@motionscript/core 0.1.0-alpha.5 → 0.1.0-alpha.7
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 +55 -0
- package/README.md +2 -4
- package/dist/assets/errors.js +4 -5
- package/dist/assets/errors.js.map +1 -1
- package/dist/assets/scope.d.ts +1 -1
- package/dist/assets/scope.d.ts.map +1 -1
- package/dist/assets/scope.js +1 -1
- package/dist/assets/scope.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +3 -18
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/index.d.ts +3 -5
- package/dist/attributes/index.d.ts.map +1 -1
- package/dist/attributes/index.js +2 -2
- package/dist/attributes/index.js.map +1 -1
- package/dist/attributes/layout/insets.d.ts +1 -1
- package/dist/attributes/layout/insets.js.map +1 -1
- package/dist/attributes/layout/size.d.ts +1 -1
- package/dist/attributes/layout/size.js +1 -1
- package/dist/attributes/layout/size.js.map +1 -1
- package/dist/attributes/properties/decorator.d.ts +44 -11
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- package/dist/attributes/properties/decorator.js +37 -9
- package/dist/attributes/properties/decorator.js.map +1 -1
- package/dist/attributes/properties/inputs.d.ts +1 -1
- package/dist/attributes/properties/inputs.js +1 -1
- package/dist/attributes/properties/inputs.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +19 -140
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +12 -108
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.d.ts +1 -1
- package/dist/attributes/shape/corners/corner-radius.js +1 -1
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/fill/color/parser.d.ts +1 -1
- package/dist/attributes/shape/fill/color/parser.js +1 -1
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/canvas3d.d.ts +2 -2
- package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.d.ts +2 -2
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/video.d.ts +1 -1
- package/dist/attributes/shape/fill/implementations/video.js +1 -1
- package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
- package/dist/attributes/shape/fill/lerp.d.ts +1 -1
- package/dist/attributes/shape/fill/lerp.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +1 -1
- package/dist/attributes/shape/filters/chain.js +1 -1
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +4 -3
- package/dist/attributes/shape/filters/union.d.ts.map +1 -1
- package/dist/attributes/shape/filters/union.js.map +1 -1
- package/dist/attributes/shape/path/ops.d.ts +1 -2
- package/dist/attributes/shape/path/ops.d.ts.map +1 -1
- package/dist/attributes/shape/path/ops.js.map +1 -1
- package/dist/attributes/shared/operators.d.ts +2 -2
- package/dist/attributes/shared/operators.js.map +1 -1
- package/dist/attributes/text/types.d.ts +2 -3
- package/dist/attributes/text/types.d.ts.map +1 -1
- package/dist/attributes/text/types.js.map +1 -1
- package/dist/browser/chunks/chunk-D4FSTPML.js +14 -0
- package/dist/browser/chunks/chunk-D4FSTPML.js.map +7 -0
- package/dist/browser/chunks/chunk-LKUYVFU3.js +2 -0
- package/dist/browser/chunks/chunk-LKUYVFU3.js.map +7 -0
- package/dist/browser/chunks/chunk-RTNATFWX.js +5 -0
- package/dist/browser/chunks/chunk-RTNATFWX.js.map +7 -0
- package/dist/browser/chunks/chunk-ZRPZPWZU.js +3 -0
- package/dist/browser/chunks/chunk-ZRPZPWZU.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/component.js.map +4 -4
- package/dist/browser/experimental.js +2 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/manifest.json +3 -4
- package/dist/browser/sdk.js +1 -1
- package/dist/component/api.d.ts +508 -0
- package/dist/component/api.d.ts.map +1 -0
- package/dist/component/api.js +4 -0
- package/dist/component/api.js.map +1 -0
- package/dist/component/builtins/audio.d.ts +26 -0
- package/dist/component/builtins/audio.d.ts.map +1 -0
- package/dist/component/builtins/audio.js +41 -0
- package/dist/component/builtins/audio.js.map +1 -0
- package/dist/component/builtins/canvas3d.d.ts +98 -0
- package/dist/component/builtins/canvas3d.d.ts.map +1 -0
- package/dist/component/builtins/canvas3d.js +21 -0
- package/dist/component/builtins/canvas3d.js.map +1 -0
- package/dist/component/builtins/composite.d.ts +56 -0
- package/dist/component/builtins/composite.d.ts.map +1 -0
- package/dist/component/builtins/composite.js +25 -0
- package/dist/component/builtins/composite.js.map +1 -0
- package/dist/component/builtins/geometry.d.ts +505 -0
- package/dist/component/builtins/geometry.d.ts.map +1 -0
- package/dist/component/builtins/geometry.js +107 -0
- package/dist/component/builtins/geometry.js.map +1 -0
- package/dist/component/builtins/layout.d.ts +88 -0
- package/dist/component/builtins/layout.d.ts.map +1 -0
- package/dist/component/builtins/layout.js +84 -0
- package/dist/component/builtins/layout.js.map +1 -0
- package/dist/component/builtins/media.d.ts +95 -0
- package/dist/component/builtins/media.d.ts.map +1 -0
- package/dist/component/builtins/media.js +149 -0
- package/dist/component/builtins/media.js.map +1 -0
- package/dist/component/builtins/providers.d.ts +23 -0
- package/dist/component/builtins/providers.d.ts.map +1 -0
- package/dist/component/builtins/providers.js +30 -0
- package/dist/component/builtins/providers.js.map +1 -0
- package/dist/component/builtins/text.d.ts +193 -0
- package/dist/component/builtins/text.d.ts.map +1 -0
- package/dist/component/builtins/text.js +113 -0
- package/dist/component/builtins/text.js.map +1 -0
- package/dist/component/builtins/three.d.ts +1085 -0
- package/dist/component/builtins/three.d.ts.map +1 -0
- package/dist/component/builtins/three.js +265 -0
- package/dist/component/builtins/three.js.map +1 -0
- package/dist/component/clip-of.d.ts +5 -0
- package/dist/component/clip-of.d.ts.map +1 -0
- package/dist/component/clip-of.js +33 -0
- package/dist/component/clip-of.js.map +1 -0
- package/dist/component/commands-for.d.ts +19 -0
- package/dist/component/commands-for.d.ts.map +1 -0
- package/dist/component/commands-for.js +5 -0
- package/dist/component/commands-for.js.map +1 -0
- package/dist/component/component-audio.d.ts +9 -0
- package/dist/component/component-audio.d.ts.map +1 -0
- package/dist/component/component-audio.js +18 -0
- package/dist/component/component-audio.js.map +1 -0
- package/dist/component/component2d.d.ts +9 -0
- package/dist/component/component2d.d.ts.map +1 -0
- package/dist/component/component2d.js +239 -0
- package/dist/component/component2d.js.map +1 -0
- package/dist/component/component3d.d.ts +9 -0
- package/dist/component/component3d.d.ts.map +1 -0
- package/dist/component/component3d.js +99 -0
- package/dist/component/component3d.js.map +1 -0
- package/dist/component/factory.d.ts +63 -0
- package/dist/component/factory.d.ts.map +1 -0
- package/dist/component/factory.js +313 -0
- package/dist/component/factory.js.map +1 -0
- package/dist/component/modules/aim.d.ts +30 -0
- package/dist/component/modules/aim.d.ts.map +1 -0
- package/dist/component/modules/aim.js +39 -0
- package/dist/component/modules/aim.js.map +1 -0
- package/dist/component/modules/corners.d.ts +13 -0
- package/dist/component/modules/corners.d.ts.map +1 -0
- package/dist/component/modules/corners.js +12 -0
- package/dist/component/modules/corners.js.map +1 -0
- package/dist/component/modules/flow.d.ts +26 -0
- package/dist/component/modules/flow.d.ts.map +1 -0
- package/dist/component/modules/flow.js +55 -0
- package/dist/component/modules/flow.js.map +1 -0
- package/dist/component/modules/material.d.ts +40 -0
- package/dist/component/modules/material.d.ts.map +1 -0
- package/dist/component/modules/material.js +75 -0
- package/dist/component/modules/material.js.map +1 -0
- package/dist/component/modules/paint.d.ts +71 -0
- package/dist/component/modules/paint.d.ts.map +1 -0
- package/dist/component/modules/paint.js +106 -0
- package/dist/component/modules/paint.js.map +1 -0
- package/dist/component/modules/shapes.d.ts +31 -0
- package/dist/component/modules/shapes.d.ts.map +1 -0
- package/dist/component/modules/shapes.js +43 -0
- package/dist/component/modules/shapes.js.map +1 -0
- package/dist/component/modules/text-layout.d.ts +26 -0
- package/dist/component/modules/text-layout.d.ts.map +1 -0
- package/dist/component/modules/text-layout.js +57 -0
- package/dist/component/modules/text-layout.js.map +1 -0
- package/dist/component/modules/text-style.d.ts +48 -0
- package/dist/component/modules/text-style.d.ts.map +1 -0
- package/dist/component/modules/text-style.js +63 -0
- package/dist/component/modules/text-style.js.map +1 -0
- package/dist/component/modules/three-entries.d.ts +23 -0
- package/dist/component/modules/three-entries.d.ts.map +1 -0
- package/dist/component/modules/three-entries.js +41 -0
- package/dist/component/modules/three-entries.js.map +1 -0
- package/dist/component/modules/view3d.d.ts +55 -0
- package/dist/component/modules/view3d.d.ts.map +1 -0
- package/dist/component/modules/view3d.js +160 -0
- package/dist/component/modules/view3d.js.map +1 -0
- package/dist/component/timeline.d.ts +22 -0
- package/dist/component/timeline.d.ts.map +1 -0
- package/dist/component/timeline.js +128 -0
- package/dist/component/timeline.js.map +1 -0
- package/dist/component/type-def.d.ts +26 -0
- package/dist/component/type-def.d.ts.map +1 -0
- package/dist/component/type-def.js +16 -0
- package/dist/component/type-def.js.map +1 -0
- package/dist/component/types.d.ts +91 -0
- package/dist/component/types.d.ts.map +1 -0
- package/dist/component/types.js +88 -0
- package/dist/component/types.js.map +1 -0
- package/dist/component/views.d.ts +121 -0
- package/dist/component/views.d.ts.map +1 -0
- package/dist/component/views.js +413 -0
- package/dist/component/views.js.map +1 -0
- package/dist/component.d.ts +10 -19
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +10 -19
- package/dist/component.js.map +1 -1
- package/dist/components/builtins/audio/audio.d.ts +53 -0
- package/dist/components/builtins/audio/audio.d.ts.map +1 -0
- package/dist/components/builtins/audio/audio.js +41 -0
- package/dist/components/builtins/audio/audio.js.map +1 -0
- package/dist/components/builtins/geometry/composite.d.ts +93 -0
- package/dist/components/builtins/geometry/composite.d.ts.map +1 -0
- package/dist/components/builtins/geometry/composite.js +25 -0
- package/dist/components/builtins/geometry/composite.js.map +1 -0
- package/dist/components/builtins/geometry/geometry.d.ts +921 -0
- package/dist/components/builtins/geometry/geometry.d.ts.map +1 -0
- package/dist/components/builtins/geometry/geometry.js +107 -0
- package/dist/components/builtins/geometry/geometry.js.map +1 -0
- package/dist/components/builtins/geometry/shape-outline.d.ts +93 -0
- package/dist/components/builtins/geometry/shape-outline.d.ts.map +1 -0
- package/dist/components/builtins/geometry/shape-outline.js +470 -0
- package/dist/components/builtins/geometry/shape-outline.js.map +1 -0
- package/dist/components/builtins/layout/layout.d.ts +186 -0
- package/dist/components/builtins/layout/layout.d.ts.map +1 -0
- package/dist/components/builtins/layout/layout.js +84 -0
- package/dist/components/builtins/layout/layout.js.map +1 -0
- package/dist/components/builtins/media/media.d.ts +240 -0
- package/dist/components/builtins/media/media.d.ts.map +1 -0
- package/dist/components/builtins/media/media.js +149 -0
- package/dist/components/builtins/media/media.js.map +1 -0
- package/dist/components/builtins/providers/providers.d.ts +47 -0
- package/dist/components/builtins/providers/providers.d.ts.map +1 -0
- package/dist/components/builtins/providers/providers.js +30 -0
- package/dist/components/builtins/providers/providers.js.map +1 -0
- package/dist/components/builtins/text/number-format.d.ts +66 -0
- package/dist/components/builtins/text/number-format.d.ts.map +1 -0
- package/dist/components/builtins/text/number-format.js +227 -0
- package/dist/components/builtins/text/number-format.js.map +1 -0
- package/dist/components/builtins/text/number-pattern.d.ts +51 -0
- package/dist/components/builtins/text/number-pattern.d.ts.map +1 -0
- package/dist/components/builtins/text/number-pattern.js +77 -0
- package/dist/components/builtins/text/number-pattern.js.map +1 -0
- package/dist/components/builtins/text/text-defaults.d.ts +32 -0
- package/dist/components/builtins/text/text-defaults.d.ts.map +1 -0
- package/dist/components/builtins/text/text-defaults.js +37 -0
- package/dist/components/builtins/text/text-defaults.js.map +1 -0
- package/dist/components/builtins/text/text-layout.d.ts +82 -0
- package/dist/components/builtins/text/text-layout.d.ts.map +1 -0
- package/dist/components/builtins/text/text-layout.js +331 -0
- package/dist/components/builtins/text/text-layout.js.map +1 -0
- package/dist/components/builtins/text/text.d.ts +409 -0
- package/dist/components/builtins/text/text.d.ts.map +1 -0
- package/dist/components/builtins/text/text.js +113 -0
- package/dist/components/builtins/text/text.js.map +1 -0
- package/dist/components/builtins/three/canvas3d.d.ts +245 -0
- package/dist/components/builtins/three/canvas3d.d.ts.map +1 -0
- package/dist/components/builtins/three/canvas3d.js +21 -0
- package/dist/components/builtins/three/canvas3d.js.map +1 -0
- package/dist/components/builtins/three/grid-geometry3d.d.ts +62 -0
- package/dist/components/builtins/three/grid-geometry3d.d.ts.map +1 -0
- package/dist/components/builtins/three/grid-geometry3d.js +114 -0
- package/dist/components/builtins/three/grid-geometry3d.js.map +1 -0
- package/dist/components/builtins/three/three.d.ts +1889 -0
- package/dist/components/builtins/three/three.d.ts.map +1 -0
- package/dist/components/builtins/three/three.js +305 -0
- package/dist/components/builtins/three/three.js.map +1 -0
- package/dist/components/factory/api.d.ts +516 -0
- package/dist/components/factory/api.d.ts.map +1 -0
- package/dist/components/factory/api.js +4 -0
- package/dist/components/factory/api.js.map +1 -0
- package/dist/components/factory/clip-of.d.ts +5 -0
- package/dist/components/factory/clip-of.d.ts.map +1 -0
- package/dist/components/factory/clip-of.js +33 -0
- package/dist/components/factory/clip-of.js.map +1 -0
- package/dist/components/factory/commands-for.d.ts +19 -0
- package/dist/components/factory/commands-for.d.ts.map +1 -0
- package/dist/components/factory/commands-for.js +5 -0
- package/dist/components/factory/commands-for.js.map +1 -0
- package/dist/components/factory/component-audio.d.ts +9 -0
- package/dist/components/factory/component-audio.d.ts.map +1 -0
- package/dist/components/factory/component-audio.js +18 -0
- package/dist/components/factory/component-audio.js.map +1 -0
- package/dist/components/factory/component2d.d.ts +8 -0
- package/dist/components/factory/component2d.d.ts.map +1 -0
- package/dist/components/factory/component2d.js +240 -0
- package/dist/components/factory/component2d.js.map +1 -0
- package/dist/components/factory/component3d.d.ts +9 -0
- package/dist/components/factory/component3d.d.ts.map +1 -0
- package/dist/components/factory/component3d.js +99 -0
- package/dist/components/factory/component3d.js.map +1 -0
- package/dist/components/factory/factory.d.ts +63 -0
- package/dist/components/factory/factory.d.ts.map +1 -0
- package/dist/components/factory/factory.js +313 -0
- package/dist/components/factory/factory.js.map +1 -0
- package/dist/components/factory/timeline.d.ts +22 -0
- package/dist/components/factory/timeline.d.ts.map +1 -0
- package/dist/components/factory/timeline.js +128 -0
- package/dist/components/factory/timeline.js.map +1 -0
- package/dist/components/factory/type-def.d.ts +26 -0
- package/dist/components/factory/type-def.d.ts.map +1 -0
- package/dist/components/factory/type-def.js +16 -0
- package/dist/components/factory/type-def.js.map +1 -0
- package/dist/components/factory/types.d.ts +91 -0
- package/dist/components/factory/types.d.ts.map +1 -0
- package/dist/components/factory/types.js +88 -0
- package/dist/components/factory/types.js.map +1 -0
- package/dist/components/factory/views.d.ts +121 -0
- package/dist/components/factory/views.d.ts.map +1 -0
- package/dist/components/factory/views.js +413 -0
- package/dist/components/factory/views.js.map +1 -0
- package/dist/components/modules/aim.d.ts +30 -0
- package/dist/components/modules/aim.d.ts.map +1 -0
- package/dist/components/modules/aim.js +39 -0
- package/dist/components/modules/aim.js.map +1 -0
- package/dist/components/modules/corners.d.ts +13 -0
- package/dist/components/modules/corners.d.ts.map +1 -0
- package/dist/components/modules/corners.js +12 -0
- package/dist/components/modules/corners.js.map +1 -0
- package/dist/components/modules/flow.d.ts +26 -0
- package/dist/components/modules/flow.d.ts.map +1 -0
- package/dist/components/modules/flow.js +57 -0
- package/dist/components/modules/flow.js.map +1 -0
- package/dist/components/modules/material.d.ts +40 -0
- package/dist/components/modules/material.d.ts.map +1 -0
- package/dist/components/modules/material.js +75 -0
- package/dist/components/modules/material.js.map +1 -0
- package/dist/components/modules/paint.d.ts +71 -0
- package/dist/components/modules/paint.d.ts.map +1 -0
- package/dist/components/modules/paint.js +106 -0
- package/dist/components/modules/paint.js.map +1 -0
- package/dist/components/modules/shapes.d.ts +31 -0
- package/dist/components/modules/shapes.d.ts.map +1 -0
- package/dist/components/modules/shapes.js +43 -0
- package/dist/components/modules/shapes.js.map +1 -0
- package/dist/components/modules/text-layout.d.ts +26 -0
- package/dist/components/modules/text-layout.d.ts.map +1 -0
- package/dist/components/modules/text-layout.js +57 -0
- package/dist/components/modules/text-layout.js.map +1 -0
- package/dist/components/modules/text-style.d.ts +48 -0
- package/dist/components/modules/text-style.d.ts.map +1 -0
- package/dist/components/modules/text-style.js +63 -0
- package/dist/components/modules/text-style.js.map +1 -0
- package/dist/components/modules/three-entries.d.ts +23 -0
- package/dist/components/modules/three-entries.d.ts.map +1 -0
- package/dist/components/modules/three-entries.js +41 -0
- package/dist/components/modules/three-entries.js.map +1 -0
- package/dist/components/modules/view3d.d.ts +59 -0
- package/dist/components/modules/view3d.d.ts.map +1 -0
- package/dist/components/modules/view3d.js +171 -0
- package/dist/components/modules/view3d.js.map +1 -0
- package/dist/components/trees/2d/group-bounds.d.ts +56 -0
- package/dist/components/trees/2d/group-bounds.d.ts.map +1 -0
- package/dist/components/trees/2d/group-bounds.js +87 -0
- package/dist/components/trees/2d/group-bounds.js.map +1 -0
- package/dist/components/trees/2d/node-lifecycle.d.ts +46 -0
- package/dist/components/trees/2d/node-lifecycle.d.ts.map +1 -0
- package/dist/components/trees/2d/node-lifecycle.js +264 -0
- package/dist/components/trees/2d/node-lifecycle.js.map +1 -0
- package/dist/components/trees/2d/node-motion.d.ts +56 -0
- package/dist/components/trees/2d/node-motion.d.ts.map +1 -0
- package/dist/components/trees/2d/node-motion.js +86 -0
- package/dist/components/trees/2d/node-motion.js.map +1 -0
- package/dist/components/trees/2d/node-render.d.ts +36 -0
- package/dist/components/trees/2d/node-render.d.ts.map +1 -0
- package/dist/components/trees/2d/node-render.js +67 -0
- package/dist/components/trees/2d/node-render.js.map +1 -0
- package/dist/components/trees/2d/node-space.d.ts +63 -0
- package/dist/components/trees/2d/node-space.d.ts.map +1 -0
- package/dist/components/trees/2d/node-space.js +131 -0
- package/dist/components/trees/2d/node-space.js.map +1 -0
- package/dist/components/trees/2d/node-transform.d.ts +55 -0
- package/dist/components/trees/2d/node-transform.d.ts.map +1 -0
- package/dist/components/trees/2d/node-transform.js +73 -0
- package/dist/components/trees/2d/node-transform.js.map +1 -0
- package/dist/components/trees/2d/node2d.d.ts +1020 -0
- package/dist/components/trees/2d/node2d.d.ts.map +1 -0
- package/dist/components/trees/2d/node2d.js +1481 -0
- package/dist/components/trees/2d/node2d.js.map +1 -0
- package/dist/components/trees/audio/index.d.ts +2 -0
- package/dist/components/trees/audio/index.d.ts.map +1 -0
- package/dist/components/trees/audio/index.js +2 -0
- package/dist/components/trees/audio/index.js.map +1 -0
- package/dist/components/trees/audio/node-audio.d.ts +109 -0
- package/dist/components/trees/audio/node-audio.d.ts.map +1 -0
- package/dist/components/trees/audio/node-audio.js +167 -0
- package/dist/components/trees/audio/node-audio.js.map +1 -0
- package/dist/components/trees/index.d.ts +10 -0
- package/dist/components/trees/index.d.ts.map +1 -0
- package/dist/components/trees/index.js +14 -0
- package/dist/components/trees/index.js.map +1 -0
- package/dist/components/trees/node/node-editor-state.d.ts +53 -0
- package/dist/components/trees/node/node-editor-state.d.ts.map +1 -0
- package/dist/components/trees/node/node-editor-state.js +23 -0
- package/dist/components/trees/node/node-editor-state.js.map +1 -0
- package/dist/components/trees/node/node-reactive.d.ts +89 -0
- package/dist/components/trees/node/node-reactive.d.ts.map +1 -0
- package/dist/components/trees/node/node-reactive.js +135 -0
- package/dist/components/trees/node/node-reactive.js.map +1 -0
- package/dist/components/trees/node/node-time.d.ts +39 -0
- package/dist/components/trees/node/node-time.d.ts.map +1 -0
- package/dist/components/trees/node/node-time.js +14 -0
- package/dist/components/trees/node/node-time.js.map +1 -0
- package/dist/components/trees/node/node-walk.d.ts +46 -0
- package/dist/components/trees/node/node-walk.d.ts.map +1 -0
- package/dist/components/trees/node/node-walk.js +74 -0
- package/dist/components/trees/node/node-walk.js.map +1 -0
- package/dist/components/trees/node/node.d.ts +401 -0
- package/dist/components/trees/node/node.d.ts.map +1 -0
- package/dist/components/trees/node/node.js +680 -0
- package/dist/components/trees/node/node.js.map +1 -0
- package/dist/components/trees/root/canvas2d-node.d.ts +163 -0
- package/dist/components/trees/root/canvas2d-node.d.ts.map +1 -0
- package/dist/components/trees/root/canvas2d-node.js +216 -0
- package/dist/components/trees/root/canvas2d-node.js.map +1 -0
- package/dist/components/trees/three/node3d.d.ts +222 -0
- package/dist/components/trees/three/node3d.d.ts.map +1 -0
- package/dist/components/trees/three/node3d.js +289 -0
- package/dist/components/trees/three/node3d.js.map +1 -0
- package/dist/document/audio.d.ts +9 -1
- package/dist/document/audio.d.ts.map +1 -1
- package/dist/document/audio.js +41 -0
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +13 -31
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +2 -2
- package/dist/document/command-traits.js +4 -1
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.d.ts +2 -2
- package/dist/document/deny-globals.js +2 -2
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/diff.d.ts.map +1 -1
- package/dist/document/diff.js +3 -3
- package/dist/document/diff.js.map +1 -1
- package/dist/document/doc-index.d.ts.map +1 -1
- package/dist/document/doc-index.js +3 -3
- package/dist/document/doc-index.js.map +1 -1
- package/dist/document/expression/index.d.ts +1 -1
- package/dist/document/expression/index.js +1 -1
- package/dist/document/expression/index.js.map +1 -1
- package/dist/document/expression/ops.js +1 -1
- package/dist/document/expression/ops.js.map +1 -1
- package/dist/document/index.d.ts +1 -2
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/index.js +1 -2
- package/dist/document/index.js.map +1 -1
- package/dist/document/node-decorator.d.ts +14 -10
- package/dist/document/node-decorator.d.ts.map +1 -1
- package/dist/document/node-decorator.js +14 -10
- package/dist/document/node-decorator.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +9 -3
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.js +2 -2
- package/dist/document/placement.js.map +1 -1
- package/dist/document/registry.d.ts +29 -36
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +29 -35
- package/dist/document/registry.js.map +1 -1
- package/dist/document/settled-index.d.ts +49 -0
- package/dist/document/settled-index.d.ts.map +1 -0
- package/dist/document/settled-index.js +247 -0
- package/dist/document/settled-index.js.map +1 -0
- package/dist/document/timeline.d.ts +29 -3
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +99 -3
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +4 -4
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +1 -1
- package/dist/document/validate.js.map +1 -1
- package/dist/experimental.d.ts +22 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +20 -0
- package/dist/experimental.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/layout/types.d.ts +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/nodes/audio/index.d.ts +2 -2
- package/dist/nodes/audio/index.d.ts.map +1 -1
- package/dist/nodes/audio/index.js +0 -2
- package/dist/nodes/audio/index.js.map +1 -1
- package/dist/nodes/audio/sound-node.d.ts +2 -1
- package/dist/nodes/audio/sound-node.d.ts.map +1 -1
- package/dist/nodes/audio/sound-node.js +3 -0
- package/dist/nodes/audio/sound-node.js.map +1 -1
- package/dist/nodes/index.d.ts +39 -27
- package/dist/nodes/index.d.ts.map +1 -1
- package/dist/nodes/index.js +16 -30
- package/dist/nodes/index.js.map +1 -1
- package/dist/nodes/node/node.d.ts +7 -1
- package/dist/nodes/node/node.d.ts.map +1 -1
- package/dist/nodes/node/node.js +23 -8
- package/dist/nodes/node/node.js.map +1 -1
- package/dist/nodes/root/canvas2d-node.d.ts +2 -1
- package/dist/nodes/root/canvas2d-node.d.ts.map +1 -1
- package/dist/nodes/root/canvas2d-node.js +3 -0
- package/dist/nodes/root/canvas2d-node.js.map +1 -1
- package/dist/nodes/text/richtext-node.d.ts +0 -5
- package/dist/nodes/text/richtext-node.d.ts.map +1 -1
- package/dist/nodes/text/richtext-node.js +5 -71
- package/dist/nodes/text/richtext-node.js.map +1 -1
- package/dist/nodes/text/text-base.d.ts +5 -22
- package/dist/nodes/text/text-base.d.ts.map +1 -1
- package/dist/nodes/text/text-base.js +12 -363
- package/dist/nodes/text/text-base.js.map +1 -1
- package/dist/nodes/text/text-layout.d.ts +87 -0
- package/dist/nodes/text/text-layout.d.ts.map +1 -0
- package/dist/nodes/text/text-layout.js +368 -0
- package/dist/nodes/text/text-layout.js.map +1 -0
- package/dist/nodes/three/canvas3d-node.d.ts +3 -1
- package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
- package/dist/nodes/three/canvas3d-node.js +6 -0
- package/dist/nodes/three/canvas3d-node.js.map +1 -1
- package/dist/props/host.d.ts +1 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/slot.d.ts +1 -1
- package/dist/props/slot.js +1 -1
- package/dist/props/slot.js.map +1 -1
- package/dist/render/clip.d.ts +1 -1
- package/dist/render/clip.js +1 -1
- package/dist/render/clip.js.map +1 -1
- package/dist/render/descriptors/rect.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +11 -5
- package/dist/render/descriptors/text.d.ts.map +1 -1
- package/dist/render/descriptors/text.js +7 -1
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/render-context2d.d.ts +2 -2
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render3d/builders.d.ts +1 -1
- package/dist/render3d/builders.js +1 -1
- package/dist/render3d/builders.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts +13 -19
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +13 -19
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/render3d/scene3d.d.ts +1 -1
- package/dist/render3d/scene3d.js +1 -1
- package/dist/render3d/scene3d.js.map +1 -1
- package/dist/render3d/texture.d.ts +2 -2
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js.map +1 -1
- package/dist/render3d/vector3.d.ts +2 -2
- package/dist/render3d/vector3.js +2 -2
- package/dist/render3d/vector3.js.map +1 -1
- package/dist/runtime/asset-refine.d.ts +1 -1
- package/dist/runtime/asset-refine.d.ts.map +1 -1
- package/dist/runtime/asset-refine.js +1 -1
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-update.js +1 -1
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/audio-index.d.ts +0 -11
- package/dist/runtime/audio-index.d.ts.map +1 -1
- package/dist/runtime/audio-index.js +0 -25
- package/dist/runtime/audio-index.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +7 -4
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +21 -7
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +11 -3
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +83 -23
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +3 -3
- package/dist/runtime/engine.js +2 -2
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/node-picking.d.ts +2 -2
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +9 -10
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +12 -5
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +6 -1
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts +2 -2
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +1 -1
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/state-evaluator.d.ts +2 -2
- package/dist/runtime/state-evaluator.d.ts.map +1 -1
- package/dist/runtime/state-evaluator.js.map +1 -1
- package/dist/runtime/text-geometry.d.ts +1 -1
- package/dist/runtime/text-geometry.d.ts.map +1 -1
- package/dist/runtime/text-geometry.js +6 -3
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +46 -21
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +47 -43
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +7 -9
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +2 -2
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.d.ts +13 -1
- package/dist/tween/command.d.ts.map +1 -1
- package/dist/tween/command.js +14 -0
- package/dist/tween/command.js.map +1 -1
- package/dist/tween/index.d.ts +2 -1
- package/dist/tween/index.d.ts.map +1 -1
- package/dist/tween/index.js +1 -1
- package/dist/tween/index.js.map +1 -1
- package/dist/tween/loop.d.ts +1 -1
- package/dist/tween/loop.js +1 -1
- package/dist/tween/loop.js.map +1 -1
- package/dist/util/reference.d.ts +6 -6
- package/dist/util/reference.js.map +1 -1
- package/package.json +7 -10
- package/dist/browser/chunks/chunk-FUZVFT3W.js +0 -18
- package/dist/browser/chunks/chunk-FUZVFT3W.js.map +0 -7
- package/dist/browser/chunks/chunk-QG6C23IJ.js +0 -3
- package/dist/browser/chunks/chunk-QG6C23IJ.js.map +0 -7
- package/dist/browser/chunks/chunk-SFNJRPBV.js +0 -2
- package/dist/browser/chunks/chunk-SFNJRPBV.js.map +0 -7
- package/dist/browser/jsx-jsx-dev-runtime.js +0 -2
- package/dist/browser/jsx-jsx-runtime.js +0 -2
- package/dist/browser/jsx-jsx-runtime.js.map +0 -7
- /package/dist/browser/{jsx-jsx-dev-runtime.js.map → experimental.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-descriptor.js","sourceRoot":"","sources":["../../src/document/node-descriptor.ts"],"names":[],"mappings":"","sourcesContent":["import type { PropertyEditor } from \"@/attributes/properties/decorator\";\r\nimport type { NodeDimension } from \"@/
|
|
1
|
+
{"version":3,"file":"node-descriptor.js","sourceRoot":"","sources":["../../src/document/node-descriptor.ts"],"names":[],"mappings":"","sourcesContent":["import type { PropertyEditor } from \"@/attributes/properties/decorator\";\r\nimport type { NodeDimension } from \"@/components/trees/node/node\";\r\n\r\n/**\r\n * What a node type declares about itself beyond its key.\r\n *\r\n * The **technical** description of a type — how it lays children out, what a\r\n * fresh one is seeded with, what it inherits from. Deliberately *not* how it is\r\n * presented: no display name, no icon, no shelf, no copy. Those are a host's to\r\n * resolve and to translate, and a component that carried them would be shipping\r\n * one language's product decisions inside an engine artifact.\r\n *\r\n * It replaced a `manifest.json` written beside each package. Two descriptions of\r\n * one class is the shape that drifts, and it did: eight of nine packages ended\r\n * up promising commands their classes had never implemented.\r\n *\r\n * **Nothing here is read while rendering.** A frame is identical whether a type\r\n * declares a seed or not. It exists so a host has one place to ask.\r\n */\r\nexport interface NodeTypeDescriptor {\r\n /**\r\n * The document key, matching `NodeSpec.type`.\r\n *\r\n * **Frozen** for anything already published: a stored document naming it has\r\n * to keep meaning the same thing forever.\r\n */\r\n key: string;\r\n /** The type it inherits editing sections and commands from, for a host that groups them. */\r\n parentKey?: string;\r\n /**\r\n * Which scene graph the type belongs to — **derived from the class**, never\r\n * written here, for the same reason {@link properties} is.\r\n *\r\n * `dimension` is a getter on the prototype precisely so it answers before a\r\n * node is constructed, which is what lets a host ask \"can this type go in\r\n * that tree?\" from the registry alone rather than by building one and\r\n * catching the throw.\r\n */\r\n dimension?: NodeDimension;\r\n /**\r\n * The trees it takes children from: its own, or a viewport's two (a Canvas\r\n * 3D takes 2D and 3D); empty for a type that takes none. **Derived** from\r\n * the class, as {@link dimension} is.\r\n */\r\n holds?: readonly NodeDimension[];\r\n /**\r\n * Whether a host may copy this component's source.\r\n *\r\n * False for anything a host reaches into by identity — its own primitives. A\r\n * type is forkable exactly when the host knows nothing about it beyond this.\r\n */\r\n forkable?: boolean;\r\n\r\n layout?: NodeLayoutDescriptor;\r\n /** What a freshly placed one's props are seeded with. */\r\n seed?: Record<string, unknown>;\r\n\r\n /**\r\n * The types this one goes inside: a plot in a coordinate system, a tangent\r\n * in a plot. A name also stands for every type built on it ({@link parentKey}).\r\n * Unsaid, it goes wherever its {@link dimension} allows.\r\n *\r\n * A statement about the class, not a rule the engine enforces: a node put\r\n * elsewhere still builds and usually draws nothing, which is exactly what\r\n * a host is told here so it can offer the type only where it works. See\r\n * `placement.ts`.\r\n */\r\n within?: readonly string[];\r\n /**\r\n * Types it needs at least one of beside it, under the same parent: an area\r\n * between curves needs a curve. For a requirement that is not a parent,\r\n * because the thing needed is shared or there may be several of it.\r\n */\r\n beside?: readonly string[];\r\n /** Takes only the children that name it in their {@link within}: a plot holds its marks, not a photograph. */\r\n closed?: boolean;\r\n\r\n /**\r\n * The editable properties, by key — **derived from `property`**, never\r\n * written here.\r\n *\r\n * A hand-written list of a class's properties, beside a class of\r\n * properties, is exactly the restatement this whole descriptor exists to\r\n * remove. What a host needs beyond the key — a range, an enum's choices, the\r\n * controls inside an object-valued prop — is declared on the `property`\r\n * itself, which is the thing being edited.\r\n */\r\n properties?: Record<string, NodePropertyDescriptor>;\r\n}\r\n\r\n/** One editable property, as a host draws it. */\r\nexport interface NodePropertyDescriptor extends PropertyEditor {\r\n /** The control to draw. Always present here, inferred when not declared. */\r\n kind: string;\r\n /** What a freshly placed node holds, when the class declares one. */\r\n default?: unknown;\r\n}\r\n\r\n/** The layout answer a node type's children get from it. */\r\nexport interface NodeLayoutDescriptor {\r\n children?: \"flow\" | \"horizontal\" | \"vertical\" | \"grid\" | \"freeform\";\r\n acceptsChildren?: boolean;\r\n defaultWidthMode?: NodeSizeMode;\r\n defaultHeightMode?: NodeSizeMode;\r\n /** What a freshly placed one is sized to. */\r\n defaultWidth?: number;\r\n defaultHeight?: number;\r\n /** A locked width:height, for a type whose box *is* its design. */\r\n aspectRatio?: number;\r\n}\r\n\r\n/** How a node type sizes one axis. */\r\nexport type NodeSizeMode = \"fixed\" | \"hug\" | \"fill\";\r\n"]}
|
|
@@ -22,7 +22,7 @@ function among(registry, type, names, options) {
|
|
|
22
22
|
export function parentIssue(registry, child, parent, options = {}) {
|
|
23
23
|
const own = registry.describe(child);
|
|
24
24
|
const holder = parent === null ? undefined : registry.describe(parent);
|
|
25
|
-
if (parent !== null && holder?.layout?.acceptsChildren === false)
|
|
25
|
+
if (parent !== null && (holder?.layout?.acceptsChildren === false || holder?.holds?.length === 0))
|
|
26
26
|
return { kind: "leaf", parent };
|
|
27
27
|
const within = own?.within ?? [];
|
|
28
28
|
if (within.length > 0 && (parent === null || !among(registry, parent, within, options))) {
|
|
@@ -31,7 +31,7 @@ export function parentIssue(registry, child, parent, options = {}) {
|
|
|
31
31
|
if (parent !== null && holder?.closed === true && !among(registry, parent, within, options)) {
|
|
32
32
|
return { kind: "closed", parent };
|
|
33
33
|
}
|
|
34
|
-
const inThree = parent !== null && (holder?.dimension === "3d" || among(registry, parent, [CANVAS_3D], options));
|
|
34
|
+
const inThree = parent !== null && (holder?.dimension === "3d" || holder?.holds?.includes("3d") === true || among(registry, parent, [CANVAS_3D], options));
|
|
35
35
|
if ((own?.dimension === "3d") !== inThree)
|
|
36
36
|
return { kind: "dimension", parent };
|
|
37
37
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/document/placement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AAyCtD,mEAAmE;AACnE,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B,uEAAuE;AACvE,MAAM,UAAU,WAAW,CAAC,QAAk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AAQ,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC;QACjF,MAAM,KAAK,GACP,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC;YACrD,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QACjG,IAAI,KAAK;YAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,+FAA+F;AAC/F,SAAS,OAAO,CAAC,KAAwB,EAAE,GAAW;IAClD,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC","sourcesContent":["import type { Registry } from \"./registry\";\r\nimport { ROOT_NODE_ID, type NodeSpec } from \"./types\";\r\n\r\n/**\r\n * Where a node type may go, read off the registry without building anything:\r\n * the answer a host needs before it offers a type under a parent, accepts a\r\n * drop, or lets an assistant create a row.\r\n *\r\n * Four things decide it. A parent that takes no children takes none. The two\r\n * trees do not mix: a `Node3D` lives under a Canvas 3D or another 3D node, and\r\n * nothing else does. A type that names where it goes ({@link\r\n * NodeTypeDescriptor.within}) goes only there, and a {@link\r\n * NodeTypeDescriptor.closed} parent takes only the types that name it. Those\r\n * are about the parent; {@link NodeTypeDescriptor.beside} is about the\r\n * siblings, and is kept apart because a host can meet it by adding one.\r\n *\r\n * None of it is enforced when a document is built. A node in the wrong place\r\n * builds and, as a rule, draws nothing; this says why.\r\n */\r\n\r\n/** Why a node of a type is not where it can work. */\r\nexport type PlacementIssue =\r\n /** The parent takes no children. */\r\n | { kind: \"leaf\"; parent: string }\r\n /** A 3D node outside a 3D tree, or anything else inside one. */\r\n | { kind: \"dimension\"; parent: string | null }\r\n /** It goes inside one of `within`, and the parent is none of them. */\r\n | { kind: \"within\"; within: readonly string[] }\r\n /** The parent takes only the types that name it. */\r\n | { kind: \"closed\"; parent: string }\r\n /** It needs one of `beside` under the same parent, and there is none. */\r\n | { kind: \"beside\"; beside: readonly string[] };\r\n\r\nexport interface PlacementOptions {\r\n /**\r\n * A host's own sense of one type standing for another, beside the\r\n * registry's: a copy of a component it made under a new key is still that\r\n * component to whatever goes inside it.\r\n */\r\n isA?: (type: string, name: string) => boolean;\r\n}\r\n\r\n/** The one core type whose children are of the other dimension. */\r\nconst CANVAS_3D = \"canvas3d\";\r\n\r\n/** Whether `type` is `name`, or is built on it through `parentKey`. */\r\nexport function nodeTypeIsA(registry: Registry, type: string, name: string): boolean {\r\n const seen = new Set<string>();\r\n for (let at: string | undefined = type; at !== undefined && !seen.has(at); at = registry.describe(at)?.parentKey) {\r\n if (at === name) return true;\r\n seen.add(at);\r\n }\r\n return false;\r\n}\r\n\r\nfunction among(registry: Registry, type: string, names: readonly string[], options: PlacementOptions): boolean {\r\n return names.some((name) => nodeTypeIsA(registry, type, name) || options.isA?.(type, name) === true);\r\n}\r\n\r\n/**\r\n * Why a node of `child` cannot go directly inside one of `parent`, or `null`\r\n * when it can. A `null` parent is the document's own root, which is 2D and\r\n * names nothing.\r\n */\r\nexport function parentIssue(\r\n registry: Registry,\r\n child: string,\r\n parent: string | null,\r\n options: PlacementOptions = {},\r\n): PlacementIssue | null {\r\n const own = registry.describe(child);\r\n const holder = parent === null ? undefined : registry.describe(parent);\r\n if (parent !== null && holder?.layout?.acceptsChildren === false) return { kind: \"leaf\", parent };\r\n\r\n const within = own?.within ?? [];\r\n if (within.length > 0 && (parent === null || !among(registry, parent, within, options))) {\r\n return { kind: \"within\", within };\r\n }\r\n if (parent !== null && holder?.closed === true && !among(registry, parent, within, options)) {\r\n return { kind: \"closed\", parent };\r\n }\r\n\r\n const inThree = parent !== null && (holder?.dimension === \"3d\" || among(registry, parent, [CANVAS_3D], options));\r\n if ((own?.dimension === \"3d\") !== inThree) return { kind: \"dimension\", parent };\r\n return null;\r\n}\r\n\r\n/** The sibling `child` needs that `siblings`, the types already under its parent, do not include; `null` when it needs none or has one. */\r\nexport function siblingIssue(\r\n registry: Registry,\r\n child: string,\r\n siblings: readonly string[],\r\n options: PlacementOptions = {},\r\n): PlacementIssue | null {\r\n const beside = registry.describe(child)?.beside ?? [];\r\n if (beside.length === 0 || siblings.some((type) => among(registry, type, beside, options))) return null;\r\n return { kind: \"beside\", beside };\r\n}\r\n\r\n/**\r\n * Every node of `nodes` that is not where its type says it goes, by id, with\r\n * the first reason. A node of an unregistered type is left out: that is a build\r\n * error, and says so itself.\r\n */\r\nexport function placementIssues(\r\n registry: Registry,\r\n nodes: readonly Pick<NodeSpec, \"id\" | \"type\" | \"parentId\">[],\r\n options: PlacementOptions = {},\r\n): Map<string, PlacementIssue> {\r\n // A document may write its stage as a row or leave it out: either way its children's parent is the root.\r\n const parentOf = (node: Pick<NodeSpec, \"parentId\">) => (node.parentId === ROOT_NODE_ID ? null : node.parentId);\r\n const byId = new Map(nodes.map((node) => [node.id, node]));\r\n const children = new Map<string | null, string[]>();\r\n for (const node of nodes) {\r\n if (node.id === ROOT_NODE_ID) continue;\r\n const under = children.get(parentOf(node));\r\n if (under) under.push(node.type);\r\n else children.set(parentOf(node), [node.type]);\r\n }\r\n const issues = new Map<string, PlacementIssue>();\r\n for (const node of nodes) {\r\n if (node.id === ROOT_NODE_ID || !registry.hasNode(node.type)) continue;\r\n const parentId = parentOf(node);\r\n const parentType = parentId === null ? null : (byId.get(parentId)?.type ?? null);\r\n const issue =\r\n parentIssue(registry, node.type, parentType, options) ??\r\n siblingIssue(registry, node.type, without(children.get(parentId) ?? [], node.type), options);\r\n if (issue) issues.set(node.id, issue);\r\n }\r\n return issues;\r\n}\r\n\r\n// The node's own type once: a second area is a sibling of the first, the first is not its own.\r\nfunction without(types: readonly string[], own: string): string[] {\r\n const at = types.indexOf(own);\r\n return at === -1 ? [...types] : [...types.slice(0, at), ...types.slice(at + 1)];\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/document/placement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AAyCtD,mEAAmE;AACnE,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B,uEAAuE;AACvE,MAAM,UAAU,WAAW,CAAC,QAAkB,EAAE,IAAY,EAAE,IAAY;IACtE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,IAAI,EAAE,GAAuB,IAAI,EAAE,EAAE,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC;QAC/G,IAAI,EAAE,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,KAAK,CAAC,QAAkB,EAAE,IAAY,EAAE,KAAwB,EAAE,OAAyB;IAChG,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AACzG,CAAC;AAED;;;;GAIG;AACH,M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AO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC","sourcesContent":["import type { Registry } from \"./registry\";\r\nimport { ROOT_NODE_ID, type NodeSpec } from \"./types\";\r\n\r\n/**\r\n * Where a node type may go, read off the registry without building anything:\r\n * the answer a host needs before it offers a type under a parent, accepts a\r\n * drop, or lets an assistant create a row.\r\n *\r\n * Four things decide it. A parent that takes no children takes none. The two\r\n * trees do not mix: a `Node3D` lives under a Canvas 3D or another 3D node, and\r\n * nothing else does. A type that names where it goes ({@link\r\n * NodeTypeDescriptor.within}) goes only there, and a {@link\r\n * NodeTypeDescriptor.closed} parent takes only the types that name it. Those\r\n * are about the parent; {@link NodeTypeDescriptor.beside} is about the\r\n * siblings, and is kept apart because a host can meet it by adding one.\r\n *\r\n * None of it is enforced when a document is built. A node in the wrong place\r\n * builds and, as a rule, draws nothing; this says why.\r\n */\r\n\r\n/** Why a node of a type is not where it can work. */\r\nexport type PlacementIssue =\r\n /** The parent takes no children. */\r\n | { kind: \"leaf\"; parent: string }\r\n /** A 3D node outside a 3D tree, or anything else inside one. */\r\n | { kind: \"dimension\"; parent: string | null }\r\n /** It goes inside one of `within`, and the parent is none of them. */\r\n | { kind: \"within\"; within: readonly string[] }\r\n /** The parent takes only the types that name it. */\r\n | { kind: \"closed\"; parent: string }\r\n /** It needs one of `beside` under the same parent, and there is none. */\r\n | { kind: \"beside\"; beside: readonly string[] };\r\n\r\nexport interface PlacementOptions {\r\n /**\r\n * A host's own sense of one type standing for another, beside the\r\n * registry's: a copy of a component it made under a new key is still that\r\n * component to whatever goes inside it.\r\n */\r\n isA?: (type: string, name: string) => boolean;\r\n}\r\n\r\n/** The one core type whose children are of the other dimension. */\r\nconst CANVAS_3D = \"canvas3d\";\r\n\r\n/** Whether `type` is `name`, or is built on it through `parentKey`. */\r\nexport function nodeTypeIsA(registry: Registry, type: string, name: string): boolean {\r\n const seen = new Set<string>();\r\n for (let at: string | undefined = type; at !== undefined && !seen.has(at); at = registry.describe(at)?.parentKey) {\r\n if (at === name) return true;\r\n seen.add(at);\r\n }\r\n return false;\r\n}\r\n\r\nfunction among(registry: Registry, type: string, names: readonly string[], options: PlacementOptions): boolean {\r\n return names.some((name) => nodeTypeIsA(registry, type, name) || options.isA?.(type, name) === true);\r\n}\r\n\r\n/**\r\n * Why a node of `child` cannot go directly inside one of `parent`, or `null`\r\n * when it can. A `null` parent is the document's own root, which is 2D and\r\n * names nothing.\r\n */\r\nexport function parentIssue(\r\n registry: Registry,\r\n child: string,\r\n parent: string | null,\r\n options: PlacementOptions = {},\r\n): PlacementIssue | null {\r\n const own = registry.describe(child);\r\n const holder = parent === null ? undefined : registry.describe(parent);\r\n if (parent !== null && (holder?.layout?.acceptsChildren === false || holder?.holds?.length === 0)) return { kind: \"leaf\", parent };\r\n\r\n const within = own?.within ?? [];\r\n if (within.length > 0 && (parent === null || !among(registry, parent, within, options))) {\r\n return { kind: \"within\", within };\r\n }\r\n if (parent !== null && holder?.closed === true && !among(registry, parent, within, options)) {\r\n return { kind: \"closed\", parent };\r\n }\r\n\r\n const inThree = parent !== null && (holder?.dimension === \"3d\" || holder?.holds?.includes(\"3d\") === true || among(registry, parent, [CANVAS_3D], options));\r\n if ((own?.dimension === \"3d\") !== inThree) return { kind: \"dimension\", parent };\r\n return null;\r\n}\r\n\r\n/** The sibling `child` needs that `siblings`, the types already under its parent, do not include; `null` when it needs none or has one. */\r\nexport function siblingIssue(\r\n registry: Registry,\r\n child: string,\r\n siblings: readonly string[],\r\n options: PlacementOptions = {},\r\n): PlacementIssue | null {\r\n const beside = registry.describe(child)?.beside ?? [];\r\n if (beside.length === 0 || siblings.some((type) => among(registry, type, beside, options))) return null;\r\n return { kind: \"beside\", beside };\r\n}\r\n\r\n/**\r\n * Every node of `nodes` that is not where its type says it goes, by id, with\r\n * the first reason. A node of an unregistered type is left out: that is a build\r\n * error, and says so itself.\r\n */\r\nexport function placementIssues(\r\n registry: Registry,\r\n nodes: readonly Pick<NodeSpec, \"id\" | \"type\" | \"parentId\">[],\r\n options: PlacementOptions = {},\r\n): Map<string, PlacementIssue> {\r\n // A document may write its stage as a row or leave it out: either way its children's parent is the root.\r\n const parentOf = (node: Pick<NodeSpec, \"parentId\">) => (node.parentId === ROOT_NODE_ID ? null : node.parentId);\r\n const byId = new Map(nodes.map((node) => [node.id, node]));\r\n const children = new Map<string | null, string[]>();\r\n for (const node of nodes) {\r\n if (node.id === ROOT_NODE_ID) continue;\r\n const under = children.get(parentOf(node));\r\n if (under) under.push(node.type);\r\n else children.set(parentOf(node), [node.type]);\r\n }\r\n const issues = new Map<string, PlacementIssue>();\r\n for (const node of nodes) {\r\n if (node.id === ROOT_NODE_ID || !registry.hasNode(node.type)) continue;\r\n const parentId = parentOf(node);\r\n const parentType = parentId === null ? null : (byId.get(parentId)?.type ?? null);\r\n const issue =\r\n parentIssue(registry, node.type, parentType, options) ??\r\n siblingIssue(registry, node.type, without(children.get(parentId) ?? [], node.type), options);\r\n if (issue) issues.set(node.id, issue);\r\n }\r\n return issues;\r\n}\r\n\r\n// The node's own type once: a second area is a sibling of the first, the first is not its own.\r\nfunction without(types: readonly string[], own: string): string[] {\r\n const at = types.indexOf(own);\r\n return at === -1 ? [...types] : [...types.slice(0, at), ...types.slice(at + 1)];\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node } from "../
|
|
1
|
+
import type { Node } from "../components/trees/node/node.js";
|
|
2
2
|
import type { Command } from "../tween/command.js";
|
|
3
3
|
import type { EasingFunction } from "../tween/ease/type.js";
|
|
4
4
|
import { type CommandArg, type CommandArgDescriptor } from "../tween/command-decorator.js";
|
|
@@ -11,14 +11,14 @@ import type { NodeSpec } from "./types.js";
|
|
|
11
11
|
* A document names a node type, a command, a lerp and a shader with a string.
|
|
12
12
|
* Something has to turn `"rect"` into a class and `"fillTo"` into an animation,
|
|
13
13
|
* and that something is deliberately a registry rather than a table in the
|
|
14
|
-
* database: node types are code — a class with
|
|
15
|
-
* `renderSelf`, and
|
|
14
|
+
* database: node types are code — a class with `property` declarations, a
|
|
15
|
+
* `renderSelf`, and `command()` methods — and code is versioned with the
|
|
16
16
|
* library, not with the document.
|
|
17
17
|
*
|
|
18
18
|
* **It is an instance, not a module.** Every table here used to be a
|
|
19
19
|
* module-scope `Map` behind a dozen free functions, which made a registration
|
|
20
20
|
* a fact about the *process*: two engines in one process shared one vocabulary,
|
|
21
|
-
* a
|
|
21
|
+
* a declared class was registered by the mere act of being imported, whichever
|
|
22
22
|
* host loaded first won a contested key, and a test had to remember to call a
|
|
23
23
|
* `clearRegistries()` that reached into three modules. A registry is now a value
|
|
24
24
|
* with an owner — an `Engine`'s own, reached through `registerNode`/`registerShader`
|
|
@@ -89,7 +89,7 @@ export type VariableCommandFactory = (target: VariableTarget, args: Record<strin
|
|
|
89
89
|
/**
|
|
90
90
|
* How a variable's value interpolates between two states.
|
|
91
91
|
*
|
|
92
|
-
* The same shape every
|
|
92
|
+
* The same shape every `property` tween already has, widened to `unknown`
|
|
93
93
|
* because a variable's type is a fact of the document rather than of a class:
|
|
94
94
|
* one holds a number, the next a colour string, the next a whole fill object.
|
|
95
95
|
*/
|
|
@@ -137,7 +137,7 @@ export type CommandTypeEntry = {
|
|
|
137
137
|
/**
|
|
138
138
|
* One node type's own command table.
|
|
139
139
|
*
|
|
140
|
-
* Built from the class's
|
|
140
|
+
* Built from the class's `command()` methods — the **whole** prototype chain,
|
|
141
141
|
* not just its own — because the table is per type. A `Card` extending `Rect`
|
|
142
142
|
* answers to `fadeTo` for the same reason it answers to `.fadeTo()`: it has the
|
|
143
143
|
* method. There is nothing here for two node types to collide over, so
|
|
@@ -150,13 +150,11 @@ export interface NodeTypeRecord {
|
|
|
150
150
|
ctor: NodeConstructor;
|
|
151
151
|
/** Its commands, by the key a document names them with. */
|
|
152
152
|
commands: ReadonlyMap<string, NodeCommandEntry>;
|
|
153
|
-
/** Commands it inherits and withdrew (`withdraw`): never offered, still dispatched for a stored document that names one. */
|
|
154
|
-
withdrawn: ReadonlyMap<string, NodeCommandEntry>;
|
|
155
153
|
/**
|
|
156
154
|
* What the type declares about itself — see {@link NodeTypeDescriptor}.
|
|
157
155
|
*
|
|
158
156
|
* Always present, so a host reads one shape whether the type was registered
|
|
159
|
-
* with a bare key, a full descriptor, or a
|
|
157
|
+
* with a bare key, a full descriptor, or a component.
|
|
160
158
|
*/
|
|
161
159
|
descriptor: NodeTypeDescriptor;
|
|
162
160
|
}
|
|
@@ -165,7 +163,7 @@ export interface NodeCommandEntry {
|
|
|
165
163
|
/** The method to call. */
|
|
166
164
|
method: string;
|
|
167
165
|
/**
|
|
168
|
-
* Its leading parameters, from
|
|
166
|
+
* Its leading parameters, from `command({ args })`, always as descriptors.
|
|
169
167
|
*
|
|
170
168
|
* A bare name normalises to `{ key, kind: "unknown" }`, so a host reads one
|
|
171
169
|
* shape whether the method bothered to describe its arguments or not.
|
|
@@ -173,8 +171,8 @@ export interface NodeCommandEntry {
|
|
|
173
171
|
args: readonly CommandArgDescriptor[];
|
|
174
172
|
}
|
|
175
173
|
/**
|
|
176
|
-
* How a registry compiles and links a node authored as a TS
|
|
177
|
-
*
|
|
174
|
+
* How a registry compiles and links a node authored as a TS source string
|
|
175
|
+
* that default-exports a component, via {@link Registry.addNodeFromSource}.
|
|
178
176
|
*
|
|
179
177
|
* Entirely host-supplied — `core` has no compiler dependency and cannot
|
|
180
178
|
* import the published `@motionscript/sdk` barrel itself (that package
|
|
@@ -190,12 +188,6 @@ export interface DynamicNodeConfig {
|
|
|
190
188
|
* script authored under either name keeps compiling unmodified.
|
|
191
189
|
*/
|
|
192
190
|
sdk: Record<string, unknown>;
|
|
193
|
-
/**
|
|
194
|
-
* What `require("@motionscript/sdk/jsx-runtime")` resolves to (also under
|
|
195
|
-
* the legacy `motionscript/jsx-runtime` and `motion-script/jsx-runtime`
|
|
196
|
-
* specifiers). Omit to reject a script that uses JSX outright.
|
|
197
|
-
*/
|
|
198
|
-
jsxRuntime?: Record<string, unknown>;
|
|
199
191
|
/**
|
|
200
192
|
* Further modules a script may `require`, by exact specifier — what a
|
|
201
193
|
* forked component imports beyond the sdk barrel:
|
|
@@ -205,7 +197,7 @@ export interface DynamicNodeConfig {
|
|
|
205
197
|
*/
|
|
206
198
|
modules?: Readonly<Record<string, unknown>>;
|
|
207
199
|
/**
|
|
208
|
-
* TS
|
|
200
|
+
* TS source → JS text (CommonJS). Host-injected, never bundled —
|
|
209
201
|
* `core` has no compiler dependency of its own.
|
|
210
202
|
*/
|
|
211
203
|
compile: (source: string) => Promise<string>;
|
|
@@ -213,9 +205,9 @@ export interface DynamicNodeConfig {
|
|
|
213
205
|
/** What a registry is seeded with, on top of the builtin vocabulary. */
|
|
214
206
|
export interface RegistryOptions {
|
|
215
207
|
/**
|
|
216
|
-
* Custom node types —
|
|
208
|
+
* Custom node types — components, or explicit keys.
|
|
217
209
|
*
|
|
218
|
-
* An array reads each class's
|
|
210
|
+
* An array reads each class's `node()` declaration; a record names the key
|
|
219
211
|
* outright, which is also an assertion that the two agree (a rename on
|
|
220
212
|
* either side throws here rather than surfacing as an unknown type at
|
|
221
213
|
* render).
|
|
@@ -244,15 +236,15 @@ export declare class Registry {
|
|
|
244
236
|
/**
|
|
245
237
|
* Register a node class, with its commands and whatever else it declares.
|
|
246
238
|
*
|
|
247
|
-
* Takes a
|
|
239
|
+
* Takes a component (or a class carrying a `node()` declaration) on its own, or a bare key / full
|
|
248
240
|
* {@link NodeTypeDescriptor} plus the class. The descriptor is the code half
|
|
249
241
|
* of what a component package used to restate in a `manifest.json` —
|
|
250
242
|
* carried, never interpreted, so a host has one place to ask and no second
|
|
251
243
|
* file to disagree with the class.
|
|
252
244
|
*
|
|
253
|
-
* The commands come off the class, so
|
|
245
|
+
* The commands come off the class, so `command()` is the only place a
|
|
254
246
|
* node's animations are written down. Nothing is constructed to read them:
|
|
255
|
-
*
|
|
247
|
+
* `command` records onto the prototype, so an object *over* the prototype
|
|
256
248
|
* reaches the whole chain without running a constructor that may expect
|
|
257
249
|
* props, build children, or touch a clock.
|
|
258
250
|
*
|
|
@@ -275,11 +267,11 @@ export declare class Registry {
|
|
|
275
267
|
replace?: boolean;
|
|
276
268
|
}): this;
|
|
277
269
|
/**
|
|
278
|
-
* Compile a TS
|
|
270
|
+
* Compile a TS source string into a live node type and register it.
|
|
279
271
|
*
|
|
280
|
-
* The script must `export default` a
|
|
281
|
-
*
|
|
282
|
-
* already reads it off a statically-imported
|
|
272
|
+
* The script must `export default` a component (`component2d({ key, … })`),
|
|
273
|
+
* whose `key` supplies the registry key, exactly as {@link addNode}
|
|
274
|
+
* already reads it off a statically-imported one. There is no separate
|
|
283
275
|
* `key` parameter: one way to name a dynamic node's key, not two that
|
|
284
276
|
* could disagree.
|
|
285
277
|
*
|
|
@@ -348,7 +340,7 @@ export declare class Registry {
|
|
|
348
340
|
/**
|
|
349
341
|
* Whether a node of `nodeTypeKey` takes `commandKey`: one its own table
|
|
350
342
|
* publishes, or a node-less one that acts on a node (`to`, `fillTo`) unless
|
|
351
|
-
* the method it runs is one the type lacks
|
|
343
|
+
* the method it runs is one the type lacks. What a host offers a
|
|
352
344
|
* node is its table and the node-less commands it takes.
|
|
353
345
|
*/
|
|
354
346
|
takesCommand(nodeTypeKey: string, commandKey: string): boolean;
|
|
@@ -436,8 +428,7 @@ export declare class Registry {
|
|
|
436
428
|
*
|
|
437
429
|
* `new Function` in-realm, never a blob module or a worker — see
|
|
438
430
|
* {@link DynamicNodeConfig} and `deny-globals.ts` for why. `require()` is
|
|
439
|
-
* locked to exactly `"@motionscript/sdk"
|
|
440
|
-
* (plus the earlier unscoped `"motionscript"` and `"motion-script"`
|
|
431
|
+
* locked to exactly `"@motionscript/sdk"` (plus the earlier unscoped `"motionscript"` and `"motion-script"`
|
|
441
432
|
* spellings, so a script written under either name still compiles) and
|
|
442
433
|
* the host's `modules`, own keys only so `require("constructor")` cannot
|
|
443
434
|
* reach `Object`. No relative
|
|
@@ -447,11 +438,11 @@ export declare class Registry {
|
|
|
447
438
|
/** One key, one factory — see {@link addNode} for why. */
|
|
448
439
|
private _claimed;
|
|
449
440
|
/**
|
|
450
|
-
* A class's editable properties, read off its
|
|
441
|
+
* A class's editable properties, read off its `property` declarations.
|
|
451
442
|
*
|
|
452
|
-
* The whole prototype chain, so a
|
|
453
|
-
*
|
|
454
|
-
* control it actually has
|
|
443
|
+
* The whole prototype chain, so a component publishes the box its tree's
|
|
444
|
+
* base declares as well as its own entries — a host editing one edits every
|
|
445
|
+
* control it actually has.
|
|
455
446
|
*/
|
|
456
447
|
private _describeProperties;
|
|
457
448
|
/**
|
|
@@ -461,9 +452,11 @@ export declare class Registry {
|
|
|
461
452
|
* it answers from the prototype, before any field initializer has run.
|
|
462
453
|
*/
|
|
463
454
|
private _describeDimension;
|
|
455
|
+
/** The trees a type takes children from, off the prototype as its dimension is. */
|
|
456
|
+
private _describeHolds;
|
|
464
457
|
/**
|
|
465
458
|
* The control a value's own type implies. Only ever a fallback: a typed
|
|
466
|
-
*
|
|
459
|
+
* property states its kind, and a plain `property` may too.
|
|
467
460
|
*
|
|
468
461
|
* A function default is a *reactive binding*, not a value, so it says nothing
|
|
469
462
|
* about the control; those declare their kind or take "unknown", which a host
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/document/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAiB,MAAM,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/document/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAiB,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAe,MA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AQ,CAAC,aAAa,CAAC,CAAoB;IAEnD;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,eAAe;IA6BvB,0DAA0D;IAC1D,OAAO,CAAC,QAAQ;IAShB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAK1B,mFAAmF;IACnF,OAAO,CAAC,cAAc;IAKtB;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;IAclB,sFAAsF;IACtF,OAAO,CAAC,aAAa;CAIxB"}
|
|
@@ -6,7 +6,7 @@ import { DENIED_GLOBALS } from "./deny-globals.js";
|
|
|
6
6
|
import { getNodeDescriptor } from "./node-decorator.js";
|
|
7
7
|
/**
|
|
8
8
|
* The specifiers a dynamic node's `require()` resolves to the host's sdk
|
|
9
|
-
* barrel
|
|
9
|
+
* barrel. The published
|
|
10
10
|
* name comes first; the two after it are the package's earlier unscoped names,
|
|
11
11
|
* kept so a script authored under either still compiles.
|
|
12
12
|
*/
|
|
@@ -36,12 +36,14 @@ export class Registry {
|
|
|
36
36
|
}
|
|
37
37
|
addNode(type, ctorOrOptions, maybeOptions) {
|
|
38
38
|
const isTwoArgForm = typeof ctorOrOptions === "function";
|
|
39
|
-
|
|
39
|
+
// A component (`component2d(...)`) registers as the node class it generated.
|
|
40
|
+
const given = (isTwoArgForm ? ctorOrOptions : type);
|
|
41
|
+
const cls = typeof given.node === "function" ? given.node : given;
|
|
40
42
|
const options = isTwoArgForm ? maybeOptions : ctorOrOptions;
|
|
41
43
|
const declared = isTwoArgForm ? type : getNodeDescriptor(cls);
|
|
42
44
|
if (declared === undefined) {
|
|
43
|
-
throw new Error(`${cls.name || "The class"}
|
|
44
|
-
`
|
|
45
|
+
throw new Error(`${cls.name || "The class"} is no component, so it has no document key. ` +
|
|
46
|
+
`Make it with component2d({ key }), or register it explicitly: addNode("myKey", TheClass).`);
|
|
45
47
|
}
|
|
46
48
|
const descriptor = typeof declared === "string" ? { key: declared } : declared;
|
|
47
49
|
const key = descriptor.key;
|
|
@@ -56,30 +58,29 @@ export class Registry {
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
const commands = new Map();
|
|
59
|
-
const withdrawn = new Map();
|
|
60
61
|
for (const meta of getCommandMeta(Object.create(cls.prototype))) {
|
|
61
|
-
|
|
62
|
+
commands.set(meta.key, { method: meta.method, args: this._describeArgs(meta.args) });
|
|
62
63
|
}
|
|
63
64
|
this._nodes.set(key, {
|
|
64
65
|
key,
|
|
65
66
|
ctor: cls,
|
|
66
67
|
commands,
|
|
67
|
-
withdrawn,
|
|
68
68
|
// Derived, never declared: see `NodeTypeDescriptor.properties`.
|
|
69
69
|
descriptor: {
|
|
70
70
|
...descriptor,
|
|
71
71
|
dimension: this._describeDimension(cls),
|
|
72
|
+
holds: this._describeHolds(cls),
|
|
72
73
|
properties: this._describeProperties(cls),
|
|
73
74
|
},
|
|
74
75
|
});
|
|
75
76
|
return this;
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
|
-
* Compile a TS
|
|
79
|
+
* Compile a TS source string into a live node type and register it.
|
|
79
80
|
*
|
|
80
|
-
* The script must `export default` a
|
|
81
|
-
*
|
|
82
|
-
* already reads it off a statically-imported
|
|
81
|
+
* The script must `export default` a component (`component2d({ key, … })`),
|
|
82
|
+
* whose `key` supplies the registry key, exactly as {@link addNode}
|
|
83
|
+
* already reads it off a statically-imported one. There is no separate
|
|
83
84
|
* `key` parameter: one way to name a dynamic node's key, not two that
|
|
84
85
|
* could disagree.
|
|
85
86
|
*
|
|
@@ -187,7 +188,7 @@ export class Registry {
|
|
|
187
188
|
*/
|
|
188
189
|
nodeCommand(nodeTypeKey, commandKey) {
|
|
189
190
|
const record = this._nodes.get(nodeTypeKey);
|
|
190
|
-
const entry = record?.commands.get(commandKey)
|
|
191
|
+
const entry = record?.commands.get(commandKey);
|
|
191
192
|
if (!entry)
|
|
192
193
|
return undefined;
|
|
193
194
|
return (target, args, duration, easing) => {
|
|
@@ -206,7 +207,7 @@ export class Registry {
|
|
|
206
207
|
/**
|
|
207
208
|
* Whether a node of `nodeTypeKey` takes `commandKey`: one its own table
|
|
208
209
|
* publishes, or a node-less one that acts on a node (`to`, `fillTo`) unless
|
|
209
|
-
* the method it runs is one the type lacks
|
|
210
|
+
* the method it runs is one the type lacks. What a host offers a
|
|
210
211
|
* node is its table and the node-less commands it takes.
|
|
211
212
|
*/
|
|
212
213
|
takesCommand(nodeTypeKey, commandKey) {
|
|
@@ -220,8 +221,6 @@ export class Registry {
|
|
|
220
221
|
return false;
|
|
221
222
|
if (global.method === undefined)
|
|
222
223
|
return true;
|
|
223
|
-
if (record.withdrawn.has(global.method))
|
|
224
|
-
return false;
|
|
225
224
|
return typeof record.ctor.prototype[global.method] === "function";
|
|
226
225
|
}
|
|
227
226
|
/**
|
|
@@ -374,28 +373,20 @@ export class Registry {
|
|
|
374
373
|
*
|
|
375
374
|
* `new Function` in-realm, never a blob module or a worker — see
|
|
376
375
|
* {@link DynamicNodeConfig} and `deny-globals.ts` for why. `require()` is
|
|
377
|
-
* locked to exactly `"@motionscript/sdk"
|
|
378
|
-
* (plus the earlier unscoped `"motionscript"` and `"motion-script"`
|
|
376
|
+
* locked to exactly `"@motionscript/sdk"` (plus the earlier unscoped `"motionscript"` and `"motion-script"`
|
|
379
377
|
* spellings, so a script written under either name still compiles) and
|
|
380
378
|
* the host's `modules`, own keys only so `require("constructor")` cannot
|
|
381
379
|
* reach `Object`. No relative
|
|
382
380
|
* imports, since a dynamic node is one script, not a package.
|
|
383
381
|
*/
|
|
384
382
|
_evalNodeModule(js) {
|
|
385
|
-
const { sdk,
|
|
383
|
+
const { sdk, modules } = this._dynamicNodes;
|
|
386
384
|
const require = (specifier) => {
|
|
387
385
|
if (SDK_SPECIFIERS.includes(specifier))
|
|
388
386
|
return sdk;
|
|
389
|
-
if (jsxRuntime && SDK_SPECIFIERS.some((name) => specifier === `${name}/jsx-runtime`)) {
|
|
390
|
-
return jsxRuntime;
|
|
391
|
-
}
|
|
392
387
|
if (modules && Object.hasOwn(modules, specifier))
|
|
393
388
|
return modules[specifier];
|
|
394
|
-
const available = [
|
|
395
|
-
"@motionscript/sdk",
|
|
396
|
-
...(jsxRuntime ? ["@motionscript/sdk/jsx-runtime"] : []),
|
|
397
|
-
...Object.keys(modules ?? {}),
|
|
398
|
-
];
|
|
389
|
+
const available = ["@motionscript/sdk", ...Object.keys(modules ?? {})];
|
|
399
390
|
throw new Error(`"${specifier}" isn't available to a custom node. It can require ` +
|
|
400
391
|
`${available.map((s) => `"${s}"`).join(", ")}; a host supplies more through \`dynamicNodes.modules\`.`);
|
|
401
392
|
};
|
|
@@ -407,8 +398,8 @@ export class Registry {
|
|
|
407
398
|
const factory = new Function("exports", "require", "module", ...DENIED_GLOBALS, `"use strict";\nreturn function () {\n${js}\n};`);
|
|
408
399
|
factory(mod.exports, require, mod)();
|
|
409
400
|
const ctor = mod.exports.default;
|
|
410
|
-
if (typeof ctor !== "function" || getNodeDescriptor(ctor) === undefined) {
|
|
411
|
-
throw new Error("This script must `export default` a
|
|
401
|
+
if (typeof ctor !== "function" || getNodeDescriptor(typeof ctor.node === "function" ? ctor.node : ctor) === undefined) {
|
|
402
|
+
throw new Error("This script must `export default` a component: `component2d({ key: \"…\", … })`.");
|
|
412
403
|
}
|
|
413
404
|
return ctor;
|
|
414
405
|
}
|
|
@@ -422,17 +413,15 @@ export class Registry {
|
|
|
422
413
|
throw new Error(`Command type "${key}" is already registered to a different factory. Keys must be unique.`);
|
|
423
414
|
}
|
|
424
415
|
/**
|
|
425
|
-
* A class's editable properties, read off its
|
|
416
|
+
* A class's editable properties, read off its `property` declarations.
|
|
426
417
|
*
|
|
427
|
-
* The whole prototype chain, so a
|
|
428
|
-
*
|
|
429
|
-
* control it actually has
|
|
418
|
+
* The whole prototype chain, so a component publishes the box its tree's
|
|
419
|
+
* base declares as well as its own entries — a host editing one edits every
|
|
420
|
+
* control it actually has.
|
|
430
421
|
*/
|
|
431
422
|
_describeProperties(ctor) {
|
|
432
423
|
const out = {};
|
|
433
424
|
for (const meta of getPropertyMeta(Object.create(ctor.prototype))) {
|
|
434
|
-
if (meta.withdrawn)
|
|
435
|
-
continue;
|
|
436
425
|
const editor = meta.editor ?? {};
|
|
437
426
|
out[meta.key] = {
|
|
438
427
|
...editor,
|
|
@@ -452,9 +441,14 @@ export class Registry {
|
|
|
452
441
|
const dimension = Object.create(ctor.prototype).dimension;
|
|
453
442
|
return typeof dimension === "string" ? dimension : undefined;
|
|
454
443
|
}
|
|
444
|
+
/** The trees a type takes children from, off the prototype as its dimension is. */
|
|
445
|
+
_describeHolds(ctor) {
|
|
446
|
+
const trees = Object.create(ctor.prototype)._childTrees;
|
|
447
|
+
return Array.isArray(trees) ? [...trees] : undefined;
|
|
448
|
+
}
|
|
455
449
|
/**
|
|
456
450
|
* The control a value's own type implies. Only ever a fallback: a typed
|
|
457
|
-
*
|
|
451
|
+
* property states its kind, and a plain `property` may too.
|
|
458
452
|
*
|
|
459
453
|
* A function default is a *reactive binding*, not a value, so it says nothing
|
|
460
454
|
* about the control; those declare their kind or take "unknown", which a host
|