@open-pencil/scene-graph 0.17.0-beta.1 → 0.17.0-beta.3
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/arrow-caps.d.ts.map +1 -1
- package/dist/arrow-caps.js +2 -5
- package/dist/arrow-caps.js.map +1 -1
- package/dist/asset-keys.d.ts +11 -1
- package/dist/asset-keys.d.ts.map +1 -1
- package/dist/asset-keys.js +16 -1
- package/dist/asset-keys.js.map +1 -1
- package/dist/behaviours/index.d.ts +2 -2
- package/dist/behaviours/index.js +2 -2
- package/dist/behaviours/kinds.d.ts +11 -5
- package/dist/behaviours/kinds.d.ts.map +1 -1
- package/dist/behaviours/kinds.js +76 -75
- package/dist/behaviours/kinds.js.map +1 -1
- package/dist/behaviours/layers.d.ts.map +1 -1
- package/dist/behaviours/layers.js +3 -2
- package/dist/behaviours/layers.js.map +1 -1
- package/dist/behaviours/model.d.ts +7 -4
- package/dist/behaviours/model.d.ts.map +1 -1
- package/dist/behaviours/model.js +16 -9
- package/dist/behaviours/model.js.map +1 -1
- package/dist/behaviours/schema.d.ts +118 -4
- package/dist/behaviours/schema.d.ts.map +1 -1
- package/dist/behaviours/schema.js +18 -3
- package/dist/behaviours/schema.js.map +1 -1
- package/dist/behaviours/spec.d.ts.map +1 -1
- package/dist/behaviours/spec.js +3 -2
- package/dist/behaviours/spec.js.map +1 -1
- package/dist/bindings.js +9 -1
- package/dist/bindings.js.map +1 -1
- package/dist/checkpoint.d.ts +31 -2
- package/dist/checkpoint.d.ts.map +1 -1
- package/dist/checkpoint.js +211 -10
- package/dist/checkpoint.js.map +1 -1
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +3 -3
- package/dist/components/properties.d.ts +18 -1
- package/dist/components/properties.d.ts.map +1 -1
- package/dist/components/properties.js +66 -3
- package/dist/components/properties.js.map +1 -1
- package/dist/components/variants.d.ts +16 -10
- package/dist/components/variants.d.ts.map +1 -1
- package/dist/components/variants.js +39 -13
- package/dist/components/variants.js.map +1 -1
- package/dist/connectors/hit.d.ts.map +1 -1
- package/dist/connectors/hit.js +1 -7
- package/dist/connectors/hit.js.map +1 -1
- package/dist/connectors/pieces.d.ts.map +1 -1
- package/dist/connectors/pieces.js +2 -5
- package/dist/connectors/pieces.js.map +1 -1
- package/dist/constants.d.ts +6 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +17 -1
- package/dist/constants.js.map +1 -1
- package/dist/constraints.d.ts +25 -0
- package/dist/constraints.d.ts.map +1 -0
- package/dist/constraints.js +51 -0
- package/dist/constraints.js.map +1 -0
- package/dist/coordinate.d.ts +64 -1
- package/dist/coordinate.d.ts.map +1 -1
- package/dist/coordinate.js +217 -1
- package/dist/coordinate.js.map +1 -1
- package/dist/copy.d.ts.map +1 -1
- package/dist/copy.js +17 -16
- package/dist/copy.js.map +1 -1
- package/dist/css/blend.d.ts +11 -0
- package/dist/css/blend.d.ts.map +1 -0
- package/dist/css/blend.js +30 -0
- package/dist/css/blend.js.map +1 -0
- package/dist/css/index.d.ts +4 -2
- package/dist/css/index.js +4 -2
- package/dist/css/text.d.ts +28 -1
- package/dist/css/text.d.ts.map +1 -1
- package/dist/css/text.js +84 -17
- package/dist/css/text.js.map +1 -1
- package/dist/css/transform.d.ts +34 -0
- package/dist/css/transform.d.ts.map +1 -0
- package/dist/css/transform.js +320 -0
- package/dist/css/transform.js.map +1 -0
- package/dist/css/values.d.ts.map +1 -1
- package/dist/css/values.js +11 -1
- package/dist/css/values.js.map +1 -1
- package/dist/cubic.d.ts +7 -0
- package/dist/cubic.d.ts.map +1 -0
- package/dist/cubic.js +17 -0
- package/dist/cubic.js.map +1 -0
- package/dist/export-format.d.ts +14 -1
- package/dist/export-format.d.ts.map +1 -1
- package/dist/export-format.js +26 -1
- package/dist/export-format.js.map +1 -1
- package/dist/fields/text.d.ts +2 -2
- package/dist/fields/text.d.ts.map +1 -1
- package/dist/fields/text.js +2 -1
- package/dist/fields/text.js.map +1 -1
- package/dist/figjam/index.d.ts +2 -2
- package/dist/figjam/index.js +2 -2
- package/dist/figjam/palette.d.ts +13 -2
- package/dist/figjam/palette.d.ts.map +1 -1
- package/dist/figjam/palette.js +30 -2
- package/dist/figjam/palette.js.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +2 -2
- package/dist/generated/shape-with-text.d.ts +7 -2
- package/dist/generated/shape-with-text.d.ts.map +1 -1
- package/dist/generated/shape-with-text.js +20 -3
- package/dist/generated/shape-with-text.js.map +1 -1
- package/dist/geometry.d.ts +37 -46
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +80 -137
- package/dist/geometry.js.map +1 -1
- package/dist/graph.d.ts +49 -12
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +125 -27
- package/dist/graph.js.map +1 -1
- package/dist/group-bounds.d.ts +14 -4
- package/dist/group-bounds.d.ts.map +1 -1
- package/dist/group-bounds.js +76 -11
- package/dist/group-bounds.js.map +1 -1
- package/dist/guides.d.ts +3 -1
- package/dist/guides.d.ts.map +1 -1
- package/dist/guides.js +5 -1
- package/dist/guides.js.map +1 -1
- package/dist/hit-test.d.ts +5 -0
- package/dist/hit-test.d.ts.map +1 -1
- package/dist/hit-test.js +57 -38
- package/dist/hit-test.js.map +1 -1
- package/dist/images.d.ts +27 -3
- package/dist/images.d.ts.map +1 -1
- package/dist/images.js +57 -3
- package/dist/images.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/instances/fields.d.ts +2 -2
- package/dist/instances/fields.d.ts.map +1 -1
- package/dist/instances/fields.js +8 -0
- package/dist/instances/fields.js.map +1 -1
- package/dist/instances/index.d.ts +1 -3
- package/dist/instances/index.d.ts.map +1 -1
- package/dist/instances/index.js +39 -30
- package/dist/instances/index.js.map +1 -1
- package/dist/instances/kept-overrides.js +204 -0
- package/dist/instances/kept-overrides.js.map +1 -0
- package/dist/instances/main-component.d.ts +3 -1
- package/dist/instances/main-component.d.ts.map +1 -1
- package/dist/instances/main-component.js +10 -2
- package/dist/instances/main-component.js.map +1 -1
- package/dist/instances/overrides.d.ts +4 -1
- package/dist/instances/overrides.d.ts.map +1 -1
- package/dist/instances/overrides.js +18 -2
- package/dist/instances/overrides.js.map +1 -1
- package/dist/instances/placement.js +55 -12
- package/dist/instances/placement.js.map +1 -1
- package/dist/instances/swap.js +291 -0
- package/dist/instances/swap.js.map +1 -0
- package/dist/instances/sync.js +112 -39
- package/dist/instances/sync.js.map +1 -1
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +2 -1
- package/dist/node-defaults.js.map +1 -1
- package/dist/order-keys.d.ts +3 -1
- package/dist/order-keys.d.ts.map +1 -1
- package/dist/order-keys.js +6 -1
- package/dist/order-keys.js.map +1 -1
- package/dist/outline/flatten.d.ts +15 -0
- package/dist/outline/flatten.d.ts.map +1 -0
- package/dist/outline/flatten.js +189 -0
- package/dist/outline/flatten.js.map +1 -0
- package/dist/outline/heads.js +34 -0
- package/dist/outline/heads.js.map +1 -0
- package/dist/outline/hit.d.ts +21 -0
- package/dist/outline/hit.d.ts.map +1 -0
- package/dist/outline/hit.js +276 -0
- package/dist/outline/hit.js.map +1 -0
- package/dist/outline/index.d.ts +5 -0
- package/dist/outline/index.js +5 -0
- package/dist/outline/point.d.ts +16 -0
- package/dist/outline/point.d.ts.map +1 -0
- package/dist/outline/point.js +42 -0
- package/dist/outline/point.js.map +1 -0
- package/dist/outline/shapes.d.ts +35 -0
- package/dist/outline/shapes.d.ts.map +1 -0
- package/dist/outline/shapes.js +181 -0
- package/dist/outline/shapes.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +4 -1
- package/dist/plugin-data/fields.d.ts.map +1 -1
- package/dist/plugin-data/fields.js +21 -4
- package/dist/plugin-data/fields.js.map +1 -1
- package/dist/resize.d.ts +22 -11
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +227 -93
- package/dist/resize.js.map +1 -1
- package/dist/scaling/index.d.ts +3 -2
- package/dist/scaling/index.js +3 -2
- package/dist/scaling/node.d.ts.map +1 -1
- package/dist/scaling/node.js +5 -1
- package/dist/scaling/node.js.map +1 -1
- package/dist/scaling/snapshot.d.ts +25 -0
- package/dist/scaling/snapshot.d.ts.map +1 -0
- package/dist/scaling/snapshot.js +39 -0
- package/dist/scaling/snapshot.js.map +1 -0
- package/dist/scaling/tree.d.ts +24 -2
- package/dist/scaling/tree.d.ts.map +1 -1
- package/dist/scaling/tree.js +38 -15
- package/dist/scaling/tree.js.map +1 -1
- package/dist/shaders/model.d.ts.map +1 -1
- package/dist/shaders/model.js +2 -1
- package/dist/shaders/model.js.map +1 -1
- package/dist/shared-styles.d.ts +16 -1
- package/dist/shared-styles.d.ts.map +1 -1
- package/dist/shared-styles.js +69 -2
- package/dist/shared-styles.js.map +1 -1
- package/dist/slots/authoring.d.ts +3 -2
- package/dist/slots/authoring.d.ts.map +1 -1
- package/dist/slots/authoring.js +5 -3
- package/dist/slots/authoring.js.map +1 -1
- package/dist/slots/content.d.ts.map +1 -1
- package/dist/slots/content.js +6 -1
- package/dist/slots/content.js.map +1 -1
- package/dist/slots/frames.d.ts +2 -0
- package/dist/slots/frames.d.ts.map +1 -1
- package/dist/slots/frames.js +7 -2
- package/dist/slots/frames.js.map +1 -1
- package/dist/text/direction.d.ts +3 -1
- package/dist/text/direction.d.ts.map +1 -1
- package/dist/text/direction.js +5 -1
- package/dist/text/direction.js.map +1 -1
- package/dist/text/index.d.ts +2 -2
- package/dist/text/index.js +3 -3
- package/dist/text/lengths.d.ts +6 -1
- package/dist/text/lengths.d.ts.map +1 -1
- package/dist/text/lengths.js +10 -1
- package/dist/text/lengths.js.map +1 -1
- package/dist/text/overflow.d.ts +2 -2
- package/dist/text/overflow.js.map +1 -1
- package/dist/text/picture.d.ts +1 -2
- package/dist/text/picture.d.ts.map +1 -1
- package/dist/text/picture.js +1 -4
- package/dist/text/picture.js.map +1 -1
- package/dist/transfer/apply.d.ts.map +1 -1
- package/dist/transfer/apply.js +1 -6
- package/dist/transfer/apply.js.map +1 -1
- package/dist/transfer/copied.d.ts +35 -3
- package/dist/transfer/copied.d.ts.map +1 -1
- package/dist/transfer/copied.js +44 -13
- package/dist/transfer/copied.js.map +1 -1
- package/dist/transfer/dependencies.d.ts +38 -0
- package/dist/transfer/dependencies.d.ts.map +1 -0
- package/dist/transfer/dependencies.js +100 -0
- package/dist/transfer/dependencies.js.map +1 -0
- package/dist/transfer/history.js +0 -1
- package/dist/transfer/history.js.map +1 -1
- package/dist/transfer/index.d.ts +5 -3
- package/dist/transfer/index.js +5 -3
- package/dist/transfer/nodes.d.ts.map +1 -1
- package/dist/transfer/nodes.js +16 -19
- package/dist/transfer/nodes.js.map +1 -1
- package/dist/transfer/plan.d.ts +0 -1
- package/dist/transfer/plan.js +3 -5
- package/dist/transfer/plan.js.map +1 -1
- package/dist/transfer/remove.js +5 -2
- package/dist/transfer/remove.js.map +1 -1
- package/dist/transfer/resources.d.ts +21 -0
- package/dist/transfer/resources.d.ts.map +1 -0
- package/dist/transfer/resources.js +38 -0
- package/dist/transfer/resources.js.map +1 -0
- package/dist/transfer/variables.d.ts +8 -1
- package/dist/transfer/variables.d.ts.map +1 -1
- package/dist/transfer/variables.js +24 -1
- package/dist/transfer/variables.js.map +1 -1
- package/dist/types.d.ts +73 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/undo.d.ts +28 -3
- package/dist/undo.d.ts.map +1 -1
- package/dist/undo.js +24 -7
- package/dist/undo.js.map +1 -1
- package/dist/variables/bindings.d.ts +37 -11
- package/dist/variables/bindings.d.ts.map +1 -1
- package/dist/variables/bindings.js +122 -74
- package/dist/variables/bindings.js.map +1 -1
- package/dist/variables/fields.d.ts +19 -1
- package/dist/variables/fields.d.ts.map +1 -1
- package/dist/variables/fields.js +36 -1
- package/dist/variables/fields.js.map +1 -1
- package/dist/variables/formula/check.d.ts +1 -1
- package/dist/variables/formula/index.d.ts +2 -2
- package/dist/variables/formula/index.js +1 -1
- package/dist/variables/formula/index.js.map +1 -1
- package/dist/variables/formula/print.d.ts +1 -1
- package/dist/variables/formula/signatures.js +1 -1
- package/dist/variables/index.d.ts +7 -7
- package/dist/variables/index.d.ts.map +1 -1
- package/dist/variables/index.js +57 -26
- package/dist/variables/index.js.map +1 -1
- package/dist/variables/paints.d.ts +57 -0
- package/dist/variables/paints.d.ts.map +1 -0
- package/dist/variables/paints.js +231 -0
- package/dist/variables/paints.js.map +1 -0
- package/dist/variables/resolution.d.ts +14 -11
- package/dist/variables/resolution.d.ts.map +1 -1
- package/dist/variables/resolution.js +36 -17
- package/dist/variables/resolution.js.map +1 -1
- package/dist/variables/subtree.js +17 -0
- package/dist/variables/subtree.js.map +1 -0
- package/dist/vector-network.d.ts.map +1 -1
- package/dist/vector-network.js +2 -8
- package/dist/vector-network.js.map +1 -1
- package/package.json +14 -1
- package/src/arrow-caps.ts +2 -5
- package/src/asset-keys.ts +20 -0
- package/src/behaviours/kinds.ts +51 -34
- package/src/behaviours/layers.ts +4 -2
- package/src/behaviours/model.ts +22 -11
- package/src/behaviours/schema.ts +20 -4
- package/src/behaviours/spec.ts +8 -2
- package/src/bindings.ts +11 -2
- package/src/checkpoint.ts +319 -17
- package/src/components/properties.ts +101 -2
- package/src/components/variants.ts +51 -30
- package/src/connectors/hit.ts +1 -12
- package/src/connectors/pieces.ts +2 -5
- package/src/constants.ts +17 -0
- package/src/constraints.ts +60 -0
- package/src/coordinate.ts +220 -0
- package/src/copy.ts +18 -19
- package/src/css/blend.ts +27 -0
- package/src/css/index.ts +18 -1
- package/src/css/text.ts +85 -17
- package/src/css/transform.ts +266 -0
- package/src/css/values.ts +8 -0
- package/src/cubic.ts +14 -0
- package/src/export-format.ts +29 -0
- package/src/fields/text.ts +3 -1
- package/src/figjam/palette.ts +29 -1
- package/src/generated/shape-with-text.ts +28 -2
- package/src/geometry.ts +97 -206
- package/src/graph.ts +155 -45
- package/src/group-bounds.ts +84 -17
- package/src/guides.ts +5 -0
- package/src/hit-test.ts +93 -64
- package/src/images.ts +71 -3
- package/src/instances/fields.ts +8 -0
- package/src/instances/index.ts +62 -31
- package/src/instances/kept-overrides.ts +280 -0
- package/src/instances/main-component.ts +12 -0
- package/src/instances/overrides.ts +27 -1
- package/src/instances/placement.ts +63 -10
- package/src/instances/swap.ts +456 -0
- package/src/instances/sync.ts +176 -50
- package/src/node-defaults.ts +3 -1
- package/src/order-keys.ts +6 -0
- package/src/outline/flatten.ts +190 -0
- package/src/outline/heads.ts +52 -0
- package/src/outline/hit.ts +369 -0
- package/src/outline/index.ts +4 -0
- package/src/outline/point.ts +59 -0
- package/src/outline/shapes.ts +207 -0
- package/src/plugin-data/fields.ts +21 -2
- package/src/resize.ts +267 -119
- package/src/scaling/index.ts +9 -1
- package/src/scaling/node.ts +9 -1
- package/src/scaling/snapshot.ts +51 -0
- package/src/scaling/tree.ts +63 -19
- package/src/shaders/model.ts +2 -3
- package/src/shared-styles.ts +90 -1
- package/src/slots/authoring.ts +5 -3
- package/src/slots/content.ts +6 -1
- package/src/slots/frames.ts +9 -7
- package/src/text/direction.ts +5 -0
- package/src/text/lengths.ts +10 -0
- package/src/text/overflow.ts +2 -2
- package/src/text/picture.ts +0 -4
- package/src/transfer/apply.ts +1 -13
- package/src/transfer/copied.ts +83 -15
- package/src/transfer/dependencies.ts +126 -0
- package/src/transfer/history.ts +0 -6
- package/src/transfer/index.ts +20 -2
- package/src/transfer/nodes.ts +17 -31
- package/src/transfer/plan.ts +3 -11
- package/src/transfer/remove.ts +5 -2
- package/src/transfer/resources.ts +54 -0
- package/src/transfer/variables.ts +34 -0
- package/src/types.ts +83 -1
- package/src/undo.ts +48 -10
- package/src/variables/bindings.ts +152 -88
- package/src/variables/fields.ts +46 -1
- package/src/variables/formula/index.ts +3 -1
- package/src/variables/index.ts +90 -39
- package/src/variables/paints.ts +296 -0
- package/src/variables/resolution.ts +39 -28
- package/src/variables/subtree.ts +15 -0
- package/src/vector-network.ts +4 -2
|
@@ -1,14 +1,46 @@
|
|
|
1
1
|
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { SceneNode } from "../types.js";
|
|
2
3
|
//#region src/transfer/copied.d.ts
|
|
4
|
+
/** How a layer's references to other layers are resolved anew. */
|
|
5
|
+
interface ReferenceResolvers {
|
|
6
|
+
/** The component a reference names now; `previous` is the one the layer named, if any. */
|
|
7
|
+
component: (id: string, previous: string | null) => string;
|
|
8
|
+
/** The layer an override names now; `component` is the one its instance now draws. */
|
|
9
|
+
layer: (id: string, component: string | null) => string;
|
|
10
|
+
/** The layer a connector's end follows now. */
|
|
11
|
+
endpoint: (id: string) => string;
|
|
12
|
+
/**
|
|
13
|
+
* The layer a text link names now. Without it links keep naming their layers, as Figma's
|
|
14
|
+
* duplicate and paste do (desktop 126); copies into another document, which lacks those
|
|
15
|
+
* layers, pass it.
|
|
16
|
+
*/
|
|
17
|
+
link?: (id: string) => string;
|
|
18
|
+
variable: (id: string) => string;
|
|
19
|
+
}
|
|
20
|
+
/** Copies placed in another document, whose text links must follow the copy. */
|
|
21
|
+
interface CopiedReferenceOptions {
|
|
22
|
+
followTextLinks?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** The instance-swap properties `nodes` define, whose values name components. */
|
|
25
|
+
declare function instanceSwapPropertyIds(nodes: Iterable<SceneNode>): Set<string>;
|
|
26
|
+
/**
|
|
27
|
+
* `node`'s references to other layers, resolved anew: its main component, the layers its
|
|
28
|
+
* overrides change and the components they swap in, the components its instance-swap properties
|
|
29
|
+
* default to or are set to, and the layers its connector ends follow. `previous` is the layer
|
|
30
|
+
* whose references these replace, so a resolver can keep what it already pointed at. Only the
|
|
31
|
+
* fields whose references change are returned: every write is an update collaboration sends.
|
|
32
|
+
*/
|
|
33
|
+
declare function resolvedReferences(node: SceneNode, previous: SceneNode, resolve: ReferenceResolvers, swapProperties: ReadonlySet<string>): Partial<SceneNode>;
|
|
3
34
|
/**
|
|
4
35
|
* Points copied layers at one another, as `prepareNodeTransfer` does for a paste: an instance's
|
|
5
36
|
* main component, the layers its overrides change and the components they swap in, the
|
|
6
37
|
* components an instance-swap property defaults to or is set to, and the layers a connector's
|
|
7
38
|
* ends follow. `mappedIds` maps each copied layer to its copy, such as a library copy or a design
|
|
8
39
|
* JSX render folded into the layers it replaces; a reference outside the copy stays as it is, and
|
|
9
|
-
* so do variable IDs, since the copies keep their source's variables.
|
|
40
|
+
* so do variable IDs, since the copies keep their source's variables. Text links follow the copy
|
|
41
|
+
* only with `followTextLinks`.
|
|
10
42
|
*/
|
|
11
|
-
declare function remapCopiedReferences(graph: SceneGraph, mappedIds: ReadonlyMap<string, string
|
|
43
|
+
declare function remapCopiedReferences(graph: SceneGraph, mappedIds: ReadonlyMap<string, string>, options?: CopiedReferenceOptions): void;
|
|
12
44
|
//#endregion
|
|
13
|
-
export { remapCopiedReferences };
|
|
45
|
+
export { CopiedReferenceOptions, ReferenceResolvers, instanceSwapPropertyIds, remapCopiedReferences, resolvedReferences };
|
|
14
46
|
//# sourceMappingURL=copied.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copied.d.ts","names":[],"sources":["../../src/transfer/copied.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"copied.d.ts","names":[],"sources":["../../src/transfer/copied.ts"],"mappings":";;;;UASiB;;EAEf,YAAY,YAAY;;EAExB,QAAQ,YAAY;;EAEpB,WAAW;;;;;;EAMX,QAAQ;EACR,WAAW;;;UAII;EACf;;;iBAUc,wBAAwB,OAAO,SAAS,aAAa;;;;;;;;iBAWrD,mBACd,MAAM,WACN,UAAU,WACV,SAAS,oBACT,gBAAgB,sBACf,QAAQ;;;;;;;;;;iBA8DK,sBACd,OAAO,YACP,WAAW,6BACX,UAAS"}
|
package/dist/transfer/copied.js
CHANGED
|
@@ -1,32 +1,55 @@
|
|
|
1
1
|
import { remapInstanceOverrideState } from "../instances/overrides.js";
|
|
2
|
+
import { remapStyleRunReferences } from "../text/references.js";
|
|
2
3
|
import { componentPropertyDefinitions } from "../components/properties.js";
|
|
3
4
|
import { isEqual, mapValues } from "es-toolkit";
|
|
4
5
|
//#region src/transfer/copied.ts
|
|
5
6
|
function swapPropertyIds(definitions) {
|
|
6
7
|
return definitions.filter((definition) => definition.type === "INSTANCE_SWAP").map((definition) => definition.id);
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
/** The instance-swap properties `nodes` define, whose values name components. */
|
|
10
|
+
function instanceSwapPropertyIds(nodes) {
|
|
11
|
+
return new Set([...nodes].flatMap((node) => swapPropertyIds(node.componentPropertyDefinitions)));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `node`'s references to other layers, resolved anew: its main component, the layers its
|
|
15
|
+
* overrides change and the components they swap in, the components its instance-swap properties
|
|
16
|
+
* default to or are set to, and the layers its connector ends follow. `previous` is the layer
|
|
17
|
+
* whose references these replace, so a resolver can keep what it already pointed at. Only the
|
|
18
|
+
* fields whose references change are returned: every write is an update collaboration sends.
|
|
19
|
+
*/
|
|
20
|
+
function resolvedReferences(node, previous, resolve, swapProperties) {
|
|
9
21
|
const changes = {};
|
|
10
|
-
|
|
22
|
+
const componentId = node.componentId ? resolve.component(node.componentId, previous.componentId) : null;
|
|
23
|
+
if (componentId !== node.componentId) changes.componentId = componentId;
|
|
11
24
|
const overrides = remapInstanceOverrideState(node.instanceOverrides, {
|
|
12
|
-
node:
|
|
13
|
-
variable:
|
|
25
|
+
node: (id) => resolve.layer(id, componentId),
|
|
26
|
+
variable: resolve.variable
|
|
14
27
|
});
|
|
15
28
|
if (!isEqual(overrides, node.instanceOverrides)) changes.instanceOverrides = overrides;
|
|
29
|
+
const previousDefaults = new Map(previous.componentPropertyDefinitions.map((definition) => [definition.id, definition.defaultValue]));
|
|
16
30
|
const definitions = node.componentPropertyDefinitions.map((definition) => definition.type === "INSTANCE_SWAP" && definition.defaultValue ? {
|
|
17
31
|
...definition,
|
|
18
|
-
defaultValue:
|
|
32
|
+
defaultValue: resolve.component(definition.defaultValue, previousDefaults.get(definition.id) ?? null)
|
|
19
33
|
} : definition);
|
|
20
34
|
if (!isEqual(definitions, node.componentPropertyDefinitions)) changes.componentPropertyDefinitions = definitions;
|
|
21
|
-
const assignments = mapValues(node.componentPropertyAssignments, (value, id) => swapProperties.has(id) ?
|
|
35
|
+
const assignments = mapValues(node.componentPropertyAssignments, (value, id) => swapProperties.has(id) ? resolve.component(value, previous.componentPropertyAssignments[id] ?? null) : value);
|
|
22
36
|
if (!isEqual(assignments, node.componentPropertyAssignments)) changes.componentPropertyAssignments = assignments;
|
|
23
37
|
for (const field of ["connectorStart", "connectorEnd"]) {
|
|
24
38
|
const endpoint = node[field];
|
|
25
|
-
|
|
39
|
+
const nodeId = endpoint?.nodeId ? resolve.endpoint(endpoint.nodeId) : null;
|
|
40
|
+
if (endpoint && nodeId && nodeId !== endpoint.nodeId) changes[field] = {
|
|
26
41
|
...endpoint,
|
|
27
|
-
nodeId
|
|
42
|
+
nodeId
|
|
28
43
|
};
|
|
29
44
|
}
|
|
45
|
+
if (resolve.link) {
|
|
46
|
+
const styleRuns = remapStyleRunReferences(node.styleRuns, {
|
|
47
|
+
variable: (id) => id,
|
|
48
|
+
style: (id) => id,
|
|
49
|
+
node: resolve.link
|
|
50
|
+
});
|
|
51
|
+
if (!isEqual(styleRuns, node.styleRuns)) changes.styleRuns = styleRuns;
|
|
52
|
+
}
|
|
30
53
|
return changes;
|
|
31
54
|
}
|
|
32
55
|
/**
|
|
@@ -35,18 +58,26 @@ function remappedReferences(node, mapped, swapProperties) {
|
|
|
35
58
|
* components an instance-swap property defaults to or is set to, and the layers a connector's
|
|
36
59
|
* ends follow. `mappedIds` maps each copied layer to its copy, such as a library copy or a design
|
|
37
60
|
* JSX render folded into the layers it replaces; a reference outside the copy stays as it is, and
|
|
38
|
-
* so do variable IDs, since the copies keep their source's variables.
|
|
61
|
+
* so do variable IDs, since the copies keep their source's variables. Text links follow the copy
|
|
62
|
+
* only with `followTextLinks`.
|
|
39
63
|
*/
|
|
40
|
-
function remapCopiedReferences(graph, mappedIds) {
|
|
64
|
+
function remapCopiedReferences(graph, mappedIds, options = {}) {
|
|
41
65
|
const mapped = (id) => mappedIds.get(id) ?? id;
|
|
66
|
+
const resolve = {
|
|
67
|
+
component: mapped,
|
|
68
|
+
layer: mapped,
|
|
69
|
+
endpoint: mapped,
|
|
70
|
+
link: options.followTextLinks ? mapped : void 0,
|
|
71
|
+
variable: (id) => id
|
|
72
|
+
};
|
|
42
73
|
const copies = [...mappedIds.values()].flatMap((id) => graph.getNode(id) ?? []);
|
|
43
|
-
const copiedSwaps = copies
|
|
74
|
+
const copiedSwaps = instanceSwapPropertyIds(copies);
|
|
44
75
|
for (const node of copies) {
|
|
45
|
-
const changes =
|
|
76
|
+
const changes = resolvedReferences(node, node, resolve, /* @__PURE__ */ new Set([...copiedSwaps, ...swapPropertyIds(componentPropertyDefinitions(graph, node))]));
|
|
46
77
|
if (Object.keys(changes).length > 0) graph.updateNode(node.id, changes);
|
|
47
78
|
}
|
|
48
79
|
}
|
|
49
80
|
//#endregion
|
|
50
|
-
export { remapCopiedReferences };
|
|
81
|
+
export { instanceSwapPropertyIds, remapCopiedReferences, resolvedReferences };
|
|
51
82
|
|
|
52
83
|
//# sourceMappingURL=copied.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copied.js","names":[],"sources":["../../src/transfer/copied.ts"],"sourcesContent":["import { isEqual, mapValues } from 'es-toolkit'\n\nimport { componentPropertyDefinitions } from '../components/properties'\nimport type { SceneGraph } from '../graph'\nimport { remapInstanceOverrideState } from '../instances/overrides'\nimport type { ComponentPropertyDefinition, SceneNode } from '../types'\n\nfunction swapPropertyIds(definitions: readonly ComponentPropertyDefinition[]): string[] {\n return definitions\n .filter((definition) => definition.type === 'INSTANCE_SWAP')\n .map((definition) => definition.id)\n}\n\
|
|
1
|
+
{"version":3,"file":"copied.js","names":[],"sources":["../../src/transfer/copied.ts"],"sourcesContent":["import { isEqual, mapValues } from 'es-toolkit'\n\nimport { componentPropertyDefinitions } from '../components/properties'\nimport type { SceneGraph } from '../graph'\nimport { remapInstanceOverrideState } from '../instances/overrides'\nimport { remapStyleRunReferences } from '../text/references'\nimport type { ComponentPropertyDefinition, SceneNode } from '../types'\n\n/** How a layer's references to other layers are resolved anew. */\nexport interface ReferenceResolvers {\n /** The component a reference names now; `previous` is the one the layer named, if any. */\n component: (id: string, previous: string | null) => string\n /** The layer an override names now; `component` is the one its instance now draws. */\n layer: (id: string, component: string | null) => string\n /** The layer a connector's end follows now. */\n endpoint: (id: string) => string\n /**\n * The layer a text link names now. Without it links keep naming their layers, as Figma's\n * duplicate and paste do (desktop 126); copies into another document, which lacks those\n * layers, pass it.\n */\n link?: (id: string) => string\n variable: (id: string) => string\n}\n\n/** Copies placed in another document, whose text links must follow the copy. */\nexport interface CopiedReferenceOptions {\n followTextLinks?: boolean\n}\n\nfunction swapPropertyIds(definitions: readonly ComponentPropertyDefinition[]): string[] {\n return definitions\n .filter((definition) => definition.type === 'INSTANCE_SWAP')\n .map((definition) => definition.id)\n}\n\n/** The instance-swap properties `nodes` define, whose values name components. */\nexport function instanceSwapPropertyIds(nodes: Iterable<SceneNode>): Set<string> {\n return new Set([...nodes].flatMap((node) => swapPropertyIds(node.componentPropertyDefinitions)))\n}\n\n/**\n * `node`'s references to other layers, resolved anew: its main component, the layers its\n * overrides change and the components they swap in, the components its instance-swap properties\n * default to or are set to, and the layers its connector ends follow. `previous` is the layer\n * whose references these replace, so a resolver can keep what it already pointed at. Only the\n * fields whose references change are returned: every write is an update collaboration sends.\n */\nexport function resolvedReferences(\n node: SceneNode,\n previous: SceneNode,\n resolve: ReferenceResolvers,\n swapProperties: ReadonlySet<string>\n): Partial<SceneNode> {\n const changes: Partial<SceneNode> = {}\n const componentId = node.componentId\n ? resolve.component(node.componentId, previous.componentId)\n : null\n if (componentId !== node.componentId) changes.componentId = componentId\n const overrides = remapInstanceOverrideState(node.instanceOverrides, {\n node: (id) => resolve.layer(id, componentId),\n variable: resolve.variable\n })\n if (!isEqual(overrides, node.instanceOverrides)) changes.instanceOverrides = overrides\n const previousDefaults = new Map(\n previous.componentPropertyDefinitions.map((definition) => [\n definition.id,\n definition.defaultValue\n ])\n )\n const definitions = node.componentPropertyDefinitions.map((definition) =>\n definition.type === 'INSTANCE_SWAP' && definition.defaultValue\n ? {\n ...definition,\n defaultValue: resolve.component(\n definition.defaultValue,\n previousDefaults.get(definition.id) ?? null\n )\n }\n : definition\n )\n if (!isEqual(definitions, node.componentPropertyDefinitions))\n changes.componentPropertyDefinitions = definitions\n const assignments = mapValues(node.componentPropertyAssignments, (value, id) =>\n swapProperties.has(id)\n ? resolve.component(value, previous.componentPropertyAssignments[id] ?? null)\n : value\n )\n if (!isEqual(assignments, node.componentPropertyAssignments))\n changes.componentPropertyAssignments = assignments\n for (const field of ['connectorStart', 'connectorEnd'] as const) {\n const endpoint = node[field]\n const nodeId = endpoint?.nodeId ? resolve.endpoint(endpoint.nodeId) : null\n if (endpoint && nodeId && nodeId !== endpoint.nodeId) changes[field] = { ...endpoint, nodeId }\n }\n if (resolve.link) {\n const styleRuns = remapStyleRunReferences(node.styleRuns, {\n variable: (id) => id,\n style: (id) => id,\n node: resolve.link\n })\n if (!isEqual(styleRuns, node.styleRuns)) changes.styleRuns = styleRuns\n }\n return changes\n}\n\n/**\n * Points copied layers at one another, as `prepareNodeTransfer` does for a paste: an instance's\n * main component, the layers its overrides change and the components they swap in, the\n * components an instance-swap property defaults to or is set to, and the layers a connector's\n * ends follow. `mappedIds` maps each copied layer to its copy, such as a library copy or a design\n * JSX render folded into the layers it replaces; a reference outside the copy stays as it is, and\n * so do variable IDs, since the copies keep their source's variables. Text links follow the copy\n * only with `followTextLinks`.\n */\nexport function remapCopiedReferences(\n graph: SceneGraph,\n mappedIds: ReadonlyMap<string, string>,\n options: CopiedReferenceOptions = {}\n): void {\n const mapped = (id: string) => mappedIds.get(id) ?? id\n const resolve: ReferenceResolvers = {\n component: mapped,\n layer: mapped,\n endpoint: mapped,\n link: options.followTextLinks ? mapped : undefined,\n variable: (id) => id\n }\n const copies = [...mappedIds.values()].flatMap((id) => graph.getNode(id) ?? [])\n const copiedSwaps = instanceSwapPropertyIds(copies)\n for (const node of copies) {\n // An instance's swap property may be defined on a component the copy leaves behind.\n const swapProperties = new Set([\n ...copiedSwaps,\n ...swapPropertyIds(componentPropertyDefinitions(graph, node))\n ])\n const changes = resolvedReferences(node, node, resolve, swapProperties)\n if (Object.keys(changes).length > 0) graph.updateNode(node.id, changes)\n }\n}\n"],"mappings":";;;;;AA8BA,SAAS,gBAAgB,aAA+D;CACtF,OAAO,YACJ,QAAQ,eAAe,WAAW,SAAS,eAAe,CAAC,CAC3D,KAAK,eAAe,WAAW,EAAE;AACtC;;AAGA,SAAgB,wBAAwB,OAAyC;CAC/E,OAAO,IAAI,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,SAAS,SAAS,gBAAgB,KAAK,4BAA4B,CAAC,CAAC;AACjG;;;;;;;;AASA,SAAgB,mBACd,MACA,UACA,SACA,gBACoB;CACpB,MAAM,UAA8B,CAAC;CACrC,MAAM,cAAc,KAAK,cACrB,QAAQ,UAAU,KAAK,aAAa,SAAS,WAAW,IACxD;CACJ,IAAI,gBAAgB,KAAK,aAAa,QAAQ,cAAc;CAC5D,MAAM,YAAY,2BAA2B,KAAK,mBAAmB;EACnE,OAAO,OAAO,QAAQ,MAAM,IAAI,WAAW;EAC3C,UAAU,QAAQ;CACpB,CAAC;CACD,IAAI,CAAC,QAAQ,WAAW,KAAK,iBAAiB,GAAG,QAAQ,oBAAoB;CAC7E,MAAM,mBAAmB,IAAI,IAC3B,SAAS,6BAA6B,KAAK,eAAe,CACxD,WAAW,IACX,WAAW,YACb,CAAC,CACH;CACA,MAAM,cAAc,KAAK,6BAA6B,KAAK,eACzD,WAAW,SAAS,mBAAmB,WAAW,eAC9C;EACE,GAAG;EACH,cAAc,QAAQ,UACpB,WAAW,cACX,iBAAiB,IAAI,WAAW,EAAE,KAAK,IACz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CAAC,CAC9D,CACqE,CAAC;EACtE,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,WAAW,KAAK,IAAI,OAAO;CACxE;AACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { SceneNode } from "../types.js";
|
|
3
|
+
//#region src/transfer/dependencies.d.ts
|
|
4
|
+
/** What layers need from their document to draw the same in another one. */
|
|
5
|
+
interface LayerDependencies {
|
|
6
|
+
/** The variables the layers and their styles bind, and every variable those alias. */
|
|
7
|
+
variables: Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* The collections of those variables, those the layers set a mode of, and those a kept
|
|
10
|
+
* expression names a mode of.
|
|
11
|
+
*/
|
|
12
|
+
collections: Set<string>;
|
|
13
|
+
/** The shared styles the layers use, as the style layers that define them. */
|
|
14
|
+
styles: SceneNode[];
|
|
15
|
+
/** The images the layers and their styles paint with. */
|
|
16
|
+
images: Set<string>;
|
|
17
|
+
}
|
|
18
|
+
/** The variables a layer names: its own bindings, its characters', and its overrides'. */
|
|
19
|
+
declare function layerVariableIds(node: SceneNode): string[];
|
|
20
|
+
/**
|
|
21
|
+
* The images a layer paints with: its fills, strokes, vector regions, text decorations, and
|
|
22
|
+
* characters.
|
|
23
|
+
*/
|
|
24
|
+
declare function layerImageHashes(node: SceneNode): string[];
|
|
25
|
+
/**
|
|
26
|
+
* The variables, collections, styles, and images `layers` depend on, as a copy into another
|
|
27
|
+
* document must carry them: a style brings what it binds and paints with in turn, and a variable
|
|
28
|
+
* brings the variables it aliases.
|
|
29
|
+
*/
|
|
30
|
+
declare function layerDependencies(graph: SceneGraph, layers: Iterable<SceneNode>): LayerDependencies;
|
|
31
|
+
/**
|
|
32
|
+
* These variables and every variable they alias, at any depth, with their collections and the
|
|
33
|
+
* collections a kept expression names a mode of.
|
|
34
|
+
*/
|
|
35
|
+
declare function variableDependencies(graph: SceneGraph, ids: Iterable<string>): Pick<LayerDependencies, 'variables' | 'collections'>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { LayerDependencies, layerDependencies, layerImageHashes, layerVariableIds, variableDependencies };
|
|
38
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","names":[],"sources":["../../src/transfer/dependencies.ts"],"mappings":";;;;UAUiB;;EAEf,WAAW;;;;;EAKX,aAAa;;EAEb,QAAQ;;EAER,QAAQ;;;iBAIM,iBAAiB,MAAM;;;;;iBAgBvB,iBAAiB,MAAM;;;;;;iBAkBvB,kBACd,OAAO,YACP,QAAQ,SAAS,aAChB;;;;;iBA8Ba,qBACd,OAAO,YACP,KAAK,mBACJ,KAAK"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { overriddenBindingField } from "../instances/overrides.js";
|
|
2
|
+
import { isUnsupportedVariableValue, variableValueReferences } from "../variables/value.js";
|
|
3
|
+
import { styleRunReferences } from "../text/references.js";
|
|
4
|
+
import { referencedStyleIds, sharedStyleLayers } from "../shared-styles.js";
|
|
5
|
+
import { regionFills } from "../vector-network.js";
|
|
6
|
+
import { imagePaintHashes } from "../images.js";
|
|
7
|
+
//#region src/transfer/dependencies.ts
|
|
8
|
+
/** The variables a layer names: its own bindings, its characters', and its overrides'. */
|
|
9
|
+
function layerVariableIds(node) {
|
|
10
|
+
const { self, descendants } = node.instanceOverrides;
|
|
11
|
+
const overridden = [...self, ...[...descendants.values()].flatMap((fields) => [...fields])];
|
|
12
|
+
return [
|
|
13
|
+
...Object.values(node.boundVariables),
|
|
14
|
+
...styleRunReferences(node.styleRuns).variables,
|
|
15
|
+
...overridden.flatMap(([field, value]) => typeof value === "string" && overriddenBindingField(field) !== null ? [value] : [])
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The images a layer paints with: its fills, strokes, vector regions, text decorations, and
|
|
20
|
+
* characters.
|
|
21
|
+
*/
|
|
22
|
+
function layerImageHashes(node) {
|
|
23
|
+
return imagePaintHashes([
|
|
24
|
+
...node.fills,
|
|
25
|
+
...node.strokes,
|
|
26
|
+
...regionFills(node.vectorNetwork),
|
|
27
|
+
...node.textDecorationFills,
|
|
28
|
+
...node.styleRuns.flatMap((run) => [...run.style.fills ?? [], ...run.style.textDecorationFills ?? []])
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The variables, collections, styles, and images `layers` depend on, as a copy into another
|
|
33
|
+
* document must carry them: a style brings what it binds and paints with in turn, and a variable
|
|
34
|
+
* brings the variables it aliases.
|
|
35
|
+
*/
|
|
36
|
+
function layerDependencies(graph, layers) {
|
|
37
|
+
const collections = /* @__PURE__ */ new Set();
|
|
38
|
+
const images = /* @__PURE__ */ new Set();
|
|
39
|
+
const styles = /* @__PURE__ */ new Map();
|
|
40
|
+
const pending = [];
|
|
41
|
+
let styleLayers;
|
|
42
|
+
const styleLayer = (id) => (styleLayers ??= sharedStyleLayers(graph)).get(id);
|
|
43
|
+
const visit = (node) => {
|
|
44
|
+
for (const hash of layerImageHashes(node)) images.add(hash);
|
|
45
|
+
pending.push(...layerVariableIds(node));
|
|
46
|
+
for (const id of Object.keys(node.variableModes)) if (graph.variableCollections.has(id)) collections.add(id);
|
|
47
|
+
for (const id of referencedStyleIds(node)) {
|
|
48
|
+
const style = styles.has(id) ? void 0 : styleLayer(id);
|
|
49
|
+
if (!style) continue;
|
|
50
|
+
styles.set(id, style);
|
|
51
|
+
visit(style);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
for (const node of layers) visit(node);
|
|
55
|
+
const resolved = variableDependencies(graph, pending);
|
|
56
|
+
for (const id of resolved.collections) collections.add(id);
|
|
57
|
+
return {
|
|
58
|
+
variables: resolved.variables,
|
|
59
|
+
collections,
|
|
60
|
+
styles: [...styles.values()],
|
|
61
|
+
images
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* These variables and every variable they alias, at any depth, with their collections and the
|
|
66
|
+
* collections a kept expression names a mode of.
|
|
67
|
+
*/
|
|
68
|
+
function variableDependencies(graph, ids) {
|
|
69
|
+
const pending = [...ids];
|
|
70
|
+
const variables = /* @__PURE__ */ new Set();
|
|
71
|
+
const collections = /* @__PURE__ */ new Set();
|
|
72
|
+
let modeCollections;
|
|
73
|
+
const collectionOfMode = (modeId) => {
|
|
74
|
+
modeCollections ??= new Map([...graph.variableCollections.values()].flatMap((collection) => collection.modes.map((mode) => [mode.modeId, collection.id])));
|
|
75
|
+
return modeCollections.get(modeId);
|
|
76
|
+
};
|
|
77
|
+
for (let id = pending.pop(); id !== void 0; id = pending.pop()) {
|
|
78
|
+
if (variables.has(id)) continue;
|
|
79
|
+
const variable = graph.variables.get(id);
|
|
80
|
+
if (!variable) continue;
|
|
81
|
+
variables.add(id);
|
|
82
|
+
collections.add(variable.collectionId);
|
|
83
|
+
for (const value of Object.values(variable.valuesByMode)) {
|
|
84
|
+
pending.push(...variableValueReferences(value));
|
|
85
|
+
if (!isUnsupportedVariableValue(value)) continue;
|
|
86
|
+
for (const modeId of value.modes) {
|
|
87
|
+
const collection = collectionOfMode(modeId);
|
|
88
|
+
if (collection) collections.add(collection);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
variables,
|
|
94
|
+
collections
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { layerDependencies, layerImageHashes, layerVariableIds, variableDependencies };
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.js","names":[],"sources":["../../src/transfer/dependencies.ts"],"sourcesContent":["import 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/** The variables a layer names: its own bindings, its characters', and its overrides'. */\nexport function layerVariableIds(node: SceneNode): string[] {\n const { self, descendants } = node.instanceOverrides\n const overridden = [...self, ...[...descendants.values()].flatMap((fields) => [...fields])]\n return [\n ...Object.values(node.boundVariables),\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 pending.push(...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 pending.push(...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":";;;;;;;;AAyBA,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,OAAO;EACL,GAAG,OAAO,OAAO,KAAK,cAAc;EACpC,GAAG,mBAAmB,KAAK,SAAS,CAAC,CAAC;EACtC,GAAG,WAAW,S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AS;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,QAAQ,KAAK,GAAG,wBAAwB,KAAK,CAAC;GAE9C,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
|
@@ -22,7 +22,6 @@ function captureTransferredState(graph, original) {
|
|
|
22
22
|
}),
|
|
23
23
|
variables: original.variables.map((variable) => structuredClone(requireValue(graph.variables.get(variable.id), "variable", variable.id))),
|
|
24
24
|
collections: original.collections.map((collection) => structuredClone(requireValue(graph.variableCollections.get(collection.id), "collection", collection.id))),
|
|
25
|
-
activeModes: new Map(original.collections.map((collection) => [collection.id, requireValue(graph.activeMode.get(collection.id), "active mode", collection.id)])),
|
|
26
25
|
images: new Map([...original.images.keys()].map((hash) => [hash, requireValue(graph.images.get(hash), "image", hash).slice()]))
|
|
27
26
|
};
|
|
28
27
|
}
|
|
@@ -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
|
|
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"}
|
package/dist/transfer/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { GraphTransferInput, prepareGraphTransfer } from "./plan.js";
|
|
|
2
2
|
import { GraphTransferPlan, applyGraphTransfer } from "./apply.js";
|
|
3
3
|
import { removeGraphTransfer } from "./remove.js";
|
|
4
4
|
import { captureTransferredState } from "./history.js";
|
|
5
|
-
import { VariableTransferReferences, prepareVariableTransfer } from "./variables.js";
|
|
5
|
+
import { VariableTransferReferences, copyVariableTables, prepareVariableTransfer } from "./variables.js";
|
|
6
6
|
import { NodeTransferReferences, prepareNodeTransfer } from "./nodes.js";
|
|
7
|
-
import { remapCopiedReferences } from "./copied.js";
|
|
8
|
-
|
|
7
|
+
import { CopiedReferenceOptions, ReferenceResolvers, instanceSwapPropertyIds, remapCopiedReferences, resolvedReferences } from "./copied.js";
|
|
8
|
+
import { LayerDependencies, layerDependencies, layerImageHashes, layerVariableIds, variableDependencies } from "./dependencies.js";
|
|
9
|
+
import { ResourceReferences, remappedResourceReferences } from "./resources.js";
|
|
10
|
+
export { type CopiedReferenceOptions, type GraphTransferInput, type GraphTransferPlan, type LayerDependencies, type NodeTransferReferences, type ReferenceResolvers, type ResourceReferences, type VariableTransferReferences, applyGraphTransfer, captureTransferredState, copyVariableTables, instanceSwapPropertyIds, layerDependencies, layerImageHashes, layerVariableIds, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, remapCopiedReferences, remappedResourceReferences, removeGraphTransfer, resolvedReferences, variableDependencies };
|
package/dist/transfer/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { instanceSwapPropertyIds, remapCopiedReferences, resolvedReferences } from "./copied.js";
|
|
2
|
+
import { remappedResourceReferences } from "./resources.js";
|
|
1
3
|
import { prepareNodeTransfer } from "./nodes.js";
|
|
2
4
|
import { removeGraphTransfer } from "./remove.js";
|
|
3
5
|
import { captureTransferredState } from "./history.js";
|
|
4
|
-
import { prepareVariableTransfer } from "./variables.js";
|
|
6
|
+
import { copyVariableTables, prepareVariableTransfer } from "./variables.js";
|
|
5
7
|
import { applyGraphTransfer } from "./apply.js";
|
|
6
8
|
import { prepareGraphTransfer } from "./plan.js";
|
|
7
|
-
import {
|
|
8
|
-
export { applyGraphTransfer, captureTransferredState, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, remapCopiedReferences, removeGraphTransfer };
|
|
9
|
+
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 };
|
|
@@ -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":";;;UAuCiB,+BAA+B;EAC9C,OAAO;EACP,QAAQ;EACR,YAAY;EACZ,eAAe,oBAAoB;;;iBAIrB,oBACd,QAAQ,WACR,MAAM,yBACL,QAAQ"}
|
package/dist/transfer/nodes.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { overriddenBindingField, remapInstanceOverrideState } from "../instances/overrides.js";
|
|
2
2
|
import { cloneNodeProps } from "../copy.js";
|
|
3
|
-
import {
|
|
3
|
+
import { styleRunReferences } from "../text/references.js";
|
|
4
4
|
import { referencedStyleIds } from "../shared-styles.js";
|
|
5
5
|
import { requireTransferReference } from "./references.js";
|
|
6
|
+
import { remappedResourceReferences } from "./resources.js";
|
|
6
7
|
//#region src/transfer/nodes.ts
|
|
7
8
|
function semanticTransferReferences(node) {
|
|
8
9
|
const runs = styleRunReferences(node.styleRuns);
|
|
@@ -34,36 +35,32 @@ function prepareNodeTransfer(source, refs) {
|
|
|
34
35
|
result.componentId = source.componentId ? node(source.componentId) : null;
|
|
35
36
|
result.instanceOverrides = remapInstanceOverrideState(source.instanceOverrides, {
|
|
36
37
|
node,
|
|
37
|
-
variable
|
|
38
|
+
variable,
|
|
39
|
+
collection: (id) => refs.collections.get(id)
|
|
38
40
|
});
|
|
39
|
-
|
|
40
|
-
result.variableModes = Object.fromEntries(Object.entries(source.variableModes).map(([collection, mode]) => [requireTransferReference(refs.collections, collection, "collection"), requireTransferReference(refs.modes, mode, "mode")]));
|
|
41
|
-
for (const field of [
|
|
42
|
-
"fillStyleId",
|
|
43
|
-
"strokeStyleId",
|
|
44
|
-
"textStyleId",
|
|
45
|
-
"effectStyleId",
|
|
46
|
-
"gridStyleId"
|
|
47
|
-
]) result[field] = source[field] ? style(source[field]) : null;
|
|
48
|
-
if (result.styleRuns) result.styleRuns = remapStyleRunReferences(result.styleRuns, {
|
|
41
|
+
Object.assign(result, remappedResourceReferences(source, {
|
|
49
42
|
variable,
|
|
43
|
+
collection: (id) => requireTransferReference(refs.collections, id, "collection"),
|
|
44
|
+
mode: (id) => requireTransferReference(refs.modes, id, "mode"),
|
|
50
45
|
style,
|
|
51
|
-
|
|
52
|
-
});
|
|
46
|
+
layer: (id) => refs.nodes.get(id) ?? id
|
|
47
|
+
}));
|
|
53
48
|
for (const field of ["connectorStart", "connectorEnd"]) {
|
|
54
49
|
const endpoint = result[field];
|
|
55
50
|
if (endpoint?.nodeId) endpoint.nodeId = refs.nodes.get(endpoint.nodeId) ?? endpoint.nodeId;
|
|
56
51
|
}
|
|
57
|
-
for (const region of result.vectorNetwork?.regions ?? []) if (region.fillStyleId) region.fillStyleId = style(region.fillStyleId);
|
|
58
52
|
result.componentPropertyDefinitions = source.componentPropertyDefinitions.map((definition) => ({
|
|
59
53
|
...structuredClone(definition),
|
|
60
54
|
id: property(definition.id),
|
|
61
55
|
defaultValue: propertyValue(definition.id, definition.defaultValue)
|
|
62
56
|
}));
|
|
63
|
-
result.componentPropertyReferences = source.componentPropertyReferences.
|
|
64
|
-
|
|
65
|
-
propertyId
|
|
66
|
-
|
|
57
|
+
result.componentPropertyReferences = source.componentPropertyReferences.flatMap((reference) => {
|
|
58
|
+
const propertyId = refs.properties.get(reference.propertyId);
|
|
59
|
+
return propertyId ? [{
|
|
60
|
+
...reference,
|
|
61
|
+
propertyId
|
|
62
|
+
}] : [];
|
|
63
|
+
});
|
|
67
64
|
result.componentPropertyAssignments = values(source.componentPropertyAssignments);
|
|
68
65
|
result.componentPropertyValues = { ...source.componentPropertyValues };
|
|
69
66
|
return result;
|
|
@@ -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 {
|
|
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 })\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":";;;;;;;AASA,SAAgB,2BAA2B,MAA2B;CACpE,MAAM,OAAO,mBAAmB,KAAK,SAAS;CAC9C,OAAO;EACL,GAAI,KAAK,cAAc,CAAC,KAAK,WAAW,IAAI,CAAC;EAC7C,GAAG,OAAO,OAAO,KAAK,cAAc;EACpC,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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;CACvC,CAAC,CACH;CAGA,KAAK,MAAM,SAAS,CAAC,kBAAkB,cAAc,GAAY;EAC/D,MAAM,WAAW,OAAO;EACxB,IAAI,UAAU,QAAQ,SAAS,SAAS,KAAK,MAAM,IAAI,SAAS,MAAM,KAAK,SAAS;CACtF;CACA,OAAO,+BAA+B,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;CAEhF,OAAO,0BAA0B,EAAE,GAAG,OAAO,wBAAwB;CACrE,OAAO;AACT"}
|
package/dist/transfer/plan.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ interface GraphTransferInput {
|
|
|
10
10
|
}
|
|
11
11
|
/** Preflight a self-contained fragment; allocation does not insert anything into the target. */
|
|
12
12
|
declare function prepareGraphTransfer(input: GraphTransferInput): {
|
|
13
|
-
activeModes: Map<string, string>;
|
|
14
13
|
images: Map<string, Uint8Array<ArrayBuffer>>;
|
|
15
14
|
variables: Variable[];
|
|
16
15
|
collections: VariableCollection[];
|
package/dist/transfer/plan.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sharedStyleLayers } from "../shared-styles.js";
|
|
2
2
|
import { prepareNodeTransfer } from "./nodes.js";
|
|
3
3
|
import { prepareVariableTransfer } from "./variables.js";
|
|
4
4
|
//#region src/transfer/plan.ts
|
|
@@ -55,13 +55,12 @@ function prepareGraphTransfer(input) {
|
|
|
55
55
|
propertyTypes.set(definition.id, definition.type);
|
|
56
56
|
if (!properties.has(definition.id)) properties.set(definition.id, allocate());
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
for (const node of target.getAllNodes()) if (node.sharedStyleType !== null && node.source.id) targetStyleIds.add(node.source.id);
|
|
58
|
+
const targetStyles = sharedStyleLayers(target);
|
|
60
59
|
const styles = /* @__PURE__ */ new Map();
|
|
61
60
|
for (const node of ordered) {
|
|
62
61
|
const id = node.source.id;
|
|
63
62
|
if (node.sharedStyleType === null || !id) continue;
|
|
64
|
-
styles.set(id,
|
|
63
|
+
styles.set(id, targetStyles.has(id) ? allocate() : id);
|
|
65
64
|
}
|
|
66
65
|
const references = {
|
|
67
66
|
nodes,
|
|
@@ -96,7 +95,6 @@ function prepareGraphTransfer(input) {
|
|
|
96
95
|
props: withStyleId(node, prepareNodeTransfer(node, references), styles)
|
|
97
96
|
})),
|
|
98
97
|
...resources,
|
|
99
|
-
activeModes: new Map([...source.activeMode].map(([collection, mode]) => [requireTransferReference(collections, collection, "collection"), requireTransferReference(modes, mode, "mode")])),
|
|
100
98
|
images: new Map([...source.images].map(([hash, bytes]) => [hash, bytes.slice()]))
|
|
101
99
|
};
|
|
102
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","names":[],"sources":["../../src/transfer/plan.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport
|
|
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,O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AAI,KAAK,EAAE,GAAG,OAAO;EAC/B,IAAI,aAAa,IAAI,KAAK,EAAE,GAAG,OAAO,OAAO;EAC7C,OAAO,OAAO,KAAK,YAAY,EAAE;CACnC;CACA,OAAO;EACL,SAAS;EACT,SAAS,MAAM,QAAQ,IAAI,MAAM;EACjC,mBAAmB,MAAM,kBAAkB,IAAI,MAAM;EACrD,OAAO,QAAQ,KAAK,UAAU;GAC5B,IAAI,OAAO,KAAK,EAAE;GAClB,MAAM,KAAK;GACX,UAAU,kBAAkB,IAAI;GAChC,OAAO,YAAY,MAAM,oBAAoB,MAAM,UAAU,GAAG,MAAM;EACxE,EAAE;EACF,GAAG;EACH,QAAQ,IAAI,IAAI,CAAC,GAAG,OAAO,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAAC,MAAM,MAAM,MAAM,CAAC,CAAC,CAAC;CAClF;AACF"}
|
package/dist/transfer/remove.js
CHANGED
|
@@ -21,10 +21,13 @@ function removeGraphTransfer(graph, plan) {
|
|
|
21
21
|
for (const variable of graph.variables.values()) if (!variables.has(variable.id) && referencesOwned(variable.valuesByMode)) throw new Error("Transferred variable has external aliases");
|
|
22
22
|
graph.withBufferedEvents(() => {
|
|
23
23
|
for (const node of plan.nodes.toReversed()) graph.deleteNode(node.id);
|
|
24
|
-
for (const id of variables)
|
|
24
|
+
for (const id of variables) {
|
|
25
|
+
graph.willChangeVariable(id);
|
|
26
|
+
graph.variables.delete(id);
|
|
27
|
+
}
|
|
25
28
|
for (const id of collections) {
|
|
29
|
+
graph.willChangeCollection(id);
|
|
26
30
|
graph.variableCollections.delete(id);
|
|
27
|
-
graph.activeMode.delete(id);
|
|
28
31
|
}
|
|
29
32
|
});
|
|
30
33
|
}
|