@moondraft/import 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +34 -0
- package/README.md +36 -2
- package/SOURCE.md +169 -0
- package/dist/adapter/convert.d.ts +122 -0
- package/dist/adapter/convert.js +2302 -0
- package/dist/adapter/figma.d.ts +9 -0
- package/dist/adapter/figma.js +30 -0
- package/dist/adapter/file-components.d.ts +14 -0
- package/dist/adapter/file-components.js +262 -0
- package/dist/adapter/file-resources.d.ts +29 -0
- package/dist/adapter/file-resources.js +562 -0
- package/dist/adapter/index.d.ts +6 -0
- package/dist/adapter/index.js +9 -0
- package/dist/adapter/link.d.ts +45 -0
- package/dist/adapter/link.js +688 -0
- package/dist/adapter/payload.d.ts +31 -0
- package/dist/adapter/payload.js +78 -0
- package/dist/adapter/shapes.d.ts +31 -0
- package/dist/adapter/shapes.js +75 -0
- package/dist/adapter/variables.d.ts +44 -0
- package/dist/adapter/variables.js +103 -0
- package/dist/figma-file.d.ts +38 -0
- package/dist/figma-file.js +97 -0
- package/dist/figma-worker.d.ts +11 -0
- package/dist/figma-worker.js +12 -0
- package/dist/figma.d.ts +26 -0
- package/dist/figma.js +96 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +49 -0
- package/dist/report.d.ts +15 -0
- package/dist/report.js +69 -0
- package/dist/svg.d.ts +33 -0
- package/dist/svg.js +44 -0
- package/dist/syntax.d.ts +8 -0
- package/dist/syntax.js +19 -0
- package/dist/taco/figma-import/clipboard.d.ts +25 -0
- package/dist/taco/figma-import/clipboard.js +87 -0
- package/dist/taco/figma-import/clipboardSize.d.ts +31 -0
- package/dist/taco/figma-import/clipboardSize.js +107 -0
- package/dist/taco/figma-import/container/compression.d.ts +9 -0
- package/dist/taco/figma-import/container/compression.js +174 -0
- package/dist/taco/figma-import/container/error.d.ts +15 -0
- package/dist/taco/figma-import/container/error.js +19 -0
- package/dist/taco/figma-import/container/kiwiContainer.d.ts +38 -0
- package/dist/taco/figma-import/container/kiwiContainer.js +61 -0
- package/dist/taco/figma-import/container/limits.d.ts +22 -0
- package/dist/taco/figma-import/container/limits.js +22 -0
- package/dist/taco/figma-import/container/zip.d.ts +14 -0
- package/dist/taco/figma-import/container/zip.js +154 -0
- package/dist/taco/figma-import/figFile.d.ts +34 -0
- package/dist/taco/figma-import/figFile.js +91 -0
- package/dist/taco/figma-import/figFileDocument.d.ts +25 -0
- package/dist/taco/figma-import/figFileDocument.js +100 -0
- package/dist/taco/figma-import/import/blobs.d.ts +10 -0
- package/dist/taco/figma-import/import/blobs.js +23 -0
- package/dist/taco/figma-import/import/carry.d.ts +11 -0
- package/dist/taco/figma-import/import/carry.js +33 -0
- package/dist/taco/figma-import/import/componentProps.d.ts +84 -0
- package/dist/taco/figma-import/import/componentProps.js +313 -0
- package/dist/taco/figma-import/import/componentSets.d.ts +83 -0
- package/dist/taco/figma-import/import/componentSets.js +647 -0
- package/dist/taco/figma-import/import/converters/effects.d.ts +31 -0
- package/dist/taco/figma-import/import/converters/effects.js +127 -0
- package/dist/taco/figma-import/import/converters/ellipse.d.ts +7 -0
- package/dist/taco/figma-import/import/converters/ellipse.js +54 -0
- package/dist/taco/figma-import/import/converters/frame.d.ts +21 -0
- package/dist/taco/figma-import/import/converters/frame.js +55 -0
- package/dist/taco/figma-import/import/converters/gradient.d.ts +72 -0
- package/dist/taco/figma-import/import/converters/gradient.js +106 -0
- package/dist/taco/figma-import/import/converters/group.d.ts +21 -0
- package/dist/taco/figma-import/import/converters/group.js +39 -0
- package/dist/taco/figma-import/import/converters/image.d.ts +13 -0
- package/dist/taco/figma-import/import/converters/image.js +83 -0
- package/dist/taco/figma-import/import/converters/layout.d.ts +34 -0
- package/dist/taco/figma-import/import/converters/layout.js +168 -0
- package/dist/taco/figma-import/import/converters/line.d.ts +11 -0
- package/dist/taco/figma-import/import/converters/line.js +40 -0
- package/dist/taco/figma-import/import/converters/rectangle.d.ts +3 -0
- package/dist/taco/figma-import/import/converters/rectangle.js +11 -0
- package/dist/taco/figma-import/import/converters/section.d.ts +9 -0
- package/dist/taco/figma-import/import/converters/section.js +35 -0
- package/dist/taco/figma-import/import/converters/shared.d.ts +68 -0
- package/dist/taco/figma-import/import/converters/shared.js +362 -0
- package/dist/taco/figma-import/import/converters/text.d.ts +41 -0
- package/dist/taco/figma-import/import/converters/text.js +576 -0
- package/dist/taco/figma-import/import/converters/vector.d.ts +84 -0
- package/dist/taco/figma-import/import/converters/vector.js +468 -0
- package/dist/taco/figma-import/import/converters/vectorNetwork.d.ts +98 -0
- package/dist/taco/figma-import/import/converters/vectorNetwork.js +385 -0
- package/dist/taco/figma-import/import/fields.d.ts +15 -0
- package/dist/taco/figma-import/import/fields.js +29 -0
- package/dist/taco/figma-import/import/instances.d.ts +163 -0
- package/dist/taco/figma-import/import/instances.js +1323 -0
- package/dist/taco/figma-import/import/nestingCycles.d.ts +86 -0
- package/dist/taco/figma-import/import/nestingCycles.js +488 -0
- package/dist/taco/figma-import/import/slots.d.ts +56 -0
- package/dist/taco/figma-import/import/slots.js +96 -0
- package/dist/taco/figma-import/import/styles.d.ts +46 -0
- package/dist/taco/figma-import/import/styles.js +42 -0
- package/dist/taco/figma-import/import/tree.d.ts +66 -0
- package/dist/taco/figma-import/import/tree.js +194 -0
- package/dist/taco/figma-import/import/types.d.ts +232 -0
- package/dist/taco/figma-import/import/types.js +33 -0
- package/dist/taco/figma-import/import/variables.d.ts +136 -0
- package/dist/taco/figma-import/import/variables.js +762 -0
- package/dist/taco/figma-import/import/variantTrees.d.ts +20 -0
- package/dist/taco/figma-import/import/variantTrees.js +480 -0
- package/dist/taco/figma-import/import/walk.d.ts +159 -0
- package/dist/taco/figma-import/import/walk.js +1297 -0
- package/dist/taco/figma-import/index.d.ts +22 -0
- package/dist/taco/figma-import/index.js +13 -0
- package/dist/taco/figma-import/kiwi/byteReader.d.ts +37 -0
- package/dist/taco/figma-import/kiwi/byteReader.js +151 -0
- package/dist/taco/figma-import/kiwi/error.d.ts +14 -0
- package/dist/taco/figma-import/kiwi/error.js +29 -0
- package/dist/taco/figma-import/kiwi/limits.d.ts +18 -0
- package/dist/taco/figma-import/kiwi/limits.js +18 -0
- package/dist/taco/figma-import/kiwi/message.d.ts +10 -0
- package/dist/taco/figma-import/kiwi/message.js +145 -0
- package/dist/taco/figma-import/kiwi/schema.d.ts +42 -0
- package/dist/taco/figma-import/kiwi/schema.js +206 -0
- package/dist/taco/figma-import/kiwi/types.d.ts +46 -0
- package/dist/taco/figma-import/kiwi/types.js +18 -0
- package/dist/taco/model/agent-hidden-fields.d.ts +20 -0
- package/dist/taco/model/agent-hidden-fields.js +29 -0
- package/dist/taco/model/asset-users.d.ts +23 -0
- package/dist/taco/model/asset-users.js +128 -0
- package/dist/taco/model/auto-layout-lines.d.ts +32 -0
- package/dist/taco/model/auto-layout-lines.js +70 -0
- package/dist/taco/model/codec.d.ts +444 -0
- package/dist/taco/model/codec.js +5635 -0
- package/dist/taco/model/color.d.ts +11 -0
- package/dist/taco/model/color.js +61 -0
- package/dist/taco/model/comment-operations.d.ts +102 -0
- package/dist/taco/model/comment-operations.js +227 -0
- package/dist/taco/model/component-evaluation.d.ts +94 -0
- package/dist/taco/model/component-evaluation.js +548 -0
- package/dist/taco/model/component-expressions.d.ts +242 -0
- package/dist/taco/model/component-expressions.js +1082 -0
- package/dist/taco/model/component-properties.d.ts +111 -0
- package/dist/taco/model/component-properties.js +339 -0
- package/dist/taco/model/component-samples.d.ts +83 -0
- package/dist/taco/model/component-samples.js +290 -0
- package/dist/taco/model/component-validity.d.ts +85 -0
- package/dist/taco/model/component-validity.js +397 -0
- package/dist/taco/model/components.d.ts +155 -0
- package/dist/taco/model/components.js +505 -0
- package/dist/taco/model/connector-ends.d.ts +20 -0
- package/dist/taco/model/connector-ends.js +188 -0
- package/dist/taco/model/connector-geometry.d.ts +74 -0
- package/dist/taco/model/connector-geometry.js +293 -0
- package/dist/taco/model/corner-radii.d.ts +26 -0
- package/dist/taco/model/corner-radii.js +47 -0
- package/dist/taco/model/derivations.d.ts +81 -0
- package/dist/taco/model/derivations.js +151 -0
- package/dist/taco/model/export-settings.d.ts +53 -0
- package/dist/taco/model/export-settings.js +156 -0
- package/dist/taco/model/expressions/ast.d.ts +153 -0
- package/dist/taco/model/expressions/ast.js +6 -0
- package/dist/taco/model/expressions/cache.d.ts +23 -0
- package/dist/taco/model/expressions/cache.js +43 -0
- package/dist/taco/model/expressions/check.d.ts +72 -0
- package/dist/taco/model/expressions/check.js +517 -0
- package/dist/taco/model/expressions/completion.d.ts +61 -0
- package/dist/taco/model/expressions/completion.js +421 -0
- package/dist/taco/model/expressions/evaluate.d.ts +32 -0
- package/dist/taco/model/expressions/evaluate.js +519 -0
- package/dist/taco/model/expressions/forms.d.ts +84 -0
- package/dist/taco/model/expressions/forms.js +200 -0
- package/dist/taco/model/expressions/index.d.ts +14 -0
- package/dist/taco/model/expressions/index.js +17 -0
- package/dist/taco/model/expressions/lexer.d.ts +42 -0
- package/dist/taco/model/expressions/lexer.js +213 -0
- package/dist/taco/model/expressions/library.d.ts +33 -0
- package/dist/taco/model/expressions/library.js +117 -0
- package/dist/taco/model/expressions/names.d.ts +43 -0
- package/dist/taco/model/expressions/names.js +99 -0
- package/dist/taco/model/expressions/parser.d.ts +15 -0
- package/dist/taco/model/expressions/parser.js +438 -0
- package/dist/taco/model/expressions/rename.d.ts +34 -0
- package/dist/taco/model/expressions/rename.js +46 -0
- package/dist/taco/model/expressions/source.d.ts +15 -0
- package/dist/taco/model/expressions/source.js +161 -0
- package/dist/taco/model/expressions/types.d.ts +119 -0
- package/dist/taco/model/expressions/types.js +102 -0
- package/dist/taco/model/expressions/values.d.ts +97 -0
- package/dist/taco/model/expressions/values.js +160 -0
- package/dist/taco/model/geometry-limits.d.ts +16 -0
- package/dist/taco/model/geometry-limits.js +67 -0
- package/dist/taco/model/geometry.d.ts +47 -0
- package/dist/taco/model/geometry.js +193 -0
- package/dist/taco/model/group-bounds.d.ts +38 -0
- package/dist/taco/model/group-bounds.js +144 -0
- package/dist/taco/model/id-table.d.ts +37 -0
- package/dist/taco/model/id-table.js +80 -0
- package/dist/taco/model/index.d.ts +25 -0
- package/dist/taco/model/index.js +27 -0
- package/dist/taco/model/instance-resolver.d.ts +372 -0
- package/dist/taco/model/instance-resolver.js +1748 -0
- package/dist/taco/model/layer-syntax.d.ts +340 -0
- package/dist/taco/model/layer-syntax.js +3506 -0
- package/dist/taco/model/layout/constraints.d.ts +84 -0
- package/dist/taco/model/layout/constraints.js +445 -0
- package/dist/taco/model/layout/frame-layout.d.ts +46 -0
- package/dist/taco/model/layout/frame-layout.js +618 -0
- package/dist/taco/model/layout/node-sizing.d.ts +163 -0
- package/dist/taco/model/layout/node-sizing.js +486 -0
- package/dist/taco/model/legacy-connector-caps.d.ts +15 -0
- package/dist/taco/model/legacy-connector-caps.js +70 -0
- package/dist/taco/model/linear-call.d.ts +48 -0
- package/dist/taco/model/linear-call.js +58 -0
- package/dist/taco/model/new-nodes.d.ts +145 -0
- package/dist/taco/model/new-nodes.js +277 -0
- package/dist/taco/model/node-builder.d.ts +449 -0
- package/dist/taco/model/node-builder.js +2294 -0
- package/dist/taco/model/node-table-watch.d.ts +36 -0
- package/dist/taco/model/node-table-watch.js +63 -0
- package/dist/taco/model/node-transform.d.ts +39 -0
- package/dist/taco/model/node-transform.js +79 -0
- package/dist/taco/model/node-users-index.d.ts +10 -0
- package/dist/taco/model/node-users-index.js +82 -0
- package/dist/taco/model/operation-references.d.ts +80 -0
- package/dist/taco/model/operation-references.js +399 -0
- package/dist/taco/model/operations.d.ts +610 -0
- package/dist/taco/model/operations.js +2882 -0
- package/dist/taco/model/overlay-table.d.ts +71 -0
- package/dist/taco/model/overlay-table.js +171 -0
- package/dist/taco/model/override-remap.d.ts +69 -0
- package/dist/taco/model/override-remap.js +230 -0
- package/dist/taco/model/parent-table.d.ts +53 -0
- package/dist/taco/model/parent-table.js +193 -0
- package/dist/taco/model/problem-collector.d.ts +27 -0
- package/dist/taco/model/problem-collector.js +101 -0
- package/dist/taco/model/sha256.d.ts +10 -0
- package/dist/taco/model/sha256.js +74 -0
- package/dist/taco/model/shape-geometry.d.ts +96 -0
- package/dist/taco/model/shape-geometry.js +368 -0
- package/dist/taco/model/shared-node-table.d.ts +97 -0
- package/dist/taco/model/shared-node-table.js +546 -0
- package/dist/taco/model/slots.d.ts +113 -0
- package/dist/taco/model/slots.js +281 -0
- package/dist/taco/model/stroke-settings.d.ts +37 -0
- package/dist/taco/model/stroke-settings.js +90 -0
- package/dist/taco/model/svg-path-import.d.ts +89 -0
- package/dist/taco/model/svg-path-import.js +219 -0
- package/dist/taco/model/text-measurement.d.ts +142 -0
- package/dist/taco/model/text-measurement.js +846 -0
- package/dist/taco/model/text-reads.d.ts +66 -0
- package/dist/taco/model/text-reads.js +128 -0
- package/dist/taco/model/text-sizer.d.ts +358 -0
- package/dist/taco/model/text-sizer.js +996 -0
- package/dist/taco/model/theme-users.d.ts +59 -0
- package/dist/taco/model/theme-users.js +312 -0
- package/dist/taco/model/thumbnail.d.ts +15 -0
- package/dist/taco/model/thumbnail.js +34 -0
- package/dist/taco/model/types.d.ts +2347 -0
- package/dist/taco/model/types.js +366 -0
- package/dist/taco/model/unknown-property.d.ts +5 -0
- package/dist/taco/model/unknown-property.js +7 -0
- package/dist/taco/model/validated-documents.d.ts +22 -0
- package/dist/taco/model/validated-documents.js +22 -0
- package/dist/taco/model/variable-modes.d.ts +61 -0
- package/dist/taco/model/variable-modes.js +438 -0
- package/dist/taco/model/variable-references.d.ts +54 -0
- package/dist/taco/model/variable-references.js +183 -0
- package/dist/taco/model/variables.d.ts +24 -0
- package/dist/taco/model/variables.js +151 -0
- package/dist/taco/model/vector-network.d.ts +34 -0
- package/dist/taco/model/vector-network.js +411 -0
- package/dist/taco/svg-import/import-svg.d.ts +36 -0
- package/dist/taco/svg-import/import-svg.js +729 -0
- package/dist/taco/svg-import/index.d.ts +3 -0
- package/dist/taco/svg-import/index.js +3 -0
- package/dist/taco/svg-import/limits/limits.d.ts +79 -0
- package/dist/taco/svg-import/limits/limits.js +160 -0
- package/dist/taco/svg-import/paint/gradients.d.ts +64 -0
- package/dist/taco/svg-import/paint/gradients.js +429 -0
- package/dist/taco/svg-import/paint/paint.d.ts +32 -0
- package/dist/taco/svg-import/paint/paint.js +162 -0
- package/dist/taco/svg-import/paths/paths.d.ts +58 -0
- package/dist/taco/svg-import/paths/paths.js +205 -0
- package/dist/taco/svg-import/public-types.d.ts +279 -0
- package/dist/taco/svg-import/public-types.js +56 -0
- package/dist/taco/svg-import/report/report.d.ts +44 -0
- package/dist/taco/svg-import/report/report.js +79 -0
- package/dist/taco/svg-import/reuse/reuse.d.ts +99 -0
- package/dist/taco/svg-import/reuse/reuse.js +840 -0
- package/dist/taco/svg-import/shapes/shapes.d.ts +35 -0
- package/dist/taco/svg-import/shapes/shapes.js +386 -0
- package/dist/taco/svg-import/structure/effects.d.ts +26 -0
- package/dist/taco/svg-import/structure/effects.js +618 -0
- package/dist/taco/svg-import/structure/image.d.ts +24 -0
- package/dist/taco/svg-import/structure/image.js +495 -0
- package/dist/taco/svg-import/structure/walk.d.ts +85 -0
- package/dist/taco/svg-import/structure/walk.js +544 -0
- package/dist/taco/svg-import/style/color.d.ts +40 -0
- package/dist/taco/svg-import/style/color.js +275 -0
- package/dist/taco/svg-import/style/computed.d.ts +214 -0
- package/dist/taco/svg-import/style/computed.js +1534 -0
- package/dist/taco/svg-import/style/css.d.ts +127 -0
- package/dist/taco/svg-import/style/css.js +541 -0
- package/dist/taco/svg-import/style/media.d.ts +25 -0
- package/dist/taco/svg-import/style/media.js +307 -0
- package/dist/taco/svg-import/style/properties.d.ts +43 -0
- package/dist/taco/svg-import/style/properties.js +135 -0
- package/dist/taco/svg-import/style/selector-reach.d.ts +30 -0
- package/dist/taco/svg-import/style/selector-reach.js +169 -0
- package/dist/taco/svg-import/style/selector-validity.d.ts +14 -0
- package/dist/taco/svg-import/style/selector-validity.js +307 -0
- package/dist/taco/svg-import/text/text.d.ts +29 -0
- package/dist/taco/svg-import/text/text.js +545 -0
- package/dist/taco/svg-import/transform/matrix.d.ts +111 -0
- package/dist/taco/svg-import/transform/matrix.js +229 -0
- package/dist/taco/svg-import/tree/element-data.d.ts +52 -0
- package/dist/taco/svg-import/tree/element-data.js +155 -0
- package/dist/taco/svg-import/tree/elements.d.ts +36 -0
- package/dist/taco/svg-import/tree/elements.js +121 -0
- package/dist/taco/svg-import/units/length.d.ts +43 -0
- package/dist/taco/svg-import/units/length.js +125 -0
- package/dist/taco/svg-import/units/viewbox.d.ts +35 -0
- package/dist/taco/svg-import/units/viewbox.js +77 -0
- package/package.json +54 -4
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import type { AssetId, ComponentDefinition, ComponentId, NodeId, SceneNode, TextStyle, VariableCollection, VariableModes } from "../../model/index.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The limits of one import: `nodes` is the most entries in the message's
|
|
4
|
+
* `nodeChanges` list, and also the most Taco layers the import builds: a
|
|
5
|
+
* component's layers count once, and an instance counts as one layer,
|
|
6
|
+
* since it does not copy its component's layers (a node that is left out
|
|
7
|
+
* is not counted); `depth` the deepest nesting, an imported root being
|
|
8
|
+
* level 1; `vectorCommands` the most drawing commands
|
|
9
|
+
* read from all VECTOR geometry together, so that many layers sharing one
|
|
10
|
+
* large blob cannot add up past it (a VECTOR that would go over is left out
|
|
11
|
+
* and reported). The defaults depend on where the roots come from; see
|
|
12
|
+
* `DEFAULT_FIGMA_IMPORT_LIMITS`.
|
|
13
|
+
*/
|
|
14
|
+
export interface FigmaImportLimits {
|
|
15
|
+
readonly nodes: number;
|
|
16
|
+
readonly depth: number;
|
|
17
|
+
readonly vectorCommands: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The default limits for each root source, a guard against an import that
|
|
21
|
+
* would use up the host's memory. A whole .fig file (`"pages"`) may build
|
|
22
|
+
* 500,000 layers: a design system file such as HeroUI v3 (29,179 node
|
|
23
|
+
* changes; 26,451 layers built, its 2,997 components' layers once and each
|
|
24
|
+
* instance as one) keeps about 1.8 KB of heap per built layer (measured 20
|
|
25
|
+
* Oct 2026; 3 KB when instances copied their components' layers), so
|
|
26
|
+
* 500,000 layers come to about 1 to 1.5 GB. A paste
|
|
27
|
+
* (`"clipboard-selection"`) keeps its limit of 100,000. Both: 64 levels,
|
|
28
|
+
* 1,000,000 vector commands.
|
|
29
|
+
* `FigmaImportOptions.limits` overrides any of them.
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_FIGMA_IMPORT_LIMITS: Readonly<Record<FigmaRootSource, FigmaImportLimits>>;
|
|
32
|
+
/**
|
|
33
|
+
* Where the roots come from. `"clipboard-selection"`: the nodes named by
|
|
34
|
+
* `clipboardSelectionRegions`, in the message's order (what a person copied).
|
|
35
|
+
* `"pages"`: the children of every `CANVAS` under the `DOCUMENT` node 0:0,
|
|
36
|
+
* leaving out pages marked `internalOnly` (a .fig file).
|
|
37
|
+
*/
|
|
38
|
+
export type FigmaRootSource = "clipboard-selection" | "pages";
|
|
39
|
+
export interface FigmaImportOptions {
|
|
40
|
+
/** Returns a fresh id for every created node, so the host controls ids. */
|
|
41
|
+
readonly idSource: () => string;
|
|
42
|
+
/** When omitted: `"clipboard-selection"` if the message has a non-empty `clipboardSelectionRegions`, else `"pages"`. */
|
|
43
|
+
readonly roots?: FigmaRootSource;
|
|
44
|
+
readonly limits?: Partial<FigmaImportLimits>;
|
|
45
|
+
/**
|
|
46
|
+
* The bytes of the image whose SHA-1 hash is `hashHex` (40 lowercase hex
|
|
47
|
+
* digits, as Figma names a .fig file's `images/<hash>` entry), or
|
|
48
|
+
* `undefined` when the host has none. The importer never fetches: an image
|
|
49
|
+
* paint whose bytes are not supplied is left out and reported once. A
|
|
50
|
+
* missing `mimeType` is read from the bytes (PNG, JPEG, GIF or WebP); a
|
|
51
|
+
* missing `width` and `height` come from the paint's original image size.
|
|
52
|
+
*/
|
|
53
|
+
readonly images?: (hashHex: string) => FigmaSuppliedImage | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the `key` of each imported component, unique in the document
|
|
56
|
+
* it goes into, given the Figma node the component comes from (a SYMBOL,
|
|
57
|
+
* or the COMPONENT_SET a set's component is made from). When omitted, a
|
|
58
|
+
* file's (`"pages"`) keys are the same on every import of the same file:
|
|
59
|
+
* the node's Figma `componentKey` where it has one that no other component
|
|
60
|
+
* of the import took, else `figma-<guid>`. A paste's keys are random UUIDs,
|
|
61
|
+
* since the same component may be pasted twice into one document.
|
|
62
|
+
*/
|
|
63
|
+
readonly componentKeySource?: (source: FigmaComponentSource) => string;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the message's variables are imported as `variableCollections` and the layers bound to them (the
|
|
66
|
+
* default). `false` is for a host that cannot add variables to the document, such as the clipboard paste: no
|
|
67
|
+
* variable is imported, and every binding keeps its value and is reported.
|
|
68
|
+
*/
|
|
69
|
+
readonly bindVariables?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether each Figma text style a text layer names (`styleIdForText`) is imported as a shared text style in
|
|
72
|
+
* `textStyles` and the layer's runs linked to it (the default). `false` is for a host that cannot add text styles to
|
|
73
|
+
* the document, such as the clipboard paste: the runs keep the style's values as direct formatting, reported once
|
|
74
|
+
* for each style.
|
|
75
|
+
*/
|
|
76
|
+
readonly textStyles?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/** The Figma node an imported component comes from, for `FigmaImportOptions.componentKeySource`. */
|
|
79
|
+
export interface FigmaComponentSource {
|
|
80
|
+
/** The SYMBOL's or COMPONENT_SET's guid as `sessionID:localID`. */
|
|
81
|
+
readonly figmaId: string;
|
|
82
|
+
/** Its Figma `componentKey`, when it has one (a published component or set). */
|
|
83
|
+
readonly componentKey?: string;
|
|
84
|
+
}
|
|
85
|
+
/** The bytes of one image, as the host supplies them. */
|
|
86
|
+
export interface FigmaSuppliedImage {
|
|
87
|
+
readonly bytes: Uint8Array;
|
|
88
|
+
readonly mimeType?: string;
|
|
89
|
+
readonly width?: number;
|
|
90
|
+
readonly height?: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* One image the imported paints use. Its `id` is `figma-image-<hash>`, so the
|
|
94
|
+
* same image is one asset across nodes and imports. The host stores it as a
|
|
95
|
+
* Taco `ImageAsset`, such as with `source: { kind: "data", data: <bytes as base64> }`.
|
|
96
|
+
*/
|
|
97
|
+
export interface FigmaImportedImage {
|
|
98
|
+
readonly id: AssetId;
|
|
99
|
+
/** The image's SHA-1 hash as 40 lowercase hex digits. */
|
|
100
|
+
readonly hash: string;
|
|
101
|
+
readonly mimeType: string;
|
|
102
|
+
readonly bytes: Uint8Array;
|
|
103
|
+
readonly width?: number;
|
|
104
|
+
readonly height?: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* `"node-left-out"`: the node and every layer inside it are not imported.
|
|
108
|
+
* `"property-left-out"`: the node is imported without one property.
|
|
109
|
+
* `"approximated"`: a property is imported, but not exactly.
|
|
110
|
+
*/
|
|
111
|
+
export type FigmaImportReportKind = "node-left-out" | "property-left-out" | "approximated";
|
|
112
|
+
export interface FigmaImportReportEntry {
|
|
113
|
+
/** The Figma guid as `sessionID:localID`, such as `12:34`. */
|
|
114
|
+
readonly nodeId: string;
|
|
115
|
+
/** The Figma node type, such as `VECTOR`; empty when the message has no such node. */
|
|
116
|
+
readonly nodeType: string;
|
|
117
|
+
/** Where the node sits, such as `CANVAS "Page 1" > FRAME "Card" > TEXT "Title"`. */
|
|
118
|
+
readonly nodePath: string;
|
|
119
|
+
/** The kind of layer: `nodeType`, except `GROUP` for a FRAME that Figma uses as a group. */
|
|
120
|
+
readonly layerType: string;
|
|
121
|
+
readonly kind: FigmaImportReportKind;
|
|
122
|
+
/** What was left out or changed, in plain words. */
|
|
123
|
+
readonly reason: string;
|
|
124
|
+
/**
|
|
125
|
+
* The layers inside the node that this entry leaves out with it, counted
|
|
126
|
+
* by `layerType` in the order first met; empty when it leaves none out.
|
|
127
|
+
* One import names at most 32 layer types; layers of any type met after
|
|
128
|
+
* those count under `OTHER` (only a crafted message has that many types).
|
|
129
|
+
*/
|
|
130
|
+
readonly layersInside: readonly FigmaLayerCount[];
|
|
131
|
+
}
|
|
132
|
+
/** How many layers of one `layerType`. */
|
|
133
|
+
export interface FigmaLayerCount {
|
|
134
|
+
readonly layerType: string;
|
|
135
|
+
readonly count: number;
|
|
136
|
+
}
|
|
137
|
+
/** One imported page of a .fig file, with its top-level nodes back to front. */
|
|
138
|
+
export interface FigmaImportedPage {
|
|
139
|
+
readonly figmaId: string;
|
|
140
|
+
readonly name: string;
|
|
141
|
+
readonly roots: readonly NodeId[];
|
|
142
|
+
/** The variable mode the page chooses for each collection, by collection id; omitted when it chooses none. */
|
|
143
|
+
readonly variableModes?: VariableModes;
|
|
144
|
+
}
|
|
145
|
+
export interface FigmaImportResult {
|
|
146
|
+
/** How the reader selected the imported roots. */
|
|
147
|
+
readonly rootSource: FigmaRootSource;
|
|
148
|
+
/** The imported top-level nodes: every page's roots in page order, or the copied nodes. */
|
|
149
|
+
readonly roots: readonly SceneNode[];
|
|
150
|
+
/** Every created node, `roots` and component layers included, parents before their children. */
|
|
151
|
+
readonly nodes: readonly SceneNode[];
|
|
152
|
+
/** The imported pages; empty when the roots came from a clipboard selection. */
|
|
153
|
+
readonly pages: readonly FigmaImportedPage[];
|
|
154
|
+
/** Everything not imported exactly, in the order the walk met it. */
|
|
155
|
+
readonly report: readonly FigmaImportReportEntry[];
|
|
156
|
+
/** The images the imported paints use, keyed by asset id, each once. */
|
|
157
|
+
readonly assets: Readonly<Record<AssetId, FigmaImportedImage>>;
|
|
158
|
+
/**
|
|
159
|
+
* The layer each Figma node the walk met went to, keyed by the Figma guid
|
|
160
|
+
* as a report entry's `nodeId` gives it: the layer made from the node, or,
|
|
161
|
+
* for a node left out, the layer made from its nearest kept parent (none
|
|
162
|
+
* for a left-out root). A SYMBOL goes to its component's root, not to the
|
|
163
|
+
* instance that shows it where it sits. A slot's content frame goes to no
|
|
164
|
+
* layer. The layers inside it are copied for each instance that puts it
|
|
165
|
+
* in a slot, and each goes to the copy made for the first such instance
|
|
166
|
+
* in walk order; the others are reached through their instances' `slots`.
|
|
167
|
+
*/
|
|
168
|
+
readonly layerIds: Readonly<Record<string, NodeId>>;
|
|
169
|
+
/**
|
|
170
|
+
* The components made from SYMBOLs: for a .fig file (`"pages"`) every
|
|
171
|
+
* SYMBOL on its pages, and each one on an internal-only page that an
|
|
172
|
+
* imported instance, swap or property names; for a clipboard selection
|
|
173
|
+
* each SYMBOL under the roots and each one an imported instance, swap or
|
|
174
|
+
* property names, wherever it sits in the message. A variant brings the
|
|
175
|
+
* other variants of its set. Each root is in `nodes` with no parent, at 0, 0; a SYMBOL
|
|
176
|
+
* under the roots shows there as an instance of its component.
|
|
177
|
+
*
|
|
178
|
+
* A COMPONENT_SET's imported variants are one component, named after the
|
|
179
|
+
* set (design 8.1): matching layers share one tree, differing fields use
|
|
180
|
+
* expressions, and missing or reordered children have presence conditions.
|
|
181
|
+
* A field the model cannot compute keeps the whole set as stacked variants
|
|
182
|
+
* and is named in the report. Each VARIANT property is an enum with the id
|
|
183
|
+
* `figma-<def guid>`, listed first in Figma's order, whose options are the
|
|
184
|
+
* values the imported variants use, in the set's value order, with the ids
|
|
185
|
+
* `figma-<def guid>=<value>`; its default is the top-left variant's value,
|
|
186
|
+
* Figma's default variant. The variants' other properties follow, each
|
|
187
|
+
* once. A set that does not have every combination gets a `validity`
|
|
188
|
+
* expression true for exactly the combinations it has. Instances, swaps,
|
|
189
|
+
* instance swap values and preferred components that named a variant name
|
|
190
|
+
* the set's component with the variant's values; an instance Figma shows
|
|
191
|
+
* at another size than its variant's (resized, or filling its parent)
|
|
192
|
+
* keeps that size. Overrides and `layerIds` address the merged layers.
|
|
193
|
+
* Duplicate tuples keep their unused layers hidden; instances show the
|
|
194
|
+
* first variant with those values. A set whose variants would contain
|
|
195
|
+
* the set itself stays one component per variant and is reported.
|
|
196
|
+
*
|
|
197
|
+
* A component's name leaves out the parts of Figma's name, between ` / `,
|
|
198
|
+
* that are only `property=value` pairs, as `Avatar / variant=img, type=success`
|
|
199
|
+
* becomes `Avatar`; a name that is nothing else takes its set's name.
|
|
200
|
+
*/
|
|
201
|
+
readonly components: readonly ComponentDefinition[];
|
|
202
|
+
/** The component made from each SYMBOL, and from each merged COMPONENT_SET, keyed by its Figma guid. */
|
|
203
|
+
readonly componentIds: Readonly<Record<string, ComponentId>>;
|
|
204
|
+
/** Ordinary SYMBOL placements on public pages, keyed by the node ID of their intermediate instance. */
|
|
205
|
+
readonly componentPlacements: Readonly<Record<NodeId, ComponentId>>;
|
|
206
|
+
/**
|
|
207
|
+
* The message's variable collections, by id, for the host to add to the document's theme
|
|
208
|
+
* (`DocumentTheme.variableCollections`): the layers' `variableBindings` and `variableModes` name them. Empty
|
|
209
|
+
* when the message has none, or with `bindVariables: false`.
|
|
210
|
+
*/
|
|
211
|
+
readonly variableCollections: Readonly<Record<string, VariableCollection>>;
|
|
212
|
+
/**
|
|
213
|
+
* The Figma text styles the text layers name, by id, for the host to add to the document's theme
|
|
214
|
+
* (`DocumentTheme.textStyles`): the runs' `styleId` names them. They name no font asset. Empty when no layer names
|
|
215
|
+
* one, or with `textStyles: false`.
|
|
216
|
+
*/
|
|
217
|
+
readonly textStyles: Readonly<Record<string, TextStyle>>;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Why a message is refused: `not-node-changes` (not a `NODE_CHANGES` message,
|
|
221
|
+
* or a malformed node change), `duplicate-guid`, `cycle` (a node is its own
|
|
222
|
+
* ancestor), `no-roots` (no `DOCUMENT` 0:0, or no clipboard selection when
|
|
223
|
+
* one was asked for), `too-many-nodes` (over `limits.nodes`) and `too-deep`
|
|
224
|
+
* (over `limits.depth`).
|
|
225
|
+
*/
|
|
226
|
+
export declare const FIGMA_IMPORT_ERROR_CODES: readonly ["not-node-changes", "duplicate-guid", "cycle", "no-roots", "too-many-nodes", "too-deep"];
|
|
227
|
+
export type FigmaImportErrorCode = (typeof FIGMA_IMPORT_ERROR_CODES)[number];
|
|
228
|
+
/** Thrown when a message is refused. Nothing is returned, so nothing is half imported. */
|
|
229
|
+
export declare class FigmaImportError extends Error {
|
|
230
|
+
readonly code: FigmaImportErrorCode;
|
|
231
|
+
constructor(code: FigmaImportErrorCode, message: string);
|
|
232
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default limits for each root source, a guard against an import that
|
|
3
|
+
* would use up the host's memory. A whole .fig file (`"pages"`) may build
|
|
4
|
+
* 500,000 layers: a design system file such as HeroUI v3 (29,179 node
|
|
5
|
+
* changes; 26,451 layers built, its 2,997 components' layers once and each
|
|
6
|
+
* instance as one) keeps about 1.8 KB of heap per built layer (measured 20
|
|
7
|
+
* Oct 2026; 3 KB when instances copied their components' layers), so
|
|
8
|
+
* 500,000 layers come to about 1 to 1.5 GB. A paste
|
|
9
|
+
* (`"clipboard-selection"`) keeps its limit of 100,000. Both: 64 levels,
|
|
10
|
+
* 1,000,000 vector commands.
|
|
11
|
+
* `FigmaImportOptions.limits` overrides any of them.
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_FIGMA_IMPORT_LIMITS = {
|
|
14
|
+
"clipboard-selection": { nodes: 100_000, depth: 64, vectorCommands: 1_000_000 },
|
|
15
|
+
pages: { nodes: 500_000, depth: 64, vectorCommands: 1_000_000 },
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Why a message is refused: `not-node-changes` (not a `NODE_CHANGES` message,
|
|
19
|
+
* or a malformed node change), `duplicate-guid`, `cycle` (a node is its own
|
|
20
|
+
* ancestor), `no-roots` (no `DOCUMENT` 0:0, or no clipboard selection when
|
|
21
|
+
* one was asked for), `too-many-nodes` (over `limits.nodes`) and `too-deep`
|
|
22
|
+
* (over `limits.depth`).
|
|
23
|
+
*/
|
|
24
|
+
export const FIGMA_IMPORT_ERROR_CODES = ["not-node-changes", "duplicate-guid", "cycle", "no-roots", "too-many-nodes", "too-deep"];
|
|
25
|
+
/** Thrown when a message is refused. Nothing is returned, so nothing is half imported. */
|
|
26
|
+
export class FigmaImportError extends Error {
|
|
27
|
+
code;
|
|
28
|
+
constructor(code, message) {
|
|
29
|
+
super(`Figma import (${code}): ${message}`);
|
|
30
|
+
this.name = "FigmaImportError";
|
|
31
|
+
this.code = code;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { type SceneNode, type TextNode, type VariableCollection, type VariableId, type VariableModeId, type VariableType, type VariableValue } from "../../model/index.ts";
|
|
2
|
+
import { type FigmaObject } from "./fields.ts";
|
|
3
|
+
import type { FigmaTreeNode } from "./tree.ts";
|
|
4
|
+
import { type FigmaStyleList } from "./styles.ts";
|
|
5
|
+
import type { FigmaImportReportKind } from "./types.ts";
|
|
6
|
+
type Report = (node: FigmaTreeNode, kind: FigmaImportReportKind, reason: string) => void;
|
|
7
|
+
/** A Figma variable as imported, or why it is not, under the Figma guid and the library key that name it. */
|
|
8
|
+
type Known = {
|
|
9
|
+
readonly id: VariableId;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly type: VariableType;
|
|
12
|
+
readonly opacity?: true;
|
|
13
|
+
} | {
|
|
14
|
+
readonly missing: string;
|
|
15
|
+
};
|
|
16
|
+
/** The variables of one import, and the collections they went to. */
|
|
17
|
+
export interface FigmaVariables {
|
|
18
|
+
readonly collections: Readonly<Record<string, VariableCollection>>;
|
|
19
|
+
/** Source of each retained collection and variable, keyed by its local ID. */
|
|
20
|
+
readonly sources: ReadonlyMap<string, FigmaTreeNode>;
|
|
21
|
+
/** Direct aliases by variable and local mode, including a missing mode's inherited default. */
|
|
22
|
+
readonly aliases: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
23
|
+
/** Tests the mode values reachable through a saved file’s variable and its aliases.
|
|
24
|
+
* @param id - Imported variable ID.
|
|
25
|
+
* @param accepts - Predicate applied to each reachable literal.
|
|
26
|
+
* @returns Whether every mode satisfies the predicate.
|
|
27
|
+
*/
|
|
28
|
+
valuesMatch(id: string, accepts: (value: VariableValue) => boolean): boolean;
|
|
29
|
+
/** Looks up a numeric variable with positive length in every reachable mode.
|
|
30
|
+
* @param data - Figma binding.
|
|
31
|
+
* @param where - Source location for diagnostics.
|
|
32
|
+
* @returns Variable ID, or null when any mode has an invalid size.
|
|
33
|
+
*/
|
|
34
|
+
positiveLengthOf(data: unknown, where: string): VariableId | null;
|
|
35
|
+
/** The imported variable a Figma `VariableData` names, or why there is none. */
|
|
36
|
+
variableOf(data: unknown, where: string): Known;
|
|
37
|
+
/** The collection and mode a `variableModeBySetMap` entry names, or why there is none. */
|
|
38
|
+
modeOf(entry: unknown, where: string): {
|
|
39
|
+
readonly collectionId: string;
|
|
40
|
+
readonly modeId: VariableModeId;
|
|
41
|
+
} | string;
|
|
42
|
+
/**
|
|
43
|
+
* The style name a `FONT_STYLE` binding `data` of layer `figma` gives, in the mode the layer uses (its own or its
|
|
44
|
+
* nearest parent's choice for the variable's collection, else the default mode), and the variable's name; or why
|
|
45
|
+
* there is none. A variable deleted in Figma still gives its value. With `shownBy`, the layer is read as its instance
|
|
46
|
+
* shows it: the instance's choice comes before the component's, and the instance's parents replace the component's.
|
|
47
|
+
*/
|
|
48
|
+
fontStyleOf(data: unknown, figma: FigmaTreeNode, where: string, shownBy?: ShownBy): {
|
|
49
|
+
readonly style: string;
|
|
50
|
+
readonly variable: string;
|
|
51
|
+
} | {
|
|
52
|
+
readonly missing: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The number a `FLOAT` variable binding `data` of layer `figma` gives, in the mode the layer uses as for
|
|
56
|
+
* `fontStyleOf` (with `shownBy`, as that instance shows the layer), and the variable's name; or why there is none.
|
|
57
|
+
*/
|
|
58
|
+
numberOf(data: unknown, figma: FigmaTreeNode, where: string, shownBy?: ShownBy): {
|
|
59
|
+
readonly value: number;
|
|
60
|
+
readonly variable: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly missing: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The colour, as Taco hex, a `COLOR` variable binding `data` of layer `figma` gives, in the mode the layer uses as for
|
|
66
|
+
* `fontStyleOf` (with `shownBy`, as that instance shows the layer), and the variable's name; or why there is none.
|
|
67
|
+
*/
|
|
68
|
+
colorOf(data: unknown, figma: FigmaTreeNode, where: string, shownBy?: ShownBy): {
|
|
69
|
+
readonly value: string;
|
|
70
|
+
readonly variable: string;
|
|
71
|
+
} | {
|
|
72
|
+
readonly missing: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* An instance that shows a component layer, and the SYMBOL the instance shows; `modes` holds the instance's overrides of
|
|
77
|
+
* `variableModeBySetMap` on the SYMBOL's layers, by layer id.
|
|
78
|
+
*/
|
|
79
|
+
export interface ShownBy {
|
|
80
|
+
readonly instance: FigmaTreeNode;
|
|
81
|
+
readonly symbol: FigmaTreeNode;
|
|
82
|
+
readonly modes?: ReadonlyMap<string, unknown>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Every `VARIABLE_SET` of the message as a collection, its modes in Figma's order (the first is the default), and
|
|
86
|
+
* every `VARIABLE` in it with a value for each mode. A set or variable Figma marks deleted (`isSoftDeleted`) is left
|
|
87
|
+
* out, as is a variable whose set is not in the message or whose type Taco lacks; each is reported. Taco variables
|
|
88
|
+
* hold no aliases, so an alias takes the value it resolves to: in the same mode within its own collection, else in
|
|
89
|
+
* the other collection's default mode. A mode without a value takes the default mode's. Two collections of one name
|
|
90
|
+
* get a number, so that `var('collection/name')` can tell them apart. A number variable scoped to opacity alone (layer
|
|
91
|
+
* or color opacity) holds Figma's percentage, so it is imported divided by 100, on Taco's 0 to 1 scale. Ids come from
|
|
92
|
+
* `newId`.
|
|
93
|
+
* @param nodes - Source nodes in file order.
|
|
94
|
+
* @param newId - Allocates local identifiers.
|
|
95
|
+
* @param report - Receives import diagnostics.
|
|
96
|
+
* @param keepAliases - Retain source keys and direct alias targets for native file records.
|
|
97
|
+
* @returns Variable definitions and lookup functions.
|
|
98
|
+
*/
|
|
99
|
+
export declare function readFigmaVariables(nodes: Iterable<FigmaTreeNode>, newId: () => string, report: Report, keepAliases?: boolean): FigmaVariables;
|
|
100
|
+
/**
|
|
101
|
+
* Sets the variable bindings and variable modes of `layer`, converted from `figma`. A paint's `colorVar` binds
|
|
102
|
+
* `fillColor` or `strokeColor` when it is the bottom fill or the first stroke and solid (a text layer's colour is its
|
|
103
|
+
* top visible solid fill, bound as `textColor`); `variableConsumptionMap` entries bind by `FIELD_PROPERTIES` and
|
|
104
|
+
* `FIELD_GROUPS`. A binding the layer cannot take keeps the imported value and is named, with why, in one entry
|
|
105
|
+
* for the layer. With `variables` undefined (the host adds no variables) every binding is reported so. `overridden`
|
|
106
|
+
* names the binding fields an instance copy dropped because its instance overrides them; they join the same entry.
|
|
107
|
+
* `shownBy` reads a bound font style in the modes that instance shows the layer in (`FigmaVariables.fontStyleOf`).
|
|
108
|
+
* No reason names the layer: the entry's node is the layer, so that a host can count one reason over many layers.
|
|
109
|
+
* `styleList` reads the paints of the fill and stroke styles the layer names (`styleBackedList`), whose bindings it takes.
|
|
110
|
+
*/
|
|
111
|
+
export declare function bindLayerVariables(layer: SceneNode, figma: FigmaTreeNode, variables: FigmaVariables | undefined, report: (kind: FigmaImportReportKind, reason: string) => void, overridden?: readonly string[], shownBy?: ShownBy, styleList?: FigmaStyleList): void;
|
|
112
|
+
/**
|
|
113
|
+
* Whether the opacity `opacity` of Figma solid paint `paint` on layer `figma` is its colour variable's alpha, copied
|
|
114
|
+
* there by Figma: the paint's own colour is opaque, and the opacity rounds to the variable's 8-bit alpha in the mode
|
|
115
|
+
* the layer uses. For a saved file, match the paint's stored RGBA against the reachable variable colours.
|
|
116
|
+
* @param paint - Original solid paint.
|
|
117
|
+
* @param opacity - Stored paint opacity.
|
|
118
|
+
* @param figma - Consuming layer.
|
|
119
|
+
* @param variables - Imported variable definitions.
|
|
120
|
+
* @param where - Source location for diagnostics.
|
|
121
|
+
* @param shownBy - Instance displaying the layer.
|
|
122
|
+
* @returns Whether the variable colour already includes this opacity.
|
|
123
|
+
*/
|
|
124
|
+
export declare function foldsVariableAlpha(paint: FigmaObject, opacity: number, figma: FigmaTreeNode, variables: FigmaVariables | undefined, where: string, shownBy?: ShownBy): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* The font size Taco draws text `layer`, converted from `figma`, at when `bindLayerVariables` keeps its own `FONT_SIZE`
|
|
127
|
+
* binding: the variable's value in the mode the layer uses (with `shownBy`, as that instance shows it); else `undefined`,
|
|
128
|
+
* and each run is drawn at its own size.
|
|
129
|
+
*/
|
|
130
|
+
export declare function keptFontSize(layer: TextNode, figma: FigmaTreeNode, variables: FigmaVariables | undefined, shownBy?: ShownBy): number | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* The variable modes `figma` chooses (`variableModeBySetMap`), by collection id; a choice that names no imported
|
|
133
|
+
* collection or mode is added to `left`.
|
|
134
|
+
*/
|
|
135
|
+
export declare function figmaVariableModes(figma: FigmaTreeNode, variables: FigmaVariables | undefined, left: string[]): Record<string, VariableModeId>;
|
|
136
|
+
export {};
|