@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/fonts.ts
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_FONT_FAMILY,
|
|
5
|
+
CJK_FALLBACK_FAMILIES_MACOS,
|
|
6
|
+
CJK_FALLBACK_FAMILIES_WINDOWS,
|
|
7
|
+
CJK_FALLBACK_FAMILIES_LINUX,
|
|
8
|
+
CJK_GOOGLE_FONT,
|
|
9
|
+
GOOGLE_FONTS_API_KEY
|
|
10
|
+
} from './constants'
|
|
11
|
+
import type { SceneGraph } from './scene-graph'
|
|
12
|
+
|
|
13
|
+
export interface FontInfo {
|
|
14
|
+
family: string
|
|
15
|
+
fullName: string
|
|
16
|
+
style: string
|
|
17
|
+
postscriptName: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const loadedFamilies = new Map<string, ArrayBuffer>()
|
|
21
|
+
const loadedFamilyNames = new Set<string>()
|
|
22
|
+
let fontProvider: TypefaceFontProvider | null = null
|
|
23
|
+
|
|
24
|
+
export function initFontService(_canvasKit: CanvasKit, provider: TypefaceFontProvider) {
|
|
25
|
+
fontProvider = provider
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getFontProvider(): TypefaceFontProvider | null {
|
|
29
|
+
return fontProvider
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function queryFonts(): Promise<FontInfo[]> {
|
|
33
|
+
if (typeof window === 'undefined' || !window.queryLocalFonts) return []
|
|
34
|
+
try {
|
|
35
|
+
const fonts = await window.queryLocalFonts()
|
|
36
|
+
const seen = new Set<string>()
|
|
37
|
+
const result: FontInfo[] = []
|
|
38
|
+
for (const f of fonts) {
|
|
39
|
+
const key = `${f.family}|${f.style}`
|
|
40
|
+
if (seen.has(key)) continue
|
|
41
|
+
seen.add(key)
|
|
42
|
+
result.push({
|
|
43
|
+
family: f.family,
|
|
44
|
+
fullName: f.fullName,
|
|
45
|
+
style: f.style,
|
|
46
|
+
postscriptName: f.postscriptName
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
return result
|
|
50
|
+
} catch {
|
|
51
|
+
return []
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function listFamilies(): Promise<string[]> {
|
|
56
|
+
const fonts = await queryFonts()
|
|
57
|
+
return [...new Set(fonts.map((f) => f.family))].sort()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const BUNDLED_FONTS: Record<string, string> = {
|
|
61
|
+
'Inter|Regular': '/Inter-Regular.ttf'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const googleFontsCache = new Map<string, Record<string, string>>()
|
|
65
|
+
const googleFontsFailed = new Set<string>()
|
|
66
|
+
|
|
67
|
+
function normalizeFontFamily(family: string): string {
|
|
68
|
+
return family.replace(/\s+Variable$/i, '')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function tryNormalizedFallback(family: string): Promise<Record<string, string> | null> {
|
|
72
|
+
const normalized = normalizeFontFamily(family)
|
|
73
|
+
if (normalized !== family) {
|
|
74
|
+
const result = await fetchGoogleFontFiles(normalized)
|
|
75
|
+
if (result) googleFontsCache.set(family, result)
|
|
76
|
+
else googleFontsFailed.add(family)
|
|
77
|
+
return result
|
|
78
|
+
}
|
|
79
|
+
googleFontsFailed.add(family)
|
|
80
|
+
return null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function fetchGoogleFontFiles(family: string): Promise<Record<string, string> | null> {
|
|
84
|
+
if (googleFontsCache.has(family)) return googleFontsCache.get(family) ?? null
|
|
85
|
+
if (googleFontsFailed.has(family)) return null
|
|
86
|
+
|
|
87
|
+
const url = `https://www.googleapis.com/webfonts/v1/webfonts?family=${encodeURIComponent(family)}&key=${GOOGLE_FONTS_API_KEY}`
|
|
88
|
+
let response: Response
|
|
89
|
+
try {
|
|
90
|
+
response = await fetch(url)
|
|
91
|
+
} catch {
|
|
92
|
+
googleFontsFailed.add(family)
|
|
93
|
+
return null
|
|
94
|
+
}
|
|
95
|
+
if (!response.ok) {
|
|
96
|
+
return tryNormalizedFallback(family)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const data = (await response.json()) as { items?: Array<{ files?: Record<string, string> }> }
|
|
100
|
+
const files = data.items?.[0]?.files
|
|
101
|
+
if (!files) {
|
|
102
|
+
return tryNormalizedFallback(family)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
googleFontsCache.set(family, files)
|
|
106
|
+
return files
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function styleToVariant(style: string): string {
|
|
110
|
+
const weight = styleToWeight(style)
|
|
111
|
+
const italic = style.toLowerCase().includes('italic')
|
|
112
|
+
if (weight === 400 && !italic) return 'regular'
|
|
113
|
+
if (weight === 400 && italic) return 'italic'
|
|
114
|
+
return italic ? `${weight}italic` : `${weight}`
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function fetchGoogleFont(family: string, style: string): Promise<ArrayBuffer | null> {
|
|
118
|
+
const files = await fetchGoogleFontFiles(family)
|
|
119
|
+
if (!files) return null
|
|
120
|
+
|
|
121
|
+
const variant = styleToVariant(style)
|
|
122
|
+
const ttfUrl = files[variant] ?? files['regular']
|
|
123
|
+
if (!ttfUrl) return null
|
|
124
|
+
|
|
125
|
+
const response = await fetch(ttfUrl)
|
|
126
|
+
if (!response.ok) return null
|
|
127
|
+
|
|
128
|
+
return response.arrayBuffer()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function loadFont(family: string, style = 'Regular'): Promise<ArrayBuffer | null> {
|
|
132
|
+
const cacheKey = `${family}|${style}`
|
|
133
|
+
if (loadedFamilies.has(cacheKey)) {
|
|
134
|
+
const cached = loadedFamilies.get(cacheKey)
|
|
135
|
+
if (!cached) return null
|
|
136
|
+
registerFontInCanvasKit(family, cached)
|
|
137
|
+
return cached
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Try local font access API first (browser only)
|
|
141
|
+
if (window.queryLocalFonts) {
|
|
142
|
+
try {
|
|
143
|
+
const fonts = await window.queryLocalFonts()
|
|
144
|
+
const normalized = normalizeFontFamily(family)
|
|
145
|
+
const match =
|
|
146
|
+
fonts.find((f: FontInfo) => f.family === family && f.style === style) ??
|
|
147
|
+
fonts.find((f: FontInfo) => f.family === family) ??
|
|
148
|
+
(normalized !== family
|
|
149
|
+
? (fonts.find((f: FontInfo) => f.family === normalized && f.style === style) ??
|
|
150
|
+
fonts.find((f: FontInfo) => f.family === normalized))
|
|
151
|
+
: undefined)
|
|
152
|
+
if (match) {
|
|
153
|
+
const blob: Blob = await match.blob()
|
|
154
|
+
const buffer = await blob.arrayBuffer()
|
|
155
|
+
|
|
156
|
+
if (registerFontInCanvasKit(family, buffer)) {
|
|
157
|
+
loadedFamilies.set(cacheKey, buffer)
|
|
158
|
+
loadedFamilyNames.add(family)
|
|
159
|
+
registerFontInBrowser(family, style, buffer)
|
|
160
|
+
return buffer
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} catch {
|
|
164
|
+
/* fall through to Google Fonts */
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Try Google Fonts
|
|
169
|
+
if (typeof fetch !== 'undefined') {
|
|
170
|
+
try {
|
|
171
|
+
const buffer = await fetchGoogleFont(family, style)
|
|
172
|
+
if (buffer && registerFontInCanvasKit(family, buffer)) {
|
|
173
|
+
loadedFamilies.set(cacheKey, buffer)
|
|
174
|
+
loadedFamilyNames.add(family)
|
|
175
|
+
registerFontInBrowser(family, style, buffer)
|
|
176
|
+
return buffer
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
/* fall through to bundled */
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Fall back to bundled font
|
|
184
|
+
const bundledUrl = BUNDLED_FONTS[cacheKey]
|
|
185
|
+
if (bundledUrl) {
|
|
186
|
+
try {
|
|
187
|
+
const response = await fetch(bundledUrl)
|
|
188
|
+
const buffer = await response.arrayBuffer()
|
|
189
|
+
|
|
190
|
+
if (registerFontInCanvasKit(family, buffer)) {
|
|
191
|
+
loadedFamilies.set(cacheKey, buffer)
|
|
192
|
+
loadedFamilyNames.add(family)
|
|
193
|
+
registerFontInBrowser(family, style, buffer)
|
|
194
|
+
return buffer
|
|
195
|
+
}
|
|
196
|
+
} catch {
|
|
197
|
+
/* no bundled font available */
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Last resort: register the default font (Inter) under the missing family name
|
|
202
|
+
// so text nodes still render with correct content instead of being invisible.
|
|
203
|
+
const defaultData = loadedFamilies.get(`${DEFAULT_FONT_FAMILY}|Regular`)
|
|
204
|
+
if (defaultData && registerFontInCanvasKit(family, defaultData)) {
|
|
205
|
+
loadedFamilies.set(cacheKey, defaultData)
|
|
206
|
+
loadedFamilyNames.add(family)
|
|
207
|
+
registerFontInBrowser(family, style, defaultData)
|
|
208
|
+
return defaultData
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return null
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function registerFontInCanvasKit(family: string, data: ArrayBuffer): boolean {
|
|
215
|
+
if (!fontProvider || data.byteLength < 4) return false
|
|
216
|
+
try {
|
|
217
|
+
fontProvider.registerFont(data, family)
|
|
218
|
+
return true
|
|
219
|
+
} catch {
|
|
220
|
+
return false
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function registerFontInBrowser(family: string, style: string, data: ArrayBuffer) {
|
|
225
|
+
if (typeof document === 'undefined') return
|
|
226
|
+
const weight = styleToWeight(style)
|
|
227
|
+
const italic = style.toLowerCase().includes('italic') ? 'italic' : 'normal'
|
|
228
|
+
const face = new FontFace(family, data, {
|
|
229
|
+
weight: String(weight),
|
|
230
|
+
style: italic
|
|
231
|
+
})
|
|
232
|
+
face.load().then(() => document.fonts.add(face)).catch(() => {
|
|
233
|
+
console.warn(`Failed to load font "${family}" (${style})`)
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function styleToWeight(style: string): number {
|
|
238
|
+
const s = style.toLowerCase().replace(/[\s-_]/g, '')
|
|
239
|
+
if (s.includes('thin') || s.includes('hairline')) return 100
|
|
240
|
+
if (s.includes('extralight') || s.includes('ultralight')) return 200
|
|
241
|
+
if (s.includes('light')) return 300
|
|
242
|
+
if (s.includes('medium')) return 500
|
|
243
|
+
if (s.includes('semibold') || s.includes('demibold')) return 600
|
|
244
|
+
if (s.includes('extrabold') || s.includes('ultrabold')) return 800
|
|
245
|
+
if (s.includes('black') || s.includes('heavy')) return 900
|
|
246
|
+
if (s.includes('bold')) return 700
|
|
247
|
+
return 400
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export async function ensureNodeFont(family: string, weight: number): Promise<void> {
|
|
251
|
+
const style = weightToStyle(weight)
|
|
252
|
+
await loadFont(family, style)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function markFontLoaded(family: string, style: string, data: ArrayBuffer): void {
|
|
256
|
+
const cacheKey = `${family}|${style}`
|
|
257
|
+
loadedFamilies.set(cacheKey, data)
|
|
258
|
+
loadedFamilyNames.add(family)
|
|
259
|
+
registerFontInCanvasKit(family, data)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function isFontLoaded(family: string): boolean {
|
|
263
|
+
return loadedFamilyNames.has(family)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function getLoadedFontData(family: string, style: string): ArrayBuffer | null {
|
|
267
|
+
return loadedFamilies.get(`${family}|${style}`) ?? null
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function collectFontKeys(graph: SceneGraph, nodeIds: string[]): Array<[string, string]> {
|
|
271
|
+
const fontKeys = new Set<string>()
|
|
272
|
+
const collect = (id: string) => {
|
|
273
|
+
const node = graph.getNode(id)
|
|
274
|
+
if (!node) return
|
|
275
|
+
if (node.type === 'TEXT') {
|
|
276
|
+
const family = node.fontFamily || DEFAULT_FONT_FAMILY
|
|
277
|
+
fontKeys.add(`${family}\0${weightToStyle(node.fontWeight || 400, node.italic)}`)
|
|
278
|
+
for (const run of node.styleRuns) {
|
|
279
|
+
const f = run.style.fontFamily ?? family
|
|
280
|
+
const w = run.style.fontWeight ?? node.fontWeight
|
|
281
|
+
const i = run.style.italic ?? node.italic
|
|
282
|
+
fontKeys.add(`${f}\0${weightToStyle(w, i)}`)
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
for (const childId of node.childIds) collect(childId)
|
|
286
|
+
}
|
|
287
|
+
for (const id of nodeIds) collect(id)
|
|
288
|
+
|
|
289
|
+
return [...fontKeys]
|
|
290
|
+
.map((k) => k.split('\0') as [string, string])
|
|
291
|
+
.filter(([family]) => family !== DEFAULT_FONT_FAMILY)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let cjkFallbackFamily: string | null = null
|
|
295
|
+
let cjkFallbackPromise: Promise<string | null> | null = null
|
|
296
|
+
|
|
297
|
+
function getCJKCandidates(): string[] {
|
|
298
|
+
if (typeof navigator === 'undefined') return [...CJK_FALLBACK_FAMILIES_LINUX]
|
|
299
|
+
const ua = navigator.userAgent
|
|
300
|
+
if (ua.includes('Mac')) return CJK_FALLBACK_FAMILIES_MACOS
|
|
301
|
+
if (ua.includes('Windows')) return CJK_FALLBACK_FAMILIES_WINDOWS
|
|
302
|
+
return CJK_FALLBACK_FAMILIES_LINUX
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async function tryLoadLocalFont(family: string): Promise<ArrayBuffer | null> {
|
|
306
|
+
if (typeof window === 'undefined' || !window.queryLocalFonts) return null
|
|
307
|
+
try {
|
|
308
|
+
const fonts = await window.queryLocalFonts()
|
|
309
|
+
const match = fonts.find((f: FontInfo) => f.family === family)
|
|
310
|
+
if (!match) return null
|
|
311
|
+
const blob: Blob = await match.blob()
|
|
312
|
+
const buffer = await blob.arrayBuffer()
|
|
313
|
+
if (!registerFontInCanvasKit(family, buffer)) return null
|
|
314
|
+
const cacheKey = `${family}|Regular`
|
|
315
|
+
loadedFamilies.set(cacheKey, buffer)
|
|
316
|
+
loadedFamilyNames.add(family)
|
|
317
|
+
registerFontInBrowser(family, 'Regular', buffer)
|
|
318
|
+
return buffer
|
|
319
|
+
} catch {
|
|
320
|
+
return null
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export async function ensureCJKFallback(): Promise<string | null> {
|
|
325
|
+
if (cjkFallbackFamily) return cjkFallbackFamily
|
|
326
|
+
if (cjkFallbackPromise) return cjkFallbackPromise
|
|
327
|
+
|
|
328
|
+
cjkFallbackPromise = (async () => {
|
|
329
|
+
for (const family of getCJKCandidates()) {
|
|
330
|
+
if (await tryLoadLocalFont(family)) {
|
|
331
|
+
cjkFallbackFamily = family
|
|
332
|
+
return family
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const data = await loadFont(CJK_GOOGLE_FONT, 'Regular')
|
|
337
|
+
if (data) {
|
|
338
|
+
cjkFallbackFamily = CJK_GOOGLE_FONT
|
|
339
|
+
return CJK_GOOGLE_FONT
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return null
|
|
343
|
+
})()
|
|
344
|
+
|
|
345
|
+
return cjkFallbackPromise
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export function getCJKFallbackFamily(): string | null {
|
|
349
|
+
return cjkFallbackFamily
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export function setCJKFallbackFamily(family: string): void {
|
|
353
|
+
cjkFallbackFamily = family
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export function weightToStyle(weight: number, italic = false): string {
|
|
357
|
+
let label = 'Regular'
|
|
358
|
+
if (weight <= 100) label = 'Thin'
|
|
359
|
+
else if (weight <= 200) label = 'ExtraLight'
|
|
360
|
+
else if (weight <= 300) label = 'Light'
|
|
361
|
+
else if (weight <= 400) label = 'Regular'
|
|
362
|
+
else if (weight <= 500) label = 'Medium'
|
|
363
|
+
else if (weight <= 600) label = 'SemiBold'
|
|
364
|
+
else if (weight <= 700) label = 'Bold'
|
|
365
|
+
else if (weight <= 800) label = 'ExtraBold'
|
|
366
|
+
else if (weight >= 900) label = 'Black'
|
|
367
|
+
if (italic) label += ' Italic'
|
|
368
|
+
return label
|
|
369
|
+
}
|
package/src/geometry.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Vector } from './types'
|
|
2
|
+
|
|
3
|
+
export function degToRad(degrees: number): number {
|
|
4
|
+
return (degrees * Math.PI) / 180
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function radToDeg(radians: number): number {
|
|
8
|
+
return (radians * 180) / Math.PI
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function rotatePoint(
|
|
12
|
+
px: number,
|
|
13
|
+
py: number,
|
|
14
|
+
cx: number,
|
|
15
|
+
cy: number,
|
|
16
|
+
rad: number
|
|
17
|
+
): Vector {
|
|
18
|
+
const cos = Math.cos(rad)
|
|
19
|
+
const sin = Math.sin(rad)
|
|
20
|
+
return {
|
|
21
|
+
x: cx + (px - cx) * cos - (py - cy) * sin,
|
|
22
|
+
y: cy + (px - cx) * sin + (py - cy) * cos
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function rotatedCorners(
|
|
27
|
+
cx: number,
|
|
28
|
+
cy: number,
|
|
29
|
+
hw: number,
|
|
30
|
+
hh: number,
|
|
31
|
+
rotationDeg: number
|
|
32
|
+
): [Vector, Vector, Vector, Vector] {
|
|
33
|
+
const rad = degToRad(rotationDeg)
|
|
34
|
+
const cos = Math.cos(rad)
|
|
35
|
+
const sin = Math.sin(rad)
|
|
36
|
+
return [
|
|
37
|
+
{ x: cx + -hw * cos - -hh * sin, y: cy + -hw * sin + -hh * cos },
|
|
38
|
+
{ x: cx + hw * cos - -hh * sin, y: cy + hw * sin + -hh * cos },
|
|
39
|
+
{ x: cx + hw * cos - hh * sin, y: cy + hw * sin + hh * cos },
|
|
40
|
+
{ x: cx + -hw * cos - hh * sin, y: cy + -hw * sin + hh * cos }
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function rotatedBBox(
|
|
45
|
+
x: number,
|
|
46
|
+
y: number,
|
|
47
|
+
w: number,
|
|
48
|
+
h: number,
|
|
49
|
+
rotationDeg: number
|
|
50
|
+
): { left: number; right: number; top: number; bottom: number; centerX: number; centerY: number } {
|
|
51
|
+
if (rotationDeg === 0) {
|
|
52
|
+
return {
|
|
53
|
+
left: x,
|
|
54
|
+
right: x + w,
|
|
55
|
+
top: y,
|
|
56
|
+
bottom: y + h,
|
|
57
|
+
centerX: x + w / 2,
|
|
58
|
+
centerY: y + h / 2
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const corners = rotatedCorners(x + w / 2, y + h / 2, w / 2, h / 2, rotationDeg)
|
|
62
|
+
let left = Infinity,
|
|
63
|
+
right = -Infinity,
|
|
64
|
+
top = Infinity,
|
|
65
|
+
bottom = -Infinity
|
|
66
|
+
for (const c of corners) {
|
|
67
|
+
left = Math.min(left, c.x)
|
|
68
|
+
right = Math.max(right, c.x)
|
|
69
|
+
top = Math.min(top, c.y)
|
|
70
|
+
bottom = Math.max(bottom, c.y)
|
|
71
|
+
}
|
|
72
|
+
return { left, right, top, bottom, centerX: (left + right) / 2, centerY: (top + bottom) / 2 }
|
|
73
|
+
}
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface ImportMetaEnv {
|
|
2
|
+
readonly VITE_GOOGLE_FONTS_API_KEY?: string
|
|
3
|
+
[key: string]: string | undefined
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface ImportMeta {
|
|
7
|
+
readonly env?: ImportMetaEnv
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface FontData {
|
|
11
|
+
family: string
|
|
12
|
+
fullName: string
|
|
13
|
+
postscriptName: string
|
|
14
|
+
style: string
|
|
15
|
+
blob(): Promise<Blob>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Window {
|
|
19
|
+
queryLocalFonts?(): Promise<FontData[]>
|
|
20
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
export type { GUID, Color, Vector, Matrix, Rect } from './types'
|
|
2
|
+
export { degToRad, radToDeg, rotatePoint, rotatedCorners, rotatedBBox } from './geometry'
|
|
3
|
+
|
|
4
|
+
export * from './constants'
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
SceneGraph,
|
|
8
|
+
generateId,
|
|
9
|
+
type SceneNode,
|
|
10
|
+
type NodeType,
|
|
11
|
+
type Fill,
|
|
12
|
+
type FillType,
|
|
13
|
+
type Stroke,
|
|
14
|
+
type StrokeCap,
|
|
15
|
+
type StrokeJoin,
|
|
16
|
+
type MaskType,
|
|
17
|
+
type Effect,
|
|
18
|
+
type BlendMode,
|
|
19
|
+
type ImageScaleMode,
|
|
20
|
+
type GradientStop,
|
|
21
|
+
type GradientTransform,
|
|
22
|
+
type LayoutMode,
|
|
23
|
+
type LayoutSizing,
|
|
24
|
+
type LayoutAlign,
|
|
25
|
+
type LayoutAlignSelf,
|
|
26
|
+
type LayoutCounterAlign,
|
|
27
|
+
type LayoutWrap,
|
|
28
|
+
type GridTrack,
|
|
29
|
+
type GridTrackSizing,
|
|
30
|
+
type GridPosition,
|
|
31
|
+
type ConstraintType,
|
|
32
|
+
type TextAutoResize,
|
|
33
|
+
type TextAlignVertical,
|
|
34
|
+
type TextCase,
|
|
35
|
+
type TextDecoration,
|
|
36
|
+
type ArcData,
|
|
37
|
+
type VectorNetwork,
|
|
38
|
+
type VectorVertex,
|
|
39
|
+
type VectorSegment,
|
|
40
|
+
type VectorRegion,
|
|
41
|
+
type GeometryPath,
|
|
42
|
+
type HandleMirroring,
|
|
43
|
+
type WindingRule,
|
|
44
|
+
type VariableType,
|
|
45
|
+
type VariableValue,
|
|
46
|
+
type Variable,
|
|
47
|
+
type VariableCollection,
|
|
48
|
+
type VariableCollectionMode,
|
|
49
|
+
type CharacterStyleOverride,
|
|
50
|
+
type StyleRun,
|
|
51
|
+
type SceneGraphEvents
|
|
52
|
+
} from './scene-graph'
|
|
53
|
+
|
|
54
|
+
export { FigmaAPI, FigmaNodeProxy, computeImageHash, type FigmaFontName } from './figma-api'
|
|
55
|
+
export { ALL_TOOLS, defineTool, toolsToAI, extractNodeIds, buildTailwindConfig } from './tools'
|
|
56
|
+
export type { ToolDef, ParamDef, ParamType } from './tools'
|
|
57
|
+
export { executeRpcCommand, ALL_RPC_COMMANDS } from './rpc'
|
|
58
|
+
export { queryByXPath, matchByXPath } from './xpath'
|
|
59
|
+
export type { XPathQueryOptions } from './xpath'
|
|
60
|
+
export type {
|
|
61
|
+
InfoResult, PageItem, TreeArgs, TreeResult, TreeNodeResult,
|
|
62
|
+
FindArgs, FindNodeResult, QueryArgs, QueryNodeResult, NodeArgs, NodeResult,
|
|
63
|
+
VariablesArgs, VariablesResult,
|
|
64
|
+
AnalyzeColorsArgs, AnalyzeColorsResult,
|
|
65
|
+
AnalyzeTypographyArgs, AnalyzeTypographyResult,
|
|
66
|
+
AnalyzeSpacingResult, SpacingValue,
|
|
67
|
+
AnalyzeClustersArgs, AnalyzeClustersResult, TypographyStyle
|
|
68
|
+
} from './rpc'
|
|
69
|
+
export { SkiaRenderer, type RenderOverlays } from './renderer/index'
|
|
70
|
+
export { LabelCache, type CachedSection, type CachedComponent } from './renderer/label-cache'
|
|
71
|
+
export {
|
|
72
|
+
RenderProfiler,
|
|
73
|
+
FrameStats,
|
|
74
|
+
GPUTimer,
|
|
75
|
+
DrawCallCounter,
|
|
76
|
+
PhaseTimer,
|
|
77
|
+
CaptureStack,
|
|
78
|
+
toSpeedscopeJSON
|
|
79
|
+
} from './profiler'
|
|
80
|
+
export type { FrameCapture, NodeProfile } from './profiler'
|
|
81
|
+
export { computeLayout, computeAllLayouts, setTextMeasurer } from './layout'
|
|
82
|
+
export type { TextMeasurer } from './layout'
|
|
83
|
+
export { getCanvasKit, getGpuBackend, type CanvasKitOptions, type GpuBackend } from './canvaskit'
|
|
84
|
+
export {
|
|
85
|
+
collectFontKeys,
|
|
86
|
+
loadFont,
|
|
87
|
+
listFamilies,
|
|
88
|
+
initFontService,
|
|
89
|
+
getFontProvider,
|
|
90
|
+
isFontLoaded,
|
|
91
|
+
getLoadedFontData,
|
|
92
|
+
markFontLoaded,
|
|
93
|
+
ensureNodeFont,
|
|
94
|
+
ensureCJKFallback,
|
|
95
|
+
getCJKFallbackFamily,
|
|
96
|
+
setCJKFallbackFamily,
|
|
97
|
+
styleToWeight,
|
|
98
|
+
weightToStyle
|
|
99
|
+
} from './fonts'
|
|
100
|
+
export {
|
|
101
|
+
parseColor,
|
|
102
|
+
normalizeColor,
|
|
103
|
+
colorToHex,
|
|
104
|
+
colorToHex8,
|
|
105
|
+
colorToHexRaw,
|
|
106
|
+
colorToRgba255,
|
|
107
|
+
colorToCSS,
|
|
108
|
+
colorToCSSCompact,
|
|
109
|
+
rgba255ToColor,
|
|
110
|
+
colorToFill,
|
|
111
|
+
colorDistance
|
|
112
|
+
} from './color'
|
|
113
|
+
export {
|
|
114
|
+
vectorNetworkToPath,
|
|
115
|
+
geometryBlobToPath,
|
|
116
|
+
decodeVectorNetworkBlob,
|
|
117
|
+
encodeVectorNetworkBlob,
|
|
118
|
+
computeVectorBounds
|
|
119
|
+
} from './vector'
|
|
120
|
+
export { computeSelectionBounds, computeSnap, type SnapGuide } from './snap'
|
|
121
|
+
export { UndoManager, type UndoEntry } from './undo'
|
|
122
|
+
export { TextEditor, type TextCaret, type TextEditorState } from './text-editor'
|
|
123
|
+
export {
|
|
124
|
+
getStyleAt,
|
|
125
|
+
applyStyleToRange,
|
|
126
|
+
removeStyleFromRange,
|
|
127
|
+
selectionHasStyle,
|
|
128
|
+
toggleBoldInRange,
|
|
129
|
+
toggleItalicInRange,
|
|
130
|
+
toggleDecorationInRange,
|
|
131
|
+
adjustRunsForInsert,
|
|
132
|
+
adjustRunsForDelete
|
|
133
|
+
} from './style-runs'
|
|
134
|
+
export { renderNodesToImage, renderThumbnail, computeContentBounds, type ExportFormat } from './render-image'
|
|
135
|
+
export {
|
|
136
|
+
renderNodesToSVG,
|
|
137
|
+
geometryBlobToSVGPath,
|
|
138
|
+
vectorNetworkToSVGPaths,
|
|
139
|
+
type SVGExportOptions
|
|
140
|
+
} from './svg-export'
|
|
141
|
+
export { svg, renderSVGNode, type SVGNode } from './svg-node'
|
|
142
|
+
export { exportFigFile, compressFigData, compressFigDataSync } from './fig-export'
|
|
143
|
+
export {
|
|
144
|
+
FIG_KIWI_VERSION,
|
|
145
|
+
buildFigKiwi,
|
|
146
|
+
parseFigKiwiChunks,
|
|
147
|
+
decompressFigKiwiData,
|
|
148
|
+
decompressFigKiwiDataAsync,
|
|
149
|
+
sceneNodeToKiwi,
|
|
150
|
+
fractionalPosition,
|
|
151
|
+
mapToFigmaType
|
|
152
|
+
} from './kiwi-serialize'
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
createElement,
|
|
156
|
+
renderTree,
|
|
157
|
+
renderJSX,
|
|
158
|
+
renderTreeNode,
|
|
159
|
+
buildComponent,
|
|
160
|
+
Frame,
|
|
161
|
+
Text,
|
|
162
|
+
Rectangle,
|
|
163
|
+
Ellipse,
|
|
164
|
+
Line,
|
|
165
|
+
Star,
|
|
166
|
+
Polygon,
|
|
167
|
+
Vector as VectorNode,
|
|
168
|
+
Group,
|
|
169
|
+
Section,
|
|
170
|
+
View,
|
|
171
|
+
Rect as RectNode,
|
|
172
|
+
Component as ComponentNode,
|
|
173
|
+
Instance as InstanceNode,
|
|
174
|
+
Page as PageNode,
|
|
175
|
+
INTRINSIC_ELEMENTS,
|
|
176
|
+
isTreeNode,
|
|
177
|
+
resolveToTree,
|
|
178
|
+
node,
|
|
179
|
+
type TreeNode,
|
|
180
|
+
type BaseProps,
|
|
181
|
+
type TextProps,
|
|
182
|
+
type StyleProps,
|
|
183
|
+
type RenderResult,
|
|
184
|
+
sceneNodeToJSX,
|
|
185
|
+
selectionToJSX,
|
|
186
|
+
type JSXFormat,
|
|
187
|
+
selectionToCode,
|
|
188
|
+
type CodeFormat
|
|
189
|
+
} from './render'
|
|
190
|
+
export {
|
|
191
|
+
parseFigmaClipboard,
|
|
192
|
+
importClipboardNodes,
|
|
193
|
+
figmaNodesBounds,
|
|
194
|
+
parseLutrisClipboard,
|
|
195
|
+
buildFigmaClipboardHTML,
|
|
196
|
+
buildLutrisClipboardHTML,
|
|
197
|
+
prefetchFigmaSchema,
|
|
198
|
+
type TextPictureBuilder,
|
|
199
|
+
type LutrisClipboardData
|
|
200
|
+
} from './clipboard'
|
|
201
|
+
|
|
202
|
+
export { readFigFile, parseFigFile } from './kiwi/fig-file'
|
|
203
|
+
export { importNodeChanges } from './kiwi/fig-import'
|
|
204
|
+
export {
|
|
205
|
+
initCodec,
|
|
206
|
+
encodeMessage,
|
|
207
|
+
decodeMessage,
|
|
208
|
+
compress,
|
|
209
|
+
decompress,
|
|
210
|
+
getCompiledSchema,
|
|
211
|
+
getSchemaBytes,
|
|
212
|
+
createNodeChangesMessage,
|
|
213
|
+
createNodeChange,
|
|
214
|
+
parseVariableId,
|
|
215
|
+
encodePaintWithVariableBinding,
|
|
216
|
+
encodeNodeChangeWithVariables,
|
|
217
|
+
type NodeChange,
|
|
218
|
+
type GUID as KiwiGUID,
|
|
219
|
+
type Color as KiwiColor,
|
|
220
|
+
type Paint as KiwiPaint,
|
|
221
|
+
type Effect as KiwiEffect,
|
|
222
|
+
type VariableBinding,
|
|
223
|
+
type ParentIndex,
|
|
224
|
+
type FigmaMessage
|
|
225
|
+
} from './kiwi/codec'
|
|
226
|
+
|
|
227
|
+
export {
|
|
228
|
+
MESSAGE_TYPES,
|
|
229
|
+
NODE_TYPES,
|
|
230
|
+
NODE_PHASES,
|
|
231
|
+
BLEND_MODES,
|
|
232
|
+
PAINT_TYPES,
|
|
233
|
+
PROTOCOL_VERSION,
|
|
234
|
+
KIWI,
|
|
235
|
+
SESSION_ID,
|
|
236
|
+
ZSTD_MAGIC,
|
|
237
|
+
buildMultiplayerUrl,
|
|
238
|
+
isZstdCompressed,
|
|
239
|
+
hasFigWireHeader,
|
|
240
|
+
skipFigWireHeader,
|
|
241
|
+
isKiwiMessage,
|
|
242
|
+
getKiwiMessageType,
|
|
243
|
+
parseVarint,
|
|
244
|
+
FIG_WIRE_MAGIC
|
|
245
|
+
} from './kiwi/protocol'
|
|
246
|
+
|
|
247
|
+
export { figmaFileToSceneGraph } from './figma-rest-import'
|