@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,449 @@
|
|
|
1
|
+
import { type SceneNodeKind } from "./codec.ts";
|
|
2
|
+
import { type NewCodeStyle } from "./new-nodes.ts";
|
|
3
|
+
import type { SerializedSubtree } from "./operations.ts";
|
|
4
|
+
import { type VariableArgument } from "./variable-references.ts";
|
|
5
|
+
import { type ComponentDefinition, type ComponentId, type ComponentPropertyDefinition, type ComponentPropertyValue, type DesignDocument, type NodeId, type Rect, type DocumentTheme, type SceneNode, type TransformMatrix, type VariableProperty, type VectorNetwork, type ValuedComponentPropertyDefinition, type SlotComponentProperty } from "./types.ts";
|
|
6
|
+
/** Where something is in the source: line and column, both from 1. */
|
|
7
|
+
export interface NodeBuildPosition {
|
|
8
|
+
readonly line: number;
|
|
9
|
+
readonly column: number;
|
|
10
|
+
}
|
|
11
|
+
/** One layer `buildNodes` made: its id, its layer name, the call that made it, as `vflex #1 > text #2`, and where that call is. */
|
|
12
|
+
export interface BuiltNodeCall extends NodeBuildPosition {
|
|
13
|
+
readonly id: NodeId;
|
|
14
|
+
/** The layer name: the call's `name`, or the one the panel's tool would give it, such as `Text 3`. */
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly call: string;
|
|
17
|
+
}
|
|
18
|
+
/** What `buildNodes` made: one subtree for each top-level call, and every layer made, in source order. */
|
|
19
|
+
export interface NodeBuildResult {
|
|
20
|
+
readonly subtrees: readonly SerializedSubtree[];
|
|
21
|
+
readonly calls: readonly BuiltNodeCall[];
|
|
22
|
+
/**
|
|
23
|
+
* The slot properties that `slot:Name` on a frame names and its component does not have yet, for a host to add to
|
|
24
|
+
* the component before it inserts the subtrees. Left out when there are none.
|
|
25
|
+
*/
|
|
26
|
+
readonly slotProperties?: readonly {
|
|
27
|
+
readonly componentId: ComponentId;
|
|
28
|
+
readonly property: SlotComponentProperty;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A source `buildNodes` cannot read (`syntax`) or a call it cannot make
|
|
33
|
+
* (`argument`: an unknown shorthand or argument, an argument given twice,
|
|
34
|
+
* an id given by two calls, children where the shorthand takes none, a
|
|
35
|
+
* value without a name, `fill` or `hug` where a size cannot take it, or `x`
|
|
36
|
+
* or `y` on a layer auto layout places), or a source with more calls than `maxCalls`
|
|
37
|
+
* allows (`size`). The message names the place, and the call when there is one.
|
|
38
|
+
*/
|
|
39
|
+
export declare class NodeBuildError extends Error {
|
|
40
|
+
readonly kind: "syntax" | "argument" | "size";
|
|
41
|
+
readonly line: number;
|
|
42
|
+
readonly column: number;
|
|
43
|
+
/** The call, as `vflex #1 > text #2`, for an `argument` error. */
|
|
44
|
+
readonly call: string | undefined;
|
|
45
|
+
/** The names the call's shorthand accepts, for an unknown argument. */
|
|
46
|
+
readonly accepted: readonly string[] | undefined;
|
|
47
|
+
constructor(kind: "syntax" | "argument" | "size", message: string, line: number, column: number, call?: string, accepted?: readonly string[]);
|
|
48
|
+
}
|
|
49
|
+
/** What `buildNodes` needs besides the source. */
|
|
50
|
+
export interface NodeBuildOptions {
|
|
51
|
+
/** A fresh id for a layer of `kind` that names none. Default: `<kind>-<random UUID>`. */
|
|
52
|
+
readonly newId?: (kind: string) => string;
|
|
53
|
+
/** The code style a `code` block uses. Default: the document's default code style. */
|
|
54
|
+
readonly codeStyle?: NewCodeStyle;
|
|
55
|
+
/**
|
|
56
|
+
* The most calls the source may have, counting every child. The parser stops at the call after the
|
|
57
|
+
* last allowed one and refuses the source as `size`, before any layer is made. Default: no limit.
|
|
58
|
+
*/
|
|
59
|
+
readonly maxCalls?: number;
|
|
60
|
+
/**
|
|
61
|
+
* The id of the layer the top-level layers go into. When the document holds it, a top-level call is judged as a
|
|
62
|
+
* child of it: `x` and `y` are refused in an auto layout frame, and `w:fill` or `h:fill` outside one.
|
|
63
|
+
*/
|
|
64
|
+
readonly parentId?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The spelling the source is written in. `"layer"` (the default) is the layer syntax of `node.build`: strings in
|
|
67
|
+
* double quotes with JSON escapes. `"tool"` is the spelling of the `read`, `build` and `edit` agent
|
|
68
|
+
* tools (`layer-syntax.ts`), written to need no JSON escapes when it is sent inside a JSON string: strings in single
|
|
69
|
+
* quotes (double quotes are read too) with a quote inside written twice (`'it''s'`), no backslash anywhere,
|
|
70
|
+
* backtick expressions refused, and `;` between top-level calls as well as `,`. It also reads calls by a component's
|
|
71
|
+
* name and in a scope (`button(text:'Buy')`, `forms.text()`, `std.text(...)`; see `componentNames`), made as
|
|
72
|
+
* `instance(componentId:..., ...)` calls.
|
|
73
|
+
*/
|
|
74
|
+
readonly syntax?: LayerSyntaxSpelling;
|
|
75
|
+
/**
|
|
76
|
+
* The id of the component the top-level layers go into, for `slot:Name` on a frame; left out, the component that
|
|
77
|
+
* holds `parentId`, if any. A call whose id is a component's root goes into that component.
|
|
78
|
+
*/
|
|
79
|
+
readonly component?: string;
|
|
80
|
+
/**
|
|
81
|
+
* True reads `slots:{Name:(2 layers, #<host id>)}`, the form a read prints for a filled slot without its layers, as the
|
|
82
|
+
* host as it is: the instance lists it and nothing is made. Left out, that form is refused.
|
|
83
|
+
*/
|
|
84
|
+
readonly keepSlotSummaries?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** The spelling of a source: see `NodeBuildOptions.syntax`. */
|
|
87
|
+
export type LayerSyntaxSpelling = "layer" | "tool";
|
|
88
|
+
/** The refusal of a backslash in the tool spelling, which never escapes anything. */
|
|
89
|
+
export declare const LAYER_SYNTAX_BACKSLASH_REFUSAL: string;
|
|
90
|
+
/** The refusal of a backtick in the tool spelling. */
|
|
91
|
+
export declare const LAYER_SYNTAX_BACKTICK_REFUSAL = "expressions in backticks are not supported yet; write the value itself";
|
|
92
|
+
/** A value of the language, once read: what the node holds. */
|
|
93
|
+
export type BuildValue = string | number | boolean | readonly BuildValue[] | {
|
|
94
|
+
readonly [key: string]: BuildValue;
|
|
95
|
+
};
|
|
96
|
+
/** One `name:value` of a call, as read. */
|
|
97
|
+
export interface Argument extends NodeBuildPosition {
|
|
98
|
+
/** Undefined for a value written without a name, which the builder refuses. */
|
|
99
|
+
readonly name: string | undefined;
|
|
100
|
+
readonly value: BuildValue;
|
|
101
|
+
/** The value as the source writes it, to show the call rewritten with names. */
|
|
102
|
+
readonly text: string;
|
|
103
|
+
/** True for `-name` (tool spelling only): the model field `name` is left out of the layer the call makes. */
|
|
104
|
+
readonly remove?: true;
|
|
105
|
+
}
|
|
106
|
+
/** One call of a source, as read. */
|
|
107
|
+
export interface Call extends NodeBuildPosition {
|
|
108
|
+
readonly name: string;
|
|
109
|
+
readonly arguments: readonly Argument[];
|
|
110
|
+
/** Undefined when the call has no `[...]`. */
|
|
111
|
+
readonly children: readonly Call[] | undefined;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The content of one slot as a `slots:{Name:( ... )}` list writes it: the calls of its layers, the id of its slot host
|
|
115
|
+
* when the list ends with `#<host id>`, and, for the form read prints at depth 0, `(2 layers, #<host id>)`, the count.
|
|
116
|
+
*/
|
|
117
|
+
export interface SlotContentSyntax extends NodeBuildPosition {
|
|
118
|
+
readonly calls: readonly Call[];
|
|
119
|
+
readonly hostId?: string;
|
|
120
|
+
/** The number of layers of `(2 layers, #<host id>)`, the form that names a filled slot without its layers. */
|
|
121
|
+
readonly summary?: number;
|
|
122
|
+
}
|
|
123
|
+
/** A value that stands for the slot content `content`, for `slotContentOf` to find again. */
|
|
124
|
+
export declare function slotContentValue(content: SlotContentSyntax): BuildValue;
|
|
125
|
+
/** The slot content a value stands for, or undefined for any other value. */
|
|
126
|
+
export declare const slotContentOf: (value: unknown) => SlotContentSyntax | undefined;
|
|
127
|
+
/** The refusal of `(2 layers, #<host id>)` where layers are to be written: what it is, and how to build into that slot. */
|
|
128
|
+
export declare const slotSummaryRefusal: (count: number, hostId: string) => string;
|
|
129
|
+
/** The argument of an instance call and the key of `over:{Path:{...}}` that fill its slots. */
|
|
130
|
+
export declare const INSTANCE_SLOTS_ARGUMENT = "slots";
|
|
131
|
+
/**
|
|
132
|
+
* `value` with each slot content inside it (at any depth of its objects) replaced by what `map` gives; `value` itself
|
|
133
|
+
* when it holds none.
|
|
134
|
+
*/
|
|
135
|
+
export declare function mapSlotContents(value: BuildValue, map: (content: SlotContentSyntax) => SlotContentSyntax): BuildValue;
|
|
136
|
+
/** The calls of every slot content in the arguments of `call`, in the order written. */
|
|
137
|
+
export declare function slotContentCalls(call: Call): Call[];
|
|
138
|
+
/** `reference` is a layer id with a place after it, `#card.right` (tool spelling only; see `readLayerReference`). */
|
|
139
|
+
export type TokenKind = "word" | "number" | "string" | "colour" | "reference" | "punctuation" | "end";
|
|
140
|
+
/**
|
|
141
|
+
* A layer id with an optional place on the layer after it, as the tool spelling writes the end of a connector:
|
|
142
|
+
* `#card`, `#card.right`, `#star.vertex(2)`, `#card.point(0.5, 1)`, or `#'1:2'.top` for an id with other characters.
|
|
143
|
+
* `place` is the word after the dot and `numbers` what is in `(...)` after it, each part as written, trimmed.
|
|
144
|
+
*/
|
|
145
|
+
export interface LayerReference {
|
|
146
|
+
readonly id: string;
|
|
147
|
+
readonly place?: string;
|
|
148
|
+
readonly numbers?: readonly string[];
|
|
149
|
+
}
|
|
150
|
+
/** Reads a layer reference (`#card.right`); undefined for a text that is not one. */
|
|
151
|
+
export declare function readLayerReference(text: string): LayerReference | undefined;
|
|
152
|
+
/** A layer reference as the tool spelling writes it, numbers as `String(Number(part))` where they are numbers. */
|
|
153
|
+
export declare function layerReferenceText(reference: LayerReference): string;
|
|
154
|
+
/** One token of a source. */
|
|
155
|
+
export interface Token extends NodeBuildPosition {
|
|
156
|
+
readonly kind: TokenKind;
|
|
157
|
+
readonly text: string;
|
|
158
|
+
readonly value?: BuildValue;
|
|
159
|
+
/** Where the token starts and ends in the source, as string indexes. */
|
|
160
|
+
readonly start: number;
|
|
161
|
+
readonly end: number;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A reader of a source, token by token, for `buildNodes` and for the rules of the `edit` tool
|
|
165
|
+
* (`layer-syntax.ts`). Each method throws a `syntax` NodeBuildError naming the line, the column and what was expected.
|
|
166
|
+
*/
|
|
167
|
+
export interface LayerSyntaxReader {
|
|
168
|
+
readonly source: string;
|
|
169
|
+
readonly toolSpelling: boolean;
|
|
170
|
+
peek(offset?: number): Token;
|
|
171
|
+
next(): Token;
|
|
172
|
+
isPunctuation(token: Token, text: string): boolean;
|
|
173
|
+
expect(text: string, what?: string): Token;
|
|
174
|
+
expected(what: string, token?: Token): NodeBuildError;
|
|
175
|
+
value(): BuildValue;
|
|
176
|
+
/** The value of the argument `name`, read as a call reads it: `slots:` and `over:` read slot lists where they take them. */
|
|
177
|
+
argumentValue(name: string): BuildValue;
|
|
178
|
+
call(): Call;
|
|
179
|
+
}
|
|
180
|
+
/** A reader of `source` in `spelling`; `maxCalls` limits the calls it reads (a `size` NodeBuildError past it). */
|
|
181
|
+
export declare function layerSyntaxReader(source: string, spelling?: LayerSyntaxSpelling, maxCalls?: number): LayerSyntaxReader;
|
|
182
|
+
type MutableNode = Record<string, unknown>;
|
|
183
|
+
/** What a shorthand knows when it makes its node. */
|
|
184
|
+
interface MakeContext {
|
|
185
|
+
readonly document: DesignDocument;
|
|
186
|
+
readonly id: NodeId;
|
|
187
|
+
readonly name: string;
|
|
188
|
+
readonly codeStyle: NewCodeStyle;
|
|
189
|
+
/** The arguments by name. */
|
|
190
|
+
readonly given: ReadonlyMap<string, BuildValue>;
|
|
191
|
+
/** The box from `x`, `y`, `w` and `h`, with the shorthand's default size where `w` or `h` is not a number. */
|
|
192
|
+
readonly box: Rect;
|
|
193
|
+
/** How `w` and `h` size the layer; undefined where the call does not give one. */
|
|
194
|
+
readonly sizing: {
|
|
195
|
+
readonly w: Sizing | undefined;
|
|
196
|
+
readonly h: Sizing | undefined;
|
|
197
|
+
};
|
|
198
|
+
/** The model fields the call writes by name. */
|
|
199
|
+
readonly fields: ReadonlyMap<string, BuildValue>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* How `w` or `h` sizes a layer, as Figma's resizing: `fixed` (a number, or a value the model judges),
|
|
203
|
+
* `fill` (fill the space an auto layout parent gives it) or `hug` (fit its content).
|
|
204
|
+
*/
|
|
205
|
+
type Sizing = "fixed" | "fill" | "hug";
|
|
206
|
+
/** A short argument: where it goes in the node. */
|
|
207
|
+
export type ShortArgument = (node: MutableNode, value: BuildValue) => void;
|
|
208
|
+
/** One shorthand of the layer syntax: the call that makes one kind of layer. */
|
|
209
|
+
export interface Shorthand {
|
|
210
|
+
readonly name: string;
|
|
211
|
+
readonly kind: SceneNodeKind;
|
|
212
|
+
readonly summary: string;
|
|
213
|
+
/** The name of its content argument (the characters of a text, the source of a code block), when it has one. */
|
|
214
|
+
readonly content?: string;
|
|
215
|
+
readonly takesChildren: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Which of `fill` and `hug` its `w` and `h` take besides a number. `points` is the reason a line or a
|
|
218
|
+
* connector takes numbers only. `hugsByDefault` is for a text, which hugs its content when `w` is left out.
|
|
219
|
+
*/
|
|
220
|
+
readonly sizes: {
|
|
221
|
+
readonly fill: boolean;
|
|
222
|
+
readonly hug: boolean;
|
|
223
|
+
readonly points?: string;
|
|
224
|
+
readonly hugsByDefault?: boolean;
|
|
225
|
+
};
|
|
226
|
+
/** The size used where `w` or `h` is not given. */
|
|
227
|
+
readonly defaultSize: {
|
|
228
|
+
readonly width: number;
|
|
229
|
+
readonly height: number;
|
|
230
|
+
};
|
|
231
|
+
/** The label of its layers' names and how the panel counts them. */
|
|
232
|
+
readonly naming: {
|
|
233
|
+
readonly label: string;
|
|
234
|
+
readonly counts?: (node: SceneNode) => boolean;
|
|
235
|
+
};
|
|
236
|
+
readonly make: (context: MakeContext) => SceneNode;
|
|
237
|
+
/** The short arguments it takes besides `x`, `y`, `w`, `h`, `id`, `name` and `opacity`. */
|
|
238
|
+
readonly short: Readonly<Record<string, ShortArgument>>;
|
|
239
|
+
/** Short arguments of every shorthand that this one does not take. */
|
|
240
|
+
readonly without?: readonly string[];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* A value a short argument cannot write, with what to write instead; `buildNodes` refuses the call with it, naming the
|
|
244
|
+
* argument's place, and the `edit` tool refuses the rule.
|
|
245
|
+
*/
|
|
246
|
+
export declare class ShortArgumentError extends Error {
|
|
247
|
+
/** Names the argument whose place a refusal from a shorthand's `make` gives, when it is not the call's. */
|
|
248
|
+
readonly argument: string | undefined;
|
|
249
|
+
constructor(message: string, argument?: string);
|
|
250
|
+
}
|
|
251
|
+
/** The forms of a connector end, for refusals and help. */
|
|
252
|
+
export declare const CONNECTOR_END_FORMS: string;
|
|
253
|
+
/**
|
|
254
|
+
* The points of a path from `d`, SVG path data, as an SVG file draws them (`vectorNetworkFromSvgPathData`, as an imported
|
|
255
|
+
* SVG path). Throws a ShortArgumentError naming the command, its place in `d` (counting characters from 1) and the forms
|
|
256
|
+
* for data that does not start with M, a letter that is no command, a command with too few or too many numbers, an arc
|
|
257
|
+
* flag other than 0 or 1, a number too large, or data that draws nothing.
|
|
258
|
+
*/
|
|
259
|
+
export declare function pathNetworkOf(value: BuildValue): VectorNetwork;
|
|
260
|
+
/**
|
|
261
|
+
* A path's points and transform with its bounds moved to `x` and `y` and sized to `w` and `h`, those given: `w` and `h` scale
|
|
262
|
+
* its points from the top-left corner of their bounds, as resizing a vector does, and `x` and `y` move its transform, so
|
|
263
|
+
* that the box around its points (`getVectorNetworkBounds`) has that corner and that size. The model judges the values:
|
|
264
|
+
* one that is not a number goes into the transform where it would have scaled or moved the path, for the model to refuse
|
|
265
|
+
* there. Throws a ShortArgumentError for a size of a path that has none that way (a straight line), and for `w` or `h` of a
|
|
266
|
+
* path whose transform turns or scales it.
|
|
267
|
+
*/
|
|
268
|
+
export declare function placedPath(vectorNetwork: VectorNetwork, transform: TransformMatrix, place: Readonly<Partial<Record<"x" | "y" | "w" | "h", BuildValue>>>): {
|
|
269
|
+
vectorNetwork: VectorNetwork;
|
|
270
|
+
transform: TransformMatrix;
|
|
271
|
+
};
|
|
272
|
+
/** The shorthand named `name` in the tool spelling (every shorthand of `buildNodes`, and video). */
|
|
273
|
+
export declare function toolShorthand(name: string): Shorthand | undefined;
|
|
274
|
+
/** The short names a shorthand accepts, in the order the table shows them. */
|
|
275
|
+
export declare function shortNamesOf(shorthand: Shorthand): string[];
|
|
276
|
+
/** The model fields a shorthand passes through unchanged. */
|
|
277
|
+
export declare function modelFieldsOf(shorthand: Shorthand): string[];
|
|
278
|
+
/** One shorthand as the help text and `protocol.describe` show it. */
|
|
279
|
+
export interface NodeShorthandDescription {
|
|
280
|
+
readonly name: string;
|
|
281
|
+
/** The kind of layer it makes. */
|
|
282
|
+
readonly kind: SceneNodeKind;
|
|
283
|
+
readonly summary: string;
|
|
284
|
+
/** The name of its content argument (`text` of a text, `source` of a code block), if any; it is named like every other. */
|
|
285
|
+
readonly content?: string;
|
|
286
|
+
readonly takesChildren: boolean;
|
|
287
|
+
/** Its short argument names. */
|
|
288
|
+
readonly arguments: readonly string[];
|
|
289
|
+
/** What its `w` and `h` take, in words, as `a number, fill or hug`; undefined when it takes no `w` and `h`. */
|
|
290
|
+
readonly sizes?: string;
|
|
291
|
+
/** The model fields it passes through unchanged, by their own names. */
|
|
292
|
+
readonly modelFields: readonly string[];
|
|
293
|
+
}
|
|
294
|
+
/** Every shorthand of `buildNodes`, with its arguments. */
|
|
295
|
+
export declare function nodeShorthands(): readonly NodeShorthandDescription[];
|
|
296
|
+
/**
|
|
297
|
+
* The shorthands as lines of text, one each: its call form, what it makes, and its arguments. Help texts
|
|
298
|
+
* show this table, so that it always lists the shorthands `buildNodes` has.
|
|
299
|
+
*/
|
|
300
|
+
export declare function nodeShorthandTable(): readonly string[];
|
|
301
|
+
/** The fields of a component the layer syntax reads: what `document.inspect` lists for each. */
|
|
302
|
+
export type LayerSyntaxComponent = Pick<ComponentDefinition, "id" | "name" | "rootId" | "properties" | "validity">;
|
|
303
|
+
/** A component call the syntax cannot make, from the helpers below; `buildNodes` adds the place, `layer-syntax.ts` the layer. */
|
|
304
|
+
export declare class ComponentCallError extends Error {
|
|
305
|
+
readonly at: NodeBuildPosition | undefined;
|
|
306
|
+
constructor(message: string, at?: NodeBuildPosition);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The call name of a component in the tool spelling, from its model name: split at `/` (the folders of the Assets
|
|
310
|
+
* panel), each part in lower case with every run of characters other than a to z and 0 to 9 written as one `-`, a `-` at
|
|
311
|
+
* either end left out and a part that starts with a digit given a `c` in front, the parts joined by `.`: "Button" is
|
|
312
|
+
* `button`, "Forms/Text" is `forms.text`, "Icon / Arrow Left" is `icon.arrow-left`. Undefined for a name with no letter or
|
|
313
|
+
* digit, which no call name can write.
|
|
314
|
+
*/
|
|
315
|
+
export declare function componentCallName(name: string): string | undefined;
|
|
316
|
+
/** A call name as written, in the form `componentCallName` gives: lower case, `_` read as `-` and a run of `-` as one. */
|
|
317
|
+
export declare function normalisedCallName(written: string): string;
|
|
318
|
+
/** What a call name names: a shorthand, or a component. */
|
|
319
|
+
export type ResolvedCallName = {
|
|
320
|
+
readonly kind: "shorthand";
|
|
321
|
+
readonly shorthand: Shorthand;
|
|
322
|
+
} | {
|
|
323
|
+
readonly kind: "component";
|
|
324
|
+
readonly component: LayerSyntaxComponent;
|
|
325
|
+
};
|
|
326
|
+
/** The components of a document by their call names. */
|
|
327
|
+
export interface ComponentNames {
|
|
328
|
+
readonly components: readonly LayerSyntaxComponent[];
|
|
329
|
+
byId(id: string): LayerSyntaxComponent | undefined;
|
|
330
|
+
/**
|
|
331
|
+
* What a call name names. `std.x` is the shorthand x; a bare name that is a shorthand is that shorthand, even when a
|
|
332
|
+
* component has the name too; `doc.x` and `a.b` are the component whose whole call name is `x` or `a.b`; any other
|
|
333
|
+
* bare name is the one component whose last part it is. Throws a ComponentCallError where that is not one thing
|
|
334
|
+
* (several components, or none for a name with a dot); undefined for a bare name that names nothing.
|
|
335
|
+
*/
|
|
336
|
+
resolve(written: string): ResolvedCallName | undefined;
|
|
337
|
+
/** The call name a read prints for the component: its whole call name, `doc.` in front where that names something else; undefined when no call name names it alone. */
|
|
338
|
+
callNameOf(component: LayerSyntaxComponent): string | undefined;
|
|
339
|
+
/**
|
|
340
|
+
* Every component `written` may name, in document order: for `doc.x` and `a.b`, those whose whole call name it is;
|
|
341
|
+
* for any other bare name, those whose call name ends in it (`resolve` names the one, or refuses several); none for `std.x`.
|
|
342
|
+
*/
|
|
343
|
+
named(written: string): readonly LayerSyntaxComponent[];
|
|
344
|
+
}
|
|
345
|
+
/** The components of `document` by their call names (see `componentCallName`). */
|
|
346
|
+
export declare function componentNames(document: DesignDocument): ComponentNames;
|
|
347
|
+
/** The call names of the document's components, for a refusal; empty without components. */
|
|
348
|
+
export declare function componentCallNames(document: DesignDocument): readonly string[];
|
|
349
|
+
/**
|
|
350
|
+
* The components of `document` that `component.list` lists, in document order: those after the component `after`, when
|
|
351
|
+
* given, that are among `ids` and that one of `callNames` may name (`ComponentNames.named`), when given. Undefined when
|
|
352
|
+
* `after` is no component of the document.
|
|
353
|
+
*/
|
|
354
|
+
export declare function listedComponents(document: DesignDocument, query: {
|
|
355
|
+
readonly callNames?: readonly string[];
|
|
356
|
+
readonly ids?: readonly string[];
|
|
357
|
+
readonly after?: string;
|
|
358
|
+
}): readonly LayerSyntaxComponent[] | undefined;
|
|
359
|
+
/** Where an instance call writes props in `props:{...}`, and the inner layers' overrides in `over:{...}`. */
|
|
360
|
+
export declare const INSTANCE_PROPS_ARGUMENT = "props";
|
|
361
|
+
export declare const INSTANCE_OVER_ARGUMENT = "over";
|
|
362
|
+
/** The arguments of an instance call other than its component's props: its layer's short arguments and model fields, `over` and `props`. */
|
|
363
|
+
export declare function instanceCallArguments(): ReadonlySet<string>;
|
|
364
|
+
/** Whether a prop is written in `props:{...}`: its name is another argument of an instance call (a person may call a prop `name`). */
|
|
365
|
+
export declare const propertyInProps: (property: ComponentPropertyDefinition) => boolean;
|
|
366
|
+
/**
|
|
367
|
+
* A key of `over:{...}` that the tool spelling reads bare, as one word: names joined by `.`, each a letter or `_` and then
|
|
368
|
+
* letters, digits, `_` and `-`.
|
|
369
|
+
*/
|
|
370
|
+
export declare const BARE_OVER_KEY: RegExp;
|
|
371
|
+
/**
|
|
372
|
+
* The props of a component as a refusal lists them: each with what it takes and its default. In the `expression` form,
|
|
373
|
+
* for a refusal of an expression, each prop and option name is written as an expression reads it: in backticks when
|
|
374
|
+
* it is not a plain word, an option after a dot, as `` `Primary / Hover` `` and `` .`Extra large` ``.
|
|
375
|
+
*/
|
|
376
|
+
export declare function componentPropertyList(component: LayerSyntaxComponent, names: ComponentNames, form?: "call" | "expression"): string;
|
|
377
|
+
/**
|
|
378
|
+
* For a refusal of an expression: a sentence saying that a name that is not a plain word is written in backticks, with
|
|
379
|
+
* the first prop name of `component` that needs them as the example, else the first such option; empty when every name
|
|
380
|
+
* is a plain word.
|
|
381
|
+
*/
|
|
382
|
+
export declare function expressionBacktickHint(component: LayerSyntaxComponent): string;
|
|
383
|
+
/**
|
|
384
|
+
* The value an instance stores for `property` from a value written in the syntax: an option's name for an enum (its id is
|
|
385
|
+
* stored), a component's call name for an instance swap (its id is stored), else the value itself when it has the prop's
|
|
386
|
+
* kind. Throws a ComponentCallError that shows the right form.
|
|
387
|
+
*/
|
|
388
|
+
export declare function propertyValueFromSyntax(component: LayerSyntaxComponent, property: ValuedComponentPropertyDefinition, value: BuildValue, names: ComponentNames): ComponentPropertyValue;
|
|
389
|
+
/** The fields of an override that a short name writes, as the shorthands write them on a layer. */
|
|
390
|
+
export declare const OVERRIDE_SHORT_NAMES: readonly ["text", "color", "size", "weight", "font", "fill", "stroke", "visible", "opacity"];
|
|
391
|
+
/** The text style fields `color`, `size`, `weight` and `font` of an override write, as those of a text write its run's. */
|
|
392
|
+
export declare const OVERRIDE_TEXT_STYLE_FIELDS: Readonly<Record<string, string>>;
|
|
393
|
+
/** The layers of a component, root first, in tree order, as `document` holds them; a nested instance is one layer. */
|
|
394
|
+
export declare function componentLayers(document: DesignDocument, component: LayerSyntaxComponent): SceneNode[];
|
|
395
|
+
/** A layer that `over:{...}` can name, inside the component or inside an instance nested in it. */
|
|
396
|
+
export interface OverridePath {
|
|
397
|
+
/** The stored key: the ids from the component down to the layer, one for each nested instance on the way, joined by `;`. */
|
|
398
|
+
readonly key: string;
|
|
399
|
+
/** The key by name: the names of the same layers, joined by `.`, as `Card.Button.Label`. */
|
|
400
|
+
readonly name: string;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* The layers of a component that `over:{...}` can name, root first, depth-first as the layers panel shows them: each
|
|
404
|
+
* layer of the component, and right after a nested instance the layers of that instance's component, through as many
|
|
405
|
+
* nested instances as `document` holds the layers of. A component inside itself is not entered again.
|
|
406
|
+
*/
|
|
407
|
+
export declare function overridePaths(document: DesignDocument, component: LayerSyntaxComponent): OverridePath[];
|
|
408
|
+
/**
|
|
409
|
+
* The overrides of `over:{...}` by layer path: each key names a layer of the component by its layer name, a layer inside
|
|
410
|
+
* a nested instance by the names on the way joined by `.` (`Button.Label`: the layer Label of the nested instance
|
|
411
|
+
* Button), or as `#<path>` (the stored key: the ids from the component down to the layer, joined by `;`). A key matches
|
|
412
|
+
* the joined names exactly, so a name that holds a dot needs nothing escaped; a key that names two layers is refused
|
|
413
|
+
* listing their `#<path>` forms. Throws a ComponentCallError that shows the right form.
|
|
414
|
+
*/
|
|
415
|
+
export declare function overridesFromSyntax(document: DesignDocument, component: LayerSyntaxComponent, value: BuildValue, names: ComponentNames, slots?: Record<string, Record<string, BuildValue>>): Record<string, Record<string, unknown>>;
|
|
416
|
+
/** The slot properties of a component, in order. */
|
|
417
|
+
export declare const slotPropertiesOf: (component: Pick<LayerSyntaxComponent, "properties">) => SlotComponentProperty[];
|
|
418
|
+
/**
|
|
419
|
+
* The component of the nested instance that `path` (layer ids through nested instances, as an override key) names
|
|
420
|
+
* inside `component`; undefined when a layer on the way is missing or the last is not an instance.
|
|
421
|
+
*/
|
|
422
|
+
export declare function componentAtPath(document: DesignDocument, component: LayerSyntaxComponent, path: readonly string[]): LayerSyntaxComponent | undefined;
|
|
423
|
+
/**
|
|
424
|
+
* A call of the tool spelling in the terms of the shorthands (children as written): `std.x` and a call name in
|
|
425
|
+
* another case as the shorthand's own name, and a component call as `instance(componentId:..., ...)` (see
|
|
426
|
+
* `instanceCallOf`). A call that names nothing comes back as written, for `buildNodes` to refuse. Throws a
|
|
427
|
+
* ComponentCallError for a call name that names several things, or for an argument of a component call it cannot write.
|
|
428
|
+
*/
|
|
429
|
+
export declare function resolveLayerCall(document: DesignDocument, call: Call): Call;
|
|
430
|
+
/**
|
|
431
|
+
* The layers a source of shorthand calls describes, as subtrees ready for `node.insert`, one for each
|
|
432
|
+
* top-level call, and each layer with the call that made it and its name. A layer named with `id:` keeps
|
|
433
|
+
* that id; every other gets `options.newId`. A new text is named by its first words; other names count on from
|
|
434
|
+
* the document's, as the panel's tools name layers.
|
|
435
|
+
*
|
|
436
|
+
* Throws `NodeBuildError` for a source it cannot read or a call it cannot make: a value without a name
|
|
437
|
+
* (the message shows the call with names), `fill` or `hug` for a `w` or `h` that cannot take it, and
|
|
438
|
+
* `x` or `y` on a layer its parent's auto layout places. It never judges a value: the nodes come back as
|
|
439
|
+
* the arguments wrote them, for the document model to accept or refuse.
|
|
440
|
+
*/
|
|
441
|
+
export declare function buildNodes(document: DesignDocument, source: string, options?: NodeBuildOptions): NodeBuildResult;
|
|
442
|
+
/**
|
|
443
|
+
* The value of the argument `name` of a layer of `kind` with each `var('…')` read (variable-references.ts): an argument
|
|
444
|
+
* written as one takes the variable's value in its active mode, and the properties it binds go into `bound`; in
|
|
445
|
+
* `variableBindings` each key written as one is bound to the variable and stays as its id. A `var('…')` anywhere else
|
|
446
|
+
* is refused.
|
|
447
|
+
*/
|
|
448
|
+
export declare function readVariables(theme: DocumentTheme, name: string, value: BuildValue, kind: string, bound: Map<VariableProperty, VariableArgument>): BuildValue;
|
|
449
|
+
export {};
|