@pairdraw/scene-graph 0.19.2 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/dist/color/index.d.ts +28 -7
  2. package/dist/color/index.d.ts.map +1 -1
  3. package/dist/color/index.js +40 -15
  4. package/dist/color/index.js.map +1 -1
  5. package/dist/color/management.d.ts +19 -6
  6. package/dist/color/management.d.ts.map +1 -1
  7. package/dist/color/management.js +56 -1
  8. package/dist/color/management.js.map +1 -1
  9. package/dist/color/profile.d.ts +32 -0
  10. package/dist/color/profile.d.ts.map +1 -0
  11. package/dist/color/profile.js +140 -0
  12. package/dist/color/profile.js.map +1 -0
  13. package/dist/comments/index.d.ts +2 -2
  14. package/dist/comments/index.js +2 -2
  15. package/dist/comments/merge.d.ts.map +1 -1
  16. package/dist/comments/merge.js +1 -0
  17. package/dist/comments/merge.js.map +1 -1
  18. package/dist/comments/schema.d.ts +3 -1
  19. package/dist/comments/schema.d.ts.map +1 -1
  20. package/dist/comments/schema.js +19 -2
  21. package/dist/comments/schema.js.map +1 -1
  22. package/dist/comments/threads.d.ts +3 -1
  23. package/dist/comments/threads.d.ts.map +1 -1
  24. package/dist/comments/threads.js +2 -1
  25. package/dist/comments/threads.js.map +1 -1
  26. package/dist/components/index.d.ts +2 -2
  27. package/dist/components/index.js +2 -2
  28. package/dist/components/properties.d.ts.map +1 -1
  29. package/dist/components/properties.js +7 -7
  30. package/dist/components/properties.js.map +1 -1
  31. package/dist/components/variants.d.ts +12 -1
  32. package/dist/components/variants.d.ts.map +1 -1
  33. package/dist/components/variants.js +30 -1
  34. package/dist/components/variants.js.map +1 -1
  35. package/dist/constants.d.ts +25 -1
  36. package/dist/constants.d.ts.map +1 -1
  37. package/dist/constants.js +94 -1
  38. package/dist/constants.js.map +1 -1
  39. package/dist/copy.d.ts.map +1 -1
  40. package/dist/copy.js +17 -1
  41. package/dist/copy.js.map +1 -1
  42. package/dist/css/index.d.ts +2 -2
  43. package/dist/css/index.js +2 -2
  44. package/dist/css/shadows.d.ts +2 -2
  45. package/dist/css/shadows.d.ts.map +1 -1
  46. package/dist/css/shadows.js +4 -4
  47. package/dist/css/shadows.js.map +1 -1
  48. package/dist/css/text.d.ts +17 -1
  49. package/dist/css/text.d.ts.map +1 -1
  50. package/dist/css/text.js +62 -1
  51. package/dist/css/text.js.map +1 -1
  52. package/dist/css/values.d.ts +7 -2
  53. package/dist/css/values.d.ts.map +1 -1
  54. package/dist/css/values.js +8 -4
  55. package/dist/css/values.js.map +1 -1
  56. package/dist/design-memory/index.d.ts +3 -0
  57. package/dist/design-memory/index.js +3 -0
  58. package/dist/design-memory/model.d.ts +33 -0
  59. package/dist/design-memory/model.d.ts.map +1 -0
  60. package/dist/design-memory/model.js +142 -0
  61. package/dist/design-memory/model.js.map +1 -0
  62. package/dist/design-memory/schema.d.ts +76 -0
  63. package/dist/design-memory/schema.d.ts.map +1 -0
  64. package/dist/design-memory/schema.js +72 -0
  65. package/dist/design-memory/schema.js.map +1 -0
  66. package/dist/effects.d.ts +7 -4
  67. package/dist/effects.d.ts.map +1 -1
  68. package/dist/effects.js +9 -4
  69. package/dist/effects.js.map +1 -1
  70. package/dist/empty-values.js +102 -0
  71. package/dist/empty-values.js.map +1 -0
  72. package/dist/fields/components.d.ts +9 -0
  73. package/dist/fields/components.d.ts.map +1 -0
  74. package/dist/fields/components.js +24 -0
  75. package/dist/fields/components.js.map +1 -0
  76. package/dist/fields/index.d.ts +3 -2
  77. package/dist/fields/index.js +3 -2
  78. package/dist/fields/layout.d.ts +3 -1
  79. package/dist/fields/layout.d.ts.map +1 -1
  80. package/dist/fields/layout.js +10 -1
  81. package/dist/fields/layout.js.map +1 -1
  82. package/dist/graph.d.ts +12 -1
  83. package/dist/graph.d.ts.map +1 -1
  84. package/dist/graph.js +39 -7
  85. package/dist/graph.js.map +1 -1
  86. package/dist/grid-values.d.ts +10 -0
  87. package/dist/grid-values.d.ts.map +1 -0
  88. package/dist/grid-values.js +53 -0
  89. package/dist/grid-values.js.map +1 -0
  90. package/dist/hit-test/drop.d.ts +20 -0
  91. package/dist/hit-test/drop.d.ts.map +1 -0
  92. package/dist/hit-test/drop.js +54 -0
  93. package/dist/hit-test/drop.js.map +1 -0
  94. package/dist/hit-test/geometry.js +86 -0
  95. package/dist/hit-test/geometry.js.map +1 -0
  96. package/dist/hit-test/masks.d.ts +14 -0
  97. package/dist/hit-test/masks.d.ts.map +1 -0
  98. package/dist/hit-test/masks.js +41 -0
  99. package/dist/hit-test/masks.js.map +1 -0
  100. package/dist/hit-test/paint.d.ts +6 -0
  101. package/dist/hit-test/paint.d.ts.map +1 -0
  102. package/dist/hit-test/paint.js +19 -0
  103. package/dist/hit-test/paint.js.map +1 -0
  104. package/dist/hit-test.d.ts +4 -15
  105. package/dist/hit-test.d.ts.map +1 -1
  106. package/dist/hit-test.js +5 -173
  107. package/dist/hit-test.js.map +1 -1
  108. package/dist/images.d.ts +3 -2
  109. package/dist/images.d.ts.map +1 -1
  110. package/dist/images.js +18 -2
  111. package/dist/images.js.map +1 -1
  112. package/dist/index.d.ts +2 -2
  113. package/dist/instances/copies.js +2 -1
  114. package/dist/instances/copies.js.map +1 -1
  115. package/dist/instances/fields.d.ts.map +1 -1
  116. package/dist/instances/fields.js +2 -0
  117. package/dist/instances/fields.js.map +1 -1
  118. package/dist/instances/index.d.ts +2 -1
  119. package/dist/instances/index.d.ts.map +1 -1
  120. package/dist/instances/index.js +13 -12
  121. package/dist/instances/index.js.map +1 -1
  122. package/dist/instances/overrides.d.ts +15 -1
  123. package/dist/instances/overrides.d.ts.map +1 -1
  124. package/dist/instances/overrides.js +37 -1
  125. package/dist/instances/overrides.js.map +1 -1
  126. package/dist/instances/source-walk.d.ts +12 -0
  127. package/dist/instances/source-walk.d.ts.map +1 -0
  128. package/dist/instances/swap-overrides.js +3 -3
  129. package/dist/instances/swap-overrides.js.map +1 -1
  130. package/dist/instances/sync.js +9 -7
  131. package/dist/instances/sync.js.map +1 -1
  132. package/dist/node-defaults.d.ts.map +1 -1
  133. package/dist/node-defaults.js +43 -38
  134. package/dist/node-defaults.js.map +1 -1
  135. package/dist/plugin-data/fields.d.ts +90 -0
  136. package/dist/plugin-data/fields.d.ts.map +1 -1
  137. package/dist/plugin-data/fields.js +33 -24
  138. package/dist/plugin-data/fields.js.map +1 -1
  139. package/dist/plugin-data/index.d.ts +2 -2
  140. package/dist/plugin-data/index.js +2 -2
  141. package/dist/plugin-data/schema.d.ts +6 -1
  142. package/dist/plugin-data/schema.d.ts.map +1 -1
  143. package/dist/plugin-data/schema.js +24 -1
  144. package/dist/plugin-data/schema.js.map +1 -1
  145. package/dist/preview.d.ts.map +1 -1
  146. package/dist/preview.js +2 -0
  147. package/dist/preview.js.map +1 -1
  148. package/dist/scaling/node.d.ts.map +1 -1
  149. package/dist/scaling/node.js +5 -1
  150. package/dist/scaling/node.js.map +1 -1
  151. package/dist/shaders/animation.d.ts +21 -0
  152. package/dist/shaders/animation.d.ts.map +1 -0
  153. package/dist/shaders/animation.js +25 -0
  154. package/dist/shaders/animation.js.map +1 -0
  155. package/dist/shaders/index.d.ts +2 -1
  156. package/dist/shaders/index.js +2 -1
  157. package/dist/slots/content.d.ts.map +1 -1
  158. package/dist/slots/content.js +4 -4
  159. package/dist/slots/content.js.map +1 -1
  160. package/dist/statuses/index.d.ts +2 -2
  161. package/dist/statuses/index.js +2 -2
  162. package/dist/statuses/workflow.d.ts +3 -1
  163. package/dist/statuses/workflow.d.ts.map +1 -1
  164. package/dist/statuses/workflow.js +6 -2
  165. package/dist/statuses/workflow.js.map +1 -1
  166. package/dist/token-sources/document.d.ts +26 -0
  167. package/dist/token-sources/document.d.ts.map +1 -0
  168. package/dist/token-sources/document.js +80 -0
  169. package/dist/token-sources/document.js.map +1 -0
  170. package/dist/token-sources/index.d.ts +3 -0
  171. package/dist/token-sources/index.js +3 -0
  172. package/dist/token-sources/schema.d.ts +43 -0
  173. package/dist/token-sources/schema.d.ts.map +1 -0
  174. package/dist/token-sources/schema.js +50 -0
  175. package/dist/token-sources/schema.js.map +1 -0
  176. package/dist/transfer/variables.d.ts.map +1 -1
  177. package/dist/transfer/variables.js +1 -1
  178. package/dist/transfer/variables.js.map +1 -1
  179. package/dist/types.d.ts +135 -15
  180. package/dist/types.d.ts.map +1 -1
  181. package/dist/types.js.map +1 -1
  182. package/dist/variables/bindings.d.ts +6 -5
  183. package/dist/variables/bindings.d.ts.map +1 -1
  184. package/dist/variables/bindings.js +24 -16
  185. package/dist/variables/bindings.js.map +1 -1
  186. package/dist/variables/formula/index.d.ts.map +1 -1
  187. package/dist/variables/formula/index.js +12 -6
  188. package/dist/variables/formula/index.js.map +1 -1
  189. package/dist/variables/index.d.ts +14 -1
  190. package/dist/variables/index.d.ts.map +1 -1
  191. package/dist/variables/index.js +38 -10
  192. package/dist/variables/index.js.map +1 -1
  193. package/dist/variables/paints.d.ts +9 -8
  194. package/dist/variables/paints.d.ts.map +1 -1
  195. package/dist/variables/paints.js +35 -26
  196. package/dist/variables/paints.js.map +1 -1
  197. package/dist/variables/resolver.d.ts +45 -0
  198. package/dist/variables/resolver.d.ts.map +1 -0
  199. package/dist/variables/resolver.js +106 -0
  200. package/dist/variables/resolver.js.map +1 -0
  201. package/dist/variations/copy.d.ts +16 -0
  202. package/dist/variations/copy.d.ts.map +1 -0
  203. package/dist/variations/copy.js +78 -0
  204. package/dist/variations/copy.js.map +1 -0
  205. package/dist/variations/index.d.ts +6 -0
  206. package/dist/variations/index.js +6 -0
  207. package/dist/variations/match.d.ts +23 -0
  208. package/dist/variations/match.d.ts.map +1 -0
  209. package/dist/variations/match.js +80 -0
  210. package/dist/variations/match.js.map +1 -0
  211. package/dist/variations/model.d.ts +39 -0
  212. package/dist/variations/model.d.ts.map +1 -0
  213. package/dist/variations/model.js +90 -0
  214. package/dist/variations/model.js.map +1 -0
  215. package/dist/variations/pick.d.ts +43 -0
  216. package/dist/variations/pick.d.ts.map +1 -0
  217. package/dist/variations/pick.js +211 -0
  218. package/dist/variations/pick.js.map +1 -0
  219. package/dist/variations/schema.d.ts +27 -0
  220. package/dist/variations/schema.d.ts.map +1 -0
  221. package/dist/variations/schema.js +27 -0
  222. package/dist/variations/schema.js.map +1 -0
  223. package/package.json +21 -1
  224. package/src/color/index.ts +43 -9
  225. package/src/color/management.ts +54 -1
  226. package/src/color/profile.ts +131 -0
  227. package/src/comments/merge.ts +3 -0
  228. package/src/comments/schema.ts +32 -2
  229. package/src/comments/threads.ts +5 -2
  230. package/src/components/properties.ts +13 -7
  231. package/src/components/variants.ts +39 -0
  232. package/src/constants.ts +75 -0
  233. package/src/copy.ts +20 -1
  234. package/src/css/index.ts +7 -1
  235. package/src/css/shadows.ts +8 -5
  236. package/src/css/text.ts +62 -0
  237. package/src/css/values.ts +12 -5
  238. package/src/design-memory/index.ts +2 -0
  239. package/src/design-memory/model.ts +143 -0
  240. package/src/design-memory/schema.ts +84 -0
  241. package/src/effects.ts +16 -7
  242. package/src/empty-values.ts +117 -0
  243. package/src/fields/components.ts +21 -0
  244. package/src/fields/index.ts +1 -0
  245. package/src/fields/layout.ts +10 -0
  246. package/src/graph.ts +50 -6
  247. package/src/grid-values.ts +47 -0
  248. package/src/hit-test/drop.ts +90 -0
  249. package/src/hit-test/geometry.ts +131 -0
  250. package/src/hit-test/masks.ts +57 -0
  251. package/src/hit-test/paint.ts +24 -0
  252. package/src/hit-test.ts +8 -277
  253. package/src/images.ts +27 -3
  254. package/src/instances/copies.ts +2 -1
  255. package/src/instances/fields.ts +2 -0
  256. package/src/instances/index.ts +20 -11
  257. package/src/instances/overrides.ts +49 -0
  258. package/src/instances/swap-overrides.ts +3 -2
  259. package/src/instances/sync.ts +11 -7
  260. package/src/node-defaults.ts +51 -41
  261. package/src/plugin-data/fields.ts +34 -32
  262. package/src/plugin-data/index.ts +1 -0
  263. package/src/plugin-data/schema.ts +30 -0
  264. package/src/preview.ts +2 -0
  265. package/src/scaling/node.ts +7 -2
  266. package/src/shaders/animation.ts +39 -0
  267. package/src/shaders/index.ts +1 -0
  268. package/src/slots/content.ts +8 -4
  269. package/src/statuses/workflow.ts +6 -4
  270. package/src/token-sources/document.ts +104 -0
  271. package/src/token-sources/index.ts +2 -0
  272. package/src/token-sources/schema.ts +59 -0
  273. package/src/transfer/variables.ts +2 -1
  274. package/src/types.ts +145 -14
  275. package/src/variables/bindings.ts +35 -18
  276. package/src/variables/formula/index.ts +19 -18
  277. package/src/variables/index.ts +49 -10
  278. package/src/variables/paints.ts +64 -29
  279. package/src/variables/resolver.ts +178 -0
  280. package/src/variations/copy.ts +89 -0
  281. package/src/variations/index.ts +5 -0
  282. package/src/variations/match.ts +100 -0
  283. package/src/variations/model.ts +132 -0
  284. package/src/variations/pick.ts +293 -0
  285. package/src/variations/schema.ts +29 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","names":[],"sources":["../../src/design-memory/model.ts"],"sourcesContent":["import { tryParseColor, colorToHex } from '../color'\nimport type { SceneGraph } from '../graph'\nimport { readPluginData, withPluginData } from '../plugin-data/field'\nimport { PAIRDRAW_PLUGIN_DATA } from '../plugin-data/fields'\nimport { randomHex } from '../random'\nimport type { PluginDataEntry } from '../types'\nimport {\n DESIGN_MEMORY_LIMITS,\n type DesignDecisionAuthor,\n type DesignMemory,\n type DesignMemoryGroup\n} from './schema'\n\nconst { designMemory } = PAIRDRAW_PLUGIN_DATA\n\nconst GROUP_LIMITS = {\n colors: DESIGN_MEMORY_LIMITS.colors,\n fonts: DESIGN_MEMORY_LIMITS.fonts,\n fontSizes: DESIGN_MEMORY_LIMITS.numbers,\n spacing: DESIGN_MEMORY_LIMITS.numbers,\n radius: DESIGN_MEMORY_LIMITS.numbers\n} as const satisfies Record<DesignMemoryGroup, number>\n\n/**\n * A new memory: every group allows the document's own variables and styles. Off-system colors\n * and fonts refuse an agent's edit; sizes, spacing and radii have real exceptions, so they warn.\n */\nexport function createDesignMemory(): DesignMemory {\n return {\n version: 1,\n colors: { fromSystem: true, values: [], enforce: 'refuse' },\n fonts: { fromSystem: true, values: [], enforce: 'refuse' },\n fontSizes: { fromSystem: true, values: [], enforce: 'warn' },\n spacing: { fromSystem: true, values: [], enforce: 'warn' },\n radius: { fromSystem: true, values: [], enforce: 'warn' },\n decisions: [],\n examples: []\n }\n}\n\n/** The document's memory, or null when it has none or it is unreadable. */\nexport function readDesignMemory(graph: SceneGraph): DesignMemory | null {\n return readPluginData(graph.getNode(graph.rootId)?.pluginData, designMemory) ?? null\n}\n\nconst MEMORIES = new WeakMap<\n SceneGraph,\n { entries: readonly PluginDataEntry[] | undefined; memory: DesignMemory | null }\n>()\n\n/**\n * The document's memory, read once per state of its document node: an edit replaces the node's\n * plugin data, so a check on every agent call parses nothing new.\n */\nexport function cachedDesignMemory(graph: SceneGraph): DesignMemory | null {\n const entries = graph.getNode(graph.rootId)?.pluginData\n const known = MEMORIES.get(graph)\n if (known && known.entries === entries) return known.memory\n const memory = readDesignMemory(graph)\n MEMORIES.set(graph, { entries, memory })\n return memory\n}\n\n/** Stores the memory on the document node as an undoable change; `null` removes it. */\nexport function writeDesignMemory(graph: SceneGraph, memory: DesignMemory | null): void {\n const root = graph.getNode(graph.rootId)\n if (!root) return\n graph.updateNode(root.id, {\n pluginData: withPluginData(root.pluginData, designMemory, memory ?? undefined)\n })\n}\n\n/** A value as a group keeps it, or null when it is not one: colors become `#RRGGBB`. */\nexport function normalizeDesignValue(\n group: DesignMemoryGroup,\n value: string | number\n): string | number | null {\n if (group === 'colors') {\n const color = typeof value === 'string' ? tryParseColor(value.trim()) : null\n return color ? colorToHex(color) : null\n }\n if (group === 'fonts') {\n const family = typeof value === 'string' ? value.trim() : ''\n return family && family.length <= DESIGN_MEMORY_LIMITS.fontLength ? family : null\n }\n const number = typeof value === 'number' ? value : Number(value)\n if (!Number.isFinite(number)) return null\n // A text has a size; spacing and radii may be zero.\n return number > 0 || (number === 0 && group !== 'fontSizes') ? number : null\n}\n\n/**\n * The memory with `value` allowed in `group`, once; a value the group cannot read, or one past\n * its limit, leaves it as it was.\n */\nexport function allowDesignValue(\n memory: DesignMemory,\n group: DesignMemoryGroup,\n value: string | number\n): DesignMemory {\n const normalized = normalizeDesignValue(group, value)\n const values: readonly (string | number)[] = memory[group].values\n if (normalized === null || values.includes(normalized) || values.length >= GROUP_LIMITS[group])\n return memory\n return { ...memory, [group]: { ...memory[group], values: [...values, normalized] } }\n}\n\n/** The memory with `value` no longer allowed in `group` by itself. */\nexport function disallowDesignValue(\n memory: DesignMemory,\n group: DesignMemoryGroup,\n value: string | number\n): DesignMemory {\n const values: readonly (string | number)[] = memory[group].values\n return {\n ...memory,\n [group]: { ...memory[group], values: values.filter((item) => item !== value) }\n }\n}\n\n/** The memory with a decision added last; blank text or a full list leaves it as it was. */\nexport function addDesignDecision(\n memory: DesignMemory,\n text: string,\n author: DesignDecisionAuthor\n): DesignMemory {\n const trimmed = text.trim().slice(0, DESIGN_MEMORY_LIMITS.decisionLength).trim()\n if (!trimmed || memory.decisions.length >= DESIGN_MEMORY_LIMITS.decisions) return memory\n return {\n ...memory,\n decisions: [...memory.decisions, { id: randomHex(8), text: trimmed, author }]\n }\n}\n\n/** The memory with a layer pinned as an example, once; a full list leaves it as it was. */\nexport function pinDesignExample(memory: DesignMemory, nodeId: string): DesignMemory {\n if (\n memory.examples.some((example) => example.nodeId === nodeId) ||\n memory.examples.length >= DESIGN_MEMORY_LIMITS.examples\n )\n return memory\n return { ...memory, examples: [...memory.examples, { nodeId }] }\n}\n"],"mappings":";;;;;;AAaA,MAAM,EAAE,iBAAiB;AAEzB,MAAM,eAAe;CACnB,QAAQ,qBAAqB;CAC7B,OAAO,qBAAqB;CAC5B,WAAW,qBAAqB;CAChC,SAAS,qBAAqB;CAC9B,QAAQ,qBAAqB;AAC/B;;;;;AAMA,SAAgB,qBAAmC;CACjD,OAAO;EACL,SAAS;EACT,QAAQ;GAAE,YAAY;GAAM,QAAQ,CAAC;GAAG,SAAS;EAAS;EAC1D,OAAO;GAAE,YAAY;GAAM,Q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examples one document's memory keeps. */
4
+ declare const DESIGN_MEMORY_LIMITS: {
5
+ readonly colors: 128;
6
+ readonly fonts: 16;
7
+ readonly numbers: 32;
8
+ readonly decisions: 40;
9
+ readonly decisionLength: 400;
10
+ readonly examples: 12;
11
+ readonly fontLength: 100;
12
+ };
13
+ /** The kinds of value a memory allows, each with its own list and enforcement. */
14
+ declare const DESIGN_MEMORY_GROUPS: readonly ["colors", "fonts", "fontSizes", "spacing", "radius"];
15
+ type DesignMemoryGroup = (typeof DESIGN_MEMORY_GROUPS)[number];
16
+ /**
17
+ * What happens to an agent's edit that uses a value the memory does not allow: it is undone and
18
+ * the agent told the allowed values, it goes through with a warning, or nothing is checked.
19
+ * People's own edits are never refused; lint lists them.
20
+ */
21
+ declare const DESIGN_MEMORY_ENFORCEMENTS: readonly ["refuse", "warn", "off"];
22
+ type DesignMemoryEnforcement = (typeof DESIGN_MEMORY_ENFORCEMENTS)[number];
23
+ declare const DESIGN_DECISION_AUTHORS: readonly ["person", "agent"];
24
+ type DesignDecisionAuthor = (typeof DESIGN_DECISION_AUTHORS)[number];
25
+ /**
26
+ * A document's design rules for agents: the values its designs may use, decisions written down
27
+ * about them, and frames pinned as examples to follow.
28
+ */
29
+ declare const designMemorySchema: v.ObjectSchema<{
30
+ readonly version: v.LiteralSchema<1, undefined>;
31
+ readonly colors: v.ObjectSchema<{
32
+ readonly fromSystem: v.BooleanSchema<undefined>;
33
+ readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<unknown, string>, undefined>, v.MaxLengthAction<string[], number, undefined>]>;
34
+ readonly enforce: v.PicklistSchema<readonly ["refuse", "warn", "off"], undefined>;
35
+ }, undefined>;
36
+ readonly fonts: v.ObjectSchema<{
37
+ readonly fromSystem: v.BooleanSchema<undefined>;
38
+ readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<unknown, string>, undefined>, v.MaxLengthAction<string[], number, undefined>]>;
39
+ readonly enforce: v.PicklistSchema<readonly ["refuse", "warn", "off"], undefined>;
40
+ }, undefined>;
41
+ readonly fontSizes: v.ObjectSchema<{
42
+ readonly fromSystem: v.BooleanSchema<undefined>;
43
+ readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<unknown, number>, undefined>, v.MaxLengthAction<number[], number, undefined>]>;
44
+ readonly enforce: v.PicklistSchema<readonly ["refuse", "warn", "off"], undefined>;
45
+ }, undefined>;
46
+ readonly spacing: v.ObjectSchema<{
47
+ readonly fromSystem: v.BooleanSchema<undefined>;
48
+ readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<unknown, number>, undefined>, v.MaxLengthAction<number[], number, undefined>]>;
49
+ readonly enforce: v.PicklistSchema<readonly ["refuse", "warn", "off"], undefined>;
50
+ }, undefined>;
51
+ readonly radius: v.ObjectSchema<{
52
+ readonly fromSystem: v.BooleanSchema<undefined>;
53
+ readonly values: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<unknown, number>, undefined>, v.MaxLengthAction<number[], number, undefined>]>;
54
+ readonly enforce: v.PicklistSchema<readonly ["refuse", "warn", "off"], undefined>;
55
+ }, undefined>;
56
+ readonly decisions: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
57
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>;
58
+ readonly text: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>, v.MaxLengthAction<string, 400, undefined>]>;
59
+ readonly author: v.PicklistSchema<readonly ["person", "agent"], undefined>;
60
+ }, undefined>, undefined>, v.MaxLengthAction<{
61
+ id: string;
62
+ text: string;
63
+ author: "person" | "agent";
64
+ }[], 40, undefined>]>;
65
+ readonly examples: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
66
+ readonly nodeId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>;
67
+ }, undefined>, undefined>, v.MaxLengthAction<{
68
+ nodeId: string;
69
+ }[], 12, undefined>]>;
70
+ }, undefined>;
71
+ type DesignMemory = v.InferOutput<typeof designMemorySchema>;
72
+ type DesignDecision = DesignMemory['decisions'][number];
73
+ type DesignExample = DesignMemory['examples'][number];
74
+ //#endregion
75
+ export { DESIGN_DECISION_AUTHORS, DESIGN_MEMORY_ENFORCEMENTS, DESIGN_MEMORY_GROUPS, DESIGN_MEMORY_LIMITS, DesignDecision, DesignDecisionAuthor, DesignExample, DesignMemory, DesignMemoryEnforcement, DesignMemoryGroup, designMemorySchema };
76
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/design-memory/schema.ts"],"mappings":";;;cAGa;;;;;;;;;;cAWA;KACD,4BAA4B;;;;;;cAO3B;KACD,kCAAkC;cAEjC;KACD,+BAA+B;;;;;cA4C9B,oBAAkB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAWnB,eAAe,EAAE,mBAAmB;KACpC,iBAAiB;KACjB,gBAAgB"}
@@ -0,0 +1,72 @@
1
+ import * as v from "valibot";
2
+ //#region src/design-memory/schema.ts
3
+ /** How many values, decisions and examples one document's memory keeps. */
4
+ const DESIGN_MEMORY_LIMITS = {
5
+ colors: 128,
6
+ fonts: 16,
7
+ numbers: 32,
8
+ decisions: 40,
9
+ decisionLength: 400,
10
+ examples: 12,
11
+ fontLength: 100
12
+ };
13
+ /** The kinds of value a memory allows, each with its own list and enforcement. */
14
+ const DESIGN_MEMORY_GROUPS = [
15
+ "colors",
16
+ "fonts",
17
+ "fontSizes",
18
+ "spacing",
19
+ "radius"
20
+ ];
21
+ /**
22
+ * What happens to an agent's edit that uses a value the memory does not allow: it is undone and
23
+ * the agent told the allowed values, it goes through with a warning, or nothing is checked.
24
+ * People's own edits are never refused; lint lists them.
25
+ */
26
+ const DESIGN_MEMORY_ENFORCEMENTS = [
27
+ "refuse",
28
+ "warn",
29
+ "off"
30
+ ];
31
+ const DESIGN_DECISION_AUTHORS = ["person", "agent"];
32
+ const enforcementSchema = v.picklist(DESIGN_MEMORY_ENFORCEMENTS);
33
+ /** A color as a memory keeps it: `#RRGGBB`, since alpha is never compared. */
34
+ const hexColorSchema = v.pipe(v.string(), v.regex(/^#[0-9A-F]{6}$/));
35
+ const fontFamilySchema = v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(DESIGN_MEMORY_LIMITS.fontLength));
36
+ const fontSizeSchema = v.pipe(v.number(), v.finite(), v.gtValue(0));
37
+ const lengthSchema = v.pipe(v.number(), v.finite(), v.minValue(0));
38
+ /**
39
+ * One group: `fromSystem` allows what the document's variables and styles hold, and `values`
40
+ * adds values of the person's own.
41
+ */
42
+ function valueGroup(value, max) {
43
+ return v.object({
44
+ fromSystem: v.boolean(),
45
+ values: v.pipe(v.array(value), v.maxLength(max)),
46
+ enforce: enforcementSchema
47
+ });
48
+ }
49
+ const decisionSchema = v.object({
50
+ id: v.pipe(v.string(), v.nonEmpty()),
51
+ text: v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(DESIGN_MEMORY_LIMITS.decisionLength)),
52
+ author: v.picklist(DESIGN_DECISION_AUTHORS)
53
+ });
54
+ const exampleSchema = v.object({ nodeId: v.pipe(v.string(), v.nonEmpty()) });
55
+ /**
56
+ * A document's design rules for agents: the values its designs may use, decisions written down
57
+ * about them, and frames pinned as examples to follow.
58
+ */
59
+ const designMemorySchema = v.object({
60
+ version: v.literal(1),
61
+ colors: valueGroup(hexColorSchema, DESIGN_MEMORY_LIMITS.colors),
62
+ fonts: valueGroup(fontFamilySchema, DESIGN_MEMORY_LIMITS.fonts),
63
+ fontSizes: valueGroup(fontSizeSchema, DESIGN_MEMORY_LIMITS.numbers),
64
+ spacing: valueGroup(lengthSchema, DESIGN_MEMORY_LIMITS.numbers),
65
+ radius: valueGroup(lengthSchema, DESIGN_MEMORY_LIMITS.numbers),
66
+ decisions: v.pipe(v.array(decisionSchema), v.maxLength(DESIGN_MEMORY_LIMITS.decisions)),
67
+ examples: v.pipe(v.array(exampleSchema), v.maxLength(DESIGN_MEMORY_LIMITS.examples))
68
+ });
69
+ //#endregion
70
+ export { DESIGN_DECISION_AUTHORS, DESIGN_MEMORY_ENFORCEMENTS, DESIGN_MEMORY_GROUPS, DESIGN_MEMORY_LIMITS, designMemorySchema };
71
+
72
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../src/design-memory/schema.ts"],"sourcesContent":["import * as v from 'valibot'\n\n/** How many values, decisions and examples one document's memory keeps. */\nexport const DESIGN_MEMORY_LIMITS = {\n colors: 128,\n fonts: 16,\n numbers: 32,\n decisions: 40,\n decisionLength: 400,\n examples: 12,\n fontLength: 100\n} as const\n\n/** The kinds of value a memory allows, each with its own list and enforcement. */\nexport const DESIGN_MEMORY_GROUPS = ['colors', 'fonts', 'fontSizes', 'spacing', 'radius'] as const\nexport type DesignMemoryGroup = (typeof DESIGN_MEMORY_GROUPS)[number]\n\n/**\n * What happens to an agent's edit that uses a value the memory does not allow: it is undone and\n * the agent told the allowed values, it goes through with a warning, or nothing is checked.\n * People's own edits are never refused; lint lists them.\n */\nexport const DESIGN_MEMORY_ENFORCEMENTS = ['refuse', 'warn', 'off'] as const\nexport type DesignMemoryEnforcement = (typeof DESIGN_MEMORY_ENFORCEMENTS)[number]\n\nexport const DESIGN_DECISION_AUTHORS = ['person', 'agent'] as const\nexport type DesignDecisionAuthor = (typeof DESIGN_DECISION_AUTHORS)[number]\n\nconst enforcementSchema = v.picklist(DESIGN_MEMORY_ENFORCEMENTS)\n\n/** A color as a memory keeps it: `#RRGGBB`, since alpha is never compared. */\nconst hexColorSchema = v.pipe(v.string(), v.regex(/^#[0-9A-F]{6}$/))\nconst fontFamilySchema = v.pipe(\n v.string(),\n v.trim(),\n v.nonEmpty(),\n v.maxLength(DESIGN_MEMORY_LIMITS.fontLength)\n)\nconst fontSizeSchema = v.pipe(v.number(), v.finite(), v.gtValue(0))\nconst lengthSchema = v.pipe(v.number(), v.finite(), v.minValue(0))\n\n/**\n * One group: `fromSystem` allows what the document's variables and styles hold, and `values`\n * adds values of the person's own.\n */\nfunction valueGroup<T>(value: v.GenericSchema<unknown, T>, max: number) {\n return v.object({\n fromSystem: v.boolean(),\n values: v.pipe(v.array(value), v.maxLength(max)),\n enforce: enforcementSchema\n })\n}\n\nconst decisionSchema = v.object({\n id: v.pipe(v.string(), v.nonEmpty()),\n text: v.pipe(\n v.string(),\n v.trim(),\n v.nonEmpty(),\n v.maxLength(DESIGN_MEMORY_LIMITS.decisionLength)\n ),\n author: v.picklist(DESIGN_DECISION_AUTHORS)\n})\n\nconst exampleSchema = v.object({ nodeId: v.pipe(v.string(), v.nonEmpty()) })\n\n/**\n * A document's design rules for agents: the values its designs may use, decisions written down\n * about them, and frames pinned as examples to follow.\n */\nexport const designMemorySchema = v.object({\n version: v.literal(1),\n colors: valueGroup(hexColorSchema, DESIGN_MEMORY_LIMITS.colors),\n fonts: valueGroup(fontFamilySchema, DESIGN_MEMORY_LIMITS.fonts),\n fontSizes: valueGroup(fontSizeSchema, DESIGN_MEMORY_LIMITS.numbers),\n spacing: valueGroup(lengthSchema, DESIGN_MEMORY_LIMITS.numbers),\n radius: valueGroup(lengthSchema, DESIGN_MEMORY_LIMITS.numbers),\n decisions: v.pipe(v.array(decisionSchema), v.maxLength(DESIGN_MEMORY_LIMITS.decisions)),\n examples: v.pipe(v.array(exampleSchema), v.maxLength(DESIGN_MEMORY_LIMITS.examples))\n})\n\nexport type DesignMemory = v.InferOutput<typeof designMemorySchema>\nexport type DesignDecision = DesignMemory['decisions'][number]\nexport type DesignExample = DesignMemory['examples'][number]\n"],"mappings":";;;AAGA,MAAa,uBAAuB;CAClC,QAAQ;CACR,OAAO;CACP,SAAS;CACT,WAAW;CACX,gBAAgB;CAChB,UAAU;CACV,YAAY;AACd;;AAGA,MAAa,uBAAuB;CA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B,KAAK;CAC9D,WAAW,WAAW,gBAAgB,qBAAqB,OAAO;CAClE,SAAS,WAAW,cAAc,qBAAqB,OAAO;CAC9D,QAAQ,WAAW,cAAc,qBAAqB,OAAO;CAC7D,WAAW,EAAE,KAAK,EAAE,MAAM,cAAc,GAAG,EAAE,UAAU,qBAAqB,SAAS,CAAC;CACtF,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,GAAG,EAAE,UAAU,qBAAqB,QAAQ,CAAC;AACrF,CAAC"}
package/dist/effects.d.ts CHANGED
@@ -1,16 +1,19 @@
1
1
  import { Vector } from "./primitives/index.js";
2
- import { Effect, ShaderEffect, ShadowEffect } from "./types.js";
2
+ import { Effect, ShadowEffect } from "./types.js";
3
3
  //#region src/effects.d.ts
4
4
  /** A shadow or blur whose offset may still be missing or only partly present. */
5
5
  type ShadowInput = Omit<ShadowEffect, 'offset'> & {
6
6
  offset?: Partial<Vector> | null;
7
7
  };
8
+ /** An effect as a caller may pass it, before its geometry is made finite. */
9
+ type EffectInput = Effect | ShadowInput;
8
10
  /**
9
11
  * Shadows and blurs keep a finite offset. A drop or inner shadow missing one uses `{x: 0, y: 4}`,
10
- * the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader effects
11
- * are left alone. An array that is already valid is returned as itself.
12
+ * the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader, noise,
13
+ * and texture effects carry no offset and are left alone. An array that is already valid is
14
+ * returned as itself.
12
15
  */
13
- declare function normalizeEffects(effects: (ShaderEffect | ShadowInput)[]): Effect[];
16
+ declare function normalizeEffects(effects: EffectInput[]): Effect[];
14
17
  //#endregion
15
18
  export { normalizeEffects };
16
19
  //# sourceMappingURL=effects.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"effects.d.ts","names":[],"sources":["../src/effects.ts"],"mappings":";;;;KAOK,cAAc,KAAK;EACtB,SAAS,QAAQ;;;;;;;iBAqDH,iBAAiB,UAAU,eAAe,iBAAiB"}
1
+ {"version":3,"file":"effects.d.ts","names":[],"sources":["../src/effects.ts"],"mappings":";;;;KAOK,cAAc,KAAK;EACtB,SAAS,QAAQ;;;KAId,cAAc,SAAS;;;;;;;iBA0DZ,iBAAiB,SAAS,gBAAgB"}
package/dist/effects.js CHANGED
@@ -35,6 +35,10 @@ function isStoredShadow(effect) {
35
35
  const offset = effect.offset;
36
36
  return !!offset && typeof offset.x === "number" && Number.isFinite(offset.x) && typeof offset.y === "number" && Number.isFinite(offset.y);
37
37
  }
38
+ /** An effect that carries geometry of its own, which has to be finite to render. */
39
+ function isOffsetEffect(effect) {
40
+ return effect.type !== "SHADER" && effect.type !== "NOISE" && effect.type !== "TEXTURE";
41
+ }
38
42
  function withFiniteOffset(effect) {
39
43
  const offset = finiteOffset(effect);
40
44
  if (!offset) {
@@ -50,17 +54,18 @@ function withFiniteOffset(effect) {
50
54
  };
51
55
  }
52
56
  function isStoredEffect(effect) {
53
- return effect.type === "SHADER" || isStoredShadow(effect);
57
+ return !isOffsetEffect(effect) || isStoredShadow(effect);
54
58
  }
55
59
  /**
56
60
  * Shadows and blurs keep a finite offset. A drop or inner shadow missing one uses `{x: 0, y: 4}`,
57
- * the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader effects
58
- * are left alone. An array that is already valid is returned as itself.
61
+ * the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader, noise,
62
+ * and texture effects carry no offset and are left alone. An array that is already valid is
63
+ * returned as itself.
59
64
  */
60
65
  function normalizeEffects(effects) {
61
66
  let next = null;
62
67
  for (const [index, effect] of effects.entries()) {
63
- const normalized = effect.type === "SHADER" ? effect : withFiniteOffset(effect);
68
+ const normalized = isOffsetEffect(effect) ? withFiniteOffset(effect) : effect;
64
69
  if (normalized === effect) {
65
70
  if (next && isStoredEffect(effect)) next.push(effect);
66
71
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"effects.js","names":[],"sources":["../src/effects.ts"],"sourcesContent":["import type { Vector } from './primitives'\nimport type { Effect, ShaderEffect, ShadowEffect } from './types'\n\nconst SHADOW_OFFSET: Vector = { x: 0, y: 4 }\nconst BLUR_OFFSET: Vector = { x: 0, y: 0 }\n\n/** A shadow or blur whose offset may still be missing or only partly present. */\ntype ShadowInput = Omit<ShadowEffect, 'offset'> & {\n offset?: Partial<Vector> | null\n}\n\nfunction fallbackOffset(type: ShadowEffect['type']): Vector {\n return type === 'DROP_SHADOW' || type === 'INNER_SHADOW' ? SHADOW_OFFSET : BLUR_OFFSET\n}\n\nfunction component(offset: object, key: 'x' | 'y', fallback: number): number {\n if (!(key in offset)) return fallback\n const value: unknown = Reflect.get(offset, key)\n return typeof value === 'number' && Number.isFinite(value) ? value : fallback\n}\n\n/** A new offset when `effect.offset` is missing or not finite; null when it can stay. */\nfunction finiteOffset(effect: ShadowInput): Vector | null {\n const fallback = fallbackOffset(effect.type)\n const offset: unknown = effect.offset\n if (offset === null || typeof offset !== 'object') return { x: fallback.x, y: fallback.y }\n const x = component(offset, 'x', fallback.x)\n const y = component(offset, 'y', fallback.y)\n if (Reflect.get(offset, 'x') === x && Reflect.get(offset, 'y') === y) return null\n return { x, y }\n}\n\nfunction isStoredShadow(effect: ShadowInput): effect is ShadowEffect {\n const offset = effect.offset\n return (\n !!offset &&\n typeof offset.x === 'number' &&\n Number.isFinite(offset.x) &&\n typeof offset.y === 'number' &&\n Number.isFinite(offset.y)\n )\n}\n\nfunction withFiniteOffset(effect: ShadowInput): Effect {\n const offset = finiteOffset(effect)\n if (!offset) {\n if (isStoredShadow(effect)) return effect\n return { ...effect, offset: fallbackOffset(effect.type) }\n }\n return { ...effect, offset }\n}\n\nfunction isStoredEffect(effect: ShaderEffect | ShadowInput): effect is Effect {\n return effect.type === 'SHADER' || isStoredShadow(effect)\n}\n\n/**\n * Shadows and blurs keep a finite offset. A drop or inner shadow missing one uses `{x: 0, y: 4}`,\n * the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader effects\n * are left alone. An array that is already valid is returned as itself.\n */\nexport function normalizeEffects(effects: (ShaderEffect | ShadowInput)[]): Effect[] {\n let next: Effect[] | null = null\n for (const [index, effect] of effects.entries()) {\n const normalized = effect.type === 'SHADER' ? effect : withFiniteOffset(effect)\n if (normalized === effect) {\n if (next && isStoredEffect(effect)) next.push(effect)\n continue\n }\n next ??= effects.slice(0, index).filter(isStoredEffect)\n next.push(normalized)\n }\n if (next) return next\n if (effects.every(isStoredEffect)) return effects\n return effects.filter(isStoredEffect)\n}\n"],"mappings":";AAGA,MAAM,gBAAwB;CAAE,GAAG;CAAG,GAAG;AAAE;AAC3C,MAAM,cAAsB;CAAE,GAAG;CAAG,GAAG;AAAE;AAOzC,SAAS,eAAe,MAAoC;CAC1D,OAAO,SAAS,iBAAiB,SAAS,iBAAiB,gBAAgB;AAC7E;AAEA,SAAS,UAAU,QAAgB,KAAgB,UAA0B;CAC3E,IAAI,EAAE,OAAO,SAAS,OAAO;CAC7B,MAAM,QAAiB,QAAQ,IAAI,QAAQ,GAAG;CAC9C,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ;AACvE;;AAGA,SAAS,aAAa,QAAoC;CACxD,MAAM,WAAW,eAAe,OAAO,IAAI;CAC3C,MAAM,SAAkB,OAAO;CAC/B,IAAI,WAAW,QAAQ,OAAO,WAAW,UAAU,OAAO;EAAE,GAAG,SAAS;EAAG,GAAG,SAAS;CAAE;CACzF,MAAM,IAAI,UAAU,QAAQ,KAAK,SAAS,CAAC;CAC3C,MAAM,IAAI,UAAU,QAAQ,KAAK,SAAS,CAAC;CAC3C,IAAI,QAAQ,IAAI,QAAQ,GAAG,MAAM,KAAK,QAAQ,IAAI,QAAQ,GAAG,MAAM,GAAG,OAAO;CAC7E,OAAO;EAAE;EAAG;CAAE;AAChB;AAEA,SAAS,eAAe,QAA6C;CACnE,MAAM,SAAS,OAAO;CACtB,OACE,CAAC,CAAC,UACF,OAAO,OAAO,MAAM,YACpB,OAAO,SAAS,OAAO,CAAC,KACxB,OAAO,OAAO,MAAM,YACpB,OAAO,SAAS,OAAO,CAAC;AAE5B;AAEA,SAAS,iBAAiB,QAA6B;CACrD,MAAM,SAAS,aAAa,MAAM;CAClC,IAAI,CAAC,QAAQ;EACX,IAAI,eAAe,MAAM,GAAG,OAAO;EACnC,OAAO;GAAE,GAAG;GAAQ,QAAQ,eAAe,OAAO,IAAI;EAAE;CAC1D;CACA,OAAO;EAAE,GAAG;EAAQ;CAAO;AAC7B;AAEA,SAAS,eAAe,QAAsD;CAC5E,OAAO,OAAO,SAAS,YAAY,eAAe,MAAM;AAC1D;;;;;;AAOA,SAAgB,iBAAiB,SAAmD;CAClF,IAAI,OAAwB;CAC5B,KAAK,MAAM,CAAC,OAAO,WAAW,QAAQ,QAAQ,GAAG;EAC/C,MAAM,aAAa,OAAO,SAAS,WAAW,SAAS,iBAAiB,MAAM;EAC9E,IAAI,eAAe,QAAQ;GACzB,IAAI,QAAQ,eAAe,MAAM,GAAG,KAAK,KAAK,MAAM;GACpD;EACF;EACA,SAAS,QAAQ,MAAM,GAAG,KAAK,CAAC,CAAC,OAAO,cAAc;EACtD,KAAK,KAAK,UAAU;CACtB;CACA,IAAI,MAAM,OAAO;CACjB,IAAI,QAAQ,MAAM,cAAc,GAAG,OAAO;CAC1C,OAAO,QAAQ,OAAO,cAAc;AACtC"}
1
+ {"version":3,"file":"effects.js","names":[],"sources":["../src/effects.ts"],"sourcesContent":["import type { Vector } from './primitives'\nimport type { Effect, ShadowEffect } from './types'\n\nconst SHADOW_OFFSET: Vector = { x: 0, y: 4 }\nconst BLUR_OFFSET: Vector = { x: 0, y: 0 }\n\n/** A shadow or blur whose offset may still be missing or only partly present. */\ntype ShadowInput = Omit<ShadowEffect, 'offset'> & {\n offset?: Partial<Vector> | null\n}\n\n/** An effect as a caller may pass it, before its geometry is made finite. */\ntype EffectInput = Effect | ShadowInput\n\nfunction fallbackOffset(type: ShadowEffect['type']): Vector {\n return type === 'DROP_SHADOW' || type === 'INNER_SHADOW' ? SHADOW_OFFSET : BLUR_OFFSET\n}\n\nfunction component(offset: object, key: 'x' | 'y', fallback: number): number {\n if (!(key in offset)) return fallback\n const value: unknown = Reflect.get(offset, key)\n return typeof value === 'number' && Number.isFinite(value) ? value : fallback\n}\n\n/** A new offset when `effect.offset` is missing or not finite; null when it can stay. */\nfunction finiteOffset(effect: ShadowInput): Vector | null {\n const fallback = fallbackOffset(effect.type)\n const offset: unknown = effect.offset\n if (offset === null || typeof offset !== 'object') return { x: fallback.x, y: fallback.y }\n const x = component(offset, 'x', fallback.x)\n const y = component(offset, 'y', fallback.y)\n if (Reflect.get(offset, 'x') === x && Reflect.get(offset, 'y') === y) return null\n return { x, y }\n}\n\nfunction isStoredShadow(effect: ShadowInput): effect is ShadowEffect {\n const offset = effect.offset\n return (\n !!offset &&\n typeof offset.x === 'number' &&\n Number.isFinite(offset.x) &&\n typeof offset.y === 'number' &&\n Number.isFinite(offset.y)\n )\n}\n\n/** An effect that carries geometry of its own, which has to be finite to render. */\nfunction isOffsetEffect(effect: EffectInput): effect is ShadowInput {\n return effect.type !== 'SHADER' && effect.type !== 'NOISE' && effect.type !== 'TEXTURE'\n}\n\nfunction withFiniteOffset(effect: ShadowInput): Effect {\n const offset = finiteOffset(effect)\n if (!offset) {\n if (isStoredShadow(effect)) return effect\n return { ...effect, offset: fallbackOffset(effect.type) }\n }\n return { ...effect, offset }\n}\n\nfunction isStoredEffect(effect: EffectInput): effect is Effect {\n return !isOffsetEffect(effect) || isStoredShadow(effect)\n}\n\n/**\n * Shadows and blurs keep a finite offset. A drop or inner shadow missing one uses `{x: 0, y: 4}`,\n * the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader, noise,\n * and texture effects carry no offset and are left alone. An array that is already valid is\n * returned as itself.\n */\nexport function normalizeEffects(effects: EffectInput[]): Effect[] {\n let next: Effect[] | null = null\n for (const [index, effect] of effects.entries()) {\n const normalized = isOffsetEffect(effect) ? withFiniteOffset(effect) : effect\n if (normalized === effect) {\n if (next && isStoredEffect(effect)) next.push(effect)\n continue\n }\n next ??= effects.slice(0, index).filter(isStoredEffect)\n next.push(normalized)\n }\n if (next) return next\n if (effects.every(isStoredEffect)) return effects\n return effects.filter(isStoredEffect)\n}\n"],"mappings":";AAGA,MAAM,gBAAwB;CAAE,GAAG;CAAG,GAAG;AAAE;AAC3C,MAAM,cAAsB;CAAE,GAAG;CAAG,GAAG;AAAE;AAUzC,SAAS,eAAe,MAAoC;CAC1D,OAAO,SAAS,iBAAiB,SAAS,iBAAiB,gBAAgB;AAC7E;AAEA,SAAS,UAAU,QAAgB,KAAgB,UAA0B;CAC3E,IAAI,EAAE,OAAO,SAAS,OAAO;CAC7B,MAAM,QAAiB,QAAQ,IAAI,QAAQ,GAAG;CAC9C,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ;AACvE;;AAGA,SAAS,aAAa,QAAoC;CACxD,MAAM,WAAW,eAAe,OAAO,IAAI;CAC3C,MAAM,SAAkB,OAAO;CAC/B,IAAI,WAAW,QAAQ,OAAO,WAAW,UAAU,OAAO;EAAE,GAAG,SAAS;EAAG,GAAG,SAAS;CAAE;CACzF,MAAM,IAAI,UAAU,QAAQ,KAAK,SAAS,CAAC;CAC3C,MAAM,IAAI,UAAU,QAAQ,KAAK,SAAS,CAAC;CAC3C,IAAI,QAAQ,IAAI,QAAQ,GAAG,MAAM,KAAK,QAAQ,IAAI,QAAQ,GAAG,MAAM,GAAG,OAAO;CAC7E,OAAO;EAAE;EAAG;CAAE;AAChB;AAEA,SAAS,eAAe,QAA6C;CACnE,MAAM,SAAS,OAAO;CACtB,OACE,CAAC,CAAC,UACF,OAAO,OAAO,MAAM,YACpB,OAAO,SAAS,OAAO,CAAC,KACxB,OAAO,OAAO,MAAM,YACpB,OAAO,SAAS,OAAO,CAAC;AAE5B;;AAGA,SAAS,eAAe,QAA4C;CAClE,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS,WAAW,OAAO,SAAS;AAChF;AAEA,SAAS,iBAAiB,QAA6B;CACrD,MAAM,SAAS,aAAa,MAAM;CAClC,IAAI,CAAC,QAAQ;EACX,IAAI,eAAe,MAAM,GAAG,OAAO;EACnC,OAAO;GAAE,GAAG;GAAQ,QAAQ,eAAe,OAAO,IAAI;EAAE;CAC1D;CACA,OAAO;EAAE,GAAG;EAAQ;CAAO;AAC7B;AAEA,SAAS,eAAe,QAAuC;CAC7D,OAAO,CAAC,eAAe,MAAM,KAAK,eAAe,MAAM;AACzD;;;;;;;AAQA,SAAgB,iBAAiB,SAAkC;CACjE,IAAI,OAAwB;CAC5B,KAAK,MAAM,CAAC,OAAO,WAAW,QAAQ,QAAQ,GAAG;EAC/C,MAAM,aAAa,eAAe,MAAM,IAAI,iBAAiB,MAAM,IAAI;EACvE,IAAI,eAAe,QAAQ;GACzB,IAAI,QAAQ,eAAe,MAAM,GAAG,KAAK,KAAK,MAAM;GACpD;EACF;EACA,SAAS,QAAQ,MAAM,GAAG,KAAK,CAAC,CAAC,OAAO,cAAc;EACtD,KAAK,KAAK,UAAU;CACtB;CACA,IAAI,MAAM,OAAO;CACjB,IAAI,QAAQ,MAAM,cAAc,GAAG,OAAO;CAC1C,OAAO,QAAQ,OAAO,cAAc;AACtC"}
@@ -0,0 +1,102 @@
1
+ import { EMPTY_INSTANCE_OVERRIDES, isEmptyInstanceOverrideState } from "./instances/overrides.js";
2
+ import { isEmptyObject, isPlainObject } from "es-toolkit";
3
+ //#region src/empty-values.ts
4
+ /**
5
+ * The empty list and record every layer holds until a field gets a value of its own. All layers
6
+ * share them, so they are frozen: a field is replaced, never written into, and a write into one
7
+ * throws instead of reaching every layer of every document.
8
+ */
9
+ const EMPTY_LIST = Object.freeze([]);
10
+ const EMPTY_RECORD = Object.freeze({});
11
+ /** The child list is the graph's to grow in place, so every layer keeps its own. */
12
+ const OWN_LIST_FIELDS = /* @__PURE__ */ new Set(["childIds"]);
13
+ /** Fields keyed by name, such as bindings and property values, that start empty. */
14
+ const RECORD_FIELDS = /* @__PURE__ */ new Set([
15
+ "componentPropertyAssignments",
16
+ "componentPropertyValues",
17
+ "boundVariables",
18
+ "variableBindingScales",
19
+ "variableAssignmentScales",
20
+ "variableModes"
21
+ ]);
22
+ const SOURCE_LIST_FIELDS = ["editedFields"];
23
+ const FIG_SOURCE_LIST_FIELDS = [
24
+ "symbolOverrides",
25
+ "componentPropAssignments",
26
+ "derivedSymbolData"
27
+ ];
28
+ function sharedEmptyList(value) {
29
+ return Array.isArray(value) && value.length === 0 ? EMPTY_LIST : value;
30
+ }
31
+ function sharedEmptyRecord(value) {
32
+ return isPlainObject(value) && isEmptyObject(value) ? EMPTY_RECORD : value;
33
+ }
34
+ function sharedEmptyValue(field, value) {
35
+ if (field === "instanceOverrides") return sharedEmptyOverrideState(value);
36
+ if (Array.isArray(value)) return OWN_LIST_FIELDS.has(field) ? value : sharedEmptyList(value);
37
+ return RECORD_FIELDS.has(field) ? sharedEmptyRecord(value) : value;
38
+ }
39
+ /** An override state with nothing in it, so a layer that cleared its overrides shares the empty one. */
40
+ function sharedEmptyOverrideState(value) {
41
+ if (!isPlainObject(value)) return value;
42
+ const { self, descendants } = value;
43
+ if (!(self instanceof Map) || !(descendants instanceof Map)) return value;
44
+ return isEmptyInstanceOverrideState(value) ? EMPTY_INSTANCE_OVERRIDES : value;
45
+ }
46
+ /**
47
+ * `record` with the empty lists among `lists` and the empty record at `recordField` swapped for
48
+ * the shared ones: a copy when anything changes, so the caller's object is never written into.
49
+ * A field the record lacks stays absent.
50
+ */
51
+ function withSharedEmpties(record, lists, recordField) {
52
+ const fields = lists.map((field) => [field, sharedEmptyList]);
53
+ if (recordField !== void 0) fields.push([recordField, sharedEmptyRecord]);
54
+ let copy = null;
55
+ for (const [field, shared] of fields) {
56
+ if (!Object.hasOwn(record, field)) continue;
57
+ const value = Reflect.get(record, field);
58
+ const next = shared(value);
59
+ if (next === value) continue;
60
+ copy ??= { ...record };
61
+ Reflect.set(copy, field, next);
62
+ }
63
+ return copy ?? record;
64
+ }
65
+ /**
66
+ * Source metadata with its empty lists and raw fields swapped for the shared ones. The metadata
67
+ * object and its `fig` part stay the layer's own, since readers and edits write their scalars in
68
+ * place; metadata missing parts, as libraries and plugins may give, is kept as given.
69
+ */
70
+ function withSharedEmptySource(source) {
71
+ const outer = withSharedEmpties(source, SOURCE_LIST_FIELDS);
72
+ const fig = Reflect.get(source, "fig");
73
+ if (!isPlainObject(fig)) return outer;
74
+ const sharedFig = withSharedEmpties(fig, FIG_SOURCE_LIST_FIELDS, "rawNodeFields");
75
+ if (sharedFig === fig) return outer;
76
+ return {
77
+ ...outer,
78
+ fig: {
79
+ ...source.fig,
80
+ ...sharedFig
81
+ }
82
+ };
83
+ }
84
+ /**
85
+ * Swap the `fields` of `node` that hold an empty list or record, its source metadata's included,
86
+ * for the shared ones. Writing known keys keeps the shape every layer shares.
87
+ */
88
+ function shareEmptyNodeValues(node, fields) {
89
+ for (const field of fields) {
90
+ const value = Reflect.get(node, field);
91
+ if (field === "source") {
92
+ if (isPlainObject(value)) node.source = withSharedEmptySource(node.source);
93
+ continue;
94
+ }
95
+ const shared = sharedEmptyValue(field, value);
96
+ if (shared !== value) Reflect.set(node, field, shared);
97
+ }
98
+ }
99
+ //#endregion
100
+ export { EMPTY_LIST, EMPTY_RECORD, shareEmptyNodeValues };
101
+
102
+ //# sourceMappingURL=empty-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-values.js","names":[],"sources":["../src/empty-values.ts"],"sourcesContent":["import { isEmptyObject, isPlainObject } from 'es-toolkit'\n\nimport {\n EMPTY_INSTANCE_OVERRIDES,\n isEmptyInstanceOverrideState,\n type InstanceOverrideState\n} from './instances/overrides'\nimport type { SceneNode, SourceMetadata } from './types'\n\n/**\n * The empty list and record every layer holds until a field gets a value of its own. All layers\n * share them, so they are frozen: a field is replaced, never written into, and a write into one\n * throws instead of reaching every layer of every document.\n */\nexport const EMPTY_LIST: never[] = Object.freeze<never[]>([]) as never[]\nexport const EMPTY_RECORD: Record<string, never> = Object.freeze({})\n\n/** The child list is the graph's to grow in place, so every layer keeps its own. */\nconst OWN_LIST_FIELDS: ReadonlySet<string> = new Set<keyof SceneNode>(['childIds'])\n\n/** Fields keyed by name, such as bindings and property values, that start empty. */\nconst RECORD_FIELDS: ReadonlySet<string> = new Set<keyof SceneNode>([\n 'componentPropertyAssignments',\n 'componentPropertyValues',\n 'boundVariables',\n 'variableBindingScales',\n 'variableAssignmentScales',\n 'variableModes'\n])\n\nconst SOURCE_LIST_FIELDS = ['editedFields'] as const\nconst FIG_SOURCE_LIST_FIELDS = [\n 'symbolOverrides',\n 'componentPropAssignments',\n 'derivedSymbolData'\n] as const\n\nfunction sharedEmptyList(value: unknown): unknown {\n return Array.isArray(value) && value.length === 0 ? EMPTY_LIST : value\n}\n\nfunction sharedEmptyRecord(value: unknown): unknown {\n return isPlainObject(value) && isEmptyObject(value) ? EMPTY_RECORD : value\n}\n\nfunction sharedEmptyValue(field: string, value: unknown): unknown {\n if (field === 'instanceOverrides') return sharedEmptyOverrideState(value)\n if (Array.isArray(value)) return OWN_LIST_FIELDS.has(field) ? value : sharedEmptyList(value)\n return RECORD_FIELDS.has(field) ? sharedEmptyRecord(value) : value\n}\n\n/** An override state with nothing in it, so a layer that cleared its overrides shares the empty one. */\nfunction sharedEmptyOverrideState(value: unknown): unknown {\n if (!isPlainObject(value)) return value\n const { self, descendants } = value as Partial<InstanceOverrideState>\n if (!(self instanceof Map) || !(descendants instanceof Map)) return value\n return isEmptyInstanceOverrideState(value as InstanceOverrideState)\n ? EMPTY_INSTANCE_OVERRIDES\n : value\n}\n\n/**\n * `record` with the empty lists among `lists` and the empty record at `recordField` swapped for\n * the shared ones: a copy when anything changes, so the caller's object is never written into.\n * A field the record lacks stays absent.\n */\nfunction withSharedEmpties<T extends object>(\n record: T,\n lists: readonly string[],\n recordField?: string\n): T {\n const fields: [string, (value: unknown) => unknown][] = lists.map((field) => [\n field,\n sharedEmptyList\n ])\n if (recordField !== undefined) fields.push([recordField, sharedEmptyRecord])\n let copy: T | null = null\n for (const [field, shared] of fields) {\n if (!Object.hasOwn(record, field)) continue\n const value: unknown = Reflect.get(record, field)\n const next = shared(value)\n if (next === value) continue\n copy ??= { ...record }\n Reflect.set(copy, field, next)\n }\n return copy ?? record\n}\n\n/**\n * Source metadata with its empty lists and raw fields swapped for the shared ones. The metadata\n * object and its `fig` part stay the layer's own, since readers and edits write their scalars in\n * place; metadata missing parts, as libraries and plugins may give, is kept as given.\n */\nfunction withSharedEmptySource(source: SourceMetadata): SourceMetadata {\n const outer = withSharedEmpties(source, SOURCE_LIST_FIELDS)\n const fig: unknown = Reflect.get(source, 'fig')\n if (!isPlainObject(fig)) return outer\n const sharedFig = withSharedEmpties(fig, FIG_SOURCE_LIST_FIELDS, 'rawNodeFields')\n if (sharedFig === fig) return outer\n return { ...outer, fig: { ...source.fig, ...sharedFig } }\n}\n\n/**\n * Swap the `fields` of `node` that hold an empty list or record, its source metadata's included,\n * for the shared ones. Writing known keys keeps the shape every layer shares.\n */\nexport function shareEmptyNodeValues(node: SceneNode, fields: Iterable<string>): void {\n for (const field of fields) {\n const value: unknown = Reflect.get(node, field)\n if (field === 'source') {\n if (isPlainObject(value)) node.source = withSharedEmptySource(node.source)\n continue\n }\n const shared = sharedEmptyValue(field, value)\n if (shared !== value) Reflect.set(node, field, shared)\n }\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,aAAsB,OAAO,OAAgB,CAAC,CAAC;AAC5D,MAAa,eAAsC,OAAO,OAAO,CAAC,CAAC;;AAGnE,MAAM,kCAAuC,IAAI,IAAqB,CAAC,UAAU,CAAC;;AAGlF,MAAM,gCAAqC,IAAI,IAAqB;CAClE;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,qBAAqB,CAAC,cAAc;AAC1C,MAAM,yBAAyB;CAC7B;CACA;CACA;AACF;AAEA,SAAS,gBAAgB,OAAyB;CAChD,OAAO,MA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;CAChC,MAAM,YAAY,kBAAkB,KAAK,wBAAwB,eAAe;CAChF,IAAI,cAAc,KAAK,OAAO;CAC9B,OAAO;EAAE,GAAG;EAAO,KAAK;GAAE,GAAG,OAAO;GAAK,GAAG;EAAU;CAAE;AAC1D;;;;;AAMA,SAAgB,qBAAqB,MAAiB,QAAgC;CACpF,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,QAAiB,QAAQ,IAAI,MAAM,KAAK;EAC9C,IAAI,UAAU,UAAU;GACtB,IAAI,cAAc,KAAK,GAAG,KAAK,SAAS,sBAAsB,KAAK,MAAM;GACzE;EACF;EACA,MAAM,SAAS,iBAAiB,OAAO,KAAK;EAC5C,IAAI,WAAW,OAAO,QAAQ,IAAI,MAAM,OAAO,MAAM;CACvD;AACF"}
@@ -0,0 +1,9 @@
1
+ //#region src/fields/components.d.ts
2
+ /**
3
+ * What makes a layer a main component beyond its type: its key, its properties and variant
4
+ * specs, and how it is published to libraries.
5
+ */
6
+ declare const MAIN_COMPONENT_FIELDS: readonly ["componentKey", "componentPropertyDefinitions", "variantPropSpecs", "sourceLibraryKey", "publishId", "overrideKey", "sharedSymbolVersion", "publishedVersion", "librarySource", "isPublishable", "isSymbolPublishable", "symbolDescription", "symbolLinks"];
7
+ //#endregion
8
+ export { MAIN_COMPONENT_FIELDS };
9
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","names":[],"sources":["../../src/fields/components.ts"],"mappings":";;;;;cAMa"}
@@ -0,0 +1,24 @@
1
+ //#region src/fields/components.ts
2
+ /**
3
+ * What makes a layer a main component beyond its type: its key, its properties and variant
4
+ * specs, and how it is published to libraries.
5
+ */
6
+ const MAIN_COMPONENT_FIELDS = [
7
+ "componentKey",
8
+ "componentPropertyDefinitions",
9
+ "variantPropSpecs",
10
+ "sourceLibraryKey",
11
+ "publishId",
12
+ "overrideKey",
13
+ "sharedSymbolVersion",
14
+ "publishedVersion",
15
+ "librarySource",
16
+ "isPublishable",
17
+ "isSymbolPublishable",
18
+ "symbolDescription",
19
+ "symbolLinks"
20
+ ];
21
+ //#endregion
22
+ export { MAIN_COMPONENT_FIELDS };
23
+
24
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","names":[],"sources":["../../src/fields/components.ts"],"sourcesContent":["import type { SceneNode } from '../types'\n\n/**\n * What makes a layer a main component beyond its type: its key, its properties and variant\n * specs, and how it is published to libraries.\n */\nexport const MAIN_COMPONENT_FIELDS = [\n 'componentKey',\n 'componentPropertyDefinitions',\n 'variantPropSpecs',\n 'sourceLibraryKey',\n 'publishId',\n 'overrideKey',\n 'sharedSymbolVersion',\n 'publishedVersion',\n 'librarySource',\n 'isPublishable',\n 'isSymbolPublishable',\n 'symbolDescription',\n 'symbolLinks'\n] as const satisfies readonly (keyof SceneNode)[]\n"],"mappings":";;;;;AAMA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { CORNER_FIELDS, PAINT_FIELDS, STROKE_FIELDS } from "./appearance.js";
2
+ import { MAIN_COMPONENT_FIELDS } from "./components.js";
2
3
  import { SIZE_FIELDS, TRANSFORM_FIELDS } from "./geometry.js";
3
- import { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, SIZE_CONSTRAINT_FIELDS } from "./layout.js";
4
+ import { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS } from "./layout.js";
4
5
  import { TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS } from "./text.js";
5
- export { AUTO_LAYOUT_FIELDS, CORNER_FIELDS, LAYOUT_AFFECTING_KEYS, PAINT_FIELDS, SIZE_CONSTRAINT_FIELDS, SIZE_FIELDS, STROKE_FIELDS, TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS, TRANSFORM_FIELDS };
6
+ export { AUTO_LAYOUT_FIELDS, CORNER_FIELDS, LAYOUT_AFFECTING_KEYS, MAIN_COMPONENT_FIELDS, PAINT_FIELDS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS, SIZE_FIELDS, STROKE_FIELDS, TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS, TRANSFORM_FIELDS };
@@ -1,5 +1,6 @@
1
1
  import { SIZE_FIELDS, TRANSFORM_FIELDS } from "./geometry.js";
2
- import { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, SIZE_CONSTRAINT_FIELDS } from "./layout.js";
2
+ import { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS } from "./layout.js";
3
3
  import { TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS } from "./text.js";
4
4
  import { CORNER_FIELDS, PAINT_FIELDS, STROKE_FIELDS } from "./appearance.js";
5
- export { AUTO_LAYOUT_FIELDS, CORNER_FIELDS, LAYOUT_AFFECTING_KEYS, PAINT_FIELDS, SIZE_CONSTRAINT_FIELDS, SIZE_FIELDS, STROKE_FIELDS, TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS, TRANSFORM_FIELDS };
5
+ import { MAIN_COMPONENT_FIELDS } from "./components.js";
6
+ export { AUTO_LAYOUT_FIELDS, CORNER_FIELDS, LAYOUT_AFFECTING_KEYS, MAIN_COMPONENT_FIELDS, PAINT_FIELDS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS, SIZE_FIELDS, STROKE_FIELDS, TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS, TRANSFORM_FIELDS };
@@ -1,10 +1,12 @@
1
1
  //#region src/fields/layout.d.ts
2
2
  /** How a frame lays out its children: auto layout and its grid tracks. */
3
3
  declare const AUTO_LAYOUT_FIELDS: readonly ["layoutMode", "layoutDirection", "layoutWrap", "primaryAxisAlign", "counterAxisAlign", "counterAxisAlignContent", "primaryAxisSizing", "counterAxisSizing", "itemSpacing", "counterAxisSpacing", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "strokesIncludedInLayout", "gridTemplateColumns", "gridTemplateRows", "gridColumnGap", "gridRowGap"];
4
+ /** How a layer sits in its parent: its constraints and its place in an auto layout or grid. */
5
+ declare const PARENT_LAYOUT_FIELDS: readonly ["horizontalConstraint", "verticalConstraint", "layoutPositioning", "layoutGrow", "layoutAlignSelf", "gridPosition"];
4
6
  /** Size limits a layer keeps however it is resized. */
5
7
  declare const SIZE_CONSTRAINT_FIELDS: readonly ["minWidth", "maxWidth", "minHeight", "maxHeight", "targetAspectRatio"];
6
8
  /** Fields whose change moves a layer or its children, so cached absolute positions go stale. */
7
9
  declare const LAYOUT_AFFECTING_KEYS: ReadonlySet<string>;
8
10
  //#endregion
9
- export { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, SIZE_CONSTRAINT_FIELDS };
11
+ export { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS };
10
12
  //# sourceMappingURL=layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","names":[],"sources":["../../src/fields/layout.ts"],"mappings":";;cAIa;;cAuBA;;cASA,uBAAuB"}
1
+ {"version":3,"file":"layout.d.ts","names":[],"sources":["../../src/fields/layout.ts"],"mappings":";;cAIa;;cAuBA;;cAUA;;cASA,uBAAuB"}
@@ -22,6 +22,15 @@ const AUTO_LAYOUT_FIELDS = [
22
22
  "gridColumnGap",
23
23
  "gridRowGap"
24
24
  ];
25
+ /** How a layer sits in its parent: its constraints and its place in an auto layout or grid. */
26
+ const PARENT_LAYOUT_FIELDS = [
27
+ "horizontalConstraint",
28
+ "verticalConstraint",
29
+ "layoutPositioning",
30
+ "layoutGrow",
31
+ "layoutAlignSelf",
32
+ "gridPosition"
33
+ ];
25
34
  /** Size limits a layer keeps however it is resized. */
26
35
  const SIZE_CONSTRAINT_FIELDS = [
27
36
  "minWidth",
@@ -44,6 +53,6 @@ const LAYOUT_AFFECTING_KEYS = /* @__PURE__ */ new Set([
44
53
  ...SIZE_CONSTRAINT_FIELDS
45
54
  ]);
46
55
  //#endregion
47
- export { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, SIZE_CONSTRAINT_FIELDS };
56
+ export { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS };
48
57
 
49
58
  //# sourceMappingURL=layout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","names":[],"sources":["../../src/fields/layout.ts"],"sourcesContent":["import type { SceneNode } from '../types'\nimport { SIZE_FIELDS, TRANSFORM_FIELDS } from './geometry'\n\n/** How a frame lays out its children: auto layout and its grid tracks. */\nexport const AUTO_LAYOUT_FIELDS = [\n 'layoutMode',\n 'layoutDirection',\n 'layoutWrap',\n 'primaryAxisAlign',\n 'counterAxisAlign',\n 'counterAxisAlignContent',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'strokesIncludedInLayout',\n 'gridTemplateColumns',\n 'gridTemplateRows',\n 'gridColumnGap',\n 'gridRowGap'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** Size limits a layer keeps however it is resized. */\nexport const SIZE_CONSTRAINT_FIELDS = [\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'targetAspectRatio'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** Fields whose change moves a layer or its children, so cached absolute positions go stale. */\nexport const LAYOUT_AFFECTING_KEYS: ReadonlySet<string> = new Set([\n ...TRANSFORM_FIELDS,\n ...SIZE_FIELDS,\n ...AUTO_LAYOUT_FIELDS,\n 'layoutPositioning',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'horizontalConstraint',\n 'verticalConstraint',\n 'gridPosition',\n ...SIZE_CONSTRAINT_FIELDS\n])\n"],"mappings":";;;AAIA,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,wCAA6C,IAAI,IAAI;CAChE,GAAG;CACH,GAAG;CACH,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA,GAAG;AACL,CAAC"}
1
+ {"version":3,"file":"layout.js","names":[],"sources":["../../src/fields/layout.ts"],"sourcesContent":["import type { SceneNode } from '../types'\nimport { SIZE_FIELDS, TRANSFORM_FIELDS } from './geometry'\n\n/** How a frame lays out its children: auto layout and its grid tracks. */\nexport const AUTO_LAYOUT_FIELDS = [\n 'layoutMode',\n 'layoutDirection',\n 'layoutWrap',\n 'primaryAxisAlign',\n 'counterAxisAlign',\n 'counterAxisAlignContent',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'strokesIncludedInLayout',\n 'gridTemplateColumns',\n 'gridTemplateRows',\n 'gridColumnGap',\n 'gridRowGap'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** How a layer sits in its parent: its constraints and its place in an auto layout or grid. */\nexport const PARENT_LAYOUT_FIELDS = [\n 'horizontalConstraint',\n 'verticalConstraint',\n 'layoutPositioning',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'gridPosition'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** Size limits a layer keeps however it is resized. */\nexport const SIZE_CONSTRAINT_FIELDS = [\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'targetAspectRatio'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** Fields whose change moves a layer or its children, so cached absolute positions go stale. */\nexport const LAYOUT_AFFECTING_KEYS: ReadonlySet<string> = new Set([\n ...TRANSFORM_FIELDS,\n ...SIZE_FIELDS,\n ...AUTO_LAYOUT_FIELDS,\n 'layoutPositioning',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'horizontalConstraint',\n 'verticalConstraint',\n 'gridPosition',\n ...SIZE_CONSTRAINT_FIELDS\n])\n"],"mappings":";;;AAIA,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,wCAA6C,IAAI,IAAI;CAChE,GAAG;CACH,GAAG;CACH,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA,GAAG;AACL,CAAC"}
package/dist/graph.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BufferedSceneEmitter } from "./buffered-events.js";
2
2
  import { NodeCloneMode } from "./copy.js";
3
3
  import { Color, Rect, Vector } from "./primitives/index.js";
4
- import { DropTargetOptions } from "./hit-test.js";
4
+ import { DropTargetOptions } from "./hit-test/drop.js";
5
5
  import { SwapInstanceOptions } from "./instances/index.js";
6
6
  import { NodePreviewObserver } from "./preview.js";
7
7
  import { VariableModeFallback } from "./variables/resolution.js";
@@ -94,6 +94,10 @@ declare class SceneGraph {
94
94
  resolveStringVariableForNode(nodeId: string, variableId: string, fallback?: VariableModeFallback): string | undefined;
95
95
  getVariablesForCollection(collectionId: string): Variable[];
96
96
  getVariablesByType(type: VariableType): Variable[];
97
+ /** Every variable but the deleted ones, which only their bindings still reach. */
98
+ getLiveVariables(): Variable[];
99
+ /** Every collection but the deleted ones. */
100
+ getLiveCollections(): VariableCollection[];
97
101
  bindVariable(nodeId: string, field: string, variableId: string): void;
98
102
  unbindVariable(nodeId: string, field: string): void;
99
103
  getChildren(id: string): SceneNode[];
@@ -196,6 +200,13 @@ declare class SceneGraph {
196
200
  */
197
201
  insertChildAt(childId: string, parentId: string, index: number): void;
198
202
  deleteNode(id: string): void;
203
+ /**
204
+ * Deletes `node` and its layers, children first. Their parent goes with them, so its child
205
+ * list is emptied once instead of being filtered for each child, which kept deleting a frame
206
+ * of thousands of layers quadratic. The list is emptied before the children go, so a listener
207
+ * of a child's deletion never finds it still listed.
208
+ */
209
+ private deleteSubtree;
199
210
  hitTest(px: number, py: number, scopeId?: string): SceneNode | null;
200
211
  /** `pad`, in canvas units, grows each shape's box, as Figma takes clicks just outside one. */
201
212
  hitTestDeep(px: number, py: number, scopeId?: string, pad?: number): SceneNode | null;
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","names":[],"sources":["../src/graph.ts"],"mappings":";;;;;;;;;cA4Da;mBAuCkB;EAtC7B,OAAK,YAAA;EACL,QAAM,YAAA,WAAA;EACN,WAAS,YAAA;EACT,qBAAmB,YAAA;EACnB,YAAU;EACV;EACA;;EAEA,mBAAmB;EACnB,oBAAoB;EACpB,cAAc;EACd,kBAAgB,YAAA;WACP,SAAO;UACR;mBACS;UAQT;;UAEA;mBACS;mBAGA;;mBAEA;UACT;UACA;EACR;EACA,eAAa,YAAA;;EAEb,cAAY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