@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,63 @@
1
+ // The browser's server search: the rows a query line answers over the whole
2
+ // graph, not what happens to be loaded. `rows` is what a picker lists (the
3
+ // UX host's `find`, @yaks/ux); `hits` is the palette's ranked form of the
4
+ // same answer. A picker's line and its debounced hook are @yaks/ux's
5
+ // `pickLine` and `useHits`.
6
+ import { applyLocal, base } from "../live.js";
7
+ import { hitOf, rowOf } from "../client.js";
8
+ import { vocab } from "../types.js";
9
+ import { parse } from "@yaks/query";
10
+ // One server search. A malformed filter answers 400 — the typist's news in
11
+ // the palette, but a picker has no error slot, so a bad line simply yields no
12
+ // options (the same "no matches yet" a half-typed filter always showed). An
13
+ // abort is silent: the caller replaced the query and no longer wants this one.
14
+ export let rows = async (q, limit = 20, signal)=>{
15
+ // Pickers draw domain views, not projections: a filter such as .session
16
+ // must still carry its brief and a .comment must carry what it says.
17
+ let r = await fetch(`${base()}/query?q=${encodeURIComponent(`${q}&* .limit=${limit}`)}`, {
18
+ signal
19
+ });
20
+ if (!r.ok) throw new Error(await r.text());
21
+ return await r.json();
22
+ };
23
+ /** The rows a query answers, read as it was asked: what a portable view asks
24
+ * the graph for (@yaks/render's `query`), a session's name among them. */ export let read = async (q, signal)=>{
25
+ let r = await fetch(`${base()}/query?q=${encodeURIComponent(q)}`, {
26
+ signal
27
+ });
28
+ if (!r.ok) throw new Error(await r.text());
29
+ return await r.json();
30
+ };
31
+ /** The graph's people, up to `limit`: none where the vocabulary declares no
32
+ * `person` (a tracker store), whose server would refuse the line. */ export let people = (limit, signal)=>vocab.comp('person') ? rows('.person', limit, signal) : Promise.resolve([]);
33
+ /** Whether a query answers values rather than navigable entity rows. */ export let aggregate = (q)=>{
34
+ try {
35
+ return parse(q).clauses.some((c)=>[
36
+ 'count',
37
+ 'tally',
38
+ 'distinct'
39
+ ].includes(c.kind));
40
+ } catch {
41
+ return false;
42
+ }
43
+ };
44
+ /** The same search, each row as the palette ranks and shows it. */ export let hits = async (q, limit = 20, signal)=>{
45
+ // Aggregate answers are values, not entities a picker can navigate to.
46
+ // The addressed query page renders them; the palette still offers that link.
47
+ // Words need no order of their own: the server answers a window of a search
48
+ // best match first (@yaks/fts).
49
+ if (aggregate(q)) return [];
50
+ let found = await rows(q, limit, signal);
51
+ // Keep the actual bundles: every picker draws the hit through the registry,
52
+ // not from a private title-only search shape.
53
+ applyLocal(found.flatMap(({ entity, ...comps })=>Object.entries({
54
+ entity,
55
+ ...comps
56
+ }).filter(([, value])=>value && typeof value == 'object').map(([name, value])=>({
57
+ eid: entity.eid,
58
+ name,
59
+ comp: value
60
+ }))));
61
+ return found.map((r)=>hitOf(rowOf(r)));
62
+ };
63
+ //# sourceMappingURL=hits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hits.js","sources":["./hits.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,qEAAqE;AACrE,4BAA4B;AAC5B,SAAS,UAAU,EAAE,IAAI,qBAAoB;AAC7C,SAAS,KAAK,EAAE,KAAK,uBAAsB;AAC3C,SAAmB,KAAK,sBAAqB;AAE7C,SAAS,KAAK,2BAAgC;AAE9C,2EAA2E;AAC3E,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,OAAO,IAAI,OAAO,OAChB,GACA,QAAQ,EAAE,EACV;EAEA,wEAAwE;EACxE,qEAAqE;EACrE,IAAI,IAAI,MAAM,MACZ,GAAG,OAAO,SAAS,EAAE,mBAAmB,GAAG,EAAE,UAAU,EAAE,OAAO,GAAG,EACnE;IAAE;EAAO;EAEX,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,IAAI,MAAM,MAAM,EAAE,IAAI;EACvC,OAAO,MAAM,EAAE,IAAI;AACrB,EAAC;AAED;wEACwE,GACxE,OAAO,IAAI,OAAO,OAChB,GACA;EAEA,IAAI,IAAI,MAAM,MAAM,GAAG,OAAO,SAAS,EAAE,mBAAmB,IAAI,EAAE;IAAE;EAAO;EAC3E,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,IAAI,MAAM,MAAM,EAAE,IAAI;EACvC,OAAO,MAAM,EAAE,IAAI;AACrB,EAAC;AAED;mEACmE,GACnE,OAAO,IAAI,SAAS,CAAC,OAAe,SAClC,MAAM,IAAI,CAAC,YAAY,KAAK,WAAW,OAAO,UAAU,QAAQ,OAAO,CAAC,EAAE,EAAC;AAE7E,sEAAsE,GACtE,OAAO,IAAI,YAAY,CAAC;EACtB,IAAI;IACF,OAAO,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,IAC5B;QAAC;QAAS;QAAS;OAAW,CAAC,QAAQ,CAAC,EAAE,IAAI;EAElD,EAAE,OAAM;IACN,OAAO;EACT;AACF,EAAC;AAED,iEAAiE,GACjE,OAAO,IAAI,OAAO,OAChB,GACA,QAAQ,EAAE,EACV;EAEA,uEAAuE;EACvE,6EAA6E;EAC7E,4EAA4E;EAC5E,gCAAgC;EAChC,IAAI,UAAU,IAAI,OAAO,EAAE;EAC3B,IAAI,QAAQ,MAAM,KAAK,GAAG,OAAO;EACjC,4EAA4E;EAC5E,8CAA8C;EAC9C,WACE,MAAM,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,GACjC,OAAO,OAAO,CAAC;MAAE;MAAQ,GAAG,KAAK;IAAC,GAC/B,MAAM,CAAC,CAAC,GAAG,MAAM,GAAK,SAAS,OAAO,SAAS,UAC/C,GAAG,CAAC,CAAC,CAAC,MAAM,MAAM,GAAK,CAAC;QACvB,KAAK,OAAO,GAAG;QACf;QACA,MAAM;MACR,CAAC;EAGP,OAAO,MAAM,GAAG,CAAC,CAAC,IAAM,MAAM,MAAM;AACtC,EAAC"}
@@ -0,0 +1,84 @@
1
+ // The browser's server search: the rows a query line answers over the whole
2
+ // graph, not what happens to be loaded. `rows` is what a picker lists (the
3
+ // UX host's `find`, @yaks/ux); `hits` is the palette's ranked form of the
4
+ // same answer. A picker's line and its debounced hook are @yaks/ux's
5
+ // `pickLine` and `useHits`.
6
+ import { applyLocal, base } from '../live.js'
7
+ import { hitOf, rowOf } from '../client.js'
8
+ import { type Hit, vocab } from '../types.js'
9
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
10
+ import { parse } from '@yaks/query'
11
+
12
+ // One server search. A malformed filter answers 400 — the typist's news in
13
+ // the palette, but a picker has no error slot, so a bad line simply yields no
14
+ // options (the same "no matches yet" a half-typed filter always showed). An
15
+ // abort is silent: the caller replaced the query and no longer wants this one.
16
+ export let rows = async (
17
+ q: string,
18
+ limit = 20,
19
+ signal?: AbortSignal,
20
+ ): Promise<Bundle[]> => {
21
+ // Pickers draw domain views, not projections: a filter such as .session
22
+ // must still carry its brief and a .comment must carry what it says.
23
+ let r = await fetch(
24
+ `${base()}/query?q=${encodeURIComponent(`${q}&* .limit=${limit}`)}`,
25
+ { signal },
26
+ )
27
+ if (!r.ok) throw new Error(await r.text())
28
+ return await r.json()
29
+ }
30
+
31
+ /** The rows a query answers, read as it was asked: what a portable view asks
32
+ * the graph for (@yaks/render's `query`), a session's name among them. */
33
+ export let read = async (
34
+ q: string,
35
+ signal?: AbortSignal,
36
+ ): Promise<Bundle[]> => {
37
+ let r = await fetch(`${base()}/query?q=${encodeURIComponent(q)}`, { signal })
38
+ if (!r.ok) throw new Error(await r.text())
39
+ return await r.json()
40
+ }
41
+
42
+ /** The graph's people, up to `limit`: none where the vocabulary declares no
43
+ * `person` (a tracker store), whose server would refuse the line. */
44
+ export let people = (limit: number, signal?: AbortSignal): Promise<Bundle[]> =>
45
+ vocab.comp('person') ? rows('.person', limit, signal) : Promise.resolve([])
46
+
47
+ /** Whether a query answers values rather than navigable entity rows. */
48
+ export let aggregate = (q: string): boolean => {
49
+ try {
50
+ return parse(q).clauses.some((c) =>
51
+ ['count', 'tally', 'distinct'].includes(c.kind)
52
+ )
53
+ } catch {
54
+ return false
55
+ }
56
+ }
57
+
58
+ /** The same search, each row as the palette ranks and shows it. */
59
+ export let hits = async (
60
+ q: string,
61
+ limit = 20,
62
+ signal?: AbortSignal,
63
+ ): Promise<Hit[]> => {
64
+ // Aggregate answers are values, not entities a picker can navigate to.
65
+ // The addressed query page renders them; the palette still offers that link.
66
+ // Words need no order of their own: the server answers a window of a search
67
+ // best match first (@yaks/fts).
68
+ if (aggregate(q)) return []
69
+ let found = await rows(q, limit, signal)
70
+ // Keep the actual bundles: every picker draws the hit through the registry,
71
+ // not from a private title-only search shape.
72
+ applyLocal(
73
+ found.flatMap(({ entity, ...comps }) =>
74
+ Object.entries({ entity, ...comps })
75
+ .filter(([, value]) => value && typeof value == 'object')
76
+ .map(([name, value]) => ({
77
+ eid: entity.eid,
78
+ name,
79
+ comp: value as Record<string, unknown>,
80
+ }))
81
+ ),
82
+ )
83
+ return found.map((r) => hitOf(rowOf(r)))
84
+ }
@@ -0,0 +1,177 @@
1
+ /** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
2
+ // @ts-types="@yaks/ui/lucide"
3
+ import ArrowUpRight from 'npm:lucide@1.31.0/dist/esm/icons/arrow-up-right.mjs'
4
+ // The app's icon vocabulary. Lucide owns the SVGs; this small name map keeps
5
+ // entity views data-driven and gives unknown views the document face.
6
+ //
7
+ // Each icon is its own module of Lucide's SVG nodes, imported by path. The
8
+ // package's barrel re-exports all ~1,800 icons, and a named import from it
9
+ // still loads every one: in each test process that renders a card, and in
10
+ // every bundle of the app, where esbuild resolved ~3,500 modules for these
11
+ // thirty-odd.
12
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h } from 'npm:react@19.3.0'
13
+ import type { IconNode } from 'npm:lucide@1.31.0'
14
+ // @ts-types="@yaks/ui/lucide"
15
+ import AlarmClock from 'npm:lucide@1.31.0/dist/esm/icons/alarm-clock.mjs'
16
+ // @ts-types="@yaks/ui/lucide"
17
+ import BookOpen from 'npm:lucide@1.31.0/dist/esm/icons/book-open.mjs'
18
+ // @ts-types="@yaks/ui/lucide"
19
+ import Activity from 'npm:lucide@1.31.0/dist/esm/icons/activity.mjs'
20
+ // @ts-types="@yaks/ui/lucide"
21
+ import Bookmark from 'npm:lucide@1.31.0/dist/esm/icons/bookmark.mjs'
22
+ // @ts-types="@yaks/ui/lucide"
23
+ import Bot from 'npm:lucide@1.31.0/dist/esm/icons/bot.mjs'
24
+ // @ts-types="@yaks/ui/lucide"
25
+ import Box from 'npm:lucide@1.31.0/dist/esm/icons/box.mjs'
26
+ // @ts-types="@yaks/ui/lucide"
27
+ import Braces from 'npm:lucide@1.31.0/dist/esm/icons/braces.mjs'
28
+ // @ts-types="@yaks/ui/lucide"
29
+ import Bug from 'npm:lucide@1.31.0/dist/esm/icons/bug.mjs'
30
+ // @ts-types="@yaks/ui/lucide"
31
+ import CircleAlert from 'npm:lucide@1.31.0/dist/esm/icons/circle-alert.mjs'
32
+ // @ts-types="@yaks/ui/lucide"
33
+ import CircleX from 'npm:lucide@1.31.0/dist/esm/icons/circle-x.mjs'
34
+ // @ts-types="@yaks/ui/lucide"
35
+ import Clock from 'npm:lucide@1.31.0/dist/esm/icons/clock.mjs'
36
+ // @ts-types="@yaks/ui/lucide"
37
+ import Columns2 from 'npm:lucide@1.31.0/dist/esm/icons/columns-2.mjs'
38
+ // @ts-types="@yaks/ui/lucide"
39
+ import Columns3 from 'npm:lucide@1.31.0/dist/esm/icons/columns-3.mjs'
40
+ // @ts-types="@yaks/ui/lucide"
41
+ import Database from 'npm:lucide@1.31.0/dist/esm/icons/database.mjs'
42
+ // @ts-types="@yaks/ui/lucide"
43
+ import Drama from 'npm:lucide@1.31.0/dist/esm/icons/drama.mjs'
44
+ // @ts-types="@yaks/ui/lucide"
45
+ import EllipsisVertical from 'npm:lucide@1.31.0/dist/esm/icons/ellipsis-vertical.mjs'
46
+ // @ts-types="@yaks/ui/lucide"
47
+ import FileText from 'npm:lucide@1.31.0/dist/esm/icons/file-text.mjs'
48
+ // @ts-types="@yaks/ui/lucide"
49
+ import Folder from 'npm:lucide@1.31.0/dist/esm/icons/folder.mjs'
50
+ // @ts-types="@yaks/ui/lucide"
51
+ import Globe from 'npm:lucide@1.31.0/dist/esm/icons/globe.mjs'
52
+ // @ts-types="@yaks/ui/lucide"
53
+ import Hash from 'npm:lucide@1.31.0/dist/esm/icons/hash.mjs'
54
+ // @ts-types="@yaks/ui/lucide"
55
+ import History from 'npm:lucide@1.31.0/dist/esm/icons/rotate-ccw-clock.mjs'
56
+ // @ts-types="@yaks/ui/lucide"
57
+ import House from 'npm:lucide@1.31.0/dist/esm/icons/house.mjs'
58
+ // @ts-types="@yaks/ui/lucide"
59
+ import Image from 'npm:lucide@1.31.0/dist/esm/icons/image.mjs'
60
+ // @ts-types="@yaks/ui/lucide"
61
+ import Kanban from 'npm:lucide@1.31.0/dist/esm/icons/kanban.mjs'
62
+ // @ts-types="@yaks/ui/lucide"
63
+ import LayoutDashboard from 'npm:lucide@1.31.0/dist/esm/icons/layout-dashboard.mjs'
64
+ // @ts-types="@yaks/ui/lucide"
65
+ import Lightbulb from 'npm:lucide@1.31.0/dist/esm/icons/lightbulb.mjs'
66
+ // @ts-types="@yaks/ui/lucide"
67
+ import List from 'npm:lucide@1.31.0/dist/esm/icons/list.mjs'
68
+ // @ts-types="@yaks/ui/lucide"
69
+ import Map from 'npm:lucide@1.31.0/dist/esm/icons/map.mjs'
70
+ // @ts-types="@yaks/ui/lucide"
71
+ import Menu from 'npm:lucide@1.31.0/dist/esm/icons/menu.mjs'
72
+ // @ts-types="@yaks/ui/lucide"
73
+ import MessageCircle from 'npm:lucide@1.31.0/dist/esm/icons/message-circle.mjs'
74
+ // @ts-types="@yaks/ui/lucide"
75
+ import ScanSearch from 'npm:lucide@1.31.0/dist/esm/icons/scan-search.mjs'
76
+ // @ts-types="@yaks/ui/lucide"
77
+ import Plus from 'npm:lucide@1.31.0/dist/esm/icons/plus.mjs'
78
+ // @ts-types="@yaks/ui/lucide"
79
+ import Search from 'npm:lucide@1.31.0/dist/esm/icons/search.mjs'
80
+ // @ts-types="@yaks/ui/lucide"
81
+ import Settings from 'npm:lucide@1.31.0/dist/esm/icons/settings.mjs'
82
+ // @ts-types="@yaks/ui/lucide"
83
+ import Shapes from 'npm:lucide@1.31.0/dist/esm/icons/shapes.mjs'
84
+ // @ts-types="@yaks/ui/lucide"
85
+ import SquareCheck from 'npm:lucide@1.31.0/dist/esm/icons/square-check.mjs'
86
+ // @ts-types="@yaks/ui/lucide"
87
+ import Stamp from 'npm:lucide@1.31.0/dist/esm/icons/stamp.mjs'
88
+ // @ts-types="@yaks/ui/lucide"
89
+ import Star from 'npm:lucide@1.31.0/dist/esm/icons/star.mjs'
90
+ // @ts-types="@yaks/ui/lucide"
91
+ import Table from 'npm:lucide@1.31.0/dist/esm/icons/table.mjs'
92
+ // @ts-types="@yaks/ui/lucide"
93
+ import Workflow from 'npm:lucide@1.31.0/dist/esm/icons/workflow.mjs'
94
+ // @ts-types="@yaks/ui/lucide"
95
+ import X from 'npm:lucide@1.31.0/dist/esm/icons/x.mjs'
96
+
97
+ let glyphs: Record<string, IconNode> = {
98
+ 'alarm-clock': AlarmClock,
99
+ 'square-check': SquareCheck,
100
+ 'circle-alert': CircleAlert,
101
+ 'circle-x': CircleX,
102
+ lightbulb: Lightbulb,
103
+ stamp: Stamp,
104
+ table: Table,
105
+ map: Map,
106
+ 'message-circle': MessageCircle,
107
+ list: List,
108
+ menu: Menu,
109
+ 'layout-dashboard': LayoutDashboard,
110
+ 'columns-2': Columns2,
111
+ 'columns-3': Columns3,
112
+ kanban: Kanban,
113
+ 'file-text': FileText,
114
+ globe: Globe,
115
+ hash: Hash,
116
+ history: History,
117
+ image: Image,
118
+ braces: Braces,
119
+ 'scan-search': ScanSearch,
120
+ drama: Drama,
121
+ search: Search,
122
+ shapes: Shapes,
123
+ 'ellipsis-vertical': EllipsisVertical,
124
+ bot: Bot,
125
+ 'book-open': BookOpen,
126
+ box: Box,
127
+ workflow: Workflow,
128
+ settings: Settings,
129
+ 'arrow-up-right': ArrowUpRight,
130
+ activity: Activity,
131
+ bookmark: Bookmark,
132
+ bug: Bug,
133
+ clock: Clock,
134
+ database: Database,
135
+ folder: Folder,
136
+ house: House,
137
+ plus: Plus,
138
+ star: Star,
139
+ x: X,
140
+ }
141
+
142
+ /** Learn glyphs a package names for what it offers (its `./views` facet's
143
+ * `icons`), beside the app's own; a name the app already draws keeps its
144
+ * glyph. */
145
+ export let learnGlyphs = (more: Record<string, IconNode>): void => {
146
+ for (let [name, glyph] of Object.entries(more)) glyphs[name] ??= glyph
147
+ }
148
+
149
+ /** One glyph as Lucide draws it: a 24-unit stroked SVG, sized in pixels. */
150
+ export let Icon = (
151
+ { name, size = 14, class: part, className }: {
152
+ name: string
153
+ size?: number
154
+ class?: string
155
+ className?: string
156
+ },
157
+ ) => {
158
+ let extra = [part, className].filter(Boolean).join(' ')
159
+ let known = name in glyphs ? name : 'file-text'
160
+ return (
161
+ <svg
162
+ xmlns='http://www.w3.org/2000/svg'
163
+ width={size}
164
+ height={size}
165
+ viewBox='0 0 24 24'
166
+ fill='none'
167
+ stroke='currentColor'
168
+ strokeWidth='2'
169
+ strokeLinecap='round'
170
+ strokeLinejoin='round'
171
+ className={`lucide lucide-${known} Icon${extra ? ` ${extra}` : ''}`}
172
+ aria-hidden='true'
173
+ >
174
+ {glyphs[known].map(([tag, attrs]) => h(tag, attrs))}
175
+ </svg>
176
+ )
177
+ }
@@ -0,0 +1,331 @@
1
+ /** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
2
+ // Browse supplies the inspector's views with the same held queries, page
3
+ // graph and navigation as every other app view. The readings stay in inspect;
4
+ // this is only the app's host adapter, not a second inspector or registry.
5
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, type ReactNode, useMemo } from 'npm:react@19.3.0'
6
+ import { contributed } from 'jsr:@yaks/render@0.2.36'
7
+ import { define, prepared, resolve } from 'jsr:@yaks/render@0.2.36'
8
+ import { signal } from 'npm:@preact/signals-core@1.14.5'
9
+ import { useObserved } from 'jsr:@yaks/ux@0.2.36'
10
+ import { useDerived } from './read.ts'
11
+ import { parse } from 'jsr:@yaks/query@0.2.36'
12
+ import { all, Past, schemaPages } from 'jsr:@yaks/inspect@0.2.36'
13
+ import { inspectViews as memoryViews } from 'jsr:@yaks/memory@0.2.36/views'
14
+ import { inspectViews as sessionViews } from 'jsr:@yaks/session@0.2.36/views'
15
+ import { inspectViews as taskViews } from 'jsr:@yaks/task@0.2.36/views'
16
+ import type { Answer, Ask, Asks, Bundle, Io } from 'jsr:@yaks/inspect@0.2.36'
17
+ import {
18
+ aggRead,
19
+ apply,
20
+ ent,
21
+ type Hold,
22
+ queryEids,
23
+ querySubscription,
24
+ row,
25
+ subscriptionState,
26
+ useHold,
27
+ } from '../live.ts'
28
+ import { parseQuery, type Pred, resolveRefs } from '../query.ts'
29
+ import { findEid } from '../live.ts'
30
+ import { EID, idIn, idOf, kindOf, vocab } from '../types.ts'
31
+ import { entityPath, searchPath } from '../url.ts'
32
+ import {
33
+ bundle,
34
+ type Entry,
35
+ extend,
36
+ named,
37
+ registry,
38
+ renderView,
39
+ } from './registry.ts'
40
+ import { front } from './fields.tsx'
41
+ import { ago } from './Stamp.tsx'
42
+ import { navigate } from './nav.tsx'
43
+ import { type Home, type Offer, offerPlaces } from './offers.ts'
44
+ import { learnGlyphs } from './icons.tsx'
45
+ import { Fault } from './Fault.tsx'
46
+ import type { IconNode } from 'npm:lucide@1.31.0'
47
+
48
+ let held = (eid: string): Bundle | undefined =>
49
+ row(eid).value ? bundle(ent(eid)) : undefined
50
+
51
+ // An entity's page: by the id it displays, or, for a deleted entity the page
52
+ // knows only by the id it was named by (`M-4446`), by that id.
53
+ let pathOf = (eid: string) =>
54
+ entityPath(row(eid).value || EID.test(eid) ? idOf(ent(eid)) : eid)
55
+
56
+ let AGGREGATES = ['count', 'tally', 'distinct']
57
+
58
+ // One ask, read: its line, whether it is an aggregate, and its predicates.
59
+ type Plan = {
60
+ line: string
61
+ once: boolean
62
+ typed: boolean
63
+ agg: boolean
64
+ preds?: Pred[]
65
+ error?: string
66
+ }
67
+ let plan = (a: Ask): Plan => {
68
+ let line = typeof a == 'string' ? a : a.query
69
+ let once = typeof a != 'string' && !!a.once
70
+ let typed = typeof a != 'string' && !!a.typed
71
+ try {
72
+ let agg = parse(line).clauses.some((c) => AGGREGATES.includes(c.kind))
73
+ return {
74
+ line,
75
+ once,
76
+ typed,
77
+ agg,
78
+ preds: agg ? undefined : resolveRefs(parseQuery(line), findEid),
79
+ }
80
+ } catch (e) {
81
+ return { line, once, typed, agg: false, error: String(e) }
82
+ }
83
+ }
84
+
85
+ let aggName = (p: Plan) => `inspect:${p.once ? 'once' : 'live'}:${p.line}`
86
+
87
+ // What an ask holds while its view is mounted.
88
+ let hold = (p: Plan): Hold | undefined =>
89
+ p.error
90
+ ? undefined
91
+ : p.agg
92
+ ? { agg: aggName(p), line: p.line, once: p.once, typed: p.typed }
93
+ : { query: p.preds!, source: p.line, typed: p.typed }
94
+
95
+ // What an ask's answer is now: read in the render, so a new answer paints.
96
+ let answer = (p: Plan): Answer => {
97
+ if (p.error) return { rows: [], ready: true, error: p.error }
98
+ if (p.agg) {
99
+ let name = aggName(p)
100
+ let state = subscriptionState(name)
101
+ let got = aggRead(name)
102
+ let map = got?.map ?? {}
103
+ let failed = state.status == 'failed' ? state.reason : undefined
104
+ return {
105
+ rows: [],
106
+ ready: !!got?.live,
107
+ error: failed,
108
+ count: got?.live && /\.count\b/.test(p.line) ? map[''] ?? 0 : undefined,
109
+ tally: got?.live && !/\.count\b/.test(p.line) ? map : undefined,
110
+ }
111
+ }
112
+ let state = querySubscription(p.preds!, p.line)?.state
113
+ // Local membership can name a row loaded by a narrower projection. Only
114
+ // this query's answer establishes that its requested fields arrived.
115
+ let rows = state && state.status != 'ready'
116
+ ? []
117
+ : queryEids(p.preds!).value.map(held)
118
+ .filter((b): b is Bundle => !!b)
119
+ return {
120
+ rows,
121
+ ready: !state || state.status == 'ready',
122
+ error: state?.status == 'failed' ? state.reason : undefined,
123
+ }
124
+ }
125
+
126
+ let useAnswers = (asks: Asks): Record<string, Answer> => {
127
+ let key = JSON.stringify(asks)
128
+ let plans = useMemo(
129
+ () => Object.entries(asks).map(([name, a]) => [name, plan(a)] as const),
130
+ [key],
131
+ )
132
+ useHold(...plans.map(([, p]) => hold(p)))
133
+ return useDerived(
134
+ () => Object.fromEntries(plans.map(([name, p]) => [name, answer(p)])),
135
+ [plans],
136
+ )
137
+ }
138
+
139
+ // Updates to the inspector's page graph wake the views mounted over it.
140
+ let turn = signal(0)
141
+ front.watch('.inspector|.table|.Disclosure').subscribe(() => turn.value++)
142
+
143
+ export let inspectIo: Io = {
144
+ vocab,
145
+ ask: useAnswers,
146
+ edits: typeof Deno == 'undefined',
147
+ apply: async (bs) => {
148
+ await apply(bs)
149
+ },
150
+ get: (eid) => row(eid).value ? bundle(ent(eid)) : undefined,
151
+ link: (eid) => pathOf(eid),
152
+ // An old version is its entity's page as of a transaction (App.tsx `?at=`).
153
+ past: (eid, tx) => `${pathOf(eid)}?at=${tx}`,
154
+ find: searchPath,
155
+ go: (href) => navigate(href),
156
+ id: (b) => idIn(b.entity.eid, b),
157
+ kind: kindOf,
158
+ name: named,
159
+ when: ago,
160
+ state: front.ent,
161
+ set: (bs) => {
162
+ void Promise.resolve(front.mutate(bs)).then(() => turn.value++)
163
+ },
164
+ show: (b, view, ctx = {}) => {
165
+ let e = ent(b.entity.eid)
166
+ let supplied = { ...e, ...b, eid: b.entity.eid, entity: b.entity }
167
+ return renderView(supplied as import('../types.ts').Ent, view, ctx)
168
+ },
169
+ can: (b, view) => !!resolve(registry, b, view, vocab),
170
+ }
171
+
172
+ // The app's registry selects the inspector's parts too: a package's more
173
+ // specific reading wins, and io.show comes back through this same registry.
174
+ export let adaptViews = (views: import('jsr:@yaks/inspect@0.2.36').View[]): Entry[] =>
175
+ views
176
+ .filter((r) => r.view != 'Inspect.Reference.Inline')
177
+ .map((r) => ({
178
+ ...r,
179
+ Render: ({ e, ...ctx }) => {
180
+ useObserved(turn)
181
+ let b = bundle(e)
182
+ let got = useAnswers(r.asks?.(b, inspectIo, ctx) ?? {})
183
+ return h(r.Render, { e: b, io: inspectIo, ctx, got })
184
+ },
185
+ }))
186
+
187
+ export let inspectViews: Entry[] = adaptViews([
188
+ ...await memoryViews(),
189
+ ...await sessionViews(),
190
+ ...await taskViews(),
191
+ ...all,
192
+ ].filter((r) =>
193
+ (r.view != 'Inspect.Page' || schemaPages.includes(r)) &&
194
+ r.view != 'Inspect.Reference.Inline'
195
+ ))
196
+
197
+ // Query and map pages are chosen by the same registry as entity pages. The
198
+ // temporary bundle identifies the page; its query is caller context, not data
199
+ // written into the server graph.
200
+ let PageBody = (
201
+ { view, eid = `browse-page:${view}`, ...ctx }: {
202
+ view: string
203
+ eid?: string
204
+ query?: string
205
+ },
206
+ ) => {
207
+ let entry = resolve(registry, { entity: { eid } }, view, vocab)
208
+ return entry?.view == view && 'Render' in entry
209
+ ? h(entry.Render, {
210
+ e: {
211
+ eid,
212
+ entity: { eid },
213
+ num: 0,
214
+ kind: 'entity',
215
+ refs: [],
216
+ kids: [],
217
+ } as import('../types.ts').Ent,
218
+ ...ctx,
219
+ })
220
+ : null
221
+ }
222
+
223
+ export let PagePart = (props: Parameters<typeof PageBody>[0]) => (
224
+ <Fault key={props.eid ?? props.view} place={props.view}>
225
+ <PageBody {...props} />
226
+ </Fault>
227
+ )
228
+
229
+ /** An entity as it was just after a transaction (`at`), or, without one, a
230
+ * deleted entity as it was last: @yaks/inspect's `Past`, through the app's
231
+ * doors. `eid` is the entity's eid, or the id a deleted one was named by. */
232
+ export let PastPage = (
233
+ { eid, id, at, lost }: {
234
+ eid: string
235
+ id: string
236
+ at?: string
237
+ lost: import('npm:preact@10.29.7').JSX.Element
238
+ },
239
+ ) =>
240
+ h(Past, { e: held(eid) ?? { entity: { eid } }, io: inspectIo, id, at, lost })
241
+
242
+ export let InspectPage = (
243
+ { query, map }: { query?: string; map?: boolean },
244
+ ) =>
245
+ h(PagePart, {
246
+ view: map ? 'Inspect.Map' : 'Inspect.Query',
247
+ eid: map ? 'browse-map' : `browse-query:${query}`,
248
+ query,
249
+ })
250
+
251
+ /** What a package's `./views` facet offers the app: its renderers, its
252
+ * inspector views, the pages it lists in the sidebar, the owner's home page,
253
+ * tabs on what its views draw, and the glyphs those wear. */
254
+ export type Facet = {
255
+ package?: string
256
+ views?: import('jsr:@yaks/render@0.2.36').Registry<
257
+ Entry | import('jsr:@yaks/inspect@0.2.36').View
258
+ >
259
+ componentViews?:
260
+ | import('jsr:@yaks/render@0.2.36').Registry<Entry>
261
+ | (() =>
262
+ | import('jsr:@yaks/render@0.2.36').Registry<Entry>
263
+ | Promise<import('jsr:@yaks/render@0.2.36').Registry<Entry>>)
264
+ inspectViews?:
265
+ | import('jsr:@yaks/inspect@0.2.36').View[]
266
+ | (() =>
267
+ | import('jsr:@yaks/inspect@0.2.36').View[]
268
+ | Promise<import('jsr:@yaks/inspect@0.2.36').View[]>)
269
+ destinations?: import('../navigation.ts').Destination[]
270
+ home?: Home
271
+ tabs?: Offer[]
272
+ icons?: Record<string, IconNode>
273
+ }
274
+
275
+ /** Merge configured contributions without registering query-backed views as
276
+ * native components. The same entry may be offered under both facet exports;
277
+ * it is mounted once, through the query adapter. */
278
+ export let contributedViews = async (facets: Facet[]): Promise<Entry[]> =>
279
+ (await Promise.all(facets.map(async (f) => {
280
+ let views = typeof f.inspectViews == 'function'
281
+ ? await f.inspectViews()
282
+ : f.inspectViews ?? []
283
+ let components = typeof f.componentViews == 'function'
284
+ ? await f.componentViews()
285
+ : f.componentViews
286
+ let adapted = new Set<unknown>(views)
287
+ let entries = [
288
+ ...adaptViews(views),
289
+ ...[...f.views?.renderers ?? [], ...components?.renderers ?? []].filter((
290
+ r,
291
+ ): r is Entry => !adapted.has(r)),
292
+ ]
293
+ return (await prepared(
294
+ define(f.package ? contributed(f.package, entries) : entries),
295
+ )).renderers
296
+ }))).flat()
297
+
298
+ /** Take in what the configured packages offer, before the app paints: their
299
+ * views, destinations, home page, tabs and glyphs. Every door does this the
300
+ * same way, once. The function returned puts back the views and places they
301
+ * displaced, so a test that takes a package in leaves the app as it found it
302
+ * (the glyphs it learned stay). */
303
+ export let contribute = async (facets: Facet[]): Promise<() => void> => {
304
+ let dropViews = extend(await contributedViews(facets))
305
+ let dropPlaces = offerPlaces({
306
+ home: facets.find((f) => f.home)?.home,
307
+ tabs: facets.flatMap((f) => f.tabs ?? []),
308
+ destinations: facets.flatMap((f) => f.destinations ?? []),
309
+ })
310
+ for (let f of facets) learnGlyphs(f.icons ?? {})
311
+ return () => {
312
+ dropPlaces()
313
+ dropViews()
314
+ }
315
+ }
316
+
317
+ /** What waits at an offered place for an entity, as `children` says it; none
318
+ * while nothing does or it is still unknown. */
319
+ export let Waiting = (
320
+ { offer, eid, children }: {
321
+ offer: Offer
322
+ eid: string
323
+ children: (n: number) => ReactNode
324
+ },
325
+ ) => {
326
+ let n = useDerived(() => offer.waiting?.(bundle(ent(eid)), inspectIo), [
327
+ offer,
328
+ eid,
329
+ ])
330
+ return n ? <>{children(n)}</> : null
331
+ }