@open-pencil/scene-graph 0.17.0-beta.2 → 0.17.0-beta.4

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 (244) hide show
  1. package/dist/asset-keys.d.ts +11 -1
  2. package/dist/asset-keys.d.ts.map +1 -1
  3. package/dist/asset-keys.js +16 -1
  4. package/dist/asset-keys.js.map +1 -1
  5. package/dist/checkpoint.d.ts +3 -3
  6. package/dist/checkpoint.d.ts.map +1 -1
  7. package/dist/checkpoint.js +53 -23
  8. package/dist/checkpoint.js.map +1 -1
  9. package/dist/components/index.d.ts +2 -2
  10. package/dist/components/index.js +2 -2
  11. package/dist/components/properties.d.ts +6 -1
  12. package/dist/components/properties.d.ts.map +1 -1
  13. package/dist/components/properties.js +9 -1
  14. package/dist/components/properties.js.map +1 -1
  15. package/dist/constants.d.ts +6 -1
  16. package/dist/constants.d.ts.map +1 -1
  17. package/dist/constants.js +17 -1
  18. package/dist/constants.js.map +1 -1
  19. package/dist/constraints.d.ts +25 -0
  20. package/dist/constraints.d.ts.map +1 -0
  21. package/dist/constraints.js +51 -0
  22. package/dist/constraints.js.map +1 -0
  23. package/dist/coordinate.d.ts +64 -1
  24. package/dist/coordinate.d.ts.map +1 -1
  25. package/dist/coordinate.js +217 -1
  26. package/dist/coordinate.js.map +1 -1
  27. package/dist/copy.d.ts.map +1 -1
  28. package/dist/copy.js +8 -1
  29. package/dist/copy.js.map +1 -1
  30. package/dist/css/index.d.ts +3 -2
  31. package/dist/css/index.js +3 -2
  32. package/dist/css/text.d.ts +28 -1
  33. package/dist/css/text.d.ts.map +1 -1
  34. package/dist/css/text.js +84 -17
  35. package/dist/css/text.js.map +1 -1
  36. package/dist/css/transform.d.ts +34 -0
  37. package/dist/css/transform.d.ts.map +1 -0
  38. package/dist/css/transform.js +320 -0
  39. package/dist/css/transform.js.map +1 -0
  40. package/dist/css/values.d.ts.map +1 -1
  41. package/dist/css/values.js +11 -1
  42. package/dist/css/values.js.map +1 -1
  43. package/dist/figjam/palette.d.ts +1 -1
  44. package/dist/figjam/palette.js +1 -1
  45. package/dist/figjam/palette.js.map +1 -1
  46. package/dist/geometry.d.ts +8 -1
  47. package/dist/geometry.d.ts.map +1 -1
  48. package/dist/geometry.js +19 -8
  49. package/dist/geometry.js.map +1 -1
  50. package/dist/graph.d.ts +48 -12
  51. package/dist/graph.d.ts.map +1 -1
  52. package/dist/graph.js +110 -24
  53. package/dist/graph.js.map +1 -1
  54. package/dist/group-bounds.d.ts +14 -4
  55. package/dist/group-bounds.d.ts.map +1 -1
  56. package/dist/group-bounds.js +76 -11
  57. package/dist/group-bounds.js.map +1 -1
  58. package/dist/hit-test.d.ts +5 -0
  59. package/dist/hit-test.d.ts.map +1 -1
  60. package/dist/hit-test.js +18 -12
  61. package/dist/hit-test.js.map +1 -1
  62. package/dist/images.d.ts +27 -3
  63. package/dist/images.d.ts.map +1 -1
  64. package/dist/images.js +57 -3
  65. package/dist/images.js.map +1 -1
  66. package/dist/index.d.ts +2 -2
  67. package/dist/instances/index.d.ts.map +1 -1
  68. package/dist/instances/index.js +3 -0
  69. package/dist/instances/index.js.map +1 -1
  70. package/dist/instances/placement.js +55 -12
  71. package/dist/instances/placement.js.map +1 -1
  72. package/dist/instances/swap.js +3 -0
  73. package/dist/instances/swap.js.map +1 -1
  74. package/dist/instances/sync.js +34 -13
  75. package/dist/instances/sync.js.map +1 -1
  76. package/dist/node-defaults.d.ts.map +1 -1
  77. package/dist/node-defaults.js +1 -0
  78. package/dist/node-defaults.js.map +1 -1
  79. package/dist/order-keys.d.ts +3 -1
  80. package/dist/order-keys.d.ts.map +1 -1
  81. package/dist/order-keys.js +6 -1
  82. package/dist/order-keys.js.map +1 -1
  83. package/dist/plugin-data/fields.d.ts +2 -0
  84. package/dist/plugin-data/fields.d.ts.map +1 -1
  85. package/dist/plugin-data/fields.js +2 -0
  86. package/dist/plugin-data/fields.js.map +1 -1
  87. package/dist/resize.d.ts +22 -11
  88. package/dist/resize.d.ts.map +1 -1
  89. package/dist/resize.js +227 -93
  90. package/dist/resize.js.map +1 -1
  91. package/dist/scaling/index.d.ts +3 -2
  92. package/dist/scaling/index.js +3 -2
  93. package/dist/scaling/node.d.ts.map +1 -1
  94. package/dist/scaling/node.js +5 -1
  95. package/dist/scaling/node.js.map +1 -1
  96. package/dist/scaling/snapshot.d.ts +25 -0
  97. package/dist/scaling/snapshot.d.ts.map +1 -0
  98. package/dist/scaling/snapshot.js +39 -0
  99. package/dist/scaling/snapshot.js.map +1 -0
  100. package/dist/scaling/tree.d.ts +24 -2
  101. package/dist/scaling/tree.d.ts.map +1 -1
  102. package/dist/scaling/tree.js +37 -14
  103. package/dist/scaling/tree.js.map +1 -1
  104. package/dist/shaders/model.d.ts.map +1 -1
  105. package/dist/shaders/model.js +2 -1
  106. package/dist/shaders/model.js.map +1 -1
  107. package/dist/shared-styles.d.ts +3 -1
  108. package/dist/shared-styles.d.ts.map +1 -1
  109. package/dist/shared-styles.js +7 -1
  110. package/dist/shared-styles.js.map +1 -1
  111. package/dist/slots/authoring.d.ts +3 -2
  112. package/dist/slots/authoring.d.ts.map +1 -1
  113. package/dist/slots/authoring.js +5 -3
  114. package/dist/slots/authoring.js.map +1 -1
  115. package/dist/slots/content.d.ts.map +1 -1
  116. package/dist/slots/content.js +4 -1
  117. package/dist/slots/content.js.map +1 -1
  118. package/dist/text/direction.d.ts +3 -1
  119. package/dist/text/direction.d.ts.map +1 -1
  120. package/dist/text/direction.js +5 -1
  121. package/dist/text/direction.js.map +1 -1
  122. package/dist/transfer/apply.d.ts.map +1 -1
  123. package/dist/transfer/apply.js +1 -6
  124. package/dist/transfer/apply.js.map +1 -1
  125. package/dist/transfer/copied.d.ts +35 -3
  126. package/dist/transfer/copied.d.ts.map +1 -1
  127. package/dist/transfer/copied.js +44 -13
  128. package/dist/transfer/copied.js.map +1 -1
  129. package/dist/transfer/dependencies.d.ts +38 -0
  130. package/dist/transfer/dependencies.d.ts.map +1 -0
  131. package/dist/transfer/dependencies.js +100 -0
  132. package/dist/transfer/dependencies.js.map +1 -0
  133. package/dist/transfer/history.js +0 -1
  134. package/dist/transfer/history.js.map +1 -1
  135. package/dist/transfer/index.d.ts +5 -3
  136. package/dist/transfer/index.js +5 -3
  137. package/dist/transfer/nodes.d.ts.map +1 -1
  138. package/dist/transfer/nodes.js +7 -14
  139. package/dist/transfer/nodes.js.map +1 -1
  140. package/dist/transfer/plan.d.ts +0 -1
  141. package/dist/transfer/plan.js +3 -5
  142. package/dist/transfer/plan.js.map +1 -1
  143. package/dist/transfer/remove.js +5 -2
  144. package/dist/transfer/remove.js.map +1 -1
  145. package/dist/transfer/resources.d.ts +21 -0
  146. package/dist/transfer/resources.d.ts.map +1 -0
  147. package/dist/transfer/resources.js +38 -0
  148. package/dist/transfer/resources.js.map +1 -0
  149. package/dist/transfer/variables.d.ts +8 -1
  150. package/dist/transfer/variables.d.ts.map +1 -1
  151. package/dist/transfer/variables.js +24 -1
  152. package/dist/transfer/variables.js.map +1 -1
  153. package/dist/types.d.ts +47 -2
  154. package/dist/types.d.ts.map +1 -1
  155. package/dist/types.js.map +1 -1
  156. package/dist/undo.d.ts +28 -3
  157. package/dist/undo.d.ts.map +1 -1
  158. package/dist/undo.js +24 -7
  159. package/dist/undo.js.map +1 -1
  160. package/dist/variables/bindings.d.ts +17 -14
  161. package/dist/variables/bindings.d.ts.map +1 -1
  162. package/dist/variables/bindings.js +30 -72
  163. package/dist/variables/bindings.js.map +1 -1
  164. package/dist/variables/fields.d.ts +1 -1
  165. package/dist/variables/fields.js +1 -1
  166. package/dist/variables/fields.js.map +1 -1
  167. package/dist/variables/formula/check.d.ts +1 -1
  168. package/dist/variables/formula/index.d.ts +2 -2
  169. package/dist/variables/formula/index.js +1 -1
  170. package/dist/variables/formula/index.js.map +1 -1
  171. package/dist/variables/formula/print.d.ts +1 -1
  172. package/dist/variables/formula/signatures.js +1 -1
  173. package/dist/variables/index.d.ts +6 -6
  174. package/dist/variables/index.d.ts.map +1 -1
  175. package/dist/variables/index.js +40 -24
  176. package/dist/variables/index.js.map +1 -1
  177. package/dist/variables/paints.d.ts +57 -0
  178. package/dist/variables/paints.d.ts.map +1 -0
  179. package/dist/variables/paints.js +231 -0
  180. package/dist/variables/paints.js.map +1 -0
  181. package/dist/variables/resolution.d.ts +14 -11
  182. package/dist/variables/resolution.d.ts.map +1 -1
  183. package/dist/variables/resolution.js +36 -17
  184. package/dist/variables/resolution.js.map +1 -1
  185. package/dist/variables/subtree.js +17 -0
  186. package/dist/variables/subtree.js.map +1 -0
  187. package/dist/vector-network.d.ts.map +1 -1
  188. package/dist/vector-network.js +2 -8
  189. package/dist/vector-network.js.map +1 -1
  190. package/package.json +8 -1
  191. package/src/asset-keys.ts +20 -0
  192. package/src/checkpoint.ts +87 -32
  193. package/src/components/properties.ts +9 -0
  194. package/src/constants.ts +17 -0
  195. package/src/constraints.ts +60 -0
  196. package/src/coordinate.ts +220 -0
  197. package/src/copy.ts +9 -4
  198. package/src/css/index.ts +17 -1
  199. package/src/css/text.ts +85 -17
  200. package/src/css/transform.ts +266 -0
  201. package/src/css/values.ts +8 -0
  202. package/src/figjam/palette.ts +1 -1
  203. package/src/geometry.ts +20 -9
  204. package/src/graph.ts +128 -42
  205. package/src/group-bounds.ts +84 -17
  206. package/src/hit-test.ts +30 -14
  207. package/src/images.ts +71 -3
  208. package/src/instances/index.ts +4 -0
  209. package/src/instances/placement.ts +63 -10
  210. package/src/instances/swap.ts +5 -0
  211. package/src/instances/sync.ts +48 -21
  212. package/src/node-defaults.ts +1 -0
  213. package/src/order-keys.ts +6 -0
  214. package/src/plugin-data/fields.ts +6 -0
  215. package/src/resize.ts +267 -119
  216. package/src/scaling/index.ts +9 -1
  217. package/src/scaling/node.ts +9 -1
  218. package/src/scaling/snapshot.ts +51 -0
  219. package/src/scaling/tree.ts +63 -19
  220. package/src/shaders/model.ts +2 -3
  221. package/src/shared-styles.ts +8 -0
  222. package/src/slots/authoring.ts +5 -3
  223. package/src/slots/content.ts +4 -1
  224. package/src/text/direction.ts +5 -0
  225. package/src/transfer/apply.ts +1 -13
  226. package/src/transfer/copied.ts +83 -15
  227. package/src/transfer/dependencies.ts +126 -0
  228. package/src/transfer/history.ts +0 -6
  229. package/src/transfer/index.ts +20 -2
  230. package/src/transfer/nodes.ts +10 -26
  231. package/src/transfer/plan.ts +3 -11
  232. package/src/transfer/remove.ts +5 -2
  233. package/src/transfer/resources.ts +54 -0
  234. package/src/transfer/variables.ts +34 -0
  235. package/src/types.ts +55 -1
  236. package/src/undo.ts +48 -10
  237. package/src/variables/bindings.ts +44 -91
  238. package/src/variables/fields.ts +1 -1
  239. package/src/variables/formula/index.ts +3 -1
  240. package/src/variables/index.ts +56 -38
  241. package/src/variables/paints.ts +296 -0
  242. package/src/variables/resolution.ts +39 -28
  243. package/src/variables/subtree.ts +15 -0
  244. package/src/vector-network.ts +4 -2
@@ -1 +1 @@
1
- {"version":3,"file":"sync.js","names":["hasNodeInstanceOverride"],"sources":["../../src/instances/sync.ts"],"sourcesContent":["// Child cloning and property synchronization shared by instance creation, swap, and sync.\nimport { uniq } from 'es-toolkit/array'\nimport { pick } from 'es-toolkit/object'\nimport { isEmptyObject, isEqual } from 'es-toolkit/predicate'\n\nimport { cloneNodeProps, copyEffects, copyFills, copyStrokes, copyStyleRuns } from '../copy'\nimport type { NodeCloneMode } from '../copy'\nimport type { SceneGraph } from '../graph'\nimport { scaleNodeChanges } from '../scaling/node'\nimport { ownsSlotContent, slotPropertyId } from '../slots/frames'\nimport type { SceneNode } from '../types'\nimport { resolvedNumericBindings } from '../variables/bindings'\nimport { effectBindingTarget, isNumericVariableBindingField } from '../variables/fields'\nimport { scaleVariableBindingUnits } from '../variables/units'\nimport { applyEnclosingAssignments, assignedFieldValues, propertyDrivenFields } from './assignments'\nimport { keepOwnContentSize, remeasureChangedText, type SyncedPlacement } from './content-size'\nimport {\n createInstanceSyncContext,\n hasUnplacedCopiesBelow,\n restoreRemovedCopy,\n unplacedCopy,\n type InstanceSyncContext\n} from './copies'\nimport { INSTANCE_SYNC_FIELD_OWNERS, INSTANCE_SYNC_FIELDS } from './fields'\nimport { ownsSelfFillField, sourceWithEffectiveFill } from './main-component'\nimport {\n bindingOverrideField,\n copiedComponentLayerId,\n hasInstanceOverride as hasNodeInstanceOverride,\n overriddenBindingField,\n setInstanceOverride,\n type InstanceOverrideState\n} from './overrides'\nimport { PLACEMENT_FIELDS, placedByConstraints } from './placement'\nimport { followVectorGeometry } from './vector-geometry'\n\nfunction setSceneProp<K extends keyof SceneNode>(\n target: Partial<SceneNode>,\n key: K,\n value: SceneNode[K]\n): void {\n target[key] = value\n}\n\nexport function copyProp(\n target: Partial<SceneNode> | SceneNode,\n source: SceneNode,\n key: keyof SceneNode\n): void {\n if (key === 'fills') {\n setSceneProp(target, key, copyFills(source.fills))\n } else if (key === 'strokes') {\n setSceneProp(target, key, copyStrokes(source.strokes))\n } else if (key === 'effects') {\n setSceneProp(target, key, copyEffects(source.effects))\n } else if (key === 'styleRuns') {\n setSceneProp(target, key, copyStyleRuns(source.styleRuns))\n } else if (key === 'boundVariables') {\n // Shallow copy the binding map — values are variable IDs (strings), not objects\n setSceneProp(target, key, { ...source.boundVariables })\n setSceneProp(target, 'variableBindingScales', { ...source.variableBindingScales })\n } else if (key === 'variableModes') {\n setSceneProp(target, key, { ...source.variableModes })\n } else if (key === 'gridPosition') {\n // Shallow copy the grid position object — all fields are primitives\n setSceneProp(target, key, source.gridPosition ? { ...source.gridPosition } : null)\n } else if (key === 'targetAspectRatio') {\n setSceneProp(target, key, source.targetAspectRatio ? { ...source.targetAspectRatio } : null)\n } else if (key === 'booleanOperation') {\n setSceneProp(target, key, source.booleanOperation ?? 'UNION')\n } else {\n const value = source[key]\n setSceneProp(target, key, Array.isArray(value) ? structuredClone(value) : value)\n }\n}\n\nexport function bindingProtection(scopes: ReadonlySet<string>[]): (field: string) => boolean {\n const fields = new Set<string>()\n for (const scope of scopes) {\n const perField = [...scope].some((field) => overriddenBindingField(field) !== null)\n for (const field of scope) {\n if (field !== 'boundVariables' || !perField) fields.add(field)\n }\n }\n return (field) => {\n if (fields.has(field)) return true\n // Effects an instance set itself own their bindings too, bound or not, as its fills do.\n const binding = overriddenBindingField(field)\n return binding !== null && fields.has('effects') && effectBindingTarget(binding) !== null\n }\n}\n\nfunction isUnbound(node: SceneNode): boolean {\n return isEmptyObject(node.boundVariables) && isEmptyObject(node.variableBindingScales)\n}\n\nexport function syncBindingFields(\n target: SceneNode,\n source: SceneNode,\n updates: Partial<SceneNode>,\n protectedField: (field: string) => boolean\n): void {\n if (protectedField('boundVariables') || (isUnbound(source) && isUnbound(target))) {\n return\n }\n const bindings = { ...source.boundVariables }\n const scales = { ...source.variableBindingScales }\n for (const field of new Set([\n ...Object.keys(source.boundVariables),\n ...Object.keys(target.boundVariables),\n ...Object.keys(target.variableBindingScales)\n ])) {\n if (!protectedField(bindingOverrideField(field))) continue\n if (!Object.hasOwn(target.boundVariables, field)) Reflect.deleteProperty(bindings, field)\n else bindings[field] = target.boundVariables[field]\n if (target.variableBindingScales[field] === undefined) Reflect.deleteProperty(scales, field)\n else scales[field] = target.variableBindingScales[field]\n }\n updates.boundVariables = bindings\n updates.variableBindingScales = scales\n}\n\nexport function isProtectedSyncField(\n node: SceneNode,\n key: string,\n protectedField: (field: string) => boolean\n): boolean {\n return (\n protectedField(key) ||\n (key in node.boundVariables &&\n (protectedField('boundVariables') || protectedField(bindingOverrideField(key))))\n )\n}\n\nexport function sourceInTargetCoordinates(source: SceneNode, targetScale: number): SceneNode {\n const factor = targetScale / source.componentScale\n if (!Number.isFinite(factor) || factor <= 0) throw new Error('Invalid component coordinate scale')\n if (factor === 1) return source\n return {\n ...source,\n ...scaleNodeChanges(source, factor, true),\n ...scaleVariableBindingUnits(source, factor)\n }\n}\n\nconst SYNCED_FIELDS = INSTANCE_SYNC_FIELDS.filter((key) => key !== 'boundVariables').map((key) => ({\n key,\n owner: INSTANCE_SYNC_FIELD_OWNERS[key],\n placement: PLACEMENT_FIELDS.has(key),\n position: key === 'x' || key === 'y'\n}))\n\nexport const NOTHING_PROTECTED = (_field: string): boolean => false\n\ninterface SyncedFieldsInput {\n compParent: SceneNode\n instParent: SceneNode\n /** The component's coordinates in the copy's. */\n factor: number\n /** Fields the copy keeps: overridden, bound, or driven by a property. */\n skip: (key: string) => boolean\n}\n\n/** The fields a copy takes from its component's layer, placed in the copy's parent. */\nfunction copySyncedFields(\n updates: Partial<SceneNode>,\n copy: SceneNode,\n source: SceneNode,\n { compParent, instParent, factor, skip }: SyncedFieldsInput\n): SyncedPlacement {\n // In an auto layout flow the layout places the copy, as it placed the component's layer.\n const placedByLayout = instParent.layoutMode !== 'NONE' && source.layoutPositioning !== 'ABSOLUTE'\n const placed = placedByLayout\n ? source\n : placedByConstraints(source, compParent, instParent, factor)\n for (const { key, owner, placement, position } of SYNCED_FIELDS) {\n if ((placedByLayout && position) || skip(key) || (owner && skip(owner))) {\n continue\n }\n const from = placement ? placed : source\n // Most fields already match: comparing first spares cloning them for nothing.\n if (copy[key] === from[key] || isEqual(copy[key], from[key])) {\n continue\n }\n copyProp(updates, from, key)\n }\n // New paints bring their style link, unless the copy keeps a style of its own.\n if (updates.fills)\n updates.fillStyleId = skip('fillStyleId') ? copy.fillStyleId : source.fillStyleId\n followVectorGeometry(updates, copy, source)\n remeasureChangedText(updates, copy)\n return { placed, x: !placedByLayout && !skip('x'), y: !placedByLayout && !skip('y') }\n}\n\nexport function updateSyncedProps(\n graph: SceneGraph,\n target: SceneNode,\n updates: Partial<SceneNode>,\n /** A field the copy keeps as its own, which the sync leaves as it is. */\n kept: (field: string) => boolean = () => false\n): void {\n resolveBoundNumbersInPlace(graph, target, updates, kept)\n let changed: Partial<SceneNode> | undefined\n for (const key of Object.keys(updates)) {\n const current = target[key as keyof SceneNode]\n const value = updates[key as keyof SceneNode]\n if (current !== value && !isEqual(current, value)) {\n changed ??= {}\n Reflect.set(changed, key, value)\n }\n }\n if (!changed) {\n return\n }\n if (changed.fills && updates.fillStyleId !== undefined) {\n changed.fillStyleId = updates.fillStyleId\n }\n graph.updateNode(target.id, changed)\n}\n\n/**\n * A bound number the sync writes takes the value it resolves to where the copy sits, not the\n * one its component holds: an instance that sets another mode, or sits in one that does, shows\n * that mode's value, as Figma draws it. A field the sync leaves alone, such as one an instance\n * overrides, keeps its own value.\n */\nfunction resolveBoundNumbersInPlace(\n graph: SceneGraph,\n target: SceneNode,\n updates: Partial<SceneNode>,\n kept: (field: string) => boolean\n): void {\n const bound = updates.boundVariables ?? target.boundVariables\n // The fields the sync writes, and the ones it binds anew, which keep an equal value only in\n // the component's mode.\n const rebound = updates.boundVariables\n ? Object.keys(bound).filter((field) => bound[field] !== target.boundVariables[field])\n : []\n const synced = uniq([...Object.keys(updates), ...rebound]).filter(\n (field) => isNumericVariableBindingField(field) && bound[field] && !kept(field)\n )\n if (synced.length === 0) return\n // The modes the copy takes in this sync decide what its bindings resolve to.\n if (updates.variableModes && !isEqual(updates.variableModes, target.variableModes))\n graph.updateNode(target.id, { variableModes: updates.variableModes })\n const resolved = resolvedNumericBindings(graph, { ...target, ...updates })\n Object.assign(updates, pick(resolved, synced as (keyof SceneNode)[]))\n}\n\nexport function cloneChildInCoordinates(\n graph: SceneGraph,\n src: SceneNode,\n sourceParent: SceneNode,\n targetParent: SceneNode,\n mode: NodeCloneMode = 'deep'\n): SceneNode {\n const componentScale =\n (src.componentScale * targetParent.componentScale) / sourceParent.componentScale\n return graph.createNode(src.type, targetParent.id, {\n ...cloneNodeProps(sourceInTargetCoordinates(src, componentScale), src.id, mode),\n componentScale\n })\n}\n\nexport function cloneChildrenWithMapping(\n graph: SceneGraph,\n sourceParentId: string,\n destParentId: string,\n mode: NodeCloneMode = 'deep'\n): void {\n // A cyclic component, such as an instance of an ancestor, would clone itself without end.\n if (sourceParentId === destParentId || graph.isDescendant(destParentId, sourceParentId)) return\n\n const sourceParent = graph.nodes.get(sourceParentId)\n const targetParent = graph.nodes.get(destParentId)\n if (!sourceParent || !targetParent) return\n\n for (const childId of sourceParent.childIds) {\n const src = graph.nodes.get(childId)\n if (!src) continue\n\n const clone = cloneChildInCoordinates(graph, src, sourceParent, targetParent, mode)\n\n if (src.childIds.length > 0) {\n cloneChildrenWithMapping(graph, childId, clone.id, mode)\n }\n }\n}\n\nexport function enclosingInstanceOverrideFields(graph: SceneGraph, node: SceneNode): Set<string>[] {\n const fields: Set<string>[] = []\n let parent = node.parentId ? graph.nodes.get(node.parentId) : undefined\n while (parent) {\n if (parent.type === 'INSTANCE') {\n fields.push(new Set(parent.instanceOverrides.descendants.get(node.id)?.keys()))\n }\n parent = parent.parentId ? graph.nodes.get(parent.parentId) : undefined\n }\n return fields\n}\n\nfunction childBindingProtection(\n graph: SceneGraph,\n child: SceneNode,\n overrides: InstanceOverrideState\n) {\n const fields = enclosingInstanceOverrideFields(graph, child)\n fields.push(new Set(overrides.descendants.get(child.id)?.keys()))\n if (child.instanceOverrides.self.size === 0 && fields.every((scope) => scope.size === 0)) {\n return NOTHING_PROTECTED\n }\n const protectedField = bindingProtection(fields)\n return (field: string) => protectedField(field) || ownsSelfFillField(child, field)\n}\n\nfunction linkMatchedChild(\n overrides: InstanceOverrideState,\n instParentId: string,\n instChild: SceneNode,\n compChildId: string\n): void {\n if (instChild.type === 'INSTANCE') {\n setInstanceOverride(overrides, instParentId, instChild.id, 'sourceComponentId', compChildId)\n } else {\n instChild.componentId = compChildId\n }\n}\n\nfunction matchFallbackChildren(\n graph: SceneGraph,\n compParent: SceneNode,\n instParent: SceneNode,\n instParentId: string,\n overrides: InstanceOverrideState,\n instChildMap: Map<string, SceneNode>,\n usedInstChildIds: Set<string>\n): void {\n const fallbackByType = new Map<SceneNode['type'], Map<string, SceneNode[]>>()\n const remainingCandidateCount = new Map<SceneNode['type'], number>()\n const unmatchedComponentCount = new Map<SceneNode['type'], number>()\n for (const compChildId of compParent.childIds) {\n if (instChildMap.has(compChildId)) continue\n const child = graph.nodes.get(compChildId)\n if (child) {\n unmatchedComponentCount.set(child.type, (unmatchedComponentCount.get(child.type) ?? 0) + 1)\n }\n }\n for (const childId of instParent.childIds) {\n const child = graph.nodes.get(childId)\n if (!child || usedInstChildIds.has(child.id)) continue\n remainingCandidateCount.set(child.type, (remainingCandidateCount.get(child.type) ?? 0) + 1)\n let byName = fallbackByType.get(child.type)\n if (!byName) {\n byName = new Map()\n fallbackByType.set(child.type, byName)\n }\n const queue = byName.get(child.name)\n if (queue) queue.push(child)\n else byName.set(child.name, [child])\n }\n\n // Match by name and type with FIFO queues to preserve sibling order in linear time.\n for (const compChildId of compParent.childIds) {\n if (instChildMap.has(compChildId)) continue\n const compChild = graph.nodes.get(compChildId)\n if (!compChild) continue\n const candidatesByName = fallbackByType.get(compChild.type)\n const candidateCount = remainingCandidateCount.get(compChild.type) ?? 0\n if (candidateCount > (unmatchedComponentCount.get(compChild.type) ?? 0)) continue\n const match = candidatesByName?.get(compChild.name)?.shift()\n if (!match) continue\n remainingCandidateCount.set(compChild.type, candidateCount - 1)\n instChildMap.set(compChildId, match)\n usedInstChildIds.add(match.id)\n linkMatchedChild(overrides, instParentId, match, compChildId)\n }\n}\n\nfunction sortInstanceChildren(\n graph: SceneGraph,\n instParent: SceneNode,\n instParentId: string,\n compChildOrder: string[],\n overrides: InstanceOverrideState\n): void {\n const orderMap = new Map<string, number>()\n for (let i = 0; i < compChildOrder.length; i++) orderMap.set(compChildOrder[i], i)\n\n const ranks = new Map<string, number>()\n for (let index = 0; index < instParent.childIds.length; index++) {\n const childId = instParent.childIds[index]\n const node = graph.nodes.get(childId)\n const mapped = node && copiedComponentLayerId(overrides, instParentId, node)\n const componentIndex = mapped ? orderMap.get(mapped) : undefined\n ranks.set(childId, componentIndex ?? compChildOrder.length + index)\n }\n const sorted = instParent.childIds.toSorted(\n (left, right) => (ranks.get(left) ?? 0) - (ranks.get(right) ?? 0)\n )\n // Move through the graph so the reorder is reported, as collaboration syncs it.\n sorted.forEach((childId, index) => {\n if (instParent.childIds[index] !== childId) graph.insertChildAt(childId, instParentId, index)\n })\n}\n\nexport interface MatchedCopy {\n compParent: SceneNode\n instParent: SceneNode\n compChild: SceneNode\n instChild: SceneNode\n}\n\nexport function syncCopy(\n graph: SceneGraph,\n { compParent, instParent, compChild, instChild }: MatchedCopy,\n protectedField: (field: string) => boolean,\n linkedLayerId?: string\n): void {\n const driven = propertyDrivenFields(graph, instChild, compChild)\n const kept =\n driven.size === 0 && protectedField === NOTHING_PROTECTED\n ? NOTHING_PROTECTED\n : (key: string) => driven.has(key) || isProtectedSyncField(instChild, key, protectedField)\n const componentScale =\n (compChild.componentScale * instParent.componentScale) / compParent.componentScale\n const effectiveSource = sourceWithEffectiveFill(graph, compChild, instChild)\n const source = sourceInTargetCoordinates(effectiveSource, componentScale)\n // Which properties a layer serves is the component's to say; a slot or exposed layer\n // created on the component becomes one in every instance.\n const updates: Partial<SceneNode> = {}\n if (instChild.componentScale !== componentScale) {\n updates.componentScale = componentScale\n }\n if (!isEqual(instChild.componentPropertyReferences, compChild.componentPropertyReferences)) {\n updates.componentPropertyReferences = structuredClone(compChild.componentPropertyReferences)\n }\n if (linkedLayerId !== undefined) {\n updates.componentId = linkedLayerId\n }\n syncBindingFields(instChild, source, updates, protectedField)\n const placement = copySyncedFields(updates, instChild, source, {\n compParent,\n instParent,\n factor: componentScale / compChild.componentScale,\n skip: kept\n })\n Object.assign(updates, assignedFieldValues(graph, instChild, compChild))\n keepOwnContentSize(graph, updates, instChild, source, placement)\n updateSyncedProps(graph, instChild, updates, kept)\n}\n\n/** True when syncing `compParentId` into `instParentId` would form a cycle. */\nfunction isCyclicSync(graph: SceneGraph, compParentId: string, instParentId: string): boolean {\n return compParentId === instParentId || graph.isDescendant(instParentId, compParentId)\n}\n\n/** Children already linked to a component child by sourceComponentId or componentId. */\nfunction matchLinkedChildren(\n graph: SceneGraph,\n instParent: SceneNode,\n instParentId: string,\n overrides: InstanceOverrideState,\n compChildIdSet: ReadonlySet<string>,\n instChildMap: Map<string, SceneNode>,\n usedInstChildIds: Set<string>\n): void {\n for (const childId of instParent.childIds) {\n const child = graph.nodes.get(childId)\n if (!child) continue\n const mappedComponentId = copiedComponentLayerId(overrides, instParentId, child)\n if (mappedComponentId && compChildIdSet.has(mappedComponentId)) {\n instChildMap.set(mappedComponentId, child)\n usedInstChildIds.add(child.id)\n }\n }\n}\n\n/**\n * Pass 3 of a sync: bring along the copy of a layer moved here inside the component, bring back\n * one the sync removed when its layer returns, or clone a layer the instance has no copy of. A\n * clone takes its own subtree unless copies the instance has belong in it, which the recursion\n * moves in instead. Children left unmatched are the sync's to remove once it finishes.\n */\nfunction placeMissingChildren(\n graph: SceneGraph,\n compParent: SceneNode,\n instParent: SceneNode,\n instChildMap: Map<string, SceneNode>,\n usedInstChildIds: Set<string>,\n context: InstanceSyncContext\n): void {\n for (const child of instChildMap.values()) context.matched.add(child.id)\n\n for (const compChildId of compParent.childIds) {\n if (instChildMap.has(compChildId)) continue\n const moved =\n unplacedCopy(graph, context, compChildId, instParent.id) ??\n restoreRemovedCopy(graph, context, compChildId, instParent.id)\n if (moved) {\n graph.insertChildAt(moved.id, instParent.id, instParent.childIds.length)\n instChildMap.set(compChildId, moved)\n usedInstChildIds.add(moved.id)\n context.matched.add(moved.id)\n continue\n }\n const src = graph.nodes.get(compChildId)\n if (!src) continue\n const clone = cloneChildInCoordinates(graph, src, compParent, instParent)\n if (src.childIds.length > 0 && !hasUnplacedCopiesBelow(graph, context, compChildId)) {\n cloneChildrenWithMapping(graph, compChildId, clone.id)\n }\n applyEnclosingAssignments(graph, clone)\n instChildMap.set(compChildId, clone)\n usedInstChildIds.add(clone.id)\n context.matched.add(clone.id)\n }\n for (const childId of instParent.childIds) {\n if (!usedInstChildIds.has(childId)) context.leftovers.add(childId)\n }\n}\n\nexport function syncChildren(\n graph: SceneGraph,\n compParentId: string,\n instParentId: string,\n overrides: InstanceOverrideState,\n context: InstanceSyncContext = createInstanceSyncContext(instParentId, overrides)\n): void {\n // An instance inside its own component would clone the component into itself without end.\n if (isCyclicSync(graph, compParentId, instParentId)) return\n\n const compParent = graph.nodes.get(compParentId)\n const instParent = graph.nodes.get(instParentId)\n if (!compParent || !instParent) return\n\n const instChildMap = new Map<string, SceneNode>()\n const usedInstChildIds = new Set<string>()\n const compChildIdSet = new Set(compParent.childIds)\n\n // Pass 1: Direct matching via sourceComponentId or componentId\n matchLinkedChildren(\n graph,\n instParent,\n instParentId,\n overrides,\n compChildIdSet,\n instChildMap,\n usedInstChildIds\n )\n\n // Pass 2: Fallback matching for unmatched children (e.g. from Figma imports)\n matchFallbackChildren(\n graph,\n compParent,\n instParent,\n instParentId,\n overrides,\n instChildMap,\n usedInstChildIds\n )\n\n placeMissingChildren(graph, compParent, instParent, instChildMap, usedInstChildIds, context)\n\n // Pass 4: Synchronize properties and recurse\n for (const compChildId of compParent.childIds) {\n const compChild = graph.nodes.get(compChildId)\n const instChild = instChildMap.get(compChildId)\n if (!compChild || !instChild) continue\n\n syncCopy(\n graph,\n { compParent, instParent, compChild, instChild },\n childBindingProtection(graph, instChild, overrides)\n )\n\n if (\n compChild.childIds.length > 0 &&\n !hasNodeInstanceOverride(overrides, instParentId, instChild.id, 'componentId') &&\n // The component's frame is the authority on which slot this is; instance copies of\n // its bindings are not synced.\n !ownsSlotContent(graph, instChild, slotPropertyId(compChild))\n ) {\n syncChildren(graph, compChildId, instChild.id, overrides, context)\n }\n }\n\n // Pass 5: Sort instance children to match component child order\n sortInstanceChildren(graph, instParent, instParentId, compParent.childIds, overrides)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,SAAS,aACP,QACA,KACA,OACM;CACN,OAAO,OAAO;AAChB;AAEA,SAAgB,SACd,QACA,QACA,KACM;CACN,IAAI,QAAQ,SACV,aAAa,QAAQ,KAAK,UAAU,OAAO,KAAK,CAAC;MAC5C,IAAI,QAAQ,WACjB,aAAa,QAAQ,KAAK,YAAY,OAAO,OAAO,CAAC;MAChD,IAAI,QAAQ,WACjB,aAAa,QAAQ,KAAK,YAA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,aAAa,KAG7E,CAAC,gBAAgB,OAAO,WAAW,eAAe,SAAS,CAAC,GAE5D,aAAa,OAAO,aAAa,UAAU,IAAI,WAAW,OAAO;CAErE;CAGA,qBAAqB,OAAO,YAAY,cAAc,WAAW,UAAU,SAAS;AACtF"}
1
+ {"version":3,"file":"sync.js","names":["hasNodeInstanceOverride"],"sources":["../../src/instances/sync.ts"],"sourcesContent":["// Child cloning and property synchronization shared by instance creation, swap, and sync.\nimport { uniq } from 'es-toolkit/array'\nimport { pick } from 'es-toolkit/object'\nimport { isEmptyObject, isEqual } from 'es-toolkit/predicate'\n\nimport { cloneNodeProps, copyEffects, copyFills, copyStrokes, copyStyleRuns } from '../copy'\nimport type { NodeCloneMode } from '../copy'\nimport type { SceneGraph } from '../graph'\nimport { scaleNodeChanges } from '../scaling/node'\nimport { ownsSlotContent, slotPropertyId } from '../slots/frames'\nimport type { SceneNode } from '../types'\nimport { resolvedNumericBindings } from '../variables/bindings'\nimport {\n effectBindingTarget,\n isNumericVariableBindingField,\n paintBindingTarget\n} from '../variables/fields'\nimport {\n applyBoundPaintColorsIn,\n copyAppliedBoundPaints,\n keepCopyBoundPaints\n} from '../variables/paints'\nimport { scaleVariableBindingUnits } from '../variables/units'\nimport { applyEnclosingAssignments, assignedFieldValues, propertyDrivenFields } from './assignments'\nimport { keepOwnContentSize, remeasureChangedText, type SyncedPlacement } from './content-size'\nimport {\n createInstanceSyncContext,\n hasUnplacedCopiesBelow,\n restoreRemovedCopy,\n unplacedCopy,\n type InstanceSyncContext\n} from './copies'\nimport { INSTANCE_SYNC_FIELD_OWNERS, INSTANCE_SYNC_FIELDS } from './fields'\nimport { ownsSelfFillField, sourceWithEffectiveFill } from './main-component'\nimport {\n bindingOverrideField,\n copiedComponentLayerId,\n hasInstanceOverride as hasNodeInstanceOverride,\n overriddenBindingField,\n setInstanceOverride,\n type InstanceOverrideState\n} from './overrides'\nimport { fitCopiedGroup, PLACEMENT_FIELDS, placedByConstraints } from './placement'\nimport { followVectorGeometry } from './vector-geometry'\n\nfunction setSceneProp<K extends keyof SceneNode>(\n target: Partial<SceneNode>,\n key: K,\n value: SceneNode[K]\n): void {\n target[key] = value\n}\n\nexport function copyProp(\n target: Partial<SceneNode> | SceneNode,\n source: SceneNode,\n key: keyof SceneNode\n): void {\n if (key === 'fills') {\n setSceneProp(target, key, copyFills(source.fills))\n } else if (key === 'strokes') {\n setSceneProp(target, key, copyStrokes(source.strokes))\n } else if (key === 'effects') {\n setSceneProp(target, key, copyEffects(source.effects))\n } else if (key === 'styleRuns') {\n setSceneProp(target, key, copyStyleRuns(source.styleRuns))\n } else if (key === 'boundVariables') {\n // Shallow copy the binding map — values are variable IDs (strings), not objects\n setSceneProp(target, key, { ...source.boundVariables })\n setSceneProp(target, 'variableBindingScales', { ...source.variableBindingScales })\n } else if (key === 'variableModes') {\n setSceneProp(target, key, { ...source.variableModes })\n } else if (key === 'gridPosition') {\n // Shallow copy the grid position object — all fields are primitives\n setSceneProp(target, key, source.gridPosition ? { ...source.gridPosition } : null)\n } else if (key === 'targetAspectRatio') {\n setSceneProp(target, key, source.targetAspectRatio ? { ...source.targetAspectRatio } : null)\n } else if (key === 'booleanOperation') {\n setSceneProp(target, key, source.booleanOperation ?? 'UNION')\n } else {\n const value = source[key]\n setSceneProp(target, key, Array.isArray(value) ? structuredClone(value) : value)\n }\n}\n\nexport function bindingProtection(scopes: ReadonlySet<string>[]): (field: string) => boolean {\n const fields = new Set<string>()\n for (const scope of scopes) {\n const perField = [...scope].some((field) => overriddenBindingField(field) !== null)\n for (const field of scope) {\n if (field !== 'boundVariables' || !perField) fields.add(field)\n }\n }\n return (field) => {\n if (fields.has(field)) return true\n // Paints and effects an instance set itself own their bindings too, bound or not.\n const binding = overriddenBindingField(field)\n if (binding === null) return false\n const paint = paintBindingTarget(binding)\n if (paint) return fields.has(paint.list)\n return fields.has('effects') && effectBindingTarget(binding) !== null\n }\n}\n\nfunction isUnbound(node: SceneNode): boolean {\n return isEmptyObject(node.boundVariables) && isEmptyObject(node.variableBindingScales)\n}\n\nexport function syncBindingFields(\n target: SceneNode,\n source: SceneNode,\n updates: Partial<SceneNode>,\n protectedField: (field: string) => boolean\n): void {\n if (protectedField('boundVariables') || (isUnbound(source) && isUnbound(target))) {\n return\n }\n const bindings = { ...source.boundVariables }\n const scales = { ...source.variableBindingScales }\n for (const field of new Set([\n ...Object.keys(source.boundVariables),\n ...Object.keys(target.boundVariables),\n ...Object.keys(target.variableBindingScales)\n ])) {\n if (!protectedField(bindingOverrideField(field))) continue\n if (!Object.hasOwn(target.boundVariables, field)) Reflect.deleteProperty(bindings, field)\n else bindings[field] = target.boundVariables[field]\n if (target.variableBindingScales[field] === undefined) Reflect.deleteProperty(scales, field)\n else scales[field] = target.variableBindingScales[field]\n }\n updates.boundVariables = bindings\n updates.variableBindingScales = scales\n}\n\nexport function isProtectedSyncField(\n node: SceneNode,\n key: string,\n protectedField: (field: string) => boolean\n): boolean {\n return (\n protectedField(key) ||\n (key in node.boundVariables &&\n (protectedField('boundVariables') || protectedField(bindingOverrideField(key))))\n )\n}\n\nexport function sourceInTargetCoordinates(source: SceneNode, targetScale: number): SceneNode {\n const factor = targetScale / source.componentScale\n if (!Number.isFinite(factor) || factor <= 0) throw new Error('Invalid component coordinate scale')\n if (factor === 1) return source\n return {\n ...source,\n ...scaleNodeChanges(source, factor, true),\n ...scaleVariableBindingUnits(source, factor)\n }\n}\n\nconst SYNCED_FIELDS = INSTANCE_SYNC_FIELDS.filter((key) => key !== 'boundVariables').map((key) => ({\n key,\n owner: INSTANCE_SYNC_FIELD_OWNERS[key],\n placement: PLACEMENT_FIELDS.has(key),\n position: key === 'x' || key === 'y'\n}))\n\nexport const NOTHING_PROTECTED = (_field: string): boolean => false\n\ninterface SyncedFieldsInput {\n compParent: SceneNode\n instParent: SceneNode\n /** The component's coordinates in the copy's. */\n factor: number\n /** Fields the copy keeps: overridden, bound, or driven by a property. */\n skip: (key: string) => boolean\n}\n\n/** The fields a copy takes from its component's layer, placed in the copy's parent. */\nfunction copySyncedFields(\n graph: SceneGraph,\n updates: Partial<SceneNode>,\n copy: SceneNode,\n source: SceneNode,\n { compParent, instParent, factor, skip }: SyncedFieldsInput\n): SyncedPlacement {\n // In an auto layout flow the layout places the copy, as it placed the component's layer.\n const placedByLayout = instParent.layoutMode !== 'NONE' && source.layoutPositioning !== 'ABSOLUTE'\n const placed = placedByLayout\n ? source\n : placedByConstraints(graph, source, compParent, instParent, factor)\n for (const { key, owner, placement, position } of SYNCED_FIELDS) {\n if ((placedByLayout && position) || skip(key) || (owner && skip(owner))) {\n continue\n }\n const from = placement ? placed : source\n // Most fields already match: comparing first spares cloning them for nothing.\n if (copy[key] === from[key] || isEqual(copy[key], from[key])) {\n continue\n }\n copyProp(updates, from, key)\n }\n // New paints bring their style link, unless the copy keeps a style of its own.\n if (updates.fills)\n updates.fillStyleId = skip('fillStyleId') ? copy.fillStyleId : source.fillStyleId\n followVectorGeometry(updates, copy, source)\n remeasureChangedText(updates, copy)\n return { placed, x: !placedByLayout && !skip('x'), y: !placedByLayout && !skip('y') }\n}\n\nexport function updateSyncedProps(\n graph: SceneGraph,\n target: SceneNode,\n updates: Partial<SceneNode>,\n /** A field the copy keeps as its own, which the sync leaves as it is. */\n kept: (field: string) => boolean = () => false\n): void {\n resolveBoundNumbersInPlace(graph, target, updates, kept)\n if (updates.fills || updates.strokes || updates.boundVariables) {\n applySyncedModes(graph, target, updates)\n keepCopyBoundPaints(graph, target, updates)\n }\n let changed: Partial<SceneNode> | undefined\n for (const key of Object.keys(updates)) {\n const current = target[key as keyof SceneNode]\n const value = updates[key as keyof SceneNode]\n if (current !== value && !isEqual(current, value)) {\n changed ??= {}\n Reflect.set(changed, key, value)\n }\n }\n if (!changed) {\n return\n }\n if (changed.fills && updates.fillStyleId !== undefined) {\n changed.fillStyleId = updates.fillStyleId\n }\n graph.updateNode(target.id, changed)\n}\n\n/**\n * A bound number the sync writes takes the value it resolves to where the copy sits, not the\n * one its component holds: an instance that sets another mode, or sits in one that does, shows\n * that mode's value, as Figma draws it. A field the sync leaves alone, such as one an instance\n * overrides, keeps its own value.\n */\nfunction resolveBoundNumbersInPlace(\n graph: SceneGraph,\n target: SceneNode,\n updates: Partial<SceneNode>,\n kept: (field: string) => boolean\n): void {\n const bound = updates.boundVariables ?? target.boundVariables\n // The fields the sync writes, and the ones it binds anew, which keep an equal value only in\n // the component's mode.\n const rebound = updates.boundVariables\n ? Object.keys(bound).filter((field) => bound[field] !== target.boundVariables[field])\n : []\n const synced = uniq([...Object.keys(updates), ...rebound]).filter(\n (field) => isNumericVariableBindingField(field) && bound[field] && !kept(field)\n )\n if (synced.length === 0) return\n applySyncedModes(graph, target, updates)\n const resolved = resolvedNumericBindings(graph, { ...target, ...updates })\n Object.assign(updates, pick(resolved, synced as (keyof SceneNode)[]))\n}\n\n/** The modes the copy takes in this sync decide what its bindings resolve to. */\nfunction applySyncedModes(graph: SceneGraph, target: SceneNode, updates: Partial<SceneNode>): void {\n if (updates.variableModes && !isEqual(updates.variableModes, target.variableModes))\n graph.updateNode(target.id, { variableModes: updates.variableModes })\n}\n\nexport function cloneChildInCoordinates(\n graph: SceneGraph,\n src: SceneNode,\n sourceParent: SceneNode,\n targetParent: SceneNode,\n mode: NodeCloneMode = 'deep'\n): SceneNode {\n const componentScale =\n (src.componentScale * targetParent.componentScale) / sourceParent.componentScale\n const clone = graph.createNode(src.type, targetParent.id, {\n ...cloneNodeProps(sourceInTargetCoordinates(src, componentScale), src.id, mode),\n componentScale\n })\n copyAppliedBoundPaints(src, clone)\n return clone\n}\n\nexport function cloneChildrenWithMapping(\n graph: SceneGraph,\n sourceParentId: string,\n destParentId: string,\n mode: NodeCloneMode = 'deep'\n): void {\n // A cyclic component, such as an instance of an ancestor, would clone itself without end.\n if (sourceParentId === destParentId || graph.isDescendant(destParentId, sourceParentId)) return\n\n const sourceParent = graph.nodes.get(sourceParentId)\n const targetParent = graph.nodes.get(destParentId)\n if (!sourceParent || !targetParent) return\n\n for (const childId of sourceParent.childIds) {\n const src = graph.nodes.get(childId)\n if (!src) continue\n\n const clone = cloneChildInCoordinates(graph, src, sourceParent, targetParent, mode)\n\n if (src.childIds.length > 0) {\n cloneChildrenWithMapping(graph, childId, clone.id, mode)\n }\n }\n}\n\nexport function enclosingInstanceOverrideFields(graph: SceneGraph, node: SceneNode): Set<string>[] {\n const fields: Set<string>[] = []\n let parent = node.parentId ? graph.nodes.get(node.parentId) : undefined\n while (parent) {\n if (parent.type === 'INSTANCE') {\n fields.push(new Set(parent.instanceOverrides.descendants.get(node.id)?.keys()))\n }\n parent = parent.parentId ? graph.nodes.get(parent.parentId) : undefined\n }\n return fields\n}\n\nfunction childBindingProtection(\n graph: SceneGraph,\n child: SceneNode,\n overrides: InstanceOverrideState\n) {\n const fields = enclosingInstanceOverrideFields(graph, child)\n fields.push(new Set(overrides.descendants.get(child.id)?.keys()))\n if (child.instanceOverrides.self.size === 0 && fields.every((scope) => scope.size === 0)) {\n return NOTHING_PROTECTED\n }\n const protectedField = bindingProtection(fields)\n return (field: string) => protectedField(field) || ownsSelfFillField(child, field)\n}\n\nfunction linkMatchedChild(\n overrides: InstanceOverrideState,\n instParentId: string,\n instChild: SceneNode,\n compChildId: string\n): void {\n if (instChild.type === 'INSTANCE') {\n setInstanceOverride(overrides, instParentId, instChild.id, 'sourceComponentId', compChildId)\n } else {\n instChild.componentId = compChildId\n }\n}\n\nfunction matchFallbackChildren(\n graph: SceneGraph,\n compParent: SceneNode,\n instParent: SceneNode,\n instParentId: string,\n overrides: InstanceOverrideState,\n instChildMap: Map<string, SceneNode>,\n usedInstChildIds: Set<string>\n): void {\n const fallbackByType = new Map<SceneNode['type'], Map<string, SceneNode[]>>()\n const remainingCandidateCount = new Map<SceneNode['type'], number>()\n const unmatchedComponentCount = new Map<SceneNode['type'], number>()\n for (const compChildId of compParent.childIds) {\n if (instChildMap.has(compChildId)) continue\n const child = graph.nodes.get(compChildId)\n if (child) {\n unmatchedComponentCount.set(child.type, (unmatchedComponentCount.get(child.type) ?? 0) + 1)\n }\n }\n for (const childId of instParent.childIds) {\n const child = graph.nodes.get(childId)\n if (!child || usedInstChildIds.has(child.id)) continue\n remainingCandidateCount.set(child.type, (remainingCandidateCount.get(child.type) ?? 0) + 1)\n let byName = fallbackByType.get(child.type)\n if (!byName) {\n byName = new Map()\n fallbackByType.set(child.type, byName)\n }\n const queue = byName.get(child.name)\n if (queue) queue.push(child)\n else byName.set(child.name, [child])\n }\n\n // Match by name and type with FIFO queues to preserve sibling order in linear time.\n for (const compChildId of compParent.childIds) {\n if (instChildMap.has(compChildId)) continue\n const compChild = graph.nodes.get(compChildId)\n if (!compChild) continue\n const candidatesByName = fallbackByType.get(compChild.type)\n const candidateCount = remainingCandidateCount.get(compChild.type) ?? 0\n if (candidateCount > (unmatchedComponentCount.get(compChild.type) ?? 0)) continue\n const match = candidatesByName?.get(compChild.name)?.shift()\n if (!match) continue\n remainingCandidateCount.set(compChild.type, candidateCount - 1)\n instChildMap.set(compChildId, match)\n usedInstChildIds.add(match.id)\n linkMatchedChild(overrides, instParentId, match, compChildId)\n }\n}\n\nfunction sortInstanceChildren(\n graph: SceneGraph,\n instParent: SceneNode,\n instParentId: string,\n compChildOrder: string[],\n overrides: InstanceOverrideState\n): void {\n const orderMap = new Map<string, number>()\n for (let i = 0; i < compChildOrder.length; i++) orderMap.set(compChildOrder[i], i)\n\n const ranks = new Map<string, number>()\n for (let index = 0; index < instParent.childIds.length; index++) {\n const childId = instParent.childIds[index]\n const node = graph.nodes.get(childId)\n const mapped = node && copiedComponentLayerId(overrides, instParentId, node)\n const componentIndex = mapped ? orderMap.get(mapped) : undefined\n ranks.set(childId, componentIndex ?? compChildOrder.length + index)\n }\n const sorted = instParent.childIds.toSorted(\n (left, right) => (ranks.get(left) ?? 0) - (ranks.get(right) ?? 0)\n )\n // Move through the graph so the reorder is reported, as collaboration syncs it.\n sorted.forEach((childId, index) => {\n if (instParent.childIds[index] !== childId) graph.insertChildAt(childId, instParentId, index)\n })\n}\n\nexport interface MatchedCopy {\n compParent: SceneNode\n instParent: SceneNode\n compChild: SceneNode\n instChild: SceneNode\n}\n\nexport function syncCopy(\n graph: SceneGraph,\n { compParent, instParent, compChild, instChild }: MatchedCopy,\n protectedField: (field: string) => boolean,\n linkedLayerId?: string\n): boolean {\n const driven = propertyDrivenFields(graph, instChild, compChild)\n const kept =\n driven.size === 0 && protectedField === NOTHING_PROTECTED\n ? NOTHING_PROTECTED\n : (key: string) => driven.has(key) || isProtectedSyncField(instChild, key, protectedField)\n const componentScale =\n (compChild.componentScale * instParent.componentScale) / compParent.componentScale\n const effectiveSource = sourceWithEffectiveFill(graph, compChild, instChild)\n const source = sourceInTargetCoordinates(effectiveSource, componentScale)\n // Which properties a layer serves is the component's to say; a slot or exposed layer\n // created on the component becomes one in every instance.\n const updates: Partial<SceneNode> = {}\n if (instChild.componentScale !== componentScale) {\n updates.componentScale = componentScale\n }\n if (!isEqual(instChild.componentPropertyReferences, compChild.componentPropertyReferences)) {\n updates.componentPropertyReferences = structuredClone(compChild.componentPropertyReferences)\n }\n if (linkedLayerId !== undefined) {\n updates.componentId = linkedLayerId\n }\n syncBindingFields(instChild, source, updates, protectedField)\n const placement = copySyncedFields(graph, updates, instChild, source, {\n compParent,\n instParent,\n factor: componentScale / compChild.componentScale,\n skip: kept\n })\n Object.assign(updates, assignedFieldValues(graph, instChild, compChild))\n keepOwnContentSize(graph, updates, instChild, source, placement)\n updateSyncedProps(graph, instChild, updates, kept)\n return placement.placed !== source\n}\n\n/** True when syncing `compParentId` into `instParentId` would form a cycle. */\nfunction isCyclicSync(graph: SceneGraph, compParentId: string, instParentId: string): boolean {\n return compParentId === instParentId || graph.isDescendant(instParentId, compParentId)\n}\n\n/** Children already linked to a component child by sourceComponentId or componentId. */\nfunction matchLinkedChildren(\n graph: SceneGraph,\n instParent: SceneNode,\n instParentId: string,\n overrides: InstanceOverrideState,\n compChildIdSet: ReadonlySet<string>,\n instChildMap: Map<string, SceneNode>,\n usedInstChildIds: Set<string>\n): void {\n for (const childId of instParent.childIds) {\n const child = graph.nodes.get(childId)\n if (!child) continue\n const mappedComponentId = copiedComponentLayerId(overrides, instParentId, child)\n if (mappedComponentId && compChildIdSet.has(mappedComponentId)) {\n instChildMap.set(mappedComponentId, child)\n usedInstChildIds.add(child.id)\n }\n }\n}\n\n/**\n * Pass 3 of a sync: bring along the copy of a layer moved here inside the component, bring back\n * one the sync removed when its layer returns, or clone a layer the instance has no copy of. A\n * clone takes its own subtree unless copies the instance has belong in it, which the recursion\n * moves in instead. Children left unmatched are the sync's to remove once it finishes.\n */\nfunction placeMissingChildren(\n graph: SceneGraph,\n compParent: SceneNode,\n instParent: SceneNode,\n instChildMap: Map<string, SceneNode>,\n usedInstChildIds: Set<string>,\n context: InstanceSyncContext\n): void {\n for (const child of instChildMap.values()) context.matched.add(child.id)\n\n for (const compChildId of compParent.childIds) {\n if (instChildMap.has(compChildId)) continue\n const moved =\n unplacedCopy(graph, context, compChildId, instParent.id) ??\n restoreRemovedCopy(graph, context, compChildId, instParent.id)\n if (moved) {\n graph.insertChildAt(moved.id, instParent.id, instParent.childIds.length)\n instChildMap.set(compChildId, moved)\n usedInstChildIds.add(moved.id)\n context.matched.add(moved.id)\n continue\n }\n const src = graph.nodes.get(compChildId)\n if (!src) continue\n const clone = cloneChildInCoordinates(graph, src, compParent, instParent)\n if (src.childIds.length > 0 && !hasUnplacedCopiesBelow(graph, context, compChildId)) {\n cloneChildrenWithMapping(graph, compChildId, clone.id)\n }\n applyEnclosingAssignments(graph, clone)\n applyBoundPaintColorsIn(graph, clone.id)\n instChildMap.set(compChildId, clone)\n usedInstChildIds.add(clone.id)\n context.matched.add(clone.id)\n }\n for (const childId of instParent.childIds) {\n if (!usedInstChildIds.has(childId)) context.leftovers.add(childId)\n }\n}\n\nexport function syncChildren(\n graph: SceneGraph,\n compParentId: string,\n instParentId: string,\n overrides: InstanceOverrideState,\n context: InstanceSyncContext = createInstanceSyncContext(instParentId, overrides)\n): boolean {\n // An instance inside its own component would clone the component into itself without end.\n if (isCyclicSync(graph, compParentId, instParentId)) return false\n\n const compParent = graph.nodes.get(compParentId)\n const instParent = graph.nodes.get(instParentId)\n if (!compParent || !instParent) return false\n\n const instChildMap = new Map<string, SceneNode>()\n const usedInstChildIds = new Set<string>()\n const compChildIdSet = new Set(compParent.childIds)\n\n // Pass 1: Direct matching via sourceComponentId or componentId\n matchLinkedChildren(\n graph,\n instParent,\n instParentId,\n overrides,\n compChildIdSet,\n instChildMap,\n usedInstChildIds\n )\n\n // Pass 2: Fallback matching for unmatched children (e.g. from Figma imports)\n matchFallbackChildren(\n graph,\n compParent,\n instParent,\n instParentId,\n overrides,\n instChildMap,\n usedInstChildIds\n )\n\n placeMissingChildren(graph, compParent, instParent, instChildMap, usedInstChildIds, context)\n\n // Pass 4: Synchronize properties and recurse\n let constrained = false\n for (const compChildId of compParent.childIds) {\n const compChild = graph.nodes.get(compChildId)\n const instChild = instChildMap.get(compChildId)\n if (!compChild || !instChild) continue\n\n const match = { compParent, instParent, compChild, instChild }\n const protection = childBindingProtection(graph, instChild, overrides)\n // True when its constraints placed the copy elsewhere than the component's layer.\n if (syncCopy(graph, match, protection)) constrained = true\n if (\n compChild.childIds.length > 0 &&\n !hasNodeInstanceOverride(overrides, instParentId, instChild.id, 'componentId') &&\n // The component's frame is the authority on which slot this is; instance copies of\n // its bindings are not synced.\n !ownsSlotContent(graph, instChild, slotPropertyId(compChild))\n ) {\n if (syncChildren(graph, compChildId, instChild.id, overrides, context)) constrained = true\n }\n }\n\n // Pass 5: Sort instance children to match component child order\n sortInstanceChildren(graph, instParent, instParentId, compParent.childIds, overrides)\n // A group fits layers its constraints moved; else it keeps the component's box, as a boolean must.\n if (constrained) fitCopiedGroup(graph, instParentId)\n return constrained\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6CA,SAAS,aACP,QACA,KACA,OACM;CACN,OAAO,OAAO;AAChB;AAEA,SAAgB,SACd,QACA,QACA,KACM;CACN,IA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AA"}
1
+ {"version":3,"file":"node-defaults.d.ts","names":[],"sources":["../src/node-defaults.ts"],"mappings":";;iBAUgB,+BAA+B;;iBA4B/B,mBAAmB,MAAM,WAAW;;;;;iBASpC,kBACd,MAAM,KAAK,yDACV,KAAK;iBAKQ,kBACd,0BACA,MAAM,UACN,YAAW,QAAQ,aAClB;;cAmLU,wBAAwB,YAAY;;cAMpC,mBAAmB,YAAY;;cAS/B,uBAAuB,YAAY;iBAShC,iBAAiB,MAAM,KAAK;cAI/B,iBAAe,IAAA"}
@@ -189,6 +189,7 @@ function createDefaultNode(generateId, type, overrides = {}) {
189
189
  sharedSymbolVersion: null,
190
190
  publishedVersion: null,
191
191
  librarySource: null,
192
+ libraryLayerId: null,
192
193
  isPublishable: false,
193
194
  isSymbolPublishable: false,
194
195
  isExposedInstance: false,
@@ -1 +1 @@
1
- {"version":3,"file":"node-defaults.js","names":[],"sources":["../src/node-defaults.ts"],"sourcesContent":["import {\n BLACK,\n DEFAULT_FONT_FAMILY,\n DEFAULT_STROKE_MITER_LIMIT,\n DEFAULT_STROKE_WEIGHT\n} from './constants'\nimport { createInstanceOverrideState } from './instances/overrides'\nimport { NO_LETTER_SPACING } from './text/lengths'\nimport type { NodeType, SceneNode, SourceMetadata } from './types'\n\nexport function createDefaultSourceMetadata(): SourceMetadata {\n return {\n format: null,\n id: null,\n orderKey: null,\n editedFields: [],\n fig: {\n rawSize: null,\n rawTransform: null,\n rawNodeFields: {},\n layout: null,\n symbolOverrides: [],\n componentPropAssignments: [],\n derivedSymbolData: [],\n derivedSymbolDataLayoutVersion: null,\n uniformScaleFactor: null\n }\n }\n}\n\n/**\n * Every SceneNode field. Nodes start with all of them, so setting any field later keeps the\n * shape every node shares; a key added after creation turns a JavaScriptCore object into a\n * slower, larger dictionary.\n */\ntype CompleteNodeFields = SceneNode & Record<keyof SceneNode, unknown>\n\n/** Where Figma aligns a new node's strokes: centered on lines and vectors, outside text, else inside. */\nexport function defaultStrokeAlign(type: NodeType): SceneNode['strokeAlign'] {\n if (type === 'LINE' || type === 'VECTOR') return 'CENTER'\n return type === 'TEXT' ? 'OUTSIDE' : 'INSIDE'\n}\n\n/**\n * Weight and alignment a stroke added to `node` takes: its first stroke's, or what the node keeps\n * with none. Adding a stroke from the panel and from the plugin API both go through here.\n */\nexport function newStrokeGeometry(\n node: Pick<SceneNode, 'strokes' | 'strokeWeight' | 'strokeAlign'>\n): Pick<SceneNode['strokes'][number], 'weight' | 'align'> {\n const first = node.strokes.at(0)\n return { weight: first?.weight ?? node.strokeWeight, align: first?.align ?? node.strokeAlign }\n}\n\nexport function createDefaultNode(\n generateId: () => string,\n type: NodeType,\n overrides: Partial<SceneNode> = {}\n): SceneNode {\n return {\n id: generateId(),\n type,\n name: type.charAt(0) + type.slice(1).toLowerCase(),\n parentId: null,\n childIds: [],\n x: 0,\n y: 0,\n width: 100,\n height: 100,\n rotation: 0,\n source: createDefaultSourceMetadata(),\n derivedLayout: null,\n fills:\n type === 'TEXT' ? [{ type: 'SOLID' as const, color: BLACK, opacity: 1, visible: true }] : [],\n strokes: [],\n effects: [],\n layoutGrids: [],\n guides: [],\n fillStyleId: null,\n strokeStyleId: null,\n textStyleId: null,\n effectStyleId: null,\n gridStyleId: null,\n sharedStyleType: null,\n opacity: 1,\n cornerRadius: 0,\n topLeftRadius: 0,\n topRightRadius: 0,\n bottomRightRadius: 0,\n bottomLeftRadius: 0,\n independentCorners: false,\n cornerSmoothing: 0,\n visible: true,\n locked: false,\n clipsContent: false,\n text: '',\n fontSize: 14,\n fontFamily: DEFAULT_FONT_FAMILY,\n fontWeight: 400,\n italic: false,\n fontStyle: null,\n textAlignHorizontal: 'LEFT',\n textDirection: 'AUTO',\n textLanguage: null,\n leadingTrim: 'NONE',\n lineHeight: null,\n letterSpacing: NO_LETTER_SPACING,\n layoutMode: 'NONE',\n layoutDirection: 'AUTO',\n layoutWrap: 'NO_WRAP',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n counterAxisSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n blendMode: 'PASS_THROUGH',\n layoutPositioning: 'AUTO',\n layoutGrow: 0,\n layoutAlignSelf: 'AUTO',\n vectorNetwork: null,\n handleMirroring: 'NONE',\n fillGeometry: [],\n strokeGeometry: [],\n arcData: null,\n textAlignVertical: 'TOP',\n textAutoResize: 'NONE',\n textCase: 'ORIGINAL',\n textDecoration: 'NONE',\n textDecorationStyle: 'SOLID',\n textDecorationThickness: null,\n textDecorationFills: [],\n textDecorationSkipInk: true,\n textUnderlineOffset: null,\n maxLines: null,\n textParagraphs: [],\n listSpacing: 0,\n paragraphSpacing: 0,\n paragraphIndent: 0,\n hangingList: false,\n styleRuns: [],\n fontVariations: [],\n opticalSizeFromFontSize: true,\n fontFeatures: [],\n horizontalConstraint: 'MIN',\n verticalConstraint: 'MIN',\n strokeCap: 'NONE',\n strokeJoin: 'MITER',\n dashPattern: [],\n borderTopWeight: 0,\n borderRightWeight: 0,\n borderBottomWeight: 0,\n borderLeftWeight: 0,\n independentStrokeWeights: false,\n strokeWeight: DEFAULT_STROKE_WEIGHT,\n strokeAlign: defaultStrokeAlign(type),\n strokeMiterLimit: DEFAULT_STROKE_MITER_LIMIT,\n minWidth: null,\n maxWidth: null,\n minHeight: null,\n maxHeight: null,\n targetAspectRatio: null,\n connectorStart: null,\n connectorEnd: null,\n connectorLineType: 'ELBOWED',\n connectorStartCap: 'ROUND',\n connectorEndCap: 'ARROW_LINES',\n connectorControlPoints: [],\n connectorCurveHandles: null,\n connectorLabelPosition: null,\n isMask: false,\n maskType: 'ALPHA',\n maskIsOutline: false,\n gridTemplateColumns: [],\n gridTemplateRows: [],\n gridColumnGap: 0,\n gridRowGap: 0,\n gridPosition: null,\n counterAxisAlignContent: 'AUTO',\n itemReverseZIndex: false,\n strokesIncludedInLayout: false,\n expanded: true,\n textTruncation: 'DISABLED',\n autoRename: true,\n pointCount: 5,\n // Figma's: the golden-ratio star, whose inner points line up with its outer ones.\n starInnerRadius: (3 - Math.sqrt(5)) / 2,\n shapeWithTextType: 'SQUARE',\n shapeUserHeight: 0,\n shapeTruncates: false,\n componentId: null,\n instanceOverrides: createInstanceOverrideState(),\n componentPropertyDefinitions: [],\n componentPropertyReferences: [],\n componentPropertyAssignments: {},\n componentPropertyValues: {},\n componentKey: null,\n sourceLibraryKey: null,\n publishId: null,\n overrideKey: null,\n sharedSymbolVersion: null,\n publishedVersion: null,\n librarySource: null,\n isPublishable: false,\n isSymbolPublishable: false,\n isExposedInstance: false,\n symbolDescription: '',\n symbolLinks: [],\n variantPropSpecs: [],\n boundVariables: {},\n variableBindingScales: {},\n variableAssignmentScales: {},\n componentScale: 1,\n variableModes: {},\n exportSettings: [],\n status: null,\n pluginData: [],\n pluginRelaunchData: [],\n internalOnly: false,\n flipX: false,\n flipY: false,\n textPicture: null,\n derivedTextGlyphs: null,\n derivedTextHeight: null,\n textPathData: null,\n textPathBox: null,\n booleanOperation: undefined,\n ...overrides\n } satisfies CompleteNodeFields\n}\n\n/** Containers whose bounds follow their children and that set no coordinate space, as in Figma. */\nexport const FITTED_CONTAINER_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'GROUP',\n 'BOOLEAN_OPERATION'\n])\n\n/** Layers whose stroke can take a weight per side, as Figma's `strokeTopWeight` and its siblings. */\nexport const SIDE_STROKE_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'RECTANGLE',\n 'FRAME',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\n/** The kinds that hold layers of their own on the canvas: what a shadow or a clip encloses. */\nexport const LAYER_CONTAINER_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'FRAME',\n 'GROUP',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\nexport function isLayerContainer(node: Pick<SceneNode, 'type'>): boolean {\n return LAYER_CONTAINER_TYPES.has(node.type)\n}\n\nexport const CONTAINER_TYPES = new Set<NodeType>([\n 'CANVAS',\n 'FRAME',\n 'GROUP',\n 'BOOLEAN_OPERATION',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n"],"mappings":";;;;AAUA,SAAgB,8BAA8C;CAC5D,OAAO;EACL,QAAQ;EACR,IAAI;EACJ,UAAU;EACV,cAAc,CAAC;EACf,KAAK;GACH,SAAS;GACT,cAAc;GACd,eAAe,CAAC;GAChB,QAAQ;GACR,iBAAiB,CAAC;GAClB,0BAA0B,CAAC;GAC3B,mBAAmB,CAAC;GACpB,gCAAgC;GAChC,oBAAoB;EACtB;CACF;AACF;;AAUA,SAAgB,mBAAmB,MAA0C;CAC3E,IAAI,SAAS,UAAU,SAAS,UAAU,OAAO;CACjD,OAAO,SAAS,SAAS,YAAY;AACvC;;;;;AAMA,SAAgB,kBACd,MACwD;CACxD,MAAM,QAAQ,KAAK,QAAQ,GAAG,CAAC;CAC/B,OAAO;EAAE,QAAQ,OAAO,UAAU,KAAK;EAAc,OAAO,OAAO,SAAS,KAAK;CAAY;AAC/F;AAEA,SAAgB,kBACd,YACA,MACA,YAAgC,CAAC,GACtB;CACX,OAAO;EACL,IAAI,WAAW;EACf;EACA,MAAM,KAAK,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY;EACjD,UAAU;EACV,UAAU,CAAC;EACX,GAAG;EACH,GAAG;EACH,OAAO;EACP,QAAQ;EACR,UAAU;EACV,QAAQ,4BAA4B;EACpC,eAAe;EACf,OACE,SAAS,SAAS,CAAC;GAAE,MAAM;GAAkB,OAAO;GAAO,SAAS;GAAG,SAAS;EAAK,CAAC,IAAI,CAAC;EAC7F,SAAS,CAAC;EACV,SAAS,CAAC;EACV,aAAa,CAAC;EACd,QAAQ,CAAC;EACT,aAAa;EACb,eAAe;EACf,aAAa;EACb,eAAe;EACf,aAAa;EACb,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ACA;AACF,CAAC"}
1
+ {"version":3,"file":"node-defaults.js","names":[],"sources":["../src/node-defaults.ts"],"sourcesContent":["import {\n BLACK,\n DEFAULT_FONT_FAMILY,\n DEFAULT_STROKE_MITER_LIMIT,\n DEFAULT_STROKE_WEIGHT\n} from './constants'\nimport { createInstanceOverrideState } from './instances/overrides'\nimport { NO_LETTER_SPACING } from './text/lengths'\nimport type { NodeType, SceneNode, SourceMetadata } from './types'\n\nexport function createDefaultSourceMetadata(): SourceMetadata {\n return {\n format: null,\n id: null,\n orderKey: null,\n editedFields: [],\n fig: {\n rawSize: null,\n rawTransform: null,\n rawNodeFields: {},\n layout: null,\n symbolOverrides: [],\n componentPropAssignments: [],\n derivedSymbolData: [],\n derivedSymbolDataLayoutVersion: null,\n uniformScaleFactor: null\n }\n }\n}\n\n/**\n * Every SceneNode field. Nodes start with all of them, so setting any field later keeps the\n * shape every node shares; a key added after creation turns a JavaScriptCore object into a\n * slower, larger dictionary.\n */\ntype CompleteNodeFields = SceneNode & Record<keyof SceneNode, unknown>\n\n/** Where Figma aligns a new node's strokes: centered on lines and vectors, outside text, else inside. */\nexport function defaultStrokeAlign(type: NodeType): SceneNode['strokeAlign'] {\n if (type === 'LINE' || type === 'VECTOR') return 'CENTER'\n return type === 'TEXT' ? 'OUTSIDE' : 'INSIDE'\n}\n\n/**\n * Weight and alignment a stroke added to `node` takes: its first stroke's, or what the node keeps\n * with none. Adding a stroke from the panel and from the plugin API both go through here.\n */\nexport function newStrokeGeometry(\n node: Pick<SceneNode, 'strokes' | 'strokeWeight' | 'strokeAlign'>\n): Pick<SceneNode['strokes'][number], 'weight' | 'align'> {\n const first = node.strokes.at(0)\n return { weight: first?.weight ?? node.strokeWeight, align: first?.align ?? node.strokeAlign }\n}\n\nexport function createDefaultNode(\n generateId: () => string,\n type: NodeType,\n overrides: Partial<SceneNode> = {}\n): SceneNode {\n return {\n id: generateId(),\n type,\n name: type.charAt(0) + type.slice(1).toLowerCase(),\n parentId: null,\n childIds: [],\n x: 0,\n y: 0,\n width: 100,\n height: 100,\n rotation: 0,\n source: createDefaultSourceMetadata(),\n derivedLayout: null,\n fills:\n type === 'TEXT' ? [{ type: 'SOLID' as const, color: BLACK, opacity: 1, visible: true }] : [],\n strokes: [],\n effects: [],\n layoutGrids: [],\n guides: [],\n fillStyleId: null,\n strokeStyleId: null,\n textStyleId: null,\n effectStyleId: null,\n gridStyleId: null,\n sharedStyleType: null,\n opacity: 1,\n cornerRadius: 0,\n topLeftRadius: 0,\n topRightRadius: 0,\n bottomRightRadius: 0,\n bottomLeftRadius: 0,\n independentCorners: false,\n cornerSmoothing: 0,\n visible: true,\n locked: false,\n clipsContent: false,\n text: '',\n fontSize: 14,\n fontFamily: DEFAULT_FONT_FAMILY,\n fontWeight: 400,\n italic: false,\n fontStyle: null,\n textAlignHorizontal: 'LEFT',\n textDirection: 'AUTO',\n textLanguage: null,\n leadingTrim: 'NONE',\n lineHeight: null,\n letterSpacing: NO_LETTER_SPACING,\n layoutMode: 'NONE',\n layoutDirection: 'AUTO',\n layoutWrap: 'NO_WRAP',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n counterAxisSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n blendMode: 'PASS_THROUGH',\n layoutPositioning: 'AUTO',\n layoutGrow: 0,\n layoutAlignSelf: 'AUTO',\n vectorNetwork: null,\n handleMirroring: 'NONE',\n fillGeometry: [],\n strokeGeometry: [],\n arcData: null,\n textAlignVertical: 'TOP',\n textAutoResize: 'NONE',\n textCase: 'ORIGINAL',\n textDecoration: 'NONE',\n textDecorationStyle: 'SOLID',\n textDecorationThickness: null,\n textDecorationFills: [],\n textDecorationSkipInk: true,\n textUnderlineOffset: null,\n maxLines: null,\n textParagraphs: [],\n listSpacing: 0,\n paragraphSpacing: 0,\n paragraphIndent: 0,\n hangingList: false,\n styleRuns: [],\n fontVariations: [],\n opticalSizeFromFontSize: true,\n fontFeatures: [],\n horizontalConstraint: 'MIN',\n verticalConstraint: 'MIN',\n strokeCap: 'NONE',\n strokeJoin: 'MITER',\n dashPattern: [],\n borderTopWeight: 0,\n borderRightWeight: 0,\n borderBottomWeight: 0,\n borderLeftWeight: 0,\n independentStrokeWeights: false,\n strokeWeight: DEFAULT_STROKE_WEIGHT,\n strokeAlign: defaultStrokeAlign(type),\n strokeMiterLimit: DEFAULT_STROKE_MITER_LIMIT,\n minWidth: null,\n maxWidth: null,\n minHeight: null,\n maxHeight: null,\n targetAspectRatio: null,\n connectorStart: null,\n connectorEnd: null,\n connectorLineType: 'ELBOWED',\n connectorStartCap: 'ROUND',\n connectorEndCap: 'ARROW_LINES',\n connectorControlPoints: [],\n connectorCurveHandles: null,\n connectorLabelPosition: null,\n isMask: false,\n maskType: 'ALPHA',\n maskIsOutline: false,\n gridTemplateColumns: [],\n gridTemplateRows: [],\n gridColumnGap: 0,\n gridRowGap: 0,\n gridPosition: null,\n counterAxisAlignContent: 'AUTO',\n itemReverseZIndex: false,\n strokesIncludedInLayout: false,\n expanded: true,\n textTruncation: 'DISABLED',\n autoRename: true,\n pointCount: 5,\n // Figma's: the golden-ratio star, whose inner points line up with its outer ones.\n starInnerRadius: (3 - Math.sqrt(5)) / 2,\n shapeWithTextType: 'SQUARE',\n shapeUserHeight: 0,\n shapeTruncates: false,\n componentId: null,\n instanceOverrides: createInstanceOverrideState(),\n componentPropertyDefinitions: [],\n componentPropertyReferences: [],\n componentPropertyAssignments: {},\n componentPropertyValues: {},\n componentKey: null,\n sourceLibraryKey: null,\n publishId: null,\n overrideKey: null,\n sharedSymbolVersion: null,\n publishedVersion: null,\n librarySource: null,\n libraryLayerId: null,\n isPublishable: false,\n isSymbolPublishable: false,\n isExposedInstance: false,\n symbolDescription: '',\n symbolLinks: [],\n variantPropSpecs: [],\n boundVariables: {},\n variableBindingScales: {},\n variableAssignmentScales: {},\n componentScale: 1,\n variableModes: {},\n exportSettings: [],\n status: null,\n pluginData: [],\n pluginRelaunchData: [],\n internalOnly: false,\n flipX: false,\n flipY: false,\n textPicture: null,\n derivedTextGlyphs: null,\n derivedTextHeight: null,\n textPathData: null,\n textPathBox: null,\n booleanOperation: undefined,\n ...overrides\n } satisfies CompleteNodeFields\n}\n\n/** Containers whose bounds follow their children and that set no coordinate space, as in Figma. */\nexport const FITTED_CONTAINER_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'GROUP',\n 'BOOLEAN_OPERATION'\n])\n\n/** Layers whose stroke can take a weight per side, as Figma's `strokeTopWeight` and its siblings. */\nexport const SIDE_STROKE_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'RECTANGLE',\n 'FRAME',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\n/** The kinds that hold layers of their own on the canvas: what a shadow or a clip encloses. */\nexport const LAYER_CONTAINER_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'FRAME',\n 'GROUP',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\nexport function isLayerContainer(node: Pick<SceneNode, 'type'>): boolean {\n return LAYER_CONTAINER_TYPES.has(node.type)\n}\n\nexport const CONTAINER_TYPES = new Set<NodeType>([\n 'CANVAS',\n 'FRAME',\n 'GROUP',\n 'BOOLEAN_OPERATION',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n"],"mappings":";;;;AAUA,SAAgB,8BAA8C;CAC5D,OAAO;EACL,QAAQ;EACR,IAAI;EACJ,UAAU;EACV,cAAc,CAAC;EACf,KAAK;GACH,SAAS;GACT,cAAc;GACd,eAAe,CAAC;GAChB,QAAQ;GACR,iBAAiB,CAAC;GAClB,0BAA0B,CAAC;GAC3B,mBAAmB,CAAC;GACpB,gCAAgC;GAChC,oBAAoB;EACtB;CACF;AACF;;AAUA,SAAgB,mBAAmB,MAA0C;CA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;EACf,gBAAgB;EAChB,eAAe;EACf,qBAAqB;EACrB,mBAAmB;EACnB,mBAAmB;EACnB,aAAa,CAAC;EACd,kBAAkB,CAAC;EACnB,gBAAgB,CAAC;EACjB,uBAAuB,CAAC;EACxB,0BAA0B,CAAC;EAC3B,gBAAgB;EAChB,eAAe,CAAC;EAChB,gBAAgB,CAAC;EACjB,QAAQ;EACR,YAAY,CAAC;EACb,oBAAoB,CAAC;EACrB,cAAc;EACd,OAAO;EACP,OAAO;EACP,aAAa;EACb,mBAAmB;EACnB,mBAAmB;EACnB,cAAc;EACd,aAAa;EACb,kBAAkB,KAAA;EAClB,GAAG;CACL;AACF;;AAGA,MAAa,yCAAgD,IAAI,IAAc,CAC7E,SACA,mBACF,CAAC;;AAGD,MAAa,oCAA2C,IAAI,IAAc;CACxE;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,wCAA+C,IAAI,IAAc;CAC5E;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,iBAAiB,MAAwC;CACvE,OAAO,sBAAsB,IAAI,KAAK,IAAI;AAC5C;AAEA,MAAa,kCAAkB,IAAI,IAAc;CAC/C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
@@ -4,6 +4,8 @@
4
4
  * comparison, as Figma writes `parentIndex.position`. A new key fits between two neighbours
5
5
  * without renumbering the others.
6
6
  */
7
+ /** Sorts order keys as Figma does: by plain string comparison. */
8
+ declare function compareOrderKeys(a: string, b: string): number;
7
9
  /** The order key for position `index` of a freshly numbered sibling list. */
8
10
  declare function fractionalPosition(index: number): string;
9
11
  /**
@@ -35,5 +37,5 @@ interface SiblingOrderKeyOptions {
35
37
  */
36
38
  declare function siblingOrderKeys(sourceKeys: ReadonlyArray<string | null | undefined>, options?: SiblingOrderKeyOptions): string[];
37
39
  //#endregion
38
- export { SiblingOrderKeyOptions, fractionalPosition, hasOrderKeyBetween, orderKeyBetween, siblingOrderKeys };
40
+ export { SiblingOrderKeyOptions, compareOrderKeys, fractionalPosition, hasOrderKeyBetween, orderKeyBetween, siblingOrderKeys };
39
41
  //# sourceMappingURL=order-keys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"order-keys.d.ts","names":[],"sources":["../src/order-keys.ts"],"mappings":";;;;;;;iBAYgB,mBAAmB;;;;;;;;;;;;iBAoDnB,gBAAgB,mBAAmB,mBAAmB;;iBAStD,mBAAmB,mBAAmB;UA4BrC;;;;;EAKf;;;;;;;;iBASc,iBACd,YAAY,0CACZ,UAAS"}
1
+ {"version":3,"file":"order-keys.d.ts","names":[],"sources":["../src/order-keys.ts"],"mappings":";;;;;;;iBAYgB,iBAAiB,WAAW;;iBAM5B,mBAAmB;;;;;;;;;;;;iBAoDnB,gBAAgB,mBAAmB,mBAAmB;;iBAStD,mBAAmB,mBAAmB;UA4BrC;;;;;EAKf;;;;;;;;iBASc,iBACd,YAAY,0CACZ,UAAS"}
@@ -8,6 +8,11 @@ const ORDER_KEY_MIN = 33;
8
8
  const ORDER_KEY_MAX = 126;
9
9
  const ORDER_KEY_MID = "O";
10
10
  const INDEX_KEY_BASE = 94;
11
+ /** Sorts order keys as Figma does: by plain string comparison. */
12
+ function compareOrderKeys(a, b) {
13
+ if (a === b) return 0;
14
+ return a < b ? -1 : 1;
15
+ }
11
16
  /** The order key for position `index` of a freshly numbered sibling list. */
12
17
  function fractionalPosition(index) {
13
18
  const numTildes = Math.floor(index / INDEX_KEY_BASE);
@@ -131,6 +136,6 @@ function siblingOrderKeys(sourceKeys, options = {}) {
131
136
  return keys;
132
137
  }
133
138
  //#endregion
134
- export { fractionalPosition, hasOrderKeyBetween, orderKeyBetween, siblingOrderKeys };
139
+ export { compareOrderKeys, fractionalPosition, hasOrderKeyBetween, orderKeyBetween, siblingOrderKeys };
135
140
 
136
141
  //# sourceMappingURL=order-keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"order-keys.js","names":[],"sources":["../src/order-keys.ts"],"sourcesContent":["/**\n * Fractional order keys: printable-ASCII strings (`!` to `~`) that order siblings by plain string\n * comparison, as Figma writes `parentIndex.position`. A new key fits between two neighbours\n * without renumbering the others.\n */\n\nconst ORDER_KEY_MIN = 33 // '!'\nconst ORDER_KEY_MAX = 126 // '~'\nconst ORDER_KEY_MID = 'O'\nconst INDEX_KEY_BASE = ORDER_KEY_MAX - ORDER_KEY_MIN + 1\n\n/** The order key for position `index` of a freshly numbered sibling list. */\nexport function fractionalPosition(index: number): string {\n const numTildes = Math.floor(index / INDEX_KEY_BASE)\n const lastChar = String.fromCharCode(ORDER_KEY_MIN + (index % INDEX_KEY_BASE))\n return String.fromCharCode(ORDER_KEY_MAX).repeat(numTildes) + lastChar\n}\n\n/**\n * The shortest key strictly between `lo` and `hi` (either may be open), or null when the\n * printable alphabet has none. Splits at the first character where they differ when a character\n * fits between; otherwise keeps that character and recurses into the remainder.\n */\nfunction keyBetween(lo: string | null, hi: string | null): string | null {\n if (lo !== null && hi !== null && lo >= hi) return null\n const low = lo ?? ''\n // An open upper bound shares no prefix, so the empty string ends the scan immediately.\n const high = hi ?? ''\n let i = 0\n while (i < low.length && i < high.length && low[i] === high[i]) i++\n const a = i < low.length ? low.charCodeAt(i) : ORDER_KEY_MIN - 1\n const b = hi !== null && i < hi.length ? hi.charCodeAt(i) : ORDER_KEY_MAX + 1\n if (b - a > 1) return low.slice(0, i) + String.fromCharCode(Math.floor((a + b) / 2))\n // Keep lo's character: anything above the rest of lo then sorts below hi.\n if (i < low.length) {\n return low.slice(0, i + 1) + (keyBetween(low.slice(i + 1), null) ?? ORDER_KEY_MID)\n }\n // lo is a prefix of hi whose next character can't be lowered: keep it and go below the rest.\n const rest = hi?.slice(i + 1) ?? ''\n if (!hi || rest === '') return null\n return hi.slice(0, i + 1) + (keyBetween(null, rest) ?? '')\n}\n\n/** A key above `lo` that has room for `suffix` while staying below `hi`, or null. */\nfunction keyWithSuffix(lo: string | null, hi: string, suffix: string): string | null {\n // A key that is a prefix of hi leaves no room after it; go one level deeper until it is not.\n for (let key = keyBetween(lo, hi); key !== null; key = keyBetween(key, hi)) {\n if (key + suffix < hi) return key + suffix\n if (!hi.startsWith(key)) return null\n }\n return null\n}\n\n/**\n * A key above `lo` and below `hi`; either bound may be open.\n *\n * `suffix`, a few random printable characters, is appended where it fits, so two peers that\n * insert at the same spot at once get distinct keys with room between them. The key stays short:\n * it grows by about one character for every five keys inserted into the same gap.\n *\n * Every pair of bounds gets a key. When no printable key sorts between them, because `lo` is not\n * below `hi` or `hi` is `lo` followed only by `!`, the result is the key `orderKeyBetween(lo, null)`\n * gives, which is above `lo` but not below `hi`, and the caller must re-key `hi`.\n */\nexport function orderKeyBetween(lo: string | null, hi: string | null, suffix = ''): string {\n const key = keyBetween(lo, hi)\n if (key === null) return (keyBetween(lo, null) ?? ORDER_KEY_MID) + suffix\n if (!suffix) return key\n if (hi === null) return key + suffix\n return keyWithSuffix(lo, hi, suffix) ?? key\n}\n\n/** Whether some printable key sorts strictly between `lo` and `hi`. */\nexport function hasOrderKeyBetween(lo: string | null, hi: string | null): boolean {\n return keyBetween(lo, hi) !== null\n}\n\n/** Indices of the longest strictly increasing run of keys, so a moved layer re-keys alone. */\nfunction increasingKeyIndices(sourceKeys: ReadonlyArray<string | null | undefined>): Set<number> {\n const tails: number[] = []\n const previous = new Map<number, number>()\n for (let index = 0; index < sourceKeys.length; index++) {\n const key = sourceKeys[index]\n if (!key) continue\n let low = 0\n let high = tails.length\n while (low < high) {\n const mid = (low + high) >> 1\n if ((sourceKeys[tails[mid]] ?? '') < key) low = mid + 1\n else high = mid\n }\n // A key with nothing below it cannot start the run once a sibling has to precede it.\n if (low === 0 && index > 0 && !hasOrderKeyBetween(null, key)) continue\n if (low > 0) previous.set(index, tails[low - 1])\n tails[low] = index\n }\n const kept = new Set<number>()\n for (let index = tails.at(-1); index !== undefined; index = previous.get(index)) kept.add(index)\n return kept\n}\n\nexport interface SiblingOrderKeyOptions {\n /**\n * Returns a suffix for each key the function makes up, as `orderKeyBetween` takes. Without it,\n * a sibling that needs a key gets its index key when that fits between its neighbours.\n */\n suffix?: () => string\n}\n\n/**\n * Order keys for siblings in their current order. The longest increasing run of existing keys\n * is kept; other siblings get the index key when it fits between their neighbours (or a key with\n * a suffix, when `options.suffix` is given), and otherwise a key between them, so no two siblings\n * share a key.\n */\nexport function siblingOrderKeys(\n sourceKeys: ReadonlyArray<string | null | undefined>,\n options: SiblingOrderKeyOptions = {}\n): string[] {\n const keys: string[] = []\n let prev: string | null = null\n let pending: number[] = []\n\n const nextKey = (index: number, lo: string | null, upper: string | null): string | null => {\n if (options.suffix) {\n const key = orderKeyBetween(lo, upper, options.suffix())\n return upper === null || key < upper ? key : null\n }\n const candidate = fractionalPosition(index)\n if ((lo === null || candidate > lo) && (upper === null || candidate < upper)) return candidate\n return keyBetween(lo, upper)\n }\n\n const fill = (upper: string | null): string[] | null => {\n const filled: string[] = []\n let lo = prev\n for (const index of pending) {\n const key = nextKey(index, lo, upper)\n if (key === null) return null\n filled.push(key)\n lo = key\n }\n return filled\n }\n\n const kept = increasingKeyIndices(sourceKeys)\n for (let index = 0; index < sourceKeys.length; index++) {\n const key = sourceKeys[index]\n const filled = key && kept.has(index) ? fill(key) : null\n if (key && filled) {\n pending.forEach((pendingIndex, i) => (keys[pendingIndex] = filled[i]))\n keys[index] = key\n prev = key\n pending = []\n } else {\n pending.push(index)\n }\n }\n const rest = fill(null) ?? []\n pending.forEach((pendingIndex, i) => (keys[pendingIndex] = rest[i]))\n return keys\n}\n"],"mappings":";;;;;;AAMA,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;;AAGvB,SAAgB,mBAAmB,OAAuB;CACxD,MAAM,YAAY,KAAK,MAAM,QAAQ,cAAc;CACnD,MAAM,WAAW,OAAO,aAAa,gBAAiB,QAAQ,cAAe;CAC7E,OAAO,OAAO,aAAa,aAAa,CAAC,CAAC,OAAO,SAAS,IAAI;AAChE;;;;;;AAOA,SAAS,WAAW,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AAK;CAC7B;CAEA,MAAM,QAAQ,UAA0C;EACtD,MAAM,SAAmB,CAAC;EAC1B,IAAI,KAAK;EACT,KAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,MAAM,QAAQ,OAAO,IAAI,KAAK;GACpC,IAAI,QAAQ,MAAM,OAAO;GACzB,OAAO,KAAK,GAAG;GACf,KAAK;EACP;EACA,OAAO;CACT;CAEA,MAAM,OAAO,qBAAqB,UAAU;CAC5C,KAAK,IAAI,QAAQ,GAAG,QAAQ,WAAW,QAAQ,SAAS;EACtD,MAAM,MAAM,WAAW;EACvB,MAAM,SAAS,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,IAAI;EACpD,IAAI,OAAO,QAAQ;GACjB,QAAQ,SAAS,cAAc,MAAO,KAAK,gBAAgB,OAAO,EAAG;GACrE,KAAK,SAAS;GACd,OAAO;GACP,UAAU,CAAC;EACb,OACE,QAAQ,KAAK,KAAK;CAEtB;CACA,MAAM,OAAO,KAAK,IAAI,KAAK,CAAC;CAC5B,QAAQ,SAAS,cAAc,MAAO,KAAK,gBAAgB,KAAK,EAAG;CACnE,OAAO;AACT"}
1
+ {"version":3,"file":"order-keys.js","names":[],"sources":["../src/order-keys.ts"],"sourcesContent":["/**\n * Fractional order keys: printable-ASCII strings (`!` to `~`) that order siblings by plain string\n * comparison, as Figma writes `parentIndex.position`. A new key fits between two neighbours\n * without renumbering the others.\n */\n\nconst ORDER_KEY_MIN = 33 // '!'\nconst ORDER_KEY_MAX = 126 // '~'\nconst ORDER_KEY_MID = 'O'\nconst INDEX_KEY_BASE = ORDER_KEY_MAX - ORDER_KEY_MIN + 1\n\n/** Sorts order keys as Figma does: by plain string comparison. */\nexport function compareOrderKeys(a: string, b: string): number {\n if (a === b) return 0\n return a < b ? -1 : 1\n}\n\n/** The order key for position `index` of a freshly numbered sibling list. */\nexport function fractionalPosition(index: number): string {\n const numTildes = Math.floor(index / INDEX_KEY_BASE)\n const lastChar = String.fromCharCode(ORDER_KEY_MIN + (index % INDEX_KEY_BASE))\n return String.fromCharCode(ORDER_KEY_MAX).repeat(numTildes) + lastChar\n}\n\n/**\n * The shortest key strictly between `lo` and `hi` (either may be open), or null when the\n * printable alphabet has none. Splits at the first character where they differ when a character\n * fits between; otherwise keeps that character and recurses into the remainder.\n */\nfunction keyBetween(lo: string | null, hi: string | null): string | null {\n if (lo !== null && hi !== null && lo >= hi) return null\n const low = lo ?? ''\n // An open upper bound shares no prefix, so the empty string ends the scan immediately.\n const high = hi ?? ''\n let i = 0\n while (i < low.length && i < high.length && low[i] === high[i]) i++\n const a = i < low.length ? low.charCodeAt(i) : ORDER_KEY_MIN - 1\n const b = hi !== null && i < hi.length ? hi.charCodeAt(i) : ORDER_KEY_MAX + 1\n if (b - a > 1) return low.slice(0, i) + String.fromCharCode(Math.floor((a + b) / 2))\n // Keep lo's character: anything above the rest of lo then sorts below hi.\n if (i < low.length) {\n return low.slice(0, i + 1) + (keyBetween(low.slice(i + 1), null) ?? ORDER_KEY_MID)\n }\n // lo is a prefix of hi whose next character can't be lowered: keep it and go below the rest.\n const rest = hi?.slice(i + 1) ?? ''\n if (!hi || rest === '') return null\n return hi.slice(0, i + 1) + (keyBetween(null, rest) ?? '')\n}\n\n/** A key above `lo` that has room for `suffix` while staying below `hi`, or null. */\nfunction keyWithSuffix(lo: string | null, hi: string, suffix: string): string | null {\n // A key that is a prefix of hi leaves no room after it; go one level deeper until it is not.\n for (let key = keyBetween(lo, hi); key !== null; key = keyBetween(key, hi)) {\n if (key + suffix < hi) return key + suffix\n if (!hi.startsWith(key)) return null\n }\n return null\n}\n\n/**\n * A key above `lo` and below `hi`; either bound may be open.\n *\n * `suffix`, a few random printable characters, is appended where it fits, so two peers that\n * insert at the same spot at once get distinct keys with room between them. The key stays short:\n * it grows by about one character for every five keys inserted into the same gap.\n *\n * Every pair of bounds gets a key. When no printable key sorts between them, because `lo` is not\n * below `hi` or `hi` is `lo` followed only by `!`, the result is the key `orderKeyBetween(lo, null)`\n * gives, which is above `lo` but not below `hi`, and the caller must re-key `hi`.\n */\nexport function orderKeyBetween(lo: string | null, hi: string | null, suffix = ''): string {\n const key = keyBetween(lo, hi)\n if (key === null) return (keyBetween(lo, null) ?? ORDER_KEY_MID) + suffix\n if (!suffix) return key\n if (hi === null) return key + suffix\n return keyWithSuffix(lo, hi, suffix) ?? key\n}\n\n/** Whether some printable key sorts strictly between `lo` and `hi`. */\nexport function hasOrderKeyBetween(lo: string | null, hi: string | null): boolean {\n return keyBetween(lo, hi) !== null\n}\n\n/** Indices of the longest strictly increasing run of keys, so a moved layer re-keys alone. */\nfunction increasingKeyIndices(sourceKeys: ReadonlyArray<string | null | undefined>): Set<number> {\n const tails: number[] = []\n const previous = new Map<number, number>()\n for (let index = 0; index < sourceKeys.length; index++) {\n const key = sourceKeys[index]\n if (!key) continue\n let low = 0\n let high = tails.length\n while (low < high) {\n const mid = (low + high) >> 1\n if ((sourceKeys[tails[mid]] ?? '') < key) low = mid + 1\n else high = mid\n }\n // A key with nothing below it cannot start the run once a sibling has to precede it.\n if (low === 0 && index > 0 && !hasOrderKeyBetween(null, key)) continue\n if (low > 0) previous.set(index, tails[low - 1])\n tails[low] = index\n }\n const kept = new Set<number>()\n for (let index = tails.at(-1); index !== undefined; index = previous.get(index)) kept.add(index)\n return kept\n}\n\nexport interface SiblingOrderKeyOptions {\n /**\n * Returns a suffix for each key the function makes up, as `orderKeyBetween` takes. Without it,\n * a sibling that needs a key gets its index key when that fits between its neighbours.\n */\n suffix?: () => string\n}\n\n/**\n * Order keys for siblings in their current order. The longest increasing run of existing keys\n * is kept; other siblings get the index key when it fits between their neighbours (or a key with\n * a suffix, when `options.suffix` is given), and otherwise a key between them, so no two siblings\n * share a key.\n */\nexport function siblingOrderKeys(\n sourceKeys: ReadonlyArray<string | null | undefined>,\n options: SiblingOrderKeyOptions = {}\n): string[] {\n const keys: string[] = []\n let prev: string | null = null\n let pending: number[] = []\n\n const nextKey = (index: number, lo: string | null, upper: string | null): string | null => {\n if (options.suffix) {\n const key = orderKeyBetween(lo, upper, options.suffix())\n return upper === null || key < upper ? key : null\n }\n const candidate = fractionalPosition(index)\n if ((lo === null || candidate > lo) && (upper === null || candidate < upper)) return candidate\n return keyBetween(lo, upper)\n }\n\n const fill = (upper: string | null): string[] | null => {\n const filled: string[] = []\n let lo = prev\n for (const index of pending) {\n const key = nextKey(index, lo, upper)\n if (key === null) return null\n filled.push(key)\n lo = key\n }\n return filled\n }\n\n const kept = increasingKeyIndices(sourceKeys)\n for (let index = 0; index < sourceKeys.length; index++) {\n const key = sourceKeys[index]\n const filled = key && kept.has(index) ? fill(key) : null\n if (key && filled) {\n pending.forEach((pendingIndex, i) => (keys[pendingIndex] = filled[i]))\n keys[index] = key\n prev = key\n pending = []\n } else {\n pending.push(index)\n }\n }\n const rest = fill(null) ?? []\n pending.forEach((pendingIndex, i) => (keys[pendingIndex] = rest[i]))\n return keys\n}\n"],"mappings":";;;;;;AAMA,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;;AAGvB,SAAgB,iBAAiB,GAAW,GAAmB;CAC7D,IAAI,MAAM,GAAG,OAAO;CACpB,OAAO,IAAI,IAAI,KAAK;AACtB;;AAGA,SAAgB,mBAAmB,OAAuB;CACxD,MAAM,YAAY,KAAK,MAAM,QAAQ,cAAc;CACnD,MAAM,WAAW,OAAO,aAAa,gBAAiB,QAAQ,cAAe;CAC7E,OAAO,OAAO,aAAa,aAAa,CAAC,CAAC,OAAO,SAAS,IAAI;AAChE;;;;;;AAOA,SAAS,WAAW,IAAmB,IAAkC;CACvE,IAAI,OAAO,QAAQ,OAAO,QAAQ,MAAM,IAAI,OAAO;CACnD,MAAM,MAAM,MAAM;CAElB,MAAM,OAAO,MAAM;CACnB,IAAI,IAAI;CACR,OAAO,IAAI,IAAI,UAAU,IAAI,KAAK,UAAU,IAAI,OAAO,KAAK,IAAI;CAChE,MAAM,IAAI,IAAI,IAAI,SAAS,I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EA,MAAM,OAAO,qBAAqB,UAAU;CAC5C,KAAK,IAAI,QAAQ,GAAG,QAAQ,WAAW,QAAQ,SAAS;EACtD,MAAM,MAAM,WAAW;EACvB,MAAM,SAAS,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,IAAI;EACpD,IAAI,OAAO,QAAQ;GACjB,QAAQ,SAAS,cAAc,MAAO,KAAK,gBAAgB,OAAO,EAAG;GACrE,KAAK,SAAS;GACd,OAAO;GACP,UAAU,CAAC;EACb,OACE,QAAQ,KAAK,KAAK;CAEtB;CACA,MAAM,OAAO,KAAK,IAAI,KAAK,CAAC;CAC5B,QAAQ,SAAS,cAAc,MAAO,KAAK,gBAAgB,KAAK,EAAG;CACnE,OAAO;AACT"}
@@ -33,6 +33,8 @@ declare const OPEN_PENCIL_PLUGIN_DATA: {
33
33
  textPathBox: PluginDataField<Rect>;
34
34
  /** The library asset a node was inserted from. */
35
35
  librarySource: PluginDataField<LibraryAssetSource>;
36
+ /** The library source layer a library definition's layer copies, on every definition layer. */
37
+ libraryLayer: PluginDataField<string>;
36
38
  /**
37
39
  * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the
38
40
  * root keeps it across a save as every layer keeps its GUID.
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","names":[],"sources":["../../src/plugin-data/fields.ts"],"mappings":";;;;;;;UAsHiB;EACf,OAAO;EACP,cAAc;IAAiB;IAAa;;;;;;;;cAuCjC;;iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0EG,kBAAkB,kBAAkB,oBAAoB"}
1
+ {"version":3,"file":"fields.d.ts","names":[],"sources":["../../src/plugin-data/fields.ts"],"mappings":";;;;;;;UAsHiB;EACf,OAAO;EACP,cAAc;IAAiB;IAAa;;;;;;;;cAuCjC;;iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgFG,kBAAkB,kBAAkB,oBAAoB"}
@@ -119,6 +119,8 @@ const OPEN_PENCIL_PLUGIN_DATA = {
119
119
  textPathBox: jsonPluginDataField("textPathBox", "format", textPathBoxSchema),
120
120
  /** The library asset a node was inserted from. */
121
121
  librarySource: jsonPluginDataField("librarySource", "bookkeeping", librarySourceSchema),
122
+ /** The library source layer a library definition's layer copies, on every definition layer. */
123
+ libraryLayer: jsonPluginDataField("libraryLayer", "bookkeeping", v.pipe(v.string(), v.nonEmpty(), v.maxLength(1024))),
122
124
  /**
123
125
  * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the
124
126
  * root keeps it across a save as every layer keeps its GUID.
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","names":[],"sources":["../../src/plugin-data/fields.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { behaviourSchema } from '../behaviours/schema'\nimport type { OkHCLPayload } from '../color/okhcl'\nimport { commentThreadsSchema } from '../comments/schema'\nimport { isExportFormatId, type ExportFormatId } from '../export-format'\nimport { clampExportScale } from '../export-scale'\nimport { FIG_COMPRESSIONS } from '../fig-compression'\nimport { iconSchema, iconTintSchema } from '../icons/schema'\nimport type { Rect } from '../primitives'\nimport { shaderPaintSchema } from '../shaders/schema'\nimport { nodeStatusSchema, statusWorkflowSchema } from '../statuses/schema'\nimport {\n MODE_ATTRIBUTE_PATTERN,\n TOKEN_UNITS,\n type EnabledLibraryBinding,\n type ExportSetting,\n type LayoutDirection,\n type LibraryAssetSource,\n type PluginDataEntry,\n type SourceLibraryPublication,\n type TextDirection,\n type TokenUnit\n} from '../types'\nimport {\n jsonPluginDataField,\n textPluginDataField,\n withoutPluginData,\n type PluginDataKey\n} from './field'\n\nconst DIRECTIONS = ['AUTO', 'LTR', 'RTL'] as const satisfies readonly (\n | TextDirection\n | LayoutDirection\n)[]\n\nconst textPathBoxSchema: v.GenericSchema<unknown, Rect> = v.pipe(\n v.object({ x: v.number(), y: v.number(), width: v.number(), height: v.number() }),\n v.check(\n ({ x, y, width, height }) => Number.isFinite(x + y + width + height) && width > 0 && height > 0\n )\n)\n\n/** String-valued entries of a JSON object; other entries are dropped, not rejected. */\nconst boundVariablesSchema = v.pipe(\n v.custom<Record<string, unknown>>(\n (value) => typeof value === 'object' && value !== null && !Array.isArray(value)\n ),\n v.transform((value) =>\n Object.fromEntries(\n Object.entries(value).filter(\n (entry): entry is [string, string] => typeof entry[1] === 'string'\n )\n )\n )\n)\n\n/** Every entry must be valid, or the whole value is ignored in favour of native settings. */\nconst exportSettingsSchema: v.GenericSchema<unknown, ExportSetting[]> = v.array(\n v.pipe(\n v.object({\n scale: v.pipe(v.number(), v.finite()),\n format: v.custom<ExportFormatId>(isExportFormatId),\n suffix: v.optional(v.string()),\n size: v.optional(\n v.object({\n type: v.picklist(['WIDTH', 'HEIGHT']),\n value: v.pipe(v.number(), v.finite())\n })\n ),\n contentsOnly: v.optional(v.boolean()),\n useAbsoluteBounds: v.optional(v.boolean()),\n colorProfile: v.optional(v.picklist(['DOCUMENT', 'SRGB', 'DISPLAY_P3_V4'])),\n svgOutlineText: v.optional(v.boolean()),\n svgIdAttribute: v.optional(v.boolean()),\n svgSimplifyStroke: v.optional(v.boolean())\n }),\n // Clamp at the file boundary: imported plugin data may carry a scale the UI never produces.\n v.transform((setting) => ({ ...setting, scale: clampExportScale(setting.scale) }))\n )\n)\n\nconst librarySourceSchema: v.GenericSchema<unknown, LibraryAssetSource> = v.pipe(\n v.object({\n identity: v.object({ libraryId: v.string(), assetKey: v.string(), revisionId: v.string() }),\n sourceNodeId: v.optional(v.unknown()),\n readOnly: v.optional(v.unknown())\n }),\n v.transform(({ identity, sourceNodeId, readOnly }) => ({\n identity,\n sourceNodeId: typeof sourceNodeId === 'string' ? sourceNodeId : null,\n readOnly: readOnly === true\n }))\n)\n\nconst enabledLibrarySchema = v.object({\n libraryId: v.string(),\n revisionId: v.string(),\n enabled: v.optional(v.unknown())\n})\n\n/** Invalid entries are skipped one by one, so one bad binding keeps the others. */\nconst enabledLibrariesSchema: v.GenericSchema<unknown, EnabledLibraryBinding[]> = v.pipe(\n v.array(v.unknown()),\n v.transform((items) =>\n items.flatMap((item) => {\n const parsed = v.safeParse(enabledLibrarySchema, item)\n if (!parsed.success) return []\n const { libraryId, revisionId, enabled } = parsed.output\n return [{ libraryId, revisionId, enabled: enabled === true }]\n })\n )\n)\n\n// Shape only. Whether a string is valid CSS is checked where it is written into a stylesheet.\nconst cssTextSchema = v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(1000))\n\n/** Token fields Figma has no slot for, with mode ids as the file spells them. */\nexport interface StoredToken {\n unit?: TokenUnit\n expressions?: Record<string, { css: string; resolved?: number }>\n}\n\nconst tokenSchema: v.GenericSchema<unknown, StoredToken> = v.object({\n unit: v.optional(v.picklist(TOKEN_UNITS)),\n expressions: v.optional(\n v.record(\n v.string(),\n v.object({ css: cssTextSchema, resolved: v.optional(v.pipe(v.number(), v.finite())) })\n )\n )\n})\n\nconst okhclSchema: v.GenericSchema<unknown, OkHCLPayload> = v.object({\n version: v.literal(1),\n kind: v.picklist(['fill', 'stroke']),\n index: v.number(),\n color: v.object({\n h: v.number(),\n c: v.number(),\n l: v.number(),\n a: v.fallback(v.optional(v.number()), undefined)\n })\n})\n\nconst sourceLibraryPublicationSchema: v.GenericSchema<unknown, SourceLibraryPublication> = v.object(\n {\n libraryId: v.string(),\n revisionId: v.string(),\n name: v.string(),\n catalogSource: v.optional(v.string())\n }\n)\n\n/**\n * Every plugin-data entry OpenPencil writes under {@link OPEN_PENCIL_PLUGIN_ID}: state Figma's\n * format has no field for. Add a key here, never as a string elsewhere, so reading and writing\n * it share one schema.\n */\nexport const OPEN_PENCIL_PLUGIN_DATA = {\n /** A text node's direction, on TEXT nodes. */\n textDirection: textPluginDataField('textDirection', 'format', DIRECTIONS),\n /** An auto-layout frame's direction. */\n layoutDirection: textPluginDataField('layoutDirection', 'format', DIRECTIONS),\n /** Marks a component set Figma would read as a plain frame. */\n nodeType: textPluginDataField('nodeType', 'format', ['COMPONENT_SET']),\n /** Variable bindings by field path, including those Figma cannot store natively. */\n boundVariables: jsonPluginDataField('boundVariables', 'format', boundVariablesSchema),\n exportSettings: jsonPluginDataField('exportSettings', 'format', exportSettingsSchema),\n /** The node-local rect a TEXT_PATH layout maps onto, which Kiwi has no field for. */\n textPathBox: jsonPluginDataField('textPathBox', 'format', textPathBoxSchema),\n /** The library asset a node was inserted from. */\n librarySource: jsonPluginDataField('librarySource', 'bookkeeping', librarySourceSchema),\n /**\n * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the\n * root keeps it across a save as every layer keeps its GUID.\n */\n documentId: jsonPluginDataField(\n 'documentId',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))\n ),\n /** Libraries enabled for the document, on the DOCUMENT node. */\n enabledLibraries: jsonPluginDataField('enabledLibraries', 'bookkeeping', enabledLibrariesSchema),\n /** The library this document publishes as, on the DOCUMENT node. */\n sourceLibraryPublication: jsonPluginDataField(\n 'sourceLibraryPublication',\n 'bookkeeping',\n sourceLibraryPublicationSchema\n ),\n /** Canvas comment threads, deleted ones included, on the DOCUMENT node. */\n comments: jsonPluginDataField('comments', 'bookkeeping', commentThreadsSchema),\n /** The statuses layers can be in, on the DOCUMENT node. */\n statuses: jsonPluginDataField('statuses', 'bookkeeping', statusWorkflowSchema),\n /** How tightly the document's `.fig` data is compressed, on the DOCUMENT node. */\n figCompression: textPluginDataField('figCompression', 'bookkeeping', FIG_COMPRESSIONS),\n /** A layer's status, any state of the workflow; Figma's `sectionStatusInfo` knows only two. */\n status: jsonPluginDataField('status', 'format', nodeStatusSchema),\n /** Unit and CSS expressions, on each VARIABLE. */\n token: jsonPluginDataField('token', 'format', tokenSchema),\n /** Mode conditions by mode id, on each VARIABLE_SET. */\n modeConditions: jsonPluginDataField(\n 'modeConditions',\n 'format',\n v.record(v.string(), cssTextSchema)\n ),\n /** The attribute that switches manual modes, on each VARIABLE_SET. */\n modeAttribute: jsonPluginDataField(\n 'modeAttribute',\n 'format',\n v.pipe(v.string(), v.trim(), v.maxLength(100), v.regex(MODE_ATTRIBUTE_PATTERN))\n ),\n /** One entry per paint picked in OkHCL, so the picker reopens on the same coordinates. */\n okhcl: jsonPluginDataField('okhcl', 'content', okhclSchema),\n /** How a main component or component set behaves as a control in preview. */\n behaviour: jsonPluginDataField('behaviour', 'content', behaviourSchema),\n /** The icon a frame draws, such as `lucide:home`, on the frame its paths are in. */\n icon: jsonPluginDataField('icon', 'content', iconSchema),\n /** Which of an icon path's paints its icon's color sets, on each path the source drew in it. */\n iconTint: jsonPluginDataField('iconTint', 'content', iconTintSchema),\n /** One entry per paint that draws a shader, matched to its image paint by the frame's hash. */\n shader: jsonPluginDataField('shader', 'content', shaderPaintSchema)\n} satisfies Record<string, PluginDataKey>\n\nconst NOT_CONTENT = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter(\n (field) => field.role !== 'content'\n)\n\n/**\n * A node's plugin data that is part of its content, in a stable order: OpenPencil's content\n * fields and every other plugin's entries, which the node carries wherever it goes. Format\n * copies of node fields and bookkeeping are left out.\n */\nexport function contentPluginData(entries: readonly PluginDataEntry[]): PluginDataEntry[] {\n return withoutPluginData(entries, NOT_CONTENT).sort(\n (a, b) => a.pluginId.localeCompare(b.pluginId) || a.key.localeCompare(b.key)\n )\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,MAAM,aAAa;CAAC;CAAQ;CAAO;AAAK;AAKxC,MAAM,oBAAoD,EAAE,KAC1D,EAAE,OAAO;CAAE,GAAG,EAAE,OAAO;CAAG,GAAG,EAAE,OAAO;CAAG,OAAO,EAAE,OAAO;CAAG,QAAQ,EAAE,OAAO;AAAE,CAAC,GAChF,EAAE,OACC,EA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AG,EAAE,UAAU,GAAG,GAAG,EAAE,MAAM,sBAAsB,CAAC,CAChF;;CAEA,OAAO,oBAAoB,SAAS,WAAW,WAAW;;CAE1D,WAAW,oBAAoB,aAAa,WAAW,eAAe;;CAEtE,MAAM,oBAAoB,QAAQ,WAAW,UAAU;;CAEvD,UAAU,oBAAoB,YAAY,WAAW,cAAc;;CAEnE,QAAQ,oBAAoB,UAAU,WAAW,iBAAiB;AACpE;AAEA,MAAM,cAAc,OAAO,OAAO,uBAAuB,CAAC,CAAC,QACxD,UAAU,MAAM,SAAS,SAC5B;;;;;;AAOA,SAAgB,kBAAkB,SAAwD;CACxF,OAAO,kBAAkB,SAAS,WAAW,CAAC,CAAC,MAC5C,GAAG,MAAM,EAAE,SAAS,cAAc,EAAE,QAAQ,KAAK,EAAE,IAAI,cAAc,EAAE,GAAG,CAC7E;AACF"}
1
+ {"version":3,"file":"fields.js","names":[],"sources":["../../src/plugin-data/fields.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { behaviourSchema } from '../behaviours/schema'\nimport type { OkHCLPayload } from '../color/okhcl'\nimport { commentThreadsSchema } from '../comments/schema'\nimport { isExportFormatId, type ExportFormatId } from '../export-format'\nimport { clampExportScale } from '../export-scale'\nimport { FIG_COMPRESSIONS } from '../fig-compression'\nimport { iconSchema, iconTintSchema } from '../icons/schema'\nimport type { Rect } from '../primitives'\nimport { shaderPaintSchema } from '../shaders/schema'\nimport { nodeStatusSchema, statusWorkflowSchema } from '../statuses/schema'\nimport {\n MODE_ATTRIBUTE_PATTERN,\n TOKEN_UNITS,\n type EnabledLibraryBinding,\n type ExportSetting,\n type LayoutDirection,\n type LibraryAssetSource,\n type PluginDataEntry,\n type SourceLibraryPublication,\n type TextDirection,\n type TokenUnit\n} from '../types'\nimport {\n jsonPluginDataField,\n textPluginDataField,\n withoutPluginData,\n type PluginDataKey\n} from './field'\n\nconst DIRECTIONS = ['AUTO', 'LTR', 'RTL'] as const satisfies readonly (\n | TextDirection\n | LayoutDirection\n)[]\n\nconst textPathBoxSchema: v.GenericSchema<unknown, Rect> = v.pipe(\n v.object({ x: v.number(), y: v.number(), width: v.number(), height: v.number() }),\n v.check(\n ({ x, y, width, height }) => Number.isFinite(x + y + width + height) && width > 0 && height > 0\n )\n)\n\n/** String-valued entries of a JSON object; other entries are dropped, not rejected. */\nconst boundVariablesSchema = v.pipe(\n v.custom<Record<string, unknown>>(\n (value) => typeof value === 'object' && value !== null && !Array.isArray(value)\n ),\n v.transform((value) =>\n Object.fromEntries(\n Object.entries(value).filter(\n (entry): entry is [string, string] => typeof entry[1] === 'string'\n )\n )\n )\n)\n\n/** Every entry must be valid, or the whole value is ignored in favour of native settings. */\nconst exportSettingsSchema: v.GenericSchema<unknown, ExportSetting[]> = v.array(\n v.pipe(\n v.object({\n scale: v.pipe(v.number(), v.finite()),\n format: v.custom<ExportFormatId>(isExportFormatId),\n suffix: v.optional(v.string()),\n size: v.optional(\n v.object({\n type: v.picklist(['WIDTH', 'HEIGHT']),\n value: v.pipe(v.number(), v.finite())\n })\n ),\n contentsOnly: v.optional(v.boolean()),\n useAbsoluteBounds: v.optional(v.boolean()),\n colorProfile: v.optional(v.picklist(['DOCUMENT', 'SRGB', 'DISPLAY_P3_V4'])),\n svgOutlineText: v.optional(v.boolean()),\n svgIdAttribute: v.optional(v.boolean()),\n svgSimplifyStroke: v.optional(v.boolean())\n }),\n // Clamp at the file boundary: imported plugin data may carry a scale the UI never produces.\n v.transform((setting) => ({ ...setting, scale: clampExportScale(setting.scale) }))\n )\n)\n\nconst librarySourceSchema: v.GenericSchema<unknown, LibraryAssetSource> = v.pipe(\n v.object({\n identity: v.object({ libraryId: v.string(), assetKey: v.string(), revisionId: v.string() }),\n sourceNodeId: v.optional(v.unknown()),\n readOnly: v.optional(v.unknown())\n }),\n v.transform(({ identity, sourceNodeId, readOnly }) => ({\n identity,\n sourceNodeId: typeof sourceNodeId === 'string' ? sourceNodeId : null,\n readOnly: readOnly === true\n }))\n)\n\nconst enabledLibrarySchema = v.object({\n libraryId: v.string(),\n revisionId: v.string(),\n enabled: v.optional(v.unknown())\n})\n\n/** Invalid entries are skipped one by one, so one bad binding keeps the others. */\nconst enabledLibrariesSchema: v.GenericSchema<unknown, EnabledLibraryBinding[]> = v.pipe(\n v.array(v.unknown()),\n v.transform((items) =>\n items.flatMap((item) => {\n const parsed = v.safeParse(enabledLibrarySchema, item)\n if (!parsed.success) return []\n const { libraryId, revisionId, enabled } = parsed.output\n return [{ libraryId, revisionId, enabled: enabled === true }]\n })\n )\n)\n\n// Shape only. Whether a string is valid CSS is checked where it is written into a stylesheet.\nconst cssTextSchema = v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(1000))\n\n/** Token fields Figma has no slot for, with mode ids as the file spells them. */\nexport interface StoredToken {\n unit?: TokenUnit\n expressions?: Record<string, { css: string; resolved?: number }>\n}\n\nconst tokenSchema: v.GenericSchema<unknown, StoredToken> = v.object({\n unit: v.optional(v.picklist(TOKEN_UNITS)),\n expressions: v.optional(\n v.record(\n v.string(),\n v.object({ css: cssTextSchema, resolved: v.optional(v.pipe(v.number(), v.finite())) })\n )\n )\n})\n\nconst okhclSchema: v.GenericSchema<unknown, OkHCLPayload> = v.object({\n version: v.literal(1),\n kind: v.picklist(['fill', 'stroke']),\n index: v.number(),\n color: v.object({\n h: v.number(),\n c: v.number(),\n l: v.number(),\n a: v.fallback(v.optional(v.number()), undefined)\n })\n})\n\nconst sourceLibraryPublicationSchema: v.GenericSchema<unknown, SourceLibraryPublication> = v.object(\n {\n libraryId: v.string(),\n revisionId: v.string(),\n name: v.string(),\n catalogSource: v.optional(v.string())\n }\n)\n\n/**\n * Every plugin-data entry OpenPencil writes under {@link OPEN_PENCIL_PLUGIN_ID}: state Figma's\n * format has no field for. Add a key here, never as a string elsewhere, so reading and writing\n * it share one schema.\n */\nexport const OPEN_PENCIL_PLUGIN_DATA = {\n /** A text node's direction, on TEXT nodes. */\n textDirection: textPluginDataField('textDirection', 'format', DIRECTIONS),\n /** An auto-layout frame's direction. */\n layoutDirection: textPluginDataField('layoutDirection', 'format', DIRECTIONS),\n /** Marks a component set Figma would read as a plain frame. */\n nodeType: textPluginDataField('nodeType', 'format', ['COMPONENT_SET']),\n /** Variable bindings by field path, including those Figma cannot store natively. */\n boundVariables: jsonPluginDataField('boundVariables', 'format', boundVariablesSchema),\n exportSettings: jsonPluginDataField('exportSettings', 'format', exportSettingsSchema),\n /** The node-local rect a TEXT_PATH layout maps onto, which Kiwi has no field for. */\n textPathBox: jsonPluginDataField('textPathBox', 'format', textPathBoxSchema),\n /** The library asset a node was inserted from. */\n librarySource: jsonPluginDataField('librarySource', 'bookkeeping', librarySourceSchema),\n /** The library source layer a library definition's layer copies, on every definition layer. */\n libraryLayer: jsonPluginDataField(\n 'libraryLayer',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(1024))\n ),\n /**\n * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the\n * root keeps it across a save as every layer keeps its GUID.\n */\n documentId: jsonPluginDataField(\n 'documentId',\n 'bookkeeping',\n v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))\n ),\n /** Libraries enabled for the document, on the DOCUMENT node. */\n enabledLibraries: jsonPluginDataField('enabledLibraries', 'bookkeeping', enabledLibrariesSchema),\n /** The library this document publishes as, on the DOCUMENT node. */\n sourceLibraryPublication: jsonPluginDataField(\n 'sourceLibraryPublication',\n 'bookkeeping',\n sourceLibraryPublicationSchema\n ),\n /** Canvas comment threads, deleted ones included, on the DOCUMENT node. */\n comments: jsonPluginDataField('comments', 'bookkeeping', commentThreadsSchema),\n /** The statuses layers can be in, on the DOCUMENT node. */\n statuses: jsonPluginDataField('statuses', 'bookkeeping', statusWorkflowSchema),\n /** How tightly the document's `.fig` data is compressed, on the DOCUMENT node. */\n figCompression: textPluginDataField('figCompression', 'bookkeeping', FIG_COMPRESSIONS),\n /** A layer's status, any state of the workflow; Figma's `sectionStatusInfo` knows only two. */\n status: jsonPluginDataField('status', 'format', nodeStatusSchema),\n /** Unit and CSS expressions, on each VARIABLE. */\n token: jsonPluginDataField('token', 'format', tokenSchema),\n /** Mode conditions by mode id, on each VARIABLE_SET. */\n modeConditions: jsonPluginDataField(\n 'modeConditions',\n 'format',\n v.record(v.string(), cssTextSchema)\n ),\n /** The attribute that switches manual modes, on each VARIABLE_SET. */\n modeAttribute: jsonPluginDataField(\n 'modeAttribute',\n 'format',\n v.pipe(v.string(), v.trim(), v.maxLength(100), v.regex(MODE_ATTRIBUTE_PATTERN))\n ),\n /** One entry per paint picked in OkHCL, so the picker reopens on the same coordinates. */\n okhcl: jsonPluginDataField('okhcl', 'content', okhclSchema),\n /** How a main component or component set behaves as a control in preview. */\n behaviour: jsonPluginDataField('behaviour', 'content', behaviourSchema),\n /** The icon a frame draws, such as `lucide:home`, on the frame its paths are in. */\n icon: jsonPluginDataField('icon', 'content', iconSchema),\n /** Which of an icon path's paints its icon's color sets, on each path the source drew in it. */\n iconTint: jsonPluginDataField('iconTint', 'content', iconTintSchema),\n /** One entry per paint that draws a shader, matched to its image paint by the frame's hash. */\n shader: jsonPluginDataField('shader', 'content', shaderPaintSchema)\n} satisfies Record<string, PluginDataKey>\n\nconst NOT_CONTENT = Object.values(OPEN_PENCIL_PLUGIN_DATA).filter(\n (field) => field.role !== 'content'\n)\n\n/**\n * A node's plugin data that is part of its content, in a stable order: OpenPencil's content\n * fields and every other plugin's entries, which the node carries wherever it goes. Format\n * copies of node fields and bookkeeping are left out.\n */\nexport function contentPluginData(entries: readonly PluginDataEntry[]): PluginDataEntry[] {\n return withoutPluginData(entries, NOT_CONTENT).sort(\n (a, b) => a.pluginId.localeCompare(b.pluginId) || a.key.localeCompare(b.key)\n )\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,MAAM,aAAa;CAAC;CAAQ;CAAO;AAAK;AAKxC,MAAM,oBAAoD,EAAE,KAC1D,EAAE,OAAO;CAAE,GAAG,EAAE,OAAO;CAAG,GAAG,EAAE,OAAO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;CAEhE,OAAO,oBAAoB,SAAS,UAAU,WAAW;;CAEzD,gBAAgB,oBACd,kBACA,UACA,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,CACpC;;CAEA,eAAe,oBACb,iBACA,UACA,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,GAAG,GAAG,EAAE,MAAM,sBAAsB,CAAC,CAChF;;CAEA,OAAO,oBAAoB,SAAS,WAAW,WAAW;;CAE1D,WAAW,oBAAoB,aAAa,WAAW,eAAe;;CAEtE,MAAM,oBAAoB,QAAQ,WAAW,UAAU;;CAEvD,UAAU,oBAAoB,YAAY,WAAW,cAAc;;CAEnE,QAAQ,oBAAoB,UAAU,WAAW,iBAAiB;AACpE;AAEA,MAAM,cAAc,OAAO,OAAO,uBAAuB,CAAC,CAAC,QACxD,UAAU,MAAM,SAAS,SAC5B;;;;;;AAOA,SAAgB,kBAAkB,SAAwD;CACxF,OAAO,kBAAkB,SAAS,WAAW,CAAC,CAAC,MAC5C,GAAG,MAAM,EAAE,SAAS,cAAc,EAAE,QAAQ,KAAK,EAAE,IAAI,cAAc,EAAE,GAAG,CAC7E;AACF"}
package/dist/resize.d.ts CHANGED
@@ -7,22 +7,23 @@ import { ConstraintType, SceneNode, VectorNetwork } from "./types.js";
7
7
  * geometry that must scale with the node, and textPathBox is the layout box the
8
8
  * glyphs were reflowed against.
9
9
  */
10
- type ResizeSnapshot = Pick<SceneNode, 'type' | 'x' | 'y' | 'width' | 'height' | 'vectorNetwork' | 'fillGeometry' | 'strokeGeometry' | 'derivedTextGlyphs' | 'strokes' | 'textPathData' | 'textPathBox'>;
10
+ type ResizeSnapshot = Pick<SceneNode, 'type' | 'x' | 'y' | 'width' | 'height' | 'flipX' | 'flipY' | 'vectorNetwork' | 'fillGeometry' | 'strokeGeometry' | 'derivedTextGlyphs' | 'strokes' | 'textPathData' | 'textPathBox'>;
11
11
  interface ResizeGraph {
12
+ readonly rootId: string;
12
13
  getNode(id: string): SceneNode | undefined;
13
14
  }
15
+ /** A child's box after its parent resizes, and the axes on which it turned over. */
16
+ type ConstrainedRect = Rect & {
17
+ flipsX?: boolean;
18
+ flipsY?: boolean;
19
+ };
14
20
  /** Keep a placed box's constrained edges or center when its content determines its size. */
15
21
  declare function resizedChildRect(placed: Rect, size: Pick<Rect, 'width' | 'height'>, horizontal: ConstraintType, vertical: ConstraintType): Rect;
16
- /** A child's box after its parent resizes, keeping a locked aspect ratio as Figma does. */
17
- declare function constrainedChildRect(child: Rect, parentBefore: Pick<Rect, 'width' | 'height'>, parentAfter: Pick<Rect, 'width' | 'height'>, horizontal: ConstraintType, vertical: ConstraintType, aspectRatio?: number | null): Rect;
18
22
  /**
19
- * Where a child goes when layout resizes its parent, as Figma places a layer that ignores auto
20
- * layout when its Hug frame grows (measured on desktop 126): Right and Left & right move or grow
21
- * it by the change in the parent's size rounded to whole pixels, Center by the change in its
22
- * rounded half, and Scale by the exact ratio, its position to 1/128 of a pixel. Sizes are not
23
- * rounded, so applying a run of changes one at a time lands where applying them at once does.
23
+ * A child's box after its parent resizes, by a handle, `resize()`, layout, or an instance taking
24
+ * another size than its component, keeping a locked aspect ratio as Figma does.
24
25
  */
25
- declare function layoutConstrainedChildRect(child: Rect, parentBefore: Pick<Rect, 'width' | 'height'>, parentAfter: Pick<Rect, 'width' | 'height'>, horizontal: ConstraintType, vertical: ConstraintType, aspectRatio?: number | null): Rect;
26
+ declare function constrainedChildRect(child: Rect, parentBefore: Pick<Rect, 'width' | 'height'>, parentAfter: Pick<Rect, 'width' | 'height'>, horizontal: ConstraintType, vertical: ConstraintType, aspectRatio?: number | null): ConstrainedRect;
26
27
  declare function scaledChildRect(child: Rect, parentBefore: Pick<Rect, 'width' | 'height'>, parentAfter: Pick<Rect, 'width' | 'height'>): Rect;
27
28
  declare function scaleVectorNetworkForResize(vectorNetwork: VectorNetwork | null, originalWidth: number, originalHeight: number, width: number, height: number): VectorNetwork | null;
28
29
  /** Snapshot one node's resize-relevant state (rect + geometry that must scale with it). */
@@ -35,7 +36,17 @@ declare function createResizeSnapshot(node: SceneNode): ResizeSnapshot;
35
36
  */
36
37
  declare function scaledGeometryChanges(orig: Pick<ResizeSnapshot, 'type' | 'vectorNetwork' | 'fillGeometry' | 'strokeGeometry' | 'derivedTextGlyphs' | 'strokes' | 'textPathData' | 'textPathBox'>, origWidth: number, origHeight: number, width: number, height: number): Partial<SceneNode>;
37
38
  declare function collectResizeDescendants(graph: ResizeGraph, rootId: string): Map<string, ResizeSnapshot> | null;
38
- declare function computeConstrainedResizeChanges(graph: ResizeGraph, rootId: string, rootBefore: Pick<Rect, 'width' | 'height'>, rootAfter: Pick<Rect, 'width' | 'height'>, originals: ReadonlyMap<string, ResizeSnapshot>): Map<string, Partial<SceneNode>>;
39
+ /**
40
+ * The flips a child takes when its constraints place it from `from`, written only where they
41
+ * differ from the ones it has now, so a drag that crosses back undoes its own turn.
42
+ */
43
+ declare function flipChanges(from: Pick<SceneNode, 'flipX' | 'flipY'>, current: Pick<SceneNode, 'flipX' | 'flipY'>, flipsX?: boolean, flipsY?: boolean): Partial<Pick<SceneNode, 'flipX' | 'flipY'>>;
44
+ type Size = Pick<Rect, 'width' | 'height'>;
45
+ /**
46
+ * Where the descendants of a layer go when it resizes from `rootBefore` to `rootAfter`, from the
47
+ * places `originals` recorded.
48
+ */
49
+ declare function computeConstrainedResizeChanges(graph: ResizeGraph, rootId: string, rootBefore: Size, rootAfter: Size, originals: ReadonlyMap<string, ResizeSnapshot>): Map<string, Partial<SceneNode>>;
39
50
  //#endregion
40
- export { ResizeSnapshot, collectResizeDescendants, computeConstrainedResizeChanges, constrainedChildRect, createResizeSnapshot, layoutConstrainedChildRect, resizedChildRect, scaleVectorNetworkForResize, scaledChildRect, scaledGeometryChanges };
51
+ export { ConstrainedRect, ResizeSnapshot, collectResizeDescendants, computeConstrainedResizeChanges, constrainedChildRect, createResizeSnapshot, flipChanges, resizedChildRect, scaleVectorNetworkForResize, scaledChildRect, scaledGeometryChanges };
41
52
  //# sourceMappingURL=resize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resize.d.ts","names":[],"sources":["../src/resize.ts"],"mappings":";;;;;;;;;KAkBY,iBAAiB,KAC3B;UAeQ;EACR,QAAQ,aAAa;;;iBA8CP,iBACd,QAAQ,MACR,MAAM,KAAK,2BACX,YAAY,gBACZ,UAAU,iBACT;;iBAyBa,qBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,2BAClB,YAAY,gBACZ,UAAU,gBACV,8BACC;;;;;;;;iBAuCa,2BACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,2BAClB,YAAY,gBACZ,UAAU,gBACV,8BACC;iBAgBa,gBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,4BACjB;iBAIa,4BACd,eAAe,sBACf,uBACA,wBACA,eACA,iBACC;;iBA8Ba,qBAAqB,MAAM,YAAY;;;;;;;iBAkDvC,sBACd,MAAM,KACJ,kJAUF,mBACA,oBACA,eACA,iBACC,QAAQ;iBAqDK,yBACd,OAAO,aACP,iBACC,YAAY;iBAoBC,gCACd,OAAO,aACP,gBACA,YAAY,KAAK,2BACjB,WAAW,KAAK,2BAChB,WAAW,oBAAoB,kBAC9B,YAAY,QAAQ"}
1
+ {"version":3,"file":"resize.d.ts","names":[],"sources":["../src/resize.ts"],"mappings":";;;;;;;;;KAuBY,iBAAiB,KAC3B;UAiBQ;WACC;EACT,QAAQ,aAAa;;;KAeX,kBAAkB;EAAS;EAAkB;;;iBAkDzC,iBACd,QAAQ,MACR,MAAM,KAAK,2BACX,YAAY,gBACZ,UAAU,iBACT;;;;;iBA4Ba,qBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,2BAClB,YAAY,gBACZ,UAAU,gBACV,8BACC;iBAca,gBACd,OAAO,MACP,cAAc,KAAK,2BACnB,aAAa,KAAK,4BACjB;iBASa,4BACd,eAAe,sBACf,uBACA,wBACA,eACA,iBACC;;iBA6Ba,qBAAqB,MAAM,YAAY;;;;;;;iBAoDvC,sBACd,MAAM,KACJ,kJAUF,mBACA,oBACA,eACA,iBACC,QAAQ;iBAsFK,yBACd,OAAO,aACP,iBACC,YAAY;;;;;iBAwBC,YACd,MAAM,KAAK,+BACX,SAAS,KAAK,+BACd,kBACA,mBACC,QAAQ,KAAK;KASX,OAAO,KAAK;;;;;iBAmJD,gCACd,OAAO,aACP,gBACA,YAAY,MACZ,WAAW,MACX,WAAW,oBAAoB,kBAC9B,YAAY,QAAQ"}