@pairdraw/scene-graph 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/components/index.d.ts +2 -2
  2. package/dist/components/index.js +2 -2
  3. package/dist/components/properties.d.ts +6 -1
  4. package/dist/components/properties.d.ts.map +1 -1
  5. package/dist/components/properties.js +14 -3
  6. package/dist/components/properties.js.map +1 -1
  7. package/dist/copy.d.ts.map +1 -1
  8. package/dist/copy.js +1 -0
  9. package/dist/copy.js.map +1 -1
  10. package/dist/css/gradient.d.ts +23 -0
  11. package/dist/css/gradient.d.ts.map +1 -0
  12. package/dist/css/gradient.js +404 -0
  13. package/dist/css/gradient.js.map +1 -0
  14. package/dist/css/index.d.ts +2 -1
  15. package/dist/css/index.js +2 -1
  16. package/dist/css/shadows.d.ts.map +1 -1
  17. package/dist/css/shadows.js +2 -13
  18. package/dist/css/shadows.js.map +1 -1
  19. package/dist/css/values.js +24 -1
  20. package/dist/css/values.js.map +1 -1
  21. package/dist/font-style.d.ts +2 -1
  22. package/dist/font-style.d.ts.map +1 -1
  23. package/dist/font-style.js +31 -6
  24. package/dist/font-style.js.map +1 -1
  25. package/dist/geometry.d.ts +10 -1
  26. package/dist/geometry.d.ts.map +1 -1
  27. package/dist/geometry.js +21 -6
  28. package/dist/geometry.js.map +1 -1
  29. package/dist/graph.d.ts +49 -3
  30. package/dist/graph.d.ts.map +1 -1
  31. package/dist/graph.js +179 -17
  32. package/dist/graph.js.map +1 -1
  33. package/dist/hit-test.d.ts +3 -1
  34. package/dist/hit-test.d.ts.map +1 -1
  35. package/dist/hit-test.js +38 -23
  36. package/dist/hit-test.js.map +1 -1
  37. package/dist/icons/index.d.ts +2 -2
  38. package/dist/icons/index.js +2 -2
  39. package/dist/icons/model.d.ts +8 -2
  40. package/dist/icons/model.d.ts.map +1 -1
  41. package/dist/icons/model.js +10 -1
  42. package/dist/icons/model.js.map +1 -1
  43. package/dist/index.d.ts +2 -2
  44. package/dist/instances/assignments.js +40 -6
  45. package/dist/instances/assignments.js.map +1 -1
  46. package/dist/instances/fields.d.ts +2 -2
  47. package/dist/instances/fields.d.ts.map +1 -1
  48. package/dist/instances/fields.js +18 -1
  49. package/dist/instances/fields.js.map +1 -1
  50. package/dist/instances/index.d.ts +38 -2
  51. package/dist/instances/index.d.ts.map +1 -1
  52. package/dist/instances/index.js +134 -15
  53. package/dist/instances/index.js.map +1 -1
  54. package/dist/instances/overrides.d.ts +10 -1
  55. package/dist/instances/overrides.d.ts.map +1 -1
  56. package/dist/instances/overrides.js +28 -2
  57. package/dist/instances/overrides.js.map +1 -1
  58. package/dist/instances/placement.js +1 -1
  59. package/dist/instances/placement.js.map +1 -1
  60. package/dist/instances/swap-overrides.js +94 -0
  61. package/dist/instances/swap-overrides.js.map +1 -0
  62. package/dist/instances/sync.js +90 -12
  63. package/dist/instances/sync.js.map +1 -1
  64. package/dist/layout/draw-order.d.ts +11 -0
  65. package/dist/layout/draw-order.d.ts.map +1 -0
  66. package/dist/layout/draw-order.js +14 -0
  67. package/dist/layout/draw-order.js.map +1 -0
  68. package/dist/layout/index.d.ts +2 -1
  69. package/dist/layout/index.js +2 -1
  70. package/dist/node-defaults.d.ts +11 -1
  71. package/dist/node-defaults.d.ts.map +1 -1
  72. package/dist/node-defaults.js +16 -1
  73. package/dist/node-defaults.js.map +1 -1
  74. package/dist/order-keys.d.ts +3 -1
  75. package/dist/order-keys.d.ts.map +1 -1
  76. package/dist/order-keys.js +6 -1
  77. package/dist/order-keys.js.map +1 -1
  78. package/dist/resize.d.ts +29 -9
  79. package/dist/resize.d.ts.map +1 -1
  80. package/dist/resize.js +95 -62
  81. package/dist/resize.js.map +1 -1
  82. package/dist/shared-styles.d.ts.map +1 -1
  83. package/dist/shared-styles.js +1 -8
  84. package/dist/shared-styles.js.map +1 -1
  85. package/dist/slots/authoring.d.ts +3 -2
  86. package/dist/slots/authoring.d.ts.map +1 -1
  87. package/dist/slots/authoring.js +5 -3
  88. package/dist/slots/authoring.js.map +1 -1
  89. package/dist/slots/content.d.ts.map +1 -1
  90. package/dist/slots/content.js +4 -1
  91. package/dist/slots/content.js.map +1 -1
  92. package/dist/source-metadata.d.ts +4 -2
  93. package/dist/source-metadata.d.ts.map +1 -1
  94. package/dist/source-metadata.js +10 -3
  95. package/dist/source-metadata.js.map +1 -1
  96. package/dist/strokes.d.ts +39 -0
  97. package/dist/strokes.d.ts.map +1 -0
  98. package/dist/strokes.js +104 -0
  99. package/dist/strokes.js.map +1 -0
  100. package/dist/text/direction.d.ts +6 -2
  101. package/dist/text/direction.d.ts.map +1 -1
  102. package/dist/text/direction.js +2 -1
  103. package/dist/text/direction.js.map +1 -1
  104. package/dist/text/index.d.ts +3 -3
  105. package/dist/text/index.js +3 -3
  106. package/dist/text/lengths.d.ts +6 -1
  107. package/dist/text/lengths.d.ts.map +1 -1
  108. package/dist/text/lengths.js +10 -1
  109. package/dist/text/lengths.js.map +1 -1
  110. package/dist/text/overflow.d.ts +22 -6
  111. package/dist/text/overflow.d.ts.map +1 -1
  112. package/dist/text/overflow.js +24 -6
  113. package/dist/text/overflow.js.map +1 -1
  114. package/dist/transfer/nodes.js +9 -5
  115. package/dist/transfer/nodes.js.map +1 -1
  116. package/dist/types.d.ts +18 -2
  117. package/dist/types.d.ts.map +1 -1
  118. package/dist/types.js.map +1 -1
  119. package/dist/undo.d.ts +36 -1
  120. package/dist/undo.d.ts.map +1 -1
  121. package/dist/undo.js +52 -2
  122. package/dist/undo.js.map +1 -1
  123. package/dist/variables/bindings.d.ts +14 -6
  124. package/dist/variables/bindings.d.ts.map +1 -1
  125. package/dist/variables/bindings.js +42 -67
  126. package/dist/variables/bindings.js.map +1 -1
  127. package/dist/variables/formula/signatures.js +1 -1
  128. package/dist/variables/index.d.ts +10 -4
  129. package/dist/variables/index.d.ts.map +1 -1
  130. package/dist/variables/index.js +58 -15
  131. package/dist/variables/index.js.map +1 -1
  132. package/dist/variables/paints.d.ts +101 -0
  133. package/dist/variables/paints.d.ts.map +1 -0
  134. package/dist/variables/paints.js +313 -0
  135. package/dist/variables/paints.js.map +1 -0
  136. package/dist/variables/resolution.d.ts +14 -1
  137. package/dist/variables/resolution.d.ts.map +1 -1
  138. package/dist/variables/resolution.js +44 -4
  139. package/dist/variables/resolution.js.map +1 -1
  140. package/dist/variables/subtree.js +17 -0
  141. package/dist/variables/subtree.js.map +1 -0
  142. package/package.json +6 -1
  143. package/src/components/properties.ts +17 -2
  144. package/src/copy.ts +1 -0
  145. package/src/css/gradient.ts +438 -0
  146. package/src/css/index.ts +1 -0
  147. package/src/css/shadows.ts +2 -18
  148. package/src/css/values.ts +27 -1
  149. package/src/font-style.ts +38 -4
  150. package/src/geometry.ts +25 -6
  151. package/src/graph.ts +207 -17
  152. package/src/hit-test.ts +67 -24
  153. package/src/icons/model.ts +11 -1
  154. package/src/instances/assignments.ts +65 -7
  155. package/src/instances/fields.ts +21 -0
  156. package/src/instances/index.ts +237 -14
  157. package/src/instances/overrides.ts +36 -1
  158. package/src/instances/placement.ts +5 -1
  159. package/src/instances/swap-overrides.ts +123 -0
  160. package/src/instances/sync.ts +139 -12
  161. package/src/layout/draw-order.ts +13 -0
  162. package/src/layout/index.ts +1 -0
  163. package/src/node-defaults.ts +21 -0
  164. package/src/order-keys.ts +6 -0
  165. package/src/resize.ts +133 -69
  166. package/src/shared-styles.ts +1 -3
  167. package/src/slots/authoring.ts +5 -3
  168. package/src/slots/content.ts +4 -1
  169. package/src/source-metadata.ts +18 -3
  170. package/src/strokes.ts +121 -0
  171. package/src/text/direction.ts +7 -5
  172. package/src/text/lengths.ts +10 -0
  173. package/src/text/overflow.ts +30 -7
  174. package/src/transfer/nodes.ts +7 -5
  175. package/src/types.ts +17 -0
  176. package/src/undo.ts +79 -2
  177. package/src/variables/bindings.ts +52 -74
  178. package/src/variables/index.ts +80 -14
  179. package/src/variables/paints.ts +413 -0
  180. package/src/variables/resolution.ts +56 -5
  181. package/src/variables/subtree.ts +15 -0
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","names":[],"sources":["../../src/instances/fields.ts"],"sourcesContent":["import { difference } from 'es-toolkit/array'\n\nimport { CORNER_FIELDS, PAINT_FIELDS, STROKE_FIELDS } from '../fields/appearance'\nimport { SIZE_FIELDS, TRANSFORM_FIELDS } from '../fields/geometry'\nimport { AUTO_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS } from '../fields/layout'\nimport { TEXT_STYLE_FIELDS } from '../fields/text'\nimport { STYLE_LINK_FIELDS } from '../shared-styles'\nimport type { SceneNode } from '../types'\n\nexport const INSTANCE_SYNC_TEXT_PROPS = [\n 'name',\n 'text',\n ...TEXT_STYLE_FIELDS,\n 'textDirection',\n 'textAutoResize',\n 'textTruncation',\n 'maxLines',\n 'leadingTrim',\n 'listSpacing',\n 'hangingList',\n // Styled ranges belong to the characters: an instance that overrides its text keeps them.\n 'styleRuns',\n 'textParagraphs'\n] as const\n\n/** Fields that belong to another one: overriding the owner keeps them too. */\nexport const INSTANCE_SYNC_FIELD_OWNERS: Readonly<Partial<Record<string, string>>> = {\n fillStyleId: 'fills',\n styleRuns: 'text',\n textParagraphs: 'text'\n}\n\n/**\n * Where a component's layer sits and how it is shaped, which Figma refuses to override in an\n * instance (\"This property cannot be overridden in an instance\"), so its copies always follow.\n * A layer in an auto layout flow takes its position from the layout instead.\n */\nexport const INSTANCE_FOLLOWED_FIELDS = [\n ...TRANSFORM_FIELDS,\n 'horizontalConstraint',\n 'verticalConstraint',\n 'layoutPositioning',\n 'counterAxisAlignContent',\n 'isMask',\n 'maskType',\n 'arcData',\n 'pointCount',\n 'starInnerRadius',\n 'shapeWithTextType',\n 'shapeUserHeight',\n 'shapeTruncates'\n] as const\n\n/** Fields a component's layer gives its copies unless an instance overrides them. */\nexport const INSTANCE_SYNC_PROPS: (keyof SceneNode)[] = difference(\n [\n ...SIZE_FIELDS,\n ...SIZE_CONSTRAINT_FIELDS,\n ...PAINT_FIELDS,\n ...STROKE_FIELDS,\n ...CORNER_FIELDS,\n ...AUTO_LAYOUT_FIELDS,\n 'itemReverseZIndex',\n 'gridPosition',\n 'clipsContent',\n 'layoutGrids',\n 'boundVariables',\n 'variableModes',\n // Applied shared styles follow the component unless an instance overrides them.\n ...STYLE_LINK_FIELDS\n ],\n INSTANCE_FOLLOWED_FIELDS\n)\n\n/** How a layer inside an instance sits in its parent and whether it is locked, which its overrides may change. */\nconst INSTANCE_SYNC_CHILD_PROPS = ['layoutGrow', 'layoutAlignSelf', 'locked'] as const\n\n/** Fields an edit to a layer inside an instance records as that instance's override. */\nexport const INSTANCE_OVERRIDE_FIELDS = [\n ...INSTANCE_SYNC_PROPS,\n ...INSTANCE_SYNC_TEXT_PROPS,\n ...INSTANCE_SYNC_CHILD_PROPS,\n 'visible'\n] as const\n\n/** Fields a component's layer gives the copies of it in every instance. */\nexport const INSTANCE_SYNC_FIELDS = [\n ...INSTANCE_OVERRIDE_FIELDS,\n ...INSTANCE_FOLLOWED_FIELDS\n] as const\n"],"mappings":";;;;;;;AASA,MAAa,2BAA2B;CACtC;CACA;CACA,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;AACF;;AAGA,MAAa,6BAAwE;CACnF,aAAa;CACb,WAAW;CACX,gBAAgB;AAClB;;;;;;AAOA,MAAa,2BAA2B;CACtC,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,sBAA2C,WACtD;CACE,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CAEA,GAAG;AACL,GACA,wBACF;;AAGA,MAAM,4BAA4B;CAAC;CAAc;CAAmB;AAAQ;;AAG5E,MAAa,2BAA2B;CACtC,GAAG;CACH,GAAG;CACH,GAAG;CACH;AACF;;AAGA,MAAa,uBAAuB,CAClC,GAAG,0BACH,GAAG,wBACL"}
1
+ {"version":3,"file":"fields.js","names":[],"sources":["../../src/instances/fields.ts"],"sourcesContent":["import { difference } from 'es-toolkit/array'\n\nimport { CORNER_FIELDS, PAINT_FIELDS, STROKE_FIELDS } from '../fields/appearance'\nimport { SIZE_FIELDS, TRANSFORM_FIELDS } from '../fields/geometry'\nimport { AUTO_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS } from '../fields/layout'\nimport { TEXT_STYLE_FIELDS } from '../fields/text'\nimport { STYLE_LINK_FIELDS } from '../shared-styles'\nimport type { SceneNode } from '../types'\n\nexport const INSTANCE_SYNC_TEXT_PROPS = [\n 'name',\n 'text',\n ...TEXT_STYLE_FIELDS,\n 'textDirection',\n 'textAutoResize',\n 'textTruncation',\n 'maxLines',\n 'leadingTrim',\n 'listSpacing',\n 'hangingList',\n // Styled ranges belong to the characters: an instance that overrides its text keeps them.\n 'styleRuns',\n 'textParagraphs'\n] as const\n\n/** Fields that belong to another one: overriding the owner keeps them too. */\nexport const INSTANCE_SYNC_FIELD_OWNERS: Readonly<Partial<Record<string, string>>> = {\n fillStyleId: 'fills',\n styleRuns: 'text',\n textParagraphs: 'text'\n}\n\n/**\n * Where a component's layer sits and how it is shaped, which Figma refuses to override in an\n * instance (\"This property cannot be overridden in an instance\"), so its copies always follow.\n * A layer in an auto layout flow takes its position from the layout instead.\n */\nexport const INSTANCE_FOLLOWED_FIELDS = [\n ...TRANSFORM_FIELDS,\n // A size limit has no field of its own in the file, so an instance cannot keep one of its own.\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'horizontalConstraint',\n 'verticalConstraint',\n 'layoutPositioning',\n 'counterAxisAlignContent',\n 'isMask',\n 'maskType',\n 'arcData',\n 'pointCount',\n 'starInnerRadius',\n 'shapeWithTextType',\n 'shapeUserHeight',\n 'shapeTruncates'\n] as const\n\n/** Fields a component's layer gives its copies unless an instance overrides them. */\nexport const INSTANCE_SYNC_PROPS: (keyof SceneNode)[] = difference(\n [\n ...SIZE_FIELDS,\n ...SIZE_CONSTRAINT_FIELDS,\n ...PAINT_FIELDS,\n ...STROKE_FIELDS,\n ...CORNER_FIELDS,\n ...AUTO_LAYOUT_FIELDS,\n // An instance frame and its component share one alignment in the file, so the instance\n // follows the component's instead of keeping its own.\n 'layoutAlignSelf',\n 'itemReverseZIndex',\n 'gridPosition',\n 'clipsContent',\n 'layoutGrids',\n 'boundVariables',\n 'variableModes',\n // Applied shared styles follow the component unless an instance overrides them.\n ...STYLE_LINK_FIELDS\n ],\n INSTANCE_FOLLOWED_FIELDS\n)\n\n/** How a layer inside an instance sits in its parent and whether it is locked, which its overrides may change. */\nconst INSTANCE_SYNC_CHILD_PROPS = ['layoutGrow', 'layoutAlignSelf', 'locked'] as const\n\n/** Fields an edit to a layer inside an instance records as that instance's override. */\nexport const INSTANCE_OVERRIDE_FIELDS = [\n ...INSTANCE_SYNC_PROPS,\n ...INSTANCE_SYNC_TEXT_PROPS,\n ...INSTANCE_SYNC_CHILD_PROPS,\n 'visible'\n] as const\n\n/** Fields a component's layer gives the copies of it in every instance. */\nexport const INSTANCE_SYNC_FIELDS = [\n ...INSTANCE_OVERRIDE_FIELDS,\n ...INSTANCE_FOLLOWED_FIELDS\n] as const\n\n/**\n * Fields an instance frame takes from its component frame, where the file keeps one value for\n * both: a layer inside an instance has no field of its own for them.\n */\nexport const INSTANCE_FRAME_FOLLOWED_FIELDS: (keyof SceneNode)[] = [\n 'layoutPositioning',\n 'layoutGrow',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight'\n]\n"],"mappings":";;;;;;;AASA,MAAa,2BAA2B;CACtC;CACA;CACA,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;AACF;;AAGA,MAAa,6BAAwE;CACnF,aAAa;CACb,WAAW;CACX,gBAAgB;AAClB;;;;;;AAOA,MAAa,2BAA2B;CACtC,GAAG;CAEH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,sBAA2C,WACtD;CACE,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CAGH;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,GAAG;AACL,GACA,wBACF;;AAGA,MAAM,4BAA4B;CAAC;CAAc;CAAmB;AAAQ;;AAG5E,MAAa,2BAA2B;CACtC,GAAG;CACH,GAAG;CACH,GAAG;CACH;AACF;;AAGA,MAAa,uBAAuB,CAClC,GAAG,0BACH,GAAG,wBACL;;;;;AAMA,MAAa,iCAAsD;CACjE;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -1,4 +1,5 @@
1
1
  import { NodeCloneMode } from "../copy.js";
2
+ import { InstanceOverrideState } from "./overrides.js";
2
3
  import { canCreateInstance, createsComponentCycle, cycleSafeParent } from "./cycles.js";
3
4
  import { instanceMainComponent } from "./main-component.js";
4
5
  import { isInShownReplacedLayer, isReplacedLayer, owningInstance, replacedComponentLayerId, showsReplacedLayer } from "./replacements.js";
@@ -16,8 +17,15 @@ interface SwapInstanceOptions {
16
17
  * such as preview, keeps names so layer paths stay the same.
17
18
  */
18
19
  keepName?: boolean;
20
+ /**
21
+ * Keep the overrides the instance's layers record, matched to the layers of the new component
22
+ * that take their places, as Figma keeps them when a variant changes. A swap that only
23
+ * materializes a layer the caller re-applies itself, such as a pen icon's glyph, skips this:
24
+ * what the placeholder recorded is scaffolding, not a user's edit.
25
+ */
26
+ restoreOverrides?: boolean;
19
27
  }
20
- declare function swapInstanceComponent(graph: SceneGraph, instanceId: string, componentId: string, { keepName }?: SwapInstanceOptions): void;
28
+ declare function swapInstanceComponent(graph: SceneGraph, instanceId: string, componentId: string, { keepName, restoreOverrides }?: SwapInstanceOptions): void;
21
29
  declare function syncInstances(graph: SceneGraph, componentId: string): void;
22
30
  /**
23
31
  * Syncs each component's instances, in order, as one edit: the copies they remove stay
@@ -37,10 +45,38 @@ declare function getMainComponent(graph: SceneGraph, instanceId: string): SceneN
37
45
  declare function getInstances(graph: SceneGraph, componentId: string): SceneNode[];
38
46
  /** Nearest INSTANCE at or above `nodeId` — self, parent, grandparent, etc. */
39
47
  declare function findInstanceAncestor(graph: SceneGraph, nodeId: string): SceneNode | undefined;
48
+ /**
49
+ * Whether Figma lets this layer take a size of its own: a layer inside an instance shows its
50
+ * component's size and cannot be resized, while an instance nested in another may be.
51
+ */
52
+ declare function takesOwnSize(graph: SceneGraph, node: SceneNode): boolean;
40
53
  /**
41
54
  * True when a node field is protected from instance synchronization.
42
55
  */
43
56
  declare function hasInstanceOverride(graph: SceneGraph, nodeId: string, field: string): boolean;
57
+ /**
58
+ * The instance above `instanceId` that records an assignment made through it: an assignment of a
59
+ * nested instance's property is an edit of the instance it sits in, not of the nested instance.
60
+ */
61
+ declare function assignmentOverrideOwner(graph: SceneGraph, instanceId: string): SceneNode | undefined;
62
+ /** The overrides an assignment edit writes on the instance above it, for undo to restore. */
63
+ interface AssignmentOverrideState {
64
+ ownerId: string;
65
+ overrides: InstanceOverrideState;
66
+ }
67
+ declare function takeAssignmentOverrideState(graph: SceneGraph, instanceId: string): AssignmentOverrideState | undefined;
68
+ declare function restoreAssignmentOverrideState(graph: SceneGraph, state: AssignmentOverrideState): void;
69
+ /**
70
+ * Records that an instance assigned one of its component properties, as an edit of the instance
71
+ * above it: the assignment is made through the outer instance, so a text override of the same
72
+ * level does not outrank it. A top-level instance has no outer instance to record it on.
73
+ */
74
+ declare function recordAssignmentOverride(graph: SceneGraph, instanceId: string, propertyId: string, value: string): void;
75
+ /**
76
+ * The fields `changes` overrides on an instance layer. New strokes that change only what the
77
+ * layer's line fields say override those fields, not the paints (`changesMoreThanStrokeLines`).
78
+ */
79
+ declare function instanceOverrideFields(node: SceneNode, changes: Partial<SceneNode>): string[];
44
80
  declare function recordInstanceOverride(graph: SceneGraph, nodeId: string, fields: Iterable<string>): void;
45
81
  /** Whether a layer can be replaced in its instance: it sits in the part the component owns. */
46
82
  declare function canReplaceInstanceLayer(graph: SceneGraph, nodeId: string): boolean;
@@ -59,5 +95,5 @@ declare function replaceInstanceLayer(graph: SceneGraph, targetId: string, repla
59
95
  */
60
96
  declare function restoreReplacedLayer(graph: SceneGraph, nodeId: string): boolean;
61
97
  //#endregion
62
- export { INSTANCE_FOLLOWED_FIELDS, INSTANCE_OVERRIDE_FIELDS, INSTANCE_SYNC_FIELDS, INSTANCE_SYNC_PROPS, INSTANCE_SYNC_TEXT_PROPS, SwapInstanceOptions, canCreateInstance, canReplaceInstanceLayer, copyInstanceComponentProps, createInstance, createsComponentCycle, cycleSafeParent, detachInstance, findInstanceAncestor, getInstances, getMainComponent, hasInstanceOverride, instanceMainComponent, isInShownReplacedLayer, isReplacedLayer, owningInstance, populateInstanceChildren, recordInstanceOverride, replaceInstanceLayer, replacedComponentLayerId, restoreReplacedLayer, retargetCopiedOverrides, showsReplacedLayer, swapInstanceComponent, syncInstance, syncInstances, syncInstancesTogether };
98
+ export { AssignmentOverrideState, INSTANCE_FOLLOWED_FIELDS, INSTANCE_OVERRIDE_FIELDS, INSTANCE_SYNC_FIELDS, INSTANCE_SYNC_PROPS, INSTANCE_SYNC_TEXT_PROPS, SwapInstanceOptions, assignmentOverrideOwner, canCreateInstance, canReplaceInstanceLayer, copyInstanceComponentProps, createInstance, createsComponentCycle, cycleSafeParent, detachInstance, findInstanceAncestor, getInstances, getMainComponent, hasInstanceOverride, instanceMainComponent, instanceOverrideFields, isInShownReplacedLayer, isReplacedLayer, owningInstance, populateInstanceChildren, recordAssignmentOverride, recordInstanceOverride, replaceInstanceLayer, replacedComponentLayerId, restoreAssignmentOverrideState, restoreReplacedLayer, retargetCopiedOverrides, showsReplacedLayer, swapInstanceComponent, syncInstance, syncInstances, syncInstancesTogether, takeAssignmentOverrideState, takesOwnSize };
63
99
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/instances/index.ts"],"mappings":";;;;;;;;iBAkDgB,2BAA2B,WAAW,YA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;iBAOtC,oBAAoB,OAAO,YAAY,gBAAgB;;;;;iBA2CvD,wBACd,OAAO,YACP,qBACC;;UAMc;EACf;EACA,WAAW;;iBAGG,4BACd,OAAO,YACP,qBACC;iBAOa,+BACd,OAAO,YACP,OAAO;;;;;;iBAYO,yBACd,OAAO,YACP,oBACA,oBACA;;;;;iBAkBc,uBAAuB,MAAM,WAAW,SAAS,QAAQ;iBAMzD,uBACd,OAAO,YACP,gBACA,QAAQ;;iBAsDM,wBAAwB,OAAO,YAAY;;;;;;;;;iBAqB3C,qBACd,OAAO,YACP,kBACA;;;;;iBAmDc,qBAAqB,OAAO,YAAY"}
@@ -1,26 +1,39 @@
1
- import { REPLACED_LAYER_OVERRIDE, copiedComponentLayerId, createInstanceOverrideState, getInstanceOverride, hasInstanceOverride as hasInstanceOverride$1, setInstanceOverride, variableModeOverrideField } from "./overrides.js";
1
+ import { REPLACED_LAYER_OVERRIDE, assignmentOverrideField, cloneInstanceOverrideState, copiedComponentLayerId, createInstanceOverrideState, getInstanceOverride, hasInstanceOverride as hasInstanceOverride$1, overriddenAssignmentId, setInstanceOverride, variableModeOverrideField } from "./overrides.js";
2
+ import { shapeGeometryChanges } from "../resize.js";
2
3
  import { instanceMainComponent } from "./main-component.js";
3
4
  import { detachOwnedSlotContent, restoreOwnedSlotContent } from "../slots/frames.js";
5
+ import { changesMoreThanStrokeLines } from "../strokes.js";
6
+ import { applyBoundPaintColorsIn, keepCopyBoundPaints } from "../variables/paints.js";
4
7
  import { keepOwnContentSize } from "./content-size.js";
5
8
  import { isInShownReplacedLayer, isReplacedLayer, owningInstance, replacedComponentLayerId, replacedLayerIn, showsReplacedLayer } from "./replacements.js";
6
9
  import { createInstanceSyncContext, groupCopyRemovals, removeLeftoverCopies } from "./copies.js";
7
- import { INSTANCE_FOLLOWED_FIELDS, INSTANCE_OVERRIDE_FIELDS, INSTANCE_SYNC_FIELDS, INSTANCE_SYNC_PROPS, INSTANCE_SYNC_TEXT_PROPS } from "./fields.js";
10
+ import { INSTANCE_FOLLOWED_FIELDS, INSTANCE_FRAME_FOLLOWED_FIELDS, INSTANCE_OVERRIDE_FIELDS, INSTANCE_SYNC_FIELDS, INSTANCE_SYNC_PROPS, INSTANCE_SYNC_TEXT_PROPS } from "./fields.js";
8
11
  import { differingVariableModeCollections } from "./modes.js";
9
- import { bindingProtection, cloneChildrenWithMapping, copyProp, enclosingInstanceOverrideFields, isProtectedSyncField, sourceInTargetCoordinates, syncBindingFields, syncChildren, syncVariableModeFields, updateSyncedProps } from "./sync.js";
12
+ import { applySyncedStrokeLines, bindingProtection, cloneChildrenWithMapping, copyProp, enclosingInstanceOverrideFields, isProtectedSyncField, sourceInTargetCoordinates, syncBindingFields, syncChildren, syncVariableModeFields, updateSyncedProps } from "./sync.js";
10
13
  import { slotScope } from "../slots/content.js";
11
14
  import { canCreateInstance, createsComponentCycle, cycleSafeParent } from "./cycles.js";
15
+ import { walkInstanceSources } from "./source-walk.js";
16
+ import { captureInstanceOverrides, restoreInstanceOverrides } from "./swap-overrides.js";
12
17
  //#region src/instances/index.ts
13
18
  function copyInstanceComponentProps(component) {
14
19
  const props = {};
15
- for (const key of INSTANCE_SYNC_PROPS) copyProp(props, component, key);
20
+ for (const key of [...INSTANCE_SYNC_PROPS, ...INSTANCE_FRAME_FOLLOWED_FIELDS]) copyProp(props, component, key);
16
21
  return props;
17
22
  }
23
+ /**
24
+ * The name Figma gives a new instance of `component`: its component set's name for a variant,
25
+ * whose own name only says which variant it is, and the component's own name otherwise.
26
+ */
27
+ function instanceComponentName(graph, component) {
28
+ const parent = component.parentId ? graph.nodes.get(component.parentId) : void 0;
29
+ return parent?.type === "COMPONENT_SET" ? parent.name : component.name;
30
+ }
18
31
  function createInstance(graph, componentId, parentId, overrides = {}) {
19
32
  const component = graph.nodes.get(componentId);
20
33
  if (component?.type !== "COMPONENT" || !canCreateInstance(graph, componentId, parentId)) return null;
21
34
  const props = {
22
35
  ...copyInstanceComponentProps(component),
23
- name: component.name
36
+ name: instanceComponentName(graph, component)
24
37
  };
25
38
  const instance = graph.createNode("INSTANCE", parentId, {
26
39
  ...props,
@@ -28,6 +41,7 @@ function createInstance(graph, componentId, parentId, overrides = {}) {
28
41
  componentId
29
42
  });
30
43
  cloneChildrenWithMapping(graph, component.id, instance.id);
44
+ applyBoundPaintColorsIn(graph, instance.id);
31
45
  return instance;
32
46
  }
33
47
  function populateInstanceChildren(graph, instanceId, componentId, mode = "deep") {
@@ -49,7 +63,7 @@ function recordNestedSwap(graph, instance, componentId) {
49
63
  setInstanceOverride(owner.instanceOverrides, owner.id, instance.id, "componentId", componentId);
50
64
  graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides });
51
65
  }
52
- function swapInstanceComponent(graph, instanceId, componentId, { keepName = false } = {}) {
66
+ function swapInstanceComponent(graph, instanceId, componentId, { keepName = false, restoreOverrides = true } = {}) {
53
67
  const instance = graph.nodes.get(instanceId);
54
68
  const component = graph.nodes.get(componentId);
55
69
  if (!instance || component?.type !== "COMPONENT" || instance.type !== "INSTANCE") return;
@@ -64,16 +78,29 @@ function swapInstanceComponent(graph, instanceId, componentId, { keepName = fals
64
78
  copyProp(updates, source, key);
65
79
  }
66
80
  syncVariableModeFields(instance, source, updates, overridden);
67
- if (!keepName && (!previousComponent || instance.name === previousComponent.name)) updates.name = component.name;
81
+ applySyncedStrokeLines(graph, instance, updates, overridden);
82
+ if (!keepName && (!previousComponent || instance.name === instanceComponentName(graph, previousComponent))) updates.name = instanceComponentName(graph, component);
83
+ keepCopyBoundPaints(graph, instance, updates);
68
84
  const childIds = Array.from(instance.childIds);
69
85
  const slotContent = detachOwnedSlotContent(graph, instance);
86
+ swapInstanceLayers(graph, instanceId, componentId, updates, childIds, restoreOverrides);
87
+ restoreOwnedSlotContent(graph, instance, slotContent);
88
+ }
89
+ /**
90
+ * Replaces the instance's layers with clones of its new component's and gives the recorded
91
+ * overrides back to the layers that take the old ones' places, matched by name path.
92
+ */
93
+ function swapInstanceLayers(graph, instanceId, componentId, updates, childIds, restoreOverrides) {
94
+ const capturedOverrides = restoreOverrides ? captureInstanceOverrides(graph, graph.nodes.get(instanceId)) : void 0;
70
95
  for (const childId of childIds) {
71
96
  forgetOverridesOf(graph, childId);
72
97
  graph.deleteNode(childId);
73
98
  }
74
99
  graph.updateNode(instanceId, updates);
75
100
  cloneChildrenWithMapping(graph, componentId, instanceId);
76
- restoreOwnedSlotContent(graph, instance, slotContent);
101
+ applyBoundPaintColorsIn(graph, instanceId);
102
+ const swapped = graph.nodes.get(instanceId);
103
+ if (swapped && capturedOverrides) restoreInstanceOverrides(graph, swapped, capturedOverrides);
77
104
  }
78
105
  const syncingComponentsByGraph = /* @__PURE__ */ new WeakMap();
79
106
  function syncInstances(graph, componentId) {
@@ -119,8 +146,10 @@ function syncInstancesOf(graph, componentId, instances) {
119
146
  if (isProtectedSyncField(instance, key, protectedField)) continue;
120
147
  copyProp(updates, source, key);
121
148
  }
149
+ for (const key of INSTANCE_FRAME_FOLLOWED_FIELDS) if (!isProtectedSyncField(instance, key, protectedField)) copyProp(updates, source, key);
122
150
  keepOwnContentSize(graph, updates, instance, source);
123
- updateSyncedProps(graph, instance, updates);
151
+ if (updates.width !== void 0 || updates.height !== void 0) Object.assign(updates, shapeGeometryChanges(instance, updates.width ?? instance.width, updates.height ?? instance.height));
152
+ updateSyncedProps(graph, instance, updates, (key) => isProtectedSyncField(instance, key, protectedField));
124
153
  const context = createInstanceSyncContext(instance.id, instance.instanceOverrides);
125
154
  syncChildren(graph, component.id, instance.id, instance.instanceOverrides, context);
126
155
  removeLeftoverCopies(graph, context, removals);
@@ -147,12 +176,56 @@ function retargetCopiedOverrides(graph, copies) {
147
176
  }
148
177
  }
149
178
  function detachInstance(graph, instanceId) {
150
- if (graph.nodes.get(instanceId)?.type !== "INSTANCE") return;
179
+ const node = graph.nodes.get(instanceId);
180
+ if (node?.type !== "INSTANCE") return;
181
+ for (const nested of outermostNestedInstances(graph, node)) adoptNestedOverrides(graph, node, nested);
151
182
  graph.updateNode(instanceId, {
152
183
  type: "FRAME",
153
184
  componentId: null,
154
185
  instanceOverrides: createInstanceOverrideState()
155
186
  });
187
+ const detachLinks = (parentId) => {
188
+ for (const child of graph.getChildren(parentId)) {
189
+ if (child.type === "INSTANCE") continue;
190
+ if (child.componentId) graph.updateNode(child.id, { componentId: null });
191
+ detachLinks(child.id);
192
+ }
193
+ };
194
+ detachLinks(instanceId);
195
+ }
196
+ const OWNER_ONLY_FIELDS = /* @__PURE__ */ new Set(["componentId", "sourceComponentId"]);
197
+ function outermostNestedInstances(graph, instance) {
198
+ return graph.getChildren(instance.id).flatMap((child) => child.type === "INSTANCE" ? [child] : outermostNestedInstances(graph, child));
199
+ }
200
+ /**
201
+ * An instance a detached one holds stands on its own once that one is a frame, and so must what
202
+ * makes it differ from its component. Cloned in, it kept the overrides of the instance it copies,
203
+ * under that instance's layers; those, and the ones the detached instance recorded on its layers,
204
+ * now go under its own.
205
+ */
206
+ function adoptNestedOverrides(graph, detached, nested) {
207
+ const ownLayer = /* @__PURE__ */ new Map();
208
+ walkInstanceSources(graph, nested, (source, target) => {
209
+ ownLayer.set(source.id, target.id);
210
+ return true;
211
+ });
212
+ const { self, descendants: kept } = cloneInstanceOverrideState(nested.instanceOverrides);
213
+ const outer = cloneInstanceOverrideState(detached.instanceOverrides).descendants;
214
+ const descendants = /* @__PURE__ */ new Map();
215
+ const claim = (layerId, fields) => {
216
+ const merged = descendants.get(layerId);
217
+ if (!merged) descendants.set(layerId, fields);
218
+ else for (const [field, value] of fields) merged.set(field, value);
219
+ };
220
+ for (const [layerId, fields] of kept) if (ownLayer.has(layerId)) claim(ownLayer.get(layerId) ?? layerId, fields);
221
+ for (const [layerId, fields] of kept) if (!ownLayer.has(layerId)) claim(layerId, fields);
222
+ for (const [layerId, fields] of outer) if (layerId === nested.id) {
223
+ for (const [field, value] of fields) if (!OWNER_ONLY_FIELDS.has(field)) self.set(field, value);
224
+ } else if (graph.isDescendant(layerId, nested.id)) claim(layerId, fields);
225
+ graph.updateNode(nested.id, { instanceOverrides: {
226
+ self,
227
+ descendants
228
+ } });
156
229
  }
157
230
  function getMainComponent(graph, instanceId) {
158
231
  const node = graph.nodes.get(instanceId);
@@ -178,6 +251,13 @@ function findInstanceAncestor(graph, nodeId) {
178
251
  }
179
252
  }
180
253
  /**
254
+ * Whether Figma lets this layer take a size of its own: a layer inside an instance shows its
255
+ * component's size and cannot be resized, while an instance nested in another may be.
256
+ */
257
+ function takesOwnSize(graph, node) {
258
+ return node.type === "INSTANCE" || !node.parentId || !findInstanceAncestor(graph, node.parentId);
259
+ }
260
+ /**
181
261
  * True when a node field is protected from instance synchronization.
182
262
  */
183
263
  function hasInstanceOverride(graph, nodeId, field) {
@@ -205,13 +285,52 @@ function overrideFieldsOf(graph, instance, nodeId, fields) {
205
285
  if (!node || !source) return fields;
206
286
  return [...fields.filter((field) => field !== "variableModes"), ...differingVariableModeCollections(node, source).map(variableModeOverrideField)];
207
287
  }
288
+ /**
289
+ * The instance above `instanceId` that records an assignment made through it: an assignment of a
290
+ * nested instance's property is an edit of the instance it sits in, not of the nested instance.
291
+ */
292
+ function assignmentOverrideOwner(graph, instanceId) {
293
+ const parentId = graph.nodes.get(instanceId)?.parentId;
294
+ return parentId ? findInstanceAncestor(graph, parentId) : void 0;
295
+ }
296
+ function takeAssignmentOverrideState(graph, instanceId) {
297
+ const owner = assignmentOverrideOwner(graph, instanceId);
298
+ return owner ? {
299
+ ownerId: owner.id,
300
+ overrides: cloneInstanceOverrideState(owner.instanceOverrides)
301
+ } : void 0;
302
+ }
303
+ function restoreAssignmentOverrideState(graph, state) {
304
+ graph.updateNode(state.ownerId, { instanceOverrides: cloneInstanceOverrideState(state.overrides) });
305
+ }
306
+ /**
307
+ * Records that an instance assigned one of its component properties, as an edit of the instance
308
+ * above it: the assignment is made through the outer instance, so a text override of the same
309
+ * level does not outrank it. A top-level instance has no outer instance to record it on.
310
+ */
311
+ function recordAssignmentOverride(graph, instanceId, propertyId, value) {
312
+ const outer = assignmentOverrideOwner(graph, instanceId);
313
+ if (!outer) return;
314
+ setInstanceOverride(outer.instanceOverrides, outer.id, instanceId, assignmentOverrideField(propertyId), value);
315
+ graph.updateNode(outer.id, { instanceOverrides: outer.instanceOverrides });
316
+ }
317
+ /**
318
+ * The fields `changes` overrides on an instance layer. New strokes that change only what the
319
+ * layer's line fields say override those fields, not the paints (`changesMoreThanStrokeLines`).
320
+ */
321
+ function instanceOverrideFields(node, changes) {
322
+ const fields = Object.keys(changes);
323
+ if (!changes.strokes || changesMoreThanStrokeLines(node, changes)) return fields;
324
+ return fields.filter((field) => field !== "strokes");
325
+ }
208
326
  function recordInstanceOverride(graph, nodeId, fields) {
209
327
  const instance = findInstanceAncestor(graph, nodeId);
210
328
  if (!instance) return;
211
- const relevant = overrideFieldsOf(graph, instance, nodeId, [...fields].filter((field) => INSTANCE_OVERRIDE_FIELDS.includes(field)));
212
- if (relevant.length === 0) return;
213
- for (const field of relevant) setInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field);
214
- graph.updateNode(instance.id, { instanceOverrides: instance.instanceOverrides });
329
+ const added = overrideFieldsOf(graph, instance, nodeId, [...fields].filter((field) => INSTANCE_OVERRIDE_FIELDS.includes(field) || overriddenAssignmentId(field) !== null)).filter((field) => !hasInstanceOverride$1(instance.instanceOverrides, instance.id, nodeId, field));
330
+ if (added.length === 0) return;
331
+ const overrides = cloneInstanceOverrideState(instance.instanceOverrides);
332
+ for (const field of added) setInstanceOverride(overrides, instance.id, nodeId, field);
333
+ graph.updateNode(instance.id, { instanceOverrides: overrides });
215
334
  }
216
335
  /** Every layer at or below `rootId`. */
217
336
  function subtreeIds(graph, rootId) {
@@ -303,6 +422,6 @@ function restoreReplacedLayer(graph, nodeId) {
303
422
  return true;
304
423
  }
305
424
  //#endregion
306
- export { INSTANCE_FOLLOWED_FIELDS, INSTANCE_OVERRIDE_FIELDS, INSTANCE_SYNC_FIELDS, INSTANCE_SYNC_PROPS, INSTANCE_SYNC_TEXT_PROPS, canCreateInstance, canReplaceInstanceLayer, copyInstanceComponentProps, createInstance, createsComponentCycle, cycleSafeParent, detachInstance, findInstanceAncestor, getInstances, getMainComponent, hasInstanceOverride, instanceMainComponent, isInShownReplacedLayer, isReplacedLayer, owningInstance, populateInstanceChildren, recordInstanceOverride, replaceInstanceLayer, replacedComponentLayerId, restoreReplacedLayer, retargetCopiedOverrides, showsReplacedLayer, swapInstanceComponent, syncInstance, syncInstances, syncInstancesTogether };
425
+ export { INSTANCE_FOLLOWED_FIELDS, INSTANCE_OVERRIDE_FIELDS, INSTANCE_SYNC_FIELDS, INSTANCE_SYNC_PROPS, INSTANCE_SYNC_TEXT_PROPS, assignmentOverrideOwner, canCreateInstance, canReplaceInstanceLayer, copyInstanceComponentProps, createInstance, createsComponentCycle, cycleSafeParent, detachInstance, findInstanceAncestor, getInstances, getMainComponent, hasInstanceOverride, instanceMainComponent, instanceOverrideFields, isInShownReplacedLayer, isReplacedLayer, owningInstance, populateInstanceChildren, recordAssignmentOverride, recordInstanceOverride, replaceInstanceLayer, replacedComponentLayerId, restoreAssignmentOverrideState, restoreReplacedLayer, retargetCopiedOverrides, showsReplacedLayer, swapInstanceComponent, syncInstance, syncInstances, syncInstancesTogether, takeAssignmentOverrideState, takesOwnSize };
307
426
 
308
427
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["hasNodeInstanceOverride"],"sources":["../../src/instances/index.ts"],"sourcesContent":["import type { NodeCloneMode } from '../copy'\nimport type { SceneGraph } from '../graph'\nimport { slotScope } from '../slots/content'\nimport { detachOwnedSlotContent, restoreOwnedSlotContent } from '../slots/frames'\nimport type { SceneNode } from '../types'\nimport { keepOwnContentSize } from './content-size'\nimport { createInstanceSyncContext, groupCopyRemovals, removeLeftoverCopies } from './copies'\nimport { canCreateInstance, createsComponentCycle } from './cycles'\nimport { INSTANCE_OVERRIDE_FIELDS, INSTANCE_SYNC_PROPS } from './fields'\nimport { differingVariableModeCollections } from './modes'\nimport {\n copiedComponentLayerId,\n createInstanceOverrideState,\n getInstanceOverride,\n hasInstanceOverride as hasNodeInstanceOverride,\n REPLACED_LAYER_OVERRIDE,\n setInstanceOverride,\n variableModeOverrideField\n} from './overrides'\nimport { owningInstance, replacedLayerIn } from './replacements'\nimport {\n bindingProtection,\n cloneChildrenWithMapping,\n copyProp,\n enclosingInstanceOverrideFields,\n isProtectedSyncField,\n sourceInTargetCoordinates,\n syncBindingFields,\n syncChildren,\n syncVariableModeFields,\n updateSyncedProps\n} from './sync'\n\nexport { canCreateInstance, createsComponentCycle, cycleSafeParent } from './cycles'\nexport { instanceMainComponent } from './main-component'\nexport {\n isInShownReplacedLayer,\n isReplacedLayer,\n owningInstance,\n replacedComponentLayerId,\n showsReplacedLayer\n} from './replacements'\nexport {\n INSTANCE_FOLLOWED_FIELDS,\n INSTANCE_OVERRIDE_FIELDS,\n INSTANCE_SYNC_FIELDS,\n INSTANCE_SYNC_PROPS,\n INSTANCE_SYNC_TEXT_PROPS\n} from './fields'\n\nexport function copyInstanceComponentProps(component: SceneNode): Partial<SceneNode> {\n const props: Partial<SceneNode> = {}\n for (const key of INSTANCE_SYNC_PROPS) copyProp(props, component, key)\n return props\n}\n\nexport function createInstance(\n graph: SceneGraph,\n componentId: string,\n parentId: string,\n overrides: Partial<SceneNode> = {}\n): SceneNode | null {\n const component = graph.nodes.get(componentId)\n if (component?.type !== 'COMPONENT' || !canCreateInstance(graph, componentId, parentId))\n return null\n\n const props: Partial<SceneNode> = {\n ...copyInstanceComponentProps(component),\n name: component.name\n }\n\n // The component checked above is the one the instance shows, whatever `overrides` holds.\n const instance = graph.createNode('INSTANCE', parentId, { ...props, ...overrides, componentId })\n\n cloneChildrenWithMapping(graph, component.id, instance.id)\n\n return instance\n}\n\nexport function populateInstanceChildren(\n graph: SceneGraph,\n instanceId: string,\n componentId: string,\n mode: NodeCloneMode = 'deep'\n): void {\n const instance = graph.nodes.get(instanceId)\n const component = graph.nodes.get(componentId)\n if (!instance || !component || instance.type !== 'INSTANCE') return\n cloneChildrenWithMapping(graph, componentId, instanceId, mode)\n}\n\n/**\n * A nested instance's link to the enclosing component's record is its `componentId` when it\n * was populated by cloning. A swap replaces that field, so keep the correspondence as the\n * owner's `sourceComponentId` override and record the swap itself; materialized documents\n * already carry the correspondence and only gain the swap.\n */\nfunction recordNestedSwap(graph: SceneGraph, instance: SceneNode, componentId: string): void {\n const owner = instance.parentId ? findInstanceAncestor(graph, instance.parentId) : undefined\n if (!owner) return\n const existing = getInstanceOverride(\n owner.instanceOverrides,\n owner.id,\n instance.id,\n 'sourceComponentId'\n )\n if (typeof existing !== 'string' && instance.componentId)\n setInstanceOverride(\n owner.instanceOverrides,\n owner.id,\n instance.id,\n 'sourceComponentId',\n instance.componentId\n )\n setInstanceOverride(owner.instanceOverrides, owner.id, instance.id, 'componentId', componentId)\n graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides })\n}\n\nexport interface SwapInstanceOptions {\n /**\n * Keep the instance's name even when it is its old component's. A swap otherwise renames such\n * an instance after the new component, as Figma does; a view that only shows another variant,\n * such as preview, keeps names so layer paths stay the same.\n */\n keepName?: boolean\n}\n\nexport function swapInstanceComponent(\n graph: SceneGraph,\n instanceId: string,\n componentId: string,\n { keepName = false }: SwapInstanceOptions = {}\n): void {\n const instance = graph.nodes.get(instanceId)\n const component = graph.nodes.get(componentId)\n if (!instance || component?.type !== 'COMPONENT' || instance.type !== 'INSTANCE') return\n if (instance.parentId && !canCreateInstance(graph, componentId, instance.parentId)) return\n\n const previousComponent = instance.componentId ? graph.nodes.get(instance.componentId) : undefined\n recordNestedSwap(graph, instance, componentId)\n const updates: Partial<SceneNode> = { componentId }\n const source = sourceInTargetCoordinates(component, instance.componentScale)\n const overridden = (field: string) =>\n hasNodeInstanceOverride(instance.instanceOverrides, instance.id, instance.id, field)\n for (const key of INSTANCE_SYNC_PROPS) {\n if (key === 'variableModes' || overridden(key)) continue\n copyProp(updates, source, key)\n }\n syncVariableModeFields(instance, source, updates, overridden)\n\n if (!keepName && (!previousComponent || instance.name === previousComponent.name))\n updates.name = component.name\n\n const childIds = Array.from(instance.childIds)\n const slotContent = detachOwnedSlotContent(graph, instance)\n for (const childId of childIds) {\n // The clones take new IDs, so what was recorded for the removed layers would never apply.\n forgetOverridesOf(graph, childId)\n graph.deleteNode(childId)\n }\n graph.updateNode(instanceId, updates)\n cloneChildrenWithMapping(graph, componentId, instanceId)\n restoreOwnedSlotContent(graph, instance, slotContent)\n}\n\nconst syncingComponentsByGraph = new WeakMap<SceneGraph, Set<string>>()\n\nexport function syncInstances(graph: SceneGraph, componentId: string): void {\n syncInstancesOf(graph, componentId, getInstances(graph, componentId))\n}\n\n/**\n * Syncs each component's instances, in order, as one edit: the copies they remove stay\n * restorable together for as long as undo keeps that edit.\n */\nexport function syncInstancesTogether(graph: SceneGraph, componentIds: Iterable<string>): void {\n groupCopyRemovals(graph, () => {\n for (const id of componentIds) syncInstances(graph, id)\n })\n}\n\n/** Syncs one instance from its component, as `syncInstances` does for every instance. */\nexport function syncInstance(graph: SceneGraph, instanceId: string): void {\n const instance = graph.nodes.get(instanceId)\n if (instance?.type !== 'INSTANCE' || !instance.componentId) return\n syncInstancesOf(graph, instance.componentId, [instance])\n}\n\nfunction syncInstancesOf(\n graph: SceneGraph,\n componentId: string,\n instances: Iterable<SceneNode>\n): void {\n const component = graph.nodes.get(componentId)\n if (component?.type !== 'COMPONENT') return\n let syncing = syncingComponentsByGraph.get(graph)\n if (!syncing) {\n syncing = new Set()\n syncingComponentsByGraph.set(graph, syncing)\n }\n if (syncing.has(componentId)) return\n syncing.add(componentId)\n try {\n groupCopyRemovals(graph, (removals) => {\n for (const instance of instances) {\n const enclosing = enclosingInstanceOverrideFields(graph, instance)\n enclosing.push(new Set(instance.instanceOverrides.self.keys()))\n const protectedField = bindingProtection(enclosing)\n const source = sourceInTargetCoordinates(component, instance.componentScale)\n const updates: Partial<SceneNode> = {}\n syncBindingFields(instance, source, updates, protectedField)\n syncVariableModeFields(instance, source, updates, protectedField)\n for (const key of INSTANCE_SYNC_PROPS) {\n if (key === 'boundVariables' || key === 'variableModes') continue\n if (isProtectedSyncField(instance, key, protectedField)) continue\n copyProp(updates, source, key)\n }\n // An instance that hugs its layers sizes to what it shows, not to the component.\n keepOwnContentSize(graph, updates, instance, source)\n updateSyncedProps(graph, instance, updates)\n const context = createInstanceSyncContext(instance.id, instance.instanceOverrides)\n syncChildren(graph, component.id, instance.id, instance.instanceOverrides, context)\n removeLeftoverCopies(graph, context, removals)\n }\n })\n } finally {\n syncing.delete(componentId)\n }\n}\n\n/**\n * Renames the layers that the copied instances among `copies` record overrides for to their\n * copies, as a copied instance records its own layers' overrides. The values keep naming what\n * they name, since a copy shows the same components as its source.\n */\nexport function retargetCopiedOverrides(\n graph: SceneGraph,\n copies: ReadonlyMap<string, string>\n): void {\n for (const id of copies.values()) {\n const node = graph.nodes.get(id)\n if (node?.type !== 'INSTANCE' || node.instanceOverrides.descendants.size === 0) continue\n const descendants = new Map(\n [...node.instanceOverrides.descendants].map(([target, fields]) => [\n copies.get(target) ?? target,\n fields\n ])\n )\n graph.updateNode(id, { instanceOverrides: { ...node.instanceOverrides, descendants } })\n }\n}\n\nexport function detachInstance(graph: SceneGraph, instanceId: string): void {\n const node = graph.nodes.get(instanceId)\n if (node?.type !== 'INSTANCE') return\n // Through `updateNode`, so the instance index, change observers, and undo recorders see it.\n graph.updateNode(instanceId, {\n type: 'FRAME',\n componentId: null,\n instanceOverrides: createInstanceOverrideState()\n })\n}\n\nexport function getMainComponent(graph: SceneGraph, instanceId: string): SceneNode | undefined {\n const node = graph.nodes.get(instanceId)\n if (!node?.componentId) return undefined\n return graph.nodes.get(node.componentId)\n}\n\nexport function getInstances(graph: SceneGraph, componentId: string): SceneNode[] {\n const ids = graph.instanceIndex.get(componentId)\n if (!ids) return []\n const instances: SceneNode[] = []\n for (const id of ids) {\n const node = graph.nodes.get(id)\n if (node) instances.push(node)\n }\n return instances\n}\n\n/** Nearest INSTANCE at or above `nodeId` — self, parent, grandparent, etc. */\nexport function findInstanceAncestor(graph: SceneGraph, nodeId: string): SceneNode | undefined {\n let current = graph.nodes.get(nodeId)\n while (current) {\n if (current.type === 'INSTANCE') return current\n current = current.parentId ? graph.nodes.get(current.parentId) : undefined\n }\n return undefined\n}\n\n/**\n * True when a node field is protected from instance synchronization.\n */\nexport function hasInstanceOverride(graph: SceneGraph, nodeId: string, field: string): boolean {\n const instance = findInstanceAncestor(graph, nodeId)\n if (!instance) return false\n return hasNodeInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field)\n}\n\n/**\n * The layer of the component an instance layer copies, which its overrides are measured\n * against: the instance's component for the instance itself.\n */\nfunction copiedLayer(graph: SceneGraph, instance: SceneNode, node: SceneNode) {\n const id =\n node.id === instance.id\n ? instance.componentId\n : copiedComponentLayerId(instance.instanceOverrides, instance.id, node)\n return id ? graph.nodes.get(id) : undefined\n}\n\n/**\n * The override fields an edit of these fields records. A mode edit claims only the collections\n * whose mode now differs from the component layer's, so the component's other modes still\n * reach the layer; with no layer to compare, it claims every mode.\n */\nfunction overrideFieldsOf(\n graph: SceneGraph,\n instance: SceneNode,\n nodeId: string,\n fields: string[]\n): string[] {\n if (!fields.includes('variableModes')) return fields\n const node = graph.nodes.get(nodeId)\n const source = node && copiedLayer(graph, instance, node)\n if (!node || !source) return fields\n return [\n ...fields.filter((field) => field !== 'variableModes'),\n ...differingVariableModeCollections(node, source).map(variableModeOverrideField)\n ]\n}\n\nexport function recordInstanceOverride(\n graph: SceneGraph,\n nodeId: string,\n fields: Iterable<string>\n): void {\n const instance = findInstanceAncestor(graph, nodeId)\n if (!instance) return\n\n const relevant = overrideFieldsOf(\n graph,\n instance,\n nodeId,\n [...fields].filter((field) => (INSTANCE_OVERRIDE_FIELDS as readonly string[]).includes(field))\n )\n\n if (relevant.length === 0) return\n\n for (const field of relevant)\n setInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field)\n graph.updateNode(instance.id, { instanceOverrides: instance.instanceOverrides })\n}\n\n/** Every layer at or below `rootId`. */\nfunction subtreeIds(graph: SceneGraph, rootId: string): string[] {\n const ids: string[] = []\n const visit = (id: string) => {\n ids.push(id)\n for (const childId of graph.nodes.get(id)?.childIds ?? []) visit(childId)\n }\n visit(rootId)\n return ids\n}\n\n/** Forget what the instances above `nodeId` recorded for it and the layers inside it. */\nfunction forgetOverridesOf(graph: SceneGraph, nodeId: string): void {\n const ids = subtreeIds(graph, nodeId)\n const parentId = graph.nodes.get(nodeId)?.parentId\n if (!parentId) return\n graph.closest(parentId, (ancestor) => {\n if (ancestor.type !== 'INSTANCE') return false\n const { descendants } = ancestor.instanceOverrides\n if (ids.some((id) => descendants.delete(id)))\n graph.updateNode(ancestor.id, { instanceOverrides: ancestor.instanceOverrides })\n return false\n })\n}\n\n/** Whether a layer can be replaced in its instance: it sits in the part the component owns. */\nexport function canReplaceInstanceLayer(graph: SceneGraph, nodeId: string): boolean {\n const node = graph.nodes.get(nodeId)\n const owner = node && owningInstance(graph, node)\n if (!node?.parentId || !owner) return false\n // Slot content is the instance's own already, and a generated frame's layers are fixed.\n const scope = slotScope(graph, node.parentId)\n if (scope.kind !== 'locked' || scope.owner.type !== 'INSTANCE') return false\n return (\n replacedLayerIn(owner, node.id) !== undefined ||\n copiedComponentLayerId(owner.instanceOverrides, owner.id, node) !== undefined\n )\n}\n\n/**\n * Put `replacementId` in place of `targetId`, a layer an instance copies from its component, as\n * an override of the nearest instance above it, as pen.dev replaces a layer inside an instance.\n * The replacement takes the target's place among its siblings and its position, the target\n * goes, and syncs keep the replacement in place of the component layer the target copied. A\n * replaced layer can be replaced again. Returns false and changes nothing when the target is no\n * such layer, or the replacement cannot go there.\n */\nexport function replaceInstanceLayer(\n graph: SceneGraph,\n targetId: string,\n replacementId: string\n): boolean {\n const target = graph.nodes.get(targetId)\n const replacement = graph.nodes.get(replacementId)\n const parentId = target?.parentId\n if (!target || !replacement || !parentId || targetId === replacementId) return false\n const owner = owningInstance(graph, target)\n if (!owner || graph.isDescendant(parentId, replacementId)) return false\n if (createsComponentCycle(graph, replacementId, parentId)) return false\n const layerId =\n replacedLayerIn(owner, target.id) ??\n copiedComponentLayerId(owner.instanceOverrides, owner.id, target)\n if (!layerId) return false\n\n // The replacement copies no layer of the component, so its own layers lose such links; an\n // instance among them keeps its own component and layers.\n const unlink = (id: string) => {\n const node = graph.nodes.get(id)\n if (!node) return\n if (node.type !== 'INSTANCE' && node.componentId) graph.updateNode(id, { componentId: null })\n if (node.type !== 'INSTANCE') node.childIds.forEach(unlink)\n }\n unlink(replacementId)\n\n const index = graph.nodes.get(parentId)?.childIds.indexOf(target.id) ?? -1\n forgetOverridesOf(graph, target.id)\n forgetOverridesOf(graph, replacementId)\n graph.insertChildAt(replacementId, parentId, index < 0 ? Number.MAX_SAFE_INTEGER : index)\n graph.updateNode(replacementId, {\n x: target.x,\n y: target.y,\n layoutPositioning: target.layoutPositioning,\n horizontalConstraint: target.horizontalConstraint,\n verticalConstraint: target.verticalConstraint\n })\n graph.deleteNode(target.id)\n setInstanceOverride(\n owner.instanceOverrides,\n owner.id,\n replacementId,\n REPLACED_LAYER_OVERRIDE,\n layerId\n )\n graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides })\n return true\n}\n\n/**\n * Take a replaced layer out and bring back the component layer it stood in for, synced from the\n * outermost instance as a reset syncs. Returns false when the layer is not a replaced one.\n */\nexport function restoreReplacedLayer(graph: SceneGraph, nodeId: string): boolean {\n const node = graph.nodes.get(nodeId)\n const owner = node && owningInstance(graph, node)\n if (!node || !owner || replacedLayerIn(owner, nodeId) === undefined) return false\n let outermost = owner\n for (let above = owningInstance(graph, owner); above; above = owningInstance(graph, above))\n outermost = above\n forgetOverridesOf(graph, nodeId)\n graph.deleteNode(nodeId)\n syncInstance(graph, outermost.id)\n // An enclosing sync stops at a swapped instance, which brings its layers back itself.\n const above = owningInstance(graph, owner)\n if (above && getInstanceOverride(above.instanceOverrides, above.id, owner.id, 'componentId'))\n syncInstance(gra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Ae,OAAO,IAAI;CAChD,IAAI,CAAC,QAAQ,CAAC,SAAS,gBAAgB,OAAO,MAAM,MAAM,KAAA,GAAW,OAAO;CAC5E,IAAI,YAAY;CAChB,KAAK,IAAI,QAAQ,eAAe,OAAO,KAAK,GAAG,OAAO,QAAQ,eAAe,OAAO,KAAK,GACvF,YAAY;CACd,kBAAkB,OAAO,MAAM;CAC/B,MAAM,WAAW,MAAM;CACvB,aAAa,OAAO,UAAU,EAAE;CAEhC,MAAM,QAAQ,eAAe,OAAO,KAAK;CACzC,IAAI,SAAS,oBAAoB,MAAM,mBAAmB,MAAM,IAAI,MAAM,IAAI,aAAa,GACzF,aAAa,OAAO,MAAM,EAAE;CAC9B,OAAO;AACT"}
1
+ {"version":3,"file":"index.js","names":["hasNodeInstanceOverride"],"sources":["../../src/instances/index.ts"],"sourcesContent":["import type { NodeCloneMode } from '../copy'\nimport type { SceneGraph } from '../graph'\nimport { shapeGeometryChanges } from '../resize'\nimport { slotScope } from '../slots/content'\nimport { detachOwnedSlotContent, restoreOwnedSlotContent } from '../slots/frames'\nimport { changesMoreThanStrokeLines } from '../strokes'\nimport type { SceneNode } from '../types'\nimport { applyBoundPaintColorsIn, keepCopyBoundPaints } from '../variables/paints'\nimport { keepOwnContentSize } from './content-size'\nimport { createInstanceSyncContext, groupCopyRemovals, removeLeftoverCopies } from './copies'\nimport { canCreateInstance, createsComponentCycle } from './cycles'\nimport {\n INSTANCE_FRAME_FOLLOWED_FIELDS,\n INSTANCE_OVERRIDE_FIELDS,\n INSTANCE_SYNC_PROPS\n} from './fields'\nimport { differingVariableModeCollections } from './modes'\nimport {\n assignmentOverrideField,\n cloneInstanceOverrideState,\n copiedComponentLayerId,\n createInstanceOverrideState,\n getInstanceOverride,\n hasInstanceOverride as hasNodeInstanceOverride,\n type InstanceOverrideState,\n overriddenAssignmentId,\n REPLACED_LAYER_OVERRIDE,\n setInstanceOverride,\n variableModeOverrideField\n} from './overrides'\nimport { owningInstance, replacedLayerIn } from './replacements'\nimport { walkInstanceSources } from './source-walk'\nimport { captureInstanceOverrides, restoreInstanceOverrides } from './swap-overrides'\nimport {\n applySyncedStrokeLines,\n bindingProtection,\n cloneChildrenWithMapping,\n copyProp,\n enclosingInstanceOverrideFields,\n isProtectedSyncField,\n sourceInTargetCoordinates,\n syncBindingFields,\n syncChildren,\n syncVariableModeFields,\n updateSyncedProps\n} from './sync'\n\nexport { canCreateInstance, createsComponentCycle, cycleSafeParent } from './cycles'\nexport { instanceMainComponent } from './main-component'\nexport {\n isInShownReplacedLayer,\n isReplacedLayer,\n owningInstance,\n replacedComponentLayerId,\n showsReplacedLayer\n} from './replacements'\nexport {\n INSTANCE_FOLLOWED_FIELDS,\n INSTANCE_OVERRIDE_FIELDS,\n INSTANCE_SYNC_FIELDS,\n INSTANCE_SYNC_PROPS,\n INSTANCE_SYNC_TEXT_PROPS\n} from './fields'\n\nexport function copyInstanceComponentProps(component: SceneNode): Partial<SceneNode> {\n const props: Partial<SceneNode> = {}\n // A new instance starts with the fields its component frame lends it, as resyncing one does.\n for (const key of [...INSTANCE_SYNC_PROPS, ...INSTANCE_FRAME_FOLLOWED_FIELDS])\n copyProp(props, component, key)\n return props\n}\n\n/**\n * The name Figma gives a new instance of `component`: its component set's name for a variant,\n * whose own name only says which variant it is, and the component's own name otherwise.\n */\nfunction instanceComponentName(graph: SceneGraph, component: SceneNode): string {\n const parent = component.parentId ? graph.nodes.get(component.parentId) : undefined\n return parent?.type === 'COMPONENT_SET' ? parent.name : component.name\n}\n\nexport function createInstance(\n graph: SceneGraph,\n componentId: string,\n parentId: string,\n overrides: Partial<SceneNode> = {}\n): SceneNode | null {\n const component = graph.nodes.get(componentId)\n if (component?.type !== 'COMPONENT' || !canCreateInstance(graph, componentId, parentId))\n return null\n\n const props: Partial<SceneNode> = {\n ...copyInstanceComponentProps(component),\n name: instanceComponentName(graph, component)\n }\n\n // The component checked above is the one the instance shows, whatever `overrides` holds.\n const instance = graph.createNode('INSTANCE', parentId, { ...props, ...overrides, componentId })\n\n cloneChildrenWithMapping(graph, component.id, instance.id)\n // A copy shows its bound paints in its own context, not as its component's paints hold them.\n applyBoundPaintColorsIn(graph, instance.id)\n\n return instance\n}\n\nexport function populateInstanceChildren(\n graph: SceneGraph,\n instanceId: string,\n componentId: string,\n mode: NodeCloneMode = 'deep'\n): void {\n const instance = graph.nodes.get(instanceId)\n const component = graph.nodes.get(componentId)\n if (!instance || !component || instance.type !== 'INSTANCE') return\n cloneChildrenWithMapping(graph, componentId, instanceId, mode)\n}\n\n/**\n * A nested instance's link to the enclosing component's record is its `componentId` when it\n * was populated by cloning. A swap replaces that field, so keep the correspondence as the\n * owner's `sourceComponentId` override and record the swap itself; materialized documents\n * already carry the correspondence and only gain the swap.\n */\nfunction recordNestedSwap(graph: SceneGraph, instance: SceneNode, componentId: string): void {\n const owner = instance.parentId ? findInstanceAncestor(graph, instance.parentId) : undefined\n if (!owner) return\n const existing = getInstanceOverride(\n owner.instanceOverrides,\n owner.id,\n instance.id,\n 'sourceComponentId'\n )\n if (typeof existing !== 'string' && instance.componentId)\n setInstanceOverride(\n owner.instanceOverrides,\n owner.id,\n instance.id,\n 'sourceComponentId',\n instance.componentId\n )\n setInstanceOverride(owner.instanceOverrides, owner.id, instance.id, 'componentId', componentId)\n graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides })\n}\n\nexport interface SwapInstanceOptions {\n /**\n * Keep the instance's name even when it is its old component's. A swap otherwise renames such\n * an instance after the new component, as Figma does; a view that only shows another variant,\n * such as preview, keeps names so layer paths stay the same.\n */\n keepName?: boolean\n /**\n * Keep the overrides the instance's layers record, matched to the layers of the new component\n * that take their places, as Figma keeps them when a variant changes. A swap that only\n * materializes a layer the caller re-applies itself, such as a pen icon's glyph, skips this:\n * what the placeholder recorded is scaffolding, not a user's edit.\n */\n restoreOverrides?: boolean\n}\n\nexport function swapInstanceComponent(\n graph: SceneGraph,\n instanceId: string,\n componentId: string,\n { keepName = false, restoreOverrides = true }: SwapInstanceOptions = {}\n): void {\n const instance = graph.nodes.get(instanceId)\n const component = graph.nodes.get(componentId)\n if (!instance || component?.type !== 'COMPONENT' || instance.type !== 'INSTANCE') return\n if (instance.parentId && !canCreateInstance(graph, componentId, instance.parentId)) return\n\n const previousComponent = instance.componentId ? graph.nodes.get(instance.componentId) : undefined\n recordNestedSwap(graph, instance, componentId)\n const updates: Partial<SceneNode> = { componentId }\n const source = sourceInTargetCoordinates(component, instance.componentScale)\n const overridden = (field: string) =>\n hasNodeInstanceOverride(instance.instanceOverrides, instance.id, instance.id, field)\n for (const key of INSTANCE_SYNC_PROPS) {\n if (key === 'variableModes' || overridden(key)) continue\n copyProp(updates, source, key)\n }\n syncVariableModeFields(instance, source, updates, overridden)\n applySyncedStrokeLines(graph, instance, updates, overridden)\n\n if (\n !keepName &&\n (!previousComponent || instance.name === instanceComponentName(graph, previousComponent))\n )\n updates.name = instanceComponentName(graph, component)\n\n keepCopyBoundPaints(graph, instance, updates)\n const childIds = Array.from(instance.childIds)\n const slotContent = detachOwnedSlotContent(graph, instance)\n swapInstanceLayers(graph, instanceId, componentId, updates, childIds, restoreOverrides)\n restoreOwnedSlotContent(graph, instance, slotContent)\n}\n\n/**\n * Replaces the instance's layers with clones of its new component's and gives the recorded\n * overrides back to the layers that take the old ones' places, matched by name path.\n */\nfunction swapInstanceLayers(\n graph: SceneGraph,\n instanceId: string,\n componentId: string,\n updates: Partial<SceneNode>,\n childIds: string[],\n restoreOverrides: boolean\n): void {\n // The clones take new IDs, so what was recorded for the removed layers only applies again once\n // it is matched to the layers of the new component that take their places.\n const capturedOverrides = restoreOverrides\n ? captureInstanceOverrides(graph, graph.nodes.get(instanceId) as SceneNode)\n : undefined\n for (const childId of childIds) {\n forgetOverridesOf(graph, childId)\n graph.deleteNode(childId)\n }\n graph.updateNode(instanceId, updates)\n cloneChildrenWithMapping(graph, componentId, instanceId)\n applyBoundPaintColorsIn(graph, instanceId)\n const swapped = graph.nodes.get(instanceId)\n if (swapped && capturedOverrides) restoreInstanceOverrides(graph, swapped, capturedOverrides)\n}\n\nconst syncingComponentsByGraph = new WeakMap<SceneGraph, Set<string>>()\n\nexport function syncInstances(graph: SceneGraph, componentId: string): void {\n syncInstancesOf(graph, componentId, getInstances(graph, componentId))\n}\n\n/**\n * Syncs each component's instances, in order, as one edit: the copies they remove stay\n * restorable together for as long as undo keeps that edit.\n */\nexport function syncInstancesTogether(graph: SceneGraph, componentIds: Iterable<string>): void {\n groupCopyRemovals(graph, () => {\n for (const id of componentIds) syncInstances(graph, id)\n })\n}\n\n/** Syncs one instance from its component, as `syncInstances` does for every instance. */\nexport function syncInstance(graph: SceneGraph, instanceId: string): void {\n const instance = graph.nodes.get(instanceId)\n if (instance?.type !== 'INSTANCE' || !instance.componentId) return\n syncInstancesOf(graph, instance.componentId, [instance])\n}\n\nfunction syncInstancesOf(\n graph: SceneGraph,\n componentId: string,\n instances: Iterable<SceneNode>\n): void {\n const component = graph.nodes.get(componentId)\n if (component?.type !== 'COMPONENT') return\n let syncing = syncingComponentsByGraph.get(graph)\n if (!syncing) {\n syncing = new Set()\n syncingComponentsByGraph.set(graph, syncing)\n }\n if (syncing.has(componentId)) return\n syncing.add(componentId)\n try {\n groupCopyRemovals(graph, (removals) => {\n for (const instance of instances) {\n const enclosing = enclosingInstanceOverrideFields(graph, instance)\n enclosing.push(new Set(instance.instanceOverrides.self.keys()))\n const protectedField = bindingProtection(enclosing)\n const source = sourceInTargetCoordinates(component, instance.componentScale)\n const updates: Partial<SceneNode> = {}\n syncBindingFields(instance, source, updates, protectedField)\n syncVariableModeFields(instance, source, updates, protectedField)\n for (const key of INSTANCE_SYNC_PROPS) {\n if (key === 'boundVariables' || key === 'variableModes') continue\n if (isProtectedSyncField(instance, key, protectedField)) continue\n copyProp(updates, source, key)\n }\n // The file keeps one value for the instance frame and its component, so the frame takes\n // those the layers inside an instance may not set.\n for (const key of INSTANCE_FRAME_FOLLOWED_FIELDS) {\n if (!isProtectedSyncField(instance, key, protectedField)) copyProp(updates, source, key)\n }\n // An instance that hugs its layers sizes to what it shows, not to the component.\n keepOwnContentSize(graph, updates, instance, source)\n // A size that follows the component invalidates outlines the file saved on the instance;\n // its live box draws them again.\n if (updates.width !== undefined || updates.height !== undefined) {\n Object.assign(\n updates,\n shapeGeometryChanges(\n instance,\n updates.width ?? instance.width,\n updates.height ?? instance.height\n )\n )\n }\n updateSyncedProps(graph, instance, updates, (key) =>\n isProtectedSyncField(instance, key, protectedField)\n )\n const context = createInstanceSyncContext(instance.id, instance.instanceOverrides)\n syncChildren(graph, component.id, instance.id, instance.instanceOverrides, context)\n removeLeftoverCopies(graph, context, removals)\n }\n })\n } finally {\n syncing.delete(componentId)\n }\n}\n\n/**\n * Renames the layers that the copied instances among `copies` record overrides for to their\n * copies, as a copied instance records its own layers' overrides. The values keep naming what\n * they name, since a copy shows the same components as its source.\n */\nexport function retargetCopiedOverrides(\n graph: SceneGraph,\n copies: ReadonlyMap<string, string>\n): void {\n for (const id of copies.values()) {\n const node = graph.nodes.get(id)\n if (node?.type !== 'INSTANCE' || node.instanceOverrides.descendants.size === 0) continue\n const descendants = new Map(\n [...node.instanceOverrides.descendants].map(([target, fields]) => [\n copies.get(target) ?? target,\n fields\n ])\n )\n graph.updateNode(id, { instanceOverrides: { ...node.instanceOverrides, descendants } })\n }\n}\n\nexport function detachInstance(graph: SceneGraph, instanceId: string): void {\n const node = graph.nodes.get(instanceId)\n if (node?.type !== 'INSTANCE') return\n for (const nested of outermostNestedInstances(graph, node))\n adoptNestedOverrides(graph, node, nested)\n // Through `updateNode`, so the instance index, change observers, and undo recorders see it.\n graph.updateNode(instanceId, {\n type: 'FRAME',\n componentId: null,\n instanceOverrides: createInstanceOverrideState()\n })\n // Its mirrored layers stand on their own: a component child id would name a layer of another\n // node, which the format never stores and a later sync would read as a link back. A nested\n // instance is not a mirror and keeps its own links, which its overrides are written through.\n const detachLinks = (parentId: string): void => {\n for (const child of graph.getChildren(parentId)) {\n if (child.type === 'INSTANCE') continue\n if (child.componentId) graph.updateNode(child.id, { componentId: null })\n detachLinks(child.id)\n }\n }\n detachLinks(instanceId)\n}\n\n// A swap's bookkeeping belongs to the instance enclosing the swapped one, never to the swapped one.\nconst OWNER_ONLY_FIELDS = new Set(['componentId', 'sourceComponentId'])\n\nfunction outermostNestedInstances(graph: SceneGraph, instance: SceneNode): SceneNode[] {\n return graph\n .getChildren(instance.id)\n .flatMap((child) =>\n child.type === 'INSTANCE' ? [child] : outermostNestedInstances(graph, child)\n )\n}\n\n/**\n * An instance a detached one holds stands on its own once that one is a frame, and so must what\n * makes it differ from its component. Cloned in, it kept the overrides of the instance it copies,\n * under that instance's layers; those, and the ones the detached instance recorded on its layers,\n * now go under its own.\n */\nfunction adoptNestedOverrides(graph: SceneGraph, detached: SceneNode, nested: SceneNode): void {\n const ownLayer = new Map<string, string>()\n walkInstanceSources(graph, nested, (source, target) => {\n ownLayer.set(source.id, target.id)\n return true\n })\n const { self, descendants: kept } = cloneInstanceOverrideState(nested.instanceOverrides)\n const outer = cloneInstanceOverrideState(detached.instanceOverrides).descendants\n const descendants = new Map<string, Map<string, unknown>>()\n const claim = (layerId: string, fields: Map<string, unknown>): void => {\n const merged = descendants.get(layerId)\n if (!merged) descendants.set(layerId, fields)\n else for (const [field, value] of fields) merged.set(field, value)\n }\n // What was recorded on its own layers is more recent than what it copied, so it is laid on top.\n for (const [layerId, fields] of kept)\n if (ownLayer.has(layerId)) claim(ownLayer.get(layerId) ?? layerId, fields)\n for (const [layerId, fields] of kept) if (!ownLayer.has(layerId)) claim(layerId, fields)\n for (const [layerId, fields] of outer) {\n if (layerId === nested.id) {\n for (const [field, value] of fields) if (!OWNER_ONLY_FIELDS.has(field)) self.set(field, value)\n } else if (graph.isDescendant(layerId, nested.id)) claim(layerId, fields)\n }\n graph.updateNode(nested.id, { instanceOverrides: { self, descendants } })\n}\n\nexport function getMainComponent(graph: SceneGraph, instanceId: string): SceneNode | undefined {\n const node = graph.nodes.get(instanceId)\n if (!node?.componentId) return undefined\n return graph.nodes.get(node.componentId)\n}\n\nexport function getInstances(graph: SceneGraph, componentId: string): SceneNode[] {\n const ids = graph.instanceIndex.get(componentId)\n if (!ids) return []\n const instances: SceneNode[] = []\n for (const id of ids) {\n const node = graph.nodes.get(id)\n if (node) instances.push(node)\n }\n return instances\n}\n\n/** Nearest INSTANCE at or above `nodeId` — self, parent, grandparent, etc. */\nexport function findInstanceAncestor(graph: SceneGraph, nodeId: string): SceneNode | undefined {\n let current = graph.nodes.get(nodeId)\n while (current) {\n if (current.type === 'INSTANCE') return current\n current = current.parentId ? graph.nodes.get(current.parentId) : undefined\n }\n return undefined\n}\n\n/**\n * Whether Figma lets this layer take a size of its own: a layer inside an instance shows its\n * component's size and cannot be resized, while an instance nested in another may be.\n */\nexport function takesOwnSize(graph: SceneGraph, node: SceneNode): boolean {\n return node.type === 'INSTANCE' || !node.parentId || !findInstanceAncestor(graph, node.parentId)\n}\n\n/**\n * True when a node field is protected from instance synchronization.\n */\nexport function hasInstanceOverride(graph: SceneGraph, nodeId: string, field: string): boolean {\n const instance = findInstanceAncestor(graph, nodeId)\n if (!instance) return false\n return hasNodeInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field)\n}\n\n/**\n * The layer of the component an instance layer copies, which its overrides are measured\n * against: the instance's component for the instance itself.\n */\nfunction copiedLayer(graph: SceneGraph, instance: SceneNode, node: SceneNode) {\n const id =\n node.id === instance.id\n ? instance.componentId\n : copiedComponentLayerId(instance.instanceOverrides, instance.id, node)\n return id ? graph.nodes.get(id) : undefined\n}\n\n/**\n * The override fields an edit of these fields records. A mode edit claims only the collections\n * whose mode now differs from the component layer's, so the component's other modes still\n * reach the layer; with no layer to compare, it claims every mode.\n */\nfunction overrideFieldsOf(\n graph: SceneGraph,\n instance: SceneNode,\n nodeId: string,\n fields: string[]\n): string[] {\n if (!fields.includes('variableModes')) return fields\n const node = graph.nodes.get(nodeId)\n const source = node && copiedLayer(graph, instance, node)\n if (!node || !source) return fields\n return [\n ...fields.filter((field) => field !== 'variableModes'),\n ...differingVariableModeCollections(node, source).map(variableModeOverrideField)\n ]\n}\n\n/**\n * The instance above `instanceId` that records an assignment made through it: an assignment of a\n * nested instance's property is an edit of the instance it sits in, not of the nested instance.\n */\nexport function assignmentOverrideOwner(\n graph: SceneGraph,\n instanceId: string\n): SceneNode | undefined {\n const parentId = graph.nodes.get(instanceId)?.parentId\n return parentId ? findInstanceAncestor(graph, parentId) : undefined\n}\n\n/** The overrides an assignment edit writes on the instance above it, for undo to restore. */\nexport interface AssignmentOverrideState {\n ownerId: string\n overrides: InstanceOverrideState\n}\n\nexport function takeAssignmentOverrideState(\n graph: SceneGraph,\n instanceId: string\n): AssignmentOverrideState | undefined {\n const owner = assignmentOverrideOwner(graph, instanceId)\n return owner\n ? { ownerId: owner.id, overrides: cloneInstanceOverrideState(owner.instanceOverrides) }\n : undefined\n}\n\nexport function restoreAssignmentOverrideState(\n graph: SceneGraph,\n state: AssignmentOverrideState\n): void {\n graph.updateNode(state.ownerId, {\n instanceOverrides: cloneInstanceOverrideState(state.overrides)\n })\n}\n\n/**\n * Records that an instance assigned one of its component properties, as an edit of the instance\n * above it: the assignment is made through the outer instance, so a text override of the same\n * level does not outrank it. A top-level instance has no outer instance to record it on.\n */\nexport function recordAssignmentOverride(\n graph: SceneGraph,\n instanceId: string,\n propertyId: string,\n value: string\n): void {\n const outer = assignmentOverrideOwner(graph, instanceId)\n if (!outer) return\n setInstanceOverride(\n outer.instanceOverrides,\n outer.id,\n instanceId,\n assignmentOverrideField(propertyId),\n value\n )\n graph.updateNode(outer.id, { instanceOverrides: outer.instanceOverrides })\n}\n\n/**\n * The fields `changes` overrides on an instance layer. New strokes that change only what the\n * layer's line fields say override those fields, not the paints (`changesMoreThanStrokeLines`).\n */\nexport function instanceOverrideFields(node: SceneNode, changes: Partial<SceneNode>): string[] {\n const fields = Object.keys(changes)\n if (!changes.strokes || changesMoreThanStrokeLines(node, changes)) return fields\n return fields.filter((field) => field !== 'strokes')\n}\n\nexport function recordInstanceOverride(\n graph: SceneGraph,\n nodeId: string,\n fields: Iterable<string>\n): void {\n const instance = findInstanceAncestor(graph, nodeId)\n if (!instance) return\n\n const relevant = overrideFieldsOf(\n graph,\n instance,\n nodeId,\n [...fields].filter(\n (field) =>\n (INSTANCE_OVERRIDE_FIELDS as readonly string[]).includes(field) ||\n overriddenAssignmentId(field) !== null\n )\n )\n\n const added = relevant.filter(\n (field) => !hasNodeInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field)\n )\n if (added.length === 0) return\n\n // A new state rather than an edit of the old one, so a preview that captured the old state\n // puts it back on cancel.\n const overrides = cloneInstanceOverrideState(instance.instanceOverrides)\n for (const field of added) setInstanceOverride(overrides, instance.id, nodeId, field)\n graph.updateNode(instance.id, { instanceOverrides: overrides })\n}\n\n/** Every layer at or below `rootId`. */\nfunction subtreeIds(graph: SceneGraph, rootId: string): string[] {\n const ids: string[] = []\n const visit = (id: string) => {\n ids.push(id)\n for (const childId of graph.nodes.get(id)?.childIds ?? []) visit(childId)\n }\n visit(rootId)\n return ids\n}\n\n/** Forget what the instances above `nodeId` recorded for it and the layers inside it. */\nfunction forgetOverridesOf(graph: SceneGraph, nodeId: string): void {\n const ids = subtreeIds(graph, nodeId)\n const parentId = graph.nodes.get(nodeId)?.parentId\n if (!parentId) return\n graph.closest(parentId, (ancestor) => {\n if (ancestor.type !== 'INSTANCE') return false\n const { descendants } = ancestor.instanceOverrides\n if (ids.some((id) => descendants.delete(id)))\n graph.updateNode(ancestor.id, { instanceOverrides: ancestor.instanceOverrides })\n return false\n })\n}\n\n/** Whether a layer can be replaced in its instance: it sits in the part the component owns. */\nexport function canReplaceInstanceLayer(graph: SceneGraph, nodeId: string): boolean {\n const node = graph.nodes.get(nodeId)\n const owner = node && owningInstance(graph, node)\n if (!node?.parentId || !owner) return false\n // Slot content is the instance's own already, and a generated frame's layers are fixed.\n const scope = slotScope(graph, node.parentId)\n if (scope.kind !== 'locked' || scope.owner.type !== 'INSTANCE') return false\n return (\n replacedLayerIn(owner, node.id) !== undefined ||\n copiedComponentLayerId(owner.instanceOverrides, owner.id, node) !== undefined\n )\n}\n\n/**\n * Put `replacementId` in place of `targetId`, a layer an instance copies from its component, as\n * an override of the nearest instance above it, as pen.dev replaces a layer inside an instance.\n * The replacement takes the target's place among its siblings and its position, the target\n * goes, and syncs keep the replacement in place of the component layer the target copied. A\n * replaced layer can be replaced again. Returns false and changes nothing when the target is no\n * such layer, or the replacement cannot go there.\n */\nexport function replaceInstanceLayer(\n graph: SceneGraph,\n targetId: string,\n replacementId: string\n): boolean {\n const target = graph.nodes.get(targetId)\n const replacement = graph.nodes.get(replacementId)\n const parentId = target?.parentId\n if (!target || !replacement || !parentId || targetId === replacementId) return false\n const owner = owningInstance(graph, target)\n if (!owner || graph.isDescendant(parentId, replacementId)) return false\n if (createsComponentCycle(graph, replacementId, parentId)) return false\n const layerId =\n replacedLayerIn(owner, target.id) ??\n copiedComponentLayerId(owner.instanceOverrides, owner.id, target)\n if (!layerId) return false\n\n // The replacement copies no layer of the component, so its own layers lose such links; an\n // instance among them keeps its own component and layers.\n const unlink = (id: string) => {\n const node = graph.nodes.get(id)\n if (!node) return\n if (node.type !== 'INSTANCE' && node.componentId) graph.updateNode(id, { componentId: null })\n if (node.type !== 'INSTANCE') node.childIds.forEach(unlink)\n }\n unlink(replacementId)\n\n const index = graph.nodes.get(parentId)?.childIds.indexOf(target.id) ?? -1\n forgetOverridesOf(graph, target.id)\n forgetOverridesOf(graph, replacementId)\n graph.insertChildAt(replacementId, parentId, index < 0 ? Number.MAX_SAFE_INTEGER : index)\n graph.updateNode(replacementId, {\n x: target.x,\n y: target.y,\n layoutPositioning: target.layoutPositioning,\n horizontalConstraint: target.horizontalConstraint,\n verticalConstraint: target.verticalConstraint\n })\n graph.deleteNode(target.id)\n setInstanceOverride(\n owner.instanceOverrides,\n owner.id,\n replacementId,\n REPLACED_LAYER_OVERRIDE,\n layerId\n )\n graph.updateNode(owner.id, { instanceOverrides: owner.instanceOverrides })\n return true\n}\n\n/**\n * Take a replaced layer out and bring back the component layer it stood in for, synced from the\n * outermost instance as a reset syncs. Returns false when the layer is not a replaced one.\n */\nexport function restoreReplacedLayer(graph: SceneGraph, nodeId: string): boolean {\n const node = graph.nodes.get(nodeId)\n const owner = node && owningInstance(graph, node)\n if (!node || !owner || replacedLayerIn(owner, nodeId) === undefined) return false\n let outermost = owner\n for (let above = owningInstance(graph, owner); above; above = owningInstance(graph, above))\n outermost = above\n forgetOverridesOf(graph, nodeId)\n graph.deleteNode(nodeId)\n syncInstance(graph, outermost.id)\n // An enclosing sync stops at a swapped instance, which brings its layers back itself.\n const above = owningInstance(graph, owner)\n if (above && getInstanceOverride(above.instanceOverrides, above.id, owner.id, 'componentId'))\n syncInstance(graph, owner.id)\n return true\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgEA,SAAgB,2BAA2B,WAA0C;CACnF,MAAM,QAA4B,CAAC;CAEnC,KAAK,MAAM,OAAO,CAAC,GAAG,qBAAqB,GAAG,8BAA8B,GAC1E,SAAS,OAAO,WAAW,GAAG;CAChC,OAAO;AACT;;;;;AAMA,SAAS,sBAAsB,OAAmB,WAA8B;CAC9E,MAAM,SAAS,UAAU,WAAW,MAAM,MAAM,IAAI,UAAU,QAAQ,IAAI,KAAA;CAC1E,OAAO,QAAQ,SAAS,kBAAkB,OAAO,OAAO,UAAU;AACpE;AAEA,SAAgB,eACd,OACA,aACA,UACA,YAAgC,CAAC,GACf;CAClB,MAAM,YAAY,MAAM,MAAM,IAAI,WAAW;CAC7C,IAAI,WAAW,SAAS,eAAe,CAAC,kBAAkB,OAAO,aAAa,QAAQ,GACpF,OAAO;CAET,MAAM,QAA4B;EAChC,GAAG,2BAA2B,SAAS;EACvC,MAAM,sBAAsB,OAAO,SAAS;CAC9C;CAGA,MAAM,WAAW,MAAM,WAAW,YAAY,UAAU;EAAE,GAAG;EAAO,GAAG;EAAW;CAAY,CAAC;CAE/F,yBAAyB,OAAO,UAAU,IAA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kBAAkB,OAAO,aAAa;CACtC,MAAM,cAAc,eAAe,UAAU,QAAQ,IAAI,OAAO,mBAAmB,KAAK;CACxF,MAAM,WAAW,eAAe;EAC9B,GAAG,OAAO;EACV,GAAG,OAAO;EACV,mBAAmB,OAAO;EAC1B,sBAAsB,OAAO;EAC7B,oBAAoB,OAAO;CAC7B,CAAC;CACD,MAAM,WAAW,OAAO,EAAE;CAC1B,oBACE,MAAM,mBACN,MAAM,IACN,eACA,yBACA,OACF;CACA,MAAM,WAAW,MAAM,IAAI,EAAE,mBAAmB,MAAM,kBAAkB,CAAC;CACzE,OAAO;AACT;;;;;AAMA,SAAgB,qBAAqB,OAAmB,QAAyB;CAC/E,MAAM,OAAO,MAAM,MAAM,IAAI,MAAM;CACnC,MAAM,QAAQ,QAAQ,eAAe,OAAO,IAAI;CAChD,IAAI,CAAC,QAAQ,CAAC,SAAS,gBAAgB,OAAO,MAAM,MAAM,KAAA,GAAW,OAAO;CAC5E,IAAI,YAAY;CAChB,KAAK,IAAI,QAAQ,eAAe,OAAO,KAAK,GAAG,OAAO,QAAQ,eAAe,OAAO,KAAK,GACvF,YAAY;CACd,kBAAkB,OAAO,MAAM;CAC/B,MAAM,WAAW,MAAM;CACvB,aAAa,OAAO,UAAU,EAAE;CAEhC,MAAM,QAAQ,eAAe,OAAO,KAAK;CACzC,IAAI,SAAS,oBAAoB,MAAM,mBAAmB,MAAM,IAAI,MAAM,IAAI,aAAa,GACzF,aAAa,OAAO,MAAM,EAAE;CAC9B,OAAO;AACT"}
@@ -18,6 +18,13 @@ declare function overriddenBindingField(field: InstanceOverrideField): string |
18
18
  declare function variableModeOverrideField(collectionId: string): InstanceOverrideField;
19
19
  /** The collection a mode override field claims, or null for an override of anything else. */
20
20
  declare function overriddenVariableModeCollection(field: InstanceOverrideField): string | null;
21
+ /**
22
+ * The override field that claims a nested instance's assignment of `propertyId`, which keeps
23
+ * that assignment through a sync of the instance that makes it.
24
+ */
25
+ declare function assignmentOverrideField(propertyId: string): InstanceOverrideField;
26
+ /** The property an assignment override field claims, or null for an override of anything else. */
27
+ declare function overriddenAssignmentId(field: InstanceOverrideField): string | null;
21
28
  /**
22
29
  * The override field that marks a layer of an instance as one put in place of a component's
23
30
  * layer, recorded by the nearest instance above it. Its value is the layer it replaces, which
@@ -41,6 +48,8 @@ declare function cloneInstanceOverrideState(state: InstanceOverrideState): Insta
41
48
  interface InstanceOverrideReferenceMapper {
42
49
  node: (id: string) => string;
43
50
  variable: (id: string) => string;
51
+ collection?: (id: string) => string | undefined;
52
+ property?: (id: string) => string | undefined;
44
53
  }
45
54
  /** Remap runtime identities only; ordinary strings and source-format payloads stay opaque. */
46
55
  declare function remapInstanceOverrideState(state: InstanceOverrideState, references: InstanceOverrideReferenceMapper): InstanceOverrideState;
@@ -59,5 +68,5 @@ declare function deleteInstanceOverride(state: InstanceOverrideState, instanceId
59
68
  declare function clearInstanceOverrides(state: InstanceOverrideState): void;
60
69
  declare function forEachInstanceOverride(state: InstanceOverrideState, callback: (nodeId: string, field: InstanceOverrideField, value: unknown) => void): void;
61
70
  //#endregion
62
- export { InstanceOverrideField, InstanceOverrideReferenceMapper, InstanceOverrideState, REPLACED_LAYER_OVERRIDE, SerializedInstanceOverrideState, SerializedOverrideValue, bindingOverrideField, clearInstanceOverrides, cloneInstanceOverrideState, copiedComponentLayerId, createInstanceOverrideState, deleteInstanceOverride, deserializeInstanceOverrideState, forEachInstanceOverride, getInstanceOverride, hasInstanceOverride, isLayerReferenceOverride, overriddenBindingField, overriddenVariableModeCollection, remapInstanceOverrideState, serializeInstanceOverrideState, setInstanceOverride, variableModeOverrideField };
71
+ export { InstanceOverrideField, InstanceOverrideReferenceMapper, InstanceOverrideState, REPLACED_LAYER_OVERRIDE, SerializedInstanceOverrideState, SerializedOverrideValue, assignmentOverrideField, bindingOverrideField, clearInstanceOverrides, cloneInstanceOverrideState, copiedComponentLayerId, createInstanceOverrideState, deleteInstanceOverride, deserializeInstanceOverrideState, forEachInstanceOverride, getInstanceOverride, hasInstanceOverride, isLayerReferenceOverride, overriddenAssignmentId, overriddenBindingField, overriddenVariableModeCollection, remapInstanceOverrideState, serializeInstanceOverrideState, setInstanceOverride, variableModeOverrideField };
63
72
  //# sourceMappingURL=overrides.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"overrides.d.ts","names":[],"sources":["../../src/instances/overrides.ts"],"mappings":";KAAY;UAEK;EACf,MAAM,IAAI;EACV,aAAa,YAAY,IAAI;;;;;;iBASf,qBAAqB,gBAAgB;;iBAKrC,uBAAuB,OAAO;;;;;iBAY9B,0BAA0B,uBAAuB;;iBAKjD,iCAAiC,OAAO;;;;;;cAW3C;;iBAGG,yBAAyB,OAAO;iBAMhC,+BAA+B;UAI9B;EACf;EACA;;UAGe;EACf,MAAM,OAAO,uBAAuB;EACpC,aAAa,eAAe,OAAO,uBAAuB;;iBAiC5C,+BACd,OAAO,wBACN;iBAUa,iCAAiC,iBAAiB;iBAgBlD,2BAA2B,OAAO,wBAAwB;UAYzD;EACf,OAAO;EACP,WAAW;;;iBAIG,2BACd,OAAO,uBACP,YAAY,kCACX;iBAkBa,oBACd,OAAO,uBACP,oBACA,gBACA,OAAO;;;;;iBASO,uBACd,OAAO,uBACP,oBACA;EAAQ;EAAY;;iBAMN,oBACd,OAAO,uBACP,oBACA,gBACA,OAAO;iBAMO,oBACd,OAAO,uBACP,oBACA,gBACA,OAAO,uBACP;iBAWc,uBACd,OAAO,uBACP,oBACA,gBACA,OAAO;iBAQO,uBAAuB,OAAO;iBAK9B,wBACd,OAAO,uBACP,WAAW,gBAAgB,OAAO,uBAAuB"}
1
+ {"version":3,"file":"overrides.d.ts","names":[],"sources":["../../src/instances/overrides.ts"],"mappings":";KAAY;UAEK;EACf,MAAM,IAAI;EACV,aAAa,YAAY,IAAI;;;;;;iBASf,qBAAqB,gBAAgB;;iBAKrC,uBAAuB,OAAO;;;;;iBAY9B,0BAA0B,uBAAuB;;iBAKjD,iCAAiC,OAAO;;;;;iBAYxC,wBAAwB,qBAAqB;;iBAK7C,uBAAuB,OAAO;;;;;;cAWjC;;iBAGG,yBAAyB,OAAO;iBAMhC,+BAA+B;UAI9B;EACf;EACA;;UAGe;EACf,MAAM,OAAO,uBAAuB;EACpC,aAAa,eAAe,OAAO,uBAAuB;;iBAiC5C,+BACd,OAAO,wBACN;iBAUa,iCAAiC,iBAAiB;iBAgBlD,2BAA2B,OAAO,wBAAwB;UAYzD;EACf,OAAO;EACP,WAAW;EACX,cAAc;EACd,YAAY;;;iBAIE,2BACd,OAAO,uBACP,YAAY,kCACX;iBAkCa,oBACd,OAAO,uBACP,oBACA,gBACA,OAAO;;;;;iBASO,uBACd,OAAO,uBACP,oBACA;EAAQ;EAAY;;iBAMN,oBACd,OAAO,uBACP,oBACA,gBACA,OAAO;iBAMO,oBACd,OAAO,uBACP,oBACA,gBACA,OAAO,uBACP;iBAWc,uBACd,OAAO,uBACP,oBACA,gBACA,OAAO;iBAQO,uBAAuB,OAAO;iBAK9B,wBACd,OAAO,uBACP,WAAW,gBAAgB,OAAO,uBAAuB"}
@@ -23,6 +23,18 @@ function variableModeOverrideField(collectionId) {
23
23
  function overriddenVariableModeCollection(field) {
24
24
  return field.startsWith(VARIABLE_MODE_OVERRIDE_PREFIX) ? field.slice(14) : null;
25
25
  }
26
+ const ASSIGNMENT_OVERRIDE_PREFIX = "componentPropertyAssignments/";
27
+ /**
28
+ * The override field that claims a nested instance's assignment of `propertyId`, which keeps
29
+ * that assignment through a sync of the instance that makes it.
30
+ */
31
+ function assignmentOverrideField(propertyId) {
32
+ return `${ASSIGNMENT_OVERRIDE_PREFIX}${propertyId}`;
33
+ }
34
+ /** The property an assignment override field claims, or null for an override of anything else. */
35
+ function overriddenAssignmentId(field) {
36
+ return field.startsWith(ASSIGNMENT_OVERRIDE_PREFIX) ? field.slice(29) : null;
37
+ }
26
38
  /**
27
39
  * The override field that marks a layer of an instance as one put in place of a component's
28
40
  * layer, recorded by the nearest instance above it. Its value is the layer it replaces, which
@@ -109,7 +121,21 @@ function remapInstanceOverrideState(state, references) {
109
121
  if (overriddenBindingField(field) !== null) return references.variable(value);
110
122
  return value;
111
123
  };
112
- const fields = (entries) => new Map([...entries].map(([field, value]) => [field, remapValue(field, value)]));
124
+ const remapField = (field) => {
125
+ const property = overriddenAssignmentId(field);
126
+ if (property !== null && references.property) {
127
+ const mapped = references.property(property);
128
+ return mapped === void 0 ? void 0 : assignmentOverrideField(mapped);
129
+ }
130
+ const collection = overriddenVariableModeCollection(field);
131
+ if (collection === null || !references.collection) return field;
132
+ const mapped = references.collection(collection);
133
+ return mapped === void 0 ? void 0 : variableModeOverrideField(mapped);
134
+ };
135
+ const fields = (entries) => new Map([...entries].flatMap(([field, value]) => {
136
+ const mapped = remapField(field);
137
+ return mapped === void 0 ? [] : [[mapped, remapValue(field, value)]];
138
+ }));
113
139
  const descendants = /* @__PURE__ */ new Map();
114
140
  for (const [id, entries] of state.descendants) {
115
141
  const mapped = references.node(id);
@@ -159,6 +185,6 @@ function forEachInstanceOverride(state, callback) {
159
185
  for (const [nodeId, fields] of state.descendants) for (const [field, value] of fields) callback(nodeId, field, value);
160
186
  }
161
187
  //#endregion
162
- export { REPLACED_LAYER_OVERRIDE, bindingOverrideField, clearInstanceOverrides, cloneInstanceOverrideState, copiedComponentLayerId, createInstanceOverrideState, deleteInstanceOverride, deserializeInstanceOverrideState, forEachInstanceOverride, getInstanceOverride, hasInstanceOverride, isLayerReferenceOverride, overriddenBindingField, overriddenVariableModeCollection, remapInstanceOverrideState, serializeInstanceOverrideState, setInstanceOverride, variableModeOverrideField };
188
+ export { REPLACED_LAYER_OVERRIDE, assignmentOverrideField, bindingOverrideField, clearInstanceOverrides, cloneInstanceOverrideState, copiedComponentLayerId, createInstanceOverrideState, deleteInstanceOverride, deserializeInstanceOverrideState, forEachInstanceOverride, getInstanceOverride, hasInstanceOverride, isLayerReferenceOverride, overriddenAssignmentId, overriddenBindingField, overriddenVariableModeCollection, remapInstanceOverrideState, serializeInstanceOverrideState, setInstanceOverride, variableModeOverrideField };
163
189
 
164
190
  //# sourceMappingURL=overrides.js.map