@heycys/gallery 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +51 -1
- package/browser/editor/components/callout/index.mjs +40 -15
- package/browser/editor/components/columns/page.mjs +45 -32
- package/browser/editor/components/details/index.mjs +2 -1
- package/browser/editor/components/dialog/index.mjs +2 -1
- package/browser/editor/components/dialog/page.mjs +0 -18
- package/browser/editor/components/divider/index.mjs +1 -1
- package/browser/editor/components/embed/index.mjs +2 -2
- package/browser/editor/components/figure/page.mjs +10 -1
- package/browser/editor/components/file/page.mjs +2 -2
- 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 +2 -0
- package/browser/editor/components/heading/page.mjs +6 -0
- package/browser/editor/components/highlight/index.mjs +4 -20
- package/browser/editor/components/icons.mjs +13 -2
- package/browser/editor/components/image/crop.mjs +6 -9
- package/browser/editor/components/image/page.mjs +2 -2
- package/browser/editor/components/installed/index.mjs +82 -29
- package/browser/editor/components/installed/page.mjs +146 -34
- package/browser/editor/components/installed/served.mjs +6 -5
- package/browser/editor/components/instances.mjs +18 -0
- package/browser/editor/components/kit.mjs +3 -0
- package/browser/editor/components/list/page.mjs +3 -6
- package/browser/editor/components/media/page.mjs +44 -14
- package/browser/editor/components/pages.mjs +2 -2
- package/browser/editor/components/registry.mjs +68 -33
- package/browser/editor/components/section/index.mjs +2 -1
- package/browser/editor/components/set-apart.mjs +24 -0
- package/browser/editor/components/table/index.mjs +64 -5
- package/browser/editor/components/table/page.mjs +30 -19
- package/browser/editor/page/annotate/anchors.mjs +4 -3
- package/browser/editor/page/annotate/card.mjs +3 -6
- package/browser/editor/page/annotate/index.mjs +61 -34
- package/browser/editor/page/autosave.mjs +357 -38
- package/browser/editor/page/beside.mjs +5 -5
- package/browser/editor/page/block-menu/colors.mjs +3 -1
- package/browser/editor/page/block-menu/index.mjs +8 -6
- package/browser/editor/page/blocks.mjs +16 -7
- package/browser/editor/page/board/client.mjs +57 -0
- package/browser/editor/page/board/hint.mjs +145 -0
- package/browser/editor/page/board/history.mjs +119 -0
- package/browser/editor/page/board/index.mjs +970 -0
- package/browser/editor/page/board/settings.mjs +209 -0
- package/browser/editor/page/caret.mjs +5 -2
- package/browser/editor/page/changes/bar.mjs +94 -0
- package/browser/editor/page/changes/ghost.mjs +206 -0
- package/browser/editor/page/changes/gone-words.mjs +94 -0
- package/browser/editor/page/changes/index.mjs +447 -0
- package/browser/editor/page/changes/words.mjs +27 -0
- package/browser/editor/page/clipboard/import/colors.mjs +3 -3
- 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 +156 -26
- package/browser/editor/page/clipboard/own/blocks.mjs +25 -16
- package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
- package/browser/editor/page/clipboard/own/describe.mjs +16 -7
- package/browser/editor/page/clipboard/own/export.mjs +6 -6
- package/browser/editor/page/clipboard/own/selection.mjs +3 -3
- package/browser/editor/page/clipboard/own/writers.mjs +0 -11
- package/browser/editor/page/columns/index.mjs +48 -46
- package/browser/editor/page/commit.mjs +98 -25
- package/browser/editor/page/conflicts.mjs +13 -33
- package/browser/editor/page/convert.mjs +8 -7
- package/browser/editor/page/core.mjs +81 -27
- package/browser/editor/page/custom-page.mjs +106 -0
- package/browser/editor/page/drag/index.mjs +40 -24
- package/browser/editor/page/drag/preview.mjs +9 -4
- package/browser/editor/page/editor.mjs +120 -28
- package/browser/editor/page/emoji-picker/emoji-tab.mjs +22 -13
- package/browser/editor/page/emoji-picker/grid.mjs +7 -5
- package/browser/editor/page/emoji-picker/icon-tab.mjs +4 -4
- package/browser/editor/page/emoji-picker/icons.mjs +0 -1
- package/browser/editor/page/emoji-picker/index.mjs +11 -9
- package/browser/editor/page/emoji-picker/styles.mjs +156 -2
- package/browser/editor/page/emoji-picker/support.mjs +6 -4
- package/browser/editor/page/emoji-picker/upload.mjs +14 -13
- package/browser/editor/page/fills.mjs +5 -3
- package/browser/editor/page/fold/index.mjs +348 -0
- package/browser/editor/page/fold/rule.mjs +125 -0
- package/browser/editor/page/folded.mjs +23 -0
- package/browser/editor/page/format-bar/bar.mjs +2 -1
- package/browser/editor/page/format-bar/index.mjs +1 -1
- package/browser/editor/page/geometry.mjs +8 -6
- package/browser/editor/page/handle/index.mjs +22 -14
- package/browser/editor/page/hints/index.mjs +1 -1
- package/browser/editor/page/history.mjs +24 -4
- package/browser/editor/page/insert/index.mjs +30 -17
- package/browser/editor/page/links/index.mjs +5 -3
- package/browser/editor/page/links/pages.mjs +27 -9
- package/browser/editor/page/long-runs.mjs +75 -0
- package/browser/editor/page/look.mjs +69 -6
- package/browser/editor/page/margin.mjs +63 -27
- package/browser/editor/page/media-menu/index.mjs +6 -7
- package/browser/editor/page/menu.mjs +86 -31
- package/browser/editor/page/merge.mjs +24 -0
- package/browser/editor/page/notices.mjs +3 -3
- package/browser/editor/page/offered.mjs +1 -1
- package/browser/editor/page/outline/folds.mjs +11 -10
- package/browser/editor/page/outline/index.mjs +131 -45
- package/browser/editor/page/outline/list.mjs +23 -11
- package/browser/editor/page/outline/read.mjs +1 -1
- package/browser/editor/page/outline/strip.mjs +7 -1
- package/browser/editor/page/page-objects.mjs +13 -2
- package/browser/editor/page/panel.mjs +9 -13
- package/browser/editor/page/present-links.mjs +11 -2
- package/browser/editor/page/resize/index.mjs +42 -29
- package/browser/editor/page/selection/delete.mjs +8 -6
- package/browser/editor/page/selection/index.mjs +10 -3
- package/browser/editor/page/served.mjs +14 -0
- package/browser/editor/page/session.mjs +101 -6
- package/browser/editor/page/slash-menu/index.mjs +3 -3
- package/browser/editor/page/table/cell-bar.mjs +4 -1
- package/browser/editor/page/table/cells.mjs +103 -47
- package/browser/editor/page/table/icons.mjs +3 -1
- package/browser/editor/page/table/index.mjs +40 -16
- package/browser/editor/page/table/pictures.mjs +299 -0
- package/browser/editor/page/table/views.mjs +150 -0
- package/browser/editor/page/table/widths.mjs +9 -4
- package/browser/editor/page/text-select/index.mjs +43 -14
- package/browser/editor/page/todo-writes.mjs +75 -0
- package/browser/editor/page/tooltip.mjs +1 -1
- package/browser/editor/page/type-grid.mjs +4 -3
- package/browser/editor/page/typing/code-edges.mjs +63 -17
- package/browser/editor/page/typing/index.mjs +65 -9
- package/browser/editor/page/typing/leave.mjs +1 -1
- package/browser/editor/page/ui.mjs +13 -0
- package/browser/shared/annotations.mjs +8 -10
- package/browser/shared/block-packs.mjs +404 -0
- package/browser/shared/board-places.mjs +224 -0
- package/browser/shared/card-size.mjs +59 -0
- package/browser/shared/code-folds.mjs +5 -1
- package/browser/shared/colors.mjs +17 -14
- package/browser/shared/component-catalog.mjs +345 -54
- package/browser/shared/component-source.mjs +37 -0
- package/browser/shared/components/callout.mjs +4 -2
- package/browser/shared/components/index.mjs +72 -9
- package/browser/shared/components/installed.mjs +110 -8
- package/browser/shared/components/page.mjs +22 -3
- package/browser/shared/components/state.mjs +5 -1
- package/browser/shared/components/table.mjs +1 -1
- package/browser/shared/components/text.mjs +2 -2
- package/browser/shared/document-look.mjs +183 -0
- package/browser/shared/drafts.mjs +432 -0
- package/browser/shared/emoji/data/LICENSE-lucide.txt +43 -0
- package/browser/shared/emoji/data/README.md +4 -2
- package/browser/shared/emoji/data/categories.json +1 -1
- package/browser/shared/emoji/data/keywords-en.json +1 -1
- package/browser/shared/emoji/data/keywords-zh.json +1 -1
- package/browser/shared/emoji/data/names.json +1 -1
- package/browser/shared/emoji/data/positions.json +1 -1
- package/browser/shared/emoji/data/twemoji-index.json +1 -1
- package/browser/shared/emoji/data/twemoji-svg.bin +0 -0
- package/browser/shared/emoji/data.mjs +10 -12
- package/browser/shared/emoji/emoji.mjs +8 -7
- package/browser/shared/emoji/icon-value.mjs +4 -3
- 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/html-tree.mjs +11 -5
- package/browser/shared/i18n/en.mjs +374 -35
- package/browser/shared/json-layout.mjs +47 -0
- package/browser/shared/long-runs.mjs +39 -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/new-names.mjs +5 -2
- package/browser/shared/outline-shape.mjs +128 -0
- package/browser/shared/outline.mjs +458 -0
- package/browser/shared/pack-manifest.mjs +77 -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 +388 -0
- package/browser/shared/paths.mjs +6 -0
- package/browser/shared/preferences.mjs +10 -4
- package/browser/shared/preview-server.mjs +3 -7
- package/browser/shared/session.mjs +13 -5
- package/browser/shared/shipped-blocks.mjs +299 -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 +134 -0
- package/browser/shared/workspace-columns.mjs +120 -0
- package/browser/shared/workspace-look.mjs +91 -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/browser/shared/zoom.mjs +5 -5
- package/dist/chunk-2NRBY6AJ.mjs +2 -0
- package/dist/chunk-32ZUEFZ7.mjs +2 -0
- package/dist/chunk-35NQ4PLQ.mjs +2 -0
- package/dist/chunk-3KJHLHUO.mjs +2 -0
- package/dist/chunk-3NJACR4W.mjs +2 -0
- package/dist/chunk-4AV456RQ.mjs +2 -0
- package/dist/chunk-4OZWXZE5.mjs +5 -0
- package/dist/chunk-5XYHDBJ5.mjs +2 -0
- package/dist/chunk-5ZJA7CXT.mjs +2 -0
- package/dist/chunk-6A53MZYZ.mjs +2 -0
- package/dist/chunk-6EXH3ORZ.mjs +166 -0
- package/dist/chunk-6EZ7FNIK.mjs +3 -0
- package/dist/{chunk-UXUK4PMC.mjs → chunk-6QBHU4DF.mjs} +1 -1
- package/dist/{chunk-6U2SLSDN.mjs → chunk-6VTU6KEO.mjs} +1 -1
- package/dist/chunk-B4P2CM2J.mjs +3 -0
- package/dist/chunk-BPL64HGA.mjs +4 -0
- package/dist/chunk-BVEFGE4B.mjs +2 -0
- package/dist/chunk-BZ5RAF7L.mjs +2 -0
- package/dist/chunk-CRJEG7MT.mjs +2 -0
- package/dist/{chunk-B3VTYBYR.mjs → chunk-D4CKRD3V.mjs} +91 -91
- package/dist/chunk-D4EURAX4.mjs +4 -0
- package/dist/chunk-DQCE7TJY.mjs +5 -0
- package/dist/chunk-DR73Y2UJ.mjs +3 -0
- package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
- package/dist/{chunk-DB4WKGYF.mjs → chunk-ERLAIBOA.mjs} +2 -2
- package/dist/chunk-EURLTOTZ.mjs +4 -0
- package/dist/chunk-FJYN7RTH.mjs +4 -0
- package/dist/chunk-FWNRPMCJ.mjs +12 -0
- package/dist/chunk-FWW4CSAZ.mjs +2 -0
- package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
- package/dist/chunk-GY3FAUVM.mjs +2 -0
- package/dist/chunk-HLYV7RIH.mjs +2 -0
- package/dist/chunk-HMYTM3GT.mjs +15 -0
- package/dist/chunk-IA4PSIMD.mjs +2 -0
- package/dist/chunk-JEUK3ZO7.mjs +2 -0
- package/dist/chunk-JVHHHGEA.mjs +3 -0
- package/dist/chunk-KTKHRC6H.mjs +2 -0
- package/dist/chunk-L7UP52JO.mjs +2 -0
- package/dist/chunk-MHW7ZKOU.mjs +2 -0
- package/dist/chunk-N76HWBA3.mjs +10 -0
- package/dist/chunk-N7AZZLGT.mjs +548 -0
- package/dist/chunk-NAMN3RAF.mjs +2 -0
- package/dist/{chunk-YXAUQPVK.mjs → chunk-NFMCP2HI.mjs} +3 -3
- package/dist/chunk-NG375ILQ.mjs +2 -0
- package/dist/chunk-NVRNLK25.mjs +6 -0
- package/dist/chunk-NWFBE2YA.mjs +2 -0
- package/dist/chunk-NWR2LT5B.mjs +2 -0
- package/dist/chunk-OJKMINIU.mjs +20 -0
- package/dist/chunk-OUUP3WKT.mjs +2 -0
- package/dist/chunk-OW5NWPOJ.mjs +10 -0
- package/dist/chunk-PAREWQGB.mjs +4 -0
- package/dist/chunk-POQSE4C2.mjs +2 -0
- package/dist/chunk-PUOQ65NC.mjs +2 -0
- package/dist/{chunk-Z52HTUW7.mjs → chunk-PVER7LSC.mjs} +2 -2
- package/dist/chunk-PZDLJJTJ.mjs +3 -0
- package/dist/chunk-Q47PLKIJ.mjs +15 -0
- package/dist/chunk-Q4UEPUWF.mjs +2 -0
- package/dist/chunk-QKXMPUXC.mjs +2 -0
- package/dist/chunk-QOUEFUCH.mjs +16 -0
- package/dist/chunk-RFDZXFJF.mjs +13 -0
- package/dist/chunk-RKPWLGZ3.mjs +4 -0
- package/dist/chunk-RMECZA2K.mjs +2 -0
- package/dist/{chunk-EUX7IC5J.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
- package/dist/chunk-SX4LJYT6.mjs +8 -0
- package/dist/chunk-SXHBYZST.mjs +16 -0
- package/dist/chunk-TANZRINB.mjs +2 -0
- package/dist/chunk-TEZAWDSQ.mjs +2 -0
- package/dist/chunk-UBBRTJ2R.mjs +24 -0
- package/dist/chunk-UFNYFFKO.mjs +20 -0
- package/dist/chunk-UGWYKHBL.mjs +170 -0
- package/dist/chunk-UKSHDZZ6.mjs +2 -0
- package/dist/chunk-UMHUSOPJ.mjs +2 -0
- package/dist/chunk-UNOYVIYR.mjs +2 -0
- package/dist/chunk-V6RIYQZZ.mjs +4 -0
- package/dist/chunk-VJPFVNNW.mjs +15 -0
- package/dist/chunk-VS3ZMVGX.mjs +5 -0
- package/dist/chunk-VTKNEYT3.mjs +6 -0
- package/dist/chunk-VXACTLO3.mjs +3 -0
- package/dist/chunk-W3BGBJQW.mjs +2 -0
- package/dist/chunk-YI43RG4P.mjs +2 -0
- package/dist/chunk-YQGT4AB2.mjs +6 -0
- package/dist/chunk-ZB4H7ZN4.mjs +2 -0
- package/dist/{chunk-ACOPDCNB.mjs → chunk-ZHEHPMBK.mjs} +1 -1
- package/dist/chunk-ZTHICSSF.mjs +2 -0
- package/dist/chunk-ZUNVAXLH.mjs +2 -0
- package/dist/chunk-ZWPMCK7P.mjs +2 -0
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{chunk-EVJ3BX3M.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 +14 -14
- package/kit/math.js +18 -2
- package/kit/report.css +500 -151
- package/kit/runtime.js +1720 -170
- package/kit/state.js +10 -1
- package/kit/tables.js +172 -37
- package/kit/ui.js +166 -27
- 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 +156 -0
- package/packs/gallery/countdown/preview.svg +1 -0
- package/packs/gallery/countdown/style.css +130 -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 +295 -0
- package/packs/gallery/habit/preview.svg +1 -0
- package/packs/gallery/habit/style.css +246 -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 +351 -0
- package/packs/gallery/heatmap/preview.svg +1 -0
- package/packs/gallery/heatmap/style.css +201 -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 +102 -0
- package/packs/gallery/note/preview.svg +1 -0
- package/packs/gallery/note/style.css +76 -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 +238 -0
- package/packs/gallery/recent/preview.svg +1 -0
- package/packs/gallery/recent/style.css +158 -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 +138 -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 +166 -0
- package/packs/gallery/stats/preview.svg +1 -0
- package/packs/gallery/stats/style.css +151 -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 +185 -0
- package/packs/gallery/today/preview.svg +1 -0
- package/packs/gallery/today/style.css +120 -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 +342 -0
- package/packs/gallery/todos/preview.svg +1 -0
- package/packs/gallery/todos/style.css +267 -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 +312 -0
- package/packs/gallery/weather/preview.svg +1 -0
- package/packs/gallery/weather/style.css +258 -0
- package/packs/gallery/weather/template.html +3 -0
- package/packs/gallery/weather/writing.md +26 -0
- package/packs/gallery-soft/pack.json +8 -0
- package/release.json +13 -11
- package/sdk/doc-kit.d.ts +404 -7
- package/sdk/doc-state.d.ts +2 -0
- package/skill/SKILL.md +71 -26
- package/skill/references/block-script.md +140 -0
- package/skill/references/building-blocks.md +257 -0
- package/skill/references/example-report.html +1 -1
- package/skill/references/extensions.md +59 -0
- package/skill/references/pages-and-data.md +221 -0
- package/skill/references/writing-html.md +9 -7
- package/skill/sdk/doc-kit.d.ts +404 -7
- package/skill/sdk/doc-state.d.ts +2 -0
- package/web/assets/index-BK2e_07w.js +13 -0
- package/web/assets/index-CWFI83mF.css +1 -0
- package/web/index.html +2 -2
- package/browser/editor/components/callout/page.mjs +0 -13
- package/dist/chunk-2PBALTR3.mjs +0 -57
- package/dist/chunk-3LA3EMDE.mjs +0 -15
- package/dist/chunk-5FRMCDPY.mjs +0 -16
- package/dist/chunk-5LEK2CBS.mjs +0 -2
- package/dist/chunk-5OFN5AHC.mjs +0 -2
- package/dist/chunk-5SIYS5HN.mjs +0 -2
- package/dist/chunk-5TEK3RAD.mjs +0 -2
- package/dist/chunk-6CYG3Z4V.mjs +0 -2
- package/dist/chunk-7GHT2UCA.mjs +0 -15
- package/dist/chunk-7QQBR7PB.mjs +0 -2
- package/dist/chunk-ATCJYAR4.mjs +0 -2
- package/dist/chunk-C7HWOBIF.mjs +0 -2
- package/dist/chunk-E7VYDG2X.mjs +0 -2
- package/dist/chunk-EZY3WC6Z.mjs +0 -15
- package/dist/chunk-FQGQH4KM.mjs +0 -2
- package/dist/chunk-G7TOXONE.mjs +0 -6
- package/dist/chunk-GPF4YWWB.mjs +0 -9
- package/dist/chunk-GYQV7Y4J.mjs +0 -120
- package/dist/chunk-HMHK3EQ6.mjs +0 -2
- package/dist/chunk-HQQMJCQJ.mjs +0 -10
- package/dist/chunk-IERUOGC3.mjs +0 -6
- package/dist/chunk-ITNLYXXV.mjs +0 -3
- package/dist/chunk-L4DVONOG.mjs +0 -2
- package/dist/chunk-LAE5NQ4B.mjs +0 -2
- package/dist/chunk-LC7YNQFG.mjs +0 -2
- package/dist/chunk-LHTFLRB6.mjs +0 -4
- package/dist/chunk-NFIBI4IP.mjs +0 -26
- package/dist/chunk-NSKUTQ5J.mjs +0 -5
- package/dist/chunk-O52JMOCZ.mjs +0 -2
- package/dist/chunk-P2CAZPDP.mjs +0 -3
- package/dist/chunk-QMQUXTU4.mjs +0 -12
- package/dist/chunk-QVWVFC5K.mjs +0 -6
- package/dist/chunk-QYKCJ7FG.mjs +0 -8
- package/dist/chunk-QZY6Q64C.mjs +0 -2
- package/dist/chunk-TDQP3DKQ.mjs +0 -10
- package/dist/chunk-TX6JH7TR.mjs +0 -2
- package/dist/chunk-UNUEWH4S.mjs +0 -2
- package/dist/chunk-V4CPWKMZ.mjs +0 -2
- package/dist/chunk-VACRB2NE.mjs +0 -3
- package/dist/chunk-W63L7367.mjs +0 -7
- package/dist/chunk-W7CXPCRV.mjs +0 -6
- package/dist/chunk-XINNG4F2.mjs +0 -4
- package/dist/chunk-YL2DPWVS.mjs +0 -4
- package/dist/chunk-YZ5Z6H4W.mjs +0 -4
- package/dist/chunk-ZBIM6ARY.mjs +0 -216
- package/skill/references/building-components.md +0 -327
- package/web/assets/index-B6Ai3wsa.js +0 -13
- package/web/assets/index-SYPC3EZy.css +0 -1
package/dist/chunk-TDQP3DKQ.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{B as Je,D as Qe,E as me,F as Et,I as Xe,J as tn,a as pe,e as Fe,f as Ee,g as Re,h as wt,i as he,j as Oe,k as Xt,l as Rt,m as De,n as Ve,o as At,p as Ne,q as Ge,r as $e,s as gt,t as Y,u as Le,v as Ye,w as We,x as Me,y as W,z as Ze}from"./chunk-NFIBI4IP.mjs";import{d as Tt}from"./chunk-W63L7367.mjs";import{b as ue,c as de,e as Ae}from"./chunk-A55HN5OK.mjs";import{BLOCK_TYPES as ve,COPIED_AS_ITSELF as zn,IDENTITY as gn}from"../browser/editor/components/registry.mjs";import{copyKeys as Un}from"../browser/editor/components/figure/index.mjs";import{accepts as ye,attributeValue as An,BLOCK_TYPES as Dt,boxRole as be,CHAPTER as En,holdsStraight as On,IDENTITY as Pe,isLead as rn,SIZES as Nn,sizeValue as ln,TOGGLES as an}from"../browser/editor/components/registry.mjs";import{iconMarkup as $n,iconValueOf as Ln,validIcon as Mn}from"../browser/editor/components/icon/index.mjs";Ae();import{attributeValue as bn,BLOCK_TYPES as en,HOSTS as xn,TOGGLES as wn}from"../browser/editor/components/registry.mjs";import{texSource as nn}from"../browser/editor/components/math/index.mjs";var je=new Set(Object.entries(en).filter(([,s])=>!s.box&&!s.bare).map(([s])=>s)),te=(s,m,w="")=>{let g=W[m.type]?.leaf;if(g)return g(s,m,w);let k=[s.className,...m.classes??[]].filter(Boolean).join(" ");return`<${s.tag}${k?` class="${k}"`:""}${he(m.attributes)}${w}>${m.html}</${s.tag}>`},Ce=(s,m)=>s===void 0||!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(s).every(([w,g])=>typeof g=="string"&&bn(m,w,g)),Te=s=>s?.empty===!0,Be=(s,m)=>s===void 0?null:w=>s.includes(m.slice(w.startOffset,w.endOffset));function ke(s,m,{empty:w=!1,file:g}={}){if(typeof m!="string"||!m.trim()&&!(w&&m===""))return!1;if(m==="")return!0;if(s.tex&&!nn(m))return!1;let k=s.inside??s.tag,O=`<${k}>${m}</${k}>`,[I,...a]=de(O,{sourceCodeLocationInfo:!0}).childNodes;return a.length===0&&I?.tagName===k&&me(I,[],s.inside!==void 0,{lists:k==="td"||k==="th",known:Be(g,O)})===null}var vn=new Set(Object.values(en).filter(s=>s.text&&s.className).map(s=>s.kind));function qe(s,m){if(s.keep?.reason==="script")return null;if(s.kind==="list")return m.some(g=>g.unit===s.id&&g.kind==="list")?"list":null;let w=W[s.kind];return w?.written?w.written(s)?"written":null:s.text===void 0||s.nested?null:["p","h1","h2","h3","h4","li"].includes(s.tag)||vn.has(s.kind)?"text":null}function ge(s,m,w){if(!Array.isArray(m)||!m.every(k=>Sn(s,k,w)))return"invalid";let g=m.filter(k=>k.keep);return g.length>1?"invalid":m.length>g.length&&!s.caps.split||g.length===0&&!s.caps.remove||m.length===0&&s.nested?"fixed":g.length===1&&g[0].html.trim()===""&&!s.caps.empty?"empty":null}function sn(s,m,w){let g=`<table><tbody><tr><${s}>${m}</${s}></tr></tbody></table>`,[k,...O]=de(g,{sourceCodeLocationInfo:!0}).childNodes,I=O.length===0&&k?.tagName==="table"&&k.childNodes.length===1?k.childNodes[0]:null,a=I?.childNodes.length===1?I.childNodes[0]:null,p=a?.childNodes.length===1?a.childNodes[0]:null;return p?.tagName===s&&me(p,[],!1,{lists:!0,known:Be(w,g)})===null}var on={p:"paragraph",h1:"heading",h2:"heading",h3:"heading",h4:"heading",li:"item"},In=(s,m)=>s.classes===void 0||!s.keep&&Array.isArray(s.classes)&&new Set(s.classes).size===s.classes.length&&s.classes.every(w=>(wn[on[m]]??[]).includes(w));function Sn(s,m,w){if(!m||typeof m.html!="string"||xn[s.kind]?.tex&&!nn(m.html))return!1;let g=m.keep?s.tag:m.tag;if(!m.keep&&Je[s.tag]!==g||!In(m,g)||m.attributes!==void 0&&(m.keep||!Ce(m.attributes,on[g])))return!1;let k=g==="td"||g==="th",O=k?`<table><tbody><tr><${g}>${m.html}</${g}></tr></tbody></table>`:`<${g}>${m.html}</${g}>`,[I,...a]=de(O,{sourceCodeLocationInfo:!0}).childNodes;if(a.length>0||!I)return!1;let p=I;if(k){let h=I.tagName==="table"&&I.childNodes.length===1?I.childNodes[0]:null,u=h?.childNodes.length===1?h.childNodes[0]:null;p=u?.childNodes.length===1?u.childNodes[0]:null}return p?.tagName===g&&me(p,[],Qe(s.kind,s.tag,s.caps),{lists:k,known:Be(w,O)})===null}import{attr as cn}from"../browser/shared/html-tree.mjs";import{pageLanguage as jn}from"../browser/shared/components/page.mjs";import{SHEETS as Cn}from"../browser/editor/components/kit.mjs";import{BLOCK_ID as Tn}from"../browser/shared/ids.mjs";function fn({current:s,edits:m,units:w=[],partial:g=!1,ids:k=!1,touch:O=[],proposals:I=null}){let a=Et(s),p=a.blocks,h=s.includes(`\r
|
|
3
|
-
`)?`\r
|
|
4
|
-
`:`
|
|
5
|
-
`,u=[],$=[],j=[],K=new Map,q=null,Z,yt=!1,J=(t,n)=>u.push({unit:t.id,reason:n}),X=t=>{let r=Rt(t).replace(/[0-9.]/g,l=>String.fromCharCode(l.charCodeAt(0)-65248)).replace(/[\s,,]/g,"").replace(/[−–]/g,"-").match(/-?\d+(?:\.\d+)?/)?.[0];return r===void 0?null:Number(r)},ct=(t,n,r)=>{if(t.kind!=="cell")return;let l=s.slice(t.start,t.innerStart),c=/\sdata-sort-value(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/.exec(l);if(!c)return;let d=(c[1]??c[2]??c[3]??"").trim(),x=/^-?\d+(\.\d+)?(e[-+]?\d+)?$/i.test(d)?Number(d):null,[S,f]=[X(s.slice(t.innerStart,t.innerEnd)),X(n)],b="";x!==null&&f!==null?b=` data-sort-value="${Number((f*(S?x/S:1)).toPrecision(12))}"`:x!==null&&S===null&&(b=c[0]),b!==c[0]&&$.push({start:t.start+c.index,end:t.start+c.index+c[0].length,text:b,of:[{id:r}]})},Vt=t=>{t.keep&&e(t)?J(t,"referenced"):j.push({start:t.start,end:t.end},...t.companion?[t.companion]:[])},ne=(t,n)=>{let r=t.classAttr,l=r?r.value.split(/\s+/).filter(Boolean):[],c=l;for(let[x,S]of n)c=S?c.includes(x)?c:[...c,x]:c.filter(f=>f!==x);if(c.join(" ")===l.join(" "))return;if(at(t),!r){let x=/^<[A-Za-z][\w-]*/.exec(s.slice(t.elStart,t.elStart+40));if(!x)return J(t,"unknown");let S=t.elStart+x[0].length;$.push({start:S,end:S,text:` class="${c.join(" ")}"`});return}if(c.length===0){$.push({...Xt(s,r.start,r.end),text:""});return}let d=/=\s*'/.test(s.slice(r.start,r.end))?"'":'"';$.push({start:r.start,end:r.end,text:`class=${d}${c.join(" ")}${d}`})},vt=typeof k=="function"?k:k?Xe:null,rt=new Set([...s.matchAll(tn)].map(t=>t[1]??t[2])),Bt=()=>{for(;;){let t=vt();if(!rt.has(t))return rt.add(t)&&t}},se=[],qt=[],Gt=t=>t?` ${Pe}="${t}"`:"",ie=t=>typeof t=="string"&&Tn.test(t)&&!rt.has(t),lt=(t,n)=>{let r=vt?ie(n)?(rt.add(n),n):Bt():null;return r&&t!==void 0&&qt.push({key:t,id:r}),Gt(r)},et=new Set,Pt=t=>{et.add(t.at);let n=I?.get(t.id),r=vt?ie(n)?(rt.add(n),n):Bt():null;return r&&se.push({at:t.at,id:r}),Gt(r)},at=t=>{if(!vt||!t||t.blockId||t.at===void 0||et.has(t.at))return;let n=Oe(s,t.at);$.push({start:n,end:n,text:Pt(t)})},Ot=t=>{let{element:n,source:r}=At(t.restore),l=n.sourceCodeLocation,c=cn(n,Pe);if(c&&!rt.has(c))return rt.add(c),t.key!==void 0&&qt.push({key:t.key,id:c}),r;let d=r,x=l.startTag.endOffset-1;if(c){let S=l.attrs[Pe],f=Xt(d,S.startOffset,S.endOffset);d=d.slice(0,f.start)+d.slice(f.end),x-=f.end-f.start}return x=Oe(d,x),d.slice(0,x)+lt(t.key,t.blockId)+d.slice(x)},pt=t=>{let n=null;for(let r of a.units)r.elStart<=t.start&&t.start<r.end&&(!n||r.elStart>n.elStart)&&(n=r);return n},P=new Set;for(let t of m){let{id:n,parts:r}=t??{},l=Number.isInteger(n)?p[n]:void 0;if(!l){u.push({id:n,reason:"unknown"});continue}if(Array.isArray(r)&&r.length===0&&l.self!==null&&a.units[l.self].keep){u.push({id:n,reason:"referenced"});continue}let c=ge(l,r,s);if(c){u.push({id:n,reason:c});continue}if(r.length===0){let N={...Le(s,l.start,l.end),of:[{id:n}]};$.push(N),K.set(n,N),l.self!==null&&P.add(l.self);continue}let d=Y(s,l.start),x=d===null?"":h+d,S=N=>`<${N.tag}${N.classes?` class="${N.classes.join(" ")}"`:""}${he(N.attributes)}${lt(N.key,N.blockId)}>${N.html}</${N.tag}>`,f=r.findIndex(N=>N.keep),b=pt(l),v=b&&b.at===l.innerStart-1;if((!v||l.tag==="li")&&at(b),l.tag==="li"&&f>=0){let N=r.slice(0,f),H=r.slice(f+1),z=b?{start:b.start,end:b.end}:null;$.push({start:l.innerStart,end:l.innerEnd,text:r[f].html,of:[{id:n}]}),N.length>0&&$.push({start:l.start,end:l.start,seq:1/0,text:N.map(S).join(x)+x,edge:z,of:[{id:n}]}),H.length>0&&$.push({start:l.end,end:l.end,text:x+H.map(S).join(x),edge:z,of:[{id:n}]})}else{let N=s.slice(l.start,l.innerStart);if(v&&vt&&!b.blockId&&!et.has(b.at)&&(N=`${N.slice(0,-1)}${Pt(b)}>`),r.length===1&&f===0&&N===s.slice(l.start,l.innerStart)){$.push({start:l.innerStart,end:l.innerEnd,text:r[0].html,of:[{id:n}]}),ct(l,r[0].html,n),l.kind==="title"&&(q={from:Rt(s.slice(l.innerStart,l.innerEnd)),to:Rt(r[0].html)});continue}let H=r.map(z=>z.keep?N+z.html+s.slice(l.innerEnd,l.end):S(z)).join(x);$.push({start:l.start,end:l.end,text:H,of:[{id:n}]})}l.kind==="title"&&(q={from:Rt(s.slice(l.innerStart,l.innerEnd)),to:Rt(r[0].html)})}let G=(t,n,r)=>{let l=a.units.filter(f=>f.box===t),c=[];for(let f=1;f<l.length;f++){let b=s.slice(l[f-1].end,l[f].start);b.trim()||c.push({pair:[l[f-1],l[f]],gap:b})}let d=c.find(({pair:f})=>f.includes(n))??c[0];if(d)return d.gap.replace(/\r?\n/g,h);let x=Y(s,r.start),S=be(a.boxes[t]?.kind)==="root"?h:"";return x===null?"":S+h+x},Yt=t=>{if(t.kind!=="nest"||Y(s,t.innerEnd)!==null)return null;let n=a.units[t.unit];return n?Y(s,n.elStart):null},Wt=(t,n)=>{let r=s.slice(t.at+1,t.innerEnd).match(/\n([ \t]*)\S/);return r?r[1]:`${n??""} `},zt=(t,n)=>n!==null&&be(t.kind)==="root",ft=[],Zt=(t,n,r,l)=>{let c=Number.isInteger(n?.into)?a.boxes[n.into]:null,d=Number.isInteger(n?.after),x=c?null:a.units[d?n.after:n?.before],S=c??(x?a.boxes[x.box]:null),f=H=>H>=t.start&&H<t.end;if(!S||!(ye(S.kind,Jt(t))||l===S.kind)||t.kind==="tab"&&S.id!==t.box||x&&(x===t||!r.has(x.id)||f(x.elStart))||c&&f(S.at))return J(t,"position");let b=Y(s,t.start);if(at(t),c){if(c.innerEnd===null)return J(t,"missing");let H=Yt(c);if(H!==null){ft.push({start:t.start,end:t.end,at:c.innerEnd,seq:o++,from:b,to:H+nt,wrap:_=>h+H+nt+_+h+H});return}let z=Y(s,c.innerEnd),ot=Wt(c,z),B=z!==null&&ot.startsWith(z)?ot.slice(z.length):" ",U=zt(c,z);ft.push({start:t.start,end:t.end,at:U?c.innerEnd-z.length:c.innerEnd,seq:o++,from:b,to:ot,wrap:_=>z===null?_:U?z+B+_+h:B+_+h+z});return}let v=G(x.box,x,x),N=d?v.includes(`
|
|
6
|
-
`)?v.slice(v.lastIndexOf(`
|
|
7
|
-
`)+1):null:Y(s,x.start);ft.push({start:t.start,end:t.end,at:d?x.end:x.start,seq:o++,from:b,to:N,wrap:H=>d?v+H:H+v})},ht=(t,n)=>t.classes===void 0||Array.isArray(t.classes)&&new Set(t.classes).size===t.classes.length&&t.classes.every(r=>(an[n.kind]??[]).includes(r)),Ut=(t,n)=>!Ze(t)&&(W[t.type]?.check?.(t)??!0)&&ht(t,n)&&Ce(t.attributes,n.kind),_t=(t,n,r={})=>ke(t,n,{...r,file:s}),Ht=(t,n)=>{if(it.has(t.id))return;let r=Dt[n?.type],l=qe(t,a.boxes);if(!(l==="text"||l==="written"&&r?.kind!==t.kind)||!je.has(n?.type)||!ke(r,n.html,{empty:Te(r),file:s}))return J(t,"invalid");if(!dt.has(t.id)&&!mt.has(t.id)&&!ye(a.boxes[t.box].kind,r.kind))return J(t,"position");if(!Ut(n,r))return J(t,"invalid");let c=t.blockId?Gt(t.blockId):Pt(t);et.add(t.at);let d=l==="written"&&t.node?Fe(s,t.node,W[t.kind].attribute):t.carried;$.push({start:t.elStart,end:t.end,text:te(r,n,d+c)})},oe=(t,n)=>{if(it.has(t.id))return;let r=W[t.kind]?.rewrite;if(!r)return J(t,"invalid");let l=r(s,t.node,n,{validCell:(c,d)=>sn(c,d,s),get packages(){return Tt().packages}});if(!l)return J(t,"invalid");at(t),$.push(...[l].flat())},re=(t,n)=>{if(qe(t,a.boxes)!=="list"||n!=="ul"&&n!=="ol")return J(t,"invalid");let r=/^<(ul|ol)\b/i.exec(s.slice(t.elStart,t.elStart+3)),l=/<\/(ul|ol)\s*>$/i.exec(s.slice(t.elStart,t.end));if(!r||!l)return J(t,"unknown");if(r[1].toLowerCase()===n)return;at(t);let c=t.end-l[0].length+2;$.push({start:t.elStart+1,end:t.elStart+3,text:n},{start:c,end:c+2,text:n})},Kt=new Set([...s.matchAll(/\sid\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi)].map(t=>t[1]??t[2]??t[3])),Nt=new Map,$t=new Set,nt=/\n(\t|[ ]+)</.exec(s)?.[1]??" ",bt=(t,n)=>{let r=d=>ye(n,d)||t?.stood===n;if(t?.restore!==void 0){let d=At(t.restore),x=d?.kind==="item"?Ee(d.element,n):d?.kind;if(!d||!r(x))return!1;if(t.children===void 0)return!0;let S=Dt[t.type];return On(S)&&S.kind===x&&t.children.every(f=>bt(f,S.box))}if(t?.unit!==void 0){let d=Number.isInteger(t.unit)?a.units[t.unit]:void 0;return!d||$t.has(d.id)||it.has(d.id)||dt.has(d.id)||P.has(d.id)||d.kind==="tab"||!r(Jt(d))?!1:($t.add(d.id),!0)}let l=Dt[t?.type];if(!l||!r(l.kind))return!1;if(t.type==="divider")return!0;if(t.type==="icon")return Mn(t.icon);let c=W[t.type];return l.bare&&c?.check?c.check(t,{validLeaf:_t,usedIds:Kt})&&ht(t,l):l.box?!Array.isArray(t.children)||t.children.length===0&&!c?.empty||!ht(t,l)||c?.check&&!c.check(t,{validLeaf:_t,usedIds:Kt})?!1:t.children.every(d=>bt(d,l.box)):!je.has(t.type)||!ke(l,t.html,{empty:Te(l),file:s})||!Ut(t,l)?!1:t.children===void 0?!0:Array.isArray(t.children)&&c?.children?.(t,bt)===!0},Q=(t,n)=>{if(t.unit!==void 0){let b=Nt.get(t.unit);return gt(F(b),b.from,n)}if(t.restore!==void 0&&t.children===void 0)return gt(Ot(t),"",n);let r=Dt[t.type];if(t.type==="divider")return`<hr${lt(t.key,t.blockId)}>`;if(t.type==="icon")return $n(t.icon,lt(t.key,t.blockId));let l=n===null?null:n+nt,c=(b,v,N,H=n,z=l)=>z===null?b+v.join("")+N:b+v.map(ot=>h+z+ot).join("")+h+H+N,d=b=>t.children.map(v=>Q(v,b));if(t.restore!==void 0){let b=Ot(t),{element:v}=At(b),{startTag:N,endTag:H}=v.sourceCodeLocation,z=v.childNodes.findLastIndex(B=>B.tagName),ot=v.childNodes.slice(z+1).filter(B=>B.nodeName==="#comment").map(({sourceCodeLocation:{startOffset:B,endOffset:U}})=>gt(b.slice(B,U),Y(b,B),l));return c(gt(b.slice(0,N.endOffset),"",n),[...d(l),...ot],H?b.slice(H.startOffset):`</${r.tag}>`)}let x={get id(){return lt(t.key,t.blockId)},get language(){return jn(s)},idOf:b=>lt(b.key,b.blockId),render:(b,v)=>Q(b,v),indent:n,inner:l,step:nt,block:c,children:d,deep:b=>n===null?null:n+nt.repeat(b)},S=W[t.type]?.write;if(r.bare&&S)return S(t,x);if(!r.box)return t.children?S(t,x):te(r,t,lt(t.key,t.blockId));if(S)return S(t,x);let f=[r.className,...t.classes??[]].filter(Boolean).join(" ");return c(`<${r.tag}${f?` class="${f}"`:""}${lt(t.key,t.blockId)}>`,d(l),`</${r.tag}>`)},st=[],le=t=>{let{insert:n,place:r}=t,l=B=>u.push({unit:t.id,reason:B}),c=n?.restore!==void 0?At(n.restore):null;if(n?.type==="icon"||c?.kind==="icon"){let B=Number.isInteger(r?.into)?a.boxes[r.into]:null,U=B?null:a.units[Number.isInteger(r?.after)?r.after:r?.before],_=B??(U?a.boxes[U.box]:null);if(rn(_?.kind,"icon")){if(!bt(n,_.kind))return l("invalid");if(_.innerEnd===null)return l("missing");let kt=a.units.find(Ke=>Ke.box===_.id&&Ke.kind!=="icon"),Qt=kt?kt.start:_.innerEnd,Ct=Y(s,Qt);st.push({at:Qt,seq:o++,text:()=>Q(n,Ct)+(Ct===null?"":h+Ct)});return}if(!bt(n,"header"))return l("invalid");let tt=p.find(kt=>kt.kind==="title");if(!tt)return l("missing");let xt=Y(s,tt.start);st.push({at:tt.start,seq:o++,text:()=>Q(n,xt)+(xt===null?"":h+xt)}),Z=c?Ln(c.source):n.icon;return}if(n?.type==="tab"||c?.kind==="tab")return Lt(t,c,l);let d=Number.isInteger(r?.into)?a.boxes[r.into]:null,x=Number.isInteger(r?.after),S=d?null:a.units[x?r.after:r?.before],f=d??(S?a.boxes[S.box]:null),b=n?.restore!==void 0?At(n.restore):null,v=b?f&&b.kind==="item"?Ee(b.element,f.kind):b.kind:Dt[n?.type]?.kind;if(!f||!v||!(ye(f.kind,v)||n.stood===f.kind)||S&&!jt.has(S.id))return l("position");let N=new Set($t);if(!bt(n,f.kind))return l("invalid");for(let B of $t){if(N.has(B))continue;let U=a.units[B];at(U);let _={start:U.start,end:U.end,at:null,from:Y(s,U.start)};Nt.set(B,_),ft.push(_)}if(d){if(d.innerEnd===null)return l("missing");let B=Yt(d);if(B!==null){st.push({at:d.innerEnd,seq:o++,text:()=>h+B+nt+Q(n,B+nt)+h+B});return}let U=Y(s,d.innerEnd),_=Wt(d,U),tt=U!==null&&_.startsWith(U)?_.slice(U.length):nt,xt=a.units.filter(Ct=>Ct.box===d.id),kt=be(d.kind)==="root"&&En.has(v)&&(xt.some(Ct=>jt.has(Ct.id))||!d.pure&&(xt.length>0||n.restore!==void 0))?h:"",Qt=zt(d,U);st.push({at:Qt?d.innerEnd-U.length:d.innerEnd,seq:o++,text:()=>U===null?Q(n,null):Qt?kt+U+tt+Q(n,_)+h:tt+Q(n,_)+h+U});return}let H=x?S.end:S.start;if(be(f.kind)==="root"){let B=G(S.box,S,S),U=x?B.includes(`
|
|
8
|
-
`)?B.slice(B.lastIndexOf(`
|
|
9
|
-
`)+1):null:Y(s,S.start);st.push({at:H,seq:o++,text:()=>x?B+Q(n,U):Q(n,U)+B});return}let z=Y(s,S.start),ot=z===null?"":h+z;st.push({at:H,seq:o++,text:()=>x?ot+Q(n,z):Q(n,z)+ot})},Lt=({insert:t,place:n},r,l)=>{let c=Number.isInteger(n?.after),d=a.units[c?n.after:n?.before];if(d?.kind!=="tab"||!jt.has(d.id))return l("position");if(!bt(t,"tabs"))return l("invalid");let x=d.companion,S=a.units[d.parent??-1];if(!x||!S)return l("missing");let f=r?cn(r.element,Cn.tabKey):t.sheet,b=s.slice(S.start,S.end);if(b.includes(`data-sheet-tab="${f}"`)||b.includes(`data-doc-sheet="${f}"`))return l("invalid");let v=Y(s,d.start),N=Y(s,x.start),H=(_,tt)=>_===null?tt:c?h+_+tt:tt+h+_,z=()=>r?gt(Ot(t),"",v):We({...t,sheet:f},lt(t.key,t.blockId)),ot=()=>{if(r)return gt(r.panel,"",N);let _=`<div data-doc-sheet="${f}">`;if(t.children.length===0)return N===null?`${_}</div>`:`${_}${h}${N}</div>`;let tt=N===null?null:N+nt,xt=t.children.map(kt=>Q(kt,tt));return tt===null?_+xt.join("")+"</div>":_+xt.map(kt=>h+tt+kt).join("")+h+N+"</div>"};st.push({at:c?d.end:d.start,seq:o++,text:()=>H(v,z())});let B=c?/^\s*/.exec(s.slice(x.end))[0]:/\s*$/.exec(s.slice(0,x.start))[0],U=N!==null&&/\n[ \t]*\r?\n/.test(B)?h:"";st.push({at:c?x.end:x.start,seq:o++,text:()=>c?U+H(N,ot()):H(N,ot())+U})},Ie=(t,n)=>{let r=t.node?.sourceCodeLocation;if(t.at===void 0||!r)return J(t,"unknown");at(t),$.push(...Me(s,r.startTag,[["style",l=>Ve(l?.value??"",n)||null]]))},D=(t,n)=>{let r=t.node?.sourceCodeLocation;if(t.at===void 0||!r)return J(t,"unknown");at(t),$.push(...Me(s,r.startTag,n))},Mt=new Map,ut=new Map,It=new Map,it=new Set(w.filter(t=>t?.remove===!0).map(t=>t.id)),dt=new Set(w.filter(t=>t?.move).map(t=>t.id)),mt=new Map,ae=(t,n)=>n?.unit!==void 0?mt.set(n.unit,t.id):Array.isArray(n?.children)&&n.children.forEach(r=>ae(t,r));w.forEach(t=>ae(t,t?.insert));let ce=new Map(w.filter(t=>Number.isInteger(t?.id)&&t.replace).map(t=>[t.id,t.replace])),Jt=t=>Dt[ce.get(t.id)?.type]?.kind??t.kind,jt=new Set(a.units.map(t=>t.id).filter(t=>!it.has(t)&&!dt.has(t)&&!mt.has(t)&&!P.has(t))),fe=a.units.filter(t=>dt.has(t.id)||mt.has(t.id)),Se=(t,n)=>r=>n.some(l=>l!==t&&t.start<=l.start&&l.end<=t.end&&l.start<=r&&r<l.end),e=t=>!!t.keep&&!t.keep.at.every(Se(t,fe)),i=(t,n)=>{let r=[$,j,ft,st],l=r.map(c=>c.length);n(),r.forEach((c,d)=>c.slice(l[d]).forEach(x=>x.of??=t))},o=0;for(let t of w){let{id:n,remove:r,toggle:l,on:c,move:d,size:x,value:S,attribute:f,stood:b}=t??{},v=Number.isInteger(n)?a.units[n]:void 0;i([{unit:n}],()=>{if(t?.insert&&typeof n=="string")le(t);else if(v&&t.replace){let N=u.length;Ht(v,t.replace),u.length>N&&ce.delete(v.id)}else v&&t.retag?re(v,t.retag):v&&(t.table||t.source)?oe(v,t.table??t.source):v&&r===!0?e(v)?u.push({unit:n,reason:"referenced"}):v.kind==="tab"&&a.units.every(N=>N.box!==v.box||it.has(N.id))?u.push({unit:n,reason:"last"}):(v.kind==="icon"&&!rn(a.boxes[v.box]?.kind,"icon")&&(yt=!0),Vt(v)):v&&d&&typeof d=="object"&&!it.has(n)?P.has(n)||Zt(v,d,jt,b):v&&typeof c=="boolean"&&(an[v.kind]??[]).includes(l)?(Mt.get(v)??Mt.set(v,new Map).get(v)).set(l,c):v&&Nn[v.kind]?.[x]&&(S===null||ln(v.kind,x,S)!==null)?it.has(n)||(ut.get(v)??ut.set(v,new Map).get(v)).set(x,S===null?null:ln(v.kind,x,S)):v&&typeof f=="string"&&An(v.kind,f,S)?it.has(n)||(It.get(v)??It.set(v,new Map).get(v)).set(f,S):u.push({unit:n,reason:x===void 0&&f===void 0?"unknown":"invalid"})})}let y=new Set(u.map(t=>t.unit).filter(t=>t!==void 0)),M=t=>(it.has(t.id)||dt.has(t.id)||mt.has(t.id))&&!y.has(mt.get(t.id)??t.id);for(let t of a.boxes){if(!["list","quote"].includes(t.kind)||!t.pure||t.unit===null)continue;let n=a.units[t.unit];if(!n||it.has(n.id)||dt.has(n.id)||mt.has(n.id))continue;let r=a.units.filter(c=>c.box===t.id);if(r.length===0||!r.every(M))continue;let l=c=>!!c&&(c.into===t.id||[n,...r].some(d=>c.after===d.id||c.before===d.id));w.some(c=>l(c?.insert?c.place:c?.move))||Vt(n)}for(let[t,n]of Mt)i([{unit:t.id}],()=>ne(t,n));for(let[t,n]of ut)i([{unit:t.id}],()=>Ie(t,n));for(let[t,n]of It)i([{unit:t.id}],()=>D(t,n));for(let t of O)at(a.units[t]);let E=new Set([...K.keys()].map(t=>p[t].wrapper).filter(Boolean));for(let t of E){let n=t.ids.map(r=>K.get(r));n.some(r=>!r)||j.some(r=>r.start<=t.start&&t.end<=r.end)||(n.forEach(r=>r.skip=!0),$.push({...Le(s,t.start,t.end),of:t.ids.map(r=>({id:r}))}))}if(q&&q.from!==q.to){let t=De(s,q);q.synced=!!t,t&&$.push(t)}else q=null;let L=new Map;for(let t of j){let n=`${t.start}:${t.end}`;L.has(n)?L.get(n).of=[...L.get(n).of??[],...t.of??[]]:L.set(n,t)}j.splice(0,j.length,...L.values());let A=(t,n)=>{t.of?.length||u.push({reason:n});for(let r of t.of??[])u.push({...r,reason:n})},C=(t,n,r)=>n===r?t.start<n&&n<t.end:t.start<=n&&r<=t.end,R=(t,n,r,l=null)=>{let c=null;for(let d of ft){let x=l!==null&&d.start===l.start&&d.end===l.end;d!==r&&(x||C(d,t,n))&&(!c||d.start>=c.start)&&(c=d)}return c},V=(t,n,r,l=null)=>{let c=R(t,n,r,l);return j.some(d=>d!==r&&C(d,t,n)&&!(c&&C(d,c.start,c.end)))},T=new Set,F=t=>{if(T.has(t))return A(t,"position"),"";T.add(t);try{return St(t)}finally{T.delete(t)}},St=t=>{let[n,r]=t?[t.start,t.end]:[0,s.length],l=(f,b,v=null,N=null)=>R(f,b,v,N)===t&&!V(f,b,v,N),c=[];for(let f of[...j,...ft].filter(b=>b!==t&&l(b.start,b.end,b)).sort((b,v)=>b.start-v.start)){let b=c.at(-1);b&&(f.start<=b.end||!s.slice(b.end,f.start).trim())?(b.end=Math.max(b.end,f.end),b.of.push(...f.of??[])):c.push({start:f.start,end:f.end,of:[...f.of??[]]})}let d=[...$.filter(f=>!f.skip&&l(f.start,f.end,null,f.edge??null)).map(f=>({...f,seq:f.seq??-2})),...c.map(f=>({...Ye(s,f.start,f.end),seq:-1,of:f.of})),...[...ft.filter(f=>f.at!==null),...st].filter(f=>l(f.at,f.at,f)).map(f=>({start:f.at,end:f.at,seq:f.seq,text:f.text?f.text():f.wrap(gt(F(f),f.from,f.to)),of:f.of}))].sort((f,b)=>f.start-b.start||f.end-f.start-(b.end-b.start)||f.seq-b.seq),x=[];for(let f of d)x.length>0&&f.start<x.at(-1).end?A(f,"overlap"):x.push(f);let S=s.slice(n,r);for(let f of x.reverse())S=S.slice(0,f.start-n)+f.text+S.slice(f.end-n);return S},Ft=F(null);if(u.length>0&&!g)return{ok:!1,conflicts:u};let He=Z??(yt?null:void 0);return{ok:u.length===0,text:Ft,version:pe(Ft),ids:{assigned:se,created:qt},...q?{title:q}:{},...He!==void 0?{icon:He}:{},...g?{conflicts:u}:{}}}import{attr as yn}from"../browser/shared/html-tree.mjs";import{outsideKey as _n}from"../browser/shared/ids.mjs";Ae();import{commonPrefix as un,commonSuffix as dn,mergeText as pn}from"../browser/editor/page/merge.mjs";var ee=new Map;function xe(s){let m=ee.get(s);if(m)return m;let w=/data-block-id/i.test(s)?Re(s,[ue(s,{sourceCodeLocationInfo:!0})]):[],g="",k=0,O=0,I=[];for(let p of w)g+=s.slice(k,p.start),k=p.end,O+=p.end-p.start,I.push({at:g.length,end:p.end,removed:O});g+=s.slice(k);let a={text:g,at:p=>p-(I.findLast(h=>h.end<=p)?.removed??0),source:p=>p+(I.findLast(h=>h.at<=p)?.removed??0)};for(ee.set(s,a);ee.size>4;)ee.delete(ee.keys().next().value);return a}function ze(s,m,w,g=w.start){let[k,O]=[xe(s),xe(m)],I=k.at(w.start),a=k.text.slice(I,k.at(w.end)),p=K=>O.source(K+k.at(g)-I),h=K=>{let q=[];for(let Z=K.indexOf(a);Z>=0;Z=K.indexOf(a,Z+1))q.push(Z);return q},u=h(O.text);if(u.length<=1&&h(k.text).length<=1)return u.length===1?p(u[0]):-1;let $=k.text.slice(Math.max(0,I-120),I),j=u.filter(K=>O.text.slice(Math.max(0,K-$.length),K)===$);return j.length===1?p(j[0]):u.length>1?-2:-1}function Ue(s,m,w,g){let[O,I]=[xe(s),xe(m)],[a,p]=[O.at(w.start),O.at(w.end)],h=O.text.slice(Math.max(0,a-400),a),u=O.text.slice(p,p+400),$=g.filter(q=>q.tag===w.tag).map(q=>{let[Z,yt]=[I.at(q.start),I.at(q.end)];return{other:q,score:dn(h,I.text.slice(Math.max(0,Z-400),Z))+un(u,I.text.slice(yt,yt+400))}}).sort((q,Z)=>Z.score-q.score),[j,K]=$;return j&&j.score>=40&&j.score-(K?.score??0)>=20?j.other:null}function hn(s,m){let w=p=>p.replace(/<[^>]*>/g," ").replace(/&(?:[a-z]+|#\d+);/gi," ").replace(/\s+/g," ").trim(),g=w(s),k=w(m);if(!g||!k)return!g&&!k;if(g.length<2||k.length<2)return g===k;let O=p=>{let h=new Map;for(let u=0;u<p.length-1;u++)h.set(p.slice(u,u+2),(h.get(p.slice(u,u+2))??0)+1);return h},I=O(k),a=0;for(let[p,h]of O(g))a+=Math.min(h,I.get(p)??0);return 2*a/(g.length-1+k.length-1)>=.5}Ae();import{IDENTITY as Bn}from"../browser/editor/components/registry.mjs";import{escapeAttribute as qn}from"../browser/shared/escape.mjs";import{attr as mn}from"../browser/shared/html-tree.mjs";import{CHART_DATA as _e,CHART_SOURCE as we,nextChartKey as Pn}from"../browser/shared/table-chart.mjs";function kn(s,m){if(m.size===0||!s.includes(we))return{text:s,keys:{}};let w=[],g=(a,p)=>{for(let h of a.childNodes??[]){if(!h.tagName)continue;let u=p||m.has(mn(h,Bn));for(let $ of[_e,we]){let j=mn(h,$);j!==void 0&&w.push({name:$,key:j,made:u,at:h.sourceCodeLocation?.attrs?.[$]??null})}g(h.tagName==="template"?h.content:h,u)}};g(ue(s,{sourceCodeLocationInfo:!0}),!1);let k=new Set(w.map(({key:a})=>a)),O={};for(let a of new Set(w.filter(p=>p.made&&p.name===we).map(p=>p.key))){let p=w.filter(u=>u.key===a&&!u.made),h=w.some(u=>u.key===a&&u.made&&u.name===_e);h&&p.length>0?(O[a]=Pn(k),k.add(O[a])):!h&&p.some(u=>u.name===we)&&(O[a]=null)}return{text:w.filter(({name:a,key:p,made:h,at:u})=>h&&u&&Object.hasOwn(O,p)&&!(O[p]===null&&a===_e)).map(({name:a,key:p,at:h})=>O[p]===null?{...Xt(s,h.startOffset,h.endOffset),put:""}:{start:h.startOffset,end:h.endOffset,put:`${a}="${qn(O[p])}"`}).sort((a,p)=>p.start-a.start).reduce((a,{start:p,end:h,put:u})=>a.slice(0,p)+u+a.slice(h),s),keys:O}}function Hn({current:s,opening:m=null,texts:w=[],units:g=[],touch:k=[],ids:O=!0,seal:I=null,pageIds:a=null}){let p=Et(s),h=typeof m=="string"?Et(m):null,u=e=>s.slice(e.innerStart,e.innerEnd),$=null,j=e=>($??=new Map(p.units.map(i=>[i.id,wt(s,i)]))).get(e.id),K=new Map,q=new Set,Z=new Map,yt=new Set(Array.isArray(a)?a.filter(e=>typeof e=="string"):[]),J=(e,i,o=!0,y=[])=>{let M=F=>!!F.blockId&&yt.has(F.blockId)&&!y.includes(F.blockId),E=yt.size>0?p.units.filter(F=>!M(F)):p.units,L=typeof i=="string"?E.filter(F=>j(F)===i):[],A=e>=0?h?.units[e]:void 0,C=A&&L.length>1?h.units.filter(F=>!M(F)&&wt(m,F)===i):[];if(L.length===1)return{unit:L[0]};if(C.length===L.length&&C.includes(A))return{unit:L[C.indexOf(A)]};if(!A)return L.length>1?{reason:"ambiguous"}:{gone:!0};let R=ze(m,s,A,A.elStart),V=R>=0?E.find(F=>F.elStart===R):null;if(V)return{unit:V};if(R===-2||L.length>1)return{reason:"ambiguous"};if(!o)return{gone:!0};let T=Ue(m,s,A,E);return T&&hn(m.slice(A.start,A.end),s.slice(T.start,T.end))?{unit:T,changed:!0}:{gone:!0}},X=e=>{if(!e||typeof e.key!="number"&&typeof e.key!="string")return{reason:"invalid"};if(K.has(e.key))return K.get(e.key);let i,o=typeof e.blockId=="string"?p.units.filter(y=>y.blockId===e.blockId):[];if(o.length===1&&typeof e.id!="string")i={unit:o[0]};else if(typeof e.id=="string"){let y=p.units.filter(M=>M.blockId===e.id);i=y.length===1?{unit:y[0]}:y.length>1?{reason:"ambiguous"}:Number.isInteger(e.open)&&typeof e.openHash=="string"?J(e.open,e.openHash,!1,[e.id]):{gone:!0}}else Number.isInteger(e.open)?i=J(e.open,e.hash,!0,[e.blockId]):i={reason:"invalid"};return i.unit&&!i.unit.blockId&&typeof e.blockId=="string"&&Z.set(i.unit.id,e.blockId),K.set(e.key,i),i.unit&&ct(e,i)&&q.add(e.key),i},ct=(e,i)=>i.changed||e.hash===null||typeof e.hash=="string"&&j(i.unit)!==e.hash,Vt=new Set(p.units.map(e=>e.blockId).filter(Boolean)),ne=[],vt=e=>e?.restore!==void 0?yn(At(e.restore?.source)?.element??{},gn)??e.blockId:e?.blockId,rt=e=>{let i=vt(e);if(typeof i=="string"&&Vt.has(i))return!0;let o=ve[e?.type];return!!o?.keyed&&typeof e.id=="string"&&p.boxes.some(y=>y.kind===o.box&&y.key===e.id)},Bt=e=>{let i=vt(e);e?.key!==void 0&&typeof i=="string"&&Vt.has(i)&&ne.push({key:e.key,id:i}),Array.isArray(e?.children)&&e.children.forEach(Bt)},se=(e,i)=>{let o=ve[i?.type];return!!o&&s.slice(e.elStart,e.end)===te(o,i,(e.carried??"")+(e.blockId?` ${gn}="${e.blockId}"`:""))},qt=(e,i,o)=>Array.isArray(e)&&Array.isArray(i)&&e.length===i.length&&e[0]===i[0]&&e.slice(1).every((y,M)=>y[0]===i[M+1]?.[0]&&y[1]===i[M+1][1]&&(!o||y[2]===i[M+1][2])),Gt=e=>{if(!e||typeof e.before!="string")return{reason:"invalid"};let i=o=>({block:o,changed:u(o)!==e.before});if(e.title){let o=p.blocks.filter(y=>y.kind==="title");return o.length===1?i(o[0]):{reason:o.length?"ambiguous":"missing"}}if(e.unit){let o=X(e.unit);if(!o.unit)return{reason:o.gone?"missing":o.reason};let y=p.blocks.filter(L=>L.unit===o.unit.id);if(e.self){let L=y.find(A=>A.self===o.unit.id);return L?i(L):{reason:"missing"}}let M=y.find(L=>qt(L.path,e.path,!1));if(M&&qt(M.path,e.path,!0))return i(M);let E=y.filter(L=>u(L)===e.before);return E.length===1?i(E[0]):{reason:W[o.unit.kind]?.textParts&&!ct(e.unit,o)?"package":"structure"}}if(Number.isInteger(e.open)||e.outside){let o=p.blocks.filter(A=>A.unit===null&&A.kind!=="title"&&u(A)===e.before);if(o.length===1)return i(o[0]);let y=Number.isInteger(e.open)?h?.blocks[e.open]:null;if(!y||o.length>1)return{reason:o.length>1?"ambiguous":"missing"};let M=ze(m,s,y),E=M>=0?p.blocks.find(A=>A.start===M):null;if(E)return i(E);let L=M===-2?null:Ue(m,s,y,p.blocks.filter(A=>A.unit===null));return L?i(L):{reason:M===-2?"ambiguous":"missing"}}return{reason:"invalid"}},ie=e=>{if(e?.main)return p.boxes.find(o=>o.kind==="main")??null;if(e&&!e.unit&&typeof e.kind=="string")return p.boxes.find(o=>o.unit===null&&o.kind===e.kind&&(o.key??null)===(e.key??null))??null;let i=e?.unit?X(e.unit):null;return i?.unit?p.boxes.find(o=>o.unit===i.unit.id&&o.kind===e.kind&&(o.key??null)===(e.key??null))??null:null},lt=[],et=e=>{e&&typeof e=="object"&&(typeof e.key=="number"||typeof e.key=="string")&<.push(e)},Pt=e=>{e?.unit!==void 0&&et(e.unit),e?.copy!==void 0&&et(e.copy),e?.children?.forEach(Pt)},at=e=>{et(e?.after),et(e?.before),et(e?.into?.unit)};for(let e of w)et(e?.block?.unit);for(let e of g)et(e?.unit),at(e?.place),at(e?.move),Pt(e?.insert);k.forEach(et);let Ot=new Map;for(let e of lt){let i=X(e);i.unit&&(Ot.get(i.unit)??Ot.set(i.unit,[]).get(i.unit)).push({key:e.key,changed:!!i.changed})}for(let e of Ot.values())if(!(new Set(e.map(i=>i.key)).size<2))for(let i of e)i.changed&&K.set(i.key,{gone:!0});let pt=new Map,P=new Map,G=(e,i,o,y={})=>e.set(i,{key:i,status:"conflict",reason:o,...y}),Yt=new Map,Wt=(e,i,o,y)=>{let M=L=>{for(let A=L.unit;A!=null;A=i.units[A]?.parent)if(A===o.id)return!0;return!1};if(!y)return{hash:wt(e,o),theirs:i.blocks.filter(M).map(L=>e.slice(L.innerStart,L.innerEnd)).join(`
|
|
10
|
-
`)};let E=L=>Object.fromEntries(y.filter(A=>typeof L?.[A]=="string").map(A=>[A,L[A]]));return{theirs:E(W[o.kind]?.dataOf?.(e,o.node,Tt().packages)??{}),parts:E(o.parts)}},zt=(e,i,o=null,y={})=>{Yt.set(e,{unit:i,held:o}),G(P,e,"changed",{...Wt(s,p,i,o),...y})},ft=[],Zt=new Map;for(let e of w){let{key:i,block:o}=e??{},y=e?.parts,M=Array.isArray(y)?y.filter(A=>!A?.keep):[];M.some(rt)&&(M.forEach(Bt),y=y.filter(A=>A?.keep||!rt(A)));let E=Gt(o);if(!E.block){E.reason==="missing"&&Array.isArray(y)&&!y.some(A=>A?.keep)&&y.every(rt)?pt.set(i,{key:i,status:"applied"}):G(pt,i,E.reason);continue}let L=Array.isArray(y)&&y.length===1&&y[0]?.keep&&typeof y[0].html=="string"?y[0].html:null;if(E.changed&&L!==null&&L===u(E.block))pt.set(i,{key:i,status:"applied"});else if(E.changed){let A=L===null?null:pn(o.before,L,u(E.block));if(A===null||ge(E.block,[{keep:!0,html:A}],s)){G(pt,i,"changed",{theirs:u(E.block)});continue}y=[{keep:!0,html:A}],pt.set(i,{key:i,status:"merged",html:A})}else pt.set(i,{key:i,status:"applied"});Zt.set(E.block.id,i),ft.push({id:E.block.id,parts:y})}let ht=[],Ut=new Map,_t=(e,i)=>Ut.set(e,[...Ut.get(e)??[],i]),Ht={},oe=e=>{if(e?.into){let y=ie(e.into);return y?{into:y.id}:null}let i=!!e?.after,o=X(i?e.after:e?.before);return o?.unit?{[i?"after":"before"]:o.unit.id}:null},re=null,Kt=e=>{if(e?.unit!==void 0){let y=X(e.unit);return y.unit?{unit:y.unit.id,stood:e.stood}:null}if(e?.restore!==void 0){let{source:y,seal:M}=e.restore??{};if(!I||typeof y!="string"||M!==I(y))return null;let E=Array.isArray(e.children)?e.children.map(Kt):void 0;return E?.includes(null)?null:{restore:y,key:e.key,blockId:e.blockId,stood:e.stood,...E?{type:e.type,children:E}:{}}}if(e?.copy!==void 0){let y=X(e.copy),M=e.keys===void 0?null:Un(e.keys);return e.keys!==void 0&&!M?null:y.unit&&zn.has(y.unit.kind)?{restore:$e(s,y.unit,{keys:M,taken:re??=new Set(Ne(s))}),key:e.key,blockId:e.blockId}:null}if(!e||typeof e!="object")return null;let i=W[e.type]?.source;if(i){let y=E=>$e(E,{start:0,end:E.length},{taken:re??=new Set(Ne(s))}),M=i(e,{packages:Tt().packages,written:y});return M?{restore:M,key:e.key,blockId:e.blockId}:null}let o=Array.isArray(e.children)?e.children.map(Kt):void 0;return o?.includes(null)?null:{...e,...o?{children:o}:{}}},Nt=new Set,$t=e=>[...Nt].filter(i=>i!==e&&[e,e.companion].some(o=>o&&o.start<=i.start&&i.end<=o.end)),nt=e=>{if(e?.unit!==void 0){let i=X(e.unit);i.unit&&Nt.add(i.unit)}else Array.isArray(e?.children)&&e.children.forEach(nt)};for(let e of g)e?.move?nt({unit:e.unit}):e?.insert&&nt(e.insert);let bt=(e,i)=>{let o=p.boxes.filter(E=>E.unit===e.id),y=new Map(i.map(E=>[X(E).unit,E])),M=p.units.filter(E=>o.some(L=>L.id===E.box));return o.every(E=>E.pure)&&M.length>0&&M.every(E=>Nt.has(E)||y.has(E)&&!ct(y.get(E),{unit:E}))},Q=new Set,st=e=>{if(e?.unit!==void 0){let i=X(e.unit);i.unit&&Q.add(i.unit)}else Array.isArray(e?.children)&&e.children.forEach(st)},le=[],Lt=new Map;for(let e of g){let i=e?.key;if(e?.insert&&rt(e.insert)){Bt({...e.insert,key:e.insert.key??i}),P.set(i,{key:i,status:"applied"});continue}if(e?.insert){let C=Kt({...e.insert,key:e.insert.key??i}),R=oe(e.place);if(!C||!R){G(P,i,!C&&W[e.insert.type]?.source?W[e.insert.type].unwritten(e.insert,{packages:Tt().packages}):"position");continue}P.set(i,{key:i,status:"applied"}),_t(i,i),ht.push({id:i,insert:C,place:R}),st(e.insert);continue}let o=X(e?.unit);if(e?.force===!0&&o.gone&&typeof e.hash=="string"&&typeof e.unit.id!="string"){let C=Number.isInteger(e.unit.open)&&e.unit.open>=0?h?.units[e.unit.open]:void 0;o=!h||h.units.some(V=>V!==C&&wt(m,V)===e.hash)?{reason:"ambiguous"}:J(-1,e.hash,!1,[e.unit.blockId]),o.unit&&!o.unit.blockId&&typeof e.unit.blockId=="string"&&Z.set(o.unit.id,e.unit.blockId),K.set(e.unit.key,o)}if(e?.source&&o.gone&&typeof e.unit.id=="string"&&e.parts&&typeof e.parts=="object"){let C=Object.entries(e.parts).filter(([,V])=>typeof V=="string"),R=C.length>0?p.units.filter(V=>V.parts&&!yt.has(V.blockId)&&C.every(([T,F])=>V.parts[T]===F)):[];R.length===1&&(o={unit:R[0]},R[0].blockId||Z.set(R[0].id,e.unit.id),K.set(e.unit.key,o),ct(e.unit,o)&&q.add(e.unit.key))}let y=typeof e?.size=="string"||typeof e?.toggle=="string"||typeof e?.attribute=="string",M=e?.remove===!0&&Array.isArray(e.items)&&e.force!==!0&&!!o.unit&&ct(e.unit,o)&&bt(o.unit,e.items);if(e?.remove===!0&&Array.isArray(e.items)&&e.force!==!0&&!M&&(o.gone||o.unit&&ct(e.unit,o))){let C=e.items.map(T=>({ref:T,found:X(T)})),R=C.find(T=>!T.found.unit&&!T.found.gone),V=C.filter(T=>T.found.unit&&!Nt.has(T.found.unit));if(R)G(P,i,R.found.reason);else if(V.some(T=>ct(T.ref,T.found)))o.unit?zt(i,o.unit):G(P,i,"changed");else if(V.some(T=>Lt.has(T.found.unit)))G(P,i,"ambiguous");else{P.set(i,{key:i,status:"applied"});for(let{ref:T,found:F}of V)Lt.set(F.unit,T.key),_t(F.unit.id,i),ht.push({id:F.unit.id,remove:!0})}continue}if(!o.unit){o.gone&&(e?.remove===!0||y)?P.set(i,{key:i,status:"applied"}):G(P,i,o.gone?"missing":o.reason);continue}if(e.replace&&se(o.unit,e.replace)){P.set(i,{key:i,status:"applied"});continue}if(e.source){let C=W[o.unit.kind]?.definition?.(o.unit.node,Tt().packages);if(typeof C!="string"||C!==e.definition){G(P,i,"definition");continue}}if(e.table&&W[o.unit.kind]?.definition){G(P,i,"invalid");continue}let E=e.source;if(e.source&&typeof e.source=="object"&&(e.force===!0||ct(e.unit,o))){let C=e.force===!0||!o.changed,R=St=>C&&St.every(Ft=>typeof e.parts?.[Ft]=="string"&&e.parts[Ft]===o.unit.parts?.[Ft]),V=Kn(e.source,e.together),T=V.filter(R).flat(),F=V.filter(St=>!R(St)).flat();if(F.length>0){if(zt(i,o.unit,F,T.length>0?{wrote:T}:{}),T.length===0)continue;E=Object.fromEntries(T.map(St=>[St,e.source[St]]))}}else if((e.remove===!0||e.replace||e.table)&&!M&&(e.force===!0?j(o.unit)!==e.hash:ct(e.unit,o))){zt(i,o.unit);continue}let L=E!==e.source;if(Lt.has(o.unit)&&Lt.get(o.unit)!==e.unit.key){G(P,i,"ambiguous");continue}Lt.set(o.unit,e.unit.key);let A=null;if(e.remove===!0){A={remove:!0};let{unit:C}=o,R=C.companion?Ge(s,C):gt(s.slice(C.start,C.end),Y(s,C.start),"");Ht[i]={source:R,seal:I?I(R):null,...$t(C).length>0?{around:!0}:{}}}else if(e.move){let C=oe(e.move);if(!C){G(P,i,"position");continue}A={move:C,stood:e.stood}}else e.replace?A={replace:e.replace}:typeof e.retag=="string"?A={retag:e.retag}:e.table&&typeof e.table=="object"?A={table:e.table}:E&&typeof E=="object"?A={source:E}:typeof e.toggle=="string"?A={toggle:e.toggle,on:e.on}:typeof e.size=="string"?A={size:e.size,value:e.value}:typeof e.attribute=="string"&&(A={attribute:e.attribute,value:e.value});if(!A){G(P,i,"unknown");continue}L||P.set(i,{key:i,status:"applied"}),_t(o.unit.id,i),ht.push({id:o.unit.id,...A}),A.move&&Q.add(o.unit),A.remove&&le.push({key:i,unit:o.unit})}for(let{key:e,unit:i}of le)$t(i).every(o=>Q.has(o))||(G(P,e,"position"),delete Ht[e],ht.splice(ht.findIndex(o=>o.id===i.id&&o.remove),1));let Ie=[...new Set(k.map(X).filter(e=>e.unit).map(e=>e.unit.id))],D=fn({current:s,edits:ft,units:ht,partial:!0,ids:O,touch:Ie,proposals:Z}),Mt=kn(D.text,new Set((D.ids?.created??[]).map(({id:e})=>e)));D.text=Mt.text;for(let e of D.conflicts??[]){e.id!==void 0&&Zt.has(e.id)&&G(pt,Zt.get(e.id),e.reason);for(let i of Ut.get(e.unit)??[])G(P,i,e.reason),delete Ht[i]}let ut=Et(D.text),It=new Map,it=new Map(D.ids.assigned.map(({at:e,id:i})=>[e,i]));for(let[e,i]of K){let o=i.unit?i.unit.blockId??it.get(i.unit.at):null;o&&It.set(e,o)}for(let[e,{unit:i,held:o}]of Yt){let y=i.blockId??it.get(i.at),M=y?ut.units.filter(E=>E.blockId===y):[];M.length===1&&P.get(e)?.reason==="changed"&&Object.assign(P.get(e),Wt(D.text,ut,M[0],o))}let dt=new Map([...ne,...D.ids.created].map(({key:e,id:i})=>[e,i])),mt=new Set([...It.values(),...dt.values()]),ae=new Set(ut.units.map(e=>e.blockId).filter(Boolean)),ce=[...mt].filter(e=>!ae.has(e)),Jt=new Map,jt=new Map,fe=e=>{let o=(Array.isArray(e?.children)?e.children.map(fe).some(Boolean):!1)||[e?.unit,e?.copy].some(y=>y!==void 0&&q.has(y?.key));return e?.key!==void 0&&jt.set(e.key,o),o};for(let e of g)e?.insert&&fe({...e.insert,key:e.insert.key??e.key});for(let[e,i]of[...It,...[...dt].filter(([o])=>jt.get(o)!==!0)]){if(q.has(e))continue;let o=ut.units.filter(y=>y.blockId===i);o.length===1&&Jt.set(e,wt(D.text,o[0]))}let Se=g.filter(e=>ve[e?.insert?.type]?.keyed&&typeof e.insert.id=="string"&&P.get(e.key)?.status==="applied").map(e=>({key:e.insert.id,box:ve[e.insert.type].box}));return{text:D.text,version:pe(D.text),texts:[...pt.values()],units:[...P.values()],ids:Object.fromEntries(It),made:Object.fromEntries(dt),hashes:Object.fromEntries(Jt),removed:Ht,gone:ce,file:Dn(D.text,ut,mt,new Set(dt.values())),outside:Rn(D.text,ut),keyed:Fn(D.text,ut,Se),...Object.keys(Mt.keys).length>0?{chartKeys:Mt.keys}:{},...D.title?{title:D.title}:{},...D.icon!==void 0?{icon:D.icon}:{}}}function Kn(s,m){let w=[];for(let g of[...Array.isArray(m)?m:[],...Object.keys(s).map(k=>[k])]){let k=Array.isArray(g)?g.filter(I=>typeof I=="string"&&Object.hasOwn(s,I)):[],O=w.filter(I=>k.some(a=>I.includes(a)));if(k.length!==0){for(let I of O)w.splice(w.indexOf(I),1);w.push([...new Set([...O.flat(),...k])])}}return w}function Fn(s,m,w){let g={};for(let{key:k,box:O}of w){let I=m.boxes.find(a=>a.kind===O&&a.key===k);I&&(g[k]={units:m.units.filter(a=>a.box===I.id).map(a=>a.blockId??{hash:wt(s,a)})})}return g}function Rn(s,m){let w={};for(let g of m.blocks){let k=g.unit===null?_n(g.kind==="title",yn(g.node,"id")):null;k&&(w[k]=s.slice(g.innerStart,g.innerEnd))}return w}function Dn(s,m,w,g){let k=new Map;for(let a of m.units)a.blockId&&k.set(a.blockId,(k.get(a.blockId)??0)+1);let O=a=>{for(let p=a.parent;p!=null;p=m.units[p].parent)if(g.has(m.units[p].blockId))return!0;return!1},I={};for(let a of m.units){if(!a.blockId||k.get(a.blockId)!==1||!(w.has(a.blockId)||O(a)))continue;let p=a.parent===null?null:m.units[a.parent];I[a.blockId]={kind:a.kind,hash:wt(s,a),keep:a.keep??null,...a.grid?{grid:!0}:{},...a.parts?{parts:a.parts}:{},parent:p?p.blockId??"":null,boxes:m.boxes.filter(h=>h.unit===a.id).map(h=>({kind:h.kind,key:h.key,units:m.units.filter(u=>u.box===h.id).map(u=>u.blockId??{hash:wt(s,u)})})),blocks:m.blocks.filter(h=>h.unit===a.id).map(h=>({...h.self!==null?{self:!0}:{path:h.path},kind:h.kind,caps:Object.keys(h.caps),inner:s.slice(h.innerStart,h.innerEnd),...h.atoms.length>0?{atoms:h.atoms}:{}})),...W[a.kind]?.definition&&(g.has(a.blockId)||O(a))?{markup:s.slice(a.elStart,a.end)}:{}}}return I}function Rs({current:s,units:m=[]}){let w=Et(s),g=[];for(let k of m){if(typeof k?.id!="string"||typeof k.key!="string"&&typeof k.key!="number")continue;let O=w.units.filter(a=>a.blockId===k.id);if(O.length===0){g.push({key:k.key,gone:!0});continue}if(O.length>1||k.from===void 0||k.from===k.parent||k.from===""||k.parent==="")continue;(O[0].parent===null?null:w.units[O[0].parent].blockId??"")===k.from&&g.push({key:k.key,moved:!0})}return g}function Ds({current:s,instances:m=[],pageIds:w=null}){let g=Et(s),k=new Set(Array.isArray(w)?w.filter(I=>typeof I=="string"):[]),O=[];for(let I of m){if(typeof I?.id!="string"||typeof I.key!="string"&&typeof I.key!="number"||!I.parts||typeof I.parts!="object")continue;let a=j=>Object.entries(I.parts).filter(([K,q])=>typeof j.parts?.[K]=="string"&&j.parts[K]!==q?.after&&Array.isArray(q?.before)&&q.before.includes(j.parts[K])),p=g.units.filter(j=>j.blockId===I.id),h=p.length===0?g.units.filter(j=>j.parts&&!k.has(j.blockId)&&a(j).length>0):[],u=p.length===1?p[0]:h.length===1?h[0]:null,$=u?a(u):[];$.length>0&&O.push({key:I.key,parts:Object.fromEntries($.map(([j])=>[j,u.parts[j]])),markup:s.slice(u.elStart,u.end)})}return O}function Vs({current:s,opening:m=null,texts:w=[],pageIds:g=null}){let k=w.filter(u=>typeof u?.block?.before=="string"&&typeof u.original=="string").map(u=>({entry:u,was:new Set([u.original,...Array.isArray(u.earlier)?u.earlier.filter($=>typeof $=="string"):[]].filter($=>$!==u.block.before))})).filter(({was:u})=>u.size>0),O=u=>Hn({current:s,opening:m,ids:!1,pageIds:g,texts:u.map(({entry:{key:$,block:j}})=>({key:$,block:j,parts:[{keep:!0,html:j.before}]}))}).texts,I=O(k),a=new Set(I.filter(u=>u.reason==="overlap").map(u=>u.key)),p=[...I.filter(u=>!a.has(u.key)),...k.filter(({entry:u})=>a.has(u.key)).flatMap(u=>O([u]))],h=new Map(k.map(({entry:u,was:$})=>[u.key,$]));return p.filter(u=>u.status==="merged"&&h.get(u.key)?.has(u.html)).map(({key:u,html:$})=>({key:u,theirs:$}))}export{fn as a,Hn as b,Rs as c,Ds as d,Vs as e};
|
package/dist/chunk-TX6JH7TR.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import o from"node:path";import{reportsDirectory as t}from"../browser/shared/paths.mjs";import{readWritingPreferences as i,saysAnything as a}from"../browser/shared/writing-preferences.mjs";var e=r=>o.resolve(r);async function f(){let{file:r,text:n,made:s}=await i(t);return[`\u5DE5\u4F5C\u533A\uFF1A${o.resolve(t)}`,a(n)?`\u5199\u4F5C\u504F\u597D\uFF1A\u5148\u8BFB\u5B83\uFF0C\u7167\u5B83\u5199\uFF08${e(r)}${s?"\uFF0C\u8FD9\u6B21\u6309\u9ED8\u8BA4\u7684\u5199\u4F5C\u504F\u597D\u65B0\u5EFA":""}\uFF09`:`\u5199\u4F5C\u504F\u597D\uFF1A\u7A7A\uFF08${e(r)}\uFF09`]}export{e as a,f as b};
|
package/dist/chunk-UNUEWH4S.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as E,b as F,c as H}from"./chunk-G7TOXONE.mjs";import{b as L,c as O,d as b,e as D}from"./chunk-W63L7367.mjs";import{existsSync as K}from"node:fs";var Q=120;function R(n,h){let r=({packages:s,problems:l})=>new Map([...s,...l].map(([e,{stamp:m}])=>[e,m])),[o,p]=[r(n),r(h)];return[...new Set([...o.keys(),...p.keys()])].filter(s=>o.get(s)!==p.get(s)).sort()}function v({root:n,tell:h,delay:r=Q,quiet:o=H,hold:p=E,limit:s=F,now:l=Date.now}){let e=null,m=0,f=null,c=new Map;b(n);let I=i=>{e&&m<=l()+i||(clearTimeout(e),m=l()+i,e=setTimeout(y,i),e.unref?.())};function y({settled:i=!1}={}){e=null;let u=b(n),a=O(n,u.settings),M=l();a.stamp!==f?.stamp&&(f={stamp:a.stamp,at:M});let T=M-f.at;if(T<o&&!i)return I(o-T);let d=new Map(a.packages),g=new Map(a.problems),k=1/0;for(let[t,S]of u.packages){if(!(!a.settings.disabled.includes(t)&&(g.has(t)||!d.has(t)&&K(S.folder)))){c.delete(t);continue}c.has(t)||c.set(t,f.at);let x=Math.min(p-T,s-(M-c.get(t)));if(x<=0){c.delete(t);continue}d.set(t,S),g.delete(t),k=Math.min(k,x)}let{settings:w}=a,C=L({packages:d,problems:g,settings:w});if(C!==u.stamp){let t={packages:d,problems:g,settings:w,stamp:C};D(n,t),h(t,R(u,t))}k!==1/0&&I(k)}return{changed:()=>I(r),taken(){clearTimeout(e),y({settled:!0})},close(){clearTimeout(e),e=null}}}export{Q as a,v as b};
|
package/dist/chunk-V4CPWKMZ.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{b as p,d as m,e as u,f,g as d}from"./chunk-XINNG4F2.mjs";import{j as n}from"./chunk-NSKUTQ5J.mjs";import{k as i,s as a,v as c}from"./chunk-QMQUXTU4.mjs";import{reportsDirectory as g}from"../browser/shared/paths.mjs";import{documentDirectory as $,documentFiles as y}from"../browser/shared/workspace.mjs";var k=()=>`No documents in ${g} yet: gallery new <slug> "<title>" makes one.`;async function A(w){let{slugs:e,options:h}=await n({options:["--allow-failures"],argv:w,noneIsAll:!0});e.length===0&&(console.error(k()),process.exit(1)),await p(e),await f(e),await d(e);let{reports:r,failures:t}=await i(e,{prepare:m()}),s=r.filter(o=>!t.has(o.slug));for(let o of s)console.log(`OK ${o.slug}`);for(let o of e)y($(o,g)).both&&console.log(`note ${o}: both doc.html and report.html: report.html is not read`);a(r),u(r);let l=s.length+t.size;console.log(`Checked ${l} document${l===1?"":"s"}: ${s.length} passed, ${t.size} failed.`),await c(t,{allow:h.has("--allow-failures")})}export{k as a,A as b};
|
package/dist/chunk-VACRB2NE.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as m,b as G,c as J}from"./chunk-HYMEEXKN.mjs";import w from"node:fs";import k from"node:path";import je from"node:zlib";import{escapeAttribute as I}from"../browser/shared/escape.mjs";import{componentOf as M,instancesOf as Ee,partOf as q}from"../browser/shared/components/index.mjs";import{ICON_COLOR_VALUES as Y,TAB_ICON as Q,glyphOf as ee,iconKind as j,iconUrl as te,iconValueOf as P,tabIconValue as Ce}from"../browser/shared/emoji/icon-value.mjs";import{mediaTypeOf as se,mediaUrl as De}from"../browser/shared/media.mjs";import{emojiDataDirectory as Re,reportsDirectory as oe}from"../browser/shared/paths.mjs";import{slugPattern as Te}from"../browser/shared/reports.mjs";import{documentDirectory as ne}from"../browser/shared/workspace.mjs";var N=Re,X=String.fromCodePoint(65039),Z=null,B=null;function Me(){return Z??={positions:JSON.parse(w.readFileSync(k.join(N,"positions.json"),"utf8")),index:JSON.parse(w.readFileSync(k.join(N,"twemoji-index.json"),"utf8")),svg:je.gunzipSync(w.readFileSync(k.join(N,"twemoji-svg.bin")))},Z}function re(e){let{positions:t,index:s,svg:n}=Me(),o=[e,e.replaceAll(X,""),`${e}${X}`].find(i=>t[i]),r=o&&s[t[o][0]];return r?n.subarray(r[0],r[0]+r[1]):null}function ie(e){let t=re(e);return t?`data:image/svg+xml;base64,${t.toString("base64")}`:null}function es(e){return E(""),[...B.keys()].filter(t=>t.startsWith(`${e}/`)).map(t=>t.slice(e.length+1))}function E(e,t="currentColor"){B??=new Map(JSON.parse(w.readFileSync(k.join(N,"icons.json"),"utf8")).icons.flatMap(([,o,r,i,a])=>[[`mingcute/${o}`,i],[`tabler/${r}`,a]].filter(([,c])=>c)));let s=ee(e),n=s&&B.get(`${s.set}/${s.name}`);return n?n.split("#COLOR").join(t).replace("<svg ",'<svg aria-hidden="true" '):null}function Ie(e){let[t,s]=Y[ee(e)?.color]??Y.gray,n=E(e);return n&&n.replace(/<svg\b[^>]*>/,o=>`${o.replace(/ aria-hidden="true"/,"").replace(/^<svg /,'<svg xmlns="http://www.w3.org/2000/svg" ').replace(/ xmlns="http:\/\/www\.w3\.org\/2000\/svg"(?=.* xmlns=)/,"")}<style>svg{color:${t}}@media (prefers-color-scheme:dark){svg{color:${s}}}</style>`)}function Be({value:e,slug:t=null,tab:s=!1,reportsDirectory:n=oe}){let o=j(e);if(o==="emoji"){let i=re(e);return i&&{type:"image/svg+xml",body:i}}if(o==="glyph"){let i=s?Ie(e):E(e,"#000");return i&&{type:"image/svg+xml",body:Buffer.from(i)}}if(o!=="image"||!t||!Te.test(t))return null;let r=k.join(ne(t,n),e);return w.existsSync(r)?{type:se(e),body:w.readFileSync(r)}:null}var ae=/(<div\b[^>]*\bclass="doc-icon"[^>]*>)([\s\S]*?)(<\/div>)/g;function ts(e,{slug:t,mode:s="export",reportsDirectory:n=oe}){return He(Ae(e,{mode:s}).replace(ae,(o,r,i,a)=>{let c=P(o),l=j(c);if(!l)return o;let f=null;if(l==="emoji"){let d=ie(c);f=d&&`<img alt="${I(c)}" src="${d}">`}else if(l==="glyph")f=E(c);else if(s==="preview")f=`<img src="${De("asset",t,c)}" alt="">`;else{let d=k.join(ne(t,n),c),p=w.existsSync(d)?w.readFileSync(d):null;f=p&&`<img src="data:${se(c)};base64,${p.toString("base64")}" alt="">`}let u=s==="preview"?r.replace(/>$/,` data-ge-icon="${I(c)}">`):r;return f?`${u}${f}${a}`:`${u}${i}${a}`}),ze(_e(e),{slug:t,mode:s,reportsDirectory:n}))}var ce=e=>[...e.matchAll(ae)].flatMap(t=>{let s=j(P(t[0]))==="image"?/<img\b[^>]*\bsrc="/.exec(t[2]):null;return s?[t.index+t[1].length+s.index]:[]}),Pe=/<button\b[^>]*\bdata-tab-icon="([^"]*)"[^>]*>/g;function Ae(e,{mode:t="export"}={}){return e.replace(Pe,(s,n)=>{if(j(n)!=="emoji"||s.includes(Q))return s;let o=t==="preview"?te(n):ie(n);if(!o)return s;let r=`${Q}: ${Ce(o)}`;return/\sstyle="/.test(s)?s.replace(/\sstyle="([^"]*)"/,(i,a)=>` style="${a.replace(/;?\s*$/,"; ")}${r}"`):s.replace(/>$/,` style="${r}">`)})}function Ue(e){let t=q(e,M("page").header)[0];return{all:Ee(e,M("icon")),own:t?q(t,M("icon").match):[]}}function _e(e){let[t]=Ue(m(e)).own;return t?P(G(e,t)):null}function ze(e,{slug:t,mode:s,reportsDirectory:n}){if(!e)return null;if(s==="preview")return te(e,t,{tab:!0});let o=Be({value:e,slug:t,tab:!0,reportsDirectory:n});return o&&`data:${o.type};base64,${Buffer.from(o.body).toString("base64")}`}var He=(e,t)=>t&&/<\/head>/i.test(e)&&!e.includes("data-doc-tab-icon")?e.replace(/<\/head>/i,()=>` <link rel="icon" href="${I(t)}" data-doc-tab-icon>
|
|
3
|
-
</head>`):e;import Ze from"node:fs";import et from"node:path";import{reportsDirectory as tt}from"../browser/shared/paths.mjs";import{assetFile as st,assetProblem as ot,embedFile as nt}from"../browser/shared/media.mjs";import{attr as le,hasClass as rt,walk as it}from"../browser/shared/html-tree.mjs";import fe from"node:fs";import We from"node:path";import{attr as Ve,hasClass as Ke,walk as Ge}from"../browser/shared/html-tree.mjs";import{MEDIA_ROUTES as Je,mediaTypeOf as qe,mediaUrl as Ye}from"../browser/shared/media.mjs";import{documentDirectory as Qe}from"../browser/shared/workspace.mjs";function x(e,t,s){let n=null;return Ge(e,o=>{!n&&o.tagName===t&&Ke(o,s)&&(n=o)}),n}function A(e,t){let s=We.join(e,t);return fe.statSync(s,{throwIfNoEntry:!1})?.isFile()?`data:${qe(t)};base64,${fe.readFileSync(s).toString("base64")}`:null}function Xe(e,{attribute:t,route:s,slug:n,mode:o,reportsDirectory:r}){if(!Je[s](e))return null;if(o==="preview")return`${t}="${Ye(s,n,e)}" data-ge-${t}="${e}"`;let i=A(Qe(n,r),e);return i&&`${t}="${i}"`}function S(e,t,{attribute:s,route:n,slug:o,mode:r,reportsDirectory:i}){let a=t.map(f=>({place:f.sourceCodeLocation?.attrs?.[s],value:Ve(f,s)})).filter(({place:f})=>f).sort((f,u)=>f.place.startOffset-u.place.startOffset),c=[],l=0;for(let{place:f,value:u}of a){let d=Xe(u,{attribute:s,route:n,slug:o,mode:r,reportsDirectory:i});d===null||f.startOffset<l||(c.push(e.slice(l,f.startOffset),d),l=f.endOffset)}return c.push(e.slice(l)),c.join("")}function U(e){let t=[];return it(e,s=>{let n=s.tagName==="figure"&&rt(s,"doc-embed")?x(s,"iframe","doc-embed-frame"):null;n&&t.push(n)}),t}function gs(e,{slug:t,mode:s="export",reportsDirectory:n=tt}){return e.includes("doc-embed")?S(e,U(m(e)),{attribute:"src",route:"embed",slug:t,mode:s,reportsDirectory:n}):e}var de=(e,t=m(e))=>U(t).map(s=>s.sourceCodeLocation.startOffset);function $s({html:e,directory:t,tree:s=m(e)}){let n=[];for(let o of U(s)){let r=`line ${o.sourceCodeLocation.startLine}`,i=le(o,"src")??"",a=le(o,"sandbox"),c=/^https:\/\/[^\s"]+$/.test(i),l=!c&&!/^[a-z][a-z0-9+.-]*:/i.test(i)&&!st(i)?ot(i):null;l?n.push(`${r}: an embed's frame (${i.slice(0,80)}): ${l} (an HTML or PDF file; or a web page, https://\u2026)`):!c&&!nt(i)?n.push(`${r}: an embed's frame (${i.slice(0,80)}) shows a web page (https://\u2026, never http) or an HTML or PDF file of the document's folder (assets/<file>)`):!c&&!Ze.existsSync(et.join(t,i))?n.push(`${r}: the embed's file ${i} is not in the document's folder`):(c||/\.html?$/i.test(i))&&a===void 0?n.push(`${r}: an embed's frame (${i.slice(0,80)}) is sandboxed: sandbox="allow-scripts allow-popups \u2026"`):!c&&/\.html?$/i.test(i)&&/\ballow-same-origin\b/.test(a)?n.push(`${r}: an embedded HTML file (${i}) keeps its own origin: its sandbox has no allow-same-origin`):!c&&/\.pdf$/i.test(i)&&a!==void 0&&n.push(`${r}: an embedded PDF (${i}) is sandboxed, and a sandboxed frame shows no PDF: take its sandbox attribute off`)}return[...new Set(n)]}import at from"node:fs";import ct from"node:path";import{reportsDirectory as ft}from"../browser/shared/paths.mjs";import{assetFile as lt,assetProblem as dt}from"../browser/shared/media.mjs";import{attr as ue,hasClass as ut,walk as pt}from"../browser/shared/html-tree.mjs";function C(e,t=m(e)){let s=[];return pt(t,n=>{n.tagName==="figure"&&ut(n,"doc-file")&&s.push({node:n,link:x(n,"a","doc-file-link")})}),s}function Fs(e,{slug:t,mode:s="export",reportsDirectory:n=ft}){if(!e.includes("doc-file"))return e;let o=C(e).flatMap(({link:r})=>r?[r]:[]);return S(e,o,{attribute:"href",route:"file",slug:t,mode:s,reportsDirectory:n})}function Ls({html:e,directory:t,tree:s=m(e)}){let n=[];for(let{link:o}of C(e,s)){if(!o)continue;let r=`line ${o.sourceCodeLocation?.startLine}`,i=ue(o,"href")??"";lt(i)?at.existsSync(ct.join(t,i))||n.push(`${r}: the file block's file ${i} is not in the document's folder`):n.push(`${r}: a file block's file (${i.slice(0,80)}): ${dt(i)} (<a class="doc-file-link" href="assets/<file>" download="<name>">)`),ue(o,"download")||n.push(`${r}: a file block's link (${i.slice(0,80)}) says the name to save it as: download="<name>"`)}return[...new Set(n)]}import mt from"node:fs";import ht from"node:path";import{reportsDirectory as gt}from"../browser/shared/paths.mjs";import{assetProblem as pe,imageFile as me}from"../browser/shared/media.mjs";import{attr as _,hasClass as $t,walk as z}from"../browser/shared/html-tree.mjs";var bt={"doc-image":"image","doc-bookmark":"bookmark"},wt={image:"an image's picture",bookmark:"a bookmark's icon or cover"},yt=/doc-(?:image|bookmark|link-mention-icon)/;function he(e){let t=[];return z(e,s=>{let n=s.tagName==="figure"&&(_(s,"class")??"").split(/\s+/).map(o=>bt[o]).find(Boolean);n&&t.push({node:s,kind:n})}),t}function D(e,t=m(e)){let s=new Map,n=(o,r,i)=>{let a=o.sourceCodeLocation;a&&!s.has(a.startOffset)&&s.set(a.startOffset,{at:a.startOffset,line:a.startLine,node:o,what:r,kind:i,mention:i==="mention"})};for(let{node:o,kind:r}of he(t))z(o,i=>i.tagName==="img"&&n(i,wt[r],r));return z(t,o=>o.tagName==="img"&&$t(o,"doc-link-mention-icon")&&n(o,"a link's icon","mention")),[...s.values()].sort((o,r)=>o.at-r.at)}function Is(e,{slug:t,mode:s="export",reportsDirectory:n=gt}){return yt.test(e)?S(e,D(e).map(({node:o})=>o),{attribute:"src",route:"asset",slug:t,mode:s,reportsDirectory:n}):e}function Bs({html:e,directory:t,tree:s=m(e)}){let n=[];for(let{line:o,node:r,what:i,mention:a}of D(e,s)){let c=_(r,"src");a&&!me(c)?n.push(`line ${o}: a link's icon (${(c??"").slice(0,80)}): ${pe(c,{picture:!0})}; or write an empty <span class="doc-link-mention-icon"></span>`):c===void 0?n.push(`line ${o}: ${i} has no src: <img src="assets/<file>" alt="\u2026">`):me(c)?mt.existsSync(ht.join(t,c))||n.push(`line ${o}: ${i} ${c} is not in the document's folder`):n.push(`line ${o}: ${i} (${c.slice(0,80)}): ${pe(c,{picture:!0})}`)}for(let{node:o,kind:r}of he(s)){let i=r==="bookmark"?x(o,"a","doc-bookmark-card"):null,a=i&&_(i,"href");i&&!/^https?:\/\/[^\s"]+$/.test(a??"")&&n.push(`line ${i.sourceCodeLocation?.startLine}: a bookmark's link (${(a??"").slice(0,80)}) is a web address: <a class="doc-bookmark-card" href="https://\u2026">`)}return[...new Set(n)]}import Se from"node:fs";import Oe from"node:path";import{escapeAttribute as F}from"../browser/shared/escape.mjs";import{attr as O,hasClass as kt,walk as xt}from"../browser/shared/html-tree.mjs";import{cssReferences as ge}from"../browser/shared/css-references.mjs";import{assetFile as St,assetProblem as Ot,imageFile as vt,mediaUrl as Ft,referencedFile as L}from"../browser/shared/media.mjs";import{reportsDirectory as Lt}from"../browser/shared/paths.mjs";import{documentDirectory as Nt}from"../browser/shared/workspace.mjs";var $e=/^\s*(?:\.\/)?assets\//i,be=1e6;function jt(e){let t=[],s=0;for(;s<e.length;){for(;s<e.length&&/[\s,]/.test(e[s]);)s++;if(s>=e.length)break;let n=s;for(;n<e.length&&!/\s/.test(e[n]);)n++;let o=e.slice(s,n),r="";if(o.endsWith(","))o=o.replace(/,+$/,""),s=n;else{let a=n;for(let c=0;a<e.length&&(e[a]!==","||c>0);a++)e[a]==="("?c++:e[a]===")"&&c--;r=e.slice(n,a).trim(),s=a+1}let i=r.split(/\s+/).find(a=>/^\d*\.?\d+[wx]$/i.test(a));t.push({url:o,descriptor:r,size:i?parseFloat(i):1,wide:/w$/i.test(i??"")})}return t}function Et(e){let t=e.filter(s=>s.wide);return(t.length>0?t:e).reduce((s,n)=>!s||n.size>s.size?n:s,null)}var Ct=new Set(["body","table","thead","tbody","tfoot","tr","td","th"]);function W(e,t,s=n=>$e.test(n)){let n=[],o=r=>{s(r.value,r.node)&&n.push({...r,value:r.value.trim(),written:r.css?.written})};return xt(t,r=>{let i=r.sourceCodeLocation;if(i){for(let{name:a,value:c,prefix:l}of r.attrs){let f=l?`${l}:${a}`:a,u=i.attrs?.[f],d={node:r,how:a,key:f,place:u,line:u?.startLine??i.startLine};if(a==="src"||a==="href"||a==="poster"||a==="data"&&r.tagName==="object"||a==="background"&&Ct.has(r.tagName))o({...d,value:c});else if(a==="srcset"){let p=jt(c),y=Et(p.filter(b=>$e.test(b.url)));p.forEach((b,h)=>o({...d,value:b.url,candidates:p,index:h,largest:b===y}))}else if(a==="style")for(let p of ge(c))o({...d,value:p.value,css:p})}if(r.tagName==="style")for(let a of r.childNodes){if(a.nodeName!=="#text"||!a.sourceCodeLocation)continue;let{startOffset:c,endOffset:l}=a.sourceCodeLocation;for(let f of ge(e.slice(c,l)))o({node:r,how:"css",value:f.value,line:J(e,c+f.index),css:{...f,offset:c}})}}}),n}function ve(e,t){let s=new Map;for(let{at:n,kind:o}of D(e,t))s.set(n,{attribute:"src",owner:"block",icon:o!=="image"});for(let{link:n}of C(e,t))n&&s.set(n.sourceCodeLocation.startOffset,{attribute:"href",owner:"block"});for(let n of de(e,t))s.set(n,{attribute:"src",owner:"block"});for(let n of ce(e))s.set(n,{attribute:"src",owner:"icon"});return s}var Fe=(e,t)=>{let s=e.get(t.node.sourceCodeLocation.startOffset);return s?.attribute===t.how?s:null},Dt=new Set(["img","input","video","audio","source","track"]),we="an export holds no stylesheet of the folder (the addresses in one are read from its own place): put its rules in the page's <style>",ye=e=>(O(e,"rel")??"").toLowerCase().split(/\s+/),H=/\.html?$/i,Rt={html:'src="assets/<file>.html" sandbox="allow-scripts"',pdf:'src="assets/<file>.pdf"'},V=e=>`<figure class="doc-embed doc-embed--file"><iframe class="doc-embed-frame" ${Rt[e]}></iframe><figcaption></figcaption></figure>`,ke=`its frame with no sandbox (a sandboxed one shows no PDF): ${V("pdf")}`,xe='show a picture with <img src="assets/<file>">, a file to save with a link, <a href="assets/<file>" download="<name>">';function K({node:e,how:t,css:s,value:n}){let o=e.tagName;if(t==="style"||t==="css")return s.kind==="import"?{not:we}:{use:"shown"};if(t==="srcset"&&(o==="img"||o==="source")||t==="poster"&&o==="video"||t==="src"&&Dt.has(o)||t==="background")return{use:"shown"};if(t==="src"&&o==="iframe"){let r=L(n)??"";return H.test(r)?{use:"frame"}:/\.pdf$/i.test(r)?{not:`a PDF shows in an embed block alone (the kit hands its file to the browser's PDF viewer, in the preview and in an export): make it one, ${ke}`}:{not:`a frame shows a page of the folder (an HTML file), not this file, which the preview would hand out for saving: ${xe}`}}if(t==="href"&&(o==="a"||o==="area"))return{use:"link"};if(t==="href"&&(o==="image"||o==="link"&&ye(e).some(r=>r.endsWith("icon"))))return{use:"shown"};if(o==="object"||o==="embed"){let r=L(n)??"";return{not:`an export's policy loads no plugin content (<object>, <embed>): ${/\.pdf$/i.test(r)?`show a PDF in an embed block, ${ke}`:H.test(r)?`show a page in an embed block, ${V("html")}`:xe}`}}return o==="script"?{not:"an export runs the page's own scripts alone: put the code in the page's <script>"}:o==="link"&&ye(e).includes("stylesheet")?{not:we}:{not:"an export holds a file of the folder as a picture, a font, a video or audio, a link or a frame, not there"}}var R=e=>e.startsWith("assets/")&&St(e),Tt=e=>Ot(e)??`the folder is assets/, in lowercase: write it so (assets/${e.slice(7)})`,Le=(e,t,s)=>t==="link"&&H.test(s)&&O(e.node,"download")===void 0,Mt=(e,t)=>e==="frame"?"embed":e==="shown"&&vt(t)?"asset":"file",It=(e,t)=>!!Se.statSync(Oe.join(e,t),{throwIfNoEntry:!1})?.isFile(),v=({node:e,how:t,value:s,written:n})=>({srcset:`<${e.tagName} srcset="\u2026 ${s} \u2026">`,style:`${n} in the style of <${e.tagName}>`,css:`${n} in <style>`})[t]??`<${e.tagName} ${t}="${s}">`,Bt=e=>{for(let t=e.parentNode;t;t=t.parentNode)if(t.tagName&&kt(t,"doc-icon"))return!0;return!1},Pt=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`:`${e[0]}`;function At(e,t){let s=new Map;for(let{file:i,line:a,owned:c}of e){let l=s.get(i)??s.set(i,{lines:[],owned:!1}).get(i);c?l.owned=!0:l.lines.push(a)}let n=0,o=[];for(let[i,{lines:a,owned:c}]of s){let l=c?a.length:a.length-1;if(l<1)continue;let f=l*Math.ceil(Se.statSync(Oe.join(t,i)).size/3)*4;n+=f;let u=a.length===1?"once":a.length===2?"twice":`${a.length} times`;o.push({bytes:f,said:`${i} ${u}${c?" besides a media block's or the icon's":""} (line${new Set(a).size>1?"s":""} ${Pt([...new Set(a)])})`})}if(n<=be)return[];let r=o.sort((i,a)=>a.bytes-i.bytes).map(({said:i})=>i).join(", ");return[`files embedded more than once make an export ${n.toLocaleString("en-US")} bytes bigger, over the ${be.toLocaleString("en-US")} bytes the copies outside the media blocks may add: ${r}; show each fewer times (a picture, a link or a frame holds a copy of its own each time it is written), or, for a CSS background (url() in a <style> or a style attribute), name it once in the page's <style> (--picture: url(assets/<file>)) and write var(--picture) where it shows`]}function Ne({html:e,directory:t,tree:s}){let n=ve(e,s),o=[],r=[],i=[];for(let a of W(e,s)){let{line:c}=a,l=Fe(n,a),f=L(a.value),u=f!==null&&It(t,f);if(u&&!R(f)&&i.push({file:f,line:c}),l?.owner==="block"){u&&R(f)&&r.push({file:f,line:c,owned:!0,icon:!!l.icon});continue}if(u||o.push(l?`line ${c}: the icon's image ${a.value} is not in the document's folder`:`line ${c}: ${v(a)} names a file that is not in the document's folder`),l){u&&r.push({file:f,line:c,owned:!0,icon:!0});continue}let{use:d,not:p}=K(a);p&&o.push(`line ${c}: ${v(a)}: ${p}`),!(!d||!u)&&(R(f)?Le(a,d,f)?o.push(`line ${c}: ${v(a)} opens an HTML file, which an export cannot (a browser opens no page from a data: address): show it in an embed block, ${V("html")}, or give the link download="<name>" to hand it out as a file`):a.node.tagName==="img"&&a.how==="src"&&Bt(a.node)?o.push(`line ${c}: ${v(a)} is in an icon (.doc-icon) written as an icon is not read (its picker, the browser tab's icon): write it <div class="doc-icon"><img src="assets/<file>" alt=""></div>, in double quotes and with no other class`):(a.how!=="srcset"||a.largest)&&r.push({file:f,line:c}):o.push(`line ${c}: ${v(a)}: ${Tt(f)}`))}return{failures:o,embedded:r,unserved:i}}function Zs({html:e,directory:t,tree:s=m(e)}){let{failures:n,embedded:o}=Ne({html:e,directory:t,tree:s});return[...new Set([...n,...At(o,t)])]}function eo({html:e,directory:t,tree:s=m(e)}){let{embedded:n,unserved:o}=Ne({html:e,directory:t,tree:s});return{embedded:n.map(({file:r,line:i,icon:a=!1})=>({file:r,line:i,icon:a})),unserved:o}}function Ut(e,{slug:t,mode:s,directory:n}){let{use:o}=K(e),r=L(e.value);if(!o||!r||!R(r)||Le(e,o,r))return null;let i=/#.*$/.exec(e.value)?.[0]??"";if(s==="preview")return`${Ft(Mt(o,r),t,r)}${i}`;let a=A(n,r);return a&&`${a}${i}`}function _t(e,t,{mode:s,shown:n}){let[o]=t,{node:r,how:i,key:a}=o,c=(h,g="")=>({start:e.startOffset,end:e.endOffset,text:`${a}="${F(h)}"${g}`}),l=s==="preview"?` data-ge-${i}="${F(O(r,i)??"")}"`:"",u=(s==="preview"?[`data-ge-${i}`,`data-rs-${i}`].map(h=>r.sourceCodeLocation.attrs?.[h]).filter(Boolean):[]).map(h=>({start:h.startOffset,end:h.endOffset,text:""}));if(i==="srcset"){if(s==="export"){let g=t.find(T=>T.largest),$=g&&n(g);return $?[c(`${$} ${g.candidates[g.index].descriptor}`.trim())]:[]}let h=new Map(t.map(g=>[g.index,n(g)]));return[...h.values()].some(Boolean)?[c(o.candidates.map((g,$)=>[h.get($)??g.url,g.descriptor].filter(Boolean).join(" ")).join(", "),l),...u]:[]}if(i==="style"){let h=O(r,"style"),g=t.map($=>({...$.css,address:n($)})).filter($=>$.address).sort(($,T)=>T.start-$.start);for(let $ of g)h=`${h.slice(0,$.start)}${$.address}${h.slice($.end)}`;return g.length>0?[c(h)]:[]}let d=n(o);if(!d)return[];if(s==="preview"||K(o).use!=="link")return[c(d,l),...u];let p=L(o.value).slice(7),y=O(r,"download");if(y===void 0)return[c(d,` download="${F(p)}"`)];let b=r.sourceCodeLocation.attrs?.download;return[c(d),...y===""&&b?[{start:b.startOffset,end:b.endOffset,text:`download="${F(p)}"`}]:[]]}function zt(e,t){let s=[],n=0;for(let{start:o,end:r,text:i}of[...t].sort((a,c)=>a.start-c.start))o<n||(s.push(e.slice(n,o),i),n=r);return s.push(e.slice(n)),s.join("")}var to=(e,t,s=m(e))=>W(e,s,t);function so(e,t){let s=[],n=new Map;for(let o of e){let r=t(o);typeof r=="string"&&(o.how==="css"?s.push({start:o.css.offset+o.css.start,end:o.css.offset+o.css.end,text:r}):o.place&&n.set(o.place,[...n.get(o.place)??[],{...o,address:r}]))}for(let[o,r]of n){let[{node:i,how:a,key:c,candidates:l}]=r,f=r[0].address;if(a==="srcset"){let u=new Map(r.map(d=>[d.index,d.address]));f=l.map((d,p)=>[u.get(p)??d.url,d.descriptor].filter(Boolean).join(" ")).join(", ")}else if(a==="style"){f=O(i,"style");for(let{css:u,address:d}of[...r].sort((p,y)=>y.css.start-p.css.start))f=`${f.slice(0,u.start)}${d}${f.slice(u.end)}`}s.push({start:o.startOffset,end:o.endOffset,text:`${c}="${F(f)}"`})}return s}function oo(e,{slug:t,mode:s="export",reportsDirectory:n=Lt}){if(!/assets\//i.test(e.replace(/\sdata-ge-(?:src|href|icon)="[^"]*"/g,"")))return e;let o=m(e),r=ve(e,o),i=Nt(t,n),a=f=>Ut(f,{slug:t,mode:s,directory:i}),c=[],l=new Map;for(let f of W(e,o))if(!Fe(r,f))if(f.how==="css"){let u=a(f),d=f.css.offset;u&&c.push({start:d+f.css.start,end:d+f.css.end,text:u})}else f.place&&l.set(f.place,[...l.get(f.place)??[],f]);for(let[f,u]of l)c.push(..._t(f,u,{mode:s,shown:a}));return zt(e,c)}export{ie as a,es as b,E as c,Be as d,ts as e,Ue as f,_e as g,gs as h,$s as i,Fs as j,Ls as k,Is as l,Bs as m,Zs as n,eo as o,zt as p,to as q,so as r,oo as s};
|
package/dist/chunk-W63L7367.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as P,c as C,e as at}from"./chunk-A55HN5OK.mjs";at();import{isUtf8 as ct}from"node:buffer";import{createHash as lt}from"node:crypto";import{lstatSync as pt,readFileSync as A,realpathSync as F,statSync as mt}from"node:fs";import dt from"node:fs/promises";import y from"node:path";import{isInstance as ft,parseCompound as ut,parsePart as gt,parseSelector as ht,partOf as yt}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as B,NO_TEXT as bt,PACKAGE_ID as J,PACKAGE_MARK as wt,instanceMatch as kt,refusedInCopy as Et,settingState as Ot}from"../browser/shared/components/installed.mjs";import{writeAtomic as St}from"../browser/shared/files.mjs";import{attr as At,walk as vt}from"../browser/shared/html-tree.mjs";import{inLanguage as $t,refusal as Z,said as o,saying as xt,told as Nt}from"../browser/shared/i18n/index.mjs";import{DEVICE_NAMES as Tt,PACKAGE_MANIFEST as w,WORKSPACE_MARK as It,findWorkspace as jt,layoutOf as H,markerOf as _t,packageFolders as Mt}from"../browser/shared/workspace.mjs";var z=1,L=new Set(["code","state","sheets","tokens","dialogs","katex-styles","katex","katex-auto-render","math","d3","charts","tables"]),Pt=["id","apiVersion","version","name","description","words","parts","runtime","assets","markdown","schema"],Ct=["at","edit","optional","min","max"],Ft=["generated","attrs"],zt=["text","data","none"],Lt=["parts","text"],Y=["kit.js","style.css","preview.svg"],E="template.html",Rt=[w,E,...Y],v=t=>[...new Set([...Rt,...t])].sort(),Dt=/^(?:[A-Za-z0-9_-][A-Za-z0-9._-]*\/)*[A-Za-z0-9_-][A-Za-z0-9._-]*\.[A-Za-z0-9]+$/,Vt=/^(?:doc-|data-doc-|data-ge-)|^data-block-id$/i,R=256*1024,u=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),f=t=>typeof t=="string"&&t.trim()!=="",$=(t,n)=>t.id<n.id?-1:1,i=t=>{throw Z(t)},g=t=>{let n=lt("sha256");return t(n),n.digest("hex").slice(0,16)};function b(t,n){let s=y.join(t,n);try{let e=pt(s,{throwIfNoEntry:!1});if(!e)return null;if(!e.isSymbolicLink()&&!n.includes("/"))return s;let r=F.native(s);return r.startsWith(F.native(t)+y.sep)?r:null}catch{return null}}function q(t,n){try{let s=b(t,n);return s&&A(s)}catch{return null}}var D=new Map,Kt=2e3;function Wt(t){let{size:n,mtimeMs:s}=mt(t),e=D.get(t);if(e?.size===n&&e.time===s)return e.digest;let r=g(c=>c.update(A(t)));return Date.now()-s>Kt&&D.set(t,{size:n,time:s,digest:r}),r}var x=(t,n)=>g(s=>{for(let e of n){let r=b(t,e),c="none";try{r&&(c=Wt(r))}catch{}s.update(`${e}\0${c}
|
|
3
|
-
`)}}),X=t=>t.toString("utf8").replace(/^\uFEFF/,""),Q=(t,n)=>{t.length>R&&i(o("{0} \u6709 {1} KB\uFF0C\u800C\u6BCF\u4E00\u9875\u90FD\u5E26\u7740\u5B83\uFF0C\u6700\u591A {2} KB",n,Math.ceil(t.length/1024),R/1024))},N=(t,n,s="")=>{for(let e of Object.keys(t))n.includes(e)||i(o("{0} \u4E0D\u662F\u7EC4\u4EF6\u5305\u80FD\u5199\u7684\u5B57\u6BB5",`${s}${e}`))},V=(t,n)=>{for(let s of n)t[s]===void 0&&i(o("\u7F3A\u5C11 {0}",s))},K=(t,n)=>{(!u(t)||!f(t.zh)||!f(t.en)||Object.keys(t).length!==2)&&i(o("{0} \u8981\u5199\u6210 { zh, en } \u4E24\u79CD\u8BED\u8A00\u7684\u6587\u5B57",n))},Gt=t=>t.split(",").map(n=>n.split(">").at(-1).trim()).filter(n=>n!=="*").map(n=>ut(n).tag);function Ut(t,n){let s=`parts.${t}`;u(n)||i(o("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868",s)),N(n,Ct,`${s}.`),f(n.at)||i(o("\u7F3A\u5C11 {0}",`${s}.at`));try{gt(n.at)}catch(e){i(o("{0} \u5199\u9519\u4E86\uFF1A{1}",`${s}.at`,e.message))}zt.includes(n.edit)||i(o("{0} \u7684 edit \u53EA\u80FD\u662F text\u3001data \u6216 none",s)),n.optional!==void 0&&typeof n.optional!="boolean"&&i(o("{0} \u8981\u5199\u6210 true \u6216 false",`${s}.optional`));for(let e of["min","max"])n[e]!==void 0&&!(Number.isInteger(n[e])&&n[e]>=0)&&i(o("{0} \u8981\u5199\u6210\u4E0D\u5C0F\u4E8E 0 \u7684\u6574\u6570",`${s}.${e}`));if(n.min>n.max&&i(o("{0} \u7684 min \u6BD4 max \u5927\uFF0C\u6CA1\u6709\u5B9E\u4F8B\u80FD\u6EE1\u8DB3",s)),n.edit==="text")for(let e of Gt(n.at))bt.has(e)&&i(o("{0} \u4E0D\u80FD\u6309\u6587\u5B57\u7F16\u8F91\uFF1A<{1}> \u4E0D\u662F\u80FD\u6253\u5B57\u7684\u6587\u5B57",s,e))}var Bt=t=>t.split(",").some(n=>n.split(">").every(s=>[":scope","*"].includes(s.trim())));function Jt(t,n){if(t===void 0)return null;u(t)||i(o("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime")),N(t,Ft,"runtime.");let s=`[${B}="${n}"]`,e=(l,p)=>{try{if(!f(l))throw new Error("no selector");ht(l)}catch(m){i(o("{0} \u5199\u9519\u4E86\uFF1A{1}",p,m.message))}return l.split(",").map(m=>m.trim().startsWith(":scope")?m.trim().replace(":scope",s):`${s} ${m.trim()}`).join(", ")},{generated:r=[],attrs:c={}}=t;Array.isArray(r)||i(o("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.generated")),u(c)||i(o("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime.attrs"));for(let l of Object.values(c)){(!Array.isArray(l)||!l.every(f))&&i(o("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.attrs"));for(let p of l)Vt.test(p)&&i(o("{0} \u662F Gallery \u81EA\u5DF1\u7684\u540D\u5B57\uFF0C\u7EC4\u4EF6\u5305\u4E0D\u80FD\u7528",p))}let a=l=>{let p=e(l,"runtime.generated");return Bt(l)&&i(o("{0} \u7684 {1} \u662F\u6574\u4E2A\u5B9E\u4F8B\uFF0C\u800C\u8FD9\u91CC\u53EA\u5199\u5B83\u751F\u6210\u7684\u8282\u70B9","runtime.generated",l)),p};return{generated:r.map(a),attrs:Object.fromEntries(Object.entries(c).map(([l,p])=>[e(l,"runtime.attrs"),p]))}}function Zt(t,n){if(t===void 0)return{kit:[],own:[]};(!Array.isArray(t)||!t.every(f))&&i(o("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","assets"));let s=t.filter(e=>!L.has(e));for(let e of s)Dt.test(e)||i(o("assets \u91CC\u7684 {0} \u65E2\u4E0D\u662F\u5957\u4EF6\u7684\u8D44\u6E90\uFF0C\u4E5F\u4E0D\u662F\u5305\u91CC\u7684\u6587\u4EF6",e)),b(n,e)||i(o("assets \u5199\u4E86 {0}\uFF0C\u5305\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6587\u4EF6",e));return{kit:t.filter(e=>L.has(e)),own:s}}function Ht(t,n,s){let e;try{e=JSON.parse(s)}catch(p){i(o("component.json \u4E0D\u662F JSON\uFF1A{0}",p.message))}u(e)||i(o("component.json \u5199\u7684\u4E0D\u662F\u4E00\u4E2A\u5BF9\u8C61")),J.test(t)||i(o("{0} \u4E0D\u80FD\u505A\u7EC4\u4EF6\u5305\u7684 id\uFF1A\u8303\u56F4\u548C\u540D\u5B57\u90FD\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",t));for(let p of t.split("/"))Tt.has(p)&&i(o("{0} \u4E0D\u80FD\u505A\u7EC4\u4EF6\u5305\u7684 id\uFF1A{1} \u662F Windows \u7559\u7ED9\u8BBE\u5907\u7684\u540D\u5B57",t,p));if(e.id!==t&&i(o("\u6E05\u5355\u7684 id \u662F {0}\uFF0C\u548C\u5B83\u7684\u6587\u4EF6\u5939 {1} \u4E0D\u4E00\u6837",String(e.id),t)),V(e,["apiVersion"]),(!Number.isInteger(e.apiVersion)||e.apiVersion<1)&&i(o("apiVersion \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570")),e.apiVersion!==z)throw Z(o("\u8FD9\u4E2A\u7EC4\u4EF6\u5305\u8981 apiVersion {0}\uFF0C\u8FD9\u4E00\u7248 Gallery \u53EA\u652F\u6301 {1}",e.apiVersion,z),{disabled:!0,version:f(e.version)?e.version:null});N(e,Pt),V(e,["version","name","description","parts"]),f(e.version)||i(o("{0} \u8981\u5199\u6210\u6587\u5B57","version")),K(e.name,"name"),K(e.description,"description"),e.words!==void 0&&typeof e.words!="string"&&i(o("{0} \u8981\u5199\u6210\u6587\u5B57","words")),u(e.parts)||i(o("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","parts"));for(let[p,m]of Object.entries(e.parts))Ut(p,m);let r=Jt(e.runtime,t),{kit:c,own:a}=Zt(e.assets,n);e.markdown!==void 0&&!Lt.includes(e.markdown)&&i(o("markdown \u53EA\u80FD\u662F parts \u6216 text")),e.schema!==void 0&&!(Number.isInteger(e.schema)&&e.schema>=1)&&i(o("schema \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570"));let l=q(n,E);return l&&Q(l,E),{id:t,match:kt(t),parts:e.parts,...r?{runtime:r}:{},...e.schema!==void 0?{schema:e.schema}:{},apiVersion:e.apiVersion,version:e.version,name:e.name,description:e.description,words:e.words??"",assets:c,markdown:e.markdown??"parts",files:[...new Set([...Y.filter(p=>b(n,p)),...a])],template:l&&X(l),folder:n,definition:g(p=>p.update(s)),stamp:x(n,v(a))}}function Yt(t,n){try{let s=q(n,w);return s||i(o("\u8BFB\u4E0D\u51FA component.json")),ct(s)||i(o("{0} \u4E0D\u662F UTF-8 \u7F16\u7801\uFF1A\u8BF7\u5B58\u6210 UTF-8",w)),Q(s,w),Ht(t,n,X(s))}catch(s){let e=xt(s),r=g(c=>c.update(`${x(n,v([]))} ${JSON.stringify(e)}`));return{id:t.toLowerCase(),stamp:r,problem:e,disabled:s.disabled===!0,version:s.version??null}}}var T=()=>jt().root,qt=/^[a-z0-9][a-z0-9-]*(?:\/[a-z0-9][a-z0-9-]*)?$/,W=(t,n)=>[...new Set(Array.isArray(t)?t.filter(s=>typeof s=="string"&&n.test(s)):[])],I=t=>({hidden:W(t?.components?.hidden,qt),disabled:W(t?.components?.disabled,J)}),j=o("gallery.json \u8BFB\u4E0D\u51FA\u6765\uFF1A\u6539\u597D\u8FD9\u4E2A\u6587\u4EF6\u540E\u518D\u8BD5"),Xt=o("gallery.json \u4E0D\u662F Gallery \u7684\u6587\u4EF6");function O(t){if(t===null)return{value:null};let{value:n,ours:s,reads:e}=_t(t);return s?{value:n}:{problem:e?Xt:j}}function Qt(t){try{return O(A(H(t).marker,"utf8"))}catch(n){return n.code==="ENOENT"?O(null):{problem:j}}}var te=["EPERM","EACCES","EBUSY","EROFS"];async function Ee(t,{id:n,hidden:s,disabled:e}){let r=H(t).marker,c=await dt.readFile(r,"utf8").catch(d=>{if(d.code==="ENOENT")return null;i(j)}),{value:a,problem:l}=O(c);l&&i(l);let p=(d,M)=>M===void 0?d:M?[...new Set([...d,n])]:d.filter(it=>it!==n),{hidden:m,disabled:ot}=I(a),rt={...u(a?.components)?a.components:{},hidden:p(m,s),disabled:p(ot,e)};await St(r,`${JSON.stringify({...a??It,components:rt},null,2)}
|
|
4
|
-
`,{expect:c}).catch(d=>{throw te.includes(d.code)&&i(o("gallery.json \u5199\u4E0D\u8FDB\u53BB\uFF1A\u53EF\u80FD\u662F\u53EA\u8BFB\u7684\uFF0C\u6216\u88AB\u522B\u7684\u7A0B\u5E8F\u5360\u7740")),d})||i(o("gallery.json \u521A\u521A\u88AB\u6539\u8FC7\uFF1A\u518D\u8BD5\u4E00\u6B21"))}var ee=t=>({...t,off:!0,disabled:!0,problem:o("\u5728\u8BBE\u7F6E\u91CC\u505C\u7528\u4E86"),stamp:g(n=>n.update(`${t.stamp} off`))}),k=I(null),ne=({packages:t,problems:n,settings:s=k})=>g(e=>{for(let{id:r,stamp:c}of[...t.values(),...n.values()].sort($))e.update(`${r} ${c}
|
|
5
|
-
`);e.update(`hidden ${[...s.hidden].sort().join(" ")}
|
|
6
|
-
`),e.update(`settings ${s.problem?.message??""}
|
|
7
|
-
`)});function se(t,n){let{value:s,problem:e}=Qt(t);return e?{hidden:n.hidden,disabled:n.disabled,problem:e}:I(s)}function oe(t=T(),n=k,{on:s=null}={}){let e=se(t,n),r=new Map,c=new Map;for(let{id:a,folder:l}of Mt(t)){let p=Yt(a,l);(p.problem?c:r).set(p.id,p)}for(let a of r.keys())c.delete(a);for(let a of e.disabled)!r.has(a)||a===s||(c.set(a,ee(r.get(a))),r.delete(a));return{packages:r,problems:c,settings:e,stamp:ne({packages:r,problems:c,settings:e})}}var h=new Map;function Oe(t=T()){let n=y.resolve(t);return h.has(n)||h.set(n,oe(n)),h.get(n)}var Se=(t,n)=>{h.set(y.resolve(t),n)},Ae=(t=T())=>{h.delete(y.resolve(t))},G=(t,n)=>$t(t,()=>Nt(n)),_=t=>({zh:G("zh",t),en:G("en",t)}),ve=({settings:t})=>t.problem?_(t.problem):null,tt=(t,n)=>t.problem?t.disabled?"disabled":"broken":Ot(t.id,n),et=({id:t,match:n,parts:s,runtime:e,schema:r})=>({id:t,match:n,parts:s,...e?{runtime:e}:{},...r!==void 0?{schema:r}:{}}),$e=({packages:t,problems:n})=>[...[...t.values()].map(et),...[...n.values()].map(({id:s,problem:e})=>({id:s,problem:_(e)}))],re=t=>`DocKit.describe(${JSON.stringify(t)});`.replace(/</g,"\\u003c"),S=({id:t,stamp:n},s)=>`/__gallery/components/${t}/${s}?v=${n}`;function ie(t){let n=`${wt}="${t.id}"`,s=e=>t.files.includes(e);return{styles:s("style.css")?[`<link rel="stylesheet" href="${S(t,"style.css")}" ${n}>`]:[],scripts:[`<script ${n}>${re({...et(t),...s("kit.js")?{script:!0}:{}})}</script>`,...s("kit.js")?[`<script src="${S(t,"kit.js")}" ${n}></script>`]:[]]}}var xe=({folder:t},n)=>b(t,n),Ne=({folder:t,files:n})=>x(t,v(n));function U(t,n){let s=C(t,{sourceCodeLocationInfo:!0}).childNodes.filter(r=>r.tagName||r.nodeName==="#text"&&r.value.trim()),[e]=s;return s.length===1&&e.tagName&&ft(e)&&At(e,B)===n&&e.sourceCodeLocation.endTag?e:null}function ae(t,n){let s=U(t,n),e=s&&P(s),r=e&&U(e,n);return r?{markup:e,root:r}:null}function nt({id:t,template:n,parts:s}){if(!n)return{};let e=ae(n,t);if(!e)return{problem:o("template.html \u8981\u662F\u8FD9\u4E2A\u7EC4\u4EF6\u5305\u7684\u4E00\u4E2A\u5B9E\u4F8B\uFF0C\u6709\u81EA\u5DF1\u7684\u7ED3\u675F\u6807\u7B7E\uFF0C\u6B64\u5916\u4EC0\u4E48\u90FD\u6CA1\u6709")};let r=[];if(vt({childNodes:[e.root]},a=>{Et(a.tagName,a.attrs)&&r.push(a.tagName)}),r.length>0)return{problem:o("template.html \u91CC\u7684 <{0}> \u8FDB\u4E0D\u4E86\u65B0\u5EFA\u7684\u5757\uFF1A\u811A\u672C\u3001\u4E8B\u4EF6\u3001\u6837\u5F0F\u548C Gallery \u81EA\u5DF1\u7684\u6807\u8BB0\u90FD\u4E0D\u5199\u5728\u6A21\u677F\u91CC",r[0])};let c=Object.entries(s).find(([,a])=>{let l=yt(e.root,a.at).length;return l<(a.optional?0:a.min??1)||l>(a.max??1/0)});return c?{problem:o("template.html \u7684 {0} \u548C\u6E05\u5355\u5199\u7684\u6570\u76EE\u4E0D\u7B26",c[0])}:{markup:e.markup}}var Te=t=>nt(t).problem??null,st=t=>nt(t).markup??null,Ie=({packages:t,settings:n=k})=>[...t.values()].sort($).map(s=>({id:s.id,version:s.version,name:s.name,description:s.description,words:s.words,definition:s.definition,stamp:s.stamp,template:st(s),preview:s.files.includes("preview.svg")?S(s,"preview.svg"):null,state:tt(s,n),markdown:s.markdown,assets:s.assets,tags:ie(s)})),je=({packages:t,problems:n,settings:s=k})=>[...t.values(),...n.values()].sort($).map(e=>({id:e.id,version:e.version??null,name:e.name??null,description:e.description??null,state:tt(e,s),reason:e.problem&&!e.off?_(e.problem):null,template:!!st(e),hidden:s.hidden.includes(e.id),disabled:s.disabled.includes(e.id)})),_e=({hidden:t,disabled:n})=>`settings ${t.join(",")} ${n.join(",")}`;export{Ee as a,ne as b,oe as c,Oe as d,Se as e,Ae as f,G as g,ve as h,$e as i,re as j,ie as k,xe as l,Ne as m,ae as n,Te as o,st as p,Ie as q,je as r,_e as s};
|
package/dist/chunk-W7CXPCRV.mjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{k as et}from"./chunk-QYKCJ7FG.mjs";import{a as nt}from"./chunk-E7VYDG2X.mjs";import L from"node:fs/promises";import rt from"node:path";import{writeAtomic as it}from"../browser/shared/files.mjs";import{documentFiles as wt}from"../browser/shared/workspace.mjs";var mt=s=>L.access(s).then(()=>!0,()=>!1);async function Ct(s,{create:d,slugOf:l,folderOf:p,fill:P,place:O,under:A="",said:c="\u5BFC\u5165\u81EA {0}",lang:M=null}){let E=[],v=[];async function h(f,F,C){let S=await l(f,C);await d(S,f.title,c.replace("{0}",()=>f.from),{lang:M});let R=p(S),{html:J,json:y}=wt(R),$=await L.readFile(J,"utf8");await it(J,et(await P({source:$,nodes:f.nodes,icon:f.icon,own:f.own,raws:f.raws,lang:f.lang}))),f.files.length&&await L.mkdir(rt.join(R,"assets"),{recursive:!0});for(let{from:N,name:T}of f.files){let x=rt.join(R,"assets",T);await mt(x)||await L.copyFile(N,x)}if(f.icon){let N=JSON.parse(await L.readFile(y,"utf8"));await it(y,`${JSON.stringify({...N,icon:f.icon},null,2)}
|
|
3
|
-
`)}await O(S,F),E.push(S);for(let N of f.children??[])await h(N,S,null);return S}for(let[f,F]of s.entries())v.push(await h(F,A,f));return{made:E,top:v}}import{randomBytes as dt}from"node:crypto";import w from"node:fs/promises";import u from"node:path";import{writeAtomic as _}from"../browser/shared/files.mjs";import{sendJson as W}from"../browser/shared/http.mjs";import{said as D,saying as ht}from"../browser/shared/i18n/index.mjs";import{reportsDirectory as pt}from"../browser/shared/paths.mjs";import{listReportSlugs as yt,slugPattern as g}from"../browser/shared/reports.mjs";import{COMPONENTS_FOLDER as Q,DOCUMENT_FOLDERS as kt,PAGE_SLUG as Ot,documentDirectory as jt,documentFiles as Y,layoutOf as gt,listTrash as vt,packageFolders as St,pageSlug as xt,slugTaken as bt,trashIdPattern as at}from"../browser/shared/workspace.mjs";import{MENTION as Et}from"../browser/shared/components/mention.mjs";import{findIn as Nt,reportLines as Pt,tidyQuery as Ft}from"../browser/shared/search.mjs";import{countWords as $t}from"../browser/shared/words.mjs";var Tt=([s,d,l,...p])=>p.length?D("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}\uFF1B{2} \u7B49 {3} \u6761",s,d,l,p.length+3):l!==void 0?D("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}\uFF1B{2}",s,d,l):d!==void 0?D("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}",s,d):D("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}",s),ot=s=>s==="en"?"en":null;async function H(s,d){for(let l=0;;l++)try{return await w.rename(s,d)}catch(p){if(!["EPERM","EBUSY","EACCES"].includes(p.code))throw p;if(l>=5)break;await new Promise(P=>setTimeout(P,60*(l+1)))}await w.cp(s,d,{recursive:!0,errorOnExist:!0,force:!1}),await w.rm(s,{recursive:!0,force:!0,maxRetries:5})}var At=s=>u.resolve(s);function qt({edits:s,reports:d,reportsDirectory:l=pt,server:p={kind:"dev",version:null,stop:null},components:P=null}){let{trash:O,outline:A}=gt(l),c=(t,n,e)=>[t,{ok:!1,reason:n,...ht(e)}],M=t=>w.readFile(t,"utf8").then(JSON.parse).catch(()=>null),E=t=>jt(t,l),v=t=>Y(E(t)),h=t=>u.join(l,t),f=t=>T(Y(h(t)).html),F=async t=>{let n=await w.readdir(h(t),{withFileTypes:!0});if(t!==Q)return n.map(({name:r})=>r);let e=new Set(St(l).map(({id:r})=>r.split("/")[0]));return n.filter(r=>r.isFile()||kt.includes(r.name)&&!e.has(r.name)).map(({name:r})=>r)},C=async(t,n,e)=>{await w.mkdir(e,{recursive:!0});let r=[];try{for(let i of t)await H(u.join(n,i),u.join(e,i)),r.push(i)}catch(i){for(let a of r)await H(u.join(e,a),u.join(n,a));throw i}},S=async(t,n)=>{if(t!==Q)return H(h(t),n);await C(await F(t),h(t),n),await w.rmdir(h(t)).catch(()=>{})},R=async(t,n)=>t===Q&&!await f(t)&&(await Promise.all((await w.readdir(n)).map(e=>T(u.join(h(t),e))))).every(e=>!e),J=async t=>await M(Y(t).json)??{},y=async t=>{let{title:n=t,description:e="",type:r,instructions:i,icon:a}=await J(E(t));return{slug:t,title:n,description:e,...r?{type:r}:{},...typeof a=="string"&&a?{icon:a}:{},...i===!0?{instructions:!0}:{}}},$=()=>xt(l),N=async(t,n)=>{let e=await J(E(t));await _(v(t).json,`${JSON.stringify({...e,[n]:!0},null,2)}
|
|
4
|
-
`)},T=t=>w.access(t).then(()=>!0,()=>!1),x=async(t,{own:n=null}={})=>{let e=new Set((await B()).map(({slug:r})=>r));e.delete(n);for(let r=1;;r++){let i=r===1?t:`${t}-${r}`;if(!bt(i,l)&&!e.has(i))return i}},z=async(t,n)=>{let e=v(t).html,r=await w.readFile(e,"utf8"),i=nt(r).replace(`data-doc-id="${n}"`,`data-doc-id="${t}"`);i!==r&&await _(e,i)};async function b(){let t=await $(),n=(await yt(l)).filter(o=>o!==t),e=await M(A),r={"":[]},i=new Set,a=o=>{for(let k of e?.children?.[o]??[])!n.includes(k)||i.has(k)||(i.add(k),(r[o]??=[]).push(k),a(k))};a("");for(let o of n)i.has(o)||r[""].push(o);return{version:1,children:r}}function st(t){let n=t?.children;if(!n||typeof n!="object"||Array.isArray(n))return!1;let e=new Set;for(let[r,i]of Object.entries(n)){if(r!==""&&!g.test(r)||!Array.isArray(i))return!1;for(let a of i){if(typeof a!="string"||!g.test(a)||e.has(a)||a===r)return!1;e.add(a)}}return!0}let G=async t=>(await w.mkdir(u.dirname(A),{recursive:!0}),_(A,`${JSON.stringify({version:1,children:t.children},null,2)}
|
|
5
|
-
`));async function U(t,n="",e=1/0){let r=await b();for(let o of Object.values(r.children))o.includes(t)&&o.splice(o.indexOf(t),1);let i=n!==t&&(n===""||Object.values(r.children).some(o=>o.includes(n))),a=r.children[i?n:""]??=[];a.splice(Math.max(0,Math.min(e,a.length)),0,t),await G(r)}async function ct(t){let n=await b();for(let[e,r]of Object.entries(n.children)){let i=r.indexOf(t);if(!(i<0))return r.splice(i,1,...n.children[t]??[]),delete n.children[t],await G(n),{parent:e,index:i}}return{parent:"",index:1/0}}let V=new Map;async function ut(t,n){let e=v(t).html,r=await w.stat(e).catch(()=>null);if(!r)return null;let i=V.get(t);if(i?.at===r.mtimeMs&&(i.titles===null||i.titles===n))return i.lines;let a=(await s.read(t))?.text??"",o=Pt(d.words(a,t));return V.set(t,{at:r.mtimeMs,titles:a.includes(Et)?n:null,lines:o}),o}let X=t=>M(u.join(O,t,"entry.json")),B=()=>vt(l),Z={info:async()=>[200,{ok:!0,version:1,gallery:p.version,token:s.token,commands:[...Object.keys(K)],server:{pid:process.pid,workspace:u.resolve(l),kind:p.kind}}],async outline(){let t=await b(),n=await $(),e=[...Object.values(t.children).flat(),...n?[n]:[]],r=async i=>[i,await y(i)];return[200,{ok:!0,outline:t,instructions:n,reports:Object.fromEntries(await Promise.all(e.map(r))),trash:await B()}]},trash:async()=>[200,{ok:!0,entries:await B()}],async stats(t){let n=t.get("slug")??"",e=g.test(n)?v(n).html:"",[r,i]=g.test(n)?await Promise.all([w.stat(e),s.read(n)]).catch(()=>[]):[];return!r||!i?c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"):[200,{ok:!0,edited:Math.round(r.mtimeMs),words:$t(i.text)}]},components:async()=>[200,{ok:!0,...P.read()}],async source(t){let n=t.get("slug")??"";if(!g.test(n))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let e=u.resolve(v(n).html);return await T(e)?[200,{ok:!0,path:e}]:c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863")},async search(t){let n=Ft(t.get("q")??"");if(!n)return[200,{ok:!0,results:[]}];let{children:e}=await b(),r=[],i=m=>(e[m]??[]).forEach(j=>{r.push(j),i(j)});i("");let a=n.toLowerCase(),o=new Map(await Promise.all(r.map(async m=>[m,await y(m)]))),k=JSON.stringify([...o].map(([m,{title:j}])=>[m,j])),I=(await Promise.all(r.map(async m=>{let j=await ut(m,k);if(!j)return null;let q=String(o.get(m).title).toLowerCase().includes(a),{count:tt,hits:ft}=Nt(j,n);return q||tt?{slug:m,title:q,count:tt,hits:ft}:null}))).filter(Boolean);return I.sort((m,j)=>Number(j.title)-Number(m.title)||j.count-m.count),[200,{ok:!0,results:I.slice(0,50)}]}},K={async outline({outline:t}){return st(t)?(await G(t),[200,{ok:!0,outline:await b()}]):c(400,"outline","\u6587\u6863\u76EE\u5F55\u7684\u7ED3\u6784\u4E0D\u5BF9\uFF1A\u6BCF\u4EFD\u6587\u6863\u53EA\u80FD\u51FA\u73B0\u4E00\u6B21")},async create({title:t,description:n,parent:e="",language:r}){let i=typeof t=="string"&&t.trim()?t.trim():"\u672A\u547D\u540D\u6587\u6863",a=await x("doc");return await d.create(a,i,typeof n=="string"&&n.trim()?n.trim():"\u65B0\u6587\u6863",{lang:ot(r)}),await U(a,typeof e=="string"?e:""),[200,{ok:!0,report:await y(a)}]},async instructions({title:t,description:n,language:e}){let r=await $();if(r)return[200,{ok:!0,report:await y(r)}];let i=await x(Ot),a=(o,k)=>typeof o=="string"&&o.trim()?o.trim().slice(0,200):k;return await d.create(i,a(t,"\u5199\u4F5C\u504F\u597D"),a(n,"Agent \u6BCF\u6B21\u5199\u62A5\u544A\u524D\u90FD\u4F1A\u5148\u8BFB\u7684\u5199\u4F5C\u504F\u597D"),{lang:ot(e),page:!0}),await N(i,"instructions"),[200,{ok:!0,report:await y(i)}]},async components({id:t,hidden:n,disabled:e}){try{return[200,{ok:!0,...await P.write({id:t,hidden:n,disabled:e})}]}catch(r){return c(409,"components",r)}},async duplicate({slug:t,suffix:n}){if(typeof t!="string"||!g.test(t)||!await f(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let e=await x(`${t}-copy`),r=new Set(["",...await F(t)]);await w.cp(h(t),h(e),{recursive:!0,errorOnExist:!0,filter:m=>r.has(u.relative(h(t),m).split(u.sep)[0])}),await z(e,t);let{title:i}=await y(t),a=await s.renameReport(e,`${i}${typeof n=="string"&&n.length>0&&n.length<=20?n:"\uFF08\u526F\u672C\uFF09"}`),o=await b(),[k,I]=Object.entries(o.children).find(([,m])=>m.includes(t))??["",null];return await U(e,k,I?I.indexOf(t)+1:1/0),[200,{ok:!0,report:await y(e),notes:a.notes??[]}]},async rename({slug:t,title:n}){if(typeof t!="string"||!g.test(t))return c(400,"slug","\u6587\u6863\u540D\u4E0D\u5BF9");let e=await s.renameReport(t,n);return e.ok?[200,{ok:!0,report:await y(t),notes:e.notes}]:c({title:400,missing:404}[e.reason]??409,e.reason,e.message??"\u6539\u540D\u6CA1\u6709\u6210\u529F")},async trash({slug:t}){if(typeof t!="string"||!g.test(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");if(t===await $())return c(409,"instructions","\u5199\u4F5C\u504F\u597D\u4E0D\u80FD\u79FB\u5230\u56DE\u6536\u533A");if(!await f(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let{title:n}=await y(t),e=`${Date.now().toString(36)}-${dt(3).toString("hex")}`,r=await b(),{parent:i,index:a}=await ct(t);try{await w.mkdir(u.join(O,e),{recursive:!0}),await S(t,u.join(O,e,"report"))}catch(k){throw await G(r),await w.rm(u.join(O,e),{recursive:!0,force:!0}).catch(()=>{}),k}let o={id:e,slug:t,title:n,at:Date.now(),parent:i,index:Number.isFinite(a)?a:-1};return await _(u.join(O,e,"entry.json"),`${JSON.stringify(o,null,2)}
|
|
6
|
-
`),[200,{ok:!0,entry:o}]},async restore({id:t}){let n=typeof t=="string"&&at.test(t)?await X(t):null;if(!n)return c(404,"missing","\u56DE\u6536\u533A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879");let e=u.join(O,t,"report"),r=await R(n.slug,e),i=r?n.slug:await x(n.slug,{own:n.slug});return r?await C(await w.readdir(e),e,h(i)):await H(e,h(i)),i!==n.slug&&await z(i,n.slug),await w.rm(u.join(O,t),{recursive:!0,force:!0}),await U(i,n.parent,n.index<0?1/0:n.index),[200,{ok:!0,report:await y(i),entry:{...n,slug:i}}]},async destroy({id:t}){return typeof t!="string"||!at.test(t)||!await X(t)?c(404,"missing","\u56DE\u6536\u533A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879"):(await w.rm(u.join(O,t),{recursive:!0,force:!0}),[200,{ok:!0}])},async export({slug:t}){if(typeof t!="string"||!g.test(t)||!await T(E(t)))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let{problems:n=[],file:e,refused:r}=await d.export(t);return r?c(r.reason==="missing"?404:409,r.reason,r.message):n.length?c(422,"check",Tt(n)):[200,{ok:!0,path:At(e)}]}};function lt(t,n,e){if(t.method==="GET"&&Object.hasOwn(Z,e)){let r=t.headers.host??"",i=t.socket.localPort;return r!==`127.0.0.1:${i}`&&r!==`localhost:${i}`?W(n,403,{ok:!1,reason:"host"}):Z[e](new URL(t.url??"/","http://localhost").searchParams).then(([a,o])=>W(n,a,o),a=>W(n,...c(500,"read",a)))}return t.method==="POST"&&e==="stop"?s.respond(async r=>{let i=await s.check(r);return i.error?i.error:p.kind!=="cli"||typeof p.stop!="function"?c(409,"dev","\u8FD9\u662F npm run dev \u7684\u670D\u52A1\u5668\uFF1A\u5728\u8FD0\u884C\u5B83\u7684\u5730\u65B9\u505C\u6B62\u5B83"):(n.once("finish",()=>p.stop()),[200,{ok:!0,pid:process.pid}])})(t,n):t.method==="POST"&&Object.hasOwn(K,e)?s.respond(async r=>{let i=await s.check(r);return i.error?i.error:K[e](i.body&&typeof i.body=="object"?i.body:{})})(t,n):W(n,404,{ok:!1,reason:"unknown"})}return{handle:lt,outline:b,trashEntries:B,place:U,freeSlug:x}}export{Ct as a,qt as b};
|
package/dist/chunk-XINNG4F2.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as L,b as N,c as O,d as T,e as I}from"./chunk-7GHT2UCA.mjs";import{f as k}from"./chunk-QMQUXTU4.mjs";import{k as p}from"./chunk-QYKCJ7FG.mjs";import{b as x,d as S,e as b,f as d,g as v,h as D,i as j}from"./chunk-5FRMCDPY.mjs";import{a as y}from"./chunk-E7VYDG2X.mjs";import f from"node:path";import{editStateDirectory as M,reportsDirectory as h}from"../browser/shared/paths.mjs";import{findPreviewServer as P}from"../browser/shared/preview-server.mjs";import{documentDirectory as A,documentFiles as E,isDocumentSource as B}from"../browser/shared/workspace.mjs";var m=t=>f.resolve(t),G=t=>f.basename(E(f.dirname(t)).json),_={busy:"it kept changing while it was being written (an Agent writing it?); nothing written. Run the export again.",timeout:"the workspace's Gallery server did not answer in 30s; nothing written. Run the export again."};async function F(t,e,n="hand-in"){let a=`127.0.0.1:${t.port}`,o;try{o=await fetch(`http://${a}/__gallery/edit/${n}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${a}`,"X-Gallery-Token":t.token},body:JSON.stringify({slug:e,workspace:h}),signal:AbortSignal.timeout(3e4)})}catch(s){return s.name==="TimeoutError"?{ok:!1,reason:"timeout"}:null}let i=await o.json().catch(()=>null);return typeof i?.ok!="boolean"||["elsewhere","token","host","origin"].includes(i.reason)?null:i}async function te(t){let e=await P({reportsDirectory:h}),n=null,a=[],o=new Map,i=[];for(let s of t){let{html:l,json:c}=E(A(s,h)),r=e?await F(e,s):null;if(r===null&&(n??=I({reportsDirectory:h,stateDirectory:M,finish:p}),r=await n.handIn(s),r.ok&&await n.settleNotes(s)),!r.ok){r.reason!=="missing"&&o.set(s,[`${m(l)} was not handed in: ${_[r.reason]??r.message??r.reason}`]);continue}if(r.repeated?.length){o.set(s,k(r.repeated));continue}i.push(...$(l,r)),r.written&&(r.changes.length&&i.push(...d(l,r.changes,{reread:!1})),r.added&&i.push(...g(l,r.given,r.added)),a.push(m(l))),C(r)&&a.push(m(c))}return{written:a,failures:o,lines:i}}async function ne(t){let e=await P({reportsDirectory:h});if(e){for(let n of t)if(await F(e,n,"settle")===null)return}}var C=({title:t=null,icon:e=null})=>!!(t&&typeof t.from=="string"&&t.from!==t.to||e&&!e.missing),R=10;function g(t,e,n=e?.length??0,{pending:a=!1}={}){let o=`${n} block${n===1?"":"s"}`;if(a){let s=[`ids ${m(t)}: ${o} without an id yet: the export gives ${n===1?"it":"each"} one`];return n>R?s:[...s,...e.map(({line:l,tag:c})=>` line ${l} ${c}`)]}let i=[`ids ${m(t)}: ${o} given an id`];return!e||n>R?i:[...i,...e.map(({line:s,tag:l,id:c})=>` line ${s} ${l} \u2192 ${c}`)]}function $(t,{title:e=null,icon:n=null}={},{pending:a=!1}={}){let o=m(f.dirname(t)),i=G(t),s=(c,r,w)=>a?`${c} not ${r} yet (${w}): the export writes ${c.includes(" and ")?"them":"it"}`:`${c} written ${r}: ${w}`,l=[];if(e){let c=[...e.page?["<title>"]:[],...typeof e.from=="string"&&e.from!==e.to?[`${i}'s title`]:[]];c.length&&l.push(`title ${o}: ${s(c.join(" and "),"as its h1 says it",JSON.stringify(e.to))}`)}return n?.missing?l.push(`icon ${o}: ${i} has the icon ${JSON.stringify(n.from)} and the page's header none: write it there (<div class="doc-icon">\u2026</div> before the h1) or take "icon" out of ${i} (the export leaves ${i}'s as it is)`):n&&l.push(`icon ${o}: ${s(`${i}'s icon`,"as its header has it",n.to===null?"none":JSON.stringify(n.to))}`),l}function oe(t,{by:e="this export"}={}){let n=t.length===1,a=[...t.filter(o=>B(f.basename(o))).map(o=>f.basename(o)).filter((o,i,s)=>s.indexOf(o)===i).map(o=>`${o}: the kit's markup, block ids`),...t.filter(o=>/^(doc|report)\.json$/.test(f.basename(o))).map(o=>f.basename(o)).filter((o,i,s)=>s.indexOf(o)===i).map(o=>`${o}: the title or icon said above`)];return`Re-read ${t.join(", ")} before editing ${n?"it":"them"}: ${e} wrote ${n?"it":"them"} (${a.join("; ")}).`}import H from"node:path";import{FILE as W}from"../browser/shared/annotations.mjs";import{editStateDirectory as J,reportsDirectory as u}from"../browser/shared/paths.mjs";import{documentDirectory as K,documentFiles as X}from"../browser/shared/workspace.mjs";function ue({say:t=!0}={}){return e=>{let{text:n,changes:a}=x(e.html,{finish:p});if(t&&a.length&&console.log(d(e.htmlPath,a,{pending:!0}).join(`
|
|
3
|
-
`)),t){let o=S(e.html);o.length&&console.log(g(e.htmlPath,o,o.length,{pending:!0}).join(`
|
|
4
|
-
`));for(let i of $(e.htmlPath,b(y(e.html),e.metadata),{pending:!0}))console.log(i)}return n}}function ge(t){for(let e of t){for(let n of v(e.html))console.log(`note ${e.slug}: ${n} (read-only in the preview)`);for(let n of D(e.html))console.log(`note ${e.slug}: ${n}`);for(let n of j(e.html))console.log(`note ${e.slug}: ${n}`)}}async function $e(t){for(let e of t){let n=await O({stateDirectory:J,reportsDirectory:u,slug:e});for(let a of T(X(K(e,u)).html,n))console.log(a)}}async function we(t){for(let e of t){let n=await L({stateDirectory:J,reportsDirectory:u,slug:e});for(let a of N(H.join(K(e,u),W),n))console.log(a)}}export{te as a,ne as b,oe as c,ue as d,ge as e,$e as f,we as g};
|
package/dist/chunk-YL2DPWVS.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as te,f as ne,n as se}from"./chunk-3LA3EMDE.mjs";import{b as A,d as oe}from"./chunk-2PBALTR3.mjs";import{a as N}from"./chunk-TX6JH7TR.mjs";import"./chunk-LC7YNQFG.mjs";import"./chunk-ITNLYXXV.mjs";import"./chunk-ZBIM6ARY.mjs";import"./chunk-NSKUTQ5J.mjs";import{a as J,i as X,r as Z}from"./chunk-QMQUXTU4.mjs";import{d as Y,e as q,i as j,j as V,k as W}from"./chunk-HQQMJCQJ.mjs";import{a as $}from"./chunk-QYKCJ7FG.mjs";import"./chunk-YZ5Z6H4W.mjs";import"./chunk-VACRB2NE.mjs";import{a as D,c as x}from"./chunk-HYMEEXKN.mjs";import"./chunk-TDQP3DKQ.mjs";import{b as ee,g as R}from"./chunk-5FRMCDPY.mjs";import"./chunk-E7VYDG2X.mjs";import{c as Q}from"./chunk-NFIBI4IP.mjs";import{c as K,e as G,g as P,o as H}from"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{isUtf8 as ke}from"node:buffer";import ue from"node:fs";import E from"node:path";import{instancesOf as _,isInstance as Le,partOf as fe}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as y,refusedInCopy as Se}from"../browser/shared/components/installed.mjs";import{attr as T,elementsOf as de,walk as I}from"../browser/shared/html-tree.mjs";import{blankedCss as v}from"../browser/shared/css-references.mjs";import{ATTRIBUTE as ce}from"../browser/shared/components/installed.mjs";var $e=new Set(["media","supports","container","layer","starting-style"]);function F(t,e){let n=0,s="";for(let o=0;o<t.length;o++){let i=t[o];i==="\\"?o++:s?s=i===s?"":s:i==='"'||i==="'"?s=i:i===")"||i==="]"?n--:(n===0&&e(i,o),(i==="("||i==="[")&&n++)}}function be(t){let e=v(t),n=v(t,{strings:!0}),s={children:[]},o=[s],i=0,a=0;for(let r=0;r<e.length;r++){let c=e[r];if(c==="\\")r++;else if(c==="("||c==="[")a++;else if(c===")"||c==="]")a=Math.max(0,a-1);else{if(a>0)continue;if(c==="{"){let l={prelude:n.slice(i,r),start:i,children:[]};o.at(-1).children.push(l),o.push(l),i=r+1}else c==="}"?(o.length>1&&o.pop(),i=r+1):c===";"&&(i=r+1)}}return s.children}function ie(t){let e=[],n=0;return F(t,(s,o)=>{s===","&&(e.push({text:t.slice(n,o),start:n}),n=o+1)}),e.push({text:t.slice(n),start:n}),e.filter(({text:s})=>s.trim())}function he(t){let e=[],n=t.trim(),s="",o=0,i=0,a=r=>{(i||r)>o&&e.push({combinator:s,compound:n.slice(o,i||r)}),i=0};return F(n,(r,c)=>{/\s/.test(r)?c===o?o=c+1:i||=c:">+~".includes(r)?(a(c),s=r,o=c+1):i&&(a(c),s=" ",o=c)}),a(n.length),e}function re(t){let e=[],n=-1,s=0,o="";for(let a=0;a<t.length;a++){let r=t[a];r==="\\"?a++:o?o=r===o?"":o:r==='"'||r==="'"?o=r:r==="("?s++:r===")"?s--:r==="["&&s===0?n=a:r==="]"&&s===0&&n>=0&&(e.push(t.slice(n,a+1)),n=-1)}let i=!1;return F(t,a=>{i||=a==="&"}),{attributes:e,nesting:i,scope:/(?:^|[^\w-]):scope\b/.test(t)}}var ye=t=>new RegExp(`^\\[\\s*${ce}\\s*=\\s*(["'])${t.replace(/[/-]/g,"\\$&")}\\1\\s*i?\\s*\\]$`,"i"),xe=t=>v(t).replace(/\\.|\[[^\]]*\]/g,"").includes("&");function ae(t,e,n){let s=he(t),o=({compound:l})=>re(l).attributes.some(h=>e.test(h)),i=({compound:l})=>{let{nesting:h,scope:u}=re(l);return!!n&&(h||u)},a=l=>["+","~"].includes(l?.combinator),r=s.findLastIndex(l=>o(l)||i(l));if(r<0)return!n||xe(t)?{why:"outside"}:{why:n==="instance"&&a(s[0])?"beside":null,subject:"inside"};let c=o(s[r])||n==="instance";return{why:c&&a(s[r+1])?"beside":null,subject:c&&r===s.length-1?"instance":"inside"}}var le=t=>t.some(({subject:e})=>e==="instance")?"instance":"inside";function pe(t,e){let n=ye(e),s=`[${ce}="${e}"]`,o=[],i=(r,c,l)=>{let h=c.replace(/\s+/g," ").trim();o.push({line:x(t,r),what:l==="beside"?`${h} reaches what stands beside the instance: what it styles has to stand in it`:`${h} reaches outside the instance: start it at ${s}`})},a=(r,c)=>{for(let l of r){let h=l.prelude.length-l.prelude.trimStart().length,u=l.start+h,p=/^@([\w-]+)\s*/.exec(l.prelude.trim());if(p){let f=p[1].toLowerCase();if($e.has(f))a(l.children,c);else if(f==="page")o.push({line:x(t,u),what:"@page reaches the paper of the whole document: an instance has no page of its own"});else if(f==="scope"){let d=/^@scope\s*\(([^)]*)\)/i.exec(l.prelude.trim())?.[1]??"",g=ie(d).map(({text:w})=>({...ae(w,n,c),steps:he(w).length}));d&&g.every(({why:w,steps:S})=>!w&&S===1)?a(l.children,le(g)):i(u,l.prelude,"outside")}continue}let m=ie(l.prelude).map(({text:f,start:d})=>{let g=ae(f,n,c);return g.why&&i(l.start+d+f.length-f.trimStart().length,f,g.why),g});m.some(({why:f})=>f)||a(l.children,le(m))}};return a(be(t),null),o}var b="template.html",k="example.html",C="component.json",Ee=new Set(["localStorage","sessionStorage"]),Oe=/^\S+: (?:line \d+ of )?its (?:kit\.js|style\.css) /,je=/(?: (?:names a file that )?is not in the document's folder|: it is (?:no file of|not in) the document's .*)$|^external resources are not portable: .*$/,Ne=": an example stands in no document: write a picture as a data: address, or draw it from style.css with a file the manifest's assets name",Ae=t=>t.replace(je,e=>(e.startsWith("external")?e:"")+Ne),L=(t,e)=>j({folder:t},e);function O(t,e){let n=null;try{n=ue.readFileSync(E.join(t,e))}catch{return null}return ke(n)?null:{file:e,what:"it is not UTF-8: save it as UTF-8 (PowerShell's > writes UTF-16; Set-Content -Encoding utf8 does not)"}}function z(t,e){let n=/^line (\d+): | \(line (\d+)\)/.exec(e);return n?{file:t,line:Number(n[1]??n[2]),what:e.replace(n[0],"")}:{file:t,what:e}}function U(t,e){let n=$.parseJsonText(C,t),s=n.statements[0]?.expression,o=null;for(let i of e.split(".")){let a=s?.properties?.find(({name:r})=>r?.text===i);if(!a)break;o=n.getLineAndCharacterOfPosition(a.getStart(n)).line+1,s=a.initializer}return o}function Te(t,{message:e,text:n="",values:s=[]}){let o=/at position (\d+)/.exec(e)?.[1];if(o)return x(t,Number(o));for(let i of[...s.map(String),...n.match(/[a-zA-Z][\w.]*/g)??[]]){let a=U(t,i);if(a)return a}return null}var Ce=t=>R(t).map(e=>/^line (\d+): <([^>]+)>: ([\s\S]*)$/.exec(e)).filter(Boolean).map(([,e,n,s])=>({line:Number(e),tag:n,why:s}));function Ie(t,{file:e,tree:n,html:s}){let o=[],i=Ce(s),a=Object.entries(t.parts).filter(([,l])=>l.edit==="text"),r=Object.entries(t.parts).filter(([,l])=>l.edit==="data"),c=(l,h)=>{let u=!1;return I(l,p=>{u||=p===h}),u};for(let l of _(n,t))for(let[h,u]of a)for(let p of fe(l,u.at)){let m=p.sourceCodeLocation?.startLine,f=de(p).find(w=>Q.has(w.tagName)),d=i.find(w=>w.line===m&&w.tag===p.tagName),g=r.find(([,w])=>fe(l,w.at).some(S=>S===p||c(S,p)||c(p,S)))?.[0];g?o.push({file:e,line:m,what:`the part ${h} (${u.at}) is edited as text, and stands in the part ${g}, edited as data, or around it, which is the component's: the editor leaves it read-only: name elements apart`}):f?o.push({file:e,line:m,what:`the part ${h} (${u.at}) is edited as text and holds a block, its <${f.tagName}> at line ${f.sourceCodeLocation?.startLine}: a text part holds words and marks alone, and the editor would leave this one read-only: write its \`at\` as what holds the words (${u.at} > ${f.tagName}), or give each block a part of its own`}):d&&o.push({file:e,line:m,what:`the part ${h} (${u.at}) is edited as text, and the editor would leave it read-only for what it holds: ${d.why}. A text part holds words and marks alone`})}return o}var ge="(?:(?:[zcs]h|[bpmfdtnlgkhjqxrzcsyw])?(?:[iuv]?(?:a(?:i|o|ng?)?|e(?:i|r|ng?)?|o(?:u|ng)?)|i(?:u|ng?)?|u(?:i|n)?|vn?))",Pe=new RegExp(`^${ge}$`,"i"),Re=new RegExp(`^${ge}{1,8}$`,"i"),M=new RegExp("\\p{Script=Han}","u"),ve=6,we=t=>[...t].filter(e=>M.test(e)).length;function Fe(t){let e=t.replaceAll("'",""),n=[0,...Array(e.length).fill(1/0)];for(let s=1;s<=e.length;s++)for(let o=Math.max(0,s-ve);o<s;o++)n[o]+1<n[s]&&Pe.test(e.slice(o,s))&&(n[s]=n[o]+1);return e&&Number.isFinite(n[e.length])?n[e.length]:null}function ze({name:t,words:e}){let n=we(t.zh),s=e.split(/\s+/).filter(Boolean);return n===0?M.test(e)&&!s.some(o=>Re.test(o)):!s.some(o=>Fe(o.toLowerCase())===n)}function Be({id:t,folder:e,catalog:n,off:s,parts:o}){let i=n.packages.get(t),a=n.problems.get(t)?.problem,r=L(e,C)??"",c=[];a&&c.push({file:C,line:Te(r,a),what:P("en",a)}),i?.template===null&&c.push({file:b,what:`there is none, and it is what "/" puts in a document: with none, no menu offers the block: write one <div ${y}="${t}"> with what a new instance holds`}),c.push(...o);let l=O(e,"writing.md");l&&c.push(l);let h=l||L(e,"writing.md")?.trim()?[]:[{file:"writing.md",what:"there is none, so gallery component show has nothing to say of how to write it"}];return i&&ze(i)&&h.push({file:C,line:U(r,"words")??U(r,"name.zh"),what:M.test(i.name.zh)?`no word of words spells its whole name ${i.name.zh} in pinyin as an input method composes it, its ${we(i.name.zh)} Chinese characters a syllable each in one word (as \u65B9\u6848\u6253\u5206 is fangandafen): "/" finds it while those letters are being composed only by such a word. What is counted is how many syllables a word reads as, not which characters they spell`:'its words are Chinese and none of them is pinyin: "/" goes by the letters an input method is composing, so write the pinyin there (\u770B\u677F kanban)'}),s&&h.push({file:"gallery.json",what:"the user turned it off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6, which is theirs to change and says nothing of the package: it is checked as if it were on, and the instances of a document show what they hold, read-only, until it is on"}),{title:"manifest",problems:c,notes:h}}function Ue(t){let e=$.createSourceFile("kit.js",t,$.ScriptTarget.Latest,!0,$.ScriptKind.JS),n=[],s=o=>{let i=$.isCallExpression(o)&&$.isPropertyAccessExpression(o.expression)?o.expression:null;if(i?.name.text==="component"&&/\bDocKit$/.test(i.expression.getText(e))){let[a]=o.arguments,r=a&&$.isObjectLiteralExpression(a)?a.properties.find(l=>l.name?.getText(e)==="id"):null,c=r&&$.isPropertyAssignment(r)&&$.isStringLiteralLike(r.initializer)?r.initializer.text:null;n.push({id:c,at:o.getStart(e)})}$.forEachChild(o,s)};return s(e),n}function _e(t){let e="kit.js";if(!t.files.includes("kit.js"))return{title:e,none:"none: a static block"};let n=O(t.folder,e);if(n)return{title:e,stops:!0,problems:[n]};let s=j(t,"kit.js")??"",o=J(s);if(o)return{title:e,stops:!0,problems:[{file:e,line:o.line,what:`a browser refuses it: ${o.message}`}]};let i=W(t).map(({line:l,what:h})=>({file:e,line:l,what:h})),a=i.length>0;for(let{name:l,at:h}of Y(s,Ee))i.push({file:e,line:x(s,h),what:`uses ${l}: an instance keeps what a reader chose with context.state`});let r=Ue(s);for(let{id:l,at:h}of r)l!==null&&l!==t.id&&i.push({file:e,line:x(s,h),what:`it registers ${l}, and this package is ${t.id}`});let c=r.length?[]:[{file:e,what:`no DocKit.component({ id: "${t.id}", mount(host, context) { \u2026 } }) is to be read in it, and a script may make that call in ways reading does not tell: running it says whether it starts one`}];for(let{line:l,code:h,message:u,refused:p}of q(s,{assets:t.assets}))(p?i:c).push({file:e,line:l,what:`TS${h}: ${u}`});return{title:e,stops:a,problems:i.sort((l,h)=>(l.line??0)-(h.line??0)),notes:c}}function Me(t){let e="style.css";if(!t.files.includes("style.css"))return{title:e,none:"none"};let n=O(t.folder,e);if(n)return{title:e,stops:!0,problems:[n]};let s=j(t,"style.css")??"",o=V(t),i=[...pe(s,t.id),...o].map(({line:a,what:r})=>({file:e,line:a,what:r}));return{title:e,stops:o.length>0,problems:i.sort((a,r)=>a.line-r.line)}}function De(t,{tree:e}){let n=null;I(e,r=>{n??=r.tagName==="main"?r:null});let s=de(n??{}),o=(n?.childNodes??[]).some(r=>r.nodeName==="#text"&&r.value.trim()),[i]=s;if(s.length!==1||o||!Le(i)||T(i,y)!==t)return[{file:b,line:i?.sourceCodeLocation?.startLine,what:`a template is one element, a <div ${y}="${t}"> or a <section>, and it holds ${s.length===1&&!o?`<${i.tagName}${T(i,y)?` ${y}="${T(i,y)}"`:""}>`:`${s.length} element${s.length===1?"":"s"}${o?" and words":""}`}`}];let a=[];return I({childNodes:[i]},r=>{T(r,"data-block-id")!==void 0&&a.push({file:b,line:r.sourceCodeLocation?.startLine,what:"it writes a data-block-id, which every instance made of it would repeat: leave it out, Gallery gives a block its id"})}),a}function Ke(t,{tree:e}){let n=H(t);if(!n)return[];let[s]=_(e,t),o=null;return s&&I({childNodes:[s]},i=>{Se(i.tagName,i.attrs)&&(o??=i)}),[{file:b,line:(o??s)?.sourceCodeLocation?.startLine,what:P("en",n)}]}function Ge(t){return[[b,"component-template"],[k,"component-example"]].flatMap(([e,n])=>{let s=L(t,e);if(s===null||!s.trim()||O(t,e))return[];let o=ne(n,s),{text:i}=ee(o);return[{file:e,slug:n,written:o,html:i,tree:D(i)}]})}function He({id:t,folder:e,found:n,pages:s,parts:o}){let i="template.html and example.html",a=[],r=[];for(let p of[b,k]){let m=O(e,p);m?a.push(m):p===b&&!L(e,p)?.trim()&&n.template!==null?a.push({file:p,what:"it is empty"}):p===k&&!s.some(f=>f.file===p)&&a.push({file:p,what:`there is none or it is empty: write an instance as a writer would fill it, a <div ${y}="${t}">; it is what this check runs`})}let c=s.find(p=>p.file===b);c&&a.push(...De(t,c));let l=s.find(p=>p.file===k);l&&_(l.tree,n).length===0&&a.push({file:k,what:`it holds no instance of ${t}: a <div ${y}="${t}">`});let h=s.map(({slug:p,written:m,html:f,file:d})=>({file:d,slug:p,written:m,html:f,directory:E.join(e,p),htmlPath:E.join(e,p,"doc.html"),metadata:{title:p,description:p,type:"component"}})),u=X(h);for(let p of h){for(let m of u.get(p.slug)??[])Oe.test(m)||a.push(z(p.file,Ae(m)));for(let m of Z(p))r.push(z(p.file,m));for(let m of R(p.html)){let f=z(p.file,`${m} (read-only in the preview)`);o.some(({file:d,line:g})=>d===f.file&&g===f.line)||r.push(f)}}return c&&!a.some(({file:p})=>p===b)&&a.push(...Ke(n,c)),{title:i,problems:a,notes:r}}function Ye(t,e){let n=K(t,void 0,{on:e}),s=A(t,e);if(!n.packages.has(e)&&!n.problems.has(e))return null;G(t,n);let o=n.packages.has(e)&&n.settings.disabled.includes(e),i=n.packages.get(e)??{id:e,folder:s,files:["kit.js","style.css"].filter(l=>ue.existsSync(E.join(s,l)))},a=Ge(s),r=n.packages.has(e)?null:"its manifest does not load",c=r?[]:a.flatMap(l=>Ie(i,l));return{found:n.packages.get(e)??null,pages:a,sections:[Be({id:e,folder:s,catalog:n,off:o,parts:c}),_e(i),Me(i),r?{title:"template.html and example.html",skipped:r}:He({id:e,folder:s,found:i,pages:a,parts:c})]}}var B=({file:t,line:e})=>e?`${t}:${e}`:t;function me({title:t,problems:e=[],notes:n=[],told:s=[],none:o,skipped:i,unverified:a,pictures:r},c){let l=a?`UNVERIFIED ${a}`:i?`not run: ${i}`:o??(e.length?`${e.length} problem${e.length===1?"":"s"}`:`ok${n.length?`, ${n.length} note${n.length===1?"":"s"}`:""}`);return[`${c}. ${t}: ${l}`,...e.map(h=>` FAIL ${B(h)}: ${h.what}`),...n.map(h=>` note ${B(h)}: ${h.what}`),...s.map(h=>` way back ${B(h)}: ${h.what}`),...r?[qe(r)]:[]]}function qe({folder:t,overviews:e,each:n,edited:s=[],asExport:o=[]}){let i=e.length?`${N(E.join(t,e[0]))}${e.slice(1).map(c=>` and ${c}`).join("")}, the three widths of each theme side by side; then each at full size: `:`${N(t)}: `,a=o.length===0?"":o.length===s.length?", each the same picture as the export's at its width: the block draws nothing more where a reader can edit":`, ${o.join(" and ")} the same picture as the export's at its width`,r=s.length?`; and ${s.join(" and ")}, as the editing page draws it (context.canEdit() true)${a}`:"";return` Pictures (none looked at for you; example.html above the line, template.html below it, each under its name): ${i}${n.join(", ")}${r}`}function Ve([t,e,n,s]){return t.problems.length?"the manifest":e.stops?"kit.js":n.stops?"style.css":s.skipped||s.problems.length?"template.html and example.html":null}async function $t(t,e){let n=Ye(t,e);n||(console.error(oe(t,e)),process.exit(1)),console.log(`${e}: ${N(A(t,e))}`),n.sections.forEach((r,c)=>console.log(me(r,c+1).join(`
|
|
3
|
-
`)));let s=Ve(n.sections),o=A(t,e),i=s?{title:te,skipped:`${s} first`}:await se(t,n.found,{example:L(o,k),template:L(o,b)});console.log(me(i,5).join(`
|
|
4
|
-
`));let a=[...n.sections,i].reduce((r,{problems:c=[]})=>r+c.length,0);a?(console.log(`FAIL ${e}: ${a} problem${a===1?"":"s"}`),process.exitCode=1):i.unverified?(console.log(`UNVERIFIED ${e}: the rest passed, and no browser ran it: export a document that holds it and open that in Chrome or Edge.`),process.exitCode=3):console.log(`OK ${e}`)}export{$t as checkCommand,Fe as fewestSyllables,Ye as readSections,me as sectionLines,ze as wantsPinyin};
|
package/dist/chunk-YZ5Z6H4W.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as u}from"./chunk-E7VYDG2X.mjs";import l from"node:fs/promises";import p from"node:path";import{escapeMarkup as b}from"../browser/shared/escape.mjs";import{sha256 as g}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 j}from"../browser/shared/workspace.mjs";async function v(t,c){if(!S.test(t))throw new Error(`A document's folder name must be lowercase kebab-case: ${t}`);let s=N(t,c),{html:r,json:n}=$(s),[m,o]=[p.basename(r),p.basename(n)],e,f;try{[e,f]=await Promise.all([l.readFile(r),l.readFile(n,"utf8")])}catch(a){if(a.code!=="ENOENT")throw a;let h=await l.stat(s).then(()=>!0,()=>!1);throw new Error(h?`${s} needs both ${m} and ${o}.`:`${s} does not exist.`)}let i;try{i=JSON.parse(f)}catch(a){throw new Error(`${o} is not valid JSON: ${a.message}`)}for(let a of["title","description","type"])if(typeof i[a]!="string"||i[a].trim()==="")throw new Error(`${o} is missing a non-empty ${a}.`);if(i.source!==void 0&&typeof i.source!="string")throw new Error(`${o} source must be a string when given.`);return{slug:t,directory:s,htmlPath:r,metadataPath:n,html:e.toString("utf8"),fileSha256:g(e),metadata:i}}async function z(t=[],{directory:c=E,prepare:s=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 n=[],m=new Map;for(let o of r)try{let e=await v(o,c);s&&([e.written,e.html]=[u(e.html),s(e)]),n.push(e)}catch(e){m.set(o,[e.message])}return{reports:n,failures:m}}var F=/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/,P=/\n[ \t]*<!-- Starter content:[^\n]*-->\n[ \t]*<section\b[^>]*\sdata-doc-placeholder\b[\s\S]*?<\/section>/;async function M(t,c,s,{directory:r=E,blank:n=!1,lang:m=null,page:o=!1}={}){if(!S.test(t))throw new Error("Slug must be lowercase kebab-case.");if(j(t,r))throw Object.assign(new Error(`"${t}" is taken in ${p.resolve(r)}`),{code:"EEXIST"});let e=o?O(r).pages:p.resolve(r),f=p.join(e,t),{html:i,metadata:a}=await R(t,c,s,{blank:n,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,i),l.writeFile(h.json,`${JSON.stringify(a,null,2)}
|
|
3
|
-
`)]),{slug:t,directory:f,metadata:a}}async function R(t,c,s,{blank:r=!1,lang:n=null}={}){let m=w=>b(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:s},i=r?o.replace(P,`
|
|
4
|
-
<p></p>`):o;if(r&&i===o)throw new Error("The starter's placeholder section was not found.");let a=typeof n=="string"&&F.test(n)?i.replace(/(<html\b[^>]*\slang=")[^"]*"/,(w,d)=>`${d}${n}"`):i,h={SLUG:t,TITLE:m(c)};return{html:a.replace(/__REPORT_(SLUG|TITLE)__/g,(w,d)=>h[d]),metadata:f}}export{z as a,M as b,R as c};
|
package/dist/chunk-ZBIM6ARY.mjs
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
var n=["init","new","import","open","serve","stop","check","export","qa","list","component","skill"],a=`The workspace (the folder of your documents) is --workspace <dir>, else GALLERY_WORKSPACE, else the
|
|
3
|
-
nearest folder up from here holding gallery.json (gallery init makes one), else ~/Documents/Gallery (on Windows
|
|
4
|
-
the Documents folder Explorer shows, OneDrive's when OneDrive backs it up).`,e=`A document is named by its slug, by its link (\u5468\u62A5-k3xv9q2a, what gallery list shows after /#) or by a
|
|
5
|
-
whole address, as a user hands one over (http://127.0.0.1:4317/#\u5468\u62A5-k3xv9q2a, a block's id after a / or not): the
|
|
6
|
-
words in a link are a label, and a title changed since leaves the address good.`,o={init:`Usage: gallery init [<dir>] [--from <old reports dir>]
|
|
7
|
-
Makes a workspace: <dir> (else the workspace found as every command finds it) with its gallery.json
|
|
8
|
-
and .gallery/ (never over a gallery.json that is there). Prints \u5DE5\u4F5C\u533A\uFF1A<abs>\uFF08\u65B0\u5EFA or \u5DF2\u6709\uFF09.
|
|
9
|
-
--from copies the documents of an older Gallery (its reports/ folder: one folder a document, each
|
|
10
|
-
holding report.html or doc.html) into the workspace: every document whose slug is free here (the
|
|
11
|
-
others listed as skipped), its preferences.md when the workspace has none, the sidebar's order, the
|
|
12
|
-
\u5199\u4F5C\u504F\u597D page, the custom emoji and the documents' recent versions. The old folder is only read:
|
|
13
|
-
nothing there is changed, moved or deleted.
|
|
14
|
-
Exits 1 when the workspace cannot be written or --from names no folder.`,new:`Usage: gallery new <slug> "<title>" ["<description>"] [--no-preview] [--no-browser]
|
|
15
|
-
A new document in <workspace>/<slug>/ from the starter: its doc.html, holding the starter's section
|
|
16
|
-
to replace, and doc.json, with the title and the description (\u65B0\u6587\u6863 when none is given). Then says
|
|
17
|
-
where it wrote (the workspace), where the user's writing preferences are (\u5199\u4F5C\u504F\u597D,
|
|
18
|
-
<workspace>/preferences.md, to read first: made from Gallery's default when there are none yet) and
|
|
19
|
-
the next steps (the first: send the user the address now), and last starts this workspace's Gallery
|
|
20
|
-
server (or uses the one running: it runs on after this command), opens the default browser at the
|
|
21
|
-
document and prints the address to give the user, as gallery open does. --no-preview (or
|
|
22
|
-
GALLERY_NO_PREVIEW=1) leaves the server alone; --no-browser (or GALLERY_NO_BROWSER=1) opens no
|
|
23
|
-
browser. Editing needs Chrome or Edge.
|
|
24
|
-
A title or a description that starts with "-" and a letter would be read as an option: put "--"
|
|
25
|
-
before the arguments (gallery new q3-review -- "-Q3 \u56DE\u987E").
|
|
26
|
-
Exits 1 when the document exists, or the slug is the workspace's own (exports, the \u5199\u4F5C\u504F\u597D page's) or
|
|
27
|
-
a document's in the trash.`,import:`Usage: gallery import <file> [<slug> ["<title>"]] [--no-preview] [--no-browser]
|
|
28
|
-
New documents made of a file, as the workbench's \u5BFC\u5165 makes them: Markdown (.md .markdown .mdx .txt
|
|
29
|
-
.text), HTML (.html .htm .xhtml, a Gallery export too), a table (.csv .tsv), Word (.docx), PDF (.pdf,
|
|
30
|
-
its text), EPUB (.epub) or a .zip of them (a Notion export: one document a page, nested as there).
|
|
31
|
-
The first document's title is the argument's, else the file's (front matter, first heading, name);
|
|
32
|
-
its slug the argument's, else made of the title's Latin words (lowercase kebab-case, a number added
|
|
33
|
-
when it is taken, as gallery new would refuse it). The pictures a Markdown file links to by relative addresses are copied into
|
|
34
|
-
<slug>/assets/. Then says what it made, what it could not bring as the file has it (by line), the
|
|
35
|
-
text the preview leaves read-only, the workspace, \u5199\u4F5C\u504F\u597D, the next steps (the first: send the user
|
|
36
|
-
the address now), and last, as gallery new does, the browser opened at the first document and the
|
|
37
|
-
server's address to give the user (--no-preview, or GALLERY_NO_PREVIEW=1, leaves the server alone;
|
|
38
|
-
--no-browser, or GALLERY_NO_BROWSER=1, opens no browser).
|
|
39
|
-
Put "--" before a title that starts with "-" and a letter.
|
|
40
|
-
Exits 1 when the file is not there, cannot be read, or gallery new would refuse the slug; 2 for a
|
|
41
|
-
kind it does not take.`,open:`Usage: gallery open [<slug>] [--no-browser]
|
|
42
|
-
Starts this workspace's Gallery server (or uses the one running: it runs on after this command, its
|
|
43
|
-
log in <workspace>/.gallery/logs/server.log), waits until it answers, and opens the default browser
|
|
44
|
-
at the workbench, or at the document <slug>, at its block when an address names one (--no-browser,
|
|
45
|
-
or GALLERY_NO_BROWSER=1, opens none).
|
|
46
|
-
${e}
|
|
47
|
-
Prints the workspace, the server, the document's page alone (the Agent's own, with a slug) and last
|
|
48
|
-
the address to give the user. Editing needs Chrome or Edge: open the address there.
|
|
49
|
-
With a slug and no qa baseline yet, it first keeps one of the document as it is now, so that the
|
|
50
|
-
first gallery qa after the changes pictures what changed.
|
|
51
|
-
Exits 1 when there is no such document, no server answers, or the workspace's server takes the
|
|
52
|
-
request and gives no answer (a second server is never started beside it).`,serve:`Usage: gallery serve [--port <n>]
|
|
53
|
-
Runs this workspace's Gallery server in the foreground until Ctrl+C (gallery open runs one in the
|
|
54
|
-
background instead). Prints the address once it answers. --port picks the port (else the last one
|
|
55
|
-
this workspace used, else the first free one from 4317).
|
|
56
|
-
Exits 1 when a server of this workspace runs already (its address said) or the port is taken.`,stop:`Usage: gallery stop
|
|
57
|
-
Stops this workspace's Gallery server, the one gallery open or gallery new started: it finishes the
|
|
58
|
-
saves in its queue first. A server npm run dev runs (Gallery's own development) is stopped where it runs.
|
|
59
|
-
Exits 0 when it stopped or none runs, 1 when it could not be stopped.`,check:`Usage: gallery check [<slug>...] [--allow-failures]
|
|
60
|
-
Checks each named document (none named: every document of the workspace) on its own.
|
|
61
|
-
${e}
|
|
62
|
-
Reads it as its preview shows it (natural HTML made the kit's in memory) and writes nothing: what the export will
|
|
63
|
-
write as the kit's markup is printed by line, and the blocks it will give an id (each at its line
|
|
64
|
-
when they are ten at most); first, once, what the preview wrote as the kit's markup when the reader
|
|
65
|
-
edited the document, and the \u6279\u6CE8 it deleted because their words are gone. Problems to act on first
|
|
66
|
-
("fix") come before the others ("note").
|
|
67
|
-
Exits 1 when a document fails, unless --allow-failures.`,export:`Usage: gallery export <slug>... [--allow-failures]
|
|
68
|
-
gallery export --all [--allow-failures]
|
|
69
|
-
Hands each named document in: its doc.html (report.html in an older document) written as its
|
|
70
|
-
preview shows it, natural HTML as the kit's markup and every block given an id (through the
|
|
71
|
-
workspace's server while one runs); then checks it and writes one standalone offline file per
|
|
72
|
-
passing document, <workspace>/exports/<slug>.html. A document the quick checks fail is not handed in.
|
|
73
|
-
${e}
|
|
74
|
-
It says first, once, what the preview wrote when the reader edited a document and the \u6279\u6CE8 it deleted;
|
|
75
|
-
then the failures ("FAIL <slug>: N problems"), the exports made, the notes to act on first ("fix")
|
|
76
|
-
and the others ("note"), what the hand-in wrote by line, which files to re-read before editing them,
|
|
77
|
-
and last, for each document exported, \u4EA4\u7ED9\u7528\u6237\uFF08\u79BB\u7EBF\u6587\u4EF6\uFF09\uFF1A and the export's absolute path.
|
|
78
|
-
Exits 1 when a document fails, unless --allow-failures.`,qa:`Usage: gallery qa <slug>... [--tiles] [--blocks <id,\u2026>] [--no-export]
|
|
79
|
-
gallery qa --all [--tiles] [--no-export]
|
|
80
|
-
Looks at each named document's export (<workspace>/exports/<slug>.html; one with none yet, or one not
|
|
81
|
-
made from its doc.html and its component packages as they are now, is exported first, as gallery
|
|
82
|
-
export does, unless --no-export) as a reader's browser shows it: Chrome or Edge, headless, at 1024, 736 and 360px wide
|
|
83
|
-
and in a laptop's 1024\xD7768 window, every disclosure open, each Sheet and detail card shown in turn.
|
|
84
|
-
${e}
|
|
85
|
-
Each finding is said with its place in the document's file (doc.html:<line>, report.html:<line> in
|
|
86
|
-
an older document): fail (errors, broken pictures, charts that drew nothing, the page wider than the
|
|
87
|
-
window\u2026), warn (columns or rows out of sight, overlapping text\u2026), info, unverified (no browser, a
|
|
88
|
-
wait that ran out\u2026). Pictures go to <workspace>/.gallery/qa/<slug>/ (its absolute path printed):
|
|
89
|
-
flagged/, changed/ and cards/ (the blocks changed since the last look, and the cards not pictured
|
|
90
|
-
yet), blocks/ (--blocks <id,\u2026>, one document only; the ids split at commas or spaces, and one the
|
|
91
|
-
document has not refused before anything is looked at), tiles/ (--tiles: the page in tiles). Each run
|
|
92
|
-
empties its own folders first: flagged/ every run, changed/ and cards/ a plain run, blocks/ a --blocks
|
|
93
|
-
run, tiles/ a --tiles run. A --blocks run says, before its verdict, the changed blocks and the cards
|
|
94
|
-
it did not picture: a plain run pictures them. First, once, as gallery check says them, what the
|
|
95
|
-
preview wrote when the reader edited the document and the \u6279\u6CE8 it deleted. Then the verdict, and
|
|
96
|
-
last, on a line of its own, the export's absolute path after \u4EA4\u7ED9\u7528\u6237\uFF08\u79BB\u7EBF\u6587\u4EF6\uFF09\uFF1A.
|
|
97
|
-
GALLERY_BROWSER=<executable> picks the browser. A browser that does not start is tried once more
|
|
98
|
-
with a fresh profile.
|
|
99
|
-
Exits 1 when anything fails (or the export it ran first did), 3 when something could not be
|
|
100
|
-
verified (UNVERIFIED: no browser, or one that did not start), 2 when an export is missing or stale
|
|
101
|
-
with --no-export or --blocks names an id the document has not, else 0. A warning never fails.`,list:`Usage: gallery list [<words>...]
|
|
102
|
-
The workspace's documents, for an Agent to find the one the user means: each one's slug and title,
|
|
103
|
-
its description, its address (\u5730\u5740\uFF1A/#<link>, after the port of the workspace's server), when its file
|
|
104
|
-
was last written and where that file is, the one edited last first.
|
|
105
|
-
With words, only those whose title, description or slug holds any of them (case alike, Chinese found
|
|
106
|
-
inside words), the best first; with a document's link or whole address, that document, or that it is
|
|
107
|
-
in the trash. First, the workspace and where \u5199\u4F5C\u504F\u597D is (made from Gallery's default when there is none
|
|
108
|
-
yet).`,component:`Usage: gallery component new <id> [--script]
|
|
109
|
-
gallery component list
|
|
110
|
-
gallery component show <id>
|
|
111
|
-
gallery component check <id>
|
|
112
|
-
gallery component try <slug> [<instance id>] --press <selector> [--keep]
|
|
113
|
-
gallery component try <slug> [<instance id>] --drag <selector> --to <selector> [--keep]
|
|
114
|
-
gallery component try <slug> [<instance id>] --key <selector> <key> [--keep]
|
|
115
|
-
A component package is a block to use again, kept in the workspace: components/<scope>/<name>/. An id
|
|
116
|
-
is <scope>/<name>, or a <name> alone in the scope local; a document uses one by an element naming it.
|
|
117
|
-
new starts a package: component.json, template.html, example.html, writing.md and style.css, and with
|
|
118
|
-
--script a kit.js. It passes check as it stands, and says what to write next.
|
|
119
|
-
Exits 1 when the id is taken.
|
|
120
|
-
list says what the workspace has now: the components to write with, each with its version, then those
|
|
121
|
-
not to write with now and why: hidden, disabled, one that does not load, a manifest one level too shallow;
|
|
122
|
-
and last the blocks of Gallery's own the user hid.
|
|
123
|
-
show says how to write one: its parts, its writing.md and its example.
|
|
124
|
-
Exits 1 when there is no such component or it does not load.
|
|
125
|
-
check says what is wrong with one, each problem ("FAIL") at its place in the package's files, each note
|
|
126
|
-
never a failure, in five sections: 1 the manifest, with template.html there, text parts that hold
|
|
127
|
-
words and marks alone, and a note on a Chinese name no word of its words spells whole in pinyin, a
|
|
128
|
-
syllable a character, by how many syllables a word reads as; 2 kit.js: what a browser refuses, what
|
|
129
|
-
an export refuses, what it registers, a type check against sdk/; 3 style.css: every selector in the
|
|
130
|
-
instance, what an export cannot hold; 4 template.html and example.html, each read as a document's page
|
|
131
|
-
by what gallery check runs, and template.html as what a menu can put in; 5
|
|
132
|
-
both in a temporary document, exported and opened as gallery qa opens one, in Chrome or Edge under the export's
|
|
133
|
-
policy: what the console and the policy say, a dialog or a window it opens, mount then dehydrate then
|
|
134
|
-
mount and copies put back giving the same DOM (a drawing neither the manifest's runtime nor dehydrate
|
|
135
|
-
names piles up, and what piles up outside the instance is named too), a text part the component
|
|
136
|
-
redraws, a data part a mount changes, a write with no gesture once the page takes edits, the way back
|
|
137
|
-
to the file (a way back line: what the component's example wrote, each part with how many of its
|
|
138
|
-
lines the write took out and put in, and that the server took it; a note on a write that lays a part
|
|
139
|
-
out anew, and on a list a card is dropped on that listens for dragover and not for dragenter), a page
|
|
140
|
-
wider than the window, and the pictures, in <workspace>/.gallery/qa/components/<id>/, its absolute
|
|
141
|
-
path printed, emptied each run: overview-light.png and overview-dark.png, the three widths of a theme
|
|
142
|
-
side by side, then each at 360, 736 and 1024px wide, light and dark, and edit-1024-light.png and
|
|
143
|
-
edit-360-light.png, as the editing page draws it, said when they are the export's. Section 5 waits
|
|
144
|
-
until what it needs passes; a page that stops answering or loads itself again ends it, and is said;
|
|
145
|
-
with no browser, one that does not start or goes while it looks, or a folder it cannot write, it says
|
|
146
|
-
so and the rest stands. A package the user turned off is checked as any, with a note saying so.
|
|
147
|
-
GALLERY_BROWSER=<executable> picks the browser.
|
|
148
|
-
Exits 1 when anything fails, 3 when nothing did and no browser ran it (UNVERIFIED), else 0.
|
|
149
|
-
Exits 2 for an id no package can have.
|
|
150
|
-
try makes one gesture a reader makes on an instance in a document, with the pointer and the keys, and
|
|
151
|
-
says what it wrote. It starts the workspace's server (or uses the one running), as gallery open does,
|
|
152
|
-
and opens the document's page alone, editable (the Agent \u81EA\u7528 address), in Chrome or Edge, headless, in
|
|
153
|
-
a profile of its own, and waits until the server has told the page of the writes made before it (a
|
|
154
|
-
package changed, doc.html written), which load it again. Each selector is the first element of the
|
|
155
|
-
instance it finds: --press, a press at its middle; --drag \u2026 --to, pressed there, moved in steps to the
|
|
156
|
-
middle of another and released a moment after the move that comes onto it; --key, the key (Enter,
|
|
157
|
-
Space, ArrowRight, a letter, Shift+Tab) with the focus on it, as Tab gives it. <slug> names the
|
|
158
|
-
document, as its link or a whole address does too (gallery help says how), and the instance is named
|
|
159
|
-
by its data-block-id, or by its package's id where the document holds one of it; with one instance in
|
|
160
|
-
the document, not at all. Once <html>'s data-ge-save says saved again it prints a Gesture line, what it
|
|
161
|
-
did to which element, and a Wrote line: each part of the instance in doc.html with how many of its
|
|
162
|
-
lines the gesture took out and put in, and that nothing outside the instance changed, data-block-id
|
|
163
|
-
aside, which a save gives (what did is someone else's, which stays). Then it presses Ctrl+Z once, the
|
|
164
|
-
focus where the gesture left it but off a field of the instance, as a reader undoes, and an Undone line
|
|
165
|
-
says doc.html is as it was; --keep leaves the write (a Kept line). Last, a picture of the instance after
|
|
166
|
-
the gesture, <workspace>/.gallery/qa/<slug>/try/after.png, its absolute path printed, emptied each run.
|
|
167
|
-
A first save of an edit writes a document's plain HTML as the kit's markup, which the Wrote line says
|
|
168
|
-
and which stays: the file is compared as its page shows it. A trial cut off after its gesture (the page
|
|
169
|
-
offline, a card held for the reader, a load of its own, the browser gone) reads doc.html and says what
|
|
170
|
-
it holds of the gesture.
|
|
171
|
-
Exits 1 when the gesture wrote nothing (what came of it said: no context.edit, one the page refused, an
|
|
172
|
-
HTML5 drag dropped nowhere, a selector that finds nothing as the component failed), when one Ctrl+Z did
|
|
173
|
-
not give doc.html back, when the component failed, or when a trial cut off left the gesture's write in
|
|
174
|
-
doc.html, said with the parts it holds, for you to put back; 2 for a mistake in the command line: a
|
|
175
|
-
selector that finds nothing shown in the instance, an instance the document has not among them, a drag
|
|
176
|
-
that ends on what it drags; 3 when the trial was not seen through and doc.html holds nothing of the
|
|
177
|
-
gesture (UNVERIFIED: no server or browser ran it, a card waits for the reader, someone else wrote
|
|
178
|
-
doc.html meanwhile, which stays), the line saying what doc.html holds.`,skill:`Usage: gallery skill install [--agent claude|codex] [--project] [--dir <path>]
|
|
179
|
-
Writes the Gallery skill that matches this gallery command (what an Agent reads to write documents
|
|
180
|
-
with it: SKILL.md, references/, sdk/) where the Agent reads skills:
|
|
181
|
-
Claude Code ~/.claude/skills/gallery (CLAUDE_CONFIG_DIR/skills/gallery when that is set)
|
|
182
|
-
Codex ~/.codex/skills/gallery (CODEX_HOME/skills/gallery when that is set)
|
|
183
|
-
for each of them whose folder is there (neither: Claude Code's), or the one --agent names. --project
|
|
184
|
-
writes it into this folder's .claude/skills/gallery (.codex/skills/gallery for Codex) instead, for
|
|
185
|
-
this project alone; --dir <path> writes it into <path> itself, the skill's own folder, for any other agent.
|
|
186
|
-
A Gallery skill there is replaced (nothing done when it holds the same files). An older Gallery's
|
|
187
|
-
skill (the whole tools: package.json and src/, or reports/, its SKILL.md named gallery or
|
|
188
|
-
html-report-studio), there or anywhere in that skills folder, has its documents copied into the
|
|
189
|
-
workspace first, as gallery init --from copies them, and its exports into <workspace>/exports/ where
|
|
190
|
-
the name is free; then it is moved to <workspace>/.gallery/old-skill-<date>/ (never deleted), so that
|
|
191
|
-
the Agent sees one Gallery skill. Says what it did and where; then open a new Agent session.
|
|
192
|
-
Exits 1, changing nothing, when a target holds something else or an older skill's preview server
|
|
193
|
-
still runs (stop it first); 1 too when an older skill cannot be moved (its documents are copied).`},r=o.component.split(`
|
|
194
|
-
`).filter(t=>/^(?:Usage:)?\s*gallery component try /.test(t)).map((t,s)=>s===0?`Usage: ${t.trimStart()}`:t).join(`
|
|
195
|
-
`),i=`Usage: gallery <command> [options] [--workspace <dir>]
|
|
196
|
-
Gallery: documents written as HTML, edited in the browser, exported as one offline file.
|
|
197
|
-
|
|
198
|
-
gallery init [<dir>] [--from <old reports dir>] make a workspace (copy an older Gallery's documents)
|
|
199
|
-
gallery new <slug> "<title>" ["<description>"] a new document; starts the server, opens the browser
|
|
200
|
-
gallery import <file> [<slug> ["<title>"]] documents made of a file (Markdown, HTML, Word, PDF\u2026)
|
|
201
|
-
gallery open [<slug>] [--no-browser] start or reuse the server and open the browser
|
|
202
|
-
gallery serve [--port <n>] run the server in the foreground
|
|
203
|
-
gallery stop stop the workspace's server
|
|
204
|
-
gallery check [<slug>...] check documents (none named: all)
|
|
205
|
-
gallery export <slug>... | --all write <workspace>/exports/<slug>.html
|
|
206
|
-
gallery qa <slug>... [--blocks a,b] [--tiles] look at exports in Chrome or Edge
|
|
207
|
-
gallery list [<words>...] the documents, or those the words name
|
|
208
|
-
gallery component new|list|show|check [<id>] make, list, read and check component packages
|
|
209
|
-
gallery component try <slug> --press <selector> a reader's gesture on an instance, and what it wrote
|
|
210
|
-
gallery skill install [--agent claude|codex] write the Agent's skill for this version
|
|
211
|
-
gallery help [<command>] this, or a command's whole usage
|
|
212
|
-
gallery --version the version
|
|
213
|
-
|
|
214
|
-
${e}
|
|
215
|
-
${a}
|
|
216
|
-
Editing in the browser and gallery qa need Chrome or Edge. Node 22.13 or newer.`;export{n as a,o as b,r as c,i as d};
|