@efxlab/motion-canvas-2d 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (455) hide show
  1. package/editor/index.css +40 -0
  2. package/editor/index.js +525 -0
  3. package/editor/index.js.map +1 -0
  4. package/lib/code/CodeCursor.d.ts +84 -0
  5. package/lib/code/CodeCursor.d.ts.map +1 -0
  6. package/lib/code/CodeCursor.js +315 -0
  7. package/lib/code/CodeDiffer.d.ts +28 -0
  8. package/lib/code/CodeDiffer.d.ts.map +1 -0
  9. package/lib/code/CodeDiffer.js +51 -0
  10. package/lib/code/CodeFragment.d.ts +42 -0
  11. package/lib/code/CodeFragment.d.ts.map +1 -0
  12. package/lib/code/CodeFragment.js +72 -0
  13. package/lib/code/CodeHighlighter.d.ts +69 -0
  14. package/lib/code/CodeHighlighter.d.ts.map +1 -0
  15. package/lib/code/CodeHighlighter.js +2 -0
  16. package/lib/code/CodeMetrics.d.ts +11 -0
  17. package/lib/code/CodeMetrics.d.ts.map +1 -0
  18. package/lib/code/CodeMetrics.js +29 -0
  19. package/lib/code/CodeRange.d.ts +43 -0
  20. package/lib/code/CodeRange.d.ts.map +1 -0
  21. package/lib/code/CodeRange.js +185 -0
  22. package/lib/code/CodeScope.d.ts +16 -0
  23. package/lib/code/CodeScope.d.ts.map +1 -0
  24. package/lib/code/CodeScope.js +72 -0
  25. package/lib/code/CodeSelection.d.ts +6 -0
  26. package/lib/code/CodeSelection.d.ts.map +1 -0
  27. package/lib/code/CodeSelection.js +13 -0
  28. package/lib/code/CodeSignal.d.ts +63 -0
  29. package/lib/code/CodeSignal.d.ts.map +1 -0
  30. package/lib/code/CodeSignal.js +206 -0
  31. package/lib/code/CodeTokenizer.d.ts +8 -0
  32. package/lib/code/CodeTokenizer.d.ts.map +1 -0
  33. package/lib/code/CodeTokenizer.js +50 -0
  34. package/lib/code/DefaultHighlightStyle.d.ts +3 -0
  35. package/lib/code/DefaultHighlightStyle.d.ts.map +1 -0
  36. package/lib/code/DefaultHighlightStyle.js +98 -0
  37. package/lib/code/LezerHighlighter.d.ts +22 -0
  38. package/lib/code/LezerHighlighter.d.ts.map +1 -0
  39. package/lib/code/LezerHighlighter.js +91 -0
  40. package/lib/code/diff.d.ts +31 -0
  41. package/lib/code/diff.d.ts.map +1 -0
  42. package/lib/code/diff.js +236 -0
  43. package/lib/code/extractRange.d.ts +17 -0
  44. package/lib/code/extractRange.d.ts.map +1 -0
  45. package/lib/code/extractRange.js +102 -0
  46. package/lib/code/index.d.ts +14 -0
  47. package/lib/code/index.d.ts.map +1 -0
  48. package/lib/code/index.js +14 -0
  49. package/lib/components/Bezier.d.ts +22 -0
  50. package/lib/components/Bezier.d.ts.map +1 -0
  51. package/lib/components/Bezier.js +80 -0
  52. package/lib/components/Camera.d.ts +172 -0
  53. package/lib/components/Camera.d.ts.map +1 -0
  54. package/lib/components/Camera.js +239 -0
  55. package/lib/components/Circle.d.ts +191 -0
  56. package/lib/components/Circle.d.ts.map +1 -0
  57. package/lib/components/Circle.js +178 -0
  58. package/lib/components/Code.d.ts +238 -0
  59. package/lib/components/Code.d.ts.map +1 -0
  60. package/lib/components/Code.js +331 -0
  61. package/lib/components/CodeBlock.d.ts +131 -0
  62. package/lib/components/CodeBlock.d.ts.map +1 -0
  63. package/lib/components/CodeBlock.js +462 -0
  64. package/lib/components/CubicBezier.d.ts +69 -0
  65. package/lib/components/CubicBezier.d.ts.map +1 -0
  66. package/lib/components/CubicBezier.js +81 -0
  67. package/lib/components/Curve.d.ts +202 -0
  68. package/lib/components/Curve.d.ts.map +1 -0
  69. package/lib/components/Curve.js +284 -0
  70. package/lib/components/Grid.d.ts +75 -0
  71. package/lib/components/Grid.d.ts.map +1 -0
  72. package/lib/components/Grid.js +91 -0
  73. package/lib/components/Icon.d.ts +58 -0
  74. package/lib/components/Icon.d.ts.map +1 -0
  75. package/lib/components/Icon.js +58 -0
  76. package/lib/components/Img.d.ts +116 -0
  77. package/lib/components/Img.d.ts.map +1 -0
  78. package/lib/components/Img.js +233 -0
  79. package/lib/components/Knot.d.ts +89 -0
  80. package/lib/components/Knot.d.ts.map +1 -0
  81. package/lib/components/Knot.js +68 -0
  82. package/lib/components/Latex.d.ts +49 -0
  83. package/lib/components/Latex.d.ts.map +1 -0
  84. package/lib/components/Latex.js +206 -0
  85. package/lib/components/Layout.d.ts +423 -0
  86. package/lib/components/Layout.d.ts.map +1 -0
  87. package/lib/components/Layout.js +699 -0
  88. package/lib/components/Line.d.ts +158 -0
  89. package/lib/components/Line.d.ts.map +1 -0
  90. package/lib/components/Line.js +315 -0
  91. package/lib/components/Node.d.ts +843 -0
  92. package/lib/components/Node.d.ts.map +1 -0
  93. package/lib/components/Node.js +1335 -0
  94. package/lib/components/Path.d.ts +18 -0
  95. package/lib/components/Path.d.ts.map +1 -0
  96. package/lib/components/Path.js +96 -0
  97. package/lib/components/Polygon.d.ts +157 -0
  98. package/lib/components/Polygon.d.ts.map +1 -0
  99. package/lib/components/Polygon.js +183 -0
  100. package/lib/components/QuadBezier.d.ts +61 -0
  101. package/lib/components/QuadBezier.d.ts.map +1 -0
  102. package/lib/components/QuadBezier.js +76 -0
  103. package/lib/components/Ray.d.ts +60 -0
  104. package/lib/components/Ray.d.ts.map +1 -0
  105. package/lib/components/Ray.js +95 -0
  106. package/lib/components/Rect.d.ts +112 -0
  107. package/lib/components/Rect.d.ts.map +1 -0
  108. package/lib/components/Rect.js +76 -0
  109. package/lib/components/SVG.d.ts +175 -0
  110. package/lib/components/SVG.d.ts.map +1 -0
  111. package/lib/components/SVG.js +582 -0
  112. package/lib/components/Shape.d.ts +39 -0
  113. package/lib/components/Shape.d.ts.map +1 -0
  114. package/lib/components/Shape.js +134 -0
  115. package/lib/components/Spline.d.ts +87 -0
  116. package/lib/components/Spline.d.ts.map +1 -0
  117. package/lib/components/Spline.js +230 -0
  118. package/lib/components/Txt.d.ts +51 -0
  119. package/lib/components/Txt.d.ts.map +1 -0
  120. package/lib/components/Txt.js +172 -0
  121. package/lib/components/TxtLeaf.d.ts +20 -0
  122. package/lib/components/TxtLeaf.d.ts.map +1 -0
  123. package/lib/components/TxtLeaf.js +185 -0
  124. package/lib/components/Video.d.ts +110 -0
  125. package/lib/components/Video.d.ts.map +1 -0
  126. package/lib/components/Video.js +267 -0
  127. package/lib/components/View2D.d.ts +25 -0
  128. package/lib/components/View2D.d.ts.map +1 -0
  129. package/lib/components/View2D.js +85 -0
  130. package/lib/components/index.d.ts +27 -0
  131. package/lib/components/index.d.ts.map +1 -0
  132. package/lib/components/index.js +27 -0
  133. package/lib/components/types.d.ts +17 -0
  134. package/lib/components/types.d.ts.map +1 -0
  135. package/lib/components/types.js +2 -0
  136. package/lib/curves/ArcSegment.d.ts +26 -0
  137. package/lib/curves/ArcSegment.d.ts.map +1 -0
  138. package/lib/curves/ArcSegment.js +116 -0
  139. package/lib/curves/CircleSegment.d.ts +18 -0
  140. package/lib/curves/CircleSegment.d.ts.map +1 -0
  141. package/lib/curves/CircleSegment.js +60 -0
  142. package/lib/curves/CubicBezierSegment.d.ts +18 -0
  143. package/lib/curves/CubicBezierSegment.d.ts.map +1 -0
  144. package/lib/curves/CubicBezierSegment.js +60 -0
  145. package/lib/curves/CurveDrawingInfo.d.ts +11 -0
  146. package/lib/curves/CurveDrawingInfo.d.ts.map +1 -0
  147. package/lib/curves/CurveDrawingInfo.js +2 -0
  148. package/lib/curves/CurvePoint.d.ts +15 -0
  149. package/lib/curves/CurvePoint.d.ts.map +1 -0
  150. package/lib/curves/CurvePoint.js +2 -0
  151. package/lib/curves/CurveProfile.d.ts +7 -0
  152. package/lib/curves/CurveProfile.d.ts.map +1 -0
  153. package/lib/curves/CurveProfile.js +2 -0
  154. package/lib/curves/KnotInfo.d.ts +12 -0
  155. package/lib/curves/KnotInfo.d.ts.map +1 -0
  156. package/lib/curves/KnotInfo.js +2 -0
  157. package/lib/curves/LineSegment.d.ts +16 -0
  158. package/lib/curves/LineSegment.d.ts.map +1 -0
  159. package/lib/curves/LineSegment.js +51 -0
  160. package/lib/curves/Polynomial.d.ts +118 -0
  161. package/lib/curves/Polynomial.d.ts.map +1 -0
  162. package/lib/curves/Polynomial.js +263 -0
  163. package/lib/curves/Polynomial2D.d.ts +22 -0
  164. package/lib/curves/Polynomial2D.d.ts.map +1 -0
  165. package/lib/curves/Polynomial2D.js +51 -0
  166. package/lib/curves/PolynomialSegment.d.ts +39 -0
  167. package/lib/curves/PolynomialSegment.d.ts.map +1 -0
  168. package/lib/curves/PolynomialSegment.js +88 -0
  169. package/lib/curves/QuadBezierSegment.d.ts +17 -0
  170. package/lib/curves/QuadBezierSegment.d.ts.map +1 -0
  171. package/lib/curves/QuadBezierSegment.js +53 -0
  172. package/lib/curves/Segment.d.ts +9 -0
  173. package/lib/curves/Segment.d.ts.map +1 -0
  174. package/lib/curves/Segment.js +3 -0
  175. package/lib/curves/UniformPolynomialCurveSampler.d.ts +43 -0
  176. package/lib/curves/UniformPolynomialCurveSampler.d.ts.map +1 -0
  177. package/lib/curves/UniformPolynomialCurveSampler.js +74 -0
  178. package/lib/curves/createCurveProfileLerp.d.ts +32 -0
  179. package/lib/curves/createCurveProfileLerp.d.ts.map +1 -0
  180. package/lib/curves/createCurveProfileLerp.js +351 -0
  181. package/lib/curves/getBezierSplineProfile.d.ts +12 -0
  182. package/lib/curves/getBezierSplineProfile.d.ts.map +1 -0
  183. package/lib/curves/getBezierSplineProfile.js +140 -0
  184. package/lib/curves/getCircleProfile.d.ts +4 -0
  185. package/lib/curves/getCircleProfile.d.ts.map +1 -0
  186. package/lib/curves/getCircleProfile.js +44 -0
  187. package/lib/curves/getPathProfile.d.ts +3 -0
  188. package/lib/curves/getPathProfile.d.ts.map +1 -0
  189. package/lib/curves/getPathProfile.js +128 -0
  190. package/lib/curves/getPointAtDistance.d.ts +4 -0
  191. package/lib/curves/getPointAtDistance.d.ts.map +1 -0
  192. package/lib/curves/getPointAtDistance.js +15 -0
  193. package/lib/curves/getPolylineProfile.d.ts +4 -0
  194. package/lib/curves/getPolylineProfile.d.ts.map +1 -0
  195. package/lib/curves/getPolylineProfile.js +58 -0
  196. package/lib/curves/getRectProfile.d.ts +4 -0
  197. package/lib/curves/getRectProfile.d.ts.map +1 -0
  198. package/lib/curves/getRectProfile.js +57 -0
  199. package/lib/curves/index.d.ts +17 -0
  200. package/lib/curves/index.d.ts.map +1 -0
  201. package/lib/curves/index.js +17 -0
  202. package/lib/decorators/canvasStyleSignal.d.ts +5 -0
  203. package/lib/decorators/canvasStyleSignal.d.ts.map +1 -0
  204. package/lib/decorators/canvasStyleSignal.js +12 -0
  205. package/lib/decorators/colorSignal.d.ts +2 -0
  206. package/lib/decorators/colorSignal.d.ts.map +1 -0
  207. package/lib/decorators/colorSignal.js +9 -0
  208. package/lib/decorators/compound.d.ts +27 -0
  209. package/lib/decorators/compound.d.ts.map +1 -0
  210. package/lib/decorators/compound.js +49 -0
  211. package/lib/decorators/computed.d.ts +9 -0
  212. package/lib/decorators/computed.d.ts.map +1 -0
  213. package/lib/decorators/computed.js +18 -0
  214. package/lib/decorators/defaultStyle.d.ts +2 -0
  215. package/lib/decorators/defaultStyle.d.ts.map +1 -0
  216. package/lib/decorators/defaultStyle.js +13 -0
  217. package/lib/decorators/filtersSignal.d.ts +11 -0
  218. package/lib/decorators/filtersSignal.d.ts.map +1 -0
  219. package/lib/decorators/filtersSignal.js +73 -0
  220. package/lib/decorators/index.d.ts +11 -0
  221. package/lib/decorators/index.d.ts.map +1 -0
  222. package/lib/decorators/index.js +11 -0
  223. package/lib/decorators/initializers.d.ts +4 -0
  224. package/lib/decorators/initializers.d.ts.map +1 -0
  225. package/lib/decorators/initializers.js +27 -0
  226. package/lib/decorators/nodeName.d.ts +9 -0
  227. package/lib/decorators/nodeName.d.ts.map +1 -0
  228. package/lib/decorators/nodeName.js +13 -0
  229. package/lib/decorators/signal.d.ts +183 -0
  230. package/lib/decorators/signal.d.ts.map +1 -0
  231. package/lib/decorators/signal.js +285 -0
  232. package/lib/decorators/spacingSignal.d.ts +2 -0
  233. package/lib/decorators/spacingSignal.d.ts.map +1 -0
  234. package/lib/decorators/spacingSignal.js +15 -0
  235. package/lib/decorators/vector2Signal.d.ts +8 -0
  236. package/lib/decorators/vector2Signal.d.ts.map +1 -0
  237. package/lib/decorators/vector2Signal.js +15 -0
  238. package/lib/index.d.ts +9 -0
  239. package/lib/index.d.ts.map +1 -0
  240. package/lib/index.js +9 -0
  241. package/lib/jsx-dev-runtime.d.ts +3 -0
  242. package/lib/jsx-dev-runtime.d.ts.map +1 -0
  243. package/lib/jsx-dev-runtime.js +3 -0
  244. package/lib/jsx-runtime.d.ts +12 -0
  245. package/lib/jsx-runtime.d.ts.map +1 -0
  246. package/lib/jsx-runtime.js +23 -0
  247. package/lib/partials/Filter.d.ts +82 -0
  248. package/lib/partials/Filter.d.ts.map +1 -0
  249. package/lib/partials/Filter.js +137 -0
  250. package/lib/partials/Gradient.d.ts +31 -0
  251. package/lib/partials/Gradient.d.ts.map +1 -0
  252. package/lib/partials/Gradient.js +63 -0
  253. package/lib/partials/Pattern.d.ts +13 -0
  254. package/lib/partials/Pattern.d.ts.map +1 -0
  255. package/lib/partials/Pattern.js +27 -0
  256. package/lib/partials/ShaderConfig.d.ts +81 -0
  257. package/lib/partials/ShaderConfig.d.ts.map +1 -0
  258. package/lib/partials/ShaderConfig.js +25 -0
  259. package/lib/partials/index.d.ts +5 -0
  260. package/lib/partials/index.d.ts.map +1 -0
  261. package/lib/partials/index.js +5 -0
  262. package/lib/partials/types.d.ts +35 -0
  263. package/lib/partials/types.d.ts.map +1 -0
  264. package/lib/partials/types.js +2 -0
  265. package/lib/scenes/Scene2D.d.ts +23 -0
  266. package/lib/scenes/Scene2D.d.ts.map +1 -0
  267. package/lib/scenes/Scene2D.js +152 -0
  268. package/lib/scenes/index.d.ts +4 -0
  269. package/lib/scenes/index.d.ts.map +1 -0
  270. package/lib/scenes/index.js +4 -0
  271. package/lib/scenes/makeScene2D.d.ts +5 -0
  272. package/lib/scenes/makeScene2D.d.ts.map +1 -0
  273. package/lib/scenes/makeScene2D.js +12 -0
  274. package/lib/scenes/useScene2D.d.ts +3 -0
  275. package/lib/scenes/useScene2D.d.ts.map +1 -0
  276. package/lib/scenes/useScene2D.js +5 -0
  277. package/lib/tsconfig.build.tsbuildinfo +1 -0
  278. package/lib/tsconfig.tsbuildinfo +1 -0
  279. package/lib/utils/CanvasUtils.d.ts +21 -0
  280. package/lib/utils/CanvasUtils.d.ts.map +1 -0
  281. package/lib/utils/CanvasUtils.js +138 -0
  282. package/lib/utils/diff.d.ts +31 -0
  283. package/lib/utils/diff.d.ts.map +1 -0
  284. package/lib/utils/diff.js +97 -0
  285. package/lib/utils/index.d.ts +4 -0
  286. package/lib/utils/index.d.ts.map +1 -0
  287. package/lib/utils/index.js +4 -0
  288. package/lib/utils/is.d.ts +8 -0
  289. package/lib/utils/is.d.ts.map +1 -0
  290. package/lib/utils/is.js +10 -0
  291. package/lib/utils/makeSignalExtensions.d.ts +4 -0
  292. package/lib/utils/makeSignalExtensions.d.ts.map +1 -0
  293. package/lib/utils/makeSignalExtensions.js +20 -0
  294. package/lib/utils/withDefaults.d.ts +20 -0
  295. package/lib/utils/withDefaults.d.ts.map +1 -0
  296. package/lib/utils/withDefaults.js +23 -0
  297. package/package.json +54 -0
  298. package/src/editor/NodeInspectorConfig.tsx +76 -0
  299. package/src/editor/PreviewOverlayConfig.tsx +65 -0
  300. package/src/editor/Provider.tsx +109 -0
  301. package/src/editor/SceneGraphTabConfig.tsx +87 -0
  302. package/src/editor/icons/CircleIcon.tsx +7 -0
  303. package/src/editor/icons/CodeBlockIcon.tsx +8 -0
  304. package/src/editor/icons/CurveIcon.tsx +7 -0
  305. package/src/editor/icons/GridIcon.tsx +7 -0
  306. package/src/editor/icons/IconMap.ts +35 -0
  307. package/src/editor/icons/ImgIcon.tsx +8 -0
  308. package/src/editor/icons/LayoutIcon.tsx +9 -0
  309. package/src/editor/icons/LineIcon.tsx +7 -0
  310. package/src/editor/icons/NodeIcon.tsx +7 -0
  311. package/src/editor/icons/RayIcon.tsx +7 -0
  312. package/src/editor/icons/RectIcon.tsx +7 -0
  313. package/src/editor/icons/ShapeIcon.tsx +7 -0
  314. package/src/editor/icons/TxtIcon.tsx +8 -0
  315. package/src/editor/icons/VideoIcon.tsx +7 -0
  316. package/src/editor/icons/View2DIcon.tsx +10 -0
  317. package/src/editor/index.css +0 -0
  318. package/src/editor/index.ts +19 -0
  319. package/src/editor/shortcuts.ts +27 -0
  320. package/src/editor/tree/DetachedRoot.tsx +27 -0
  321. package/src/editor/tree/NodeElement.tsx +72 -0
  322. package/src/editor/tree/TreeElement.tsx +70 -0
  323. package/src/editor/tree/TreeRoot.tsx +10 -0
  324. package/src/editor/tree/ViewRoot.tsx +20 -0
  325. package/src/editor/tree/index.module.scss +45 -0
  326. package/src/editor/tree/index.ts +4 -0
  327. package/src/editor/tree/navigation.ts +145 -0
  328. package/src/editor/tsconfig.build.json +5 -0
  329. package/src/editor/tsconfig.json +12 -0
  330. package/src/editor/tsdoc.json +4 -0
  331. package/src/editor/utils/SignalSet.ts +37 -0
  332. package/src/editor/utils/index.ts +1 -0
  333. package/src/editor/vite-env.d.ts +1 -0
  334. package/src/lib/code/CodeCursor.ts +468 -0
  335. package/src/lib/code/CodeDiffer.ts +77 -0
  336. package/src/lib/code/CodeFragment.ts +96 -0
  337. package/src/lib/code/CodeHighlighter.ts +73 -0
  338. package/src/lib/code/CodeMetrics.ts +47 -0
  339. package/src/lib/code/CodeRange.test.ts +113 -0
  340. package/src/lib/code/CodeRange.ts +222 -0
  341. package/src/lib/code/CodeScope.ts +100 -0
  342. package/src/lib/code/CodeSelection.ts +28 -0
  343. package/src/lib/code/CodeSignal.ts +348 -0
  344. package/src/lib/code/CodeTokenizer.ts +54 -0
  345. package/src/lib/code/DefaultHighlightStyle.ts +98 -0
  346. package/src/lib/code/LezerHighlighter.ts +113 -0
  347. package/src/lib/code/diff.test.ts +311 -0
  348. package/src/lib/code/diff.ts +319 -0
  349. package/src/lib/code/extractRange.ts +125 -0
  350. package/src/lib/code/index.ts +13 -0
  351. package/src/lib/components/Bezier.ts +103 -0
  352. package/src/lib/components/Camera.ts +359 -0
  353. package/src/lib/components/Circle.ts +269 -0
  354. package/src/lib/components/Code.ts +532 -0
  355. package/src/lib/components/CodeBlock.ts +581 -0
  356. package/src/lib/components/CubicBezier.ts +115 -0
  357. package/src/lib/components/Curve.ts +455 -0
  358. package/src/lib/components/Grid.ts +134 -0
  359. package/src/lib/components/Icon.ts +95 -0
  360. package/src/lib/components/Img.ts +305 -0
  361. package/src/lib/components/Knot.ts +156 -0
  362. package/src/lib/components/Latex.ts +249 -0
  363. package/src/lib/components/Layout.ts +1071 -0
  364. package/src/lib/components/Line.ts +394 -0
  365. package/src/lib/components/Node.ts +1949 -0
  366. package/src/lib/components/Path.ts +132 -0
  367. package/src/lib/components/Polygon.ts +238 -0
  368. package/src/lib/components/QuadBezier.ts +103 -0
  369. package/src/lib/components/Ray.ts +126 -0
  370. package/src/lib/components/Rect.ts +186 -0
  371. package/src/lib/components/SVG.ts +788 -0
  372. package/src/lib/components/Shape.ts +146 -0
  373. package/src/lib/components/Spline.ts +318 -0
  374. package/src/lib/components/Txt.test.tsx +81 -0
  375. package/src/lib/components/Txt.ts +204 -0
  376. package/src/lib/components/TxtLeaf.ts +210 -0
  377. package/src/lib/components/Video.ts +368 -0
  378. package/src/lib/components/View2D.ts +85 -0
  379. package/src/lib/components/__logs__/image-without-source.md +17 -0
  380. package/src/lib/components/__logs__/line-without-points.md +30 -0
  381. package/src/lib/components/__logs__/reactive-playback-rate.md +21 -0
  382. package/src/lib/components/__logs__/spline-with-insufficient-knots.md +24 -0
  383. package/src/lib/components/__tests__/children.test.tsx +142 -0
  384. package/src/lib/components/__tests__/clone.test.tsx +126 -0
  385. package/src/lib/components/__tests__/generatorTest.ts +27 -0
  386. package/src/lib/components/__tests__/mockScene2D.ts +50 -0
  387. package/src/lib/components/__tests__/query.test.tsx +122 -0
  388. package/src/lib/components/__tests__/state.test.tsx +60 -0
  389. package/src/lib/components/index.ts +26 -0
  390. package/src/lib/components/types.ts +35 -0
  391. package/src/lib/curves/ArcSegment.ts +155 -0
  392. package/src/lib/curves/CircleSegment.ts +77 -0
  393. package/src/lib/curves/CubicBezierSegment.ts +78 -0
  394. package/src/lib/curves/CurveDrawingInfo.ts +11 -0
  395. package/src/lib/curves/CurvePoint.ts +15 -0
  396. package/src/lib/curves/CurveProfile.ts +7 -0
  397. package/src/lib/curves/KnotInfo.ts +10 -0
  398. package/src/lib/curves/LineSegment.ts +62 -0
  399. package/src/lib/curves/Polynomial.ts +355 -0
  400. package/src/lib/curves/Polynomial2D.ts +62 -0
  401. package/src/lib/curves/PolynomialSegment.ts +124 -0
  402. package/src/lib/curves/QuadBezierSegment.ts +64 -0
  403. package/src/lib/curves/Segment.ts +17 -0
  404. package/src/lib/curves/UniformPolynomialCurveSampler.ts +93 -0
  405. package/src/lib/curves/createCurveProfileLerp.ts +471 -0
  406. package/src/lib/curves/getBezierSplineProfile.ts +227 -0
  407. package/src/lib/curves/getCircleProfile.ts +86 -0
  408. package/src/lib/curves/getPathProfile.ts +177 -0
  409. package/src/lib/curves/getPointAtDistance.ts +21 -0
  410. package/src/lib/curves/getPolylineProfile.test.ts +21 -0
  411. package/src/lib/curves/getPolylineProfile.ts +88 -0
  412. package/src/lib/curves/getRectProfile.ts +138 -0
  413. package/src/lib/curves/index.ts +16 -0
  414. package/src/lib/decorators/canvasStyleSignal.ts +15 -0
  415. package/src/lib/decorators/colorSignal.ts +9 -0
  416. package/src/lib/decorators/compound.ts +85 -0
  417. package/src/lib/decorators/computed.ts +18 -0
  418. package/src/lib/decorators/defaultStyle.ts +15 -0
  419. package/src/lib/decorators/filtersSignal.ts +133 -0
  420. package/src/lib/decorators/index.ts +10 -0
  421. package/src/lib/decorators/initializers.ts +34 -0
  422. package/src/lib/decorators/nodeName.ts +13 -0
  423. package/src/lib/decorators/signal.test.ts +89 -0
  424. package/src/lib/decorators/signal.ts +348 -0
  425. package/src/lib/decorators/spacingSignal.ts +15 -0
  426. package/src/lib/decorators/vector2Signal.ts +35 -0
  427. package/src/lib/globals.d.ts +3 -0
  428. package/src/lib/index.ts +8 -0
  429. package/src/lib/jsx-dev-runtime.ts +2 -0
  430. package/src/lib/jsx-runtime.ts +45 -0
  431. package/src/lib/parse-svg-path.d.ts +14 -0
  432. package/src/lib/partials/Filter.ts +185 -0
  433. package/src/lib/partials/Gradient.ts +103 -0
  434. package/src/lib/partials/Pattern.ts +35 -0
  435. package/src/lib/partials/ShaderConfig.ts +122 -0
  436. package/src/lib/partials/index.ts +4 -0
  437. package/src/lib/partials/types.ts +58 -0
  438. package/src/lib/scenes/Scene2D.ts +195 -0
  439. package/src/lib/scenes/index.ts +3 -0
  440. package/src/lib/scenes/makeScene2D.ts +19 -0
  441. package/src/lib/scenes/useScene2D.ts +6 -0
  442. package/src/lib/tsconfig.build.json +12 -0
  443. package/src/lib/tsconfig.json +14 -0
  444. package/src/lib/tsdoc.json +4 -0
  445. package/src/lib/utils/CanvasUtils.ts +306 -0
  446. package/src/lib/utils/diff.test.ts +453 -0
  447. package/src/lib/utils/diff.ts +148 -0
  448. package/src/lib/utils/index.ts +3 -0
  449. package/src/lib/utils/is.ts +11 -0
  450. package/src/lib/utils/makeSignalExtensions.ts +29 -0
  451. package/src/lib/utils/withDefaults.tsx +26 -0
  452. package/src/tsconfig.base.json +18 -0
  453. package/src/tsconfig.build.json +8 -0
  454. package/src/tsconfig.json +5 -0
  455. package/tsconfig.project.json +7 -0
@@ -0,0 +1,843 @@
1
+ import { BBox, ColorSignal, PossibleColor, PossibleSpacing, PossibleVector2, Promisable, ReferenceReceiver, Signal, SignalValue, SimpleSignal, SimpleVector2Signal, SpacingSignal, ThreadGenerator, TimingFunction, Vector2, Vector2Signal } from '@efxlab/motion-canvas-core';
2
+ import { NODE_NAME } from '../decorators';
3
+ import { FiltersSignal } from '../decorators/filtersSignal';
4
+ import { Filter } from '../partials';
5
+ import { PossibleShaderConfig, ShaderConfig } from '../partials/ShaderConfig';
6
+ import type { View2D } from './View2D';
7
+ import type { ComponentChildren } from './types';
8
+ export type NodeState = NodeProps & Record<string, any>;
9
+ export interface NodeProps {
10
+ ref?: ReferenceReceiver<any>;
11
+ children?: SignalValue<ComponentChildren>;
12
+ /**
13
+ * @deprecated Use {@link children} instead.
14
+ */
15
+ spawner?: SignalValue<ComponentChildren>;
16
+ key?: string;
17
+ x?: SignalValue<number>;
18
+ y?: SignalValue<number>;
19
+ position?: SignalValue<PossibleVector2>;
20
+ rotation?: SignalValue<number>;
21
+ scaleX?: SignalValue<number>;
22
+ scaleY?: SignalValue<number>;
23
+ scale?: SignalValue<PossibleVector2>;
24
+ skewX?: SignalValue<number>;
25
+ skewY?: SignalValue<number>;
26
+ skew?: SignalValue<PossibleVector2>;
27
+ zIndex?: SignalValue<number>;
28
+ opacity?: SignalValue<number>;
29
+ filters?: SignalValue<Filter[]>;
30
+ shadowColor?: SignalValue<PossibleColor>;
31
+ shadowBlur?: SignalValue<number>;
32
+ shadowOffsetX?: SignalValue<number>;
33
+ shadowOffsetY?: SignalValue<number>;
34
+ shadowOffset?: SignalValue<PossibleVector2>;
35
+ cache?: SignalValue<boolean>;
36
+ /**
37
+ * {@inheritDoc Node.cachePadding}
38
+ */
39
+ cachePaddingTop?: SignalValue<number>;
40
+ /**
41
+ * {@inheritDoc Node.cachePadding}
42
+ */
43
+ cachePaddingBottom?: SignalValue<number>;
44
+ /**
45
+ * {@inheritDoc Node.cachePadding}
46
+ */
47
+ cachePaddingLeft?: SignalValue<number>;
48
+ /**
49
+ * {@inheritDoc Node.cachePadding}
50
+ */
51
+ cachePaddingRight?: SignalValue<number>;
52
+ /**
53
+ * {@inheritDoc Node.cachePadding}
54
+ */
55
+ cachePadding?: SignalValue<PossibleSpacing>;
56
+ composite?: SignalValue<boolean>;
57
+ compositeOperation?: SignalValue<GlobalCompositeOperation>;
58
+ /**
59
+ * @experimental
60
+ */
61
+ shaders?: PossibleShaderConfig;
62
+ }
63
+ export declare class Node implements Promisable<Node> {
64
+ /**
65
+ * @internal
66
+ */
67
+ readonly [NODE_NAME]: string;
68
+ isClass: boolean;
69
+ /**
70
+ * Represents the position of this node in local space of its parent.
71
+ *
72
+ * @example
73
+ * Initializing the position:
74
+ * ```tsx
75
+ * // with a possible vector:
76
+ * <Node position={[1, 2]} />
77
+ * // with individual components:
78
+ * <Node x={1} y={2} />
79
+ * ```
80
+ *
81
+ * Accessing the position:
82
+ * ```tsx
83
+ * // retrieving the vector:
84
+ * const position = node.position();
85
+ * // retrieving an individual component:
86
+ * const x = node.position.x();
87
+ * ```
88
+ *
89
+ * Setting the position:
90
+ * ```tsx
91
+ * // with a possible vector:
92
+ * node.position([1, 2]);
93
+ * node.position(() => [1, 2]);
94
+ * // with individual components:
95
+ * node.position.x(1);
96
+ * node.position.x(() => 1);
97
+ * ```
98
+ */
99
+ readonly position: Vector2Signal<this>;
100
+ get x(): SimpleSignal<number, this>;
101
+ get y(): SimpleSignal<number, this>;
102
+ /**
103
+ * A helper signal for operating on the position in world space.
104
+ *
105
+ * @remarks
106
+ * Retrieving the position using this signal returns the position in world
107
+ * space. Similarly, setting the position using this signal transforms the
108
+ * new value to local space.
109
+ *
110
+ * If the new value is a function, the position of this node will be
111
+ * continuously updated to always match the position returned by the function.
112
+ * This can be useful to "pin" the node in a specific place or to make it
113
+ * follow another node's position.
114
+ *
115
+ * Unlike {@link position}, this signal is not compound - it doesn't contain
116
+ * separate signals for the `x` and `y` components.
117
+ */
118
+ readonly absolutePosition: SimpleVector2Signal<this>;
119
+ protected getAbsolutePosition(): Vector2;
120
+ protected setAbsolutePosition(value: SignalValue<PossibleVector2>): void;
121
+ /**
122
+ * Represents the rotation (in degrees) of this node relative to its parent.
123
+ */
124
+ readonly rotation: SimpleSignal<number, this>;
125
+ /**
126
+ * A helper signal for operating on the rotation in world space.
127
+ *
128
+ * @remarks
129
+ * Retrieving the rotation using this signal returns the rotation in world
130
+ * space. Similarly, setting the rotation using this signal transforms the
131
+ * new value to local space.
132
+ *
133
+ * If the new value is a function, the rotation of this node will be
134
+ * continuously updated to always match the rotation returned by the function.
135
+ */
136
+ readonly absoluteRotation: SimpleSignal<number, this>;
137
+ protected getAbsoluteRotation(): number;
138
+ protected setAbsoluteRotation(value: SignalValue<number>): void;
139
+ /**
140
+ * Represents the scale of this node in local space of its parent.
141
+ *
142
+ * @example
143
+ * Initializing the scale:
144
+ * ```tsx
145
+ * // with a possible vector:
146
+ * <Node scale={[1, 2]} />
147
+ * // with individual components:
148
+ * <Node scaleX={1} scaleY={2} />
149
+ * ```
150
+ *
151
+ * Accessing the scale:
152
+ * ```tsx
153
+ * // retrieving the vector:
154
+ * const scale = node.scale();
155
+ * // retrieving an individual component:
156
+ * const scaleX = node.scale.x();
157
+ * ```
158
+ *
159
+ * Setting the scale:
160
+ * ```tsx
161
+ * // with a possible vector:
162
+ * node.scale([1, 2]);
163
+ * node.scale(() => [1, 2]);
164
+ * // with individual components:
165
+ * node.scale.x(1);
166
+ * node.scale.x(() => 1);
167
+ * ```
168
+ */
169
+ readonly scale: Vector2Signal<this>;
170
+ /**
171
+ * Represents the skew of this node in local space of its parent.
172
+ *
173
+ * @example
174
+ * Initializing the skew:
175
+ * ```tsx
176
+ * // with a possible vector:
177
+ * <Node skew={[40, 20]} />
178
+ * // with individual components:
179
+ * <Node skewX={40} skewY={20} />
180
+ * ```
181
+ *
182
+ * Accessing the skew:
183
+ * ```tsx
184
+ * // retrieving the vector:
185
+ * const skew = node.skew();
186
+ * // retrieving an individual component:
187
+ * const skewX = node.skew.x();
188
+ * ```
189
+ *
190
+ * Setting the skew:
191
+ * ```tsx
192
+ * // with a possible vector:
193
+ * node.skew([40, 20]);
194
+ * node.skew(() => [40, 20]);
195
+ * // with individual components:
196
+ * node.skew.x(40);
197
+ * node.skew.x(() => 40);
198
+ * ```
199
+ */
200
+ readonly skew: Vector2Signal<this>;
201
+ /**
202
+ * A helper signal for operating on the scale in world space.
203
+ *
204
+ * @remarks
205
+ * Retrieving the scale using this signal returns the scale in world space.
206
+ * Similarly, setting the scale using this signal transforms the new value to
207
+ * local space.
208
+ *
209
+ * If the new value is a function, the scale of this node will be continuously
210
+ * updated to always match the position returned by the function.
211
+ *
212
+ * Unlike {@link scale}, this signal is not compound - it doesn't contain
213
+ * separate signals for the `x` and `y` components.
214
+ */
215
+ readonly absoluteScale: SimpleVector2Signal<this>;
216
+ protected getAbsoluteScale(): Vector2;
217
+ protected setAbsoluteScale(value: SignalValue<PossibleVector2>): void;
218
+ private getRelativeScale;
219
+ readonly zIndex: SimpleSignal<number, this>;
220
+ readonly cache: SimpleSignal<boolean, this>;
221
+ /**
222
+ * Controls the padding of the cached canvas used by this node.
223
+ *
224
+ * @remarks
225
+ * By default, the size of the cache is determined based on the bounding box
226
+ * of the node and its children. That includes effects such as stroke or
227
+ * shadow. This property can be used to expand the cache area further.
228
+ * Usually used to account for custom effects created by {@link shaders}.
229
+ */
230
+ readonly cachePadding: SpacingSignal<this>;
231
+ readonly composite: SimpleSignal<boolean, this>;
232
+ readonly compositeOperation: SimpleSignal<GlobalCompositeOperation, this>;
233
+ private readonly compositeOverride;
234
+ protected tweenCompositeOperation(value: SignalValue<GlobalCompositeOperation>, time: number, timingFunction: TimingFunction): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>;
235
+ /**
236
+ * Represents the opacity of this node in the range 0-1.
237
+ *
238
+ * @remarks
239
+ * The value is clamped to the range 0-1.
240
+ */
241
+ readonly opacity: SimpleSignal<number, this>;
242
+ absoluteOpacity(): number;
243
+ readonly filters: FiltersSignal<this>;
244
+ readonly shadowColor: ColorSignal<this>;
245
+ readonly shadowBlur: SimpleSignal<number, this>;
246
+ readonly shadowOffset: Vector2Signal<this>;
247
+ /**
248
+ * @experimental
249
+ */
250
+ readonly shaders: Signal<PossibleShaderConfig, ShaderConfig[], this>;
251
+ protected hasFilters(): boolean;
252
+ protected hasShadow(): boolean;
253
+ protected filterString(): string;
254
+ /**
255
+ * @deprecated Use {@link children} instead.
256
+ */
257
+ protected readonly spawner: SimpleSignal<ComponentChildren, this>;
258
+ protected getSpawner(): ComponentChildren;
259
+ protected setSpawner(value: SignalValue<ComponentChildren>): void;
260
+ readonly children: Signal<ComponentChildren, Node[], this>;
261
+ protected setChildren(value: SignalValue<ComponentChildren>): void;
262
+ protected getChildren(): Node[];
263
+ protected spawnedChildren(): Node[];
264
+ protected sortedChildren(): Node[];
265
+ protected view2D: View2D;
266
+ private stateStack;
267
+ protected realChildren: Node[];
268
+ protected hasSpawnedChildren: boolean;
269
+ private unregister;
270
+ readonly parent: SimpleSignal<Node | null, void>;
271
+ readonly properties: Record<string, import("../decorators").PropertyMetadata<any>>;
272
+ readonly key: string;
273
+ readonly creationStack?: string;
274
+ constructor({ children, spawner, key, ...rest }: NodeProps);
275
+ /**
276
+ * Get the local-to-world matrix for this node.
277
+ *
278
+ * @remarks
279
+ * This matrix transforms vectors from local space of this node to world
280
+ * space.
281
+ *
282
+ * @example
283
+ * Calculate the absolute position of a point located 200 pixels to the right
284
+ * of the node:
285
+ * ```ts
286
+ * const local = new Vector2(0, 200);
287
+ * const world = local.transformAsPoint(node.localToWorld());
288
+ * ```
289
+ */
290
+ localToWorld(): DOMMatrix;
291
+ /**
292
+ * Get the world-to-local matrix for this node.
293
+ *
294
+ * @remarks
295
+ * This matrix transforms vectors from world space to local space of this
296
+ * node.
297
+ *
298
+ * @example
299
+ * Calculate the position relative to this node for a point located in the
300
+ * top-left corner of the screen:
301
+ * ```ts
302
+ * const world = new Vector2(0, 0);
303
+ * const local = world.transformAsPoint(node.worldToLocal());
304
+ * ```
305
+ */
306
+ worldToLocal(): DOMMatrix;
307
+ /**
308
+ * Get the world-to-parent matrix for this node.
309
+ *
310
+ * @remarks
311
+ * This matrix transforms vectors from world space to local space of this
312
+ * node's parent.
313
+ */
314
+ worldToParent(): DOMMatrix;
315
+ /**
316
+ * Get the parent-to-world matrix for this node.
317
+ *
318
+ * @remarks
319
+ * This matrix transforms vectors from local space of this node's parent to
320
+ * world space.
321
+ */
322
+ parentToWorld(): DOMMatrix;
323
+ /**
324
+ * Get the local-to-parent matrix for this node.
325
+ *
326
+ * @remarks
327
+ * This matrix transforms vectors from local space of this node to local space
328
+ * of this node's parent.
329
+ */
330
+ localToParent(): DOMMatrix;
331
+ /**
332
+ * A matrix mapping composite space to world space.
333
+ *
334
+ * @remarks
335
+ * Certain effects such as blur and shadows ignore the current transformation.
336
+ * This matrix can be used to transform their parameters so that the effect
337
+ * appears relative to the closest composite root.
338
+ */
339
+ compositeToWorld(): DOMMatrix;
340
+ protected compositeRoot(): Node | null;
341
+ compositeToLocal(): DOMMatrix;
342
+ view(): View2D;
343
+ /**
344
+ * Add the given node(s) as the children of this node.
345
+ *
346
+ * @remarks
347
+ * The nodes will be appended at the end of the children list.
348
+ *
349
+ * @example
350
+ * ```tsx
351
+ * const node = <Layout />;
352
+ * node.add(<Rect />);
353
+ * node.add(<Circle />);
354
+ * ```
355
+ * Result:
356
+ * ```mermaid
357
+ * graph TD;
358
+ * layout([Layout])
359
+ * circle([Circle])
360
+ * rect([Rect])
361
+ * layout-->rect;
362
+ * layout-->circle;
363
+ * ```
364
+ *
365
+ * @param node - A node or an array of nodes to append.
366
+ */
367
+ add(node: ComponentChildren): this;
368
+ /**
369
+ * Insert the given node(s) at the specified index in the children list.
370
+ *
371
+ * @example
372
+ * ```tsx
373
+ * const node = (
374
+ * <Layout>
375
+ * <Rect />
376
+ * <Circle />
377
+ * </Layout>
378
+ * );
379
+ *
380
+ * node.insert(<Txt />, 1);
381
+ * ```
382
+ *
383
+ * Result:
384
+ * ```mermaid
385
+ * graph TD;
386
+ * layout([Layout])
387
+ * circle([Circle])
388
+ * text([Text])
389
+ * rect([Rect])
390
+ * layout-->rect;
391
+ * layout-->text;
392
+ * layout-->circle;
393
+ * ```
394
+ *
395
+ * @param node - A node or an array of nodes to insert.
396
+ * @param index - An index at which to insert the node(s).
397
+ */
398
+ insert(node: ComponentChildren, index?: number): this;
399
+ /**
400
+ * Remove this node from the tree.
401
+ */
402
+ remove(): this;
403
+ /**
404
+ * Rearrange this node in relation to its siblings.
405
+ *
406
+ * @remarks
407
+ * Children are rendered starting from the beginning of the children list.
408
+ * We can change the rendering order by rearranging said list.
409
+ *
410
+ * A positive `by` arguments move the node up (it will be rendered on top of
411
+ * the elements it has passed). Negative values move it down.
412
+ *
413
+ * @param by - Number of places by which the node should be moved.
414
+ */
415
+ move(by?: number): this;
416
+ /**
417
+ * Move the node up in relation to its siblings.
418
+ *
419
+ * @remarks
420
+ * The node will exchange places with the sibling right above it (if any) and
421
+ * from then on will be rendered on top of it.
422
+ */
423
+ moveUp(): this;
424
+ /**
425
+ * Move the node down in relation to its siblings.
426
+ *
427
+ * @remarks
428
+ * The node will exchange places with the sibling right below it (if any) and
429
+ * from then on will be rendered under it.
430
+ */
431
+ moveDown(): this;
432
+ /**
433
+ * Move the node to the top in relation to its siblings.
434
+ *
435
+ * @remarks
436
+ * The node will be placed at the end of the children list and from then on
437
+ * will be rendered on top of all of its siblings.
438
+ */
439
+ moveToTop(): this;
440
+ /**
441
+ * Move the node to the bottom in relation to its siblings.
442
+ *
443
+ * @remarks
444
+ * The node will be placed at the beginning of the children list and from then
445
+ * on will be rendered below all of its siblings.
446
+ */
447
+ moveToBottom(): this;
448
+ /**
449
+ * Move the node to the provided position relative to its siblings.
450
+ *
451
+ * @remarks
452
+ * If the node is getting moved to a lower position, it will be placed below
453
+ * the sibling that's currently at the provided index (if any).
454
+ * If the node is getting moved to a higher position, it will be placed above
455
+ * the sibling that's currently at the provided index (if any).
456
+ *
457
+ * @param index - The index to move the node to.
458
+ */
459
+ moveTo(index: number): this;
460
+ /**
461
+ * Move the node below the provided node in the parent's layout.
462
+ *
463
+ * @remarks
464
+ * The node will be moved below the provided node and from then on will be
465
+ * rendered below it. By default, if the node is already positioned lower than
466
+ * the sibling node, it will not get moved.
467
+ *
468
+ * @param node - The sibling node below which to move.
469
+ * @param directlyBelow - Whether the node should be positioned directly below
470
+ * the sibling. When true, will move the node even if
471
+ * it is already positioned below the sibling.
472
+ */
473
+ moveBelow(node: Node, directlyBelow?: boolean): this;
474
+ /**
475
+ * Move the node above the provided node in the parent's layout.
476
+ *
477
+ * @remarks
478
+ * The node will be moved above the provided node and from then on will be
479
+ * rendered on top of it. By default, if the node is already positioned
480
+ * higher than the sibling node, it will not get moved.
481
+ *
482
+ * @param node - The sibling node below which to move.
483
+ * @param directlyAbove - Whether the node should be positioned directly above the
484
+ * sibling. When true, will move the node even if it is
485
+ * already positioned above the sibling.
486
+ */
487
+ moveAbove(node: Node, directlyAbove?: boolean): this;
488
+ /**
489
+ * Change the parent of this node while keeping the absolute transform.
490
+ *
491
+ * @remarks
492
+ * After performing this operation, the node will stay in the same place
493
+ * visually, but its parent will be changed.
494
+ *
495
+ * @param newParent - The new parent of this node.
496
+ */
497
+ reparent(newParent: Node): this;
498
+ /**
499
+ * Remove all children of this node.
500
+ */
501
+ removeChildren(): this;
502
+ /**
503
+ * Get the current children of this node.
504
+ *
505
+ * @remarks
506
+ * Unlike {@link children}, this method does not have any side effects.
507
+ * It does not register the `children` signal as a dependency, and it does not
508
+ * spawn any children. It can be used to safely retrieve the current state of
509
+ * the scene graph for debugging purposes.
510
+ */
511
+ peekChildren(): readonly Node[];
512
+ /**
513
+ * Find all descendants of this node that match the given predicate.
514
+ *
515
+ * @param predicate - A function that returns true if the node matches.
516
+ */
517
+ findAll<T extends Node>(predicate: (node: any) => node is T): T[];
518
+ /**
519
+ * Find all descendants of this node that match the given predicate.
520
+ *
521
+ * @param predicate - A function that returns true if the node matches.
522
+ */
523
+ findAll<T extends Node = Node>(predicate: (node: any) => boolean): T[];
524
+ /**
525
+ * Find the first descendant of this node that matches the given predicate.
526
+ *
527
+ * @param predicate - A function that returns true if the node matches.
528
+ */
529
+ findFirst<T extends Node>(predicate: (node: Node) => node is T): T | null;
530
+ /**
531
+ * Find the first descendant of this node that matches the given predicate.
532
+ *
533
+ * @param predicate - A function that returns true if the node matches.
534
+ */
535
+ findFirst<T extends Node = Node>(predicate: (node: Node) => boolean): T | null;
536
+ /**
537
+ * Find the last descendant of this node that matches the given predicate.
538
+ *
539
+ * @param predicate - A function that returns true if the node matches.
540
+ */
541
+ findLast<T extends Node>(predicate: (node: Node) => node is T): T | null;
542
+ /**
543
+ * Find the last descendant of this node that matches the given predicate.
544
+ *
545
+ * @param predicate - A function that returns true if the node matches.
546
+ */
547
+ findLast<T extends Node = Node>(predicate: (node: Node) => boolean): T | null;
548
+ /**
549
+ * Find the closest ancestor of this node that matches the given predicate.
550
+ *
551
+ * @param predicate - A function that returns true if the node matches.
552
+ */
553
+ findAncestor<T extends Node>(predicate: (node: Node) => node is T): T | null;
554
+ /**
555
+ * Find the closest ancestor of this node that matches the given predicate.
556
+ *
557
+ * @param predicate - A function that returns true if the node matches.
558
+ */
559
+ findAncestor<T extends Node = Node>(predicate: (node: Node) => boolean): T | null;
560
+ /**
561
+ * Get the nth children cast to the specified type.
562
+ *
563
+ * @param index - The index of the child to retrieve.
564
+ */
565
+ childAs<T extends Node = Node>(index: number): T | null;
566
+ /**
567
+ * Get the children array cast to the specified type.
568
+ */
569
+ childrenAs<T extends Node = Node>(): T[];
570
+ /**
571
+ * Get the parent cast to the specified type.
572
+ */
573
+ parentAs<T extends Node = Node>(): T | null;
574
+ /**
575
+ * Prepare this node to be disposed of.
576
+ *
577
+ * @remarks
578
+ * This method is called automatically when a scene is refreshed. It will
579
+ * be called even if the node is not currently attached to the tree.
580
+ *
581
+ * The goal of this method is to clean any external references to allow the
582
+ * node to be garbage collected.
583
+ */
584
+ dispose(): void;
585
+ /**
586
+ * Create a copy of this node.
587
+ *
588
+ * @param customProps - Properties to override.
589
+ */
590
+ clone(customProps?: NodeState): this;
591
+ /**
592
+ * Create a copy of this node.
593
+ *
594
+ * @remarks
595
+ * Unlike {@link clone}, a snapshot clone calculates any reactive properties
596
+ * at the moment of cloning and passes the raw values to the copy.
597
+ *
598
+ * @param customProps - Properties to override.
599
+ */
600
+ snapshotClone(customProps?: NodeState): this;
601
+ /**
602
+ * Create a reactive copy of this node.
603
+ *
604
+ * @remarks
605
+ * A reactive copy has all its properties dynamically updated to match the
606
+ * source node.
607
+ *
608
+ * @param customProps - Properties to override.
609
+ */
610
+ reactiveClone(customProps?: NodeState): this;
611
+ /**
612
+ * Create an instance of this node's class.
613
+ *
614
+ * @param props - Properties to pass to the constructor.
615
+ */
616
+ instantiate(props?: NodeProps): this;
617
+ /**
618
+ * Set the children without parsing them.
619
+ *
620
+ * @remarks
621
+ * This method assumes that the caller took care of parsing the children and
622
+ * updating the hierarchy.
623
+ *
624
+ * @param value - The children to set.
625
+ */
626
+ protected setParsedChildren(value: Node[]): void;
627
+ protected spawnChildren(reactive: boolean, children: ComponentChildren): void;
628
+ /**
629
+ * Parse any `ComponentChildren` into an array of nodes.
630
+ *
631
+ * @param children - The children to parse.
632
+ */
633
+ protected parseChildren(children: ComponentChildren): Node[];
634
+ /**
635
+ * Remove the given child.
636
+ */
637
+ protected removeChild(child: Node): void;
638
+ /**
639
+ * Whether this node should be cached or not.
640
+ */
641
+ protected requiresCache(): boolean;
642
+ protected cacheCanvas(): CanvasRenderingContext2D;
643
+ /**
644
+ * Get a cache canvas with the contents of this node rendered onto it.
645
+ */
646
+ protected cachedCanvas(): CanvasRenderingContext2D;
647
+ /**
648
+ * Get a bounding box for the contents rendered by this node.
649
+ *
650
+ * @remarks
651
+ * The returned bounding box should be in local space.
652
+ */
653
+ protected getCacheBBox(): BBox;
654
+ /**
655
+ * Get a bounding box for the contents rendered by this node as well
656
+ * as its children.
657
+ */
658
+ cacheBBox(): BBox;
659
+ /**
660
+ * Get a bounding box for the contents rendered by this node (including
661
+ * effects applied after caching).
662
+ *
663
+ * @remarks
664
+ * The returned bounding box should be in local space.
665
+ */
666
+ protected fullCacheBBox(): BBox;
667
+ /**
668
+ * Get a bounding box in world space for the contents rendered by this node as
669
+ * well as its children.
670
+ *
671
+ * @remarks
672
+ * This is the same the bounding box returned by {@link cacheBBox} only
673
+ * transformed to world space.
674
+ */
675
+ protected worldSpaceCacheBBox(): BBox;
676
+ protected parentWorldSpaceCacheBBox(): BBox;
677
+ /**
678
+ * Prepare the given context for drawing a cached node onto it.
679
+ *
680
+ * @remarks
681
+ * This method is called before the contents of the cache canvas are drawn
682
+ * on the screen. It can be used to apply effects to the entire node together
683
+ * with its children, instead of applying them individually.
684
+ * Effects such as transparency, shadows, and filters use this technique.
685
+ *
686
+ * Whether the node is cached is decided by the {@link requiresCache} method.
687
+ *
688
+ * @param context - The context using which the cache will be drawn.
689
+ */
690
+ protected setupDrawFromCache(context: CanvasRenderingContext2D): void;
691
+ protected renderFromSource(context: CanvasRenderingContext2D, source: CanvasImageSource, x: number, y: number): void;
692
+ private shaderCanvas;
693
+ /**
694
+ * Render this node onto the given canvas.
695
+ *
696
+ * @param context - The context to draw with.
697
+ */
698
+ render(context: CanvasRenderingContext2D): void;
699
+ /**
700
+ * Draw this node onto the canvas.
701
+ *
702
+ * @remarks
703
+ * This method is used when drawing directly onto the screen as well as onto
704
+ * the cache canvas.
705
+ * It assumes that the context have already been transformed to local space.
706
+ *
707
+ * @param context - The context to draw with.
708
+ */
709
+ protected draw(context: CanvasRenderingContext2D): void;
710
+ protected drawChildren(context: CanvasRenderingContext2D): void;
711
+ /**
712
+ * Draw an overlay for this node.
713
+ *
714
+ * @remarks
715
+ * The overlay for the currently inspected node is displayed on top of the
716
+ * canvas.
717
+ *
718
+ * The provided context is in screen space. The local-to-screen matrix can be
719
+ * used to transform all shapes that need to be displayed.
720
+ * This approach allows to keep the line widths and gizmo sizes consistent,
721
+ * no matter how zoomed-in the view is.
722
+ *
723
+ * @param context - The context to draw with.
724
+ * @param matrix - A local-to-screen matrix.
725
+ */
726
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
727
+ protected transformContext(context: CanvasRenderingContext2D): void;
728
+ /**
729
+ * Try to find a node intersecting the given position.
730
+ *
731
+ * @param position - The searched position.
732
+ */
733
+ hit(position: Vector2): Node | null;
734
+ /**
735
+ * Collect all asynchronous resources used by this node.
736
+ */
737
+ protected collectAsyncResources(): void;
738
+ /**
739
+ * Wait for any asynchronous resources that this node or its children have.
740
+ *
741
+ * @remarks
742
+ * Certain resources like images are always loaded asynchronously.
743
+ * Awaiting this method makes sure that all such resources are done loading
744
+ * before continuing the animation.
745
+ */
746
+ toPromise(): Promise<this>;
747
+ /**
748
+ * Return a snapshot of the node's current signal values.
749
+ *
750
+ * @remarks
751
+ * This method will calculate the values of any reactive properties of the
752
+ * node at the time the method is called.
753
+ */
754
+ getState(): NodeState;
755
+ /**
756
+ * Apply the given state to the node, setting all matching signal values to
757
+ * the provided values.
758
+ *
759
+ * @param state - The state to apply to the node.
760
+ */
761
+ applyState(state: NodeState): void;
762
+ /**
763
+ * Smoothly transition between the current state of the node and the given
764
+ * state.
765
+ *
766
+ * @param state - The state to transition to.
767
+ * @param duration - The duration of the transition.
768
+ * @param timing - The timing function to use for the transition.
769
+ */
770
+ applyState(state: NodeState, duration: number, timing?: TimingFunction): ThreadGenerator;
771
+ /**
772
+ * Push a snapshot of the node's current state onto the node's state stack.
773
+ *
774
+ * @remarks
775
+ * This method can be used together with the {@link restore} method to save a
776
+ * node's current state and later restore it. It is possible to store more
777
+ * than one state by calling `save` method multiple times.
778
+ */
779
+ save(): void;
780
+ /**
781
+ * Restore the node to its last saved state.
782
+ *
783
+ * @remarks
784
+ * This method can be used together with the {@link save} method to restore a
785
+ * node to a previously saved state. Restoring a node to a previous state
786
+ * removes that state from the state stack.
787
+ *
788
+ * @example
789
+ * ```tsx
790
+ * const node = <Circle width={100} height={100} fill={"lightseagreen"} />
791
+ *
792
+ * view.add(node);
793
+ *
794
+ * // Save the node's current state
795
+ * node.save();
796
+ *
797
+ * // Modify some of the node's properties
798
+ * yield* node.scale(2, 1);
799
+ * yield* node.fill('hotpink', 1);
800
+ *
801
+ * // Restore the node to its saved state
802
+ * node.restore();
803
+ * ```
804
+ */
805
+ restore(): void;
806
+ /**
807
+ * Tween the node to its last saved state.
808
+ *
809
+ * @remarks
810
+ * This method can be used together with the {@link save} method to restore a
811
+ * node to a previously saved state. Restoring a node to a previous state
812
+ * removes that state from the state stack.
813
+ *
814
+ * @example
815
+ * ```tsx
816
+ * const node = <Circle width={100} height={100} fill={"lightseagreen"} />
817
+ *
818
+ * view.add(node);
819
+ *
820
+ * // Save the node's current state
821
+ * node.save();
822
+ *
823
+ * // Modify some of the node's properties
824
+ * yield* node.scale(2, 1);
825
+ * yield* node.fill('hotpink', 1);
826
+ *
827
+ * // Tween the node to its saved state over 1 second
828
+ * yield* node.restore(1);
829
+ * ```
830
+ *
831
+ * @param duration - The duration of the transition.
832
+ * @param timing - The timing function to use for the transition.
833
+ */
834
+ restore(duration: number, timing?: TimingFunction): ThreadGenerator;
835
+ [Symbol.iterator](): Generator<{
836
+ meta: import("../decorators").PropertyMetadata<any>;
837
+ signal: SimpleSignal<any>;
838
+ key: string;
839
+ }, void, unknown>;
840
+ private signalByKey;
841
+ private reversedChildren;
842
+ }
843
+ //# sourceMappingURL=Node.d.ts.map