@moondraft/import 0.0.0-stage → 0.2.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 (337) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE +34 -0
  3. package/README.md +36 -2
  4. package/SOURCE.md +394 -0
  5. package/dist/adapter/convert.d.ts +144 -0
  6. package/dist/adapter/convert.js +2811 -0
  7. package/dist/adapter/figma-descriptions.d.ts +7 -0
  8. package/dist/adapter/figma-descriptions.js +34 -0
  9. package/dist/adapter/figma-grids.d.ts +12 -0
  10. package/dist/adapter/figma-grids.js +175 -0
  11. package/dist/adapter/figma-handoff.d.ts +12 -0
  12. package/dist/adapter/figma-handoff.js +167 -0
  13. package/dist/adapter/figma-hyperlinks.d.ts +13 -0
  14. package/dist/adapter/figma-hyperlinks.js +77 -0
  15. package/dist/adapter/figma.d.ts +12 -0
  16. package/dist/adapter/figma.js +40 -0
  17. package/dist/adapter/file-components.d.ts +20 -0
  18. package/dist/adapter/file-components.js +352 -0
  19. package/dist/adapter/file-resources.d.ts +29 -0
  20. package/dist/adapter/file-resources.js +851 -0
  21. package/dist/adapter/image-crop.d.ts +18 -0
  22. package/dist/adapter/image-crop.js +30 -0
  23. package/dist/adapter/index.d.ts +6 -0
  24. package/dist/adapter/index.js +9 -0
  25. package/dist/adapter/link.d.ts +49 -0
  26. package/dist/adapter/link.js +892 -0
  27. package/dist/adapter/payload.d.ts +31 -0
  28. package/dist/adapter/payload.js +78 -0
  29. package/dist/adapter/shapes.d.ts +31 -0
  30. package/dist/adapter/shapes.js +75 -0
  31. package/dist/adapter/variables.d.ts +45 -0
  32. package/dist/adapter/variables.js +106 -0
  33. package/dist/figma-file.d.ts +38 -0
  34. package/dist/figma-file.js +97 -0
  35. package/dist/figma-worker.d.ts +11 -0
  36. package/dist/figma-worker.js +12 -0
  37. package/dist/figma.d.ts +26 -0
  38. package/dist/figma.js +230 -0
  39. package/dist/index.d.ts +29 -0
  40. package/dist/index.js +50 -0
  41. package/dist/report.d.ts +42 -0
  42. package/dist/report.js +142 -0
  43. package/dist/serialize.d.ts +7 -0
  44. package/dist/serialize.js +79 -0
  45. package/dist/svg.d.ts +33 -0
  46. package/dist/svg.js +44 -0
  47. package/dist/syntax.d.ts +8 -0
  48. package/dist/syntax.js +19 -0
  49. package/dist/taco/figma-import/clipboard.d.ts +25 -0
  50. package/dist/taco/figma-import/clipboard.js +87 -0
  51. package/dist/taco/figma-import/clipboardSize.d.ts +31 -0
  52. package/dist/taco/figma-import/clipboardSize.js +107 -0
  53. package/dist/taco/figma-import/container/compression.d.ts +9 -0
  54. package/dist/taco/figma-import/container/compression.js +174 -0
  55. package/dist/taco/figma-import/container/error.d.ts +15 -0
  56. package/dist/taco/figma-import/container/error.js +19 -0
  57. package/dist/taco/figma-import/container/kiwiContainer.d.ts +41 -0
  58. package/dist/taco/figma-import/container/kiwiContainer.js +61 -0
  59. package/dist/taco/figma-import/container/limits.d.ts +22 -0
  60. package/dist/taco/figma-import/container/limits.js +22 -0
  61. package/dist/taco/figma-import/container/zip.d.ts +14 -0
  62. package/dist/taco/figma-import/container/zip.js +154 -0
  63. package/dist/taco/figma-import/figFile.d.ts +34 -0
  64. package/dist/taco/figma-import/figFile.js +91 -0
  65. package/dist/taco/figma-import/figFileDocument.d.ts +25 -0
  66. package/dist/taco/figma-import/figFileDocument.js +100 -0
  67. package/dist/taco/figma-import/import/blobs.d.ts +10 -0
  68. package/dist/taco/figma-import/import/blobs.js +23 -0
  69. package/dist/taco/figma-import/import/carry.d.ts +24 -0
  70. package/dist/taco/figma-import/import/carry.js +66 -0
  71. package/dist/taco/figma-import/import/componentProps.d.ts +90 -0
  72. package/dist/taco/figma-import/import/componentProps.js +329 -0
  73. package/dist/taco/figma-import/import/componentSets.d.ts +85 -0
  74. package/dist/taco/figma-import/import/componentSets.js +647 -0
  75. package/dist/taco/figma-import/import/converters/effects.d.ts +31 -0
  76. package/dist/taco/figma-import/import/converters/effects.js +127 -0
  77. package/dist/taco/figma-import/import/converters/ellipse.d.ts +7 -0
  78. package/dist/taco/figma-import/import/converters/ellipse.js +54 -0
  79. package/dist/taco/figma-import/import/converters/exportSettings.d.ts +4 -0
  80. package/dist/taco/figma-import/import/converters/exportSettings.js +49 -0
  81. package/dist/taco/figma-import/import/converters/frame.d.ts +21 -0
  82. package/dist/taco/figma-import/import/converters/frame.js +63 -0
  83. package/dist/taco/figma-import/import/converters/gradient.d.ts +74 -0
  84. package/dist/taco/figma-import/import/converters/gradient.js +108 -0
  85. package/dist/taco/figma-import/import/converters/group.d.ts +19 -0
  86. package/dist/taco/figma-import/import/converters/group.js +30 -0
  87. package/dist/taco/figma-import/import/converters/image.d.ts +13 -0
  88. package/dist/taco/figma-import/import/converters/image.js +94 -0
  89. package/dist/taco/figma-import/import/converters/layout.d.ts +33 -0
  90. package/dist/taco/figma-import/import/converters/layout.js +187 -0
  91. package/dist/taco/figma-import/import/converters/line.d.ts +11 -0
  92. package/dist/taco/figma-import/import/converters/line.js +40 -0
  93. package/dist/taco/figma-import/import/converters/rectangle.d.ts +3 -0
  94. package/dist/taco/figma-import/import/converters/rectangle.js +11 -0
  95. package/dist/taco/figma-import/import/converters/section.d.ts +8 -0
  96. package/dist/taco/figma-import/import/converters/section.js +29 -0
  97. package/dist/taco/figma-import/import/converters/shared.d.ts +71 -0
  98. package/dist/taco/figma-import/import/converters/shared.js +372 -0
  99. package/dist/taco/figma-import/import/converters/text.d.ts +54 -0
  100. package/dist/taco/figma-import/import/converters/text.js +707 -0
  101. package/dist/taco/figma-import/import/converters/vector.d.ts +105 -0
  102. package/dist/taco/figma-import/import/converters/vector.js +609 -0
  103. package/dist/taco/figma-import/import/converters/vectorNetwork.d.ts +114 -0
  104. package/dist/taco/figma-import/import/converters/vectorNetwork.js +503 -0
  105. package/dist/taco/figma-import/import/fields.d.ts +15 -0
  106. package/dist/taco/figma-import/import/fields.js +29 -0
  107. package/dist/taco/figma-import/import/instances.d.ts +184 -0
  108. package/dist/taco/figma-import/import/instances.js +1530 -0
  109. package/dist/taco/figma-import/import/nestingCycles.d.ts +86 -0
  110. package/dist/taco/figma-import/import/nestingCycles.js +488 -0
  111. package/dist/taco/figma-import/import/slots.d.ts +56 -0
  112. package/dist/taco/figma-import/import/slots.js +96 -0
  113. package/dist/taco/figma-import/import/styles.d.ts +48 -0
  114. package/dist/taco/figma-import/import/styles.js +48 -0
  115. package/dist/taco/figma-import/import/tree.d.ts +66 -0
  116. package/dist/taco/figma-import/import/tree.js +194 -0
  117. package/dist/taco/figma-import/import/types.d.ts +232 -0
  118. package/dist/taco/figma-import/import/types.js +33 -0
  119. package/dist/taco/figma-import/import/variables.d.ts +137 -0
  120. package/dist/taco/figma-import/import/variables.js +769 -0
  121. package/dist/taco/figma-import/import/variantTrees.d.ts +20 -0
  122. package/dist/taco/figma-import/import/variantTrees.js +520 -0
  123. package/dist/taco/figma-import/import/walk.d.ts +207 -0
  124. package/dist/taco/figma-import/import/walk.js +1464 -0
  125. package/dist/taco/figma-import/index.d.ts +22 -0
  126. package/dist/taco/figma-import/index.js +13 -0
  127. package/dist/taco/figma-import/kiwi/byteReader.d.ts +37 -0
  128. package/dist/taco/figma-import/kiwi/byteReader.js +151 -0
  129. package/dist/taco/figma-import/kiwi/error.d.ts +14 -0
  130. package/dist/taco/figma-import/kiwi/error.js +29 -0
  131. package/dist/taco/figma-import/kiwi/limits.d.ts +18 -0
  132. package/dist/taco/figma-import/kiwi/limits.js +18 -0
  133. package/dist/taco/figma-import/kiwi/message.d.ts +12 -0
  134. package/dist/taco/figma-import/kiwi/message.js +147 -0
  135. package/dist/taco/figma-import/kiwi/schema.d.ts +42 -0
  136. package/dist/taco/figma-import/kiwi/schema.js +206 -0
  137. package/dist/taco/figma-import/kiwi/types.d.ts +46 -0
  138. package/dist/taco/figma-import/kiwi/types.js +18 -0
  139. package/dist/taco/model/agent-hidden-fields.d.ts +20 -0
  140. package/dist/taco/model/agent-hidden-fields.js +29 -0
  141. package/dist/taco/model/asset-users.d.ts +23 -0
  142. package/dist/taco/model/asset-users.js +128 -0
  143. package/dist/taco/model/auto-layout-lines.d.ts +32 -0
  144. package/dist/taco/model/auto-layout-lines.js +70 -0
  145. package/dist/taco/model/codec.d.ts +444 -0
  146. package/dist/taco/model/codec.js +5665 -0
  147. package/dist/taco/model/color.d.ts +11 -0
  148. package/dist/taco/model/color.js +61 -0
  149. package/dist/taco/model/comment-operations.d.ts +102 -0
  150. package/dist/taco/model/comment-operations.js +227 -0
  151. package/dist/taco/model/component-evaluation.d.ts +96 -0
  152. package/dist/taco/model/component-evaluation.js +555 -0
  153. package/dist/taco/model/component-expressions.d.ts +242 -0
  154. package/dist/taco/model/component-expressions.js +1082 -0
  155. package/dist/taco/model/component-properties.d.ts +111 -0
  156. package/dist/taco/model/component-properties.js +339 -0
  157. package/dist/taco/model/component-samples.d.ts +83 -0
  158. package/dist/taco/model/component-samples.js +290 -0
  159. package/dist/taco/model/component-validity.d.ts +85 -0
  160. package/dist/taco/model/component-validity.js +397 -0
  161. package/dist/taco/model/components.d.ts +155 -0
  162. package/dist/taco/model/components.js +505 -0
  163. package/dist/taco/model/connector-ends.d.ts +20 -0
  164. package/dist/taco/model/connector-ends.js +188 -0
  165. package/dist/taco/model/connector-geometry.d.ts +74 -0
  166. package/dist/taco/model/connector-geometry.js +293 -0
  167. package/dist/taco/model/corner-radii.d.ts +26 -0
  168. package/dist/taco/model/corner-radii.js +47 -0
  169. package/dist/taco/model/derivations.d.ts +81 -0
  170. package/dist/taco/model/derivations.js +151 -0
  171. package/dist/taco/model/export-settings.d.ts +53 -0
  172. package/dist/taco/model/export-settings.js +156 -0
  173. package/dist/taco/model/expressions/ast.d.ts +153 -0
  174. package/dist/taco/model/expressions/ast.js +6 -0
  175. package/dist/taco/model/expressions/cache.d.ts +23 -0
  176. package/dist/taco/model/expressions/cache.js +43 -0
  177. package/dist/taco/model/expressions/check.d.ts +72 -0
  178. package/dist/taco/model/expressions/check.js +517 -0
  179. package/dist/taco/model/expressions/completion.d.ts +61 -0
  180. package/dist/taco/model/expressions/completion.js +421 -0
  181. package/dist/taco/model/expressions/evaluate.d.ts +32 -0
  182. package/dist/taco/model/expressions/evaluate.js +519 -0
  183. package/dist/taco/model/expressions/forms.d.ts +84 -0
  184. package/dist/taco/model/expressions/forms.js +200 -0
  185. package/dist/taco/model/expressions/index.d.ts +14 -0
  186. package/dist/taco/model/expressions/index.js +17 -0
  187. package/dist/taco/model/expressions/lexer.d.ts +42 -0
  188. package/dist/taco/model/expressions/lexer.js +213 -0
  189. package/dist/taco/model/expressions/library.d.ts +33 -0
  190. package/dist/taco/model/expressions/library.js +117 -0
  191. package/dist/taco/model/expressions/names.d.ts +43 -0
  192. package/dist/taco/model/expressions/names.js +99 -0
  193. package/dist/taco/model/expressions/parser.d.ts +15 -0
  194. package/dist/taco/model/expressions/parser.js +438 -0
  195. package/dist/taco/model/expressions/rename.d.ts +34 -0
  196. package/dist/taco/model/expressions/rename.js +46 -0
  197. package/dist/taco/model/expressions/source.d.ts +15 -0
  198. package/dist/taco/model/expressions/source.js +161 -0
  199. package/dist/taco/model/expressions/types.d.ts +119 -0
  200. package/dist/taco/model/expressions/types.js +102 -0
  201. package/dist/taco/model/expressions/values.d.ts +97 -0
  202. package/dist/taco/model/expressions/values.js +160 -0
  203. package/dist/taco/model/geometry-limits.d.ts +16 -0
  204. package/dist/taco/model/geometry-limits.js +67 -0
  205. package/dist/taco/model/geometry.d.ts +47 -0
  206. package/dist/taco/model/geometry.js +193 -0
  207. package/dist/taco/model/group-bounds.d.ts +38 -0
  208. package/dist/taco/model/group-bounds.js +144 -0
  209. package/dist/taco/model/id-table.d.ts +37 -0
  210. package/dist/taco/model/id-table.js +80 -0
  211. package/dist/taco/model/index.d.ts +25 -0
  212. package/dist/taco/model/index.js +27 -0
  213. package/dist/taco/model/instance-resolver.d.ts +376 -0
  214. package/dist/taco/model/instance-resolver.js +1778 -0
  215. package/dist/taco/model/layer-syntax.d.ts +340 -0
  216. package/dist/taco/model/layer-syntax.js +3506 -0
  217. package/dist/taco/model/layout/constraints.d.ts +84 -0
  218. package/dist/taco/model/layout/constraints.js +445 -0
  219. package/dist/taco/model/layout/frame-layout.d.ts +46 -0
  220. package/dist/taco/model/layout/frame-layout.js +618 -0
  221. package/dist/taco/model/layout/node-sizing.d.ts +163 -0
  222. package/dist/taco/model/layout/node-sizing.js +486 -0
  223. package/dist/taco/model/legacy-connector-caps.d.ts +15 -0
  224. package/dist/taco/model/legacy-connector-caps.js +70 -0
  225. package/dist/taco/model/linear-call.d.ts +48 -0
  226. package/dist/taco/model/linear-call.js +58 -0
  227. package/dist/taco/model/new-nodes.d.ts +145 -0
  228. package/dist/taco/model/new-nodes.js +277 -0
  229. package/dist/taco/model/node-builder.d.ts +449 -0
  230. package/dist/taco/model/node-builder.js +2294 -0
  231. package/dist/taco/model/node-table-watch.d.ts +36 -0
  232. package/dist/taco/model/node-table-watch.js +63 -0
  233. package/dist/taco/model/node-transform.d.ts +39 -0
  234. package/dist/taco/model/node-transform.js +79 -0
  235. package/dist/taco/model/node-users-index.d.ts +10 -0
  236. package/dist/taco/model/node-users-index.js +82 -0
  237. package/dist/taco/model/operation-references.d.ts +80 -0
  238. package/dist/taco/model/operation-references.js +399 -0
  239. package/dist/taco/model/operations.d.ts +610 -0
  240. package/dist/taco/model/operations.js +2882 -0
  241. package/dist/taco/model/overlay-table.d.ts +71 -0
  242. package/dist/taco/model/overlay-table.js +171 -0
  243. package/dist/taco/model/override-remap.d.ts +69 -0
  244. package/dist/taco/model/override-remap.js +230 -0
  245. package/dist/taco/model/parent-table.d.ts +53 -0
  246. package/dist/taco/model/parent-table.js +193 -0
  247. package/dist/taco/model/problem-collector.d.ts +27 -0
  248. package/dist/taco/model/problem-collector.js +101 -0
  249. package/dist/taco/model/sha256.d.ts +10 -0
  250. package/dist/taco/model/sha256.js +79 -0
  251. package/dist/taco/model/shape-geometry.d.ts +96 -0
  252. package/dist/taco/model/shape-geometry.js +368 -0
  253. package/dist/taco/model/shared-node-table.d.ts +97 -0
  254. package/dist/taco/model/shared-node-table.js +546 -0
  255. package/dist/taco/model/slots.d.ts +113 -0
  256. package/dist/taco/model/slots.js +281 -0
  257. package/dist/taco/model/stroke-settings.d.ts +37 -0
  258. package/dist/taco/model/stroke-settings.js +90 -0
  259. package/dist/taco/model/svg-path-import.d.ts +89 -0
  260. package/dist/taco/model/svg-path-import.js +219 -0
  261. package/dist/taco/model/text-measurement.d.ts +142 -0
  262. package/dist/taco/model/text-measurement.js +846 -0
  263. package/dist/taco/model/text-reads.d.ts +66 -0
  264. package/dist/taco/model/text-reads.js +128 -0
  265. package/dist/taco/model/text-sizer.d.ts +358 -0
  266. package/dist/taco/model/text-sizer.js +996 -0
  267. package/dist/taco/model/theme-users.d.ts +59 -0
  268. package/dist/taco/model/theme-users.js +312 -0
  269. package/dist/taco/model/thumbnail.d.ts +15 -0
  270. package/dist/taco/model/thumbnail.js +34 -0
  271. package/dist/taco/model/types.d.ts +2369 -0
  272. package/dist/taco/model/types.js +366 -0
  273. package/dist/taco/model/unknown-property.d.ts +5 -0
  274. package/dist/taco/model/unknown-property.js +7 -0
  275. package/dist/taco/model/validated-documents.d.ts +22 -0
  276. package/dist/taco/model/validated-documents.js +22 -0
  277. package/dist/taco/model/variable-modes.d.ts +61 -0
  278. package/dist/taco/model/variable-modes.js +438 -0
  279. package/dist/taco/model/variable-references.d.ts +54 -0
  280. package/dist/taco/model/variable-references.js +183 -0
  281. package/dist/taco/model/variables.d.ts +24 -0
  282. package/dist/taco/model/variables.js +151 -0
  283. package/dist/taco/model/vector-network.d.ts +34 -0
  284. package/dist/taco/model/vector-network.js +411 -0
  285. package/dist/taco/svg-import/import-svg.d.ts +36 -0
  286. package/dist/taco/svg-import/import-svg.js +729 -0
  287. package/dist/taco/svg-import/index.d.ts +3 -0
  288. package/dist/taco/svg-import/index.js +3 -0
  289. package/dist/taco/svg-import/limits/limits.d.ts +79 -0
  290. package/dist/taco/svg-import/limits/limits.js +160 -0
  291. package/dist/taco/svg-import/paint/gradients.d.ts +64 -0
  292. package/dist/taco/svg-import/paint/gradients.js +429 -0
  293. package/dist/taco/svg-import/paint/paint.d.ts +32 -0
  294. package/dist/taco/svg-import/paint/paint.js +162 -0
  295. package/dist/taco/svg-import/paths/paths.d.ts +58 -0
  296. package/dist/taco/svg-import/paths/paths.js +205 -0
  297. package/dist/taco/svg-import/public-types.d.ts +279 -0
  298. package/dist/taco/svg-import/public-types.js +56 -0
  299. package/dist/taco/svg-import/report/report.d.ts +44 -0
  300. package/dist/taco/svg-import/report/report.js +79 -0
  301. package/dist/taco/svg-import/reuse/reuse.d.ts +99 -0
  302. package/dist/taco/svg-import/reuse/reuse.js +840 -0
  303. package/dist/taco/svg-import/shapes/shapes.d.ts +35 -0
  304. package/dist/taco/svg-import/shapes/shapes.js +386 -0
  305. package/dist/taco/svg-import/structure/effects.d.ts +26 -0
  306. package/dist/taco/svg-import/structure/effects.js +618 -0
  307. package/dist/taco/svg-import/structure/image.d.ts +24 -0
  308. package/dist/taco/svg-import/structure/image.js +495 -0
  309. package/dist/taco/svg-import/structure/walk.d.ts +85 -0
  310. package/dist/taco/svg-import/structure/walk.js +544 -0
  311. package/dist/taco/svg-import/style/color.d.ts +40 -0
  312. package/dist/taco/svg-import/style/color.js +275 -0
  313. package/dist/taco/svg-import/style/computed.d.ts +214 -0
  314. package/dist/taco/svg-import/style/computed.js +1534 -0
  315. package/dist/taco/svg-import/style/css.d.ts +127 -0
  316. package/dist/taco/svg-import/style/css.js +541 -0
  317. package/dist/taco/svg-import/style/media.d.ts +25 -0
  318. package/dist/taco/svg-import/style/media.js +307 -0
  319. package/dist/taco/svg-import/style/properties.d.ts +43 -0
  320. package/dist/taco/svg-import/style/properties.js +135 -0
  321. package/dist/taco/svg-import/style/selector-reach.d.ts +30 -0
  322. package/dist/taco/svg-import/style/selector-reach.js +169 -0
  323. package/dist/taco/svg-import/style/selector-validity.d.ts +14 -0
  324. package/dist/taco/svg-import/style/selector-validity.js +307 -0
  325. package/dist/taco/svg-import/text/text.d.ts +29 -0
  326. package/dist/taco/svg-import/text/text.js +545 -0
  327. package/dist/taco/svg-import/transform/matrix.d.ts +111 -0
  328. package/dist/taco/svg-import/transform/matrix.js +229 -0
  329. package/dist/taco/svg-import/tree/element-data.d.ts +52 -0
  330. package/dist/taco/svg-import/tree/element-data.js +155 -0
  331. package/dist/taco/svg-import/tree/elements.d.ts +36 -0
  332. package/dist/taco/svg-import/tree/elements.js +121 -0
  333. package/dist/taco/svg-import/units/length.d.ts +43 -0
  334. package/dist/taco/svg-import/units/length.js +125 -0
  335. package/dist/taco/svg-import/units/viewbox.d.ts +35 -0
  336. package/dist/taco/svg-import/units/viewbox.js +77 -0
  337. package/package.json +55 -4
@@ -0,0 +1,397 @@
1
+ // Which combinations of a component's variant properties exist
2
+ // (docs/components/design.md 8.2, "Valid combinations"). A component may
3
+ // carry a validity expression, a boolean expression over its enum and
4
+ // boolean properties; an instance may take only the combinations it is true
5
+ // for. Without one, every combination is valid, as before 0.35.0.
6
+ //
7
+ // Validity is an expression, not a list, so the options to offer and the
8
+ // nearest valid combination are found by evaluation: a search over the
9
+ // other properties' values, in a fixed order, that skips every branch a
10
+ // partial evaluation already shows to be false. The search has a step limit
11
+ // and throws when it is reached, so an expression it cannot decide quickly
12
+ // fails loudly instead of freezing the editor.
13
+ import { ModelError } from "./codec.js";
14
+ import { checkExpressionSource } from "./expressions/check.js";
15
+ import { evaluateExpression } from "./expressions/evaluate.js";
16
+ import { parseExpression } from "./expressions/parser.js";
17
+ import { EXPRESSION_TYPES, expressionEnumType } from "./expressions/types.js";
18
+ import { expressionValuesEqual } from "./expressions/values.js";
19
+ import { entryOf, putEntry } from "./id-table.js";
20
+ /**
21
+ * The most steps one search for a valid combination may take (one step is
22
+ * one property given one value). Above it the search throws a `ModelError`
23
+ * naming the component: its validity expression is too costly to search.
24
+ * @since 0.35.0
25
+ */
26
+ export const VARIANT_SEARCH_STEP_LIMIT = 100_000;
27
+ function validityProperties(component) {
28
+ return (component.properties ?? []).filter((property) => property.kind === "enum" || property.kind === "boolean");
29
+ }
30
+ function propertyType(property) {
31
+ return property.kind === "boolean"
32
+ ? EXPRESSION_TYPES.boolean
33
+ : expressionEnumType(property.name, property.options.map((option) => option.name));
34
+ }
35
+ /**
36
+ * The checking environment of a component's validity expression: its enum
37
+ * and boolean properties by name, and nothing else (no other property, no
38
+ * variable, no `stored`).
39
+ * @since 0.35.0
40
+ */
41
+ export function componentValidityEnvironment(component) {
42
+ const types = new Map(validityProperties(component).map((property) => [property.name, propertyType(property)]));
43
+ return {
44
+ propertyType: (name) => types.get(name),
45
+ variableType: () => undefined,
46
+ };
47
+ }
48
+ /**
49
+ * Checks `source` (the component's own validity expression by default) as a
50
+ * validity expression of `component`: it must parse, be a boolean, and read
51
+ * only the component's enum and boolean properties. Undefined when there is
52
+ * no expression to check.
53
+ * @since 0.35.0
54
+ */
55
+ export function checkComponentValidity(component, source = component.validity) {
56
+ if (source === undefined)
57
+ return undefined;
58
+ return checkExpressionSource(source, EXPRESSION_TYPES.boolean, componentValidityEnvironment(component));
59
+ }
60
+ // ---------------------------------------------------------------------------
61
+ // Parsed expressions
62
+ const parsedSources = new Map();
63
+ const PARSED_KEPT = 64;
64
+ /** The parsed validity expression; throws when it does not parse, which the codec never lets a document hold. */
65
+ function parsedValidity(component, source) {
66
+ const cached = parsedSources.get(source);
67
+ if (cached !== undefined)
68
+ return cached;
69
+ const parsed = parseExpression(source);
70
+ if (!parsed.ok) {
71
+ throw new ModelError("INVALID_SCHEMA", `The validity expression of ${component.name} does not parse: ${parsed.error.message}`, `$.components.${component.id}.validity`);
72
+ }
73
+ if (parsedSources.size >= PARSED_KEPT)
74
+ parsedSources.delete(parsedSources.keys().next().value);
75
+ parsedSources.set(source, parsed.expression);
76
+ return parsed.expression;
77
+ }
78
+ function axesOf(component) {
79
+ return validityProperties(component).map((property) => ({
80
+ property,
81
+ values: property.kind === "boolean" ? [false, true] : property.options.map((option) => option.id),
82
+ }));
83
+ }
84
+ /** The value `values` gives the property: its own when it fits, else the default. */
85
+ function effectiveValue(axis, values) {
86
+ const value = entryOf(values, axis.property.id);
87
+ return value !== undefined && axis.values.includes(value) ? value : axis.property.defaultValue;
88
+ }
89
+ function expressionValue(property, value) {
90
+ if (property.kind === "boolean")
91
+ return { kind: "boolean", value: value === true };
92
+ const option = property.options.find((candidate) => candidate.id === value) ?? property.options[0];
93
+ return { kind: "enum", option: option.name };
94
+ }
95
+ function patternMatches(pattern, value) {
96
+ if (pattern.kind === "option")
97
+ return value.kind === "enum" && value.option === pattern.name;
98
+ return value.kind === "boolean" && value.value === pattern.value;
99
+ }
100
+ /**
101
+ * The value of `expression` when the properties `known` gives are all it
102
+ * needs, else undefined. Sound for pruning: a value it gives is the value
103
+ * every combination with those properties evaluates to.
104
+ */
105
+ function partialValue(expression, known, scopes = []) {
106
+ const again = (inner) => partialValue(inner, known, scopes);
107
+ switch (expression.kind) {
108
+ case "boolean":
109
+ return { kind: "boolean", value: expression.value };
110
+ case "option":
111
+ return { kind: "enum", option: expression.name };
112
+ case "name": {
113
+ for (let index = scopes.length - 1; index >= 0; index -= 1) {
114
+ const scope = scopes[index];
115
+ if (scope.has(expression.name))
116
+ return scope.get(expression.name);
117
+ }
118
+ return known(expression.name);
119
+ }
120
+ case "unary": {
121
+ if (expression.operator !== "not")
122
+ return undefined;
123
+ const operand = again(expression.operand);
124
+ return operand?.kind === "boolean" ? { kind: "boolean", value: !operand.value } : undefined;
125
+ }
126
+ case "binary": {
127
+ const { operator } = expression;
128
+ if (operator === "and" || operator === "or") {
129
+ const decisive = operator === "or";
130
+ const left = again(expression.left);
131
+ if (left?.kind === "boolean" && left.value === decisive)
132
+ return left;
133
+ const right = again(expression.right);
134
+ if (right?.kind === "boolean" && right.value === decisive)
135
+ return right;
136
+ if (left?.kind === "boolean" && right?.kind === "boolean")
137
+ return { kind: "boolean", value: !decisive };
138
+ return undefined;
139
+ }
140
+ if (operator !== "==" && operator !== "!=")
141
+ return undefined;
142
+ const left = again(expression.left);
143
+ const right = again(expression.right);
144
+ if (left === undefined || right === undefined)
145
+ return undefined;
146
+ const equal = expressionValuesEqual(left, right);
147
+ return { kind: "boolean", value: operator === "==" ? equal : !equal };
148
+ }
149
+ case "if": {
150
+ const condition = again(expression.condition);
151
+ if (condition?.kind === "boolean")
152
+ return again(condition.value ? expression.then : expression.else);
153
+ const then = again(expression.then);
154
+ const otherwise = again(expression.else);
155
+ return then !== undefined && otherwise !== undefined && expressionValuesEqual(then, otherwise) ? then : undefined;
156
+ }
157
+ case "let": {
158
+ const value = again(expression.value);
159
+ return partialValue(expression.body, known, [...scopes, new Map([[expression.name, value]])]);
160
+ }
161
+ case "match": {
162
+ const subject = again(expression.subject);
163
+ if (subject !== undefined) {
164
+ const arm = expression.arms.find((candidate) => candidate.patterns.some((pattern) => patternMatches(pattern, subject)));
165
+ if (arm !== undefined)
166
+ return again(arm.body);
167
+ return expression.otherwise === undefined ? undefined : again(expression.otherwise);
168
+ }
169
+ const bodies = [...expression.arms.map((arm) => arm.body), ...(expression.otherwise === undefined ? [] : [expression.otherwise])];
170
+ const values = bodies.map(again);
171
+ const first = values[0];
172
+ return first !== undefined && values.every((value) => value !== undefined && expressionValuesEqual(value, first)) ? first : undefined;
173
+ }
174
+ default:
175
+ return undefined;
176
+ }
177
+ }
178
+ /** A search over one component's combinations, with its step count. */
179
+ class CombinationSearch {
180
+ axes;
181
+ expression;
182
+ indexByName;
183
+ steps = 0;
184
+ component;
185
+ constructor(component) {
186
+ this.component = component;
187
+ this.axes = axesOf(component);
188
+ this.expression = component.validity === undefined ? undefined : parsedValidity(component, component.validity);
189
+ this.indexByName = new Map(this.axes.map((axis, index) => [axis.property.name, index]));
190
+ }
191
+ current(values) {
192
+ return this.axes.map((axis) => effectiveValue(axis, values));
193
+ }
194
+ /** True when the combination is valid; every combination is without an expression. */
195
+ valid(combination) {
196
+ if (this.expression === undefined)
197
+ return true;
198
+ const result = evaluateExpression(this.expression, {
199
+ propertyValue: (name) => {
200
+ const index = this.indexByName.get(name);
201
+ return index === undefined ? undefined : expressionValue(this.axes[index].property, combination[index]);
202
+ },
203
+ variableValue: () => undefined,
204
+ });
205
+ return result.kind === "boolean" && result.value;
206
+ }
207
+ /** False when the first `count` values already make the expression false whatever the rest are. */
208
+ couldBeValid(combination, count) {
209
+ if (this.expression === undefined)
210
+ return true;
211
+ const value = partialValue(this.expression, (name) => {
212
+ const index = this.indexByName.get(name);
213
+ return index === undefined || index >= count ? undefined : expressionValue(this.axes[index].property, combination[index]);
214
+ });
215
+ return !(value?.kind === "boolean" && !value.value);
216
+ }
217
+ step() {
218
+ this.steps += 1;
219
+ if (this.steps > VARIANT_SEARCH_STEP_LIMIT) {
220
+ throw new ModelError("INVALID_SCHEMA", `Finding a valid combination of ${this.component.name} took more than ${String(VARIANT_SEARCH_STEP_LIMIT)} steps; write its validity expression so that fewer combinations need trying`, `$.components.${this.component.id}.validity`);
221
+ }
222
+ }
223
+ /**
224
+ * The first valid combination, in the search order, that keeps `held`
225
+ * and differs from `from` in at most `budget` other properties.
226
+ */
227
+ find(from, held, budget) {
228
+ const combination = [...from];
229
+ const visit = (index, cost) => {
230
+ if (index === this.axes.length)
231
+ return this.valid(combination);
232
+ const fixed = held.get(index);
233
+ const choices = fixed === undefined ? this.axes[index].values : [fixed];
234
+ for (const value of choices) {
235
+ const spent = cost + (fixed === undefined && value !== from[index] ? 1 : 0);
236
+ if (spent > budget)
237
+ continue;
238
+ this.step();
239
+ combination[index] = value;
240
+ if (index + 1 < this.axes.length && !this.couldBeValid(combination, index + 1))
241
+ continue;
242
+ if (visit(index + 1, spent))
243
+ return true;
244
+ }
245
+ combination[index] = from[index];
246
+ return false;
247
+ };
248
+ return visit(0, 0) ? combination : undefined;
249
+ }
250
+ /** The valid combination nearest `from` that keeps `held`: fewest other properties changed, then the search order. */
251
+ nearest(from, held) {
252
+ const start = from.map((value, index) => held.get(index) ?? value);
253
+ if (this.valid(start))
254
+ return start;
255
+ for (let budget = 1; budget <= this.axes.length - held.size; budget += 1) {
256
+ const found = this.find(from, held, budget);
257
+ if (found !== undefined)
258
+ return found;
259
+ }
260
+ return undefined;
261
+ }
262
+ }
263
+ // ---------------------------------------------------------------------------
264
+ // Public functions
265
+ /**
266
+ * True when `values` (an instance's values by property ID; a missing value
267
+ * or one that does not fit reads as the default) form a valid combination
268
+ * of `component`. Always true for a component without a validity
269
+ * expression. Only enum and boolean values matter.
270
+ * @since 0.35.0
271
+ */
272
+ export function isValidVariantCombination(component, values = {}) {
273
+ if (component.validity === undefined)
274
+ return true;
275
+ const search = new CombinationSearch(component);
276
+ return search.valid(search.current(values));
277
+ }
278
+ /**
279
+ * For each enum and boolean property of `component`, by property ID, the
280
+ * values to offer with the others as in `values`: an option is offered
281
+ * when at least one valid combination has it (choosing it may change other
282
+ * properties, see `nearestValidCombination`). Enum values are option IDs in
283
+ * option order; booleans are `false`, then `true`. Every value is offered
284
+ * without a validity expression. Throws a `ModelError` when the search
285
+ * passes `VARIANT_SEARCH_STEP_LIMIT` steps.
286
+ * @since 0.35.0
287
+ */
288
+ export function offeredVariantValues(component, values = {}) {
289
+ const search = new CombinationSearch(component);
290
+ const from = search.current(values);
291
+ const offered = {};
292
+ search.axes.forEach((axis, index) => {
293
+ const kept = search.expression === undefined
294
+ ? axis.values
295
+ : axis.values.filter((value) => search.find(from, new Map([[index, value]]), search.axes.length) !== undefined);
296
+ putEntry(offered, axis.property.id, kept);
297
+ });
298
+ return offered;
299
+ }
300
+ /**
301
+ * The valid combination nearest to `values` that keeps `propertyId` at
302
+ * `value` (or, with no property given, the valid combination nearest to
303
+ * `values`): the fewest other properties changed; among as near ones, the
304
+ * first in the search order, which takes the properties in the component's
305
+ * order and each one's values in option order (a boolean `false` before
306
+ * `true`), so an earlier property's earlier option wins. Undefined when no
307
+ * valid combination has that value. `values` itself when it is valid.
308
+ * Throws a `ModelError` when the search passes `VARIANT_SEARCH_STEP_LIMIT`
309
+ * steps, and when `propertyId` is not an enum or boolean property or
310
+ * `value` does not fit it.
311
+ * @since 0.35.0
312
+ */
313
+ export function nearestValidCombination(component, values = {}, propertyId, value) {
314
+ const search = new CombinationSearch(component);
315
+ const from = search.current(values);
316
+ const held = new Map();
317
+ if (propertyId !== undefined) {
318
+ const index = search.axes.findIndex((axis) => axis.property.id === propertyId);
319
+ const axis = search.axes[index];
320
+ if (axis === undefined || value === undefined || !axis.values.includes(value)) {
321
+ throw new ModelError("INVALID_SCHEMA", `${JSON.stringify(value)} is not a value of an enum or boolean property ${propertyId} of ${component.name}`, `$.components.${component.id}.properties`);
322
+ }
323
+ held.set(index, value);
324
+ }
325
+ const found = search.nearest(from, held);
326
+ if (found === undefined)
327
+ return undefined;
328
+ const result = {};
329
+ const changed = [];
330
+ search.axes.forEach((axis, index) => {
331
+ putEntry(result, axis.property.id, found[index]);
332
+ if (found[index] !== from[index])
333
+ changed.push(axis.property.id);
334
+ });
335
+ return { values: result, changed };
336
+ }
337
+ /** `Name=Option` for each property, as messages show a combination. */
338
+ function describeValues(component, values, ids) {
339
+ return ids.map((id) => {
340
+ const property = (component.properties ?? []).find((candidate) => candidate.id === id);
341
+ const value = entryOf(values, id);
342
+ const shown = property.kind === "enum" ? property.options.find((option) => option.id === value)?.name ?? String(value) : String(value);
343
+ return `${property.name}=${shown}`;
344
+ }).join(", ");
345
+ }
346
+ /**
347
+ * Why `values` are not a valid combination of `component`, naming the valid
348
+ * combinations nearest to them (each keeps one property and changes as few
349
+ * others as it can); undefined when they are valid.
350
+ * @since 0.35.0
351
+ */
352
+ export function invalidCombinationProblem(component, values = {}) {
353
+ const search = new CombinationSearch(component);
354
+ const from = search.current(values);
355
+ if (search.valid(from))
356
+ return undefined;
357
+ const all = {};
358
+ search.axes.forEach((axis, index) => putEntry(all, axis.property.id, from[index]));
359
+ const alternatives = [];
360
+ search.axes.forEach((_, index) => {
361
+ const found = search.nearest(from, new Map([[index, from[index]]]));
362
+ if (found === undefined)
363
+ return;
364
+ const changed = {};
365
+ const ids = [];
366
+ search.axes.forEach((axis, position) => {
367
+ if (found[position] === from[position])
368
+ return;
369
+ putEntry(changed, axis.property.id, found[position]);
370
+ ids.push(axis.property.id);
371
+ });
372
+ const shown = describeValues(component, changed, ids);
373
+ if (!alternatives.includes(shown))
374
+ alternatives.push(shown);
375
+ });
376
+ const current = describeValues(component, all, search.axes.map((axis) => axis.property.id));
377
+ const offered = alternatives.length === 0 ? "it has no valid combination near these values" : `valid instead: ${alternatives.join("; or ")}`;
378
+ return `${current} is not a valid combination of ${component.name} (its validity is ${component.validity}); ${offered}`;
379
+ }
380
+ /**
381
+ * `values` with the enum and boolean values moved to the nearest valid
382
+ * combination when they are not one (see `nearestValidCombination`; no
383
+ * property is held), writing only the values that change. `values` itself
384
+ * when it is valid or none is near.
385
+ * @since 0.35.0
386
+ */
387
+ export function withValidVariantValues(component, values) {
388
+ if (component.validity === undefined || isValidVariantCombination(component, values))
389
+ return values;
390
+ const nearest = nearestValidCombination(component, values);
391
+ if (nearest === undefined)
392
+ return values;
393
+ const next = { ...values };
394
+ for (const id of nearest.changed)
395
+ putEntry(next, id, nearest.values[id]);
396
+ return next;
397
+ }
@@ -0,0 +1,155 @@
1
+ import { type ParentLookup } from "./parent-table.ts";
2
+ import { type ComponentDefinition, type ComponentId, type DesignDocument, type InstanceNode, type NodeId, type SceneNode } from "./types.ts";
3
+ /**
4
+ * The parts of a virtual node ID: the stored instance the layer belongs to
5
+ * and the layer path inside it.
6
+ * @since 0.23.0
7
+ */
8
+ export interface VirtualNodeId {
9
+ /** The stored `InstanceNode` on a page or inside a component. */
10
+ readonly instanceId: NodeId;
11
+ /**
12
+ * The component node IDs from the instance down to the layer, in order.
13
+ * Component roots that are passed through are left out; a component root
14
+ * is only named when it is the addressed layer itself (for the instance's
15
+ * own paints and size). Never empty.
16
+ */
17
+ readonly path: readonly NodeId[];
18
+ }
19
+ /** True when `id` names a layer inside an instance rather than a stored node. */
20
+ export declare const isVirtualNodeId: (id: string) => boolean;
21
+ /**
22
+ * Splits a virtual node ID `<instance id>;<layer path>` into its instance and
23
+ * layer path. Returns `null` for a stored node ID (no separator) and for a
24
+ * malformed ID with an empty segment. This is the only place that splits
25
+ * virtual IDs.
26
+ * @since 0.23.0
27
+ */
28
+ export declare function parseVirtualNodeId(id: string): VirtualNodeId | null;
29
+ /** Builds the virtual node ID of the layer at `path` inside `instanceId`. */
30
+ export declare function virtualNodeId(instanceId: NodeId, path: readonly NodeId[]): NodeId;
31
+ /** The key of `InstanceNode.overrides` for the layer at `path`. */
32
+ export declare function layerPathKey(path: readonly NodeId[]): string;
33
+ /**
34
+ * Splits an override key into its component node IDs, or returns `null` when
35
+ * the key is malformed (empty, or with an empty segment). Whether the named
36
+ * nodes still exist is not checked: such a key is allowed and has no effect.
37
+ * @since 0.23.0
38
+ */
39
+ export declare function parseLayerPath(key: string): readonly NodeId[] | null;
40
+ /**
41
+ * The stored node an ID refers to: the instance for a virtual ID, the ID
42
+ * itself otherwise. Selection code uses it to find the node that moves,
43
+ * deletes or reorders when a layer inside an instance is selected.
44
+ */
45
+ export declare function storedNodeIdOf(id: NodeId): NodeId;
46
+ /** The root node IDs of every component, in `components` order. */
47
+ export declare function componentRootIds(document: DesignDocument): readonly NodeId[];
48
+ /** The component whose root is `rootId`, if any. */
49
+ export declare function findComponentByRoot(document: DesignDocument, rootId: NodeId): ComponentDefinition | undefined;
50
+ /**
51
+ * The component whose layer tree contains the stored node `nodeId` (the root
52
+ * included), or `undefined` when the node is on a page or does not exist.
53
+ * Pass `parents` (from `buildParentMap`) when calling this for many nodes.
54
+ */
55
+ export declare function componentOwningNode(document: DesignDocument, nodeId: NodeId, parents?: ParentLookup): ComponentDefinition | undefined;
56
+ /** True when the stored node is a component layer (its root included) rather than a page node. */
57
+ export declare function isComponentLayer(document: DesignDocument, nodeId: NodeId): boolean;
58
+ /**
59
+ * The components a node refers to: an instance's `componentId`, and every
60
+ * component its overrides swap a nested instance to, a swap that only some
61
+ * variants make (`LayerOverride.conditional`) included. Empty for other nodes.
62
+ */
63
+ export declare function componentReferencesOf(node: SceneNode): readonly ComponentId[];
64
+ /**
65
+ * The stored instance nodes of `componentId`, by ID, sorted. Swaps in
66
+ * overrides do not count. A frozen document made by edits from one already
67
+ * asked about reads only the nodes the edits wrote, not the whole document.
68
+ */
69
+ export declare function instancesOfComponent(document: DesignDocument, componentId: ComponentId): readonly NodeId[];
70
+ /**
71
+ * The stored instance nodes that show `componentId`, by ID, sorted: its
72
+ * instances and the instances whose overrides swap it in
73
+ * (`componentReferencesOf`). Like `instancesOfComponent`, a frozen document
74
+ * made by edits from one already asked about reads only the nodes the edits
75
+ * wrote.
76
+ * @since 0.33.0
77
+ */
78
+ export declare function instancesReferencingComponent(document: DesignDocument, componentId: ComponentId): readonly NodeId[];
79
+ /**
80
+ * The stored instance nodes that can show `componentId`, by ID, sorted: those
81
+ * `instancesReferencingComponent` gives, and those whose own property values,
82
+ * or an override's for a nested instance, name it (an instance swap value).
83
+ * Like `instancesOfComponent`, a frozen document made by edits from one
84
+ * already asked about reads only the nodes the edits wrote. A component that
85
+ * shows `componentId` through an instance property's default is not among
86
+ * them: see `componentsSwappingInByDefault`.
87
+ */
88
+ export declare function instancesShowingComponent(document: DesignDocument, componentId: ComponentId): readonly NodeId[];
89
+ /**
90
+ * The components with an instance property whose default is `componentId`:
91
+ * each of their instances that keeps the default shows it. Reads the
92
+ * component definitions once per components record, not their layers.
93
+ */
94
+ export declare function componentsSwappingInByDefault(document: DesignDocument, componentId: ComponentId): readonly ComponentId[];
95
+ /**
96
+ * Which components contain which. `nests.get(a)` holds every `b` such that a
97
+ * node under `a`'s root is an instance of `b`, or an override under `a`'s
98
+ * root swaps a nested instance to `b`. `nestedBy` is the reverse. Every
99
+ * component appears as a key of both maps, with an empty set when it has no
100
+ * edges. Instances on pages add no edges.
101
+ * @since 0.23.0
102
+ */
103
+ export interface ComponentNestingGraph {
104
+ readonly nests: ReadonlyMap<ComponentId, ReadonlySet<ComponentId>>;
105
+ readonly nestedBy: ReadonlyMap<ComponentId, ReadonlySet<ComponentId>>;
106
+ }
107
+ /**
108
+ * How many times `componentNestingGraph` has walked every component's tree,
109
+ * for tests that check a list or a check builds the graph at most once.
110
+ * @since 0.37.0
111
+ */
112
+ export declare const componentNestingStats: {
113
+ builds: number;
114
+ };
115
+ /** Builds the `ComponentNestingGraph` of a document. Missing component references are kept as edges. */
116
+ export declare function componentNestingGraph(document: DesignDocument): ComponentNestingGraph;
117
+ /**
118
+ * Finds a cycle in the nesting graph: a list of component IDs where each
119
+ * nests the next and the last equals the first. Returns `null` when the
120
+ * graph has no cycle.
121
+ * @since 0.23.0
122
+ */
123
+ export declare function findComponentCycle(graph: ComponentNestingGraph): readonly ComponentId[] | null;
124
+ /**
125
+ * Every component whose tree contains `componentId`, directly or through
126
+ * nesting. A change to `componentId` also changes the instances of these.
127
+ */
128
+ export declare function componentsNesting(graph: ComponentNestingGraph, componentId: ComponentId): ReadonlySet<ComponentId>;
129
+ /** Every component that `componentId`'s tree contains, directly or through nesting. */
130
+ export declare function componentsNestedIn(graph: ComponentNestingGraph, componentId: ComponentId): ReadonlySet<ComponentId>;
131
+ /**
132
+ * Notes that `view`, a working view whose node record is written in place,
133
+ * holds the same components and component layers as `document` for as long
134
+ * as it is read: `nestingGraphOf(view)` is then the graph of `document`,
135
+ * not one built again from a record that is not frozen.
136
+ */
137
+ export declare function shareComponentTrees(view: DesignDocument, document: DesignDocument): void;
138
+ /**
139
+ * The `ComponentNestingGraph` of `document`, built once per document object,
140
+ * or kept from a document it was made from when no component tree changed
141
+ * on the way (`derivedNestingGraph`). Callers
142
+ * must not change the returned graph.
143
+ * @since 0.37.0
144
+ */
145
+ export declare function nestingGraphOf(document: DesignDocument): ComponentNestingGraph;
146
+ /**
147
+ * Reports whether placing an instance of `placedId` inside `hostId`'s tree,
148
+ * or swapping a nested instance there to `placedId`, would make a component
149
+ * contain itself. The editor disables such choices; `assertDocument` rejects
150
+ * the result.
151
+ * @since 0.23.0
152
+ */
153
+ export declare function wouldNestCycle(document: DesignDocument, hostId: ComponentId, placedId: ComponentId): boolean;
154
+ /** The node an instance ID names, checked to be an `InstanceNode`. */
155
+ export declare function instanceNodeOf(document: DesignDocument, instanceId: NodeId): InstanceNode | undefined;