@heycys/gallery 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/THIRD-PARTY-NOTICES.md +1 -1
  2. package/browser/editor/components/columns/page.mjs +4 -4
  3. package/browser/editor/components/embed/index.mjs +2 -2
  4. package/browser/editor/components/flowchart/add.mjs +7 -6
  5. package/browser/editor/components/flowchart/page.mjs +1 -1
  6. package/browser/editor/components/icons.mjs +8 -0
  7. package/browser/editor/components/image/crop.mjs +6 -9
  8. package/browser/editor/components/installed/index.mjs +11 -4
  9. package/browser/editor/components/installed/page.mjs +27 -16
  10. package/browser/editor/components/installed/served.mjs +6 -5
  11. package/browser/editor/components/instances.mjs +18 -0
  12. package/browser/editor/components/list/page.mjs +3 -6
  13. package/browser/editor/components/registry.mjs +13 -4
  14. package/browser/editor/components/table/index.mjs +59 -2
  15. package/browser/editor/components/table/page.mjs +1 -1
  16. package/browser/editor/page/annotate/card.mjs +3 -6
  17. package/browser/editor/page/autosave.mjs +310 -37
  18. package/browser/editor/page/board/client.mjs +57 -0
  19. package/browser/editor/page/board/hint.mjs +145 -0
  20. package/browser/editor/page/board/history.mjs +119 -0
  21. package/browser/editor/page/board/index.mjs +970 -0
  22. package/browser/editor/page/board/settings.mjs +209 -0
  23. package/browser/editor/page/caret.mjs +1 -1
  24. package/browser/editor/page/changes/bar.mjs +6 -14
  25. package/browser/editor/page/changes/index.mjs +2 -2
  26. package/browser/editor/page/clipboard/import/html.mjs +29 -6
  27. package/browser/editor/page/clipboard/import/inline.mjs +32 -0
  28. package/browser/editor/page/clipboard/import/markdown.mjs +58 -13
  29. package/browser/editor/page/clipboard/import/read.mjs +6 -1
  30. package/browser/editor/page/clipboard/import/to-blocks.mjs +44 -12
  31. package/browser/editor/page/clipboard/import/yuque.mjs +622 -0
  32. package/browser/editor/page/clipboard/index.mjs +124 -13
  33. package/browser/editor/page/clipboard/own/blocks.mjs +11 -11
  34. package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
  35. package/browser/editor/page/clipboard/own/selection.mjs +1 -1
  36. package/browser/editor/page/columns/index.mjs +48 -46
  37. package/browser/editor/page/commit.mjs +80 -22
  38. package/browser/editor/page/conflicts.mjs +7 -7
  39. package/browser/editor/page/core.mjs +31 -15
  40. package/browser/editor/page/custom-page.mjs +106 -0
  41. package/browser/editor/page/editor.mjs +51 -14
  42. package/browser/editor/page/emoji-picker/styles.mjs +7 -12
  43. package/browser/editor/page/emoji-picker/upload.mjs +2 -2
  44. package/browser/editor/page/handle/index.mjs +5 -8
  45. package/browser/editor/page/history.mjs +24 -4
  46. package/browser/editor/page/links/index.mjs +5 -3
  47. package/browser/editor/page/links/pages.mjs +27 -9
  48. package/browser/editor/page/look.mjs +54 -3
  49. package/browser/editor/page/margin.mjs +18 -3
  50. package/browser/editor/page/media-menu/index.mjs +6 -7
  51. package/browser/editor/page/menu.mjs +18 -7
  52. package/browser/editor/page/notices.mjs +2 -2
  53. package/browser/editor/page/page-objects.mjs +13 -2
  54. package/browser/editor/page/panel.mjs +4 -9
  55. package/browser/editor/page/present-links.mjs +11 -2
  56. package/browser/editor/page/resize/index.mjs +42 -29
  57. package/browser/editor/page/served.mjs +14 -0
  58. package/browser/editor/page/session.mjs +48 -4
  59. package/browser/editor/page/slash-menu/index.mjs +3 -3
  60. package/browser/editor/page/table/cells.mjs +102 -46
  61. package/browser/editor/page/table/icons.mjs +2 -0
  62. package/browser/editor/page/table/index.mjs +29 -10
  63. package/browser/editor/page/table/pictures.mjs +299 -0
  64. package/browser/editor/page/table/views.mjs +150 -0
  65. package/browser/editor/page/text-select/index.mjs +26 -12
  66. package/browser/editor/page/todo-writes.mjs +75 -0
  67. package/browser/editor/page/typing/index.mjs +53 -3
  68. package/browser/editor/page/ui.mjs +13 -0
  69. package/browser/shared/block-packs.mjs +404 -0
  70. package/browser/shared/board-places.mjs +224 -0
  71. package/browser/shared/card-size.mjs +59 -0
  72. package/browser/shared/colors.mjs +3 -2
  73. package/browser/shared/component-catalog.mjs +323 -46
  74. package/browser/shared/component-source.mjs +37 -0
  75. package/browser/shared/components/index.mjs +12 -3
  76. package/browser/shared/components/installed.mjs +35 -3
  77. package/browser/shared/components/page.mjs +18 -8
  78. package/browser/shared/components/state.mjs +5 -1
  79. package/browser/shared/document-look.mjs +10 -5
  80. package/browser/shared/drafts.mjs +432 -0
  81. package/browser/shared/extension-sidebar.mjs +126 -0
  82. package/browser/shared/extensions.mjs +79 -0
  83. package/browser/shared/file-table.mjs +101 -0
  84. package/browser/shared/i18n/en.mjs +307 -27
  85. package/browser/shared/json-layout.mjs +47 -0
  86. package/browser/shared/net-cache.mjs +133 -0
  87. package/browser/shared/net-keys.mjs +32 -0
  88. package/browser/shared/net-policy.mjs +177 -0
  89. package/browser/shared/outline-shape.mjs +128 -0
  90. package/browser/shared/outline.mjs +331 -67
  91. package/browser/shared/pack-manifest.mjs +77 -0
  92. package/browser/shared/page-address.mjs +6 -3
  93. package/browser/shared/page-cards.mjs +308 -0
  94. package/browser/shared/page-links.mjs +69 -6
  95. package/browser/shared/pages.mjs +388 -0
  96. package/browser/shared/paths.mjs +6 -0
  97. package/browser/shared/preview-server.mjs +3 -7
  98. package/browser/shared/session.mjs +8 -1
  99. package/browser/shared/shipped-blocks.mjs +299 -0
  100. package/browser/shared/table-chart.mjs +33 -1
  101. package/browser/shared/todos.mjs +83 -0
  102. package/browser/shared/user-directory.mjs +24 -0
  103. package/browser/shared/versions.mjs +14 -0
  104. package/browser/shared/web-links.mjs +134 -0
  105. package/browser/shared/workspace-columns.mjs +120 -0
  106. package/browser/shared/workspace-name.mjs +154 -0
  107. package/browser/shared/workspace-query.mjs +125 -0
  108. package/browser/shared/workspace-registry.mjs +272 -0
  109. package/browser/shared/workspace.mjs +171 -20
  110. package/dist/chunk-2NRBY6AJ.mjs +2 -0
  111. package/dist/chunk-32ZUEFZ7.mjs +2 -0
  112. package/dist/chunk-35NQ4PLQ.mjs +2 -0
  113. package/dist/chunk-3KJHLHUO.mjs +2 -0
  114. package/dist/chunk-3NJACR4W.mjs +2 -0
  115. package/dist/chunk-4AV456RQ.mjs +2 -0
  116. package/dist/chunk-4OZWXZE5.mjs +5 -0
  117. package/dist/chunk-5XYHDBJ5.mjs +2 -0
  118. package/dist/chunk-5ZJA7CXT.mjs +2 -0
  119. package/dist/chunk-6A53MZYZ.mjs +2 -0
  120. package/dist/chunk-6EXH3ORZ.mjs +166 -0
  121. package/dist/chunk-6EZ7FNIK.mjs +3 -0
  122. package/dist/{chunk-V5JTW2LH.mjs → chunk-6QBHU4DF.mjs} +1 -1
  123. package/dist/{chunk-Y6RLRPG3.mjs → chunk-6VTU6KEO.mjs} +1 -1
  124. package/dist/chunk-B4P2CM2J.mjs +3 -0
  125. package/dist/{chunk-FDLXYYG4.mjs → chunk-BPL64HGA.mjs} +1 -1
  126. package/dist/chunk-BVEFGE4B.mjs +2 -0
  127. package/dist/{chunk-LS4F7JUM.mjs → chunk-BZ5RAF7L.mjs} +1 -1
  128. package/dist/chunk-CRJEG7MT.mjs +2 -0
  129. package/dist/{chunk-LCTHTZIL.mjs → chunk-D4CKRD3V.mjs} +91 -91
  130. package/dist/chunk-D4EURAX4.mjs +4 -0
  131. package/dist/chunk-DQCE7TJY.mjs +5 -0
  132. package/dist/chunk-DR73Y2UJ.mjs +3 -0
  133. package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
  134. package/dist/{chunk-GB5SOYQJ.mjs → chunk-ERLAIBOA.mjs} +2 -2
  135. package/dist/chunk-EURLTOTZ.mjs +4 -0
  136. package/dist/chunk-FJYN7RTH.mjs +4 -0
  137. package/dist/chunk-FWNRPMCJ.mjs +12 -0
  138. package/dist/chunk-FWW4CSAZ.mjs +2 -0
  139. package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
  140. package/dist/chunk-GY3FAUVM.mjs +2 -0
  141. package/dist/chunk-HLYV7RIH.mjs +2 -0
  142. package/dist/chunk-HMYTM3GT.mjs +15 -0
  143. package/dist/chunk-IA4PSIMD.mjs +2 -0
  144. package/dist/chunk-JEUK3ZO7.mjs +2 -0
  145. package/dist/chunk-KTKHRC6H.mjs +2 -0
  146. package/dist/chunk-L7UP52JO.mjs +2 -0
  147. package/dist/{chunk-SYGN7GLU.mjs → chunk-MHW7ZKOU.mjs} +1 -1
  148. package/dist/chunk-N76HWBA3.mjs +10 -0
  149. package/dist/chunk-N7AZZLGT.mjs +548 -0
  150. package/dist/chunk-NAMN3RAF.mjs +2 -0
  151. package/dist/{chunk-5ZKJ3H4P.mjs → chunk-NFMCP2HI.mjs} +3 -3
  152. package/dist/chunk-NG375ILQ.mjs +2 -0
  153. package/dist/chunk-NVRNLK25.mjs +6 -0
  154. package/dist/chunk-NWFBE2YA.mjs +2 -0
  155. package/dist/chunk-NWR2LT5B.mjs +2 -0
  156. package/dist/chunk-OJKMINIU.mjs +20 -0
  157. package/dist/{chunk-4FS7Z7WR.mjs → chunk-OUUP3WKT.mjs} +1 -1
  158. package/dist/{chunk-BGGDRNYQ.mjs → chunk-OW5NWPOJ.mjs} +1 -1
  159. package/dist/chunk-PAREWQGB.mjs +4 -0
  160. package/dist/chunk-POQSE4C2.mjs +2 -0
  161. package/dist/chunk-PUOQ65NC.mjs +2 -0
  162. package/dist/{chunk-XNROSH2T.mjs → chunk-PVER7LSC.mjs} +2 -2
  163. package/dist/chunk-PZDLJJTJ.mjs +3 -0
  164. package/dist/chunk-Q47PLKIJ.mjs +15 -0
  165. package/dist/chunk-Q4UEPUWF.mjs +2 -0
  166. package/dist/chunk-QKXMPUXC.mjs +2 -0
  167. package/dist/chunk-QOUEFUCH.mjs +16 -0
  168. package/dist/chunk-RFDZXFJF.mjs +13 -0
  169. package/dist/chunk-RKPWLGZ3.mjs +4 -0
  170. package/dist/chunk-RMECZA2K.mjs +2 -0
  171. package/dist/{chunk-7DTINW6U.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  172. package/dist/chunk-SX4LJYT6.mjs +8 -0
  173. package/dist/chunk-SXHBYZST.mjs +16 -0
  174. package/dist/chunk-TANZRINB.mjs +2 -0
  175. package/dist/chunk-TEZAWDSQ.mjs +2 -0
  176. package/dist/chunk-UBBRTJ2R.mjs +24 -0
  177. package/dist/chunk-UFNYFFKO.mjs +20 -0
  178. package/dist/chunk-UGWYKHBL.mjs +170 -0
  179. package/dist/chunk-UKSHDZZ6.mjs +2 -0
  180. package/dist/chunk-UNOYVIYR.mjs +2 -0
  181. package/dist/{chunk-E7LWZRXY.mjs → chunk-V6RIYQZZ.mjs} +1 -1
  182. package/dist/chunk-VJPFVNNW.mjs +15 -0
  183. package/dist/chunk-VS3ZMVGX.mjs +5 -0
  184. package/dist/chunk-VTKNEYT3.mjs +6 -0
  185. package/dist/chunk-VXACTLO3.mjs +3 -0
  186. package/dist/chunk-YI43RG4P.mjs +2 -0
  187. package/dist/chunk-YQGT4AB2.mjs +6 -0
  188. package/dist/chunk-ZB4H7ZN4.mjs +2 -0
  189. package/dist/{chunk-IVDLMMBD.mjs → chunk-ZHEHPMBK.mjs} +1 -1
  190. package/dist/chunk-ZTHICSSF.mjs +2 -0
  191. package/dist/chunk-ZUNVAXLH.mjs +2 -0
  192. package/dist/chunk-ZWPMCK7P.mjs +2 -0
  193. package/dist/cli.mjs +1 -1
  194. package/dist/server.mjs +1 -1
  195. package/dist/{chunk-U6KNPJPR.mjs → update-fetch.mjs} +1 -1
  196. package/dist/worker.mjs +1 -1
  197. package/kit/board.css +95 -0
  198. package/kit/board.js +250 -0
  199. package/kit/charts.js +5 -71
  200. package/kit/code.js +14 -14
  201. package/kit/report.css +255 -17
  202. package/kit/runtime.js +1600 -125
  203. package/kit/state.js +10 -1
  204. package/kit/tables.js +128 -43
  205. package/kit/ui.js +77 -35
  206. package/package.json +2 -1
  207. package/packs/gallery/card/component.json +14 -0
  208. package/packs/gallery/card/example.html +10 -0
  209. package/packs/gallery/card/preview.svg +1 -0
  210. package/packs/gallery/card/style.css +6 -0
  211. package/packs/gallery/card/template.html +6 -0
  212. package/packs/gallery/card/writing.md +14 -0
  213. package/packs/gallery/chart-card/component.json +15 -0
  214. package/packs/gallery/chart-card/example.html +14 -0
  215. package/packs/gallery/chart-card/kit.js +130 -0
  216. package/packs/gallery/chart-card/preview.svg +1 -0
  217. package/packs/gallery/chart-card/style.css +42 -0
  218. package/packs/gallery/chart-card/template.html +13 -0
  219. package/packs/gallery/chart-card/writing.md +20 -0
  220. package/packs/gallery/chart-view/component.json +20 -0
  221. package/packs/gallery/chart-view/example.html +13 -0
  222. package/packs/gallery/chart-view/kit.js +355 -0
  223. package/packs/gallery/chart-view/preview.svg +1 -0
  224. package/packs/gallery/chart-view/style.css +94 -0
  225. package/packs/gallery/chart-view/template.html +3 -0
  226. package/packs/gallery/chart-view/writing.md +22 -0
  227. package/packs/gallery/countdown/component.json +18 -0
  228. package/packs/gallery/countdown/example.html +3 -0
  229. package/packs/gallery/countdown/kit.js +156 -0
  230. package/packs/gallery/countdown/preview.svg +1 -0
  231. package/packs/gallery/countdown/style.css +130 -0
  232. package/packs/gallery/countdown/template.html +3 -0
  233. package/packs/gallery/countdown/writing.md +22 -0
  234. package/packs/gallery/habit/component.json +14 -0
  235. package/packs/gallery/habit/example.html +3 -0
  236. package/packs/gallery/habit/kit.js +295 -0
  237. package/packs/gallery/habit/preview.svg +1 -0
  238. package/packs/gallery/habit/style.css +246 -0
  239. package/packs/gallery/habit/template.html +3 -0
  240. package/packs/gallery/habit/writing.md +21 -0
  241. package/packs/gallery/heatmap/component.json +18 -0
  242. package/packs/gallery/heatmap/example.html +3 -0
  243. package/packs/gallery/heatmap/kit.js +351 -0
  244. package/packs/gallery/heatmap/preview.svg +1 -0
  245. package/packs/gallery/heatmap/style.css +201 -0
  246. package/packs/gallery/heatmap/template.html +3 -0
  247. package/packs/gallery/heatmap/writing.md +21 -0
  248. package/packs/gallery/kanban/component.json +18 -0
  249. package/packs/gallery/kanban/example.html +12 -0
  250. package/packs/gallery/kanban/kit.js +540 -0
  251. package/packs/gallery/kanban/preview.svg +1 -0
  252. package/packs/gallery/kanban/style.css +212 -0
  253. package/packs/gallery/kanban/template.html +3 -0
  254. package/packs/gallery/kanban/writing.md +20 -0
  255. package/packs/gallery/metric/component.json +22 -0
  256. package/packs/gallery/metric/example.html +15 -0
  257. package/packs/gallery/metric/kit.js +248 -0
  258. package/packs/gallery/metric/preview.svg +1 -0
  259. package/packs/gallery/metric/style.css +92 -0
  260. package/packs/gallery/metric/template.html +3 -0
  261. package/packs/gallery/metric/writing.md +23 -0
  262. package/packs/gallery/note/component.json +14 -0
  263. package/packs/gallery/note/example.html +3 -0
  264. package/packs/gallery/note/kit.js +102 -0
  265. package/packs/gallery/note/preview.svg +1 -0
  266. package/packs/gallery/note/style.css +76 -0
  267. package/packs/gallery/note/template.html +3 -0
  268. package/packs/gallery/note/writing.md +18 -0
  269. package/packs/gallery/pack.json +8 -0
  270. package/packs/gallery/recent/component.json +13 -0
  271. package/packs/gallery/recent/example.html +1 -0
  272. package/packs/gallery/recent/kit.js +238 -0
  273. package/packs/gallery/recent/preview.svg +1 -0
  274. package/packs/gallery/recent/style.css +158 -0
  275. package/packs/gallery/recent/template.html +1 -0
  276. package/packs/gallery/recent/writing.md +15 -0
  277. package/packs/gallery/static/component.json +13 -0
  278. package/packs/gallery/static/example.html +11 -0
  279. package/packs/gallery/static/preview.svg +1 -0
  280. package/packs/gallery/static/style.css +138 -0
  281. package/packs/gallery/static/template.html +1 -0
  282. package/packs/gallery/static/writing.md +18 -0
  283. package/packs/gallery/stats/component.json +13 -0
  284. package/packs/gallery/stats/example.html +1 -0
  285. package/packs/gallery/stats/kit.js +166 -0
  286. package/packs/gallery/stats/preview.svg +1 -0
  287. package/packs/gallery/stats/style.css +151 -0
  288. package/packs/gallery/stats/template.html +1 -0
  289. package/packs/gallery/stats/writing.md +11 -0
  290. package/packs/gallery/today/component.json +12 -0
  291. package/packs/gallery/today/example.html +1 -0
  292. package/packs/gallery/today/kit.js +185 -0
  293. package/packs/gallery/today/preview.svg +1 -0
  294. package/packs/gallery/today/style.css +120 -0
  295. package/packs/gallery/today/template.html +1 -0
  296. package/packs/gallery/today/writing.md +14 -0
  297. package/packs/gallery/todos/component.json +19 -0
  298. package/packs/gallery/todos/example.html +3 -0
  299. package/packs/gallery/todos/kit.js +342 -0
  300. package/packs/gallery/todos/preview.svg +1 -0
  301. package/packs/gallery/todos/style.css +267 -0
  302. package/packs/gallery/todos/template.html +3 -0
  303. package/packs/gallery/todos/writing.md +30 -0
  304. package/packs/gallery/weather/component.json +19 -0
  305. package/packs/gallery/weather/example.html +3 -0
  306. package/packs/gallery/weather/kit.js +312 -0
  307. package/packs/gallery/weather/preview.svg +1 -0
  308. package/packs/gallery/weather/style.css +258 -0
  309. package/packs/gallery/weather/template.html +3 -0
  310. package/packs/gallery/weather/writing.md +26 -0
  311. package/packs/gallery-soft/pack.json +8 -0
  312. package/release.json +12 -10
  313. package/sdk/doc-kit.d.ts +396 -5
  314. package/sdk/doc-state.d.ts +2 -0
  315. package/skill/SKILL.md +56 -23
  316. package/skill/references/block-script.md +140 -0
  317. package/skill/references/building-blocks.md +257 -0
  318. package/skill/references/extensions.md +59 -0
  319. package/skill/references/pages-and-data.md +221 -0
  320. package/skill/references/writing-html.md +6 -4
  321. package/skill/sdk/doc-kit.d.ts +396 -5
  322. package/skill/sdk/doc-state.d.ts +2 -0
  323. package/web/assets/index-BK2e_07w.js +13 -0
  324. package/web/assets/index-CWFI83mF.css +1 -0
  325. package/web/index.html +2 -2
  326. package/dist/chunk-3HIRPVLU.mjs +0 -2
  327. package/dist/chunk-5MHMDLZD.mjs +0 -4
  328. package/dist/chunk-64K7IPLO.mjs +0 -255
  329. package/dist/chunk-6QXGZM36.mjs +0 -8
  330. package/dist/chunk-6RGJOMJP.mjs +0 -16
  331. package/dist/chunk-AJ73XJF3.mjs +0 -2
  332. package/dist/chunk-AUZGSZJH.mjs +0 -13
  333. package/dist/chunk-BFE45AKL.mjs +0 -2
  334. package/dist/chunk-BXO2ZY5P.mjs +0 -2
  335. package/dist/chunk-CEH4MRCC.mjs +0 -2
  336. package/dist/chunk-CY2FNNAB.mjs +0 -16
  337. package/dist/chunk-DFUDV4LX.mjs +0 -2
  338. package/dist/chunk-DKXG4XDG.mjs +0 -2
  339. package/dist/chunk-EZQ34M3F.mjs +0 -124
  340. package/dist/chunk-EZY3WC6Z.mjs +0 -15
  341. package/dist/chunk-FUKQNOQS.mjs +0 -9
  342. package/dist/chunk-JPOSLGOC.mjs +0 -6
  343. package/dist/chunk-L3QKH4OK.mjs +0 -26
  344. package/dist/chunk-LAE5NQ4B.mjs +0 -2
  345. package/dist/chunk-LEF6DRCK.mjs +0 -59
  346. package/dist/chunk-NO5NJCHO.mjs +0 -2
  347. package/dist/chunk-NQPVAU63.mjs +0 -2
  348. package/dist/chunk-NSKUTQ5J.mjs +0 -5
  349. package/dist/chunk-O35FIXRB.mjs +0 -2
  350. package/dist/chunk-P2CAZPDP.mjs +0 -3
  351. package/dist/chunk-PL6GHLGD.mjs +0 -15
  352. package/dist/chunk-QJIR2BLP.mjs +0 -6
  353. package/dist/chunk-QUPLVPB2.mjs +0 -7
  354. package/dist/chunk-R7BNENLY.mjs +0 -4
  355. package/dist/chunk-S6O4UHLC.mjs +0 -2
  356. package/dist/chunk-SGJWQKEI.mjs +0 -2
  357. package/dist/chunk-TX6JH7TR.mjs +0 -2
  358. package/dist/chunk-TYK6VNAB.mjs +0 -10
  359. package/dist/chunk-UALRNVSE.mjs +0 -4
  360. package/dist/chunk-V3HXVQEM.mjs +0 -2
  361. package/dist/chunk-V5VXUJKG.mjs +0 -2
  362. package/dist/chunk-VBXMADMP.mjs +0 -2
  363. package/dist/chunk-VNV55RUA.mjs +0 -2
  364. package/dist/chunk-VPD2PS35.mjs +0 -2
  365. package/dist/chunk-W4VKN3GF.mjs +0 -7
  366. package/dist/chunk-W5BXXPDJ.mjs +0 -3
  367. package/dist/chunk-XUNHRCOG.mjs +0 -6
  368. package/skill/references/building-components.md +0 -367
  369. package/web/assets/index-Bh74DfsV.css +0 -1
  370. package/web/assets/index-UW0RyFFt.js +0 -13
@@ -0,0 +1,13 @@
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 Oe,f as we,g as ge,h as $e,i as We,j as ne,l as Y,m as Ge,n as Ae,o as Ke,p as Ve,q as ze,r as g,t as Qe,u as Ye}from"./chunk-QOUEFUCH.mjs";import{M as Xe}from"./chunk-VTKNEYT3.mjs";import{f as Te,i as Je}from"./chunk-NFMCP2HI.mjs";import{a as K}from"./chunk-JEUK3ZO7.mjs";import{a as me}from"./chunk-NWFBE2YA.mjs";import{a as Ue,b as Ze,f as pe,g as qe}from"./chunk-PUOQ65NC.mjs";import{e as Ne,g as te}from"./chunk-OJKMINIU.mjs";import{b as Se}from"./chunk-SXHBYZST.mjs";import{b as T,i as Pe}from"./chunk-4OZWXZE5.mjs";import{a as Be}from"./chunk-HYMEEXKN.mjs";import{f as Ee,j as He}from"./chunk-FWNRPMCJ.mjs";import{randomBytes as Ct}from"node:crypto";import{existsSync as It}from"node:fs";import N from"node:fs/promises";import A from"node:path";import{isInstance as Re,isSlot as jt,partOf as Mt}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as ke,FALLBACK as Rt,FIELDS as Dt,INSTANCE as ft,PACKAGE_ID as _t,SLOT as Ft}from"../browser/shared/components/installed.mjs";import{attr as ce,walk as Ht}from"../browser/shared/html-tree.mjs";import{documentDirectory as Pt,documentFiles as Bt,layoutOf as se,packageFolders as Jt,slugTaken as Ut}from"../browser/shared/workspace.mjs";var et=10,Ce=6,Zt=3,qt=100,De=1024,_e=900,Wt=4e3,le=3e4,Gt=1500,Ie=3e4,je=500,Kt=5e3,Vt=200,tt=20,nt=160,ye=12,zt=3600*1e3,Qt=["p","pi","pin"],he=e=>new Promise(t=>setTimeout(t,e));async function at(e){let{_keyDefinitions:t}=await import("./chunk-43B75J5T.mjs"),n=Object.hasOwn(t,e)?[e]:e.split("+"),a=new Set(["Control","Shift","Alt","Meta"]);if(n.some(s=>!Object.hasOwn(t,s))||n.slice(0,-1).some(s=>!a.has(s)))throw new T(`Not a key: ${e} (a key as a browser names it, Enter, Space, Escape, Tab, ArrowRight, a letter or a digit, after modifiers joined by "+": Shift+Tab, Control+Enter).`);return n}var ie={press:"<selector>",drag:'<selector>, with "to": <selector>',key:"[<selector>, <key>]",type:"[<selector>, <words>]",select:"[<selector>, <value>]"};async function ut(e,t=null){let n=d=>new T(t?`${t[0].toUpperCase()}${t.slice(1)}: ${d}`:`${d[0].toUpperCase()}${d.slice(1)}`);if(!e||typeof e!="object"||Array.isArray(e))throw n(`a step is an object naming one gesture: ${Object.entries(ie).map(([d,h])=>`"${d}": ${h}`).join(", ")}, and "then": <key> after it.`);let a=Object.keys(e).filter(d=>!Object.hasOwn(ie,d)&&!["to","then","replace"].includes(d));if(a.length)throw n(`no such field: ${a.join(", ")} (a step names one of ${Object.keys(ie).join(", ")}, "to" with a drag, "replace": true with typing and "then" after any).`);let s=Object.keys(ie).filter(d=>e[d]!==void 0),o=d=>t?`"${d}"`:`--${d}`;if(s.length!==1)throw n(s.length?`one gesture at a time: ${s.map(o).join(" or ")}.`:t?`name the gesture: ${Object.keys(ie).map(o).join(", ")}.`:"Say the gesture: --press <selector>, --drag <selector> --to <selector>, --key <selector> <key>, --type <selector> <words> or --select <selector> <value>; or --steps <file>.");let[i]=s;if(e.to!==void 0&&i!=="drag")throw n(`${o("to")} goes with ${o("drag")}: ${t?'"drag": <selector>, "to": <selector>':"--drag <selector> --to <selector>"}.`);if(i==="drag"&&e.to===void 0)throw n(`${o("drag")} takes ${o("to")}: ${t?'"drag": <selector>, "to": <selector>':"--drag <selector> --to <selector>"}, where it is dropped.`);if(e.replace!==void 0&&i!=="type")throw n(`${o("replace")} goes with ${o("type")}: it selects what the field holds before the words go in.`);if(e.replace!==void 0&&e.replace!==!0)throw n(`${o("replace")} is true: ${t?'"replace": true':"--replace"} selects what the field holds before the words go in.`);let l=(d,h)=>{if(typeof d!="string"||!d)throw n(`${h} is words: ${JSON.stringify(d)}.`);return d},c=(d,h)=>{if(!Array.isArray(d)||d.length!==2)throw n(`${o(i)} takes ${t?`[<selector>, ${h}]`:`<selector> ${h}`}.`);return[l(d[0],"a selector"),l(d[1],h)]},r={kind:i};if(i==="press"&&(r.at=l(e.press,"a selector")),i==="drag"&&Object.assign(r,{at:l(e.drag,"a selector"),to:l(e.to,"a selector")}),i==="key"){let[d,h]=c(e.key,"<key>");Object.assign(r,{at:d,key:h,keys:await at(h)})}return i==="type"&&([r.at,r.text]=c(e.type,"<words>"),e.replace&&(r.replace=!0)),i==="select"&&([r.at,r.value]=c(e.select,"<value>")),e.then!==void 0&&(r.then={key:l(e.then,"a key"),keys:await at(l(e.then,"a key"))}),r}async function Yt(e,t={},n=!1){if(n&&e.has("--steps"))throw new T('--steps <file> holds every gesture: --replace goes in a step of it, as { "type": [".name", "\u65B0\u540D\u5B57"], "replace": true }, not beside it.');if(e.has("--steps")){let s=["--press","--drag","--to","--key","--type","--select","--then"].filter(o=>e.has(o));if(s.length)throw new T(`--steps <file> holds every gesture: ${s.join(", ")} goes in it, not beside it.`);return null}let a={};for(let s of["press","drag","to","then"])e.has(`--${s}`)&&(a[s]=e.get(`--${s}`));for(let s of["key","type","select"])e.has(`--${s}`)&&(a[s]=[e.get(`--${s}`),t[`--${s}`]]);return n&&(a.replace=!0),ut(a)}async function Xt(e){let t=A.basename(e),n;try{n=await N.readFile(e,"utf8")}catch(o){throw new T(`No steps file: ${K(e)} (${o.code??ne(o)}).`)}let a;try{a=JSON.parse(n.replace(/^/,""))}catch(o){throw new T(`${t} is no JSON: ${ne(o)}. A steps file is a list of steps, as [{ "press": ".add" }, { "type": [".name", "\u65B0\u540D\u5B57"], "then": "Enter" }].`)}if(!Array.isArray(a)||a.length===0)throw new T(`${t} holds no list of steps: write [{ "press": ".add" }, { "type": [".name", "\u65B0\u540D\u5B57"], "then": "Enter" }].`);if(a.length>tt)throw new T(`${t} holds ${a.length} steps, and a trial makes ${tt} at most: try fewer at a time.`);let s=[];for(let[o,i]of a.entries())s.push(await ut(i,`step ${o+1} of ${t}`));return s}var pt=e=>{let t=e.parentNode;for(;t&&!Re(t);)t=t.parentNode;return t??null},en=(e,t)=>{for(let n=e.parentNode;n&&n!==t;n=n.parentNode)if(jt(n))return ce(n,Ft);return null};function wt(e){let t=[];return Ht(Be(e),n=>{if(!Re(n))return;let a=pt(n);t.push({element:n,id:ce(n,ke),blockId:ce(n,"data-block-id")??null,line:n.sourceCodeLocation?.startLine,in:a?{id:ce(a,ke),line:a.sourceCodeLocation?.startLine,slot:en(n,a)}:null})},{inTemplates:!1}),t}var gt=({line:e,in:t},n)=>`${n}:${e}${t?`, in ${t.slot?`the slot ${t.slot} of `:""}${t.id} at ${n}:${t.line}`:""}`,tn=(e,{id:t,blockId:n})=>n??(e.filter(a=>a.id===t).length===1?t:null);function nn(e,t,{slug:n,name:a}){let s=()=>e.map(c=>` ${tn(e,c)??"(no id yet: gallery export gives it one)"} ${c.id} at ${gt(c,a)}`).join(`
3
+ `);if(t===null){if(e.length===1)return 0;throw new T(`${n} holds ${e.length} instances: name one, gallery block try ${n} <instance id> \u2026
4
+ ${s()}`)}let o=e.findIndex(({blockId:c})=>c===t);if(o>=0)return o;let i=t.includes("/")?t:`local/${t}`,l=_t.test(i)?e.flatMap((c,r)=>c.id===i?[r]:[]):[];if(l.length===1)return l[0];throw new T(l.length?`${n} holds ${l.length} instances of ${i}: name one by its id
5
+ ${s()}`:`${n} holds no instance ${t}:
6
+ ${s()}`)}var an=e=>e.replace(/\s+data-block-id="[^"]*"/g,""),st=e=>an(Se(e).text),sn=(e,t)=>(typeof t=="function"?t(e):wt(e)[t]?.element)??null;function ot(e,t,n){let a=sn(e,t);if(!a||ce(a,ke)!==n.id)return null;let s=[],o=Object.entries(n.parts).map(([r,{at:d}])=>{let h=Mt(a,d).filter(f=>f.sourceCodeLocation?.endTag&&!Re(f)&&pt(f)===a).map(({sourceCodeLocation:{startTag:f,endTag:u}})=>({start:f.endOffset,end:u.startOffset}));return s.push(...h),{name:r,text:h.map(({start:f,end:u})=>e.slice(f,u)).join(`
7
+ `)}}),i=s.sort((r,d)=>r.start-d.start||d.end-r.end).filter((r,d)=>!s.slice(0,d).some(h=>h.start<=r.start&&r.end<=h.end)),l="",c=0;for(let{start:r,end:d}of i)l+=e.slice(c,r),c=d;return{parts:o,outside:l+e.slice(c)}}function on(e,t,n,a){let[s,o]=[ot(e,n,a),ot(t,n,a)];return!s||!o?{parts:[],outside:null,gone:!0}:{parts:s.parts.flatMap(({name:l,text:c},r)=>c===o.parts[r].text?[]:[{name:l,...Ae(c,o.parts[r].text),how:Ve(c,o.parts[r].text),runs:Ke(c,o.parts[r].text)}]),outside:s.outside===o.outside?null:Ae(s.outside,o.outside),gone:!1}}function rn(e){let t=n=>n.length>nt?`${n.slice(0,nt)}\u2026`:n;return e.flatMap(({name:n,runs:a=[]})=>{let s=a.flatMap(({removed:l,added:c})=>[...l.map(r=>`- ${t(r)}`),...c.map(r=>`+ ${t(r)}`)]),o=e.length>1?" ":" ",i=s.slice(0,ye).map(l=>`${o}${l}`);return s.length>ye&&i.push(`${o}\u2026 ${s.length-ye} more line${s.length-ye===1?"":"s"}`),e.length>1?[` ${n}:`,...i]:i})}async function cn(e,t=null){let{components:n,marker:a}=se(e);return await mt([t,a,n].filter(Boolean))+me+te+je}async function ln(e,{directory:t,files:n,text:a}){let{scratch:s}=se(e);await N.mkdir(s,{recursive:!0});let o;do o=`try-${Ct(4).toString("hex")}`;while(Ut(o,e)||It(A.join(s,o)));let i=A.join(s,o);await N.mkdir(i),await N.cp(A.join(t,"assets"),A.join(i,"assets"),{recursive:!0}).catch(c=>{if(c.code!=="ENOENT")throw c}),await N.copyFile(n.json,A.join(i,A.basename(n.json))).catch(c=>{if(c.code!=="ENOENT")throw c});let l=A.join(i,A.basename(n.html));return await N.writeFile(l,a),{slug:o,folder:i,file:l}}async function $t(e,t){let{scratch:n,state:a}=se(e);await N.rm(A.join(n,t),{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{});for(let s of await N.readdir(a).catch(()=>[]))await N.rm(A.join(a,s,t),{recursive:!0,force:!0,maxRetries:3,retryDelay:100}).catch(()=>{})}async function dn(e,t=Date.now()){let{scratch:n}=se(e);for(let a of await N.readdir(n,{withFileTypes:!0}).catch(()=>[])){if(!a.isDirectory()||!/^try-[a-f0-9]{8}$/.test(a.name))continue;let{mtimeMs:s}=await N.stat(A.join(n,a.name)).catch(()=>({mtimeMs:t}));t-s>=zt&&await $t(e,a.name)}}async function mt(e){let t=[...e];for(let a of e)for(let s of await N.readdir(a,{recursive:!0,withFileTypes:!0}).catch(()=>[]))t.push(A.join(s.parentPath,s.name));let n=await Promise.all(t.map(a=>N.stat(a).then(({mtimeMs:s})=>s,()=>0)));return Math.max(...n)}var hn=e=>fetch(`${e}/__gallery/workspace/components`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?t.json():null).then(t=>Array.isArray(t?.packages)?t.packages:null,()=>null);async function fn(e,t,n){let{components:a,marker:s}=se(e),o=Jt(e).find(m=>m.id.toLowerCase()===t)?.folder??A.join(a,...t.split("/")),[i,l]=await Promise.all([mt([s,o]),hn(n)]),{packages:c,problems:r,settings:d}=Ee(e),h=l?.find(m=>m.id===t)??null,f=l?h?.state??"none":null,u=f==="normal"||f==="hidden",w=d.disabled.includes(t),k=r.get(t),y=k&&!w&&u?He("en",k.problem):null,p=l!==null&&c.has(t)&&!u;return{by:i+(y?Ne:me+te),held:y,behind:p,off:w,stamp:(c.get(t)??k)?.stamp??null,state:f,reason:h?.reason?.en??null}}var yt=({state:e,reason:t})=>e==="none"?"no such custom block":t?`it as not loading (${t})`:"it turned off";function un(e,{said:t,unparsed:n=null,off:a,behind:s=!1,state:o,reason:i}){let l="the instance shows what it holds, read-only, so a reader can do nothing with it";return n?`${l}: its kit.js did not parse, so no component of it started, and the console says ${n}`:t.length?`${l}: its component failed as the page started it, and the console says ${t.join("; ")}`:a?`${l}: ${e} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868`:s?`${l}: the server has not taken ${e} as components/ holds it, where it loads: its catalog in use has ${yt({state:o,reason:i})}`:o==="disabled"&&!i?`${l}: ${e} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868`:o==="broken"||o==="disabled"?`${l}: the server has ${e} as not loading (${i}): gallery block check ${e} says why`:o==="none"?`${l}: the server has not taken ${e} as components/ holds it (its catalog in use has no such custom block)`:o?`${l}: the page was served before the server took ${e} as components/ holds it, and did not load itself again with it`:`${l}: its component failed or never started, and the console said nothing of it`}var pn=(e,t,n)=>t.held?`${e} does not load as components/ holds it (${t.held}), and the server keeps it as it was until components/ has not changed for ${Ne/1e3}s, as it keeps a custom block written file by file`:t.behind?`components/ holds ${e} as loading, and the server's catalog in use still has ${yt(t)}: it takes what components/ holds once that has not changed for ${te/1e3}s`:n?`${e} or gallery.json changed a moment ago, and the server takes the change once components/ has not changed for ${te/1e3}s, the page served before loading itself again for it`:`the server took ${e} as components/ holds it, and the page served before is to load itself again with it`,wn=(e,t,n)=>t.held?`the server still keeps ${e} as it was`:t.behind?`the server has still not taken ${e} as components/ holds it`:`the server took ${e} as components/ holds it, and the page did not load itself again with it in ${n/1e3}s`;async function gn({root:e,id:t,origin:n,loadedAt:a,loaded:s,told:o=Kt,say:i=l=>console.log(l)}){let l=Date.now(),c,r=0,d=0,h=!1;for(;;await he(Vt)){let f=await fn(e,t,n),u=Date.now();c!==void 0&&f.stamp!==c&&(r=u),c=f.stamp,f.behind&&!d&&(d=u);let w=Math.max(f.by,...[r,d].filter(Boolean).map(y=>y+me+te)),k=s()?"the page loaded itself again":f.off?`gallery.json turns ${t} off now`:a>=w?`the page was asked for after the server took ${t} as components/ holds it`:u>w+o?wn(t,f,o):null;if(k)return h&&i(`Waited ${((u-l)/1e3).toFixed(1)}s: ${k}`),f;h||w-u<=je&&u-l<=je||(h=!0,i(`Waiting: ${pn(t,f,w>u)}, ${Math.ceil((w+o-u)/1e3)}s more at most`))}}function $n({instance:e,at:t,card:n}){return typeof n=="string"?[...[...document.querySelectorAll(".gallery-board > .gallery-card")].find(s=>s.getAttribute("data-card-id")===n)?.children??[]].find(s=>s.matches(e))??null:[...document.querySelectorAll(e)][t]??null}function mn(e,t){let n=u=>`<${u.localName}${u.classList.length?` class="${u.getAttribute("class")}"`:""}>`,a;try{a=e.querySelector(t)}catch{return{invalid:!0}}if(!a)return{none:!0,held:[...new Set([...e.querySelectorAll("[class]")].filter(u=>u.getClientRects().length>0).flatMap(u=>[...u.classList].map(w=>`.${w}`)))].slice(0,16)};let s=((a instanceof HTMLElement?a.innerText:a.textContent)??"").replace(/\s+/g," ").trim(),o={named:n(a),words:s.length>40?`${s.slice(0,40)}\u2026`:s},i=[...a.getClientRects()].filter(({width:u,height:w})=>u>0&&w>0);if(!i.length)return{...o,hidden:!0};let{left:l,top:c,right:r,bottom:d,width:h,height:f}=i.reduce((u,w)=>u.width*u.height>=w.width*w.height?u:w);return{...o,box:{left:l,top:c,right:r,bottom:d,x:l+h/2,y:c+f/2}}}function yn(e,{selector:t,x:n,y:a}){let s=e.querySelector(t),o=document.elementFromPoint(n,a);return!o||s.contains(o)?null:`<${o.localName}${o.classList.length?` class="${o.getAttribute("class")}"`:""}>`}function kn(e,{at:t,to:n}){let[a,s]=[e.querySelector(t),e.querySelector(n)];return a===s?"same":a.contains(s)?"inside":null}function kt(e){let t=a=>a instanceof Element?`<${a.localName}${a.classList.length?` class="${a.getAttribute("class")}"`:""}>`:"the page",n={edits:[],taken:0,states:[],started:null,dropped:null,effect:null};addEventListener("doc-component-edit",a=>{a.target===e&&(n.edits.push({taken:a.defaultPrevented,parts:(a.detail?.parts??[]).map(({name:s})=>s)}),a.defaultPrevented&&(n.taken+=1))}),new MutationObserver(a=>{for(let{oldValue:s}of a)n.states.push(s);n.states.push(document.documentElement.getAttribute("data-ge-save"))}).observe(document.documentElement,{attributes:!0,attributeFilter:["data-ge-save"],attributeOldValue:!0}),document.addEventListener("dragstart",a=>{n.started=t(a.target)},!0),document.addEventListener("drop",a=>{n.dropped=t(a.target)},!0),document.addEventListener("dragend",a=>{n.effect=a.dataTransfer?.dropEffect??null},!0),globalThis.__galleryTry=n}function bn(){return Object.assign(globalThis.__galleryTry,{edits:[],started:null,dropped:null,effect:null}),{taken:globalThis.__galleryTry.taken}}function bt(e){let t=[...e.querySelectorAll("input, select, textarea")].map(n=>n instanceof HTMLInputElement&&["checkbox","radio"].includes(n.type)?n.checked?"ticked":"not ticked":n.value);return{words:(e.innerText??"").replace(/\s+/g," ").trim(),fields:t}}function vn(e){let n=(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value:e.textContent??"").replace(/\s+/g," ").trim();return n.length>40?`${n.slice(0,40)}\u2026`:n}function xn(e){let t=document.activeElement,n="";if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)try{n=t.value.slice(t.selectionStart??0,t.selectionEnd??0)}catch{}else{let s=getSelection();s&&!s.isCollapsed&&e.contains(s.anchorNode)&&(n=s.toString())}let a=n.replace(/\s+/g," ").trim();return a.length>40?`${a.slice(0,40)}\u2026`:a}function En(e){let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)try{return t.selectionStart===null?null:t.selectionEnd===t.value.length}catch{return null}let n=getSelection();if(!n?.rangeCount||!e.contains(n.focusNode))return null;let a=document.createRange();return a.selectNodeContents(e),a.setStart(n.focusNode,n.focusOffset),a.toString().trim()===""}function Sn(e){let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){t.select();return}let n=document.createRange();n.selectNodeContents(e),getSelection()?.removeAllRanges(),getSelection()?.addRange(n)}function it(e){let t=document.activeElement;return t&&(t===e||e.contains(t)||t instanceof HTMLElement&&t.isContentEditable&&t.contains(e))?null:`<${t?.localName??"body"}>`}function Tn(e){let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){try{t.setSelectionRange(t.value.length,t.value.length)}catch{}return}let n=document.createRange();n.selectNodeContents(e),n.collapse(!1),getSelection()?.removeAllRanges(),getSelection()?.addRange(n)}function Nn(e,{selector:t,value:n}){let a=e.querySelector(t);if(!(a instanceof HTMLSelectElement))return{notSelect:`<${a.localName}${a.classList.length?` class="${a.getAttribute("class")}"`:""}>`};let s=[...a.options],o=s.find(i=>i.value===n)??s.find(i=>i.textContent.trim()===n);return o?a.disabled||o.disabled?{disabled:!0}:(a.focus(),o.selected=!0,a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),{chosen:o.textContent.trim()}):{options:s.map(i=>i.value===i.textContent.trim()?i.value:`${i.value} (${i.textContent.trim()})`)}}async function Fe(e,{still:t,step:n,wait:a=0}){let s=globalThis.__galleryQueries??null,o=Date.now()+a,i=()=>s!==null&&s.pending.size>0&&Date.now()<o,l=()=>new Promise(r=>{requestAnimationFrame(r),setTimeout(r,100)});await l(),await l();let c=e.outerHTML;for(let r=0,d=Date.now()+t;r<3;){if(Date.now()>d)return null;await new Promise(f=>setTimeout(f,n));let h=e.outerHTML;i()?(r=0,d=Date.now()+t):r=h===c?r+1:0,c=h}return c}function On(e,t,{left:n,top:a,right:s,bottom:o}){let i=0;for(let[l,c,r,d]of[[e.x,t.x,n,s],[e.y,t.y,a,o]]){if(c===l)continue;let[h,f]=[(r-l)/(c-l),(d-l)/(c-l)];i=Math.max(i,Math.min(h,f))}return i*Math.hypot(t.x-e.x,t.y-e.y)}function An(e,t){let n=Math.hypot(t.x-e.x,t.y-e.y),a=c=>n===0?{x:e.x,y:e.y}:{x:e.x+(t.x-e.x)*c/n,y:e.y+(t.y-e.y)*c/n},s=Math.min(Ce,n),o=On(e,t,t)-Zt,i=o>s?o:n,l=[a(s/2),a(s)];for(let c=1;c<=et;c++)l.push(a(s+(i-s)*c/et));return i!==n&&l.push({x:t.x,y:t.y}),l}var de={press:"press",drag:"drag",key:"key",type:"typing",select:"choice"},ae=(e,{named:t,words:n})=>`${e} (${t}${n?` "${n}"`:""})`,rt=e=>Object.assign(new T(e),{unfound:!0});async function vt(e,t){let n=t.slice(0,-1);for(let a of n)await e.keyboard.down(a);await e.keyboard.press(t.at(-1));for(let a of n.toReversed())await e.keyboard.up(a)}async function Ln(e,t,n){let a=!1;for(let[s]of n.matchAll(/[\x00-\x7f]+|[^\x00-\x7f]+/gu)){if(/^[\x00-\x7f]/.test(s)){await e.keyboard.type(s);continue}a=!0;for(let o of Qt)await t.send("Input.imeSetComposition",{text:o,selectionStart:o.length,selectionEnd:o.length});await t.send("Input.insertText",{text:s})}return a?/[\x00-\x7f]/.test(n)?"its ASCII key by key and the rest through an input method":"through an input method, composed then committed":"key by key"}async function Cn(e,t,n,a){let s=await In(e,t,n,a);return n.then?(await vt(e,n.then.keys),{...s,said:`${s.said}, then ${n.then.key} pressed where the focus was`}):s}async function In(e,t,n,a){let s=async c=>{let r=await g(t.evaluate(mn,c),"the page was asked what the selector finds");if(r.invalid)throw new T(`Not a selector: ${c}.`);if(r.none)throw rt(`Nothing in the instance is ${c}${r.held.length?`: what it shows has ${r.held.join(", ")}`:": it shows nothing with a class"}.`);if(r.hidden)throw rt(`${c} finds ${r.named} in the instance, which is not shown (it has no box on the page), so a reader cannot reach it: name what it shows.`);return r},o=await s(n.at);if(n.kind==="press"){let{x:c,y:r}=o.box,d=await g(t.evaluate(yn,{selector:n.at,x:c,y:r}),"the page was asked what stands at the press");return await e.mouse.move(c,r),await e.mouse.down(),await e.mouse.up(),{said:`a press on ${ae(n.at,o)}, with the pointer at its middle`,over:d}}if(n.kind==="drag"){let c=await s(n.to),r=await g(t.evaluate(kn,{at:n.at,to:n.to}),"the page was asked where the drag ends");if(r)throw new T(`${r==="same"?`--drag and --to find the same element, ${o.named}`:`--to ${n.to} finds ${c.named}, which stands in what --drag ${n.at} finds, ${o.named}`}: a drag ends where it is dropped, on another element of the instance (another column, another row), which --to names.`);if(Math.hypot(c.box.x-o.box.x,c.box.y-o.box.y)<Ce)throw new T(`The middles of what --drag ${n.at} and --to ${n.to} find stand less than ${Ce}px apart, too near for a drag to start: name with --to where it is dropped, further off.`);let d=An(o.box,c.box);await e.mouse.move(o.box.x,o.box.y),await e.mouse.down();for(let{x:h,y:f}of d)await e.mouse.move(h,f);return await he(qt),await e.mouse.up(),{said:`a drag of ${ae(n.at,o)} to ${ae(n.to,c)}, with the pointer in ${d.length} moves, released as it comes onto it`}}if(n.kind==="select"){let c=await g(t.evaluate(Nn,{selector:n.at,value:n.value}),"the page was asked to choose the option");if(c.notSelect)throw new T(`${n.at} finds ${c.notSelect} in the instance, which is no <select>: --select names a <select> the instance draws, and the option by its value or its words.`);if(c.options)throw new T(`${n.at} has no option ${JSON.stringify(n.value)}: ${c.options.length?`its options are ${c.options.join(", ")}`:"it has no option"}.`);if(c.disabled)throw new T(`${n.at} or its option ${JSON.stringify(n.value)} is disabled, so a reader cannot choose it.`);return{said:`${JSON.stringify(c.chosen)} chosen in ${ae(n.at,o)}, as a reader picks an option`}}let i=await t.$(n.at);if(n.kind==="type"){let c=!1,r=await g(e.evaluate(vn,i),"the page was asked what the field holds");await g(e.evaluate(it,i),"the page was asked where the focus is")&&(await e.mouse.click(o.box.x,o.box.y),await g(e.evaluate(Tn,i),"the caret went to the end"),c=!0),n.replace&&await g(e.evaluate(Sn,i),"all the field holds was selected");let d=await g(e.evaluate(it,i),"the page was asked where the focus is"),h=await g(e.evaluate(xn,i),"the page was asked what is selected"),f=c||!r||n.replace||h?!0:await g(e.evaluate(En,i),"the page was asked where the caret is"),u=await Ln(e,a,n.text),w=c?", pressed first":", where the focus was",k='(--replace, or "replace": true in a step, puts them in its place)',y=n.replace?`${w}, ${r?`all it held (${JSON.stringify(r)}) selected first (--replace), so that the words took its place`:"nothing in it to replace"}`:h?`${w}, ${h===r?"all it held":"part of it"} (${JSON.stringify(h)}) selected already (a step before), so that the words took its place`:c?`, pressed first and the caret at its end${r?`: it held ${JSON.stringify(r)}, and the words went after it ${k}`:""}`:r?f===!1?`, where the focus was, the caret inside what it held (${JSON.stringify(r)}), where a step before left it (a press puts it where the pointer lands, an arrow key moves it), so that the words went in there, not after it ${k}`:f?`, where the focus was, the caret at its end: it held ${JSON.stringify(r)}, and the words went after it ${k}`:`, where the focus was: it held ${JSON.stringify(r)}, and the words went in at the caret, where a step before left it ${k}`:", where the focus was";return{said:`${JSON.stringify(n.text)} typed in ${ae(n.at,o)}${y}, ${u}`,unfocused:d,typed:!0}}await g(i.focus(),"the focus went to the element");let l=await g(e.evaluate(c=>document.activeElement===c||c.contains(document.activeElement)?null:`<${document.activeElement?.localName??"body"}>`,i),"the page was asked where the focus is");return await vt(e,n.keys),{said:`${n.key} pressed with the focus given to ${ae(n.at,o)}, as Tab gives it`,unfocused:l}}var xt=e=>fetch(`${e}/__gallery/workspace/info`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok,()=>!1);async function jn(e,t,n){let a=Date.now();for(let s=0,o=0;;await he(100)){let{seen:i,now:l}=await g(e.evaluate(r=>({seen:globalThis.__galleryTry.states.slice(r),now:document.documentElement.getAttribute("data-ge-save")}),t),"the page was asked where saving stands"),c=l!=="saved"||i.some(r=>r!=="saved");if(c&&l==="saved")return"saved";if(l==="stopped"||l==="reloading")return l;if(s=l==="held"?s+1:0,s>=3)return"held";if(o=l==="offline"?o+1:0,o>0&&o%10===0&&!await xt(n))return"offline";if(!c&&Date.now()-a>Gt)return"unchanged";if(Date.now()-a>Ie)return l}}var Mn=e=>({held:"a card waits for a reader: someone else changed the part meanwhile, and the page held its write for the reader there, which closing the page dropped",offline:"the page could not reach the server (offline)",stopped:"the page stopped saving (stopped): the server refused its write",reloading:"the page loaded itself again (doc.html or a custom block it holds changed meanwhile)",waiting:`it waited ${Ie/1e3}s to be saved and never was`,syncing:`its save took more than ${Ie/1e3}s`})[e];function Rn(e,{parts:t,outside:n,gone:a},{gesture:s,name:o,held:i=!1,scratch:l=!1,aside:c="data-block-id aside"}){if(l)return{unverified:`${e}${!a&&t.length?`, the copy holding what the ${s} wrote, ${Y(t)}`:""}: the trial was made on a scratch copy, gone now, and ${o} holds nothing of it`};let r=n?`; outside the instance's parts -${n.removed} +${n.added} lines someone else wrote meanwhile, which stay`:"";return a?{unverified:`${e}, and ${o} holds the instance no more where it stood: someone else wrote the file meanwhile`}:t.length===0?{unverified:`${e}: ${o} is as it was${n?" in the instance's parts":""} (${c})${r}`}:i?{unverified:`${e}: what ${o} holds of ${Y(t)} is someone else's, which stays${r}`}:{unverified:`${e}: ${o} holds what the ${s} wrote, ${Y(t)}, kept (--keep)${r}`}}function Dn(e,t,{over:n,unfocused:a,refusals:s,name:o}){let i=[];return n&&i.push(`the press landed on ${n}, which stands over it there`),a&&i.push(e==="type"?`the element takes no typing (a field or an editable element), so the words went to ${a}`:`the element takes no focus (a button, a field or a tabindex), so the key went to ${a}`),t.started&&!t.dropped?i.push(`an HTML5 drag started (dragstart on ${t.started}) and nothing took its drop where it was released (dragend's dropEffect ${t.effect??"none"}): a list a card is dropped on cancels dragenter as well as dragover (preventDefault), or a release as the pointer comes onto it drops nothing`):t.dropped&&t.edits.length===0&&i.push(`it was dropped on ${t.dropped}, and no context.edit came of it`),t.edits.some(({taken:l})=>l)?i.push("context.edit was taken, and its change left what the parts hold as it was"):t.edits.length?i.push(`context.edit was called and the page refused it${s.length?`: the console says ${s.join("; ")}`:""}`):t.started||i.push(e==="type"?"no context.edit came of it: the component answers no typing there, or writes what was typed only on a key or as the field loses the focus (then Enter, --then Enter), or asked while context.canEdit() was false":`no context.edit came of it: the component answers no ${de[e]} there, or asked while context.canEdit() was false`),`the ${de[e]} wrote nothing to ${o}: ${i.join("; ")}`}async function Et(e,t){await We(e);let n={own:new Map,others:new Map,dialogs:new Map,pending:[],page:0,from:0},a=new RegExp(`/__gallery/components/${t}/kit\\.js[^:\\s)]*:(\\d+)`),s=(i,l,{at:c="",unparsed:r=!1}={})=>{if(l<n.from)return;let d=i.split(`
8
+ `)[0],h=a.exec(i)??a.exec(c);i.includes(t)||h?n.own.set(d,{line:Number(h?.[1])||null,page:l,unparsed:r&&a.test(c)}):n.others.set(d,{page:l})};e.on("request",i=>{i.isNavigationRequest()&&i.frame()===e.mainFrame()&&(n.page+=1)}),e.on("console",i=>{if(!["error","warn","warning"].includes(i.type())||/^Failed to load resource/.test(i.text()))return;let{page:l}=n;n.pending.push(Promise.all(i.args().map(c=>c.evaluate(r=>r instanceof Error?r.stack:String(r)).catch(()=>""))).then(c=>s(c.join(" ")||i.text(),l)))});let o=await ze(e,{add:i=>n.dialogs.set(i,{page:n.page})});return o.on("Runtime.exceptionThrown",({exceptionDetails:{exception:i,text:l,url:c,lineNumber:r,stackTrace:d}})=>{s(i?.description??String(i?.value??l),n.page,{at:c?`${c}:${r+1}`:"",unparsed:!d&&i?.className==="SyntaxError"})}),await o.send("Runtime.enable"),n}function _n(e){e.from=e.page;for(let t of[e.own,e.others,e.dialogs])for(let[n,{page:a}]of t)a<e.from&&t.delete(n)}var re=e=>Promise.race([Promise.all(e.pending),he(2e3)]);async function Fn(e){let t=n=>e.waitForSelector(n,{timeout:le}).catch(a=>{if(a.name==="TimeoutError")throw a;return e.waitForSelector(n,{timeout:le})});try{return await t("[data-doc-ready]"),await t("html[data-ge-editing][data-ge-save]"),await e.waitForFunction(()=>globalThis.__galleryTryEditable===!0&&document.documentElement.getAttribute("data-ge-save")==="saved",{timeout:le}),!0}catch(n){if(n.name!=="TimeoutError")throw n;return!1}}async function St(e,{where:t,id:n}){let a=await g(e.evaluateHandle($n,{instance:ft,...t}),"the page was asked for the instance"),s=await g(a.evaluate((o,{fallback:i,id:l})=>!(o instanceof Element)||o.getAttribute("data-doc-component")!==l?null:(DocKit.reveal?.(o),{fallback:o.hasAttribute(i),height:o.getBoundingClientRect().height}),{fallback:Rt,id:n}),"the page was asked for the instance");return s?(await e.setViewport({width:De,height:Math.min(Wt,Math.max(_e,Math.ceil(s.height)+240))}),await g(a.evaluate(o=>o.scrollIntoView({block:"center",behavior:"instant"})),"the instance was brought into view"),await g(a.evaluate(Fe,{still:we,step:ge,wait:$e}),"the instance held still"),{host:a,fallback:s.fallback}):null}function Hn({at:e,found:t}){return{where:{at:e},ready:Fn,saves:n=>({mark:()=>g(n.evaluate(()=>globalThis.__galleryTry.states.length),"the page was asked where saving stands"),until:(a,s)=>jn(n,a,s)}),changes:(n,a)=>on(st(n),st(a),e,t),plain:(n,a,s)=>a===n&&Se(n).changes.length>0&&s.parts.length>0,stayed:Mn,outside:"others",aside:"data-block-id aside",inside:Tt}}async function Pn(e){return g(e.evaluate(({instance:t,fields:n})=>{let a=document.activeElement;return a instanceof HTMLElement&&a.closest(t)&&a.matches(n)?(a.blur(),!0):!1},{instance:ft,fields:Dt}),"the focus left the instance's field")}async function Bn(e){await e.keyboard.down("Control"),await e.keyboard.press("z"),await e.keyboard.up("Control")}var Jn=e=>`${e}${[11,12,13].includes(e%100)?"th":["th","st","nd","rd"][e%10]??"th"}`,Un=3,Le=(e,t)=>e.length===1?`the ${de[e[0].kind]}`:`step ${t+1}`,V=e=>e.length===1?`the ${de[e[0].kind]}`:"the steps";function Zn(e,t){if(e.words!==t.words){let a=0;for(;a<e.words.length&&e.words[a]===t.words[a];)a++;let s=o=>JSON.stringify(`${a>20?"\u2026":""}${o.slice(Math.max(0,a-20),a+30)}${o.length>a+30?"\u2026":""}`);return`its words read ${s(e.words)} there and ${s(t.words)} here`}let n=e.fields.findIndex((a,s)=>a!==t.fields[s]);if(n>=0||e.fields.length!==t.fields.length){let a=n>=0?n:Math.min(e.fields.length,t.fields.length);return`its field ${a+1} (of ${e.fields.length}) holds ${JSON.stringify(e.fields[a]??null)} there and ${JSON.stringify(t.fields[a]??null)} here`}return null}var ct=["ticked","not ticked"],qn=["true","false","checked","done"],Wn={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},Me=e=>new Set(e.normalize("NFKC").toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]),lt=e=>e.replace(/<[^>]*>/g," ").replace(/"(?:[^"\\]|\\.)*"\s*:/g," ").replace(/&(?:#(\d+)|#x([\da-f]+)|([a-z]+));/gi,(t,n,a,s)=>{let o=n?Number(n):a?Number.parseInt(a,16):null;return o!==null?o<=1114111?String.fromCodePoint(o):t:Wn[s.toLowerCase()]??t}),dt=e=>qn.map(t=>(e.join(`
9
+ `).toLowerCase().match(new RegExp(`\\b${t}\\b`,"g"))??[]).length).join();function Gn(e){let t=new Set,n=!1;for(let{parts:a}of e)for(let{runs:s=[]}of a)for(let{removed:o,added:i}of s){let[l,c]=[Me(o.map(lt).join(`
10
+ `)),Me(i.map(lt).join(`
11
+ `))];for(let r of c)l.has(r)||t.add(r);for(let r of l)c.has(r)||t.add(r);dt(o)!==dt(i)&&(n=!0)}return{words:t,ticks:n}}function Kn(e,t,n){let a=({words:h,fields:f})=>Me([h,...f.filter(u=>!ct.includes(u))].join(" ")),[s,o]=[a(e),a(t)],i=[...[...s].filter(h=>!o.has(h)),...[...o].filter(h=>!s.has(h))],l=h=>/[^\x00-\x7f]/.test(h),c=h=>[...n.words].some(f=>f===h||[h,f].every(u=>[...u].length>=2)&&[f,h].some(u=>l(u))&&(h.includes(f)||f.includes(h))),r=i.filter(c),d=h=>JSON.stringify(h.fields.filter(f=>ct.includes(f)));return n.ticks&&d(e)!==d(t)&&r.push("a box ticked"),r}async function Vn(e,{root:t,address:n,fresh:a,steps:s,keep:o,file:i,name:l,line:c,found:r,out:d,host:h}){let f=await g(e.createBrowserContext(),"a browser context opened"),u=await g(f.newPage(),"a tab opened"),w=await g(Et(u,r.id),"the tab was set to listen"),k=h.saves(u),y=[w],p={problems:[],notes:[],steps:[]},m=($,O=`${l}:${c}`)=>p.problems.push({where:O,what:$}),L=!o,D=L?`the copy of ${l}`:l,_=new URL(n).origin,C=0,F=0;u.on("request",$=>{!$.isNavigationRequest()||$.frame()!==u.mainFrame()||(C+=1,F=Date.now())});let M=null,H=null,S=async()=>h.changes(H,await N.readFile(i,"utf8").catch(()=>"")),b=($,O,v=!1)=>({...p,unverified:Rn($,O,{gesture:s.length===1?de[s[0].kind]:"steps",name:l,held:v,scratch:L,aside:h.aside}).unverified}),j=h.stayed,Z=await g(u.createCDPSession(),"the tab opened a session");await g(u.evaluateOnNewDocument(()=>addEventListener("doc-editable",()=>{globalThis.__galleryTryEditable=!0})),"the tab was set to tell when the page takes edits"),await g(u.setViewport({width:De,height:_e}),"the window was sized"),await g(u.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]),"the light theme came");try{await g(u.goto(n,{waitUntil:"load",timeout:0}),"the page opened",Oe);let $=null,O=null;for(let x=1;!$;x++){let E=C;try{if(!await h.ready(u))return{...p,unverified:`the page did not come to edit in ${le/1e3}s, so nothing was tried`};if($=await St(u,{where:h.where,id:r.id}),!$)return{...p,unverified:`the page does not hold the instance where ${l} has it (${l} changed meanwhile?), so nothing was tried`};if(await he(Math.max(0,await cn(t,L?null:i)-Date.now())),$.fallback&&(O=await gn({root:t,id:r.id,origin:_,loadedAt:F,loaded:()=>C!==E})),C!==E)throw new Error("the page loaded itself again");if($.fallback)break;if(H=await N.readFile(i,"utf8"),await g($.host.evaluate(kt),"the page was asked to listen"),C!==E)throw new Error("the page loaded itself again")}catch(I){if(C===E||x===Un)throw I;$=null,_n(w)}}let{host:v}=$;if($.fallback){await re(w);let x=[...w.own].map(([E,{line:I,unparsed:z}])=>({words:`${E}${I?` (kit.js:${I})`:""}`,unparsed:z}));return w.own.clear(),m(un(r.id,{said:x.map(({words:E})=>E),unparsed:x.find(({unparsed:E})=>E)?.words??null,...O})),await ht(v,p,d,h.framed)}M=C;let P=H,X=null;for(let[x,E]of s.entries()){let I=Le(s,x),{taken:z}=await g(u.evaluate(bn),"the page was asked to listen"),fe=await k.mark(),W=await Cn(u,v,E,Z),Q=await k.until(fe,_),G=await N.readFile(i,"utf8").catch(()=>""),J=h.changes(P,G);if(p.steps.push({said:W.said,parts:J.parts,outside:J.outside,plain:h.plain(H,P,J),taken:z}),C>M)return b(`after ${I}, ${j("reloading")}`,await S());if(j(Q))return b(`after ${I}, ${j(Q)}`,await S(),Q==="held");if(J.gone)return b(`after ${I}`,await S());X={step:E,gestured:W,heard:await g(u.evaluate(()=>globalThis.__galleryTry),"the page was asked what it heard")};for(let{name:ve,how:R}of J.parts)R&&p.notes.push({where:`${l}:${c}`,what:`${I}'s write lays the part ${ve} out anew (${R}): ${Ge}`});J.parts.length&&(p.steps.at(-1).before=P),P=G}await ht(v,p,d,h.framed);let B=await g(v.evaluate(Fe,{still:we,step:ge,wait:$e}).then(()=>v.evaluate(bt)),"the instance held still"),q=p.steps.filter(({parts:x})=>x.length),be=p.steps.map(x=>x.outside).filter(Boolean);if(h.outside==="problem"?p.steps.forEach((x,E)=>{x.outside&&m(`${Le(s,E)} changed ${l} outside ${h.outsideSaid(x.outside)}`)}):be.length&&(p.others={removed:be.reduce((x,{removed:E})=>x+E,0),added:be.reduce((x,{added:E})=>x+E,0)}),q.length===0){await re(w);let x=[...w.own.keys()].filter(I=>I.includes("context.edit"));for(let I of x)w.own.delete(I);let E=Dn(X.step.kind,X.heard,{...X.gestured,refusals:x,name:D});return m(s.length===1?E:`none of the ${s.length} steps wrote anything to ${D}; of the last, step ${s.length}, ${E}`),p}if(!o){let x=await k.mark();if(await Pn(u)){let W=await k.until(x,_);if(C>M)return b(`as the focus left the instance's field, ${j("reloading")}`,await S());if(j(W))return b(`as the focus left the instance's field, ${j(W)}`,await S(),W==="held")}let E=await g(u.evaluate(()=>globalThis.__galleryTry.taken),"the page was asked what it took"),I=s.length===1,z=0,fe=0;e:for(let[W,Q]of[...q.entries()].toReversed()){let G=Le(s,p.steps.indexOf(Q)),J=Math.max(1,(q[W+1]?.taken??E)-Q.taken),ve=R=>I?R===1?"one Ctrl+Z":`${R} Ctrl+Z`:`${R===1?"the Ctrl+Z":`${R} Ctrl+Z`} for ${G}`;for(let R=1;;R++){let oe=R===1?`the Ctrl+Z for ${G}`:`the ${Jn(R)} Ctrl+Z for ${G}`,At=await k.mark();await Bn(u);let ue=await k.until(At,_),Lt=await N.readFile(i,"utf8").catch(()=>""),xe=h.changes(Q.before,Lt);if(C>M)return b(`after ${oe}, ${j("reloading")}`,await S());if(j(ue))return b(`after ${oe}, ${j(ue)}`,await S(),ue==="held");if(xe.gone)return b(`after ${oe}`,await S());if(ue==="unchanged"){m(`${R===1&&I?"one Ctrl+Z":oe} wrote nothing, so ${D} keeps what ${G} wrote: a reader's undo does not take it back (the component keeps Ctrl+Z from the page where the focus is, or wrote by no context.edit)`);break e}if(xe.parts.length===0){fe+=R;break}if(R>=J){m(`after ${ve(R)}${J>1?", one for each write the page took of it,":""} ${D} is not as it was${I?"":` before ${G}`}, ${Y(xe.parts)} still differing: a reader's undo does not give it back (the component writes again as it hears the part change)`);break e}}z+=1}z===q.length&&Object.assign(p,{undone:z,presses:fe})}if(p.problems.length)return p;await pe(u.close());let Ot=x=>p.notes.push({where:`${l}:${c}`,what:x}),ee=await Qn(f,{...await a(P),host:h,found:r,after:B,written:Gn(q),out:d,hearings:y,problem:m,note:Ot,called:V(s)});return p.readBack=ee.back,p.aside=ee.aside??!1,ee.picture&&(p.fresh=ee.picture),ee.unverified?p.unverified=`${ee.unverified}, so it was not read back`:p.others&&(p.unverified=`someone else wrote ${l} meanwhile, outside the instance's parts (the user's page, an Agent), which stays: try it again once the file holds still`),p}catch($){if($ instanceof T){if(p.steps.length&&($.made=p),!$.unfound||(await re(w),w.own.size===0&&w.dialogs.size===0))throw $;return m(`${$.message[0].toLowerCase()}${$.message.slice(1).replace(/\.$/,"")}; its component did not draw it, and the console says why`),p}let O=M===null?null:await S();if(O&&C>M)return b(`after a gesture, ${j("reloading")}`,O);if(await Ye(e)){let v=`the browser went while waiting until ${$.doing??"the page answered"}`;return O?b(v,O):{...p,unverified:`${v}, so nothing was tried`}}return $.stuck?m(`the page stopped answering while waiting until ${$.doing}: a script that never ends, or a component that changes what it hears`,"the page"):m(`the trial stopped: ${ne($)}`,"the page"),p}finally{let $=new Set;for(let O of y){await re(O);for(let[v,{line:P}]of O.own)!$.has(v)&&$.add(v)&&p.problems.push({where:P?`kit.js:${P}`:"the page",what:`the console says ${v}`});for(let v of O.others.keys())!$.has(v)&&$.add(v)&&p.notes.push({where:"the page",what:`the console says ${v}`});for(let v of O.dialogs.keys())!$.has(v)&&$.add(v)&&p.problems.push({where:"the page",what:`it opened a dialog (${v}), which stops a reader's page until it is answered: show what it says in the instance`})}await pe(f.close())}}function zn(e,t,n,a){console.log(`FAIL ${e}: ${Qe(t)}, so nothing was tried and the browser was closed${a?"":`; the copy of ${n} was taken away`}. A script that never ends does this, and so may a browser that stalled: run the command once more`),process.exitCode=1}async function Qn(e,{address:t,file:n,host:a,found:s,after:o,written:i,out:l,hearings:c,problem:r,note:d,called:h}){let f=await g(e.newPage(),"a tab opened");c.push(await g(Et(f,s.id),"the fresh tab was set to listen"));let u=a.saves(f),w=c.at(-1),k=new URL(t).origin;await g(f.evaluateOnNewDocument(()=>addEventListener("doc-editable",()=>{globalThis.__galleryTryEditable=!0})),"the fresh tab was set to tell when the page takes edits"),await g(f.setViewport({width:De,height:_e}),"the window was sized"),await g(f.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]),"the light theme came");let y=`a fresh page of what ${h} wrote`,p={back:!1};try{let m=await N.readFile(n,"utf8");if(await g(f.goto(t,{waitUntil:"load",timeout:0}),"the fresh page opened",Oe),!await a.ready(f))return{back:!1,unverified:`${y} did not come to edit in ${le/1e3}s`};let L=await St(f,{where:a.where,id:s.id});if(!L)return r(`${y} does not hold the instance where the file has it: what the steps wrote is no instance of ${s.id} as the page reads it`),p;if(L.fallback){await re(w);let b=[...w.own].map(([j,{line:Z}])=>`${j}${Z?` (kit.js:${Z})`:""}`);return w.own.clear(),r(`${y} shows the instance in its fallback, what it holds read-only: its component failed as the page started it, ${b.length?`and the console says ${b.join("; ")}`:"and the console said nothing of it"}: what ${h} wrote is what its mount cannot read`),p}await g(L.host.evaluate(kt),"the fresh page was asked to listen");let D=await u.until(await u.mark(),k);if(D==="offline")return{back:!1,unverified:`${y}: ${a.stayed(D)}`};if(D!=="unchanged"&&D!=="saved")return r(`${y}: ${a.stayed(D)??D}`),p;let _=a.changes(m,await N.readFile(n,"utf8").catch(()=>""));if(_.gone)return{back:!1,unverified:`${y}: its file holds the instance no more where it stood (someone else wrote it meanwhile)`};if(D==="saved"||_.parts.length)return r(`${y} writes ${_.parts.length?Y(_.parts):"it again"} with no gesture as it opens, so that a page would write each time it opened: draw what the parts hold as they are, and write on a gesture alone`),p;let C=await g(L.host.evaluate(Fe,{still:we,step:ge,wait:$e}).then(()=>L.host.evaluate(bt)),"the fresh page's instance held still"),F=Zn(o,C);if(!F)return{back:!0};let M=A.join(l,"fresh.png");await g(L.host.screenshot({path:M}),"the fresh page's instance was pictured").catch(()=>{});let H=`${y} shows the instance otherwise than the page did after ${h.replace(/^the steps$/,"the last step")}: ${F}`,S=Kn(o,C,i);return S.length?(r(`${H} (the fresh page's picture: ${K(M)}), and what differs is of what ${h} wrote (${S.slice(0,3).map(b=>b==="a box ticked"?b:JSON.stringify(b)).join(", ")}). What it draws of what it wrote is to come from its parts alone, read as it wrote them: a value kept in memory, or written in a form its mount does not read, is gone on the next page`),{...p,picture:M}):(d(`${H}; none of it is of what ${h} wrote, and a fresh page keeps no filter or tab chosen, no editor left open, no words typed and not committed (--then Enter commits them), and need not. Its picture: ${K(M)}. What a reader keeps belongs in a part`),{back:!0,aside:!0,picture:M})}catch(m){return await xt(k)?(m.stuck?r(`${y} stopped answering while waiting until ${m.doing}: a script that never ends, or a component that changes what it hears`,"the page"):r(`${y} could not be read back: ${ne(m)}`,"the page"),p):{back:!1,unverified:`the server stopped answering as ${y} opened`}}finally{await pe(f.close())}}async function ht(e,t,n,a=null){let s=A.join(n,"after.png");try{let o=a?await g(e.evaluateHandle(a),"the instance's frame was found"):e;await g(o.screenshot({path:s}),"the instance was pictured"),t.picture=s}catch(o){if(o.stuck)throw o}return t}var U={gesture:"Gesture: ",step:"Step ",wrote:"Wrote: ",undone:"Undone: ",kept:"Kept (--keep): ",readBack:"Read back: ",picture:"Picture of the instance after "},Tt="nothing outside the instance changed (data-block-id aside)",Yn="open it: no one has looked at it for you";function Xn({slug:e,name:t,steps:n,keep:a,host:s=null},o){let i=n.length>1,l=a?t:`the copy of ${t}`,c=s?.aside??"data-block-id aside",r=Nt({name:t,several:i,keep:a,host:s},o.steps),d=o.steps.filter(({parts:p})=>p.length),h=a&&d.some(({plain:p})=>p)?", its plain HTML the kit's markup":"",f=o.presses??o.undone;if(a&&d.length)r.push(`${U.kept}${t} holds what ${V(n)} wrote`);else if(o.undone){let p=i?f===o.undone?`${f} Ctrl+Z, one for each step that wrote, the last first, each giving ${l} back as it was before its step`:`${f} Ctrl+Z for the ${o.undone} step${o.undone===1?"":"s"} that wrote, one for each write the page took, the last first, each step's giving ${l} back as it was before it`:f===1?`one Ctrl+Z, and ${l} is as it was`:`${f} Ctrl+Z, one for each write the page took of ${V(n)}, and ${l} is as it was`;r.push(`${U.undone}${p} (${c}${h})`)}o.readBack&&r.push(`${U.readBack}${a?`${t} opened again in a fresh page`:`a fresh page of what ${V(n)} wrote (a copy of it)`}: the instance mounts, writes nothing as it opens, and shows what the page showed after ${i?"the last step":V(n)}${o.aside?` of what ${i?"they":"it"} wrote; what else the page showed there, which nothing wrote, it does not (the note)`:""}`);for(let{where:p,what:m}of o.problems)r.push(` FAIL ${p}: ${m}`);for(let{where:p,what:m}of o.notes)r.push(` note ${p}: ${m}`);o.picture&&r.push(`${U.picture}${i?"the last step":V(n)}: ${K(o.picture)} (${Yn})`);let u=[o.picture,o.fresh].filter(Boolean);u.length&&r.push(Xe([{folder:A.dirname(u[0]),files:u}]));let w=o.problems.length;if(w)return{lines:[...r,`FAIL ${e}: ${w} problem${w===1?"":"s"}`],code:1};if(o.unverified)return{lines:[...r,`UNVERIFIED ${e}: ${o.unverified}`],code:3};let k=[...new Set(d.flatMap(({parts:p})=>p.map(({name:m})=>m)))].join(" and "),y=a?", kept (--keep)":`, ${f===1?"one Ctrl+Z":`${f} Ctrl+Z`} took ${i?"them":"it"} back`;return{lines:[...r,`OK ${e}: ${V(n)} wrote ${k}${y}, and a fresh page read ${i?"them":"it"} back${a?"":`; ${t} not written (a scratch copy)`}`],code:0}}function Nt({several:e,keep:t,host:n=null},a){let s=[];for(let[o,i]of a.entries()){if(s.push(e?`${U.step}${o+1}: ${i.said}`:`${U.gesture}${i.said}`),i.parts.length===0){e&&s.push(`${U.wrote}nothing`);continue}let l=t&&i.plain?"; and the page wrote the document's plain HTML as the kit's markup, as its first save of an edit does (gallery check and gallery export say what, by line, once), which stays":"",c=i.outside?n?.outside==="problem"?`; and outside ${n.outsideSaid(i.outside)}`:`; outside the instance's parts -${i.outside.removed} +${i.outside.added} lines someone else wrote meanwhile (the user's page, an Agent), which stay`:`; ${n?.inside??Tt}`;s.push(`${U.wrote}${Y(i.parts)}${c}${l}`,...rn(i.parts))}return s}function ea({name:e,steps:t,keep:n,host:a=null},s){let o=s.steps.length,i=o===1?"step 1":`steps 1 to ${o}`,l=s.steps.some(({parts:d})=>d.length),c=Nt({name:e,several:t.length>1,keep:n,host:a},s.steps),r=`step ${o+1} was not made, for the mistake below`;return n?c.push(l?`${U.kept}${e} holds what ${i} wrote, which stays; ${r}`:`Not made: ${r}; ${i} wrote nothing to ${e}`):c.push(`Not made: ${r}; ${i} ${l?"wrote to":"made"} a scratch copy, gone now, and ${e} holds nothing of ${o===1?"it":"them"}`),c}async function ka(e,{named:t,values:n,seconds:a={},keep:s,replace:o=!1}){let i=await Yt(n,a,o),l=i?[i]:null;if(t.length===0)throw new T("Name the document: gallery block try <slug> [<instance id>] and the gesture.");if(t.length>2)throw new T("gallery block try takes a document and an instance's id at most.");let c=n.has("--steps")?A.resolve(n.get("--steps")):null,r=l??await Xt(c),{slug:d,block:h}=await Pe(t[0]),f=Pt(d,e),u=Bt(f),w=u.html,k=await N.readFile(w,"utf8").catch(()=>null);k===null&&(console.error(`No document "${d}": ${K(w)} does not exist (gallery list lists those there are).`),process.exit(1));let y=wt(k);y.length===0&&(console.error(`${d} holds no instance of a custom block (an element with ${ke}): gallery block list says which there are, and gallery block show <id> how to write one.`),process.exit(1));let p=A.basename(w),m=nn(y,t[1]??h,{slug:d,name:p}),{id:L,line:D}=y[m],_=Ee(e),C=_.packages.get(L);if(!C){let S=_.problems.get(L);console.error(S?.off?`${L} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868: its instances show what they hold, read-only, so a reader can do nothing with them.`:S?`${L} does not load, so its instances show what they hold, read-only: gallery block check ${L} says why.`:`No component ${L} in this workspace, so its instance shows what it holds, read-only: gallery block list says which there are.`),process.exit(1)}console.log(`${L} in ${d}, ${gt(y[m],p)}: ${K(w)}`),c&&console.log(`Steps: ${r.length} from ${K(c)}, made one after another in one page`);let F=await Je({slug:d,command:`gallery block try ${d}`});if(!F.ok){console.log(`UNVERIFIED ${d}: ${F.message}`),process.exitCode=3;return}await dn(e);let M=[],H=async S=>{let b=await ln(e,{directory:f,files:u,text:S});return M.push(b.slug),b};try{let S=s?{slug:d,file:w}:await H(k),b=Te(F.port,S.slug);console.log(s?`Page: ${b} (the document's page alone, editable: the Agent's own; --keep: what ${V(r)} write stays in ${p}; the server runs on after this command)`:`Page: ${b} (a scratch copy of ${d}, its page alone, editable, made for this trial and gone at its end: ${p} is not written, and no page of the user's shows the trial; the server runs on after this command)`);let j=Ue();if(!j){console.log(`UNVERIFIED ${d}: no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one), so nothing was tried`),process.exitCode=3;return}let Z;try{Z=await qe({executablePath:j,args:Ze()})}catch(O){console.log(`UNVERIFIED ${d}: the browser ${j} did not start, twice, each time with a fresh profile (${ne(O)}; GALLERY_BROWSER=<its executable> picks another), so nothing was tried`),process.exitCode=3;return}let $=A.join(se(e).qa,d,"try");try{await N.rm($,{recursive:!0,force:!0}),await N.mkdir($,{recursive:!0});let O=async B=>{if(s)return{address:b,file:S.file};let q=await H(B);return{address:Te(F.port,q.slug),file:q.file}},v;try{v=await Vn(Z.browser,{root:e,address:b,fresh:O,steps:r,keep:s,file:S.file,name:p,line:D,found:C,out:$,host:Hn({at:m,found:C})})}catch(B){if(B instanceof T&&B.made&&console.log(ea({name:p,steps:r,keep:s},B.made).join(`
12
+ `)),B.stuck)return zn(d,B,p,s);throw B}let{lines:P,code:X}=Xn({slug:d,name:p,steps:r,keep:s},v);console.log(P.join(`
13
+ `)),process.exitCode=X}finally{await Z.close()}}finally{for(let S of M)await $t(e,S)}}export{le as a,Gt as b,Ie as c,at as d,ie as e,ut as f,Yt as g,Xt as h,wt as i,gt as j,nn as k,an as l,st as m,ot as n,on as o,rn as p,cn as q,ln as r,$t as s,dn as t,fn as u,un as v,gn as w,Fe as x,An as y,Rn as z,Dn as A,Et as B,_n as C,Hn as D,V as E,Zn as F,Me as G,Gn as H,Kn as I,Vn as J,zn as K,U as L,Tt as M,Yn as N,Xn as O,ea as P,ka as Q};
@@ -0,0 +1,4 @@
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(`
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
+ ${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,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{d as m,i as g,k as p}from"./chunk-NFMCP2HI.mjs";import{b as a,f as l,i as c}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{reportsDirectory as i}from"../browser/shared/paths.mjs";import{joinDefaultTree as b,joinedLine as k}from"../browser/shared/drafts.mjs";var D=5e3;async function v(f){let{positional:s,options:u}=l({options:["--no-browser"],argv:f});if(s.length>1)throw new a("Name one document at most.");let{slug:o=null,block:w=null}=s.length?await c(s[0]):{};console.log(`\u5DE5\u4F5C\u533A\uFF1A${i}`);let e=await g({slug:o,baseline:o!==null});if(e.ok||console.error(e.message),e.reason==="missing"){let{HOME:n,pageExists:d}=await import("../browser/shared/pages.mjs"),{missingPageSaid:E,HOME_NOT_MADE:r}=await import("./chunk-2NRBY6AJ.mjs");d(o,i)?console.error(`"${o}" is a custom page, not a document: gallery page open ${o} opens it and gives its address.`):o===n&&await E(o,i)===r&&console.error(r)}if(o!==null&&e.reason!=="missing"){let{roundBegins:n}=await import("./chunk-4AV456RQ.mjs");await n(o,e.ok?{}:{wait:D})}if(o!==null&&e.reason!=="missing"){let n=k(await b(i,o));n&&console.log(n)}e.ok||process.exit(1);let t=await p(o,e,w);for(let n of t)console.log(n);console.log(await m(t,u))}export{v as run};