@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,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For tests that count every read of the node tables edits make
|
|
3
|
+
* (edit-cost-growth): when `wrap` is set, every node table an edit copies is
|
|
4
|
+
* passed through it before the edit writes into it, so a counting proxy is
|
|
5
|
+
* the table the document keeps and every cache is keyed by.
|
|
6
|
+
*/
|
|
7
|
+
export declare const nodeTableWatch: {
|
|
8
|
+
wrap: (<Table extends object>(table: Table) => Table) | null;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* For tests that count what a view of a document costs: `entriesPut` counts
|
|
12
|
+
* the entries `nodeTableWith` puts over a table.
|
|
13
|
+
*/
|
|
14
|
+
export declare const nodeTableWithStats: {
|
|
15
|
+
entriesPut: number;
|
|
16
|
+
};
|
|
17
|
+
/** One pass over a whole node table: the functions that made it, innermost first, and the entries it listed. */
|
|
18
|
+
export interface NodeTableWalk {
|
|
19
|
+
readonly callers: readonly string[];
|
|
20
|
+
readonly entries: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Starts recording every pass over a whole shared or overlay node table:
|
|
24
|
+
* `tableKeys`, `tableValues`, `tableEntries`, `plainNodeTable`, a copy that
|
|
25
|
+
* starts a new family, and `Object.keys`, `Object.values`, `Object.entries`,
|
|
26
|
+
* `for…in`, a spread or `copyTable` through the table's Proxy (see
|
|
27
|
+
* `watchSharedTableListings` for the one case it misses: listing through the
|
|
28
|
+
* Proxy a table that was the head before the recording started, so a test
|
|
29
|
+
* records an edit first and counts the passes of a second recording). Each
|
|
30
|
+
* pass is recorded with the functions on the stack that made it (built-in
|
|
31
|
+
* functions left out) and the number of entries the table had. `stop` ends
|
|
32
|
+
* the recording and gives the passes.
|
|
33
|
+
*/
|
|
34
|
+
export declare function recordNodeTableWalks(): {
|
|
35
|
+
stop(): readonly NodeTableWalk[];
|
|
36
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lets a test count the passes over whole node tables that edits make.
|
|
3
|
+
* Internal: the package does not export it. Edits keep their node tables as
|
|
4
|
+
* shared tables (`shared-node-table.ts`), which report every pass over a
|
|
5
|
+
* whole table to `watchSharedTableListings`, so no table is wrapped and every
|
|
6
|
+
* cache kept per table (parents, instances, frozen checks) stays as it is.
|
|
7
|
+
*/
|
|
8
|
+
import { unwatchSharedTableListings, watchSharedTableListings } from "./shared-node-table.js";
|
|
9
|
+
/**
|
|
10
|
+
* For tests that count every read of the node tables edits make
|
|
11
|
+
* (edit-cost-growth): when `wrap` is set, every node table an edit copies is
|
|
12
|
+
* passed through it before the edit writes into it, so a counting proxy is
|
|
13
|
+
* the table the document keeps and every cache is keyed by.
|
|
14
|
+
*/
|
|
15
|
+
export const nodeTableWatch = { wrap: null };
|
|
16
|
+
/**
|
|
17
|
+
* For tests that count what a view of a document costs: `entriesPut` counts
|
|
18
|
+
* the entries `nodeTableWith` puts over a table.
|
|
19
|
+
*/
|
|
20
|
+
export const nodeTableWithStats = { entriesPut: 0 };
|
|
21
|
+
/**
|
|
22
|
+
* Starts recording every pass over a whole shared or overlay node table:
|
|
23
|
+
* `tableKeys`, `tableValues`, `tableEntries`, `plainNodeTable`, a copy that
|
|
24
|
+
* starts a new family, and `Object.keys`, `Object.values`, `Object.entries`,
|
|
25
|
+
* `for…in`, a spread or `copyTable` through the table's Proxy (see
|
|
26
|
+
* `watchSharedTableListings` for the one case it misses: listing through the
|
|
27
|
+
* Proxy a table that was the head before the recording started, so a test
|
|
28
|
+
* records an edit first and counts the passes of a second recording). Each
|
|
29
|
+
* pass is recorded with the functions on the stack that made it (built-in
|
|
30
|
+
* functions left out) and the number of entries the table had. `stop` ends
|
|
31
|
+
* the recording and gives the passes.
|
|
32
|
+
*/
|
|
33
|
+
export function recordNodeTableWalks() {
|
|
34
|
+
const walks = [];
|
|
35
|
+
watchSharedTableListings(function recordWalk(entries) {
|
|
36
|
+
walks.push({ callers: callersOf(new Error().stack ?? ""), entries });
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
stop() {
|
|
40
|
+
unwatchSharedTableListings();
|
|
41
|
+
return walks;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** The frames of the hook itself, left out of a walk's callers. */
|
|
46
|
+
const HOOK_FRAMES = new Set(["recordWalk", "noteListing", "countedHeadKeys", "ownKeys"]);
|
|
47
|
+
/** The named functions of a V8 stack below the hook, innermost first, without built-ins. */
|
|
48
|
+
function callersOf(stack) {
|
|
49
|
+
const callers = [];
|
|
50
|
+
// The first line is the message.
|
|
51
|
+
for (const line of stack.split("\n").slice(1)) {
|
|
52
|
+
const frame = /^\s*at (?:async )?(\S+) \((.*)\)$/u.exec(line);
|
|
53
|
+
if (frame === null)
|
|
54
|
+
continue;
|
|
55
|
+
const [, name, location] = frame;
|
|
56
|
+
if (location === "<anonymous>" || location === "native" || location.startsWith("node:"))
|
|
57
|
+
continue;
|
|
58
|
+
const caller = name.replace(/^Object\./u, "");
|
|
59
|
+
if (!HOOK_FRAMES.has(caller))
|
|
60
|
+
callers.push(caller);
|
|
61
|
+
}
|
|
62
|
+
return callers;
|
|
63
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DesignDocument, NodeId, SceneNode, TransformMatrix } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Where a layer is drawn: the transform from a layer's own coordinates to its
|
|
4
|
+
* parent's, and through every ancestor to the page. The editor, the page
|
|
5
|
+
* compiler and connector attachment all place layers with these two
|
|
6
|
+
* functions, so a point on a layer lands in the same place for each of them.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Composes two affine transforms. The result applies `right` first, then `left`.
|
|
10
|
+
* Matrices use the `[a, b, c, d, e, f]` layout, where
|
|
11
|
+
* `x' = a*x + c*y + e` and `y' = b*x + d*y + f`. In 3×3 form this is the
|
|
12
|
+
* matrix product $M = L R$, so $M\mathbf{p} = L(R\mathbf{p})$.
|
|
13
|
+
*/
|
|
14
|
+
export declare function multiplyTransforms(left: TransformMatrix, right: TransformMatrix): TransformMatrix;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a transform can be inverted: its determinant is finite and its
|
|
17
|
+
* magnitude is above `Number.EPSILON`. This is the one rule for it: the
|
|
18
|
+
* editor's `invertTransform` refuses every other matrix, and a layer whose
|
|
19
|
+
* transform it refuses has no selection box.
|
|
20
|
+
*/
|
|
21
|
+
export declare function transformIsInvertible(transform: TransformMatrix): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The transform from a layer's own coordinates (the top-left of its frame at
|
|
24
|
+
* the origin) to its parent's: its flips, then its rotation, both about the
|
|
25
|
+
* middle of its frame, then its position. A path carries its transform
|
|
26
|
+
* itself. A layer that is not rotated or flipped gives exactly its position,
|
|
27
|
+
* with no rounding.
|
|
28
|
+
*/
|
|
29
|
+
export declare function nodeLocalTransform(node: SceneNode): TransformMatrix;
|
|
30
|
+
/**
|
|
31
|
+
* The transform from a layer's own coordinates to canonical page
|
|
32
|
+
* coordinates: every ancestor's position, rotation and flips, then the
|
|
33
|
+
* layer's own. The structural root (a page's root frame, or the root of a
|
|
34
|
+
* component) is the coordinate origin, so its own transform is left out.
|
|
35
|
+
* `parents` defaults to the parent table kept for `document.nodes`
|
|
36
|
+
* (`parentMapOf`). Pass a `transforms` cache when
|
|
37
|
+
* calling this for many layers of one document.
|
|
38
|
+
*/
|
|
39
|
+
export declare function nodePageTransform(document: DesignDocument, id: NodeId, parents?: ReadonlyMap<NodeId, NodeId>, transforms?: Map<NodeId, TransformMatrix>): TransformMatrix;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { IDENTITY_TRANSFORM } from "./geometry.js";
|
|
2
|
+
import { parentMapOf } from "./group-bounds.js";
|
|
3
|
+
import { entryOf } from "./id-table.js";
|
|
4
|
+
/**
|
|
5
|
+
* Where a layer is drawn: the transform from a layer's own coordinates to its
|
|
6
|
+
* parent's, and through every ancestor to the page. The editor, the page
|
|
7
|
+
* compiler and connector attachment all place layers with these two
|
|
8
|
+
* functions, so a point on a layer lands in the same place for each of them.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Composes two affine transforms. The result applies `right` first, then `left`.
|
|
12
|
+
* Matrices use the `[a, b, c, d, e, f]` layout, where
|
|
13
|
+
* `x' = a*x + c*y + e` and `y' = b*x + d*y + f`. In 3×3 form this is the
|
|
14
|
+
* matrix product $M = L R$, so $M\mathbf{p} = L(R\mathbf{p})$.
|
|
15
|
+
*/
|
|
16
|
+
export function multiplyTransforms(left, right) {
|
|
17
|
+
const [a, b, c, d, e, f] = left;
|
|
18
|
+
const [g, h, i, j, k, l] = right;
|
|
19
|
+
return [
|
|
20
|
+
a * g + c * h,
|
|
21
|
+
b * g + d * h,
|
|
22
|
+
a * i + c * j,
|
|
23
|
+
b * i + d * j,
|
|
24
|
+
a * k + c * l + e,
|
|
25
|
+
b * k + d * l + f,
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether a transform can be inverted: its determinant is finite and its
|
|
30
|
+
* magnitude is above `Number.EPSILON`. This is the one rule for it: the
|
|
31
|
+
* editor's `invertTransform` refuses every other matrix, and a layer whose
|
|
32
|
+
* transform it refuses has no selection box.
|
|
33
|
+
*/
|
|
34
|
+
export function transformIsInvertible(transform) {
|
|
35
|
+
const [a, b, c, d] = transform;
|
|
36
|
+
const determinant = a * d - b * c;
|
|
37
|
+
return Number.isFinite(determinant) && Math.abs(determinant) > Number.EPSILON;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The transform from a layer's own coordinates (the top-left of its frame at
|
|
41
|
+
* the origin) to its parent's: its flips, then its rotation, both about the
|
|
42
|
+
* middle of its frame, then its position. A path carries its transform
|
|
43
|
+
* itself. A layer that is not rotated or flipped gives exactly its position,
|
|
44
|
+
* with no rounding.
|
|
45
|
+
*/
|
|
46
|
+
export function nodeLocalTransform(node) {
|
|
47
|
+
if (node.type === "shape" && node.shape === "path")
|
|
48
|
+
return node.transform;
|
|
49
|
+
if (node.rotation === 0 && node.flipX !== true && node.flipY !== true) {
|
|
50
|
+
return [1, 0, 0, 1, node.frame.x, node.frame.y];
|
|
51
|
+
}
|
|
52
|
+
const angle = node.rotation * Math.PI / 180;
|
|
53
|
+
const x = node.flipX ? -1 : 1;
|
|
54
|
+
const y = node.flipY ? -1 : 1;
|
|
55
|
+
const a = Math.cos(angle) * x, b = Math.sin(angle) * x;
|
|
56
|
+
const c = -Math.sin(angle) * y, d = Math.cos(angle) * y;
|
|
57
|
+
const cx = node.frame.width / 2, cy = node.frame.height / 2;
|
|
58
|
+
return [a, b, c, d, node.frame.x + cx - a * cx - c * cy,
|
|
59
|
+
node.frame.y + cy - b * cx - d * cy];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The transform from a layer's own coordinates to canonical page
|
|
63
|
+
* coordinates: every ancestor's position, rotation and flips, then the
|
|
64
|
+
* layer's own. The structural root (a page's root frame, or the root of a
|
|
65
|
+
* component) is the coordinate origin, so its own transform is left out.
|
|
66
|
+
* `parents` defaults to the parent table kept for `document.nodes`
|
|
67
|
+
* (`parentMapOf`). Pass a `transforms` cache when
|
|
68
|
+
* calling this for many layers of one document.
|
|
69
|
+
*/
|
|
70
|
+
export function nodePageTransform(document, id, parents = parentMapOf(document.nodes), transforms = new Map()) {
|
|
71
|
+
const cached = transforms.get(id);
|
|
72
|
+
if (cached !== undefined)
|
|
73
|
+
return cached;
|
|
74
|
+
const parent = parents.get(id);
|
|
75
|
+
const transform = parent === undefined ? IDENTITY_TRANSFORM
|
|
76
|
+
: multiplyTransforms(nodePageTransform(document, parent, parents, transforms), nodeLocalTransform(entryOf(document.nodes, id)));
|
|
77
|
+
transforms.set(id, transform);
|
|
78
|
+
return transform;
|
|
79
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NodeId } from "./types.ts";
|
|
2
|
+
export declare class NodeUsers<Key> {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(base: NodeUsers<Key> | undefined, keysById: ReadonlyMap<NodeId, readonly Key[] | null>);
|
|
5
|
+
keysOf(id: NodeId): readonly Key[] | null;
|
|
6
|
+
usersOf(key: Key): NodeId[];
|
|
7
|
+
with(changes: ReadonlyMap<NodeId, readonly Key[] | null>): NodeUsers<Key>;
|
|
8
|
+
}
|
|
9
|
+
/** Whether two key lists of one node hold the same keys in the same order. */
|
|
10
|
+
export declare function sameKeys<Key>(left: readonly Key[] | null, right: readonly Key[] | null): boolean;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which nodes use each key (an asset, a theme style or variable): an index
|
|
3
|
+
* made of layers, each listing the keys of the nodes one edit wrote over the
|
|
4
|
+
* layer below, so the index of an edited document costs as much as the
|
|
5
|
+
* nodes the edit wrote. Every few layers it is written out flat, so lookups
|
|
6
|
+
* stay short.
|
|
7
|
+
*
|
|
8
|
+
* Internal to the model: not exported from the package index.
|
|
9
|
+
*/
|
|
10
|
+
/** How many layers of changes an index stacks before it is written out flat. */
|
|
11
|
+
const MAX_NODE_USERS_DEPTH = 8;
|
|
12
|
+
export class NodeUsers {
|
|
13
|
+
#base;
|
|
14
|
+
/** The keys each node this layer lists uses; null for a node that uses none, or is gone. */
|
|
15
|
+
#keysById;
|
|
16
|
+
#idsByKey;
|
|
17
|
+
#depth;
|
|
18
|
+
constructor(base, keysById) {
|
|
19
|
+
this.#base = base;
|
|
20
|
+
this.#keysById = keysById;
|
|
21
|
+
const idsByKey = new Map();
|
|
22
|
+
for (const [id, keys] of keysById) {
|
|
23
|
+
for (const key of keys ?? []) {
|
|
24
|
+
const ids = idsByKey.get(key);
|
|
25
|
+
if (ids === undefined)
|
|
26
|
+
idsByKey.set(key, [id]);
|
|
27
|
+
else
|
|
28
|
+
ids.push(id);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
this.#idsByKey = idsByKey;
|
|
32
|
+
this.#depth = base === undefined ? 0 : base.#depth + 1;
|
|
33
|
+
}
|
|
34
|
+
keysOf(id) {
|
|
35
|
+
const own = this.#keysById.get(id);
|
|
36
|
+
if (own !== undefined)
|
|
37
|
+
return own;
|
|
38
|
+
return this.#base === undefined ? null : this.#base.keysOf(id);
|
|
39
|
+
}
|
|
40
|
+
usersOf(key) {
|
|
41
|
+
const ids = [...(this.#idsByKey.get(key) ?? [])];
|
|
42
|
+
for (const id of this.#base === undefined ? [] : this.#base.usersOf(key)) {
|
|
43
|
+
if (!this.#keysById.has(id))
|
|
44
|
+
ids.push(id);
|
|
45
|
+
}
|
|
46
|
+
return ids;
|
|
47
|
+
}
|
|
48
|
+
with(changes) {
|
|
49
|
+
if (changes.size === 0)
|
|
50
|
+
return this;
|
|
51
|
+
if (this.#depth + 1 < MAX_NODE_USERS_DEPTH)
|
|
52
|
+
return new NodeUsers(this, changes);
|
|
53
|
+
const flat = new Map();
|
|
54
|
+
this.#addTo(flat, new Set());
|
|
55
|
+
for (const [id, keys] of changes) {
|
|
56
|
+
if (keys === null)
|
|
57
|
+
flat.delete(id);
|
|
58
|
+
else
|
|
59
|
+
flat.set(id, keys);
|
|
60
|
+
}
|
|
61
|
+
return new NodeUsers(undefined, flat);
|
|
62
|
+
}
|
|
63
|
+
#addTo(flat, decided) {
|
|
64
|
+
for (const [id, keys] of this.#keysById) {
|
|
65
|
+
if (decided.has(id))
|
|
66
|
+
continue;
|
|
67
|
+
decided.add(id);
|
|
68
|
+
if (keys !== null)
|
|
69
|
+
flat.set(id, keys);
|
|
70
|
+
}
|
|
71
|
+
if (this.#base !== undefined)
|
|
72
|
+
this.#base.#addTo(flat, decided);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** Whether two key lists of one node hold the same keys in the same order. */
|
|
76
|
+
export function sameKeys(left, right) {
|
|
77
|
+
if (left === right)
|
|
78
|
+
return true;
|
|
79
|
+
if (left === null || right === null || left.length !== right.length)
|
|
80
|
+
return false;
|
|
81
|
+
return left.every((key, index) => key === right[index]);
|
|
82
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { DocumentOperation } from "./operations.ts";
|
|
2
|
+
import type { DesignDocument } from "./types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* A kind of document part that has its own ID: a node (layer), a page, a
|
|
5
|
+
* component or an asset.
|
|
6
|
+
*/
|
|
7
|
+
export type DocumentPartKind = "node" | "page" | "component" | "asset";
|
|
8
|
+
/**
|
|
9
|
+
* One part of a document: one with an ID, named by its kind and ID, or the
|
|
10
|
+
* theme as a whole (its styles, named colors and variables), which an
|
|
11
|
+
* operation names when it names any style or variable in it.
|
|
12
|
+
*/
|
|
13
|
+
export type DocumentPartReference = {
|
|
14
|
+
readonly kind: DocumentPartKind;
|
|
15
|
+
readonly id: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: "theme";
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Every part `operation` names by ID, each once, in the order the operation
|
|
21
|
+
* names them: the part it changes (such as `node.patch`'s `nodeId` or the ID of
|
|
22
|
+
* the asset `asset.put` writes), the parts it places it under (`parentId`,
|
|
23
|
+
* `newParentId`), every node of an inserted subtree, and each part a node, page,
|
|
24
|
+
* component, theme or comment thread in it refers to (such as a connector's
|
|
25
|
+
* ends, an instance's component, an image's asset or a text run's font asset).
|
|
26
|
+
* The theme counts as one part, named when the operation names any node, text
|
|
27
|
+
* or code style or any variable or variable mode, writes a whole text or code
|
|
28
|
+
* node (whose runs or code without a style ID take the theme's default style)
|
|
29
|
+
* or a layer override that sets a text layer's text or style (also one that
|
|
30
|
+
* clears its style), or replaces the theme. A `node.patch` of a text or code node names it too,
|
|
31
|
+
* which only the document can tell (`textStyleThemeReads`).
|
|
32
|
+
*
|
|
33
|
+
* The records are walked by their types, field by field, so only a field the
|
|
34
|
+
* schema types as an ID is read as one: a word in a text, a name, a field name,
|
|
35
|
+
* a key a person chose (such as a named color or a layer path of an instance's
|
|
36
|
+
* overrides) and anything in the free-form `metadata` of a node, page or
|
|
37
|
+
* component are never taken for an ID. Component property values are not read
|
|
38
|
+
* either, since an instance's value is a component ID only for a property of
|
|
39
|
+
* kind `instance`, which the component's definition says; the component whose
|
|
40
|
+
* definition gives the values their meaning is found in a document with
|
|
41
|
+
* `propertyValueComponents`. The operation is
|
|
42
|
+
* read as given, so a field of the wrong type is skipped rather than refused;
|
|
43
|
+
* applying the operation refuses it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function operationReferences(operation: DocumentOperation): DocumentPartReference[];
|
|
46
|
+
/**
|
|
47
|
+
* The theme, when `operation` patches or replaces a node that is a text or code
|
|
48
|
+
* node, as the operation says (`node.replace`) or else as `document` has it: its
|
|
49
|
+
* rendering always goes through the theme, through the styles it names or, for
|
|
50
|
+
* runs and code without a style ID, the theme's default text or code style.
|
|
51
|
+
* `operationReferences` reads the operation alone, and a patch does not say the
|
|
52
|
+
* type of the node it writes.
|
|
53
|
+
*/
|
|
54
|
+
export declare function textStyleThemeReads(document: DesignDocument, operation: DocumentOperation): DocumentPartReference[];
|
|
55
|
+
/**
|
|
56
|
+
* Every component that each instance `operation` writes resolves through in `document` (`resolvedInstanceComponents`),
|
|
57
|
+
* each once: writing an instance reads every component it resolves through. An operation writes an instance when it
|
|
58
|
+
* patches or replaces the node, or inserts it in a subtree (of `node.insert`, `page.insert` or `component.insert`).
|
|
59
|
+
* Its rendering depends on its component, each nested component after overrides, and the components its property
|
|
60
|
+
* values or their defaults select, so call this with the document both before and after the operation: before, for
|
|
61
|
+
* what an override or value it clears had covered, and after, for what it shows now. A written node that `document`
|
|
62
|
+
* does not hold as an instance counts for nothing. Throws the resolver's `ModelError` when an instance there does not
|
|
63
|
+
* resolve.
|
|
64
|
+
*/
|
|
65
|
+
export declare function instanceComponentReads(document: DesignDocument, operation: DocumentOperation): DocumentPartReference[];
|
|
66
|
+
/**
|
|
67
|
+
* The components whose property definitions give meaning to the property values `operation` writes, as `document`
|
|
68
|
+
* has them, each once. An operation writes values when it sets them or clears ones stored (`node.patch`'s `remove`, a
|
|
69
|
+
* `node.replace` without them, an override it removes with its values): for each instance whose `propertyValues` it
|
|
70
|
+
* writes, the component the instance shows (the one the operation writes, else the one `document` stores for it),
|
|
71
|
+
* and for each layer override whose `propertyValues` it writes, that component and the one the nested instance at
|
|
72
|
+
* the override's layer path shows (the override's swap, else the one it shows once the instance resolves in
|
|
73
|
+
* `document`, else the one stored on the nested instance). Each written value is then resolved against that component's property definitions in `document`:
|
|
74
|
+
* a value of an `instance`-kind property is a component ID, so the component it selects counts too, and when the
|
|
75
|
+
* written values leave such a property without a value it had (it is cleared), the property's default, which the
|
|
76
|
+
* instance then shows, counts. `operationReferences` reads the operation alone, so it cannot tell which component a
|
|
77
|
+
* stored instance shows or which values are component IDs. A node `document` does not have counts only through what
|
|
78
|
+
* the operation writes, and an override key that is not a layer path names no nested component.
|
|
79
|
+
*/
|
|
80
|
+
export declare function propertyValueComponents(document: DesignDocument, operation: DocumentOperation): DocumentPartReference[];
|