@heycys/gallery 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) 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/icon/page.mjs +6 -4
  8. package/browser/editor/components/icons.mjs +5 -2
  9. package/browser/editor/components/image/index.mjs +2 -0
  10. package/browser/editor/components/image/page.mjs +172 -90
  11. package/browser/editor/components/installed/index.mjs +6 -2
  12. package/browser/editor/components/installed/page.mjs +80 -13
  13. package/browser/editor/components/media/icons.mjs +13 -8
  14. package/browser/editor/components/media/page.mjs +5 -3
  15. package/browser/editor/components/media/toolbar.mjs +12 -3
  16. package/browser/editor/components/paragraph/index.mjs +4 -3
  17. package/browser/editor/components/registry.mjs +17 -5
  18. package/browser/editor/components/table/index.mjs +4 -2
  19. package/browser/editor/page/after/index.mjs +288 -0
  20. package/browser/editor/page/align.mjs +91 -0
  21. package/browser/editor/page/beside.mjs +5 -6
  22. package/browser/editor/page/block-menu/index.mjs +6 -3
  23. package/browser/editor/page/blocks.mjs +3 -1
  24. package/browser/editor/page/board/hint.mjs +64 -27
  25. package/browser/editor/page/board/index.mjs +160 -71
  26. package/browser/editor/page/board/motion.mjs +177 -0
  27. package/browser/editor/page/board/settings.mjs +4 -3
  28. package/browser/editor/page/clipboard/import/read.mjs +20 -2
  29. package/browser/editor/page/clipboard/index.mjs +10 -3
  30. package/browser/editor/page/clipboard/own/blocks.mjs +3 -4
  31. package/browser/editor/page/clipboard/own/describe.mjs +6 -2
  32. package/browser/editor/page/commit.mjs +2 -2
  33. package/browser/editor/page/core.mjs +3 -1
  34. package/browser/editor/page/custom-page.mjs +15 -11
  35. package/browser/editor/page/editor.mjs +31 -14
  36. package/browser/editor/page/history.mjs +19 -4
  37. package/browser/editor/page/insert/index.mjs +20 -22
  38. package/browser/editor/page/menu.mjs +15 -7
  39. package/browser/editor/page/page-objects.mjs +3 -7
  40. package/browser/editor/page/present-links.mjs +5 -4
  41. package/browser/editor/page/present-shell.mjs +63 -0
  42. package/browser/editor/page/selection/index.mjs +10 -2
  43. package/browser/editor/page/table/binding.mjs +87 -0
  44. package/browser/editor/page/table/icons.mjs +0 -2
  45. package/browser/editor/page/table/index.mjs +10 -14
  46. package/browser/editor/page/table/views.mjs +5 -52
  47. package/browser/editor/page/table/widths.mjs +82 -10
  48. package/browser/editor/page/typing/index.mjs +44 -12
  49. package/browser/editor/page/typing/leave.mjs +19 -5
  50. package/browser/shared/block-packs.mjs +23 -8
  51. package/browser/shared/component-catalog.mjs +15 -8
  52. package/browser/shared/component-source.mjs +3 -1
  53. package/browser/shared/components/heading.mjs +2 -1
  54. package/browser/shared/components/installed.mjs +1 -1
  55. package/browser/shared/components/page.mjs +2 -0
  56. package/browser/shared/components/paragraph.mjs +8 -1
  57. package/browser/shared/components/table.mjs +1 -0
  58. package/browser/shared/document-copy.mjs +43 -0
  59. package/browser/shared/drafts.mjs +10 -3
  60. package/browser/shared/emoji/icon-value.mjs +2 -2
  61. package/browser/shared/emoji/line-icons.mjs +37 -0
  62. package/browser/shared/extensions.mjs +83 -7
  63. package/browser/shared/http.mjs +9 -0
  64. package/browser/shared/i18n/en.mjs +50 -17
  65. package/browser/shared/outline-shape.mjs +6 -0
  66. package/browser/shared/outline.mjs +165 -12
  67. package/browser/shared/pack-manifest.mjs +12 -1
  68. package/browser/shared/pages.mjs +169 -57
  69. package/browser/shared/pinyin.mjs +92 -0
  70. package/browser/shared/present-step.mjs +17 -0
  71. package/browser/shared/sidebar-head.mjs +70 -0
  72. package/browser/shared/web-links.mjs +5 -0
  73. package/browser/shared/workspace-columns.mjs +11 -7
  74. package/dist/{chunk-N7AZZLGT.mjs → chunk-2GKGEVMR.mjs} +29 -24
  75. package/dist/chunk-2OHANJ6Q.mjs +2 -0
  76. package/dist/{chunk-HYMEEXKN.mjs → chunk-2RKIHJI2.mjs} +1 -1
  77. package/dist/{chunk-742D2WWJ.mjs → chunk-36FIRJIF.mjs} +2 -2
  78. package/dist/{chunk-BPL64HGA.mjs → chunk-3A5I2GJK.mjs} +1 -1
  79. package/dist/{chunk-RFDZXFJF.mjs → chunk-3OFXMN6N.mjs} +1 -1
  80. package/dist/chunk-46ACXOU5.mjs +2 -0
  81. package/dist/{chunk-PUOQ65NC.mjs → chunk-4AMTKWDO.mjs} +1 -1
  82. package/dist/{chunk-VTKNEYT3.mjs → chunk-4DNHHJSL.mjs} +1 -1
  83. package/dist/chunk-5DPABPBI.mjs +2 -0
  84. package/dist/chunk-5IIH335D.mjs +3 -0
  85. package/dist/chunk-5L26JUYA.mjs +2 -0
  86. package/dist/{chunk-3NJACR4W.mjs → chunk-5MEXZ2UF.mjs} +1 -1
  87. package/dist/{chunk-ZHEHPMBK.mjs → chunk-6MPKCH3P.mjs} +1 -1
  88. package/dist/{chunk-C564NU2H.mjs → chunk-74RPP2M2.mjs} +1 -1
  89. package/dist/chunk-7M2BQQGZ.mjs +2 -0
  90. package/dist/{chunk-VXACTLO3.mjs → chunk-7M7UPWU6.mjs} +1 -1
  91. package/dist/{chunk-ZB4H7ZN4.mjs → chunk-7N2LPG33.mjs} +1 -1
  92. package/dist/{chunk-UBBRTJ2R.mjs → chunk-7XDYK3UC.mjs} +1 -1
  93. package/dist/chunk-AEMVZYZQ.mjs +166 -0
  94. package/dist/{chunk-POQSE4C2.mjs → chunk-AFGUR7SY.mjs} +1 -1
  95. package/dist/{chunk-QKXMPUXC.mjs → chunk-AMDGVDNV.mjs} +1 -1
  96. package/dist/{chunk-KTKHRC6H.mjs → chunk-ASAXY2DJ.mjs} +1 -1
  97. package/dist/{chunk-NVRNLK25.mjs → chunk-BYSF5UMM.mjs} +2 -2
  98. package/dist/{chunk-U3SSPL4K.mjs → chunk-CCSGFCLZ.mjs} +1 -1
  99. package/dist/{chunk-NWFBE2YA.mjs → chunk-CG3UHDKH.mjs} +1 -1
  100. package/dist/chunk-CPS4SRPF.mjs +5 -0
  101. package/dist/{chunk-B4P2CM2J.mjs → chunk-CZ5KJSGK.mjs} +1 -1
  102. package/dist/chunk-DAMVDXR3.mjs +2 -0
  103. package/dist/{chunk-NG375ILQ.mjs → chunk-DH6GMDNN.mjs} +1 -1
  104. package/dist/chunk-DHB7UZ7F.mjs +3 -0
  105. package/dist/{chunk-MHW7ZKOU.mjs → chunk-DKR7LFIY.mjs} +1 -1
  106. package/dist/chunk-DLFZJJEE.mjs +2 -0
  107. package/dist/{chunk-6EZ7FNIK.mjs → chunk-F4ZA6JRZ.mjs} +1 -1
  108. package/dist/{chunk-6VTU6KEO.mjs → chunk-FCK6NXON.mjs} +1 -1
  109. package/dist/{chunk-ZWPMCK7P.mjs → chunk-FX42XU6J.mjs} +1 -1
  110. package/dist/chunk-FXQBADMN.mjs +5 -0
  111. package/dist/{chunk-W3BGBJQW.mjs → chunk-G4YP7GVC.mjs} +1 -1
  112. package/dist/{chunk-V6XZ4VIR.mjs → chunk-GWOYMENX.mjs} +1 -1
  113. package/dist/chunk-HATA2W7X.mjs +2 -0
  114. package/dist/{chunk-YI43RG4P.mjs → chunk-HBAUKKQH.mjs} +1 -1
  115. package/dist/{chunk-MAFIGVXY.mjs → chunk-HM4E43VM.mjs} +1 -1
  116. package/dist/{chunk-CRJEG7MT.mjs → chunk-JI6T3A4Y.mjs} +1 -1
  117. package/dist/{chunk-NFMCP2HI.mjs → chunk-JJNRIFND.mjs} +2 -2
  118. package/dist/chunk-JL6R4FG4.mjs +4 -0
  119. package/dist/{chunk-UMHUSOPJ.mjs → chunk-JXLSHVJ2.mjs} +1 -1
  120. package/dist/{chunk-FJYN7RTH.mjs → chunk-KFZBYDIS.mjs} +1 -1
  121. package/dist/{chunk-ZTHICSSF.mjs → chunk-KH24LWAT.mjs} +1 -1
  122. package/dist/{chunk-RKPWLGZ3.mjs → chunk-KUILYI7H.mjs} +1 -1
  123. package/dist/{chunk-RMECZA2K.mjs → chunk-L7W624FD.mjs} +1 -1
  124. package/dist/chunk-LE44MD3O.mjs +4 -0
  125. package/dist/{chunk-4K5KC6V2.mjs → chunk-LV24RY2E.mjs} +1 -1
  126. package/dist/{chunk-43B75J5T.mjs → chunk-MKTX5PGV.mjs} +1 -1
  127. package/dist/{chunk-LKX55H76.mjs → chunk-NAGMRVW4.mjs} +1 -1
  128. package/dist/{chunk-D4CKRD3V.mjs → chunk-NFABH3QW.mjs} +2 -2
  129. package/dist/{chunk-PVER7LSC.mjs → chunk-NIW7F7LU.mjs} +2 -2
  130. package/dist/{chunk-PAREWQGB.mjs → chunk-NWRZXELO.mjs} +1 -1
  131. package/dist/{chunk-OJKMINIU.mjs → chunk-OU3S466R.mjs} +15 -15
  132. package/dist/{chunk-5ZJA7CXT.mjs → chunk-PAFSFVYB.mjs} +1 -1
  133. package/dist/chunk-QCEATQC4.mjs +2 -0
  134. package/dist/{chunk-Y34NR5JL.mjs → chunk-QJ3TFJLQ.mjs} +1 -1
  135. package/dist/{chunk-IA4PSIMD.mjs → chunk-QK3VISCA.mjs} +1 -1
  136. package/dist/{chunk-ZUNVAXLH.mjs → chunk-QXVNUASA.mjs} +1 -1
  137. package/dist/{chunk-GRAXKKG4.mjs → chunk-QZ35UAB4.mjs} +1 -1
  138. package/dist/{chunk-UGWYKHBL.mjs → chunk-S2Y7VI4H.mjs} +2 -2
  139. package/dist/{chunk-OW5NWPOJ.mjs → chunk-SAHS56QM.mjs} +1 -1
  140. package/dist/{chunk-QOUEFUCH.mjs → chunk-SOD23RGL.mjs} +1 -1
  141. package/dist/chunk-TDWJKOLN.mjs +2 -0
  142. package/dist/{chunk-V6RIYQZZ.mjs → chunk-TOE6DPLH.mjs} +1 -1
  143. package/dist/chunk-UGO5N3EI.mjs +15 -0
  144. package/dist/{chunk-Q47PLKIJ.mjs → chunk-UGWMMEJ5.mjs} +1 -1
  145. package/dist/{chunk-NWR2LT5B.mjs → chunk-V5JRSGZF.mjs} +1 -1
  146. package/dist/{chunk-BZ5RAF7L.mjs → chunk-VA3KAQZD.mjs} +1 -1
  147. package/dist/chunk-VG5JEIUQ.mjs +12 -0
  148. package/dist/{chunk-UNOYVIYR.mjs → chunk-VGTMLQWZ.mjs} +1 -1
  149. package/dist/chunk-VKSRM7EY.mjs +22 -0
  150. package/dist/{chunk-YQGT4AB2.mjs → chunk-VNUWREXU.mjs} +1 -1
  151. package/dist/{chunk-AGDILNWB.mjs → chunk-VPVOAJ7X.mjs} +1 -1
  152. package/dist/{chunk-HLYV7RIH.mjs → chunk-WCWYNFDF.mjs} +1 -1
  153. package/dist/chunk-WTEGUPFG.mjs +16 -0
  154. package/dist/{chunk-N76HWBA3.mjs → chunk-XKOHV4H6.mjs} +1 -1
  155. package/dist/{chunk-HMYTM3GT.mjs → chunk-XMKHCUI6.mjs} +1 -1
  156. package/dist/{chunk-OUUP3WKT.mjs → chunk-XQRUG4G3.mjs} +1 -1
  157. package/dist/{chunk-32ZUEFZ7.mjs → chunk-YBB5LWZK.mjs} +1 -1
  158. package/dist/{chunk-SX4LJYT6.mjs → chunk-YFJU3O7G.mjs} +1 -1
  159. package/dist/chunk-YPPJVDQI.mjs +2 -0
  160. package/dist/chunk-ZANMKAWS.mjs +2 -0
  161. package/dist/{chunk-6QBHU4DF.mjs → chunk-ZCP7BTOZ.mjs} +1 -1
  162. package/dist/{chunk-ERLAIBOA.mjs → chunk-ZEY2RLBT.mjs} +2 -2
  163. package/dist/{chunk-SQ6Y2ZMA.mjs → chunk-ZO7SFB2E.mjs} +2 -2
  164. package/dist/cli.mjs +1 -1
  165. package/dist/server.mjs +1 -1
  166. package/dist/worker.mjs +1 -1
  167. package/kit/board.css +5 -5
  168. package/kit/code.js +15 -15
  169. package/kit/math.js +1 -1
  170. package/kit/report.css +123 -44
  171. package/kit/runtime.js +45 -7
  172. package/kit/tables.js +2 -0
  173. package/kit/ui.js +2 -0
  174. package/package.json +1 -1
  175. package/packs/gallery/chart-view/kit.js +3 -3
  176. package/packs/gallery/chart-view/writing.md +1 -1
  177. package/packs/gallery/countdown/component.json +1 -1
  178. package/packs/gallery/countdown/kit.js +89 -29
  179. package/packs/gallery/countdown/preview.svg +1 -1
  180. package/packs/gallery/countdown/style.css +88 -100
  181. package/packs/gallery/countdown/writing.md +2 -2
  182. package/packs/gallery/habit/component.json +3 -3
  183. package/packs/gallery/habit/kit.js +114 -75
  184. package/packs/gallery/habit/preview.svg +1 -1
  185. package/packs/gallery/habit/style.css +133 -205
  186. package/packs/gallery/habit/writing.md +2 -2
  187. package/packs/gallery/heatmap/component.json +2 -2
  188. package/packs/gallery/heatmap/kit.js +335 -173
  189. package/packs/gallery/heatmap/preview.svg +1 -1
  190. package/packs/gallery/heatmap/style.css +158 -170
  191. package/packs/gallery/heatmap/writing.md +2 -2
  192. package/packs/gallery/kanban/kit.js +3 -3
  193. package/packs/gallery/kanban/writing.md +1 -1
  194. package/packs/gallery/metric/kit.js +3 -3
  195. package/packs/gallery/metric/writing.md +1 -1
  196. package/packs/gallery/note/component.json +3 -3
  197. package/packs/gallery/note/kit.js +40 -13
  198. package/packs/gallery/note/preview.svg +1 -1
  199. package/packs/gallery/note/style.css +51 -30
  200. package/packs/gallery/note/writing.md +2 -2
  201. package/packs/gallery/recent/component.json +2 -2
  202. package/packs/gallery/recent/kit.js +141 -86
  203. package/packs/gallery/recent/preview.svg +1 -1
  204. package/packs/gallery/recent/style.css +53 -126
  205. package/packs/gallery/recent/writing.md +2 -2
  206. package/packs/gallery/static/component.json +2 -2
  207. package/packs/gallery/static/preview.svg +1 -1
  208. package/packs/gallery/static/style.css +99 -66
  209. package/packs/gallery/static/writing.md +2 -2
  210. package/packs/gallery/stats/component.json +3 -3
  211. package/packs/gallery/stats/kit.js +253 -72
  212. package/packs/gallery/stats/preview.svg +1 -1
  213. package/packs/gallery/stats/style.css +64 -142
  214. package/packs/gallery/stats/writing.md +2 -2
  215. package/packs/gallery/today/component.json +2 -2
  216. package/packs/gallery/today/kit.js +62 -27
  217. package/packs/gallery/today/preview.svg +1 -1
  218. package/packs/gallery/today/style.css +101 -72
  219. package/packs/gallery/today/writing.md +2 -2
  220. package/packs/gallery/todos/component.json +1 -1
  221. package/packs/gallery/todos/kit.js +218 -71
  222. package/packs/gallery/todos/preview.svg +1 -1
  223. package/packs/gallery/todos/style.css +170 -223
  224. package/packs/gallery/todos/writing.md +1 -1
  225. package/packs/gallery/weather/component.json +2 -2
  226. package/packs/gallery/weather/kit.js +165 -90
  227. package/packs/gallery/weather/preview.svg +1 -1
  228. package/packs/gallery/weather/style.css +100 -218
  229. package/packs/gallery/weather/writing.md +1 -1
  230. package/packs/gallery-soft/countdown/component.json +18 -0
  231. package/packs/gallery-soft/countdown/example.html +3 -0
  232. package/packs/gallery-soft/countdown/kit.js +206 -0
  233. package/packs/gallery-soft/countdown/preview.svg +1 -0
  234. package/packs/gallery-soft/countdown/style.css +211 -0
  235. package/packs/gallery-soft/countdown/template.html +3 -0
  236. package/packs/gallery-soft/countdown/writing.md +24 -0
  237. package/packs/gallery-soft/habit/component.json +14 -0
  238. package/packs/gallery-soft/habit/example.html +3 -0
  239. package/packs/gallery-soft/habit/kit.js +366 -0
  240. package/packs/gallery-soft/habit/preview.svg +1 -0
  241. package/packs/gallery-soft/habit/style.css +251 -0
  242. package/packs/gallery-soft/habit/template.html +3 -0
  243. package/packs/gallery-soft/habit/writing.md +23 -0
  244. package/packs/gallery-soft/heatmap/component.json +18 -0
  245. package/packs/gallery-soft/heatmap/example.html +3 -0
  246. package/packs/gallery-soft/heatmap/kit.js +498 -0
  247. package/packs/gallery-soft/heatmap/preview.svg +1 -0
  248. package/packs/gallery-soft/heatmap/style.css +181 -0
  249. package/packs/gallery-soft/heatmap/template.html +3 -0
  250. package/packs/gallery-soft/heatmap/writing.md +23 -0
  251. package/packs/gallery-soft/note/component.json +14 -0
  252. package/packs/gallery-soft/note/example.html +3 -0
  253. package/packs/gallery-soft/note/kit.js +162 -0
  254. package/packs/gallery-soft/note/preview.svg +1 -0
  255. package/packs/gallery-soft/note/style.css +148 -0
  256. package/packs/gallery-soft/note/template.html +3 -0
  257. package/packs/gallery-soft/note/writing.md +20 -0
  258. package/packs/gallery-soft/recent/component.json +13 -0
  259. package/packs/gallery-soft/recent/example.html +1 -0
  260. package/packs/gallery-soft/recent/kit.js +335 -0
  261. package/packs/gallery-soft/recent/preview.svg +1 -0
  262. package/packs/gallery-soft/recent/style.css +160 -0
  263. package/packs/gallery-soft/recent/template.html +1 -0
  264. package/packs/gallery-soft/recent/writing.md +17 -0
  265. package/packs/gallery-soft/static/component.json +13 -0
  266. package/packs/gallery-soft/static/example.html +12 -0
  267. package/packs/gallery-soft/static/preview.svg +1 -0
  268. package/packs/gallery-soft/static/style.css +186 -0
  269. package/packs/gallery-soft/static/template.html +1 -0
  270. package/packs/gallery-soft/static/writing.md +20 -0
  271. package/packs/gallery-soft/stats/component.json +13 -0
  272. package/packs/gallery-soft/stats/example.html +1 -0
  273. package/packs/gallery-soft/stats/kit.js +341 -0
  274. package/packs/gallery-soft/stats/preview.svg +1 -0
  275. package/packs/gallery-soft/stats/style.css +119 -0
  276. package/packs/gallery-soft/stats/template.html +1 -0
  277. package/packs/gallery-soft/stats/writing.md +13 -0
  278. package/packs/gallery-soft/today/component.json +12 -0
  279. package/packs/gallery-soft/today/example.html +1 -0
  280. package/packs/gallery-soft/today/kit.js +222 -0
  281. package/packs/gallery-soft/today/preview.svg +1 -0
  282. package/packs/gallery-soft/today/style.css +178 -0
  283. package/packs/gallery-soft/today/template.html +1 -0
  284. package/packs/gallery-soft/today/writing.md +16 -0
  285. package/packs/gallery-soft/todos/component.json +19 -0
  286. package/packs/gallery-soft/todos/example.html +3 -0
  287. package/packs/gallery-soft/todos/kit.js +527 -0
  288. package/packs/gallery-soft/todos/preview.svg +1 -0
  289. package/packs/gallery-soft/todos/style.css +212 -0
  290. package/packs/gallery-soft/todos/template.html +3 -0
  291. package/packs/gallery-soft/todos/writing.md +32 -0
  292. package/packs/gallery-soft/weather/component.json +19 -0
  293. package/packs/gallery-soft/weather/example.html +3 -0
  294. package/packs/gallery-soft/weather/kit.js +411 -0
  295. package/packs/gallery-soft/weather/preview.svg +1 -0
  296. package/packs/gallery-soft/weather/style.css +185 -0
  297. package/packs/gallery-soft/weather/template.html +3 -0
  298. package/packs/gallery-soft/weather/writing.md +28 -0
  299. package/release.json +10 -10
  300. package/skill/SKILL.md +15 -14
  301. package/skill/references/building-blocks.md +4 -4
  302. package/skill/references/extensions.md +11 -7
  303. package/skill/references/pages-and-data.md +13 -9
  304. package/skill/references/writing-html.md +2 -0
  305. package/web/assets/index-BHC5ZOMh.js +15 -0
  306. package/web/assets/index-xP0uw3a0.css +1 -0
  307. package/web/index.html +2 -2
  308. package/dist/chunk-2NRBY6AJ.mjs +0 -2
  309. package/dist/chunk-35NQ4PLQ.mjs +0 -2
  310. package/dist/chunk-3KJHLHUO.mjs +0 -2
  311. package/dist/chunk-4AV456RQ.mjs +0 -2
  312. package/dist/chunk-5XYHDBJ5.mjs +0 -2
  313. package/dist/chunk-6A53MZYZ.mjs +0 -2
  314. package/dist/chunk-6EXH3ORZ.mjs +0 -166
  315. package/dist/chunk-BVEFGE4B.mjs +0 -2
  316. package/dist/chunk-D4EURAX4.mjs +0 -4
  317. package/dist/chunk-DQCE7TJY.mjs +0 -5
  318. package/dist/chunk-FWNRPMCJ.mjs +0 -12
  319. package/dist/chunk-FWW4CSAZ.mjs +0 -2
  320. package/dist/chunk-GY3FAUVM.mjs +0 -2
  321. package/dist/chunk-JVHHHGEA.mjs +0 -3
  322. package/dist/chunk-L7UP52JO.mjs +0 -2
  323. package/dist/chunk-NAMN3RAF.mjs +0 -2
  324. package/dist/chunk-PZDLJJTJ.mjs +0 -3
  325. package/dist/chunk-SXHBYZST.mjs +0 -16
  326. package/dist/chunk-TEZAWDSQ.mjs +0 -2
  327. package/dist/chunk-UFNYFFKO.mjs +0 -20
  328. package/dist/chunk-UKSHDZZ6.mjs +0 -2
  329. package/dist/chunk-VJPFVNNW.mjs +0 -15
  330. package/dist/chunk-VS3ZMVGX.mjs +0 -5
  331. package/web/assets/index-BK2e_07w.js +0 -13
  332. package/web/assets/index-CWFI83mF.css +0 -1
  333. /package/dist/{chunk-YEY3RSFQ.mjs → chunk-5MMN3N5J.mjs} +0 -0
  334. /package/dist/{chunk-UH4SIXTR.mjs → chunk-74UW7QSL.mjs} +0 -0
  335. /package/dist/{chunk-W7XHE4CT.mjs → chunk-EKGYYOSP.mjs} +0 -0
  336. /package/dist/{chunk-QAIHRH3I.mjs → chunk-KNZJT4ET.mjs} +0 -0
  337. /package/dist/{chunk-A55HN5OK.mjs → chunk-N3DSBH5S.mjs} +0 -0
  338. /package/dist/{chunk-QR6A54KJ.mjs → chunk-ZW2A6GBW.mjs} +0 -0
@@ -1,15 +0,0 @@
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 Kt,b as Ut}from"./chunk-PZDLJJTJ.mjs";import{a as Bt}from"./chunk-UMHUSOPJ.mjs";import{randomBytes as At}from"node:crypto";import y from"node:fs/promises";import m from"node:path";import{writeAtomic as J}from"../browser/shared/files.mjs";import{sendJson as H}from"../browser/shared/http.mjs";import{said as B,saying as Pt}from"../browser/shared/i18n/index.mjs";import{reportsDirectory as _e}from"../browser/shared/paths.mjs";import{moveDocument as Te,outlineAndFile as Ce,placeIn as wt,readOutline as Fe,validOutline as te,withOutlineLock as Je,writeOutline as Ge,writtenAs as Ye}from"../browser/shared/outline.mjs";import{DOCS as mt,isForeign as ee,isTop as pt,topOf as kt}from"../browser/shared/outline-shape.mjs";import{addDraft as ne,addWorkspace as We,draftEntry as Me,draftFacts as re,draftOf as Lt,findDraft as He,foreignMarker as Ve,projectChoices as Be,registeredIds as oe,workspaceNames as Ke,workspaceOf as X}from"../browser/shared/drafts.mjs";import{forgetSnapshot as ht,shownWorkspaces as Ue}from"../browser/shared/workspace-columns.mjs";import{nameStops as ze}from"../browser/shared/workspace-name.mjs";import{registerWorkspace as De,workspaceId as gt,workspaceKey as ie}from"../browser/shared/workspace-registry.mjs";import{spawn as Xt}from"node:child_process";import Se from"node:os";import Et from"node:path";import{NO_DEFAULT_TREE as ve}from"../browser/shared/drafts.mjs";import{said as zt}from"../browser/shared/i18n/index.mjs";import{packageRoot as be}from"../browser/shared/paths.mjs";import{answerOf as Dt,compareVersions as xe,galleryVersion as Ee,readAnnouncement as xt}from"../browser/shared/preview-server.mjs";import{isWorkspace as Ae,readRegistry as Pe,workspaceId as Le,workspaceKey as dt}from"../browser/shared/workspace-registry.mjs";var Qt={rename:["slug","title"],create:["title","description","language"]},Ie=9e4,Ne=f=>!["","0",void 0].includes(f);function Re(f,{platform:b=process.platform,env:l=process.env}={}){return Ne(l.GALLERY_NO_BROWSER)?{skip:"GALLERY_NO_BROWSER is set"}:b==="win32"?{command:Et.join(l.SystemRoot||l.windir||"C:\\Windows","explorer.exe"),args:[`/select,"${f}"`],verbatim:!0}:b==="darwin"?{command:"open",args:["-R",f]}:!l.DISPLAY&&!l.WAYLAND_DISPLAY?{skip:"no display here (neither DISPLAY nor WAYLAND_DISPLAY is set)"}:{command:"xdg-open",args:[Et.dirname(f)]}}function Zt(f,b){let l=Re(f,b);return l.skip?Promise.resolve({opened:!1,why:l.skip}):new Promise(L=>{let R;try{R=Xt(l.command,l.args,{detached:!0,stdio:"ignore",windowsHide:!1,windowsVerbatimArguments:!!l.verbatim})}catch(P){return L({opened:!1,why:P.code??P.message})}R.once("error",P=>L({opened:!1,why:P.code??P.message})),R.once("spawn",()=>{R.unref(),L({opened:!0})})})}function $e(f){let b=/^http:\/\/127\.0\.0\.1:(\d{1,5})$/.exec(String(f??"")),l=b?Number(b[1]):0;return l>0&&l<65536?l:null}function qt({root:f,changed:b=()=>{},log:l=()=>{},gallery:L=Et.join(be,"bin","gallery.mjs")}){let R=dt(f),P=new Map;function yt(p){let d={...process.env,[ve]:"1",GALLERY_NO_UPDATE_CHECK:"1"};return delete d.GALLERY_WORKSPACE,delete d.GALLERY_SERVER_KIND,d.GALLERY_VITE_CACHE_DIR&&(d.GALLERY_VITE_CACHE_DIR=`${d.GALLERY_VITE_CACHE_DIR}-${Le(p)}`),new Promise(v=>{let E=[],A;try{A=Xt(process.execPath,[L,"--workspace",p,"open","--no-browser"],{cwd:Se.homedir(),env:d,stdio:["ignore","pipe","pipe"],windowsHide:!0})}catch(j){return v({ok:!1,message:j.message})}A.stdout.on("data",j=>E.push(String(j))),A.stderr.on("data",j=>E.push(String(j)));let O=setTimeout(()=>A.kill(),Ie);A.once("error",j=>{clearTimeout(O),v({ok:!1,message:j.message})}),A.once("exit",j=>{clearTimeout(O);let $=E.join("").trim().split(/\r?\n/).filter(Boolean);v(j===0?{ok:!0}:{ok:!1,message:$.slice(-3).join(" ")||`gallery open ended with ${j}`})})})}async function lt(p){let d=await xt({reportsDirectory:p});return!d||await Dt(d,p,5e3)!=="yes"||d.kind!=="dev"&&xe(d.version,Ee)<0?null:{port:d.port,token:d.token,pid:d.pid}}async function G(p,{start:d=!0}={}){if(dt(p)===R)return{refused:"self",message:"\u8FD9\u662F\u5F53\u524D\u7684\u5DE5\u4F5C\u533A"};if(!Ae(p))return{refused:"workspace",message:zt("\u627E\u4E0D\u5230\u5B83\u6240\u5728\u7684\u5DE5\u4F5C\u533A\uFF1A{0} \u4E0D\u5728\u4E86",p)};let v=await lt(p);if(v||!d)return v??{refused:"start",message:"\u5B83\u6240\u5728\u5DE5\u4F5C\u533A\u7684\u670D\u52A1\u6CA1\u6709\u5728\u8FD0\u884C"};let E=dt(p);P.has(E)||(l(`starting the server of ${p}`),P.set(E,yt(p).finally(()=>P.delete(E))));let A=await P.get(E);return await lt(p)??{refused:"start",message:A.ok?"\u5B83\u6240\u5728\u5DE5\u4F5C\u533A\u7684\u670D\u52A1\u6CA1\u6709\u56DE\u7B54":zt("\u6CA1\u80FD\u542F\u52A8\u5B83\u6240\u5728\u5DE5\u4F5C\u533A\u7684\u670D\u52A1\uFF1A{0}",A.message)}}async function Ot(p,d,v){if(!Object.hasOwn(Qt,d))return[404,{ok:!1,reason:"unknown",message:"\u8FD9\u4E2A\u547D\u4EE4\u4E0D\u80FD\u8F6C\u7ED9\u522B\u7684\u5DE5\u4F5C\u533A"}];let E=await G(p);if(E.refused)return[409,{ok:!1,reason:E.refused,message:E.message}];let A=Object.fromEntries(Qt[d].filter(j=>v?.[j]!==void 0).map(j=>[j,v[j]])),O=`127.0.0.1:${E.port}`;try{let j=await fetch(`http://${O}/__gallery/workspace/${d}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${O}`,"X-Gallery-Token":E.token},body:JSON.stringify(A),signal:AbortSignal.timeout(3e4)}),$=await j.json().catch(()=>null);return $&&typeof $.ok=="boolean"?[j.status,$]:[502,{ok:!1,reason:"answer",message:"\u5B83\u6240\u5728\u5DE5\u4F5C\u533A\u7684\u670D\u52A1\u6CA1\u6709\u7ED9\u51FA\u7ED3\u679C"}]}catch{return[502,{ok:!1,reason:"answer",message:"\u5B83\u6240\u5728\u5DE5\u4F5C\u533A\u7684\u670D\u52A1\u6CA1\u6709\u56DE\u7B54"}]}}let S=new Map;async function W(p){let d=$e(p);if(d===null)return!1;let v=S.get(d);if(v&&Date.now()-v.at<6e4)return v.answer;let E=(async()=>{for(let{root:A}of Pe().workspaces){let O=await xt({reportsDirectory:A});if(O?.port===d&&await Dt(O,A,3e3)==="yes")return!0}return!1})();return S.set(d,{at:Date.now(),answer:E}),E}let q=new Map,C=new Map,K=new Set,c=!1;async function et(p,d,v){let E=new AbortController,A={controller:E,port:v.port};C.set(p,A);try{let O=await fetch(`http://127.0.0.1:${v.port}/__gallery/events?workspace=own`,{signal:E.signal});if(!O.ok||!O.body)return;K.has(p)&&b(d),K.add(p);let j=new TextDecoder,$="";for await(let jt of O.body){$+=j.decode(jt,{stream:!0});for(let I=$.indexOf(`
3
-
4
- `);I>=0;I=$.indexOf(`
5
-
6
- `)){let St=$.slice(0,I);$=$.slice(I+2),/^data: workspace /m.test(St)&&b(d)}}}catch{}finally{C.get(p)===A&&C.delete(p)}}async function U(){for(let[p,d]of C)q.has(p)||d.controller.abort();for(let[p,d]of q){if(c||C.has(p)||dt(d)===R)continue;let v=await xt({reportsDirectory:d});v&&!C.has(p)&&!c&&et(p,d,v)}}let F=Promise.resolve(),x=setInterval(()=>{F=F.then(U).catch(()=>{})},3e3);x.unref();function Y(p){q.clear();for(let[d,v]of p)v&&q.set(d,v);F=F.then(U).catch(()=>{})}function nt(){c=!0,clearInterval(x);for(let{controller:p}of C.values())p.abort();C.clear()}return{serverOf:G,forward:Ot,shellVouched:W,follow:Y,close:nt,get following(){return[...C.keys()]}}}import{LINK_FILE as It,linkStem as Qe,linkValue as at,ownAddress as Nt,readLinkText as Xe}from"../browser/shared/web-links.mjs";import{sameDirectory as Z}from"../browser/shared/preview-server.mjs";import{listReportSlugs as Ze,slugPattern as _}from"../browser/shared/reports.mjs";import{COMPONENTS_FOLDER as qe,DOCUMENT_FOLDERS as tn,PAGE_SLUG as en,SHARED_FOLDERS as Rt,defaultWorkspace as nn,documentDirectory as rn,documentFiles as st,ensureWorkspace as on,idHolder as an,isDocSlug as sn,layoutOf as ae,listTrash as cn,newDocSlug as $t,packageFolders as ln,pageSlug as un,readLink as _t,slugTaken as fn,trashIdPattern as se}from"../browser/shared/workspace.mjs";import{HOME as dn,listPages as wn,pageFiles as ct,readPageMeta as ce,renamePage as mn}from"../browser/shared/pages.mjs";import{listExtensions as pn}from"../browser/shared/extensions.mjs";import{effectiveLook as Tt,ownLookFor as kn,ownLookOf as hn,sameLook as gn,withLookField as le}from"../browser/shared/document-look.mjs";import{workspaceLook as Ct,writeWorkspaceLook as yn}from"../browser/shared/workspace-look.mjs";import{findIn as On,tidyQuery as jn}from"../browser/shared/search.mjs";var Sn=([f,b,l,...L])=>L.length?B("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}\uFF1B{2} \u7B49 {3} \u6761",f,b,l,L.length+3):l!==void 0?B("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}\uFF1B{2}",f,b,l):b!==void 0?B("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}",f,b):B("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}",f),ue=f=>f==="en"?"en":null,vn=32*1024*1024;async function V(f,b){for(let l=0;;l++)try{return await y.rename(f,b)}catch(L){if(!["EPERM","EBUSY","EACCES"].includes(L.code))throw L;if(l>=5)break;await new Promise(R=>setTimeout(R,60*(l+1)))}await y.cp(f,b,{recursive:!0,errorOnExist:!0,force:!1}),await y.rm(f,{recursive:!0,force:!0,maxRetries:5})}var bn=f=>m.resolve(f);function ar({edits:f,reports:b,reportsDirectory:l=_e,server:L={kind:"dev",version:null,stop:null},components:R=null,changed:P=()=>{},relayed:yt=P,index:lt=null,web:G=null,elsewhere:Ot=null}){let{trash:S}=ae(l),W=Ot??qt({root:l,changed:t=>{t&&ht(t),yt()}}),q=null,C=()=>q??=ze(),K=lt??Ut({root:l,read:Kt(f),draw:(t,e)=>b.words(t,e)}),c=(t,e,n)=>[t,{ok:!1,reason:e,...Pt(n)}],et=t=>y.readFile(t,"utf8").then(JSON.parse).catch(()=>null),U=t=>rn(t,l),F=t=>st(U(t)),x=t=>m.join(l,t),Y=t=>tt(st(x(t)).html),nt=t=>Promise.resolve(f.forgetChanges?.(t)).catch(()=>{}),p=async t=>{let e=await y.readdir(x(t),{withFileTypes:!0});if(!Rt.includes(t))return e.map(({name:r})=>r);let n=t===qe?new Set(ln(l).map(({id:r})=>r.split("/")[0])):new Set;return e.filter(r=>r.isFile()||tn.includes(r.name)&&!n.has(r.name)).map(({name:r})=>r)},d=async(t,e,n)=>{await y.mkdir(n,{recursive:!0});let r=[];try{for(let o of t)await V(m.join(e,o),m.join(n,o)),r.push(o)}catch(o){for(let i of r)await V(m.join(n,i),m.join(e,i));throw o}},v=async(t,e)=>{if(!Rt.includes(t))return V(x(t),e);await d(await p(t),x(t),e),await y.rmdir(x(t)).catch(()=>{})},E=async(t,e)=>Rt.includes(t)&&!await Y(t)&&(await Promise.all((await y.readdir(e)).map(n=>tt(m.join(x(t),n))))).every(n=>!n),A=async t=>await et(st(t).json)??{},O=async t=>{let{title:e=t,description:n="",type:r,instructions:o,icon:i,look:a}=await A(U(t)),s=o===!0?{}:Tt(a,Ct(l));return{slug:t,title:e,description:n,...r?{type:r}:{},...typeof i=="string"&&i?{icon:i}:{},...o===!0?{instructions:!0}:{},...Object.keys(s).length?{look:s}:{}}},j=async t=>{let e=await _t(x(t));return e&&{slug:t,title:e.title,description:"",kind:"link",url:e.url,...e.icon?{icon:e.icon}:{},...e.siteIcon?{siteIcon:e.siteIcon}:{}}},$=async(t,e,n=[])=>{let r=Lt(t),o=r&&n.find(({id:M})=>M===r.ws),i=o?.facts.get(r.slug);if(i){let M=m.join(o.root,r.slug);return{slug:t,title:i.title,description:i.description,kind:"draft",workspace:r.ws,...i.icon?{icon:i.icon}:{},path:i.path,folder:M,root:o.root}}let{ws:a,title:s,description:u,icon:k,path:g,folder:w,root:h,missing:N}=await re(t,e);return{slug:t,title:s,description:u,kind:"draft",workspace:a,...k?{icon:k}:{},...g?{path:g,folder:w,root:h}:{},...N?{missing:N}:{}}},jt=async(t,e,n,r)=>ee(t)?$(t,n,r):e.includes(t)?await j(t)??{slug:t,title:t,description:"",kind:"link",url:""}:O(t),I=gt(l),St=()=>ie(nn())===ie(l),fe=(t,e)=>{let n=t.shown.find(({isDefault:s})=>s)?.id??(St()?I:null),r=new Set([...t.drafts.map(s=>Lt(s)?.ws),...t.groups.map(({workspace:s})=>s),...t.shown.map(({id:s})=>s)].filter(Boolean)),o=new Set(t.groups.filter(({workspace:s,title:u})=>s&&!u).map(({workspace:s})=>s));t.groups.find(({id:s})=>s===mt)?.title||o.add(I),o.delete(n);let i=Ke(new Set([...r,I]),{ids:new Map([...e,[I,[l]]]),stops:C(),among:o});W.follow(new Map([...i].filter(([s])=>s!==I).map(([s,{root:u}])=>[s,u])));let a=Object.fromEntries([...r].map(s=>[s,{...i.get(s)??{missing:X(s,e).refused??"unknown"},...s===n?{default:!0}:{}}]));return a[I]={...i.get(I),there:!0,self:!0,...I===n?{default:!0}:{}},a},z=()=>un(l),de=async(t,e)=>{let n=await A(U(t));await J(F(t).json,`${JSON.stringify({...n,[e]:!0},null,2)}
7
- `)},tt=t=>y.access(t).then(()=>!0,()=>!1),ut=async(t,{own:e=null}={})=>{let n=new Set((await rt()).map(({slug:r})=>r));n.delete(e);for(let r=1;;r++){let o=r===1?t:`${t}-${r}`;if(!fn(o,l)&&!n.has(o))return o}},vt=async t=>{let e=await ut(t.slug,{own:t.slug});return sn(t.slug)?e===t.slug&&!await an(t.slug,l)?e:$t(l):e},Ft=async(t,e)=>{let n=F(t).html,r=await y.readFile(n,"utf8"),o=Bt(r).replace(`data-doc-id="${e}"`,`data-doc-id="${t}"`);o!==r&&await J(n,o)},T=()=>Fe(l),D=async t=>{await Ge(l,t),P()},Q=t=>Je(l,t);async function ft(t,e="",n=1/0){await Q(async()=>{let r=await T();wt(r,t,e,n),await D(r)})}async function Jt(t,{parent:e="",after:n=null,first:r=!1}={}){await Q(async()=>{let o=await T();for(let a of Object.values(o.children))a.includes(t)&&a.splice(a.indexOf(t),1);let i=typeof n=="string"?Object.keys(o.children).find(a=>o.children[a].includes(n)):void 0;i!==void 0?wt(o,t,i,o.children[i].indexOf(n)+1):wt(o,t,typeof e=="string"?e:"",r===!0?0:1/0),await D(o)})}function we(t,e){let n=new Set(Object.values(t.children).flat()),r={...t.children};for(let{id:o}of e.groups){if(o===mt)continue;let i=a=>{let s=(e.children[a]??[]).filter(u=>!n.has(u));(pt(a)||s.length)&&(r[a]=s),s.forEach(i)};i(kt(o))}return{groups:e.groups,children:r}}function Gt(t){return Q(async()=>{let e=await T();for(let[n,r]of Object.entries(e.children)){let o=r.indexOf(t);if(!(o<0))return r.splice(o,1,...e.children[t]??[]),delete e.children[t],await D(e),{parent:n,index:o}}return{parent:"",index:1/0}})}let me=(t,e)=>K.lines(t,e),Yt=t=>et(m.join(S,t,"entry.json")),rt=()=>cn(l);async function pe(t){if(t===dn)return c(409,"home","\u9996\u9875\u4E0D\u80FD\u79FB\u5230\u56DE\u6536\u533A");let e=await ce(t,l);if(!e)return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u9875\u9762");let n=`${Date.now().toString(36)}-${At(3).toString("hex")}`;try{await y.mkdir(m.join(S,n),{recursive:!0}),await V(ct(t,l).folder,m.join(S,n,"page"))}catch(o){throw await y.rm(m.join(S,n),{recursive:!0,force:!0}).catch(()=>{}),o}let r={id:n,kind:"page",slug:t,title:e.title,at:Date.now(),parent:"",index:-1};return await J(m.join(S,n,"entry.json"),`${JSON.stringify(r,null,2)}
8
- `),[200,{ok:!0,entry:r}]}async function ke(t){let e=m.join(S,t.id,"page"),n=await vt(t);if(await y.mkdir(ae(l).customPages,{recursive:!0}),await V(e,ct(n,l).folder),n!==t.slug){let{html:r}=ct(n,l),o=await y.readFile(r,"utf8").catch(()=>null),i=o?.replace(`data-page-id="${t.slug}"`,`data-page-id="${n}"`);o!==null&&i!==o&&await J(r,i)}return await y.rm(m.join(S,t.id),{recursive:!0,force:!0}),[200,{ok:!0,page:await ce(n,l),entry:{...t,slug:n}}]}async function he(t){let e=await _t(x(t));if(!e)return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u94FE\u63A5");let n=`${Date.now().toString(36)}-${At(3).toString("hex")}`,r=await T(),{parent:o,index:i}=await Gt(t);try{await y.mkdir(m.join(S,n),{recursive:!0}),await V(x(t),m.join(S,n,"link"))}catch(s){throw await Q(()=>D(r)),await y.rm(m.join(S,n),{recursive:!0,force:!0}).catch(()=>{}),s}let a={id:n,kind:"link",slug:t,title:e.title,at:Date.now(),parent:o,index:Number.isFinite(i)?i:-1};return await J(m.join(S,n,"entry.json"),`${JSON.stringify(a,null,2)}
9
- `),[200,{ok:!0,entry:a}]}async function ge(t){let e=m.join(S,t.id,"link"),n=await vt(t);return await V(e,x(n)),await y.rm(m.join(S,t.id),{recursive:!0,force:!0}),await ft(n,t.parent,t.index<0?1/0:t.index),[200,{ok:!0,report:await j(n),entry:{...t,slug:n}}]}function ye(t,{parent:e,after:n,first:r}){let o=a=>pt(a)?Object.hasOwn(t.children,a):Object.values(t.children).some(s=>s.includes(a));if(n!=null){let a=Object.keys(t.children).find(s=>t.children[s].includes(n));return a===void 0?{refused:[404,"after","\u627E\u4E0D\u5230\u8981\u653E\u5728\u5B83\u540E\u9762\u7684\u6761\u76EE"]}:e!=null&&e!==a?{refused:[409,"level","\u8981\u653E\u5728\u5B83\u540E\u9762\u7684\u6761\u76EE\u4E0D\u5728\u8FD9\u4E00\u5C42"]}:{parent:a,index:t.children[a].indexOf(n)+1}}let i=e??kt(mt);return pt(i)&&t.groups.some(a=>a.extension&&kt(a.id)===i)?{refused:[409,"extension","\u6269\u5C55\u7684\u680F\u91CC\u653E\u4E0D\u4E86\u522B\u7684\u6761\u76EE"]}:o(i)?{parent:i,index:r?0:(t.children[i]??[]).length}:{refused:[404,"parent",pt(i)?"\u627E\u4E0D\u5230\u8FD9\u4E00\u680F":"\u627E\u4E0D\u5230\u8981\u653E\u5230\u5B83\u4E0B\u9762\u7684\u6761\u76EE"]}}let ot=new Map;function Oe(t){let e=ot.get(t);if(e&&Date.now()-e.at<36e5)return e.answer;let n=G?G.frameable(t).catch(()=>({frameable:!0,reason:"unknown"})):Promise.resolve({frameable:!0,reason:"unknown"});return ot.size>=500&&ot.delete(ot.keys().next().value),ot.set(t,{at:Date.now(),answer:n}),n}function Wt(t,e){return G?.icon?(async()=>{let n=await G.icon(e).catch(()=>null);if(!n)return null;let r=m.join(x(t),It),o=await y.readFile(r,"utf8").catch(()=>null),i=o===null?null:Xe(o);if(!i||i.url!==e||i.siteIcon===n)return null;let a=at({...i,siteIcon:n});return a.refused||!a.value.siteIcon||!await J(r,`${JSON.stringify(a.value,null,2)}
10
- `,{expect:o})?null:(P(),n)})().catch(()=>null):Promise.resolve(null)}let Mt={info:async()=>[200,{ok:!0,version:1,gallery:L.version,token:f.token,commands:[...Object.keys(it)],server:{pid:process.pid,workspace:m.resolve(l),kind:L.kind}}],async outline(){let{outline:t,others:e}=await Ce(l),n=await z(),r=[...Object.values(t.children).flat(),...n?[n]:[]],o=oe(),i=async w=>[w,await jt(w,t.links,o,e)],[a,s,u,k]=await Promise.all([Promise.all(r.map(i)),wn(l),rt(),pn(l)]),g=k.map(({id:w,title:h,icon:N,entries:M,count:bt,error:Vt})=>({id:w,title:h,...N?{icon:N}:{},entries:M,count:bt,...Vt?{error:Pt(Vt)}:{}}));return[200,{ok:!0,outline:t,instructions:n,reports:Object.fromEntries(a),pages:s,trash:u,workspaces:fe(t,o),self:I,extensions:g}]},trash:async()=>[200,{ok:!0,entries:await rt()}],async stats(t){let e=t.get("slug")??"",n=_.test(e)?await K.facts(e).catch(()=>null):null;return n?[200,{ok:!0,edited:n.edited,words:n.words}]:c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863")},async query(t){let e;try{e=JSON.parse(t.get("options")??"{}")}catch{return[400,{ok:!1,reason:"options",message:"options is JSON"}]}return K.query(t.get("kind")??"",e,{doc:t.get("doc")})},components:async()=>[200,{ok:!0,...R.read()}],async source(t){let e=t.get("slug")??"",n=t.get("kind")==="page";if(!_.test(e))return c(404,"missing",n?"\u627E\u4E0D\u5230\u8FD9\u4E2A\u9875\u9762":"\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let r=m.resolve(n?ct(e,l).html:F(e).html);return await tt(r)?[200,{ok:!0,path:r}]:c(404,"missing",n?"\u627E\u4E0D\u5230\u8FD9\u4E2A\u9875\u9762":"\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863")},projects:async()=>[200,{ok:!0,workspaces:await Be(l,{stops:C()})}],shell:async t=>[200,{ok:!0,shell:await W.shellVouched(t.get("origin"))}],async search(t){let e=jn(t.get("q")??"");if(!e)return[200,{ok:!0,results:[]}];let{children:n,groups:r,links:o}=await T(),i=[],a=w=>(n[w]??[]).forEach(h=>{!o.includes(h)&&!ee(h)&&i.push(h),a(h)});for(let{id:w}of r)a(kt(w));let s=e.toLowerCase(),u=new Map(await Promise.all(i.map(async w=>[w,await O(w)]))),k=JSON.stringify([...u].map(([w,{title:h}])=>[w,h])),g=(await Promise.all(i.map(async w=>{let h=await me(w,k);if(!h)return null;let N=String(u.get(w).title).toLowerCase().includes(s),{count:M,hits:bt}=On(h,e);return N||M?{slug:w,title:N,count:M,hits:bt}:null}))).filter(Boolean);return g.sort((w,h)=>Number(h.title)-Number(w.title)||h.count-w.count),[200,{ok:!0,results:g.slice(0,50)}]}},it={async outline({outline:t,base:e}){return!te(t)||e!==void 0&&!te(e)?c(400,"outline","\u6587\u6863\u76EE\u5F55\u7684\u7ED3\u6784\u4E0D\u5BF9\uFF1A\u6BCF\u4EFD\u6587\u6863\u53EA\u80FD\u51FA\u73B0\u4E00\u6B21"):await Q(async()=>{let r=await T();return e!==void 0&&!Ye(e,r)?!1:(await D(t.groups?t:we(t,r)),!0)})?[200,{ok:!0,outline:await T()}]:c(409,"stale","\u6587\u6863\u76EE\u5F55\u521A\u5728\u522B\u5904\u6539\u8FC7")},async move({slug:t,parent:e,after:n=null,first:r=!1,workspace:o}){if(typeof o=="string"&&!Z(o,l))return c(409,"elsewhere","\u8FD9\u4E2A\u9884\u89C8\u670D\u52A1\u5668\u7BA1\u7684\u662F\u53E6\u4E00\u4E2A\u76EE\u5F55\u7684\u6587\u6863");let i=u=>typeof u=="string"&&_.test(u);if(!i(t)||e!==void 0&&e!==""&&!i(e)||n!==null&&!i(n)||typeof r!="boolean")return c(400,"body","\u8BF7\u6C42\u683C\u5F0F\u4E0D\u5BF9");let a=await z();if(a!==null&&[t,e,n].includes(a))return c(409,"instructions","\u5199\u4F5C\u504F\u597D\u4E0D\u5728\u6587\u6863\u76EE\u5F55\u91CC\uFF0C\u4E0D\u80FD\u79FB\u52A8\uFF0C\u4E0B\u9762\u4E5F\u4E0D\u80FD\u653E\u6587\u6863");let s=await Te(l,t,{parent:e,after:n,first:r});if(s.written&&P(),!s.ok){let[u,k]={missing:[404,"\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"],parent:[404,"\u627E\u4E0D\u5230\u8981\u653E\u5230\u5B83\u4E0B\u9762\u7684\u6587\u6863"],after:[404,"\u627E\u4E0D\u5230\u8981\u653E\u5728\u5B83\u540E\u9762\u7684\u6587\u6863"],level:[409,"\u8981\u653E\u5728\u5B83\u540E\u9762\u7684\u6587\u6863\u4E0D\u5728\u8FD9\u4E00\u5C42"],itself:[409,"\u6587\u6863\u4E0D\u80FD\u653E\u5728\u5B83\u81EA\u5DF1\u540E\u9762"],inside:[409,"\u6587\u6863\u4E0D\u80FD\u79FB\u5230\u5B83\u81EA\u5DF1\u6216\u5B83\u4E0B\u9762\u7684\u6587\u6863\u4E0B\u9762"]}[s.reason];return c(u,s.reason,k)}return[200,{ok:!0,...s,outline:await T()}]},async create({title:t,description:e,parent:n="",after:r=null,first:o=!1,language:i}){let a=typeof t=="string"?t.replace(/\s+/g," ").trim().slice(0,200):"",s=await $t(l);return await nt(s),await b.create(s,a,typeof e=="string"&&e.trim()?e.trim():"\u65B0\u6587\u6863",{lang:ue(i)}),await Jt(s,{parent:n,after:r,first:o}),[200,{ok:!0,report:await O(s)}]},async instructions({title:t,description:e,language:n}){let r=await z();if(r)return[200,{ok:!0,report:await O(r)}];let o=await ut(en),i=(a,s)=>typeof a=="string"&&a.trim()?a.trim().slice(0,200):s;return await b.create(o,i(t,"\u5199\u4F5C\u504F\u597D"),i(e,"Agent \u6BCF\u6B21\u5199\u62A5\u544A\u524D\u90FD\u4F1A\u5148\u8BFB\u7684\u5199\u4F5C\u504F\u597D"),{lang:ue(n),page:!0}),await de(o,"instructions"),[200,{ok:!0,report:await O(o)}]},async components({id:t,hidden:e,shown:n,disabled:r,unlisted:o,net:i,pack:a,enabled:s}){try{return[200,{ok:!0,...await R.write(a!==void 0?{pack:a,enabled:s}:{id:t,hidden:e,shown:n,disabled:r,unlisted:o,net:i})}]}catch(u){return c(409,"components",u)}},async duplicate({slug:t,suffix:e,untitled:n}){if(typeof t!="string"||!_.test(t)||!await Y(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let r=await $t(l);await nt(r);let o=new Set(["",...await p(t)]);await y.cp(x(t),x(r),{recursive:!0,errorOnExist:!0,filter:w=>o.has(m.relative(x(t),w).split(m.sep)[0])}),await Ft(r,t);let{title:i}=await O(t),a=i||(typeof n=="string"&&n.trim()?n.trim().slice(0,50):"\u672A\u547D\u540D\u6587\u6863"),s=await f.renameReport(r,`${a}${typeof e=="string"&&e.length>0&&e.length<=20?e:"\uFF08\u526F\u672C\uFF09"}`),u=await T(),[k,g]=Object.entries(u.children).find(([,w])=>w.includes(t))??["",null];return await ft(r,k,g?g.indexOf(t)+1:1/0),[200,{ok:!0,report:await O(r),notes:s.notes??[]}]},async look({slug:t,look:e}){if(typeof t!="string"||!_.test(t)||!await Y(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");if(t===await z())return c(409,"instructions","\u5199\u4F5C\u504F\u597D\u6CA1\u6709\u5B57\u4F53\u4E0E\u5E03\u5C40");if(e!==null&&(typeof e!="object"||Array.isArray(e)))return c(400,"look","\u5B57\u4F53\u4E0E\u5E03\u5C40\u4E0D\u5BF9");let n=F(t).json,r=null;try{r=JSON.parse(await y.readFile(n,"utf8"))}catch{}if(!r||typeof r!="object"||Array.isArray(r))return c(409,"metadata","\u8FD9\u4EFD\u6587\u6863\u7684\u6807\u9898\u548C\u8BF4\u660E\u8BFB\u4E0D\u51FA\u6765");let o=le(r,kn(e,Ct(l)));return JSON.stringify(o)!==JSON.stringify(r)&&await J(n,`${JSON.stringify(o,null,2)}
11
- `),[200,{ok:!0,report:await O(t)}]},async looks({slug:t}){if(typeof t!="string"||!_.test(t)||!await Y(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let e=await z();if(t===e)return c(409,"instructions","\u5199\u4F5C\u504F\u597D\u6CA1\u6709\u5B57\u4F53\u4E0E\u5E03\u5C40");let n=await et(F(t).json);if(!n||typeof n!="object"||Array.isArray(n))return c(409,"metadata","\u8FD9\u4EFD\u6587\u6863\u7684\u6807\u9898\u548C\u8BF4\u660E\u8BFB\u4E0D\u51FA\u6765");let r=Ct(l),o=Tt(n.look,r);try{await yn(l,o)}catch(u){return c(409,"workspace",u)}let i=0,a=(await Ze(l)).filter(u=>u!==e).map(u=>({json:F(u).json,self:u===t})),s=(await rt()).filter(({kind:u})=>u==="document").map(({id:u})=>({json:st(m.join(S,u,"report")).json,self:!1}));for(let{json:u,self:k}of[...a,...s])for(let g=0;g<3;g++){let w=await y.readFile(u,"utf8").catch(()=>null),h=null;try{h=JSON.parse(w??"")}catch{}if(!h||typeof h!="object"||Array.isArray(h)||!Object.hasOwn(h,"look")||h.instructions===!0)break;let N=await J(u,`${JSON.stringify(le(h,{}),null,2)}
12
- `,{expect:w}).catch(()=>null);if(N===null)break;if(N){!k&&Object.keys(hn(h.look)).length>0&&!gn(Tt(h.look,r),o)&&i++;break}}return[200,{ok:!0,look:o,replaced:i,report:await O(t)}]},async rename({slug:t,title:e,kind:n="document"}){if(typeof t!="string"||!_.test(t))return c(400,"slug","\u6587\u6863\u540D\u4E0D\u5BF9");if(n==="page"){let o;try{o=await mn(t,e,l)}catch{return c(400,"title","\u6807\u9898\u4E0D\u80FD\u662F\u7A7A\u7684\uFF0C\u4E5F\u4E0D\u80FD\u8D85\u8FC7 200 \u4E2A\u5B57")}return o?[200,{ok:!0,page:o}]:c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u9875\u9762")}let r=await f.renameReport(t,e);return r.ok?[200,{ok:!0,report:await O(t),notes:r.notes}]:c({title:400,missing:404}[r.reason]??409,r.reason,r.message??"\u6539\u540D\u6CA1\u6709\u6210\u529F")},async trash({slug:t,kind:e="document"}){if(typeof t!="string"||!_.test(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");if(e==="page")return pe(t);if(e==="link")return he(t);if(t===await z())return c(409,"instructions","\u5199\u4F5C\u504F\u597D\u4E0D\u80FD\u79FB\u5230\u56DE\u6536\u533A");if(!await Y(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let{title:n}=await O(t),r=`${Date.now().toString(36)}-${At(3).toString("hex")}`,o=await T(),{parent:i,index:a}=await Gt(t);try{await y.mkdir(m.join(S,r),{recursive:!0}),await v(t,m.join(S,r,"report"))}catch(u){throw await Q(()=>D(o)),await y.rm(m.join(S,r),{recursive:!0,force:!0}).catch(()=>{}),u}let s={id:r,kind:"document",slug:t,title:n,at:Date.now(),parent:i,index:Number.isFinite(a)?a:-1};return await J(m.join(S,r,"entry.json"),`${JSON.stringify(s,null,2)}
13
- `),[200,{ok:!0,entry:s}]},async restore({id:t}){let e=typeof t=="string"&&se.test(t)?await Yt(t):null;if(!e)return c(404,"missing","\u56DE\u6536\u533A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879");if(e.kind==="page")return ke(e);if(e.kind==="link")return ge(e);let n=m.join(S,t,"report"),r=await E(e.slug,n),o=r?e.slug:await vt(e);return r?await d(await y.readdir(n),n,x(o)):await V(n,x(o)),o!==e.slug&&await Ft(o,e.slug),await y.rm(m.join(S,t),{recursive:!0,force:!0}),await ft(o,e.parent,e.index<0?1/0:e.index),[200,{ok:!0,report:await O(o),entry:{...e,kind:"document",slug:o}}]},async destroy({id:t}){let e=typeof t=="string"&&se.test(t)?await Yt(t):null;return e?((e.kind??"document")==="document"&&!await Y(e.slug)&&await nt(e.slug),await y.rm(m.join(S,t),{recursive:!0,force:!0}),[200,{ok:!0}]):c(404,"missing","\u56DE\u6536\u533A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879")},async link({url:t,title:e,icon:n=null,parent:r,after:o=null,first:i=!1},{port:a,wait:s=!1}={}){let u=at({url:t,title:e,icon:n});if(u.refused)return c(400,u.refused,u.message);if(Nt(u.value.url,a))return c(409,"own","\u8FD9\u662F Gallery \u81EA\u5DF1\u7684\u5730\u5740\uFF0C\u8BF7\u76F4\u63A5\u94FE\u63A5\u6587\u6863");if(r!=null&&typeof r!="string"||o!==null&&typeof o!="string"||typeof i!="boolean")return c(400,"body","\u8BF7\u6C42\u683C\u5F0F\u4E0D\u5BF9");let k=await Q(async()=>{let w=await T(),h=ye(w,{parent:r,after:o,first:i||r==null&&o===null});if(h.refused)return h;let N=await ut(Qe(u.value.title,u.value.url));return await y.mkdir(x(N),{recursive:!0}),await J(m.join(x(N),It),`${JSON.stringify(u.value,null,2)}
14
- `),wt(w,N,h.parent,h.index),await D(w),{slug:N,parent:h.parent,index:h.index}});if(k.refused)return c(...k.refused);let g=Wt(k.slug,u.value.url);return s&&await g,[200,{ok:!0,link:await j(k.slug),parent:k.parent,index:k.index,outline:await T()}]},async"link-set"({slug:t,url:e,title:n,icon:r},{port:o,wait:i=!1}={}){let a=typeof t=="string"&&_.test(t)?await _t(x(t)):null;if(!a)return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u94FE\u63A5");let s=e??a.url,u=at({url:s,title:n??a.title,icon:r===void 0?a.icon??null:r,siteIcon:a.siteIcon??null});if(u.refused)return c(400,u.refused,u.message);let k=u.value.url!==a.url;if(k&&Nt(u.value.url,o))return c(409,"own","\u8FD9\u662F Gallery \u81EA\u5DF1\u7684\u5730\u5740\uFF0C\u8BF7\u76F4\u63A5\u94FE\u63A5\u6587\u6863");if(k&&delete u.value.siteIcon,JSON.stringify(u.value)!==JSON.stringify(a)&&await J(m.join(x(t),It),`${JSON.stringify(u.value,null,2)}
15
- `),k){let g=Wt(t,u.value.url);i&&await g}return[200,{ok:!0,link:await j(t)}]},async"draft-add"({path:t,confirm:e=!1,after:n=null}){let r=await He(t),o=typeof n=="string"?n:null;if(r.kind==="missing")return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u6587\u4EF6\u6216\u6587\u4EF6\u5939");if(r.kind==="plain")return c(409,"plain","\u8FD9\u4E0D\u662F Gallery \u7684\u5E95\u7A3F\u6216\u5DE5\u4F5C\u533A\uFF0C\u53EF\u4EE5\u7528\u300C\u5BFC\u5165\u300D\u628A\u6587\u4EF6\u590D\u5236\u8FDB\u6765");if(r.kind==="nested")return c(409,"nested","\u8FD9\u4EFD\u5E95\u7A3F\u4E0D\u5728\u5B83\u5DE5\u4F5C\u533A\u7684\u7B2C\u4E00\u5C42\uFF08\u5728\u56DE\u6536\u533A\u91CC\uFF0C\u6216\u662F\u5199\u4F5C\u504F\u597D\uFF09\uFF0C\u4E0D\u80FD\u6DFB\u52A0");if(r.kind==="name")return c(409,"name","\u8FD9\u4E2A\u6587\u4EF6\u5939\u7684\u540D\u5B57\u4E0D\u662F Gallery \u6587\u6863\u7684\u5199\u6CD5\uFF08\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26\uFF09\uFF0C\u4E0D\u80FD\u6DFB\u52A0");let i=r.kind==="workspace"?r.root:r.kind==="folder"?null:r.root,a=!i||!Ue(l).some(g=>Z(g.root,i));if(!i){let g=r.kind==="folder"?r.folder:r.parent;if(Ve(g))return c(409,"marker",B("{0} \u91CC\u7684 gallery.json \u662F\u522B\u7684\u7A0B\u5E8F\u7684\uFF0C\u4E0D\u80FD\u628A\u5B83\u767B\u8BB0\u6210\u5DE5\u4F5C\u533A",g));if(e!==!0)return[409,{ok:!1,reason:"unregistered",folder:g,...Pt(B("\u4F1A\u628A {0} \u767B\u8BB0\u6210\u4E00\u4E2A\u5DE5\u4F5C\u533A\uFF08\u5728\u91CC\u9762\u653E gallery.json \u548C .gallery/\uFF09",g))}];if(!(await on(g)).ours)return c(409,"marker",B("{0} \u91CC\u7684 gallery.json \u662F\u522B\u7684\u7A0B\u5E8F\u7684\uFF0C\u4E0D\u80FD\u628A\u5B83\u767B\u8BB0\u6210\u5DE5\u4F5C\u533A",g));i=g}let s=r.kind==="workspace"||r.kind==="folder";if(Z(i,l))return[200,{ok:!0,kind:s?"workspace":"draft",own:!0,existing:!0,...s?{column:mt}:{entry:r.slug}}];let u=await De(i,{force:!0}).catch(()=>"failed"),k=X(gt(i));return k.refused==="ambiguous"?c(409,"ambiguous",B("\u672C\u673A\u767B\u8BB0\u7684 {0} \u4E2A\u5DE5\u4F5C\u533A\u7F16\u53F7\u76F8\u540C\uFF08{1}\uFF09\uFF0C\u5148\u7528 gallery workspaces --forget \u53BB\u6389\u5176\u4E2D\u4E00\u4E2A",k.roots.length,gt(i))):!k.root||!Z(k.root,i)?u==="temporary"?c(409,"temporary","\u8FD9\u4E2A\u5DE5\u4F5C\u533A\u5728\u7CFB\u7EDF\u7684\u4E34\u65F6\u6587\u4EF6\u5939\u91CC\uFF0C\u4E0D\u80FD\u6DFB\u52A0"):c(409,"registry","\u6CA1\u80FD\u628A\u5B83\u7684\u5DE5\u4F5C\u533A\u8BB0\u8FDB\u672C\u673A\u7684\u767B\u8BB0\u8868"):(ht(i),s?[200,{ok:!0,kind:"workspace",...await We(l,i,{changed:P,after:o})}]:[200,{ok:!0,kind:"draft",...await ne(l,i,r.slug,{changed:P,pick:!0,after:o,fresh:a})}])},async"draft-join"({root:t,slug:e}){if(typeof t!="string"||typeof e!="string"||!_.test(e))return c(400,"body","\u8BF7\u6C42\u683C\u5F0F\u4E0D\u5BF9");if(Z(t,l))return c(409,"own","\u8FD9\u662F\u5F53\u524D\u7684\u5DE5\u4F5C\u533A");let n=X(gt(t));return!n.root||!Z(n.root,t)?c(409,"registry","\u8FD9\u4E2A\u5DE5\u4F5C\u533A\u4E0D\u5728\u672C\u673A\u7684\u767B\u8BB0\u8868\u91CC"):await tt(st(m.join(t,e)).html)?(ht(t),[200,{ok:!0,...await ne(l,t,e,{changed:P})}]):c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863")},async export({slug:t}){if(typeof t!="string"||!_.test(t)||!await tt(U(t)))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let{problems:e=[],file:n,refused:r}=await b.export(t);return r?c(r.reason==="missing"?404:409,r.reason,r.message):e.length?c(422,"check",Sn(e)):[200,{ok:!0,path:bn(n)}]}},Ht={async frameable({url:t},{port:e}){let n=typeof t=="string"?at({url:t,title:"-"}):{refused:"url"};return n.refused?c(400,"url","\u8FD9\u4E0D\u662F\u4E00\u4E2A\u7F51\u5740"):Nt(n.value.url,e)?[200,{ok:!0,frameable:!1,reason:"own"}]:[200,{ok:!0,...await Oe(n.value.url)}]},async elsewhere({ws:t}){let e=typeof t=="string"?X(t):{refused:"unknown"};if(e.refused)return c(409,e.refused,e.refused==="ambiguous"?"\u672C\u673A\u767B\u8BB0\u7684\u5DE5\u4F5C\u533A\u91CC\u6709\u4E24\u4E2A\u7528\u7684\u662F\u540C\u4E00\u4E2A\u7F16\u53F7\uFF0C\u5148\u7528 gallery workspaces --forget \u53BB\u6389\u5176\u4E2D\u4E00\u4E2A":"\u627E\u4E0D\u5230\u5B83\u6240\u5728\u7684\u5DE5\u4F5C\u533A\uFF1A\u5B83\u4E0D\u5728\u672C\u673A\u7684\u767B\u8BB0\u8868\u91CC");let n=await W.serverOf(e.root);return n.refused?c(409,n.refused,n.message):[200,{ok:!0,origin:`http://127.0.0.1:${n.port}`}]},async"draft-command"({ws:t,name:e,...n}){let r=typeof t=="string"?X(t):{refused:"unknown"};return r.refused?c(409,r.refused,"\u627E\u4E0D\u5230\u5B83\u6240\u5728\u7684\u5DE5\u4F5C\u533A\uFF1A\u5B83\u4E0D\u5728\u672C\u673A\u7684\u767B\u8BB0\u8868\u91CC"):W.forward(r.root,e,n)},async"draft-create"({ws:t,title:e,description:n,language:r,parent:o="",after:i=null,first:a=!1}){if(t===I)return c(409,"self","\u8FD9\u662F\u5F53\u524D\u7684\u5DE5\u4F5C\u533A");let s=typeof t=="string"?X(t):{refused:"unknown"};if(s.refused)return c(409,s.refused,"\u627E\u4E0D\u5230\u5B83\u6240\u5728\u7684\u5DE5\u4F5C\u533A\uFF1A\u5B83\u4E0D\u5728\u672C\u673A\u7684\u767B\u8BB0\u8868\u91CC");let[u,k]=await W.forward(s.root,"create",{title:e,description:n,language:r});if(!k?.ok)return[u,k];let g=k.report?.slug;if(typeof g!="string"||!_.test(g))return c(502,"answer","\u5B83\u6240\u5728\u5DE5\u4F5C\u533A\u7684\u670D\u52A1\u6CA1\u6709\u7ED9\u51FA\u7ED3\u679C");let w=Me(t,g);return ht(s.root),await Jt(w,{parent:o,after:i,first:a}),[200,{ok:!0,entry:w,report:{...k.report,slug:w,kind:"draft",workspace:t}}]},async reveal({entry:t,ws:e,page:n}){let r=oe(),o=null;return typeof n=="string"?o=_.test(n)?ct(n,l).folder:null:typeof t=="string"&&Lt(t)?o=(await re(t,r)).folder:e===I?o=m.resolve(l):typeof e=="string"&&(o=X(e,r).root??null),!o||!await tt(o)?c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4E2A\u6587\u4EF6\u5939"):[200,{ok:!0,path:o,...await Zt(o)}]},async title({url:t}){let e=typeof t=="string"?at({url:t,title:"-"}):{refused:"url"};if(e.refused)return c(400,"url","\u8FD9\u4E0D\u662F\u4E00\u4E2A\u7F51\u5740");let n=G?await G.title(e.value.url).catch(()=>""):"";return[200,{ok:!0,title:typeof n=="string"?n.slice(0,200):""}]}};function je(t,e,n){if(t.method==="GET"&&Object.hasOwn(Mt,n)){let o=t.headers.host??"",i=t.socket.localPort;return o!==`127.0.0.1:${i}`&&o!==`localhost:${i}`?H(e,403,{ok:!1,reason:"host"}):Mt[n](new URL(t.url??"/","http://localhost").searchParams).then(([a,s])=>H(e,a,s),a=>H(e,...c(500,"read",a)))}if(t.method==="POST"&&n==="stop")return f.respond(async o=>{let i=await f.check(o);return i.error?i.error:L.kind!=="cli"||typeof L.stop!="function"?c(409,"dev","\u8FD9\u662F npm run dev \u7684\u670D\u52A1\u5668\uFF1A\u5728\u8FD0\u884C\u5B83\u7684\u5730\u65B9\u505C\u6B62\u5B83"):(e.once("finish",()=>L.stop()),[200,{ok:!0,pid:process.pid}])})(t,e);if(t.method==="POST"&&n==="pack-install")return f.respond(async o=>{let i=await f.check(o,vn);if(i.error)return i.error;if(!R?.install)return c(404,"unknown");try{return[200,{ok:!0,...R.install(i.body??{})}]}catch(a){if(!a.code)throw a;return c(409,a.code,a)}})(t,e);if(t.method==="POST"&&n==="todo")return(async()=>{let o=await f.check(t);if(o.error)return o.error;let{slug:i,items:a}=o.body??{};return typeof i!="string"||!_.test(i)||!Array.isArray(a)?[400,{ok:!1,reason:"body"}]:!await Y(i)||i===await z()?c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"):f.setTodos(i,a)})().then(([o,i])=>H(e,o,i),o=>H(e,...c(500,"write",o.message)));let r={port:t.socket.localPort};return t.method==="POST"&&Object.hasOwn(it,n)?f.respond(async o=>{let i=await f.check(o);if(i.error)return i.error;let a=i.body&&typeof i.body=="object"?i.body:{};return typeof a.workspace=="string"&&!Z(a.workspace,l)?c(409,"elsewhere","\u8FD9\u4E2A\u9884\u89C8\u670D\u52A1\u5668\u7BA1\u7684\u662F\u53E6\u4E00\u4E2A\u76EE\u5F55\u7684\u6587\u6863"):it[n](a,r)})(t,e):t.method==="POST"&&Object.hasOwn(Ht,n)?(async()=>{let o=await f.check(t);return o.error?o.error:Ht[n](o.body&&typeof o.body=="object"?o.body:{},r)})().then(([o,i])=>H(e,o,i),o=>H(e,...c(500,"read",o))):H(e,404,{ok:!1,reason:"unknown"})}return{handle:je,outline:T,trashEntries:rt,place:ft,freeSlug:ut,index:K,run:(t,e,n={})=>Object.hasOwn(it,t)?it[t](e??{},{wait:!0,...n}):Promise.resolve(c(404,"unknown","\u6CA1\u6709\u8FD9\u4E2A\u547D\u4EE4")),close:()=>W.close()}}export{ar as a};
@@ -1,5 +0,0 @@
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 ge,k as we,v as $e,w as be}from"./chunk-QOUEFUCH.mjs";import{M as ye}from"./chunk-VTKNEYT3.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-BPL64HGA.mjs";import{c as P,f as ke}from"./chunk-UGWYKHBL.mjs";import"./chunk-OUUP3WKT.mjs";import{a as R}from"./chunk-JEUK3ZO7.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-ZUNVAXLH.mjs";import"./chunk-6VTU6KEO.mjs";import"./chunk-OJKMINIU.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-UKSHDZZ6.mjs";import"./chunk-6EZ7FNIK.mjs";import"./chunk-35NQ4PLQ.mjs";import"./chunk-V6RIYQZZ.mjs";import{b as de,h as _}from"./chunk-SXHBYZST.mjs";import"./chunk-N7AZZLGT.mjs";import{n as ie}from"./chunk-D4EURAX4.mjs";import"./chunk-4OZWXZE5.mjs";import{a as pe,j as fe,s as me}from"./chunk-HMYTM3GT.mjs";import{d as re,e as le,i as I,j as ce,k as he}from"./chunk-OW5NWPOJ.mjs";import"./chunk-ZTHICSSF.mjs";import{a as w}from"./chunk-SX4LJYT6.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-W3BGBJQW.mjs";import"./chunk-JVHHHGEA.mjs";import{a as U,c as S}from"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-N76HWBA3.mjs";import"./chunk-FJYN7RTH.mjs";import{c as ae}from"./chunk-UBBRTJ2R.mjs";import{a as F,f as te,h as se,j as z,r as ne,s as oe}from"./chunk-FWNRPMCJ.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{isUtf8 as ze}from"node:buffer";import W from"node:fs";import j from"node:path";import{instanceSlots as Ue,instancesOf as X,isInstance as Z,partOf as V}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as $,refusedInCopy as _e}from"../browser/shared/components/installed.mjs";import{attr as b,elementsOf as Q,walk as T}from"../browser/shared/html-tree.mjs";import{blankedCss as B}from"../browser/shared/css-references.mjs";import{ATTRIBUTE as G,SLOT as Le}from"../browser/shared/components/installed.mjs";var Te=new Set(["media","supports","container","layer","starting-style"]);function K(t,e){let s=0,o="";for(let n=0;n<t.length;n++){let i=t[n];i==="\\"?n++:o?o=i===o?"":o:i==='"'||i==="'"?o=i:i===")"||i==="]"?s--:(s===0&&e(i,n),(i==="("||i==="[")&&s++)}}function Ce(t){let e=B(t),s=B(t,{strings:!0}),o={children:[]},n=[o],i=0,r=0;for(let a=0;a<e.length;a++){let l=e[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 M(t){let e=[],s=0;return K(t,(o,n)=>{o===","&&(e.push({text:t.slice(s,n),start:s}),s=n+1)}),e.push({text:t.slice(s),start:s}),e.filter(({text:o})=>o.trim())}function q(t){let e=[],s=t.trim(),o="",n=0,i=0,r=a=>{(i||a)>n&&e.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),e}function D(t){let e=[],s=-1,o=0,n="";for(let r=0;r<t.length;r++){let a=t[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&&(e.push(t.slice(s,r+1)),s=-1)}let i=!1;return K(t,r=>{i||=r==="&"}),{attributes:e,nesting:i,scope:/(?:^|[^\w-]):scope\b/.test(t)}}var Ie=t=>new RegExp(`^\\[\\s*${G}\\s*=\\s*(["'])${t.replace(/[/-]/g,"\\$&")}\\1\\s*i?\\s*\\]$`,"i"),Re=t=>B(t).replace(/\\.|\[[^\]]*\]/g,"").includes("&");function xe(t,e,s,o=!1){let n=q(t),i=({compound:f})=>D(f).attributes.some(h=>e.test(h)),r=({compound:f})=>{let{nesting:h,scope:m}=D(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||Re(t)?{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=t=>t.some(({subject:e})=>e==="instance")?"instance":"inside",Pe=new RegExp(`^\\[\\s*${Le}\\s*(?:\\]|=)`,"i"),Fe=t=>M(/\)\s*to\s*\(([^)]*)\)/i.exec(t)?.[1]??"").some(({text:e})=>q(e).length===1&&D(e).attributes.some(s=>Pe.test(s))),Ee=(t,e)=>Ne(t,e).outside;function je(t,e,s){if(s.length===0)return[];let o=`slot${s.length===1?"":"s"} ${s.join(" and ")}`;return Ne(t,e).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}="${e}"]) to ([${Le}])`}))}function Ne(t,e){let s=Ie(e),o=`[${G}="${e}"]`,n=[],i=[],r=(l,c,p)=>{let f=c.replace(/\s+/g," ").trim();n.push({line:S(t,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(Te.has(d))a(h.children,c,p,f);else if(d==="page")n.push({line:S(t,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=M(x).map(({text:E})=>({...xe(E,s,c),steps:q(E).length}));x&&L.every(({why:E,steps:Ae})=>!E&&Ae===1)?a(h.children,Se(L),!1,f||Fe(h.prelude.trim())):r(u,h.prelude,"outside")}continue}let k=M(h.prelude).map(({text:d,start:x})=>{let L=xe(d,s,c,p),E=h.start+x+d.length-d.trimStart().length;return L.why?r(E,d,L.why):L.deep&&!f&&!p&&i.push({line:S(t,E),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(t),null),{outside:n,deep:i}}var g="template.html",N="example.html",O="component.json",Be=new Set(["localStorage","sessionStorage"]),Me=/^\S+: (?:line \d+ of )?its (?:kit\.js|style\.css) /,De=/(?: (?: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=t=>t.replace(De,e=>(e.startsWith("external")?e:"")+Ge),A=(t,e)=>I({folder:t},e);function C(t,e){let s=null;try{s=W.readFileSync(j.join(t,e))}catch{return null}return ze(s)?null:{file:e,what:"it is not UTF-8: save it as UTF-8 (PowerShell's > writes UTF-16; Set-Content -Encoding utf8 does not)"}}function H(t,e){let s=/^line (\d+): | \(line (\d+)\)/.exec(e);return s?{file:t,line:Number(s[1]??s[2]),what:e.replace(s[0],"")}:{file:t,what:e}}function v(t,e){let s=w.parseJsonText(O,t),o=s.statements[0]?.expression,n=null;for(let i of e.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 qe(t,{message:e,text:s="",values:o=[]}){let n=/at position (\d+)/.exec(e)?.[1];if(n)return S(t,Number(n));for(let i of[...o.map(String),...s.match(/[a-zA-Z][\w.]*/g)??[]]){let r=v(t,i);if(r)return r}return null}var He=t=>_(t).map(e=>/^line (\d+): <([^>]+)>: ([\s\S]*)$/.exec(e)).filter(Boolean).map(([,e,s,o])=>({line:Number(e),tag:s,why:o}));function Je(t,{file:e,tree:s,html:o}){let n=[],i=He(o),r=Object.entries(t.parts).filter(([,c])=>c.edit==="text"),a=Object.entries(t.parts).filter(([,c])=>c.edit==="data"),l=(c,p)=>{let f=!1;return T(c,h=>{f||=h===p}),f};for(let c of X(s,t))for(let[p,f]of r)for(let h of V(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])=>V(c,d.at).some(x=>x===h||l(x,h)||l(h,x)))?.[0];k?n.push({file:e,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:e,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:e,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 Oe="(?:(?:[zcs]h|[bpmfdtnlgkhjqxrzcsyw])?(?:[iuv]?(?:a(?:i|o|ng?)?|e(?:i|r|ng?)?|o(?:u|ng)?)|i(?:u|ng?)?|u(?:i|n)?|vn?))",Ye=new RegExp(`^${Oe}$`,"i"),Ve=new RegExp(`^${Oe}{1,8}$`,"i"),ee=new RegExp("\\p{Script=Han}","u"),We=6,ve=t=>[...t].filter(e=>ee.test(e)).length;function Xe(t){let e=t.replaceAll("'",""),s=[0,...Array(e.length).fill(1/0)];for(let o=1;o<=e.length;o++)for(let n=Math.max(0,o-We);n<o;n++)s[n]+1<s[o]&&Ye.test(e.slice(n,o))&&(s[o]=s[n]+1);return e&&Number.isFinite(s[e.length])?s[e.length]:null}function Ze({name:t,words:e}){let s=ve(t.zh),o=e.split(/\s+/).filter(Boolean);return s===0?ee.test(e)&&!o.some(n=>Ve.test(n)):!o.some(n=>Xe(n.toLowerCase())===s)}function Qe({id:t,folder:e,catalog:s,off:o,parts:n}){let i=s.packages.get(t),r=s.problems.get(t)?.problem,a=A(e,O)??"",l=[];r&&l.push({file:O,line:qe(a,r),what:z("en",r)}),i?.template===null&&l.push({file:g,what:`there is none, and it is what "/" puts in a document: with none, no menu offers the block: write one <div ${$}="${t}"> with what a new instance holds`}),l.push(...n);let c=C(e,"writing.md");c&&l.push(c);let p=c||A(e,"writing.md")?.trim()?[]:[{file:"writing.md",what:"there is none, so gallery block show has nothing to say of how to write it"}];i&&Ze(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(W.readFileSync(j.join(e,"preview.svg")),t)}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(...tt(i)),p.push(...et(i,a))),{title:"manifest",problems:l,notes:p}}function et({places:t,parts:e,card:s},o){let n=[];if(t.includes("page"))for(let[i,r]of Object.entries(e))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 (${t.join(", ")}) hold no page: nothing reads it`});return n}function tt(t){if(t.settings.length===0||!t.template)return[];let e=ne(t.template,t.id),s=e?V(e.root,t.parts[F].at):[];if(s.length!==1||(b(s[0],"type")??"").trim().toLowerCase()!=="application/json")return[{file:g,what:`its manifest has settings, and the template holds ${s.length===1?`a <${s[0].tagName}> where`:`${s.length} elements of`} its settings part (${t.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:g,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 st(t){let e=w.createSourceFile("kit.js",t,w.ScriptTarget.Latest,!0,w.ScriptKind.JS),s=[],o=n=>{let i=w.isCallExpression(n)&&w.isPropertyAccessExpression(n.expression)?n.expression:null;if(i?.name.text==="component"&&/\bDocKit$/.test(i.expression.getText(e))){let[r]=n.arguments,a=r&&w.isObjectLiteralExpression(r)?r.properties.find(c=>c.name?.getText(e)==="id"):null,l=a&&w.isPropertyAssignment(a)&&w.isStringLiteralLike(a.initializer)?a.initializer.text:null;s.push({id:l,at:n.getStart(e)})}w.forEachChild(n,o)};return o(e),s}function nt(t){let e="kit.js";if(!t.files.includes("kit.js"))return{title:e,none:"none: a static block"};let s=C(t.folder,e);if(s)return{title:e,stops:!0,problems:[s]};let o=I(t,"kit.js")??"",n=pe(o);if(n)return{title:e,stops:!0,problems:[{file:e,line:n.line,what:`a browser refuses it: ${n.message}`}]};let i=he(t).map(({line:c,what:p})=>({file:e,line:c,what:p})),r=i.length>0;for(let{name:c,at:p}of re(o,Be))i.push({file:e,line:S(o,p),what:`uses ${c}: an instance keeps what a reader chose with context.state`});let a=st(o);for(let{id:c,at:p}of a)c!==null&&c!==t.id&&i.push({file:e,line:S(o,p),what:`it registers ${c}, and this block is ${t.id}`});let l=a.length?[]:[{file:e,what:`no DocKit.component({ id: "${t.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:t.assets}))(h?i:l).push({file:e,line:c,what:`TS${p}: ${f}`});return{title:e,stops:r,problems:i.sort((c,p)=>(c.line??0)-(p.line??0)),notes:l}}function ot(t){let e="style.css";if(!t.files.includes("style.css"))return{title:e,none:"none"};let s=C(t.folder,e);if(s)return{title:e,stops:!0,problems:[s]};let o=I(t,"style.css")??"",n=ce(t),i=[...Ee(o,t.id),...n].map(({line:l,what:c})=>({file:e,line:l,what:c})),r=Object.entries(t.parts??{}).filter(([,{edit:l}])=>l==="flow").map(([l])=>l),a=je(o,t.id,r).map(({line:l,what:c})=>({file:e,line:l,what:c}));return{title:e,stops:n.length>0,problems:i.sort((l,c)=>l.line-c.line),notes:a}}function it(t,{tree:e}){let s=null;T(e,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,$)!==t)return[{file:g,line:i?.sourceCodeLocation?.startLine,what:`a template is one element, a <div ${$}="${t}"> 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 T({childNodes:[i]},a=>{b(a,"data-block-id")!==void 0&&r.push({file:g,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 at=[[t=>b(t,"data-doc-chart")!==void 0,t=>`a chart (<${t.tagName} data-doc-chart="${b(t,"data-doc-chart")}">)`],[t=>t.tagName==="figure",()=>"a card (<figure>)"],[t=>t.tagName==="caption",()=>"a table's <caption>"],[Z,t=>`an instance of ${b(t,$)}`]];function rt(t,e){let s=null;if(T(U(e),i=>{s??=Z(i)&&b(i,$)===t?i:null}),!s)return[];let o=[],n=(i,r)=>{for(let a of Q(i)){let l=at.find(([c])=>c(a));l?o.push({file:g,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 Ue(s))n(i,i);return o}function lt(t,{tree:e}){let s=oe(t);if(!s)return[];let[o]=X(e,t),n=null;return o&&T({childNodes:[o]},i=>{_e(i.tagName,i.attrs)&&(n??=i)}),[{file:g,line:(n??o)?.sourceCodeLocation?.startLine,what:z("en",s)}]}function ct(t){return[[g,"component-template"],[N,"component-example"]].flatMap(([e,s])=>{let o=A(t,e);if(o===null||!o.trim()||C(t,e))return[];let n=we(s,o),{text:i}=de(n);return[{file:e,slug:s,written:n,html:i,tree:U(i)}]})}function ht({id:t,folder:e,found:s,pages:o,parts:n}){let i="template.html and example.html",r=[],a=[];for(let h of[g,N]){let m=C(e,h);m?r.push(m):h===g&&!A(e,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 ${$}="${t}">; it is what this check runs`})}let l=o.find(h=>h.file===g);l&&r.push(...it(t,l),...rt(t,l.written));let c=o.find(h=>h.file===N);c&&X(c.tree,s).length===0&&r.push({file:N,what:`it holds no instance of ${t}: a <div ${$}="${t}">`});let p=o.map(({slug:h,written:m,html:u,file:y})=>({file:y,slug:h,written:m,html:u,directory:j.join(e,h),htmlPath:j.join(e,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)??[])Me.test(m)||r.push(H(h.file,Ke(m)));for(let m of me(h))a.push(H(h.file,m));for(let m of _(h.html)){let u=H(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===g)&&r.push(...lt(s,l)),{title:i,problems:r,notes:a}}function pt(t,e){let s=te(t,void 0,{on:e}),o=P(t,e);if(!s.packages.has(e)&&!s.problems.has(e))return null;se(t,s);let n=s.packages.has(e)&&s.settings.disabled.includes(e),i=s.packages.get(e)??{id:e,folder:o,files:["kit.js","style.css"].filter(c=>W.existsSync(j.join(o,c)))},r=ct(o),a=s.packages.has(e)?null:"its manifest does not load",l=a?[]:r.flatMap(c=>Je(i,c));return{found:s.packages.get(e)??null,pages:r,sections:[Qe({id:e,folder:o,catalog:s,off:n,parts:l}),nt(i),ot(i),a?{title:"template.html and example.html",skipped:a}:ht({id:e,folder:o,found:i,pages:r,parts:l})]}}var J=({file:t,line:e})=>e?`${t}:${e}`:t;function Y({title:t,problems:e=[],notes:s=[],told:o=[],none:n,skipped:i,unverified:r,pictures:a},l){let c=r?`UNVERIFIED ${r}`:i?`not run: ${i}`:n??(e.length?`${e.length} problem${e.length===1?"":"s"}`:`ok${s.length?`, ${s.length} note${s.length===1?"":"s"}`:""}`);return[`${l}. ${t}: ${c}`,...e.map(p=>` FAIL ${J(p)}: ${p.what}`),...s.map(p=>` note ${J(p)}: ${p.what}`),...o.map(p=>` way back ${J(p)}: ${p.what}`),...a?[ft(a)]:[]]}function ft({folder:t,overviews:e,each:s,edited:o=[],asExport:n=[],documents:i=!1}){let r=e.length?`${R(j.join(t,e[0]))}${e.slice(1).map(c=>` and ${c}`).join("")}, the three widths of each theme side by side; then each at full size: `:`${R(t)}: `,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 mt([t,e,s,o]){return t.problems.length?"the manifest":e.stops?"kit.js":s.stops?"style.css":o.skipped||o.problems.length?"template.html and example.html":null}async function _t(t,e,{documents:s=!1}={}){let o=pt(t,e);o||(console.error(ke(t,e)),process.exit(1)),console.log(`${e}: ${R(P(t,e))}`),o.sections.forEach((p,f)=>console.log(Y(p,f+1).join(`
3
- `)));let n=mt(o.sections),i=P(t,e),r=n?{title:ue,skipped:`${n} first`}:await $e(t,o.found,{example:A(i,N),template:A(i,g)});console.log(Y(r,5).join(`
4
- `));let a=s?n?[{title:ge(),skipped:`${n} first`}]:await be(t,o.found):[];a.forEach((p,f)=>console.log(Y(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=>j.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 ${e}: ${c} problem${c===1?"":"s"}`),process.exitCode=1):r.unverified||a.some(({unverified:p})=>p)?(console.log(`UNVERIFIED ${e}: 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 ${e}${s?" and its instances in the workspace's documents":""}`)}export{_t as checkCommand,Xe as fewestSyllables,pt as readSections,Y as sectionLines,Ze as wantsPinyin};