@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
package/package.json CHANGED
@@ -1,6 +1,83 @@
1
1
  {
2
2
  "name": "@yaks/browse",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.36",
4
+ "homepage": "https://jsr.io/@yaks/browse",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./_dist/mod.d.ts",
9
+ "default": "./mod.js"
10
+ },
11
+ "./main": {
12
+ "default": "./main.tsx"
13
+ },
14
+ "./hosting": {
15
+ "types": "./_dist/hosting.d.ts",
16
+ "default": "./hosting.js"
17
+ },
18
+ "./app": {
19
+ "types": "./_dist/app.d.ts",
20
+ "default": "./app.js"
21
+ },
22
+ "./web": {
23
+ "types": "./_dist/app.d.ts",
24
+ "default": "./app.js"
25
+ },
26
+ "./cli": {
27
+ "types": "./_dist/cli.d.ts",
28
+ "default": "./cli.js"
29
+ }
30
+ },
31
+ "license": "Apache-2.0",
32
+ "dependencies": {
33
+ "@yaks/api": "0.2.36",
34
+ "@yaks/archetype": "0.2.36",
35
+ "@yaks/blob": "0.2.36",
36
+ "@yaks/canvas": "0.2.36",
37
+ "@yaks/cli": "0.2.36",
38
+ "@yaks/client": "0.2.36",
39
+ "@yaks/connections": "0.2.36",
40
+ "@yaks/draft": "0.2.36",
41
+ "@yaks/edge": "0.2.36",
42
+ "@yaks/file": "0.2.36",
43
+ "@yaks/filter": "0.2.36",
44
+ "@yaks/fp": "0.2.36",
45
+ "@yaks/fts": "0.2.36",
46
+ "@yaks/graph": "0.2.36",
47
+ "@yaks/harness": "0.2.36",
48
+ "@yaks/id": "0.2.36",
49
+ "@yaks/inspect": "0.2.36",
50
+ "@yaks/kernel": "0.2.36",
51
+ "@yaks/key": "0.2.36",
52
+ "@yaks/markdown": "0.2.36",
53
+ "@yaks/match": "0.2.36",
54
+ "@yaks/memory": "0.2.36",
55
+ "@yaks/names": "0.2.36",
56
+ "@yaks/native": "0.2.36",
57
+ "@yaks/preact": "0.2.36",
58
+ "@yaks/process": "0.2.36",
59
+ "@yaks/query": "0.2.36",
60
+ "@yaks/react": "0.2.36",
61
+ "@yaks/render": "0.2.36",
62
+ "@yaks/secrets": "0.2.36",
63
+ "@yaks/session": "0.2.36",
64
+ "@yaks/sql": "0.2.36",
65
+ "@yaks/sync": "0.2.36",
66
+ "@yaks/task": "0.2.36",
67
+ "@yaks/tools": "0.2.36",
68
+ "@yaks/topic": "0.2.36",
69
+ "@yaks/tui": "0.2.36",
70
+ "@yaks/ui": "0.2.36",
71
+ "@yaks/ux": "0.2.36",
72
+ "@yaks/vocab": "0.2.36",
73
+ "@yaks/web": "0.2.36",
74
+ "@preact/signals-core": "1.14.5",
75
+ "@types/react": "19.3.0",
76
+ "highlight.js": "11.11.1",
77
+ "lucide": "1.31.0",
78
+ "preact": "10.29.7",
79
+ "react": "19.3.0"
80
+ },
81
+ "description": "The graph browsing app: domain views, editing and navigation, painted through @yaks/ui in browsers and terminals.",
82
+ "repository": "https://github.com/yak-sh/yak.git"
83
+ }
package/paste.js ADDED
@@ -0,0 +1,157 @@
1
+ import { searchBoard } from "@yaks/canvas";
2
+ import { system } from "@yaks/fp";
3
+ import { door } from "./hosting.js";
4
+ // Pasted content → the right entity. Matchers in specificity order: a bare
5
+ // eid or T-123 id lands a card on the EXISTING entity; a URL mints a web
6
+ // entity (rendered as the framed page); JSON minting comps, or carrying a
7
+ // known eid, or shaped like a task, does the obvious; anything else becomes
8
+ // a task — first line title, rest body.
9
+ import { base, cache, capable, findEid, uuid } from "./live.js";
10
+ import { HUMAN, LETTERED, SHORT } from "@yaks/id";
11
+ import { EID } from "./types.js";
12
+ let task = (title, body = '', status = 'open')=>{
13
+ let eid = uuid();
14
+ let mark = status == 'done' ? [
15
+ {
16
+ eid,
17
+ name: 'completed',
18
+ comp: {}
19
+ }
20
+ ] : status == 'cancelled' ? [
21
+ {
22
+ eid,
23
+ name: 'cancelled',
24
+ comp: {}
25
+ }
26
+ ] : [];
27
+ return {
28
+ changes: [
29
+ {
30
+ eid,
31
+ name: 'doc',
32
+ comp: {
33
+ eid,
34
+ title,
35
+ body
36
+ }
37
+ },
38
+ {
39
+ eid,
40
+ name: 'task',
41
+ comp: {
42
+ eid
43
+ }
44
+ },
45
+ ...mark
46
+ ],
47
+ target: eid
48
+ };
49
+ };
50
+ let json = (text)=>{
51
+ let o;
52
+ try {
53
+ o = JSON.parse(text);
54
+ } catch {
55
+ return null;
56
+ }
57
+ if (!o || typeof o != 'object' || Array.isArray(o)) return null;
58
+ if (typeof o.eid == 'string' && cache.value[o.eid]) {
59
+ return {
60
+ changes: [],
61
+ target: o.eid
62
+ };
63
+ }
64
+ let names = [
65
+ 'doc',
66
+ 'task',
67
+ 'board',
68
+ 'web'
69
+ ].filter((n)=>o[n] && typeof o[n] == 'object');
70
+ if (names.length) {
71
+ let eid = uuid();
72
+ let task = o.task;
73
+ let status = String(task?.status ?? 'open');
74
+ let cleanTask = (({ status: _status, ...rest })=>rest)(task ?? {});
75
+ return {
76
+ changes: [
77
+ ...names.map((n)=>({
78
+ eid,
79
+ name: n,
80
+ comp: n == 'task' ? {
81
+ ...cleanTask,
82
+ eid
83
+ } : {
84
+ ...o[n],
85
+ eid
86
+ }
87
+ })),
88
+ ...status == 'done' ? [
89
+ {
90
+ eid,
91
+ name: 'completed',
92
+ comp: {}
93
+ }
94
+ ] : status == 'cancelled' ? [
95
+ {
96
+ eid,
97
+ name: 'cancelled',
98
+ comp: {}
99
+ }
100
+ ] : []
101
+ ],
102
+ target: eid
103
+ };
104
+ }
105
+ if (typeof o.title == 'string') {
106
+ return task(o.title, String(o.body ?? ''), String(o.status ?? 'open'));
107
+ }
108
+ return null;
109
+ };
110
+ export let pasted = (raw, clock = system)=>{
111
+ let text = raw.trim();
112
+ if (!text) return null;
113
+ // A handle written with a letter (`T#3f9a1c`) is an id too, so it is refused
114
+ // by the finder rather than filed as a task titled with it.
115
+ if (EID.test(text) || SHORT.test(text) || HUMAN.test(text) || LETTERED.test(text)) {
116
+ let eid = findEid(text);
117
+ return eid ? {
118
+ changes: [],
119
+ target: eid
120
+ } : null;
121
+ }
122
+ if (/^https?:\/\/\S+$/.test(text)) {
123
+ let board = capable('canvas') ? searchBoard(text, globalThis.location?.origin ?? 'https://tasks.yak.sh') : null;
124
+ if (board) return json(JSON.stringify(board));
125
+ let eid = uuid();
126
+ // Ask the server to freeze the page (fire-and-forget: the answer comes
127
+ // back over the ws as web.frozen_at + a doc with the page title).
128
+ // Delayed a beat so the mint reaches the server first.
129
+ if (door('freeze')) {
130
+ clock.after(300, ()=>{
131
+ fetch(`${base()}/freeze?eid=${eid}`).catch(()=>{});
132
+ });
133
+ }
134
+ return {
135
+ changes: [
136
+ {
137
+ eid,
138
+ name: 'web',
139
+ comp: {
140
+ eid,
141
+ url: text
142
+ }
143
+ }
144
+ ],
145
+ target: eid,
146
+ view: 'Web',
147
+ w: 480
148
+ };
149
+ }
150
+ if (/^[{[]/.test(text)) {
151
+ let hit = json(text);
152
+ if (hit) return hit;
153
+ }
154
+ let [head, ...rest] = text.split('\n');
155
+ return task(head.slice(0, 80), rest.join('\n').trim());
156
+ };
157
+ //# sourceMappingURL=paste.js.map
package/paste.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste.js","sources":["./paste.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,4BAAiC;AACrD,SAAqB,MAAM,wBAA6B;AACxD,SAAS,IAAI,uBAAsB;AACnC,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,4EAA4E;AAC5E,wCAAwC;AACxC,SAAS,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,oBAAmB;AAC/D,SAAS,KAAK,EAAE,QAAQ,EAAE,KAAK,wBAA6B;AAC5D,SAAsB,GAAG,qBAAoB;AAW7C,IAAI,OAAO,CAAC,OAAe,OAAO,EAAE,EAAE,SAAS,MAAM;EACnD,IAAI,MAAM;EACV,IAAI,OAAO,UAAU,SACjB;IAAC;MAAE;MAAK,MAAM;MAAa,MAAM,CAAC;IAAE;GAAE,GACtC,UAAU,cACV;IAAC;MAAE;MAAK,MAAM;MAAa,MAAM,CAAC;IAAE;GAAE,GACtC,EAAE;EACN,OAAO;IACL,SAAS;MACP;QAAE;QAAK,MAAM;QAAO,M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
2
+ import { type Clock, system } from '@yaks/fp'
3
+ import { door } from './hosting.js'
4
+ // Pasted content → the right entity. Matchers in specificity order: a bare
5
+ // eid or T-123 id lands a card on the EXISTING entity; a URL mints a web
6
+ // entity (rendered as the framed page); JSON minting comps, or carrying a
7
+ // known eid, or shaped like a task, does the obvious; anything else becomes
8
+ // a task — first line title, rest body.
9
+ import { base, cache, capable, findEid, uuid } from './live.js'
10
+ import { HUMAN, LETTERED, SHORT } from '@yaks/id'
11
+ import { type Change, EID } from './types.js'
12
+
13
+ // What a paste resolves to: comps to mint (none for existing entities),
14
+ // the entity a card should target, and optionally how to show it.
15
+ export type Pasted = {
16
+ changes: Change[]
17
+ target: string
18
+ view?: string
19
+ w?: number
20
+ }
21
+
22
+ let task = (title: string, body = '', status = 'open'): Pasted => {
23
+ let eid = uuid()
24
+ let mark = status == 'done'
25
+ ? [{ eid, name: 'completed', comp: {} }]
26
+ : status == 'cancelled'
27
+ ? [{ eid, name: 'cancelled', comp: {} }]
28
+ : []
29
+ return {
30
+ changes: [
31
+ { eid, name: 'doc', comp: { eid, title, body } },
32
+ { eid, name: 'task', comp: { eid } },
33
+ ...mark,
34
+ ],
35
+ target: eid,
36
+ }
37
+ }
38
+
39
+ let json = (text: string): Pasted | null => {
40
+ let o: Record<string, unknown>
41
+ try {
42
+ o = JSON.parse(text)
43
+ } catch {
44
+ return null
45
+ }
46
+ if (!o || typeof o != 'object' || Array.isArray(o)) return null
47
+ if (typeof o.eid == 'string' && cache.value[o.eid]) {
48
+ return { changes: [], target: o.eid }
49
+ }
50
+ let names = ['doc', 'task', 'board', 'web'].filter(
51
+ (n) => o[n] && typeof o[n] == 'object',
52
+ )
53
+ if (names.length) {
54
+ let eid = uuid()
55
+ let task = o.task as Record<string, unknown> | undefined
56
+ let status = String(task?.status ?? 'open')
57
+ let cleanTask = (({ status: _status, ...rest }) => rest)(task ?? {})
58
+ return {
59
+ changes: [
60
+ ...names.map((n) => ({
61
+ eid,
62
+ name: n,
63
+ comp: n == 'task'
64
+ ? { ...cleanTask, eid }
65
+ : { ...(o[n] as object), eid },
66
+ })),
67
+ ...status == 'done'
68
+ ? [{ eid, name: 'completed', comp: {} }]
69
+ : status == 'cancelled'
70
+ ? [{ eid, name: 'cancelled', comp: {} }]
71
+ : [],
72
+ ],
73
+ target: eid,
74
+ }
75
+ }
76
+ if (typeof o.title == 'string') {
77
+ return task(o.title, String(o.body ?? ''), String(o.status ?? 'open'))
78
+ }
79
+ return null
80
+ }
81
+
82
+ export let pasted = (raw: string, clock: Clock = system): Pasted | null => {
83
+ let text = raw.trim()
84
+ if (!text) return null
85
+ // A handle written with a letter (`T#3f9a1c`) is an id too, so it is refused
86
+ // by the finder rather than filed as a task titled with it.
87
+ if (
88
+ EID.test(text) || SHORT.test(text) || HUMAN.test(text) ||
89
+ LETTERED.test(text)
90
+ ) {
91
+ let eid = findEid(text)
92
+ return eid ? { changes: [], target: eid } : null
93
+ }
94
+ if (/^https?:\/\/\S+$/.test(text)) {
95
+ let board = capable('canvas')
96
+ ? searchBoard(text, globalThis.location?.origin ?? 'https://tasks.yak.sh')
97
+ : null
98
+ if (board) return json(JSON.stringify(board))
99
+
100
+ let eid = uuid()
101
+ // Ask the server to freeze the page (fire-and-forget: the answer comes
102
+ // back over the ws as web.frozen_at + a doc with the page title).
103
+ // Delayed a beat so the mint reaches the server first.
104
+ if (door('freeze')) {
105
+ clock.after(300, () => {
106
+ fetch(`${base()}/freeze?eid=${eid}`).catch(() => {})
107
+ })
108
+ }
109
+ return {
110
+ changes: [{ eid, name: 'web', comp: { eid, url: text } }],
111
+ target: eid,
112
+ view: 'Web',
113
+ w: 480,
114
+ }
115
+ }
116
+ if (/^[{[]/.test(text)) {
117
+ let hit = json(text)
118
+ if (hit) return hit
119
+ }
120
+ let [head, ...rest] = text.split('\n')
121
+ return task(head.slice(0, 80), rest.join('\n').trim())
122
+ }
package/props.js ADDED
@@ -0,0 +1,303 @@
1
+ // Typed scalar parsing and formatting. PropType declares the language;
2
+ // this module gives every declaration one canonical stored and shown value.
3
+ import { comps, derivedProps, EID, spineProps, stamped, vocab } from "./types.js";
4
+ import { short } from "@yaks/id";
5
+ import { timeInstant } from "@yaks/query";
6
+ import { local } from "./time.js";
7
+ import { normalize } from "./url.js";
8
+ // A component's merged type map and a prop's owner list sit on the hot path
9
+ // (every query match, index pass and prop render funnels through them), so
10
+ // recomputing the spread and the O(components) owner scan on each call was
11
+ // pure waste (T-17036, the 16ms frame budget). They are memoized per
12
+ // vocabulary: learn() replaces the tables, and the memo goes with them.
13
+ let memo = (()=>{
14
+ let seen;
15
+ let types = new Map();
16
+ let owners = new Map();
17
+ return ()=>{
18
+ if (seen != comps) {
19
+ seen = comps;
20
+ types = new Map();
21
+ owners = new Map();
22
+ }
23
+ return {
24
+ types,
25
+ owners
26
+ };
27
+ };
28
+ })();
29
+ let types = (comp)=>{
30
+ let { types: held } = memo();
31
+ let hit = held.get(comp);
32
+ if (hit) return hit;
33
+ let t = {
34
+ ...comps[comp],
35
+ ...stamped[comp],
36
+ ...derivedProps[comp],
37
+ ...spineProps[comp]
38
+ };
39
+ held.set(comp, t);
40
+ return t;
41
+ };
42
+ export let propOwners = (prop)=>{
43
+ let { owners: held } = memo();
44
+ let hit = held.get(prop);
45
+ if (hit) return hit;
46
+ let out = [
47
+ ...new Set([
48
+ ...Object.keys(comps),
49
+ ...Object.keys(stamped)
50
+ ])
51
+ ].filter((comp)=>prop in types(comp));
52
+ held.set(prop, out);
53
+ return out;
54
+ };
55
+ // The qualified name is only noise until two components share the column.
56
+ export let propAt = (comp, prop)=>{
57
+ let type = types(comp)[prop];
58
+ if (!type) return;
59
+ let owners = propOwners(prop);
60
+ return {
61
+ comp,
62
+ prop,
63
+ name: owners.length > 1 ? `${comp}.${prop}` : prop,
64
+ type
65
+ };
66
+ };
67
+ // The declared type of a prop whose owning component isn't named — a shared
68
+ // reference routed to comp '' (route()'s any-of), or a bare filter. Every
69
+ // component sharing a name declares it identically, so the first hit is
70
+ // authoritative.
71
+ export let bareType = (prop)=>{
72
+ for (let c of propOwners(prop)){
73
+ let t = types(c)[prop];
74
+ if (t) return t;
75
+ }
76
+ };
77
+ // THE reference detector: is (comp, prop) an entity reference, and to what
78
+ // kind? 'entity' target = any entity; undefined = not a reference. A named
79
+ // comp reads its own declaration; comp '' searches the vocabulary.
80
+ export let refOf = (comp, prop)=>{
81
+ let t = comp ? types(comp)[prop] : bareType(prop);
82
+ return typeof t == 'object' && 'eid' in t ? t.eid : undefined;
83
+ };
84
+ // Just the yes/no of it: refOf answers with a target kind ('entity' = any),
85
+ // which is truthy for every reference, so this is a thin name over the
86
+ // intent — ask isRef when the kind doesn't matter, refOf when it does.
87
+ export let isRef = (comp, prop)=>refOf(comp, prop) != null;
88
+ // A column as a Prop, where a shared reference (comp '') is typed by its name.
89
+ export let typed = (comp, prop)=>{
90
+ let p = propAt(comp, prop);
91
+ if (p) return p;
92
+ let type = !comp ? bareType(prop) : undefined;
93
+ return type ? {
94
+ comp,
95
+ prop,
96
+ name: prop,
97
+ type
98
+ } : undefined;
99
+ };
100
+ // What the caller sent, quoted back. An object says its shape rather than
101
+ // '[object Object]': a refusal is read by whoever wrote the value.
102
+ let got = (v)=>v && typeof v == 'object' ? JSON.stringify(v) : String(v);
103
+ let fail = (p, grammar, v)=>{
104
+ throw new Error(`${p.name} is ${grammar} — got '${got(v)}'`);
105
+ };
106
+ let DECIMAL = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
107
+ let number = (p, v)=>{
108
+ let s = typeof v == 'string' ? v.trim() : String(v);
109
+ if (typeof v != 'string' && typeof v != 'number' || !DECIMAL.test(s) || !Number.isFinite(Number(s))) {
110
+ return fail(p, 'a finite decimal number (1, -2.5, 6e3)', v);
111
+ }
112
+ return Number(s);
113
+ };
114
+ let priority = (p, v)=>{
115
+ let s = typeof v == 'string' ? v.trim().replace(/^p/i, '') : String(v);
116
+ if (typeof v != 'string' && typeof v != 'number' || !DECIMAL.test(s) || !Number.isFinite(Number(s))) {
117
+ return fail(p, 'a finite number, optionally P-prefixed (P2, p02, 1.5)', v);
118
+ }
119
+ return Number(s);
120
+ };
121
+ let bool = (p, v)=>{
122
+ let s = String(v).trim().toLowerCase();
123
+ if (s == 'true' || s == '1' || s == 'yes') return 1;
124
+ if (s == 'false' || s == '0' || s == 'no') return 0;
125
+ return fail(p, 'a boolean (true, false, 1, 0, yes, no)', v);
126
+ };
127
+ let time = (p, v, ctx)=>{
128
+ if (typeof v != 'string') {
129
+ return fail(p, 'a time (today, 1 hour ago, in 60m, or ISO stamp)', v);
130
+ }
131
+ let at = timeInstant(v, ctx.now);
132
+ if (at == null || !Number.isFinite(at)) {
133
+ return fail(p, 'a time (today, 1 hour ago, in 60m, or ISO stamp)', v);
134
+ }
135
+ return new Date(at).toISOString();
136
+ };
137
+ let oneOf = (p, v)=>{
138
+ let type = p.type;
139
+ let s = typeof v == 'string' ? v : '';
140
+ let declared = type.enum.find((x)=>x.toLowerCase() == s.toLowerCase());
141
+ let alias = Object.entries(type.aliases ?? {}).find(([a])=>a.toLowerCase() == s.toLowerCase())?.[1];
142
+ let value = declared ?? type.enum.find((x)=>x.toLowerCase() == alias?.toLowerCase());
143
+ return value ?? fail(p, `one of ${type.enum.join(', ')}`, v);
144
+ };
145
+ // `.filed.project=tasks` is the shape: a token that IS a venture in the fleet,
146
+ // under an alias that diverges. When a near match resolves, naming it is
147
+ // the whole message — the grammar is not what the caller got wrong, and
148
+ // it is spelled by the noun the column carries ('no project', not 'no
149
+ // project'). Nothing close: the grammar line, plainly, no guess.
150
+ let noun = (p)=>p.prop == 'eid' ? 'entity' : p.prop;
151
+ let eid = (p, v, ctx)=>{
152
+ // A read handed back. A reference ANSWERS `{eid, name}` wherever the reader
153
+ // could name what it points at (workers/yak/listing.ts `named`), so the row
154
+ // a page read and writes back means the eid it named — one more spelling of
155
+ // an id, at the door that already accepts every other one.
156
+ let s = String(v && typeof v == 'object' && 'eid' in v ? v.eid : v).trim();
157
+ if (EID.test(s)) return s.toLowerCase();
158
+ let found = ctx.resolve?.(s);
159
+ if (found && EID.test(found)) return found.toLowerCase();
160
+ let target = typeof p.type == 'object' && 'eid' in p.type ? p.type.eid : '';
161
+ let near = ctx.near?.(s, target);
162
+ if (near) throw new Error(`no ${noun(p)} '${s}' — did you mean ${near}?`);
163
+ return fail(p, 'a human id / alias / UUID', v);
164
+ };
165
+ let text = (p, v)=>typeof v == 'string' ? v : fail(p, 'text', v);
166
+ // A page address is text with ONE canonical spelling (url.ts normalize).
167
+ // Living here is what keeps a save and a query in agreement without
168
+ // either side knowing: both grammars parse their scalars through this
169
+ // module, so `.web.url=https://x.com/p?utm_source=n#top` written and the same
170
+ // string filtered land on the same characters.
171
+ let url = (p, v)=>normalize(text(p, v));
172
+ let tag = (t)=>typeof t == 'string' ? t : 'enum' in t ? 'enum' : 'eid' in t ? 'eid' : 'text';
173
+ // Empty clears these — an optional enum too (T-16491): a closed set is still
174
+ // an optional column, so `.venture.phase=` un-sets it the way every other
175
+ // scalar does. A required enum is protected by the schema, so clearing it is
176
+ // refused loudly rather than silently corrupted.
177
+ let nullable = (t)=>[
178
+ 'number',
179
+ 'priority',
180
+ 'bool',
181
+ 'time',
182
+ 'eid',
183
+ 'enum'
184
+ ].includes(tag(t));
185
+ let parsers = {
186
+ number,
187
+ priority,
188
+ bool,
189
+ time,
190
+ enum: oneOf,
191
+ eid,
192
+ text,
193
+ url
194
+ };
195
+ // Null always passes through. Empty text is text; empty optional scalars clear.
196
+ export let parseProp = (p, input, ctx = {})=>{
197
+ if (input == null) return null;
198
+ if (input === '' && nullable(p.type)) return null;
199
+ return (parsers[tag(p.type)] ?? text)(p, input, ctx);
200
+ };
201
+ export let formatProp = (p, value, ctx = {})=>{
202
+ let parsed = parseProp(p, value, ctx);
203
+ if (parsed == null) return null;
204
+ if (tag(p.type) == 'priority') return `P${parsed}`;
205
+ if (tag(p.type) == 'bool') return parsed ? 'true' : 'false';
206
+ // A stamp is stored Zulu but SHOWN local — one door for every face.
207
+ if (tag(p.type) == 'time') return local(String(parsed));
208
+ // A reference nothing here can describe (its target not loaded) reads as
209
+ // the target's short handle, as the CLI prints it — never the bare uuid.
210
+ if (tag(p.type) == 'eid') {
211
+ return ctx.describe?.(String(parsed)) ?? short(String(parsed));
212
+ }
213
+ return String(parsed);
214
+ };
215
+ let ref = (name)=>({
216
+ comp: 'entity',
217
+ prop: name,
218
+ name,
219
+ type: {
220
+ eid: 'entity',
221
+ death: 'keep'
222
+ }
223
+ });
224
+ // What an id with no column to type it resolves through: `.refs=T-3`, a walk's
225
+ // target, `.entity.eid=T-3`. A plain entity reference, so the id turns into its eid
226
+ // at delivery exactly as a declared reference's would.
227
+ export let anyRef = ref('refs');
228
+ let requiredRef = (p, value, ctx)=>{
229
+ let parsed = parseProp(p, value, ctx);
230
+ if (parsed == null) return fail(p, 'a human id / alias / UUID', value);
231
+ return String(parsed);
232
+ };
233
+ // A field OPERATOR is a plain object whose key names an apply()-resolved op
234
+ // (`$edit`, …) rather than a literal column value. Detected by the `$` sigil so
235
+ // the value language leaves it alone; a real scalar is never an object.
236
+ export let isFieldOp = (v)=>v != null && typeof v == 'object' && !Array.isArray(v) && Object.keys(v).some((k)=>k.startsWith('$'));
237
+ // The same operator, said at a DOT-PARAM door, where every value arrives as
238
+ // text: the JSON graph_apply takes as a comp value, spelled inline —
239
+ // `.doc.body={"$edit":{"old":"a","new":"b"}}`. Undefined for anything else, so
240
+ // ordinary prose (JSON included) stays a literal; only the reserved `$` sigil
241
+ // is read as an operator. Without this the JSON stored AS the body and
242
+ // clobbered the doc it was meant to patch (T-33926).
243
+ export let fieldOp = (raw)=>{
244
+ if (!raw.trimStart().startsWith('{')) return;
245
+ let v;
246
+ try {
247
+ v = JSON.parse(raw);
248
+ } catch {
249
+ return;
250
+ }
251
+ return isFieldOp(v) ? v : undefined;
252
+ };
253
+ // A batch gets one value language before any writer observes it. Unknown
254
+ // components and server-owned columns stay untouched for the db allowlist;
255
+ // every declared scalar leaves in canonical form.
256
+ export let normalizeChanges = (changes, ctx = {})=>changes.map((change)=>{
257
+ let eid = requiredRef(ref('eid'), change.eid, ctx);
258
+ if (change.comp == null) return {
259
+ ...change,
260
+ eid
261
+ };
262
+ let comp = Object.fromEntries(Object.entries(change.comp).map(([name, value])=>{
263
+ // Structured columns are graph values, not text editors. The host
264
+ // admits their schema; keep objects/arrays intact on the write wire.
265
+ let schema = vocab.def(change.name)?.properties?.[name];
266
+ if (schema?.type == 'object' || schema?.type == 'array') {
267
+ return [
268
+ name,
269
+ value
270
+ ];
271
+ }
272
+ // A field OPERATOR (e.g. { $edit }) is not a literal — pass it through
273
+ // untouched for apply() to resolve against the current stored value.
274
+ // A scalar parser would (rightly) reject the object as non-text.
275
+ if (isFieldOp(value)) return [
276
+ name,
277
+ value
278
+ ];
279
+ let p = name in (comps[change.name] ?? {}) ? propAt(change.name, name) : undefined;
280
+ if (!p) return [
281
+ name,
282
+ value
283
+ ];
284
+ // An edge's ends ARE its identity: a value that resolves to nothing is
285
+ // a name nobody can hold, refused here rather than stored as null.
286
+ if (change.name == 'edge' && name != 'ord') {
287
+ return [
288
+ name,
289
+ requiredRef(p, value, ctx)
290
+ ];
291
+ }
292
+ return [
293
+ name,
294
+ parseProp(p, value, ctx)
295
+ ];
296
+ }));
297
+ return {
298
+ ...change,
299
+ eid,
300
+ comp
301
+ };
302
+ });
303
+ //# sourceMappingURL=props.js.map