@efxlab/motion-canvas-2d 4.0.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/editor/index.css +40 -0
- package/editor/index.js +525 -0
- package/editor/index.js.map +1 -0
- package/lib/code/CodeCursor.d.ts +84 -0
- package/lib/code/CodeCursor.d.ts.map +1 -0
- package/lib/code/CodeCursor.js +315 -0
- package/lib/code/CodeDiffer.d.ts +28 -0
- package/lib/code/CodeDiffer.d.ts.map +1 -0
- package/lib/code/CodeDiffer.js +51 -0
- package/lib/code/CodeFragment.d.ts +42 -0
- package/lib/code/CodeFragment.d.ts.map +1 -0
- package/lib/code/CodeFragment.js +72 -0
- package/lib/code/CodeHighlighter.d.ts +69 -0
- package/lib/code/CodeHighlighter.d.ts.map +1 -0
- package/lib/code/CodeHighlighter.js +2 -0
- package/lib/code/CodeMetrics.d.ts +11 -0
- package/lib/code/CodeMetrics.d.ts.map +1 -0
- package/lib/code/CodeMetrics.js +29 -0
- package/lib/code/CodeRange.d.ts +43 -0
- package/lib/code/CodeRange.d.ts.map +1 -0
- package/lib/code/CodeRange.js +185 -0
- package/lib/code/CodeScope.d.ts +16 -0
- package/lib/code/CodeScope.d.ts.map +1 -0
- package/lib/code/CodeScope.js +72 -0
- package/lib/code/CodeSelection.d.ts +6 -0
- package/lib/code/CodeSelection.d.ts.map +1 -0
- package/lib/code/CodeSelection.js +13 -0
- package/lib/code/CodeSignal.d.ts +63 -0
- package/lib/code/CodeSignal.d.ts.map +1 -0
- package/lib/code/CodeSignal.js +206 -0
- package/lib/code/CodeTokenizer.d.ts +8 -0
- package/lib/code/CodeTokenizer.d.ts.map +1 -0
- package/lib/code/CodeTokenizer.js +50 -0
- package/lib/code/DefaultHighlightStyle.d.ts +3 -0
- package/lib/code/DefaultHighlightStyle.d.ts.map +1 -0
- package/lib/code/DefaultHighlightStyle.js +98 -0
- package/lib/code/LezerHighlighter.d.ts +22 -0
- package/lib/code/LezerHighlighter.d.ts.map +1 -0
- package/lib/code/LezerHighlighter.js +91 -0
- package/lib/code/diff.d.ts +31 -0
- package/lib/code/diff.d.ts.map +1 -0
- package/lib/code/diff.js +236 -0
- package/lib/code/extractRange.d.ts +17 -0
- package/lib/code/extractRange.d.ts.map +1 -0
- package/lib/code/extractRange.js +102 -0
- package/lib/code/index.d.ts +14 -0
- package/lib/code/index.d.ts.map +1 -0
- package/lib/code/index.js +14 -0
- package/lib/components/Bezier.d.ts +22 -0
- package/lib/components/Bezier.d.ts.map +1 -0
- package/lib/components/Bezier.js +80 -0
- package/lib/components/Camera.d.ts +172 -0
- package/lib/components/Camera.d.ts.map +1 -0
- package/lib/components/Camera.js +239 -0
- package/lib/components/Circle.d.ts +191 -0
- package/lib/components/Circle.d.ts.map +1 -0
- package/lib/components/Circle.js +178 -0
- package/lib/components/Code.d.ts +238 -0
- package/lib/components/Code.d.ts.map +1 -0
- package/lib/components/Code.js +331 -0
- package/lib/components/CodeBlock.d.ts +131 -0
- package/lib/components/CodeBlock.d.ts.map +1 -0
- package/lib/components/CodeBlock.js +462 -0
- package/lib/components/CubicBezier.d.ts +69 -0
- package/lib/components/CubicBezier.d.ts.map +1 -0
- package/lib/components/CubicBezier.js +81 -0
- package/lib/components/Curve.d.ts +202 -0
- package/lib/components/Curve.d.ts.map +1 -0
- package/lib/components/Curve.js +284 -0
- package/lib/components/Grid.d.ts +75 -0
- package/lib/components/Grid.d.ts.map +1 -0
- package/lib/components/Grid.js +91 -0
- package/lib/components/Icon.d.ts +58 -0
- package/lib/components/Icon.d.ts.map +1 -0
- package/lib/components/Icon.js +58 -0
- package/lib/components/Img.d.ts +116 -0
- package/lib/components/Img.d.ts.map +1 -0
- package/lib/components/Img.js +233 -0
- package/lib/components/Knot.d.ts +89 -0
- package/lib/components/Knot.d.ts.map +1 -0
- package/lib/components/Knot.js +68 -0
- package/lib/components/Latex.d.ts +49 -0
- package/lib/components/Latex.d.ts.map +1 -0
- package/lib/components/Latex.js +206 -0
- package/lib/components/Layout.d.ts +423 -0
- package/lib/components/Layout.d.ts.map +1 -0
- package/lib/components/Layout.js +699 -0
- package/lib/components/Line.d.ts +158 -0
- package/lib/components/Line.d.ts.map +1 -0
- package/lib/components/Line.js +315 -0
- package/lib/components/Node.d.ts +843 -0
- package/lib/components/Node.d.ts.map +1 -0
- package/lib/components/Node.js +1335 -0
- package/lib/components/Path.d.ts +18 -0
- package/lib/components/Path.d.ts.map +1 -0
- package/lib/components/Path.js +96 -0
- package/lib/components/Polygon.d.ts +157 -0
- package/lib/components/Polygon.d.ts.map +1 -0
- package/lib/components/Polygon.js +183 -0
- package/lib/components/QuadBezier.d.ts +61 -0
- package/lib/components/QuadBezier.d.ts.map +1 -0
- package/lib/components/QuadBezier.js +76 -0
- package/lib/components/Ray.d.ts +60 -0
- package/lib/components/Ray.d.ts.map +1 -0
- package/lib/components/Ray.js +95 -0
- package/lib/components/Rect.d.ts +112 -0
- package/lib/components/Rect.d.ts.map +1 -0
- package/lib/components/Rect.js +76 -0
- package/lib/components/SVG.d.ts +175 -0
- package/lib/components/SVG.d.ts.map +1 -0
- package/lib/components/SVG.js +582 -0
- package/lib/components/Shape.d.ts +39 -0
- package/lib/components/Shape.d.ts.map +1 -0
- package/lib/components/Shape.js +134 -0
- package/lib/components/Spline.d.ts +87 -0
- package/lib/components/Spline.d.ts.map +1 -0
- package/lib/components/Spline.js +230 -0
- package/lib/components/Txt.d.ts +51 -0
- package/lib/components/Txt.d.ts.map +1 -0
- package/lib/components/Txt.js +172 -0
- package/lib/components/TxtLeaf.d.ts +20 -0
- package/lib/components/TxtLeaf.d.ts.map +1 -0
- package/lib/components/TxtLeaf.js +185 -0
- package/lib/components/Video.d.ts +110 -0
- package/lib/components/Video.d.ts.map +1 -0
- package/lib/components/Video.js +267 -0
- package/lib/components/View2D.d.ts +25 -0
- package/lib/components/View2D.d.ts.map +1 -0
- package/lib/components/View2D.js +85 -0
- package/lib/components/index.d.ts +27 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +27 -0
- package/lib/components/types.d.ts +17 -0
- package/lib/components/types.d.ts.map +1 -0
- package/lib/components/types.js +2 -0
- package/lib/curves/ArcSegment.d.ts +26 -0
- package/lib/curves/ArcSegment.d.ts.map +1 -0
- package/lib/curves/ArcSegment.js +116 -0
- package/lib/curves/CircleSegment.d.ts +18 -0
- package/lib/curves/CircleSegment.d.ts.map +1 -0
- package/lib/curves/CircleSegment.js +60 -0
- package/lib/curves/CubicBezierSegment.d.ts +18 -0
- package/lib/curves/CubicBezierSegment.d.ts.map +1 -0
- package/lib/curves/CubicBezierSegment.js +60 -0
- package/lib/curves/CurveDrawingInfo.d.ts +11 -0
- package/lib/curves/CurveDrawingInfo.d.ts.map +1 -0
- package/lib/curves/CurveDrawingInfo.js +2 -0
- package/lib/curves/CurvePoint.d.ts +15 -0
- package/lib/curves/CurvePoint.d.ts.map +1 -0
- package/lib/curves/CurvePoint.js +2 -0
- package/lib/curves/CurveProfile.d.ts +7 -0
- package/lib/curves/CurveProfile.d.ts.map +1 -0
- package/lib/curves/CurveProfile.js +2 -0
- package/lib/curves/KnotInfo.d.ts +12 -0
- package/lib/curves/KnotInfo.d.ts.map +1 -0
- package/lib/curves/KnotInfo.js +2 -0
- package/lib/curves/LineSegment.d.ts +16 -0
- package/lib/curves/LineSegment.d.ts.map +1 -0
- package/lib/curves/LineSegment.js +51 -0
- package/lib/curves/Polynomial.d.ts +118 -0
- package/lib/curves/Polynomial.d.ts.map +1 -0
- package/lib/curves/Polynomial.js +263 -0
- package/lib/curves/Polynomial2D.d.ts +22 -0
- package/lib/curves/Polynomial2D.d.ts.map +1 -0
- package/lib/curves/Polynomial2D.js +51 -0
- package/lib/curves/PolynomialSegment.d.ts +39 -0
- package/lib/curves/PolynomialSegment.d.ts.map +1 -0
- package/lib/curves/PolynomialSegment.js +88 -0
- package/lib/curves/QuadBezierSegment.d.ts +17 -0
- package/lib/curves/QuadBezierSegment.d.ts.map +1 -0
- package/lib/curves/QuadBezierSegment.js +53 -0
- package/lib/curves/Segment.d.ts +9 -0
- package/lib/curves/Segment.d.ts.map +1 -0
- package/lib/curves/Segment.js +3 -0
- package/lib/curves/UniformPolynomialCurveSampler.d.ts +43 -0
- package/lib/curves/UniformPolynomialCurveSampler.d.ts.map +1 -0
- package/lib/curves/UniformPolynomialCurveSampler.js +74 -0
- package/lib/curves/createCurveProfileLerp.d.ts +32 -0
- package/lib/curves/createCurveProfileLerp.d.ts.map +1 -0
- package/lib/curves/createCurveProfileLerp.js +351 -0
- package/lib/curves/getBezierSplineProfile.d.ts +12 -0
- package/lib/curves/getBezierSplineProfile.d.ts.map +1 -0
- package/lib/curves/getBezierSplineProfile.js +140 -0
- package/lib/curves/getCircleProfile.d.ts +4 -0
- package/lib/curves/getCircleProfile.d.ts.map +1 -0
- package/lib/curves/getCircleProfile.js +44 -0
- package/lib/curves/getPathProfile.d.ts +3 -0
- package/lib/curves/getPathProfile.d.ts.map +1 -0
- package/lib/curves/getPathProfile.js +128 -0
- package/lib/curves/getPointAtDistance.d.ts +4 -0
- package/lib/curves/getPointAtDistance.d.ts.map +1 -0
- package/lib/curves/getPointAtDistance.js +15 -0
- package/lib/curves/getPolylineProfile.d.ts +4 -0
- package/lib/curves/getPolylineProfile.d.ts.map +1 -0
- package/lib/curves/getPolylineProfile.js +58 -0
- package/lib/curves/getRectProfile.d.ts +4 -0
- package/lib/curves/getRectProfile.d.ts.map +1 -0
- package/lib/curves/getRectProfile.js +57 -0
- package/lib/curves/index.d.ts +17 -0
- package/lib/curves/index.d.ts.map +1 -0
- package/lib/curves/index.js +17 -0
- package/lib/decorators/canvasStyleSignal.d.ts +5 -0
- package/lib/decorators/canvasStyleSignal.d.ts.map +1 -0
- package/lib/decorators/canvasStyleSignal.js +12 -0
- package/lib/decorators/colorSignal.d.ts +2 -0
- package/lib/decorators/colorSignal.d.ts.map +1 -0
- package/lib/decorators/colorSignal.js +9 -0
- package/lib/decorators/compound.d.ts +27 -0
- package/lib/decorators/compound.d.ts.map +1 -0
- package/lib/decorators/compound.js +49 -0
- package/lib/decorators/computed.d.ts +9 -0
- package/lib/decorators/computed.d.ts.map +1 -0
- package/lib/decorators/computed.js +18 -0
- package/lib/decorators/defaultStyle.d.ts +2 -0
- package/lib/decorators/defaultStyle.d.ts.map +1 -0
- package/lib/decorators/defaultStyle.js +13 -0
- package/lib/decorators/filtersSignal.d.ts +11 -0
- package/lib/decorators/filtersSignal.d.ts.map +1 -0
- package/lib/decorators/filtersSignal.js +73 -0
- package/lib/decorators/index.d.ts +11 -0
- package/lib/decorators/index.d.ts.map +1 -0
- package/lib/decorators/index.js +11 -0
- package/lib/decorators/initializers.d.ts +4 -0
- package/lib/decorators/initializers.d.ts.map +1 -0
- package/lib/decorators/initializers.js +27 -0
- package/lib/decorators/nodeName.d.ts +9 -0
- package/lib/decorators/nodeName.d.ts.map +1 -0
- package/lib/decorators/nodeName.js +13 -0
- package/lib/decorators/signal.d.ts +183 -0
- package/lib/decorators/signal.d.ts.map +1 -0
- package/lib/decorators/signal.js +285 -0
- package/lib/decorators/spacingSignal.d.ts +2 -0
- package/lib/decorators/spacingSignal.d.ts.map +1 -0
- package/lib/decorators/spacingSignal.js +15 -0
- package/lib/decorators/vector2Signal.d.ts +8 -0
- package/lib/decorators/vector2Signal.d.ts.map +1 -0
- package/lib/decorators/vector2Signal.js +15 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +9 -0
- package/lib/jsx-dev-runtime.d.ts +3 -0
- package/lib/jsx-dev-runtime.d.ts.map +1 -0
- package/lib/jsx-dev-runtime.js +3 -0
- package/lib/jsx-runtime.d.ts +12 -0
- package/lib/jsx-runtime.d.ts.map +1 -0
- package/lib/jsx-runtime.js +23 -0
- package/lib/partials/Filter.d.ts +82 -0
- package/lib/partials/Filter.d.ts.map +1 -0
- package/lib/partials/Filter.js +137 -0
- package/lib/partials/Gradient.d.ts +31 -0
- package/lib/partials/Gradient.d.ts.map +1 -0
- package/lib/partials/Gradient.js +63 -0
- package/lib/partials/Pattern.d.ts +13 -0
- package/lib/partials/Pattern.d.ts.map +1 -0
- package/lib/partials/Pattern.js +27 -0
- package/lib/partials/ShaderConfig.d.ts +81 -0
- package/lib/partials/ShaderConfig.d.ts.map +1 -0
- package/lib/partials/ShaderConfig.js +25 -0
- package/lib/partials/index.d.ts +5 -0
- package/lib/partials/index.d.ts.map +1 -0
- package/lib/partials/index.js +5 -0
- package/lib/partials/types.d.ts +35 -0
- package/lib/partials/types.d.ts.map +1 -0
- package/lib/partials/types.js +2 -0
- package/lib/scenes/Scene2D.d.ts +23 -0
- package/lib/scenes/Scene2D.d.ts.map +1 -0
- package/lib/scenes/Scene2D.js +152 -0
- package/lib/scenes/index.d.ts +4 -0
- package/lib/scenes/index.d.ts.map +1 -0
- package/lib/scenes/index.js +4 -0
- package/lib/scenes/makeScene2D.d.ts +5 -0
- package/lib/scenes/makeScene2D.d.ts.map +1 -0
- package/lib/scenes/makeScene2D.js +12 -0
- package/lib/scenes/useScene2D.d.ts +3 -0
- package/lib/scenes/useScene2D.d.ts.map +1 -0
- package/lib/scenes/useScene2D.js +5 -0
- package/lib/tsconfig.build.tsbuildinfo +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/utils/CanvasUtils.d.ts +21 -0
- package/lib/utils/CanvasUtils.d.ts.map +1 -0
- package/lib/utils/CanvasUtils.js +138 -0
- package/lib/utils/diff.d.ts +31 -0
- package/lib/utils/diff.d.ts.map +1 -0
- package/lib/utils/diff.js +97 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +4 -0
- package/lib/utils/is.d.ts +8 -0
- package/lib/utils/is.d.ts.map +1 -0
- package/lib/utils/is.js +10 -0
- package/lib/utils/makeSignalExtensions.d.ts +4 -0
- package/lib/utils/makeSignalExtensions.d.ts.map +1 -0
- package/lib/utils/makeSignalExtensions.js +20 -0
- package/lib/utils/withDefaults.d.ts +20 -0
- package/lib/utils/withDefaults.d.ts.map +1 -0
- package/lib/utils/withDefaults.js +23 -0
- package/package.json +54 -0
- package/src/editor/NodeInspectorConfig.tsx +76 -0
- package/src/editor/PreviewOverlayConfig.tsx +65 -0
- package/src/editor/Provider.tsx +109 -0
- package/src/editor/SceneGraphTabConfig.tsx +87 -0
- package/src/editor/icons/CircleIcon.tsx +7 -0
- package/src/editor/icons/CodeBlockIcon.tsx +8 -0
- package/src/editor/icons/CurveIcon.tsx +7 -0
- package/src/editor/icons/GridIcon.tsx +7 -0
- package/src/editor/icons/IconMap.ts +35 -0
- package/src/editor/icons/ImgIcon.tsx +8 -0
- package/src/editor/icons/LayoutIcon.tsx +9 -0
- package/src/editor/icons/LineIcon.tsx +7 -0
- package/src/editor/icons/NodeIcon.tsx +7 -0
- package/src/editor/icons/RayIcon.tsx +7 -0
- package/src/editor/icons/RectIcon.tsx +7 -0
- package/src/editor/icons/ShapeIcon.tsx +7 -0
- package/src/editor/icons/TxtIcon.tsx +8 -0
- package/src/editor/icons/VideoIcon.tsx +7 -0
- package/src/editor/icons/View2DIcon.tsx +10 -0
- package/src/editor/index.css +0 -0
- package/src/editor/index.ts +19 -0
- package/src/editor/shortcuts.ts +27 -0
- package/src/editor/tree/DetachedRoot.tsx +27 -0
- package/src/editor/tree/NodeElement.tsx +72 -0
- package/src/editor/tree/TreeElement.tsx +70 -0
- package/src/editor/tree/TreeRoot.tsx +10 -0
- package/src/editor/tree/ViewRoot.tsx +20 -0
- package/src/editor/tree/index.module.scss +45 -0
- package/src/editor/tree/index.ts +4 -0
- package/src/editor/tree/navigation.ts +145 -0
- package/src/editor/tsconfig.build.json +5 -0
- package/src/editor/tsconfig.json +12 -0
- package/src/editor/tsdoc.json +4 -0
- package/src/editor/utils/SignalSet.ts +37 -0
- package/src/editor/utils/index.ts +1 -0
- package/src/editor/vite-env.d.ts +1 -0
- package/src/lib/code/CodeCursor.ts +468 -0
- package/src/lib/code/CodeDiffer.ts +77 -0
- package/src/lib/code/CodeFragment.ts +96 -0
- package/src/lib/code/CodeHighlighter.ts +73 -0
- package/src/lib/code/CodeMetrics.ts +47 -0
- package/src/lib/code/CodeRange.test.ts +113 -0
- package/src/lib/code/CodeRange.ts +222 -0
- package/src/lib/code/CodeScope.ts +100 -0
- package/src/lib/code/CodeSelection.ts +28 -0
- package/src/lib/code/CodeSignal.ts +348 -0
- package/src/lib/code/CodeTokenizer.ts +54 -0
- package/src/lib/code/DefaultHighlightStyle.ts +98 -0
- package/src/lib/code/LezerHighlighter.ts +113 -0
- package/src/lib/code/diff.test.ts +311 -0
- package/src/lib/code/diff.ts +319 -0
- package/src/lib/code/extractRange.ts +125 -0
- package/src/lib/code/index.ts +13 -0
- package/src/lib/components/Bezier.ts +103 -0
- package/src/lib/components/Camera.ts +359 -0
- package/src/lib/components/Circle.ts +269 -0
- package/src/lib/components/Code.ts +532 -0
- package/src/lib/components/CodeBlock.ts +581 -0
- package/src/lib/components/CubicBezier.ts +115 -0
- package/src/lib/components/Curve.ts +455 -0
- package/src/lib/components/Grid.ts +134 -0
- package/src/lib/components/Icon.ts +95 -0
- package/src/lib/components/Img.ts +305 -0
- package/src/lib/components/Knot.ts +156 -0
- package/src/lib/components/Latex.ts +249 -0
- package/src/lib/components/Layout.ts +1071 -0
- package/src/lib/components/Line.ts +394 -0
- package/src/lib/components/Node.ts +1949 -0
- package/src/lib/components/Path.ts +132 -0
- package/src/lib/components/Polygon.ts +238 -0
- package/src/lib/components/QuadBezier.ts +103 -0
- package/src/lib/components/Ray.ts +126 -0
- package/src/lib/components/Rect.ts +186 -0
- package/src/lib/components/SVG.ts +788 -0
- package/src/lib/components/Shape.ts +146 -0
- package/src/lib/components/Spline.ts +318 -0
- package/src/lib/components/Txt.test.tsx +81 -0
- package/src/lib/components/Txt.ts +204 -0
- package/src/lib/components/TxtLeaf.ts +210 -0
- package/src/lib/components/Video.ts +368 -0
- package/src/lib/components/View2D.ts +85 -0
- package/src/lib/components/__logs__/image-without-source.md +17 -0
- package/src/lib/components/__logs__/line-without-points.md +30 -0
- package/src/lib/components/__logs__/reactive-playback-rate.md +21 -0
- package/src/lib/components/__logs__/spline-with-insufficient-knots.md +24 -0
- package/src/lib/components/__tests__/children.test.tsx +142 -0
- package/src/lib/components/__tests__/clone.test.tsx +126 -0
- package/src/lib/components/__tests__/generatorTest.ts +27 -0
- package/src/lib/components/__tests__/mockScene2D.ts +50 -0
- package/src/lib/components/__tests__/query.test.tsx +122 -0
- package/src/lib/components/__tests__/state.test.tsx +60 -0
- package/src/lib/components/index.ts +26 -0
- package/src/lib/components/types.ts +35 -0
- package/src/lib/curves/ArcSegment.ts +155 -0
- package/src/lib/curves/CircleSegment.ts +77 -0
- package/src/lib/curves/CubicBezierSegment.ts +78 -0
- package/src/lib/curves/CurveDrawingInfo.ts +11 -0
- package/src/lib/curves/CurvePoint.ts +15 -0
- package/src/lib/curves/CurveProfile.ts +7 -0
- package/src/lib/curves/KnotInfo.ts +10 -0
- package/src/lib/curves/LineSegment.ts +62 -0
- package/src/lib/curves/Polynomial.ts +355 -0
- package/src/lib/curves/Polynomial2D.ts +62 -0
- package/src/lib/curves/PolynomialSegment.ts +124 -0
- package/src/lib/curves/QuadBezierSegment.ts +64 -0
- package/src/lib/curves/Segment.ts +17 -0
- package/src/lib/curves/UniformPolynomialCurveSampler.ts +93 -0
- package/src/lib/curves/createCurveProfileLerp.ts +471 -0
- package/src/lib/curves/getBezierSplineProfile.ts +227 -0
- package/src/lib/curves/getCircleProfile.ts +86 -0
- package/src/lib/curves/getPathProfile.ts +177 -0
- package/src/lib/curves/getPointAtDistance.ts +21 -0
- package/src/lib/curves/getPolylineProfile.test.ts +21 -0
- package/src/lib/curves/getPolylineProfile.ts +88 -0
- package/src/lib/curves/getRectProfile.ts +138 -0
- package/src/lib/curves/index.ts +16 -0
- package/src/lib/decorators/canvasStyleSignal.ts +15 -0
- package/src/lib/decorators/colorSignal.ts +9 -0
- package/src/lib/decorators/compound.ts +85 -0
- package/src/lib/decorators/computed.ts +18 -0
- package/src/lib/decorators/defaultStyle.ts +15 -0
- package/src/lib/decorators/filtersSignal.ts +133 -0
- package/src/lib/decorators/index.ts +10 -0
- package/src/lib/decorators/initializers.ts +34 -0
- package/src/lib/decorators/nodeName.ts +13 -0
- package/src/lib/decorators/signal.test.ts +89 -0
- package/src/lib/decorators/signal.ts +348 -0
- package/src/lib/decorators/spacingSignal.ts +15 -0
- package/src/lib/decorators/vector2Signal.ts +35 -0
- package/src/lib/globals.d.ts +3 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/jsx-dev-runtime.ts +2 -0
- package/src/lib/jsx-runtime.ts +45 -0
- package/src/lib/parse-svg-path.d.ts +14 -0
- package/src/lib/partials/Filter.ts +185 -0
- package/src/lib/partials/Gradient.ts +103 -0
- package/src/lib/partials/Pattern.ts +35 -0
- package/src/lib/partials/ShaderConfig.ts +122 -0
- package/src/lib/partials/index.ts +4 -0
- package/src/lib/partials/types.ts +58 -0
- package/src/lib/scenes/Scene2D.ts +195 -0
- package/src/lib/scenes/index.ts +3 -0
- package/src/lib/scenes/makeScene2D.ts +19 -0
- package/src/lib/scenes/useScene2D.ts +6 -0
- package/src/lib/tsconfig.build.json +12 -0
- package/src/lib/tsconfig.json +14 -0
- package/src/lib/tsdoc.json +4 -0
- package/src/lib/utils/CanvasUtils.ts +306 -0
- package/src/lib/utils/diff.test.ts +453 -0
- package/src/lib/utils/diff.ts +148 -0
- package/src/lib/utils/index.ts +3 -0
- package/src/lib/utils/is.ts +11 -0
- package/src/lib/utils/makeSignalExtensions.ts +29 -0
- package/src/lib/utils/withDefaults.tsx +26 -0
- package/src/tsconfig.base.json +18 -0
- package/src/tsconfig.build.json +8 -0
- package/src/tsconfig.json +5 -0
- package/tsconfig.project.json +7 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
interface TransformDiff<T> {
|
|
2
|
+
inserted: TransformDiffItem<T>[];
|
|
3
|
+
deleted: TransformDiffItem<T>[];
|
|
4
|
+
transformed: TransformDiffItemTransformed<T>[];
|
|
5
|
+
}
|
|
6
|
+
interface TransformDiffItem<T> {
|
|
7
|
+
before?: T;
|
|
8
|
+
beforeIdIndex: number;
|
|
9
|
+
current: T;
|
|
10
|
+
currentIndex: number;
|
|
11
|
+
}
|
|
12
|
+
interface TransformDiffItemTransformed<T> {
|
|
13
|
+
insert: boolean;
|
|
14
|
+
remove: boolean;
|
|
15
|
+
from: TransformDiffItem<T>;
|
|
16
|
+
to: TransformDiffItem<T>;
|
|
17
|
+
}
|
|
18
|
+
interface ApplyTransformInserted<T> {
|
|
19
|
+
item: TransformDiffItem<T>;
|
|
20
|
+
order: number;
|
|
21
|
+
}
|
|
22
|
+
interface ApplyTransformResult<T> {
|
|
23
|
+
inserted: ApplyTransformInserted<T>[];
|
|
24
|
+
}
|
|
25
|
+
interface Idable {
|
|
26
|
+
id: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function getTransformDiff<T extends Idable>(from: T[], to: T[]): TransformDiff<T>;
|
|
29
|
+
export declare function applyTransformDiff<T extends Idable>(current: T[], diff: TransformDiff<T>, cloner: (original: T) => T): ApplyTransformResult<T>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/lib/utils/diff.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa,CAAC,CAAC;IACvB,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;IACjC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChC,WAAW,EAAE,4BAA4B,CAAC,CAAC,CAAC,EAAE,CAAC;CAChD;AAED,UAAU,iBAAiB,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,4BAA4B,CAAC,CAAC;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC3B,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAC1B;AAED,UAAU,sBAAsB,CAAC,CAAC;IAChC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,oBAAoB,CAAC,CAAC;IAC9B,QAAQ,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAAE,CAAC;CACvC;AAED,UAAU,MAAM;IACd,EAAE,EAAE,MAAM,CAAC;CACZ;AAsBD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,IAAI,EAAE,CAAC,EAAE,EACT,EAAE,EAAE,CAAC,EAAE,GACN,aAAa,CAAC,CAAC,CAAC,CA0ClB;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EACjD,OAAO,EAAE,CAAC,EAAE,EACZ,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GACzB,oBAAoB,CAAC,CAAC,CAAC,CA2CzB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
function getIdMap(list) {
|
|
2
|
+
const map = new Map();
|
|
3
|
+
let before = undefined;
|
|
4
|
+
for (const [index, current] of list.entries()) {
|
|
5
|
+
const currentArray = map.get(current.id) ?? [];
|
|
6
|
+
if (!map.has(current.id)) {
|
|
7
|
+
map.set(current.id, currentArray);
|
|
8
|
+
}
|
|
9
|
+
currentArray.push({
|
|
10
|
+
before,
|
|
11
|
+
current,
|
|
12
|
+
beforeIdIndex: before ? map.get(before.id).length - 1 : -1,
|
|
13
|
+
currentIndex: index,
|
|
14
|
+
});
|
|
15
|
+
before = current;
|
|
16
|
+
}
|
|
17
|
+
return map;
|
|
18
|
+
}
|
|
19
|
+
export function getTransformDiff(from, to) {
|
|
20
|
+
const diff = {
|
|
21
|
+
inserted: [],
|
|
22
|
+
deleted: [],
|
|
23
|
+
transformed: [],
|
|
24
|
+
};
|
|
25
|
+
const fromMap = getIdMap(from);
|
|
26
|
+
const toMap = getIdMap(to);
|
|
27
|
+
for (const [key, fromItem] of fromMap.entries()) {
|
|
28
|
+
const toItem = toMap.get(key);
|
|
29
|
+
if (toItem) {
|
|
30
|
+
toMap.delete(key);
|
|
31
|
+
for (let i = 0; i < Math.max(fromItem.length, toItem.length); i++) {
|
|
32
|
+
const insert = i >= fromItem.length;
|
|
33
|
+
const remove = i >= toItem.length;
|
|
34
|
+
const fromNode = !insert ? fromItem[i] : fromItem[fromItem.length - 1];
|
|
35
|
+
const toNode = !remove ? toItem[i] : toItem[toItem.length - 1];
|
|
36
|
+
diff.transformed.push({
|
|
37
|
+
insert,
|
|
38
|
+
remove,
|
|
39
|
+
from: fromNode,
|
|
40
|
+
to: toNode,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
for (const node of fromItem) {
|
|
46
|
+
diff.deleted.push(node);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const toItem of toMap.values()) {
|
|
51
|
+
for (const node of toItem) {
|
|
52
|
+
diff.inserted.push(node);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return diff;
|
|
56
|
+
}
|
|
57
|
+
export function applyTransformDiff(current, diff, cloner) {
|
|
58
|
+
function insert(item) {
|
|
59
|
+
let idIndex = -1;
|
|
60
|
+
const index = item.before
|
|
61
|
+
? current.findIndex(({ id }) => {
|
|
62
|
+
if (id === item.before?.id) {
|
|
63
|
+
idIndex++;
|
|
64
|
+
if (idIndex === item.beforeIdIndex)
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
})
|
|
69
|
+
: 0;
|
|
70
|
+
current.splice(index + 1, 0, item.current);
|
|
71
|
+
}
|
|
72
|
+
const result = {
|
|
73
|
+
inserted: diff.inserted.map(item => ({
|
|
74
|
+
item,
|
|
75
|
+
order: item.currentIndex,
|
|
76
|
+
})),
|
|
77
|
+
};
|
|
78
|
+
for (const item of diff.transformed) {
|
|
79
|
+
if (!item.insert)
|
|
80
|
+
continue;
|
|
81
|
+
const from = item.from;
|
|
82
|
+
item.from = {
|
|
83
|
+
...item.to,
|
|
84
|
+
current: cloner(from.current),
|
|
85
|
+
};
|
|
86
|
+
result.inserted.push({
|
|
87
|
+
item: item.from,
|
|
88
|
+
order: item.to.currentIndex,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
result.inserted.sort((a, b) => a.order - b.order);
|
|
92
|
+
for (const item of result.inserted) {
|
|
93
|
+
insert(item.item);
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlmZi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvdXRpbHMvZGlmZi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFpQ0EsU0FBUyxRQUFRLENBQW1CLElBQVM7SUFDM0MsTUFBTSxHQUFHLEdBQUcsSUFBSSxHQUFHLEVBQWtDLENBQUM7SUFDdEQsSUFBSSxNQUFNLEdBQWtCLFNBQVMsQ0FBQztJQUN0QyxLQUFLLE1BQU0sQ0FBQyxLQUFLLEVBQUUsT0FBTyxDQUFDLElBQUksSUFBSSxDQUFDLE9BQU8sRUFBRSxFQUFFLENBQUM7UUFDOUMsTUFBTSxZQUFZLEdBQUcsR0FBRyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxDQUFDO1FBQy9DLElBQUksQ0FBQyxHQUFHLENBQUMsR0FB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mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,MAAM,CAAC;AACrB,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './CanvasUtils';
|
|
2
|
+
export * from './is';
|
|
3
|
+
export * from './withDefaults';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3V0aWxzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMsTUFBTSxDQUFDO0FBQ3JCLGNBQWMsZ0JBQWdCLENBQUMifQ==
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a predicate that checks if the given object is an instance of the
|
|
3
|
+
* given class.
|
|
4
|
+
*
|
|
5
|
+
* @param klass - The class to check against.
|
|
6
|
+
*/
|
|
7
|
+
export declare function is<T>(klass: new (...args: any[]) => T): (object: any) => object is T;
|
|
8
|
+
//# sourceMappingURL=is.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../src/lib/utils/is.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAClB,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAC/B,CAAC,MAAM,EAAE,GAAG,KAAK,MAAM,IAAI,CAAC,CAE9B"}
|
package/lib/utils/is.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a predicate that checks if the given object is an instance of the
|
|
3
|
+
* given class.
|
|
4
|
+
*
|
|
5
|
+
* @param klass - The class to check against.
|
|
6
|
+
*/
|
|
7
|
+
export function is(klass) {
|
|
8
|
+
return (object) => object instanceof klass;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3V0aWxzL2lzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7OztHQUtHO0FBQ0gsTUFBTSxVQUFVLEVBQUUsQ0FDaEIsS0FBZ0M7SUFFaEMsT0FBTyxDQUFDLE1BQU0sRUFBZSxFQUFFLENBQUMsTUFBTSxZQUFZLEtBQUssQ0FBQztBQUMxRCxDQUFDIn0=
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SignalExtensions } from '@efxlab/motion-canvas-core';
|
|
2
|
+
import { PropertyMetadata } from '../decorators';
|
|
3
|
+
export declare function makeSignalExtensions<TSetterValue, TValue extends TSetterValue>(meta?: Partial<PropertyMetadata<TValue>>, owner?: any, name?: string): Partial<SignalExtensions<TSetterValue, TValue>>;
|
|
4
|
+
//# sourceMappingURL=makeSignalExtensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeSignalExtensions.d.ts","sourceRoot":"","sources":["../../src/lib/utils/makeSignalExtensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAa,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAE/C,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,SAAS,YAAY,EAC5E,IAAI,GAAE,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAM,EAC5C,KAAK,CAAC,EAAE,GAAG,EACX,IAAI,CAAC,EAAE,MAAM,mDAsBd"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { capitalize } from '@efxlab/motion-canvas-core';
|
|
2
|
+
export function makeSignalExtensions(meta = {}, owner, name) {
|
|
3
|
+
const extensions = {};
|
|
4
|
+
if (name && owner) {
|
|
5
|
+
const setter = meta.setter ?? owner?.[`set${capitalize(name)}`];
|
|
6
|
+
if (setter) {
|
|
7
|
+
extensions.setter = setter.bind(owner);
|
|
8
|
+
}
|
|
9
|
+
const getter = meta.getter ?? owner?.[`get${capitalize(name)}`];
|
|
10
|
+
if (getter) {
|
|
11
|
+
extensions.getter = getter.bind(owner);
|
|
12
|
+
}
|
|
13
|
+
const tweener = meta.tweener ?? owner?.[`tween${capitalize(name)}`];
|
|
14
|
+
if (tweener) {
|
|
15
|
+
extensions.tweener = tweener.bind(owner);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return extensions;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFrZVNpZ25hbEV4dGVuc2lvbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3V0aWxzL21ha2VTaWduYWxFeHRlbnNpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBbUIsVUFBVSxFQUFDLE1BQU0sNEJBQTRCLENBQUM7QUFHeEUsTUFBTSxVQUFVLG9CQUFvQixDQUNsQyxPQUEwQyxFQUFFLEVBQzVDLEtBQVcsRUFDWCxJQUFhO0lBRWIsTUFBTSxVQUFVLEdBQW9ELEVBQUUsQ0FBQztJQUV2RSxJQUFJLElBQUksSUFBSSxLQUFLLEVBQUUsQ0FBQztRQUNsQixNQUFNLE1BQU0sR0FBRyxJQUFJLENBQUMsTUFBTSxJQUFJLEtBQUssRUFBRSxDQUFDLE1BQU0sVUFBVSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQztRQUNoRSxJQUFJLE1BQU0sRUFBRSxDQUFDO1lBQ1gsVUFBVSxDQUFDLE1BQU0sR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDO1FBQ3pDLENBQUM7UUFFRCxNQUFNLE1BQU0sR0FBRyxJQUFJLENBQUMsTUFBTSxJQUFJLEtBQUssRUFBRSxDQUFDLE1BQU0sVUFBVSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQztRQUNoRSxJQUFJLE1BQU0sRUFBRSxDQUFDO1lBQ1gsVUFBVSxDQUFDLE1BQU0sR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDO1FBQ3pDLENBQUM7UUFFRCxNQUFNLE9BQU8sR0FBRyxJQUFJLENBQUMsT0FBTyxJQUFJLEtBQUssRUFBRSxDQUFDLFFBQVEsVUFBVSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQztRQUNwRSxJQUFJLE9BQU8sRUFBRSxDQUFDO1lBQ1osVUFBVSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDO1FBQzNDLENBQUM7SUFDSCxDQUFDO0lBRUQsT0FBTyxVQUFVLENBQUM7QUFDcEIsQ0FBQyJ9
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FunctionComponent, NodeConstructor, PropsOf } from '../components';
|
|
2
|
+
/**
|
|
3
|
+
* Create a higher order component with default props.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const MyTxt = withDefaults(Txt, {
|
|
8
|
+
* fill: '#f3303f',
|
|
9
|
+
* });
|
|
10
|
+
*
|
|
11
|
+
* // ...
|
|
12
|
+
*
|
|
13
|
+
* view.add(<MyTxt>Hello, World!</MyTxt>);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param component - The base class or function component to wrap.
|
|
17
|
+
* @param defaults - The default props to apply.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withDefaults<T extends FunctionComponent | NodeConstructor>(component: T, defaults: PropsOf<T>): (props: PropsOf<T>) => import("../components").Node;
|
|
20
|
+
//# sourceMappingURL=withDefaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withDefaults.d.ts","sourceRoot":"","sources":["../../src/lib/utils/withDefaults.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,eAAe,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE1E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,iBAAiB,GAAG,eAAe,EACxE,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,IAGZ,OAAO,OAAO,CAAC,CAAC,CAAC,kCAC1B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@efxlab/motion-canvas-2d/lib/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Create a higher order component with default props.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const MyTxt = withDefaults(Txt, {
|
|
8
|
+
* fill: '#f3303f',
|
|
9
|
+
* });
|
|
10
|
+
*
|
|
11
|
+
* // ...
|
|
12
|
+
*
|
|
13
|
+
* view.add(<MyTxt>Hello, World!</MyTxt>);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param component - The base class or function component to wrap.
|
|
17
|
+
* @param defaults - The default props to apply.
|
|
18
|
+
*/
|
|
19
|
+
export function withDefaults(component, defaults) {
|
|
20
|
+
const Node = component;
|
|
21
|
+
return (props) => _jsx(Node, { ...defaults, ...props });
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2l0aERlZmF1bHRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi91dGlscy93aXRoRGVmYXVsdHMudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTs7Ozs7Ozs7Ozs7Ozs7OztHQWdCRztBQUNILE1BQU0sVUFBVSxZQUFZLENBQzFCLFNBQVksRUFDWixRQUFvQjtJQUVwQixNQUFNLElBQUksR0FBRyxTQUFnQixDQUFDO0lBQzlCLE9BQU8sQ0FBQyxLQUFpQixFQUFFLEVBQUUsQ0FBQyxLQUFDLElBQUksT0FBSyxRQUFRLEtBQU0sS0FBSyxHQUFJLENBQUM7QUFDbEUsQ0FBQyJ9
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@efxlab/motion-canvas-2d",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "A 2D renderer for Motion Canvas",
|
|
5
|
+
"author": "motion-canvas",
|
|
6
|
+
"homepage": "https://motioncanvas.io/",
|
|
7
|
+
"bugs": "https://github.com/motion-canvas/motion-canvas/issues",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"main": "lib/index.js",
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"dev": "tspc -p src/lib -w",
|
|
16
|
+
"build": "npm run build-lib && npm run build-editor",
|
|
17
|
+
"build-lib": "tspc -p src/lib/tsconfig.build.json",
|
|
18
|
+
"build-editor": "rollup -c rollup.editor.mjs",
|
|
19
|
+
"bundle": "rollup -c rollup.config.mjs",
|
|
20
|
+
"test": "vitest"
|
|
21
|
+
},
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/electroheadfx/efx-motion-canvas.git"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"lib",
|
|
29
|
+
"editor",
|
|
30
|
+
"src",
|
|
31
|
+
"tsconfig.project.json"
|
|
32
|
+
],
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@efxlab/motion-canvas-internal": "workspace:*",
|
|
35
|
+
"@efxlab/motion-canvas-ui": "workspace:*",
|
|
36
|
+
"@preact/signals": "^1.2.1",
|
|
37
|
+
"@types/node": "^25.2.3",
|
|
38
|
+
"clsx": "^2.0.0",
|
|
39
|
+
"jsdom": "^22.1.0",
|
|
40
|
+
"preact": "10.19.3",
|
|
41
|
+
"ts-patch": "^3.3.0",
|
|
42
|
+
"vitest": "^0.34.6"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@codemirror/language": "^6.10.1",
|
|
46
|
+
"@efxlab/motion-canvas-core": "workspace:*",
|
|
47
|
+
"@lezer/common": "^1.2.1",
|
|
48
|
+
"@lezer/highlight": "^1.2.0",
|
|
49
|
+
"code-fns": "^0.8.2",
|
|
50
|
+
"escape-string-regexp": "^5.0.0",
|
|
51
|
+
"mathjax-full": "^3.2.2",
|
|
52
|
+
"parse-svg-path": "^0.1.2"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoField,
|
|
3
|
+
Button,
|
|
4
|
+
Group,
|
|
5
|
+
Label,
|
|
6
|
+
Pane,
|
|
7
|
+
PluginInspectorConfig,
|
|
8
|
+
Separator,
|
|
9
|
+
UnknownField,
|
|
10
|
+
findAndOpenFirstUserFile,
|
|
11
|
+
useApplication,
|
|
12
|
+
} from '@efxlab/motion-canvas-ui';
|
|
13
|
+
import {useComputed} from '@preact/signals';
|
|
14
|
+
import {NodeInspectorKey, usePluginState} from './Provider';
|
|
15
|
+
|
|
16
|
+
function Component() {
|
|
17
|
+
const {inspection} = useApplication();
|
|
18
|
+
const {scene, afterRender} = usePluginState();
|
|
19
|
+
const node = useComputed(() => {
|
|
20
|
+
afterRender.value;
|
|
21
|
+
const {payload} = inspection.value;
|
|
22
|
+
return scene.value?.getNode(payload as string);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const attributes = useComputed(() => {
|
|
26
|
+
afterRender.value;
|
|
27
|
+
const currentNode = node.value;
|
|
28
|
+
const attributes: [string, unknown][] = [];
|
|
29
|
+
|
|
30
|
+
if (currentNode) {
|
|
31
|
+
for (const {key, meta, signal} of currentNode) {
|
|
32
|
+
if (!meta.inspectable) continue;
|
|
33
|
+
attributes.push([key, signal()]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return attributes;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const stack = node.value?.creationStack;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Pane title="Node Inspector" id="node-inspector-pane">
|
|
44
|
+
<Separator size={1} />
|
|
45
|
+
{stack && (
|
|
46
|
+
<Group>
|
|
47
|
+
<Label />
|
|
48
|
+
<Button onClick={() => findAndOpenFirstUserFile(stack)} main>
|
|
49
|
+
GO TO SOURCE
|
|
50
|
+
</Button>
|
|
51
|
+
</Group>
|
|
52
|
+
)}
|
|
53
|
+
<Group>
|
|
54
|
+
<Label>key</Label>
|
|
55
|
+
<UnknownField value={inspection.value.payload} />
|
|
56
|
+
</Group>
|
|
57
|
+
{!node.value && (
|
|
58
|
+
<Group>
|
|
59
|
+
<Label />
|
|
60
|
+
Couldn't find the node. It may have been deleted or doesn't exist yet.
|
|
61
|
+
</Group>
|
|
62
|
+
)}
|
|
63
|
+
{attributes.value.map(([key, value]) => (
|
|
64
|
+
<Group key={key}>
|
|
65
|
+
<Label>{key}</Label>
|
|
66
|
+
<AutoField value={value} />
|
|
67
|
+
</Group>
|
|
68
|
+
))}
|
|
69
|
+
</Pane>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const NodeInspectorConfig: PluginInspectorConfig = {
|
|
74
|
+
key: NodeInspectorKey,
|
|
75
|
+
component: Component,
|
|
76
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {Vector2} from '@efxlab/motion-canvas-core';
|
|
2
|
+
import {
|
|
3
|
+
MouseButton,
|
|
4
|
+
OverlayWrapper,
|
|
5
|
+
PluginOverlayConfig,
|
|
6
|
+
useViewportContext,
|
|
7
|
+
useViewportMatrix,
|
|
8
|
+
} from '@efxlab/motion-canvas-ui';
|
|
9
|
+
import {ComponentChildren} from 'preact';
|
|
10
|
+
import {usePluginState} from './Provider';
|
|
11
|
+
|
|
12
|
+
function Component({children}: {children?: ComponentChildren}) {
|
|
13
|
+
const state = useViewportContext();
|
|
14
|
+
const {scene, selectNode} = usePluginState();
|
|
15
|
+
const matrix = useViewportMatrix();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<OverlayWrapper
|
|
19
|
+
onPointerDown={event => {
|
|
20
|
+
if (event.button !== MouseButton.Left || event.shiftKey) return;
|
|
21
|
+
if (!scene.value) return;
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
|
|
24
|
+
const position = new Vector2(
|
|
25
|
+
event.x - state.rect.x,
|
|
26
|
+
event.y - state.rect.y,
|
|
27
|
+
).transformAsPoint(matrix.inverse());
|
|
28
|
+
|
|
29
|
+
selectNode(
|
|
30
|
+
scene.value.inspectPosition(position.x, position.y) as string,
|
|
31
|
+
);
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</OverlayWrapper>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function drawHook() {
|
|
40
|
+
const {selectedNode, hoveredKey, afterRender, scene} = usePluginState();
|
|
41
|
+
selectedNode.value;
|
|
42
|
+
hoveredKey.value;
|
|
43
|
+
afterRender.value;
|
|
44
|
+
|
|
45
|
+
return (ctx: CanvasRenderingContext2D, matrix: DOMMatrix) => {
|
|
46
|
+
const currentScene = scene.peek();
|
|
47
|
+
if (!currentScene) return;
|
|
48
|
+
|
|
49
|
+
let node = selectedNode.value;
|
|
50
|
+
if (node) {
|
|
51
|
+
currentScene.drawOverlay(node.key, matrix, ctx);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
node = currentScene.getNode(hoveredKey.value);
|
|
55
|
+
if (node && hoveredKey.value !== selectedNode.value?.key) {
|
|
56
|
+
ctx.globalAlpha = 0.5;
|
|
57
|
+
currentScene.drawOverlay(hoveredKey.value, matrix, ctx);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const PreviewOverlayConfig: PluginOverlayConfig = {
|
|
63
|
+
drawHook,
|
|
64
|
+
component: Component,
|
|
65
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {Node, Scene2D} from '@efxlab/motion-canvas-2d';
|
|
2
|
+
import {SceneRenderEvent} from '@efxlab/motion-canvas-core';
|
|
3
|
+
import {useApplication, useCurrentScene} from '@efxlab/motion-canvas-ui';
|
|
4
|
+
import {
|
|
5
|
+
ReadonlySignal,
|
|
6
|
+
Signal,
|
|
7
|
+
computed,
|
|
8
|
+
signal,
|
|
9
|
+
useSignalEffect,
|
|
10
|
+
} from '@preact/signals';
|
|
11
|
+
import {ComponentChildren, createContext} from 'preact';
|
|
12
|
+
import {useContext, useMemo} from 'preact/hooks';
|
|
13
|
+
import {SignalSet} from './utils';
|
|
14
|
+
|
|
15
|
+
export interface PluginState {
|
|
16
|
+
selectedNode: ReadonlySignal<Node | null>;
|
|
17
|
+
hoveredKey: Signal<string | null>;
|
|
18
|
+
selectNode: (nodeKey: string | null) => void;
|
|
19
|
+
openNodes: SignalSet<string>;
|
|
20
|
+
openDetached: Signal<boolean>;
|
|
21
|
+
visibleNodes: Set<string>;
|
|
22
|
+
scene: ReadonlySignal<Scene2D | null>;
|
|
23
|
+
afterRender: ReadonlySignal<number>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const PluginContext = createContext<PluginState | null>(null);
|
|
27
|
+
|
|
28
|
+
export const NodeInspectorKey = '@efxlab/motion-canvas-2d/node-inspector';
|
|
29
|
+
|
|
30
|
+
export function usePluginState() {
|
|
31
|
+
return useContext(PluginContext)!;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function Provider({children}: {children?: ComponentChildren}) {
|
|
35
|
+
const {inspection} = useApplication();
|
|
36
|
+
const currentScene = useCurrentScene();
|
|
37
|
+
|
|
38
|
+
const state = useMemo(() => {
|
|
39
|
+
const afterRender = signal(0);
|
|
40
|
+
const openDetached = signal(false);
|
|
41
|
+
const visibleNodes = new Set<string>();
|
|
42
|
+
const scene = signal(currentScene as Scene2D);
|
|
43
|
+
const selectedNode = computed(() => {
|
|
44
|
+
afterRender.value;
|
|
45
|
+
const {key, payload} = inspection.value;
|
|
46
|
+
if (key === NodeInspectorKey) {
|
|
47
|
+
return scene.value?.getNode(payload as string) ?? null;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
});
|
|
51
|
+
const hoveredKey = signal<string | null>(null);
|
|
52
|
+
const openNodes = new SignalSet<string>();
|
|
53
|
+
const selectNode = (nodeKey: string | null) => {
|
|
54
|
+
const {key, payload} = inspection.peek();
|
|
55
|
+
|
|
56
|
+
if (key === NodeInspectorKey && !nodeKey) {
|
|
57
|
+
inspection.value = {key: '', payload: null};
|
|
58
|
+
} else if (payload !== nodeKey) {
|
|
59
|
+
inspection.value = {key: NodeInspectorKey, payload: nodeKey};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
selectedNode,
|
|
65
|
+
selectNode,
|
|
66
|
+
hoveredKey,
|
|
67
|
+
afterRender,
|
|
68
|
+
openNodes,
|
|
69
|
+
openDetached,
|
|
70
|
+
visibleNodes,
|
|
71
|
+
scene,
|
|
72
|
+
} satisfies PluginState;
|
|
73
|
+
}, []);
|
|
74
|
+
|
|
75
|
+
state.scene.value = currentScene as Scene2D;
|
|
76
|
+
|
|
77
|
+
useSignalEffect(() =>
|
|
78
|
+
state.scene.value?.onRenderLifecycle.subscribe(([event]) => {
|
|
79
|
+
if (event === SceneRenderEvent.AfterRender) {
|
|
80
|
+
state.afterRender.value++;
|
|
81
|
+
}
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
// Expand all nodes necessary to reveal the selected one:
|
|
86
|
+
useSignalEffect(() => {
|
|
87
|
+
const selectedNode = state.selectedNode.value;
|
|
88
|
+
|
|
89
|
+
if (selectedNode && !state.visibleNodes.has(selectedNode.key ?? '')) {
|
|
90
|
+
let node = selectedNode.parent() ?? null;
|
|
91
|
+
if (!node && selectedNode !== selectedNode.view()) {
|
|
92
|
+
state.openDetached.value = true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
while (node) {
|
|
96
|
+
state.openNodes.add(node.key);
|
|
97
|
+
const parent = node.parent();
|
|
98
|
+
if (!parent && node !== node.view()) {
|
|
99
|
+
state.openDetached.value = true;
|
|
100
|
+
}
|
|
101
|
+
node = parent;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<PluginContext.Provider value={state}>{children}</PluginContext.Provider>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountTree,
|
|
3
|
+
emphasize,
|
|
4
|
+
Pane,
|
|
5
|
+
PluginTabConfig,
|
|
6
|
+
PluginTabProps,
|
|
7
|
+
Tab,
|
|
8
|
+
useApplication,
|
|
9
|
+
usePanels,
|
|
10
|
+
useReducedMotion,
|
|
11
|
+
useSurfaceShortcuts,
|
|
12
|
+
} from '@efxlab/motion-canvas-ui';
|
|
13
|
+
import {useSignalEffect} from '@preact/signals';
|
|
14
|
+
import {useEffect, useRef} from 'preact/hooks';
|
|
15
|
+
import {usePluginState} from './Provider';
|
|
16
|
+
import {SCENE_GRAPH_SHORTCUTS} from './shortcuts';
|
|
17
|
+
import {DetachedRoot, useKeyboardNavigation, ViewRoot} from './tree';
|
|
18
|
+
|
|
19
|
+
function TabComponent({tab}: PluginTabProps) {
|
|
20
|
+
const {sidebar} = usePanels();
|
|
21
|
+
const inspectorTab = useRef<HTMLButtonElement>(null);
|
|
22
|
+
const reducedMotion = useReducedMotion();
|
|
23
|
+
const {selectedNode, selectNode} = usePluginState();
|
|
24
|
+
const {logger} = useApplication();
|
|
25
|
+
|
|
26
|
+
useEffect(
|
|
27
|
+
() =>
|
|
28
|
+
logger.onInspected.subscribe(key => {
|
|
29
|
+
sidebar.set(tab);
|
|
30
|
+
selectNode(key);
|
|
31
|
+
}),
|
|
32
|
+
[tab],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
useSignalEffect(() => {
|
|
36
|
+
if (
|
|
37
|
+
selectedNode.value &&
|
|
38
|
+
sidebar.current.peek() !== tab &&
|
|
39
|
+
!reducedMotion &&
|
|
40
|
+
inspectorTab.current &&
|
|
41
|
+
inspectorTab.current.getAnimations().length < 2
|
|
42
|
+
) {
|
|
43
|
+
inspectorTab.current.animate(emphasize(), {duration: 400});
|
|
44
|
+
inspectorTab.current.animate([{color: 'white'}, {color: ''}], {
|
|
45
|
+
duration: 800,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Tab
|
|
52
|
+
forwardRef={inspectorTab}
|
|
53
|
+
title="Scene Graph"
|
|
54
|
+
id="scene-graph-tab"
|
|
55
|
+
tab={tab}
|
|
56
|
+
>
|
|
57
|
+
<AccountTree />
|
|
58
|
+
</Tab>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function PaneComponent() {
|
|
63
|
+
const ref = useSurfaceShortcuts<HTMLDivElement>(SCENE_GRAPH_SHORTCUTS);
|
|
64
|
+
const {selectNode} = usePluginState();
|
|
65
|
+
|
|
66
|
+
useKeyboardNavigation();
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Pane
|
|
70
|
+
forwardRef={ref}
|
|
71
|
+
title="Scene Graph"
|
|
72
|
+
id="scene-graph-pane"
|
|
73
|
+
onClick={() => {
|
|
74
|
+
selectNode(null);
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
<ViewRoot />
|
|
78
|
+
<DetachedRoot />
|
|
79
|
+
</Pane>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const SceneGraphTabConfig: PluginTabConfig = {
|
|
84
|
+
name: 'scene-graph',
|
|
85
|
+
tabComponent: TabComponent,
|
|
86
|
+
paneComponent: PaneComponent,
|
|
87
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function CircleIcon() {
|
|
2
|
+
return (
|
|
3
|
+
<svg viewBox="0 0 20 20" fill="currentColor">
|
|
4
|
+
<path d="M10,5C12.76,5 15,7.24 15,10C15,12.76 12.76,15 10,15C7.24,15 5,12.76 5,10C5,7.24 7.24,5 10,5ZM10,7C8.344,7 7,8.344 7,10C7,11.656 8.344,13 10,13C11.656,13 13,11.656 13,10C13,8.344 11.656,7 10,7Z" />
|
|
5
|
+
</svg>
|
|
6
|
+
);
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function CodeBlockIcon() {
|
|
2
|
+
return (
|
|
3
|
+
<svg viewBox="0 0 20 20" fill="currentColor">
|
|
4
|
+
<path d="M5,9L5,6.999C5,6.469 5.211,5.96 5.585,5.586C5.96,5.211 6.469,5 6.999,5L9,5L9,7L6.999,7L7,9L7,11L7,13L8.985,13L9,15L7,15C5.895,15 5,14.105 5,13L5,11L4,11L4,9L5,9Z" />
|
|
5
|
+
<path d="M15,11L15,13.001C15,13.531 14.789,14.04 14.415,14.414C14.04,14.789 13.531,15 13.001,15L11,15L11,13L13,13L13,11L13,9L13,7L11.015,7L11,5L13,5C14.105,5 15,5.895 15,7L15,9L16,9L16,11L15,11Z" />
|
|
6
|
+
</svg>
|
|
7
|
+
);
|
|
8
|
+
}
|