@shivaedev/work-board 0.2.1 → 0.4.0

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 (420) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +208 -11
  3. package/dist/attention/overviewHtml.d.ts +3 -0
  4. package/dist/attention/overviewHtml.d.ts.map +1 -0
  5. package/dist/attention/overviewHtml.js +41 -0
  6. package/dist/attention/overviewHtml.js.map +1 -0
  7. package/dist/attention/requests.d.ts +24 -0
  8. package/dist/attention/requests.d.ts.map +1 -0
  9. package/dist/attention/requests.js +40 -0
  10. package/dist/attention/requests.js.map +1 -0
  11. package/dist/attention/style.d.ts +2 -0
  12. package/dist/attention/style.d.ts.map +1 -0
  13. package/dist/attention/style.js +10 -0
  14. package/dist/attention/style.js.map +1 -0
  15. package/dist/board.d.ts.map +1 -1
  16. package/dist/board.js +15 -2
  17. package/dist/board.js.map +1 -1
  18. package/dist/cli.js +1 -1
  19. package/dist/files/changes.d.ts +1 -0
  20. package/dist/files/changes.d.ts.map +1 -1
  21. package/dist/files/changes.js +5 -10
  22. package/dist/files/changes.js.map +1 -1
  23. package/dist/files/home.d.ts.map +1 -1
  24. package/dist/files/home.js +4 -0
  25. package/dist/files/home.js.map +1 -1
  26. package/dist/files/list.d.ts +7 -0
  27. package/dist/files/list.d.ts.map +1 -1
  28. package/dist/files/list.js +23 -13
  29. package/dist/files/list.js.map +1 -1
  30. package/dist/files/markdownPath.d.ts +3 -0
  31. package/dist/files/markdownPath.d.ts.map +1 -0
  32. package/dist/files/markdownPath.js +31 -0
  33. package/dist/files/markdownPath.js.map +1 -0
  34. package/dist/files/url.d.ts +2 -0
  35. package/dist/files/url.d.ts.map +1 -0
  36. package/dist/files/url.js +4 -0
  37. package/dist/files/url.js.map +1 -0
  38. package/dist/files/watchDirectories.d.ts +9 -0
  39. package/dist/files/watchDirectories.d.ts.map +1 -0
  40. package/dist/files/watchDirectories.js +33 -0
  41. package/dist/files/watchDirectories.js.map +1 -0
  42. package/dist/history/baseline.d.ts +19 -0
  43. package/dist/history/baseline.d.ts.map +1 -0
  44. package/dist/history/baseline.js +40 -0
  45. package/dist/history/baseline.js.map +1 -0
  46. package/dist/history/compare.d.ts +14 -0
  47. package/dist/history/compare.d.ts.map +1 -0
  48. package/dist/history/compare.js +47 -0
  49. package/dist/history/compare.js.map +1 -0
  50. package/dist/history/documents.d.ts +10 -0
  51. package/dist/history/documents.d.ts.map +1 -0
  52. package/dist/history/documents.js +15 -0
  53. package/dist/history/documents.js.map +1 -0
  54. package/dist/history/fields.d.ts +3 -0
  55. package/dist/history/fields.d.ts.map +1 -0
  56. package/dist/history/fields.js +27 -0
  57. package/dist/history/fields.js.map +1 -0
  58. package/dist/history/html.d.ts +4 -0
  59. package/dist/history/html.d.ts.map +1 -0
  60. package/dist/history/html.js +22 -0
  61. package/dist/history/html.js.map +1 -0
  62. package/dist/history/limits.d.ts +3 -0
  63. package/dist/history/limits.d.ts.map +1 -0
  64. package/dist/history/limits.js +3 -0
  65. package/dist/history/limits.js.map +1 -0
  66. package/dist/history/response.d.ts +4 -0
  67. package/dist/history/response.d.ts.map +1 -0
  68. package/dist/history/response.js +20 -0
  69. package/dist/history/response.js.map +1 -0
  70. package/dist/history/schema.d.ts +24 -0
  71. package/dist/history/schema.d.ts.map +1 -0
  72. package/dist/history/schema.js +19 -0
  73. package/dist/history/schema.js.map +1 -0
  74. package/dist/history/script.d.ts +2 -0
  75. package/dist/history/script.d.ts.map +1 -0
  76. package/dist/history/script.js +113 -0
  77. package/dist/history/script.js.map +1 -0
  78. package/dist/http/assets.d.ts.map +1 -1
  79. package/dist/http/assets.js +18 -1
  80. package/dist/http/assets.js.map +1 -1
  81. package/dist/http/history.d.ts +7 -0
  82. package/dist/http/history.d.ts.map +1 -0
  83. package/dist/http/history.js +45 -0
  84. package/dist/http/history.js.map +1 -0
  85. package/dist/http/identity.d.ts +7 -0
  86. package/dist/http/identity.d.ts.map +1 -0
  87. package/dist/http/identity.js +38 -0
  88. package/dist/http/identity.js.map +1 -0
  89. package/dist/http/overview.d.ts +5 -0
  90. package/dist/http/overview.d.ts.map +1 -0
  91. package/dist/http/overview.js +13 -0
  92. package/dist/http/overview.js.map +1 -0
  93. package/dist/http/page.d.ts +3 -2
  94. package/dist/http/page.d.ts.map +1 -1
  95. package/dist/http/page.js +34 -13
  96. package/dist/http/page.js.map +1 -1
  97. package/dist/http/search.d.ts +5 -0
  98. package/dist/http/search.d.ts.map +1 -0
  99. package/dist/http/search.js +11 -0
  100. package/dist/http/search.js.map +1 -0
  101. package/dist/http/work.d.ts +6 -0
  102. package/dist/http/work.d.ts.map +1 -0
  103. package/dist/http/work.js +22 -0
  104. package/dist/http/work.js.map +1 -0
  105. package/dist/metadata/attentionProblems.d.ts +4 -0
  106. package/dist/metadata/attentionProblems.d.ts.map +1 -0
  107. package/dist/metadata/attentionProblems.js +16 -0
  108. package/dist/metadata/attentionProblems.js.map +1 -0
  109. package/dist/metadata/backlinks.d.ts +8 -0
  110. package/dist/metadata/backlinks.d.ts.map +1 -0
  111. package/dist/metadata/backlinks.js +34 -0
  112. package/dist/metadata/backlinks.js.map +1 -0
  113. package/dist/metadata/fields.d.ts +37 -0
  114. package/dist/metadata/fields.d.ts.map +1 -0
  115. package/dist/metadata/fields.js +25 -0
  116. package/dist/metadata/fields.js.map +1 -0
  117. package/dist/metadata/links.d.ts +4 -0
  118. package/dist/metadata/links.d.ts.map +1 -0
  119. package/dist/metadata/links.js +18 -0
  120. package/dist/metadata/links.js.map +1 -0
  121. package/dist/metadata/locations.d.ts +3 -0
  122. package/dist/metadata/locations.d.ts.map +1 -0
  123. package/dist/metadata/locations.js +35 -0
  124. package/dist/metadata/locations.js.map +1 -0
  125. package/dist/metadata/model.d.ts +15 -0
  126. package/dist/metadata/model.d.ts.map +1 -0
  127. package/dist/metadata/model.js +13 -0
  128. package/dist/metadata/model.js.map +1 -0
  129. package/dist/metadata/parse.d.ts +16 -0
  130. package/dist/metadata/parse.d.ts.map +1 -0
  131. package/dist/metadata/parse.js +48 -0
  132. package/dist/metadata/parse.js.map +1 -0
  133. package/dist/metadata/problems.d.ts +4 -0
  134. package/dist/metadata/problems.d.ts.map +1 -0
  135. package/dist/metadata/problems.js +59 -0
  136. package/dist/metadata/problems.js.map +1 -0
  137. package/dist/metadata/relationshipLabel.d.ts +2 -0
  138. package/dist/metadata/relationshipLabel.d.ts.map +1 -0
  139. package/dist/metadata/relationshipLabel.js +14 -0
  140. package/dist/metadata/relationshipLabel.js.map +1 -0
  141. package/dist/metadata/schema.d.ts +44 -0
  142. package/dist/metadata/schema.d.ts.map +1 -0
  143. package/dist/metadata/schema.js +36 -0
  144. package/dist/metadata/schema.js.map +1 -0
  145. package/dist/metadata/sourceLinks.d.ts +5 -0
  146. package/dist/metadata/sourceLinks.d.ts.map +1 -0
  147. package/dist/metadata/sourceLinks.js +44 -0
  148. package/dist/metadata/sourceLinks.js.map +1 -0
  149. package/dist/page/attentionDetails.d.ts +4 -0
  150. package/dist/page/attentionDetails.d.ts.map +1 -0
  151. package/dist/page/attentionDetails.js +13 -0
  152. package/dist/page/attentionDetails.js.map +1 -0
  153. package/dist/page/backlinksHtml.d.ts +3 -0
  154. package/dist/page/backlinksHtml.d.ts.map +1 -0
  155. package/dist/page/backlinksHtml.js +16 -0
  156. package/dist/page/backlinksHtml.js.map +1 -0
  157. package/dist/page/board.d.ts +1 -1
  158. package/dist/page/board.d.ts.map +1 -1
  159. package/dist/page/board.js +14 -4
  160. package/dist/page/board.js.map +1 -1
  161. package/dist/page/client.d.ts +2 -1
  162. package/dist/page/client.d.ts.map +1 -1
  163. package/dist/page/client.js +66 -7
  164. package/dist/page/client.js.map +1 -1
  165. package/dist/page/criteriaEvidence.d.ts +4 -0
  166. package/dist/page/criteriaEvidence.d.ts.map +1 -0
  167. package/dist/page/criteriaEvidence.js +27 -0
  168. package/dist/page/criteriaEvidence.js.map +1 -0
  169. package/dist/page/diagrams.d.ts +1 -1
  170. package/dist/page/diagrams.d.ts.map +1 -1
  171. package/dist/page/diagrams.js +12 -4
  172. package/dist/page/diagrams.js.map +1 -1
  173. package/dist/page/document.d.ts +1 -1
  174. package/dist/page/document.d.ts.map +1 -1
  175. package/dist/page/document.js +6 -3
  176. package/dist/page/document.js.map +1 -1
  177. package/dist/page/libraryScript.d.ts +2 -0
  178. package/dist/page/libraryScript.d.ts.map +1 -0
  179. package/dist/page/libraryScript.js +73 -0
  180. package/dist/page/libraryScript.js.map +1 -0
  181. package/dist/page/metadata.d.ts +5 -0
  182. package/dist/page/metadata.d.ts.map +1 -0
  183. package/dist/page/metadata.js +34 -0
  184. package/dist/page/metadata.js.map +1 -0
  185. package/dist/page/metadataDetails.d.ts +4 -0
  186. package/dist/page/metadataDetails.d.ts.map +1 -0
  187. package/dist/page/metadataDetails.js +23 -0
  188. package/dist/page/metadataDetails.js.map +1 -0
  189. package/dist/page/metadataLinks.d.ts +6 -0
  190. package/dist/page/metadataLinks.d.ts.map +1 -0
  191. package/dist/page/metadataLinks.js +31 -0
  192. package/dist/page/metadataLinks.js.map +1 -0
  193. package/dist/page/nav.d.ts.map +1 -1
  194. package/dist/page/nav.js +3 -3
  195. package/dist/page/nav.js.map +1 -1
  196. package/dist/page/navigationScript.d.ts +2 -0
  197. package/dist/page/navigationScript.d.ts.map +1 -0
  198. package/dist/page/navigationScript.js +104 -0
  199. package/dist/page/navigationScript.js.map +1 -0
  200. package/dist/page/readingStateScript.d.ts +2 -0
  201. package/dist/page/readingStateScript.d.ts.map +1 -0
  202. package/dist/page/readingStateScript.js +62 -0
  203. package/dist/page/readingStateScript.js.map +1 -0
  204. package/dist/page/readingStyles.d.ts +2 -0
  205. package/dist/page/readingStyles.d.ts.map +1 -0
  206. package/dist/page/readingStyles.js +29 -0
  207. package/dist/page/readingStyles.js.map +1 -0
  208. package/dist/page/readingTools.d.ts +3 -0
  209. package/dist/page/readingTools.d.ts.map +1 -0
  210. package/dist/page/readingTools.js +10 -0
  211. package/dist/page/readingTools.js.map +1 -0
  212. package/dist/page/recordedEvidence.d.ts +4 -0
  213. package/dist/page/recordedEvidence.d.ts.map +1 -0
  214. package/dist/page/recordedEvidence.js +10 -0
  215. package/dist/page/recordedEvidence.js.map +1 -0
  216. package/dist/page/searchDialog.d.ts +3 -0
  217. package/dist/page/searchDialog.d.ts.map +1 -0
  218. package/dist/page/searchDialog.js +16 -0
  219. package/dist/page/searchDialog.js.map +1 -0
  220. package/dist/page/searchResultsScript.d.ts +2 -0
  221. package/dist/page/searchResultsScript.d.ts.map +1 -0
  222. package/dist/page/searchResultsScript.js +64 -0
  223. package/dist/page/searchResultsScript.js.map +1 -0
  224. package/dist/page/searchScript.d.ts +2 -0
  225. package/dist/page/searchScript.d.ts.map +1 -0
  226. package/dist/page/searchScript.js +73 -0
  227. package/dist/page/searchScript.js.map +1 -0
  228. package/dist/page/shell.d.ts +1 -1
  229. package/dist/page/shell.d.ts.map +1 -1
  230. package/dist/page/shell.js +23 -5
  231. package/dist/page/shell.js.map +1 -1
  232. package/dist/page/stateScript.d.ts +2 -0
  233. package/dist/page/stateScript.d.ts.map +1 -0
  234. package/dist/page/stateScript.js +55 -0
  235. package/dist/page/stateScript.js.map +1 -0
  236. package/dist/page/style.d.ts.map +1 -1
  237. package/dist/page/style.js +15 -34
  238. package/dist/page/style.js.map +1 -1
  239. package/dist/page/swap.d.ts +1 -1
  240. package/dist/page/swap.d.ts.map +1 -1
  241. package/dist/page/swap.js +4 -1
  242. package/dist/page/swap.js.map +1 -1
  243. package/dist/page/workspaceStyles.d.ts +3 -0
  244. package/dist/page/workspaceStyles.d.ts.map +1 -0
  245. package/dist/page/workspaceStyles.js +79 -0
  246. package/dist/page/workspaceStyles.js.map +1 -0
  247. package/dist/render/documentHeadings.d.ts +667 -0
  248. package/dist/render/documentHeadings.d.ts.map +1 -0
  249. package/dist/render/documentHeadings.js +45 -0
  250. package/dist/render/documentHeadings.js.map +1 -0
  251. package/dist/render/documentLinks.d.ts +659 -0
  252. package/dist/render/documentLinks.d.ts.map +1 -0
  253. package/dist/render/documentLinks.js +19 -0
  254. package/dist/render/documentLinks.js.map +1 -0
  255. package/dist/render/markdown.d.ts +7 -1
  256. package/dist/render/markdown.d.ts.map +1 -1
  257. package/dist/render/markdown.js +13 -2
  258. package/dist/render/markdown.js.map +1 -1
  259. package/dist/search/attentionEntries.d.ts +4 -0
  260. package/dist/search/attentionEntries.d.ts.map +1 -0
  261. package/dist/search/attentionEntries.js +20 -0
  262. package/dist/search/attentionEntries.js.map +1 -0
  263. package/dist/search/collector.d.ts +13 -0
  264. package/dist/search/collector.d.ts.map +1 -0
  265. package/dist/search/collector.js +40 -0
  266. package/dist/search/collector.js.map +1 -0
  267. package/dist/search/entries.d.ts +10 -0
  268. package/dist/search/entries.d.ts.map +1 -0
  269. package/dist/search/entries.js +37 -0
  270. package/dist/search/entries.js.map +1 -0
  271. package/dist/search/linkCollector.d.ts +8 -0
  272. package/dist/search/linkCollector.d.ts.map +1 -0
  273. package/dist/search/linkCollector.js +16 -0
  274. package/dist/search/linkCollector.js.map +1 -0
  275. package/dist/search/match.d.ts +14 -0
  276. package/dist/search/match.d.ts.map +1 -0
  277. package/dist/search/match.js +26 -0
  278. package/dist/search/match.js.map +1 -0
  279. package/dist/search/metadataEntries.d.ts +4 -0
  280. package/dist/search/metadataEntries.d.ts.map +1 -0
  281. package/dist/search/metadataEntries.js +42 -0
  282. package/dist/search/metadataEntries.js.map +1 -0
  283. package/dist/search/snapshot.d.ts +13 -0
  284. package/dist/search/snapshot.d.ts.map +1 -0
  285. package/dist/search/snapshot.js +49 -0
  286. package/dist/search/snapshot.js.map +1 -0
  287. package/dist/views/items.d.ts +11 -0
  288. package/dist/views/items.d.ts.map +1 -0
  289. package/dist/views/items.js +48 -0
  290. package/dist/views/items.js.map +1 -0
  291. package/dist/views/projection.d.ts +15 -0
  292. package/dist/views/projection.d.ts.map +1 -0
  293. package/dist/views/projection.js +47 -0
  294. package/dist/views/projection.js.map +1 -0
  295. package/dist/views/savedScript.d.ts +2 -0
  296. package/dist/views/savedScript.d.ts.map +1 -0
  297. package/dist/views/savedScript.js +89 -0
  298. package/dist/views/savedScript.js.map +1 -0
  299. package/dist/views/state.d.ts +15 -0
  300. package/dist/views/state.d.ts.map +1 -0
  301. package/dist/views/state.js +45 -0
  302. package/dist/views/state.js.map +1 -0
  303. package/dist/views/tools.d.ts +3 -0
  304. package/dist/views/tools.d.ts.map +1 -0
  305. package/dist/views/tools.js +11 -0
  306. package/dist/views/tools.js.map +1 -0
  307. package/dist/views/workCards.d.ts +4 -0
  308. package/dist/views/workCards.d.ts.map +1 -0
  309. package/dist/views/workCards.js +23 -0
  310. package/dist/views/workCards.js.map +1 -0
  311. package/dist/views/workControls.d.ts +4 -0
  312. package/dist/views/workControls.d.ts.map +1 -0
  313. package/dist/views/workControls.js +32 -0
  314. package/dist/views/workControls.js.map +1 -0
  315. package/dist/views/workDetail.d.ts +13 -0
  316. package/dist/views/workDetail.d.ts.map +1 -0
  317. package/dist/views/workDetail.js +26 -0
  318. package/dist/views/workDetail.js.map +1 -0
  319. package/dist/views/workHtml.d.ts +15 -0
  320. package/dist/views/workHtml.d.ts.map +1 -0
  321. package/dist/views/workHtml.js +35 -0
  322. package/dist/views/workHtml.js.map +1 -0
  323. package/dist/views/workStyle.d.ts +2 -0
  324. package/dist/views/workStyle.d.ts.map +1 -0
  325. package/dist/views/workStyle.js +18 -0
  326. package/dist/views/workStyle.js.map +1 -0
  327. package/dist/views/workTable.d.ts +4 -0
  328. package/dist/views/workTable.d.ts.map +1 -0
  329. package/dist/views/workTable.js +19 -0
  330. package/dist/views/workTable.js.map +1 -0
  331. package/package.json +14 -10
  332. package/src/attention/overviewHtml.ts +44 -0
  333. package/src/attention/requests.ts +64 -0
  334. package/src/attention/style.ts +9 -0
  335. package/src/board.ts +16 -3
  336. package/src/cli.ts +1 -1
  337. package/src/files/changes.ts +6 -17
  338. package/src/files/home.ts +4 -0
  339. package/src/files/list.ts +25 -14
  340. package/src/files/markdownPath.ts +31 -0
  341. package/src/files/url.ts +3 -0
  342. package/src/files/watchDirectories.ts +60 -0
  343. package/src/history/baseline.ts +43 -0
  344. package/src/history/compare.ts +54 -0
  345. package/src/history/documents.ts +21 -0
  346. package/src/history/fields.ts +32 -0
  347. package/src/history/html.ts +23 -0
  348. package/src/history/limits.ts +2 -0
  349. package/src/history/response.ts +23 -0
  350. package/src/history/schema.ts +36 -0
  351. package/src/history/script.ts +112 -0
  352. package/src/http/assets.ts +18 -1
  353. package/src/http/history.ts +50 -0
  354. package/src/http/identity.ts +62 -0
  355. package/src/http/overview.ts +19 -0
  356. package/src/http/page.ts +52 -15
  357. package/src/http/search.ts +13 -0
  358. package/src/http/work.ts +41 -0
  359. package/src/metadata/attentionProblems.ts +18 -0
  360. package/src/metadata/backlinks.ts +46 -0
  361. package/src/metadata/fields.ts +26 -0
  362. package/src/metadata/links.ts +19 -0
  363. package/src/metadata/locations.ts +34 -0
  364. package/src/metadata/model.ts +27 -0
  365. package/src/metadata/parse.ts +62 -0
  366. package/src/metadata/problems.ts +66 -0
  367. package/src/metadata/relationshipLabel.ts +14 -0
  368. package/src/metadata/schema.ts +45 -0
  369. package/src/metadata/sourceLinks.ts +46 -0
  370. package/src/page/attentionDetails.ts +18 -0
  371. package/src/page/backlinksHtml.ts +18 -0
  372. package/src/page/board.ts +14 -4
  373. package/src/page/client.ts +66 -7
  374. package/src/page/criteriaEvidence.ts +36 -0
  375. package/src/page/diagrams.ts +12 -4
  376. package/src/page/document.ts +6 -3
  377. package/src/page/libraryScript.ts +72 -0
  378. package/src/page/metadata.ts +40 -0
  379. package/src/page/metadataDetails.ts +26 -0
  380. package/src/page/metadataLinks.ts +35 -0
  381. package/src/page/nav.ts +5 -4
  382. package/src/page/navigationScript.ts +103 -0
  383. package/src/page/readingStateScript.ts +61 -0
  384. package/src/page/readingStyles.ts +28 -0
  385. package/src/page/readingTools.ts +12 -0
  386. package/src/page/recordedEvidence.ts +12 -0
  387. package/src/page/searchDialog.ts +16 -0
  388. package/src/page/searchResultsScript.ts +63 -0
  389. package/src/page/searchScript.ts +72 -0
  390. package/src/page/shell.ts +32 -5
  391. package/src/page/stateScript.ts +54 -0
  392. package/src/page/style.ts +15 -35
  393. package/src/page/swap.ts +4 -1
  394. package/src/page/workspaceStyles.ts +79 -0
  395. package/src/render/documentHeadings.ts +52 -0
  396. package/src/render/documentLinks.ts +19 -0
  397. package/src/render/markdown.ts +21 -4
  398. package/src/search/attentionEntries.ts +22 -0
  399. package/src/search/collector.ts +44 -0
  400. package/src/search/entries.ts +51 -0
  401. package/src/search/linkCollector.ts +16 -0
  402. package/src/search/match.ts +28 -0
  403. package/src/search/metadataEntries.ts +44 -0
  404. package/src/search/snapshot.ts +59 -0
  405. package/src/views/items.ts +55 -0
  406. package/src/views/projection.ts +59 -0
  407. package/src/views/savedScript.ts +88 -0
  408. package/src/views/state.ts +47 -0
  409. package/src/views/tools.ts +11 -0
  410. package/src/views/workCards.ts +26 -0
  411. package/src/views/workControls.ts +38 -0
  412. package/src/views/workDetail.ts +28 -0
  413. package/src/views/workHtml.ts +39 -0
  414. package/src/views/workStyle.ts +17 -0
  415. package/src/views/workTable.ts +21 -0
  416. package/dist/index.d.ts +0 -2
  417. package/dist/index.d.ts.map +0 -1
  418. package/dist/index.js +0 -2
  419. package/dist/index.js.map +0 -1
  420. package/src/index.ts +0 -1
package/src/page/style.ts CHANGED
@@ -1,36 +1,13 @@
1
- const tokens = `
2
- :root {
3
- color-scheme: light dark;
4
- --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
5
- --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
6
- --bg: #ffffff; --surface: #f6f8fa; --text: #1f2328; --muted: #59636e; --border: #d1d9e0; --link: #0969da; --danger: #b3261e;
7
- }
8
- @media (prefers-color-scheme: dark) {
9
- :root { --bg: #1e1e1e; --surface: #272727; --text: #e8e8e8; --muted: #a8a8a8; --border: #3d3d3d; --link: #58a6ff; --danger: #ff8a80; }
10
- }
11
- `;
12
-
13
- const page = `
14
- body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--sans); }
15
- a { color: var(--link); }
16
- .page { box-sizing: content-box; max-width: 72ch; margin: 0 auto; padding: 0 16px 64px; }
17
- .bar { display: flex; align-items: flex-start; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
18
- .files { flex: 1; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
19
- .files a { color: var(--text); text-decoration: none; }
20
- .files a:hover, .files a[aria-current="page"] { color: var(--link); text-decoration: underline; }
21
- .files details[open] { flex-basis: 100%; }
22
- .files summary { cursor: pointer; color: var(--muted); }
23
- .files ul { list-style: none; margin: 4px 0 8px; padding: 0 0 0 12px; border-left: 1px solid var(--border); }
24
- .age { color: var(--muted); font: 12px var(--mono); margin-left: 6px; }
25
- .live { color: var(--muted); font: 12px/1.9 var(--mono); }
26
- .live[data-state="down"], .live[data-state="stale"] { color: var(--danger); }
27
- .meta { color: var(--muted); font-size: 14px; margin: 0; }
28
- .meta .age { margin: 0; }
29
- `;
1
+ import { attentionStyle } from "#attention/style.ts";
2
+ import { workStyle } from "#views/workStyle.ts";
3
+ import { metadataStyles } from "./metadata.ts";
4
+ import { readingStyles } from "./readingStyles.ts";
5
+ import { searchStyles } from "./searchDialog.ts";
6
+ import { layout, theme } from "./workspaceStyles.ts";
30
7
 
31
8
  const prose = `
32
9
  h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; margin: 1.6em 0 0.5em; }
33
- h1 { font-size: 1.9em; margin-top: 1em; }
10
+ h1 { overflow-wrap: anywhere; font-size: 1.9em; margin-top: 1em; }
34
11
  h2 { font-size: 1.45em; }
35
12
  h3 { font-size: 1.15em; }
36
13
  h1 strong, h2 strong, h3 strong { font-weight: inherit; }
@@ -43,7 +20,8 @@ code { font: 0.875em var(--mono); background: var(--surface); padding: 0.1em 0.3
43
20
  pre { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
44
21
  pre code { background: none; padding: 0; font-size: 0.85em; }
45
22
  .shiki span { color: var(--shiki-light); }
46
- @media (prefers-color-scheme: dark) { .shiki span { color: var(--shiki-dark); } }
23
+ @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .shiki span { color: var(--shiki-dark); } }
24
+ :root[data-theme="dark"] .shiki span { color: var(--shiki-dark); }
47
25
  table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 0.925em; }
48
26
  th, td { text-align: left; vertical-align: top; padding: 6px 10px; border: 1px solid var(--border); }
49
27
  tr:nth-child(2n) td { background: var(--surface); }
@@ -59,9 +37,11 @@ const board = `
59
37
  .board-head .intro { color: var(--muted); }
60
38
  .counts { margin: 0; }
61
39
  .counts b { font-variant-numeric: tabular-nums; }
62
- .board section { margin-top: 2.2em; }
63
- .board section > h2 { margin: 0 0 0.2em; }
64
- .item, .notes { padding: 0.9em 0 0.1em; border-top: 1px solid var(--border); }
40
+ .board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: var(--space); margin-top: 2em; align-items: start; }
41
+ .board section { min-width: 0; }
42
+ .board section > h2 { margin: 0 0 0.8em; font-size: 1.1em; overflow-wrap: anywhere; }
43
+ .item, .notes { padding: var(--card-space); margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); overflow-wrap: anywhere; }
44
+ .item > :last-child, .notes > :last-child { margin-bottom: 0; }
65
45
  .item > h3 { margin: 0 0 0.4em; }
66
46
  .item > h3 > code:first-child { background: none; padding: 0; margin-right: 0.6em; color: var(--muted); font-weight: 400; }
67
47
  footer { margin-top: 2.5em; padding-top: 1em; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.925em; }
@@ -76,4 +56,4 @@ figure.diagram[data-state="failed"]::after { content: attr(data-error); color: v
76
56
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
77
57
  `;
78
58
 
79
- export const style = tokens + page + prose + board + diagrams;
59
+ export const style = theme + layout + prose + board + diagrams + readingStyles() + searchStyles + metadataStyles + workStyle() + attentionStyle();
package/src/page/swap.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const swap = `
2
- const containers = new Set(["DIV", "SECTION", "ARTICLE", "HEADER", "FOOTER", "MAIN", "NAV"]);
2
+ const containers = new Set(["DIV", "SECTION", "ARTICLE", "HEADER", "FOOTER", "MAIN", "NAV", "FORM", "SELECT", "LABEL", "ASIDE"]);
3
3
 
4
4
  const structural = (element) => [...element.childNodes].every((node) => node.nodeType === 1 || node.textContent.trim() === "");
5
5
 
@@ -56,6 +56,8 @@ const matches = (a, b) => {
56
56
  };
57
57
 
58
58
  const patch = (current, incoming) => {
59
+ const selected = current.tagName === "SELECT" ? current.value : null;
60
+ const fallback = incoming.tagName === "SELECT" ? incoming.value : null;
59
61
  if (!structural(current) || !structural(incoming)) {
60
62
  current.replaceChildren(...incoming.childNodes);
61
63
  for (const child of current.children) remember(child);
@@ -83,6 +85,7 @@ const patch = (current, incoming) => {
83
85
  i++;
84
86
  j++;
85
87
  }
88
+ if (selected !== null) current.value = [...current.options].some((option) => option.value === selected) ? selected : fallback;
86
89
  };
87
90
 
88
91
  const keysOf = (root) => {
@@ -0,0 +1,79 @@
1
+ export const layout = `
2
+ * { box-sizing: border-box; }
3
+ body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--sans); }
4
+ a { color: var(--link); }
5
+ button, select { font: inherit; color: inherit; }
6
+ button, select, summary { cursor: pointer; }
7
+ button, select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); }
8
+ :focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
9
+ .skip { position: fixed; top: -100px; left: 16px; z-index: 5; padding: 8px 16px; background: var(--card); }
10
+ .skip:focus { top: 8px; }
11
+ .workspace { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
12
+ :root[data-sidebar="closed"] .workspace { grid-template-columns: minmax(0, 1fr); }
13
+ .sidebar { --focus: #e2bc79; position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; padding: var(--space) 16px; background: var(--sidebar); color: var(--sidebar-text); }
14
+ .sidebar[hidden] { display: none; }
15
+ .brand { display: block; padding: 0 12px 28px; font-size: 24px; font-weight: 600; letter-spacing: -0.8px; text-decoration: none; color: var(--sidebar-text); }
16
+ .brand span { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--sidebar-muted); }
17
+ .sidebar .nav-heading { margin: 0 12px 12px; font: 600 12px var(--sans); color: var(--sidebar-muted); }
18
+ .files { font-size: 14px; }
19
+ .files ul { list-style: none; margin: 0 0 10px; padding: 0; }
20
+ .files li { display: flex; align-items: baseline; gap: 8px; margin: 0; padding: 4px 10px; border-radius: 5px; }
21
+ .files li:has(a[aria-current="page"]) { background: #385242; }
22
+ .files a { flex: 1; min-width: 0; color: var(--sidebar-text); text-decoration: none; overflow-wrap: anywhere; }
23
+ .files a:hover, .files a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
24
+ .files details { margin: 8px 0; }
25
+ .files summary { padding: 6px 10px; color: var(--sidebar-muted); overflow-wrap: anywhere; }
26
+ .files details ul { margin-left: 14px; border-left: 1px solid var(--sidebar-border); }
27
+ .age { color: var(--muted); font: 12px var(--mono); margin-left: 6px; white-space: nowrap; }
28
+ .files .age { color: var(--sidebar-muted); margin: 0; flex-shrink: 0; }
29
+ .page { min-width: 0; }
30
+ .bar { display: flex; align-items: center; gap: 16px; padding: 16px var(--space); border-bottom: 1px solid var(--border); font-size: 13px; }
31
+ .bar button { flex-shrink: 0; }
32
+ .breadcrumbs { display: flex; flex-wrap: wrap; gap: 6px 10px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
33
+ .breadcrumbs > span:not(.separator) { min-width: 0; }
34
+ .separator { color: var(--muted); }
35
+ .live { color: var(--muted); font: 12px/1.9 var(--mono); }
36
+ .live[data-state="down"], .live[data-state="stale"] { color: var(--danger); }
37
+ .preferences { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; align-items: center; padding: 14px var(--space) 0; color: var(--muted); font-size: 12px; }
38
+ .preference { display: flex; gap: 8px; align-items: center; }
39
+ #preference-status:empty { display: none; }
40
+ #doc { padding: var(--space) var(--space) 64px; min-width: 0; }
41
+ .document-view { max-width: calc(72ch + 2 * var(--space)); margin-inline: auto; }
42
+ .board-view { max-width: 1600px; margin-inline: auto; }
43
+ .meta { color: var(--muted); font-size: 13px; margin: 0; overflow-wrap: anywhere; }
44
+ .meta .age { margin: 0; }
45
+ @media (max-width: 760px) {
46
+ .workspace { grid-template-columns: minmax(0, 1fr); }
47
+ .sidebar { position: static; height: auto; max-height: 42vh; border-bottom: 1px solid var(--border); }
48
+ .brand { padding-bottom: 16px; }
49
+ .bar { flex-wrap: wrap; gap: 12px; }
50
+ .breadcrumbs { flex-basis: calc(100% - 100px); }
51
+ .live { margin-left: auto; }
52
+ .preferences { justify-content: flex-start; }
53
+ :root { --space: 18px; }
54
+ }
55
+ `;
56
+ const light = `
57
+ color-scheme: light;
58
+ --bg: #f7f8f4; --surface: #edf1e7; --card: #ffffff; --text: #263c34; --muted: #596957;
59
+ --border: #d5dfd0; --link: #315f45; --danger: #a03024; --focus: #976323;
60
+ --sidebar: #203a30; --sidebar-text: #e7eee2; --sidebar-muted: #b6c8ad; --sidebar-border: #4a624c;
61
+ `;
62
+ const dark = `
63
+ color-scheme: dark;
64
+ --bg: #18251f; --surface: #26382d; --card: #203027; --text: #e7eee2; --muted: #b0c1a6;
65
+ --border: #455a48; --link: #b1d4a1; --danger: #ffafa2; --focus: #e2bc79;
66
+ --sidebar: #142219; --sidebar-text: #e7eee2; --sidebar-muted: #b6c8ad; --sidebar-border: #455a48;
67
+ `;
68
+
69
+ export const theme = `
70
+ :root {
71
+ --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
72
+ --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
73
+ --space: 24px; --card-space: 20px;
74
+ ${light}
75
+ }
76
+ @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { ${dark} } }
77
+ :root[data-theme="dark"] { ${dark} }
78
+ :root[data-density="compact"] { --space: 16px; --card-space: 12px; }
79
+ `;
@@ -0,0 +1,52 @@
1
+ import { defineHastPlugin } from "satteri";
2
+
3
+ export interface Heading {
4
+ readonly depth: number;
5
+ readonly id: string;
6
+ readonly title: string;
7
+ }
8
+
9
+ export function documentHeadings() {
10
+ const entries: Heading[] = [];
11
+ const used = new Set<string>();
12
+ const plugin = defineHastPlugin({
13
+ element: {
14
+ filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
15
+ visit: (element, context) => {
16
+ if (element.properties.id !== undefined) {
17
+ return;
18
+ }
19
+ const title = context.textContent(element).trim();
20
+ const slug =
21
+ title
22
+ .normalize("NFKC")
23
+ .toLowerCase()
24
+ .replace(/[^\p{Letter}\p{Number}\s_-]/gu, "")
25
+ .trim()
26
+ .replace(/\s+/gu, "-") || "section";
27
+ const base = `heading-${slug}`;
28
+ let id = base;
29
+ for (let suffix = 2; used.has(id); suffix += 1) {
30
+ id = `${base}-${suffix}`;
31
+ }
32
+ used.add(id);
33
+ entries.push({ depth: Number(element.tagName.slice(1)), id, title });
34
+ return {
35
+ ...element,
36
+ children: [
37
+ ...element.children,
38
+ {
39
+ children: [],
40
+ properties: { ariaLabel: `Link to ${title || "section"}`, className: ["heading-anchor"], href: `#${id}` },
41
+ tagName: "a",
42
+ type: "element" as const,
43
+ },
44
+ ],
45
+ properties: { ...element.properties, id, tabIndex: -1 },
46
+ };
47
+ },
48
+ },
49
+ name: "work-board-headings",
50
+ });
51
+ return { entries, plugin };
52
+ }
@@ -0,0 +1,19 @@
1
+ import { defineHastPlugin } from "satteri";
2
+ import { fileUrl } from "#files/url.ts";
3
+
4
+ export function documentLinks(file: string) {
5
+ return defineHastPlugin({
6
+ element: {
7
+ filter: ["a"],
8
+ visit: (element) => {
9
+ const href = element.properties.href;
10
+ if (typeof href !== "string" || href.startsWith("#") || href.startsWith("/") || /^[a-z][a-z\d+.-]*:/iu.exec(href) !== null) {
11
+ return;
12
+ }
13
+ const target = new URL(href, `http://work-board.local${fileUrl(file)}`);
14
+ return { ...element, properties: { ...element.properties, href: target.pathname + target.search + target.hash } };
15
+ },
16
+ },
17
+ name: "work-board-document-links",
18
+ });
19
+ }
@@ -1,16 +1,33 @@
1
1
  import { Effect } from "effect";
2
- import { markdownToHtml } from "satteri";
2
+ import { type HastPluginInput, markdownToHtml } from "satteri";
3
3
  import { codeBlocks } from "./code.ts";
4
+ import type { documentHeadings } from "./documentHeadings.ts";
5
+ import { documentLinks } from "./documentLinks.ts";
4
6
  import { RenderFailed } from "./failed.ts";
5
7
  import { footnoteIds } from "./footnotes.ts";
6
8
  import { Highlighter } from "./highlighter.ts";
7
9
 
8
- export const renderMarkdown = Effect.fn("WorkBoard.renderMarkdown")(function* (source: string, idPrefix = "") {
10
+ export interface RenderOptions {
11
+ readonly file?: string;
12
+ readonly headings?: ReturnType<typeof documentHeadings>;
13
+ readonly idPrefix?: string;
14
+ }
15
+
16
+ export const renderMarkdown = Effect.fn("WorkBoard.renderMarkdown")(function* (source: string, options: RenderOptions = {}) {
9
17
  const highlighter = yield* Highlighter;
18
+ const plugins: HastPluginInput[] = [codeBlocks(highlighter)];
19
+ if (options.idPrefix !== undefined) {
20
+ plugins.push(footnoteIds(options.idPrefix));
21
+ }
22
+ if (options.file !== undefined) {
23
+ plugins.push(documentLinks(options.file));
24
+ }
25
+ if (options.headings !== undefined) {
26
+ plugins.push(options.headings.plugin);
27
+ }
10
28
  const { html } = yield* Effect.tryPromise({
11
29
  catch: (cause) => new RenderFailed({ cause }),
12
- try: async () =>
13
- markdownToHtml(source, { hastPlugins: idPrefix === "" ? [codeBlocks(highlighter)] : [codeBlocks(highlighter), footnoteIds(idPrefix)] }),
30
+ try: async () => markdownToHtml(source, { hastPlugins: plugins }),
14
31
  });
15
32
  return html;
16
33
  });
@@ -0,0 +1,22 @@
1
+ import type { MetadataDocument } from "#metadata/model.ts";
2
+ import type { Entry } from "./entries.ts";
3
+
4
+ export function attentionEntries(document: MetadataDocument, href: string): readonly Entry[] {
5
+ const requests = document.parsed.fields.attention ?? [];
6
+ return requests.flatMap((request, index) => {
7
+ if (requests.filter((other) => other.id === request.id).length !== 1) {
8
+ return [];
9
+ }
10
+ const line = document.parsed.lines[`attention.${index}`] ?? document.parsed.lines.attention;
11
+ return [
12
+ {
13
+ file: document.file,
14
+ href: `${href}#attention-request-${encodeURIComponent(request.id)}`,
15
+ kind: "passage",
16
+ ...(line === undefined ? {} : { line }),
17
+ text: [request.reason, request.id, request.kind, request.state, ...request.responseFrom, ...request.unblocks].join(" "),
18
+ title: request.reason,
19
+ },
20
+ ];
21
+ });
22
+ }
@@ -0,0 +1,44 @@
1
+ import type { Element } from "hast";
2
+ import { defineHastPlugin } from "satteri";
3
+ import { fileUrl } from "#files/url.ts";
4
+ import type { Entry } from "./entries.ts";
5
+
6
+ function sourceLine(element: Element, first: number | undefined, length: number): { readonly line?: number } {
7
+ if (!element.position || first === undefined || element.position.start.line > length) {
8
+ return {};
9
+ }
10
+ return { line: first + element.position.start.line - 1 };
11
+ }
12
+
13
+ export function searchCollector(file: string, startLine: () => number | undefined, length: () => number) {
14
+ const entries: Entry[] = [];
15
+ let passage = "";
16
+ let label = file;
17
+ const plugin = defineHastPlugin({
18
+ element: {
19
+ filter: ["h1", "h2", "h3", "h4", "h5", "h6", "p", "pre", "li", "td", "th"],
20
+ visit: (element, context) => {
21
+ const text = context.textContent(element).replace(/\s+/gu, " ").trim();
22
+ if (!text || element.properties.id === "footnote-label") {
23
+ return;
24
+ }
25
+ const heading = element.tagName.startsWith("h") && element.tagName !== "th";
26
+ if (heading && typeof element.properties.id === "string") {
27
+ passage = element.properties.id;
28
+ label = text;
29
+ }
30
+ entries.push({
31
+ file,
32
+ href: fileUrl(file) + (passage ? `#${encodeURIComponent(passage)}` : ""),
33
+ kind: heading ? "heading" : "passage",
34
+ ...sourceLine(element, startLine(), length()),
35
+ text,
36
+ title: label,
37
+ });
38
+ },
39
+ },
40
+ name: "work-board-search-text",
41
+ });
42
+
43
+ return { entries, plugin };
44
+ }
@@ -0,0 +1,51 @@
1
+ import { markdownToHtml } from "satteri";
2
+ import { fileUrl } from "#files/url.ts";
3
+ import { boardOf } from "#render/board.ts";
4
+ import { documentHeadings } from "#render/documentHeadings.ts";
5
+ import { searchCollector } from "./collector.ts";
6
+ import { linkCollector } from "./linkCollector.ts";
7
+
8
+ export interface Entry {
9
+ readonly file: string;
10
+ readonly href: string;
11
+ readonly kind: "document" | "heading" | "passage";
12
+ readonly line?: number;
13
+ readonly text: string;
14
+ readonly title: string;
15
+ }
16
+
17
+ function fragmentLocation(source: string, fragment: string, bodyLine: number, seen: Map<string, number>): number | undefined {
18
+ const start = source.indexOf(fragment, seen.get(fragment) ?? 0);
19
+ if (start < 0) {
20
+ return undefined;
21
+ }
22
+ seen.set(fragment, start + fragment.length);
23
+ return bodyLine + source.slice(0, start).split("\n").length - 1;
24
+ }
25
+
26
+ export async function entriesOf(source: string, file: string, home: boolean, bodyLine = 1, links = new Set<string>()): Promise<readonly Entry[]> {
27
+ const headings = documentHeadings();
28
+ let fragmentLine: number | undefined = bodyLine;
29
+ let fragmentLength = 0;
30
+ const seenFragments = new Map<string, number>();
31
+ const { entries, plugin } = searchCollector(
32
+ file,
33
+ () => fragmentLine,
34
+ () => fragmentLength,
35
+ );
36
+ const board = home ? boardOf(source) : undefined;
37
+ const fragments = board
38
+ ? [board.title, board.intro, ...board.sections.flatMap((section) => [section.heading, section.notes, ...section.items]), board.footer]
39
+ : [source];
40
+ for (const fragment of fragments) {
41
+ if (fragment) {
42
+ fragmentLength = fragment.split("\n").length;
43
+ fragmentLine = board ? fragmentLocation(source, fragment, bodyLine, seenFragments) : bodyLine;
44
+ await markdownToHtml(board?.definitions ? `${fragment}\n\n${board.definitions}` : fragment, {
45
+ hastPlugins: [headings.plugin, plugin, linkCollector(links)],
46
+ });
47
+ }
48
+ }
49
+ const title = headings.entries.find((heading) => heading.depth === 1)?.title || file;
50
+ return [{ file, href: fileUrl(file), kind: "document", line: bodyLine, text: `${file} ${title}`, title }, ...entries];
51
+ }
@@ -0,0 +1,16 @@
1
+ import { defineHastPlugin } from "satteri";
2
+
3
+ export function linkCollector(links: Set<string>) {
4
+ return defineHastPlugin({
5
+ element: {
6
+ filter: ["a"],
7
+ visit: (element) => {
8
+ const href = element.properties.href;
9
+ if (typeof href === "string" && !href.startsWith("#")) {
10
+ links.add(href);
11
+ }
12
+ },
13
+ },
14
+ name: "work-board-link-collector",
15
+ });
16
+ }
@@ -0,0 +1,28 @@
1
+ import type { Entry } from "./entries.ts";
2
+
3
+ function normalize(text: string): string {
4
+ return text.normalize("NFKC").toLowerCase().replace(/\s+/gu, " ").trim();
5
+ }
6
+
7
+ export function searchMatch(entries: readonly Entry[], query: string) {
8
+ const phrase = normalize(query.slice(0, 200));
9
+ const terms = phrase.split(" ").filter(Boolean).slice(0, 8);
10
+ if (terms.length === 0) {
11
+ return { results: [], total: 0 };
12
+ }
13
+ const matches = entries
14
+ .flatMap((entry, order) => {
15
+ const text = normalize(entry.text);
16
+ if (!terms.every((term) => text.includes(term))) {
17
+ return [];
18
+ }
19
+ const at = Math.max(0, entry.text.toLowerCase().indexOf(terms[0] ?? ""));
20
+ const start = Math.max(0, at - 50);
21
+ const snippet = (start ? "…" : "") + entry.text.slice(start, start + 180) + (entry.text.length > start + 180 ? "…" : "");
22
+ const ranks = { document: 0, heading: 2, passage: 4 };
23
+ const rank = ranks[entry.kind] + (text.includes(phrase) ? 0 : 1);
24
+ return [{ entry: { ...entry, snippet }, order, rank }];
25
+ })
26
+ .sort((left, right) => left.rank - right.rank || left.order - right.order);
27
+ return { results: matches.slice(0, 40).map((match) => match.entry), total: matches.length };
28
+ }
@@ -0,0 +1,44 @@
1
+ import { fileUrl } from "#files/url.ts";
2
+ import { identityUrl } from "#metadata/links.ts";
3
+ import type { MetadataDocument, MetadataModel } from "#metadata/model.ts";
4
+ import { attentionEntries } from "./attentionEntries.ts";
5
+ import type { Entry } from "./entries.ts";
6
+
7
+ function itemUrl(document: MetadataDocument, model: MetadataModel): string {
8
+ const id = document.parsed.fields.id;
9
+ return model.unavailable.length === 0 && id && model.ids.get(id)?.length === 1 ? identityUrl(id) : fileUrl(document.file);
10
+ }
11
+ export function metadataEntries(entries: readonly Entry[], documents: readonly MetadataDocument[], model: MetadataModel): readonly Entry[] {
12
+ const sources = new Map(documents.map((document) => [document.file, document]));
13
+ const enriched = entries.map((entry) => {
14
+ const document = sources.get(entry.file);
15
+ if (entry.kind !== "document" || !document) {
16
+ return entry;
17
+ }
18
+ const fields = document.parsed.fields;
19
+ return {
20
+ ...entry,
21
+ href: itemUrl(document, model),
22
+ text: [entry.text, fields.id, fields.kind, fields.status, fields.owner, fields.nextAction].filter(Boolean).join(" "),
23
+ };
24
+ });
25
+ for (const document of documents) {
26
+ enriched.push(...attentionEntries(document, itemUrl(document, model)));
27
+ const criteria = document.parsed.fields.criteria ?? [];
28
+ for (const [index, criterion] of criteria.entries()) {
29
+ if (criteria.filter((item) => item.id === criterion.id).length !== 1) {
30
+ continue;
31
+ }
32
+ const line = document.parsed.lines[`criteria.${index}`] ?? document.parsed.lines.criteria;
33
+ enriched.push({
34
+ file: document.file,
35
+ href: `${itemUrl(document, model)}#criterion-${encodeURIComponent(criterion.id)}`,
36
+ kind: "passage",
37
+ ...(line === undefined ? {} : { line }),
38
+ text: criterion.text,
39
+ title: criterion.text,
40
+ });
41
+ }
42
+ }
43
+ return enriched;
44
+ }
@@ -0,0 +1,59 @@
1
+ import { Effect, FileSystem, Option, Ref, Semaphore } from "effect";
2
+ import type { Changes } from "#files/changes.ts";
3
+ import { markdownPath } from "#files/markdownPath.ts";
4
+ import { type MetadataDocument, metadataModel } from "#metadata/model.ts";
5
+ import { metadataParse } from "#metadata/parse.ts";
6
+ import { type Entry, entriesOf } from "./entries.ts";
7
+ import { metadataEntries } from "./metadataEntries.ts";
8
+
9
+ export interface Snapshot {
10
+ readonly documents: readonly MetadataDocument[];
11
+ readonly entries: readonly Entry[];
12
+ readonly model: ReturnType<typeof metadataModel>;
13
+ readonly revision: number;
14
+ readonly unavailable: readonly string[];
15
+ }
16
+
17
+ export const searchSnapshot = Effect.fn("WorkBoard.searchSnapshot")(function* (root: string, home: string | undefined, changes: Changes) {
18
+ const cached = yield* Ref.make<Snapshot | undefined>(undefined);
19
+ const semaphore = yield* Semaphore.make(1);
20
+ const read = Effect.gen(function* () {
21
+ const revision = yield* changes.revision;
22
+ const hit = yield* Ref.get(cached);
23
+ if (hit?.revision === revision && (yield* Ref.get(changes.watching))) {
24
+ return hit;
25
+ }
26
+ const fs = yield* FileSystem.FileSystem;
27
+ const files = yield* changes.files;
28
+ const entries: Entry[] = [];
29
+ const documents: MetadataDocument[] = [];
30
+ const unavailable: string[] = [];
31
+ for (const file of files) {
32
+ const found = yield* Effect.option(
33
+ Effect.gen(function* () {
34
+ const real = yield* markdownPath(root, changes.realRoot, file.path);
35
+ if (real === undefined) {
36
+ return undefined;
37
+ }
38
+ const source = yield* fs.readFileString(real);
39
+ const parsed = metadataParse(source);
40
+ const links = new Set<string>();
41
+ const rendered = yield* Effect.tryPromise(() => entriesOf(parsed.body, file.path, file.path === home, parsed.bodyLine, links));
42
+ return { links: [...links], parsed, rendered };
43
+ }),
44
+ );
45
+ if (Option.isSome(found) && found.value) {
46
+ documents.push({ file: file.path, links: found.value.links, parsed: found.value.parsed });
47
+ entries.push(...found.value.rendered);
48
+ } else {
49
+ unavailable.push(file.path);
50
+ }
51
+ }
52
+ const model = metadataModel(documents, unavailable, home ?? files[0]?.path);
53
+ const enriched = metadataEntries(entries, documents, model);
54
+ const snapshot = { documents, entries: enriched, model, revision, unavailable };
55
+ yield* Ref.set(cached, unavailable.length > 0 ? undefined : snapshot);
56
+ return snapshot;
57
+ });
58
+ return semaphore.withPermit(read);
59
+ });
@@ -0,0 +1,55 @@
1
+ import type { MetadataDocument } from "#metadata/model.ts";
2
+ import type { Snapshot } from "#search/snapshot.ts";
3
+ import { fieldFilter, type State } from "./state.ts";
4
+
5
+ export interface Item {
6
+ readonly document: MetadataDocument;
7
+ readonly id: string;
8
+ readonly title: string;
9
+ }
10
+ export function itemsOf(snapshot: Snapshot): readonly Item[] {
11
+ const titles = new Map(snapshot.entries.filter((entry) => entry.kind === "document").map((entry) => [entry.file, entry.title]));
12
+ return [...snapshot.model.ids].flatMap(([id, documents]) => {
13
+ const document = documents.length === 1 ? documents[0] : undefined;
14
+ return document ? [{ document, id, title: titles.get(document.file) ?? document.file }] : [];
15
+ });
16
+ }
17
+ function matches(item: Item, state: State): boolean {
18
+ const fields = item.document.parsed.fields;
19
+ if (state.owner && fieldFilter(fields.owner) !== state.owner) {
20
+ return false;
21
+ }
22
+ if (state.status && fieldFilter(fields.status) !== state.status) {
23
+ return false;
24
+ }
25
+ const text = [item.id, item.title, fields.kind, fields.status, fields.owner, fields.nextAction]
26
+ .filter(Boolean)
27
+ .join(" ")
28
+ .normalize("NFKC")
29
+ .toLowerCase();
30
+ return state.query
31
+ .normalize("NFKC")
32
+ .toLowerCase()
33
+ .split(/\s+/u)
34
+ .filter(Boolean)
35
+ .every((term) => text.includes(term));
36
+ }
37
+ function order(item: Item, sort: State["sort"]): string | undefined {
38
+ return sort === "title" ? item.title : item.document.parsed.fields[sort];
39
+ }
40
+ const collator = new Intl.Collator("en", { numeric: true, sensitivity: "base" });
41
+ export function filterItems(items: readonly Item[], state: State): readonly Item[] {
42
+ return items
43
+ .filter((item) => matches(item, state))
44
+ .sort((a, b) => {
45
+ const left = order(a, state.sort);
46
+ const right = order(b, state.sort);
47
+ if (left === undefined) {
48
+ return right === undefined ? a.id.localeCompare(b.id) : 1;
49
+ }
50
+ if (right === undefined) {
51
+ return -1;
52
+ }
53
+ return collator.compare(left, right) || a.id.localeCompare(b.id);
54
+ });
55
+ }