@motionscript/core 0.1.0-alpha.8 → 0.1.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 (817) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +201 -201
  3. package/NOTICE +49 -49
  4. package/README.md +91 -91
  5. package/dist/assets/asset-index.js.map +1 -1
  6. package/dist/assets/catalog.js.map +1 -1
  7. package/dist/assets/errors.js.map +1 -1
  8. package/dist/assets/index.js.map +1 -1
  9. package/dist/assets/manager.js.map +1 -1
  10. package/dist/assets/manifest.js.map +1 -1
  11. package/dist/assets/record.js.map +1 -1
  12. package/dist/assets/scope.js.map +1 -1
  13. package/dist/attributes/audio/effects/chain.js.map +1 -1
  14. package/dist/attributes/audio/effects/implementations/echo.js.map +1 -1
  15. package/dist/attributes/audio/effects/implementations/gain.js.map +1 -1
  16. package/dist/attributes/audio/effects/implementations/highpass.js.map +1 -1
  17. package/dist/attributes/audio/effects/implementations/lowpass.js.map +1 -1
  18. package/dist/attributes/audio/effects/implementations/tremolo.js.map +1 -1
  19. package/dist/attributes/audio/effects/index.js.map +1 -1
  20. package/dist/attributes/audio/effects/registry.js.map +1 -1
  21. package/dist/attributes/audio/effects/union.js.map +1 -1
  22. package/dist/attributes/audio/ramp.js.map +1 -1
  23. package/dist/attributes/audio/request.js.map +1 -1
  24. package/dist/attributes/audio/schedule.js.map +1 -1
  25. package/dist/attributes/audio/sound.js.map +1 -1
  26. package/dist/attributes/audio/transition.js.map +1 -1
  27. package/dist/attributes/index.js.map +1 -1
  28. package/dist/attributes/layout/alignment.js.map +1 -1
  29. package/dist/attributes/layout/index.js.map +1 -1
  30. package/dist/attributes/layout/insets.js.map +1 -1
  31. package/dist/attributes/layout/matrix2d.js.map +1 -1
  32. package/dist/attributes/layout/size.js.map +1 -1
  33. package/dist/attributes/layout/space3d.js.map +1 -1
  34. package/dist/attributes/layout/transform3d.js.map +1 -1
  35. package/dist/attributes/layout/vector2.js.map +1 -1
  36. package/dist/attributes/layout/world-transform.js.map +1 -1
  37. package/dist/attributes/mask/boolean.js.map +1 -1
  38. package/dist/attributes/mask/mask.js.map +1 -1
  39. package/dist/attributes/properties/decorator.js.map +1 -1
  40. package/dist/attributes/properties/inputs.js.map +1 -1
  41. package/dist/attributes/properties/typed.js.map +1 -1
  42. package/dist/attributes/render3d/orbit.js.map +1 -1
  43. package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
  44. package/dist/attributes/shape/corners/corner-style.js.map +1 -1
  45. package/dist/attributes/shape/corners/corners.js.map +1 -1
  46. package/dist/attributes/shape/corners/index.js.map +1 -1
  47. package/dist/attributes/shape/effects/backdrop.js.map +1 -1
  48. package/dist/attributes/shape/effects/chain.js.map +1 -1
  49. package/dist/attributes/shape/effects/effect-data.js.map +1 -1
  50. package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
  51. package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
  52. package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
  53. package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
  54. package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
  55. package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
  56. package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
  57. package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
  58. package/dist/attributes/shape/effects/implementations/curves.d.ts +2 -2
  59. package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
  60. package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
  61. package/dist/attributes/shape/effects/implementations/dither.d.ts +2 -2
  62. package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
  63. package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
  64. package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
  65. package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
  66. package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
  67. package/dist/attributes/shape/effects/implementations/glow.d.ts +4 -4
  68. package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
  69. package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
  70. package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
  71. package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
  72. package/dist/attributes/shape/effects/implementations/invert.d.ts +2 -2
  73. package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
  74. package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
  75. package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
  76. package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
  77. package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
  78. package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
  79. package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
  80. package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
  81. package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
  82. package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
  83. package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
  84. package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
  85. package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
  86. package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
  87. package/dist/attributes/shape/effects/implementations/shader.d.ts +2 -2
  88. package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
  89. package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
  90. package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
  91. package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
  92. package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
  93. package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
  94. package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
  95. package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
  96. package/dist/attributes/shape/effects/index.js.map +1 -1
  97. package/dist/attributes/shape/effects/registry.js.map +1 -1
  98. package/dist/attributes/shape/effects/spec.js.map +1 -1
  99. package/dist/attributes/shape/effects/union.js.map +1 -1
  100. package/dist/attributes/shape/fill/blend.js.map +1 -1
  101. package/dist/attributes/shape/fill/chain.js.map +1 -1
  102. package/dist/attributes/shape/fill/coerce.js.map +1 -1
  103. package/dist/attributes/shape/fill/color/constants.js.map +1 -1
  104. package/dist/attributes/shape/fill/color/parser.d.ts.map +1 -1
  105. package/dist/attributes/shape/fill/color/parser.js +20 -5
  106. package/dist/attributes/shape/fill/color/parser.js.map +1 -1
  107. package/dist/attributes/shape/fill/gradient-stops.js.map +1 -1
  108. package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
  109. package/dist/attributes/shape/fill/implementations/color.js.map +1 -1
  110. package/dist/attributes/shape/fill/implementations/conic-gradient.js.map +1 -1
  111. package/dist/attributes/shape/fill/implementations/dot-grid.js.map +1 -1
  112. package/dist/attributes/shape/fill/implementations/fractal-noise.js.map +1 -1
  113. package/dist/attributes/shape/fill/implementations/grid.js.map +1 -1
  114. package/dist/attributes/shape/fill/implementations/image.js.map +1 -1
  115. package/dist/attributes/shape/fill/implementations/linear-gradient.js.map +1 -1
  116. package/dist/attributes/shape/fill/implementations/noise.js.map +1 -1
  117. package/dist/attributes/shape/fill/implementations/radial-gradient.js.map +1 -1
  118. package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
  119. package/dist/attributes/shape/fill/implementations/stripe.js.map +1 -1
  120. package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
  121. package/dist/attributes/shape/fill/index.js.map +1 -1
  122. package/dist/attributes/shape/fill/lerp.js.map +1 -1
  123. package/dist/attributes/shape/fill/media-preset.js.map +1 -1
  124. package/dist/attributes/shape/fill/registry.js.map +1 -1
  125. package/dist/attributes/shape/fill/union.js.map +1 -1
  126. package/dist/attributes/shape/filters/chain.js.map +1 -1
  127. package/dist/attributes/shape/filters/implementations/alpha.js.map +1 -1
  128. package/dist/attributes/shape/filters/implementations/blur.js.map +1 -1
  129. package/dist/attributes/shape/filters/implementations/color-adjustment.js.map +1 -1
  130. package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
  131. package/dist/attributes/shape/filters/implementations/curves.js.map +1 -1
  132. package/dist/attributes/shape/filters/implementations/echo.js.map +1 -1
  133. package/dist/attributes/shape/filters/implementations/exposure.js.map +1 -1
  134. package/dist/attributes/shape/filters/implementations/grayscale.js.map +1 -1
  135. package/dist/attributes/shape/filters/implementations/posterize-time.js.map +1 -1
  136. package/dist/attributes/shape/filters/index.js.map +1 -1
  137. package/dist/attributes/shape/filters/registry.js.map +1 -1
  138. package/dist/attributes/shape/filters/union.js.map +1 -1
  139. package/dist/attributes/shape/path/anchors.js.map +1 -1
  140. package/dist/attributes/shape/path/bezier.js.map +1 -1
  141. package/dist/attributes/shape/path/index.js.map +1 -1
  142. package/dist/attributes/shape/path/measure.js.map +1 -1
  143. package/dist/attributes/shape/path/morph.js.map +1 -1
  144. package/dist/attributes/shape/path/ops.js.map +1 -1
  145. package/dist/attributes/shape/path/types.js.map +1 -1
  146. package/dist/attributes/shape/path/walk.js.map +1 -1
  147. package/dist/attributes/shape/shaders/index.js.map +1 -1
  148. package/dist/attributes/shape/shaders/language.js.map +1 -1
  149. package/dist/attributes/shape/shaders/pack.js.map +1 -1
  150. package/dist/attributes/shape/shaders/resolve.js.map +1 -1
  151. package/dist/attributes/shape/shadow/index.js.map +1 -1
  152. package/dist/attributes/shape/shadow/shadow.js.map +1 -1
  153. package/dist/attributes/shape/stroke/index.js.map +1 -1
  154. package/dist/attributes/shape/stroke/stroke.js.map +1 -1
  155. package/dist/attributes/shared/operators.js.map +1 -1
  156. package/dist/attributes/text/index.js.map +1 -1
  157. package/dist/attributes/text/ops.js.map +1 -1
  158. package/dist/attributes/text/types.js.map +1 -1
  159. package/dist/browser/chunks/{chunk-LKUYVFU3.js → chunk-4BDLFEOC.js} +1 -1
  160. package/dist/browser/chunks/chunk-4BDLFEOC.js.map +7 -0
  161. package/dist/browser/chunks/chunk-CCGVIR4F.js +3 -0
  162. package/dist/browser/chunks/chunk-CCGVIR4F.js.map +7 -0
  163. package/dist/browser/chunks/chunk-N4WSN5WY.js +13 -0
  164. package/dist/browser/chunks/chunk-N4WSN5WY.js.map +7 -0
  165. package/dist/browser/chunks/chunk-WZSI3GSK.js +6 -0
  166. package/dist/browser/chunks/chunk-WZSI3GSK.js.map +7 -0
  167. package/dist/browser/component.js +1 -1
  168. package/dist/browser/experimental.js +1 -1
  169. package/dist/browser/experimental.js.map +1 -1
  170. package/dist/browser/index.js +1 -1
  171. package/dist/browser/index.js.map +1 -1
  172. package/dist/browser/manifest.json +1 -1
  173. package/dist/browser/sdk.js +1 -1
  174. package/dist/component.js.map +1 -1
  175. package/dist/components/builtins/audio/audio.js.map +1 -1
  176. package/dist/components/builtins/geometry/composite.js.map +1 -1
  177. package/dist/components/builtins/geometry/geometry.js.map +1 -1
  178. package/dist/components/builtins/geometry/shape-outline.js.map +1 -1
  179. package/dist/components/builtins/layout/layout.js.map +1 -1
  180. package/dist/components/builtins/media/media.js.map +1 -1
  181. package/dist/components/builtins/providers/providers.js.map +1 -1
  182. package/dist/components/builtins/text/number-format.js.map +1 -1
  183. package/dist/components/builtins/text/number-pattern.js.map +1 -1
  184. package/dist/components/builtins/text/text-defaults.js.map +1 -1
  185. package/dist/components/builtins/text/text-layout.js.map +1 -1
  186. package/dist/components/builtins/text/text.d.ts +9 -9
  187. package/dist/components/builtins/text/text.js.map +1 -1
  188. package/dist/components/builtins/three/canvas3d.js.map +1 -1
  189. package/dist/components/builtins/three/grid-geometry3d.js.map +1 -1
  190. package/dist/components/builtins/three/three.js.map +1 -1
  191. package/dist/components/factory/api.js.map +1 -1
  192. package/dist/components/factory/clip-of.js.map +1 -1
  193. package/dist/components/factory/commands-for.js.map +1 -1
  194. package/dist/components/factory/component-audio.js.map +1 -1
  195. package/dist/components/factory/component2d.js.map +1 -1
  196. package/dist/components/factory/component3d.js.map +1 -1
  197. package/dist/components/factory/factory.js.map +1 -1
  198. package/dist/components/factory/timeline.js.map +1 -1
  199. package/dist/components/factory/type-def.js.map +1 -1
  200. package/dist/components/factory/types.js.map +1 -1
  201. package/dist/components/factory/views.d.ts.map +1 -1
  202. package/dist/components/factory/views.js +41 -1
  203. package/dist/components/factory/views.js.map +1 -1
  204. package/dist/components/modules/aim.js.map +1 -1
  205. package/dist/components/modules/corners.js.map +1 -1
  206. package/dist/components/modules/flow.js.map +1 -1
  207. package/dist/components/modules/material.js.map +1 -1
  208. package/dist/components/modules/paint.js.map +1 -1
  209. package/dist/components/modules/shapes.js.map +1 -1
  210. package/dist/components/modules/text-layout.js.map +1 -1
  211. package/dist/components/modules/text-style.d.ts +1 -1
  212. package/dist/components/modules/text-style.js.map +1 -1
  213. package/dist/components/modules/three-entries.js.map +1 -1
  214. package/dist/components/modules/view3d.js.map +1 -1
  215. package/dist/components/trees/2d/group-bounds.js.map +1 -1
  216. package/dist/components/trees/2d/node-lifecycle.js.map +1 -1
  217. package/dist/components/trees/2d/node-motion.js.map +1 -1
  218. package/dist/components/trees/2d/node-render.js.map +1 -1
  219. package/dist/components/trees/2d/node-space.js.map +1 -1
  220. package/dist/components/trees/2d/node-transform.js.map +1 -1
  221. package/dist/components/trees/2d/node2d.js.map +1 -1
  222. package/dist/components/trees/audio/index.js.map +1 -1
  223. package/dist/components/trees/audio/node-audio.js.map +1 -1
  224. package/dist/components/trees/index.js.map +1 -1
  225. package/dist/components/trees/node/node-editor-state.js.map +1 -1
  226. package/dist/components/trees/node/node-reactive.d.ts +3 -4
  227. package/dist/components/trees/node/node-reactive.d.ts.map +1 -1
  228. package/dist/components/trees/node/node-reactive.js +13 -10
  229. package/dist/components/trees/node/node-reactive.js.map +1 -1
  230. package/dist/components/trees/node/node-time.js.map +1 -1
  231. package/dist/components/trees/node/node-walk.js.map +1 -1
  232. package/dist/components/trees/node/node.js.map +1 -1
  233. package/dist/components/trees/root/canvas2d-node.js.map +1 -1
  234. package/dist/components/trees/three/node3d.js.map +1 -1
  235. package/dist/document/audio.js.map +1 -1
  236. package/dist/document/builtins.js.map +1 -1
  237. package/dist/document/command-traits.d.ts +8 -0
  238. package/dist/document/command-traits.d.ts.map +1 -1
  239. package/dist/document/command-traits.js +17 -0
  240. package/dist/document/command-traits.js.map +1 -1
  241. package/dist/document/deny-globals.js.map +1 -1
  242. package/dist/document/diff.js.map +1 -1
  243. package/dist/document/doc-index.js.map +1 -1
  244. package/dist/document/expression/compile.js.map +1 -1
  245. package/dist/document/expression/index.js.map +1 -1
  246. package/dist/document/expression/ops.js.map +1 -1
  247. package/dist/document/expression/parse.js.map +1 -1
  248. package/dist/document/expression/refs.js.map +1 -1
  249. package/dist/document/expression/types.js.map +1 -1
  250. package/dist/document/expression/walk.js.map +1 -1
  251. package/dist/document/index.js.map +1 -1
  252. package/dist/document/migrate.js.map +1 -1
  253. package/dist/document/missing-node.js.map +1 -1
  254. package/dist/document/node-decorator.js.map +1 -1
  255. package/dist/document/node-descriptor.js.map +1 -1
  256. package/dist/document/placement.js.map +1 -1
  257. package/dist/document/project.js.map +1 -1
  258. package/dist/document/prop-evolution.js.map +1 -1
  259. package/dist/document/registry.js.map +1 -1
  260. package/dist/document/settled-index.d.ts +6 -0
  261. package/dist/document/settled-index.d.ts.map +1 -1
  262. package/dist/document/settled-index.js +18 -1
  263. package/dist/document/settled-index.js.map +1 -1
  264. package/dist/document/timeline-patch.js.map +1 -1
  265. package/dist/document/timeline.d.ts.map +1 -1
  266. package/dist/document/timeline.js +26 -6
  267. package/dist/document/timeline.js.map +1 -1
  268. package/dist/document/types.js.map +1 -1
  269. package/dist/document/validate.js.map +1 -1
  270. package/dist/document/vocabulary.js.map +1 -1
  271. package/dist/experimental.d.ts.map +1 -1
  272. package/dist/experimental.js.map +1 -1
  273. package/dist/index.js.map +1 -1
  274. package/dist/layout/bounds.js.map +1 -1
  275. package/dist/layout/constraints.js.map +1 -1
  276. package/dist/layout/flex.js.map +1 -1
  277. package/dist/layout/freeform.js.map +1 -1
  278. package/dist/layout/grid.js.map +1 -1
  279. package/dist/layout/index.js.map +1 -1
  280. package/dist/layout/item.js.map +1 -1
  281. package/dist/layout/ops.js.map +1 -1
  282. package/dist/layout/types.js.map +1 -1
  283. package/dist/platform/audio-sink.js.map +1 -1
  284. package/dist/platform/exporter.js.map +1 -1
  285. package/dist/platform/index.js.map +1 -1
  286. package/dist/platform/stepped-clock.js.map +1 -1
  287. package/dist/platform/storage-adapter.js.map +1 -1
  288. package/dist/platform/ticker.js.map +1 -1
  289. package/dist/project/config.js.map +1 -1
  290. package/dist/project/index.js.map +1 -1
  291. package/dist/project/tree.js.map +1 -1
  292. package/dist/props/host.d.ts +5 -0
  293. package/dist/props/host.d.ts.map +1 -1
  294. package/dist/props/host.js +3 -1
  295. package/dist/props/host.js.map +1 -1
  296. package/dist/props/index.js.map +1 -1
  297. package/dist/props/layout.d.ts +29 -0
  298. package/dist/props/layout.d.ts.map +1 -0
  299. package/dist/props/layout.js +84 -0
  300. package/dist/props/layout.js.map +1 -0
  301. package/dist/props/observer.js.map +1 -1
  302. package/dist/props/slot.js.map +1 -1
  303. package/dist/renamed-scene-names.js.map +1 -1
  304. package/dist/render/canvas-render-context2d.js.map +1 -1
  305. package/dist/render/clip-contains.js.map +1 -1
  306. package/dist/render/clip.js.map +1 -1
  307. package/dist/render/descriptors/ellipse.js.map +1 -1
  308. package/dist/render/descriptors/line.js.map +1 -1
  309. package/dist/render/descriptors/path-builder.js.map +1 -1
  310. package/dist/render/descriptors/path.js.map +1 -1
  311. package/dist/render/descriptors/polygon.js.map +1 -1
  312. package/dist/render/descriptors/polygram.js.map +1 -1
  313. package/dist/render/descriptors/rect.js.map +1 -1
  314. package/dist/render/descriptors/richtext.js.map +1 -1
  315. package/dist/render/descriptors/shape.js.map +1 -1
  316. package/dist/render/descriptors/text.js.map +1 -1
  317. package/dist/render/descriptors/transform.js.map +1 -1
  318. package/dist/render/graphics2d.js.map +1 -1
  319. package/dist/render/index.js.map +1 -1
  320. package/dist/render/measure-context.js.map +1 -1
  321. package/dist/render/null-render-context.js.map +1 -1
  322. package/dist/render/render-context2d.js.map +1 -1
  323. package/dist/render/render-issue.js.map +1 -1
  324. package/dist/render/surface.js.map +1 -1
  325. package/dist/render/text-defaults.js.map +1 -1
  326. package/dist/render/text-layout.js.map +1 -1
  327. package/dist/render3d/bounds3d.js.map +1 -1
  328. package/dist/render3d/builders.js.map +1 -1
  329. package/dist/render3d/camera.js.map +1 -1
  330. package/dist/render3d/fill3d.js.map +1 -1
  331. package/dist/render3d/geometry.js.map +1 -1
  332. package/dist/render3d/graphics3d.js.map +1 -1
  333. package/dist/render3d/index.js.map +1 -1
  334. package/dist/render3d/inert.js.map +1 -1
  335. package/dist/render3d/light.js.map +1 -1
  336. package/dist/render3d/material.js.map +1 -1
  337. package/dist/render3d/matrix4.js.map +1 -1
  338. package/dist/render3d/render-context3d.js.map +1 -1
  339. package/dist/render3d/resources.js.map +1 -1
  340. package/dist/render3d/rounded-box.js.map +1 -1
  341. package/dist/render3d/scene-settings.js.map +1 -1
  342. package/dist/render3d/scene3d.js.map +1 -1
  343. package/dist/render3d/segments.js.map +1 -1
  344. package/dist/render3d/texture.js.map +1 -1
  345. package/dist/render3d/tracking.js.map +1 -1
  346. package/dist/render3d/transform.js.map +1 -1
  347. package/dist/render3d/vector3.js.map +1 -1
  348. package/dist/render3d/walk.js.map +1 -1
  349. package/dist/runtime/asset-refine.js.map +1 -1
  350. package/dist/runtime/asset-timeline.js.map +1 -1
  351. package/dist/runtime/asset-update.js.map +1 -1
  352. package/dist/runtime/audio-index.js.map +1 -1
  353. package/dist/runtime/builtin-context.js.map +1 -1
  354. package/dist/runtime/clip-instance.js.map +1 -1
  355. package/dist/runtime/clip-store.js.map +1 -1
  356. package/dist/runtime/engine.js.map +1 -1
  357. package/dist/runtime/frame-time.js.map +1 -1
  358. package/dist/runtime/index.js.map +1 -1
  359. package/dist/runtime/node-picking.js.map +1 -1
  360. package/dist/runtime/node-picking3d.js.map +1 -1
  361. package/dist/runtime/placement.js.map +1 -1
  362. package/dist/runtime/playback-controller.js.map +1 -1
  363. package/dist/runtime/playback.js.map +1 -1
  364. package/dist/runtime/precompisition.js.map +1 -1
  365. package/dist/runtime/project-assets.js.map +1 -1
  366. package/dist/runtime/session.js.map +1 -1
  367. package/dist/runtime/settle.js.map +1 -1
  368. package/dist/runtime/state-evaluator.js.map +1 -1
  369. package/dist/runtime/text-geometry.js.map +1 -1
  370. package/dist/sdk/index.js.map +1 -1
  371. package/dist/tween/command-decorator.js.map +1 -1
  372. package/dist/tween/command.js.map +1 -1
  373. package/dist/tween/ease/constants.js.map +1 -1
  374. package/dist/tween/ease/curve.js.map +1 -1
  375. package/dist/tween/ease/describe.js.map +1 -1
  376. package/dist/tween/ease/spec.js.map +1 -1
  377. package/dist/tween/ease/type.js.map +1 -1
  378. package/dist/tween/index.js.map +1 -1
  379. package/dist/tween/inert.js.map +1 -1
  380. package/dist/tween/lerp.js.map +1 -1
  381. package/dist/tween/loop.js.map +1 -1
  382. package/dist/tween/prepare.js.map +1 -1
  383. package/dist/tween/stepper.js.map +1 -1
  384. package/dist/tween/to-command.js.map +1 -1
  385. package/dist/util/clamp.js.map +1 -1
  386. package/dist/util/context.js.map +1 -1
  387. package/dist/util/csv.js.map +1 -1
  388. package/dist/util/generateList.js.map +1 -1
  389. package/dist/util/index.js.map +1 -1
  390. package/dist/util/metrics.js.map +1 -1
  391. package/dist/util/random.js.map +1 -1
  392. package/dist/util/reference.js.map +1 -1
  393. package/dist/util/scheduler.js.map +1 -1
  394. package/package.json +1 -1
  395. package/dist/attributes/audio/filters/chain.d.ts +0 -113
  396. package/dist/attributes/audio/filters/chain.d.ts.map +0 -1
  397. package/dist/attributes/audio/filters/chain.js +0 -104
  398. package/dist/attributes/audio/filters/chain.js.map +0 -1
  399. package/dist/attributes/audio/filters/curve.d.ts +0 -152
  400. package/dist/attributes/audio/filters/curve.d.ts.map +0 -1
  401. package/dist/attributes/audio/filters/curve.js +0 -250
  402. package/dist/attributes/audio/filters/curve.js.map +0 -1
  403. package/dist/attributes/audio/filters/implementations/echo.d.ts +0 -14
  404. package/dist/attributes/audio/filters/implementations/echo.d.ts.map +0 -1
  405. package/dist/attributes/audio/filters/implementations/echo.js +0 -11
  406. package/dist/attributes/audio/filters/implementations/echo.js.map +0 -1
  407. package/dist/attributes/audio/filters/implementations/gain.d.ts +0 -10
  408. package/dist/attributes/audio/filters/implementations/gain.d.ts.map +0 -1
  409. package/dist/attributes/audio/filters/implementations/gain.js +0 -6
  410. package/dist/attributes/audio/filters/implementations/gain.js.map +0 -1
  411. package/dist/attributes/audio/filters/implementations/highpass.d.ts +0 -12
  412. package/dist/attributes/audio/filters/implementations/highpass.d.ts.map +0 -1
  413. package/dist/attributes/audio/filters/implementations/highpass.js +0 -10
  414. package/dist/attributes/audio/filters/implementations/highpass.js.map +0 -1
  415. package/dist/attributes/audio/filters/implementations/lowpass.d.ts +0 -12
  416. package/dist/attributes/audio/filters/implementations/lowpass.d.ts.map +0 -1
  417. package/dist/attributes/audio/filters/implementations/lowpass.js +0 -10
  418. package/dist/attributes/audio/filters/implementations/lowpass.js.map +0 -1
  419. package/dist/attributes/audio/filters/implementations/speed.d.ts +0 -18
  420. package/dist/attributes/audio/filters/implementations/speed.d.ts.map +0 -1
  421. package/dist/attributes/audio/filters/implementations/speed.js +0 -6
  422. package/dist/attributes/audio/filters/implementations/speed.js.map +0 -1
  423. package/dist/attributes/audio/filters/implementations/tremolo.d.ts +0 -12
  424. package/dist/attributes/audio/filters/implementations/tremolo.d.ts.map +0 -1
  425. package/dist/attributes/audio/filters/implementations/tremolo.js +0 -10
  426. package/dist/attributes/audio/filters/implementations/tremolo.js.map +0 -1
  427. package/dist/attributes/audio/filters/index.d.ts +0 -22
  428. package/dist/attributes/audio/filters/index.d.ts.map +0 -1
  429. package/dist/attributes/audio/filters/index.js +0 -8
  430. package/dist/attributes/audio/filters/index.js.map +0 -1
  431. package/dist/attributes/audio/filters/registry.d.ts +0 -36
  432. package/dist/attributes/audio/filters/registry.d.ts.map +0 -1
  433. package/dist/attributes/audio/filters/registry.js +0 -82
  434. package/dist/attributes/audio/filters/registry.js.map +0 -1
  435. package/dist/attributes/audio/filters/union.d.ts +0 -18
  436. package/dist/attributes/audio/filters/union.d.ts.map +0 -1
  437. package/dist/attributes/audio/filters/union.js +0 -28
  438. package/dist/attributes/audio/filters/union.js.map +0 -1
  439. package/dist/attributes/shape/sksl-uniforms.d.ts +0 -146
  440. package/dist/attributes/shape/sksl-uniforms.d.ts.map +0 -1
  441. package/dist/attributes/shape/sksl-uniforms.js +0 -0
  442. package/dist/attributes/shape/sksl-uniforms.js.map +0 -1
  443. package/dist/browser/chunks/chunk-AOT33LMS.js +0 -13
  444. package/dist/browser/chunks/chunk-AOT33LMS.js.map +0 -7
  445. package/dist/browser/chunks/chunk-GKM6UZJR.js +0 -6
  446. package/dist/browser/chunks/chunk-GKM6UZJR.js.map +0 -7
  447. package/dist/browser/chunks/chunk-LKUYVFU3.js.map +0 -7
  448. package/dist/browser/chunks/chunk-ZRPZPWZU.js +0 -3
  449. package/dist/browser/chunks/chunk-ZRPZPWZU.js.map +0 -7
  450. package/dist/component/api.d.ts +0 -508
  451. package/dist/component/api.d.ts.map +0 -1
  452. package/dist/component/api.js +0 -4
  453. package/dist/component/api.js.map +0 -1
  454. package/dist/component/builtins/audio.d.ts +0 -26
  455. package/dist/component/builtins/audio.d.ts.map +0 -1
  456. package/dist/component/builtins/audio.js +0 -41
  457. package/dist/component/builtins/audio.js.map +0 -1
  458. package/dist/component/builtins/canvas3d.d.ts +0 -98
  459. package/dist/component/builtins/canvas3d.d.ts.map +0 -1
  460. package/dist/component/builtins/canvas3d.js +0 -21
  461. package/dist/component/builtins/canvas3d.js.map +0 -1
  462. package/dist/component/builtins/composite.d.ts +0 -56
  463. package/dist/component/builtins/composite.d.ts.map +0 -1
  464. package/dist/component/builtins/composite.js +0 -25
  465. package/dist/component/builtins/composite.js.map +0 -1
  466. package/dist/component/builtins/geometry.d.ts +0 -505
  467. package/dist/component/builtins/geometry.d.ts.map +0 -1
  468. package/dist/component/builtins/geometry.js +0 -107
  469. package/dist/component/builtins/geometry.js.map +0 -1
  470. package/dist/component/builtins/layout.d.ts +0 -88
  471. package/dist/component/builtins/layout.d.ts.map +0 -1
  472. package/dist/component/builtins/layout.js +0 -84
  473. package/dist/component/builtins/layout.js.map +0 -1
  474. package/dist/component/builtins/media.d.ts +0 -95
  475. package/dist/component/builtins/media.d.ts.map +0 -1
  476. package/dist/component/builtins/media.js +0 -149
  477. package/dist/component/builtins/media.js.map +0 -1
  478. package/dist/component/builtins/providers.d.ts +0 -23
  479. package/dist/component/builtins/providers.d.ts.map +0 -1
  480. package/dist/component/builtins/providers.js +0 -30
  481. package/dist/component/builtins/providers.js.map +0 -1
  482. package/dist/component/builtins/text.d.ts +0 -193
  483. package/dist/component/builtins/text.d.ts.map +0 -1
  484. package/dist/component/builtins/text.js +0 -113
  485. package/dist/component/builtins/text.js.map +0 -1
  486. package/dist/component/builtins/three.d.ts +0 -1085
  487. package/dist/component/builtins/three.d.ts.map +0 -1
  488. package/dist/component/builtins/three.js +0 -265
  489. package/dist/component/builtins/three.js.map +0 -1
  490. package/dist/component/clip-of.d.ts +0 -5
  491. package/dist/component/clip-of.d.ts.map +0 -1
  492. package/dist/component/clip-of.js +0 -33
  493. package/dist/component/clip-of.js.map +0 -1
  494. package/dist/component/commands-for.d.ts +0 -19
  495. package/dist/component/commands-for.d.ts.map +0 -1
  496. package/dist/component/commands-for.js +0 -5
  497. package/dist/component/commands-for.js.map +0 -1
  498. package/dist/component/component-audio.d.ts +0 -9
  499. package/dist/component/component-audio.d.ts.map +0 -1
  500. package/dist/component/component-audio.js +0 -18
  501. package/dist/component/component-audio.js.map +0 -1
  502. package/dist/component/component2d.d.ts +0 -9
  503. package/dist/component/component2d.d.ts.map +0 -1
  504. package/dist/component/component2d.js +0 -239
  505. package/dist/component/component2d.js.map +0 -1
  506. package/dist/component/component3d.d.ts +0 -9
  507. package/dist/component/component3d.d.ts.map +0 -1
  508. package/dist/component/component3d.js +0 -99
  509. package/dist/component/component3d.js.map +0 -1
  510. package/dist/component/factory.d.ts +0 -63
  511. package/dist/component/factory.d.ts.map +0 -1
  512. package/dist/component/factory.js +0 -313
  513. package/dist/component/factory.js.map +0 -1
  514. package/dist/component/modules/aim.d.ts +0 -30
  515. package/dist/component/modules/aim.d.ts.map +0 -1
  516. package/dist/component/modules/aim.js +0 -39
  517. package/dist/component/modules/aim.js.map +0 -1
  518. package/dist/component/modules/corners.d.ts +0 -13
  519. package/dist/component/modules/corners.d.ts.map +0 -1
  520. package/dist/component/modules/corners.js +0 -12
  521. package/dist/component/modules/corners.js.map +0 -1
  522. package/dist/component/modules/flow.d.ts +0 -26
  523. package/dist/component/modules/flow.d.ts.map +0 -1
  524. package/dist/component/modules/flow.js +0 -55
  525. package/dist/component/modules/flow.js.map +0 -1
  526. package/dist/component/modules/material.d.ts +0 -40
  527. package/dist/component/modules/material.d.ts.map +0 -1
  528. package/dist/component/modules/material.js +0 -75
  529. package/dist/component/modules/material.js.map +0 -1
  530. package/dist/component/modules/paint.d.ts +0 -71
  531. package/dist/component/modules/paint.d.ts.map +0 -1
  532. package/dist/component/modules/paint.js +0 -106
  533. package/dist/component/modules/paint.js.map +0 -1
  534. package/dist/component/modules/shapes.d.ts +0 -31
  535. package/dist/component/modules/shapes.d.ts.map +0 -1
  536. package/dist/component/modules/shapes.js +0 -43
  537. package/dist/component/modules/shapes.js.map +0 -1
  538. package/dist/component/modules/text-layout.d.ts +0 -26
  539. package/dist/component/modules/text-layout.d.ts.map +0 -1
  540. package/dist/component/modules/text-layout.js +0 -57
  541. package/dist/component/modules/text-layout.js.map +0 -1
  542. package/dist/component/modules/text-style.d.ts +0 -48
  543. package/dist/component/modules/text-style.d.ts.map +0 -1
  544. package/dist/component/modules/text-style.js +0 -63
  545. package/dist/component/modules/text-style.js.map +0 -1
  546. package/dist/component/modules/three-entries.d.ts +0 -23
  547. package/dist/component/modules/three-entries.d.ts.map +0 -1
  548. package/dist/component/modules/three-entries.js +0 -41
  549. package/dist/component/modules/three-entries.js.map +0 -1
  550. package/dist/component/modules/view3d.d.ts +0 -55
  551. package/dist/component/modules/view3d.d.ts.map +0 -1
  552. package/dist/component/modules/view3d.js +0 -160
  553. package/dist/component/modules/view3d.js.map +0 -1
  554. package/dist/component/timeline.d.ts +0 -22
  555. package/dist/component/timeline.d.ts.map +0 -1
  556. package/dist/component/timeline.js +0 -128
  557. package/dist/component/timeline.js.map +0 -1
  558. package/dist/component/type-def.d.ts +0 -26
  559. package/dist/component/type-def.d.ts.map +0 -1
  560. package/dist/component/type-def.js +0 -16
  561. package/dist/component/type-def.js.map +0 -1
  562. package/dist/component/types.d.ts +0 -91
  563. package/dist/component/types.d.ts.map +0 -1
  564. package/dist/component/types.js +0 -88
  565. package/dist/component/types.js.map +0 -1
  566. package/dist/component/views.d.ts +0 -121
  567. package/dist/component/views.d.ts.map +0 -1
  568. package/dist/component/views.js +0 -413
  569. package/dist/component/views.js.map +0 -1
  570. package/dist/document/withdraw.d.ts +0 -28
  571. package/dist/document/withdraw.d.ts.map +0 -1
  572. package/dist/document/withdraw.js +0 -61
  573. package/dist/document/withdraw.js.map +0 -1
  574. package/dist/jsx/jsx-dev-runtime.d.ts +0 -3
  575. package/dist/jsx/jsx-dev-runtime.d.ts.map +0 -1
  576. package/dist/jsx/jsx-dev-runtime.js +0 -3
  577. package/dist/jsx/jsx-dev-runtime.js.map +0 -1
  578. package/dist/jsx/jsx-runtime.d.ts +0 -27
  579. package/dist/jsx/jsx-runtime.d.ts.map +0 -1
  580. package/dist/jsx/jsx-runtime.js +0 -26
  581. package/dist/jsx/jsx-runtime.js.map +0 -1
  582. package/dist/nodes/2d/node-lifecycle.d.ts +0 -46
  583. package/dist/nodes/2d/node-lifecycle.d.ts.map +0 -1
  584. package/dist/nodes/2d/node-lifecycle.js +0 -264
  585. package/dist/nodes/2d/node-lifecycle.js.map +0 -1
  586. package/dist/nodes/2d/node-motion.d.ts +0 -56
  587. package/dist/nodes/2d/node-motion.d.ts.map +0 -1
  588. package/dist/nodes/2d/node-motion.js +0 -86
  589. package/dist/nodes/2d/node-motion.js.map +0 -1
  590. package/dist/nodes/2d/node-render.d.ts +0 -44
  591. package/dist/nodes/2d/node-render.d.ts.map +0 -1
  592. package/dist/nodes/2d/node-render.js +0 -80
  593. package/dist/nodes/2d/node-render.js.map +0 -1
  594. package/dist/nodes/2d/node-space.d.ts +0 -63
  595. package/dist/nodes/2d/node-space.d.ts.map +0 -1
  596. package/dist/nodes/2d/node-space.js +0 -131
  597. package/dist/nodes/2d/node-space.js.map +0 -1
  598. package/dist/nodes/2d/node-transform.d.ts +0 -55
  599. package/dist/nodes/2d/node-transform.d.ts.map +0 -1
  600. package/dist/nodes/2d/node-transform.js +0 -73
  601. package/dist/nodes/2d/node-transform.js.map +0 -1
  602. package/dist/nodes/2d/node2d.d.ts +0 -1111
  603. package/dist/nodes/2d/node2d.d.ts.map +0 -1
  604. package/dist/nodes/2d/node2d.js +0 -1665
  605. package/dist/nodes/2d/node2d.js.map +0 -1
  606. package/dist/nodes/2d/paint-node.d.ts +0 -142
  607. package/dist/nodes/2d/paint-node.d.ts.map +0 -1
  608. package/dist/nodes/2d/paint-node.js +0 -232
  609. package/dist/nodes/2d/paint-node.js.map +0 -1
  610. package/dist/nodes/audio/audio-bus.d.ts +0 -28
  611. package/dist/nodes/audio/audio-bus.d.ts.map +0 -1
  612. package/dist/nodes/audio/audio-bus.js +0 -33
  613. package/dist/nodes/audio/audio-bus.js.map +0 -1
  614. package/dist/nodes/audio/index.d.ts +0 -4
  615. package/dist/nodes/audio/index.d.ts.map +0 -1
  616. package/dist/nodes/audio/index.js +0 -2
  617. package/dist/nodes/audio/index.js.map +0 -1
  618. package/dist/nodes/audio/node-audio.d.ts +0 -107
  619. package/dist/nodes/audio/node-audio.d.ts.map +0 -1
  620. package/dist/nodes/audio/node-audio.js +0 -179
  621. package/dist/nodes/audio/node-audio.js.map +0 -1
  622. package/dist/nodes/audio/sound-node.d.ts +0 -41
  623. package/dist/nodes/audio/sound-node.d.ts.map +0 -1
  624. package/dist/nodes/audio/sound-node.js +0 -71
  625. package/dist/nodes/audio/sound-node.js.map +0 -1
  626. package/dist/nodes/geometry/boolean-node.d.ts +0 -28
  627. package/dist/nodes/geometry/boolean-node.d.ts.map +0 -1
  628. package/dist/nodes/geometry/boolean-node.js +0 -81
  629. package/dist/nodes/geometry/boolean-node.js.map +0 -1
  630. package/dist/nodes/geometry/bounds-shape-node.d.ts +0 -149
  631. package/dist/nodes/geometry/bounds-shape-node.d.ts.map +0 -1
  632. package/dist/nodes/geometry/bounds-shape-node.js +0 -181
  633. package/dist/nodes/geometry/bounds-shape-node.js.map +0 -1
  634. package/dist/nodes/geometry/box-path-node.d.ts +0 -89
  635. package/dist/nodes/geometry/box-path-node.d.ts.map +0 -1
  636. package/dist/nodes/geometry/box-path-node.js +0 -116
  637. package/dist/nodes/geometry/box-path-node.js.map +0 -1
  638. package/dist/nodes/geometry/ellipse-node.d.ts +0 -18
  639. package/dist/nodes/geometry/ellipse-node.d.ts.map +0 -1
  640. package/dist/nodes/geometry/ellipse-node.js +0 -45
  641. package/dist/nodes/geometry/ellipse-node.js.map +0 -1
  642. package/dist/nodes/geometry/group-bounds.d.ts +0 -56
  643. package/dist/nodes/geometry/group-bounds.d.ts.map +0 -1
  644. package/dist/nodes/geometry/group-bounds.js +0 -87
  645. package/dist/nodes/geometry/group-bounds.js.map +0 -1
  646. package/dist/nodes/geometry/mask-node.d.ts +0 -33
  647. package/dist/nodes/geometry/mask-node.d.ts.map +0 -1
  648. package/dist/nodes/geometry/mask-node.js +0 -66
  649. package/dist/nodes/geometry/mask-node.js.map +0 -1
  650. package/dist/nodes/geometry/path-node.d.ts +0 -26
  651. package/dist/nodes/geometry/path-node.d.ts.map +0 -1
  652. package/dist/nodes/geometry/path-node.js +0 -58
  653. package/dist/nodes/geometry/path-node.js.map +0 -1
  654. package/dist/nodes/geometry/polygon-node.d.ts +0 -26
  655. package/dist/nodes/geometry/polygon-node.d.ts.map +0 -1
  656. package/dist/nodes/geometry/polygon-node.js +0 -47
  657. package/dist/nodes/geometry/polygon-node.js.map +0 -1
  658. package/dist/nodes/geometry/polygram-node.d.ts +0 -33
  659. package/dist/nodes/geometry/polygram-node.d.ts.map +0 -1
  660. package/dist/nodes/geometry/polygram-node.js +0 -52
  661. package/dist/nodes/geometry/polygram-node.js.map +0 -1
  662. package/dist/nodes/geometry/rect-node.d.ts +0 -38
  663. package/dist/nodes/geometry/rect-node.d.ts.map +0 -1
  664. package/dist/nodes/geometry/rect-node.js +0 -56
  665. package/dist/nodes/geometry/rect-node.js.map +0 -1
  666. package/dist/nodes/geometry/shape-node.d.ts +0 -71
  667. package/dist/nodes/geometry/shape-node.d.ts.map +0 -1
  668. package/dist/nodes/geometry/shape-node.js +0 -140
  669. package/dist/nodes/geometry/shape-node.js.map +0 -1
  670. package/dist/nodes/geometry/shape-outline.d.ts +0 -93
  671. package/dist/nodes/geometry/shape-outline.d.ts.map +0 -1
  672. package/dist/nodes/geometry/shape-outline.js +0 -470
  673. package/dist/nodes/geometry/shape-outline.js.map +0 -1
  674. package/dist/nodes/index.d.ts +0 -53
  675. package/dist/nodes/index.d.ts.map +0 -1
  676. package/dist/nodes/index.js +0 -35
  677. package/dist/nodes/index.js.map +0 -1
  678. package/dist/nodes/layout/camera-node.d.ts +0 -80
  679. package/dist/nodes/layout/camera-node.d.ts.map +0 -1
  680. package/dist/nodes/layout/camera-node.js +0 -153
  681. package/dist/nodes/layout/camera-node.js.map +0 -1
  682. package/dist/nodes/layout/orbit-camera-node.d.ts +0 -80
  683. package/dist/nodes/layout/orbit-camera-node.d.ts.map +0 -1
  684. package/dist/nodes/layout/orbit-camera-node.js +0 -118
  685. package/dist/nodes/layout/orbit-camera-node.js.map +0 -1
  686. package/dist/nodes/layout/rotated-box.d.ts +0 -20
  687. package/dist/nodes/layout/rotated-box.d.ts.map +0 -1
  688. package/dist/nodes/layout/rotated-box.js +0 -76
  689. package/dist/nodes/layout/rotated-box.js.map +0 -1
  690. package/dist/nodes/media/video-node.d.ts +0 -229
  691. package/dist/nodes/media/video-node.d.ts.map +0 -1
  692. package/dist/nodes/media/video-node.js +0 -350
  693. package/dist/nodes/media/video-node.js.map +0 -1
  694. package/dist/nodes/node/declare-paints.d.ts +0 -19
  695. package/dist/nodes/node/declare-paints.d.ts.map +0 -1
  696. package/dist/nodes/node/declare-paints.js +0 -27
  697. package/dist/nodes/node/declare-paints.js.map +0 -1
  698. package/dist/nodes/node/node-editor-state.d.ts +0 -53
  699. package/dist/nodes/node/node-editor-state.d.ts.map +0 -1
  700. package/dist/nodes/node/node-editor-state.js +0 -23
  701. package/dist/nodes/node/node-editor-state.js.map +0 -1
  702. package/dist/nodes/node/node-reactive.d.ts +0 -89
  703. package/dist/nodes/node/node-reactive.d.ts.map +0 -1
  704. package/dist/nodes/node/node-reactive.js +0 -135
  705. package/dist/nodes/node/node-reactive.js.map +0 -1
  706. package/dist/nodes/node/node-time.d.ts +0 -39
  707. package/dist/nodes/node/node-time.d.ts.map +0 -1
  708. package/dist/nodes/node/node-time.js +0 -14
  709. package/dist/nodes/node/node-time.js.map +0 -1
  710. package/dist/nodes/node/node-walk.d.ts +0 -46
  711. package/dist/nodes/node/node-walk.d.ts.map +0 -1
  712. package/dist/nodes/node/node-walk.js +0 -74
  713. package/dist/nodes/node/node-walk.js.map +0 -1
  714. package/dist/nodes/node/node.d.ts +0 -445
  715. package/dist/nodes/node/node.d.ts.map +0 -1
  716. package/dist/nodes/node/node.js +0 -745
  717. package/dist/nodes/node/node.js.map +0 -1
  718. package/dist/nodes/node/text-defaults.d.ts +0 -32
  719. package/dist/nodes/node/text-defaults.d.ts.map +0 -1
  720. package/dist/nodes/node/text-defaults.js +0 -37
  721. package/dist/nodes/node/text-defaults.js.map +0 -1
  722. package/dist/nodes/root/canvas2d-node.d.ts +0 -163
  723. package/dist/nodes/root/canvas2d-node.d.ts.map +0 -1
  724. package/dist/nodes/root/canvas2d-node.js +0 -264
  725. package/dist/nodes/root/canvas2d-node.js.map +0 -1
  726. package/dist/nodes/root/provider-node.d.ts +0 -47
  727. package/dist/nodes/root/provider-node.d.ts.map +0 -1
  728. package/dist/nodes/root/provider-node.js +0 -63
  729. package/dist/nodes/root/provider-node.js.map +0 -1
  730. package/dist/nodes/root/theme-provider-node.d.ts +0 -29
  731. package/dist/nodes/root/theme-provider-node.d.ts.map +0 -1
  732. package/dist/nodes/root/theme-provider-node.js +0 -43
  733. package/dist/nodes/root/theme-provider-node.js.map +0 -1
  734. package/dist/nodes/text/default-text-style-node.d.ts +0 -103
  735. package/dist/nodes/text/default-text-style-node.d.ts.map +0 -1
  736. package/dist/nodes/text/default-text-style-node.js +0 -146
  737. package/dist/nodes/text/default-text-style-node.js.map +0 -1
  738. package/dist/nodes/text/number-format.d.ts +0 -66
  739. package/dist/nodes/text/number-format.d.ts.map +0 -1
  740. package/dist/nodes/text/number-format.js +0 -227
  741. package/dist/nodes/text/number-format.js.map +0 -1
  742. package/dist/nodes/text/number-node.d.ts +0 -94
  743. package/dist/nodes/text/number-node.d.ts.map +0 -1
  744. package/dist/nodes/text/number-node.js +0 -86
  745. package/dist/nodes/text/number-node.js.map +0 -1
  746. package/dist/nodes/text/number-pattern.d.ts +0 -51
  747. package/dist/nodes/text/number-pattern.d.ts.map +0 -1
  748. package/dist/nodes/text/number-pattern.js +0 -77
  749. package/dist/nodes/text/number-pattern.js.map +0 -1
  750. package/dist/nodes/text/richtext-node.d.ts +0 -68
  751. package/dist/nodes/text/richtext-node.d.ts.map +0 -1
  752. package/dist/nodes/text/richtext-node.js +0 -78
  753. package/dist/nodes/text/richtext-node.js.map +0 -1
  754. package/dist/nodes/text/text-base.d.ts +0 -118
  755. package/dist/nodes/text/text-base.d.ts.map +0 -1
  756. package/dist/nodes/text/text-base.js +0 -153
  757. package/dist/nodes/text/text-base.js.map +0 -1
  758. package/dist/nodes/text/text-layout.d.ts +0 -87
  759. package/dist/nodes/text/text-layout.d.ts.map +0 -1
  760. package/dist/nodes/text/text-layout.js +0 -368
  761. package/dist/nodes/text/text-layout.js.map +0 -1
  762. package/dist/nodes/text/text-node.d.ts +0 -84
  763. package/dist/nodes/text/text-node.d.ts.map +0 -1
  764. package/dist/nodes/text/text-node.js +0 -188
  765. package/dist/nodes/text/text-node.js.map +0 -1
  766. package/dist/nodes/text/text-selection.d.ts +0 -125
  767. package/dist/nodes/text/text-selection.d.ts.map +0 -1
  768. package/dist/nodes/text/text-selection.js +0 -209
  769. package/dist/nodes/text/text-selection.js.map +0 -1
  770. package/dist/nodes/three/camera-nodes.d.ts +0 -109
  771. package/dist/nodes/three/camera-nodes.d.ts.map +0 -1
  772. package/dist/nodes/three/camera-nodes.js +0 -112
  773. package/dist/nodes/three/camera-nodes.js.map +0 -1
  774. package/dist/nodes/three/canvas3d-node.d.ts +0 -295
  775. package/dist/nodes/three/canvas3d-node.d.ts.map +0 -1
  776. package/dist/nodes/three/canvas3d-node.js +0 -486
  777. package/dist/nodes/three/canvas3d-node.js.map +0 -1
  778. package/dist/nodes/three/drawable-nodes.d.ts +0 -173
  779. package/dist/nodes/three/drawable-nodes.d.ts.map +0 -1
  780. package/dist/nodes/three/drawable-nodes.js +0 -284
  781. package/dist/nodes/three/drawable-nodes.js.map +0 -1
  782. package/dist/nodes/three/environment-nodes.d.ts +0 -106
  783. package/dist/nodes/three/environment-nodes.d.ts.map +0 -1
  784. package/dist/nodes/three/environment-nodes.js +0 -134
  785. package/dist/nodes/three/environment-nodes.js.map +0 -1
  786. package/dist/nodes/three/geometry-nodes.d.ts +0 -197
  787. package/dist/nodes/three/geometry-nodes.d.ts.map +0 -1
  788. package/dist/nodes/three/geometry-nodes.js +0 -322
  789. package/dist/nodes/three/geometry-nodes.js.map +0 -1
  790. package/dist/nodes/three/grid-geometry3d.d.ts +0 -62
  791. package/dist/nodes/three/grid-geometry3d.d.ts.map +0 -1
  792. package/dist/nodes/three/grid-geometry3d.js +0 -114
  793. package/dist/nodes/three/grid-geometry3d.js.map +0 -1
  794. package/dist/nodes/three/group3d.d.ts +0 -23
  795. package/dist/nodes/three/group3d.d.ts.map +0 -1
  796. package/dist/nodes/three/group3d.js +0 -21
  797. package/dist/nodes/three/group3d.js.map +0 -1
  798. package/dist/nodes/three/light-nodes.d.ts +0 -120
  799. package/dist/nodes/three/light-nodes.d.ts.map +0 -1
  800. package/dist/nodes/three/light-nodes.js +0 -173
  801. package/dist/nodes/three/light-nodes.js.map +0 -1
  802. package/dist/nodes/three/mesh3d.d.ts +0 -117
  803. package/dist/nodes/three/mesh3d.d.ts.map +0 -1
  804. package/dist/nodes/three/mesh3d.js +0 -147
  805. package/dist/nodes/three/mesh3d.js.map +0 -1
  806. package/dist/nodes/three/node3d.d.ts +0 -230
  807. package/dist/nodes/three/node3d.d.ts.map +0 -1
  808. package/dist/nodes/three/node3d.js +0 -337
  809. package/dist/nodes/three/node3d.js.map +0 -1
  810. package/dist/render/descriptors/latex.d.ts +0 -6
  811. package/dist/render/descriptors/latex.d.ts.map +0 -1
  812. package/dist/render/descriptors/latex.js +0 -2
  813. package/dist/render/descriptors/latex.js.map +0 -1
  814. package/dist/tween/seekable.d.ts +0 -81
  815. package/dist/tween/seekable.d.ts.map +0 -1
  816. package/dist/tween/seekable.js +0 -137
  817. package/dist/tween/seekable.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/document/expression/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAM1B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA+B;IA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AAC,CAAC;IAE9G,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;AACpE,CAAC","sourcesContent":["/**\r\n * The one scanner and the one grammar, plus the document's own dialect.\r\n *\r\n * There were two of each — this module's, and the function-plot language in\r\n * `@motionscript/math` — and they agreed on every rule they documented while\r\n * disagreeing on the parts nobody wrote down. Plot scanned `1.2.3` as a single\r\n * token, which `Number` turned into a `NaN` that parsed, compiled and rendered\r\n * an entirely invisible surface with no diagnostic anywhere. It treated `\\r` as\r\n * an unexpected character, so a pasted CRLF equation failed. It checked no arity\r\n * on its variadic functions, so `atan2(1)` was a silent `NaN`.\r\n *\r\n * What the two genuinely disagree about is a *table*: which functions exist,\r\n * whether `sin` takes degrees or radians, and how a reference is spelled. That\r\n * is {@link ExpressionDialect}, and it is the only thing this file is\r\n * parameterized by.\r\n *\r\n * Precedence is the ordinary arithmetic one, with `^` right-associative and\r\n * **implicit multiplication** between adjacent primaries — which is what makes\r\n * `4[g]+3` mean what it reads as. Note `unary` sits *above* `power`, so `-2^2`\r\n * is `-4` as in maths, and the exponent parses as a unary so `2^3^2` is 512 and\r\n * `2^-3` is legal.\r\n */\r\nimport { ExpressionError } from \"./types\";\r\nimport type { BinaryOp, ExpressionDialect, ExpressionNode, FnArity, ParsedExpression } from \"./types\";\r\n\r\nconst DEG = Math.PI / 180;\r\n\r\ninterface DocumentFn extends FnArity {\r\n apply(args: number[]): number;\r\n}\r\n\r\n/**\r\n * The document's function library.\r\n *\r\n * Deliberately small and closed: an expression is stored in a document and\r\n * evaluated by whatever version of the library opens it later, so every name\r\n * here is as much a public contract as an exported symbol. Trig is in **degrees**\r\n * because every other angle in the library is.\r\n */\r\nexport const DOCUMENT_FUNCTIONS: Record<string, DocumentFn> = {\r\n abs: { arity: [1, 1], apply: (a) => Math.abs(a[0]) },\r\n sign: { arity: [1, 1], apply: (a) => Math.sign(a[0]) },\r\n sqrt: { arity: [1, 1], apply: (a) => Math.sqrt(a[0]) },\r\n floor: { arity: [1, 1], apply: (a) => Math.floor(a[0]) },\r\n ceil: { arity: [1, 1], apply: (a) => Math.ceil(a[0]) },\r\n round: { arity: [1, 2], apply: (a) => (a.length > 1 && a[1] !== 0 ? Math.round(a[0] / a[1]) * a[1] : Math.round(a[0])) },\r\n min: { arity: [1, Infinity], apply: (a) => Math.min(...a) },\r\n max: { arity: [1, Infinity], apply: (a) => Math.max(...a) },\r\n clamp: { arity: [3, 3], apply: (a) => Math.min(Math.max(a[0], a[1]), a[2]) },\r\n mod: { arity: [2, 2], apply: (a) => ((a[0] % a[1]) + a[1]) % a[1] },\r\n pow: { arity: [2, 2], apply: (a) => a[0] ** a[1] },\r\n log: { arity: [1, 2], apply: (a) => (a.length > 1 ? Math.log(a[0]) / Math.log(a[1]) : Math.log(a[0])) },\r\n exp: { arity: [1, 1], apply: (a) => Math.exp(a[0]) },\r\n mix: { arity: [3, 3], apply: (a) => a[0] + (a[1] - a[0]) * a[2] },\r\n smoothstep: {\r\n arity: [3, 3],\r\n apply: (a) => {\r\n if (Number.isNaN(a[0]) || Number.isNaN(a[1]) || Number.isNaN(a[2])) return NaN;\r\n // Equal edges: a step at the edge, like `step` — no divide by zero.\r\n if (a[0] === a[1]) return a[2] < a[0] ? 0 : 1;\r\n const t = Math.min(Math.max((a[2] - a[0]) / (a[1] - a[0]), 0), 1);\r\n return t * t * (3 - 2 * t);\r\n },\r\n },\r\n step: { arity: [2, 2], apply: (a) => (Number.isNaN(a[0]) || Number.isNaN(a[1]) ? NaN : a[1] < a[0] ? 0 : 1) },\r\n sin: { arity: [1, 1], apply: (a) => Math.sin(a[0] * DEG) },\r\n cos: { arity: [1, 1], apply: (a) => Math.cos(a[0] * DEG) },\r\n tan: { arity: [1, 1], apply: (a) => Math.tan(a[0] * DEG) },\r\n asin: { arity: [1, 1], apply: (a) => Math.asin(a[0]) / DEG },\r\n acos: { arity: [1, 1], apply: (a) => Math.acos(a[0]) / DEG },\r\n atan: { arity: [1, 1], apply: (a) => Math.atan(a[0]) / DEG },\r\n atan2: { arity: [2, 2], apply: (a) => Math.atan2(a[0], a[1]) / DEG },\r\n hypot: { arity: [2, Infinity], apply: (a) => Math.hypot(...a) },\r\n};\r\n\r\n/** Bare identifiers that are values rather than calls. */\r\nconst DOCUMENT_CONSTANTS: Record<string, number> = {\r\n pi: Math.PI,\r\n tau: Math.PI * 2,\r\n e: Math.E,\r\n};\r\n\r\n/** The language a `\"=…\"` prop is written in. */\r\nexport const DOCUMENT_DIALECT: ExpressionDialect = {\r\n functions: DOCUMENT_FUNCTIONS,\r\n constants: DOCUMENT_CONSTANTS,\r\n refs: \"bracket\",\r\n unknownName: (name) =>\r\n `unknown name \"${name}\" — a variable is referenced as \"[${name}]\"; ` +\r\n `bare names are the constants ${sortedKeys(DOCUMENT_CONSTANTS).join(\", \")}`,\r\n};\r\n\r\n/** Sorted, so a message or a completion list is stable. */\r\nexport function sortedKeys(table: Record<string, unknown>): string[] {\r\n return Object.keys(table).sort();\r\n}\r\n\r\n// ── Scanner ──────────────────────────────────────────────────────────────────\r\n\r\ntype TokenKind = \"number\" | \"ref\" | \"ident\" | \"op\" | \"(\" | \")\" | \",\" | \"end\";\r\n\r\ninterface Token {\r\n kind: TokenKind;\r\n /** The identifier, operator or reference name. Empty for numbers. */\r\n text: string;\r\n /** Parsed value, for numbers. */\r\n value: number;\r\n pos: number;\r\n}\r\n\r\nconst OPERATORS = new Set([\"+\", \"-\", \"*\", \"/\", \"%\", \"^\"]);\r\n\r\nfunction isDigit(ch: string | undefined): boolean {\r\n return ch !== undefined && ch >= \"0\" && ch <= \"9\";\r\n}\r\n\r\nfunction tokenize(source: string, dialect: ExpressionDialect): Token[] {\r\n const tokens: Token[] = [];\r\n let i = 0;\r\n\r\n while (i < source.length) {\r\n const ch = source[i];\r\n\r\n if (ch === \" \" || ch === \"\\t\" || ch === \"\\n\" || ch === \"\\r\") {\r\n i++;\r\n continue;\r\n }\r\n\r\n if (isDigit(ch) || (ch === \".\" && isDigit(source[i + 1]))) {\r\n const start = i;\r\n while (isDigit(source[i])) i++;\r\n if (source[i] === \".\") {\r\n i++;\r\n while (isDigit(source[i])) i++;\r\n }\r\n if (source[i] === \"e\" || source[i] === \"E\") {\r\n const mark = i;\r\n i++;\r\n if (source[i] === \"+\" || source[i] === \"-\") i++;\r\n if (isDigit(source[i])) {\r\n while (isDigit(source[i])) i++;\r\n } else {\r\n // `2e` followed by something else is `2` times the identifier\r\n // `e`, not a malformed exponent.\r\n i = mark;\r\n }\r\n }\r\n // A second `.` ends a number that has already had one. Both parsers\r\n // this replaces got here differently and both got it wrong: one\r\n // scanned `1.2.3` as a single token that `Number` turned into a\r\n // silent `NaN`, the other split it into `1.2 * 0.3`. Neither is\r\n // anything anyone wrote on purpose.\r\n if (source[i] === \".\") throw new ExpressionError('unexpected character \".\"', source, i);\r\n tokens.push({ kind: \"number\", text: \"\", value: Number(source.slice(start, i)), pos: start });\r\n continue;\r\n }\r\n\r\n // `[` is legal only where a reference is spelled with one, so a plot\r\n // equation gets \"unexpected character\" here rather than failing later\r\n // with a message about variable references it has never heard of.\r\n if (ch === \"[\" && dialect.refs === \"bracket\") {\r\n const start = i;\r\n const end = source.indexOf(\"]\", i + 1);\r\n if (end === -1) throw new ExpressionError(\"unclosed `[` — a variable reference is written `[id]`\", source, start);\r\n const name = source.slice(i + 1, end).trim();\r\n if (name.length === 0) throw new ExpressionError(\"empty variable reference `[]`\", source, start);\r\n if (name.includes(\"[\")) throw new ExpressionError(\"variable references cannot nest\", source, start);\r\n tokens.push({ kind: \"ref\", text: name, value: 0, pos: start });\r\n i = end + 1;\r\n continue;\r\n }\r\n\r\n if (/[A-Za-z_]/.test(ch)) {\r\n const start = i;\r\n while (i < source.length && /[A-Za-z0-9_]/.test(source[i])) i++;\r\n tokens.push({ kind: \"ident\", text: source.slice(start, i), value: 0, pos: start });\r\n continue;\r\n }\r\n\r\n if (OPERATORS.has(ch)) {\r\n tokens.push({ kind: \"op\", text: ch, value: 0, pos: i++ });\r\n continue;\r\n }\r\n if (ch === \"(\" || ch === \")\" || ch === \",\") {\r\n tokens.push({ kind: ch as TokenKind, text: ch, value: 0, pos: i++ });\r\n continue;\r\n }\r\n\r\n throw new ExpressionError(`unexpected character \"${ch}\"`, source, i);\r\n }\r\n\r\n tokens.push({ kind: \"end\", text: \"\", value: 0, pos: source.length });\r\n return tokens;\r\n}\r\n\r\n// ── Grammar ──────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Parse a formula against a dialect.\r\n *\r\n * `source` is the formula alone — the document's `=` is stripped by the walk\r\n * that recognised it, because the marker is not part of any grammar.\r\n */\r\nexport function parse(source: string, dialect: ExpressionDialect = DOCUMENT_DIALECT): ParsedExpression {\r\n if (source.trim().length === 0) throw new ExpressionError(\"empty expression\", source);\r\n\r\n const tokens = tokenize(source, dialect);\r\n const refs: string[] = [];\r\n let index = 0;\r\n\r\n const peek = (): Token => tokens[index];\r\n const next = (): Token => tokens[index++];\r\n\r\n const addRef = (name: string): ExpressionNode => {\r\n if (!refs.includes(name)) refs.push(name);\r\n return { kind: \"ref\", name };\r\n };\r\n\r\n /** True when the token can begin a primary — the test implicit `*` turns on. */\r\n const startsPrimary = (t: Token): boolean =>\r\n t.kind === \"number\" || t.kind === \"ref\" || t.kind === \"ident\" || t.kind === \"(\";\r\n\r\n function parseAdditive(): ExpressionNode {\r\n let left = parseMultiplicative();\r\n for (;;) {\r\n const t = peek();\r\n if (t.kind === \"op\" && (t.text === \"+\" || t.text === \"-\")) {\r\n next();\r\n left = { kind: \"binary\", op: t.text, left, right: parseMultiplicative() };\r\n continue;\r\n }\r\n return left;\r\n }\r\n }\r\n\r\n function parseMultiplicative(): ExpressionNode {\r\n let left = parseUnary();\r\n for (;;) {\r\n const t = peek();\r\n if (t.kind === \"op\" && (t.text === \"*\" || t.text === \"/\" || t.text === \"%\")) {\r\n next();\r\n left = { kind: \"binary\", op: t.text as BinaryOp, left, right: parseUnary() };\r\n continue;\r\n }\r\n // `4[g]`, `2(x+1)`, `[a][b]`, `2pi` — juxtaposition is multiplication.\r\n if (startsPrimary(t)) {\r\n left = { kind: \"binary\", op: \"*\", left, right: parseUnary() };\r\n continue;\r\n }\r\n return left;\r\n }\r\n }\r\n\r\n function parseUnary(): ExpressionNode {\r\n const t = peek();\r\n if (t.kind === \"op\" && (t.text === \"-\" || t.text === \"+\")) {\r\n next();\r\n const operand = parseUnary();\r\n return t.text === \"-\" ? { kind: \"unary\", op: \"-\", operand } : operand;\r\n }\r\n return parsePower();\r\n }\r\n\r\n function parsePower(): ExpressionNode {\r\n const base = parsePrimary();\r\n const t = peek();\r\n if (t.kind === \"op\" && t.text === \"^\") {\r\n next();\r\n // Right-associative, and binding tighter than unary minus on its\r\n // right: `2^-1` is a half, not an error.\r\n return { kind: \"binary\", op: \"^\", left: base, right: parseUnary() };\r\n }\r\n return base;\r\n }\r\n\r\n function parseCall(name: string, pos: number): ExpressionNode {\r\n // Own keys only: `toString(1)` must be an unknown function, not a lookup\r\n // that finds `Object.prototype`'s.\r\n const def = Object.hasOwn(dialect.functions, name) ? dialect.functions[name] : undefined;\r\n if (!def) {\r\n throw new ExpressionError(\r\n `unknown function \"${name}\" — available: ${sortedKeys(dialect.functions).join(\", \")}`,\r\n source, pos,\r\n );\r\n }\r\n const args: ExpressionNode[] = [];\r\n if (peek().kind !== \")\") {\r\n for (;;) {\r\n args.push(parseAdditive());\r\n if (peek().kind !== \",\") break;\r\n next();\r\n }\r\n }\r\n const close = next();\r\n if (close.kind !== \")\") throw new ExpressionError(`expected \\`)\\` closing ${name}(`, source, close.pos);\r\n\r\n const [min, max] = def.arity;\r\n if (args.length < min || args.length > max) {\r\n const want = max === Infinity ? `at least ${min}` : min === max ? `${min}` : `${min}–${max}`;\r\n // Singular only when `want` names the number one (`1`, `at least 1`), never for a range.\r\n const plural = (max === Infinity || min === max) && min === 1 ? \"\" : \"s\";\r\n throw new ExpressionError(\r\n `${name}() takes ${want} argument${plural}, got ${args.length}`,\r\n source, pos,\r\n );\r\n }\r\n return { kind: \"call\", name, args };\r\n }\r\n\r\n function parsePrimary(): ExpressionNode {\r\n const t = next();\r\n switch (t.kind) {\r\n case \"number\":\r\n return { kind: \"const\", value: t.value };\r\n case \"ref\":\r\n return addRef(t.text);\r\n case \"(\": {\r\n const inner = parseAdditive();\r\n const close = next();\r\n if (close.kind !== \")\") throw new ExpressionError(\"expected `)`\", source, close.pos);\r\n return inner;\r\n }\r\n case \"ident\": {\r\n if (peek().kind === \"(\") {\r\n next();\r\n return parseCall(t.text, t.pos);\r\n }\r\n // A constant is folded here, before a bare identifier can become\r\n // a reference — so a dialect's constant name can never also be\r\n // one of its free variables.\r\n const constant = Object.hasOwn(dialect.constants, t.text) ? dialect.constants[t.text] : undefined;\r\n if (constant !== undefined) return { kind: \"const\", value: constant };\r\n if (dialect.refs === \"bare\") return addRef(t.text);\r\n throw new ExpressionError(dialect.unknownName(t.text), source, t.pos);\r\n }\r\n default:\r\n throw new ExpressionError(\r\n t.kind === \"end\" ? \"expression ends early\" : `unexpected \"${t.text}\"`,\r\n source, t.pos,\r\n );\r\n }\r\n }\r\n\r\n const root = parseAdditive();\r\n const trailing = peek();\r\n if (trailing.kind !== \"end\") throw new ExpressionError(`unexpected \"${trailing.text}\"`, source, trailing.pos);\r\n\r\n return { source, root, refs, passthrough: root.kind === \"ref\" };\r\n}\r\n"]}
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/document/expression/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAM1B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA+B;IAC1D,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,K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EAAE,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;AACpE,CAAC","sourcesContent":["/**\n * The one scanner and the one grammar, plus the document's own dialect.\n *\n * There were two of each — this module's, and the function-plot language in\n * `@motionscript/math` — and they agreed on every rule they documented while\n * disagreeing on the parts nobody wrote down. Plot scanned `1.2.3` as a single\n * token, which `Number` turned into a `NaN` that parsed, compiled and rendered\n * an entirely invisible surface with no diagnostic anywhere. It treated `\\r` as\n * an unexpected character, so a pasted CRLF equation failed. It checked no arity\n * on its variadic functions, so `atan2(1)` was a silent `NaN`.\n *\n * What the two genuinely disagree about is a *table*: which functions exist,\n * whether `sin` takes degrees or radians, and how a reference is spelled. That\n * is {@link ExpressionDialect}, and it is the only thing this file is\n * parameterized by.\n *\n * Precedence is the ordinary arithmetic one, with `^` right-associative and\n * **implicit multiplication** between adjacent primaries — which is what makes\n * `4[g]+3` mean what it reads as. Note `unary` sits *above* `power`, so `-2^2`\n * is `-4` as in maths, and the exponent parses as a unary so `2^3^2` is 512 and\n * `2^-3` is legal.\n */\nimport { ExpressionError } from \"./types\";\nimport type { BinaryOp, ExpressionDialect, ExpressionNode, FnArity, ParsedExpression } from \"./types\";\n\nconst DEG = Math.PI / 180;\n\ninterface DocumentFn extends FnArity {\n apply(args: number[]): number;\n}\n\n/**\n * The document's function library.\n *\n * Deliberately small and closed: an expression is stored in a document and\n * evaluated by whatever version of the library opens it later, so every name\n * here is as much a public contract as an exported symbol. Trig is in **degrees**\n * because every other angle in the library is.\n */\nexport const DOCUMENT_FUNCTIONS: Record<string, DocumentFn> = {\n abs: { arity: [1, 1], apply: (a) => Math.abs(a[0]) },\n sign: { arity: [1, 1], apply: (a) => Math.sign(a[0]) },\n sqrt: { arity: [1, 1], apply: (a) => Math.sqrt(a[0]) },\n floor: { arity: [1, 1], apply: (a) => Math.floor(a[0]) },\n ceil: { arity: [1, 1], apply: (a) => Math.ceil(a[0]) },\n round: { arity: [1, 2], apply: (a) => (a.length > 1 && a[1] !== 0 ? Math.round(a[0] / a[1]) * a[1] : Math.round(a[0])) },\n min: { arity: [1, Infinity], apply: (a) => Math.min(...a) },\n max: { arity: [1, Infinity], apply: (a) => Math.max(...a) },\n clamp: { arity: [3, 3], apply: (a) => Math.min(Math.max(a[0], a[1]), a[2]) },\n mod: { arity: [2, 2], apply: (a) => ((a[0] % a[1]) + a[1]) % a[1] },\n pow: { arity: [2, 2], apply: (a) => a[0] ** a[1] },\n log: { arity: [1, 2], apply: (a) => (a.length > 1 ? Math.log(a[0]) / Math.log(a[1]) : Math.log(a[0])) },\n exp: { arity: [1, 1], apply: (a) => Math.exp(a[0]) },\n mix: { arity: [3, 3], apply: (a) => a[0] + (a[1] - a[0]) * a[2] },\n smoothstep: {\n arity: [3, 3],\n apply: (a) => {\n if (Number.isNaN(a[0]) || Number.isNaN(a[1]) || Number.isNaN(a[2])) return NaN;\n // Equal edges: a step at the edge, like `step` — no divide by zero.\n if (a[0] === a[1]) return a[2] < a[0] ? 0 : 1;\n const t = Math.min(Math.max((a[2] - a[0]) / (a[1] - a[0]), 0), 1);\n return t * t * (3 - 2 * t);\n },\n },\n step: { arity: [2, 2], apply: (a) => (Number.isNaN(a[0]) || Number.isNaN(a[1]) ? NaN : a[1] < a[0] ? 0 : 1) },\n sin: { arity: [1, 1], apply: (a) => Math.sin(a[0] * DEG) },\n cos: { arity: [1, 1], apply: (a) => Math.cos(a[0] * DEG) },\n tan: { arity: [1, 1], apply: (a) => Math.tan(a[0] * DEG) },\n asin: { arity: [1, 1], apply: (a) => Math.asin(a[0]) / DEG },\n acos: { arity: [1, 1], apply: (a) => Math.acos(a[0]) / DEG },\n atan: { arity: [1, 1], apply: (a) => Math.atan(a[0]) / DEG },\n atan2: { arity: [2, 2], apply: (a) => Math.atan2(a[0], a[1]) / DEG },\n hypot: { arity: [2, Infinity], apply: (a) => Math.hypot(...a) },\n};\n\n/** Bare identifiers that are values rather than calls. */\nconst DOCUMENT_CONSTANTS: Record<string, number> = {\n pi: Math.PI,\n tau: Math.PI * 2,\n e: Math.E,\n};\n\n/** The language a `\"=…\"` prop is written in. */\nexport const DOCUMENT_DIALECT: ExpressionDialect = {\n functions: DOCUMENT_FUNCTIONS,\n constants: DOCUMENT_CONSTANTS,\n refs: \"bracket\",\n unknownName: (name) =>\n `unknown name \"${name}\" — a variable is referenced as \"[${name}]\"; ` +\n `bare names are the constants ${sortedKeys(DOCUMENT_CONSTANTS).join(\", \")}`,\n};\n\n/** Sorted, so a message or a completion list is stable. */\nexport function sortedKeys(table: Record<string, unknown>): string[] {\n return Object.keys(table).sort();\n}\n\n// ── Scanner ──────────────────────────────────────────────────────────────────\n\ntype TokenKind = \"number\" | \"ref\" | \"ident\" | \"op\" | \"(\" | \")\" | \",\" | \"end\";\n\ninterface Token {\n kind: TokenKind;\n /** The identifier, operator or reference name. Empty for numbers. */\n text: string;\n /** Parsed value, for numbers. */\n value: number;\n pos: number;\n}\n\nconst OPERATORS = new Set([\"+\", \"-\", \"*\", \"/\", \"%\", \"^\"]);\n\nfunction isDigit(ch: string | undefined): boolean {\n return ch !== undefined && ch >= \"0\" && ch <= \"9\";\n}\n\nfunction tokenize(source: string, dialect: ExpressionDialect): Token[] {\n const tokens: Token[] = [];\n let i = 0;\n\n while (i < source.length) {\n const ch = source[i];\n\n if (ch === \" \" || ch === \"\\t\" || ch === \"\\n\" || ch === \"\\r\") {\n i++;\n continue;\n }\n\n if (isDigit(ch) || (ch === \".\" && isDigit(source[i + 1]))) {\n const start = i;\n while (isDigit(source[i])) i++;\n if (source[i] === \".\") {\n i++;\n while (isDigit(source[i])) i++;\n }\n if (source[i] === \"e\" || source[i] === \"E\") {\n const mark = i;\n i++;\n if (source[i] === \"+\" || source[i] === \"-\") i++;\n if (isDigit(source[i])) {\n while (isDigit(source[i])) i++;\n } else {\n // `2e` followed by something else is `2` times the identifier\n // `e`, not a malformed exponent.\n i = mark;\n }\n }\n // A second `.` ends a number that has already had one. Both parsers\n // this replaces got here differently and both got it wrong: one\n // scanned `1.2.3` as a single token that `Number` turned into a\n // silent `NaN`, the other split it into `1.2 * 0.3`. Neither is\n // anything anyone wrote on purpose.\n if (source[i] === \".\") throw new ExpressionError('unexpected character \".\"', source, i);\n tokens.push({ kind: \"number\", text: \"\", value: Number(source.slice(start, i)), pos: start });\n continue;\n }\n\n // `[` is legal only where a reference is spelled with one, so a plot\n // equation gets \"unexpected character\" here rather than failing later\n // with a message about variable references it has never heard of.\n if (ch === \"[\" && dialect.refs === \"bracket\") {\n const start = i;\n const end = source.indexOf(\"]\", i + 1);\n if (end === -1) throw new ExpressionError(\"unclosed `[` — a variable reference is written `[id]`\", source, start);\n const name = source.slice(i + 1, end).trim();\n if (name.length === 0) throw new ExpressionError(\"empty variable reference `[]`\", source, start);\n if (name.includes(\"[\")) throw new ExpressionError(\"variable references cannot nest\", source, start);\n tokens.push({ kind: \"ref\", text: name, value: 0, pos: start });\n i = end + 1;\n continue;\n }\n\n if (/[A-Za-z_]/.test(ch)) {\n const start = i;\n while (i < source.length && /[A-Za-z0-9_]/.test(source[i])) i++;\n tokens.push({ kind: \"ident\", text: source.slice(start, i), value: 0, pos: start });\n continue;\n }\n\n if (OPERATORS.has(ch)) {\n tokens.push({ kind: \"op\", text: ch, value: 0, pos: i++ });\n continue;\n }\n if (ch === \"(\" || ch === \")\" || ch === \",\") {\n tokens.push({ kind: ch as TokenKind, text: ch, value: 0, pos: i++ });\n continue;\n }\n\n throw new ExpressionError(`unexpected character \"${ch}\"`, source, i);\n }\n\n tokens.push({ kind: \"end\", text: \"\", value: 0, pos: source.length });\n return tokens;\n}\n\n// ── Grammar ──────────────────────────────────────────────────────────────────\n\n/**\n * Parse a formula against a dialect.\n *\n * `source` is the formula alone — the document's `=` is stripped by the walk\n * that recognised it, because the marker is not part of any grammar.\n */\nexport function parse(source: string, dialect: ExpressionDialect = DOCUMENT_DIALECT): ParsedExpression {\n if (source.trim().length === 0) throw new ExpressionError(\"empty expression\", source);\n\n const tokens = tokenize(source, dialect);\n const refs: string[] = [];\n let index = 0;\n\n const peek = (): Token => tokens[index];\n const next = (): Token => tokens[index++];\n\n const addRef = (name: string): ExpressionNode => {\n if (!refs.includes(name)) refs.push(name);\n return { kind: \"ref\", name };\n };\n\n /** True when the token can begin a primary — the test implicit `*` turns on. */\n const startsPrimary = (t: Token): boolean =>\n t.kind === \"number\" || t.kind === \"ref\" || t.kind === \"ident\" || t.kind === \"(\";\n\n function parseAdditive(): ExpressionNode {\n let left = parseMultiplicative();\n for (;;) {\n const t = peek();\n if (t.kind === \"op\" && (t.text === \"+\" || t.text === \"-\")) {\n next();\n left = { kind: \"binary\", op: t.text, left, right: parseMultiplicative() };\n continue;\n }\n return left;\n }\n }\n\n function parseMultiplicative(): ExpressionNode {\n let left = parseUnary();\n for (;;) {\n const t = peek();\n if (t.kind === \"op\" && (t.text === \"*\" || t.text === \"/\" || t.text === \"%\")) {\n next();\n left = { kind: \"binary\", op: t.text as BinaryOp, left, right: parseUnary() };\n continue;\n }\n // `4[g]`, `2(x+1)`, `[a][b]`, `2pi` — juxtaposition is multiplication.\n if (startsPrimary(t)) {\n left = { kind: \"binary\", op: \"*\", left, right: parseUnary() };\n continue;\n }\n return left;\n }\n }\n\n function parseUnary(): ExpressionNode {\n const t = peek();\n if (t.kind === \"op\" && (t.text === \"-\" || t.text === \"+\")) {\n next();\n const operand = parseUnary();\n return t.text === \"-\" ? { kind: \"unary\", op: \"-\", operand } : operand;\n }\n return parsePower();\n }\n\n function parsePower(): ExpressionNode {\n const base = parsePrimary();\n const t = peek();\n if (t.kind === \"op\" && t.text === \"^\") {\n next();\n // Right-associative, and binding tighter than unary minus on its\n // right: `2^-1` is a half, not an error.\n return { kind: \"binary\", op: \"^\", left: base, right: parseUnary() };\n }\n return base;\n }\n\n function parseCall(name: string, pos: number): ExpressionNode {\n // Own keys only: `toString(1)` must be an unknown function, not a lookup\n // that finds `Object.prototype`'s.\n const def = Object.hasOwn(dialect.functions, name) ? dialect.functions[name] : undefined;\n if (!def) {\n throw new ExpressionError(\n `unknown function \"${name}\" — available: ${sortedKeys(dialect.functions).join(\", \")}`,\n source, pos,\n );\n }\n const args: ExpressionNode[] = [];\n if (peek().kind !== \")\") {\n for (;;) {\n args.push(parseAdditive());\n if (peek().kind !== \",\") break;\n next();\n }\n }\n const close = next();\n if (close.kind !== \")\") throw new ExpressionError(`expected \\`)\\` closing ${name}(`, source, close.pos);\n\n const [min, max] = def.arity;\n if (args.length < min || args.length > max) {\n const want = max === Infinity ? `at least ${min}` : min === max ? `${min}` : `${min}–${max}`;\n // Singular only when `want` names the number one (`1`, `at least 1`), never for a range.\n const plural = (max === Infinity || min === max) && min === 1 ? \"\" : \"s\";\n throw new ExpressionError(\n `${name}() takes ${want} argument${plural}, got ${args.length}`,\n source, pos,\n );\n }\n return { kind: \"call\", name, args };\n }\n\n function parsePrimary(): ExpressionNode {\n const t = next();\n switch (t.kind) {\n case \"number\":\n return { kind: \"const\", value: t.value };\n case \"ref\":\n return addRef(t.text);\n case \"(\": {\n const inner = parseAdditive();\n const close = next();\n if (close.kind !== \")\") throw new ExpressionError(\"expected `)`\", source, close.pos);\n return inner;\n }\n case \"ident\": {\n if (peek().kind === \"(\") {\n next();\n return parseCall(t.text, t.pos);\n }\n // A constant is folded here, before a bare identifier can become\n // a reference — so a dialect's constant name can never also be\n // one of its free variables.\n const constant = Object.hasOwn(dialect.constants, t.text) ? dialect.constants[t.text] : undefined;\n if (constant !== undefined) return { kind: \"const\", value: constant };\n if (dialect.refs === \"bare\") return addRef(t.text);\n throw new ExpressionError(dialect.unknownName(t.text), source, t.pos);\n }\n default:\n throw new ExpressionError(\n t.kind === \"end\" ? \"expression ends early\" : `unexpected \"${t.text}\"`,\n source, t.pos,\n );\n }\n }\n\n const root = parseAdditive();\n const trailing = peek();\n if (trailing.kind !== \"end\") throw new ExpressionError(`unexpected \"${trailing.text}\"`, source, trailing.pos);\n\n return { source, root, refs, passthrough: root.kind === \"ref\" };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ref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AC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;;gBACtC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACL,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import { expressionOps } from \"./ops\";\r\n\r\n/**\r\n * A reference split into the node key and prop it names, or `undefined` when it\r\n * has no dot and so names a variable instead.\r\n *\r\n * The dot is the whole discriminator, in the parser (which hands the bracket's\r\n * contents over as one opaque name), the validator, and `ClipTimeline`.\r\n */\r\nexport function splitNodeRef(ref: string): { key: string; prop: string } | undefined {\r\n const dot = ref.indexOf(\".\");\r\n return dot < 0 ? undefined : { key: ref.slice(0, dot), prop: ref.slice(dot + 1) };\r\n}\r\n\r\nexport interface ExpressionRefs {\r\n /** Variable ids read, de-duplicated, in first-seen order. */\r\n vars: string[];\r\n /** `[key, prop]` pairs read, de-duplicated, in first-seen order. */\r\n keys: Array<[key: string, prop: string]>;\r\n /** Expressions that failed to parse; their references are not in the lists above. */\r\n unparsable: number;\r\n}\r\n\r\n/** Every reference inside every expression in an authored value, at any depth. */\r\nexport function expressionRefs(value: unknown, path = \"\"): ExpressionRefs {\r\n const vars: string[] = [];\r\n const keys: Array<[string, string]> = [];\r\n let unparsable = 0;\r\n const seen = new Set<string>();\r\n for (const site of expressionOps.collect(value, path)) {\r\n const parsed = expressionOps.tryParse(site.source);\r\n if (\"error\" in parsed) {\r\n unparsable++;\r\n continue;\r\n }\r\n for (const ref of parsed.expression.refs) {\r\n if (seen.has(ref)) continue;\r\n seen.add(ref);\r\n const node = splitNodeRef(ref);\r\n if (node) keys.push([node.key, node.prop]);\r\n else vars.push(ref);\r\n }\r\n }\r\n return { vars, keys, unparsable };\r\n}\r\n"]}
1
+ {"version":3,"file":"refs.js","sourceRoot":"","sources":["../../../src/document/expression/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACL,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import { expressionOps } from \"./ops\";\n\n/**\n * A reference split into the node key and prop it names, or `undefined` when it\n * has no dot and so names a variable instead.\n *\n * The dot is the whole discriminator, in the parser (which hands the bracket's\n * contents over as one opaque name), the validator, and `ClipTimeline`.\n */\nexport function splitNodeRef(ref: string): { key: string; prop: string } | undefined {\n const dot = ref.indexOf(\".\");\n return dot < 0 ? undefined : { key: ref.slice(0, dot), prop: ref.slice(dot + 1) };\n}\n\nexport interface ExpressionRefs {\n /** Variable ids read, de-duplicated, in first-seen order. */\n vars: string[];\n /** `[key, prop]` pairs read, de-duplicated, in first-seen order. */\n keys: Array<[key: string, prop: string]>;\n /** Expressions that failed to parse; their references are not in the lists above. */\n unparsable: number;\n}\n\n/** Every reference inside every expression in an authored value, at any depth. */\nexport function expressionRefs(value: unknown, path = \"\"): ExpressionRefs {\n const vars: string[] = [];\n const keys: Array<[string, string]> = [];\n let unparsable = 0;\n const seen = new Set<string>();\n for (const site of expressionOps.collect(value, path)) {\n const parsed = expressionOps.tryParse(site.source);\n if (\"error\" in parsed) {\n unparsable++;\n continue;\n }\n for (const ref of parsed.expression.refs) {\n if (seen.has(ref)) continue;\n seen.add(ref);\n const node = splitNodeRef(ref);\n if (node) keys.push([node.key, node.prop]);\n else vars.push(ref);\n }\n }\n return { vars, keys, unparsable };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/document/expression/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,yFAAyF;AACzF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACtC,iFAAiF;IACxE,MAAM,CAAS;IACxB,sFAAsF;IAC7E,QAAQ,CAAS;IAC1B,6EAA6E;IACpE,IAAI,CAAU;IAEvB,YAAY,OAAe,EAAE,MAAc,EAAE,QAAQ,GAAG,CAAC,CAAC,EAAE,IAAa;QACrE,MAAM,KAAK,GAAG,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,QAAQ,GAAG,CAAC,QAAQ,MAAM,IAAI,CAAC,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC;QACrG,KAAK,CAAC,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ","sourcesContent":["/**\r\n * Every type the expression module names, in one place.\r\n *\r\n * The vocabulary is small and worth seeing at once, because the whole module is\r\n * four representations and the steps between them:\r\n *\r\n * a prop value ──▶ \"=4[g]+3\" ──▶ ExpressionNode ──▶ () => unknown\r\n * at any depth the marked the AST, per a prop binding\r\n * (walk) string dialect (parse) (compile)\r\n *\r\n * The `=` appears in exactly one of those steps. It marks a *document prop* as a\r\n * formula, which is recognition, not grammar — `=` is not a legal character in\r\n * any dialect — so the walk strips it and the parser never sees one.\r\n */\r\n\r\n/** Thrown for a formula that cannot be parsed or whose reference resolves to nothing. */\r\nexport class ExpressionError extends Error {\r\n /** The formula as the parser received it: no marker, and no surrounding prop. */\r\n readonly source: string;\r\n /** Character offset into {@link source}, or `-1` when the whole thing is at fault. */\r\n readonly position: number;\r\n /** Where in the props bag it was written, JSON-Pointer style, when known. */\r\n readonly path?: string;\r\n\r\n constructor(message: string, source: string, position = -1, path?: string) {\r\n const where = position >= 0 ? ` (at character ${position + 1} of \"${source}\")` : ` (in \"${source}\")`;\r\n super(`${message}${where}${path ? ` at ${path}` : \"\"}`);\r\n this.name = \"ExpressionError\";\r\n this.source = source;\r\n this.position = position;\r\n this.path = path;\r\n }\r\n}\r\n\r\n// ── The syntax tree ──────────────────────────────────────────────────────────\r\n\r\nexport type BinaryOp = \"+\" | \"-\" | \"*\" | \"/\" | \"%\" | \"^\";\r\n\r\n/** One node of a parsed formula. Kept public so a host can lint or rewrite one. */\r\nexport type ExpressionNode =\r\n | { kind: \"const\"; value: number }\r\n | { kind: \"ref\"; name: string }\r\n | { kind: \"unary\"; op: \"-\"; operand: ExpressionNode }\r\n | { kind: \"binary\"; op: BinaryOp; left: ExpressionNode; right: ExpressionNode }\r\n | { kind: \"call\"; name: string; args: ExpressionNode[] };\r\n\r\n/** A formula, parsed. Resolver-free, so it can be checked without a scene. */\r\nexport interface ParsedExpression {\r\n /** The formula's text as the parser received it — no marker. */\r\n readonly source: string;\r\n readonly root: ExpressionNode;\r\n /** Names it reads, de-duplicated, in first-seen order. */\r\n readonly refs: readonly string[];\r\n /**\r\n * True when the formula is exactly one reference and nothing else.\r\n *\r\n * The passthrough case: the document's compiled binding returns the\r\n * variable's value untouched rather than coercing it to a number, which is\r\n * what lets a variable hold a colour, a `Vector2` or any other prop value.\r\n * A dialect whose references are bare identifiers sets it for a lone\r\n * variable too (`\"x\"`), where it means nothing — only the document's\r\n * compiler reads it.\r\n */\r\n readonly passthrough: boolean;\r\n}\r\n\r\n// ── Dialects ─────────────────────────────────────────────────────────────────\r\n\r\n/** What the parser needs to know about a function. What it *does* is the back end's. */\r\nexport interface FnArity {\r\n /** Minimum and maximum argument count; `Infinity` for variadic. */\r\n arity: [number, number];\r\n}\r\n\r\n/**\r\n * One language over the shared grammar.\r\n *\r\n * The grammar is fixed — precedence, implicit multiplication, right-associative\r\n * `^`, the scientific-notation rule — and everything a language is free to\r\n * disagree about is here. That is what lets the document's `sin` be degrees and\r\n * a function plot's be radians without two parsers: the trig unit is a property\r\n * of a table, not of the grammar.\r\n */\r\nexport interface ExpressionDialect {\r\n /** Names callable as `f(…)`, and how many arguments each takes. */\r\n functions: Record<string, FnArity>;\r\n /** Bare identifiers that are values. Folded at parse time, so one can never also be a reference. */\r\n constants: Record<string, number>;\r\n /**\r\n * How a reference is spelled. `\"bracket\"` is `[id]`, and is the only mode in\r\n * which `[` is a legal character; `\"bare\"` makes any identifier that is not a\r\n * call or a constant a reference.\r\n */\r\n refs: \"bracket\" | \"bare\";\r\n /** What an identifier that resolves to nothing says. The document points at `[id]`; a plot does not. */\r\n unknownName(name: string): string;\r\n}\r\n\r\n// ── Compilation ──────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Resolves a name to a read function, or `undefined` when nothing in the\r\n * document declares it. The read is what the compiled binding calls, once per\r\n * evaluation of the prop it drives.\r\n */\r\nexport type VariableResolver = (name: string) => (() => unknown) | undefined;\r\n\r\n/**\r\n * A prop value, compiled: either a plain value or the binding an expression\r\n * somewhere inside it produced.\r\n */\r\nexport type CompiledValue =\r\n | { dynamic: false; value: unknown }\r\n | { dynamic: true; read: () => unknown };\r\n\r\n/** A props bag, split into what a constructor can take and what has to be bound. */\r\nexport interface CompiledProps {\r\n /**\r\n * Props with no expression in them.\r\n *\r\n * Handed to the node's constructor as-is. A bound prop is deliberately\r\n * *absent* here rather than present as a placeholder: a node's constructor\r\n * reads its raw props to decide things like a default size, and a\r\n * placeholder would answer those questions with a lie.\r\n */\r\n literal: Record<string, unknown>;\r\n /** Field → binding, applied with `node.set()` once the variables exist. */\r\n bindings: Record<string, () => unknown>;\r\n /** True when {@link CompiledProps.bindings} has anything in it. */\r\n hasBindings: boolean;\r\n}\r\n\r\n/** One expression found in a document, and where. */\r\nexport interface ExpressionSite {\r\n /** JSON-Pointer-style path, matching `ValidationIssue.path`. */\r\n path: string;\r\n /** The raw prop value, `=` and all. */\r\n source: string;\r\n}\r\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/document/expression/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,yFAAyF;AACzF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACtC,iFAAiF;IACxE,MAAM,CAAS;IACxB,sFAAsF;IAC7E,QAAQ,CAAS;IAC1B,6EAA6E;IACpE,IAAI,CAAU;IAEvB,YAAY,OAAe,EAAE,MAAc,EAAE,QAAQ,GAAG,CAAC,CAAC,EAAE,IAAa;QACrE,MAAM,KAAK,GAAG,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,QAAQ,GAAG,CAAC,QAAQ,MAAM,IAAI,CAAC,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC;QACrG,KAAK,CAAC,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ","sourcesContent":["/**\n * Every type the expression module names, in one place.\n *\n * The vocabulary is small and worth seeing at once, because the whole module is\n * four representations and the steps between them:\n *\n * a prop value ──▶ \"=4[g]+3\" ──▶ ExpressionNode ──▶ () => unknown\n * at any depth the marked the AST, per a prop binding\n * (walk) string dialect (parse) (compile)\n *\n * The `=` appears in exactly one of those steps. It marks a *document prop* as a\n * formula, which is recognition, not grammar — `=` is not a legal character in\n * any dialect — so the walk strips it and the parser never sees one.\n */\n\n/** Thrown for a formula that cannot be parsed or whose reference resolves to nothing. */\nexport class ExpressionError extends Error {\n /** The formula as the parser received it: no marker, and no surrounding prop. */\n readonly source: string;\n /** Character offset into {@link source}, or `-1` when the whole thing is at fault. */\n readonly position: number;\n /** Where in the props bag it was written, JSON-Pointer style, when known. */\n readonly path?: string;\n\n constructor(message: string, source: string, position = -1, path?: string) {\n const where = position >= 0 ? ` (at character ${position + 1} of \"${source}\")` : ` (in \"${source}\")`;\n super(`${message}${where}${path ? ` at ${path}` : \"\"}`);\n this.name = \"ExpressionError\";\n this.source = source;\n this.position = position;\n this.path = path;\n }\n}\n\n// ── The syntax tree ──────────────────────────────────────────────────────────\n\nexport type BinaryOp = \"+\" | \"-\" | \"*\" | \"/\" | \"%\" | \"^\";\n\n/** One node of a parsed formula. Kept public so a host can lint or rewrite one. */\nexport type ExpressionNode =\n | { kind: \"const\"; value: number }\n | { kind: \"ref\"; name: string }\n | { kind: \"unary\"; op: \"-\"; operand: ExpressionNode }\n | { kind: \"binary\"; op: BinaryOp; left: ExpressionNode; right: ExpressionNode }\n | { kind: \"call\"; name: string; args: ExpressionNode[] };\n\n/** A formula, parsed. Resolver-free, so it can be checked without a scene. */\nexport interface ParsedExpression {\n /** The formula's text as the parser received it — no marker. */\n readonly source: string;\n readonly root: ExpressionNode;\n /** Names it reads, de-duplicated, in first-seen order. */\n readonly refs: readonly string[];\n /**\n * True when the formula is exactly one reference and nothing else.\n *\n * The passthrough case: the document's compiled binding returns the\n * variable's value untouched rather than coercing it to a number, which is\n * what lets a variable hold a colour, a `Vector2` or any other prop value.\n * A dialect whose references are bare identifiers sets it for a lone\n * variable too (`\"x\"`), where it means nothing — only the document's\n * compiler reads it.\n */\n readonly passthrough: boolean;\n}\n\n// ── Dialects ─────────────────────────────────────────────────────────────────\n\n/** What the parser needs to know about a function. What it *does* is the back end's. */\nexport interface FnArity {\n /** Minimum and maximum argument count; `Infinity` for variadic. */\n arity: [number, number];\n}\n\n/**\n * One language over the shared grammar.\n *\n * The grammar is fixed — precedence, implicit multiplication, right-associative\n * `^`, the scientific-notation rule — and everything a language is free to\n * disagree about is here. That is what lets the document's `sin` be degrees and\n * a function plot's be radians without two parsers: the trig unit is a property\n * of a table, not of the grammar.\n */\nexport interface ExpressionDialect {\n /** Names callable as `f(…)`, and how many arguments each takes. */\n functions: Record<string, FnArity>;\n /** Bare identifiers that are values. Folded at parse time, so one can never also be a reference. */\n constants: Record<string, number>;\n /**\n * How a reference is spelled. `\"bracket\"` is `[id]`, and is the only mode in\n * which `[` is a legal character; `\"bare\"` makes any identifier that is not a\n * call or a constant a reference.\n */\n refs: \"bracket\" | \"bare\";\n /** What an identifier that resolves to nothing says. The document points at `[id]`; a plot does not. */\n unknownName(name: string): string;\n}\n\n// ── Compilation ──────────────────────────────────────────────────────────────\n\n/**\n * Resolves a name to a read function, or `undefined` when nothing in the\n * document declares it. The read is what the compiled binding calls, once per\n * evaluation of the prop it drives.\n */\nexport type VariableResolver = (name: string) => (() => unknown) | undefined;\n\n/**\n * A prop value, compiled: either a plain value or the binding an expression\n * somewhere inside it produced.\n */\nexport type CompiledValue =\n | { dynamic: false; value: unknown }\n | { dynamic: true; read: () => unknown };\n\n/** A props bag, split into what a constructor can take and what has to be bound. */\nexport interface CompiledProps {\n /**\n * Props with no expression in them.\n *\n * Handed to the node's constructor as-is. A bound prop is deliberately\n * *absent* here rather than present as a placeholder: a node's constructor\n * reads its raw props to decide things like a default size, and a\n * placeholder would answer those questions with a lie.\n */\n literal: Record<string, unknown>;\n /** Field → binding, applied with `node.set()` once the variables exist. */\n bindings: Record<string, () => unknown>;\n /** True when {@link CompiledProps.bindings} has anything in it. */\n hasBindings: boolean;\n}\n\n/** One expression found in a document, and where. */\nexport interface ExpressionSite {\n /** JSON-Pointer-style path, matching `ValidationIssue.path`. */\n path: string;\n /** The raw prop value, `=` and all. */\n source: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"walk.js","sourceRoot":"","sources":["../../../src/document/expression/walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG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G,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YAChC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;QACpD,CAAC,CAAC,CAAC,CAAC;IACR,CAAC,CAAC,CAAC;IACH,OAAQ,MAAuB,CAAC,KAAK,CAAC;AAC1C,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAC7B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["/**\r\n * Recognition, and the one walk over an authored prop value.\r\n *\r\n * There were two walks — one compiling, one collecting — with the same three\r\n * cases and different leaves, and they had already drifted: the compiling one\r\n * read `Object.keys`, the collecting one `for…in`. Neither carried a path, so an\r\n * `ExpressionError` from a formula nested inside a `fill` array named the\r\n * formula and left the reader to find which prop it was written in.\r\n *\r\n * One recursion now, parameterized by what to do with a string. `bind` returns a\r\n * replacement, so containers are rebuilt around it; `collect` returns its input,\r\n * so nothing is rebuilt and the result is thrown away.\r\n */\r\nimport { compile } from \"./compile\";\r\nimport { parse } from \"./parse\";\r\nimport type { CompiledProps, CompiledValue, ExpressionSite, VariableResolver } from \"./types\";\r\n\r\n/**\r\n * True when a value is a formula rather than a string.\r\n *\r\n * `\"==\"` is the escape, so `\"==total\"` is the literal `\"=total\"` and not an\r\n * expression; a bare `\"=\"` is likewise just that string. Both are handled by\r\n * {@link unescape}, which every literal path runs values through.\r\n */\r\nexport function isSource(value: unknown): value is string {\r\n return typeof value === \"string\" && value.length > 1 && value[0] === \"=\" && value[1] !== \"=\";\r\n}\r\n\r\n/** Strip the escape from a literal string that begins with `=`. `\"==x\"` → `\"=x\"`. */\r\nexport function unescape(value: string): string {\r\n return value.startsWith(\"==\") ? value.slice(1) : value;\r\n}\r\n\r\n/** What the walk does with each string it reaches. Returns the value to put back. */\r\ntype StringHandler = (source: string, path: string) => CompiledValue;\r\n\r\nconst STATIC = (value: unknown): CompiledValue => ({ dynamic: false, value });\r\n\r\n/**\r\n * Visit every string in an authored value, at any depth.\r\n *\r\n * An expression is recognised at any depth, not just as a whole prop, because\r\n * half the props worth driving are compound: `{\"origin\": {\"x\": \"=[g]\", \"y\": 0}}`,\r\n * `{\"fill\": [\"#111\", {\"type\": \"solid\", \"color\": \"=[c]\"}]}`. A container holding\r\n * one is rebuilt on each recompute; a container holding none is passed through\r\n * **by identity**, so a scene that uses no expressions allocates nothing and\r\n * compares equal to the document it came from.\r\n */\r\nfunction walk(value: unknown, path: string, onString: StringHandler): CompiledValue {\r\n if (typeof value === \"string\") return onString(value, path);\r\n\r\n if (Array.isArray(value)) {\r\n const parts = value.map((v, i) => walk(v, `${path}[${i}]`, onString));\r\n if (parts.some((p) => p.dynamic)) {\r\n return { dynamic: true, read: () => parts.map((p) => (p.dynamic ? p.read() : p.value)) };\r\n }\r\n // Rebuild only if a leaf actually changed, so the common case keeps the\r\n // document's own array.\r\n const rebuilt = parts.map((p) => (p as { value: unknown }).value);\r\n return STATIC(rebuilt.every((v, i) => v === value[i]) ? value : rebuilt);\r\n }\r\n\r\n if (isPlainObject(value)) {\r\n const keys = Object.keys(value);\r\n const parts = keys.map((k) => walk(value[k], `${path}.${k}`, onString));\r\n if (parts.some((p) => p.dynamic)) {\r\n return {\r\n dynamic: true,\r\n read: () => {\r\n const out: Record<string, unknown> = {};\r\n keys.forEach((k, i) => {\r\n const part = parts[i];\r\n out[k] = part.dynamic ? part.read() : part.value;\r\n });\r\n return out;\r\n },\r\n };\r\n }\r\n if (!parts.some((p, i) => (p as { value: unknown }).value !== value[keys[i]])) return STATIC(value);\r\n const rebuilt: Record<string, unknown> = {};\r\n keys.forEach((k, i) => { rebuilt[k] = (parts[i] as { value: unknown }).value; });\r\n return STATIC(rebuilt);\r\n }\r\n\r\n return STATIC(value);\r\n}\r\n\r\n/** Compile one authored prop value: a plain value, or the binding it produced. */\r\nexport function bind(value: unknown, resolve: VariableResolver, path = \"props\"): CompiledValue {\r\n return walk(value, path, (source, at) =>\r\n isSource(source)\r\n // The `=` is the document's marker, not the grammar's — strip it here\r\n // and the parser never sees one.\r\n ? { dynamic: true, read: compile(parse(source.slice(1)), resolve, at) }\r\n : STATIC(unescape(source)));\r\n}\r\n\r\n/** Compile a whole props bag. See {@link CompiledProps}. */\r\nexport function bindProps(\r\n props: Record<string, unknown> | undefined,\r\n resolve: VariableResolver,\r\n path = \"props\",\r\n): CompiledProps {\r\n const literal: Record<string, unknown> = {};\r\n const bindings: Record<string, () => unknown> = {};\r\n let hasBindings = false;\r\n\r\n for (const key of Object.keys(props ?? {})) {\r\n const compiled = bind(props![key], resolve, `${path}.${key}`);\r\n if (compiled.dynamic) {\r\n bindings[key] = compiled.read;\r\n hasBindings = true;\r\n } else {\r\n literal[key] = compiled.value;\r\n }\r\n }\r\n return { literal, bindings, hasBindings };\r\n}\r\n\r\n/**\r\n * Find every expression inside an authored value, at any depth.\r\n *\r\n * Used by the validator, which checks that each one parses and names a declared\r\n * variable — the two failures worth catching before anything is built.\r\n */\r\nexport function collect(value: unknown, path: string): ExpressionSite[] {\r\n const out: ExpressionSite[] = [];\r\n walk(value, path, (source, at) => {\r\n if (isSource(source)) out.push({ path: at, source });\r\n return STATIC(source);\r\n });\r\n return out;\r\n}\r\n\r\n/** A bracketed reference. The grammar has no string literals, so a `[` is always one. */\r\nconst REF = /\\[([^[\\]]+)\\]/g;\r\n\r\n/**\r\n * Rewrite the references inside every expression in an authored value.\r\n *\r\n * `rename` sees each reference as written (`\"fade\"`, `\"card.x\"`) and returns its\r\n * replacement, or `undefined` to keep it. What a host moving a subtree between\r\n * documents needs when ids or keys change on the way; a value with nothing to\r\n * rewrite comes back **by identity**, the same as {@link bind}'s static path.\r\n */\r\nexport function renameRefs<T>(value: T, rename: (ref: string) => string | undefined): T {\r\n const result = walk(value, \"\", (source) => {\r\n if (!isSource(source)) return STATIC(source);\r\n return STATIC(source.replace(REF, (whole, ref: string) => {\r\n // The parser trims a reference's name (`[ g ]` reads `g`), so the callback sees it trimmed too.\r\n const next = rename(ref.trim());\r\n return next === undefined ? whole : `[${next}]`;\r\n }));\r\n });\r\n return (result as { value: T }).value;\r\n}\r\n\r\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\r\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\r\n}\r\n"]}
1
+ {"version":3,"file":"walk.js","sourceRoot":"","sources":["../../../src/document/expression/walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;AACjG,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,QAAQ,CAAC,KAAa;IAClC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3D,CAAC;AAKD,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAE9E;;;;;;;;;GASG;AACH,SAAS,IAAI,CAAC,KAAc,EAAE,IAAY,EAAE,QAAuB;IAC/D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAE5D,IAAI,KAAK,CAAC,OAAO,CAAC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MAAM,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACrD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACf,CAAC;AAED,yFAAyF;AACzF,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAE7B;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAI,KAAQ,EAAE,MAA2C;IAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE;QACtC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,GAAW,EAAE,EAAE;YACrD,gGAAgG;YAChG,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YAChC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;QACpD,CAAC,CAAC,CAAC,CAAC;IACR,CAAC,CAAC,CAAC;IACH,OAAQ,MAAuB,CAAC,KAAK,CAAC;AAC1C,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAC7B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["/**\n * Recognition, and the one walk over an authored prop value.\n *\n * There were two walks — one compiling, one collecting — with the same three\n * cases and different leaves, and they had already drifted: the compiling one\n * read `Object.keys`, the collecting one `for…in`. Neither carried a path, so an\n * `ExpressionError` from a formula nested inside a `fill` array named the\n * formula and left the reader to find which prop it was written in.\n *\n * One recursion now, parameterized by what to do with a string. `bind` returns a\n * replacement, so containers are rebuilt around it; `collect` returns its input,\n * so nothing is rebuilt and the result is thrown away.\n */\nimport { compile } from \"./compile\";\nimport { parse } from \"./parse\";\nimport type { CompiledProps, CompiledValue, ExpressionSite, VariableResolver } from \"./types\";\n\n/**\n * True when a value is a formula rather than a string.\n *\n * `\"==\"` is the escape, so `\"==total\"` is the literal `\"=total\"` and not an\n * expression; a bare `\"=\"` is likewise just that string. Both are handled by\n * {@link unescape}, which every literal path runs values through.\n */\nexport function isSource(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 1 && value[0] === \"=\" && value[1] !== \"=\";\n}\n\n/** Strip the escape from a literal string that begins with `=`. `\"==x\"` → `\"=x\"`. */\nexport function unescape(value: string): string {\n return value.startsWith(\"==\") ? value.slice(1) : value;\n}\n\n/** What the walk does with each string it reaches. Returns the value to put back. */\ntype StringHandler = (source: string, path: string) => CompiledValue;\n\nconst STATIC = (value: unknown): CompiledValue => ({ dynamic: false, value });\n\n/**\n * Visit every string in an authored value, at any depth.\n *\n * An expression is recognised at any depth, not just as a whole prop, because\n * half the props worth driving are compound: `{\"origin\": {\"x\": \"=[g]\", \"y\": 0}}`,\n * `{\"fill\": [\"#111\", {\"type\": \"solid\", \"color\": \"=[c]\"}]}`. A container holding\n * one is rebuilt on each recompute; a container holding none is passed through\n * **by identity**, so a scene that uses no expressions allocates nothing and\n * compares equal to the document it came from.\n */\nfunction walk(value: unknown, path: string, onString: StringHandler): CompiledValue {\n if (typeof value === \"string\") return onString(value, path);\n\n if (Array.isArray(value)) {\n const parts = value.map((v, i) => walk(v, `${path}[${i}]`, onString));\n if (parts.some((p) => p.dynamic)) {\n return { dynamic: true, read: () => parts.map((p) => (p.dynamic ? p.read() : p.value)) };\n }\n // Rebuild only if a leaf actually changed, so the common case keeps the\n // document's own array.\n const rebuilt = parts.map((p) => (p as { value: unknown }).value);\n return STATIC(rebuilt.every((v, i) => v === value[i]) ? value : rebuilt);\n }\n\n if (isPlainObject(value)) {\n const keys = Object.keys(value);\n const parts = keys.map((k) => walk(value[k], `${path}.${k}`, onString));\n if (parts.some((p) => p.dynamic)) {\n return {\n dynamic: true,\n read: () => {\n const out: Record<string, unknown> = {};\n keys.forEach((k, i) => {\n const part = parts[i];\n out[k] = part.dynamic ? part.read() : part.value;\n });\n return out;\n },\n };\n }\n if (!parts.some((p, i) => (p as { value: unknown }).value !== value[keys[i]])) return STATIC(value);\n const rebuilt: Record<string, unknown> = {};\n keys.forEach((k, i) => { rebuilt[k] = (parts[i] as { value: unknown }).value; });\n return STATIC(rebuilt);\n }\n\n return STATIC(value);\n}\n\n/** Compile one authored prop value: a plain value, or the binding it produced. */\nexport function bind(value: unknown, resolve: VariableResolver, path = \"props\"): CompiledValue {\n return walk(value, path, (source, at) =>\n isSource(source)\n // The `=` is the document's marker, not the grammar's — strip it here\n // and the parser never sees one.\n ? { dynamic: true, read: compile(parse(source.slice(1)), resolve, at) }\n : STATIC(unescape(source)));\n}\n\n/** Compile a whole props bag. See {@link CompiledProps}. */\nexport function bindProps(\n props: Record<string, unknown> | undefined,\n resolve: VariableResolver,\n path = \"props\",\n): CompiledProps {\n const literal: Record<string, unknown> = {};\n const bindings: Record<string, () => unknown> = {};\n let hasBindings = false;\n\n for (const key of Object.keys(props ?? {})) {\n const compiled = bind(props![key], resolve, `${path}.${key}`);\n if (compiled.dynamic) {\n bindings[key] = compiled.read;\n hasBindings = true;\n } else {\n literal[key] = compiled.value;\n }\n }\n return { literal, bindings, hasBindings };\n}\n\n/**\n * Find every expression inside an authored value, at any depth.\n *\n * Used by the validator, which checks that each one parses and names a declared\n * variable — the two failures worth catching before anything is built.\n */\nexport function collect(value: unknown, path: string): ExpressionSite[] {\n const out: ExpressionSite[] = [];\n walk(value, path, (source, at) => {\n if (isSource(source)) out.push({ path: at, source });\n return STATIC(source);\n });\n return out;\n}\n\n/** A bracketed reference. The grammar has no string literals, so a `[` is always one. */\nconst REF = /\\[([^[\\]]+)\\]/g;\n\n/**\n * Rewrite the references inside every expression in an authored value.\n *\n * `rename` sees each reference as written (`\"fade\"`, `\"card.x\"`) and returns its\n * replacement, or `undefined` to keep it. What a host moving a subtree between\n * documents needs when ids or keys change on the way; a value with nothing to\n * rewrite comes back **by identity**, the same as {@link bind}'s static path.\n */\nexport function renameRefs<T>(value: T, rename: (ref: string) => string | undefined): T {\n const result = walk(value, \"\", (source) => {\n if (!isSource(source)) return STATIC(source);\n return STATIC(source.replace(REF, (whole, ref: string) => {\n // The parser trims a reference's name (`[ g ]` reads `g`), so the callback sees it trimmed too.\n const next = rename(ref.trim());\n return next === undefined ? whole : `[${next}]`;\n }));\n });\n return (result as { value: T }).value;\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/document/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,OAAO,EACH,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,GAClB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGpE,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAChE,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,iFAAiF;AACjF,2EAA2E;AAC3E,mBAAmB","sourcesContent":["export * from \"./types\";\r\nexport * from \"./project\";\r\nexport * from \"./expression\";\r\nexport * from \"./validate\";\r\nexport {\r\n DOCUMENT_FORMAT_VERSION,\r\n DOCUMENT_MIGRATIONS,\r\n DocumentTooNewError,\r\n documentFormatVersion,\r\n migrateDocument,\r\n} from \"./migrate\";\r\nexport type { DocumentChange, DocumentMigration, DocumentMigrationResult, JsonDocument, NoteChange } from \"./migrate\";\r\nexport { migrateNodeProps } from \"./prop-evolution\";\r\nexport type { PropEvolution, PropMigration, PropNote } from \"./prop-evolution\";\r\nexport { missingNodeOf } from \"./missing-node\";\r\nexport { registryVocabulary, vocabularyBreaks } from \"./vocabulary\";\r\nexport type { RegistryVocabulary, VocabularyBreak } from \"./vocabulary\";\r\nexport type { MissingNodeInfo } from \"./missing-node\";\r\nexport * from \"./registry\";\r\nexport * from \"./node-descriptor\";\r\nexport { NODE_META, getNodeDescriptor } from \"./node-decorator\";\r\nexport * from \"./placement\";\r\nexport * from \"./timeline\";\r\nexport * from \"./audio\";\r\n// `installBuiltins` is deliberately NOT exported: a `Registry` seeds itself from\r\n// its own constructor, so a host has no module-scope call for a bundler to\r\n// tree-shake away.\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/document/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,OAAO,EACH,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,GAClB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGpE,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAChE,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,iFAAiF;AACjF,2EAA2E;AAC3E,mBAAmB","sourcesContent":["export * from \"./types\";\nexport * from \"./project\";\nexport * from \"./expression\";\nexport * from \"./validate\";\nexport {\n DOCUMENT_FORMAT_VERSION,\n DOCUMENT_MIGRATIONS,\n DocumentTooNewError,\n documentFormatVersion,\n migrateDocument,\n} from \"./migrate\";\nexport type { DocumentChange, DocumentMigration, DocumentMigrationResult, JsonDocument, NoteChange } from \"./migrate\";\nexport { migrateNodeProps } from \"./prop-evolution\";\nexport type { PropEvolution, PropMigration, PropNote } from \"./prop-evolution\";\nexport { missingNodeOf } from \"./missing-node\";\nexport { registryVocabulary, vocabularyBreaks } from \"./vocabulary\";\nexport type { RegistryVocabulary, VocabularyBreak } from \"./vocabulary\";\nexport type { MissingNodeInfo } from \"./missing-node\";\nexport * from \"./registry\";\nexport * from \"./node-descriptor\";\nexport { NODE_META, getNodeDescriptor } from \"./node-decorator\";\nexport * from \"./placement\";\nexport * from \"./timeline\";\nexport * from \"./audio\";\n// `installBuiltins` is deliberately NOT exported: a `Registry` seeds itself from\n// its own constructor, so a host has no module-scope call for a bundler to\n// tree-shake away.\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/document/migrate.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,wGAAwG;AACxG,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,2FAA2F;AAC3F,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACjC,OAAO,CAAS;IAChB,SAAS,CAAS;IAE3B,YAAY,OAAe,EAAE,YAAoB,uBAAuB;QACpE,KAAK,CACD,2BAA2B,OAAO,0CAA0C,SAAS,KAAK;YAC1F,8BAA8B,CACjC,CAAC;QACF,IAAI,CAAC,IAAI,GAAG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CAAC,CAAC;YAC/G,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAC;YAChC,aAAa,GAAG,IAAI,CAAC;YACrB,OAAO,EAAE,GAAI,KAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAChD,CAAC,CAAC;QACF,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IACjB,IAAI,IAAI,KAAK,MAAM,IAAI,CAAC,aAAa;QAAE,OAAO,OAAO,CAAC;IACtD,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;AACnF,CAAC","sourcesContent":["import type { ProjectDocument } from \"./project\";\r\nimport type { ClipDocument } from \"./types\";\r\n\r\n/**\r\n * Saved documents outlive the engine that wrote them, so each carries the\r\n * format it was written in and this module carries every step from one format\r\n * to the next.\r\n *\r\n * A step is a pure function over JSON: it never mutates what it is handed and\r\n * never needs a registry, so a host can run it over a row it has not opened\r\n * and a test can pin it with two literals. Steps only ever go up; a document\r\n * newer than the engine is refused with {@link DocumentTooNewError} rather than\r\n * read as whatever it happens to resemble.\r\n */\r\n\r\n/** The format this engine reads natively and writes. A document without `formatVersion` is format 0. */\r\nexport const DOCUMENT_FORMAT_VERSION = 2;\r\n\r\n/** A document written by a newer engine than this one. Thrown before anything reads it. */\r\nexport class DocumentTooNewError extends Error {\r\n readonly version: number;\r\n readonly supported: number;\r\n\r\n constructor(version: number, supported: number = DOCUMENT_FORMAT_VERSION) {\r\n super(\r\n `This document is format ${version}, newer than this engine reads (format ${supported}). ` +\r\n `Open it with a newer engine.`,\r\n );\r\n this.name = \"DocumentTooNewError\";\r\n this.version = version;\r\n this.supported = supported;\r\n }\r\n}\r\n\r\n/** A document as JSON, before anything has checked its shape. */\r\nexport type JsonDocument = Record<string, unknown>;\r\n\r\n/** One thing a migration changed. `path` locates it as a `ValidationIssue`'s does. */\r\nexport interface DocumentChange {\r\n /** The format the step that made it read. */\r\n from: number;\r\n path: string;\r\n message: string;\r\n}\r\n\r\n/** Records a change at `path`, relative to the document the step was handed. */\r\nexport type NoteChange = (path: string, message: string) => void;\r\n\r\n/** The step from format {@link from} to `from + 1`. */\r\nexport interface DocumentMigration {\r\n readonly from: number;\r\n /** What the format change was, for a changelog or a host's log. */\r\n readonly description: string;\r\n /** Run on every clip document, standalone or inside a project's track. */\r\n readonly clip?: (clip: JsonDocument, note: NoteChange) => JsonDocument;\r\n /** Run on a project's own fields, before its clips. */\r\n readonly project?: (project: JsonDocument, note: NoteChange) => JsonDocument;\r\n}\r\n\r\nexport interface DocumentMigrationResult<T> {\r\n /** The input itself when it was already current; otherwise a new document stamped with {@link to}. */\r\n document: T;\r\n from: number;\r\n to: number;\r\n changes: DocumentChange[];\r\n}\r\n\r\n/**\r\n * Every step, oldest first. A release that changes what a stored document\r\n * means adds the next one here, bumps {@link DOCUMENT_FORMAT_VERSION}, and\r\n * gives the step a test (`tests/migrate.test.ts`).\r\n */\r\nexport const DOCUMENT_MIGRATIONS: readonly DocumentMigration[] = [\r\n {\r\n from: 0,\r\n description: \"Documents start carrying `formatVersion`; a clip's retired `constants` rows become `variables`.\",\r\n clip: (clip, note) => {\r\n if (!Array.isArray(clip.constants)) return clip;\r\n const { constants, ...rest } = clip;\r\n const variables = Array.isArray(rest.variables) ? [...rest.variables] : [];\r\n for (const row of constants as unknown[]) {\r\n if (typeof row !== \"object\" || row === null) {\r\n variables.push(row);\r\n continue;\r\n }\r\n const { kind: _kind, ...variable } = row as Record<string, unknown>;\r\n variables.push(variable);\r\n }\r\n note(\"constants\", `${constants.length} constant row(s) moved into \\`variables\\`.`);\r\n return { ...rest, variables };\r\n },\r\n },\r\n {\r\n from: 1,\r\n description:\r\n \"SkSL is retired: every shader fill, shader effect and shader pack written in it says `language: \\\"sksl\\\"`, \" +\r\n \"the `sksl` effect key becomes `shader`, and `coords` is dropped.\",\r\n clip: (clip, note) => retireSkSL(clip, \"\", note) as JsonDocument,\r\n },\r\n];\r\n\r\n/** SkSL's entry point or an SkSL `uniform` declaration, neither of which a WGSL source can contain. */\r\nconst SKSL_SOURCE = /\\b(?:half4|float4|vec4)\\s+main\\s*\\(|^\\s*uniform\\s+\\w+\\s+\\w+/m;\r\n\r\ntype JsonObject = Record<string, unknown>;\r\n\r\nconst isObject = (value: unknown): value is JsonObject =>\r\n typeof value === \"object\" && value !== null && !Array.isArray(value);\r\n\r\n// Fills and effects sit in node props, named fills, effect and filter arrays,\r\n// command values and tween keyframes alike, so the whole clip is walked.\r\nfunction retireSkSL(value: unknown, path: string, note: NoteChange): unknown {\r\n if (Array.isArray(value)) {\r\n let out: unknown[] | undefined;\r\n value.forEach((item, i) => {\r\n const next = retireSkSL(item, `${path}[${i}]`, note);\r\n if (next !== item) (out ??= [...value])[i] = next;\r\n });\r\n return out ?? value;\r\n }\r\n if (!isObject(value)) return value;\r\n let out: JsonObject | undefined;\r\n for (const [key, item] of Object.entries(value)) {\r\n const next = retireSkSL(item, path ? `${path}.${key}` : key, note);\r\n if (next !== item) (out ??= { ...value })[key] = next;\r\n }\r\n return retireShader(out ?? value, path, note);\r\n}\r\n\r\nfunction retireShader(shader: JsonObject, path: string, note: NoteChange): JsonObject {\r\n const legacyKey = shader.type === \"sksl\";\r\n const isShader = legacyKey\r\n || (shader.type === \"shader\" && (typeof shader.source === \"string\" || typeof shader.shader === \"string\"))\r\n || ((shader.scope === \"fill\" || shader.scope === \"effect\") && typeof shader.source === \"string\");\r\n if (!isShader) return shader;\r\n\r\n const out: JsonObject = { ...shader };\r\n if (legacyKey) out.type = \"shader\";\r\n const moved = out.type === \"shader\" && typeof out.shader === \"string\" && out.source === undefined;\r\n if (moved) {\r\n out.source = out.shader;\r\n delete out.shader;\r\n }\r\n // The `sksl` key meant SkSL whatever its source looked like, unless it said otherwise.\r\n const sksl = out.language === \"sksl\"\r\n || (out.language === undefined && (legacyKey || SKSL_SOURCE.test(typeof out.source === \"string\" ? out.source : \"\")));\r\n const stamped = sksl && out.language === undefined;\r\n if (stamped) out.language = \"sksl\";\r\n const hadCoords = \"coords\" in out;\r\n delete out.coords;\r\n\r\n if (sksl) note(path, \"SkSL shaders no longer draw; port it to WGSL.\");\r\n else if (legacyKey) note(path, \"The retired `sksl` effect key is now `shader`.\");\r\n else if (moved) note(path, \"The shader's `shader` field is now `source`.\");\r\n else if (hadCoords) note(path, \"`coords` dropped; it only ever applied to SkSL.\");\r\n return legacyKey || moved || stamped || hadCoords ? out : shader;\r\n}\r\n\r\n/** The format a document says it is in: its `formatVersion`, or 0 when it has none. */\r\nexport function documentFormatVersion(doc: unknown): number {\r\n if (typeof doc !== \"object\" || doc === null) return 0;\r\n const version = (doc as { formatVersion?: unknown }).formatVersion;\r\n if (version === undefined) return 0;\r\n if (typeof version !== \"number\" || !Number.isInteger(version) || version < 0) {\r\n throw new TypeError(`formatVersion must be a whole number >= 0 (got ${JSON.stringify(version)}).`);\r\n }\r\n return version;\r\n}\r\n\r\n/**\r\n * Bring a still, composition, audio or project document up to\r\n * {@link DOCUMENT_FORMAT_VERSION}.\r\n *\r\n * A clip inside a project with no `formatVersion` of its own is read at the\r\n * project's, since it was written alongside it. Anything that is not a\r\n * document comes back untouched, for validation to describe.\r\n */\r\nexport function migrateDocument<T extends ProjectDocument | ClipDocument>(doc: T): DocumentMigrationResult<T>;\r\nexport function migrateDocument(doc: unknown): DocumentMigrationResult<unknown>;\r\nexport function migrateDocument(doc: unknown): DocumentMigrationResult<unknown> {\r\n return migrateDocumentWith(doc, DOCUMENT_MIGRATIONS, DOCUMENT_FORMAT_VERSION);\r\n}\r\n\r\n/** @internal {@link migrateDocument} over a given list of steps, for a test pinning the runner. */\r\nexport function migrateDocumentWith(\r\n doc: unknown,\r\n migrations: readonly DocumentMigration[],\r\n target: number,\r\n): DocumentMigrationResult<unknown> {\r\n const from = documentFormatVersion(doc);\r\n if (from > target) throw new DocumentTooNewError(from, target);\r\n if (typeof doc !== \"object\" || doc === null || Array.isArray(doc)) {\r\n return { document: doc, from, to: from, changes: [] };\r\n }\r\n const changes: DocumentChange[] = [];\r\n const json = doc as JsonDocument;\r\n const migrated = json.kind === \"project\"\r\n ? migrateProject(json, from, migrations, target, changes)\r\n : migrateClip(json, from, migrations, target, changes, \"\");\r\n return { document: migrated, from, to: target, changes };\r\n}\r\n\r\nfunction stepsBetween(from: number, to: number, migrations: readonly DocumentMigration[]): DocumentMigration[] {\r\n const steps: DocumentMigration[] = [];\r\n for (let version = from; version < to; version++) {\r\n const step = migrations.find((m) => m.from === version);\r\n if (!step) throw new Error(`No document migration from format ${version} to ${version + 1}.`);\r\n steps.push(step);\r\n }\r\n return steps;\r\n}\r\n\r\nfunction noteInto(changes: DocumentChange[], from: number, prefix: string): NoteChange {\r\n return (path, message) => changes.push({ from, path: prefix && path ? `${prefix}.${path}` : prefix || path, message });\r\n}\r\n\r\n/** `stamp` false leaves a clip that inherits its project's version without a field of its own. */\r\nfunction migrateClip(\r\n clip: JsonDocument,\r\n from: number,\r\n migrations: readonly DocumentMigration[],\r\n target: number,\r\n changes: DocumentChange[],\r\n prefix: string,\r\n stamp = true,\r\n): JsonDocument {\r\n if (from === target) return clip;\r\n let out = clip;\r\n for (const step of stepsBetween(from, target, migrations)) {\r\n if (step.clip) out = step.clip(out, noteInto(changes, step.from, prefix));\r\n }\r\n return stamp ? { ...out, formatVersion: target } : out;\r\n}\r\n\r\nfunction migrateProject(\r\n project: JsonDocument,\r\n from: number,\r\n migrations: readonly DocumentMigration[],\r\n target: number,\r\n changes: DocumentChange[],\r\n): JsonDocument {\r\n let out = project;\r\n if (from < target) {\r\n for (const step of stepsBetween(from, target, migrations)) {\r\n if (step.project) out = step.project(out, noteInto(changes, step.from, \"\"));\r\n }\r\n }\r\n let tracksChanged = false;\r\n const tracks = Array.isArray(out.tracks)\r\n ? (out.tracks as unknown[]).map((track, i) => {\r\n if (typeof track !== \"object\" || track === null) return track;\r\n const clip = (track as { clip?: unknown }).clip;\r\n if (typeof clip !== \"object\" || clip === null || Array.isArray(clip)) return track;\r\n const own = (clip as { formatVersion?: unknown }).formatVersion !== undefined;\r\n const version = own ? documentFormatVersion(clip) : from;\r\n if (version > target) throw new DocumentTooNewError(version, target);\r\n const next = migrateClip(clip as JsonDocument, version, migrations, target, changes, `tracks[${i}].clip`, own);\r\n if (next === clip) return track;\r\n tracksChanged = true;\r\n return { ...(track as object), clip: next };\r\n })\r\n : out.tracks;\r\n if (from === target && !tracksChanged) return project;\r\n return { ...out, ...(tracksChanged ? { tracks } : {}), formatVersion: target };\r\n}\r\n"]}
1
+ {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/document/migrate.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,wGAAwG;AACxG,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,2FAA2F;AAC3F,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACjC,OAAO,CAAS;IAChB,SAAS,CAAS;IAE3B,YAAY,OAAe,EAAE,YAAoB,uBAAuB;QACpE,KAAK,CACD,2BAA2B,OAAO,0CAA0C,SAAS,KAAK;YAC1F,8BAA8B,CACjC,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ;AAmCD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAiC;IAC7D;QACI,IAAI,EAAE,CAAC;QACP,WAAW,EAAE,iGAAiG;QAC9G,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;YACjB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;gBAAE,OAAO,IAAI,CAAC;YAChD,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;YACpC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CAAC;AACnF,CAAC","sourcesContent":["import type { ProjectDocument } from \"./project\";\nimport type { ClipDocument } from \"./types\";\n\n/**\n * Saved documents outlive the engine that wrote them, so each carries the\n * format it was written in and this module carries every step from one format\n * to the next.\n *\n * A step is a pure function over JSON: it never mutates what it is handed and\n * never needs a registry, so a host can run it over a row it has not opened\n * and a test can pin it with two literals. Steps only ever go up; a document\n * newer than the engine is refused with {@link DocumentTooNewError} rather than\n * read as whatever it happens to resemble.\n */\n\n/** The format this engine reads natively and writes. A document without `formatVersion` is format 0. */\nexport const DOCUMENT_FORMAT_VERSION = 2;\n\n/** A document written by a newer engine than this one. Thrown before anything reads it. */\nexport class DocumentTooNewError extends Error {\n readonly version: number;\n readonly supported: number;\n\n constructor(version: number, supported: number = DOCUMENT_FORMAT_VERSION) {\n super(\n `This document is format ${version}, newer than this engine reads (format ${supported}). ` +\n `Open it with a newer engine.`,\n );\n this.name = \"DocumentTooNewError\";\n this.version = version;\n this.supported = supported;\n }\n}\n\n/** A document as JSON, before anything has checked its shape. */\nexport type JsonDocument = Record<string, unknown>;\n\n/** One thing a migration changed. `path` locates it as a `ValidationIssue`'s does. */\nexport interface DocumentChange {\n /** The format the step that made it read. */\n from: number;\n path: string;\n message: string;\n}\n\n/** Records a change at `path`, relative to the document the step was handed. */\nexport type NoteChange = (path: string, message: string) => void;\n\n/** The step from format {@link from} to `from + 1`. */\nexport interface DocumentMigration {\n readonly from: number;\n /** What the format change was, for a changelog or a host's log. */\n readonly description: string;\n /** Run on every clip document, standalone or inside a project's track. */\n readonly clip?: (clip: JsonDocument, note: NoteChange) => JsonDocument;\n /** Run on a project's own fields, before its clips. */\n readonly project?: (project: JsonDocument, note: NoteChange) => JsonDocument;\n}\n\nexport interface DocumentMigrationResult<T> {\n /** The input itself when it was already current; otherwise a new document stamped with {@link to}. */\n document: T;\n from: number;\n to: number;\n changes: DocumentChange[];\n}\n\n/**\n * Every step, oldest first. A release that changes what a stored document\n * means adds the next one here, bumps {@link DOCUMENT_FORMAT_VERSION}, and\n * gives the step a test (`tests/migrate.test.ts`).\n */\nexport const DOCUMENT_MIGRATIONS: readonly DocumentMigration[] = [\n {\n from: 0,\n description: \"Documents start carrying `formatVersion`; a clip's retired `constants` rows become `variables`.\",\n clip: (clip, note) => {\n if (!Array.isArray(clip.constants)) return clip;\n const { constants, ...rest } = clip;\n const variables = Array.isArray(rest.variables) ? [...rest.variables] : [];\n for (const row of constants as unknown[]) {\n if (typeof row !== \"object\" || row === null) {\n variables.push(row);\n continue;\n }\n const { kind: _kind, ...variable } = row as Record<string, unknown>;\n variables.push(variable);\n }\n note(\"constants\", `${constants.length} constant row(s) moved into \\`variables\\`.`);\n return { ...rest, variables };\n },\n },\n {\n from: 1,\n description:\n \"SkSL is retired: every shader fill, shader effect and shader pack written in it says `language: \\\"sksl\\\"`, \" +\n \"the `sksl` effect key becomes `shader`, and `coords` is dropped.\",\n clip: (clip, note) => retireSkSL(clip, \"\", note) as JsonDocument,\n },\n];\n\n/** SkSL's entry point or an SkSL `uniform` declaration, neither of which a WGSL source can contain. */\nconst SKSL_SOURCE = /\\b(?:half4|float4|vec4)\\s+main\\s*\\(|^\\s*uniform\\s+\\w+\\s+\\w+/m;\n\ntype JsonObject = Record<string, unknown>;\n\nconst isObject = (value: unknown): value is JsonObject =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n// Fills and effects sit in node props, named fills, effect and filter arrays,\n// command values and tween keyframes alike, so the whole clip is walked.\nfunction retireSkSL(value: unknown, path: string, note: NoteChange): unknown {\n if (Array.isArray(value)) {\n let out: unknown[] | undefined;\n value.forEach((item, i) => {\n const next = retireSkSL(item, `${path}[${i}]`, note);\n if (next !== item) (out ??= [...value])[i] = next;\n });\n return out ?? value;\n }\n if (!isObject(value)) return value;\n let out: JsonObject | undefined;\n for (const [key, item] of Object.entries(value)) {\n const next = retireSkSL(item, path ? `${path}.${key}` : key, note);\n if (next !== item) (out ??= { ...value })[key] = next;\n }\n return retireShader(out ?? value, path, note);\n}\n\nfunction retireShader(shader: JsonObject, path: string, note: NoteChange): JsonObject {\n const legacyKey = shader.type === \"sksl\";\n const isShader = legacyKey\n || (shader.type === \"shader\" && (typeof shader.source === \"string\" || typeof shader.shader === \"string\"))\n || ((shader.scope === \"fill\" || shader.scope === \"effect\") && typeof shader.source === \"string\");\n if (!isShader) return shader;\n\n const out: JsonObject = { ...shader };\n if (legacyKey) out.type = \"shader\";\n const moved = out.type === \"shader\" && typeof out.shader === \"string\" && out.source === undefined;\n if (moved) {\n out.source = out.shader;\n delete out.shader;\n }\n // The `sksl` key meant SkSL whatever its source looked like, unless it said otherwise.\n const sksl = out.language === \"sksl\"\n || (out.language === undefined && (legacyKey || SKSL_SOURCE.test(typeof out.source === \"string\" ? out.source : \"\")));\n const stamped = sksl && out.language === undefined;\n if (stamped) out.language = \"sksl\";\n const hadCoords = \"coords\" in out;\n delete out.coords;\n\n if (sksl) note(path, \"SkSL shaders no longer draw; port it to WGSL.\");\n else if (legacyKey) note(path, \"The retired `sksl` effect key is now `shader`.\");\n else if (moved) note(path, \"The shader's `shader` field is now `source`.\");\n else if (hadCoords) note(path, \"`coords` dropped; it only ever applied to SkSL.\");\n return legacyKey || moved || stamped || hadCoords ? out : shader;\n}\n\n/** The format a document says it is in: its `formatVersion`, or 0 when it has none. */\nexport function documentFormatVersion(doc: unknown): number {\n if (typeof doc !== \"object\" || doc === null) return 0;\n const version = (doc as { formatVersion?: unknown }).formatVersion;\n if (version === undefined) return 0;\n if (typeof version !== \"number\" || !Number.isInteger(version) || version < 0) {\n throw new TypeError(`formatVersion must be a whole number >= 0 (got ${JSON.stringify(version)}).`);\n }\n return version;\n}\n\n/**\n * Bring a still, composition, audio or project document up to\n * {@link DOCUMENT_FORMAT_VERSION}.\n *\n * A clip inside a project with no `formatVersion` of its own is read at the\n * project's, since it was written alongside it. Anything that is not a\n * document comes back untouched, for validation to describe.\n */\nexport function migrateDocument<T extends ProjectDocument | ClipDocument>(doc: T): DocumentMigrationResult<T>;\nexport function migrateDocument(doc: unknown): DocumentMigrationResult<unknown>;\nexport function migrateDocument(doc: unknown): DocumentMigrationResult<unknown> {\n return migrateDocumentWith(doc, DOCUMENT_MIGRATIONS, DOCUMENT_FORMAT_VERSION);\n}\n\n/** @internal {@link migrateDocument} over a given list of steps, for a test pinning the runner. */\nexport function migrateDocumentWith(\n doc: unknown,\n migrations: readonly DocumentMigration[],\n target: number,\n): DocumentMigrationResult<unknown> {\n const from = documentFormatVersion(doc);\n if (from > target) throw new DocumentTooNewError(from, target);\n if (typeof doc !== \"object\" || doc === null || Array.isArray(doc)) {\n return { document: doc, from, to: from, changes: [] };\n }\n const changes: DocumentChange[] = [];\n const json = doc as JsonDocument;\n const migrated = json.kind === \"project\"\n ? migrateProject(json, from, migrations, target, changes)\n : migrateClip(json, from, migrations, target, changes, \"\");\n return { document: migrated, from, to: target, changes };\n}\n\nfunction stepsBetween(from: number, to: number, migrations: readonly DocumentMigration[]): DocumentMigration[] {\n const steps: DocumentMigration[] = [];\n for (let version = from; version < to; version++) {\n const step = migrations.find((m) => m.from === version);\n if (!step) throw new Error(`No document migration from format ${version} to ${version + 1}.`);\n steps.push(step);\n }\n return steps;\n}\n\nfunction noteInto(changes: DocumentChange[], from: number, prefix: string): NoteChange {\n return (path, message) => changes.push({ from, path: prefix && path ? `${prefix}.${path}` : prefix || path, message });\n}\n\n/** `stamp` false leaves a clip that inherits its project's version without a field of its own. */\nfunction migrateClip(\n clip: JsonDocument,\n from: number,\n migrations: readonly DocumentMigration[],\n target: number,\n changes: DocumentChange[],\n prefix: string,\n stamp = true,\n): JsonDocument {\n if (from === target) return clip;\n let out = clip;\n for (const step of stepsBetween(from, target, migrations)) {\n if (step.clip) out = step.clip(out, noteInto(changes, step.from, prefix));\n }\n return stamp ? { ...out, formatVersion: target } : out;\n}\n\nfunction migrateProject(\n project: JsonDocument,\n from: number,\n migrations: readonly DocumentMigration[],\n target: number,\n changes: DocumentChange[],\n): JsonDocument {\n let out = project;\n if (from < target) {\n for (const step of stepsBetween(from, target, migrations)) {\n if (step.project) out = step.project(out, noteInto(changes, step.from, \"\"));\n }\n }\n let tracksChanged = false;\n const tracks = Array.isArray(out.tracks)\n ? (out.tracks as unknown[]).map((track, i) => {\n if (typeof track !== \"object\" || track === null) return track;\n const clip = (track as { clip?: unknown }).clip;\n if (typeof clip !== \"object\" || clip === null || Array.isArray(clip)) return track;\n const own = (clip as { formatVersion?: unknown }).formatVersion !== undefined;\n const version = own ? documentFormatVersion(clip) : from;\n if (version > target) throw new DocumentTooNewError(version, target);\n const next = migrateClip(clip as JsonDocument, version, migrations, target, changes, `tracks[${i}].clip`, own);\n if (next === clip) return track;\n tracksChanged = true;\n return { ...(track as object), clip: next };\n })\n : out.tracks;\n if (from === target && !tracksChanged) return project;\n return { ...out, ...(tracksChanged ? { tracks } : {}), formatVersion: target };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"missing-node.js","sourceRoot":"","sources":["../../src/document/missing-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAmBtE,MAAM,aAAa,GAAG,WAAW,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC;AAC5D,MAAM,aAAa,GAAG,WAAW,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC;AAC5D,MAAM,gBAAgB,GAAG,cAAc,CAAC,EAAE,GAAG,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAIrE,MAAM,YAAY,GAA2C;IACzD,IAAI,EAAE,aAAa,CAAC,IAAkC;IACtD,IAAI,EAAE,aAAa,CAAC,IAAkC;IACtD,KAAK,EAAE,gBAAgB,CAAC,IAAkC;CAC7D,CAAC;AAEF,gGAA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ACzE,MAAM,UAAU,gBAAgB,CAAC,SAAwB,EAAE,KAA8B;IACrF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtF,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAU;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import { getPropertyMeta } from \"@/attributes/properties/decorator\";\r\nimport { component2d } from \"@/components/factory/component2d\";\r\nimport { component3d } from \"@/components/factory/component3d\";\r\nimport { componentAudio } from \"@/components/factory/component-audio\";\r\nimport type { Node, NodeDimension } from \"@/components/trees/node/node\";\r\nimport type { NodeSpec } from \"./types\";\r\n\r\n/**\r\n * What a build puts where a row names a type its registry lacks: a node of the\r\n * row's tree that keeps the row's id, its placement and its children, and\r\n * draws nothing itself. One unknown type then costs one node rather than the\r\n * whole clip, and an editor still shows the row where it was.\r\n *\r\n * None of these is registered, so no document can name one.\r\n */\r\n\r\n/** The type a placeholder stands in for, and the props its row authored. */\r\nexport interface MissingNodeInfo {\r\n type: string;\r\n props: Readonly<Record<string, unknown>>;\r\n}\r\n\r\nconst MissingNode2D = component2d({ key: \"missingNode2d\" });\r\nconst MissingNode3D = component3d({ key: \"missingNode3d\" });\r\nconst MissingNodeAudio = componentAudio({ key: \"missingNodeAudio\" });\r\n\r\ntype PlaceholderCtor = new (props?: Record<string, unknown>) => Node;\r\n\r\nconst PLACEHOLDERS: Record<NodeDimension, PlaceholderCtor> = {\r\n \"2d\": MissingNode2D.node as unknown as PlaceholderCtor,\r\n \"3d\": MissingNode3D.node as unknown as PlaceholderCtor,\r\n audio: MissingNodeAudio.node as unknown as PlaceholderCtor,\r\n};\r\n\r\n/** Placement it keeps; nothing that would draw or composite, so it shows nothing of its own. */\r\nconst DRAWS = new Set([\"effects\", \"blend\", \"clip\", \"shadow\"]);\r\n\r\nconst KEPT = Object.fromEntries(Object.entries(PLACEHOLDERS).map(([dimension, ctor]) => [\r\n dimension,\r\n new Set(getPropertyMeta(Object.create(ctor.prototype) as object).map((m) => m.key).filter((key) => !DRAWS.has(key))),\r\n])) as unknown as Record<NodeDimension, ReadonlySet<string>>;\r\n\r\nconst MISSING = new WeakMap<Node, MissingNodeInfo>();\r\n\r\n/** Stands in for every placeholder's class when a build compares a live node's class with its row's. */\r\nexport const MISSING_TYPE: unique symbol = Symbol(\"missingNodeType\");\r\n\r\n/** @internal A placeholder for `spec`, in `dimension`, taking what it can of `props` (the literal half of the row's). */\r\nexport function missingNode(dimension: NodeDimension, spec: NodeSpec, props: Record<string, unknown>): Node {\r\n const node = new PLACEHOLDERS[dimension]({\r\n ...placeholderProps(dimension, props),\r\n id: spec.id,\r\n ...(spec.key !== undefined && { key: spec.key }),\r\n });\r\n MISSING.set(node, { type: spec.type, props: spec.props });\r\n return node;\r\n}\r\n\r\n/** @internal Of a props bag, what a placeholder of `dimension` takes. */\r\nexport function placeholderProps(dimension: NodeDimension, props: Record<string, unknown>): Record<string, unknown> {\r\n const kept = KEPT[dimension];\r\n const out: Record<string, unknown> = {};\r\n for (const [key, value] of Object.entries(props)) if (kept.has(key)) out[key] = value;\r\n return out;\r\n}\r\n\r\n/**\r\n * The unknown type a live node stands in for, or `undefined` for a real node —\r\n * so a host can mark the row and keep its props for when the type is back.\r\n */\r\nexport function missingNodeOf(node: Node): MissingNodeInfo | undefined {\r\n return MISSING.get(node);\r\n}\r\n"]}
1
+ {"version":3,"file":"missing-node.js","sourceRoot":"","sources":["../../src/document/missing-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,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MAAM,CAAC,MAAM,YAAY,GAAkB,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAErE,yHAAyH;AACzH,MAAM,UAAU,WAAW,CAAC,SAAwB,EAAE,IAAc,EAAE,KAA8B;IAChG,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;QACrC,GAAG,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC;QACrC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;KACnD,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,gBAAgB,CAAC,SAAwB,EAAE,KAA8B;IACrF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtF,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAU;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import { getPropertyMeta } from \"@/attributes/properties/decorator\";\nimport { component2d } from \"@/components/factory/component2d\";\nimport { component3d } from \"@/components/factory/component3d\";\nimport { componentAudio } from \"@/components/factory/component-audio\";\nimport type { Node, NodeDimension } from \"@/components/trees/node/node\";\nimport type { NodeSpec } from \"./types\";\n\n/**\n * What a build puts where a row names a type its registry lacks: a node of the\n * row's tree that keeps the row's id, its placement and its children, and\n * draws nothing itself. One unknown type then costs one node rather than the\n * whole clip, and an editor still shows the row where it was.\n *\n * None of these is registered, so no document can name one.\n */\n\n/** The type a placeholder stands in for, and the props its row authored. */\nexport interface MissingNodeInfo {\n type: string;\n props: Readonly<Record<string, unknown>>;\n}\n\nconst MissingNode2D = component2d({ key: \"missingNode2d\" });\nconst MissingNode3D = component3d({ key: \"missingNode3d\" });\nconst MissingNodeAudio = componentAudio({ key: \"missingNodeAudio\" });\n\ntype PlaceholderCtor = new (props?: Record<string, unknown>) => Node;\n\nconst PLACEHOLDERS: Record<NodeDimension, PlaceholderCtor> = {\n \"2d\": MissingNode2D.node as unknown as PlaceholderCtor,\n \"3d\": MissingNode3D.node as unknown as PlaceholderCtor,\n audio: MissingNodeAudio.node as unknown as PlaceholderCtor,\n};\n\n/** Placement it keeps; nothing that would draw or composite, so it shows nothing of its own. */\nconst DRAWS = new Set([\"effects\", \"blend\", \"clip\", \"shadow\"]);\n\nconst KEPT = Object.fromEntries(Object.entries(PLACEHOLDERS).map(([dimension, ctor]) => [\n dimension,\n new Set(getPropertyMeta(Object.create(ctor.prototype) as object).map((m) => m.key).filter((key) => !DRAWS.has(key))),\n])) as unknown as Record<NodeDimension, ReadonlySet<string>>;\n\nconst MISSING = new WeakMap<Node, MissingNodeInfo>();\n\n/** Stands in for every placeholder's class when a build compares a live node's class with its row's. */\nexport const MISSING_TYPE: unique symbol = Symbol(\"missingNodeType\");\n\n/** @internal A placeholder for `spec`, in `dimension`, taking what it can of `props` (the literal half of the row's). */\nexport function missingNode(dimension: NodeDimension, spec: NodeSpec, props: Record<string, unknown>): Node {\n const node = new PLACEHOLDERS[dimension]({\n ...placeholderProps(dimension, props),\n id: spec.id,\n ...(spec.key !== undefined && { key: spec.key }),\n });\n MISSING.set(node, { type: spec.type, props: spec.props });\n return node;\n}\n\n/** @internal Of a props bag, what a placeholder of `dimension` takes. */\nexport function placeholderProps(dimension: NodeDimension, props: Record<string, unknown>): Record<string, unknown> {\n const kept = KEPT[dimension];\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) if (kept.has(key)) out[key] = value;\n return out;\n}\n\n/**\n * The unknown type a live node stands in for, or `undefined` for a real node —\n * so a host can mark the row and keep its props for when the type is back.\n */\nexport function missingNodeOf(node: Node): MissingNodeInfo | undefined {\n return MISSING.get(node);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"node-decorator.js","sourceRoot":"","sources":["../../src/document/node-decorator.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,IAAI,CAAC,IAAiC;IAClD,iEAAiE;IACjE,4EAA4E;IAC5E,2EAA2E;IAC3E,OAAO;IACP,OAAO,UAAsD,IAAO;QAChE,MAAM,UAAU,GAAuB,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACtF,IAAI,CAAC,SAAqC,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC;QACpE,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAsC;IACpE,MAAM,KAAK,GAAG,IAAI,CAAC,SAAgD,CAAC;IACpE,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IACxF,OAAO,KAAK,CAAC,SAAS,CAAuB,CAAC;AAClD,CAAC","sourcesContent":["import type { NodeTypeDescriptor } from \"./node-descriptor\";\r\n\r\n/** Symbol under which `node` metadata is stored on a class prototype. */\r\nexport const NODE_META = Symbol(\"nodeMeta\");\r\n\r\n/**\r\n * Declare a node class's document key — and nothing else.\r\n *\r\n * **It does not register.** Registration happens when the class is handed to a\r\n * `Registry` (`new Engine(platform, { nodes: [Blob] })`), because a registry is\r\n * a value an engine owns rather than a table the module graph writes into. A\r\n * declaration that registered made the *order modules happened to be imported in*\r\n * part of the engine's state: whichever host loaded first won the key, a second\r\n * engine in the same process inherited a vocabulary it never asked for, and a\r\n * class that was merely imported was already registered whether or not anything\r\n * meant to offer it.\r\n *\r\n * What is left is a declaration, read back by {@link getNodeDescriptor}. A\r\n * component factory makes it for the class it generates (`component2d({ key })`);\r\n * a hand-written class makes it itself:\r\n *\r\n * ```ts\r\n * class Blob extends Node2D<BlobProps> {\r\n * declare readonly wobble: number;\r\n * wobbleTo(args: CommandArgs<{ wobble: number }>) { … }\r\n * }\r\n * declareMembers(Blob, {\r\n * wobble: property({ default: 0.4 }),\r\n * wobbleTo: command({ args: [\"wobble\"] }),\r\n * });\r\n * node(\"blob\")(Blob);\r\n *\r\n * const registry = new Registry({ nodes: [Blob] });\r\n * // { \"type\": \"blob\", \"props\": { \"wobble\": 0.4 } }\r\n * ```\r\n *\r\n * The full form declares everything a host needs to *offer* the type — the\r\n * shelves it sits on, how it lays children out, what a freshly placed one is\r\n * seeded with — which is what a component package used to restate in a\r\n * `manifest.json` beside a class nothing checked it against:\r\n *\r\n * ```ts\r\n * node({\r\n * key: \"lineChart\",\r\n * forkable: true,\r\n * layout: { children: \"freeform\", acceptsChildren: true },\r\n * seed: { width: 760, height: 460 },\r\n * })(LineChart);\r\n * ```\r\n *\r\n * None of it is read while rendering — see {@link NodeTypeDescriptor}.\r\n *\r\n * **The key is written out, not taken from the class name.** A minifier is free\r\n * to rename `Blob` to `o`, and the key is what stored documents contain — so a\r\n * derived one would work in development and silently rewrite every document's\r\n * vocabulary in a production bundle. It is public API, and spelled like it.\r\n */\r\nexport function node(type: string | NodeTypeDescriptor) {\r\n // Deliberately looser than `NodeConstructor`, which takes a bare\r\n // `Record<string, unknown>`: a real node class declares its own props type,\r\n // and requiring assignability would reject exactly the classes this exists\r\n // for.\r\n return function <T extends new (...args: never[]) => object>(ctor: T): T {\r\n const descriptor: NodeTypeDescriptor = typeof type === \"string\" ? { key: type } : type;\r\n (ctor.prototype as Record<symbol, unknown>)[NODE_META] = descriptor;\r\n return ctor;\r\n };\r\n}\r\n\r\n/**\r\n * What `node` declared on this exact class, or `undefined`.\r\n *\r\n * Own prototype only, deliberately: a subclass inherits its parent's methods but\r\n * not its identity, and a `Card extends Rect` that answered to `\"rect\"` would\r\n * collide with the real one the moment both were registered.\r\n */\r\nexport function getNodeDescriptor(ctor: new (...args: never[]) => object): NodeTypeDescriptor | undefined {\r\n const proto = ctor.prototype as Record<symbol, unknown> | undefined;\r\n if (!proto || !Object.prototype.hasOwnProperty.call(proto, NODE_META)) return undefined;\r\n return proto[NODE_META] as NodeTypeDescriptor;\r\n}\r\n"]}
1
+ {"version":3,"file":"node-decorator.js","sourceRoot":"","sources":["../../src/document/node-decorator.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,IAAI,CAAC,IAAiC;IAClD,iEAAiE;IACjE,4EAA4E;IAC5E,2EAA2E;IAC3E,OAAO;IACP,OAAO,UAAsD,IAAO;QAChE,MAAM,UAAU,GAAuB,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACtF,IAAI,CAAC,SAAqC,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC;QACpE,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAsC;IACpE,MAAM,KAAK,GAAG,IAAI,CAAC,SAAgD,CAAC;IACpE,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IACxF,OAAO,KAAK,CAAC,SAAS,CAAuB,CAAC;AAClD,CAAC","sourcesContent":["import type { NodeTypeDescriptor } from \"./node-descriptor\";\n\n/** Symbol under which `node` metadata is stored on a class prototype. */\nexport const NODE_META = Symbol(\"nodeMeta\");\n\n/**\n * Declare a node class's document key — and nothing else.\n *\n * **It does not register.** Registration happens when the class is handed to a\n * `Registry` (`new Engine(platform, { nodes: [Blob] })`), because a registry is\n * a value an engine owns rather than a table the module graph writes into. A\n * declaration that registered made the *order modules happened to be imported in*\n * part of the engine's state: whichever host loaded first won the key, a second\n * engine in the same process inherited a vocabulary it never asked for, and a\n * class that was merely imported was already registered whether or not anything\n * meant to offer it.\n *\n * What is left is a declaration, read back by {@link getNodeDescriptor}. A\n * component factory makes it for the class it generates (`component2d({ key })`);\n * a hand-written class makes it itself:\n *\n * ```ts\n * class Blob extends Node2D<BlobProps> {\n * declare readonly wobble: number;\n * wobbleTo(args: CommandArgs<{ wobble: number }>) { … }\n * }\n * declareMembers(Blob, {\n * wobble: property({ default: 0.4 }),\n * wobbleTo: command({ args: [\"wobble\"] }),\n * });\n * node(\"blob\")(Blob);\n *\n * const registry = new Registry({ nodes: [Blob] });\n * // { \"type\": \"blob\", \"props\": { \"wobble\": 0.4 } }\n * ```\n *\n * The full form declares everything a host needs to *offer* the type — the\n * shelves it sits on, how it lays children out, what a freshly placed one is\n * seeded with — which is what a component package used to restate in a\n * `manifest.json` beside a class nothing checked it against:\n *\n * ```ts\n * node({\n * key: \"lineChart\",\n * forkable: true,\n * layout: { children: \"freeform\", acceptsChildren: true },\n * seed: { width: 760, height: 460 },\n * })(LineChart);\n * ```\n *\n * None of it is read while rendering — see {@link NodeTypeDescriptor}.\n *\n * **The key is written out, not taken from the class name.** A minifier is free\n * to rename `Blob` to `o`, and the key is what stored documents contain — so a\n * derived one would work in development and silently rewrite every document's\n * vocabulary in a production bundle. It is public API, and spelled like it.\n */\nexport function node(type: string | NodeTypeDescriptor) {\n // Deliberately looser than `NodeConstructor`, which takes a bare\n // `Record<string, unknown>`: a real node class declares its own props type,\n // and requiring assignability would reject exactly the classes this exists\n // for.\n return function <T extends new (...args: never[]) => object>(ctor: T): T {\n const descriptor: NodeTypeDescriptor = typeof type === \"string\" ? { key: type } : type;\n (ctor.prototype as Record<symbol, unknown>)[NODE_META] = descriptor;\n return ctor;\n };\n}\n\n/**\n * What `node` declared on this exact class, or `undefined`.\n *\n * Own prototype only, deliberately: a subclass inherits its parent's methods but\n * not its identity, and a `Card extends Rect` that answered to `\"rect\"` would\n * collide with the real one the moment both were registered.\n */\nexport function getNodeDescriptor(ctor: new (...args: never[]) => object): NodeTypeDescriptor | undefined {\n const proto = ctor.prototype as Record<symbol, unknown> | undefined;\n if (!proto || !Object.prototype.hasOwnProperty.call(proto, NODE_META)) return undefined;\n return proto[NODE_META] as NodeTypeDescriptor;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"node-descriptor.js","sourceRoot":"","sources":["../../src/document/node-descriptor.ts"],"names":[],"mappings":"","sourcesContent":["import type { PropertyEditor } from \"@/attributes/properties/decorator\";\r\nimport type { NodeDimension } from \"@/components/trees/node/node\";\r\n\r\n/**\r\n * What a node type declares about itself beyond its key.\r\n *\r\n * The **technical** description of a type — how it lays children out, what a\r\n * fresh one is seeded with, what it inherits from. Deliberately *not* how it is\r\n * presented: no display name, no icon, no shelf, no copy. Those are a host's to\r\n * resolve and to translate, and a component that carried them would be shipping\r\n * one language's product decisions inside an engine artifact.\r\n *\r\n * It replaced a `manifest.json` written beside each package. Two descriptions of\r\n * one class is the shape that drifts, and it did: eight of nine packages ended\r\n * up promising commands their classes had never implemented.\r\n *\r\n * **Nothing here is read while rendering.** A frame is identical whether a type\r\n * declares a seed or not. It exists so a host has one place to ask.\r\n */\r\nexport interface NodeTypeDescriptor {\r\n /**\r\n * The document key, matching `NodeSpec.type`.\r\n *\r\n * **Frozen** for anything already published: a stored document naming it has\r\n * to keep meaning the same thing forever.\r\n */\r\n key: string;\r\n /** The type it inherits editing sections and commands from, for a host that groups them. */\r\n parentKey?: string;\r\n /**\r\n * Which scene graph the type belongs to — **derived from the class**, never\r\n * written here, for the same reason {@link properties} is.\r\n *\r\n * `dimension` is a getter on the prototype precisely so it answers before a\r\n * node is constructed, which is what lets a host ask \"can this type go in\r\n * that tree?\" from the registry alone rather than by building one and\r\n * catching the throw.\r\n */\r\n dimension?: NodeDimension;\r\n /**\r\n * The trees it takes children from: its own, or a viewport's two (a Canvas\r\n * 3D takes 2D and 3D); empty for a type that takes none. **Derived** from\r\n * the class, as {@link dimension} is.\r\n */\r\n holds?: readonly NodeDimension[];\r\n /**\r\n * Whether a host may copy this component's source.\r\n *\r\n * False for anything a host reaches into by identity — its own primitives. A\r\n * type is forkable exactly when the host knows nothing about it beyond this.\r\n */\r\n forkable?: boolean;\r\n\r\n layout?: NodeLayoutDescriptor;\r\n /** What a freshly placed one's props are seeded with. */\r\n seed?: Record<string, unknown>;\r\n\r\n /**\r\n * The types this one goes inside: a plot in a coordinate system, a tangent\r\n * in a plot. A name also stands for every type built on it ({@link parentKey}).\r\n * Unsaid, it goes wherever its {@link dimension} allows.\r\n *\r\n * A statement about the class, not a rule the engine enforces: a node put\r\n * elsewhere still builds and usually draws nothing, which is exactly what\r\n * a host is told here so it can offer the type only where it works. See\r\n * `placement.ts`.\r\n */\r\n within?: readonly string[];\r\n /**\r\n * Types it needs at least one of beside it, under the same parent: an area\r\n * between curves needs a curve. For a requirement that is not a parent,\r\n * because the thing needed is shared or there may be several of it.\r\n */\r\n beside?: readonly string[];\r\n /** Takes only the children that name it in their {@link within}: a plot holds its marks, not a photograph. */\r\n closed?: boolean;\r\n\r\n /**\r\n * The editable properties, by key — **derived from `property`**, never\r\n * written here.\r\n *\r\n * A hand-written list of a class's properties, beside a class of\r\n * properties, is exactly the restatement this whole descriptor exists to\r\n * remove. What a host needs beyond the key — a range, an enum's choices, the\r\n * controls inside an object-valued prop — is declared on the `property`\r\n * itself, which is the thing being edited.\r\n */\r\n properties?: Record<string, NodePropertyDescriptor>;\r\n /** Old prop keys a stored row may still carry → the entry each became. **Derived** from the component's `renamed`. */\r\n renamed?: Readonly<Record<string, string>>;\r\n}\r\n\r\n/** One editable property, as a host draws it. */\r\nexport interface NodePropertyDescriptor extends PropertyEditor {\r\n /** The control to draw. Always present here, inferred when not declared. */\r\n kind: string;\r\n /** What a freshly placed node holds, when the class declares one. */\r\n default?: unknown;\r\n /** Present when the component deprecated it: why, and what to use instead. A host stops offering it. */\r\n deprecated?: string;\r\n}\r\n\r\n/** The layout answer a node type's children get from it. */\r\nexport interface NodeLayoutDescriptor {\r\n children?: \"flow\" | \"horizontal\" | \"vertical\" | \"grid\" | \"freeform\";\r\n acceptsChildren?: boolean;\r\n defaultWidthMode?: NodeSizeMode;\r\n defaultHeightMode?: NodeSizeMode;\r\n /** What a freshly placed one is sized to. */\r\n defaultWidth?: number;\r\n defaultHeight?: number;\r\n /** A locked width:height, for a type whose box *is* its design. */\r\n aspectRatio?: number;\r\n}\r\n\r\n/** How a node type sizes one axis. */\r\nexport type NodeSizeMode = \"fixed\" | \"hug\" | \"fill\";\r\n"]}
1
+ {"version":3,"file":"node-descriptor.js","sourceRoot":"","sources":["../../src/document/node-descriptor.ts"],"names":[],"mappings":"","sourcesContent":["import type { PropertyEditor } from \"@/attributes/properties/decorator\";\nimport type { NodeDimension } from \"@/components/trees/node/node\";\n\n/**\n * What a node type declares about itself beyond its key.\n *\n * The **technical** description of a type — how it lays children out, what a\n * fresh one is seeded with, what it inherits from. Deliberately *not* how it is\n * presented: no display name, no icon, no shelf, no copy. Those are a host's to\n * resolve and to translate, and a component that carried them would be shipping\n * one language's product decisions inside an engine artifact.\n *\n * It replaced a `manifest.json` written beside each package. Two descriptions of\n * one class is the shape that drifts, and it did: eight of nine packages ended\n * up promising commands their classes had never implemented.\n *\n * **Nothing here is read while rendering.** A frame is identical whether a type\n * declares a seed or not. It exists so a host has one place to ask.\n */\nexport interface NodeTypeDescriptor {\n /**\n * The document key, matching `NodeSpec.type`.\n *\n * **Frozen** for anything already published: a stored document naming it has\n * to keep meaning the same thing forever.\n */\n key: string;\n /** The type it inherits editing sections and commands from, for a host that groups them. */\n parentKey?: string;\n /**\n * Which scene graph the type belongs to — **derived from the class**, never\n * written here, for the same reason {@link properties} is.\n *\n * `dimension` is a getter on the prototype precisely so it answers before a\n * node is constructed, which is what lets a host ask \"can this type go in\n * that tree?\" from the registry alone rather than by building one and\n * catching the throw.\n */\n dimension?: NodeDimension;\n /**\n * The trees it takes children from: its own, or a viewport's two (a Canvas\n * 3D takes 2D and 3D); empty for a type that takes none. **Derived** from\n * the class, as {@link dimension} is.\n */\n holds?: readonly NodeDimension[];\n /**\n * Whether a host may copy this component's source.\n *\n * False for anything a host reaches into by identity — its own primitives. A\n * type is forkable exactly when the host knows nothing about it beyond this.\n */\n forkable?: boolean;\n\n layout?: NodeLayoutDescriptor;\n /** What a freshly placed one's props are seeded with. */\n seed?: Record<string, unknown>;\n\n /**\n * The types this one goes inside: a plot in a coordinate system, a tangent\n * in a plot. A name also stands for every type built on it ({@link parentKey}).\n * Unsaid, it goes wherever its {@link dimension} allows.\n *\n * A statement about the class, not a rule the engine enforces: a node put\n * elsewhere still builds and usually draws nothing, which is exactly what\n * a host is told here so it can offer the type only where it works. See\n * `placement.ts`.\n */\n within?: readonly string[];\n /**\n * Types it needs at least one of beside it, under the same parent: an area\n * between curves needs a curve. For a requirement that is not a parent,\n * because the thing needed is shared or there may be several of it.\n */\n beside?: readonly string[];\n /** Takes only the children that name it in their {@link within}: a plot holds its marks, not a photograph. */\n closed?: boolean;\n\n /**\n * The editable properties, by key — **derived from `property`**, never\n * written here.\n *\n * A hand-written list of a class's properties, beside a class of\n * properties, is exactly the restatement this whole descriptor exists to\n * remove. What a host needs beyond the key — a range, an enum's choices, the\n * controls inside an object-valued prop — is declared on the `property`\n * itself, which is the thing being edited.\n */\n properties?: Record<string, NodePropertyDescriptor>;\n /** Old prop keys a stored row may still carry → the entry each became. **Derived** from the component's `renamed`. */\n renamed?: Readonly<Record<string, string>>;\n}\n\n/** One editable property, as a host draws it. */\nexport interface NodePropertyDescriptor extends PropertyEditor {\n /** The control to draw. Always present here, inferred when not declared. */\n kind: string;\n /** What a freshly placed node holds, when the class declares one. */\n default?: unknown;\n /** Present when the component deprecated it: why, and what to use instead. A host stops offering it. */\n deprecated?: string;\n}\n\n/** The layout answer a node type's children get from it. */\nexport interface NodeLayoutDescriptor {\n children?: \"flow\" | \"horizontal\" | \"vertical\" | \"grid\" | \"freeform\";\n acceptsChildren?: boolean;\n defaultWidthMode?: NodeSizeMode;\n defaultHeightMode?: NodeSizeMode;\n /** What a freshly placed one is sized to. */\n defaultWidth?: number;\n defaultHeight?: number;\n /** A locked width:height, for a type whose box *is* its design. */\n aspectRatio?: number;\n}\n\n/** How a node type sizes one axis. */\nexport type NodeSizeMode = \"fixed\" | \"hug\" | \"fill\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/document/placement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AA0CtD,mEAAmE;AACnE,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B,uEAAuE;AACvE,MAAM,UAAU,WAAW,CAAC,QAAkB,EAAE,IAAY,EAAE,IAAY;IACtE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,IAAI,EAAE,GAAuB,IAAI,EAAE,EAAE,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC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MAAM,KAAK,GACP,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC;YACrD,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QACjG,IAAI,KAAK;YAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,+FAA+F;AAC/F,SAAS,OAAO,CAAC,KAAwB,EAAE,GAAW;IAClD,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC","sourcesContent":["import type { Registry } from \"./registry\";\r\nimport { ROOT_NODE_ID, type NodeSpec } from \"./types\";\r\n\r\n/**\r\n * Where a node type may go, read off the registry without building anything:\r\n * the answer a host needs before it offers a type under a parent, accepts a\r\n * drop, or lets an assistant create a row.\r\n *\r\n * Four things decide it. A parent that takes no children takes none. The two\r\n * trees do not mix: a `Node3D` lives under a Canvas 3D or another 3D node, and\r\n * nothing else does. A type that names where it goes ({@link\r\n * NodeTypeDescriptor.within}) goes only there, and a {@link\r\n * NodeTypeDescriptor.closed} parent takes only the types that name it. Those\r\n * are about the parent; {@link NodeTypeDescriptor.beside} is about the\r\n * siblings, and is kept apart because a host can meet it by adding one.\r\n *\r\n * Only a leaf is enforced when a document is built: a component declaring\r\n * `allowedChildren: []` throws on a child. A node in any other wrong place\r\n * builds and, as a rule, draws nothing; this says why.\r\n */\r\n\r\n/** Why a node of a type is not where it can work. */\r\nexport type PlacementIssue =\r\n /** The parent takes no children. */\r\n | { kind: \"leaf\"; parent: string }\r\n /** A 3D node outside a 3D tree, or anything else inside one. */\r\n | { kind: \"dimension\"; parent: string | null }\r\n /** It goes inside one of `within`, and the parent is none of them. */\r\n | { kind: \"within\"; within: readonly string[] }\r\n /** The parent takes only the types that name it. */\r\n | { kind: \"closed\"; parent: string }\r\n /** It needs one of `beside` under the same parent, and there is none. */\r\n | { kind: \"beside\"; beside: readonly string[] };\r\n\r\nexport interface PlacementOptions {\r\n /**\r\n * A host's own sense of one type standing for another, beside the\r\n * registry's: a copy of a component it made under a new key is still that\r\n * component to whatever goes inside it.\r\n */\r\n isA?: (type: string, name: string) => boolean;\r\n}\r\n\r\n/** The one core type whose children are of the other dimension. */\r\nconst CANVAS_3D = \"canvas3d\";\r\n\r\n/** Whether `type` is `name`, or is built on it through `parentKey`. */\r\nexport function nodeTypeIsA(registry: Registry, type: string, name: string): boolean {\r\n const seen = new Set<string>();\r\n for (let at: string | undefined = type; at !== undefined && !seen.has(at); at = registry.describe(at)?.parentKey) {\r\n if (at === name) return true;\r\n seen.add(at);\r\n }\r\n return false;\r\n}\r\n\r\nfunction among(registry: Registry, type: string, names: readonly string[], options: PlacementOptions): boolean {\r\n return names.some((name) => nodeTypeIsA(registry, type, name) || options.isA?.(type, name) === true);\r\n}\r\n\r\n/**\r\n * Why a node of `child` cannot go directly inside one of `parent`, or `null`\r\n * when it can. A `null` parent is the document's own root, which is 2D and\r\n * names nothing.\r\n */\r\nexport function parentIssue(\r\n registry: Registry,\r\n child: string,\r\n parent: string | null,\r\n options: PlacementOptions = {},\r\n): PlacementIssue | null {\r\n const own = registry.describe(child);\r\n const holder = parent === null ? undefined : registry.describe(parent);\r\n if (parent !== null && (holder?.layout?.acceptsChildren === false || holder?.holds?.length === 0)) return { kind: \"leaf\", parent };\r\n\r\n const within = own?.within ?? [];\r\n if (within.length > 0 && (parent === null || !among(registry, parent, within, options))) {\r\n return { kind: \"within\", within };\r\n }\r\n if (parent !== null && holder?.closed === true && !among(registry, parent, within, options)) {\r\n return { kind: \"closed\", parent };\r\n }\r\n\r\n const inThree = parent !== null && (holder?.dimension === \"3d\" || holder?.holds?.includes(\"3d\") === true || among(registry, parent, [CANVAS_3D], options));\r\n if ((own?.dimension === \"3d\") !== inThree) return { kind: \"dimension\", parent };\r\n return null;\r\n}\r\n\r\n/** The sibling `child` needs that `siblings`, the types already under its parent, do not include; `null` when it needs none or has one. */\r\nexport function siblingIssue(\r\n registry: Registry,\r\n child: string,\r\n siblings: readonly string[],\r\n options: PlacementOptions = {},\r\n): PlacementIssue | null {\r\n const beside = registry.describe(child)?.beside ?? [];\r\n if (beside.length === 0 || siblings.some((type) => among(registry, type, beside, options))) return null;\r\n return { kind: \"beside\", beside };\r\n}\r\n\r\n/**\r\n * Every node of `nodes` that is not where its type says it goes, by id, with\r\n * the first reason. A node of an unregistered type is left out: that is a build\r\n * error, and says so itself.\r\n */\r\nexport function placementIssues(\r\n registry: Registry,\r\n nodes: readonly Pick<NodeSpec, \"id\" | \"type\" | \"parentId\">[],\r\n options: PlacementOptions = {},\r\n): Map<string, PlacementIssue> {\r\n // A document may write its stage as a row or leave it out: either way its children's parent is the root.\r\n const parentOf = (node: Pick<NodeSpec, \"parentId\">) => (node.parentId === ROOT_NODE_ID ? null : node.parentId);\r\n const byId = new Map(nodes.map((node) => [node.id, node]));\r\n const children = new Map<string | null, string[]>();\r\n for (const node of nodes) {\r\n if (node.id === ROOT_NODE_ID) continue;\r\n const under = children.get(parentOf(node));\r\n if (under) under.push(node.type);\r\n else children.set(parentOf(node), [node.type]);\r\n }\r\n const issues = new Map<string, PlacementIssue>();\r\n for (const node of nodes) {\r\n if (node.id === ROOT_NODE_ID || !registry.hasNode(node.type)) continue;\r\n const parentId = parentOf(node);\r\n const parentType = parentId === null ? null : (byId.get(parentId)?.type ?? null);\r\n const issue =\r\n parentIssue(registry, node.type, parentType, options) ??\r\n siblingIssue(registry, node.type, without(children.get(parentId) ?? [], node.type), options);\r\n if (issue) issues.set(node.id, issue);\r\n }\r\n return issues;\r\n}\r\n\r\n// The node's own type once: a second area is a sibling of the first, the first is not its own.\r\nfunction without(types: readonly string[], own: string): string[] {\r\n const at = types.indexOf(own);\r\n return at === -1 ? [...types] : [...types.slice(0, at), ...types.slice(at + 1)];\r\n}\r\n"]}
1
+ {"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/document/placement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AA0CtD,mEAAmE;AACnE,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B,uEAAuE;AACvE,MAAM,UAAU,WAAW,CAAC,QAAkB,EAAE,IAAY,EAAE,IAAY;IACtE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,IAAI,EAAE,GAAuB,IAAI,EAAE,EAAE,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC;QAC/G,IAAI,EAAE,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,KAAK,CAAC,QAAkB,EAAE,IAAY,EAAE,KAAwB,EAAE,OAAyB;IAChG,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AACzG,CAAC;AAED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,CAAC;IAC9B,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC","sourcesContent":["import type { Registry } from \"./registry\";\nimport { ROOT_NODE_ID, type NodeSpec } from \"./types\";\n\n/**\n * Where a node type may go, read off the registry without building anything:\n * the answer a host needs before it offers a type under a parent, accepts a\n * drop, or lets an assistant create a row.\n *\n * Four things decide it. A parent that takes no children takes none. The two\n * trees do not mix: a `Node3D` lives under a Canvas 3D or another 3D node, and\n * nothing else does. A type that names where it goes ({@link\n * NodeTypeDescriptor.within}) goes only there, and a {@link\n * NodeTypeDescriptor.closed} parent takes only the types that name it. Those\n * are about the parent; {@link NodeTypeDescriptor.beside} is about the\n * siblings, and is kept apart because a host can meet it by adding one.\n *\n * Only a leaf is enforced when a document is built: a component declaring\n * `allowedChildren: []` throws on a child. A node in any other wrong place\n * builds and, as a rule, draws nothing; this says why.\n */\n\n/** Why a node of a type is not where it can work. */\nexport type PlacementIssue =\n /** The parent takes no children. */\n | { kind: \"leaf\"; parent: string }\n /** A 3D node outside a 3D tree, or anything else inside one. */\n | { kind: \"dimension\"; parent: string | null }\n /** It goes inside one of `within`, and the parent is none of them. */\n | { kind: \"within\"; within: readonly string[] }\n /** The parent takes only the types that name it. */\n | { kind: \"closed\"; parent: string }\n /** It needs one of `beside` under the same parent, and there is none. */\n | { kind: \"beside\"; beside: readonly string[] };\n\nexport interface PlacementOptions {\n /**\n * A host's own sense of one type standing for another, beside the\n * registry's: a copy of a component it made under a new key is still that\n * component to whatever goes inside it.\n */\n isA?: (type: string, name: string) => boolean;\n}\n\n/** The one core type whose children are of the other dimension. */\nconst CANVAS_3D = \"canvas3d\";\n\n/** Whether `type` is `name`, or is built on it through `parentKey`. */\nexport function nodeTypeIsA(registry: Registry, type: string, name: string): boolean {\n const seen = new Set<string>();\n for (let at: string | undefined = type; at !== undefined && !seen.has(at); at = registry.describe(at)?.parentKey) {\n if (at === name) return true;\n seen.add(at);\n }\n return false;\n}\n\nfunction among(registry: Registry, type: string, names: readonly string[], options: PlacementOptions): boolean {\n return names.some((name) => nodeTypeIsA(registry, type, name) || options.isA?.(type, name) === true);\n}\n\n/**\n * Why a node of `child` cannot go directly inside one of `parent`, or `null`\n * when it can. A `null` parent is the document's own root, which is 2D and\n * names nothing.\n */\nexport function parentIssue(\n registry: Registry,\n child: string,\n parent: string | null,\n options: PlacementOptions = {},\n): PlacementIssue | null {\n const own = registry.describe(child);\n const holder = parent === null ? undefined : registry.describe(parent);\n if (parent !== null && (holder?.layout?.acceptsChildren === false || holder?.holds?.length === 0)) return { kind: \"leaf\", parent };\n\n const within = own?.within ?? [];\n if (within.length > 0 && (parent === null || !among(registry, parent, within, options))) {\n return { kind: \"within\", within };\n }\n if (parent !== null && holder?.closed === true && !among(registry, parent, within, options)) {\n return { kind: \"closed\", parent };\n }\n\n const inThree = parent !== null && (holder?.dimension === \"3d\" || holder?.holds?.includes(\"3d\") === true || among(registry, parent, [CANVAS_3D], options));\n if ((own?.dimension === \"3d\") !== inThree) return { kind: \"dimension\", parent };\n return null;\n}\n\n/** The sibling `child` needs that `siblings`, the types already under its parent, do not include; `null` when it needs none or has one. */\nexport function siblingIssue(\n registry: Registry,\n child: string,\n siblings: readonly string[],\n options: PlacementOptions = {},\n): PlacementIssue | null {\n const beside = registry.describe(child)?.beside ?? [];\n if (beside.length === 0 || siblings.some((type) => among(registry, type, beside, options))) return null;\n return { kind: \"beside\", beside };\n}\n\n/**\n * Every node of `nodes` that is not where its type says it goes, by id, with\n * the first reason. A node of an unregistered type is left out: that is a build\n * error, and says so itself.\n */\nexport function placementIssues(\n registry: Registry,\n nodes: readonly Pick<NodeSpec, \"id\" | \"type\" | \"parentId\">[],\n options: PlacementOptions = {},\n): Map<string, PlacementIssue> {\n // A document may write its stage as a row or leave it out: either way its children's parent is the root.\n const parentOf = (node: Pick<NodeSpec, \"parentId\">) => (node.parentId === ROOT_NODE_ID ? null : node.parentId);\n const byId = new Map(nodes.map((node) => [node.id, node]));\n const children = new Map<string | null, string[]>();\n for (const node of nodes) {\n if (node.id === ROOT_NODE_ID) continue;\n const under = children.get(parentOf(node));\n if (under) under.push(node.type);\n else children.set(parentOf(node), [node.type]);\n }\n const issues = new Map<string, PlacementIssue>();\n for (const node of nodes) {\n if (node.id === ROOT_NODE_ID || !registry.hasNode(node.type)) continue;\n const parentId = parentOf(node);\n const parentType = parentId === null ? null : (byId.get(parentId)?.type ?? null);\n const issue =\n parentIssue(registry, node.type, parentType, options) ??\n siblingIssue(registry, node.type, without(children.get(parentId) ?? [], node.type), options);\n if (issue) issues.set(node.id, issue);\n }\n return issues;\n}\n\n// The node's own type once: a second area is a sibling of the first, the first is not its own.\nfunction without(types: readonly string[], own: string): string[] {\n const at = types.indexOf(own);\n return at === -1 ? [...types] : [...types.slice(0, at), ...types.slice(at + 1)];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/document/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA+E3C,gDAAgD;AAChD,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC1C,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAK,GAAuB,CAAC,IAAI,KAAK,SAAS,CAAC;AAClG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC7B,GAAqC,EACrC,SAA6D,EAAE;IAE/D,IAAI,iBAAiB,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,OAAO;QACH,IAAI,EAAE,SAAS;QACf,GAAG,CAAC,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE,CAAC;QAC5E,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,UAAU;QAC/B,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;KACvE,CAAC;AACN,CAAC","sourcesContent":["import type { Size2D } from \"@/attributes/layout/size\";\r\nimport type { Theme } from \"@/project/config\";\r\n\r\nimport type { ClipDocument, VisualDocument } from \"./types\";\r\nimport { documentDuration } from \"./types\";\r\n\r\n/**\r\n * The **project** as data: a whole video, not one clip — and the one thing the\r\n * runtime plays.\r\n *\r\n * A clip document says what happens inside one composition. This says how those\r\n * compositions are laid against each other to make the finished thing — and it\r\n * is the same idea one level up, so it reads the same way: rows placed at times,\r\n * evaluated rather than played.\r\n *\r\n * ### One list of tracks\r\n *\r\n * A {@link ClipDocument} is a still, a composition *or* an audio document, and a\r\n * composition already carries both picture and sound — so there is one list for\r\n * all of it, not a second one for sound.\r\n *\r\n * **Array position is paint order**, first entry at the back, exactly as\r\n * position in a `fill` array is. A background is the first track; an overlay is\r\n * the last; a cross-dissolve is two tracks whose spans overlap and whose clips\r\n * fade themselves.\r\n */\r\nexport interface ProjectDocument {\r\n kind: \"project\";\r\n /** The format it was written in — see `migrate.ts`. Absent is format 0, every document written before the field existed. */\r\n formatVersion?: number;\r\n /** Human-readable project name. */\r\n name: string;\r\n /** Target frame rate. Defaults to 60. */\r\n fps?: number;\r\n /** Output canvas dimensions in pixels. Defaults to 1920×1080. */\r\n viewport?: Size2D;\r\n /** Visual design tokens (colors, typography) available to every clip. */\r\n theme?: Theme;\r\n /**\r\n * Every clip, placed. **Array position is paint order** — the first entry is\r\n * at the back.\r\n */\r\n tracks: Track[];\r\n}\r\n\r\n/**\r\n * One clip, placed on the project timeline.\r\n *\r\n * The clip document is **inline**, not referenced by id. A shared id would deduplicate JSON and\r\n * cost an id space, a resolution step and a dangling-reference failure mode — and\r\n * it would not buy what it looks like it buys, because the content that actually\r\n * repeats in an edit mostly has to *differ* per placement (a lower third with\r\n * different text, a chapter card with a different label).\r\n */\r\nexport interface Track {\r\n /**\r\n * Stable identity, so a host can address, reorder and diff one row — and so\r\n * the runtime can keep a track's built tree across an edit that leaves its\r\n * clip untouched.\r\n */\r\n id: string;\r\n /** Display label. */\r\n name?: string;\r\n /** What plays: a still, a composition, or sound. */\r\n clip: ClipDocument;\r\n /**\r\n * Second on the **project** timeline at which this clip's own clock reads 0.\r\n * Authored, never derived from the row above it, so a clip's start cannot\r\n * move because a neighbour changed. Defaults to 0.\r\n */\r\n startAt?: number;\r\n /**\r\n * Seconds this clip occupies. **Required.**\r\n *\r\n * So a project's length is arithmetic over its tracks rather than something\r\n * measured out of a media file or a timeline — a three-minute music bed\r\n * cannot silently make a thirty-second edit three minutes long. Longer than\r\n * the document holds its last frame; shorter cuts it off, which is also what\r\n * lets a **still**, a document with no length at all, be a backdrop.\r\n */\r\n duration: number;\r\n}\r\n\r\n/** Narrows an unknown document to a project. */\r\nexport function isProjectDocument(doc: unknown): doc is ProjectDocument {\r\n return typeof doc === \"object\" && doc !== null && (doc as ProjectDocument).kind === \"project\";\r\n}\r\n\r\n/**\r\n * The project a session plays, from either document it can open.\r\n *\r\n * A lone still or composition becomes the only track of a project around it.\r\n * Viewport and fps describe the output rather than the clip, so they come from\r\n * the caller.\r\n */\r\nexport function asProjectDocument(\r\n doc: ProjectDocument | VisualDocument,\r\n output: { name?: string; viewport?: Size2D; fps?: number } = {},\r\n): ProjectDocument {\r\n if (isProjectDocument(doc)) return doc;\r\n return {\r\n kind: \"project\",\r\n ...(doc.formatVersion !== undefined && { formatVersion: doc.formatVersion }),\r\n name: output.name ?? \"Untitled\",\r\n fps: output.fps,\r\n viewport: output.viewport,\r\n theme: doc.theme,\r\n tracks: [{ id: \"clip\", clip: doc, duration: documentDuration(doc) }],\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/document/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA+E3C,gDAAgD;AAChD,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC1C,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAK,GAAuB,CAAC,IAAI,KAAK,SAAS,CAAC;AAClG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC7B,GAAqC,EACrC,SAA6D,EAAE;IAE/D,IAAI,iBAAiB,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,OAAO;QACH,IAAI,EAAE,SAAS;QACf,GAAG,CAAC,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE,CAAC;QAC5E,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,UAAU;QAC/B,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;KACvE,CAAC;AACN,CAAC","sourcesContent":["import type { Size2D } from \"@/attributes/layout/size\";\nimport type { Theme } from \"@/project/config\";\n\nimport type { ClipDocument, VisualDocument } from \"./types\";\nimport { documentDuration } from \"./types\";\n\n/**\n * The **project** as data: a whole video, not one clip — and the one thing the\n * runtime plays.\n *\n * A clip document says what happens inside one composition. This says how those\n * compositions are laid against each other to make the finished thing — and it\n * is the same idea one level up, so it reads the same way: rows placed at times,\n * evaluated rather than played.\n *\n * ### One list of tracks\n *\n * A {@link ClipDocument} is a still, a composition *or* an audio document, and a\n * composition already carries both picture and sound — so there is one list for\n * all of it, not a second one for sound.\n *\n * **Array position is paint order**, first entry at the back, exactly as\n * position in a `fill` array is. A background is the first track; an overlay is\n * the last; a cross-dissolve is two tracks whose spans overlap and whose clips\n * fade themselves.\n */\nexport interface ProjectDocument {\n kind: \"project\";\n /** The format it was written in — see `migrate.ts`. Absent is format 0, every document written before the field existed. */\n formatVersion?: number;\n /** Human-readable project name. */\n name: string;\n /** Target frame rate. Defaults to 60. */\n fps?: number;\n /** Output canvas dimensions in pixels. Defaults to 1920×1080. */\n viewport?: Size2D;\n /** Visual design tokens (colors, typography) available to every clip. */\n theme?: Theme;\n /**\n * Every clip, placed. **Array position is paint order** — the first entry is\n * at the back.\n */\n tracks: Track[];\n}\n\n/**\n * One clip, placed on the project timeline.\n *\n * The clip document is **inline**, not referenced by id. A shared id would deduplicate JSON and\n * cost an id space, a resolution step and a dangling-reference failure mode — and\n * it would not buy what it looks like it buys, because the content that actually\n * repeats in an edit mostly has to *differ* per placement (a lower third with\n * different text, a chapter card with a different label).\n */\nexport interface Track {\n /**\n * Stable identity, so a host can address, reorder and diff one row — and so\n * the runtime can keep a track's built tree across an edit that leaves its\n * clip untouched.\n */\n id: string;\n /** Display label. */\n name?: string;\n /** What plays: a still, a composition, or sound. */\n clip: ClipDocument;\n /**\n * Second on the **project** timeline at which this clip's own clock reads 0.\n * Authored, never derived from the row above it, so a clip's start cannot\n * move because a neighbour changed. Defaults to 0.\n */\n startAt?: number;\n /**\n * Seconds this clip occupies. **Required.**\n *\n * So a project's length is arithmetic over its tracks rather than something\n * measured out of a media file or a timeline — a three-minute music bed\n * cannot silently make a thirty-second edit three minutes long. Longer than\n * the document holds its last frame; shorter cuts it off, which is also what\n * lets a **still**, a document with no length at all, be a backdrop.\n */\n duration: number;\n}\n\n/** Narrows an unknown document to a project. */\nexport function isProjectDocument(doc: unknown): doc is ProjectDocument {\n return typeof doc === \"object\" && doc !== null && (doc as ProjectDocument).kind === \"project\";\n}\n\n/**\n * The project a session plays, from either document it can open.\n *\n * A lone still or composition becomes the only track of a project around it.\n * Viewport and fps describe the output rather than the clip, so they come from\n * the caller.\n */\nexport function asProjectDocument(\n doc: ProjectDocument | VisualDocument,\n output: { name?: string; viewport?: Size2D; fps?: number } = {},\n): ProjectDocument {\n if (isProjectDocument(doc)) return doc;\n return {\n kind: \"project\",\n ...(doc.formatVersion !== undefined && { formatVersion: doc.formatVersion }),\n name: output.name ?? \"Untitled\",\n fps: output.fps,\n viewport: output.viewport,\n theme: doc.theme,\n tracks: [{ id: \"clip\", clip: doc, duration: documentDuration(doc) }],\n };\n}\n"]}