@open-pencil/scene-graph 0.17.0-beta.1 → 0.17.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/dist/arrow-caps.d.ts.map +1 -1
  2. package/dist/arrow-caps.js +2 -5
  3. package/dist/arrow-caps.js.map +1 -1
  4. package/dist/asset-keys.d.ts +11 -1
  5. package/dist/asset-keys.d.ts.map +1 -1
  6. package/dist/asset-keys.js +16 -1
  7. package/dist/asset-keys.js.map +1 -1
  8. package/dist/behaviours/index.d.ts +2 -2
  9. package/dist/behaviours/index.js +2 -2
  10. package/dist/behaviours/kinds.d.ts +11 -5
  11. package/dist/behaviours/kinds.d.ts.map +1 -1
  12. package/dist/behaviours/kinds.js +76 -75
  13. package/dist/behaviours/kinds.js.map +1 -1
  14. package/dist/behaviours/layers.d.ts.map +1 -1
  15. package/dist/behaviours/layers.js +3 -2
  16. package/dist/behaviours/layers.js.map +1 -1
  17. package/dist/behaviours/model.d.ts +7 -4
  18. package/dist/behaviours/model.d.ts.map +1 -1
  19. package/dist/behaviours/model.js +16 -9
  20. package/dist/behaviours/model.js.map +1 -1
  21. package/dist/behaviours/schema.d.ts +118 -4
  22. package/dist/behaviours/schema.d.ts.map +1 -1
  23. package/dist/behaviours/schema.js +18 -3
  24. package/dist/behaviours/schema.js.map +1 -1
  25. package/dist/behaviours/spec.d.ts.map +1 -1
  26. package/dist/behaviours/spec.js +3 -2
  27. package/dist/behaviours/spec.js.map +1 -1
  28. package/dist/bindings.js +9 -1
  29. package/dist/bindings.js.map +1 -1
  30. package/dist/checkpoint.d.ts +31 -2
  31. package/dist/checkpoint.d.ts.map +1 -1
  32. package/dist/checkpoint.js +211 -10
  33. package/dist/checkpoint.js.map +1 -1
  34. package/dist/components/index.d.ts +3 -3
  35. package/dist/components/index.js +3 -3
  36. package/dist/components/properties.d.ts +18 -1
  37. package/dist/components/properties.d.ts.map +1 -1
  38. package/dist/components/properties.js +66 -3
  39. package/dist/components/properties.js.map +1 -1
  40. package/dist/components/variants.d.ts +16 -10
  41. package/dist/components/variants.d.ts.map +1 -1
  42. package/dist/components/variants.js +39 -13
  43. package/dist/components/variants.js.map +1 -1
  44. package/dist/connectors/hit.d.ts.map +1 -1
  45. package/dist/connectors/hit.js +1 -7
  46. package/dist/connectors/hit.js.map +1 -1
  47. package/dist/connectors/pieces.d.ts.map +1 -1
  48. package/dist/connectors/pieces.js +2 -5
  49. package/dist/connectors/pieces.js.map +1 -1
  50. package/dist/constants.d.ts +6 -1
  51. package/dist/constants.d.ts.map +1 -1
  52. package/dist/constants.js +17 -1
  53. package/dist/constants.js.map +1 -1
  54. package/dist/constraints.d.ts +25 -0
  55. package/dist/constraints.d.ts.map +1 -0
  56. package/dist/constraints.js +51 -0
  57. package/dist/constraints.js.map +1 -0
  58. package/dist/coordinate.d.ts +64 -1
  59. package/dist/coordinate.d.ts.map +1 -1
  60. package/dist/coordinate.js +217 -1
  61. package/dist/coordinate.js.map +1 -1
  62. package/dist/copy.d.ts.map +1 -1
  63. package/dist/copy.js +17 -16
  64. package/dist/copy.js.map +1 -1
  65. package/dist/css/blend.d.ts +11 -0
  66. package/dist/css/blend.d.ts.map +1 -0
  67. package/dist/css/blend.js +30 -0
  68. package/dist/css/blend.js.map +1 -0
  69. package/dist/css/index.d.ts +4 -2
  70. package/dist/css/index.js +4 -2
  71. package/dist/css/text.d.ts +28 -1
  72. package/dist/css/text.d.ts.map +1 -1
  73. package/dist/css/text.js +84 -17
  74. package/dist/css/text.js.map +1 -1
  75. package/dist/css/transform.d.ts +34 -0
  76. package/dist/css/transform.d.ts.map +1 -0
  77. package/dist/css/transform.js +320 -0
  78. package/dist/css/transform.js.map +1 -0
  79. package/dist/css/values.d.ts.map +1 -1
  80. package/dist/css/values.js +11 -1
  81. package/dist/css/values.js.map +1 -1
  82. package/dist/cubic.d.ts +7 -0
  83. package/dist/cubic.d.ts.map +1 -0
  84. package/dist/cubic.js +17 -0
  85. package/dist/cubic.js.map +1 -0
  86. package/dist/export-format.d.ts +14 -1
  87. package/dist/export-format.d.ts.map +1 -1
  88. package/dist/export-format.js +26 -1
  89. package/dist/export-format.js.map +1 -1
  90. package/dist/fields/text.d.ts +2 -2
  91. package/dist/fields/text.d.ts.map +1 -1
  92. package/dist/fields/text.js +2 -1
  93. package/dist/fields/text.js.map +1 -1
  94. package/dist/figjam/index.d.ts +2 -2
  95. package/dist/figjam/index.js +2 -2
  96. package/dist/figjam/palette.d.ts +13 -2
  97. package/dist/figjam/palette.d.ts.map +1 -1
  98. package/dist/figjam/palette.js +30 -2
  99. package/dist/figjam/palette.js.map +1 -1
  100. package/dist/generated/index.d.ts +2 -2
  101. package/dist/generated/index.js +2 -2
  102. package/dist/generated/shape-with-text.d.ts +7 -2
  103. package/dist/generated/shape-with-text.d.ts.map +1 -1
  104. package/dist/generated/shape-with-text.js +20 -3
  105. package/dist/generated/shape-with-text.js.map +1 -1
  106. package/dist/geometry.d.ts +37 -46
  107. package/dist/geometry.d.ts.map +1 -1
  108. package/dist/geometry.js +80 -137
  109. package/dist/geometry.js.map +1 -1
  110. package/dist/graph.d.ts +49 -12
  111. package/dist/graph.d.ts.map +1 -1
  112. package/dist/graph.js +125 -27
  113. package/dist/graph.js.map +1 -1
  114. package/dist/group-bounds.d.ts +14 -4
  115. package/dist/group-bounds.d.ts.map +1 -1
  116. package/dist/group-bounds.js +76 -11
  117. package/dist/group-bounds.js.map +1 -1
  118. package/dist/guides.d.ts +3 -1
  119. package/dist/guides.d.ts.map +1 -1
  120. package/dist/guides.js +5 -1
  121. package/dist/guides.js.map +1 -1
  122. package/dist/hit-test.d.ts +5 -0
  123. package/dist/hit-test.d.ts.map +1 -1
  124. package/dist/hit-test.js +57 -38
  125. package/dist/hit-test.js.map +1 -1
  126. package/dist/images.d.ts +27 -3
  127. package/dist/images.d.ts.map +1 -1
  128. package/dist/images.js +57 -3
  129. package/dist/images.js.map +1 -1
  130. package/dist/index.d.ts +2 -2
  131. package/dist/instances/fields.d.ts +2 -2
  132. package/dist/instances/fields.d.ts.map +1 -1
  133. package/dist/instances/fields.js +8 -0
  134. package/dist/instances/fields.js.map +1 -1
  135. package/dist/instances/index.d.ts +1 -3
  136. package/dist/instances/index.d.ts.map +1 -1
  137. package/dist/instances/index.js +39 -30
  138. package/dist/instances/index.js.map +1 -1
  139. package/dist/instances/kept-overrides.js +204 -0
  140. package/dist/instances/kept-overrides.js.map +1 -0
  141. package/dist/instances/main-component.d.ts +3 -1
  142. package/dist/instances/main-component.d.ts.map +1 -1
  143. package/dist/instances/main-component.js +10 -2
  144. package/dist/instances/main-component.js.map +1 -1
  145. package/dist/instances/overrides.d.ts +4 -1
  146. package/dist/instances/overrides.d.ts.map +1 -1
  147. package/dist/instances/overrides.js +18 -2
  148. package/dist/instances/overrides.js.map +1 -1
  149. package/dist/instances/placement.js +55 -12
  150. package/dist/instances/placement.js.map +1 -1
  151. package/dist/instances/swap.js +291 -0
  152. package/dist/instances/swap.js.map +1 -0
  153. package/dist/instances/sync.js +112 -39
  154. package/dist/instances/sync.js.map +1 -1
  155. package/dist/node-defaults.d.ts.map +1 -1
  156. package/dist/node-defaults.js +2 -1
  157. package/dist/node-defaults.js.map +1 -1
  158. package/dist/order-keys.d.ts +3 -1
  159. package/dist/order-keys.d.ts.map +1 -1
  160. package/dist/order-keys.js +6 -1
  161. package/dist/order-keys.js.map +1 -1
  162. package/dist/outline/flatten.d.ts +15 -0
  163. package/dist/outline/flatten.d.ts.map +1 -0
  164. package/dist/outline/flatten.js +189 -0
  165. package/dist/outline/flatten.js.map +1 -0
  166. package/dist/outline/heads.js +34 -0
  167. package/dist/outline/heads.js.map +1 -0
  168. package/dist/outline/hit.d.ts +21 -0
  169. package/dist/outline/hit.d.ts.map +1 -0
  170. package/dist/outline/hit.js +276 -0
  171. package/dist/outline/hit.js.map +1 -0
  172. package/dist/outline/index.d.ts +5 -0
  173. package/dist/outline/index.js +5 -0
  174. package/dist/outline/point.d.ts +16 -0
  175. package/dist/outline/point.d.ts.map +1 -0
  176. package/dist/outline/point.js +42 -0
  177. package/dist/outline/point.js.map +1 -0
  178. package/dist/outline/shapes.d.ts +35 -0
  179. package/dist/outline/shapes.d.ts.map +1 -0
  180. package/dist/outline/shapes.js +181 -0
  181. package/dist/outline/shapes.js.map +1 -0
  182. package/dist/plugin-data/fields.d.ts +4 -1
  183. package/dist/plugin-data/fields.d.ts.map +1 -1
  184. package/dist/plugin-data/fields.js +21 -4
  185. package/dist/plugin-data/fields.js.map +1 -1
  186. package/dist/resize.d.ts +22 -11
  187. package/dist/resize.d.ts.map +1 -1
  188. package/dist/resize.js +227 -93
  189. package/dist/resize.js.map +1 -1
  190. package/dist/scaling/index.d.ts +3 -2
  191. package/dist/scaling/index.js +3 -2
  192. package/dist/scaling/node.d.ts.map +1 -1
  193. package/dist/scaling/node.js +5 -1
  194. package/dist/scaling/node.js.map +1 -1
  195. package/dist/scaling/snapshot.d.ts +25 -0
  196. package/dist/scaling/snapshot.d.ts.map +1 -0
  197. package/dist/scaling/snapshot.js +39 -0
  198. package/dist/scaling/snapshot.js.map +1 -0
  199. package/dist/scaling/tree.d.ts +24 -2
  200. package/dist/scaling/tree.d.ts.map +1 -1
  201. package/dist/scaling/tree.js +38 -15
  202. package/dist/scaling/tree.js.map +1 -1
  203. package/dist/shaders/model.d.ts.map +1 -1
  204. package/dist/shaders/model.js +2 -1
  205. package/dist/shaders/model.js.map +1 -1
  206. package/dist/shared-styles.d.ts +16 -1
  207. package/dist/shared-styles.d.ts.map +1 -1
  208. package/dist/shared-styles.js +69 -2
  209. package/dist/shared-styles.js.map +1 -1
  210. package/dist/slots/authoring.d.ts +3 -2
  211. package/dist/slots/authoring.d.ts.map +1 -1
  212. package/dist/slots/authoring.js +5 -3
  213. package/dist/slots/authoring.js.map +1 -1
  214. package/dist/slots/content.d.ts.map +1 -1
  215. package/dist/slots/content.js +6 -1
  216. package/dist/slots/content.js.map +1 -1
  217. package/dist/slots/frames.d.ts +2 -0
  218. package/dist/slots/frames.d.ts.map +1 -1
  219. package/dist/slots/frames.js +7 -2
  220. package/dist/slots/frames.js.map +1 -1
  221. package/dist/text/direction.d.ts +3 -1
  222. package/dist/text/direction.d.ts.map +1 -1
  223. package/dist/text/direction.js +5 -1
  224. package/dist/text/direction.js.map +1 -1
  225. package/dist/text/index.d.ts +2 -2
  226. package/dist/text/index.js +3 -3
  227. package/dist/text/lengths.d.ts +6 -1
  228. package/dist/text/lengths.d.ts.map +1 -1
  229. package/dist/text/lengths.js +10 -1
  230. package/dist/text/lengths.js.map +1 -1
  231. package/dist/text/overflow.d.ts +2 -2
  232. package/dist/text/overflow.js.map +1 -1
  233. package/dist/text/picture.d.ts +1 -2
  234. package/dist/text/picture.d.ts.map +1 -1
  235. package/dist/text/picture.js +1 -4
  236. package/dist/text/picture.js.map +1 -1
  237. package/dist/transfer/apply.d.ts.map +1 -1
  238. package/dist/transfer/apply.js +1 -6
  239. package/dist/transfer/apply.js.map +1 -1
  240. package/dist/transfer/copied.d.ts +35 -3
  241. package/dist/transfer/copied.d.ts.map +1 -1
  242. package/dist/transfer/copied.js +44 -13
  243. package/dist/transfer/copied.js.map +1 -1
  244. package/dist/transfer/dependencies.d.ts +38 -0
  245. package/dist/transfer/dependencies.d.ts.map +1 -0
  246. package/dist/transfer/dependencies.js +100 -0
  247. package/dist/transfer/dependencies.js.map +1 -0
  248. package/dist/transfer/history.js +0 -1
  249. package/dist/transfer/history.js.map +1 -1
  250. package/dist/transfer/index.d.ts +5 -3
  251. package/dist/transfer/index.js +5 -3
  252. package/dist/transfer/nodes.d.ts.map +1 -1
  253. package/dist/transfer/nodes.js +16 -19
  254. package/dist/transfer/nodes.js.map +1 -1
  255. package/dist/transfer/plan.d.ts +0 -1
  256. package/dist/transfer/plan.js +3 -5
  257. package/dist/transfer/plan.js.map +1 -1
  258. package/dist/transfer/remove.js +5 -2
  259. package/dist/transfer/remove.js.map +1 -1
  260. package/dist/transfer/resources.d.ts +21 -0
  261. package/dist/transfer/resources.d.ts.map +1 -0
  262. package/dist/transfer/resources.js +38 -0
  263. package/dist/transfer/resources.js.map +1 -0
  264. package/dist/transfer/variables.d.ts +8 -1
  265. package/dist/transfer/variables.d.ts.map +1 -1
  266. package/dist/transfer/variables.js +24 -1
  267. package/dist/transfer/variables.js.map +1 -1
  268. package/dist/types.d.ts +73 -2
  269. package/dist/types.d.ts.map +1 -1
  270. package/dist/types.js.map +1 -1
  271. package/dist/undo.d.ts +28 -3
  272. package/dist/undo.d.ts.map +1 -1
  273. package/dist/undo.js +24 -7
  274. package/dist/undo.js.map +1 -1
  275. package/dist/variables/bindings.d.ts +37 -11
  276. package/dist/variables/bindings.d.ts.map +1 -1
  277. package/dist/variables/bindings.js +122 -74
  278. package/dist/variables/bindings.js.map +1 -1
  279. package/dist/variables/fields.d.ts +19 -1
  280. package/dist/variables/fields.d.ts.map +1 -1
  281. package/dist/variables/fields.js +36 -1
  282. package/dist/variables/fields.js.map +1 -1
  283. package/dist/variables/formula/check.d.ts +1 -1
  284. package/dist/variables/formula/index.d.ts +2 -2
  285. package/dist/variables/formula/index.js +1 -1
  286. package/dist/variables/formula/index.js.map +1 -1
  287. package/dist/variables/formula/print.d.ts +1 -1
  288. package/dist/variables/formula/signatures.js +1 -1
  289. package/dist/variables/index.d.ts +7 -7
  290. package/dist/variables/index.d.ts.map +1 -1
  291. package/dist/variables/index.js +57 -26
  292. package/dist/variables/index.js.map +1 -1
  293. package/dist/variables/paints.d.ts +57 -0
  294. package/dist/variables/paints.d.ts.map +1 -0
  295. package/dist/variables/paints.js +231 -0
  296. package/dist/variables/paints.js.map +1 -0
  297. package/dist/variables/resolution.d.ts +14 -11
  298. package/dist/variables/resolution.d.ts.map +1 -1
  299. package/dist/variables/resolution.js +36 -17
  300. package/dist/variables/resolution.js.map +1 -1
  301. package/dist/variables/subtree.js +17 -0
  302. package/dist/variables/subtree.js.map +1 -0
  303. package/dist/vector-network.d.ts.map +1 -1
  304. package/dist/vector-network.js +2 -8
  305. package/dist/vector-network.js.map +1 -1
  306. package/package.json +14 -1
  307. package/src/arrow-caps.ts +2 -5
  308. package/src/asset-keys.ts +20 -0
  309. package/src/behaviours/kinds.ts +51 -34
  310. package/src/behaviours/layers.ts +4 -2
  311. package/src/behaviours/model.ts +22 -11
  312. package/src/behaviours/schema.ts +20 -4
  313. package/src/behaviours/spec.ts +8 -2
  314. package/src/bindings.ts +11 -2
  315. package/src/checkpoint.ts +319 -17
  316. package/src/components/properties.ts +101 -2
  317. package/src/components/variants.ts +51 -30
  318. package/src/connectors/hit.ts +1 -12
  319. package/src/connectors/pieces.ts +2 -5
  320. package/src/constants.ts +17 -0
  321. package/src/constraints.ts +60 -0
  322. package/src/coordinate.ts +220 -0
  323. package/src/copy.ts +18 -19
  324. package/src/css/blend.ts +27 -0
  325. package/src/css/index.ts +18 -1
  326. package/src/css/text.ts +85 -17
  327. package/src/css/transform.ts +266 -0
  328. package/src/css/values.ts +8 -0
  329. package/src/cubic.ts +14 -0
  330. package/src/export-format.ts +29 -0
  331. package/src/fields/text.ts +3 -1
  332. package/src/figjam/palette.ts +29 -1
  333. package/src/generated/shape-with-text.ts +28 -2
  334. package/src/geometry.ts +97 -206
  335. package/src/graph.ts +155 -45
  336. package/src/group-bounds.ts +84 -17
  337. package/src/guides.ts +5 -0
  338. package/src/hit-test.ts +93 -64
  339. package/src/images.ts +71 -3
  340. package/src/instances/fields.ts +8 -0
  341. package/src/instances/index.ts +62 -31
  342. package/src/instances/kept-overrides.ts +280 -0
  343. package/src/instances/main-component.ts +12 -0
  344. package/src/instances/overrides.ts +27 -1
  345. package/src/instances/placement.ts +63 -10
  346. package/src/instances/swap.ts +456 -0
  347. package/src/instances/sync.ts +176 -50
  348. package/src/node-defaults.ts +3 -1
  349. package/src/order-keys.ts +6 -0
  350. package/src/outline/flatten.ts +190 -0
  351. package/src/outline/heads.ts +52 -0
  352. package/src/outline/hit.ts +369 -0
  353. package/src/outline/index.ts +4 -0
  354. package/src/outline/point.ts +59 -0
  355. package/src/outline/shapes.ts +207 -0
  356. package/src/plugin-data/fields.ts +21 -2
  357. package/src/resize.ts +267 -119
  358. package/src/scaling/index.ts +9 -1
  359. package/src/scaling/node.ts +9 -1
  360. package/src/scaling/snapshot.ts +51 -0
  361. package/src/scaling/tree.ts +63 -19
  362. package/src/shaders/model.ts +2 -3
  363. package/src/shared-styles.ts +90 -1
  364. package/src/slots/authoring.ts +5 -3
  365. package/src/slots/content.ts +6 -1
  366. package/src/slots/frames.ts +9 -7
  367. package/src/text/direction.ts +5 -0
  368. package/src/text/lengths.ts +10 -0
  369. package/src/text/overflow.ts +2 -2
  370. package/src/text/picture.ts +0 -4
  371. package/src/transfer/apply.ts +1 -13
  372. package/src/transfer/copied.ts +83 -15
  373. package/src/transfer/dependencies.ts +126 -0
  374. package/src/transfer/history.ts +0 -6
  375. package/src/transfer/index.ts +20 -2
  376. package/src/transfer/nodes.ts +17 -31
  377. package/src/transfer/plan.ts +3 -11
  378. package/src/transfer/remove.ts +5 -2
  379. package/src/transfer/resources.ts +54 -0
  380. package/src/transfer/variables.ts +34 -0
  381. package/src/types.ts +83 -1
  382. package/src/undo.ts +48 -10
  383. package/src/variables/bindings.ts +152 -88
  384. package/src/variables/fields.ts +46 -1
  385. package/src/variables/formula/index.ts +3 -1
  386. package/src/variables/index.ts +90 -39
  387. package/src/variables/paints.ts +296 -0
  388. package/src/variables/resolution.ts +39 -28
  389. package/src/variables/subtree.ts +15 -0
  390. package/src/vector-network.ts +4 -2
@@ -1 +1 @@
1
- {"version":3,"file":"remove.js","names":[],"sources":["../../src/transfer/remove.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { GraphTransferPlan } from './apply'\nimport { semanticTransferReferences } from './nodes'\n\n/** Refuse to remove transferred content that has acquired external dependents. */\nexport function removeGraphTransfer(graph: SceneGraph, plan: GraphTransferPlan): void {\n const nodes = new Set(plan.nodes.map((node) => node.id))\n const variables = new Set(plan.variables.map((variable) => variable.id))\n const collections = new Set(plan.collections.map((collection) => collection.id))\n const referencesOwned = (value: unknown): boolean => {\n if (typeof value === 'string')\n return nodes.has(value) || variables.has(value) || collections.has(value)\n if (!value || typeof value !== 'object' || ArrayBuffer.isView(value)) return false\n if (value instanceof Map)\n return [...value].some(([key, item]) => referencesOwned(key) || referencesOwned(item))\n return Object.values(value).some(referencesOwned)\n }\n for (const node of graph.getAllNodes()) {\n if (nodes.has(node.id)) {\n if (node.childIds.some((id) => !nodes.has(id)))\n throw new Error('Transferred node has non-owned children')\n continue\n }\n if (semanticTransferReferences(node).some(referencesOwned))\n throw new Error(`Transferred content is referenced by ${node.id}`)\n }\n for (const variable of graph.variables.values()) {\n if (!variables.has(variable.id) && referencesOwned(variable.valuesByMode))\n throw new Error('Transferred variable has external aliases')\n }\n graph.withBufferedEvents(() => {\n for (const node of plan.nodes.toReversed()) graph.deleteNode(node.id)\n for (const id of variables) graph.variables.delete(id)\n for (const id of collections) {\n graph.variableCollections.delete(id)\n graph.activeMode.delete(id)\n }\n })\n}\n"],"mappings":";;;AAKA,SAAgB,oBAAoB,OAAmB,MAA+B;CACpF,MAAM,QAAQ,IAAI,IAAI,KAAK,MAAM,KAAK,SAAS,KAAK,EAAE,CAAC;CACvD,MAAM,YAAY,IAAI,IAAI,KAAK,UAAU,KAAK,aAAa,SAAS,EAAE,CAAC;CACvE,MAAM,cAAc,IAAI,IAAI,KAAK,YAAY,KAAK,eAAe,WAAW,EAAE,CAAC;CAC/E,MAAM,mBAAmB,UAA4B;EACnD,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK;EAC1E,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,YAAY,OAAO,KAAK,GAAG,OAAO;EAC7E,IAAI,iBAAiB,KACnB,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,UAAU,gBAAgB,GAAG,KAAK,gBAAgB,IAAI,CAAC;EACvF,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,KAAK,eAAe;CAClD;CACA,KAAK,MAAM,QAAQ,MAAM,YAAY,GAAG;EACtC,IAAI,MAAM,IAAI,KAAK,EAAE,GAAG;GACtB,IAAI,KAAK,SAAS,MAAM,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,GAC3C,MAAM,IAAI,MAAM,yCAAyC;GAC3D;EACF;EACA,IAAI,2BAA2B,IAAI,CAAC,CAAC,KAAK,eAAe,GACvD,MAAM,IAAI,MAAM,wCAAwC,KAAK,IAAI;CACrE;CACA,KAAK,MAAM,YAAY,MAAM,UAAU,OAAO,GAC5C,IAAI,CAAC,UAAU,IAAI,SAAS,EAAE,KAAK,gBAAgB,SAAS,YAAY,GACtE,MAAM,IAAI,MAAM,2CAA2C;CAE/D,MAAM,yBAAyB;EAC7B,KAAK,MAAM,QAAQ,KAAK,MAAM,WAAW,GAAG,MAAM,WAAW,KAAK,EAAE;EACpE,KAAK,MAAM,MAAM,WAAW,MAAM,UAAU,OAAO,EAAE;EACrD,KAAK,MAAM,MAAM,aAAa;GAC5B,MAAM,oBAAoB,OAAO,EAAE;GACnC,MAAM,WAAW,OAAO,EAAE;EAC5B;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"remove.js","names":[],"sources":["../../src/transfer/remove.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { GraphTransferPlan } from './apply'\nimport { semanticTransferReferences } from './nodes'\n\n/** Refuse to remove transferred content that has acquired external dependents. */\nexport function removeGraphTransfer(graph: SceneGraph, plan: GraphTransferPlan): void {\n const nodes = new Set(plan.nodes.map((node) => node.id))\n const variables = new Set(plan.variables.map((variable) => variable.id))\n const collections = new Set(plan.collections.map((collection) => collection.id))\n const referencesOwned = (value: unknown): boolean => {\n if (typeof value === 'string')\n return nodes.has(value) || variables.has(value) || collections.has(value)\n if (!value || typeof value !== 'object' || ArrayBuffer.isView(value)) return false\n if (value instanceof Map)\n return [...value].some(([key, item]) => referencesOwned(key) || referencesOwned(item))\n return Object.values(value).some(referencesOwned)\n }\n for (const node of graph.getAllNodes()) {\n if (nodes.has(node.id)) {\n if (node.childIds.some((id) => !nodes.has(id)))\n throw new Error('Transferred node has non-owned children')\n continue\n }\n if (semanticTransferReferences(node).some(referencesOwned))\n throw new Error(`Transferred content is referenced by ${node.id}`)\n }\n for (const variable of graph.variables.values()) {\n if (!variables.has(variable.id) && referencesOwned(variable.valuesByMode))\n throw new Error('Transferred variable has external aliases')\n }\n graph.withBufferedEvents(() => {\n for (const node of plan.nodes.toReversed()) graph.deleteNode(node.id)\n for (const id of variables) {\n graph.willChangeVariable(id)\n graph.variables.delete(id)\n }\n for (const id of collections) {\n graph.willChangeCollection(id)\n graph.variableCollections.delete(id)\n }\n })\n}\n"],"mappings":";;;AAKA,SAAgB,oBAAoB,OAAmB,MAA+B;CACpF,MAAM,QAAQ,IAAI,IAAI,KAAK,MAAM,KAAK,SAAS,KAAK,EAAE,CAAC;CACvD,MAAM,YAAY,IAAI,IAAI,KAAK,UAAU,KAAK,aAAa,SAAS,EAAE,CAAC;CACvE,MAAM,cAAc,IAAI,IAAI,KAAK,YAAY,KAAK,eAAe,WAAW,EAAE,CAAC;CAC/E,MAAM,mBAAmB,UAA4B;EACnD,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK;EAC1E,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,YAAY,OAAO,KAAK,GAAG,OAAO;EAC7E,IAAI,iBAAiB,KACnB,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,UAAU,gBAAgB,GAAG,KAAK,gBAAgB,IAAI,CAAC;EACvF,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,KAAK,eAAe;CAClD;CACA,KAAK,MAAM,QAAQ,MAAM,YAAY,GAAG;EACtC,IAAI,MAAM,IAAI,KAAK,EAAE,GAAG;GACtB,IAAI,KAAK,SAAS,MAAM,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,GAC3C,MAAM,IAAI,MAAM,yCAAyC;GAC3D;EACF;EACA,IAAI,2BAA2B,IAAI,CAAC,CAAC,KAAK,eAAe,GACvD,MAAM,IAAI,MAAM,wCAAwC,KAAK,IAAI;CACrE;CACA,KAAK,MAAM,YAAY,MAAM,UAAU,OAAO,GAC5C,IAAI,CAAC,UAAU,IAAI,SAAS,EAAE,KAAK,gBAAgB,SAAS,YAAY,GACtE,MAAM,IAAI,MAAM,2CAA2C;CAE/D,MAAM,yBAAyB;EAC7B,KAAK,MAAM,QAAQ,KAAK,MAAM,WAAW,GAAG,MAAM,WAAW,KAAK,EAAE;EACpE,KAAK,MAAM,MAAM,WAAW;GAC1B,MAAM,mBAAmB,EAAE;GAC3B,MAAM,UAAU,OAAO,EAAE;EAC3B;EACA,KAAK,MAAM,MAAM,aAAa;GAC5B,MAAM,qBAAqB,EAAE;GAC7B,MAAM,oBAAoB,OAAO,EAAE;EACrC;CACF,CAAC;AACH"}
@@ -0,0 +1,21 @@
1
+ import { SceneNode } from "../types.js";
2
+ //#region src/transfer/resources.d.ts
3
+ /** How a layer's references to variables, collections, modes, and styles are renamed. */
4
+ interface ResourceReferences {
5
+ variable: (id: string) => string;
6
+ collection: (id: string) => string;
7
+ mode: (id: string) => string;
8
+ style: (id: string) => string;
9
+ /** The layer a text link names; links keep naming theirs without it. */
10
+ layer?: (id: string) => string;
11
+ }
12
+ /**
13
+ * `node`'s references to variables, collections, modes, and styles, renamed as a copy into
14
+ * another document renames them: its bindings, the modes it sets, the styles it and its text
15
+ * ranges and vector regions use. Only the fields that change are returned. Instance overrides
16
+ * name layers too, so their callers rename them with the layers.
17
+ */
18
+ declare function remappedResourceReferences(node: SceneNode, references: ResourceReferences): Partial<SceneNode>;
19
+ //#endregion
20
+ export { ResourceReferences, remappedResourceReferences };
21
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","names":[],"sources":["../../src/transfer/resources.ts"],"mappings":";;;UAOiB;EACf,WAAW;EACX,aAAa;EACb,OAAO;EACP,QAAQ;;EAER,SAAS;;;;;;;;iBASK,2BACd,MAAM,WACN,YAAY,qBACX,QAAQ"}
@@ -0,0 +1,38 @@
1
+ import { remapStyleRunReferences } from "../text/references.js";
2
+ import { STYLE_LINK_FIELDS } from "../shared-styles.js";
3
+ import { isEqual } from "es-toolkit";
4
+ //#region src/transfer/resources.ts
5
+ /**
6
+ * `node`'s references to variables, collections, modes, and styles, renamed as a copy into
7
+ * another document renames them: its bindings, the modes it sets, the styles it and its text
8
+ * ranges and vector regions use. Only the fields that change are returned. Instance overrides
9
+ * name layers too, so their callers rename them with the layers.
10
+ */
11
+ function remappedResourceReferences(node, references) {
12
+ const { variable, collection, mode, style, layer } = references;
13
+ const remapped = {
14
+ boundVariables: Object.fromEntries(Object.entries(node.boundVariables).map(([field, id]) => [field, variable(id)])),
15
+ variableModes: Object.fromEntries(Object.entries(node.variableModes).map(([id, modeId]) => [collection(id), mode(modeId)])),
16
+ styleRuns: remapStyleRunReferences(node.styleRuns, {
17
+ variable,
18
+ style,
19
+ node: layer
20
+ })
21
+ };
22
+ for (const field of STYLE_LINK_FIELDS) {
23
+ const id = node[field];
24
+ if (id) remapped[field] = style(id);
25
+ }
26
+ if (node.vectorNetwork?.regions.some((region) => region.fillStyleId)) remapped.vectorNetwork = {
27
+ ...node.vectorNetwork,
28
+ regions: node.vectorNetwork.regions.map((region) => region.fillStyleId ? {
29
+ ...region,
30
+ fillStyleId: style(region.fillStyleId)
31
+ } : region)
32
+ };
33
+ return Object.fromEntries(Object.entries(remapped).filter(([field, value]) => !isEqual(value, node[field])));
34
+ }
35
+ //#endregion
36
+ export { remappedResourceReferences };
37
+
38
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","names":[],"sources":["../../src/transfer/resources.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit'\n\nimport { STYLE_LINK_FIELDS } from '../shared-styles'\nimport { remapStyleRunReferences } from '../text/references'\nimport type { SceneNode } from '../types'\n\n/** How a layer's references to variables, collections, modes, and styles are renamed. */\nexport interface ResourceReferences {\n variable: (id: string) => string\n collection: (id: string) => string\n mode: (id: string) => string\n style: (id: string) => string\n /** The layer a text link names; links keep naming theirs without it. */\n layer?: (id: string) => string\n}\n\n/**\n * `node`'s references to variables, collections, modes, and styles, renamed as a copy into\n * another document renames them: its bindings, the modes it sets, the styles it and its text\n * ranges and vector regions use. Only the fields that change are returned. Instance overrides\n * name layers too, so their callers rename them with the layers.\n */\nexport function remappedResourceReferences(\n node: SceneNode,\n references: ResourceReferences\n): Partial<SceneNode> {\n const { variable, collection, mode, style, layer } = references\n const remapped: Partial<SceneNode> = {\n boundVariables: Object.fromEntries(\n Object.entries(node.boundVariables).map(([field, id]) => [field, variable(id)])\n ),\n variableModes: Object.fromEntries(\n Object.entries(node.variableModes).map(([id, modeId]) => [collection(id), mode(modeId)])\n ),\n styleRuns: remapStyleRunReferences(node.styleRuns, { variable, style, node: layer })\n }\n for (const field of STYLE_LINK_FIELDS) {\n const id = node[field]\n if (id) remapped[field] = style(id)\n }\n if (node.vectorNetwork?.regions.some((region) => region.fillStyleId)) {\n remapped.vectorNetwork = {\n ...node.vectorNetwork,\n regions: node.vectorNetwork.regions.map((region) =>\n region.fillStyleId ? { ...region, fillStyleId: style(region.fillStyleId) } : region\n )\n }\n }\n return Object.fromEntries(\n Object.entries(remapped).filter(\n ([field, value]) => !isEqual(value, node[field as keyof SceneNode])\n )\n )\n}\n"],"mappings":";;;;;;;;;;AAsBA,SAAgB,2BACd,MACA,YACoB;CACpB,MAAM,EAAE,UAAU,YAAY,MAAM,OAAO,UAAU;CACrD,MAAM,WAA+B;EACnC,gBAAgB,OAAO,YACrB,OAAO,QAAQ,KAAK,cAAc,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,OAAO,SAAS,EAAE,CAAC,CAAC,CAChF;EACA,eAAe,OAAO,YACpB,OAAO,QAAQ,KAAK,aAAa,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,WAAW,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC,CACzF;EACA,WAAW,wBAAwB,KAAK,WAAW;GAAE;GAAU;GAAO,MAAM;EAAM,CAAC;CACrF;CACA,KAAK,MAAM,SAAS,mBAAmB;EACrC,MAAM,KAAK,KAAK;EAChB,IAAI,IAAI,SAAS,SAAS,MAAM,EAAE;CACpC;CACA,IAAI,KAAK,eAAe,QAAQ,MAAM,WAAW,OAAO,WAAW,GACjE,SAAS,gBAAgB;EACvB,GAAG,KAAK;EACR,SAAS,KAAK,cAAc,QAAQ,KAAK,WACvC,OAAO,cAAc;GAAE,GAAG;GAAQ,aAAa,MAAM,OAAO,WAAW;EAAE,IAAI,MAC/E;CACF;CAEF,OAAO,OAAO,YACZ,OAAO,QAAQ,QAAQ,CAAC,CAAC,QACtB,CAAC,OAAO,WAAW,CAAC,QAAQ,OAAO,KAAK,MAAyB,CACpE,CACF;AACF"}
@@ -1,3 +1,4 @@
1
+ import { SceneGraph } from "../graph.js";
1
2
  import { Variable, VariableCollection } from "../types.js";
2
3
  //#region src/transfer/variables.d.ts
3
4
  interface VariableTransferReferences {
@@ -10,6 +11,12 @@ declare function prepareVariableTransfer(variables: readonly Variable[], collect
10
11
  variables: Variable[];
11
12
  collections: VariableCollection[];
12
13
  };
14
+ /**
15
+ * Copies the variables `ids` and the collections `collectionIds` into `target`, IDs kept. Each
16
+ * collection comes from the first of its `sources` that has it, and its variables with it; a
17
+ * variable it lacks there comes from the next. A collection keeps only the variables copied.
18
+ */
19
+ declare function copyVariableTables(target: SceneGraph, ids: ReadonlySet<string>, collectionIds: Iterable<string>, sources: (collectionId: string) => readonly SceneGraph[]): void;
13
20
  //#endregion
14
- export { VariableTransferReferences, prepareVariableTransfer };
21
+ export { VariableTransferReferences, copyVariableTables, prepareVariableTransfer };
15
22
  //# sourceMappingURL=variables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"variables.d.ts","names":[],"sources":["../../src/transfer/variables.ts"],"mappings":";;UAIiB;EACf,WAAW;EACX,aAAa;EACb,OAAO;;;iBAqCO,wBACd,oBAAoB,YACpB,sBAAsB,sBACtB,YAAY;EACT,WAAW;EAAY,aAAa"}
1
+ {"version":3,"file":"variables.d.ts","names":[],"sources":["../../src/transfer/variables.ts"],"mappings":";;;UAOiB;EACf,WAAW;EACX,aAAa;EACb,OAAO;;;iBAqCO,wBACd,oBAAoB,YACpB,sBAAsB,sBACtB,YAAY;EACT,WAAW;EAAY,aAAa;;;;;;;iBAyCzB,mBACd,QAAQ,YACR,KAAK,qBACL,eAAe,kBACf,UAAU,kCAAkC"}
@@ -1,5 +1,6 @@
1
1
  import { mapVariableValueReferences } from "../variables/value.js";
2
2
  import { requireTransferReference } from "./references.js";
3
+ import { uniq } from "es-toolkit";
3
4
  //#region src/transfer/variables.ts
4
5
  function assertUniqueMappings(ids, kind) {
5
6
  if (new Set(ids.values()).size !== ids.size) throw new Error(`Colliding ${kind} transfer mappings`);
@@ -46,7 +47,29 @@ function prepareVariableTransfer(variables, collections, references) {
46
47
  }))
47
48
  };
48
49
  }
50
+ /**
51
+ * Copies the variables `ids` and the collections `collectionIds` into `target`, IDs kept. Each
52
+ * collection comes from the first of its `sources` that has it, and its variables with it; a
53
+ * variable it lacks there comes from the next. A collection keeps only the variables copied.
54
+ */
55
+ function copyVariableTables(target, ids, collectionIds, sources) {
56
+ for (const collectionId of collectionIds) {
57
+ const graphs = sources(collectionId);
58
+ const first = (read) => graphs.map(read).find((found) => found !== void 0);
59
+ const collection = first((graph) => graph.variableCollections.get(collectionId));
60
+ if (!collection) continue;
61
+ const members = uniq(graphs.flatMap((graph) => graph.variableCollections.get(collectionId)?.variableIds ?? [])).filter((id) => ids.has(id));
62
+ target.variableCollections.set(collectionId, {
63
+ ...structuredClone(collection),
64
+ variableIds: members
65
+ });
66
+ for (const id of members) {
67
+ const variable = first((graph) => graph.variables.get(id));
68
+ if (variable) target.variables.set(id, structuredClone(variable));
69
+ }
70
+ }
71
+ }
49
72
  //#endregion
50
- export { prepareVariableTransfer };
73
+ export { copyVariableTables, prepareVariableTransfer };
51
74
 
52
75
  //# sourceMappingURL=variables.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"variables.js","names":["mapped"],"sources":["../../src/transfer/variables.ts"],"sourcesContent":["import type { Variable, VariableCollection, VariableValue } from '../types'\nimport { mapVariableValueReferences } from '../variables/value'\nimport { requireTransferReference as mapped } from './references'\n\nexport interface VariableTransferReferences {\n variables: ReadonlyMap<string, string>\n collections: ReadonlyMap<string, string>\n modes: ReadonlyMap<string, string>\n}\n\nfunction assertUniqueMappings(ids: ReadonlyMap<string, string>, kind: string): void {\n if (new Set(ids.values()).size !== ids.size)\n throw new Error(`Colliding ${kind} transfer mappings`)\n}\n\nfunction assertResourceOwnership(\n variables: readonly Variable[],\n collections: readonly VariableCollection[]\n): void {\n const sets = new Map(collections.map((collection) => [collection.id, collection]))\n const tokens = new Map(variables.map((variable) => [variable.id, variable]))\n if (sets.size !== collections.length || tokens.size !== variables.length)\n throw new Error('Duplicate source variable resource')\n for (const collection of collections) {\n const modes = new Set(collection.modes.map((mode) => mode.modeId))\n if (!modes.has(collection.defaultModeId) || modes.size !== collection.modes.length)\n throw new Error(`Invalid modes for collection ${collection.id}`)\n for (const id of collection.variableIds) {\n if (tokens.get(id)?.collectionId !== collection.id)\n throw new Error(`Invalid variable membership ${id} in ${collection.id}`)\n }\n }\n for (const variable of variables) {\n const collection = sets.get(variable.collectionId)\n if (!collection?.variableIds.includes(variable.id))\n throw new Error(`Missing collection membership for ${variable.id}`)\n const modes = new Set(collection.modes.map((mode) => mode.modeId))\n for (const mode of Object.keys(variable.valuesByMode)) {\n if (!modes.has(mode)) throw new Error(`Unknown mode ${mode} for ${variable.id}`)\n }\n }\n}\n\n/** Prepare isolated resource copies; never mutate the source or destination graph. */\nexport function prepareVariableTransfer(\n variables: readonly Variable[],\n collections: readonly VariableCollection[],\n references: VariableTransferReferences\n): { variables: Variable[]; collections: VariableCollection[] } {\n assertResourceOwnership(variables, collections)\n assertUniqueMappings(references.variables, 'variable')\n assertUniqueMappings(references.collections, 'collection')\n assertUniqueMappings(references.modes, 'mode')\n const value = (input: VariableValue): VariableValue =>\n mapVariableValueReferences(\n input,\n (id) => mapped(references.variables, id, 'variable alias'),\n (id) => references.modes.get(id) ?? id\n )\n return {\n collections: collections.map((collection) => ({\n ...structuredClone(collection),\n id: mapped(references.collections, collection.id, 'collection'),\n defaultModeId: mapped(references.modes, collection.defaultModeId, 'mode'),\n modes: collection.modes.map((mode) => ({\n ...mode,\n modeId: mapped(references.modes, mode.modeId, 'mode')\n })),\n variableIds: collection.variableIds.map((id) => mapped(references.variables, id, 'variable'))\n })),\n variables: variables.map((variable) => ({\n ...structuredClone(variable),\n id: mapped(references.variables, variable.id, 'variable'),\n collectionId: mapped(references.collections, variable.collectionId, 'collection'),\n valuesByMode: Object.fromEntries(\n Object.entries(variable.valuesByMode).map(([mode, input]) => [\n mapped(references.modes, mode, 'mode'),\n value(input)\n ])\n )\n }))\n }\n}\n"],"mappings":";;;AAUA,SAAS,qBAAqB,KAAkC,MAAoB;CAClF,IAAI,IAAI,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,MACrC,MAAM,IAAI,MAAM,aAAa,KAAK,mBAAmB;AACzD;AAEA,SAAS,wBACP,WACA,aACM;CACN,MAAM,OAAO,IAAI,IAAI,YAAY,KAAK,eAAe,CAAC,WAAW,IAAI,UAAU,CAAC,CAAC;CACjF,MAAM,SAAS,IAAI,IAAI,UAAU,KAAK,aAAa,CAAC,SAAS,IAAI,QAAQ,CAAC,CAAC;CAC3E,IAAI,KAAK,SAAS,YAAY,UAAU,OAAO,SAAS,UAAU,QAChE,MAAM,IAAI,MAAM,oCAAoC;CACtD,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,QAAQ,IAAI,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yBAAO,WAAW,OAAO,KAAK,QAAQ,MAAM;GACtD,EAAE;GACF,aAAa,WAAW,YAAY,KAAK,OAAOA,yBAAO,WAAW,WAAW,IAAI,UAAU,CAAC;EAC9F,EAAE;EACF,WAAW,UAAU,KAAK,cAAc;GACtC,GAAG,gBAAgB,QAAQ;GAC3B,IAAIA,yBAAO,WAAW,WAAW,SAAS,IAAI,UAAU;GACxD,cAAcA,yBAAO,WAAW,aAAa,SAAS,cAAc,YAAY;GAChF,cAAc,OAAO,YACnB,OAAO,QAAQ,SAAS,YAAY,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAC3DA,yBAAO,WAAW,OAAO,MAAM,MAAM,GACrC,MAAM,KAAK,CACb,CAAC,CACH;EACF,EAAE;CACJ;AACF"}
1
+ {"version":3,"file":"variables.js","names":["mapped"],"sources":["../../src/transfer/variables.ts"],"sourcesContent":["import { uniq } from 'es-toolkit'\n\nimport type { SceneGraph } from '../graph'\nimport type { Variable, VariableCollection, VariableValue } from '../types'\nimport { mapVariableValueReferences } from '../variables/value'\nimport { requireTransferReference as mapped } from './references'\n\nexport interface VariableTransferReferences {\n variables: ReadonlyMap<string, string>\n collections: ReadonlyMap<string, string>\n modes: ReadonlyMap<string, string>\n}\n\nfunction assertUniqueMappings(ids: ReadonlyMap<string, string>, kind: string): void {\n if (new Set(ids.values()).size !== ids.size)\n throw new Error(`Colliding ${kind} transfer mappings`)\n}\n\nfunction assertResourceOwnership(\n variables: readonly Variable[],\n collections: readonly VariableCollection[]\n): void {\n const sets = new Map(collections.map((collection) => [collection.id, collection]))\n const tokens = new Map(variables.map((variable) => [variable.id, variable]))\n if (sets.size !== collections.length || tokens.size !== variables.length)\n throw new Error('Duplicate source variable resource')\n for (const collection of collections) {\n const modes = new Set(collection.modes.map((mode) => mode.modeId))\n if (!modes.has(collection.defaultModeId) || modes.size !== collection.modes.length)\n throw new Error(`Invalid modes for collection ${collection.id}`)\n for (const id of collection.variableIds) {\n if (tokens.get(id)?.collectionId !== collection.id)\n throw new Error(`Invalid variable membership ${id} in ${collection.id}`)\n }\n }\n for (const variable of variables) {\n const collection = sets.get(variable.collectionId)\n if (!collection?.variableIds.includes(variable.id))\n throw new Error(`Missing collection membership for ${variable.id}`)\n const modes = new Set(collection.modes.map((mode) => mode.modeId))\n for (const mode of Object.keys(variable.valuesByMode)) {\n if (!modes.has(mode)) throw new Error(`Unknown mode ${mode} for ${variable.id}`)\n }\n }\n}\n\n/** Prepare isolated resource copies; never mutate the source or destination graph. */\nexport function prepareVariableTransfer(\n variables: readonly Variable[],\n collections: readonly VariableCollection[],\n references: VariableTransferReferences\n): { variables: Variable[]; collections: VariableCollection[] } {\n assertResourceOwnership(variables, collections)\n assertUniqueMappings(references.variables, 'variable')\n assertUniqueMappings(references.collections, 'collection')\n assertUniqueMappings(references.modes, 'mode')\n const value = (input: VariableValue): VariableValue =>\n mapVariableValueReferences(\n input,\n (id) => mapped(references.variables, id, 'variable alias'),\n (id) => references.modes.get(id) ?? id\n )\n return {\n collections: collections.map((collection) => ({\n ...structuredClone(collection),\n id: mapped(references.collections, collection.id, 'collection'),\n defaultModeId: mapped(references.modes, collection.defaultModeId, 'mode'),\n modes: collection.modes.map((mode) => ({\n ...mode,\n modeId: mapped(references.modes, mode.modeId, 'mode')\n })),\n variableIds: collection.variableIds.map((id) => mapped(references.variables, id, 'variable'))\n })),\n variables: variables.map((variable) => ({\n ...structuredClone(variable),\n id: mapped(references.variables, variable.id, 'variable'),\n collectionId: mapped(references.collections, variable.collectionId, 'collection'),\n valuesByMode: Object.fromEntries(\n Object.entries(variable.valuesByMode).map(([mode, input]) => [\n mapped(references.modes, mode, 'mode'),\n value(input)\n ])\n )\n }))\n }\n}\n\n/**\n * Copies the variables `ids` and the collections `collectionIds` into `target`, IDs kept. Each\n * collection comes from the first of its `sources` that has it, and its variables with it; a\n * variable it lacks there comes from the next. A collection keeps only the variables copied.\n */\nexport function copyVariableTables(\n target: SceneGraph,\n ids: ReadonlySet<string>,\n collectionIds: Iterable<string>,\n sources: (collectionId: string) => readonly SceneGraph[]\n): void {\n for (const collectionId of collectionIds) {\n const graphs = sources(collectionId)\n const first = <T>(read: (graph: SceneGraph) => T | undefined): T | undefined =>\n graphs.map(read).find((found) => found !== undefined)\n const collection = first((graph) => graph.variableCollections.get(collectionId))\n if (!collection) continue\n const members = uniq(\n graphs.flatMap((graph) => graph.variableCollections.get(collectionId)?.variableIds ?? [])\n ).filter((id) => ids.has(id))\n target.variableCollections.set(collectionId, {\n ...structuredClone(collection),\n variableIds: members\n })\n for (const id of members) {\n const variable = first((graph) => graph.variables.get(id))\n if (variable) target.variables.set(id, structuredClone(variable))\n }\n }\n}\n"],"mappings":";;;;AAaA,SAAS,qBAAqB,KAAkC,MAAoB;CAClF,IAAI,IAAI,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,MACrC,MAAM,IAAI,MAAM,aAAa,KAAK,mBAAmB;AACzD;AAEA,SAAS,wBACP,WACA,aACM;CACN,MAAM,OAAO,IAAI,IAAI,YAAY,KAAK,eAAe,CAAC,WAAW,IAAI,UAAU,CAAC,CAAC;CACjF,MAAM,SAAS,IAAI,IAAI,UAAU,KAAK,aAAa,CAAC,SAAS,IAAI,QAAQ,CAAC,CAAC;CAC3E,IAAI,KAAK,SAAS,YAAY,UAAU,OAAO,SAAS,UAAU,QAChE,MAAM,IAAI,MAAM,oCAAoC;CACtD,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,QAAQ,IAAI,IAAI,WAAW,MAAM,KAAK,SAAS,KAAK,MAAM,CAAC;EACjE,IAAI,CAAC,MAAM,IAAI,WAAW,aAAa,KAAK,MAAM,SAAS,WAAW,MAAM,QAC1E,MAAM,IAAI,MAAM,gCAAgC,WAAW,IAAI;EACjE,KAAK,MAAM,MAAM,WAAW,aAC1B,IAAI,OAAO,IAAI,EAAE,CAAC,EAAE,iBAAiB,WAAW,IAC9C,MAAM,IAAI,MAAM,+BAA+B,GAAG,MAAM,WAAW,IAAI;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O,YACnB,OAAO,QAAQ,SAAS,YAAY,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAC3DA,yBAAO,WAAW,OAAO,MAAM,MAAM,GACrC,MAAM,KAAK,CACb,CAAC,CACH;EACF,EAAE;CACJ;AACF;;;;;;AAOA,SAAgB,mBACd,QACA,KACA,eACA,SACM;CACN,KAAK,MAAM,gBAAgB,eAAe;EACxC,MAAM,SAAS,QAAQ,YAAY;EACnC,MAAM,SAAY,SAChB,OAAO,IAAI,IAAI,CAAC,CAAC,MAAM,UAAU,UAAU,KAAA,CAAS;EACtD,MAAM,aAAa,OAAO,UAAU,MAAM,oBAAoB,IAAI,YAAY,CAAC;EAC/E,IAAI,CAAC,YAAY;EACjB,MAAM,UAAU,KACd,OAAO,SAAS,UAAU,MAAM,oBAAoB,IAAI,YAAY,CAAC,EAAE,eAAe,CAAC,CAAC,CAC1F,CAAC,CAAC,QAAQ,OAAO,IAAI,IAAI,EAAE,CAAC;EAC5B,OAAO,oBAAoB,IAAI,cAAc;GAC3C,GAAG,gBAAgB,UAAU;GAC7B,aAAa;EACf,CAAC;EACD,KAAK,MAAM,MAAM,SAAS;GACxB,MAAM,WAAW,OAAO,UAAU,MAAM,UAAU,IAAI,EAAE,CAAC;GACzD,IAAI,UAAU,OAAO,UAAU,IAAI,IAAI,gBAAgB,QAAQ,CAAC;EAClE;CACF;AACF"}
package/dist/types.d.ts CHANGED
@@ -20,12 +20,25 @@ type SceneGraphEventHandlers = Partial<{
20
20
  reparented: (nodeId: string, oldParentId: string | null, newParentId: string) => void;
21
21
  reordered: (nodeId: string, parentId: string, index: number, previousParentId: string | null) => void;
22
22
  }>;
23
+ /** The document's records besides its nodes, which edits report changing as they do nodes. */
24
+ type DocumentRecordKind = 'variable' | 'collection';
23
25
  /** Hears about nodes as an edit adds and changes them, synchronously and before each change. */
24
26
  interface NodeChangeObserver {
25
27
  /** A node is about to change and is still as it was. */
26
28
  before: (node: SceneNode) => void;
27
29
  /** A node was just added. */
28
30
  created: (node: SceneNode) => void;
31
+ /**
32
+ * A variable or collection is about to change, be added, or be removed, and is still as it
33
+ * was: absent, for one about to be added.
34
+ */
35
+ beforeRecord?: (kind: DocumentRecordKind, id: string) => void;
36
+ /**
37
+ * The edit being observed waits on something outside it (`SceneGraph.waitOutsideEdit`): until
38
+ * `resume`, nodes change for someone else's edit, not this one.
39
+ */
40
+ pause?: () => void;
41
+ resume?: () => void;
29
42
  }
30
43
  type DocumentColorSpace = 'srgb' | 'display-p3';
31
44
  /** What a document is for, as Figma keeps design files and FigJam boards apart. */
@@ -153,8 +166,31 @@ interface Stroke extends Fill {
153
166
  join?: StrokeJoin;
154
167
  dashPattern?: number[];
155
168
  }
169
+ /**
170
+ * A Glass effect's lens, in Figma's plugin terms: how far in from the edge it bends what is
171
+ * behind the layer (`depth`, 1 to 100 px) and how strongly (`refraction`, 0 to 1), the light it
172
+ * catches (`lightAngle` in degrees, 0 lighting the top edge, and `lightIntensity`, 0 to 1), and how
173
+ * far the colours split (`dispersion`, 0 to 1). The effect's `radius` frosts the glass.
174
+ */
175
+ interface GlassEffectParams {
176
+ refraction: number;
177
+ depth: number;
178
+ lightAngle: number;
179
+ lightIntensity: number;
180
+ dispersion: number;
181
+ }
182
+ /**
183
+ * A progressive blur's ramp, in Figma's plugin terms: the blur grows from `startRadius` at
184
+ * `startOffset` to the effect's `radius` at `endOffset`, both points fractions of the layer's
185
+ * size, and holds each end's radius beyond it.
186
+ */
187
+ interface ProgressiveBlur {
188
+ startRadius: number;
189
+ startOffset: Vector;
190
+ endOffset: Vector;
191
+ }
156
192
  interface Effect {
157
- type: 'DROP_SHADOW' | 'INNER_SHADOW' | 'LAYER_BLUR' | 'BACKGROUND_BLUR' | 'FOREGROUND_BLUR';
193
+ type: 'DROP_SHADOW' | 'INNER_SHADOW' | 'LAYER_BLUR' | 'BACKGROUND_BLUR' | 'FOREGROUND_BLUR' | 'GLASS';
158
194
  color: Color;
159
195
  offset: Vector;
160
196
  radius: number;
@@ -162,6 +198,10 @@ interface Effect {
162
198
  visible: boolean;
163
199
  blendMode?: BlendMode;
164
200
  showShadowBehindNode?: boolean;
201
+ /** Set on a `GLASS` effect, and only there. */
202
+ glass?: GlassEffectParams;
203
+ /** Set on a layer or background blur that is progressive, and only there. */
204
+ progressive?: ProgressiveBlur;
165
205
  }
166
206
  type ConstraintType = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'SCALE';
167
207
  type TextAutoResize = 'NONE' | 'HEIGHT' | 'WIDTH_AND_HEIGHT' | 'TRUNCATE';
@@ -310,9 +350,35 @@ interface PluginDataEntry {
310
350
  key: string;
311
351
  value: string;
312
352
  }
353
+ /** A fixed width or height in pixels an export is scaled to, instead of a multiplier. */
354
+ interface ExportSize {
355
+ type: 'WIDTH' | 'HEIGHT';
356
+ value: number;
357
+ }
358
+ /** The colour profile an export is written in; the document's own unless set. */
359
+ type ExportColorProfile = 'DOCUMENT' | 'SRGB' | 'DISPLAY_P3_V4';
360
+ /**
361
+ * One export a layer keeps. The options past `scale` and `format` are Figma's and read as Figma's
362
+ * defaults when left out.
363
+ */
313
364
  interface ExportSetting {
314
365
  scale: number;
315
366
  format: ExportFormatId;
367
+ /** Appended to the file name. */
368
+ suffix?: string;
369
+ /** A size that replaces `scale`. */
370
+ size?: ExportSize;
371
+ /** Only the layer, without what overlaps it (default true). */
372
+ contentsOnly?: boolean;
373
+ /** The layer's box rather than everything it draws, for text (default false). */
374
+ useAbsoluteBounds?: boolean;
375
+ colorProfile?: ExportColorProfile;
376
+ /** SVG: text as outlines rather than `<text>` (default true). */
377
+ svgOutlineText?: boolean;
378
+ /** SVG: every layer's name as its element's `id` (default false). */
379
+ svgIdAttribute?: boolean;
380
+ /** SVG: strokes as strokes where possible rather than masked outlines (default true). */
381
+ svgSimplifyStroke?: boolean;
316
382
  }
317
383
  interface PluginRelaunchDataEntry {
318
384
  pluginId: string;
@@ -626,6 +692,11 @@ interface SceneNode {
626
692
  sharedSymbolVersion: string | null;
627
693
  publishedVersion: string | null;
628
694
  librarySource: LibraryAssetSource | null;
695
+ /**
696
+ * The layer of a library's source document that a library definition's layer copies, which pairs
697
+ * it with the same layer in the library's next revision whatever that layer is called by then.
698
+ */
699
+ libraryLayerId: string | null;
629
700
  isPublishable: boolean;
630
701
  isSymbolPublishable: boolean;
631
702
  /**
@@ -824,5 +895,5 @@ declare function isLibraryCollection(collection: Pick<VariableCollection, 'key'>
824
895
  declare const MODE_ATTRIBUTE_PATTERN: RegExp;
825
896
  declare function isModeAttributeName(name: string): boolean;
826
897
  //#endregion
827
- export { ArcData, AxisSizingMode, BlendMode, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, Effect, EnabledLibraryBinding, ExportSetting, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, NodeChangeObserver, NodeType, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType, SlotSettings, SourceLibraryPublication, SourceMetadata, Stroke, StrokeCap, StrokeJoin, StyleRun, SymbolLink, TEXT_BINDABLE_FIELDS, TOKEN_UNITS, TextAlignVertical, TextAutoResize, TextBindableField, TextBoundVariables, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextLength, TextListType, TextParagraphSpacingField, TextParagraphStyle, TextPathData, TokenExpression, TokenUnit, VARIABLE_FORMULA_OPERATORS, VARIABLE_SCOPES, Variable, VariableAlias, VariableCollection, VariableCollectionMode, VariableColorExpression, VariableFormula, VariableFormulaNode, VariableFormulaOperation, VariableFormulaOperator, VariableLiteral, VariableModeMap, VariableScope, VariableType, VariableUnsupportedExpression, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule, isLibraryCollection, isModeAttributeName };
898
+ export { ArcData, AxisSizingMode, BlendMode, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, DocumentRecordKind, Effect, EnabledLibraryBinding, ExportColorProfile, ExportSetting, ExportSize, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GlassEffectParams, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, NodeChangeObserver, NodeType, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, ProgressiveBlur, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType, SlotSettings, SourceLibraryPublication, SourceMetadata, Stroke, StrokeCap, StrokeJoin, StyleRun, SymbolLink, TEXT_BINDABLE_FIELDS, TOKEN_UNITS, TextAlignVertical, TextAutoResize, TextBindableField, TextBoundVariables, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextLength, TextListType, TextParagraphSpacingField, TextParagraphStyle, TextPathData, TokenExpression, TokenUnit, VARIABLE_FORMULA_OPERATORS, VARIABLE_SCOPES, Variable, VariableAlias, VariableCollection, VariableCollectionMode, VariableColorExpression, VariableFormula, VariableFormulaNode, VariableFormulaOperation, VariableFormulaOperator, VariableLiteral, VariableModeMap, VariableScope, VariableType, VariableUnsupportedExpression, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule, isLibraryCollection, isModeAttributeName };
828
899
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;UAQiB;EACf,iBAAiB,MAAM;EACvB,iBAAiB,YAAY,SAAS,QAAQ;EAC9C,wBAAwB,YAAY,SAAS,QAAQ;EACrD,iBAAiB,YAAY;EAC7B,oBAAoB,gBAAgB,4BAA4B;EAChE,mBACE,gBACA,kBACA,eACA;;KAIQ,0BAA0B;EACpC,UAAU,MAAM;EAChB,UAAU,YAAY,SAAS,QAAQ;EACvC,iBAAiB,YAAY,SAAS,QAAQ;EAC9C,UAAU,YAAY;EACtB,aAAa,gBAAgB,4BAA4B;EACzD,YACE,gBACA,kBACA,eACA;;;UAKa;;EAEf,SAAS,MAAM;;EAEf,UAAU,MAAM;;KAGN;;KAGA;UAEK;EACf,SAAS;EACT,cAAc;EACd,eAAe;EACf,QAAQ;EACR;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA,KAAK;;KAGK;KACA;UAEK;EACf;EACA;EACA;EACA;EACA;EACA,kBAAkB;;UAGH;EACf;EACA;EACA,cAAc;EACd,YAAY;;UAGG;EACf,aAAa;EACb;;EAEA,QAAQ;;EAER;;UAGe;EACf,UAAU;EACV,UAAU;EACV,SAAS;;UAGM;EACf,aAAa;EACb,cAAc;;KAGJ;KAqBA;KAW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AEhB,uBAAuB,QAAQ;;EAE/B,0BAA0B,QAAQ;;EAElC;EACA,eAAe;EACf,gBAAgB;;;;;;EAMhB;EAEA,YAAY;EACZ,oBAAoB;EAEpB;EAEA;EACA;EAEA,aAAa;EACb,mBAAmB;;;;;;EAMnB;;EAEA,cAAc;;EAEd,aAAa;;KAGH;;KAGA;UAEK;EACf;EACA,OAAO;;;UAIQ;EACf;EACA;EACA;EACA;;EAEA;;;;;;UAOe;EACf;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,eAAe;;KAGL;UACK;EACf;;;UAIe;EACf;EACA,OAAO,QAAQ;EACf,kBAAkB;;KAGR,kBAAkB;;cAEjB;KAmBD,kCAAkC;UAC7B;EACf,UAAU;EACV,UAAU;;KAEA,sBAAsB,kBAAkB,gBAAgB;UACnD;EACf;EACA,MAAM;EACN,OAAO;;;;;;;;UAQQ;EACf;;EAEA;EACA,OAAO;EACP;EACA;;KAEU,gBACR,kBACA,gBACA,0BACA,kBACA;KACQ,kBAAkB;;cAGjB;KAyBD,wBAAwB;cAEvB;KACD,6BAA6B;;;;;cAM5B;KACD,oBAAoB;;;;;;UAOf;EACf;EACA;;UAGe;EACf;EACA;EACA,MAAM;EACN;EACA,cAAc,eAAe;EAC7B;EACA;;EAEA,SAAS;;;;;EAKT,aAAa,QAAQ,OAAO;;EAE5B,OAAO;;EAEP,cAAc,eAAe;EAC7B,aAAa;;EAEb;;EAEA;;;KAIU,yBACT,WAAW,cAAc,UAAU,oBAAoB,mBAClD;UAES;EACf;EACA;;;;;EAKA;;EAEA;;UAGe;EACf;EACA;;EAEA,OAAO;EACP;EACA;;;;;EAKA;EACA,aAAa;;;;;EAKb;;EAEA;;;iBAIc,oBAAoB,YAAY,KAAK;;cAKxC,wBAAsB;iBAEnB,oBAAoB"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-lines -- scene node contracts are kept together as the public graph type surface */\n\nimport type { ExportFormatId } from './export-format'\nimport type { CanvasGuide } from './guides'\nimport type { InstanceOverrideState } from './instances/overrides'\nimport type { Color, Matrix, Rect, Vector } from './primitives'\nimport type { ShapeWithTextType } from './shape-with-text/kinds'\n\nexport interface SceneGraphEvents {\n 'node:created': (node: SceneNode) => void\n 'node:updated': (id: string, changes: Partial<SceneNode>) => void\n 'node:previewUpdated': (id: string, changes: Partial<SceneNode>) => void\n 'node:deleted': (id: string, parentId: string | null) => void\n 'node:reparented': (nodeId: string, oldParentId: string | null, newParentId: string) => void\n 'node:reordered': (\n nodeId: string,\n parentId: string,\n index: number,\n previousParentId: string | null\n ) => void\n}\n\nexport type SceneGraphEventHandlers = Partial<{\n created: (node: SceneNode) => void\n updated: (id: string, changes: Partial<SceneNode>) => void\n previewUpdated: (id: string, changes: Partial<SceneNode>) => void\n deleted: (id: string, parentId: string | null) => void\n reparented: (nodeId: string, oldParentId: string | null, newParentId: string) => void\n reordered: (\n nodeId: string,\n parentId: string,\n index: number,\n previousParentId: string | null\n ) => void\n}>\n\n/** Hears about nodes as an edit adds and changes them, synchronously and before each change. */\nexport interface NodeChangeObserver {\n /** A node is about to change and is still as it was. */\n before: (node: SceneNode) => void\n /** A node was just added. */\n created: (node: SceneNode) => void\n}\n\nexport type DocumentColorSpace = 'srgb' | 'display-p3'\n\n/** What a document is for, as Figma keeps design files and FigJam boards apart. */\nexport type DocumentKind = 'design' | 'board'\n\nexport interface FigmaSourcePayload {\n rawSize: Vector | null\n rawTransform: Matrix | null\n rawNodeFields: Record<string, unknown>\n layout: FigmaLayoutMetadata | null\n symbolOverrides: unknown[]\n componentPropAssignments: unknown[]\n derivedSymbolData: unknown[]\n derivedSymbolDataLayoutVersion: number | null\n uniformScaleFactor: number | null\n}\n\nexport interface SourceMetadata {\n format: 'fig' | null\n id: string | null\n orderKey: string | null\n editedFields: string[]\n fig: FigmaSourcePayload\n}\n\nexport type HandleMirroring = 'NONE' | 'ANGLE' | 'ANGLE_AND_LENGTH'\nexport type WindingRule = 'NONZERO' | 'EVENODD'\n\nexport interface VectorVertex {\n x: number\n y: number\n strokeCap?: string\n strokeJoin?: string\n cornerRadius?: number\n handleMirroring?: HandleMirroring\n}\n\nexport interface VectorSegment {\n start: number\n end: number\n tangentStart: Vector\n tangentEnd: Vector\n}\n\nexport interface VectorRegion {\n windingRule: WindingRule\n loops: number[][]\n /** The region's own paints. Without them it draws the layer's fills, as in Figma. */\n fills?: Fill[]\n /** The shared fill style the region's paints come from. */\n fillStyleId?: string\n}\n\nexport interface VectorNetwork {\n vertices: VectorVertex[]\n segments: VectorSegment[]\n regions: VectorRegion[]\n}\n\nexport interface GeometryPath {\n windingRule: WindingRule\n commandsBlob: Uint8Array\n}\n\nexport type NodeType =\n | 'CANVAS'\n | 'FRAME'\n | 'RECTANGLE'\n | 'ROUNDED_RECTANGLE'\n | 'ELLIPSE'\n | 'TEXT'\n | 'LINE'\n | 'STAR'\n | 'POLYGON'\n | 'VECTOR'\n | 'BOOLEAN_OPERATION'\n | 'GROUP'\n | 'SECTION'\n | 'COMPONENT'\n | 'COMPONENT_SET'\n | 'INSTANCE'\n | 'CONNECTOR'\n | 'SHAPE_WITH_TEXT'\n | 'STICKY'\n\nexport type FillType =\n | 'SOLID'\n | 'GRADIENT_LINEAR'\n | 'GRADIENT_RADIAL'\n | 'GRADIENT_ANGULAR'\n | 'GRADIENT_DIAMOND'\n | 'IMAGE'\n | 'VIDEO'\n | 'PATTERN'\n | 'NOISE'\n | 'CUSTOM'\nexport type BlendMode =\n | 'NORMAL'\n | 'DARKEN'\n | 'MULTIPLY'\n | 'LINEAR_BURN'\n | 'COLOR_BURN'\n | 'LIGHTEN'\n | 'SCREEN'\n | 'LINEAR_DODGE'\n | 'COLOR_DODGE'\n | 'OVERLAY'\n | 'SOFT_LIGHT'\n | 'HARD_LIGHT'\n | 'DIFFERENCE'\n | 'EXCLUSION'\n | 'HUE'\n | 'SATURATION'\n | 'COLOR'\n | 'LUMINOSITY'\n | 'PASS_THROUGH'\nexport type ImageScaleMode = 'FILL' | 'FIT' | 'CROP' | 'TILE'\nexport type NoiseType = 'MULTITONE' | 'MONOTONE' | 'DUOTONE'\nexport type PatternTileType = 'RECTANGULAR' | 'HORIZONTAL_HEXAGONAL' | 'VERTICAL_HEXAGONAL'\nexport type PatternAlignment = 'START' | 'CENTER' | 'END'\n\nexport interface GradientStop {\n color: Color\n position: number\n}\n\nexport type GradientTransform = Matrix\n\nexport interface Fill {\n type: FillType\n color: Color\n opacity: number\n visible: boolean\n blendMode?: BlendMode\n gradientStops?: GradientStop[]\n gradientTransform?: GradientTransform\n imageHash?: string\n imageScaleMode?: ImageScaleMode\n /** A crop's image-space window; Fill, Fit and Tile ignore it. */\n imageTransform?: GradientTransform\n /** Clockwise turn of a Fill, Fit or Tile image, in multiples of 90°; a crop holds its own. */\n imageRotation?: number\n sourceNodeId?: string\n scale?: number\n spacing?: number\n patternSpacing?: Vector\n patternTileType?: PatternTileType\n verticalAlignment?: PatternAlignment\n horizontalAlignment?: PatternAlignment\n noiseType?: NoiseType\n density?: number\n noiseSize?: Vector\n customEffectId?: string\n}\n\nexport type StrokeCap =\n | 'NONE'\n | 'ROUND'\n | 'SQUARE'\n | 'ARROW_LINES'\n | 'ARROW_EQUILATERAL'\n | 'TRIANGLE_FILLED'\n | 'DIAMOND_FILLED'\n | 'CIRCLE_FILLED'\nexport type StrokeJoin = 'MITER' | 'BEVEL' | 'ROUND'\nexport type SharedStyleType = 'FILL' | 'TEXT' | 'EFFECT' | 'GRID'\nexport type SharedStyleKind = 'fill' | 'stroke' | 'text' | 'effect' | 'grid'\nexport type MaskType = 'ALPHA' | 'VECTOR' | 'LUMINANCE'\n\nexport interface LayoutGrid {\n visible?: boolean\n color?: Color\n /** `STRIPES` is the archive's name for columns or rows, along `axis`. */\n pattern?: 'COLUMNS' | 'ROWS' | 'GRID' | 'STRIPES'\n axis?: 'X' | 'Y'\n type?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH'\n alignment?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH'\n numSections?: number\n /** Figma's plugin API reports an Auto count as `null` and accepts `Infinity` for it. */\n count?: number | null\n offset?: number\n sectionSize?: number\n gutterSize?: number\n}\n\nexport interface SharedStyle {\n id: string\n nodeId: string\n name: string\n type: SharedStyleType\n}\n\n/** A stroke is a paint with the geometry that decides where it is drawn. */\nexport interface Stroke extends Fill {\n weight: number\n align: 'INSIDE' | 'CENTER' | 'OUTSIDE'\n cap?: StrokeCap\n join?: StrokeJoin\n dashPattern?: number[]\n}\n\nexport interface Effect {\n type: 'DROP_SHADOW' | 'INNER_SHADOW' | 'LAYER_BLUR' | 'BACKGROUND_BLUR' | 'FOREGROUND_BLUR'\n color: Color\n offset: Vector\n radius: number\n spread: number\n visible: boolean\n blendMode?: BlendMode\n showShadowBehindNode?: boolean\n}\n\nexport type ConstraintType = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'SCALE'\nexport type TextAutoResize = 'NONE' | 'HEIGHT' | 'WIDTH_AND_HEIGHT' | 'TRUNCATE'\n\n/** Where a connector end attaches to a layer: a side, the side Figma picks, or a fixed point. */\nexport type ConnectorMagnet =\n | 'NONE'\n | 'AUTO'\n | 'AUTO_HORIZONTAL'\n | 'TOP'\n | 'RIGHT'\n | 'BOTTOM'\n | 'LEFT'\n | 'CENTER'\n | 'EDGE'\n | 'ABSOLUTE'\n\n/**\n * One end of a connector. Bound to a layer, it follows the layer by `magnet`, or by `position`\n * in the layer's own axes when the magnet is `NONE`. Free, `nodeId` is null and `position` is in\n * the connector's parent's axes.\n */\nexport interface ConnectorEndpoint {\n nodeId: string | null\n magnet: ConnectorMagnet\n position: Vector\n}\n\nexport type ConnectorLineType = 'ELBOWED' | 'STRAIGHT' | 'CURVED'\n\n/**\n * A segment of an elbow connector that was dragged into place: the line it runs along, through\n * `position`, in the connector's own axes. `position` lies midway along the segment as last drawn.\n */\nexport interface ConnectorControlPoint {\n position: Vector\n direction: 'HORIZONTAL' | 'VERTICAL'\n}\n\n/**\n * Where a connector's label was dragged along its line: `offset` of the way from the middle of\n * the line towards one end, by length, on the line or to one side of it. `ABOVE` is the side to\n * the left of the line's direction.\n */\nexport interface ConnectorLabelPosition {\n section: 'MIDDLE_TO_START' | 'MIDDLE_TO_END'\n offset: number\n offAxis: 'NONE' | 'ABOVE' | 'BELOW'\n}\nexport type TextAlignVertical = 'TOP' | 'CENTER' | 'BOTTOM'\nexport type TextCase = 'ORIGINAL' | 'UPPER' | 'LOWER' | 'TITLE'\nexport type TextDecoration = 'NONE' | 'UNDERLINE' | 'STRIKETHROUGH'\nexport type TextDecorationStyle = 'SOLID' | 'DOTTED' | 'WAVY'\nexport type LeadingTrim = 'NONE' | 'CAP_HEIGHT'\nexport type TextDirection = 'AUTO' | 'LTR' | 'RTL'\nexport type LayoutDirection = 'AUTO' | 'LTR' | 'RTL'\n/** Whether a paragraph is an item of a numbered list, a bulleted list, or no list. */\nexport type TextListType = 'NONE' | 'ORDERED' | 'UNORDERED'\n\n/** How one paragraph of a text node (a line ending at a newline) sits in a list. */\n/** Spacing a text sets for all its paragraphs and a paragraph can set for itself. */\nexport type TextParagraphSpacingField = 'listSpacing' | 'paragraphSpacing' | 'paragraphIndent'\n\nexport interface TextParagraphStyle {\n listType: TextListType\n /** Nesting level: 1–5 for list items; kept but not drawn for plain paragraphs. */\n indentation: number\n /** This paragraph's own spacing, in place of the text's; absent ones follow the text. */\n listSpacing?: number\n paragraphSpacing?: number\n paragraphIndent?: number\n}\n\nexport interface FontVariation {\n axis: string\n value: number\n}\n\nexport interface FontFeature {\n tag: string\n enabled: boolean\n}\n\n/** Where a stretch of text links to, as Figma's `HyperlinkTarget`: a URL, or a node by its ID. */\nexport interface HyperlinkTarget {\n type: 'URL' | 'NODE'\n value: string\n}\n\n/** The text fields a range of characters can bind to a variable, as Figma lists them. */\nexport const TEXT_BINDABLE_FIELDS = [\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontWeight',\n 'letterSpacing',\n 'lineHeight',\n 'paragraphSpacing',\n 'paragraphIndent'\n] as const\n\nexport type TextBindableField = (typeof TEXT_BINDABLE_FIELDS)[number]\n\n/** Variable IDs bound to text fields, by field. */\nexport type TextBoundVariables = Partial<Record<TextBindableField, string>>\n\n/**\n * A line height or letter spacing as Figma keeps it: pixels, or a percent of the font size that\n * follows the size when it changes.\n */\nexport interface TextLength {\n value: number\n unit: 'PIXELS' | 'PERCENT'\n}\n\nexport interface CharacterStyleOverride {\n fontWeight?: number\n italic?: boolean\n /** The characters' face by its font's own name for it; `null` is the face their weight picks. */\n fontStyle?: string | null\n textDecoration?: TextDecoration\n textDecorationStyle?: TextDecorationStyle\n textDecorationThickness?: number | null\n textDecorationFills?: Fill[]\n textDecorationSkipInk?: boolean\n textUnderlineOffset?: number | null\n fontSize?: number\n fontFamily?: string\n letterSpacing?: TextLength\n /** `null` is automatic, from the font. */\n lineHeight?: TextLength | null\n fills?: Fill[]\n fontVariations?: FontVariation[]\n /** Whether the characters' optical size follows their font size, in place of the text's own. */\n opticalSizeFromFontSize?: boolean\n fontFeatures?: FontFeature[]\n textLanguage?: string | null\n textCase?: TextCase\n /** A link over the characters; `null`, like leaving it out, links nowhere. */\n hyperlink?: HyperlinkTarget | null\n /** The text style the characters use in place of the text's own; `null` uses none. */\n textStyleId?: string | null\n /** The fill style the characters use in place of the text's own; `null` uses none. */\n fillStyleId?: string | null\n /** The characters' text field bindings, in place of the text's own. */\n boundVariables?: TextBoundVariables\n}\n\nexport interface StyleRun {\n start: number\n length: number\n style: CharacterStyleOverride\n}\n\nexport interface ArcData {\n startingAngle: number\n endingAngle: number\n innerRadius: number\n}\n\nexport type LayoutMode = 'NONE' | 'HORIZONTAL' | 'VERTICAL' | 'GRID'\n/** A node's sizing along one axis; fill is stored on the child, see `layoutSizing`. */\nexport type LayoutSizing = 'FIXED' | 'HUG' | 'FILL'\n/** Whether an auto-layout frame keeps its size or hugs its children along one of its axes. */\nexport type AxisSizingMode = 'FIXED' | 'HUG'\n\nexport type GridTrackSizing = 'FIXED' | 'FR' | 'AUTO'\n\nexport interface GridTrack {\n sizing: GridTrackSizing\n value: number\n}\n\nexport interface GridPosition {\n column: number\n row: number\n columnSpan: number\n rowSpan: number\n}\nexport type LayoutAlign = 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN'\nexport type LayoutCounterAlign = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'BASELINE'\nexport type LayoutAlignSelf = 'AUTO' | 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'BASELINE'\nexport type LayoutWrap = 'NO_WRAP' | 'WRAP'\n\nexport interface PluginDataEntry {\n pluginId: string\n key: string\n value: string\n}\n\nexport interface ExportSetting {\n scale: number\n format: ExportFormatId\n}\n\nexport interface PluginRelaunchDataEntry {\n pluginId: string\n command: string\n message: string\n isDeleted: boolean\n}\n\n/**\n * One derived glyph outline for display (path text / missing-font fidelity).\n * Figma import is one producer; OpenPencil editing and reflow can regenerate it.\n * commandsBlob is in font units; paint multiplies by fontSize (and scaleX/Y).\n */\nexport interface TextPathData {\n network: VectorNetwork\n normalizedSize: Vector\n /** Where on the start segment the text starts, from 0 at its start to 1 at its end. */\n tValue: number\n forward: boolean\n /** The segment the text starts on, which Figma marks in the network blob; 0 when unmarked. */\n startSegment?: number\n}\n\nexport interface DerivedTextGlyph {\n /** UTF-16 source-text cluster start, when supplied by the shaping source. */\n firstCharacter?: number\n commandsBlob: Uint8Array\n x: number\n y: number\n fontSize: number\n /** Figma Glyph.rotation — radians, not degrees. Zero for axis-aligned text. */\n rotation?: number\n /**\n * Horizontal advance in pixels at `fontSize`, before `scaleX`, when the shaping source gave\n * one; where the glyph ends, so decorations stop at the text rather than the layer's edge.\n */\n advance?: number\n /**\n * Accumulated non-uniform resize scale (default 1). Paint order is\n * translate → scale(scaleX,Y) → rotate → scale(fontSize,-fontSize) so\n * anisotropic stretch matches scaleGeometryPaths(strokeGeometry).\n * Do not fold this into fontSize or rotated letters desync from outlines.\n */\n scaleX?: number\n scaleY?: number\n /**\n * The code points of the emoji this glyph stands for, sequence and all. Its outline is only a\n * placeholder square a 1 em wide; the emoji's image is drawn there instead, as Figma does.\n */\n emojiCodePoints?: number[]\n /** The image set Figma draws the emoji from, when the file names one other than Apple's. */\n emojiImageSet?: 'NOTO'\n}\n\nexport interface SymbolLink {\n uri: string\n displayName?: string\n displayText?: string\n}\n\nexport interface VariantPropSpec {\n propDefId: string\n value: string\n}\n\nexport type FigmaLayoutMetadata = Partial<\n Record<\n | 'stackMode'\n | 'stackCounterAlign'\n | 'stackJustify'\n | 'stackCounterAlignItems'\n | 'stackPrimaryAlignItems'\n | 'stackPrimarySizing'\n | 'stackCounterSizing'\n | 'stackWrap'\n | 'stackPositioning'\n | 'stackChildAlignSelf',\n string\n > &\n Record<\n | 'stackSpacing'\n | 'stackPadding'\n | 'stackPaddingRight'\n | 'stackPaddingBottom'\n | 'stackVerticalPadding'\n | 'stackHorizontalPadding'\n | 'stackChildPrimaryGrow'\n | 'stackCounterSpacing',\n number\n > &\n Record<'bordersTakeSpace' | 'stackReverseZIndex', boolean>\n>\n\nexport interface LibraryAssetIdentity {\n libraryId: string\n assetKey: string\n revisionId: string\n}\n\nexport interface LibraryAssetSource {\n identity: LibraryAssetIdentity\n sourceNodeId: string | null\n readOnly: boolean\n}\n\nexport interface EnabledLibraryBinding {\n libraryId: string\n revisionId: string\n enabled: boolean\n}\n\n/** The library a document publishes as. */\nexport interface SourceLibraryPublication {\n libraryId: string\n revisionId: string\n name: string\n catalogSource?: string\n}\n\n/** A reply in a canvas comment thread. */\nexport interface CommentReply {\n id: string\n author: string\n /** The author's collaboration color when they wrote it, for their avatar. */\n authorColor?: Color\n /** Markdown: bold, italic, strikethrough, links and lists. */\n text: string\n createdAt: string\n deleted?: boolean\n}\n\n/** A canvas comment thread, kept in the document's root plugin data. */\nexport interface CommentThread {\n id: string\n pageId: string\n /** Page name when the pin was placed, for readers of the raw data. */\n pageName?: string\n /** Top-level layer under the pin; the pin follows it when it moves. */\n nodeId?: string | null\n nodeName?: string | null\n /** Offset from the layer's top-left corner, in canvas units. */\n offsetX?: number\n offsetY?: number\n /** Canvas position when the pin was last saved; used when the layer is gone. */\n x: number\n y: number\n author: string\n /** The author's collaboration color when they wrote it, for their avatar. */\n authorColor?: Color\n /** Markdown: bold, italic, strikethrough, links and lists. */\n text: string\n createdAt: string\n /** Bumped on every change. */\n updatedAt: string\n resolved: boolean\n resolvedAt?: string | null\n /** Deleted threads stay as tombstones so a stale copy cannot bring them back. */\n deleted?: boolean\n replies: CommentReply[]\n}\n\nexport interface SceneNode {\n id: string\n type: NodeType\n name: string\n parentId: string | null\n childIds: string[]\n\n x: number\n y: number\n width: number\n height: number\n rotation: number\n source: SourceMetadata\n /** Materialized layout hint imported or generated outside the live Yoga layout pass. */\n derivedLayout: Partial<Rect> | null\n\n fills: Fill[]\n strokes: Stroke[]\n effects: Effect[]\n layoutGrids: LayoutGrid[]\n guides: CanvasGuide[]\n fillStyleId: string | null\n strokeStyleId: string | null\n textStyleId: string | null\n effectStyleId: string | null\n gridStyleId: string | null\n sharedStyleType: SharedStyleType | null\n opacity: number\n\n cornerRadius: number\n topLeftRadius: number\n topRightRadius: number\n bottomRightRadius: number\n bottomLeftRadius: number\n independentCorners: boolean\n cornerSmoothing: number\n\n visible: boolean\n locked: boolean\n clipsContent: boolean\n\n blendMode: BlendMode\n\n text: string\n fontSize: number\n fontFamily: string\n fontWeight: number\n italic: boolean\n /**\n * The face by the name its font gives it (\"Semi Bold\", \"Book\", \"Condensed Bold\"), which Figma\n * finds a font's face by; `null` is the face the weight and slant pick in the family.\n */\n fontStyle: string | null\n textAlignHorizontal: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'\n textDirection: TextDirection\n textLanguage: string | null\n textAlignVertical: TextAlignVertical\n textAutoResize: TextAutoResize\n textCase: TextCase\n textDecoration: TextDecoration\n textDecorationStyle: TextDecorationStyle\n textDecorationThickness: number | null\n textDecorationFills: Fill[]\n textDecorationSkipInk: boolean\n textUnderlineOffset: number | null\n leadingTrim: LeadingTrim\n /** `null` is automatic, from the font. */\n lineHeight: TextLength | null\n letterSpacing: TextLength\n maxLines: number | null\n /**\n * One entry per paragraph of `text`, in order. Missing entries are plain paragraphs, so text\n * without lists keeps this empty.\n */\n textParagraphs: TextParagraphStyle[]\n /** Space after a list item followed by another; a paragraph's own value comes first. */\n listSpacing: number\n /** Space after a paragraph other than between two list items. */\n paragraphSpacing: number\n /** Indent of the first line of each plain paragraph. */\n paragraphIndent: number\n /** Whether list markers hang outside the text box instead of indenting the items. */\n hangingList: boolean\n\n styleRuns: StyleRun[]\n fontVariations: FontVariation[]\n /**\n * Whether a variable font's optical size follows the font size, as Figma's \"Set optical size\n * automatically\" does by default; when it does not, the `opsz` in `fontVariations` applies.\n */\n opticalSizeFromFontSize: boolean\n fontFeatures: FontFeature[]\n\n horizontalConstraint: ConstraintType\n verticalConstraint: ConstraintType\n\n layoutMode: LayoutMode\n layoutDirection: LayoutDirection\n layoutWrap: LayoutWrap\n primaryAxisAlign: LayoutAlign\n counterAxisAlign: LayoutCounterAlign\n primaryAxisSizing: AxisSizingMode\n counterAxisSizing: AxisSizingMode\n itemSpacing: number\n counterAxisSpacing: number\n paddingTop: number\n paddingRight: number\n paddingBottom: number\n paddingLeft: number\n\n layoutPositioning: 'AUTO' | 'ABSOLUTE'\n layoutGrow: number\n layoutAlignSelf: LayoutAlignSelf\n\n vectorNetwork: VectorNetwork | null\n handleMirroring: HandleMirroring\n booleanOperation: 'UNION' | 'SUBTRACT' | 'INTERSECT' | 'EXCLUDE' | undefined\n fillGeometry: GeometryPath[]\n strokeGeometry: GeometryPath[]\n\n arcData: ArcData | null\n\n strokeCap: StrokeCap\n strokeJoin: StrokeJoin\n dashPattern: number[]\n\n borderTopWeight: number\n borderRightWeight: number\n borderBottomWeight: number\n borderLeftWeight: number\n independentStrokeWeights: boolean\n\n /**\n * The weight and alignment a node keeps for its strokes, as Figma keeps them on the node: they\n * last while it has no strokes, and a stroke added to it takes them. Each stroke still carries\n * its own `weight` and `align`, which win while the node has strokes.\n */\n strokeWeight: number\n strokeAlign: Stroke['align']\n\n strokeMiterLimit: number\n\n minWidth: number | null\n maxWidth: number | null\n minHeight: number | null\n maxHeight: number | null\n /**\n * The size whose proportions the layer keeps, as Figma stores it: the width and height it had\n * when the ratio was locked, not a reduced ratio. Null leaves the proportions free.\n */\n targetAspectRatio: Vector | null\n\n /** A connector's ends and the line between them; null on other layers. */\n connectorStart: ConnectorEndpoint | null\n connectorEnd: ConnectorEndpoint | null\n connectorLineType: ConnectorLineType\n connectorStartCap: StrokeCap\n connectorEndCap: StrokeCap\n /**\n * An elbow connector's segments between its first and last, in order, once one was dragged;\n * empty while it routes itself. Kept, unused, while the line is straight or curved.\n */\n connectorControlPoints: ConnectorControlPoint[]\n /**\n * A curved connector's two cubic control points, in the connector's own axes, once its curve\n * was dragged; null while it curves by itself. Kept, unused, while the line is not curved.\n */\n connectorCurveHandles: [Vector, Vector] | null\n /** Where a connector's label was dragged to; null while it sits midway along the line. */\n connectorLabelPosition: ConnectorLabelPosition | null\n\n isMask: boolean\n maskType: MaskType\n maskIsOutline: boolean\n\n gridTemplateColumns: GridTrack[]\n gridTemplateRows: GridTrack[]\n gridColumnGap: number\n gridRowGap: number\n gridPosition: GridPosition | null\n\n counterAxisAlignContent: 'AUTO' | 'SPACE_BETWEEN'\n itemReverseZIndex: boolean\n strokesIncludedInLayout: boolean\n\n expanded: boolean\n textTruncation: 'DISABLED' | 'ENDING'\n autoRename: boolean\n\n pointCount: number\n starInnerRadius: number\n /** The FigJam kind a SHAPE_WITH_TEXT draws; its label is the node's own text. */\n shapeWithTextType: ShapeWithTextType\n /** The height a shape with text was given; it grows past it to fit its label. 0 is unset. */\n shapeUserHeight: number\n /**\n * Whether a shape with text keeps its height and cuts its label off with \"…\" instead of growing,\n * as FigJam does once the shape's height was set.\n */\n shapeTruncates: boolean\n\n componentId: string | null\n instanceOverrides: InstanceOverrideState\n componentPropertyDefinitions: ComponentPropertyDefinition[]\n componentPropertyReferences: ComponentPropertyReference[]\n componentPropertyAssignments: Record<string, string>\n componentPropertyValues: Record<string, string>\n componentKey: string | null\n sourceLibraryKey: string | null\n publishId: string | null\n overrideKey: string | null\n sharedSymbolVersion: string | null\n publishedVersion: string | null\n librarySource: LibraryAssetSource | null\n isPublishable: boolean\n isSymbolPublishable: boolean\n /**\n * On an instance inside a component: its properties show on instances of that component,\n * as Figma's `isExposedInstance`.\n */\n isExposedInstance: boolean\n symbolDescription: string\n symbolLinks: SymbolLink[]\n variantPropSpecs: VariantPropSpec[]\n\n boundVariables: Record<string, string>\n /** Multipliers from bound numeric values to this occurrence's scene units. */\n variableBindingScales: Partial<Record<string, number>>\n /** Numeric units for new declarations owned by this node's occurrence scope. */\n variableAssignmentScales: Partial<Record<string, number>>\n /** Explicit coordinate scale relative to the containing component definition. */\n componentScale: number\n variableModes: VariableModeMap\n exportSettings: ExportSetting[]\n /**\n * The id of the status a team gave the layer, a state of the document's workflow such as Ready\n * for dev. It stays while the layer sits where it cannot show one; `effectiveStatus` tells\n * whether it shows.\n */\n status: string | null\n\n pluginData: PluginDataEntry[]\n pluginRelaunchData: PluginRelaunchDataEntry[]\n\n internalOnly: boolean\n\n flipX: boolean\n flipY: boolean\n\n textPicture: Uint8Array | null\n derivedTextGlyphs: DerivedTextGlyph[] | null\n /**\n * How far a text's lines reach down from its top: measured at its width when its text or width\n * changes, or read from the lines a file saved, and never saved itself. A fixed-size box does not\n * clip them, as in Figma, so its visual bounds reach this far. Null when not known.\n */\n derivedTextHeight: number | null\n /** Format-neutral layout path for text-on-path nodes. */\n textPathData: TextPathData | null\n /** Node-local box that maps textPathData into the node coordinate space. */\n textPathBox: Rect | null\n}\n\nexport type ComponentPropertyType = 'VARIANT' | 'TEXT' | 'BOOLEAN' | 'INSTANCE_SWAP' | 'SLOT'\n\n/** `SLOT_CONTENT` marks a frame whose children are the slot's content. */\nexport type ComponentPropertyReferenceField = 'VISIBLE' | 'TEXT' | 'INSTANCE_SWAP' | 'SLOT_CONTENT'\n\nexport interface ComponentPropertyReference {\n propertyId: string\n field: ComponentPropertyReferenceField\n}\n\n/** Guidance for a slot property; Figma reports a breach but still accepts the content. */\nexport interface SlotSettings {\n minChildren?: number\n maxChildren?: number\n allowPreferredValuesOnly: boolean\n displayEmptyByDefault: boolean\n /** Content added to the slot fills its counter axis. */\n stretchChildOnInsert: boolean\n}\n\n/**\n * For a `SLOT` property, an instance assignment (whatever its value) means the instance owns\n * that slot's content: the slot frame's children in the instance, which component sync keeps.\n */\nexport interface ComponentPropertyDefinition {\n id: string\n name: string\n type: ComponentPropertyType\n defaultValue: string\n variantOptions?: string[]\n preferredValues?: string[]\n description?: string\n slotSettings?: SlotSettings\n}\n\nexport type VariableType = 'COLOR' | 'FLOAT' | 'STRING' | 'BOOLEAN'\nexport interface VariableAlias {\n aliasId: string\n}\n\n/** Figma's two-argument color expression; opacity is a percentage, not an alpha multiplier. */\nexport interface VariableColorExpression {\n expression: 'COMPOSE_COLOR'\n color: Color | VariableAlias\n opacity: number | VariableAlias\n}\n\nexport type VariableLiteral = Color | number | string | boolean\n/** The arithmetic, comparison, logic and conversions a formula combines values with. */\nexport const VARIABLE_FORMULA_OPERATORS = [\n 'add',\n 'subtract',\n 'multiply',\n 'divide',\n 'negate',\n 'equal',\n 'notEqual',\n 'less',\n 'lessOrEqual',\n 'greater',\n 'greaterOrEqual',\n 'and',\n 'or',\n 'not',\n 'text',\n 'truthy',\n 'if'\n] as const\nexport type VariableFormulaOperator = (typeof VARIABLE_FORMULA_OPERATORS)[number]\nexport interface VariableFormulaOperation {\n operator: VariableFormulaOperator\n operands: VariableFormulaNode[]\n}\nexport type VariableFormulaNode = VariableLiteral | VariableAlias | VariableFormulaOperation\nexport interface VariableFormula {\n expression: 'FORMULA'\n type: VariableType\n value: VariableFormulaNode\n}\n/**\n * An imported expression OpenPencil cannot evaluate, kept as the file wrote it so saving writes it\n * back. `references` holds one entry per alias in `value`, in the order the format walks them, and\n * `null` where the alias names a variable this document does not have. `modes` holds the mode id of\n * each mode key in `value`, in the same walk order.\n */\nexport interface VariableUnsupportedExpression {\n expression: 'UNSUPPORTED'\n /** The function name the file gives, such as `VAR_MODE_LOOKUP`. */\n function: string\n value: Record<string, unknown>\n references: (string | null)[]\n modes: string[]\n}\nexport type VariableValue =\n | VariableLiteral\n | VariableAlias\n | VariableColorExpression\n | VariableFormula\n | VariableUnsupportedExpression\nexport type VariableModeMap = Record<string, string>\n\n/** Property pickers a variable is offered in, as Figma names them. */\nexport const VARIABLE_SCOPES = [\n 'ALL_SCOPES',\n 'TEXT_CONTENT',\n 'CORNER_RADIUS',\n 'WIDTH_HEIGHT',\n 'GAP',\n 'ALL_FILLS',\n 'FRAME_FILL',\n 'SHAPE_FILL',\n 'TEXT_FILL',\n 'STROKE',\n 'STROKE_FLOAT',\n 'EFFECT_FLOAT',\n 'EFFECT_COLOR',\n 'OPACITY',\n 'FONT_STYLE',\n 'FONT_FAMILY',\n 'FONT_SIZE',\n 'LINE_HEIGHT',\n 'LETTER_SPACING',\n 'PARAGRAPH_SPACING',\n 'PARAGRAPH_INDENT',\n 'FONT_VARIATIONS',\n 'TRANSFORM'\n] as const\nexport type VariableScope = (typeof VARIABLE_SCOPES)[number]\n\nexport const CODE_SYNTAX_PLATFORMS = ['WEB', 'ANDROID', 'iOS'] as const\nexport type CodeSyntaxPlatform = (typeof CODE_SYNTAX_PLATFORMS)[number]\n\n/**\n * The CSS unit a numeric token is written in. Lengths (`px`, `rem`) stay in canvas pixels in\n * the document and convert only when written as CSS; the other units store the number as written.\n */\nexport const TOKEN_UNITS = ['none', 'px', 'rem', '%', 'ms', 's', 'deg'] as const\nexport type TokenUnit = (typeof TOKEN_UNITS)[number]\n\n/**\n * CSS written in place of a number mode's value, such as `clamp(1rem, 4vw, 1.5rem)`. While the\n * mode holds a plain number, `resolved` records it, so a number later edited elsewhere, Figma\n * included, shows the CSS no longer describes it.\n */\nexport interface TokenExpression {\n css: string\n resolved?: number\n}\n\nexport interface Variable {\n id: string\n name: string\n type: VariableType\n collectionId: string\n valuesByMode: Record<string, VariableValue>\n description: string\n hiddenFromPublishing: boolean\n /** Absent means every scope. */\n scopes?: VariableScope[]\n /**\n * Per-platform code snippets, as Figma's Dev Mode shows them. A `WEB` snippet of `--x` or\n * `var(--x)` names the token's CSS custom property; otherwise the name is derived.\n */\n codeSyntax?: Partial<Record<CodeSyntaxPlatform, string>>\n /** FLOAT only. Absent means inferred when written as CSS. */\n unit?: TokenUnit\n /** Raw CSS by mode id, for values a number cannot express (`clamp()`, `calc()`). */\n expressions?: Record<string, TokenExpression>\n pluginData?: PluginDataEntry[]\n /** Published library key (from NodeChange.key). Used for assetRef resolution in colorVar. */\n key?: string\n /** Published library version (from NodeChange.version). Used for assetRef resolution in colorVar. */\n version?: string\n}\n\n/** Scalar numeric node fields accepted by numeric property controls. */\nexport type NumericNodeProperty = {\n [K in keyof SceneNode]-?: SceneNode[K] extends number ? K : never\n}[keyof SceneNode]\n\nexport interface VariableCollectionMode {\n modeId: string\n name: string\n /**\n * Where the mode applies in CSS: a selector (`[data-theme=\"dark\"]`, `.compact`) or an\n * at-rule prelude (`@media (max-width: 640px)`). Absent means the default for its axis.\n */\n condition?: string\n /** Where Figma lists the mode, as the file saved it; Figma orders a collection's modes by it. */\n sortPosition?: string\n}\n\nexport interface VariableCollection {\n id: string\n name: string\n /** The default mode comes first, as in Figma. */\n modes: VariableCollectionMode[]\n defaultModeId: string\n variableIds: string[]\n /**\n * The attribute that switches a mode with no condition of its own, `data-theme` for\n * `[data-theme=\"dark\"]`. Absent means one named after the collection.\n */\n modeAttribute?: string\n pluginData?: PluginDataEntry[]\n /**\n * Published library key, for a collection the file copies from a library. Such a collection\n * belongs to the library: Figma lists it with the library's, not the file's own.\n */\n key?: string\n /** Published library version, which references by key carry with it. */\n version?: string\n}\n\n/** Whether a collection is a library's copy, which takes no variables or modes of the file's. */\nexport function isLibraryCollection(collection: Pick<VariableCollection, 'key'>): boolean {\n return !!collection.key\n}\n\n/** An HTML attribute name a stylesheet can select on unescaped: `data-theme`, `theme`. */\nexport const MODE_ATTRIBUTE_PATTERN = /^[A-Za-z_][\\w-]*$/\n\nexport function isModeAttributeName(name: string): boolean {\n return name.length <= 100 && MODE_ATTRIBUTE_PATTERN.test(name)\n}\n"],"mappings":";;AAyVA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAwjBA,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAmCA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,wBAAwB;CAAC;CAAO;CAAW;AAAK;;;;;AAO7D,MAAa,cAAc;CAAC;CAAQ;CAAM;CAAO;CAAK;CAAM;CAAK;AAAK;;AA+EtE,SAAgB,oBAAoB,YAAsD;CACxF,OAAO,CAAC,CAAC,WAAW;AACtB;;AAGA,MAAa,yBAAyB;AAEtC,SAAgB,oBAAoB,MAAuB;CACzD,OAAO,KAAK,UAAU,OAAO,uBAAuB,KAAK,IAAI;AAC/D"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-lines -- scene node contracts are kept together as the public graph type surface */\n\nimport type { ExportFormatId } from './export-format'\nimport type { CanvasGuide } from './guides'\nimport type { InstanceOverrideState } from './instances/overrides'\nimport type { Color, Matrix, Rect, Vector } from './primitives'\nimport type { ShapeWithTextType } from './shape-with-text/kinds'\n\nexport interface SceneGraphEvents {\n 'node:created': (node: SceneNode) => void\n 'node:updated': (id: string, changes: Partial<SceneNode>) => void\n 'node:previewUpdated': (id: string, changes: Partial<SceneNode>) => void\n 'node:deleted': (id: string, parentId: string | null) => void\n 'node:reparented': (nodeId: string, oldParentId: string | null, newParentId: string) => void\n 'node:reordered': (\n nodeId: string,\n parentId: string,\n index: number,\n previousParentId: string | null\n ) => void\n}\n\nexport type SceneGraphEventHandlers = Partial<{\n created: (node: SceneNode) => void\n updated: (id: string, changes: Partial<SceneNode>) => void\n previewUpdated: (id: string, changes: Partial<SceneNode>) => void\n deleted: (id: string, parentId: string | null) => void\n reparented: (nodeId: string, oldParentId: string | null, newParentId: string) => void\n reordered: (\n nodeId: string,\n parentId: string,\n index: number,\n previousParentId: string | null\n ) => void\n}>\n\n/** The document's records besides its nodes, which edits report changing as they do nodes. */\nexport type DocumentRecordKind = 'variable' | 'collection'\n\n/** Hears about nodes as an edit adds and changes them, synchronously and before each change. */\nexport interface NodeChangeObserver {\n /** A node is about to change and is still as it was. */\n before: (node: SceneNode) => void\n /** A node was just added. */\n created: (node: SceneNode) => void\n /**\n * A variable or collection is about to change, be added, or be removed, and is still as it\n * was: absent, for one about to be added.\n */\n beforeRecord?: (kind: DocumentRecordKind, id: string) => void\n /**\n * The edit being observed waits on something outside it (`SceneGraph.waitOutsideEdit`): until\n * `resume`, nodes change for someone else's edit, not this one.\n */\n pause?: () => void\n resume?: () => void\n}\n\nexport type DocumentColorSpace = 'srgb' | 'display-p3'\n\n/** What a document is for, as Figma keeps design files and FigJam boards apart. */\nexport type DocumentKind = 'design' | 'board'\n\nexport interface FigmaSourcePayload {\n rawSize: Vector | null\n rawTransform: Matrix | null\n rawNodeFields: Record<string, unknown>\n layout: FigmaLayoutMetadata | null\n symbolOverrides: unknown[]\n componentPropAssignments: unknown[]\n derivedSymbolData: unknown[]\n derivedSymbolDataLayoutVersion: number | null\n uniformScaleFactor: number | null\n}\n\nexport interface SourceMetadata {\n format: 'fig' | null\n id: string | null\n orderKey: string | null\n editedFields: string[]\n fig: FigmaSourcePayload\n}\n\nexport type HandleMirroring = 'NONE' | 'ANGLE' | 'ANGLE_AND_LENGTH'\nexport type WindingRule = 'NONZERO' | 'EVENODD'\n\nexport interface VectorVertex {\n x: number\n y: number\n strokeCap?: string\n strokeJoin?: string\n cornerRadius?: number\n handleMirroring?: HandleMirroring\n}\n\nexport interface VectorSegment {\n start: number\n end: number\n tangentStart: Vector\n tangentEnd: Vector\n}\n\nexport interface VectorRegion {\n windingRule: WindingRule\n loops: number[][]\n /** The region's own paints. Without them it draws the layer's fills, as in Figma. */\n fills?: Fill[]\n /** The shared fill style the region's paints come from. */\n fillStyleId?: string\n}\n\nexport interface VectorNetwork {\n vertices: VectorVertex[]\n segments: VectorSegment[]\n regions: VectorRegion[]\n}\n\nexport interface GeometryPath {\n windingRule: WindingRule\n commandsBlob: Uint8Array\n}\n\nexport type NodeType =\n | 'CANVAS'\n | 'FRAME'\n | 'RECTANGLE'\n | 'ROUNDED_RECTANGLE'\n | 'ELLIPSE'\n | 'TEXT'\n | 'LINE'\n | 'STAR'\n | 'POLYGON'\n | 'VECTOR'\n | 'BOOLEAN_OPERATION'\n | 'GROUP'\n | 'SECTION'\n | 'COMPONENT'\n | 'COMPONENT_SET'\n | 'INSTANCE'\n | 'CONNECTOR'\n | 'SHAPE_WITH_TEXT'\n | 'STICKY'\n\nexport type FillType =\n | 'SOLID'\n | 'GRADIENT_LINEAR'\n | 'GRADIENT_RADIAL'\n | 'GRADIENT_ANGULAR'\n | 'GRADIENT_DIAMOND'\n | 'IMAGE'\n | 'VIDEO'\n | 'PATTERN'\n | 'NOISE'\n | 'CUSTOM'\nexport type BlendMode =\n | 'NORMAL'\n | 'DARKEN'\n | 'MULTIPLY'\n | 'LINEAR_BURN'\n | 'COLOR_BURN'\n | 'LIGHTEN'\n | 'SCREEN'\n | 'LINEAR_DODGE'\n | 'COLOR_DODGE'\n | 'OVERLAY'\n | 'SOFT_LIGHT'\n | 'HARD_LIGHT'\n | 'DIFFERENCE'\n | 'EXCLUSION'\n | 'HUE'\n | 'SATURATION'\n | 'COLOR'\n | 'LUMINOSITY'\n | 'PASS_THROUGH'\nexport type ImageScaleMode = 'FILL' | 'FIT' | 'CROP' | 'TILE'\nexport type NoiseType = 'MULTITONE' | 'MONOTONE' | 'DUOTONE'\nexport type PatternTileType = 'RECTANGULAR' | 'HORIZONTAL_HEXAGONAL' | 'VERTICAL_HEXAGONAL'\nexport type PatternAlignment = 'START' | 'CENTER' | 'END'\n\nexport interface GradientStop {\n color: Color\n position: number\n}\n\nexport type GradientTransform = Matrix\n\nexport interface Fill {\n type: FillType\n color: Color\n opacity: number\n visible: boolean\n blendMode?: BlendMode\n gradientStops?: GradientStop[]\n gradientTransform?: GradientTransform\n imageHash?: string\n imageScaleMode?: ImageScaleMode\n /** A crop's image-space window; Fill, Fit and Tile ignore it. */\n imageTransform?: GradientTransform\n /** Clockwise turn of a Fill, Fit or Tile image, in multiples of 90°; a crop holds its own. */\n imageRotation?: number\n sourceNodeId?: string\n scale?: number\n spacing?: number\n patternSpacing?: Vector\n patternTileType?: PatternTileType\n verticalAlignment?: PatternAlignment\n horizontalAlignment?: PatternAlignment\n noiseType?: NoiseType\n density?: number\n noiseSize?: Vector\n customEffectId?: string\n}\n\nexport type StrokeCap =\n | 'NONE'\n | 'ROUND'\n | 'SQUARE'\n | 'ARROW_LINES'\n | 'ARROW_EQUILATERAL'\n | 'TRIANGLE_FILLED'\n | 'DIAMOND_FILLED'\n | 'CIRCLE_FILLED'\nexport type StrokeJoin = 'MITER' | 'BEVEL' | 'ROUND'\nexport type SharedStyleType = 'FILL' | 'TEXT' | 'EFFECT' | 'GRID'\nexport type SharedStyleKind = 'fill' | 'stroke' | 'text' | 'effect' | 'grid'\nexport type MaskType = 'ALPHA' | 'VECTOR' | 'LUMINANCE'\n\nexport interface LayoutGrid {\n visible?: boolean\n color?: Color\n /** `STRIPES` is the archive's name for columns or rows, along `axis`. */\n pattern?: 'COLUMNS' | 'ROWS' | 'GRID' | 'STRIPES'\n axis?: 'X' | 'Y'\n type?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH'\n alignment?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH'\n numSections?: number\n /** Figma's plugin API reports an Auto count as `null` and accepts `Infinity` for it. */\n count?: number | null\n offset?: number\n sectionSize?: number\n gutterSize?: number\n}\n\nexport interface SharedStyle {\n id: string\n nodeId: string\n name: string\n type: SharedStyleType\n}\n\n/** A stroke is a paint with the geometry that decides where it is drawn. */\nexport interface Stroke extends Fill {\n weight: number\n align: 'INSIDE' | 'CENTER' | 'OUTSIDE'\n cap?: StrokeCap\n join?: StrokeJoin\n dashPattern?: number[]\n}\n\n/**\n * A Glass effect's lens, in Figma's plugin terms: how far in from the edge it bends what is\n * behind the layer (`depth`, 1 to 100 px) and how strongly (`refraction`, 0 to 1), the light it\n * catches (`lightAngle` in degrees, 0 lighting the top edge, and `lightIntensity`, 0 to 1), and how\n * far the colours split (`dispersion`, 0 to 1). The effect's `radius` frosts the glass.\n */\nexport interface GlassEffectParams {\n refraction: number\n depth: number\n lightAngle: number\n lightIntensity: number\n dispersion: number\n}\n\n/**\n * A progressive blur's ramp, in Figma's plugin terms: the blur grows from `startRadius` at\n * `startOffset` to the effect's `radius` at `endOffset`, both points fractions of the layer's\n * size, and holds each end's radius beyond it.\n */\nexport interface ProgressiveBlur {\n startRadius: number\n startOffset: Vector\n endOffset: Vector\n}\n\nexport interface Effect {\n type:\n | 'DROP_SHADOW'\n | 'INNER_SHADOW'\n | 'LAYER_BLUR'\n | 'BACKGROUND_BLUR'\n | 'FOREGROUND_BLUR'\n | 'GLASS'\n color: Color\n offset: Vector\n radius: number\n spread: number\n visible: boolean\n blendMode?: BlendMode\n showShadowBehindNode?: boolean\n /** Set on a `GLASS` effect, and only there. */\n glass?: GlassEffectParams\n /** Set on a layer or background blur that is progressive, and only there. */\n progressive?: ProgressiveBlur\n}\n\nexport type ConstraintType = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'SCALE'\nexport type TextAutoResize = 'NONE' | 'HEIGHT' | 'WIDTH_AND_HEIGHT' | 'TRUNCATE'\n\n/** Where a connector end attaches to a layer: a side, the side Figma picks, or a fixed point. */\nexport type ConnectorMagnet =\n | 'NONE'\n | 'AUTO'\n | 'AUTO_HORIZONTAL'\n | 'TOP'\n | 'RIGHT'\n | 'BOTTOM'\n | 'LEFT'\n | 'CENTER'\n | 'EDGE'\n | 'ABSOLUTE'\n\n/**\n * One end of a connector. Bound to a layer, it follows the layer by `magnet`, or by `position`\n * in the layer's own axes when the magnet is `NONE`. Free, `nodeId` is null and `position` is in\n * the connector's parent's axes.\n */\nexport interface ConnectorEndpoint {\n nodeId: string | null\n magnet: ConnectorMagnet\n position: Vector\n}\n\nexport type ConnectorLineType = 'ELBOWED' | 'STRAIGHT' | 'CURVED'\n\n/**\n * A segment of an elbow connector that was dragged into place: the line it runs along, through\n * `position`, in the connector's own axes. `position` lies midway along the segment as last drawn.\n */\nexport interface ConnectorControlPoint {\n position: Vector\n direction: 'HORIZONTAL' | 'VERTICAL'\n}\n\n/**\n * Where a connector's label was dragged along its line: `offset` of the way from the middle of\n * the line towards one end, by length, on the line or to one side of it. `ABOVE` is the side to\n * the left of the line's direction.\n */\nexport interface ConnectorLabelPosition {\n section: 'MIDDLE_TO_START' | 'MIDDLE_TO_END'\n offset: number\n offAxis: 'NONE' | 'ABOVE' | 'BELOW'\n}\nexport type TextAlignVertical = 'TOP' | 'CENTER' | 'BOTTOM'\nexport type TextCase = 'ORIGINAL' | 'UPPER' | 'LOWER' | 'TITLE'\nexport type TextDecoration = 'NONE' | 'UNDERLINE' | 'STRIKETHROUGH'\nexport type TextDecorationStyle = 'SOLID' | 'DOTTED' | 'WAVY'\nexport type LeadingTrim = 'NONE' | 'CAP_HEIGHT'\nexport type TextDirection = 'AUTO' | 'LTR' | 'RTL'\nexport type LayoutDirection = 'AUTO' | 'LTR' | 'RTL'\n/** Whether a paragraph is an item of a numbered list, a bulleted list, or no list. */\nexport type TextListType = 'NONE' | 'ORDERED' | 'UNORDERED'\n\n/** How one paragraph of a text node (a line ending at a newline) sits in a list. */\n/** Spacing a text sets for all its paragraphs and a paragraph can set for itself. */\nexport type TextParagraphSpacingField = 'listSpacing' | 'paragraphSpacing' | 'paragraphIndent'\n\nexport interface TextParagraphStyle {\n listType: TextListType\n /** Nesting level: 1–5 for list items; kept but not drawn for plain paragraphs. */\n indentation: number\n /** This paragraph's own spacing, in place of the text's; absent ones follow the text. */\n listSpacing?: number\n paragraphSpacing?: number\n paragraphIndent?: number\n}\n\nexport interface FontVariation {\n axis: string\n value: number\n}\n\nexport interface FontFeature {\n tag: string\n enabled: boolean\n}\n\n/** Where a stretch of text links to, as Figma's `HyperlinkTarget`: a URL, or a node by its ID. */\nexport interface HyperlinkTarget {\n type: 'URL' | 'NODE'\n value: string\n}\n\n/** The text fields a range of characters can bind to a variable, as Figma lists them. */\nexport const TEXT_BINDABLE_FIELDS = [\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontWeight',\n 'letterSpacing',\n 'lineHeight',\n 'paragraphSpacing',\n 'paragraphIndent'\n] as const\n\nexport type TextBindableField = (typeof TEXT_BINDABLE_FIELDS)[number]\n\n/** Variable IDs bound to text fields, by field. */\nexport type TextBoundVariables = Partial<Record<TextBindableField, string>>\n\n/**\n * A line height or letter spacing as Figma keeps it: pixels, or a percent of the font size that\n * follows the size when it changes.\n */\nexport interface TextLength {\n value: number\n unit: 'PIXELS' | 'PERCENT'\n}\n\nexport interface CharacterStyleOverride {\n fontWeight?: number\n italic?: boolean\n /** The characters' face by its font's own name for it; `null` is the face their weight picks. */\n fontStyle?: string | null\n textDecoration?: TextDecoration\n textDecorationStyle?: TextDecorationStyle\n textDecorationThickness?: number | null\n textDecorationFills?: Fill[]\n textDecorationSkipInk?: boolean\n textUnderlineOffset?: number | null\n fontSize?: number\n fontFamily?: string\n letterSpacing?: TextLength\n /** `null` is automatic, from the font. */\n lineHeight?: TextLength | null\n fills?: Fill[]\n fontVariations?: FontVariation[]\n /** Whether the characters' optical size follows their font size, in place of the text's own. */\n opticalSizeFromFontSize?: boolean\n fontFeatures?: FontFeature[]\n textLanguage?: string | null\n textCase?: TextCase\n /** A link over the characters; `null`, like leaving it out, links nowhere. */\n hyperlink?: HyperlinkTarget | null\n /** The text style the characters use in place of the text's own; `null` uses none. */\n textStyleId?: string | null\n /** The fill style the characters use in place of the text's own; `null` uses none. */\n fillStyleId?: string | null\n /** The characters' text field bindings, in place of the text's own. */\n boundVariables?: TextBoundVariables\n}\n\nexport interface StyleRun {\n start: number\n length: number\n style: CharacterStyleOverride\n}\n\nexport interface ArcData {\n startingAngle: number\n endingAngle: number\n innerRadius: number\n}\n\nexport type LayoutMode = 'NONE' | 'HORIZONTAL' | 'VERTICAL' | 'GRID'\n/** A node's sizing along one axis; fill is stored on the child, see `layoutSizing`. */\nexport type LayoutSizing = 'FIXED' | 'HUG' | 'FILL'\n/** Whether an auto-layout frame keeps its size or hugs its children along one of its axes. */\nexport type AxisSizingMode = 'FIXED' | 'HUG'\n\nexport type GridTrackSizing = 'FIXED' | 'FR' | 'AUTO'\n\nexport interface GridTrack {\n sizing: GridTrackSizing\n value: number\n}\n\nexport interface GridPosition {\n column: number\n row: number\n columnSpan: number\n rowSpan: number\n}\nexport type LayoutAlign = 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN'\nexport type LayoutCounterAlign = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'BASELINE'\nexport type LayoutAlignSelf = 'AUTO' | 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'BASELINE'\nexport type LayoutWrap = 'NO_WRAP' | 'WRAP'\n\nexport interface PluginDataEntry {\n pluginId: string\n key: string\n value: string\n}\n\n/** A fixed width or height in pixels an export is scaled to, instead of a multiplier. */\nexport interface ExportSize {\n type: 'WIDTH' | 'HEIGHT'\n value: number\n}\n\n/** The colour profile an export is written in; the document's own unless set. */\nexport type ExportColorProfile = 'DOCUMENT' | 'SRGB' | 'DISPLAY_P3_V4'\n\n/**\n * One export a layer keeps. The options past `scale` and `format` are Figma's and read as Figma's\n * defaults when left out.\n */\nexport interface ExportSetting {\n scale: number\n format: ExportFormatId\n /** Appended to the file name. */\n suffix?: string\n /** A size that replaces `scale`. */\n size?: ExportSize\n /** Only the layer, without what overlaps it (default true). */\n contentsOnly?: boolean\n /** The layer's box rather than everything it draws, for text (default false). */\n useAbsoluteBounds?: boolean\n colorProfile?: ExportColorProfile\n /** SVG: text as outlines rather than `<text>` (default true). */\n svgOutlineText?: boolean\n /** SVG: every layer's name as its element's `id` (default false). */\n svgIdAttribute?: boolean\n /** SVG: strokes as strokes where possible rather than masked outlines (default true). */\n svgSimplifyStroke?: boolean\n}\n\nexport interface PluginRelaunchDataEntry {\n pluginId: string\n command: string\n message: string\n isDeleted: boolean\n}\n\n/**\n * One derived glyph outline for display (path text / missing-font fidelity).\n * Figma import is one producer; OpenPencil editing and reflow can regenerate it.\n * commandsBlob is in font units; paint multiplies by fontSize (and scaleX/Y).\n */\nexport interface TextPathData {\n network: VectorNetwork\n normalizedSize: Vector\n /** Where on the start segment the text starts, from 0 at its start to 1 at its end. */\n tValue: number\n forward: boolean\n /** The segment the text starts on, which Figma marks in the network blob; 0 when unmarked. */\n startSegment?: number\n}\n\nexport interface DerivedTextGlyph {\n /** UTF-16 source-text cluster start, when supplied by the shaping source. */\n firstCharacter?: number\n commandsBlob: Uint8Array\n x: number\n y: number\n fontSize: number\n /** Figma Glyph.rotation — radians, not degrees. Zero for axis-aligned text. */\n rotation?: number\n /**\n * Horizontal advance in pixels at `fontSize`, before `scaleX`, when the shaping source gave\n * one; where the glyph ends, so decorations stop at the text rather than the layer's edge.\n */\n advance?: number\n /**\n * Accumulated non-uniform resize scale (default 1). Paint order is\n * translate → scale(scaleX,Y) → rotate → scale(fontSize,-fontSize) so\n * anisotropic stretch matches scaleGeometryPaths(strokeGeometry).\n * Do not fold this into fontSize or rotated letters desync from outlines.\n */\n scaleX?: number\n scaleY?: number\n /**\n * The code points of the emoji this glyph stands for, sequence and all. Its outline is only a\n * placeholder square a 1 em wide; the emoji's image is drawn there instead, as Figma does.\n */\n emojiCodePoints?: number[]\n /** The image set Figma draws the emoji from, when the file names one other than Apple's. */\n emojiImageSet?: 'NOTO'\n}\n\nexport interface SymbolLink {\n uri: string\n displayName?: string\n displayText?: string\n}\n\nexport interface VariantPropSpec {\n propDefId: string\n value: string\n}\n\nexport type FigmaLayoutMetadata = Partial<\n Record<\n | 'stackMode'\n | 'stackCounterAlign'\n | 'stackJustify'\n | 'stackCounterAlignItems'\n | 'stackPrimaryAlignItems'\n | 'stackPrimarySizing'\n | 'stackCounterSizing'\n | 'stackWrap'\n | 'stackPositioning'\n | 'stackChildAlignSelf',\n string\n > &\n Record<\n | 'stackSpacing'\n | 'stackPadding'\n | 'stackPaddingRight'\n | 'stackPaddingBottom'\n | 'stackVerticalPadding'\n | 'stackHorizontalPadding'\n | 'stackChildPrimaryGrow'\n | 'stackCounterSpacing',\n number\n > &\n Record<'bordersTakeSpace' | 'stackReverseZIndex', boolean>\n>\n\nexport interface LibraryAssetIdentity {\n libraryId: string\n assetKey: string\n revisionId: string\n}\n\nexport interface LibraryAssetSource {\n identity: LibraryAssetIdentity\n sourceNodeId: string | null\n readOnly: boolean\n}\n\nexport interface EnabledLibraryBinding {\n libraryId: string\n revisionId: string\n enabled: boolean\n}\n\n/** The library a document publishes as. */\nexport interface SourceLibraryPublication {\n libraryId: string\n revisionId: string\n name: string\n catalogSource?: string\n}\n\n/** A reply in a canvas comment thread. */\nexport interface CommentReply {\n id: string\n author: string\n /** The author's collaboration color when they wrote it, for their avatar. */\n authorColor?: Color\n /** Markdown: bold, italic, strikethrough, links and lists. */\n text: string\n createdAt: string\n deleted?: boolean\n}\n\n/** A canvas comment thread, kept in the document's root plugin data. */\nexport interface CommentThread {\n id: string\n pageId: string\n /** Page name when the pin was placed, for readers of the raw data. */\n pageName?: string\n /** Top-level layer under the pin; the pin follows it when it moves. */\n nodeId?: string | null\n nodeName?: string | null\n /** Offset from the layer's top-left corner, in canvas units. */\n offsetX?: number\n offsetY?: number\n /** Canvas position when the pin was last saved; used when the layer is gone. */\n x: number\n y: number\n author: string\n /** The author's collaboration color when they wrote it, for their avatar. */\n authorColor?: Color\n /** Markdown: bold, italic, strikethrough, links and lists. */\n text: string\n createdAt: string\n /** Bumped on every change. */\n updatedAt: string\n resolved: boolean\n resolvedAt?: string | null\n /** Deleted threads stay as tombstones so a stale copy cannot bring them back. */\n deleted?: boolean\n replies: CommentReply[]\n}\n\nexport interface SceneNode {\n id: string\n type: NodeType\n name: string\n parentId: string | null\n childIds: string[]\n\n x: number\n y: number\n width: number\n height: number\n rotation: number\n source: SourceMetadata\n /** Materialized layout hint imported or generated outside the live Yoga layout pass. */\n derivedLayout: Partial<Rect> | null\n\n fills: Fill[]\n strokes: Stroke[]\n effects: Effect[]\n layoutGrids: LayoutGrid[]\n guides: CanvasGuide[]\n fillStyleId: string | null\n strokeStyleId: string | null\n textStyleId: string | null\n effectStyleId: string | null\n gridStyleId: string | null\n sharedStyleType: SharedStyleType | null\n opacity: number\n\n cornerRadius: number\n topLeftRadius: number\n topRightRadius: number\n bottomRightRadius: number\n bottomLeftRadius: number\n independentCorners: boolean\n cornerSmoothing: number\n\n visible: boolean\n locked: boolean\n clipsContent: boolean\n\n blendMode: BlendMode\n\n text: string\n fontSize: number\n fontFamily: string\n fontWeight: number\n italic: boolean\n /**\n * The face by the name its font gives it (\"Semi Bold\", \"Book\", \"Condensed Bold\"), which Figma\n * finds a font's face by; `null` is the face the weight and slant pick in the family.\n */\n fontStyle: string | null\n textAlignHorizontal: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'\n textDirection: TextDirection\n textLanguage: string | null\n textAlignVertical: TextAlignVertical\n textAutoResize: TextAutoResize\n textCase: TextCase\n textDecoration: TextDecoration\n textDecorationStyle: TextDecorationStyle\n textDecorationThickness: number | null\n textDecorationFills: Fill[]\n textDecorationSkipInk: boolean\n textUnderlineOffset: number | null\n leadingTrim: LeadingTrim\n /** `null` is automatic, from the font. */\n lineHeight: TextLength | null\n letterSpacing: TextLength\n maxLines: number | null\n /**\n * One entry per paragraph of `text`, in order. Missing entries are plain paragraphs, so text\n * without lists keeps this empty.\n */\n textParagraphs: TextParagraphStyle[]\n /** Space after a list item followed by another; a paragraph's own value comes first. */\n listSpacing: number\n /** Space after a paragraph other than between two list items. */\n paragraphSpacing: number\n /** Indent of the first line of each plain paragraph. */\n paragraphIndent: number\n /** Whether list markers hang outside the text box instead of indenting the items. */\n hangingList: boolean\n\n styleRuns: StyleRun[]\n fontVariations: FontVariation[]\n /**\n * Whether a variable font's optical size follows the font size, as Figma's \"Set optical size\n * automatically\" does by default; when it does not, the `opsz` in `fontVariations` applies.\n */\n opticalSizeFromFontSize: boolean\n fontFeatures: FontFeature[]\n\n horizontalConstraint: ConstraintType\n verticalConstraint: ConstraintType\n\n layoutMode: LayoutMode\n layoutDirection: LayoutDirection\n layoutWrap: LayoutWrap\n primaryAxisAlign: LayoutAlign\n counterAxisAlign: LayoutCounterAlign\n primaryAxisSizing: AxisSizingMode\n counterAxisSizing: AxisSizingMode\n itemSpacing: number\n counterAxisSpacing: number\n paddingTop: number\n paddingRight: number\n paddingBottom: number\n paddingLeft: number\n\n layoutPositioning: 'AUTO' | 'ABSOLUTE'\n layoutGrow: number\n layoutAlignSelf: LayoutAlignSelf\n\n vectorNetwork: VectorNetwork | null\n handleMirroring: HandleMirroring\n booleanOperation: 'UNION' | 'SUBTRACT' | 'INTERSECT' | 'EXCLUDE' | undefined\n fillGeometry: GeometryPath[]\n strokeGeometry: GeometryPath[]\n\n arcData: ArcData | null\n\n strokeCap: StrokeCap\n strokeJoin: StrokeJoin\n dashPattern: number[]\n\n borderTopWeight: number\n borderRightWeight: number\n borderBottomWeight: number\n borderLeftWeight: number\n independentStrokeWeights: boolean\n\n /**\n * The weight and alignment a node keeps for its strokes, as Figma keeps them on the node: they\n * last while it has no strokes, and a stroke added to it takes them. Each stroke still carries\n * its own `weight` and `align`, which win while the node has strokes.\n */\n strokeWeight: number\n strokeAlign: Stroke['align']\n\n strokeMiterLimit: number\n\n minWidth: number | null\n maxWidth: number | null\n minHeight: number | null\n maxHeight: number | null\n /**\n * The size whose proportions the layer keeps, as Figma stores it: the width and height it had\n * when the ratio was locked, not a reduced ratio. Null leaves the proportions free.\n */\n targetAspectRatio: Vector | null\n\n /** A connector's ends and the line between them; null on other layers. */\n connectorStart: ConnectorEndpoint | null\n connectorEnd: ConnectorEndpoint | null\n connectorLineType: ConnectorLineType\n connectorStartCap: StrokeCap\n connectorEndCap: StrokeCap\n /**\n * An elbow connector's segments between its first and last, in order, once one was dragged;\n * empty while it routes itself. Kept, unused, while the line is straight or curved.\n */\n connectorControlPoints: ConnectorControlPoint[]\n /**\n * A curved connector's two cubic control points, in the connector's own axes, once its curve\n * was dragged; null while it curves by itself. Kept, unused, while the line is not curved.\n */\n connectorCurveHandles: [Vector, Vector] | null\n /** Where a connector's label was dragged to; null while it sits midway along the line. */\n connectorLabelPosition: ConnectorLabelPosition | null\n\n isMask: boolean\n maskType: MaskType\n maskIsOutline: boolean\n\n gridTemplateColumns: GridTrack[]\n gridTemplateRows: GridTrack[]\n gridColumnGap: number\n gridRowGap: number\n gridPosition: GridPosition | null\n\n counterAxisAlignContent: 'AUTO' | 'SPACE_BETWEEN'\n itemReverseZIndex: boolean\n strokesIncludedInLayout: boolean\n\n expanded: boolean\n textTruncation: 'DISABLED' | 'ENDING'\n autoRename: boolean\n\n pointCount: number\n starInnerRadius: number\n /** The FigJam kind a SHAPE_WITH_TEXT draws; its label is the node's own text. */\n shapeWithTextType: ShapeWithTextType\n /** The height a shape with text was given; it grows past it to fit its label. 0 is unset. */\n shapeUserHeight: number\n /**\n * Whether a shape with text keeps its height and cuts its label off with \"…\" instead of growing,\n * as FigJam does once the shape's height was set.\n */\n shapeTruncates: boolean\n\n componentId: string | null\n instanceOverrides: InstanceOverrideState\n componentPropertyDefinitions: ComponentPropertyDefinition[]\n componentPropertyReferences: ComponentPropertyReference[]\n componentPropertyAssignments: Record<string, string>\n componentPropertyValues: Record<string, string>\n componentKey: string | null\n sourceLibraryKey: string | null\n publishId: string | null\n overrideKey: string | null\n sharedSymbolVersion: string | null\n publishedVersion: string | null\n librarySource: LibraryAssetSource | null\n /**\n * The layer of a library's source document that a library definition's layer copies, which pairs\n * it with the same layer in the library's next revision whatever that layer is called by then.\n */\n libraryLayerId: string | null\n isPublishable: boolean\n isSymbolPublishable: boolean\n /**\n * On an instance inside a component: its properties show on instances of that component,\n * as Figma's `isExposedInstance`.\n */\n isExposedInstance: boolean\n symbolDescription: string\n symbolLinks: SymbolLink[]\n variantPropSpecs: VariantPropSpec[]\n\n boundVariables: Record<string, string>\n /** Multipliers from bound numeric values to this occurrence's scene units. */\n variableBindingScales: Partial<Record<string, number>>\n /** Numeric units for new declarations owned by this node's occurrence scope. */\n variableAssignmentScales: Partial<Record<string, number>>\n /** Explicit coordinate scale relative to the containing component definition. */\n componentScale: number\n variableModes: VariableModeMap\n exportSettings: ExportSetting[]\n /**\n * The id of the status a team gave the layer, a state of the document's workflow such as Ready\n * for dev. It stays while the layer sits where it cannot show one; `effectiveStatus` tells\n * whether it shows.\n */\n status: string | null\n\n pluginData: PluginDataEntry[]\n pluginRelaunchData: PluginRelaunchDataEntry[]\n\n internalOnly: boolean\n\n flipX: boolean\n flipY: boolean\n\n textPicture: Uint8Array | null\n derivedTextGlyphs: DerivedTextGlyph[] | null\n /**\n * How far a text's lines reach down from its top: measured at its width when its text or width\n * changes, or read from the lines a file saved, and never saved itself. A fixed-size box does not\n * clip them, as in Figma, so its visual bounds reach this far. Null when not known.\n */\n derivedTextHeight: number | null\n /** Format-neutral layout path for text-on-path nodes. */\n textPathData: TextPathData | null\n /** Node-local box that maps textPathData into the node coordinate space. */\n textPathBox: Rect | null\n}\n\nexport type ComponentPropertyType = 'VARIANT' | 'TEXT' | 'BOOLEAN' | 'INSTANCE_SWAP' | 'SLOT'\n\n/** `SLOT_CONTENT` marks a frame whose children are the slot's content. */\nexport type ComponentPropertyReferenceField = 'VISIBLE' | 'TEXT' | 'INSTANCE_SWAP' | 'SLOT_CONTENT'\n\nexport interface ComponentPropertyReference {\n propertyId: string\n field: ComponentPropertyReferenceField\n}\n\n/** Guidance for a slot property; Figma reports a breach but still accepts the content. */\nexport interface SlotSettings {\n minChildren?: number\n maxChildren?: number\n allowPreferredValuesOnly: boolean\n displayEmptyByDefault: boolean\n /** Content added to the slot fills its counter axis. */\n stretchChildOnInsert: boolean\n}\n\n/**\n * For a `SLOT` property, an instance assignment (whatever its value) means the instance owns\n * that slot's content: the slot frame's children in the instance, which component sync keeps.\n */\nexport interface ComponentPropertyDefinition {\n id: string\n name: string\n type: ComponentPropertyType\n defaultValue: string\n variantOptions?: string[]\n preferredValues?: string[]\n description?: string\n slotSettings?: SlotSettings\n}\n\nexport type VariableType = 'COLOR' | 'FLOAT' | 'STRING' | 'BOOLEAN'\nexport interface VariableAlias {\n aliasId: string\n}\n\n/** Figma's two-argument color expression; opacity is a percentage, not an alpha multiplier. */\nexport interface VariableColorExpression {\n expression: 'COMPOSE_COLOR'\n color: Color | VariableAlias\n opacity: number | VariableAlias\n}\n\nexport type VariableLiteral = Color | number | string | boolean\n/** The arithmetic, comparison, logic and conversions a formula combines values with. */\nexport const VARIABLE_FORMULA_OPERATORS = [\n 'add',\n 'subtract',\n 'multiply',\n 'divide',\n 'negate',\n 'equal',\n 'notEqual',\n 'less',\n 'lessOrEqual',\n 'greater',\n 'greaterOrEqual',\n 'and',\n 'or',\n 'not',\n 'text',\n 'truthy',\n 'if'\n] as const\nexport type VariableFormulaOperator = (typeof VARIABLE_FORMULA_OPERATORS)[number]\nexport interface VariableFormulaOperation {\n operator: VariableFormulaOperator\n operands: VariableFormulaNode[]\n}\nexport type VariableFormulaNode = VariableLiteral | VariableAlias | VariableFormulaOperation\nexport interface VariableFormula {\n expression: 'FORMULA'\n type: VariableType\n value: VariableFormulaNode\n}\n/**\n * An imported expression OpenPencil cannot evaluate, kept as the file wrote it so saving writes it\n * back. `references` holds one entry per alias in `value`, in the order the format walks them, and\n * `null` where the alias names a variable this document does not have. `modes` holds the mode id of\n * each mode key in `value`, in the same walk order.\n */\nexport interface VariableUnsupportedExpression {\n expression: 'UNSUPPORTED'\n /** The function name the file gives, such as `VAR_MODE_LOOKUP`. */\n function: string\n value: Record<string, unknown>\n references: (string | null)[]\n modes: string[]\n}\nexport type VariableValue =\n | VariableLiteral\n | VariableAlias\n | VariableColorExpression\n | VariableFormula\n | VariableUnsupportedExpression\nexport type VariableModeMap = Record<string, string>\n\n/** Property pickers a variable is offered in, as Figma names them. */\nexport const VARIABLE_SCOPES = [\n 'ALL_SCOPES',\n 'TEXT_CONTENT',\n 'CORNER_RADIUS',\n 'WIDTH_HEIGHT',\n 'GAP',\n 'ALL_FILLS',\n 'FRAME_FILL',\n 'SHAPE_FILL',\n 'TEXT_FILL',\n 'STROKE',\n 'STROKE_FLOAT',\n 'EFFECT_FLOAT',\n 'EFFECT_COLOR',\n 'OPACITY',\n 'FONT_STYLE',\n 'FONT_FAMILY',\n 'FONT_SIZE',\n 'LINE_HEIGHT',\n 'LETTER_SPACING',\n 'PARAGRAPH_SPACING',\n 'PARAGRAPH_INDENT',\n 'FONT_VARIATIONS',\n 'TRANSFORM'\n] as const\nexport type VariableScope = (typeof VARIABLE_SCOPES)[number]\n\nexport const CODE_SYNTAX_PLATFORMS = ['WEB', 'ANDROID', 'iOS'] as const\nexport type CodeSyntaxPlatform = (typeof CODE_SYNTAX_PLATFORMS)[number]\n\n/**\n * The CSS unit a numeric token is written in. Lengths (`px`, `rem`) stay in canvas pixels in\n * the document and convert only when written as CSS; the other units store the number as written.\n */\nexport const TOKEN_UNITS = ['none', 'px', 'rem', '%', 'ms', 's', 'deg'] as const\nexport type TokenUnit = (typeof TOKEN_UNITS)[number]\n\n/**\n * CSS written in place of a number mode's value, such as `clamp(1rem, 4vw, 1.5rem)`. While the\n * mode holds a plain number, `resolved` records it, so a number later edited elsewhere, Figma\n * included, shows the CSS no longer describes it.\n */\nexport interface TokenExpression {\n css: string\n resolved?: number\n}\n\nexport interface Variable {\n id: string\n name: string\n type: VariableType\n collectionId: string\n valuesByMode: Record<string, VariableValue>\n description: string\n hiddenFromPublishing: boolean\n /** Absent means every scope. */\n scopes?: VariableScope[]\n /**\n * Per-platform code snippets, as Figma's Dev Mode shows them. A `WEB` snippet of `--x` or\n * `var(--x)` names the token's CSS custom property; otherwise the name is derived.\n */\n codeSyntax?: Partial<Record<CodeSyntaxPlatform, string>>\n /** FLOAT only. Absent means inferred when written as CSS. */\n unit?: TokenUnit\n /** Raw CSS by mode id, for values a number cannot express (`clamp()`, `calc()`). */\n expressions?: Record<string, TokenExpression>\n pluginData?: PluginDataEntry[]\n /** Published library key (from NodeChange.key). Used for assetRef resolution in colorVar. */\n key?: string\n /** Published library version (from NodeChange.version). Used for assetRef resolution in colorVar. */\n version?: string\n}\n\n/** Scalar numeric node fields accepted by numeric property controls. */\nexport type NumericNodeProperty = {\n [K in keyof SceneNode]-?: SceneNode[K] extends number ? K : never\n}[keyof SceneNode]\n\nexport interface VariableCollectionMode {\n modeId: string\n name: string\n /**\n * Where the mode applies in CSS: a selector (`[data-theme=\"dark\"]`, `.compact`) or an\n * at-rule prelude (`@media (max-width: 640px)`). Absent means the default for its axis.\n */\n condition?: string\n /** Where Figma lists the mode, as the file saved it; Figma orders a collection's modes by it. */\n sortPosition?: string\n}\n\nexport interface VariableCollection {\n id: string\n name: string\n /** The default mode comes first, as in Figma. */\n modes: VariableCollectionMode[]\n defaultModeId: string\n variableIds: string[]\n /**\n * The attribute that switches a mode with no condition of its own, `data-theme` for\n * `[data-theme=\"dark\"]`. Absent means one named after the collection.\n */\n modeAttribute?: string\n pluginData?: PluginDataEntry[]\n /**\n * Published library key, for a collection the file copies from a library. Such a collection\n * belongs to the library: Figma lists it with the library's, not the file's own.\n */\n key?: string\n /** Published library version, which references by key carry with it. */\n version?: string\n}\n\n/** Whether a collection is a library's copy, which takes no variables or modes of the file's. */\nexport function isLibraryCollection(collection: Pick<VariableCollection, 'key'>): boolean {\n return !!collection.key\n}\n\n/** An HTML attribute name a stylesheet can select on unescaped: `data-theme`, `theme`. */\nexport const MODE_ATTRIBUTE_PATTERN = /^[A-Za-z_][\\w-]*$/\n\nexport function isModeAttributeName(name: string): boolean {\n return name.length <= 100 && MODE_ATTRIBUTE_PATTERN.test(name)\n}\n"],"mappings":";;AA0YA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAylBA,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAmCA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,wBAAwB;CAAC;CAAO;CAAW;AAAK;;;;;AAO7D,MAAa,cAAc;CAAC;CAAQ;CAAM;CAAO;CAAK;CAAM;CAAK;AAAK;;AA+EtE,SAAgB,oBAAoB,YAAsD;CACxF,OAAO,CAAC,CAAC,WAAW;AACtB;;AAGA,MAAa,yBAAyB;AAEtC,SAAgB,oBAAoB,MAAuB;CACzD,OAAO,KAAK,UAAU,OAAO,uBAAuB,KAAK,IAAI;AAC/D"}
package/dist/undo.d.ts CHANGED
@@ -5,10 +5,28 @@ interface UndoEntry {
5
5
  inverse: () => void;
6
6
  coalesceKey?: string;
7
7
  }
8
+ /**
9
+ * Why committed history changed: a new step, a change joining the newest step, undo, redo, or
10
+ * clearing it.
11
+ */
12
+ type HistoryChange = 'record' | 'join' | 'undo' | 'redo' | 'clear';
8
13
  interface UndoManagerOptions {
9
14
  limit?: number;
10
- /** Called after recording, undoing, redoing, or clearing committed history. */
11
- onChange?: () => void;
15
+ /**
16
+ * Called after recording, joining, undoing, redoing, or clearing committed history, with which,
17
+ * and with the step recorded or joined for `'record'` and `'join'`.
18
+ */
19
+ onChange?: (change: HistoryChange, step?: UndoEntry) => void;
20
+ /**
21
+ * Called when an edit ends without a step, its changes undone or amounting to nothing: a batch
22
+ * rolled back, or an edit reported with `discardEdit`. History is unchanged, so `onChange` is not.
23
+ */
24
+ onDiscard?: () => void;
25
+ /**
26
+ * Runs an undo or a redo, which the editor runs outside edits in progress
27
+ * (`SceneGraph.runOutsideEdits`), so an agent's edit open meanwhile does not record it.
28
+ */
29
+ runReplay?: (replay: () => void) => void;
12
30
  }
13
31
  /** How many edits undo keeps by default. */
14
32
  declare const DEFAULT_HISTORY_LIMIT = 200;
@@ -21,6 +39,8 @@ declare class UndoManager {
21
39
  private readonly settlers;
22
40
  private readonly limit;
23
41
  private readonly onChange;
42
+ private readonly onDiscard;
43
+ private readonly runReplay;
24
44
  constructor(options?: UndoManagerOptions);
25
45
  apply(entry: UndoEntry): void;
26
46
  execute(entry: UndoEntry): void;
@@ -44,6 +64,11 @@ declare class UndoManager {
44
64
  commitBatch(): void;
45
65
  runBatch<T>(label: string, fn: () => T, coalesceKey?: string): T;
46
66
  rollbackBatch(): void;
67
+ /**
68
+ * Reports an edit that ended without a step, rolled back or changing nothing, as a rolled-back
69
+ * batch does. Called once the edit has closed, so `isRecording` tells whether another is open.
70
+ */
71
+ discardEdit(): void;
47
72
  /** Abandon provisional history without replaying it or changing committed undo/redo entries. */
48
73
  discardBatches(): void;
49
74
  clear(): void;
@@ -89,5 +114,5 @@ declare class UndoManager {
89
114
  private trimUndoStack;
90
115
  }
91
116
  //#endregion
92
- export { DEFAULT_HISTORY_LIMIT, UndoEntry, UndoManager, UndoManagerOptions };
117
+ export { DEFAULT_HISTORY_LIMIT, HistoryChange, UndoEntry, UndoManager, UndoManagerOptions };
93
118
  //# sourceMappingURL=undo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"undo.d.ts","names":[],"sources":["../src/undo.ts"],"mappings":";UAAiB;EACf;EACA;EACA;EACA;;UAGe;EACf;;EAEA;;;cAUW;cAEA;UACH;UAC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