@heycys/gallery 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/browser/editor/components/align.mjs +58 -0
  3. package/browser/editor/components/code/index.mjs +1 -1
  4. package/browser/editor/components/embed/page.mjs +1 -1
  5. package/browser/editor/components/file/page.mjs +4 -4
  6. package/browser/editor/components/heading/index.mjs +7 -6
  7. package/browser/editor/components/icons.mjs +3 -0
  8. package/browser/editor/components/image/index.mjs +2 -0
  9. package/browser/editor/components/image/page.mjs +172 -90
  10. package/browser/editor/components/installed/index.mjs +6 -2
  11. package/browser/editor/components/installed/page.mjs +80 -13
  12. package/browser/editor/components/media/icons.mjs +13 -8
  13. package/browser/editor/components/media/page.mjs +5 -3
  14. package/browser/editor/components/media/toolbar.mjs +12 -3
  15. package/browser/editor/components/paragraph/index.mjs +4 -3
  16. package/browser/editor/components/registry.mjs +17 -5
  17. package/browser/editor/components/table/index.mjs +4 -2
  18. package/browser/editor/page/after/index.mjs +288 -0
  19. package/browser/editor/page/align.mjs +91 -0
  20. package/browser/editor/page/beside.mjs +5 -6
  21. package/browser/editor/page/block-menu/index.mjs +6 -3
  22. package/browser/editor/page/blocks.mjs +3 -1
  23. package/browser/editor/page/board/hint.mjs +64 -27
  24. package/browser/editor/page/board/index.mjs +160 -71
  25. package/browser/editor/page/board/motion.mjs +177 -0
  26. package/browser/editor/page/board/settings.mjs +4 -3
  27. package/browser/editor/page/clipboard/index.mjs +10 -3
  28. package/browser/editor/page/clipboard/own/blocks.mjs +3 -4
  29. package/browser/editor/page/clipboard/own/describe.mjs +6 -2
  30. package/browser/editor/page/commit.mjs +2 -2
  31. package/browser/editor/page/core.mjs +3 -1
  32. package/browser/editor/page/custom-page.mjs +15 -11
  33. package/browser/editor/page/editor.mjs +31 -14
  34. package/browser/editor/page/history.mjs +19 -4
  35. package/browser/editor/page/insert/index.mjs +20 -22
  36. package/browser/editor/page/menu.mjs +15 -7
  37. package/browser/editor/page/page-objects.mjs +3 -7
  38. package/browser/editor/page/present-links.mjs +5 -4
  39. package/browser/editor/page/present-shell.mjs +63 -0
  40. package/browser/editor/page/selection/index.mjs +10 -2
  41. package/browser/editor/page/table/binding.mjs +87 -0
  42. package/browser/editor/page/table/icons.mjs +0 -2
  43. package/browser/editor/page/table/index.mjs +10 -14
  44. package/browser/editor/page/table/views.mjs +5 -52
  45. package/browser/editor/page/table/widths.mjs +82 -10
  46. package/browser/editor/page/typing/index.mjs +44 -12
  47. package/browser/editor/page/typing/leave.mjs +19 -5
  48. package/browser/shared/block-packs.mjs +23 -8
  49. package/browser/shared/component-catalog.mjs +15 -8
  50. package/browser/shared/component-source.mjs +3 -1
  51. package/browser/shared/components/heading.mjs +2 -1
  52. package/browser/shared/components/installed.mjs +1 -1
  53. package/browser/shared/components/page.mjs +2 -0
  54. package/browser/shared/components/paragraph.mjs +8 -1
  55. package/browser/shared/components/table.mjs +1 -0
  56. package/browser/shared/emoji/line-icons.mjs +37 -0
  57. package/browser/shared/http.mjs +9 -0
  58. package/browser/shared/i18n/en.mjs +40 -17
  59. package/browser/shared/outline.mjs +30 -2
  60. package/browser/shared/pack-manifest.mjs +12 -1
  61. package/browser/shared/pages.mjs +169 -57
  62. package/browser/shared/pinyin.mjs +92 -0
  63. package/browser/shared/present-step.mjs +17 -0
  64. package/browser/shared/sidebar-head.mjs +70 -0
  65. package/browser/shared/web-links.mjs +5 -0
  66. package/dist/chunk-2OHANJ6Q.mjs +2 -0
  67. package/dist/{chunk-QOUEFUCH.mjs → chunk-3MBRL2PM.mjs} +1 -1
  68. package/dist/{chunk-NWR2LT5B.mjs → chunk-4OKWZY5E.mjs} +1 -1
  69. package/dist/{chunk-RMECZA2K.mjs → chunk-5K44HLTZ.mjs} +1 -1
  70. package/dist/{chunk-NFMCP2HI.mjs → chunk-5XA2ZBAE.mjs} +2 -2
  71. package/dist/{chunk-OUUP3WKT.mjs → chunk-67N2QJYT.mjs} +1 -1
  72. package/dist/chunk-6KBYRA2C.mjs +2 -0
  73. package/dist/{chunk-SX4LJYT6.mjs → chunk-6N3PX4XX.mjs} +1 -1
  74. package/dist/{chunk-RFDZXFJF.mjs → chunk-7JDX4E65.mjs} +1 -1
  75. package/dist/chunk-7M2BQQGZ.mjs +2 -0
  76. package/dist/{chunk-ZUNVAXLH.mjs → chunk-7OG26PGF.mjs} +1 -1
  77. package/dist/{chunk-B4P2CM2J.mjs → chunk-AHN3NFKJ.mjs} +1 -1
  78. package/dist/chunk-ALZ6ZENZ.mjs +3 -0
  79. package/dist/{chunk-UGWYKHBL.mjs → chunk-AR5D57ZD.mjs} +2 -2
  80. package/dist/{chunk-W3BGBJQW.mjs → chunk-BFJGHSQN.mjs} +1 -1
  81. package/dist/{chunk-HLYV7RIH.mjs → chunk-CMA72MAG.mjs} +1 -1
  82. package/dist/{chunk-D4CKRD3V.mjs → chunk-DAZL73VK.mjs} +2 -2
  83. package/dist/{chunk-6VTU6KEO.mjs → chunk-DJISHPUL.mjs} +1 -1
  84. package/dist/{chunk-BPL64HGA.mjs → chunk-EAIFITAV.mjs} +1 -1
  85. package/dist/chunk-EP25HDAJ.mjs +2 -0
  86. package/dist/{chunk-6EZ7FNIK.mjs → chunk-F4ZA6JRZ.mjs} +1 -1
  87. package/dist/{chunk-3KJHLHUO.mjs → chunk-F6HVDZR4.mjs} +1 -1
  88. package/dist/{chunk-3NJACR4W.mjs → chunk-FDMAXMQA.mjs} +1 -1
  89. package/dist/chunk-FETSREUN.mjs +5 -0
  90. package/dist/{chunk-RKPWLGZ3.mjs → chunk-GHOYKMQ3.mjs} +1 -1
  91. package/dist/chunk-HDWTZ763.mjs +12 -0
  92. package/dist/{chunk-VTKNEYT3.mjs → chunk-HPOI4ZX7.mjs} +1 -1
  93. package/dist/{chunk-OW5NWPOJ.mjs → chunk-HXG7EOPJ.mjs} +1 -1
  94. package/dist/{chunk-V6RIYQZZ.mjs → chunk-ITOH5EGO.mjs} +1 -1
  95. package/dist/{chunk-ZWPMCK7P.mjs → chunk-IV64FFI4.mjs} +1 -1
  96. package/dist/chunk-J43Z6LSS.mjs +2 -0
  97. package/dist/chunk-J5PUIV3Y.mjs +4 -0
  98. package/dist/{chunk-KTKHRC6H.mjs → chunk-JA7G53PC.mjs} +1 -1
  99. package/dist/{chunk-NWFBE2YA.mjs → chunk-JLTZF4LA.mjs} +1 -1
  100. package/dist/{chunk-GY3FAUVM.mjs → chunk-JZT7I2OJ.mjs} +1 -1
  101. package/dist/{chunk-QKXMPUXC.mjs → chunk-K5XATEOO.mjs} +1 -1
  102. package/dist/chunk-L2SUIS5S.mjs +2 -0
  103. package/dist/{chunk-TEZAWDSQ.mjs → chunk-LM4XFQHZ.mjs} +1 -1
  104. package/dist/{chunk-5ZJA7CXT.mjs → chunk-MN7BZL4R.mjs} +1 -1
  105. package/dist/chunk-MTYYHM2G.mjs +15 -0
  106. package/dist/{chunk-HMYTM3GT.mjs → chunk-MXUBKDRO.mjs} +1 -1
  107. package/dist/{chunk-MHW7ZKOU.mjs → chunk-OEXWRJME.mjs} +1 -1
  108. package/dist/{chunk-CRJEG7MT.mjs → chunk-OFHXGWOX.mjs} +1 -1
  109. package/dist/chunk-ORID3AE7.mjs +166 -0
  110. package/dist/{chunk-32ZUEFZ7.mjs → chunk-PGDE24N5.mjs} +1 -1
  111. package/dist/{chunk-UNOYVIYR.mjs → chunk-POTA2FV4.mjs} +1 -1
  112. package/dist/{chunk-N7AZZLGT.mjs → chunk-QE5RG76S.mjs} +18 -17
  113. package/dist/{chunk-N76HWBA3.mjs → chunk-R2ZDLJYT.mjs} +1 -1
  114. package/dist/chunk-SWUTTZCN.mjs +2 -0
  115. package/dist/{chunk-POQSE4C2.mjs → chunk-TR7TWGHB.mjs} +1 -1
  116. package/dist/chunk-U5XL7D6A.mjs +3 -0
  117. package/dist/{chunk-PVER7LSC.mjs → chunk-U7NZI6N4.mjs} +2 -2
  118. package/dist/{chunk-Q47PLKIJ.mjs → chunk-UGWMMEJ5.mjs} +1 -1
  119. package/dist/chunk-UJQJKNGK.mjs +2 -0
  120. package/dist/chunk-UYVCQK3H.mjs +22 -0
  121. package/dist/{chunk-FJYN7RTH.mjs → chunk-VFX2KNHP.mjs} +1 -1
  122. package/dist/{chunk-UBBRTJ2R.mjs → chunk-VS7JIGJW.mjs} +1 -1
  123. package/dist/{chunk-NVRNLK25.mjs → chunk-W7665ZEC.mjs} +2 -2
  124. package/dist/{chunk-NG375ILQ.mjs → chunk-WQDQWCX5.mjs} +1 -1
  125. package/dist/chunk-YLPSMDIS.mjs +5 -0
  126. package/dist/{chunk-VXACTLO3.mjs → chunk-YNAWBAYN.mjs} +1 -1
  127. package/dist/{chunk-ZB4H7ZN4.mjs → chunk-YROX2O22.mjs} +1 -1
  128. package/dist/{chunk-YQGT4AB2.mjs → chunk-ZDLPUOAG.mjs} +1 -1
  129. package/dist/chunk-ZQS6H473.mjs +16 -0
  130. package/dist/{chunk-OJKMINIU.mjs → chunk-ZWWC4KLF.mjs} +15 -15
  131. package/dist/cli.mjs +1 -1
  132. package/dist/server.mjs +1 -1
  133. package/dist/worker.mjs +1 -1
  134. package/kit/board.css +5 -5
  135. package/kit/code.js +15 -15
  136. package/kit/report.css +120 -41
  137. package/kit/runtime.js +45 -7
  138. package/kit/tables.js +2 -0
  139. package/kit/ui.js +2 -0
  140. package/package.json +1 -1
  141. package/packs/gallery/chart-view/kit.js +3 -3
  142. package/packs/gallery/chart-view/writing.md +1 -1
  143. package/packs/gallery/countdown/component.json +1 -1
  144. package/packs/gallery/countdown/kit.js +89 -29
  145. package/packs/gallery/countdown/preview.svg +1 -1
  146. package/packs/gallery/countdown/style.css +88 -100
  147. package/packs/gallery/countdown/writing.md +2 -2
  148. package/packs/gallery/habit/component.json +3 -3
  149. package/packs/gallery/habit/kit.js +114 -75
  150. package/packs/gallery/habit/preview.svg +1 -1
  151. package/packs/gallery/habit/style.css +133 -205
  152. package/packs/gallery/habit/writing.md +2 -2
  153. package/packs/gallery/heatmap/component.json +2 -2
  154. package/packs/gallery/heatmap/kit.js +335 -173
  155. package/packs/gallery/heatmap/preview.svg +1 -1
  156. package/packs/gallery/heatmap/style.css +158 -170
  157. package/packs/gallery/heatmap/writing.md +2 -2
  158. package/packs/gallery/kanban/kit.js +3 -3
  159. package/packs/gallery/kanban/writing.md +1 -1
  160. package/packs/gallery/metric/kit.js +3 -3
  161. package/packs/gallery/metric/writing.md +1 -1
  162. package/packs/gallery/note/component.json +3 -3
  163. package/packs/gallery/note/kit.js +40 -13
  164. package/packs/gallery/note/preview.svg +1 -1
  165. package/packs/gallery/note/style.css +51 -30
  166. package/packs/gallery/note/writing.md +2 -2
  167. package/packs/gallery/recent/component.json +2 -2
  168. package/packs/gallery/recent/kit.js +141 -86
  169. package/packs/gallery/recent/preview.svg +1 -1
  170. package/packs/gallery/recent/style.css +53 -126
  171. package/packs/gallery/recent/writing.md +2 -2
  172. package/packs/gallery/static/component.json +2 -2
  173. package/packs/gallery/static/preview.svg +1 -1
  174. package/packs/gallery/static/style.css +99 -66
  175. package/packs/gallery/static/writing.md +2 -2
  176. package/packs/gallery/stats/component.json +3 -3
  177. package/packs/gallery/stats/kit.js +253 -72
  178. package/packs/gallery/stats/preview.svg +1 -1
  179. package/packs/gallery/stats/style.css +64 -142
  180. package/packs/gallery/stats/writing.md +2 -2
  181. package/packs/gallery/today/component.json +2 -2
  182. package/packs/gallery/today/kit.js +62 -27
  183. package/packs/gallery/today/preview.svg +1 -1
  184. package/packs/gallery/today/style.css +101 -72
  185. package/packs/gallery/today/writing.md +2 -2
  186. package/packs/gallery/todos/component.json +1 -1
  187. package/packs/gallery/todos/kit.js +218 -71
  188. package/packs/gallery/todos/preview.svg +1 -1
  189. package/packs/gallery/todos/style.css +170 -223
  190. package/packs/gallery/todos/writing.md +1 -1
  191. package/packs/gallery/weather/component.json +2 -2
  192. package/packs/gallery/weather/kit.js +165 -90
  193. package/packs/gallery/weather/preview.svg +1 -1
  194. package/packs/gallery/weather/style.css +100 -218
  195. package/packs/gallery/weather/writing.md +1 -1
  196. package/packs/gallery-soft/countdown/component.json +18 -0
  197. package/packs/gallery-soft/countdown/example.html +3 -0
  198. package/packs/gallery-soft/countdown/kit.js +206 -0
  199. package/packs/gallery-soft/countdown/preview.svg +1 -0
  200. package/packs/gallery-soft/countdown/style.css +211 -0
  201. package/packs/gallery-soft/countdown/template.html +3 -0
  202. package/packs/gallery-soft/countdown/writing.md +24 -0
  203. package/packs/gallery-soft/habit/component.json +14 -0
  204. package/packs/gallery-soft/habit/example.html +3 -0
  205. package/packs/gallery-soft/habit/kit.js +366 -0
  206. package/packs/gallery-soft/habit/preview.svg +1 -0
  207. package/packs/gallery-soft/habit/style.css +251 -0
  208. package/packs/gallery-soft/habit/template.html +3 -0
  209. package/packs/gallery-soft/habit/writing.md +23 -0
  210. package/packs/gallery-soft/heatmap/component.json +18 -0
  211. package/packs/gallery-soft/heatmap/example.html +3 -0
  212. package/packs/gallery-soft/heatmap/kit.js +498 -0
  213. package/packs/gallery-soft/heatmap/preview.svg +1 -0
  214. package/packs/gallery-soft/heatmap/style.css +181 -0
  215. package/packs/gallery-soft/heatmap/template.html +3 -0
  216. package/packs/gallery-soft/heatmap/writing.md +23 -0
  217. package/packs/gallery-soft/note/component.json +14 -0
  218. package/packs/gallery-soft/note/example.html +3 -0
  219. package/packs/gallery-soft/note/kit.js +162 -0
  220. package/packs/gallery-soft/note/preview.svg +1 -0
  221. package/packs/gallery-soft/note/style.css +148 -0
  222. package/packs/gallery-soft/note/template.html +3 -0
  223. package/packs/gallery-soft/note/writing.md +20 -0
  224. package/packs/gallery-soft/recent/component.json +13 -0
  225. package/packs/gallery-soft/recent/example.html +1 -0
  226. package/packs/gallery-soft/recent/kit.js +335 -0
  227. package/packs/gallery-soft/recent/preview.svg +1 -0
  228. package/packs/gallery-soft/recent/style.css +160 -0
  229. package/packs/gallery-soft/recent/template.html +1 -0
  230. package/packs/gallery-soft/recent/writing.md +17 -0
  231. package/packs/gallery-soft/static/component.json +13 -0
  232. package/packs/gallery-soft/static/example.html +12 -0
  233. package/packs/gallery-soft/static/preview.svg +1 -0
  234. package/packs/gallery-soft/static/style.css +186 -0
  235. package/packs/gallery-soft/static/template.html +1 -0
  236. package/packs/gallery-soft/static/writing.md +20 -0
  237. package/packs/gallery-soft/stats/component.json +13 -0
  238. package/packs/gallery-soft/stats/example.html +1 -0
  239. package/packs/gallery-soft/stats/kit.js +341 -0
  240. package/packs/gallery-soft/stats/preview.svg +1 -0
  241. package/packs/gallery-soft/stats/style.css +119 -0
  242. package/packs/gallery-soft/stats/template.html +1 -0
  243. package/packs/gallery-soft/stats/writing.md +13 -0
  244. package/packs/gallery-soft/today/component.json +12 -0
  245. package/packs/gallery-soft/today/example.html +1 -0
  246. package/packs/gallery-soft/today/kit.js +222 -0
  247. package/packs/gallery-soft/today/preview.svg +1 -0
  248. package/packs/gallery-soft/today/style.css +178 -0
  249. package/packs/gallery-soft/today/template.html +1 -0
  250. package/packs/gallery-soft/today/writing.md +16 -0
  251. package/packs/gallery-soft/todos/component.json +19 -0
  252. package/packs/gallery-soft/todos/example.html +3 -0
  253. package/packs/gallery-soft/todos/kit.js +527 -0
  254. package/packs/gallery-soft/todos/preview.svg +1 -0
  255. package/packs/gallery-soft/todos/style.css +212 -0
  256. package/packs/gallery-soft/todos/template.html +3 -0
  257. package/packs/gallery-soft/todos/writing.md +32 -0
  258. package/packs/gallery-soft/weather/component.json +19 -0
  259. package/packs/gallery-soft/weather/example.html +3 -0
  260. package/packs/gallery-soft/weather/kit.js +411 -0
  261. package/packs/gallery-soft/weather/preview.svg +1 -0
  262. package/packs/gallery-soft/weather/style.css +185 -0
  263. package/packs/gallery-soft/weather/template.html +3 -0
  264. package/packs/gallery-soft/weather/writing.md +28 -0
  265. package/release.json +9 -9
  266. package/skill/SKILL.md +12 -12
  267. package/skill/references/building-blocks.md +4 -4
  268. package/skill/references/pages-and-data.md +13 -9
  269. package/skill/references/writing-html.md +2 -0
  270. package/web/assets/index-BM_K-Auu.css +1 -0
  271. package/web/assets/index-DRslOBiv.js +15 -0
  272. package/web/index.html +2 -2
  273. package/dist/chunk-2NRBY6AJ.mjs +0 -2
  274. package/dist/chunk-35NQ4PLQ.mjs +0 -2
  275. package/dist/chunk-4AV456RQ.mjs +0 -2
  276. package/dist/chunk-5XYHDBJ5.mjs +0 -2
  277. package/dist/chunk-6A53MZYZ.mjs +0 -2
  278. package/dist/chunk-6EXH3ORZ.mjs +0 -166
  279. package/dist/chunk-BVEFGE4B.mjs +0 -2
  280. package/dist/chunk-D4EURAX4.mjs +0 -4
  281. package/dist/chunk-DQCE7TJY.mjs +0 -5
  282. package/dist/chunk-FWNRPMCJ.mjs +0 -12
  283. package/dist/chunk-FWW4CSAZ.mjs +0 -2
  284. package/dist/chunk-JVHHHGEA.mjs +0 -3
  285. package/dist/chunk-PZDLJJTJ.mjs +0 -3
  286. package/dist/chunk-SXHBYZST.mjs +0 -16
  287. package/dist/chunk-UFNYFFKO.mjs +0 -20
  288. package/dist/chunk-UKSHDZZ6.mjs +0 -2
  289. package/dist/chunk-VJPFVNNW.mjs +0 -15
  290. package/dist/chunk-VS3ZMVGX.mjs +0 -5
  291. package/web/assets/index-BK2e_07w.js +0 -13
  292. package/web/assets/index-CWFI83mF.css +0 -1
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{b as E}from"./chunk-SXHBYZST.mjs";import{g as M}from"./chunk-OW5NWPOJ.mjs";import{a as O}from"./chunk-HYMEEXKN.mjs";import{e as I,j as S}from"./chunk-FJYN7RTH.mjs";import d from"node:fs/promises";import b from"node:path";import{isInstance as T}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as _}from"../browser/shared/components/installed.mjs";import{exportSourceOf as q}from"../browser/shared/export-wrap.mjs";import{sha256 as w}from"../browser/shared/files.mjs";import{attr as g,hasClass as y}from"../browser/shared/html-tree.mjs";import{editStateDirectory as F,exportsDirectory as z,qaDirectory as G,reportsDirectory as H}from"../browser/shared/paths.mjs";import{documentDirectory as K,documentFiles as Q}from"../browser/shared/workspace.mjs";function V(t,e=null){return t.tagName==="figure"&&y(t,"doc-figure")||t.tagName==="div"&&(y(t,"doc-code")||y(t,"doc-diff"))||e===D||T(t)||y(t,"doc-flow")||y(t,"doc-sheet-shell")||g(t,"data-doc-sheets")!==void 0?0:t.tagName==="figure"||y(t,"doc-columns")?1:y(t,"doc-table-wrap")?2:3}function X(t){let e=new Map,n=new Map;for(let i of I(t).units)i.blockId&&!n.has(i.blockId)&&n.set(i.blockId,i.kind);let a=new Map,r=new Map,o=new Map,f=i=>!!i.tagName&&g(i,"data-block-id")!==void 0,u=(i,c)=>{if(i.nodeName==="#text")return i.value;if(!i.tagName||i.tagName==="template")return"";let s=g(i,"data-doc-chart-data")?.trim();s&&a.get(c).push(s);let l=g(i,"data-doc-chart-source")?.trim();l&&!r.has(l)&&r.set(l,c);let h=i.attrs.map(({name:k,value:N})=>`${k}="${N}"`).sort().join(" ");return`<${i.tagName} ${h}>${(i.childNodes??[]).map(k=>f(k)?"":u(k,c)).join("")}</${i.tagName}>`},m=(i,c)=>{for(let s of i.childNodes??[]){if(!s.tagName||s.tagName==="template")continue;let l=g(s,"data-block-id"),h=c;if(l!==void 0&&!e.has(l)){let k=[s.tagName,...(g(s,"class")??"").split(/\s+/).filter(Boolean).slice(0,1)].join("."),N=o.get(c)??0;o.set(c,N+1),a.set(l,[]);let v=V(s,n.get(l)),x=s.sourceCodeLocation,U=x?(x.endOffset??x.startTag?.endOffset??x.startOffset)-x.startOffset:0,B=u(s,l).replace(R," ");e.set(l,{hash:w(B).slice(0,16),bare:w(B.replace(`data-block-id="${l}"`,"")).slice(0,16),rank:v,card:v<3,whole:n.get(l)===D,figure:n.get(l)===tt,tag:k,parent:c,at:N,size:U,package:T(s)?g(s,_)??null:null}),h=l}m(s,h)}};m(O(t),null);let p=new Map([...e].map(([i,{hash:c,bare:s}])=>[i,{hash:c,bare:s}]));for(let[i,c]of a){let s=c.map(l=>p.get(r.get(l))).filter(Boolean);s.length&&(e.get(i).hash=w([p.get(i).hash,...s.map(({hash:l})=>l)].join("|")).slice(0,16),e.get(i).bare=w([p.get(i).bare,...s.map(({bare:l})=>l)].join("|")).slice(0,16))}return e}function Y(t){let e=[],n=a=>{for(let r of a.childNodes??[])if(!(!r.tagName||r.tagName==="template"||g(r,"data-block-id")!==void 0))if(r.tagName==="script"||r.tagName==="style"){let o=r.attrs.map(({name:f,value:u})=>`${f}="${u}"`).sort().join(" ");e.push(`<${r.tagName} ${o}>${(r.childNodes??[]).map(f=>f.value??"").join("")}`.replace(R," "))}else n(r)};return n(O(t)),e.length?w(e.join("|")).slice(0,16):""}var Z=t=>Object.fromEntries(M(t).map(({id:e,stamp:n})=>[e,n])),D="block",tt="figure",R=/[ \t\n\f\r]+/g,et=["export","preview"];function st(t){if(t==null)return null;try{let{blocks:e,places:n,moved:a,unseen:r,from:o,time:f,idless:u,page:m,packages:p}=JSON.parse(t)??{};if(!e||typeof e!="object"||Array.isArray(e))return null;let i=n&&typeof n=="object"&&!Array.isArray(n)?n:{},c=s=>Array.isArray(s)?s.filter(l=>typeof l=="string"):[];return{blocks:Object.fromEntries(Object.entries(e).filter(([,s])=>typeof s=="string")),places:Object.fromEntries(Object.entries(i).filter(([,s])=>Array.isArray(s)&&s.length===2&&(s[0]===null||typeof s[0]=="string")&&Number.isInteger(s[1]))),moved:c(a),unseen:c(r),...et.includes(o)?{from:o,time:Number.isFinite(f)?f:null}:{},...c(u).length?{idless:c(u)}:{},...typeof m=="string"?{page:m}:{},...p&&typeof p=="object"&&!Array.isArray(p)?{packages:Object.fromEntries(Object.entries(p).filter(([,s])=>typeof s=="string"))}:{}}}catch{return null}}var $="ge-idless-";function nt(t,{from:e,time:n}){let a=0,{text:r}=S(E(t).text,()=>`${$}${a++}`),o=Z(r),f={blocks:{},places:{},moved:[],unseen:[],from:e,time:n,page:Y(r),...Object.keys(o).length?{packages:o}:{}},u=[];for(let[m,{hash:p,bare:i,card:c,parent:s,at:l}]of X(r)){if(m.startsWith($)){u.push(i);continue}f.blocks[m]=p,s?.startsWith($)||(f.places[m]=[s,l]),c&&f.unseen.push(m)}return u.length?{...f,idless:u}:f}function yt(t,e){if(!e?.idless?.length)return e;let n=new Map;for(let o of e.idless)n.set(o,(n.get(o)??0)+1);let a={...e,blocks:{...e.blocks},unseen:[...e.unseen]};for(let[o,{hash:f,bare:u,card:m}]of t)Object.hasOwn(e.blocks,o)||!n.get(u)||(n.set(u,n.get(u)-1),a.blocks[o]=f,m&&a.unseen.push(o));let r=[...n].flatMap(([o,f])=>Array(f).fill(o));return r.length?a.idless=r:delete a.idless,a}var at=/<[^>]*\sdata-doc-placeholder\b/,j=t=>b.join(G,t),L=t=>b.join(j(t),"blocks.json"),P=t=>b.join(j(t),"exported.html");async function W(t){return st(await d.readFile(L(t),"utf8").catch(()=>null))!==null}async function C(t,e,n){let a=async c=>d.readFile(c).then(s=>({bytes:s,file:c}),()=>null),r=await a(P(t)),o=[r];if(e){let c=e.slice(0,16),s=b.join(F,"history",t),l=await d.readdir(s).catch(()=>[]);o.push(...await Promise.all(l.filter(h=>h.endsWith(`-${c}.html`)).map(h=>a(b.join(s,h))))),o.push(await a(b.join(F,"snapshots",`${c}.html`)))}let f=r?(await d.stat(r.file).catch(()=>null))?.mtimeMs??null:null,m=!(r&&e&&n!==null&&f!==null&&f>n&&w(r.bytes)!==e)&&e&&o.find(c=>c&&w(c.bytes)===e),p=m||r;if(!p)return null;let i=m&&n!==null?n:p===r?f??n:(await d.stat(p.file).catch(()=>null))?.mtimeMs??n;return{text:p.bytes.toString("utf8"),time:i??null}}async function A(t){let e=b.join(z,`${t}.html`),[n,a]=await Promise.all([d.readFile(e,"utf8").catch(()=>null),d.stat(e).catch(()=>null)]);return n===null||!a?null:{said:q(n),time:a.mtimeMs}}async function J(t,e,n){if(at.test(e))return!1;let a=nt(e,n);return!Object.keys(a.blocks).length&&!a.idless?!1:(await d.mkdir(j(t),{recursive:!0}),await d.writeFile(L(t),`${JSON.stringify(a)}
2
+ import{b as E}from"./chunk-ZQS6H473.mjs";import{g as M}from"./chunk-HXG7EOPJ.mjs";import{a as O}from"./chunk-HYMEEXKN.mjs";import{e as I,j as S}from"./chunk-VFX2KNHP.mjs";import d from"node:fs/promises";import b from"node:path";import{isInstance as T}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as _}from"../browser/shared/components/installed.mjs";import{exportSourceOf as q}from"../browser/shared/export-wrap.mjs";import{sha256 as w}from"../browser/shared/files.mjs";import{attr as g,hasClass as y}from"../browser/shared/html-tree.mjs";import{editStateDirectory as F,exportsDirectory as z,qaDirectory as G,reportsDirectory as H}from"../browser/shared/paths.mjs";import{documentDirectory as K,documentFiles as Q}from"../browser/shared/workspace.mjs";function V(t,e=null){return t.tagName==="figure"&&y(t,"doc-figure")||t.tagName==="div"&&(y(t,"doc-code")||y(t,"doc-diff"))||e===D||T(t)||y(t,"doc-flow")||y(t,"doc-sheet-shell")||g(t,"data-doc-sheets")!==void 0?0:t.tagName==="figure"||y(t,"doc-columns")?1:y(t,"doc-table-wrap")?2:3}function X(t){let e=new Map,n=new Map;for(let i of I(t).units)i.blockId&&!n.has(i.blockId)&&n.set(i.blockId,i.kind);let a=new Map,r=new Map,o=new Map,f=i=>!!i.tagName&&g(i,"data-block-id")!==void 0,u=(i,c)=>{if(i.nodeName==="#text")return i.value;if(!i.tagName||i.tagName==="template")return"";let s=g(i,"data-doc-chart-data")?.trim();s&&a.get(c).push(s);let l=g(i,"data-doc-chart-source")?.trim();l&&!r.has(l)&&r.set(l,c);let h=i.attrs.map(({name:k,value:N})=>`${k}="${N}"`).sort().join(" ");return`<${i.tagName} ${h}>${(i.childNodes??[]).map(k=>f(k)?"":u(k,c)).join("")}</${i.tagName}>`},m=(i,c)=>{for(let s of i.childNodes??[]){if(!s.tagName||s.tagName==="template")continue;let l=g(s,"data-block-id"),h=c;if(l!==void 0&&!e.has(l)){let k=[s.tagName,...(g(s,"class")??"").split(/\s+/).filter(Boolean).slice(0,1)].join("."),N=o.get(c)??0;o.set(c,N+1),a.set(l,[]);let v=V(s,n.get(l)),x=s.sourceCodeLocation,U=x?(x.endOffset??x.startTag?.endOffset??x.startOffset)-x.startOffset:0,B=u(s,l).replace(R," ");e.set(l,{hash:w(B).slice(0,16),bare:w(B.replace(`data-block-id="${l}"`,"")).slice(0,16),rank:v,card:v<3,whole:n.get(l)===D,figure:n.get(l)===tt,tag:k,parent:c,at:N,size:U,package:T(s)?g(s,_)??null:null}),h=l}m(s,h)}};m(O(t),null);let p=new Map([...e].map(([i,{hash:c,bare:s}])=>[i,{hash:c,bare:s}]));for(let[i,c]of a){let s=c.map(l=>p.get(r.get(l))).filter(Boolean);s.length&&(e.get(i).hash=w([p.get(i).hash,...s.map(({hash:l})=>l)].join("|")).slice(0,16),e.get(i).bare=w([p.get(i).bare,...s.map(({bare:l})=>l)].join("|")).slice(0,16))}return e}function Y(t){let e=[],n=a=>{for(let r of a.childNodes??[])if(!(!r.tagName||r.tagName==="template"||g(r,"data-block-id")!==void 0))if(r.tagName==="script"||r.tagName==="style"){let o=r.attrs.map(({name:f,value:u})=>`${f}="${u}"`).sort().join(" ");e.push(`<${r.tagName} ${o}>${(r.childNodes??[]).map(f=>f.value??"").join("")}`.replace(R," "))}else n(r)};return n(O(t)),e.length?w(e.join("|")).slice(0,16):""}var Z=t=>Object.fromEntries(M(t).map(({id:e,stamp:n})=>[e,n])),D="block",tt="figure",R=/[ \t\n\f\r]+/g,et=["export","preview"];function st(t){if(t==null)return null;try{let{blocks:e,places:n,moved:a,unseen:r,from:o,time:f,idless:u,page:m,packages:p}=JSON.parse(t)??{};if(!e||typeof e!="object"||Array.isArray(e))return null;let i=n&&typeof n=="object"&&!Array.isArray(n)?n:{},c=s=>Array.isArray(s)?s.filter(l=>typeof l=="string"):[];return{blocks:Object.fromEntries(Object.entries(e).filter(([,s])=>typeof s=="string")),places:Object.fromEntries(Object.entries(i).filter(([,s])=>Array.isArray(s)&&s.length===2&&(s[0]===null||typeof s[0]=="string")&&Number.isInteger(s[1]))),moved:c(a),unseen:c(r),...et.includes(o)?{from:o,time:Number.isFinite(f)?f:null}:{},...c(u).length?{idless:c(u)}:{},...typeof m=="string"?{page:m}:{},...p&&typeof p=="object"&&!Array.isArray(p)?{packages:Object.fromEntries(Object.entries(p).filter(([,s])=>typeof s=="string"))}:{}}}catch{return null}}var $="ge-idless-";function nt(t,{from:e,time:n}){let a=0,{text:r}=S(E(t).text,()=>`${$}${a++}`),o=Z(r),f={blocks:{},places:{},moved:[],unseen:[],from:e,time:n,page:Y(r),...Object.keys(o).length?{packages:o}:{}},u=[];for(let[m,{hash:p,bare:i,card:c,parent:s,at:l}]of X(r)){if(m.startsWith($)){u.push(i);continue}f.blocks[m]=p,s?.startsWith($)||(f.places[m]=[s,l]),c&&f.unseen.push(m)}return u.length?{...f,idless:u}:f}function yt(t,e){if(!e?.idless?.length)return e;let n=new Map;for(let o of e.idless)n.set(o,(n.get(o)??0)+1);let a={...e,blocks:{...e.blocks},unseen:[...e.unseen]};for(let[o,{hash:f,bare:u,card:m}]of t)Object.hasOwn(e.blocks,o)||!n.get(u)||(n.set(u,n.get(u)-1),a.blocks[o]=f,m&&a.unseen.push(o));let r=[...n].flatMap(([o,f])=>Array(f).fill(o));return r.length?a.idless=r:delete a.idless,a}var at=/<[^>]*\sdata-doc-placeholder\b/,j=t=>b.join(G,t),L=t=>b.join(j(t),"blocks.json"),P=t=>b.join(j(t),"exported.html");async function W(t){return st(await d.readFile(L(t),"utf8").catch(()=>null))!==null}async function C(t,e,n){let a=async c=>d.readFile(c).then(s=>({bytes:s,file:c}),()=>null),r=await a(P(t)),o=[r];if(e){let c=e.slice(0,16),s=b.join(F,"history",t),l=await d.readdir(s).catch(()=>[]);o.push(...await Promise.all(l.filter(h=>h.endsWith(`-${c}.html`)).map(h=>a(b.join(s,h))))),o.push(await a(b.join(F,"snapshots",`${c}.html`)))}let f=r?(await d.stat(r.file).catch(()=>null))?.mtimeMs??null:null,m=!(r&&e&&n!==null&&f!==null&&f>n&&w(r.bytes)!==e)&&e&&o.find(c=>c&&w(c.bytes)===e),p=m||r;if(!p)return null;let i=m&&n!==null?n:p===r?f??n:(await d.stat(p.file).catch(()=>null))?.mtimeMs??n;return{text:p.bytes.toString("utf8"),time:i??null}}async function A(t){let e=b.join(z,`${t}.html`),[n,a]=await Promise.all([d.readFile(e,"utf8").catch(()=>null),d.stat(e).catch(()=>null)]);return n===null||!a?null:{said:q(n),time:a.mtimeMs}}async function J(t,e,n){if(at.test(e))return!1;let a=nt(e,n);return!Object.keys(a.blocks).length&&!a.idless?!1:(await d.mkdir(j(t),{recursive:!0}),await d.writeFile(L(t),`${JSON.stringify(a)}
3
3
  `),!0)}async function bt(t){let e=new Map(await Promise.all(t.map(async a=>[a,await A(a).catch(()=>null)])));return{keep:async(a,r=null)=>{for(let o of a)try{if(!await W(o)){let m=e.get(o),p=await C(o,m?.said??null,m?.time??null);p&&await J(o,p.text,{from:"export",time:p.time})}let[f,u]=await Promise.all([d.readFile(Q(K(o,H)).html),r?{said:r.get(o)??null}:A(o)]);u?.said&&w(f)===u.said&&(await d.mkdir(j(o),{recursive:!0}),await d.writeFile(P(o),f))}catch{}}}}async function kt(t,e){try{if(await W(t))return!1;let n=await A(t),a=await C(t,n?.said??null,n?.time??null);return await J(t,a?.text??e,a?{from:"export",time:a.time}:{from:"preview",time:Date.now()})}catch{return!1}}export{V as a,X as b,Y as c,Z as d,et as e,st as f,nt as g,yt as h,W as i,C as j,bt as k,kt as l};
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{e as D,f as x}from"./chunk-OUUP3WKT.mjs";import{a as d,b as u,c as w,d as y}from"./chunk-OJKMINIU.mjs";import{b as c,d as f,e as m,g as p,h as g,i as a,j as h}from"./chunk-SXHBYZST.mjs";import{k as l}from"./chunk-SX4LJYT6.mjs";import{a as s}from"./chunk-UMHUSOPJ.mjs";import S from"node:path";import{FILE as j}from"../browser/shared/annotations.mjs";import{editStateDirectory as L,reportsDirectory as i}from"../browser/shared/paths.mjs";import{documentDirectory as $,documentFiles as k}from"../browser/shared/workspace.mjs";function O({say:e=!0}={}){return o=>{let{text:t,changes:n}=c(o.html,{finish:l});if(e&&n.length&&console.log(p(o.htmlPath,n,{pending:!0}).join(`
2
+ import{e as D,f as x}from"./chunk-67N2QJYT.mjs";import{a as d,b as u,c as w,d as y}from"./chunk-ZWWC4KLF.mjs";import{b as c,d as f,e as m,g as p,h as g,i as a,j as h}from"./chunk-ZQS6H473.mjs";import{k as l}from"./chunk-6N3PX4XX.mjs";import{a as s}from"./chunk-UMHUSOPJ.mjs";import S from"node:path";import{FILE as j}from"../browser/shared/annotations.mjs";import{editStateDirectory as L,reportsDirectory as i}from"../browser/shared/paths.mjs";import{documentDirectory as $,documentFiles as k}from"../browser/shared/workspace.mjs";function O({say:e=!0}={}){return o=>{let{text:t,changes:n}=c(o.html,{finish:l});if(e&&n.length&&console.log(p(o.htmlPath,n,{pending:!0}).join(`
3
3
  `)),e){let r=f(o.html);r.length&&console.log(D(o.htmlPath,r,r.length,{pending:!0}).join(`
4
4
  `));for(let N of x(o.htmlPath,m(s(o.html),o.metadata),{pending:!0}))console.log(N)}return t}}function b(e){for(let o of e){for(let t of g(o.html))console.log(`note ${o.slug}: ${t} (read-only in the preview)`);for(let t of a(o.html))console.log(`note ${o.slug}: ${t}`);for(let t of h(o.html))console.log(`note ${o.slug}: ${t}`)}}async function q(e){for(let o of e){let t=await w({stateDirectory:L,reportsDirectory:i,slug:o});for(let n of y(k($(o,i)).html,t))console.log(n)}}async function z(e){for(let o of e){let t=await d({stateDirectory:L,reportsDirectory:i,slug:o});for(let n of u(S.join($(o,i),j),t))console.log(n)}}export{O as a,b,q as c,z as d};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{g as v,h as X}from"./chunk-AR5D57ZD.mjs";import{a as C,b as B,d as z,g as W,i as J,j as K}from"./chunk-5XA2ZBAE.mjs";import{a as w}from"./chunk-JEUK3ZO7.mjs";import{f as G}from"./chunk-QE5RG76S.mjs";import{h as F,i as H}from"./chunk-UYVCQK3H.mjs";import{a as R,e as P,f as Y}from"./chunk-J5PUIV3Y.mjs";import{a as U,b as d,f as q}from"./chunk-4OZWXZE5.mjs";import{f as L}from"./chunk-HDWTZ763.mjs";import{editStateDirectory as re,reportsDirectory as Z}from"../browser/shared/paths.mjs";import{FIRST_BOARD as le,HOME as D,createPage as ce,listPages as de,pageExists as ee,pageFiles as O,pageSlugRefused as te,pagesSettings as he,readPageMeta as ge}from"../browser/shared/pages.mjs";import{findPreviewServer as se}from"../browser/shared/preview-server.mjs";var M=(e,t)=>`${W(e)}#@${t}`,pe=(e,t)=>`http://127.0.0.1:${e}/pages/${t}`,fe="The default home page (\u9996\u9875, slug home) is not made yet: Gallery makes it, with its own cards, when its server first starts in this workspace. gallery open --no-browser starts it: run that once, then gallery page list again.";async function oe(e){return H()||ee(D,e)||he(e).homeMade||await te(D,e)?null:fe}async function ne(e,t){return(e===D?await oe(t):null)??`No custom page "${e}": ${w(O(e,t).html)} does not exist (gallery page list lists those there are).`}async function ae(e){return(await se({reportsDirectory:e,answering:!0,timeout:2e3}))?.port??null}async function we(e,[t,o,...i]){if(!t||!o?.trim()||i.length)throw new d("Name the slug and the title, the title quoted when it has spaces.");let n=await te(t,e);n&&(console.error(n),process.exit(1));let s=await ce(t,o,{root:e});console.log(`Created ${w(s.html)} and page.json`),console.log(`It is listed in the workbench's sidebar, last among the rows under \u65B0\u5EFA and \u641C\u7D22 (the user may drag it elsewhere), and shows one empty board (data-board-id="main"): use it, or write the page as you like.`);let a=await ae(e),r=`write page.html: a board of cards (each <section class="gallery-card" data-card-id="\u2026" data-x data-y data-w data-h> around one custom block's instance; gallery page add places one), or any HTML, CSS and script of your own (references/pages-and-data.md)`,c="at the end tell them where it is in the sidebar (under \u65B0\u5EFA and \u641C\u7D22, its title)";a?(console.log(`Next: send the user the address on the last line now, in a message of its own (the page is theirs to watch as its cards arrive); ${r}; ${c}.`),console.log(`${C}${M(a,t)}`)):console.log(`Next: run gallery page open ${t} --no-browser now (it starts the server) and send the user the address on its \u4EA4\u7ED9\u7528\u6237 line, in a message of its own, before you write any card (the page is theirs to watch as its cards arrive); then ${r}; ${c}.`)}async function me(e,t){if(t.length)throw new d("gallery page list takes nothing else.");let o=await de(e);console.log(`\u5DE5\u4F5C\u533A\uFF1A${w(e)}`);let i=await oe(e);o.length===0&&!i?console.log('No custom pages yet: gallery page new <slug> "<\u6807\u9898>" makes one.'):o.length>0&&console.log(`Custom pages, in the sidebar's order (${o.length}):`);let n=o.length?await ae(e):null;for(let{slug:s,title:a,icon:r}of o)console.log(`- ${s} ${r?`${r} `:""}${a}`),console.log(` \u5730\u5740\uFF1A${n?M(n,s):`/#@${s}`} ${w(O(s,e).html)}`);i&&console.log(i)}async function ue(e,[t,...o],i){if(!t||o.length)throw new d("gallery page open takes one page's slug.");await ge(t,e)||(console.error(await ne(t,e)),process.exit(1)),console.log(`\u5DE5\u4F5C\u533A\uFF1A${w(e)}`);let s=await J({command:`gallery page open ${t}`});s.ok||(console.error(s.message),process.exit(1));let a=[K(s),`${B}${pe(s.port,t)}`,`${C}${M(s.port,t)}`];for(let r of a)console.log(r);console.log(await z(a,i))}async function Q(e,t,o){let i=`127.0.0.1:${e.port}`;try{let n=await fetch(`http://${i}/__gallery/pages/${t}/cards`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${i}`,"X-Gallery-Token":e.token},body:JSON.stringify({...o,workspace:Z}),signal:AbortSignal.timeout(3e4)}),s=await n.json().catch(()=>null);return!s||["elsewhere","token","host","origin","unknown","method"].includes(s.reason)?null:[n.status,s]}catch{return null}}var $e=8e3,b={places:e=>`${e} is a block of documents (its manifest's places has no "page"): it does not go on a custom page.`,disabled:e=>`${e} is turned off (\u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 \u505C\u7528): nothing of it loads, on a page or in a document.`,missing:e=>`No custom block ${e} in this workspace: gallery block list lists them.`,template:e=>`${e} has no template.html a new card can be made of (gallery block check ${e} says why).`,board:(e,t)=>`No board "${t}" on this page: its <div class="gallery-board" data-board-id="\u2026">s are the ones there are.`,cells:()=>"--x, --y, --w and --h are whole numbers (x and y from 0, w and h from 1).",busy:()=>"page.html was written again and again meanwhile: run this again.",size:()=>"page.html would grow past 1,000,000 bytes.",values:(e,t,o)=>`${e}'s setting ${o?`"${o}" `:""}does not take that value (a text of 10,000 characters at most, a number, a date, one of a select's options, a switch's true or false).`,settings:e=>`${e} has no settings, or a card of it no settings part: --set goes with a block whose manifest has some.`};function ye(e){let t=e.indexOf("--"),o=[],i=[];for(let n=0;n<e.length;n++){let s=e[n];if(t!==-1&&n>=t)i.push(s);else if(s==="--set"||s.startsWith("--set=")){let a=s==="--set"?e[n+1]:s.slice(6);s==="--set"&&(n+=1);let r=a?.indexOf("=")??-1;if(a===void 0||r<1)throw new d("--set takes a setting's key and its value: --set <key>=<value> (--set city=\u4E0A\u6D77).");o.push([a.slice(0,r),a.slice(r+1)])}else i.push(s)}return{argv:i,given:o}}var V=new Map([["true",!0],["yes",!0],["on",!0],["1",!0],["false",!1],["no",!1],["off",!1],["0",!1]]);function be(e,t){let o=t.settings??[],i=()=>o.length?`its settings are ${o.map(({key:s,label:a})=>`${s} (${a?.en??a?.zh??s})`).join(", ")}`:"it has no settings",n={};for(let[s,a]of e){let r=o.find(c=>c.key===s);if(!r)throw new d(`${t.id} has no setting "${s}": ${i()}.`);if(Object.hasOwn(n,s))throw new d(`--set ${s} is given twice.`);if(r.type==="number"){if(a.trim()!==""&&!Number.isFinite(Number(a)))throw new d(`The setting ${s} of ${t.id} is a number: --set ${s}=<number>, or --set ${s}= for none.`);n[s]=a.trim()===""?null:Number(a)}else if(r.type==="switch"){if(!V.has(a.trim().toLowerCase()))throw new d(`The setting ${s} of ${t.id} is a switch: --set ${s}=true or --set ${s}=false.`);n[s]=V.get(a.trim().toLowerCase())}else if(r.type==="select"){if(!r.options.includes(a))throw new d(`The setting ${s} of ${t.id} is one of ${r.options.join(", ")}: --set ${s}=<one of them>.`);n[s]=a}else if(r.type==="date"){if(a!==""&&!/^\d{4}-\d{2}-\d{2}$/.test(a))throw new d(`The setting ${s} of ${t.id} is a date, written YYYY-MM-DD: --set ${s}=2027-02-06.`);n[s]=a}else n[s]=a}return n}function ke(e,t){let o=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return(e.settings??[]).filter(i=>i.required&&i.type!=="switch").filter(({key:i,default:n})=>{let s=Object.hasOwn(o,i)?o[i]:n;return s==null||typeof s=="string"&&s.trim()===""}).map(({key:i,label:n})=>({key:i,label:n?.en??n?.zh??i,zh:n?.zh??null}))}async function xe(e,[t,o,...i],n,s,a,r=[]){if(!t||!o||i.length)throw new d("gallery page add takes a page's slug and a block's id (gallery block list lists them).");let c={};for(let l of["x","y","w","h"]){let g=s.get(`--${l}`);if(g!==void 0){if(!/^\d+$/.test(g)||(l==="w"||l==="h")&&Number(g)<1)throw new d(b.cells());c[l]=Number(g)}}if(c.x===void 0!=(c.y===void 0))throw new d("--x and --y go together: a place is both.");ee(t,e)||(console.error(await ne(t,e)),process.exit(1));let k=o.includes("/")?null:P(o),h=o.includes("/")?o:k?k.id:o,m=L(e),u=m.packages.get(h);if(!u){let l=Y(h)?P(h):null;m.settings.disabled.includes(h)?console.error(b.disabled(h)):console.error(l?`${h} is one of Gallery's own blocks, not yet in this workspace: gallery block add ${l.pack===R?l.name:l.id} puts it in; then run this again.`:m.problems.has(h)?`${h} does not load (gallery block check ${h} says why).`:b.missing(h)),process.exit(1)}u.places.includes("page")||(console.error(b.places(h)),process.exit(1));let p=s.get("--board"),y=r.length?be(r,u):null,N={op:"add",block:h,...p?{board:p}:{},...c,...y?{settings:y}:{},agent:!0},j=await se({reportsDirectory:e}),x=j?await Q(j,t,N):null;for(let l=0;x?.[1]?.reason==="missing"&&l<$e/250;l++)await new Promise(g=>setTimeout(g,250)),x=await Q(j,t,N);let[ie,f]=x??await F({root:e,stateDirectory:re,catalog:()=>m}).apply(t,N);if(!f?.ok){let l=f?.reason;console.error(b[l]?.(h,p??le,f?.message)??`Not added (${ie}: ${l??"no answer"}${f?.message?`: ${f.message}`:""}).`),process.exit(1)}let $=f.cards.find(l=>l.id===f.card),I=(f.pushed??[]).map(l=>f.cards.find(g=>g.id===l)).filter(Boolean);console.log(`Added a card of ${h} to ${w(O(t,e).html)}${x?" (through the workspace's running server: an open page shows it at once)":""}:`),console.log(` data-card-id="${$.id}" on board ${$.board}: x ${$.x}, y ${$.y}, w ${$.w}, h ${$.h}${f.measure?" (its block gives no height: 2 cells, --h sets another)":""}`),I.length&&console.log(` Pushed down under it, as it met them: ${I.map(l=>`${l.id} (y ${l.y})`).join(", ")}; no card moved up.`),y&&console.log(` Settings written with it: ${Object.entries(y).map(([l,g])=>`${l}=${JSON.stringify(g)}`).join(", ")}`),console.log(y?"The rest of its data is as the block's template writes it, in the card's instance: write it there if it is to hold something else, leaving every other card as it is.":"Its data is as the block's template writes it, in the card's instance: write it there if it is to hold something else, leaving every other card as it is.");let S=ke(u,{...y??{}});if(S.length){let l=S.map(({key:g,label:T,zh:E})=>`${g} (${E&&E!==T?`${T}, ${E}`:T})`).join(", ");console.log(`${h} needs its setting ${l} before the card shows anything, and this card has none: ask the user for it, or take it from what the workspace says (\u5199\u4F5C\u504F\u597D, the documents) and tell them in the handoff which you did. Give it with the add (${S.map(({key:g})=>`--set ${g}=<value>`).join(" ")}); for this card, write it in its settings part of ${w(O(t,e).html)} (the <script type="application/json"> of data-card-id="${$.id}": {"${S[0].key}":"\u2026"}), re-reading the page right before, or the user fills it in on the card (the grip at its top right \u203A \u8BBE\u7F6E\u2026).`)}}var _={new:we,list:me,open:ue,add:xe,try:async(e,t,o,i,n)=>(await import("./chunk-J43Z6LSS.mjs")).pageTryCommand(e,{named:t,values:i,seconds:n,keep:o.has("--keep"),replace:o.has("--replace")}),check:async(e,t)=>(await import("./chunk-YLPSMDIS.mjs")).pageCheckCommand(e,t)},A=["--board","--x","--y","--w","--h"];async function Ie(e){try{return await Se(e)}catch(t){throw t instanceof d&&e.find(o=>!U(o))==="try"&&(t.synopsis=G),t}}async function Se(e){let{argv:t,seconds:o}=X(e),{argv:i,given:n}=ye(t),{positional:s,options:a,values:r}=q({options:["--no-browser","--keep","--replace"],values:[...A,...v],argv:i}),[c,...k]=s,h=Object.keys(_).join(", ");if(!c)throw new d(`Say what to do: ${h}.`);if(!Object.hasOwn(_,c))throw new d(`No such page command: ${c} (${h}).`);if(a.has("--no-browser")&&c!=="open")throw new d(`--no-browser goes with open, not ${c}.`);let m=[...v.filter(p=>r.has(p)),...Object.keys(o).filter(p=>!r.has(p)),...a.has("--keep")?["--keep"]:[],...a.has("--replace")?["--replace"]:[]];if(m.length&&c!=="try")throw new d(`${m[0]} goes with try, not ${c}.`);let u=A.filter(p=>r.has(p));if(u.length&&c!=="add")throw new d(`${u.join(", ")} go with add, not ${c}.`);if(n.length&&c!=="add")throw new d(`--set goes with add, not ${c}.`);return _[c](Z,k,a,new Map([...r].filter(([p])=>c==="try"?v.includes(p):A.includes(p))),o,n)}export{M as a,pe as b,fe as c,ne as d,ye as e,be as f,ke as g,Ie as h};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{c as L,d as _,e as D,g as N}from"./chunk-35NQ4PLQ.mjs";import{createHash as q,randomUUID as Q}from"node:crypto";import f from"node:fs/promises";import g from"node:path";import{refusal as V,said as T,saying as X}from"../browser/shared/i18n/index.mjs";import{extensionOf as Y,imageExtension as Z,imageFile as M,mediaTypeOf as tt,UPLOAD_LIMITS as y}from"../browser/shared/media.mjs";import{slugPattern as F}from"../browser/shared/reports.mjs";import{documentDirectory as U,documentFiles as et,layoutOf as nt}from"../browser/shared/workspace.mjs";var z=i=>Y(String(i??"").replace(/[?#].*$/,"")),it=i=>{let e=String(i??"").replace(/[?#].*$/,"");e=e.slice(e.lastIndexOf("/")+1);try{e=decodeURIComponent(e)}catch{}return e.replace(/[\u0000-\u001f<>:"/\\|?*]/g,"").trim().slice(0,120)||"file"};function rt(i){let e=i.subarray(0,16);return e[0]===137&&e.toString("latin1",1,4)==="PNG"?"image/png":e[0]===0&&e[1]===0&&e[2]===1&&e[3]===0?"image/x-icon":e[0]===255&&e[1]===216?"image/jpeg":e.toString("latin1",0,4)==="GIF8"?"image/gif":e.toString("latin1",0,4)==="RIFF"&&e.toString("latin1",8,12)==="WEBP"?"image/webp":e.toString("latin1",4,12)==="ftypavif"?"image/avif":/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*<svg\b/i.test(i.subarray(0,512).toString("utf8"))?"image/svg+xml":null}var w=(i,e)=>V(e,{reason:i}),S=(i,e)=>{let l=rt(i);if(!l)throw w("type","\u4EC5\u652F\u6301\u56FE\u7247");return Z(l)},at=(i,e)=>z(e),ot=(i,e)=>{let l=z(e);if(!["html","htm","pdf"].includes(l)||l==="pdf"&&i.subarray(0,5).toString("latin1")!=="%PDF-")throw w("type","\u53EA\u80FD\u5D4C\u5165 HTML \u6216 PDF \u6587\u4EF6");return l},j={big:i=>T("\u56FE\u7247\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u5F20\u56FE\u7247"},B={big:i=>T("\u6587\u4EF6\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u4E2A\u6587\u4EF6"},k={icon:{limit:y.icon,words:j,extension:S},image:{limit:y.image,words:j,extension:S},file:{limit:y.file,words:B,extension:at,named:!0},embed:{limit:y.embed,words:B,extension:ot,named:!0}};function wt(i,e,l,b){let s=k[i].extension(l,b);return`${i}-${e.slice(0,12)}${s?`.${s}`:""}`}function bt({reportsDirectory:i}){let e=nt(i).emojiLibrary,l=async t=>{let n=U(t,i);return await f.stat(et(n).html).catch(()=>null)?n:null},b=g.join(e,"library.json"),s=(t,n,r)=>[t,{ok:!1,reason:n,...X(r)}];async function O(t,n,{stem:r,limit:a,words:c=j,extension:o=S,given:m}){let u=o(n,m);if(n.length>a)throw w("size",c.big(a/1024/1024));let p=`${r}-${q("sha256").update(n).digest("hex").slice(0,12)}${u?`.${u}`:""}`;await f.mkdir(t,{recursive:!0});let h=g.join(t,p);return await f.stat(h).catch(()=>null)||await f.writeFile(h,n),p}let E=(t,n,r,a=y.icon)=>O(t,n,{stem:r,limit:a});async function I(t,n,r=j){let a=await L(t,{unreachable:r.unreachable});if(!a.ok)throw w("download",r.unreachable);let c=await _(a,n);if(!c)throw w("size",r.big(n/1024/1024));return c}async function $(){try{let t=JSON.parse(await f.readFile(b,"utf8"));return Array.isArray(t)?t:[]}catch{return[]}}let v=t=>({id:t.id,name:t.name,url:`/__gallery/edit/emoji-library/${t.file}`,created_time:t.created,alive:!0});async function A(t){let{slug:n,data:r,url:a,library:c}=t??{},o=Object.hasOwn(k,t?.kind)?t.kind:"icon";if(typeof n!="string"||!F.test(n))return s(400,"body");let m=await l(n);if(!m)return s(404,"missing");let{limit:u,words:p,extension:h,named:J}=k[o];try{let d,x;if(typeof r=="string")d=Buffer.from(r,"base64"),x=t.name;else if(typeof a=="string")d=await I(a,u,p),x=a;else if(typeof c=="string"){let P=(await $()).find(K=>K.id===c);if(!P)return s(404,"library","\u8FD9\u4E2A\u81EA\u5B9A\u4E49\u8868\u60C5\u5DF2\u4E0D\u5728\u8868\u60C5\u5E93\u91CC");d=await f.readFile(g.join(e,P.file))}else return s(400,"body");return[200,{ok:!0,path:`assets/${await O(g.join(m,"assets"),d,{stem:o,limit:u,words:p,extension:h,given:x})}`,...J?{name:it(x),size:d.length}:{}}]}catch(d){return s(422,d.reason??"write",d)}}async function R(t){let{slug:n,url:r,parts:a="all"}=t??{};if(typeof n!="string"||!F.test(n)||typeof r!="string"||!["all","icon","title"].includes(a))return s(400,"body");let c=await l(n);if(!c)return s(404,"missing");try{return[200,{ok:!0,...await N(r,async(m,u)=>`assets/${await E(g.join(c,"assets"),m,u,y.image)}`,{icon:a!=="title",cover:a==="all"})}]}catch(o){return s(422,o.reason??"download",o)}}async function W(t){return typeof t?.url!="string"?s(400,"body"):[200,{ok:!0,...await D(t.url)}]}async function C(t){let{slug:n,name:r,url:a}=t??{};if(typeof r!="string"||!/^[\p{Ll}\p{Lo}\d_-]{1,49}$/u.test(r)||typeof a!="string")return s(400,"body");let c=await $();if(c.some(o=>o.name===r))return s(409,"name","\u540D\u79F0\u5DF2\u88AB\u5360\u7528");try{let o;M(a)&&typeof n=="string"&&F.test(n)?o=await f.readFile(g.join(U(n,i),a)):o=await I(a,y.icon);let m=await E(e,o,"emoji"),u={id:Q(),name:r,file:m,created:Date.now()};return await f.writeFile(b,`${JSON.stringify([...c,u],null,2)}
2
+ import{c as L,d as _,e as D,h as N}from"./chunk-7M2BQQGZ.mjs";import{createHash as q,randomUUID as Q}from"node:crypto";import f from"node:fs/promises";import g from"node:path";import{refusal as V,said as T,saying as X}from"../browser/shared/i18n/index.mjs";import{extensionOf as Y,imageExtension as Z,imageFile as M,mediaTypeOf as tt,UPLOAD_LIMITS as y}from"../browser/shared/media.mjs";import{slugPattern as F}from"../browser/shared/reports.mjs";import{documentDirectory as U,documentFiles as et,layoutOf as nt}from"../browser/shared/workspace.mjs";var z=i=>Y(String(i??"").replace(/[?#].*$/,"")),it=i=>{let e=String(i??"").replace(/[?#].*$/,"");e=e.slice(e.lastIndexOf("/")+1);try{e=decodeURIComponent(e)}catch{}return e.replace(/[\u0000-\u001f<>:"/\\|?*]/g,"").trim().slice(0,120)||"file"};function rt(i){let e=i.subarray(0,16);return e[0]===137&&e.toString("latin1",1,4)==="PNG"?"image/png":e[0]===0&&e[1]===0&&e[2]===1&&e[3]===0?"image/x-icon":e[0]===255&&e[1]===216?"image/jpeg":e.toString("latin1",0,4)==="GIF8"?"image/gif":e.toString("latin1",0,4)==="RIFF"&&e.toString("latin1",8,12)==="WEBP"?"image/webp":e.toString("latin1",4,12)==="ftypavif"?"image/avif":/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*<svg\b/i.test(i.subarray(0,512).toString("utf8"))?"image/svg+xml":null}var w=(i,e)=>V(e,{reason:i}),S=(i,e)=>{let l=rt(i);if(!l)throw w("type","\u4EC5\u652F\u6301\u56FE\u7247");return Z(l)},at=(i,e)=>z(e),ot=(i,e)=>{let l=z(e);if(!["html","htm","pdf"].includes(l)||l==="pdf"&&i.subarray(0,5).toString("latin1")!=="%PDF-")throw w("type","\u53EA\u80FD\u5D4C\u5165 HTML \u6216 PDF \u6587\u4EF6");return l},j={big:i=>T("\u56FE\u7247\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u5F20\u56FE\u7247"},B={big:i=>T("\u6587\u4EF6\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u4E2A\u6587\u4EF6"},k={icon:{limit:y.icon,words:j,extension:S},image:{limit:y.image,words:j,extension:S},file:{limit:y.file,words:B,extension:at,named:!0},embed:{limit:y.embed,words:B,extension:ot,named:!0}};function wt(i,e,l,b){let s=k[i].extension(l,b);return`${i}-${e.slice(0,12)}${s?`.${s}`:""}`}function bt({reportsDirectory:i}){let e=nt(i).emojiLibrary,l=async t=>{let n=U(t,i);return await f.stat(et(n).html).catch(()=>null)?n:null},b=g.join(e,"library.json"),s=(t,n,r)=>[t,{ok:!1,reason:n,...X(r)}];async function O(t,n,{stem:r,limit:a,words:c=j,extension:o=S,given:m}){let u=o(n,m);if(n.length>a)throw w("size",c.big(a/1024/1024));let p=`${r}-${q("sha256").update(n).digest("hex").slice(0,12)}${u?`.${u}`:""}`;await f.mkdir(t,{recursive:!0});let h=g.join(t,p);return await f.stat(h).catch(()=>null)||await f.writeFile(h,n),p}let E=(t,n,r,a=y.icon)=>O(t,n,{stem:r,limit:a});async function I(t,n,r=j){let a=await L(t,{unreachable:r.unreachable});if(!a.ok)throw w("download",r.unreachable);let c=await _(a,n);if(!c)throw w("size",r.big(n/1024/1024));return c}async function $(){try{let t=JSON.parse(await f.readFile(b,"utf8"));return Array.isArray(t)?t:[]}catch{return[]}}let v=t=>({id:t.id,name:t.name,url:`/__gallery/edit/emoji-library/${t.file}`,created_time:t.created,alive:!0});async function A(t){let{slug:n,data:r,url:a,library:c}=t??{},o=Object.hasOwn(k,t?.kind)?t.kind:"icon";if(typeof n!="string"||!F.test(n))return s(400,"body");let m=await l(n);if(!m)return s(404,"missing");let{limit:u,words:p,extension:h,named:J}=k[o];try{let d,x;if(typeof r=="string")d=Buffer.from(r,"base64"),x=t.name;else if(typeof a=="string")d=await I(a,u,p),x=a;else if(typeof c=="string"){let P=(await $()).find(K=>K.id===c);if(!P)return s(404,"library","\u8FD9\u4E2A\u81EA\u5B9A\u4E49\u8868\u60C5\u5DF2\u4E0D\u5728\u8868\u60C5\u5E93\u91CC");d=await f.readFile(g.join(e,P.file))}else return s(400,"body");return[200,{ok:!0,path:`assets/${await O(g.join(m,"assets"),d,{stem:o,limit:u,words:p,extension:h,given:x})}`,...J?{name:it(x),size:d.length}:{}}]}catch(d){return s(422,d.reason??"write",d)}}async function R(t){let{slug:n,url:r,parts:a="all"}=t??{};if(typeof n!="string"||!F.test(n)||typeof r!="string"||!["all","icon","title"].includes(a))return s(400,"body");let c=await l(n);if(!c)return s(404,"missing");try{return[200,{ok:!0,...await N(r,async(m,u)=>`assets/${await E(g.join(c,"assets"),m,u,y.image)}`,{icon:a!=="title",cover:a==="all"})}]}catch(o){return s(422,o.reason??"download",o)}}async function W(t){return typeof t?.url!="string"?s(400,"body"):[200,{ok:!0,...await D(t.url)}]}async function C(t){let{slug:n,name:r,url:a}=t??{};if(typeof r!="string"||!/^[\p{Ll}\p{Lo}\d_-]{1,49}$/u.test(r)||typeof a!="string")return s(400,"body");let c=await $();if(c.some(o=>o.name===r))return s(409,"name","\u540D\u79F0\u5DF2\u88AB\u5360\u7528");try{let o;M(a)&&typeof n=="string"&&F.test(n)?o=await f.readFile(g.join(U(n,i),a)):o=await I(a,y.icon);let m=await E(e,o,"emoji"),u={id:Q(),name:r,file:m,created:Date.now()};return await f.writeFile(b,`${JSON.stringify([...c,u],null,2)}
3
3
  `),[200,{ok:!0,entry:v(u)}]}catch(o){return s(422,o.reason??"write",o)}}let G=async()=>[200,{ok:!0,list:(await $()).map(v)}];async function H(t){if(!M(`assets/${t}`))return null;let n=await f.readFile(g.join(e,t)).catch(()=>null);return n&&{type:tt(t),body:n}}return{upload:A,unfurl:R,frameable:W,addEmoji:C,listEmojis:G,readEmoji:H}}export{wt as a,bt as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a,b}from"./chunk-ZWPMCK7P.mjs";import"./chunk-RKPWLGZ3.mjs";import"./chunk-N7AZZLGT.mjs";import"./chunk-UFNYFFKO.mjs";import"./chunk-D4EURAX4.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-UBBRTJ2R.mjs";import"./chunk-FWNRPMCJ.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as copiedLines,b as run};
2
+ import{a,b}from"./chunk-IV64FFI4.mjs";import"./chunk-GHOYKMQ3.mjs";import"./chunk-QE5RG76S.mjs";import"./chunk-UYVCQK3H.mjs";import"./chunk-J5PUIV3Y.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as copiedLines,b as run};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-6VTU6KEO.mjs";import"./chunk-V6RIYQZZ.mjs";import"./chunk-SXHBYZST.mjs";import"./chunk-OW5NWPOJ.mjs";import"./chunk-SX4LJYT6.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-N76HWBA3.mjs";import"./chunk-FJYN7RTH.mjs";import"./chunk-UBBRTJ2R.mjs";import"./chunk-FWNRPMCJ.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{e as BASELINE_FROM,h as adoptIdless,g as baselineOf,b as blocksOf,k as exportBaselines,j as exportedText,i as hasBaseline,d as packageStamps,c as pageOf,l as previewBaseline,a as rankOf,f as readBaseline};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-DJISHPUL.mjs";import"./chunk-ITOH5EGO.mjs";import"./chunk-ZQS6H473.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-R2ZDLJYT.mjs";import"./chunk-VFX2KNHP.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{e as BASELINE_FROM,h as adoptIdless,g as baselineOf,b as blocksOf,k as exportBaselines,j as exportedText,i as hasBaseline,d as packageStamps,c as pageOf,l as previewBaseline,a as rankOf,f as readBaseline};
@@ -0,0 +1,5 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{a as ue,b as we,k as ge,v as $e,w as be}from"./chunk-3MBRL2PM.mjs";import{M as ye}from"./chunk-HPOI4ZX7.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-EAIFITAV.mjs";import{c as R,f as ke}from"./chunk-AR5D57ZD.mjs";import"./chunk-67N2QJYT.mjs";import{a as P}from"./chunk-JEUK3ZO7.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-7OG26PGF.mjs";import"./chunk-DJISHPUL.mjs";import"./chunk-ZWWC4KLF.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-ITOH5EGO.mjs";import{b as de,h as D}from"./chunk-ZQS6H473.mjs";import"./chunk-QE5RG76S.mjs";import{n as ie}from"./chunk-J5PUIV3Y.mjs";import"./chunk-4OZWXZE5.mjs";import{a as pe,j as fe,s as me}from"./chunk-MXUBKDRO.mjs";import{d as re,e as le,i as I,j as ce,k as he}from"./chunk-HXG7EOPJ.mjs";import"./chunk-ZTHICSSF.mjs";import{a as g}from"./chunk-6N3PX4XX.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import{a as z,c as S}from"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-R2ZDLJYT.mjs";import"./chunk-VFX2KNHP.mjs";import{c as ae}from"./chunk-VS7JIGJW.mjs";import{a as F,f as te,h as se,j as U,r as ne,s as oe}from"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{isUtf8 as Ue}from"node:buffer";import X from"node:fs";import E from"node:path";import{instanceSlots as ze,instancesOf as Y,isInstance as Z,partOf as W}from"../browser/shared/components/index.mjs";import{fewestSyllables as Oe}from"../browser/shared/pinyin.mjs";import{ATTRIBUTE as $,refusedInCopy as De}from"../browser/shared/components/installed.mjs";import{attr as b,elementsOf as Q,walk as A}from"../browser/shared/html-tree.mjs";import{blankedCss as M}from"../browser/shared/css-references.mjs";import{ATTRIBUTE as G,SLOT as Le}from"../browser/shared/components/installed.mjs";var Ae=new Set(["media","supports","container","layer","starting-style"]);function K(e,t){let s=0,o="";for(let n=0;n<e.length;n++){let i=e[n];i==="\\"?n++:o?o=i===o?"":o:i==='"'||i==="'"?o=i:i===")"||i==="]"?s--:(s===0&&t(i,n),(i==="("||i==="[")&&s++)}}function Ce(e){let t=M(e),s=M(e,{strings:!0}),o={children:[]},n=[o],i=0,r=0;for(let a=0;a<t.length;a++){let l=t[a];if(l==="\\")a++;else if(l==="("||l==="[")r++;else if(l===")"||l==="]")r=Math.max(0,r-1);else{if(r>0)continue;if(l==="{"){let c={prelude:s.slice(i,a),start:i,children:[]};n.at(-1).children.push(c),n.push(c),i=a+1}else l==="}"?(n.length>1&&n.pop(),i=a+1):l===";"&&(i=a+1)}}return o.children}function _(e){let t=[],s=0;return K(e,(o,n)=>{o===","&&(t.push({text:e.slice(s,n),start:s}),s=n+1)}),t.push({text:e.slice(s),start:s}),t.filter(({text:o})=>o.trim())}function H(e){let t=[],s=e.trim(),o="",n=0,i=0,r=a=>{(i||a)>n&&t.push({combinator:o,compound:s.slice(n,i||a)}),i=0};return K(s,(a,l)=>{/\s/.test(a)?l===n?n=l+1:i||=l:">+~".includes(a)?(r(l),o=a,n=l+1):i&&(r(l),o=" ",n=l)}),r(s.length),t}function B(e){let t=[],s=-1,o=0,n="";for(let r=0;r<e.length;r++){let a=e[r];a==="\\"?r++:n?n=a===n?"":n:a==='"'||a==="'"?n=a:a==="("?o++:a===")"?o--:a==="["&&o===0?s=r:a==="]"&&o===0&&s>=0&&(t.push(e.slice(s,r+1)),s=-1)}let i=!1;return K(e,r=>{i||=r==="&"}),{attributes:t,nesting:i,scope:/(?:^|[^\w-]):scope\b/.test(e)}}var Ie=e=>new RegExp(`^\\[\\s*${G}\\s*=\\s*(["'])${e.replace(/[/-]/g,"\\$&")}\\1\\s*i?\\s*\\]$`,"i"),Pe=e=>M(e).replace(/\\.|\[[^\]]*\]/g,"").includes("&");function xe(e,t,s,o=!1){let n=H(e),i=({compound:f})=>B(f).attributes.some(h=>t.test(h)),r=({compound:f})=>{let{nesting:h,scope:m}=B(f);return!!s&&(h||m)},a=f=>["+","~"].includes(f?.combinator),l=f=>n.slice(f).some(({combinator:h},m)=>(m+f===0?h||" ":h)===" "),c=n.findLastIndex(f=>i(f)||r(f));if(c<0)return!s||Pe(e)?{why:"outside"}:{why:s==="instance"&&a(n[0])?"beside":null,subject:"inside",deep:o||l(0)};let p=i(n[c])||s==="instance";return{why:p&&a(n[c+1])?"beside":null,subject:p&&c===n.length-1?"instance":"inside",deep:!i(n[c])&&o||l(c+1)}}var Se=e=>e.some(({subject:t})=>t==="instance")?"instance":"inside",Re=new RegExp(`^\\[\\s*${Le}\\s*(?:\\]|=)`,"i"),Fe=e=>_(/\)\s*to\s*\(([^)]*)\)/i.exec(e)?.[1]??"").some(({text:t})=>H(t).length===1&&B(t).attributes.some(s=>Re.test(s))),je=(e,t)=>Ne(e,t).outside;function Ee(e,t,s){if(s.length===0)return[];let o=`slot${s.length===1?"":"s"} ${s.join(" and ")}`;return Ne(e,t).deep.map(({line:n,words:i})=>({line:n,what:`${i} also reaches the blocks in ${o}, the document's: write each step with > or wrap the rules in @scope ([${G}="${t}"]) to ([${Le}])`}))}function Ne(e,t){let s=Ie(t),o=`[${G}="${t}"]`,n=[],i=[],r=(l,c,p)=>{let f=c.replace(/\s+/g," ").trim();n.push({line:S(e,l),what:p==="beside"?`${f} reaches what stands beside the instance: what it styles has to stand in it`:`${f} reaches outside the instance: start it at ${o}`})},a=(l,c,p=!1,f=!1)=>{for(let h of l){let m=h.prelude.length-h.prelude.trimStart().length,u=h.start+m,y=/^@([\w-]+)\s*/.exec(h.prelude.trim());if(y){let d=y[1].toLowerCase();if(Ae.has(d))a(h.children,c,p,f);else if(d==="page")n.push({line:S(e,u),what:"@page reaches the paper of the whole document: an instance has no page of its own"});else if(d==="scope"){let x=/^@scope\s*\(([^)]*)\)/i.exec(h.prelude.trim())?.[1]??"",L=_(x).map(({text:j})=>({...xe(j,s,c),steps:H(j).length}));x&&L.every(({why:j,steps:Te})=>!j&&Te===1)?a(h.children,Se(L),!1,f||Fe(h.prelude.trim())):r(u,h.prelude,"outside")}continue}let k=_(h.prelude).map(({text:d,start:x})=>{let L=xe(d,s,c,p),j=h.start+x+d.length-d.trimStart().length;return L.why?r(j,d,L.why):L.deep&&!f&&!p&&i.push({line:S(e,j),words:d.replace(/\s+/g," ").trim()}),L});k.some(({why:d})=>d)||a(h.children,Se(k),k.some(d=>d.deep),f)}};return a(Ce(e),null),{outside:n,deep:i}}var w="template.html",N="example.html",O="component.json",Me=new Set(["localStorage","sessionStorage"]),_e=/^\S+: (?:line \d+ of )?its (?:kit\.js|style\.css) /,Be=/(?: (?:names a file that )?is not in the document's folder|: it is (?:no file of|not in) the document's .*)$|^external resources are not portable: .*$/,Ge=": an example stands in no document: write a picture as a data: address, or draw it from style.css with a file the manifest's assets name",Ke=e=>e.replace(Be,t=>(t.startsWith("external")?t:"")+Ge),T=(e,t)=>I({folder:e},t);function C(e,t){let s=null;try{s=X.readFileSync(E.join(e,t))}catch{return null}return Ue(s)?null:{file:t,what:"it is not UTF-8: save it as UTF-8 (PowerShell's > writes UTF-16; Set-Content -Encoding utf8 does not)"}}function J(e,t){let s=/^line (\d+): | \(line (\d+)\)/.exec(t);return s?{file:e,line:Number(s[1]??s[2]),what:t.replace(s[0],"")}:{file:e,what:t}}function v(e,t){let s=g.parseJsonText(O,e),o=s.statements[0]?.expression,n=null;for(let i of t.split(".")){let r=o?.properties?.find(({name:a})=>a?.text===i);if(!r)break;n=s.getLineAndCharacterOfPosition(r.getStart(s)).line+1,o=r.initializer}return n}function He(e,{message:t,text:s="",values:o=[]}){let n=/at position (\d+)/.exec(t)?.[1];if(n)return S(e,Number(n));for(let i of[...o.map(String),...s.match(/[a-zA-Z][\w.]*/g)??[]]){let r=v(e,i);if(r)return r}return null}var Je=e=>D(e).map(t=>/^line (\d+): <([^>]+)>: ([\s\S]*)$/.exec(t)).filter(Boolean).map(([,t,s,o])=>({line:Number(t),tag:s,why:o}));function qe(e,{file:t,tree:s,html:o}){let n=[],i=Je(o),r=Object.entries(e.parts).filter(([,c])=>c.edit==="text"),a=Object.entries(e.parts).filter(([,c])=>c.edit==="data"),l=(c,p)=>{let f=!1;return A(c,h=>{f||=h===p}),f};for(let c of Y(s,e))for(let[p,f]of r)for(let h of W(c,f.at)){let m=h.sourceCodeLocation?.startLine,u=Q(h).find(d=>ae.has(d.tagName)),y=i.find(d=>d.line===m&&d.tag===h.tagName),k=a.find(([,d])=>W(c,d.at).some(x=>x===h||l(x,h)||l(h,x)))?.[0];k?n.push({file:t,line:m,what:`the part ${p} (${f.at}) is edited as text, and stands in the part ${k}, edited as data, or around it, which is the component's: the editor leaves it read-only: name elements apart`}):u?n.push({file:t,line:m,what:`the part ${p} (${f.at}) is edited as text and holds a block, its <${u.tagName}> at line ${u.sourceCodeLocation?.startLine}: a text part holds words and marks alone, and the editor would leave this one read-only: write its \`at\` as what holds the words (${f.at} > ${u.tagName}), or give each block a part of its own`}):y&&n.push({file:t,line:m,what:`the part ${p} (${f.at}) is edited as text, and the editor would leave it read-only for what it holds: ${y.why}. A text part holds words and marks alone`})}return n}var ee=new RegExp("\\p{Script=Han}","u"),ve=e=>[...e].filter(t=>ee.test(t)).length,Ve={test:e=>{let t=Oe(e);return t!==null&&t<=8}};function We({name:e,words:t}){let s=ve(e.zh),o=t.split(/\s+/).filter(Boolean);return s===0?ee.test(t)&&!o.some(n=>Ve.test(n)):!o.some(n=>Oe(n.toLowerCase())===s)}function Xe({id:e,folder:t,catalog:s,off:o,parts:n}){let i=s.packages.get(e),r=s.problems.get(e)?.problem,a=T(t,O)??"",l=[];r&&l.push({file:O,line:He(a,r),what:U("en",r)}),i?.template===null&&l.push({file:w,what:`there is none, and it is what "/" puts in a document: with none, no menu offers the block: write one <div ${$}="${e}"> with what a new instance holds`}),l.push(...n);let c=C(t,"writing.md");c&&l.push(c);let p=c||T(t,"writing.md")?.trim()?[]:[{file:"writing.md",what:"there is none, so gallery block show has nothing to say of how to write it"}];i&&We(i)&&p.push({file:O,line:v(a,"words")??v(a,"name.zh"),what:ee.test(i.name.zh)?`no word of words spells its whole name ${i.name.zh} in pinyin as an input method composes it, its ${ve(i.name.zh)} Chinese characters a syllable each in one word (as \u65B9\u6848\u6253\u5206 is fangandafen): "/" finds it while those letters are being composed only by such a word. What is counted is how many syllables a word reads as, not which characters they spell`:'its words are Chinese and none of them is pinyin: "/" goes by the letters an input method is composing, so write the pinyin there (\u770B\u677F kanban)'});let f=(()=>{try{return ie(X.readFileSync(E.join(t,"preview.svg")),e)}catch{return null}})();return f&&p.push({file:"preview.svg",what:`it is Gallery's ${f.id} picture, byte for byte (a block made with --recipe keeps its recipe's drawing, which the menu shows beside this block's name): draw this block's own, or delete preview.svg, which the menu does without`}),o&&p.push({file:"gallery.json",what:"the user turned it off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868, which is theirs to change and says nothing of the block: it is checked as if it were on, and the instances of a document show what they hold, read-only, until it is on"}),i&&(l.push(...Ze(i)),p.push(...Ye(i,a))),{title:"manifest",problems:l,notes:p}}function Ye({places:e,parts:t,card:s},o){let n=[];if(e.includes("page"))for(let[i,r]of Object.entries(t))r.edit==="text"&&n.push({file:O,line:v(o,`parts.${i}`),what:`the part ${i} is edited as text, which is read-only on a custom page (no editor runs there): a block whose places hold page keeps what a reader changes there in a data part, with its own field or the card's settings`});else v(o,"card")&&n.push({file:O,line:v(o,"card"),what:`card is for a custom page's board, and its places (${e.join(", ")}) hold no page: nothing reads it`});return n}function Ze(e){if(e.settings.length===0||!e.template)return[];let t=ne(e.template,e.id),s=t?W(t.root,e.parts[F].at):[];if(s.length!==1||(b(s[0],"type")??"").trim().toLowerCase()!=="application/json")return[{file:w,what:`its manifest has settings, and the template holds ${s.length===1?`a <${s[0].tagName}> where`:`${s.length} elements of`} its settings part (${e.parts[F].at}): it is to hold one <script type="application/json">, the values a new card starts with ({} for each setting's default)`}];let o=s[0].childNodes.map(n=>n.value??"").join("").trim();try{let n=JSON.parse(o||"{}");if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("it is no object");return[]}catch(n){return[{file:w,line:s[0].sourceCodeLocation?.startLine,what:`its settings part is not a JSON object (${n.message}): write {} or the values of some of its settings, by key`}]}}function Qe(e){let t=g.createSourceFile("kit.js",e,g.ScriptTarget.Latest,!0,g.ScriptKind.JS),s=[],o=n=>{let i=g.isCallExpression(n)&&g.isPropertyAccessExpression(n.expression)?n.expression:null;if(i?.name.text==="component"&&/\bDocKit$/.test(i.expression.getText(t))){let[r]=n.arguments,a=r&&g.isObjectLiteralExpression(r)?r.properties.find(c=>c.name?.getText(t)==="id"):null,l=a&&g.isPropertyAssignment(a)&&g.isStringLiteralLike(a.initializer)?a.initializer.text:null;s.push({id:l,at:n.getStart(t)})}g.forEachChild(n,o)};return o(t),s}function et(e){let t="kit.js";if(!e.files.includes("kit.js"))return{title:t,none:"none: a static block"};let s=C(e.folder,t);if(s)return{title:t,stops:!0,problems:[s]};let o=I(e,"kit.js")??"",n=pe(o);if(n)return{title:t,stops:!0,problems:[{file:t,line:n.line,what:`a browser refuses it: ${n.message}`}]};let i=he(e).map(({line:c,what:p})=>({file:t,line:c,what:p})),r=i.length>0;for(let{name:c,at:p}of re(o,Me))i.push({file:t,line:S(o,p),what:`uses ${c}: an instance keeps what a reader chose with context.state`});let a=Qe(o);for(let{id:c,at:p}of a)c!==null&&c!==e.id&&i.push({file:t,line:S(o,p),what:`it registers ${c}, and this block is ${e.id}`});let l=a.length?[]:[{file:t,what:`no DocKit.component({ id: "${e.id}", mount(host, context) { \u2026 } }) is to be read in it, and a script may make that call in ways reading does not tell: running it says whether it starts one`}];for(let{line:c,code:p,message:f,refused:h}of le(o,{assets:e.assets}))(h?i:l).push({file:t,line:c,what:`TS${p}: ${f}`});return{title:t,stops:r,problems:i.sort((c,p)=>(c.line??0)-(p.line??0)),notes:l}}function tt(e){let t="style.css";if(!e.files.includes("style.css"))return{title:t,none:"none"};let s=C(e.folder,t);if(s)return{title:t,stops:!0,problems:[s]};let o=I(e,"style.css")??"",n=ce(e),i=[...je(o,e.id),...n].map(({line:l,what:c})=>({file:t,line:l,what:c})),r=Object.entries(e.parts??{}).filter(([,{edit:l}])=>l==="flow").map(([l])=>l),a=Ee(o,e.id,r).map(({line:l,what:c})=>({file:t,line:l,what:c}));return{title:t,stops:n.length>0,problems:i.sort((l,c)=>l.line-c.line),notes:a}}function st(e,{tree:t}){let s=null;A(t,a=>{s??=a.tagName==="main"?a:null});let o=Q(s??{}),n=(s?.childNodes??[]).some(a=>a.nodeName==="#text"&&a.value.trim()),[i]=o;if(o.length!==1||n||!Z(i)||b(i,$)!==e)return[{file:w,line:i?.sourceCodeLocation?.startLine,what:`a template is one element, a <div ${$}="${e}"> or a <section>, and it holds ${o.length===1&&!n?`<${i.tagName}${b(i,$)?` ${$}="${b(i,$)}"`:""}>`:`${o.length} element${o.length===1?"":"s"}${n?" and words":""}`}`}];let r=[];return A({childNodes:[i]},a=>{b(a,"data-block-id")!==void 0&&r.push({file:w,line:a.sourceCodeLocation?.startLine,what:"it writes a data-block-id, which every instance made of it would repeat: leave it out, Gallery gives a block its id"})}),r}var nt=[[e=>b(e,"data-doc-chart")!==void 0,e=>`a chart (<${e.tagName} data-doc-chart="${b(e,"data-doc-chart")}">)`],[e=>e.tagName==="figure",()=>"a card (<figure>)"],[e=>e.tagName==="caption",()=>"a table's <caption>"],[Z,e=>`an instance of ${b(e,$)}`]];function ot(e,t){let s=null;if(A(z(t),i=>{s??=Z(i)&&b(i,$)===e?i:null}),!s)return[];let o=[],n=(i,r)=>{for(let a of Q(i)){let l=nt.find(([c])=>c(a));l?o.push({file:w,line:a.sourceCodeLocation?.startLine,what:`its slot ${b(r,"data-doc-slot")} holds ${l[1](a)}, which a new block from "/" would not have: a menu makes what a template's slot holds as a paste of it makes blocks, and a paste makes no chart, card, table caption or instance of a block. Keep the template's slots to blocks the page makes (paragraphs, headings, lists, quotes, code, a plain table, a disclosure), and show the rest in example.html`}):n(a.tagName==="template"?a.content:a,r)}};for(let i of ze(s))n(i,i);return o}function it(e,{tree:t}){let s=oe(e);if(!s)return[];let[o]=Y(t,e),n=null;return o&&A({childNodes:[o]},i=>{De(i.tagName,i.attrs)&&(n??=i)}),[{file:w,line:(n??o)?.sourceCodeLocation?.startLine,what:U("en",s)}]}function at(e){return[[w,"component-template"],[N,"component-example"]].flatMap(([t,s])=>{let o=T(e,t);if(o===null||!o.trim()||C(e,t))return[];let n=ge(s,o),{text:i}=de(n);return[{file:t,slug:s,written:n,html:i,tree:z(i)}]})}function rt({id:e,folder:t,found:s,pages:o,parts:n}){let i="template.html and example.html",r=[],a=[];for(let h of[w,N]){let m=C(t,h);m?r.push(m):h===w&&!T(t,h)?.trim()&&s.template!==null?r.push({file:h,what:"it is empty"}):h===N&&!o.some(u=>u.file===h)&&r.push({file:h,what:`there is none or it is empty: write an instance as a writer would fill it, a <div ${$}="${e}">; it is what this check runs`})}let l=o.find(h=>h.file===w);l&&r.push(...st(e,l),...ot(e,l.written));let c=o.find(h=>h.file===N);c&&Y(c.tree,s).length===0&&r.push({file:N,what:`it holds no instance of ${e}: a <div ${$}="${e}">`});let p=o.map(({slug:h,written:m,html:u,file:y})=>({file:y,slug:h,written:m,html:u,directory:E.join(t,h),htmlPath:E.join(t,h,"doc.html"),metadata:{title:h,description:h,type:"component"}})),f=fe(p);for(let h of p){for(let m of f.get(h.slug)??[])_e.test(m)||r.push(J(h.file,Ke(m)));for(let m of me(h))a.push(J(h.file,m));for(let m of D(h.html)){let u=J(h.file,`${m} (read-only in the preview)`);n.some(({file:y,line:k})=>y===u.file&&k===u.line)||a.push(u)}}return l&&!r.some(({file:h})=>h===w)&&r.push(...it(s,l)),{title:i,problems:r,notes:a}}function lt(e,t){let s=te(e,void 0,{on:t}),o=R(e,t);if(!s.packages.has(t)&&!s.problems.has(t))return null;se(e,s);let n=s.packages.has(t)&&s.settings.disabled.includes(t),i=s.packages.get(t)??{id:t,folder:o,files:["kit.js","style.css"].filter(c=>X.existsSync(E.join(o,c)))},r=at(o),a=s.packages.has(t)?null:"its manifest does not load",l=a?[]:r.flatMap(c=>qe(i,c));return{found:s.packages.get(t)??null,pages:r,sections:[Xe({id:t,folder:o,catalog:s,off:n,parts:l}),et(i),tt(i),a?{title:"template.html and example.html",skipped:a}:rt({id:t,folder:o,found:i,pages:r,parts:l})]}}var q=({file:e,line:t})=>t?`${e}:${t}`:e;function V({title:e,problems:t=[],notes:s=[],told:o=[],none:n,skipped:i,unverified:r,pictures:a},l){let c=r?`UNVERIFIED ${r}`:i?`not run: ${i}`:n??(t.length?`${t.length} problem${t.length===1?"":"s"}`:`ok${s.length?`, ${s.length} note${s.length===1?"":"s"}`:""}`);return[`${l}. ${e}: ${c}`,...t.map(p=>` FAIL ${q(p)}: ${p.what}`),...s.map(p=>` note ${q(p)}: ${p.what}`),...o.map(p=>` way back ${q(p)}: ${p.what}`),...a?[ct(a)]:[]]}function ct({folder:e,overviews:t,each:s,edited:o=[],asExport:n=[],documents:i=!1}){let r=t.length?`${P(E.join(e,t[0]))}${t.slice(1).map(c=>` and ${c}`).join("")}, the three widths of each theme side by side; then each at full size: `:`${P(e)}: `,a=n.length===0?"":n.length===o.length?", each the same picture as the export's at its width: the block draws nothing more where a reader can edit":`, ${n.join(" and ")} the same picture as the export's at its width`,l=o.length?`; and ${o.join(" and ")}, as the editing page draws it (context.canEdit() true)${a}`:"";return` Pictures (none looked at for you; ${i?"each instance under a line naming where it stands in the document":"example.html above the line, template.html below it, each under its name"}): ${r}${s.join(", ")}${l}`}function ht([e,t,s,o]){return e.problems.length?"the manifest":t.stops?"kit.js":s.stops?"style.css":o.skipped||o.problems.length?"template.html and example.html":null}async function Ut(e,t,{documents:s=!1}={}){let o=lt(e,t);o||(console.error(ke(e,t)),process.exit(1)),console.log(`${t}: ${P(R(e,t))}`),o.sections.forEach((p,f)=>console.log(V(p,f+1).join(`
3
+ `)));let n=ht(o.sections),i=R(e,t),r=n?{title:ue,skipped:`${n} first`}:await $e(e,o.found,{example:T(i,N),template:T(i,w)});console.log(V(r,5).join(`
4
+ `));let a=s?n?[{title:we(),skipped:`${n} first`}]:await be(e,o.found):[];a.forEach((p,f)=>console.log(V(p,6+f).join(`
5
+ `)));let l=ye([r,...a].filter(({pictures:p})=>p).map(({pictures:{folder:p,overviews:f,each:h,edited:m=[]}})=>({folder:p,files:[...f,...h,...m].map(u=>E.join(p,u))})));l&&console.log(l);let c=[...o.sections,r,...a].reduce((p,{problems:f=[]})=>p+f.length,0);c?(console.log(`FAIL ${t}: ${c} problem${c===1?"":"s"}`),process.exitCode=1):r.unverified||a.some(({unverified:p})=>p)?(console.log(`UNVERIFIED ${t}: the rest passed, and no browser ran ${r.unverified?"it":"the documents' instances"}: export a document that holds it and open that in Chrome or Edge.`),process.exitCode=3):console.log(`OK ${t}${s?" and its instances in the workspace's documents":""}`)}export{Ut as checkCommand,Oe as fewestSyllables,lt as readSections,V as sectionLines,We as wantsPinyin};
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as w,b as k,c as f,g as u}from"./chunk-N7AZZLGT.mjs";import{readFileSync as x,realpathSync as E}from"node:fs";import p from"node:path";import{fileURLToPath as $}from"node:url";var S=p.dirname($(import.meta.url));function v(t=S){for(let e=t;;e=p.dirname(e)){try{let a=JSON.parse(x(p.join(e,"package.json"),"utf8"));if(a.name==="@heycys/gallery")return a.version}catch{}if(p.dirname(e)===e)return"0.0.0"}}var O={init:()=>import("./chunk-3KJHLHUO.mjs"),new:()=>import("./chunk-TEZAWDSQ.mjs"),import:()=>import("./chunk-YQGT4AB2.mjs"),open:()=>import("./chunk-RMECZA2K.mjs"),serve:()=>import("./chunk-PVER7LSC.mjs"),stop:()=>import("./chunk-EKNHM3P4.mjs"),check:()=>import("./chunk-5XYHDBJ5.mjs"),export:()=>import("./chunk-HLYV7RIH.mjs"),qa:()=>import("./chunk-POQSE4C2.mjs"),list:()=>import("./chunk-ZHEHPMBK.mjs"),workspaces:()=>import("./chunk-5ZJA7CXT.mjs"),move:()=>import("./chunk-BZ5RAF7L.mjs"),set:()=>import("./chunk-VXACTLO3.mjs"),link:()=>import("./chunk-GY3FAUVM.mjs"),extension:()=>import("./chunk-L7UP52JO.mjs"),block:()=>import("./chunk-32ZUEFZ7.mjs"),page:()=>import("./chunk-2NRBY6AJ.mjs"),skill:()=>import("./chunk-UNOYVIYR.mjs")},j=new Set(["stop","init","skill","workspaces"]),N=(t,e)=>`${t.split(`
2
+ import{a as w,b as k,c as f,g as u}from"./chunk-QE5RG76S.mjs";import{readFileSync as x,realpathSync as E}from"node:fs";import p from"node:path";import{fileURLToPath as $}from"node:url";var S=p.dirname($(import.meta.url));function v(t=S){for(let e=t;;e=p.dirname(e)){try{let a=JSON.parse(x(p.join(e,"package.json"),"utf8"));if(a.name==="@heycys/gallery")return a.version}catch{}if(p.dirname(e)===e)return"0.0.0"}}var O={init:()=>import("./chunk-F6HVDZR4.mjs"),new:()=>import("./chunk-LM4XFQHZ.mjs"),import:()=>import("./chunk-ZDLPUOAG.mjs"),open:()=>import("./chunk-5K44HLTZ.mjs"),serve:()=>import("./chunk-U7NZI6N4.mjs"),stop:()=>import("./chunk-EKNHM3P4.mjs"),check:()=>import("./chunk-6KBYRA2C.mjs"),export:()=>import("./chunk-CMA72MAG.mjs"),qa:()=>import("./chunk-TR7TWGHB.mjs"),list:()=>import("./chunk-ZHEHPMBK.mjs"),workspaces:()=>import("./chunk-MN7BZL4R.mjs"),move:()=>import("./chunk-BZ5RAF7L.mjs"),set:()=>import("./chunk-YNAWBAYN.mjs"),link:()=>import("./chunk-JZT7I2OJ.mjs"),extension:()=>import("./chunk-L7UP52JO.mjs"),block:()=>import("./chunk-PGDE24N5.mjs"),page:()=>import("./chunk-UJQJKNGK.mjs"),skill:()=>import("./chunk-POTA2FV4.mjs")},j=new Set(["stop","init","skill","workspaces"]),N=(t,e)=>`${t.split(`
3
3
  `)[0]} (gallery ${e?`${e} --help`:"help"} says more)`,g=t=>/^--.|^-[A-Za-z]/.test(t);function A(t){let e=t.indexOf("--"),a=e===-1?t:t.slice(0,e),h=e===-1?[]:t.slice(e),n=[],s=null;for(let r=0;r<a.length;r++){let o=a[r];if(o==="--workspace"||o.startsWith("--workspace=")){let c=o.includes("=")?o.slice(o.indexOf("=")+1):r+1<a.length&&!g(a[r+1])?a[++r]:"";if(!c)return{error:"--workspace takes a folder: --workspace <dir>",usage:u};if(s!==null&&p.resolve(s)!==p.resolve(c))return{error:`Two workspaces named: ${s} and ${c}.`,usage:u};s=c;continue}n.push(o)}if(n[0]==="--version"||n[0]==="-v"||n[0]==="-V")return n.length===1&&h.length===0?{version:!0}:{error:"--version takes nothing else.",usage:u};if(n.length===0||n[0]==="help"||n[0]==="--help"||n[0]==="-h"){let r=n[0]==="help"?n[1]:void 0;return r===void 0?{help:u}:Object.hasOwn(f,r)?{help:f[r]}:{error:`No such command: ${r} (${w.join(", ")}).`,usage:u}}let[d,...m]=n,l=k[d]??d;if(!Object.hasOwn(O,l))return{error:g(l)?`Unknown option: ${l} (the command comes first: gallery <command> [options]).`:`No such command: ${l} (${w.join(", ")}).`,usage:u};let i=[...m,...h];if(m.some(r=>r==="--help"||r==="-h"))return{help:f[l]};if(l==="init"){let r=new Set(["--from","--name"]),o=[];for(let c=0;c<m.length;c++)r.has(m[c])?c++:g(m[c])||o.push(m[c]);if(o.push(...h.slice(1)),o.length>1)return{error:"Name one folder at most.",usage:f.init,command:l};if(o.length===1){if(s!==null&&p.resolve(s)!==p.resolve(o[0]))return{error:`Two workspaces named: ${o[0]} and --workspace ${s}.`,usage:f.init,command:l};s=o[0]}}return{command:l,argv:i,flag:s}}var L=(t,e)=>`Cannot write the workspace ${t} (${e}): allow Gallery to write there, or pass --workspace <a folder you may write>.`,G=(t,e=!0)=>e?`${p.join(t,"gallery.json")} is not Gallery's (another program's file of that name): pass --workspace <another folder> for Gallery's documents.`:`${p.join(t,"gallery.json")} does not read as JSON: mend the file, or pass --workspace <another folder> for Gallery's documents.`;async function b(t=process.argv.slice(2)){process.stdout.on("error",i=>{throw i.code==="EPIPE"&&process.exit(process.exitCode??0),i});let e=A(t);if(e.version){let i=v();console.log(i);try{let{versionNotes:r}=await import("./chunk-TANZRINB.mjs");for(let o of r(i))console.log(o)}catch{}return}if(e.help)return void console.log(e.help);e.error&&(console.error(`${e.error}
4
4
  ${N(e.usage,e.command)}`),process.exit(2));let{command:a,flag:h}=e,{findWorkspace:n}=await import("../browser/shared/workspace.mjs"),s=n({flag:h});if(process.env.GALLERY_WORKSPACE=s.root,!j.has(a)){let{ensureWorkspace:i}=await import("../browser/shared/workspace.mjs");try{let{ours:o,reads:c}=await i(s.root);o||(console.error(G(s.root,c)),process.exit(1))}catch(o){if(!o.code)throw o;console.error(L(s.root,o.code)),process.exit(1)}let{registerQuietly:r}=await import("../browser/shared/workspace-registry.mjs");await r(s.root)}let{UsageError:d,usageFailureText:m}=await import("./chunk-GPIWQ4X4.mjs"),l=await O[a]();try{await l.run(e.argv,{command:a,workspace:s.root,how:s.how,version:v()})}catch(i){if(!(i instanceof d))throw i;console.error(m(f[a],i.message,i.synopsis)),process.exit(2)}}var y=t=>{try{return E.native(t)}catch{return null}};process.argv[1]&&y(process.argv[1])===y($(import.meta.url))&&b();export{v as a,A as b,L as c,G as d,b as e};
@@ -0,0 +1,12 @@
1
+ import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
+ import{a as H,c as X,e as ve}from"./chunk-A55HN5OK.mjs";ve();import{isUtf8 as _e}from"node:buffer";import{createHash as Pe}from"node:crypto";import{existsSync as Ce,lstatSync as De,readFileSync as _,readdirSync as Me,realpathSync as Q,statSync as Fe}from"node:fs";import Le from"node:fs/promises";import k from"node:path";import{isInstance as Re,parseCompound as Ke,parsePart as Ge,parseSelector as Ve,partOf as Ue}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as pe,NO_TEXT as We,PACKAGE_ID as A,PACKAGE_MARK as Be,SLOT as ee,inDocumentMenus as Je,instanceMatch as Ze,refusedInCopy as qe,settingState as Ye}from"../browser/shared/components/installed.mjs";import{writeAtomic as He}from"../browser/shared/files.mjs";import{attr as Xe,walk as Qe}from"../browser/shared/html-tree.mjs";import{HOST as me,NET as te,netHostsOf as et}from"../browser/shared/net-policy.mjs";import{inLanguage as tt,refusal as ue,said as i,saying as nt,told as st}from"../browser/shared/i18n/index.mjs";import{DEFAULT_PACK as ot,OWN_SCOPE as it,PACK_FILE as ne,PACK_ID as he,readPackManifest as rt}from"../browser/shared/pack-manifest.mjs";import{DEVICE_NAMES as at,PACKAGE_MANIFEST as I,WORKSPACE_MARK as ct,findWorkspace as lt,layoutOf as G,markerOf as ft,packageFolders as dt}from"../browser/shared/workspace.mjs";var se=1,oe=new Set(["code","state","sheets","tokens","dialogs","katex-styles","katex","katex-auto-render","math","d3","charts","tables"]),pt=["id","apiVersion","version","name","description","words","parts","runtime","assets","markdown","schema","places","card","settings","needs"],mt=["at","edit","optional","min","max"],ut=["generated","attrs"],ht=["document","page"],wt=["document"],yt=["sizes","w","h","min","max","resize","fit","bare","consent"],y={w:12,h:24},bt=["fixed","content"],ie={sizes:null,any:!1,w:4,h:null,min:{w:1,h:1},max:{...y},resize:!1,fit:"fixed",bare:!1},gt=["key","label","type","options","default","required"],kt=/^[a-z][a-zA-Z0-9]*$/,re=["text","number","select","date","switch","document"],Ot=/^\d{4}-\d{2}-\d{2}$/,$t="settings",Et=["workspace","tables"],St=["text","data","flow","none"],xt=/^[a-z][a-z0-9-]*$/,At=e=>`div[${ee}="${e}"], section[${ee}="${e}"]`,Nt=e=>Object.fromEntries(Object.entries(e).map(([n,s])=>[n,s.edit==="flow"?{...s,at:At(n)}:s])),jt=["parts","text"],we=["kit.js","style.css","preview.svg"],M="template.html",zt=[I,M,...we],V=e=>[...new Set([...zt,...e])].sort(),Tt=/^(?:[A-Za-z0-9_-][A-Za-z0-9._-]*\/)*[A-Za-z0-9_-][A-Za-z0-9._-]*\.[A-Za-z0-9]+$/,It=/^(?:doc-|data-doc-|data-ge-)|^data-block-id$/i,ae=256*1024,u=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),b=e=>typeof e=="string"&&e.trim()!=="",U=(e,n)=>e.id<n.id?-1:1,r=e=>{throw ue(e)},S=e=>{let n=Pe("sha256");return e(n),n.digest("hex").slice(0,16)};function j(e,n){let s=k.join(e,n);try{let t=De(s,{throwIfNoEntry:!1});if(!t)return null;if(!t.isSymbolicLink()&&!n.includes("/"))return s;let o=Q.native(s);return o.startsWith(Q.native(e)+k.sep)?o:null}catch{return null}}function ye(e,n){try{let s=j(e,n);return s&&_(s)}catch{return null}}var ce=new Map,vt=2e3;function _t(e){let{size:n,mtimeMs:s}=Fe(e),t=ce.get(e);if(t?.size===n&&t.time===s)return t.digest;let o=S(f=>f.update(_(e)));return Date.now()-s>vt&&ce.set(e,{size:n,time:s,digest:o}),o}var W=(e,n)=>S(s=>{for(let t of n){let o=j(e,t),f="none";try{o&&(f=_t(o))}catch{}s.update(`${t}\0${f}
3
+ `)}}),be=e=>e.toString("utf8").replace(/^\uFEFF/,""),ge=(e,n)=>{e.length>ae&&r(i("{0} \u6709 {1} KB\uFF0C\u800C\u6BCF\u4E00\u9875\u90FD\u5E26\u7740\u5B83\uFF0C\u6700\u591A {2} KB",n,Math.ceil(e.length/1024),ae/1024))},E=(e,n,s="")=>{for(let t of Object.keys(e))n.includes(t)||r(i("{0} \u4E0D\u662F\u81EA\u5B9A\u4E49\u5757\u7684\u6E05\u5355\u80FD\u5199\u7684\u5B57\u6BB5",`${s}${t}`))},le=(e,n)=>{for(let s of n)e[s]===void 0&&r(i("\u7F3A\u5C11 {0}",s))},v=(e,n)=>{(!u(e)||!b(e.zh)||!b(e.en)||Object.keys(e).length!==2)&&r(i("{0} \u8981\u5199\u6210 { zh, en } \u4E24\u79CD\u8BED\u8A00\u7684\u6587\u5B57",n))},F=e=>e.split(",").map(n=>n.split(">").at(-1).trim()).filter(n=>n!=="*").map(n=>Ke(n).tag);function Pt(e,n){let s=`parts.${e}`;if(u(n)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868",s)),E(n,mt,`${s}.`),n.edit==="flow"){xt.test(e)||r(i("{0} \u662F\u63D2\u69FD\uFF0C\u540D\u5B57\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",s)),n.at!==void 0&&r(i('{0} \u662F\u63D2\u69FD\uFF0C\u7531 data-doc-slot="{1}" \u6807\u51FA\uFF0C\u4E0D\u5199 at',s,e)),(n.min!==void 0||n.max!==void 0)&&r(i("{0} \u662F\u63D2\u69FD\uFF0C\u4E00\u4E2A\u5B9E\u4F8B\u91CC\u53EA\u6709\u4E00\u4E2A\uFF0C\u4E0D\u5199 min\u3001max",s)),n.optional!==void 0&&typeof n.optional!="boolean"&&r(i("{0} \u8981\u5199\u6210 true \u6216 false",`${s}.optional`));return}b(n.at)||r(i("\u7F3A\u5C11 {0}",`${s}.at`));try{Ge(n.at)}catch(t){r(i("{0} \u5199\u9519\u4E86\uFF1A{1}",`${s}.at`,t.message))}St.includes(n.edit)||r(i("{0} \u7684 edit \u53EA\u80FD\u662F text\u3001data\u3001flow \u6216 none",s)),n.optional!==void 0&&typeof n.optional!="boolean"&&r(i("{0} \u8981\u5199\u6210 true \u6216 false",`${s}.optional`));for(let t of["min","max"])n[t]!==void 0&&!(Number.isInteger(n[t])&&n[t]>=0)&&r(i("{0} \u8981\u5199\u6210\u4E0D\u5C0F\u4E8E 0 \u7684\u6574\u6570",`${s}.${t}`));if(n.min>n.max&&r(i("{0} \u7684 min \u6BD4 max \u5927\uFF0C\u6CA1\u6709\u5B9E\u4F8B\u80FD\u6EE1\u8DB3",s)),n.edit==="text")for(let t of F(n.at))We.has(t)&&r(i("{0} \u4E0D\u80FD\u6309\u6587\u5B57\u7F16\u8F91\uFF1A<{1}> \u4E0D\u662F\u80FD\u6253\u5B57\u7684\u6587\u5B57",s,t))}var Ct=e=>e.split(",").some(n=>n.split(">").every(s=>[":scope","*"].includes(s.trim())));function Dt(e,n){if(e===void 0)return null;u(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime")),E(e,ut,"runtime.");let s=`[${pe}="${n}"]`,t=(d,a)=>{try{if(!b(d))throw new Error("no selector");Ve(d)}catch(l){r(i("{0} \u5199\u9519\u4E86\uFF1A{1}",a,l.message))}return d.split(",").map(l=>l.trim().startsWith(":scope")?l.trim().replace(":scope",s):`${s} ${l.trim()}`).join(", ")},{generated:o=[],attrs:f={}}=e;Array.isArray(o)||r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.generated")),u(f)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime.attrs"));for(let d of Object.values(f)){(!Array.isArray(d)||!d.every(b))&&r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.attrs"));for(let a of d)It.test(a)&&r(i("{0} \u662F Gallery \u81EA\u5DF1\u7684\u540D\u5B57\uFF0C\u81EA\u5B9A\u4E49\u5757\u4E0D\u80FD\u7528",a))}let c=d=>{let a=t(d,"runtime.generated");return Ct(d)&&r(i("{0} \u7684 {1} \u662F\u6574\u4E2A\u5B9E\u4F8B\uFF0C\u800C\u8FD9\u91CC\u53EA\u5199\u5B83\u751F\u6210\u7684\u8282\u70B9","runtime.generated",d)),a};return{generated:o.map(c),attrs:Object.fromEntries(Object.entries(f).map(([d,a])=>[t(d,"runtime.attrs"),a]))}}var T=(e,n)=>Number.isInteger(e)&&e>=1&&e<=n,O=e=>e.find((n,s)=>e.indexOf(n)!==s);function Mt(e){return e===void 0?wt:((!Array.isArray(e)||e.length===0||!e.every(n=>ht.includes(n)))&&r(i('places \u8981\u5199\u6210 document\u3001page \u4E2D\u7684\u4E00\u4E2A\u6216\u4E24\u4E2A\uFF0C\u5982 ["document"]')),O(e)&&r(i("places \u91CC {0} \u5199\u4E86\u4E24\u6B21",O(e))),[...e])}function Ft(e){if(e===void 0)return ie;u(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","card")),E(e,yt,"card.");let n=a=>Array.isArray(a)&&a.length===2&&T(a[0],y.w)&&T(a[1],y.h);if(e.sizes!==void 0){(!Array.isArray(e.sizes)||e.sizes.length===0||!e.sizes.every(n))&&r(i("card.sizes \u8981\u5199\u6210 [\u5BBD, \u9AD8] \u7684\u4E00\u4E32\uFF0C\u5BBD 1 \u5230 {0} \u683C\uFF0C\u9AD8 1 \u5230 {1} \u683C",y.w,y.h));let a=O(e.sizes.map(p=>p.join("x")));a&&r(i("card.sizes \u91CC {0} \u5199\u4E86\u4E24\u6B21",a));let l=["w","h"].find(p=>e[p]!==void 0);l&&r(i("\u5199\u4E86 card.sizes\uFF0C\u5C31\u4E0D\u518D\u5199 card.{0}\uFF1A\u7B2C\u4E00\u79CD\u5927\u5C0F\u662F\u9ED8\u8BA4\u7684",l))}for(let a of["w","h"])e[a]!==void 0&&!T(e[a],y[a])&&r(i("{0} \u8981\u5199\u6210 1 \u5230 {1} \u7684\u6574\u6570",`card.${a}`,y[a]));let s={};for(let a of["min","max"]){let l=e[a];if(l!==void 0){u(l)||r(i("{0} \u8981\u5199\u6210 { w, h }\uFF0C\u5355\u4F4D\u662F\u683C",`card.${a}`)),E(l,["w","h"],`card.${a}.`);for(let p of["w","h"])l[p]!==void 0&&!T(l[p],y[p])&&r(i("{0} \u8981\u5199\u6210 1 \u5230 {1} \u7684\u6574\u6570",`card.${a}.${p}`,y[p]));s[a]=l}}let t={w:s.min?.w??1,h:s.min?.h??1},o={w:s.max?.w??y.w,h:s.max?.h??y.h},f=e.sizes?e.sizes[0][0]:e.w??ie.w,c=e.sizes?e.sizes[0][1]:e.h??null,d=!!e.sizes&&(e.min!==void 0||e.max!==void 0);if(d){let a=e.sizes.find(([l,p])=>l<t.w||l>o.w||p<t.h||p>o.h);a&&r(i("card.sizes \u91CC {0} \u4E0D\u5728 card.min \u5230 card.max \u4E4B\u95F4",a.join("x")))}for(let a of["w","h"]){t[a]>o[a]&&r(i("card.min.{0} \u6BD4 card.max.{0} \u5927",a));let l={w:f,h:c}[a];l!==null&&!e.sizes&&(l<t[a]||l>o[a])&&r(i("\u9ED8\u8BA4\u7684 card.{0} \u662F {1}\uFF0C\u4E0D\u5728 card.min \u5230 card.max \u4E4B\u95F4\uFF08{2} \u5230 {3}\uFF09",a,l,t[a],o[a]))}for(let a of["resize","bare"])e[a]!==void 0&&typeof e[a]!="boolean"&&r(i("{0} \u8981\u5199\u6210 true \u6216 false",`card.${a}`));return e.fit!==void 0&&!bt.includes(e.fit)&&r(i("card.fit \u53EA\u80FD\u662F fixed \u6216 content")),e.consent!==void 0&&v(e.consent,"card.consent"),{sizes:e.sizes?e.sizes.map(([a,l])=>[a,l]):null,any:d,w:f,h:c,min:t,max:o,resize:e.resize??!1,fit:e.fit??"fixed",bare:e.bare??!1,...e.consent!==void 0?{consent:{zh:e.consent.zh,en:e.consent.en}}:{}}}var Lt=(e,{type:n,options:s})=>({text:typeof e=="string",number:typeof e=="number"&&Number.isFinite(e),select:s?.includes(e),date:typeof e=="string"&&Ot.test(e),switch:typeof e=="boolean",document:typeof e=="string"})[n];function Rt(e,n){if(e===void 0)return[];Array.isArray(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u5B57\u6BB5","settings"));let s=[];e.forEach((o,f)=>{let c=`settings[${f}]`;u(o)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868",c)),E(o,gt,`${c}.`),(typeof o.key!="string"||!kt.test(o.key))&&r(i("{0} \u7684 key \u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u53EA\u7528\u5B57\u6BCD\u548C\u6570\u5B57\uFF08\u5982 city\u3001startDate\uFF09",c)),s.includes(o.key)&&r(i("settings \u91CC key {0} \u5199\u4E86\u4E24\u6B21",o.key)),s.push(o.key),v(o.label,`${c}.label`),re.includes(o.type)||r(i("{0} \u7684 type \u53EA\u80FD\u662F {1}",c,re.join(", "))),o.type==="select"?((!Array.isArray(o.options)||o.options.length===0||!o.options.every(b))&&r(i("{0} \u662F select\uFF0C\u8981\u6709 options\uFF1A\u4E00\u4E32\u6587\u5B57",c)),O(o.options)&&r(i("{0} \u7684 options \u91CC {1} \u5199\u4E86\u4E24\u6B21",c,O(o.options)))):o.options!==void 0&&r(i("{0} \u4E0D\u662F select\uFF0C\u4E0D\u5199 options",c)),o.default!==void 0&&!Lt(o.default,o)&&r(i("{0} \u7684 default \u548C\u5B83\u7684 type {1} \u4E0D\u7B26",c,o.type)),o.required!==void 0&&typeof o.required!="boolean"&&r(i("{0} \u7684 required \u8981\u5199 true \u6216 false",c))});let t=n[$t];return e.length>0&&!(t?.edit==="data"&&F(t.at).every(o=>o==="script")&&F(t.at).length>0)&&r(i('\u5199\u4E86 settings\uFF0Cparts \u91CC\u5C31\u8981\u6709\u4E00\u4E2A\u540D\u4E3A settings\u3001edit \u4E3A data \u7684\u90E8\u5206\uFF0C\u5B83\u662F\u4E00\u4E2A <script type="application/json">\uFF0C\u5B58\u5361\u7247\u8BBE\u7F6E\u7684\u503C')),e.map(o=>({...o}))}function Kt(e){if(e===void 0)return[];Array.isArray(e)||r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","needs"));for(let n of e)typeof n=="string"&&(Et.includes(n)||n.startsWith(te)&&me.test(n.slice(te.length)))||r(i("needs \u91CC\u7684 {0} \u4E0D\u8BA4\u8BC6\uFF1A\u53EA\u8BA4 workspace\u3001tables \u548C net:<\u57DF\u540D>\uFF08\u5C0F\u5199\u7684\u4E3B\u673A\u540D\uFF0C\u4E0D\u5E26\u7AEF\u53E3\u548C\u8DEF\u5F84\uFF0C\u53EF\u4EE5\u4EE5 *. \u5F00\u5934\uFF09",typeof n=="string"?n:JSON.stringify(n)));return O(e)&&r(i("needs \u91CC {0} \u5199\u4E86\u4E24\u6B21",O(e))),[...e]}function Gt(e,n){if(!e.includes("page"))return;let s=Object.entries(n).find(([,t])=>t.edit==="flow");s&&r(i("places \u91CC\u6709 page\uFF0C\u5C31\u4E0D\u80FD\u6709\u63D2\u69FD\uFF1A{0} \u7684 edit \u662F flow\uFF0C\u63D2\u69FD\u653E\u7684\u662F\u6587\u6863\u7684\u5757\uFF0C\u81EA\u5B9A\u4E49\u9875\u4E0A\u6CA1\u6709",`parts.${s[0]}`))}function Vt(e,n){if(e===void 0)return{kit:[],own:[]};(!Array.isArray(e)||!e.every(b))&&r(i("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","assets"));let s=e.filter(t=>!oe.has(t));for(let t of s)Tt.test(t)||r(i("assets \u91CC\u7684 {0} \u65E2\u4E0D\u662F\u5957\u4EF6\u7684\u8D44\u6E90\uFF0C\u4E5F\u4E0D\u662F\u5757\u7684\u6587\u4EF6\u5939\u91CC\u7684\u6587\u4EF6",t)),j(n,t)||r(i("assets \u5199\u4E86 {0}\uFF0C\u5757\u7684\u6587\u4EF6\u5939\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6587\u4EF6",t));return{kit:e.filter(t=>oe.has(t)),own:s}}function Ut(e,n,s){let t;try{t=JSON.parse(s)}catch(w){r(i("component.json \u4E0D\u662F JSON\uFF1A{0}",w.message))}u(t)||r(i("component.json \u5199\u7684\u4E0D\u662F\u4E00\u4E2A\u5BF9\u8C61")),A.test(e)||r(i("{0} \u4E0D\u80FD\u505A\u81EA\u5B9A\u4E49\u5757\u7684 id\uFF1A\u8303\u56F4\u548C\u540D\u5B57\u90FD\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",e));for(let w of e.split("/"))at.has(w)&&r(i("{0} \u4E0D\u80FD\u505A\u81EA\u5B9A\u4E49\u5757\u7684 id\uFF1A{1} \u662F Windows \u7559\u7ED9\u8BBE\u5907\u7684\u540D\u5B57",e,w));if(t.id!==e&&r(i("\u6E05\u5355\u7684 id \u662F {0}\uFF0C\u548C\u5B83\u7684\u6587\u4EF6\u5939 {1} \u4E0D\u4E00\u6837",String(t.id),e)),le(t,["apiVersion"]),(!Number.isInteger(t.apiVersion)||t.apiVersion<1)&&r(i("apiVersion \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570")),t.apiVersion!==se)throw ue(i("\u8FD9\u4E2A\u81EA\u5B9A\u4E49\u5757\u8981 apiVersion {0}\uFF0C\u8FD9\u4E00\u7248 Gallery \u53EA\u652F\u6301 {1}",t.apiVersion,se),{disabled:!0,version:b(t.version)?t.version:null});E(t,pt),le(t,["version","name","description","parts"]),b(t.version)||r(i("{0} \u8981\u5199\u6210\u6587\u5B57","version")),v(t.name,"name"),v(t.description,"description"),t.words!==void 0&&typeof t.words!="string"&&r(i("{0} \u8981\u5199\u6210\u6587\u5B57","words")),u(t.parts)||r(i("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","parts"));for(let[w,$]of Object.entries(t.parts))Pt(w,$);let o=Dt(t.runtime,e),{kit:f,own:c}=Vt(t.assets,n);t.markdown!==void 0&&!jt.includes(t.markdown)&&r(i("markdown \u53EA\u80FD\u662F parts \u6216 text")),t.schema!==void 0&&!(Number.isInteger(t.schema)&&t.schema>=1)&&r(i("schema \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570"));let d=Mt(t.places);Gt(d,t.parts);let a=Ft(t.card),l=Rt(t.settings,t.parts),p=Kt(t.needs),h=ye(n,M);return h&&ge(h,M),{id:e,match:Ze(e),parts:Nt(t.parts),...o?{runtime:o}:{},...t.schema!==void 0?{schema:t.schema}:{},apiVersion:t.apiVersion,version:t.version,name:t.name,description:t.description,words:t.words??"",assets:f,markdown:t.markdown??"parts",places:d,card:a,settings:l,needs:p,files:[...new Set([...we.filter(w=>j(n,w)),...c])],template:h&&be(h),folder:n,definition:S(w=>w.update(s)),stamp:W(n,V(c))}}function Wt(e,n){try{let s=ye(n,I);return s||r(i("\u8BFB\u4E0D\u51FA component.json")),_e(s)||r(i("{0} \u4E0D\u662F UTF-8 \u7F16\u7801\uFF1A\u8BF7\u5B58\u6210 UTF-8",I)),ge(s,I),Ut(e,n,be(s))}catch(s){let t=nt(s),o=S(f=>f.update(`${W(n,V([]))} ${JSON.stringify(t)}`));return{id:e.toLowerCase(),stamp:o,problem:t,disabled:s.disabled===!0,version:s.version??null}}}var P=()=>lt().root,Bt=/^[a-z0-9][a-z0-9-]*(?:\/[a-z0-9][a-z0-9-]*)?$/,x=(e,n)=>[...new Set(Array.isArray(e)?e.filter(s=>typeof s=="string"&&n.test(s)):[])],Jt=e=>Object.fromEntries(Object.entries(u(e)?e:{}).filter(([n])=>A.test(n)).map(([n,s])=>[n,x(s,me)]).filter(([,n])=>n.length>0)),Zt=e=>Object.fromEntries(Object.entries(u(e)?e:{}).filter(([n,s])=>he.test(n)&&typeof s?.enabled=="boolean").map(([n,s])=>[n,s.enabled])),C=e=>{let n=Zt(e?.components?.packs);return{hidden:x(e?.components?.hidden,Bt),disabled:x(e?.components?.disabled,A),shown:x(e?.components?.shown,A),unlisted:x(e?.components?.unlisted,A),net:Jt(e?.components?.net),packs:n,packsOff:Object.keys(n).filter(s=>n[s]===!1).sort()}},B=i("gallery.json \u8BFB\u4E0D\u51FA\u6765\uFF1A\u6539\u597D\u8FD9\u4E2A\u6587\u4EF6\u540E\u518D\u8BD5"),qt=i("gallery.json \u4E0D\u662F Gallery \u7684\u6587\u4EF6");function L(e){if(e===null)return{value:null};let{value:n,ours:s,reads:t}=ft(e);return s?{value:n}:{problem:t?qt:B}}function ke(e){try{return L(_(G(e).marker,"utf8"))}catch(n){return n.code==="ENOENT"?L(null):{problem:B}}}var On=(e=P())=>C(ke(e).value),Yt=["EPERM","EACCES","EBUSY","EROFS"];async function $n(e,{id:n,hidden:s,shown:t,disabled:o,unlisted:f,net:c,pack:d,enabled:a}){let l=G(e).marker,p=await Le.readFile(l,"utf8").catch(m=>{if(m.code==="ENOENT")return null;r(B)}),{value:h,problem:w}=L(p);w&&r(w);let $=(m,Y)=>Y===void 0?m:Y?[...new Set([...m,n])]:m.filter(Ie=>Ie!==n),{hidden:Ne,disabled:je,shown:ze,unlisted:Te}=C(h),g=u(h?.components)?h.components:{},Z=$(ze,t),q=$(Te,f),z={...g,hidden:$(Ne,s),disabled:$(je,o),...Z.length>0||Object.hasOwn(g,"shown")?{shown:Z}:{},...q.length>0||Object.hasOwn(g,"unlisted")?{unlisted:q}:{}};if(d!==void 0){let m=u(g.packs)?g.packs:{};z.packs={...m,[d]:{...u(m[d])?m[d]:{},enabled:a===!0}}}if(c!==void 0){let m={...u(g.net)?g.net:{}};c.length>0?m[n]=[...new Set(c)]:delete m[n],Object.keys(m).length>0?z.net=m:delete z.net}await He(l,`${JSON.stringify({...h??ct,components:z},null,2)}
4
+ `,{expect:p}).catch(m=>{throw Yt.includes(m.code)&&r(i("gallery.json \u5199\u4E0D\u8FDB\u53BB\uFF1A\u53EF\u80FD\u662F\u53EA\u8BFB\u7684\uFF0C\u6216\u88AB\u522B\u7684\u7A0B\u5E8F\u5360\u7740")),m})||r(i("gallery.json \u521A\u521A\u88AB\u6539\u8FC7\uFF1A\u518D\u8BD5\u4E00\u6B21"))}var Ht=e=>({...e,off:!0,disabled:!0,problem:i("\u5728\u8BBE\u7F6E\u91CC\u505C\u7528\u4E86"),stamp:S(n=>n.update(`${e.stamp} off`))}),D=C(null),Xt=({packages:e,problems:n,settings:s=D,packs:t=new Map})=>S(o=>{for(let{id:f,stamp:c}of[...e.values(),...n.values()].sort(U))o.update(`${f} ${c}
5
+ `);o.update(`hidden ${[...s.hidden].sort().join(" ")}
6
+ `),o.update(`shown ${[...s.shown].sort().join(" ")}
7
+ `),o.update(`unlisted ${[...s.unlisted??[]].sort().join(" ")}
8
+ `),o.update(`net ${Oe(s).join(" ")}
9
+ `),o.update(`packs off ${(s.packsOff??[]).join(" ")}
10
+ `);for(let[f,c]of[...t].sort(([d],[a])=>d<a?-1:1))o.update(`pack ${f} ${JSON.stringify(c)}
11
+ `);o.update(`settings ${s.problem?.message??""}
12
+ `)}),Oe=({net:e={}})=>Object.entries(e).flatMap(([n,s])=>s.map(t=>`${n}@${t}`)).sort();function Qt(e,n){let{value:s,problem:t}=ke(e);return t?{hidden:n.hidden,disabled:n.disabled,shown:n.shown??[],unlisted:n.unlisted??[],net:n.net??{},packs:n.packs??{},packsOff:n.packsOff??[],problem:t}:C(s)}var R=null,$e=[],En=(e,n=["gallery"])=>{R=e,$e=[...n]};function en(e=P(),n=D,{on:s=null}={}){let t=Qt(e,n),o=new Map,f=new Map,c=dt(e),d=c.map(({id:l})=>l).filter(l=>$e.includes(l.split("/")[0]));if(R&&d.length>0)try{R(e,d)}catch{}for(let{id:l,folder:p}of c){let h=Wt(l,p);(h.problem?f:o).set(h.id,h)}for(let l of o.keys())f.delete(l);for(let l of t.disabled)!o.has(l)||l===s||(f.set(l,Ht(o.get(l))),o.delete(l));let a=tn(e,c.map(({id:l})=>l.split("/")[0]));return{packages:o,problems:f,settings:t,packs:a,stamp:Xt({packages:o,problems:f,settings:t,packs:a})}}function tn(e,n=[]){let{components:s}=G(e),t=[];try{t=Me(s).filter(f=>he.test(f)&&Ce(k.join(s,f,ne)))}catch{}let o=new Map;for(let f of[...new Set([...n,...t])].sort()){let c=null;try{c=f===it?ot.name:rt(_(k.join(s,f,ne),"utf8")).name}catch{}o.set(f,c)}return o}var N=new Map;function Sn(e=P()){let n=k.resolve(e);return N.has(n)||N.set(n,en(n)),N.get(n)}var xn=(e,n)=>{N.set(k.resolve(e),n)},An=(e=P())=>{N.delete(k.resolve(e))},fe=(e,n)=>tt(e,()=>st(n)),J=e=>({zh:fe("zh",e),en:fe("en",e)}),Nn=({settings:e})=>e.problem?J(e.problem):null,Ee=(e,n)=>e.problem?e.disabled?"disabled":"broken":Ye(e.id,n,e.places),Se=({id:e,match:n,parts:s,runtime:t,schema:o,needs:f,card:c})=>({id:e,match:n,parts:s,...t?{runtime:t}:{},...o!==void 0?{schema:o}:{},...f?.length?{needs:f}:{},...c?.consent?{consent:c.consent}:{}}),jn=({packages:e,problems:n})=>[...[...e.values()].map(Se),...[...n.values()].map(({id:s,problem:t})=>({id:s,problem:J(t)}))],nn=e=>`DocKit.describe(${JSON.stringify(e)});`.replace(/</g,"\\u003c"),K=({id:e,stamp:n},s)=>`/__gallery/components/${e}/${s}?v=${n}`;function sn(e){let n=`${Be}="${e.id}"`,s=t=>e.files.includes(t);return{styles:s("style.css")?[`<link rel="stylesheet" href="${K(e,"style.css")}" ${n}>`]:[],scripts:[`<script ${n}>${nn({...Se(e),...s("kit.js")?{script:!0}:{}})}</script>`,...s("kit.js")?[`<script src="${K(e,"kit.js")}" ${n}></script>`]:[]]}}var zn=({folder:e},n)=>j(e,n),Tn=({folder:e,files:n})=>W(e,V(n));function de(e,n){let s=X(e,{sourceCodeLocationInfo:!0}).childNodes.filter(o=>o.tagName||o.nodeName==="#text"&&o.value.trim()),[t]=s;return s.length===1&&t.tagName&&Re(t)&&Xe(t,pe)===n&&t.sourceCodeLocation.endTag?t:null}function on(e,n){let s=de(e,n),t=s&&H(s),o=t&&de(t,n);return o?{markup:t,root:o}:null}function xe({id:e,template:n,parts:s}){if(!n)return{};let t=on(n,e);if(!t)return{problem:i("template.html \u8981\u662F\u8FD9\u4E2A\u81EA\u5B9A\u4E49\u5757\u7684\u4E00\u4E2A\u5B9E\u4F8B\uFF0C\u6709\u81EA\u5DF1\u7684\u7ED3\u675F\u6807\u7B7E\uFF0C\u6B64\u5916\u4EC0\u4E48\u90FD\u6CA1\u6709")};let o=[];if(Qe({childNodes:[t.root]},c=>{qe(c.tagName,c.attrs)&&o.push(c.tagName)}),o.length>0)return{problem:i("template.html \u91CC\u7684 <{0}> \u8FDB\u4E0D\u4E86\u65B0\u5EFA\u7684\u5757\uFF1A\u811A\u672C\u3001\u4E8B\u4EF6\u3001\u6837\u5F0F\u548C Gallery \u81EA\u5DF1\u7684\u6807\u8BB0\u90FD\u4E0D\u5199\u5728\u6A21\u677F\u91CC",o[0])};let f=Object.entries(s).find(([,c])=>{let d=Ue(t.root,c.at).length;return d<(c.optional?0:c.min??1)||d>(c.edit==="flow"?1:c.max??1/0)});return f?{problem:i("template.html \u7684 {0} \u548C\u6E05\u5355\u5199\u7684\u6570\u76EE\u4E0D\u7B26",f[0])}:{markup:t.markup}}var In=e=>xe(e).problem??null,Ae=e=>xe(e).markup??null,vn=({packages:e,settings:n=D,packs:s=new Map})=>[...e.values()].sort(U).map(t=>({id:t.id,version:t.version,name:t.name,description:t.description,words:t.words,definition:t.definition,stamp:t.stamp,template:Ae(t),preview:t.files.includes("preview.svg")?K(t,"preview.svg"):null,state:Ee(t,n),places:t.places,needs:t.needs,settings:t.settings,markdown:t.markdown,assets:t.assets,tags:sn(t),pack:{id:t.id.split("/")[0],name:s.get(t.id.split("/")[0])??null}})),_n=({packages:e,problems:n,settings:s=D})=>[...e.values(),...n.values()].sort(U).map(t=>({id:t.id,pack:t.id.split("/")[0],version:t.version??null,name:t.name??null,description:t.description??null,state:Ee(t,s),reason:t.problem&&!t.off?J(t.problem):null,template:!!Ae(t),places:t.places??null,needs:t.needs??null,hidden:s.hidden.includes(t.id),shown:s.shown.includes(t.id),disabled:s.disabled.includes(t.id),unlisted:(s.unlisted??[]).includes(t.id),allowed:(s.net?.[t.id]??[]).filter(o=>et(t.needs).includes(o)),menu:Je(t.places,{...s,disabled:[],unlisted:[],packsOff:[]},t.id)})),Pn=e=>`settings ${e.hidden.join(",")} ${e.disabled.join(",")} ${e.shown.join(",")} ${Oe(e).join(",")} ${(e.unlisted??[]).join(",")} ${(e.packsOff??[]).join(",")}`;export{$t as a,On as b,$n as c,Xt as d,En as e,en as f,Sn as g,xn as h,An as i,fe as j,Nn as k,jn as l,nn as m,K as n,sn as o,zn as p,Tn as q,on as r,In as s,Ae as t,vn as u,_n as v,Pn as w};