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

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 (885) hide show
  1. package/dist/arrow-caps.d.ts +35 -14
  2. package/dist/arrow-caps.d.ts.map +1 -1
  3. package/dist/arrow-caps.js +286 -55
  4. package/dist/arrow-caps.js.map +1 -1
  5. package/dist/asset-keys.d.ts +17 -0
  6. package/dist/asset-keys.d.ts.map +1 -0
  7. package/dist/asset-keys.js.map +1 -0
  8. package/dist/behaviours/index.d.ts +6 -0
  9. package/dist/behaviours/index.js +6 -0
  10. package/dist/behaviours/kinds.d.ts +62 -0
  11. package/dist/behaviours/kinds.d.ts.map +1 -0
  12. package/dist/{chunks/behaviours → behaviours}/kinds.js +76 -75
  13. package/dist/behaviours/kinds.js.map +1 -0
  14. package/dist/behaviours/layers.d.ts +16 -0
  15. package/dist/behaviours/layers.d.ts.map +1 -0
  16. package/dist/behaviours/layers.js +43 -0
  17. package/dist/behaviours/layers.js.map +1 -0
  18. package/dist/behaviours/model.d.ts +48 -0
  19. package/dist/behaviours/model.d.ts.map +1 -0
  20. package/dist/behaviours/model.js +156 -0
  21. package/dist/behaviours/model.js.map +1 -0
  22. package/dist/behaviours/schema.d.ts +228 -0
  23. package/dist/behaviours/schema.d.ts.map +1 -0
  24. package/dist/behaviours/schema.js +86 -0
  25. package/dist/behaviours/schema.js.map +1 -0
  26. package/dist/behaviours/spec.d.ts +26 -0
  27. package/dist/behaviours/spec.d.ts.map +1 -0
  28. package/dist/{chunks/behaviours → behaviours}/spec.js +6 -29
  29. package/dist/behaviours/spec.js.map +1 -0
  30. package/dist/bindings.js +26 -0
  31. package/dist/bindings.js.map +1 -0
  32. package/dist/buffered-events.d.ts +21 -0
  33. package/dist/buffered-events.d.ts.map +1 -0
  34. package/dist/buffered-events.js.map +1 -0
  35. package/dist/checkpoint.d.ts +42 -0
  36. package/dist/checkpoint.d.ts.map +1 -0
  37. package/dist/checkpoint.js +249 -0
  38. package/dist/checkpoint.js.map +1 -0
  39. package/dist/clipping.d.ts +31 -0
  40. package/dist/clipping.d.ts.map +1 -0
  41. package/dist/clipping.js +125 -0
  42. package/dist/clipping.js.map +1 -0
  43. package/dist/color/contrast.d.ts +17 -0
  44. package/dist/color/contrast.d.ts.map +1 -0
  45. package/dist/{chunks/color → color}/contrast.js +2 -24
  46. package/dist/color/contrast.js.map +1 -0
  47. package/dist/color/index.d.ts +38 -0
  48. package/dist/color/index.d.ts.map +1 -0
  49. package/dist/color/index.js +110 -0
  50. package/dist/color/index.js.map +1 -0
  51. package/dist/color/management.d.ts +32 -0
  52. package/dist/color/management.d.ts.map +1 -0
  53. package/dist/color/management.js +187 -0
  54. package/dist/color/management.js.map +1 -0
  55. package/dist/color/normalize.d.ts +6 -0
  56. package/dist/color/normalize.d.ts.map +1 -0
  57. package/dist/color/normalize.js +15 -0
  58. package/dist/color/normalize.js.map +1 -0
  59. package/dist/color/okhcl.d.ts +33 -0
  60. package/dist/color/okhcl.d.ts.map +1 -0
  61. package/dist/color/okhcl.js +146 -0
  62. package/dist/color/okhcl.js.map +1 -0
  63. package/dist/color/schema.d.ts +11 -0
  64. package/dist/color/schema.d.ts.map +1 -0
  65. package/dist/color/schema.js +13 -0
  66. package/dist/color/schema.js.map +1 -0
  67. package/dist/comments/document.d.ts +23 -0
  68. package/dist/comments/document.d.ts.map +1 -0
  69. package/dist/{chunks/comments → comments}/document.js +2 -1
  70. package/dist/comments/document.js.map +1 -0
  71. package/dist/comments/index.d.ts +6 -0
  72. package/dist/comments/index.js +6 -0
  73. package/dist/comments/list.d.ts +25 -0
  74. package/dist/comments/list.d.ts.map +1 -0
  75. package/dist/comments/list.js +33 -0
  76. package/dist/comments/list.js.map +1 -0
  77. package/dist/comments/merge.d.ts +16 -0
  78. package/dist/comments/merge.d.ts.map +1 -0
  79. package/dist/{chunks/comments → comments}/merge.js +1 -1
  80. package/dist/comments/merge.js.map +1 -0
  81. package/dist/comments/schema.d.ts +8 -0
  82. package/dist/comments/schema.d.ts.map +1 -0
  83. package/dist/comments/schema.js +50 -0
  84. package/dist/comments/schema.js.map +1 -0
  85. package/dist/comments/threads.d.ts +59 -0
  86. package/dist/comments/threads.d.ts.map +1 -0
  87. package/dist/{chunks/comments/list.js → comments/threads.js} +3 -53
  88. package/dist/comments/threads.js.map +1 -0
  89. package/dist/components/exposure.d.ts +24 -0
  90. package/dist/components/exposure.d.ts.map +1 -0
  91. package/dist/components/exposure.js +51 -0
  92. package/dist/components/exposure.js.map +1 -0
  93. package/dist/components/index.d.ts +4 -0
  94. package/dist/components/index.js +4 -0
  95. package/dist/components/properties.d.ts +32 -0
  96. package/dist/components/properties.d.ts.map +1 -0
  97. package/dist/components/properties.js +180 -0
  98. package/dist/components/properties.js.map +1 -0
  99. package/dist/components/variants.d.ts +33 -0
  100. package/dist/components/variants.d.ts.map +1 -0
  101. package/dist/components/variants.js +58 -0
  102. package/dist/components/variants.js.map +1 -0
  103. package/dist/connectors/controls.d.ts +34 -0
  104. package/dist/connectors/controls.d.ts.map +1 -0
  105. package/dist/connectors/controls.js +196 -0
  106. package/dist/connectors/controls.js.map +1 -0
  107. package/dist/connectors/create.d.ts +23 -0
  108. package/dist/connectors/create.d.ts.map +1 -0
  109. package/dist/connectors/create.js +33 -0
  110. package/dist/connectors/create.js.map +1 -0
  111. package/dist/connectors/elbow.js +191 -0
  112. package/dist/connectors/elbow.js.map +1 -0
  113. package/dist/connectors/gaps.d.ts +10 -0
  114. package/dist/connectors/gaps.d.ts.map +1 -0
  115. package/dist/connectors/gaps.js +86 -0
  116. package/dist/connectors/gaps.js.map +1 -0
  117. package/dist/connectors/hit.d.ts +11 -0
  118. package/dist/connectors/hit.d.ts.map +1 -0
  119. package/dist/connectors/hit.js +47 -0
  120. package/dist/connectors/hit.js.map +1 -0
  121. package/dist/connectors/index.d.ts +11 -0
  122. package/dist/connectors/index.js +11 -0
  123. package/dist/connectors/label.d.ts +32 -0
  124. package/dist/connectors/label.d.ts.map +1 -0
  125. package/dist/connectors/label.js +213 -0
  126. package/dist/connectors/label.js.map +1 -0
  127. package/dist/connectors/layout.d.ts +46 -0
  128. package/dist/connectors/layout.d.ts.map +1 -0
  129. package/dist/connectors/layout.js +234 -0
  130. package/dist/connectors/layout.js.map +1 -0
  131. package/dist/connectors/pieces.d.ts +22 -0
  132. package/dist/connectors/pieces.d.ts.map +1 -0
  133. package/dist/connectors/pieces.js +156 -0
  134. package/dist/connectors/pieces.js.map +1 -0
  135. package/dist/connectors/route.d.ts +23 -0
  136. package/dist/connectors/route.d.ts.map +1 -0
  137. package/dist/connectors/route.js +107 -0
  138. package/dist/connectors/route.js.map +1 -0
  139. package/dist/connectors/sides.d.ts +23 -0
  140. package/dist/connectors/sides.d.ts.map +1 -0
  141. package/dist/connectors/sides.js +98 -0
  142. package/dist/connectors/sides.js.map +1 -0
  143. package/dist/connectors/sublayers.d.ts +76 -0
  144. package/dist/connectors/sublayers.d.ts.map +1 -0
  145. package/dist/connectors/sublayers.js +208 -0
  146. package/dist/connectors/sublayers.js.map +1 -0
  147. package/dist/constants.d.ts +11 -2
  148. package/dist/constants.d.ts.map +1 -0
  149. package/dist/constants.js +25 -1
  150. package/dist/constants.js.map +1 -0
  151. package/dist/coordinate.d.ts +94 -2
  152. package/dist/coordinate.d.ts.map +1 -0
  153. package/dist/coordinate.js +268 -1
  154. package/dist/coordinate.js.map +1 -0
  155. package/dist/copy.d.ts +49 -2
  156. package/dist/copy.d.ts.map +1 -0
  157. package/dist/copy.js +264 -2
  158. package/dist/copy.js.map +1 -0
  159. package/dist/css/blend.d.ts +11 -0
  160. package/dist/css/blend.d.ts.map +1 -0
  161. package/dist/css/blend.js +30 -0
  162. package/dist/css/blend.js.map +1 -0
  163. package/dist/css/grid.d.ts +7 -0
  164. package/dist/css/grid.d.ts.map +1 -0
  165. package/dist/{chunks/css → css}/grid.js +2 -33
  166. package/dist/css/grid.js.map +1 -0
  167. package/dist/css/index.d.ts +7 -0
  168. package/dist/css/index.js +7 -0
  169. package/dist/css/layout.d.ts +17 -0
  170. package/dist/css/layout.d.ts.map +1 -0
  171. package/dist/css/layout.js +45 -0
  172. package/dist/css/layout.js.map +1 -0
  173. package/dist/css/shadows.d.ts +10 -0
  174. package/dist/css/shadows.d.ts.map +1 -0
  175. package/dist/css/shadows.js +64 -0
  176. package/dist/css/shadows.js.map +1 -0
  177. package/dist/css/text.d.ts +22 -0
  178. package/dist/css/text.d.ts.map +1 -0
  179. package/dist/css/text.js +76 -0
  180. package/dist/css/text.js.map +1 -0
  181. package/dist/css/values.d.ts +14 -0
  182. package/dist/css/values.d.ts.map +1 -0
  183. package/dist/css/values.js +36 -0
  184. package/dist/css/values.js.map +1 -0
  185. package/dist/cubic.d.ts +7 -0
  186. package/dist/cubic.d.ts.map +1 -0
  187. package/dist/cubic.js +17 -0
  188. package/dist/cubic.js.map +1 -0
  189. package/dist/events.js.map +1 -0
  190. package/dist/export-format.d.ts +25 -0
  191. package/dist/export-format.d.ts.map +1 -0
  192. package/dist/export-format.js +47 -0
  193. package/dist/export-format.js.map +1 -0
  194. package/dist/export-scale.d.ts +14 -0
  195. package/dist/export-scale.d.ts.map +1 -0
  196. package/dist/export-scale.js +19 -0
  197. package/dist/export-scale.js.map +1 -0
  198. package/dist/fields/appearance.d.ts +9 -0
  199. package/dist/fields/appearance.d.ts.map +1 -0
  200. package/dist/fields/appearance.js +36 -0
  201. package/dist/fields/appearance.js.map +1 -0
  202. package/dist/fields/geometry.d.ts +7 -0
  203. package/dist/fields/geometry.d.ts.map +1 -0
  204. package/dist/fields/geometry.js.map +1 -0
  205. package/dist/fields/index.d.ts +5 -0
  206. package/dist/fields/index.js +5 -0
  207. package/dist/fields/layout.d.ts +10 -0
  208. package/dist/fields/layout.d.ts.map +1 -0
  209. package/dist/fields/layout.js +49 -0
  210. package/dist/fields/layout.js.map +1 -0
  211. package/dist/fields/text.d.ts +11 -0
  212. package/dist/fields/text.d.ts.map +1 -0
  213. package/dist/fields/text.js +64 -0
  214. package/dist/fields/text.js.map +1 -0
  215. package/dist/fig-compression.d.ts +11 -0
  216. package/dist/fig-compression.d.ts.map +1 -0
  217. package/dist/fig-compression.js +15 -0
  218. package/dist/fig-compression.js.map +1 -0
  219. package/dist/figjam/index.d.ts +3 -0
  220. package/dist/figjam/index.js +3 -0
  221. package/dist/figjam/palette.d.ts +270 -0
  222. package/dist/figjam/palette.d.ts.map +1 -0
  223. package/dist/figjam/palette.js +439 -0
  224. package/dist/figjam/palette.js.map +1 -0
  225. package/dist/figjam/text.d.ts +70 -0
  226. package/dist/figjam/text.d.ts.map +1 -0
  227. package/dist/figjam/text.js +95 -0
  228. package/dist/figjam/text.js.map +1 -0
  229. package/dist/font-style.d.ts +46 -0
  230. package/dist/font-style.d.ts.map +1 -0
  231. package/dist/font-style.js +127 -0
  232. package/dist/font-style.js.map +1 -0
  233. package/dist/generated/index.d.ts +44 -0
  234. package/dist/generated/index.d.ts.map +1 -0
  235. package/dist/generated/index.js +58 -0
  236. package/dist/generated/index.js.map +1 -0
  237. package/dist/generated/kind.d.ts +27 -0
  238. package/dist/generated/kind.d.ts.map +1 -0
  239. package/dist/generated/shape-with-text.d.ts +43 -0
  240. package/dist/generated/shape-with-text.d.ts.map +1 -0
  241. package/dist/generated/shape-with-text.js +135 -0
  242. package/dist/generated/shape-with-text.js.map +1 -0
  243. package/dist/generated/sticky.d.ts +128 -0
  244. package/dist/generated/sticky.d.ts.map +1 -0
  245. package/dist/generated/sticky.js +233 -0
  246. package/dist/generated/sticky.js.map +1 -0
  247. package/dist/geometry.d.ts +89 -2
  248. package/dist/geometry.d.ts.map +1 -0
  249. package/dist/geometry.js +306 -2
  250. package/dist/geometry.js.map +1 -0
  251. package/dist/gradient.d.ts +9 -2
  252. package/dist/gradient.d.ts.map +1 -1
  253. package/dist/gradient.js +13 -1
  254. package/dist/gradient.js.map +1 -1
  255. package/dist/graph.d.ts +178 -0
  256. package/dist/graph.d.ts.map +1 -0
  257. package/dist/graph.js +625 -0
  258. package/dist/graph.js.map +1 -0
  259. package/dist/group-bounds.d.ts +42 -0
  260. package/dist/group-bounds.d.ts.map +1 -0
  261. package/dist/{chunks/group-bounds.js → group-bounds.js} +56 -14
  262. package/dist/group-bounds.js.map +1 -0
  263. package/dist/guides.d.ts +21 -2
  264. package/dist/guides.d.ts.map +1 -0
  265. package/dist/guides.js +5 -1
  266. package/dist/guides.js.map +1 -1
  267. package/dist/hit-test.d.ts +48 -2
  268. package/dist/hit-test.d.ts.map +1 -0
  269. package/dist/hit-test.js +75 -57
  270. package/dist/hit-test.js.map +1 -1
  271. package/dist/icons/glyph.d.ts +22 -0
  272. package/dist/icons/glyph.d.ts.map +1 -0
  273. package/dist/{chunks/icons → icons}/glyph.js +2 -40
  274. package/dist/icons/glyph.js.map +1 -0
  275. package/dist/icons/index.d.ts +4 -0
  276. package/dist/icons/index.js +4 -0
  277. package/dist/icons/model.d.ts +29 -0
  278. package/dist/icons/model.d.ts.map +1 -0
  279. package/dist/icons/model.js +51 -0
  280. package/dist/icons/model.js.map +1 -0
  281. package/dist/icons/schema.d.ts +31 -0
  282. package/dist/icons/schema.d.ts.map +1 -0
  283. package/dist/icons/schema.js +28 -0
  284. package/dist/icons/schema.js.map +1 -0
  285. package/dist/ids.d.ts +12 -0
  286. package/dist/ids.d.ts.map +1 -0
  287. package/dist/ids.js +31 -0
  288. package/dist/ids.js.map +1 -0
  289. package/dist/images.d.ts +39 -2
  290. package/dist/images.d.ts.map +1 -0
  291. package/dist/images.js +67 -9
  292. package/dist/images.js.map +1 -1
  293. package/dist/index.d.ts +5 -7
  294. package/dist/index.js +5 -23
  295. package/dist/instances/assignments.js +89 -0
  296. package/dist/instances/assignments.js.map +1 -0
  297. package/dist/instances/content-size.js +60 -0
  298. package/dist/instances/content-size.js.map +1 -0
  299. package/dist/instances/copies.js +161 -0
  300. package/dist/instances/copies.js.map +1 -0
  301. package/dist/instances/cycles.d.ts +20 -0
  302. package/dist/instances/cycles.d.ts.map +1 -0
  303. package/dist/instances/cycles.js +53 -0
  304. package/dist/instances/cycles.js.map +1 -0
  305. package/dist/instances/fields.d.ts +18 -0
  306. package/dist/instances/fields.d.ts.map +1 -0
  307. package/dist/instances/fields.js +90 -0
  308. package/dist/instances/fields.js.map +1 -0
  309. package/dist/instances/index.d.ts +38 -0
  310. package/dist/instances/index.d.ts.map +1 -0
  311. package/dist/instances/index.js +180 -0
  312. package/dist/instances/index.js.map +1 -0
  313. package/dist/instances/kept-overrides.js +204 -0
  314. package/dist/instances/kept-overrides.js.map +1 -0
  315. package/dist/instances/main-component.d.ts +13 -0
  316. package/dist/instances/main-component.d.ts.map +1 -0
  317. package/dist/instances/main-component.js +50 -0
  318. package/dist/instances/main-component.js.map +1 -0
  319. package/dist/instances/overrides.d.ts +51 -0
  320. package/dist/instances/overrides.d.ts.map +1 -0
  321. package/dist/instances/overrides.js +158 -0
  322. package/dist/instances/overrides.js.map +1 -0
  323. package/dist/instances/placement.js +30 -0
  324. package/dist/instances/placement.js.map +1 -0
  325. package/dist/instances/source-walk.js +31 -0
  326. package/dist/instances/source-walk.js.map +1 -0
  327. package/dist/instances/swap.js +288 -0
  328. package/dist/instances/swap.js.map +1 -0
  329. package/dist/instances/sync.js +327 -0
  330. package/dist/instances/sync.js.map +1 -0
  331. package/dist/instances/vector-geometry.js +70 -0
  332. package/dist/instances/vector-geometry.js.map +1 -0
  333. package/dist/layout/aspect-ratio.d.ts +27 -0
  334. package/dist/layout/aspect-ratio.d.ts.map +1 -0
  335. package/dist/layout/aspect-ratio.js +45 -0
  336. package/dist/layout/aspect-ratio.js.map +1 -0
  337. package/dist/layout/guides.d.ts +25 -0
  338. package/dist/layout/guides.d.ts.map +1 -0
  339. package/dist/layout/guides.js +105 -0
  340. package/dist/layout/guides.js.map +1 -0
  341. package/dist/layout/index.d.ts +5 -0
  342. package/dist/{layout.js → layout/index.js} +4 -3
  343. package/dist/layout/keywords.d.ts +26 -0
  344. package/dist/layout/keywords.d.ts.map +1 -0
  345. package/dist/layout/keywords.js +59 -0
  346. package/dist/layout/keywords.js.map +1 -0
  347. package/dist/layout/sizing.d.ts +40 -0
  348. package/dist/layout/sizing.d.ts.map +1 -0
  349. package/dist/layout/sizing.js +122 -0
  350. package/dist/layout/sizing.js.map +1 -0
  351. package/dist/layout/writes.js +55 -0
  352. package/dist/layout/writes.js.map +1 -0
  353. package/dist/matrix.d.ts +16 -2
  354. package/dist/matrix.d.ts.map +1 -0
  355. package/dist/matrix.js +119 -1
  356. package/dist/matrix.js.map +1 -0
  357. package/dist/mutation-impact.d.ts +23 -0
  358. package/dist/mutation-impact.d.ts.map +1 -0
  359. package/dist/mutation-impact.js +67 -0
  360. package/dist/mutation-impact.js.map +1 -0
  361. package/dist/node-defaults.d.ts +22 -2
  362. package/dist/node-defaults.d.ts.map +1 -0
  363. package/dist/node-defaults.js +254 -2
  364. package/dist/node-defaults.js.map +1 -0
  365. package/dist/outline/flatten.d.ts +15 -0
  366. package/dist/outline/flatten.d.ts.map +1 -0
  367. package/dist/outline/flatten.js +189 -0
  368. package/dist/outline/flatten.js.map +1 -0
  369. package/dist/outline/heads.js +34 -0
  370. package/dist/outline/heads.js.map +1 -0
  371. package/dist/outline/hit.d.ts +21 -0
  372. package/dist/outline/hit.d.ts.map +1 -0
  373. package/dist/outline/hit.js +276 -0
  374. package/dist/outline/hit.js.map +1 -0
  375. package/dist/outline/index.d.ts +5 -0
  376. package/dist/outline/index.js +5 -0
  377. package/dist/outline/point.d.ts +16 -0
  378. package/dist/outline/point.d.ts.map +1 -0
  379. package/dist/outline/point.js +42 -0
  380. package/dist/outline/point.js.map +1 -0
  381. package/dist/outline/shapes.d.ts +35 -0
  382. package/dist/outline/shapes.d.ts.map +1 -0
  383. package/dist/outline/shapes.js +181 -0
  384. package/dist/outline/shapes.js.map +1 -0
  385. package/dist/paints/index.d.ts +2 -0
  386. package/dist/paints/index.js +2 -0
  387. package/dist/paints/schema.d.ts +77 -0
  388. package/dist/paints/schema.d.ts.map +1 -0
  389. package/dist/paints/schema.js +56 -0
  390. package/dist/paints/schema.js.map +1 -0
  391. package/dist/parse-path.d.ts +9 -1
  392. package/dist/parse-path.d.ts.map +1 -1
  393. package/dist/parse-path.js +39 -2
  394. package/dist/parse-path.js.map +1 -1
  395. package/dist/plugin-data/field.d.ts +47 -0
  396. package/dist/plugin-data/field.d.ts.map +1 -0
  397. package/dist/plugin-data/field.js +73 -0
  398. package/dist/plugin-data/field.js.map +1 -0
  399. package/dist/plugin-data/fields.d.ts +143 -0
  400. package/dist/plugin-data/fields.d.ts.map +1 -0
  401. package/dist/plugin-data/fields.js +168 -0
  402. package/dist/plugin-data/fields.js.map +1 -0
  403. package/dist/plugin-data/index.d.ts +3 -0
  404. package/dist/plugin-data/index.js +3 -0
  405. package/dist/polygon.d.ts +4 -2
  406. package/dist/polygon.d.ts.map +1 -1
  407. package/dist/polygon.js +17 -2
  408. package/dist/polygon.js.map +1 -1
  409. package/dist/preview.d.ts +12 -2
  410. package/dist/preview.d.ts.map +1 -0
  411. package/dist/preview.js +62 -1
  412. package/dist/preview.js.map +1 -0
  413. package/dist/{primitives2.d.ts → primitives/index.d.ts} +4 -3
  414. package/dist/primitives/index.d.ts.map +1 -0
  415. package/dist/primitives/index.js +2 -0
  416. package/dist/primitives/schema.d.ts +18 -0
  417. package/dist/primitives/schema.d.ts.map +1 -0
  418. package/dist/primitives/schema.js +19 -0
  419. package/dist/primitives/schema.js.map +1 -0
  420. package/dist/random.js +24 -1
  421. package/dist/random.js.map +1 -0
  422. package/dist/resize.d.ts +6 -4
  423. package/dist/resize.d.ts.map +1 -1
  424. package/dist/resize.js +287 -2
  425. package/dist/resize.js.map +1 -0
  426. package/dist/scaling/index.d.ts +3 -0
  427. package/dist/scaling/index.js +3 -0
  428. package/dist/scaling/node.d.ts +6 -0
  429. package/dist/scaling/node.d.ts.map +1 -0
  430. package/dist/scaling/node.js +148 -0
  431. package/dist/scaling/node.js.map +1 -0
  432. package/dist/scaling/tree.d.ts +7 -0
  433. package/dist/scaling/tree.d.ts.map +1 -0
  434. package/dist/scaling/tree.js +47 -0
  435. package/dist/scaling/tree.js.map +1 -0
  436. package/dist/shaders/index.d.ts +4 -0
  437. package/dist/shaders/index.js +4 -0
  438. package/dist/shaders/model.d.ts +41 -0
  439. package/dist/shaders/model.d.ts.map +1 -0
  440. package/dist/shaders/model.js +71 -0
  441. package/dist/shaders/model.js.map +1 -0
  442. package/dist/shaders/schema.d.ts +41 -0
  443. package/dist/shaders/schema.d.ts.map +1 -0
  444. package/dist/shaders/schema.js +36 -0
  445. package/dist/shaders/schema.js.map +1 -0
  446. package/dist/shaders/still.d.ts +18 -0
  447. package/dist/shaders/still.d.ts.map +1 -0
  448. package/dist/shaders/still.js +36 -0
  449. package/dist/shaders/still.js.map +1 -0
  450. package/dist/shape-with-text/fit.d.ts +28 -0
  451. package/dist/shape-with-text/fit.d.ts.map +1 -0
  452. package/dist/shape-with-text/fit.js +271 -0
  453. package/dist/shape-with-text/fit.js.map +1 -0
  454. package/dist/shape-with-text/geometry.d.ts +20 -0
  455. package/dist/shape-with-text/geometry.d.ts.map +1 -0
  456. package/dist/shape-with-text/geometry.js +539 -0
  457. package/dist/shape-with-text/geometry.js.map +1 -0
  458. package/dist/shape-with-text/index.d.ts +4 -0
  459. package/dist/shape-with-text/index.js +4 -0
  460. package/dist/shape-with-text/kinds.d.ts +20 -0
  461. package/dist/shape-with-text/kinds.d.ts.map +1 -0
  462. package/dist/shape-with-text/kinds.js +86 -0
  463. package/dist/shape-with-text/kinds.js.map +1 -0
  464. package/dist/shared-styles.d.ts +51 -0
  465. package/dist/shared-styles.d.ts.map +1 -0
  466. package/dist/shared-styles.js +186 -0
  467. package/dist/shared-styles.js.map +1 -0
  468. package/dist/slots/authoring.d.ts +27 -0
  469. package/dist/slots/authoring.d.ts.map +1 -0
  470. package/dist/slots/authoring.js +77 -0
  471. package/dist/slots/authoring.js.map +1 -0
  472. package/dist/slots/content.d.ts +41 -0
  473. package/dist/slots/content.d.ts.map +1 -0
  474. package/dist/slots/content.js +105 -0
  475. package/dist/slots/content.js.map +1 -0
  476. package/dist/slots/frames.d.ts +40 -0
  477. package/dist/slots/frames.d.ts.map +1 -0
  478. package/dist/slots/frames.js +118 -0
  479. package/dist/slots/frames.js.map +1 -0
  480. package/dist/slots/index.d.ts +5 -0
  481. package/dist/slots/index.js +5 -0
  482. package/dist/slots/limits.d.ts +14 -0
  483. package/dist/slots/limits.d.ts.map +1 -0
  484. package/dist/slots/limits.js +28 -0
  485. package/dist/slots/limits.js.map +1 -0
  486. package/dist/snap.d.ts +21 -2
  487. package/dist/snap.d.ts.map +1 -0
  488. package/dist/snap.js +109 -1
  489. package/dist/snap.js.map +1 -0
  490. package/dist/source-metadata.js +10 -1
  491. package/dist/source-metadata.js.map +1 -0
  492. package/dist/statuses/impact.d.ts +18 -0
  493. package/dist/statuses/impact.d.ts.map +1 -0
  494. package/dist/statuses/impact.js +33 -0
  495. package/dist/statuses/impact.js.map +1 -0
  496. package/dist/statuses/index.d.ts +5 -0
  497. package/dist/statuses/index.js +5 -0
  498. package/dist/statuses/node.d.ts +22 -0
  499. package/dist/statuses/node.d.ts.map +1 -0
  500. package/dist/statuses/node.js +47 -0
  501. package/dist/statuses/node.js.map +1 -0
  502. package/dist/statuses/schema.d.ts +59 -0
  503. package/dist/statuses/schema.d.ts.map +1 -0
  504. package/dist/statuses/schema.js +27 -0
  505. package/dist/statuses/schema.js.map +1 -0
  506. package/dist/statuses/workflow.d.ts +120 -0
  507. package/dist/statuses/workflow.d.ts.map +1 -0
  508. package/dist/statuses/workflow.js +135 -0
  509. package/dist/statuses/workflow.js.map +1 -0
  510. package/dist/{text-direction.d.ts → text/direction.d.ts} +2 -2
  511. package/dist/text/direction.d.ts.map +1 -0
  512. package/dist/{text-direction.js → text/direction.js} +1 -1
  513. package/dist/text/direction.js.map +1 -0
  514. package/dist/text/index.d.ts +7 -0
  515. package/dist/text/index.js +7 -0
  516. package/dist/text/lengths.d.ts +24 -0
  517. package/dist/text/lengths.d.ts.map +1 -0
  518. package/dist/text/lengths.js +49 -0
  519. package/dist/text/lengths.js.map +1 -0
  520. package/dist/text/lists.d.ts +44 -0
  521. package/dist/text/lists.d.ts.map +1 -0
  522. package/dist/text/lists.js +100 -0
  523. package/dist/text/lists.js.map +1 -0
  524. package/dist/text/overflow.d.ts +11 -0
  525. package/dist/text/overflow.d.ts.map +1 -0
  526. package/dist/text/overflow.js +13 -0
  527. package/dist/text/overflow.js.map +1 -0
  528. package/dist/text/paragraphs.d.ts +62 -0
  529. package/dist/text/paragraphs.d.ts.map +1 -0
  530. package/dist/text/paragraphs.js +166 -0
  531. package/dist/text/paragraphs.js.map +1 -0
  532. package/dist/{text-picture.d.ts → text/picture.d.ts} +3 -4
  533. package/dist/text/picture.d.ts.map +1 -0
  534. package/dist/text/picture.js +38 -0
  535. package/dist/text/picture.js.map +1 -0
  536. package/dist/text/references.d.ts +21 -0
  537. package/dist/text/references.d.ts.map +1 -0
  538. package/dist/text/references.js +43 -0
  539. package/dist/text/references.js.map +1 -0
  540. package/dist/text/schema.d.ts +10 -0
  541. package/dist/text/schema.d.ts.map +1 -0
  542. package/dist/text/schema.js +11 -0
  543. package/dist/text/schema.js.map +1 -0
  544. package/dist/transfer/apply.d.ts +9 -0
  545. package/dist/transfer/apply.d.ts.map +1 -0
  546. package/dist/transfer/apply.js +65 -0
  547. package/dist/transfer/apply.js.map +1 -0
  548. package/dist/transfer/copied.d.ts +14 -0
  549. package/dist/transfer/copied.d.ts.map +1 -0
  550. package/dist/transfer/copied.js +52 -0
  551. package/dist/transfer/copied.js.map +1 -0
  552. package/dist/transfer/history.d.ts +8 -0
  553. package/dist/transfer/history.d.ts.map +1 -0
  554. package/dist/transfer/history.js +32 -0
  555. package/dist/transfer/history.js.map +1 -0
  556. package/dist/transfer/identity.js +12 -0
  557. package/dist/transfer/identity.js.map +1 -0
  558. package/dist/transfer/index.d.ts +8 -0
  559. package/dist/transfer/index.js +8 -0
  560. package/dist/transfer/nodes.d.ts +14 -0
  561. package/dist/transfer/nodes.d.ts.map +1 -0
  562. package/dist/transfer/nodes.js +78 -0
  563. package/dist/transfer/nodes.js.map +1 -0
  564. package/dist/transfer/plan.d.ts +29 -0
  565. package/dist/transfer/plan.d.ts.map +1 -0
  566. package/dist/transfer/plan.js +106 -0
  567. package/dist/transfer/plan.js.map +1 -0
  568. package/dist/transfer/references.js +10 -0
  569. package/dist/transfer/references.js.map +1 -0
  570. package/dist/transfer/remove.d.ts +8 -0
  571. package/dist/transfer/remove.d.ts.map +1 -0
  572. package/dist/transfer/remove.js +34 -0
  573. package/dist/transfer/remove.js.map +1 -0
  574. package/dist/transfer/validation.js +39 -0
  575. package/dist/transfer/validation.js.map +1 -0
  576. package/dist/transfer/variables.d.ts +15 -0
  577. package/dist/transfer/variables.d.ts.map +1 -0
  578. package/dist/transfer/variables.js +52 -0
  579. package/dist/transfer/variables.js.map +1 -0
  580. package/dist/types.d.ts +195 -2007
  581. package/dist/types.d.ts.map +1 -1
  582. package/dist/types.js +89 -2
  583. package/dist/types.js.map +1 -0
  584. package/dist/undo.d.ts +93 -2
  585. package/dist/undo.d.ts.map +1 -0
  586. package/dist/undo.js +235 -1
  587. package/dist/undo.js.map +1 -0
  588. package/dist/variables/bindings.d.ts +83 -0
  589. package/dist/variables/bindings.d.ts.map +1 -0
  590. package/dist/variables/bindings.js +314 -0
  591. package/dist/variables/bindings.js.map +1 -0
  592. package/dist/variables/corners.d.ts +12 -0
  593. package/dist/variables/corners.d.ts.map +1 -0
  594. package/dist/variables/corners.js +38 -0
  595. package/dist/variables/corners.js.map +1 -0
  596. package/dist/variables/fields.d.ts +43 -0
  597. package/dist/variables/fields.d.ts.map +1 -0
  598. package/dist/variables/fields.js +104 -0
  599. package/dist/variables/fields.js.map +1 -0
  600. package/dist/variables/formula/check.d.ts +14 -0
  601. package/dist/variables/formula/check.d.ts.map +1 -0
  602. package/dist/variables/formula/check.js +73 -0
  603. package/dist/variables/formula/check.js.map +1 -0
  604. package/dist/variables/formula/evaluate.d.ts +7 -0
  605. package/dist/variables/formula/evaluate.d.ts.map +1 -0
  606. package/dist/variables/formula/evaluate.js +30 -0
  607. package/dist/variables/formula/evaluate.js.map +1 -0
  608. package/dist/variables/formula/index.d.ts +21 -0
  609. package/dist/variables/formula/index.d.ts.map +1 -0
  610. package/dist/variables/formula/index.js +77 -0
  611. package/dist/variables/formula/index.js.map +1 -0
  612. package/dist/variables/formula/parse.js +141 -0
  613. package/dist/variables/formula/parse.js.map +1 -0
  614. package/dist/variables/formula/print.d.ts +25 -0
  615. package/dist/variables/formula/print.d.ts.map +1 -0
  616. package/dist/variables/formula/print.js +105 -0
  617. package/dist/variables/formula/print.js.map +1 -0
  618. package/dist/variables/formula/schema.d.ts +7 -0
  619. package/dist/variables/formula/schema.d.ts.map +1 -0
  620. package/dist/variables/formula/schema.js +62 -0
  621. package/dist/variables/formula/schema.js.map +1 -0
  622. package/dist/variables/formula/signatures.d.ts +9 -0
  623. package/dist/variables/formula/signatures.d.ts.map +1 -0
  624. package/dist/variables/formula/signatures.js +238 -0
  625. package/dist/variables/formula/signatures.js.map +1 -0
  626. package/dist/variables/formula/tokens.d.ts +26 -0
  627. package/dist/variables/formula/tokens.d.ts.map +1 -0
  628. package/dist/variables/formula/tokens.js +82 -0
  629. package/dist/variables/formula/tokens.js.map +1 -0
  630. package/dist/variables/formula/tree.d.ts +22 -0
  631. package/dist/variables/formula/tree.d.ts.map +1 -0
  632. package/dist/variables/formula/tree.js +35 -0
  633. package/dist/variables/formula/tree.js.map +1 -0
  634. package/dist/variables/index.d.ts +41 -0
  635. package/dist/variables/index.d.ts.map +1 -0
  636. package/dist/variables/index.js +238 -0
  637. package/dist/variables/index.js.map +1 -0
  638. package/dist/variables/resolution.d.ts +39 -0
  639. package/dist/variables/resolution.d.ts.map +1 -0
  640. package/dist/variables/resolution.js +154 -0
  641. package/dist/variables/resolution.js.map +1 -0
  642. package/dist/variables/schema.d.ts +40 -0
  643. package/dist/variables/schema.d.ts.map +1 -0
  644. package/dist/variables/schema.js +32 -0
  645. package/dist/variables/schema.js.map +1 -0
  646. package/dist/variables/text.d.ts +16 -0
  647. package/dist/variables/text.d.ts.map +1 -0
  648. package/dist/variables/text.js +49 -0
  649. package/dist/variables/text.js.map +1 -0
  650. package/dist/variables/token.d.ts +18 -0
  651. package/dist/variables/token.d.ts.map +1 -0
  652. package/dist/variables/token.js +39 -0
  653. package/dist/variables/token.js.map +1 -0
  654. package/dist/variables/units.js +19 -0
  655. package/dist/variables/units.js.map +1 -0
  656. package/dist/variables/value.d.ts +12 -0
  657. package/dist/variables/value.d.ts.map +1 -0
  658. package/dist/variables/value.js +70 -0
  659. package/dist/variables/value.js.map +1 -0
  660. package/dist/vector-network.d.ts +65 -2
  661. package/dist/vector-network.d.ts.map +1 -0
  662. package/dist/vector-network.js +375 -2
  663. package/dist/vector-network.js.map +1 -0
  664. package/package.json +303 -137
  665. package/src/arrow-caps.ts +279 -62
  666. package/src/behaviours/index.ts +5 -0
  667. package/src/behaviours/kinds.ts +51 -34
  668. package/src/behaviours/layers.ts +5 -3
  669. package/src/behaviours/model.ts +25 -22
  670. package/src/behaviours/schema.ts +64 -13
  671. package/src/behaviours/spec.ts +11 -50
  672. package/src/bindings.ts +11 -2
  673. package/src/checkpoint.ts +252 -5
  674. package/src/clipping.ts +112 -0
  675. package/src/color/index.ts +1 -0
  676. package/src/color/schema.ts +10 -0
  677. package/src/comments/document.ts +1 -1
  678. package/src/comments/index.ts +5 -0
  679. package/src/comments/schema.ts +51 -0
  680. package/src/comments/threads.ts +1 -1
  681. package/src/components/exposure.ts +1 -1
  682. package/src/components/index.ts +8 -0
  683. package/src/components/properties.ts +94 -4
  684. package/src/components/variants.ts +52 -31
  685. package/src/connectors/controls.ts +229 -0
  686. package/src/connectors/create.ts +48 -0
  687. package/src/connectors/elbow.ts +235 -0
  688. package/src/connectors/gaps.ts +72 -0
  689. package/src/connectors/hit.ts +49 -0
  690. package/src/connectors/index.ts +28 -0
  691. package/src/connectors/label.ts +238 -0
  692. package/src/connectors/layout.ts +280 -0
  693. package/src/connectors/pieces.ts +141 -0
  694. package/src/connectors/route.ts +148 -0
  695. package/src/connectors/sides.ts +94 -0
  696. package/src/connectors/sublayers.ts +203 -0
  697. package/src/coordinate.ts +10 -3
  698. package/src/copy.ts +71 -31
  699. package/src/css/blend.ts +27 -0
  700. package/src/css/index.ts +2 -0
  701. package/src/css/text.ts +84 -0
  702. package/src/cubic.ts +14 -0
  703. package/src/export-format.ts +30 -1
  704. package/src/fields/appearance.ts +35 -0
  705. package/src/fields/index.ts +4 -0
  706. package/src/fields/layout.ts +48 -0
  707. package/src/fields/text.ts +32 -1
  708. package/src/fig-compression.ts +9 -0
  709. package/src/figjam/index.ts +2 -0
  710. package/src/figjam/palette.ts +473 -0
  711. package/src/figjam/text.ts +83 -0
  712. package/src/font-style.ts +58 -14
  713. package/src/generated/index.ts +76 -0
  714. package/src/generated/kind.ts +24 -0
  715. package/src/generated/shape-with-text.ts +157 -0
  716. package/src/generated/sticky.ts +213 -0
  717. package/src/geometry.ts +102 -312
  718. package/src/gradient.ts +14 -0
  719. package/src/graph.ts +849 -0
  720. package/src/group-bounds.ts +59 -12
  721. package/src/guides.ts +6 -1
  722. package/src/hit-test.ts +118 -74
  723. package/src/icons/index.ts +3 -0
  724. package/src/icons/model.ts +9 -0
  725. package/src/icons/schema.ts +19 -3
  726. package/src/ids.ts +34 -0
  727. package/src/images.ts +71 -8
  728. package/src/index.ts +2 -976
  729. package/src/instances/assignments.ts +116 -0
  730. package/src/instances/content-size.ts +23 -2
  731. package/src/instances/copies.ts +7 -10
  732. package/src/instances/cycles.ts +1 -1
  733. package/src/instances/fields.ts +47 -92
  734. package/src/{instances.ts → instances/index.ts} +69 -44
  735. package/src/instances/kept-overrides.ts +280 -0
  736. package/src/instances/main-component.ts +55 -1
  737. package/src/{instance-overrides.ts → instances/overrides.ts} +58 -2
  738. package/src/instances/placement.ts +1 -1
  739. package/src/instances/source-walk.ts +3 -9
  740. package/src/instances/swap.ts +451 -0
  741. package/src/instances/sync.ts +166 -177
  742. package/src/instances/vector-geometry.ts +3 -3
  743. package/src/layout/aspect-ratio.ts +1 -1
  744. package/src/layout/sizing.ts +1 -1
  745. package/src/layout/writes.ts +59 -0
  746. package/src/matrix.ts +1 -1
  747. package/src/mutation-impact.ts +1 -1
  748. package/src/node-defaults.ts +43 -3
  749. package/src/outline/flatten.ts +190 -0
  750. package/src/outline/heads.ts +52 -0
  751. package/src/outline/hit.ts +369 -0
  752. package/src/outline/index.ts +4 -0
  753. package/src/outline/point.ts +59 -0
  754. package/src/outline/shapes.ts +207 -0
  755. package/src/paints/index.ts +1 -0
  756. package/src/paints/schema.ts +67 -0
  757. package/src/parse-path.ts +49 -4
  758. package/src/plugin-data/fields.ts +69 -77
  759. package/src/plugin-data/index.ts +2 -0
  760. package/src/polygon.ts +17 -0
  761. package/src/preview.ts +1 -1
  762. package/src/{primitives.ts → primitives/index.ts} +2 -0
  763. package/src/primitives/schema.ts +14 -0
  764. package/src/resize.ts +32 -6
  765. package/src/scaling/node.ts +10 -6
  766. package/src/scaling/tree.ts +2 -1
  767. package/src/shaders/index.ts +3 -0
  768. package/src/shaders/schema.ts +3 -3
  769. package/src/shape-with-text/fit.ts +154 -0
  770. package/src/shape-with-text/geometry.ts +496 -0
  771. package/src/shape-with-text/index.ts +10 -0
  772. package/src/shape-with-text/kinds.ts +86 -0
  773. package/src/shared-styles.ts +169 -17
  774. package/src/slots/authoring.ts +1 -1
  775. package/src/slots/content.ts +10 -5
  776. package/src/slots/frames.ts +12 -10
  777. package/src/slots/index.ts +4 -0
  778. package/src/slots/limits.ts +1 -1
  779. package/src/snap.ts +3 -1
  780. package/src/statuses/impact.ts +38 -0
  781. package/src/statuses/index.ts +4 -0
  782. package/src/statuses/node.ts +63 -0
  783. package/src/statuses/schema.ts +39 -0
  784. package/src/statuses/workflow.ts +121 -0
  785. package/src/text/index.ts +3 -0
  786. package/src/text/lengths.ts +44 -0
  787. package/src/text/overflow.ts +12 -0
  788. package/src/text/picture.ts +0 -4
  789. package/src/text/schema.ts +7 -0
  790. package/src/transfer/apply.ts +1 -1
  791. package/src/transfer/copied.ts +72 -0
  792. package/src/transfer/history.ts +1 -1
  793. package/src/transfer/index.ts +1 -0
  794. package/src/transfer/nodes.ts +18 -19
  795. package/src/transfer/plan.ts +1 -1
  796. package/src/transfer/remove.ts +1 -1
  797. package/src/transfer/validation.ts +1 -1
  798. package/src/transfer/variables.ts +7 -6
  799. package/src/types.ts +246 -13
  800. package/src/undo.ts +64 -2
  801. package/src/variables/bindings.ts +166 -66
  802. package/src/variables/corners.ts +39 -0
  803. package/src/variables/fields.ts +83 -0
  804. package/src/variables/formula/check.ts +99 -0
  805. package/src/variables/formula/evaluate.ts +33 -0
  806. package/src/variables/formula/index.ts +129 -0
  807. package/src/variables/formula/parse.ts +160 -0
  808. package/src/variables/formula/print.ts +167 -0
  809. package/src/variables/formula/schema.ts +77 -0
  810. package/src/variables/formula/signatures.ts +266 -0
  811. package/src/variables/formula/tokens.ts +114 -0
  812. package/src/variables/formula/tree.ts +53 -0
  813. package/src/{variables.ts → variables/index.ts} +86 -146
  814. package/src/variables/resolution.ts +293 -0
  815. package/src/variables/schema.ts +31 -0
  816. package/src/variables/text.ts +51 -0
  817. package/src/variables/token.ts +27 -1
  818. package/src/variables/value.ts +92 -0
  819. package/src/vector-network.ts +263 -22
  820. package/dist/chunks/asset-keys.js.map +0 -1
  821. package/dist/chunks/behaviours/kinds.js.map +0 -1
  822. package/dist/chunks/behaviours/layers.js +0 -611
  823. package/dist/chunks/behaviours/layers.js.map +0 -1
  824. package/dist/chunks/behaviours/spec.js.map +0 -1
  825. package/dist/chunks/bindings.js +0 -18
  826. package/dist/chunks/bindings.js.map +0 -1
  827. package/dist/chunks/buffered-events.js.map +0 -1
  828. package/dist/chunks/checkpoint.js +0 -78
  829. package/dist/chunks/checkpoint.js.map +0 -1
  830. package/dist/chunks/color/contrast.js.map +0 -1
  831. package/dist/chunks/color/index.js +0 -1662
  832. package/dist/chunks/color/index.js.map +0 -1
  833. package/dist/chunks/comments/document.js.map +0 -1
  834. package/dist/chunks/comments/list.js.map +0 -1
  835. package/dist/chunks/comments/merge.js.map +0 -1
  836. package/dist/chunks/components/exposure.js +0 -2291
  837. package/dist/chunks/components/exposure.js.map +0 -1
  838. package/dist/chunks/components/variants.js +0 -32
  839. package/dist/chunks/components/variants.js.map +0 -1
  840. package/dist/chunks/coordinate.js +0 -385
  841. package/dist/chunks/coordinate.js.map +0 -1
  842. package/dist/chunks/css/grid.js.map +0 -1
  843. package/dist/chunks/css/index.js +0 -160
  844. package/dist/chunks/css/index.js.map +0 -1
  845. package/dist/chunks/events.js.map +0 -1
  846. package/dist/chunks/fields/geometry.js.map +0 -1
  847. package/dist/chunks/font-style.js +0 -96
  848. package/dist/chunks/font-style.js.map +0 -1
  849. package/dist/chunks/group-bounds.js.map +0 -1
  850. package/dist/chunks/icons/glyph.js.map +0 -1
  851. package/dist/chunks/index.js +0 -2430
  852. package/dist/chunks/index.js.map +0 -1
  853. package/dist/color.d.ts +0 -78
  854. package/dist/color.d.ts.map +0 -1
  855. package/dist/color.js +0 -3
  856. package/dist/constants2.d.ts +0 -11
  857. package/dist/constants2.d.ts.map +0 -1
  858. package/dist/css.d.ts +0 -39
  859. package/dist/css.d.ts.map +0 -1
  860. package/dist/css.js +0 -3
  861. package/dist/images2.d.ts +0 -16
  862. package/dist/images2.d.ts.map +0 -1
  863. package/dist/instances.d.ts +0 -2
  864. package/dist/instances.js +0 -2
  865. package/dist/layout.d.ts +0 -2
  866. package/dist/matrix2.d.ts +0 -16
  867. package/dist/matrix2.d.ts.map +0 -1
  868. package/dist/primitives.d.ts +0 -2
  869. package/dist/primitives.js +0 -0
  870. package/dist/primitives2.d.ts.map +0 -1
  871. package/dist/text-direction.d.ts.map +0 -1
  872. package/dist/text-direction.js.map +0 -1
  873. package/dist/text-picture.d.ts.map +0 -1
  874. package/dist/text-picture.js +0 -2
  875. package/dist/text.d.ts +0 -2
  876. package/dist/text.js +0 -3
  877. package/dist/types2.d.ts +0 -2
  878. package/dist/undo2.d.ts +0 -73
  879. package/dist/undo2.d.ts.map +0 -1
  880. package/dist/variables.d.ts +0 -2
  881. package/dist/variables.js +0 -2
  882. /package/dist/{chunks/asset-keys.js → asset-keys.js} +0 -0
  883. /package/dist/{chunks/buffered-events.js → buffered-events.js} +0 -0
  884. /package/dist/{chunks/events.js → events.js} +0 -0
  885. /package/dist/{chunks/fields → fields}/geometry.js +0 -0
@@ -0,0 +1,83 @@
1
+ import { VariableModeFallback } from "./resolution.js";
2
+ import { EFFECT_BINDING_PROPERTIES, EffectBindingProperty, PaintBindingList, TEXT_CONTENT_VARIABLE_TYPES, VISIBILITY_VARIABLE_TYPES, effectBindableProperties, effectBindingField, effectBindingTarget, effectBindingVariableType, isNumericVariableBindingField, paintBindingTarget } from "./fields.js";
3
+ import { SceneGraph } from "../graph.js";
4
+ import { SceneNode, TextLength } from "../types.js";
5
+ //#region src/variables/bindings.d.ts
6
+ /** New declarations belong to the outermost occurrence, bounded by a component definition. */
7
+ declare function variableBindingOwner(graph: SceneGraph, node: SceneNode): SceneNode;
8
+ declare function assignVariableBindingUnits(graph: SceneGraph, node: SceneNode, field: string): void;
9
+ /** A bound number as the field stores it. */
10
+ declare function boundNumberValue(field: string, value: number): number | TextLength;
11
+ /**
12
+ * The values a node's numeric bindings resolve to in its mode, in scene units, for the fields
13
+ * whose stored value differs. A width or height an instance overrides keeps its own value.
14
+ */
15
+ declare function resolvedNumericBindings(graph: SceneGraph, node: SceneNode, fallback?: VariableModeFallback): Partial<SceneNode>;
16
+ /**
17
+ * The text and visibility a node's string and boolean bindings resolve to in its mode, for the
18
+ * fields whose stored value differs. Text or visibility an instance overrides, which typing in a
19
+ * layer or toggling its eye records, keeps its own value, as an overridden width or height does.
20
+ * A bound font family is left as stored: changing it needs the font loaded, which resolving a
21
+ * binding cannot do.
22
+ */
23
+ declare function resolvedValueBindings(graph: SceneGraph, node: SceneNode, fallback?: VariableModeFallback): Partial<SceneNode>;
24
+ /**
25
+ * The runs a text's character bindings resolve to in its mode, when a bound number differs from
26
+ * what its characters hold. Bound font families and styles are left as stored, as the text's own.
27
+ */
28
+ declare function resolvedRunBindings(graph: SceneGraph, node: SceneNode, fallback?: VariableModeFallback): Pick<Partial<SceneNode>, 'styleRuns'>;
29
+ /** The fills and strokes a node's color bindings resolve to in its mode, when it has any. */
30
+ declare function resolvedPaintBindings(graph: SceneGraph, node: SceneNode, fallback?: VariableModeFallback): Pick<Partial<SceneNode>, 'fills' | 'strokes'>;
31
+ /**
32
+ * The effects a node's effect bindings resolve to in its mode, when one differs from what the node
33
+ * holds. Lengths stay as the variables give them, negative ones included, as Figma keeps them;
34
+ * drawing treats a negative blur as none. In an instance they take its scale against its
35
+ * component, whenever they were bound, as Figma scales them; a layer scaled outside an instance
36
+ * goes back to the variable's own value.
37
+ */
38
+ declare function resolvedEffectBindings(graph: SceneGraph, node: SceneNode, fallback?: VariableModeFallback): Pick<Partial<SceneNode>, 'effects'>;
39
+ /**
40
+ * The layers a reconcile looks at: those bound to these variables, directly or through a variable
41
+ * aliasing them, or the layers in these subtrees. Without a scope, every layer.
42
+ */
43
+ type BindingScope = {
44
+ variables: Iterable<string>;
45
+ } | {
46
+ subtrees: Iterable<string>;
47
+ };
48
+ /** These variables and every variable that aliases one of them, at any depth and in any mode. */
49
+ declare function variablesResolvingThrough(graph: SceneGraph, ids: Iterable<string>): Set<string>;
50
+ /**
51
+ * The collections whose variables the layers in these subtrees resolve: those they bind, and
52
+ * those the bound variables alias, so a mode set on the subtrees can change what they show.
53
+ */
54
+ declare function collectionsBoundIn(graph: SceneGraph, roots: Iterable<string>): Set<string>;
55
+ /**
56
+ * The layers a change to these variables reaches: those binding one of them, or a variable that
57
+ * aliases one, on the layer itself or on its characters.
58
+ */
59
+ declare function layersUsingVariables(graph: SceneGraph, ids: Iterable<string>): SceneNode[];
60
+ /**
61
+ * Resolve live numeric, text, visibility, and effect bindings, numbers in scene units, without
62
+ * authoring instance overrides. A scope limits it to the layers a change can reach, so layers whose
63
+ * saved values differ from their bindings elsewhere in the document are left as saved. Returns the
64
+ * layers whose change needs a layout pass; effects are not a layout input, so an effect-only change
65
+ * is written but not returned.
66
+ */
67
+ declare function reconcileVariableBindings(graph: SceneGraph, scope?: BindingScope): string[];
68
+ /**
69
+ * As `reconcileVariableBindings`, with the layout fields each relaid layer received. Effects
70
+ * are written too, but draw without layout, so a layer whose only change is an effect is left out.
71
+ */
72
+ declare function reconcileVariableBindingUpdates(graph: SceneGraph, scope?: BindingScope): Map<string, Partial<SceneNode>>;
73
+ /** A layer list whose items carry their own bindings, keyed by position such as `fills/1/color`. */
74
+ type BoundLayerList = 'fills' | 'strokes' | 'effects';
75
+ /**
76
+ * `boundVariables` once the `list` items are rebuilt from `sources`, where `sources[i]` is the
77
+ * position the new item `i` had before, or null for an added item. A binding moves with its item
78
+ * and goes with a removed one, as Figma keeps a binding on its paint or effect.
79
+ */
80
+ declare function listBindingsAfterEdit(boundVariables: Readonly<Record<string, string>>, list: BoundLayerList, sources: readonly (number | null)[]): Record<string, string>;
81
+ //#endregion
82
+ export { BindingScope, BoundLayerList, EFFECT_BINDING_PROPERTIES, type EffectBindingProperty, type PaintBindingList, TEXT_CONTENT_VARIABLE_TYPES, VISIBILITY_VARIABLE_TYPES, assignVariableBindingUnits, boundNumberValue, collectionsBoundIn, effectBindableProperties, effectBindingField, effectBindingTarget, effectBindingVariableType, isNumericVariableBindingField, layersUsingVariables, listBindingsAfterEdit, paintBindingTarget, reconcileVariableBindingUpdates, reconcileVariableBindings, resolvedEffectBindings, resolvedNumericBindings, resolvedPaintBindings, resolvedRunBindings, resolvedValueBindings, variableBindingOwner, variablesResolvingThrough };
83
+ //# sourceMappingURL=bindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindings.d.ts","names":[],"sources":["../../src/variables/bindings.ts"],"mappings":";;;;;;iBAkCgB,qBAAqB,OAAO,YAAY,MAAM,YAAY;iBAW1D,2BACd,OAAO,YACP,MAAM,WACN;;iBAoBc,iBAAiB,eAAe,yBAAyB;;;;;iBAQzD,wBACd,OAAO,YACP,MAAM,WACN,WAAU,uBACT,QAAQ;;;;;;;;iBA2BK,sBACd,OAAO,YACP,MAAM,WACN,WAAU,uBACT,QAAQ;;;;;iBAsBK,oBACd,OAAO,YACP,MAAM,WACN,WAAU,uBACT,KAAK,QAAQ;;iBAsCA,sBACd,OAAO,YACP,MAAM,WACN,WAAU,uBACT,KAAK,QAAQ;;;;;;;;iBAgDA,uBACd,OAAO,YACP,MAAM,WACN,WAAU,uBACT,KAAK,QAAQ;;;;;KAyBJ;EAAiB,WAAW;;EAAuB,UAAU;;;iBAGzD,0BAA0B,OAAO,YAAY,KAAK,mBAAmB;;;;;iBAmCrE,mBAAmB,OAAO,YAAY,OAAO,mBAAmB;;;;;iBAoBhE,qBAAqB,OAAO,YAAY,KAAK,mBAAmB;;;;;;;;iBAoBhE,0BAA0B,OAAO,YAAY,QAAQ;;;;;iBAQrD,gCACd,OAAO,YACP,QAAQ,eACP,YAAY,QAAQ;;KAiBX;;;;;;iBAOI,sBACd,gBAAgB,SAAS,yBACzB,MAAM,gBACN,sCACC"}
@@ -0,0 +1,314 @@
1
+ import { EFFECT_BINDING_PROPERTIES, NUMERIC_FIELDS, TEXT_CONTENT_VARIABLE_TYPES, VISIBILITY_VARIABLE_TYPES, effectBindableProperties, effectBindingField, effectBindingTarget, effectBindingVariableType, isNumericVariableBindingField, paintBindingTarget } from "./fields.js";
2
+ import { hasInstanceOverride } from "../instances/overrides.js";
3
+ import { pixelLength } from "../text/lengths.js";
4
+ import { copyFills, copyStrokes } from "../copy.js";
5
+ import { variableText, variableTruthy } from "./text.js";
6
+ import { variableValueReferences } from "./value.js";
7
+ import { isEmptyObject, isEqual } from "es-toolkit/predicate";
8
+ //#region src/variables/bindings.ts
9
+ /** New declarations belong to the outermost occurrence, bounded by a component definition. */
10
+ function variableBindingOwner(graph, node) {
11
+ let owner = node;
12
+ let current = node;
13
+ while (current) {
14
+ if (current.type === "COMPONENT" || current.type === "COMPONENT_SET") break;
15
+ if (current.type === "INSTANCE") owner = current;
16
+ current = current.parentId ? graph.getNode(current.parentId) : void 0;
17
+ }
18
+ return owner;
19
+ }
20
+ function assignVariableBindingUnits(graph, node, field) {
21
+ if (!isNumericVariableBindingField(field)) return;
22
+ const owner = variableBindingOwner(graph, node);
23
+ node.variableBindingScales = {
24
+ ...node.variableBindingScales,
25
+ [field]: owner.variableAssignmentScales[field] ?? 1
26
+ };
27
+ }
28
+ /** Fields a bound number sets as a length in pixels, as Figma's do, whatever unit they held. */
29
+ const TEXT_LENGTH_FIELDS = /* @__PURE__ */ new Set(["lineHeight", "letterSpacing"]);
30
+ /** Whether the instance a layer sits in, or the instance itself, overrides one of its fields. */
31
+ function overriddenInInstance(graph, nodeId, field) {
32
+ const instance = graph.closest(nodeId, (node) => node.type === "INSTANCE");
33
+ return !!instance && hasInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field);
34
+ }
35
+ /** A bound number as the field stores it. */
36
+ function boundNumberValue(field, value) {
37
+ return TEXT_LENGTH_FIELDS.has(field) ? pixelLength(value) : value;
38
+ }
39
+ /**
40
+ * The values a node's numeric bindings resolve to in its mode, in scene units, for the fields
41
+ * whose stored value differs. A width or height an instance overrides keeps its own value.
42
+ */
43
+ function resolvedNumericBindings(graph, node, fallback = "active") {
44
+ const updates = {};
45
+ for (const [field, variableId] of Object.entries(node.boundVariables)) {
46
+ if (!NUMERIC_FIELDS.has(field)) continue;
47
+ if ((field === "width" || field === "height") && overriddenInInstance(graph, node.id, field)) continue;
48
+ const value = graph.resolveNumberVariableForNode(node.id, variableId, fallback);
49
+ if (value === void 0 || !Number.isFinite(value)) continue;
50
+ const effective = value * (node.variableBindingScales[field] ?? 1);
51
+ if (!Number.isFinite(effective)) continue;
52
+ const next = boundNumberValue(field, field === "opacity" ? Math.max(0, Math.min(1, effective)) : effective);
53
+ if (!isEqual(node[field], next)) Object.assign(updates, { [field]: next });
54
+ }
55
+ return updates;
56
+ }
57
+ /**
58
+ * The text and visibility a node's string and boolean bindings resolve to in its mode, for the
59
+ * fields whose stored value differs. Text or visibility an instance overrides, which typing in a
60
+ * layer or toggling its eye records, keeps its own value, as an overridden width or height does.
61
+ * A bound font family is left as stored: changing it needs the font loaded, which resolving a
62
+ * binding cannot do.
63
+ */
64
+ function resolvedValueBindings(graph, node, fallback = "active") {
65
+ const updates = {};
66
+ const resolve = (field) => {
67
+ const variableId = node.boundVariables[field];
68
+ if (!variableId || overriddenInInstance(graph, node.id, field)) return void 0;
69
+ return graph.resolveVariableForNode(node.id, variableId, fallback);
70
+ };
71
+ const text = node.type === "TEXT" ? variableText(resolve("text")) : void 0;
72
+ if (text !== void 0 && text !== node.text) updates.text = text;
73
+ const visible = variableTruthy(resolve("visible"));
74
+ if (visible !== void 0 && visible !== node.visible) updates.visible = visible;
75
+ return updates;
76
+ }
77
+ /** Fields of a range of characters a bound number gives its value; the rest need fonts loaded. */
78
+ const NUMERIC_RUN_FIELDS = [
79
+ "fontSize",
80
+ "fontWeight",
81
+ "letterSpacing",
82
+ "lineHeight"
83
+ ];
84
+ /**
85
+ * The runs a text's character bindings resolve to in its mode, when a bound number differs from
86
+ * what its characters hold. Bound font families and styles are left as stored, as the text's own.
87
+ */
88
+ function resolvedRunBindings(graph, node, fallback = "active") {
89
+ const styleRuns = node.styleRuns.map((run) => {
90
+ const bound = run.style.boundVariables;
91
+ if (!bound) return run;
92
+ let style = run.style;
93
+ for (const field of NUMERIC_RUN_FIELDS) {
94
+ const variableId = bound[field];
95
+ if (!variableId) continue;
96
+ const value = graph.resolveNumberVariableForNode(node.id, variableId, fallback);
97
+ if (value === void 0 || !Number.isFinite(value)) continue;
98
+ const next = boundNumberValue(field, value);
99
+ if (isEqual(style[field], next)) continue;
100
+ style = {
101
+ ...style,
102
+ [field]: next
103
+ };
104
+ }
105
+ return style === run.style ? run : {
106
+ ...run,
107
+ style
108
+ };
109
+ });
110
+ return styleRuns.some((run, index) => run !== node.styleRuns[index]) ? { styleRuns } : {};
111
+ }
112
+ /** The variables a node binds, its own and its characters'. */
113
+ function boundVariableIds(node) {
114
+ return [...Object.values(node.boundVariables), ...node.styleRuns.flatMap((run) => Object.values(run.style.boundVariables ?? {}))].filter((id) => typeof id === "string");
115
+ }
116
+ /**
117
+ * A bound paint takes its whole color from the variable, alpha included, the way Figma stores
118
+ * it: the variable's RGB at full alpha, and its alpha as the paint's opacity.
119
+ */
120
+ function applyBoundColor(paint, color) {
121
+ paint.color = {
122
+ ...color,
123
+ a: 1
124
+ };
125
+ paint.opacity = color.a;
126
+ }
127
+ /** The fills and strokes a node's color bindings resolve to in its mode, when it has any. */
128
+ function resolvedPaintBindings(graph, node, fallback = "active") {
129
+ const changes = {};
130
+ for (const field in node.boundVariables) {
131
+ if (!field.endsWith("/color")) continue;
132
+ const paint = paintBindingTarget(field);
133
+ if (!paint) continue;
134
+ const color = graph.resolveColorVariableForNode(node.id, node.boundVariables[field], fallback);
135
+ const { index } = paint;
136
+ if (!color) continue;
137
+ if (paint.list === "fills") {
138
+ if (!node.fills[index]) continue;
139
+ changes.fills ??= copyFills(node.fills);
140
+ applyBoundColor(changes.fills[index], color);
141
+ } else {
142
+ if (!node.strokes[index]) continue;
143
+ changes.strokes ??= copyStrokes(node.strokes);
144
+ applyBoundColor(changes.strokes[index], color);
145
+ }
146
+ }
147
+ return changes;
148
+ }
149
+ /** `effect` with one bound property set to its variable's value; a colour keeps its alpha. */
150
+ function withBoundEffectValue(effect, property, value) {
151
+ if (typeof value !== "number") return property === "color" ? {
152
+ ...effect,
153
+ color: value
154
+ } : effect;
155
+ if (property === "offsetX") return {
156
+ ...effect,
157
+ offset: {
158
+ ...effect.offset,
159
+ x: value
160
+ }
161
+ };
162
+ if (property === "offsetY") return {
163
+ ...effect,
164
+ offset: {
165
+ ...effect.offset,
166
+ y: value
167
+ }
168
+ };
169
+ if (property === "radius" || property === "spread") return {
170
+ ...effect,
171
+ [property]: value
172
+ };
173
+ return effect;
174
+ }
175
+ /** A bound effect length in an occurrence's coordinates, which are 1:1 outside instances. */
176
+ function scaledLength(length, node) {
177
+ return length === void 0 ? void 0 : length * node.componentScale;
178
+ }
179
+ /**
180
+ * The effects a node's effect bindings resolve to in its mode, when one differs from what the node
181
+ * holds. Lengths stay as the variables give them, negative ones included, as Figma keeps them;
182
+ * drawing treats a negative blur as none. In an instance they take its scale against its
183
+ * component, whenever they were bound, as Figma scales them; a layer scaled outside an instance
184
+ * goes back to the variable's own value.
185
+ */
186
+ function resolvedEffectBindings(graph, node, fallback = "active") {
187
+ let effects;
188
+ for (const [field, variableId] of Object.entries(node.boundVariables)) {
189
+ const target = effectBindingTarget(field);
190
+ if (!target) continue;
191
+ const effect = (effects ?? node.effects).at(target.index);
192
+ if (!effect || !effectBindableProperties(effect.type).includes(target.property)) continue;
193
+ const value = target.property === "color" ? graph.resolveColorVariableForNode(node.id, variableId, fallback) : scaledLength(graph.resolveNumberVariableForNode(node.id, variableId, fallback), node);
194
+ if (value == null || typeof value === "number" && !Number.isFinite(value)) continue;
195
+ const next = withBoundEffectValue(effect, target.property, value);
196
+ if (isEqual(next, effect)) continue;
197
+ effects ??= [...node.effects];
198
+ effects[target.index] = next;
199
+ }
200
+ return effects ? { effects } : {};
201
+ }
202
+ /** These variables and every variable that aliases one of them, at any depth and in any mode. */
203
+ function variablesResolvingThrough(graph, ids) {
204
+ const found = new Set(ids);
205
+ let grew = true;
206
+ while (grew) {
207
+ grew = false;
208
+ for (const variable of graph.variables.values()) {
209
+ if (found.has(variable.id)) continue;
210
+ if (Object.values(variable.valuesByMode).some((value) => variableValueReferences(value).some((id) => found.has(id)))) {
211
+ found.add(variable.id);
212
+ grew = true;
213
+ }
214
+ }
215
+ }
216
+ return found;
217
+ }
218
+ function subtreeNodes(graph, roots) {
219
+ const nodes = [];
220
+ const pending = [...roots];
221
+ for (let id = pending.pop(); id !== void 0; id = pending.pop()) {
222
+ const node = graph.getNode(id);
223
+ if (!node) continue;
224
+ nodes.push(node);
225
+ pending.push(...node.childIds);
226
+ }
227
+ return nodes;
228
+ }
229
+ /**
230
+ * The collections whose variables the layers in these subtrees resolve: those they bind, and
231
+ * those the bound variables alias, so a mode set on the subtrees can change what they show.
232
+ */
233
+ function collectionsBoundIn(graph, roots) {
234
+ const pending = subtreeNodes(graph, roots).flatMap(boundVariableIds);
235
+ const seen = /* @__PURE__ */ new Set();
236
+ const collections = /* @__PURE__ */ new Set();
237
+ for (let id = pending.pop(); id !== void 0; id = pending.pop()) {
238
+ if (seen.has(id)) continue;
239
+ seen.add(id);
240
+ const variable = graph.variables.get(id);
241
+ if (!variable) continue;
242
+ collections.add(variable.collectionId);
243
+ for (const value of Object.values(variable.valuesByMode)) pending.push(...variableValueReferences(value));
244
+ }
245
+ return collections;
246
+ }
247
+ /**
248
+ * The layers a change to these variables reaches: those binding one of them, or a variable that
249
+ * aliases one, on the layer itself or on its characters.
250
+ */
251
+ function layersUsingVariables(graph, ids) {
252
+ const variables = variablesResolvingThrough(graph, ids);
253
+ return [...graph.getAllNodes()].filter((node) => boundVariableIds(node).some((id) => variables.has(id)));
254
+ }
255
+ function scopedNodes(graph, scope) {
256
+ if (!scope) return graph.getAllNodes();
257
+ if ("subtrees" in scope) return subtreeNodes(graph, scope.subtrees);
258
+ return layersUsingVariables(graph, scope.variables);
259
+ }
260
+ /**
261
+ * Resolve live numeric, text, visibility, and effect bindings, numbers in scene units, without
262
+ * authoring instance overrides. A scope limits it to the layers a change can reach, so layers whose
263
+ * saved values differ from their bindings elsewhere in the document are left as saved. Returns the
264
+ * layers whose change needs a layout pass; effects are not a layout input, so an effect-only change
265
+ * is written but not returned.
266
+ */
267
+ function reconcileVariableBindings(graph, scope) {
268
+ return [...reconcileVariableBindingUpdates(graph, scope).keys()];
269
+ }
270
+ /**
271
+ * As `reconcileVariableBindings`, with the layout fields each relaid layer received. Effects
272
+ * are written too, but draw without layout, so a layer whose only change is an effect is left out.
273
+ */
274
+ function reconcileVariableBindingUpdates(graph, scope) {
275
+ const relaid = /* @__PURE__ */ new Map();
276
+ for (const node of scopedNodes(graph, scope)) {
277
+ const layoutUpdates = {
278
+ ...resolvedNumericBindings(graph, node),
279
+ ...resolvedValueBindings(graph, node),
280
+ ...resolvedRunBindings(graph, node)
281
+ };
282
+ const updates = {
283
+ ...layoutUpdates,
284
+ ...resolvedEffectBindings(graph, node)
285
+ };
286
+ if (isEmptyObject(updates)) continue;
287
+ graph.updateNode(node.id, updates);
288
+ if (!isEmptyObject(layoutUpdates)) relaid.set(node.id, layoutUpdates);
289
+ }
290
+ return relaid;
291
+ }
292
+ /**
293
+ * `boundVariables` once the `list` items are rebuilt from `sources`, where `sources[i]` is the
294
+ * position the new item `i` had before, or null for an added item. A binding moves with its item
295
+ * and goes with a removed one, as Figma keeps a binding on its paint or effect.
296
+ */
297
+ function listBindingsAfterEdit(boundVariables, list, sources) {
298
+ const prefix = `${list}/`;
299
+ const moved = {};
300
+ for (const [field, variableId] of Object.entries(boundVariables)) {
301
+ if (!field.startsWith(prefix)) {
302
+ moved[field] = variableId;
303
+ continue;
304
+ }
305
+ const [index, ...property] = field.slice(prefix.length).split("/");
306
+ const next = sources.indexOf(Number(index));
307
+ if (next !== -1 && property.length > 0) moved[`${prefix}${next}/${property.join("/")}`] = variableId;
308
+ }
309
+ return moved;
310
+ }
311
+ //#endregion
312
+ export { EFFECT_BINDING_PROPERTIES, TEXT_CONTENT_VARIABLE_TYPES, VISIBILITY_VARIABLE_TYPES, assignVariableBindingUnits, boundNumberValue, collectionsBoundIn, effectBindableProperties, effectBindingField, effectBindingTarget, effectBindingVariableType, isNumericVariableBindingField, layersUsingVariables, listBindingsAfterEdit, paintBindingTarget, reconcileVariableBindingUpdates, reconcileVariableBindings, resolvedEffectBindings, resolvedNumericBindings, resolvedPaintBindings, resolvedRunBindings, resolvedValueBindings, variableBindingOwner, variablesResolvingThrough };
313
+
314
+ //# sourceMappingURL=bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindings.js","names":[],"sources":["../../src/variables/bindings.ts"],"sourcesContent":["import { isEmptyObject, isEqual } from 'es-toolkit/predicate'\n\nimport type { VariableModeFallback } from '.'\nimport { copyFills, copyStrokes } from '../copy'\nimport type { SceneGraph } from '../graph'\nimport { hasInstanceOverride } from '../instances/overrides'\nimport type { Color } from '../primitives'\nimport { pixelLength } from '../text/lengths'\nimport type { Effect, Fill, SceneNode, Stroke, StyleRun, TextLength } from '../types'\nimport {\n effectBindableProperties,\n effectBindingTarget,\n NUMERIC_FIELDS,\n isNumericVariableBindingField,\n paintBindingTarget,\n type EffectBindingProperty\n} from './fields'\nimport { variableText, variableTruthy } from './text'\nimport { variableValueReferences } from './value'\nexport {\n EFFECT_BINDING_PROPERTIES,\n effectBindableProperties,\n effectBindingField,\n effectBindingTarget,\n effectBindingVariableType,\n isNumericVariableBindingField,\n paintBindingTarget,\n type EffectBindingProperty,\n TEXT_CONTENT_VARIABLE_TYPES,\n VISIBILITY_VARIABLE_TYPES,\n type PaintBindingList\n} from './fields'\n\n/** New declarations belong to the outermost occurrence, bounded by a component definition. */\nexport function variableBindingOwner(graph: SceneGraph, node: SceneNode): SceneNode {\n let owner = node\n let current: SceneNode | undefined = node\n while (current) {\n if (current.type === 'COMPONENT' || current.type === 'COMPONENT_SET') break\n if (current.type === 'INSTANCE') owner = current\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n return owner\n}\n\nexport function assignVariableBindingUnits(\n graph: SceneGraph,\n node: SceneNode,\n field: string\n): void {\n if (!isNumericVariableBindingField(field)) return\n const owner = variableBindingOwner(graph, node)\n node.variableBindingScales = {\n ...node.variableBindingScales,\n [field]: owner.variableAssignmentScales[field] ?? 1\n }\n}\n\n/** Fields a bound number sets as a length in pixels, as Figma's do, whatever unit they held. */\nconst TEXT_LENGTH_FIELDS: ReadonlySet<string> = new Set(['lineHeight', 'letterSpacing'])\n\n/** Whether the instance a layer sits in, or the instance itself, overrides one of its fields. */\nfunction overriddenInInstance(graph: SceneGraph, nodeId: string, field: string): boolean {\n const instance = graph.closest(nodeId, (node) => node.type === 'INSTANCE')\n return !!instance && hasInstanceOverride(instance.instanceOverrides, instance.id, nodeId, field)\n}\n\n/** A bound number as the field stores it. */\nexport function boundNumberValue(field: string, value: number): number | TextLength {\n return TEXT_LENGTH_FIELDS.has(field) ? pixelLength(value) : value\n}\n\n/**\n * The values a node's numeric bindings resolve to in its mode, in scene units, for the fields\n * whose stored value differs. A width or height an instance overrides keeps its own value.\n */\nexport function resolvedNumericBindings(\n graph: SceneGraph,\n node: SceneNode,\n fallback: VariableModeFallback = 'active'\n): Partial<SceneNode> {\n const updates: Partial<SceneNode> = {}\n for (const [field, variableId] of Object.entries(node.boundVariables)) {\n if (!NUMERIC_FIELDS.has(field)) continue\n if ((field === 'width' || field === 'height') && overriddenInInstance(graph, node.id, field))\n continue\n const value = graph.resolveNumberVariableForNode(node.id, variableId, fallback)\n if (value === undefined || !Number.isFinite(value)) continue\n const scale = node.variableBindingScales[field] ?? 1\n const effective = value * scale\n if (!Number.isFinite(effective)) continue\n const next = boundNumberValue(\n field,\n field === 'opacity' ? Math.max(0, Math.min(1, effective)) : effective\n )\n if (!isEqual(node[field as keyof SceneNode], next)) Object.assign(updates, { [field]: next })\n }\n return updates\n}\n\n/**\n * The text and visibility a node's string and boolean bindings resolve to in its mode, for the\n * fields whose stored value differs. Text or visibility an instance overrides, which typing in a\n * layer or toggling its eye records, keeps its own value, as an overridden width or height does.\n * A bound font family is left as stored: changing it needs the font loaded, which resolving a\n * binding cannot do.\n */\nexport function resolvedValueBindings(\n graph: SceneGraph,\n node: SceneNode,\n fallback: VariableModeFallback = 'active'\n): Partial<SceneNode> {\n const updates: Partial<SceneNode> = {}\n const resolve = (field: 'text' | 'visible') => {\n const variableId = node.boundVariables[field]\n if (!variableId || overriddenInInstance(graph, node.id, field)) return undefined\n return graph.resolveVariableForNode(node.id, variableId, fallback)\n }\n const text = node.type === 'TEXT' ? variableText(resolve('text')) : undefined\n if (text !== undefined && text !== node.text) updates.text = text\n // Figma binds visibility to text too, and shows the layer when the text reads as true.\n const visible = variableTruthy(resolve('visible'))\n if (visible !== undefined && visible !== node.visible) updates.visible = visible\n return updates\n}\n\n/** Fields of a range of characters a bound number gives its value; the rest need fonts loaded. */\nconst NUMERIC_RUN_FIELDS = ['fontSize', 'fontWeight', 'letterSpacing', 'lineHeight'] as const\n\n/**\n * The runs a text's character bindings resolve to in its mode, when a bound number differs from\n * what its characters hold. Bound font families and styles are left as stored, as the text's own.\n */\nexport function resolvedRunBindings(\n graph: SceneGraph,\n node: SceneNode,\n fallback: VariableModeFallback = 'active'\n): Pick<Partial<SceneNode>, 'styleRuns'> {\n const styleRuns = node.styleRuns.map((run): StyleRun => {\n const bound = run.style.boundVariables\n if (!bound) return run\n let style = run.style\n for (const field of NUMERIC_RUN_FIELDS) {\n const variableId = bound[field]\n if (!variableId) continue\n const value = graph.resolveNumberVariableForNode(node.id, variableId, fallback)\n if (value === undefined || !Number.isFinite(value)) continue\n const next = boundNumberValue(field, value)\n if (isEqual(style[field], next)) continue\n style = { ...style, [field]: next }\n }\n return style === run.style ? run : { ...run, style }\n })\n const changed = styleRuns.some((run, index) => run !== node.styleRuns[index])\n return changed ? { styleRuns } : {}\n}\n\n/** The variables a node binds, its own and its characters'. */\nfunction boundVariableIds(node: SceneNode): string[] {\n return [\n ...Object.values(node.boundVariables),\n ...node.styleRuns.flatMap((run) => Object.values(run.style.boundVariables ?? {}))\n ].filter((id): id is string => typeof id === 'string')\n}\n\n/**\n * A bound paint takes its whole color from the variable, alpha included, the way Figma stores\n * it: the variable's RGB at full alpha, and its alpha as the paint's opacity.\n */\nfunction applyBoundColor(paint: Fill | Stroke, color: Color): void {\n paint.color = { ...color, a: 1 }\n paint.opacity = color.a\n}\n\n/** The fills and strokes a node's color bindings resolve to in its mode, when it has any. */\nexport function resolvedPaintBindings(\n graph: SceneGraph,\n node: SceneNode,\n fallback: VariableModeFallback = 'active'\n): Pick<Partial<SceneNode>, 'fills' | 'strokes'> {\n // Most nodes bind nothing, so no copy is made until a paint binding is actually found.\n const changes: Pick<Partial<SceneNode>, 'fills' | 'strokes'> = {}\n for (const field in node.boundVariables) {\n if (!field.endsWith('/color')) continue\n const paint = paintBindingTarget(field)\n if (!paint) continue\n const color = graph.resolveColorVariableForNode(node.id, node.boundVariables[field], fallback)\n const { index } = paint\n if (!color) continue\n if (paint.list === 'fills') {\n if (!node.fills[index]) continue\n changes.fills ??= copyFills(node.fills)\n applyBoundColor(changes.fills[index], color)\n } else {\n if (!node.strokes[index]) continue\n changes.strokes ??= copyStrokes(node.strokes)\n applyBoundColor(changes.strokes[index], color)\n }\n }\n return changes\n}\n\n/** `effect` with one bound property set to its variable's value; a colour keeps its alpha. */\nfunction withBoundEffectValue(\n effect: Effect,\n property: EffectBindingProperty,\n value: number | Color\n): Effect {\n if (typeof value !== 'number') return property === 'color' ? { ...effect, color: value } : effect\n if (property === 'offsetX') return { ...effect, offset: { ...effect.offset, x: value } }\n if (property === 'offsetY') return { ...effect, offset: { ...effect.offset, y: value } }\n if (property === 'radius' || property === 'spread') return { ...effect, [property]: value }\n return effect\n}\n\n/** A bound effect length in an occurrence's coordinates, which are 1:1 outside instances. */\nfunction scaledLength(length: number | undefined, node: SceneNode): number | undefined {\n return length === undefined ? undefined : length * node.componentScale\n}\n\n/**\n * The effects a node's effect bindings resolve to in its mode, when one differs from what the node\n * holds. Lengths stay as the variables give them, negative ones included, as Figma keeps them;\n * drawing treats a negative blur as none. In an instance they take its scale against its\n * component, whenever they were bound, as Figma scales them; a layer scaled outside an instance\n * goes back to the variable's own value.\n */\nexport function resolvedEffectBindings(\n graph: SceneGraph,\n node: SceneNode,\n fallback: VariableModeFallback = 'active'\n): Pick<Partial<SceneNode>, 'effects'> {\n // Most nodes bind nothing, so no copy is made until a value actually changes.\n let effects: Effect[] | undefined\n for (const [field, variableId] of Object.entries(node.boundVariables)) {\n const target = effectBindingTarget(field)\n if (!target) continue\n const effect = (effects ?? node.effects).at(target.index)\n if (!effect || !effectBindableProperties(effect.type).includes(target.property)) continue\n const value =\n target.property === 'color'\n ? graph.resolveColorVariableForNode(node.id, variableId, fallback)\n : scaledLength(graph.resolveNumberVariableForNode(node.id, variableId, fallback), node)\n if (value == null || (typeof value === 'number' && !Number.isFinite(value))) continue\n const next = withBoundEffectValue(effect, target.property, value)\n if (isEqual(next, effect)) continue\n effects ??= [...node.effects]\n effects[target.index] = next\n }\n return effects ? { effects } : {}\n}\n\n/**\n * The layers a reconcile looks at: those bound to these variables, directly or through a variable\n * aliasing them, or the layers in these subtrees. Without a scope, every layer.\n */\nexport type BindingScope = { variables: Iterable<string> } | { subtrees: Iterable<string> }\n\n/** These variables and every variable that aliases one of them, at any depth and in any mode. */\nexport function variablesResolvingThrough(graph: SceneGraph, ids: Iterable<string>): Set<string> {\n const found = new Set(ids)\n let grew = true\n while (grew) {\n grew = false\n for (const variable of graph.variables.values()) {\n if (found.has(variable.id)) continue\n const aliases = Object.values(variable.valuesByMode).some((value) =>\n variableValueReferences(value).some((id) => found.has(id))\n )\n if (aliases) {\n found.add(variable.id)\n grew = true\n }\n }\n }\n return found\n}\n\nfunction subtreeNodes(graph: SceneGraph, roots: Iterable<string>): SceneNode[] {\n const nodes: SceneNode[] = []\n const pending = [...roots]\n for (let id = pending.pop(); id !== undefined; id = pending.pop()) {\n const node = graph.getNode(id)\n if (!node) continue\n nodes.push(node)\n pending.push(...node.childIds)\n }\n return nodes\n}\n\n/**\n * The collections whose variables the layers in these subtrees resolve: those they bind, and\n * those the bound variables alias, so a mode set on the subtrees can change what they show.\n */\nexport function collectionsBoundIn(graph: SceneGraph, roots: Iterable<string>): Set<string> {\n const pending = subtreeNodes(graph, roots).flatMap(boundVariableIds)\n const seen = new Set<string>()\n const collections = new Set<string>()\n for (let id = pending.pop(); id !== undefined; id = pending.pop()) {\n if (seen.has(id)) continue\n seen.add(id)\n const variable = graph.variables.get(id)\n if (!variable) continue\n collections.add(variable.collectionId)\n for (const value of Object.values(variable.valuesByMode))\n pending.push(...variableValueReferences(value))\n }\n return collections\n}\n\n/**\n * The layers a change to these variables reaches: those binding one of them, or a variable that\n * aliases one, on the layer itself or on its characters.\n */\nexport function layersUsingVariables(graph: SceneGraph, ids: Iterable<string>): SceneNode[] {\n const variables = variablesResolvingThrough(graph, ids)\n return [...graph.getAllNodes()].filter((node) =>\n boundVariableIds(node).some((id) => variables.has(id))\n )\n}\n\nfunction scopedNodes(graph: SceneGraph, scope: BindingScope | undefined): Iterable<SceneNode> {\n if (!scope) return graph.getAllNodes()\n if ('subtrees' in scope) return subtreeNodes(graph, scope.subtrees)\n return layersUsingVariables(graph, scope.variables)\n}\n\n/**\n * Resolve live numeric, text, visibility, and effect bindings, numbers in scene units, without\n * authoring instance overrides. A scope limits it to the layers a change can reach, so layers whose\n * saved values differ from their bindings elsewhere in the document are left as saved. Returns the\n * layers whose change needs a layout pass; effects are not a layout input, so an effect-only change\n * is written but not returned.\n */\nexport function reconcileVariableBindings(graph: SceneGraph, scope?: BindingScope): string[] {\n return [...reconcileVariableBindingUpdates(graph, scope).keys()]\n}\n\n/**\n * As `reconcileVariableBindings`, with the layout fields each relaid layer received. Effects\n * are written too, but draw without layout, so a layer whose only change is an effect is left out.\n */\nexport function reconcileVariableBindingUpdates(\n graph: SceneGraph,\n scope?: BindingScope\n): Map<string, Partial<SceneNode>> {\n const relaid = new Map<string, Partial<SceneNode>>()\n for (const node of scopedNodes(graph, scope)) {\n const layoutUpdates = {\n ...resolvedNumericBindings(graph, node),\n ...resolvedValueBindings(graph, node),\n ...resolvedRunBindings(graph, node)\n }\n const updates = { ...layoutUpdates, ...resolvedEffectBindings(graph, node) }\n if (isEmptyObject(updates)) continue\n graph.updateNode(node.id, updates)\n if (!isEmptyObject(layoutUpdates)) relaid.set(node.id, layoutUpdates)\n }\n return relaid\n}\n\n/** A layer list whose items carry their own bindings, keyed by position such as `fills/1/color`. */\nexport type BoundLayerList = 'fills' | 'strokes' | 'effects'\n\n/**\n * `boundVariables` once the `list` items are rebuilt from `sources`, where `sources[i]` is the\n * position the new item `i` had before, or null for an added item. A binding moves with its item\n * and goes with a removed one, as Figma keeps a binding on its paint or effect.\n */\nexport function listBindingsAfterEdit(\n boundVariables: Readonly<Record<string, string>>,\n list: BoundLayerList,\n sources: readonly (number | null)[]\n): Record<string, string> {\n const prefix = `${list}/`\n const moved: Record<string, string> = {}\n for (const [field, variableId] of Object.entries(boundVariables)) {\n if (!field.startsWith(prefix)) {\n moved[field] = variableId\n continue\n }\n const [index, ...property] = field.slice(prefix.length).split('/')\n const next = sources.indexOf(Number(index))\n if (next !== -1 && property.length > 0)\n moved[`${prefix}${next}/${property.join('/')}`] = variableId\n }\n return moved\n}\n"],"mappings":";;;;;;;;;AAkCA,SAAgB,qBAAqB,OAAmB,MAA4B;CAClF,IAAI,QAAQ;CACZ,IAAI,UAAiC;CACrC,OAAO,SAAS;EACd,IAAI,QAAQ,SAAS,eAAe,QAAQ,SAAS,iBAAiB;EACtE,IAAI,QAAQ,SAAS,YAAY,QAAQ;EACzC,UAAU,QAAQ,WAAW,MAAM,QAAQ,QAAQ,QAAQ,IAAI,KAAA;CACjE;CACA,OAAO;AACT;AAEA,SAAgB,2BACd,OACA,MACA,OACM;CACN,IAAI,CAAC,8BAA8B,KAAK,GAAG;CAC3C,MAAM,QAAQ,qBAAqB,OAAO,IAAI;CAC9C,KAAK,wBAAwB;EAC3B,GAAG,KAAK;GACP,QAAQ,MAAM,yBAAyB,UAAU;CACpD;AACF;;AAGA,MAAM,qCAA0C,IAAI,IAAI,CAAC,cAAc,eAAe,CAAC;;AAGvF,SAAS,qBAAqB,OAAmB,QAAgB,OAAwB;CACvF,MAAM,WAAW,MAAM,QAAQ,SAAS,SAAS,KAAK,SAAS,UAAU;CACzE,OAAO,CAAC,CAAC,YAAY,oBAAoB,SAAS,mBAAmB,SAAS,IAAI,QAAQ,KAAK;AACjG;;AAGA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AO,KAAK,GAAG;EAC5C,MAAM,gBAAgB;GACpB,GAAG,wBAAwB,OAAO,IAAI;GACtC,GAAG,sBAAsB,OAAO,IAAI;GACpC,GAAG,oBAAoB,OAAO,IAAI;EACpC;EACA,MAAM,UAAU;GAAE,GAAG;GAAe,GAAG,uBAAuB,OAAO,IAAI;EAAE;EAC3E,IAAI,cAAc,OAAO,GAAG;EAC5B,MAAM,WAAW,KAAK,IAAI,OAAO;EACjC,IAAI,CAAC,cAAc,aAAa,GAAG,OAAO,IAAI,KAAK,IAAI,aAAa;CACtE;CACA,OAAO;AACT;;;;;;AAUA,SAAgB,sBACd,gBACA,MACA,SACwB;CACxB,MAAM,SAAS,GAAG,KAAK;CACvB,MAAM,QAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,OAAO,eAAe,OAAO,QAAQ,cAAc,GAAG;EAChE,IAAI,CAAC,MAAM,WAAW,MAAM,GAAG;GAC7B,MAAM,SAAS;GACf;EACF;EACA,MAAM,CAAC,OAAO,GAAG,YAAY,MAAM,MAAM,OAAO,MAAM,CAAC,CAAC,MAAM,GAAG;EACjE,MAAM,OAAO,QAAQ,QAAQ,OAAO,KAAK,CAAC;EAC1C,IAAI,SAAS,MAAM,SAAS,SAAS,GACnC,MAAM,GAAG,SAAS,KAAK,GAAG,SAAS,KAAK,GAAG,OAAO;CACtD;CACA,OAAO;AACT"}
@@ -0,0 +1,12 @@
1
+ import { SceneNode } from "../types.js";
2
+ //#region src/variables/corners.d.ts
3
+ /**
4
+ * The changes that draw a layer's radius corner by corner, as Figma keeps it once corners can
5
+ * differ: each corner not bound on its own takes the radius the layer shows, and a binding of the
6
+ * whole radius, which a .fig or .pen file holds as one field, moves to those corners, so each
7
+ * corner can then change or be unbound alone.
8
+ */
9
+ declare function independentCornerChanges(node: SceneNode): Partial<SceneNode>;
10
+ //#endregion
11
+ export { independentCornerChanges };
12
+ //# sourceMappingURL=corners.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"corners.d.ts","names":[],"sources":["../../src/variables/corners.ts"],"mappings":";;;;;;;;iBAiBgB,yBAAyB,MAAM,YAAY,QAAQ"}
@@ -0,0 +1,38 @@
1
+ import { omit } from "es-toolkit/object";
2
+ //#region src/variables/corners.ts
3
+ const CORNERS = [
4
+ "topLeftRadius",
5
+ "topRightRadius",
6
+ "bottomLeftRadius",
7
+ "bottomRightRadius"
8
+ ];
9
+ /**
10
+ * The changes that draw a layer's radius corner by corner, as Figma keeps it once corners can
11
+ * differ: each corner not bound on its own takes the radius the layer shows, and a binding of the
12
+ * whole radius, which a .fig or .pen file holds as one field, moves to those corners, so each
13
+ * corner can then change or be unbound alone.
14
+ */
15
+ function independentCornerChanges(node) {
16
+ const changes = {};
17
+ if (!node.independentCorners) {
18
+ changes.independentCorners = true;
19
+ for (const corner of CORNERS) if (!node.boundVariables[corner]) changes[corner] = node.cornerRadius;
20
+ }
21
+ const variableId = node.boundVariables.cornerRadius;
22
+ if (!variableId) return changes;
23
+ const unbound = CORNERS.filter((corner) => !node.boundVariables[corner]);
24
+ const scale = node.variableBindingScales.cornerRadius;
25
+ changes.boundVariables = {
26
+ ...omit(node.boundVariables, ["cornerRadius"]),
27
+ ...Object.fromEntries(unbound.map((corner) => [corner, variableId]))
28
+ };
29
+ changes.variableBindingScales = {
30
+ ...omit(node.variableBindingScales, ["cornerRadius"]),
31
+ ...scale === void 0 ? {} : Object.fromEntries(unbound.map((corner) => [corner, scale]))
32
+ };
33
+ return changes;
34
+ }
35
+ //#endregion
36
+ export { independentCornerChanges };
37
+
38
+ //# sourceMappingURL=corners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"corners.js","names":[],"sources":["../../src/variables/corners.ts"],"sourcesContent":["import { omit } from 'es-toolkit/object'\n\nimport type { SceneNode } from '../types'\n\nconst CORNERS = [\n 'topLeftRadius',\n 'topRightRadius',\n 'bottomLeftRadius',\n 'bottomRightRadius'\n] as const\n\n/**\n * The changes that draw a layer's radius corner by corner, as Figma keeps it once corners can\n * differ: each corner not bound on its own takes the radius the layer shows, and a binding of the\n * whole radius, which a .fig or .pen file holds as one field, moves to those corners, so each\n * corner can then change or be unbound alone.\n */\nexport function independentCornerChanges(node: SceneNode): Partial<SceneNode> {\n const changes: Partial<SceneNode> = {}\n if (!node.independentCorners) {\n changes.independentCorners = true\n // A corner bound on its own keeps the value its variable gave it.\n for (const corner of CORNERS)\n if (!node.boundVariables[corner]) changes[corner] = node.cornerRadius\n }\n const variableId = node.boundVariables.cornerRadius\n if (!variableId) return changes\n const unbound = CORNERS.filter((corner) => !node.boundVariables[corner])\n const scale = node.variableBindingScales.cornerRadius\n changes.boundVariables = {\n ...omit(node.boundVariables, ['cornerRadius']),\n ...Object.fromEntries(unbound.map((corner) => [corner, variableId]))\n }\n changes.variableBindingScales = {\n ...omit(node.variableBindingScales, ['cornerRadius']),\n ...(scale === undefined ? {} : Object.fromEntries(unbound.map((corner) => [corner, scale])))\n }\n return changes\n}\n"],"mappings":";;AAIA,MAAM,UAAU;CACd;CACA;CACA;CACA;AACF;;;;;;;AAQA,SAAgB,yBAAyB,MAAqC;CAC5E,MAAM,UAA8B,CAAC;CACrC,IAAI,CAAC,KAAK,oBAAoB;EAC5B,QAAQ,qBAAqB;EAE7B,KAAK,MAAM,UAAU,SACnB,IAAI,CAAC,KAAK,eAAe,SAAS,QAAQ,UAAU,KAAK;CAC7D;CACA,MAAM,aAAa,KAAK,eAAe;CACvC,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,UAAU,QAAQ,QAAQ,WAAW,CAAC,KAAK,eAAe,OAAO;CACvE,MAAM,QAAQ,KAAK,sBAAsB;CACzC,QAAQ,iBAAiB;EACvB,GAAG,KAAK,KAAK,gBAAgB,CAAC,cAAc,CAAC;EAC7C,GAAG,OAAO,YAAY,QAAQ,KAAK,WAAW,CAAC,QAAQ,UAAU,CAAC,CAAC;CACrE;CACA,QAAQ,wBAAwB;EAC9B,GAAG,KAAK,KAAK,uBAAuB,CAAC,cAAc,CAAC;EACpD,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,OAAO,YAAY,QAAQ,KAAK,WAAW,CAAC,QAAQ,KAAK,CAAC,CAAC;CAC5F;CACA,OAAO;AACT"}
@@ -0,0 +1,43 @@
1
+ import { Effect } from "../types.js";
2
+ //#region src/variables/fields.d.ts
3
+ declare function isNumericVariableBindingField(field: string): boolean;
4
+ /**
5
+ * The variable types text content binds to: text, or a number shown as text, as Figma's layer
6
+ * panel offers. Figma's plugin API takes text alone; font family stays text-only.
7
+ */
8
+ declare const TEXT_CONTENT_VARIABLE_TYPES: readonly ["STRING", "FLOAT"];
9
+ /**
10
+ * The variable types visibility binds to: a boolean, or text that shows the layer unless it reads
11
+ * as false, as Figma's layer panel offers. Figma's plugin API takes booleans alone.
12
+ */
13
+ declare const VISIBILITY_VARIABLE_TYPES: readonly ["BOOLEAN", "STRING"];
14
+ /** The paint lists whose colours bind to variables, one binding field per paint. */
15
+ type PaintBindingList = 'fills' | 'strokes';
16
+ /**
17
+ * The paint a binding field names the colour of, such as the second fill for `fills/1/color`, or
18
+ * null for a field that binds anything else.
19
+ */
20
+ declare function paintBindingTarget(field: string): {
21
+ list: PaintBindingList;
22
+ index: number;
23
+ } | null;
24
+ /** The effect fields that bind to variables, in the order Figma's messages list them. */
25
+ declare const EFFECT_BINDING_PROPERTIES: readonly ["color", "radius", "spread", "offsetX", "offsetY"];
26
+ type EffectBindingProperty = (typeof EFFECT_BINDING_PROPERTIES)[number];
27
+ /** The node binding field for one property of the effect at `index`, such as `effects/0/radius`. */
28
+ declare function effectBindingField(index: number, property: EffectBindingProperty): string;
29
+ /**
30
+ * The effect and property a binding field names, such as the second effect's blur for
31
+ * `effects/1/radius`, or null for a field that binds anything else.
32
+ */
33
+ declare function effectBindingTarget(field: string): {
34
+ index: number;
35
+ property: EffectBindingProperty;
36
+ } | null;
37
+ /** The properties of an effect that bind: every shadow property, and only a blur's radius. */
38
+ declare function effectBindableProperties(type: Effect['type']): readonly EffectBindingProperty[];
39
+ /** The variable type an effect property binds to: colour to COLOR, lengths to FLOAT. */
40
+ declare function effectBindingVariableType(property: EffectBindingProperty): 'COLOR' | 'FLOAT';
41
+ //#endregion
42
+ export { EFFECT_BINDING_PROPERTIES, EffectBindingProperty, PaintBindingList, TEXT_CONTENT_VARIABLE_TYPES, VISIBILITY_VARIABLE_TYPES, effectBindableProperties, effectBindingField, effectBindingTarget, effectBindingVariableType, isNumericVariableBindingField, paintBindingTarget };
43
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","names":[],"sources":["../../src/variables/fields.ts"],"mappings":";;iBAoCgB,8BAA8B;;;;;cAWjC;;;;;cAYA;;KAMD;;;;;iBAQI,mBACd;EACG,MAAM;EAAkB;;;cAQhB;KAQD,gCAAgC;;iBAO5B,mBAAmB,eAAe,UAAU;;;;;iBAQ5C,oBACd;EACG;EAAe,UAAU;;;iBAQd,yBAAyB,MAAM,0BAA0B;;iBAOzD,0BAA0B,UAAU"}