@pairdraw/scene-graph 0.19.2 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/dist/color/index.d.ts +28 -7
  2. package/dist/color/index.d.ts.map +1 -1
  3. package/dist/color/index.js +40 -15
  4. package/dist/color/index.js.map +1 -1
  5. package/dist/color/management.d.ts +19 -6
  6. package/dist/color/management.d.ts.map +1 -1
  7. package/dist/color/management.js +56 -1
  8. package/dist/color/management.js.map +1 -1
  9. package/dist/color/profile.d.ts +32 -0
  10. package/dist/color/profile.d.ts.map +1 -0
  11. package/dist/color/profile.js +140 -0
  12. package/dist/color/profile.js.map +1 -0
  13. package/dist/comments/index.d.ts +2 -2
  14. package/dist/comments/index.js +2 -2
  15. package/dist/comments/merge.d.ts.map +1 -1
  16. package/dist/comments/merge.js +1 -0
  17. package/dist/comments/merge.js.map +1 -1
  18. package/dist/comments/schema.d.ts +3 -1
  19. package/dist/comments/schema.d.ts.map +1 -1
  20. package/dist/comments/schema.js +19 -2
  21. package/dist/comments/schema.js.map +1 -1
  22. package/dist/comments/threads.d.ts +3 -1
  23. package/dist/comments/threads.d.ts.map +1 -1
  24. package/dist/comments/threads.js +2 -1
  25. package/dist/comments/threads.js.map +1 -1
  26. package/dist/components/index.d.ts +2 -2
  27. package/dist/components/index.js +2 -2
  28. package/dist/components/properties.d.ts.map +1 -1
  29. package/dist/components/properties.js +7 -7
  30. package/dist/components/properties.js.map +1 -1
  31. package/dist/components/variants.d.ts +12 -1
  32. package/dist/components/variants.d.ts.map +1 -1
  33. package/dist/components/variants.js +30 -1
  34. package/dist/components/variants.js.map +1 -1
  35. package/dist/constants.d.ts +25 -1
  36. package/dist/constants.d.ts.map +1 -1
  37. package/dist/constants.js +94 -1
  38. package/dist/constants.js.map +1 -1
  39. package/dist/copy.d.ts.map +1 -1
  40. package/dist/copy.js +17 -1
  41. package/dist/copy.js.map +1 -1
  42. package/dist/css/index.d.ts +2 -2
  43. package/dist/css/index.js +2 -2
  44. package/dist/css/shadows.d.ts +2 -2
  45. package/dist/css/shadows.d.ts.map +1 -1
  46. package/dist/css/shadows.js +4 -4
  47. package/dist/css/shadows.js.map +1 -1
  48. package/dist/css/text.d.ts +17 -1
  49. package/dist/css/text.d.ts.map +1 -1
  50. package/dist/css/text.js +62 -1
  51. package/dist/css/text.js.map +1 -1
  52. package/dist/css/values.d.ts +7 -2
  53. package/dist/css/values.d.ts.map +1 -1
  54. package/dist/css/values.js +8 -4
  55. package/dist/css/values.js.map +1 -1
  56. package/dist/design-memory/index.d.ts +3 -0
  57. package/dist/design-memory/index.js +3 -0
  58. package/dist/design-memory/model.d.ts +33 -0
  59. package/dist/design-memory/model.d.ts.map +1 -0
  60. package/dist/design-memory/model.js +142 -0
  61. package/dist/design-memory/model.js.map +1 -0
  62. package/dist/design-memory/schema.d.ts +76 -0
  63. package/dist/design-memory/schema.d.ts.map +1 -0
  64. package/dist/design-memory/schema.js +72 -0
  65. package/dist/design-memory/schema.js.map +1 -0
  66. package/dist/effects.d.ts +7 -4
  67. package/dist/effects.d.ts.map +1 -1
  68. package/dist/effects.js +9 -4
  69. package/dist/effects.js.map +1 -1
  70. package/dist/empty-values.js +102 -0
  71. package/dist/empty-values.js.map +1 -0
  72. package/dist/fields/components.d.ts +9 -0
  73. package/dist/fields/components.d.ts.map +1 -0
  74. package/dist/fields/components.js +24 -0
  75. package/dist/fields/components.js.map +1 -0
  76. package/dist/fields/index.d.ts +3 -2
  77. package/dist/fields/index.js +3 -2
  78. package/dist/fields/layout.d.ts +3 -1
  79. package/dist/fields/layout.d.ts.map +1 -1
  80. package/dist/fields/layout.js +10 -1
  81. package/dist/fields/layout.js.map +1 -1
  82. package/dist/graph.d.ts +12 -1
  83. package/dist/graph.d.ts.map +1 -1
  84. package/dist/graph.js +39 -7
  85. package/dist/graph.js.map +1 -1
  86. package/dist/grid-values.d.ts +10 -0
  87. package/dist/grid-values.d.ts.map +1 -0
  88. package/dist/grid-values.js +53 -0
  89. package/dist/grid-values.js.map +1 -0
  90. package/dist/hit-test/drop.d.ts +20 -0
  91. package/dist/hit-test/drop.d.ts.map +1 -0
  92. package/dist/hit-test/drop.js +54 -0
  93. package/dist/hit-test/drop.js.map +1 -0
  94. package/dist/hit-test/geometry.js +86 -0
  95. package/dist/hit-test/geometry.js.map +1 -0
  96. package/dist/hit-test/masks.d.ts +14 -0
  97. package/dist/hit-test/masks.d.ts.map +1 -0
  98. package/dist/hit-test/masks.js +41 -0
  99. package/dist/hit-test/masks.js.map +1 -0
  100. package/dist/hit-test/paint.d.ts +6 -0
  101. package/dist/hit-test/paint.d.ts.map +1 -0
  102. package/dist/hit-test/paint.js +19 -0
  103. package/dist/hit-test/paint.js.map +1 -0
  104. package/dist/hit-test.d.ts +4 -15
  105. package/dist/hit-test.d.ts.map +1 -1
  106. package/dist/hit-test.js +5 -173
  107. package/dist/hit-test.js.map +1 -1
  108. package/dist/images.d.ts +3 -2
  109. package/dist/images.d.ts.map +1 -1
  110. package/dist/images.js +18 -2
  111. package/dist/images.js.map +1 -1
  112. package/dist/index.d.ts +2 -2
  113. package/dist/instances/copies.js +2 -1
  114. package/dist/instances/copies.js.map +1 -1
  115. package/dist/instances/fields.d.ts.map +1 -1
  116. package/dist/instances/fields.js +2 -0
  117. package/dist/instances/fields.js.map +1 -1
  118. package/dist/instances/index.d.ts +2 -1
  119. package/dist/instances/index.d.ts.map +1 -1
  120. package/dist/instances/index.js +13 -12
  121. package/dist/instances/index.js.map +1 -1
  122. package/dist/instances/overrides.d.ts +15 -1
  123. package/dist/instances/overrides.d.ts.map +1 -1
  124. package/dist/instances/overrides.js +37 -1
  125. package/dist/instances/overrides.js.map +1 -1
  126. package/dist/instances/source-walk.d.ts +12 -0
  127. package/dist/instances/source-walk.d.ts.map +1 -0
  128. package/dist/instances/swap-overrides.js +3 -3
  129. package/dist/instances/swap-overrides.js.map +1 -1
  130. package/dist/instances/sync.js +9 -7
  131. package/dist/instances/sync.js.map +1 -1
  132. package/dist/node-defaults.d.ts.map +1 -1
  133. package/dist/node-defaults.js +43 -38
  134. package/dist/node-defaults.js.map +1 -1
  135. package/dist/plugin-data/fields.d.ts +90 -0
  136. package/dist/plugin-data/fields.d.ts.map +1 -1
  137. package/dist/plugin-data/fields.js +33 -24
  138. package/dist/plugin-data/fields.js.map +1 -1
  139. package/dist/plugin-data/index.d.ts +2 -2
  140. package/dist/plugin-data/index.js +2 -2
  141. package/dist/plugin-data/schema.d.ts +6 -1
  142. package/dist/plugin-data/schema.d.ts.map +1 -1
  143. package/dist/plugin-data/schema.js +24 -1
  144. package/dist/plugin-data/schema.js.map +1 -1
  145. package/dist/preview.d.ts.map +1 -1
  146. package/dist/preview.js +2 -0
  147. package/dist/preview.js.map +1 -1
  148. package/dist/scaling/node.d.ts.map +1 -1
  149. package/dist/scaling/node.js +5 -1
  150. package/dist/scaling/node.js.map +1 -1
  151. package/dist/shaders/animation.d.ts +21 -0
  152. package/dist/shaders/animation.d.ts.map +1 -0
  153. package/dist/shaders/animation.js +25 -0
  154. package/dist/shaders/animation.js.map +1 -0
  155. package/dist/shaders/index.d.ts +2 -1
  156. package/dist/shaders/index.js +2 -1
  157. package/dist/slots/content.d.ts.map +1 -1
  158. package/dist/slots/content.js +4 -4
  159. package/dist/slots/content.js.map +1 -1
  160. package/dist/statuses/index.d.ts +2 -2
  161. package/dist/statuses/index.js +2 -2
  162. package/dist/statuses/workflow.d.ts +3 -1
  163. package/dist/statuses/workflow.d.ts.map +1 -1
  164. package/dist/statuses/workflow.js +6 -2
  165. package/dist/statuses/workflow.js.map +1 -1
  166. package/dist/token-sources/document.d.ts +26 -0
  167. package/dist/token-sources/document.d.ts.map +1 -0
  168. package/dist/token-sources/document.js +80 -0
  169. package/dist/token-sources/document.js.map +1 -0
  170. package/dist/token-sources/index.d.ts +3 -0
  171. package/dist/token-sources/index.js +3 -0
  172. package/dist/token-sources/schema.d.ts +43 -0
  173. package/dist/token-sources/schema.d.ts.map +1 -0
  174. package/dist/token-sources/schema.js +50 -0
  175. package/dist/token-sources/schema.js.map +1 -0
  176. package/dist/transfer/variables.d.ts.map +1 -1
  177. package/dist/transfer/variables.js +1 -1
  178. package/dist/transfer/variables.js.map +1 -1
  179. package/dist/types.d.ts +135 -15
  180. package/dist/types.d.ts.map +1 -1
  181. package/dist/types.js.map +1 -1
  182. package/dist/variables/bindings.d.ts +6 -5
  183. package/dist/variables/bindings.d.ts.map +1 -1
  184. package/dist/variables/bindings.js +24 -16
  185. package/dist/variables/bindings.js.map +1 -1
  186. package/dist/variables/formula/index.d.ts.map +1 -1
  187. package/dist/variables/formula/index.js +12 -6
  188. package/dist/variables/formula/index.js.map +1 -1
  189. package/dist/variables/index.d.ts +14 -1
  190. package/dist/variables/index.d.ts.map +1 -1
  191. package/dist/variables/index.js +38 -10
  192. package/dist/variables/index.js.map +1 -1
  193. package/dist/variables/paints.d.ts +9 -8
  194. package/dist/variables/paints.d.ts.map +1 -1
  195. package/dist/variables/paints.js +35 -26
  196. package/dist/variables/paints.js.map +1 -1
  197. package/dist/variables/resolver.d.ts +45 -0
  198. package/dist/variables/resolver.d.ts.map +1 -0
  199. package/dist/variables/resolver.js +106 -0
  200. package/dist/variables/resolver.js.map +1 -0
  201. package/dist/variations/copy.d.ts +16 -0
  202. package/dist/variations/copy.d.ts.map +1 -0
  203. package/dist/variations/copy.js +78 -0
  204. package/dist/variations/copy.js.map +1 -0
  205. package/dist/variations/index.d.ts +6 -0
  206. package/dist/variations/index.js +6 -0
  207. package/dist/variations/match.d.ts +23 -0
  208. package/dist/variations/match.d.ts.map +1 -0
  209. package/dist/variations/match.js +80 -0
  210. package/dist/variations/match.js.map +1 -0
  211. package/dist/variations/model.d.ts +39 -0
  212. package/dist/variations/model.d.ts.map +1 -0
  213. package/dist/variations/model.js +90 -0
  214. package/dist/variations/model.js.map +1 -0
  215. package/dist/variations/pick.d.ts +43 -0
  216. package/dist/variations/pick.d.ts.map +1 -0
  217. package/dist/variations/pick.js +211 -0
  218. package/dist/variations/pick.js.map +1 -0
  219. package/dist/variations/schema.d.ts +27 -0
  220. package/dist/variations/schema.d.ts.map +1 -0
  221. package/dist/variations/schema.js +27 -0
  222. package/dist/variations/schema.js.map +1 -0
  223. package/package.json +21 -1
  224. package/src/color/index.ts +43 -9
  225. package/src/color/management.ts +54 -1
  226. package/src/color/profile.ts +131 -0
  227. package/src/comments/merge.ts +3 -0
  228. package/src/comments/schema.ts +32 -2
  229. package/src/comments/threads.ts +5 -2
  230. package/src/components/properties.ts +13 -7
  231. package/src/components/variants.ts +39 -0
  232. package/src/constants.ts +75 -0
  233. package/src/copy.ts +20 -1
  234. package/src/css/index.ts +7 -1
  235. package/src/css/shadows.ts +8 -5
  236. package/src/css/text.ts +62 -0
  237. package/src/css/values.ts +12 -5
  238. package/src/design-memory/index.ts +2 -0
  239. package/src/design-memory/model.ts +143 -0
  240. package/src/design-memory/schema.ts +84 -0
  241. package/src/effects.ts +16 -7
  242. package/src/empty-values.ts +117 -0
  243. package/src/fields/components.ts +21 -0
  244. package/src/fields/index.ts +1 -0
  245. package/src/fields/layout.ts +10 -0
  246. package/src/graph.ts +50 -6
  247. package/src/grid-values.ts +47 -0
  248. package/src/hit-test/drop.ts +90 -0
  249. package/src/hit-test/geometry.ts +131 -0
  250. package/src/hit-test/masks.ts +57 -0
  251. package/src/hit-test/paint.ts +24 -0
  252. package/src/hit-test.ts +8 -277
  253. package/src/images.ts +27 -3
  254. package/src/instances/copies.ts +2 -1
  255. package/src/instances/fields.ts +2 -0
  256. package/src/instances/index.ts +20 -11
  257. package/src/instances/overrides.ts +49 -0
  258. package/src/instances/swap-overrides.ts +3 -2
  259. package/src/instances/sync.ts +11 -7
  260. package/src/node-defaults.ts +51 -41
  261. package/src/plugin-data/fields.ts +34 -32
  262. package/src/plugin-data/index.ts +1 -0
  263. package/src/plugin-data/schema.ts +30 -0
  264. package/src/preview.ts +2 -0
  265. package/src/scaling/node.ts +7 -2
  266. package/src/shaders/animation.ts +39 -0
  267. package/src/shaders/index.ts +1 -0
  268. package/src/slots/content.ts +8 -4
  269. package/src/statuses/workflow.ts +6 -4
  270. package/src/token-sources/document.ts +104 -0
  271. package/src/token-sources/index.ts +2 -0
  272. package/src/token-sources/schema.ts +59 -0
  273. package/src/transfer/variables.ts +2 -1
  274. package/src/types.ts +145 -14
  275. package/src/variables/bindings.ts +35 -18
  276. package/src/variables/formula/index.ts +19 -18
  277. package/src/variables/index.ts +49 -10
  278. package/src/variables/paints.ts +64 -29
  279. package/src/variables/resolver.ts +178 -0
  280. package/src/variations/copy.ts +89 -0
  281. package/src/variations/index.ts +5 -0
  282. package/src/variations/match.ts +100 -0
  283. package/src/variations/model.ts +132 -0
  284. package/src/variations/pick.ts +293 -0
  285. package/src/variations/schema.ts +29 -0
@@ -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 { normalizeEffects } from './effects'\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\n/**\n * The name a layer of `type` carries when nothing names it, as Figma writes a type's name: words\n * of a compound type apart, so a shape with text is a \"Shape with text\".\n */\nexport function defaultNodeName(type: NodeType): string {\n const words = type.toLowerCase().replaceAll('_', ' ')\n return words.charAt(0).toUpperCase() + words.slice(1)\n}\n\n/**\n * The name Figma gives a layer that follows its text: the characters trimmed, on one line, and\n * the type's own name while they hold nothing.\n */\nexport function textLayerName(type: NodeType, text: string): string {\n const lines = text\n .split(/\\r\\n|\\r|\\n/)\n .map((line) => line.trim())\n .filter((line) => line !== '')\n return lines.join(' ') || defaultNodeName(type)\n}\n\n/**\n * The fields auto layout sets on the frame that holds it, with the value each holds when no frame\n * lays anything out. A page holds layers; it is not one, so none of these apply to it and a page\n * that took them would place its layers by a container nobody can see.\n */\nexport const FRAME_LAYOUT_DEFAULTS = {\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} as const satisfies Partial<SceneNode>\n\nexport function createDefaultNode(\n generateId: () => string,\n type: NodeType,\n overrides: Partial<SceneNode> = {}\n): SceneNode {\n const node = {\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 ...FRAME_LAYOUT_DEFAULTS,\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 starInnerRadius: 0.38,\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 prototypeReactions: [],\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 node.effects = normalizeEffects(node.effects)\n return node\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\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":";;;;;AAWA,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;;;;;AAMA,SAAgB,gBAAgB,MAAwB;CACtD,MAAM,QAAQ,KAAK,YAAY,CAAC,CAAC,WAAW,KAAK,GAAG;CACpD,OAAO,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;AACtD;;;;;AAMA,SAAgB,cAAc,MAA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AmB;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,oBAAoB,CAAC;EACrB,cAAc;EACd,OAAO;EACP,OAAO;EACP,aAAa;EACb,mBAAmB;EACnB,mBAAmB;EACnB,cAAc;EACd,aAAa;EACb,kBAAkB,KAAA;EAClB,GAAG;CACL;CACA,KAAK,UAAU,iBAAiB,KAAK,OAAO;CAC5C,OAAO;AACT;;AAGA,MAAa,yCAAgD,IAAI,IAAc,CAC7E,SACA,mBACF,CAAC;;AAGD,MAAa,oCAA2C,IAAI,IAAc;CACxE;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,kCAAkB,IAAI,IAAc;CAC/C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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 { normalizeEffects } from './effects'\nimport { EMPTY_LIST, EMPTY_RECORD, shareEmptyNodeValues } from './empty-values'\nimport { EMPTY_INSTANCE_OVERRIDES } 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: EMPTY_LIST,\n fig: {\n rawSize: null,\n rawTransform: null,\n rawNodeFields: EMPTY_RECORD,\n layout: null,\n symbolOverrides: EMPTY_LIST,\n componentPropAssignments: EMPTY_LIST,\n derivedSymbolData: EMPTY_LIST,\n derivedSymbolDataLayoutVersion: null,\n uniformScaleFactor: null\n },\n drawio: null\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\n/**\n * The name a layer of `type` carries when nothing names it, as Figma writes a type's name: words\n * of a compound type apart, so a shape with text is a \"Shape with text\".\n */\nexport function defaultNodeName(type: NodeType): string {\n const words = type.toLowerCase().replaceAll('_', ' ')\n return words.charAt(0).toUpperCase() + words.slice(1)\n}\n\n/**\n * The name Figma gives a layer that follows its text: the characters trimmed, on one line, and\n * the type's own name while they hold nothing.\n */\nexport function textLayerName(type: NodeType, text: string): string {\n const lines = text\n .split(/\\r\\n|\\r|\\n/)\n .map((line) => line.trim())\n .filter((line) => line !== '')\n return lines.join(' ') || defaultNodeName(type)\n}\n\n/**\n * The fields auto layout sets on the frame that holds it, with the value each holds when no frame\n * lays anything out. A page holds layers; it is not one, so none of these apply to it and a page\n * that took them would place its layers by a container nobody can see.\n */\nexport const FRAME_LAYOUT_DEFAULTS = {\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} as const satisfies Partial<SceneNode>\n\nexport function createDefaultNode(\n generateId: () => string,\n type: NodeType,\n overrides: Partial<SceneNode> = {}\n): SceneNode {\n // A literal ending in a spread is built one field at a time, and V8 keeps an object given this\n // many fields that way in dictionary mode, about 3 KB more per layer; a spread copy of a\n // finished literal keeps fast fields, in JavaScriptCore as well.\n const defaults = {\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'\n ? [{ type: 'SOLID' as const, color: BLACK, opacity: 1, visible: true }]\n : EMPTY_LIST,\n strokes: EMPTY_LIST,\n effects: EMPTY_LIST,\n layoutGrids: EMPTY_LIST,\n guides: EMPTY_LIST,\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 overflowDirection: 'NONE',\n scrollBehavior: 'SCROLLS',\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 ...FRAME_LAYOUT_DEFAULTS,\n blendMode: 'PASS_THROUGH',\n layoutPositioning: 'AUTO',\n layoutGrow: 0,\n layoutAlignSelf: 'AUTO',\n vectorNetwork: null,\n handleMirroring: 'NONE',\n fillGeometry: EMPTY_LIST,\n strokeGeometry: EMPTY_LIST,\n arcData: null,\n textAlignVertical: 'TOP',\n textAutoResize: 'NONE',\n textCase: 'ORIGINAL',\n textDecoration: 'NONE',\n textDecorationStyle: 'SOLID',\n textDecorationThickness: null,\n textDecorationFills: EMPTY_LIST,\n textDecorationSkipInk: true,\n textUnderlineOffset: null,\n maxLines: null,\n textParagraphs: EMPTY_LIST,\n listSpacing: 0,\n paragraphSpacing: 0,\n paragraphIndent: 0,\n hangingList: false,\n styleRuns: EMPTY_LIST,\n fontVariations: EMPTY_LIST,\n opticalSizeFromFontSize: true,\n fontFeatures: EMPTY_LIST,\n horizontalConstraint: 'MIN',\n verticalConstraint: 'MIN',\n strokeCap: 'NONE',\n strokeJoin: 'MITER',\n dashPattern: EMPTY_LIST,\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: EMPTY_LIST,\n connectorCurveHandles: null,\n connectorLabelPosition: null,\n isMask: false,\n maskType: 'ALPHA',\n maskIsOutline: false,\n gridTemplateColumns: EMPTY_LIST,\n gridTemplateRows: EMPTY_LIST,\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 starInnerRadius: 0.38,\n shapeWithTextType: 'SQUARE',\n shapeUserHeight: 0,\n shapeTruncates: false,\n componentId: null,\n instanceOverrides: EMPTY_INSTANCE_OVERRIDES,\n componentPropertyDefinitions: EMPTY_LIST,\n componentPropertyReferences: EMPTY_LIST,\n componentPropertyAssignments: EMPTY_RECORD,\n componentPropertyValues: EMPTY_RECORD,\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: EMPTY_LIST,\n variantPropSpecs: EMPTY_LIST,\n boundVariables: EMPTY_RECORD,\n variableBindingScales: EMPTY_RECORD,\n variableAssignmentScales: EMPTY_RECORD,\n componentScale: 1,\n variableModes: EMPTY_RECORD,\n exportSettings: EMPTY_LIST,\n status: null,\n pluginData: EMPTY_LIST,\n pluginRelaunchData: EMPTY_LIST,\n prototypeReactions: EMPTY_LIST,\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 } satisfies CompleteNodeFields\n const node: SceneNode = { ...defaults, ...overrides }\n node.effects = normalizeEffects(node.effects)\n shareEmptyNodeValues(node, Object.keys(overrides))\n return node\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\nexport const CONTAINER_TYPES = new Set<NodeType>([\n 'CANVAS',\n 'FRAME',\n 'GROUP',\n 'BOOLEAN_OPERATION',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET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ACA;CACA;CACA;AACF,CAAC"}
@@ -61,6 +61,14 @@ declare const PAIRDRAW_PLUGIN_DATA: {
61
61
  textPathBox: PluginDataField<Rect>;
62
62
  /** The library asset a node was inserted from. */
63
63
  librarySource: PluginDataField<LibraryAssetSource>;
64
+ /**
65
+ * Where a layer of a pasted component came from: the copying document's root id and the node's id
66
+ * there. A later paste of the same snapshot into that document reuses the component it made.
67
+ */
68
+ clipboardOrigin: PluginDataField<{
69
+ documentId: string;
70
+ nodeId: string;
71
+ }>;
64
72
  /**
65
73
  * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the
66
74
  * root keeps it across a save as every layer keeps its GUID.
@@ -70,6 +78,13 @@ declare const PAIRDRAW_PLUGIN_DATA: {
70
78
  enabledLibraries: PluginDataField<EnabledLibraryBinding[]>;
71
79
  /** The library this document publishes as, on the DOCUMENT node. */
72
80
  sourceLibraryPublication: PluginDataField<SourceLibraryPublication>;
81
+ /**
82
+ * The `.pen` documents this document imports, by alias and relative path, on the DOCUMENT node.
83
+ * A `.pen` file names them in its own `imports`, so a save writes them back from here.
84
+ */
85
+ penImports: PluginDataField<{
86
+ [x: string]: string;
87
+ }>;
73
88
  /** Canvas comment threads, deleted ones included, on the DOCUMENT node. */
74
89
  comments: PluginDataField<CommentThread[]>;
75
90
  /** The statuses layers can be in, on the DOCUMENT node. */
@@ -86,6 +101,67 @@ declare const PAIRDRAW_PLUGIN_DATA: {
86
101
  };
87
102
  }[];
88
103
  }>;
104
+ /** The code the document's variables are linked to, on the DOCUMENT node. */
105
+ tokenSources: PluginDataField<{
106
+ id: string;
107
+ kind: "css" | "folder" | "dtcg";
108
+ name: string;
109
+ path?: string | undefined;
110
+ syncedAt?: string | undefined;
111
+ snapshot: {
112
+ [x: string]: {
113
+ [x: string]: string;
114
+ };
115
+ };
116
+ names?: {
117
+ [x: string]: string;
118
+ } | undefined;
119
+ currentNames?: {
120
+ [x: string]: string;
121
+ } | undefined;
122
+ modes?: {
123
+ [x: string]: {
124
+ [x: string]: string;
125
+ };
126
+ } | undefined;
127
+ }[]>;
128
+ /** The design rules agents follow in the document, on the DOCUMENT node. */
129
+ designMemory: PluginDataField<{
130
+ version: 1;
131
+ colors: {
132
+ fromSystem: boolean;
133
+ values: string[];
134
+ enforce: "refuse" | "warn" | "off";
135
+ };
136
+ fonts: {
137
+ fromSystem: boolean;
138
+ values: string[];
139
+ enforce: "refuse" | "warn" | "off";
140
+ };
141
+ fontSizes: {
142
+ fromSystem: boolean;
143
+ values: number[];
144
+ enforce: "refuse" | "warn" | "off";
145
+ };
146
+ spacing: {
147
+ fromSystem: boolean;
148
+ values: number[];
149
+ enforce: "refuse" | "warn" | "off";
150
+ };
151
+ radius: {
152
+ fromSystem: boolean;
153
+ values: number[];
154
+ enforce: "refuse" | "warn" | "off";
155
+ };
156
+ decisions: {
157
+ id: string;
158
+ text: string;
159
+ author: "person" | "agent";
160
+ }[];
161
+ examples: {
162
+ nodeId: string;
163
+ }[];
164
+ }>;
89
165
  /** How tightly the document's `.fig` data is compressed, on the DOCUMENT node. */
90
166
  figCompression: PluginDataField<"fast" | "smaller" | "smallest">;
91
167
  /** A layer's status, any state of the workflow; Figma's `sectionStatusInfo` knows only two. */
@@ -208,6 +284,20 @@ declare const PAIRDRAW_PLUGIN_DATA: {
208
284
  preset: string;
209
285
  refreshedAt: string;
210
286
  }>;
287
+ /**
288
+ * On a section, that its children are variations of another layer: which one, and how that
289
+ * layer looked when they were made. A copy of the section is an ordinary section.
290
+ */
291
+ variationSet: PluginDataField<{
292
+ version: 1;
293
+ originalId: string;
294
+ originalFingerprint?: string | undefined;
295
+ }>;
296
+ /**
297
+ * On a layer of a version, the main component or component set of the original it stands in
298
+ * for, so a pick keeps that component rather than pairing it by name.
299
+ */
300
+ variationStandIn: PluginDataField<string>;
211
301
  };
212
302
  /**
213
303
  * A node's plugin data that is part of its content, in a stable order: Pairdraw's content
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","names":[],"sources":["../../src/plugin-data/fields.ts"],"mappings":";;;;;;;;;;;;UAsHiB;EACf;EACA;;;UAWe;EACf,OAAO;EACP,cAAc;IAAiB;IAAa;;;;UA0B7B;EACf;EACA;EACA;EACA;EACA;IAAU,UAAU;IAAQ,OAAO;;;;;;;;cA6CxB;;iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4FG,kBAAkB,kBAAkB,oBAAoB"}
1
+ {"version":3,"file":"fields.d.ts","names":[],"sources":["../../src/plugin-data/fields.ts"],"mappings":";;;;;;;;;;;;UAyGiB;EACf;EACA;;;UAWe;EACf,OAAO;EACP,cAAc;IAAiB;IAAa;;;;UA0B7B;EACf;EACA;EACA;EACA;EACA;IAAU,UAAU;IAAQ,OAAO;;;;;;;;cAoCxB;;iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoHG,kBAAkB,kBAAkB,oBAAoB"}
@@ -3,6 +3,7 @@ import { agentNotesSchema } from "../agent-notes/schema.js";
3
3
  import { behaviourSchema } from "../behaviours/schema.js";
4
4
  import { browserNodeSchema } from "../browser-node/schema.js";
5
5
  import { commentThreadsSchema } from "../comments/schema.js";
6
+ import { designMemorySchema } from "../design-memory/schema.js";
6
7
  import { clampExportQuality, isExportFormatId } from "../export-format.js";
7
8
  import { clampExportScale } from "../export-scale.js";
8
9
  import { FIG_COMPRESSIONS } from "../fig-compression.js";
@@ -10,8 +11,10 @@ import { iconSchema, iconTintSchema } from "../icons/schema.js";
10
11
  import { scriptNodeSchema } from "../script/schema.js";
11
12
  import { shaderPaintSchema } from "../shaders/schema.js";
12
13
  import { nodeStatusSchema, statusWorkflowSchema } from "../statuses/schema.js";
14
+ import { tokenSourcesSchema } from "../token-sources/schema.js";
13
15
  import { MODE_ATTRIBUTE_PATTERN, TOKEN_UNITS } from "../types.js";
14
- import { webCitationSchema } from "./schema.js";
16
+ import { variationSetSchema, variationStandInSchema } from "../variations/schema.js";
17
+ import { enabledLibrariesSchema, sourceLibraryPublicationSchema, webCitationSchema } from "./schema.js";
15
18
  import * as v from "valibot";
16
19
  //#region src/plugin-data/fields.ts
17
20
  const DIRECTIONS = [
@@ -37,6 +40,10 @@ const exportSettingsSchema = v.array(v.pipe(v.object({
37
40
  format,
38
41
  ...quality === void 0 ? {} : { quality: clampExportQuality(quality) }
39
42
  }))));
43
+ const clipboardOriginSchema = v.object({
44
+ documentId: v.pipe(v.string(), v.nonEmpty(), v.maxLength(64)),
45
+ nodeId: v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))
46
+ });
40
47
  const librarySourceSchema = v.pipe(v.object({
41
48
  identity: v.object({
42
49
  libraryId: v.string(),
@@ -50,22 +57,6 @@ const librarySourceSchema = v.pipe(v.object({
50
57
  sourceNodeId: typeof sourceNodeId === "string" ? sourceNodeId : null,
51
58
  readOnly: readOnly === true
52
59
  })));
53
- const enabledLibrarySchema = v.object({
54
- libraryId: v.string(),
55
- revisionId: v.string(),
56
- enabled: v.optional(v.unknown())
57
- });
58
- /** Invalid entries are skipped one by one, so one bad binding keeps the others. */
59
- const enabledLibrariesSchema = v.pipe(v.array(v.unknown()), v.transform((items) => items.flatMap((item) => {
60
- const parsed = v.safeParse(enabledLibrarySchema, item);
61
- if (!parsed.success) return [];
62
- const { libraryId, revisionId, enabled } = parsed.output;
63
- return [{
64
- libraryId,
65
- revisionId,
66
- enabled: enabled === true
67
- }];
68
- })));
69
60
  const cssTextSchema = v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(1e3));
70
61
  const replacedLayersSchema = v.array(v.object({
71
62
  path: v.pipe(v.array(v.pipe(v.string(), v.regex(/^\d+:\d+$/))), v.minLength(1)),
@@ -120,12 +111,6 @@ const meshFillsSchema = v.pipe(v.array(v.unknown()), v.transform((items) => item
120
111
  points
121
112
  }];
122
113
  })));
123
- const sourceLibraryPublicationSchema = v.object({
124
- libraryId: v.string(),
125
- revisionId: v.string(),
126
- name: v.string(),
127
- catalogSource: v.optional(v.string())
128
- });
129
114
  /**
130
115
  * Every plugin-data entry Pairdraw writes under {@link PAIRDRAW_PLUGIN_ID}: state Figma's
131
116
  * format has no field for. Add a key here, never as a string elsewhere, so reading and writing
@@ -153,6 +138,11 @@ const PAIRDRAW_PLUGIN_DATA = {
153
138
  /** The library asset a node was inserted from. */
154
139
  librarySource: jsonPluginDataField("librarySource", "bookkeeping", librarySourceSchema),
155
140
  /**
141
+ * Where a layer of a pasted component came from: the copying document's root id and the node's id
142
+ * there. A later paste of the same snapshot into that document reuses the component it made.
143
+ */
144
+ clipboardOrigin: jsonPluginDataField("clipboardOrigin", "bookkeeping", clipboardOriginSchema),
145
+ /**
156
146
  * The document root's id, on the DOCUMENT node, whose own GUID is always Figma's `0:0`; the
157
147
  * root keeps it across a save as every layer keeps its GUID.
158
148
  */
@@ -161,10 +151,19 @@ const PAIRDRAW_PLUGIN_DATA = {
161
151
  enabledLibraries: jsonPluginDataField("enabledLibraries", "bookkeeping", enabledLibrariesSchema),
162
152
  /** The library this document publishes as, on the DOCUMENT node. */
163
153
  sourceLibraryPublication: jsonPluginDataField("sourceLibraryPublication", "bookkeeping", sourceLibraryPublicationSchema),
154
+ /**
155
+ * The `.pen` documents this document imports, by alias and relative path, on the DOCUMENT node.
156
+ * A `.pen` file names them in its own `imports`, so a save writes them back from here.
157
+ */
158
+ penImports: jsonPluginDataField("penImports", "bookkeeping", v.record(v.string(), v.string())),
164
159
  /** Canvas comment threads, deleted ones included, on the DOCUMENT node. */
165
160
  comments: jsonPluginDataField("comments", "bookkeeping", commentThreadsSchema),
166
161
  /** The statuses layers can be in, on the DOCUMENT node. */
167
162
  statuses: jsonPluginDataField("statuses", "bookkeeping", statusWorkflowSchema),
163
+ /** The code the document's variables are linked to, on the DOCUMENT node. */
164
+ tokenSources: jsonPluginDataField("tokenSources", "bookkeeping", tokenSourcesSchema),
165
+ /** The design rules agents follow in the document, on the DOCUMENT node. */
166
+ designMemory: jsonPluginDataField("designMemory", "bookkeeping", designMemorySchema),
168
167
  /** How tightly the document's `.fig` data is compressed, on the DOCUMENT node. */
169
168
  figCompression: textPluginDataField("figCompression", "bookkeeping", FIG_COMPRESSIONS),
170
169
  /** A layer's status, any state of the workflow; Figma's `sectionStatusInfo` knows only two. */
@@ -197,7 +196,17 @@ const PAIRDRAW_PLUGIN_DATA = {
197
196
  * A snapshot of one page: its address, viewport, and when it was refreshed. The picture is
198
197
  * the layer's image fill. An address that is not an http or https page does not decode.
199
198
  */
200
- browserNode: jsonPluginDataField("browserNode", "content", browserNodeSchema)
199
+ browserNode: jsonPluginDataField("browserNode", "content", browserNodeSchema),
200
+ /**
201
+ * On a section, that its children are variations of another layer: which one, and how that
202
+ * layer looked when they were made. A copy of the section is an ordinary section.
203
+ */
204
+ variationSet: jsonPluginDataField("variationSet", "bookkeeping", variationSetSchema),
205
+ /**
206
+ * On a layer of a version, the main component or component set of the original it stands in
207
+ * for, so a pick keeps that component rather than pairing it by name.
208
+ */
209
+ variationStandIn: jsonPluginDataField("variationStandIn", "bookkeeping", variationStandInSchema)
201
210
  };
202
211
  const NOT_CONTENT = Object.values(PAIRDRAW_PLUGIN_DATA).filter((field) => field.role !== "content");
203
212
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","names":[],"sources":["../../src/plugin-data/fields.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { agentNotesSchema } from '../agent-notes/schema'\nimport { behaviourSchema } from '../behaviours/schema'\nimport { browserNodeSchema } from '../browser-node/schema'\nimport type { OkHCLPayload } from '../color/okhcl'\nimport { commentThreadsSchema } from '../comments/schema'\nimport { clampExportQuality, 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 { Color, Rect, Vector } from '../primitives'\nimport { scriptNodeSchema } from '../script/schema'\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'\nimport { webCitationSchema } from './schema'\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 quality: v.optional(v.pipe(v.number(), v.finite()))\n }),\n // Clamp at the file boundary: imported plugin data may carry a scale the UI never produces.\n v.transform(({ scale, format, quality }) => ({\n scale: clampExportScale(scale),\n format,\n ...(quality === undefined ? {} : { quality: clampExportQuality(quality) })\n }))\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/**\n * A layer an instance shows in place of one of its component's layers, which Figma has no\n * override for: the GUID path of the component layer it replaces, as an override's `guidPath`\n * spells it, and the replacement's own records as a Base64 Kiwi `NODE_CHANGES` message.\n */\nexport interface StoredReplacedLayer {\n path: string[]\n records: string\n}\n\nconst replacedLayersSchema: v.GenericSchema<unknown, StoredReplacedLayer[]> = v.array(\n v.object({\n path: v.pipe(v.array(v.pipe(v.string(), v.regex(/^\\d+:\\d+$/))), v.minLength(1)),\n records: v.pipe(v.string(), v.nonEmpty())\n })\n)\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\n/** A mesh paint Figma's format has no type for, stored beside its solid fallback paint. */\nexport interface StoredMeshFill {\n kind: 'fill' | 'stroke'\n index: number\n columns: number\n rows: number\n points: { position: Vector; color: Color }[]\n}\n\n/** Invalid entries are skipped one by one, so one bad mesh keeps the others. */\nconst meshFillsSchema: v.GenericSchema<unknown, StoredMeshFill[]> = v.pipe(\n v.array(v.unknown()),\n v.transform((items) =>\n items.flatMap((item) => {\n const parsed = v.safeParse(\n v.object({\n kind: v.picklist(['fill', 'stroke']),\n index: v.pipe(v.number(), v.integer(), v.minValue(0)),\n columns: v.pipe(v.number(), v.integer(), v.minValue(1)),\n rows: v.pipe(v.number(), v.integer(), v.minValue(1)),\n points: v.array(\n v.object({\n position: v.object({ x: v.number(), y: v.number() }),\n color: v.object({ r: v.number(), g: v.number(), b: v.number(), a: v.number() })\n })\n )\n }),\n item\n )\n if (!parsed.success) return []\n const { kind, index, columns, rows, points } = parsed.output\n if (points.length !== (columns + 1) * (rows + 1)) return []\n return [{ kind, index, columns, rows, points }]\n })\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 Pairdraw writes under {@link PAIRDRAW_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 PAIRDRAW_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 /**\n * A primary axis alignment Figma has no mode for, on auto-layout frames; the record keeps\n * Figma's space between, and a frame whose record says otherwise was changed in Figma.\n */\n primaryAxisAlign: textPluginDataField('primaryAxisAlign', 'format', ['SPACE_AROUND']),\n /** Marks a component set Figma would read as a plain frame, and a script node Figma has no type for. */\n nodeType: textPluginDataField('nodeType', 'format', ['COMPONENT_SET', 'SCRIPT']),\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 /** Layers an instance shows in place of its component's, on the instance's own record. */\n replacedLayers: jsonPluginDataField('replacedLayers', 'format', replacedLayersSchema),\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 /** A script node's source and its `@input` values, on the SCRIPT node. */\n script: jsonPluginDataField('script', 'content', scriptNodeSchema),\n /** One entry per mesh paint, beside the solid fallback its record carries. */\n meshFills: jsonPluginDataField('meshFills', 'format', meshFillsSchema),\n /** Notes a person left on a layer for agents: what it means or does, and a request about it. */\n agentNotes: jsonPluginDataField('agentNotes', 'content', agentNotesSchema),\n /** A page a sticky cites: its URL, title, quote, and the time the page was read. */\n webCitation: jsonPluginDataField('webCitation', 'content', webCitationSchema),\n /**\n * A snapshot of one page: its address, viewport, and when it was refreshed. The picture is\n * the layer's image fill. An address that is not an http or https page does not decode.\n */\n browserNode: jsonPluginDataField('browserNode', 'content', browserNodeSchema)\n} satisfies Record<string, PluginDataKey>\n\nconst NOT_CONTENT = Object.values(PAIRDRAW_PLUGIN_DATA).filter((field) => field.role !== 'content')\n\n/**\n * A node's plugin data that is part of its content, in a stable order: Pairdraw'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":";;;;;;;;;;;;;;;;AAmCA,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,EAAE,GAAG,GAAG,OAAO,aAAa,OAAO,SAAS,IAAI,IAAI,QAAQ,MAAM,KAAK,QAAQ,KAAK,SAAS,CAChG,CACF;;AAGA,MAAM,uBAAuB,EAAE,KAC7B,EAAE,QACC,UAAU,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK,CAChF,GACA,EAAE,WAAW,UACX,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,QACnB,UAAqC,OAAO,MAAM,OAAO,QAC5D,CACF,CACF,CACF;;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AAM,SAAS,SAAS;;;;;;AAOlG,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 { agentNotesSchema } from '../agent-notes/schema'\nimport { behaviourSchema } from '../behaviours/schema'\nimport { browserNodeSchema } from '../browser-node/schema'\nimport type { OkHCLPayload } from '../color/okhcl'\nimport { commentThreadsSchema } from '../comments/schema'\nimport { designMemorySchema } from '../design-memory/schema'\nimport { clampExportQuality, 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 { Color, Rect, Vector } from '../primitives'\nimport { scriptNodeSchema } from '../script/schema'\nimport { shaderPaintSchema } from '../shaders/schema'\nimport { nodeStatusSchema, statusWorkflowSchema } from '../statuses/schema'\nimport { tokenSourcesSchema } from '../token-sources/schema'\nimport {\n MODE_ATTRIBUTE_PATTERN,\n TOKEN_UNITS,\n type ExportSetting,\n type LayoutDirection,\n type LibraryAssetSource,\n type PluginDataEntry,\n type TextDirection,\n type TokenUnit\n} from '../types'\nimport { variationSetSchema, variationStandInSchema } from '../variations/schema'\nimport {\n jsonPluginDataField,\n textPluginDataField,\n withoutPluginData,\n type PluginDataKey\n} from './field'\nimport { enabledLibrariesSchema, sourceLibraryPublicationSchema, webCitationSchema } from './schema'\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 quality: v.optional(v.pipe(v.number(), v.finite()))\n }),\n // Clamp at the file boundary: imported plugin data may carry a scale the UI never produces.\n v.transform(({ scale, format, quality }) => ({\n scale: clampExportScale(scale),\n format,\n ...(quality === undefined ? {} : { quality: clampExportQuality(quality) })\n }))\n )\n)\n\nconst clipboardOriginSchema = v.object({\n documentId: v.pipe(v.string(), v.nonEmpty(), v.maxLength(64)),\n nodeId: v.pipe(v.string(), v.nonEmpty(), v.maxLength(64))\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\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/**\n * A layer an instance shows in place of one of its component's layers, which Figma has no\n * override for: the GUID path of the component layer it replaces, as an override's `guidPath`\n * spells it, and the replacement's own records as a Base64 Kiwi `NODE_CHANGES` message.\n */\nexport interface StoredReplacedLayer {\n path: string[]\n records: string\n}\n\nconst replacedLayersSchema: v.GenericSchema<unknown, StoredReplacedLayer[]> = v.array(\n v.object({\n path: v.pipe(v.array(v.pipe(v.string(), v.regex(/^\\d+:\\d+$/))), v.minLength(1)),\n records: v.pipe(v.string(), v.nonEmpty())\n })\n)\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\n/** A mesh paint Figma's format has no type for, stored beside its solid fallback paint. */\nexport interface StoredMeshFill {\n kind: 'fill' | 'stroke'\n index: number\n columns: number\n rows: number\n points: { position: Vector; color: Color }[]\n}\n\n/** Invalid entries are skipped one by one, so one bad mesh keeps the others. */\nconst meshFillsSchema: v.GenericSchema<unknown, StoredMeshFill[]> = v.pipe(\n v.array(v.unknown()),\n v.transform((items) =>\n items.flatMap((item) => {\n const parsed = v.safeParse(\n v.object({\n kind: v.picklist(['fill', 'stroke']),\n index: v.pipe(v.number(), v.integer(), v.minValue(0)),\n columns: v.pipe(v.number(), v.integer(), v.minValue(1)),\n rows: v.pipe(v.number(), v.integer(), v.minValue(1)),\n points: v.array(\n v.object({\n position: v.object({ x: v.number(), y: v.number() }),\n color: v.object({ r: v.number(), g: v.number(), b: v.number(), a: v.number() })\n })\n )\n }),\n item\n )\n if (!parsed.success) return []\n const { kind, index, columns, rows, points } = parsed.output\n if (points.length !== (columns + 1) * (rows + 1)) return []\n return [{ kind, index, columns, rows, points }]\n })\n )\n)\n\n/**\n * Every plugin-data entry Pairdraw writes under {@link PAIRDRAW_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 PAIRDRAW_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 /**\n * A primary axis alignment Figma has no mode for, on auto-layout frames; the record keeps\n * Figma's space between, and a frame whose record says otherwise was changed in Figma.\n */\n primaryAxisAlign: textPluginDataField('primaryAxisAlign', 'format', ['SPACE_AROUND']),\n /** Marks a component set Figma would read as a plain frame, and a script node Figma has no type for. */\n nodeType: textPluginDataField('nodeType', 'format', ['COMPONENT_SET', 'SCRIPT']),\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 /** Layers an instance shows in place of its component's, on the instance's own record. */\n replacedLayers: jsonPluginDataField('replacedLayers', 'format', replacedLayersSchema),\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 * Where a layer of a pasted component came from: the copying document's root id and the node's id\n * there. A later paste of the same snapshot into that document reuses the component it made.\n */\n clipboardOrigin: jsonPluginDataField('clipboardOrigin', 'bookkeeping', clipboardOriginSchema),\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 /**\n * The `.pen` documents this document imports, by alias and relative path, on the DOCUMENT node.\n * A `.pen` file names them in its own `imports`, so a save writes them back from here.\n */\n penImports: jsonPluginDataField('penImports', 'bookkeeping', v.record(v.string(), v.string())),\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 /** The code the document's variables are linked to, on the DOCUMENT node. */\n tokenSources: jsonPluginDataField('tokenSources', 'bookkeeping', tokenSourcesSchema),\n /** The design rules agents follow in the document, on the DOCUMENT node. */\n designMemory: jsonPluginDataField('designMemory', 'bookkeeping', designMemorySchema),\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 /** A script node's source and its `@input` values, on the SCRIPT node. */\n script: jsonPluginDataField('script', 'content', scriptNodeSchema),\n /** One entry per mesh paint, beside the solid fallback its record carries. */\n meshFills: jsonPluginDataField('meshFills', 'format', meshFillsSchema),\n /** Notes a person left on a layer for agents: what it means or does, and a request about it. */\n agentNotes: jsonPluginDataField('agentNotes', 'content', agentNotesSchema),\n /** A page a sticky cites: its URL, title, quote, and the time the page was read. */\n webCitation: jsonPluginDataField('webCitation', 'content', webCitationSchema),\n /**\n * A snapshot of one page: its address, viewport, and when it was refreshed. The picture is\n * the layer's image fill. An address that is not an http or https page does not decode.\n */\n browserNode: jsonPluginDataField('browserNode', 'content', browserNodeSchema),\n /**\n * On a section, that its children are variations of another layer: which one, and how that\n * layer looked when they were made. A copy of the section is an ordinary section.\n */\n variationSet: jsonPluginDataField('variationSet', 'bookkeeping', variationSetSchema),\n /**\n * On a layer of a version, the main component or component set of the original it stands in\n * for, so a pick keeps that component rather than pairing it by name.\n */\n variationStandIn: jsonPluginDataField('variationStandIn', 'bookkeeping', variationStandInSchema)\n} satisfies Record<string, PluginDataKey>\n\nconst NOT_CONTENT = Object.values(PAIRDRAW_PLUGIN_DATA).filter((field) => field.role !== 'content')\n\n/**\n * A node's plugin data that is part of its content, in a stable order: Pairdraw'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[]): Plugin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AAE,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;;CAElE,QAAQ,oBAAoB,UAAU,WAAW,gBAAgB;;CAEjE,WAAW,oBAAoB,aAAa,UAAU,eAAe;;CAErE,YAAY,oBAAoB,cAAc,WAAW,gBAAgB;;CAEzE,aAAa,oBAAoB,eAAe,WAAW,iBAAiB;;;;;CAK5E,aAAa,oBAAoB,eAAe,WAAW,iBAAiB;;;;;CAK5E,cAAc,oBAAoB,gBAAgB,eAAe,kBAAkB;;;;;CAKnF,kBAAkB,oBAAoB,oBAAoB,eAAe,sBAAsB;AACjG;AAEA,MAAM,cAAc,OAAO,OAAO,oBAAoB,CAAC,CAAC,QAAQ,UAAU,MAAM,SAAS,SAAS;;;;;;AAOlG,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,5 +1,5 @@
1
1
  import { PAIRDRAW_PLUGIN_ID, PluginDataField, PluginDataKey, PluginDataRole, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, textPluginDataField, withAllPluginData, withPluginData, withoutPluginData } from "./field.js";
2
2
  import { PAIRDRAW_PLUGIN_DATA, StoredMeshFill, StoredReplacedLayer, StoredToken, contentPluginData } from "./fields.js";
3
- import { CITATION_QUOTE_LIMIT, WebCitation } from "./schema.js";
3
+ import { CITATION_QUOTE_LIMIT, WebCitation, enabledLibrariesSchema, sourceLibraryPublicationSchema } from "./schema.js";
4
4
  import { readWebCitation, withWebCitation } from "./citation.js";
5
- export { CITATION_QUOTE_LIMIT, PAIRDRAW_PLUGIN_DATA, PAIRDRAW_PLUGIN_ID, PluginDataField, PluginDataKey, PluginDataRole, StoredMeshFill, StoredReplacedLayer, StoredToken, type WebCitation, contentPluginData, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, readWebCitation, textPluginDataField, withAllPluginData, withPluginData, withWebCitation, withoutPluginData };
5
+ export { CITATION_QUOTE_LIMIT, PAIRDRAW_PLUGIN_DATA, PAIRDRAW_PLUGIN_ID, PluginDataField, PluginDataKey, PluginDataRole, StoredMeshFill, StoredReplacedLayer, StoredToken, type WebCitation, contentPluginData, enabledLibrariesSchema, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, readWebCitation, sourceLibraryPublicationSchema, textPluginDataField, withAllPluginData, withPluginData, withWebCitation, withoutPluginData };
@@ -1,5 +1,5 @@
1
1
  import { PAIRDRAW_PLUGIN_ID, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, textPluginDataField, withAllPluginData, withPluginData, withoutPluginData } from "./field.js";
2
- import { CITATION_QUOTE_LIMIT } from "./schema.js";
2
+ import { CITATION_QUOTE_LIMIT, enabledLibrariesSchema, sourceLibraryPublicationSchema } from "./schema.js";
3
3
  import { PAIRDRAW_PLUGIN_DATA, contentPluginData } from "./fields.js";
4
4
  import { readWebCitation, withWebCitation } from "./citation.js";
5
- export { CITATION_QUOTE_LIMIT, PAIRDRAW_PLUGIN_DATA, PAIRDRAW_PLUGIN_ID, contentPluginData, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, readWebCitation, textPluginDataField, withAllPluginData, withPluginData, withWebCitation, withoutPluginData };
5
+ export { CITATION_QUOTE_LIMIT, PAIRDRAW_PLUGIN_DATA, PAIRDRAW_PLUGIN_ID, contentPluginData, enabledLibrariesSchema, hasPluginData, isPluginDataEntry, jsonPluginDataField, pluginDataEntry, readAllPluginData, readPluginData, readWebCitation, sourceLibraryPublicationSchema, textPluginDataField, withAllPluginData, withPluginData, withWebCitation, withoutPluginData };
@@ -1,3 +1,4 @@
1
+ import { EnabledLibraryBinding, SourceLibraryPublication } from "../types.js";
1
2
  import * as v from "valibot";
2
3
  //#region src/plugin-data/schema.d.ts
3
4
  /** A quote kept on a sticky. A longer passage is cut before it is stored. */
@@ -13,6 +14,10 @@ declare const webCitationSchema: v.ObjectSchema<{
13
14
  readonly readAt: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, undefined>]>;
14
15
  }, undefined>;
15
16
  type WebCitation = v.InferOutput<typeof webCitationSchema>;
17
+ /** One library a document switched on; invalid entries are skipped one by one. */
18
+ declare const enabledLibrariesSchema: v.GenericSchema<unknown, EnabledLibraryBinding[]>;
19
+ /** The library a document publishes as: its identity, its revision, and where it was published. */
20
+ declare const sourceLibraryPublicationSchema: v.GenericSchema<unknown, SourceLibraryPublication>;
16
21
  //#endregion
17
- export { CITATION_QUOTE_LIMIT, WebCitation, webCitationSchema };
22
+ export { CITATION_QUOTE_LIMIT, WebCitation, enabledLibrariesSchema, sourceLibraryPublicationSchema, webCitationSchema };
18
23
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/plugin-data/schema.ts"],"mappings":";;;cAGa;;;;;cAmBA,mBAAiB,EAAA;;;;;;KAYlB,cAAc,EAAE,mBAAmB"}
1
+ {"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/plugin-data/schema.ts"],"mappings":";;;;cAKa;;;;;cAmBA,mBAAiB,EAAA;;;;;;KAYlB,cAAc,EAAE,mBAAmB;;cASlC,wBAAwB,EAAE,uBAAuB;;cAajD,gCAAgC,EAAE,uBAAuB"}
@@ -23,7 +23,30 @@ const webCitationSchema = v.object({
23
23
  quote: v.pipe(v.string(), v.trim(), v.maxLength(CITATION_QUOTE_LIMIT)),
24
24
  readAt: v.pipe(v.string(), v.isoTimestamp())
25
25
  });
26
+ const enabledLibrarySchema = v.object({
27
+ libraryId: v.string(),
28
+ revisionId: v.string(),
29
+ enabled: v.optional(v.unknown())
30
+ });
31
+ /** One library a document switched on; invalid entries are skipped one by one. */
32
+ const enabledLibrariesSchema = v.pipe(v.array(v.unknown()), v.transform((items) => items.flatMap((item) => {
33
+ const parsed = v.safeParse(enabledLibrarySchema, item);
34
+ if (!parsed.success) return [];
35
+ const { libraryId, revisionId, enabled } = parsed.output;
36
+ return [{
37
+ libraryId,
38
+ revisionId,
39
+ enabled: enabled === true
40
+ }];
41
+ })));
42
+ /** The library a document publishes as: its identity, its revision, and where it was published. */
43
+ const sourceLibraryPublicationSchema = v.object({
44
+ libraryId: v.string(),
45
+ revisionId: v.string(),
46
+ name: v.string(),
47
+ catalogSource: v.optional(v.string())
48
+ });
26
49
  //#endregion
27
- export { CITATION_QUOTE_LIMIT, webCitationSchema };
50
+ export { CITATION_QUOTE_LIMIT, enabledLibrariesSchema, sourceLibraryPublicationSchema, webCitationSchema };
28
51
 
29
52
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../src/plugin-data/schema.ts"],"sourcesContent":["import * as v from 'valibot'\n\n/** A quote kept on a sticky. A longer passage is cut before it is stored. */\nexport const CITATION_QUOTE_LIMIT = 2_000\n\nconst CITATION_URL_LIMIT = 2_048\nconst CITATION_TITLE_LIMIT = 300\n\n/** An http or https page with a host. Other schemes are not citations. */\nfunction isCitedPage(value: string): boolean {\n try {\n const url = new URL(value)\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.hostname !== ''\n } catch {\n return false\n }\n}\n\n/**\n * A page a sticky cites: where it was read, what it was called, the words taken from it, and\n * when. The quote is characters from the page, kept as text.\n */\nexport const webCitationSchema = v.object({\n url: v.pipe(\n v.string(),\n v.trim(),\n v.maxLength(CITATION_URL_LIMIT),\n v.check(isCitedPage, 'A citation names an http or https page.')\n ),\n title: v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(CITATION_TITLE_LIMIT)),\n quote: v.pipe(v.string(), v.trim(), v.maxLength(CITATION_QUOTE_LIMIT)),\n readAt: v.pipe(v.string(), v.isoTimestamp())\n})\n\nexport type WebCitation = v.InferOutput<typeof webCitationSchema>\n"],"mappings":";;;AAGA,MAAa,uBAAuB;AAEpC,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;;AAG7B,SAAS,YAAY,OAAwB;CAC3C,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EACzB,QAAQ,IAAI,aAAa,WAAW,IAAI,aAAa,aAAa,IAAI,aAAa;CACrF,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,MAAa,oBAAoB,EAAE,OAAO;CACxC,KAAK,EAAE,KACL,EAAE,OAAO,GACT,EAAE,KAAK,GACP,EAAE,UAAU,kBAAkB,GAC9B,EAAE,MAAM,aAAa,yCAAyC,CAChE;CACA,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,SAAS,GAAG,EAAE,UAAU,oBAAoB,CAAC;CACnF,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,oBAAoB,CAAC;CACrE,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,aAAa,CAAC;AAC7C,CAAC"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../src/plugin-data/schema.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { EnabledLibraryBinding, SourceLibraryPublication } from '../types'\n\n/** A quote kept on a sticky. A longer passage is cut before it is stored. */\nexport const CITATION_QUOTE_LIMIT = 2_000\n\nconst CITATION_URL_LIMIT = 2_048\nconst CITATION_TITLE_LIMIT = 300\n\n/** An http or https page with a host. Other schemes are not citations. */\nfunction isCitedPage(value: string): boolean {\n try {\n const url = new URL(value)\n return (url.protocol === 'http:' || url.protocol === 'https:') && url.hostname !== ''\n } catch {\n return false\n }\n}\n\n/**\n * A page a sticky cites: where it was read, what it was called, the words taken from it, and\n * when. The quote is characters from the page, kept as text.\n */\nexport const webCitationSchema = v.object({\n url: v.pipe(\n v.string(),\n v.trim(),\n v.maxLength(CITATION_URL_LIMIT),\n v.check(isCitedPage, 'A citation names an http or https page.')\n ),\n title: v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(CITATION_TITLE_LIMIT)),\n quote: v.pipe(v.string(), v.trim(), v.maxLength(CITATION_QUOTE_LIMIT)),\n readAt: v.pipe(v.string(), v.isoTimestamp())\n})\n\nexport type WebCitation = v.InferOutput<typeof webCitationSchema>\n\nconst enabledLibrarySchema = v.object({\n libraryId: v.string(),\n revisionId: v.string(),\n enabled: v.optional(v.unknown())\n})\n\n/** One library a document switched on; invalid entries are skipped one by one. */\nexport const 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/** The library a document publishes as: its identity, its revision, and where it was published. */\nexport const sourceLibraryPublicationSchema: v.GenericSchema<unknown, SourceLibraryPublication> =\n v.object({\n libraryId: v.string(),\n revisionId: v.string(),\n name: v.string(),\n catalogSource: v.optional(v.string())\n })\n"],"mappings":";;;AAKA,MAAa,uBAAuB;AAEpC,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;;AAG7B,SAAS,YAAY,OAAwB;CAC3C,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EACzB,QAAQ,IAAI,aAAa,WAAW,IAAI,aAAa,aAAa,IAAI,aAAa;CACrF,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,MAAa,oBAAoB,EAAE,OAAO;CACxC,KAAK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sources":["../src/preview.ts"],"mappings":";;KAMY,uBAAuB,MAAM,WAAW,SAAS,QAAQ;KAEhE;EACH,OAAO,YAAY;EACnB;EACA;;iBAwCc,kBACd,OAAO,cACP,YACA,SAAS,QAAQ,YACjB,eAAe,sBACd,QAAQ"}
package/dist/preview.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { normalizeEffects } from "./effects.js";
2
+ import { shareEmptyNodeValues } from "./empty-values.js";
2
3
  import { normalizeVectorNetwork } from "./vector-network.js";
3
4
  import { textCacheInvalidationChanges } from "./text/picture.js";
4
5
  //#region src/preview.ts
@@ -60,6 +61,7 @@ function updateNodePreview(graph, id, changes, beforeUpdate) {
60
61
  beforeUpdate?.(node, normalizedChanges);
61
62
  graph.positionPreviewVersion++;
62
63
  Object.assign(node, normalizedChanges);
64
+ shareEmptyNodeValues(node, Object.keys(normalizedChanges));
63
65
  return normalizedChanges;
64
66
  }
65
67
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"preview.js","names":[],"sources":["../src/preview.ts"],"sourcesContent":["import { normalizeEffects } from './effects'\nimport { textCacheInvalidationChanges } from './text/picture'\nimport type { SceneNode } from './types'\nimport { normalizeVectorNetwork } from './vector-network'\n\nexport type NodePreviewObserver = (node: SceneNode, changes: Partial<SceneNode>) => void\n\ntype PreviewGraph = {\n nodes: Map<string, SceneNode>\n positionPreviewVersion: number\n clearAbsPosCache: () => void\n}\n\nconst LAYOUT_AFFECTING_KEYS = new Set<string>([\n 'x',\n 'y',\n 'width',\n 'height',\n 'rotation',\n 'flipX',\n 'flipY',\n 'parentId',\n 'childIds',\n 'layoutMode',\n 'layoutDirection',\n 'layoutWrap',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'layoutPositioning',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'visible',\n 'text',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'styleRuns',\n 'textAutoResize'\n])\n\nexport function updateNodePreview(\n graph: PreviewGraph,\n id: string,\n changes: Partial<SceneNode>,\n beforeUpdate?: NodePreviewObserver\n): Partial<SceneNode> | null {\n const node = graph.nodes.get(id)\n if (!node) return null\n changes = Object.fromEntries(\n (Object.entries(changes) as Array<[string, unknown]>).filter(([, value]) => value !== undefined)\n )\n if ((Object.keys(changes) as (keyof SceneNode)[]).every((key) => node[key] === changes[key])) {\n return null\n }\n const affectsLayout = Object.keys(changes).some((key) => LAYOUT_AFFECTING_KEYS.has(key))\n if (affectsLayout) graph.clearAbsPosCache()\n let normalizedChanges = changes\n if (node.type === 'TEXT') {\n normalizedChanges = { ...textCacheInvalidationChanges(node, changes), ...changes }\n }\n if (changes.vectorNetwork) {\n normalizedChanges = {\n ...normalizedChanges,\n vectorNetwork: normalizeVectorNetwork(changes.vectorNetwork)\n }\n }\n if (changes.effects) {\n normalizedChanges = { ...normalizedChanges, effects: normalizeEffects(changes.effects) }\n }\n beforeUpdate?.(node, normalizedChanges)\n graph.positionPreviewVersion++\n Object.assign(node, normalizedChanges)\n return normalizedChanges\n}\n"],"mappings":";;;;AAaA,MAAM,wCAAwB,IAAI,IAAY;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,kBACd,OACA,IACA,SACA,cAC2B;CAC3B,MAAM,OAAO,MAAM,MAAM,IAAI,EAAE;CAC/B,IAAI,CAAC,MAAM,OAAO;CAClB,UAAU,OAAO,YACd,OAAO,QAAQ,OAAO,CAAC,CAA8B,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CACjG;CACA,IAAK,OAAO,KAAK,OAAO,CAAC,CAAyB,OAAO,QAAQ,KAAK,SAAS,QAAQ,IAAI,GACzF,OAAO;CAGT,IADsB,OAAO,KAAK,OAAO,CAAC,CAAC,MAAM,QAAQ,sBAAsB,IAAI,GAAG,CACtE,GAAG,MAAM,iBAAiB;CAC1C,IAAI,oBAAoB;CACxB,IAAI,KAAK,SAAS,QAChB,oBAAoB;EAAE,GAAG,6BAA6B,MAAM,OAAO;EAAG,GAAG;CAAQ;CAEnF,IAAI,QAAQ,eACV,oBAAoB;EAClB,GAAG;EACH,eAAe,uBAAuB,QAAQ,aAAa;CAC7D;CAEF,IAAI,QAAQ,SACV,oBAAoB;EAAE,GAAG;EAAmB,SAAS,iBAAiB,QAAQ,OAAO;CAAE;CAEzF,eAAe,MAAM,iBAAiB;CACtC,MAAM;CACN,OAAO,OAAO,MAAM,iBAAiB;CACrC,OAAO;AACT"}
1
+ {"version":3,"file":"preview.js","names":[],"sources":["../src/preview.ts"],"sourcesContent":["import { normalizeEffects } from './effects'\nimport { shareEmptyNodeValues } from './empty-values'\nimport { textCacheInvalidationChanges } from './text/picture'\nimport type { SceneNode } from './types'\nimport { normalizeVectorNetwork } from './vector-network'\n\nexport type NodePreviewObserver = (node: SceneNode, changes: Partial<SceneNode>) => void\n\ntype PreviewGraph = {\n nodes: Map<string, SceneNode>\n positionPreviewVersion: number\n clearAbsPosCache: () => void\n}\n\nconst LAYOUT_AFFECTING_KEYS = new Set<string>([\n 'x',\n 'y',\n 'width',\n 'height',\n 'rotation',\n 'flipX',\n 'flipY',\n 'parentId',\n 'childIds',\n 'layoutMode',\n 'layoutDirection',\n 'layoutWrap',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'layoutPositioning',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'visible',\n 'text',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'styleRuns',\n 'textAutoResize'\n])\n\nexport function updateNodePreview(\n graph: PreviewGraph,\n id: string,\n changes: Partial<SceneNode>,\n beforeUpdate?: NodePreviewObserver\n): Partial<SceneNode> | null {\n const node = graph.nodes.get(id)\n if (!node) return null\n changes = Object.fromEntries(\n (Object.entries(changes) as Array<[string, unknown]>).filter(([, value]) => value !== undefined)\n )\n if ((Object.keys(changes) as (keyof SceneNode)[]).every((key) => node[key] === changes[key])) {\n return null\n }\n const affectsLayout = Object.keys(changes).some((key) => LAYOUT_AFFECTING_KEYS.has(key))\n if (affectsLayout) graph.clearAbsPosCache()\n let normalizedChanges = changes\n if (node.type === 'TEXT') {\n normalizedChanges = { ...textCacheInvalidationChanges(node, changes), ...changes }\n }\n if (changes.vectorNetwork) {\n normalizedChanges = {\n ...normalizedChanges,\n vectorNetwork: normalizeVectorNetwork(changes.vectorNetwork)\n }\n }\n if (changes.effects) {\n normalizedChanges = { ...normalizedChanges, effects: normalizeEffects(changes.effects) }\n }\n beforeUpdate?.(node, normalizedChanges)\n graph.positionPreviewVersion++\n Object.assign(node, normalizedChanges)\n shareEmptyNodeValues(node, Object.keys(normalizedChanges))\n return normalizedChanges\n}\n"],"mappings":";;;;;AAcA,MAAM,wCAAwB,IAAI,IAAY;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,kBACd,OACA,IACA,SACA,cAC2B;CAC3B,MAAM,OAAO,MAAM,MAAM,IAAI,EAAE;CAC/B,IAAI,CAAC,MAAM,OAAO;CAClB,UAAU,OAAO,YACd,OAAO,QAAQ,OAAO,CAAC,CAA8B,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CACjG;CACA,IAAK,OAAO,KAAK,OAAO,CAAC,CAAyB,OAAO,QAAQ,KAAK,SAAS,QAAQ,IAAI,GACzF,OAAO;CAGT,IADsB,OAAO,KAAK,OAAO,CAAC,CAAC,MAAM,QAAQ,sBAAsB,IAAI,GAAG,CACtE,GAAG,MAAM,iBAAiB;CAC1C,IAAI,oBAAoB;CACxB,IAAI,KAAK,SAAS,QAChB,oBAAoB;EAAE,GAAG,6BAA6B,MAAM,OAAO;EAAG,GAAG;CAAQ;CAEnF,IAAI,QAAQ,eACV,oBAAoB;EAClB,GAAG;EACH,eAAe,uBAAuB,QAAQ,aAAa;CAC7D;CAEF,IAAI,QAAQ,SACV,oBAAoB;EAAE,GAAG;EAAmB,SAAS,iBAAiB,QAAQ,OAAO;CAAE;CAEzF,eAAe,MAAM,iBAAiB;CACtC,MAAM;CACN,OAAO,OAAO,MAAM,iBAAiB;CACrC,qBAAqB,MAAM,OAAO,KAAK,iBAAiB,CAAC;CACzD,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","names":[],"sources":["../../src/scaling/node.ts"],"mappings":";;iBAyIgB,iBACd,MAAM,WACN,eACA,yBACC,QAAQ"}
1
+ {"version":3,"file":"node.d.ts","names":[],"sources":["../../src/scaling/node.ts"],"mappings":";;iBA8IgB,iBACd,MAAM,WACN,eACA,yBACC,QAAQ"}
@@ -36,7 +36,11 @@ function scaledStrokes(strokes, scale) {
36
36
  function scaledEffects(effects, scale) {
37
37
  return effects.map((effect) => {
38
38
  const copy = structuredClone(effect);
39
- if (copy.type === "SHADER") return copy;
39
+ if (copy.type === "SHADER" || copy.type === "NOISE") return copy;
40
+ if (copy.type === "TEXTURE") {
41
+ copy.radius *= scale;
42
+ return copy;
43
+ }
40
44
  copy.offset = {
41
45
  x: copy.offset.x * scale,
42
46
  y: copy.offset.y * scale
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","names":[],"sources":["../../src/scaling/node.ts"],"sourcesContent":["import { copyDerivedGlyphs, scaleGeometryPaths } from '../copy'\nimport { scaledTextLength } from '../text/lengths'\nimport { TEXT_PARAGRAPH_SPACING_FIELDS } from '../text/paragraphs'\nimport { followsPath } from '../text/path'\nimport {\n type Effect,\n type Fill,\n type GridTrack,\n type LayoutGrid,\n type SceneNode,\n type Stroke,\n type StyleRun,\n type TextParagraphStyle\n} from '../types'\nimport { cloneVectorNetwork } from '../vector-network'\n\nfunction scaledPathText(node: SceneNode, scale: number): Partial<SceneNode> {\n if (!node.textPathData && !followsPath(node)) {\n return {}\n }\n const box = node.textPathBox\n return {\n derivedTextGlyphs:\n copyDerivedGlyphs(node.derivedTextGlyphs)?.map((glyph) => ({\n ...glyph,\n x: glyph.x * scale,\n y: glyph.y * scale,\n fontSize: glyph.fontSize * scale,\n ...(glyph.advance === undefined ? {} : { advance: glyph.advance * scale })\n })) ?? null,\n textPathBox: box && {\n x: box.x * scale,\n y: box.y * scale,\n width: box.width * scale,\n height: box.height * scale\n }\n }\n}\n\nfunction scaledOptional(value: number | null, scale: number): number | null {\n return value == null ? null : value * scale\n}\n\nfunction scaledStrokes(strokes: readonly Stroke[], scale: number): Stroke[] {\n return strokes.map((stroke) => ({\n ...structuredClone(stroke),\n weight: stroke.weight * scale,\n dashPattern: stroke.dashPattern?.map((value) => value * scale)\n }))\n}\n\nfunction scaledEffects(effects: readonly Effect[], scale: number): Effect[] {\n return effects.map((effect) => {\n const copy = structuredClone(effect)\n // A shader effect has no geometry of its own; only a shadow's measures follow the layer.\n if (copy.type === 'SHADER') return copy\n copy.offset = { x: copy.offset.x * scale, y: copy.offset.y * scale }\n copy.radius *= scale\n copy.spread *= scale\n return copy\n })\n}\n\nfunction scaledFills(fills: readonly Fill[], scale: number): Fill[] {\n return fills.map((fill) => ({\n ...structuredClone(fill),\n scale: fill.scale == null ? undefined : fill.scale * scale,\n spacing: fill.spacing == null ? undefined : fill.spacing * scale,\n patternSpacing: fill.patternSpacing\n ? { x: fill.patternSpacing.x * scale, y: fill.patternSpacing.y * scale }\n : undefined,\n noiseSize: fill.noiseSize\n ? { x: fill.noiseSize.x * scale, y: fill.noiseSize.y * scale }\n : undefined\n }))\n}\n\nfunction scaledStyleRuns(styleRuns: readonly StyleRun[], scale: number): StyleRun[] {\n return styleRuns.map((run) => ({\n ...structuredClone(run),\n style: {\n ...structuredClone(run.style),\n fontSize: run.style.fontSize == null ? undefined : run.style.fontSize * scale,\n letterSpacing: run.style.letterSpacing && scaledTextLength(run.style.letterSpacing, scale),\n lineHeight: run.style.lineHeight && scaledTextLength(run.style.lineHeight, scale),\n textDecorationThickness: scaledOptional(run.style.textDecorationThickness ?? null, scale),\n textUnderlineOffset: scaledOptional(run.style.textUnderlineOffset ?? null, scale)\n }\n }))\n}\n\nfunction scaledParagraphStyles(\n paragraphs: readonly TextParagraphStyle[],\n scale: number\n): TextParagraphStyle[] {\n return paragraphs.map((style) => {\n const scaled = { ...style }\n for (const field of TEXT_PARAGRAPH_SPACING_FIELDS) {\n const value = style[field]\n if (value !== undefined) scaled[field] = value * scale\n }\n return scaled\n })\n}\n\nfunction scaledLayoutGrids(grids: readonly LayoutGrid[], scale: number): LayoutGrid[] {\n return grids.map((grid) => ({\n ...structuredClone(grid),\n offset: grid.offset == null ? undefined : grid.offset * scale,\n sectionSize: grid.sectionSize == null ? undefined : grid.sectionSize * scale,\n gutterSize: grid.gutterSize == null ? undefined : grid.gutterSize * scale\n }))\n}\n\nfunction scaledGridTracks(tracks: readonly GridTrack[], scale: number): GridTrack[] {\n return tracks.map((track) => ({\n ...track,\n value: track.sizing === 'FIXED' ? track.value * scale : track.value\n }))\n}\n\nfunction scaledVectorNetwork(node: SceneNode, scale: number): SceneNode['vectorNetwork'] {\n if (!node.vectorNetwork) return null\n const network = cloneVectorNetwork(node.vectorNetwork)\n for (const vertex of network.vertices) {\n vertex.x *= scale\n vertex.y *= scale\n }\n for (const segment of network.segments) {\n segment.tangentStart.x *= scale\n segment.tangentStart.y *= scale\n segment.tangentEnd.x *= scale\n segment.tangentEnd.y *= scale\n }\n return network\n}\n\nexport function scaleNodeChanges(\n node: SceneNode,\n scale: number,\n scalePosition: boolean\n): Partial<SceneNode> {\n return {\n x: scalePosition ? node.x * scale : node.x,\n y: scalePosition ? node.y * scale : node.y,\n width: node.width * scale,\n height: node.height * scale,\n minWidth: scaledOptional(node.minWidth, scale),\n maxWidth: scaledOptional(node.maxWidth, scale),\n minHeight: scaledOptional(node.minHeight, scale),\n maxHeight: scaledOptional(node.maxHeight, scale),\n cornerRadius: node.cornerRadius * scale,\n topLeftRadius: node.topLeftRadius * scale,\n topRightRadius: node.topRightRadius * scale,\n bottomRightRadius: node.bottomRightRadius * scale,\n bottomLeftRadius: node.bottomLeftRadius * scale,\n fontSize: node.fontSize * scale,\n letterSpacing: scaledTextLength(node.letterSpacing, scale),\n lineHeight: node.lineHeight && scaledTextLength(node.lineHeight, scale),\n textDecorationThickness: scaledOptional(node.textDecorationThickness, scale),\n textUnderlineOffset: scaledOptional(node.textUnderlineOffset, scale),\n styleRuns: scaledStyleRuns(node.styleRuns, scale),\n listSpacing: node.listSpacing * scale,\n paragraphSpacing: node.paragraphSpacing * scale,\n paragraphIndent: node.paragraphIndent * scale,\n textParagraphs: scaledParagraphStyles(node.textParagraphs, scale),\n derivedTextHeight: scaledOptional(node.derivedTextHeight, scale),\n itemSpacing: node.itemSpacing * scale,\n counterAxisSpacing: node.counterAxisSpacing * scale,\n paddingTop: node.paddingTop * scale,\n paddingRight: node.paddingRight * scale,\n paddingBottom: node.paddingBottom * scale,\n paddingLeft: node.paddingLeft * scale,\n gridColumnGap: node.gridColumnGap * scale,\n gridRowGap: node.gridRowGap * scale,\n gridTemplateColumns: scaledGridTracks(node.gridTemplateColumns, scale),\n gridTemplateRows: scaledGridTracks(node.gridTemplateRows, scale),\n strokes: scaledStrokes(node.strokes, scale),\n strokeWeight: node.strokeWeight * scale,\n dashPattern: node.dashPattern.map((value) => value * scale),\n borderTopWeight: node.borderTopWeight * scale,\n borderRightWeight: node.borderRightWeight * scale,\n borderBottomWeight: node.borderBottomWeight * scale,\n borderLeftWeight: node.borderLeftWeight * scale,\n strokeMiterLimit: node.strokeMiterLimit,\n effects: scaledEffects(node.effects, scale),\n fills: scaledFills(node.fills, scale),\n layoutGrids: scaledLayoutGrids(node.layoutGrids, scale),\n vectorNetwork: scaledVectorNetwork(node, scale),\n fillGeometry: scaleGeometryPaths(node.fillGeometry, scale, scale),\n strokeGeometry: scaleGeometryPaths(node.strokeGeometry, scale, scale),\n ...scaledPathText(node, scale)\n }\n}\n"],"mappings":";;;;;;AAgBA,SAAS,eAAe,MAAiB,OAAmC;CAC1E,IAAI,CAAC,KAAK,gBAAgB,CAAC,YAAY,IAAI,GACzC,OAAO,CAAC;CAEV,MAAM,MAAM,KAAK;CACjB,OAAO;EACL,mBACE,kBAAkB,KAAK,iBAAiB,CAAC,EAAE,KAAK,WAAW;GACzD,GAAG;GACH,GAAG,MAAM,IAAI;GACb,GAAG,MAAM,IAAI;GACb,UAAU,MAAM,WAAW;GAC3B,GAAI,MAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,MAAM,UAAU,MAAM;EAC1E,EAAE,KAAK;EACT,aAAa,OAAO;GAClB,GAAG,IAAI,IAAI;GACX,GAAG,IAAI,IAAI;GACX,OAAO,IAAI,QAAQ;GACnB,QAAQ,IAAI,SAAS;EACvB;CACF;AACF;AAEA,SAAS,eAAe,OAAsB,OAA8B;CAC1E,OAAO,SAAS,OAAO,OAAO,QAAQ;AACxC;AAEA,SAAS,cAAc,SAA4B,OAAyB;CAC1E,OAAO,QAAQ,KAAK,YAAY;EAC9B,GAAG,gBAAgB,MAAM;EACzB,QAAQ,OAAO,SAAS;EACxB,aAAa,OAAO,aAAa,KAAK,UAAU,QAAQ,KAAK;CAC/D,EAAE;AACJ;AAEA,SAAS,cAAc,SAA4B,OAAyB;CAC1E,OAAO,QAAQ,KAAK,WAAW;EAC7B,MAAM,OAAO,gBAAgB,MAAM;EAEnC,IAAI,KAAK,SAAS,UAAU,OAAO;EACnC,KAAK,SAAS;GAAE,GAAG,KAAK,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M,KAAK;CAC/B;AACF"}
1
+ {"version":3,"file":"node.js","names":[],"sources":["../../src/scaling/node.ts"],"sourcesContent":["import { copyDerivedGlyphs, scaleGeometryPaths } from '../copy'\nimport { scaledTextLength } from '../text/lengths'\nimport { TEXT_PARAGRAPH_SPACING_FIELDS } from '../text/paragraphs'\nimport { followsPath } from '../text/path'\nimport {\n type Effect,\n type Fill,\n type GridTrack,\n type LayoutGrid,\n type SceneNode,\n type Stroke,\n type StyleRun,\n type TextParagraphStyle\n} from '../types'\nimport { cloneVectorNetwork } from '../vector-network'\n\nfunction scaledPathText(node: SceneNode, scale: number): Partial<SceneNode> {\n if (!node.textPathData && !followsPath(node)) {\n return {}\n }\n const box = node.textPathBox\n return {\n derivedTextGlyphs:\n copyDerivedGlyphs(node.derivedTextGlyphs)?.map((glyph) => ({\n ...glyph,\n x: glyph.x * scale,\n y: glyph.y * scale,\n fontSize: glyph.fontSize * scale,\n ...(glyph.advance === undefined ? {} : { advance: glyph.advance * scale })\n })) ?? null,\n textPathBox: box && {\n x: box.x * scale,\n y: box.y * scale,\n width: box.width * scale,\n height: box.height * scale\n }\n }\n}\n\nfunction scaledOptional(value: number | null, scale: number): number | null {\n return value == null ? null : value * scale\n}\n\nfunction scaledStrokes(strokes: readonly Stroke[], scale: number): Stroke[] {\n return strokes.map((stroke) => ({\n ...structuredClone(stroke),\n weight: stroke.weight * scale,\n dashPattern: stroke.dashPattern?.map((value) => value * scale)\n }))\n}\n\nfunction scaledEffects(effects: readonly Effect[], scale: number): Effect[] {\n return effects.map((effect) => {\n const copy = structuredClone(effect)\n // A shader effect has no geometry of its own, and a noise's grain keeps its size.\n if (copy.type === 'SHADER' || copy.type === 'NOISE') return copy\n // A texture roughens the edges by its radius; its grain keeps its size too.\n if (copy.type === 'TEXTURE') {\n copy.radius *= scale\n return copy\n }\n copy.offset = { x: copy.offset.x * scale, y: copy.offset.y * scale }\n copy.radius *= scale\n copy.spread *= scale\n return copy\n })\n}\n\nfunction scaledFills(fills: readonly Fill[], scale: number): Fill[] {\n return fills.map((fill) => ({\n ...structuredClone(fill),\n scale: fill.scale == null ? undefined : fill.scale * scale,\n spacing: fill.spacing == null ? undefined : fill.spacing * scale,\n patternSpacing: fill.patternSpacing\n ? { x: fill.patternSpacing.x * scale, y: fill.patternSpacing.y * scale }\n : undefined,\n noiseSize: fill.noiseSize\n ? { x: fill.noiseSize.x * scale, y: fill.noiseSize.y * scale }\n : undefined\n }))\n}\n\nfunction scaledStyleRuns(styleRuns: readonly StyleRun[], scale: number): StyleRun[] {\n return styleRuns.map((run) => ({\n ...structuredClone(run),\n style: {\n ...structuredClone(run.style),\n fontSize: run.style.fontSize == null ? undefined : run.style.fontSize * scale,\n letterSpacing: run.style.letterSpacing && scaledTextLength(run.style.letterSpacing, scale),\n lineHeight: run.style.lineHeight && scaledTextLength(run.style.lineHeight, scale),\n textDecorationThickness: scaledOptional(run.style.textDecorationThickness ?? null, scale),\n textUnderlineOffset: scaledOptional(run.style.textUnderlineOffset ?? null, scale)\n }\n }))\n}\n\nfunction scaledParagraphStyles(\n paragraphs: readonly TextParagraphStyle[],\n scale: number\n): TextParagraphStyle[] {\n return paragraphs.map((style) => {\n const scaled = { ...style }\n for (const field of TEXT_PARAGRAPH_SPACING_FIELDS) {\n const value = style[field]\n if (value !== undefined) scaled[field] = value * scale\n }\n return scaled\n })\n}\n\nfunction scaledLayoutGrids(grids: readonly LayoutGrid[], scale: number): LayoutGrid[] {\n return grids.map((grid) => ({\n ...structuredClone(grid),\n offset: grid.offset == null ? undefined : grid.offset * scale,\n sectionSize: grid.sectionSize == null ? undefined : grid.sectionSize * scale,\n gutterSize: grid.gutterSize == null ? undefined : grid.gutterSize * scale\n }))\n}\n\nfunction scaledGridTracks(tracks: readonly GridTrack[], scale: number): GridTrack[] {\n return tracks.map((track) => ({\n ...track,\n value: track.sizing === 'FIXED' ? track.value * scale : track.value\n }))\n}\n\nfunction scaledVectorNetwork(node: SceneNode, scale: number): SceneNode['vectorNetwork'] {\n if (!node.vectorNetwork) return null\n const network = cloneVectorNetwork(node.vectorNetwork)\n for (const vertex of network.vertices) {\n vertex.x *= scale\n vertex.y *= scale\n }\n for (const segment of network.segments) {\n segment.tangentStart.x *= scale\n segment.tangentStart.y *= scale\n segment.tangentEnd.x *= scale\n segment.tangentEnd.y *= scale\n }\n return network\n}\n\nexport function scaleNodeChanges(\n node: SceneNode,\n scale: number,\n scalePosition: boolean\n): Partial<SceneNode> {\n return {\n x: scalePosition ? node.x * scale : node.x,\n y: scalePosition ? node.y * scale : node.y,\n width: node.width * scale,\n height: node.height * scale,\n minWidth: scaledOptional(node.minWidth, scale),\n maxWidth: scaledOptional(node.maxWidth, scale),\n minHeight: scaledOptional(node.minHeight, scale),\n maxHeight: scaledOptional(node.maxHeight, scale),\n cornerRadius: node.cornerRadius * scale,\n topLeftRadius: node.topLeftRadius * scale,\n topRightRadius: node.topRightRadius * scale,\n bottomRightRadius: node.bottomRightRadius * scale,\n bottomLeftRadius: node.bottomLeftRadius * scale,\n fontSize: node.fontSize * scale,\n letterSpacing: scaledTextLength(node.letterSpacing, scale),\n lineHeight: node.lineHeight && scaledTextLength(node.lineHeight, scale),\n textDecorationThickness: scaledOptional(node.textDecorationThickness, scale),\n textUnderlineOffset: scaledOptional(node.textUnderlineOffset, scale),\n styleRuns: scaledStyleRuns(node.styleRuns, scale),\n listSpacing: node.listSpacing * scale,\n paragraphSpacing: node.paragraphSpacing * scale,\n paragraphIndent: node.paragraphIndent * scale,\n textParagraphs: scaledParagraphStyles(node.textParagraphs, scale),\n derivedTextHeight: scaledOptional(node.derivedTextHeight, scale),\n itemSpacing: node.itemSpacing * scale,\n counterAxisSpacing: node.counterAxisSpacing * scale,\n paddingTop: node.paddingTop * scale,\n paddingRight: node.paddingRight * scale,\n paddingBottom: node.paddingBottom * scale,\n paddingLeft: node.paddingLeft * scale,\n gridColumnGap: node.gridColumnGap * scale,\n gridRowGap: node.gridRowGap * scale,\n gridTemplateColumns: scaledGridTracks(node.gridTemplateColumns, scale),\n gridTemplateRows: scaledGridTracks(node.gridTemplateRows, scale),\n strokes: scaledStrokes(node.strokes, scale),\n strokeWeight: node.strokeWeight * scale,\n dashPattern: node.dashPattern.map((value) => value * scale),\n borderTopWeight: node.borderTopWeight * scale,\n borderRightWeight: node.borderRightWeight * scale,\n borderBottomWeight: node.borderBottomWeight * scale,\n borderLeftWeight: node.borderLeftWeight * scale,\n strokeMiterLimit: node.strokeMiterLimit,\n effects: scaledEffects(node.effects, scale),\n fills: scaledFills(node.fills, scale),\n layoutGrids: scaledLayoutGrids(node.layoutGrids, scale),\n vectorNetwork: scaledVectorNetwork(node, scale),\n fillGeometry: scaleGeometryPaths(node.fillGeometry, scale, scale),\n strokeGeometry: scaleGeometryPaths(node.strokeGeometry, scale, scale),\n ...scaledPathText(node, scale)\n }\n}\n"],"mappings":";;;;;;AAgBA,SAAS,eAAe,MAAiB,OAAmC;CAC1E,IAAI,CAAC,KAAK,gBAAgB,CAAC,YAAY,IAAI,GACzC,OAAO,CAAC;CAEV,MAAM,MAAM,KAAK;CACjB,OAAO;EACL,mBACE,kBAAkB,KAAK,iBAAiB,CAAC,EAAE,KAAK,WAAW;GACzD,GAAG;GACH,GAAG,MAAM,IAAI;GACb,GAAG,MAAM,IAAI;GACb,UAAU,MAAM,WAAW;GAC3B,GAAI,MAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,MAAM,UAAU,MAAM;EAC1E,EAAE,KAAK;EACT,aAAa,OAAO;GAClB,GAAG,IAAI,IAAI;GACX,GAAG,IAAI,IAAI;GACX,OAAO,IAAI,QAAQ;GACnB,QAAQ,IAAI,SAAS;EACvB;CACF;AACF;AAEA,SAAS,eAAe,OAAsB,OAA8B;CAC1E,OAAO,SAAS,OAAO,OAAO,QAAQ;AACxC;AAEA,SAAS,cAAc,SAA4B,OAAyB;CAC1E,OAAO,QAAQ,KAAK,YAAY;EAC9B,GAAG,gBAAgB,MAAM;EACzB,QAAQ,OAAO,SAAS;E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