@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.
Files changed (271) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +324 -2
  3. package/_dist/app.d.ts +8 -0
  4. package/_dist/app.d.ts.map +1 -0
  5. package/_dist/cli.d.ts +16 -0
  6. package/_dist/cli.d.ts.map +1 -0
  7. package/_dist/hosting.d.ts +24 -0
  8. package/_dist/hosting.d.ts.map +1 -0
  9. package/_dist/mod.d.ts +7 -0
  10. package/_dist/mod.d.ts.map +1 -0
  11. package/_dist/types.d.ts +5 -0
  12. package/_dist/types.d.ts.map +1 -0
  13. package/_dist/url.d.ts +2 -0
  14. package/_dist/url.d.ts.map +1 -0
  15. package/app.js +10 -0
  16. package/app.js.map +1 -0
  17. package/app.ts +10 -0
  18. package/browser-links.js +22 -0
  19. package/browser-links.js.map +1 -0
  20. package/browser-links.ts +28 -0
  21. package/cli.js +172 -0
  22. package/cli.js.map +1 -0
  23. package/cli.ts +168 -0
  24. package/client.js +748 -0
  25. package/client.js.map +1 -0
  26. package/client.ts +734 -0
  27. package/clipboard.js +18 -0
  28. package/clipboard.js.map +1 -0
  29. package/clipboard.ts +17 -0
  30. package/commands.js +1157 -0
  31. package/commands.js.map +1 -0
  32. package/commands.ts +1108 -0
  33. package/components/Ansi.tsx +160 -0
  34. package/components/App.tsx +446 -0
  35. package/components/Canvas.tsx +625 -0
  36. package/components/Card.tsx +276 -0
  37. package/components/Chat.tsx +205 -0
  38. package/components/Configuration.tsx +218 -0
  39. package/components/Decision.tsx +49 -0
  40. package/components/Dot.tsx +52 -0
  41. package/components/Entity.tsx +609 -0
  42. package/components/Fault.tsx +43 -0
  43. package/components/Filter.tsx +103 -0
  44. package/components/Keybindings.tsx +100 -0
  45. package/components/Keys.tsx +67 -0
  46. package/components/Markdown.tsx +90 -0
  47. package/components/Navigation.tsx +161 -0
  48. package/components/New.tsx +490 -0
  49. package/components/Peek.tsx +168 -0
  50. package/components/Prio.tsx +20 -0
  51. package/components/Run.tsx +263 -0
  52. package/components/Search.tsx +280 -0
  53. package/components/Stamp.tsx +44 -0
  54. package/components/Status.tsx +514 -0
  55. package/components/Sync.tsx +173 -0
  56. package/components/Tile.tsx +50 -0
  57. package/components/answered.js +23 -0
  58. package/components/answered.js.map +1 -0
  59. package/components/answered.ts +25 -0
  60. package/components/comp.js +11 -0
  61. package/components/comp.js.map +1 -0
  62. package/components/comp.ts +10 -0
  63. package/components/drag.js +173 -0
  64. package/components/drag.js.map +1 -0
  65. package/components/drag.ts +198 -0
  66. package/components/fields.tsx +90 -0
  67. package/components/fixtures/README.md +10 -0
  68. package/components/fixtures/archetypes.json +3646 -0
  69. package/components/hits.js +63 -0
  70. package/components/hits.js.map +1 -0
  71. package/components/hits.ts +84 -0
  72. package/components/icons.tsx +177 -0
  73. package/components/inspect.tsx +331 -0
  74. package/components/mount.ts +79 -0
  75. package/components/nav.tsx +479 -0
  76. package/components/offers.js +26 -0
  77. package/components/offers.js.map +1 -0
  78. package/components/offers.ts +54 -0
  79. package/components/page.js +21 -0
  80. package/components/page.js.map +1 -0
  81. package/components/page.ts +18 -0
  82. package/components/read.js +5 -0
  83. package/components/read.js.map +1 -0
  84. package/components/read.ts +7 -0
  85. package/components/registry.js +285 -0
  86. package/components/registry.js.map +1 -0
  87. package/components/registry.ts +317 -0
  88. package/components/session_status.tsx +115 -0
  89. package/components/subscriptions.js +149 -0
  90. package/components/subscriptions.js.map +1 -0
  91. package/components/subscriptions.ts +161 -0
  92. package/components/title.tsx +21 -0
  93. package/components/useQuery.js +166 -0
  94. package/components/useQuery.js.map +1 -0
  95. package/components/useQuery.ts +211 -0
  96. package/components/views/Board.tsx +450 -0
  97. package/components/views/BoardTile.tsx +65 -0
  98. package/components/views/Dashboard.tsx +148 -0
  99. package/components/views/Debug.tsx +445 -0
  100. package/components/views/Dependency.tsx +51 -0
  101. package/components/views/Entry.tsx +500 -0
  102. package/components/views/Gist.tsx +28 -0
  103. package/components/views/Inline.tsx +54 -0
  104. package/components/views/Json.tsx +19 -0
  105. package/components/views/Layout.tsx +211 -0
  106. package/components/views/List.tsx +238 -0
  107. package/components/views/Md.tsx +43 -0
  108. package/components/views/Media.tsx +48 -0
  109. package/components/views/Memory.tsx +32 -0
  110. package/components/views/Relate.tsx +205 -0
  111. package/components/views/Search.tsx +42 -0
  112. package/components/views/Session.tsx +850 -0
  113. package/components/views/SessionManage.tsx +127 -0
  114. package/components/views/Show.tsx +758 -0
  115. package/components/views/Shown.tsx +72 -0
  116. package/components/views/Split.tsx +58 -0
  117. package/components/views/TaskTile.tsx +37 -0
  118. package/components/views/Title.tsx +105 -0
  119. package/components/views/Wake.tsx +77 -0
  120. package/components/views/Web.tsx +49 -0
  121. package/components/wells.js +30 -0
  122. package/components/wells.js.map +1 -0
  123. package/components/wells.ts +33 -0
  124. package/configuration.js +38 -0
  125. package/configuration.js.map +1 -0
  126. package/configuration.ts +41 -0
  127. package/decision_sync.js +88 -0
  128. package/decision_sync.js.map +1 -0
  129. package/decision_sync.ts +93 -0
  130. package/deno.json +1 -0
  131. package/domain-host.tsx +108 -0
  132. package/edge.js +193 -0
  133. package/edge.js.map +1 -0
  134. package/edge.ts +196 -0
  135. package/entry_log.js +241 -0
  136. package/entry_log.js.map +1 -0
  137. package/entry_log.ts +214 -0
  138. package/failure.js +22 -0
  139. package/failure.js.map +1 -0
  140. package/failure.ts +34 -0
  141. package/front.json +61 -0
  142. package/highlight.js +143 -0
  143. package/highlight.js.map +1 -0
  144. package/highlight.ts +149 -0
  145. package/history.js +68 -0
  146. package/history.js.map +1 -0
  147. package/history.ts +72 -0
  148. package/host_commands.js +107 -0
  149. package/host_commands.js.map +1 -0
  150. package/host_commands.ts +38 -0
  151. package/hosting.js +53 -0
  152. package/hosting.js.map +1 -0
  153. package/hosting.ts +72 -0
  154. package/idb.js +14 -0
  155. package/idb.js.map +1 -0
  156. package/idb.ts +15 -0
  157. package/index.js +232 -0
  158. package/index.js.map +1 -0
  159. package/index.ts +252 -0
  160. package/keybindings.js +136 -0
  161. package/keybindings.js.map +1 -0
  162. package/keybindings.ts +37 -0
  163. package/kit.js +103 -0
  164. package/kit.js.map +1 -0
  165. package/kit.ts +119 -0
  166. package/layout.js +254 -0
  167. package/layout.js.map +1 -0
  168. package/layout.ts +210 -0
  169. package/legacy_outbox.js +53 -0
  170. package/legacy_outbox.js.map +1 -0
  171. package/legacy_outbox.ts +63 -0
  172. package/live.js +2883 -0
  173. package/live.js.map +1 -0
  174. package/live.ts +3334 -0
  175. package/live_archetypes.js +92 -0
  176. package/live_archetypes.js.map +1 -0
  177. package/live_archetypes.ts +113 -0
  178. package/live_client.js +145 -0
  179. package/live_client.js.map +1 -0
  180. package/live_client.ts +120 -0
  181. package/main.tsx +5 -0
  182. package/mod.js +7 -0
  183. package/mod.js.map +1 -0
  184. package/mod.ts +7 -0
  185. package/mount.tsx +50 -0
  186. package/navigation.js +120 -0
  187. package/navigation.js.map +1 -0
  188. package/navigation.ts +152 -0
  189. package/near.js +83 -0
  190. package/near.js.map +1 -0
  191. package/near.ts +83 -0
  192. package/new.js +295 -0
  193. package/new.js.map +1 -0
  194. package/new.ts +361 -0
  195. package/outbox.js +112 -0
  196. package/outbox.js.map +1 -0
  197. package/outbox.ts +129 -0
  198. package/owner.js +39 -0
  199. package/owner.js.map +1 -0
  200. package/owner.ts +37 -0
  201. package/package.json +81 -4
  202. package/paste.js +157 -0
  203. package/paste.js.map +1 -0
  204. package/paste.ts +122 -0
  205. package/props.js +303 -0
  206. package/props.js.map +1 -0
  207. package/props.ts +358 -0
  208. package/providers.js +136 -0
  209. package/providers.js.map +1 -0
  210. package/providers.ts +194 -0
  211. package/query.js +987 -0
  212. package/query.js.map +1 -0
  213. package/query.ts +1113 -0
  214. package/remote.js +37 -0
  215. package/remote.js.map +1 -0
  216. package/remote.ts +46 -0
  217. package/resolver.js +149 -0
  218. package/resolver.js.map +1 -0
  219. package/resolver.ts +213 -0
  220. package/rfc2047.js +37 -0
  221. package/rfc2047.js.map +1 -0
  222. package/rfc2047.ts +40 -0
  223. package/row_holds.js +107 -0
  224. package/row_holds.js.map +1 -0
  225. package/row_holds.ts +93 -0
  226. package/served.ts +42 -0
  227. package/session_worktree.js +7 -0
  228. package/session_worktree.js.map +1 -0
  229. package/session_worktree.ts +16 -0
  230. package/sessions.js +57 -0
  231. package/sessions.js.map +1 -0
  232. package/sessions.ts +53 -0
  233. package/sha.js +161 -0
  234. package/sha.js.map +1 -0
  235. package/sha.ts +164 -0
  236. package/styles.css +2823 -0
  237. package/subs.js +36 -0
  238. package/subs.js.map +1 -0
  239. package/subs.ts +40 -0
  240. package/terminal-route.js +13 -0
  241. package/terminal-route.js.map +1 -0
  242. package/terminal-route.ts +17 -0
  243. package/terminal.js +251 -0
  244. package/terminal.js.map +1 -0
  245. package/terminal.ts +186 -0
  246. package/time.js +142 -0
  247. package/time.js.map +1 -0
  248. package/time.ts +133 -0
  249. package/title.js +25 -0
  250. package/title.js.map +1 -0
  251. package/title.ts +50 -0
  252. package/tui/doc.ts +6 -0
  253. package/tui/testing.ts +19 -0
  254. package/twin.js +11 -0
  255. package/twin.js.map +1 -0
  256. package/twin.ts +13 -0
  257. package/types.js +456 -0
  258. package/types.js.map +1 -0
  259. package/types.ts +1370 -0
  260. package/url.js +77 -0
  261. package/url.js.map +1 -0
  262. package/url.ts +85 -0
  263. package/verb.js +82 -0
  264. package/verb.js.map +1 -0
  265. package/verb.ts +137 -0
  266. package/warmth.js +41 -0
  267. package/warmth.js.map +1 -0
  268. package/warmth.ts +54 -0
  269. package/wire.js +86 -0
  270. package/wire.js.map +1 -0
  271. package/wire.ts +63 -0
@@ -0,0 +1,211 @@
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 { useRef, useState } from 'npm:react@19.3.0'
3
+ import { type Ent, type Hit, idOf, uuid } from '../../types.ts'
4
+ import { backlinks, ent, mutate } from '../../live.ts'
5
+ import { useQueryEids } from '../useQuery.ts'
6
+ import { block, Button, Combobox } from 'jsr:@yaks/ui@0.2.36'
7
+ import { resolve } from '../registry.ts'
8
+ import { Entity } from '../Entity.tsx'
9
+ import { panEvents } from '../Canvas.tsx'
10
+ import { hits as queryHits } from '../hits.ts'
11
+ import { close, kids, resize, setContent, split } from '../../layout.ts'
12
+
13
+ // The tiling container (D-14718): a layout entity rendered as its pane
14
+ // tree. A container pane lays its children along dir, each flex-weighted
15
+ // by its own size (flex-grow normalizes the weights natively); a leaf
16
+ // renders its content through the shared registry; an empty leaf offers
17
+ // an inline finder — the palette's stand-in until rollout step 3. Every
18
+ // gesture is one layout.ts batch through mutate(); a gutter drag
19
+ // previews locally and lands its two-change batch on settle, the Canvas
20
+ // settle discipline.
21
+
22
+ let Frame = block('div', 'Layout', {
23
+ Pane: 'div',
24
+ Gutter: 'div',
25
+ Acts: 'div',
26
+ Act: 'button',
27
+ Fill: 'div',
28
+ Empty: 'div',
29
+ })
30
+ let { Pane, Gutter: GutterEl, Acts, Act, Fill: FillEl, Empty } = Frame
31
+
32
+ // The panes of one layout, straight off the reactive cache. The cache
33
+ // key is the identity (a comp cast from another client may carry no eid
34
+ // inside itself — the Pinned precedent), so eid is restamped here.
35
+ // Imperative on purpose — handlers call it mid-gesture — so the Layout
36
+ // component HOLDS the `.pane.layout=<layout>` sub at its root and every read
37
+ // here is local over those held rows; handlers never open a sub.
38
+ let panesOf = (layout: string) =>
39
+ backlinks(layout)
40
+ .filter((b) => b.via == 'pane.layout')
41
+ .flatMap((b) => {
42
+ let p = ent(b.from).pane
43
+ return p ? [{ ...p, eid: b.from }] : []
44
+ })
45
+
46
+ // A gutter between two siblings: drag transfers weight. The preview
47
+ // writes flex-grow on the two neighboring elements only; the settle
48
+ // computes the final batch and pins the DOM to it, so a clamped or
49
+ // unmoved drag can never leave a preview value behind.
50
+ let Gutter = ({ dir, a, b }: { dir: string; a: string; b: string }) => {
51
+ let down = (e: PointerEvent) => {
52
+ let g = e.currentTarget as HTMLElement
53
+ e.preventDefault()
54
+ e.stopPropagation()
55
+ g.setPointerCapture(e.pointerId)
56
+ let horiz = dir == 'h'
57
+ let span = horiz
58
+ ? g.parentElement!.clientWidth
59
+ : g.parentElement!.clientHeight
60
+ let start = horiz ? e.clientX : e.clientY
61
+ let pa = { ...ent(a).pane!, eid: a }
62
+ let pb = { ...ent(b).pane!, eid: b }
63
+ let sibs = kids(panesOf(pa.layout!), pa.parent!)
64
+ let total = sibs.reduce((n, s) => n + (s.size ?? 1), 0) || 1
65
+ let prev = g.previousElementSibling as HTMLElement
66
+ let next = g.nextElementSibling as HTMLElement
67
+ let dw = 0
68
+ let move = (ev: PointerEvent) => {
69
+ dw = ((horiz ? ev.clientX : ev.clientY) - start) / span * total
70
+ prev.style.flexGrow = String(Math.max(0.05, (pa.size ?? 1) + dw))
71
+ next.style.flexGrow = String(Math.max(0.05, (pb.size ?? 1) - dw))
72
+ }
73
+ panEvents(g, move, () => {
74
+ let batch = resize([pa, pb], a, b, dw)
75
+ prev.style.flexGrow = String(batch[0]?.comp?.size ?? pa.size ?? 1)
76
+ next.style.flexGrow = String(batch[1]?.comp?.size ?? pb.size ?? 1)
77
+ if (batch.length) mutate(...batch)
78
+ })
79
+ }
80
+ return <GutterEl mod={dir} onPointerDown={down} />
81
+ }
82
+
83
+ // The thin pane chrome, shown on hover: split right, split below, close.
84
+ let PaneActs = ({ eid, layout }: { eid: string; layout: string }) => {
85
+ let act = (
86
+ run: (panes: ReturnType<typeof panesOf>) => ReturnType<typeof split>,
87
+ ) =>
88
+ (e: MouseEvent) => {
89
+ e.stopPropagation()
90
+ mutate(...run(panesOf(layout)))
91
+ }
92
+ return (
93
+ <Acts>
94
+ <Act
95
+ data-tip='split right'
96
+ onClick={act((panes) => split(panes, eid, 'h'))}
97
+ >
98
+ │
99
+ </Act>
100
+ <Act
101
+ data-tip='split below'
102
+ onClick={act((panes) => split(panes, eid, 'v'))}
103
+ >
104
+ ─
105
+ </Act>
106
+ <Act data-tip='close pane' onClick={act((panes) => close(panes, eid))}>
107
+ ×
108
+ </Act>
109
+ </Acts>
110
+ )
111
+ }
112
+
113
+ // The inline finder an empty pane offers: type, pick, the pane fills —
114
+ // the pick stores the target's default view, spawnHit's convention.
115
+ let Fill = ({ eid, layout }: { eid: string; layout: string }) => {
116
+ let [hits, setHits] = useState<Hit[]>([])
117
+ let latest = useRef(0)
118
+ let seek = async (q: string) => {
119
+ let request = ++latest.current
120
+ setHits([])
121
+ let found = q.trim() ? await queryHits(q) : []
122
+ if (request == latest.current) setHits(found.slice(0, 12))
123
+ }
124
+ let pick = (h: Hit) =>
125
+ mutate(...setContent(
126
+ panesOf(layout),
127
+ eid,
128
+ h.eid,
129
+ resolve(ent(h.eid)).view,
130
+ ))
131
+ return (
132
+ <FillEl>
133
+ <Combobox
134
+ className='Layout_Input'
135
+ placeholder='fill this pane — search the graph…'
136
+ onText={seek}
137
+ options={hits.map((h) => ({
138
+ value: h.eid,
139
+ label: h.title || idOf(h),
140
+ note: h.title ? idOf(h) : undefined,
141
+ }))}
142
+ onChoose={(_value, index) => pick(hits[index])}
143
+ />
144
+ </FillEl>
145
+ )
146
+ }
147
+
148
+ // One pane, recursive. Weight rides inline (data); the axis is a class.
149
+ let PaneView = ({ eid, layout }: { eid: string; layout: string }) => {
150
+ let p = ent(eid).pane
151
+ if (!p) return null
152
+ let ks = p.dir ? kids(panesOf(layout), eid) : []
153
+ return (
154
+ <Pane
155
+ mod={p.dir ? (p.dir == 'h' ? 'row' : 'col') : 'leaf'}
156
+ data-eid={eid}
157
+ style={{ flexGrow: p.size ?? 1 }}
158
+ >
159
+ {p.dir
160
+ ? ks.flatMap((k, i) => [
161
+ ...(i
162
+ ? [
163
+ <Gutter
164
+ key={`g${k.eid}`}
165
+ dir={p.dir!}
166
+ a={ks[i - 1].eid}
167
+ b={k.eid}
168
+ />,
169
+ ]
170
+ : []),
171
+ <PaneView key={k.eid} eid={k.eid} layout={layout} />,
172
+ ])
173
+ : p.content
174
+ ? <Entity eid={p.content} view={p.view || undefined} />
175
+ : <Fill eid={eid} layout={layout} />}
176
+ {!p.dir && <PaneActs eid={eid} layout={layout} />}
177
+ </Pane>
178
+ )
179
+ }
180
+
181
+ export let Layout = ({ e }: { e: Ent }) => {
182
+ // Hold the layout's panes for the view's life: panesOf's imperative reads
183
+ // (render helpers AND drag/close handlers) reuse this held set, and closing
184
+ // the layout releases it (T-21489).
185
+ useQueryEids(`.pane.layout=${e.eid}`)
186
+ let root = e.layout?.root
187
+ if (root && ent(root).pane) {
188
+ return (
189
+ <Frame>
190
+ <PaneView eid={root} layout={e.eid} />
191
+ </Frame>
192
+ )
193
+ }
194
+ // A rootless layout (its root pane was deleted directly — root
195
+ // detaches by design): offer to re-root rather than render a dead end.
196
+ let reroot = () => {
197
+ let pane = uuid()
198
+ mutate(
199
+ { eid: pane, name: 'pane', comp: { layout: e.eid } },
200
+ { eid: e.eid, name: 'layout', comp: { root: pane } },
201
+ )
202
+ }
203
+ return (
204
+ <Frame>
205
+ <Empty>
206
+ empty layout —{' '}
207
+ <Button type='button' onClick={reroot}>add a pane</Button>
208
+ </Empty>
209
+ </Frame>
210
+ )
211
+ }
@@ -0,0 +1,238 @@
1
+ /** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
2
+ import { vocab } from '../../types.ts'
3
+ import { type Ent } from '../../types.ts'
4
+ /* @ts-types="npm:@types/react@19.3.0" */ import { useEffect, useLayoutEffect, useRef, useState } from 'npm:react@19.3.0'
5
+ import { unmime } from '../../rfc2047.ts'
6
+ import {
7
+ boardPost,
8
+ byWarmth,
9
+ capable,
10
+ ent,
11
+ type SubscriptionRead,
12
+ subWindow,
13
+ } from '../../live.ts'
14
+ import { orderOf, parseQuery, windowOf } from '../../query.ts'
15
+ import { block, Button, Rows } from 'jsr:@yaks/ui@0.2.36'
16
+ import { Answer } from 'jsr:@yaks/ux@0.2.36'
17
+ import { menuAt } from '../nav.tsx'
18
+ import { useFilteredQuery, usePassOf } from '../Filter.tsx'
19
+ import { dragData } from '../drag.ts'
20
+ import { usePinned, usePinTargets } from '../subscriptions.ts'
21
+ import { usePage } from '../useQuery.ts'
22
+ import { useDerived } from '../read.ts'
23
+ import { Id } from './Inline.tsx'
24
+ import { Entity } from '../Entity.tsx'
25
+ import { slot, tileLink, type TileProps, tileTitle } from '../Tile.tsx'
26
+ import { answeredOf, retryOf } from '../answered.ts'
27
+
28
+ // A canvas as a linear list — every pinned card's target, one summary row
29
+ // each, id chips linking through. The mobile answer to a spatial plane.
30
+ // Rows are native draggables: dropped on a canvas they carry their PIN,
31
+ // so the existing card relocates there (the row IS that card, listed).
32
+ export let List = ({ e }: { e: Ent }) => {
33
+ let pass = usePassOf(e.eid)
34
+ // Each row paints a pin's TARGET with no Card around it, so this face holds
35
+ // those rows itself — nothing else subscribes them (T-22371).
36
+ let ps = usePinned(e.eid)
37
+ usePinTargets(ps)
38
+ let shown = ps.toSorted((a, b) => b.z - a.z).filter((p) => pass(p.target))
39
+ return (
40
+ <Rows>
41
+ <Answer
42
+ answered={answeredOf(shown, pass)}
43
+ empty='Nothing on this canvas'
44
+ failed='The canvas could not load.'
45
+ retry={retryOf(pass.subscription)}
46
+ >
47
+ {(pins) =>
48
+ pins.map((p) => (
49
+ <Rows.Item
50
+ key={p.eid}
51
+ draggable={capable('canvas')}
52
+ onDragStart={(ev: DragEvent) =>
53
+ dragData(ev, p.target, p.view, p.w, p.eid)}
54
+ >
55
+ <Entity eid={p.target} view='List.Tile' />
56
+ </Rows.Item>
57
+ ))}
58
+ </Answer>
59
+ </Rows>
60
+ )
61
+ }
62
+
63
+ // A board as a linear FEED — its query run over the whole graph, not
64
+ // just tasks (that's the Board face's job). The Front page (.order=hot)
65
+ // reads as the graph-wide feed: warm first; any other board lists newest
66
+ // first. Either way the rows read in the order the server takes the window
67
+ // in, so the page scrolling asks for next lands below the rows already shown.
68
+ // Capped loudly — a "+N more" row, never silent truncation.
69
+ export let BoardList = ({ e }: { e: Ent }) => (
70
+ <QueryList eid={e.eid} query={String(e.board?.query ?? '')} />
71
+ )
72
+
73
+ // Saved boards and built-in listings share filtering, paging and row faces.
74
+ export let QueryList = (
75
+ { eid, query: saved }: { eid: string; query: string },
76
+ ) => {
77
+ let root = useRef<HTMLDivElement>(null)
78
+ let [size, setSize] = useState(0)
79
+ let [limit, setLimit] = useState(0)
80
+ let query = useFilteredQuery(eid, saved)
81
+ useLayoutEffect(() => {
82
+ let node = root.current?.parentElement
83
+ let measure = () =>
84
+ setSize(Math.max(4, Math.ceil((node?.clientHeight || 480) / 64) + 2))
85
+ measure()
86
+ if (!node || !globalThis.ResizeObserver) return
87
+ let observer = new ResizeObserver(measure)
88
+ observer.observe(node)
89
+ return () => observer.disconnect()
90
+ }, [])
91
+ useEffect(() => setLimit(0), [eid, query])
92
+ let line = query
93
+ let bound = Infinity
94
+ // A saved query that does not parse is refused here, before any window is
95
+ // measured or asked.
96
+ let refusal: SubscriptionRead | undefined
97
+ try {
98
+ let preds = parseQuery(query)
99
+ bound = windowOf(preds).limit ?? Infinity
100
+ if (!orderOf(preds)) {
101
+ if (vocab.prop('entity', 'num')) line += '&.order=-entity.num'
102
+ else if (vocab.prop('created', 'at')) line += '&.order=-created.at'
103
+ }
104
+ // Apply the feed's existing exclusions before the server takes a window.
105
+ // Filtering only the returned window can leave an empty home page when
106
+ // its newest documents are comments, despite older visible content.
107
+ for (
108
+ let name of [
109
+ 'card',
110
+ 'camera',
111
+ 'fold',
112
+ 'shelf',
113
+ 'cursor',
114
+ 'client',
115
+ 'comment',
116
+ ]
117
+ ) {
118
+ if (vocab.comp(name)) line += `&!${name}`
119
+ }
120
+ line += '&.limit=' + Math.min(bound, Math.max(size, limit))
121
+ } catch (error) {
122
+ refusal = {
123
+ sub: '',
124
+ state: {
125
+ status: 'failed',
126
+ reason: error instanceof Error ? error.message : String(error),
127
+ reference: query,
128
+ },
129
+ }
130
+ }
131
+ let page = usePage(query, line, !refusal && !!query.trim() && size > 0)
132
+ let boardRead = refusal ?? page.subscription
133
+ let win = boardRead ? subWindow(boardRead.sub) : undefined
134
+ let total = win?.total
135
+ let more = Math.max(
136
+ 0,
137
+ Math.min(
138
+ bound,
139
+ win?.total ??
140
+ (page.eids.length == Math.max(size, limit) ? page.eids.length + 1 : 0),
141
+ ) -
142
+ page.eids.length,
143
+ )
144
+ let grow = () => {
145
+ if (more && page.ready) setLimit(Math.max(size, limit) + size)
146
+ }
147
+ useEffect(() => {
148
+ let node = root.current?.parentElement
149
+ if (!node) return
150
+ let scroll = () => {
151
+ if (node.scrollHeight - node.scrollTop - node.clientHeight < 160) grow()
152
+ }
153
+ node.addEventListener('scroll', scroll)
154
+ return () => node.removeEventListener('scroll', scroll)
155
+ }, [more, size, limit, page.ready])
156
+ let rows = useDerived(() => {
157
+ try {
158
+ let listed = boardPost({ eid }, false, page.eids)
159
+ return orderOf(parseQuery(saved)) == 'hot'
160
+ ? listed.map(ent).sort(byWarmth(Date.now())).map((e) => e.eid)
161
+ : listed
162
+ } catch {
163
+ return undefined
164
+ }
165
+ }, [eid, saved, page.eids])
166
+ let answered = answeredOf(rows ?? [], {
167
+ ready: page.ready,
168
+ subscription: boardRead,
169
+ })
170
+ if (!rows && !answered.refused) return <Rows elRef={root} />
171
+ // The member sub is a WINDOW now (live.ts boardLine), so `rows` is a page of
172
+ // the board and not the board. "+N more" counts against the total the server
173
+ // STATED, or the feed would say "+300 more" while four thousand match — the
174
+ // silent truncation this row exists to prevent. The ephemeral filter is
175
+ // part of this page's query, so the total follows it too.
176
+ return (
177
+ <Rows elRef={root} mod='ruled' aria-busy={!page.ready}>
178
+ <Answer
179
+ answered={answered}
180
+ empty='No results.'
181
+ loading={rows?.length ? 'Loading more…' : 'Loading…'}
182
+ failed='The list could not load.'
183
+ retry={retryOf(boardRead)}
184
+ >
185
+ {(eids) => (
186
+ <>
187
+ {eids.map((eid) => (
188
+ // a feed row dragged onto a canvas spawns the entity as a card
189
+ <Rows.Item
190
+ key={eid}
191
+ draggable={capable('canvas')}
192
+ onDragStart={(ev: DragEvent) => dragData(ev, eid, 'Full')}
193
+ >
194
+ <Entity eid={eid} view='Feed.List.Tile' />
195
+ </Rows.Item>
196
+ ))}
197
+ {page.ready && more > 0 && (
198
+ <Rows.More>
199
+ <Button type='button' mod='quiet' onClick={grow}>
200
+ Load more{total != null && ` (${more} remaining)`}
201
+ </Button>
202
+ </Rows.More>
203
+ )}
204
+ </>
205
+ )}
206
+ </Answer>
207
+ </Rows>
208
+ )
209
+ }
210
+
211
+ // The default list line: title (or kind) + the id chip. The whole tile
212
+ // is the LINK — clickProps on the el: click peeks, double click
213
+ // navigates — and right-click serves the app menu (menuAt): navigation
214
+ // plus the entity's verbs. With no special List.Tile renderer, the registry
215
+ // falls through to each entity shape's plain Tile face.
216
+ let Line = block('div', 'ListTile', { Title: 'span' })
217
+ let summary = (e: Ent) =>
218
+ (e.mail ? unmime(e.doc?.title ?? '') : e.doc?.title) ||
219
+ e.doc?.body?.split('\n').find((line) => line.trim()) || e.kind
220
+
221
+ export let ListTile = ({ e, slots, onOpen }: TileProps) => (
222
+ <Line {...tileLink(e, onOpen)} onContextMenu={menuAt(e)}>
223
+ {slot(slots, 'before')}
224
+ {/* a mail's stored subject may be an encoded-word — decode to read */}
225
+ <Line.Title {...tileTitle(slots, summary(e))} />
226
+ <Id e={e} />
227
+ {slot(slots, 'after')}
228
+ {slot(slots, 'body')}
229
+ </Line>
230
+ )
231
+
232
+ // Every feed asks for this shared face; the kind-specific Tile still owns
233
+ // what the entity says, including session and letter summaries.
234
+ export let ListEntry = ({ e, ...props }: TileProps) => (
235
+ <Rows.Link {...tileLink(e, props.onOpen)}>
236
+ <Entity eid={e.eid} view='List.Tile' {...props} />
237
+ </Rows.Link>
238
+ )
@@ -0,0 +1,43 @@
1
+ /** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
2
+ import { type Ent, idOf, statusOf } from '../../types.ts'
3
+ import { ent, pending } from '../../live.ts'
4
+ import { el } from 'jsr:@yaks/ui@0.2.36'
5
+ import { highlight } from '../../highlight.ts'
6
+
7
+ // A doc as markdown with frontmatter — the file a dragged Markdown tab drops on
8
+ // the desktop, shown raw by the Markdown view. Any entity with a doc qualifies;
9
+ // workflow lines (status) appear only where the entity carries them. A kind
10
+ // whose package draws its own Markdown view wins over this one: a persona or a
11
+ // skill is the text an agent is given (@yaks/persona).
12
+ export let mdText = (e: Ent) => {
13
+ let refs = e.refs
14
+ .map((r) => `${r.type}: ${idOf(ent(r.child))}`)
15
+ .join('\n')
16
+ return [
17
+ '---',
18
+ `id: ${idOf(e)}`,
19
+ `title: ${e.doc?.title ?? ''}`,
20
+ ...(e.task ? [`status: ${statusOf(e)}`] : []),
21
+ ...(refs ? [refs] : []),
22
+ '---',
23
+ '',
24
+ // The raw file is also what a drag drops on the desktop, so a body this
25
+ // client hasn't been shipped says so rather than dropping an empty one.
26
+ pending(e) ? '…' : e.doc?.body ?? '',
27
+ '',
28
+ ].join('\n')
29
+ }
30
+
31
+ let Pre = el('pre', 'Md')
32
+
33
+ export let Md = ({ e }: { e: Ent }) => {
34
+ let lit = highlight(mdText(e), 'markdown')
35
+ return (
36
+ <Pre>
37
+ <code
38
+ className='hljs language-markdown'
39
+ dangerouslySetInnerHTML={{ __html: lit.html }}
40
+ />
41
+ </Pre>
42
+ )
43
+ }
@@ -0,0 +1,48 @@
1
+ /** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
2
+ // An artifact's face, directly or through an attachment. The bytes never ride
3
+ // the graph: GET /blob/<address> serves them from the store beside the db.
4
+ import { type Ent } from '../../types.ts'
5
+ import { ent } from '../../live.ts'
6
+ import { block, el } from 'jsr:@yaks/ui@0.2.36'
7
+
8
+ let Img = el('img', 'Media')
9
+ let Audio = el('audio', 'Media')
10
+ let Video = el('video', 'Media')
11
+ let File = block('a', 'MediaFile', { Name: 'span', Size: 'span' })
12
+ let { Name, Size } = File
13
+
14
+ // Human byte size — 812 B, 340 KB, 1.2 MB.
15
+ let size = (n?: number | null) =>
16
+ !n
17
+ ? ''
18
+ : n < 1024
19
+ ? `${n} B`
20
+ : n < 1024 ** 2
21
+ ? `${Math.round(n / 1024)} KB`
22
+ : `${(n / 1024 ** 2).toFixed(1)} MB`
23
+
24
+ export let Media = ({ e }: { e: Ent }) => {
25
+ let b = e.attachment ? ent(e.attachment.artifact) : e
26
+ let address = b.artifact?.address ?? e.attachment?.artifact
27
+ let src = `/blob/${address}`
28
+ let mime = b.artifact?.media_type ?? e.attachment?.media_type
29
+ return mime?.startsWith('image/')
30
+ ? (
31
+ <Img
32
+ src={src}
33
+ alt={e.attachment?.name ?? 'image'}
34
+ width={b.image?.w ?? undefined}
35
+ height={b.image?.h ?? undefined}
36
+ />
37
+ )
38
+ : mime?.startsWith('audio/')
39
+ ? <Audio src={src} controls preload='metadata' />
40
+ : mime?.startsWith('video/')
41
+ ? <Video src={src} controls preload='metadata' />
42
+ : (
43
+ <File href={src} download={e.attachment?.name ?? 'file'}>
44
+ <Name>{e.attachment?.name ?? 'download'}</Name>
45
+ <Size>{size(b.artifact?.size)}</Size>
46
+ </File>
47
+ )
48
+ }
@@ -0,0 +1,32 @@
1
+ /** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
2
+ import { menuAt } from '../nav.tsx'
3
+ import { slot, tileLink, type TileProps, tileTitle } from '../Tile.tsx'
4
+ import { block, el } from 'jsr:@yaks/ui@0.2.36'
5
+ import { Stamp } from '../Stamp.tsx'
6
+ import { Id } from './Inline.tsx'
7
+ import { words } from 'jsr:@yaks/memory@0.2.36'
8
+ import type { Ent } from '../../types.ts'
9
+
10
+ // A memory in a list: index line, confirmation age, id — with `feedback`
11
+ // ahead of it when the memory records someone's correction, the one thing
12
+ // the retired type enum said that the line did not already carry. The
13
+ // existing tile shell keeps it at home beside every other feed row;
14
+ // only the content is specific to memory. A memory marks words wherever they
15
+ // are (a doc, a comment, a transcript entry), so the index line is the title
16
+ // somebody gave it, else the first line of those words.
17
+ let Line = block('div', 'ListTile', { Title: 'span' })
18
+ let Type = el('span', 'MemoryType')
19
+
20
+ let index = (e: Ent) => e.doc?.title || words(e).trim().split('\n')[0]
21
+
22
+ export let MemoryTile = ({ e, slots, onOpen }: TileProps) => (
23
+ <Line {...tileLink(e, onOpen)} onContextMenu={menuAt(e)}>
24
+ {slot(slots, 'before')}
25
+ {e.feedback ? <Type>feedback</Type> : null}
26
+ <Line.Title {...tileTitle(slots, index(e))} />
27
+ <Stamp at={e.memory!.last_confirmed_at} label='confirmed' />
28
+ <Id e={e} />
29
+ {slot(slots, 'after')}
30
+ {slot(slots, 'body')}
31
+ </Line>
32
+ )