@heycys/gallery 0.0.0-stage → 0.1.1

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 (806) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/THIRD-PARTY-NOTICES.md +3303 -0
  4. package/assets/writing-preferences.md +107 -0
  5. package/bin/gallery.mjs +10 -0
  6. package/browser/editor/components/bookmark/icons.mjs +6 -0
  7. package/browser/editor/components/bookmark/index.mjs +80 -0
  8. package/browser/editor/components/bookmark/page.mjs +147 -0
  9. package/browser/editor/components/builders.mjs +19 -0
  10. package/browser/editor/components/callout/index.mjs +64 -0
  11. package/browser/editor/components/code/index.mjs +327 -0
  12. package/browser/editor/components/code/page.mjs +561 -0
  13. package/browser/editor/components/colors.mjs +50 -0
  14. package/browser/editor/components/columns/index.mjs +104 -0
  15. package/browser/editor/components/columns/page.mjs +310 -0
  16. package/browser/editor/components/details/index.mjs +73 -0
  17. package/browser/editor/components/details/page.mjs +86 -0
  18. package/browser/editor/components/dialog/index.mjs +84 -0
  19. package/browser/editor/components/dialog/page.mjs +201 -0
  20. package/browser/editor/components/divider/index.mjs +48 -0
  21. package/browser/editor/components/embed/icons.mjs +11 -0
  22. package/browser/editor/components/embed/index.mjs +123 -0
  23. package/browser/editor/components/embed/page.mjs +309 -0
  24. package/browser/editor/components/figure/index.mjs +87 -0
  25. package/browser/editor/components/figure/page.mjs +42 -0
  26. package/browser/editor/components/file/icons.mjs +14 -0
  27. package/browser/editor/components/file/index.mjs +77 -0
  28. package/browser/editor/components/file/page.mjs +114 -0
  29. package/browser/editor/components/flowchart/add.mjs +123 -0
  30. package/browser/editor/components/flowchart/index.mjs +246 -0
  31. package/browser/editor/components/flowchart/page.mjs +453 -0
  32. package/browser/editor/components/heading/index.mjs +53 -0
  33. package/browser/editor/components/heading/page.mjs +6 -0
  34. package/browser/editor/components/highlight/index.mjs +63 -0
  35. package/browser/editor/components/icon/index.mjs +57 -0
  36. package/browser/editor/components/icon/page.mjs +286 -0
  37. package/browser/editor/components/icons.mjs +48 -0
  38. package/browser/editor/components/image/crop.mjs +189 -0
  39. package/browser/editor/components/image/index.mjs +104 -0
  40. package/browser/editor/components/image/page.mjs +385 -0
  41. package/browser/editor/components/image/viewer.mjs +213 -0
  42. package/browser/editor/components/installed/index.mjs +179 -0
  43. package/browser/editor/components/installed/page.mjs +523 -0
  44. package/browser/editor/components/installed/served.mjs +35 -0
  45. package/browser/editor/components/kit.mjs +67 -0
  46. package/browser/editor/components/list/index.mjs +194 -0
  47. package/browser/editor/components/list/join.mjs +68 -0
  48. package/browser/editor/components/list/numbers.mjs +107 -0
  49. package/browser/editor/components/list/page.mjs +632 -0
  50. package/browser/editor/components/math/index.mjs +88 -0
  51. package/browser/editor/components/math/page.mjs +236 -0
  52. package/browser/editor/components/math/tex-logo.mjs +6 -0
  53. package/browser/editor/components/media/icons.mjs +19 -0
  54. package/browser/editor/components/media/page.mjs +192 -0
  55. package/browser/editor/components/media/parts.mjs +60 -0
  56. package/browser/editor/components/media/size.mjs +20 -0
  57. package/browser/editor/components/media/toolbar.mjs +37 -0
  58. package/browser/editor/components/media/write.mjs +7 -0
  59. package/browser/editor/components/pages.mjs +46 -0
  60. package/browser/editor/components/paragraph/index.mjs +43 -0
  61. package/browser/editor/components/paragraph/page.mjs +52 -0
  62. package/browser/editor/components/placeholder-bar.mjs +17 -0
  63. package/browser/editor/components/placeholder.mjs +128 -0
  64. package/browser/editor/components/quote/index.mjs +33 -0
  65. package/browser/editor/components/registry.mjs +859 -0
  66. package/browser/editor/components/rows.mjs +16 -0
  67. package/browser/editor/components/section/index.mjs +42 -0
  68. package/browser/editor/components/section/page.mjs +141 -0
  69. package/browser/editor/components/set-apart.mjs +24 -0
  70. package/browser/editor/components/sheets/index.mjs +137 -0
  71. package/browser/editor/components/sheets/page.mjs +227 -0
  72. package/browser/editor/components/sheets/pills.mjs +226 -0
  73. package/browser/editor/components/table/grid.mjs +73 -0
  74. package/browser/editor/components/table/index.mjs +308 -0
  75. package/browser/editor/components/table/page.mjs +683 -0
  76. package/browser/editor/components/table/slots.mjs +41 -0
  77. package/browser/editor/components/widget/index.mjs +50 -0
  78. package/browser/editor/page/annotate/anchors.mjs +230 -0
  79. package/browser/editor/page/annotate/card.mjs +102 -0
  80. package/browser/editor/page/annotate/index.mjs +1656 -0
  81. package/browser/editor/page/at-menu/index.mjs +317 -0
  82. package/browser/editor/page/autosave.mjs +1023 -0
  83. package/browser/editor/page/beside.mjs +21 -0
  84. package/browser/editor/page/block-info.mjs +63 -0
  85. package/browser/editor/page/block-menu/colors.mjs +84 -0
  86. package/browser/editor/page/block-menu/index.mjs +217 -0
  87. package/browser/editor/page/blocks.mjs +255 -0
  88. package/browser/editor/page/caret.mjs +682 -0
  89. package/browser/editor/page/changes/bar.mjs +102 -0
  90. package/browser/editor/page/changes/ghost.mjs +206 -0
  91. package/browser/editor/page/changes/gone-words.mjs +94 -0
  92. package/browser/editor/page/changes/index.mjs +447 -0
  93. package/browser/editor/page/changes/words.mjs +27 -0
  94. package/browser/editor/page/chip-fills.mjs +126 -0
  95. package/browser/editor/page/clipboard/import/colors.mjs +192 -0
  96. package/browser/editor/page/clipboard/import/html.mjs +792 -0
  97. package/browser/editor/page/clipboard/import/inline.mjs +232 -0
  98. package/browser/editor/page/clipboard/import/languages.mjs +42 -0
  99. package/browser/editor/page/clipboard/import/markdown.mjs +760 -0
  100. package/browser/editor/page/clipboard/import/math.mjs +100 -0
  101. package/browser/editor/page/clipboard/import/office.mjs +245 -0
  102. package/browser/editor/page/clipboard/import/read.mjs +120 -0
  103. package/browser/editor/page/clipboard/import/rich.mjs +29 -0
  104. package/browser/editor/page/clipboard/import/to-blocks.mjs +290 -0
  105. package/browser/editor/page/clipboard/index.mjs +816 -0
  106. package/browser/editor/page/clipboard/own/blocks.mjs +211 -0
  107. package/browser/editor/page/clipboard/own/chart-keys.mjs +58 -0
  108. package/browser/editor/page/clipboard/own/describe.mjs +124 -0
  109. package/browser/editor/page/clipboard/own/export.mjs +167 -0
  110. package/browser/editor/page/clipboard/own/ids.mjs +39 -0
  111. package/browser/editor/page/clipboard/own/index.mjs +13 -0
  112. package/browser/editor/page/clipboard/own/rules.mjs +44 -0
  113. package/browser/editor/page/clipboard/own/selection.mjs +159 -0
  114. package/browser/editor/page/clipboard/own/writers.mjs +315 -0
  115. package/browser/editor/page/columns/index.mjs +360 -0
  116. package/browser/editor/page/commit.mjs +1813 -0
  117. package/browser/editor/page/conflicts.mjs +249 -0
  118. package/browser/editor/page/convert.mjs +831 -0
  119. package/browser/editor/page/core.mjs +1693 -0
  120. package/browser/editor/page/drag/drop.mjs +307 -0
  121. package/browser/editor/page/drag/index.mjs +351 -0
  122. package/browser/editor/page/drag/preview.mjs +126 -0
  123. package/browser/editor/page/edge-scroll.mjs +50 -0
  124. package/browser/editor/page/editor.mjs +1780 -0
  125. package/browser/editor/page/emoji-picker/emoji-tab.mjs +287 -0
  126. package/browser/editor/page/emoji-picker/glyph-html.mjs +26 -0
  127. package/browser/editor/page/emoji-picker/grid.mjs +81 -0
  128. package/browser/editor/page/emoji-picker/icon-tab.mjs +217 -0
  129. package/browser/editor/page/emoji-picker/icons.mjs +31 -0
  130. package/browser/editor/page/emoji-picker/index.mjs +166 -0
  131. package/browser/editor/page/emoji-picker/styles.mjs +161 -0
  132. package/browser/editor/page/emoji-picker/support.mjs +204 -0
  133. package/browser/editor/page/emoji-picker/upload.mjs +236 -0
  134. package/browser/editor/page/export-report.mjs +23 -0
  135. package/browser/editor/page/fills.mjs +62 -0
  136. package/browser/editor/page/find/index.mjs +107 -0
  137. package/browser/editor/page/flags.mjs +70 -0
  138. package/browser/editor/page/fold/index.mjs +348 -0
  139. package/browser/editor/page/fold/rule.mjs +125 -0
  140. package/browser/editor/page/folded.mjs +23 -0
  141. package/browser/editor/page/format-bar/bar.mjs +449 -0
  142. package/browser/editor/page/format-bar/brush.mjs +77 -0
  143. package/browser/editor/page/format-bar/colors.mjs +46 -0
  144. package/browser/editor/page/format-bar/index.mjs +404 -0
  145. package/browser/editor/page/formula/index.mjs +236 -0
  146. package/browser/editor/page/formula/panel.mjs +336 -0
  147. package/browser/editor/page/formula/symbols.mjs +156 -0
  148. package/browser/editor/page/frame.mjs +74 -0
  149. package/browser/editor/page/frames.mjs +196 -0
  150. package/browser/editor/page/geometry.mjs +402 -0
  151. package/browser/editor/page/gesture.mjs +45 -0
  152. package/browser/editor/page/handle/index.mjs +650 -0
  153. package/browser/editor/page/handle-sizes.mjs +14 -0
  154. package/browser/editor/page/hints/index.mjs +84 -0
  155. package/browser/editor/page/history.mjs +401 -0
  156. package/browser/editor/page/insert/index.mjs +256 -0
  157. package/browser/editor/page/kept.mjs +38 -0
  158. package/browser/editor/page/links/address.mjs +40 -0
  159. package/browser/editor/page/links/index.mjs +866 -0
  160. package/browser/editor/page/links/pages.mjs +131 -0
  161. package/browser/editor/page/links/views.mjs +369 -0
  162. package/browser/editor/page/long-runs.mjs +75 -0
  163. package/browser/editor/page/look.mjs +77 -0
  164. package/browser/editor/page/made.mjs +24 -0
  165. package/browser/editor/page/margin.mjs +373 -0
  166. package/browser/editor/page/markdown/index.mjs +88 -0
  167. package/browser/editor/page/markdown/rules.mjs +33 -0
  168. package/browser/editor/page/marks.mjs +377 -0
  169. package/browser/editor/page/media-menu/index.mjs +158 -0
  170. package/browser/editor/page/menu.mjs +544 -0
  171. package/browser/editor/page/merge.mjs +124 -0
  172. package/browser/editor/page/notices.mjs +142 -0
  173. package/browser/editor/page/offered.mjs +32 -0
  174. package/browser/editor/page/outline/folds.mjs +53 -0
  175. package/browser/editor/page/outline/index.mjs +783 -0
  176. package/browser/editor/page/outline/list.mjs +184 -0
  177. package/browser/editor/page/outline/read.mjs +201 -0
  178. package/browser/editor/page/outline/strip.mjs +287 -0
  179. package/browser/editor/page/outline/tree.mjs +248 -0
  180. package/browser/editor/page/overlay-layer.mjs +227 -0
  181. package/browser/editor/page/overlays.mjs +205 -0
  182. package/browser/editor/page/own.mjs +28 -0
  183. package/browser/editor/page/pads.mjs +71 -0
  184. package/browser/editor/page/page-objects.mjs +105 -0
  185. package/browser/editor/page/panel.mjs +65 -0
  186. package/browser/editor/page/placement.mjs +58 -0
  187. package/browser/editor/page/post.mjs +41 -0
  188. package/browser/editor/page/present-links.mjs +50 -0
  189. package/browser/editor/page/quiet.mjs +48 -0
  190. package/browser/editor/page/resize/index.mjs +327 -0
  191. package/browser/editor/page/select-all/index.mjs +262 -0
  192. package/browser/editor/page/selection/delete.mjs +61 -0
  193. package/browser/editor/page/selection/index.mjs +164 -0
  194. package/browser/editor/page/selection/marquee.mjs +174 -0
  195. package/browser/editor/page/session.mjs +168 -0
  196. package/browser/editor/page/slash-menu/index.mjs +291 -0
  197. package/browser/editor/page/storage.mjs +48 -0
  198. package/browser/editor/page/sync-state.mjs +267 -0
  199. package/browser/editor/page/table/aligns.mjs +29 -0
  200. package/browser/editor/page/table/cell-bar.mjs +141 -0
  201. package/browser/editor/page/table/cells.mjs +527 -0
  202. package/browser/editor/page/table/icons.mjs +40 -0
  203. package/browser/editor/page/table/index.mjs +990 -0
  204. package/browser/editor/page/table/lists.mjs +187 -0
  205. package/browser/editor/page/table/widths.mjs +313 -0
  206. package/browser/editor/page/tex.mjs +32 -0
  207. package/browser/editor/page/text-select/index.mjs +671 -0
  208. package/browser/editor/page/tooltip.mjs +98 -0
  209. package/browser/editor/page/type-grid.mjs +83 -0
  210. package/browser/editor/page/typing/code-edges.mjs +274 -0
  211. package/browser/editor/page/typing/index.mjs +282 -0
  212. package/browser/editor/page/typing/leave.mjs +68 -0
  213. package/browser/editor/page/ui.mjs +160 -0
  214. package/browser/shared/annotations.mjs +569 -0
  215. package/browser/shared/code-folds.mjs +14 -0
  216. package/browser/shared/code-languages.mjs +70 -0
  217. package/browser/shared/code-lines.mjs +30 -0
  218. package/browser/shared/colors.mjs +30 -0
  219. package/browser/shared/component-catalog.mjs +573 -0
  220. package/browser/shared/components/bookmark.mjs +26 -0
  221. package/browser/shared/components/callout.mjs +9 -0
  222. package/browser/shared/components/chart.mjs +20 -0
  223. package/browser/shared/components/code.mjs +37 -0
  224. package/browser/shared/components/columns.mjs +16 -0
  225. package/browser/shared/components/details.mjs +15 -0
  226. package/browser/shared/components/dialog.mjs +28 -0
  227. package/browser/shared/components/diff.mjs +18 -0
  228. package/browser/shared/components/divider.mjs +6 -0
  229. package/browser/shared/components/embed.mjs +25 -0
  230. package/browser/shared/components/figure.mjs +14 -0
  231. package/browser/shared/components/file.mjs +23 -0
  232. package/browser/shared/components/heading.mjs +6 -0
  233. package/browser/shared/components/highlight.mjs +9 -0
  234. package/browser/shared/components/icon.mjs +18 -0
  235. package/browser/shared/components/image.mjs +39 -0
  236. package/browser/shared/components/index.mjs +396 -0
  237. package/browser/shared/components/installed.mjs +232 -0
  238. package/browser/shared/components/list.mjs +146 -0
  239. package/browser/shared/components/math.mjs +49 -0
  240. package/browser/shared/components/mention.mjs +33 -0
  241. package/browser/shared/components/page.mjs +46 -0
  242. package/browser/shared/components/paragraph.mjs +9 -0
  243. package/browser/shared/components/quote.mjs +6 -0
  244. package/browser/shared/components/section.mjs +8 -0
  245. package/browser/shared/components/sheets.mjs +80 -0
  246. package/browser/shared/components/state.mjs +20 -0
  247. package/browser/shared/components/table.mjs +49 -0
  248. package/browser/shared/components/text.mjs +14 -0
  249. package/browser/shared/components/widget.mjs +10 -0
  250. package/browser/shared/copy-ids.mjs +72 -0
  251. package/browser/shared/css-references.mjs +110 -0
  252. package/browser/shared/document-look.mjs +178 -0
  253. package/browser/shared/emoji/custom.mjs +91 -0
  254. package/browser/shared/emoji/data/LICENSE-lucide.txt +43 -0
  255. package/browser/shared/emoji/data/LICENSE-mingcute.txt +202 -0
  256. package/browser/shared/emoji/data/LICENSE-tabler.txt +21 -0
  257. package/browser/shared/emoji/data/README.md +28 -0
  258. package/browser/shared/emoji/data/categories.json +1 -0
  259. package/browser/shared/emoji/data/icons.json +1 -0
  260. package/browser/shared/emoji/data/keywords-en.json +1 -0
  261. package/browser/shared/emoji/data/keywords-zh.json +1 -0
  262. package/browser/shared/emoji/data/names.json +1 -0
  263. package/browser/shared/emoji/data/positions.json +1 -0
  264. package/browser/shared/emoji/data/twemoji-index.json +1 -0
  265. package/browser/shared/emoji/data/twemoji-svg.bin +0 -0
  266. package/browser/shared/emoji/data.mjs +194 -0
  267. package/browser/shared/emoji/emoji.mjs +38 -0
  268. package/browser/shared/emoji/glyphs.mjs +134 -0
  269. package/browser/shared/emoji/icon-value.mjs +91 -0
  270. package/browser/shared/escape.mjs +20 -0
  271. package/browser/shared/export-wrap.mjs +89 -0
  272. package/browser/shared/files.mjs +33 -0
  273. package/browser/shared/html-tree.mjs +59 -0
  274. package/browser/shared/http.mjs +22 -0
  275. package/browser/shared/i18n/en.mjs +1223 -0
  276. package/browser/shared/i18n/index.mjs +132 -0
  277. package/browser/shared/ids.mjs +24 -0
  278. package/browser/shared/import-types.mjs +23 -0
  279. package/browser/shared/inline-spacing.mjs +97 -0
  280. package/browser/shared/layers.mjs +42 -0
  281. package/browser/shared/long-runs.mjs +39 -0
  282. package/browser/shared/media.mjs +162 -0
  283. package/browser/shared/new-names.mjs +67 -0
  284. package/browser/shared/number-reading.mjs +92 -0
  285. package/browser/shared/old-names.mjs +143 -0
  286. package/browser/shared/outline.mjs +194 -0
  287. package/browser/shared/page-address.mjs +140 -0
  288. package/browser/shared/page-links.mjs +86 -0
  289. package/browser/shared/paths.mjs +73 -0
  290. package/browser/shared/preferences.mjs +116 -0
  291. package/browser/shared/preview-server.mjs +247 -0
  292. package/browser/shared/qa-levels.mjs +93 -0
  293. package/browser/shared/reading-place.mjs +91 -0
  294. package/browser/shared/renamed-storage.mjs +220 -0
  295. package/browser/shared/reports.mjs +46 -0
  296. package/browser/shared/search.mjs +85 -0
  297. package/browser/shared/session.mjs +77 -0
  298. package/browser/shared/table-chart.mjs +113 -0
  299. package/browser/shared/table-hides.mjs +120 -0
  300. package/browser/shared/table-slots.mjs +75 -0
  301. package/browser/shared/words.mjs +23 -0
  302. package/browser/shared/workspace-look.mjs +91 -0
  303. package/browser/shared/workspace.mjs +535 -0
  304. package/browser/shared/writing-preferences.mjs +68 -0
  305. package/browser/shared/zoom.mjs +57 -0
  306. package/dist/chunk-2B5E4CDJ.mjs +2 -0
  307. package/dist/chunk-342HXE3Q.mjs +2 -0
  308. package/dist/chunk-3HIRPVLU.mjs +2 -0
  309. package/dist/chunk-43B75J5T.mjs +2 -0
  310. package/dist/chunk-4FS7Z7WR.mjs +2 -0
  311. package/dist/chunk-4K5KC6V2.mjs +2 -0
  312. package/dist/chunk-5L7RYZCL.mjs +2 -0
  313. package/dist/chunk-5MHMDLZD.mjs +4 -0
  314. package/dist/chunk-5ZKJ3H4P.mjs +8 -0
  315. package/dist/chunk-64K7IPLO.mjs +255 -0
  316. package/dist/chunk-6QXGZM36.mjs +8 -0
  317. package/dist/chunk-6RGJOMJP.mjs +16 -0
  318. package/dist/chunk-742D2WWJ.mjs +19 -0
  319. package/dist/chunk-7DTINW6U.mjs +48 -0
  320. package/dist/chunk-A55HN5OK.mjs +2 -0
  321. package/dist/chunk-AGDILNWB.mjs +2 -0
  322. package/dist/chunk-AJ73XJF3.mjs +2 -0
  323. package/dist/chunk-AUZGSZJH.mjs +13 -0
  324. package/dist/chunk-BFE45AKL.mjs +2 -0
  325. package/dist/chunk-BGGDRNYQ.mjs +10 -0
  326. package/dist/chunk-BXO2ZY5P.mjs +2 -0
  327. package/dist/chunk-C564NU2H.mjs +77 -0
  328. package/dist/chunk-CEH4MRCC.mjs +2 -0
  329. package/dist/chunk-CY2FNNAB.mjs +16 -0
  330. package/dist/chunk-DFUDV4LX.mjs +2 -0
  331. package/dist/chunk-DKXG4XDG.mjs +2 -0
  332. package/dist/chunk-E7LWZRXY.mjs +4 -0
  333. package/dist/chunk-EZQ34M3F.mjs +124 -0
  334. package/dist/chunk-EZY3WC6Z.mjs +15 -0
  335. package/dist/chunk-FDLXYYG4.mjs +4 -0
  336. package/dist/chunk-FUKQNOQS.mjs +9 -0
  337. package/dist/chunk-GB5SOYQJ.mjs +7 -0
  338. package/dist/chunk-GRAXKKG4.mjs +2 -0
  339. package/dist/chunk-HYMEEXKN.mjs +4 -0
  340. package/dist/chunk-IVDLMMBD.mjs +2 -0
  341. package/dist/chunk-JPOSLGOC.mjs +6 -0
  342. package/dist/chunk-JVHHHGEA.mjs +3 -0
  343. package/dist/chunk-L3QKH4OK.mjs +26 -0
  344. package/dist/chunk-LAE5NQ4B.mjs +2 -0
  345. package/dist/chunk-LCTHTZIL.mjs +960 -0
  346. package/dist/chunk-LEF6DRCK.mjs +59 -0
  347. package/dist/chunk-LKX55H76.mjs +2 -0
  348. package/dist/chunk-LS4F7JUM.mjs +2 -0
  349. package/dist/chunk-MAFIGVXY.mjs +2 -0
  350. package/dist/chunk-NO5NJCHO.mjs +2 -0
  351. package/dist/chunk-NQPVAU63.mjs +2 -0
  352. package/dist/chunk-NSKUTQ5J.mjs +5 -0
  353. package/dist/chunk-O35FIXRB.mjs +2 -0
  354. package/dist/chunk-P2CAZPDP.mjs +3 -0
  355. package/dist/chunk-PL6GHLGD.mjs +15 -0
  356. package/dist/chunk-QAIHRH3I.mjs +13 -0
  357. package/dist/chunk-QJIR2BLP.mjs +6 -0
  358. package/dist/chunk-QR6A54KJ.mjs +3 -0
  359. package/dist/chunk-QUPLVPB2.mjs +7 -0
  360. package/dist/chunk-R7BNENLY.mjs +4 -0
  361. package/dist/chunk-S6O4UHLC.mjs +2 -0
  362. package/dist/chunk-SGJWQKEI.mjs +2 -0
  363. package/dist/chunk-SYGN7GLU.mjs +2 -0
  364. package/dist/chunk-TMYZB6AV.mjs +2 -0
  365. package/dist/chunk-TX6JH7TR.mjs +2 -0
  366. package/dist/chunk-TYK6VNAB.mjs +10 -0
  367. package/dist/chunk-U3SSPL4K.mjs +8 -0
  368. package/dist/chunk-U6KNPJPR.mjs +2 -0
  369. package/dist/chunk-UALRNVSE.mjs +4 -0
  370. package/dist/chunk-UH4SIXTR.mjs +2 -0
  371. package/dist/chunk-UMHUSOPJ.mjs +2 -0
  372. package/dist/chunk-V3HXVQEM.mjs +2 -0
  373. package/dist/chunk-V5JTW2LH.mjs +27 -0
  374. package/dist/chunk-V5VXUJKG.mjs +2 -0
  375. package/dist/chunk-V6XZ4VIR.mjs +2 -0
  376. package/dist/chunk-VBXMADMP.mjs +2 -0
  377. package/dist/chunk-VNV55RUA.mjs +2 -0
  378. package/dist/chunk-VPD2PS35.mjs +2 -0
  379. package/dist/chunk-W3BGBJQW.mjs +2 -0
  380. package/dist/chunk-W4VKN3GF.mjs +7 -0
  381. package/dist/chunk-W5BXXPDJ.mjs +3 -0
  382. package/dist/chunk-W7XHE4CT.mjs +2 -0
  383. package/dist/chunk-XNROSH2T.mjs +4 -0
  384. package/dist/chunk-XUNHRCOG.mjs +6 -0
  385. package/dist/chunk-Y34NR5JL.mjs +2 -0
  386. package/dist/chunk-Y6RLRPG3.mjs +3 -0
  387. package/dist/chunk-YEY3RSFQ.mjs +2 -0
  388. package/dist/cli.mjs +2 -0
  389. package/dist/server.mjs +2 -0
  390. package/dist/worker.mjs +5 -0
  391. package/kit/charts.js +355 -0
  392. package/kit/code.js +164 -0
  393. package/kit/dialogs.js +157 -0
  394. package/kit/math.js +2004 -0
  395. package/kit/report.css +2932 -0
  396. package/kit/runtime.js +1782 -0
  397. package/kit/sheets.js +123 -0
  398. package/kit/state.js +217 -0
  399. package/kit/tables.js +1499 -0
  400. package/kit/tokens.js +29 -0
  401. package/kit/ui.js +658 -0
  402. package/package.json +41 -4
  403. package/release.json +25 -0
  404. package/sdk/column-widths.d.ts +56 -0
  405. package/sdk/doc-charts.d.ts +82 -0
  406. package/sdk/doc-code.d.ts +28 -0
  407. package/sdk/doc-dialogs.d.ts +4 -0
  408. package/sdk/doc-kit.d.ts +147 -0
  409. package/sdk/doc-math.d.ts +3 -0
  410. package/sdk/doc-sheets.d.ts +15 -0
  411. package/sdk/doc-state.d.ts +41 -0
  412. package/sdk/doc-tables.d.ts +24 -0
  413. package/sdk/doc-tokens.d.ts +22 -0
  414. package/sdk/index.d.ts +30 -0
  415. package/skill/SKILL.md +150 -0
  416. package/skill/agents/openai.yaml +5 -0
  417. package/skill/references/building-components.md +367 -0
  418. package/skill/references/example-report.html +356 -0
  419. package/skill/references/writing-html.md +187 -0
  420. package/skill/sdk/column-widths.d.ts +56 -0
  421. package/skill/sdk/doc-charts.d.ts +82 -0
  422. package/skill/sdk/doc-code.d.ts +28 -0
  423. package/skill/sdk/doc-dialogs.d.ts +4 -0
  424. package/skill/sdk/doc-kit.d.ts +147 -0
  425. package/skill/sdk/doc-math.d.ts +3 -0
  426. package/skill/sdk/doc-sheets.d.ts +15 -0
  427. package/skill/sdk/doc-state.d.ts +41 -0
  428. package/skill/sdk/doc-tables.d.ts +24 -0
  429. package/skill/sdk/doc-tokens.d.ts +22 -0
  430. package/skill/sdk/index.d.ts +30 -0
  431. package/starter/doc.html +21 -0
  432. package/starter/doc.json +5 -0
  433. package/vendor/d3.v7.9.0.min.js +2 -0
  434. package/vendor/katex/auto-render.min.js +1 -0
  435. package/vendor/katex/contrib/mhchem.min.js +1 -0
  436. package/vendor/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  437. package/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  438. package/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  439. package/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  440. package/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  441. package/vendor/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  442. package/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  443. package/vendor/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  444. package/vendor/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  445. package/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  446. package/vendor/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  447. package/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  448. package/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  449. package/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  450. package/vendor/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  451. package/vendor/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  452. package/vendor/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  453. package/vendor/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  454. package/vendor/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  455. package/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  456. package/vendor/katex/katex.min.css +1 -0
  457. package/vendor/katex/katex.min.js +1 -0
  458. package/vendor/pdfjs/LICENSE +177 -0
  459. package/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  460. package/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  461. package/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  462. package/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  463. package/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  464. package/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  465. package/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  466. package/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  467. package/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  468. package/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  469. package/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  470. package/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  471. package/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  472. package/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  473. package/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  474. package/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  475. package/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  476. package/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  477. package/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  478. package/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  479. package/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  480. package/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  481. package/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  482. package/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  483. package/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  484. package/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  485. package/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  486. package/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  487. package/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  488. package/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  489. package/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  490. package/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  491. package/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  492. package/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  493. package/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  494. package/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  495. package/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  496. package/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  497. package/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  498. package/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  499. package/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  500. package/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  501. package/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  502. package/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  503. package/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  504. package/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  505. package/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  506. package/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  507. package/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  508. package/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  509. package/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  510. package/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  511. package/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  512. package/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  513. package/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  514. package/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  515. package/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  516. package/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  517. package/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  518. package/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  519. package/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  520. package/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  521. package/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  522. package/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  523. package/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  524. package/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  525. package/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  526. package/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  527. package/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  528. package/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  529. package/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
  530. package/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  531. package/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  532. package/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  533. package/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  534. package/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  535. package/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  536. package/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  537. package/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  538. package/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  539. package/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  540. package/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  541. package/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  542. package/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  543. package/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  544. package/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  545. package/vendor/pdfjs/cmaps/H.bcmap +0 -0
  546. package/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  547. package/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  548. package/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  549. package/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  550. package/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  551. package/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  552. package/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  553. package/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  554. package/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  555. package/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  556. package/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  557. package/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  558. package/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  559. package/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  560. package/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  561. package/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  562. package/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  563. package/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  564. package/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  565. package/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  566. package/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  567. package/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  568. package/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  569. package/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  570. package/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  571. package/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  572. package/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  573. package/vendor/pdfjs/cmaps/LICENSE +36 -0
  574. package/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  575. package/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  576. package/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  577. package/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  578. package/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  579. package/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  580. package/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  581. package/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  582. package/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  583. package/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  584. package/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  585. package/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  586. package/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  587. package/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  588. package/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  589. package/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  590. package/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  591. package/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  592. package/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  593. package/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  594. package/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  595. package/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  596. package/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  597. package/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  598. package/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  599. package/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  600. package/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  601. package/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  602. package/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  603. package/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  604. package/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  605. package/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  606. package/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  607. package/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  608. package/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  609. package/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  610. package/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  611. package/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  612. package/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  613. package/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  614. package/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  615. package/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  616. package/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  617. package/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  618. package/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  619. package/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  620. package/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  621. package/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  622. package/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  623. package/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  624. package/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  625. package/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  626. package/vendor/pdfjs/cmaps/V.bcmap +0 -0
  627. package/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  628. package/vendor/pdfjs/legacy/build/pdf.min.mjs +27 -0
  629. package/vendor/pdfjs/legacy/build/pdf.worker.min.mjs +27 -0
  630. package/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  631. package/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  632. package/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  633. package/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  634. package/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  635. package/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  636. package/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  637. package/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  638. package/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  639. package/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  640. package/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  641. package/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  642. package/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  643. package/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  644. package/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  645. package/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  646. package/vendor/types/@types/d3/LICENSE +21 -0
  647. package/vendor/types/@types/d3/index.d.ts +39 -0
  648. package/vendor/types/@types/d3/package.json +81 -0
  649. package/vendor/types/@types/d3-array/LICENSE +21 -0
  650. package/vendor/types/@types/d3-array/index.d.ts +1118 -0
  651. package/vendor/types/@types/d3-array/package.json +56 -0
  652. package/vendor/types/@types/d3-axis/LICENSE +21 -0
  653. package/vendor/types/@types/d3-axis/index.d.ts +293 -0
  654. package/vendor/types/@types/d3-axis/package.json +47 -0
  655. package/vendor/types/@types/d3-brush/LICENSE +21 -0
  656. package/vendor/types/@types/d3-brush/index.d.ts +255 -0
  657. package/vendor/types/@types/d3-brush/package.json +42 -0
  658. package/vendor/types/@types/d3-chord/LICENSE +21 -0
  659. package/vendor/types/@types/d3-chord/index.d.ts +471 -0
  660. package/vendor/types/@types/d3-chord/package.json +40 -0
  661. package/vendor/types/@types/d3-color/LICENSE +21 -0
  662. package/vendor/types/@types/d3-color/index.d.ts +669 -0
  663. package/vendor/types/@types/d3-color/package.json +55 -0
  664. package/vendor/types/@types/d3-contour/LICENSE +21 -0
  665. package/vendor/types/@types/d3-contour/index.d.ts +222 -0
  666. package/vendor/types/@types/d3-contour/package.json +38 -0
  667. package/vendor/types/@types/d3-delaunay/LICENSE +21 -0
  668. package/vendor/types/@types/d3-delaunay/index.d.ts +316 -0
  669. package/vendor/types/@types/d3-delaunay/package.json +30 -0
  670. package/vendor/types/@types/d3-dispatch/LICENSE +21 -0
  671. package/vendor/types/@types/d3-dispatch/index.d.ts +96 -0
  672. package/vendor/types/@types/d3-dispatch/package.json +51 -0
  673. package/vendor/types/@types/d3-drag/LICENSE +21 -0
  674. package/vendor/types/@types/d3-drag/index.d.ts +395 -0
  675. package/vendor/types/@types/d3-drag/package.json +42 -0
  676. package/vendor/types/@types/d3-dsv/LICENSE +21 -0
  677. package/vendor/types/@types/d3-dsv/index.d.ts +482 -0
  678. package/vendor/types/@types/d3-dsv/package.json +45 -0
  679. package/vendor/types/@types/d3-ease/LICENSE +21 -0
  680. package/vendor/types/@types/d3-ease/index.d.ts +316 -0
  681. package/vendor/types/@types/d3-ease/package.json +40 -0
  682. package/vendor/types/@types/d3-fetch/LICENSE +21 -0
  683. package/vendor/types/@types/d3-fetch/index.d.ts +282 -0
  684. package/vendor/types/@types/d3-fetch/package.json +37 -0
  685. package/vendor/types/@types/d3-force/LICENSE +21 -0
  686. package/vendor/types/@types/d3-force/index.d.ts +899 -0
  687. package/vendor/types/@types/d3-force/package.json +45 -0
  688. package/vendor/types/@types/d3-format/LICENSE +21 -0
  689. package/vendor/types/@types/d3-format/index.d.ts +337 -0
  690. package/vendor/types/@types/d3-format/package.json +45 -0
  691. package/vendor/types/@types/d3-geo/LICENSE +21 -0
  692. package/vendor/types/@types/d3-geo/index.d.ts +1371 -0
  693. package/vendor/types/@types/d3-geo/package.json +48 -0
  694. package/vendor/types/@types/d3-hierarchy/LICENSE +21 -0
  695. package/vendor/types/@types/d3-hierarchy/index.d.ts +928 -0
  696. package/vendor/types/@types/d3-hierarchy/package.json +50 -0
  697. package/vendor/types/@types/d3-interpolate/LICENSE +21 -0
  698. package/vendor/types/@types/d3-interpolate/index.d.ts +387 -0
  699. package/vendor/types/@types/d3-interpolate/package.json +47 -0
  700. package/vendor/types/@types/d3-path/LICENSE +21 -0
  701. package/vendor/types/@types/d3-path/index.d.ts +108 -0
  702. package/vendor/types/@types/d3-path/package.json +41 -0
  703. package/vendor/types/@types/d3-polygon/LICENSE +21 -0
  704. package/vendor/types/@types/d3-polygon/index.d.ts +41 -0
  705. package/vendor/types/@types/d3-polygon/package.json +40 -0
  706. package/vendor/types/@types/d3-quadtree/LICENSE +21 -0
  707. package/vendor/types/@types/d3-quadtree/index.d.ts +204 -0
  708. package/vendor/types/@types/d3-quadtree/package.json +45 -0
  709. package/vendor/types/@types/d3-random/LICENSE +21 -0
  710. package/vendor/types/@types/d3-random/index.d.ts +313 -0
  711. package/vendor/types/@types/d3-random/package.json +41 -0
  712. package/vendor/types/@types/d3-scale/LICENSE +21 -0
  713. package/vendor/types/@types/d3-scale/index.d.ts +2669 -0
  714. package/vendor/types/@types/d3-scale/package.json +53 -0
  715. package/vendor/types/@types/d3-scale-chromatic/LICENSE +21 -0
  716. package/vendor/types/@types/d3-scale-chromatic/index.d.ts +520 -0
  717. package/vendor/types/@types/d3-scale-chromatic/package.json +46 -0
  718. package/vendor/types/@types/d3-selection/LICENSE +21 -0
  719. package/vendor/types/@types/d3-selection/index.d.ts +1210 -0
  720. package/vendor/types/@types/d3-selection/package.json +56 -0
  721. package/vendor/types/@types/d3-shape/LICENSE +21 -0
  722. package/vendor/types/@types/d3-shape/index.d.ts +2792 -0
  723. package/vendor/types/@types/d3-shape/package.json +53 -0
  724. package/vendor/types/@types/d3-time/LICENSE +21 -0
  725. package/vendor/types/@types/d3-time/index.d.ts +697 -0
  726. package/vendor/types/@types/d3-time/package.json +46 -0
  727. package/vendor/types/@types/d3-time-format/LICENSE +21 -0
  728. package/vendor/types/@types/d3-time-format/index.d.ts +202 -0
  729. package/vendor/types/@types/d3-time-format/package.json +40 -0
  730. package/vendor/types/@types/d3-timer/LICENSE +21 -0
  731. package/vendor/types/@types/d3-timer/index.d.ts +68 -0
  732. package/vendor/types/@types/d3-timer/package.json +45 -0
  733. package/vendor/types/@types/d3-transition/LICENSE +21 -0
  734. package/vendor/types/@types/d3-transition/index.d.ts +664 -0
  735. package/vendor/types/@types/d3-transition/package.json +47 -0
  736. package/vendor/types/@types/d3-zoom/LICENSE +21 -0
  737. package/vendor/types/@types/d3-zoom/index.d.ts +611 -0
  738. package/vendor/types/@types/d3-zoom/package.json +48 -0
  739. package/vendor/types/@types/geojson/LICENSE +21 -0
  740. package/vendor/types/@types/geojson/index.d.ts +202 -0
  741. package/vendor/types/@types/geojson/package.json +46 -0
  742. package/vendor/typescript/LICENSE.txt +55 -0
  743. package/vendor/typescript/lib.decorators.d.ts +384 -0
  744. package/vendor/typescript/lib.decorators.legacy.d.ts +22 -0
  745. package/vendor/typescript/lib.dom.d.ts +39429 -0
  746. package/vendor/typescript/lib.dom.iterable.d.ts +571 -0
  747. package/vendor/typescript/lib.es2015.collection.d.ts +147 -0
  748. package/vendor/typescript/lib.es2015.core.d.ts +597 -0
  749. package/vendor/typescript/lib.es2015.d.ts +28 -0
  750. package/vendor/typescript/lib.es2015.generator.d.ts +77 -0
  751. package/vendor/typescript/lib.es2015.iterable.d.ts +605 -0
  752. package/vendor/typescript/lib.es2015.promise.d.ts +81 -0
  753. package/vendor/typescript/lib.es2015.proxy.d.ts +128 -0
  754. package/vendor/typescript/lib.es2015.reflect.d.ts +144 -0
  755. package/vendor/typescript/lib.es2015.symbol.d.ts +46 -0
  756. package/vendor/typescript/lib.es2015.symbol.wellknown.d.ts +326 -0
  757. package/vendor/typescript/lib.es2016.array.include.d.ts +116 -0
  758. package/vendor/typescript/lib.es2016.d.ts +21 -0
  759. package/vendor/typescript/lib.es2016.intl.d.ts +31 -0
  760. package/vendor/typescript/lib.es2017.arraybuffer.d.ts +21 -0
  761. package/vendor/typescript/lib.es2017.d.ts +26 -0
  762. package/vendor/typescript/lib.es2017.date.d.ts +31 -0
  763. package/vendor/typescript/lib.es2017.intl.d.ts +44 -0
  764. package/vendor/typescript/lib.es2017.object.d.ts +49 -0
  765. package/vendor/typescript/lib.es2017.sharedmemory.d.ts +135 -0
  766. package/vendor/typescript/lib.es2017.string.d.ts +45 -0
  767. package/vendor/typescript/lib.es2017.typedarrays.d.ts +53 -0
  768. package/vendor/typescript/lib.es2018.asyncgenerator.d.ts +77 -0
  769. package/vendor/typescript/lib.es2018.asynciterable.d.ts +53 -0
  770. package/vendor/typescript/lib.es2018.d.ts +24 -0
  771. package/vendor/typescript/lib.es2018.intl.d.ts +83 -0
  772. package/vendor/typescript/lib.es2018.promise.d.ts +30 -0
  773. package/vendor/typescript/lib.es2018.regexp.d.ts +37 -0
  774. package/vendor/typescript/lib.es2019.array.d.ts +79 -0
  775. package/vendor/typescript/lib.es2019.d.ts +24 -0
  776. package/vendor/typescript/lib.es2019.intl.d.ts +23 -0
  777. package/vendor/typescript/lib.es2019.object.d.ts +33 -0
  778. package/vendor/typescript/lib.es2019.string.d.ts +37 -0
  779. package/vendor/typescript/lib.es2019.symbol.d.ts +24 -0
  780. package/vendor/typescript/lib.es2020.bigint.d.ts +765 -0
  781. package/vendor/typescript/lib.es2020.d.ts +27 -0
  782. package/vendor/typescript/lib.es2020.date.d.ts +42 -0
  783. package/vendor/typescript/lib.es2020.intl.d.ts +474 -0
  784. package/vendor/typescript/lib.es2020.number.d.ts +28 -0
  785. package/vendor/typescript/lib.es2020.promise.d.ts +47 -0
  786. package/vendor/typescript/lib.es2020.sharedmemory.d.ts +99 -0
  787. package/vendor/typescript/lib.es2020.string.d.ts +44 -0
  788. package/vendor/typescript/lib.es2020.symbol.wellknown.d.ts +41 -0
  789. package/vendor/typescript/lib.es2021.d.ts +23 -0
  790. package/vendor/typescript/lib.es2021.intl.d.ts +166 -0
  791. package/vendor/typescript/lib.es2021.promise.d.ts +48 -0
  792. package/vendor/typescript/lib.es2021.string.d.ts +33 -0
  793. package/vendor/typescript/lib.es2021.weakref.d.ts +78 -0
  794. package/vendor/typescript/lib.es2022.array.d.ts +121 -0
  795. package/vendor/typescript/lib.es2022.d.ts +25 -0
  796. package/vendor/typescript/lib.es2022.error.d.ts +75 -0
  797. package/vendor/typescript/lib.es2022.intl.d.ts +145 -0
  798. package/vendor/typescript/lib.es2022.object.d.ts +26 -0
  799. package/vendor/typescript/lib.es2022.regexp.d.ts +39 -0
  800. package/vendor/typescript/lib.es2022.string.d.ts +25 -0
  801. package/vendor/typescript/lib.es5.d.ts +4601 -0
  802. package/vendor/typescript/package.json +4 -0
  803. package/vendor/typescript/typescript.js +446 -0
  804. package/web/assets/index-Bh74DfsV.css +1 -0
  805. package/web/assets/index-UW0RyFFt.js +13 -0
  806. package/web/index.html +14 -0
@@ -0,0 +1,30 @@
1
+ // The number a code block's first line shows, written once: the kit's code.js numbers its lines from
2
+ // it in the reading view, the page editor in its line numbers' column, and the export takes it in
3
+ // from what an Agent writes (src/editor/source/natural.mjs: data-line-start, or Prism's data-start).
4
+ // An excerpt of a file shows the file's own numbers so: data-line-start="38" numbers its lines 38,
5
+ // 39 … Its folded lines (data-folded-lines) are counted in the block, from 1, whatever it shows.
6
+
7
+ /** The class of a code block (div.doc-code) whose long lines scroll, each on one line. */
8
+ export const NOWRAP = "doc-code--nowrap";
9
+
10
+ /** The attribute on a code block that says the lines whose structure is folded: their numbers (1-based), ascending, spaces between. */
11
+ export const FOLDED_LINES = "data-folded-lines";
12
+ const FOLDED_NUMBERS = /^[1-9]\d{0,5}( [1-9]\d{0,5}){0,499}$/;
13
+
14
+ /** Whether a value is folded lines as data-folded-lines takes them. */
15
+ export const validFolded = (value) => typeof value === "string" && FOLDED_NUMBERS.test(value);
16
+
17
+ /** The attribute on a code block (div.doc-code) that numbers its first line. */
18
+ export const LINE_START = "data-line-start";
19
+
20
+ /**
21
+ * A first line's number as an attribute writes it: a whole number from 1 (six digits at most, zeros
22
+ * before them as a file's listing may pad it: 038), blanks around it.
23
+ */
24
+ const NUMBER = /^\s*0*([1-9]\d{0,5})\s*$/;
25
+
26
+ /** The number a value of data-line-start gives the first line, or null when it gives none (1 then). */
27
+ export function lineStart(value) {
28
+ const found = NUMBER.exec(value ?? "");
29
+ return found ? Number(found[1]) : null;
30
+ }
@@ -0,0 +1,30 @@
1
+ // The kit's nine colors (Notion's text and background colors, light and dark), written once: their
2
+ // names, what the reader calls them and their values (a text color, a block's fill and the deeper
3
+ // fill of words in a line). The kit's stylesheets (render/kit/styles/
4
+ // base.css: .doc-text-* and .doc-highlight-*, tokens.css) are written by hand, as CSS is;
5
+ // tests/unit/clipboard.mjs holds them to these values. Everything else that needs a value reads it
6
+ // here: the editor's color pickers (names), pasted colors matched onto the nine (clipboard/import/
7
+ // colors.mjs) and the colors a copy carries to other programs (clipboard/own/export.mjs).
8
+
9
+ /**
10
+ * Each color in Notion's order: `name` (the classes are doc-text-<name> and doc-highlight-
11
+ * <name>), `label` (what the reader calls it), and its text color, its background as a block's
12
+ * (`fill`, base.css's --doc-fill) and its background on words in a line (`mark`, base.css's
13
+ * --doc-mark, deeper than the fill) as [light, dark].
14
+ */
15
+ export const COLORS = [
16
+ { name: "gray", label: "灰色", text: ["#6e6e73", "#a1a1a6"], fill: ["#f0efed", "#383836"], mark: ["#e0dfdd", "#454542"] },
17
+ { name: "brown", label: "棕色", text: ["#9f765a", "#ba856f"], fill: ["#f5ede9", "#45362d"], mark: ["#efdbce", "#534034"] },
18
+ { name: "orange", label: "橙色", text: ["#d27b2d", "#c77d48"], fill: ["#fbebde", "#53361f"], mark: ["#fbddc5", "#654025"] },
19
+ { name: "yellow", label: "黄色", text: ["#cb9434", "#ca9849"], fill: ["#f9f3dc", "#504425"], mark: ["#f8eab6", "#614f26"] },
20
+ { name: "green", label: "绿色", text: ["#50946e", "#529e72"], fill: ["#e8f1ec", "#263d30"], mark: ["#cfead9", "#2c4b3a"] },
21
+ { name: "blue", label: "蓝色", text: ["#387dc9", "#5e87c9"], fill: ["#e5f2fc", "#233850"], mark: ["#cde5fb", "#294564"] },
22
+ { name: "purple", label: "紫色", text: ["#9a6bb4", "#9d68d3"], fill: ["#f3ebf9", "#3c2d47"], mark: ["#ebdaf6", "#4b3859"] },
23
+ { name: "pink", label: "粉色", text: ["#c14c8a", "#d15796"], fill: ["#fae9f1", "#4e2b3c"], mark: ["#f8d7e6", "#5d3548"] },
24
+ { name: "red", label: "红色", text: ["#cf5148", "#df5452"], fill: ["#fce9e7", "#502c29"], mark: ["#fed7d1", "#663632"] },
25
+ ];
26
+
27
+ export const COLOR_NAMES = COLORS.map(({ name }) => name);
28
+
29
+ /** The page's own text color and background (tokens.css --doc-text, --doc-surface) as [light, dark]: what no color is. */
30
+ export const BODY = { text: ["#2c2c2b", "#f3f3f3"], background: ["#ffffff", "#202020"] };
@@ -0,0 +1,573 @@
1
+ import { isUtf8 } from "node:buffer";
2
+ import { createHash } from "node:crypto";
3
+ import { lstatSync, readFileSync, realpathSync, statSync } from "node:fs";
4
+ import fs from "node:fs/promises";
5
+ import path from "node:path";
6
+ import { parseFragment, serializeOuter } from "parse5";
7
+ import { isInstance, parseCompound, parsePart, parseSelector, partOf } from "./components/index.mjs";
8
+ import { ATTRIBUTE, NO_TEXT, PACKAGE_ID, PACKAGE_MARK, SLOT, instanceMatch, refusedInCopy, settingState } from "./components/installed.mjs";
9
+ import { writeAtomic } from "./files.mjs";
10
+ import { attr, walk } from "./html-tree.mjs";
11
+ import { inLanguage, refusal, said, saying, told } from "./i18n/index.mjs";
12
+ import { DEVICE_NAMES, PACKAGE_MANIFEST, WORKSPACE_MARK, findWorkspace, layoutOf, markerOf, packageFolders } from "./workspace.mjs";
13
+
14
+ // 组件包: what the workspace's component packages say of themselves to Gallery, read from
15
+ // <workspace>/components/<scope>/<name>/component.json, plain data, whose code no system runs here. A
16
+ // package is a description as a kit component's is (src/shared/components/): its id, where its
17
+ // instances are, its parts and what it leaves on a page, so that what reads a built-in's reads a
18
+ // package's: the scan and the checks here, the kit on the page by DocKit.describe, the same object.
19
+ // A manifest offers only FIELDS, no unit, box, host, rank or category: those are the engines', and a
20
+ // field it does not know keeps its package from loading.
21
+ //
22
+ // The catalog is { packages, problems, settings, stamp }. `packages`, by id, are those that load. A
23
+ // package that does not load (a manifest that does not read as one, one for an apiVersion this Gallery
24
+ // does not run, which counts as disabled, or one the settings turned off) stands in `problems`, by its
25
+ // id in lowercase, as an instance names it, with why (`problem`, said()'s, in either language by
26
+ // problemIn), and touches nothing else: its instances show as those of a package that is not there,
27
+ // and whoever reads them says why. `settings` is what gallery.json says of the components (设置 › 组件列表,
28
+ // componentSettings): `hidden` and `disabled`, by the id of a package or the name of a built-in
29
+ // component, and `problem` where the file cannot be read as saying anything (settingsNow). A package
30
+ // hidden runs as any other and is left out of the lists that offer one, each of which reads its state
31
+ // (menuOf, packageStates); one disabled is one that does not load, so that nothing that loads a
32
+ // package has a case for it. A stamp is a hash of what files hold: `stamp`, of a package, over what
33
+ // reaches a page of it (STAMPED and the files `assets` names), of one that does not load over those
34
+ // and why, and of the catalog, over its packages', what is hidden and whether gallery.json reads;
35
+ // `definition`, over the manifest alone, is what a page's commit is to be held to.
36
+ //
37
+ // readCatalog reads the disk; what reads a catalog for use (the scan, the checks, a page) asks
38
+ // currentCatalog, which reads it once a process and keeps it: a command's or a job's life is short,
39
+ // and the server's watcher (src/server/catalog-watch.mjs) puts a new one in its place. This file runs
40
+ // on the server alone (no page imports it): the workspace it reads is the one GALLERY_WORKSPACE names
41
+ // at each read, as the gallery command and the tests set it.
42
+
43
+ /** The apiVersion this Gallery runs. */
44
+ export const API_VERSION = 1;
45
+
46
+ /** The kit's files a package may ask for by id in `assets`, as src/render/assets.mjs names them (the others are on every page). */
47
+ export const KIT_ASSETS = new Set(["code", "state", "sheets", "tokens", "dialogs", "katex-styles", "katex", "katex-auto-render", "math", "d3", "charts", "tables"]);
48
+
49
+ // What a manifest may hold, a part of one and its `runtime`.
50
+ const FIELDS = ["id", "apiVersion", "version", "name", "description", "words", "parts", "runtime", "assets", "markdown", "schema"];
51
+ const PART_FIELDS = ["at", "edit", "optional", "min", "max"];
52
+ const RUNTIME_FIELDS = ["generated", "attrs"];
53
+
54
+ // What a package's part may be edited as: its text, its data through the kit's edit, the document's
55
+ // blocks (a slot, marked data-doc-slot="<name>" in its markup), or not at all.
56
+ const EDITS = ["text", "data", "flow", "none"];
57
+ // What a slot's name may be: it is written in an attribute's value, and a selector finds it there.
58
+ const SLOT_NAME = /^[a-z][a-z0-9-]*$/;
59
+ /** Where a part edited as flow is in an instance: the slot of its name. */
60
+ export const slotAt = (name) => `div[${SLOT}="${name}"], section[${SLOT}="${name}"]`;
61
+ // A manifest's parts as the engines read them: a slot's `at` is its mark, which the manifest does not write.
62
+ const partsRead = (parts) => Object.fromEntries(Object.entries(parts).map(([name, part]) => [name, part.edit === "flow" ? { ...part, at: slotAt(name) } : part]));
63
+ const MARKDOWN = ["parts", "text"];
64
+
65
+ // The files of a package by their fixed names: those served from its folder (kit.js and style.css are
66
+ // the page's that uses it, preview.svg the menu's), and with them what a stamp reads.
67
+ // example.html and writing.md are for who writes with it, and reach no page: a change of them is no
68
+ // change of the catalog, which every open page hears.
69
+ const SERVED = ["kit.js", "style.css", "preview.svg"];
70
+ const TEMPLATE = "template.html";
71
+ const STAMPED = [PACKAGE_MANIFEST, TEMPLATE, ...SERVED];
72
+ // What a package's stamp reads, its `files` being what `assets` named besides.
73
+ const stamped = (files) => [...new Set([...STAMPED, ...files])].sort();
74
+
75
+ // A file of the package's own that `assets` names: a relative path of plain names, with an extension.
76
+ const OWN_FILE = /^(?:[A-Za-z0-9_-][A-Za-z0-9._-]*\/)*[A-Za-z0-9_-][A-Za-z0-9._-]*\.[A-Za-z0-9]+$/;
77
+ // What Gallery and the kit mark a page with, which no package sets or takes off, in any case, as HTML
78
+ // reads an attribute's name.
79
+ const OWN_NAME = /^(?:doc-|data-doc-|data-ge-)|^data-block-id$/i;
80
+ // What every page of the workspace holds of a package, whichever it uses: its manifest's words and
81
+ // its template are in each page's map.
82
+ const ON_EVERY_PAGE = 256 * 1024;
83
+
84
+ const isTable = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
85
+ const isWords = (value) => typeof value === "string" && value.trim() !== "";
86
+ const byId = (a, b) => (a.id < b.id ? -1 : 1);
87
+ const fail = (message) => {
88
+ throw refusal(message);
89
+ };
90
+ const hashOf = (write) => {
91
+ const hash = createHash("sha256");
92
+ write(hash);
93
+ return hash.digest("hex").slice(0, 16);
94
+ };
95
+
96
+ /** Where a file of the package's folder is, or null: none there, or a link that leads out of it. */
97
+ function ownPath(folder, name) {
98
+ const found = path.join(folder, name);
99
+ try {
100
+ const stat = lstatSync(found, { throwIfNoEntry: false });
101
+ if (!stat) return null;
102
+ if (!stat.isSymbolicLink() && !name.includes("/")) return found; // right in it: no walk through the path
103
+ const real = realpathSync.native(found);
104
+ return real.startsWith(realpathSync.native(folder) + path.sep) ? real : null;
105
+ } catch {
106
+ return null;
107
+ }
108
+ }
109
+
110
+ /** The bytes of a file of the package's folder, or null. */
111
+ function ownFile(folder, name) {
112
+ try {
113
+ const real = ownPath(folder, name);
114
+ return real && readFileSync(real);
115
+ } catch {
116
+ return null;
117
+ }
118
+ }
119
+
120
+ // What a file holds, as a hash kept by its size and its time, so that a look over a package read a
121
+ // moment ago reads none of it again, however large (a font, a file of data). A file written this very
122
+ // moment is read each time: the write that comes next can carry the same size and time.
123
+ const digests = new Map(); // a file's path -> { size, time, digest }
124
+ const SETTLED = 2000;
125
+ function digestOf(real) {
126
+ const { size, mtimeMs } = statSync(real);
127
+ const known = digests.get(real);
128
+ if (known?.size === size && known.time === mtimeMs) return known.digest;
129
+ const digest = hashOf((hash) => hash.update(readFileSync(real)));
130
+ if (Date.now() - mtimeMs > SETTLED) digests.set(real, { size, time: mtimeMs, digest });
131
+ return digest;
132
+ }
133
+
134
+ const stampOf = (folder, names) => hashOf((hash) => {
135
+ for (const name of names) {
136
+ const real = ownPath(folder, name);
137
+ let digest = "none"; // no such file, or one gone between the two
138
+ try {
139
+ if (real) digest = digestOf(real);
140
+ } catch {}
141
+ hash.update(`${name}\u0000${digest}\n`);
142
+ }
143
+ });
144
+
145
+ // A file's words, no byte-order mark, which an editor on Windows may write.
146
+ const wordsOf = (bytes) => bytes.toString("utf8").replace(/^\uFEFF/, "");
147
+ const notTooLong = (bytes, name) => {
148
+ if (bytes.length > ON_EVERY_PAGE) fail(said("{0} 有 {1} KB,而每一页都带着它,最多 {2} KB", name, Math.ceil(bytes.length / 1024), ON_EVERY_PAGE / 1024));
149
+ };
150
+
151
+ const onlyFields = (table, fields, where = "") => {
152
+ for (const key of Object.keys(table)) if (!fields.includes(key)) fail(said("{0} 不是组件包能写的字段", `${where}${key}`));
153
+ };
154
+ const required = (manifest, fields) => {
155
+ for (const field of fields) if (manifest[field] === undefined) fail(said("缺少 {0}", field));
156
+ };
157
+ const bothLanguages = (value, field) => {
158
+ if (!isTable(value) || !isWords(value.zh) || !isWords(value.en) || Object.keys(value).length !== 2) fail(said("{0} 要写成 { zh, en } 两种语言的文字", field));
159
+ };
160
+
161
+ // The tags a part's `at` ends on, where it names one.
162
+ const tailTags = (at) => at.split(",").map((piece) => piece.split(">").at(-1).trim()).filter((step) => step !== "*").map((step) => parseCompound(step).tag);
163
+
164
+ function checkPart(name, part) {
165
+ const where = `parts.${name}`;
166
+ if (!isTable(part)) fail(said("{0} 要写成一张表", where));
167
+ onlyFields(part, PART_FIELDS, `${where}.`);
168
+ if (part.edit === "flow") {
169
+ // A slot: found by its mark, one to an instance.
170
+ if (!SLOT_NAME.test(name)) fail(said("{0} 是插槽,名字只用小写字母、数字和连字符", where));
171
+ if (part.at !== undefined) fail(said("{0} 是插槽,由 data-doc-slot=\"{1}\" 标出,不写 at", where, name));
172
+ if (part.min !== undefined || part.max !== undefined) fail(said("{0} 是插槽,一个实例里只有一个,不写 min、max", where));
173
+ if (part.optional !== undefined && typeof part.optional !== "boolean") fail(said("{0} 要写成 true 或 false", `${where}.optional`));
174
+ return;
175
+ }
176
+ if (!isWords(part.at)) fail(said("缺少 {0}", `${where}.at`));
177
+ try {
178
+ parsePart(part.at);
179
+ } catch (error) {
180
+ fail(said("{0} 写错了:{1}", `${where}.at`, error.message));
181
+ }
182
+ if (!EDITS.includes(part.edit)) fail(said("{0} 的 edit 只能是 text、data、flow 或 none", where));
183
+ if (part.optional !== undefined && typeof part.optional !== "boolean") fail(said("{0} 要写成 true 或 false", `${where}.optional`));
184
+ for (const bound of ["min", "max"]) if (part[bound] !== undefined && !(Number.isInteger(part[bound]) && part[bound] >= 0)) fail(said("{0} 要写成不小于 0 的整数", `${where}.${bound}`));
185
+ if (part.min > part.max) fail(said("{0} 的 min 比 max 大,没有实例能满足", where));
186
+ if (part.edit === "text") for (const tag of tailTags(part.at)) if (NO_TEXT.has(tag)) fail(said("{0} 不能按文字编辑:<{1}> 不是能打字的文字", where, tag));
187
+ }
188
+
189
+ // Whether a selector takes the instance itself, or all it holds: what a copy of the view would lose with it.
190
+ const takesAll = (selector) => selector.split(",").some((one) => one.split(">").every((step) => [":scope", "*"].includes(step.trim())));
191
+
192
+ // `runtime` as the kit reads it: DocKit.dehydrate looks through the whole page, so each selector is
193
+ // given the package's instances as its root.
194
+ function runtimeOf(runtime, id) {
195
+ if (runtime === undefined) return null;
196
+ if (!isTable(runtime)) fail(said("{0} 要写成一张表", "runtime"));
197
+ onlyFields(runtime, RUNTIME_FIELDS, "runtime.");
198
+ const root = `[${ATTRIBUTE}="${id}"]`;
199
+ const scoped = (selector, where) => {
200
+ try {
201
+ if (!isWords(selector)) throw new Error("no selector");
202
+ parseSelector(selector);
203
+ } catch (error) {
204
+ fail(said("{0} 写错了:{1}", where, error.message));
205
+ }
206
+ return selector.split(",").map((one) => (one.trim().startsWith(":scope") ? one.trim().replace(":scope", root) : `${root} ${one.trim()}`)).join(", ");
207
+ };
208
+ const { generated = [], attrs = {} } = runtime;
209
+ if (!Array.isArray(generated)) fail(said("{0} 要写成一串文字", "runtime.generated"));
210
+ if (!isTable(attrs)) fail(said("{0} 要写成一张表", "runtime.attrs"));
211
+ for (const names of Object.values(attrs)) {
212
+ if (!Array.isArray(names) || !names.every(isWords)) fail(said("{0} 要写成一串文字", "runtime.attrs"));
213
+ for (const name of names) if (OWN_NAME.test(name)) fail(said("{0} 是 Gallery 自己的名字,组件包不能用", name));
214
+ }
215
+ const made = (selector) => {
216
+ const written = scoped(selector, "runtime.generated");
217
+ if (takesAll(selector)) fail(said("{0} 的 {1} 是整个实例,而这里只写它生成的节点", "runtime.generated", selector));
218
+ return written;
219
+ };
220
+ return {
221
+ generated: generated.map(made),
222
+ attrs: Object.fromEntries(Object.entries(attrs).map(([selector, names]) => [scoped(selector, "runtime.attrs"), names])),
223
+ };
224
+ }
225
+
226
+ // `assets`: the kit's files a package asks for, by id, and files of its own, by their path in its folder.
227
+ function assetsOf(assets, folder) {
228
+ if (assets === undefined) return { kit: [], own: [] };
229
+ if (!Array.isArray(assets) || !assets.every(isWords)) fail(said("{0} 要写成一串文字", "assets"));
230
+ const own = assets.filter((asset) => !KIT_ASSETS.has(asset));
231
+ for (const asset of own) {
232
+ if (!OWN_FILE.test(asset)) fail(said("assets 里的 {0} 既不是套件的资源,也不是包里的文件", asset));
233
+ if (!ownPath(folder, asset)) fail(said("assets 写了 {0},包里没有这个文件", asset));
234
+ }
235
+ return { kit: assets.filter((asset) => KIT_ASSETS.has(asset)), own };
236
+ }
237
+
238
+ // A package as `manifest` says it, or the error that says why not. An apiVersion it does not run
239
+ // comes first of all that is about its contents, which a later Gallery may have changed.
240
+ function packageOf(id, folder, text) {
241
+ let manifest;
242
+ try {
243
+ manifest = JSON.parse(text);
244
+ } catch (error) {
245
+ fail(said("component.json 不是 JSON:{0}", error.message));
246
+ }
247
+ if (!isTable(manifest)) fail(said("component.json 写的不是一个对象"));
248
+ if (!PACKAGE_ID.test(id)) fail(said("{0} 不能做组件包的 id:范围和名字都只用小写字母、数字和连字符", id));
249
+ for (const name of id.split("/")) if (DEVICE_NAMES.has(name)) fail(said("{0} 不能做组件包的 id:{1} 是 Windows 留给设备的名字", id, name));
250
+ if (manifest.id !== id) fail(said("清单的 id 是 {0},和它的文件夹 {1} 不一样", String(manifest.id), id));
251
+ required(manifest, ["apiVersion"]);
252
+ if (!Number.isInteger(manifest.apiVersion) || manifest.apiVersion < 1) fail(said("apiVersion 要写成一个正整数"));
253
+ if (manifest.apiVersion !== API_VERSION) throw refusal(said("这个组件包要 apiVersion {0},这一版 Gallery 只支持 {1}", manifest.apiVersion, API_VERSION), { disabled: true, version: isWords(manifest.version) ? manifest.version : null });
254
+ onlyFields(manifest, FIELDS);
255
+ required(manifest, ["version", "name", "description", "parts"]);
256
+ if (!isWords(manifest.version)) fail(said("{0} 要写成文字", "version"));
257
+ bothLanguages(manifest.name, "name");
258
+ bothLanguages(manifest.description, "description");
259
+ if (manifest.words !== undefined && typeof manifest.words !== "string") fail(said("{0} 要写成文字", "words"));
260
+ if (!isTable(manifest.parts)) fail(said("{0} 要写成一张表", "parts"));
261
+ for (const [name, part] of Object.entries(manifest.parts)) checkPart(name, part);
262
+ const runtime = runtimeOf(manifest.runtime, id);
263
+ const { kit, own } = assetsOf(manifest.assets, folder);
264
+ if (manifest.markdown !== undefined && !MARKDOWN.includes(manifest.markdown)) fail(said("markdown 只能是 parts 或 text"));
265
+ if (manifest.schema !== undefined && !(Number.isInteger(manifest.schema) && manifest.schema >= 1)) fail(said("schema 要写成一个正整数"));
266
+ const template = ownFile(folder, TEMPLATE);
267
+ if (template) notTooLong(template, TEMPLATE);
268
+ return {
269
+ id,
270
+ match: instanceMatch(id),
271
+ parts: partsRead(manifest.parts),
272
+ ...(runtime ? { runtime } : {}),
273
+ ...(manifest.schema !== undefined ? { schema: manifest.schema } : {}),
274
+ apiVersion: manifest.apiVersion,
275
+ version: manifest.version,
276
+ name: manifest.name,
277
+ description: manifest.description,
278
+ words: manifest.words ?? "",
279
+ assets: kit,
280
+ markdown: manifest.markdown ?? "parts",
281
+ files: [...new Set([...SERVED.filter((file) => ownPath(folder, file)), ...own])],
282
+ template: template && wordsOf(template),
283
+ folder,
284
+ definition: hashOf((hash) => hash.update(text)),
285
+ stamp: stampOf(folder, stamped(own)),
286
+ };
287
+ }
288
+
289
+ // What a folder holds: a package, or what keeps it from being one.
290
+ function readPackage(id, folder) {
291
+ try {
292
+ const bytes = ownFile(folder, PACKAGE_MANIFEST);
293
+ if (!bytes) fail(said("读不出 component.json"));
294
+ if (!isUtf8(bytes)) fail(said("{0} 不是 UTF-8 编码:请存成 UTF-8", PACKAGE_MANIFEST));
295
+ notTooLong(bytes, PACKAGE_MANIFEST);
296
+ return packageOf(id, folder, wordsOf(bytes));
297
+ } catch (error) {
298
+ const problem = saying(error);
299
+ const stamp = hashOf((hash) => hash.update(`${stampOf(folder, stamped([]))} ${JSON.stringify(problem)}`));
300
+ return { id: id.toLowerCase(), stamp, problem, disabled: error.disabled === true, version: error.version ?? null };
301
+ }
302
+ }
303
+
304
+ const workspaceRoot = () => findWorkspace().root;
305
+
306
+ // A file edited by hand holds what it holds: of its lists, what can be an id is read, once each, and
307
+ // the rest is passed over, one that names nothing there doing nothing. An id may be of a package that
308
+ // comes back, so it stays. Only a package can be disabled.
309
+ const NAMED = /^[a-z0-9][a-z0-9-]*(?:\/[a-z0-9][a-z0-9-]*)?$/;
310
+ const idsIn = (list, shape) => [...new Set(Array.isArray(list) ? list.filter((id) => typeof id === "string" && shape.test(id)) : [])];
311
+ const settingsIn = (file) => ({ hidden: idsIn(file?.components?.hidden, NAMED), disabled: idsIn(file?.components?.disabled, PACKAGE_ID) });
312
+
313
+ // gallery.json's text (null: no file) as what it holds, `value`, or `problem`, why it cannot be taken
314
+ // for a workspace's: what the catalog goes on through (settingsNow) and no writer writes over.
315
+ const UNREAD = said("gallery.json 读不出来:改好这个文件后再试");
316
+ const NOT_OURS = said("gallery.json 不是 Gallery 的文件");
317
+ function fileOf(text) {
318
+ if (text === null) return { value: null };
319
+ const { value, ours, reads } = markerOf(text);
320
+ return ours ? { value } : { problem: reads ? NOT_OURS : UNREAD };
321
+ }
322
+
323
+ function fileAt(root) {
324
+ try {
325
+ return fileOf(readFileSync(layoutOf(root).marker, "utf8"));
326
+ } catch (error) {
327
+ return error.code === "ENOENT" ? fileOf(null) : { problem: UNREAD };
328
+ }
329
+ }
330
+
331
+ /**
332
+ * What gallery.json says of the components: { hidden, disabled }, ids of packages and, in `hidden`,
333
+ * names of built-in components. One that is not there says nothing, and neither does one that does not
334
+ * read or is another program's: what goes on using a workspace goes by the catalog (readCatalog).
335
+ */
336
+ export const componentSettings = (root = workspaceRoot()) => settingsIn(fileAt(root).value);
337
+
338
+ // What a system says of a file it will not let be written, after writeAtomic's own tries.
339
+ const NOT_WRITABLE = ["EPERM", "EACCES", "EBUSY", "EROFS"];
340
+
341
+ /**
342
+ * gallery.json with `id` hidden or not and disabled or not, as `hidden` and `disabled` say (true,
343
+ * false, or left out for as it is), written at once and with all else it holds kept. A file that does
344
+ * not read, is another program's, changed under this write or cannot be written is refused, and stays
345
+ * as it is: it is not this write's to mend.
346
+ */
347
+ export async function writeComponentSettings(root, { id, hidden, disabled }) {
348
+ const file = layoutOf(root).marker;
349
+ const text = await fs.readFile(file, "utf8").catch((error) => {
350
+ if (error.code === "ENOENT") return null;
351
+ fail(UNREAD);
352
+ });
353
+ const { value, problem } = fileOf(text);
354
+ if (problem) fail(problem);
355
+ const named = (list, on) => (on === undefined ? list : on ? [...new Set([...list, id])] : list.filter((other) => other !== id));
356
+ const { hidden: wasHidden, disabled: wasDisabled } = settingsIn(value);
357
+ const components = { ...(isTable(value?.components) ? value.components : {}), hidden: named(wasHidden, hidden), disabled: named(wasDisabled, disabled) };
358
+ const written = await writeAtomic(file, `${JSON.stringify({ ...(value ?? WORKSPACE_MARK), components }, null, 2)}\n`, { expect: text }).catch((error) => {
359
+ if (NOT_WRITABLE.includes(error.code)) fail(said("gallery.json 写不进去:可能是只读的,或被别的程序占着"));
360
+ throw error;
361
+ });
362
+ if (!written) fail(said("gallery.json 刚刚被改过:再试一次"));
363
+ }
364
+
365
+ // A package the settings turned off: to all that loads one, one that does not load, what its manifest
366
+ // says kept for who lists it (`off`).
367
+ const turnedOff = (found) => ({ ...found, off: true, disabled: true, problem: said("在设置里停用了"), stamp: hashOf((hash) => hash.update(`${found.stamp} off`)) });
368
+
369
+ const NO_SETTINGS = settingsIn(null);
370
+
371
+ /** The stamp of a catalog: of what its packages are, those that do not load and why too, of what is hidden and of why gallery.json does not read, neither of which changes a package. */
372
+ export const catalogStamp = ({ packages, problems, settings = NO_SETTINGS }) => hashOf((hash) => {
373
+ for (const { id, stamp } of [...packages.values(), ...problems.values()].sort(byId)) hash.update(`${id} ${stamp}\n`);
374
+ hash.update(`hidden ${[...settings.hidden].sort().join(" ")}\n`);
375
+ hash.update(`settings ${settings.problem?.message ?? ""}\n`);
376
+ });
377
+
378
+ // The settings a catalog goes by: what gallery.json says or, while it cannot be read as saying
379
+ // anything, what was in use (`held`, a broken manifest's hold, for a slip by hand), with why (`problem`).
380
+ function settingsNow(root, held) {
381
+ const { value, problem } = fileAt(root);
382
+ return problem ? { hidden: held.hidden, disabled: held.disabled, problem } : settingsIn(value);
383
+ }
384
+
385
+ /**
386
+ * The workspace's packages as they are on disk now: the catalog, whatever a package or gallery.json
387
+ * holds. `held`: the settings of the catalog in use, for a file that does not read; a process with
388
+ * none has nothing to go by. `on`: a package read as its files say whatever gallery.json says of it,
389
+ * for what holds it to them (gallery component check).
390
+ */
391
+ export function readCatalog(root = workspaceRoot(), held = NO_SETTINGS, { on = null } = {}) {
392
+ const settings = settingsNow(root, held);
393
+ const packages = new Map();
394
+ const problems = new Map();
395
+ for (const { id, folder } of packageFolders(root)) {
396
+ const found = readPackage(id, folder);
397
+ (found.problem ? problems : packages).set(found.id, found);
398
+ }
399
+ for (const id of packages.keys()) problems.delete(id); // a folder of its name in another case, on a system that tells the two apart
400
+ for (const id of settings.disabled) {
401
+ if (!packages.has(id) || id === on) continue;
402
+ problems.set(id, turnedOff(packages.get(id)));
403
+ packages.delete(id);
404
+ }
405
+ return { packages, problems, settings, stamp: catalogStamp({ packages, problems, settings }) };
406
+ }
407
+
408
+ const kept = new Map(); // a workspace's root -> the catalog in use
409
+
410
+ /** The catalog in use: the one kept, read the first time it is asked for. */
411
+ export function currentCatalog(root = workspaceRoot()) {
412
+ const key = path.resolve(root);
413
+ if (!kept.has(key)) kept.set(key, readCatalog(key));
414
+ return kept.get(key);
415
+ }
416
+
417
+ /** `catalog` in use from now on (the server's watcher). */
418
+ export const keepCatalog = (root, catalog) => void kept.set(path.resolve(root), catalog);
419
+
420
+ /** The next ask reads the disk (a job of the worker, which hears no watcher; a test that wrote a package). */
421
+ export const forgetCatalog = (root = workspaceRoot()) => void kept.delete(path.resolve(root));
422
+
423
+ /** Why a package does not load, in `language` ("zh" or "en"), whatever the language in use. */
424
+ export const problemIn = (language, problem) => inLanguage(language, () => told(problem));
425
+
426
+ // Why a package does not load, in both languages, as a page and a list say it.
427
+ const bothProblems = (problem) => ({ zh: problemIn("zh", problem), en: problemIn("en", problem) });
428
+
429
+ /** Why gallery.json cannot be read, in both languages, as 设置 › 组件列表 says it, or null. */
430
+ export const settingsProblem = ({ settings }) => (settings.problem ? bothProblems(settings.problem) : null);
431
+
432
+ // What a package is now: "normal", "hidden", "disabled" (turned off, or for an apiVersion this Gallery
433
+ // does not run), or "broken", one that does not load of itself.
434
+ const stateOf = (found, settings) => (found.problem ? (found.disabled ? "disabled" : "broken") : settingState(found.id, settings));
435
+
436
+ /** What the kit is told of a package: where its instances are, its parts, what it leaves on a page and how far its content's shape goes. */
437
+ export const descriptionOf = ({ id, match, parts, runtime, schema }) => ({ id, match, parts, ...(runtime ? { runtime } : {}), ...(schema !== undefined ? { schema } : {}) });
438
+
439
+ /**
440
+ * What the kit is told of a catalog, each by DocKit.describe, the one way a page learns a package's
441
+ * parts: of a package its description, of one that does not load why, in both languages, its note
442
+ * saying it in the page's.
443
+ */
444
+ export const descriptionsOf = ({ packages, problems }) => [
445
+ ...[...packages.values()].map(descriptionOf),
446
+ ...[...problems.values()].map(({ id, problem }) => ({ id, problem: bothProblems(problem) })),
447
+ ];
448
+
449
+ /** The line that tells the kit of `description`, safe in a script of a page. */
450
+ export const describeLine = (description) => `DocKit.describe(${JSON.stringify(description)});`.replace(/</g, "\\u003c");
451
+
452
+ /** Where a page has a file of a package from, by the stamp that keeps it for good (src/server/component-route.mjs). */
453
+ export const packageAddress = ({ id, stamp }, file) => `/__gallery/components/${id}/${file}?v=${stamp}`;
454
+
455
+ /**
456
+ * The tags that load a package in a page, by kind, each a string of HTML: `styles`, a link to its
457
+ * style.css; `scripts`, the line that tells the kit of it, written here from its manifest so that a
458
+ * package's script says nothing of itself, and a script of its kit.js, which that line then says
459
+ * comes with the page (`script`: the kit marks an instance its script did not start). A package with no
460
+ * script gets the line all the same: that is what makes its instances a package's and no fallback. The
461
+ * one place these are written; a page that has its tags has all of a package.
462
+ */
463
+ export function packageTags(found) {
464
+ const mark = `${PACKAGE_MARK}="${found.id}"`;
465
+ const has = (file) => found.files.includes(file);
466
+ return {
467
+ styles: has("style.css") ? [`<link rel="stylesheet" href="${packageAddress(found, "style.css")}" ${mark}>`] : [],
468
+ scripts: [
469
+ `<script ${mark}>${describeLine({ ...descriptionOf(found), ...(has("kit.js") ? { script: true } : {}) })}</script>`,
470
+ ...(has("kit.js") ? [`<script src="${packageAddress(found, "kit.js")}" ${mark}></script>`] : []),
471
+ ],
472
+ };
473
+ }
474
+
475
+ /** Where a file of a package is now, or null. */
476
+ export const packagePath = ({ folder }, file) => ownPath(folder, file);
477
+
478
+ /** A package's stamp as its files are now, for the moment before the catalog in use has taken them. */
479
+ export const packageStampNow = ({ folder, files }) => stampOf(folder, stamped(files));
480
+
481
+ // The element `text` is, when it is one instance of the package `id` and nothing else (a comment
482
+ // aside), closed by an end tag of its own, or null: what the parser closed at the end of the text
483
+ // (an end tag left out, a comment or a field left open) would take in what stands after it in a file.
484
+ function instanceIn(text, id) {
485
+ const nodes = parseFragment(text, { sourceCodeLocationInfo: true }).childNodes.filter((node) => node.tagName || (node.nodeName === "#text" && node.value.trim()));
486
+ const [root] = nodes;
487
+ return nodes.length === 1 && root.tagName && isInstance(root) && attr(root, ATTRIBUTE) === id && root.sourceCodeLocation.endTag ? root : null;
488
+ }
489
+
490
+ /**
491
+ * What a file is to hold of the instance `text` is, the one way a template or a copy's markup gets
492
+ * there, or null: { markup, root }. Its markup is written anew from what was read, so that what the
493
+ * parser put right is right in the file and what it dropped stays out (an end tag of nothing here
494
+ * would close what stands around the block there), and `root` is that markup read again: what the
495
+ * file will read, the thing to look at.
496
+ */
497
+ export function instanceMarkup(text, id) {
498
+ const read = instanceIn(text, id);
499
+ const markup = read && serializeOuter(read);
500
+ const root = markup && instanceIn(markup, id);
501
+ return root ? { markup, root } : null;
502
+ }
503
+
504
+ // What the template of a package is: { markup } as a new instance is written, or { problem }, or
505
+ // neither where it has none. It is to be what a new instance is: one instance of the package in one
506
+ // piece, holding nothing a clipboard could not bring (refusedInCopy: a script, which would run from
507
+ // the next load on alone, a handler, the editor's marks, which a page takes for its own), and the parts
508
+ // its manifest asks for, or the block a reader makes keeps the document from passing gallery check.
509
+ function readTemplate({ id, template, parts }) {
510
+ if (!template) return {};
511
+ const read = instanceMarkup(template, id);
512
+ if (!read) return { problem: said("template.html 要是这个组件包的一个实例,有自己的结束标签,此外什么都没有") };
513
+ const held = [];
514
+ walk({ childNodes: [read.root] }, (node) => { if (refusedInCopy(node.tagName, node.attrs)) held.push(node.tagName); });
515
+ if (held.length > 0) return { problem: said("template.html 里的 <{0}> 进不了新建的块:脚本、事件、样式和 Gallery 自己的标记都不写在模板里", held[0]) };
516
+ const short = Object.entries(parts).find(([, part]) => {
517
+ const count = partOf(read.root, part.at).length;
518
+ return count < (part.optional ? 0 : part.min ?? 1) || count > (part.edit === "flow" ? 1 : part.max ?? Infinity);
519
+ });
520
+ return short ? { problem: said("template.html 的 {0} 和清单写的数目不符", short[0]) } : { markup: read.markup };
521
+ }
522
+
523
+ /** Why no menu offers the template of `found`, said()'s, for `gallery component check` to say, or null: it has none, or one no reason keeps out. */
524
+ export const templateProblem = (found) => readTemplate(found).problem ?? null;
525
+
526
+ /** The markup of an instance of `found` as a new one is written, or null: it has no template a menu offers. */
527
+ export const templateOf = (found) => readTemplate(found).markup ?? null;
528
+
529
+ /**
530
+ * What the page the editor runs on holds of a catalog: its MAP's `components` (src/editor/service.mjs),
531
+ * no route and no dynamic import. One entry for each package that loads, by id: { id, version, name:
532
+ * { zh, en }, description: { zh, en }, words, definition, stamp, template (the markup "/" puts in: one
533
+ * instance of it, or null), preview (the address of its picture, or null), state ("normal", or "hidden": a menu offers what is "normal" and reads no setting), markdown, assets (the kit's files it asks for,
534
+ * by id), tags (packageTags: what loads it in a page that was served without it, the line that tells the
535
+ * kit of its parts among them) }. A page knows what it holds of a package's parts from the kit
536
+ * (descriptionsOf), and of one that came after it was served from these tags.
537
+ */
538
+ export const menuOf = ({ packages, settings = NO_SETTINGS }) => [...packages.values()].sort(byId).map((found) => ({
539
+ id: found.id,
540
+ version: found.version,
541
+ name: found.name,
542
+ description: found.description,
543
+ words: found.words,
544
+ definition: found.definition,
545
+ stamp: found.stamp,
546
+ template: templateOf(found),
547
+ preview: found.files.includes("preview.svg") ? packageAddress(found, "preview.svg") : null,
548
+ state: stateOf(found, settings),
549
+ markdown: found.markdown,
550
+ assets: found.assets,
551
+ tags: packageTags(found),
552
+ }));
553
+
554
+ /**
555
+ * The workspace's packages as who lists them says them, by id: { id, version, name, description (what
556
+ * a manifest says, null where it does not read), state ("normal", "hidden", "disabled" or "broken":
557
+ * stateOf), reason ({ zh, en }, why it does not load of itself, or null), template (whether it has one
558
+ * a menu can put in: with none, none can), hidden and disabled (what gallery.json says of it) }.
559
+ */
560
+ export const packageStates = ({ packages, problems, settings = NO_SETTINGS }) => [...packages.values(), ...problems.values()].sort(byId).map((found) => ({
561
+ id: found.id,
562
+ version: found.version ?? null,
563
+ name: found.name ?? null,
564
+ description: found.description ?? null,
565
+ state: stateOf(found, settings),
566
+ reason: found.problem && !found.off ? bothProblems(found.problem) : null,
567
+ template: Boolean(templateOf(found)),
568
+ hidden: settings.hidden.includes(found.id),
569
+ disabled: settings.disabled.includes(found.id),
570
+ }));
571
+
572
+ /** The message that tells a page of `settings` on its event stream, its two lists by commas: what it offers follows them, whatever it holds. */
573
+ export const settingsLine = ({ hidden, disabled }) => `settings ${hidden.join(",")} ${disabled.join(",")}`;