@llc3233149/core 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvaskit.d.ts +9 -0
- package/dist/canvaskit.d.ts.map +1 -0
- package/dist/canvaskit.js +55 -0
- package/dist/canvaskit.js.map +1 -0
- package/dist/clipboard.d.ts +32 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +345 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/color.d.ts +28 -0
- package/dist/color.d.ts.map +1 -0
- package/dist/color.js +67 -0
- package/dist/color.js.map +1 -0
- package/dist/constants.d.ts +159 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +224 -0
- package/dist/constants.js.map +1 -0
- package/dist/copy.d.ts +20 -0
- package/dist/copy.d.ts.map +1 -0
- package/dist/copy.js +64 -0
- package/dist/copy.js.map +1 -0
- package/dist/fig-export-worker.d.ts +2 -0
- package/dist/fig-export-worker.d.ts.map +1 -0
- package/dist/fig-export-worker.js +17 -0
- package/dist/fig-export-worker.js.map +1 -0
- package/dist/fig-export.d.ts +13 -0
- package/dist/fig-export.d.ts.map +1 -0
- package/dist/fig-export.js +243 -0
- package/dist/fig-export.js.map +1 -0
- package/dist/figma-api.d.ts +268 -0
- package/dist/figma-api.d.ts.map +1 -0
- package/dist/figma-api.js +1074 -0
- package/dist/figma-api.js.map +1 -0
- package/dist/figma-rest-import.d.ts +122 -0
- package/dist/figma-rest-import.d.ts.map +1 -0
- package/dist/figma-rest-import.js +319 -0
- package/dist/figma-rest-import.js.map +1 -0
- package/dist/fonts.d.ts +24 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +356 -0
- package/dist/fonts.js.map +1 -0
- package/dist/geometry.d.ts +14 -0
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +47 -0
- package/dist/geometry.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/kiwi/codec.d.ts +292 -0
- package/dist/kiwi/codec.d.ts.map +1 -0
- package/dist/kiwi/codec.js +340 -0
- package/dist/kiwi/codec.js.map +1 -0
- package/dist/kiwi/fig-file.d.ts +4 -0
- package/dist/kiwi/fig-file.d.ts.map +1 -0
- package/dist/kiwi/fig-file.js +236 -0
- package/dist/kiwi/fig-file.js.map +1 -0
- package/dist/kiwi/fig-import.d.ts +4 -0
- package/dist/kiwi/fig-import.d.ts.map +1 -0
- package/dist/kiwi/fig-import.js +248 -0
- package/dist/kiwi/fig-import.js.map +1 -0
- package/dist/kiwi/fig-parse-worker.d.ts +7 -0
- package/dist/kiwi/fig-parse-worker.d.ts.map +1 -0
- package/dist/kiwi/fig-parse-worker.js +184 -0
- package/dist/kiwi/fig-parse-worker.js.map +1 -0
- package/dist/kiwi/instance-overrides.d.ts +66 -0
- package/dist/kiwi/instance-overrides.d.ts.map +1 -0
- package/dist/kiwi/instance-overrides.js +644 -0
- package/dist/kiwi/instance-overrides.js.map +1 -0
- package/dist/kiwi/kiwi-convert.d.ts +19 -0
- package/dist/kiwi/kiwi-convert.d.ts.map +1 -0
- package/dist/kiwi/kiwi-convert.js +678 -0
- package/dist/kiwi/kiwi-convert.js.map +1 -0
- package/dist/kiwi/kiwi-schema/bb.d.ts +25 -0
- package/dist/kiwi/kiwi-schema/bb.d.ts.map +1 -0
- package/dist/kiwi/kiwi-schema/bb.js +225 -0
- package/dist/kiwi/kiwi-schema/bb.js.map +1 -0
- package/dist/kiwi/kiwi-schema/binary.d.ts +5 -0
- package/dist/kiwi/kiwi-schema/binary.d.ts.map +1 -0
- package/dist/kiwi/kiwi-schema/binary.js +86 -0
- package/dist/kiwi/kiwi-schema/binary.js.map +1 -0
- package/dist/kiwi/kiwi-schema/index.d.ts +6 -0
- package/dist/kiwi/kiwi-schema/index.d.ts.map +1 -0
- package/dist/kiwi/kiwi-schema/index.js +5 -0
- package/dist/kiwi/kiwi-schema/index.js.map +1 -0
- package/dist/kiwi/kiwi-schema/js.d.ts +4 -0
- package/dist/kiwi/kiwi-schema/js.d.ts.map +1 -0
- package/dist/kiwi/kiwi-schema/js.js +282 -0
- package/dist/kiwi/kiwi-schema/js.js.map +1 -0
- package/dist/kiwi/kiwi-schema/parser.d.ts +5 -0
- package/dist/kiwi/kiwi-schema/parser.d.ts.map +1 -0
- package/dist/kiwi/kiwi-schema/parser.js +228 -0
- package/dist/kiwi/kiwi-schema/parser.js.map +1 -0
- package/dist/kiwi/kiwi-schema/schema.d.ts +22 -0
- package/dist/kiwi/kiwi-schema/schema.d.ts.map +1 -0
- package/dist/kiwi/kiwi-schema/schema.js +2 -0
- package/dist/kiwi/kiwi-schema/schema.js.map +1 -0
- package/dist/kiwi/kiwi-schema/util.d.ts +3 -0
- package/dist/kiwi/kiwi-schema/util.d.ts.map +1 -0
- package/dist/kiwi/kiwi-schema/util.js +10 -0
- package/dist/kiwi/kiwi-schema/util.js.map +1 -0
- package/dist/kiwi/protocol.d.ts +172 -0
- package/dist/kiwi/protocol.d.ts.map +1 -0
- package/dist/kiwi/protocol.js +214 -0
- package/dist/kiwi/protocol.js.map +1 -0
- package/dist/kiwi/schema.d.ts +3 -0
- package/dist/kiwi/schema.d.ts.map +1 -0
- package/dist/kiwi/schema.js +2285 -0
- package/dist/kiwi/schema.js.map +1 -0
- package/dist/kiwi-serialize.d.ts +17 -0
- package/dist/kiwi-serialize.d.ts.map +1 -0
- package/dist/kiwi-serialize.js +419 -0
- package/dist/kiwi-serialize.js.map +1 -0
- package/dist/layout.d.ts +9 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +533 -0
- package/dist/layout.js.map +1 -0
- package/dist/profiler/draw-call-counter.d.ts +9 -0
- package/dist/profiler/draw-call-counter.d.ts.map +1 -0
- package/dist/profiler/draw-call-counter.js +37 -0
- package/dist/profiler/draw-call-counter.js.map +1 -0
- package/dist/profiler/frame-capture.d.ts +34 -0
- package/dist/profiler/frame-capture.d.ts.map +1 -0
- package/dist/profiler/frame-capture.js +90 -0
- package/dist/profiler/frame-capture.js.map +1 -0
- package/dist/profiler/frame-stats.d.ts +33 -0
- package/dist/profiler/frame-stats.d.ts.map +1 -0
- package/dist/profiler/frame-stats.js +103 -0
- package/dist/profiler/frame-stats.js.map +1 -0
- package/dist/profiler/gpu-timer.d.ts +15 -0
- package/dist/profiler/gpu-timer.d.ts.map +1 -0
- package/dist/profiler/gpu-timer.js +77 -0
- package/dist/profiler/gpu-timer.js.map +1 -0
- package/dist/profiler/hud-renderer.d.ts +22 -0
- package/dist/profiler/hud-renderer.d.ts.map +1 -0
- package/dist/profiler/hud-renderer.js +200 -0
- package/dist/profiler/hud-renderer.js.map +1 -0
- package/dist/profiler/index.d.ts +9 -0
- package/dist/profiler/index.d.ts.map +1 -0
- package/dist/profiler/index.js +8 -0
- package/dist/profiler/index.js.map +1 -0
- package/dist/profiler/phase-timer.d.ts +9 -0
- package/dist/profiler/phase-timer.d.ts.map +1 -0
- package/dist/profiler/phase-timer.js +51 -0
- package/dist/profiler/phase-timer.js.map +1 -0
- package/dist/profiler/render-profiler.d.ts +41 -0
- package/dist/profiler/render-profiler.d.ts.map +1 -0
- package/dist/profiler/render-profiler.js +142 -0
- package/dist/profiler/render-profiler.js.map +1 -0
- package/dist/render/components.d.ts +25 -0
- package/dist/render/components.d.ts.map +1 -0
- package/dist/render/components.js +55 -0
- package/dist/render/components.js.map +1 -0
- package/dist/render/emoji-icons.d.ts +5 -0
- package/dist/render/emoji-icons.d.ts.map +1 -0
- package/dist/render/emoji-icons.js +55 -0
- package/dist/render/emoji-icons.js.map +1 -0
- package/dist/render/export-code.d.ts +9 -0
- package/dist/render/export-code.d.ts.map +1 -0
- package/dist/render/export-code.js +335 -0
- package/dist/render/export-code.js.map +1 -0
- package/dist/render/export-jsx.d.ts +5 -0
- package/dist/render/export-jsx.d.ts.map +1 -0
- package/dist/render/export-jsx.js +621 -0
- package/dist/render/export-jsx.js.map +1 -0
- package/dist/render/index.d.ts +8 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +8 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/jsx-runtime.d.ts +31 -0
- package/dist/render/jsx-runtime.d.ts.map +1 -0
- package/dist/render/jsx-runtime.js +13 -0
- package/dist/render/jsx-runtime.js.map +1 -0
- package/dist/render/mini-react.d.ts +14 -0
- package/dist/render/mini-react.d.ts.map +1 -0
- package/dist/render/mini-react.js +16 -0
- package/dist/render/mini-react.js.map +1 -0
- package/dist/render/render-jsx.d.ts +24 -0
- package/dist/render/render-jsx.d.ts.map +1 -0
- package/dist/render/render-jsx.js +51 -0
- package/dist/render/render-jsx.js.map +1 -0
- package/dist/render/renderer.d.ts +16 -0
- package/dist/render/renderer.d.ts.map +1 -0
- package/dist/render/renderer.js +437 -0
- package/dist/render/renderer.js.map +1 -0
- package/dist/render/tailwind.d.ts +20 -0
- package/dist/render/tailwind.d.ts.map +1 -0
- package/dist/render/tailwind.js +115 -0
- package/dist/render/tailwind.js.map +1 -0
- package/dist/render/tree.d.ts +72 -0
- package/dist/render/tree.d.ts.map +1 -0
- package/dist/render/tree.js +63 -0
- package/dist/render/tree.js.map +1 -0
- package/dist/render-image.d.ts +19 -0
- package/dist/render-image.d.ts.map +1 -0
- package/dist/render-image.js +84 -0
- package/dist/render-image.js.map +1 -0
- package/dist/renderer/effects.d.ts +9 -0
- package/dist/renderer/effects.d.ts.map +1 -0
- package/dist/renderer/effects.js +44 -0
- package/dist/renderer/effects.js.map +1 -0
- package/dist/renderer/fills.d.ts +9 -0
- package/dist/renderer/fills.d.ts.map +1 -0
- package/dist/renderer/fills.js +189 -0
- package/dist/renderer/fills.js.map +1 -0
- package/dist/renderer/index.d.ts +2 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/renderer/index.js +2 -0
- package/dist/renderer/index.js.map +1 -0
- package/dist/renderer/label-cache.d.ts +43 -0
- package/dist/renderer/label-cache.d.ts.map +1 -0
- package/dist/renderer/label-cache.js +85 -0
- package/dist/renderer/label-cache.js.map +1 -0
- package/dist/renderer/labels.d.ts +6 -0
- package/dist/renderer/labels.d.ts.map +1 -0
- package/dist/renderer/labels.js +126 -0
- package/dist/renderer/labels.js.map +1 -0
- package/dist/renderer/lru-cache.d.ts +20 -0
- package/dist/renderer/lru-cache.d.ts.map +1 -0
- package/dist/renderer/lru-cache.js +65 -0
- package/dist/renderer/lru-cache.js.map +1 -0
- package/dist/renderer/overlays.d.ts +25 -0
- package/dist/renderer/overlays.d.ts.map +1 -0
- package/dist/renderer/overlays.js +783 -0
- package/dist/renderer/overlays.js.map +1 -0
- package/dist/renderer/renderer.d.ts +229 -0
- package/dist/renderer/renderer.d.ts.map +1 -0
- package/dist/renderer/renderer.js +909 -0
- package/dist/renderer/renderer.js.map +1 -0
- package/dist/renderer/rulers.d.ts +8 -0
- package/dist/renderer/rulers.d.ts.map +1 -0
- package/dist/renderer/rulers.js +147 -0
- package/dist/renderer/rulers.js.map +1 -0
- package/dist/renderer/scene.d.ts +11 -0
- package/dist/renderer/scene.d.ts.map +1 -0
- package/dist/renderer/scene.js +392 -0
- package/dist/renderer/scene.js.map +1 -0
- package/dist/renderer/shapes.d.ts +13 -0
- package/dist/renderer/shapes.d.ts.map +1 -0
- package/dist/renderer/shapes.js +160 -0
- package/dist/renderer/shapes.js.map +1 -0
- package/dist/renderer/strokes.d.ts +9 -0
- package/dist/renderer/strokes.d.ts.map +1 -0
- package/dist/renderer/strokes.js +180 -0
- package/dist/renderer/strokes.js.map +1 -0
- package/dist/rpc/commands.d.ts +202 -0
- package/dist/rpc/commands.d.ts.map +1 -0
- package/dist/rpc/commands.js +429 -0
- package/dist/rpc/commands.js.map +1 -0
- package/dist/rpc/index.d.ts +3 -0
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/rpc/index.js +2 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/scene-graph.d.ts +318 -0
- package/dist/scene-graph.d.ts.map +1 -0
- package/dist/scene-graph.js +803 -0
- package/dist/scene-graph.js.map +1 -0
- package/dist/snap.d.ts +16 -0
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +97 -0
- package/dist/snap.js.map +1 -0
- package/dist/style-runs.d.ts +20 -0
- package/dist/style-runs.d.ts.map +1 -0
- package/dist/style-runs.js +168 -0
- package/dist/style-runs.js.map +1 -0
- package/dist/svg-export/defs.d.ts +19 -0
- package/dist/svg-export/defs.d.ts.map +1 -0
- package/dist/svg-export/defs.js +191 -0
- package/dist/svg-export/defs.js.map +1 -0
- package/dist/svg-export/index.d.ts +8 -0
- package/dist/svg-export/index.d.ts.map +1 -0
- package/dist/svg-export/index.js +318 -0
- package/dist/svg-export/index.js.map +1 -0
- package/dist/svg-export/paths.d.ts +9 -0
- package/dist/svg-export/paths.d.ts.map +1 -0
- package/dist/svg-export/paths.js +189 -0
- package/dist/svg-export/paths.js.map +1 -0
- package/dist/svg-node.d.ts +8 -0
- package/dist/svg-node.d.ts.map +1 -0
- package/dist/svg-node.js +48 -0
- package/dist/svg-node.js.map +1 -0
- package/dist/text-editor.d.ts +57 -0
- package/dist/text-editor.d.ts.map +1 -0
- package/dist/text-editor.js +337 -0
- package/dist/text-editor.js.map +1 -0
- package/dist/tools/ai-adapter.d.ts +22 -0
- package/dist/tools/ai-adapter.d.ts.map +1 -0
- package/dist/tools/ai-adapter.js +121 -0
- package/dist/tools/ai-adapter.js.map +1 -0
- package/dist/tools/analyze.d.ts +22 -0
- package/dist/tools/analyze.d.ts.map +1 -0
- package/dist/tools/analyze.js +677 -0
- package/dist/tools/analyze.js.map +1 -0
- package/dist/tools/create.d.ts +8 -0
- package/dist/tools/create.d.ts.map +1 -0
- package/dist/tools/create.js +204 -0
- package/dist/tools/create.js.map +1 -0
- package/dist/tools/describe.d.ts +9 -0
- package/dist/tools/describe.d.ts.map +1 -0
- package/dist/tools/describe.js +295 -0
- package/dist/tools/describe.js.map +1 -0
- package/dist/tools/export-code.d.ts +2 -0
- package/dist/tools/export-code.d.ts.map +1 -0
- package/dist/tools/export-code.js +34 -0
- package/dist/tools/export-code.js.map +1 -0
- package/dist/tools/export-tailwind-config.d.ts +27 -0
- package/dist/tools/export-tailwind-config.d.ts.map +1 -0
- package/dist/tools/export-tailwind-config.js +215 -0
- package/dist/tools/export-tailwind-config.js.map +1 -0
- package/dist/tools/icons.d.ts +5 -0
- package/dist/tools/icons.d.ts.map +1 -0
- package/dist/tools/icons.js +192 -0
- package/dist/tools/icons.js.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/modify.d.ts +22 -0
- package/dist/tools/modify.d.ts.map +1 -0
- package/dist/tools/modify.js +653 -0
- package/dist/tools/modify.js.map +1 -0
- package/dist/tools/patterns.d.ts +2 -0
- package/dist/tools/patterns.d.ts.map +1 -0
- package/dist/tools/patterns.js +173 -0
- package/dist/tools/patterns.js.map +1 -0
- package/dist/tools/read.d.ts +17 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +379 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/registry.d.ts +3 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +124 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/schema.d.ts +46 -0
- package/dist/tools/schema.d.ts.map +1 -0
- package/dist/tools/schema.js +17 -0
- package/dist/tools/schema.js.map +1 -0
- package/dist/tools/structure.d.ts +18 -0
- package/dist/tools/structure.d.ts.map +1 -0
- package/dist/tools/structure.js +345 -0
- package/dist/tools/structure.js.map +1 -0
- package/dist/tools/variables.d.ts +12 -0
- package/dist/tools/variables.d.ts.map +1 -0
- package/dist/tools/variables.js +190 -0
- package/dist/tools/variables.js.map +1 -0
- package/dist/tools/vector.d.ts +15 -0
- package/dist/tools/vector.d.ts.map +1 -0
- package/dist/tools/vector.js +312 -0
- package/dist/tools/vector.js.map +1 -0
- package/dist/types.d.ts +29 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/undo.d.ts +33 -0
- package/dist/undo.d.ts.map +1 -0
- package/dist/undo.js +98 -0
- package/dist/undo.js.map +1 -0
- package/dist/vector.d.ts +14 -0
- package/dist/vector.d.ts.map +1 -0
- package/dist/vector.js +334 -0
- package/dist/vector.js.map +1 -0
- package/dist/xpath.d.ts +8 -0
- package/dist/xpath.d.ts.map +1 -0
- package/dist/xpath.js +199 -0
- package/dist/xpath.js.map +1 -0
- package/package.json +54 -0
- package/src/canvaskit.ts +66 -0
- package/src/clipboard.ts +444 -0
- package/src/color.ts +83 -0
- package/src/constants.ts +277 -0
- package/src/copy.ts +75 -0
- package/src/fig-export-worker.ts +28 -0
- package/src/fig-export.ts +321 -0
- package/src/figma-api.ts +1297 -0
- package/src/figma-rest-import.ts +443 -0
- package/src/fonts.ts +369 -0
- package/src/geometry.ts +73 -0
- package/src/global.d.ts +20 -0
- package/src/index.ts +247 -0
- package/src/kiwi/codec.ts +614 -0
- package/src/kiwi/fig-file.ts +248 -0
- package/src/kiwi/fig-import.ts +300 -0
- package/src/kiwi/fig-parse-worker.ts +213 -0
- package/src/kiwi/instance-overrides.ts +682 -0
- package/src/kiwi/kiwi-convert.ts +771 -0
- package/src/kiwi/kiwi-schema/bb.ts +244 -0
- package/src/kiwi/kiwi-schema/binary.ts +102 -0
- package/src/kiwi/kiwi-schema/index.ts +5 -0
- package/src/kiwi/kiwi-schema/js.ts +339 -0
- package/src/kiwi/kiwi-schema/parser.ts +287 -0
- package/src/kiwi/kiwi-schema/schema.ts +24 -0
- package/src/kiwi/kiwi-schema/util.ts +10 -0
- package/src/kiwi/protocol.ts +237 -0
- package/src/kiwi/schema.ts +2286 -0
- package/src/kiwi-serialize.ts +467 -0
- package/src/layout.ts +608 -0
- package/src/profiler/draw-call-counter.ts +43 -0
- package/src/profiler/frame-capture.ts +139 -0
- package/src/profiler/frame-stats.ts +122 -0
- package/src/profiler/gpu-timer.ts +93 -0
- package/src/profiler/hud-renderer.ts +242 -0
- package/src/profiler/index.ts +8 -0
- package/src/profiler/phase-timer.ts +62 -0
- package/src/profiler/render-profiler.ts +163 -0
- package/src/render/components.ts +69 -0
- package/src/render/emoji-icons.ts +60 -0
- package/src/render/export-code.ts +366 -0
- package/src/render/export-jsx.ts +633 -0
- package/src/render/index.ts +38 -0
- package/src/render/jsx-runtime.ts +36 -0
- package/src/render/mini-react.ts +30 -0
- package/src/render/render-jsx.ts +74 -0
- package/src/render/renderer.ts +508 -0
- package/src/render/tailwind.ts +114 -0
- package/src/render/tree.ts +137 -0
- package/src/render-image.ts +139 -0
- package/src/renderer/effects.ts +64 -0
- package/src/renderer/fills.ts +248 -0
- package/src/renderer/index.ts +1 -0
- package/src/renderer/label-cache.ts +114 -0
- package/src/renderer/labels.ts +168 -0
- package/src/renderer/lru-cache.ts +71 -0
- package/src/renderer/overlays.ts +1089 -0
- package/src/renderer/renderer.ts +1226 -0
- package/src/renderer/rulers.ts +230 -0
- package/src/renderer/scene.ts +554 -0
- package/src/renderer/shapes.ts +193 -0
- package/src/renderer/strokes.ts +221 -0
- package/src/rpc/commands.ts +667 -0
- package/src/rpc/index.ts +25 -0
- package/src/scene-graph.ts +1254 -0
- package/src/snap.ts +122 -0
- package/src/style-runs.ts +234 -0
- package/src/svg-export/defs.ts +255 -0
- package/src/svg-export/index.ts +427 -0
- package/src/svg-export/paths.ts +212 -0
- package/src/svg-node.ts +62 -0
- package/src/text-editor.ts +349 -0
- package/src/tools/ai-adapter.ts +144 -0
- package/src/tools/analyze.ts +786 -0
- package/src/tools/create.ts +206 -0
- package/src/tools/describe.ts +280 -0
- package/src/tools/export-code.ts +41 -0
- package/src/tools/export-tailwind-config.ts +266 -0
- package/src/tools/icons.ts +213 -0
- package/src/tools/index.ts +6 -0
- package/src/tools/modify.ts +651 -0
- package/src/tools/patterns.ts +189 -0
- package/src/tools/read.ts +401 -0
- package/src/tools/registry.ts +155 -0
- package/src/tools/schema.ts +65 -0
- package/src/tools/structure.ts +348 -0
- package/src/tools/variables.ts +193 -0
- package/src/tools/vector.ts +311 -0
- package/src/types.ts +32 -0
- package/src/undo.ts +126 -0
- package/src/vector.ts +413 -0
- package/src/xpath.ts +259 -0
package/src/layout.ts
ADDED
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
import Yoga, {
|
|
2
|
+
Align,
|
|
3
|
+
Direction,
|
|
4
|
+
Display,
|
|
5
|
+
FlexDirection,
|
|
6
|
+
GridTrackType,
|
|
7
|
+
Gutter,
|
|
8
|
+
Justify,
|
|
9
|
+
Edge,
|
|
10
|
+
MeasureMode,
|
|
11
|
+
Overflow,
|
|
12
|
+
PositionType,
|
|
13
|
+
Wrap,
|
|
14
|
+
type Node as YogaNode
|
|
15
|
+
} from 'yoga-layout'
|
|
16
|
+
|
|
17
|
+
import type { GridTrack, SceneGraph, SceneNode } from './scene-graph'
|
|
18
|
+
|
|
19
|
+
export type TextMeasurer = (
|
|
20
|
+
node: SceneNode,
|
|
21
|
+
maxWidth?: number
|
|
22
|
+
) => { width: number; height: number } | null
|
|
23
|
+
|
|
24
|
+
let globalTextMeasurer: TextMeasurer | null = null
|
|
25
|
+
|
|
26
|
+
const GLYPH_WIDTH_FACTOR = 0.6
|
|
27
|
+
|
|
28
|
+
export function setTextMeasurer(measurer: TextMeasurer | null): void {
|
|
29
|
+
globalTextMeasurer = measurer
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function computeLayout(graph: SceneGraph, frameId: string): void {
|
|
33
|
+
const frame = graph.getNode(frameId)
|
|
34
|
+
if (!frame || frame.layoutMode === 'NONE') return
|
|
35
|
+
|
|
36
|
+
const yogaRoot =
|
|
37
|
+
frame.layoutMode === 'GRID' ? buildGridTree(graph, frame) : buildYogaTree(graph, frame)
|
|
38
|
+
yogaRoot.calculateLayout(undefined, undefined, Direction.LTR)
|
|
39
|
+
applyYogaLayout(graph, frame, yogaRoot)
|
|
40
|
+
freeYogaTree(yogaRoot)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function computeAllLayouts(graph: SceneGraph, scopeId?: string): void {
|
|
44
|
+
const visited = new Set<string>()
|
|
45
|
+
computeLayoutsBottomUp(graph, scopeId ?? graph.rootId, visited)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function computeLayoutsBottomUp(graph: SceneGraph, nodeId: string, visited: Set<string>): void {
|
|
49
|
+
const node = graph.getNode(nodeId)
|
|
50
|
+
if (!node || visited.has(nodeId)) return
|
|
51
|
+
visited.add(nodeId)
|
|
52
|
+
|
|
53
|
+
for (const childId of node.childIds) {
|
|
54
|
+
computeLayoutsBottomUp(graph, childId, visited)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (node.layoutMode !== 'NONE') {
|
|
58
|
+
computeLayout(graph, nodeId)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// --- Grid layout ---
|
|
63
|
+
|
|
64
|
+
function mapGridTrack(track: GridTrack): { type: GridTrackType; value: number } {
|
|
65
|
+
switch (track.sizing) {
|
|
66
|
+
case 'FR':
|
|
67
|
+
return { type: GridTrackType.Fr, value: track.value }
|
|
68
|
+
case 'FIXED':
|
|
69
|
+
return { type: GridTrackType.Points, value: track.value }
|
|
70
|
+
default:
|
|
71
|
+
return { type: GridTrackType.Auto, value: 0 }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function configureAsGrid(yogaNode: YogaNode, node: SceneNode): void {
|
|
76
|
+
yogaNode.setDisplay(Display.Grid)
|
|
77
|
+
yogaNode.setWidth(node.width)
|
|
78
|
+
if (node.gridTemplateRows.length > 0 || node.height > 0) {
|
|
79
|
+
yogaNode.setHeight(node.height)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (node.gridTemplateColumns.length > 0) {
|
|
83
|
+
yogaNode.setGridTemplateColumns(node.gridTemplateColumns.map(mapGridTrack))
|
|
84
|
+
}
|
|
85
|
+
if (node.gridTemplateRows.length > 0) {
|
|
86
|
+
yogaNode.setGridTemplateRows(node.gridTemplateRows.map(mapGridTrack))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
yogaNode.setGap(Gutter.Column, node.gridColumnGap)
|
|
90
|
+
yogaNode.setGap(Gutter.Row, node.gridRowGap)
|
|
91
|
+
|
|
92
|
+
yogaNode.setPadding(Edge.Top, node.paddingTop)
|
|
93
|
+
yogaNode.setPadding(Edge.Right, node.paddingRight)
|
|
94
|
+
yogaNode.setPadding(Edge.Bottom, node.paddingBottom)
|
|
95
|
+
yogaNode.setPadding(Edge.Left, node.paddingLeft)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function createGridChildNode(child: SceneNode): YogaNode {
|
|
99
|
+
const yogaChild = Yoga.Node.create()
|
|
100
|
+
if (!child.visible) {
|
|
101
|
+
yogaChild.setDisplay(Display.None)
|
|
102
|
+
} else {
|
|
103
|
+
const pos = child.gridPosition
|
|
104
|
+
if (pos) {
|
|
105
|
+
yogaChild.setGridColumnStart(pos.column)
|
|
106
|
+
yogaChild.setGridColumnEndSpan(pos.columnSpan)
|
|
107
|
+
yogaChild.setGridRowStart(pos.row)
|
|
108
|
+
yogaChild.setGridRowEndSpan(pos.rowSpan)
|
|
109
|
+
}
|
|
110
|
+
const hasLayout = child.layoutMode !== 'NONE'
|
|
111
|
+
const explicitStretch = child.layoutGrow > 0 || child.layoutAlignSelf === 'STRETCH'
|
|
112
|
+
|
|
113
|
+
if (explicitStretch || hasLayout) {
|
|
114
|
+
yogaChild.setWidthStretch()
|
|
115
|
+
} else {
|
|
116
|
+
yogaChild.setWidth(child.width)
|
|
117
|
+
}
|
|
118
|
+
if (explicitStretch) {
|
|
119
|
+
yogaChild.setHeightStretch()
|
|
120
|
+
} else {
|
|
121
|
+
yogaChild.setHeight(child.height)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return yogaChild
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function buildGridTree(graph: SceneGraph, frame: SceneNode): YogaNode {
|
|
128
|
+
const root = Yoga.Node.create()
|
|
129
|
+
configureAsGrid(root, frame)
|
|
130
|
+
|
|
131
|
+
const children = graph.getChildren(frame.id)
|
|
132
|
+
for (const child of children) {
|
|
133
|
+
if (child.layoutPositioning === 'ABSOLUTE') {
|
|
134
|
+
const yogaChild = Yoga.Node.create()
|
|
135
|
+
configureAbsoluteChild(yogaChild, child)
|
|
136
|
+
root.insertChild(yogaChild, root.getChildCount())
|
|
137
|
+
} else {
|
|
138
|
+
root.insertChild(createGridChildNode(child), root.getChildCount())
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return root
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// --- Flex layout ---
|
|
146
|
+
|
|
147
|
+
function buildYogaTree(graph: SceneGraph, frame: SceneNode): YogaNode {
|
|
148
|
+
const root = Yoga.Node.create()
|
|
149
|
+
|
|
150
|
+
if (frame.primaryAxisSizing === 'FIXED') {
|
|
151
|
+
if (frame.layoutMode === 'HORIZONTAL') root.setWidth(frame.width)
|
|
152
|
+
else root.setHeight(frame.height)
|
|
153
|
+
}
|
|
154
|
+
if (frame.counterAxisSizing === 'FIXED') {
|
|
155
|
+
if (frame.layoutMode === 'HORIZONTAL') root.setHeight(frame.height)
|
|
156
|
+
else root.setWidth(frame.width)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
configureFlexContainer(root, frame)
|
|
160
|
+
|
|
161
|
+
const children = graph.getChildren(frame.id)
|
|
162
|
+
for (const child of children) {
|
|
163
|
+
const yogaChild = Yoga.Node.create()
|
|
164
|
+
|
|
165
|
+
if (child.layoutPositioning === 'ABSOLUTE') {
|
|
166
|
+
configureAbsoluteChild(yogaChild, child)
|
|
167
|
+
} else if (!child.visible) {
|
|
168
|
+
yogaChild.setDisplay(Display.None)
|
|
169
|
+
} else if (child.layoutMode === 'GRID') {
|
|
170
|
+
configureChildAsGrid(yogaChild, child, frame, graph)
|
|
171
|
+
} else if (child.layoutMode !== 'NONE') {
|
|
172
|
+
configureChildAsAutoLayout(yogaChild, child, frame, graph)
|
|
173
|
+
} else {
|
|
174
|
+
configureChildAsLeaf(yogaChild, child, frame)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
root.insertChild(yogaChild, root.getChildCount())
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return root
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function configureAbsoluteChild(yogaChild: YogaNode, child: SceneNode): void {
|
|
184
|
+
yogaChild.setPositionType(PositionType.Absolute)
|
|
185
|
+
yogaChild.setPosition(Edge.Left, child.x)
|
|
186
|
+
yogaChild.setPosition(Edge.Top, child.y)
|
|
187
|
+
yogaChild.setWidth(child.width)
|
|
188
|
+
yogaChild.setHeight(child.height)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function configureFlexContainer(yogaNode: YogaNode, node: SceneNode): void {
|
|
192
|
+
yogaNode.setFlexDirection(
|
|
193
|
+
node.layoutMode === 'HORIZONTAL' ? FlexDirection.Row : FlexDirection.Column
|
|
194
|
+
)
|
|
195
|
+
yogaNode.setFlexWrap(node.layoutWrap === 'WRAP' ? Wrap.Wrap : Wrap.NoWrap)
|
|
196
|
+
yogaNode.setJustifyContent(mapJustify(node.primaryAxisAlign))
|
|
197
|
+
yogaNode.setAlignItems(mapAlign(node.counterAxisAlign))
|
|
198
|
+
if (node.clipsContent) yogaNode.setOverflow(Overflow.Hidden)
|
|
199
|
+
|
|
200
|
+
if (node.layoutWrap === 'WRAP' && node.counterAxisAlignContent === 'SPACE_BETWEEN') {
|
|
201
|
+
yogaNode.setAlignContent(Align.SpaceBetween)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
yogaNode.setPadding(Edge.Top, node.paddingTop)
|
|
205
|
+
yogaNode.setPadding(Edge.Right, node.paddingRight)
|
|
206
|
+
yogaNode.setPadding(Edge.Bottom, node.paddingBottom)
|
|
207
|
+
yogaNode.setPadding(Edge.Left, node.paddingLeft)
|
|
208
|
+
|
|
209
|
+
yogaNode.setGap(
|
|
210
|
+
Gutter.Column,
|
|
211
|
+
node.layoutMode === 'HORIZONTAL' ? node.itemSpacing : node.counterAxisSpacing
|
|
212
|
+
)
|
|
213
|
+
yogaNode.setGap(
|
|
214
|
+
Gutter.Row,
|
|
215
|
+
node.layoutMode === 'HORIZONTAL' ? node.counterAxisSpacing : node.itemSpacing
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
applyMinMaxConstraints(yogaNode, node)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function configureChildAsGrid(
|
|
222
|
+
yogaChild: YogaNode,
|
|
223
|
+
child: SceneNode,
|
|
224
|
+
parent: SceneNode,
|
|
225
|
+
graph: SceneGraph
|
|
226
|
+
): void {
|
|
227
|
+
yogaChild.setDisplay(Display.Grid)
|
|
228
|
+
|
|
229
|
+
if (child.gridTemplateColumns.length > 0) {
|
|
230
|
+
yogaChild.setGridTemplateColumns(child.gridTemplateColumns.map(mapGridTrack))
|
|
231
|
+
}
|
|
232
|
+
if (child.gridTemplateRows.length > 0) {
|
|
233
|
+
yogaChild.setGridTemplateRows(child.gridTemplateRows.map(mapGridTrack))
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
yogaChild.setGap(Gutter.Column, child.gridColumnGap)
|
|
237
|
+
yogaChild.setGap(Gutter.Row, child.gridRowGap)
|
|
238
|
+
|
|
239
|
+
yogaChild.setPadding(Edge.Top, child.paddingTop)
|
|
240
|
+
yogaChild.setPadding(Edge.Right, child.paddingRight)
|
|
241
|
+
yogaChild.setPadding(Edge.Bottom, child.paddingBottom)
|
|
242
|
+
yogaChild.setPadding(Edge.Left, child.paddingLeft)
|
|
243
|
+
|
|
244
|
+
const isParentRow = parent.layoutMode === 'HORIZONTAL'
|
|
245
|
+
const selfOverride = child.layoutAlignSelf !== 'AUTO'
|
|
246
|
+
const stretchCross = selfOverride
|
|
247
|
+
? child.layoutAlignSelf === 'STRETCH'
|
|
248
|
+
: parent.counterAxisAlign === 'STRETCH'
|
|
249
|
+
|
|
250
|
+
if (child.layoutGrow > 0) {
|
|
251
|
+
yogaChild.setFlexGrow(child.layoutGrow)
|
|
252
|
+
yogaChild.setFlexShrink(1)
|
|
253
|
+
yogaChild.setFlexBasis(0)
|
|
254
|
+
if (!stretchCross) {
|
|
255
|
+
if (isParentRow) yogaChild.setHeight(child.height)
|
|
256
|
+
else yogaChild.setWidth(child.width)
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
if (isParentRow) {
|
|
260
|
+
yogaChild.setWidth(child.width)
|
|
261
|
+
if (!stretchCross) yogaChild.setHeight(child.height)
|
|
262
|
+
} else {
|
|
263
|
+
if (child.gridTemplateRows.length > 0) yogaChild.setHeight(child.height)
|
|
264
|
+
if (!stretchCross) yogaChild.setWidth(child.width)
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const selfAlign = mapAlignSelf(child.layoutAlignSelf)
|
|
269
|
+
if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)
|
|
270
|
+
|
|
271
|
+
applyMinMaxConstraints(yogaChild, child)
|
|
272
|
+
|
|
273
|
+
const grandchildren = graph.getChildren(child.id)
|
|
274
|
+
for (const gc of grandchildren) {
|
|
275
|
+
if (gc.layoutPositioning === 'ABSOLUTE') {
|
|
276
|
+
const yogaGC = Yoga.Node.create()
|
|
277
|
+
configureAbsoluteChild(yogaGC, gc)
|
|
278
|
+
yogaChild.insertChild(yogaGC, yogaChild.getChildCount())
|
|
279
|
+
} else {
|
|
280
|
+
yogaChild.insertChild(createGridChildNode(gc), yogaChild.getChildCount())
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function applyMinMaxConstraints(yogaNode: YogaNode, node: SceneNode): void {
|
|
286
|
+
if (node.minWidth != null) yogaNode.setMinWidth(node.minWidth)
|
|
287
|
+
if (node.maxWidth != null) yogaNode.setMaxWidth(node.maxWidth)
|
|
288
|
+
if (node.minHeight != null) yogaNode.setMinHeight(node.minHeight)
|
|
289
|
+
if (node.maxHeight != null) yogaNode.setMaxHeight(node.maxHeight)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function configureChildAsAutoLayout(
|
|
293
|
+
yogaChild: YogaNode,
|
|
294
|
+
child: SceneNode,
|
|
295
|
+
parent: SceneNode,
|
|
296
|
+
graph: SceneGraph
|
|
297
|
+
): void {
|
|
298
|
+
const isParentRow = parent.layoutMode === 'HORIZONTAL'
|
|
299
|
+
const isChildRow = child.layoutMode === 'HORIZONTAL'
|
|
300
|
+
|
|
301
|
+
const widthSizing = isChildRow ? child.primaryAxisSizing : child.counterAxisSizing
|
|
302
|
+
const heightSizing = isChildRow ? child.counterAxisSizing : child.primaryAxisSizing
|
|
303
|
+
|
|
304
|
+
if (isParentRow) {
|
|
305
|
+
setSizing(yogaChild, 'width', widthSizing, child.width, child.layoutGrow)
|
|
306
|
+
setSizing(yogaChild, 'height', heightSizing, child.height, 0)
|
|
307
|
+
} else {
|
|
308
|
+
setSizing(yogaChild, 'width', widthSizing, child.width, 0)
|
|
309
|
+
setSizing(yogaChild, 'height', heightSizing, child.height, child.layoutGrow)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const selfAlign = mapAlignSelf(child.layoutAlignSelf)
|
|
313
|
+
if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)
|
|
314
|
+
|
|
315
|
+
configureFlexContainer(yogaChild, child)
|
|
316
|
+
|
|
317
|
+
const grandchildren = graph.getChildren(child.id)
|
|
318
|
+
for (const gc of grandchildren) {
|
|
319
|
+
const yogaGC = Yoga.Node.create()
|
|
320
|
+
if (gc.layoutPositioning === 'ABSOLUTE') {
|
|
321
|
+
configureAbsoluteChild(yogaGC, gc)
|
|
322
|
+
} else if (!gc.visible) {
|
|
323
|
+
yogaGC.setDisplay(Display.None)
|
|
324
|
+
} else if (gc.layoutMode === 'GRID') {
|
|
325
|
+
configureChildAsGrid(yogaGC, gc, child, graph)
|
|
326
|
+
} else if (gc.layoutMode !== 'NONE') {
|
|
327
|
+
configureChildAsAutoLayout(yogaGC, gc, child, graph)
|
|
328
|
+
} else {
|
|
329
|
+
configureChildAsLeaf(yogaGC, gc, child)
|
|
330
|
+
}
|
|
331
|
+
yogaChild.insertChild(yogaGC, yogaChild.getChildCount())
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function configureChildAsLeaf(yogaChild: YogaNode, child: SceneNode, parent: SceneNode): void {
|
|
336
|
+
const isRow = parent.layoutMode === 'HORIZONTAL'
|
|
337
|
+
const selfOverride = child.layoutAlignSelf !== 'AUTO'
|
|
338
|
+
const stretchCross = selfOverride
|
|
339
|
+
? child.layoutAlignSelf === 'STRETCH'
|
|
340
|
+
: parent.counterAxisAlign === 'STRETCH'
|
|
341
|
+
|
|
342
|
+
const isText = child.type === 'TEXT'
|
|
343
|
+
const needsMeasureFunc =
|
|
344
|
+
isText && globalTextMeasurer && child.textAutoResize !== 'NONE'
|
|
345
|
+
|
|
346
|
+
if (needsMeasureFunc) {
|
|
347
|
+
configureTextLeaf(yogaChild, child, parent)
|
|
348
|
+
} else if (isText && !globalTextMeasurer && child.textAutoResize !== 'NONE') {
|
|
349
|
+
const est = estimateTextSize(child)
|
|
350
|
+
if (child.textAutoResize === 'WIDTH_AND_HEIGHT') {
|
|
351
|
+
yogaChild.setWidth(est.width)
|
|
352
|
+
yogaChild.setHeight(est.height)
|
|
353
|
+
} else if (child.textAutoResize === 'HEIGHT') {
|
|
354
|
+
yogaChild.setWidth(child.width)
|
|
355
|
+
yogaChild.setHeight(est.height)
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
configureNonTextLeaf(yogaChild, child, isRow, stretchCross)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const selfAlign = mapAlignSelf(child.layoutAlignSelf)
|
|
362
|
+
if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)
|
|
363
|
+
|
|
364
|
+
applyMinMaxConstraints(yogaChild, child)
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Fallback text size estimate when CanvasKit is unavailable (headless/tests).
|
|
368
|
+
// Without this, text nodes keep their 100×100 default and blow up HUG containers.
|
|
369
|
+
function estimateTextSize(node: SceneNode): { width: number; height: number } {
|
|
370
|
+
const fontSize = node.fontSize || 14
|
|
371
|
+
const lineHeight = fontSize * 1.2
|
|
372
|
+
const charWidth = fontSize * GLYPH_WIDTH_FACTOR
|
|
373
|
+
return {
|
|
374
|
+
width: Math.ceil(node.text.length * charWidth),
|
|
375
|
+
height: Math.ceil(lineHeight)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function configureTextLeaf(
|
|
380
|
+
yogaChild: YogaNode,
|
|
381
|
+
child: SceneNode,
|
|
382
|
+
_parent: SceneNode
|
|
383
|
+
): void {
|
|
384
|
+
const autoResize = child.textAutoResize
|
|
385
|
+
|
|
386
|
+
if (child.layoutGrow > 0) {
|
|
387
|
+
yogaChild.setFlexGrow(child.layoutGrow)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const cache = new Map<number, { width: number; height: number }>()
|
|
391
|
+
const UNCONSTRAINED_KEY = -1
|
|
392
|
+
|
|
393
|
+
if (autoResize === 'WIDTH_AND_HEIGHT') {
|
|
394
|
+
yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {
|
|
395
|
+
const maxW = widthMode === MeasureMode.Undefined ? undefined : width
|
|
396
|
+
const cacheKey = maxW === undefined ? UNCONSTRAINED_KEY : Math.round(maxW)
|
|
397
|
+
const cached = cache.get(cacheKey)
|
|
398
|
+
if (cached) return cached
|
|
399
|
+
|
|
400
|
+
const measured = globalTextMeasurer?.(child, maxW)
|
|
401
|
+
const result = measured ?? { width: child.width, height: child.height }
|
|
402
|
+
cache.set(cacheKey, result)
|
|
403
|
+
return result
|
|
404
|
+
})
|
|
405
|
+
} else if (autoResize === 'HEIGHT') {
|
|
406
|
+
const fixedWidth = child.width
|
|
407
|
+
if (child.layoutGrow <= 0) {
|
|
408
|
+
yogaChild.setWidth(fixedWidth)
|
|
409
|
+
}
|
|
410
|
+
yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {
|
|
411
|
+
const constraintW =
|
|
412
|
+
widthMode === MeasureMode.Undefined ? fixedWidth : Math.min(width, fixedWidth || width)
|
|
413
|
+
const cacheKey = Math.round(constraintW)
|
|
414
|
+
const cached = cache.get(cacheKey)
|
|
415
|
+
if (cached) return cached
|
|
416
|
+
|
|
417
|
+
const measured = globalTextMeasurer?.(child, constraintW)
|
|
418
|
+
const result = { width: constraintW, height: measured?.height ?? child.height }
|
|
419
|
+
cache.set(cacheKey, result)
|
|
420
|
+
return result
|
|
421
|
+
})
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function configureNonTextLeaf(
|
|
426
|
+
yogaChild: YogaNode,
|
|
427
|
+
child: SceneNode,
|
|
428
|
+
isRow: boolean,
|
|
429
|
+
stretchCross: boolean
|
|
430
|
+
): void {
|
|
431
|
+
const w = child.width
|
|
432
|
+
const h = child.height
|
|
433
|
+
|
|
434
|
+
if (child.layoutGrow > 0) {
|
|
435
|
+
yogaChild.setFlexGrow(child.layoutGrow)
|
|
436
|
+
if (!stretchCross) {
|
|
437
|
+
if (isRow) yogaChild.setHeight(h)
|
|
438
|
+
else yogaChild.setWidth(w)
|
|
439
|
+
}
|
|
440
|
+
} else {
|
|
441
|
+
if (isRow) {
|
|
442
|
+
yogaChild.setWidth(w)
|
|
443
|
+
if (!stretchCross) yogaChild.setHeight(h)
|
|
444
|
+
} else {
|
|
445
|
+
yogaChild.setHeight(h)
|
|
446
|
+
if (!stretchCross) yogaChild.setWidth(w)
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function setSizing(
|
|
452
|
+
yogaNode: YogaNode,
|
|
453
|
+
axis: 'width' | 'height',
|
|
454
|
+
sizing: string,
|
|
455
|
+
fixedValue: number,
|
|
456
|
+
grow: number
|
|
457
|
+
): void {
|
|
458
|
+
if (grow > 0) {
|
|
459
|
+
yogaNode.setFlexGrow(grow)
|
|
460
|
+
yogaNode.setFlexShrink(1)
|
|
461
|
+
yogaNode.setFlexBasis(0)
|
|
462
|
+
return
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
switch (sizing) {
|
|
466
|
+
case 'FIXED':
|
|
467
|
+
if (axis === 'width') yogaNode.setWidth(fixedValue)
|
|
468
|
+
else yogaNode.setHeight(fixedValue)
|
|
469
|
+
break
|
|
470
|
+
case 'HUG':
|
|
471
|
+
break
|
|
472
|
+
case 'FILL':
|
|
473
|
+
yogaNode.setFlexGrow(1)
|
|
474
|
+
yogaNode.setFlexShrink(1)
|
|
475
|
+
yogaNode.setFlexBasis(0)
|
|
476
|
+
break
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function applyFrameSize(graph: SceneGraph, frame: SceneNode, yogaNode: YogaNode): void {
|
|
481
|
+
if (frame.layoutMode === 'GRID') {
|
|
482
|
+
if (frame.gridTemplateRows.length === 0) {
|
|
483
|
+
graph.updateNode(frame.id, { height: yogaNode.getComputedHeight() })
|
|
484
|
+
}
|
|
485
|
+
return
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (frame.primaryAxisSizing !== 'HUG' && frame.counterAxisSizing !== 'HUG') return
|
|
489
|
+
|
|
490
|
+
const computedW = yogaNode.getComputedWidth()
|
|
491
|
+
const computedH = yogaNode.getComputedHeight()
|
|
492
|
+
const updates: Partial<SceneNode> = {}
|
|
493
|
+
|
|
494
|
+
if (frame.primaryAxisSizing === 'HUG') {
|
|
495
|
+
if (frame.layoutMode === 'HORIZONTAL') updates.width = computedW
|
|
496
|
+
else updates.height = computedH
|
|
497
|
+
}
|
|
498
|
+
if (frame.counterAxisSizing === 'HUG') {
|
|
499
|
+
if (frame.layoutMode === 'HORIZONTAL') updates.height = computedH
|
|
500
|
+
else updates.width = computedW
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
graph.updateNode(frame.id, updates)
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function applyYogaLayout(graph: SceneGraph, frame: SceneNode, yogaNode: YogaNode): void {
|
|
507
|
+
applyFrameSize(graph, frame, yogaNode)
|
|
508
|
+
|
|
509
|
+
const children = graph.getChildren(frame.id)
|
|
510
|
+
let yogaIndex = 0
|
|
511
|
+
for (const child of children) {
|
|
512
|
+
const yogaChild = yogaNode.getChild(yogaIndex)
|
|
513
|
+
yogaIndex++
|
|
514
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
515
|
+
if (!yogaChild) continue
|
|
516
|
+
|
|
517
|
+
if (child.visible && child.layoutPositioning !== 'ABSOLUTE') {
|
|
518
|
+
graph.updateNode(child.id, {
|
|
519
|
+
x: yogaChild.getComputedLeft(),
|
|
520
|
+
y: yogaChild.getComputedTop(),
|
|
521
|
+
width: yogaChild.getComputedWidth(),
|
|
522
|
+
height: yogaChild.getComputedHeight()
|
|
523
|
+
})
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (child.layoutMode !== 'NONE') {
|
|
527
|
+
if (child.layoutMode === 'GRID' && child.visible && child.layoutPositioning !== 'ABSOLUTE') {
|
|
528
|
+
computeLayout(graph, child.id)
|
|
529
|
+
} else if (frame.layoutMode === 'GRID' && child.visible && child.layoutPositioning !== 'ABSOLUTE') {
|
|
530
|
+
recomputeGridChild(graph, child)
|
|
531
|
+
} else {
|
|
532
|
+
applyYogaLayout(graph, child, yogaChild)
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function recomputeGridChild(graph: SceneGraph, child: SceneNode): void {
|
|
539
|
+
const updated = graph.getNode(child.id)
|
|
540
|
+
if (!updated || updated.layoutMode === 'NONE') return
|
|
541
|
+
|
|
542
|
+
const savedPrimary = updated.primaryAxisSizing
|
|
543
|
+
const savedCounter = updated.counterAxisSizing
|
|
544
|
+
const updates: Partial<SceneNode> = {}
|
|
545
|
+
|
|
546
|
+
if (savedPrimary === 'HUG') updates.primaryAxisSizing = 'FIXED'
|
|
547
|
+
if (savedCounter === 'HUG') updates.counterAxisSizing = 'FIXED'
|
|
548
|
+
if (Object.keys(updates).length > 0) graph.updateNode(child.id, updates)
|
|
549
|
+
|
|
550
|
+
computeLayout(graph, child.id)
|
|
551
|
+
|
|
552
|
+
const restore: Partial<SceneNode> = {}
|
|
553
|
+
if (updates.primaryAxisSizing) restore.primaryAxisSizing = savedPrimary
|
|
554
|
+
if (updates.counterAxisSizing) restore.counterAxisSizing = savedCounter
|
|
555
|
+
if (Object.keys(restore).length > 0) graph.updateNode(child.id, restore)
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function freeYogaTree(node: YogaNode): void {
|
|
559
|
+
for (let i = node.getChildCount() - 1; i >= 0; i--) {
|
|
560
|
+
freeYogaTree(node.getChild(i))
|
|
561
|
+
}
|
|
562
|
+
if ('free' in node) (node as { free(): void }).free()
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function mapJustify(align: string): Justify {
|
|
566
|
+
switch (align) {
|
|
567
|
+
case 'CENTER':
|
|
568
|
+
return Justify.Center
|
|
569
|
+
case 'MAX':
|
|
570
|
+
return Justify.FlexEnd
|
|
571
|
+
case 'SPACE_BETWEEN':
|
|
572
|
+
return Justify.SpaceBetween
|
|
573
|
+
default:
|
|
574
|
+
return Justify.FlexStart
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function mapAlign(align: string): Align {
|
|
579
|
+
switch (align) {
|
|
580
|
+
case 'CENTER':
|
|
581
|
+
return Align.Center
|
|
582
|
+
case 'MAX':
|
|
583
|
+
return Align.FlexEnd
|
|
584
|
+
case 'STRETCH':
|
|
585
|
+
return Align.Stretch
|
|
586
|
+
case 'BASELINE':
|
|
587
|
+
return Align.Baseline
|
|
588
|
+
default:
|
|
589
|
+
return Align.FlexStart
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function mapAlignSelf(alignSelf: string): Align | null {
|
|
594
|
+
switch (alignSelf) {
|
|
595
|
+
case 'MIN':
|
|
596
|
+
return Align.FlexStart
|
|
597
|
+
case 'CENTER':
|
|
598
|
+
return Align.Center
|
|
599
|
+
case 'MAX':
|
|
600
|
+
return Align.FlexEnd
|
|
601
|
+
case 'STRETCH':
|
|
602
|
+
return Align.Stretch
|
|
603
|
+
case 'BASELINE':
|
|
604
|
+
return Align.Baseline
|
|
605
|
+
default:
|
|
606
|
+
return null
|
|
607
|
+
}
|
|
608
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const DRAW_METHODS = [
|
|
2
|
+
'drawArrays',
|
|
3
|
+
'drawElements',
|
|
4
|
+
'drawArraysInstanced',
|
|
5
|
+
'drawElementsInstanced'
|
|
6
|
+
] as const
|
|
7
|
+
|
|
8
|
+
type DrawMethod = (typeof DRAW_METHODS)[number]
|
|
9
|
+
|
|
10
|
+
export class DrawCallCounter {
|
|
11
|
+
count = 0
|
|
12
|
+
|
|
13
|
+
private originals = new Map<DrawMethod, (...args: unknown[]) => void>()
|
|
14
|
+
private gl: WebGL2RenderingContext | null
|
|
15
|
+
|
|
16
|
+
constructor(gl: WebGL2RenderingContext | null) {
|
|
17
|
+
this.gl = gl
|
|
18
|
+
if (!gl) return
|
|
19
|
+
|
|
20
|
+
for (const method of DRAW_METHODS) {
|
|
21
|
+
const original = gl[method].bind(gl) as (...args: unknown[]) => void
|
|
22
|
+
this.originals.set(method, original)
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- monkey-patching overloaded WebGL draw methods
|
|
24
|
+
;(gl[method] as Function) = (...args: unknown[]) => { this.count++; original(...args) }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
reset(): number {
|
|
29
|
+
const prev = this.count
|
|
30
|
+
this.count = 0
|
|
31
|
+
return prev
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
destroy(): void {
|
|
35
|
+
const gl = this.gl
|
|
36
|
+
if (!gl) return
|
|
37
|
+
|
|
38
|
+
for (const [method, fn] of this.originals) {
|
|
39
|
+
;(gl[method] as Function) = fn
|
|
40
|
+
}
|
|
41
|
+
this.originals.clear()
|
|
42
|
+
}
|
|
43
|
+
}
|