@motionscript/core 0.1.0-alpha.6 → 0.1.0-alpha.7

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 (445) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +2 -4
  3. package/dist/assets/errors.js +4 -5
  4. package/dist/assets/errors.js.map +1 -1
  5. package/dist/assets/scope.d.ts +1 -1
  6. package/dist/assets/scope.d.ts.map +1 -1
  7. package/dist/assets/scope.js +1 -1
  8. package/dist/assets/scope.js.map +1 -1
  9. package/dist/attributes/audio/schedule.d.ts +3 -18
  10. package/dist/attributes/audio/schedule.d.ts.map +1 -1
  11. package/dist/attributes/audio/schedule.js.map +1 -1
  12. package/dist/attributes/index.d.ts +3 -5
  13. package/dist/attributes/index.d.ts.map +1 -1
  14. package/dist/attributes/index.js +2 -2
  15. package/dist/attributes/index.js.map +1 -1
  16. package/dist/attributes/layout/insets.d.ts +1 -1
  17. package/dist/attributes/layout/insets.js.map +1 -1
  18. package/dist/attributes/layout/size.d.ts +1 -1
  19. package/dist/attributes/layout/size.js +1 -1
  20. package/dist/attributes/layout/size.js.map +1 -1
  21. package/dist/attributes/properties/decorator.d.ts +44 -11
  22. package/dist/attributes/properties/decorator.d.ts.map +1 -1
  23. package/dist/attributes/properties/decorator.js +37 -9
  24. package/dist/attributes/properties/decorator.js.map +1 -1
  25. package/dist/attributes/properties/inputs.d.ts +1 -1
  26. package/dist/attributes/properties/inputs.js +1 -1
  27. package/dist/attributes/properties/inputs.js.map +1 -1
  28. package/dist/attributes/properties/typed.d.ts +19 -140
  29. package/dist/attributes/properties/typed.d.ts.map +1 -1
  30. package/dist/attributes/properties/typed.js +12 -108
  31. package/dist/attributes/properties/typed.js.map +1 -1
  32. package/dist/attributes/shape/corners/corner-radius.d.ts +1 -1
  33. package/dist/attributes/shape/corners/corner-radius.js +1 -1
  34. package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
  35. package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +1 -1
  36. package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
  37. package/dist/attributes/shape/fill/color/parser.d.ts +1 -1
  38. package/dist/attributes/shape/fill/color/parser.js +1 -1
  39. package/dist/attributes/shape/fill/color/parser.js.map +1 -1
  40. package/dist/attributes/shape/fill/implementations/canvas3d.d.ts +2 -2
  41. package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
  42. package/dist/attributes/shape/fill/implementations/shader.d.ts +2 -2
  43. package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
  44. package/dist/attributes/shape/fill/implementations/video.d.ts +1 -1
  45. package/dist/attributes/shape/fill/implementations/video.js +1 -1
  46. package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
  47. package/dist/attributes/shape/fill/lerp.d.ts +1 -1
  48. package/dist/attributes/shape/fill/lerp.js.map +1 -1
  49. package/dist/attributes/shape/filters/chain.d.ts +1 -1
  50. package/dist/attributes/shape/filters/chain.js +1 -1
  51. package/dist/attributes/shape/filters/chain.js.map +1 -1
  52. package/dist/attributes/shape/filters/union.d.ts +4 -3
  53. package/dist/attributes/shape/filters/union.d.ts.map +1 -1
  54. package/dist/attributes/shape/filters/union.js.map +1 -1
  55. package/dist/attributes/shape/path/ops.d.ts +1 -2
  56. package/dist/attributes/shape/path/ops.d.ts.map +1 -1
  57. package/dist/attributes/shape/path/ops.js.map +1 -1
  58. package/dist/attributes/shared/operators.d.ts +2 -2
  59. package/dist/attributes/shared/operators.js.map +1 -1
  60. package/dist/attributes/text/types.d.ts +2 -3
  61. package/dist/attributes/text/types.d.ts.map +1 -1
  62. package/dist/attributes/text/types.js.map +1 -1
  63. package/dist/browser/chunks/chunk-D4FSTPML.js +14 -0
  64. package/dist/browser/chunks/chunk-D4FSTPML.js.map +7 -0
  65. package/dist/browser/chunks/chunk-LKUYVFU3.js +2 -0
  66. package/dist/browser/chunks/{chunk-DHB4COFY.js.map → chunk-LKUYVFU3.js.map} +4 -4
  67. package/dist/browser/chunks/chunk-RTNATFWX.js +5 -0
  68. package/dist/browser/chunks/chunk-RTNATFWX.js.map +7 -0
  69. package/dist/browser/chunks/chunk-ZRPZPWZU.js +3 -0
  70. package/dist/browser/chunks/chunk-ZRPZPWZU.js.map +7 -0
  71. package/dist/browser/component.js +1 -1
  72. package/dist/browser/component.js.map +4 -4
  73. package/dist/browser/experimental.js +1 -1
  74. package/dist/browser/index.js +1 -1
  75. package/dist/browser/index.js.map +4 -4
  76. package/dist/browser/manifest.json +2 -4
  77. package/dist/browser/sdk.js +1 -1
  78. package/dist/component.d.ts +10 -18
  79. package/dist/component.d.ts.map +1 -1
  80. package/dist/component.js +10 -17
  81. package/dist/component.js.map +1 -1
  82. package/dist/components/builtins/audio/audio.d.ts +53 -0
  83. package/dist/components/builtins/audio/audio.d.ts.map +1 -0
  84. package/dist/components/builtins/audio/audio.js +41 -0
  85. package/dist/components/builtins/audio/audio.js.map +1 -0
  86. package/dist/components/builtins/geometry/composite.d.ts +93 -0
  87. package/dist/components/builtins/geometry/composite.d.ts.map +1 -0
  88. package/dist/components/builtins/geometry/composite.js +25 -0
  89. package/dist/components/builtins/geometry/composite.js.map +1 -0
  90. package/dist/components/builtins/geometry/geometry.d.ts +921 -0
  91. package/dist/components/builtins/geometry/geometry.d.ts.map +1 -0
  92. package/dist/components/builtins/geometry/geometry.js +107 -0
  93. package/dist/components/builtins/geometry/geometry.js.map +1 -0
  94. package/dist/components/builtins/geometry/shape-outline.d.ts +93 -0
  95. package/dist/components/builtins/geometry/shape-outline.d.ts.map +1 -0
  96. package/dist/components/builtins/geometry/shape-outline.js +470 -0
  97. package/dist/components/builtins/geometry/shape-outline.js.map +1 -0
  98. package/dist/components/builtins/layout/layout.d.ts +186 -0
  99. package/dist/components/builtins/layout/layout.d.ts.map +1 -0
  100. package/dist/components/builtins/layout/layout.js +84 -0
  101. package/dist/components/builtins/layout/layout.js.map +1 -0
  102. package/dist/components/builtins/media/media.d.ts +240 -0
  103. package/dist/components/builtins/media/media.d.ts.map +1 -0
  104. package/dist/components/builtins/media/media.js +149 -0
  105. package/dist/components/builtins/media/media.js.map +1 -0
  106. package/dist/components/builtins/providers/providers.d.ts +47 -0
  107. package/dist/components/builtins/providers/providers.d.ts.map +1 -0
  108. package/dist/components/builtins/providers/providers.js +30 -0
  109. package/dist/components/builtins/providers/providers.js.map +1 -0
  110. package/dist/components/builtins/text/number-format.d.ts +66 -0
  111. package/dist/components/builtins/text/number-format.d.ts.map +1 -0
  112. package/dist/components/builtins/text/number-format.js +227 -0
  113. package/dist/components/builtins/text/number-format.js.map +1 -0
  114. package/dist/components/builtins/text/number-pattern.d.ts +51 -0
  115. package/dist/components/builtins/text/number-pattern.d.ts.map +1 -0
  116. package/dist/components/builtins/text/number-pattern.js +77 -0
  117. package/dist/components/builtins/text/number-pattern.js.map +1 -0
  118. package/dist/components/builtins/text/text-defaults.d.ts +32 -0
  119. package/dist/components/builtins/text/text-defaults.d.ts.map +1 -0
  120. package/dist/components/builtins/text/text-defaults.js +37 -0
  121. package/dist/components/builtins/text/text-defaults.js.map +1 -0
  122. package/dist/components/builtins/text/text-layout.d.ts +82 -0
  123. package/dist/components/builtins/text/text-layout.d.ts.map +1 -0
  124. package/dist/components/builtins/text/text-layout.js +331 -0
  125. package/dist/components/builtins/text/text-layout.js.map +1 -0
  126. package/dist/components/builtins/text/text.d.ts +409 -0
  127. package/dist/components/builtins/text/text.d.ts.map +1 -0
  128. package/dist/components/builtins/text/text.js +113 -0
  129. package/dist/components/builtins/text/text.js.map +1 -0
  130. package/dist/components/builtins/three/canvas3d.d.ts +245 -0
  131. package/dist/components/builtins/three/canvas3d.d.ts.map +1 -0
  132. package/dist/components/builtins/three/canvas3d.js +21 -0
  133. package/dist/components/builtins/three/canvas3d.js.map +1 -0
  134. package/dist/components/builtins/three/grid-geometry3d.d.ts +62 -0
  135. package/dist/components/builtins/three/grid-geometry3d.d.ts.map +1 -0
  136. package/dist/components/builtins/three/grid-geometry3d.js +114 -0
  137. package/dist/components/builtins/three/grid-geometry3d.js.map +1 -0
  138. package/dist/components/builtins/three/three.d.ts +1889 -0
  139. package/dist/components/builtins/three/three.d.ts.map +1 -0
  140. package/dist/components/builtins/three/three.js +305 -0
  141. package/dist/components/builtins/three/three.js.map +1 -0
  142. package/dist/components/factory/api.d.ts +516 -0
  143. package/dist/components/factory/api.d.ts.map +1 -0
  144. package/dist/components/factory/api.js +4 -0
  145. package/dist/components/factory/api.js.map +1 -0
  146. package/dist/components/factory/clip-of.d.ts +5 -0
  147. package/dist/components/factory/clip-of.d.ts.map +1 -0
  148. package/dist/components/factory/clip-of.js +33 -0
  149. package/dist/components/factory/clip-of.js.map +1 -0
  150. package/dist/components/factory/commands-for.d.ts +19 -0
  151. package/dist/components/factory/commands-for.d.ts.map +1 -0
  152. package/dist/components/factory/commands-for.js +5 -0
  153. package/dist/components/factory/commands-for.js.map +1 -0
  154. package/dist/components/factory/component-audio.d.ts +9 -0
  155. package/dist/components/factory/component-audio.d.ts.map +1 -0
  156. package/dist/components/factory/component-audio.js +18 -0
  157. package/dist/components/factory/component-audio.js.map +1 -0
  158. package/dist/components/factory/component2d.d.ts +8 -0
  159. package/dist/components/factory/component2d.d.ts.map +1 -0
  160. package/dist/components/factory/component2d.js +240 -0
  161. package/dist/components/factory/component2d.js.map +1 -0
  162. package/dist/components/factory/component3d.d.ts +9 -0
  163. package/dist/components/factory/component3d.d.ts.map +1 -0
  164. package/dist/components/factory/component3d.js +99 -0
  165. package/dist/components/factory/component3d.js.map +1 -0
  166. package/dist/components/factory/factory.d.ts +63 -0
  167. package/dist/components/factory/factory.d.ts.map +1 -0
  168. package/dist/components/factory/factory.js +313 -0
  169. package/dist/components/factory/factory.js.map +1 -0
  170. package/dist/components/factory/timeline.d.ts +22 -0
  171. package/dist/components/factory/timeline.d.ts.map +1 -0
  172. package/dist/components/factory/timeline.js +128 -0
  173. package/dist/components/factory/timeline.js.map +1 -0
  174. package/dist/components/factory/type-def.d.ts +26 -0
  175. package/dist/components/factory/type-def.d.ts.map +1 -0
  176. package/dist/components/factory/type-def.js +16 -0
  177. package/dist/components/factory/type-def.js.map +1 -0
  178. package/dist/components/factory/types.d.ts +91 -0
  179. package/dist/components/factory/types.d.ts.map +1 -0
  180. package/dist/components/factory/types.js +88 -0
  181. package/dist/components/factory/types.js.map +1 -0
  182. package/dist/components/factory/views.d.ts +121 -0
  183. package/dist/components/factory/views.d.ts.map +1 -0
  184. package/dist/components/factory/views.js +413 -0
  185. package/dist/components/factory/views.js.map +1 -0
  186. package/dist/components/modules/aim.d.ts +30 -0
  187. package/dist/components/modules/aim.d.ts.map +1 -0
  188. package/dist/components/modules/aim.js +39 -0
  189. package/dist/components/modules/aim.js.map +1 -0
  190. package/dist/components/modules/corners.d.ts +13 -0
  191. package/dist/components/modules/corners.d.ts.map +1 -0
  192. package/dist/components/modules/corners.js +12 -0
  193. package/dist/components/modules/corners.js.map +1 -0
  194. package/dist/components/modules/flow.d.ts +26 -0
  195. package/dist/components/modules/flow.d.ts.map +1 -0
  196. package/dist/components/modules/flow.js +57 -0
  197. package/dist/components/modules/flow.js.map +1 -0
  198. package/dist/components/modules/material.d.ts +40 -0
  199. package/dist/components/modules/material.d.ts.map +1 -0
  200. package/dist/components/modules/material.js +75 -0
  201. package/dist/components/modules/material.js.map +1 -0
  202. package/dist/components/modules/paint.d.ts +71 -0
  203. package/dist/components/modules/paint.d.ts.map +1 -0
  204. package/dist/components/modules/paint.js +106 -0
  205. package/dist/components/modules/paint.js.map +1 -0
  206. package/dist/components/modules/shapes.d.ts +31 -0
  207. package/dist/components/modules/shapes.d.ts.map +1 -0
  208. package/dist/components/modules/shapes.js +43 -0
  209. package/dist/components/modules/shapes.js.map +1 -0
  210. package/dist/components/modules/text-layout.d.ts +26 -0
  211. package/dist/components/modules/text-layout.d.ts.map +1 -0
  212. package/dist/components/modules/text-layout.js +57 -0
  213. package/dist/components/modules/text-layout.js.map +1 -0
  214. package/dist/components/modules/text-style.d.ts +48 -0
  215. package/dist/components/modules/text-style.d.ts.map +1 -0
  216. package/dist/components/modules/text-style.js +63 -0
  217. package/dist/components/modules/text-style.js.map +1 -0
  218. package/dist/components/modules/three-entries.d.ts +23 -0
  219. package/dist/components/modules/three-entries.d.ts.map +1 -0
  220. package/dist/components/modules/three-entries.js +41 -0
  221. package/dist/components/modules/three-entries.js.map +1 -0
  222. package/dist/components/modules/view3d.d.ts +59 -0
  223. package/dist/components/modules/view3d.d.ts.map +1 -0
  224. package/dist/components/modules/view3d.js +171 -0
  225. package/dist/components/modules/view3d.js.map +1 -0
  226. package/dist/components/trees/2d/group-bounds.d.ts +56 -0
  227. package/dist/components/trees/2d/group-bounds.d.ts.map +1 -0
  228. package/dist/components/trees/2d/group-bounds.js +87 -0
  229. package/dist/components/trees/2d/group-bounds.js.map +1 -0
  230. package/dist/components/trees/2d/node-lifecycle.d.ts +46 -0
  231. package/dist/components/trees/2d/node-lifecycle.d.ts.map +1 -0
  232. package/dist/components/trees/2d/node-lifecycle.js +264 -0
  233. package/dist/components/trees/2d/node-lifecycle.js.map +1 -0
  234. package/dist/components/trees/2d/node-motion.d.ts +56 -0
  235. package/dist/components/trees/2d/node-motion.d.ts.map +1 -0
  236. package/dist/components/trees/2d/node-motion.js +86 -0
  237. package/dist/components/trees/2d/node-motion.js.map +1 -0
  238. package/dist/components/trees/2d/node-render.d.ts +36 -0
  239. package/dist/components/trees/2d/node-render.d.ts.map +1 -0
  240. package/dist/components/trees/2d/node-render.js +67 -0
  241. package/dist/components/trees/2d/node-render.js.map +1 -0
  242. package/dist/components/trees/2d/node-space.d.ts +63 -0
  243. package/dist/components/trees/2d/node-space.d.ts.map +1 -0
  244. package/dist/components/trees/2d/node-space.js +131 -0
  245. package/dist/components/trees/2d/node-space.js.map +1 -0
  246. package/dist/components/trees/2d/node-transform.d.ts +55 -0
  247. package/dist/components/trees/2d/node-transform.d.ts.map +1 -0
  248. package/dist/components/trees/2d/node-transform.js +73 -0
  249. package/dist/components/trees/2d/node-transform.js.map +1 -0
  250. package/dist/components/trees/2d/node2d.d.ts +1020 -0
  251. package/dist/components/trees/2d/node2d.d.ts.map +1 -0
  252. package/dist/components/trees/2d/node2d.js +1481 -0
  253. package/dist/components/trees/2d/node2d.js.map +1 -0
  254. package/dist/components/trees/audio/index.d.ts +2 -0
  255. package/dist/components/trees/audio/index.d.ts.map +1 -0
  256. package/dist/components/trees/audio/index.js +2 -0
  257. package/dist/components/trees/audio/index.js.map +1 -0
  258. package/dist/components/trees/audio/node-audio.d.ts +109 -0
  259. package/dist/components/trees/audio/node-audio.d.ts.map +1 -0
  260. package/dist/components/trees/audio/node-audio.js +167 -0
  261. package/dist/components/trees/audio/node-audio.js.map +1 -0
  262. package/dist/components/trees/index.d.ts +10 -0
  263. package/dist/components/trees/index.d.ts.map +1 -0
  264. package/dist/components/trees/index.js +14 -0
  265. package/dist/components/trees/index.js.map +1 -0
  266. package/dist/components/trees/node/node-editor-state.d.ts +53 -0
  267. package/dist/components/trees/node/node-editor-state.d.ts.map +1 -0
  268. package/dist/components/trees/node/node-editor-state.js +23 -0
  269. package/dist/components/trees/node/node-editor-state.js.map +1 -0
  270. package/dist/components/trees/node/node-reactive.d.ts +89 -0
  271. package/dist/components/trees/node/node-reactive.d.ts.map +1 -0
  272. package/dist/components/trees/node/node-reactive.js +135 -0
  273. package/dist/components/trees/node/node-reactive.js.map +1 -0
  274. package/dist/components/trees/node/node-time.d.ts +39 -0
  275. package/dist/components/trees/node/node-time.d.ts.map +1 -0
  276. package/dist/components/trees/node/node-time.js +14 -0
  277. package/dist/components/trees/node/node-time.js.map +1 -0
  278. package/dist/components/trees/node/node-walk.d.ts +46 -0
  279. package/dist/components/trees/node/node-walk.d.ts.map +1 -0
  280. package/dist/components/trees/node/node-walk.js +74 -0
  281. package/dist/components/trees/node/node-walk.js.map +1 -0
  282. package/dist/components/trees/node/node.d.ts +401 -0
  283. package/dist/components/trees/node/node.d.ts.map +1 -0
  284. package/dist/components/trees/node/node.js +680 -0
  285. package/dist/components/trees/node/node.js.map +1 -0
  286. package/dist/components/trees/root/canvas2d-node.d.ts +163 -0
  287. package/dist/components/trees/root/canvas2d-node.d.ts.map +1 -0
  288. package/dist/components/trees/root/canvas2d-node.js +216 -0
  289. package/dist/components/trees/root/canvas2d-node.js.map +1 -0
  290. package/dist/components/trees/three/node3d.d.ts +222 -0
  291. package/dist/components/trees/three/node3d.d.ts.map +1 -0
  292. package/dist/components/trees/three/node3d.js +289 -0
  293. package/dist/components/trees/three/node3d.js.map +1 -0
  294. package/dist/document/builtins.js +13 -13
  295. package/dist/document/builtins.js.map +1 -1
  296. package/dist/document/command-traits.d.ts +2 -2
  297. package/dist/document/command-traits.js +1 -1
  298. package/dist/document/command-traits.js.map +1 -1
  299. package/dist/document/deny-globals.d.ts +2 -2
  300. package/dist/document/deny-globals.js +2 -2
  301. package/dist/document/deny-globals.js.map +1 -1
  302. package/dist/document/expression/index.d.ts +1 -1
  303. package/dist/document/expression/index.js +1 -1
  304. package/dist/document/expression/index.js.map +1 -1
  305. package/dist/document/expression/ops.js +1 -1
  306. package/dist/document/expression/ops.js.map +1 -1
  307. package/dist/document/index.d.ts +1 -2
  308. package/dist/document/index.d.ts.map +1 -1
  309. package/dist/document/index.js +1 -2
  310. package/dist/document/index.js.map +1 -1
  311. package/dist/document/node-decorator.d.ts +14 -10
  312. package/dist/document/node-decorator.d.ts.map +1 -1
  313. package/dist/document/node-decorator.js +14 -10
  314. package/dist/document/node-decorator.js.map +1 -1
  315. package/dist/document/node-descriptor.d.ts +3 -3
  316. package/dist/document/node-descriptor.d.ts.map +1 -1
  317. package/dist/document/node-descriptor.js.map +1 -1
  318. package/dist/document/registry.d.ts +23 -25
  319. package/dist/document/registry.d.ts.map +1 -1
  320. package/dist/document/registry.js +12 -18
  321. package/dist/document/registry.js.map +1 -1
  322. package/dist/document/timeline.d.ts +3 -3
  323. package/dist/document/timeline.d.ts.map +1 -1
  324. package/dist/document/timeline.js +2 -2
  325. package/dist/document/timeline.js.map +1 -1
  326. package/dist/document/types.d.ts +4 -4
  327. package/dist/document/types.js.map +1 -1
  328. package/dist/document/validate.d.ts +1 -1
  329. package/dist/document/validate.js.map +1 -1
  330. package/dist/experimental.d.ts +19 -19
  331. package/dist/experimental.d.ts.map +1 -1
  332. package/dist/experimental.js +17 -17
  333. package/dist/experimental.js.map +1 -1
  334. package/dist/index.d.ts +10 -11
  335. package/dist/index.d.ts.map +1 -1
  336. package/dist/index.js +10 -11
  337. package/dist/index.js.map +1 -1
  338. package/dist/layout/types.d.ts +1 -1
  339. package/dist/layout/types.js.map +1 -1
  340. package/dist/props/host.d.ts +1 -1
  341. package/dist/props/host.js.map +1 -1
  342. package/dist/props/slot.d.ts +1 -1
  343. package/dist/props/slot.js +1 -1
  344. package/dist/props/slot.js.map +1 -1
  345. package/dist/render/clip.d.ts +1 -1
  346. package/dist/render/clip.js +1 -1
  347. package/dist/render/clip.js.map +1 -1
  348. package/dist/render/descriptors/rect.js.map +1 -1
  349. package/dist/render/descriptors/text.d.ts +11 -5
  350. package/dist/render/descriptors/text.d.ts.map +1 -1
  351. package/dist/render/descriptors/text.js +7 -1
  352. package/dist/render/descriptors/text.js.map +1 -1
  353. package/dist/render/render-context2d.d.ts +2 -2
  354. package/dist/render/render-context2d.js.map +1 -1
  355. package/dist/render3d/builders.d.ts +1 -1
  356. package/dist/render3d/builders.js +1 -1
  357. package/dist/render3d/builders.js.map +1 -1
  358. package/dist/render3d/graphics3d.d.ts +13 -19
  359. package/dist/render3d/graphics3d.d.ts.map +1 -1
  360. package/dist/render3d/graphics3d.js +13 -19
  361. package/dist/render3d/graphics3d.js.map +1 -1
  362. package/dist/render3d/scene3d.d.ts +1 -1
  363. package/dist/render3d/scene3d.js +1 -1
  364. package/dist/render3d/scene3d.js.map +1 -1
  365. package/dist/render3d/texture.d.ts +2 -2
  366. package/dist/render3d/texture.d.ts.map +1 -1
  367. package/dist/render3d/texture.js.map +1 -1
  368. package/dist/render3d/vector3.d.ts +2 -2
  369. package/dist/render3d/vector3.js +2 -2
  370. package/dist/render3d/vector3.js.map +1 -1
  371. package/dist/runtime/asset-refine.d.ts +1 -1
  372. package/dist/runtime/asset-refine.d.ts.map +1 -1
  373. package/dist/runtime/asset-refine.js +1 -1
  374. package/dist/runtime/asset-refine.js.map +1 -1
  375. package/dist/runtime/asset-update.js +1 -1
  376. package/dist/runtime/asset-update.js.map +1 -1
  377. package/dist/runtime/audio-index.d.ts +0 -11
  378. package/dist/runtime/audio-index.d.ts.map +1 -1
  379. package/dist/runtime/audio-index.js +0 -25
  380. package/dist/runtime/audio-index.js.map +1 -1
  381. package/dist/runtime/clip-instance.d.ts +3 -3
  382. package/dist/runtime/clip-instance.d.ts.map +1 -1
  383. package/dist/runtime/clip-instance.js +4 -4
  384. package/dist/runtime/clip-instance.js.map +1 -1
  385. package/dist/runtime/clip-store.d.ts +2 -3
  386. package/dist/runtime/clip-store.d.ts.map +1 -1
  387. package/dist/runtime/clip-store.js +17 -35
  388. package/dist/runtime/clip-store.js.map +1 -1
  389. package/dist/runtime/engine.d.ts +3 -3
  390. package/dist/runtime/engine.js +2 -2
  391. package/dist/runtime/engine.js.map +1 -1
  392. package/dist/runtime/node-picking.d.ts +2 -2
  393. package/dist/runtime/node-picking.d.ts.map +1 -1
  394. package/dist/runtime/node-picking.js +3 -3
  395. package/dist/runtime/node-picking.js.map +1 -1
  396. package/dist/runtime/node-picking3d.d.ts +2 -2
  397. package/dist/runtime/node-picking3d.d.ts.map +1 -1
  398. package/dist/runtime/node-picking3d.js +1 -1
  399. package/dist/runtime/node-picking3d.js.map +1 -1
  400. package/dist/runtime/playback-controller.d.ts +2 -2
  401. package/dist/runtime/playback-controller.d.ts.map +1 -1
  402. package/dist/runtime/playback-controller.js +1 -1
  403. package/dist/runtime/playback-controller.js.map +1 -1
  404. package/dist/runtime/state-evaluator.d.ts +2 -2
  405. package/dist/runtime/state-evaluator.d.ts.map +1 -1
  406. package/dist/runtime/state-evaluator.js.map +1 -1
  407. package/dist/runtime/text-geometry.d.ts +1 -1
  408. package/dist/runtime/text-geometry.d.ts.map +1 -1
  409. package/dist/runtime/text-geometry.js +4 -5
  410. package/dist/runtime/text-geometry.js.map +1 -1
  411. package/dist/sdk/index.d.ts +43 -39
  412. package/dist/sdk/index.d.ts.map +1 -1
  413. package/dist/sdk/index.js +24 -25
  414. package/dist/sdk/index.js.map +1 -1
  415. package/dist/tween/command-decorator.d.ts +7 -9
  416. package/dist/tween/command-decorator.d.ts.map +1 -1
  417. package/dist/tween/command-decorator.js +2 -2
  418. package/dist/tween/command-decorator.js.map +1 -1
  419. package/dist/tween/command.d.ts +1 -1
  420. package/dist/tween/command.js.map +1 -1
  421. package/dist/tween/index.d.ts +2 -1
  422. package/dist/tween/index.d.ts.map +1 -1
  423. package/dist/tween/index.js +1 -1
  424. package/dist/tween/index.js.map +1 -1
  425. package/dist/tween/loop.d.ts +1 -1
  426. package/dist/tween/loop.js +1 -1
  427. package/dist/tween/loop.js.map +1 -1
  428. package/dist/util/reference.d.ts +6 -6
  429. package/dist/util/reference.js.map +1 -1
  430. package/package.json +2 -10
  431. package/dist/browser/chunks/chunk-2RIYH36X.js +0 -3
  432. package/dist/browser/chunks/chunk-2RIYH36X.js.map +0 -7
  433. package/dist/browser/chunks/chunk-DDJN3QII.js +0 -15
  434. package/dist/browser/chunks/chunk-DDJN3QII.js.map +0 -7
  435. package/dist/browser/chunks/chunk-DHB4COFY.js +0 -2
  436. package/dist/browser/chunks/chunk-EJDPYDQI.js +0 -5
  437. package/dist/browser/chunks/chunk-EJDPYDQI.js.map +0 -7
  438. package/dist/browser/chunks/chunk-SFNJRPBV.js +0 -2
  439. package/dist/browser/chunks/chunk-SFNJRPBV.js.map +0 -7
  440. package/dist/browser/chunks/chunk-XAWE4EAK.js +0 -2
  441. package/dist/browser/chunks/chunk-XAWE4EAK.js.map +0 -7
  442. package/dist/browser/jsx-jsx-dev-runtime.js +0 -2
  443. package/dist/browser/jsx-jsx-dev-runtime.js.map +0 -7
  444. package/dist/browser/jsx-jsx-runtime.js +0 -2
  445. package/dist/browser/jsx-jsx-runtime.js.map +0 -7
@@ -0,0 +1,680 @@
1
+ import { _observer, PropSlot } from "../../../props/slot.js";
2
+ import { STRUCTURE_SLOT } from "../../../props/observer.js";
3
+ import { toCommand } from "../../../tween/to-command.js";
4
+ import { makeCommand } from "../../../tween/command.js";
5
+ import { prepareNumericCellTween } from "../../../tween/prepare.js";
6
+ import { inertCommand, inertStepper } from "../../../tween/inert.js";
7
+ import { ContextMap } from "../../../util/context.js";
8
+ import { declareMembers, getPropertyMeta } from "../../../attributes/properties/decorator.js";
9
+ import { applyProp, applySnapshotLayer, collectProperties, popState, restoreAnimated, saveState, } from "./node-reactive.js";
10
+ import { advanceNodeTime, createNodeTime } from "../../../components/trees/node/node-time.js";
11
+ import { command } from "../../../tween/command-decorator.js";
12
+ /** Where a node of each dimension is allowed to live, for the mismatch error. */
13
+ const HOSTS_OF = {
14
+ "2d": "2D nodes go in the 2D tree, or inside a Canvas3D as a HUD over its scene.",
15
+ "3d": "Put 3D nodes inside a Canvas3D, which is the one node that holds both.",
16
+ audio: "Put audio nodes under an AudioBus, or directly on the scene root.",
17
+ };
18
+ /**
19
+ * The dimension-agnostic base of the scene graph: tree, identity, reactive
20
+ * properties, commands, context, clock, asset declaration, teardown. Nothing
21
+ * about *where* a node is or *how* it draws — that's {@link Node2D} / `Node3D`.
22
+ * They meet only at `Canvas3D`; mixing them anywhere else throws (see
23
+ * {@link acceptsChild}).
24
+ *
25
+ * Subclasses call {@link initProps} from their own constructor rather than the
26
+ * base doing it: a subclass's field initializers only run *after* `super()`
27
+ * returns, so applying `property` defaults any earlier would write into cells
28
+ * that don't exist yet.
29
+ */
30
+ export class Node {
31
+ /** The trees this type takes children from, answerable from the prototype as {@link dimension} is. */
32
+ get _childTrees() {
33
+ return [this.dimension];
34
+ }
35
+ constructor(props) {
36
+ // Retain the raw props (see _props doc) so a provider's provideContext can
37
+ // read which keys the author passed. Captured before any default
38
+ // application so it reflects exactly what the author passed. The object is
39
+ // retained by reference, so a subclass expanding prop sugar in place
40
+ // afterwards (`size`, `transform3D`) is reflected here too.
41
+ this._props = props;
42
+ // Neither is a property: identity does not tween, so neither has any
43
+ // business in the table `set()`, `to()` and the baseline restore walk
44
+ // iterate.
45
+ const identity = props;
46
+ this.key = identity?.key;
47
+ // Nullish, never falsy: `""` is the scene root's real id, not a missing
48
+ // one (`checkRootShape` in document/validate.ts defines the root as the
49
+ // row holding it), and a UUID in its place would have the host's tree
50
+ // report a root no document row mentions.
51
+ this.id = identity?.id ?? crypto.randomUUID();
52
+ }
53
+ /** See {@link NodeProps.key}. */
54
+ key;
55
+ _hidden = false;
56
+ _locked = false;
57
+ /**
58
+ * Hidden by the editor — no paint, no pick, no layout slot. See
59
+ * {@link NodeEditorState.hidden}.
60
+ */
61
+ get hidden() {
62
+ return this._hidden;
63
+ }
64
+ /** Locked by the editor — unpickable, but drawn. See {@link NodeEditorState.locked}. */
65
+ get locked() {
66
+ return this._locked;
67
+ }
68
+ /**
69
+ * @internal — written only by `applyEditorStates`, which owns both flags for
70
+ * the whole tree. Not a setter pair, so a caller cannot set one and leave the
71
+ * other holding a previous frame's answer.
72
+ */
73
+ _setEditorState(hidden, locked) {
74
+ this._hidden = hidden;
75
+ this._locked = locked;
76
+ }
77
+ /**
78
+ * Fire the `ref` and apply every declared property, reading
79
+ * initial values from `props`.
80
+ *
81
+ * Called by the concrete constructor ({@link Node2D}'s, `Node3D`'s) rather
82
+ * than by this one, because a subclass's field initializers run *after*
83
+ * `super()` returns: doing this here would apply props while the cells those
84
+ * props write into are still `undefined`.
85
+ */
86
+ initProps(props) {
87
+ if (props?.ref) {
88
+ props.ref(this);
89
+ }
90
+ // Apply every declared property, reading initial values from props.
91
+ for (const meta of getPropertyMeta(this)) {
92
+ const propsVal = props ? props[meta.key] : undefined;
93
+ const initial = propsVal !== undefined ? propsVal : meta.default;
94
+ this.applyProp(meta.key, initial, meta.options);
95
+ }
96
+ }
97
+ /**
98
+ * Adopt the `children` prop. Called by the concrete constructor after its own
99
+ * defaults are in place, so a child never lands in a tree whose parent has not
100
+ * finished sizing itself.
101
+ */
102
+ adoptChildrenProp(props) {
103
+ if (props && props.children) {
104
+ const raw = Array.isArray(props.children) ? props.children : [props.children];
105
+ const flat = raw.flat(Infinity)
106
+ .filter((c) => c instanceof Node);
107
+ if (flat.length > 0)
108
+ this._addChildren(flat);
109
+ }
110
+ }
111
+ /**
112
+ * Whether `child` may be adopted by this node.
113
+ *
114
+ * A node holds children of its own dimension; the places the trees meet are
115
+ * `Canvas3D`, which takes 2D and 3D, and `Canvas2D`, which takes 2D and
116
+ * audio. Both partition what they accept. Rejecting the mix here rather than
117
+ * letting it through is deliberate: a `Box3D` parented to a `Rect` would be
118
+ * silently skipped by both the layout walk and the 3D walk, and would simply
119
+ * never appear.
120
+ */
121
+ acceptsChild(child) {
122
+ return child.dimension === this.dimension;
123
+ }
124
+ /** Throw if `child` cannot go here: by its tree, by what this node takes, or by where the child says it goes. */
125
+ assertAcceptsChild(child) {
126
+ if (!this.acceptsChild(child)) {
127
+ const why = child.dimension === this.dimension ? this._childRule() : HOSTS_OF[child.dimension];
128
+ throw new TypeError(`${this.className} (${this.dimension}) cannot hold ${child.className} (${child.dimension}).${why ? ` ${why}` : ""}`);
129
+ }
130
+ const refusal = child._parentRefusal(this);
131
+ if (refusal)
132
+ throw new TypeError(refusal);
133
+ }
134
+ /** What this node takes, for the error when it refuses a child of its own tree. */
135
+ _childRule() {
136
+ return "";
137
+ }
138
+ /** Why this node cannot go inside `parent`, or `null`: only a node that names its parents refuses one. */
139
+ _parentRefusal(_parent) {
140
+ return null;
141
+ }
142
+ _assets = null;
143
+ _parent = null;
144
+ /**
145
+ * Whether this node is in a live scene tree. Gates measure/layout/render,
146
+ * asset declaration and every command — checked at the handful of places
147
+ * the framework dispatches from, not per method.
148
+ */
149
+ _mounted = false;
150
+ /** See {@link _mounted}. */
151
+ get mounted() {
152
+ return this._mounted;
153
+ }
154
+ get parent() {
155
+ if (_observer !== null)
156
+ _observer.read(this._structureSlot());
157
+ return this._parent;
158
+ }
159
+ get assets() {
160
+ if (!this._assets)
161
+ throw new Error("Assets not bound — this node is not attached to a scene. See Node.attach().");
162
+ return this._assets;
163
+ }
164
+ /** Token→value map pushed down from ancestor providers, bound by {@link attach}. */
165
+ _context = ContextMap.EMPTY;
166
+ /** True once {@link attach} has reached this node. */
167
+ _contextBound = false;
168
+ /** Raw constructor props, retained so {@link provideContext} can see which keys were explicitly passed. Kept through {@link dispose} so a reused instance re-derives context on the next attach. */
169
+ _props;
170
+ /** Read the nearest ancestor provider's value for `ctx` (or its default). */
171
+ useContext(ctx) {
172
+ return this._context.get(ctx);
173
+ }
174
+ /** Assigned in the constructor — see {@link NodeProps.id}. */
175
+ id;
176
+ /**
177
+ * The slots behind this node's `property` fields. See {@link PropCells}.
178
+ *
179
+ * @internal — the authoring surface is the declared props themselves, plus
180
+ * `set()`/`to()`/`captureProps()`.
181
+ */
182
+ __cells;
183
+ _children = [];
184
+ /**
185
+ * Flatten a constructor's raw `children` prop into the `Node` instances it
186
+ * contains, without mutating or adding them — the same normalisation the
187
+ * constructor applies before adding them, exposed standalone so
188
+ * {@link applyDefaultSize} overrides can inspect children's own resolved
189
+ * `width`/`height` *before* they're attached (children are constructed,
190
+ * defaults and all, before being passed in as props).
191
+ */
192
+ static flattenChildrenProp(props) {
193
+ const childProp = props ? props.children : undefined;
194
+ if (!childProp)
195
+ return [];
196
+ const raw = Array.isArray(childProp) ? childProp : [childProp];
197
+ return raw.flat(Infinity).filter((c) => c instanceof Node);
198
+ }
199
+ // ---- Reactive properties ----------------------------------------------
200
+ /**
201
+ * Declare a prop on this node. Creates a {@link PropSlot}-backed accessor
202
+ * for `field`, applies an initial value (callback → binding; otherwise
203
+ * constant), and registers optional tween/mapper metadata used by `set()`
204
+ * and `to()`.
205
+ *
206
+ * Subsequent calls for the same field reuse the existing slot and act as
207
+ * a value assignment, so subclasses can override a parent's default by
208
+ * calling applyProp again without losing the slot or its bindings.
209
+ */
210
+ applyProp(field, initial, options) {
211
+ applyProp(this, field, initial, options);
212
+ }
213
+ /** @internal Hot-path prop write (mapper- and binding-aware). Public-but-underscored like `_prepareStep` so reactive companions in this directory can call it; not part of the authoring surface. */
214
+ _writeProp(field, value) {
215
+ if (value === undefined)
216
+ return;
217
+ const slot = this.__cells?.slots.get(field);
218
+ if (!slot)
219
+ return;
220
+ const mapper = this.__cells?.mappers?.get(field);
221
+ if (typeof value === "function") {
222
+ const extFn = value;
223
+ if (mapper) {
224
+ // A binding that reads `undefined` — a node reference to a node that is
225
+ // not there — leaves the prop as a node built without it, and never
226
+ // reaches the mapper, which holds the shape the prop's readers go through.
227
+ let unset;
228
+ slot.bind(() => {
229
+ const read = extFn();
230
+ return read === undefined
231
+ ? (unset ??= { value: this._unsetValue(field, mapper) }).value
232
+ : mapper(read, slot.get());
233
+ });
234
+ }
235
+ else {
236
+ slot.bind(extFn);
237
+ }
238
+ }
239
+ else {
240
+ slot.set(mapper ? mapper(value, slot.get()) : value);
241
+ }
242
+ }
243
+ get properties() {
244
+ return collectProperties(this);
245
+ }
246
+ /**
247
+ * This node's **class** name, for a message or a host's type column. Not an
248
+ * authored identity — those are {@link id} and {@link key}, and nothing in
249
+ * the document model is called a name any more. Nor is it the registry key a
250
+ * document writes in `NodeSpec.type`: a minifier is free to rename a class.
251
+ */
252
+ get className() {
253
+ return this.constructor.name;
254
+ }
255
+ set(props) {
256
+ const slots = this.__cells?.slots;
257
+ if (!slots)
258
+ return;
259
+ // Iterate the caller's keys (usually 1–3) rather than every registered
260
+ // prop (15+): set() runs in the per-frame hot path. Only keys backed by
261
+ // a slot are written; unknown keys are ignored — which is also what
262
+ // lets a subclass distribute its own sugar (2D's `size`, `transform3D`)
263
+ // into real keys and then delegate here.
264
+ for (const key in props) {
265
+ const val = props[key];
266
+ if (val !== undefined && slots.has(key))
267
+ this._writeProp(key, val);
268
+ }
269
+ }
270
+ to(args) {
271
+ return toCommand(this, args.data ?? {}, args.duration, args.easing);
272
+ }
273
+ /**
274
+ * Build a {@link Command} from a pure function of normalized time — an
275
+ * animation this node can be *evaluated* at, not only run through. The pair
276
+ * to {@link to}, for the built-in commands whose values at `t` are not a prop
277
+ * list, and what a component command's timeline lowers to.
278
+ *
279
+ * Snapshot whatever the animation starts from *outside* `at`: reading a prop
280
+ * inside it would re-read the value the command is itself writing.
281
+ */
282
+ command(at, duration = 1, easing) {
283
+ if (!this._mounted)
284
+ return inertCommand(this, duration);
285
+ return makeCommand(this, at, duration, easing);
286
+ }
287
+ /**
288
+ * Resolve a single `to()` step into a flat {@link TweenStepper} — all the
289
+ * per-key setup (mapper, numeric-vs-custom routing) happens once here, then
290
+ * `advance(dt)` is allocation-free. Used by both a chain's iterator path and
291
+ * the batched `parallel` path.
292
+ *
293
+ * A subclass with positional sugar of its own (2D's `size` and anchors)
294
+ * expands `to` in place and then delegates here.
295
+ */
296
+ _prepareStep(to, duration, easing) {
297
+ if (!this._mounted)
298
+ return inertStepper(duration);
299
+ // A tween runs in stored space, so the destination is mapped once, here,
300
+ // and every step after it is a stored value written to the slot as it is.
301
+ // Writing a step through the setter would map it a second time, which only
302
+ // an idempotent mapper survives.
303
+ const numCells = [];
304
+ const numFrom = [];
305
+ const numEnd = [];
306
+ const customLerps = [];
307
+ const stringSnaps = [];
308
+ for (const key of Object.keys(to)) {
309
+ const slot = this.__cells?.slots.get(key);
310
+ if (!slot)
311
+ continue;
312
+ const extVal = to[key];
313
+ const mapper = this.__cells?.mappers?.get(key);
314
+ const targetVal = mapper ? mapper(extVal, this[key]) : extVal;
315
+ const tweenFn = this.__cells?.tweens?.get(key);
316
+ if (tweenFn) {
317
+ const from = this[key];
318
+ customLerps.push((t) => {
319
+ slot.set(tweenFn(from, targetVal, t));
320
+ });
321
+ }
322
+ else if (typeof targetVal === 'number') {
323
+ numCells.push(slot);
324
+ numFrom.push(this[key]);
325
+ numEnd.push(targetVal);
326
+ }
327
+ else if (typeof targetVal === 'string') {
328
+ stringSnaps.push([slot, targetVal]);
329
+ }
330
+ }
331
+ const lerp = prepareNumericCellTween(numCells, numFrom, numEnd);
332
+ const hasCustom = customLerps.length > 0;
333
+ const hasSnaps = stringSnaps.length > 0;
334
+ const apply = (t) => {
335
+ const easedT = easing ? easing(t) : t;
336
+ lerp(easedT);
337
+ if (hasCustom)
338
+ for (const fn of customLerps)
339
+ fn(easedT);
340
+ // A discrete prop has nothing between its endpoints, so it snaps at
341
+ // the end rather than interpolating. Applied here rather than only in
342
+ // `advance` because a `seek` past the end has, by definition, reached
343
+ // that end — leaving it out meant `seek(duration)` and running to
344
+ // `duration` produced different nodes, and only the second was right.
345
+ if (hasSnaps && t >= 1)
346
+ for (const [slot, val] of stringSnaps)
347
+ slot.set(val);
348
+ };
349
+ let elapsed = 0;
350
+ return {
351
+ // Tracks `elapsed`, so a seek and a subsequent advance agree about
352
+ // where the tween is. Without it, seeking forward then advancing
353
+ // rewound to `dt`.
354
+ seek: (e) => {
355
+ elapsed = e;
356
+ apply(duration > 0 ? Math.min(e / duration, 1) : 1);
357
+ },
358
+ advance: (dt) => {
359
+ elapsed += dt;
360
+ if (elapsed < duration) {
361
+ apply(elapsed / duration);
362
+ return false;
363
+ }
364
+ apply(1);
365
+ return true;
366
+ },
367
+ };
368
+ }
369
+ /** What a node constructed without `field` holds: its declared default, through the mapper. */
370
+ _unsetValue(field, mapper) {
371
+ const declared = getPropertyMeta(this).find((meta) => meta.key === field)?.default;
372
+ const initial = typeof declared === "function" ? declared() : declared;
373
+ return initial === undefined ? undefined : mapper(initial, undefined);
374
+ }
375
+ // ---- State stack (save / restore) -------------------------------------
376
+ // A per-node LIFO stack of property snapshots, mirroring Motion Canvas's
377
+ // node.save()/restore(). `save()` pushes a snapshot of every declared prop;
378
+ // `restore()` pops the most recent one and either snaps to it (no duration)
379
+ // or tweens the numeric props back to it over `duration`.
380
+ /** @internal LIFO stack of save() snapshot layers. Underscore-internal so the prop companion can read it; not authoring surface. */
381
+ _stateStack = [];
382
+ /**
383
+ * Push a snapshot of this node's current state onto its save stack.
384
+ *
385
+ * Every reactive prop (`x`, `y`, `scale`, `opacity`, `fill`, …) is captured,
386
+ * preserving reactive bindings — a prop bound to `() => other().x` is saved
387
+ * as the binding, not just its resolved value, so {@link restore} re-binds
388
+ * it rather than freezing the value. Calls stack: each `save()` pushes a new
389
+ * layer, and each {@link restore} pops the most recent one.
390
+ *
391
+ * @example
392
+ * node.save();
393
+ * node.moveTo({ data: { x: 200, y: 0 }, duration: 1 });
394
+ * node.restore({ duration: 1 }); // animate back to where it was saved
395
+ */
396
+ save() {
397
+ saveState(this);
398
+ }
399
+ restore(args) {
400
+ const layer = popState(this);
401
+ const duration = args?.duration;
402
+ if (duration === undefined || duration <= 0) {
403
+ if (layer)
404
+ applySnapshotLayer(this, layer);
405
+ return;
406
+ }
407
+ return restoreAnimated(this, layer, duration, args?.easing);
408
+ }
409
+ // ---- Clock ------------------------------------------------------------
410
+ _time = createNodeTime();
411
+ /** This node's place on the scene clock. See {@link NodeTime}. */
412
+ get time() {
413
+ if (_observer !== null)
414
+ _observer.clock?.(this);
415
+ return this._time;
416
+ }
417
+ /**
418
+ * Advance **this node's** clock to `total` clip-seconds and sample its
419
+ * derived render state.
420
+ *
421
+ * Per-node, not per-subtree: {@link attach} already recurses, so a recursive
422
+ * advance here would re-advance every descendant once per ancestor.
423
+ *
424
+ * Sampling happens here, not at render: this runs on every advanced frame in
425
+ * every playback path (forward, scrub, precomp), whereas `render` runs only
426
+ * for displayed frames. Sampling per-frame is what makes velocity correct on
427
+ * the first frame after a scrub/rewind, where sampling only at render time
428
+ * read zero. The advance loop runs before `generator.next()` (so audio
429
+ * scheduling in generator bodies reads the right time), which means x/y here
430
+ * still hold the previous frame's value — velocity therefore trails the
431
+ * rendered position by one frame. That lag is constant and identical forward
432
+ * vs. scrub, and imperceptible for motion blur.
433
+ */
434
+ _advanceOwnTime(total) {
435
+ advanceNodeTime(this._time, total);
436
+ this._sample();
437
+ }
438
+ /**
439
+ * Sample this node's own derived render state for the current frame. Nothing
440
+ * to derive in the general case; {@link Node2D} samples its motion here.
441
+ *
442
+ * @internal The per-node half of `sampleTree` — a walk, not a node method.
443
+ */
444
+ _sample() { }
445
+ /**
446
+ * Record this node's current position as the motion history's previous
447
+ * frame, stamped `at`, deriving no velocity.
448
+ *
449
+ * @internal The per-node half of `primeMotionTree`.
450
+ */
451
+ _primeMotion(at) { }
452
+ // ---- Attachment -------------------------------------------------------
453
+ /**
454
+ * Put this subtree into the scene: mark it mounted, bind the asset catalog
455
+ * and inherited context, advance its clock to `scope.time`.
456
+ *
457
+ * Safe and cheap to call every frame — an unchanged catalog/context
458
+ * short-circuits, and {@link resolveContext} fires only on first attach.
459
+ *
460
+ * @internal Driven by `ClipInstance` per frame, and by {@link add} for a mid-frame subtree.
461
+ */
462
+ attach(scope) {
463
+ const first = !this._mounted;
464
+ this._mounted = true;
465
+ if (this._assets !== scope.assets)
466
+ this._assets = scope.assets;
467
+ const next = this.provideContext(scope.context);
468
+ // Unchanged map, already bound, and not this instance's first attach ⇒
469
+ // the whole subtree already holds `next` and the walk below would be pure
470
+ // repetition of the context half. The time half still has to run.
471
+ const contextChanged = !this._contextBound || this._context !== next;
472
+ if (contextChanged) {
473
+ this._context = next;
474
+ this._contextBound = true;
475
+ }
476
+ if (first)
477
+ this.resolveContext(next);
478
+ this._advanceOwnTime(scope.time);
479
+ if (this._children.length === 0)
480
+ return;
481
+ const childScope = next === scope.context ? scope : { ...scope, context: next };
482
+ for (const child of this._children)
483
+ child.attach(childScope);
484
+ }
485
+ /**
486
+ * Take this subtree out of the scene. Not a teardown — props/children/bindings
487
+ * stay, so it can be attached elsewhere (`reparent`). {@link dispose} tears down.
488
+ *
489
+ * @internal Driven by {@link remove}/{@link clear}.
490
+ */
491
+ detach() {
492
+ if (!this._mounted)
493
+ return;
494
+ this._mounted = false;
495
+ for (const child of this._children)
496
+ child.detach();
497
+ }
498
+ /** The scope this node was last attached with, for handing to a late child. */
499
+ _currentScope() {
500
+ return this._assets && this._contextBound
501
+ ? { assets: this._assets, context: this._context, time: this._time.total }
502
+ : null;
503
+ }
504
+ /** Attach `child` if this node is itself attached; otherwise leave it for the walk. */
505
+ /** @internal Shared with `Node2D.addChildAt`, which splices rather than pushes. */
506
+ _attachChild(child) {
507
+ if (!this._mounted)
508
+ return;
509
+ const scope = this._currentScope();
510
+ if (scope)
511
+ child.attach(scope);
512
+ }
513
+ // ---- Context lifecycle ------------------------------------------------
514
+ /**
515
+ * Apply inherited context **values** to this node, once, after it's linked
516
+ * into the tree and ancestor providers have resolved: a component's
517
+ * `inherit` entries. Runs exactly once per instance.
518
+ */
519
+ resolveContext(ctx) { }
520
+ /**
521
+ * The {@link ContextMap} handed to descendants: a component's `provide`
522
+ * adds its tokens. The base passes the parent's map through unchanged.
523
+ */
524
+ provideContext(parent) {
525
+ return parent;
526
+ }
527
+ /**
528
+ * Bind `node`'s asset catalog, context and clock without making it a child —
529
+ * for a node used purely as a pixel source (`Tex.surface`), laid out on
530
+ * demand rather than sitting in the tree.
531
+ */
532
+ attachDetached(node) {
533
+ const scope = this._currentScope();
534
+ if (scope)
535
+ node.attach(scope);
536
+ }
537
+ /**
538
+ * Declare what this node draws from its props and inherited context alone —
539
+ * never `layoutBounds` or the clock. The runtime records what this reads and
540
+ * calls it again only when one of those props is written, so anything else it
541
+ * depends on is a change nobody will ask about.
542
+ */
543
+ declareAssets(assets) { }
544
+ get children() {
545
+ if (_observer !== null)
546
+ _observer.read(this._structureSlot());
547
+ return this._children;
548
+ }
549
+ /**
550
+ * Every child, both dimensions, unfiltered — unlike {@link children}, which
551
+ * a {@link Node2D} filters to its own kind. Used where index has to match
552
+ * the authored tree (picking), since filtering would renumber it.
553
+ */
554
+ get _allChildren() {
555
+ if (_observer !== null)
556
+ _observer.read(this._structureSlot());
557
+ return this._children;
558
+ }
559
+ /**
560
+ * Add children — a node, an array, or a nested mix; falsy entries
561
+ * (`cond && node`) are dropped. A child of the other dimension throws —
562
+ * see {@link acceptsChild}.
563
+ */
564
+ add(child) {
565
+ if (child instanceof Node) {
566
+ this._addChild(child);
567
+ return;
568
+ }
569
+ const flat = Node.flattenChildrenProp({ children: child });
570
+ if (flat.length > 0)
571
+ this._addChildren(flat);
572
+ }
573
+ /** Remove children — same shapes as {@link add}. Not a child of this one is a no-op. */
574
+ remove(child) {
575
+ if (child instanceof Node) {
576
+ this._removeChild(child);
577
+ return;
578
+ }
579
+ for (const node of Node.flattenChildrenProp({ children: child })) {
580
+ this._removeChild(node);
581
+ }
582
+ }
583
+ /** Remove every child, detaching each (see {@link remove}). */
584
+ clear() {
585
+ for (const child of this._children) {
586
+ if (_observer !== null)
587
+ this._structureChanged(child);
588
+ child._parent = null;
589
+ child.detach();
590
+ }
591
+ this._children.length = 0;
592
+ }
593
+ /**
594
+ * Insert `child` at `index` among this node's children.
595
+ *
596
+ * On {@link Node} rather than {@link Node2D} because it is tree machinery —
597
+ * `ClipTimeline.syncPresence` reaches for it on whatever a spec's
598
+ * `parentId` names, which since audio joined the graph is not always a 2D
599
+ * node. `Node2D` overrides it for the animated insert, which measures the
600
+ * child off-tree and so needs a laid-out one.
601
+ */
602
+ addChildAt(args) {
603
+ const { child, index } = args.data;
604
+ this.assertAcceptsChild(child);
605
+ this._insertChildAt(child, index);
606
+ }
607
+ /** @internal Shared with `Node2D.addChildAt`'s instant branch. */
608
+ _insertChildAt(child, index) {
609
+ if (_observer !== null)
610
+ this._structureChanged(child);
611
+ this._children.splice(index, 0, child);
612
+ child._parent = this;
613
+ this._attachChild(child);
614
+ }
615
+ /**
616
+ * @internal The pseudo-slot {@link children} and {@link parent} report to an
617
+ * observer. Allocated on first observation, so a tree nobody observes carries none.
618
+ */
619
+ _structureSlot() {
620
+ return this._structure ??= new PropSlot(null, this, STRUCTURE_SLOT);
621
+ }
622
+ /** @internal Report a child entering or leaving this node — its parent link changes with it. Call only while observed. */
623
+ _structureChanged(child) {
624
+ _observer.write(this._structureSlot());
625
+ if (child)
626
+ _observer.write(child._structureSlot());
627
+ }
628
+ _structure = null;
629
+ _addChild(child) {
630
+ this.assertAcceptsChild(child);
631
+ if (_observer !== null)
632
+ this._structureChanged(child);
633
+ this._children.push(child);
634
+ child._parent = this;
635
+ this._attachChild(child);
636
+ }
637
+ _addChildren(children) {
638
+ for (const child of children)
639
+ this.assertAcceptsChild(child);
640
+ if (_observer !== null)
641
+ for (const child of children)
642
+ this._structureChanged(child);
643
+ this._children.push(...children);
644
+ for (const child of children)
645
+ child._parent = this;
646
+ for (const child of children)
647
+ this._attachChild(child);
648
+ }
649
+ _removeChild(child) {
650
+ const i = this._children.indexOf(child);
651
+ if (i < 0)
652
+ return;
653
+ if (_observer !== null)
654
+ this._structureChanged(child);
655
+ const [removed] = this._children.splice(i, 1);
656
+ if (removed) {
657
+ removed._parent = null;
658
+ removed.detach();
659
+ }
660
+ }
661
+ dispose() {
662
+ if (this.__cells) {
663
+ for (const slot of this.__cells.slots.values()) {
664
+ slot.dispose();
665
+ }
666
+ }
667
+ this.__cells = undefined;
668
+ this._assets = null;
669
+ this._mounted = false;
670
+ // _props is retained (authored identity) so provideContext still works after reuse.
671
+ this._context = ContextMap.EMPTY;
672
+ this._contextBound = false;
673
+ }
674
+ }
675
+ declareMembers(Node, {
676
+ to: command(),
677
+ restore: command(),
678
+ addChildAt: command({ args: ["child", "index"] }),
679
+ });
680
+ //# sourceMappingURL=node.js.map