@heycys/gallery 0.1.0 → 0.1.2

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 (465) hide show
  1. package/THIRD-PARTY-NOTICES.md +51 -1
  2. package/browser/editor/components/callout/index.mjs +40 -15
  3. package/browser/editor/components/columns/page.mjs +45 -32
  4. package/browser/editor/components/details/index.mjs +2 -1
  5. package/browser/editor/components/dialog/index.mjs +2 -1
  6. package/browser/editor/components/dialog/page.mjs +0 -18
  7. package/browser/editor/components/divider/index.mjs +1 -1
  8. package/browser/editor/components/embed/index.mjs +2 -2
  9. package/browser/editor/components/figure/page.mjs +10 -1
  10. package/browser/editor/components/file/page.mjs +2 -2
  11. package/browser/editor/components/flowchart/add.mjs +7 -6
  12. package/browser/editor/components/flowchart/page.mjs +1 -1
  13. package/browser/editor/components/heading/index.mjs +2 -0
  14. package/browser/editor/components/heading/page.mjs +6 -0
  15. package/browser/editor/components/highlight/index.mjs +4 -20
  16. package/browser/editor/components/icons.mjs +13 -2
  17. package/browser/editor/components/image/crop.mjs +6 -9
  18. package/browser/editor/components/image/page.mjs +2 -2
  19. package/browser/editor/components/installed/index.mjs +82 -29
  20. package/browser/editor/components/installed/page.mjs +146 -34
  21. package/browser/editor/components/installed/served.mjs +6 -5
  22. package/browser/editor/components/instances.mjs +18 -0
  23. package/browser/editor/components/kit.mjs +3 -0
  24. package/browser/editor/components/list/page.mjs +3 -6
  25. package/browser/editor/components/media/page.mjs +44 -14
  26. package/browser/editor/components/pages.mjs +2 -2
  27. package/browser/editor/components/registry.mjs +68 -33
  28. package/browser/editor/components/section/index.mjs +2 -1
  29. package/browser/editor/components/set-apart.mjs +24 -0
  30. package/browser/editor/components/table/index.mjs +64 -5
  31. package/browser/editor/components/table/page.mjs +30 -19
  32. package/browser/editor/page/annotate/anchors.mjs +4 -3
  33. package/browser/editor/page/annotate/card.mjs +3 -6
  34. package/browser/editor/page/annotate/index.mjs +61 -34
  35. package/browser/editor/page/autosave.mjs +357 -38
  36. package/browser/editor/page/beside.mjs +5 -5
  37. package/browser/editor/page/block-menu/colors.mjs +3 -1
  38. package/browser/editor/page/block-menu/index.mjs +8 -6
  39. package/browser/editor/page/blocks.mjs +16 -7
  40. package/browser/editor/page/board/client.mjs +57 -0
  41. package/browser/editor/page/board/hint.mjs +145 -0
  42. package/browser/editor/page/board/history.mjs +119 -0
  43. package/browser/editor/page/board/index.mjs +970 -0
  44. package/browser/editor/page/board/settings.mjs +209 -0
  45. package/browser/editor/page/caret.mjs +5 -2
  46. package/browser/editor/page/changes/bar.mjs +94 -0
  47. package/browser/editor/page/changes/ghost.mjs +206 -0
  48. package/browser/editor/page/changes/gone-words.mjs +94 -0
  49. package/browser/editor/page/changes/index.mjs +447 -0
  50. package/browser/editor/page/changes/words.mjs +27 -0
  51. package/browser/editor/page/clipboard/import/colors.mjs +3 -3
  52. package/browser/editor/page/clipboard/import/html.mjs +29 -6
  53. package/browser/editor/page/clipboard/import/inline.mjs +32 -0
  54. package/browser/editor/page/clipboard/import/markdown.mjs +58 -13
  55. package/browser/editor/page/clipboard/import/read.mjs +6 -1
  56. package/browser/editor/page/clipboard/import/to-blocks.mjs +44 -12
  57. package/browser/editor/page/clipboard/import/yuque.mjs +622 -0
  58. package/browser/editor/page/clipboard/index.mjs +156 -26
  59. package/browser/editor/page/clipboard/own/blocks.mjs +25 -16
  60. package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
  61. package/browser/editor/page/clipboard/own/describe.mjs +16 -7
  62. package/browser/editor/page/clipboard/own/export.mjs +6 -6
  63. package/browser/editor/page/clipboard/own/selection.mjs +3 -3
  64. package/browser/editor/page/clipboard/own/writers.mjs +0 -11
  65. package/browser/editor/page/columns/index.mjs +48 -46
  66. package/browser/editor/page/commit.mjs +98 -25
  67. package/browser/editor/page/conflicts.mjs +13 -33
  68. package/browser/editor/page/convert.mjs +8 -7
  69. package/browser/editor/page/core.mjs +81 -27
  70. package/browser/editor/page/custom-page.mjs +106 -0
  71. package/browser/editor/page/drag/index.mjs +40 -24
  72. package/browser/editor/page/drag/preview.mjs +9 -4
  73. package/browser/editor/page/editor.mjs +120 -28
  74. package/browser/editor/page/emoji-picker/emoji-tab.mjs +22 -13
  75. package/browser/editor/page/emoji-picker/grid.mjs +7 -5
  76. package/browser/editor/page/emoji-picker/icon-tab.mjs +4 -4
  77. package/browser/editor/page/emoji-picker/icons.mjs +0 -1
  78. package/browser/editor/page/emoji-picker/index.mjs +11 -9
  79. package/browser/editor/page/emoji-picker/styles.mjs +156 -2
  80. package/browser/editor/page/emoji-picker/support.mjs +6 -4
  81. package/browser/editor/page/emoji-picker/upload.mjs +14 -13
  82. package/browser/editor/page/fills.mjs +5 -3
  83. package/browser/editor/page/fold/index.mjs +348 -0
  84. package/browser/editor/page/fold/rule.mjs +125 -0
  85. package/browser/editor/page/folded.mjs +23 -0
  86. package/browser/editor/page/format-bar/bar.mjs +2 -1
  87. package/browser/editor/page/format-bar/index.mjs +1 -1
  88. package/browser/editor/page/geometry.mjs +8 -6
  89. package/browser/editor/page/handle/index.mjs +22 -14
  90. package/browser/editor/page/hints/index.mjs +1 -1
  91. package/browser/editor/page/history.mjs +24 -4
  92. package/browser/editor/page/insert/index.mjs +30 -17
  93. package/browser/editor/page/links/index.mjs +5 -3
  94. package/browser/editor/page/links/pages.mjs +27 -9
  95. package/browser/editor/page/long-runs.mjs +75 -0
  96. package/browser/editor/page/look.mjs +69 -6
  97. package/browser/editor/page/margin.mjs +63 -27
  98. package/browser/editor/page/media-menu/index.mjs +6 -7
  99. package/browser/editor/page/menu.mjs +86 -31
  100. package/browser/editor/page/merge.mjs +24 -0
  101. package/browser/editor/page/notices.mjs +3 -3
  102. package/browser/editor/page/offered.mjs +1 -1
  103. package/browser/editor/page/outline/folds.mjs +11 -10
  104. package/browser/editor/page/outline/index.mjs +131 -45
  105. package/browser/editor/page/outline/list.mjs +23 -11
  106. package/browser/editor/page/outline/read.mjs +1 -1
  107. package/browser/editor/page/outline/strip.mjs +7 -1
  108. package/browser/editor/page/page-objects.mjs +13 -2
  109. package/browser/editor/page/panel.mjs +9 -13
  110. package/browser/editor/page/present-links.mjs +11 -2
  111. package/browser/editor/page/resize/index.mjs +42 -29
  112. package/browser/editor/page/selection/delete.mjs +8 -6
  113. package/browser/editor/page/selection/index.mjs +10 -3
  114. package/browser/editor/page/served.mjs +14 -0
  115. package/browser/editor/page/session.mjs +101 -6
  116. package/browser/editor/page/slash-menu/index.mjs +3 -3
  117. package/browser/editor/page/table/cell-bar.mjs +4 -1
  118. package/browser/editor/page/table/cells.mjs +103 -47
  119. package/browser/editor/page/table/icons.mjs +3 -1
  120. package/browser/editor/page/table/index.mjs +40 -16
  121. package/browser/editor/page/table/pictures.mjs +299 -0
  122. package/browser/editor/page/table/views.mjs +150 -0
  123. package/browser/editor/page/table/widths.mjs +9 -4
  124. package/browser/editor/page/text-select/index.mjs +43 -14
  125. package/browser/editor/page/todo-writes.mjs +75 -0
  126. package/browser/editor/page/tooltip.mjs +1 -1
  127. package/browser/editor/page/type-grid.mjs +4 -3
  128. package/browser/editor/page/typing/code-edges.mjs +63 -17
  129. package/browser/editor/page/typing/index.mjs +65 -9
  130. package/browser/editor/page/typing/leave.mjs +1 -1
  131. package/browser/editor/page/ui.mjs +13 -0
  132. package/browser/shared/annotations.mjs +8 -10
  133. package/browser/shared/block-packs.mjs +404 -0
  134. package/browser/shared/board-places.mjs +224 -0
  135. package/browser/shared/card-size.mjs +59 -0
  136. package/browser/shared/code-folds.mjs +5 -1
  137. package/browser/shared/colors.mjs +17 -14
  138. package/browser/shared/component-catalog.mjs +345 -54
  139. package/browser/shared/component-source.mjs +37 -0
  140. package/browser/shared/components/callout.mjs +4 -2
  141. package/browser/shared/components/index.mjs +72 -9
  142. package/browser/shared/components/installed.mjs +110 -8
  143. package/browser/shared/components/page.mjs +22 -3
  144. package/browser/shared/components/state.mjs +5 -1
  145. package/browser/shared/components/table.mjs +1 -1
  146. package/browser/shared/components/text.mjs +2 -2
  147. package/browser/shared/document-look.mjs +183 -0
  148. package/browser/shared/drafts.mjs +432 -0
  149. package/browser/shared/emoji/data/LICENSE-lucide.txt +43 -0
  150. package/browser/shared/emoji/data/README.md +4 -2
  151. package/browser/shared/emoji/data/categories.json +1 -1
  152. package/browser/shared/emoji/data/keywords-en.json +1 -1
  153. package/browser/shared/emoji/data/keywords-zh.json +1 -1
  154. package/browser/shared/emoji/data/names.json +1 -1
  155. package/browser/shared/emoji/data/positions.json +1 -1
  156. package/browser/shared/emoji/data/twemoji-index.json +1 -1
  157. package/browser/shared/emoji/data/twemoji-svg.bin +0 -0
  158. package/browser/shared/emoji/data.mjs +10 -12
  159. package/browser/shared/emoji/emoji.mjs +8 -7
  160. package/browser/shared/emoji/icon-value.mjs +4 -3
  161. package/browser/shared/extension-sidebar.mjs +126 -0
  162. package/browser/shared/extensions.mjs +79 -0
  163. package/browser/shared/file-table.mjs +101 -0
  164. package/browser/shared/html-tree.mjs +11 -5
  165. package/browser/shared/i18n/en.mjs +374 -35
  166. package/browser/shared/json-layout.mjs +47 -0
  167. package/browser/shared/long-runs.mjs +39 -0
  168. package/browser/shared/net-cache.mjs +133 -0
  169. package/browser/shared/net-keys.mjs +32 -0
  170. package/browser/shared/net-policy.mjs +177 -0
  171. package/browser/shared/new-names.mjs +5 -2
  172. package/browser/shared/outline-shape.mjs +128 -0
  173. package/browser/shared/outline.mjs +458 -0
  174. package/browser/shared/pack-manifest.mjs +77 -0
  175. package/browser/shared/page-address.mjs +6 -3
  176. package/browser/shared/page-cards.mjs +308 -0
  177. package/browser/shared/page-links.mjs +69 -6
  178. package/browser/shared/pages.mjs +388 -0
  179. package/browser/shared/paths.mjs +6 -0
  180. package/browser/shared/preferences.mjs +10 -4
  181. package/browser/shared/preview-server.mjs +3 -7
  182. package/browser/shared/session.mjs +13 -5
  183. package/browser/shared/shipped-blocks.mjs +299 -0
  184. package/browser/shared/table-chart.mjs +33 -1
  185. package/browser/shared/todos.mjs +83 -0
  186. package/browser/shared/user-directory.mjs +24 -0
  187. package/browser/shared/versions.mjs +14 -0
  188. package/browser/shared/web-links.mjs +134 -0
  189. package/browser/shared/workspace-columns.mjs +120 -0
  190. package/browser/shared/workspace-look.mjs +91 -0
  191. package/browser/shared/workspace-name.mjs +154 -0
  192. package/browser/shared/workspace-query.mjs +125 -0
  193. package/browser/shared/workspace-registry.mjs +272 -0
  194. package/browser/shared/workspace.mjs +171 -20
  195. package/browser/shared/zoom.mjs +5 -5
  196. package/dist/chunk-2NRBY6AJ.mjs +2 -0
  197. package/dist/chunk-32ZUEFZ7.mjs +2 -0
  198. package/dist/chunk-35NQ4PLQ.mjs +2 -0
  199. package/dist/chunk-3KJHLHUO.mjs +2 -0
  200. package/dist/chunk-3NJACR4W.mjs +2 -0
  201. package/dist/chunk-4AV456RQ.mjs +2 -0
  202. package/dist/chunk-4OZWXZE5.mjs +5 -0
  203. package/dist/chunk-5XYHDBJ5.mjs +2 -0
  204. package/dist/chunk-5ZJA7CXT.mjs +2 -0
  205. package/dist/chunk-6A53MZYZ.mjs +2 -0
  206. package/dist/chunk-6EXH3ORZ.mjs +166 -0
  207. package/dist/chunk-6EZ7FNIK.mjs +3 -0
  208. package/dist/{chunk-UXUK4PMC.mjs → chunk-6QBHU4DF.mjs} +1 -1
  209. package/dist/{chunk-6U2SLSDN.mjs → chunk-6VTU6KEO.mjs} +1 -1
  210. package/dist/chunk-B4P2CM2J.mjs +3 -0
  211. package/dist/chunk-BPL64HGA.mjs +4 -0
  212. package/dist/chunk-BVEFGE4B.mjs +2 -0
  213. package/dist/chunk-BZ5RAF7L.mjs +2 -0
  214. package/dist/chunk-CRJEG7MT.mjs +2 -0
  215. package/dist/{chunk-B3VTYBYR.mjs → chunk-D4CKRD3V.mjs} +91 -91
  216. package/dist/chunk-D4EURAX4.mjs +4 -0
  217. package/dist/chunk-DQCE7TJY.mjs +5 -0
  218. package/dist/chunk-DR73Y2UJ.mjs +3 -0
  219. package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
  220. package/dist/{chunk-DB4WKGYF.mjs → chunk-ERLAIBOA.mjs} +2 -2
  221. package/dist/chunk-EURLTOTZ.mjs +4 -0
  222. package/dist/chunk-FJYN7RTH.mjs +4 -0
  223. package/dist/chunk-FWNRPMCJ.mjs +12 -0
  224. package/dist/chunk-FWW4CSAZ.mjs +2 -0
  225. package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
  226. package/dist/chunk-GY3FAUVM.mjs +2 -0
  227. package/dist/chunk-HLYV7RIH.mjs +2 -0
  228. package/dist/chunk-HMYTM3GT.mjs +15 -0
  229. package/dist/chunk-IA4PSIMD.mjs +2 -0
  230. package/dist/chunk-JEUK3ZO7.mjs +2 -0
  231. package/dist/chunk-JVHHHGEA.mjs +3 -0
  232. package/dist/chunk-KTKHRC6H.mjs +2 -0
  233. package/dist/chunk-L7UP52JO.mjs +2 -0
  234. package/dist/chunk-MHW7ZKOU.mjs +2 -0
  235. package/dist/chunk-N76HWBA3.mjs +10 -0
  236. package/dist/chunk-N7AZZLGT.mjs +548 -0
  237. package/dist/chunk-NAMN3RAF.mjs +2 -0
  238. package/dist/{chunk-YXAUQPVK.mjs → chunk-NFMCP2HI.mjs} +3 -3
  239. package/dist/chunk-NG375ILQ.mjs +2 -0
  240. package/dist/chunk-NVRNLK25.mjs +6 -0
  241. package/dist/chunk-NWFBE2YA.mjs +2 -0
  242. package/dist/chunk-NWR2LT5B.mjs +2 -0
  243. package/dist/chunk-OJKMINIU.mjs +20 -0
  244. package/dist/chunk-OUUP3WKT.mjs +2 -0
  245. package/dist/chunk-OW5NWPOJ.mjs +10 -0
  246. package/dist/chunk-PAREWQGB.mjs +4 -0
  247. package/dist/chunk-POQSE4C2.mjs +2 -0
  248. package/dist/chunk-PUOQ65NC.mjs +2 -0
  249. package/dist/{chunk-Z52HTUW7.mjs → chunk-PVER7LSC.mjs} +2 -2
  250. package/dist/chunk-PZDLJJTJ.mjs +3 -0
  251. package/dist/chunk-Q47PLKIJ.mjs +15 -0
  252. package/dist/chunk-Q4UEPUWF.mjs +2 -0
  253. package/dist/chunk-QKXMPUXC.mjs +2 -0
  254. package/dist/chunk-QOUEFUCH.mjs +16 -0
  255. package/dist/chunk-RFDZXFJF.mjs +13 -0
  256. package/dist/chunk-RKPWLGZ3.mjs +4 -0
  257. package/dist/chunk-RMECZA2K.mjs +2 -0
  258. package/dist/{chunk-EUX7IC5J.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  259. package/dist/chunk-SX4LJYT6.mjs +8 -0
  260. package/dist/chunk-SXHBYZST.mjs +16 -0
  261. package/dist/chunk-TANZRINB.mjs +2 -0
  262. package/dist/chunk-TEZAWDSQ.mjs +2 -0
  263. package/dist/chunk-UBBRTJ2R.mjs +24 -0
  264. package/dist/chunk-UFNYFFKO.mjs +20 -0
  265. package/dist/chunk-UGWYKHBL.mjs +170 -0
  266. package/dist/chunk-UKSHDZZ6.mjs +2 -0
  267. package/dist/chunk-UMHUSOPJ.mjs +2 -0
  268. package/dist/chunk-UNOYVIYR.mjs +2 -0
  269. package/dist/chunk-V6RIYQZZ.mjs +4 -0
  270. package/dist/chunk-VJPFVNNW.mjs +15 -0
  271. package/dist/chunk-VS3ZMVGX.mjs +5 -0
  272. package/dist/chunk-VTKNEYT3.mjs +6 -0
  273. package/dist/chunk-VXACTLO3.mjs +3 -0
  274. package/dist/chunk-W3BGBJQW.mjs +2 -0
  275. package/dist/chunk-YI43RG4P.mjs +2 -0
  276. package/dist/chunk-YQGT4AB2.mjs +6 -0
  277. package/dist/chunk-ZB4H7ZN4.mjs +2 -0
  278. package/dist/{chunk-ACOPDCNB.mjs → chunk-ZHEHPMBK.mjs} +1 -1
  279. package/dist/chunk-ZTHICSSF.mjs +2 -0
  280. package/dist/chunk-ZUNVAXLH.mjs +2 -0
  281. package/dist/chunk-ZWPMCK7P.mjs +2 -0
  282. package/dist/cli.mjs +1 -1
  283. package/dist/server.mjs +1 -1
  284. package/dist/{chunk-EVJ3BX3M.mjs → update-fetch.mjs} +1 -1
  285. package/dist/worker.mjs +1 -1
  286. package/kit/board.css +95 -0
  287. package/kit/board.js +250 -0
  288. package/kit/charts.js +5 -71
  289. package/kit/code.js +14 -14
  290. package/kit/math.js +18 -2
  291. package/kit/report.css +500 -151
  292. package/kit/runtime.js +1720 -170
  293. package/kit/state.js +10 -1
  294. package/kit/tables.js +172 -37
  295. package/kit/ui.js +166 -27
  296. package/package.json +2 -1
  297. package/packs/gallery/card/component.json +14 -0
  298. package/packs/gallery/card/example.html +10 -0
  299. package/packs/gallery/card/preview.svg +1 -0
  300. package/packs/gallery/card/style.css +6 -0
  301. package/packs/gallery/card/template.html +6 -0
  302. package/packs/gallery/card/writing.md +14 -0
  303. package/packs/gallery/chart-card/component.json +15 -0
  304. package/packs/gallery/chart-card/example.html +14 -0
  305. package/packs/gallery/chart-card/kit.js +130 -0
  306. package/packs/gallery/chart-card/preview.svg +1 -0
  307. package/packs/gallery/chart-card/style.css +42 -0
  308. package/packs/gallery/chart-card/template.html +13 -0
  309. package/packs/gallery/chart-card/writing.md +20 -0
  310. package/packs/gallery/chart-view/component.json +20 -0
  311. package/packs/gallery/chart-view/example.html +13 -0
  312. package/packs/gallery/chart-view/kit.js +355 -0
  313. package/packs/gallery/chart-view/preview.svg +1 -0
  314. package/packs/gallery/chart-view/style.css +94 -0
  315. package/packs/gallery/chart-view/template.html +3 -0
  316. package/packs/gallery/chart-view/writing.md +22 -0
  317. package/packs/gallery/countdown/component.json +18 -0
  318. package/packs/gallery/countdown/example.html +3 -0
  319. package/packs/gallery/countdown/kit.js +156 -0
  320. package/packs/gallery/countdown/preview.svg +1 -0
  321. package/packs/gallery/countdown/style.css +130 -0
  322. package/packs/gallery/countdown/template.html +3 -0
  323. package/packs/gallery/countdown/writing.md +22 -0
  324. package/packs/gallery/habit/component.json +14 -0
  325. package/packs/gallery/habit/example.html +3 -0
  326. package/packs/gallery/habit/kit.js +295 -0
  327. package/packs/gallery/habit/preview.svg +1 -0
  328. package/packs/gallery/habit/style.css +246 -0
  329. package/packs/gallery/habit/template.html +3 -0
  330. package/packs/gallery/habit/writing.md +21 -0
  331. package/packs/gallery/heatmap/component.json +18 -0
  332. package/packs/gallery/heatmap/example.html +3 -0
  333. package/packs/gallery/heatmap/kit.js +351 -0
  334. package/packs/gallery/heatmap/preview.svg +1 -0
  335. package/packs/gallery/heatmap/style.css +201 -0
  336. package/packs/gallery/heatmap/template.html +3 -0
  337. package/packs/gallery/heatmap/writing.md +21 -0
  338. package/packs/gallery/kanban/component.json +18 -0
  339. package/packs/gallery/kanban/example.html +12 -0
  340. package/packs/gallery/kanban/kit.js +540 -0
  341. package/packs/gallery/kanban/preview.svg +1 -0
  342. package/packs/gallery/kanban/style.css +212 -0
  343. package/packs/gallery/kanban/template.html +3 -0
  344. package/packs/gallery/kanban/writing.md +20 -0
  345. package/packs/gallery/metric/component.json +22 -0
  346. package/packs/gallery/metric/example.html +15 -0
  347. package/packs/gallery/metric/kit.js +248 -0
  348. package/packs/gallery/metric/preview.svg +1 -0
  349. package/packs/gallery/metric/style.css +92 -0
  350. package/packs/gallery/metric/template.html +3 -0
  351. package/packs/gallery/metric/writing.md +23 -0
  352. package/packs/gallery/note/component.json +14 -0
  353. package/packs/gallery/note/example.html +3 -0
  354. package/packs/gallery/note/kit.js +102 -0
  355. package/packs/gallery/note/preview.svg +1 -0
  356. package/packs/gallery/note/style.css +76 -0
  357. package/packs/gallery/note/template.html +3 -0
  358. package/packs/gallery/note/writing.md +18 -0
  359. package/packs/gallery/pack.json +8 -0
  360. package/packs/gallery/recent/component.json +13 -0
  361. package/packs/gallery/recent/example.html +1 -0
  362. package/packs/gallery/recent/kit.js +238 -0
  363. package/packs/gallery/recent/preview.svg +1 -0
  364. package/packs/gallery/recent/style.css +158 -0
  365. package/packs/gallery/recent/template.html +1 -0
  366. package/packs/gallery/recent/writing.md +15 -0
  367. package/packs/gallery/static/component.json +13 -0
  368. package/packs/gallery/static/example.html +11 -0
  369. package/packs/gallery/static/preview.svg +1 -0
  370. package/packs/gallery/static/style.css +138 -0
  371. package/packs/gallery/static/template.html +1 -0
  372. package/packs/gallery/static/writing.md +18 -0
  373. package/packs/gallery/stats/component.json +13 -0
  374. package/packs/gallery/stats/example.html +1 -0
  375. package/packs/gallery/stats/kit.js +166 -0
  376. package/packs/gallery/stats/preview.svg +1 -0
  377. package/packs/gallery/stats/style.css +151 -0
  378. package/packs/gallery/stats/template.html +1 -0
  379. package/packs/gallery/stats/writing.md +11 -0
  380. package/packs/gallery/today/component.json +12 -0
  381. package/packs/gallery/today/example.html +1 -0
  382. package/packs/gallery/today/kit.js +185 -0
  383. package/packs/gallery/today/preview.svg +1 -0
  384. package/packs/gallery/today/style.css +120 -0
  385. package/packs/gallery/today/template.html +1 -0
  386. package/packs/gallery/today/writing.md +14 -0
  387. package/packs/gallery/todos/component.json +19 -0
  388. package/packs/gallery/todos/example.html +3 -0
  389. package/packs/gallery/todos/kit.js +342 -0
  390. package/packs/gallery/todos/preview.svg +1 -0
  391. package/packs/gallery/todos/style.css +267 -0
  392. package/packs/gallery/todos/template.html +3 -0
  393. package/packs/gallery/todos/writing.md +30 -0
  394. package/packs/gallery/weather/component.json +19 -0
  395. package/packs/gallery/weather/example.html +3 -0
  396. package/packs/gallery/weather/kit.js +312 -0
  397. package/packs/gallery/weather/preview.svg +1 -0
  398. package/packs/gallery/weather/style.css +258 -0
  399. package/packs/gallery/weather/template.html +3 -0
  400. package/packs/gallery/weather/writing.md +26 -0
  401. package/packs/gallery-soft/pack.json +8 -0
  402. package/release.json +13 -11
  403. package/sdk/doc-kit.d.ts +404 -7
  404. package/sdk/doc-state.d.ts +2 -0
  405. package/skill/SKILL.md +71 -26
  406. package/skill/references/block-script.md +140 -0
  407. package/skill/references/building-blocks.md +257 -0
  408. package/skill/references/example-report.html +1 -1
  409. package/skill/references/extensions.md +59 -0
  410. package/skill/references/pages-and-data.md +221 -0
  411. package/skill/references/writing-html.md +9 -7
  412. package/skill/sdk/doc-kit.d.ts +404 -7
  413. package/skill/sdk/doc-state.d.ts +2 -0
  414. package/web/assets/index-BK2e_07w.js +13 -0
  415. package/web/assets/index-CWFI83mF.css +1 -0
  416. package/web/index.html +2 -2
  417. package/browser/editor/components/callout/page.mjs +0 -13
  418. package/dist/chunk-2PBALTR3.mjs +0 -57
  419. package/dist/chunk-3LA3EMDE.mjs +0 -15
  420. package/dist/chunk-5FRMCDPY.mjs +0 -16
  421. package/dist/chunk-5LEK2CBS.mjs +0 -2
  422. package/dist/chunk-5OFN5AHC.mjs +0 -2
  423. package/dist/chunk-5SIYS5HN.mjs +0 -2
  424. package/dist/chunk-5TEK3RAD.mjs +0 -2
  425. package/dist/chunk-6CYG3Z4V.mjs +0 -2
  426. package/dist/chunk-7GHT2UCA.mjs +0 -15
  427. package/dist/chunk-7QQBR7PB.mjs +0 -2
  428. package/dist/chunk-ATCJYAR4.mjs +0 -2
  429. package/dist/chunk-C7HWOBIF.mjs +0 -2
  430. package/dist/chunk-E7VYDG2X.mjs +0 -2
  431. package/dist/chunk-EZY3WC6Z.mjs +0 -15
  432. package/dist/chunk-FQGQH4KM.mjs +0 -2
  433. package/dist/chunk-G7TOXONE.mjs +0 -6
  434. package/dist/chunk-GPF4YWWB.mjs +0 -9
  435. package/dist/chunk-GYQV7Y4J.mjs +0 -120
  436. package/dist/chunk-HMHK3EQ6.mjs +0 -2
  437. package/dist/chunk-HQQMJCQJ.mjs +0 -10
  438. package/dist/chunk-IERUOGC3.mjs +0 -6
  439. package/dist/chunk-ITNLYXXV.mjs +0 -3
  440. package/dist/chunk-L4DVONOG.mjs +0 -2
  441. package/dist/chunk-LAE5NQ4B.mjs +0 -2
  442. package/dist/chunk-LC7YNQFG.mjs +0 -2
  443. package/dist/chunk-LHTFLRB6.mjs +0 -4
  444. package/dist/chunk-NFIBI4IP.mjs +0 -26
  445. package/dist/chunk-NSKUTQ5J.mjs +0 -5
  446. package/dist/chunk-O52JMOCZ.mjs +0 -2
  447. package/dist/chunk-P2CAZPDP.mjs +0 -3
  448. package/dist/chunk-QMQUXTU4.mjs +0 -12
  449. package/dist/chunk-QVWVFC5K.mjs +0 -6
  450. package/dist/chunk-QYKCJ7FG.mjs +0 -8
  451. package/dist/chunk-QZY6Q64C.mjs +0 -2
  452. package/dist/chunk-TDQP3DKQ.mjs +0 -10
  453. package/dist/chunk-TX6JH7TR.mjs +0 -2
  454. package/dist/chunk-UNUEWH4S.mjs +0 -2
  455. package/dist/chunk-V4CPWKMZ.mjs +0 -2
  456. package/dist/chunk-VACRB2NE.mjs +0 -3
  457. package/dist/chunk-W63L7367.mjs +0 -7
  458. package/dist/chunk-W7CXPCRV.mjs +0 -6
  459. package/dist/chunk-XINNG4F2.mjs +0 -4
  460. package/dist/chunk-YL2DPWVS.mjs +0 -4
  461. package/dist/chunk-YZ5Z6H4W.mjs +0 -4
  462. package/dist/chunk-ZBIM6ARY.mjs +0 -216
  463. package/skill/references/building-components.md +0 -327
  464. package/web/assets/index-B6Ai3wsa.js +0 -13
  465. package/web/assets/index-SYPC3EZy.css +0 -1
package/kit/state.js CHANGED
@@ -117,7 +117,15 @@
117
117
  const storageKey = options.storageKey || `gallery:${key}${scopeSuffix}`;
118
118
  const storage = storageFor(storageKey);
119
119
  if (!options.storageKey) carryOldState(storage, storageFor(`html-report-studio:${key}${scopeSuffix}`), matches, version);
120
- const restored = parseStored(storage.read(), matches, version) || embeddedState(matches, version) || {};
120
+ // What it was kept under before (`formerId`: a component's instance, by its markup until it had a
121
+ // block id), read when nothing is kept under its own name, and carried to it at once, so that the
122
+ // reader's choice outlives the name, and the carry is done once.
123
+ const former = typeof options.formerId === "string" && options.formerId && !options.storageKey && scoped(options.formerId) !== key ? scoped(options.formerId) : null;
124
+ const formerMatches = (other) => typeof other === "string" && scoped(other) === former;
125
+ const own = parseStored(storage.read(), matches, version);
126
+ const carried = own || !former ? null : parseStored(storageFor(`gallery:${former}${scopeSuffix}`).read(), formerMatches, version);
127
+ const embedded = own || carried ? null : embeddedState(matches, version) || (former ? embeddedState(formerMatches, version) : null);
128
+ const restored = own || carried || embedded || {};
121
129
  const state = Object.assign(Object.create(null), defaults);
122
130
  for (const [key, value] of Object.entries(restored)) {
123
131
  if (!transientKeys.has(key)) state[key] = clone(value);
@@ -140,6 +148,7 @@
140
148
  const snapshot = clone(state);
141
149
  for (const listener of listeners) listener(clone(snapshot), change);
142
150
  }
151
+ if (carried) persist();
143
152
 
144
153
  const api = {
145
154
  id,
package/kit/tables.js CHANGED
@@ -384,6 +384,79 @@
384
384
  for (const [cell, sides] of edges) if (cell.getAttribute(EDGE) !== sides) cell.setAttribute(EDGE, sides);
385
385
  }
386
386
 
387
+ // src/shared/components/page.mjs
388
+ var LOOK_ATTRIBUTES = Object.freeze({ font: "data-doc-font", size: "data-doc-size", spacing: "data-doc-spacing", width: "data-doc-measure", full: "data-doc-width" });
389
+ var page_default = {
390
+ id: "page",
391
+ match: "main.doc-page",
392
+ flow: ".doc-page",
393
+ groups: false,
394
+ header: "header.doc-header",
395
+ // the title and the lines under it
396
+ title: ".doc-title",
397
+ // the document's title, the h1 of the header: its text, mirrored in <title> and report.json
398
+ attrs: {
399
+ "data-doc-id": "the document's slug: its reading state is kept under it",
400
+ "data-doc-kit": "a kit asset's tag (the render puts in those a report needs; an older source writes them)",
401
+ "data-doc-vendor": "a vendor library's tag",
402
+ "data-doc-placeholder": "the starter's content, which the checks want replaced",
403
+ "data-doc-transient-view": "its hidden or open shows transient reading state, reset in an export of the view"
404
+ },
405
+ classes: ["doc-page", "doc-header", "doc-kicker", "doc-title", "doc-button"],
406
+ runtime: {
407
+ generated: [".doc-display", "script[data-doc-state]"],
408
+ // data-doc-effective-theme: the theme the page shows now (ui.js), "light" or "dark", which a custom page's own colors go by.
409
+ // data-doc-platform: "mac" on an Apple platform (runtime/index.js sets it as the page opens), the text's color and smoothing go by it; a copy of the view lets it go, its reader's machine judges anew.
410
+ root: { attrs: ["data-doc-ready", "data-doc-drawn", "data-doc-controls", "data-doc-effective-theme", "data-doc-platform"] },
411
+ // The reader's theme (ui.js) and the document's look (字体与布局 and 全宽: its doc.json's, put on by
412
+ // the render, src/shared/document-look.mjs; the reader's own 全宽显示 is the same data-doc-width), which
413
+ // a copy of the view keeps; never written in doc.html.
414
+ state: { html: ["data-doc-theme", ...Object.values(LOOK_ATTRIBUTES)] },
415
+ internal: [
416
+ "doc-display*",
417
+ "data-doc-export-copy",
418
+ "data-theme",
419
+ "doc-export-id",
420
+ "doc-reveal",
421
+ "doc-kit-error",
422
+ "doc-net-consent*",
423
+ "data-doc-snapshot",
424
+ // The time an export's snapshot was made (its data-doc-snapshot tag's: render/net-snapshot.mjs), which context.workspace.query answers as `at`.
425
+ "data-at",
426
+ // A custom page's (no document's: src/render/page-html.mjs, the kit's board/): its cards' cells, the Agent's
427
+ // (data-x, data-y, data-w, data-h), and its boards' columns now (data-columns, board.js's).
428
+ "data-x",
429
+ "data-y",
430
+ "data-w",
431
+ "data-h",
432
+ "data-columns"
433
+ ]
434
+ }
435
+ };
436
+
437
+ // src/shared/document-look.mjs
438
+ var LOOK = Object.freeze({
439
+ font: Object.freeze(["sans", "serif", "mixed"]),
440
+ // 等线体, 衬线体, 混合体 (the title and headings serif)
441
+ size: Object.freeze(["default", "small", "large"]),
442
+ // 字体大小: 小号, 默认, 大号
443
+ spacing: Object.freeze(["default", "compact", "loose"]),
444
+ // 正文间距: 紧凑, 默认, 宽松
445
+ width: Object.freeze(["default", "narrow", "wide"]),
446
+ // 正文宽度: 偏窄, 默认, 偏宽
447
+ // 全宽 (the 更多 menu's switch under 目录): the page at the full width of its area, whatever its 正文宽度 is; its attribute is
448
+ // the kit's own data-doc-width="full", the reader's display menu's 全宽显示 too (components/page.mjs LOOK_ATTRIBUTES)
449
+ full: Object.freeze(["default", "full"])
450
+ });
451
+ var SIZE_FACTOR = Object.freeze({ default: 1, small: 15 / 16, large: 18 / 16 });
452
+ var SPACING = Object.freeze({
453
+ default: Object.freeze({ leading: 1, gaps: 1 }),
454
+ compact: Object.freeze({ leading: 0.8, gaps: 0.75 }),
455
+ loose: Object.freeze({ leading: 1.2, gaps: 1.25 })
456
+ });
457
+ var WIDTH = Object.freeze({ default: 712, narrow: 648, wide: 776 });
458
+ var ATTRIBUTE_VALUE = String.raw`(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?`;
459
+
387
460
  // src/shared/table-hides.mjs
388
461
  function cellColumns(table) {
389
462
  const taken = [];
@@ -497,6 +570,7 @@
497
570
  frame.className = "doc-scrollbars-frame";
498
571
  node.prepend(frame);
499
572
  }
573
+ frame.style.removeProperty("width");
500
574
  const bars = { node, table, frame, y: node.querySelector(".doc-scrollbar--y"), x: node.querySelector(".doc-scrollbar--x"), timer: 0, axes: {}, noted: "", reach: 0 };
501
575
  scrollbars.set(wrapper, bars);
502
576
  wrapper.addEventListener("scroll", () => {
@@ -514,10 +588,10 @@
514
588
  const bars = scrollbars.get(wrapper);
515
589
  if (!bars) return;
516
590
  const { table } = bars;
517
- const { clientWidth: width, clientHeight: height, offsetWidth, offsetHeight } = wrapper;
591
+ const { clientWidth: width, clientHeight: height } = wrapper;
592
+ const style = getComputedStyle(wrapper);
518
593
  const content = { width: Math.max(width, table.offsetWidth), height: Math.max(height, table.offsetHeight) };
519
- setStyle(bars.frame, "width", `${offsetWidth}px`);
520
- setStyle(bars.frame, "height", `${offsetHeight}px`);
594
+ setStyle(bars.frame, "height", `${outerHeight(wrapper, style)}px`);
521
595
  const x = content.width - width > 1, y = content.height - height > 1;
522
596
  const sizes = `${width}x${height}:${content.width}x${content.height}`;
523
597
  if (width > 0 && (renote || sizes !== bars.noted)) {
@@ -525,7 +599,6 @@
525
599
  bars.reach = noteHidden(wrapper, table);
526
600
  }
527
601
  bars.node.toggleAttribute("data-more", x && wrapper.scrollLeft + width < bars.reach - 1);
528
- const style = getComputedStyle(wrapper);
529
602
  const corner = (radius, border) => Math.max(0, (parseFloat(style[radius]) || 0) - (parseFloat(style[border]) || 0));
530
603
  const header = table.tHead?.getBoundingClientRect().height || 0;
531
604
  const first = fixedFirstCell(table)?.getBoundingClientRect().width || 0;
@@ -555,6 +628,12 @@
555
628
  bars.axes.x = place(bars.x, start, end, first, width, content.width, wrapper.scrollLeft);
556
629
  }
557
630
  }
631
+ function outerHeight(element, style) {
632
+ const height = parseFloat(style.height);
633
+ if (!Number.isFinite(height)) return element.offsetHeight;
634
+ if (style.boxSizing === "border-box") return height;
635
+ return height + ["paddingTop", "paddingBottom", "borderTopWidth", "borderBottomWidth"].reduce((sum, name) => sum + (parseFloat(style[name]) || 0), 0);
636
+ }
558
637
  function noteHidden(wrapper, table) {
559
638
  const notes = [];
560
639
  const hides = tableHides(wrapper, table);
@@ -622,6 +701,7 @@
622
701
  var CODE_RUN_MAX = 320;
623
702
  var WIDE = "\u2014\u3000-\u30FF\u3400-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF00-\uFFEF";
624
703
  var NATIVE_BREAKS = new RegExp(`(?<=-)|(?<=[${WIDE}])|(?=[${WIDE}])`, "u");
704
+ var SUBPIXEL = 0.5;
625
705
  var layouts = /* @__PURE__ */ new WeakMap();
626
706
  var layoutObservers = /* @__PURE__ */ new WeakMap();
627
707
  var pendingLayouts = /* @__PURE__ */ new Set();
@@ -683,7 +763,8 @@
683
763
  function contextOf(table) {
684
764
  const root = document.documentElement;
685
765
  const classes = [...table.classList].filter((name) => name !== "doc-table--auto").join(" ");
686
- return `${classes}${wrapperOf(table)?.className ?? ""}${root.getAttribute("data-doc-theme") ?? ""}|${root.getAttribute("data-doc-width") ?? ""}`;
766
+ const look = Object.values(LOOK_ATTRIBUTES).map((name) => root.getAttribute(name) ?? "").join("|");
767
+ return `${classes}${wrapperOf(table)?.className ?? ""}${root.getAttribute("data-doc-theme") ?? ""}|${root.getAttribute("data-doc-width") ?? ""}|${look}`;
687
768
  }
688
769
  function createCellMeasurer(table) {
689
770
  sameZoom();
@@ -832,13 +913,32 @@
832
913
  const wrapper = wrapperOf(table);
833
914
  const sized = Boolean(wrapper) && getComputedStyle(wrapper).getPropertyValue("--doc-span-width").trim() !== "";
834
915
  const wider = sized ? Math.max(1, parseFloat(getComputedStyle(wrapper).getPropertyValue("--doc-span")) || 1) : 1;
835
- return { wrapper, sized, wider, previousWidth: wrapper?.style.width };
916
+ return { wrapper, sized, wider };
917
+ }
918
+ function innerWidth(element) {
919
+ const style = getComputedStyle(element);
920
+ const padding = (parseFloat(style.paddingLeft) || 0) + (parseFloat(style.paddingRight) || 0);
921
+ const border = (parseFloat(style.borderLeftWidth) || 0) + (parseFloat(style.borderRightWidth) || 0);
922
+ if (element.getClientRects?.().length > 0 && /px$/.test(style.width)) {
923
+ const width = parseFloat(style.width);
924
+ return style.boxSizing === "border-box" ? width - padding - border : width;
925
+ }
926
+ return (element.clientWidth || element.getBoundingClientRect().width - border) - padding;
927
+ }
928
+ function roomOf(element, width = null) {
929
+ const before = element.style.width;
930
+ if (width === null || before === width) return innerWidth(element);
931
+ element.style.width = width;
932
+ try {
933
+ return innerWidth(element);
934
+ } finally {
935
+ element.style.width = before;
936
+ }
836
937
  }
837
938
  function sizedInside({ wrapper, sized, wider }) {
838
939
  if (!sized) return null;
839
- wrapper.style.width = "";
840
- const style = getComputedStyle(wrapper);
841
- const inner = wrapper.clientWidth - (parseFloat(style.paddingLeft) || 0) - (parseFloat(style.paddingRight) || 0);
940
+ if (wrapper.style.width) wrapper.style.width = "";
941
+ const inner = innerWidth(wrapper);
842
942
  return inner > 0 ? { wider, inner } : null;
843
943
  }
844
944
  function frameEdges(wrapper) {
@@ -912,19 +1012,19 @@
912
1012
  table.classList.add("doc-table--auto");
913
1013
  table.style.width = `${total2}px`;
914
1014
  clearColumnMarks(table);
1015
+ let room = frameSize?.inner ?? null;
915
1016
  if (wrapper) {
916
1017
  const edges = frameEdges(wrapper);
917
1018
  setAttribute(wrapper, "data-doc-min-width", String(Math.min(total2, COLUMN_FLOOR) + edges));
918
1019
  if (!frameSize) {
919
- wrapper.style.width = "100%";
920
- const style = getComputedStyle(wrapper);
921
- const available = wrapper.clientWidth - (parseFloat(style.paddingLeft) || 0) - (parseFloat(style.paddingRight) || 0);
922
- wrapper.style.width = total2 < available ? `${total2 + edges}px` : "100%";
1020
+ room = roomOf(wrapper, "100%");
1021
+ setStyle(wrapper, "width", total2 < room ? `${total2 + edges}px` : "100%");
923
1022
  }
924
1023
  }
925
1024
  writeColgroup(table, sizes.map((width, index) => ({ width: `${width}px`, key: String(index) })));
926
1025
  layouts.set(table, sizes.map((width, index) => ({ key: String(index), kind: "compact", preferredWidth: width, softMinWidth: width, hardMinWidth: width, width, ratio: width / total2 })));
927
1026
  for (const [cell, { c, cols }] of slots?.places ?? []) markRunWrap(cell, sizes.slice(c, c + cols).reduce((sum, width) => sum + width, 0), measureCell);
1027
+ return room;
928
1028
  }
929
1029
  function raiseNarrow(widths, room, floor) {
930
1030
  const low = widths.filter((width) => width < floor).sort((a, b) => a - b);
@@ -939,12 +1039,15 @@
939
1039
  }
940
1040
  return widths.map((width) => Math.max(width, Math.min(level, floor)));
941
1041
  }
942
- function refreshLayout(table) {
1042
+ function refreshLayout(table, { observed = false } = {}) {
943
1043
  idleLayouts.delete(table);
944
1044
  const measure = createCellMeasurer(table);
945
- layOut(table, measure);
1045
+ const room = layOut(table, measure);
946
1046
  measure.done();
947
1047
  markWhole(table);
1048
+ followChain(table, room, observed);
1049
+ const watched = observedOf.get(table);
1050
+ if (watched) leftAt.set(table, new Map(watched.map((element) => [element, innerWidth(element)])));
948
1051
  const wrapper = wrapperOf(table);
949
1052
  if (wrapper) placeScrollbars(wrapper, { renote: true });
950
1053
  }
@@ -957,7 +1060,36 @@
957
1060
  if (manual) return manualLayout(table, frame, manual, measure);
958
1061
  const count = headers.length || rows[0]?.cells.length || 0;
959
1062
  if (!count || table.tHead && table.tHead.rows.length !== 1 || spanned) return nativeLayout(table, frame);
960
- allocatedLayout(table, frame, headers, rows, count, measure);
1063
+ return allocatedLayout(table, frame, headers, rows, count, measure);
1064
+ }
1065
+ var observedOf = /* @__PURE__ */ new WeakMap();
1066
+ var leftAt = /* @__PURE__ */ new WeakMap();
1067
+ var CHAIN_GAP = 100;
1068
+ var RETURNS_MAX = 3;
1069
+ var HOLD = 1e3;
1070
+ var chains = /* @__PURE__ */ new WeakMap();
1071
+ function followChain(table, room, observed) {
1072
+ const now = performance.now();
1073
+ const chain = chains.get(table);
1074
+ if (!observed || !chain || now - chain.at > CHAIN_GAP) {
1075
+ if (chain?.timer) clearTimeout(chain.timer);
1076
+ chains.set(table, { at: now, rooms: [room], returns: 0, held: false, timer: 0 });
1077
+ return;
1078
+ }
1079
+ const near = (other) => typeof room === "number" && typeof other === "number" && Math.abs(room - other) < SUBPIXEL;
1080
+ if (!near(chain.rooms.at(-1)) && near(chain.rooms.at(-2))) chain.returns++;
1081
+ chain.rooms = [...chain.rooms.slice(-2), room];
1082
+ chain.at = now;
1083
+ chain.held = chain.returns >= RETURNS_MAX;
1084
+ }
1085
+ function held(table) {
1086
+ const chain = chains.get(table);
1087
+ if (!chain?.held) return false;
1088
+ chain.timer ||= setTimeout(() => {
1089
+ chains.delete(table);
1090
+ queueLayout(table);
1091
+ }, Math.max(0, chain.at + HOLD - performance.now()));
1092
+ return true;
961
1093
  }
962
1094
  var wholeTexts = /* @__PURE__ */ new WeakMap();
963
1095
  function markWhole(table) {
@@ -1014,21 +1146,19 @@ ${columns.map((texts) => texts?.join("\n") ?? "").join("\f")}`;
1014
1146
  table.removeAttribute("data-doc-filled");
1015
1147
  table.style.removeProperty("width");
1016
1148
  }
1149
+ return frameSize?.inner ?? null;
1017
1150
  }
1018
1151
  function allocatedLayout(table, frame, headers, rows, count, measureCell) {
1019
1152
  table.removeAttribute("data-doc-filled");
1020
- const { wrapper, sized, wider, previousWidth } = frame;
1153
+ const { wrapper, sized, wider } = frame;
1021
1154
  const parent = wrapper || table.parentElement;
1022
- if (!parent) return;
1023
- if (wrapper) wrapper.style.width = sized ? "" : "100%";
1155
+ if (!parent) return null;
1156
+ if (sized && wrapper.style.width) wrapper.style.width = "";
1024
1157
  const style = getComputedStyle(parent);
1025
1158
  const padding = (parseFloat(style.paddingLeft) || 0) + (parseFloat(style.paddingRight) || 0);
1026
1159
  const border = (parseFloat(style.borderLeftWidth) || 0) + (parseFloat(style.borderRightWidth) || 0);
1027
- const available = (parent.clientWidth || parent.getBoundingClientRect().width - border) - padding;
1028
- if (!(available > 0)) {
1029
- if (wrapper) wrapper.style.width = previousWidth;
1030
- return;
1031
- }
1160
+ const available = roomOf(parent, wrapper && !sized ? "100%" : null);
1161
+ if (!(available > 0)) return null;
1032
1162
  const font = fontFor(rows[0]?.cells[0] || table);
1033
1163
  const cellPadding = cellPaddingFor(getComputedStyle(rows[0]?.cells[0] || headers[0]));
1034
1164
  const measuredCells = /* @__PURE__ */ new Map();
@@ -1074,7 +1204,7 @@ ${columns.map((texts) => texts?.join("\n") ?? "").join("\f")}`;
1074
1204
  table.classList.add("doc-table--auto");
1075
1205
  table.style.width = sized && tableWidth <= available + 4 ? "100%" : `${tableWidth}px`;
1076
1206
  if (wrapper) setAttribute(wrapper, "data-doc-min-width", String(Math.ceil(result.reduce((value, column) => value + column.softMinWidth, 0) + border + padding)));
1077
- if (wrapper && !sized) wrapper.style.width = tableWidth >= available - 0.01 ? "100%" : `${tableWidth + border + padding}px`;
1207
+ if (wrapper && !sized) setStyle(wrapper, "width", tableWidth >= available - 0.01 ? "100%" : `${tableWidth + border + padding}px`);
1078
1208
  writeColgroup(table, result.map((column) => ({ width: `${column.ratio * 100}%`, key: column.key })));
1079
1209
  result.forEach((column, index) => {
1080
1210
  for (const cell of [headers[index], ...rows.map((row) => row.cells[index])].filter(Boolean)) {
@@ -1086,15 +1216,23 @@ ${columns.map((texts) => texts?.join("\n") ?? "").join("\f")}`;
1086
1216
  }
1087
1217
  });
1088
1218
  layouts.set(table, result.map((column) => ({ ...column, width: column.ratio * tableWidth })));
1219
+ return available;
1089
1220
  }
1090
- function queueLayout(table) {
1221
+ var observedOnly = /* @__PURE__ */ new WeakSet();
1222
+ function queueLayout(table, { observed = false } = {}) {
1223
+ if (!observed) observedOnly.delete(table);
1224
+ else if (!pendingLayouts.has(table)) observedOnly.add(table);
1091
1225
  pendingLayouts.add(table);
1092
1226
  if (layoutFrame) return;
1093
1227
  layoutFrame = requestAnimationFrame(() => {
1094
1228
  layoutFrame = 0;
1095
1229
  const tables = [...pendingLayouts];
1096
1230
  pendingLayouts.clear();
1097
- tables.filter((table2) => table2.isConnected).forEach(refreshLayout);
1231
+ for (const table2 of tables) {
1232
+ const observed2 = observedOnly.has(table2);
1233
+ observedOnly.delete(table2);
1234
+ if (table2.isConnected) refreshLayout(table2, { observed: observed2 });
1235
+ }
1098
1236
  });
1099
1237
  }
1100
1238
  var idleLayouts = /* @__PURE__ */ new Set();
@@ -1107,26 +1245,23 @@ ${columns.map((texts) => texts?.join("\n") ?? "").join("\f")}`;
1107
1245
  idleQueued = false;
1108
1246
  const tables = [...idleLayouts];
1109
1247
  idleLayouts.clear();
1110
- tables.forEach(queueLayout);
1248
+ tables.forEach((table2) => queueLayout(table2));
1111
1249
  };
1112
1250
  if (globalThis.requestIdleCallback) requestIdleCallback(run, { timeout: 1e3 });
1113
1251
  else setTimeout(run, 50);
1114
1252
  }
1115
1253
  function applyColumnWidths(table, { layout = true } = {}) {
1116
1254
  if (!layoutObservers.has(table)) {
1117
- const previous = /* @__PURE__ */ new WeakMap();
1118
1255
  const observer = new ResizeObserver((entries) => {
1119
- for (const { target, contentRect } of entries) {
1120
- if (contentRect.width !== previous.get(target)) {
1121
- previous.set(target, contentRect.width);
1122
- queueLayout(table);
1123
- }
1124
- }
1256
+ const left = leftAt.get(table);
1257
+ const changed = entries.some(({ target, contentRect }) => !(Math.abs(contentRect.width - (left?.get(target) ?? NaN)) < SUBPIXEL));
1258
+ if (changed && !held(table)) queueLayout(table, { observed: true });
1125
1259
  });
1126
1260
  const wrapper = wrapperOf(table);
1127
1261
  const parent = wrapper ? wrapper.parentElement : table.parentElement;
1128
- if (parent) observer.observe(parent);
1129
- if (wrapper) observer.observe(wrapper);
1262
+ const watched = [parent, wrapper].filter(Boolean);
1263
+ watched.forEach((element) => observer.observe(element));
1264
+ observedOf.set(table, watched);
1130
1265
  layoutObservers.set(table, observer);
1131
1266
  if (wrapper) drawScrollbars(wrapper, table);
1132
1267
  }
package/kit/ui.js CHANGED
@@ -3,6 +3,9 @@
3
3
  // src/shared/components/installed.mjs
4
4
  var ATTRIBUTE = "data-doc-component";
5
5
  var INSTANCE = `div[${ATTRIBUTE}], section[${ATTRIBUTE}]`;
6
+ var SLOT = "data-doc-slot";
7
+ var SLOT_PART = `div[${SLOT}], section[${SLOT}]`;
8
+ var REGION = `${INSTANCE}, ${SLOT_PART}`;
6
9
  var PACKAGE_MARK = "data-doc-package";
7
10
  var DATA_MOST = 1024 * 1024;
8
11
 
@@ -131,7 +134,8 @@ ${source}
131
134
  var OWN_METAS = new RegExp(`<head\\b[^>]*>\\s*<meta name="generator" content="(?:${GENERATORS.join("|")})">\\s*<meta http-equiv="Content-Security-Policy" content="[^"]*">\\s*<meta name="${SOURCE_META}" content="sha256:([0-9a-f]{64})">(?:\\s*<meta name="${PACKAGES_META}" content="([^"]*)">)?`, "i");
132
135
 
133
136
  // src/shared/page-links.mjs
134
- function pageId(slug) {
137
+ var DOC_SLUG = /^doc-([a-z][a-z0-9]{7})$/;
138
+ function hashId(slug) {
135
139
  let one = 3735928559;
136
140
  let two = 1103547991;
137
141
  for (let at = 0; at < slug.length; at++) {
@@ -143,10 +147,15 @@ ${source}
143
147
  const hash = (two >>> 0) % 2 ** 21 * 2 ** 32 + (one >>> 0);
144
148
  return String.fromCharCode(97 + hash % 26) + Math.floor(hash / 26).toString(36).padStart(7, "0").slice(-7);
145
149
  }
150
+ var pageId = (slug) => DOC_SLUG.exec(slug)?.[1] ?? hashId(slug);
151
+ var earlierId = (slug) => DOC_SLUG.test(slug) ? hashId(slug) : null;
152
+ var ID_FIRST = "abcdefghijklmnopqrstuvwxyz";
153
+ var ID_REST = `${ID_FIRST}0123456789`;
146
154
  function pageOfLink(links, value) {
147
155
  if (links.has(value)) return value;
148
156
  const id = value.slice(value.lastIndexOf("-") + 1);
149
157
  for (const slug of links.keys()) if (pageId(slug) === id) return slug;
158
+ for (const slug of links.keys()) if (earlierId(slug) === id) return slug;
150
159
  return null;
151
160
  }
152
161
 
@@ -204,6 +213,101 @@ ${source}
204
213
  }
205
214
  }
206
215
 
216
+ // src/shared/components/page.mjs
217
+ var LOOK_ATTRIBUTES = Object.freeze({ font: "data-doc-font", size: "data-doc-size", spacing: "data-doc-spacing", width: "data-doc-measure", full: "data-doc-width" });
218
+ var page_default = {
219
+ id: "page",
220
+ match: "main.doc-page",
221
+ flow: ".doc-page",
222
+ groups: false,
223
+ header: "header.doc-header",
224
+ // the title and the lines under it
225
+ title: ".doc-title",
226
+ // the document's title, the h1 of the header: its text, mirrored in <title> and report.json
227
+ attrs: {
228
+ "data-doc-id": "the document's slug: its reading state is kept under it",
229
+ "data-doc-kit": "a kit asset's tag (the render puts in those a report needs; an older source writes them)",
230
+ "data-doc-vendor": "a vendor library's tag",
231
+ "data-doc-placeholder": "the starter's content, which the checks want replaced",
232
+ "data-doc-transient-view": "its hidden or open shows transient reading state, reset in an export of the view"
233
+ },
234
+ classes: ["doc-page", "doc-header", "doc-kicker", "doc-title", "doc-button"],
235
+ runtime: {
236
+ generated: [".doc-display", "script[data-doc-state]"],
237
+ // data-doc-effective-theme: the theme the page shows now (ui.js), "light" or "dark", which a custom page's own colors go by.
238
+ // data-doc-platform: "mac" on an Apple platform (runtime/index.js sets it as the page opens), the text's color and smoothing go by it; a copy of the view lets it go, its reader's machine judges anew.
239
+ root: { attrs: ["data-doc-ready", "data-doc-drawn", "data-doc-controls", "data-doc-effective-theme", "data-doc-platform"] },
240
+ // The reader's theme (ui.js) and the document's look (字体与布局 and 全宽: its doc.json's, put on by
241
+ // the render, src/shared/document-look.mjs; the reader's own 全宽显示 is the same data-doc-width), which
242
+ // a copy of the view keeps; never written in doc.html.
243
+ state: { html: ["data-doc-theme", ...Object.values(LOOK_ATTRIBUTES)] },
244
+ internal: [
245
+ "doc-display*",
246
+ "data-doc-export-copy",
247
+ "data-theme",
248
+ "doc-export-id",
249
+ "doc-reveal",
250
+ "doc-kit-error",
251
+ "doc-net-consent*",
252
+ "data-doc-snapshot",
253
+ // The time an export's snapshot was made (its data-doc-snapshot tag's: render/net-snapshot.mjs), which context.workspace.query answers as `at`.
254
+ "data-at",
255
+ // A custom page's (no document's: src/render/page-html.mjs, the kit's board/): its cards' cells, the Agent's
256
+ // (data-x, data-y, data-w, data-h), and its boards' columns now (data-columns, board.js's).
257
+ "data-x",
258
+ "data-y",
259
+ "data-w",
260
+ "data-h",
261
+ "data-columns"
262
+ ]
263
+ }
264
+ };
265
+
266
+ // src/shared/document-look.mjs
267
+ var LOOK = Object.freeze({
268
+ font: Object.freeze(["sans", "serif", "mixed"]),
269
+ // 等线体, 衬线体, 混合体 (the title and headings serif)
270
+ size: Object.freeze(["default", "small", "large"]),
271
+ // 字体大小: 小号, 默认, 大号
272
+ spacing: Object.freeze(["default", "compact", "loose"]),
273
+ // 正文间距: 紧凑, 默认, 宽松
274
+ width: Object.freeze(["default", "narrow", "wide"]),
275
+ // 正文宽度: 偏窄, 默认, 偏宽
276
+ // 全宽 (the 更多 menu's switch under 目录): the page at the full width of its area, whatever its 正文宽度 is; its attribute is
277
+ // the kit's own data-doc-width="full", the reader's display menu's 全宽显示 too (components/page.mjs LOOK_ATTRIBUTES)
278
+ full: Object.freeze(["default", "full"])
279
+ });
280
+ var SIZE_FACTOR = Object.freeze({ default: 1, small: 15 / 16, large: 18 / 16 });
281
+ var SPACING = Object.freeze({
282
+ default: Object.freeze({ leading: 1, gaps: 1 }),
283
+ compact: Object.freeze({ leading: 0.8, gaps: 0.75 }),
284
+ loose: Object.freeze({ leading: 1.2, gaps: 1.25 })
285
+ });
286
+ var WIDTH = Object.freeze({ default: 712, narrow: 648, wide: 776 });
287
+ var isPlain = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
288
+ function lookOf(value) {
289
+ const look = {};
290
+ if (!isPlain(value)) return look;
291
+ for (const [key, choices] of Object.entries(LOOK)) {
292
+ const chosen = value[key];
293
+ if (typeof chosen === "string" && choices.includes(chosen) && chosen !== choices[0]) look[key] = chosen;
294
+ }
295
+ return look;
296
+ }
297
+ var ATTRIBUTE_VALUE = String.raw`(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?`;
298
+ function setLookOn(element, look) {
299
+ const next = lookOf(look);
300
+ let changed = false;
301
+ for (const [key, name] of Object.entries(LOOK_ATTRIBUTES)) {
302
+ const value = next[key] ?? null;
303
+ if (element.getAttribute(name) === value) continue;
304
+ if (value === null) element.removeAttribute(name);
305
+ else element.setAttribute(name, value);
306
+ changed = true;
307
+ }
308
+ return changed;
309
+ }
310
+
207
311
  // src/render/kit/words.js
208
312
  var DISPLAY = {
209
313
  "display": { zh: "\u663E\u793A\u8BBE\u7F6E", en: "Display settings" },
@@ -237,17 +341,47 @@ ${source}
237
341
  "use strict";
238
342
  const root = document.documentElement;
239
343
  const page = document.querySelector(".doc-page");
240
- if (!page || document.querySelector(".doc-display")) return;
344
+ const custom = page ? null : document.querySelector(".gallery-page");
345
+ if (!(page || custom) || document.querySelector(".doc-display")) return;
241
346
  const systemTheme = matchMedia("(prefers-color-scheme: dark)");
242
347
  if (!globalThis.DocState) throw new Error("Report UI requires /kit/state.js to be loaded first.");
243
348
  if (!globalThis.DocKit) throw new Error("Report UI requires /kit/runtime.js to be loaded first.");
244
- const reportId = page.dataset.docId || location.pathname || "report";
245
- const displayState = DocState.create({
349
+ const reportId = page?.dataset.docId || location.pathname || "report";
350
+ const displayState = page ? DocState.create({
246
351
  id: "display",
247
352
  // this report's (DocState scopes it by data-doc-id)
248
353
  version: 1,
249
354
  defaults: { theme: null, width: "reading", exportVersion: 0 }
355
+ }) : null;
356
+ const chosenTheme = () => {
357
+ const theme = displayState?.get("theme");
358
+ return theme === "light" || theme === "dark" ? theme : null;
359
+ };
360
+ function effectiveTheme() {
361
+ return root.dataset.docTheme || (systemTheme.matches ? "dark" : "light");
362
+ }
363
+ const themeChanged = () => {
364
+ root.dataset.docEffectiveTheme = effectiveTheme();
365
+ for (const name of ["doc-theme-change", "report-theme-change"]) dispatchEvent(new CustomEvent(name, { detail: { theme: effectiveTheme() } }));
366
+ };
367
+ addEventListener("doc-theme-request", (event) => {
368
+ const theme = event.detail?.theme ?? chosenTheme();
369
+ if (theme === "light" || theme === "dark") root.dataset.docTheme = theme;
370
+ else delete root.dataset.docTheme;
371
+ updateThemeItems();
372
+ themeChanged();
250
373
  });
374
+ systemTheme.addEventListener?.("change", () => {
375
+ if (root.dataset.docTheme) return;
376
+ themeChanged();
377
+ });
378
+ const markReady = () => requestAnimationFrame(() => root.setAttribute("data-doc-ready", ""));
379
+ const ready = () => document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", markReady, { once: true }) : markReady();
380
+ if (custom) {
381
+ root.dataset.docEffectiveTheme = effectiveTheme();
382
+ ready();
383
+ return;
384
+ }
251
385
  const icons = {
252
386
  // Two sliders, their knobs open circles the lines stop at.
253
387
  settings: '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M3.5 6.5h7.25M15.25 6.5h1.25M3.5 13.5h1.25M9.25 13.5h7.25"/><circle cx="13" cy="6.5" r="2.25"/><circle cx="7" cy="13.5" r="2.25"/></svg>',
@@ -308,19 +442,15 @@ ${source}
308
442
  display.append(menuButton, menu);
309
443
  document.body.prepend(display);
310
444
  root.dataset.docControls = "ready";
311
- const markReady = () => requestAnimationFrame(() => root.setAttribute("data-doc-ready", ""));
312
- if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", markReady, { once: true });
313
- else markReady();
314
- const storedTheme = displayState.get("theme");
315
- if (storedTheme === "light" || storedTheme === "dark") root.dataset.docTheme = storedTheme;
445
+ ready();
446
+ const storedTheme = chosenTheme();
447
+ if (storedTheme) root.dataset.docTheme = storedTheme;
448
+ root.dataset.docEffectiveTheme = effectiveTheme();
316
449
  const storedWidth = displayState.get("width");
317
450
  if (storedWidth === "full") root.dataset.docWidth = "full";
318
- function effectiveTheme() {
319
- return root.dataset.docTheme || (systemTheme.matches ? "dark" : "light");
320
- }
321
451
  function updateThemeItems() {
322
- const chosen = displayState.get("theme");
323
- const current = chosen === "light" || chosen === "dark" ? chosen : "system";
452
+ if (!displayState) return;
453
+ const current = chosenTheme() ?? "system";
324
454
  themeItems.forEach((item) => item.setAttribute("aria-checked", String(item.dataset.theme === current)));
325
455
  }
326
456
  function updateWidthItem() {
@@ -511,9 +641,6 @@ ${clone.outerHTML}`;
511
641
  event.preventDefault();
512
642
  list[next].focus();
513
643
  });
514
- const themeChanged = () => {
515
- for (const name of ["doc-theme-change", "report-theme-change"]) dispatchEvent(new CustomEvent(name, { detail: { theme: effectiveTheme() } }));
516
- };
517
644
  themeItems.forEach((item) => item.addEventListener("click", () => {
518
645
  const theme = item.dataset.theme;
519
646
  if (theme === "system") delete root.dataset.docTheme;
@@ -522,12 +649,28 @@ ${clone.outerHTML}`;
522
649
  updateThemeItems();
523
650
  themeChanged();
524
651
  }));
525
- addEventListener("doc-theme-request", (event) => {
526
- const theme = event.detail?.theme ?? displayState.get("theme");
527
- if (theme === "light" || theme === "dark") root.dataset.docTheme = theme;
528
- else delete root.dataset.docTheme;
529
- updateThemeItems();
530
- themeChanged();
652
+ const LOOK_HELD = 2e3;
653
+ let held = null;
654
+ const showLook = (look) => {
655
+ if (!setLookOn(root, look)) return;
656
+ dispatchEvent(new Event("doc-layout-change"));
657
+ dispatchEvent(new Event("resize"));
658
+ dispatchEvent(new CustomEvent("doc-look-change", { detail: { look: lookOf(look) } }));
659
+ };
660
+ addEventListener("doc-look-request", (event) => {
661
+ const look = event.detail?.look;
662
+ if (event.detail?.from === "file") {
663
+ if (held) held.said = look;
664
+ else showLook(look);
665
+ return;
666
+ }
667
+ clearTimeout(held?.timer);
668
+ held = { said: null, timer: setTimeout(() => {
669
+ const said = held?.said;
670
+ held = null;
671
+ if (said) showLook(said);
672
+ }, LOOK_HELD) };
673
+ showLook(look);
531
674
  });
532
675
  widthItem.addEventListener("click", () => {
533
676
  const next = root.dataset.docWidth === "full" ? "reading" : "full";
@@ -551,10 +694,6 @@ ${clone.outerHTML}`;
551
694
  }
552
695
  dispatchEvent(new CustomEvent("doc-export-copy-done", { detail: outcome }));
553
696
  });
554
- systemTheme.addEventListener?.("change", () => {
555
- if (root.dataset.docTheme) return;
556
- themeChanged();
557
- });
558
697
  updateThemeItems();
559
698
  updateWidthItem();
560
699
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycys/gallery",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Gallery: documents written as HTML by an AI agent, shown and edited in the browser, delivered as one offline file. The gallery command and its local server.",
5
5
  "keywords": [
6
6
  "gallery",
@@ -29,6 +29,7 @@
29
29
  "vendor/",
30
30
  "starter/",
31
31
  "assets/",
32
+ "packs/",
32
33
  "sdk/",
33
34
  "skill/",
34
35
  "release.json",