allyhub 0.9.0 → 0.10.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 +8 -0
- package/dist/commands/auth.js +4 -4
- package/dist/commands/cloud-tools.js +11 -11
- package/dist/commands/frames/compare.js +2 -2
- package/dist/commands/frames/piece.js +1 -1
- package/dist/commands/frames.js +8 -8
- package/dist/commands/index.js +1 -1
- package/dist/commands/inspect/common.js +4 -2
- package/dist/commands/inspect/facts.js +3 -3
- package/dist/commands/inspect/layout.js +1 -1
- package/dist/commands/orgs.js +2 -2
- package/dist/help.js +4 -4
- package/dist/main.js +8 -7
- package/dist/node_modules/@allyhub/3d-extension/package.json +34 -2
- 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/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-extension/package.json +2 -1
- package/dist/node_modules/@allyhub/canvas-extension/skills/allyhub/references/canvas.md +4 -24
- package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +2 -2
- package/dist/node_modules/@allyhub/chart/dist/chart.js +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/client.d.ts +10 -0
- package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/config.d.ts +9 -0
- package/dist/node_modules/@allyhub/cloud/dist/config.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/credentials.d.ts +4 -4
- package/dist/node_modules/@allyhub/cloud/dist/credentials.js +2 -2
- package/dist/node_modules/@allyhub/cloud/dist/device.d.ts +12 -0
- package/dist/node_modules/@allyhub/cloud/dist/device.js +2 -0
- 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/components/r/callout.json +1 -1
- package/dist/node_modules/@allyhub/components/src/callout.ts +98 -13
- 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/captions.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/docx.js +4 -4
- package/dist/node_modules/@allyhub/doc/dist/html.js +50 -47
- package/dist/node_modules/@allyhub/doc/dist/model.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/page.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/paper.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/table.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/write.js +22 -22
- package/dist/node_modules/@allyhub/doc/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-extension/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/doc-extension/package.json +17 -2
- 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/faces.d.ts +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +87 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +89 -0
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +50 -0
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/i18n/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
- package/dist/node_modules/@allyhub/image-extension/package.json +16 -1
- package/dist/node_modules/@allyhub/image-extension/skills/allyhub/references/images.md +7 -39
- 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/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/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/media/package.json +1 -1
- package/dist/node_modules/@allyhub/media-extension/dist/vision/faces.js +1 -1
- package/dist/node_modules/@allyhub/media-extension/package.json +7 -4
- package/dist/node_modules/@allyhub/model/package.json +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
- package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +16 -0
- package/dist/node_modules/@allyhub/piece/dist/page/locate.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +6 -0
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/project/dist/version.js +1 -1
- package/dist/node_modules/@allyhub/project/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +132 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +19 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.d.ts +337 -0
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +153 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +4 -2
- package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +43 -188
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +1 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +1 -0
- package/dist/node_modules/@allyhub/protocol/dist/mail.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +51 -91
- package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +3 -3
- package/dist/node_modules/@allyhub/protocol/package.json +5 -1
- package/dist/node_modules/@allyhub/registry/package.json +1 -1
- package/dist/node_modules/@allyhub/render/dist/look.js +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/player/clips.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/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/index.d.ts +2 -2
- package/dist/node_modules/@allyhub/scenery/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/moire.d.ts +45 -5
- package/dist/node_modules/@allyhub/scenery/dist/moire.js +2 -2
- package/dist/node_modules/@allyhub/scenery/dist/phone.d.ts +4 -3
- package/dist/node_modules/@allyhub/scenery/dist/phone.js +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/grade.d.ts +7 -0
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/grade.js +2 -0
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/index.d.ts +4 -3
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/index.js +1 -1
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/screens.d.ts +1 -1
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/screens.js +1 -1
- package/dist/node_modules/@allyhub/scenery-host/dist/measure/facts.js +1 -1
- package/dist/node_modules/@allyhub/scenery-host/dist/page/screens.d.ts +8 -0
- package/dist/node_modules/@allyhub/scenery-host/dist/page/screens.js +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/define.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/kernels.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/maths.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/types.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/chart.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/move.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/print.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/inspect.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/printed.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/values.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/write.js +15 -15
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/formula.js +2 -2
- 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/sax.js +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.js +3 -2
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/export.js +4 -4
- package/dist/node_modules/@allyhub/sheet-extension/package.json +22 -3
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
- package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-extension/package.json +20 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/import/code.js +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/dist/import/index.js +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/common.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/shapes.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/read/text.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/shapes.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/text.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/dist/xml.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
- package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +5 -5
- 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/fonts/caladea/400-italic.css +19 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/400.css +19 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700-italic.css +19 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700.css +19 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/LICENSE +93 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/cambria.css +76 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400-italic.css +79 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400.css +79 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700-italic.css +79 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700.css +79 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/LICENSE +93 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/courier-new.css +316 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400-italic.css +79 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400.css +79 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700-italic.css +79 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700.css +79 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/LICENSE +93 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-400-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-400-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-700-italic.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-700-normal.woff2 +0 -0
- package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/times-new-roman.css +316 -0
- package/dist/node_modules/@allyhub/stage-page/dist/host.js +1 -1
- package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.html +3 -0
- package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +19 -19
- package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-extension/package.json +16 -1
- package/dist/node_modules/@allyhub/video-measure/dist/version.js +1 -1
- package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/dist/phone.js +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/dist/held.js +2 -0
- package/dist/node_modules/@allyhub/website-extension/dist/project-tools.js +24 -1
- package/dist/node_modules/@allyhub/website-extension/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/website-extension/package.json +49 -2
- package/dist/node_modules/@allyhub/x-extension/package.json +34 -4
- package/dist/node_modules/@allyhub/x-extension/skills/allyhub/references/x.md +7 -62
- package/dist/node_modules/@allyhub/x-model/package.json +1 -1
- package/dist/node_modules/@allyhub/x-view/dist/article.js +1 -1
- package/dist/node_modules/@allyhub/x-view/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/x-view/dist/post.js +2 -2
- package/dist/node_modules/@allyhub/x-view/package.json +1 -1
- package/dist/package.json +10 -10
- package/dist/text/facts-text.js +5 -5
- package/dist/text/index.js +1 -1
- package/dist/text/long-text.js +4 -0
- package/dist/works.js +1 -1
- package/editor-web/assets/{abnfDiagram-WEYOIA3C-CN5PiJYY.js → abnfDiagram-WEYOIA3C-CjAmWsNR.js} +1 -1
- package/editor-web/assets/alt-DnBZJzEh.js +4 -0
- package/editor-web/assets/{architecture-WOLXFQ4H-BnvZtQYk.js → architecture-WOLXFQ4H-DeeKhyhZ.js} +1 -1
- package/editor-web/assets/{architectureDiagram-ZHVYKT53-tkcEcFQ8.js → architectureDiagram-ZHVYKT53-b32qTaJg.js} +1 -1
- package/editor-web/assets/{arrow-up-DTP2yVSU.js → arrow-up-L4YV_65f.js} +1 -1
- package/editor-web/assets/article-DLMjAdbP.js +73 -0
- package/editor-web/assets/{audio-lines-Ti8-m7H2.js → audio-lines-BFcM7G2L.js} +1 -1
- package/editor-web/assets/{blockDiagram-RJAE7QA3-DhqEIpie.js → blockDiagram-RJAE7QA3-BNbnMNmw.js} +1 -1
- package/editor-web/assets/button-Chk675Xu.js +41 -0
- package/editor-web/assets/{c4Diagram-XDPPPE54-Bg9G95tl.js → c4Diagram-XDPPPE54-BEuemvMw.js} +1 -1
- package/editor-web/assets/calc-worker-D2pGis6e.js +45 -0
- package/editor-web/assets/channel-EzYq4r0d.js +1 -0
- package/editor-web/assets/chart-Be9Hj5GL.js +1 -0
- package/editor-web/assets/choice-BgmBh4yu.js +1 -0
- package/editor-web/assets/{chunk-2E7WHVMD-C8Ve9lAa.js → chunk-2E7WHVMD-Zb5nPx_e.js} +1 -1
- package/editor-web/assets/{chunk-4EMNKR2T-BDWwPUnT.js → chunk-4EMNKR2T-DSEM2reX.js} +1 -1
- package/editor-web/assets/{chunk-55XCU76K-BQiNPKgx.js → chunk-55XCU76K-BOZa_65H.js} +1 -1
- package/editor-web/assets/{chunk-7S6XSTFO-QoEt-6jf.js → chunk-7S6XSTFO-DeiGeVpB.js} +1 -1
- package/editor-web/assets/{chunk-AQDTSKZB-BeuwIv0-.js → chunk-AQDTSKZB-fPuQFBJc.js} +1 -1
- package/editor-web/assets/{chunk-DSNLSHJZ-BHW7sLAz.js → chunk-DSNLSHJZ-5vdnoak2.js} +1 -1
- package/editor-web/assets/{chunk-HAGFOTED-bbGED0hu.js → chunk-HAGFOTED-DFF2mZJ1.js} +1 -1
- package/editor-web/assets/{chunk-HNE4Q36P-FltWp8yo.js → chunk-HNE4Q36P-g6-ZLbTg.js} +1 -1
- package/editor-web/assets/{chunk-NQOKRVIF-NeQzr6kH.js → chunk-NQOKRVIF-o3hNcHMJ.js} +1 -1
- package/editor-web/assets/{chunk-UHW7PFBP-eA4-WUhn.js → chunk-UHW7PFBP-BQiDI9dK.js} +1 -1
- package/editor-web/assets/{chunk-VQ5W62QI-BPPv325z.js → chunk-VQ5W62QI-CJlMXWWz.js} +1 -1
- package/editor-web/assets/{chunk-WQQL4CDK-DOCIz7Te.js → chunk-WQQL4CDK-pNBU8dXv.js} +1 -1
- package/editor-web/assets/{chunk-YZO67HFG-Dc_ihQJi.js → chunk-YZO67HFG-2x-BiWd-.js} +1 -1
- package/editor-web/assets/{chunk-ZAUX2LTX-CoqwCPSm.js → chunk-ZAUX2LTX-etFStEM8.js} +1 -1
- package/editor-web/assets/{chunk-ZCHMQSOR-CZUQPkJx.js → chunk-ZCHMQSOR-B3AYRhIY.js} +1 -1
- package/editor-web/assets/{classDiagram-v2-4MYWR3UA-DUh9c50k.js → classDiagram-v2-4MYWR3UA-6y2yX0oq.js} +1 -1
- package/editor-web/assets/collaborator-LRd0hELn.js +1 -0
- package/editor-web/assets/createLucideIcon-CPS-TrJJ.js +1 -0
- package/editor-web/assets/{cynefin-EF2NZ3EQ-DUTZiog0.js → cynefin-EF2NZ3EQ-CX4BTQQe.js} +1 -1
- package/editor-web/assets/{cynefinDiagram-WF24UDRP-oAjpfbrU.js → cynefinDiagram-WF24UDRP-LbDkOTy3.js} +1 -1
- package/editor-web/assets/{dagre-NK4GIZVX-BrKvKCvb.js → dagre-NK4GIZVX-wCKQk7hi.js} +1 -1
- package/editor-web/assets/{diagram-CBK3MWTC-GekVRnmm.js → diagram-CBK3MWTC-a9fofQwk.js} +1 -1
- package/editor-web/assets/{diagram-I5XIIV2D-CDd1VFRT.js → diagram-I5XIIV2D-UCLZWch5.js} +1 -1
- package/editor-web/assets/{diagram-ODIL2UCW-535RISTn.js → diagram-ODIL2UCW-CAEe88Lp.js} +1 -1
- package/editor-web/assets/{diagram-PFBEJUXE-MXzzKCGG.js → diagram-PFBEJUXE-Cp1o45bs.js} +1 -1
- package/editor-web/assets/{diagram-RJA3I4VV-vKVwkQxY.js → diagram-RJA3I4VV-c6OVxDyq.js} +1 -1
- package/editor-web/assets/{diagram-TYUNFSNR-UwGAiQLx.js → diagram-TYUNFSNR-BVRWslDM.js} +1 -1
- package/editor-web/assets/{dist-CKyfo5RM.js → dist--KKyT5zP.js} +1 -1
- package/editor-web/assets/dist-1k0MHB3i.js +1 -0
- package/editor-web/assets/dist-B9KHJqL5.js +4 -0
- package/editor-web/assets/dist-BbJyrhIY.js +1 -0
- package/editor-web/assets/dist-CJXCQxQM.js +37 -0
- package/editor-web/assets/dist-D9xQGwe9.js +5 -0
- package/editor-web/assets/dist-DFiLzbx8.js +219 -0
- package/editor-web/assets/{dist-shKo7XVN.js → dist-DIPV6xfF.js} +1 -1
- package/editor-web/assets/dist-Dp-fQMtx.js +6 -0
- package/editor-web/assets/dist-Duw28VxJ.js +16 -0
- package/editor-web/assets/{dist-9ymlIMhr.js → dist-DwGhfliS.js} +1 -1
- package/editor-web/assets/dist-OBE2IIYP.js +24 -0
- package/editor-web/assets/dist-j6ZLVcgf.js +38 -0
- package/editor-web/assets/{ebnfDiagram-V4P3TTPT-73yGokYa.js → ebnfDiagram-V4P3TTPT-KdOTJgFu.js} +1 -1
- package/editor-web/assets/{elk-QONTBCTQ-BW6V9y6a.js → elk-QONTBCTQ-Cmlrp7qB.js} +1 -1
- package/editor-web/assets/{erDiagram-KYQIGQAA-BPqIJ22h.js → erDiagram-KYQIGQAA-CBM7-aQm.js} +1 -1
- package/editor-web/assets/{eventmodeling-K75KTNOO-_VZ8jvuy.js → eventmodeling-K75KTNOO-CEoJkbuW.js} +1 -1
- package/editor-web/assets/flowDiagram-IUGLLWBU-Xm2E2ib_.js +1 -0
- package/editor-web/assets/{ganttDiagram-R7GPNTJY-DZ157JN2.js → ganttDiagram-R7GPNTJY-D4S6ZSYD.js} +1 -1
- package/editor-web/assets/{gitGraph-VSP46ZUC-fmcNL9bq.js → gitGraph-VSP46ZUC-BvkL6RSh.js} +1 -1
- package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-DiZDyksR.js → gitGraphDiagram-PDYL7XHY-lTGguloH.js} +1 -1
- package/editor-web/assets/hint-BimUgJms.js +1 -0
- package/editor-web/assets/index-C-i_iuxN.js +28 -0
- package/editor-web/assets/index-Cxh_Shkm.css +2 -0
- package/editor-web/assets/{info-OHQRW6UA-V06620kN.js → info-OHQRW6UA-DvKzqNvp.js} +1 -1
- package/editor-web/assets/{infoDiagram-MVDRKAX5-CbIgheWX.js → infoDiagram-MVDRKAX5-D7hCpehs.js} +1 -1
- package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-D5oJQPkG.js → ishikawaDiagram-HPEHV2GE-Bg93sZQe.js} +1 -1
- package/editor-web/assets/{italic-CDhZKo_q.js → italic-BQBwRTe8.js} +1 -1
- package/editor-web/assets/{journeyDiagram-BOSHW7O7-BZEv6JI4.js → journeyDiagram-BOSHW7O7-CKm_KONJ.js} +1 -1
- package/editor-web/assets/{kanban-definition-FNSA4HC5-CLG1R8y_.js → kanban-definition-FNSA4HC5-BKknnpTR.js} +1 -1
- package/editor-web/assets/{mermaid-parser.core-DxDwXM7z.js → mermaid-parser.core-BzqkDnqL.js} +3 -3
- package/editor-web/assets/{mermaid.core-tU55ZwVG.js → mermaid.core-CEpvTOAe.js} +4 -4
- package/editor-web/assets/{mindmap-definition-6OY57UG3-CYf4zzAh.js → mindmap-definition-6OY57UG3-BJ0qG8Wi.js} +1 -1
- package/editor-web/assets/minus-oPj1GxwA.js +1 -0
- package/editor-web/assets/{packet-JDAUHWVQ-DsHeKYNL.js → packet-JDAUHWVQ-ew3kvyFm.js} +1 -1
- package/editor-web/assets/{pegDiagram-ECIUJNBX-CQyh6TTa.js → pegDiagram-ECIUJNBX-DqUS2xit.js} +1 -1
- package/editor-web/assets/{pie-XZMESJXO-3vCIvpNB.js → pie-XZMESJXO-DTIAMPGm.js} +1 -1
- package/editor-web/assets/{pieDiagram-GNMPY74T-DF5yGBLn.js → pieDiagram-GNMPY74T-DoKOE02-.js} +1 -1
- package/editor-web/assets/progress-CPEbDOoN.js +6 -0
- package/editor-web/assets/{quadrantDiagram-D57K4MC3-B7pxlDYP.js → quadrantDiagram-D57K4MC3-DauOpYun.js} +1 -1
- package/editor-web/assets/{radar-ABXABTNO-cpEA41mL.js → radar-ABXABTNO-BvMJXUU-.js} +1 -1
- package/editor-web/assets/{railroad-I3PHUGI6-BLyy5R2c.js → railroad-I3PHUGI6-D3jdJmhM.js} +1 -1
- package/editor-web/assets/{railroad-abnf-LNEFI6M7-Y-oyol19.js → railroad-abnf-LNEFI6M7-Dm8ZpmPj.js} +1 -1
- package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-o58wHZsr.js → railroad-ebnf-DWYD2UWJ-oc0Du7Ag.js} +1 -1
- package/editor-web/assets/{railroad-peg-JR7BVNR7-CcD3PXZ8.js → railroad-peg-JR7BVNR7-CMrQL_7U.js} +1 -1
- package/editor-web/assets/{railroadDiagram-Y72NRBL7-BuCC4eyy.js → railroadDiagram-Y72NRBL7-y99z0C7i.js} +1 -1
- package/editor-web/assets/react-DztDSW4P.js +1 -0
- package/editor-web/assets/{repeat-2-C5PCbNsg.js → repeat-2-DJi4LW5C.js} +1 -1
- package/editor-web/assets/{requirementDiagram-EQYSW5RA-Dp-JFGn4.js → requirementDiagram-EQYSW5RA-jMr_uoF6.js} +1 -1
- package/editor-web/assets/row-ClBisiBs.js +1 -0
- package/editor-web/assets/{sankeyDiagram-SY24JHO5-rYuCqEvw.js → sankeyDiagram-SY24JHO5-DcUyx03Q.js} +1 -1
- package/editor-web/assets/schemas-68mjUjP5.js +1 -0
- package/editor-web/assets/{sequenceDiagram-BLEHNHQU-DryW8x6d.js → sequenceDiagram-BLEHNHQU-R4X8wRCd.js} +1 -1
- package/editor-web/assets/session-2u9U7koW.js +1 -0
- package/editor-web/assets/slides-BByblSSR.js +1 -0
- package/editor-web/assets/snapshots-C9KV-Y2_.js +56 -0
- package/editor-web/assets/sound-DExlNJbb.js +1 -0
- package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-Bnp0XfpT.js → stateDiagram-v2-A6IESKWZ-BqvXKbCA.js} +1 -1
- package/editor-web/assets/{strikethrough-DJckA35o.js → strikethrough-CyUBnGTl.js} +1 -1
- package/editor-web/assets/{svg-BjM9RazX.js → svg-lBRT-uhy.js} +1 -1
- package/editor-web/assets/swatch-1c1uVn1z.js +1 -0
- package/editor-web/assets/{swimlanes-B3ENRKFQ-BiRRhhbd.js → swimlanes-B3ENRKFQ-hjTXIc6M.js} +1 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-BLfytmPY.js +8 -0
- package/editor-web/assets/switch-D0K-K8-C.js +1 -0
- package/editor-web/assets/{syntax-CC6QYhCz.js → syntax-Bih_jv7W.js} +1 -1
- package/editor-web/assets/tabs-CxxOnGLR.js +1 -0
- package/editor-web/assets/{textarea-BGtPqZdB.js → textarea-Fu93tFO3.js} +1 -1
- package/editor-web/assets/{timeline-definition-JXYKGLGB-D-Q5ZtDF.js → timeline-definition-JXYKGLGB-BcSoN4Dq.js} +1 -1
- package/editor-web/assets/{trash-2-Bjj6cWzP.js → trash-2-BAKAeziW.js} +1 -1
- package/editor-web/assets/{treeView-D4JQ5SDB-B6DDatXq.js → treeView-D4JQ5SDB-CsFN2jrc.js} +1 -1
- package/editor-web/assets/{treemap-SAJKECNS-D7j5ZhiI.js → treemap-SAJKECNS-DP1eqXJ2.js} +1 -1
- package/editor-web/assets/{undo-2-yOSG766T.js → undo-2-DQ5CBmki.js} +1 -1
- package/editor-web/assets/{usecaseDiagram-WPOLBNNX-tkrdKUJB.js → usecaseDiagram-WPOLBNNX-BGxa0osF.js} +1 -1
- package/editor-web/assets/{vennDiagram-Q3Y3IDCW-Ch4XbSnD.js → vennDiagram-Q3Y3IDCW-D2XhTF49.js} +1 -1
- package/editor-web/assets/video-CDbPX4Cr.js +1 -0
- package/editor-web/assets/{wardley-7MLQ67FV-Bynt7qNQ.js → wardley-7MLQ67FV-DM3jMAbZ.js} +1 -1
- package/editor-web/assets/{wardleyDiagram-IVAIDKWA-DRuSgm_L.js → wardleyDiagram-IVAIDKWA-Bf-DaZEg.js} +1 -1
- package/editor-web/assets/{xychartDiagram-4URNHDU4-DctpvfkL.js → xychartDiagram-4URNHDU4-dp-mdcWd.js} +1 -1
- package/editor-web/index.html +6 -5
- package/package.json +2 -2
- package/editor-web/assets/alt-BOVao_9S.js +0 -4
- package/editor-web/assets/article-B6YCzhj8.js +0 -73
- package/editor-web/assets/calc-worker-B5-fDWnb.js +0 -45
- package/editor-web/assets/channel-C26aBI4o.js +0 -1
- package/editor-web/assets/chart-BOnxneyw.js +0 -1
- package/editor-web/assets/choice-O5nwc2N0.js +0 -1
- package/editor-web/assets/collaborator-BJU5qwHd.js +0 -1
- package/editor-web/assets/createLucideIcon-B3B95oX5.js +0 -1
- package/editor-web/assets/dist-C6NqUEG4.js +0 -16
- package/editor-web/assets/dist-C9UGmCG9.js +0 -6
- package/editor-web/assets/dist-CAk5bjBm.js +0 -1
- package/editor-web/assets/dist-CRaWqNwq.js +0 -37
- package/editor-web/assets/dist-CwIBc7HQ.js +0 -1
- package/editor-web/assets/dist-DXRmkezB.js +0 -38
- package/editor-web/assets/dist-EKK5i0dG.js +0 -219
- package/editor-web/assets/dist-hHJlpLWo.js +0 -5
- package/editor-web/assets/dist-oYKcwWUj.js +0 -4
- package/editor-web/assets/dist-wrKxBrVu.js +0 -24
- package/editor-web/assets/flowDiagram-IUGLLWBU-ouDQYiTr.js +0 -1
- package/editor-web/assets/hint-_AQWCDMj.js +0 -1
- package/editor-web/assets/index-BsstP-cI.js +0 -28
- package/editor-web/assets/index-DQRcmxBO.css +0 -2
- package/editor-web/assets/minus-Cgmm6ncD.js +0 -1
- package/editor-web/assets/progress-0B_TVsPi.js +0 -6
- package/editor-web/assets/react-BP46yLMB.js +0 -1
- package/editor-web/assets/react-pgBZqVxJ.js +0 -96
- package/editor-web/assets/schemas-Ewwjtbf4.js +0 -1
- package/editor-web/assets/session-DiI9KYRI.js +0 -1
- package/editor-web/assets/slides-CCwgBcGH.js +0 -1
- package/editor-web/assets/sound-CqryteNl.js +0 -1
- package/editor-web/assets/swatch-DL3HqIjW.js +0 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-BkOls8Tv.js +0 -8
- package/editor-web/assets/switch-DltnKqN-.js +0 -1
- package/editor-web/assets/tabs-C-re0Kxn.js +0 -1
- package/editor-web/assets/video-DXFiCNGc.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
+
import{screenGradeWeight as h}from"@allyhub/scenery";const m="http://www.w3.org/2000/svg",c=32;let $=0;const s=e=>{const t=Math.round(e*1e4)/1e4;return String(Object.is(t,-0)?0:t)};function b(e,t){for(let n=1;n<e.length;n++){const[r,l]=e[n-1]??[0,0],[o,i]=e[n]??[1,1];if(t<=o)return o===r?i:l+(i-l)*(t-r)/(o-r)}return e[e.length-1]?.[1]??t}function u(e,t){const n=Array.from({length:c+1},(a,p)=>s(Math.min(1,Math.max(0,b(e.curve,p/c)-p/c+.5)))).join(" "),r="0.2126 0.7152 0.0722 0 0",[l,o,i]=e.balance??[1,1,1];return[`<feColorMatrix in="SourceGraphic" type="matrix" values="${r} ${r} ${r} 0 0 0 1 0" result="${t}-luma"/>`,`<feComponentTransfer in="${t}-luma" result="${t}-change">`,`<feFuncR type="table" tableValues="${n}"/><feFuncG type="table" tableValues="${n}"/><feFuncB type="table" tableValues="${n}"/><feFuncA type="table" tableValues="1 1"/>`,"</feComponentTransfer>",`<feComposite in="SourceGraphic" in2="${t}-change" operator="arithmetic" k1="0" k2="1" k3="1" k4="-0.5" result="${t}-lit"/>`,`<feComposite in="${t}-lit" in2="SourceGraphic" operator="in" result="${t}-toned"/>`,`<feColorMatrix in="${t}-toned" type="saturate" values="${s(e.saturation??1)}" result="${t}-strong"/>`,`<feColorMatrix in="${t}-strong" type="hueRotate" values="${s(e.hue??0)}" result="${t}-turned"/>`,`<feColorMatrix in="${t}-turned" type="matrix" values="${s(l)} 0 0 0 0 0 ${s(o)} 0 0 0 0 0 ${s(i)} 0 0 0 0 0 1 0" result="${t}"/>`].join("")}export function gradeFilterMarkup(e,t,n){const r=n<=0?u(t.room,"room"):n>=1?u(t.screen,"screen"):u(t.room,"room")+u(t.screen,"screen")+`<feComposite in="room" in2="screen" operator="arithmetic" k1="0" k2="${s(1-n)}" k3="${s(n)}" k4="0"/>`;return`<filter id="${e}" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">${r}</filter>`}const f=new WeakMap;export function gradeLayer(e,t,n){let r=f.get(e);if(!t){r&&(r.svg.remove(),f.delete(e),e.el.style.filter="");return}const l=e.el.parentElement;if(!l)return;if(!r){const a=document.createElementNS(m,"svg");a.setAttribute("width","0"),a.setAttribute("height","0"),a.setAttribute("aria-hidden","true"),Object.assign(a.style,{position:"absolute",left:"0",top:"0"}),l.appendChild(a),$+=1,r={svg:a,id:`ak-sensor-grade-${String($)}`,markup:""},f.set(e,r)}const o=Math.round(h(n,t.share)*100)/100,i=gradeFilterMarkup(r.id,t,o);i!==r.markup&&(r.svg.innerHTML=i,r.markup=i),e.el.style.filter=`url(#${r.id})`,e.el.dataset.akGrade=`${String(Math.round(n*1e3)/1e3)}:${String(o)}`}
|
|
@@ -24,9 +24,10 @@ export declare const SCREEN_DEFAULTS: {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function screen(content: Piece | readonly GraphicLayer[], opts?: ScreenOptions): Screen;
|
|
26
26
|
/**
|
|
27
|
-
* A scenery layer's defaults.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* A scenery layer's defaults. It is drawn at the frame's own pixels: at half
|
|
28
|
+
* each way (the old default), a laptop's words filmed close went soft, and
|
|
29
|
+
* the full size cost a phone-filmed short about 8% more time. A draft may
|
|
30
|
+
* ask for quality.scale 0.5; above 1 is supersampled.
|
|
30
31
|
*/
|
|
31
32
|
export declare const SCENERY_LAYER_DEFAULTS: {
|
|
32
33
|
scale: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{glassProblems as _,moireCamera as C,moireProblems as A,PANEL_DEFAULTS as D,project as R,resolveCamera as M,SCREEN_FOCUS_DEFAULTS as j,SCREEN_LIGHT_DEFAULTS as x,screenLightBaseProblem as P}from"@allyhub/scenery";import{isPiece as z,LAYER_BRAND as L}from"@allyhub/piece";import{bakeFile as B,DRAWN_OVER_RULE as I,ruleOf as J,SCENERY_RULES as H}from"../allyhub.js";import{sceneryFileOf as W}from"../module.js";import{drawMoire as G}from"./moire.js";import{answerFor as q}from"./queries.js";import{blurScreen as V,drawScreen as Y,mountScreen as K,placeInScenery as X,screenEdge as Z,screenFocusOf as Q,screenTo as ee,stackByDepth as ne}from"./screens.js";import{cameraOf as re,coded as O,refScenery as $,registry as v,ruled as k,sceneryAtFilm as se,sceneryTime as F}from"./state.js";import{SCREEN as te}from"./types.js";export{stackByDepth}from"./screens.js";export{markScenery,sceneryFileOf}from"../module.js";export{PHONE_CAMERA,phoneCamera,aimAt,aimed,AIM_DEFAULTS,AUTO_EXPOSURE_DEFAULTS,AUTOFOCUS_DEFAULTS,BAKE_DEFAULTS,blend,CAMERA_DEFAULTS,cameraProblems,cutsOf,defineScenery,diagonalLens,directionOf,easeValue,exposureOf,fieldOfView,FIT_DEFAULTS,fitCamera,focusScreen,GLASS_DEFAULTS,handheld,HANDHELD_DEFAULTS,keys,lensForVertical,mixCameras,orbit,PANEL_DEFAULTS,path,PATH_DEFAULTS,project,resolveCamera,rise,SCREEN_LIGHT_DEFAULTS,SENSOR_DEFAULTS,shots,STABILIZER_DEFAULTS,withCuts,SCENERY_RENDERER_DEFAULTS,yawPitchOf}from"@allyhub/scenery";export const SCREEN_DEFAULTS={size:[1920,1080],background:"#000000"};function ie(t){if(t===!1)return!1;const n=typeof t=="object"?t:{},e=n.brightness??1;if(!(Number.isFinite(e)&&e>=0))throw new Error(`screen()'s inScenery brightness ${String(e)} is not a number of 0 or more.`);const o=n.light??!0;if(o===!1)return{brightness:e,light:!1};const s=(typeof o=="object"?o.cells:void 0)??[...x.cells];if(s.length!==2||!s.every(a=>Number.isInteger(a)&&a>=1&&a<=32))throw new Error(`screen()'s inScenery light cells ${JSON.stringify(s)} are not two whole numbers from 1 to 32 (across, down).`);const c=(typeof o=="object"?o.specular:void 0)??x.specular;if(typeof c!="boolean")throw new Error(`screen()'s inScenery light specular ${JSON.stringify(c)} is not true or false.`);const i=(typeof o=="object"?o.base:void 0)??x.base;if(i!==null){const a=P(i);if(a!==void 0)throw new Error(`screen()'s inScenery light base: ${a}.`)}const l=i;return{brightness:e,light:{cells:[s[0]??1,s[1]??1],specular:c,base:l?{brightness:l.brightness??e,color:typeof l.color=="string"?l.color:l.color?[...l.color]:"#ffffff"}:null}}}export function screen(t,n={}){if((n.start!==void 0||n.cue!==void 0)&&n.time!==void 0)throw new Error("screen() takes start and cue, or time, not both.");if(n.cues!==void 0){if(n.start!==void 0||n.cue!==void 0||n.time!==void 0)throw new Error("screen() takes cues, or start and cue, or time: one way to time it.");if(Object.keys(n.cues).length===0)throw new Error(`screen()'s cues is empty: give the screen's moments and where each plays, { "@click": "@press" }.`);for(const[a,h]of Object.entries(n.cues)){if(!(a.trim().startsWith("@")?!0:Number.isFinite(Number(a)))||Array.isArray(t)&&a.trim().startsWith("@"))throw new Error(`screen()'s cue key ${JSON.stringify(a)}: ${Array.isArray(t)?`layers' moments are seconds of the screen's time, as a string ("2.5")`:`a video's own reference ("@click") or seconds of its time as a string ("2.5")`}.`);if(!(typeof h=="number"&&Number.isFinite(h))&&!(typeof h=="string"&&h.trim()!==""))throw new Error(`screen()'s cue ${JSON.stringify(a)} plays at ${JSON.stringify(h)}: a reference of the film ("@press") or a scenery time in seconds.`)}}if(typeof n.cue=="number"&&!Number.isFinite(n.cue))throw new Error(`screen()'s cue ${String(n.cue)} is not a number of seconds.`);if(typeof n.cue=="string"&&Array.isArray(t))throw new Error(`screen()'s cue "${n.cue}" is a reference: only a video has references of its own. Give layers' cue in seconds of the screen's time.`);const e=n.background??SCREEN_DEFAULTS.background,o={[te]:!0,time:n.time??{},...n.start!==void 0?{start:n.start}:{},...n.cue!==void 0?{cue:n.cue}:{},...n.cues!==void 0?{cues:{...n.cues}}:{},background:e==="transparent"?null:e,...n.pixels?{pixels:{...n.pixels}}:{},...n.glass?{glass:{...n.glass}}:{},inScenery:ie(n.inScenery)},s=A(void 0,n.pixels);if(s.length>0)throw new Error(`screen()'s ${s.join(" ")}`);const c=_(n.glass);if(c.length>0)throw new Error(`screen()'s ${c.join(" ")}`);if(!Array.isArray(t)){if(!z(t))throw new Error('screen() shows a video item (its piece, imported: import demo from "../demo/video") or graphic layers.');if(n.size!==void 0||n.dur!==void 0)throw new Error("screen() with a video takes its size and length from the video: its own format, and its length.");return{...o,video:t,layers:[],size:SCREEN_DEFAULTS.size}}const i=t;for(const a of i)if(a[L]!=="graphic")throw new Error("screen() takes graphic layers (components, custom()), or a video item whose own layers include footage.");const l=n.size??SCREEN_DEFAULTS.size;if(!(l[0]>0&&l[1]>0))throw new Error(`screen()'s size ${JSON.stringify(l)} is not two sizes in px.`);return{...o,layers:i,size:l,...n.dur!==void 0?{dur:n.dur}:{}}}export const SCENERY_LAYER_DEFAULTS={scale:.5,name:"scenery",focusLevels:j.levels};const N=new WeakMap,T=new WeakMap,U=new WeakMap,oe=()=>{const t=import.meta.url;return new URL("../three-libs/",t).href};function ae(t,n,e){const o=W(t);return{assetUrl:s=>n.asset(`/${s.replace(/^\/+/,"")}`).url,...o===void 0?{}:{module:o},decoders:oe(),seed:e,onProblem:s=>{n.report?.({code:J(s.kind),level:s.level,message:s.message})},bakeUrl:(s,c)=>n.optionalAsset?.(`/${B(s,c)}`)?.url,...n.realTimers?{timers:n.realTimers}:{}}}function ce(t,n,e){let o=T.get(t);return o||(o=Promise.all([import("../page/page.js"),import("../signature.js")]).then(async([{SceneryPage:s},{signatureOf:c}])=>{const i={page:await s.open(t,ae(t,n,e)),sign:c};return U.set(t,i),i}),T.set(t,o)),o}function le(t,n){const e=n.canvas;e.parentNode!==t.el&&t.el.insertBefore(e,t.canvas),e.dataset.akSign="the scenery's renderer",Object.assign(e.style,{position:"absolute",left:t.canvas.style.left,top:t.canvas.style.top,width:t.canvas.style.width,height:t.canvas.style.height,clipPath:"inset(0 calc(100% - 1px) calc(100% - 1px) 0)",pointerEvents:"none"})}export function scenery(t,n){const{at:e,until:o,dur:s,z:c,...i}=n,l={...e===void 0?{}:{at:e},...o===void 0?{}:{until:o},...s===void 0?{}:{dur:s},...c===void 0?{}:{z:c}},a=i.box===void 0||i.box==="full"?[0,0,1,1]:i.box;if(a.some(p=>!Number.isFinite(p))||a[2]<=0||a[3]<=0||a[0]+a[2]>1+1e-9||a[1]+a[3]>1+1e-9)throw new Error(`scenery()'s box ${JSON.stringify(a)} is not inside the frame: [x, y, width, height] as fractions, x + width and y + height at most 1.`);const h=i.quality?.scale??SCENERY_LAYER_DEFAULTS.scale;if(!(h>0&&h<=4))throw new Error(`scenery()'s quality.scale ${String(h)} is outside (0, 4].`);const u=i.quality?.focusLevels??SCENERY_LAYER_DEFAULTS.focusLevels;if(!(Number.isInteger(u)&&u>=1&&u<=16))throw new Error(`scenery()'s quality.focusLevels ${String(u)} is not a whole number from 1 to 16.`);const d=A(i.sensor,void 0);if(d.length>0)throw new Error(`scenery()'s ${d.join(" ")}`);const f=i.background;return{[L]:"graphic",...l,component:"scenery",props:{scenery:t,camera:i.camera,box:a,...f===void 0?{}:{background:f==="transparent"?null:f},time:i.time??{},scale:h,focusLevels:u,...i.sensor?{sensor:{...i.sensor}}:{},name:i.name??SCENERY_LAYER_DEFAULTS.name,screens:i.screens??{},props:i.props??[]},mount(p,y,w){k(()=>{de(p,y,w)})},render(p,y){k(()=>{fe(p,y)})}}}function de(t,n,e){const{width:o,height:s}=e.dims,c={x:Math.round(n.box[0]*o),y:Math.round(n.box[1]*s),w:Math.max(1,Math.round(n.box[2]*o)),h:Math.max(1,Math.round(n.box[3]*s))},i=document.createElement("canvas"),l=e.sceneryScale??n.scale;i.width=Math.max(1,Math.round(c.w*l)),i.height=Math.max(1,Math.round(c.h*l)),Object.assign(i.style,{position:"absolute",left:`${String(c.x)}px`,top:`${String(c.y)}px`,width:`${String(c.w)}px`,height:`${String(c.h)}px`});const a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:i.style.left,top:i.style.top,width:i.style.width,height:i.style.height,overflow:"hidden",isolation:"isolate"});const h=g=>se(n,(e.film?.start??0)+g);t.appendChild(a);const u=Object.entries(n.screens).map(([g,r])=>K(a,g,r,e,h,m=>$(n,e,m)));let d;n.sensor&&u.length>0&&(d=document.createElement("canvas"),d.width=c.w,d.height=c.h,d.dataset.akSign="the scenery's moiré",Object.assign(d.style,{position:"absolute",left:"0px",top:"0px",width:`${String(c.w)}px`,height:`${String(c.h)}px`,zIndex:"100000",mixBlendMode:"multiply",pointerEvents:"none"}),a.appendChild(d)),u.length===0&&a.remove(),t.appendChild(i);const f={props:n,ctx:e,el:t,canvas:i,px:c,screens:u,time:g=>$(n,e,g),...d?{moire:d}:{}};N.set(t,f),q(f);const p=v.get(n.name)??[];p.push(f),v.set(n.name,p);const y=g=>Promise.all(n.props.map(r=>g.props.add(r))),w=g=>{throw O(g)},E=U.get(n.scenery);if(E){f.page=E.page,f.sign=E.sign,n.props.length>0&&e.wait(y(E.page).catch(w));return}e.wait(ce(n.scenery,e,n.name).then(async({page:g,sign:r})=>{await y(g),f.page=g,f.sign=r}).catch(w))}function fe(t,n){const e=N.get(t);if(!e?.page)return;const o=e.page,s=F(e,n),c=e.px.w/e.px.h,i=o.stateFrom(re(e),s,c,e.time);o.props.show(e.props.props,s);const l=o.aim(i,c),{width:a,height:h}=e.canvas,u=o.screens.drawsElements,d=u?e.screens.filter(r=>r.spec.inScenery!==!1):[];if(!u&&!e.fellBack){const r=e.screens.filter(m=>m.spec.inScenery!==!1);r.length>0&&(e.fellBack=!0,e.ctx.report?.({code:I,level:"warn",message:`The screens ${r.map(m=>`"${m.mesh}"`).join(", ")} of the scenery layer "${e.props.name}" are drawn over the scenery, unlit and untoned, not in it: this page cannot draw an element into the scenery's canvas (Chrome's HTML-in-Canvas is missing or turned off, or the scenery draws with WebGPU). AllyHub's own Chrome, which allyhub frames, check and exports use, has it: when allyhub check does not report this, only this page's preview is affected, so change nothing. screen(…, { inScenery: false }) would take the scenery's light and a sensor's moiré out of the export too.`}))}const f=e.screens.filter(r=>!d.includes(r)).map(r=>r.mesh),p=e.screens.map(r=>o.screens.quad(r.mesh,l.resolved,[e.px.w,e.px.h])),y=Math.ceil(2/(e.canvas.height/e.px.h))+1;d.length>0&&le(e,o);const w=[];if(e.screens.forEach((r,m)=>{if(d.includes(r)){const b=r.spec.pixels?.density??D.density,S=r.spec.inScenery;o.screens.show(r.mesh,r.el,{brightness:S===!1?1:S.brightness,light:S===!1?!1:S.light,...e.moire&&e.props.sensor?{factor:e.moire}:{}}),X(r,p[m],b),w.push(ee(r,s));return}Y(r,s,p[m]),Z(r,p[m],y),V(r,Q(e,r,p[m],l.resolved))}),ne(e.screens.map((r,m)=>({el:r.el,depth:p[m]?.depth}))),e.sign&&(e.canvas.dataset.akSign=e.sign(o.scene,l.camera,[a,h],`${e.props.background===void 0?"the scenery's":e.props.background??"none"}|${f.join(",")}${l.resolved.dof?`|f/${String(l.resolved.dof.aperture)}@${String(l.resolved.dof.focus)}:${String(l.resolved.dof.lens)}`:""}${e.props.sensor?`|sensor ${JSON.stringify(e.props.sensor)} ${JSON.stringify(e.screens.map(r=>r.spec.pixels??null))}`:""}${e.screens.some(r=>r.spec.glass)?`|glass ${JSON.stringify(e.screens.map(r=>r.spec.glass??null))}`:""}${d.length>0?`|in scenery ${JSON.stringify(d.map(r=>[r.mesh,r.spec.inScenery]))}`:""}`)),e.ctx.layoutOnly===!0)return;e.moire&&e.props.sensor&&G(e,p,l.resolved,C(l.resolved,[e.ctx.dims.width,e.ctx.dims.height],e.px.h,e.props.sensor,[e.px.x,e.px.y]));const E=new Map(e.screens.flatMap(r=>r.spec.glass?[[r.mesh,r.spec.glass]]:[])),g=()=>{const r=o.drawer.inPlace(l.camera,a,h,e.props.background,f,l.resolved.dof,E.size>0?E:void 0,d.map(b=>b.mesh)),m=e.canvas.getContext("2d");if(m&&(m.clearRect(0,0,a,h),m.drawImage(r,0,0,a,h),o.lost))throw Object.assign(new Error(`The scenery's WebGL context was lost (the browser's GPU process failed): its picture at ${n.toFixed(3)} s is empty.`),{code:H.renderer})};if(d.length===0){g();return}e.ctx.wait(Promise.all(w).then(()=>o.screens.paint([a,h])).then(g).catch(r=>{throw O(r)}))}export function projectScenery(t,n,e,o){const s=v.get(t)?.find(f=>f.el.parentElement===o.parentElement&&f.ctx.layer.start<=e&&e<f.ctx.layer.end&&f.page),c=s?.page;if(!s||!c)return;const i=F(s,e),l=s.px.w/s.px.h,a=c.stateFrom(s.props.camera,i,l,s.time);c.props.show(s.props.props,i);const h=M(a,l,f=>c.pointOf(f)),u=typeof n=="string"?c.pointOf(n):n,d=R(h,u);return{x:s.px.x+(d.x+1)/2*s.px.w,y:s.px.y+(1-d.y)/2*s.px.h,inView:d.inView,depth:d.depth}}
|
|
2
|
+
import{glassProblems as D,moireCamera as R,moireProblems as A,PANEL_DEFAULTS as L,project as M,resolveCamera as j,SCREEN_FOCUS_DEFAULTS as P,SCREEN_LIGHT_DEFAULTS as x,screenLightBaseProblem as z}from"@allyhub/scenery";import{isPiece as B,LAYER_BRAND as O}from"@allyhub/piece";import{bakeFile as I,DRAWN_OVER_RULE as J,ruleOf as H,SCENERY_RULES as W}from"../allyhub.js";import{sceneryFileOf as G}from"../module.js";import{gradeLayer as q}from"./grade.js";import{drawMoire as V}from"./moire.js";import{answerFor as Y}from"./queries.js";import{blurScreen as K,drawScreen as X,mountScreen as Z,placeInScenery as Q,screenEdge as ee,screenFocusOf as re,screenTo as ne,stackByDepth as se}from"./screens.js";import{cameraOf as te,coded as $,refScenery as k,registry as v,ruled as F,sceneryAtFilm as ie,sceneryTime as N}from"./state.js";import{SCREEN as oe}from"./types.js";export{stackByDepth}from"./screens.js";export{markScenery,sceneryFileOf}from"../module.js";export{PHONE_CAMERA,phoneCamera,aimAt,aimed,AIM_DEFAULTS,AUTO_EXPOSURE_DEFAULTS,AUTOFOCUS_DEFAULTS,BAKE_DEFAULTS,blend,CAMERA_DEFAULTS,cameraProblems,cutsOf,defineScenery,diagonalLens,directionOf,easeValue,exposureOf,fieldOfView,FIT_DEFAULTS,fitCamera,focusScreen,GLASS_DEFAULTS,handheld,HANDHELD_DEFAULTS,keys,lensForVertical,mixCameras,orbit,PANEL_DEFAULTS,path,PATH_DEFAULTS,project,resolveCamera,rise,SCREEN_LIGHT_DEFAULTS,SENSOR_DEFAULTS,shots,STABILIZER_DEFAULTS,withCuts,SCENERY_RENDERER_DEFAULTS,yawPitchOf}from"@allyhub/scenery";export const SCREEN_DEFAULTS={size:[1920,1080],background:"#000000"};function ae(t){if(t===!1)return!1;const r=typeof t=="object"?t:{},e=r.brightness??1;if(!(Number.isFinite(e)&&e>=0))throw new Error(`screen()'s inScenery brightness ${String(e)} is not a number of 0 or more.`);const i=r.light??!0;if(i===!1)return{brightness:e,light:!1};const s=(typeof i=="object"?i.cells:void 0)??[...x.cells];if(s.length!==2||!s.every(a=>Number.isInteger(a)&&a>=1&&a<=32))throw new Error(`screen()'s inScenery light cells ${JSON.stringify(s)} are not two whole numbers from 1 to 32 (across, down).`);const c=(typeof i=="object"?i.specular:void 0)??x.specular;if(typeof c!="boolean")throw new Error(`screen()'s inScenery light specular ${JSON.stringify(c)} is not true or false.`);const o=(typeof i=="object"?i.base:void 0)??x.base;if(o!==null){const a=z(o);if(a!==void 0)throw new Error(`screen()'s inScenery light base: ${a}.`)}const l=o;return{brightness:e,light:{cells:[s[0]??1,s[1]??1],specular:c,base:l?{brightness:l.brightness??e,color:typeof l.color=="string"?l.color:l.color?[...l.color]:"#ffffff"}:null}}}export function screen(t,r={}){if((r.start!==void 0||r.cue!==void 0)&&r.time!==void 0)throw new Error("screen() takes start and cue, or time, not both.");if(r.cues!==void 0){if(r.start!==void 0||r.cue!==void 0||r.time!==void 0)throw new Error("screen() takes cues, or start and cue, or time: one way to time it.");if(Object.keys(r.cues).length===0)throw new Error(`screen()'s cues is empty: give the screen's moments and where each plays, { "@click": "@press" }.`);for(const[a,h]of Object.entries(r.cues)){if(!(a.trim().startsWith("@")?!0:Number.isFinite(Number(a)))||Array.isArray(t)&&a.trim().startsWith("@"))throw new Error(`screen()'s cue key ${JSON.stringify(a)}: ${Array.isArray(t)?`layers' moments are seconds of the screen's time, as a string ("2.5")`:`a video's own reference ("@click") or seconds of its time as a string ("2.5")`}.`);if(!(typeof h=="number"&&Number.isFinite(h))&&!(typeof h=="string"&&h.trim()!==""))throw new Error(`screen()'s cue ${JSON.stringify(a)} plays at ${JSON.stringify(h)}: a reference of the film ("@press") or a scenery time in seconds.`)}}if(typeof r.cue=="number"&&!Number.isFinite(r.cue))throw new Error(`screen()'s cue ${String(r.cue)} is not a number of seconds.`);if(typeof r.cue=="string"&&Array.isArray(t))throw new Error(`screen()'s cue "${r.cue}" is a reference: only a video has references of its own. Give layers' cue in seconds of the screen's time.`);const e=r.background??SCREEN_DEFAULTS.background,i={[oe]:!0,time:r.time??{},...r.start!==void 0?{start:r.start}:{},...r.cue!==void 0?{cue:r.cue}:{},...r.cues!==void 0?{cues:{...r.cues}}:{},background:e==="transparent"?null:e,...r.pixels?{pixels:{...r.pixels}}:{},...r.glass?{glass:{...r.glass}}:{},inScenery:ae(r.inScenery)},s=A(void 0,r.pixels);if(s.length>0)throw new Error(`screen()'s ${s.join(" ")}`);const c=D(r.glass);if(c.length>0)throw new Error(`screen()'s ${c.join(" ")}`);if(!Array.isArray(t)){if(!B(t))throw new Error('screen() shows a video item (its piece, imported: import demo from "../demo/video") or graphic layers.');if(r.size!==void 0||r.dur!==void 0)throw new Error("screen() with a video takes its size and length from the video: its own format, and its length.");return{...i,video:t,layers:[],size:SCREEN_DEFAULTS.size}}const o=t;for(const a of o)if(a[O]!=="graphic")throw new Error("screen() takes graphic layers (components, custom()), or a video item whose own layers include footage.");const l=r.size??SCREEN_DEFAULTS.size;if(!(l[0]>0&&l[1]>0))throw new Error(`screen()'s size ${JSON.stringify(l)} is not two sizes in px.`);return{...i,layers:o,size:l,...r.dur!==void 0?{dur:r.dur}:{}}}export const SCENERY_LAYER_DEFAULTS={scale:1,name:"scenery",focusLevels:P.levels};const T=new WeakMap,U=new WeakMap,_=new WeakMap,ce=()=>{const t=import.meta.url;return new URL("../three-libs/",t).href};function le(t,r,e){const i=G(t);return{assetUrl:s=>r.asset(`/${s.replace(/^\/+/,"")}`).url,...i===void 0?{}:{module:i},decoders:ce(),seed:e,onProblem:s=>{r.report?.({code:H(s.kind),level:s.level,message:s.message})},bakeUrl:(s,c)=>r.optionalAsset?.(`/${I(s,c)}`)?.url,...r.realTimers?{timers:r.realTimers}:{}}}function de(t,r,e){let i=U.get(t);return i||(i=Promise.all([import("../page/page.js"),import("../signature.js")]).then(async([{SceneryPage:s},{signatureOf:c}])=>{const o={page:await s.open(t,le(t,r,e)),sign:c};return _.set(t,o),o}),U.set(t,i)),i}function fe(t,r){const e=r.canvas;e.parentNode!==t.el&&t.el.insertBefore(e,t.canvas),e.dataset.akSign="the scenery's renderer",Object.assign(e.style,{position:"absolute",left:t.canvas.style.left,top:t.canvas.style.top,width:t.canvas.style.width,height:t.canvas.style.height,clipPath:"inset(0 calc(100% - 1px) calc(100% - 1px) 0)",pointerEvents:"none"})}export function scenery(t,r){const{at:e,until:i,dur:s,z:c,...o}=r,l={...e===void 0?{}:{at:e},...i===void 0?{}:{until:i},...s===void 0?{}:{dur:s},...c===void 0?{}:{z:c}},a=o.box===void 0||o.box==="full"?[0,0,1,1]:o.box;if(a.some(p=>!Number.isFinite(p))||a[2]<=0||a[3]<=0||a[0]+a[2]>1+1e-9||a[1]+a[3]>1+1e-9)throw new Error(`scenery()'s box ${JSON.stringify(a)} is not inside the frame: [x, y, width, height] as fractions, x + width and y + height at most 1.`);const h=o.quality?.scale??SCENERY_LAYER_DEFAULTS.scale;if(!(h>0&&h<=4))throw new Error(`scenery()'s quality.scale ${String(h)} is outside (0, 4].`);const u=o.quality?.focusLevels??SCENERY_LAYER_DEFAULTS.focusLevels;if(!(Number.isInteger(u)&&u>=1&&u<=16))throw new Error(`scenery()'s quality.focusLevels ${String(u)} is not a whole number from 1 to 16.`);const d=A(o.sensor,void 0);if(d.length>0)throw new Error(`scenery()'s ${d.join(" ")}`);const f=o.background;return{[O]:"graphic",...l,component:"scenery",props:{scenery:t,camera:o.camera,box:a,...f===void 0?{}:{background:f==="transparent"?null:f},time:o.time??{},scale:h,focusLevels:u,...o.sensor?{sensor:{...o.sensor}}:{},name:o.name??SCENERY_LAYER_DEFAULTS.name,screens:o.screens??{},props:o.props??[]},mount(p,y,w){F(()=>{he(p,y,w)})},render(p,y){F(()=>{me(p,y)})}}}function he(t,r,e){const{width:i,height:s}=e.dims,c={x:Math.round(r.box[0]*i),y:Math.round(r.box[1]*s),w:Math.max(1,Math.round(r.box[2]*i)),h:Math.max(1,Math.round(r.box[3]*s))},o=document.createElement("canvas"),l=e.sceneryScale??r.scale;o.width=Math.max(1,Math.round(c.w*l)),o.height=Math.max(1,Math.round(c.h*l)),Object.assign(o.style,{position:"absolute",left:`${String(c.x)}px`,top:`${String(c.y)}px`,width:`${String(c.w)}px`,height:`${String(c.h)}px`});const a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:o.style.left,top:o.style.top,width:o.style.width,height:o.style.height,overflow:"hidden",isolation:"isolate"});const h=g=>ie(r,(e.film?.start??0)+g);t.appendChild(a);const u=Object.entries(r.screens).map(([g,n])=>Z(a,g,n,e,h,m=>k(r,e,m)));let d;r.sensor&&u.length>0&&(d=document.createElement("canvas"),d.width=c.w,d.height=c.h,d.dataset.akSign="the scenery's moiré",Object.assign(d.style,{position:"absolute",left:"0px",top:"0px",width:`${String(c.w)}px`,height:`${String(c.h)}px`,zIndex:"100000",mixBlendMode:"multiply",pointerEvents:"none"}),a.appendChild(d)),u.length===0&&a.remove(),t.appendChild(o);const f={props:r,ctx:e,el:t,canvas:o,px:c,screens:u,time:g=>k(r,e,g),...d?{moire:d}:{}};T.set(t,f),Y(f);const p=v.get(r.name)??[];p.push(f),v.set(r.name,p);const y=g=>Promise.all(r.props.map(n=>g.props.add(n))),w=g=>{throw $(g)},E=_.get(r.scenery);if(E){f.page=E.page,f.sign=E.sign,r.props.length>0&&e.wait(y(E.page).catch(w));return}e.wait(de(r.scenery,e,r.name).then(async({page:g,sign:n})=>{await y(g),f.page=g,f.sign=n}).catch(w))}function me(t,r){const e=T.get(t);if(!e?.page)return;const i=e.page,s=N(e,r),c=e.px.w/e.px.h,o=i.stateFrom(te(e),s,c,e.time);i.props.show(e.props.props,s);const l=i.aim(o,c),{width:a,height:h}=e.canvas,u=i.screens.drawsElements,d=u?e.screens.filter(n=>n.spec.inScenery!==!1):[];if(!u&&!e.fellBack){const n=e.screens.filter(m=>m.spec.inScenery!==!1);n.length>0&&(e.fellBack=!0,e.ctx.report?.({code:J,level:"warn",message:`The screens ${n.map(m=>`"${m.mesh}"`).join(", ")} of the scenery layer "${e.props.name}" are drawn over the scenery, unlit and untoned, not in it: this page cannot draw an element into the scenery's canvas (Chrome's HTML-in-Canvas is missing or turned off, or the scenery draws with WebGPU). AllyHub's own Chrome, which allyhub frames, check and exports use, has it: when allyhub check does not report this, only this page's preview is affected, so change nothing. screen(…, { inScenery: false }) would take the scenery's light and a sensor's moiré out of the export too.`}))}const f=e.screens.filter(n=>!d.includes(n)).map(n=>n.mesh),p=e.screens.map(n=>i.screens.quad(n.mesh,l.resolved,[e.px.w,e.px.h]));q(e,e.props.sensor?.grade,Math.max(0,...e.screens.map(n=>i.screens.share(n.mesh,l.resolved,[e.px.w,e.px.h]))));const y=Math.ceil(2/(e.canvas.height/e.px.h))+1;d.length>0&&fe(e,i);const w=[];if(e.screens.forEach((n,m)=>{if(d.includes(n)){const b=n.spec.pixels?.density??L.density,C=n.spec.pixels?.mesh??L.mesh,S=n.spec.inScenery;i.screens.show(n.mesh,n.el,{brightness:S===!1?1:S.brightness,light:S===!1?!1:S.light,...e.moire&&e.props.sensor?{factor:e.moire}:{}}),Q(n,p[m],b,C),w.push(ne(n,s));return}X(n,s,p[m]),ee(n,p[m],y),K(n,re(e,n,p[m],l.resolved))}),se(e.screens.map((n,m)=>({el:n.el,depth:p[m]?.depth}))),e.sign&&(e.canvas.dataset.akSign=e.sign(i.scene,l.camera,[a,h],`${e.props.background===void 0?"the scenery's":e.props.background??"none"}|${f.join(",")}${l.resolved.dof?`|f/${String(l.resolved.dof.aperture)}@${String(l.resolved.dof.focus)}:${String(l.resolved.dof.lens)}`:""}${e.props.sensor?`|sensor ${JSON.stringify(e.props.sensor)} ${JSON.stringify(e.screens.map(n=>n.spec.pixels??null))}`:""}${e.screens.some(n=>n.spec.glass)?`|glass ${JSON.stringify(e.screens.map(n=>n.spec.glass??null))}`:""}${d.length>0?`|in scenery ${JSON.stringify(d.map(n=>[n.mesh,n.spec.inScenery]))}`:""}`)),e.ctx.layoutOnly===!0)return;e.moire&&e.props.sensor&&V(e,p,l.resolved,R(l.resolved,[e.ctx.dims.width,e.ctx.dims.height],e.px.h,e.props.sensor,[e.px.x,e.px.y]));const E=new Map(e.screens.flatMap(n=>n.spec.glass?[[n.mesh,n.spec.glass]]:[])),g=()=>{const n=i.drawer.inPlace(l.camera,a,h,e.props.background,f,l.resolved.dof,E.size>0?E:void 0,d.map(b=>b.mesh)),m=e.canvas.getContext("2d");if(m&&(m.clearRect(0,0,a,h),m.drawImage(n,0,0,a,h),i.lost))throw Object.assign(new Error(`The scenery's WebGL context was lost (the browser's GPU process failed): its picture at ${r.toFixed(3)} s is empty.`),{code:W.renderer})};if(d.length===0){g();return}e.ctx.wait(Promise.all(w).then(()=>i.screens.paint([a,h])).then(g).catch(n=>{throw $(n)}))}export function projectScenery(t,r,e,i){const s=v.get(t)?.find(f=>f.el.parentElement===i.parentElement&&f.ctx.layer.start<=e&&e<f.ctx.layer.end&&f.page),c=s?.page;if(!s||!c)return;const o=N(s,e),l=s.px.w/s.px.h,a=c.stateFrom(s.props.camera,o,l,s.time);c.props.show(s.props.props,o);const h=j(a,l,f=>c.pointOf(f)),u=typeof r=="string"?c.pointOf(r):r,d=M(h,u);return{x:s.px.x+(d.x+1)/2*s.px.w,y:s.px.y+(1-d.y)/2*s.px.h,inView:d.inView,depth:d.depth}}
|
|
@@ -38,7 +38,7 @@ export declare function stackByDepth(screens: readonly {
|
|
|
38
38
|
export declare function placeInScenery(sc: MountedScreen, quad: {
|
|
39
39
|
corners: [Px, Px, Px, Px];
|
|
40
40
|
angle: number;
|
|
41
|
-
} | undefined, density: number): void;
|
|
41
|
+
} | undefined, density: number, mesh?: number): void;
|
|
42
42
|
/** A screen's content at scenery time t, without placing it: a screen drawn in the scenery. */
|
|
43
43
|
export declare function screenTo(sc: MountedScreen, sceneryT: number): Promise<unknown>;
|
|
44
44
|
/** A screen at scenery time: its content drawn, its picture mapped onto its quad. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{homography as I,matrix3d as N,screenFocus as L,SCENERY_RENDERER_DEFAULTS as B}from"@allyhub/scenery";import{addLayerRule as U,layerShown as _,showLayer as j}from"@allyhub/piece";import{coded as H}from"./state.js";export function blurScreen(t,
|
|
2
|
+
import{homography as I,matrix3d as N,screenFocus as L,SCENERY_RENDERER_DEFAULTS as B}from"@allyhub/scenery";import{addLayerRule as U,layerShown as _,showLayer as j}from"@allyhub/piece";import{coded as H}from"./state.js";export function blurScreen(t,i){if(!i){t.focus&&(t.surface.style.filter="");return}const e=t.el.parentElement;if(!e)return;if(!t.focus){const o=document.createElementNS(P,"svg");o.setAttribute("width","0"),o.setAttribute("height","0"),o.setAttribute("aria-hidden","true"),Object.assign(o.style,{position:"absolute",left:"0",top:"0"}),e.appendChild(o),D+=1,t.focus={svg:o,id:`ak-screen-focus-${String(D)}`,markup:""}}const n=V(t.focus.id,t.size,i);n!==t.focus.markup&&(t.focus.svg.innerHTML=n,t.focus.markup=n),t.surface.style.filter=`url(#${t.focus.id})`}const P="http://www.w3.org/2000/svg";let D=0;const S=t=>{const i=Math.round(t*1e3)/1e3;return String(Object.is(i,-0)?0:i)};function V(t,i,e){const[n,o]=i,r=[],a=e.sigmas.length>1;a&&r.push(`<defs><linearGradient id="${t}-lg" gradientUnits="userSpaceOnUse" x1="${S(e.from[0])}" y1="${S(e.from[1])}" x2="${S(e.to[0])}" y2="${S(e.to[1])}"><stop offset="0" stop-color="#000"/><stop offset="1" stop-color="#fff"/></linearGradient>`,`<rect id="${t}-r" x="0" y="0" width="${S(n)}" height="${S(o)}" fill="url(#${t}-lg)"/></defs>`),r.push(`<filter id="${t}" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">`),a&&r.push(`<feImage href="#${t}-r" result="g"/>`,'<feColorMatrix in="g" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0" result="w"/>');const p=[];e.sigmas.forEach((l,d)=>{const y=e.weights[d]??[];if(a&&!y.some(b=>b>0))return;const w=a?W(e,y,n,o):void 0,m=w?` x="${S(w[0])}" y="${S(w[1])}" width="${S(w[2])}" height="${S(w[3])}"`:"";let $="SourceGraphic";if(l>=.05&&(r.push(`<feGaussianBlur in="SourceGraphic" stdDeviation="${S(l)}"${m} result="b${String(d)}"/>`),$=`b${String(d)}`),!a){p.push($);return}r.push(`<feComponentTransfer in="w"${m} result="w${String(d)}"><feFuncA type="table" tableValues="${y.map(S).join(" ")}"/></feComponentTransfer>`,`<feComposite in="${$}" in2="w${String(d)}" operator="arithmetic" k1="1"${m} result="m${String(d)}"/>`),p.push(`m${String(d)}`)});let f=p[0]??"SourceGraphic";return p.slice(1).forEach((l,d)=>{const y=`s${String(d)}`;r.push(`<feComposite in="${f}" in2="${l}" operator="arithmetic" k2="1" k3="1" result="${y}"/>`),f=y}),r.push(`<feColorMatrix in="${f}" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1" result="o"/>`,'<feComposite in="o" in2="SourceAlpha" operator="in"/>',"</filter>"),r.join("")}function W(t,i,e,n){const o=i.length,r=i.findIndex(g=>g>0);let a=o-1;for(;a>0&&!((i[a]??0)>0);)a-=1;const p=Math.max(0,r-1)/(o-1),f=Math.min(o-1,a+1)/(o-1);if(p<=0&&f>=1)return;const l=t.to[0]-t.from[0],d=t.to[1]-t.from[1],y=l*l+d*d;if(y<=0)return;const w=g=>((g[0]-t.from[0])*l+(g[1]-t.from[1])*d)/y,m=(g,C)=>{const s=[];return g.forEach((u,c)=>{const h=g[(c+1)%g.length]??u,x=C(u),E=C(h);if(x>=0&&s.push(u),x>=0!=E>=0){const M=x/(x-E);s.push([u[0]+(h[0]-u[0])*M,u[1]+(h[1]-u[1])*M])}}),s};let $=[[0,0],[e,0],[e,n],[0,n]];if($=m($,g=>w(g)-p),$=m($,g=>f-w(g)),$.length===0)return[0,0,0,0];const b=$.map(g=>g[0]),v=$.map(g=>g[1]),O=Math.max(0,Math.floor(Math.min(...b))-1),z=Math.max(0,Math.floor(Math.min(...v))-1),A=Math.min(e,Math.ceil(Math.max(...b))+1),F=Math.min(n,Math.ceil(Math.max(...v))+1);return[O,z,A-O,F-z]}export function screenFocusOf(t,i,e,n){if(!n.dof||!e||!t.page)return;const o=t.page.screens.face(i.mesh);if(!o)return;const r=t.props.scenery.renderer?.focus?.maxRadius??B.focus.maxRadius,a=t.canvas.height/t.px.h;return L({camera:n,corners:[o.point(0,0),o.point(1,0),o.point(1,1),o.point(0,1)],quad:e.corners,size:i.size,frameHeight:t.px.h,levels:t.props.focusLevels,most:2*r/a})}export function mountScreen(t,i,e,n,o,r){const a=document.createElement("div");a.dataset.akScreen=i;const p=([s,u])=>{a.style.width=`${String(s)}px`,a.style.height=`${String(u)}px`};Object.assign(a.style,{position:"absolute",left:"0px",top:"0px",overflow:"hidden",transformOrigin:"0 0",opacity:"0.999",display:"none"});const f=document.createElement("div");Object.assign(f.style,{position:"absolute",inset:"0",background:e.background??"transparent"}),a.appendChild(f),p(e.size),t.appendChild(a);const l=e.time,d=e.start===void 0?void 0:typeof e.start=="number"?e.start:r(e.start),y=d!==void 0||e.cue!==void 0||e.cues!==void 0;let w=(typeof e.cue=="number"?e.cue:0)-(d??0),m;const $=s=>{if(!e.cues)return;const u=Object.entries(e.cues).map(([c,h])=>[typeof h=="number"?h:r(h),s(c.trim())]);u.sort((c,h)=>c[0]-h[0]);for(let c=1;c<u.length;c++){const[h,x]=u[c-1]??[0,0],[E,M]=u[c]??[0,0];if(!(E>h&&M>x))throw new Error(`screen() on "${i}": its cues are not in the same order on both clocks (the screen's ${x.toFixed(3)} s at scenery ${h.toFixed(3)} s, then ${M.toFixed(3)} s at ${E.toFixed(3)} s). Each later moment of the screen plays later.`)}m=u,v.stretches=u.slice(1).map((c,h)=>{const x=u[h]??c;return{from:x[0],to:c[0],video:[x[1],c[1]],speed:Math.round((c[1]-x[1])/(c[0]-x[0])*1e4)/1e4}})},b=s=>{if(m&&m.length>0){const u=m[0]??[0,0];if(s<=u[0])return u[1]+(s-u[0]);for(let h=1;h<m.length;h++){const[x,E]=m[h]??[0,0];if(s<=x){const[M,k]=m[h-1]??[0,0];return k+(s-M)/(x-M)*(E-k)}}const c=m[m.length-1]??[0,0];return c[1]+(s-c[0])}return y?w+s:typeof l=="function"?l(s):(l.from??0)+s},v={mesh:i,spec:e,el:a,surface:f,size:[e.size[0],e.size[1]],timeAt:b,ctx:n,layers:[]};if(e.video){if(!n.video)throw new Error(`This host cannot show a video on the screen "${i}".`);const s=document.createElement("div");return f.appendChild(s),n.wait(n.video(e.video,s).then(u=>{typeof e.cue=="string"&&(w=u.at(e.cue)-(d??0)),$(c=>c.startsWith("@")?u.at(c):Number(c)),v.video=u,v.size=[u.width,u.height],p(v.size)})),v}$(s=>Number(s));const[O,z]=e.size,A=e.dur??(!y&&typeof l=="function"?1/0:b(o(n.layer.end))),F=[0,0,O,z],g=s=>{if(!y&&typeof l=="function")throw new Error(`screen() on "${i}" has a function for its time, which a reference cannot be placed in: give it a start (or { from }) to time its layers by the script.`);return b(o(s))},C=s=>typeof s=="number"?s:g(n.at(s));return v.layers=T(a,()=>e.layers.map((s,u)=>{const c=document.createElement("div");Object.assign(c.style,{position:"absolute",inset:"0"}),j(c,!1),f.appendChild(c);const h=s.at===void 0?0:C(s.at),x=s.until!==void 0?C(s.until):s.dur!==void 0?h+s.dur:A,E={...n,get layoutOnly(){return n.layoutOnly===!0},format:`${O}x${z}`,dims:{width:O,height:z,orient:O>z?"landscape":O<z?"portrait":"square",safe:{top:0,bottom:0,left:0,right:0}},dur:A,words:()=>!y&&typeof l=="function"?[]:n.words().map(k=>({...k,start:g(k.start),end:g(k.end)})),at:C,layer:{start:h,end:x},captions:()=>[],face:()=>{},faces:()=>[],texts:()=>[],covered:[],content:F},M=s.times?R(s.props,s.times,C):s.props;return U(c.ownerDocument),j(c,!0),G(i,s,u,"mount",()=>{s.mount(c,M,E)}),j(c,!1),{spec:s,props:M,el:c,ctx:E,start:h,end:x}})),v}function T(t,i){const e=_(t);j(t,!0);try{return i()}finally{j(t,e)}}function R(t,i,e){if(Array.isArray(t))return t.map(o=>R(o,i,e));if(i===!0)return typeof t=="string"||typeof t=="number"?e(t):t;if(typeof t!="object"||t===null)return t;const n={...t};for(const[o,r]of Object.entries(i))o in n&&n[o]!==void 0&&(n[o]=R(n[o],r,e));return n}export function stackByDepth(t){t.map((e,n)=>({i:n,depth:e.depth??1/0})).sort((e,n)=>n.depth-e.depth||e.i-n.i).forEach(({i:e},n)=>{const o=t[e];o&&(o.el.style.zIndex=String(n))})}export function placeInScenery(t,i,e,n=0){const[o,r]=t.size;Y(t,e,n),Object.assign(t.el.style,{display:"block",opacity:"1",width:`${String(o*e)}px`,height:`${String(r*e)}px`}),Object.assign(t.surface.style,{inset:"auto",left:"0px",top:"0px",width:`${String(o)}px`,height:`${String(r)}px`,transformOrigin:"0 0",transform:e===1?"none":`scale(${String(e)})`});const a=i?I(o,r,i.corners):void 0;if(!i||!a||i.angle>=90){t.el.style.transform="scale(0)";return}const p=a.map((f,l)=>l%3===2?f:f/e);t.el.style.transform=N(p.map(f=>Math.round(f*1e9)/1e9))}function Y(t,i,e){let n=t.surface.querySelector(":scope > [data-panel-mesh]");if(e<=0){n?.remove();return}n||(n=document.createElement("div"),n.dataset.panelMesh="",Object.assign(n.style,{position:"absolute",inset:"0",pointerEvents:"none",zIndex:"2147483647"}),t.surface.appendChild(n));const o=3/i,r=o/3,a=Math.min(1,e),p=a*(2/3),f=(l,d)=>`repeating-linear-gradient(${String(l)}deg, rgba(0,0,0,${d.toFixed(3)}) 0 ${String(r)}px, transparent ${String(r)}px ${String(o)}px)`;n.style.background=`${f(0,a)}, ${f(90,p)}`}function G(t,i,e,n,o){try{o()}catch(r){throw H(r,`On the screen "${t}", its layer ${String(e+1)} (${i.component}) failed in ${n}: `)}}export function screenTo(t,i){const e=t.timeAt(i);if(t.video){const n=Math.max(0,t.video.duration-.001),o=Math.min(Math.max(e,0),n);return t.video.seek(o,t.ctx.layoutOnly===!0)}return t.layers.forEach((n,o)=>{const r=e>=n.start&&e<n.end;j(n.el,r),r&&G(t.mesh,n.spec,o,`render at ${e.toFixed(2)} s`,()=>{n.spec.render(n.el,e,n.props,n.ctx)})}),Promise.resolve()}export function drawScreen(t,i,e){const n=e?I(t.size[0],t.size[1],e.corners):void 0;if(!e||!n||e.angle>=90){t.el.style.display="none";return}t.el.style.display="block",t.el.style.transform=N(n.map(r=>Math.round(r*1e9)/1e9));const o=t.timeAt(i);if(t.video){const r=Math.max(0,t.video.duration-.001),a=t.video,p=Math.min(Math.max(o,0),r),f=t.ctx.layoutOnly===!0;t.ctx.wait(Promise.resolve().then(()=>a.seek(p,f)));return}t.layers.forEach((r,a)=>{const p=o>=r.start&&o<r.end;j(r.el,p),p&&G(t.mesh,r.spec,a,`render at ${o.toFixed(2)} s`,()=>{r.spec.render(r.el,o,r.props,r.ctx)})})}export function screenEdge(t,i,e){const n=t.spec.background;if(!i||n===null)return;const[o,r,a,p]=i.corners,f=($,b)=>Math.hypot(b[0]-$[0],b[1]-$[1]),[l,d]=t.size,y=Math.min(f(o,r)/l,f(p,a)/l,f(o,p)/d,f(r,a)/d),w=Math.min(Math.ceil(e/Math.max(y,.001)),Math.max(l,d)),m=`0 0 0 ${String(w)}px ${n}`;t.edge!==m&&(t.el.style.boxShadow=m,t.edge=m)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{blurDiameter as
|
|
2
|
+
import{blurDiameter as ie}from"@allyhub/scenery";import{motionOf as ce}from"@allyhub/scenery";import{moireBand as de,moireCamera as le,moireScreen as me}from"@allyhub/scenery";import{apply as he,homography as fe,screenOnFrame as pe}from"@allyhub/scenery";import{drawnCamera as ue}from"../page/page.js";import{clearanceOf as ge,measure as ye,nearPlaneOf as be,solidsOf as ke}from"./index.js";const k=(n,t,r)=>n?{least:t<n.least?t:n.least,leastAt:t<n.least?r:n.leastAt,most:t>n.most?t:n.most,mostAt:t>n.most?r:n.mostAt}:{least:t,leastAt:r,most:t,mostAt:r},_=n=>n?Math.min(1,n.scale):1;function L(n,t){const r=new Map,h=[];for(const u of n)for(const g of u.keys){const m=r.get(g);m&&u.t-m.to<=t*1.5?m.to=u.t:(m&&h.push({key:g,...m}),r.set(g,{from:u.t,to:u.t}))}for(const[u,g]of r)h.push({key:u,...g});return h}export async function layerFacts(n,t){const r={layer:t.layer,start:t.start,end:t.end},h=[],u=t.sceneryAt(0),g=t.scenery===!1?{contacts:[],support:[],health:[]}:await ye(n,{t:u,near:.01,tolerance:.001,samples:400,grid:5,all:!1,volume:!0},t.time),m=n.bake.state;t.scenery!==!1&&m.digest!==""&&h.push({kind:"scenery-bake",data:{...r,laid:m.laid!==null,asked:m.asked,digest:m.digest,renderer:m.renderer,...m.laid?{bakedOn:m.laid.renderer}:{},...t.file===void 0?{}:{file:t.file}}});for(const e of g.contacts){const a=Math.max(e.depth?.aInB??0,e.depth?.bInA??0);h.push({kind:"scenery-contact",data:{...r,a:e.a,b:e.b,crossing:e.crossing,touching:e.touching,...e.gap!==void 0?{gap:e.gap}:{},...e.area!==void 0?{area:e.area}:{},...e.curve?{curve:e.curve.length}:{},...e.within?{within:e.within}:{},...e.depth?{depth:a}:{},...e.lift?{lift:{a:e.lift.a,b:e.lift.b}}:{},...e.volume!==void 0?{volume:e.volume}:{},...e.volumeMissing?{volumeMissing:e.volumeMissing}:{},...e.missing?{missing:e.missing}:{}}})}for(const e of g.support)h.push({kind:"scenery-support",data:{...r,object:e.path,gap:e.gap,sunk:e.sunk,on:e.on.map(a=>a.path),footprintShare:e.footprintShare,...e.margin!==void 0?{margin:e.margin}:{},nothingBelow:e.nothingBelow}});for(const e of g.health)e.closed&&e.degenerate===0&&!e.selfIntersections||h.push({kind:"mesh-health",data:{...r,object:e.path,triangles:e.triangles,closed:e.closed,openEdges:e.openEdges,nonManifoldEdges:e.nonManifoldEdges,degenerate:e.degenerate,selfIntersections:e.selfIntersections}});const B=t.fps??30,E=1/B,N=t.end-t.start,G=[],H=[],J=[],K=new Map;let O;const Q=Math.max(1,Math.round(B/10));let P;const f=t.frame??[1080,1920],T=[Math.max(64,Math.round(f[0]/4)),Math.max(64,Math.round(f[1]/4))],U=(t.screens??[]).map(e=>({mesh:e.mesh,size:e.size,shown:[],samples:[],...e.stretches?{stretches:e.stretches}:{},...e.text===void 0?{}:{text:e.text},...e.pixels?{pixels:e.pixels}:{},...e.drawn?{drawn:e.drawn}:{}}));for(let e=0,a=0;a<=N+1e-9;e++,a=e*E){const d=t.sceneryAt(a),se=n.stateFrom(t.camera,d,t.aspect,t.time),R=n.aim(se,t.aspect),o=R.resolved,D=ue(R),l=Math.round((t.start+a)*1e6)/1e6;if(G.push({t:l,position:o.position,forward:o.forward,up:o.up,right:o.right,lens:o.lens,yaw:D.yaw,pitch:D.pitch,roll:D.roll,...o.target?{target:o.target}:{}}),e%Q!==0)continue;for(const s of U){const y=n.screens.quad(s.mesh,o,f),W=n.screens.share(s.mesh,o,f),X=W>0&&(y===void 0||y.angle<90);if(s.shown.push({t:l,keys:X?["shown"]:[]}),!X||(s.share=k(s.share,W,l),!y))continue;const M=pe(s.size[0],s.size[1],y.corners,f,y.angle),oe=k(s.scale,M.scale.least,l);s.scale=k(oe,M.scale.most,l),s.angle=k(s.angle,M.angle,l);const Y=o.dof?n.screens.face(s.mesh):void 0;if(Y&&o.dof){const c=[[0,0],[1,0],[1,1],[0,1]].map(([I,S])=>{const z=Y.point(I,S).map((A,v)=>A-(o.position[v]??0));return(z[0]??0)*o.forward[0]+(z[1]??0)*o.forward[1]+(z[2]??0)*o.forward[2]}),j=Math.min(...c),F=Math.max(...c),C=c.map(I=>ie(o,I,f[1])),b=o.dof.focus>=j&&o.dof.focus<=F;s.blur=k(s.blur,b?0:Math.min(...C),l),s.blur=k(s.blur,Math.max(...C),l)}if(t.sensor){const c=n.screens.face(s.mesh),j=le(o,t.output??f,f[1],t.sensor,t.box?[t.box[0],t.box[1]]:[0,0]),F=c?me({quad:y.corners,corners:[c.point(0,0),c.point(1,0),c.point(1,1),c.point(0,1)],size:s.size,camera:o,...s.pixels?{panel:s.pixels}:{}}):void 0,C=fe(s.size[0],s.size[1],y.corners);let b={depth:0,period:1/0};if(F&&C)for(let S=1;S<8;S++)for(let z=1;z<12;z++){const A=he(C,s.size[0]*z/12,s.size[1]*S/8);if(A[0]<0||A[1]<0||A[0]>f[0]||A[1]>f[1])continue;const v=de(F,j,A);v&&v.depth>b.depth&&(b=v)}const I=s.moire?.most??-1;s.moire=k(s.moire,b.depth,l),b.depth>I&&Number.isFinite(b.period)&&(s.moirePeriod=b.period)}const x=await n.screens.hidden(s.mesh,R,T[0],T[1]);if(x){const c=s.hidden?.most??-1;s.hidden=k(s.hidden,x.hidden,l),x.hidden>c&&(s.by=x.by)}const[ae,re]=t.box??[0,0],Z=c=>Math.round(c*10)/10;s.samples.push({t:l,corners:y.corners.map(([c,j])=>[Z(c+ae),Z(j+re)]),share:M.share,scale:[M.scale.least,M.scale.most],angle:M.angle,...x?{hidden:Math.round(x.hidden*1e4)/1e4}:{}})}P&&n.animated&&P.refresh();const ne=P??=ke(n),w=ge(ne,o.position,be(o));w.nearest&&(!O||w.nearest.distance<O.distance)&&(O={object:w.nearest.path,distance:w.nearest.distance,t:l});for(const s of w.inside)K.set(s.path,s.closed);J.push({t:l,keys:w.inside.map(s=>s.path)}),H.push({t:l,keys:w.nearCut})}const q=E*Q,$=L(J,q),ee=L(H,q);h.push({kind:"camera-clearance",data:{...r,...O?{nearest:O}:{},inside:$.map(e=>({object:e.key,closed:K.get(e.key)??!1,from:e.from,to:e.to})),nearCut:ee.map(e=>({object:e.key,from:e.from,to:e.to}))}});for(const e of U){const a=d=>({least:Math.round(d.least*1e4)/1e4,leastAt:d.leastAt,most:Math.round(d.most*1e4)/1e4,mostAt:d.mostAt});h.push({kind:"scenery-screen",data:{...r,screen:e.mesh,size:[e.size[0],e.size[1]],frame:[f[0],f[1]],shown:L(e.shown,q).map(d=>({from:d.from,to:d.to})),...e.share?{share:a(e.share)}:{},...e.scale?{scale:a(e.scale)}:{},...e.angle?{angle:a(e.angle)}:{},...e.blur?{blur:a(e.blur)}:{},...e.moire?{moire:{...a(e.moire),...e.moirePeriod!==void 0?{period:Math.round(e.moirePeriod*10)/10}:{}}}:{},...e.hidden?{hidden:{...a(e.hidden),by:e.by??[]}}:{},samples:e.samples,...e.stretches?{stretches:[...e.stretches]}:{},...e.drawn?{drawn:e.drawn}:{},...e.text!==void 0&&e.scale?{text:{size:e.text,onFrame:[Math.round(e.text*e.scale.least*_(e.drawn)*100)/100,Math.round(e.text*e.scale.most*_(e.drawn)*100)/100]}}:{}}})}const te=n.cutsOf(t.camera,t.time),V=[];for(const e of te)for(let a=0,d=0;d<=N+1e-9;a++,d=a*E)if(t.sceneryAt(d)>=e){V.push(Math.round((t.start+d)*1e6)/1e6);break}const i=ce(G,V),p=e=>({peak:e.peak,at:e.at});return h.push({kind:"camera-motion",data:{...r,fps:B,length:i.length,peaks:{truck:p(i.truck),pedestal:p(i.pedestal),dolly:p(i.dolly),pan:p(i.pan),tilt:p(i.tilt),roll:p(i.roll),zoom:p(i.zoom),speed:p(i.speed),turn:p(i.turn),acceleration:p(i.acceleration),jerk:p(i.jerk)},smoothness:i.smoothness,step:i.step,...i.cuts.length>0?{cuts:i.cuts}:{}}}),n.pose(u,t.time),h}
|
|
@@ -126,6 +126,14 @@ export declare class Screens {
|
|
|
126
126
|
* Undefined while a corner is behind the camera (the screen is then not
|
|
127
127
|
* shown).
|
|
128
128
|
*/
|
|
129
|
+
/**
|
|
130
|
+
* The share of a w × h frame a screen's face covers, seen from a camera:
|
|
131
|
+
* its face cut where it passes behind the near plane, so a screen the
|
|
132
|
+
* camera is right up against (a corner behind it, which `quad` leaves
|
|
133
|
+
* undefined) fills the frame as it does. 0 when none of it is in front,
|
|
134
|
+
* or the camera sees its back.
|
|
135
|
+
*/
|
|
136
|
+
share(name: string, camera: ResolvedCamera, frame: readonly [number, number]): number;
|
|
129
137
|
quad(name: string, camera: ResolvedCamera, frame: readonly [number, number]): ScreenQuad | undefined;
|
|
130
138
|
/**
|
|
131
139
|
* How much of a screen what is in front of it hides from a camera, drawn
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{Color as
|
|
2
|
+
import{Color as W,Float32BufferAttribute as F,Mesh as O,PerspectiveCamera as D,Vector3 as f,WebGLRenderer as S}from"three";import{clipToFrame as G,project as A,shownCentre as $}from"@allyhub/scenery";import{reflectsAreaLights as P}from"../bake/apply.js";import{SceneryError as L}from"../errors.js";import{countable as k,seenFrom as R}from"../idbuffer.js";import{readTextureLevel as H}from"../measure/screen-readback.js";import{paths as I,vec as T}from"../scene.js";import{SCREEN_LIGHT_DEFAULTS as z,ScreenLight as V}from"../screen-light.js";import{ScreenPictures as _,canDrawElements as N}from"../screen-picture.js";import{length as C,normalize as Q,sub as q}from"../vec.js";function U(b,e){const i=b.brightness??e,n=typeof b.color=="string"?new W(b.color):b.color?new W(...b.color):new W(1,1,1);return[n.r*i,n.g*i,n.b*i]}function J(b){return(e,i)=>{let n=0;for(let r=0;r<b.length;r++){const s=b[r],t=b[(r+1)%b.length];if(!s||!t)return!1;const o=(t[0]-s[0])*(i-s[1])-(t[1]-s[1])*(e-s[0]);if(o===0)continue;const h=o>0?1:-1;if(n===0)n=h;else if(h!==n)return!1}return!0}}function E(b){let e;return b.traverse(i=>{!e&&i instanceof O&&(e=i)}),e}export class Screens{scene;renderer;object;mustObject;report;timers;pictures;lit=new Map;light=new V(P);mapped=new WeakSet;constructor(e){this.scene=e.scene,this.renderer=e.renderer,this.object=e.object,this.mustObject=e.mustObject,this.report=e.report,this.timers=e.timers}get drawsElements(){return this.renderer instanceof S&&N()}get canvas(){return this.pictures?.host??this.renderer.domElement}picture(e){return this.pictures?.get(e)}owns(e){return this.pictures?.owns(e)??!1}factorOf(e){return this.pictures?.factorOf(e)}adopt(e){this.pictures?.adopt(e)}frame(e,i){this.pictures?.frame(e,i)}show(e,i,n={}){if(!(this.renderer instanceof S))throw new L("build",`A screen drawn in the scenery ("${e}") needs the WebGL renderer.`);this.pictures??=new _(this.renderer,(r,s)=>{this.report({kind:"screen",level:"error",message:`The screen "${r}", drawn in the scenery, cannot show its element as it is: ${s}.`})}),this.pictures.show(e,i,n),this.lit.set(e,n.light===!1?!1:{cells:[...n.light?.cells??z.cells],specular:n.light?.specular??z.specular,base:(()=>{const r=n.light?.base??z.base;return r?U(r,n.brightness??1):null})()})}async paint(e,i=5e3){if(!this.pictures)return;const n=this.renderer.domElement;if(e&&(n.width!==e[0]||n.height!==e[1])&&this.renderer.setSize(e[0],e[1],!1),!await this.pictures.paint(this.timers,i))throw new L("build",`A screen drawn in the scenery was not painted within ${String(i)} ms (Chrome's HTML-in-Canvas): its picture would be the last moment's.`)}read(e,i,n){const r=this.pictures?.get(e);if(!r)return"it is not drawn in the scenery";if(!r.size)return"its picture was never copied into its texture";if(!(this.renderer instanceof S))return"its scenery is not drawn with WebGL";if(n)return"the scenery's WebGL context was lost";let s;try{s=H(this.renderer.getContext(),r.texture.sourceTexture,i)}finally{this.renderer.resetState()}return typeof s=="string"?s:{...s,element:r.element}}repaint(e){const i=this.pictures?.get(e);i&&(i.dirty=!0)}mapToFace(e,i){const n=this.face(e);if(!n)return;const r=new f(...n.point(0,0)),s=new f(...n.point(1,0)).sub(r),t=new f(...n.point(0,1)).sub(r),o=s.lengthSq(),h=t.lengthSq(),x=new f;for(const p of i){const l=p.geometry;if(this.mapped.has(l))continue;const u=l.getAttribute("position"),g=new Float32Array(u.count*2);p.updateWorldMatrix(!0,!1);for(let d=0;d<u.count;d++)x.fromBufferAttribute(u,d).applyMatrix4(p.matrixWorld).sub(r),g[d*2]=x.dot(s)/o,g[d*2+1]=x.dot(t)/h;l.setAttribute("uv",new F(g,2)),this.mapped.add(l)}}lightBy(e){const i=this.pictures,n=[];for(const r of e){const s=this.lit.get(r),t=i?.get(r),o=this.face(r);if(s===!1||s===void 0||!t?.size||!o)continue;const h=new f(...o.point(0,0));n.push({picture:t.texture,size:t.size,corner:h,across:new f(...o.point(1,0)).sub(h),down:new f(...o.point(0,1)).sub(h),brightness:t.brightness,cells:s.cells,specular:s.specular,...s.base?{base:s.base}:{}})}this.light.set(n),n.length!==0&&this.scene.traverse(r=>{if(!(r instanceof O))return;const s=Array.isArray(r.material)?r.material:[r.material];for(const t of s)t.isMeshStandardMaterial&&t.userData.screenLight!==!1&&!i?.owns(t)&&this.light.patch(t)})}face(e){const i=this.object(e);if(!i)return;const n=E(i);if(!n)return;const r=n.geometry;r.boundingBox||r.computeBoundingBox();const s=r.boundingBox;if(!s)return;n.updateWorldMatrix(!0,!1);const t=n.matrixWorld,o=(g,d)=>T(new f(s.min.x+(s.max.x-s.min.x)*g,s.max.y-(s.max.y-s.min.y)*d,s.max.z).applyMatrix4(t)),h=o(0,0),x=o(1,0),p=o(0,1),l=q(x,h),u=q(p,h);return{point:o,center:o(.5,.5),normal:T(new f(0,0,1).transformDirection(t)),up:Q([-u[0],-u[1],-u[2]]),width:C(l),height:C(u)}}share(e,i,n){const r=E(this.mustObject(e)),s=r?.geometry;if(!r||!s)return 0;s.boundingBox||s.computeBoundingBox();const t=s.boundingBox;if(!t)return 0;const o=new f((t.min.x+t.max.x)/2,(t.min.y+t.max.y)/2,t.max.z).applyMatrix4(r.matrixWorld);if(new f(0,0,1).transformDirection(r.matrixWorld).dot(new f(...i.position).sub(o))<=0)return 0;const x=[[t.min.x,t.max.y],[t.max.x,t.max.y],[t.max.x,t.min.y],[t.min.x,t.min.y]].map(([c,w])=>{const m=new f(c,w,t.max.z).applyMatrix4(r.matrixWorld);return[m.x,m.y,m.z]}),p=i.near,l=c=>A(i,c).depth,u=[];if(x.forEach((c,w)=>{const m=x[(w+1)%x.length]??c,a=l(c),M=l(m);if(a>=p&&u.push(c),a>=p!=M>=p){const j=(p-a)/(M-a);u.push([c[0]+(m[0]-c[0])*j,c[1]+(m[1]-c[1])*j,c[2]+(m[2]-c[2])*j])}}),u.length<3)return 0;const g=u.map(c=>{const w=A(i,c);return[(w.x+1)/2*n[0],(1-w.y)/2*n[1]]}),d=G(g,n[0],n[1]);let y=0;return d.forEach((c,w)=>{const m=d[(w+1)%d.length]??c;y+=c[0]*m[1]-m[0]*c[1]}),Math.min(1,Math.abs(y)/2/(n[0]*n[1]))}quad(e,i,n){const r=E(this.mustObject(e));if(!r)throw new L("name",`The screen "${e}" has no mesh to show content on.`);const s=r.geometry;s.boundingBox||s.computeBoundingBox();const t=s.boundingBox;if(!t)return;const o=[];let h=0;for(const[M,j]of[[t.min.x,t.max.y],[t.max.x,t.max.y],[t.max.x,t.min.y],[t.min.x,t.min.y]]){const B=new f(M,j,t.max.z).applyMatrix4(r.matrixWorld),v=A(i,[B.x,B.y,B.z]);if(!(v.depth>i.near))return;h=Math.max(h,v.depth),o.push([(v.x+1)/2*n[0],(1-v.y)/2*n[1]])}const[x,p,l,u]=o;if(!x||!p||!l||!u)return;const g=[x,p,l,u],[d,y]=$(g,n)??[.5,.5],c=new f(t.min.x+(t.max.x-t.min.x)*d,t.max.y-(t.max.y-t.min.y)*y,t.max.z).applyMatrix4(r.matrixWorld),w=new f(0,0,1).transformDirection(r.matrixWorld),m=new f(...i.position).sub(c).normalize(),a=Math.acos(Math.max(-1,Math.min(1,w.dot(m))))*180/Math.PI;return{corners:g,angle:a,depth:h}}async hidden(e,i,n,r){const s=this.mustObject(e),t=I(this.scene),o=k(this.scene,t,!0);o.some(a=>a.object===s)||o.push({object:s,name:e,path:t.get(s)??e});const h=this.quad(e,i.resolved,[n,r]);if(!h)return;const x=h.corners.map(a=>a[0]),p=h.corners.map(a=>a[1]),l=Math.max(0,Math.floor(Math.min(...x))),u=Math.max(0,Math.floor(Math.min(...p))),g=Math.min(n,Math.ceil(Math.max(...x))),d=Math.min(r,Math.ceil(Math.max(...p)));if(g<=l||d<=u)return;let y=i.camera;if(i.camera instanceof D){const a=i.camera.clone();a.setViewOffset(n,r,l,u,g-l,d-u),a.far=Math.min(a.far,h.depth*1.001+.001),a.updateProjectionMatrix(),y=a}const c=J(h.corners),w=y!==i.camera,[m]=await R(this.renderer,this.scene,y,o,w?g-l:n,w?d-u:r,{by:!0,of:new Set([s]),region:w?(a,M)=>c(a+l,M+u):c});if(!(!m||m.pixels===0&&m.hidden===0))return{hidden:m.hidden,by:(m.by??[]).map(a=>({object:a.path,share:a.share}))}}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{parseValue as
|
|
2
|
+
import{parseValue as x}from"numfmt";import{CellError as f,ERR as i,Matrix as h,numberText as M,readTyped as b}from"../values.js";const l=new Map,w=5e4;export function numberOfText(e){if(!/\d/u.test(e))return;if(l.has(e))return l.get(e);l.size>=w&&l.clear();const r=E(e);return l.set(e,r),r}function E(e){const r=b(e.trim());if(typeof r.value=="number")return r.value;if(e.trim()==="")return;const t=x(e);return typeof t?.value=="number"?t.value:void 0}export function toNumber(e){return typeof e=="number"?e:e==null?0:typeof e=="boolean"?e?1:0:e instanceof f?e:numberOfText(e)??i.VALUE}export function toText(e){return typeof e=="string"?e:e==null?"":typeof e=="number"?M(e):typeof e=="boolean"?e?"TRUE":"FALSE":e}export function toBool(e){if(typeof e=="boolean")return e;if(e==null)return!1;if(typeof e=="number")return e!==0;if(e instanceof f)return e;const r=e.trim().toUpperCase();return r==="TRUE"?!0:r==="FALSE"?!1:i.VALUE}const y=e=>typeof e=="number"?0:typeof e=="string"?1:2;export const sameNumber=(e,r)=>e===r?!0:Math.abs(e-r)>1e-13*Math.max(Math.abs(e),Math.abs(r))?!1:Number(e.toPrecision(15))===Number(r.toPrecision(15));export function compare(e,r){const t=e??(typeof r=="string"?"":typeof r=="boolean"?!1:0),n=r??(typeof e=="string"?"":typeof e=="boolean"?!1:0),o=y(t),c=y(n);if(o!==c)return o<c?-1:1;if(typeof t=="number"&&typeof n=="number")return sameNumber(t,n)?0:t<n?-1:1;if(typeof t=="string"&&typeof n=="string"){const a=t.toUpperCase(),u=n.toUpperCase();return a===u?0:a<u?-1:1}return t===n?0:t===!1?-1:1}export const finite=e=>Number.isFinite(e)?e:i.NUM;export function snap(e,r,t){return Math.abs(e)<=Math.max(Math.abs(r),Math.abs(t))*89e-17?0:e}export function arithmetic(e,r,t){const n=toNumber(r);if(n instanceof f)return n;const o=toNumber(t);if(o instanceof f)return o;switch(e){case"+":return finite(snap(n+o,n,o));case"-":return finite(snap(n-o,n,o));case"*":return finite(n*o);case"/":return o===0?i.DIV0:finite(n/o);default:return n===0&&o===0?i.NUM:n===0&&o<0?i.DIV0:finite(n**o)}}export function binary(e,r,t){if(r instanceof f)return r;if(t instanceof f)return t;switch(e){case"&":{const n=toText(r);if(n instanceof f)return n;const o=toText(t);return o instanceof f?o:`${n}${o}`}case"=":return compare(r,t)===0;case"<>":return compare(r,t)!==0;case"<":return compare(r,t)<0;case"<=":return compare(r,t)<=0;case">":return compare(r,t)>0;case">=":return compare(r,t)>=0;default:return arithmetic(e,r,t)}}export function mapBoth(e,r,t){const n=Math.max(e.rows,r.rows),o=Math.max(e.cols,r.cols),c=new Array(n*o),a=(u,s,d)=>{const p=u.rows===1?0:s,m=u.cols===1?0:d;return p<u.rows&&m<u.cols?u.at(p,m):void 0};for(let u=0;u<n;u++)for(let s=0;s<o;s++){const d=a(e,u,s),p=a(r,u,s);c[u*o+s]=d===void 0||p===void 0?i.NA:t(d,p)}return new h(n,o,c)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{MAX_COLUMNS as E,MAX_ROWS as k,overlaps as O}from"../address.js";import{CellError as m,ERR as h,Matrix as p,serialOfDate as _}from"../values.js";import{filteredRows as B}from"../filter.js";import{FormulaCell as y,SharedFormula as I}from"../workbook.js";import{analyse as z}from"./analyse.js";import{Graph as T}from"./graph.js";import{fromWire as G,matrixFromWire as D,matrixToWire as W,toWire as P}from"./remote.js";import{RangeCache as U}from"./indexes.js";import{binary as S,mapBoth as H,toNumber as q}from"./coerce.js";import{FUNCTIONS as v}from"./functions/index.js";import{fillsGroup as j,paramAt as X}from"./functions/define.js";import{Lambda as M,MISSING as F,Missing as x,Reference as u,Union as b}from"./types.js";export function seededRandom(l){let t=2166136261;for(let e=0;e<l.length;e++)t=Math.imul(t^l.charCodeAt(e),16777619);return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Y=new Set,Z=/\b(?:SUBTOTAL|AGGREGATE)\(/iu,$=2e3,N=12,J=(l,t)=>!l||!t?l===t:l.rows!==t.rows||l.cols!==t.cols?!1:l.data.every((e,s)=>e===t.data[s]),K=(l,t)=>l.row<t.row||l.row===t.row&&l.col<t.col;export class Calc{cycles=[];computed=0;nowSerial;random;pass=0;stack=[];inCycle=new Set;namesAt=new Set;graph=new T({readsOf:t=>this.readsOf(t),readsAt:(t,e,s,n)=>this.readsAt(t,e,s,n)});graphMade=!1;reports;replica;settled=new Set;moved=[];unsettled=new Set;hiddenBy=new Map;volatiles=new Set;indexes=new U;results=new U;wb;constructor(t,e={}){this.wb=t;const{now:s,random:n}=e;this.reports=e.report===!0,this.replica=e.replica===!0,this.nowSerial=()=>_(s??new Date),this.random=n??Math.random;for(const o of t.sheets)o.expand()}allCells(){return this.wb.sheets.flatMap(t=>[...t.formulas])}filtered(t){return this.hiddenBy.get(t)??Y}calculate(){if(this.replica){for(const e of this.wb.sheets)e.clearSpills();for(const e of this.allCells())e.state=0;return this}this.hiddenBy.clear(),this.indexes.clear(),this.results.clear();for(const e of this.wb.sheets)e.clearSpills();this.moved=[],this.unsettled.clear();const t=this.allCells();for(const e of t)e.state=1;return this.cycles=[],this.inCycle.clear(),this.run(t),this.applyFilters(t),this}applyFilters(t){for(const e of this.wb.sheets){if(e.filters.every(n=>n.columns.size===0))continue;const s=B(e,this);s.size>0&&this.hiddenBy.set(e,s)}if(this.hiddenBy.size!==0&&t.some(e=>Z.test(e.shared.text))){for(const e of t)e.state=1;this.cycles=[],this.inCycle.clear(),this.run([...t])}}value(t,e,s){return this.read(t,e,s)}read(t,e,s){const n=t.at(e,s);return n===void 0?this.ghost(t,e,s):typeof n!="object"||n instanceof m?n:(n.state===1?this.compute(n):n.state===2&&this.circular(n),n.value)}ghost(t,e,s){const n=t.spillAt(e,s);if(!n)return null;if(n.state===1)this.compute(n);else if(n.state===2)return this.circular(n),null;const{array:o}=n;return o&&t.spillAt(e,s)===n?o.at(e-n.row,s-n.col):null}circular(t){const e=this.stack.indexOf(t),s=e<0?[t]:this.stack.slice(e);s.some(n=>this.inCycle.has(n))||this.cycles.push(s);for(const n of s)this.inCycle.add(n)}forget(t,e){this.indexes.changed(t,e),this.results.changed(t,e)}run(t){for(const e of t){const{sheet:s,row:n,col:o}=e;this.forget(s,{top:n,left:o,bottom:n,right:o}),e.spill&&this.forget(s,e.spill)}this.computed=0;for(const e of this.order(t))e.state===1&&this.compute(e);this.spread()}spread(){for(let t=0;this.moved.length>0;t++){const e=this.moved;if(this.moved=[],t>=N*2)break;if(t>=N)for(const{sheet:o,area:r}of e)for(const i of o.spillsIn(r))this.unsettled.add(i);this.build();const s=new Set,n=[...this.unsettled];for(const{sheet:o,area:r}of e)n.push(...this.readersIn(o,r),...o.blockedBy(r));for(;;){const o=n.pop();if(!o)break;s.has(o)||(s.add(o),n.push(...this.readers(o.sheet,o.row,o.col)))}if(s.size!==0){for(const o of s)o.state=1,this.inCycle.delete(o);this.cycles=this.cycles.filter(o=>!o.some(r=>s.has(r))),this.indexes.clear(),this.results.clear();for(const o of this.order([...s]))o.state===1&&this.compute(o)}}for(const t of this.wb.sheets)t.tighten()}spillOut(t,e){const{sheet:s,row:n,col:o}=t,r={top:n,left:o,bottom:n+e.rows-1,right:o+e.cols-1},i=s.spillsIn(r).filter(c=>c!==t);if(r.bottom>=k||r.right>=E||s.holds(r,t)||s.tables.some(c=>O(c.area,r))||s.merges.some(c=>O(c,r))||i.some(c=>K(c,t)))return s.blockSpill(t,r),!1;for(const c of i)this.evict(c,r);return s.placeSpill(t,r),!0}evict(t,e){const{sheet:s,spill:n}=t;n&&(s.clearSpill(t),s.blockSpill(t,e),t.array=void 0,t.value=h.SPILL,this.moved.push({sheet:s,area:n}),this.reports&&this.settled.add(t))}analysisOf(t){return t.analysis??=z(this.wb,t)}readsOf(t){const e=[],s=V(t);for(const n of this.analysisOf(t.shared).reads){const o=n.kind==="ref"?this.resolveRef(n,s):this.structured(n,s);o instanceof u?e.push(o):o instanceof b&&e.push(...o.parts)}return e}readsAt(t,e,s,n){const o={sheet:e,row:s,col:n,dr:s-t.row,dc:n-t.col},r=[];for(const i of this.analysisOf(t).reads){const a=i.kind==="ref"?this.resolveRef(i,o):this.structured(i,o);a instanceof u?r.push(a):a instanceof b?r.push(...a.parts):r.push(void 0)}return r}readsOfFormula(t,e){const s=[],n={sheet:e,row:t.row,col:t.col,dr:0,dc:0};for(const o of this.analysisOf(t).reads){const r=o.kind==="ref"?this.resolveRef(o,n):this.structured(o,n);r instanceof u?s.push(r):r instanceof b&&s.push(...r.parts)}return s}order(t){this.pass+=1;const{pass:e}=this,s=[],n=new Set,o=[],r=i=>{i.mark=e,o.push({cell:i,reads:this.pending(i,n),next:0})};for(const i of t)if(i.mark!==e)for(r(i);;){const a=o[o.length-1];if(!a)break;const c=a.reads[a.next];a.next+=1,c===void 0?(s.push(a.cell),o.pop()):c.mark!==e&&c.state===1&&r(c)}return s}pending(t,e){const s=[];for(const n of this.readsOf(t)){const{sheet:o}=n;if(n.single){const i=o.at(n.top,n.left);i instanceof y&&s.push(i);continue}if(e.has(n.key))continue;e.add(n.key);const r=Math.min(n.right,o.columnsUsed-1);for(let i=n.left;i<=r;i++){if(!o.hasFormulas(i))continue;const[a,c]=o.span(i,n.top,n.bottom);for(let f=a;f<=c;f++){const d=o.at(f,i);d instanceof y&&s.push(d)}}}return s}compute(t){if(this.stack.length>=$){t.value=h.CALC,t.state=0;return}t.state=2,this.stack.push(t),this.computed+=1;const{node:e}=t.shared,s=e?this.top(this.eval(e,V(t))):h.NAME;this.stack.pop(),this.unsettled.has(t)&&!this.inCycle.has(t)&&(this.inCycle.add(t),this.cycles.push([t])),this.settleResult(t,s),t.state=0,this.reports&&this.settled.add(t)}settleResult(t,e){const{sheet:s}=t,n=t.spill,o=t.array;if(s.clearSpill(t),t.array=void 0,e instanceof p){const i=tt(e);i.rows*i.cols<=1||this.spillOut(t,i)?(t.array=i,t.value=i.at(0,0)??0):t.value=h.SPILL}else t.value=e;this.inCycle.has(t)&&(s.clearSpill(t),t.value=h.CYCLE,t.array=void 0);const r=t.spill;(!J(o,t.array)||!Q(n,r))&&(n&&this.moved.push({sheet:s,area:n}),r&&this.moved.push({sheet:s,area:r}))}top(t){const e=this.flat(t);return e===null?0:e}flat(t){return t instanceof u?t.single?this.read(t.sheet,t.top,t.left):this.matrix(t):t instanceof b?h.VALUE:t instanceof M?h.CALC:t instanceof x?null:t}matrix(t){const e=t.bottom===k-1?Math.min(t.bottom,t.sheet.lastRow):t.bottom,s=t.right===E-1?Math.min(t.right,t.sheet.columnsUsed-1):t.right,n=Math.max(0,e-t.top+1),o=Math.max(0,s-t.left+1),r=new Array(n*o);for(let i=0;i<n;i++)for(let a=0;a<o;a++)r[i*o+a]=this.read(t.sheet,t.top+i,t.left+a);return new p(n,o,r)}each(t,e){const{sheet:s}=t,n=Math.min(t.right,s.columnsUsed-1);for(let o=t.left;o<=n;o++){const[r,i]=s.span(o,t.top,t.bottom);for(let a=r;a<=i;a++){const c=s.at(a,o);if(c===void 0){s.spillAt(a,o)&&e(this.read(s,a,o),a,o);continue}e(typeof c=="object"&&!(c instanceof m)?this.read(s,a,o):c,a,o)}}}evaluate(t,e){const{node:s}=t;return s?this.top(this.eval(s,{sheet:e,row:t.row,col:t.col,dr:0,dc:0})):h.NAME}evaluateAt(t,e,s,n){const{node:o}=t;return o?this.top(this.eval(o,{sheet:e,row:s,col:n,dr:s-t.row,dc:n-t.col})):h.NAME}bound(t,e,s){const n=t.abs?t.index:t.index+e;return n<0||n>=s?void 0:n}resolveRef(t,e){const s=t.sheet===void 0?e.sheet:this.wb.sheet(t.sheet);if(!s)return h.REF;let n=0,o=E-1,r=0,i=k-1;if(t.col){const a=this.bound(t.col,e.dc,E),c=this.bound(t.col2??t.col,e.dc,E);if(a===void 0||c===void 0)return h.REF;n=Math.min(a,c),o=Math.max(a,c)}if(t.row){const a=this.bound(t.row,e.dr,k),c=this.bound(t.row2??t.row,e.dr,k);if(a===void 0||c===void 0)return h.REF;r=Math.min(a,c),i=Math.max(a,c)}if(t.lastSheet!==void 0){const a=this.wb.sheet(t.lastSheet);if(!a)return h.REF;const[c,f]=[Math.min(s.index,a.index),Math.max(s.index,a.index)];return new b(this.wb.sheets.slice(c,f+1).map(d=>new u(d,r,n,i,o)))}return new u(s,r,n,i,o)}structured(t,e){const s=t.table===void 0?e.sheet.tableAt(e.row,e.col):this.wb.table(t.table);return s?et(s,t,e):t.table===void 0?h.REF:h.NAME}nameValue(t,e,s){const n=t.toLowerCase();if(s===void 0)for(let c=e.scope;c;c=c.parent){const f=c.names.get(n);if(f!==void 0)return f}const o=s===void 0?e.sheet:this.wb.sheet(s);if(!o)return h.REF;const r=this.wb.name(t,o);if(r){if(!r.formula)return r.value??null;const{node:c}=r.formula;if(!c)return h.NAME;if(this.namesAt.has(n))return h.CYCLE;this.namesAt.add(n);try{return this.eval(c,{sheet:e.sheet,row:0,col:0,dr:0,dc:0})}finally{this.namesAt.delete(n)}}const i=this.wb.table(t);if(i){const{top:c,left:f,bottom:d,right:g}=i.data;return new u(i.sheet,c,f,d,g)}const a=v.get(t.toUpperCase());return a&&a.kind!=="lazy"?st(a,t,e):h.NAME}intersect(t,e){return!(t instanceof u)||t.single?t:t.cols===1&&e.row>=t.top&&e.row<=t.bottom?new u(t.sheet,e.row,t.left,e.row,t.left):t.rows===1&&e.col>=t.left&&e.col<=t.right?new u(t.sheet,t.top,e.col,t.top,e.col):h.VALUE}unary(t,e){const s=this.flat(t);return s instanceof p?new p(s.rows,s.cols,s.data.map(e)):e(s)}operate(t,e,s){const n=this.flat(e),o=this.flat(s);if(n instanceof p||o instanceof p){const r=(i,a)=>S(t,i,a);return H(n instanceof p?n:new p(1,1,[n]),o instanceof p?o:new p(1,1,[o]),r)}return S(t,n,o)}rangeOf(t,e){return t instanceof m?t:e instanceof m?e:!(t instanceof u)||!(e instanceof u)||t.sheet!==e.sheet?h.REF:new u(t.sheet,Math.min(t.top,e.top),Math.min(t.left,e.left),Math.max(t.bottom,e.bottom),Math.max(t.right,e.right))}intersection(t,e){if(t instanceof m)return t;if(e instanceof m)return e;if(!(t instanceof u)||!(e instanceof u))return h.REF;const s=Math.max(t.top,e.top),n=Math.max(t.left,e.left),o=Math.min(t.bottom,e.bottom),r=Math.min(t.right,e.right);return t.sheet!==e.sheet||s>o||n>r?h.NULL:new u(t.sheet,s,n,o,r)}union(t,e){if(t instanceof m)return t;if(e instanceof m)return e;const s=o=>o instanceof u?[o]:o instanceof b?o.parts:[],n=[...s(t),...s(e)];return n.length===0?h.VALUE:new b(n)}eval(t,e){switch(t.kind){case"number":case"string":case"boolean":return t.value;case"error":return m.of(t.code);case"missing":return F;case"ref":return this.resolveRef(t,e);case"structured":return this.structured(t,e);case"name":return this.nameValue(t.name,e,t.sheet);case"paren":return this.eval(t.arg,e);case"unary":{const s=this.eval(t.arg,e);return t.op==="@"?this.intersect(s,e):t.op==="+"?s:this.unary(s,n=>S("*",n,-1))}case"postfix":{const s=this.eval(t.arg,e);if(t.op==="%")return this.unary(s,n=>S("/",n,100));if(s instanceof u&&s.single){const n=s.sheet.at(s.top,s.left);if(n instanceof y){this.read(s.sheet,s.top,s.left);const{spill:o}=n;if(o)return new u(s.sheet,o.top,o.left,o.bottom,o.right);if(n.array)return s}}return h.REF}case"binary":{const s=this.eval(t.left,e),n=this.eval(t.right,e);return t.op===":"?this.rangeOf(s,n):t.op===" "?this.intersection(s,n):t.op===","?this.union(s,n):this.operate(t.op,s,n)}case"array":return new p(t.rows.length,t.rows[0]?.length??0,t.rows.flatMap(s=>s.map(n=>{const o=this.eval(n,e);return o instanceof p||o instanceof u||o instanceof b||o instanceof M||o instanceof x?h.VALUE:o})));case"invoke":{const s=this.eval(t.callee,e);return s instanceof M?this.invoke(s,t.args,e):s instanceof m?s:h.VALUE}case"call":return this.call(t.name,t.args,e)}}invoke(t,e,s){return this.apply(t,e.map(n=>this.eval(n,s)))}apply(t,e){if(t.named!==void 0){const n=v.get(t.named);return!n||n.kind==="lazy"?h.NAME:e.length<n.min||e.length>n.max?h.VALUE:this.applyFunction(n,e,t.frame)}if(e.length>t.params.length)return h.VALUE;const s=new Map;return t.params.forEach((n,o)=>{s.set(n,e[o]??F)}),this.eval(t.body,{...t.frame,scope:{names:s,...t.frame.scope?{parent:t.frame.scope}:{}}})}call(t,e,s){const n=v.get(t);if(!n){const o=this.nameValue(t,s);return o instanceof M?this.invoke(o,e,s):h.NAME}return e.length<n.min||e.length>n.max?h.VALUE:n.kind==="lazy"?n.call(e,{calc:this,frame:s}):this.applyFunction(n,e.map(o=>this.eval(o,s)),s)}applyFunction(t,e,s){const n={calc:this,frame:s};if(t.kind==="lazy")return h.VALUE;if(t.kind==="raw")return j(t.params,e.length)?this.over(e,r=>X(t.params,r)==="value",r=>t.call(r,n)):h.VALUE;const o=t.errors===!0;return this.over(e,()=>!0,r=>{const i=r.map(a=>a instanceof x?void 0:a);if(!o){for(const a of i)if(a instanceof m)return a}return t.call(...i)})}over(t,e,s){const n=[],o=new Map;for(const[f,d]of t.entries()){if(!e(f)||d instanceof x){n.push(d);continue}const g=this.flat(d);g instanceof p&&o.set(f,g),n.push(g)}if(o.size===0)return s(n);const r=[...o.values()],i=Math.max(...r.map(f=>f.rows)),a=Math.max(...r.map(f=>f.cols));if(i===0||a===0)return h.CALC;const c=new Array(i*a);for(let f=0;f<i;f++)for(let d=0;d<a;d++){const g=n.map((C,A)=>{const w=o.get(A);if(!w)return C;const L=w.rows===1?0:f,R=w.cols===1?0:d;return L<w.rows&&R<w.cols?w.at(L,R):h.NA});c[f*a+d]=this.element(s(g))}return new p(i,a,c)}element(t){const e=this.flat(t);return e instanceof p?e.rows>0&&e.cols>0?e.at(0,0):h.CALC:e}scalar(t,e){if(t instanceof x)return null;if(t instanceof u){const s=this.intersect(t,e);return s instanceof u?this.read(s.sheet,s.top,s.left):h.VALUE}return t instanceof p?t.at(0,0):t instanceof b||t instanceof M?h.VALUE:t}recalculate(){if(this.replica)return this;const t=this.allCells().filter(e=>this.analysisOf(e.shared).volatile);return this.mark(t),this}build(){if(this.graphMade)return;this.graphMade=!0;const t=this.allCells();for(const e of t)this.analysisOf(e.shared).volatile&&this.volatiles.add(e);this.graph.build(t)}addEdges(t){this.analysisOf(t.shared).volatile&&this.volatiles.add(t),this.graph.add(t)}removeEdges(t){this.volatiles.delete(t),this.graph.remove(t)}readersIn(t,e){return this.graph.readersIn(t,e)}readers(t,e,s){return this.build(),this.graph.readers(t,e,s)}precedents(t){return this.readsOf(t)}mark(t){this.build();const e=new Set(t),s=[...t];for(;;){const n=s.pop();if(!n)break;for(const o of this.readers(n.sheet,n.row,n.col))e.has(o)||(e.add(o),s.push(o))}this.settle(e)}settle(t){for(const e of t)e.state=1,this.inCycle.delete(e);this.cycles=this.cycles.filter(e=>!e.some(s=>t.has(s))),this.run([...t])}set(t,e,s,n){const o=typeof n=="string"&&n.length>1&&n.startsWith("=")?new y(new I(n,e,s,{file:""}),t,e,s):void 0;this.change([{sheet:t,row:e,col:s,slot:o??n??void 0}])}prepare(){this.build()}change(t){if(this.replica){for(const{sheet:o,row:r,col:i,slot:a}of t){const c=o.at(r,i);c instanceof y&&o.clearSpill(c),o.replace(r,i,a),a instanceof y&&(a.state=0)}return}this.build();const e=new Set,s=[...this.unsettled];this.unsettled.clear();const n=new Set;for(const{sheet:o,row:r,col:i,slot:a}of t){const c=o.at(r,i);c instanceof y&&(n.add(c),this.inCycle.delete(c),this.removeEdges(c),e.delete(c),c.spill&&this.moved.push({sheet:o,area:c.spill}),o.clearSpill(c));const f=o.spillAt(r,i);f&&s.push(f),s.push(...o.blockedBy({top:r,left:i,bottom:r,right:i})),o.replace(r,i,a),this.forget(o,{top:r,left:i,bottom:r,right:i}),a instanceof y&&(this.addEdges(a),e.add(a))}n.size>0&&(this.cycles=this.cycles.filter(o=>!o.some(r=>n.has(r))));for(const{sheet:o,row:r,col:i}of t)s.push(...this.readers(o,r,i));for(s.push(...this.volatiles);;){const o=s.pop();if(!o)break;e.has(o)||(e.add(o),s.push(...this.readers(o.sheet,o.row,o.col)))}this.settle(e)}setName(t,e){const s=this.wb.name(t);if(!s)throw new Error(`There is no name ${t}.`);s.value=e,delete s.formula;const n=t.toLowerCase();this.mark(this.allCells().filter(o=>this.analysisOf(o.shared).names.has(n)))}takeComputed(){const t=[];for(const e of this.settled)t.push({sheet:e.sheet.index,row:e.row,col:e.col,value:P(e.value),...e.array?{array:W(e.array)}:{},...e.spill?{spill:e.spill}:{},...e.blocked?{blocked:e.blocked}:{}});return this.settled.clear(),{cells:t,cycles:this.cycles.map(e=>e.map(s=>({sheet:s.sheet.index,row:s.row,col:s.col}))),hidden:[...this.hiddenBy].map(([e,s])=>({sheet:e.index,rows:[...s]}))}}receive(t){for(const s of t.cells){const n=this.wb.sheets[s.sheet],o=n?.at(s.row,s.col);!n||!(o instanceof y)||(n.clearSpill(o),o.value=G(s.value),o.array=s.array?D(s.array):void 0,s.spill&&n.placeSpill(o,s.spill),s.blocked&&n.blockSpill(o,s.blocked),o.state=0)}this.cycles=t.cycles.flatMap(s=>{const n=s.flatMap(o=>{const r=this.wb.sheets[o.sheet]?.at(o.row,o.col);return r instanceof y?[r]:[]});return n.length>0?[n]:[]});const e=new Map(this.hiddenBy);this.hiddenBy.clear();for(const{sheet:s,rows:n}of t.hidden){const o=this.wb.sheets[s];if(!o)continue;const r=e.get(o),i=r?.size===n.length&&n.every(a=>r.has(a));this.hiddenBy.set(o,i?r:new Set(n))}for(const s of this.wb.sheets)s.tighten()}numberOf(t){return q(t)}}const Q=(l,t)=>l?.top===t?.top&&l?.left===t?.left&&l?.bottom===t?.bottom&&l?.right===t?.right;function tt(l){return l.data.some(t=>t===null)?new p(l.rows,l.cols,l.data.map(t=>t??0)):l}function V(l){return{sheet:l.sheet,row:l.row,col:l.col,dr:l.row-l.shared.row,dc:l.col-l.shared.col}}function et(l,t,e){const{sheet:s}=l,n=l.area;let o=n.left,r=n.right;const[i,a]=t.columns;if(i!==void 0){const A=l.column(i),w=a===void 0?A:l.column(a);if(!A||!w)return h.REF;o=n.left+Math.min(A.index,w.index),r=n.left+Math.max(A.index,w.index)}if(t.thisRow)return e.sheet!==s||e.row<=n.top||e.row>n.bottom?h.VALUE:new u(s,e.row,o,e.row,r);const c=t.sections;if(c.includes("#Totals"))return h.REF;const f=c.includes("#All")||c.includes("#Headers"),d=c.length===0||c.includes("#All")||c.includes("#Data"),g=f?n.top:n.top+1,C=d?n.bottom:n.top;return new u(s,g,o,C,r)}function st(l,t,e){return new M([],{kind:"call",name:l.name,written:t,args:[]},e,l.name)}
|
|
2
|
+
import{MAX_COLUMNS as v,MAX_ROWS as C,overlaps as N}from"../address.js";import{CellError as b,ERR as h,Matrix as m,serialOfDate as G}from"../values.js";import{filteredRows as W}from"../filter.js";import{FormulaCell as k,SharedFormula as P}from"../workbook.js";import{analyse as q}from"./analyse.js";import{Graph as H}from"./graph.js";import{fromWire as $,matrixFromWire as j,matrixToWire as K,toWire as X}from"./remote.js";import{RangeCache as U}from"./indexes.js";import{binary as O,mapBoth as Y,toNumber as Z}from"./coerce.js";import{FUNCTIONS as _}from"./functions/index.js";import{fillsGroup as J,paramAt as Q}from"./functions/define.js";import{Lambda as S,MISSING as T,Missing as L,Reference as d,Union as x,pushAll as M}from"./types.js";export function seededRandom(l){let t=2166136261;for(let e=0;e<l.length;e++)t=Math.imul(t^l.charCodeAt(e),16777619);return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const tt=new Set,et=/\b(?:SUBTOTAL|AGGREGATE)\(/iu,I=2e3,st=50,nt=1024;class V extends Error{cell;constructor(t){super("computed first"),this.cell=t}}const B=12;export const ITERATION_DEFAULTS={max_iterations:100,max_change:.001};function ot(l,t){return typeof l=="number"&&typeof t=="number"?Math.abs(t-l):l===t||l instanceof b&&t instanceof b&&l.code===t.code?0:1/0}const it=(l,t)=>!l||!t?l===t:l.rows!==t.rows||l.cols!==t.cols?!1:l.data.every((e,s)=>e===t.data[s]),rt=(l,t)=>l.row<t.row||l.row===t.row&&l.col<t.col;export class Calc{cycles=[];computed=0;iterated;nowSerial;random;pass=0;lambdaSlots=0;stack=[];inCycle=new Set;looping=new Set;tablesOf;inTables=!1;loop=new Set;around=new Set;namesAt=new Set;graph=new H({readsOf:t=>this.readsOf(t),readsAt:(t,e,s,o)=>this.readsAt(t,e,s,o)});graphMade=!1;reports;replica;settled=new Set;moved=[];unsettled=new Set;hiddenBy=new Map;volatiles=new Set;indexes=new U;results=new U;wb;constructor(t,e={}){this.wb=t;const{now:s,random:o}=e;this.reports=e.report===!0,this.replica=e.replica===!0,this.nowSerial=()=>G(s??new Date),this.random=o??Math.random;for(const n of t.sheets)n.expand()}allCells(){return this.wb.sheets.flatMap(t=>[...t.formulas])}filtered(t){return this.hiddenBy.get(t)??tt}calculate(){if(this.replica){for(const e of this.wb.sheets)e.clearSpills();for(const e of this.allCells())e.state=0;return this}this.hiddenBy.clear(),this.indexes.clear(),this.results.clear();for(const e of this.wb.sheets)e.clearSpills();this.moved=[],this.unsettled.clear();const t=this.allCells();for(const e of t)e.state=1;return this.cycles=[],this.inCycle.clear(),this.looping.clear(),this.loop=new Set,this.around.clear(),this.tablesOf=void 0,this.iterated=void 0,this.run(t),this.applyFilters(t),this}iteration(){const t=this.wb.file.iteration;if(t!==void 0)return{max_iterations:(t===!0?void 0:t.max_iterations)??ITERATION_DEFAULTS.max_iterations,max_change:(t===!0?void 0:t.max_change)??ITERATION_DEFAULTS.max_change}}applyFilters(t){for(const e of this.wb.sheets){if(e.filters.every(o=>o.columns.size===0))continue;const s=W(e,this);s.size>0&&this.hiddenBy.set(e,s)}if(this.hiddenBy.size!==0&&t.some(e=>et.test(e.shared.text))){for(const e of t)e.state=1;this.cycles=[],this.inCycle.clear(),this.run([...t])}}value(t,e,s){return this.read(t,e,s)}read(t,e,s){const o=t.at(e,s);return o===void 0?this.ghost(t,e,s):typeof o!="object"||o instanceof b?o:(o.state===1?this.computeNow(o):o.state===2&&this.circular(o),o.value)}ghost(t,e,s){const o=t.spillAt(e,s);if(!o)return null;if(o.state===1)this.computeNow(o);else if(o.state===2)return this.circular(o),null;const{array:n}=o;return n&&t.spillAt(e,s)===o?n.at(e-o.row,s-o.col):null}circular(t){const e=this.stack.indexOf(t),s=e<0?[t]:this.stack.slice(e);if(this.iteration()){for(const o of s)this.looping.add(o);return}s.some(o=>this.inCycle.has(o))||this.cycles.push(s);for(const o of s)this.inCycle.add(o)}forget(t,e){this.indexes.changed(t,e),this.results.changed(t,e)}run(t){for(const e of t){const{sheet:s,row:o,col:n}=e;this.forget(s,{top:o,left:n,bottom:o,right:n}),e.spill&&this.forget(s,e.spill)}t.some(e=>this.loop.has(e))&&(this.iterated=void 0),this.computed=0;for(const e of this.order(t))e.state===1&&this.computeNow(e);this.spread(),this.iterate(),this.tables()}tableCells(){if(this.tablesOf)return this.tablesOf;const t=new Map;for(const e of this.allCells())if(R(e.shared.node)){const s=t.get(e.shared);s?s.push(e):t.set(e.shared,[e])}return this.tablesOf=t,t}tables(){if(this.replica||this.inTables)return;const t=this.tableCells();if(t.size!==0){this.inTables=!0;try{const e=[];for(const[n,i]of t)this.table(n,i),e.push(...i);const s=new Set(e),o=new Set;for(const n of e)for(const i of this.readers(n.sheet,n.row,n.col))s.has(i)||o.add(i);o.size>0&&this.mark([...o])}finally{this.inTables=!1}}}operations(t){const e=new Map,s=(n,i)=>{const r=n===void 0?void 0:this.eval(n,i);return r instanceof d&&r.single?r:void 0},o=t.map(n=>{const i=n.shared.node;if(i?.kind!=="call")return h.REF;const r=F(n),a=s(i.args[0],r);if(!a)return h.REF;const c=[];for(let f=1;f+1<i.args.length;f+=2){const u=s(i.args[f],r),w=s(i.args[f+1],r);if(!u||!w)return h.REF;const E=`${String(u.sheet.index)}:${String(u.top)}:${String(u.left)}`;e.has(E)||e.set(E,{sheet:u.sheet,row:u.top,col:u.left,slot:u.sheet.at(u.top,u.left)});const A=this.read(w.sheet,w.top,w.left);c.push({sheet:u.sheet,row:u.top,col:u.left,slot:A??void 0})}return this.change(c),this.read(a.sheet,a.top,a.left)});e.size>0&&this.change([...e.values()]),t.forEach((n,i)=>{n.value=o[i]??null,this.reports&&this.settled.add(n)})}table(t,e){const[s]=e,o=t.node;if(!s||o?.kind!=="call")return;if(o.args.length>2){this.operations(e);return}const{sheet:n}=s,i=t.row,r=t.col,a={sheet:n,row:i,col:r,dr:0,dc:0},c=p=>{if(p===void 0||p.kind==="missing")return null;const g=this.eval(p,a);return g instanceof d&&g.single?g:void 0},f=c(o.args[0]),u=c(o.args[1]),w=p=>{for(const g of e)g.value=p,this.reports&&this.settled.add(g)};if(f===void 0||u===void 0||f===null&&u===null||i===0||r===0){w(h.REF);return}const A=[f,u].filter(p=>p!==null).map(p=>({sheet:p.sheet,row:p.top,col:p.left,slot:p.sheet.at(p.top,p.left)})),y=e.map(p=>{const g=[];f&&g.push({sheet:f.sheet,row:f.top,col:f.left,slot:this.read(n,i-1,p.col)??void 0}),u&&g.push({sheet:u.sheet,row:u.top,col:u.left,slot:this.read(n,p.row,r-1)??void 0}),this.change(g);const[z,D]=f&&u?[i-1,r-1]:u?[i-1,p.col]:[p.row,r-1];return this.read(n,z,D)});this.change(A),e.forEach((p,g)=>{p.value=y[g]??null,this.reports&&this.settled.add(p)})}iterate(){const t=this.iteration();if(!t||this.looping.size===0){this.looping.clear();return}for(const i of this.looping)this.around.add(i);const e=this.downstream([...this.looping]),s=[...e];let o=1,n=1/0;for(;o<t.max_iterations;){const i=s.map(r=>r.value);this.looping.clear(),this.indexes.clear(),this.results.clear();for(const r of s)r.state=1;for(const r of this.order(s))r.state===1&&this.compute(r);if(o+=1,n=0,s.forEach((r,a)=>{n=Math.max(n,ot(i[a]??null,r.value))}),n<t.max_change)break}this.looping.clear(),this.spread(),this.looping.clear(),this.loop=e,this.iterated={cells:s.length,iterations:o,change:n}}iterates(t){return this.loop.has(t)}circularCells(){return[...this.around]}downstream(t){const e=new Set(t),s=[...t];for(;;){const o=s.pop();if(!o)break;for(const n of this.readers(o.sheet,o.row,o.col))e.has(n)||(e.add(n),s.push(n))}return e}spread(){for(let t=0;this.moved.length>0;t++){const e=this.moved;if(this.moved=[],t>=B*2)break;if(t>=B)for(const{sheet:n,area:i}of e)for(const r of n.spillsIn(i))this.unsettled.add(r);this.build();const s=new Set,o=[...this.unsettled];for(const{sheet:n,area:i}of e)M(o,this.readersIn(n,i)),M(o,n.blockedBy(i));for(;;){const n=o.pop();if(!n)break;s.has(n)||(s.add(n),M(o,this.readers(n.sheet,n.row,n.col)))}if(s.size!==0){for(const n of s)n.state=1,this.inCycle.delete(n);this.cycles=this.cycles.filter(n=>!n.some(i=>s.has(i))),this.indexes.clear(),this.results.clear();for(const n of this.order([...s]))n.state===1&&this.computeNow(n)}}for(const t of this.wb.sheets)t.tighten()}spillOut(t,e){const{sheet:s,row:o,col:n}=t,i={top:o,left:n,bottom:o+e.rows-1,right:n+e.cols-1},r=s.spillsIn(i).filter(c=>c!==t);if(i.bottom>=C||i.right>=v||s.holds(i,t)||s.tables.some(c=>N(c.area,i))||s.merges.some(c=>N(c,i))||r.some(c=>rt(c,t)))return s.blockSpill(t,i),!1;for(const c of r)this.evict(c,i);return s.placeSpill(t,i),!0}evict(t,e){const{sheet:s,spill:o}=t;o&&(s.clearSpill(t),s.blockSpill(t,e),t.array=void 0,t.value=h.SPILL,this.moved.push({sheet:s,area:o}),this.reports&&this.settled.add(t))}analysisOf(t){return t.analysis??=q(this.wb,t)}readsOf(t){const e=[],s=F(t);for(const o of this.analysisOf(t.shared).reads){const n=o.kind==="ref"?this.resolveRef(o,s):this.structured(o,s);n instanceof d?e.push(n):n instanceof x&&e.push(...n.parts)}return e}readsAt(t,e,s,o){const n={sheet:e,row:s,col:o,dr:s-t.row,dc:o-t.col},i=[];for(const r of this.analysisOf(t).reads){const a=r.kind==="ref"?this.resolveRef(r,n):this.structured(r,n);a instanceof d?i.push(a):a instanceof x?i.push(...a.parts):i.push(void 0)}return i}readsOfFormula(t,e){const s=[],o={sheet:e,row:t.row,col:t.col,dr:0,dc:0};for(const n of this.analysisOf(t).reads){const i=n.kind==="ref"?this.resolveRef(n,o):this.structured(n,o);i instanceof d?s.push(i):i instanceof x&&s.push(...i.parts)}return s}order(t){this.pass+=1;const{pass:e}=this,s=[],o=new Set,n=[],i=r=>{r.mark=e,n.push({cell:r,reads:this.pending(r,o),next:0})};for(const r of t)if(r.mark!==e)for(i(r);;){const a=n[n.length-1];if(!a)break;const c=a.reads[a.next];a.next+=1,c===void 0?(s.push(a.cell),n.pop()):c.mark!==e&&c.state===1&&i(c)}return s}pending(t,e){const s=[];for(const o of this.readsOf(t)){const{sheet:n}=o;if(o.single){const r=n.at(o.top,o.left);r instanceof k&&s.push(r);continue}if(e.has(o.key))continue;e.add(o.key);const i=Math.min(o.right,n.columnsUsed-1);for(let r=o.left;r<=i;r++){if(!n.hasFormulas(r))continue;const[a,c]=n.span(r,o.top,o.bottom);for(let f=a;f<=c;f++){const u=n.at(f,r);u instanceof k&&s.push(u)}}}return s}computeNow(t){if(this.stack.length>0){if(this.stack.length>=st&&this.stack.length<I)throw new V(t);this.compute(t);return}const e=[t],s=new Set([t]);for(;e.length>0;){const o=e[e.length-1];if(o===void 0)break;if(o.state!==1){e.pop();continue}try{this.compute(o),e.pop()}catch(n){if(!(n instanceof V))throw n;for(const i of this.stack)i.state=1;if(this.stack.length=0,s.has(n.cell)){n.cell.value=h.CALC,n.cell.state=0;continue}s.add(n.cell),e.push(n.cell)}}}compute(t){if(this.stack.length>=I){t.value=h.CALC,t.state=0;return}t.state=2,this.stack.push(t),this.computed+=1;const{node:e}=t.shared,s=R(e)?t.value:e?this.top(this.eval(e,F(t))):h.NAME;this.stack.pop(),this.unsettled.has(t)&&!this.inCycle.has(t)&&(this.inCycle.add(t),this.cycles.push([t])),this.settleResult(t,s),t.state=0,this.reports&&this.settled.add(t)}settleResult(t,e){const{sheet:s}=t,o=t.spill,n=t.array;if(s.clearSpill(t),t.array=void 0,e instanceof m){const r=ct(e);r.rows*r.cols<=1||this.spillOut(t,r)?(t.array=r,t.value=r.at(0,0)??0):t.value=h.SPILL}else t.value=e;this.inCycle.has(t)&&(s.clearSpill(t),t.value=h.CYCLE,t.array=void 0);const i=t.spill;(!it(n,t.array)||!at(o,i))&&(o&&this.moved.push({sheet:s,area:o}),i&&this.moved.push({sheet:s,area:i}))}top(t){const e=this.flat(t);return e===null?0:e}flat(t){return t instanceof d?t.single?this.read(t.sheet,t.top,t.left):this.matrix(t):t instanceof x?h.VALUE:t instanceof S?h.CALC:t instanceof L?null:t}matrix(t){const e=t.bottom===C-1?Math.min(t.bottom,t.sheet.lastRow):t.bottom,s=t.right===v-1?Math.min(t.right,t.sheet.columnsUsed-1):t.right,o=Math.max(0,e-t.top+1),n=Math.max(0,s-t.left+1),i=new Array(o*n);for(let r=0;r<o;r++)for(let a=0;a<n;a++)i[r*n+a]=this.read(t.sheet,t.top+r,t.left+a);return new m(o,n,i)}each(t,e){const{sheet:s}=t,o=Math.min(t.right,s.columnsUsed-1);for(let n=t.left;n<=o;n++){const[i,r]=s.span(n,t.top,t.bottom);for(let a=i;a<=r;a++){const c=s.at(a,n);if(c===void 0){s.spillAt(a,n)&&e(this.read(s,a,n),a,n);continue}e(typeof c=="object"&&!(c instanceof b)?this.read(s,a,n):c,a,n)}}}evaluate(t,e){const{node:s}=t;return s?this.top(this.eval(s,{sheet:e,row:t.row,col:t.col,dr:0,dc:0})):h.NAME}evaluateAt(t,e,s,o){const{node:n}=t;return n?this.top(this.eval(n,{sheet:e,row:s,col:o,dr:s-t.row,dc:o-t.col})):h.NAME}bound(t,e,s){const o=t.abs?t.index:t.index+e;return o<0||o>=s?void 0:o}resolveRef(t,e){const s=t.sheet===void 0?e.sheet:this.wb.sheet(t.sheet);if(!s)return h.REF;let o=0,n=v-1,i=0,r=C-1;if(t.col){const a=this.bound(t.col,e.dc,v),c=this.bound(t.col2??t.col,e.dc,v);if(a===void 0||c===void 0)return h.REF;o=Math.min(a,c),n=Math.max(a,c)}if(t.row){const a=this.bound(t.row,e.dr,C),c=this.bound(t.row2??t.row,e.dr,C);if(a===void 0||c===void 0)return h.REF;i=Math.min(a,c),r=Math.max(a,c)}if(t.lastSheet!==void 0){const a=this.wb.sheet(t.lastSheet);if(!a)return h.REF;const[c,f]=[Math.min(s.index,a.index),Math.max(s.index,a.index)];return new x(this.wb.sheets.slice(c,f+1).map(u=>new d(u,i,o,r,n)))}return new d(s,i,o,r,n)}structured(t,e){const s=t.table===void 0?e.sheet.tableAt(e.row,e.col):this.wb.table(t.table);return s?lt(s,t,e):t.table===void 0?h.REF:h.NAME}nameValue(t,e,s){const o=t.toLowerCase();if(s===void 0)for(let c=e.scope;c;c=c.parent){const f=c.names.get(o);if(f!==void 0)return f}const n=s===void 0?e.sheet:this.wb.sheet(s);if(!n)return h.REF;const i=this.wb.name(t,n);if(i){if(!i.formula)return i.value??null;const{node:c}=i.formula;if(!c)return h.NAME;if(this.namesAt.has(o))return h.CYCLE;this.namesAt.add(o);try{return this.eval(c,{sheet:e.sheet,row:0,col:0,dr:0,dc:0})}finally{this.namesAt.delete(o)}}const r=this.wb.table(t);if(r){const{top:c,left:f,bottom:u,right:w}=r.data;return new d(r.sheet,c,f,u,w)}const a=_.get(t.toUpperCase());return a&&a.kind!=="lazy"?ht(a,t,e):h.NAME}intersect(t,e){return!(t instanceof d)||t.single?t:t.cols===1&&e.row>=t.top&&e.row<=t.bottom?new d(t.sheet,e.row,t.left,e.row,t.left):t.rows===1&&e.col>=t.left&&e.col<=t.right?new d(t.sheet,t.top,e.col,t.top,e.col):h.VALUE}unary(t,e){const s=this.flat(t);return s instanceof m?new m(s.rows,s.cols,s.data.map(e)):e(s)}operate(t,e,s){const o=this.flat(e),n=this.flat(s);if(o instanceof m||n instanceof m){const i=(r,a)=>O(t,r,a);return Y(o instanceof m?o:new m(1,1,[o]),n instanceof m?n:new m(1,1,[n]),i)}return O(t,o,n)}rangeOf(t,e){return t instanceof b?t:e instanceof b?e:!(t instanceof d)||!(e instanceof d)||t.sheet!==e.sheet?h.REF:new d(t.sheet,Math.min(t.top,e.top),Math.min(t.left,e.left),Math.max(t.bottom,e.bottom),Math.max(t.right,e.right))}intersection(t,e){if(t instanceof b)return t;if(e instanceof b)return e;if(!(t instanceof d)||!(e instanceof d))return h.REF;const s=Math.max(t.top,e.top),o=Math.max(t.left,e.left),n=Math.min(t.bottom,e.bottom),i=Math.min(t.right,e.right);return t.sheet!==e.sheet||s>n||o>i?h.NULL:new d(t.sheet,s,o,n,i)}union(t,e){if(t instanceof b)return t;if(e instanceof b)return e;const s=n=>n instanceof d?[n]:n instanceof x?n.parts:[],o=[...s(t),...s(e)];return o.length===0?h.VALUE:new x(o)}eval(t,e){switch(t.kind){case"number":case"string":case"boolean":return t.value;case"error":return b.of(t.code);case"missing":return T;case"ref":return this.resolveRef(t,e);case"structured":return this.structured(t,e);case"name":return this.nameValue(t.name,e,t.sheet);case"paren":return this.eval(t.arg,e);case"unary":{const s=this.eval(t.arg,e);return t.op==="@"?this.intersect(s,e):t.op==="+"?s:this.unary(s,o=>O("*",o,-1))}case"postfix":{const s=this.eval(t.arg,e);if(t.op==="%")return this.unary(s,o=>O("/",o,100));if(s instanceof d&&s.single){const o=s.sheet.at(s.top,s.left);if(o instanceof k){this.read(s.sheet,s.top,s.left);const{spill:n}=o;if(n)return new d(s.sheet,n.top,n.left,n.bottom,n.right);if(o.array)return s}}return h.REF}case"binary":{const s=this.eval(t.left,e),o=this.eval(t.right,e);return t.op===":"?this.rangeOf(s,o):t.op===" "?this.intersection(s,o):t.op===","?this.union(s,o):this.operate(t.op,s,o)}case"array":return new m(t.rows.length,t.rows[0]?.length??0,t.rows.flatMap(s=>s.map(o=>{const n=this.eval(o,e);return n instanceof m||n instanceof d||n instanceof x||n instanceof S||n instanceof L?h.VALUE:n})));case"invoke":{const s=this.eval(t.callee,e);return s instanceof S?this.invoke(s,t.args,e):s instanceof b?s:h.VALUE}case"call":return this.call(t.name,t.args,e)}}invoke(t,e,s){return this.apply(t,e.map(o=>this.eval(o,s)))}apply(t,e){if(t.named!==void 0){const n=_.get(t.named);return!n||n.kind==="lazy"?h.NAME:e.length<n.min||e.length>n.max?h.VALUE:this.applyFunction(n,e,t.frame)}if(e.length>t.params.length)return h.VALUE;const s=t.params.length+1;if(this.lambdaSlots+s>nt)return h.NUM;const o=new Map;t.params.forEach((n,i)=>{o.set(n,e[i]??T)}),this.lambdaSlots+=s;try{return this.eval(t.body,{...t.frame,scope:{names:o,...t.frame.scope?{parent:t.frame.scope}:{}}})}finally{this.lambdaSlots-=s}}call(t,e,s){const o=_.get(t);if(!o){const n=this.nameValue(t,s);return n instanceof S?this.invoke(n,e,s):h.NAME}return e.length<o.min||e.length>o.max?h.VALUE:o.kind==="lazy"?o.call(e,{calc:this,frame:s}):this.applyFunction(o,e.map(n=>this.eval(n,s)),s)}applyFunction(t,e,s){const o={calc:this,frame:s};if(t.kind==="lazy")return h.VALUE;if(t.kind==="raw")return J(t.params,e.length)?this.over(e,i=>Q(t.params,i)==="value",i=>t.call(i,o)):h.VALUE;const n=t.errors===!0;return this.over(e,()=>!0,i=>{const r=i.map(a=>a instanceof L?void 0:a);if(!n){for(const a of r)if(a instanceof b)return a}return t.call(...r)})}over(t,e,s){const o=[],n=new Map;for(const[f,u]of t.entries()){if(!e(f)||u instanceof L){o.push(u);continue}const w=this.flat(u);w instanceof m&&n.set(f,w),o.push(w)}if(n.size===0)return s(o);const i=[...n.values()],r=Math.max(...i.map(f=>f.rows)),a=Math.max(...i.map(f=>f.cols));if(r===0||a===0)return h.CALC;const c=new Array(r*a);for(let f=0;f<r;f++)for(let u=0;u<a;u++){const w=o.map((E,A)=>{const y=n.get(A);if(!y)return E;const p=y.rows===1?0:f,g=y.cols===1?0:u;return p<y.rows&&g<y.cols?y.at(p,g):h.NA});c[f*a+u]=this.element(s(w))}return new m(r,a,c)}element(t){const e=this.flat(t);return e instanceof m?e.rows>0&&e.cols>0?e.at(0,0):h.CALC:e}scalar(t,e){if(t instanceof L)return null;if(t instanceof d){const s=this.intersect(t,e);return s instanceof d?this.read(s.sheet,s.top,s.left):h.VALUE}return t instanceof m?t.at(0,0):t instanceof x||t instanceof S?h.VALUE:t}recalculate(){if(this.replica)return this;const t=this.allCells().filter(e=>this.analysisOf(e.shared).volatile);return this.mark(t),this}build(){if(this.graphMade)return;this.graphMade=!0;const t=this.allCells();for(const e of t)this.analysisOf(e.shared).volatile&&this.volatiles.add(e);this.graph.build(t)}addEdges(t){this.analysisOf(t.shared).volatile&&this.volatiles.add(t),this.graph.add(t)}removeEdges(t){this.volatiles.delete(t),this.graph.remove(t)}readersIn(t,e){return this.graph.readersIn(t,e)}readers(t,e,s){return this.build(),this.graph.readers(t,e,s)}precedents(t){return this.readsOf(t)}mark(t){this.build();const e=new Set(t),s=[...t];for(;;){const o=s.pop();if(!o)break;for(const n of this.readers(o.sheet,o.row,o.col))e.has(n)||(e.add(n),s.push(n))}this.settle(e)}settle(t){for(const e of t)e.state=1,this.inCycle.delete(e);this.cycles=this.cycles.filter(e=>!e.some(s=>t.has(s))),this.run([...t])}set(t,e,s,o){const n=typeof o=="string"&&o.length>1&&o.startsWith("=")?new k(new P(o,e,s,{file:""}),t,e,s):void 0;this.change([{sheet:t,row:e,col:s,slot:n??o??void 0}])}prepare(){this.build()}change(t){if(this.replica){for(const{sheet:n,row:i,col:r,slot:a}of t){const c=n.at(i,r);c instanceof k&&n.clearSpill(c),n.replace(i,r,a),a instanceof k&&(a.state=0)}return}this.build();const e=new Set,s=[...this.unsettled];this.unsettled.clear();const o=new Set;for(const{sheet:n,row:i,col:r,slot:a}of t){const c=n.at(i,r);(c instanceof k&&R(c.shared.node)||a instanceof k&&R(a.shared.node))&&(this.tablesOf=void 0),c instanceof k&&(o.add(c),this.inCycle.delete(c),this.removeEdges(c),e.delete(c),c.spill&&this.moved.push({sheet:n,area:c.spill}),n.clearSpill(c));const f=n.spillAt(i,r);f&&s.push(f),s.push(...n.blockedBy({top:i,left:r,bottom:i,right:r})),n.replace(i,r,a),this.forget(n,{top:i,left:r,bottom:i,right:r}),a instanceof k&&(this.addEdges(a),e.add(a))}o.size>0&&(this.cycles=this.cycles.filter(n=>!n.some(i=>o.has(i))));for(const{sheet:n,row:i,col:r}of t)M(s,this.readers(n,i,r));for(M(s,this.volatiles);;){const n=s.pop();if(!n)break;e.has(n)||(e.add(n),M(s,this.readers(n.sheet,n.row,n.col)))}this.settle(e)}setName(t,e){const s=this.wb.name(t);if(!s)throw new Error(`There is no name ${t}.`);s.value=e,delete s.formula;const o=t.toLowerCase();this.mark(this.allCells().filter(n=>this.analysisOf(n.shared).names.has(o)))}takeComputed(){const t=[];for(const e of this.settled)t.push({sheet:e.sheet.index,row:e.row,col:e.col,value:X(e.value),...e.array?{array:K(e.array)}:{},...e.spill?{spill:e.spill}:{},...e.blocked?{blocked:e.blocked}:{}});return this.settled.clear(),{cells:t,cycles:this.cycles.map(e=>e.map(s=>({sheet:s.sheet.index,row:s.row,col:s.col}))),hidden:[...this.hiddenBy].map(([e,s])=>({sheet:e.index,rows:[...s]}))}}receive(t){for(const s of t.cells){const o=this.wb.sheets[s.sheet],n=o?.at(s.row,s.col);!o||!(n instanceof k)||(o.clearSpill(n),n.value=$(s.value),n.array=s.array?j(s.array):void 0,s.spill&&o.placeSpill(n,s.spill),s.blocked&&o.blockSpill(n,s.blocked),n.state=0)}this.cycles=t.cycles.flatMap(s=>{const o=s.flatMap(n=>{const i=this.wb.sheets[n.sheet]?.at(n.row,n.col);return i instanceof k?[i]:[]});return o.length>0?[o]:[]});const e=new Map(this.hiddenBy);this.hiddenBy.clear();for(const{sheet:s,rows:o}of t.hidden){const n=this.wb.sheets[s];if(!n)continue;const i=e.get(n),r=i?.size===o.length&&o.every(a=>i.has(a));this.hiddenBy.set(n,r?i:new Set(o))}for(const s of this.wb.sheets)s.tighten()}numberOf(t){return Z(t)}}const at=(l,t)=>l?.top===t?.top&&l?.left===t?.left&&l?.bottom===t?.bottom&&l?.right===t?.right;function ct(l){return l.data.some(t=>t===null)?new m(l.rows,l.cols,l.data.map(t=>t??0)):l}function R(l){return l?.kind==="call"&&l.name==="TABLE"}function F(l){return{sheet:l.sheet,row:l.row,col:l.col,dr:l.row-l.shared.row,dc:l.col-l.shared.col}}function lt(l,t,e){const{sheet:s}=l,o=l.area;let n=o.left,i=o.right;const[r,a]=t.columns;if(r!==void 0){const A=l.column(r),y=a===void 0?A:l.column(a);if(!A||!y)return h.REF;n=o.left+Math.min(A.index,y.index),i=o.left+Math.max(A.index,y.index)}if(t.thisRow)return e.sheet!==s||e.row<=o.top||e.row>o.bottom?h.VALUE:new d(s,e.row,n,e.row,i);const c=t.sections;if(c.includes("#Totals"))return h.REF;const f=c.includes("#All")||c.includes("#Headers"),u=c.length===0||c.includes("#All")||c.includes("#Data"),w=f?o.top:o.top+1,E=u?o.bottom:o.top;return new d(s,w,n,E,i)}function ht(l,t,e){return new S([],{kind:"call",name:l.name,written:t,args:[]},e,l.name)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{CellError as l,ERR as
|
|
2
|
+
import{CellError as l,ERR as g}from"../../values.js";import{compare as O,numberOfText as A,sameNumber as b}from"../coerce.js";import{Missing as C,Reference as T}from"../types.js";import{indexKeyOf as w}from"../indexes.js";import{cellsOf as h,raw as p}from"./define.js";export function indexKey(e){if(typeof e=="number")return`n${String(Number(e.toPrecision(15)))}`;if(typeof e=="string")return`t${e.toUpperCase()}`;if(typeof e=="boolean")return e?"bT":"bF"}const y=new Map,k=1e4;export function wildcard(e){const n=y.get(e);if(n)return n;y.size>=k&&y.clear();const t=V(e);return y.set(e,t),t}function V(e){let n="";for(let r=0;r<e.length;r++){const o=e.charAt(r);o==="~"&&/[*?~]/u.test(e.charAt(r+1))?(r+=1,n+=e.charAt(r).replace(/[*?]/u,"\\$&")):o==="*"?n+="[\\s\\S]*":o==="?"?n+="[\\s\\S]":n+=o.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}const t=new RegExp(`^${n}$`,"iu");return r=>t.test(r)}export const hasWildcard=e=>/[*?~]/u.test(e);export function literalOf(e){let n="";for(let t=0;t<e.length;t++){const r=e.charAt(t);if(r==="~"&&/[*?~]/u.test(e.charAt(t+1)))t+=1,n+=e.charAt(t);else{if(r==="*"||r==="?")return;n+=r}}return n}function I(e){return n=>{if(typeof n=="number")return b(n,e);if(typeof n!="string")return!1;const t=A(n);return t!==void 0&&b(t,e)}}function G(e,n){const t=r=>e===">"?r>0:e===">="?r>=0:e==="<"?r<0:r<=0;return r=>typeof r==typeof n&&t(O(r,n))}export function criterion(e){if(e===null)return{test:I(0),key:"n0"};if(typeof e=="number")return{test:I(e),key:`n${String(Number(e.toPrecision(15)))}`};if(typeof e=="boolean")return{test:s=>s===e,key:e?"bT":"bF"};if(e instanceof l)return{test:s=>s===e};const n=/^(<>|>=|<=|=|>|<)/u.exec(e),t=n?.[1]??"=",r=n?e.slice(t.length):e,o=s=>s===null;if(r==="")return t==="="?{test:n?o:s=>s===null||s===""}:t==="<>"?{test:s=>s!==null}:{test:()=>!1};const i=A(r),c=/^(?:TRUE|FALSE)$/iu.test(r)?r.toUpperCase()==="TRUE":void 0,f=i??c;if(t==="="||t==="<>"){let s,u;if(i!==void 0)s=I(i),u=indexKey(i);else if(c!==void 0)s=d=>d===c,u=indexKey(c);else if(r.startsWith("#"))s=d=>d instanceof l&&d.code===r.toUpperCase();else if(hasWildcard(r)){const d=wildcard(r);s=m=>typeof m=="string"&&d(m)}else{const d=r.toUpperCase();s=m=>typeof m=="string"&&m.toUpperCase()===d,u=indexKey(r)}return t==="="?u===void 0?{test:s}:{test:s,key:u}:{test:d=>!s(d)}}return{test:G(t,f??r)}}function P(e,n){const t=e.reference;if(!(t?.cols!==1||e.rows<64))return n.calc.indexes.ofRepeated(w("crit",t),[t],()=>{const r=new Map,o=(i,c)=>{if(i===void 0)return;const f=r.get(i);f?f.push(c):r.set(i,[c])};for(let i=0;i<e.rows;i++){const c=e.at(i,0);if(o(indexKey(c),i),typeof c=="string"){const f=A(c);f!==void 0&&o(indexKey(f),i)}}return r})}function E(e,n){const t=n.calc.scalar(e,n.frame);return criterion(t)}function x(e,n){const t=[];for(let o=0;o+1<e.length;o+=2){const i=h(e[o],n);if(i instanceof l)return i;const c=E(e[o+1],n);if(c instanceof l)return c;t.push({cells:i,crit:c})}const r=t[0]?.cells;return r&&t.some(o=>!M(o.cells,r))?g.VALUE:t}const M=(e,n)=>e.cols===n.cols&&(e.reference?.rows??e.rows)===(n.reference?.rows??n.rows);function F(e,n,t){const r=e[0];if(!r)return;let o,i;for(const f of e){if(f.crit.key===void 0)continue;const s=P(f.cells,n);if(!s)continue;const u=s.get(f.crit.key)??[];(o===void 0||u.length<o.length)&&(o=u,i=f)}if(o!==void 0){const f=e.filter(s=>s!==i);for(const s of o)f.every(u=>u.crit.test(u.cells.at(s,0)))&&t(s,0);return}const c=Math.max(...e.map(f=>f.cells.rows));for(let f=0;f<c;f++)for(let s=0;s<r.cells.cols;s++)e.every(u=>u.crit.test(u.cells.at(f,s)))&&t(f,s)}function j(e,n){return e instanceof T?(e.rows-n.rows)*e.cols:0}function R(e,n,t,r){let o;return F(n,t,(i,c)=>{if(o)return;const f=e.at(i,c);f instanceof l?o=f:typeof f=="number"&&r(f)}),o}function v(e,n){const t=h(e[0],n);if(t instanceof l)return t;const r=e[2];return r===void 0?t:h(r,n)}const $=e=>(n,t)=>{const r=h(n[0],t);if(r instanceof l)return r;const o=E(n[1],t);if(o instanceof l)return o;const i=v(n,t);if(i instanceof l)return i;const c=[];return R(i,[{cells:r,crit:o}],t,s=>{c.push(s)})??e(c)},S=e=>(n,t)=>{const r=h(n[0],t);if(r instanceof l)return r;const o=x(n.slice(1),t);if(o instanceof l)return o;const i=o[0]?.cells;if(i&&!M(r,i))return g.VALUE;const c=[];return R(r,o,t,s=>{c.push(s)})??e(c)},a=(e,n)=>(t,r)=>{const o=[],i=[e];for(const u of t)if(u instanceof T)o.push(u),i.push(`r${u.key}`);else if(u instanceof C)i.push("-");else if(u instanceof l)i.push(`e${u.code}`);else if(u===null||typeof u!="object")i.push(`${typeof u}:${String(u)}`);else return n(t,r);if(o.length===0)return n(t,r);const c=i.join("\0"),f=r.calc.results.get(c);if(f!==void 0)return f;const s=n(t,r);return(s===null||typeof s!="object"||s instanceof l)&&r.calc.results.set(c,o,s),s},U=e=>e.reduce((n,t)=>n+t,0),N=e=>e.length===0?g.DIV0:U(e)/e.length,L=e=>e.length===0?0:e.reduce((n,t)=>t<n?t:n),z=e=>e.length===0?0:e.reduce((n,t)=>t>n?t:n);p("SUMIF","rv?r",a("SUMIF",$(U))),p("AVERAGEIF","rv?r",a("AVERAGEIF",$(N))),p("SUMIFS","r(rv)",a("SUMIFS",S(U))),p("AVERAGEIFS","r(rv)",a("AVERAGEIFS",S(N))),p("MINIFS","r(rv)",a("MINIFS",S(L))),p("MAXIFS","r(rv)",a("MAXIFS",S(z))),p("COUNTIF","rv",a("COUNTIF",(e,n)=>{const t=h(e[0],n);if(t instanceof l)return t;const r=E(e[1],n);if(r instanceof l)return r;let o=0;return F([{cells:t,crit:r}],n,()=>{o+=1}),o+(r.test(null)?j(e[0],t):0)})),p("COUNTIFS","(rv)",a("COUNTIFS",(e,n)=>{const t=x(e,n);if(t instanceof l)return t;let r=0;return F(t,n,()=>{r+=1}),r}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{parseDate as B,parseTime as H,parseValue as
|
|
2
|
+
import{parseDate as B,parseTime as H,parseValue as L}from"numfmt";import{CellError as c,ERR as u,dateOf as h,serialOf as p}from"../../values.js";import{toBool as X,toNumber as m,toText as T}from"../coerce.js";import{Missing as v}from"../types.js";import{eachRow as g,number as S,numbersOf as j,raw as U,scalar as l}from"./define.js";const P=2958465,y=e=>{const n=m(e);return n instanceof c?n:n<0||n>=P+1?u.NUM:Math.floor(n)},Y=e=>e%4===0&&e%100!==0||e%400===0,A=(e,n)=>n===2?Y(e)?29:28:[4,6,9,11].includes(n)?30:31,I=e=>e.month===2&&e.day===A(e.year,2);l("DATE",3,3,S((e=0,n=1,r=1)=>{const t=Math.trunc(e);if(t<0||t>9999)return u.NUM;const o=p(t<1900?t+1900:t,Math.trunc(n),Math.trunc(r));return o<0?u.NUM:o})),l("TIME",3,3,S((e=0,n=0,r=0)=>{const t=Math.trunc(e)*3600+Math.trunc(n)*60+Math.trunc(r);return t<0?u.NUM:t%86400/86400})),l("YEAR",1,1,e=>{const n=y(e);return n instanceof c?n:h(n).year}),l("MONTH",1,1,e=>{const n=y(e);return n instanceof c?n:h(n).month}),l("DAY",1,1,e=>{const n=y(e);return n instanceof c?n:h(n).day});const b=e=>{const n=m(e);return n instanceof c?n:n<0?u.NUM:Math.round((n-Math.floor(n))*86400)%86400};l("HOUR",1,1,e=>{const n=b(e);return n instanceof c?n:Math.floor(n/3600)}),l("MINUTE",1,1,e=>{const n=b(e);return n instanceof c?n:Math.floor(n/60)%60}),l("SECOND",1,1,e=>{const n=b(e);return n instanceof c?n:n%60}),l("DATEVALUE",1,1,e=>{const n=T(e);if(n instanceof c)return n;const r=B(n)??L(n);return typeof r?.value=="number"?Math.floor(r.value):u.VALUE}),l("TIMEVALUE",1,1,e=>{const n=T(e);if(n instanceof c)return n;const r=H(n)??L(n);return typeof r?.value!="number"?u.VALUE:r.value-Math.floor(r.value)});const D=e=>(e%7+6)%7;l("WEEKDAY",1,2,(e,n)=>{const r=y(e);if(r instanceof c)return r;const t=n==null?1:m(n);if(t instanceof c)return t;const o=D(r);return t===1?o+1:t===2?(o+6)%7+1:t===3?(o+6)%7:t>=11&&t<=17?(o+7-(t-10)%7)%7+1:u.NUM});const V=e=>{const n=(D(e)+6)%7,r=e-n+3,{year:t}=h(r);return Math.floor((r-p(t,1,1))/7)+1};l("ISOWEEKNUM",1,1,e=>{const n=y(e);return n instanceof c?n:V(n)}),l("WEEKNUM",1,2,(e,n)=>{const r=y(e);if(r instanceof c)return r;const t=n==null?1:m(n);if(t instanceof c)return t;if(t===21)return V(r);const o=t===1?0:t===2?1:t>=11&&t<=17?(t-10)%7:-1;if(o<0)return u.NUM;const a=p(h(r).year,1,1),s=(D(a)+7-o)%7;return Math.floor((r-a+s)/7)+1});const R=(e,n)=>{const{year:r,month:t,day:o}=h(e),a=r*12+t-1+n,s=Math.floor(a/12),f=a-s*12+1;return p(s,f,Math.min(o,A(s,f)))};l("EDATE",2,2,(e,n)=>{const r=y(e),t=m(n);if(r instanceof c)return r;if(t instanceof c)return t;const o=R(r,Math.trunc(t));return o<0?u.NUM:o}),l("EOMONTH",2,2,(e,n)=>{const r=y(e),t=m(n);if(r instanceof c)return r;if(t instanceof c)return t;const o=h(R(r,Math.trunc(t))),a=p(o.year,o.month,A(o.year,o.month));return a<0?u.NUM:a}),l("DAYS",2,2,(e,n)=>{const r=y(e),t=y(n);return r instanceof c?r:t instanceof c?t:r-t}),l("DATEDIF",3,3,(e,n,r)=>{const t=y(e),o=y(n),a=T(r);if(t instanceof c)return t;if(o instanceof c)return o;if(a instanceof c)return a;if(t>o)return u.NUM;const s=h(t),f=h(o),i=(f.year-s.year)*12+f.month-s.month-(f.day<s.day?1:0);switch(a.toUpperCase()){case"D":return o-t;case"M":return i;case"Y":return Math.floor(i/12);case"YM":return i%12;case"MD":{if(f.day>=s.day)return f.day-s.day;const d=f.month===1?12:f.month-1,N=f.month===1?f.year-1:f.year;return A(N,d)-s.day+f.day}case"YD":{const d=f.year-s.year-(i%12<0?1:0),N=Math.floor(i/12),M=R(t,N*12);return d>=0?o-M:u.NUM}default:return u.NUM}});function W(e,n,r){const t=h(e),o=h(n);let a=t.day,s=o.day,f=o.month,i=o.year;return r?(a=Math.min(a,30),s=Math.min(s,30)):(a===A(t.year,t.month)&&(a=30),s===31&&(a<30?(s=1,f+=1,f>12&&(f=1,i+=1)):s=30)),(i-t.year)*360+(f-t.month)*30+s-a}l("DAYS360",2,3,(e,n,r)=>{const t=y(e),o=y(n),a=r===void 0?!1:X(r);return t instanceof c?t:o instanceof c?o:a instanceof c?a:W(t,o,a)});export function yearFrac(e,n,r){const[t,o]=e<=n?[e,n]:[n,e],a=h(t),s=h(o),f=o-t;switch(r){case 0:{let i=a.day,d=s.day;return I(a)&&(I(s)&&(d=30),i=30),d===31&&i>=30&&(d=30),i===31&&(i=30),((s.year-a.year)*360+(s.month-a.month)*30+d-i)/360}case 2:return f/360;case 3:return f/365;case 4:return W(t,o,!0)/360;default:{if(a.year===s.year||s.year===a.year+1&&(a.month>s.month||a.month===s.month&&a.day>=s.day)){let M;if(a.year===s.year)M=Y(a.year);else{const E=w=>Y(w)?p(w,2,29):1/0;M=E(a.year)>=t&&E(a.year)<=o||E(s.year)>=t&&E(s.year)<=o}return f/(M?366:365)}const d=s.year-a.year+1,N=p(s.year+1,1,1)-p(a.year,1,1);return f/(N/d)}}}l("YEARFRAC",2,3,(e,n,r)=>{const t=y(e),o=y(n),a=r==null?0:m(r);if(t instanceof c)return t;if(o instanceof c)return o;if(a instanceof c)return a;const s=Math.trunc(a);return s<0||s>4?u.NUM:yearFrac(t,o,s)});function _(e){const n=(...t)=>[0,1,2,3,4,5,6].map(o=>t.includes(o));if(e==null)return n(0,6);if(typeof e=="string"){if(!/^[01]{7}$/u.test(e)||e==="1111111")return u.VALUE;const t=e.split("").map(o=>o==="1");return[t[6]??!1,...t.slice(0,6)]}const r=m(e);return r instanceof c?r:r>=1&&r<=7?n((r+5)%7,(r+6)%7):r>=11&&r<=17?n(r-11):u.NUM}function k(e,n){if(e===void 0||e instanceof v)return new Set;const r=j([e],n);return r instanceof c?r:new Set(r.map(t=>Math.floor(t)))}function $(e,n,r,t){const o=e<=n?1:-1;let a=0;for(let s=e;o>0?s<=n:s>=n;s+=o)r[D(s)]!==!0&&!t.has(s)&&(a+=o);return a}function q(e,n,r,t){if(r.every(Boolean))return u.VALUE;const o=n<0?-1:1;let a=e;for(let s=Math.abs(n);s>0;)a+=o,r[D(a)]!==!0&&!t.has(a)&&(s-=1);return a<0?u.NUM:a}const K=e=>(n,r)=>{const t=y(r.calc.scalar(n[0],r.frame)),o=y(r.calc.scalar(n[1],r.frame));if(t instanceof c)return t;if(o instanceof c)return o;const a=e?n[2]:void 0,s=_(a===void 0||a instanceof v?void 0:r.calc.scalar(a,r.frame));if(s instanceof c)return s;const f=k(n[e?3:2],r);return f instanceof c?f:$(t,o,s,f)},x=e=>(n,r)=>{const t=y(r.calc.scalar(n[0],r.frame)),o=m(r.calc.scalar(n[1],r.frame));if(t instanceof c)return t;if(o instanceof c)return o;const a=e?n[2]:void 0,s=_(a===void 0||a instanceof v?void 0:r.calc.scalar(a,r.frame));if(s instanceof c)return s;const f=k(n[e?3:2],r);return f instanceof c?f:q(t,Math.trunc(o),s,f)};U("NETWORKDAYS","vv?r",K(!1)),U("NETWORKDAYS.INTL","vv?vr",K(!0)),U("WORKDAY","vv?r",x(!1)),U("WORKDAY.INTL","vv?vr",x(!0)),U("NOW","",(e,n)=>n.calc.nowSerial(),{volatile:!0}),U("TODAY","",(e,n)=>Math.floor(n.calc.nowSerial()),{volatile:!0});function z(e,n,r){const t=r[0]??0;let o=0;return n.forEach((a,s)=>{o+=a/(1+e)**(((r[s]??t)-t)/365)}),o}const F=(e,n)=>{const r=[];return g([e],n,t=>r.push(t)),r},C=(e,n)=>{const r=F(e[0],n),t=F(e[1],n);if(r.length!==t.length)return u.NUM;const o=[],a=[];for(const[s,f]of r.entries()){const i=t[s]??null;if(f instanceof c)return f;if(i instanceof c)return i;if(typeof f=="number"){if(typeof i!="number")return u.VALUE;o.push(f),a.push(Math.floor(i))}}return o.length===0?u.NUM:{values:o,dates:a}};U("XNPV","vrr",(e,n)=>{const r=m(n.calc.scalar(e[0],n.frame));if(r instanceof c)return r;const t=C(e.slice(1),n);return t instanceof c?t:r<=0?u.NUM:z(r,t.values,t.dates)}),U("XIRR","rr?v",(e,n)=>{const r=C(e,n);if(r instanceof c)return r;const{values:t,dates:o}=r;if(!t.some(i=>i>0)||!t.some(i=>i<0))return u.NUM;const a=e[2]===void 0||e[2]instanceof v?.1:m(n.calc.scalar(e[2],n.frame));if(a instanceof c)return a;const s=o[0]??0;let f=a;for(let i=0;i<100;i++){let d=0,N=0;t.forEach((E,w)=>{const O=((o[w]??s)-s)/365;d+=E/(1+f)**O,N-=O*E/(1+f)**(O+1)});const M=f-d/N;if(!Number.isFinite(M))return u.NUM;if(Math.abs(M-f)<1e-10)return M;f=M<=-1?(f-1)/2:M}return u.NUM});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{CellError as
|
|
2
|
+
import{CellError as a,ERR as l,Matrix as i}from"../../values.js";import{toBool as w,toNumber as c,toText as A}from"../coerce.js";import{Lambda as h,Missing as p,Reference as g,Union as x}from"../types.js";export const FUNCTIONS=new Map;const d=255;export const many=d;export function signature(e){const r=/^([vr?]*)(?:\(([vr]+)\))?$/u.exec(e),t=r?.[1];if(t===void 0||(t.match(/\?/gu)??[]).length>1)throw new Error(`"${e}" is not a signature.`);const o=m=>Array.from({length:m.length},(y,b)=>m.charAt(b)==="v"?"value":"whole"),n=o(t.replace("?","")),f=o(r?.[2]??""),s=t.indexOf("?"),u=s>=0?s:n.length+f.length;return{fixed:n,group:f,min:u,max:f.length>0?d:n.length}}export function paramAt(e,r){return r<e.fixed.length?e.fixed[r]??"whole":e.group.length===0?"whole":e.group[(r-e.fixed.length)%e.group.length]??"whole"}export function fillsGroup(e,r){return e.group.length===0||r<=e.fixed.length?!0:(r-e.fixed.length)%e.group.length===0}export function scalar(e,r,t,o,n={}){FUNCTIONS.set(e,{name:e,min:r,max:t,kind:"scalar",call:o,from:n.from??"allyhub",...n.errors===!0?{errors:!0}:{},...n.volatile===!0?{volatile:!0}:{}})}export function raw(e,r,t,o={}){const{min:n,max:f,fixed:s,group:u}=signature(r);FUNCTIONS.set(e,{name:e,min:n,max:f,kind:"raw",params:{fixed:s,group:u},call:t,from:o.from??"allyhub",...o.volatile===!0?{volatile:!0}:{}})}export function lazy(e,r,t,o){FUNCTIONS.set(e,{name:e,min:r,max:t,kind:"lazy",call:o,from:"allyhub"})}export function alias(e,r){const t=FUNCTIONS.get(r);t&&FUNCTIONS.set(e,{...t,name:e})}export function cellsOf(e,r){if(e instanceof a)return e;if(e instanceof x)return l.VALUE;if(e instanceof g){const o=Math.min(e.bottom,e.sheet.lastRow);return{rows:Math.max(0,o-e.top+1),cols:e.cols,at:(n,f)=>r.calc.read(e.sheet,e.top+n,e.left+f),reference:e}}if(e instanceof i)return{rows:e.rows,cols:e.cols,at:(o,n)=>e.at(o,n),array:e};if(e instanceof h)return l.VALUE;const t=e instanceof p?null:e;return{rows:1,cols:1,at:()=>t}}export function eachArg(e,r,t){for(const o of e)if(o instanceof g)r.calc.each(o,n=>{t(n,!1)});else if(o instanceof x)for(const n of o.parts)r.calc.each(n,f=>{t(f,!1)});else if(o instanceof i)for(const n of o.data)n!==null&&t(n,!1);else o instanceof p?t(null,!0):o instanceof h?t(l.VALUE,!0):t(o,!0)}export function eachRow(e,r,t){const o=n=>{for(const f of r.calc.matrix(n).data)t(f,!1)};for(const n of e)if(n instanceof g)o(n);else if(n instanceof x)n.parts.forEach(o);else if(n instanceof i)for(const f of n.data)t(f,!1);else n instanceof p?t(null,!0):n instanceof h?t(l.VALUE,!0):t(n,!0)}export function numbersOf(e,r){const t=[];let o;return eachArg(e,r,(n,f)=>{if(!o){if(n instanceof a)o=n;else if(typeof n=="number")t.push(n);else if(f){const s=c(n);s instanceof a?o=s:t.push(s)}}}),o??t}export function numbersOfA(e,r){const t=[];let o;return eachArg(e,r,(n,f)=>{if(!o)if(n instanceof a)o=n;else if(typeof n=="number")t.push(n);else if(typeof n=="boolean")t.push(n?1:0);else if(f){const s=c(n);s instanceof a?o=s:t.push(s)}else typeof n=="string"&&t.push(0)}),o??t}export const number=e=>(...r)=>{const t=[];for(const o of r){const n=c(o);if(n instanceof a)return n;t.push(n)}return e(...t)};export function textArg(e){return A(e)}export function boolArg(e,r){return e==null?r:w(e)}export function numberArg(e,r){return e===void 0?r:c(e)}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{cellName as N}from"../../address.js";import{CellError as s,ERR as n,Matrix as R}from"../../values.js";import{FormulaCell as
|
|
2
|
+
import{cellName as N}from"../../address.js";import{CellError as s,ERR as n,Matrix as R}from"../../values.js";import{FormulaCell as E}from"../../workbook.js";import{toNumber as L,toText as d}from"../coerce.js";import{Lambda as I,Reference as l,Union as y}from"../types.js";import{lazy as m,raw as i,scalar as c}from"./define.js";const f=(e,r)=>{c(e,1,1,t=>r(t),{errors:!0})};f("ISBLANK",e=>e==null),f("ISNUMBER",e=>typeof e=="number"),f("ISTEXT",e=>typeof e=="string"),f("ISNONTEXT",e=>typeof e!="string"),f("ISLOGICAL",e=>typeof e=="boolean"),f("ISERROR",e=>e instanceof s),f("ISERR",e=>e instanceof s&&e!==n.NA),f("ISNA",e=>e===n.NA);const p=(e,r)=>{const t=L(e);return t instanceof s?t:Math.abs(Math.trunc(t))%2===r};c("ISEVEN",1,1,e=>p(e,0)),c("ISODD",1,1,e=>p(e,1)),c("N",1,1,e=>typeof e=="number"?e:typeof e=="boolean"?e?1:0:e instanceof s?e:0,{errors:!0}),i("NA","",()=>n.NA),i("TYPE","r",(e,r)=>{const t=r.calc.flat(e[0]);return t instanceof R?64:typeof t=="number"||t===null?1:typeof t=="string"?2:typeof t=="boolean"?4:16});const S=[n.NULL,n.DIV0,n.VALUE,n.REF,n.NAME,n.NUM,n.NA];c("ERROR.TYPE",1,1,e=>{const r=e instanceof s?S.indexOf(e):-1;return r<0?n.NA:r+1},{errors:!0}),m("ISREF",1,1,(e,r)=>{const t=e[0];if(!t)return!1;const o=r.calc.eval(t,r.frame);return o instanceof l||o instanceof y});const A=e=>e instanceof l?e.sheet.at(e.top,e.left):void 0;m("ISFORMULA",1,1,(e,r)=>{const t=e[0];if(!t)return n.VALUE;const o=r.calc.eval(t,r.frame);return o instanceof I?n.VALUE:A(o)instanceof E}),m("FORMULATEXT",1,1,(e,r)=>{const t=e[0];if(!t)return n.VALUE;const o=A(r.calc.eval(t,r.frame));return o instanceof E?o.text:n.NA}),i("CELL","v?r",(e,r)=>{const t=d(r.calc.scalar(e[0],r.frame));if(t instanceof s)return t;const o=e[1],a=o instanceof l?o:new l(r.frame.sheet,r.frame.row,r.frame.col,r.frame.row,r.frame.col),u=r.calc.read(a.sheet,a.top,a.left);switch(t.toLowerCase()){case"row":return a.top+1;case"col":return a.left+1;case"address":return N({row:a.top,col:a.left}).replace(/^([A-Z]+)(\d+)$/u,"$$$1$$$2");case"contents":return u;case"type":return u===null?"b":typeof u=="string"?"l":"v";default:return n.VALUE}}),i("TABLE","?rrrrr",()=>n.NA);
|