@allyhub/sdk 0.8.0 → 0.9.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 +11 -0
- package/NOTICE +46 -49
- package/dist/dom.d.ts +1 -209
- package/dist/dom.js +1 -1
- package/dist/image.d.ts +2 -0
- package/dist/image.js +2 -0
- package/dist/index.d.ts +1 -21
- package/dist/index.js +1 -1
- package/dist/media.d.ts +1 -5
- package/dist/media.js +1 -1
- package/dist/node_modules/@allyhub/audio/dist/levels.d.ts +4 -5
- package/dist/node_modules/@allyhub/audio/dist/levels.js +1 -1
- package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.d.ts +1 -6
- package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.js +1 -1
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.d.ts +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/diagnostics/LICENSE +241 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/fact.d.ts +37 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/fact.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/index.d.ts +4 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +43 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/problem.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/rules.d.ts +30 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/rules.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/package.json +14 -0
- package/dist/node_modules/@allyhub/formats/dist/contributed.d.ts +126 -0
- package/dist/node_modules/@allyhub/formats/dist/contributed.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/reference.d.ts +7 -12
- package/dist/node_modules/@allyhub/formats/dist/data/reference.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/script.d.ts +9 -4
- package/dist/node_modules/@allyhub/formats/dist/data/script.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +20 -82
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +96 -8
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/website.d.ts +2 -1
- package/dist/node_modules/@allyhub/formats/dist/data/website.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/work.d.ts +42 -0
- package/dist/node_modules/@allyhub/formats/dist/data/work.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/extension.d.ts +91 -0
- package/dist/node_modules/@allyhub/formats/dist/extension.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/files.d.ts +51 -0
- package/dist/node_modules/@allyhub/formats/dist/files.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/index.d.ts +5 -1
- package/dist/node_modules/@allyhub/formats/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/items.d.ts +226 -90
- package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +7 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +46 -42
- package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/LICENSE +241 -0
- package/dist/node_modules/@allyhub/image-draw/dist/context.d.ts +5 -0
- package/dist/node_modules/@allyhub/image-draw/dist/context.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/contrast.d.ts +13 -0
- package/dist/node_modules/@allyhub/image-draw/dist/contrast.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/env.d.ts +112 -0
- package/dist/node_modules/@allyhub/image-draw/dist/env.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/errors.d.ts +20 -0
- package/dist/node_modules/@allyhub/image-draw/dist/errors.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/fonts.d.ts +110 -0
- package/dist/node_modules/@allyhub/image-draw/dist/fonts.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/guards.d.ts +32 -0
- package/dist/node_modules/@allyhub/image-draw/dist/guards.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/hash.d.ts +3 -0
- package/dist/node_modules/@allyhub/image-draw/dist/hash.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/inspect.d.ts +113 -0
- package/dist/node_modules/@allyhub/image-draw/dist/inspect.js +3 -0
- package/dist/node_modules/@allyhub/image-draw/dist/layer-style.d.ts +151 -0
- package/dist/node_modules/@allyhub/image-draw/dist/layer-style.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/paint.d.ts +29 -0
- package/dist/node_modules/@allyhub/image-draw/dist/paint.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/pictures.d.ts +39 -0
- package/dist/node_modules/@allyhub/image-draw/dist/pictures.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/plan.d.ts +52 -0
- package/dist/node_modules/@allyhub/image-draw/dist/plan.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/reads.d.ts +145 -0
- package/dist/node_modules/@allyhub/image-draw/dist/reads.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/shape-path.d.ts +26 -0
- package/dist/node_modules/@allyhub/image-draw/dist/shape-path.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/stage.d.ts +56 -0
- package/dist/node_modules/@allyhub/image-draw/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/styles.d.ts +35 -0
- package/dist/node_modules/@allyhub/image-draw/dist/styles.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/tone.d.ts +53 -0
- package/dist/node_modules/@allyhub/image-draw/dist/tone.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/package.json +14 -0
- package/dist/node_modules/@allyhub/image-measure/LICENSE +241 -0
- package/dist/node_modules/@allyhub/image-measure/dist/contrast.d.ts +43 -0
- package/dist/node_modules/@allyhub/image-measure/dist/contrast.js +2 -0
- package/dist/node_modules/@allyhub/image-measure/dist/layout.d.ts +186 -0
- package/dist/node_modules/@allyhub/image-measure/dist/layout.js +5 -0
- package/dist/node_modules/@allyhub/image-measure/package.json +14 -0
- package/dist/node_modules/@allyhub/image-sdk/LICENSE +241 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.d.ts +13 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.js +2 -0
- package/dist/{define.d.ts → node_modules/@allyhub/image-sdk/dist/define.d.ts} +21 -4
- package/dist/node_modules/@allyhub/image-sdk/dist/define.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/dom.d.ts +210 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/dom.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/fill.d.ts +21 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/fill.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/group.d.ts +17 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/group.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/index.d.ts +166 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/media.d.ts +6 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/media.js +2 -0
- package/dist/{messages.d.ts → node_modules/@allyhub/image-sdk/dist/messages.d.ts} +1 -1
- package/dist/node_modules/@allyhub/image-sdk/dist/picture.d.ts +59 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/picture.js +2 -0
- package/dist/{props.d.ts → node_modules/@allyhub/image-sdk/dist/props.d.ts} +4 -4
- package/dist/node_modules/@allyhub/image-sdk/dist/shape.d.ts +34 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/shape.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/stack.d.ts +16 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/stack.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.d.ts +38 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.js +2 -0
- package/dist/{written.js → node_modules/@allyhub/image-sdk/dist/written.js} +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +19 -0
- package/dist/node_modules/@allyhub/measure/LICENSE +241 -0
- package/dist/node_modules/@allyhub/measure/dist/compare.d.ts +195 -0
- package/dist/node_modules/@allyhub/measure/dist/compare.js +2 -0
- package/dist/node_modules/@allyhub/measure/dist/grain.d.ts +8 -0
- package/dist/node_modules/@allyhub/measure/dist/grain.js +2 -0
- package/dist/node_modules/@allyhub/measure/dist/image.d.ts +16 -0
- package/dist/node_modules/@allyhub/measure/dist/image.js +2 -0
- package/dist/node_modules/@allyhub/measure/dist/index.d.ts +4 -0
- package/dist/node_modules/@allyhub/measure/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/measure/package.json +13 -0
- package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.d.ts +4 -1
- package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.d.ts +15 -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/LICENSE +241 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.d.ts +1 -9
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/context.d.ts +39 -0
- package/dist/node_modules/@allyhub/piece/dist/context.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.d.ts +2 -2
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/export.d.ts +27 -10
- package/dist/node_modules/@allyhub/piece/dist/export.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/formats.d.ts +12 -68
- package/dist/node_modules/@allyhub/piece/dist/formats.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +104 -0
- package/dist/node_modules/@allyhub/piece/dist/index.d.ts +26 -0
- package/dist/node_modules/@allyhub/piece/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/layer-style.d.ts +1558 -0
- package/dist/node_modules/@allyhub/piece/dist/layer-style.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +389 -0
- package/dist/node_modules/@allyhub/piece/dist/layer.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +421 -0
- package/dist/node_modules/@allyhub/piece/dist/layout.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.d.ts +1 -1
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.d.ts +39 -9
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.js +1 -1
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.d.ts +6 -0
- package/dist/node_modules/@allyhub/piece/dist/names.d.ts +26 -0
- package/dist/node_modules/@allyhub/piece/dist/names.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/console.d.ts +21 -0
- package/dist/node_modules/@allyhub/piece/dist/page/console.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +3 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +4 -0
- package/dist/node_modules/@allyhub/piece/dist/page/locate.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/picture.d.ts +62 -0
- package/dist/node_modules/@allyhub/piece/dist/picture.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/piece.d.ts +15 -0
- package/dist/node_modules/@allyhub/piece/dist/piece.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/script.d.ts +9 -4
- package/dist/node_modules/@allyhub/piece/dist/script.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/source.d.ts +131 -0
- package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +285 -0
- package/dist/node_modules/@allyhub/piece/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/version.d.ts +15 -0
- package/dist/node_modules/@allyhub/piece/dist/version.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.d.ts +1 -20
- package/dist/node_modules/@allyhub/piece/package.json +18 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +139 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/app.d.ts +3 -10
- package/dist/node_modules/@allyhub/protocol/dist/app.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +12 -1
- package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +232 -132
- package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/files.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +22 -9
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/image.d.ts +8 -0
- package/dist/node_modules/@allyhub/protocol/dist/image.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +5 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
- package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +98 -0
- package/dist/node_modules/@allyhub/protocol/dist/kinds.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +273 -0
- package/dist/node_modules/@allyhub/protocol/dist/mail.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +26 -0
- package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/peer.d.ts +59 -0
- package/dist/node_modules/@allyhub/protocol/dist/peer.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/place.d.ts +21 -0
- package/dist/node_modules/@allyhub/protocol/dist/place.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +125 -0
- package/dist/node_modules/@allyhub/protocol/dist/presence.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/registry.d.ts +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/routes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/shape.d.ts +35 -0
- package/dist/node_modules/@allyhub/protocol/dist/shape.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +2 -8
- package/dist/node_modules/@allyhub/protocol/dist/shares.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +70 -40
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +224 -177
- package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/protocol/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/bundled.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/declared.d.ts +14 -0
- package/dist/node_modules/@allyhub/runtimes/dist/declared.js +2 -0
- package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.d.ts +15 -0
- package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.js +2 -0
- package/dist/node_modules/@allyhub/runtimes/dist/index.d.ts +2 -0
- package/dist/node_modules/@allyhub/runtimes/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/packages.js +3 -3
- package/dist/node_modules/@allyhub/runtimes/dist/runtimes.d.ts +1 -0
- package/dist/node_modules/@allyhub/runtimes/dist/runtimes.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/manifest.json +0 -82
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/define.d.ts +2 -0
- package/dist/node_modules/@allyhub/scenery/dist/define.js +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/code.d.ts +4 -4
- package/dist/node_modules/@allyhub/sheet/dist/api/code.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.d.ts +15 -11
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/server.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/file.d.ts +5 -0
- package/dist/node_modules/@allyhub/sheet/dist/file.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/generated.d.ts +5 -19
- package/dist/node_modules/@allyhub/sheet/dist/generated.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/import.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +3 -4
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/inspect.d.ts +76 -1
- package/dist/node_modules/@allyhub/sheet/dist/patch.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/patch.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/sdk.d.ts +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/sdk.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +6 -6
- package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.d.ts +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +5 -1
- package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +23 -7
- package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +44 -4
- 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/chart-api.d.ts +18 -1
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/code.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/connect.d.ts +62 -0
- package/dist/node_modules/@allyhub/slides-core/dist/connect.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/fact.d.ts +208 -0
- package/dist/node_modules/@allyhub/slides-core/dist/fact.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/file.d.ts +4 -4
- package/dist/node_modules/@allyhub/slides-core/dist/file.js +2 -2
- package/dist/node_modules/@allyhub/slides-core/dist/index.d.ts +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/measure.d.ts +4 -2
- package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/merge.d.ts +5 -5
- package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +19 -2
- package/dist/node_modules/@allyhub/slides-core/dist/office.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/path.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +17 -10
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.d.ts +18 -0
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/stage.d.ts +28 -11
- package/dist/node_modules/@allyhub/slides-core/dist/units.d.ts +3 -6
- package/dist/node_modules/@allyhub/slides-core/dist/units.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/package.json +5 -1
- package/dist/node_modules/@allyhub/video-core/dist/audio-types.d.ts +1 -2
- package/dist/node_modules/@allyhub/video-core/dist/captions.d.ts +1 -10
- package/dist/node_modules/@allyhub/video-core/dist/captions.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/check.d.ts +62 -0
- package/dist/node_modules/@allyhub/video-core/dist/check.js +2 -0
- package/dist/node_modules/@allyhub/video-core/dist/cut-report.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/cut-report.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/edits.d.ts +3 -3
- package/dist/node_modules/@allyhub/video-core/dist/edits.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/fact.d.ts +21 -762
- package/dist/node_modules/@allyhub/video-core/dist/fact.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/footage-motion.d.ts +3 -2
- package/dist/node_modules/@allyhub/video-core/dist/footage-motion.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/index.d.ts +3 -17
- package/dist/node_modules/@allyhub/video-core/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/measure.d.ts +72 -423
- package/dist/node_modules/@allyhub/video-core/dist/measure.js +1 -4
- package/dist/node_modules/@allyhub/video-core/dist/mix-plan.d.ts +44 -0
- package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +2 -0
- package/dist/node_modules/@allyhub/video-core/dist/motion.d.ts +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/piece.d.ts +22 -430
- package/dist/node_modules/@allyhub/video-core/dist/piece.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/placement.d.ts +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/schema.d.ts +6 -12
- package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/script-edit.d.ts +11 -6
- package/dist/node_modules/@allyhub/video-core/dist/script-edit.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/seams.d.ts +2 -3
- package/dist/node_modules/@allyhub/video-core/dist/sound-under.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/sound-under.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/speech.d.ts +2 -4
- package/dist/node_modules/@allyhub/video-core/dist/speech.js +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/stage.d.ts +52 -0
- package/dist/node_modules/@allyhub/video-core/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/video-core/dist/timeline.d.ts +18 -136
- package/dist/node_modules/@allyhub/video-core/dist/timeline.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/timing.d.ts +3 -3
- package/dist/node_modules/@allyhub/video-core/dist/timing.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/transcript.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/transcript.js +1 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/LICENSE +241 -0
- package/dist/node_modules/@allyhub/video-sdk/NOTICE +118 -0
- package/dist/{free.d.ts → node_modules/@allyhub/video-sdk/dist/free.d.ts} +14 -10
- package/dist/node_modules/@allyhub/video-sdk/dist/free.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/index.d.ts +28 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/index.js +2 -0
- package/dist/{input.d.ts → node_modules/@allyhub/video-sdk/dist/input.d.ts} +76 -22
- package/dist/node_modules/@allyhub/video-sdk/dist/input.js +2 -0
- package/dist/{module.d.ts → node_modules/@allyhub/video-sdk/dist/module.d.ts} +6 -4
- package/dist/node_modules/@allyhub/video-sdk/dist/module.js +2 -0
- package/dist/{parts.d.ts → node_modules/@allyhub/video-sdk/dist/parts.d.ts} +15 -6
- package/dist/node_modules/@allyhub/video-sdk/dist/parts.js +2 -0
- package/dist/{piece.d.ts → node_modules/@allyhub/video-sdk/dist/piece.d.ts} +26 -16
- package/dist/node_modules/@allyhub/video-sdk/dist/piece.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/route.d.ts +46 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/route.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/scenery.d.ts +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/scenery.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/package.json +19 -0
- package/dist/scenery.d.ts +1 -1
- package/dist/scenery.js +1 -1
- package/dist/sheets.d.ts +1 -1
- package/dist/sheets.js +1 -1
- package/dist/slides.d.ts +1 -9
- package/dist/slides.js +1 -1
- package/docs/README.md +8 -6
- package/docs/batches.md +5 -5
- package/docs/contract.md +2 -2
- package/docs/defaults.md +278 -20
- package/docs/docs.md +77 -63
- package/docs/footage.md +7 -7
- package/docs/image.md +165 -0
- package/docs/layers.md +22 -13
- package/docs/modeling.md +4 -4
- package/docs/pictures.md +65 -0
- package/docs/project.md +51 -31
- package/docs/scenery.md +11 -11
- package/docs/sheets.md +26 -25
- package/docs/slides.md +73 -65
- package/docs/sound.md +3 -3
- package/docs/speech.md +8 -8
- package/docs/video.md +16 -13
- package/docs/websites.md +4 -4
- package/package.json +7 -2
- package/dist/define.js +0 -2
- package/dist/free.js +0 -2
- package/dist/input.js +0 -2
- package/dist/module.js +0 -2
- package/dist/node_modules/@allyhub/formats/dist/data/comments.d.ts +0 -94
- package/dist/node_modules/@allyhub/formats/dist/data/comments.js +0 -2
- package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package-lock.json +0 -227
- package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package.json +0 -8
- package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package-lock.json +0 -105
- package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package.json +0 -8
- package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package-lock.json +0 -128
- package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package.json +0 -9
- package/dist/node_modules/@allyhub/video-core/dist/export.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/formats.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/gen.d.ts +0 -37
- package/dist/node_modules/@allyhub/video-core/dist/problem.d.ts +0 -278
- package/dist/node_modules/@allyhub/video-core/dist/problem.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/script.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/source.d.ts +0 -7
- package/dist/parts.js +0 -2
- package/dist/piece.js +0 -2
- /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.js +0 -0
- /package/dist/{fit.d.ts → node_modules/@allyhub/image-sdk/dist/fit.d.ts} +0 -0
- /package/dist/{fit.js → node_modules/@allyhub/image-sdk/dist/fit.js} +0 -0
- /package/dist/{messages.js → node_modules/@allyhub/image-sdk/dist/messages.js} +0 -0
- /package/dist/{props.js → node_modules/@allyhub/image-sdk/dist/props.js} +0 -0
- /package/dist/{text.d.ts → node_modules/@allyhub/image-sdk/dist/text.d.ts} +0 -0
- /package/dist/{text.js → node_modules/@allyhub/image-sdk/dist/text.js} +0 -0
- /package/dist/{written.d.ts → node_modules/@allyhub/image-sdk/dist/written.d.ts} +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/gen.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/source.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.js +0 -0
- /package/dist/{anim.d.ts → node_modules/@allyhub/video-sdk/dist/anim.d.ts} +0 -0
- /package/dist/{anim.js → node_modules/@allyhub/video-sdk/dist/anim.js} +0 -0
- /package/dist/{noise.d.ts → node_modules/@allyhub/video-sdk/dist/noise.d.ts} +0 -0
- /package/dist/{noise.js → node_modules/@allyhub/video-sdk/dist/noise.js} +0 -0
- /package/dist/{paths.d.ts → node_modules/@allyhub/video-sdk/dist/paths.d.ts} +0 -0
- /package/dist/{paths.js → node_modules/@allyhub/video-sdk/dist/paths.js} +0 -0
- /package/dist/{phone.d.ts → node_modules/@allyhub/video-sdk/dist/phone.d.ts} +0 -0
- /package/dist/{phone.js → node_modules/@allyhub/video-sdk/dist/phone.js} +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export declare const isGeneric: (family: string) => boolean;
|
|
2
|
+
/** The families of a computed font-family, unquoted, in order. */
|
|
3
|
+
export declare function families(fontFamily: string): string[];
|
|
4
|
+
/** A FontFace's unicode-range as code point intervals ("U+4??" included). */
|
|
5
|
+
export declare function unicodeRanges(range: string): [number, number][];
|
|
6
|
+
/** A FontFace weight ("400", "100 900", "bold") as a range. */
|
|
7
|
+
export declare function weightRange(weight: string): [number, number];
|
|
8
|
+
/**
|
|
9
|
+
* The weight CSS font matching picks among faces for a wanted weight
|
|
10
|
+
* (CSS Fonts 4, 5.2): within a face's range it is exact; otherwise below
|
|
11
|
+
* 400 it looks lighter first, above 500 heavier first, and between them up
|
|
12
|
+
* to 500, then lighter, then heavier.
|
|
13
|
+
*/
|
|
14
|
+
export declare function matchWeight(want: number, faces: readonly [number, number][]): number | undefined;
|
|
15
|
+
/** Bold is faked when 600 or more is asked of faces that stop below 600. */
|
|
16
|
+
export declare const BOLD = 600;
|
|
17
|
+
export interface FaceInfo {
|
|
18
|
+
family: string;
|
|
19
|
+
weight: [number, number];
|
|
20
|
+
/** Whether the face is italic or oblique. */
|
|
21
|
+
slanted: boolean;
|
|
22
|
+
status: FontFaceLoadStatus;
|
|
23
|
+
ranges: [number, number][];
|
|
24
|
+
}
|
|
25
|
+
export interface FontWant {
|
|
26
|
+
families: string[];
|
|
27
|
+
weight: number;
|
|
28
|
+
italic: boolean;
|
|
29
|
+
/** Chrome may fake bold / italic (font-synthesis). */
|
|
30
|
+
synthBold: boolean;
|
|
31
|
+
synthItalic: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** What went wrong with the font of some text, if anything. */
|
|
34
|
+
export type FontIssue = {
|
|
35
|
+
kind: "fallback";
|
|
36
|
+
family: string;
|
|
37
|
+
failed: boolean;
|
|
38
|
+
usedFamily: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "bold";
|
|
41
|
+
family: string;
|
|
42
|
+
weight: number;
|
|
43
|
+
drawn: number;
|
|
44
|
+
faked: boolean;
|
|
45
|
+
} | {
|
|
46
|
+
kind: "italic";
|
|
47
|
+
family: string;
|
|
48
|
+
faked: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Decides, from the declared faces, how text asks for its font:
|
|
52
|
+
* `local(family)` says whether a family without faces is on this computer.
|
|
53
|
+
*/
|
|
54
|
+
export declare function fontIssue(want: FontWant, cps: readonly number[], faces: readonly FaceInfo[], local: (family: string) => boolean): FontIssue | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The families a text is drawn in, in the order they first draw one of its
|
|
57
|
+
* characters: for each, as the browser picks it, the first family of its
|
|
58
|
+
* font stack with a loaded face whose range covers it, a family on this
|
|
59
|
+
* computer (`local`; whether it has the character is not known), or a
|
|
60
|
+
* generic one; what none of them draws, the browser's default font.
|
|
61
|
+
*/
|
|
62
|
+
export declare function drawnFamilies(want: FontWant, cps: readonly number[], faces: readonly FaceInfo[], local: (family: string) => boolean): string[];
|
|
63
|
+
/** One sentence about an issue, with the fix. */
|
|
64
|
+
export declare function fontIssueText(issue: FontIssue): string;
|
|
65
|
+
/** Every string in a value (props: nested objects and arrays), at most `max`. */
|
|
66
|
+
export declare function stringsOf(v: unknown, max?: number): string[];
|
|
67
|
+
/**
|
|
68
|
+
* The emoji characters of some texts, each once, with the joiners and
|
|
69
|
+
* selectors that build sequences: what to load of the emoji font. Digits,
|
|
70
|
+
* `#` and `*` (also keycap bases) are left to the text fonts.
|
|
71
|
+
*/
|
|
72
|
+
export declare function emojiOf(texts: readonly string[]): string;
|
|
73
|
+
/** The faces of the page (read once per checked frame). */
|
|
74
|
+
export declare function pageFaces(): FaceInfo[];
|
|
75
|
+
/**
|
|
76
|
+
* Whether a family without @font-face is installed on this computer: text
|
|
77
|
+
* in it measures differently from the generic fonts it would fall back to.
|
|
78
|
+
*/
|
|
79
|
+
export declare function localFamily(family: string): boolean;
|
|
80
|
+
/** What text in el asks of its font. */
|
|
81
|
+
export declare function fontWant(cs: CSSStyleDeclaration): FontWant;
|
|
82
|
+
/** The code points of some texts, each once. */
|
|
83
|
+
export declare function codePoints(texts: readonly string[]): Set<number>;
|
|
84
|
+
/** Whether a face's unicode-range has one of these code points. */
|
|
85
|
+
export declare function coversAny(ranges: readonly [number, number][], cps: ReadonlySet<number>): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* The families a font-family value names, generic ones and variables
|
|
88
|
+
* left out, in lower case: what a declaration can draw with.
|
|
89
|
+
*/
|
|
90
|
+
export declare function namedFamilies(fontFamily: string): string[];
|
|
91
|
+
/** The families the page's stylesheets name in font-family (lower case). */
|
|
92
|
+
export declare function styleSheetFamilies(): Set<string>;
|
|
93
|
+
/**
|
|
94
|
+
* The declared families (lower case) a layer's props name: a component
|
|
95
|
+
* given a font as a prop sets it on its own elements when it mounts, and
|
|
96
|
+
* measures in it, so its faces load before mount as the look's do.
|
|
97
|
+
*/
|
|
98
|
+
export declare function propFamilies(props: readonly string[]): Set<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Loads every face of these families (lower case) that has one of the
|
|
101
|
+
* code points, whatever its weight and style. A face that fails is the
|
|
102
|
+
* check's to report (AK-L006).
|
|
103
|
+
*/
|
|
104
|
+
export declare function loadFaces(wanted: ReadonlySet<string>, cps: ReadonlySet<number>): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Loads the faces the text under `root` asks for, as Chrome would to draw
|
|
107
|
+
* it: per font (style, weight and families), the characters set in it.
|
|
108
|
+
*/
|
|
109
|
+
export declare function loadTextFonts(root: Element): Promise<void>;
|
|
110
|
+
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
+
const y=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","-apple-system","blinkmacsystemfont","inherit","initial"]);export const isGeneric=t=>y.has(t.toLowerCase());export function families(t){const e=[];let r="",i="";for(const n of t)i?n===i?i="":r+=n:n==='"'||n==="'"?i=n:n===","?(e.push(r.trim()),r=""):r+=n;return e.push(r.trim()),e.filter(Boolean)}export function unicodeRanges(t){const e=[];for(const r of t.split(",")){const i=/^\s*u\+([0-9a-f?]+)(?:-([0-9a-f]+))?\s*$/i.exec(r),n=i?.[1];if(n)if(n.includes("?"))e.push([parseInt(n.replace(/\?/g,"0"),16),parseInt(n.replace(/\?/g,"f"),16)]);else{const o=parseInt(n,16);e.push([o,i[2]?parseInt(i[2],16):o])}}return e}export function weightRange(t){const e=s=>s==="bold"?700:s==="normal"?400:Number(s),[r="400",i]=t.trim().split(/\s+/),n=e(r),o=i===void 0?n:e(i);return Number.isFinite(n)&&Number.isFinite(o)?[n,o]:[400,400]}export function matchWeight(t,e){if(e.length===0)return;if(e.some(([s,a])=>t>=s&&t<=a))return t;const r=e.filter(([s])=>s>t).map(([s])=>s),i=e.filter(([,s])=>s<t).map(([,s])=>s),n=r.length?Math.min(...r):void 0,o=i.length?Math.max(...i):void 0;return t>500?n??o:t<400?o??n:n!==void 0&&n<=500?n:o??n}export const BOLD=600;const m=(t,e)=>t.ranges.length===0||e.some(r=>t.ranges.some(([i,n])=>r>=i&&r<=n));export function fontIssue(t,e,r,i){const n=t.families[0];if(n===void 0||isGeneric(n))return;let o;for(const s of t.families){if(isGeneric(s))return o&&{kind:"fallback",...o,usedFamily:s};const a=r.filter(l=>l.family.toLowerCase()===s.toLowerCase());if(a.length===0){if(i(s))return o&&{kind:"fallback",...o,usedFamily:s};o??={family:s,failed:!1};continue}const c=a.filter(l=>m(l,e));if(c.length===0)continue;const f=c.filter(l=>l.status==="loaded");if(f.length===0){if(c.every(l=>l.status==="error")){o??={family:s,failed:!0};continue}return}if(o)return{kind:"fallback",...o,usedFamily:s};const u=matchWeight(t.weight,f.map(l=>l.weight)),d=Math.max(...f.map(l=>l.weight[1]));return t.weight>=BOLD&&d<BOLD?{kind:"bold",family:s,weight:t.weight,drawn:u??d,faked:t.synthBold}:t.italic&&!f.some(l=>l.slanted)?{kind:"italic",family:s,faked:t.synthItalic}:void 0}return o&&{kind:"fallback",...o,usedFamily:"the browser's default font"}}export function drawnFamilies(t,e,r,i){const n=[];for(const o of new Set(e)){let s="the browser's default font";for(const a of t.families){if(isGeneric(a)){s=a;break}const c=r.filter(f=>f.family.toLowerCase()===a.toLowerCase());if(c.length===0?i(a):c.some(f=>f.status==="loaded"&&m(f,[o]))){s=a;break}}n.includes(s)||n.push(s)}return n}export function fontIssueText(t){switch(t.kind){case"fallback":return t.failed?`the font "${t.family}" failed to load, so it is drawn in ${h(t.usedFamily)}. Check the @font-face url and that the file is in the workspace.`:`the font "${t.family}" is not loaded, so it is drawn in ${h(t.usedFamily)}. Import its stylesheet in the piece (import "@fontsource/<id>/400.css" after npm install @fontsource/<id>, or a .css of @font-face rules), or list it in allyhub.config.ts's fonts for every stage, or use a font the look has (var(--ak-font-display), var(--ak-font-body)).`;case"bold":return t.faked?`"${t.family}" has no face for weight ${String(t.weight)} (the loaded faces stop below ${String(BOLD)}), so Chrome fakes the bold by thickening weight ${String(t.drawn)}. Load a bold face of the font, or use a weight it has.`:`"${t.family}" has no face for weight ${String(t.weight)}, so it is drawn at weight ${String(t.drawn)}. Load a bold face of the font, or use a weight it has.`;case"italic":return t.faked?`"${t.family}" has no italic face, so Chrome fakes the italic by slanting the upright letters. Load an italic face of the font, or drop font-style: italic.`:`"${t.family}" has no italic face, so it is drawn upright. Load an italic face of the font, or drop font-style: italic.`}}const h=t=>isGeneric(t)?`the browser's ${t} font`:t.startsWith("the ")?t:`"${t}"`;export function stringsOf(t,e=2e3){const r=[],i=new Set,n=o=>{if(!(r.length>=e)){if(typeof o=="string")r.push(o);else if(typeof o=="object"&&o!==null&&!i.has(o)){i.add(o);for(const s of Array.isArray(o)?o:Object.values(o))n(s)}}};return n(t),r}export function emojiOf(t){const e=/\p{Extended_Pictographic}|\p{Regional_Indicator}|[\u{1F3FB}-\u{1F3FF}\u{E0020}-\u{E007F}]|\u200d|\ufe0f|\u20e3/gu,r=new Set;for(const i of t)for(const n of i.matchAll(e))r.add(n[0]);return[...r].join("")}const p=new Map;let g;export function pageFaces(){const t=[];return document.fonts.forEach(e=>{t.push({family:families(e.family)[0]??e.family,weight:weightRange(e.weight),slanted:e.style!=="normal",status:e.status,ranges:unicodeRanges(e.unicodeRange)})}),t}export function localFamily(t){const e=p.get(t);if(e!==void 0)return e;g??=document.createElement("canvas").getContext("2d");const r=g;if(!r)return!0;const i="mmmmmmmmmmlli10WQ@#ƌ",n=a=>(r.font=a,r.measureText(i).width),o=JSON.stringify(t),s=["monospace","serif","sans-serif"].some(a=>n(`40px ${o}, ${a}`)!==n(`40px ${a}`));return p.set(t,s),s}export function fontWant(t){const e=Number(t.fontWeight);return{families:families(t.fontFamily),weight:Number.isFinite(e)?e:400,italic:t.fontStyle!=="normal",synthBold:t.getPropertyValue("font-synthesis-weight")!=="none",synthItalic:t.getPropertyValue("font-synthesis-style")!=="none"}}export function codePoints(t){const e=new Set;for(const r of t)for(const i of r)e.add(i.codePointAt(0)??0);return e}export function coversAny(t,e){if(t.length===0)return!0;for(const r of e)if(t.some(([i,n])=>r>=i&&r<=n))return!0;return!1}export function namedFamilies(t){return families(t).filter(e=>!isGeneric(e)&&!e.startsWith("var(")).map(e=>e.toLowerCase())}export function styleSheetFamilies(){const t=new Set,e=r=>{for(const i of Array.from(r))if(i instanceof CSSStyleRule){const n=i.style.getPropertyValue("font-family");if(n)for(const o of namedFamilies(n))t.add(o)}else i instanceof CSSGroupingRule&&e(i.cssRules)};for(const r of Array.from(document.styleSheets))try{e(r.cssRules)}catch{}return t}export function propFamilies(t){const e=new Set;document.fonts.forEach(n=>{e.add((families(n.family)[0]??n.family).toLowerCase())});const r=t.map(n=>n.toLowerCase()),i=new Set;for(const n of e)n&&r.some(o=>o.includes(n))&&i.add(n);return i}export async function loadFaces(t,e){const r=[];document.fonts.forEach(i=>{if(i.status!=="unloaded")return;const n=(families(i.family)[0]??i.family).toLowerCase();t.has(n)&&coversAny(unicodeRanges(i.unicodeRange),e)&&r.push(i.load().catch(()=>{}))}),await Promise.all(r)}export async function loadTextFonts(t){const e=new Map,r=new Map,i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let o=i.nextNode();o;o=i.nextNode()){const s=o.nodeValue??"",a=o.parentElement;if(!a||!s.trim())continue;let c=r.get(a);if(c===void 0){const u=getComputedStyle(a);c=`${u.fontStyle==="normal"?"":"italic "}${u.fontWeight} 40px ${u.fontFamily}`,r.set(a,c)}let f=e.get(c);f||(f=new Set,e.set(c,f));for(const u of s)u.trim()&&f.add(u)}const n=[...e].map(([o,s])=>[o,[...s].join("")]).filter(([o,s])=>!document.fonts.check(o,s));n.length!==0&&await Promise.all(n.map(([o,s])=>document.fonts.load(o,s).catch(()=>[])))}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { RealTimers } from "@allyhub/piece";
|
|
2
|
+
/** Time 0 of a piece as a wall-clock date: 2026-01-01T00:00:00Z. */
|
|
3
|
+
export declare const EPOCH_MS: number;
|
|
4
|
+
export declare function hashString(s: string): number;
|
|
5
|
+
export declare function mulberry32(seed: number): () => number;
|
|
6
|
+
/** The real clock, captured before the guards replace it (for timing frames). */
|
|
7
|
+
export declare const realNow: () => number;
|
|
8
|
+
/** The real timer, for waits the runtime itself bounds (a clip's seek). */
|
|
9
|
+
export declare const realTimeout: (cb: () => void, ms: number) => unknown;
|
|
10
|
+
/** The real clearTimeout, captured before anything replaces the global one. */
|
|
11
|
+
export declare const realClearTimeout: (id: unknown) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Waits for promises at most `ms` (on the real clock): each one's result,
|
|
14
|
+
* or undefined for one still pending then.
|
|
15
|
+
*/
|
|
16
|
+
export declare function within<T>(list: readonly Promise<T>[], ms: number): Promise<(PromiseSettledResult<T> | undefined)[]>;
|
|
17
|
+
/** The real frame callback, for the player's playback loop. */
|
|
18
|
+
export declare const realRaf: (cb: FrameRequestCallback) => number;
|
|
19
|
+
export interface Guards {
|
|
20
|
+
/** Sets the virtual moment and reseeds randomness for it. */
|
|
21
|
+
setMoment(t: number, seed: string): void;
|
|
22
|
+
/** Runs the requestAnimationFrame callbacks queued so far, at the virtual time. */
|
|
23
|
+
flushFrames(): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The page's own clock and timers, captured before the guards replace
|
|
27
|
+
* them: a layer gets them as ctx.realTimers (a scenery's loaders while it
|
|
28
|
+
* builds), never for what a frame shows.
|
|
29
|
+
*/
|
|
30
|
+
export declare const realTimers: RealTimers;
|
|
31
|
+
export declare function installGuards(): Guards;
|
|
32
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
+
export const EPOCH_MS=Date.UTC(2026,0,1);export function hashString(t){let o=2166136261;for(let e=0;e<t.length;e++)o^=t.charCodeAt(e),o=Math.imul(o,16777619);return o>>>0}export function mulberry32(t){let o=t>>>0;return()=>{o=o+1831565813|0;let e=Math.imul(o^o>>>15,1|o);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}export const realNow=performance.now.bind(performance),realTimeout=setTimeout.bind(globalThis);const f=clearTimeout.bind(globalThis);export const realClearTimeout=t=>{f(t)};export function within(t,o){const e=t.map(()=>{});return t.length===0?Promise.resolve(e):new Promise(l=>{let i=t.length;const m=realTimeout(()=>{l([...e])},Math.max(0,o));t.forEach((a,s)=>{a.then(n=>{e[s]={status:"fulfilled",value:n}},n=>{e[s]={status:"rejected",reason:n}}).finally(()=>{i--,i===0&&(realClearTimeout(m),l([...e]))})})})}export const realRaf=typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(globalThis):t=>Number(setTimeout(()=>{t(realNow())},16)),realTimers={now:realNow,setTimeout:realTimeout,clearTimeout:realClearTimeout};let u;export function installGuards(){if(u)return u;const t=globalThis,o=Date;let e=0,l=mulberry32(1);class i extends o{constructor(...r){r.length===0?super(EPOCH_MS+e):super(...r)}static now(){return EPOCH_MS+e}}t.Date=i,Math.random=()=>l(),performance.now=()=>e;const m=n=>{if(n){const r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);for(let c=0;c<r.length;c++)r[c]=Math.floor(l()*256)}return n};crypto.getRandomValues=m;let a=[],s=1;return t.requestAnimationFrame=n=>{const r=s++;return a.push([r,n]),r},t.cancelAnimationFrame=n=>{a=a.filter(([r])=>r!==n)},t.setTimeout=()=>0,t.setInterval=()=>0,u={setMoment(n,r){e=n*1e3,l=mulberry32(hashString(r))},flushFrames(){const n=a;a=[];for(const[,r]of n)r(e)}},u}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
+
export function domHash(t){let n=2166136261,e=5381;for(let o=0;o<t.length;o++){const r=t.charCodeAt(o);n=Math.imul(n^r,16777619)>>>0,e=Math.imul(e,33)+r>>>0}return`${n.toString(16)}${e.toString(16)}:${String(t.length)}`}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type Box, type Problem } from "@allyhub/diagnostics";
|
|
2
|
+
import type { TextContainer } from "@allyhub/piece";
|
|
3
|
+
export interface ScreenText {
|
|
4
|
+
text: string;
|
|
5
|
+
el: HTMLElement;
|
|
6
|
+
bbox: Box;
|
|
7
|
+
/** Effective opacity, the product of the element's and its ancestors'. */
|
|
8
|
+
opacity: number;
|
|
9
|
+
/**
|
|
10
|
+
* The rows its glyphs cover, [top, bottom] in viewport pixels: the first
|
|
11
|
+
* line's box down to the highest glyph's top, the last line's up to the
|
|
12
|
+
* lowest glyph's bottom. A line's box is the font's whole ascent and
|
|
13
|
+
* descent, taller than what is drawn.
|
|
14
|
+
*/
|
|
15
|
+
rows: [top: number, bottom: number];
|
|
16
|
+
/**
|
|
17
|
+
* What its glyphs cover, a box per line in viewport pixels, [x0, y0, x1,
|
|
18
|
+
* y1]: each line's box down to its glyphs' rows (as `rows`), out to the
|
|
19
|
+
* first glyph's overhang on the left of the first line and the last
|
|
20
|
+
* glyph's on the right of the last.
|
|
21
|
+
*/
|
|
22
|
+
lines: [x0: number, y0: number, x1: number, y1: number][];
|
|
23
|
+
/** Its font size as drawn, in viewport pixels: the computed size scaled as a transform scales its line's box. */
|
|
24
|
+
size: number;
|
|
25
|
+
/**
|
|
26
|
+
* The height of its font's lowercase x as drawn, in viewport pixels,
|
|
27
|
+
* scaled as `size`: how large its lowercase letters are, which a
|
|
28
|
+
* handwriting or display face draws much smaller than its size says.
|
|
29
|
+
* Only for text with a lowercase Latin letter.
|
|
30
|
+
*/
|
|
31
|
+
xHeight?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Visible text in `root`, in document order, with where it is drawn;
|
|
35
|
+
* `screens: false` leaves out what is part of a picture: drawn on a 3D
|
|
36
|
+
* scenery's screens, or inside an element marked `data-ak-picture`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function screenTexts(root: HTMLElement, opts?: {
|
|
39
|
+
screens?: boolean;
|
|
40
|
+
}): ScreenText[];
|
|
41
|
+
export interface TextBlock {
|
|
42
|
+
text: string;
|
|
43
|
+
/** In the frame's pixels (the stage's, unscaled), whole pixels. */
|
|
44
|
+
box: Box;
|
|
45
|
+
/** Inside a page viewport (a site demo): the page's own text. */
|
|
46
|
+
viewport?: boolean;
|
|
47
|
+
/** The lowest opacity of its text nodes (each with its ancestors'). */
|
|
48
|
+
opacity: number;
|
|
49
|
+
/**
|
|
50
|
+
* What shows of its glyphs, in the frame's pixels: the rows they cover
|
|
51
|
+
* (a line's box is taller), cut where an ancestor clips its content
|
|
52
|
+
* (overflow); null when all of it is clipped away.
|
|
53
|
+
*/
|
|
54
|
+
ink: Box | null;
|
|
55
|
+
/** The share of its glyphs' box that shows, the lowest of its text nodes' (1: nothing clips it). */
|
|
56
|
+
shown: number;
|
|
57
|
+
/** Its font size as drawn, in the frame's pixels: the smallest of its text nodes'. */
|
|
58
|
+
size: number;
|
|
59
|
+
/** Its lowercase x's height as drawn, in the frame's pixels: the smallest of its text nodes' that have lowercase Latin letters. */
|
|
60
|
+
xHeight?: number;
|
|
61
|
+
/** The boxes it is drawn inside, nearest first (see `containersOf`). */
|
|
62
|
+
containers: TextContainer[];
|
|
63
|
+
/**
|
|
64
|
+
* What shows of its glyphs, a box per line in the frame's pixels (not
|
|
65
|
+
* rounded): cut where an ancestor clips its content, except where that
|
|
66
|
+
* ancestor's edge is at or past the frame's, so the frame's own edges are
|
|
67
|
+
* measured against them (the text-off-frame fact).
|
|
68
|
+
*/
|
|
69
|
+
glyphs: Box[];
|
|
70
|
+
/** Its text nodes: the element each is drawn by, its opacity and its glyphs' boxes (as `glyphs`). */
|
|
71
|
+
runs: {
|
|
72
|
+
el: HTMLElement;
|
|
73
|
+
opacity: number;
|
|
74
|
+
glyphs: Box[];
|
|
75
|
+
}[];
|
|
76
|
+
/** The block-level element whose text it is. */
|
|
77
|
+
el: HTMLElement;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Visible text in `root` as blocks: the text nodes of one block-level
|
|
81
|
+
* element (a line of word spans, a paragraph) joined, with the box round
|
|
82
|
+
* them in the stage's own pixels, whatever the stage is scaled to.
|
|
83
|
+
*/
|
|
84
|
+
export declare function textBlocks(root: HTMLElement, stage: HTMLElement, width: number): TextBlock[];
|
|
85
|
+
/**
|
|
86
|
+
* What allyhub inspect motion follows in a layer: every element that
|
|
87
|
+
* draws something of its own and shows (opacity over 0.05): one that holds
|
|
88
|
+
* text directly, one that paints a background, a border or a shadow, and a
|
|
89
|
+
* picture (img, svg, canvas, video; nothing inside an svg).
|
|
90
|
+
*/
|
|
91
|
+
export declare function trackedIn(root: HTMLElement): {
|
|
92
|
+
el: Element;
|
|
93
|
+
what: string;
|
|
94
|
+
opacity: number;
|
|
95
|
+
name?: string;
|
|
96
|
+
}[];
|
|
97
|
+
/** A selector that finds el inside the stage. */
|
|
98
|
+
export declare function selectorOf(el: Element, stage: HTMLElement): string;
|
|
99
|
+
export interface InspectInput {
|
|
100
|
+
part: string;
|
|
101
|
+
t: number;
|
|
102
|
+
section: HTMLElement;
|
|
103
|
+
stage: HTMLElement;
|
|
104
|
+
format: string;
|
|
105
|
+
/** The file the keys a text shows are written in (ReadLog's fileOfKeys). */
|
|
106
|
+
messagesFile: (keys: readonly string[]) => string;
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
/** Message keys showing a text, to say what to shorten. */
|
|
110
|
+
keysShowing(text: string): string[];
|
|
111
|
+
}
|
|
112
|
+
export declare function inspectFrame(input: InspectInput): Problem[];
|
|
113
|
+
//# sourceMappingURL=inspect.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
+
import{problem as v}from"@allyhub/diagnostics";import{fontIssue as K,fontIssueText as X,fontWant as G,localFamily as _,pageFaces as V}from"./fonts.js";const z=new Map;let E;function F(i,a){const s=`${i}
|
|
3
|
+
${a}`,t=z.get(s);if(t)return t;if(E??=document.createElement("canvas").getContext("2d"),!E)return;E.font=i;const e=E.measureText(a),r={fontUp:e.fontBoundingBoxAscent,fontDown:e.fontBoundingBoxDescent,up:e.actualBoundingBoxAscent,down:e.actualBoundingBoxDescent,left:Math.max(0,e.actualBoundingBoxLeft),right:Math.max(0,e.actualBoundingBoxRight-e.width)};return z.set(s,r),r}function Y(i,a,s){const t=s.getClientRects(),e=t.item(0),r=t.item(t.length-1),c=s.getBoundingClientRect(),u=Array.from(t).filter(x=>x.width>0&&x.height>0),h=(u.length>0?u:[c]).map(x=>[x.left,x.top,x.right,x.bottom]),n=getComputedStyle(i),o=parseFloat(n.fontSize)||0;if(!e||!r)return{rows:[c.top,c.bottom],lines:h,size:o};const l={rows:[e.top,r.bottom],lines:h,size:o},d=n.textTransform==="uppercase"?a.toUpperCase():n.textTransform==="lowercase"?a.toLowerCase():a,f=F(`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`,d),g=f?f.fontUp+f.fontDown:0;if(!f||g<=0||f.up+f.down<=0)return l;const y=e.height/g,b=e.top+(f.fontUp-f.up)*y,M=r.bottom-(f.fontDown-f.down)*y,m=M>b?[b,M]:[e.top,r.bottom],w=u.map((x,p)=>{const S=x.height/g,C=x.top+(f.fontUp-f.up)*S,$=x.bottom-(f.fontDown-f.down)*S,A=x.left-(p===0?f.left*S:0),R=x.right+(p===u.length-1?f.right*S:0);return $>C?[A,C,R,$]:[A,x.top,R,x.bottom]}),k=/[a-z]/.test(d)?F(`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`,"x"):void 0;return{rows:m,lines:w.length>0?w:h,size:o*y,...k&&k.up>0?{xHeight:k.up*y}:{}}}const L=i=>i.replace(/\u200b/g,"").replace(/\s+/g," ").trim();function B(i,a){let s=1;for(let t=i;t&&t!==a.parentElement;t=t.parentElement){const e=getComputedStyle(t);if(e.display==="none"||e.visibility==="hidden")return 0;s*=Number(e.opacity)}return s}function N(i,a){const s=i.closest("[data-ak-screen]");if(s!==null&&s!==a&&a.contains(s))return!0;const t=i.closest("[data-ak-picture]");return t!==null&&a.contains(t)}export function screenTexts(i,a={}){const s=[],t=document.createTreeWalker(i,NodeFilter.SHOW_TEXT);for(let e=t.nextNode();e;e=t.nextNode()){const r=L(e.textContent??""),c=e.parentElement;if(!r||!c||a.screens===!1&&N(c,i))continue;const u=B(c,i);if(u<=.05)continue;const h=document.createRange();h.selectNodeContents(e);const n=h.getBoundingClientRect();if(n.width===0&&n.height===0)continue;const o=Y(c,r,h);s.push({text:r,el:c,bbox:[n.left,n.top,n.width,n.height],opacity:u,rows:o.rows,lines:o.lines,size:o.size,...o.xHeight===void 0?{}:{xHeight:o.xHeight}})}return s}const H=new Set(["hidden","clip","scroll","auto"]);function O(i,a,s,t){let[e,r,c,u]=i;const h=.5;for(let n=a;n&&n!==s.parentElement;n=n.parentElement){const o=getComputedStyle(n),l=H.has(o.overflowX),d=H.has(o.overflowY);if(!l&&!d)continue;const f=n.getBoundingClientRect(),g=(y,b,M)=>t&&(M?y>=b-h:y<=b+h);if(l&&(g(f.left,t?.left??0,!1)||(e=Math.max(e,f.left)),g(f.right,t?.right??0,!0)||(c=Math.min(c,f.right))),d&&(g(f.top,t?.top??0,!1)||(r=Math.max(r,f.top)),g(f.bottom,t?.bottom??0,!0)||(u=Math.min(u,f.bottom))),c<=e||u<=r)return}return[e,r,c,u]}const J=/^(transparent|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\))$/,q=/[,/]\s*0(\.0+)?\s*\)$/;function D(i){const a=[],s=i.backgroundColor;return(i.backgroundImage!=="none"||!J.test(s)&&!q.test(s))&&a.push("background"),["Top","Right","Bottom","Left"].some(e=>{const r=i[`border${e}Style`];return r!=="none"&&r!=="hidden"&&parseFloat(i[`border${e}Width`])>0})&&a.push("border"),i.boxShadow!=="none"&&a.push("shadow"),a}function Z(i,a,s,t,e){const r=[];for(let c=i;c&&c!==a;c=c.parentElement){const u=getComputedStyle(c);if(H.has(u.overflowX)&&H.has(u.overflowY))continue;const h=D(u);if(h.length===0||B(c,a)<=.05)continue;const n=c.getBoundingClientRect(),o=Math.round((n.left-s.left)*t),l=Math.round((n.top-s.top)*t),d=Math.round((n.right-s.left)*t),f=Math.round((n.bottom-s.top)*t);o<=0&&l<=0&&d>=e[0]&&f>=e[1]||r.push({box:[o,l,d-o,f-l],paint:h})}return r}const W=/[\u3000-\u9fff\uf900-\uffef]/;export function textBlocks(i,a,s){const t=a.getBoundingClientRect(),e=t.width>0?s/t.width:1,r=[s,Math.round(t.height*e)],c=new Map;for(const o of screenTexts(i,{screens:!1})){let l=o.el;for(;l!==i&&l.parentElement&&getComputedStyle(l).display.startsWith("inline");)l=l.parentElement;const[d,f,g,y]=o.bbox,[b,M]=o.rows,m=O([d,b,d+g,M],o.el,i),w=Math.max(0,g)*Math.max(0,M-b),k=m&&w>0?Math.min(1,(m[2]-m[0])*(m[3]-m[1])/w):m?1:0,x=o.lines.flatMap(C=>{const $=O(C,o.el,i,t);return $?[$]:[]}),p=c.get(l);if(!p){c.set(l,{text:o.text,x0:d,y0:f,x1:d+g,y1:f+y,opacity:o.opacity,...m?{ink:m}:{},shown:k,size:o.size,...o.xHeight===void 0?{}:{xHeight:o.xHeight},glyphs:x,runs:[{el:o.el,opacity:o.opacity,glyphs:x}]});continue}p.glyphs.push(...x),p.runs.push({el:o.el,opacity:o.opacity,glyphs:x});const S=W.test(p.text.slice(-1))||W.test(o.text.slice(0,1))?"":" ";p.text+=S+o.text,p.x0=Math.min(p.x0,d),p.y0=Math.min(p.y0,f),p.x1=Math.max(p.x1,d+g),p.y1=Math.max(p.y1,f+y),p.opacity=Math.min(p.opacity,o.opacity),p.shown=Math.min(p.shown,k),p.size=Math.min(p.size,o.size),o.xHeight!==void 0&&(p.xHeight=Math.min(p.xHeight??1/0,o.xHeight)),m&&(p.ink=p.ink?[Math.min(p.ink[0],m[0]),Math.min(p.ink[1],m[1]),Math.max(p.ink[2],m[2]),Math.max(p.ink[3],m[3])]:m)}const u=(o,l,d,f)=>{const g=Math.round((o-t.left)*e),y=Math.round((l-t.top)*e);return[g,y,Math.round((d-t.left)*e)-g,Math.round((f-t.top)*e)-y]},h=o=>Math.round(o*e*100)/100,n=([o,l,d,f])=>[h(o-t.left),h(l-t.top),h(d-o),h(f-l)];return[...c.entries()].map(([o,l])=>({text:l.text,...o.closest("[data-ak-viewport]")?{viewport:!0}:{},box:u(l.x0,l.y0,l.x1,l.y1),opacity:Math.round(l.opacity*1e3)/1e3,ink:l.ink?u(...l.ink):null,shown:Math.round(l.shown*1e3)/1e3,size:Math.round(l.size*e*10)/10,...l.xHeight===void 0?{}:{xHeight:Math.round(l.xHeight*e*10)/10},containers:Z(o,i,t,e,r),glyphs:l.glyphs.map(n),runs:l.runs.map(d=>({el:d.el,opacity:d.opacity,glyphs:d.glyphs.map(n)})),el:o}))}const Q=new Set(["img","svg","canvas","video"]);export function trackedIn(i){const a=[],s=t=>{const e=t.tagName.toLowerCase(),r=Q.has(e);let c=r?e:void 0;if(!r&&t instanceof HTMLElement){const u=L(Array.from(t.childNodes).filter(h=>h.nodeType===Node.TEXT_NODE).map(h=>h.textContent??"").join(" "));u?c=`text ${JSON.stringify(T(u))}`:D(getComputedStyle(t)).length>0&&(c="box")}if(c!==void 0){const u=t instanceof HTMLElement?B(t,i):t.parentElement?B(t.parentElement,i)*Number(getComputedStyle(t).opacity):1;if(u>.05){const h=t instanceof HTMLElement||t instanceof SVGElement?t.dataset.ak:void 0;a.push({el:t,what:c,opacity:Math.round(u*1e3)/1e3,...h?{name:h}:{}})}}if(!r)for(const u of Array.from(t.children))s(u)};for(const t of Array.from(i.children))s(t);return a}export function selectorOf(i,a){const s=[];for(let t=i;t&&t!==a;t=t.parentElement){const e=t instanceof HTMLElement||t instanceof SVGElement?t.dataset:{},r=e.key;if(r!==void 0&&t.classList.contains("ak-part")){s.unshift(`section[data-key="${r}"]`);break}const c=e.ak;if(c!==void 0){s.unshift(`[data-ak="${c}"]`);continue}const u=t.parentElement,h=u?Array.from(u.children).indexOf(t)+1:1;s.unshift(`${t.tagName.toLowerCase()}:nth-child(${String(h)})`)}return s.join(" > ")}const T=i=>i.length>40?`${i.slice(0,40)}…`:i;let I;const U=new Map,j=new Map;function P(i,a){I??=Object.assign(document.createElement("canvas"),{width:64,height:64}).getContext("2d",{willReadFrequently:!0});const s=I;return s?(s.clearRect(0,0,64,64),s.font=i,s.textBaseline="middle",s.fillText(a,4,32),s.getImageData(0,0,64,64).data.join(",")):""}function tt(i,a){const s=getComputedStyle(i),t=`${s.fontStyle} ${s.fontWeight} 40px ${s.fontFamily}`;let e=U.get(t);e===void 0&&(e=P(t,""),U.set(t,e));const r=[];for(const c of new Set(Array.from(a.replace(/\s/g,"")))){const u=`${t}|${c}`;let h=j.get(u);h===void 0&&(h=P(t,c)===e,j.set(u,h)),h&&r.push(c)}return r}export function inspectFrame(i){const{part:a,t:s,section:t,stage:e}=i,r=[],c=new Set,u=new Set;let h;for(const n of screenTexts(t)){const o=m=>{const w=i.keysShowing(n.text);return{selector:selectorOf(n.el,e),bbox:m.map(k=>Math.round(k)),...w.length>0?{file:i.messagesFile(w)}:{}}},l=i.keysShowing(n.text),d=l.length>0?`Shorten the text (${l.join(", ")})`:"Shorten the text",f=n.el.closest("[data-ak-viewport]")!==null,g=getComputedStyle(n.el);if((g.overflowX!=="visible"||g.overflowY!=="visible")&&!N(n.el,t)&&!c.has(n.el)&&(n.el.scrollWidth>n.el.clientWidth+1||n.el.scrollHeight>n.el.clientHeight+1)&&(c.add(n.el),r.push(v("AK-L002",`Text is cut off: "${T(n.text)}" does not fit its box. ${d}.`,{part:a,t:s,where:o(n.bbox)}))),!f){const m=tt(n.el,n.text);m.length>0&&r.push(v("AK-L003",`No font can draw ${m.map(w=>`"${w}" (U+${(w.codePointAt(0)??0).toString(16).toUpperCase().padStart(4,"0")})`).join(", ")} in "${T(n.text)}": they will show as boxes. Replace these characters, or add a font that supports them to the style.`,{part:a,t:s,where:o(n.bbox)}))}const b=G(g),M=`${g.fontFamily}|${String(b.weight)}|${g.fontStyle}`;if(!u.has(M)){h??=V();const m=Array.from(n.text.replace(/\s/g,"")).map(k=>k.codePointAt(0)??0),w=K(b,m,h,_);w&&(u.add(M),r.push(v("AK-L006",`"${T(n.text)}": ${X(w)}`,{part:a,t:s,where:o(n.bbox)})))}}return r}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { type Adjustment, type Effects, type GraphicLayer, type LayerMask, type LayerTransform, type MediaInfo, type MediaRef, type StageContext } from "@allyhub/piece";
|
|
2
|
+
/** A box in the frame's pixels: x, y, width, height. */
|
|
3
|
+
export type PxBox = readonly [x: number, y: number, w: number, h: number];
|
|
4
|
+
/** A name for an SVG resource, unique in its document, in the order they are made. */
|
|
5
|
+
export declare function nextId(doc: Document, what: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* The SVG defs a layer's resources go in, made once: its board's, or the
|
|
8
|
+
* stage's that holds its part. Never inside the part, which is hidden
|
|
9
|
+
* between moments: Chrome draws an element an feImage names only while it
|
|
10
|
+
* is shown.
|
|
11
|
+
*/
|
|
12
|
+
export declare function defsOf(el: Element): SVGDefsElement;
|
|
13
|
+
/** A layer's own box, the frame's pixels: its `box` (shares) where it has one, else the frame. */
|
|
14
|
+
export declare function boxOf(layer: GraphicLayer, frame: {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}): PxBox;
|
|
18
|
+
/** A picture's media, read through the stage (so the output records it): an import by its path, a path from `base`. */
|
|
19
|
+
export declare function mediaOfRef(ref: MediaRef, base: string, ctx: StageContext): MediaInfo | undefined;
|
|
20
|
+
/** Whether a mask written as a string is a picture's path (else CSS, or "ellipse"). */
|
|
21
|
+
export declare const maskIsPath: (m: string) => boolean;
|
|
22
|
+
/** An adjustment's filter, for `backdrop-filter`: what it makes of what lies under it. */
|
|
23
|
+
export declare function adjustmentFilter(a: Adjustment, defs: SVGDefsElement): string;
|
|
24
|
+
/**
|
|
25
|
+
* A gradient as SVG paints it over a box: linear (Photoshop's angle,
|
|
26
|
+
* counter-clockwise from left to right), radial (from the box's centre to
|
|
27
|
+
* its farthest corner), or reflected (a linear one mirrored about its
|
|
28
|
+
* middle). Its length is `scale` percent of the box's.
|
|
29
|
+
*/
|
|
30
|
+
export declare function svgGradient(doc: Document, id: string, gradient: NonNullable<NonNullable<Effects["gradientOverlay"]>["gradient"]>, box: PxBox): SVGLinearGradientElement | SVGRadialGradientElement;
|
|
31
|
+
export interface EffectsInput {
|
|
32
|
+
readonly fx: Effects;
|
|
33
|
+
readonly fillOpacity: number;
|
|
34
|
+
readonly box: PxBox;
|
|
35
|
+
readonly frame: {
|
|
36
|
+
readonly width: number;
|
|
37
|
+
readonly height: number;
|
|
38
|
+
};
|
|
39
|
+
readonly defs: SVGDefsElement;
|
|
40
|
+
readonly ctx: StageContext;
|
|
41
|
+
/** The folder a pattern's path is from. */
|
|
42
|
+
readonly base: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The layer's effects and its fill opacity as one filter (Photoshop's
|
|
46
|
+
* layer style), bottom to top: the drop shadow and the outer glow under
|
|
47
|
+
* what it shows (knocked out where it shows), then the overlays, the
|
|
48
|
+
* satin, the inner glow, the inner shadow and the bevel over it, each
|
|
49
|
+
* cut to what it shows. A stroke is the type or shape layer's own (it
|
|
50
|
+
* draws its glyphs' or path's stroke). Its id, or undefined when it has
|
|
51
|
+
* nothing to draw.
|
|
52
|
+
*/
|
|
53
|
+
export declare function effectsFilter(o: EffectsInput): string | undefined;
|
|
54
|
+
export interface MaskInput {
|
|
55
|
+
readonly mask: LayerMask;
|
|
56
|
+
/** Where its source lies when it gives no box, the target's pixels. */
|
|
57
|
+
readonly box: PxBox;
|
|
58
|
+
/** The target's own size, its pixels: what a box in shares is of. */
|
|
59
|
+
readonly frame: {
|
|
60
|
+
readonly width: number;
|
|
61
|
+
readonly height: number;
|
|
62
|
+
};
|
|
63
|
+
readonly defs: SVGDefsElement;
|
|
64
|
+
readonly ctx: StageContext;
|
|
65
|
+
readonly base: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Masks an element: CSS's mask-image (a picture's alpha, a gradient) or
|
|
69
|
+
* clip-path (an ellipse) where that is all it asks, else an SVG mask (a
|
|
70
|
+
* path, a picture's luminance, its density, feather and inversion). An
|
|
71
|
+
* error message where it cannot be drawn.
|
|
72
|
+
*/
|
|
73
|
+
export declare function applyMask(el: HTMLElement, o: MaskInput): string | undefined;
|
|
74
|
+
/** The CSS transform that turns and flips an element about a box's centre; undefined when it does neither. */
|
|
75
|
+
export declare function transformCss(t: LayerTransform | undefined, box: PxBox): string | undefined;
|
|
76
|
+
export interface StyleInput {
|
|
77
|
+
readonly layer: GraphicLayer;
|
|
78
|
+
readonly ctx: StageContext;
|
|
79
|
+
readonly frame: {
|
|
80
|
+
readonly width: number;
|
|
81
|
+
readonly height: number;
|
|
82
|
+
};
|
|
83
|
+
/** The folder its paths are from. */
|
|
84
|
+
readonly base: string;
|
|
85
|
+
}
|
|
86
|
+
/** The folder a layer's paths are from: its module's, where its function knew it. */
|
|
87
|
+
export declare const baseOf: (layer: GraphicLayer) => string;
|
|
88
|
+
/** The class of a layer's content element: what moves, turns and is masked with it, under its effects and its clipping. */
|
|
89
|
+
export declare const LAYER_CONTENT = "ak-content";
|
|
90
|
+
/**
|
|
91
|
+
* A layer's element made ready for its style before its content mounts:
|
|
92
|
+
* where it is masked, turned, flipped or clipped, an element of its own
|
|
93
|
+
* inside it, which its content mounts in, holds its mask and its turn (and
|
|
94
|
+
* a person's move: what moves with the layer), and the layer's element its
|
|
95
|
+
* effects, blend, opacity and clipping, which Photoshop draws after them.
|
|
96
|
+
* The element to mount its content in.
|
|
97
|
+
*/
|
|
98
|
+
export declare function contentOf(el: HTMLElement, layer: GraphicLayer, frame: {
|
|
99
|
+
width: number;
|
|
100
|
+
height: number;
|
|
101
|
+
}): HTMLElement;
|
|
102
|
+
/** Where a layer's content is: its content element where it has one, else itself. */
|
|
103
|
+
export declare const contentEl: (el: HTMLElement) => HTMLElement;
|
|
104
|
+
/** Whether a layer, or a layer in it, is an adjustment: what lies under it in its group must be a backdrop root's. */
|
|
105
|
+
export declare function holdsAdjustment(layer: GraphicLayer): boolean;
|
|
106
|
+
/** Makes an element the root what an adjustment in it reads stops at (CSS's backdrop root), changing nothing it draws. */
|
|
107
|
+
export declare function backdropRoot(el: HTMLElement): void;
|
|
108
|
+
/**
|
|
109
|
+
* Draws a layer's style on its element (its content mounted): blend,
|
|
110
|
+
* opacity, fill opacity and effects, mask; and for a group, its isolation.
|
|
111
|
+
* A picture masks its own box (picture()). Undefined, or why it cannot be
|
|
112
|
+
* drawn.
|
|
113
|
+
*/
|
|
114
|
+
export declare function styleLayer(el: HTMLElement, o: StyleInput): string | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* The SVG mask of a clipping base's own shape (Photoshop's clipping mask):
|
|
117
|
+
* a picture's shown pixels, a shape's path, a fill's frame. Its id, or why
|
|
118
|
+
* this base cannot clip.
|
|
119
|
+
*/
|
|
120
|
+
export declare function silhouetteOf(base: GraphicLayer, o: {
|
|
121
|
+
frame: {
|
|
122
|
+
width: number;
|
|
123
|
+
height: number;
|
|
124
|
+
};
|
|
125
|
+
defs: SVGDefsElement;
|
|
126
|
+
ctx: StageContext;
|
|
127
|
+
}): {
|
|
128
|
+
id: string;
|
|
129
|
+
} | {
|
|
130
|
+
refused: string;
|
|
131
|
+
};
|
|
132
|
+
/** A layer's element among its siblings, with its spec. */
|
|
133
|
+
export interface Stacked {
|
|
134
|
+
readonly layer: GraphicLayer;
|
|
135
|
+
readonly el: HTMLElement;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Puts clipped layers with their base (Photoshop's clipping groups): each
|
|
139
|
+
* base and the clipped layers over it in an element of their own, isolated
|
|
140
|
+
* with the base's blend and opacity, each clipped layer masked by the
|
|
141
|
+
* base's shape. The layers' elements are siblings, back to front, in their
|
|
142
|
+
* parent. What could not be clipped, each with why.
|
|
143
|
+
*/
|
|
144
|
+
export declare function clipStack(stacked: readonly Stacked[], o: {
|
|
145
|
+
frame: {
|
|
146
|
+
width: number;
|
|
147
|
+
height: number;
|
|
148
|
+
};
|
|
149
|
+
ctx: StageContext;
|
|
150
|
+
}): string[];
|
|
151
|
+
//# sourceMappingURL=layer-style.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
+
import{ADJUSTMENT_DEFAULTS as X,BLEND_DRAWN as _,EFFECT_DEFAULTS as q,LUMA as Z,mediaKindOf as ee,pathIn as te,placePicture as ne,PICTURE_DEFAULTS as se}from"@allyhub/piece";import{strokeOnto as oe}from"./paint.js";import{shapePath as ie}from"./shape-path.js";import{brightnessContrastTable as re,colorBalanceTable as I,compose as B,curveTable as E,exposureTable as ae,gradientTables as ce,identity as R,invertTable as le,levelsTable as D,lightnessTable as de,rgbOf as L,stopsOf as pe,tableValues as P,thresholdTable as ue}from"./tone.js";const fe="http://www.w3.org/2000/svg",W=new WeakMap;export function nextId(t,n){const e=(W.get(t)??0)+1;return W.set(t,e),`ak-${n}-${String(e)}`}function k(t,n,e={},o=[]){const s=t.createElementNS(fe,n);for(const[r,i]of Object.entries(e))s.setAttribute(r,String(i));for(const r of o)s.append(r);return s}export function defsOf(t){const n=t.closest("[data-ak-board]")??t.closest(".ak-part")?.parentElement??t.ownerDocument.body,o=n.querySelector(":scope > svg[data-ak-defs]")?.querySelector("defs");if(o)return o;const s=t.ownerDocument,r=k(s,"svg",{width:0,height:0,"aria-hidden":"true","data-ak-defs":""});r.style.position="absolute",r.style.overflow="hidden";const i=k(s,"defs");return r.append(i),n.prepend(r),i}const a=t=>String(Math.round(t*1e4)/1e4);export function boxOf(t,n){const e=t.props.box;if(Array.isArray(e)&&e.length===4&&e.every(o=>typeof o=="number"&&Number.isFinite(o))){const[o,s,r,i]=e;return[o*n.width,s*n.height,r*n.width,i*n.height]}return[0,0,n.width,n.height]}export function mediaOfRef(t,n,e){if(typeof t!="string"){const s=e.asset(`/${t.path}`);return s.sha256===t.sha256?s:t}const o=te(n,t);return e.asset(o===void 0?t:`/${o}`)}export const maskIsPath=t=>t!=="ellipse"&&ee(t)==="image"&&!t.includes("(");function V(t,n){const e=new Image;e.decoding="sync",e.src=t,n.wait(e.decode().catch(()=>{n.report?.({code:"AK-A005",message:`The picture ${t} a layer's mask, pattern or clipping draws did not load.`})}))}class he{k=0;doc;el;constructor(n,e){this.doc=n,this.el=e}add(n,e,o=[]){const s=`r${String(++this.k)}`;return this.el.append(k(this.doc,n,{...e,result:s},o)),s}transfer(n,e){const o=["R","G","B","A"].flatMap(s=>{const r=e[s];return r?[k(this.doc,`feFunc${s}`,r)]:[]});return this.add("feComponentTransfer",{in:n},o)}tables(n,e,o,s,r="table"){return this.transfer(n,{R:{type:r,tableValues:P(e)},G:{type:r,tableValues:P(o)},B:{type:r,tableValues:P(s)}})}matrix(n,e){return this.add("feColorMatrix",{in:n,type:"matrix",values:e.map(a).join(" ")})}arith(n,e,o,s,r,i=0){return this.add("feComposite",{in:n,in2:e,operator:"arithmetic",k1:a(o),k2:a(s),k3:a(r),k4:a(i)})}composite(n,e,o){return this.add("feComposite",{in:n,in2:e,operator:o})}blend(n,e,o){const s=_[o];return this.add("feBlend",{in:n,in2:e,mode:"css"in s?s.css:"normal"})}flood(n,e){return this.add("feFlood",{"flood-color":n,"flood-opacity":a(e)})}blur(n,e){return e<=0?n:this.add("feGaussianBlur",{in:n,stdDeviation:a(e)})}offset(n,e,o){return e===0&&o===0?n:this.add("feOffset",{in:n,dx:a(e),dy:a(o)})}merge(n){return this.add("feMerge",{},n.map(e=>k(this.doc,"feMergeNode",{in:e})))}sub(n,e){const o={type:"table",tableValues:"1 0"},s=this.transfer(n,{R:o,G:o,B:o}),r=this.arith(s,e,0,1,1);return this.transfer(r,{R:o,G:o,B:o})}add2(n,e,o=1){return this.arith(n,e,0,1,o)}luma(n){const[e,o,s]=Z;return this.matrix(n,[e,o,s,0,0,e,o,s,0,0,e,o,s,0,0,0,0,0,1,0])}channel(n,e){const o=[0,0,0,0,0];return o[e]=1,this.matrix(n,[...o,...o,...o,0,0,0,1,0])}}function H(t,n,e){const o=t.ownerDocument,s=nextId(o,n),r=k(o,"filter",{id:s,"color-interpolation-filters":"sRGB",...e?{filterUnits:"userSpaceOnUse",x:a(e[0]),y:a(e[1]),width:a(e[2]),height:a(e[3])}:{}});return t.append(r),new he(o,r)}function U(t,n="SourceGraphic"){return t.matrix(n,[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1])}function K(t,n,e){const o=t.luma(n),s=t.luma(e),r=t.sub(o,s),i=t.sub(s,o);return t.sub(t.add2(e,r),i)}export function adjustmentFilter(t,n){const e=H(n,"adjust"),o=X;switch(t.kind){case"levels":{const s=D(t.rgb);e.tables("SourceGraphic",B(s,D(t.red)),B(s,D(t.green)),B(s,D(t.blue)));break}case"curves":{const s=E(t.rgb);e.tables("SourceGraphic",B(s,E(t.red)),B(s,E(t.green)),B(s,E(t.blue)));break}case"brightnessContrast":{const s=re(t.brightness??o.brightnessContrast.brightness,t.contrast??o.brightnessContrast.contrast);e.tables("SourceGraphic",s,s,s);break}case"exposure":{const s=ae(t.exposure??o.exposure.exposure,t.offset??o.exposure.offset,t.gammaCorrection??o.exposure.gammaCorrection);e.tables("SourceGraphic",s,s,s);break}case"invert":{const s=le();e.tables("SourceGraphic",s,s,s);break}case"threshold":{const s=e.luma("SourceGraphic"),r=ue(t.level??o.threshold.level);e.tables(s,r,r,r,"discrete");break}case"gradientMap":{const s=e.luma("SourceGraphic"),r=ce(t.gradient??{stops:[...o.gradientMap.gradient.stops]},t.reverse??!1),[i,p,w]=r??[R(),R(),R()];e.tables(s,i,p,w);break}case"hueSaturation":{let s="SourceGraphic";const r=t.hue??0;r!==0&&(s=e.add("feColorMatrix",{in:s,type:"hueRotate",values:a(r)}));const i=t.saturation??0;i!==0&&(s=e.add("feColorMatrix",{in:s,type:"saturate",values:a(1+i/100)}));const p=de(t.lightness??0);e.tables(s,p,p,p);break}case"vibrance":{let s="SourceGraphic";const r=t.saturation??0;r!==0&&(s=e.add("feColorMatrix",{in:s,type:"saturate",values:a(1+r/100)}));const i=(t.vibrance??0)/100;if(i!==0){const p=U(e,s),w=e.channel(p,0),h=e.channel(p,1),x=e.channel(p,2),y=e.add("feBlend",{in:e.add("feBlend",{in:w,in2:h,mode:"lighten"}),in2:x,mode:"lighten"}),l=e.add("feBlend",{in:e.add("feBlend",{in:w,in2:h,mode:"darken"}),in2:x,mode:"darken"}),b=e.sub(y,l),g={type:"table",tableValues:"1 0"},c=e.transfer(b,{R:g,G:g,B:g}),d=e.luma(p),f=e.arith(c,e.sub(p,d),1,0,0),u=e.arith(c,e.sub(d,p),1,0,0),m={type:"linear",slope:a(Math.abs(i))},S=e.transfer(f,{R:m,G:m,B:m}),M=e.transfer(u,{R:m,G:m,B:m}),[v,O]=i>0?[S,M]:[M,S],G=e.sub(e.add2(p,v),O);e.composite(G,"SourceGraphic","in")}break}case"colorBalance":{const s=t.shadows??[0,0,0],r=t.midtones??[0,0,0],i=t.highlights??[0,0,0],p=U(e),w=e.tables(p,I(s[0],r[0],i[0]),I(s[1],r[1],i[1]),I(s[2],r[2],i[2])),h=t.preserveLuminosity??o.colorBalance.preserveLuminosity?K(e,p,w):w;e.composite(h,"SourceGraphic","in");break}case"photoFilter":{const s=L(t.color??o.photoFilter.color)??[1,1,1,1],r=(t.density??o.photoFilter.density)/100,i=U(e),p=x=>1-r+r*s[x],w=e.matrix(i,[p(0),0,0,0,0,0,p(1),0,0,0,0,0,p(2),0,0,0,0,0,0,1]),h=t.preserveLuminosity??o.photoFilter.preserveLuminosity?K(e,i,w):w;e.composite(h,"SourceGraphic","in");break}case"blackAndWhite":{const s=o.blackAndWhite,r={r:(t.reds??s.reds)/100,y:(t.yellows??s.yellows)/100,g:(t.greens??s.greens)/100,c:(t.cyans??s.cyans)/100,b:(t.blues??s.blues)/100,m:(t.magentas??s.magentas)/100},i=U(e),p=(f,u)=>{const m=[0,0,0,0,0];m[f]=1,m[u]=-1,m[4]=1;const S=e.matrix(i,[...m,...m,...m,0,0,0,1,0]),M=R().map((v,O)=>O>=255?1:0);return e.tables(S,M,M,M,"discrete")},w=p(0,1),h=p(1,2),x=p(0,2),y=f=>{const u={type:"table",tableValues:"1 0"};return e.transfer(f,{R:u,G:u,B:u})},l=(f,u)=>e.arith(f,u,1,0,0),b=(f,u,m,S,M)=>{const v=[0,0,0];v[f]=S,v[u]=M-S,v[m]=1-M;const O=[v[0]??0,v[1]??0,v[2]??0,0,0];return e.matrix(i,[...O,...O,...O,0,0,0,1,0])},g=[[l(w,h),b(0,1,2,r.r,r.y)],[l(x,y(h)),b(0,2,1,r.r,r.m)],[l(y(w),x),b(1,0,2,r.g,r.y)],[l(h,y(x)),b(1,2,0,r.g,r.c)],[l(y(h),y(w)),b(2,1,0,r.b,r.c)],[l(y(x),w),b(2,0,1,r.b,r.m)]];let c,d;for(const[f,u]of g){const m=d===void 0?f:l(f,y(d)),S=e.arith(m,u,1,0,0);c=c===void 0?S:e.add2(c,S),d=d===void 0?f:e.add2(d,f)}e.composite(c??i,"SourceGraphic","in");break}}return e.el.childElementCount===0&&e.offset("SourceGraphic",0,1e-4),e.el.id}const z=t=>t*Math.PI/180,N=(t,n)=>[-Math.cos(z(t))*n,Math.sin(z(t))*n];function F(t,n,e){if(e<=0)return n;const o=e>=100?1e4:1/(1-e/100);return t.transfer(n,{A:{type:"linear",slope:a(o)}})}function j(t,n){return t.transfer(n,{A:{type:"table",tableValues:"1 0"}})}function me(t,n,e){const o=t.ownerDocument,s=nextId(o,"gradient"),r=svgGradient(o,s,n,e);t.append(r);const i=k(o,"rect",{id:`${s}-r`,x:a(e[0]),y:a(e[1]),width:a(e[2]),height:a(e[3]),fill:`url(#${s})`});return t.append(i),`#${s}-r`}export function svgGradient(t,n,e,o){const s=e.style??"linear",r=pe(e),[i,p,w,h]=o,x=i+w/2,y=p+h/2,l=(e.scale??100)/100,b=m=>m.map(S=>k(t,"stop",{offset:`${a(S.location)}%`,"stop-color":S.color}));if(s==="radial"){const m=Math.hypot(w,h)/2*l;return k(t,"radialGradient",{id:n,gradientUnits:"userSpaceOnUse",cx:a(x),cy:a(y),r:a(m)},b(r))}const g=z(e.angle??90),c=(Math.abs(Math.cos(g))*w+Math.abs(Math.sin(g))*h)/2*l,d=Math.cos(g)*c,f=-Math.sin(g)*c,u=s==="reflected"?[...r.map(m=>({color:m.color,location:50-m.location/2})).reverse(),...r.map(m=>({color:m.color,location:50+m.location/2}))]:r;return k(t,"linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:a(x-d),y1:a(y-f),x2:a(x+d),y2:a(y+f)},b(u))}export function effectsFilter(t){const{fx:n,frame:e}=t,o=c=>c!==void 0&&c.enabled!==!1,s=e.width,r=e.height,i=H(t.defs,"fx",[-s,-r,3*s,3*r]),p="SourceAlpha",w=t.fillOpacity/100,h=w<1?i.transfer("SourceGraphic",{A:{type:"linear",slope:a(w)}}):"SourceGraphic",x=[],y=(c,d)=>(c??d)/100,l=q;if(o(n.dropShadow)){const c=n.dropShadow,d=F(i,i.blur(p,(c.size??l.dropShadow.size)/2),c.spread??l.dropShadow.spread),[f,u]=N(c.angle??l.dropShadow.angle,c.distance??l.dropShadow.distance),m=i.composite(i.flood(c.color??l.dropShadow.color,y(c.opacity,l.dropShadow.opacity)),i.offset(d,f,u),"in");x.push(i.composite(m,p,"out"))}if(o(n.outerGlow)){const c=n.outerGlow,d=F(i,i.blur(p,(c.size??l.outerGlow.size)/2),c.spread??l.outerGlow.spread),f=i.composite(i.flood(c.color??l.outerGlow.color,y(c.opacity,l.outerGlow.opacity)),d,"in");x.push(i.composite(f,p,"out"))}let b=h;const g=(c,d)=>{b=i.blend(i.composite(c,p,"in"),b,d)};if(o(n.patternOverlay)){const c=n.patternOverlay,d=mediaOfRef(c.pattern,t.base,t.ctx);if(d){V(d.url,t.ctx);const f=(c.scale??l.patternOverlay.scale)/100,u=(d.width??1)*f,m=(d.height??1)*f,S=i.add("feImage",{href:d.url,x:0,y:0,width:a(u),height:a(m),preserveAspectRatio:"none"}),M=i.add("feTile",{in:S}),v=i.transfer(M,{A:{type:"linear",slope:a(y(c.opacity,l.patternOverlay.opacity))}});g(v,c.blendMode??l.patternOverlay.blendMode)}}if(o(n.gradientOverlay)){const c=n.gradientOverlay,d=l.gradientOverlay.gradient,f=me(t.defs,c.gradient??{...d,stops:d.stops.map(S=>({...S}))},t.box),u=i.add("feImage",{href:f,x:0,y:0,width:s,height:r}),m=i.transfer(u,{A:{type:"linear",slope:a(y(c.opacity,l.gradientOverlay.opacity))}});g(m,c.blendMode??l.gradientOverlay.blendMode)}if(o(n.colorOverlay)){const c=n.colorOverlay;g(i.flood(c.color??l.colorOverlay.color,y(c.opacity,l.colorOverlay.opacity)),c.blendMode??l.colorOverlay.blendMode)}if(o(n.satin)){const c=n.satin,d=(c.size??l.satin.size)/2,[f,u]=N(c.angle??l.satin.angle,c.distance??l.satin.distance),m=i.blur(i.offset(p,f,u),d),S=i.blur(i.offset(p,-f,-u),d),M=i.arith(i.arith(m,S,0,1,-1),i.arith(S,m,0,1,-1),0,1,1),v=c.invert??l.satin.invert?j(i,M):M;g(i.composite(i.flood(c.color??l.satin.color,y(c.opacity,l.satin.opacity)),v,"in"),c.blendMode??l.satin.blendMode)}if(o(n.innerGlow)){const c=n.innerGlow,d=(c.size??l.innerGlow.size)/2,u=(c.source??l.innerGlow.source)==="edge"?i.blur(j(i,p),d):j(i,i.blur(j(i,p),d)),m=F(i,u,c.choke??l.innerGlow.choke);g(i.composite(i.flood(c.color??l.innerGlow.color,y(c.opacity,l.innerGlow.opacity)),m,"in"),c.blendMode??l.innerGlow.blendMode)}if(o(n.innerShadow)){const c=n.innerShadow,[d,f]=N(c.angle??l.innerShadow.angle,c.distance??l.innerShadow.distance),u=F(i,i.offset(i.blur(j(i,p),(c.size??l.innerShadow.size)/2),d,f),c.choke??l.innerShadow.choke);g(i.composite(i.flood(c.color??l.innerShadow.color,y(c.opacity,l.innerShadow.opacity)),u,"in"),c.blendMode??l.innerShadow.blendMode)}if(o(n.bevelEmboss)){const c=n.bevelEmboss,d=l.bevelEmboss,f=c.size??d.size,u=i.blur(p,f/2),m=Math.min(c.altitude??d.altitude,89.9),S=(c.direction??d.direction)==="up",M=(360-(c.angle??d.angle)+(S?0:180))%360,v=i.blur(i.add("feDiffuseLighting",{in:u,surfaceScale:a(f*(c.depth??d.depth)/100),diffuseConstant:1,"lighting-color":"#ffffff"},[k(i.doc,"feDistantLight",{azimuth:a(M),elevation:a(m)})]),(c.soften??d.soften)/2),O=Math.sin(z(m)),G=L(c.highlightColor??d.highlightColor)??[1,1,1,1],$=L(c.shadowColor??d.shadowColor)??[0,0,0,1],A=y(c.highlightOpacity,d.highlightOpacity)*G[3],T=y(c.shadowOpacity,d.shadowOpacity)*$[3],C=i.matrix(v,[0,0,0,0,G[0],0,0,0,0,G[1],0,0,0,0,G[2],A/(1-O),0,0,0,-O*A/(1-O)]),Q=i.matrix(v,[0,0,0,0,$[0],0,0,0,0,$[1],0,0,0,0,$[2],-T/O,0,0,0,T]);g(Q,c.shadowMode??d.shadowMode),g(C,c.highlightMode??d.highlightMode)}if(x.length===0&&b==="SourceGraphic"){i.el.remove();return}return i.merge([...x,b]),i.el.id}function ye(t){return typeof t=="string"||!("src"in t||"path"in t||"box"in t||"mode"in t||"density"in t||"feather"in t||"invert"in t||"enabled"in t)?{src:t}:t}export function applyMask(t,n){const e=ye(n.mask);if(e.enabled===!1)return;const o=n.frame.width,s=n.frame.height,r=e.box?[e.box[0]*o,e.box[1]*s,e.box[2]*o,e.box[3]*s]:n.box,[i,p,w,h]=r,x=(e.density??100)/100,y=e.feather??0,l=e.invert===!0,b=e.mode==="luminance",g=e.src,c=typeof g=="string"&&g!=="ellipse"&&!maskIsPath(g),d=x===1&&y===0&&!l&&!b;if(c){if(y>0)return"a CSS mask-image is feathered by its own stops, not by feather";const $=[g],A=[];l&&($.unshift("linear-gradient(black, black)"),A.push("exclude")),x<1&&($.unshift(`linear-gradient(rgb(0 0 0 / ${a(1-x)}), rgb(0 0 0 / ${a(1-x)}))`),A.unshift("add")),Object.assign(t.style,{maskImage:$.join(", "),maskMode:$.map((T,C)=>C===$.length-1&&b?"luminance":"alpha").join(", "),maskRepeat:"no-repeat",maskPosition:$.map((T,C)=>C===$.length-1?`${a(i)}px ${a(p)}px`:"0px 0px").join(", "),maskSize:$.map((T,C)=>C===$.length-1?`${a(w)}px ${a(h)}px`:"100% 100%").join(", "),...A.length>0?{maskComposite:[...A,"add"].join(", ")}:{}});return}if(d&&g==="ellipse"){t.style.clipPath=`ellipse(${a(w/2)}px ${a(h/2)}px at ${a(i+w/2)}px ${a(p+h/2)}px)`;return}const f=g!==void 0&&g!=="ellipse"?mediaOfRef(g,n.base,n.ctx):void 0;if(d&&f&&e.path===void 0){Object.assign(t.style,{maskImage:`url("${f.url}")`,maskSize:`${a(w)}px ${a(h)}px`,maskPosition:`${a(i)}px ${a(p)}px`,maskRepeat:"no-repeat"});return}const u=t.ownerDocument,m=nextId(u,"mask"),S=[k(u,"rect",{x:0,y:0,width:a(o),height:a(s),fill:"black"})];if(e.path!==void 0)S.push(k(u,"path",{d:e.path,fill:"white"}));else if(g==="ellipse")S.push(k(u,"ellipse",{cx:a(i+w/2),cy:a(p+h/2),rx:a(w/2),ry:a(h/2),fill:"white"}));else if(f){V(f.url,n.ctx);const $=nextId(u,"white");b||n.defs.append(k(u,"filter",{id:$,"color-interpolation-filters":"sRGB"},[k(u,"feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"})])),S.push(k(u,"image",{href:f.url,x:a(i),y:a(p),width:a(w),height:a(h),preserveAspectRatio:"none",...b?{}:{filter:`url(#${$})`}}))}else return'a mask has a src (a picture, "ellipse" or a CSS mask-image) or a path';const M=nextId(u,"maskfx"),v=[];y>0&&v.push(k(u,"feGaussianBlur",{stdDeviation:a(y)}));const O=$=>k(u,"feComponentTransfer",{},["R","G","B"].map(A=>k(u,`feFunc${A}`,$)));l&&v.push(O({type:"table",tableValues:"1 0"})),x<1&&v.push(O({type:"linear",slope:a(x),intercept:a(1-x)}));const G=k(u,"g",{},S);v.length>0&&(n.defs.append(k(u,"filter",{id:M,filterUnits:"userSpaceOnUse",x:0,y:0,width:a(o),height:a(s),"color-interpolation-filters":"sRGB"},v)),G.setAttribute("filter",`url(#${M})`)),n.defs.append(k(u,"mask",{id:m,maskUnits:"userSpaceOnUse",x:0,y:0,width:a(o),height:a(s),style:"mask-type: luminance"},[G])),t.style.maskImage=`url(#${m})`}export function transformCss(t,n){if(!t)return;const e=t.rotation??0,o=t.flipH===!0?-1:1,s=t.flipV===!0?-1:1;if(e===0&&o===1&&s===1)return;const r=n[0]+n[2]/2,i=n[1]+n[3]/2;return`translate(${a(r)}px, ${a(i)}px) rotate(${a(e)}deg) scale(${String(o)}, ${String(s)}) translate(${a(-r)}px, ${a(-i)}px)`}export const baseOf=t=>{const n=t.props.base;return typeof n=="string"?n:""},LAYER_CONTENT="ak-content";export function contentOf(t,n,e){const o=transformCss(n.transform,boxOf(n,e)),s=n.mask!==void 0&&n.kind!=="pixel";if(n.kind==="adjustment"||o===void 0&&!s&&n.clipping!==!0)return t;const r=t.ownerDocument.createElement("div");return r.className=LAYER_CONTENT,Object.assign(r.style,{position:"absolute",inset:"0"}),o!==void 0&&Object.assign(r.style,{transform:o,transformOrigin:"0 0"}),t.append(r),r}export const contentEl=t=>t.querySelector(`:scope > .${LAYER_CONTENT}`)??t;export function holdsAdjustment(t){if(t.kind==="adjustment")return!0;const n=t.props.layers;return Array.isArray(n)&&n.some(e=>holdsAdjustment(e))}export function backdropRoot(t){t.style.filter===""&&(t.style.filter="opacity(1)")}export function styleLayer(t,n){const e=n.layer,o=e.kind==="group",s=e.blendMode??(o?"passThrough":"normal"),r=_[s];if("refused"in r)return`blendMode ${s} ${r.refused}`;const i=(e.opacity??100)/100,p=e.fillOpacity??100,w=e.effects,h=J(w);if(o&&s==="passThrough"){const l=i<1||p<100||h||e.mask!==void 0;if(l&&Y(e))return"a passThrough group that fades, is masked or has effects, holding an adjustment or a layer of another blend mode: Chrome draws a group's opacity, mask and effects on its own picture, which its layers would then no longer blend through";l&&(t.style.isolation="isolate")}else o&&(t.style.isolation="isolate",holdsAdjustment(e)&&backdropRoot(t));s!=="normal"&&s!=="passThrough"&&(e.kind!=="pixel"||J(e.effects))&&(t.style.mixBlendMode=r.css);const x=()=>defsOf(t),y=w?.stroke;if(y&&y.enabled!==!1){const l=q.stroke,b=y.size??l.size,g=y.position??l.position,c=y.color??l.color,d=(y.opacity??l.opacity)/100;if(e.kind==="type")for(const f of t.querySelectorAll("[data-ak-text]"))f.style.setProperty("-webkit-text-stroke",`${a(g==="outside"?b*2:b)}px ${d<1?`color-mix(in srgb, ${c} ${a(d*100)}%, transparent)`:c}`),g==="outside"&&f.style.setProperty("paint-order","stroke fill");else if(e.kind==="shape")for(const f of t.querySelectorAll("svg[data-ak-shape]")){const u=f.querySelector("path")?.getAttribute("d");u&&oe(f,u,{color:c,width:b,alignment:g,opacity:d*100,join:"round",cap:"round"},n.frame)}}if(h){const l=effectsFilter({fx:w,fillOpacity:p,box:boxOf(e,n.frame),frame:n.frame,defs:x(),ctx:n.ctx,base:n.base});l!==void 0&&(t.style.filter=`url(#${l})`),i<1&&(t.style.opacity=a(i))}else{const l=i*(p/100);l<1&&(t.style.opacity=a(l))}if(e.mask!==void 0&&e.kind!=="pixel"){const l=applyMask(contentEl(t),{mask:e.mask,box:boxOf(e,n.frame),frame:n.frame,defs:x(),ctx:n.ctx,base:n.base});if(l!==void 0)return l}}function J(t){return t!==void 0&&Object.values(t).some(n=>n!==void 0&&n.enabled!==!1)}function Y(t){const n=t.props.layers;return Array.isArray(n)?n.some(e=>{const o=e;return o.kind==="adjustment"||o.blendMode!==void 0&&o.blendMode!=="normal"&&o.blendMode!=="passThrough"||o.kind==="group"&&(o.blendMode??"passThrough")==="passThrough"&&Y(o)}):!1}export function silhouetteOf(t,n){const e=n.defs.ownerDocument,o=n.frame.width,s=n.frame.height,r=t.props;if(t.mask!==void 0)return{refused:"a clipping base with a mask of its own: not drawn yet"};if(t.transform!==void 0)return{refused:"a clipping base turned or flipped: not drawn yet"};const i=[];if(t.kind==="pixel"){if(r.filter!==void 0||r.radius!==void 0)return{refused:"a clipping base picture with a filter or a radius: its shape is then Chrome's drawing, which a mask cannot read"};const w=r.src,h=w===void 0?void 0:mediaOfRef(w,baseOf(t),n.ctx);if(!h)return{refused:"the clipping base's picture does not load"};V(h.url,n.ctx);const[x,y,l,b]=boxOf(t,n.frame),g=ne({source:{width:h.width??1,height:h.height??1},box:{width:l,height:b},fit:r.fit,position:r.position??se.position,crop:r.crop}),c=nextId(e,"clip"),[d,f,u,m]=g.shown;n.defs.append(k(e,"clipPath",{id:c,clipPathUnits:"userSpaceOnUse"},[k(e,"rect",{x:a(x+d),y:a(y+f),width:a(u),height:a(m)})]));const S=nextId(e,"white");n.defs.append(k(e,"filter",{id:S,"color-interpolation-filters":"sRGB"},[k(e,"feColorMatrix",{type:"matrix",values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"})]));const[M,v,O,G]=g.whole;i.push(k(e,"g",{"clip-path":`url(#${c})`},[k(e,"image",{href:h.url,x:a(x+M),y:a(y+v),width:a(O),height:a(G),preserveAspectRatio:"none",filter:`url(#${S})`})]))}else if(t.kind==="shape"){const w=ie(r,n.frame);if(w==="")return{refused:"the clipping base shape has no path"};const h=r.stroke,x=h?h.width??1:0,y=h?.alignment??"center";i.push(k(e,"path",{d:w,fill:r.fill===null||r.shape==="line"?"none":"white",...x>0&&y!=="inside"?{stroke:"white","stroke-width":a(y==="center"?x:x*2)}:{}}))}else if(t.kind==="fill")i.push(k(e,"rect",{x:0,y:0,width:a(o),height:a(s),fill:"white"}));else return{refused:`a ${t.kind??"component"} layer as a clipping base: its pixels are Chrome's drawing of HTML, which a mask cannot read (an SVG mask's foreignObject draws nothing); clip to a picture, a shape or a fill`};const p=nextId(e,"base");return n.defs.append(k(e,"mask",{id:p,maskUnits:"userSpaceOnUse",x:0,y:0,width:a(o),height:a(s),style:"mask-type: luminance"},i)),{id:p}}export function clipStack(t,n){const e=[];for(let o=0;o<t.length;o++){const s=t[o];if(!s||s.layer.clipping===!0){s&&o===0&&e.push(`layer ${s.layer.key??String(o+1)} is clipped with no layer under it`);continue}const r=[];for(let b=o+1;b<t.length&&t[b]?.layer.clipping===!0;b++){const g=t[b];g&&r.push(g)}if(r.length===0)continue;const i=defsOf(s.el),p=silhouetteOf(s.layer,{frame:n.frame,defs:i,ctx:n.ctx});if("refused"in p){e.push(`layer ${r.map(b=>b.layer.key??"?").join(", ")} clipped to ${s.layer.key??"?"}: ${p.refused}`);for(const b of r)b.el.style.display="none";o+=r.length;continue}const h=s.el.ownerDocument.createElement("div");h.className="ak-clip",Object.assign(h.style,{position:"absolute",inset:"0",isolation:"isolate"}),s.el.before(h);const x=s.el.querySelector("[data-ak-picture]");h.style.mixBlendMode=s.el.style.mixBlendMode||(x?.style.mixBlendMode??""),s.el.style.mixBlendMode="",x&&(x.style.mixBlendMode="");const y=(s.layer.opacity??100)/100;y<1&&(h.style.opacity=a(y));const l=(s.layer.fillOpacity??100)/100;s.el.style.opacity=s.el.style.filter===""&&l<1?a(l):"",r.some(b=>holdsAdjustment(b.layer))&&backdropRoot(h),h.append(s.el);for(const b of r){const g=b.el.style.maskImage;b.el.style.maskImage=g===""||g==="none"?`url(#${p.id})`:`${g}, url(#${p.id})`,g!==""&&g!=="none"&&(b.el.style.maskComposite="intersect"),h.append(b.el)}o+=r.length}return e}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Fill, type Gradient, type ShapeStroke, type StageContext } from "@allyhub/piece";
|
|
2
|
+
import { type ShapeGeometry } from "./shape-path.js";
|
|
3
|
+
/** Why a gradient cannot be painted, or undefined. */
|
|
4
|
+
export declare function gradientRefusal(g: Gradient, svgOnly: boolean): string | undefined;
|
|
5
|
+
/** A gradient as a CSS background image over its box: Photoshop's angle (counter-clockwise from left to right) as CSS's (clockwise from the top). */
|
|
6
|
+
export declare function cssGradient(g: Gradient): string;
|
|
7
|
+
/** Paints an element with a fill as CSS backgrounds: what a fill layer draws. */
|
|
8
|
+
export declare function paintCss(el: HTMLElement, fill: Fill, ctx: StageContext, base: string): void;
|
|
9
|
+
/** A shape's options as it draws them. */
|
|
10
|
+
export interface ShapeDrawing extends ShapeGeometry {
|
|
11
|
+
readonly fill?: Fill | null;
|
|
12
|
+
readonly stroke?: ShapeStroke | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Draws a shape into its element as SVG over the frame: its path filled,
|
|
16
|
+
* and stroked about it (center), inside it (twice as wide, cut to it) or
|
|
17
|
+
* outside it (twice as wide, with what is inside it cut away).
|
|
18
|
+
*/
|
|
19
|
+
export declare function drawShape(el: HTMLElement, s: ShapeDrawing, ctx: StageContext, base: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Strokes a path in an SVG: about it (center), inside it (twice as wide,
|
|
22
|
+
* cut to it) or outside it (twice as wide, with what is inside it cut
|
|
23
|
+
* away): a shape's stroke, and the stroke effect of a shape layer.
|
|
24
|
+
*/
|
|
25
|
+
export declare function strokeOnto(root: SVGSVGElement, d: string, st: ShapeStroke, frame: {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}): void;
|
|
29
|
+
//# sourceMappingURL=paint.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
+
import{SHAPE_DEFAULTS as y}from"@allyhub/piece";import{defsOf as $,mediaOfRef as v,nextId as O,svgGradient as j}from"./layer-style.js";import{shapePath as x}from"./shape-path.js";import{stopsOf as A}from"./tone.js";const o=i=>String(Math.round(i*1e4)/1e4);export function gradientRefusal(i,t){const n=i.style??"linear";if(n==="diamond")return"a diamond gradient is no CSS or SVG gradient";if(t&&n==="angle")return"an angle gradient on a shape: SVG paints no conic gradient (a fill layer draws one)"}export function cssGradient(i){const t=i.style??"linear",n=(i.scale??100)/100,f=A(i),a=r=>t==="linear"||t==="reflected"?50+(r-50)*n:r*n,s=(r,e)=>r.flatMap((p,g)=>{const m=r[g+1],h=`${p.color} ${o(e(p.location))}%`;if(!m||(p.midpoint??50)===50)return[h];const u=p.location+(m.location-p.location)*(p.midpoint??50)/100;return[h,`${o(e(u))}%`]}).join(", "),d=90-(i.angle??90);if(t==="radial")return`radial-gradient(farthest-corner at 50% 50%, ${s(f,a)})`;if(t==="angle"){const r=f.map(e=>({...e,location:100-e.location})).reverse();return`conic-gradient(from ${o(d)}deg at 50% 50%, ${s(r,e=>e)})`}if(t==="reflected"){const r=[...f.map(e=>({color:e.color,location:50-e.location/2})).reverse(),...f.map(e=>({color:e.color,location:50+e.location/2}))];return`linear-gradient(${o(d)}deg, ${s(r,a)})`}return`linear-gradient(${o(d)}deg, ${s(f,a)})`}export function paintCss(i,t,n,f){if("color"in t){i.style.background=t.color;return}if("gradient"in t){i.style.backgroundImage=cssGradient(t.gradient);return}const a=v(t.pattern,f,n);if(!a)return;const s=(t.scale??100)/100;Object.assign(i.style,{backgroundImage:`url("${a.url}")`,backgroundSize:`${o((a.width??1)*s)}px ${o((a.height??1)*s)}px`,backgroundRepeat:"repeat",backgroundPosition:"0px 0px"})}const b="http://www.w3.org/2000/svg";function E(i,t,n,f,a){if("color"in t)return t.color;const s=$(i),d=i.ownerDocument,r=O(d,"paint");if("gradient"in t)return s.append(j(d,r,t.gradient,n)),`url(#${r})`;const e=v(t.pattern,a,f);if(!e)return"none";const p=(t.scale??100)/100,g=(e.width??1)*p,m=(e.height??1)*p,h=d.createElementNS(b,"pattern");for(const[c,l]of Object.entries({id:r,patternUnits:"userSpaceOnUse",x:"0",y:"0",width:o(g),height:o(m)}))h.setAttribute(c,l);const u=d.createElementNS(b,"image");for(const[c,l]of Object.entries({href:e.url,x:"0",y:"0",width:o(g),height:o(m),preserveAspectRatio:"none"}))u.setAttribute(c,l);return h.append(u),s.append(h),`url(#${r})`}export function drawShape(i,t,n,f){const a=i.ownerDocument,s=n.dims.width,d=n.dims.height,r=x(t,n.dims),e=a.createElementNS(b,"svg");for(const[c,l]of Object.entries({width:o(s),height:o(d),viewBox:`0 0 ${o(s)} ${o(d)}`}))e.setAttribute(c,l);e.dataset.akShape="",Object.assign(e.style,{position:"absolute",left:"0",top:"0",overflow:"visible"});const p=(()=>{const c=t.box??[0,0,1,1];return[c[0]*s,c[1]*d,c[2]*s,c[3]*d]})();i.append(e);const g=t.fill===void 0?y.fill:t.fill,m=t.shape==="line";g!==null&&!m&&(c=>{const l=a.createElementNS(b,"path");l.setAttribute("d",r);for(const[k,w]of Object.entries(c))l.setAttribute(k,w);return e.append(l),l})({fill:E(i,g,p,n,f),"data-ak-fill":""});const u=t.stroke??(m?{}:null);u!==null&&strokeOnto(e,r,m?{...u,alignment:"center"}:u,n.dims)}export function strokeOnto(i,t,n,f){const a=i.ownerDocument,s=f.width,d=f.height,r=y.stroke,e=n.width??r.width,p=n.alignment??r.alignment,g={d:t,fill:"none",stroke:n.color??r.color,"stroke-width":o(p==="center"?e:e*2),"stroke-linecap":n.cap??r.cap,"stroke-linejoin":n.join??r.join,"data-ak-stroke":""};if((n.opacity??r.opacity)<100&&(g["stroke-opacity"]=o((n.opacity??r.opacity)/100)),n.dashes&&n.dashes.length>0&&(g["stroke-dasharray"]=n.dashes.map(h=>o(h*e)).join(" ")),p!=="center"){const h=$(i),u=O(a,"stroke");if(p==="inside"){const c=a.createElementNS(b,"clipPath");c.id=u;const l=a.createElementNS(b,"path");l.setAttribute("d",t),c.append(l),h.append(c),g["clip-path"]=`url(#${u})`}else{const c=a.createElementNS(b,"mask");c.id=u;const l=a.createElementNS(b,"rect");for(const[w,S]of Object.entries({maskUnits:"userSpaceOnUse",x:o(-s),y:o(-d),width:o(3*s),height:o(3*d)}))c.setAttribute(w,S);for(const[w,S]of Object.entries({x:o(-s),y:o(-d),width:o(3*s),height:o(3*d),fill:"white"}))l.setAttribute(w,S);const k=a.createElementNS(b,"path");k.setAttribute("d",t),k.setAttribute("fill","black"),c.append(l,k),h.append(c),g.mask=`url(#${u})`}}const m=a.createElementNS(b,"path");for(const[h,u]of Object.entries(g))m.setAttribute(h,u);i.append(m)}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** A picture that did not load. */
|
|
2
|
+
export interface BrokenPicture {
|
|
3
|
+
/** The element that draws it: the `<img>`, or the element with the background. */
|
|
4
|
+
el: Element;
|
|
5
|
+
/** The source as written: the `src` attribute, or the background's URL. */
|
|
6
|
+
src: string;
|
|
7
|
+
via: "img" | "background";
|
|
8
|
+
}
|
|
9
|
+
export interface PictureWatch {
|
|
10
|
+
/** Decodes what the stage draws now; what fails is recorded. */
|
|
11
|
+
sweep(): Promise<void>;
|
|
12
|
+
/** What did not load so far, once per element and source. */
|
|
13
|
+
broken(): BrokenPicture[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether a source is the stage's to serve: on its own origin, or inline
|
|
17
|
+
* (data:, blob:). Another origin is the sandbox's (AK-N003).
|
|
18
|
+
*/
|
|
19
|
+
export declare function servedHere(src: string, base: string): boolean;
|
|
20
|
+
/** The URLs of a computed `background-image` (`url("…")`, quoted by the browser). */
|
|
21
|
+
export declare function backgroundUrls(value: string): string[];
|
|
22
|
+
/** What to do about a source that did not load, in one sentence. */
|
|
23
|
+
export declare function pictureHint(src: string): string;
|
|
24
|
+
export declare function watchPictures(stage: HTMLElement): PictureWatch;
|
|
25
|
+
/**
|
|
26
|
+
* Waits until every picture the stage shows now is decoded, so a frame is
|
|
27
|
+
* never taken while a picture is still blank. A layer may change what an
|
|
28
|
+
* `<img>` shows, or an inline background image, as it plays (a captured
|
|
29
|
+
* screen swapped for the next state), and the browser may let a decoded
|
|
30
|
+
* picture go while it is out of sight and decode it again only when it is
|
|
31
|
+
* painted: either way a capture taken before it is ready shows nothing
|
|
32
|
+
* where it goes. So every frame asks each `<img>` that is shown, and each
|
|
33
|
+
* inline background URL, to be decoded (at once when it already is).
|
|
34
|
+
* The returned function waits at most `limitMs` and resolves with the
|
|
35
|
+
* sources still not decoded then; a picture that does not load, at any
|
|
36
|
+
* moment, is given to `broken` (AK-A005).
|
|
37
|
+
*/
|
|
38
|
+
export declare function pictureWaiter(stage: HTMLElement, broken?: (b: BrokenPicture) => void): (limitMs: number) => Promise<string[]>;
|
|
39
|
+
//# sourceMappingURL=pictures.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
+
import{within as m}from"./guards.js";export function servedHere(c,o){let s;try{s=new URL(c,o)}catch{return!0}return s.protocol==="data:"||s.protocol==="blob:"||s.protocol!=="http:"&&s.protocol!=="https:"?!0:s.origin===new URL(o).origin}export function backgroundUrls(c){const o=[],s=/url\(\s*(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'|([^)\s]*))\s*\)/g;for(const u of c.matchAll(s)){const e=(u[1]??u[2]??u[3]??"").replace(/\\(.)/g,"$1");e&&o.push(e)}return o}export function pictureHint(c){const o=c.trim();return o==="[object Object]"?"That is an object turned into text: for an imported media value or ctx.asset(…), use its .url.":o==="undefined"||o==="null"?`The source is ${o}: for an imported media value or ctx.asset(…), use its .url.`:/^[a-z][a-z0-9+.-]*:/i.test(o)?"The file is not there, or it is not a picture the browser can draw.":'A path is not a URL the stage serves: import the file (import logo from "./logo.svg") or use ctx.asset(path), and use its .url.'}const d=c=>c.decode().then(()=>!0,()=>!1);export function watchPictures(c){const o=[],s=()=>document.baseURI,u=(a,e,t)=>{!e||!servedHere(e,s())||o.some(i=>i.el===a&&i.src===e)||o.push({el:a,src:e,via:t})};return c.addEventListener("error",a=>{const e=a.target;e instanceof HTMLImageElement&&u(e,e.getAttribute("src")??"","img")},!0),{async sweep(){const a=Array.from(c.querySelectorAll("img"));await Promise.all(a.map(async t=>{const i=t.getAttribute("src")??"";i&&!await d(t)&&t.complete&&t.naturalWidth===0&&u(t,i,"img")}));const e=new Map;for(const t of Array.from(c.querySelectorAll("*"))){const i=getComputedStyle(t).backgroundImage;if(!i.includes("url("))continue;const r=t instanceof HTMLElement||t instanceof SVGElement?t.style.backgroundImage:"",n=r.includes("url(")?r:i;for(const l of backgroundUrls(n))e.set(l,[...e.get(l)??[],t])}await Promise.all([...e].map(async([t,i])=>{if(!servedHere(t,s()))return;const r=new Image;if(r.src=t,!await d(r))for(const n of i)u(n,t,"background")}))},broken:()=>[...o]}}export function pictureWaiter(c,o){const s=new Map,u=()=>document.baseURI;return async a=>{const e=[],t=[];for(const r of Array.from(c.querySelectorAll("img"))){if(!(r.currentSrc||r.src)||r.getClientRects().length===0)continue;const n=r.getAttribute("src")??r.currentSrc;t.push(n),e.push(r.decode().catch(()=>{r.complete&&r.naturalWidth===0&&servedHere(n,u())&&o?.({el:r,src:n,via:"img"})}))}for(const r of Array.from(c.querySelectorAll('[style*="url("]')))if(r.getClientRects().length!==0)for(const n of backgroundUrls(r.style.backgroundImage)){let l=s.get(n);l||(l=new Image,l.src=n,s.set(n,l)),t.push(n);const f=l;e.push(f.decode().catch(()=>{f.complete&&f.naturalWidth===0&&servedHere(n,u())&&o?.({el:r,src:n,via:"background"})}))}if(e.length===0)return[];const i=await m(e,a);return t.filter((r,n)=>i[n]===void 0)}}
|