@moondraft/import 0.0.0-stage → 0.2.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 +36 -0
- package/LICENSE +34 -0
- package/README.md +36 -2
- package/SOURCE.md +394 -0
- package/dist/adapter/convert.d.ts +144 -0
- package/dist/adapter/convert.js +2811 -0
- package/dist/adapter/figma-descriptions.d.ts +7 -0
- package/dist/adapter/figma-descriptions.js +34 -0
- package/dist/adapter/figma-grids.d.ts +12 -0
- package/dist/adapter/figma-grids.js +175 -0
- package/dist/adapter/figma-handoff.d.ts +12 -0
- package/dist/adapter/figma-handoff.js +167 -0
- package/dist/adapter/figma-hyperlinks.d.ts +13 -0
- package/dist/adapter/figma-hyperlinks.js +77 -0
- package/dist/adapter/figma.d.ts +12 -0
- package/dist/adapter/figma.js +40 -0
- package/dist/adapter/file-components.d.ts +20 -0
- package/dist/adapter/file-components.js +352 -0
- package/dist/adapter/file-resources.d.ts +29 -0
- package/dist/adapter/file-resources.js +851 -0
- package/dist/adapter/image-crop.d.ts +18 -0
- package/dist/adapter/image-crop.js +30 -0
- package/dist/adapter/index.d.ts +6 -0
- package/dist/adapter/index.js +9 -0
- package/dist/adapter/link.d.ts +49 -0
- package/dist/adapter/link.js +892 -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 +45 -0
- package/dist/adapter/variables.js +106 -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 +230 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +50 -0
- package/dist/report.d.ts +42 -0
- package/dist/report.js +142 -0
- package/dist/serialize.d.ts +7 -0
- package/dist/serialize.js +79 -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 +41 -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 +24 -0
- package/dist/taco/figma-import/import/carry.js +66 -0
- package/dist/taco/figma-import/import/componentProps.d.ts +90 -0
- package/dist/taco/figma-import/import/componentProps.js +329 -0
- package/dist/taco/figma-import/import/componentSets.d.ts +85 -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/exportSettings.d.ts +4 -0
- package/dist/taco/figma-import/import/converters/exportSettings.js +49 -0
- package/dist/taco/figma-import/import/converters/frame.d.ts +21 -0
- package/dist/taco/figma-import/import/converters/frame.js +63 -0
- package/dist/taco/figma-import/import/converters/gradient.d.ts +74 -0
- package/dist/taco/figma-import/import/converters/gradient.js +108 -0
- package/dist/taco/figma-import/import/converters/group.d.ts +19 -0
- package/dist/taco/figma-import/import/converters/group.js +30 -0
- package/dist/taco/figma-import/import/converters/image.d.ts +13 -0
- package/dist/taco/figma-import/import/converters/image.js +94 -0
- package/dist/taco/figma-import/import/converters/layout.d.ts +33 -0
- package/dist/taco/figma-import/import/converters/layout.js +187 -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 +8 -0
- package/dist/taco/figma-import/import/converters/section.js +29 -0
- package/dist/taco/figma-import/import/converters/shared.d.ts +71 -0
- package/dist/taco/figma-import/import/converters/shared.js +372 -0
- package/dist/taco/figma-import/import/converters/text.d.ts +54 -0
- package/dist/taco/figma-import/import/converters/text.js +707 -0
- package/dist/taco/figma-import/import/converters/vector.d.ts +105 -0
- package/dist/taco/figma-import/import/converters/vector.js +609 -0
- package/dist/taco/figma-import/import/converters/vectorNetwork.d.ts +114 -0
- package/dist/taco/figma-import/import/converters/vectorNetwork.js +503 -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 +184 -0
- package/dist/taco/figma-import/import/instances.js +1530 -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 +48 -0
- package/dist/taco/figma-import/import/styles.js +48 -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 +137 -0
- package/dist/taco/figma-import/import/variables.js +769 -0
- package/dist/taco/figma-import/import/variantTrees.d.ts +20 -0
- package/dist/taco/figma-import/import/variantTrees.js +520 -0
- package/dist/taco/figma-import/import/walk.d.ts +207 -0
- package/dist/taco/figma-import/import/walk.js +1464 -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 +12 -0
- package/dist/taco/figma-import/kiwi/message.js +147 -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 +5665 -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 +96 -0
- package/dist/taco/model/component-evaluation.js +555 -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 +376 -0
- package/dist/taco/model/instance-resolver.js +1778 -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 +79 -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 +2369 -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 +55 -4
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schema version this package reads and writes. `deserializeDocument`
|
|
3
|
+
* migrates older documents to it, and `assertDocument` rejects any other
|
|
4
|
+
* version.
|
|
5
|
+
*/
|
|
6
|
+
export const CURRENT_DOCUMENT_SCHEMA_VERSION = "0.44.0";
|
|
7
|
+
/** Canonical upper bound; retained text also carries one primary font asset. */
|
|
8
|
+
export const MAX_TEXT_FONT_FALLBACK_ASSETS = 4095;
|
|
9
|
+
function brandedId(value, label) {
|
|
10
|
+
if (value.length === 0) {
|
|
11
|
+
throw new TypeError(`${label} cannot be empty`);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
/** Brands a string as a `DocumentId`. Throws a `TypeError` for an empty string. */
|
|
16
|
+
export const documentId = (value) => brandedId(value, "DocumentId");
|
|
17
|
+
/** Brands a string as a `PageId`. Throws a `TypeError` for an empty string. */
|
|
18
|
+
export const pageId = (value) => brandedId(value, "PageId");
|
|
19
|
+
/** Brands a string as a `NodeId`. Throws a `TypeError` for an empty string. */
|
|
20
|
+
export const nodeId = (value) => brandedId(value, "NodeId");
|
|
21
|
+
/** Brands a string as an `AssetId`. Throws a `TypeError` for an empty string. */
|
|
22
|
+
export const assetId = (value) => brandedId(value, "AssetId");
|
|
23
|
+
/** Brands a string as a `NodeStyleId`. Throws a `TypeError` for an empty string. */
|
|
24
|
+
export const nodeStyleId = (value) => brandedId(value, "NodeStyleId");
|
|
25
|
+
/** Brands a string as a `TextStyleId`. Throws a `TypeError` for an empty string. */
|
|
26
|
+
export const textStyleId = (value) => brandedId(value, "TextStyleId");
|
|
27
|
+
/** Brands a string as a `CodeStyleId`. Throws a `TypeError` for an empty string. */
|
|
28
|
+
export const codeStyleId = (value) => brandedId(value, "CodeStyleId");
|
|
29
|
+
/** Brands a string as a `VariableCollectionId`. Throws a `TypeError` for an empty string. */
|
|
30
|
+
export const variableCollectionId = (value) => brandedId(value, "VariableCollectionId");
|
|
31
|
+
/** Brands a string as a `VariableModeId`. Throws a `TypeError` for an empty string. */
|
|
32
|
+
export const variableModeId = (value) => brandedId(value, "VariableModeId");
|
|
33
|
+
/** Brands a string as a `VariableId`. Throws a `TypeError` for an empty string. */
|
|
34
|
+
export const variableId = (value) => brandedId(value, "VariableId");
|
|
35
|
+
/** Brands a string as a `CommitId`. Throws a `TypeError` for an empty string. */
|
|
36
|
+
export const commitId = (value) => brandedId(value, "CommitId");
|
|
37
|
+
/**
|
|
38
|
+
* Brands a string as a `ComponentId`. Throws a `TypeError` for an empty string.
|
|
39
|
+
* @since 0.23.0
|
|
40
|
+
*/
|
|
41
|
+
export const componentId = (value) => brandedId(value, "ComponentId");
|
|
42
|
+
/**
|
|
43
|
+
* Brands a string as a `ComponentPropertyId`. Throws a `TypeError` for an empty string.
|
|
44
|
+
* @since 0.24.0
|
|
45
|
+
*/
|
|
46
|
+
export const componentPropertyId = (value) => brandedId(value, "ComponentPropertyId");
|
|
47
|
+
/** Brands a string as a `VectorVertexId`. Throws a `TypeError` for an empty string. */
|
|
48
|
+
export const vectorVertexId = (value) => brandedId(value, "VectorVertexId");
|
|
49
|
+
/** Brands a string as a `VectorSegmentId`. Throws a `TypeError` for an empty string. */
|
|
50
|
+
export const vectorSegmentId = (value) => brandedId(value, "VectorSegmentId");
|
|
51
|
+
/** Brands a string as a `VectorHandleId`. Throws a `TypeError` for an empty string. */
|
|
52
|
+
export const vectorHandleId = (value) => brandedId(value, "VectorHandleId");
|
|
53
|
+
/** Brands a string as a `VectorRegionId`. Throws a `TypeError` for an empty string. */
|
|
54
|
+
export const vectorRegionId = (value) => brandedId(value, "VectorRegionId");
|
|
55
|
+
/** OpenType feature and variation tags are exactly four printable ASCII bytes. */
|
|
56
|
+
export function openTypeTag(value) {
|
|
57
|
+
if (!/^[\x20-\x7e]{4}$/.test(value)) {
|
|
58
|
+
throw new TypeError("OpenTypeTag must contain exactly four printable ASCII characters");
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The stroke joins, as Figma names them (`MITER`, `BEVEL`, `ROUND`).
|
|
64
|
+
* @since 0.22.0
|
|
65
|
+
*/
|
|
66
|
+
export const STROKE_JOINS = ["miter", "bevel", "round"];
|
|
67
|
+
/**
|
|
68
|
+
* The ends of each dash of a dashed stroke, as in Figma's Dash cap menu.
|
|
69
|
+
* @since 0.22.0
|
|
70
|
+
*/
|
|
71
|
+
export const DASH_CAPS = ["none", "round", "square"];
|
|
72
|
+
/**
|
|
73
|
+
* Figma's default miter angle in degrees, 2 * asin(1 / 4): the angle at which
|
|
74
|
+
* a miter limit of 4 bevels.
|
|
75
|
+
* @since 0.22.0
|
|
76
|
+
*/
|
|
77
|
+
export const DEFAULT_STROKE_MITER_ANGLE = (2 * Math.asin(1 / 4) * 180) / Math.PI;
|
|
78
|
+
/**
|
|
79
|
+
* Separable and non-separable compositing modes, in CSS `mix-blend-mode` terms.
|
|
80
|
+
* @since 0.8.0
|
|
81
|
+
*/
|
|
82
|
+
export const BLEND_MODES = [
|
|
83
|
+
"normal",
|
|
84
|
+
"darken",
|
|
85
|
+
"multiply",
|
|
86
|
+
"color-burn",
|
|
87
|
+
"lighten",
|
|
88
|
+
"screen",
|
|
89
|
+
"color-dodge",
|
|
90
|
+
"overlay",
|
|
91
|
+
"soft-light",
|
|
92
|
+
"hard-light",
|
|
93
|
+
"difference",
|
|
94
|
+
"exclusion",
|
|
95
|
+
"hue",
|
|
96
|
+
"saturation",
|
|
97
|
+
"color",
|
|
98
|
+
"luminosity",
|
|
99
|
+
];
|
|
100
|
+
/**
|
|
101
|
+
* File formats a layer can export to.
|
|
102
|
+
* @since 0.14.0
|
|
103
|
+
*/
|
|
104
|
+
export const EXPORT_FORMATS = ["png", "jpeg", "svg", "pdf"];
|
|
105
|
+
/**
|
|
106
|
+
* JPEG compression level, or the raster resolution of PDF effects.
|
|
107
|
+
* @since 0.14.0
|
|
108
|
+
*/
|
|
109
|
+
export const EXPORT_QUALITIES = ["low", "medium", "high"];
|
|
110
|
+
/**
|
|
111
|
+
* "detailed" samples images bicubically; "basic" uses the nearest pixel.
|
|
112
|
+
* @since 0.14.0
|
|
113
|
+
*/
|
|
114
|
+
export const EXPORT_RESAMPLINGS = ["detailed", "basic"];
|
|
115
|
+
/**
|
|
116
|
+
* Figma's polygon and star point counts.
|
|
117
|
+
* @since 0.12.0
|
|
118
|
+
*/
|
|
119
|
+
export const MIN_SHAPE_POINT_COUNT = 3;
|
|
120
|
+
export const MAX_SHAPE_POINT_COUNT = 60;
|
|
121
|
+
/**
|
|
122
|
+
* Stroke end caps as Figma names them. None ends the stroke flat at the
|
|
123
|
+
* endpoint; round and square extend it by half the stroke width; the arrow
|
|
124
|
+
* caps draw a head in the stroke's paint whose size follows the stroke width.
|
|
125
|
+
* Lines and connectors share these end styles and draw them the same way.
|
|
126
|
+
* Heads are always solid, even on a dashed stroke.
|
|
127
|
+
* @since 0.12.0
|
|
128
|
+
*/
|
|
129
|
+
export const STROKE_CAPS = [
|
|
130
|
+
"none",
|
|
131
|
+
"round",
|
|
132
|
+
"square",
|
|
133
|
+
"line-arrow",
|
|
134
|
+
"triangle-arrow",
|
|
135
|
+
"reversed-triangle",
|
|
136
|
+
"circle-arrow",
|
|
137
|
+
"diamond-arrow",
|
|
138
|
+
];
|
|
139
|
+
/**
|
|
140
|
+
* The kinds of component property, as `ComponentPropertyDefinition.kind`.
|
|
141
|
+
* `"slot"` was added in 0.37.0.
|
|
142
|
+
* @since 0.24.0
|
|
143
|
+
*/
|
|
144
|
+
export const COMPONENT_PROPERTY_KINDS = ["boolean", "number", "text", "enum", "color", "instance", "slot"];
|
|
145
|
+
/**
|
|
146
|
+
* The unit of a number property: `"none"` reads as a `number` in
|
|
147
|
+
* expressions, `"px"` as a `length`, `"%"` as a `percent` and `"deg"` as an
|
|
148
|
+
* `angle`.
|
|
149
|
+
* @since 0.24.0
|
|
150
|
+
*/
|
|
151
|
+
export const COMPONENT_NUMBER_UNITS = ["none", "px", "%", "deg"];
|
|
152
|
+
/**
|
|
153
|
+
* True when instances give `property` a value, so it has a `defaultValue`
|
|
154
|
+
* and can be read in expressions: every kind but `"slot"`.
|
|
155
|
+
* @since 0.37.0
|
|
156
|
+
*/
|
|
157
|
+
export const isValuedComponentProperty = (property) => property.kind !== "slot";
|
|
158
|
+
/**
|
|
159
|
+
* The layer fields that can hold an expression. Which ones apply depends on
|
|
160
|
+
* the node type (see `computableFieldsOf`); `propertyValues.<property id>`
|
|
161
|
+
* computes a nested instance's property value.
|
|
162
|
+
* @since 0.24.0
|
|
163
|
+
*/
|
|
164
|
+
export const COMPUTABLE_FIELDS = [
|
|
165
|
+
"x",
|
|
166
|
+
"y",
|
|
167
|
+
"rotation",
|
|
168
|
+
"transform",
|
|
169
|
+
"clipContent",
|
|
170
|
+
"paragraphSpacing",
|
|
171
|
+
"lineHeightMultiplier",
|
|
172
|
+
"constraintSize",
|
|
173
|
+
"resizing.width",
|
|
174
|
+
"resizing.height",
|
|
175
|
+
"layout.widthSizing",
|
|
176
|
+
"layout.heightSizing",
|
|
177
|
+
"constraints.horizontal",
|
|
178
|
+
"constraints.vertical",
|
|
179
|
+
"startCap",
|
|
180
|
+
"endCap",
|
|
181
|
+
"visible",
|
|
182
|
+
"opacity",
|
|
183
|
+
"fills",
|
|
184
|
+
"strokes",
|
|
185
|
+
"effects",
|
|
186
|
+
"cornerRadius",
|
|
187
|
+
"cornerRadii",
|
|
188
|
+
"cornerSmoothing",
|
|
189
|
+
"width",
|
|
190
|
+
"height",
|
|
191
|
+
"minWidth",
|
|
192
|
+
"maxWidth",
|
|
193
|
+
"minHeight",
|
|
194
|
+
"maxHeight",
|
|
195
|
+
"gap",
|
|
196
|
+
"wrapGap",
|
|
197
|
+
"columnGap",
|
|
198
|
+
"rowGap",
|
|
199
|
+
"padding",
|
|
200
|
+
"direction",
|
|
201
|
+
"align",
|
|
202
|
+
"justify",
|
|
203
|
+
"wrap",
|
|
204
|
+
"characters",
|
|
205
|
+
"fontFamily",
|
|
206
|
+
"fontSize",
|
|
207
|
+
"fontWeight",
|
|
208
|
+
"lineHeight",
|
|
209
|
+
"letterSpacing",
|
|
210
|
+
"textColor",
|
|
211
|
+
"textStyle",
|
|
212
|
+
"componentId",
|
|
213
|
+
];
|
|
214
|
+
/**
|
|
215
|
+
* The character that joins the IDs in a layer path and a virtual node ID.
|
|
216
|
+
* Stored node IDs never contain it.
|
|
217
|
+
* @since 0.23.0
|
|
218
|
+
*/
|
|
219
|
+
export const LAYER_PATH_SEPARATOR = ";";
|
|
220
|
+
/**
|
|
221
|
+
* The most tags a page can hold in `Page.tags`.
|
|
222
|
+
* @since 0.29.0
|
|
223
|
+
*/
|
|
224
|
+
export const MAX_PAGE_TAGS = 8;
|
|
225
|
+
/**
|
|
226
|
+
* The most characters (UTF-16 code units, as `String.length` counts) one tag
|
|
227
|
+
* in `Page.tags` can have.
|
|
228
|
+
* @since 0.29.0
|
|
229
|
+
*/
|
|
230
|
+
export const MAX_PAGE_TAG_LENGTH = 32;
|
|
231
|
+
/**
|
|
232
|
+
* Says what is wrong with `value` as a page's `Page.tags`, or `null` when a
|
|
233
|
+
* page can hold it: a list of 1 to `MAX_PAGE_TAGS` different tags, each
|
|
234
|
+
* non-empty text of at most `MAX_PAGE_TAG_LENGTH` characters with no white
|
|
235
|
+
* space at its start or end.
|
|
236
|
+
* @since 0.29.0
|
|
237
|
+
*/
|
|
238
|
+
export function pageTagsProblem(value) {
|
|
239
|
+
if (!Array.isArray(value))
|
|
240
|
+
return "A page's tags must be a list of text";
|
|
241
|
+
if (value.length === 0)
|
|
242
|
+
return "An empty tag list must be omitted";
|
|
243
|
+
if (value.length > MAX_PAGE_TAGS)
|
|
244
|
+
return `A page can have at most ${MAX_PAGE_TAGS} tags`;
|
|
245
|
+
const seen = new Set();
|
|
246
|
+
for (const tag of value) {
|
|
247
|
+
if (typeof tag !== "string")
|
|
248
|
+
return "A page tag must be text";
|
|
249
|
+
if (tag.length === 0)
|
|
250
|
+
return "A page tag must not be empty";
|
|
251
|
+
if (tag !== tag.trim())
|
|
252
|
+
return "A page tag must not start or end with white space";
|
|
253
|
+
if (tag.length > MAX_PAGE_TAG_LENGTH) {
|
|
254
|
+
return `A page tag can have at most ${MAX_PAGE_TAG_LENGTH} characters`;
|
|
255
|
+
}
|
|
256
|
+
if (seen.has(tag))
|
|
257
|
+
return `The page tag ${JSON.stringify(tag)} appears twice`;
|
|
258
|
+
seen.add(tag);
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Whether the page can be deleted: true unless its `removable` is `false`.
|
|
264
|
+
* @since 0.29.0
|
|
265
|
+
*/
|
|
266
|
+
export function isPageRemovable(page) {
|
|
267
|
+
return page.removable !== false;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* The page with `tags` as its tags, in the form a document stores: an empty
|
|
271
|
+
* list leaves the field out. It does not check the tags; `pageTagsProblem`
|
|
272
|
+
* does, and so does every edit of a document.
|
|
273
|
+
* @since 0.29.0
|
|
274
|
+
*/
|
|
275
|
+
export function withPageTags(page, tags) {
|
|
276
|
+
const { tags: _previous, ...rest } = page;
|
|
277
|
+
return tags.length === 0 ? rest : { ...rest, tags: [...tags] };
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The page made removable or not, in the form a document stores: a
|
|
281
|
+
* removable page leaves the field out.
|
|
282
|
+
* @since 0.29.0
|
|
283
|
+
*/
|
|
284
|
+
export function withPageRemovable(page, removable) {
|
|
285
|
+
const { removable: _previous, ...rest } = page;
|
|
286
|
+
return removable ? rest : { ...rest, removable: false };
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Whether `value` is a colour a page can hold in `Page.canvasBackground`:
|
|
290
|
+
* `#` and six hexadecimal digits.
|
|
291
|
+
* @since 0.28.0
|
|
292
|
+
*/
|
|
293
|
+
export function isPageCanvasBackground(value) {
|
|
294
|
+
return typeof value === "string" && /^#[0-9a-fA-F]{6}$/.test(value);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The size limits of a `WebFontSource`.
|
|
298
|
+
* @since 0.30.0
|
|
299
|
+
*/
|
|
300
|
+
export const WEB_FONT_SOURCE_LIMITS = Object.freeze({
|
|
301
|
+
/** The most names `families` may hold. */
|
|
302
|
+
families: 32,
|
|
303
|
+
/** The most characters one family name may have. */
|
|
304
|
+
familyLength: 200,
|
|
305
|
+
/** The most characters `stylesheetUrl` may have. */
|
|
306
|
+
stylesheetUrlLength: 2048,
|
|
307
|
+
});
|
|
308
|
+
/** True for frames and groups, the nodes that have `children`. */
|
|
309
|
+
export const isContainerNode = (node) => node.type === "frame" || node.type === "group";
|
|
310
|
+
const NO_OWNED_CHILDREN = Object.freeze([]);
|
|
311
|
+
/**
|
|
312
|
+
* The IDs of the stored nodes that `node` owns directly: the nodes whose
|
|
313
|
+
* parent it is in the document's tree. Every walk of "the subtree this node
|
|
314
|
+
* owns" (parent tables, reachability and subtree checks, copying, removing,
|
|
315
|
+
* moving to a page, collecting a subtree's nodes) goes through this, so the
|
|
316
|
+
* tree has one definition of ownership.
|
|
317
|
+
*
|
|
318
|
+
* A container owns its `children`, in order. An instance owns the slot host
|
|
319
|
+
* frames listed in its `slots` map, ordered by the nested instance's path key
|
|
320
|
+
* and then by slot property ID (both sorted by code unit), so a host has the
|
|
321
|
+
* instance as its parent although the instance has no `children`. Every other
|
|
322
|
+
* node owns nothing.
|
|
323
|
+
*
|
|
324
|
+
* Use `isContainerNode` instead for questions about laying out or holding
|
|
325
|
+
* `children`: sizing, drop targets, insert and move targets, z-order.
|
|
326
|
+
*/
|
|
327
|
+
export const ownedChildIds = (node) => {
|
|
328
|
+
if (isContainerNode(node))
|
|
329
|
+
return node.children;
|
|
330
|
+
if (node.type === "instance" && node.slots !== undefined)
|
|
331
|
+
return slotHostIdsOf(node.slots);
|
|
332
|
+
return NO_OWNED_CHILDREN;
|
|
333
|
+
};
|
|
334
|
+
const slotHostIdCache = new WeakMap();
|
|
335
|
+
/**
|
|
336
|
+
* The host IDs in `slots`, ordered by path key and then by property ID. The
|
|
337
|
+
* result is cached when `slots` is frozen, as stored documents are, so
|
|
338
|
+
* repeated walks over one instance do not sort again.
|
|
339
|
+
*/
|
|
340
|
+
export const slotHostIdsOf = (slots) => {
|
|
341
|
+
// A document being checked may hold malformed slots (`null`, or an entry that is not a map of IDs). The check
|
|
342
|
+
// reports the shape; walks over the tree skip what is not a host ID, as they skip a malformed children list.
|
|
343
|
+
if (typeof slots !== "object" || slots === null || Array.isArray(slots))
|
|
344
|
+
return NO_OWNED_CHILDREN;
|
|
345
|
+
const cached = slotHostIdCache.get(slots);
|
|
346
|
+
if (cached !== undefined)
|
|
347
|
+
return cached;
|
|
348
|
+
const ids = [];
|
|
349
|
+
for (const pathKey of Object.keys(slots).sort(compareCodeUnits)) {
|
|
350
|
+
const byProperty = slots[pathKey];
|
|
351
|
+
if (typeof byProperty !== "object" || byProperty === null || Array.isArray(byProperty))
|
|
352
|
+
continue;
|
|
353
|
+
for (const propertyId of Object.keys(byProperty).sort(compareCodeUnits)) {
|
|
354
|
+
const hostId = byProperty[propertyId];
|
|
355
|
+
if (typeof hostId === "string")
|
|
356
|
+
ids.push(hostId);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const result = ids.length === 0 ? NO_OWNED_CHILDREN : ids;
|
|
360
|
+
if (Object.isFrozen(slots))
|
|
361
|
+
slotHostIdCache.set(slots, result);
|
|
362
|
+
return result;
|
|
363
|
+
};
|
|
364
|
+
const compareCodeUnits = (left, right) => (left < right ? -1 : left > right ? 1 : 0);
|
|
365
|
+
/** True for nodes that hold rich text (`TextNode`). */
|
|
366
|
+
export const isTextualNode = (node) => node.type === "text";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sentence for a property the model does not accept, naming every field it accepts in the same place.
|
|
3
|
+
* `allowed` is the list the check itself uses, so the sentence cannot name a field the check refuses.
|
|
4
|
+
*/
|
|
5
|
+
export declare function unknownPropertyMessage(key: string, allowed: readonly string[]): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sentence for a property the model does not accept, naming every field it accepts in the same place.
|
|
3
|
+
* `allowed` is the list the check itself uses, so the sentence cannot name a field the check refuses.
|
|
4
|
+
*/
|
|
5
|
+
export function unknownPropertyMessage(key, allowed) {
|
|
6
|
+
return `Unknown property ${key} (accepted here: ${allowed.join(", ")})`;
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documents known to be valid and frozen all the way down, so checking them
|
|
3
|
+
* again would give the same answer. `assertDocument` adds a document that
|
|
4
|
+
* passed its full check while frozen; `applyOperations` adds the document it
|
|
5
|
+
* returns when the document it was applied to is in here, because its check
|
|
6
|
+
* (`assertChangedDocument`) proves an edit of a valid document valid, and it
|
|
7
|
+
* freezes every part it wrote. `deserializeCheckedDocument` (store.ts) adds
|
|
8
|
+
* the frozen copy `deserializeDocument` returns. Only passes are kept.
|
|
9
|
+
*
|
|
10
|
+
* This module is internal to the model package: it is not exported from the
|
|
11
|
+
* package index.
|
|
12
|
+
*/
|
|
13
|
+
export declare const fullyValidatedDocuments: WeakSet<object>;
|
|
14
|
+
/**
|
|
15
|
+
* Each frozen copy `deserializeDocument` made of a value it was given (not of
|
|
16
|
+
* text), when nothing rewrote it: no migration step ran, no connector end was
|
|
17
|
+
* renamed and no group was refitted. The copy then holds what the value held
|
|
18
|
+
* when it was copied, so the two give the same `canonicalJson`. Keyed by the
|
|
19
|
+
* original, so the note keeps the copy alive only while the caller keeps the
|
|
20
|
+
* original, and never keeps the caller's original alive.
|
|
21
|
+
*/
|
|
22
|
+
export declare const unchangedCopies: WeakMap<object, object>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documents known to be valid and frozen all the way down, so checking them
|
|
3
|
+
* again would give the same answer. `assertDocument` adds a document that
|
|
4
|
+
* passed its full check while frozen; `applyOperations` adds the document it
|
|
5
|
+
* returns when the document it was applied to is in here, because its check
|
|
6
|
+
* (`assertChangedDocument`) proves an edit of a valid document valid, and it
|
|
7
|
+
* freezes every part it wrote. `deserializeCheckedDocument` (store.ts) adds
|
|
8
|
+
* the frozen copy `deserializeDocument` returns. Only passes are kept.
|
|
9
|
+
*
|
|
10
|
+
* This module is internal to the model package: it is not exported from the
|
|
11
|
+
* package index.
|
|
12
|
+
*/
|
|
13
|
+
export const fullyValidatedDocuments = new WeakSet();
|
|
14
|
+
/**
|
|
15
|
+
* Each frozen copy `deserializeDocument` made of a value it was given (not of
|
|
16
|
+
* text), when nothing rewrote it: no migration step ran, no connector end was
|
|
17
|
+
* renamed and no group was refitted. The copy then holds what the value held
|
|
18
|
+
* when it was copied, so the two give the same `canonicalJson`. Keyed by the
|
|
19
|
+
* original, so the note keeps the copy alive only while the caller keeps the
|
|
20
|
+
* original, and never keeps the caller's original alive.
|
|
21
|
+
*/
|
|
22
|
+
export const unchangedCopies = new WeakMap();
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type DesignDocument, type DocumentTheme, type NodeId, type SceneNode, type VariableCollection, type VariableModeId, type VariableModes, type VariableProperty, type VariableValue } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The modes a layer uses: its parent's modes with the layer's own choices on
|
|
4
|
+
* top. A collection the layer leaves out (Auto) keeps the parent's mode.
|
|
5
|
+
* Returns `parent` itself when `own` chooses nothing.
|
|
6
|
+
* @since 0.26.0
|
|
7
|
+
*/
|
|
8
|
+
export declare function inheritVariableModes(parent: VariableModes | undefined, own: VariableModes | undefined): VariableModes | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* The mode a collection shows under `modes`: the inherited choice, else the
|
|
11
|
+
* collection's `activeModeId`, else its `defaultModeId`.
|
|
12
|
+
* @since 0.26.0
|
|
13
|
+
*/
|
|
14
|
+
export declare function variableModeFor(collectionId: string, collection: VariableCollection, modes?: VariableModes): VariableModeId;
|
|
15
|
+
/**
|
|
16
|
+
* A stable text form of `modes` for cache keys: the collections in sorted
|
|
17
|
+
* order. Modes that match a collection's active mode are left out, so Auto
|
|
18
|
+
* and an explicit choice of the active mode give the same key.
|
|
19
|
+
* @since 0.26.0
|
|
20
|
+
*/
|
|
21
|
+
export declare function variableModesKey(theme: DocumentTheme, modes: VariableModes | undefined): string;
|
|
22
|
+
/**
|
|
23
|
+
* The modes in effect at a stored node: the page's modes, then each
|
|
24
|
+
* ancestor's, then the node's own. A layer of a component (outside any
|
|
25
|
+
* page) starts from the document's active modes at the component root; an
|
|
26
|
+
* instance applies its own modes on top when it is resolved. Undefined
|
|
27
|
+
* means every collection shows its active mode.
|
|
28
|
+
* @since 0.26.0
|
|
29
|
+
*/
|
|
30
|
+
export declare function variableModesAt(document: DesignDocument, nodeId: NodeId): VariableModes | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The modes a stored node inherits: `variableModesAt` its parent, or the
|
|
33
|
+
* page's modes for a page root. The node's own choices are not included.
|
|
34
|
+
* @since 0.26.0
|
|
35
|
+
*/
|
|
36
|
+
export declare function inheritedVariableModes(document: DesignDocument, nodeId: NodeId): VariableModes | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a node's variable bindings read any collection in a mode other
|
|
39
|
+
* than its active mode under `modes`. Stored values are written for the
|
|
40
|
+
* active modes, so only such a node needs `applyVariableBindings`.
|
|
41
|
+
* @since 0.26.0
|
|
42
|
+
*/
|
|
43
|
+
export declare function bindingsDependOnModes(theme: DocumentTheme, node: SceneNode, modes: VariableModes | undefined): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Writes one variable value into the node field it is bound to, the way the
|
|
46
|
+
* editor does when a variable is applied: a color drives the bottom fill or
|
|
47
|
+
* the first stroke, a radius sets every corner, a text property restyles
|
|
48
|
+
* every run. Sizes and opacity are clamped. A value of the wrong type
|
|
49
|
+
* changes nothing.
|
|
50
|
+
* @since 0.26.0
|
|
51
|
+
*/
|
|
52
|
+
export declare function withVariableValue(theme: DocumentTheme, node: SceneNode, property: VariableProperty, value: VariableValue): SceneNode;
|
|
53
|
+
/**
|
|
54
|
+
* Writes each of the node's variable bindings in the modes `modes` into
|
|
55
|
+
* the bound field (see `withVariableValue`). A binding to a missing
|
|
56
|
+
* variable, or one the node cannot take, is skipped. A text layer that
|
|
57
|
+
* sizes itself is measured again. Returns `node` itself when it has no
|
|
58
|
+
* bindings.
|
|
59
|
+
* @since 0.26.0
|
|
60
|
+
*/
|
|
61
|
+
export declare function applyVariableBindings(document: DesignDocument, node: SceneNode, modes: VariableModes | undefined): SceneNode;
|