@moondraft/import 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +34 -0
- package/README.md +36 -2
- package/SOURCE.md +169 -0
- package/dist/adapter/convert.d.ts +122 -0
- package/dist/adapter/convert.js +2302 -0
- package/dist/adapter/figma.d.ts +9 -0
- package/dist/adapter/figma.js +30 -0
- package/dist/adapter/file-components.d.ts +14 -0
- package/dist/adapter/file-components.js +262 -0
- package/dist/adapter/file-resources.d.ts +29 -0
- package/dist/adapter/file-resources.js +562 -0
- package/dist/adapter/index.d.ts +6 -0
- package/dist/adapter/index.js +9 -0
- package/dist/adapter/link.d.ts +45 -0
- package/dist/adapter/link.js +688 -0
- package/dist/adapter/payload.d.ts +31 -0
- package/dist/adapter/payload.js +78 -0
- package/dist/adapter/shapes.d.ts +31 -0
- package/dist/adapter/shapes.js +75 -0
- package/dist/adapter/variables.d.ts +44 -0
- package/dist/adapter/variables.js +103 -0
- package/dist/figma-file.d.ts +38 -0
- package/dist/figma-file.js +97 -0
- package/dist/figma-worker.d.ts +11 -0
- package/dist/figma-worker.js +12 -0
- package/dist/figma.d.ts +26 -0
- package/dist/figma.js +96 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +49 -0
- package/dist/report.d.ts +15 -0
- package/dist/report.js +69 -0
- package/dist/svg.d.ts +33 -0
- package/dist/svg.js +44 -0
- package/dist/syntax.d.ts +8 -0
- package/dist/syntax.js +19 -0
- package/dist/taco/figma-import/clipboard.d.ts +25 -0
- package/dist/taco/figma-import/clipboard.js +87 -0
- package/dist/taco/figma-import/clipboardSize.d.ts +31 -0
- package/dist/taco/figma-import/clipboardSize.js +107 -0
- package/dist/taco/figma-import/container/compression.d.ts +9 -0
- package/dist/taco/figma-import/container/compression.js +174 -0
- package/dist/taco/figma-import/container/error.d.ts +15 -0
- package/dist/taco/figma-import/container/error.js +19 -0
- package/dist/taco/figma-import/container/kiwiContainer.d.ts +38 -0
- package/dist/taco/figma-import/container/kiwiContainer.js +61 -0
- package/dist/taco/figma-import/container/limits.d.ts +22 -0
- package/dist/taco/figma-import/container/limits.js +22 -0
- package/dist/taco/figma-import/container/zip.d.ts +14 -0
- package/dist/taco/figma-import/container/zip.js +154 -0
- package/dist/taco/figma-import/figFile.d.ts +34 -0
- package/dist/taco/figma-import/figFile.js +91 -0
- package/dist/taco/figma-import/figFileDocument.d.ts +25 -0
- package/dist/taco/figma-import/figFileDocument.js +100 -0
- package/dist/taco/figma-import/import/blobs.d.ts +10 -0
- package/dist/taco/figma-import/import/blobs.js +23 -0
- package/dist/taco/figma-import/import/carry.d.ts +11 -0
- package/dist/taco/figma-import/import/carry.js +33 -0
- package/dist/taco/figma-import/import/componentProps.d.ts +84 -0
- package/dist/taco/figma-import/import/componentProps.js +313 -0
- package/dist/taco/figma-import/import/componentSets.d.ts +83 -0
- package/dist/taco/figma-import/import/componentSets.js +647 -0
- package/dist/taco/figma-import/import/converters/effects.d.ts +31 -0
- package/dist/taco/figma-import/import/converters/effects.js +127 -0
- package/dist/taco/figma-import/import/converters/ellipse.d.ts +7 -0
- package/dist/taco/figma-import/import/converters/ellipse.js +54 -0
- package/dist/taco/figma-import/import/converters/frame.d.ts +21 -0
- package/dist/taco/figma-import/import/converters/frame.js +55 -0
- package/dist/taco/figma-import/import/converters/gradient.d.ts +72 -0
- package/dist/taco/figma-import/import/converters/gradient.js +106 -0
- package/dist/taco/figma-import/import/converters/group.d.ts +21 -0
- package/dist/taco/figma-import/import/converters/group.js +39 -0
- package/dist/taco/figma-import/import/converters/image.d.ts +13 -0
- package/dist/taco/figma-import/import/converters/image.js +83 -0
- package/dist/taco/figma-import/import/converters/layout.d.ts +34 -0
- package/dist/taco/figma-import/import/converters/layout.js +168 -0
- package/dist/taco/figma-import/import/converters/line.d.ts +11 -0
- package/dist/taco/figma-import/import/converters/line.js +40 -0
- package/dist/taco/figma-import/import/converters/rectangle.d.ts +3 -0
- package/dist/taco/figma-import/import/converters/rectangle.js +11 -0
- package/dist/taco/figma-import/import/converters/section.d.ts +9 -0
- package/dist/taco/figma-import/import/converters/section.js +35 -0
- package/dist/taco/figma-import/import/converters/shared.d.ts +68 -0
- package/dist/taco/figma-import/import/converters/shared.js +362 -0
- package/dist/taco/figma-import/import/converters/text.d.ts +41 -0
- package/dist/taco/figma-import/import/converters/text.js +576 -0
- package/dist/taco/figma-import/import/converters/vector.d.ts +84 -0
- package/dist/taco/figma-import/import/converters/vector.js +468 -0
- package/dist/taco/figma-import/import/converters/vectorNetwork.d.ts +98 -0
- package/dist/taco/figma-import/import/converters/vectorNetwork.js +385 -0
- package/dist/taco/figma-import/import/fields.d.ts +15 -0
- package/dist/taco/figma-import/import/fields.js +29 -0
- package/dist/taco/figma-import/import/instances.d.ts +163 -0
- package/dist/taco/figma-import/import/instances.js +1323 -0
- package/dist/taco/figma-import/import/nestingCycles.d.ts +86 -0
- package/dist/taco/figma-import/import/nestingCycles.js +488 -0
- package/dist/taco/figma-import/import/slots.d.ts +56 -0
- package/dist/taco/figma-import/import/slots.js +96 -0
- package/dist/taco/figma-import/import/styles.d.ts +46 -0
- package/dist/taco/figma-import/import/styles.js +42 -0
- package/dist/taco/figma-import/import/tree.d.ts +66 -0
- package/dist/taco/figma-import/import/tree.js +194 -0
- package/dist/taco/figma-import/import/types.d.ts +232 -0
- package/dist/taco/figma-import/import/types.js +33 -0
- package/dist/taco/figma-import/import/variables.d.ts +136 -0
- package/dist/taco/figma-import/import/variables.js +762 -0
- package/dist/taco/figma-import/import/variantTrees.d.ts +20 -0
- package/dist/taco/figma-import/import/variantTrees.js +480 -0
- package/dist/taco/figma-import/import/walk.d.ts +159 -0
- package/dist/taco/figma-import/import/walk.js +1297 -0
- package/dist/taco/figma-import/index.d.ts +22 -0
- package/dist/taco/figma-import/index.js +13 -0
- package/dist/taco/figma-import/kiwi/byteReader.d.ts +37 -0
- package/dist/taco/figma-import/kiwi/byteReader.js +151 -0
- package/dist/taco/figma-import/kiwi/error.d.ts +14 -0
- package/dist/taco/figma-import/kiwi/error.js +29 -0
- package/dist/taco/figma-import/kiwi/limits.d.ts +18 -0
- package/dist/taco/figma-import/kiwi/limits.js +18 -0
- package/dist/taco/figma-import/kiwi/message.d.ts +10 -0
- package/dist/taco/figma-import/kiwi/message.js +145 -0
- package/dist/taco/figma-import/kiwi/schema.d.ts +42 -0
- package/dist/taco/figma-import/kiwi/schema.js +206 -0
- package/dist/taco/figma-import/kiwi/types.d.ts +46 -0
- package/dist/taco/figma-import/kiwi/types.js +18 -0
- package/dist/taco/model/agent-hidden-fields.d.ts +20 -0
- package/dist/taco/model/agent-hidden-fields.js +29 -0
- package/dist/taco/model/asset-users.d.ts +23 -0
- package/dist/taco/model/asset-users.js +128 -0
- package/dist/taco/model/auto-layout-lines.d.ts +32 -0
- package/dist/taco/model/auto-layout-lines.js +70 -0
- package/dist/taco/model/codec.d.ts +444 -0
- package/dist/taco/model/codec.js +5635 -0
- package/dist/taco/model/color.d.ts +11 -0
- package/dist/taco/model/color.js +61 -0
- package/dist/taco/model/comment-operations.d.ts +102 -0
- package/dist/taco/model/comment-operations.js +227 -0
- package/dist/taco/model/component-evaluation.d.ts +94 -0
- package/dist/taco/model/component-evaluation.js +548 -0
- package/dist/taco/model/component-expressions.d.ts +242 -0
- package/dist/taco/model/component-expressions.js +1082 -0
- package/dist/taco/model/component-properties.d.ts +111 -0
- package/dist/taco/model/component-properties.js +339 -0
- package/dist/taco/model/component-samples.d.ts +83 -0
- package/dist/taco/model/component-samples.js +290 -0
- package/dist/taco/model/component-validity.d.ts +85 -0
- package/dist/taco/model/component-validity.js +397 -0
- package/dist/taco/model/components.d.ts +155 -0
- package/dist/taco/model/components.js +505 -0
- package/dist/taco/model/connector-ends.d.ts +20 -0
- package/dist/taco/model/connector-ends.js +188 -0
- package/dist/taco/model/connector-geometry.d.ts +74 -0
- package/dist/taco/model/connector-geometry.js +293 -0
- package/dist/taco/model/corner-radii.d.ts +26 -0
- package/dist/taco/model/corner-radii.js +47 -0
- package/dist/taco/model/derivations.d.ts +81 -0
- package/dist/taco/model/derivations.js +151 -0
- package/dist/taco/model/export-settings.d.ts +53 -0
- package/dist/taco/model/export-settings.js +156 -0
- package/dist/taco/model/expressions/ast.d.ts +153 -0
- package/dist/taco/model/expressions/ast.js +6 -0
- package/dist/taco/model/expressions/cache.d.ts +23 -0
- package/dist/taco/model/expressions/cache.js +43 -0
- package/dist/taco/model/expressions/check.d.ts +72 -0
- package/dist/taco/model/expressions/check.js +517 -0
- package/dist/taco/model/expressions/completion.d.ts +61 -0
- package/dist/taco/model/expressions/completion.js +421 -0
- package/dist/taco/model/expressions/evaluate.d.ts +32 -0
- package/dist/taco/model/expressions/evaluate.js +519 -0
- package/dist/taco/model/expressions/forms.d.ts +84 -0
- package/dist/taco/model/expressions/forms.js +200 -0
- package/dist/taco/model/expressions/index.d.ts +14 -0
- package/dist/taco/model/expressions/index.js +17 -0
- package/dist/taco/model/expressions/lexer.d.ts +42 -0
- package/dist/taco/model/expressions/lexer.js +213 -0
- package/dist/taco/model/expressions/library.d.ts +33 -0
- package/dist/taco/model/expressions/library.js +117 -0
- package/dist/taco/model/expressions/names.d.ts +43 -0
- package/dist/taco/model/expressions/names.js +99 -0
- package/dist/taco/model/expressions/parser.d.ts +15 -0
- package/dist/taco/model/expressions/parser.js +438 -0
- package/dist/taco/model/expressions/rename.d.ts +34 -0
- package/dist/taco/model/expressions/rename.js +46 -0
- package/dist/taco/model/expressions/source.d.ts +15 -0
- package/dist/taco/model/expressions/source.js +161 -0
- package/dist/taco/model/expressions/types.d.ts +119 -0
- package/dist/taco/model/expressions/types.js +102 -0
- package/dist/taco/model/expressions/values.d.ts +97 -0
- package/dist/taco/model/expressions/values.js +160 -0
- package/dist/taco/model/geometry-limits.d.ts +16 -0
- package/dist/taco/model/geometry-limits.js +67 -0
- package/dist/taco/model/geometry.d.ts +47 -0
- package/dist/taco/model/geometry.js +193 -0
- package/dist/taco/model/group-bounds.d.ts +38 -0
- package/dist/taco/model/group-bounds.js +144 -0
- package/dist/taco/model/id-table.d.ts +37 -0
- package/dist/taco/model/id-table.js +80 -0
- package/dist/taco/model/index.d.ts +25 -0
- package/dist/taco/model/index.js +27 -0
- package/dist/taco/model/instance-resolver.d.ts +372 -0
- package/dist/taco/model/instance-resolver.js +1748 -0
- package/dist/taco/model/layer-syntax.d.ts +340 -0
- package/dist/taco/model/layer-syntax.js +3506 -0
- package/dist/taco/model/layout/constraints.d.ts +84 -0
- package/dist/taco/model/layout/constraints.js +445 -0
- package/dist/taco/model/layout/frame-layout.d.ts +46 -0
- package/dist/taco/model/layout/frame-layout.js +618 -0
- package/dist/taco/model/layout/node-sizing.d.ts +163 -0
- package/dist/taco/model/layout/node-sizing.js +486 -0
- package/dist/taco/model/legacy-connector-caps.d.ts +15 -0
- package/dist/taco/model/legacy-connector-caps.js +70 -0
- package/dist/taco/model/linear-call.d.ts +48 -0
- package/dist/taco/model/linear-call.js +58 -0
- package/dist/taco/model/new-nodes.d.ts +145 -0
- package/dist/taco/model/new-nodes.js +277 -0
- package/dist/taco/model/node-builder.d.ts +449 -0
- package/dist/taco/model/node-builder.js +2294 -0
- package/dist/taco/model/node-table-watch.d.ts +36 -0
- package/dist/taco/model/node-table-watch.js +63 -0
- package/dist/taco/model/node-transform.d.ts +39 -0
- package/dist/taco/model/node-transform.js +79 -0
- package/dist/taco/model/node-users-index.d.ts +10 -0
- package/dist/taco/model/node-users-index.js +82 -0
- package/dist/taco/model/operation-references.d.ts +80 -0
- package/dist/taco/model/operation-references.js +399 -0
- package/dist/taco/model/operations.d.ts +610 -0
- package/dist/taco/model/operations.js +2882 -0
- package/dist/taco/model/overlay-table.d.ts +71 -0
- package/dist/taco/model/overlay-table.js +171 -0
- package/dist/taco/model/override-remap.d.ts +69 -0
- package/dist/taco/model/override-remap.js +230 -0
- package/dist/taco/model/parent-table.d.ts +53 -0
- package/dist/taco/model/parent-table.js +193 -0
- package/dist/taco/model/problem-collector.d.ts +27 -0
- package/dist/taco/model/problem-collector.js +101 -0
- package/dist/taco/model/sha256.d.ts +10 -0
- package/dist/taco/model/sha256.js +74 -0
- package/dist/taco/model/shape-geometry.d.ts +96 -0
- package/dist/taco/model/shape-geometry.js +368 -0
- package/dist/taco/model/shared-node-table.d.ts +97 -0
- package/dist/taco/model/shared-node-table.js +546 -0
- package/dist/taco/model/slots.d.ts +113 -0
- package/dist/taco/model/slots.js +281 -0
- package/dist/taco/model/stroke-settings.d.ts +37 -0
- package/dist/taco/model/stroke-settings.js +90 -0
- package/dist/taco/model/svg-path-import.d.ts +89 -0
- package/dist/taco/model/svg-path-import.js +219 -0
- package/dist/taco/model/text-measurement.d.ts +142 -0
- package/dist/taco/model/text-measurement.js +846 -0
- package/dist/taco/model/text-reads.d.ts +66 -0
- package/dist/taco/model/text-reads.js +128 -0
- package/dist/taco/model/text-sizer.d.ts +358 -0
- package/dist/taco/model/text-sizer.js +996 -0
- package/dist/taco/model/theme-users.d.ts +59 -0
- package/dist/taco/model/theme-users.js +312 -0
- package/dist/taco/model/thumbnail.d.ts +15 -0
- package/dist/taco/model/thumbnail.js +34 -0
- package/dist/taco/model/types.d.ts +2347 -0
- package/dist/taco/model/types.js +366 -0
- package/dist/taco/model/unknown-property.d.ts +5 -0
- package/dist/taco/model/unknown-property.js +7 -0
- package/dist/taco/model/validated-documents.d.ts +22 -0
- package/dist/taco/model/validated-documents.js +22 -0
- package/dist/taco/model/variable-modes.d.ts +61 -0
- package/dist/taco/model/variable-modes.js +438 -0
- package/dist/taco/model/variable-references.d.ts +54 -0
- package/dist/taco/model/variable-references.js +183 -0
- package/dist/taco/model/variables.d.ts +24 -0
- package/dist/taco/model/variables.js +151 -0
- package/dist/taco/model/vector-network.d.ts +34 -0
- package/dist/taco/model/vector-network.js +411 -0
- package/dist/taco/svg-import/import-svg.d.ts +36 -0
- package/dist/taco/svg-import/import-svg.js +729 -0
- package/dist/taco/svg-import/index.d.ts +3 -0
- package/dist/taco/svg-import/index.js +3 -0
- package/dist/taco/svg-import/limits/limits.d.ts +79 -0
- package/dist/taco/svg-import/limits/limits.js +160 -0
- package/dist/taco/svg-import/paint/gradients.d.ts +64 -0
- package/dist/taco/svg-import/paint/gradients.js +429 -0
- package/dist/taco/svg-import/paint/paint.d.ts +32 -0
- package/dist/taco/svg-import/paint/paint.js +162 -0
- package/dist/taco/svg-import/paths/paths.d.ts +58 -0
- package/dist/taco/svg-import/paths/paths.js +205 -0
- package/dist/taco/svg-import/public-types.d.ts +279 -0
- package/dist/taco/svg-import/public-types.js +56 -0
- package/dist/taco/svg-import/report/report.d.ts +44 -0
- package/dist/taco/svg-import/report/report.js +79 -0
- package/dist/taco/svg-import/reuse/reuse.d.ts +99 -0
- package/dist/taco/svg-import/reuse/reuse.js +840 -0
- package/dist/taco/svg-import/shapes/shapes.d.ts +35 -0
- package/dist/taco/svg-import/shapes/shapes.js +386 -0
- package/dist/taco/svg-import/structure/effects.d.ts +26 -0
- package/dist/taco/svg-import/structure/effects.js +618 -0
- package/dist/taco/svg-import/structure/image.d.ts +24 -0
- package/dist/taco/svg-import/structure/image.js +495 -0
- package/dist/taco/svg-import/structure/walk.d.ts +85 -0
- package/dist/taco/svg-import/structure/walk.js +544 -0
- package/dist/taco/svg-import/style/color.d.ts +40 -0
- package/dist/taco/svg-import/style/color.js +275 -0
- package/dist/taco/svg-import/style/computed.d.ts +214 -0
- package/dist/taco/svg-import/style/computed.js +1534 -0
- package/dist/taco/svg-import/style/css.d.ts +127 -0
- package/dist/taco/svg-import/style/css.js +541 -0
- package/dist/taco/svg-import/style/media.d.ts +25 -0
- package/dist/taco/svg-import/style/media.js +307 -0
- package/dist/taco/svg-import/style/properties.d.ts +43 -0
- package/dist/taco/svg-import/style/properties.js +135 -0
- package/dist/taco/svg-import/style/selector-reach.d.ts +30 -0
- package/dist/taco/svg-import/style/selector-reach.js +169 -0
- package/dist/taco/svg-import/style/selector-validity.d.ts +14 -0
- package/dist/taco/svg-import/style/selector-validity.js +307 -0
- package/dist/taco/svg-import/text/text.d.ts +29 -0
- package/dist/taco/svg-import/text/text.js +545 -0
- package/dist/taco/svg-import/transform/matrix.d.ts +111 -0
- package/dist/taco/svg-import/transform/matrix.js +229 -0
- package/dist/taco/svg-import/tree/element-data.d.ts +52 -0
- package/dist/taco/svg-import/tree/element-data.js +155 -0
- package/dist/taco/svg-import/tree/elements.d.ts +36 -0
- package/dist/taco/svg-import/tree/elements.js +121 -0
- package/dist/taco/svg-import/units/length.d.ts +43 -0
- package/dist/taco/svg-import/units/length.js +125 -0
- package/dist/taco/svg-import/units/viewbox.d.ts +35 -0
- package/dist/taco/svg-import/units/viewbox.js +77 -0
- package/package.json +54 -4
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** The path of the element that contains `elementPath`, or null at the root. */
|
|
2
|
+
function parentPath(elementPath) {
|
|
3
|
+
const cut = elementPath.lastIndexOf(" > ");
|
|
4
|
+
return cut === -1 ? null : elementPath.slice(0, cut);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Collects the report of one import. Every element that is not imported
|
|
8
|
+
* exactly appears once per reason, in the order the walk meets it: an
|
|
9
|
+
* element built twice (a component's content and a plain copy of it) adds
|
|
10
|
+
* an identical line only the first time.
|
|
11
|
+
*
|
|
12
|
+
* Each entry also gets the layer it applies to. Most lines are added while
|
|
13
|
+
* their element is built, before its layer exists, so they wait on a stack
|
|
14
|
+
* until the build of an element that keeps a layer ends (`placeSince`):
|
|
15
|
+
* the element's own layer, or the nearest one kept around it. Lines added
|
|
16
|
+
* before the walk (style and root lines) are placed at the end by their
|
|
17
|
+
* path (`placeRest`).
|
|
18
|
+
*
|
|
19
|
+
* The dedupe key stays the element and its reason, without the layer: the
|
|
20
|
+
* second build of an element is a component's content shown again or a
|
|
21
|
+
* plain copy, and listing it again would count one problem twice. Its line
|
|
22
|
+
* keeps the layer of the first occurrence.
|
|
23
|
+
*/
|
|
24
|
+
export class ReportBuilder {
|
|
25
|
+
#entries = [];
|
|
26
|
+
#seen = new Set();
|
|
27
|
+
/** The entries that have no layer yet, oldest first. */
|
|
28
|
+
#unplaced = [];
|
|
29
|
+
/** The layer kept for each element path, from its first build. */
|
|
30
|
+
#layers = new Map();
|
|
31
|
+
/** Adds one entry, unless the same entry is already in the report. */
|
|
32
|
+
add(elementPath, element, kind, reason, note) {
|
|
33
|
+
const key = JSON.stringify([elementPath, element, kind, reason]);
|
|
34
|
+
if (this.#seen.has(key))
|
|
35
|
+
return;
|
|
36
|
+
this.#seen.add(key);
|
|
37
|
+
const entry = {
|
|
38
|
+
elementPath,
|
|
39
|
+
element,
|
|
40
|
+
reason,
|
|
41
|
+
kind,
|
|
42
|
+
what: note.what,
|
|
43
|
+
kept: note.kept,
|
|
44
|
+
...(note.missingFont === undefined ? {} : { missingFont: note.missingFont }),
|
|
45
|
+
};
|
|
46
|
+
this.#entries.push(entry);
|
|
47
|
+
this.#unplaced.push(entry);
|
|
48
|
+
}
|
|
49
|
+
/** A mark to pass to `placeSince` when the current element's build ends. */
|
|
50
|
+
mark() {
|
|
51
|
+
return this.#unplaced.length;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Places every entry added since `mark` that has no layer yet on the layer
|
|
55
|
+
* `nodeId`, which the element at `elementPath` became.
|
|
56
|
+
*/
|
|
57
|
+
placeSince(mark, elementPath, nodeId) {
|
|
58
|
+
if (!this.#layers.has(elementPath))
|
|
59
|
+
this.#layers.set(elementPath, nodeId);
|
|
60
|
+
for (const entry of this.#unplaced.splice(mark))
|
|
61
|
+
entry.nodeId = nodeId;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Places the entries still without a layer: on the layer of their element
|
|
65
|
+
* or of its nearest ancestor that has one, else on the root layer.
|
|
66
|
+
*/
|
|
67
|
+
placeRest(rootId) {
|
|
68
|
+
for (const entry of this.#unplaced.splice(0)) {
|
|
69
|
+
let path = entry.elementPath;
|
|
70
|
+
while (path !== null && !this.#layers.has(path))
|
|
71
|
+
path = parentPath(path);
|
|
72
|
+
entry.nodeId = path === null ? rootId : this.#layers.get(path);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** The collected entries, in document order. */
|
|
76
|
+
entries() {
|
|
77
|
+
return this.#entries;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type Rect } from "../../model/index.ts";
|
|
2
|
+
import type { SvgElementLike, SvgImportComponent } from "../public-types.ts";
|
|
3
|
+
import { type ComputedStyle } from "../style/computed.ts";
|
|
4
|
+
import { type Matrix } from "../transform/matrix.ts";
|
|
5
|
+
import { type PaintContext } from "../paint/paint.ts";
|
|
6
|
+
import type { BuiltElement, WalkContext } from "../structure/walk.ts";
|
|
7
|
+
/** What the reuse module needs of the import beyond the walk's own context. */
|
|
8
|
+
export interface ReuseContext extends PaintContext {
|
|
9
|
+
readonly idSource: () => string;
|
|
10
|
+
readonly limits: {
|
|
11
|
+
countReferenceStep: () => void;
|
|
12
|
+
countPathNumbers: (count: number) => void;
|
|
13
|
+
countUseCopy: () => void;
|
|
14
|
+
countComponent: () => void;
|
|
15
|
+
countInstance: () => void;
|
|
16
|
+
countStyleWork: (units: number) => void;
|
|
17
|
+
};
|
|
18
|
+
readonly components: SvgImportComponent[];
|
|
19
|
+
readonly reuse: ReusePlan;
|
|
20
|
+
readonly componentRegistry: ComponentRegistry;
|
|
21
|
+
/** Set while a component's tree or a plain copy is built: the in-place instance hook stays off there. */
|
|
22
|
+
readonly buildingComponentTree?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Set while an occurrence is compared with its component: the build makes
|
|
25
|
+
* throwaway ids and adds no report lines, images, components or cap counts.
|
|
26
|
+
*/
|
|
27
|
+
readonly probing: boolean;
|
|
28
|
+
readonly viewport: {
|
|
29
|
+
readonly width: number;
|
|
30
|
+
readonly height: number;
|
|
31
|
+
} | null;
|
|
32
|
+
}
|
|
33
|
+
/** The pre-pass's decisions: which `<use>` targets become components. */
|
|
34
|
+
export interface ReusePlan {
|
|
35
|
+
/** Per target id: component, or an inline copy. */
|
|
36
|
+
readonly decisions: ReadonlyMap<string, "component" | "copy">;
|
|
37
|
+
/** The element each decided id names, for the walk's in-place check. */
|
|
38
|
+
readonly targets: ReadonlyMap<string, SvgElementLike>;
|
|
39
|
+
/**
|
|
40
|
+
* Each id on a `<use>` cycle, with the refusal message naming the cycle.
|
|
41
|
+
* The import is refused when a use is built that reaches one of them, so
|
|
42
|
+
* a cycle confined to `<defs>` that nothing draws leaves the rest importing.
|
|
43
|
+
*/
|
|
44
|
+
readonly cycles: ReadonlyMap<string, string>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The pre-pass over the `<use>` graph: counts uses per target, decides
|
|
48
|
+
* components, and records cycles with the ids named. Runs before any layer
|
|
49
|
+
* is built. A use that is built and reaches a cycle refuses the whole
|
|
50
|
+
* import, so a cycle never leaves anything half imported; one that nothing
|
|
51
|
+
* draws or references is never reached.
|
|
52
|
+
*/
|
|
53
|
+
export declare function planReuse(root: SvgElementLike, ids: ReadonlyMap<string, SvgElementLike>, limits: {
|
|
54
|
+
readonly countReferenceStep: () => void;
|
|
55
|
+
}): ReusePlan;
|
|
56
|
+
/** The built component plus what later occurrences are compared and placed against. */
|
|
57
|
+
interface BuiltComponent {
|
|
58
|
+
readonly component: SvgImportComponent;
|
|
59
|
+
/** The style the shipped tree was built with; an occurrence with the same style needs no probe. */
|
|
60
|
+
readonly baseStyle: ComputedStyle;
|
|
61
|
+
/** The content's bounds in the target's user space; the component root is this size. */
|
|
62
|
+
readonly naturalBounds: Rect;
|
|
63
|
+
/** A `<symbol>`'s viewport size; with a viewBox it is the size the viewBox was fitted into. */
|
|
64
|
+
readonly symbolSize: {
|
|
65
|
+
readonly width: number;
|
|
66
|
+
readonly height: number;
|
|
67
|
+
readonly scales: boolean;
|
|
68
|
+
} | null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A context that builds without side effects, for comparing an occurrence
|
|
72
|
+
* with the shipped component: throwaway ids, no report lines, no new
|
|
73
|
+
* images or components, and no cap counts of its own beyond the import-wide
|
|
74
|
+
* work (reference steps, path data, element builds and style work) the probe
|
|
75
|
+
* really does.
|
|
76
|
+
*/
|
|
77
|
+
export declare function probeContext(ctx: WalkContext): WalkContext;
|
|
78
|
+
/** The component registry of one document: builds each component once, at its first occurrence. */
|
|
79
|
+
export declare class ComponentRegistry {
|
|
80
|
+
#private;
|
|
81
|
+
/**
|
|
82
|
+
* The component for one target, building it on first use. Under a probe
|
|
83
|
+
* context a missing component is built for comparison only and never
|
|
84
|
+
* registered.
|
|
85
|
+
*/
|
|
86
|
+
getOrBuild(targetId: string, target: SvgElementLike, baseStyle: ComputedStyle, ctx: WalkContext, sizeUse: SvgElementLike | null): BuiltComponent;
|
|
87
|
+
}
|
|
88
|
+
/** Handles one `<use>` element: an instance, an inline copy, or a report. */
|
|
89
|
+
export declare function useLayer(element: SvgElementLike, computed: ComputedStyle, matrix: Matrix, elementPath: string, ctx: WalkContext): BuiltElement;
|
|
90
|
+
/**
|
|
91
|
+
* Handles an element that is a component target drawn in place: it becomes
|
|
92
|
+
* an instance too, so every occurrence is the same kind of layer. The
|
|
93
|
+
* component already holds the element's own transform, opacity, clip, mask
|
|
94
|
+
* and filter, so the instance is placed with the parent's matrix and adds
|
|
95
|
+
* none of them again. Returns null when the in-place occurrence cannot be an
|
|
96
|
+
* instance; the reason is reported and the caller builds the element normally.
|
|
97
|
+
*/
|
|
98
|
+
export declare function drawnTargetLayer(element: SvgElementLike, targetId: string, parentStyle: ComputedStyle, parentMatrix: Matrix, elementPath: string, ctx: WalkContext): BuiltElement | null;
|
|
99
|
+
export {};
|