Merge branch 'master' into next/arvo

This commit is contained in:
fang 2022-06-30 12:59:41 +02:00
commit ad6a5acfbc
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
21 changed files with 26825 additions and 14055 deletions

View File

@ -1,21 +0,0 @@
::
:::: /hoon/css/mar
::
/? 310
=, eyre
=, mimes:html
|_ mud=@t
++ grow :: convert to
|% ++ mime [/text/css (as-octs mud)] :: convert to %mime
++ elem ;style :: convert to %hymn
;- (trip mud)
==
++ hymn ;html:(head:"{elem}" body)
--
++ grab
|% :: convert from
++ mime |=([p=mite q=octs] (@t q.q))
++ noun @t :: clam from %noun
--
++ grad %mime
--

1
pkg/arvo/mar/css.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/css.hoon

21
pkg/base-dev/mar/css.hoon Normal file
View File

@ -0,0 +1,21 @@
::
:::: /hoon/css/mar
::
/? 310
=, eyre
=, mimes:html
|_ mud=@t
++ grow :: convert to
|% ++ mime [/text/css (as-octs mud)] :: convert to %mime
++ elem ;style :: convert to %hymn
;- (trip mud)
==
++ hymn ;html:(head:"{elem}" body)
--
++ grab
|% :: convert from
++ mime |=([p=mite q=octs] (@t q.q))
++ noun @t :: clam from %noun
--
++ grad %mime
--

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
:~ title+'System' :~ title+'System'
info+'An app launcher for Urbit.' info+'An app launcher for Urbit.'
color+0xee.5432 color+0xee.5432
glob-http+['https://bootstrap.urbit.org/glob-0v2.p3f6i.19q8d.lsgcb.mckg7.dtu8f.glob' 0v2.p3f6i.19q8d.lsgcb.mckg7.dtu8f] glob-http+['https://bootstrap.urbit.org/glob-0v5.kgrq2.gp725.bo5bk.dmr7d.h41qk.glob' 0v5.kgrq2.gp725.bo5bk.dmr7d.h41qk]
::glob-ames+~zod^0v0 ::glob-ames+~zod^0v0
base+'grid' base+'grid'
version+[1 1 3] version+[1 1 3]

1
pkg/garden/mar/css.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/css.hoon

View File

@ -18,7 +18,7 @@
"@radix-ui/react-toggle": "^0.0.10", "@radix-ui/react-toggle": "^0.0.10",
"@tlon/sigil-js": "^1.4.4", "@tlon/sigil-js": "^1.4.4",
"@types/lodash": "^4.14.172", "@types/lodash": "^4.14.172",
"@urbit/api": "^2.1.0", "@urbit/api": "^2.1.1",
"@urbit/http-api": "^2.1.0", "@urbit/http-api": "^2.1.0",
"big-integer": "^1.6.48", "big-integer": "^1.6.48",
"classnames": "^2.3.1", "classnames": "^2.3.1",
@ -1468,9 +1468,9 @@
} }
}, },
"node_modules/@urbit/api": { "node_modules/@urbit/api": {
"version": "2.1.0", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/@urbit/api/-/api-2.1.0.tgz", "resolved": "https://registry.npmjs.org/@urbit/api/-/api-2.1.1.tgz",
"integrity": "sha512-2njwpvZ2s23gp5C4v9uDynU1wxrN33+vloqpvlErUhMR/4R6mXE4cMvsZzj/fCGOa0J3LRV/If7XmgG+kY69Tg==", "integrity": "sha512-QRlqhtJ73q+pgMdSwuOO62HlxA7/2c5ylCcOUT01LXkJ2LTVCl5u+QnejdDvUmqjOuN2PyZk7df30xJVg6rC2A==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"big-integer": "^1.6.48", "big-integer": "^1.6.48",
@ -8257,9 +8257,9 @@
} }
}, },
"@urbit/api": { "@urbit/api": {
"version": "2.1.0", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/@urbit/api/-/api-2.1.0.tgz", "resolved": "https://registry.npmjs.org/@urbit/api/-/api-2.1.1.tgz",
"integrity": "sha512-2njwpvZ2s23gp5C4v9uDynU1wxrN33+vloqpvlErUhMR/4R6mXE4cMvsZzj/fCGOa0J3LRV/If7XmgG+kY69Tg==", "integrity": "sha512-QRlqhtJ73q+pgMdSwuOO62HlxA7/2c5ylCcOUT01LXkJ2LTVCl5u+QnejdDvUmqjOuN2PyZk7df30xJVg6rC2A==",
"requires": { "requires": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"big-integer": "^1.6.48", "big-integer": "^1.6.48",

View File

@ -15,8 +15,8 @@
"tsc": "tsc --noEmit" "tsc": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"@radix-ui/react-checkbox": "^0.1.5",
"@fingerprintjs/fingerprintjs": "^3.3.3", "@fingerprintjs/fingerprintjs": "^3.3.3",
"@radix-ui/react-checkbox": "^0.1.5",
"@radix-ui/react-dialog": "^0.0.20", "@radix-ui/react-dialog": "^0.0.20",
"@radix-ui/react-dropdown-menu": "^0.0.23", "@radix-ui/react-dropdown-menu": "^0.0.23",
"@radix-ui/react-icons": "^1.1.0", "@radix-ui/react-icons": "^1.1.0",
@ -25,7 +25,7 @@
"@radix-ui/react-toggle": "^0.0.10", "@radix-ui/react-toggle": "^0.0.10",
"@tlon/sigil-js": "^1.4.4", "@tlon/sigil-js": "^1.4.4",
"@types/lodash": "^4.14.172", "@types/lodash": "^4.14.172",
"@urbit/api": "^2.1.0", "@urbit/api": "^2.1.1",
"@urbit/http-api": "^2.1.0", "@urbit/http-api": "^2.1.0",
"big-integer": "^1.6.48", "big-integer": "^1.6.48",
"classnames": "^2.3.1", "classnames": "^2.3.1",

View File

@ -72,7 +72,6 @@ export const Leap = React.forwardRef(
useEffect(() => { useEffect(() => {
const newMatch = getMatch(rawInput); const newMatch = getMatch(rawInput);
if (newMatch && rawInput) { if (newMatch && rawInput) {
useLeapStore.setState({ selectedMatch: newMatch }); useLeapStore.setState({ selectedMatch: newMatch });
} }
@ -112,7 +111,10 @@ export const Leap = React.forwardRef(
const navigateByInput = useCallback( const navigateByInput = useCallback(
(input: string) => { (input: string) => {
const normalizedValue = input.trim().replace(/(~?[\w^_-]{3,13})\//, '$1/apps/'); const normalizedValue = input
.trim()
.replace('%', '')
.replace(/(~?[\w^_-]{3,13})\//, '$1/apps/$1/');
push(`/leap/${menu}/${normalizedValue}`); push(`/leap/${menu}/${normalizedValue}`);
}, },
[menu] [menu]

View File

@ -7,6 +7,7 @@ module.exports = {
// Because we use styled system, and use // Because we use styled system, and use
// the convention of each prop on a new line // the convention of each prop on a new line
// we probably shouldn't keep this on // we probably shouldn't keep this on
'max-lines-per-function': ['off', {}] 'max-lines-per-function': ['off', {}],
'max-lines': ['off', {}]
} }
}; };

File diff suppressed because it is too large Load Diff

View File

@ -37,10 +37,10 @@
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"querystring": "^0.2.0", "querystring": "^0.2.0",
"react": "^17.0.2", "react": "^17.0.2",
"react-codemirror2": "git@github.com:scniro/react-codemirror2", "react-codemirror2-react-17": "^1.0.0",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-helmet": "^6.1.0", "react-helmet": "^6.1.0",
"react-markdown": "^8.0.3", "react-markdown": "^5.0.3",
"react-oembed-container": "^1.0.1", "react-oembed-container": "^1.0.1",
"react-router-dom": "^5.2.0", "react-router-dom": "^5.2.0",
"react-use-gesture": "^9.1.3", "react-use-gesture": "^9.1.3",

View File

@ -5,7 +5,7 @@ import 'codemirror/addon/hint/show-hint';
import 'codemirror/lib/codemirror.css'; import 'codemirror/lib/codemirror.css';
import 'codemirror/mode/markdown/markdown'; import 'codemirror/mode/markdown/markdown';
import React, { useRef, ClipboardEvent, useEffect, useImperativeHandle } from 'react'; import React, { useRef, ClipboardEvent, useEffect, useImperativeHandle } from 'react';
import { Controlled as CodeEditor } from 'react-codemirror2'; import { Controlled as CodeEditor } from 'react-codemirror2-react-17';
import styled from 'styled-components'; import styled from 'styled-components';
import { MOBILE_BROWSER_REGEX } from '~/logic/lib/util'; import { MOBILE_BROWSER_REGEX } from '~/logic/lib/util';
import useSettingsState from '~/logic/state/settings'; import useSettingsState from '~/logic/state/settings';

View File

@ -6,7 +6,7 @@ import 'codemirror/lib/codemirror.css';
import 'codemirror/mode/markdown/markdown'; import 'codemirror/mode/markdown/markdown';
import { useFormikContext } from 'formik'; import { useFormikContext } from 'formik';
import React, { useCallback, useRef } from 'react'; import React, { useCallback, useRef } from 'react';
import { UnControlled as CodeEditor } from 'react-codemirror2'; import { UnControlled as CodeEditor } from 'react-codemirror2-react-17';
import { Prompt } from 'react-router-dom'; import { Prompt } from 'react-router-dom';
import { useFileUpload } from '~/logic/lib/useFileUpload'; import { useFileUpload } from '~/logic/lib/useFileUpload';
import { IuseStorage } from '~/logic/lib/useStorage'; import { IuseStorage } from '~/logic/lib/useStorage';
@ -96,7 +96,7 @@ export function MarkdownEditor(
p={1} p={1}
border={1} border={1}
borderColor="lightGray" borderColor="lightGray"
backgroundColor={disabled ? '#eee' : '#fff'} backgroundColor={disabled ? 'lightGray' : 'white'}
borderRadius={2} borderRadius={2}
height={['calc(100% - 22vh)', '100%']} height={['calc(100% - 22vh)', '100%']}
{...boxProps} {...boxProps}

View File

@ -2,26 +2,12 @@ import { Anchor, Text } from '@tlon/indigo-react';
import { Contact, Group } from '@urbit/api'; import { Contact, Group } from '@urbit/api';
import React from 'react'; import React from 'react';
import ReactMarkdown, { ReactMarkdownProps } from 'react-markdown'; import ReactMarkdown, { ReactMarkdownProps } from 'react-markdown';
import RemarkDisableTokenizers from 'remark-disable-tokenizers';
import { isValidPatp } from 'urbit-ob'; import { isValidPatp } from 'urbit-ob';
import { deSig } from '~/logic/lib/util'; import { deSig } from '~/logic/lib/util';
import { PermalinkEmbed } from '~/views/apps/permalinks/embed'; import { PermalinkEmbed } from '~/views/apps/permalinks/embed';
import { Mention } from '~/views/components/MentionText'; import { Mention } from '~/views/components/MentionText';
import RemoteContent from '~/views/components/RemoteContent'; import RemoteContent from '~/views/components/RemoteContent';
const DISABLED_BLOCK_TOKENS = [
'indentedCode',
'atxHeading',
'thematicBreak',
'list',
'setextHeading',
'html',
'definition',
'table'
];
const DISABLED_INLINE_TOKENS = [];
type RichTextProps = ReactMarkdownProps & { type RichTextProps = ReactMarkdownProps & {
disableRemoteContent?: boolean; disableRemoteContent?: boolean;
contact?: Contact; contact?: Contact;
@ -110,10 +96,6 @@ const RichText = React.memo(({ disableRemoteContent = false, ...props }: RichTex
return <Text display={props.inline ? 'inline' : 'block'} mb={2} {...props}>{paraProps.children}</Text>; return <Text display={props.inline ? 'inline' : 'block'} mb={2} {...props}>{paraProps.children}</Text>;
} }
}} }}
plugins={[[
RemarkDisableTokenizers,
{ block: DISABLED_BLOCK_TOKENS, inline: DISABLED_INLINE_TOKENS }
]]}
/> />
)); ));

View File

@ -91,7 +91,7 @@ export function GraphPermissions(props: GraphPermissionsProps) {
const initialValues = { const initialValues = {
writePerms, writePerms,
writers: writers writers: [...writers]
.filter(x => x !== hostShip), .filter(x => x !== hostShip),
readerComments: association.metadata.vip === 'reader-comments' readerComments: association.metadata.vip === 'reader-comments'
}; };
@ -104,7 +104,7 @@ export function GraphPermissions(props: GraphPermissionsProps) {
resource: association.resource, resource: association.resource,
tag: 'writers' tag: 'writers'
}; };
const allWriters = writers.map(w => `~${w}`); const allWriters = [...writers].map(w => `~${w}`);
if (values.readerComments !== readerComments) { if (values.readerComments !== readerComments) {
await airlock.poke(metadataEdit(association, { await airlock.poke(metadataEdit(association, {
vip: values.readerComments ? 'reader-comments' : '' vip: values.readerComments ? 'reader-comments' : ''

View File

@ -34,26 +34,30 @@ interface GraphMentionNode {
ship: string; ship: string;
} }
const addEmphasisToMention = (contents: Content[], content: Content, index: number) => { const addEmphasisToMention = (
contents: Content[],
content: Content,
index: number
) => {
const prevContent = contents[index - 1]; const prevContent = contents[index - 1];
const nextContent = contents[index + 1]; const nextContent = contents[index + 1];
if ( if (
'text' in content && 'text' in content &&
(content.text.trim() === '**' || content.text.trim() === '*' ) (content.text.trim() === '**' || content.text.trim() === '*')
) { ) {
return { return {
text: '' text: ''
}; };
} }
if( if (
'text' in content && 'text' in content &&
content.text.endsWith('*') && content.text.endsWith('*') &&
!content.text.startsWith('*') && !content.text.startsWith('*') &&
nextContent !== undefined && nextContent !== undefined &&
'mention' in nextContent 'mention' in nextContent
) { ) {
if (content.text.charAt((content.text.length - 2)) === '*') { if (content.text.charAt(content.text.length - 2) === '*') {
return { text: content.text.slice(0, content.text.length - 2) }; return { text: content.text.slice(0, content.text.length - 2) };
} }
return { text: content.text.slice(0, content.text.length - 1) }; return { text: content.text.slice(0, content.text.length - 1) };
@ -116,9 +120,9 @@ const codeToMdAst = (content: CodeContent) => {
}; };
}; };
const contentToMdAst = (tall: boolean) => ( const contentToMdAst =
content: Content (tall: boolean) =>
): [StitchMode, any] => { (content: Content): [StitchMode, any] => {
if ('text' in content) { if ('text' in content) {
if (content.text.toString().trim().length === 0) { if (content.text.toString().trim().length === 0) {
return [ return [
@ -146,6 +150,7 @@ const contentToMdAst = (tall: boolean) => (
} }
]; ];
} else if ('url' in content) { } else if ('url' in content) {
const images = ['.jpg', '.jpeg', '.png', '.gif', '.webp'];
return [ return [
'inline', 'inline',
{ {
@ -154,7 +159,14 @@ const contentToMdAst = (tall: boolean) => (
{ {
type: 'link', type: 'link',
url: content.url, url: content.url,
children: [{ type: 'text', value: content.url }] children: [
{
type: 'text',
value: !images.some(i => content.url.includes(i))
? content.url
: ''
}
]
} }
] ]
} }
@ -181,7 +193,7 @@ const contentToMdAst = (tall: boolean) => (
children: [] children: []
} }
]; ];
}; };
function stitchInline(a: any, b: any) { function stitchInline(a: any, b: any) {
if (!a?.children) { if (!a?.children) {
@ -230,9 +242,14 @@ function getChildren<T extends unknown>(node: T): AstContent[] {
} }
export function asParent<T extends BlockContent>(node: T): Parent | undefined { export function asParent<T extends BlockContent>(node: T): Parent | undefined {
return ['paragraph', 'heading', 'list', 'listItem', 'table', 'blockquote'].includes( return [
node.type 'paragraph',
) 'heading',
'list',
'listItem',
'table',
'blockquote'
].includes(node.type)
? (node as Parent) ? (node as Parent)
: undefined; : undefined;
} }
@ -299,20 +316,10 @@ function stitchAsts(asts: [StitchMode, GraphAstNode][]) {
); );
t[1].children.map((c, idx) => { t[1].children.map((c, idx) => {
if (c.type === 'blockquote' && t[1].children[idx +1] !== undefined && t[1].children[idx +1].type === 'paragraph') {
const next = idx !== t[1].children.length -1
? t[1].children.splice(idx +1, 1)
: [];
if (next.length > 0) {
t[1].children[idx].children.push(next[0]);
}
}
const links = []; const links = [];
function addRichEmbedURL(nodes) { function addRichEmbedURL(nodes) {
if (nodes?.children) { if (nodes?.children) {
nodes.children.filter((k) => { nodes.children.filter(k => {
if (k.type === 'link') { if (k.type === 'link') {
links.push({ links.push({
type: 'root', type: 'root',
@ -324,7 +331,7 @@ function stitchAsts(asts: [StitchMode, GraphAstNode][]) {
] ]
}); });
} else if (k?.children) { } else if (k?.children) {
k.children.filter((o) => { k.children.filter(o => {
if (o.type === 'link') { if (o.type === 'link') {
links.push({ links.push({
type: 'root', type: 'root',
@ -456,7 +463,7 @@ const renderers = {
); );
return tall ? <Box mb={2}>{inner}</Box> : inner; return tall ? <Box mb={2}>{inner}</Box> : inner;
}, },
link: (props) => { link: props => {
return ( return (
<Anchor <Anchor
display="inline" display="inline"
@ -472,9 +479,13 @@ const renderers = {
); );
}, },
list: ({ depth, ordered, children }) => { list: ({ depth, ordered, children }) => {
return ordered ? <Ol fontSize="1">{children}</Ol> : <Ul fontSize="1">{children}</Ul>; return ordered ? (
<Ol fontSize="1">{children}</Ol>
) : (
<Ul fontSize="1">{children}</Ul>
);
}, },
'graph-mention': (obj) => { 'graph-mention': obj => {
return <Mention ship={obj.ship} emphasis={obj.emphasis} />; return <Mention ship={obj.ship} emphasis={obj.emphasis} />;
}, },
image: ({ url, tall }) => ( image: ({ url, tall }) => (
@ -489,11 +500,7 @@ const renderers = {
const { link } = referenceToPermalink({ reference }); const { link } = referenceToPermalink({ reference });
return ( return (
<Box my={2} flexShrink={0}> <Box my={2} flexShrink={0}>
<PermalinkEmbed <PermalinkEmbed link={link} transcluded={transcluded} showOurContact />
link={link}
transcluded={transcluded}
showOurContact
/>
</Box> </Box>
); );
}, },
@ -561,19 +568,13 @@ export type GraphContentProps = PropFunc<typeof Box> & {
showOurContact: boolean; showOurContact: boolean;
}; };
export const GraphContent = React.memo(( export const GraphContent = React.memo((props: GraphContentProps) => {
props: GraphContentProps const { contents, tall = false, transcluded = 0, ...rest } = props;
) => {
const {
contents,
tall = false,
transcluded = 0,
...rest
} = props;
const [, ast] = stitchAsts( const [, ast] = stitchAsts(
contents contents
.map((content, index) => addEmphasisToMention(contents, content, index)) .map((content, index) => addEmphasisToMention(contents, content, index))
.map(contentToMdAst(tall))); .map(contentToMdAst(tall))
);
return ( return (
<Box {...rest}> <Box {...rest}>
<Graphdown transcluded={transcluded} ast={ast} tall={tall} /> <Graphdown transcluded={transcluded} ast={ast} tall={tall} />

View File

@ -8,8 +8,12 @@
"directory": "pkg/npm/api" "directory": "pkg/npm/api"
}, },
"type": "module", "type": "module",
"main": "dist/cjs/index.js", "main": "dist/cjs/index.cjs",
"module": "dist/esm/index.js", "module": "dist/esm/index.js",
"exports": {
"require": "./dist/cjs/index.cjs",
"import": "./dist/esm/index.js"
},
"jsdelivr": "dist/urbit-api.min.js", "jsdelivr": "dist/urbit-api.min.js",
"unpkg": "dist/urbit-api.min.js", "unpkg": "dist/urbit-api.min.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -60,13 +60,13 @@ export default [
], ],
output: [ output: [
{ {
dir: 'dist/esm', file: 'dist/esm/index.js',
format: 'esm', format: 'esm',
exports: 'named', exports: 'named',
sourcemap: true sourcemap: true,
}, },
{ {
dir: 'dist/cjs', file: 'dist/cjs/index.cjs',
format: 'cjs', format: 'cjs',
exports: 'named', exports: 'named',
sourcemap: true sourcemap: true

View File

@ -1,6 +1,6 @@
{ {
"name": "@urbit/http-api", "name": "@urbit/http-api",
"version": "2.1.0", "version": "2.1.3",
"license": "MIT", "license": "MIT",
"description": "Library to interact with an Urbit ship over HTTP", "description": "Library to interact with an Urbit ship over HTTP",
"repository": { "repository": {
@ -9,8 +9,12 @@
"directory": "pkg/npm/http-api" "directory": "pkg/npm/http-api"
}, },
"type": "module", "type": "module",
"main": "dist/cjs/index.js", "main": "dist/cjs/index.cjs",
"module": "dist/esm/index.js", "module": "dist/esm/index.js",
"exports": {
"require": "./dist/cjs/index.cjs",
"import": "./dist/esm/index.js"
},
"jsdelivr": "dist/urbit-http-api.min.js", "jsdelivr": "dist/urbit-http-api.min.js",
"unpkg": "dist/urbit-http-api.min.js", "unpkg": "dist/urbit-http-api.min.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -56,13 +56,13 @@ export default [
], ],
output: [ output: [
{ {
dir: 'dist/esm', file: 'dist/esm/index.js',
format: 'esm', format: 'esm',
exports: 'named', exports: 'named',
sourcemap: true, sourcemap: true,
}, },
{ {
dir: 'dist/cjs', file: 'dist/cjs/index.cjs',
format: 'cjs', format: 'cjs',
exports: 'named', exports: 'named',
sourcemap: true, sourcemap: true,

View File

@ -235,9 +235,9 @@ export class Urbit {
console.log('Received SSE: ', event); console.log('Received SSE: ', event);
} }
if (!event.id) return; if (!event.id) return;
this.lastEventId = parseInt(event.id, 10); const eventId = parseInt(event.id, 10);
if (this.lastEventId - this.lastAcknowledgedEventId > 20) { if (eventId - this.lastAcknowledgedEventId > 20) {
this.ack(this.lastEventId); this.ack(eventId);
} }
if (event.data && JSON.parse(event.data)) { if (event.data && JSON.parse(event.data)) {
@ -312,7 +312,7 @@ export class Urbit {
* *
*/ */
reset() { reset() {
if(this.verbose) { if (this.verbose) {
console.log('resetting'); console.log('resetting');
} }
this.delete(); this.delete();