@open-pencil/scene-graph 0.17.0 → 0.18.0-beta.1
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/dist/behaviours/index.d.ts +3 -2
- package/dist/behaviours/index.js +2 -1
- package/dist/behaviours/kinds.d.ts.map +1 -1
- package/dist/behaviours/kinds.js +15 -8
- package/dist/behaviours/kinds.js.map +1 -1
- package/dist/behaviours/model.d.ts +2 -2
- package/dist/behaviours/model.d.ts.map +1 -1
- package/dist/behaviours/model.js.map +1 -1
- package/dist/behaviours/schema.d.ts +136 -1
- package/dist/behaviours/schema.d.ts.map +1 -1
- package/dist/behaviours/schema.js +17 -2
- package/dist/behaviours/schema.js.map +1 -1
- package/dist/behaviours/spec.d.ts.map +1 -1
- package/dist/behaviours/spec.js +4 -0
- package/dist/behaviours/spec.js.map +1 -1
- package/dist/behaviours/transition.d.ts +23 -0
- package/dist/behaviours/transition.d.ts.map +1 -0
- package/dist/behaviours/transition.js +36 -0
- package/dist/behaviours/transition.js.map +1 -0
- package/dist/checkpoint.d.ts.map +1 -1
- package/dist/checkpoint.js +2 -0
- package/dist/checkpoint.js.map +1 -1
- package/dist/color/index.d.ts +12 -9
- package/dist/color/index.d.ts.map +1 -1
- package/dist/color/index.js +15 -25
- package/dist/color/index.js.map +1 -1
- package/dist/color/management.d.ts +51 -23
- package/dist/color/management.d.ts.map +1 -1
- package/dist/color/management.js +154 -149
- package/dist/color/management.js.map +1 -1
- package/dist/color/okhcl.d.ts +28 -10
- package/dist/color/okhcl.d.ts.map +1 -1
- package/dist/color/okhcl.js +56 -40
- package/dist/color/okhcl.js.map +1 -1
- package/dist/color/schema.d.ts +6 -1
- package/dist/color/schema.d.ts.map +1 -1
- package/dist/color/schema.js +10 -1
- package/dist/color/schema.js.map +1 -1
- package/dist/constraints.d.ts.map +1 -1
- package/dist/constraints.js +2 -1
- package/dist/constraints.js.map +1 -1
- package/dist/copy.d.ts +7 -1
- package/dist/copy.d.ts.map +1 -1
- package/dist/copy.js +22 -1
- package/dist/copy.js.map +1 -1
- package/dist/corners.d.ts +3 -1
- package/dist/corners.d.ts.map +1 -1
- package/dist/corners.js +3 -1
- package/dist/corners.js.map +1 -1
- package/dist/css/grid.js +1 -1
- package/dist/css/index.d.ts +2 -1
- package/dist/css/index.js +3 -2
- package/dist/css/motion.d.ts +12 -0
- package/dist/css/motion.d.ts.map +1 -0
- package/dist/css/motion.js +60 -0
- package/dist/css/motion.js.map +1 -0
- package/dist/css/shadows.d.ts +4 -3
- package/dist/css/shadows.d.ts.map +1 -1
- package/dist/css/shadows.js +7 -6
- package/dist/css/shadows.js.map +1 -1
- package/dist/css/values.d.ts +3 -2
- package/dist/css/values.d.ts.map +1 -1
- package/dist/css/values.js +4 -4
- package/dist/css/values.js.map +1 -1
- package/dist/fields/index.d.ts +2 -2
- package/dist/fields/index.js +2 -2
- package/dist/fields/layout.d.ts +3 -1
- package/dist/fields/layout.d.ts.map +1 -1
- package/dist/fields/layout.js +9 -1
- package/dist/fields/layout.js.map +1 -1
- package/dist/figjam/palette.js +1 -1
- package/dist/font-style.d.ts.map +1 -1
- package/dist/font-style.js +7 -3
- package/dist/font-style.js.map +1 -1
- package/dist/generated/index.d.ts +6 -2
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +14 -4
- package/dist/generated/index.js.map +1 -1
- package/dist/geometry.d.ts +6 -1
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +10 -2
- package/dist/geometry.js.map +1 -1
- package/dist/graph.d.ts +29 -4
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +59 -9
- package/dist/graph.js.map +1 -1
- package/dist/group-bounds.d.ts +5 -2
- package/dist/group-bounds.d.ts.map +1 -1
- package/dist/group-bounds.js +38 -8
- package/dist/group-bounds.js.map +1 -1
- package/dist/hit-test.d.ts.map +1 -1
- package/dist/hit-test.js +19 -8
- package/dist/hit-test.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/instances/content-size.js +1 -1
- package/dist/instances/fields.d.ts +2 -2
- package/dist/instances/fields.d.ts.map +1 -1
- package/dist/instances/fields.js +2 -0
- package/dist/instances/fields.js.map +1 -1
- package/dist/instances/index.d.ts.map +1 -1
- package/dist/instances/index.js +50 -11
- package/dist/instances/index.js.map +1 -1
- package/dist/instances/sync.js +67 -7
- package/dist/instances/sync.js.map +1 -1
- package/dist/layout/flow.d.ts +16 -0
- package/dist/layout/flow.d.ts.map +1 -0
- package/dist/layout/flow.js +34 -0
- package/dist/layout/flow.js.map +1 -0
- package/dist/layout/index.d.ts +4 -3
- package/dist/layout/index.js +4 -3
- package/dist/layout/keywords.d.ts.map +1 -1
- package/dist/layout/keywords.js +7 -1
- package/dist/layout/keywords.js.map +1 -1
- package/dist/layout/sizing.d.ts +9 -1
- package/dist/layout/sizing.d.ts.map +1 -1
- package/dist/layout/sizing.js +17 -1
- package/dist/layout/sizing.js.map +1 -1
- package/dist/layout/spacing.d.ts +7 -1
- package/dist/layout/spacing.d.ts.map +1 -1
- package/dist/layout/spacing.js +10 -1
- package/dist/layout/spacing.js.map +1 -1
- package/dist/mesh/geometry.d.ts +83 -0
- package/dist/mesh/geometry.d.ts.map +1 -0
- package/dist/mesh/geometry.js +441 -0
- package/dist/mesh/geometry.js.map +1 -0
- package/dist/mesh/index.d.ts +4 -0
- package/dist/mesh/index.js +4 -0
- package/dist/mesh/model.d.ts +28 -0
- package/dist/mesh/model.d.ts.map +1 -0
- package/dist/mesh/model.js +40 -0
- package/dist/mesh/model.js.map +1 -0
- package/dist/mesh/schema.d.ts +191 -0
- package/dist/mesh/schema.d.ts.map +1 -0
- package/dist/mesh/schema.js +56 -0
- package/dist/mesh/schema.js.map +1 -0
- package/dist/mutation-impact.d.ts +2 -0
- package/dist/mutation-impact.d.ts.map +1 -1
- package/dist/mutation-impact.js +18 -7
- package/dist/mutation-impact.js.map +1 -1
- package/dist/node-defaults.d.ts +3 -1
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +22 -6
- package/dist/node-defaults.js.map +1 -1
- package/dist/paints/index.d.ts +5 -3
- package/dist/paints/index.js +5 -3
- package/dist/paints/pattern.d.ts +5 -1
- package/dist/paints/pattern.d.ts.map +1 -1
- package/dist/paints/pattern.js +33 -1
- package/dist/paints/pattern.js.map +1 -1
- package/dist/paints/shows.d.ts +4 -1
- package/dist/paints/shows.d.ts.map +1 -1
- package/dist/paints/shows.js +8 -1
- package/dist/paints/shows.js.map +1 -1
- package/dist/paints/solid.d.ts +11 -0
- package/dist/paints/solid.d.ts.map +1 -0
- package/dist/paints/solid.js +18 -0
- package/dist/paints/solid.js.map +1 -0
- package/dist/paints/stills.d.ts +74 -0
- package/dist/paints/stills.d.ts.map +1 -0
- package/dist/paints/stills.js +113 -0
- package/dist/paints/stills.js.map +1 -0
- package/dist/plugin-data/field.d.ts.map +1 -1
- package/dist/plugin-data/field.js +2 -0
- package/dist/plugin-data/field.js.map +1 -1
- package/dist/plugin-data/fields.d.ts +67 -0
- package/dist/plugin-data/fields.d.ts.map +1 -1
- package/dist/plugin-data/fields.js +12 -7
- package/dist/plugin-data/fields.js.map +1 -1
- package/dist/resize.d.ts +10 -3
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +34 -3
- package/dist/resize.js.map +1 -1
- package/dist/scaling/index.d.ts +2 -2
- package/dist/scaling/index.js +2 -2
- package/dist/scaling/node.d.ts +2 -1
- package/dist/scaling/node.d.ts.map +1 -1
- package/dist/scaling/node.js +27 -7
- package/dist/scaling/node.js.map +1 -1
- package/dist/shaders/index.d.ts +2 -3
- package/dist/shaders/index.js +2 -3
- package/dist/shaders/model.d.ts +3 -11
- package/dist/shaders/model.d.ts.map +1 -1
- package/dist/shaders/model.js +13 -36
- package/dist/shaders/model.js.map +1 -1
- package/dist/shaders/schema.d.ts +1 -1
- package/dist/shaders/schema.js +1 -1
- package/dist/shaders/schema.js.map +1 -1
- package/dist/shape-with-text/document.js +276 -0
- package/dist/shape-with-text/document.js.map +1 -0
- package/dist/shape-with-text/geometry.d.ts +13 -1
- package/dist/shape-with-text/geometry.d.ts.map +1 -1
- package/dist/shape-with-text/geometry.js +103 -41
- package/dist/shape-with-text/geometry.js.map +1 -1
- package/dist/shape-with-text/index.d.ts +2 -2
- package/dist/shape-with-text/index.js +2 -2
- package/dist/shared-style-index.d.ts +21 -0
- package/dist/shared-style-index.d.ts.map +1 -0
- package/dist/shared-style-index.js +72 -0
- package/dist/shared-style-index.js.map +1 -0
- package/dist/shared-styles.d.ts +3 -3
- package/dist/shared-styles.d.ts.map +1 -1
- package/dist/shared-styles.js +16 -7
- package/dist/shared-styles.js.map +1 -1
- package/dist/slides/drop.d.ts +32 -0
- package/dist/slides/drop.d.ts.map +1 -0
- package/dist/slides/drop.js +81 -0
- package/dist/slides/drop.js.map +1 -0
- package/dist/slides/index.d.ts +56 -0
- package/dist/slides/index.d.ts.map +1 -0
- package/dist/slides/index.js +134 -0
- package/dist/slides/index.js.map +1 -0
- package/dist/slides/motion.d.ts +55 -0
- package/dist/slides/motion.d.ts.map +1 -0
- package/dist/slides/motion.js +142 -0
- package/dist/slides/motion.js.map +1 -0
- package/dist/slides/playback.d.ts +59 -0
- package/dist/slides/playback.d.ts.map +1 -0
- package/dist/slides/playback.js +188 -0
- package/dist/slides/playback.js.map +1 -0
- package/dist/slides/types.d.ts +62 -0
- package/dist/slides/types.d.ts.map +1 -0
- package/dist/slides/types.js +39 -0
- package/dist/slides/types.js.map +1 -0
- package/dist/statuses/workflow.js +1 -1
- package/dist/text/direction.d.ts +6 -3
- package/dist/text/direction.d.ts.map +1 -1
- package/dist/text/direction.js +12 -12
- package/dist/text/direction.js.map +1 -1
- package/dist/text/index.d.ts +2 -1
- package/dist/text/index.js +3 -2
- package/dist/text/name.d.ts +22 -0
- package/dist/text/name.d.ts.map +1 -0
- package/dist/text/name.js +38 -0
- package/dist/text/name.js.map +1 -0
- package/dist/text/references.d.ts.map +1 -1
- package/dist/text/references.js +1 -2
- package/dist/text/references.js.map +1 -1
- package/dist/thumbnail.d.ts +23 -0
- package/dist/thumbnail.d.ts.map +1 -0
- package/dist/thumbnail.js +47 -0
- package/dist/thumbnail.js.map +1 -0
- package/dist/transfer/apply.d.ts.map +1 -1
- package/dist/transfer/apply.js +14 -3
- package/dist/transfer/apply.js.map +1 -1
- package/dist/transfer/copied.d.ts +6 -1
- package/dist/transfer/copied.d.ts.map +1 -1
- package/dist/transfer/copied.js +2 -2
- package/dist/transfer/copied.js.map +1 -1
- package/dist/transfer/dependencies.d.ts +4 -1
- package/dist/transfer/dependencies.d.ts.map +1 -1
- package/dist/transfer/dependencies.js +10 -1
- package/dist/transfer/dependencies.js.map +1 -1
- package/dist/transfer/history.js +2 -0
- package/dist/transfer/history.js.map +1 -1
- package/dist/transfer/identity.js +18 -3
- package/dist/transfer/identity.js.map +1 -1
- package/dist/transfer/index.d.ts +2 -1
- package/dist/transfer/index.js +4 -3
- package/dist/transfer/library.d.ts +45 -0
- package/dist/transfer/library.d.ts.map +1 -0
- package/dist/transfer/library.js +102 -0
- package/dist/transfer/library.js.map +1 -0
- package/dist/transfer/nodes.d.ts.map +1 -1
- package/dist/transfer/nodes.js +9 -0
- package/dist/transfer/nodes.js.map +1 -1
- package/dist/transfer/plan.d.ts +9 -0
- package/dist/transfer/plan.d.ts.map +1 -1
- package/dist/transfer/plan.js +51 -6
- package/dist/transfer/plan.js.map +1 -1
- package/dist/transfer/remove.js +7 -1
- package/dist/transfer/remove.js.map +1 -1
- package/dist/transfer/validation.js +8 -4
- package/dist/transfer/validation.js.map +1 -1
- package/dist/transfer/variables.d.ts.map +1 -1
- package/dist/transfer/variables.js +2 -1
- package/dist/transfer/variables.js.map +1 -1
- package/dist/types.d.ts +90 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +33 -1
- package/dist/types.js.map +1 -1
- package/dist/variables/bindings.d.ts +11 -6
- package/dist/variables/bindings.d.ts.map +1 -1
- package/dist/variables/bindings.js +162 -38
- package/dist/variables/bindings.js.map +1 -1
- package/dist/variables/easing.d.ts +48 -0
- package/dist/variables/easing.d.ts.map +1 -0
- package/dist/variables/easing.js +321 -0
- package/dist/variables/easing.js.map +1 -0
- package/dist/variables/formula/index.d.ts +4 -2
- package/dist/variables/formula/index.d.ts.map +1 -1
- package/dist/variables/formula/index.js +26 -9
- package/dist/variables/formula/index.js.map +1 -1
- package/dist/variables/formula/parse.js +1 -1
- package/dist/variables/formula/schema.js +1 -1
- package/dist/variables/formula/signatures.d.ts +2 -2
- package/dist/variables/formula/signatures.d.ts.map +1 -1
- package/dist/variables/formula/signatures.js.map +1 -1
- package/dist/variables/formula/tree.d.ts +2 -2
- package/dist/variables/formula/tree.d.ts.map +1 -1
- package/dist/variables/formula/tree.js.map +1 -1
- package/dist/variables/index.d.ts +22 -5
- package/dist/variables/index.d.ts.map +1 -1
- package/dist/variables/index.js +67 -17
- package/dist/variables/index.js.map +1 -1
- package/dist/variables/lookup.js +1 -1
- package/dist/variables/lookup.js.map +1 -1
- package/dist/variables/motion.d.ts +46 -0
- package/dist/variables/motion.d.ts.map +1 -0
- package/dist/variables/motion.js +107 -0
- package/dist/variables/motion.js.map +1 -0
- package/dist/variables/paints.d.ts +10 -2
- package/dist/variables/paints.d.ts.map +1 -1
- package/dist/variables/paints.js +24 -10
- package/dist/variables/paints.js.map +1 -1
- package/dist/variables/resolution.d.ts.map +1 -1
- package/dist/variables/resolution.js +10 -9
- package/dist/variables/resolution.js.map +1 -1
- package/dist/variables/schema.d.ts +59 -1
- package/dist/variables/schema.d.ts.map +1 -1
- package/dist/variables/schema.js +36 -1
- package/dist/variables/schema.js.map +1 -1
- package/dist/variables/style-bindings.d.ts +23 -0
- package/dist/variables/style-bindings.d.ts.map +1 -0
- package/dist/variables/style-bindings.js +83 -0
- package/dist/variables/style-bindings.js.map +1 -0
- package/package.json +21 -2
- package/src/behaviours/index.ts +1 -0
- package/src/behaviours/kinds.ts +5 -1
- package/src/behaviours/model.ts +2 -2
- package/src/behaviours/schema.ts +19 -2
- package/src/behaviours/spec.ts +5 -0
- package/src/behaviours/transition.ts +46 -0
- package/src/checkpoint.ts +2 -0
- package/src/color/index.ts +15 -24
- package/src/color/management.ts +144 -168
- package/src/color/okhcl.ts +62 -43
- package/src/color/schema.ts +13 -0
- package/src/constraints.ts +2 -1
- package/src/copy.ts +29 -0
- package/src/corners.ts +3 -0
- package/src/css/index.ts +1 -0
- package/src/css/motion.ts +51 -0
- package/src/css/shadows.ts +7 -6
- package/src/css/values.ts +7 -3
- package/src/fields/layout.ts +9 -0
- package/src/font-style.ts +8 -3
- package/src/generated/index.ts +15 -3
- package/src/geometry.ts +13 -1
- package/src/graph.ts +72 -9
- package/src/group-bounds.ts +54 -13
- package/src/hit-test.ts +13 -8
- package/src/instances/fields.ts +2 -0
- package/src/instances/index.ts +71 -12
- package/src/instances/sync.ts +93 -11
- package/src/layout/flow.ts +34 -0
- package/src/layout/index.ts +1 -0
- package/src/layout/keywords.ts +7 -1
- package/src/layout/sizing.ts +30 -0
- package/src/layout/spacing.ts +12 -0
- package/src/mesh/geometry.ts +433 -0
- package/src/mesh/index.ts +3 -0
- package/src/mesh/model.ts +50 -0
- package/src/mesh/schema.ts +81 -0
- package/src/mutation-impact.ts +23 -7
- package/src/node-defaults.ts +22 -5
- package/src/paints/index.ts +2 -0
- package/src/paints/pattern.ts +55 -0
- package/src/paints/shows.ts +9 -0
- package/src/paints/solid.ts +10 -0
- package/src/paints/stills.ts +182 -0
- package/src/plugin-data/field.ts +3 -0
- package/src/plugin-data/fields.ts +15 -2
- package/src/resize.ts +32 -20
- package/src/scaling/index.ts +1 -1
- package/src/scaling/node.ts +43 -6
- package/src/shaders/index.ts +0 -1
- package/src/shaders/model.ts +19 -49
- package/src/shaders/schema.ts +1 -1
- package/src/shape-with-text/document.ts +175 -0
- package/src/shape-with-text/geometry.ts +99 -27
- package/src/shared-style-index.ts +106 -0
- package/src/shared-styles.ts +21 -14
- package/src/slides/drop.ts +94 -0
- package/src/slides/index.ts +125 -0
- package/src/slides/motion.ts +169 -0
- package/src/slides/playback.ts +200 -0
- package/src/slides/types.ts +94 -0
- package/src/text/direction.ts +13 -23
- package/src/text/index.ts +1 -0
- package/src/text/name.ts +39 -0
- package/src/text/references.ts +3 -3
- package/src/thumbnail.ts +52 -0
- package/src/transfer/apply.ts +16 -3
- package/src/transfer/copied.ts +7 -2
- package/src/transfer/dependencies.ts +10 -1
- package/src/transfer/history.ts +2 -0
- package/src/transfer/identity.ts +34 -2
- package/src/transfer/index.ts +6 -0
- package/src/transfer/library.ts +153 -0
- package/src/transfer/nodes.ts +20 -0
- package/src/transfer/plan.ts +96 -10
- package/src/transfer/remove.ts +6 -2
- package/src/transfer/validation.ts +15 -7
- package/src/transfer/variables.ts +8 -2
- package/src/types.ts +114 -10
- package/src/variables/bindings.ts +260 -36
- package/src/variables/easing.ts +282 -0
- package/src/variables/formula/index.ts +33 -14
- package/src/variables/formula/signatures.ts +6 -2
- package/src/variables/formula/tree.ts +3 -3
- package/src/variables/index.ts +90 -37
- package/src/variables/lookup.ts +1 -1
- package/src/variables/motion.ts +151 -0
- package/src/variables/paints.ts +29 -7
- package/src/variables/resolution.ts +11 -5
- package/src/variables/schema.ts +41 -0
- package/src/variables/style-bindings.ts +137 -0
- package/dist/shaders/still.d.ts +0 -18
- package/dist/shaders/still.d.ts.map +0 -1
- package/dist/shaders/still.js +0 -36
- package/dist/shaders/still.js.map +0 -1
- package/src/shaders/still.ts +0 -41
|
@@ -15,7 +15,10 @@ interface LayerDependencies {
|
|
|
15
15
|
/** The images the layers and their styles paint with. */
|
|
16
16
|
images: Set<string>;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* The variables a layer names: its own bindings, its characters', its overrides', and those its
|
|
20
|
+
* behaviour's transition, slide transition and animation follow.
|
|
21
|
+
*/
|
|
19
22
|
declare function layerVariableIds(node: SceneNode): string[];
|
|
20
23
|
/**
|
|
21
24
|
* The images a layer paints with: its fills, strokes, vector regions, text decorations, and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","names":[],"sources":["../../src/transfer/dependencies.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","names":[],"sources":["../../src/transfer/dependencies.ts"],"mappings":";;;;UAeiB;;EAEf,WAAW;;;;;EAKX,aAAa;;EAEb,QAAQ;;EAER,QAAQ;;;;;;iBAOM,iBAAiB,MAAM;;;;;iBAmBvB,iBAAiB,MAAM;;;;;;iBAkBvB,kBACd,OAAO,YACP,QAAQ,SAAS,aAChB;;;;;iBA8Ba,qBACd,OAAO,YACP,KAAK,mBACJ,KAAK"}
|
|
@@ -3,15 +3,24 @@ import { isUnsupportedVariableValue, variableValueReferences } from "../variable
|
|
|
3
3
|
import { styleRunReferences } from "../text/references.js";
|
|
4
4
|
import { referencedStyleIds, sharedStyleLayers } from "../shared-styles.js";
|
|
5
5
|
import { regionFills } from "../vector-network.js";
|
|
6
|
+
import { readBehaviour } from "../behaviours/model.js";
|
|
7
|
+
import { transitionVariableIds } from "../behaviours/transition.js";
|
|
6
8
|
import { imagePaintHashes } from "../images.js";
|
|
9
|
+
import { slideVariableIds } from "../slides/motion.js";
|
|
7
10
|
import { appendAll } from "@open-pencil/std/arrays";
|
|
8
11
|
//#region src/transfer/dependencies.ts
|
|
9
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* The variables a layer names: its own bindings, its characters', its overrides', and those its
|
|
14
|
+
* behaviour's transition, slide transition and animation follow.
|
|
15
|
+
*/
|
|
10
16
|
function layerVariableIds(node) {
|
|
11
17
|
const { self, descendants } = node.instanceOverrides;
|
|
12
18
|
const overridden = [...self, ...[...descendants.values()].flatMap((fields) => [...fields])];
|
|
19
|
+
const behaviour = readBehaviour(node);
|
|
13
20
|
return [
|
|
14
21
|
...Object.values(node.boundVariables),
|
|
22
|
+
...behaviour ? transitionVariableIds(behaviour) : [],
|
|
23
|
+
...slideVariableIds(node),
|
|
15
24
|
...styleRunReferences(node.styleRuns).variables,
|
|
16
25
|
...overridden.flatMap(([field, value]) => typeof value === "string" && overriddenBindingField(field) !== null ? [value] : [])
|
|
17
26
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","names":[],"sources":["../../src/transfer/dependencies.ts"],"sourcesContent":["import { appendAll } from '@open-pencil/std/arrays'\n\nimport type { SceneGraph } from '../graph'\nimport { imagePaintHashes } from '../images'\nimport { overriddenBindingField } from '../instances/overrides'\nimport { referencedStyleIds, sharedStyleLayers } from '../shared-styles'\nimport { styleRunReferences } from '../text/references'\nimport type { SceneNode } from '../types'\nimport { isUnsupportedVariableValue, variableValueReferences } from '../variables/value'\nimport { regionFills } from '../vector-network'\n\n/** What layers need from their document to draw the same in another one. */\nexport interface LayerDependencies {\n /** The variables the layers and their styles bind, and every variable those alias. */\n variables: Set<string>\n /**\n * The collections of those variables, those the layers set a mode of, and those a kept\n * expression names a mode of.\n */\n collections: Set<string>\n /** The shared styles the layers use, as the style layers that define them. */\n styles: SceneNode[]\n /** The images the layers and their styles paint with. */\n images: Set<string>\n}\n\n
|
|
1
|
+
{"version":3,"file":"dependencies.js","names":[],"sources":["../../src/transfer/dependencies.ts"],"sourcesContent":["import { appendAll } from '@open-pencil/std/arrays'\n\nimport { readBehaviour } from '../behaviours/model'\nimport { transitionVariableIds } from '../behaviours/transition'\nimport type { SceneGraph } from '../graph'\nimport { imagePaintHashes } from '../images'\nimport { overriddenBindingField } from '../instances/overrides'\nimport { referencedStyleIds, sharedStyleLayers } from '../shared-styles'\nimport { slideVariableIds } from '../slides/motion'\nimport { styleRunReferences } from '../text/references'\nimport type { SceneNode } from '../types'\nimport { isUnsupportedVariableValue, variableValueReferences } from '../variables/value'\nimport { regionFills } from '../vector-network'\n\n/** What layers need from their document to draw the same in another one. */\nexport interface LayerDependencies {\n /** The variables the layers and their styles bind, and every variable those alias. */\n variables: Set<string>\n /**\n * The collections of those variables, those the layers set a mode of, and those a kept\n * expression names a mode of.\n */\n collections: Set<string>\n /** The shared styles the layers use, as the style layers that define them. */\n styles: SceneNode[]\n /** The images the layers and their styles paint with. */\n images: Set<string>\n}\n\n/**\n * The variables a layer names: its own bindings, its characters', its overrides', and those its\n * behaviour's transition, slide transition and animation follow.\n */\nexport function layerVariableIds(node: SceneNode): string[] {\n const { self, descendants } = node.instanceOverrides\n const overridden = [...self, ...[...descendants.values()].flatMap((fields) => [...fields])]\n const behaviour = readBehaviour(node)\n return [\n ...Object.values(node.boundVariables),\n ...(behaviour ? transitionVariableIds(behaviour) : []),\n ...slideVariableIds(node),\n ...styleRunReferences(node.styleRuns).variables,\n ...overridden.flatMap(([field, value]) =>\n typeof value === 'string' && overriddenBindingField(field) !== null ? [value] : []\n )\n ]\n}\n\n/**\n * The images a layer paints with: its fills, strokes, vector regions, text decorations, and\n * characters.\n */\nexport function layerImageHashes(node: SceneNode): string[] {\n return imagePaintHashes([\n ...node.fills,\n ...node.strokes,\n ...regionFills(node.vectorNetwork),\n ...node.textDecorationFills,\n ...node.styleRuns.flatMap((run) => [\n ...(run.style.fills ?? []),\n ...(run.style.textDecorationFills ?? [])\n ])\n ])\n}\n\n/**\n * The variables, collections, styles, and images `layers` depend on, as a copy into another\n * document must carry them: a style brings what it binds and paints with in turn, and a variable\n * brings the variables it aliases.\n */\nexport function layerDependencies(\n graph: SceneGraph,\n layers: Iterable<SceneNode>\n): LayerDependencies {\n const collections = new Set<string>()\n const images = new Set<string>()\n const styles = new Map<string, SceneNode>()\n const pending: string[] = []\n let styleLayers: Map<string, SceneNode> | undefined\n const styleLayer = (id: string): SceneNode | undefined =>\n (styleLayers ??= sharedStyleLayers(graph)).get(id)\n const visit = (node: SceneNode): void => {\n for (const hash of layerImageHashes(node)) images.add(hash)\n appendAll(pending, layerVariableIds(node))\n for (const id of Object.keys(node.variableModes))\n if (graph.variableCollections.has(id)) collections.add(id)\n for (const id of referencedStyleIds(node)) {\n const style = styles.has(id) ? undefined : styleLayer(id)\n if (!style) continue\n styles.set(id, style)\n visit(style)\n }\n }\n for (const node of layers) visit(node)\n const resolved = variableDependencies(graph, pending)\n for (const id of resolved.collections) collections.add(id)\n return { variables: resolved.variables, collections, styles: [...styles.values()], images }\n}\n\n/**\n * These variables and every variable they alias, at any depth, with their collections and the\n * collections a kept expression names a mode of.\n */\nexport function variableDependencies(\n graph: SceneGraph,\n ids: Iterable<string>\n): Pick<LayerDependencies, 'variables' | 'collections'> {\n const pending = [...ids]\n const variables = new Set<string>()\n const collections = new Set<string>()\n let modeCollections: Map<string, string> | undefined\n const collectionOfMode = (modeId: string): string | undefined => {\n modeCollections ??= new Map(\n [...graph.variableCollections.values()].flatMap((collection) =>\n collection.modes.map((mode) => [mode.modeId, collection.id] as const)\n )\n )\n return modeCollections.get(modeId)\n }\n for (let id = pending.pop(); id !== undefined; id = pending.pop()) {\n if (variables.has(id)) continue\n const variable = graph.variables.get(id)\n if (!variable) continue\n variables.add(id)\n collections.add(variable.collectionId)\n for (const value of Object.values(variable.valuesByMode)) {\n appendAll(pending, variableValueReferences(value))\n // A kept expression can name a mode of a collection none of its aliases reach.\n if (!isUnsupportedVariableValue(value)) continue\n for (const modeId of value.modes) {\n const collection = collectionOfMode(modeId)\n if (collection) collections.add(collection)\n }\n }\n }\n return { variables, collections }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAgB,iBAAiB,MAA2B;CAC1D,MAAM,EAAE,MAAM,gBAAgB,KAAK;CACnC,MAAM,aAAa,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC;CAC1F,MAAM,YAAY,cAAc,IAAI;CACpC,OAAO;EACL,GAAG,OAAO,OAAO,KAAK,cAAc;EACpC,GAAI,YAAY,sBAAsB,SAAS,IAAI,CAAC;EACpD,GAAG,iBAAiB,IAAI;EACxB,GAAG,mBAAmB,KAAK,SAAS,CAAC,CAAC;E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E,WAAW,SAAS;EAAW;EAAa,QAAQ,CAAC,GAAG,OAAO,OAAO,CAAC;EAAG;CAAO;AAC5F;;;;;AAMA,SAAgB,qBACd,OACA,KACsD;CACtD,MAAM,UAAU,CAAC,GAAG,GAAG;CACvB,MAAM,4BAAY,IAAI,IAAY;CAClC,MAAM,8BAAc,IAAI,IAAY;CACpC,IAAI;CACJ,MAAM,oBAAoB,WAAuC;EAC/D,oBAAoB,IAAI,IACtB,CAAC,GAAG,MAAM,oBAAoB,OAAO,CAAC,CAAC,CAAC,SAAS,eAC/C,WAAW,MAAM,KAAK,SAAS,CAAC,KAAK,QAAQ,WAAW,EAAE,CAAU,CACtE,CACF;EACA,OAAO,gBAAgB,IAAI,MAAM;CACnC;CACA,KAAK,IAAI,KAAK,QAAQ,IAAI,GAAG,OAAO,KAAA,GAAW,KAAK,QAAQ,IAAI,GAAG;EACjE,IAAI,UAAU,IAAI,EAAE,GAAG;EACvB,MAAM,WAAW,MAAM,UAAU,IAAI,EAAE;EACvC,IAAI,CAAC,UAAU;EACf,UAAU,IAAI,EAAE;EAChB,YAAY,IAAI,SAAS,YAAY;EACrC,KAAK,MAAM,SAAS,OAAO,OAAO,SAAS,YAAY,GAAG;GACxD,UAAU,SAAS,wBAAwB,KAAK,CAAC;GAEjD,IAAI,CAAC,2BAA2B,KAAK,GAAG;GACxC,KAAK,MAAM,UAAU,MAAM,OAAO;IAChC,MAAM,aAAa,iBAAiB,MAAM;IAC1C,IAAI,YAAY,YAAY,IAAI,UAAU;GAC5C;EACF;CACF;CACA,OAAO;EAAE;EAAW;CAAY;AAClC"}
|
package/dist/transfer/history.js
CHANGED
|
@@ -10,6 +10,8 @@ function captureTransferredState(graph, original) {
|
|
|
10
10
|
nodeIds: new Map(original.nodeIds),
|
|
11
11
|
rootIds: [...original.rootIds],
|
|
12
12
|
dependencyPageIds: [...original.dependencyPageIds],
|
|
13
|
+
reused: structuredClone(original.reused),
|
|
14
|
+
joined: structuredClone(original.joined),
|
|
13
15
|
nodes: original.nodes.map((entry) => {
|
|
14
16
|
const node = requireValue(graph.getNode(entry.id), "node", entry.id);
|
|
15
17
|
if (!node.parentId) throw new Error(`Missing transferred parent ${entry.id}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.js","names":[],"sources":["../../src/transfer/history.ts"],"sourcesContent":["import { cloneNodeProps } from '../copy'\nimport type { SceneGraph } from '../graph'\nimport type { GraphTransferPlan } from './apply'\n\n/** Capture post-placement state for redo; this does not authorize deleting shared resources. */\nexport function captureTransferredState(\n graph: SceneGraph,\n original: GraphTransferPlan\n): GraphTransferPlan {\n const requireValue = <T>(value: T | undefined, kind: string, id: string): T => {\n if (value === undefined) throw new Error(`Missing transferred ${kind} ${id}`)\n return value\n }\n return {\n nodeIds: new Map(original.nodeIds),\n rootIds: [...original.rootIds],\n dependencyPageIds: [...original.dependencyPageIds],\n nodes: original.nodes.map((entry) => {\n const node = requireValue(graph.getNode(entry.id), 'node', entry.id)\n if (!node.parentId) throw new Error(`Missing transferred parent ${entry.id}`)\n return {\n id: node.id,\n type: node.type,\n parentId: node.parentId,\n props: cloneNodeProps(node, null)\n }\n }),\n variables: original.variables.map((variable) =>\n structuredClone(requireValue(graph.variables.get(variable.id), 'variable', variable.id))\n ),\n collections: original.collections.map((collection) =>\n structuredClone(\n requireValue(graph.variableCollections.get(collection.id), 'collection', collection.id)\n )\n ),\n images: new Map(\n [...original.images.keys()].map((hash) => [\n hash,\n requireValue(graph.images.get(hash), 'image', hash).slice()\n ])\n )\n }\n}\n"],"mappings":";;;AAKA,SAAgB,wBACd,OACA,UACmB;CACnB,MAAM,gBAAmB,OAAsB,MAAc,OAAkB;EAC7E,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,uBAAuB,KAAK,GAAG,IAAI;EAC5E,OAAO;CACT;CACA,OAAO;EACL,SAAS,IAAI,IAAI,SAAS,OAAO;EACjC,SAAS,CAAC,GAAG,SAAS,OAAO;EAC7B,mBAAmB,CAAC,GAAG,SAAS,iBAAiB;EACjD,OAAO,SAAS,MAAM,KAAK,UAAU;GACnC,MAAM,OAAO,aAAa,MAAM,QAAQ,MAAM,EAAE,GAAG,QAAQ,MAAM,EAAE;GACnE,IAAI,CAAC,KAAK,UAAU,MAAM,IAAI,MAAM,8BAA8B,MAAM,IAAI;GAC5E,OAAO;IACL,IAAI,KAAK;IACT,MAAM,KAAK;IACX,UAAU,KAAK;IACf,OAAO,eAAe,MAAM,IAAI;GAClC;EACF,CAAC;EACD,WAAW,SAAS,UAAU,KAAK,aACjC,gBAAgB,aAAa,MAAM,UAAU,IAAI,SAAS,EAAE,GAAG,YAAY,SAAS,EAAE,CAAC,CACzF;EACA,aAAa,SAAS,YAAY,KAAK,eACrC,gBACE,aAAa,MAAM,oBAAoB,IAAI,WAAW,EAAE,GAAG,cAAc,WAAW,EAAE,CACxF,CACF;EACA,QAAQ,IAAI,IACV,CAAC,GAAG,SAAS,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CACxC,MACA,aAAa,MAAM,OAAO,IAAI,IAAI,GAAG,SAAS,IAAI,CAAC,CAAC,MAAM,CAC5D,CAAC,CACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"history.js","names":[],"sources":["../../src/transfer/history.ts"],"sourcesContent":["import { cloneNodeProps } from '../copy'\nimport type { SceneGraph } from '../graph'\nimport type { GraphTransferPlan } from './apply'\n\n/** Capture post-placement state for redo; this does not authorize deleting shared resources. */\nexport function captureTransferredState(\n graph: SceneGraph,\n original: GraphTransferPlan\n): GraphTransferPlan {\n const requireValue = <T>(value: T | undefined, kind: string, id: string): T => {\n if (value === undefined) throw new Error(`Missing transferred ${kind} ${id}`)\n return value\n }\n return {\n nodeIds: new Map(original.nodeIds),\n rootIds: [...original.rootIds],\n dependencyPageIds: [...original.dependencyPageIds],\n reused: structuredClone(original.reused),\n joined: structuredClone(original.joined),\n nodes: original.nodes.map((entry) => {\n const node = requireValue(graph.getNode(entry.id), 'node', entry.id)\n if (!node.parentId) throw new Error(`Missing transferred parent ${entry.id}`)\n return {\n id: node.id,\n type: node.type,\n parentId: node.parentId,\n props: cloneNodeProps(node, null)\n }\n }),\n variables: original.variables.map((variable) =>\n structuredClone(requireValue(graph.variables.get(variable.id), 'variable', variable.id))\n ),\n collections: original.collections.map((collection) =>\n structuredClone(\n requireValue(graph.variableCollections.get(collection.id), 'collection', collection.id)\n )\n ),\n images: new Map(\n [...original.images.keys()].map((hash) => [\n hash,\n requireValue(graph.images.get(hash), 'image', hash).slice()\n ])\n )\n }\n}\n"],"mappings":";;;AAKA,SAAgB,wBACd,OACA,UACmB;CACnB,MAAM,gBAAmB,OAAsB,MAAc,OAAkB;EAC7E,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,uBAAuB,KAAK,GAAG,IAAI;EAC5E,OAAO;CACT;CACA,OAAO;EACL,SAAS,IAAI,IAAI,SAAS,OAAO;EACjC,SAAS,CAAC,GAAG,SAAS,OAAO;EAC7B,mBAAmB,CAAC,GAAG,SAAS,iBAAiB;EACjD,QAAQ,gBAAgB,SAAS,MAAM;EACvC,QAAQ,gBAAgB,SAAS,MAAM;EACvC,OAAO,SAAS,MAAM,KAAK,UAAU;GACnC,MAAM,OAAO,aAAa,MAAM,QAAQ,MAAM,EAAE,GAAG,QAAQ,MAAM,EAAE;GACnE,IAAI,CAAC,KAAK,UAAU,MAAM,IAAI,MAAM,8BAA8B,MAAM,IAAI;GAC5E,OAAO;IACL,IAAI,KAAK;IACT,MAAM,KAAK;IACX,UAAU,KAAK;IACf,OAAO,eAAe,MAAM,IAAI;GAClC;EACF,CAAC;EACD,WAAW,SAAS,UAAU,KAAK,aACjC,gBAAgB,aAAa,MAAM,UAAU,IAAI,SAAS,EAAE,GAAG,YAAY,SAAS,EAAE,CAAC,CACzF;EACA,aAAa,SAAS,YAAY,KAAK,eACrC,gBACE,aAAa,MAAM,oBAAoB,IAAI,WAAW,EAAE,GAAG,cAAc,WAAW,EAAE,CACxF,CACF;EACA,QAAQ,IAAI,IACV,CAAC,GAAG,SAAS,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CACxC,MACA,aAAa,MAAM,OAAO,IAAI,IAAI,GAAG,SAAS,IAAI,CAAC,CAAC,MAAM,CAC5D,CAAC,CACH;CACF;AACF"}
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
//#region src/transfer/identity.ts
|
|
2
|
-
function variableIdentityReferences(variables, collections) {
|
|
2
|
+
function variableIdentityReferences(variables, collections, heldVariableIds = []) {
|
|
3
3
|
return {
|
|
4
|
-
variables: new Map(variables.map((variable) =>
|
|
4
|
+
variables: new Map([...variables.map((variable) => variable.id), ...heldVariableIds].map((id) => [id, id])),
|
|
5
5
|
collections: new Map(collections.map((collection) => [collection.id, collection.id])),
|
|
6
6
|
modes: new Map(collections.flatMap((collection) => collection.modes.map((mode) => [mode.modeId, mode.modeId])))
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The target's collections a plan reuses, each listing only the variables the plan adds to it,
|
|
11
|
+
* as a plan's own collections list theirs, so the plan validates as one self-contained fragment.
|
|
12
|
+
*/
|
|
13
|
+
function heldTransferCollections(target, plan) {
|
|
14
|
+
for (const id of plan.reused.variables) if (!target.variables.has(id)) throw new Error(`Missing reused transfer variable ${id}`);
|
|
15
|
+
return plan.reused.collections.map((id) => {
|
|
16
|
+
const collection = target.variableCollections.get(id);
|
|
17
|
+
if (!collection) throw new Error(`Missing reused transfer collection ${id}`);
|
|
18
|
+
return {
|
|
19
|
+
...structuredClone(collection),
|
|
20
|
+
variableIds: plan.joined.filter((entry) => entry.collectionId === id).map((entry) => entry.variableId)
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
9
24
|
//#endregion
|
|
10
|
-
export { variableIdentityReferences };
|
|
25
|
+
export { heldTransferCollections, variableIdentityReferences };
|
|
11
26
|
|
|
12
27
|
//# sourceMappingURL=identity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","names":[],"sources":["../../src/transfer/identity.ts"],"sourcesContent":["import type { Variable, VariableCollection } from '../types'\n\nexport function variableIdentityReferences(\n variables: readonly Variable[],\n collections: readonly VariableCollection[]\n) {\n return {\n variables: new Map(variables.map((variable) =>
|
|
1
|
+
{"version":3,"file":"identity.js","names":[],"sources":["../../src/transfer/identity.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { Variable, VariableCollection } from '../types'\n\nexport function variableIdentityReferences(\n variables: readonly Variable[],\n collections: readonly VariableCollection[],\n heldVariableIds: readonly string[] = []\n) {\n return {\n variables: new Map(\n [...variables.map((variable) => variable.id), ...heldVariableIds].map((id) => [id, id])\n ),\n collections: new Map(collections.map((collection) => [collection.id, collection.id])),\n modes: new Map(\n collections.flatMap((collection) =>\n collection.modes.map((mode) => [mode.modeId, mode.modeId] as const)\n )\n )\n }\n}\n\n/** The target's library resources a transfer reuses, and the variables it adds to them. */\nexport interface HeldTransferResources {\n reused: { collections: string[]; variables: string[]; styles: string[] }\n joined: Array<{ collectionId: string; variableId: string }>\n}\n\n/**\n * The target's collections a plan reuses, each listing only the variables the plan adds to it,\n * as a plan's own collections list theirs, so the plan validates as one self-contained fragment.\n */\nexport function heldTransferCollections(\n target: SceneGraph,\n plan: HeldTransferResources\n): VariableCollection[] {\n for (const id of plan.reused.variables)\n if (!target.variables.has(id)) throw new Error(`Missing reused transfer variable ${id}`)\n return plan.reused.collections.map((id) => {\n const collection = target.variableCollections.get(id)\n if (!collection) throw new Error(`Missing reused transfer collection ${id}`)\n return {\n ...structuredClone(collection),\n variableIds: plan.joined\n .filter((entry) => entry.collectionId === id)\n .map((entry) => entry.variableId)\n }\n })\n}\n"],"mappings":";AAGA,SAAgB,2BACd,WACA,aACA,kBAAqC,CAAC,GACtC;CACA,OAAO;EACL,WAAW,IAAI,IACb,CAAC,GAAG,UAAU,KAAK,aAAa,SAAS,EAAE,GAAG,GAAG,eAAe,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CACxF;EACA,aAAa,IAAI,IAAI,YAAY,KAAK,eAAe,CAAC,WAAW,IAAI,WAAW,EAAE,CAAC,CAAC;EACpF,OAAO,IAAI,IACT,YAAY,SAAS,eACnB,WAAW,MAAM,KAAK,SAAS,CAAC,KAAK,QAAQ,KAAK,MAAM,CAAU,CACpE,CACF;CACF;AACF;;;;;AAYA,SAAgB,wBACd,QACA,MACsB;CACtB,KAAK,MAAM,MAAM,KAAK,OAAO,WAC3B,IAAI,CAAC,OAAO,UAAU,IAAI,EAAE,GAAG,MAAM,IAAI,MAAM,oCAAoC,IAAI;CACzF,OAAO,KAAK,OAAO,YAAY,KAAK,OAAO;EACzC,MAAM,aAAa,OAAO,oBAAoB,IAAI,EAAE;EACpD,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,sCAAsC,IAAI;EAC3E,OAAO;GACL,GAAG,gBAAgB,UAAU;GAC7B,aAAa,KAAK,OACf,QAAQ,UAAU,MAAM,iBAAiB,EAAE,CAAC,CAC5C,KAAK,UAAU,MAAM,UAAU;EACpC;CACF,CAAC;AACH"}
|
package/dist/transfer/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ import { NodeTransferReferences, prepareNodeTransfer } from "./nodes.js";
|
|
|
7
7
|
import { CopiedReferenceOptions, ReferenceResolvers, instanceSwapPropertyIds, remapCopiedReferences, resolvedReferences } from "./copied.js";
|
|
8
8
|
import { LayerDependencies, layerDependencies, layerImageHashes, layerVariableIds, variableDependencies } from "./dependencies.js";
|
|
9
9
|
import { ResourceReferences, remappedResourceReferences } from "./resources.js";
|
|
10
|
-
|
|
10
|
+
import { LibraryReuse, libraryModeOf, matchLibraryResources, withoutLibraryKey } from "./library.js";
|
|
11
|
+
export { type CopiedReferenceOptions, type GraphTransferInput, type GraphTransferPlan, type LayerDependencies, type LibraryReuse, type NodeTransferReferences, type ReferenceResolvers, type ResourceReferences, type VariableTransferReferences, applyGraphTransfer, captureTransferredState, copyVariableTables, instanceSwapPropertyIds, layerDependencies, layerImageHashes, layerVariableIds, libraryModeOf, matchLibraryResources, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, remapCopiedReferences, remappedResourceReferences, removeGraphTransfer, resolvedReferences, variableDependencies, withoutLibraryKey };
|
package/dist/transfer/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { instanceSwapPropertyIds, remapCopiedReferences, resolvedReferences } from "./copied.js";
|
|
2
2
|
import { remappedResourceReferences } from "./resources.js";
|
|
3
3
|
import { prepareNodeTransfer } from "./nodes.js";
|
|
4
|
-
import { removeGraphTransfer } from "./remove.js";
|
|
5
|
-
import { captureTransferredState } from "./history.js";
|
|
6
4
|
import { copyVariableTables, prepareVariableTransfer } from "./variables.js";
|
|
7
5
|
import { applyGraphTransfer } from "./apply.js";
|
|
6
|
+
import { removeGraphTransfer } from "./remove.js";
|
|
7
|
+
import { captureTransferredState } from "./history.js";
|
|
8
|
+
import { libraryModeOf, matchLibraryResources, withoutLibraryKey } from "./library.js";
|
|
8
9
|
import { prepareGraphTransfer } from "./plan.js";
|
|
9
10
|
import { layerDependencies, layerImageHashes, layerVariableIds, variableDependencies } from "./dependencies.js";
|
|
10
|
-
export { applyGraphTransfer, captureTransferredState, copyVariableTables, instanceSwapPropertyIds, layerDependencies, layerImageHashes, layerVariableIds, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, remapCopiedReferences, remappedResourceReferences, removeGraphTransfer, resolvedReferences, variableDependencies };
|
|
11
|
+
export { applyGraphTransfer, captureTransferredState, copyVariableTables, instanceSwapPropertyIds, layerDependencies, layerImageHashes, layerVariableIds, libraryModeOf, matchLibraryResources, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, remapCopiedReferences, remappedResourceReferences, removeGraphTransfer, resolvedReferences, variableDependencies, withoutLibraryKey };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { SceneNode, Variable, VariableCollection, VariableCollectionMode } from "../types.js";
|
|
3
|
+
//#region src/transfer/library.d.ts
|
|
4
|
+
/** A library asset's identity: its key and the version references by key carry with it. */
|
|
5
|
+
interface LibraryIdentity {
|
|
6
|
+
key?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
}
|
|
9
|
+
/** A copy without the library key and version it came with: the document's own. */
|
|
10
|
+
declare function withoutLibraryKey<T extends LibraryIdentity>(item: T): T;
|
|
11
|
+
/** The library mode a mode stands for: the one it came from, or else itself. */
|
|
12
|
+
declare function libraryModeOf(mode: VariableCollectionMode): string;
|
|
13
|
+
/**
|
|
14
|
+
* How a transfer meets the copies the target already holds of the library resources it brings,
|
|
15
|
+
* so that a document keeps one copy of each library asset, as Figma does: a pasted layer binds
|
|
16
|
+
* to the copy the document has, which the reader would otherwise find twice under one key.
|
|
17
|
+
*/
|
|
18
|
+
interface LibraryReuse {
|
|
19
|
+
/** Source collections the target holds, by the target collection holding them. */
|
|
20
|
+
collections: Map<string, string>;
|
|
21
|
+
/** Modes of those collections, by the target mode each stands for. */
|
|
22
|
+
modes: Map<string, string>;
|
|
23
|
+
/** Source variables the target holds, by the target variable. */
|
|
24
|
+
variables: Map<string, string>;
|
|
25
|
+
/** Source styles the target holds, by the style ID layers name the target's copy with. */
|
|
26
|
+
styles: Map<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Library resources the target holds a copy of that cannot take this one's place, such as a
|
|
29
|
+
* collection whose modes do not pair: the transfer makes them its own, without their key.
|
|
30
|
+
*/
|
|
31
|
+
local: Set<string>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Matches the library resources a transfer brings against the copies the target holds.
|
|
35
|
+
* `targetStyles` is the target's `sharedStyleLayers` when the caller has it already; the target
|
|
36
|
+
* is searched for styles only when the transfer brings one.
|
|
37
|
+
*/
|
|
38
|
+
declare function matchLibraryResources(target: SceneGraph, source: {
|
|
39
|
+
collections: Iterable<VariableCollection>;
|
|
40
|
+
variables: Iterable<Variable>;
|
|
41
|
+
styles: Iterable<SceneNode>;
|
|
42
|
+
}, targetStyles?: ReadonlyMap<string, SceneNode>): LibraryReuse;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { LibraryReuse, libraryModeOf, matchLibraryResources, withoutLibraryKey };
|
|
45
|
+
//# sourceMappingURL=library.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library.d.ts","names":[],"sources":["../../src/transfer/library.ts"],"mappings":";;;;UAKU;EACR;EACA;;;iBAQc,kBAAkB,UAAU,iBAAiB,MAAM,IAAI;;iBAiBvD,cAAc,MAAM;;;;;;UAqCnB;;EAEf,aAAa;;EAEb,OAAO;;EAEP,WAAW;;EAEX,QAAQ;;;;;EAKR,OAAO;;;;;;;iBAQO,sBACd,QAAQ,YACR;EACE,aAAa,SAAS;EACtB,WAAW,SAAS;EACpB,QAAQ,SAAS;GAEnB,eAAe,oBAAoB,aAClC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { sharedStyleLayers } from "../shared-styles.js";
|
|
2
|
+
//#region src/transfer/library.ts
|
|
3
|
+
function sameAsset(a, b) {
|
|
4
|
+
return !!a.key && a.key === b.key && a.version === b.version;
|
|
5
|
+
}
|
|
6
|
+
/** A copy without the library key and version it came with: the document's own. */
|
|
7
|
+
function withoutLibraryKey(item) {
|
|
8
|
+
const copy = { ...item };
|
|
9
|
+
delete copy.key;
|
|
10
|
+
delete copy.version;
|
|
11
|
+
return copy;
|
|
12
|
+
}
|
|
13
|
+
/** The library key and version a style taken from a library keeps from its file. */
|
|
14
|
+
function styleLibraryIdentity(style) {
|
|
15
|
+
const { key, version } = style.source.fig.rawNodeFields;
|
|
16
|
+
return {
|
|
17
|
+
key: typeof key === "string" ? key : void 0,
|
|
18
|
+
version: typeof version === "string" ? version : void 0
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** The library mode a mode stands for: the one it came from, or else itself. */
|
|
22
|
+
function libraryModeOf(mode) {
|
|
23
|
+
return mode.libraryModeId ?? mode.modeId;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Which of `copy`'s modes each of `collection`'s stands for, or undefined when one has none. A mode
|
|
27
|
+
* takes the copy's mode that came from the same library mode; where there is none, as in a copy
|
|
28
|
+
* made before modes kept that link, an unpaired mode with its name, as `pairModes` in Core's
|
|
29
|
+
* library import pairs them.
|
|
30
|
+
*/
|
|
31
|
+
function pairedModes(collection, copy) {
|
|
32
|
+
const unpaired = new Map(copy.modes.map((mode) => [mode.modeId, mode]));
|
|
33
|
+
const paired = /* @__PURE__ */ new Map();
|
|
34
|
+
const pair = (mode, match) => {
|
|
35
|
+
const found = [...unpaired.values()].find(match);
|
|
36
|
+
if (!found) return;
|
|
37
|
+
unpaired.delete(found.modeId);
|
|
38
|
+
paired.set(mode.modeId, found.modeId);
|
|
39
|
+
};
|
|
40
|
+
for (const mode of collection.modes) pair(mode, (candidate) => candidate.libraryModeId === libraryModeOf(mode));
|
|
41
|
+
for (const mode of collection.modes) if (!paired.has(mode.modeId)) pair(mode, (candidate) => candidate.name === mode.name);
|
|
42
|
+
return paired.size === collection.modes.length ? paired : void 0;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Matches the library resources a transfer brings against the copies the target holds.
|
|
46
|
+
* `targetStyles` is the target's `sharedStyleLayers` when the caller has it already; the target
|
|
47
|
+
* is searched for styles only when the transfer brings one.
|
|
48
|
+
*/
|
|
49
|
+
function matchLibraryResources(target, source, targetStyles) {
|
|
50
|
+
const reuse = {
|
|
51
|
+
collections: /* @__PURE__ */ new Map(),
|
|
52
|
+
modes: /* @__PURE__ */ new Map(),
|
|
53
|
+
variables: /* @__PURE__ */ new Map(),
|
|
54
|
+
styles: /* @__PURE__ */ new Map(),
|
|
55
|
+
local: /* @__PURE__ */ new Set()
|
|
56
|
+
};
|
|
57
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
58
|
+
const firstCopy = (item) => {
|
|
59
|
+
if (!item.key) return true;
|
|
60
|
+
const identity = `${item.key}\u0000${item.version ?? ""}`;
|
|
61
|
+
if (claimed.has(identity)) {
|
|
62
|
+
reuse.local.add(item.id);
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
claimed.add(identity);
|
|
66
|
+
return true;
|
|
67
|
+
};
|
|
68
|
+
const collections = [...target.variableCollections.values()];
|
|
69
|
+
for (const collection of source.collections) {
|
|
70
|
+
if (!firstCopy(collection)) continue;
|
|
71
|
+
const copy = collections.find((candidate) => sameAsset(candidate, collection));
|
|
72
|
+
if (!copy) continue;
|
|
73
|
+
const modes = copy.deleted ? void 0 : pairedModes(collection, copy);
|
|
74
|
+
if (!modes) {
|
|
75
|
+
reuse.local.add(collection.id);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
reuse.collections.set(collection.id, copy.id);
|
|
79
|
+
for (const [mode, targetMode] of modes) reuse.modes.set(mode, targetMode);
|
|
80
|
+
}
|
|
81
|
+
const variables = [...target.variables.values()];
|
|
82
|
+
for (const variable of source.variables) {
|
|
83
|
+
if (!firstCopy(variable)) continue;
|
|
84
|
+
const copy = variables.find((candidate) => sameAsset(candidate, variable));
|
|
85
|
+
if (!copy) continue;
|
|
86
|
+
if (reuse.collections.get(variable.collectionId) === copy.collectionId && !copy.deleted) reuse.variables.set(variable.id, copy.id);
|
|
87
|
+
else reuse.local.add(variable.id);
|
|
88
|
+
}
|
|
89
|
+
const incoming = [...source.styles];
|
|
90
|
+
if (incoming.length === 0) return reuse;
|
|
91
|
+
const styles = [...(targetStyles ?? sharedStyleLayers(target)).values()].filter((style) => styleLibraryIdentity(style).key);
|
|
92
|
+
for (const style of incoming) {
|
|
93
|
+
const identity = styleLibraryIdentity(style);
|
|
94
|
+
const copy = styles.find((candidate) => sameAsset(styleLibraryIdentity(candidate), identity));
|
|
95
|
+
if (style.source.id && copy?.source.id) reuse.styles.set(style.source.id, copy.source.id);
|
|
96
|
+
}
|
|
97
|
+
return reuse;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { libraryModeOf, matchLibraryResources, withoutLibraryKey };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=library.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"library.js","names":[],"sources":["../../src/transfer/library.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport { sharedStyleLayers } from '../shared-styles'\nimport type { SceneNode, Variable, VariableCollection, VariableCollectionMode } from '../types'\n\n/** A library asset's identity: its key and the version references by key carry with it. */\ninterface LibraryIdentity {\n key?: string\n version?: string\n}\n\nfunction sameAsset(a: LibraryIdentity, b: LibraryIdentity): boolean {\n return !!a.key && a.key === b.key && a.version === b.version\n}\n\n/** A copy without the library key and version it came with: the document's own. */\nexport function withoutLibraryKey<T extends LibraryIdentity>(item: T): T {\n const copy = { ...item }\n delete copy.key\n delete copy.version\n return copy\n}\n\n/** The library key and version a style taken from a library keeps from its file. */\nfunction styleLibraryIdentity(style: SceneNode): LibraryIdentity {\n const { key, version } = style.source.fig.rawNodeFields\n return {\n key: typeof key === 'string' ? key : undefined,\n version: typeof version === 'string' ? version : undefined\n }\n}\n\n/** The library mode a mode stands for: the one it came from, or else itself. */\nexport function libraryModeOf(mode: VariableCollectionMode): string {\n return mode.libraryModeId ?? mode.modeId\n}\n\n/**\n * Which of `copy`'s modes each of `collection`'s stands for, or undefined when one has none. A mode\n * takes the copy's mode that came from the same library mode; where there is none, as in a copy\n * made before modes kept that link, an unpaired mode with its name, as `pairModes` in Core's\n * library import pairs them.\n */\nfunction pairedModes(\n collection: VariableCollection,\n copy: VariableCollection\n): Map<string, string> | undefined {\n const unpaired = new Map(copy.modes.map((mode) => [mode.modeId, mode]))\n const paired = new Map<string, string>()\n const pair = (\n mode: VariableCollectionMode,\n match: (candidate: VariableCollectionMode) => boolean\n ) => {\n const found = [...unpaired.values()].find(match)\n if (!found) return\n unpaired.delete(found.modeId)\n paired.set(mode.modeId, found.modeId)\n }\n for (const mode of collection.modes)\n pair(mode, (candidate) => candidate.libraryModeId === libraryModeOf(mode))\n for (const mode of collection.modes)\n if (!paired.has(mode.modeId)) pair(mode, (candidate) => candidate.name === mode.name)\n return paired.size === collection.modes.length ? paired : undefined\n}\n\n/**\n * How a transfer meets the copies the target already holds of the library resources it brings,\n * so that a document keeps one copy of each library asset, as Figma does: a pasted layer binds\n * to the copy the document has, which the reader would otherwise find twice under one key.\n */\nexport interface LibraryReuse {\n /** Source collections the target holds, by the target collection holding them. */\n collections: Map<string, string>\n /** Modes of those collections, by the target mode each stands for. */\n modes: Map<string, string>\n /** Source variables the target holds, by the target variable. */\n variables: Map<string, string>\n /** Source styles the target holds, by the style ID layers name the target's copy with. */\n styles: Map<string, string>\n /**\n * Library resources the target holds a copy of that cannot take this one's place, such as a\n * collection whose modes do not pair: the transfer makes them its own, without their key.\n */\n local: Set<string>\n}\n\n/**\n * Matches the library resources a transfer brings against the copies the target holds.\n * `targetStyles` is the target's `sharedStyleLayers` when the caller has it already; the target\n * is searched for styles only when the transfer brings one.\n */\nexport function matchLibraryResources(\n target: SceneGraph,\n source: {\n collections: Iterable<VariableCollection>\n variables: Iterable<Variable>\n styles: Iterable<SceneNode>\n },\n targetStyles?: ReadonlyMap<string, SceneNode>\n): LibraryReuse {\n const reuse: LibraryReuse = {\n collections: new Map(),\n modes: new Map(),\n variables: new Map(),\n styles: new Map(),\n local: new Set()\n }\n // A transfer can bring one library asset twice, as a file 0.17 saved can hold it: the first\n // copy is the library's, and the others become the document's own.\n const claimed = new Set<string>()\n const firstCopy = (item: LibraryIdentity & { id: string }): boolean => {\n if (!item.key) return true\n const identity = `${item.key}\\u0000${item.version ?? ''}`\n if (claimed.has(identity)) {\n reuse.local.add(item.id)\n return false\n }\n claimed.add(identity)\n return true\n }\n const collections = [...target.variableCollections.values()]\n for (const collection of source.collections) {\n if (!firstCopy(collection)) continue\n const copy = collections.find((candidate) => sameAsset(candidate, collection))\n if (!copy) continue\n const modes = copy.deleted ? undefined : pairedModes(collection, copy)\n if (!modes) {\n reuse.local.add(collection.id)\n continue\n }\n reuse.collections.set(collection.id, copy.id)\n for (const [mode, targetMode] of modes) reuse.modes.set(mode, targetMode)\n }\n const variables = [...target.variables.values()]\n for (const variable of source.variables) {\n if (!firstCopy(variable)) continue\n const copy = variables.find((candidate) => sameAsset(candidate, variable))\n if (!copy) continue\n if (reuse.collections.get(variable.collectionId) === copy.collectionId && !copy.deleted)\n reuse.variables.set(variable.id, copy.id)\n else reuse.local.add(variable.id)\n }\n const incoming = [...source.styles]\n if (incoming.length === 0) return reuse\n const styles = [...(targetStyles ?? sharedStyleLayers(target)).values()].filter(\n (style) => styleLibraryIdentity(style).key\n )\n for (const style of incoming) {\n const identity = styleLibraryIdentity(style)\n const copy = styles.find((candidate) => sameAsset(styleLibraryIdentity(candidate), identity))\n if (style.source.id && copy?.source.id) reuse.styles.set(style.source.id, copy.source.id)\n }\n return reuse\n}\n"],"mappings":";;AAUA,SAAS,UAAU,GAAoB,GAA6B;CAClE,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;AACvD;;AAGA,SAAgB,kBAA6C,MAAY;CACvE,MAAM,OAAO,EAAE,GAAG,KAAK;CACvB,OAAO,KAAK;CACZ,OAAO,KAAK;CACZ,OAAO;AACT;;AAGA,SAAS,qBAAqB,OAAmC;CAC/D,MAAM,EAAE,KAAK,YAAY,MAAM,OAAO,IAAI;CAC1C,OAAO;EACL,KAAK,OAAO,QAAQ,WAAW,MAAM,KAAA;EACrC,SAAS,OAAO,YAAY,WAAW,UAAU,KAAA;CACnD;AACF;;AAGA,SAAgB,cAAc,MAAsC;CAClE,OAAO,KAAK,iBAAiB,KAAK;AACpC;;;;;;;AAQA,SAAS,YACP,YACA,MACiC;CACjC,MAAM,WAAW,IAAI,IAAI,KAAK,MAAM,KAAK,SAAS,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC;CACtE,MAAM,yBA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AY,YAAY,IAAI;EACrE,IAAI,CAAC,OAAO;GACV,MAAM,MAAM,IAAI,WAAW,EAAE;GAC7B;EACF;EACA,MAAM,YAAY,IAAI,WAAW,IAAI,KAAK,EAAE;EAC5C,KAAK,MAAM,CAAC,MAAM,eAAe,OAAO,MAAM,MAAM,IAAI,MAAM,UAAU;CAC1E;CACA,MAAM,YAAY,CAAC,GAAG,OAAO,UAAU,OAAO,CAAC;CAC/C,KAAK,MAAM,YAAY,OAAO,WAAW;EACvC,IAAI,CAAC,UAAU,QAAQ,GAAG;EAC1B,MAAM,OAAO,UAAU,MAAM,cAAc,UAAU,WAAW,QAAQ,CAAC;EACzE,IAAI,CAAC,MAAM;EACX,IAAI,MAAM,YAAY,IAAI,SAAS,YAAY,MAAM,KAAK,gBAAgB,CAAC,KAAK,SAC9E,MAAM,UAAU,IAAI,SAAS,IAAI,KAAK,EAAE;OACrC,MAAM,MAAM,IAAI,SAAS,EAAE;CAClC;CACA,MAAM,WAAW,CAAC,GAAG,OAAO,MAAM;CAClC,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,MAAM,SAAS,CAAC,IAAI,gBAAgB,kBAAkB,MAAM,EAAA,CAAG,OAAO,CAAC,CAAC,CAAC,QACtE,UAAU,qBAAqB,KAAK,CAAC,CAAC,GACzC;CACA,KAAK,MAAM,SAAS,UAAU;EAC5B,MAAM,WAAW,qBAAqB,KAAK;EAC3C,MAAM,OAAO,OAAO,MAAM,cAAc,UAAU,qBAAqB,SAAS,GAAG,QAAQ,CAAC;EAC5F,IAAI,MAAM,OAAO,MAAM,MAAM,OAAO,IAAI,MAAM,OAAO,IAAI,MAAM,OAAO,IAAI,KAAK,OAAO,EAAE;CAC1F;CACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","names":[],"sources":["../../src/transfer/nodes.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","names":[],"sources":["../../src/transfer/nodes.ts"],"mappings":";;;UA6CiB,+BAA+B;EAC9C,OAAO;EACP,QAAQ;EACR,YAAY;EACZ,eAAe,oBAAoB;;;iBAIrB,oBACd,QAAQ,WACR,MAAM,yBACL,QAAQ"}
|
package/dist/transfer/nodes.js
CHANGED
|
@@ -2,14 +2,20 @@ import { overriddenBindingField, remapInstanceOverrideState } from "../instances
|
|
|
2
2
|
import { cloneNodeProps } from "../copy.js";
|
|
3
3
|
import { styleRunReferences } from "../text/references.js";
|
|
4
4
|
import { referencedStyleIds } from "../shared-styles.js";
|
|
5
|
+
import { readBehaviour, withBehaviour } from "../behaviours/model.js";
|
|
6
|
+
import { mapTransitionVariables, transitionVariableIds } from "../behaviours/transition.js";
|
|
7
|
+
import { mapSlideVariables, slideVariableIds } from "../slides/motion.js";
|
|
5
8
|
import { requireTransferReference } from "./references.js";
|
|
6
9
|
import { remappedResourceReferences } from "./resources.js";
|
|
7
10
|
//#region src/transfer/nodes.ts
|
|
8
11
|
function semanticTransferReferences(node) {
|
|
9
12
|
const runs = styleRunReferences(node.styleRuns);
|
|
13
|
+
const behaviour = readBehaviour(node);
|
|
10
14
|
return [
|
|
11
15
|
...node.componentId ? [node.componentId] : [],
|
|
12
16
|
...Object.values(node.boundVariables),
|
|
17
|
+
...behaviour ? transitionVariableIds(behaviour) : [],
|
|
18
|
+
...slideVariableIds(node),
|
|
13
19
|
...runs.variables,
|
|
14
20
|
...referencedStyleIds(node),
|
|
15
21
|
...Object.entries(node.componentPropertyAssignments).flatMap(([id, value]) => [id, value]),
|
|
@@ -63,6 +69,9 @@ function prepareNodeTransfer(source, refs) {
|
|
|
63
69
|
}] : [];
|
|
64
70
|
});
|
|
65
71
|
result.componentPropertyAssignments = values(source.componentPropertyAssignments);
|
|
72
|
+
const behaviour = readBehaviour(source);
|
|
73
|
+
if (behaviour && transitionVariableIds(behaviour).length > 0) result.pluginData = withBehaviour(source, mapTransitionVariables(behaviour, (id) => refs.variables.get(id)));
|
|
74
|
+
if (slideVariableIds(source).length > 0) Object.assign(result, mapSlideVariables(source, (id) => refs.variables.get(id)));
|
|
66
75
|
result.componentPropertyValues = { ...source.componentPropertyValues };
|
|
67
76
|
return result;
|
|
68
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","names":["required"],"sources":["../../src/transfer/nodes.ts"],"sourcesContent":["import { cloneNodeProps } from '../copy'\nimport { overriddenBindingField, remapInstanceOverrideState } from '../instances/overrides'\nimport { referencedStyleIds } from '../shared-styles'\nimport { styleRunReferences } from '../text/references'\nimport type { ComponentPropertyType, SceneNode } from '../types'\nimport { requireTransferReference as required } from './references'\nimport { remappedResourceReferences } from './resources'\nimport type { VariableTransferReferences } from './variables'\n\nexport function semanticTransferReferences(node: SceneNode): string[] {\n const runs = styleRunReferences(node.styleRuns)\n return [\n ...(node.componentId ? [node.componentId] : []),\n ...Object.values(node.boundVariables),\n ...runs.variables,\n ...referencedStyleIds(node),\n ...Object.entries(node.componentPropertyAssignments).flatMap(([id, value]) => [id, value]),\n ...node.componentPropertyReferences.map((reference) => reference.propertyId),\n ...node.componentPropertyDefinitions.flatMap((definition) => [\n definition.id,\n ...(definition.type === 'INSTANCE_SWAP' && definition.defaultValue\n ? [definition.defaultValue]\n : [])\n ]),\n ...node.instanceOverrides.descendants.keys(),\n ...[\n ...node.instanceOverrides.self,\n ...[...node.instanceOverrides.descendants.values()].flatMap((fields) => [...fields])\n ].flatMap(([field, value]) =>\n typeof value === 'string' &&\n (field === 'componentId' ||\n field === 'sourceComponentId' ||\n overriddenBindingField(field) !== null)\n ? [value]\n : []\n )\n ]\n}\n\nexport interface NodeTransferReferences extends VariableTransferReferences {\n nodes: ReadonlyMap<string, string>\n styles: ReadonlyMap<string, string>\n properties: ReadonlyMap<string, string>\n propertyTypes: ReadonlyMap<string, ComponentPropertyType>\n}\n\n/** Prepare runtime references without rewriting original format identities or ordinary text. */\nexport function prepareNodeTransfer(\n source: SceneNode,\n refs: NodeTransferReferences\n): Partial<SceneNode> {\n const node = (id: string) => required(refs.nodes, id, 'node')\n const variable = (id: string) => required(refs.variables, id, 'variable')\n const property = (id: string) => required(refs.properties, id, 'property')\n const style = (id: string) => required(refs.styles, id, 'style')\n const propertyValue = (id: string, value: string): string => {\n const type = refs.propertyTypes.get(id)\n if (!type) throw new Error(`Missing property transfer type: ${id}`)\n return type === 'INSTANCE_SWAP' && value ? node(value) : value\n }\n const values = (entries: Record<string, string>) =>\n Object.fromEntries(\n Object.entries(entries).map(([id, value]) => [property(id), propertyValue(id, value)])\n )\n const result = cloneNodeProps(source, null)\n result.componentId = source.componentId ? node(source.componentId) : null\n result.instanceOverrides = remapInstanceOverrideState(source.instanceOverrides, {\n node,\n variable,\n collection: (id) => refs.collections.get(id),\n property: (id) => refs.properties.get(id)\n })\n Object.assign(\n result,\n remappedResourceReferences(source, {\n variable,\n collection: (id) => required(refs.collections, id, 'collection'),\n mode: (id) => required(refs.modes, id, 'mode'),\n style,\n // A link to a layer the transfer leaves behind keeps naming it.\n layer: (id) => refs.nodes.get(id) ?? id\n })\n )\n // A connector keeps the layers it was attached to when they are left behind; the end becomes\n // free where nothing by that ID exists, as a pasted Figma connector does.\n for (const field of ['connectorStart', 'connectorEnd'] as const) {\n const endpoint = result[field]\n if (endpoint?.nodeId) endpoint.nodeId = refs.nodes.get(endpoint.nodeId) ?? endpoint.nodeId\n }\n result.componentPropertyDefinitions = source.componentPropertyDefinitions.map((definition) => ({\n ...structuredClone(definition),\n id: property(definition.id),\n defaultValue: propertyValue(definition.id, definition.defaultValue)\n }))\n // A reference to a property that neither the transfer nor its destination defines names nothing.\n result.componentPropertyReferences = source.componentPropertyReferences.flatMap((reference) => {\n const propertyId = refs.properties.get(reference.propertyId)\n return propertyId ? [{ ...reference, propertyId }] : []\n })\n result.componentPropertyAssignments = values(source.componentPropertyAssignments)\n // Variant values are keyed by display names, unlike definition-ID assignments.\n result.componentPropertyValues = { ...source.componentPropertyValues }\n return result\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"nodes.js","names":["required"],"sources":["../../src/transfer/nodes.ts"],"sourcesContent":["import { readBehaviour, withBehaviour } from '../behaviours/model'\nimport { mapTransitionVariables, transitionVariableIds } from '../behaviours/transition'\nimport { cloneNodeProps } from '../copy'\nimport { overriddenBindingField, remapInstanceOverrideState } from '../instances/overrides'\nimport { referencedStyleIds } from '../shared-styles'\nimport { mapSlideVariables, slideVariableIds } from '../slides/motion'\nimport { styleRunReferences } from '../text/references'\nimport type { ComponentPropertyType, SceneNode } from '../types'\nimport { requireTransferReference as required } from './references'\nimport { remappedResourceReferences } from './resources'\nimport type { VariableTransferReferences } from './variables'\n\nexport function semanticTransferReferences(node: SceneNode): string[] {\n const runs = styleRunReferences(node.styleRuns)\n const behaviour = readBehaviour(node)\n return [\n ...(node.componentId ? [node.componentId] : []),\n ...Object.values(node.boundVariables),\n ...(behaviour ? transitionVariableIds(behaviour) : []),\n ...slideVariableIds(node),\n ...runs.variables,\n ...referencedStyleIds(node),\n ...Object.entries(node.componentPropertyAssignments).flatMap(([id, value]) => [id, value]),\n ...node.componentPropertyReferences.map((reference) => reference.propertyId),\n ...node.componentPropertyDefinitions.flatMap((definition) => [\n definition.id,\n ...(definition.type === 'INSTANCE_SWAP' && definition.defaultValue\n ? [definition.defaultValue]\n : [])\n ]),\n ...node.instanceOverrides.descendants.keys(),\n ...[\n ...node.instanceOverrides.self,\n ...[...node.instanceOverrides.descendants.values()].flatMap((fields) => [...fields])\n ].flatMap(([field, value]) =>\n typeof value === 'string' &&\n (field === 'componentId' ||\n field === 'sourceComponentId' ||\n overriddenBindingField(field) !== null)\n ? [value]\n : []\n )\n ]\n}\n\nexport interface NodeTransferReferences extends VariableTransferReferences {\n nodes: ReadonlyMap<string, string>\n styles: ReadonlyMap<string, string>\n properties: ReadonlyMap<string, string>\n propertyTypes: ReadonlyMap<string, ComponentPropertyType>\n}\n\n/** Prepare runtime references without rewriting original format identities or ordinary text. */\nexport function prepareNodeTransfer(\n source: SceneNode,\n refs: NodeTransferReferences\n): Partial<SceneNode> {\n const node = (id: string) => required(refs.nodes, id, 'node')\n const variable = (id: string) => required(refs.variables, id, 'variable')\n const property = (id: string) => required(refs.properties, id, 'property')\n const style = (id: string) => required(refs.styles, id, 'style')\n const propertyValue = (id: string, value: string): string => {\n const type = refs.propertyTypes.get(id)\n if (!type) throw new Error(`Missing property transfer type: ${id}`)\n return type === 'INSTANCE_SWAP' && value ? node(value) : value\n }\n const values = (entries: Record<string, string>) =>\n Object.fromEntries(\n Object.entries(entries).map(([id, value]) => [property(id), propertyValue(id, value)])\n )\n const result = cloneNodeProps(source, null)\n result.componentId = source.componentId ? node(source.componentId) : null\n result.instanceOverrides = remapInstanceOverrideState(source.instanceOverrides, {\n node,\n variable,\n collection: (id) => refs.collections.get(id),\n property: (id) => refs.properties.get(id)\n })\n Object.assign(\n result,\n remappedResourceReferences(source, {\n variable,\n collection: (id) => required(refs.collections, id, 'collection'),\n mode: (id) => required(refs.modes, id, 'mode'),\n style,\n // A link to a layer the transfer leaves behind keeps naming it.\n layer: (id) => refs.nodes.get(id) ?? id\n })\n )\n // A connector keeps the layers it was attached to when they are left behind; the end becomes\n // free where nothing by that ID exists, as a pasted Figma connector does.\n for (const field of ['connectorStart', 'connectorEnd'] as const) {\n const endpoint = result[field]\n if (endpoint?.nodeId) endpoint.nodeId = refs.nodes.get(endpoint.nodeId) ?? endpoint.nodeId\n }\n result.componentPropertyDefinitions = source.componentPropertyDefinitions.map((definition) => ({\n ...structuredClone(definition),\n id: property(definition.id),\n defaultValue: propertyValue(definition.id, definition.defaultValue)\n }))\n // A reference to a property that neither the transfer nor its destination defines names nothing.\n result.componentPropertyReferences = source.componentPropertyReferences.flatMap((reference) => {\n const propertyId = refs.properties.get(reference.propertyId)\n return propertyId ? [{ ...reference, propertyId }] : []\n })\n result.componentPropertyAssignments = values(source.componentPropertyAssignments)\n // A behaviour's transition follows the variables the copy brings; one it left behind is let go,\n // and the transition keeps its own value.\n const behaviour = readBehaviour(source)\n if (behaviour && transitionVariableIds(behaviour).length > 0)\n result.pluginData = withBehaviour(\n source,\n mapTransitionVariables(behaviour, (id) => refs.variables.get(id))\n )\n // So do a slide's transition and a layer's animation.\n if (slideVariableIds(source).length > 0)\n Object.assign(\n result,\n mapSlideVariables(source, (id) => refs.variables.get(id))\n )\n // Variant values are keyed by display names, unlike definition-ID assignments.\n result.componentPropertyValues = { ...source.componentPropertyValues }\n return result\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,2BAA2B,MAA2B;CACpE,MAAM,OAAO,mBAAmB,KAAK,SAAS;CAC9C,MAAM,YAAY,cAAc,IAAI;CACpC,OAAO;EACL,GAAI,KAAK,cAAc,CAAC,KAAK,WAAW,IAAI,CAAC;EAC7C,GAAG,OAAO,OAAO,KAAK,cAAc;EACpC,GAAI,YAAY,sBAAsB,SAAS,IAAI,CAAC;EACpD,GAAG,iBAAiB,IAAI;EACxB,GAAG,KAAK;EACR,GAAG,mBAAmB,IAAI;EAC1B,GAAG,OAAO,QAAQ,KAAK,4BAA4B,CAAC,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,IAAI,KAAK,CAAC;EACzF,GAAG,KAAK,4BAA4B,KAAK,cAAc,UAAU,UAAU;EAC3E,GAAG,KAAK,6BAA6B,SAAS,eAAe,CAC3D,WAAW,IACX,GAAI,WAAW,SAAS,mBAAmB,WAAW,eAClD,CAAC,WAAW,YAAY,IACxB,CAAC,CACP,CAAC;EACD,GAAG,KAAK,kBAAkB,YAAY,KAAK;EAC3C,GAAG,CACD,GAAG,KAAK,kBAAkB,MAC1B,GAAG,CAAC,GAAG,KAAK,kBAAkB,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,MAAM,CAAC,CACrF,CAAC,CAAC,SAAS,CAAC,OAAO,WACjB,OAAO,UAAU,aAChB,UAAU,iBACT,UAAU,uBACV,uBAAuB,KAAK,MAAM,QAChC,CAAC,KAAK,IACN,CAAC,CACP;CACF;AACF;;AAUA,SAA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,OAAO,6BAA6B,KAAK,gBAAgB;EAC7F,GAAG,gBAAgB,UAAU;EAC7B,IAAI,SAAS,WAAW,EAAE;EAC1B,cAAc,cAAc,WAAW,IAAI,WAAW,YAAY;CACpE,EAAE;CAEF,OAAO,8BAA8B,OAAO,4BAA4B,SAAS,cAAc;EAC7F,MAAM,aAAa,KAAK,WAAW,IAAI,UAAU,UAAU;EAC3D,OAAO,aAAa,CAAC;GAAE,GAAG;GAAW;EAAW,CAAC,IAAI,CAAC;CACxD,CAAC;CACD,OAAO,+BAA+B,OAAO,OAAO,4BAA4B;CAGhF,MAAM,YAAY,cAAc,MAAM;CACtC,IAAI,aAAa,sBAAsB,SAAS,CAAC,CAAC,SAAS,GACzD,OAAO,aAAa,cAClB,QACA,uBAAuB,YAAY,OAAO,KAAK,UAAU,IAAI,EAAE,CAAC,CAClE;CAEF,IAAI,iBAAiB,MAAM,CAAC,CAAC,SAAS,GACpC,OAAO,OACL,QACA,kBAAkB,SAAS,OAAO,KAAK,UAAU,IAAI,EAAE,CAAC,CAC1D;CAEF,OAAO,0BAA0B,EAAE,GAAG,OAAO,wBAAwB;CACrE,OAAO;AACT"}
|
package/dist/transfer/plan.d.ts
CHANGED
|
@@ -13,6 +13,15 @@ declare function prepareGraphTransfer(input: GraphTransferInput): {
|
|
|
13
13
|
images: Map<string, Uint8Array<ArrayBuffer>>;
|
|
14
14
|
variables: Variable[];
|
|
15
15
|
collections: VariableCollection[];
|
|
16
|
+
joined: {
|
|
17
|
+
collectionId: string;
|
|
18
|
+
variableId: string;
|
|
19
|
+
}[];
|
|
20
|
+
reused: {
|
|
21
|
+
collections: string[];
|
|
22
|
+
variables: string[];
|
|
23
|
+
styles: string[];
|
|
24
|
+
};
|
|
16
25
|
nodeIds: Map<string, string>;
|
|
17
26
|
rootIds: string[];
|
|
18
27
|
dependencyPageIds: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","names":[],"sources":["../../src/transfer/plan.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plan.d.ts","names":[],"sources":["../../src/transfer/plan.ts"],"mappings":";;;UAYiB;EACf,QAAQ;EACR;EACA;EACA,QAAQ;EACR;;;iBAsEc,qBAAqB,OAAO"}
|
package/dist/transfer/plan.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sharedStyleLayers } from "../shared-styles.js";
|
|
2
2
|
import { prepareNodeTransfer } from "./nodes.js";
|
|
3
3
|
import { prepareVariableTransfer } from "./variables.js";
|
|
4
|
+
import { libraryModeOf, matchLibraryResources, withoutLibraryKey } from "./library.js";
|
|
4
5
|
//#region src/transfer/plan.ts
|
|
5
6
|
/** A transferred style's props under the ID the transfer gives it. */
|
|
6
7
|
function withStyleId(node, props, styles) {
|
|
@@ -14,6 +15,43 @@ function withStyleId(node, props, styles) {
|
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The variables and collections a transfer adds, given what the target holds of them: nothing
|
|
20
|
+
* for a copy it holds, and a variable new to a library collection it holds joins that one. A
|
|
21
|
+
* copy that cannot take the place of the target's becomes the target's own, without its key,
|
|
22
|
+
* and a library collection new to the target remembers each library mode, so that a later
|
|
23
|
+
* transfer of it pairs its modes exactly.
|
|
24
|
+
*/
|
|
25
|
+
function libraryResources(prepared, sourceCollections, references, reuse) {
|
|
26
|
+
const mapped = (id) => references.variables.get(id) ?? references.collections.get(id);
|
|
27
|
+
const local = new Set([...reuse.local].map(mapped));
|
|
28
|
+
const reused = {
|
|
29
|
+
collections: [...new Set(reuse.collections.values())],
|
|
30
|
+
variables: [...new Set(reuse.variables.values())],
|
|
31
|
+
styles: [...new Set(reuse.styles.values())]
|
|
32
|
+
};
|
|
33
|
+
const heldCollections = new Set(reused.collections);
|
|
34
|
+
const heldVariables = new Set(reused.variables);
|
|
35
|
+
const own = (item) => local.has(item.id) ? withoutLibraryKey(item) : item;
|
|
36
|
+
const libraryModes = new Map(sourceCollections.flatMap((collection) => collection.key ? collection.modes.map((mode) => [references.modes.get(mode.modeId), libraryModeOf(mode)]) : []));
|
|
37
|
+
const collections = prepared.collections.filter((collection) => !heldCollections.has(collection.id)).map(own).map((collection) => collection.key ? {
|
|
38
|
+
...collection,
|
|
39
|
+
modes: collection.modes.map((mode) => ({
|
|
40
|
+
...mode,
|
|
41
|
+
libraryModeId: libraryModes.get(mode.modeId)
|
|
42
|
+
}))
|
|
43
|
+
} : collection);
|
|
44
|
+
const variables = prepared.variables.filter((variable) => !heldVariables.has(variable.id)).map(own);
|
|
45
|
+
return {
|
|
46
|
+
variables,
|
|
47
|
+
collections,
|
|
48
|
+
joined: variables.filter((variable) => heldCollections.has(variable.collectionId)).map((variable) => ({
|
|
49
|
+
collectionId: variable.collectionId,
|
|
50
|
+
variableId: variable.id
|
|
51
|
+
})),
|
|
52
|
+
reused
|
|
53
|
+
};
|
|
54
|
+
}
|
|
17
55
|
/** Preflight a self-contained fragment; allocation does not insert anything into the target. */
|
|
18
56
|
function prepareGraphTransfer(input) {
|
|
19
57
|
const { source, target, parentId } = input;
|
|
@@ -32,6 +70,13 @@ function prepareGraphTransfer(input) {
|
|
|
32
70
|
reserved.add(id);
|
|
33
71
|
return id;
|
|
34
72
|
};
|
|
73
|
+
const targetStyles = sharedStyleLayers(target);
|
|
74
|
+
const reuse = matchLibraryResources(target, {
|
|
75
|
+
collections: source.variableCollections.values(),
|
|
76
|
+
variables: source.variables.values(),
|
|
77
|
+
styles: sharedStyleLayers(source).values()
|
|
78
|
+
}, targetStyles);
|
|
79
|
+
const reusedStyle = (node) => node.sharedStyleType !== null && !!node.source.id && reuse.styles.has(node.source.id);
|
|
35
80
|
const ordered = [];
|
|
36
81
|
const seen = /* @__PURE__ */ new Set();
|
|
37
82
|
const visit = (id) => {
|
|
@@ -39,15 +84,16 @@ function prepareGraphTransfer(input) {
|
|
|
39
84
|
const node = source.getNode(id);
|
|
40
85
|
if (!node) throw new Error(`Missing transfer source ${id}`);
|
|
41
86
|
seen.add(id);
|
|
87
|
+
if (reusedStyle(node)) return;
|
|
42
88
|
ordered.push(node);
|
|
43
89
|
for (const child of node.childIds) visit(child);
|
|
44
90
|
};
|
|
45
91
|
for (const id of [...input.dependencyPageIds, ...input.rootIds]) visit(id);
|
|
46
92
|
const nodes = new Map(ordered.map((node) => [node.id, allocate()]));
|
|
47
|
-
const variables = new Map([...source.variables.keys()].map((id) => [id, allocate()]));
|
|
48
|
-
const collections = new Map([...source.variableCollections.keys()].map((id) => [id, allocate()]));
|
|
93
|
+
const variables = new Map([...source.variables.keys()].map((id) => [id, reuse.variables.get(id) ?? allocate()]));
|
|
94
|
+
const collections = new Map([...source.variableCollections.keys()].map((id) => [id, reuse.collections.get(id) ?? allocate()]));
|
|
49
95
|
const modes = /* @__PURE__ */ new Map();
|
|
50
|
-
for (const collection of source.variableCollections.values()) for (const mode of collection.modes) if (!modes.has(mode.modeId)) modes.set(mode.modeId, allocate());
|
|
96
|
+
for (const collection of source.variableCollections.values()) for (const mode of collection.modes) if (!modes.has(mode.modeId)) modes.set(mode.modeId, reuse.modes.get(mode.modeId) ?? allocate());
|
|
51
97
|
const properties = /* @__PURE__ */ new Map();
|
|
52
98
|
const propertyTypes = /* @__PURE__ */ new Map();
|
|
53
99
|
for (const node of ordered) for (const definition of node.componentPropertyDefinitions) {
|
|
@@ -55,8 +101,7 @@ function prepareGraphTransfer(input) {
|
|
|
55
101
|
propertyTypes.set(definition.id, definition.type);
|
|
56
102
|
if (!properties.has(definition.id)) properties.set(definition.id, allocate());
|
|
57
103
|
}
|
|
58
|
-
const
|
|
59
|
-
const styles = /* @__PURE__ */ new Map();
|
|
104
|
+
const styles = new Map(reuse.styles);
|
|
60
105
|
for (const node of ordered) {
|
|
61
106
|
const id = node.source.id;
|
|
62
107
|
if (node.sharedStyleType === null || !id) continue;
|
|
@@ -71,7 +116,7 @@ function prepareGraphTransfer(input) {
|
|
|
71
116
|
propertyTypes,
|
|
72
117
|
styles
|
|
73
118
|
};
|
|
74
|
-
const resources = prepareVariableTransfer([...source.variables.values()], [...source.variableCollections.values()], references);
|
|
119
|
+
const resources = libraryResources(prepareVariableTransfer([...source.variables.values()], [...source.variableCollections.values()], references), [...source.variableCollections.values()], references, reuse);
|
|
75
120
|
const mapped = (id) => {
|
|
76
121
|
const value = nodes.get(id);
|
|
77
122
|
if (!value) throw new Error(`Missing transfer node mapping ${id}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","names":[],"sources":["../../src/transfer/plan.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport { sharedStyleLayers } from '../shared-styles'\nimport type { ComponentPropertyType, SceneNode } from '../types'\nimport { prepareNodeTransfer } from './nodes'\nimport { prepareVariableTransfer } from './variables'\n\nexport interface GraphTransferInput {\n source: SceneGraph\n rootIds: readonly string[]\n dependencyPageIds: readonly string[]\n target: SceneGraph\n parentId: string\n}\n\n/** A transferred style's props under the ID the transfer gives it. */\nfunction withStyleId(\n node: SceneNode,\n props: Partial<SceneNode>,\n styles: ReadonlyMap<string, string>\n): Partial<SceneNode> {\n const id =\n node.sharedStyleType !== null && node.source.id ? styles.get(node.source.id) : undefined\n if (!id || id === node.source.id) return props\n return { ...props, source: { ...(props.source ?? node.source), id } }\n}\n\n/** Preflight a self-contained fragment; allocation does not insert anything into the target. */\nexport function prepareGraphTransfer(input: GraphTransferInput) {\n const { source, target, parentId } = input\n if (!target.getNode(parentId)) throw new Error(`Missing transfer parent ${parentId}`)\n const reserved = new Set([\n ...target.nodes.keys(),\n ...target.variables.keys(),\n ...target.variableCollections.keys()\n ])\n for (const collection of target.variableCollections.values())\n for (const mode of collection.modes) reserved.add(mode.modeId)\n let sequence = 0\n const namespace = crypto.randomUUID()\n const allocate = (): string => {\n let id = `${namespace}:${sequence++}`\n while (reserved.has(id)) id = `${namespace}:${sequence++}`\n reserved.add(id)\n return id\n }\n const ordered: SceneNode[] = []\n const seen = new Set<string>()\n const visit = (id: string): void => {\n if (seen.has(id)) throw new Error(`Repeated transfer node ${id}`)\n const node = source.getNode(id)\n if (!node) throw new Error(`Missing transfer source ${id}`)\n seen.add(id)\n ordered.push(node)\n for (const child of node.childIds) visit(child)\n }\n for (const id of [...input.dependencyPageIds, ...input.rootIds]) visit(id)\n const nodes = new Map(ordered.map((node) => [node.id, allocate()]))\n const variables = new Map([...source.variables.keys()].map((id) => [id, allocate()]))\n const collections = new Map([...source.variableCollections.keys()].map((id) => [id, allocate()]))\n const modes = new Map<string, string>()\n for (const collection of source.variableCollections.values()) {\n for (const mode of collection.modes)\n if (!modes.has(mode.modeId)) modes.set(mode.modeId, allocate())\n }\n const properties = new Map<string, string>()\n const propertyTypes = new Map<string, ComponentPropertyType>()\n for (const node of ordered)\n for (const definition of node.componentPropertyDefinitions) {\n if (propertyTypes.has(definition.id) && propertyTypes.get(definition.id) !== definition.type)\n throw new Error(`Conflicting property type ${definition.id}`)\n propertyTypes.set(definition.id, definition.type)\n if (!properties.has(definition.id)) properties.set(definition.id, allocate())\n }\n // Layers name a style by the style's own ID, which a transferred style keeps unless the\n // target already holds another style by it: IDs read from Figma are only unique in one file.\n const targetStyles = sharedStyleLayers(target)\n const styles = new Map<string, string>()\n for (const node of ordered) {\n const id = node.source.id\n if (node.sharedStyleType === null || !id) continue\n styles.set(id, targetStyles.has(id) ? allocate() : id)\n }\n const references = {\n nodes,\n variables,\n collections,\n modes,\n properties,\n propertyTypes,\n styles\n }\n const resources = prepareVariableTransfer(\n [...source.variables.values()],\n [...source.variableCollections.values()],\n references\n )\n const mapped = (id: string): string => {\n const value = nodes.get(id)\n if (!value) throw new Error(`Missing transfer node mapping ${id}`)\n return value\n }\n const roots = new Set(input.rootIds)\n const dependencies = new Set(input.dependencyPageIds)\n const destinationParent = (node: SceneNode): string => {\n if (roots.has(node.id)) return parentId\n if (dependencies.has(node.id)) return target.rootId\n return mapped(node.parentId ?? '')\n }\n return {\n nodeIds: nodes,\n rootIds: input.rootIds.map(mapped),\n dependencyPageIds: input.dependencyPageIds.map(mapped),\n nodes: ordered.map((node) => ({\n id: mapped(node.id),\n type: node.type,\n parentId: destinationParent(node),\n props: withStyleId(node, prepareNodeTransfer(node, references), styles)\n })),\n ...resources,\n images: new Map([...source.images].map(([hash, bytes]) => [hash, bytes.slice()]))\n }\n}\n"],"mappings":";;;;;AAeA,SAAS,YACP,MACA,OACA,QACoB;CACpB,MAAM,KACJ,KAAK,oBAAoB,QAAQ,KAAK,OAAO,KAAK,OAAO,IAAI,KAAK,OAAO,EAAE,IAAI,KAAA;CACjF,IAAI,CAAC,MAAM,OAAO,KAAK,OAAO,IAAI,OAAO;CACzC,OAAO;EAAE,GAAG;EAAO,QAAQ;GAAE,GAAI,MAAM,UAAU,KAAK;GAAS;EAAG;CAAE;AACtE;;AAGA,SAAgB,qBAAqB,OAA2B;CAC9D,MAAM,EAAE,QAAQ,QAAQ,aAAa;CACrC,IAAI,CAAC,OAAO,QAAQ,QAAQ,GAAG,MAAM,IAAI,MAAM,2BAA2B,UAAU;CACpF,MAAM,2BAAW,IAAI,IAAI;EACvB,GAAG,OAAO,MAAM,KAAK;EACrB,GAAG,OAAO,UAAU,KAAK;EACzB,GAAG,OAAO,oBAAoB,KAAK;CACrC,CAAC;CACD,KAAK,MAAM,cAAc,OAAO,oBAAoB,OAAO,GACzD,KAAK,MAAM,QAAQ,WAAW,OAAO,SAAS,IAAI,KAAK,MAAM;CAC/D,IAAI,WAAW;CACf,MAAM,YAAY,OAAO,WAAW;CACpC,MAAM,iBAAyB;EAC7B,IAAI,KAAK,GAAG,UAAU,GAAG;EACzB,OAAO,SAAS,IAAI,EAAE,GAAG,KAAK,GAAG,UAAU,GAAG;EAC9C,SAAS,IAAI,EAAE;EACf,OAAO;CACT;CACA,MAAM,UAAuB,CAAC;CAC9B,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAAS,OAAqB;EAClC,IAAI,KAAK,IAAI,EAAE,GAAG,MAAM,IAAI,MAAM,0BAA0B,IAAI;EAChE,M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
{"version":3,"file":"plan.js","names":[],"sources":["../../src/transfer/plan.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport { sharedStyleLayers } from '../shared-styles'\nimport type { ComponentPropertyType, SceneNode, Variable, VariableCollection } from '../types'\nimport {\n libraryModeOf,\n matchLibraryResources,\n withoutLibraryKey,\n type LibraryReuse\n} from './library'\nimport { prepareNodeTransfer } from './nodes'\nimport { prepareVariableTransfer, type VariableTransferReferences } from './variables'\n\nexport interface GraphTransferInput {\n source: SceneGraph\n rootIds: readonly string[]\n dependencyPageIds: readonly string[]\n target: SceneGraph\n parentId: string\n}\n\n/** A transferred style's props under the ID the transfer gives it. */\nfunction withStyleId(\n node: SceneNode,\n props: Partial<SceneNode>,\n styles: ReadonlyMap<string, string>\n): Partial<SceneNode> {\n const id =\n node.sharedStyleType !== null && node.source.id ? styles.get(node.source.id) : undefined\n if (!id || id === node.source.id) return props\n return { ...props, source: { ...(props.source ?? node.source), id } }\n}\n\n/**\n * The variables and collections a transfer adds, given what the target holds of them: nothing\n * for a copy it holds, and a variable new to a library collection it holds joins that one. A\n * copy that cannot take the place of the target's becomes the target's own, without its key,\n * and a library collection new to the target remembers each library mode, so that a later\n * transfer of it pairs its modes exactly.\n */\nfunction libraryResources(\n prepared: { variables: Variable[]; collections: VariableCollection[] },\n sourceCollections: readonly VariableCollection[],\n references: VariableTransferReferences,\n reuse: LibraryReuse\n) {\n const mapped = (id: string) => references.variables.get(id) ?? references.collections.get(id)\n const local = new Set([...reuse.local].map(mapped))\n const reused = {\n collections: [...new Set(reuse.collections.values())],\n variables: [...new Set(reuse.variables.values())],\n styles: [...new Set(reuse.styles.values())]\n }\n const heldCollections = new Set(reused.collections)\n const heldVariables = new Set(reused.variables)\n const own = <T extends { id: string; key?: string; version?: string }>(item: T): T =>\n local.has(item.id) ? withoutLibraryKey(item) : item\n const libraryModes = new Map(\n sourceCollections.flatMap((collection) =>\n collection.key\n ? collection.modes.map((mode) => [references.modes.get(mode.modeId), libraryModeOf(mode)])\n : []\n )\n )\n const collections = prepared.collections\n .filter((collection) => !heldCollections.has(collection.id))\n .map(own)\n .map((collection) =>\n collection.key\n ? {\n ...collection,\n modes: collection.modes.map((mode) => ({\n ...mode,\n libraryModeId: libraryModes.get(mode.modeId)\n }))\n }\n : collection\n )\n const variables = prepared.variables\n .filter((variable) => !heldVariables.has(variable.id))\n .map(own)\n const joined = variables\n .filter((variable) => heldCollections.has(variable.collectionId))\n .map((variable) => ({ collectionId: variable.collectionId, variableId: variable.id }))\n return { variables, collections, joined, reused }\n}\n\n/** Preflight a self-contained fragment; allocation does not insert anything into the target. */\nexport function prepareGraphTransfer(input: GraphTransferInput) {\n const { source, target, parentId } = input\n if (!target.getNode(parentId)) throw new Error(`Missing transfer parent ${parentId}`)\n const reserved = new Set([\n ...target.nodes.keys(),\n ...target.variables.keys(),\n ...target.variableCollections.keys()\n ])\n for (const collection of target.variableCollections.values())\n for (const mode of collection.modes) reserved.add(mode.modeId)\n let sequence = 0\n const namespace = crypto.randomUUID()\n const allocate = (): string => {\n let id = `${namespace}:${sequence++}`\n while (reserved.has(id)) id = `${namespace}:${sequence++}`\n reserved.add(id)\n return id\n }\n const targetStyles = sharedStyleLayers(target)\n const reuse = matchLibraryResources(\n target,\n {\n collections: source.variableCollections.values(),\n variables: source.variables.values(),\n styles: sharedStyleLayers(source).values()\n },\n targetStyles\n )\n const reusedStyle = (node: SceneNode) =>\n node.sharedStyleType !== null && !!node.source.id && reuse.styles.has(node.source.id)\n const ordered: SceneNode[] = []\n const seen = new Set<string>()\n const visit = (id: string): void => {\n if (seen.has(id)) throw new Error(`Repeated transfer node ${id}`)\n const node = source.getNode(id)\n if (!node) throw new Error(`Missing transfer source ${id}`)\n seen.add(id)\n // Layers name the target's copy of a library style it already holds instead.\n if (reusedStyle(node)) return\n ordered.push(node)\n for (const child of node.childIds) visit(child)\n }\n for (const id of [...input.dependencyPageIds, ...input.rootIds]) visit(id)\n const nodes = new Map(ordered.map((node) => [node.id, allocate()]))\n const variables = new Map(\n [...source.variables.keys()].map((id) => [id, reuse.variables.get(id) ?? allocate()])\n )\n const collections = new Map(\n [...source.variableCollections.keys()].map((id) => [\n id,\n reuse.collections.get(id) ?? allocate()\n ])\n )\n const modes = new Map<string, string>()\n for (const collection of source.variableCollections.values()) {\n for (const mode of collection.modes)\n if (!modes.has(mode.modeId))\n modes.set(mode.modeId, reuse.modes.get(mode.modeId) ?? allocate())\n }\n const properties = new Map<string, string>()\n const propertyTypes = new Map<string, ComponentPropertyType>()\n for (const node of ordered)\n for (const definition of node.componentPropertyDefinitions) {\n if (propertyTypes.has(definition.id) && propertyTypes.get(definition.id) !== definition.type)\n throw new Error(`Conflicting property type ${definition.id}`)\n propertyTypes.set(definition.id, definition.type)\n if (!properties.has(definition.id)) properties.set(definition.id, allocate())\n }\n // Layers name a style by the style's own ID, which a transferred style keeps unless the\n // target already holds another style by it: IDs read from Figma are only unique in one file.\n const styles = new Map(reuse.styles)\n for (const node of ordered) {\n const id = node.source.id\n if (node.sharedStyleType === null || !id) continue\n styles.set(id, targetStyles.has(id) ? allocate() : id)\n }\n const references = {\n nodes,\n variables,\n collections,\n modes,\n properties,\n propertyTypes,\n styles\n }\n const resources = libraryResources(\n prepareVariableTransfer(\n [...source.variables.values()],\n [...source.variableCollections.values()],\n references\n ),\n [...source.variableCollections.values()],\n references,\n reuse\n )\n const mapped = (id: string): string => {\n const value = nodes.get(id)\n if (!value) throw new Error(`Missing transfer node mapping ${id}`)\n return value\n }\n const roots = new Set(input.rootIds)\n const dependencies = new Set(input.dependencyPageIds)\n const destinationParent = (node: SceneNode): string => {\n if (roots.has(node.id)) return parentId\n if (dependencies.has(node.id)) return target.rootId\n return mapped(node.parentId ?? '')\n }\n return {\n nodeIds: nodes,\n rootIds: input.rootIds.map(mapped),\n dependencyPageIds: input.dependencyPageIds.map(mapped),\n nodes: ordered.map((node) => ({\n id: mapped(node.id),\n type: node.type,\n parentId: destinationParent(node),\n props: withStyleId(node, prepareNodeTransfer(node, references), styles)\n })),\n ...resources,\n images: new Map([...source.images].map(([hash, bytes]) => [hash, bytes.slice()]))\n }\n}\n"],"mappings":";;;;;;AAqBA,SAAS,YACP,MACA,OACA,QACoB;CACpB,MAAM,KACJ,KAAK,oBAAoB,QAAQ,KAAK,OAAO,KAAK,OAAO,IAAI,KAAK,OAAO,EAAE,IAAI,KAAA;CACjF,IAAI,CAAC,MAAM,OAAO,KAAK,OAAO,IAAI,OAAO;CACzC,OAAO;EAAE,GAAG;EAAO,QAAQ;GAAE,GAAI,MAAM,UAAU,KAAK;GAAS;EAAG;CAAE;AACtE;;;;;;;;AASA,SAAS,iBACP,UACA,mBACA,YACA,OACA;CACA,MAAM,UAAU,OAAe,WAAW,UAAU,IAAI,EAAE,KAAK,WAAW,YAAY,IAAI,EAAE;CAC5F,MAAM,QAAQ,IAAI,IAAI,CAAC,GAAG,MAAM,KAAK,CAAC,CAAC,IAAI,MAAM,CAAC;CAClD,MAAM,SAAS;EACb,aAAa,CAAC,GAAG,IAAI,IAAI,MAAM,YAAY,OAAO,CAAC,CAAC;EACpD,WAAW,CAAC,GAAG,IAAI,IAAI,MAAM,UAAU,OAAO,CAAC,CAAC;EAChD,QAAQ,CAAC,GAAG,IAAI,IAAI,MAAM,OAAO,OAAO,CAAC,CAAC;CAC5C;CACA,MAAM,kBAAkB,IAAI,IAAI,OAAO,WAAW;CAClD,MAAM,gBAAgB,IAAI,IAAI,OAAO,SAAS;CAC9C,MAAM,OAAiE,SACrE,MAAM,IAAI,KAAK,EAAE,IAAI,kBAAkB,IAAI,IAAI;CACjD,MAAM,eAAe,IAAI,IACvB,kBAAkB,SAAS,eACzB,WAAW,MACP,WAAW,MAAM,KAAK,SAAS,CAAC,WAAW,MAAM,IAAI,KAAK,MAAM,GAAG,cAAc,IAAI,CAAC,CAAC,IACvF,CAAC,CACP,CACF;CACA,MAAM,cAAc,SAAS,YAC1B,QAAQ,eAAe,CAAC,gBAAgB,IAAI,WAAW,EAAE,CAAC,CAAC,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