@heycys/gallery 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/browser/editor/components/align.mjs +58 -0
- package/browser/editor/components/code/index.mjs +1 -1
- package/browser/editor/components/columns/page.mjs +4 -4
- package/browser/editor/components/embed/index.mjs +2 -2
- package/browser/editor/components/embed/page.mjs +1 -1
- package/browser/editor/components/file/page.mjs +4 -4
- package/browser/editor/components/flowchart/add.mjs +7 -6
- package/browser/editor/components/flowchart/page.mjs +1 -1
- package/browser/editor/components/heading/index.mjs +7 -6
- package/browser/editor/components/icons.mjs +11 -0
- package/browser/editor/components/image/crop.mjs +6 -9
- package/browser/editor/components/image/index.mjs +2 -0
- package/browser/editor/components/image/page.mjs +172 -90
- package/browser/editor/components/installed/index.mjs +15 -4
- package/browser/editor/components/installed/page.mjs +103 -25
- package/browser/editor/components/installed/served.mjs +6 -5
- package/browser/editor/components/instances.mjs +18 -0
- package/browser/editor/components/list/page.mjs +3 -6
- package/browser/editor/components/media/icons.mjs +13 -8
- package/browser/editor/components/media/page.mjs +5 -3
- package/browser/editor/components/media/toolbar.mjs +12 -3
- package/browser/editor/components/paragraph/index.mjs +4 -3
- package/browser/editor/components/registry.mjs +30 -9
- package/browser/editor/components/table/index.mjs +61 -2
- package/browser/editor/components/table/page.mjs +1 -1
- package/browser/editor/page/after/index.mjs +288 -0
- package/browser/editor/page/align.mjs +91 -0
- package/browser/editor/page/annotate/card.mjs +3 -6
- package/browser/editor/page/autosave.mjs +310 -37
- package/browser/editor/page/beside.mjs +5 -6
- package/browser/editor/page/block-menu/index.mjs +6 -3
- package/browser/editor/page/blocks.mjs +3 -1
- package/browser/editor/page/board/client.mjs +57 -0
- package/browser/editor/page/board/hint.mjs +182 -0
- package/browser/editor/page/board/history.mjs +119 -0
- package/browser/editor/page/board/index.mjs +1059 -0
- package/browser/editor/page/board/motion.mjs +177 -0
- package/browser/editor/page/board/settings.mjs +210 -0
- package/browser/editor/page/caret.mjs +1 -1
- package/browser/editor/page/changes/bar.mjs +6 -14
- package/browser/editor/page/changes/index.mjs +2 -2
- package/browser/editor/page/clipboard/import/html.mjs +29 -6
- package/browser/editor/page/clipboard/import/inline.mjs +32 -0
- package/browser/editor/page/clipboard/import/markdown.mjs +58 -13
- package/browser/editor/page/clipboard/import/read.mjs +6 -1
- package/browser/editor/page/clipboard/import/to-blocks.mjs +44 -12
- package/browser/editor/page/clipboard/import/yuque.mjs +622 -0
- package/browser/editor/page/clipboard/index.mjs +133 -15
- package/browser/editor/page/clipboard/own/blocks.mjs +13 -14
- package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
- package/browser/editor/page/clipboard/own/describe.mjs +6 -2
- package/browser/editor/page/clipboard/own/selection.mjs +1 -1
- package/browser/editor/page/columns/index.mjs +48 -46
- package/browser/editor/page/commit.mjs +80 -22
- package/browser/editor/page/conflicts.mjs +7 -7
- package/browser/editor/page/core.mjs +34 -16
- package/browser/editor/page/custom-page.mjs +110 -0
- package/browser/editor/page/editor.mjs +71 -17
- package/browser/editor/page/emoji-picker/styles.mjs +7 -12
- package/browser/editor/page/emoji-picker/upload.mjs +2 -2
- package/browser/editor/page/handle/index.mjs +5 -8
- package/browser/editor/page/history.mjs +41 -6
- package/browser/editor/page/insert/index.mjs +20 -22
- package/browser/editor/page/links/index.mjs +5 -3
- package/browser/editor/page/links/pages.mjs +27 -9
- package/browser/editor/page/look.mjs +54 -3
- package/browser/editor/page/margin.mjs +18 -3
- package/browser/editor/page/media-menu/index.mjs +6 -7
- package/browser/editor/page/menu.mjs +33 -14
- package/browser/editor/page/notices.mjs +2 -2
- package/browser/editor/page/page-objects.mjs +9 -2
- package/browser/editor/page/panel.mjs +4 -9
- package/browser/editor/page/present-links.mjs +15 -5
- package/browser/editor/page/present-shell.mjs +63 -0
- package/browser/editor/page/resize/index.mjs +42 -29
- package/browser/editor/page/selection/index.mjs +10 -2
- package/browser/editor/page/served.mjs +14 -0
- package/browser/editor/page/session.mjs +48 -4
- package/browser/editor/page/slash-menu/index.mjs +3 -3
- package/browser/editor/page/table/binding.mjs +87 -0
- package/browser/editor/page/table/cells.mjs +102 -46
- package/browser/editor/page/table/index.mjs +24 -9
- package/browser/editor/page/table/pictures.mjs +299 -0
- package/browser/editor/page/table/views.mjs +103 -0
- package/browser/editor/page/table/widths.mjs +82 -10
- package/browser/editor/page/text-select/index.mjs +26 -12
- package/browser/editor/page/todo-writes.mjs +75 -0
- package/browser/editor/page/typing/index.mjs +97 -15
- package/browser/editor/page/typing/leave.mjs +19 -5
- package/browser/editor/page/ui.mjs +13 -0
- package/browser/shared/block-packs.mjs +419 -0
- package/browser/shared/board-places.mjs +224 -0
- package/browser/shared/card-size.mjs +59 -0
- package/browser/shared/colors.mjs +3 -2
- package/browser/shared/component-catalog.mjs +330 -46
- package/browser/shared/component-source.mjs +39 -0
- package/browser/shared/components/heading.mjs +2 -1
- package/browser/shared/components/index.mjs +12 -3
- package/browser/shared/components/installed.mjs +35 -3
- package/browser/shared/components/page.mjs +20 -8
- package/browser/shared/components/paragraph.mjs +8 -1
- package/browser/shared/components/state.mjs +5 -1
- package/browser/shared/components/table.mjs +1 -0
- package/browser/shared/document-look.mjs +10 -5
- package/browser/shared/drafts.mjs +432 -0
- package/browser/shared/emoji/line-icons.mjs +37 -0
- package/browser/shared/extension-sidebar.mjs +126 -0
- package/browser/shared/extensions.mjs +79 -0
- package/browser/shared/file-table.mjs +101 -0
- package/browser/shared/http.mjs +9 -0
- package/browser/shared/i18n/en.mjs +330 -27
- package/browser/shared/json-layout.mjs +47 -0
- package/browser/shared/net-cache.mjs +133 -0
- package/browser/shared/net-keys.mjs +32 -0
- package/browser/shared/net-policy.mjs +177 -0
- package/browser/shared/outline-shape.mjs +128 -0
- package/browser/shared/outline.mjs +359 -67
- package/browser/shared/pack-manifest.mjs +88 -0
- package/browser/shared/page-address.mjs +6 -3
- package/browser/shared/page-cards.mjs +308 -0
- package/browser/shared/page-links.mjs +69 -6
- package/browser/shared/pages.mjs +500 -0
- package/browser/shared/paths.mjs +6 -0
- package/browser/shared/pinyin.mjs +92 -0
- package/browser/shared/present-step.mjs +17 -0
- package/browser/shared/preview-server.mjs +3 -7
- package/browser/shared/session.mjs +8 -1
- package/browser/shared/shipped-blocks.mjs +299 -0
- package/browser/shared/sidebar-head.mjs +70 -0
- package/browser/shared/table-chart.mjs +33 -1
- package/browser/shared/todos.mjs +83 -0
- package/browser/shared/user-directory.mjs +24 -0
- package/browser/shared/versions.mjs +14 -0
- package/browser/shared/web-links.mjs +139 -0
- package/browser/shared/workspace-columns.mjs +120 -0
- package/browser/shared/workspace-name.mjs +154 -0
- package/browser/shared/workspace-query.mjs +125 -0
- package/browser/shared/workspace-registry.mjs +272 -0
- package/browser/shared/workspace.mjs +171 -20
- package/dist/chunk-2OHANJ6Q.mjs +2 -0
- package/dist/chunk-3MBRL2PM.mjs +16 -0
- package/dist/chunk-4OKWZY5E.mjs +2 -0
- package/dist/chunk-4OZWXZE5.mjs +5 -0
- package/dist/chunk-5K44HLTZ.mjs +2 -0
- package/dist/{chunk-5ZKJ3H4P.mjs → chunk-5XA2ZBAE.mjs} +3 -3
- package/dist/{chunk-4FS7Z7WR.mjs → chunk-67N2QJYT.mjs} +1 -1
- package/dist/chunk-6KBYRA2C.mjs +2 -0
- package/dist/chunk-6N3PX4XX.mjs +8 -0
- package/dist/{chunk-V5JTW2LH.mjs → chunk-6QBHU4DF.mjs} +1 -1
- package/dist/chunk-7JDX4E65.mjs +13 -0
- package/dist/chunk-7M2BQQGZ.mjs +2 -0
- package/dist/chunk-7OG26PGF.mjs +2 -0
- package/dist/chunk-AHN3NFKJ.mjs +3 -0
- package/dist/chunk-ALZ6ZENZ.mjs +3 -0
- package/dist/chunk-AR5D57ZD.mjs +170 -0
- package/dist/{chunk-W3BGBJQW.mjs → chunk-BFJGHSQN.mjs} +1 -1
- package/dist/{chunk-LS4F7JUM.mjs → chunk-BZ5RAF7L.mjs} +1 -1
- package/dist/chunk-CMA72MAG.mjs +2 -0
- package/dist/{chunk-LCTHTZIL.mjs → chunk-DAZL73VK.mjs} +91 -91
- package/dist/{chunk-Y6RLRPG3.mjs → chunk-DJISHPUL.mjs} +1 -1
- package/dist/chunk-DR73Y2UJ.mjs +3 -0
- package/dist/{chunk-FDLXYYG4.mjs → chunk-EAIFITAV.mjs} +1 -1
- package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
- package/dist/chunk-EP25HDAJ.mjs +2 -0
- package/dist/{chunk-GB5SOYQJ.mjs → chunk-ERLAIBOA.mjs} +2 -2
- package/dist/chunk-EURLTOTZ.mjs +4 -0
- package/dist/chunk-F4ZA6JRZ.mjs +3 -0
- package/dist/chunk-F6HVDZR4.mjs +2 -0
- package/dist/chunk-FDMAXMQA.mjs +2 -0
- package/dist/chunk-FETSREUN.mjs +5 -0
- package/dist/chunk-GHOYKMQ3.mjs +4 -0
- package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
- package/dist/chunk-HDWTZ763.mjs +12 -0
- package/dist/chunk-HPOI4ZX7.mjs +6 -0
- package/dist/{chunk-BGGDRNYQ.mjs → chunk-HXG7EOPJ.mjs} +1 -1
- package/dist/chunk-IA4PSIMD.mjs +2 -0
- package/dist/{chunk-E7LWZRXY.mjs → chunk-ITOH5EGO.mjs} +1 -1
- package/dist/chunk-IV64FFI4.mjs +2 -0
- package/dist/chunk-J43Z6LSS.mjs +2 -0
- package/dist/chunk-J5PUIV3Y.mjs +4 -0
- package/dist/chunk-JA7G53PC.mjs +2 -0
- package/dist/chunk-JEUK3ZO7.mjs +2 -0
- package/dist/chunk-JLTZF4LA.mjs +2 -0
- package/dist/chunk-JZT7I2OJ.mjs +2 -0
- package/dist/chunk-K5XATEOO.mjs +2 -0
- package/dist/chunk-L2SUIS5S.mjs +2 -0
- package/dist/chunk-L7UP52JO.mjs +2 -0
- package/dist/chunk-LM4XFQHZ.mjs +2 -0
- package/dist/chunk-MN7BZL4R.mjs +2 -0
- package/dist/chunk-MTYYHM2G.mjs +15 -0
- package/dist/chunk-MXUBKDRO.mjs +15 -0
- package/dist/chunk-NAMN3RAF.mjs +2 -0
- package/dist/{chunk-SYGN7GLU.mjs → chunk-OEXWRJME.mjs} +1 -1
- package/dist/chunk-OFHXGWOX.mjs +2 -0
- package/dist/chunk-ORID3AE7.mjs +166 -0
- package/dist/chunk-PAREWQGB.mjs +4 -0
- package/dist/chunk-PGDE24N5.mjs +2 -0
- package/dist/chunk-POTA2FV4.mjs +2 -0
- package/dist/chunk-PUOQ65NC.mjs +2 -0
- package/dist/chunk-Q4UEPUWF.mjs +2 -0
- package/dist/chunk-QE5RG76S.mjs +549 -0
- package/dist/chunk-R2ZDLJYT.mjs +10 -0
- package/dist/{chunk-7DTINW6U.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
- package/dist/chunk-SWUTTZCN.mjs +2 -0
- package/dist/chunk-TANZRINB.mjs +2 -0
- package/dist/chunk-TR7TWGHB.mjs +2 -0
- package/dist/chunk-U5XL7D6A.mjs +3 -0
- package/dist/{chunk-XNROSH2T.mjs → chunk-U7NZI6N4.mjs} +2 -2
- package/dist/chunk-UGWMMEJ5.mjs +15 -0
- package/dist/chunk-UJQJKNGK.mjs +2 -0
- package/dist/chunk-UYVCQK3H.mjs +22 -0
- package/dist/chunk-VFX2KNHP.mjs +4 -0
- package/dist/chunk-VS7JIGJW.mjs +24 -0
- package/dist/chunk-W7665ZEC.mjs +6 -0
- package/dist/chunk-WQDQWCX5.mjs +2 -0
- package/dist/chunk-YI43RG4P.mjs +2 -0
- package/dist/chunk-YLPSMDIS.mjs +5 -0
- package/dist/chunk-YNAWBAYN.mjs +3 -0
- package/dist/chunk-YROX2O22.mjs +2 -0
- package/dist/chunk-ZDLPUOAG.mjs +6 -0
- package/dist/{chunk-IVDLMMBD.mjs → chunk-ZHEHPMBK.mjs} +1 -1
- package/dist/chunk-ZQS6H473.mjs +16 -0
- package/dist/chunk-ZTHICSSF.mjs +2 -0
- package/dist/chunk-ZWWC4KLF.mjs +20 -0
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{chunk-U6KNPJPR.mjs → update-fetch.mjs} +1 -1
- package/dist/worker.mjs +1 -1
- package/kit/board.css +95 -0
- package/kit/board.js +250 -0
- package/kit/charts.js +5 -71
- package/kit/code.js +17 -17
- package/kit/report.css +335 -18
- package/kit/runtime.js +1638 -125
- package/kit/state.js +10 -1
- package/kit/tables.js +130 -43
- package/kit/ui.js +79 -35
- package/package.json +2 -1
- package/packs/gallery/card/component.json +14 -0
- package/packs/gallery/card/example.html +10 -0
- package/packs/gallery/card/preview.svg +1 -0
- package/packs/gallery/card/style.css +6 -0
- package/packs/gallery/card/template.html +6 -0
- package/packs/gallery/card/writing.md +14 -0
- package/packs/gallery/chart-card/component.json +15 -0
- package/packs/gallery/chart-card/example.html +14 -0
- package/packs/gallery/chart-card/kit.js +130 -0
- package/packs/gallery/chart-card/preview.svg +1 -0
- package/packs/gallery/chart-card/style.css +42 -0
- package/packs/gallery/chart-card/template.html +13 -0
- package/packs/gallery/chart-card/writing.md +20 -0
- package/packs/gallery/chart-view/component.json +20 -0
- package/packs/gallery/chart-view/example.html +13 -0
- package/packs/gallery/chart-view/kit.js +355 -0
- package/packs/gallery/chart-view/preview.svg +1 -0
- package/packs/gallery/chart-view/style.css +94 -0
- package/packs/gallery/chart-view/template.html +3 -0
- package/packs/gallery/chart-view/writing.md +22 -0
- package/packs/gallery/countdown/component.json +18 -0
- package/packs/gallery/countdown/example.html +3 -0
- package/packs/gallery/countdown/kit.js +216 -0
- package/packs/gallery/countdown/preview.svg +1 -0
- package/packs/gallery/countdown/style.css +118 -0
- package/packs/gallery/countdown/template.html +3 -0
- package/packs/gallery/countdown/writing.md +22 -0
- package/packs/gallery/habit/component.json +14 -0
- package/packs/gallery/habit/example.html +3 -0
- package/packs/gallery/habit/kit.js +334 -0
- package/packs/gallery/habit/preview.svg +1 -0
- package/packs/gallery/habit/style.css +174 -0
- package/packs/gallery/habit/template.html +3 -0
- package/packs/gallery/habit/writing.md +21 -0
- package/packs/gallery/heatmap/component.json +18 -0
- package/packs/gallery/heatmap/example.html +3 -0
- package/packs/gallery/heatmap/kit.js +513 -0
- package/packs/gallery/heatmap/preview.svg +1 -0
- package/packs/gallery/heatmap/style.css +189 -0
- package/packs/gallery/heatmap/template.html +3 -0
- package/packs/gallery/heatmap/writing.md +21 -0
- package/packs/gallery/kanban/component.json +18 -0
- package/packs/gallery/kanban/example.html +12 -0
- package/packs/gallery/kanban/kit.js +540 -0
- package/packs/gallery/kanban/preview.svg +1 -0
- package/packs/gallery/kanban/style.css +212 -0
- package/packs/gallery/kanban/template.html +3 -0
- package/packs/gallery/kanban/writing.md +20 -0
- package/packs/gallery/metric/component.json +22 -0
- package/packs/gallery/metric/example.html +15 -0
- package/packs/gallery/metric/kit.js +248 -0
- package/packs/gallery/metric/preview.svg +1 -0
- package/packs/gallery/metric/style.css +92 -0
- package/packs/gallery/metric/template.html +3 -0
- package/packs/gallery/metric/writing.md +23 -0
- package/packs/gallery/note/component.json +14 -0
- package/packs/gallery/note/example.html +3 -0
- package/packs/gallery/note/kit.js +129 -0
- package/packs/gallery/note/preview.svg +1 -0
- package/packs/gallery/note/style.css +97 -0
- package/packs/gallery/note/template.html +3 -0
- package/packs/gallery/note/writing.md +18 -0
- package/packs/gallery/pack.json +8 -0
- package/packs/gallery/recent/component.json +13 -0
- package/packs/gallery/recent/example.html +1 -0
- package/packs/gallery/recent/kit.js +293 -0
- package/packs/gallery/recent/preview.svg +1 -0
- package/packs/gallery/recent/style.css +85 -0
- package/packs/gallery/recent/template.html +1 -0
- package/packs/gallery/recent/writing.md +15 -0
- package/packs/gallery/static/component.json +13 -0
- package/packs/gallery/static/example.html +11 -0
- package/packs/gallery/static/preview.svg +1 -0
- package/packs/gallery/static/style.css +171 -0
- package/packs/gallery/static/template.html +1 -0
- package/packs/gallery/static/writing.md +18 -0
- package/packs/gallery/stats/component.json +13 -0
- package/packs/gallery/stats/example.html +1 -0
- package/packs/gallery/stats/kit.js +347 -0
- package/packs/gallery/stats/preview.svg +1 -0
- package/packs/gallery/stats/style.css +73 -0
- package/packs/gallery/stats/template.html +1 -0
- package/packs/gallery/stats/writing.md +11 -0
- package/packs/gallery/today/component.json +12 -0
- package/packs/gallery/today/example.html +1 -0
- package/packs/gallery/today/kit.js +220 -0
- package/packs/gallery/today/preview.svg +1 -0
- package/packs/gallery/today/style.css +149 -0
- package/packs/gallery/today/template.html +1 -0
- package/packs/gallery/today/writing.md +14 -0
- package/packs/gallery/todos/component.json +19 -0
- package/packs/gallery/todos/example.html +3 -0
- package/packs/gallery/todos/kit.js +489 -0
- package/packs/gallery/todos/preview.svg +1 -0
- package/packs/gallery/todos/style.css +214 -0
- package/packs/gallery/todos/template.html +3 -0
- package/packs/gallery/todos/writing.md +30 -0
- package/packs/gallery/weather/component.json +19 -0
- package/packs/gallery/weather/example.html +3 -0
- package/packs/gallery/weather/kit.js +387 -0
- package/packs/gallery/weather/preview.svg +1 -0
- package/packs/gallery/weather/style.css +140 -0
- package/packs/gallery/weather/template.html +3 -0
- package/packs/gallery/weather/writing.md +26 -0
- package/packs/gallery-soft/countdown/component.json +18 -0
- package/packs/gallery-soft/countdown/example.html +3 -0
- package/packs/gallery-soft/countdown/kit.js +206 -0
- package/packs/gallery-soft/countdown/preview.svg +1 -0
- package/packs/gallery-soft/countdown/style.css +211 -0
- package/packs/gallery-soft/countdown/template.html +3 -0
- package/packs/gallery-soft/countdown/writing.md +24 -0
- package/packs/gallery-soft/habit/component.json +14 -0
- package/packs/gallery-soft/habit/example.html +3 -0
- package/packs/gallery-soft/habit/kit.js +366 -0
- package/packs/gallery-soft/habit/preview.svg +1 -0
- package/packs/gallery-soft/habit/style.css +251 -0
- package/packs/gallery-soft/habit/template.html +3 -0
- package/packs/gallery-soft/habit/writing.md +23 -0
- package/packs/gallery-soft/heatmap/component.json +18 -0
- package/packs/gallery-soft/heatmap/example.html +3 -0
- package/packs/gallery-soft/heatmap/kit.js +498 -0
- package/packs/gallery-soft/heatmap/preview.svg +1 -0
- package/packs/gallery-soft/heatmap/style.css +181 -0
- package/packs/gallery-soft/heatmap/template.html +3 -0
- package/packs/gallery-soft/heatmap/writing.md +23 -0
- package/packs/gallery-soft/note/component.json +14 -0
- package/packs/gallery-soft/note/example.html +3 -0
- package/packs/gallery-soft/note/kit.js +162 -0
- package/packs/gallery-soft/note/preview.svg +1 -0
- package/packs/gallery-soft/note/style.css +148 -0
- package/packs/gallery-soft/note/template.html +3 -0
- package/packs/gallery-soft/note/writing.md +20 -0
- package/packs/gallery-soft/pack.json +8 -0
- package/packs/gallery-soft/recent/component.json +13 -0
- package/packs/gallery-soft/recent/example.html +1 -0
- package/packs/gallery-soft/recent/kit.js +335 -0
- package/packs/gallery-soft/recent/preview.svg +1 -0
- package/packs/gallery-soft/recent/style.css +160 -0
- package/packs/gallery-soft/recent/template.html +1 -0
- package/packs/gallery-soft/recent/writing.md +17 -0
- package/packs/gallery-soft/static/component.json +13 -0
- package/packs/gallery-soft/static/example.html +12 -0
- package/packs/gallery-soft/static/preview.svg +1 -0
- package/packs/gallery-soft/static/style.css +186 -0
- package/packs/gallery-soft/static/template.html +1 -0
- package/packs/gallery-soft/static/writing.md +20 -0
- package/packs/gallery-soft/stats/component.json +13 -0
- package/packs/gallery-soft/stats/example.html +1 -0
- package/packs/gallery-soft/stats/kit.js +341 -0
- package/packs/gallery-soft/stats/preview.svg +1 -0
- package/packs/gallery-soft/stats/style.css +119 -0
- package/packs/gallery-soft/stats/template.html +1 -0
- package/packs/gallery-soft/stats/writing.md +13 -0
- package/packs/gallery-soft/today/component.json +12 -0
- package/packs/gallery-soft/today/example.html +1 -0
- package/packs/gallery-soft/today/kit.js +222 -0
- package/packs/gallery-soft/today/preview.svg +1 -0
- package/packs/gallery-soft/today/style.css +178 -0
- package/packs/gallery-soft/today/template.html +1 -0
- package/packs/gallery-soft/today/writing.md +16 -0
- package/packs/gallery-soft/todos/component.json +19 -0
- package/packs/gallery-soft/todos/example.html +3 -0
- package/packs/gallery-soft/todos/kit.js +527 -0
- package/packs/gallery-soft/todos/preview.svg +1 -0
- package/packs/gallery-soft/todos/style.css +212 -0
- package/packs/gallery-soft/todos/template.html +3 -0
- package/packs/gallery-soft/todos/writing.md +32 -0
- package/packs/gallery-soft/weather/component.json +19 -0
- package/packs/gallery-soft/weather/example.html +3 -0
- package/packs/gallery-soft/weather/kit.js +411 -0
- package/packs/gallery-soft/weather/preview.svg +1 -0
- package/packs/gallery-soft/weather/style.css +185 -0
- package/packs/gallery-soft/weather/template.html +3 -0
- package/packs/gallery-soft/weather/writing.md +28 -0
- package/release.json +12 -10
- package/sdk/doc-kit.d.ts +396 -5
- package/sdk/doc-state.d.ts +2 -0
- package/skill/SKILL.md +56 -23
- package/skill/references/block-script.md +140 -0
- package/skill/references/building-blocks.md +257 -0
- package/skill/references/extensions.md +59 -0
- package/skill/references/pages-and-data.md +225 -0
- package/skill/references/writing-html.md +8 -4
- package/skill/sdk/doc-kit.d.ts +396 -5
- package/skill/sdk/doc-state.d.ts +2 -0
- package/web/assets/index-BM_K-Auu.css +1 -0
- package/web/assets/index-DRslOBiv.js +15 -0
- package/web/index.html +2 -2
- package/dist/chunk-3HIRPVLU.mjs +0 -2
- package/dist/chunk-5MHMDLZD.mjs +0 -4
- package/dist/chunk-64K7IPLO.mjs +0 -255
- package/dist/chunk-6QXGZM36.mjs +0 -8
- package/dist/chunk-6RGJOMJP.mjs +0 -16
- package/dist/chunk-AJ73XJF3.mjs +0 -2
- package/dist/chunk-AUZGSZJH.mjs +0 -13
- package/dist/chunk-BFE45AKL.mjs +0 -2
- package/dist/chunk-BXO2ZY5P.mjs +0 -2
- package/dist/chunk-CEH4MRCC.mjs +0 -2
- package/dist/chunk-CY2FNNAB.mjs +0 -16
- package/dist/chunk-DFUDV4LX.mjs +0 -2
- package/dist/chunk-DKXG4XDG.mjs +0 -2
- package/dist/chunk-EZQ34M3F.mjs +0 -124
- package/dist/chunk-EZY3WC6Z.mjs +0 -15
- package/dist/chunk-FUKQNOQS.mjs +0 -9
- package/dist/chunk-JPOSLGOC.mjs +0 -6
- package/dist/chunk-JVHHHGEA.mjs +0 -3
- package/dist/chunk-L3QKH4OK.mjs +0 -26
- package/dist/chunk-LAE5NQ4B.mjs +0 -2
- package/dist/chunk-LEF6DRCK.mjs +0 -59
- package/dist/chunk-NO5NJCHO.mjs +0 -2
- package/dist/chunk-NQPVAU63.mjs +0 -2
- package/dist/chunk-NSKUTQ5J.mjs +0 -5
- package/dist/chunk-O35FIXRB.mjs +0 -2
- package/dist/chunk-P2CAZPDP.mjs +0 -3
- package/dist/chunk-PL6GHLGD.mjs +0 -15
- package/dist/chunk-QJIR2BLP.mjs +0 -6
- package/dist/chunk-QUPLVPB2.mjs +0 -7
- package/dist/chunk-R7BNENLY.mjs +0 -4
- package/dist/chunk-S6O4UHLC.mjs +0 -2
- package/dist/chunk-SGJWQKEI.mjs +0 -2
- package/dist/chunk-TX6JH7TR.mjs +0 -2
- package/dist/chunk-TYK6VNAB.mjs +0 -10
- package/dist/chunk-UALRNVSE.mjs +0 -4
- package/dist/chunk-V3HXVQEM.mjs +0 -2
- package/dist/chunk-V5VXUJKG.mjs +0 -2
- package/dist/chunk-VBXMADMP.mjs +0 -2
- package/dist/chunk-VNV55RUA.mjs +0 -2
- package/dist/chunk-VPD2PS35.mjs +0 -2
- package/dist/chunk-W4VKN3GF.mjs +0 -7
- package/dist/chunk-W5BXXPDJ.mjs +0 -3
- package/dist/chunk-XUNHRCOG.mjs +0 -6
- package/skill/references/building-components.md +0 -367
- package/web/assets/index-Bh74DfsV.css +0 -1
- package/web/assets/index-UW0RyFFt.js +0 -13
|
@@ -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{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-7JDX4E65.mjs";import"./chunk-3MBRL2PM.mjs";import"./chunk-HPOI4ZX7.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-EAIFITAV.mjs";import"./chunk-67N2QJYT.mjs";import"./chunk-5XA2ZBAE.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-JLTZF4LA.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-DJISHPUL.mjs";import"./chunk-ZWWC4KLF.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-ITOH5EGO.mjs";import"./chunk-ZQS6H473.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-MXUBKDRO.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-R2ZDLJYT.mjs";import"./chunk-VFX2KNHP.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{b as BEGIN,e as GESTURES,M as INSIDE_ALONE,N as OPEN_IT,a as READY,c as SAVING,L as TRY_LINES,m as asShown,o as changesOf,k as chosenInstance,z as cutOffSaid,D as documentHost,y as dragPath,x as drawn,s as dropScratch,t as dropStale,v as fallbackSaid,g as gestureOf,i as instancesIn,d as keysOf,B as listen,P as madeSaid,A as nothingSaid,n as partsOf,j as placeSaid,r as scratchCopy,f as stepOf,E as stepsCalled,h as stepsOf,K as stoppedTrial,C as takenAgain,u as takenBy,q as toldBy,J as trial,O as trialSaid,Q as tryCommand,w as untilTaken,l as withoutIds,F as wordsDiffer,G as wordsIn,p as writtenLines,I as writtenOtherwise,H as writtenWords};
|
|
@@ -0,0 +1,166 @@
|
|
|
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 jn}from"./chunk-DR73Y2UJ.mjs";import{b as Cn}from"./chunk-JLTZF4LA.mjs";import{a as bn,i as En,j as On}from"./chunk-PUOQ65NC.mjs";import{a as $n,b as Sn}from"./chunk-7OG26PGF.mjs";import{k as Ge}from"./chunk-DJISHPUL.mjs";import{h as gn}from"./chunk-ZWWC4KLF.mjs";import{a as yn}from"./chunk-AHN3NFKJ.mjs";import{a as xn}from"./chunk-MTYYHM2G.mjs";import{a as kn,b as vn}from"./chunk-ALZ6ZENZ.mjs";import{a as wn}from"./chunk-2OHANJ6Q.mjs";import{a as fn,b as Ke,d as mn,e as un,f as pn,g as hn}from"./chunk-7M2BQQGZ.mjs";import{b as ft,e as Ht,g as mt,h as Gt,j as Kt,k as Jt}from"./chunk-UYVCQK3H.mjs";import{a as Dt,d as Lt,e as It,f as Nt,k as Mt,l as Wt,m as Ut,r as Bt,t as dt,u as zt}from"./chunk-J5PUIV3Y.mjs";import{b as nn,c as on,d as Oe,e as rn,f as an,g as He,i as sn,m as cn,p as ln,q as dn}from"./chunk-MXUBKDRO.mjs";import{d as en,e as Re,f as Be,g as ut,h as tn,k as ze}from"./chunk-6N3PX4XX.mjs";import{b as Yt,c as Xt}from"./chunk-PAREWQGB.mjs";import{i as Zt,j as Qt,k as qt}from"./chunk-BFJGHSQN.mjs";import{d as Vt}from"./chunk-U5XL7D6A.mjs";import{a as Ie}from"./chunk-VS7JIGJW.mjs";import{c as ct,g as re,j as Pt,k as Tt,p as Rt,q as Ft,v as At,w as lt}from"./chunk-HDWTZ763.mjs";import st from"node:fs";import is from"node:fs/promises";import cs from"node:http";import{editStateDirectory as ls,kitPublicDirectory as ds,release as fs,releaseFile as it,reportsDirectory as Pe,vendorDirectory as ms,workbenchDirectory as us}from"../browser/shared/paths.mjs";import{serve as Uo}from"../browser/shared/http.mjs";import{ensureWorkspace as ps,layoutOf as hs}from"../browser/shared/workspace.mjs";import ge from"node:fs/promises";import J from"node:path";import{assetFile as Ho,referencedFile as _n}from"../browser/shared/media.mjs";import{pageAssetAddress as Go}from"../browser/shared/pages.mjs";function pt(e,n){if(!/assets\//i.test(e))return e;let t=Qt(e,a=>_n(a)!==null);return Zt(e,qt(t,a=>{let s=_n(a.value);return Ho(s)?`${Go(n,s)}${/[?#].*$/.exec(a.value.trim())?.[0]??""}`:null}))}function Pn(e,{reportsDirectory:n,kit:t,slug:a=null}={}){let{html:s,packages:f}=an(a?pt(e,a):e,{reportsDirectory:n,kit:t,page:!0});return{html:s,packages:f}}import{Z as Ko}from"../browser/shared/layers.mjs";import{escapeMarkup as ht}from"../browser/shared/escape.mjs";import{layoutNotesScript as Jo}from"../browser/shared/qa-levels.mjs";var Je=30,Yo=`
|
|
3
|
+
[data-doc-dev].doc-checks { position: fixed; z-index: ${Ko.checks}; left: 12px; bottom: 12px; max-width: min(520px, calc(100vw - 24px));
|
|
4
|
+
font: 13px/1.5 system-ui, sans-serif; color: light-dark(#37352f, #e3e2e0); }
|
|
5
|
+
[data-doc-dev].doc-checks[hidden] { display: none; }
|
|
6
|
+
[data-doc-dev].doc-checks > summary { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; cursor: pointer;
|
|
7
|
+
list-style: none; color: light-dark(#a1352b, #f19c92); background: light-dark(#fce9e7, #3b2321);
|
|
8
|
+
box-shadow: 0 0 0 1px light-dark(rgb(161 53 43 / 18%), rgb(241 156 146 / 22%)); user-select: none; }
|
|
9
|
+
[data-doc-dev].doc-checks > summary::-webkit-details-marker { display: none; }
|
|
10
|
+
[data-doc-dev].doc-checks > div { margin-top: 6px; padding: 8px 12px; max-height: 50vh; overflow: auto; border-radius: 10px;
|
|
11
|
+
background: light-dark(#ffffff, #252525); box-shadow: 0 0 0 1px light-dark(rgb(42 28 0 / 7%), #383836), 0 20px 24px light-dark(rgb(25 25 25 / 5%), rgb(0 0 0 / 20%)); }
|
|
12
|
+
[data-doc-dev].doc-checks ul { margin: 0; padding-left: 18px; }
|
|
13
|
+
[data-doc-dev].doc-checks li { margin: 2px 0; overflow-wrap: anywhere; }
|
|
14
|
+
[data-doc-dev].doc-checks p { margin: 6px 0 0; color: light-dark(#787774, #9b9a97); }
|
|
15
|
+
[data-doc-dev].doc-checks .doc-checks-live:not(:first-child) { margin-top: 8px; }
|
|
16
|
+
@media print { [data-doc-dev].doc-checks { display: none; } }`,Xo=`(() => {
|
|
17
|
+
document.currentScript.remove();
|
|
18
|
+
${Jo()}
|
|
19
|
+
const panel = document.querySelector("details.doc-checks[data-doc-dev]");
|
|
20
|
+
if (!panel) return;
|
|
21
|
+
const failures = Number(panel.dataset.failures) || 0;
|
|
22
|
+
const live = panel.querySelector(".doc-checks-live ul");
|
|
23
|
+
// The note's words in the UI's language (the root's data-ge-language).
|
|
24
|
+
const english = document.documentElement.getAttribute("data-ge-language") === "en";
|
|
25
|
+
const WORDS = english
|
|
26
|
+
? { card: "Chart card", table: "Table", named: (kind, name) => kind + " \u201C" + name + "\u201D", first: (name) => "Table (first column \u201C" + name + "\u201D)", colon: ": ",
|
|
27
|
+
failing: (count) => "Checks failed \xB7 " + count, more: (count) => count + " more", all: (slug) => "gallery check " + slug + " runs every check (TypeScript too)." }
|
|
28
|
+
: { card: "\u56FE\u8868\u5361\u7247", table: "\u8868\u683C", named: (kind, name) => kind + "\u300C" + name + "\u300D", first: (name) => "\u8868\u683C\uFF08\u9996\u5217\u300C" + name + "\u300D\uFF09", colon: "\uFF1A",
|
|
29
|
+
failing: (count) => "\u68C0\u67E5\u672A\u901A\u8FC7 \xB7 " + count + " \u9879", more: (count) => "\u8FD8\u6709 " + count + " \u9879", all: (slug) => "gallery check " + slug + " \u8DD1\u5168\u90E8\u68C0\u67E5\uFF08\u542B TypeScript\uFF09\u3002" };
|
|
30
|
+
const more = panel.querySelector("[data-more]");
|
|
31
|
+
if (more) more.textContent = WORDS.more(more.dataset.more);
|
|
32
|
+
const all = panel.querySelector("[data-all]");
|
|
33
|
+
if (all) all.textContent = WORDS.all(all.dataset.all);
|
|
34
|
+
const tidy = (node) => (node?.textContent ?? "").replace(/\\s+/g, " ").trim().slice(0, 40);
|
|
35
|
+
const what = (host) => {
|
|
36
|
+
const card = host.closest("figure");
|
|
37
|
+
const title = card?.querySelector(":scope > h3, :scope > figcaption");
|
|
38
|
+
const table = host.closest(".doc-table-wrap, table");
|
|
39
|
+
const caption = table?.querySelector("caption");
|
|
40
|
+
const header = table?.querySelector("th");
|
|
41
|
+
return title ? WORDS.named(WORDS.card, tidy(title)) : card ? WORDS.card : caption && tidy(caption) ? WORDS.named(WORDS.table, tidy(caption)) : header ? WORDS.first(tidy(header)) : host.localName;
|
|
42
|
+
};
|
|
43
|
+
// A chart that drew nothing says why in its card (the kit's line, in the same language): that line, else the note in words.
|
|
44
|
+
const said = (host, name, note) => (name === "data-missing" && tidy(host.querySelector(".doc-chart-message"))) || noteInWords(note, { english });
|
|
45
|
+
let shown = "";
|
|
46
|
+
let frame = 0;
|
|
47
|
+
const draw = () => {
|
|
48
|
+
frame = 0;
|
|
49
|
+
const notes = [...document.querySelectorAll("[data-doc-layout]")].filter((host) => !host.closest("[data-doc-dev]"))
|
|
50
|
+
.flatMap((host) => layoutNotesOf(host.getAttribute("data-doc-layout"), document.documentElement.clientWidth)
|
|
51
|
+
.filter(({ level }) => level === "fail")
|
|
52
|
+
.map(({ note, name }) => ({ line: what(host) + WORDS.colon + said(host, name, note), note })));
|
|
53
|
+
const key = notes.map(({ line }) => line).join("\\n");
|
|
54
|
+
if (key === shown) return;
|
|
55
|
+
shown = key;
|
|
56
|
+
live.replaceChildren(...notes.map(({ line, note }) => Object.assign(document.createElement("li"), { textContent: line, title: note })));
|
|
57
|
+
live.parentElement.hidden = notes.length === 0;
|
|
58
|
+
const failing = failures + notes.length;
|
|
59
|
+
panel.querySelector("summary").textContent = failing ? WORDS.failing(failing) : "";
|
|
60
|
+
panel.hidden = failing === 0;
|
|
61
|
+
};
|
|
62
|
+
const later = (records) => {
|
|
63
|
+
if (!globalThis.document?.defaultView) return; // the page is gone
|
|
64
|
+
if (!frame && records.some((record) => !record.target.closest?.("[data-doc-dev]"))) frame = requestAnimationFrame(draw);
|
|
65
|
+
};
|
|
66
|
+
new MutationObserver(later).observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ["data-doc-layout"] });
|
|
67
|
+
addEventListener("resize", () => { if (!frame) frame = requestAnimationFrame(draw); });
|
|
68
|
+
draw();
|
|
69
|
+
})();`;function Tn(e,n,t={},{directory:a}={}){let s=sn({slug:e,html:n,metadata:t,...a?{directory:a}:{}}),f=s.slice(0,Je).map(h=>`<li>${ht(h)}</li>`).join(""),r=s.length>Je?`<p data-more="${s.length-Je}">\u8FD8\u6709 ${s.length-Je} \u9879</p>`:"",m=s.length?`<ul>${f}</ul>${r}<p data-all="${ht(e)}">gallery check ${ht(e)} \u8DD1\u5168\u90E8\u68C0\u67E5\uFF08\u542B TypeScript\uFF09\u3002</p>`:"";return`<details class="doc-checks" data-doc-dev data-failures="${s.length}"${s.length?"":" hidden"}><summary>${s.length?`\u68C0\u67E5\u672A\u901A\u8FC7 \xB7 ${s.length} \u9879`:""}</summary><div>${m}<div class="doc-checks-live" hidden><ul></ul></div></div><style>${Yo}</style></details>
|
|
70
|
+
<script data-doc-dev>${Xo}</script>`}import{browserDirectory as wa,editStateDirectory as ya,kitSourceDirectory as Po,release as ka,reportsDirectory as D}from"../browser/shared/paths.mjs";import{FRAMED_BY as va,sendJson as go,serve as Ot,serveFound as Ae}from"../browser/shared/http.mjs";import{languageScript as wo}from"../browser/shared/i18n/index.mjs";import{announcePreviewServer as xa,galleryVersion as $a}from"../browser/shared/preview-server.mjs";import{registerQuietly as Sa}from"../browser/shared/workspace-registry.mjs";import{lookWord as yo}from"../browser/shared/document-look.mjs";import{documentLook as ko,ownLookAt as ba}from"../browser/shared/workspace-look.mjs";import{slugPattern as To}from"../browser/shared/reports.mjs";import{ATTRIBUTE as ot,PACKAGE_ID as Ea}from"../browser/shared/components/installed.mjs";import{COMPONENTS_FOLDER as vo,DOCUMENT_FOLDERS as xo,EXTENSIONS_FOLDER as Oa,PAGES_FOLDER as Ca,WORKSPACE_FILE as rt,documentDirectory as bt,documentFiles as ja,isDocumentFile as _a,isDocumentSource as $o,isSlugName as Ro,layoutOf as Pa}from"../browser/shared/workspace.mjs";import{PAGE_FILES as So,homeCardsNew as Ta,isBlankPage as Ra,isPageFile as Fa,pageFiles as bo,pageHintShown as Aa,pageMetaNow as Da,pageVersion as Eo}from"../browser/shared/pages.mjs";import{LINK_FILE as La}from"../browser/shared/web-links.mjs";import{SIDEBAR_FILE as Oo}from"../browser/shared/extension-sidebar.mjs";import{extensionColumnIds as Co}from"../browser/shared/extensions.mjs";import{isExtensionId as Ia}from"../browser/shared/outline-shape.mjs";import{createHash as lr,randomBytes as dr}from"node:crypto";import Q from"node:fs";import gt from"node:os";import he from"node:path";import{Transform as fr}from"node:stream";import{pipeline as mr}from"node:stream/promises";import{exportSourceOf as ur}from"../browser/shared/export-wrap.mjs";import{writeAtomic as wt}from"../browser/shared/files.mjs";import{sendJson as K}from"../browser/shared/http.mjs";import{said as yt,saying as pr}from"../browser/shared/i18n/index.mjs";import{IMPORT_LIMIT as Ln}from"../browser/shared/import-types.mjs";import{mediaUrl as hr}from"../browser/shared/media.mjs";import{fullAddress as gr}from"../browser/shared/page-address.mjs";import{documentLinks as In,slugPattern as Nn}from"../browser/shared/reports.mjs";import{documentDirectory as wr,documentFiles as Mn,newDocSlug as yr,pageSlug as kr}from"../browser/shared/workspace.mjs";import{readWritingPreferences as vr,saysAnything as xr,unshownLines as $r}from"../browser/shared/writing-preferences.mjs";import Rn from"node:fs/promises";import or from"node:path";import{Worker as Vo}from"node:worker_threads";import{refusal as Zo,said as Qo}from"../browser/shared/i18n/index.mjs";var qo=6e4,me=null,er=0,Ye=0,Ce=new Map;function tr(){me=new Vo(new URL("./worker.mjs",import.meta.url)),me.on("message",({id:n,result:t,error:a})=>{let s=Ce.get(n);s&&(Ce.delete(n),a?s.reject(Object.assign(new Error(a.message),a)):s.resolve(t),Ce.size===0&&(me?.unref(),nr()))});let e=n=>{for(let t of Ce.values())t.reject(n);Ce.clear(),me=null};me.on("error",e),me.on("exit",n=>e(Zo(Qo("\u8F6C\u6362\u8FDB\u7A0B\u610F\u5916\u9000\u51FA\uFF08{0}\uFF09",n))))}function nr(){clearTimeout(Ye),Ye=setTimeout(()=>{if(Ce.size===0&&me){let e=me;me=null,e.removeAllListeners("exit"),e.terminate()}},qo),Ye.unref?.()}function ve(e,n){clearTimeout(Ye),me||tr();let t=++er;return new Promise((a,s)=>{Ce.set(t,{resolve:a,reject:s}),me.ref(),me.postMessage({id:t,type:e,payload:n})})}import{pageLanguage as rr}from"../browser/shared/components/page.mjs";function Xe(e){return String(e??"").replace(/[\\/:*?"<>|\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,100).trim()||"Untitled"}function Ve(e,n){let t=e.lastIndexOf("."),[a,s]=t>0?[e.slice(0,t),e.slice(t)]:[e,""];for(let f=0;;f+=1){let r=f===0?e:`${a} ${f}${s}`;if(!n.has(r.toLowerCase()))return n.add(r.toLowerCase()),r}}function Ze(e,n){let t=e.split("/").slice(0,-1),a=n.split("/"),s=0;for(;s<t.length&&s<a.length-1&&t[s]===a[s];)s+=1;return[...t.slice(s).map(()=>".."),...a.slice(s)].map(r=>r===".."?r:encodeURIComponent(r).replace(/\(/g,"%28").replace(/\)/g,"%29")).join("/")}import{documentDirectory as ar,documentFiles as sr}from"../browser/shared/workspace.mjs";var Fn={markdown:"md",html:"html",pdf:"pdf"},ir={markdown:"text/markdown; charset=utf-8",html:"text/html; charset=utf-8",pdf:"application/pdf"},cr=e=>typeof e=="number"&&e>.1&&e<2;function An(e){let{format:n,content:t="everything",subpages:a=!1,folders:s=!0,paper:f="A4",scale:r=1}=e??{};return Object.hasOwn(Fn,n)&&["everything","no_files"].includes(t)&&typeof a=="boolean"&&typeof s=="boolean"&&["A4","A3","Letter","Legal","Tabloid"].includes(f)&&cr(r)}async function Dn(e,n,t){let{format:a,content:s="everything",subpages:f=!1,folders:r=!0,paper:m="A4",scale:l=1}=n,h=Fn[a],w=s==="everything",i=[],k=new Map,R=v=>k.get(v)??k.set(v,new Set).get(v),u=async(v,b)=>{let B=await t.titleOf(v),H=Ve(`${Xe(B)}.${h}`,R(b)),z=b?`${b}/${H}`:H,L=r?z.slice(0,-(h.length+1)):"";if(i.push({slug:v,title:B,file:z,folder:L,files:b?`${b}/assets`:"assets"}),f)for(let ae of await t.childrenOf(v))await u(ae,L)};await u(e,"");let{links:F}=await t.links(),S=(v,b)=>on(b,v.slug,B=>{let H=a==="pdf"?null:i.find(z=>z.slug===B)?.file??null;return H&&Ze(v.file,H)},{blocks:a!=="markdown",links:F}),x=[],Y=[];for(let v of i)if(a==="markdown"){await t.check(v.slug);let b=ar(v.slug,t.reportsDirectory),B=Oe(await Rn.readFile(sr(b).html,"utf8"),{slug:v.slug,mode:"words",reportsDirectory:t.reportsDirectory}),H=S(v,B),z=w&&!!bn(),{text:L,files:ae,charts:ne,charted:U}=await ve("markdown",{source:H,title:v.title,pictures:z}),G=L,ce=new Map;if(ae.forEach(({src:p,name:g},E)=>{ce.has(p)||(ce.set(p,`${v.files}/${Ve(Xe(g),R(v.files))}`),w&&Y.push({from:or.join(b,p),name:ce.get(p)}));let C=ce.get(p);G=G.replace(`\0F${E}\0`,()=>Ze(v.file,C))}),z&&ne>0&&G.includes("\0C")){let p=await On(await t.offline(v.slug,{files:!0})).catch(()=>[]);G=G.replace(/^.*\u0000C(\d+)\u0000.*$/gm,(g,E)=>{let C=p[Number(E)];if(!C)return"\0gone\0";let _=`${v.files}/${Ve(rr(H)==="en"?U[Number(E)]?"Chart.png":"Figure.png":U[Number(E)]?"\u56FE\u8868.png":"\u56FE.png",R(v.files))}`;return x.push({name:_,data:C,later:!0}),g.replace(`\0C${E}\0`,()=>Ze(v.file,_))}).replace(/\n*\u0000gone\u0000\n*/g,`
|
|
71
|
+
|
|
72
|
+
`).replace(/^\n+|\n+$/g,"")}x.push({name:v.file,data:G})}else a==="html"?x.push({name:v.file,data:S(v,await t.offline(v.slug,{files:w}))}):x.push({name:v.file,data:await En(S(v,await t.offline(v.slug,{files:w})),{paper:m,scale:l})});for(let v of Y){let b=await Rn.readFile(v.from).catch(()=>null);b&&x.push({name:v.name,data:b})}let W=[...x.filter(v=>!v.later&&i.some(b=>b.file===v.name)),...x.filter(v=>v.later||!i.some(b=>b.file===v.name))];return W.length===1?{name:W[0].name,type:ir[a],data:Buffer.isBuffer(W[0].data)?W[0].data:Buffer.from(W[0].data,"utf8")}:{name:`${Xe(i[0].title)}.zip`,type:"application/zip",data:wn(W)}}var Sr=3600*1e3,kt=new Set,Wn=!1,br=e=>{kt.add(e),!Wn&&(Wn=!0,process.once("exit",()=>{for(let n of kt)try{Q.rmSync(n,{recursive:!0,force:!0})}catch{}}))},Er=/^u-[a-f0-9]{16}$/;function Un({edits:e,workspace:n,reports:t,reportsDirectory:a,offline:s}){let f=null,r=()=>f??=Q.promises.mkdtemp(he.join(gt.tmpdir(),"gallery-uploads-")).then(p=>(br(p),p)),m=new Map,l=(p,g,E)=>[p,{ok:!1,reason:g,...pr(E)}],h=p=>Q.promises.access(p).then(()=>!0,()=>!1),w=p=>wr(p,a),i=p=>Mn(w(p)),k=async p=>{try{return JSON.parse(await Q.promises.readFile(i(p).json,"utf8")).title||p}catch{return p}};function R(p){if(p.method!=="POST")return[405,{ok:!1,reason:"method"}];let g=p.headers.host??"",E=p.socket.localPort;return g!==`127.0.0.1:${E}`&&g!==`localhost:${E}`?[403,{ok:!1,reason:"host"}]:p.headers.origin!==`http://${g}`?[403,{ok:!1,reason:"origin"}]:p.headers["x-gallery-token"]!==e.token?[403,{ok:!1,reason:"token"}]:/^application\/octet-stream\b/i.test(p.headers["content-type"]??"")?Number(p.headers["content-length"]??0)>Ln?l(413,"size","\u6587\u4EF6\u592A\u5927\uFF08\u6700\u591A 5GB\uFF09"):null:[415,{ok:!1,reason:"type"}]}async function u(){for(let[p,g]of m)Date.now()-g.at<Sr||(m.delete(p),await Q.promises.rm(g.file,{force:!0}).catch(()=>{}))}async function F(p,g){let E=R(p);if(E)return p.resume(),K(g,...E);let C=new URL(p.url,"http://localhost").searchParams.get("name")?.replace(/[\u0000-\u001f]/g,"").trim()??"";if(!C||C.length>255)return p.resume(),K(g,...l(400,"name","\u6587\u4EF6\u540D\u4E0D\u5BF9"));await u();let _=`u-${dr(8).toString("hex")}`,j=he.join(await r(),_),N=0,A=new fr({transform(I,Z,X){N+=I.length,X(N>Ln?Object.assign(new Error("too-large"),{reason:"size"}):null,I)}});try{await mr(p,A,Q.createWriteStream(j))}catch(I){return await Q.promises.rm(j,{force:!0}).catch(()=>{}),I.reason==="size"?K(g,...l(413,"size","\u6587\u4EF6\u592A\u5927\uFF08\u6700\u591A 5GB\uFF09")):K(g,...l(400,"body","\u6587\u4EF6\u6CA1\u6709\u4F20\u5B8C"))}return m.set(_,{file:j,name:C,at:Date.now()}),K(g,200,{ok:!0,id:_})}async function S(p,g){let E=await e.check(p);if(E.error)return K(g,...E.error);let{slug:C,options:_}=E.body??{};if(typeof C!="string"||!Nn.test(C)||!await h(i(C).html))return K(g,...l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"));if(!An(_))return K(g,...l(400,"options","\u5BFC\u51FA\u9009\u9879\u4E0D\u5BF9"));try{let j=await s(),N=new Map,A=P=>(N.has(P)||N.set(P,e.handIn(P,{reader:!0}).then(M=>{if(!M.ok)throw Object.assign(new Error(M.message??M.reason),{reason:M.reason});if(M.repeated.length)throw Object.assign(new Error("check"),{reason:"check",slug:P,failures:He(M.repeated)})})),N.get(P)),I=new Map,Z={reportsDirectory:a,titleOf:k,childrenOf:async P=>{let{children:M,links:se=[]}=await n.outline(),oe=we=>(M[we]??[]).flatMap(ye=>se.includes(ye)||ye.startsWith("~")?oe(ye):[ye]);return oe(P)},links:()=>In(a),offline:async(P,M)=>{await A(P);let se=await j(P,M),oe=_.format==="markdown"?null:ur(se);return oe&&I.set(P,oe),se},check:async P=>(await A(P),j.check(P))},{name:X,type:V,data:q}=await Dn(C,_,Z);I.size&&await(await Ge([...I.keys()])).keep([...I.keys()],I),g.writeHead(200,{"Content-Type":V,"Content-Length":q.length,"Content-Disposition":`attachment; filename*=UTF-8''${encodeURIComponent(X)}`,"X-File-Name":encodeURIComponent(X),"Cache-Control":"no-store"}),g.end(q)}catch(j){if(j.reason==="check"){let N=await k(j.slug),A=j.component?yt("\u300C{0}\u300D\u91CC\u7684\u7EC4\u4EF6 {1} \u6709\u9519\u8BEF\uFF0C\u6CA1\u6709\u751F\u6210\u6587\u4EF6\uFF1A\u53EF\u4EE5\u8BA9 AI \u68C0\u67E5\u8FD9\u4EFD\u6587\u6863\u5E76\u4FEE\u597D",N,j.component):j.failures.length>1?yt("\u300C{0}\u300D\u6CA1\u6709\u901A\u8FC7\u5BFC\u51FA\u524D\u7684\u68C0\u67E5\uFF0C\u6CA1\u6709\u751F\u6210\u6587\u4EF6\uFF1A{1}\uFF08\u5171 {2} \u5904\uFF1A\u53EF\u4EE5\u8BA9 AI \u68C0\u67E5\u8FD9\u4EFD\u6587\u6863\uFF0C\u5217\u51FA\u5168\u90E8\u5E76\u4FEE\u597D\uFF09",N,j.failures[0],j.failures.length):yt("\u300C{0}\u300D\u6CA1\u6709\u901A\u8FC7\u5BFC\u51FA\u524D\u7684\u68C0\u67E5\uFF0C\u6CA1\u6709\u751F\u6210\u6587\u4EF6\uFF1A{1}",N,j.failures[0]);return K(g,...l(422,"check",A))}K(g,...l(j.reason==="browser"?422:j.reason==="busy"?409:j.reason==="missing"?404:500,j.reason??"export",j))}}async function x(p,g){let E=await e.check(p);if(E.error)return K(g,...E.error);let{slug:C}=E.body??{},_=(await e.readTaken(C,{wait:0}))?.text??null;if(_===null)return K(g,...l(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"));let j=`http://${p.headers.host}`,{named:N}=await In(a),A=nn(Oe(_,{slug:C,mode:"words",reportsDirectory:a}),C,V=>V.slug&&gr(j,V,N),N),{text:I,files:Z}=await ve("markdown",{source:A,title:await k(C),pictures:!1}),X=I.replace(/\u0000F(\d+)\u0000/g,(V,q)=>{let{src:P,kind:M}=Z[Number(q)];return encodeURI(`${j}${hr(M==="image"?"asset":"file",C,P)}`)});return K(g,200,{ok:!0,text:X})}let Y=async p=>{let g=await e.readTaken(p,{wait:0});return{source:g?.text??"",version:g?.version??null}},W=async(p,g=null)=>{let{source:E,version:C}=g??await Y(p),_="\u5199\u4F5C\u504F\u597D",{text:j,files:N}=await ve("markdown",{source:E,title:_,pictures:!1}),A=j.split(`
|
|
73
|
+
`).slice(1).join(`
|
|
74
|
+
`).replace(/^[\s>]*(?:```.*|\d+\.|- \[x\])/gm,"").replace(/<\/?aside>/g,"");if(!/[\p{L}\p{N}]|\u0000F\d+\u0000/u.test(A))return{markdown:`# ${_}
|
|
75
|
+
`,empty:!0,version:C};let I=he.relative(a,w(p)).split(he.sep).join("/");return{markdown:`${j.replace(/\u0000F(\d+)\u0000/g,(Z,X)=>encodeURI(`${I}/${N[Number(X)].src}`))}
|
|
76
|
+
`,empty:!1,version:C}},v=p=>i(p).json,b=async p=>{try{let g=JSON.parse(await Q.promises.readFile(v(p),"utf8"));return g&&typeof g=="object"?g:null}catch{return null}},B=p=>lr("sha256").update(p).digest("hex").slice(0,16);async function H(p,g,E,C){let _=await b(p);if(!_||E===null)return;let{synced:j,...N}=_,A={file:B(g),page:E,unshown:C},I=_.madeSame;j===void 0&&I?.file===A.file&&I?.page===A.page&&JSON.stringify(I?.unshown)===JSON.stringify(C)||await wt(v(p),`${JSON.stringify({...N,madeSame:A},null,2)}
|
|
77
|
+
`)}async function z(p,g){let E=await Q.promises.mkdtemp(he.join(gt.tmpdir(),"gallery-preferences-"));try{let _=(await ve("import",{uploads:[{file:g,name:"preferences.md"}],scratch:E})).pages[0]??{nodes:[],raws:[],files:[],icon:null,lang:null},j=w(p),N=await b(p)??{},A=Mn(j).html,I=await Q.promises.readFile(A,"utf8").catch(()=>""),Z=/<html\b[^>]*\slang="([^"]*)"/i.exec(I)?.[1]??null,{html:X}=await Xt(p,N.title||"\u5199\u4F5C\u504F\u597D",N.description||"",{blank:!0,lang:Z}),V=typeof N.icon=="string"&&N.icon?N.icon:null,q=await ve("fill",{source:X,nodes:_.nodes,icon:V,raws:_.raws,lang:_.lang});_.files.length&&await Q.promises.mkdir(he.join(j,"assets"),{recursive:!0});for(let{from:M,name:se}of _.files){let oe=he.join(j,"assets",se);await h(oe)||await Q.promises.copyFile(M,oe)}let P=await Q.promises.readFile(A,"utf8").catch(()=>null);P!==null&&e.keepVersion?.(p,P),await wt(A,ze(q))}finally{await Q.promises.rm(E,{recursive:!0,force:!0}).catch(()=>{})}}async function L(p,g){let E=await e.check(p);if(E.error)return K(g,...E.error);let C=E.body?.opening===!0,_=await kr(a);if(!_)return K(g,...l(404,"missing","\u8FD8\u6CA1\u6709\u5199\u4F5C\u504F\u597D"));let j=null,N=(A,I)=>[200,{ok:!0,path:he.resolve(j),remade:A,unshown:I}];return e.respond(async()=>{let A;({file:j,text:A}=await vr(a));let I=await Y(_),Z=(await b(_))?.madeSame??null,X=Z===null||Z.page===I.version,V=Z!==null&&X&&Z.file===B(A);if(C&&V&&Array.isArray(Z.unshown))return N(!1,Z.unshown);let[q,P,M,se]=[A,"",I.version,!1];if(C&&!X)await z(_,j),{markdown:P,version:M}=await W(_),se=!0;else{let we=await W(_,I),ye=A.trim()===we.markdown.trim()||we.empty&&!xr(A);P=we.markdown,C?!ye&&!V&&(await z(_,j),{markdown:P,version:M}=await W(_),se=!0):ye||(await wt(j,we.markdown),q=we.markdown)}let oe=$r(q,P);return await H(_,q,M,oe),N(se,oe)})(p,g)}async function ae(p,g){let E=await e.check(p);if(E.error)return K(g,...E.error);let{uploads:C,parent:_="",from:j,language:N}=E.body??{},A={said:typeof j=="string"&&j.includes("{0}")&&j.length<=60?j:"\u5BFC\u5165\u81EA {0}",lang:N==="en"?"en":null};if(!Array.isArray(C)||C.length===0||C.length>1e3||!C.every(P=>typeof P=="string"&&Er.test(P)))return K(g,...l(400,"body"));let I=C.map(P=>m.get(P)).filter(Boolean);if(I.length!==C.length)return K(g,...l(410,"gone","\u4E0A\u4F20\u7684\u6587\u4EF6\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u5BFC\u5165"));for(let P of C)m.delete(P);let Z=typeof _=="string"&&Nn.test(_)&&await h(he.join(a,_))?_:"",X=await Q.promises.mkdtemp(he.join(gt.tmpdir(),"gallery-import-")),V=()=>Promise.all([Q.promises.rm(X,{recursive:!0,force:!0}),...I.map(({file:P})=>Q.promises.rm(P,{force:!0}))]).catch(()=>{}),q;try{q=await ve("import",{uploads:I.map(({file:P,name:M})=>({file:P,name:M})),scratch:X})}catch(P){return await V(),K(g,...l(500,"convert",P))}return e.respond(async()=>{try{let{made:P,top:M}=await yn(q.pages,{create:t.create,slugOf:()=>yr(a),folderOf:w,fill:se=>ve("fill",se),place:n.place,under:Z,...A});return[200,{ok:!0,pages:P.length,reports:M,skipped:q.skipped,missing:ne(q.pages)}]}finally{await V()}})(p,g)}let ne=p=>[...new Set(p.flatMap(function g(E){return[...(E.notes??[]).filter(C=>C.kind==="picture-missing").map(C=>C.name),...E.children.flatMap(g)]}))],U={export:S,markdown:x,upload:F,import:ae,preferences:L};function G(p,g,E){return Object.hasOwn(U,E)?U[E](p,g).catch(C=>{g.headersSent||K(g,...l(500,"transfer",C))}):K(g,404,{ok:!1,reason:"unknown"})}async function ce(){let p=f;f=null,m.clear();let g=await p?.catch(()=>null);g&&(kt.delete(g),await Q.promises.rm(g,{recursive:!0,force:!0}).catch(()=>{}))}return{handle:G,close:ce}}import{FACT_KINDS as Na,QUERY_ROUTE as Ma,WORKSPACE_GLOBAL as Wa}from"../browser/shared/workspace-query.mjs";function Bn({settled:e,tell:n,delay:t=120,recheck:a=1e3}){let s=new Map,f=(r,m=t)=>{clearTimeout(s.get(r));let l=setTimeout(async()=>{let h=await e(r).catch(()=>({source:null,held:!1,wait:0}));if(s.get(r)===l){if(h.held)return f(r,Math.min(Math.max(h.wait,50),a));if(h.wait>0)return f(r,h.wait);await n(r,h)}},m);s.set(r,l)};return f}import Or from"node:fs/promises";import{packageScript as Cr}from"../browser/shared/export-wrap.mjs";import{serveFound as jr}from"../browser/shared/http.mjs";import{extensionOf as _r,mediaTypeOf as Pr}from"../browser/shared/media.mjs";var Tr="/__gallery/components/",Rr=/^\/__gallery\/components\/([a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*)\/(.+)$/,Fr={js:"text/javascript; charset=utf-8",mjs:"text/javascript; charset=utf-8",css:"text/css; charset=utf-8",wasm:"application/wasm"};async function zn(e,n,t,{root:a}){if(!e.startsWith(Tr))return!1;let[,s,f]=Rr.exec(e)??[],r=s?re(a).packages.get(s):null,m=r?.files.includes(f)?Rt(r,f):null,l=m?await Or.readFile(m).catch(()=>null):null,h=l&&f==="kit.js"?Buffer.from(Cr(l.toString("utf8").replace(/^\uFEFF/,""))):l,w=h&&n===r.stamp&&n===Ft(r);return jr(t,h,{type:h?Fr[_r(f)]??Pr(f):void 0,headers:{"X-Content-Type-Options":"nosniff","Cache-Control":w?"max-age=31536000, immutable":"no-store"}}),!0}import{BLOCK_ICON as Ar}from"../browser/editor/components/icons.mjs";import{LISTED_BLOCKS as Hn}from"../browser/editor/components/registry.mjs";import{PACKAGE_ID as Dr}from"../browser/shared/components/installed.mjs";import{netHostsOf as Gn}from"../browser/shared/net-policy.mjs";import{inLanguage as Kn,refusal as Qe,said as be}from"../browser/shared/i18n/index.mjs";function Jn({root:e,taken:n}){let t=()=>{let r=re(e);return{packages:At(r).map(m=>{let l=Nt(m.id)?It(m.id):null;return{...m,newer:l?Mt(e,l):null,...l?{addAs:l.pack===Dt?l.name:l.id}:{}}}),packs:dt(e,{settings:r.settings}),packageIcon:Ar,blocks:Hn.map(({id:m,name:l,icon:h,hideable:w})=>({id:m,name:{zh:Kn("zh",l),en:Kn("en",l)},icon:h,hidden:w&&r.settings.hidden.includes(m),hideable:w})),problem:Tt(r)}},a=({id:r,hidden:m,shown:l,disabled:h,unlisted:w,net:i})=>{if(![m,l,h,w,i].every(R=>R===void 0||typeof R=="boolean"))return be("\u5F00\u5173\u7684\u503C\u4E0D\u5BF9");let k=Hn.find(R=>R.id===r);return k?h!==void 0||l!==void 0||w!==void 0||i!==void 0?be("\u5185\u7F6E\u5757\u53EA\u80FD\u9690\u85CF\uFF0C\u4E0D\u80FD\u505C\u7528"):m&&!k.hideable?be("\u8FD9\u4E2A\u5757\u4E0D\u80FD\u9690\u85CF"):null:typeof r=="string"&&Dr.test(r)?i&&Gn(re(e).packages.get(r)?.needs).length===0?be("\u8FD9\u4E2A\u5757\u4E0D\u8054\u7F51"):null:be("\u6CA1\u6709\u8FD9\u4E2A\u7EC4\u4EF6")};return{read:t,write:async r=>{if(r?.pack!==void 0){let{pack:i,enabled:k}=r;if(typeof k!="boolean")throw Qe(be("\u5F00\u5173\u7684\u503C\u4E0D\u5BF9"));if(typeof i!="string"||!dt(e,{settings:re(e).settings}).some(({id:R})=>R===i))throw Qe(be("\u6CA1\u6709\u8FD9\u4E2A\u5757\u5305"));return await ct(e,{pack:i,enabled:k}),n(),t()}let m=a(r);if(m)throw Qe(m);let{net:l,...h}=r,w=l===void 0?void 0:l?Gn(re(e).packages.get(r.id)?.needs):[];return await ct(e,{...h,...w?{net:w}:{}}),n(),t()},install:({path:r,zip:m}={})=>{let l=typeof m=="string"?Sn(Buffer.from(m,"base64")):typeof r=="string"&&r.trim()?$n(r):null;if(!l)throw Qe(be("\u7C98\u8D34\u5757\u5305\u7684\u6587\u4EF6\u5939\u6216 zip \u7684\u8DEF\u5F84"),{code:"path"});let h=Bt(e,l);return n(),{...t(),installed:h}}}}import Lr from"node:path";import{exportsDirectory as Ir}from"../browser/shared/paths.mjs";async function Yn(e,n,{workspace:t=null}={}){let a=Lr.join(Ir,`${n}.html`),s=await Ge([n]),f=await e.handInReport(n,{reader:!0});if(!f.ok)return{problems:[],refused:{reason:f.reason,message:f.message},file:a};if(f.repeated.length)return{problems:He(f.repeated),file:a};let{exported:r,failures:m}=await dn([n],{workspace:t});return await s.keep(r.map(l=>l.slug)),{problems:m.get(n)??[],file:a}}import Xn from"node:fs/promises";import Vn from"node:path";import{MEDIA_ROUTES as Zn,assetFile as Nr,extensionOf as Mr,imageFile as Wr,mediaTypeOf as Ur}from"../browser/shared/media.mjs";import{serveFound as Qn}from"../browser/shared/http.mjs";import{slugPattern as qn}from"../browser/shared/reports.mjs";import{pageFiles as Br}from"../browser/shared/pages.mjs";import{documentDirectory as zr}from"../browser/shared/workspace.mjs";var vt={asset:e=>({"Content-Type":Ur(e),"Cache-Control":"no-cache"}),file:()=>({"Content-Type":"application/octet-stream","Content-Disposition":"attachment","X-Content-Type-Options":"nosniff","Cache-Control":"no-cache"}),embed:e=>/\.pdf$/i.test(e)?{"Content-Type":"application/pdf","X-Content-Type-Options":"nosniff","Cache-Control":"no-cache"}:{"Content-Type":"text/html; charset=utf-8","Content-Security-Policy":"sandbox allow-scripts allow-popups allow-forms allow-modals","X-Content-Type-Options":"nosniff","Cache-Control":"no-cache"}},Hr=new RegExp(`^/__gallery/edit/(${Object.keys(Zn).join("|")})/([^/]+)/(assets/[^/]+)$`);async function eo(e,n,{reportsDirectory:t}){let[,a,s,f]=Hr.exec(e)??[];if(!a)return!1;let r=qn.test(s)&&Zn[a](f)?await Xn.readFile(Vn.join(zr(s,t),f)).catch(()=>null):null;return Qn(n,r,{headers:vt[a](f)}),!0}var Gr={css:"text/css; charset=utf-8",js:"text/javascript; charset=utf-8",mjs:"text/javascript; charset=utf-8"},Kr=/^\/pages\/([^/]+)\/(assets\/[^/]+)$/;async function to(e,n,{reportsDirectory:t}){let[,a,s]=Kr.exec(e)??[];if(!a)return!1;let f=qn.test(a)&&Nr(s)?await Xn.readFile(Vn.join(Br(a,t).folder,s)).catch(()=>null):null,r=Gr[Mr(s??"")];return Qn(n,f,{headers:r?{"Content-Type":r,"X-Content-Type-Options":"nosniff","Cache-Control":"no-cache"}:(Wr(s)?vt.asset:vt.file)(s)}),!0}import Jr from"node:dns";import{sendJson as Fe}from"../browser/shared/http.mjs";import{createNetCache as Yr,dataOf as Xr}from"../browser/shared/net-cache.mjs";import{readKeys as Vr}from"../browser/shared/net-keys.mjs";import{addressKind as et,addressOf as lo,hostIn as no,keptHere as oo,keyIn as ro,mapsHere as Zr,netHostsOf as Qr,proxyHere as qr,withKey as ea}from"../browser/shared/net-policy.mjs";import{galleryVersion as ta}from"../browser/shared/preview-server.mjs";var qe=512*1024,na=6e4,ao=20,so=5,io=1e4,oa=16*1024,ra=new Set([301,302,303,307,308]),aa=/^(?:application\/(?:[\w.-]+\+)?json|text\/[\w.+-]+)$/i,xe=(e,n={})=>({ok:!1,code:e,...n}),te=(e,n={},t)=>Object.assign(new Error(e),{refusal:xe(e,n),...t===void 0?{}:{detail:t}});function sa(e,n){let t;try{t=new URL(e,n)}catch{return{code:"url",why:"a redirect to an address that does not parse"}}let a=lo(t.href);return a.code?{code:"url",why:`a redirect to ${t.host?`${t.protocol}//${t.host}`:t.protocol}: ${a.why}`}:a}function co(e,n){let t=[...new Set([n,encodeURIComponent(n)])].filter(Boolean),a=s=>typeof s=="string"?t.reduce((f,r)=>f.split(r).join("{key}"),s):s;return Object.fromEntries(Object.entries(e).map(([s,f])=>[s,a(f)]))}var ia=e=>Jr.promises.lookup(e,{all:!0,verbatim:!0}),xt=e=>URL.parse(e)?.host||"?",$t=e=>et(e)==="fake-ip"?"an address a fake-ip proxy's DNS gives":"an address of this computer or of a private network";async function ca(e,{resolve:n,proxy:t}){let a=e.hostname,s=qr(t),f=u=>{let F=et(u);return F==="public"||F==="fake-ip"&&s},r=a.replace(/^\[|\]$/g,"");if(et(r)!=="none"){if(f(r))return{address:r};throw te("private",{host:a,address:r,why:`${r} is ${$t(r)}`})}let m;try{m=(await n(a)).map(u=>typeof u=="string"?u:u.address)}catch(u){throw te("offline",{why:`${a} did not resolve (${u.code??u.message})`})}if(m.length===0)throw te("offline",{why:`${a} did not resolve`});let l=m.filter(u=>!f(u));if(l.length===0)return{address:m[0]};let h=l.filter(u=>!Zr(u)),w=h.length?h:l,i=w.find(u=>!u.includes(":"))??w[0],k=`${a} resolved to ${i}, ${$t(i)}`,R=oo(a)?"and its name is one kept for this computer (localhost)":t?s?e.protocol!=="https:"?"and an http address is never handed to a proxy by its name (no TLS to check the site)":h.length?"and a private network's address is never handed to a proxy by its name (that network's own machines are there)":null:"and the proxy it goes through is not on this computer":"and no proxy of this computer goes between to reach it by its name";if(R===null)return{address:null,resolved:i,said:k};throw te("private",{host:a,address:i,why:`${k}, ${R}`},s||!t||oo(a)?void 0:`${k}, and the proxy it goes through (${xt(t)}) is not on this computer`)}var la=({resolve:e=ia,proxyFor:n=fn,connect:t,ca:a}={})=>async(s,{headers:f,signal:r})=>{let m=await n(s.href),l=await ca(s,{resolve:e,proxy:m}),{address:h}=l,w={...t?{connect:t}:{},...a?{ca:a}:{}};try{return await Ke(s,{address:h,proxy:m,headers:f,signal:r,...w})}catch(i){if(!(m&&i.proxyFailed&&(h!==null||i.code==="ECONNREFUSED")))throw h===null&&!r?.aborted?te("offline",{why:`${l.said}, and no site the proxy of this computer reached by its name proved to be it`},`${l.said}, handed by its name to the proxy (${xt(m)}): ${i.code??i.message}`):i;let k=u=>`and the proxy of this computer that would reach it${u?` (${xt(m)})`:""} is not running`,R=h===null?l.said:`${s.hostname.replace(/^\[|\]$/g,"")===h?h:`${s.hostname} resolved to ${h}`}, ${$t(h)}`;if(h===null||et(h)!=="public")throw te("private",{host:s.hostname,address:h??l.resolved,why:`${R}, ${k(!1)}`},`${R}, ${k(!0)}`);return Ke(s,{address:h,proxy:null,headers:f,signal:r,...w})}},fo=e=>(n,{headers:t,signal:a})=>Ke(new URL(`http://127.0.0.1:${e}/${n.protocol.slice(0,-1)}/${n.host}${n.pathname}${n.search}`),{address:"127.0.0.1",headers:t,signal:a});async function da(e){let n=0,t=[];for await(let a of e){if(n+=a.length,n>oa)throw Object.assign(new Error("too-large"),{status:413});t.push(a)}return JSON.parse(Buffer.concat(t).toString("utf8"))}function fa(e,n){let t=/;\s*charset="?([^";]+)"?/i.exec(n)?.[1];try{return new TextDecoder(t||"utf-8").decode(e)}catch{return new TextDecoder("utf-8").decode(e)}}function mo({root:e,catalog:n=()=>re(e),hop:t=null,now:a=Date.now,cache:s=Yr(e),log:f=()=>{}}){let r=t??la(),m=new Map,l=u=>{let F=a(),S=(m.get(u)??[]).filter(x=>F-x<6e4);return S.length>=ao?(m.set(u,S),!1):(m.set(u,[...S,F]),!0)},h={accept:"application/json, text/plain;q=0.9, text/*;q=0.8","user-agent":`Gallery/${ta} (a custom block's card)`};async function w(u,{hosts:F,allowed:S,key:x}){let Y=AbortSignal.timeout(io),W=u;for(let v=0;;v++){let b;try{b=await r(x===void 0?W:new URL(ea(W.href,x)),{headers:h,signal:Y})}catch(L){throw L.refusal?L:te("offline",{why:Y.aborted?`no answer within ${io/1e3} s`:String(L.code??L.message)})}if(ra.has(b.status)&&b.headers.get("location")){if(b.body?.cancel().catch(()=>{}),v>=so)throw te("status",{status:b.status,why:`more than ${so} redirects`});let L=sa(b.headers.get("location"),W);if(L.code)throw te("url",{why:L.why});let ae=no(L.url.hostname,F);if(!ae)throw te("host",{host:L.url.hostname,why:`a redirect to ${L.url.hostname}, which the block's needs do not name`});if(!S.includes(ae))throw te("consent",{hosts:F.filter(ne=>!S.includes(ne))});W=L.url,x=ro(W.href)?x:void 0;continue}if(b.status<200||b.status>299)throw b.body?.cancel().catch(()=>{}),te("status",{status:b.status});let B=b.headers.get("content-type")??"",H=B.split(";")[0].trim();if(H&&!aa.test(H))throw b.body?.cancel().catch(()=>{}),te("type",{type:H});if(Number(b.headers.get("content-length"))>qe)throw b.body?.cancel().catch(()=>{}),te("too-large",{limit:qe});let z;try{z=b.body?await mn(b,qe):Buffer.alloc(0)}catch(L){throw te("offline",{why:String(L.code??L.message)})}if(z===null)throw te("too-large",{limit:qe});return{type:H||"text/plain",text:fa(z,B)}}}let i=(u,F,S)=>{let x=Xr(u,F);return x===void 0?xe("type",{why:"the answer is no JSON"}):{ok:!0,data:x,at:u.at,cached:S}};async function k(u){let{block:F,url:S,as:x="json",doc:Y=null}=u??{},W=typeof F=="string"?n().packages.get(F):null;if(!W)return xe("missing",{why:"no custom block of that id loads in this workspace"});let v=Qr(W.needs);if(x!=="json"&&x!=="text")return xe("url",{why:'as is "json" or "text"'});let b=lo(S);if(b.code)return xe("url",{why:b.why});let{url:B}=b,H=no(B.hostname,v);if(!H)return xe("host",{host:B.hostname,why:v.length?`its needs name ${v.join(", ")}`:"its needs name no host of the net"});let z=n().settings.net?.[F]??[];if(!z.includes(H))return xe("consent",{hosts:v.filter(U=>!z.includes(U))});let L;if(ro(B.href)){let U=Vr(e);if(L=U[B.hostname]??U[H],L===void 0)return xe("key",{host:B.hostname})}let ae=B.href,ne=s.get(ae);if(s.used(ae,Y,x),ne&&a()-Date.parse(ne.at)<na)return i(ne,x,!0);if(!l(F))return ne?i(ne,x,!0):xe("rate",{why:`more than ${ao} fetches in a minute`});try{let{type:U,text:G}=await w(B,{hosts:v,allowed:z,key:L});return i(s.put(ae,{type:U,text:G,at:new Date(a()).toISOString()}),x,!1)}catch(U){if(!U.refusal)throw U;if(ne&&U.refusal.code!=="consent")return i(ne,x,!0);let G=L===void 0?U.refusal:co(U.refusal,L),ce=U.detail===void 0?G.why:L===void 0?U.detail:co({why:U.detail},L).why;return(G.code!=="offline"||U.detail!==void 0)&&f(`${F}: ${B.hostname} refused (${G.code}${ce?`: ${ce}`:""})`),G}}async function R(u,F){if(u.method!=="POST")return Fe(F,405,{ok:!1,reason:"method"});if(u.headers.origin!==`http://${u.headers.host}`)return Fe(F,403,{ok:!1,reason:"origin"});if(!/^application\/json\b/i.test(u.headers["content-type"]??""))return Fe(F,415,{ok:!1,reason:"type"});let S;try{S=await da(u)}catch(x){return Fe(F,x.status??400,{ok:!1,reason:"body"})}try{return Fe(F,200,await k(S))}catch(x){return Fe(F,500,{ok:!1,code:"offline",why:x.message})}}return{handle:R,answer:k,cache:s}}function uo({max:e=20}={}){let n=new Map;return{get(t,a,s){let f=`${t} ${a}`,r=n.get(f);return!r||r.text!==s?null:(n.delete(f),n.set(f,r),r.page)},set(t,a,s,f){let r=`${t} ${a}`;for(n.delete(r),n.set(r,{slug:t,text:s,page:f});n.size>e;)n.delete(n.keys().next().value)},clear(){n.clear()},forget(t){for(let[a,s]of n)s.slug===t&&n.delete(a)},get size(){return n.size}}}import{createHash as ma}from"node:crypto";import{readFileSync as ua}from"node:fs";import po from"node:fs/promises";import pa from"node:path";import{release as ha,releaseFile as ga}from"../browser/shared/paths.mjs";async function tt(e){let n=await Promise.all(e.map(a=>po.stat(a).then(({mtimeMs:s,size:f})=>`${s} ${f}`,()=>"none"))),t=ma("sha256");return e.forEach((a,s)=>t.update(`${a}\0${n[s]}
|
|
78
|
+
`)),t.digest("hex").slice(0,16)}function ho(e,n){let t=null,a=async()=>(await Promise.all(e.map(async s=>(await po.readdir(s,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(r=>r.isFile()).map(r=>pa.join(r.parentPath,r.name))))).flat().filter(n).sort();return{files:()=>t??=a(),changed:()=>{t=null}}}var St=ha?JSON.parse(ua(ga,"utf8")).stamps:null;var at=To.source.slice(1,-1),Ua=new RegExp(`^/generated/(${at})\\.html$`),Ba=new RegExp(`^/(${at})/(?:doc|report)\\.html$`),za=new RegExp(`^/pages/(${at})$`),Ha=new RegExp(`^/__gallery/pages/(${at})/(cards|library|hint)$`),Ct="/__gallery/events",je=wa,Fo=/^\/__gallery\/edit\/(v\/[a-f0-9]{16}\/)?src\/((?:shared(?:\/components|\/emoji|\/i18n)?\/|editor\/(?:page|components)(?:\/[a-z]+(?:-[a-z]+)*){0,2}\/(?!files?\.mjs))[a-z]+(?:-[a-z]+)*\.mjs)$/,Ga=/^\/__gallery\/edit\/(?:v\/[a-f0-9]{16}\/)?src\/(shared\/emoji\/data\/[a-z]+(?:-[a-z]+)*\.(json|bin))$/,nt=[J.join(je,"editor","page"),J.join(je,"editor","components"),J.join(je,"shared")],Ka=e=>Fo.test(`/__gallery/edit/src/${J.relative(je,e).split(J.sep).join("/")}`);var Ja=[Po,J.join(je,"shared","components")],Zc=[Po,...nt],Ne={"Cache-Control":"no-store"},jo={"Cache-Control":"max-age=31536000, immutable"},Et=(e,n,t)=>Ot(e,{type:n,headers:{...Ne,...va},body:t});function Ya(e){let n=e.headers?.host??"",t=e.socket?.localPort;return!!t&&(n===`127.0.0.1:${t}`||n===`localhost:${t}`)}function Xa(e){if(e.method!=="GET"&&e.method!=="HEAD")return null;let n=e.socket?.localPort;if(!n||e.headers?.host!==`localhost:${n}`)return null;let t=new URL(e.url||"/","http://localhost");return t.pathname==="/"||t.pathname==="/index.html"?`http://127.0.0.1:${n}${t.pathname}${t.search}`:null}var Ao=`window.addEventListener("doc-net-fetch", (event) => {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
event.detail.answer(fetch("/__gallery/net", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(event.detail.ask) }).then((response) => response.json()));
|
|
81
|
+
});`,Do=`let lost = false;
|
|
82
|
+
events.onerror = () => { lost = true; };
|
|
83
|
+
events.onopen = () => {
|
|
84
|
+
if (!lost) return;
|
|
85
|
+
lost = false;
|
|
86
|
+
for (const kind of ${JSON.stringify(Na)}) window.dispatchEvent(new CustomEvent("doc-workspace-change", { detail: kind }));
|
|
87
|
+
};`,Va=(e,n,t)=>`<script>
|
|
88
|
+
(() => {
|
|
89
|
+
document.currentScript.remove();
|
|
90
|
+
${Ao}
|
|
91
|
+
const solo = new URLSearchParams(location.search).has("solo");
|
|
92
|
+
let catalog = "${t}";
|
|
93
|
+
const holds = (ids) => document.querySelector(ids === undefined ? "[${ot}]" : ids.split(",").map((id) => '[${ot}="' + id + '"]').join());
|
|
94
|
+
const events = new EventSource("${Ct}?slug=${e}");
|
|
95
|
+
${Do}
|
|
96
|
+
events.onmessage = (event) => {
|
|
97
|
+
const [kind, next, ids, more, consents, unlisted, packs] = event.data.split(" ");
|
|
98
|
+
if (kind === "notes") return void window.dispatchEvent(new CustomEvent("doc-annotations-changed", { detail: { version: next ?? "" } }));
|
|
99
|
+
if (kind === "changes") return void window.dispatchEvent(new CustomEvent("doc-changes-changed", { detail: { stamp: next ?? "" } }));
|
|
100
|
+
if (kind === "look") return void window.dispatchEvent(new CustomEvent("doc-look-request", { detail: { look: Object.fromEntries(new URLSearchParams(next ?? "")), from: "file" } }));
|
|
101
|
+
if (kind === "settings") return void window.dispatchEvent(new CustomEvent("doc-settings-changed", { detail: { hidden: next ? next.split(",") : [], disabled: ids ? ids.split(",") : [], shown: more ? more.split(",") : [], net: consents ? consents.split(",") : [], unlisted: unlisted ? unlisted.split(",") : [], packsOff: packs ? packs.split(",") : [] } }));
|
|
102
|
+
if (kind === "data") return void window.dispatchEvent(new CustomEvent("doc-workspace-change", { detail: next ?? "" }));
|
|
103
|
+
if (kind !== "report" && kind !== "assets" && kind !== "components") return;
|
|
104
|
+
if (kind === "components") {
|
|
105
|
+
if (document.readyState === "loading") return void document.addEventListener("DOMContentLoaded", () => events.onmessage(event), { once: true });
|
|
106
|
+
if (solo || next === catalog) return;
|
|
107
|
+
catalog = next;
|
|
108
|
+
if (!holds(ids)) return void window.dispatchEvent(new CustomEvent("doc-catalog-changed", { detail: { ids: ids === undefined ? null : ids.split(",").filter(Boolean) } }));
|
|
109
|
+
}
|
|
110
|
+
if (window.__galleryEditBusy) {
|
|
111
|
+
window.dispatchEvent(new CustomEvent({ report: "doc-source-changed", assets: "doc-assets-changed", components: "doc-components-changed" }[kind], { detail: { version: next ?? null } }));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (kind === "report" && next === "${n}") return;
|
|
115
|
+
if (window.__galleryEditReload) return window.__galleryEditReload(); // in a workbench: swapped in, no reload seen
|
|
116
|
+
location.reload();
|
|
117
|
+
};
|
|
118
|
+
})();
|
|
119
|
+
</script>`,Za=(e,n,t)=>`<script>
|
|
120
|
+
(() => {
|
|
121
|
+
document.currentScript.remove();
|
|
122
|
+
${Ao}
|
|
123
|
+
let catalog = "${t}";
|
|
124
|
+
const holds = (ids) => {
|
|
125
|
+
const named = ids === undefined ? "[${ot}]" : ids.split(",").filter(Boolean).map((id) => '[${ot}="' + id + '"]').join() || ":not(*)";
|
|
126
|
+
return Boolean(document.querySelector(named)) || [...document.querySelectorAll("template[data-ge-held]")].some((held) => held.content.querySelector(named));
|
|
127
|
+
};
|
|
128
|
+
const again = () => (window.__galleryEditReload ? window.__galleryEditReload() : location.reload());
|
|
129
|
+
const events = new EventSource("${Ct}?page=${e}");
|
|
130
|
+
${Do}
|
|
131
|
+
events.onmessage = (event) => {
|
|
132
|
+
const [kind, next, ids, more, consents, unlisted, packs] = event.data.split(" ");
|
|
133
|
+
if (kind === "page") return void (window.__galleryPageChanged ? window.__galleryPageChanged(next) : next !== "${n}" && again());
|
|
134
|
+
if (kind === "assets") return void again();
|
|
135
|
+
if (kind === "settings") return void window.dispatchEvent(new CustomEvent("doc-settings-changed", { detail: { hidden: next ? next.split(",") : [], disabled: ids ? ids.split(",") : [], shown: more ? more.split(",") : [], net: consents ? consents.split(",") : [], unlisted: unlisted ? unlisted.split(",") : [], packsOff: packs ? packs.split(",") : [] } }));
|
|
136
|
+
if (kind === "data") return void window.dispatchEvent(new CustomEvent("doc-workspace-change", { detail: next ?? "" }));
|
|
137
|
+
if (kind !== "components") return;
|
|
138
|
+
if (document.readyState === "loading") return void document.addEventListener("DOMContentLoaded", () => events.onmessage(event), { once: true });
|
|
139
|
+
if (next === catalog) return;
|
|
140
|
+
catalog = next;
|
|
141
|
+
if (holds(ids)) again();
|
|
142
|
+
};
|
|
143
|
+
})();
|
|
144
|
+
</script>`;function Qa(e,n){let t=J.relative(e,n).split(J.sep);if(t[0]===".."||J.isAbsolute(t[0])||t[0]==="")return null;if(t.length===1&&t[0]===rt)return{slug:null,name:rt,packages:!0};let a=l=>process.platform==="win32"?l.toLowerCase():l;if(a(t[0])===Oa&&t.length>=2&&Ia(t[1])&&!xo.includes(t[1])){let l=t.slice(2);return l.some(h=>h.startsWith("."))?null:{extension:t[1],name:l.length===1?l[0]:null}}if(a(t[0])===Ca&&t.length>=2&&Ro(t[1])&&!xo.includes(t[1])){let l=t.slice(2);return l.some(h=>h.startsWith("."))?null:{page:t[1],name:l.length===1?l[0]:null}}let s=t[0]===".gallery"&&t[1]==="pages"&&t.length>=3,[f,...r]=s?t.slice(2):t,m=!s&&a(f)===vo;return!(m||To.test(f))||f==="exports"||r.some(l=>l.startsWith("."))?null:{slug:m?vo:f,name:r.length===1?r[0]:null,...m?{packages:m}:{}}}function jt(e){let n=i=>process.platform==="win32"?J.resolve(i).toLowerCase():J.resolve(i),{gallery:t,preferencesPage:a,exports:s,extensions:f}=Pa(e),[r,m,l,h]=[n(t),n(a),n(s),n(f)],w=(i,k)=>i===k||i.startsWith(k+J.sep);return i=>{let k=n(i);return w(k,h)&&k!==h&&k.slice(h.length+1).split(J.sep).some((R,u)=>u>0&&(R==="node_modules"||R===".git"))?!0:w(k,r)&&k!==r&&!w(k,m)||w(k,l)}}var _o=`<script data-doc-dev>document.currentScript.remove(); globalThis.${Wa} = ${JSON.stringify(Ma)};</script>`,ue=(e,n,t)=>new RegExp(`</${n}>`,"i").test(e)?e.replace(new RegExp(`</${n}>`,"i"),()=>` ${t}
|
|
145
|
+
</${n}>`):`${e}
|
|
146
|
+
${t}`;function Lo({stateDirectory:e=ya,logger:n=console,kind:t="dev",workbenchPage:a=null,closeServer:s=async()=>{},exit:f=()=>process.exit(0)}={}){let r=new Set,m=(o,c="",d="report")=>{for(let O of r)(!o||O.slug===o)&&O.response.write(`data: ${o?`${d} ${c}`:"assets"}
|
|
147
|
+
|
|
148
|
+
`)},l=(o,c)=>{for(let d of r)d.page===o&&d.response.write(`data: page ${c}
|
|
149
|
+
|
|
150
|
+
`)},h=!1,w=o=>{h||=o,A("workspace",()=>{let c=h;h=!1;for(let d of r)d.workspace&&(c||!d.ownOnly)&&d.response.write(`data: workspace ${Date.now()}
|
|
151
|
+
|
|
152
|
+
`)})},i=()=>w(!0),k=()=>w(!1),R=o=>m(o,String(Date.now()),"changes"),u=gn({stateDirectory:e,finish:ze,log:o=>n.info?.(`[gallery] ${o}`),onChanges:R}),F=(o,c,d,{lang:O=null,page:T=!1}={})=>Yt(o,c,d,{blank:!0,lang:O,page:T}),S=e?jn({file:J.join(e,"activity.json")}):null,x=vn({root:D,read:kn(u),activity:S,draw:(o,c)=>Oe(o,{slug:c,mode:"words",reportsDirectory:D})}),Y=new Set,W=o=>{for(let c of o)Y.add(c);Y.size!==0&&A("data",()=>{let c=[...Y];Y.clear();for(let d of r)if(d.slug||d.page)for(let O of c)d.response.write(`data: data ${O}
|
|
153
|
+
|
|
154
|
+
`)})},v=o=>J.resolve(J.dirname(bt(o,D)))===J.resolve(D),b=null,B=null,H=()=>B??=(async()=>{for(let o of r)o.response.end();r.clear(),await Promise.race([s().catch(()=>{}),new Promise(o=>setTimeout(o,3e3))]),await S?.close(),await b?.().catch(()=>{}),await L.close(),z.close(),f()})(),z=xn({server:{kind:t,version:$a,stop:H},edits:u,reports:{create:F,export:o=>Yn(u,o,{workspace:c=>x.snapshot(c)}),words:(o,c)=>Oe(o,{slug:c,mode:"words",reportsDirectory:D})},components:Jn({root:D,taken:()=>V.taken()}),changed:i,relayed:k,index:x,web:{frameable:un,title:pn,icon:o=>hn(o)}}),L=Un({edits:u,workspace:z,reports:{create:F},reportsDirectory:D,offline:o=>ln({...o,workspace:c=>x.snapshot(c)})}),ae=mo({root:D,hop:process.env.GALLERY_TEST_NET?fo(Number(process.env.GALLERY_TEST_NET)):null,log:o=>n.info?.(`[gallery] ${o}`)}),ne=Gt({root:D,edits:u,stateDirectory:e,catalogTaken:()=>V.taken(),log:o=>n.info?.(`[gallery] ${o}`),shown:pt}),U=(o,c,{present:d=!1,editorModule:O,kit:T}={})=>{let y=c,ie="",ee="",fe=!0;try{d||({html:y,snippet:ie,head:ee}=u.preview(o,c,{editor:O,kitTags:le=>tn(le,T)}))}catch(le){fe=!1,n.warn(`[gallery] text editing unavailable for ${o}: ${le.message}`)}if({html:y}=rn(y,{slug:o,mode:"preview",kit:T}),y=ue(y,"head",Va(o,Ie(c),re(D).stamp)),y=ue(y,"head",`<script data-doc-dev>${wo()}</script>`),y=ue(y,"head",_o),ee&&(y=ue(y,"head",ee)),d)return{html:ue(y,"head",`<style data-doc-present>.doc-display { display: none !important; }</style>
|
|
155
|
+
<script type="module" src="/__gallery/edit/src/editor/page/present-links.mjs" data-doc-dev></script>`),whole:fe};let ke="";try{ke=Tn(o,c)}catch(le){fe=!1,n.warn(`[gallery] checks unavailable for ${o}: ${le.message}`)}return ke&&(y=ue(y,"body",ke)),{html:ie?ue(y,"body",ie):y,whole:fe}},G=uo(),ce=ho(nt,Ka),p=o=>{let c=bt(o,D);return[c,J.join(c,"assets")]},g=()=>St?.editor??ce.files().then(tt),E=o=>St?.kit?.[o.id]??tt([ut(o)]),C=async(o,c,{present:d})=>{let[O,T,y]=await Promise.all([d?"":g(),Promise.all(Re.map(E)),tt(p(o))]),ie=[d?"present":O,...T,y,re(D).stamp,`look:${yo(ko(o,D))}`].join(" "),ee=G.get(o,ie,c);if(ee!==null)return d||u.opened(c),ee;let fe=new Map(Re.map((pe,Ee)=>[pe,T[Ee]])),ke=d?void 0:`/__gallery/edit/v/${O}/src/editor/page/editor.mjs`,{html:le,whole:de}=U(o,c,{present:d,editorModule:ke,kit:pe=>`${Be(pe)}?v=${fe.get(pe)}`});return de&&G.set(o,ie,c,le),le},_=async o=>{let c=bo(o,D),[d,O]=await Promise.all([ge.readFile(c.html,"utf8").catch(()=>null),ge.readFile(c.json,"utf8").catch(()=>"")]);if(d===null)return null;let[T,y]=await Promise.all([g(),Promise.all(Re.map(E))]),ie=new Map(Re.map(($,Se)=>[$,y[Se]])),ee=re(D),fe=Eo(d,O),ke=Ht(d,{blockOf:$=>mt(ee,$)}),le=Object.fromEntries([...new Set(ft(d).cards.map(({block:$})=>$).filter(Boolean))].map($=>[$,mt(ee,$)])),{html:de}=Pn(ke,{reportsDirectory:D,slug:o,kit:$=>`${Be($)}?v=${ie.get($)}`}),pe=Da(o,D),Ee=Aa(o,D),Te=pe?.defaultCards===!0,We=Ra(d),Ue=$=>ee.packages.get($)?.name??Lt().find(Se=>Se.id===$)?.title??null,$e=Te?Ta(D,ft(d).cards.map(({block:$})=>$)).map($=>({block:$,name:Ue($)})):[],Le=JSON.stringify({slug:o,title:pe?.title??o,token:u.token,version:fe,blocks:le,...Ee?{hint:Ee}:{},...Te?{defaults:Te}:{},...$e.length?{news:$e}:{},...We?{blank:We}:{}}).replace(/</g,"\\u003c");return de=ue(de,"head",`<script type="application/json" data-ge-page data-doc-dev>${Le}</script>`),de=ue(de,"head",Za(o,fe,ee.stamp)),de=ue(de,"head",`<script data-doc-dev>${wo()}</script>`),de=ue(de,"head",_o),ue(de,"head",`<script type="module" src="/__gallery/edit/v/${T}/src/editor/page/custom-page.mjs" data-doc-dev></script>`)};async function j(o,c,d){try{if(!Ya(o))return go(c,403,{ok:!1,reason:"host"});let O=Xa(o);if(O)return Ot(c,{status:302,headers:{Location:O,...Ne}});let T=new URL(o.url||"/","http://localhost"),y=decodeURI(T.pathname);if(y===Ct){c.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-store",Connection:"keep-alive"}),c.write(`retry: 3000
|
|
156
|
+
|
|
157
|
+
`);let $={slug:T.searchParams.get("slug"),page:T.searchParams.get("page"),workspace:T.searchParams.has("workspace"),ownOnly:T.searchParams.get("workspace")==="own",response:c};r.add($);let{stamp:Se,settings:zo}=re(D);c.write(`data: components ${Se}
|
|
158
|
+
|
|
159
|
+
`),c.write(`data: ${lt(zo)}
|
|
160
|
+
|
|
161
|
+
`),o.on("close",()=>r.delete($));return}if(y==="/__gallery/net")return ae.handle(o,c);if(y==="/__gallery/edit/commit")return u.commit(o,c);if(y==="/__gallery/edit/reverted")return u.reverted(o,c);if(y==="/__gallery/edit/hand-in")return u.handInRequest(o,c);if(y==="/__gallery/edit/settle")return u.settleRequest(o,c);if(y==="/__gallery/edit/round")return u.roundRequest(o,c);if(y==="/__gallery/edit/upload")return u.upload(o,c);if(y==="/__gallery/edit/unfurl")return u.unfurl(o,c);if(y==="/__gallery/edit/emoji-library"){if(o.method==="POST")return u.addEmoji(o,c);let[$,Se]=await u.listEmojis();return go(c,$,Se)}if(y==="/__gallery/edit/icon"){let $=Vt({value:T.searchParams.get("value")??"",slug:T.searchParams.get("slug"),tab:T.searchParams.has("tab")});return Ae(c,$?.body,{type:$?.type,headers:{"Cache-Control":"max-age=31536000, immutable"}})}if(await eo(y,c,{reportsDirectory:D})||await to(y,c,{reportsDirectory:D})||await zn(y,T.searchParams.get("v"),c,{root:D}))return;let ie=y.match(/^\/__gallery\/edit\/emoji-library\/([^/]+)$/)?.[1];if(ie){let $=await u.readEmoji(ie);return Ae(c,$?.body,{type:$?.type,headers:{"Cache-Control":"no-cache"}})}if(y==="/__gallery/edit/frameable")return u.frameable(o,c);if(y==="/__gallery/edit/annotations")return u.annotations(o,c);if(y==="/__gallery/edit/changes")return u.changes(o,c);let ee=y.match(/^\/__gallery\/transfer\/([a-z]+)$/)?.[1];if(ee)return L.handle(o,c,ee);let[,fe,ke]=y.match(Ha)??[];if(fe)return ne.handle(o,c,fe,ke);let le=y.match(/^\/__gallery\/workspace\/([a-z]+(?:-[a-z]+)*)$/)?.[1];if(le)return z.handle(o,c,le);let[,de,pe]=y.match(Fo)??[];if(pe){let $=await ge.readFile(J.join(je,pe),"utf8").catch(()=>null);return Ae(c,$,{type:"text/javascript; charset=utf-8",headers:de?jo:Ne})}let Ee=T.searchParams.has("v")&&Re.find($=>Be($)===y);if(Ee){let $=await ge.readFile(ut(Ee)).catch(()=>null);return Ae(c,$,{type:y.endsWith(".css")?"text/css; charset=utf-8":"text/javascript; charset=utf-8",headers:jo})}if(y==="/__gallery/edit/mhchem.js"){let $=await ge.readFile(en).catch(()=>null);return Ae(c,$,{type:"text/javascript; charset=utf-8",headers:Ne})}let[,Te,We]=y.match(Ga)??[];if(Te){let $=await ge.readFile(J.join(je,Te)).catch(()=>null);return Ae(c,$,{type:We==="json"?"application/json; charset=utf-8":"application/octet-stream",headers:{"Cache-Control":"max-age=86400"}})}if(a&&(y==="/"||y==="/index.html"))return Et(c,"text/html; charset=utf-8",await a(T.pathname,o));let Ue=y.match(za)?.[1];if(Ue){let $=await _(Ue);return $===null?d():Et(c,"text/html; charset=utf-8",$)}let $e=y.match(Ua)?.[1];if(!$e){let $=y.match(Ba)?.[1];return Ro($)&&await ge.access(ja(bt($,D)).html).then(()=>!0,()=>!1)?Ot(c,{status:302,headers:{Location:`/generated/${$}.html${T.search}`,...Ne}}):d()}let Le=await u.readTaken($e);if(Le===null)return d();T.searchParams.has("present")||u.noteTaken($e,Le.source).then($=>$&&R($e),()=>{}),Et(c,"text/html; charset=utf-8",await C($e,Le.text,{present:T.searchParams.has("present")}))}catch(O){d(O)}}let N=new Map,A=(o,c)=>{clearTimeout(N.get(o)),N.set(o,setTimeout(c,120))},I=o=>{ba(o,D).reads&&m(o,yo(ko(o,D)),"look")},Z=Bn({settled:u.settled,async tell(o,c){let d=await u.read(o,c.source).catch(O=>(n.error(`[gallery] ${o}: ${O.message}`),{version:Ie(c.source??"")}));if(m(o,d?.version??Ie("")),v(o)){let O=u.writerOf(o,c.source)??"agent";x.changed(o,{source:c.source??null,text:d?.text??null,by:O}).then(W,T=>n.error(`[gallery] ${o}: its facts not read: ${T.message}`))}u.noteTaken(o,c.source).then(O=>O&&R(o),O=>n.error(`[gallery] ${o}: the Agent's changes not kept: ${O.message}`)),u.checkAnnotations(o).catch(O=>n.error(`[gallery] ${o}: annotations not checked: ${O.message}`))}}),X=({id:o,problem:c,off:d})=>d||n.warn(`[gallery] custom block ${o} does not load: ${Pt("en",c)}`),V=Cn({root:D,tell({stamp:o,problems:c,settings:d},O){for(let T of O)c.has(T)&&X(c.get(T));for(let{response:T}of r)T.write(`data: components ${o} ${O.filter(y=>Ea.test(y)).join(",")}
|
|
162
|
+
|
|
163
|
+
`),T.write(`data: ${lt(d)}
|
|
164
|
+
|
|
165
|
+
`)}});for(let o of re(D).problems.values())X(o);x.start().then(o=>o>0&&W(["activity"]));let q=jt(D),P=Co(D).then(o=>o.join("/"),()=>""),M=!1,se=o=>{M||=o===Oo,A("extensions",async()=>{let c=M;M=!1;let d=await P;P=Co(D).then(O=>O.join("/"),()=>d),(c||await P!==d)&&i()})},oe=(o,c)=>!ka&&c.some(d=>o.startsWith(d+J.sep));function we(o,c){if(o==="reset"){G.clear(),ce.changed(),V.changed(),i();return}if(q(c))return;let d=Qa(D,c);if(d?.page){let{page:O,name:T}=d;T&&Fa(T)&&A(`page:${O}`,async()=>{let y=bo(O,D),[ie,ee]=await Promise.all([ge.readFile(y.html,"utf8").catch(()=>null),ge.readFile(y.json,"utf8").catch(()=>"")]);ie!==null&&l(O,Eo(ie,ee))}),(T===So.json||T===So.html&&/^(add|unlink)$/.test(o)||T===null&&/^(add|unlink)Dir$/.test(o))&&i();return}if(d?.extension){(d.name===Oo||d.name===null)&&se(d.name);return}if(d?.packages&&V.changed(),d?.name===rt&&d.slug===null&&A("look:*",()=>new Set([...r].map(({slug:O})=>O).filter(Boolean)).forEach(I)),d?.name===rt&&d.slug===null&&i(),d?.slug&&!(d.name&&_a(d.name))&&G.forget(d.slug),d&&(/^(doc|report)\.json$/.test(d.name??"")||/^(add|unlink)Dir$/.test(o)&&d.name===null)&&G.clear(),d?.slug&&!d.packages&&d.name===null&&/^(add|unlink)Dir$/.test(o)&&v(d.slug)&&(x.forget(d.slug),W(["todos","recent","stats"])),d?.slug&&!(d.packages&&d.name===null)&&(/^(doc|report)\.json$/.test(d.name??"")||/^(add|unlink)Dir$/.test(o)&&d.name===null||/^(add|unlink)$/.test(o)&&$o(d.name??""))&&i(),d?.slug&&!d.packages&&d.name===La&&i(),/^(add|unlink)(Dir)?$/.test(o)&&oe(c,nt)&&ce.changed(),d?.name&&($o(d.name)||/^(doc|report)\.json$/.test(d.name))){if(Z(d.slug),/^(doc|report)\.json$/.test(d.name)){let{slug:O}=d;A(`look:${O}`,()=>I(O))}}else if(d?.name==="annotations.json"){let{slug:O}=d;A(`notes:${O}`,async()=>{let T=await ge.readFile(c,"utf8").catch(()=>null);m(O,T===null?"":Ie(T),"notes")})}else oe(c,Ja)?A("kit",async()=>{try{await cn({fresh:!0}),m()}catch(O){n.error(`[gallery] shared kit rebuild failed: ${O.message}`)}}):oe(c,nt)&&A("editor",()=>m())}async function ye(o){b=await xa({reportsDirectory:D,port:o,token:u.token,kind:t}),await Sa(D)}async function Bo(){for(let o of N.values())clearTimeout(o);V.close(),await S?.close(),await b?.().catch(()=>{}),b=null,await L.close(),z.close()}return{handle:j,changed:we,listening:ye,close:Bo,stop:H,edits:u,get listeners(){return r.size}}}import qa from"node:fs/promises";import De from"node:path";import{FRAMED_BY as es,serve as Io}from"../browser/shared/http.mjs";var ts={".html":"text/html; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".json":"application/json; charset=utf-8",".map":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".woff2":"font/woff2",".woff":"font/woff",".ttf":"font/ttf",".txt":"text/plain; charset=utf-8"},ns=e=>ts[De.extname(e).toLowerCase()]??"application/octet-stream";function os(e,n){if(/%(?:2f|5c|00)/i.test(n)||/[\\\0]/.test(n))return null;let t;try{t=decodeURIComponent(n)}catch{return null}let a=t.split("/");if(a.some(r=>r===""||r==="."||r===".."||/[\\\0:]/.test(r)))return null;let s=De.resolve(e,...a),f=De.relative(e,s);return f&&!f.startsWith("..")&&!De.isAbsolute(f)?s:null}async function No(e,n,{web:t,kit:a,vendor:s}){if(e.method!=="GET"&&e.method!=="HEAD")return!1;let f=new URL(e.url||"/","http://localhost").pathname,r=null,m=null;if(f==="/"||f==="/index.html"){if(!t)return!1;[r,m]=[De.join(t,"index.html"),{"Cache-Control":"no-store",...es}]}else{let w=[["/assets/",t&&De.join(t,"assets"),"max-age=31536000, immutable"],["/kit/",a,"no-cache"],["/vendor/",s,"no-cache"]].find(([i,k])=>k&&f.startsWith(i));if(!w)return!1;r=os(w[1],f.slice(w[0].length)),m={"Cache-Control":w[2]}}let l=r?await qa.readFile(r).catch(()=>null):null;return l?(Io(n,{type:ns(r),headers:{...m,"X-Content-Type-Options":"nosniff"},body:e.method==="HEAD"?void 0:l}),!0):(Io(n,{status:404}),!0)}import _e from"node:fs";import Me from"node:path";import{isExtensionId as rs}from"../browser/shared/outline-shape.mjs";import{DOCUMENT_FOLDERS as Mo,isSlugName as _t,layoutOf as as}from"../browser/shared/workspace.mjs";function ss(e){let{components:n,gallery:t,preferencesPage:a,customPages:s,extensions:f}=as(e),r=(i,k)=>{try{return _e.readdirSync(i,{withFileTypes:!0}).filter(R=>R.isDirectory()&&k(R.name)).map(R=>Me.join(i,R.name))}catch{return[]}},m=[...r(e,i=>_t(i)),...r(a,i=>_t(i))],l=i=>[i,...r(i,k=>!k.startsWith(".")).flatMap(l)],h=r(s,i=>_t(i)&&!Mo.includes(i)),w=r(f,i=>rs(i)&&!Mo.includes(i));return[...new Set([e,...[t,a,s,f].filter(i=>_e.existsSync(i)),...h,...w,...m,...m.map(i=>Me.join(i,"assets")).filter(i=>_e.existsSync(i)),..._e.existsSync(n)?l(n):[]])]}function Wo(e,n,{folders:t=process.platform==="linux"}={}){let a=jt(e),s=(w,i)=>{a(i)||Me.basename(i).startsWith(".")||_e.stat(i,(k,R)=>{if(k)return n(k.code==="ENOENT"?"unlink":"change",i);let u=R.isDirectory();n(w==="rename"?u?"addDir":"add":u?"addDir":"change",i)})},f=()=>{};if(!t)try{let w=_e.watch(e,{recursive:!0},(i,k)=>k?s(i,Me.join(e,k.toString())):n("reset",e));return w.on("error",f),{close:()=>w.close()}}catch(w){if(w.code!=="ERR_FEATURE_UNAVAILABLE_ON_PLATFORM")throw w}let r=new Map,m=null,l=()=>{let w=new Set(ss(e));for(let[i,k]of r)w.has(i)||(k.close(),r.delete(i));for(let i of w)if(!r.has(i))try{let k=_e.watch(i,(R,u)=>{if(!u)return n("reset",i);R==="rename"&&h(),s(R,Me.join(i,u.toString()))});k.on("error",f),r.set(i,k)}catch{}},h=()=>{m??=setTimeout(()=>{m=null,l()},50)};return l(),{close(){clearTimeout(m);for(let w of r.values())w.close();r.clear()},get folders(){return[...r.keys()]}}}async function xl({port:e,web:n=us,kind:t=process.env.GALLERY_SERVER_KIND==="dev"?"dev":"cli",stateDirectory:a=ls,exit:s=(l=0)=>process.exit(l),watch:f=!0,signals:r=!0,log:m=console}={}){await ps(Pe),await zt(Pe,{log:S=>m.log(`[gallery] ${new Date().toISOString()} ${S}`)}),Ut(Pe,S=>m.log(`[gallery] ${new Date().toISOString()} ${S}`)),Wt(Pe);let l=await Kt(Pe,{stateDirectory:a});l.did==="made"?m.log(`[gallery] ${new Date().toISOString()} the default home page made: ${l.file} (${l.cards.length} cards)`):l.did==="failed"&&m.warn(`[gallery] ${new Date().toISOString()} ${Jt(l)}`);let h=null,w=null,i=null,k=hs(Pe),R=async()=>{w?.close(),i&&st.unwatchFile(it,i),await is.writeFile(k.lastPortFile,`${e}
|
|
166
|
+
`).catch(()=>{}),await new Promise(S=>{h.close(()=>S()),h.closeAllConnections()})},F=Lo({stateDirectory:a,logger:{info:S=>m.log(S),warn:S=>m.warn(S),error:S=>m.error(S)},kind:t,closeServer:R,exit:()=>s(0)});if(h=cs.createServer((S,x)=>{F.handle(S,x,async Y=>{if(Y){m.error(`[gallery] ${S.method} ${S.url}: ${Y.stack??Y.message}`),x.headersSent?x.end():Uo(x,{status:500});return}try{if(await No(S,x,{web:n,kit:ds,vendor:ms}))return}catch(W){m.error(`[gallery] ${S.url}: ${W.message}`)}x.headersSent||Uo(x,{status:404})})}),h.keepAliveTimeout=5e3,await new Promise((S,x)=>{h.once("error",x),h.listen(e,"127.0.0.1",()=>{h.off("error",x),S()})}),e=h.address().port,await F.listening(e),f&&(w=Wo(Pe,F.changed)),fs){let S=st.readFileSync(it,"utf8");i=()=>{let x=null;try{x=st.readFileSync(it,"utf8")}catch{}x!==S&&(m.log("[gallery] The package was replaced (another version installed): this server stops; the next gallery command starts the new one."),F.stop())},st.watchFile(it,{interval:3e3,persistent:!1},i)}if(r)for(let S of["SIGINT","SIGTERM","SIGHUP"])process.once(S,()=>F.stop());return{server:h,port:e,routes:F,async close(){await R(),await F.close()}}}export{xl as a};
|
|
@@ -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 u}from"./chunk-UMHUSOPJ.mjs";import l from"node:fs/promises";import p from"node:path";import{escapeMarkup as g}from"../browser/shared/escape.mjs";import{sha256 as b}from"../browser/shared/files.mjs";import{reportsDirectory as E,starterDirectory as y}from"../browser/shared/paths.mjs";import{listReportSlugs as T,slugPattern as S}from"../browser/shared/reports.mjs";import{documentDirectory as N,documentFiles as $,layoutOf as O,slugTaken as P}from"../browser/shared/workspace.mjs";async function j(t,c){if(!S.test(t))throw new Error(`A document's folder name must be lowercase kebab-case: ${t}`);let n=N(t,c),{html:r,json:i}=$(n),[m,o]=[p.basename(r),p.basename(i)],e,f;try{[e,f]=await Promise.all([l.readFile(r),l.readFile(i,"utf8")])}catch(s){if(s.code!=="ENOENT")throw s;let h=await l.stat(n).then(()=>!0,()=>!1);throw new Error(h?`${n} needs both ${m} and ${o}.`:`${n} does not exist.`)}let a;try{a=JSON.parse(f)}catch(s){throw new Error(`${o} is not valid JSON: ${s.message}`)}if(typeof a.title!="string")throw new Error(`${o} is missing a title.`);for(let s of["description","type"])if(typeof a[s]!="string"||a[s].trim()==="")throw new Error(`${o} is missing a non-empty ${s}.`);if(a.source!==void 0&&typeof a.source!="string")throw new Error(`${o} source must be a string when given.`);return{slug:t,directory:n,htmlPath:r,metadataPath:i,html:e.toString("utf8"),fileSha256:b(e),metadata:a}}async function z(t=[],{directory:c=E,prepare:n=null}={}){let r=t.length>0?[...new Set(t)]:await T(c);if(r.length===0)throw new Error(`No documents in ${p.resolve(c)} yet: gallery new <slug> "<title>" makes one.`);let i=[],m=new Map;for(let o of r)try{let e=await j(o,c);n&&([e.written,e.html]=[u(e.html),n(e)]),i.push(e)}catch(e){m.set(o,[e.message])}return{reports:i,failures:m}}var v=/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/,F=/\n[ \t]*<!-- Starter content:[^\n]*-->\n[ \t]*<section\b[^>]*\sdata-doc-placeholder\b[\s\S]*?<\/section>/;async function M(t,c,n,{directory:r=E,blank:i=!1,lang:m=null,page:o=!1}={}){if(!S.test(t))throw new Error("Slug must be lowercase kebab-case.");if(P(t,r))throw Object.assign(new Error(`"${t}" is taken in ${p.resolve(r)}`),{code:"EEXIST"});let e=o?O(r).preferencesPage:p.resolve(r),f=p.join(e,t),{html:a,metadata:s}=await R(t,c,n,{blank:i,lang:m});await l.mkdir(e,{recursive:!0}),await l.mkdir(f,{recursive:!1});let h=$(f);return await Promise.all([l.writeFile(h.html,a),l.writeFile(h.json,`${JSON.stringify(s,null,2)}
|
|
3
|
+
`)]),{slug:t,directory:f,metadata:s}}async function R(t,c,n,{blank:r=!1,lang:i=null}={}){let m=w=>g(w).replaceAll("'","'"),[o,e]=await Promise.all([l.readFile(p.join(y,"doc.html"),"utf8"),l.readFile(p.join(y,"doc.json"),"utf8")]),f={...JSON.parse(e),title:c,description:n},a=r?o.replace(F,`
|
|
4
|
+
<p></p>`):o;if(r&&a===o)throw new Error("The starter's placeholder section was not found.");let s=typeof i=="string"&&v.test(i)?a.replace(/(<html\b[^>]*\slang=")[^"]*"/,(w,d)=>`${d}${i}"`):a,h={SLUG:t,TITLE:m(c)};return{html:s.replace(/__REPORT_(SLUG|TITLE)__/g,(w,d)=>h[d]),metadata:f}}export{z as a,M as b,R as c};
|
|
@@ -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{a,b,c,d,e,f,g,h,i,j}from"./chunk-AR5D57ZD.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-7OG26PGF.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-QE5RG76S.mjs";import"./chunk-J5PUIV3Y.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{g as GESTURES,d as addName,b as blockNamed,i as keyOf,f as missingSaid,c as packageFolder,a as packageNamed,h as pairsOf,j as run,e as shallowSaid};
|
|
@@ -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{a as y,b as C}from"./chunk-Q4UEPUWF.mjs";import{a as A}from"./chunk-IV64FFI4.mjs";import{c as P,d as W}from"./chunk-GHOYKMQ3.mjs";import"./chunk-QE5RG76S.mjs";import"./chunk-UYVCQK3H.mjs";import"./chunk-J5PUIV3Y.mjs";import{b as j,f as M}from"./chunk-4OZWXZE5.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{randomBytes as R}from"node:crypto";import{existsSync as X,readdirSync as G,readFileSync as Y,statSync as _}from"node:fs";import c from"node:fs/promises";import q from"node:os";import i from"node:path";import{release as J,reportsDirectory as V,skillDirectory as H}from"../browser/shared/paths.mjs";import{copyOldDocuments as Q,ensureWorkspace as Z,layoutOf as z,oldStateOf as K}from"../browser/shared/workspace.mjs";var S=o=>_(o,{throwIfNoEntry:!1})?.isDirectory()??!1;function ee({agent:o=null,project:e=!1,dir:r=null,cwd:t=process.cwd(),env:s=process.env}={}){if(r)return[{agent:null,target:i.resolve(t,r),skills:null}];let a=o?[o]:Object.keys(y),u=d=>e?i.join(i.resolve(t),y[d].project):i.resolve(y[d].home(s)),p=a.filter(d=>S(u(d)));return(o||p.length?o?a:p:["claude"]).map(d=>{let h=i.join(u(d),"skills");return{agent:d,target:i.join(h,"gallery"),skills:h}})}function te(o){try{return C(Y(i.join(o,"SKILL.md"),"utf8"))}catch{return null}}function T(o){let e=_(o,{throwIfNoEntry:!1});if(!e)return{kind:"absent"};if(!e.isDirectory())return{kind:"other",why:"it is a file"};let r=G(o);if(r.length===0)return{kind:"absent"};if(r.includes(".git"))return{kind:"other",why:"it is a git checkout"};let t=te(o),s=u=>r.includes(u);return(s("package.json")&&s("src")||s("reports"))&&(t==="gallery"||t==="html-report-studio")?{kind:"fat",name:t}:t==="gallery"&&!s("package.json")&&!s("src")&&!s("reports")?{kind:"thin"}:{kind:"other",why:t?`its SKILL.md is the skill "${t}"`:"it holds no Gallery skill"}}function oe(o){return S(o)?G(o,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.name.startsWith(".")).map(e=>i.join(o,e.name)).filter(e=>T(e).kind==="fat"):[]}function re(o){let e=i.join(K(o),"servers");return S(e)?G(e).filter(r=>r.endsWith(".json")).flatMap(r=>{try{let{pid:t,port:s}=JSON.parse(Y(i.join(e,r),"utf8"));return!Number.isInteger(t)||t<=0||t===process.pid?[]:(process.kill(t,0),[{pid:t,port:s}])}catch(t){return t.code==="EPERM"?[{pid:Number.NaN,port:null}]:[]}}):[]}async function O(o){let e=0,r=0,t=async s=>{for(let a of await c.readdir(s,{withFileTypes:!0})){let u=i.join(s,a.name);a.isDirectory()?await t(u):(e++,r+=(await c.lstat(u)).size)}};return await t(o).catch(()=>{}),{files:e,bytes:r}}var B=o=>`${(o/1024/1024).toFixed(1)} MB`,se=(o,e)=>`${o} ${e}${o===1?"":"s"}`;async function v(o,e){for(let r=0;;r++)try{return await c.rename(o,e)}catch(t){if(process.platform!=="win32"||r>=10||!["EPERM","EBUSY","EACCES"].includes(t.code))throw t;await new Promise(s=>setTimeout(s,100*(r+1)))}}function ne(o,e=new Date){let r=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,t=i.join(z(o).gallery,`old-skill-${r}`);for(let s=1;;s++){let a=s===1?t:`${t}-${s}`;if(!X(a))return a}}async function ie(o,e){await c.mkdir(i.dirname(e),{recursive:!0});try{return await v(o,e),null}catch(s){if(s.code!=="EXDEV")return`${s.code??s.message}`}let r=await O(o);await c.cp(o,e,{recursive:!0,preserveTimestamps:!0,verbatimSymlinks:!0,errorOnExist:!0,force:!1});let t=await O(e);return t.files!==r.files||t.bytes!==r.bytes?`the copy holds ${t.files} files, ${t.bytes} bytes, of ${r.files}, ${r.bytes}: the old folder was left as it was`:(await c.rm(o,{recursive:!0,force:!0}),null)}async function U(o){let e=[],r=async t=>{for(let s of await c.readdir(t,{withFileTypes:!0})){let a=i.join(t,s.name);s.isDirectory()?await r(a):e.push([i.relative(o,a).split(i.sep).join("/"),await c.readFile(a)])}};return await r(o),e.sort(([t],[s])=>t<s?-1:t>s?1:0)}var le=(o,e)=>o.length===e.length&&o.every(([r,t],s)=>r===e[s][0]&&t.equals(e[s][1]));async function ae(o,e,r){if(r==="thin"&&le(await U(o),await U(e)))return"same";let t=i.dirname(e);await c.mkdir(t,{recursive:!0});let s=R(4).toString("hex"),a=i.join(t,`.gallery-skill-new-${s}`);if(await c.cp(o,a,{recursive:!0}),r==="absent")return X(e)&&await c.rmdir(e),await v(a,e),"new";let u=i.join(t,`.gallery-skill-old-${s}`);await v(e,u);try{await v(a,e)}catch(p){throw await v(u,e).catch(()=>{}),await c.rm(a,{recursive:!0,force:!0}),p}return await c.rm(u,{recursive:!0,force:!0}),"updated"}async function $e(o,{version:e}){let{positional:r,options:t,values:s}=M({options:["--project"],values:["--agent","--dir"],argv:o});if(r[0]!=="install")throw new j(r.length?`No such skill command: ${r[0]} (install).`:"Say what to do: gallery skill install.");if(r.length>1)throw new j(`gallery skill install takes no other argument: ${r[1]}`);let a=s.get("--agent")??null;if(a!==null&&!Object.hasOwn(y,a))throw new j(`--agent is claude or codex, not ${a}.`);let u=s.get("--dir")??null;if(u!==null&&(a!==null||t.has("--project")))throw new j("--dir names the skill's folder itself: not with --agent or --project.");let p=ee({agent:a,project:t.has("--project"),dir:u}),d=[],h=p.map(n=>({...n,...T(n.target)}));for(let{target:n,kind:l,why:f}of h)l==="other"&&d.push(`${n} holds something that is not a Gallery skill (${f}): move it away, or pass --dir <another folder>.`);let N=[...new Set(h.flatMap(({target:n,kind:l,skills:f})=>[...l==="fat"?[n]:[],...f?oe(f):[]]))];for(let n of N)for(let{pid:l,port:f}of re(n))d.push(Number.isNaN(l)?`The older Gallery skill ${n} has a preview server running that this user cannot see: stop it first.`:`The older Gallery skill ${n} has its preview server running (pid ${l}${f?`, port ${f}`:""}): stop it first (close the window that runs it, or end process ${l}), then run gallery skill install again.`);if(d.length){for(let n of d)console.error(n);console.error("Nothing was changed."),process.exit(1)}if(N.length){let n=V;try{let{ours:l,reads:f}=await Z(n);l||(console.error(W(n,f)),process.exit(1))}catch(l){if(!l.code)throw l;console.error(P(n,l.code)),process.exit(1)}console.log(`\u5DE5\u4F5C\u533A\uFF1A${n}`);for(let l of N){console.log(`An older Gallery skill (the whole tools) is in ${l}: its documents go into the workspace, then it moves out of the skills folder.`);let f=i.join(l,"reports");if(S(f)){let m=await Q({from:f,to:n,state:K(l)});for(let w of A(m,f,n))console.log(` ${w}`)}else console.log(" It holds no documents (no reports/ folder).");let g=i.join(l,"exports");if(S(g)){let m=z(n).exports;await c.mkdir(m,{recursive:!0});let w=[],I=[];for(let E of(await c.readdir(g)).filter(x=>x.endsWith(".html")).sort())try{await c.copyFile(i.join(g,E),i.join(m,E),c.constants.COPYFILE_EXCL),w.push(E)}catch(x){if(x.code!=="EEXIST")throw x;I.push(E)}w.length&&console.log(` Exports: copied ${se(w.length,"file")} into ${m}: ${w.join(", ")}`),I.length&&console.log(` Exports not copied (the name is taken in ${m}; they stay in the moved folder's exports/): ${I.join(", ")}`)}let{bytes:k}=await O(l),$=await O(i.join(l,"node_modules")),D=ne(n),L=await ie(l,D);L&&(console.error(`Could not move ${l} to ${D} (${L}). Its documents are copied; move the folder out of the skills folder yourself (it is never needed in it again), then run gallery skill install again.`),process.exit(1)),console.log(` Moved the old skill to ${D} (${B(k)}${$.files?`; its node_modules/, ${B($.bytes)}, may be deleted: nothing reads it any more`:""}).`)}}let F=H,b=null;if(!J){let{buildSkill:n}=await import("./chunk-UGWMMEJ5.mjs");b=await c.mkdtemp(i.join(q.tmpdir(),"gallery-skill-")),F=i.join(b,"gallery"),n(F,{version:e})}try{let n=!1;for(let{agent:l,target:f}of h){let g=T(f).kind,k=await ae(F,f,g),$=l?` for ${y[l].name}`:"";console.log(k==="same"?`The Gallery skill ${e}${$} is installed already, unchanged: ${f}`:`${k==="updated"?"Updated":"Installed"} the Gallery skill ${e}${$}: ${f}`),n||=k!=="same"}n&&console.log("Open a new Agent session to use it.")}finally{b&&await c.rm(b,{recursive:!0,force:!0})}}export{y as AGENTS,T as kindOf,$e as run,ee as targetsOf};
|
|
@@ -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{spawn as O}from"node:child_process";import{existsSync as I}from"node:fs";import C from"node:fs/promises";import _ from"node:os";import q from"node:path";import{APART as S}from"../browser/editor/components/registry.mjs";var N=6e4,x=600,B=["A4","A3","Letter","Legal","Tabloid"];function F(){if(process.env.GALLERY_BROWSER)return process.env.GALLERY_BROWSER;let{PROGRAMFILES:o="","PROGRAMFILES(X86)":e="",LOCALAPPDATA:r="",HOME:i=""}=process.env;return({win32:[`${o}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Google\\Chrome\\Application\\chrome.exe`,`${r}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Microsoft\\Edge\\Application\\msedge.exe`,`${o}\\Microsoft\\Edge\\Application\\msedge.exe`],darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Chromium.app/Contents/MacOS/Chromium",...i?[`${i}/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,`${i}/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge`,`${i}/Applications/Chromium.app/Contents/MacOS/Chromium`]:[]],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/opt/google/chrome/chrome","/usr/bin/microsoft-edge","/usr/bin/microsoft-edge-stable","/opt/microsoft/msedge/msedge","/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"]}[process.platform]??[]).find(s=>s&&I(s))??null}var $=()=>process.getuid?.()===0?["--no-sandbox"]:[],te=()=>["--no-first-run","--no-default-browser-check","--disable-extensions","--hide-scrollbars","--lang=zh-CN",...$()];function oe(o,e,r=[]){let i=o.location()?.url??"";return!/^Failed to load resource|^Refused to |Content Security Policy/.test(o.text())&&(!i||i.startsWith(e)||r.includes(i))}var re=o=>o.evaluateOnNewDocument(()=>{globalThis.__qaViolations=[],document.addEventListener("securitypolicyviolation",e=>{globalThis.__qaViolations.push({url:e.blockedURI,directive:e.effectiveDirective||e.violatedDirective,source:e.sourceFile,line:e.lineNumber})})}),V=3e4,W=5e3;function ie(o,e=W){let r=0,i=new Promise(c=>{r=setTimeout(c,e)});return Promise.race([Promise.resolve(o).catch(()=>{}),i]).finally(()=>clearTimeout(r))}var E=o=>new Promise(e=>setTimeout(e,o).unref()),D=o=>String(o??"").replace(/\s+/g," ").trim(),M=o=>{let e=o.split(/\r?\n/).map(D).filter(Boolean).at(-1);return e?`: ${e.slice(0,200)}`:""};async function se({executablePath:o,args:e=[],attempts:r=2,start:i=H}){let c=[];for(let s=0;s<r;s+=1){let n=await C.mkdtemp(q.join(_.tmpdir(),"gallery-browser-")),t=()=>C.rm(n,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{});try{let{browser:a,stop:l}=await i({executablePath:o,args:e,profile:n});return{browser:a,failures:c,close:async()=>{await l().catch(()=>{}),await t()}}}catch(a){c.push(D(a?.message??a)),await t()}}throw Object.assign(new Error(c.at(-1)??"the browser did not start"),{failures:c})}async function H({executablePath:o,args:e,profile:r,starting:i=V}){let{default:c}=await import("./chunk-ERLAIBOA.mjs"),s=await c.defaultArgs({headless:!0,userDataDir:r,args:[...e,"--remote-debugging-port=0"]}),n=process.platform!=="win32",t=O(o,s,{stdio:["ignore","ignore","pipe"],windowsHide:!0,detached:n}),a=!1;t.on("error",()=>a||=t.pid===void 0);let l=()=>a||t.exitCode!==null||t.signalCode!==null,u=new Promise(f=>t.once("exit",f)),m=()=>{if(!l())try{n?process.kill(-t.pid,"SIGKILL"):t.kill()}catch{try{t.kill("SIGKILL")}catch{}}};process.once("exit",m);let p="",d=new Promise((f,w)=>{let g=setTimeout(()=>w(new Error(`it said nothing of its DevTools port in ${i/1e3}s${M(p)}`)),i);t.stderr.setEncoding("utf8"),t.stderr.on("data",h=>{p=`${p}${h}`.slice(-4e3);let y=/DevTools listening on (ws:\/\/\S+)/.exec(p);y&&(clearTimeout(g),f(y[1]))}),t.once("error",h=>(clearTimeout(g),w(h))),t.once("exit",(h,y)=>(clearTimeout(g),w(new Error(`it stopped (${y??`exit ${h}`}) before it opened its DevTools port${M(p)}`))))}),A=async()=>{try{l()||await Promise.race([u,E(5e3)]),m(),l()||await Promise.race([u,E(3e3)])}finally{process.off("exit",m)}},v;try{let f=await d,w=0,g=new Promise((y,G)=>{w=setTimeout(()=>G(new Error(`it opened its DevTools port and did not answer in ${i/1e3}s`)),i)}),h=c.connect({browserWSEndpoint:f,defaultViewport:{width:800,height:600}});h.catch(()=>{}),v=await Promise.race([h,g]).finally(()=>clearTimeout(w))}catch(f){throw m(),await A(),f}return{browser:v,stop:async()=>{await Promise.race([v.close().catch(()=>{}),E(5e3)]),await A()}}}var b=null,L=0,T=0;async function K(){let o=F();if(!o)throw Object.assign(new Error("\u6CA1\u6709\u627E\u5230 Chrome \u6216 Edge\uFF1A\u5BFC\u51FA PDF \u9700\u8981\u7535\u8111\u4E0A\u88C5\u6709\u5176\u4E2D\u4E00\u4E2A\u6D4F\u89C8\u5668"),{reason:"browser"});let{default:e}=await import("./chunk-ERLAIBOA.mjs");return e.launch({executablePath:o,headless:!0,args:["--no-first-run","--no-default-browser-check","--disable-extensions",...$()]})}async function R(o,e){clearTimeout(L),T+=1,b??=K().catch(i=>{throw b=null,i});let r=await(await b).newPage();try{return await r.emulateMediaFeatures([{name:"prefers-reduced-motion",value:"reduce"},{name:"prefers-color-scheme",value:"light"}]),await r.setViewport({width:1200,height:900}),await r.setContent(o,{waitUntil:"load",timeout:6e4}),await P(r,{changing:x}),await e(r)}finally{await r.close().catch(()=>{}),T-=1,T===0&&(L=setTimeout(async()=>{let i=b;b=null,(await i?.catch(()=>null))?.close().catch(()=>{})},N))}}async function P(o,{timeout:e=15e3,changing:r=e}={}){let i=[],c=(n,t,a=e)=>{t!==!0&&i.push(`${n} (${t===!1?`not in ${a/1e3}s`:t})`)},s=(n,t=e)=>o.evaluate(n,t).catch(a=>a.message);return c("the fonts loaded",await s(n=>Promise.race([Promise.resolve(document.fonts?.ready).then(()=>!0),new Promise(t=>setTimeout(()=>t(!1),n))]))),c("the kit's first drawing done (data-doc-drawn)",await s(n=>new Promise(t=>{let a=Date.now(),l=()=>{!globalThis.DocKit||document.documentElement.hasAttribute("data-doc-drawn")?(globalThis.DocCode?.colorAll?.(),t(!0)):Date.now()-a>n?t(!1):setTimeout(l,50)};l()}))),c("the page done changing",await s(n=>new Promise(t=>{let a=()=>[document.documentElement.scrollHeight,...[...document.querySelectorAll("[style]")].map(d=>d.getAttribute("style")),...[...document.adoptedStyleSheets??[]].flatMap(d=>[...d.cssRules].map(A=>A.cssText)),...[...document.querySelectorAll("svg, canvas")].map(d=>d.outerHTML.length),[...document.images].filter(d=>d.complete).length].join("|"),l=Date.now(),u=a(),m=0,p=()=>{let d=a();m=d===u?m+1:0,u=d,m>=3?t(!0):Date.now()-l>n?t(!1):setTimeout(p,100)};setTimeout(p,100)}),r),r),i}async function k(o){await o.evaluate(()=>{document.documentElement.setAttribute("data-doc-theme","light");for(let e of document.querySelectorAll("[data-doc-sheets]")){let r=e.querySelector(":scope > .doc-sheet-tabs");if(r){for(let i of r.querySelectorAll(":scope > .doc-sheet-tab")){let c=i.getAttribute("data-sheet-tab"),s=[...e.querySelectorAll(":scope > [data-doc-sheet]")].find(a=>a.getAttribute("data-doc-sheet")===c);if(!s)continue;s.hidden=!1,s.removeAttribute("aria-hidden"),s.style.setProperty("display","block","important");let n=r.cloneNode(!1);n.removeAttribute("id"),n.removeAttribute("role"),n.style.setProperty("break-after","avoid");let t=i.cloneNode(!0);t.removeAttribute("id"),t.setAttribute("aria-selected","true"),t.classList.add("is-active"),n.append(t),s.before(n)}r.style.setProperty("display","none","important")}}for(let e of document.querySelectorAll("details"))e.open=!0;window.dispatchEvent(new Event("resize"))}),await P(o,{changing:x})}var j={A4:793.7,A3:1122.5,Letter:816,Legal:816,Tabloid:1056},z=96;async function U(o,e){await o.emulateMediaType("print");let r=await o.evaluate(()=>Math.max(0,innerWidth-document.documentElement.clientWidth));await o.setViewport({width:Math.floor(e)+r,height:900}),await P(o,{changing:x})}function ne(o,{paper:e="A4",scale:r=1}={}){let i=B.includes(e)?e:"A4",c=Math.min(2,Math.max(.1,r));return R(o,async s=>(await k(s),await U(s,(j[i]-2*z)/c),Buffer.from(await s.pdf({format:i,scale:c,printBackground:!0,margin:{top:"1in",right:"1in",bottom:"1in",left:"1in"}}))))}function ae(o){return R(o,async e=>{await k(e);let r=e.viewport(),i=await e.$$("main figure.doc-figure"),c=[];for(let s of i){let n=0;try{n=await s.evaluate(async(t,a)=>{let l=[];for(let u=t.closest(a);u;u=u.parentElement.closest(a))l.unshift(u);for(let u of l)u.style.setProperty("height","auto"),u.style.setProperty("max-height","calc(100dvh - (2 * var(--doc-dialog-margin)))"),u.showModal();return await new Promise(u=>requestAnimationFrame(()=>requestAnimationFrame(u))),l.length?Math.ceil(t.getBoundingClientRect().height):0},S),n&&(await e.setViewport({...r,height:r.height+n}),await P(e,{changing:x})),await s.evaluate(t=>t.scrollIntoView({block:"center"})),c.push(Buffer.from(await s.screenshot({type:"png"})))}catch{c.push(null)}await s.evaluate((t,a)=>{for(let l=t.closest(a);l;l=l.parentElement.closest(a))l.close(),l.style.removeProperty("height"),l.style.removeProperty("max-height"),l.getAttribute("style")||l.removeAttribute("style")},S).catch(()=>{}),n&&await e.setViewport(r).catch(()=>{})}return c})}export{F as a,te as b,oe as c,re as d,W as e,ie as f,se as g,P as h,ne as i,ae as j};
|
|
@@ -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 r from"node:os";import l from"node:path";var t={claude:{name:"Claude Code",home:e=>e.CLAUDE_CONFIG_DIR||l.join(r.homedir(),".claude"),project:".claude"},codex:{name:"Codex",home:e=>e.CODEX_HOME||l.join(r.homedir(),".codex"),project:".codex"}};function d(e){let o=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e.replace(/^/,""));return o?/^name:\s*["']?([\w.-]+)["']?\s*$/m.exec(o[1])?.[1]??null:null}var c=/\bThis skill is Gallery (\d+\.\d+\.\d+(?:-[\w.]+)?)'s\b/,i=e=>`This skill is Gallery ${e}'s`,m=e=>c.exec(e)?.[1]??null;export{t as a,d as b,c,i as d,m as e};
|