@yaks/browse 0.0.0-stage → 0.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +324 -2
- package/_dist/app.d.ts +8 -0
- package/_dist/app.d.ts.map +1 -0
- package/_dist/cli.d.ts +16 -0
- package/_dist/cli.d.ts.map +1 -0
- package/_dist/hosting.d.ts +24 -0
- package/_dist/hosting.d.ts.map +1 -0
- package/_dist/mod.d.ts +7 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/types.d.ts +5 -0
- package/_dist/types.d.ts.map +1 -0
- package/_dist/url.d.ts +2 -0
- package/_dist/url.d.ts.map +1 -0
- package/app.js +10 -0
- package/app.js.map +1 -0
- package/app.ts +10 -0
- package/browser-links.js +22 -0
- package/browser-links.js.map +1 -0
- package/browser-links.ts +28 -0
- package/cli.js +172 -0
- package/cli.js.map +1 -0
- package/cli.ts +168 -0
- package/client.js +748 -0
- package/client.js.map +1 -0
- package/client.ts +734 -0
- package/clipboard.js +18 -0
- package/clipboard.js.map +1 -0
- package/clipboard.ts +17 -0
- package/commands.js +1157 -0
- package/commands.js.map +1 -0
- package/commands.ts +1108 -0
- package/components/Ansi.tsx +160 -0
- package/components/App.tsx +446 -0
- package/components/Canvas.tsx +625 -0
- package/components/Card.tsx +276 -0
- package/components/Chat.tsx +205 -0
- package/components/Configuration.tsx +218 -0
- package/components/Decision.tsx +49 -0
- package/components/Dot.tsx +52 -0
- package/components/Entity.tsx +609 -0
- package/components/Fault.tsx +43 -0
- package/components/Filter.tsx +103 -0
- package/components/Keybindings.tsx +100 -0
- package/components/Keys.tsx +67 -0
- package/components/Markdown.tsx +90 -0
- package/components/Navigation.tsx +161 -0
- package/components/New.tsx +490 -0
- package/components/Peek.tsx +168 -0
- package/components/Prio.tsx +20 -0
- package/components/Run.tsx +263 -0
- package/components/Search.tsx +280 -0
- package/components/Stamp.tsx +44 -0
- package/components/Status.tsx +514 -0
- package/components/Sync.tsx +173 -0
- package/components/Tile.tsx +50 -0
- package/components/answered.js +23 -0
- package/components/answered.js.map +1 -0
- package/components/answered.ts +25 -0
- package/components/comp.js +11 -0
- package/components/comp.js.map +1 -0
- package/components/comp.ts +10 -0
- package/components/drag.js +173 -0
- package/components/drag.js.map +1 -0
- package/components/drag.ts +198 -0
- package/components/fields.tsx +90 -0
- package/components/fixtures/README.md +10 -0
- package/components/fixtures/archetypes.json +3646 -0
- package/components/hits.js +63 -0
- package/components/hits.js.map +1 -0
- package/components/hits.ts +84 -0
- package/components/icons.tsx +177 -0
- package/components/inspect.tsx +331 -0
- package/components/mount.ts +79 -0
- package/components/nav.tsx +479 -0
- package/components/offers.js +26 -0
- package/components/offers.js.map +1 -0
- package/components/offers.ts +54 -0
- package/components/page.js +21 -0
- package/components/page.js.map +1 -0
- package/components/page.ts +18 -0
- package/components/read.js +5 -0
- package/components/read.js.map +1 -0
- package/components/read.ts +7 -0
- package/components/registry.js +285 -0
- package/components/registry.js.map +1 -0
- package/components/registry.ts +317 -0
- package/components/session_status.tsx +115 -0
- package/components/subscriptions.js +149 -0
- package/components/subscriptions.js.map +1 -0
- package/components/subscriptions.ts +161 -0
- package/components/title.tsx +21 -0
- package/components/useQuery.js +166 -0
- package/components/useQuery.js.map +1 -0
- package/components/useQuery.ts +211 -0
- package/components/views/Board.tsx +450 -0
- package/components/views/BoardTile.tsx +65 -0
- package/components/views/Dashboard.tsx +148 -0
- package/components/views/Debug.tsx +445 -0
- package/components/views/Dependency.tsx +51 -0
- package/components/views/Entry.tsx +500 -0
- package/components/views/Gist.tsx +28 -0
- package/components/views/Inline.tsx +54 -0
- package/components/views/Json.tsx +19 -0
- package/components/views/Layout.tsx +211 -0
- package/components/views/List.tsx +238 -0
- package/components/views/Md.tsx +43 -0
- package/components/views/Media.tsx +48 -0
- package/components/views/Memory.tsx +32 -0
- package/components/views/Relate.tsx +205 -0
- package/components/views/Search.tsx +42 -0
- package/components/views/Session.tsx +850 -0
- package/components/views/SessionManage.tsx +127 -0
- package/components/views/Show.tsx +758 -0
- package/components/views/Shown.tsx +72 -0
- package/components/views/Split.tsx +58 -0
- package/components/views/TaskTile.tsx +37 -0
- package/components/views/Title.tsx +105 -0
- package/components/views/Wake.tsx +77 -0
- package/components/views/Web.tsx +49 -0
- package/components/wells.js +30 -0
- package/components/wells.js.map +1 -0
- package/components/wells.ts +33 -0
- package/configuration.js +38 -0
- package/configuration.js.map +1 -0
- package/configuration.ts +41 -0
- package/decision_sync.js +88 -0
- package/decision_sync.js.map +1 -0
- package/decision_sync.ts +93 -0
- package/deno.json +1 -0
- package/domain-host.tsx +108 -0
- package/edge.js +193 -0
- package/edge.js.map +1 -0
- package/edge.ts +196 -0
- package/entry_log.js +241 -0
- package/entry_log.js.map +1 -0
- package/entry_log.ts +214 -0
- package/failure.js +22 -0
- package/failure.js.map +1 -0
- package/failure.ts +34 -0
- package/front.json +61 -0
- package/highlight.js +143 -0
- package/highlight.js.map +1 -0
- package/highlight.ts +149 -0
- package/history.js +68 -0
- package/history.js.map +1 -0
- package/history.ts +72 -0
- package/host_commands.js +107 -0
- package/host_commands.js.map +1 -0
- package/host_commands.ts +38 -0
- package/hosting.js +53 -0
- package/hosting.js.map +1 -0
- package/hosting.ts +72 -0
- package/idb.js +14 -0
- package/idb.js.map +1 -0
- package/idb.ts +15 -0
- package/index.js +232 -0
- package/index.js.map +1 -0
- package/index.ts +252 -0
- package/keybindings.js +136 -0
- package/keybindings.js.map +1 -0
- package/keybindings.ts +37 -0
- package/kit.js +103 -0
- package/kit.js.map +1 -0
- package/kit.ts +119 -0
- package/layout.js +254 -0
- package/layout.js.map +1 -0
- package/layout.ts +210 -0
- package/legacy_outbox.js +53 -0
- package/legacy_outbox.js.map +1 -0
- package/legacy_outbox.ts +63 -0
- package/live.js +2883 -0
- package/live.js.map +1 -0
- package/live.ts +3334 -0
- package/live_archetypes.js +92 -0
- package/live_archetypes.js.map +1 -0
- package/live_archetypes.ts +113 -0
- package/live_client.js +145 -0
- package/live_client.js.map +1 -0
- package/live_client.ts +120 -0
- package/main.tsx +5 -0
- package/mod.js +7 -0
- package/mod.js.map +1 -0
- package/mod.ts +7 -0
- package/mount.tsx +50 -0
- package/navigation.js +120 -0
- package/navigation.js.map +1 -0
- package/navigation.ts +152 -0
- package/near.js +83 -0
- package/near.js.map +1 -0
- package/near.ts +83 -0
- package/new.js +295 -0
- package/new.js.map +1 -0
- package/new.ts +361 -0
- package/outbox.js +112 -0
- package/outbox.js.map +1 -0
- package/outbox.ts +129 -0
- package/owner.js +39 -0
- package/owner.js.map +1 -0
- package/owner.ts +37 -0
- package/package.json +81 -4
- package/paste.js +157 -0
- package/paste.js.map +1 -0
- package/paste.ts +122 -0
- package/props.js +303 -0
- package/props.js.map +1 -0
- package/props.ts +358 -0
- package/providers.js +136 -0
- package/providers.js.map +1 -0
- package/providers.ts +194 -0
- package/query.js +987 -0
- package/query.js.map +1 -0
- package/query.ts +1113 -0
- package/remote.js +37 -0
- package/remote.js.map +1 -0
- package/remote.ts +46 -0
- package/resolver.js +149 -0
- package/resolver.js.map +1 -0
- package/resolver.ts +213 -0
- package/rfc2047.js +37 -0
- package/rfc2047.js.map +1 -0
- package/rfc2047.ts +40 -0
- package/row_holds.js +107 -0
- package/row_holds.js.map +1 -0
- package/row_holds.ts +93 -0
- package/served.ts +42 -0
- package/session_worktree.js +7 -0
- package/session_worktree.js.map +1 -0
- package/session_worktree.ts +16 -0
- package/sessions.js +57 -0
- package/sessions.js.map +1 -0
- package/sessions.ts +53 -0
- package/sha.js +161 -0
- package/sha.js.map +1 -0
- package/sha.ts +164 -0
- package/styles.css +2823 -0
- package/subs.js +36 -0
- package/subs.js.map +1 -0
- package/subs.ts +40 -0
- package/terminal-route.js +13 -0
- package/terminal-route.js.map +1 -0
- package/terminal-route.ts +17 -0
- package/terminal.js +251 -0
- package/terminal.js.map +1 -0
- package/terminal.ts +186 -0
- package/time.js +142 -0
- package/time.js.map +1 -0
- package/time.ts +133 -0
- package/title.js +25 -0
- package/title.js.map +1 -0
- package/title.ts +50 -0
- package/tui/doc.ts +6 -0
- package/tui/testing.ts +19 -0
- package/twin.js +11 -0
- package/twin.js.map +1 -0
- package/twin.ts +13 -0
- package/types.js +456 -0
- package/types.js.map +1 -0
- package/types.ts +1370 -0
- package/url.js +77 -0
- package/url.js.map +1 -0
- package/url.ts +85 -0
- package/verb.js +82 -0
- package/verb.js.map +1 -0
- package/verb.ts +137 -0
- package/warmth.js +41 -0
- package/warmth.js.map +1 -0
- package/warmth.ts +54 -0
- package/wire.js +86 -0
- package/wire.js.map +1 -0
- package/wire.ts +63 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
// The ephemeral filter — typed in the titlebar, felt in the face. It ANDs
|
|
3
|
+
// into the view's own query only while it's typed, never stored:
|
|
4
|
+
// board.query is the saved filter, this is the glance. Same grammar as
|
|
5
|
+
// everywhere (query.ts), same completion as every query field; a line that
|
|
6
|
+
// doesn't parse yet filters nothing — inert, because a bar mid-keystroke is
|
|
7
|
+
// no place to throw. Escape clears; blurring empty leaves nothing. The input
|
|
8
|
+
// (FilterInput, rendered by the card chrome) and the rows it screens
|
|
9
|
+
// (passOf, read by the face) live in different subtrees, and the wire
|
|
10
|
+
// between them is the page's own graph: the line is the field
|
|
11
|
+
// `filter:<eid>` there (fields.tsx), keyed by the viewed entity, so
|
|
12
|
+
// switching tabs (Board ⇄ List) keeps the glance, and what is typed is the
|
|
13
|
+
// person's draft, so a reload, another tab and the terminal keep it too.
|
|
14
|
+
import type { SubscriptionRead } from '../live.ts'
|
|
15
|
+
import { editKeys } from 'jsr:@yaks/ux@0.2.36/edit-keys'
|
|
16
|
+
import { parseQuery } from '../query.ts'
|
|
17
|
+
import { useQueryResult } from './useQuery.ts'
|
|
18
|
+
import { block } from 'jsr:@yaks/ui@0.2.36'
|
|
19
|
+
import { fields } from './fields.tsx'
|
|
20
|
+
|
|
21
|
+
let Frame = block('div', 'Filter', {})
|
|
22
|
+
|
|
23
|
+
/** The field a viewed entity's filter line is typed in. */
|
|
24
|
+
export let filterField = (eid: string) => `filter:${eid}`
|
|
25
|
+
|
|
26
|
+
// the faces that listen — the titlebar consults this to decide whether
|
|
27
|
+
// the current view earns the input or just the spacer
|
|
28
|
+
export let filterable = new Set(['Board', 'List'])
|
|
29
|
+
|
|
30
|
+
// the bar's current text, for a face that must know whether it is SCREENING
|
|
31
|
+
// at all: a count the server computed over the saved query is the truth only
|
|
32
|
+
// while nothing narrows it here. Before the bar has mounted, a host's
|
|
33
|
+
// `initial` line is the one it will show. Reading it subscribes the caller.
|
|
34
|
+
export let useFilterLine = (eid: string, initial = ''): string =>
|
|
35
|
+
fields.useRow(filterField(eid))?.text ?? initial
|
|
36
|
+
|
|
37
|
+
// Windowed faces filter BEFORE taking a page. A half-typed expression stays
|
|
38
|
+
// inert, just as it does for the local faces, but a valid one rides the saved
|
|
39
|
+
// query instead of filtering an already-truncated page of cached rows.
|
|
40
|
+
export let useFilteredQuery = (eid: string, query: string): string => {
|
|
41
|
+
let line = useFilterLine(eid).trim()
|
|
42
|
+
try {
|
|
43
|
+
parseQuery(line)
|
|
44
|
+
return line ? query + '&' + line : query
|
|
45
|
+
} catch {
|
|
46
|
+
return query
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// the face's half: the current pass predicate for this entity's rows
|
|
51
|
+
export type Pass = ((eid: string) => boolean) & {
|
|
52
|
+
subscription?: SubscriptionRead
|
|
53
|
+
ready: boolean
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export let usePassOf = (
|
|
57
|
+
eid: string,
|
|
58
|
+
initial = '',
|
|
59
|
+
): Pass => {
|
|
60
|
+
let line = useFilterLine(eid, initial)
|
|
61
|
+
let valid = true
|
|
62
|
+
try {
|
|
63
|
+
parseQuery(line)
|
|
64
|
+
} catch {
|
|
65
|
+
valid = false
|
|
66
|
+
}
|
|
67
|
+
// Text membership is FTS5-owned, so even this transient screen reads the
|
|
68
|
+
// same server subscription as a saved board instead of tokenizing locally.
|
|
69
|
+
let result = useQueryResult(valid ? line : '')
|
|
70
|
+
let hits = new Set(result.eids)
|
|
71
|
+
let pass: Pass = Object.assign(
|
|
72
|
+
!line.trim() || !valid ? () => true : (row: string) => hits.has(row),
|
|
73
|
+
{
|
|
74
|
+
ready: !line.trim() || !valid || result.ready,
|
|
75
|
+
subscription: result.subscription,
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
return pass
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// the titlebar's half: the query field for this entity's line. What is typed
|
|
82
|
+
// there is the person's draft (./drafts.ts), so a remount, a reload, another
|
|
83
|
+
// tab and the terminal's board all narrow by it until Escape clears it.
|
|
84
|
+
export let FilterInput = (
|
|
85
|
+
{ eid, initial = '' }: { eid: string; initial?: string },
|
|
86
|
+
) => {
|
|
87
|
+
let id = filterField(eid)
|
|
88
|
+
return (
|
|
89
|
+
<Frame>
|
|
90
|
+
<fields.Filter
|
|
91
|
+
id={id}
|
|
92
|
+
initial={initial}
|
|
93
|
+
placeholder='filter…'
|
|
94
|
+
onKey={editKeys({
|
|
95
|
+
cancel: (el) => {
|
|
96
|
+
fields.set(id, '')
|
|
97
|
+
el.blur()
|
|
98
|
+
},
|
|
99
|
+
})}
|
|
100
|
+
/>
|
|
101
|
+
</Frame>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
// The web keybinding card and its global `?` door.
|
|
3
|
+
import { useObserved } from 'jsr:@yaks/ux@0.2.36'
|
|
4
|
+
import { signal } from 'npm:@preact/signals-core@1.14.5'
|
|
5
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import { useEffect, useLayoutEffect, useRef } from 'npm:react@19.3.0'
|
|
6
|
+
import { capable, mode } from '../live.ts'
|
|
7
|
+
import { webKeys } from '../keybindings.ts'
|
|
8
|
+
import { block, Modal } from 'jsr:@yaks/ui@0.2.36'
|
|
9
|
+
import { frontOverlay } from 'jsr:@yaks/ui@0.2.36/overlays'
|
|
10
|
+
|
|
11
|
+
export let keybindingsOpen = signal(false)
|
|
12
|
+
|
|
13
|
+
export let keybindingKey = (
|
|
14
|
+
key: string,
|
|
15
|
+
repeat = false,
|
|
16
|
+
typing = false,
|
|
17
|
+
) => {
|
|
18
|
+
if (keybindingsOpen.value) {
|
|
19
|
+
if (key != '?' && key != 'Escape') return false
|
|
20
|
+
keybindingsOpen.value = false
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
if (mode.value != 'normal' || repeat || typing || key != '?') return false
|
|
24
|
+
keybindingsOpen.value = true
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let Frame = block('div', 'Keybindings', {
|
|
29
|
+
List: 'dl',
|
|
30
|
+
Row: 'div',
|
|
31
|
+
Keys: 'dt',
|
|
32
|
+
About: 'dd',
|
|
33
|
+
})
|
|
34
|
+
let { List, Row, Keys, About } = Frame
|
|
35
|
+
let close = () => keybindingsOpen.value = false
|
|
36
|
+
|
|
37
|
+
export let Keybindings = () => {
|
|
38
|
+
let dialog = useRef<HTMLDialogElement>(null)
|
|
39
|
+
let opened = useObserved(keybindingsOpen)
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
let key = (e: KeyboardEvent) => {
|
|
43
|
+
if (e.key != '?' || (!keybindingsOpen.value && frontOverlay(document))) {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
let typing = e.target instanceof HTMLElement &&
|
|
47
|
+
e.target.matches('input, textarea, select, [contenteditable]')
|
|
48
|
+
if (keybindingKey(e.key, e.repeat, typing)) e.preventDefault()
|
|
49
|
+
}
|
|
50
|
+
addEventListener('keydown', key, true)
|
|
51
|
+
return () => removeEventListener('keydown', key, true)
|
|
52
|
+
}, [])
|
|
53
|
+
|
|
54
|
+
useLayoutEffect(() => {
|
|
55
|
+
let node = dialog.current
|
|
56
|
+
if (!opened || !node) return
|
|
57
|
+
node.showModal?.()
|
|
58
|
+
return () => {
|
|
59
|
+
if (node.open) node.close()
|
|
60
|
+
}
|
|
61
|
+
}, [opened])
|
|
62
|
+
|
|
63
|
+
if (!opened) return null
|
|
64
|
+
return (
|
|
65
|
+
<Modal
|
|
66
|
+
className='Keybindings'
|
|
67
|
+
elRef={dialog}
|
|
68
|
+
aria-labelledby='keybindings-title'
|
|
69
|
+
onCancel={close}
|
|
70
|
+
onClose={close}
|
|
71
|
+
onMouseDown={(e: MouseEvent) => {
|
|
72
|
+
if (e.target == e.currentTarget) close()
|
|
73
|
+
}}
|
|
74
|
+
onPointerDown={(e: PointerEvent) => e.stopPropagation()}
|
|
75
|
+
>
|
|
76
|
+
<Modal.Body className='Keybindings_Body'>
|
|
77
|
+
<Modal.Head
|
|
78
|
+
title='Keybindings'
|
|
79
|
+
titleId='keybindings-title'
|
|
80
|
+
close={{ onClick: close }}
|
|
81
|
+
/>
|
|
82
|
+
<List>
|
|
83
|
+
{webKeys.filter((b) => !b.plugin || capable(b.plugin)).map((
|
|
84
|
+
binding,
|
|
85
|
+
) => (
|
|
86
|
+
<Row key={binding.keys.join('-')}>
|
|
87
|
+
<Keys>
|
|
88
|
+
{binding.keys.flatMap((key, i) => [
|
|
89
|
+
i > 0 ? ' / ' : null,
|
|
90
|
+
<kbd key={key}>{key}</kbd>,
|
|
91
|
+
])}
|
|
92
|
+
</Keys>
|
|
93
|
+
<About>{binding.about}</About>
|
|
94
|
+
</Row>
|
|
95
|
+
))}
|
|
96
|
+
</List>
|
|
97
|
+
</Modal.Body>
|
|
98
|
+
</Modal>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
// The box a key is pasted in, on a task that asks a person for one
|
|
3
|
+
// (@yaks/connections `asks`): one for each connection it asks for that holds
|
|
4
|
+
// no working key yet. Saving writes the key through the graph, never through
|
|
5
|
+
// the outbox, and the server's vault keeps it; the task is completed once the
|
|
6
|
+
// key is checked and kept where it is used (@yaks/connections
|
|
7
|
+
// `connection_given`).
|
|
8
|
+
import { fieldsOf, KeyForm, pasted } from 'jsr:@yaks/connections@0.2.36/form'
|
|
9
|
+
import { integrationEid } from 'jsr:@yaks/connections@0.2.36/identity'
|
|
10
|
+
import type { Field } from 'jsr:@yaks/connections@0.2.36/form'
|
|
11
|
+
import { Markdown } from 'jsr:@yaks/markdown@0.2.36'
|
|
12
|
+
import { type Ent, vocab } from '../types.ts'
|
|
13
|
+
import { ent } from '../live.ts'
|
|
14
|
+
import { saveKey } from '../configuration.ts'
|
|
15
|
+
import { bundle } from './registry.ts'
|
|
16
|
+
import { useQueryResult } from './useQuery.ts'
|
|
17
|
+
import { useEntity } from './subscriptions.ts'
|
|
18
|
+
|
|
19
|
+
type Connection = { integration?: string; status?: string }
|
|
20
|
+
type Integration = {
|
|
21
|
+
title?: string
|
|
22
|
+
fields?: Field[]
|
|
23
|
+
example?: string
|
|
24
|
+
instructions?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let Asked = ({ eid }: { eid: string }) => {
|
|
28
|
+
useEntity(eid, 'connection.integration,connection.status,secret.name')
|
|
29
|
+
let c = ent(eid).connection as Connection | undefined
|
|
30
|
+
let name = c?.integration
|
|
31
|
+
let at = name ? integrationEid(name) : undefined
|
|
32
|
+
useEntity(
|
|
33
|
+
at,
|
|
34
|
+
'integration.title,integration.fields,integration.example,integration.instructions',
|
|
35
|
+
)
|
|
36
|
+
if (!name || !c?.status) return null
|
|
37
|
+
let i = ent(at!).integration as Integration | undefined
|
|
38
|
+
let fields = fieldsOf(i)
|
|
39
|
+
return (
|
|
40
|
+
<KeyForm
|
|
41
|
+
id={eid}
|
|
42
|
+
title={`Key for ${i?.title || name}`}
|
|
43
|
+
fields={fields}
|
|
44
|
+
status={c.status}
|
|
45
|
+
howTo={i?.instructions && <Markdown source={i.instructions} />}
|
|
46
|
+
save={(given) => saveKey(pasted(bundle(ent(eid)), name, fields, given))}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The connections `e` asks for, each with its box. */
|
|
52
|
+
export let Keys = ({ e }: { e: Ent }) => {
|
|
53
|
+
let on = !!e.task && !!vocab.comp('asks')
|
|
54
|
+
let asks = useQueryResult(
|
|
55
|
+
on ? `.edge.from=${e.eid}&.asks&.fields=edge.to` : '',
|
|
56
|
+
on,
|
|
57
|
+
true,
|
|
58
|
+
)
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
{asks.eids.map((a) => {
|
|
62
|
+
let to = (ent(a).edge as { to?: string } | undefined)?.to
|
|
63
|
+
return to ? <Asked key={to} eid={to} /> : null
|
|
64
|
+
})}
|
|
65
|
+
</>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
// Markdown in browse is @yaks/markdown, drawn as nodes in the face its caller
|
|
3
|
+
// chooses, so it keeps that face's layout, gestures and CSS, in the browser
|
|
4
|
+
// and the terminal alike. Markup a body wrote stays words; what browse adds is
|
|
5
|
+
// where an id leads (`refs`), what an eid is called (`ids`: the id of an
|
|
6
|
+
// entity the page already holds) and how code is coloured (`code`).
|
|
7
|
+
//
|
|
8
|
+
// An id leads to its page here, its anchor carrying data-ref so nav.tsx's
|
|
9
|
+
// delegated listeners give it the in-app open and entity menu. A hex word
|
|
10
|
+
// quoted in code is a commit, linked to its project's repository when the
|
|
11
|
+
// caller knows one; a whole SHA is the commit's own entity.
|
|
12
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import type { ComponentType, ReactNode } from 'npm:react@19.3.0'
|
|
13
|
+
import {
|
|
14
|
+
blocks,
|
|
15
|
+
Host,
|
|
16
|
+
MarkdownInline,
|
|
17
|
+
type Options,
|
|
18
|
+
parse,
|
|
19
|
+
reactNode,
|
|
20
|
+
type Refs,
|
|
21
|
+
type Run,
|
|
22
|
+
} from 'jsr:@yaks/markdown@0.2.36'
|
|
23
|
+
import { highlight } from '../highlight.ts'
|
|
24
|
+
import { EID } from '../types.ts'
|
|
25
|
+
import { entityPath } from '../url.ts'
|
|
26
|
+
import { heldId } from '../live.ts'
|
|
27
|
+
|
|
28
|
+
let SHA = /^[0-9a-f]{7,40}$/i
|
|
29
|
+
|
|
30
|
+
// A project supplies the repository root; a commit is one stable page below
|
|
31
|
+
// it. Only an http address can become a link, since repo settings ride the
|
|
32
|
+
// same untrusted graph as prose.
|
|
33
|
+
export let commitUrl = (repo: string | null | undefined, sha: string) => {
|
|
34
|
+
let root = String(repo ?? '').trim().replace(/\/+$/, '')
|
|
35
|
+
return SHA.test(sha) && /^https?:\/\//i.test(root)
|
|
36
|
+
? `${root}/commit/${sha}`
|
|
37
|
+
: undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let HEXWORD = /^[0-9a-f]+$/i
|
|
41
|
+
|
|
42
|
+
/** Where an id leads in browse, for prose that belongs to `repo`'s project. */
|
|
43
|
+
export let refs = (repo?: string | null): Refs => (id) =>
|
|
44
|
+
HEXWORD.test(id) && !EID.test(id) ? commitUrl(repo, id) : entityPath(id)
|
|
45
|
+
|
|
46
|
+
/** Code coloured by highlight.ts, as runs of classed text. */
|
|
47
|
+
export let code = (text: string, language?: string): Run[] =>
|
|
48
|
+
highlight(text, language).lines.flatMap((line, i) =>
|
|
49
|
+
i ? [{ text: '\n', classes: [] }, ...line] : line
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
/** What browse gives every Markdown beneath it, inspect pages included. */
|
|
53
|
+
export let host: Options = { refs: refs(), ids: heldId, code }
|
|
54
|
+
|
|
55
|
+
let hosts = new Map<string, Options>()
|
|
56
|
+
let hosted = (repo?: string | null) => {
|
|
57
|
+
let key = repo ?? ''
|
|
58
|
+
let found = hosts.get(key)
|
|
59
|
+
if (!found) hosts.set(key, found = { refs: refs(repo), ids: heldId, code })
|
|
60
|
+
return found
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Some Markdown as the nodes browse draws it: a document's blocks, or a
|
|
64
|
+
* title's inline line, its links and ids flattened to words because a title
|
|
65
|
+
* is usually itself the link. */
|
|
66
|
+
export let markup = (
|
|
67
|
+
text: string,
|
|
68
|
+
repo?: string | null,
|
|
69
|
+
inline = false,
|
|
70
|
+
): ReactNode =>
|
|
71
|
+
inline ? <MarkdownInline source={text} flat /> : blocks(
|
|
72
|
+
parse(text, { breaks: false }),
|
|
73
|
+
reactNode,
|
|
74
|
+
hosted(repo),
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
/** Browse's Markdown for everything beneath `children`. */
|
|
78
|
+
export let MarkdownHost = ({ children }: { children: ReactNode }) => (
|
|
79
|
+
<Host.Provider value={host}>{children}</Host.Provider>
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
export let Markdown = (
|
|
83
|
+
{ as: Face = 'div', text, repo, inline, ...props }: {
|
|
84
|
+
as?: ComponentType<Record<string, unknown>> | 'div'
|
|
85
|
+
text: string
|
|
86
|
+
repo?: string | null
|
|
87
|
+
inline?: boolean
|
|
88
|
+
[x: string]: unknown
|
|
89
|
+
},
|
|
90
|
+
) => <Face {...props}>{markup(text, repo, inline)}</Face>
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
|
|
2
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import { useLayoutEffect, useRef } from 'npm:react@19.3.0'
|
|
3
|
+
import { openOverlay } from 'jsr:@yaks/ui@0.2.36/overlays'
|
|
4
|
+
import { useObserved } from 'jsr:@yaks/ux@0.2.36'
|
|
5
|
+
import { useDerived } from './read.ts'
|
|
6
|
+
// The sidebar: search at the top, then a line per place (home, each
|
|
7
|
+
// destination, the schema), the one you are on lit. Every line is a plain
|
|
8
|
+
// link; a phone folds the sidebar behind the bar's menu, and going anywhere
|
|
9
|
+
// folds it again.
|
|
10
|
+
import { signal } from 'npm:@preact/signals-core@1.14.5'
|
|
11
|
+
import { derivedEid } from 'jsr:@yaks/graph@0.2.36/identity'
|
|
12
|
+
import { Button, Shell } from 'jsr:@yaks/ui@0.2.36'
|
|
13
|
+
import { hosting, pagePath } from '../hosting.ts'
|
|
14
|
+
import {
|
|
15
|
+
type Destination,
|
|
16
|
+
destinations,
|
|
17
|
+
type Place,
|
|
18
|
+
placeAt,
|
|
19
|
+
places,
|
|
20
|
+
} from '../navigation.ts'
|
|
21
|
+
import { owner, searchOpen } from '../live.ts'
|
|
22
|
+
import { sessionQueries } from '../sessions.ts'
|
|
23
|
+
import { vocab } from '../types.ts'
|
|
24
|
+
import { front } from './fields.tsx'
|
|
25
|
+
import { Icon } from './icons.tsx'
|
|
26
|
+
import { follow, route } from './nav.tsx'
|
|
27
|
+
import { destinationOffers, homeOffer } from './offers.ts'
|
|
28
|
+
import { Waiting } from './inspect.tsx'
|
|
29
|
+
|
|
30
|
+
let { Brand, Find, Item, Label, Count } = Shell
|
|
31
|
+
|
|
32
|
+
/** Every destination this host offers, in the sidebar's order. */
|
|
33
|
+
export let allDestinations = (): Destination[] =>
|
|
34
|
+
destinations(
|
|
35
|
+
vocab,
|
|
36
|
+
owner.value,
|
|
37
|
+
sessionQueries(vocab).all,
|
|
38
|
+
destinationOffers(),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
/** The sidebar's lines. Home is the page a package offers the owner, or the
|
|
42
|
+
* host's own list where none does. */
|
|
43
|
+
export let allPlaces = (): Place[] => {
|
|
44
|
+
let home = homeOffer()
|
|
45
|
+
return places(
|
|
46
|
+
home
|
|
47
|
+
? { name: home.name, icon: home.icon, path: '/' }
|
|
48
|
+
: { name: 'Home', icon: 'house', path: '/' },
|
|
49
|
+
allDestinations(),
|
|
50
|
+
!!vocab.comp('_namespace'),
|
|
51
|
+
!!vocab.comp('secret'),
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** What the page at `at` is called when no entity names it. */
|
|
56
|
+
export let titleAt = (at: string): Place | undefined => {
|
|
57
|
+
let place = placeAt(at, allPlaces())
|
|
58
|
+
return place?.path == '/' && !homeOffer()
|
|
59
|
+
? { ...place, name: hosting().home?.title ?? 'Home' }
|
|
60
|
+
: place
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Whether the sidebar is slid over a phone's page: page state, never kept
|
|
64
|
+
// past the page, so every load starts with it folded.
|
|
65
|
+
let sidebarEid = derivedEid('Sidebar|browse')
|
|
66
|
+
let held = front.watch(`.Sidebar .entity.eid=${sidebarEid}`)
|
|
67
|
+
let open = signal(false)
|
|
68
|
+
held.subscribe((rows) => {
|
|
69
|
+
open.value = !!(rows[0]?.Sidebar as { open?: boolean } | undefined)?.open
|
|
70
|
+
})
|
|
71
|
+
export let sidebarOpen = (): boolean => open.value
|
|
72
|
+
export let openSidebar = (yes: boolean): void =>
|
|
73
|
+
void front.mutate([{ entity: { eid: sidebarEid }, Sidebar: { open: yes } }])
|
|
74
|
+
|
|
75
|
+
/** The bar's menu: where a window is narrow, the way to the sidebar. */
|
|
76
|
+
export let SidebarMenu = () => {
|
|
77
|
+
let expanded = useObserved(open)
|
|
78
|
+
return (
|
|
79
|
+
<Shell.Menu>
|
|
80
|
+
<Button
|
|
81
|
+
type='button'
|
|
82
|
+
mod='quiet'
|
|
83
|
+
aria-label='Open navigation'
|
|
84
|
+
aria-expanded={expanded}
|
|
85
|
+
onClick={() => openSidebar(!sidebarOpen())}
|
|
86
|
+
>
|
|
87
|
+
<Icon name='menu' size={18} />
|
|
88
|
+
</Button>
|
|
89
|
+
</Shell.Menu>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// The app's name: the box's, or an app store's slug under its mount.
|
|
94
|
+
let brand = () => hosting().page.split('/').filter(Boolean)[0] ?? 'Tasks'
|
|
95
|
+
|
|
96
|
+
export let Navigation = () => {
|
|
97
|
+
let path = useObserved(route)
|
|
98
|
+
let expanded = useObserved(open)
|
|
99
|
+
let side = useRef<HTMLElement>(null)
|
|
100
|
+
useLayoutEffect(() => {
|
|
101
|
+
let node = side.current
|
|
102
|
+
if (expanded && node) {
|
|
103
|
+
let phone = node.ownerDocument.defaultView?.matchMedia?.(
|
|
104
|
+
'(max-width: 44rem)',
|
|
105
|
+
)
|
|
106
|
+
return openOverlay(node, () => openSidebar(false), {
|
|
107
|
+
shown: () => phone?.matches ?? true,
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
}, [expanded])
|
|
111
|
+
let places = useDerived(allPlaces, [])
|
|
112
|
+
let lit = placeAt(path, places)?.path
|
|
113
|
+
let go = (path: string) => (ev: MouseEvent) => {
|
|
114
|
+
follow(path)(ev)
|
|
115
|
+
if (ev.defaultPrevented) openSidebar(false)
|
|
116
|
+
}
|
|
117
|
+
let actor = useObserved(owner)
|
|
118
|
+
let home = homeOffer()
|
|
119
|
+
return (
|
|
120
|
+
<Shell.Side aria-label='Navigation' elRef={side}>
|
|
121
|
+
<Brand href={pagePath('/')} onClick={go('/')}>
|
|
122
|
+
{brand()}
|
|
123
|
+
</Brand>
|
|
124
|
+
<Find>
|
|
125
|
+
<Shell.Icon>
|
|
126
|
+
<Icon className='Shell_Glyph' name='search' size={16} />
|
|
127
|
+
</Shell.Icon>
|
|
128
|
+
<Button
|
|
129
|
+
type='button'
|
|
130
|
+
mod='quiet'
|
|
131
|
+
aria-label='Search (/)'
|
|
132
|
+
onClick={() => {
|
|
133
|
+
openSidebar(false)
|
|
134
|
+
searchOpen.value = true
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
Search <kbd>/</kbd>
|
|
138
|
+
</Button>
|
|
139
|
+
</Find>
|
|
140
|
+
{places.map((p) => (
|
|
141
|
+
<Item
|
|
142
|
+
key={p.path}
|
|
143
|
+
href={pagePath(p.path)}
|
|
144
|
+
mod={p.path == lit && 'on'}
|
|
145
|
+
aria-current={p.path == lit ? 'page' : undefined}
|
|
146
|
+
onClick={go(p.path)}
|
|
147
|
+
>
|
|
148
|
+
<Shell.Icon>
|
|
149
|
+
<Icon className='Shell_Glyph' name={p.icon} size={16} />
|
|
150
|
+
</Shell.Icon>
|
|
151
|
+
<Label>{p.name}</Label>
|
|
152
|
+
{p.path == '/' && home && actor && (
|
|
153
|
+
<Waiting offer={home} eid={actor}>
|
|
154
|
+
{(n) => <Count aria-label='waiting'>{n > 99 ? '99+' : n}</Count>}
|
|
155
|
+
</Waiting>
|
|
156
|
+
)}
|
|
157
|
+
</Item>
|
|
158
|
+
))}
|
|
159
|
+
</Shell.Side>
|
|
160
|
+
)
|
|
161
|
+
}
|