@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,5 @@
1
+ import { Clip } from "../../render/clip.js";
2
+ import type { Graphics2D } from "../../render/graphics2d.js";
3
+ /** The outline a shape's ops describe, as a clip: what `clip: true` cuts children to and picking tests against. */
4
+ export declare function clipOf(shape: Graphics2D): Clip;
5
+ //# sourceMappingURL=clip-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clip-of.d.ts","sourceRoot":"","sources":["../../../src/components/factory/clip-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,mHAAmH;AACnH,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAe9C"}
@@ -0,0 +1,33 @@
1
+ import { Clip } from "../../render/clip.js";
2
+ /** The outline a shape's ops describe, as a clip: what `clip: true` cuts children to and picking tests against. */
3
+ export function clipOf(shape) {
4
+ const clip = new Clip();
5
+ for (const op of shape.ops()) {
6
+ switch (op.kind) {
7
+ case "rect":
8
+ clip.rect(op.state);
9
+ break;
10
+ case "ellipse":
11
+ clip.ellipse(op.state);
12
+ break;
13
+ case "path":
14
+ clip.path(op.state);
15
+ break;
16
+ case "line":
17
+ clip.line(op.state);
18
+ break;
19
+ case "polygon":
20
+ clip.polygon(op.state);
21
+ break;
22
+ case "polygram":
23
+ clip.polygram(op.state);
24
+ break;
25
+ case "cut":
26
+ clip.cut();
27
+ break;
28
+ default: break;
29
+ }
30
+ }
31
+ return clip;
32
+ }
33
+ //# sourceMappingURL=clip-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clip-of.js","sourceRoot":"","sources":["../../../src/components/factory/clip-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,mHAAmH;AACnH,MAAM,UAAU,MAAM,CAAC,KAAiB;IACpC,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC;QAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;YACd,KAAK,MAAM;gBAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM;YACxC,KAAK,SAAS;gBAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM;YAC9C,KAAK,MAAM;gBAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM;YACxC,KAAK,MAAM;gBAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM;YACxC,KAAK,SAAS;gBAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM;YAC9C,KAAK,UAAU;gBAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAAC,MAAM;YAChD,KAAK,KAAK;gBAAE,IAAI,CAAC,GAAG,EAAE,CAAC;gBAAC,MAAM;YAC9B,OAAO,CAAC,CAAC,MAAM;QACnB,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { Clip } from \"@/render/clip\";\r\nimport type { Graphics2D } from \"@/render/graphics2d\";\r\n\r\n/** The outline a shape's ops describe, as a clip: what `clip: true` cuts children to and picking tests against. */\r\nexport function clipOf(shape: Graphics2D): Clip {\r\n const clip = new Clip();\r\n for (const op of shape.ops()) {\r\n switch (op.kind) {\r\n case \"rect\": clip.rect(op.state); break;\r\n case \"ellipse\": clip.ellipse(op.state); break;\r\n case \"path\": clip.path(op.state); break;\r\n case \"line\": clip.line(op.state); break;\r\n case \"polygon\": clip.polygon(op.state); break;\r\n case \"polygram\": clip.polygram(op.state); break;\r\n case \"cut\": clip.cut(); break;\r\n default: break;\r\n }\r\n }\r\n return clip;\r\n}\r\n"]}
@@ -0,0 +1,19 @@
1
+ import type { CommandsSpec, Kids, Piece, StateSpec, Values } from "../../components/factory/api.js";
2
+ /**
3
+ * A command as a module exports it: checked against the module's own state
4
+ * where it is written, then loose about the state it is run with, so it fits
5
+ * any component that spreads the module's state in.
6
+ */
7
+ type Portable<A> = A extends readonly unknown[] ? {
8
+ readonly args: A;
9
+ readonly run?: undefined;
10
+ } : unknown extends A ? (timeline: any, state: any, children: any) => Piece : {
11
+ readonly args: A;
12
+ run(timeline: any, state: any, children: any): Piece;
13
+ };
14
+ /** A module's commands, typed against the state it exports. */
15
+ export declare function commandsFor<const S extends StateSpec, const C>(state: S, commands: CommandsSpec<C, S, Values<S>, Kids>): {
16
+ readonly [N in keyof C]: Portable<C[N]>;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=commands-for.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands-for.d.ts","sourceRoot":"","sources":["../../../src/components/factory/commands-for.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAE7F;;;;GAIG;AACH,KAAK,QAAQ,CAAC,CAAC,IACX,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAA;CAAE,GAC3E,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,KAAK,GACvE;IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,KAAK,CAAA;CAAE,CAAC;AAEjF,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,CAAC,CAAC,EAC1D,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAC9C;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAE7C"}
@@ -0,0 +1,5 @@
1
+ /** A module's commands, typed against the state it exports. */
2
+ export function commandsFor(state, commands) {
3
+ return commands;
4
+ }
5
+ //# sourceMappingURL=commands-for.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands-for.js","sourceRoot":"","sources":["../../../src/components/factory/commands-for.ts"],"names":[],"mappings":"AAYA,+DAA+D;AAC/D,MAAM,UAAU,WAAW,CACvB,KAAQ,EACR,QAA6C;IAE7C,OAAO,QAAiB,CAAC;AAC7B,CAAC","sourcesContent":["import type { CommandsSpec, Kids, Piece, StateSpec, Values } from \"@/components/factory/api\";\r\n\r\n/**\r\n * A command as a module exports it: checked against the module's own state\r\n * where it is written, then loose about the state it is run with, so it fits\r\n * any component that spreads the module's state in.\r\n */\r\ntype Portable<A> =\r\n A extends readonly unknown[] ? { readonly args: A; readonly run?: undefined }\r\n : unknown extends A ? (timeline: any, state: any, children: any) => Piece\r\n : { readonly args: A; run(timeline: any, state: any, children: any): Piece };\r\n\r\n/** A module's commands, typed against the state it exports. */\r\nexport function commandsFor<const S extends StateSpec, const C>(\r\n state: S,\r\n commands: CommandsSpec<C, S, Values<S>, Kids>,\r\n): { readonly [N in keyof C]: Portable<C[N]> } {\r\n return commands as never;\r\n}\r\n"]}
@@ -0,0 +1,9 @@
1
+ import { NodeAudio } from "../../components/trees/audio/node-audio.js";
2
+ import type { Allowed, BoxAudioState, BuiltNode, Component, Element, Merge, SpecAudio, StateSpec, TreeCallProps } from "../../components/factory/api.js";
3
+ /**
4
+ * An audio component: a sound, or a bus mixing the sounds in it. Lowers onto a
5
+ * generated `NodeAudio` subclass. It has no audio field: what it plays comes
6
+ * from its commands' `timeline.sound`.
7
+ */
8
+ export declare function componentAudio<const K extends string, const S extends StateSpec = {}, const C = {}, const A extends Allowed = null, const B extends Element = never>(spec: SpecAudio<K, Merge<BoxAudioState, S>, S, C, A, B>): Component<K, Merge<BoxAudioState, S>, C, A, NodeAudio, TreeCallProps<Merge<BoxAudioState, S>, BuiltNode<Merge<BoxAudioState, S>, C, NodeAudio>>>;
9
+ //# sourceMappingURL=component-audio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-audio.d.ts","sourceRoot":"","sources":["../../../src/components/factory/component-audio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAa,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI7J;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,KAAK,CAAC,CAAC,SAAS,MAAM,EACtB,KAAK,CAAC,CAAC,SAAS,SAAS,GAAG,EAAE,EAC9B,KAAK,CAAC,CAAC,GAAG,EAAE,EACZ,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,IAAI,EAC9B,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACjC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,aAAa,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAU3M"}
@@ -0,0 +1,18 @@
1
+ import { NodeAudio } from "../../components/trees/audio/node-audio.js";
2
+ import { componentBase, finishComponent, lowering } from "../../components/factory/factory.js";
3
+ import { childView } from "../../components/factory/views.js";
4
+ /**
5
+ * An audio component: a sound, or a bus mixing the sounds in it. Lowers onto a
6
+ * generated `NodeAudio` subclass. It has no audio field: what it plays comes
7
+ * from its commands' `timeline.sound`.
8
+ */
9
+ export function componentAudio(spec) {
10
+ const l = lowering(spec, NodeAudio);
11
+ class Generated extends componentBase(NodeAudio, l) {
12
+ _commandChildren() {
13
+ return this.childrenAudio.map(childView);
14
+ }
15
+ }
16
+ return finishComponent(Generated, l);
17
+ }
18
+ //# sourceMappingURL=component-audio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-audio.js","sourceRoot":"","sources":["../../../src/components/factory/component-audio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAiB,MAAM,8BAA8B,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAM5B,IAAuD;IACrD,MAAM,CAAC,GAAG,QAAQ,CAAC,IAA2B,EAAE,SAAS,CAAC,CAAC;IAE3D,MAAM,SAAU,SAAQ,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC;QACtC,gBAAgB;YACrB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC;KACJ;IAED,OAAO,eAAe,CAAC,SAAS,EAAE,CAAC,CAAU,CAAC;AAClD,CAAC","sourcesContent":["import { NodeAudio } from \"@/components/trees/audio/node-audio\";\r\nimport type { Allowed, BoxAudioState, BuiltNode, ChildView, Component, Element, Merge, SpecAudio, StateSpec, TreeCallProps } from \"@/components/factory/api\";\r\nimport { componentBase, finishComponent, lowering, type CoreSpec } from \"@/components/factory/factory\";\r\nimport { childView } from \"@/components/factory/views\";\r\n\r\n/**\r\n * An audio component: a sound, or a bus mixing the sounds in it. Lowers onto a\r\n * generated `NodeAudio` subclass. It has no audio field: what it plays comes\r\n * from its commands' `timeline.sound`.\r\n */\r\nexport function componentAudio<\r\n const K extends string,\r\n const S extends StateSpec = {},\r\n const C = {},\r\n const A extends Allowed = null,\r\n const B extends Element = never,\r\n>(spec: SpecAudio<K, Merge<BoxAudioState, S>, S, C, A, B>): Component<K, Merge<BoxAudioState, S>, C, A, NodeAudio, TreeCallProps<Merge<BoxAudioState, S>, BuiltNode<Merge<BoxAudioState, S>, C, NodeAudio>>> {\r\n const l = lowering(spec as unknown as CoreSpec, NodeAudio);\r\n\r\n class Generated extends componentBase(NodeAudio, l) {\r\n override _commandChildren(): readonly ChildView[] {\r\n return this.childrenAudio.map(childView);\r\n }\r\n }\r\n\r\n return finishComponent(Generated, l) as never;\r\n}\r\n"]}
@@ -0,0 +1,8 @@
1
+ import type { Allowed, Box2DState, Component, Element, Merge, Spec2D, StateSpec } from "../../components/factory/api.js";
2
+ /**
3
+ * A 2D component: laid out in a box, drawn with `Graphics2D`. Lowers the spec
4
+ * onto a generated `Node2D` subclass, so a registry, a document and a host see
5
+ * an ordinary node type.
6
+ */
7
+ export declare function component2d<const K extends string, const S extends StateSpec = {}, const C = {}, const A extends Allowed = null, const B extends Element = never>(spec: Spec2D<K, Merge<Box2DState, S>, S, C, A, B>): Component<K, Merge<Box2DState, S>, C, A>;
8
+ //# sourceMappingURL=component2d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component2d.d.ts","sourceRoot":"","sources":["../../../src/components/factory/component2d.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAa,SAAS,EAAE,OAAO,EAAa,KAAK,EAAe,MAAM,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AA6BrJ;;;;GAIG;AACH,wBAAgB,WAAW,CACvB,KAAK,CAAC,CAAC,SAAS,MAAM,EACtB,KAAK,CAAC,CAAC,SAAS,SAAS,GAAG,EAAE,EAC9B,KAAK,CAAC,CAAC,GAAG,EAAE,EACZ,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,IAAI,EAC9B,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACjC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAmO7F"}
@@ -0,0 +1,240 @@
1
+ import { sizeInputOps } from "../../attributes/layout/size.js";
2
+ import { getNodeDescriptor } from "../../document/node-decorator.js";
3
+ import { flowOps } from "../../layout/ops.js";
4
+ import { Node2D } from "../../components/trees/2d/node2d.js";
5
+ import { containsClip } from "../../render/clip-contains.js";
6
+ import { clipOf } from "../../components/factory/clip-of.js";
7
+ import { componentBase, finishComponent, lowering } from "../../components/factory/factory.js";
8
+ import { childView, MeasurerImpl, RenderContextImpl, setKeyLookup, withPass, takeDecided, } from "../../components/factory/views.js";
9
+ import { childInkBounds } from "../../components/trees/2d/group-bounds.js";
10
+ import { NO_PROJECTION_3D } from "../../attributes/layout/matrix2d.js";
11
+ const NO_INSETS = { left: 0, right: 0, top: 0, bottom: 0 };
12
+ const SIZE_KEYS = new Set(["width", "height"]);
13
+ setKeyLookup((n) => getNodeDescriptor(n.constructor)?.key);
14
+ function slotOf(p) {
15
+ if (p.rotation === undefined && p.scale === undefined && p.opacity === undefined
16
+ && p.depth === undefined && p.rotationX === undefined && p.rotationY === undefined)
17
+ return null;
18
+ return {
19
+ rotation: p.rotation ?? 0, scale: p.scale ?? 1, opacity: p.opacity ?? 1,
20
+ depth: p.depth ?? 0, rotationX: p.rotationX ?? 0, rotationY: p.rotationY ?? 0,
21
+ };
22
+ }
23
+ /**
24
+ * A 2D component: laid out in a box, drawn with `Graphics2D`. Lowers the spec
25
+ * onto a generated `Node2D` subclass, so a registry, a document and a host see
26
+ * an ordinary node type.
27
+ */
28
+ export function component2d(spec) {
29
+ const s = spec;
30
+ const l = lowering(s, Node2D, SIZE_KEYS);
31
+ const { defaults } = l;
32
+ const flows = l.entries.has("flow");
33
+ class Generated extends componentBase(Node2D, l) {
34
+ _lastShape = null;
35
+ constructor(props) {
36
+ super(props);
37
+ this._measurer = new MeasurerImpl(this);
38
+ this._ctx = new RenderContextImpl(this);
39
+ this._slots = null;
40
+ this._planes = null;
41
+ this._box = null;
42
+ // A node made of other nodes hugs them, unless told otherwise; `flex` already said fill.
43
+ if (this._built > 0 && props?.flex === undefined) {
44
+ for (const axis of SIZE_KEYS) {
45
+ if (props?.[axis] === undefined && defaults[axis] === undefined)
46
+ this.applyProp(axis, "hug", { tween: sizeInputOps.lerp });
47
+ }
48
+ }
49
+ }
50
+ /**
51
+ * Hug what it was given, fill when given nothing, and fill a main axis a
52
+ * child fills, so a hugging parent doesn't leave that child no room: the
53
+ * rule shapes have today. A `defaults` size replaces it.
54
+ */
55
+ applyDefaultSize(props) {
56
+ const given = Node2D.flowChildrenProp(props);
57
+ const flow = props?.flow ?? "freeform";
58
+ // A flow container fills where a child fills, as shapes do; anything else hugs or fills, as `Node2D` does.
59
+ const main = flows
60
+ ? { width: flow !== "vertical", height: flow === "vertical" || flow === "freeform" }
61
+ : { width: false, height: false };
62
+ for (const axis of ["width", "height"]) {
63
+ if (props?.[axis] !== undefined)
64
+ continue;
65
+ const declared = defaults[axis];
66
+ const value = declared !== undefined && typeof declared !== "function" ? declared
67
+ : given.length === 0 || (main[axis] && Node2D.hasFillChild(given, axis)) ? "fill" : "hug";
68
+ this.applyProp(axis, value, { tween: sizeInputOps.lerp });
69
+ }
70
+ }
71
+ measure(constraints, scope) {
72
+ if (!s.measure)
73
+ return super.measure(constraints, scope);
74
+ this.lastMeasure = { constraints, measurer: scope };
75
+ const m = this._measurer;
76
+ m.max = { width: constraints.maxWidth, height: constraints.maxHeight };
77
+ m.scope = scope;
78
+ const natural = withPass(this, scope, m.max, () => s.measure(m, this._view, this.flowChildren().map(childView)));
79
+ // An engine module may have sized the node itself (text reports its own height even when it fills).
80
+ if (takeDecided(this))
81
+ return natural;
82
+ // The engine applies width and height: `hug` keeps the natural size, a number or `fill` replaces it.
83
+ return flowOps.size(this, constraints, NO_INSETS, natural);
84
+ }
85
+ layoutChildren(rect, scope) {
86
+ if (!s.layout)
87
+ return super.layoutChildren(rect, scope);
88
+ const children = this.flowChildren();
89
+ const box = { x: 0, y: 0, width: rect.width, height: rect.height, time: this.time };
90
+ this._box = box;
91
+ // A layout that places children by `Flow` records where a new one would go; any other leaves none.
92
+ this._childSpace = null;
93
+ const placements = withPass(this, scope, { width: rect.width, height: rect.height }, () => s.layout(box, this._view, children.map(childView)));
94
+ let slots = null;
95
+ let planes = null;
96
+ placements.forEach((p, i) => {
97
+ const child = children[i];
98
+ if (!child)
99
+ return;
100
+ child.layout({ x: p.x, y: 0 - p.y, width: p.width, height: p.height }, scope);
101
+ const slot = slotOf(p);
102
+ if (slot)
103
+ (slots ??= new Map()).set(child, slot);
104
+ if (p.plane)
105
+ (planes ??= new Map()).set(child, p.plane);
106
+ });
107
+ this._slots = slots;
108
+ this._planes = planes;
109
+ }
110
+ _placementOf(child) {
111
+ return this._slots?.get(child) ?? super._placementOf(child);
112
+ }
113
+ _planeOf(child) {
114
+ if (child)
115
+ return this._planes?.get(child) ?? null;
116
+ const box = this._box ?? { x: 0, y: 0, width: this.layoutBounds?.width ?? 0, height: this.layoutBounds?.height ?? 0, time: this.time };
117
+ return s.plane ? s.plane(box, this._view) : null;
118
+ }
119
+ renderContent(pass) {
120
+ if (!s.render)
121
+ return super.renderContent(pass);
122
+ this.applyTransform(pass);
123
+ const frame = this._spaceFrame;
124
+ // Edge-on or behind the lens: nothing of its own to draw, but its children have frames of their own.
125
+ if (frame && !frame.paints) {
126
+ this.renderChildren(pass);
127
+ return;
128
+ }
129
+ const ctx = this._ctx;
130
+ ctx.pass = pass;
131
+ ctx.cut = frame?.nearCut ?? null;
132
+ ctx.composite = null;
133
+ try {
134
+ this.renderContentWithEffects(pass, () => s.render(ctx, this._view));
135
+ }
136
+ finally {
137
+ ctx.pass = null;
138
+ ctx.cut = null;
139
+ // A render that stopped compositing clears the record; one that composites set it as it went.
140
+ this._record = ctx.composite;
141
+ }
142
+ }
143
+ /** The outline `render` paints now, found by running it with nothing drawn: picking and backdrop effects read it. */
144
+ clipSelf() {
145
+ this._probeRender();
146
+ return this._lastShape ? clipOf(this._lastShape) : null;
147
+ }
148
+ // What `render` does with the children, read from its last run: these are asked every frame,
149
+ // so they never re-run it. Before its first frame, one probe answers.
150
+ /** A composite, or a camera, paints its children into its own plane: none of them stands in a space. */
151
+ _rendersChildrenInSpace() {
152
+ const r = this._observed();
153
+ return !(r?.bounds || r?.camera) && super._rendersChildrenInSpace();
154
+ }
155
+ _localBounds() {
156
+ const bounds = this._observed()?.bounds;
157
+ return (bounds && childInkBounds(this, bounds)) ?? super._localBounds();
158
+ }
159
+ _cameraScope() {
160
+ return this._observed()?.camera ?? super._cameraScope();
161
+ }
162
+ _spaceCamera() {
163
+ return this._observed()?.space ?? super._spaceCamera();
164
+ }
165
+ /** A space's root is the space's frame, not a plane tilted in it. */
166
+ _projection() {
167
+ return this._observed()?.space ? NO_PROJECTION_3D : super._projection();
168
+ }
169
+ /** A render that builds a 3D scene views one: picking projects its 3D children through it. */
170
+ _isViewport3D() {
171
+ return this._observed()?.scene !== undefined;
172
+ }
173
+ /** The scene `render` builds now, built afresh. */
174
+ _scene3D() {
175
+ return this._probeRender()?.scene ?? null;
176
+ }
177
+ _observed() {
178
+ if (this._record === undefined)
179
+ this._probeRender();
180
+ return this._record ?? null;
181
+ }
182
+ /** Run `render` drawing nothing: the outline it paints, and what it does with the children. */
183
+ _probeRender() {
184
+ if (!s.render)
185
+ return (this._record = null);
186
+ const probe = (this._probe ??= new RenderContextImpl(this, true));
187
+ this._lastShape = null;
188
+ probe.composite = null;
189
+ s.render(probe, this._view);
190
+ return (this._record = probe.composite);
191
+ }
192
+ hitTestSelf(local, tolerance) {
193
+ const clip = this.clipSelf();
194
+ if (!clip || clip.isEmpty())
195
+ return super.hitTestSelf(local, tolerance);
196
+ return containsClip(clip, local, tolerance);
197
+ }
198
+ _renderOwnChildren(pass) {
199
+ this.renderChildren(pass);
200
+ }
201
+ _commandChildren() {
202
+ return this.flowChildren().map(childView);
203
+ }
204
+ }
205
+ const proto = Generated.prototype;
206
+ if (s.handles) {
207
+ const handles = Object.entries(s.handles);
208
+ const sizeOf = (node) => ({ width: node.layoutBounds?.width ?? 0, height: node.layoutBounds?.height ?? 0 });
209
+ proto._handles = function () {
210
+ const out = [];
211
+ for (const [prop, handle] of handles) {
212
+ const at = handle.at(this._view, sizeOf(this));
213
+ if (at)
214
+ out.push({ prop, at });
215
+ }
216
+ return out;
217
+ };
218
+ proto._handleValue = function (prop, at) {
219
+ const handle = s.handles[prop];
220
+ if (!handle)
221
+ return null;
222
+ return handle.value ? handle.value(at, this._view, sizeOf(this)) : { x: at.x, y: at.y };
223
+ };
224
+ }
225
+ if (s.bounds) {
226
+ const bounds = s.bounds;
227
+ proto._localBounds = function () {
228
+ return bounds({ width: this.layoutBounds?.width ?? 0, height: this.layoutBounds?.height ?? 0 }, this._view);
229
+ };
230
+ }
231
+ if (s.space) {
232
+ const space = s.space;
233
+ // The coordinates its 3D children stand in: read where each child places itself, and by picking.
234
+ Generated.prototype._spaceOf = function () {
235
+ return space(this._view);
236
+ };
237
+ }
238
+ return finishComponent(Generated, l);
239
+ }
240
+ //# sourceMappingURL=component2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component2d.js","sourceRoot":"","sources":["../../../src/components/factory/component2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAA2E,MAAM,8BAA8B,CAAC;AAE/H,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKtD,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAiB,MAAM,8BAA8B,CAAC;AACvG,OAAO,EACH,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,GAClF,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAqB,MAAM,8BAA8B,CAAC;AAKnF,MAAM,SAAS,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AAC3D,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE/C,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,WAA+B,CAAC,EAAE,GAAG,CAAC,CAAC;AAI/E,SAAS,MAAM,CAAC,CAAc;IAC1B,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;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;QACF,KAAK,CAAC,YAAY,GAAG,UAA2B,IAAY,EAAE,EAAW;YACrE,MAAM,MAAM,GAAG,CAAC,CAAC,OAAQ,CAAC,IAAI,CAAC,CAAC;YAChC,IAAI,CAAC,MAAM;gBAAE,OAAO,IAAI,CAAC;YACzB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,KAAc,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;QACrG,CAAC,CAAC;IACN,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QACX,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACxB,KAAK,CAAC,YAAY,GAAG;YACjB,OAAO,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAc,CAAC,CAAC;QACzH,CAAC,CAAC;IACN,CAAC;IACD,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QACV,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QACtB,iGAAiG;QAChG,SAAS,CAAC,SAAgE,CAAC,QAAQ,GAAG;YACnF,OAAO,KAAK,CAAC,IAAI,CAAC,KAAc,CAAC,CAAC;QACtC,CAAC,CAAC;IACN,CAAC;IAED,OAAO,eAAe,CAAC,SAAS,EAAE,CAAC,CAAwD,CAAC;AAChG,CAAC","sourcesContent":["import { sizeInputOps } from \"@/attributes/layout/size\";\r\nimport type { FlowMode } from \"@/layout/types\";\r\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport { getNodeDescriptor } from \"@/document/node-decorator\";\r\nimport type { BoxBounds } from \"@/layout/bounds\";\r\nimport type { SizeConstraints } from \"@/layout/constraints\";\r\nimport { flowOps } from \"@/layout/ops\";\r\nimport { Node2D, type ChildPlacement, type ChildPlane, type CameraScope, type NodeHandle } from \"@/components/trees/2d/node2d\";\r\nimport type { Clip } from \"@/render/clip\";\r\nimport { containsClip } from \"@/render/clip-contains\";\r\nimport type { Graphics2D } from \"@/render/graphics2d\";\r\nimport type { MeasureContext2D } from \"@/render/measure-context\";\r\nimport type { RenderPass2D } from \"@/render/render-context2d\";\r\nimport type { Allowed, Box2DState, ChildView, Component, Element, LayoutBox, Merge, Placement2D, Spec2D, StateSpec } from \"@/components/factory/api\";\r\nimport { clipOf } from \"@/components/factory/clip-of\";\r\nimport { componentBase, finishComponent, lowering, type CoreSpec } from \"@/components/factory/factory\";\r\nimport {\r\n childView, MeasurerImpl, RenderContextImpl, setKeyLookup, withPass, takeDecided, type ComponentHost, type Composite,\r\n} from \"@/components/factory/views\";\r\nimport { childInkBounds } from \"@/components/trees/2d/group-bounds\";\r\nimport type { SpaceCamera } from \"@/attributes/layout/space3d\";\r\nimport { NO_PROJECTION_3D, type Projection3D } from \"@/attributes/layout/matrix2d\";\r\nimport type { ChildSpace3D } from \"@/components/trees/three/node3d\";\r\nimport type { Scene3D } from \"@/render3d/scene3d\";\r\n\r\n\r\nconst NO_INSETS = { left: 0, right: 0, top: 0, bottom: 0 };\r\nconst SIZE_KEYS = new Set([\"width\", \"height\"]);\r\n\r\nsetKeyLookup((n) => getNodeDescriptor(n.constructor as new () => object)?.key);\r\n\r\ntype AnySpec = Spec2D<string, any, any, any, any, any>;\r\n\r\nfunction slotOf(p: Placement2D): ChildPlacement | null {\r\n if (p.rotation === undefined && p.scale === undefined && p.opacity === undefined\r\n && p.depth === undefined && p.rotationX === undefined && p.rotationY === undefined) return null;\r\n return {\r\n rotation: p.rotation ?? 0, scale: p.scale ?? 1, opacity: p.opacity ?? 1,\r\n depth: p.depth ?? 0, rotationX: p.rotationX ?? 0, rotationY: p.rotationY ?? 0,\r\n };\r\n}\r\n\r\n/**\r\n * A 2D component: laid out in a box, drawn with `Graphics2D`. Lowers the spec\r\n * onto a generated `Node2D` subclass, so a registry, a document and a host see\r\n * an ordinary node type.\r\n */\r\nexport function component2d<\r\n const K extends string,\r\n const S extends StateSpec = {},\r\n const C = {},\r\n const A extends Allowed = null,\r\n const B extends Element = never,\r\n>(spec: Spec2D<K, Merge<Box2DState, S>, S, C, A, B>): Component<K, Merge<Box2DState, S>, C, A> {\r\n const s = spec as unknown as AnySpec;\r\n const l = lowering(s as unknown as CoreSpec, Node2D, SIZE_KEYS);\r\n const { defaults } = l;\r\n const flows = l.entries.has(\"flow\");\r\n\r\n class Generated extends componentBase(Node2D, l) implements ComponentHost {\r\n _lastShape: Graphics2D | null = null;\r\n declare _measurer: MeasurerImpl;\r\n declare _ctx: RenderContextImpl;\r\n declare _probe: RenderContextImpl | undefined;\r\n declare _record: Composite | null | undefined;\r\n declare _slots: Map<Node2D, ChildPlacement> | null;\r\n declare _planes: Map<Node2D, ChildPlane> | null;\r\n declare _box: LayoutBox | null;\r\n\r\n constructor(props?: Record<string, unknown>) {\r\n super(props);\r\n this._measurer = new MeasurerImpl(this);\r\n this._ctx = new RenderContextImpl(this);\r\n this._slots = null;\r\n this._planes = null;\r\n this._box = null;\r\n // A node made of other nodes hugs them, unless told otherwise; `flex` already said fill.\r\n if (this._built > 0 && props?.flex === undefined) {\r\n for (const axis of SIZE_KEYS) {\r\n if (props?.[axis] === undefined && defaults[axis] === undefined) this.applyProp(axis, \"hug\", { tween: sizeInputOps.lerp });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Hug what it was given, fill when given nothing, and fill a main axis a\r\n * child fills, so a hugging parent doesn't leave that child no room: the\r\n * rule shapes have today. A `defaults` size replaces it.\r\n */\r\n protected override applyDefaultSize(props?: Record<string, unknown>): void {\r\n const given = Node2D.flowChildrenProp(props);\r\n const flow = (props?.flow as FlowMode | undefined) ?? \"freeform\";\r\n // A flow container fills where a child fills, as shapes do; anything else hugs or fills, as `Node2D` does.\r\n const main = flows\r\n ? { width: flow !== \"vertical\", height: flow === \"vertical\" || flow === \"freeform\" }\r\n : { width: false, height: false };\r\n for (const axis of [\"width\", \"height\"] as const) {\r\n if (props?.[axis] !== undefined) continue;\r\n const declared = defaults[axis];\r\n const value = declared !== undefined && typeof declared !== \"function\" ? declared\r\n : given.length === 0 || (main[axis] && Node2D.hasFillChild(given, axis)) ? \"fill\" : \"hug\";\r\n this.applyProp(axis, value, { tween: sizeInputOps.lerp });\r\n }\r\n }\r\n\r\n override measure(constraints: SizeConstraints, scope: MeasureContext2D) {\r\n if (!s.measure) return super.measure(constraints, scope);\r\n this.lastMeasure = { constraints, measurer: scope };\r\n const m = this._measurer;\r\n m.max = { width: constraints.maxWidth, height: constraints.maxHeight };\r\n m.scope = scope;\r\n const natural = withPass(this, scope, m.max, () => s.measure!(m, this._view as never, this.flowChildren().map(childView) as never));\r\n // An engine module may have sized the node itself (text reports its own height even when it fills).\r\n if (takeDecided(this)) return natural;\r\n // The engine applies width and height: `hug` keeps the natural size, a number or `fill` replaces it.\r\n return flowOps.size(this, constraints, NO_INSETS, natural);\r\n }\r\n\r\n protected override layoutChildren(rect: BoxBounds, scope: MeasureContext2D): void {\r\n if (!s.layout) return super.layoutChildren(rect, scope);\r\n const children = this.flowChildren();\r\n const box: LayoutBox = { x: 0, y: 0, width: rect.width, height: rect.height, time: this.time };\r\n this._box = box;\r\n // A layout that places children by `Flow` records where a new one would go; any other leaves none.\r\n this._childSpace = null;\r\n const placements = withPass(this, scope, { width: rect.width, height: rect.height },\r\n () => s.layout!(box, this._view as never, children.map(childView) as never));\r\n let slots: Map<Node2D, ChildPlacement> | null = null;\r\n let planes: Map<Node2D, ChildPlane> | null = null;\r\n placements.forEach((p, i) => {\r\n const child = children[i];\r\n if (!child) return;\r\n child.layout({ x: p.x, y: 0 - p.y, width: p.width, height: p.height }, scope);\r\n const slot = slotOf(p);\r\n if (slot) (slots ??= new Map()).set(child, slot);\r\n if (p.plane) (planes ??= new Map()).set(child, p.plane);\r\n });\r\n this._slots = slots;\r\n this._planes = planes;\r\n }\r\n\r\n override _placementOf(child: Node2D): ChildPlacement | null {\r\n return this._slots?.get(child) ?? super._placementOf(child);\r\n }\r\n\r\n override _planeOf(child: Node2D | null): ChildPlane | null {\r\n if (child) return this._planes?.get(child) ?? null;\r\n const box = this._box ?? { x: 0, y: 0, width: this.layoutBounds?.width ?? 0, height: this.layoutBounds?.height ?? 0, time: this.time };\r\n return s.plane ? s.plane(box, this._view as never) : null;\r\n }\r\n\r\n protected override renderContent(pass: RenderPass2D): void {\r\n if (!s.render) return super.renderContent(pass);\r\n this.applyTransform(pass);\r\n const frame = this._spaceFrame;\r\n // Edge-on or behind the lens: nothing of its own to draw, but its children have frames of their own.\r\n if (frame && !frame.paints) {\r\n this.renderChildren(pass);\r\n return;\r\n }\r\n const ctx = this._ctx;\r\n ctx.pass = pass;\r\n ctx.cut = frame?.nearCut ?? null;\r\n ctx.composite = null;\r\n try {\r\n this.renderContentWithEffects(pass, () => s.render!(ctx, this._view as never));\r\n } finally {\r\n ctx.pass = null;\r\n ctx.cut = null;\r\n // A render that stopped compositing clears the record; one that composites set it as it went.\r\n this._record = ctx.composite;\r\n }\r\n }\r\n\r\n /** The outline `render` paints now, found by running it with nothing drawn: picking and backdrop effects read it. */\r\n protected override clipSelf(): Clip | null {\r\n this._probeRender();\r\n return this._lastShape ? clipOf(this._lastShape) : null;\r\n }\r\n\r\n // What `render` does with the children, read from its last run: these are asked every frame,\r\n // so they never re-run it. Before its first frame, one probe answers.\r\n\r\n /** A composite, or a camera, paints its children into its own plane: none of them stands in a space. */\r\n override _rendersChildrenInSpace(): boolean {\r\n const r = this._observed();\r\n return !(r?.bounds || r?.camera) && super._rendersChildrenInSpace();\r\n }\r\n\r\n override _localBounds(): BoxBounds {\r\n const bounds = this._observed()?.bounds;\r\n return (bounds && childInkBounds(this, bounds)) ?? super._localBounds();\r\n }\r\n\r\n override _cameraScope(): CameraScope | null {\r\n return this._observed()?.camera ?? super._cameraScope();\r\n }\r\n\r\n override _spaceCamera(): SpaceCamera | null {\r\n return this._observed()?.space ?? super._spaceCamera();\r\n }\r\n\r\n /** A space's root is the space's frame, not a plane tilted in it. */\r\n protected override _projection(): Projection3D {\r\n return this._observed()?.space ? NO_PROJECTION_3D : super._projection();\r\n }\r\n\r\n /** A render that builds a 3D scene views one: picking projects its 3D children through it. */\r\n _isViewport3D(): boolean {\r\n return this._observed()?.scene !== undefined;\r\n }\r\n\r\n /** The scene `render` builds now, built afresh. */\r\n _scene3D(): Scene3D | null {\r\n return this._probeRender()?.scene ?? null;\r\n }\r\n\r\n _observed(): Composite | null {\r\n if (this._record === undefined) this._probeRender();\r\n return this._record ?? null;\r\n }\r\n\r\n /** Run `render` drawing nothing: the outline it paints, and what it does with the children. */\r\n _probeRender(): Composite | null {\r\n if (!s.render) return (this._record = null);\r\n const probe = (this._probe ??= new RenderContextImpl(this, true));\r\n this._lastShape = null;\r\n probe.composite = null;\r\n s.render(probe, this._view as never);\r\n return (this._record = probe.composite);\r\n }\r\n\r\n protected override hitTestSelf(local: Vector2, tolerance: number): boolean {\r\n const clip = this.clipSelf();\r\n if (!clip || clip.isEmpty()) return super.hitTestSelf(local, tolerance);\r\n return containsClip(clip, local, tolerance);\r\n }\r\n\r\n _renderOwnChildren(pass: RenderPass2D): void {\r\n this.renderChildren(pass);\r\n }\r\n\r\n override _commandChildren(): readonly ChildView[] {\r\n return this.flowChildren().map(childView);\r\n }\r\n }\r\n\r\n const proto = Generated.prototype as unknown as Record<string, unknown>;\r\n if (s.handles) {\r\n const handles = Object.entries(s.handles);\r\n const sizeOf = (node: Node2D) => ({ width: node.layoutBounds?.width ?? 0, height: node.layoutBounds?.height ?? 0 });\r\n proto._handles = function (this: Generated): readonly NodeHandle[] {\r\n const out: NodeHandle[] = [];\r\n for (const [prop, handle] of handles) {\r\n const at = handle.at(this._view as never, sizeOf(this));\r\n if (at) out.push({ prop, at });\r\n }\r\n return out;\r\n };\r\n proto._handleValue = function (this: Generated, prop: string, at: Vector2): Vector2 | null {\r\n const handle = s.handles![prop];\r\n if (!handle) return null;\r\n return handle.value ? handle.value(at, this._view as never, sizeOf(this)) : { x: at.x, y: at.y };\r\n };\r\n }\r\n if (s.bounds) {\r\n const bounds = s.bounds;\r\n proto._localBounds = function (this: Generated): BoxBounds {\r\n return bounds({ width: this.layoutBounds?.width ?? 0, height: this.layoutBounds?.height ?? 0 }, this._view as never);\r\n };\r\n }\r\n if (s.space) {\r\n const space = s.space;\r\n // The coordinates its 3D children stand in: read where each child places itself, and by picking.\r\n (Generated.prototype as unknown as { _spaceOf: () => ChildSpace3D | null })._spaceOf = function (this: Generated) {\r\n return space(this._view as never);\r\n };\r\n }\r\n\r\n return finishComponent(Generated, l) as unknown as Component<K, Merge<Box2DState, S>, C, A>;\r\n}\r\n"]}
@@ -0,0 +1,9 @@
1
+ import { Node3D } from "../../components/trees/three/node3d.js";
2
+ import type { Allowed, BuiltNode, CallProps3D, Component, Element, Merge, Spec3D, StateSpec, Transform3DState } from "../../components/factory/api.js";
3
+ /**
4
+ * A 3D component: placed by its transform, drawn with `Graphics3D`, lights and
5
+ * cameras. Lowers onto a generated `Node3D` subclass; its children render
6
+ * after it, in its space.
7
+ */
8
+ export declare function component3d<const K extends string, const S extends StateSpec = {}, const C = {}, const A extends Allowed = null, const B extends Element = never>(spec: Spec3D<K, Merge<Transform3DState, S>, S, C, A, B>): Component<K, Merge<Transform3DState, S>, C, A, Node3D, CallProps3D<Merge<Transform3DState, S>, BuiltNode<Merge<Transform3DState, S>, C, Node3D>>>;
9
+ //# sourceMappingURL=component3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component3d.d.ts","sourceRoot":"","sources":["../../../src/components/factory/component3d.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAqB,MAAM,iCAAiC,CAAC;AAQ5E,OAAO,KAAK,EACR,OAAO,EAAE,SAAS,EAAE,WAAW,EAAoB,SAAS,EAAE,OAAO,EAAE,KAAK,EAAmB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EACrI,MAAM,0BAA0B,CAAC;AAgDlC;;;;GAIG;AACH,wBAAgB,WAAW,CACvB,KAAK,CAAC,CAAC,SAAS,MAAM,EACtB,KAAK,CAAC,CAAC,SAAS,SAAS,GAAG,EAAE,EAC9B,KAAK,CAAC,CAAC,GAAG,EAAE,EACZ,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,IAAI,EAC9B,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EACjC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CA+D5M"}
@@ -0,0 +1,99 @@
1
+ import { getNodeDescriptor } from "../../document/node-decorator.js";
2
+ import { Node3D } from "../../components/trees/three/node3d.js";
3
+ import { declareEnvironment } from "../../render3d/tracking.js";
4
+ import { componentBase, finishComponent, lowering } from "../../components/factory/factory.js";
5
+ import { childView, setKeyLookup } from "../../components/factory/views.js";
6
+ setKeyLookup((n) => getNodeDescriptor(n.constructor)?.key);
7
+ /** What a 3D `render` draws into: the scene being built, with a camera placed where its node stands. */
8
+ class RenderContext3DImpl {
9
+ host;
10
+ target = null;
11
+ /** Set when `render` asks for a camera: such a node is no group, and stands its camera instead. */
12
+ camera3D = false;
13
+ environment3D = null;
14
+ constructor(host) {
15
+ this.host = host;
16
+ }
17
+ get time() {
18
+ return this.host.time;
19
+ }
20
+ draw(graphics) {
21
+ if (graphics)
22
+ this.target?.draw(graphics);
23
+ }
24
+ light(light, transform) {
25
+ this.target?.light(light, transform);
26
+ }
27
+ camera(camera) {
28
+ this.camera3D = true;
29
+ this.target?.camera({ ...this.host._ownTransform(), ...camera });
30
+ }
31
+ fog(fog) {
32
+ this.target?.fog(fog);
33
+ }
34
+ environment(environment) {
35
+ this.environment3D = environment;
36
+ this.target?.environment(environment);
37
+ }
38
+ }
39
+ /**
40
+ * A 3D component: placed by its transform, drawn with `Graphics3D`, lights and
41
+ * cameras. Lowers onto a generated `Node3D` subclass; its children render
42
+ * after it, in its space.
43
+ */
44
+ export function component3d(spec) {
45
+ const s = spec;
46
+ const l = lowering(s, Node3D);
47
+ class Generated extends componentBase(Node3D, l) {
48
+ constructor(props) {
49
+ super(props);
50
+ this._ctx3d = new RenderContext3DImpl(this);
51
+ }
52
+ renderSelf(ctx) {
53
+ if (!s.render)
54
+ return;
55
+ const c = this._ctx3d;
56
+ c.target = ctx;
57
+ try {
58
+ s.render(c, this._view);
59
+ }
60
+ finally {
61
+ c.target = null;
62
+ }
63
+ }
64
+ /** A node that stands a camera places the camera, not a group: its children stay in the parent's space. */
65
+ groupTransform() {
66
+ return this._rendersCamera() ? {} : super.groupTransform();
67
+ }
68
+ _rendersCamera() {
69
+ if (this._isCamera === undefined) {
70
+ const c = this._ctx3d;
71
+ c.camera3D = false;
72
+ if (s.render)
73
+ s.render(c, this._view);
74
+ this._isCamera = c.camera3D;
75
+ }
76
+ return this._isCamera;
77
+ }
78
+ _ownTransform() {
79
+ return this.transform3D();
80
+ }
81
+ /** What `render` draws loads itself: its textures and models, and an environment map it sets. */
82
+ declareAssets(assets) {
83
+ this._ctx3d.environment3D = null;
84
+ super.declareAssets(assets);
85
+ declareEnvironment(this._ctx3d.environment3D, assets);
86
+ }
87
+ _commandChildren() {
88
+ return this.children.filter((c) => c instanceof Node3D).map(childView);
89
+ }
90
+ }
91
+ if (s.space) {
92
+ const space = s.space;
93
+ Generated.prototype._spaceOf = function () {
94
+ return space(this._view);
95
+ };
96
+ }
97
+ return finishComponent(Generated, l);
98
+ }
99
+ //# sourceMappingURL=component3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component3d.js","sourceRoot":"","sources":["../../../src/components/factory/component3d.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAqB,MAAM,iCAAiC,CAAC;AAM5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAKzD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAiB,MAAM,8BAA8B,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAErE,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,WAA+B,CAAC,EAAE,GAAG,CAAC,CAAC;AAQ/E,wGAAwG;AACxG,MAAM,mBAAmB;IAMA;IALrB,MAAM,GAAuB,IAAI,CAAC;IAClC,mGAAmG;IACnG,QAAQ,GAAG,KAAK,CAAC;IACjB,aAAa,GAA6B,IAAI,CAAC;IAE/C,YAAqB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAI,CAAC;IAEtC,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,QAAuC;QACxC,IAAI,QAAQ;YAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,KAAkB,EAAE,SAAuB;QAC7C,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,MAAoB;QACvB,IAAI,CAAC,QAAQ,GA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AAC;QAC/D,CAAC;QAED,cAAc;YACV,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC/B,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;gBACtB,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACnB,IAAI,CAAC,CAAC,MAAM;oBAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,KAAc,CAAC,CAAC;gBAC/C,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,QAAQ,CAAC;YAChC,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;QAED,aAAa;YACT,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9B,CAAC;QAED,iGAAiG;QACxF,aAAa,CAAC,MAAkB;YACrC,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC;YACjC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAC5B,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAC1D,CAAC;QAEQ,gBAAgB;YACrB,OAAQ,IAAI,CAAC,QAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvF,CAAC;KACJ;IAED,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QACV,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QACrB,SAAS,CAAC,SAAoF,CAAC,QAAQ,GAAG;YACvG,OAAO,KAAK,CAAC,IAAI,CAAC,KAAc,CAAC,CAAC;QACtC,CAAC,CAAC;IACN,CAAC;IAED,OAAO,eAAe,CAAC,SAAS,EAAE,CAAC,CAAU,CAAC;AAClD,CAAC","sourcesContent":["import type { AssetScope } from \"@/assets/scope\";\r\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\r\nimport { getNodeDescriptor } from \"@/document/node-decorator\";\r\nimport type { Node } from \"@/components/trees/node/node\";\r\nimport { Node3D, type ChildSpace3D } from \"@/components/trees/three/node3d\";\r\nimport type { CameraData3D } from \"@/render3d/camera\";\r\nimport type { Graphics3D } from \"@/render3d/graphics3d\";\r\nimport type { LightData3D } from \"@/render3d/light\";\r\nimport type { RenderContext3D as SceneTarget } from \"@/render3d/render-context3d\";\r\nimport type { EnvironmentData3D, FogData3D } from \"@/render3d/scene-settings\";\r\nimport { declareEnvironment } from \"@/render3d/tracking\";\r\nimport type { Transform3D } from \"@/render3d/transform\";\r\nimport type {\r\n Allowed, BuiltNode, CallProps3D, ChildView, Clock, Component, Element, Merge, RenderContext3D, Spec3D, StateSpec, Transform3DState,\r\n} from \"@/components/factory/api\";\r\nimport { componentBase, finishComponent, lowering, type CoreSpec } from \"@/components/factory/factory\";\r\nimport { childView, setKeyLookup } from \"@/components/factory/views\";\r\n\r\nsetKeyLookup((n) => getNodeDescriptor(n.constructor as new () => object)?.key);\r\n\r\ntype AnySpec = Spec3D<string, any, any, any, any, any>;\r\n\r\ninterface Host3D extends Node3D {\r\n _ownTransform(): Transform3D;\r\n}\r\n\r\n/** What a 3D `render` draws into: the scene being built, with a camera placed where its node stands. */\r\nclass RenderContext3DImpl implements RenderContext3D {\r\n target: SceneTarget | null = null;\r\n /** Set when `render` asks for a camera: such a node is no group, and stands its camera instead. */\r\n camera3D = false;\r\n environment3D: EnvironmentData3D | null = null;\r\n\r\n constructor(readonly host: Host3D) { }\r\n\r\n get time(): Clock {\r\n return this.host.time;\r\n }\r\n\r\n draw(graphics: Graphics3D | null | undefined): void {\r\n if (graphics) this.target?.draw(graphics);\r\n }\r\n\r\n light(light: LightData3D, transform?: Transform3D): void {\r\n this.target?.light(light, transform);\r\n }\r\n\r\n camera(camera: CameraData3D): void {\r\n this.camera3D = true;\r\n this.target?.camera({ ...this.host._ownTransform(), ...camera } as CameraData3D);\r\n }\r\n\r\n fog(fog: FogData3D | Color | null): void {\r\n this.target?.fog(fog);\r\n }\r\n\r\n environment(environment: EnvironmentData3D | null): void {\r\n this.environment3D = environment;\r\n this.target?.environment(environment);\r\n }\r\n}\r\n\r\n/**\r\n * A 3D component: placed by its transform, drawn with `Graphics3D`, lights and\r\n * cameras. Lowers onto a generated `Node3D` subclass; its children render\r\n * after it, in its space.\r\n */\r\nexport function component3d<\r\n const K extends string,\r\n const S extends StateSpec = {},\r\n const C = {},\r\n const A extends Allowed = null,\r\n const B extends Element = never,\r\n>(spec: Spec3D<K, Merge<Transform3DState, S>, S, C, A, B>): Component<K, Merge<Transform3DState, S>, C, A, Node3D, CallProps3D<Merge<Transform3DState, S>, BuiltNode<Merge<Transform3DState, S>, C, Node3D>>> {\r\n const s = spec as unknown as AnySpec;\r\n const l = lowering(s as unknown as CoreSpec, Node3D);\r\n\r\n class Generated extends componentBase(Node3D, l) implements Host3D {\r\n declare _ctx3d: RenderContext3DImpl;\r\n declare _isCamera: boolean | undefined;\r\n\r\n constructor(props?: Record<string, unknown>) {\r\n super(props);\r\n this._ctx3d = new RenderContext3DImpl(this);\r\n }\r\n\r\n protected override renderSelf(ctx: SceneTarget): void {\r\n if (!s.render) return;\r\n const c = this._ctx3d;\r\n c.target = ctx;\r\n try {\r\n s.render(c, this._view as never);\r\n } finally {\r\n c.target = null;\r\n }\r\n }\r\n\r\n /** A node that stands a camera places the camera, not a group: its children stay in the parent's space. */\r\n protected override groupTransform(): Transform3D {\r\n return this._rendersCamera() ? {} : super.groupTransform();\r\n }\r\n\r\n _rendersCamera(): boolean {\r\n if (this._isCamera === undefined) {\r\n const c = this._ctx3d;\r\n c.camera3D = false;\r\n if (s.render) s.render(c, this._view as never);\r\n this._isCamera = c.camera3D;\r\n }\r\n return this._isCamera;\r\n }\r\n\r\n _ownTransform(): Transform3D {\r\n return this.transform3D();\r\n }\r\n\r\n /** What `render` draws loads itself: its textures and models, and an environment map it sets. */\r\n override declareAssets(assets: AssetScope): void {\r\n this._ctx3d.environment3D = null;\r\n super.declareAssets(assets);\r\n declareEnvironment(this._ctx3d.environment3D, assets);\r\n }\r\n\r\n override _commandChildren(): readonly ChildView[] {\r\n return (this.children as Node[]).filter((c) => c instanceof Node3D).map(childView);\r\n }\r\n }\r\n\r\n if (s.space) {\r\n const space = s.space;\r\n (Generated.prototype as unknown as { _spaceOf: (child: Node3D | null) => ChildSpace3D | null })._spaceOf = function (this: Generated) {\r\n return space(this._view as never);\r\n };\r\n }\r\n\r\n return finishComponent(Generated, l) as never;\r\n}\r\n"]}