allyhub 0.15.3 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/commands/add.js +1 -1
- package/dist/commands/cloud-tools.js +1 -1
- package/dist/commands/dev.js +5 -5
- package/dist/commands/doctor.js +3 -3
- package/dist/commands/frames/doc.js +1 -1
- package/dist/commands/inspect/common.js +3 -3
- package/dist/commands/inspect/facts.js +2 -2
- package/dist/commands/inspect/index.js +1 -1
- package/dist/commands/inspect/layout.js +1 -1
- package/dist/commands/inspect/uses.js +3 -0
- package/dist/commands/mail.js +6 -6
- package/dist/commands/render.js +1 -1
- package/dist/main.js +8 -8
- package/dist/node_modules/@allyhub/3d-extension/dist/cli/scenery-text.js +2 -2
- package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/audio/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/audio/dist/place.js +2 -0
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/browser/package.json +1 -1
- package/dist/node_modules/@allyhub/build/dist/content.d.ts +7 -0
- package/dist/node_modules/@allyhub/build/dist/file-check.d.ts +2 -2
- package/dist/node_modules/@allyhub/build/dist/imports.d.ts +17 -0
- package/dist/node_modules/@allyhub/build/dist/imports.js +2 -0
- package/dist/node_modules/@allyhub/build/dist/index.d.ts +3 -2
- package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/inspect-view.d.ts +1 -1
- package/dist/node_modules/@allyhub/build/dist/inspect-view.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/kind-build.d.ts +19 -3
- package/dist/node_modules/@allyhub/build/dist/prepare.js +3 -3
- package/dist/node_modules/@allyhub/build/dist/uses.d.ts +27 -6
- package/dist/node_modules/@allyhub/build/dist/uses.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/work.d.ts +9 -1
- package/dist/node_modules/@allyhub/build/dist/work.js +3 -3
- package/dist/node_modules/@allyhub/build/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-extension/skills/allyhub/references/canvas.md +2 -2
- package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/check/package.json +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/blobs.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/client.d.ts +12 -3
- package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/index.d.ts +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/cloud/package.json +1 -1
- package/dist/node_modules/@allyhub/components/package.json +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/deletion.js +2 -0
- package/dist/node_modules/@allyhub/dev-server/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/inputs.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/project.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/record.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/writer.js +3 -2
- package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
- package/dist/node_modules/@allyhub/doc/dist/docx.js +4 -4
- package/dist/node_modules/@allyhub/doc/dist/html.js +40 -40
- package/dist/node_modules/@allyhub/doc/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/markdown.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/parse.js +4 -4
- package/dist/node_modules/@allyhub/doc/dist/table.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/write.js +26 -26
- package/dist/node_modules/@allyhub/doc/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-extension/dist/build.js +2 -2
- package/dist/node_modules/@allyhub/doc-extension/dist/inspect.js +1 -1
- package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
- package/dist/node_modules/@allyhub/export/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/export/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-host/dist/points.js +1 -1
- package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +15 -3
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/website.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/items.d.ts +70 -11
- package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +15 -4
- package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +4 -0
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/i18n/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/i18n/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/dist/stage.js +1 -1
- package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
- package/dist/node_modules/@allyhub/image-extension/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/image-extension/dist/workspace.js +1 -1
- package/dist/node_modules/@allyhub/image-extension/package.json +2 -2
- package/dist/node_modules/@allyhub/image-extension/skills/allyhub/references/images.md +3 -3
- package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
- package/dist/node_modules/@allyhub/image-render/package.json +1 -1
- package/dist/node_modules/@allyhub/image-runtime/dist/load.js +2 -2
- package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/jobs/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-extension/package.json +3 -1
- package/dist/node_modules/@allyhub/linkedin-extension/skills/allyhub/references/linkedin.md +1 -1
- package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
- package/dist/node_modules/@allyhub/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/media/package.json +1 -1
- package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/model/package.json +1 -1
- package/dist/node_modules/@allyhub/office-extension/LICENSE +241 -0
- package/dist/node_modules/@allyhub/office-extension/markup/csv/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/office-extension/markup/csv/data/leads.csv +5 -0
- package/dist/node_modules/@allyhub/office-extension/markup/csv/markup.json +19 -0
- package/dist/node_modules/@allyhub/office-extension/markup/document/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/office-extension/markup/document/briefs/launch.docx +0 -0
- package/dist/node_modules/@allyhub/office-extension/markup/document/markup.json +11 -0
- package/dist/node_modules/@allyhub/office-extension/markup/presentation/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/office-extension/markup/presentation/decks/pitch.pptx +0 -0
- package/dist/node_modules/@allyhub/office-extension/markup/presentation/markup.json +11 -0
- package/dist/node_modules/@allyhub/office-extension/markup/workbook/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/office-extension/markup/workbook/data/plans.xlsx +0 -0
- package/dist/node_modules/@allyhub/office-extension/markup/workbook/markup.json +10 -0
- package/dist/node_modules/@allyhub/office-extension/package.json +124 -0
- package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
- package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +15 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/page/runtimes.d.ts +9 -0
- package/dist/node_modules/@allyhub/piece/dist/page/runtimes.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/source.d.ts +53 -10
- package/dist/node_modules/@allyhub/piece/dist/source.js +1 -1
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/project/dist/digest.js +1 -1
- package/dist/node_modules/@allyhub/project/dist/part-keys.js +1 -1
- package/dist/node_modules/@allyhub/project/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +10 -11
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +7 -0
- package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/blobs.d.ts +9 -0
- package/dist/node_modules/@allyhub/protocol/dist/blobs.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.d.ts +77 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +39 -9
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +15 -15
- package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +441 -5
- package/dist/node_modules/@allyhub/protocol/dist/events.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +2 -2
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +4 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +8 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +5 -5
- package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +45 -0
- package/dist/node_modules/@allyhub/protocol/dist/kinds.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/paywall.d.ts +134 -0
- package/dist/node_modules/@allyhub/protocol/dist/paywall.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/place.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +3 -3
- package/dist/node_modules/@allyhub/protocol/dist/purposes.d.ts +47 -0
- package/dist/node_modules/@allyhub/protocol/dist/purposes.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/routes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +52 -5
- package/dist/node_modules/@allyhub/protocol/dist/shares.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.d.ts +34 -0
- package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/sites.d.ts +1 -0
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +21 -52
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/studio-server.d.ts +264 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-server.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.d.ts +18 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.d.ts +97 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +3 -2
- package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +26 -20
- package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/turns.d.ts +71 -0
- package/dist/node_modules/@allyhub/protocol/dist/turns.js +2 -0
- package/dist/node_modules/@allyhub/protocol/package.json +1 -1
- package/dist/node_modules/@allyhub/registry/package.json +1 -1
- package/dist/node_modules/@allyhub/render/package.json +1 -1
- package/dist/node_modules/@allyhub/runtime/dist/compose.js +1 -1
- package/dist/node_modules/@allyhub/runtime/dist/embed.js +1 -1
- package/dist/node_modules/@allyhub/runtime/dist/film.js +1 -1
- package/dist/node_modules/@allyhub/runtime/dist/piece.js +2 -2
- package/dist/node_modules/@allyhub/runtime/dist/player/player.js +1 -1
- package/dist/node_modules/@allyhub/runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scaffold/dist/index.js +4 -4
- package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/dynamic.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/logical.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/build.js +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/cli/sheet.js +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/package.json +3 -3
- package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/components.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/build.js +2 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/cli/slides.js +2 -2
- package/dist/node_modules/@allyhub/slides-extension/dist/deck-pptx.js +1 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/evaluate.js +2 -2
- package/dist/node_modules/@allyhub/slides-extension/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/slides-extension/package.json +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/dist/audio-icon.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/package.json +5 -1
- package/dist/node_modules/@allyhub/slides-runtime/dist/component.js +1 -1
- package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
- package/dist/node_modules/@allyhub/slides-runtime/dist/item.js +2 -0
- package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +5 -5
- package/dist/node_modules/@allyhub/slides-runtime/dist/slide-css.js +20 -0
- package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/stage/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-page/dist/install.js +1 -1
- package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.html +1 -1
- package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.js +2 -2
- package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +20 -20
- package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/telemetry/dist/doc.js +17 -2
- package/dist/node_modules/@allyhub/telemetry/dist/level.js +2 -2
- package/dist/node_modules/@allyhub/telemetry/dist/levels.js +2 -0
- package/dist/node_modules/@allyhub/telemetry/dist/scrub.js +1 -1
- package/dist/node_modules/@allyhub/telemetry/package.json +5 -1
- package/dist/node_modules/@allyhub/text-extension/markup/markup.json +1 -1
- package/dist/node_modules/@allyhub/text-extension/markup-file/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/text-extension/markup-file/archive/assets.zip +0 -0
- package/dist/node_modules/@allyhub/text-extension/markup-file/markup.json +10 -0
- package/dist/node_modules/@allyhub/text-extension/package.json +35 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-extension/dist/build.js +1 -1
- package/dist/node_modules/@allyhub/video-extension/dist/cli/reference-text.js +3 -3
- package/dist/node_modules/@allyhub/video-extension/package.json +2 -2
- package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/website/package.json +1 -1
- package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/x-extension/package.json +3 -1
- package/dist/node_modules/@allyhub/x-extension/skills/allyhub/references/x.md +1 -1
- package/dist/node_modules/@allyhub/x-model/package.json +1 -1
- package/dist/node_modules/@allyhub/x-view/package.json +1 -1
- package/dist/package.json +13 -12
- package/dist/project.js +1 -1
- package/dist/telemetry.js +3 -3
- package/dist/text/console-text.js +2 -2
- package/dist/works.js +1 -1
- package/editor-web/assets/{abnfDiagram-WEYOIA3C-arPHIJYC.js → abnfDiagram-WEYOIA3C-CHNpVSPv.js} +1 -1
- package/editor-web/assets/{architecture-WOLXFQ4H-XPJlj9Iq.js → architecture-WOLXFQ4H-gPsJqQwV.js} +1 -1
- package/editor-web/assets/{architectureDiagram-ZHVYKT53-BZNJvOtd.js → architectureDiagram-ZHVYKT53-CEIDcC6r.js} +1 -1
- package/editor-web/assets/arrow-down-B8VUPCGi.js +1 -0
- package/editor-web/assets/arrow-up-Ds4juY8X.js +1 -0
- package/editor-web/assets/article-BHTjq0_Y.js +3 -0
- package/editor-web/assets/{article-Ck2ii-gZ.js → article-DfELjJ2o.js} +2 -2
- package/editor-web/assets/{audio-lines-1s1eRs4Q.js → audio-lines-PZj77e7t.js} +1 -1
- package/editor-web/assets/{bar-button-6Perrucg.js → bar-button-J9vbfzTx.js} +1 -1
- package/editor-web/assets/{blockDiagram-RJAE7QA3-B4L2P9Zz.js → blockDiagram-RJAE7QA3-CUzEGVet.js} +4 -4
- package/editor-web/assets/browser-C1XuTMlp.js +1 -0
- package/editor-web/assets/{c4Diagram-XDPPPE54-D5t2-Sm8.js → c4Diagram-XDPPPE54-CB94NR9s.js} +1 -1
- package/editor-web/assets/calc-worker-BdHh5LXM.js +45 -0
- package/editor-web/assets/channel-DCDCx5Es.js +1 -0
- package/editor-web/assets/chart-amT4lgX3.js +2 -0
- package/editor-web/assets/chart-file-CfbWK9l1.js +1 -0
- package/editor-web/assets/{chart-no-axes-column-CJmeYOSo.js → chart-no-axes-column-Be0lFcGF.js} +1 -1
- package/editor-web/assets/{chunk-2E7WHVMD-bWUHKM6h.js → chunk-2E7WHVMD-DFYo_Boi.js} +1 -1
- package/editor-web/assets/{chunk-4EMNKR2T-CGGaxE7r.js → chunk-4EMNKR2T-CLLjmweX.js} +1 -1
- package/editor-web/assets/{chunk-55XCU76K-BXCHI3wC.js → chunk-55XCU76K-CkwQ_3m1.js} +1 -1
- package/editor-web/assets/{chunk-7S6XSTFO-H4tWSKhS.js → chunk-7S6XSTFO-V-AvHpAB.js} +1 -1
- package/editor-web/assets/{chunk-AQDTSKZB-kyBZy8vG.js → chunk-AQDTSKZB-PjHyYpb8.js} +1 -1
- package/editor-web/assets/chunk-DSNLSHJZ-QaczBS3J.js +127 -0
- package/editor-web/assets/{chunk-HAGFOTED-P8dIUq9O.js → chunk-HAGFOTED-aLaQB5Xu.js} +1 -1
- package/editor-web/assets/{chunk-HNE4Q36P-B_BAZXMj.js → chunk-HNE4Q36P-De3ftDQR.js} +1 -1
- package/editor-web/assets/{chunk-NQOKRVIF-Bubl63jI.js → chunk-NQOKRVIF-CrhVQyvP.js} +17 -17
- package/editor-web/assets/{chunk-UHW7PFBP-DYGk0ZDz.js → chunk-UHW7PFBP-BFmZ5ZLn.js} +1 -1
- package/editor-web/assets/{chunk-VQ5W62QI-BLFRyEGi.js → chunk-VQ5W62QI-CzppUHLA.js} +1 -1
- package/editor-web/assets/{chunk-WQQL4CDK-kiwalF_c.js → chunk-WQQL4CDK-BrAU7V6v.js} +1 -1
- package/editor-web/assets/{chunk-YZO67HFG-D-bT0L2N.js → chunk-YZO67HFG-BSiF71qj.js} +1 -1
- package/editor-web/assets/{chunk-ZAUX2LTX-C_P5nPKV.js → chunk-ZAUX2LTX-BJc4r5b1.js} +1 -1
- package/editor-web/assets/{chunk-ZCHMQSOR-Deizt1PO.js → chunk-ZCHMQSOR-CkGTuehB.js} +1 -1
- package/editor-web/assets/{classDiagram-v2-4MYWR3UA-PUtBnliw.js → classDiagram-v2-4MYWR3UA-Byxc7J88.js} +7 -7
- package/editor-web/assets/code-CD-CbJG9.js +1 -0
- package/editor-web/assets/{collaborator--S95EupA.js → collaborator-BU4qU7O3.js} +1 -1
- package/editor-web/assets/{copy-DvOiv9Ra.js → copy-CuJSs0nI.js} +1 -1
- package/editor-web/assets/{createLucideIcon-REX213UO.js → createLucideIcon-lm_6n8YT.js} +1 -1
- package/editor-web/assets/csv-Bwre9FdI.js +11 -0
- package/editor-web/assets/{cynefin-EF2NZ3EQ-C09G_QFD.js → cynefin-EF2NZ3EQ-BSxkVbdf.js} +1 -1
- package/editor-web/assets/{cynefinDiagram-WF24UDRP-JxxJ5-Ov.js → cynefinDiagram-WF24UDRP-IkCgARNs.js} +1 -1
- package/editor-web/assets/{dagre-NK4GIZVX-6DkhWeGP.js → dagre-NK4GIZVX-9PgeH6nY.js} +1 -1
- package/editor-web/assets/deck-tTzKONci.js +1 -0
- package/editor-web/assets/{diagram-CBK3MWTC-kI_Q07du.js → diagram-CBK3MWTC-DRzeg3Ds.js} +1 -1
- package/editor-web/assets/{diagram-I5XIIV2D-FYaR41qP.js → diagram-I5XIIV2D-B_zeKMN6.js} +1 -1
- package/editor-web/assets/{diagram-ODIL2UCW-29WBGOdl.js → diagram-ODIL2UCW-FFm0O8SN.js} +1 -1
- package/editor-web/assets/{diagram-PFBEJUXE-BFZJ9s9P.js → diagram-PFBEJUXE-DrtCT8OA.js} +1 -1
- package/editor-web/assets/{diagram-RJA3I4VV-BSNFe4e-.js → diagram-RJA3I4VV-DtxJ3V0q.js} +1 -1
- package/editor-web/assets/{diagram-TYUNFSNR-Cb1wZgqj.js → diagram-TYUNFSNR-DmxF_8H_.js} +16 -16
- package/editor-web/assets/dist-BEpzsYn_.js +6 -0
- package/editor-web/assets/dist-BUD4ywMB.js +18 -0
- package/editor-web/assets/{dist-BrGYx10E.js → dist-Bd8IxQPP.js} +1 -1
- package/editor-web/assets/dist-C21CkR7Z.js +531 -0
- package/editor-web/assets/{dist-BuG-vxxb.js → dist-C56mWAec.js} +3 -3
- package/editor-web/assets/dist-CAb3W9_P.js +43 -0
- package/editor-web/assets/dist-CEknsRDd.js +24 -0
- package/editor-web/assets/dist-CbZAznNW.js +19 -0
- package/editor-web/assets/{dist-BaCVkpwc.js → dist-D3C6FyrO.js} +1 -1
- package/editor-web/assets/dist-DDzjbKIg.js +4 -0
- package/editor-web/assets/dist-DaEbElXI.js +3 -0
- package/editor-web/assets/{dist-CnbKC_fW.js → dist-Dr3o4vee.js} +1 -1
- package/editor-web/assets/{dist-BlqK1Oua.js → dist-DruvDNQe.js} +1 -1
- package/editor-web/assets/dist-JLyDtl9X.js +1 -0
- package/editor-web/assets/dist-PBbWAsrV.js +17 -0
- package/editor-web/assets/dist-ZZlQa66J.js +1 -0
- package/editor-web/assets/{dist-DXUMNYNX.js → dist-bQKpw3Zz.js} +5 -5
- package/editor-web/assets/dist-d4dayaWE.js +17 -0
- package/editor-web/assets/docx-draw-9Q_fArBC.js +4 -0
- package/editor-web/assets/docx-preview-pcg9ioe3.js +21 -0
- package/editor-web/assets/{ebnfDiagram-V4P3TTPT-t3vO5qHB.js → ebnfDiagram-V4P3TTPT-DSX1Aoty.js} +1 -1
- package/editor-web/assets/{elk-QONTBCTQ-DfIcGBDb.js → elk-QONTBCTQ-C7gy9q56.js} +1 -1
- package/editor-web/assets/{erDiagram-KYQIGQAA-Bgy1PYQf.js → erDiagram-KYQIGQAA-CKx_HoY4.js} +2 -2
- package/editor-web/assets/esm-BZb5QMQf.js +21 -0
- package/editor-web/assets/{eventmodeling-K75KTNOO-b8j935GM.js → eventmodeling-K75KTNOO-DL4HvSrd.js} +1 -1
- package/editor-web/assets/{file-exclamation-point-C_fX4fpI.js → file-exclamation-point-_L3ElCJ5.js} +1 -1
- package/editor-web/assets/file-question-mark-DlIjUK37.js +1 -0
- package/editor-web/assets/flowDiagram-IUGLLWBU-BUnRtJ8q.js +1 -0
- package/editor-web/assets/{ganttDiagram-R7GPNTJY-B6C_nkwn.js → ganttDiagram-R7GPNTJY-N-AP4slN.js} +1 -1
- package/editor-web/assets/{gitGraph-VSP46ZUC-CWtulOri.js → gitGraph-VSP46ZUC-BKRGJKWm.js} +1 -1
- package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-BT80Z9gj.js → gitGraphDiagram-PDYL7XHY-ClwL7w2_.js} +1 -1
- package/editor-web/assets/{group-pebHQTdP.js → group-BdrTp7gi.js} +1 -1
- package/editor-web/assets/{hint-CKIaljPY.js → hint-rlht0uxG.js} +1 -1
- package/editor-web/assets/index-BedbINE5.css +2 -0
- package/editor-web/assets/index-DG2nHq4D.js +28 -0
- package/editor-web/assets/{info-OHQRW6UA-CyWiLOaB.js → info-OHQRW6UA-DpcY8t23.js} +1 -1
- package/editor-web/assets/{infoDiagram-MVDRKAX5-3TQgBeRh.js → infoDiagram-MVDRKAX5-ChtmtWni.js} +1 -1
- package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-C3RAGFl7.js → ishikawaDiagram-HPEHV2GE-BZNTuG_F.js} +1 -1
- package/editor-web/assets/iso-ahTwmFwH.js +56 -0
- package/editor-web/assets/{italic-CtlNOXN9.js → italic-zw4_eUNF.js} +1 -1
- package/editor-web/assets/{journeyDiagram-BOSHW7O7-B3ZJp3pT.js → journeyDiagram-BOSHW7O7-C3uVmZbL.js} +1 -1
- package/editor-web/assets/{kanban-definition-FNSA4HC5-ChjUoDH7.js → kanban-definition-FNSA4HC5-puEhftGG.js} +4 -4
- package/editor-web/assets/{link-CW2KxKT_.js → link-DopSU3aa.js} +1 -1
- package/editor-web/assets/{mermaid-parser.core-CqJ7hTUI.js → mermaid-parser.core-Bw8re-WE.js} +3 -3
- package/editor-web/assets/mermaid.core-Cc2GIqBr.js +44 -0
- package/editor-web/assets/{mindmap-definition-6OY57UG3-Di0DNds3.js → mindmap-definition-6OY57UG3-C6MUl_S_.js} +3 -3
- package/editor-web/assets/minus-CbPnUIOy.js +1 -0
- package/editor-web/assets/{packet-JDAUHWVQ-CkCyk5LQ.js → packet-JDAUHWVQ-C75RnvC5.js} +1 -1
- package/editor-web/assets/{pegDiagram-ECIUJNBX-DGyUszOM.js → pegDiagram-ECIUJNBX-ChjmsdV4.js} +1 -1
- package/editor-web/assets/{pie-XZMESJXO-D56l6NOA.js → pie-XZMESJXO-BaKxJQpj.js} +1 -1
- package/editor-web/assets/{pieDiagram-GNMPY74T-C6Gy4c9c.js → pieDiagram-GNMPY74T-CT2ez8pr.js} +1 -1
- package/editor-web/assets/{progress-I2qmIfF4.js → progress-CwKcXARv.js} +1 -1
- package/editor-web/assets/props-form-D5oKHfpk.js +1 -0
- package/editor-web/assets/purify.es-B9ve_eFf.js +3 -0
- package/editor-web/assets/{quadrantDiagram-D57K4MC3-CWfkAwXQ.js → quadrantDiagram-D57K4MC3-BJItlTfk.js} +1 -1
- package/editor-web/assets/{radar-ABXABTNO-BhyQtVw_.js → radar-ABXABTNO-DnLzBlTo.js} +1 -1
- package/editor-web/assets/{railroad-I3PHUGI6-CyOyOgY6.js → railroad-I3PHUGI6-D5hj6Yv3.js} +1 -1
- package/editor-web/assets/{railroad-abnf-LNEFI6M7-ExhYWNk4.js → railroad-abnf-LNEFI6M7-DUZlZoPu.js} +1 -1
- package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-B7vR6DFd.js → railroad-ebnf-DWYD2UWJ-CDyyDC6d.js} +1 -1
- package/editor-web/assets/{railroad-peg-JR7BVNR7-hqCnhLuG.js → railroad-peg-JR7BVNR7-CC3ImNnT.js} +1 -1
- package/editor-web/assets/{railroadDiagram-Y72NRBL7-D5X_R2ve.js → railroadDiagram-Y72NRBL7-Bjw-8Se5.js} +1 -1
- package/editor-web/assets/{react-Bk7NnOLX.js → react-Edyoga_4.js} +1 -1
- package/editor-web/assets/{requirementDiagram-EQYSW5RA-CIP8sDsk.js → requirementDiagram-EQYSW5RA-CDFnuEIO.js} +1 -1
- package/editor-web/assets/{row-k2eAfT-g.js → row-C_svyL8o.js} +1 -1
- package/editor-web/assets/{sankeyDiagram-SY24JHO5-BKDJlzrK.js → sankeyDiagram-SY24JHO5-CQPVLY1w.js} +1 -1
- package/editor-web/assets/schemas-moE_A7Nj.js +1 -0
- package/editor-web/assets/{scissors-BURkYWPv.js → scissors-B_xOiUhd.js} +1 -1
- package/editor-web/assets/{search-jKDvFIEU.js → search-Ba2BbT6T.js} +1 -1
- package/editor-web/assets/{sequenceDiagram-BLEHNHQU-CkRLYFZ7.js → sequenceDiagram-BLEHNHQU-BQzuLmBX.js} +1 -1
- package/editor-web/assets/{session-CUCSWPTE.js → session-s1I85rox.js} +1 -1
- package/editor-web/assets/{sigma-CY2Chbro.js → sigma-DSUsJhMn.js} +1 -1
- package/editor-web/assets/slides-oQ_C0SVJ.js +1 -0
- package/editor-web/assets/snapshots-BPJKywuN.js +1 -0
- package/editor-web/assets/{sound-DUCxe9eC.js → sound-bTlco_K3.js} +1 -1
- package/editor-web/assets/{split-Cjm6rVDC.js → split-7CVjIkSU.js} +2 -2
- package/editor-web/assets/square-arrow-out-up-right-DF5dvsSp.js +1 -0
- package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-CCvwoTcz.js → stateDiagram-v2-A6IESKWZ-DOuageUf.js} +7 -7
- package/editor-web/assets/{sticky-note-C5qUDHhC.js → sticky-note-BdkIu5_D.js} +1 -1
- package/editor-web/assets/{strikethrough-DP-7tMz0.js → strikethrough-BwXWi4zg.js} +1 -1
- package/editor-web/assets/{surface-BocGwSox.js → surface-DtCjIlrq.js} +1 -1
- package/editor-web/assets/svg-CWIBMIQ9.js +1 -0
- package/editor-web/assets/{swatch-DGdJ5SeN.js → swatch-DhztHwPU.js} +1 -1
- package/editor-web/assets/{swimlanes-B3ENRKFQ-BXgW4pi4.js → swimlanes-B3ENRKFQ-CXKkok7X.js} +1 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-C3Car2M0.js +8 -0
- package/editor-web/assets/{switch-Dwqxw1kp.js → switch-8MU4Nfxe.js} +1 -1
- package/editor-web/assets/{syntax-DSsHrzWF.js → syntax-CU_WPKxt.js} +1 -1
- package/editor-web/assets/{table-CTjNpE4W.js → table-DRbddzx0.js} +1 -1
- package/editor-web/assets/tabs-CiF1N-pL.js +1 -0
- package/editor-web/assets/tag-CIfWT8B_.js +1 -0
- package/editor-web/assets/text-align-start-Cic2-TLh.js +1 -0
- package/editor-web/assets/{textarea-BNH6Y1-o.js → textarea-D7TnPwv1.js} +1 -1
- package/editor-web/assets/{timeline-definition-JXYKGLGB-BwuUmgv1.js → timeline-definition-JXYKGLGB-DgAjAeZp.js} +3 -3
- package/editor-web/assets/{treeView-D4JQ5SDB-Da35tnkE.js → treeView-D4JQ5SDB-C0Xvnhck.js} +1 -1
- package/editor-web/assets/{treemap-SAJKECNS-4TcJReov.js → treemap-SAJKECNS-aXfKAeSX.js} +1 -1
- package/editor-web/assets/{undo-2-DUGGyBdX.js → undo-2-C47jrRp5.js} +1 -1
- package/editor-web/assets/{usecaseDiagram-WPOLBNNX-wj02og_C.js → usecaseDiagram-WPOLBNNX-CvUlBa-L.js} +1 -1
- package/editor-web/assets/{vennDiagram-Q3Y3IDCW-Cun6o3pg.js → vennDiagram-Q3Y3IDCW-qMJ1iCxs.js} +3 -3
- package/editor-web/assets/{video-DkuN7Uu7.js → video-DQrjo1TI.js} +1 -1
- package/editor-web/assets/{wardley-7MLQ67FV-DiL2aSXm.js → wardley-7MLQ67FV-DEdnH0by.js} +1 -1
- package/editor-web/assets/{wardleyDiagram-IVAIDKWA-Cll7rTnv.js → wardleyDiagram-IVAIDKWA-Bt-B2hQ5.js} +1 -1
- package/editor-web/assets/{whole-word-6DliXke2.js → whole-word-D3ZAtnkw.js} +1 -1
- package/editor-web/assets/{words-QKSIyC_P.js → words-0Ww2RyT4.js} +1 -1
- package/editor-web/assets/{words-B-7GbYO2.js → words-XlXG79Ur.js} +1 -1
- package/editor-web/assets/workbook-FSSUiIp9.js +45 -0
- package/editor-web/assets/x-DlhyIKuu.js +41 -0
- package/editor-web/assets/{xychartDiagram-4URNHDU4-s55eVncs.js → xychartDiagram-4URNHDU4-DV4bSzTb.js} +1 -1
- package/editor-web/assets/{zoom-in-C4lxmIDE.js → zoom-in-PgsC94hP.js} +1 -1
- package/editor-web/index.html +8 -7
- package/package.json +2 -2
- package/editor-web/assets/arrow-down-DzZjFrBL.js +0 -1
- package/editor-web/assets/arrow-up-hdmh9LVD.js +0 -1
- package/editor-web/assets/article-v30Q5cvX.js +0 -3
- package/editor-web/assets/calc-worker-jImBXoeb.js +0 -45
- package/editor-web/assets/channel-B8881pqR.js +0 -1
- package/editor-web/assets/chart-BC3kUUDD.js +0 -2
- package/editor-web/assets/chunk-DSNLSHJZ-BlB7YIMo.js +0 -129
- package/editor-web/assets/code-BID_OoRp.js +0 -1
- package/editor-web/assets/dist-B3RkByp0.js +0 -1
- package/editor-web/assets/dist-BAeqmRLA.js +0 -530
- package/editor-web/assets/dist-CGJv5-SE.js +0 -45
- package/editor-web/assets/dist-CUdvgRW5.js +0 -1
- package/editor-web/assets/dist-DhKxOqdu.js +0 -43
- package/editor-web/assets/dist-Dx2yV02v.js +0 -6
- package/editor-web/assets/dist-QuK0-suW.js +0 -24
- package/editor-web/assets/dist-Sl2_j-4w.js +0 -38
- package/editor-web/assets/dist-b5nFx4mV.js +0 -3
- package/editor-web/assets/dist-tteqAu5L.js +0 -4
- package/editor-web/assets/flowDiagram-IUGLLWBU-CnzC5OOy.js +0 -1
- package/editor-web/assets/index-C3A0pCmH.css +0 -2
- package/editor-web/assets/index-CFqSJBZ-.js +0 -28
- package/editor-web/assets/mermaid.core-DR2O-coV.js +0 -44
- package/editor-web/assets/minus-D1tgAHbU.js +0 -1
- package/editor-web/assets/props-form-gwp-8pGV.js +0 -1
- package/editor-web/assets/schemas-B89k2jEC.js +0 -1
- package/editor-web/assets/slides-BdaWgL_N.js +0 -1
- package/editor-web/assets/snapshots-CTS2iez5.js +0 -56
- package/editor-web/assets/svg-nJtFNJ-7.js +0 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-AFpLq-Wf.js +0 -8
- package/editor-web/assets/tabs-B0bv2mMP.js +0 -1
- package/editor-web/assets/x-BsePFh6d.js +0 -41
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{
|
|
2
|
+
import{isListedFile as v,itemNameOf as g,listedWork as T,listsFile as k,projectPath as S}from"@allyhub/formats";import{randomBytes as E}from"node:crypto";import{isAbsolute as y,relative as j,resolve as I,sep as P}from"node:path";import{AGENT_NAME as N,FILE_METHODS as R,HOST_METHODS as x,JSONRPC as c,PRESENCE_METHODS as D,PROJECT_TOOLS as l,RPC_ERROR as d,RequestSchema as M,RpcError as f,answer as p}from"@allyhub/protocol";import{listFiles as _,projectItems as C,readWork as F}from"@allyhub/build";import{Checker as A,Indexer as J}from"./background.js";import{TRASH_KEPT_DAYS as H,movesOfDeletion as L}from"./deletion.js";import{Exports as q}from"./exports.js";import{downloadsFolder as W,hasFileManager as B,revealFile as $}from"./reveal.js";import{Live as K}from"./live.js";import{Inputs as U}from"./inputs.js";import{Pages as Y}from"./pages.js";import{fileIn as O}from"./paths.js";import{kindContext as G}from"./kinds.js";import{Presence as V}from"./presence.js";import{Texts as X}from"./texts.js";import{contributedTool as z,contributedTools as Q,projectToolContext as Z,toolHandlers as ee}from"./tools.js";import{Watcher as te}from"./watcher.js";import{Writer as se}from"./writer.js";export const SERVER_METHODS={...R,"tools/call":x["tools/call"],...D};const ie=5e3,ne="sidebar";export class ProjectServer{root;writer;watcher;live;exports;presence;inputs=new U;pages;texts;placing=Promise.resolve();telling=Promise.resolve();listed;extensions;reveal;checker;serving;indexer;clients=new Map;contributed;services;held=new Map;unhearJobs;constructor(e){this.root=I(e.root),this.services={...e.jobs===void 0?{}:{jobs:e.jobs},...e.cloud===void 0?{}:{cloud:e.cloud},...e.env===void 0?{}:{env:e.env},...e.ports===void 0?{}:{ports:e.ports}},this.unhearJobs=e.jobs?.on(t=>{if(!y(t.about.id))return;const s=j(this.root,t.about.id);s===""||s.startsWith("..")||y(s)||this.notify("jobs/changed",{job:t,item:s.split(P).join("/")})})??(()=>{}),this.contributed=Q(e.kinds),this.extensions=e.extensions,this.live=new K(this.root,{kinds:e.kinds,...e.gpu===void 0?{}:{gpu:e.gpu},recordInputs:(t,s,r)=>{const n=[...r];this.listedItems().then(a=>{const h=a.find(u=>u.entry===t);h&&this.inputs.set(h.id,s,n)})}}),this.pages=new Y({root:this.root,ports:e.ports,inputs:this.inputs}),this.presence=new V(t=>{this.notify("presence/changed",{collaborators:t})}),this.texts=new X(this.root),this.watcher=new te(this.root,(t,s)=>{this.sendTo(this.watchOwner(t),"files/changed",{watch:t,changes:s})},(t,s)=>{this.live.moved(t),this.notify("project/changed",{revision:t}),this.checker?.schedule(),this.telling=this.telling.then(()=>this.tellItems(s))},{by:{kind:"agent",name:N},moved:t=>{this.placing=this.placing.then(()=>this.wroteOutside(t))}}),this.writer=new se(this.root,e.kinds,(t,s)=>{for(const r of t)this.texts.set(r.path,r.text);this.watcher.wrote(t.map(({path:r,version:n})=>({path:r,version:n})),s)},e.writable),this.reveal=e.reveal===!1?void 0:e.reveal??(B()?$:void 0),this.exports=new q(this.root,e.kinds,t=>{this.notify("export/changed",{job:t})},e.jobs===void 0?void 0:{jobs:e.jobs,nameOf:async t=>{const{items:s}=await this.tool("project/items",{}),r=s.find(n=>n.id===t);return g(r??{id:t})}},{...e.extensions?{processors:e.extensions.exportProcessors(),analyses:e.extensions.mediaAnalyses()}:{},...this.reveal===void 0||e.exportsTo===!1?{}:{saveTo:e.exportsTo??W}});const i=e.index??process.env.ALLYHUB_NO_INDEX!=="1";if(e.check!==!1){const t=i?new J({root:this.root,analyses:e.extensions?.mediaAnalyses()??[],env:e.env??process.env,emit:r=>{this.notify("index/changed",{jobs:r})},made:()=>{this.checker?.schedule(!0)}}):void 0;this.indexer=t;const s=e.extensions?.fileEditors();this.checker=new A({live:this.live,...s===void 0?{}:{files:s},emit:r=>{this.notify("check/changed",r)},...t?{needs:r=>{t.want(r)}}:{},...e.settle===void 0?{}:{settle:e.settle}})}}static open(e){const i=new ProjectServer(e);return i.watcher.start(),i.checker?.schedule(),i.texts.warm(),Promise.resolve(i)}async settled(){await this.watcher.settled(),await this.placing,await this.telling}async tellItems(e){if(e.length===0)return;const i=await this.listedItems();for(const[t,s]of this.inputs.affected(i,e))this.notify("items/changed",{item:t,paths:s})}async wroteOutside(e){let i;for(const s of e){const{changed:r,lines:n}=await this.texts.changed(s).catch(()=>({changed:!1,lines:void 0}));r&&(i={path:s,...n})}if(i===void 0)return;const t=await this.itemOf(i.path);this.presence.agent({doing:"editing",...t===void 0?{}:{item:t},source:i})}async itemOf(e){const i=await this.listedItems(),t=i.filter(s=>s.dir!==""&&e.startsWith(`${s.dir}/`)).sort((s,r)=>r.dir.length-s.dir.length);return(i.find(s=>s.entry===e)??i.find(s=>s.files!==void 0&&k(s.files,e))??t[0])?.id}async listedItems(){const e=Date.now();return this.listed!==void 0&&e-this.listed.at<ie||(this.listed={at:e,items:this.tool("project/items",{}).then(t=>t.items,()=>[])}),await this.listed?.items??[]}owners=new Map;watchOwner(e){return this.owners.get(e)}connect(e,i={}){const t=`c${E(6).toString("hex")}`;this.clients.set(t,e);const s=this.handlersFor(t,i.origin);return{id:t,receive:async r=>{const n=await this.answerOne(s,r);n&&e(n)},close:()=>{this.clients.delete(t),this.watcher.forget(t);for(const[r,n]of this.owners)n===t&&this.owners.delete(r)}}}channel(){const e=new Set,i=this.connect(t=>{const s=JSON.parse(JSON.stringify(t));queueMicrotask(()=>{for(const r of e)r(s)})});return{send:t=>{i.receive(JSON.parse(JSON.stringify(t)))},listen:t=>(e.add(t),()=>e.delete(t)),close:()=>{i.close()}}}notify(e,i){for(const t of this.clients.values())t({jsonrpc:c,method:e,params:i})}sendTo(e,i,t){e!==void 0&&this.clients.get(e)?.({jsonrpc:c,method:i,params:t})}async answerOne(e,i){const t=M.safeParse(i);if(!t.success){const r=i?.id;return typeof r!="string"&&typeof r!="number"?void 0:{jsonrpc:c,id:r,error:{code:d.invalidRequest,message:"Not a JSON-RPC request."}}}const s=t.data;return Object.hasOwn(x,s.method)&&s.method!=="tools/call"?{jsonrpc:c,id:s.id,error:{code:d.methodNotFound,message:`${s.method} is answered by the page that hosts the editor, not by allyhub dev's server.`}}:p(SERVER_METHODS,e,s)}handlersFor(e,i){const{writer:t,watcher:s}=this,r=this.toolSet(()=>this.serving?.tree(i));return{"files/read":({path:n})=>t.read(n),"files/write":async({path:n,text:a,over:h})=>({version:await t.write(n,a,h,e)}),"files/upload":async({dir:n,name:a,data:h})=>({path:await t.upload(n,a,Buffer.from(h,"base64"),e)}),"files/url":async({path:n})=>{if(await O(this.root,n),!this.serving)throw new f(d.unavailable,"This server serves no files over HTTP: only allyhub dev's does.");return{url:this.serving.file(i,n)}},"files/list":({dir:n})=>t.list(n),"files/move":async({from:n,to:a})=>({rewritten:await t.move(n,a,e)}),"files/remove":async({path:n})=>({trash:await t.remove(n,e)}),"files/trash":async()=>({entries:await t.trash()}),"files/restore":async({id:n})=>({path:await t.restore(n,e)}),"files/watch":async({paths:n})=>{for(const h of n)await O(this.root,h);const a=await s.watch(e,n);return this.owners.set(a,e),{watch:a}},"files/unwatch":({watch:n})=>(this.owners.get(n)===e&&(s.unwatch(n),this.owners.delete(n)),Promise.resolve({})),"tools/call":async({name:n,arguments:a})=>({result:await this.runTool(r,n,a)}),"presence/get":()=>Promise.resolve({collaborators:this.presence.list()})}}toolSet(e){const i=this.toolContext(e);return{core:ee(i),context:Z(i)}}async runTool(e,i,t){const s={jsonrpc:c,id:0,method:i,params:t},r=Object.hasOwn(l,i)?void 0:this.contributed.get(i);let n;if(r===void 0)n=await p(l,e.core,s);else{const a=await z(r).catch(h=>{throw new f(d.internal,h instanceof Error?h.message:String(h))});n=await p({[i]:a},{[i]:h=>a.run(h,e.context)},s)}if("error"in n)throw new f(n.error.code,n.error.message,n.error.data);return n.result}hasTool(e){return Object.hasOwn(l,e)||this.contributed.has(e)}toolContext(e){return{live:this.live,checker:this.checker,exports:this.exports,reveal:this.reveal,tree:e,extensions:this.extensions,services:this.services,held:this.held,kindContext:G(this.root,i=>this.hasTool(i),(i,t)=>this.tool(i,t)),inputs:this.inputs,pages:this.pages}}async tool(e,i,t={}){const s=await this.runTool(this.toolSet(()=>t.tree??this.serving?.tree(void 0)),e,i);return Object.hasOwn(l,e)?l[e].result.parse(s):s}async planDeletionOfItem(e){const i=await _(this.root),{listed:t}=await C(this.root,this.live.kinds,i,this.extensions?.fileEditors()??[]),s=t.find(o=>o.id===e);if(s===void 0)throw new f(d.notFound,`There is no item ${e}.`);const r=this.live.latest(),n=new Map((r?.items??[]).map(o=>[o.id,o.files])),a=o=>{const m=!v(o);return{id:o.id,entry:o.entry,ofKind:m,files:m?n.get(o.id):[{path:o.entry}],inputs:[...this.inputs.of(o.id)]}},{work:h}=await F(this.root),{moves:u,stays:b}=L({target:a(s),others:t.filter(o=>o.id!==e).map(a),listed:T(h).map(o=>S(o.file)).filter(o=>o!==s.entry),files:i}),w=r?.pieces.find(o=>o.place===e)?.title;return{item:e,name:g(s,typeof w=="string"?w:void 0),...v(s)?{}:{kind:s.kind},entry:s.entry,moves:u,stays:b}}deleteItemFromSidebar(e,i={}){return this.writer.moveToTrashAndUnlist({planNow:()=>this.planDeletionOfItem(e),keptDays:i.keptDays??H,...i.now===void 0?{}:{now:i.now}},ne)}async close(){this.unhearJobs(),this.presence.close(),this.watcher.close(),this.clients.clear();for(const e of[...this.held.values()].reverse())await Promise.resolve(e.dispose()).catch(()=>{});this.held.clear(),await this.pages.close(),await this.checker?.close(),await this.indexer?.close(),await this.exports.close(),await this.live.close()}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{readdir as
|
|
2
|
+
import{readdir as ee,realpath as te,stat as oe}from"node:fs/promises";import{setTimeout as se}from"node:timers/promises";import{join as S,relative as ie,sep as ne}from"node:path";import{openPage as ae}from"@allyhub/browser";import{KeyedStore as re}from"@allyhub/project";import{NEVER_CANCELLED as ce}from"@allyhub/extension-api";import{COMPONENT_STILLS_MAX as U,KindSnapshotSchema as fe,RpcError as z,SNAPSHOT_TREE as b,pieceSourcePath as de,snapshotAnswerPath as T,snapshotPreviewPath as le,stillPath as H,stillsIndexKey as ue,stillsIndexPath as me}from"@allyhub/protocol";import{runtimeFiles as pe}from"@allyhub/stage-page";import{itemPreview as he}from"./card.js";import{kindContext as we,kindItem as ge}from"./kinds.js";import{USE_FORMS as ye,mediaTypeOf as A}from"@allyhub/formats";import{Reach as be,pieceBundle as $e,pieceNames as Se,reachedCheck as ke,reachedSource as Ee}from"./reach.js";import{matteFile as je}from"./tree.js";const Pe="assets/";export const PAGE_RECORDING={width:1440,height:900,timeout:3e4,settle:1500};const x="https://tree.invalid/";function I(n){return typeof n=="string"?n.startsWith(x)?n.slice(x.length):n:Array.isArray(n)?n.map(I):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([$,r])=>[$,I(r)])):n}const P=n=>new TextEncoder().encode(JSON.stringify(n));async function V(n){return(await ee(n,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(r=>r.isFile()).map(r=>ie(n,S(r.parentPath,r.name)).split(ne).join("/"))}const ve=n=>oe(n).then($=>$.isFile(),()=>!1);export async function recordTree(n,$={}){const{project:r}=n,{live:l,root:w}=r;await r.watcher.settled();const g=new Map,m=(e,t,o=A(e))=>{g.set(e,{path:e,type:o,file:t})},N=(e,t)=>{g.set(e,{path:e,type:A(e),file:t,immutable:!0})},k=(e,t,o=A(e))=>{g.set(e,{path:e,type:o,bytes:t})},_=async(e,t)=>{for(const o of await V(t))m(`${e}${o}`,S(t,o))},X=l.revision,c=await l.prepared(),R=new Map;if(n.ui!==void 0)for(const e of await V(n.ui))(e.startsWith(Pe)?N:m)(`${b.editor}${e}`,S(n.ui,e));for(const[e,t]of await pe())m(`${b.runtime}${e}`,t);const O=async(e,t)=>{let o;try{o={result:I(await r.tool(e,t,{tree:x}))}}catch(i){o={error:i instanceof z?{code:i.code,message:i.message}:{code:-32603,message:i instanceof Error?i.message:""}}}const a=T(e,t);k(a,P(o));const f=t.item;return typeof f=="string"&&R.set(f,[...R.get(f)??[],a]),o},q=we(w,e=>r.hasTool(e),async(e,t)=>{const o=await O(e,t);if(o.error)throw new z(o.error.code,o.error.message);return o.result}),Q=async(e,t,o)=>{const a=new Map;for(const s of o)a.set(ue(s),s);if(a.size===0)return;const f=re.of(w,"stills"),i={stills:{}},j=u.of(e),p=[...a];for(let s=0;s<p.length;s+=U){const y=p.slice(s,s+U);(await r.tool("components/stills",{item:e,...t===""?{}:{version:t},components:y.map(([,h])=>h)},{tree:x}).catch(()=>{}))?.stills.forEach((h,Z)=>{const K=y[Z]?.[0];!h||K===void 0||(i.stills[K]=h.key,m(H(h.key),f.path(`${h.key}.webp`),"image/webp"),j?.tree.add(H(h.key)))})}const d=me(e,t);k(d,P(i),"application/json"),j?.tree.add(d)},C=(await O("project/items",{})).result,v=(C?.items??[]).filter(e=>e.kind!==void 0),Y=new Map(c.items.map(e=>[e.id,e.files])),u=new be(v.map(e=>({...e,files:Y.get(e.id)??e.files})),c.files,(c.bundle?.beside??[]).map(e=>`${b.build}${e}`)),E=r.checker?.state,D=E===void 0||E.status==="waiting"||E.status==="running"?{status:"off",revision:l.revision,problems:E?.problems??[],facts:E?.facts??[]}:E;k(T("check/results",{}),P({result:D}));for(const e of u.items){const t=u.of(e),o=new Set(c.pieces.filter(i=>i.place===e).map(i=>i.id)),a=v.find(i=>i.id===e)?.entry,f=i=>i===a||u.itemsOf(i).includes(e);t?.own.push({path:T("project/items",{}),type:"application/json",bytes:P({result:{...C,items:v.filter(i=>i.id===e)}})},{path:T("check/results",{}),type:"application/json",bytes:P({result:ke(D,o,f)})})}for(const e of c.bundle?.chunks.files??[])N(`${b.build}${e}`,S(l.pieceDir,e));for(const e of c.bundle?.beside??[])await _(`${b.build}${e}`,S(l.pieceDir,e));const F=new Set(Object.keys(c.media));for(const e of Object.keys(c.media)){const t=je(w,c.media[e]);t!==void 0&&await ve(t)&&m(`${b.matte}${e}`,t,"video/mp4")}const L=new Map,W=new Map,B=e=>({file:(t,o,a)=>{m(`${e}${t}`,o,a)},folder:(t,o)=>_(`${e}${t}`,o),bytes:(t,o,a)=>{k(`${e}${t}`,o,a)},media:t=>{F.add(t)}});for(const e of v){const t=await r.extensions?.kindProvider(e.kind);if(!t?.snapshot)continue;const o=await Promise.resolve(t.snapshot(ge(e),q,ce)).catch(()=>{}),a=fe.safeParse(o??{});if(!a.success)continue;const{stills:f,shows:i,routes:j,page:p}=a.data;p&&L.set(e.id,{...p.folder===void 0?{}:{folder:p.folder},...p.file===void 0?{}:{file:p.file}}),i&&W.set(e.id,{media:new Set(i.media),data:new Set(i.data)});for(const d of f??[])await O("components/stage",{item:e.id,version:d.version}),d.version===""&&await O("components/stage",{item:e.id}),await Q(e.id,d.version,d.components);for(const[d,s]of Object.entries(j??{})){const y=await l.routes.route(d).catch(()=>{});if(y?.route.recordItem)for(const M of s)await y.route.recordItem(M,B(d),y.context).catch(()=>{})}}for(const e of F)m(`${b.media}${e}`,S(w,e));for(const[e,t]of L){const o=await r.tool("items/page",{item:e,...t}).catch(()=>{});if(!o)continue;const a=new URL(o.url).origin,f=await ae(await l.browser(),{width:PAGE_RECORDING.width,height:PAGE_RECORDING.height,allow:i=>i===a||i.startsWith(`${a}/`)}).catch(()=>{});if(f)try{await f.goto(o.url,{timeoutMs:PAGE_RECORDING.timeout}),await f.evaluate("document.fonts.ready.then(() => true)",{timeoutMs:PAGE_RECORDING.timeout}),await se(PAGE_RECORDING.settle)}catch{}finally{await f.close()}}for(const e of u.items){const t=u.of(e);if(t)for(const o of r.inputs.of(e))if(o===""||o.endsWith("/"))for(const a of c.files)a.startsWith(o)&&t.files.add(a);else c.files.includes(o)&&t.files.add(o)}for(const e of l.routes.specs.keys()){const t=await l.routes.route(e).catch(()=>{});t?.route.record&&await t.route.record(B(e),t.context).catch(()=>{})}const G=[w,await te(w).catch(()=>w)];for(const e of c.pieces){const t=await l.source(e.id).catch(()=>{});if(!t)continue;const o=[e,...c.pieces.filter(s=>Me(c.items,e.place).has(s.place))],a=o.map(s=>({p:s,bundle:$e(c.bundle?.chunks,s.id)})),f={files:new Set(a.flatMap(s=>[...s.bundle.files])),modules:new Set(a.flatMap(s=>[...s.bundle.modules]))},i={media:new Set,data:new Set};for(const{p:s,bundle:y}of a){const M=Se({prepared:c,piece:s,reach:u,modules:y.modules,roots:G,reads:r.checker?.reads.get(s.id),shows:W.get(s.place)});for(const h of M.media)i.media.add(h);for(const h of M.data)i.data.add(h)}const j=c.pieces.filter(s=>!o.includes(s)&&!G.some(y=>f.modules.has(S(y,s.file)))).map(s=>s.id),p=de(e.id);k(p,P(Ee(t,i,j)));const d=u.of(e.place);if(d){d.tree.add(p);for(const s of f.files)d.tree.add(`${b.build}${s}`);for(const s of i.media)d.tree.add(`${b.media}${s}`),d.tree.add(`${b.matte}${s}`),d.files.add(s)}}for(const[e,t]of R)for(const o of t)u.of(e)?.tree.add(o);for(const e of c.docs)for(const t of e.shows)u.of(e.place)?.files.add(t);for(const e of c.sheets)for(const t of e.files)u.of(e.place)?.files.add(t);const J=$.preview===!1?void 0:$.preview??(e=>he(n,e));if(J)for(const e of v){const t=await J(e).catch(()=>{});if(t===void 0)continue;const o=le(e.id);k(o,Buffer.from(JSON.stringify(t)),"application/json"),u.of(e.id)?.tree.add(o)}return{revision:X,files:[...g.values()],reach:u.done(new Set(g.keys())),routes:l.routes.loads()}}function Me(n,$){const r=new Map(n.map(g=>[g.id,g])),l=new Set,w=g=>{for(const m of r.get(g)?.uses??[])m.type===ye.live&&!l.has(m.item)&&(l.add(m.item),w(m.item))};return w($),l}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{randomBytes as
|
|
3
|
-
`),this.wrote(
|
|
2
|
+
import{randomBytes as q}from"node:crypto";import{mkdir as $,readFile as O,readdir as I,rename as x,rm as N,stat as j,writeFile as A}from"node:fs/promises";import{dirname as g,extname as B,join as h,posix as C}from"node:path";import D from"write-file-atomic";import{listWork as H,moveEdits as z,movedPath as P,unlistedWork as M}from"@allyhub/build";import{CACHE_DIR as K,TRASH_DIR as f,WORK_FILE as S,WorkItemSchema as X}from"@allyhub/formats";import{RPC_ERROR as d,RpcError as p}from"@allyhub/protocol";import{DELETED_FILE as Y,emptyTrashOlderThan as G,hasErrorCode as Q,shortNameOf as V,utcStampOf as Z}from"./deletion.js";import{current as F,fileIn as m,pathProblem as J,versionOf as b}from"./paths.js";import{writeProblems as tt}from"./validate.js";export const UPLOAD_MAX_BYTES=200*1024*1024,LIST_LIMIT=5e3;const et=[K,f];function it(v){const i=(v.split(/[/\\]/u).pop()??"").replace(/\p{Cc}/gu,"").replace(/^\.+/u,"").trim();return i===""?"file":i}export class Writer{root;kinds;wrote;writable;queue=Promise.resolve();constructor(t,i,n=()=>{},o=()=>Promise.resolve()){this.root=t,this.kinds=i,this.wrote=n,this.writable=o}serial(t){const i=async()=>(await this.writable(),t()),n=this.queue.then(i,i);return this.queue=n.catch(()=>{}),n}async read(t){const i=await F(await m(this.root,t));return i?{text:i.bytes.toString("utf8"),version:i.version}:{text:"",version:null}}write(t,i,n,o){return this.serial(async()=>{const s=await m(this.root,t,{write:!0}),a=await F(s),w=a?.version??null;if(w!==n)throw new p(d.conflict,`${t} changed since it was read.`,{text:a?.bytes.toString("utf8")??"",version:w});const c=await tt(t,i,this.kinds,this.root);if(c.length>0)throw new p(d.invalid,`${t} would not be a file AllyHub can read: ${c[0]??""}`,{problems:c});const r=b(i);return r===w||(await $(g(s),{recursive:!0}),await D(s,i),this.wrote([{path:t,version:r,text:i}],o)),r})}upload(t,i,n,o){return n.length>UPLOAD_MAX_BYTES?Promise.reject(new p(d.invalid,`${i} is larger than ${String(UPLOAD_MAX_BYTES/1024/1024)} MB.`)):this.serial(async()=>{const s=it(i),a=B(s),w=s.slice(0,s.length-a.length);for(let c=1;;c++){const r=c===1?s:`${w}-${String(c)}${a}`,e=t===""?r:`${t}/${r}`,u=await m(this.root,e,{write:!0});if(!await y(u))return await $(g(u),{recursive:!0}),await A(u,n,{flag:"wx"}),this.wrote([{path:e,version:b(n)}],o),e}})}move(t,i,n){return this.serial(async()=>{const o=await m(this.root,t,{write:!0}),s=await m(this.root,i,{write:!0});if(i===t||i.startsWith(`${t}/`))throw new p(d.invalid,`${t} cannot move into itself.`);if(!await y(o))throw new p(d.notFound,`There is no ${t}.`);if(await y(s))throw new p(d.conflict,`${i} is taken.`,{text:"",version:null});const a=await z(this.root,t,i);for(const e of a)await D(h(this.root,e.path),e.text);const w=await R(t,o);await $(g(s),{recursive:!0}),await x(o,s);const c=w.map(e=>({path:e,version:null}));for(const e of w){const u=P(e,t,i);c.push({path:u,version:(await F(h(this.root,u)))?.version??null})}const r=a.map(e=>P(e.path,t,i));for(const e of a)P(e.path,t,i)===e.path&&c.push({path:e.path,version:b(e.text)});return this.wrote(c,n),r})}remove(t,i){return this.serial(async()=>{const n=await m(this.root,t,{write:!0});if(!await y(n))throw new p(d.notFound,`There is no ${t}.`);const o=await R(t,n),s=`${String(Date.now())}-${q(4).toString("hex")}`,a=h(this.root,f,s,...t.split("/"));await $(g(a),{recursive:!0}),await x(n,a);const w=o.map(k=>({path:k,version:null})),c=h(this.root,S),r=await O(c,"utf8").catch(()=>{}),e=r===void 0?void 0:M(r,t);e!==void 0&&(await D(c,e.text),w.push({path:S,version:b(e.text)}));const u={path:t,removed:Date.now(),...e===void 0?{}:{listed:e.items}};return await A(h(this.root,f,`${s}.json`),`${JSON.stringify(u)}
|
|
3
|
+
`),this.wrote(w,i),s})}moveToTrashAndUnlist(t,i){return this.serial(async()=>{const n=await t.planNow(),{item:o,name:s,kind:a,entry:w}=n,c=(t.now??(()=>new Date))();await G(this.root,t.keptDays,c);const r=`${Z(c)}-${V(o)}`;let e=`${f}/${r}`;for(let l=2;await y(h(this.root,e));l++)e=`${f}/${r}-${String(l)}`;const u=h(this.root,S),k=await O(u,"utf8").catch(l=>{if(!Q(l,"ENOENT"))throw l}),T=k===void 0?void 0:M(k,w),W=[];try{for(const l of n.moves){const E=await m(this.root,l,{write:!0}),L=h(this.root,e,...l.split("/"));await $(g(L),{recursive:!0}),await x(E,L),W.push(l)}}catch(l){for(const E of W.reverse())await x(h(this.root,e,...E.split("/")),h(this.root,...E.split("/")));throw await N(h(this.root,e),{recursive:!0,force:!0}),l}const U={deletedAt:c.toISOString(),item:o,name:s,...a===void 0?{}:{kind:a},listed:T?.entries??[],files:n.moves.map(l=>({path:l}))};await $(h(this.root,e),{recursive:!0}),await A(h(this.root,e,Y),`${JSON.stringify(U,null,2)}
|
|
4
|
+
`);const _=n.moves.map(l=>({path:l,version:null}));return T!==void 0&&(await D(u,T.text),_.push({path:S,version:b(T.text)})),this.wrote(_,i),{plan:n,trash:e,moved:n.moves}})}async trash(){const t=h(this.root,f),i=await I(t).catch(()=>[]),n=[];for(const o of i){if(!o.endsWith(".json"))continue;const s=await O(h(t,o),"utf8").then(a=>JSON.parse(a)).catch(()=>{});typeof s?.path!="string"||typeof s.removed!="number"||J(s.path)!==void 0||n.push({id:o.slice(0,-5),path:s.path,removed:s.removed})}return n.sort((o,s)=>s.removed-o.removed)}restore(t,i){return this.serial(async()=>{const n=(await this.trash()).find(e=>e.id===t);if(!n)throw new p(d.notFound,`Nothing in the bin is ${t}.`);const o=await m(this.root,n.path,{write:!0});if(await y(o))throw new p(d.conflict,`${n.path} is there again: move it before putting this back.`,{text:"",version:null});const s=h(this.root,f,t,...n.path.split("/")),a=await O(h(this.root,f,`${t}.json`),"utf8").then(e=>JSON.parse(e).listed).catch(()=>{});await $(g(o),{recursive:!0}),await x(s,o),await N(h(this.root,f,t),{recursive:!0,force:!0}),await N(h(this.root,f,`${t}.json`),{force:!0});const w=await R(n.path,o),c=(Array.isArray(a)?a:[]).flatMap(e=>{const u=X.safeParse(e);return u.success?[u.data]:[]});for(const e of c)await H(this.root,e);c.length>0&&w.push(S);const r=[];for(const e of w)r.push({path:e,version:(await F(h(this.root,e)))?.version??null});return this.wrote(r,i),n.path})}async list(t){const i=t===""?this.root:await m(this.root,t),n=[],o=[],s=async(a,w)=>{const c=await I(a,{withFileTypes:!0}).catch(()=>[]);for(const r of c.sort((e,u)=>e.name.localeCompare(u.name))){if(n.length>=LIST_LIMIT)return;const e=w===""?r.name:`${w}/${r.name}`;if(J(e)===void 0&&!(et.some(u=>e===u)&&!(t===e||t.startsWith(`${e}/`)))){if(r.isDirectory())o.push(e),await s(h(a,r.name),e);else if(r.isFile()){const u=await j(h(a,r.name)).catch(()=>{});u&&n.push({path:e,size:u.size,modified:u.mtimeMs})}}}};return await s(i,t),{files:n,dirs:o}}}const y=v=>j(v).then(()=>!0,()=>!1);async function R(v,t){const i=await j(t).catch(()=>{});if(!i)return[];if(!i.isDirectory())return[v];const n=[],o=await I(t,{recursive:!0,withFileTypes:!0});for(const s of o)s.isFile()&&n.push(C.join(v,C.relative(t.split("\\").join("/"),h(s.parentPath,s.name).split("\\").join("/"))));return n}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{chartBook as Qe,embeddedChartXml as Je}from"@allyhub/chart";import{chartFrame as et,chartWords as tt,docChart as nt}from"./chart.js";import{BACKGROUNDS as Ie,TEXT_COLORS as Se,hex as ee}from"./color.js";import{columnWidths as it}from"./columns.js";import{COMPONENT_WIDTH as rt,componentName as ot}from"./component.js";import{blockId as $e,captionNumbers as st,contentsTitle as at,numberedCaption as Oe,writtenInChinese as dt,withoutTitle as ct}from"./captions.js";import{sourceList as lt,withSources as ht}from"./cite.js";import{HEADING_RULE_SPACE as ut,cardKept as pt,columnsKept as ft,docParts as gt,headingAnchors as mt,pageAccent as wt,trendSvg as yt}from"./html.js";import{effectiveLook as Fe,LIST_STEP as At,lineHeightPt as Tt,resolvePage as Et,sizePt as He}from"./page.js";import{splitTitle as Rt}from"./title.js";import{markdownOf as St}from"./markdown.js";import{charsAcross as Xe,columnShares as zt,emptyHead as Lt,numberColumns as Mt}from"./table.js";import{DRAWN_CODE as ve}from"./math.js";import{PAPER as te,TONE_COLORS as Ue,tagColors as
|
|
3
|
-
`).map((s,R)=>new M({...d,text:s,...R>0?{break:1}:{}}))},U=(e,t={})=>e.flatMap(i=>i.note!==void 0?S.has(i.note.toLowerCase())?z.has(i)?[new n.FootnoteReferenceRun(S.get(i.note.toLowerCase())??1)]:[new M({text:String(S.get(i.note.toLowerCase())??1),style:"FootnoteReference"})]:[]:i.text===""&&i.href?.startsWith("#")===!0?xe(i.href.slice(1),i.styles,t):i.href!==void 0
|
|
4
|
-
`).map((R,C)=>new M({text:R,font:X,size:o.small*2,...C>0?{break:1}:{}}))})]}case"columns":return[ye(e,t)];case"chart":{const d=r.numbers.get(e),s=d===void 0?void 0:e.title,{chart:R,problems:C}=nt(s===void 0?e:ct(e),u),A=he(y.DASHED,Me);if(!R)return[new h({...L(t),alignment:m.CENTER,border:{top:A,bottom:A,left:A,right:A},children:[new M({text:[e.title??"Chart",...C].join(": "),color:de})]})];const v=et(e,t.frame),b=(t.room-t.indent)/ue,P=Math.min(1,b/v.width);return k.push({chart:R,width:Math.round(v.width*P),height:Math.round(v.height*P),words:tt(e,R)}),[new h({...L(t),alignment:m.CENTER,keepNext:s!==void 0,spacing:{line:240,lineRule:n.LineRuleType.AUTO},children:[new M({text:`${je}${String(k.length)}`})]}),...s===void 0?[]:[new h({...L(t),alignment:m.CENTER,style:"Caption",children:T(e.id,[new M({text:Oe(s,d)})])})]]}case"image":return ae(e,t,u.picture?.(e.src),e.alt??e.caption??e.src,r.numbers.get(e),e.id);case"component":{const d=u.component?.(e);if(d)return ae(e,t,d,"",r.numbers.get(e),e.id);const s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:ot(e),color:de})]})]}case"table":return[...e.caption===void 0?[]:[new h({...L(t),style:"Caption",keepNext:!0,spacing:{after:E(o.caption)},children:T(e.id,[new M({text:Oe(e.caption,r.numbers.get(e))})])})],se(e,t),...J()];case"pagebreak":return[new h({spacing:{before:0,after:0,line:20,lineRule:n.LineRuleType.EXACT},children:[new n.PageBreak]})];case"bibliography":{const{page:d}=r,s=d.textIndent>0?Math.round(d.textIndent*d.size*20):480;return r.sources.map(R=>new h({...L(t),alignment:m.LEFT,indent:{left:t.indent+s,hanging:s},spacing:{after:E(o.after)},children:R.pieces.map(C=>{const A=C.italic?{italics:!0}:{};return new M({text:C.text,...A})})}))}case"toc":{const d=e.levels??3,s=r.headings.filter(A=>A.level<=d).map(A=>{const v=r.anchors.get(A)??"",b=u.headingPage?.(v),P=r.bookmarks.get(v);return{title:A.content.map(q=>q.text).join(""),level:A.level,...b===void 0?{}:{page:b},...P===void 0?{}:{href:P}}}),R=Math.min(...s.map(A=>A.level)),C=at(e,r.chinese);return[...C===""?[]:[new h({style:qe,text:C})],new n.TableOfContents(void 0,{hyperlink:!0,headingStyleRange:`1-${String(d)}`,beginDirty:!1,cachedEntries:s.map(A=>({...A,level:A.level-R+1}))})]}case"note":return[];case"divider":return[new h({...L(t),spacing:{before:E(o.divider),after:E(o.divider),line:20,lineRule:n.LineRuleType.EXACT},border:{bottom:{style:y.SINGLE,color:Le,size:4,space:0}}})];case"embed":{const d=/^<\s*([A-Za-z][\w.]*)/.exec(e.source.trim())?.[1],s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:d??"",color:de})]})]}case"source":return[];case"bullet":case"numbered":case"check":return[]}};function V(e,t){const i=[];let f,g;for(const a of e){if(!
|
|
5
|
-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${Ve}/package" Target="../embeddings/${
|
|
2
|
+
import{chartBook as Qe,embeddedChartXml as Je}from"@allyhub/chart";import{chartFrame as et,chartWords as tt,docChart as nt}from"./chart.js";import{BACKGROUNDS as Ie,TEXT_COLORS as Se,hex as ee}from"./color.js";import{columnWidths as it}from"./columns.js";import{COMPONENT_WIDTH as rt,componentName as ot}from"./component.js";import{blockId as $e,captionNumbers as st,contentsTitle as at,numberedCaption as Oe,writtenInChinese as dt,withoutTitle as ct}from"./captions.js";import{sourceList as lt,withSources as ht}from"./cite.js";import{HEADING_RULE_SPACE as ut,cardKept as pt,columnsKept as ft,docParts as gt,headingAnchors as mt,pageAccent as wt,trendSvg as yt}from"./html.js";import{effectiveLook as Fe,LIST_STEP as At,lineHeightPt as Tt,resolvePage as Et,sizePt as He}from"./page.js";import{splitTitle as Rt}from"./title.js";import{markdownOf as St}from"./markdown.js";import{charsAcross as Xe,columnShares as zt,emptyHead as Lt,numberColumns as Mt,withTableData as Ct}from"./table.js";import{DRAWN_CODE as ve}from"./math.js";import{PAPER as te,TONE_COLORS as Ue,tagColors as Nt}from"./paper.js";import{COVER_ASPECT as bt,everyBlock as ze,firstNoteMarks as xt,noteNumbers as Dt,statTone as It}from"./model.js";const ue=15,Ot=1440/25.4,Y=n=>Math.round(n*Ot),Ge="ListParagraph",Be="bullets",vt=1.8,pe=At*20,We={sans:{latin:"Calibri"},serif:{latin:"Cambria"},mono:{latin:"Courier New"},times:{latin:"Times New Roman"},song:{latin:"Times New Roman",eastAsia:"宋体"},hei:{latin:"Arial",eastAsia:"黑体"},fangsong:{latin:"Times New Roman",eastAsia:"仿宋"},kai:{latin:"Times New Roman",eastAsia:"楷体"},xiaobiaosong:{latin:"Times New Roman",eastAsia:"方正小标宋简体"}},Pe="Courier New",W=n=>n.slice(1).toUpperCase(),le=W(te.ink),fe=W(te.lead),Pt=Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=","base64"),Le=W(te.rule),ge=W(te.ruleStrong),Me=W(te.ruleMid),Ce=W(te.stone),_t=W(te.stone3),de=W(te.leadSoft),je="ALLYHUB-CHART-";function $t(n){return/[\u3040-\u30ff]/u.test(n)?"Yu Gothic":/[\uac00-\ud7af]/u.test(n)?"Malgun Gothic":"Microsoft YaHei"}const Ft=/^(https?:|mailto:)/i,Ne=n=>({indent:0,level:0,room:n,frame:rt}),Ke=n=>({...n,indent:n.indent+pe,level:Math.min(n.level+1,8)}),Ht=400,Xt=n=>n.type==="bullet"||n.type==="numbered"||n.type==="check";function Ut(n,u,w){const c=w/ue,S=Math.floor(Math.min(u??n.width,c));return{width:S,height:Math.round(S*n.height/n.width)}}const qe="TOCHeading";function Gt(n,u,w,c,S,z,r){const{AlignmentType:m,BorderStyle:y,ExternalHyperlink:l,ImageRun:x,Paragraph:h,ShadingType:Z,Table:F,TableCell:_,TableLayoutType:H,TableRow:G,TextRun:M,WidthType:p}=n,N=e=>{const t=e.filter(i=>!(i instanceof n.TableOfContents));return t.at(-1)instanceof h?t:[...t,Q(0)]},X={ascii:Pe,hAnsi:Pe,cs:Pe,eastAsia:w},$=new Set([1]);let ne=0;const k=[],B=e=>({type:Z.CLEAR,color:"auto",fill:e}),he=(e,t,i=4)=>({style:e,color:t,size:i,space:4}),o=r.page.spacing,E=e=>Math.round(e*20),Q=e=>new h({spacing:{before:0,after:E(e),line:14,lineRule:n.LineRuleType.EXACT}}),J=()=>o.after>0?[Q(o.after)]:[],j=e=>e==="center"?m.CENTER:e==="right"?m.RIGHT:e==="justify"?m.JUSTIFIED:void 0,ie=(e,t,i,f={})=>{if(t.tag!==void 0){const s=Nt(t.tag),R={...f,color:W(s.fg),size:Math.round((i.size??r.page.size*2)*.85),shading:B(W(s.bg)),...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{}};return[new M({...R,text:` ${e.replace(/\n/gu," ")} `})]}const g=ee(t.color,Se)??i.color,a=ee(t.background,Ie),d={...f,...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{},...t.underline?{underline:{}}:{},...t.strike?{strike:!0}:{},...g===void 0?{}:{color:g},...i.size===void 0?{}:{size:i.size},...t.code?{font:X,shading:B(a??Ce)}:a===void 0?{}:{shading:B(a)}};return e.split(`
|
|
3
|
+
`).map((s,R)=>new M({...d,text:s,...R>0?{break:1}:{}}))},U=(e,t={})=>e.flatMap(i=>i.note!==void 0?S.has(i.note.toLowerCase())?z.has(i)?[new n.FootnoteReferenceRun(S.get(i.note.toLowerCase())??1)]:[new M({text:String(S.get(i.note.toLowerCase())??1),style:"FootnoteReference"})]:[]:i.text===""&&i.href?.startsWith("#")===!0?xe(i.href.slice(1),i.styles,t):i.href!==void 0&&Ft.test(i.href)?[new l({link:i.href,children:ie(i.text,i.styles,t,{style:"Hyperlink"})})]:ie(i.text,i.styles,t)),xe=(e,t,i)=>{const f=decodeURIComponent(e),g=r.refs.get(f)??"",a=r.bookmarks.get(f);return g===""?[]:a===void 0?ie(g,t,i):[new n.InternalHyperlink({anchor:a,children:ie(g,t,i,{style:"Hyperlink"})})]},T=(e,t)=>{const i=e===void 0?void 0:r.bookmarks.get(e);return i===void 0?t:[new n.Bookmark({id:i,children:t})]},D=e=>{const t=j(e?.align),i=ee(e?.background,Ie);return{...t===void 0?{}:{alignment:t},...i===void 0?{}:{shading:B(i)}}},L=e=>e.indent===0?{}:{indent:{left:e.indent}},re=e=>{const t={style:y.SINGLE,color:e,size:4};return{top:t,bottom:t,left:t,right:t}},me=(e,t)=>{const i=ee(e.look?.background,Ie)??Ce,f=ee(e.look?.color,Se),g=t.room-t.indent,a=e.icon===void 0?0:E(r.page.size*vt)+E(o.box.side),d=g-a,s=(R,C)=>({top:E(o.box.top),bottom:E(Math.max(o.box.top-o.after,0)),left:R,right:C,marginUnitType:p.DXA});return new F({layout:H.FIXED,width:{size:g,type:p.DXA},columnWidths:a===0?[d]:[a,d],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:[...e.icon===void 0?[]:[new _({width:{size:a,type:p.DXA},shading:B(i),borders:re(i),margins:s(E(o.box.side),0),children:[new h({children:[new M({text:e.icon})]})]})],new _({width:{size:d,type:p.DXA},shading:B(i),borders:re(i),margins:s(a===0?E(o.box.side):0,E(o.box.side)),children:[new h({children:U(e.content,{color:f})}),...N(V(e.children??[],Ne(d-E(o.box.side))))]})]})]})},we=(e,t)=>{const i=t.room-t.indent,f=E(o.card.side),g=[...e.title===void 0?[]:[new h({spacing:{after:e.subtitle===void 0?E(o.after):0},children:U([{text:e.title,styles:{bold:!0}}])})],...e.subtitle===void 0?[]:[new h({spacing:{after:E(o.after)},children:[new M({text:e.subtitle,color:fe,size:o.small*2})]})]];return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:[i],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:pt(e,r.page),children:[new _({width:{size:i,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(Math.max(o.card.top-o.after,0)),left:f,right:f,marginUnitType:p.DXA},children:N([...g,...V(e.children??[],Ne(i-2*f))])})]})]})},oe=(e,t)=>{const i=t.room-t.indent,f=E(o.gap),g=e.stats.length,a=Math.floor((i-f*(g-1))/g),d=e.stats.flatMap((b,P)=>P===0?[a]:[f,a]),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s},C=E(o.card.side),A=o.small*2,v=e.stats.flatMap((b,P)=>{const q=It(b),ce=[...b.delta===void 0?[]:[new M({text:b.delta,color:W(Ue[q]),size:A})],...b.note===void 0?[]:[new M({text:`${b.delta===void 0?"":" "}${b.note}`,color:fe,size:A})]],Ae=a-2*C,Te=b.trend===void 0?[]:[new h({spacing:{before:60,after:0,line:240},children:[new x({type:"svg",data:Buffer.from(yt(b.trend,Ue[q]).replace("<svg ",`<svg xmlns="http://www.w3.org/2000/svg" width="${String(Math.round(Ae/15))}" height="24" `)),fallback:{type:"png",data:Pt},transformation:{width:Math.round(Ae/15),height:24}})]})],I=new _({width:{size:a,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(o.card.top),left:C,right:C,marginUnitType:p.DXA},children:[new h({spacing:{after:0},children:[new M({text:b.label,color:fe,size:A})]}),new h({spacing:{after:0,line:240,lineRule:n.LineRuleType.AUTO},children:U([{text:b.value,styles:{bold:!0}}],{size:o.figure*2})}),...ce.length===0?[]:[new h({spacing:{after:0},children:ce})],...Te]}),O=new _({width:{size:f,type:p.DXA},borders:R,children:[new h({children:[]})]});return P===0?[I]:[O,I]});return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:d,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:v})]})},se=(e,t)=>{const i=t.room-t.indent,f=Math.max(1,...e.rows.map(I=>I.length)),g=Array.from({length:f},(I,O)=>e.widths?.[O]?(e.widths[O]??0)*ue:void 0),a=g.reduce((I,O)=>I+(O??0),0),d=zt(e,{across:Xe(Math.max(i-a,0)/ue,o.small),margins:Xe(2*o.cell.side*96/72,o.small)}),s=g.reduce((I,O,_e)=>I+(O===void 0?d[_e]??1:0),0)||1,R=Math.max(i-a,0),C=g.map((I,O)=>I??R*(d[O]??1)/s),A=C.reduce((I,O)=>I+O,0)||1,v=Math.min(1,i/A),b=C.map(I=>Math.round(I*v)),P=Lt(e),q=(e.head===void 0||e.head==="both")&&!P,ce=e.head==="column"||e.head==="both",Ae=Mt(e),Te=P?e.rows.slice(1):e.rows;return new F({layout:H.FIXED,width:{size:b.reduce((I,O)=>I+O,0),type:p.DXA},columnWidths:b,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:Te.map((I,O)=>new G({tableHeader:q&&O===0,cantSplit:!0,children:Array.from({length:f},(_e,Ee)=>{const Re=q&&O===0,ke=ce&&Ee===0&&!Re;return new _({width:{size:b[Ee]??0,type:p.DXA},...Re?{shading:B(_t)}:{},borders:{top:O===0?{style:y.SINGLE,size:8,color:ge}:{style:y.NONE,size:0,color:"auto"},left:{style:y.NONE,size:0,color:"auto"},right:{style:y.NONE,size:0,color:"auto"},bottom:O===Te.length-1?{style:y.SINGLE,size:8,color:ge}:Re?{style:y.SINGLE,size:6,color:ge}:{style:y.SINGLE,size:4,color:Me}},margins:{top:E(o.cell.top),bottom:E(o.cell.top),left:E(o.cell.side),right:E(o.cell.side),marginUnitType:p.DXA},children:[new h({spacing:{after:0},...Ae.has(Ee)?{alignment:m.RIGHT}:{},children:U(I[Ee]??[],{bold:ke||Re,size:o.small*2})})]})})}))})},ae=(e,t,i,f,g,a)=>{const d=j(e.align),s={...L(t),...d===void 0?{}:{alignment:d}},R=i===void 0?void 0:e.caption,C=R!==void 0,A=[new h({...s,keepNext:C,...i?{spacing:{line:240,lineRule:n.LineRuleType.AUTO,...C?{after:E(o.caption)}:{}}}:{},children:i?[new x({type:i.type,data:i.data,transformation:Ut(i,e.width,t.room-t.indent),altText:{name:e.alt??"",title:e.caption??e.alt??"",description:e.alt??""}})]:[new M({text:f,color:de})]})];return R!==void 0&&A.push(new h({...s,style:"Caption",children:T(a,[new M({text:Oe(R,g)})])})),A},ye=(e,t)=>{const i=t.room-t.indent,f=e.columns.map(A=>A.width??1),g=f.reduce((A,v)=>A+v,0)||1,a=f.map(A=>Math.round(i*A/g)),d=it(e,t.frame),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s,insideHorizontal:s,insideVertical:s},C=Ht/2;return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:a,borders:R,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:ft(e,r.page),children:e.columns.map((A,v)=>{const b=a[v]??0,P=v===0?0:C,q=v===e.columns.length-1?0:C,ce=N(V(A.blocks,{indent:0,level:0,room:b-P-q,frame:d[v]??t.frame}));return new _({width:{size:b,type:p.DXA},borders:R,margins:{top:0,bottom:0,left:P,right:q,marginUnitType:p.DXA},children:ce})})})]})},K=(e,t,i)=>{const f=ee(e.look?.color,Se),g=V(e.children??[],Ke(t)),a=D(e.look),d=Ge;return e.type==="check"?[new h({...a,...L(t),style:d,children:[new M({text:e.checked?"☑ ":"☐ "}),...U(e.content,{color:f})]}),...g]:[new h({...a,style:d,numbering:e.type==="bullet"?{reference:Be,level:t.level}:{reference:`start-${String(i.start)}`,level:t.level,instance:i.id},children:U(e.content,{color:f})}),...g]},De=(e,t)=>{const i="look"in e?e.look:void 0,f=ee(i?.color,Se),g=D(i),a=()=>"children"in e?V(e.children??[],Ke(t)):[];switch(e.type){case"paragraph":case"toggle":return[new h({...r.sets.align&&e.look?.align===void 0?{alignment:m.JUSTIFIED}:{},...g,...r.sets.indent&&e.type==="paragraph"?{indent:{left:t.indent,firstLine:Math.round(r.page.textIndent*r.page.size*20)}}:L(t),children:U(e.content,{color:f})}),...a()];case"heading":return[new h({...g,...L(t),...e===r.title?{heading:n.HeadingLevel.TITLE}:{heading:n.HeadingLevel[`HEADING_${String(e.level)}`]},children:T(r.anchors.get(e),U(e.content,{color:f}))}),...a()];case"quote":return[new h({...g,indent:{left:t.indent+E(o.quote)},border:{left:{style:y.SINGLE,color:c??ge,size:c?12:6,space:Math.floor(o.quote-(c?1.5:.75))}},children:U(e.content,{color:f??fe})}),...a()];case"callout":return[me(e,t),...J()];case"card":return[we(e,t),...J()];case"stats":return[oe(e,t),...J()];case"code":{if(e.language===ve.math||e.language===ve.mermaid){const R=u.drawn?.(e);if(R)return ae({...e.language===ve.math?{}:{align:"center"}},t,R,"")}const d=R=>({style:y.SINGLE,color:Ce,size:4,space:R}),s=E(o.box.side+.5);return[new h({indent:{left:t.indent+s,right:s},shading:B(Ce),border:{top:d(o.box.top),bottom:d(o.box.top),left:d(o.box.side),right:d(o.box.side)},keepLines:!0,children:e.code.split(`
|
|
4
|
+
`).map((R,C)=>new M({text:R,font:X,size:o.small*2,...C>0?{break:1}:{}}))})]}case"columns":return[ye(e,t)];case"chart":{const d=r.numbers.get(e),s=d===void 0?void 0:e.title,{chart:R,problems:C}=nt(s===void 0?e:ct(e),u),A=he(y.DASHED,Me);if(!R)return[new h({...L(t),alignment:m.CENTER,border:{top:A,bottom:A,left:A,right:A},children:[new M({text:[e.title??"Chart",...C].join(": "),color:de})]})];const v=et(e,t.frame),b=(t.room-t.indent)/ue,P=Math.min(1,b/v.width);return k.push({chart:R,width:Math.round(v.width*P),height:Math.round(v.height*P),words:tt(e,R)}),[new h({...L(t),alignment:m.CENTER,keepNext:s!==void 0,spacing:{line:240,lineRule:n.LineRuleType.AUTO},children:[new M({text:`${je}${String(k.length)}`})]}),...s===void 0?[]:[new h({...L(t),alignment:m.CENTER,style:"Caption",children:T(e.id,[new M({text:Oe(s,d)})])})]]}case"image":return ae(e,t,u.picture?.(e.src),e.alt??e.caption??e.src,r.numbers.get(e),e.id);case"component":{const d=u.component?.(e);if(d)return ae(e,t,d,"",r.numbers.get(e),e.id);const s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:ot(e),color:de})]})]}case"table":return[...e.caption===void 0?[]:[new h({...L(t),style:"Caption",keepNext:!0,spacing:{after:E(o.caption)},children:T(e.id,[new M({text:Oe(e.caption,r.numbers.get(e))})])})],se(e,t),...J()];case"pagebreak":return[new h({spacing:{before:0,after:0,line:20,lineRule:n.LineRuleType.EXACT},children:[new n.PageBreak]})];case"bibliography":{const{page:d}=r,s=d.textIndent>0?Math.round(d.textIndent*d.size*20):480;return r.sources.map(R=>new h({...L(t),alignment:m.LEFT,indent:{left:t.indent+s,hanging:s},spacing:{after:E(o.after)},children:R.pieces.map(C=>{const A=C.italic?{italics:!0}:{};return new M({text:C.text,...A})})}))}case"toc":{const d=e.levels??3,s=r.headings.filter(A=>A.level<=d).map(A=>{const v=r.anchors.get(A)??"",b=u.headingPage?.(v),P=r.bookmarks.get(v);return{title:A.content.map(q=>q.text).join(""),level:A.level,...b===void 0?{}:{page:b},...P===void 0?{}:{href:P}}}),R=Math.min(...s.map(A=>A.level)),C=at(e,r.chinese);return[...C===""?[]:[new h({style:qe,text:C})],new n.TableOfContents(void 0,{hyperlink:!0,headingStyleRange:`1-${String(d)}`,beginDirty:!1,cachedEntries:s.map(A=>({...A,level:A.level-R+1}))})]}case"note":return[];case"divider":return[new h({...L(t),spacing:{before:E(o.divider),after:E(o.divider),line:20,lineRule:n.LineRuleType.EXACT},border:{bottom:{style:y.SINGLE,color:Le,size:4,space:0}}})];case"embed":{const d=/^<\s*([A-Za-z][\w.]*)/.exec(e.source.trim())?.[1],s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:d??"",color:de})]})]}case"source":return[];case"bullet":case"numbered":case"check":return[]}};function V(e,t){const i=[];let f,g;for(const a of e){if(!Xt(a)){f=void 0,g=void 0,i.push(...De(a,t));continue}if(f===void 0||g===void 0||g.type==="numbered"!=(a.type==="numbered")){const d=a.type==="numbered"?a.start??1:1;$.add(d),f={id:++ne,start:d}}g=a,i.push(...K(a,t,f))}return i.flatMap((a,d)=>a instanceof F&&i[d+1]instanceof F?[a,Q(0)]:[a])}return{charts:k,body:(e,t)=>V(e,Ne(t)),footnotes:e=>Object.fromEntries([...ze(e)].flatMap(t=>{if(t.type!=="note")return[];const i=S.get(t.label.toLowerCase());if(i===void 0)return[];const f=V(t.children??[],Ne(Y(r.page.width)-Y(r.page.margins.left+r.page.margins.right))).filter(g=>g instanceof h);return[[String(i),{children:[new h({spacing:{after:40},children:U(t.content,{size:18,color:fe})}),...f]}]]})),numbering:()=>[{reference:Be,levels:Array.from({length:9},(e,t)=>({level:t,format:n.LevelFormat.BULLET,text:["•","◦","▪"][t%3]??"•",alignment:m.LEFT,style:{paragraph:{indent:{left:(t+1)*pe,hanging:pe}}}}))},...[...$].sort((e,t)=>e-t).map(e=>({reference:`start-${String(e)}`,levels:Array.from({length:9},(t,i)=>({level:i,format:[n.LevelFormat.DECIMAL,n.LevelFormat.LOWER_LETTER,n.LevelFormat.LOWER_ROMAN][i%3]??n.LevelFormat.DECIMAL,text:`%${String(i+1)}.`,alignment:m.LEFT,...i===0?{start:e}:{},style:{paragraph:{indent:{left:(i+1)*pe,hanging:pe}}}}))}))]}}const Bt="1980-01-01T00:00:00Z",Ye=9525,Ve="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Wt=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function jt(n,u,w,c,S){return n.forEach((z,r)=>{const m=String(r+1),y=`rIdChart${m}`,l=`Microsoft_Excel_Worksheet${m}.xlsx`;S(`word/charts/chart${m}.xml`,Je(z.chart,{width:z.width*.75,height:z.height*.75},"rId1",{frameless:!0})),S(`word/charts/_rels/chart${m}.xml.rels`,`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
5
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${Ve}/package" Target="../embeddings/${l}"/></Relationships>`),S(`word/embeddings/${l}`,Qe(z.chart)),w=w.replace("</Relationships>",`<Relationship Id="${y}" Type="${Ve}/chart" Target="charts/chart${m}.xml"/></Relationships>`),c=c.replace("</Types>",`<Override ContentType="application/vnd.openxmlformats-officedocument.drawingml.chart+xml" PartName="/word/charts/chart${m}.xml"/></Types>`);const x=String(z.width*Ye),h=String(z.height*Ye),Z=`<w:r><w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${x}" cy="${h}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="0" name="Chart ${m}" descr="${Wt(z.words)}"/><wp:cNvGraphicFramePr/><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" r:id="${y}"/></a:graphicData></a:graphic></wp:inline></w:drawing></w:r>`;u=u.replace(new RegExp(`<w:r>(?:(?!<w:r>).)*?<w:t[^>]*>${je}${m}</w:t></w:r>`,"su"),Z)}),n.length>0&&!c.includes('Extension="xlsx"')&&(c=c.replace("</Types>",'<Default ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Extension="xlsx"/></Types>')),{document:u,rels:w,types:c}}function Kt(n,u,w){const c=u.unzipSync(n),S=p=>{const N=c[p];return N&&new TextDecoder().decode(N)},z=(p,N)=>{c[p]=typeof N=="string"?new TextEncoder().encode(N):N},r="word/document.xml",m="word/_rels/document.xml.rels",y="[Content_Types].xml",l=jt(w,S(r)??"",S(m)??"",S(y)??"",z);z(y,l.types);let x=l.document,h=l.rels;[...new Set([...x.matchAll(/w:hyperlink [^>]*r:id="([^"]+)"/g)].map(p=>p[1]??""))].forEach((p,N)=>{const X=`rIdLink${String(N+1)}`;x=x.split(`"${p}"`).join(`"${X}"`),h=h.split(`"${p}"`).join(`"${X}"`)});let F=0;x=x.replace(/<wp:docPr id="\d+"/g,()=>`<wp:docPr id="${String(++F)}"`);const _=new Map;x=x.replace(/<w:bookmarkStart w:name="([^"]*)" w:id="(\d+)"/g,(p,N,X)=>{const $=String(_.size+1);return _.set(X,$),`<w:bookmarkStart w:name="${N}" w:id="${$}"`}),x=x.replace(/<w:bookmarkEnd w:id="(\d+)"/g,(p,N)=>{const X=_.get(N);return X===void 0?p:`<w:bookmarkEnd w:id="${X}"`}),z(r,x),z(m,h);const H="docProps/core.xml",G=S(H);G!==void 0&&z(H,G.replace(/(<dcterms:(?:created|modified)[^>]*>)[^<]*/g,`$1${Bt}`));const M=Object.fromEntries(Object.entries(c).sort(([p],[N])=>p<N?-1:1));return u.zipSync(M,{mtime:new Date(1980,0,1)})}const be=(n,u)=>{const w=We[n];return{ascii:w.latin,hAnsi:w.latin,cs:w.latin,eastAsia:w.eastAsia??u}};function qt(n,u,w){const c={left:[],center:[],right:[]};u.left!==void 0&&c.left.push(u.left),u.center!==void 0&&c.center.push(u.center),u.right!==void 0&&c.right.push(u.right),u.outside!==void 0&&c[w.odd?"right":"left"].push(u.outside),u.inside!==void 0&&c[w.odd?"left":"right"].push(u.inside);const S={size:Math.round(w.size*2),color:w.color,font:be(w.face,w.eastAsia)},z=r=>r.split(/(\{title\}|\{section\}|\{page\}|\{pages\})/u).filter(m=>m!=="").map(m=>m==="{page}"?new n.TextRun({...S,children:[n.PageNumber.CURRENT]}):m==="{pages}"?new n.TextRun({...S,children:[n.PageNumber.TOTAL_PAGES]}):m==="{section}"?new n.SimpleField(`STYLEREF "heading ${String(w.section)}"`,""):new n.TextRun({...S,text:m==="{title}"?w.title:m}));return new n.Paragraph({style:w.style,tabStops:[{type:n.TabStopType.CENTER,position:Math.round(w.width/2)},{type:n.TabStopType.RIGHT,position:w.width}],children:[...z(c.left.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(c.center.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(c.right.join(" "))]})}const Ze=(n,u,w,c)=>({run:{...u?.font===void 0?{}:{font:be(n.font,w)},...u?.size===void 0?{}:{size:Math.round(n.size*2)},...u?.weight===void 0?{}:{bold:n.weight==="bold"},...u?.italic===void 0?{}:{italics:n.italic}},paragraph:u?.align===void 0?{}:{alignment:n.align==="center"?c.AlignmentType.CENTER:n.align==="right"?c.AlignmentType.RIGHT:c.AlignmentType.LEFT}});function Yt(n){const u=new Map,w=new Set;return n.forEach((c,S)=>{const z=c.replace(/[^A-Za-z0-9_]/gu,"_").replace(/^[^A-Za-z]+/u,"");let r=`b_${z}`.slice(0,32);(w.has(r)||z==="")&&(r=`b_${String(S)}_${z}`.slice(0,40)),w.add(r),u.set(c,r)}),u}export async function docxOf(n,u,w,c={}){const S=c.page??{},z=Fe(S).citationStyle??"apa",r=ht(Ct(w,c),c.sources??[],z,"block"),m=lt(w,c.sources??[],z),y=Fe(S),l=Et(S),x=We[l.font].eastAsia??$t(St(r)),h=be(l.font,x),Z=ee(wt(c.page),{}),F=mt(r),_=st(r,S),H=new Map;for(const T of ze(r)){const D=$e(T),L=_.get(T);D!==void 0&&L!==void 0&&H.set(D,L.label)}for(const[T,D]of F)T.type==="heading"&&H.set(D,T.content.map(L=>L.text).join(""));const{title:G}=Rt(r),M=[...ze(r)].filter(T=>T.type==="heading"&&T!==G),p=Yt([...F.values(),...[...ze(r)].flatMap(T=>{const D=$e(T);return D===void 0?[]:[D]})]),N=Gt(n,c,x,Z,Dt(r),xt(r),{page:l,sets:{indent:y.textIndent!==void 0&&y.textIndent>0,align:y.textAlign==="justify"},numbers:_,refs:H,bookmarks:p,anchors:F,title:G,headings:M,chinese:dt(r),sources:m}),X=gt(r),$={width:Y(l.width),height:Y(l.height)},ne={top:Y(l.margins.top),bottom:Y(l.margins.bottom),left:Y(l.margins.left),right:Y(l.margins.right)},k=c.cover,B=[l.header,l.footer].some(T=>T!==void 0&&(T.outside!==void 0||T.inside!==void 0)),he=X.map((T,D)=>{const L=T.landscape?$.height:$.width,re=L-ne.left-ne.right,me=N.body(T.blocks,re);if(D===0&&k){const K=Math.round(L/ue);me.unshift(new n.Paragraph({spacing:{before:0,after:0},children:[new n.ImageRun({type:k.type,data:k.data,transformation:{width:K,height:Math.round(K*bt)},floating:{horizontalPosition:{relative:n.HorizontalPositionRelativeFrom.PAGE,offset:0},verticalPosition:{relative:n.VerticalPositionRelativeFrom.PAGE,offset:0},allowOverlap:!1,margins:{bottom:324e3},wrap:{type:n.TextWrappingType.TOP_AND_BOTTOM}},altText:{name:"Cover",title:"Cover",description:""}})]}))}const we=(K,De,V)=>{if(K===void 0)return;const e=t=>qt(n,K,{style:V,odd:t,width:re,title:c.title??"",section:Math.min(...M.map(i=>i.level),6),face:K.font??l.font,eastAsia:x,size:K.size===void 0?Math.max(7.5,l.size*.75):He(K.size),color:De?de:le});return{default:e(!0),...B?{even:e(!1)}:{}}},oe=we(l.header,y.header===void 0,"Header"),se=we(l.footer,y.footer===void 0,"Footer"),ae=D===0&&k!==void 0&&oe!==void 0,ye=y.grid===void 0?void 0:{type:n.DocumentGridType.LINES_AND_CHARS,linePitch:Math.round(Tt(l)*20),charSpace:Math.round(l.textWidth/25.4*72/y.grid.chars-l.size)*4096};return{properties:{page:{size:{width:Math.min($.width,$.height),height:Math.max($.width,$.height),...T.landscape||$.width>$.height?{orientation:n.PageOrientation.LANDSCAPE}:{}},margin:{...ne,header:Math.max(0,ne.top-Y(7)-Math.round(l.size*20*1.2)),footer:Math.max(0,ne.bottom-Y(7)-Math.round(l.size*20*1.2))}},...ye===void 0?{}:{grid:ye},...ae?{titlePage:!0}:{}},...oe===void 0?{}:{headers:{default:new n.Header({children:[oe.default]}),...oe.even?{even:new n.Header({children:[oe.even]})}:{},...ae?{first:new n.Header({children:[]})}:{}}},...se===void 0?{}:{footers:{default:new n.Footer({children:[se.default]}),...se.even?{even:new n.Footer({children:[se.even]})}:{},...ae?{first:new n.Footer({children:[se.default]})}:{}}},children:me}}),o=l.lineHeight,E={spacing:{after:Math.round(l.paragraphSpacing*l.size*20),..."pt"in o?{line:Math.round(o.pt*20),lineRule:n.LineRuleType.EXACT}:{line:Math.round(o.multiple*240),lineRule:n.LineRuleType.AUTO}}},Q=l.spacing,J=T=>Math.round(T*20),j=T=>{const D=y.headings?.[T],L=Ze(l.headings[T],D,x,n);return{run:{size:Math.round(l.headings[T].size*2),bold:!0,font:h,color:le,...L.run},paragraph:{spacing:{before:J(Q.heading.before),after:J(Q.heading.after)},keepNext:!0,keepLines:!0,...l.headings[T].rule?{border:{bottom:{style:n.BorderStyle.SINGLE,size:4,color:Le,space:ut}}}:{},...L.paragraph}}},ie=Ze(l.title,y.title,x,n),U=new n.Document({creator:"AllyHub",lastModifiedBy:"AllyHub",...c.title===void 0?{}:{title:c.title},...B?{evenAndOddHeaderAndFooters:!0}:{},numbering:{config:N.numbering()},styles:{default:{document:{run:{font:h,size:Math.round(l.size*2),color:le},paragraph:E},hyperlink:{run:{color:Z??le,underline:{color:Z??ge}}},title:{run:{size:Math.round(l.title.size*2),bold:!0,font:h,color:le,...ie.run},paragraph:{spacing:{before:0,after:J(Q.title)},keepNext:!0,...ie.paragraph}},heading1:j(1),heading2:j(2),heading3:j(3),heading4:j(4),heading5:j(5),heading6:j(6)},paragraphStyles:[{id:qe,name:"TOC Heading",basedOn:"Normal",next:"Normal",quickFormat:!0,...j(1)},{id:"Caption",name:"caption",basedOn:"Normal",next:"Normal",quickFormat:!0,run:{size:Q.small*2,color:de},paragraph:{spacing:{before:0}}},{id:Ge,name:"List Paragraph",basedOn:"Normal",quickFormat:!0,paragraph:{contextualSpacing:!0}},...[["Header",l.header,y.header===void 0],["Footer",l.footer,y.footer===void 0]].flatMap(([T,D,L])=>D===void 0?[]:[{id:T,name:T.toLowerCase(),basedOn:"Normal",run:{size:Math.round((D.size===void 0?Math.max(7.5,l.size*.75):He(D.size))*2),color:L?de:le,font:be(D.font??l.font,x)},paragraph:{spacing:{before:0,after:0,line:240}}}])]},sections:he,footnotes:N.footnotes(r)}),xe=await n.Packer.toBuffer(U);return Kt(new Uint8Array(xe),u,N.charts)}
|