@twick/2d 0.14.21 → 0.15.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 (493) hide show
  1. package/dist/index.cjs +10806 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +4657 -0
  4. package/dist/index.d.ts +4657 -0
  5. package/dist/index.js +10768 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/jsx-runtime.d.mts +1 -0
  8. package/dist/jsx-runtime.d.ts +1 -0
  9. package/editor/index.css +24 -22
  10. package/editor/index.css.map +1 -0
  11. package/editor/index.d.ts +5 -0
  12. package/editor/index.js +472 -258
  13. package/editor/index.js.map +1 -1
  14. package/package.json +54 -27
  15. package/tsconfig.project.json +3 -2
  16. package/lib/code/CodeCursor.d.ts +0 -83
  17. package/lib/code/CodeCursor.d.ts.map +0 -1
  18. package/lib/code/CodeCursor.js +0 -306
  19. package/lib/code/CodeDiffer.d.ts +0 -28
  20. package/lib/code/CodeDiffer.d.ts.map +0 -1
  21. package/lib/code/CodeDiffer.js +0 -51
  22. package/lib/code/CodeFragment.d.ts +0 -42
  23. package/lib/code/CodeFragment.d.ts.map +0 -1
  24. package/lib/code/CodeFragment.js +0 -72
  25. package/lib/code/CodeHighlighter.d.ts +0 -71
  26. package/lib/code/CodeHighlighter.d.ts.map +0 -1
  27. package/lib/code/CodeHighlighter.js +0 -2
  28. package/lib/code/CodeMetrics.d.ts +0 -11
  29. package/lib/code/CodeMetrics.d.ts.map +0 -1
  30. package/lib/code/CodeMetrics.js +0 -29
  31. package/lib/code/CodeRange.d.ts +0 -41
  32. package/lib/code/CodeRange.d.ts.map +0 -1
  33. package/lib/code/CodeRange.js +0 -179
  34. package/lib/code/CodeScope.d.ts +0 -16
  35. package/lib/code/CodeScope.d.ts.map +0 -1
  36. package/lib/code/CodeScope.js +0 -72
  37. package/lib/code/CodeSelection.d.ts +0 -6
  38. package/lib/code/CodeSelection.d.ts.map +0 -1
  39. package/lib/code/CodeSelection.js +0 -13
  40. package/lib/code/CodeSignal.d.ts +0 -60
  41. package/lib/code/CodeSignal.d.ts.map +0 -1
  42. package/lib/code/CodeSignal.js +0 -194
  43. package/lib/code/CodeTokenizer.d.ts +0 -8
  44. package/lib/code/CodeTokenizer.d.ts.map +0 -1
  45. package/lib/code/CodeTokenizer.js +0 -50
  46. package/lib/code/DefaultHighlightStyle.d.ts +0 -3
  47. package/lib/code/DefaultHighlightStyle.d.ts.map +0 -1
  48. package/lib/code/DefaultHighlightStyle.js +0 -98
  49. package/lib/code/LezerHighlighter.d.ts +0 -22
  50. package/lib/code/LezerHighlighter.d.ts.map +0 -1
  51. package/lib/code/LezerHighlighter.js +0 -89
  52. package/lib/code/diff.d.ts +0 -31
  53. package/lib/code/diff.d.ts.map +0 -1
  54. package/lib/code/diff.js +0 -236
  55. package/lib/code/extractRange.d.ts +0 -17
  56. package/lib/code/extractRange.d.ts.map +0 -1
  57. package/lib/code/extractRange.js +0 -102
  58. package/lib/code/index.d.ts +0 -14
  59. package/lib/code/index.d.ts.map +0 -1
  60. package/lib/code/index.js +0 -14
  61. package/lib/components/Audio.d.ts +0 -14
  62. package/lib/components/Audio.d.ts.map +0 -1
  63. package/lib/components/Audio.js +0 -148
  64. package/lib/components/Bezier.d.ts +0 -23
  65. package/lib/components/Bezier.d.ts.map +0 -1
  66. package/lib/components/Bezier.js +0 -81
  67. package/lib/components/Circle.d.ts +0 -193
  68. package/lib/components/Circle.d.ts.map +0 -1
  69. package/lib/components/Circle.js +0 -178
  70. package/lib/components/Code.d.ts +0 -231
  71. package/lib/components/Code.d.ts.map +0 -1
  72. package/lib/components/Code.js +0 -325
  73. package/lib/components/CodeBlock.d.ts +0 -133
  74. package/lib/components/CodeBlock.d.ts.map +0 -1
  75. package/lib/components/CodeBlock.js +0 -461
  76. package/lib/components/CubicBezier.d.ts +0 -70
  77. package/lib/components/CubicBezier.d.ts.map +0 -1
  78. package/lib/components/CubicBezier.js +0 -81
  79. package/lib/components/Curve.d.ts +0 -204
  80. package/lib/components/Curve.d.ts.map +0 -1
  81. package/lib/components/Curve.js +0 -284
  82. package/lib/components/Grid.d.ts +0 -76
  83. package/lib/components/Grid.d.ts.map +0 -1
  84. package/lib/components/Grid.js +0 -91
  85. package/lib/components/Icon.d.ts +0 -59
  86. package/lib/components/Icon.d.ts.map +0 -1
  87. package/lib/components/Icon.js +0 -58
  88. package/lib/components/Img.d.ts +0 -118
  89. package/lib/components/Img.d.ts.map +0 -1
  90. package/lib/components/Img.js +0 -245
  91. package/lib/components/Knot.d.ts +0 -90
  92. package/lib/components/Knot.d.ts.map +0 -1
  93. package/lib/components/Knot.js +0 -68
  94. package/lib/components/Latex.d.ts +0 -39
  95. package/lib/components/Latex.d.ts.map +0 -1
  96. package/lib/components/Latex.js +0 -101
  97. package/lib/components/Layout.d.ts +0 -419
  98. package/lib/components/Layout.d.ts.map +0 -1
  99. package/lib/components/Layout.js +0 -706
  100. package/lib/components/Line.d.ts +0 -160
  101. package/lib/components/Line.d.ts.map +0 -1
  102. package/lib/components/Line.js +0 -346
  103. package/lib/components/Media.d.ts +0 -70
  104. package/lib/components/Media.d.ts.map +0 -1
  105. package/lib/components/Media.js +0 -493
  106. package/lib/components/Node.d.ts +0 -836
  107. package/lib/components/Node.d.ts.map +0 -1
  108. package/lib/components/Node.js +0 -1317
  109. package/lib/components/Path.d.ts +0 -20
  110. package/lib/components/Path.d.ts.map +0 -1
  111. package/lib/components/Path.js +0 -97
  112. package/lib/components/Polygon.d.ts +0 -113
  113. package/lib/components/Polygon.d.ts.map +0 -1
  114. package/lib/components/Polygon.js +0 -123
  115. package/lib/components/QuadBezier.d.ts +0 -62
  116. package/lib/components/QuadBezier.d.ts.map +0 -1
  117. package/lib/components/QuadBezier.js +0 -76
  118. package/lib/components/Ray.d.ts +0 -62
  119. package/lib/components/Ray.d.ts.map +0 -1
  120. package/lib/components/Ray.js +0 -96
  121. package/lib/components/Rect.d.ts +0 -114
  122. package/lib/components/Rect.d.ts.map +0 -1
  123. package/lib/components/Rect.js +0 -76
  124. package/lib/components/Rive.d.ts +0 -22
  125. package/lib/components/Rive.d.ts.map +0 -1
  126. package/lib/components/Rive.js +0 -117
  127. package/lib/components/SVG.d.ts +0 -178
  128. package/lib/components/SVG.d.ts.map +0 -1
  129. package/lib/components/SVG.js +0 -577
  130. package/lib/components/Shape.d.ts +0 -40
  131. package/lib/components/Shape.d.ts.map +0 -1
  132. package/lib/components/Shape.js +0 -134
  133. package/lib/components/Spline.d.ts +0 -89
  134. package/lib/components/Spline.d.ts.map +0 -1
  135. package/lib/components/Spline.js +0 -256
  136. package/lib/components/Txt.d.ts +0 -53
  137. package/lib/components/Txt.d.ts.map +0 -1
  138. package/lib/components/Txt.js +0 -173
  139. package/lib/components/TxtLeaf.d.ts +0 -21
  140. package/lib/components/TxtLeaf.d.ts.map +0 -1
  141. package/lib/components/TxtLeaf.js +0 -181
  142. package/lib/components/Video.d.ts +0 -69
  143. package/lib/components/Video.d.ts.map +0 -1
  144. package/lib/components/Video.js +0 -342
  145. package/lib/components/View2D.d.ts +0 -28
  146. package/lib/components/View2D.d.ts.map +0 -1
  147. package/lib/components/View2D.js +0 -93
  148. package/lib/components/index.d.ts +0 -29
  149. package/lib/components/index.d.ts.map +0 -1
  150. package/lib/components/index.js +0 -29
  151. package/lib/components/types.d.ts +0 -17
  152. package/lib/components/types.d.ts.map +0 -1
  153. package/lib/components/types.js +0 -2
  154. package/lib/curves/ArcSegment.d.ts +0 -26
  155. package/lib/curves/ArcSegment.d.ts.map +0 -1
  156. package/lib/curves/ArcSegment.js +0 -97
  157. package/lib/curves/CircleSegment.d.ts +0 -18
  158. package/lib/curves/CircleSegment.d.ts.map +0 -1
  159. package/lib/curves/CircleSegment.js +0 -52
  160. package/lib/curves/CubicBezierSegment.d.ts +0 -18
  161. package/lib/curves/CubicBezierSegment.d.ts.map +0 -1
  162. package/lib/curves/CubicBezierSegment.js +0 -55
  163. package/lib/curves/CurveDrawingInfo.d.ts +0 -11
  164. package/lib/curves/CurveDrawingInfo.d.ts.map +0 -1
  165. package/lib/curves/CurveDrawingInfo.js +0 -2
  166. package/lib/curves/CurvePoint.d.ts +0 -15
  167. package/lib/curves/CurvePoint.d.ts.map +0 -1
  168. package/lib/curves/CurvePoint.js +0 -2
  169. package/lib/curves/CurveProfile.d.ts +0 -7
  170. package/lib/curves/CurveProfile.d.ts.map +0 -1
  171. package/lib/curves/CurveProfile.js +0 -2
  172. package/lib/curves/KnotInfo.d.ts +0 -12
  173. package/lib/curves/KnotInfo.d.ts.map +0 -1
  174. package/lib/curves/KnotInfo.js +0 -2
  175. package/lib/curves/LineSegment.d.ts +0 -16
  176. package/lib/curves/LineSegment.d.ts.map +0 -1
  177. package/lib/curves/LineSegment.js +0 -45
  178. package/lib/curves/Polynomial.d.ts +0 -118
  179. package/lib/curves/Polynomial.d.ts.map +0 -1
  180. package/lib/curves/Polynomial.js +0 -259
  181. package/lib/curves/Polynomial2D.d.ts +0 -22
  182. package/lib/curves/Polynomial2D.d.ts.map +0 -1
  183. package/lib/curves/Polynomial2D.js +0 -45
  184. package/lib/curves/PolynomialSegment.d.ts +0 -39
  185. package/lib/curves/PolynomialSegment.d.ts.map +0 -1
  186. package/lib/curves/PolynomialSegment.js +0 -86
  187. package/lib/curves/QuadBezierSegment.d.ts +0 -17
  188. package/lib/curves/QuadBezierSegment.d.ts.map +0 -1
  189. package/lib/curves/QuadBezierSegment.js +0 -49
  190. package/lib/curves/Segment.d.ts +0 -9
  191. package/lib/curves/Segment.d.ts.map +0 -1
  192. package/lib/curves/Segment.js +0 -3
  193. package/lib/curves/UniformPolynomialCurveSampler.d.ts +0 -43
  194. package/lib/curves/UniformPolynomialCurveSampler.d.ts.map +0 -1
  195. package/lib/curves/UniformPolynomialCurveSampler.js +0 -73
  196. package/lib/curves/createCurveProfileLerp.d.ts +0 -32
  197. package/lib/curves/createCurveProfileLerp.d.ts.map +0 -1
  198. package/lib/curves/createCurveProfileLerp.js +0 -351
  199. package/lib/curves/getBezierSplineProfile.d.ts +0 -12
  200. package/lib/curves/getBezierSplineProfile.d.ts.map +0 -1
  201. package/lib/curves/getBezierSplineProfile.js +0 -137
  202. package/lib/curves/getCircleProfile.d.ts +0 -4
  203. package/lib/curves/getCircleProfile.d.ts.map +0 -1
  204. package/lib/curves/getCircleProfile.js +0 -44
  205. package/lib/curves/getPathProfile.d.ts +0 -3
  206. package/lib/curves/getPathProfile.d.ts.map +0 -1
  207. package/lib/curves/getPathProfile.js +0 -128
  208. package/lib/curves/getPointAtDistance.d.ts +0 -4
  209. package/lib/curves/getPointAtDistance.d.ts.map +0 -1
  210. package/lib/curves/getPointAtDistance.js +0 -15
  211. package/lib/curves/getPolylineProfile.d.ts +0 -4
  212. package/lib/curves/getPolylineProfile.d.ts.map +0 -1
  213. package/lib/curves/getPolylineProfile.js +0 -58
  214. package/lib/curves/getRectProfile.d.ts +0 -4
  215. package/lib/curves/getRectProfile.d.ts.map +0 -1
  216. package/lib/curves/getRectProfile.js +0 -57
  217. package/lib/curves/index.d.ts +0 -17
  218. package/lib/curves/index.d.ts.map +0 -1
  219. package/lib/curves/index.js +0 -17
  220. package/lib/decorators/canvasStyleSignal.d.ts +0 -5
  221. package/lib/decorators/canvasStyleSignal.d.ts.map +0 -1
  222. package/lib/decorators/canvasStyleSignal.js +0 -12
  223. package/lib/decorators/colorSignal.d.ts +0 -2
  224. package/lib/decorators/colorSignal.d.ts.map +0 -1
  225. package/lib/decorators/colorSignal.js +0 -9
  226. package/lib/decorators/compound.d.ts +0 -26
  227. package/lib/decorators/compound.d.ts.map +0 -1
  228. package/lib/decorators/compound.js +0 -49
  229. package/lib/decorators/computed.d.ts +0 -9
  230. package/lib/decorators/computed.d.ts.map +0 -1
  231. package/lib/decorators/computed.js +0 -18
  232. package/lib/decorators/defaultStyle.d.ts +0 -2
  233. package/lib/decorators/defaultStyle.d.ts.map +0 -1
  234. package/lib/decorators/defaultStyle.js +0 -14
  235. package/lib/decorators/filtersSignal.d.ts +0 -13
  236. package/lib/decorators/filtersSignal.d.ts.map +0 -1
  237. package/lib/decorators/filtersSignal.js +0 -73
  238. package/lib/decorators/index.d.ts +0 -11
  239. package/lib/decorators/index.d.ts.map +0 -1
  240. package/lib/decorators/index.js +0 -11
  241. package/lib/decorators/initializers.d.ts +0 -4
  242. package/lib/decorators/initializers.d.ts.map +0 -1
  243. package/lib/decorators/initializers.js +0 -27
  244. package/lib/decorators/nodeName.d.ts +0 -9
  245. package/lib/decorators/nodeName.d.ts.map +0 -1
  246. package/lib/decorators/nodeName.js +0 -13
  247. package/lib/decorators/signal.d.ts +0 -183
  248. package/lib/decorators/signal.d.ts.map +0 -1
  249. package/lib/decorators/signal.js +0 -285
  250. package/lib/decorators/spacingSignal.d.ts +0 -2
  251. package/lib/decorators/spacingSignal.d.ts.map +0 -1
  252. package/lib/decorators/spacingSignal.js +0 -15
  253. package/lib/decorators/vector2Signal.d.ts +0 -9
  254. package/lib/decorators/vector2Signal.d.ts.map +0 -1
  255. package/lib/decorators/vector2Signal.js +0 -15
  256. package/lib/index.d.ts +0 -9
  257. package/lib/index.d.ts.map +0 -1
  258. package/lib/index.js +0 -9
  259. package/lib/jsx-dev-runtime.d.ts +0 -3
  260. package/lib/jsx-dev-runtime.d.ts.map +0 -1
  261. package/lib/jsx-dev-runtime.js +0 -3
  262. package/lib/jsx-runtime.d.ts +0 -12
  263. package/lib/jsx-runtime.d.ts.map +0 -1
  264. package/lib/jsx-runtime.js +0 -23
  265. package/lib/partials/Filter.d.ts +0 -82
  266. package/lib/partials/Filter.d.ts.map +0 -1
  267. package/lib/partials/Filter.js +0 -135
  268. package/lib/partials/Gradient.d.ts +0 -31
  269. package/lib/partials/Gradient.d.ts.map +0 -1
  270. package/lib/partials/Gradient.js +0 -63
  271. package/lib/partials/Pattern.d.ts +0 -13
  272. package/lib/partials/Pattern.d.ts.map +0 -1
  273. package/lib/partials/Pattern.js +0 -27
  274. package/lib/partials/ShaderConfig.d.ts +0 -81
  275. package/lib/partials/ShaderConfig.d.ts.map +0 -1
  276. package/lib/partials/ShaderConfig.js +0 -25
  277. package/lib/partials/index.d.ts +0 -5
  278. package/lib/partials/index.d.ts.map +0 -1
  279. package/lib/partials/index.js +0 -5
  280. package/lib/partials/types.d.ts +0 -35
  281. package/lib/partials/types.d.ts.map +0 -1
  282. package/lib/partials/types.js +0 -2
  283. package/lib/scenes/Scene2D.d.ts +0 -29
  284. package/lib/scenes/Scene2D.d.ts.map +0 -1
  285. package/lib/scenes/Scene2D.js +0 -180
  286. package/lib/scenes/index.d.ts +0 -4
  287. package/lib/scenes/index.d.ts.map +0 -1
  288. package/lib/scenes/index.js +0 -4
  289. package/lib/scenes/makeScene2D.d.ts +0 -5
  290. package/lib/scenes/makeScene2D.d.ts.map +0 -1
  291. package/lib/scenes/makeScene2D.js +0 -11
  292. package/lib/scenes/useScene2D.d.ts +0 -3
  293. package/lib/scenes/useScene2D.d.ts.map +0 -1
  294. package/lib/scenes/useScene2D.js +0 -5
  295. package/lib/tsconfig.build.tsbuildinfo +0 -1
  296. package/lib/utils/CanvasUtils.d.ts +0 -23
  297. package/lib/utils/CanvasUtils.d.ts.map +0 -1
  298. package/lib/utils/CanvasUtils.js +0 -138
  299. package/lib/utils/diff.d.ts +0 -31
  300. package/lib/utils/diff.d.ts.map +0 -1
  301. package/lib/utils/diff.js +0 -97
  302. package/lib/utils/index.d.ts +0 -3
  303. package/lib/utils/index.d.ts.map +0 -1
  304. package/lib/utils/index.js +0 -3
  305. package/lib/utils/is.d.ts +0 -8
  306. package/lib/utils/is.d.ts.map +0 -1
  307. package/lib/utils/is.js +0 -10
  308. package/lib/utils/makeSignalExtensions.d.ts +0 -4
  309. package/lib/utils/makeSignalExtensions.d.ts.map +0 -1
  310. package/lib/utils/makeSignalExtensions.js +0 -20
  311. package/lib/utils/video/ffmpeg-client.d.ts +0 -5
  312. package/lib/utils/video/ffmpeg-client.d.ts.map +0 -1
  313. package/lib/utils/video/ffmpeg-client.js +0 -32
  314. package/lib/utils/video/mp4-parser-manager.d.ts +0 -3
  315. package/lib/utils/video/mp4-parser-manager.d.ts.map +0 -1
  316. package/lib/utils/video/mp4-parser-manager.js +0 -55
  317. package/lib/utils/video/parser/index.d.ts +0 -2
  318. package/lib/utils/video/parser/index.d.ts.map +0 -1
  319. package/lib/utils/video/parser/index.js +0 -2
  320. package/lib/utils/video/parser/parser.d.ts +0 -21
  321. package/lib/utils/video/parser/parser.d.ts.map +0 -1
  322. package/lib/utils/video/parser/parser.js +0 -168
  323. package/lib/utils/video/parser/sampler.d.ts +0 -16
  324. package/lib/utils/video/parser/sampler.d.ts.map +0 -1
  325. package/lib/utils/video/parser/sampler.js +0 -56
  326. package/lib/utils/video/parser/segment.d.ts +0 -48
  327. package/lib/utils/video/parser/segment.d.ts.map +0 -1
  328. package/lib/utils/video/parser/segment.js +0 -239
  329. package/lib/utils/video/parser/sink.d.ts +0 -9
  330. package/lib/utils/video/parser/sink.d.ts.map +0 -1
  331. package/lib/utils/video/parser/sink.js +0 -22
  332. package/lib/utils/video/parser/utils.d.ts +0 -10
  333. package/lib/utils/video/parser/utils.d.ts.map +0 -1
  334. package/lib/utils/video/parser/utils.js +0 -22
  335. package/src/editor/NodeInspectorConfig.tsx +0 -76
  336. package/src/editor/PreviewOverlayConfig.tsx +0 -67
  337. package/src/editor/Provider.tsx +0 -93
  338. package/src/editor/SceneGraphTabConfig.tsx +0 -81
  339. package/src/editor/icons/CircleIcon.tsx +0 -7
  340. package/src/editor/icons/CodeBlockIcon.tsx +0 -8
  341. package/src/editor/icons/CurveIcon.tsx +0 -7
  342. package/src/editor/icons/GridIcon.tsx +0 -7
  343. package/src/editor/icons/IconMap.ts +0 -35
  344. package/src/editor/icons/ImgIcon.tsx +0 -8
  345. package/src/editor/icons/LayoutIcon.tsx +0 -9
  346. package/src/editor/icons/LineIcon.tsx +0 -7
  347. package/src/editor/icons/NodeIcon.tsx +0 -7
  348. package/src/editor/icons/RayIcon.tsx +0 -7
  349. package/src/editor/icons/RectIcon.tsx +0 -7
  350. package/src/editor/icons/ShapeIcon.tsx +0 -7
  351. package/src/editor/icons/TxtIcon.tsx +0 -8
  352. package/src/editor/icons/VideoIcon.tsx +0 -7
  353. package/src/editor/icons/View2DIcon.tsx +0 -10
  354. package/src/editor/index.css +0 -0
  355. package/src/editor/index.ts +0 -17
  356. package/src/editor/tree/DetachedRoot.tsx +0 -23
  357. package/src/editor/tree/NodeElement.tsx +0 -74
  358. package/src/editor/tree/TreeElement.tsx +0 -72
  359. package/src/editor/tree/TreeRoot.tsx +0 -10
  360. package/src/editor/tree/ViewRoot.tsx +0 -20
  361. package/src/editor/tree/index.module.scss +0 -38
  362. package/src/editor/tree/index.ts +0 -3
  363. package/src/editor/tsconfig.build.json +0 -5
  364. package/src/editor/tsconfig.json +0 -12
  365. package/src/editor/tsdoc.json +0 -4
  366. package/src/editor/vite-env.d.ts +0 -1
  367. package/src/lib/code/CodeCursor.ts +0 -445
  368. package/src/lib/code/CodeDiffer.ts +0 -78
  369. package/src/lib/code/CodeFragment.ts +0 -97
  370. package/src/lib/code/CodeHighlighter.ts +0 -75
  371. package/src/lib/code/CodeMetrics.ts +0 -47
  372. package/src/lib/code/CodeRange.test.ts +0 -74
  373. package/src/lib/code/CodeRange.ts +0 -216
  374. package/src/lib/code/CodeScope.ts +0 -101
  375. package/src/lib/code/CodeSelection.ts +0 -24
  376. package/src/lib/code/CodeSignal.ts +0 -327
  377. package/src/lib/code/CodeTokenizer.ts +0 -54
  378. package/src/lib/code/DefaultHighlightStyle.ts +0 -98
  379. package/src/lib/code/LezerHighlighter.ts +0 -113
  380. package/src/lib/code/diff.test.ts +0 -311
  381. package/src/lib/code/diff.ts +0 -319
  382. package/src/lib/code/extractRange.ts +0 -126
  383. package/src/lib/code/index.ts +0 -13
  384. package/src/lib/components/Audio.ts +0 -168
  385. package/src/lib/components/Bezier.ts +0 -105
  386. package/src/lib/components/Circle.ts +0 -266
  387. package/src/lib/components/Code.ts +0 -526
  388. package/src/lib/components/CodeBlock.ts +0 -576
  389. package/src/lib/components/CubicBezier.ts +0 -112
  390. package/src/lib/components/Curve.ts +0 -455
  391. package/src/lib/components/Grid.ts +0 -135
  392. package/src/lib/components/Icon.ts +0 -96
  393. package/src/lib/components/Img.ts +0 -319
  394. package/src/lib/components/Knot.ts +0 -157
  395. package/src/lib/components/Latex.ts +0 -122
  396. package/src/lib/components/Layout.ts +0 -1092
  397. package/src/lib/components/Line.ts +0 -429
  398. package/src/lib/components/Media.ts +0 -576
  399. package/src/lib/components/Node.ts +0 -1940
  400. package/src/lib/components/Path.ts +0 -137
  401. package/src/lib/components/Polygon.ts +0 -171
  402. package/src/lib/components/QuadBezier.ts +0 -100
  403. package/src/lib/components/Ray.ts +0 -125
  404. package/src/lib/components/Rect.ts +0 -187
  405. package/src/lib/components/Rive.ts +0 -156
  406. package/src/lib/components/SVG.ts +0 -797
  407. package/src/lib/components/Shape.ts +0 -143
  408. package/src/lib/components/Spline.ts +0 -344
  409. package/src/lib/components/Txt.test.tsx +0 -81
  410. package/src/lib/components/Txt.ts +0 -203
  411. package/src/lib/components/TxtLeaf.ts +0 -205
  412. package/src/lib/components/Video.ts +0 -461
  413. package/src/lib/components/View2D.ts +0 -98
  414. package/src/lib/components/__tests__/children.test.tsx +0 -142
  415. package/src/lib/components/__tests__/clone.test.tsx +0 -126
  416. package/src/lib/components/__tests__/generatorTest.ts +0 -28
  417. package/src/lib/components/__tests__/mockScene2D.ts +0 -45
  418. package/src/lib/components/__tests__/query.test.tsx +0 -122
  419. package/src/lib/components/__tests__/state.test.tsx +0 -60
  420. package/src/lib/components/index.ts +0 -28
  421. package/src/lib/components/types.ts +0 -35
  422. package/src/lib/curves/ArcSegment.ts +0 -159
  423. package/src/lib/curves/CircleSegment.ts +0 -77
  424. package/src/lib/curves/CubicBezierSegment.ts +0 -78
  425. package/src/lib/curves/CurveDrawingInfo.ts +0 -11
  426. package/src/lib/curves/CurvePoint.ts +0 -15
  427. package/src/lib/curves/CurveProfile.ts +0 -7
  428. package/src/lib/curves/KnotInfo.ts +0 -10
  429. package/src/lib/curves/LineSegment.ts +0 -62
  430. package/src/lib/curves/Polynomial.ts +0 -355
  431. package/src/lib/curves/Polynomial2D.ts +0 -62
  432. package/src/lib/curves/PolynomialSegment.ts +0 -124
  433. package/src/lib/curves/QuadBezierSegment.ts +0 -64
  434. package/src/lib/curves/Segment.ts +0 -17
  435. package/src/lib/curves/UniformPolynomialCurveSampler.ts +0 -94
  436. package/src/lib/curves/createCurveProfileLerp.ts +0 -471
  437. package/src/lib/curves/getBezierSplineProfile.ts +0 -223
  438. package/src/lib/curves/getCircleProfile.ts +0 -86
  439. package/src/lib/curves/getPathProfile.ts +0 -178
  440. package/src/lib/curves/getPointAtDistance.ts +0 -21
  441. package/src/lib/curves/getPolylineProfile.test.ts +0 -21
  442. package/src/lib/curves/getPolylineProfile.ts +0 -89
  443. package/src/lib/curves/getRectProfile.ts +0 -139
  444. package/src/lib/curves/index.ts +0 -16
  445. package/src/lib/decorators/canvasStyleSignal.ts +0 -16
  446. package/src/lib/decorators/colorSignal.ts +0 -9
  447. package/src/lib/decorators/compound.ts +0 -72
  448. package/src/lib/decorators/computed.ts +0 -18
  449. package/src/lib/decorators/defaultStyle.ts +0 -18
  450. package/src/lib/decorators/filtersSignal.ts +0 -136
  451. package/src/lib/decorators/index.ts +0 -10
  452. package/src/lib/decorators/initializers.ts +0 -32
  453. package/src/lib/decorators/nodeName.ts +0 -13
  454. package/src/lib/decorators/signal.test.ts +0 -90
  455. package/src/lib/decorators/signal.ts +0 -345
  456. package/src/lib/decorators/spacingSignal.ts +0 -15
  457. package/src/lib/decorators/vector2Signal.ts +0 -30
  458. package/src/lib/globals.d.ts +0 -2
  459. package/src/lib/index.ts +0 -8
  460. package/src/lib/jsx-dev-runtime.ts +0 -2
  461. package/src/lib/jsx-runtime.ts +0 -46
  462. package/src/lib/parse-svg-path.d.ts +0 -14
  463. package/src/lib/partials/Filter.ts +0 -180
  464. package/src/lib/partials/Gradient.ts +0 -102
  465. package/src/lib/partials/Pattern.ts +0 -34
  466. package/src/lib/partials/ShaderConfig.ts +0 -117
  467. package/src/lib/partials/index.ts +0 -4
  468. package/src/lib/partials/types.ts +0 -58
  469. package/src/lib/scenes/Scene2D.ts +0 -242
  470. package/src/lib/scenes/index.ts +0 -3
  471. package/src/lib/scenes/makeScene2D.ts +0 -16
  472. package/src/lib/scenes/useScene2D.ts +0 -6
  473. package/src/lib/tsconfig.build.json +0 -5
  474. package/src/lib/tsconfig.json +0 -10
  475. package/src/lib/tsdoc.json +0 -4
  476. package/src/lib/utils/CanvasUtils.ts +0 -306
  477. package/src/lib/utils/diff.test.ts +0 -453
  478. package/src/lib/utils/diff.ts +0 -148
  479. package/src/lib/utils/index.ts +0 -2
  480. package/src/lib/utils/is.ts +0 -11
  481. package/src/lib/utils/makeSignalExtensions.ts +0 -30
  482. package/src/lib/utils/video/declarations.d.ts +0 -1
  483. package/src/lib/utils/video/ffmpeg-client.ts +0 -50
  484. package/src/lib/utils/video/mp4-parser-manager.ts +0 -72
  485. package/src/lib/utils/video/parser/index.ts +0 -1
  486. package/src/lib/utils/video/parser/parser.ts +0 -257
  487. package/src/lib/utils/video/parser/sampler.ts +0 -72
  488. package/src/lib/utils/video/parser/segment.ts +0 -302
  489. package/src/lib/utils/video/parser/sink.ts +0 -29
  490. package/src/lib/utils/video/parser/utils.ts +0 -31
  491. package/src/tsconfig.base.json +0 -19
  492. package/src/tsconfig.build.json +0 -8
  493. package/src/tsconfig.json +0 -5
@@ -0,0 +1,4657 @@
1
+ import * as _twick_core from '@twick/core';
2
+ import { SimpleSignal, SignalValue, Vector2Signal, PossibleColor, PossibleVector2, Color, Vector2, Signal, SignalContext, TimingFunction, ThreadGenerator, InterpolationFunction, WebGLConvertible, PlaybackState, ReferenceReceiver, Promisable, SimpleVector2Signal, SpacingSignal, ColorSignal, PossibleSpacing, BBox, SerializedVector2, Origin, Spacing, GeneratorScene, Inspectable, FullSceneDescription, ThreadGeneratorFactory, Scene, InspectedElement, InspectedAttributes, AssetInfo, DescriptionOf } from '@twick/core';
3
+ import { HighlightStyle } from '@codemirror/language';
4
+ import { Tree, Parser } from '@lezer/common';
5
+ import { OptionList } from 'mathjax-full/js/util/Options';
6
+
7
+ /**
8
+ * All possible CSS filter names.
9
+ *
10
+ * @internal
11
+ */
12
+ type FilterName = 'invert' | 'sepia' | 'grayscale' | 'brightness' | 'contrast' | 'saturate' | 'hue' | 'blur';
13
+ /**
14
+ * Definitions of all possible CSS filters.
15
+ *
16
+ * @internal
17
+ */
18
+ declare const FILTERS: Record<string, Partial<FilterProps>>;
19
+ /**
20
+ * A unified abstraction for all CSS filters.
21
+ */
22
+ interface FilterProps {
23
+ name: string;
24
+ value: SignalValue<number>;
25
+ unit: string;
26
+ scale: number;
27
+ transform: boolean;
28
+ default: number;
29
+ }
30
+ declare class Filter {
31
+ get name(): string;
32
+ get default(): number;
33
+ readonly value: SimpleSignal<number, Filter>;
34
+ private readonly props;
35
+ constructor(props: Partial<FilterProps>);
36
+ isActive(): boolean;
37
+ serialize(matrix: DOMMatrix): string;
38
+ }
39
+ /**
40
+ * Create an {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/invert | invert} filter.
41
+ *
42
+ * @param value - The value of the filter.
43
+ */
44
+ declare function invert(value?: SignalValue<number>): Filter;
45
+ /**
46
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/sepia | sepia} filter.
47
+ *
48
+ * @param value - The value of the filter.
49
+ */
50
+ declare function sepia(value?: SignalValue<number>): Filter;
51
+ /**
52
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/grayscale | grayscale} filter.
53
+ *
54
+ * @param value - The value of the filter.
55
+ */
56
+ declare function grayscale(value?: SignalValue<number>): Filter;
57
+ /**
58
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/brightness | brightness} filter.
59
+ *
60
+ * @param value - The value of the filter.
61
+ */
62
+ declare function brightness(value?: SignalValue<number>): Filter;
63
+ /**
64
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/contrast | contrast} filter.
65
+ *
66
+ * @param value - The value of the filter.
67
+ */
68
+ declare function contrast(value?: SignalValue<number>): Filter;
69
+ /**
70
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/saturate | saturate} filter.
71
+ *
72
+ * @param value - The value of the filter.
73
+ */
74
+ declare function saturate(value?: SignalValue<number>): Filter;
75
+ /**
76
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/hue-rotate | hue} filter.
77
+ *
78
+ * @param value - The value of the filter in degrees.
79
+ */
80
+ declare function hue(value?: SignalValue<number>): Filter;
81
+ /**
82
+ * Create a {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/blur | blur} filter.
83
+ *
84
+ * @param value - The value of the filter in pixels.
85
+ */
86
+ declare function blur(value?: SignalValue<number>): Filter;
87
+
88
+ type GradientType = 'linear' | 'conic' | 'radial';
89
+ interface GradientStop {
90
+ offset: SignalValue<number>;
91
+ color: SignalValue<PossibleColor>;
92
+ }
93
+ interface GradientProps {
94
+ type?: SignalValue<GradientType>;
95
+ fromX?: SignalValue<number>;
96
+ fromY?: SignalValue<number>;
97
+ from?: SignalValue<PossibleVector2>;
98
+ toX?: SignalValue<number>;
99
+ toY?: SignalValue<number>;
100
+ to?: SignalValue<PossibleVector2>;
101
+ angle?: SignalValue<number>;
102
+ fromRadius?: SignalValue<number>;
103
+ toRadius?: SignalValue<number>;
104
+ stops?: GradientStop[];
105
+ }
106
+ declare class Gradient {
107
+ readonly type: SimpleSignal<GradientType, this>;
108
+ readonly from: Vector2Signal<this>;
109
+ readonly to: Vector2Signal<this>;
110
+ readonly angle: SimpleSignal<number, this>;
111
+ readonly fromRadius: SimpleSignal<number, this>;
112
+ readonly toRadius: SimpleSignal<number, this>;
113
+ readonly stops: SimpleSignal<GradientStop[], this>;
114
+ constructor(props: GradientProps);
115
+ canvasGradient(context: CanvasRenderingContext2D): CanvasGradient;
116
+ }
117
+
118
+ type CanvasRepetition = null | 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
119
+ interface PatternProps {
120
+ image: CanvasImageSource;
121
+ repetition?: CanvasRepetition;
122
+ }
123
+ declare class Pattern {
124
+ readonly image: SimpleSignal<CanvasImageSource, this>;
125
+ readonly repetition: SimpleSignal<CanvasRepetition, this>;
126
+ constructor(props: PatternProps);
127
+ canvasPattern(context: CanvasRenderingContext2D): CanvasPattern | null;
128
+ }
129
+
130
+ type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
131
+ type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
132
+ type FlexBasis = Length | 'content' | 'max-content' | 'min-content' | 'fit-content' | null;
133
+ type FlexContent = 'center' | 'start' | 'end' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch';
134
+ type FlexItems = 'center' | 'start' | 'end' | 'stretch' | 'baseline';
135
+ type TextWrap = boolean | 'pre' | 'balance';
136
+ type LayoutMode = boolean | null;
137
+ /**
138
+ * Represents a length used by most layout properties.
139
+ *
140
+ * @remarks
141
+ * The value can be either:
142
+ * - `number` - the desired length in pixels
143
+ * - `${number}%` - a string with the desired length in percents, for example
144
+ * `'50%'`
145
+ */
146
+ type Length = number | `${number}%`;
147
+ /**
148
+ * Represents a desired length used internally by layout Nodes.
149
+ *
150
+ * @remarks
151
+ * When the desired length is set to `null` it represents a default value for
152
+ * whatever property it describes.
153
+ */
154
+ type DesiredLength = Length | null;
155
+ /**
156
+ * Represents a length limit used by layout properties such as `max-width`.
157
+ */
158
+ type LengthLimit = Length | null | 'max-content' | 'min-content';
159
+ type PossibleCanvasStyle = null | PossibleColor | Gradient | Pattern;
160
+ type CanvasStyle = null | Color | Gradient | Pattern;
161
+
162
+ interface CurveDrawingInfo {
163
+ path: Path2D;
164
+ arrowSize: number;
165
+ endPoint: Vector2;
166
+ endTangent: Vector2;
167
+ startPoint: Vector2;
168
+ startTangent: Vector2;
169
+ startOffset: number;
170
+ }
171
+
172
+ interface CurvePoint {
173
+ position: Vector2;
174
+ /**
175
+ * @deprecated
176
+ * The tangent is currently inconsistent for different types of curves and may
177
+ * sometimes return the normal of the point, instead. This will be fixed in
178
+ * the next major version but is kept as is for now for backwards
179
+ * compatibility reasons. To always get the real tangent of the point, you can
180
+ * use `normal.flipped.perpendicular`, instead.
181
+ */
182
+ tangent: Vector2;
183
+ normal: Vector2;
184
+ }
185
+
186
+ declare abstract class Segment {
187
+ abstract readonly points: Vector2[];
188
+ abstract draw(context: CanvasRenderingContext2D | Path2D, start: number, end: number, move: boolean): [CurvePoint, CurvePoint];
189
+ abstract getPoint(distance: number): CurvePoint;
190
+ abstract get arcLength(): number;
191
+ }
192
+
193
+ interface CurveProfile {
194
+ arcLength: number;
195
+ segments: Segment[];
196
+ minSin: number;
197
+ }
198
+
199
+ type CanvasStyleSignal<T> = Signal<PossibleCanvasStyle, CanvasStyle, T>;
200
+ declare function canvasStyleSignal(): PropertyDecorator;
201
+
202
+ declare function colorSignal(): PropertyDecorator;
203
+
204
+ /**
205
+ * Create a compound property decorator.
206
+ *
207
+ * @remarks
208
+ * This decorator turns a given property into a signal consisting of one or more
209
+ * nested signals.
210
+ *
211
+ * @example
212
+ * ```ts
213
+ * class Example {
214
+ * \@compound({x: 'scaleX', y: 'scaleY'})
215
+ * public declare readonly scale: Signal<Vector2, this>;
216
+ *
217
+ * public setScale() {
218
+ * this.scale({x: 7, y: 3});
219
+ * // same as:
220
+ * this.scale.x(7).scale.y(3);
221
+ * }
222
+ * }
223
+ * ```
224
+ *
225
+ * @param entries - A record mapping the property in the compound object to the
226
+ * corresponding property on the owner node.
227
+ */
228
+ declare function compound(entries: Record<string, string>): PropertyDecorator;
229
+
230
+ /**
231
+ * Create a computed method decorator.
232
+ *
233
+ * @remarks
234
+ * This decorator turns the given method into a computed value.
235
+ * See {@link createComputed} for more information.
236
+ */
237
+ declare function computed(): MethodDecorator;
238
+
239
+ declare function defaultStyle<T>(styleName: string, parse?: (value: string) => T): PropertyDecorator;
240
+
241
+ type FiltersSignal<TOwner> = Signal<Filter[], Filter[], TOwner, FiltersSignalContext<TOwner>> & {
242
+ [K in FilterName]: SimpleSignal<number, TOwner>;
243
+ };
244
+ declare class FiltersSignalContext<TOwner> extends SignalContext<Filter[], Filter[], TOwner> {
245
+ constructor(initial: Filter[], owner: TOwner);
246
+ tweener(value: SignalValue<Filter[]>, duration: number, timingFunction: TimingFunction): ThreadGenerator;
247
+ }
248
+ declare function filtersSignal(): PropertyDecorator;
249
+
250
+ type Initializer<T> = (instance: T, context?: any) => void;
251
+ declare function addInitializer<T>(target: any, initializer: Initializer<T>): void;
252
+ declare function initialize(target: any, context?: any): void;
253
+
254
+ /**
255
+ * @internal
256
+ */
257
+ declare const NODE_NAME: unique symbol;
258
+ /**
259
+ * @internal
260
+ */
261
+ declare function nodeName(name: string): (target: any) => void;
262
+
263
+ interface PropertyMetadata<T> {
264
+ default?: T;
265
+ interpolationFunction?: InterpolationFunction<T>;
266
+ parser?: (value: any) => T;
267
+ getter?: () => T;
268
+ setter?: (value: any) => void;
269
+ tweener?: (value: T, duration: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<T>) => void;
270
+ cloneable?: boolean;
271
+ inspectable?: boolean;
272
+ compoundParent?: string;
273
+ compound?: boolean;
274
+ compoundEntries: [string, string][];
275
+ }
276
+ declare function getPropertyMeta<T>(object: any, key: string | symbol): PropertyMetadata<T> | null;
277
+ declare function getPropertyMetaOrCreate<T>(object: any, key: string | symbol): PropertyMetadata<T>;
278
+ declare function getPropertiesOf(value: any): Record<string, PropertyMetadata<any>>;
279
+ declare function initializeSignals(instance: any, props: Record<string, any>): void;
280
+ /**
281
+ * Create a signal decorator.
282
+ *
283
+ * @remarks
284
+ * This decorator turns the given property into a signal.
285
+ *
286
+ * The class using this decorator can implement the following methods:
287
+ * - `get[PropertyName]` - A property getter.
288
+ * - `get[PropertyName]` - A property setter.
289
+ * - `tween[PropertyName]` - A tween provider.
290
+ *
291
+ * @example
292
+ * ```ts
293
+ * class Example {
294
+ * \@property()
295
+ * public declare length: Signal<number, this>;
296
+ * }
297
+ * ```
298
+ */
299
+ declare function signal<T>(): PropertyDecorator;
300
+ /**
301
+ * Create an initial signal value decorator.
302
+ *
303
+ * @remarks
304
+ * This decorator specifies the initial value of a property.
305
+ *
306
+ * Must be specified before the {@link signal} decorator.
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * class Example {
311
+ * \@initial(1)
312
+ * \@property()
313
+ * public declare length: Signal<number, this>;
314
+ * }
315
+ * ```
316
+ *
317
+ * @param value - The initial value of the property.
318
+ */
319
+ declare function initial<T>(value: T): PropertyDecorator;
320
+ /**
321
+ * Create a signal interpolation function decorator.
322
+ *
323
+ * @remarks
324
+ * This decorator specifies the interpolation function of a property.
325
+ * The interpolation function is used when tweening between different values.
326
+ *
327
+ * Must be specified before the {@link signal} decorator.
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * class Example {
332
+ * \@interpolation(textLerp)
333
+ * \@property()
334
+ * public declare text: Signal<string, this>;
335
+ * }
336
+ * ```
337
+ *
338
+ * @param value - The interpolation function for the property.
339
+ */
340
+ declare function interpolation<T>(value: InterpolationFunction<T>): PropertyDecorator;
341
+ /**
342
+ * Create a signal parser decorator.
343
+ *
344
+ * @remarks
345
+ * This decorator specifies the parser of a property.
346
+ * Instead of returning the raw value, its passed as the first parameter to the
347
+ * parser and the resulting value is returned.
348
+ *
349
+ * If the wrapper class has a method called `lerp` it will be set as the
350
+ * default interpolation function for the property.
351
+ *
352
+ * Must be specified before the {@link signal} decorator.
353
+ *
354
+ * @example
355
+ * ```ts
356
+ * class Example {
357
+ * \@wrapper(Vector2)
358
+ * \@property()
359
+ * public declare offset: Signal<Vector2, this>;
360
+ * }
361
+ * ```
362
+ *
363
+ * @param value - The wrapper class for the property.
364
+ */
365
+ declare function parser<T>(value: (value: any) => T): PropertyDecorator;
366
+ /**
367
+ * Create a signal wrapper decorator.
368
+ *
369
+ * @remarks
370
+ * This is a shortcut decorator for setting both the {@link parser} and
371
+ * {@link interpolation}.
372
+ *
373
+ * The interpolation function will be set only if the wrapper class has a method
374
+ * called `lerp`, which will be used as said function.
375
+ *
376
+ * Must be specified before the {@link signal} decorator.
377
+ *
378
+ * @example
379
+ * ```ts
380
+ * class Example {
381
+ * \@wrapper(Vector2)
382
+ * \@property()
383
+ * public declare offset: Signal<Vector2, this>;
384
+ *
385
+ * // same as:
386
+ * \@parser(value => new Vector2(value))
387
+ * \@interpolation(Vector2.lerp)
388
+ * \@property()
389
+ * public declare offset: Signal<Vector2, this>;
390
+ * }
391
+ * ```
392
+ *
393
+ * @param value - The wrapper class for the property.
394
+ */
395
+ declare function wrapper<T>(value: (new (value: any) => T) & {
396
+ lerp?: InterpolationFunction<T>;
397
+ }): PropertyDecorator;
398
+ /**
399
+ * Create a cloneable property decorator.
400
+ *
401
+ * @remarks
402
+ * This decorator specifies whether the property should be copied over when
403
+ * cloning the node.
404
+ *
405
+ * By default, any property is cloneable.
406
+ *
407
+ * Must be specified before the {@link signal} decorator.
408
+ *
409
+ * @example
410
+ * ```ts
411
+ * class Example {
412
+ * \@clone(false)
413
+ * \@property()
414
+ * public declare length: Signal<number, this>;
415
+ * }
416
+ * ```
417
+ *
418
+ * @param value - Whether the property should be cloneable.
419
+ */
420
+ declare function cloneable<T>(value?: boolean): PropertyDecorator;
421
+ /**
422
+ * Create an inspectable property decorator.
423
+ *
424
+ * @remarks
425
+ * This decorator specifies whether the property should be visible in the
426
+ * inspector.
427
+ *
428
+ * By default, any property is inspectable.
429
+ *
430
+ * Must be specified before the {@link signal} decorator.
431
+ *
432
+ * @example
433
+ * ```ts
434
+ * class Example {
435
+ * \@inspectable(false)
436
+ * \@property()
437
+ * public declare hiddenLength: Signal<number, this>;
438
+ * }
439
+ * ```
440
+ *
441
+ * @param value - Whether the property should be inspectable.
442
+ */
443
+ declare function inspectable<T>(value?: boolean): PropertyDecorator;
444
+
445
+ type Vector2LengthSignal<TOwner> = Signal<PossibleVector2<Length>, Vector2, TOwner> & {
446
+ x: Signal<Length, number, TOwner>;
447
+ y: Signal<Length, number, TOwner>;
448
+ };
449
+ declare function vector2Signal(prefix?: string | Record<string, string>): PropertyDecorator;
450
+
451
+ /**
452
+ * Describes a shader program used to apply effects to nodes.
453
+ *
454
+ * @experimental
455
+ */
456
+ interface ShaderConfig {
457
+ /**
458
+ * The source code of the fragment shader.
459
+ *
460
+ * @example
461
+ * ```glsl
462
+ * #version 300 es
463
+ * precision highp float;
464
+ *
465
+ * #include "@twick/core/shaders/common.glsl"
466
+ *
467
+ * void main() {
468
+ * out_color = texture(core_source_tx, source_uv);
469
+ * }
470
+ * ```
471
+ */
472
+ fragment: string;
473
+ /**
474
+ * Custom uniforms to be passed to the shader.
475
+ *
476
+ * @remarks
477
+ * The keys of this object will be used as the uniform names.
478
+ * The values can be either a number or an array of numbers.
479
+ * The following table shows how the values will be mapped to GLSL types.
480
+ *
481
+ * | TypeScript | GLSL |
482
+ * | ---------------------------------- | ------- |
483
+ * | `number` | `float` |
484
+ * | `[number, number]` | `vec2` |
485
+ * | `[number, number, number]` | `vec3` |
486
+ * | `[number, number, number, number]` | `vec4` |
487
+ *
488
+ * @example
489
+ * ```ts
490
+ * const shader = {
491
+ * // ...
492
+ * uniforms: {
493
+ * my_value: () => 1,
494
+ * my_vector: [1, 2, 3],
495
+ * },
496
+ * };
497
+ * ```
498
+ *
499
+ * ```glsl
500
+ * uniform float my_value;
501
+ * uniform vec3 my_vector;
502
+ * ```
503
+ */
504
+ uniforms?: Record<string, SignalValue<number | number[] | WebGLConvertible>>;
505
+ /**
506
+ * A custom hook run before the shader is used.
507
+ *
508
+ * @remarks
509
+ * Gives you low-level access to the WebGL context and the shader program.
510
+ *
511
+ * @param gl - WebGL context.
512
+ * @param program - The shader program.
513
+ */
514
+ setup?: (gl: WebGL2RenderingContext, program: WebGLProgram) => void;
515
+ /**
516
+ * A custom hook run after the shader is used.
517
+ *
518
+ * @remarks
519
+ * Gives you low-level access to the WebGL context and the shader program.
520
+ * Can be used to clean up resources created in the {@link setup} hook.
521
+ *
522
+ * @param gl - WebGL context.
523
+ * @param program - The shader program.
524
+ */
525
+ teardown?: (gl: WebGL2RenderingContext, program: WebGLProgram) => void;
526
+ }
527
+ type PossibleShaderConfig = (ShaderConfig | string)[] | ShaderConfig | string | null;
528
+
529
+ interface View2DProps extends RectProps {
530
+ assetHash: string;
531
+ }
532
+ declare class View2D extends Rect {
533
+ static shadowRoot: ShadowRoot;
534
+ readonly playbackState: SimpleSignal<PlaybackState, this>;
535
+ readonly globalTime: SimpleSignal<number, this>;
536
+ readonly fps: SimpleSignal<number, this>;
537
+ readonly assetHash: SimpleSignal<string, this>;
538
+ constructor(props: View2DProps);
539
+ dispose(): void;
540
+ render(context: CanvasRenderingContext2D): Promise<void>;
541
+ /**
542
+ * Find a node by its key.
543
+ *
544
+ * @param key - The key of the node.
545
+ */
546
+ findKey<T extends Node = Node>(key: string): T | null;
547
+ protected requestLayoutUpdate(): void;
548
+ protected requestFontUpdate(): void;
549
+ view(): View2D;
550
+ }
551
+
552
+ type ComponentChild = Node | object | string | number | bigint | boolean | null | undefined;
553
+ type ComponentChildren = ComponentChild | ComponentChild[];
554
+ type NodeChildren = Node | Node[];
555
+ type PropsOf<T> = T extends NodeConstructor<infer P> ? P : T extends FunctionComponent<infer P> ? P : never;
556
+ interface JSXProps {
557
+ children?: ComponentChildren;
558
+ ref?: ReferenceReceiver<Node>;
559
+ }
560
+ interface FunctionComponent<T = any> {
561
+ (props: T): Node | null;
562
+ }
563
+ interface NodeConstructor<TProps = any, TNode = Node> {
564
+ new (props: TProps): TNode;
565
+ }
566
+
567
+ type NodeState = NodeProps & Record<string, any>;
568
+ interface NodeProps {
569
+ ref?: ReferenceReceiver<any>;
570
+ children?: SignalValue<ComponentChildren>;
571
+ /**
572
+ * @deprecated Use {@link children} instead.
573
+ */
574
+ spawner?: SignalValue<ComponentChildren>;
575
+ key?: string;
576
+ x?: SignalValue<number>;
577
+ y?: SignalValue<number>;
578
+ position?: SignalValue<PossibleVector2>;
579
+ rotation?: SignalValue<number>;
580
+ scaleX?: SignalValue<number>;
581
+ scaleY?: SignalValue<number>;
582
+ scale?: SignalValue<PossibleVector2>;
583
+ skewX?: SignalValue<number>;
584
+ skewY?: SignalValue<number>;
585
+ skew?: SignalValue<PossibleVector2>;
586
+ zIndex?: SignalValue<number>;
587
+ opacity?: SignalValue<number>;
588
+ filters?: SignalValue<Filter[]>;
589
+ shadowColor?: SignalValue<PossibleColor>;
590
+ shadowBlur?: SignalValue<number>;
591
+ shadowOffsetX?: SignalValue<number>;
592
+ shadowOffsetY?: SignalValue<number>;
593
+ shadowOffset?: SignalValue<PossibleVector2>;
594
+ cache?: SignalValue<boolean>;
595
+ /**
596
+ * {@inheritDoc Node.cachePadding}
597
+ */
598
+ cachePaddingTop?: SignalValue<number>;
599
+ /**
600
+ * {@inheritDoc Node.cachePadding}
601
+ */
602
+ cachePaddingBottom?: SignalValue<number>;
603
+ /**
604
+ * {@inheritDoc Node.cachePadding}
605
+ */
606
+ cachePaddingLeft?: SignalValue<number>;
607
+ /**
608
+ * {@inheritDoc Node.cachePadding}
609
+ */
610
+ cachePaddingRight?: SignalValue<number>;
611
+ /**
612
+ * {@inheritDoc Node.cachePadding}
613
+ */
614
+ cachePadding?: SignalValue<PossibleSpacing>;
615
+ composite?: SignalValue<boolean>;
616
+ compositeOperation?: SignalValue<GlobalCompositeOperation>;
617
+ /**
618
+ * @experimental
619
+ */
620
+ shaders?: PossibleShaderConfig;
621
+ }
622
+ declare class Node implements Promisable<Node> {
623
+ /**
624
+ * @internal
625
+ */
626
+ readonly [NODE_NAME]: string;
627
+ isClass: boolean;
628
+ /**
629
+ * Represents the position of this node in local space of its parent.
630
+ *
631
+ * @example
632
+ * Initializing the position:
633
+ * ```tsx
634
+ * // with a possible vector:
635
+ * <Node position={[1, 2]} />
636
+ * // with individual components:
637
+ * <Node x={1} y={2} />
638
+ * ```
639
+ *
640
+ * Accessing the position:
641
+ * ```tsx
642
+ * // retrieving the vector:
643
+ * const position = node.position();
644
+ * // retrieving an individual component:
645
+ * const x = node.position.x();
646
+ * ```
647
+ *
648
+ * Setting the position:
649
+ * ```tsx
650
+ * // with a possible vector:
651
+ * node.position([1, 2]);
652
+ * node.position(() => [1, 2]);
653
+ * // with individual components:
654
+ * node.position.x(1);
655
+ * node.position.x(() => 1);
656
+ * ```
657
+ */
658
+ readonly position: Vector2Signal<this>;
659
+ get x(): SimpleSignal<number, this>;
660
+ get y(): SimpleSignal<number, this>;
661
+ /**
662
+ * A helper signal for operating on the position in world space.
663
+ *
664
+ * @remarks
665
+ * Retrieving the position using this signal returns the position in world
666
+ * space. Similarly, setting the position using this signal transforms the
667
+ * new value to local space.
668
+ *
669
+ * If the new value is a function, the position of this node will be
670
+ * continuously updated to always match the position returned by the function.
671
+ * This can be useful to "pin" the node in a specific place or to make it
672
+ * follow another node's position.
673
+ *
674
+ * Unlike {@link position}, this signal is not compound - it doesn't contain
675
+ * separate signals for the `x` and `y` components.
676
+ */
677
+ readonly absolutePosition: SimpleVector2Signal<this>;
678
+ protected getAbsolutePosition(): Vector2;
679
+ protected setAbsolutePosition(value: SignalValue<PossibleVector2>): void;
680
+ /**
681
+ * Represents the rotation (in degrees) of this node relative to its parent.
682
+ */
683
+ readonly rotation: SimpleSignal<number, this>;
684
+ /**
685
+ * A helper signal for operating on the rotation in world space.
686
+ *
687
+ * @remarks
688
+ * Retrieving the rotation using this signal returns the rotation in world
689
+ * space. Similarly, setting the rotation using this signal transforms the
690
+ * new value to local space.
691
+ *
692
+ * If the new value is a function, the rotation of this node will be
693
+ * continuously updated to always match the rotation returned by the function.
694
+ */
695
+ readonly absoluteRotation: SimpleSignal<number, this>;
696
+ protected getAbsoluteRotation(): number;
697
+ protected setAbsoluteRotation(value: SignalValue<number>): void;
698
+ /**
699
+ * Represents the scale of this node in local space of its parent.
700
+ *
701
+ * @example
702
+ * Initializing the scale:
703
+ * ```tsx
704
+ * // with a possible vector:
705
+ * <Node scale={[1, 2]} />
706
+ * // with individual components:
707
+ * <Node scaleX={1} scaleY={2} />
708
+ * ```
709
+ *
710
+ * Accessing the scale:
711
+ * ```tsx
712
+ * // retrieving the vector:
713
+ * const scale = node.scale();
714
+ * // retrieving an individual component:
715
+ * const scaleX = node.scale.x();
716
+ * ```
717
+ *
718
+ * Setting the scale:
719
+ * ```tsx
720
+ * // with a possible vector:
721
+ * node.scale([1, 2]);
722
+ * node.scale(() => [1, 2]);
723
+ * // with individual components:
724
+ * node.scale.x(1);
725
+ * node.scale.x(() => 1);
726
+ * ```
727
+ */
728
+ readonly scale: Vector2Signal<this>;
729
+ /**
730
+ * Represents the skew of this node in local space of its parent.
731
+ *
732
+ * @example
733
+ * Initializing the skew:
734
+ * ```tsx
735
+ * // with a possible vector:
736
+ * <Node skew={[40, 20]} />
737
+ * // with individual components:
738
+ * <Node skewX={40} skewY={20} />
739
+ * ```
740
+ *
741
+ * Accessing the skew:
742
+ * ```tsx
743
+ * // retrieving the vector:
744
+ * const skew = node.skew();
745
+ * // retrieving an individual component:
746
+ * const skewX = node.skew.x();
747
+ * ```
748
+ *
749
+ * Setting the skew:
750
+ * ```tsx
751
+ * // with a possible vector:
752
+ * node.skew([40, 20]);
753
+ * node.skew(() => [40, 20]);
754
+ * // with individual components:
755
+ * node.skew.x(40);
756
+ * node.skew.x(() => 40);
757
+ * ```
758
+ */
759
+ readonly skew: Vector2Signal<this>;
760
+ /**
761
+ * A helper signal for operating on the scale in world space.
762
+ *
763
+ * @remarks
764
+ * Retrieving the scale using this signal returns the scale in world space.
765
+ * Similarly, setting the scale using this signal transforms the new value to
766
+ * local space.
767
+ *
768
+ * If the new value is a function, the scale of this node will be continuously
769
+ * updated to always match the position returned by the function.
770
+ *
771
+ * Unlike {@link scale}, this signal is not compound - it doesn't contain
772
+ * separate signals for the `x` and `y` components.
773
+ */
774
+ readonly absoluteScale: SimpleVector2Signal<this>;
775
+ protected getAbsoluteScale(): Vector2;
776
+ protected setAbsoluteScale(value: SignalValue<PossibleVector2>): void;
777
+ private getRelativeScale;
778
+ readonly zIndex: SimpleSignal<number, this>;
779
+ readonly cache: SimpleSignal<boolean, this>;
780
+ /**
781
+ * Controls the padding of the cached canvas used by this node.
782
+ *
783
+ * @remarks
784
+ * By default, the size of the cache is determined based on the bounding box
785
+ * of the node and its children. That includes effects such as stroke or
786
+ * shadow. This property can be used to expand the cache area further.
787
+ * Usually used to account for custom effects created by {@link shaders}.
788
+ */
789
+ readonly cachePadding: SpacingSignal<this>;
790
+ readonly composite: SimpleSignal<boolean, this>;
791
+ readonly compositeOperation: SimpleSignal<GlobalCompositeOperation, this>;
792
+ private readonly compositeOverride;
793
+ protected tweenCompositeOperation(value: SignalValue<GlobalCompositeOperation>, time: number, timingFunction: TimingFunction): Generator<void | ThreadGenerator | Promise<any> | Promisable<any>, void, any>;
794
+ /**
795
+ * Represents the opacity of this node in the range 0-1.
796
+ *
797
+ * @remarks
798
+ * The value is clamped to the range 0-1.
799
+ */
800
+ readonly opacity: SimpleSignal<number, this>;
801
+ absoluteOpacity(): number;
802
+ readonly filters: FiltersSignal<this>;
803
+ readonly shadowColor: ColorSignal<this>;
804
+ readonly shadowBlur: SimpleSignal<number, this>;
805
+ readonly shadowOffset: Vector2Signal<this>;
806
+ /**
807
+ * @experimental
808
+ */
809
+ readonly shaders: Signal<PossibleShaderConfig, ShaderConfig[], this>;
810
+ protected hasFilters(): boolean;
811
+ protected hasShadow(): boolean;
812
+ protected filterString(): string;
813
+ /**
814
+ * @deprecated Use {@link children} instead.
815
+ */
816
+ protected readonly spawner: SimpleSignal<ComponentChildren, this>;
817
+ protected getSpawner(): ComponentChildren;
818
+ protected setSpawner(value: SignalValue<ComponentChildren>): void;
819
+ readonly children: Signal<ComponentChildren, Node[], this>;
820
+ protected setChildren(value: SignalValue<ComponentChildren>): void;
821
+ protected getChildren(): Node[];
822
+ protected spawnedChildren(): Node[];
823
+ protected sortedChildren(): Node[];
824
+ protected view2D: View2D;
825
+ private stateStack;
826
+ protected realChildren: Node[];
827
+ protected hasSpawnedChildren: boolean;
828
+ private unregister;
829
+ readonly parent: SimpleSignal<Node | null, void>;
830
+ readonly properties: Record<string, PropertyMetadata<any>>;
831
+ readonly key: string;
832
+ readonly creationStack?: string;
833
+ constructor({ children, spawner, key, ...rest }: NodeProps);
834
+ /**
835
+ * Get the local-to-world matrix for this node.
836
+ *
837
+ * @remarks
838
+ * This matrix transforms vectors from local space of this node to world
839
+ * space.
840
+ *
841
+ * @example
842
+ * Calculate the absolute position of a point located 200 pixels to the right
843
+ * of the node:
844
+ * ```ts
845
+ * const local = new Vector2(0, 200);
846
+ * const world = transformVectorAsPoint(local, node.localToWorld());
847
+ * ```
848
+ */
849
+ localToWorld(): DOMMatrix;
850
+ /**
851
+ * Get the world-to-local matrix for this node.
852
+ *
853
+ * @remarks
854
+ * This matrix transforms vectors from world space to local space of this
855
+ * node.
856
+ *
857
+ * @example
858
+ * Calculate the position relative to this node for a point located in the
859
+ * top-left corner of the screen:
860
+ * ```ts
861
+ * const world = new Vector2(0, 0);
862
+ * const local = transformVectorAsPoint(world, node.worldToLocal());
863
+ * ```
864
+ */
865
+ worldToLocal(): DOMMatrix;
866
+ /**
867
+ * Get the world-to-parent matrix for this node.
868
+ *
869
+ * @remarks
870
+ * This matrix transforms vectors from world space to local space of this
871
+ * node's parent.
872
+ */
873
+ worldToParent(): DOMMatrix;
874
+ /**
875
+ * Get the local-to-parent matrix for this node.
876
+ *
877
+ * @remarks
878
+ * This matrix transforms vectors from local space of this node to local space
879
+ * of this node's parent.
880
+ */
881
+ localToParent(): DOMMatrix;
882
+ /**
883
+ * A matrix mapping composite space to world space.
884
+ *
885
+ * @remarks
886
+ * Certain effects such as blur and shadows ignore the current transformation.
887
+ * This matrix can be used to transform their parameters so that the effect
888
+ * appears relative to the closest composite root.
889
+ */
890
+ compositeToWorld(): DOMMatrix;
891
+ protected compositeRoot(): Node | null;
892
+ compositeToLocal(): DOMMatrix;
893
+ view(): View2D;
894
+ /**
895
+ * Add the given node(s) as the children of this node.
896
+ *
897
+ * @remarks
898
+ * The nodes will be appended at the end of the children list.
899
+ *
900
+ * @example
901
+ * ```tsx
902
+ * const node = <Layout />;
903
+ * node.add(<Rect />);
904
+ * node.add(<Circle />);
905
+ * ```
906
+ * Result:
907
+ * ```mermaid
908
+ * graph TD;
909
+ * layout([Layout])
910
+ * circle([Circle])
911
+ * rect([Rect])
912
+ * layout-->rect;
913
+ * layout-->circle;
914
+ * ```
915
+ *
916
+ * @param node - A node or an array of nodes to append.
917
+ */
918
+ add(node: ComponentChildren): this;
919
+ /**
920
+ * Insert the given node(s) at the specified index in the children list.
921
+ *
922
+ * @example
923
+ * ```tsx
924
+ * const node = (
925
+ * <Layout>
926
+ * <Rect />
927
+ * <Circle />
928
+ * </Layout>
929
+ * );
930
+ *
931
+ * node.insert(<Txt />, 1);
932
+ * ```
933
+ *
934
+ * Result:
935
+ * ```mermaid
936
+ * graph TD;
937
+ * layout([Layout])
938
+ * circle([Circle])
939
+ * text([Text])
940
+ * rect([Rect])
941
+ * layout-->rect;
942
+ * layout-->text;
943
+ * layout-->circle;
944
+ * ```
945
+ *
946
+ * @param node - A node or an array of nodes to insert.
947
+ * @param index - An index at which to insert the node(s).
948
+ */
949
+ insert(node: ComponentChildren, index?: number): this;
950
+ /**
951
+ * Remove this node from the tree.
952
+ */
953
+ remove(): this;
954
+ /**
955
+ * Rearrange this node in relation to its siblings.
956
+ *
957
+ * @remarks
958
+ * Children are rendered starting from the beginning of the children list.
959
+ * We can change the rendering order by rearranging said list.
960
+ *
961
+ * A positive `by` arguments move the node up (it will be rendered on top of
962
+ * the elements it has passed). Negative values move it down.
963
+ *
964
+ * @param by - Number of places by which the node should be moved.
965
+ */
966
+ move(by?: number): this;
967
+ /**
968
+ * Move the node up in relation to its siblings.
969
+ *
970
+ * @remarks
971
+ * The node will exchange places with the sibling right above it (if any) and
972
+ * from then on will be rendered on top of it.
973
+ */
974
+ moveUp(): this;
975
+ /**
976
+ * Move the node down in relation to its siblings.
977
+ *
978
+ * @remarks
979
+ * The node will exchange places with the sibling right below it (if any) and
980
+ * from then on will be rendered under it.
981
+ */
982
+ moveDown(): this;
983
+ /**
984
+ * Move the node to the top in relation to its siblings.
985
+ *
986
+ * @remarks
987
+ * The node will be placed at the end of the children list and from then on
988
+ * will be rendered on top of all of its siblings.
989
+ */
990
+ moveToTop(): this;
991
+ /**
992
+ * Move the node to the bottom in relation to its siblings.
993
+ *
994
+ * @remarks
995
+ * The node will be placed at the beginning of the children list and from then
996
+ * on will be rendered below all of its siblings.
997
+ */
998
+ moveToBottom(): this;
999
+ /**
1000
+ * Move the node to the provided position relative to its siblings.
1001
+ *
1002
+ * @remarks
1003
+ * If the node is getting moved to a lower position, it will be placed below
1004
+ * the sibling that's currently at the provided index (if any).
1005
+ * If the node is getting moved to a higher position, it will be placed above
1006
+ * the sibling that's currently at the provided index (if any).
1007
+ *
1008
+ * @param index - The index to move the node to.
1009
+ */
1010
+ moveTo(index: number): this;
1011
+ /**
1012
+ * Move the node below the provided node in the parent's layout.
1013
+ *
1014
+ * @remarks
1015
+ * The node will be moved below the provided node and from then on will be
1016
+ * rendered below it. By default, if the node is already positioned lower than
1017
+ * the sibling node, it will not get moved.
1018
+ *
1019
+ * @param node - The sibling node below which to move.
1020
+ * @param directlyBelow - Whether the node should be positioned directly below
1021
+ * the sibling. When true, will move the node even if
1022
+ * it is already positioned below the sibling.
1023
+ */
1024
+ moveBelow(node: Node, directlyBelow?: boolean): this;
1025
+ /**
1026
+ * Move the node above the provided node in the parent's layout.
1027
+ *
1028
+ * @remarks
1029
+ * The node will be moved above the provided node and from then on will be
1030
+ * rendered on top of it. By default, if the node is already positioned
1031
+ * higher than the sibling node, it will not get moved.
1032
+ *
1033
+ * @param node - The sibling node below which to move.
1034
+ * @param directlyAbove - Whether the node should be positioned directly above the
1035
+ * sibling. When true, will move the node even if it is
1036
+ * already positioned above the sibling.
1037
+ */
1038
+ moveAbove(node: Node, directlyAbove?: boolean): this;
1039
+ /**
1040
+ * Change the parent of this node while keeping the absolute transform.
1041
+ *
1042
+ * @remarks
1043
+ * After performing this operation, the node will stay in the same place
1044
+ * visually, but its parent will be changed.
1045
+ *
1046
+ * @param newParent - The new parent of this node.
1047
+ */
1048
+ reparent(newParent: Node): void;
1049
+ /**
1050
+ * Remove all children of this node.
1051
+ */
1052
+ removeChildren(): void;
1053
+ /**
1054
+ * Get the current children of this node.
1055
+ *
1056
+ * @remarks
1057
+ * Unlike {@link children}, this method does not have any side effects.
1058
+ * It does not register the `children` signal as a dependency, and it does not
1059
+ * spawn any children. It can be used to safely retrieve the current state of
1060
+ * the scene graph for debugging purposes.
1061
+ */
1062
+ peekChildren(): readonly Node[];
1063
+ /**
1064
+ * Find all descendants of this node that match the given predicate.
1065
+ *
1066
+ * @param predicate - A function that returns true if the node matches.
1067
+ */
1068
+ findAll<T extends Node>(predicate: (node: any) => node is T): T[];
1069
+ /**
1070
+ * Find all descendants of this node that match the given predicate.
1071
+ *
1072
+ * @param predicate - A function that returns true if the node matches.
1073
+ */
1074
+ findAll<T extends Node = Node>(predicate: (node: any) => boolean): T[];
1075
+ /**
1076
+ * Find the first descendant of this node that matches the given predicate.
1077
+ *
1078
+ * @param predicate - A function that returns true if the node matches.
1079
+ */
1080
+ findFirst<T extends Node>(predicate: (node: Node) => node is T): T | null;
1081
+ /**
1082
+ * Find the first descendant of this node that matches the given predicate.
1083
+ *
1084
+ * @param predicate - A function that returns true if the node matches.
1085
+ */
1086
+ findFirst<T extends Node = Node>(predicate: (node: Node) => boolean): T | null;
1087
+ /**
1088
+ * Find the last descendant of this node that matches the given predicate.
1089
+ *
1090
+ * @param predicate - A function that returns true if the node matches.
1091
+ */
1092
+ findLast<T extends Node>(predicate: (node: Node) => node is T): T | null;
1093
+ /**
1094
+ * Find the last descendant of this node that matches the given predicate.
1095
+ *
1096
+ * @param predicate - A function that returns true if the node matches.
1097
+ */
1098
+ findLast<T extends Node = Node>(predicate: (node: Node) => boolean): T | null;
1099
+ /**
1100
+ * Find the closest ancestor of this node that matches the given predicate.
1101
+ *
1102
+ * @param predicate - A function that returns true if the node matches.
1103
+ */
1104
+ findAncestor<T extends Node>(predicate: (node: Node) => node is T): T | null;
1105
+ /**
1106
+ * Find the closest ancestor of this node that matches the given predicate.
1107
+ *
1108
+ * @param predicate - A function that returns true if the node matches.
1109
+ */
1110
+ findAncestor<T extends Node = Node>(predicate: (node: Node) => boolean): T | null;
1111
+ /**
1112
+ * Get the nth children cast to the specified type.
1113
+ *
1114
+ * @param index - The index of the child to retrieve.
1115
+ */
1116
+ childAs<T extends Node = Node>(index: number): T | null;
1117
+ /**
1118
+ * Get the children array cast to the specified type.
1119
+ */
1120
+ childrenAs<T extends Node = Node>(): T[];
1121
+ /**
1122
+ * Get the parent cast to the specified type.
1123
+ */
1124
+ parentAs<T extends Node = Node>(): T | null;
1125
+ /**
1126
+ * Prepare this node to be disposed of.
1127
+ *
1128
+ * @remarks
1129
+ * This method is called automatically when a scene is refreshed. It will
1130
+ * be called even if the node is not currently attached to the tree.
1131
+ *
1132
+ * The goal of this method is to clean any external references to allow the
1133
+ * node to be garbage collected.
1134
+ */
1135
+ dispose(): void;
1136
+ /**
1137
+ * Create a copy of this node.
1138
+ *
1139
+ * @param customProps - Properties to override.
1140
+ */
1141
+ clone(customProps?: NodeState): this;
1142
+ /**
1143
+ * Create a copy of this node.
1144
+ *
1145
+ * @remarks
1146
+ * Unlike {@link clone}, a snapshot clone calculates any reactive properties
1147
+ * at the moment of cloning and passes the raw values to the copy.
1148
+ *
1149
+ * @param customProps - Properties to override.
1150
+ */
1151
+ snapshotClone(customProps?: NodeState): this;
1152
+ /**
1153
+ * Create a reactive copy of this node.
1154
+ *
1155
+ * @remarks
1156
+ * A reactive copy has all its properties dynamically updated to match the
1157
+ * source node.
1158
+ *
1159
+ * @param customProps - Properties to override.
1160
+ */
1161
+ reactiveClone(customProps?: NodeState): this;
1162
+ /**
1163
+ * Create an instance of this node's class.
1164
+ *
1165
+ * @param props - Properties to pass to the constructor.
1166
+ */
1167
+ instantiate(props?: NodeProps): this;
1168
+ /**
1169
+ * Set the children without parsing them.
1170
+ *
1171
+ * @remarks
1172
+ * This method assumes that the caller took care of parsing the children and
1173
+ * updating the hierarchy.
1174
+ *
1175
+ * @param value - The children to set.
1176
+ */
1177
+ protected setParsedChildren(value: Node[]): void;
1178
+ protected spawnChildren(reactive: boolean, children: ComponentChildren): void;
1179
+ /**
1180
+ * Parse any `ComponentChildren` into an array of nodes.
1181
+ *
1182
+ * @param children - The children to parse.
1183
+ */
1184
+ protected parseChildren(children: ComponentChildren): Node[];
1185
+ /**
1186
+ * Remove the given child.
1187
+ */
1188
+ protected removeChild(child: Node): void;
1189
+ /**
1190
+ * Whether this node should be cached or not.
1191
+ */
1192
+ protected requiresCache(): boolean;
1193
+ protected cacheCanvas(): CanvasRenderingContext2D;
1194
+ /**
1195
+ * Get a cache canvas with the contents of this node rendered onto it.
1196
+ */
1197
+ protected cachedCanvas(): Promise<CanvasRenderingContext2D>;
1198
+ /**
1199
+ * Get a bounding box for the contents rendered by this node.
1200
+ *
1201
+ * @remarks
1202
+ * The returned bounding box should be in local space.
1203
+ */
1204
+ protected getCacheBBox(): BBox;
1205
+ /**
1206
+ * Get a bounding box for the contents rendered by this node as well
1207
+ * as its children.
1208
+ */
1209
+ cacheBBox(): BBox;
1210
+ /**
1211
+ * Get a bounding box for the contents rendered by this node (including
1212
+ * effects applied after caching).
1213
+ *
1214
+ * @remarks
1215
+ * The returned bounding box should be in local space.
1216
+ */
1217
+ protected fullCacheBBox(): BBox;
1218
+ /**
1219
+ * Get a bounding box in world space for the contents rendered by this node as
1220
+ * well as its children.
1221
+ *
1222
+ * @remarks
1223
+ * This is the same the bounding box returned by {@link cacheBBox} only
1224
+ * transformed to world space.
1225
+ */
1226
+ protected worldSpaceCacheBBox(): BBox;
1227
+ protected parentWorldSpaceCacheBBox(): BBox;
1228
+ /**
1229
+ * Prepare the given context for drawing a cached node onto it.
1230
+ *
1231
+ * @remarks
1232
+ * This method is called before the contents of the cache canvas are drawn
1233
+ * on the screen. It can be used to apply effects to the entire node together
1234
+ * with its children, instead of applying them individually.
1235
+ * Effects such as transparency, shadows, and filters use this technique.
1236
+ *
1237
+ * Whether the node is cached is decided by the {@link requiresCache} method.
1238
+ *
1239
+ * @param context - The context using which the cache will be drawn.
1240
+ */
1241
+ protected setupDrawFromCache(context: CanvasRenderingContext2D): void;
1242
+ protected renderFromSource(context: CanvasRenderingContext2D, source: CanvasImageSource, x: number, y: number): void;
1243
+ private shaderCanvas;
1244
+ /**
1245
+ * Render this node onto the given canvas.
1246
+ *
1247
+ * @param context - The context to draw with.
1248
+ */
1249
+ render(context: CanvasRenderingContext2D): Promise<void>;
1250
+ /**
1251
+ * Draw this node onto the canvas.
1252
+ *
1253
+ * @remarks
1254
+ * This method is used when drawing directly onto the screen as well as onto
1255
+ * the cache canvas.
1256
+ * It assumes that the context have already been transformed to local space.
1257
+ *
1258
+ * @param context - The context to draw with.
1259
+ */
1260
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
1261
+ protected drawChildren(context: CanvasRenderingContext2D): Promise<void>;
1262
+ /**
1263
+ * Draw an overlay for this node.
1264
+ *
1265
+ * @remarks
1266
+ * The overlay for the currently inspected node is displayed on top of the
1267
+ * canvas.
1268
+ *
1269
+ * The provided context is in screen space. The local-to-screen matrix can be
1270
+ * used to transform all shapes that need to be displayed.
1271
+ * This approach allows to keep the line widths and gizmo sizes consistent,
1272
+ * no matter how zoomed-in the view is.
1273
+ *
1274
+ * @param context - The context to draw with.
1275
+ * @param matrix - A local-to-screen matrix.
1276
+ */
1277
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
1278
+ protected transformContext(context: CanvasRenderingContext2D): void;
1279
+ /**
1280
+ * Try to find a node intersecting the given position.
1281
+ *
1282
+ * @param position - The searched position.
1283
+ */
1284
+ hit(position: Vector2): Node | null;
1285
+ /**
1286
+ * Collect all asynchronous resources used by this node.
1287
+ */
1288
+ protected collectAsyncResources(): void;
1289
+ /**
1290
+ * Wait for any asynchronous resources that this node or its children have.
1291
+ *
1292
+ * @remarks
1293
+ * Certain resources like images are always loaded asynchronously.
1294
+ * Awaiting this method makes sure that all such resources are done loading
1295
+ * before continuing the animation.
1296
+ */
1297
+ toPromise(): Promise<this>;
1298
+ /**
1299
+ * Return a snapshot of the node's current signal values.
1300
+ *
1301
+ * @remarks
1302
+ * This method will calculate the values of any reactive properties of the
1303
+ * node at the time the method is called.
1304
+ */
1305
+ getState(): NodeState;
1306
+ /**
1307
+ * Apply the given state to the node, setting all matching signal values to
1308
+ * the provided values.
1309
+ *
1310
+ * @param state - The state to apply to the node.
1311
+ */
1312
+ applyState(state: NodeState): void;
1313
+ /**
1314
+ * Smoothly transition between the current state of the node and the given
1315
+ * state.
1316
+ *
1317
+ * @param state - The state to transition to.
1318
+ * @param duration - The duration of the transition.
1319
+ * @param timing - The timing function to use for the transition.
1320
+ */
1321
+ applyState(state: NodeState, duration: number, timing?: TimingFunction): ThreadGenerator;
1322
+ /**
1323
+ * Push a snapshot of the node's current state onto the node's state stack.
1324
+ *
1325
+ * @remarks
1326
+ * This method can be used together with the {@link restore} method to save a
1327
+ * node's current state and later restore it. It is possible to store more
1328
+ * than one state by calling `save` method multiple times.
1329
+ */
1330
+ save(): void;
1331
+ /**
1332
+ * Restore the node to its last saved state.
1333
+ *
1334
+ * @remarks
1335
+ * This method can be used together with the {@link save} method to restore a
1336
+ * node to a previously saved state. Restoring a node to a previous state
1337
+ * removes that state from the state stack.
1338
+ *
1339
+ * @example
1340
+ * ```tsx
1341
+ * const node = <Circle width={100} height={100} fill={"lightseagreen"} />
1342
+ *
1343
+ * view.add(node);
1344
+ *
1345
+ * // Save the node's current state
1346
+ * node.save();
1347
+ *
1348
+ * // Modify some of the node's properties
1349
+ * yield* node.scale(2, 1);
1350
+ * yield* node.fill('hotpink', 1);
1351
+ *
1352
+ * // Restore the node to its saved state
1353
+ * node.restore();
1354
+ * ```
1355
+ */
1356
+ restore(): void;
1357
+ /**
1358
+ * Tween the node to its last saved state.
1359
+ *
1360
+ * @remarks
1361
+ * This method can be used together with the {@link save} method to restore a
1362
+ * node to a previously saved state. Restoring a node to a previous state
1363
+ * removes that state from the state stack.
1364
+ *
1365
+ * @example
1366
+ * ```tsx
1367
+ * const node = <Circle width={100} height={100} fill={"lightseagreen"} />
1368
+ *
1369
+ * view.add(node);
1370
+ *
1371
+ * // Save the node's current state
1372
+ * node.save();
1373
+ *
1374
+ * // Modify some of the node's properties
1375
+ * yield* node.scale(2, 1);
1376
+ * yield* node.fill('hotpink', 1);
1377
+ *
1378
+ * // Tween the node to its saved state over 1 second
1379
+ * yield* node.restore(1);
1380
+ * ```
1381
+ *
1382
+ * @param duration - The duration of the transition.
1383
+ * @param timing - The timing function to use for the transition.
1384
+ */
1385
+ restore(duration: number, timing?: TimingFunction): ThreadGenerator;
1386
+ [Symbol.iterator](): Generator<{
1387
+ meta: PropertyMetadata<any>;
1388
+ signal: SimpleSignal<any>;
1389
+ key: string;
1390
+ }, void, unknown>;
1391
+ private signalByKey;
1392
+ private reversedChildren;
1393
+ }
1394
+
1395
+ interface LayoutProps extends NodeProps {
1396
+ layout?: LayoutMode;
1397
+ tagName?: keyof HTMLElementTagNameMap;
1398
+ width?: SignalValue<Length>;
1399
+ height?: SignalValue<Length>;
1400
+ maxWidth?: SignalValue<LengthLimit>;
1401
+ maxHeight?: SignalValue<LengthLimit>;
1402
+ minWidth?: SignalValue<LengthLimit>;
1403
+ minHeight?: SignalValue<LengthLimit>;
1404
+ ratio?: SignalValue<number>;
1405
+ marginTop?: SignalValue<number>;
1406
+ marginBottom?: SignalValue<number>;
1407
+ marginLeft?: SignalValue<number>;
1408
+ marginRight?: SignalValue<number>;
1409
+ margin?: SignalValue<PossibleSpacing>;
1410
+ paddingTop?: SignalValue<number>;
1411
+ paddingBottom?: SignalValue<number>;
1412
+ paddingLeft?: SignalValue<number>;
1413
+ paddingRight?: SignalValue<number>;
1414
+ padding?: SignalValue<PossibleSpacing>;
1415
+ direction?: SignalValue<FlexDirection>;
1416
+ basis?: SignalValue<FlexBasis>;
1417
+ grow?: SignalValue<number>;
1418
+ shrink?: SignalValue<number>;
1419
+ wrap?: SignalValue<FlexWrap>;
1420
+ justifyContent?: SignalValue<FlexContent>;
1421
+ alignContent?: SignalValue<FlexContent>;
1422
+ alignItems?: SignalValue<FlexItems>;
1423
+ alignSelf?: SignalValue<FlexItems>;
1424
+ rowGap?: SignalValue<Length>;
1425
+ columnGap?: SignalValue<Length>;
1426
+ gap?: SignalValue<Length>;
1427
+ fontFamily?: SignalValue<string>;
1428
+ fontSize?: SignalValue<number>;
1429
+ fontStyle?: SignalValue<string>;
1430
+ fontWeight?: SignalValue<number>;
1431
+ lineHeight?: SignalValue<Length>;
1432
+ letterSpacing?: SignalValue<number>;
1433
+ textWrap?: SignalValue<TextWrap>;
1434
+ textDirection?: SignalValue<CanvasDirection>;
1435
+ textAlign?: SignalValue<CanvasTextAlign>;
1436
+ size?: SignalValue<PossibleVector2<Length>>;
1437
+ offsetX?: SignalValue<number>;
1438
+ offsetY?: SignalValue<number>;
1439
+ offset?: SignalValue<PossibleVector2>;
1440
+ /**
1441
+ * The position of the center of this node.
1442
+ *
1443
+ * @remarks
1444
+ * This shortcut property will set the node's position so that the center ends
1445
+ * up in the given place.
1446
+ * If present, overrides the {@link NodeProps.position} property.
1447
+ * When {@link offset} is not set, this will be the same as the
1448
+ * {@link NodeProps.position}.
1449
+ */
1450
+ middle?: SignalValue<PossibleVector2>;
1451
+ /**
1452
+ * The position of the top edge of this node.
1453
+ *
1454
+ * @remarks
1455
+ * This shortcut property will set the node's position so that the top edge
1456
+ * ends up in the given place.
1457
+ * If present, overrides the {@link NodeProps.position} property.
1458
+ */
1459
+ top?: SignalValue<PossibleVector2>;
1460
+ /**
1461
+ * The position of the bottom edge of this node.
1462
+ *
1463
+ * @remarks
1464
+ * This shortcut property will set the node's position so that the bottom edge
1465
+ * ends up in the given place.
1466
+ * If present, overrides the {@link NodeProps.position} property.
1467
+ */
1468
+ bottom?: SignalValue<PossibleVector2>;
1469
+ /**
1470
+ * The position of the left edge of this node.
1471
+ *
1472
+ * @remarks
1473
+ * This shortcut property will set the node's position so that the left edge
1474
+ * ends up in the given place.
1475
+ * If present, overrides the {@link NodeProps.position} property.
1476
+ */
1477
+ left?: SignalValue<PossibleVector2>;
1478
+ /**
1479
+ * The position of the right edge of this node.
1480
+ *
1481
+ * @remarks
1482
+ * This shortcut property will set the node's position so that the right edge
1483
+ * ends up in the given place.
1484
+ * If present, overrides the {@link NodeProps.position} property.
1485
+ */
1486
+ right?: SignalValue<PossibleVector2>;
1487
+ /**
1488
+ * The position of the top left corner of this node.
1489
+ *
1490
+ * @remarks
1491
+ * This shortcut property will set the node's position so that the top left
1492
+ * corner ends up in the given place.
1493
+ * If present, overrides the {@link NodeProps.position} property.
1494
+ */
1495
+ topLeft?: SignalValue<PossibleVector2>;
1496
+ /**
1497
+ * The position of the top right corner of this node.
1498
+ *
1499
+ * @remarks
1500
+ * This shortcut property will set the node's position so that the top right
1501
+ * corner ends up in the given place.
1502
+ * If present, overrides the {@link NodeProps.position} property.
1503
+ */
1504
+ topRight?: SignalValue<PossibleVector2>;
1505
+ /**
1506
+ * The position of the bottom left corner of this node.
1507
+ *
1508
+ * @remarks
1509
+ * This shortcut property will set the node's position so that the bottom left
1510
+ * corner ends up in the given place.
1511
+ * If present, overrides the {@link NodeProps.position} property.
1512
+ */
1513
+ bottomLeft?: SignalValue<PossibleVector2>;
1514
+ /**
1515
+ * The position of the bottom right corner of this node.
1516
+ *
1517
+ * @remarks
1518
+ * This shortcut property will set the node's position so that the bottom
1519
+ * right corner ends up in the given place.
1520
+ * If present, overrides the {@link NodeProps.position} property.
1521
+ */
1522
+ bottomRight?: SignalValue<PossibleVector2>;
1523
+ clip?: SignalValue<boolean>;
1524
+ }
1525
+ declare class Layout extends Node {
1526
+ readonly layout: SimpleSignal<LayoutMode, this>;
1527
+ readonly maxWidth: SimpleSignal<LengthLimit, this>;
1528
+ readonly maxHeight: SimpleSignal<LengthLimit, this>;
1529
+ readonly minWidth: SimpleSignal<LengthLimit, this>;
1530
+ readonly minHeight: SimpleSignal<LengthLimit, this>;
1531
+ readonly ratio: SimpleSignal<number | null, this>;
1532
+ readonly margin: SpacingSignal<this>;
1533
+ readonly padding: SpacingSignal<this>;
1534
+ readonly direction: SimpleSignal<FlexDirection, this>;
1535
+ readonly basis: SimpleSignal<FlexBasis, this>;
1536
+ readonly grow: SimpleSignal<number, this>;
1537
+ readonly shrink: SimpleSignal<number, this>;
1538
+ readonly wrap: SimpleSignal<FlexWrap, this>;
1539
+ readonly justifyContent: SimpleSignal<FlexContent, this>;
1540
+ readonly alignContent: SimpleSignal<FlexContent, this>;
1541
+ readonly alignItems: SimpleSignal<FlexItems, this>;
1542
+ readonly alignSelf: SimpleSignal<FlexItems, this>;
1543
+ readonly gap: Vector2LengthSignal<this>;
1544
+ get columnGap(): Signal<Length, number, this>;
1545
+ get rowGap(): Signal<Length, number, this>;
1546
+ readonly fontFamily: SimpleSignal<string, this>;
1547
+ readonly fontSize: SimpleSignal<number, this>;
1548
+ readonly fontStyle: SimpleSignal<string, this>;
1549
+ readonly fontWeight: SimpleSignal<number, this>;
1550
+ readonly lineHeight: SimpleSignal<Length, this>;
1551
+ readonly letterSpacing: SimpleSignal<number, this>;
1552
+ readonly textWrap: SimpleSignal<TextWrap, this>;
1553
+ readonly textDirection: SimpleSignal<CanvasDirection, this>;
1554
+ readonly textAlign: SimpleSignal<CanvasTextAlign, this>;
1555
+ protected getX(): number;
1556
+ protected setX(value: SignalValue<number>): void;
1557
+ protected getY(): number;
1558
+ protected setY(value: SignalValue<number>): void;
1559
+ /**
1560
+ * Represents the size of this node.
1561
+ *
1562
+ * @remarks
1563
+ * A size is a two-dimensional vector, where `x` represents the `width`, and `y`
1564
+ * represents the `height`.
1565
+ *
1566
+ * The value of both x and y is of type {@link partials.Length} which is
1567
+ * either:
1568
+ * - `number` - the desired length in pixels
1569
+ * - `${number}%` - a string with the desired length in percents, for example
1570
+ * `'50%'`
1571
+ * - `null` - an automatic length
1572
+ *
1573
+ * When retrieving the size, all units are converted to pixels, using the
1574
+ * current state of the layout. For example, retrieving the width set to
1575
+ * `'50%'`, while the parent has a width of `200px` will result in the number
1576
+ * `100` being returned.
1577
+ *
1578
+ * When the node is not part of the layout, setting its size using percents
1579
+ * refers to the size of the entire scene.
1580
+ *
1581
+ * @example
1582
+ * Initializing the size:
1583
+ * ```tsx
1584
+ * // with a possible vector:
1585
+ * <Node size={['50%', 200]} />
1586
+ * // with individual components:
1587
+ * <Node width={'50%'} height={200} />
1588
+ * ```
1589
+ *
1590
+ * Accessing the size:
1591
+ * ```tsx
1592
+ * // retrieving the vector:
1593
+ * const size = node.size();
1594
+ * // retrieving an individual component:
1595
+ * const width = node.size.x();
1596
+ * ```
1597
+ *
1598
+ * Setting the size:
1599
+ * ```tsx
1600
+ * // with a possible vector:
1601
+ * node.size(['50%', 200]);
1602
+ * node.size(() => ['50%', 200]);
1603
+ * // with individual components:
1604
+ * node.size.x('50%');
1605
+ * node.size.x(() => '50%');
1606
+ * ```
1607
+ */
1608
+ readonly size: Vector2LengthSignal<this>;
1609
+ get width(): Signal<Length, number, this>;
1610
+ get height(): Signal<Length, number, this>;
1611
+ protected getWidth(): number;
1612
+ protected setWidth(value: SignalValue<Length>): void;
1613
+ protected tweenWidth(value: SignalValue<Length>, time: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<Length>): ThreadGenerator;
1614
+ protected getHeight(): number;
1615
+ protected setHeight(value: SignalValue<Length>): void;
1616
+ protected tweenHeight(value: SignalValue<Length>, time: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<Length>): ThreadGenerator;
1617
+ /**
1618
+ * Get the desired size of this node.
1619
+ *
1620
+ * @remarks
1621
+ * This method can be used to control the size using external factors.
1622
+ * By default, the returned size is the same as the one declared by the user.
1623
+ */
1624
+ protected desiredSize(): SerializedVector2<DesiredLength>;
1625
+ protected tweenSize(value: SignalValue<SerializedVector2<Length>>, time: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<Vector2>): ThreadGenerator;
1626
+ /**
1627
+ * Represents the offset of this node's origin.
1628
+ *
1629
+ * @remarks
1630
+ * By default, the origin of a node is located at its center. The origin
1631
+ * serves as the pivot point when rotating and scaling a node, but it doesn't
1632
+ * affect the placement of its children.
1633
+ *
1634
+ * The value is relative to the size of this node. A value of `1` means as far
1635
+ * to the right/bottom as possible. Here are a few examples of offsets:
1636
+ * - `[-1, -1]` - top left corner
1637
+ * - `[1, -1]` - top right corner
1638
+ * - `[0, 1]` - bottom edge
1639
+ * - `[-1, 1]` - bottom left corner
1640
+ */
1641
+ readonly offset: Vector2Signal<this>;
1642
+ /**
1643
+ * The position of the center of this node.
1644
+ *
1645
+ * @remarks
1646
+ * When set, this shortcut property will modify the node's position so that
1647
+ * the center ends up in the given place.
1648
+ *
1649
+ * If the {@link offset} has not been changed, this will be the same as the
1650
+ * {@link position}.
1651
+ *
1652
+ * When retrieved, it will return the position of the center in the parent
1653
+ * space.
1654
+ */
1655
+ readonly middle: SimpleVector2Signal<this>;
1656
+ /**
1657
+ * The position of the top edge of this node.
1658
+ *
1659
+ * @remarks
1660
+ * When set, this shortcut property will modify the node's position so that
1661
+ * the top edge ends up in the given place.
1662
+ *
1663
+ * When retrieved, it will return the position of the top edge in the parent
1664
+ * space.
1665
+ */
1666
+ readonly top: SimpleVector2Signal<this>;
1667
+ /**
1668
+ * The position of the bottom edge of this node.
1669
+ *
1670
+ * @remarks
1671
+ * When set, this shortcut property will modify the node's position so that
1672
+ * the bottom edge ends up in the given place.
1673
+ *
1674
+ * When retrieved, it will return the position of the bottom edge in the
1675
+ * parent space.
1676
+ */
1677
+ readonly bottom: SimpleVector2Signal<this>;
1678
+ /**
1679
+ * The position of the left edge of this node.
1680
+ *
1681
+ * @remarks
1682
+ * When set, this shortcut property will modify the node's position so that
1683
+ * the left edge ends up in the given place.
1684
+ *
1685
+ * When retrieved, it will return the position of the left edge in the parent
1686
+ * space.
1687
+ */
1688
+ readonly left: SimpleVector2Signal<this>;
1689
+ /**
1690
+ * The position of the right edge of this node.
1691
+ *
1692
+ * @remarks
1693
+ * When set, this shortcut property will modify the node's position so that
1694
+ * the right edge ends up in the given place.
1695
+ *
1696
+ * When retrieved, it will return the position of the right edge in the parent
1697
+ * space.
1698
+ */
1699
+ readonly right: SimpleVector2Signal<this>;
1700
+ /**
1701
+ * The position of the top left corner of this node.
1702
+ *
1703
+ * @remarks
1704
+ * When set, this shortcut property will modify the node's position so that
1705
+ * the top left corner ends up in the given place.
1706
+ *
1707
+ * When retrieved, it will return the position of the top left corner in the
1708
+ * parent space.
1709
+ */
1710
+ readonly topLeft: SimpleVector2Signal<this>;
1711
+ /**
1712
+ * The position of the top right corner of this node.
1713
+ *
1714
+ * @remarks
1715
+ * When set, this shortcut property will modify the node's position so that
1716
+ * the top right corner ends up in the given place.
1717
+ *
1718
+ * When retrieved, it will return the position of the top right corner in the
1719
+ * parent space.
1720
+ */
1721
+ readonly topRight: SimpleVector2Signal<this>;
1722
+ /**
1723
+ * The position of the bottom left corner of this node.
1724
+ *
1725
+ * @remarks
1726
+ * When set, this shortcut property will modify the node's position so that
1727
+ * the bottom left corner ends up in the given place.
1728
+ *
1729
+ * When retrieved, it will return the position of the bottom left corner in
1730
+ * the parent space.
1731
+ */
1732
+ readonly bottomLeft: SimpleVector2Signal<this>;
1733
+ /**
1734
+ * The position of the bottom right corner of this node.
1735
+ *
1736
+ * @remarks
1737
+ * When set, this shortcut property will modify the node's position so that
1738
+ * the bottom right corner ends up in the given place.
1739
+ *
1740
+ * When retrieved, it will return the position of the bottom right corner in
1741
+ * the parent space.
1742
+ */
1743
+ readonly bottomRight: SimpleVector2Signal<this>;
1744
+ readonly clip: SimpleSignal<boolean, this>;
1745
+ element: HTMLElement;
1746
+ styles: CSSStyleDeclaration;
1747
+ protected readonly sizeLockCounter: SimpleSignal<number, this>;
1748
+ constructor(props: LayoutProps);
1749
+ lockSize(): void;
1750
+ releaseSize(): void;
1751
+ protected parentTransform(): Layout | null;
1752
+ anchorPosition(): Vector2;
1753
+ /**
1754
+ * Get the resolved layout mode of this node.
1755
+ *
1756
+ * @remarks
1757
+ * When the mode is `null`, its value will be inherited from the parent.
1758
+ *
1759
+ * Use {@link layout} to get the raw mode set for this node (without
1760
+ * inheritance).
1761
+ */
1762
+ layoutEnabled(): boolean;
1763
+ isLayoutRoot(): boolean;
1764
+ localToParent(): DOMMatrix;
1765
+ /**
1766
+ * A simplified version of {@link localToParent} matrix used for transforming
1767
+ * direction vectors.
1768
+ *
1769
+ * @internal
1770
+ */
1771
+ protected scalingRotationMatrix(): DOMMatrix;
1772
+ protected getComputedLayout(): BBox;
1773
+ computedPosition(): Vector2;
1774
+ protected computedSize(): Vector2;
1775
+ /**
1776
+ * Find the closest layout root and apply any new layout changes.
1777
+ */
1778
+ protected requestLayoutUpdate(): void;
1779
+ protected appendedToView(): boolean;
1780
+ /**
1781
+ * Apply any new layout changes to this node and its children.
1782
+ */
1783
+ protected updateLayout(): void;
1784
+ protected layoutChildren(): Layout[];
1785
+ /**
1786
+ * Apply any new font changes to this node and all of its ancestors.
1787
+ */
1788
+ protected requestFontUpdate(): void;
1789
+ protected getCacheBBox(): BBox;
1790
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
1791
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
1792
+ getOriginDelta(origin: Origin): Vector2;
1793
+ /**
1794
+ * Update the offset of this node and adjust the position to keep it in the
1795
+ * same place.
1796
+ *
1797
+ * @param offset - The new offset.
1798
+ */
1799
+ moveOffset(offset: Vector2): void;
1800
+ protected parsePixels(value: number | null): string;
1801
+ protected parseLength(value: number | string | null): string;
1802
+ protected applyFlex(): void;
1803
+ protected applyFont(): void;
1804
+ dispose(): void;
1805
+ hit(position: Vector2): Node | null;
1806
+ }
1807
+
1808
+ interface ShapeProps extends LayoutProps {
1809
+ fill?: SignalValue<PossibleCanvasStyle>;
1810
+ stroke?: SignalValue<PossibleCanvasStyle>;
1811
+ strokeFirst?: SignalValue<boolean>;
1812
+ lineWidth?: SignalValue<number>;
1813
+ lineJoin?: SignalValue<CanvasLineJoin>;
1814
+ lineCap?: SignalValue<CanvasLineCap>;
1815
+ lineDash?: SignalValue<number[]>;
1816
+ lineDashOffset?: SignalValue<number>;
1817
+ antialiased?: SignalValue<boolean>;
1818
+ }
1819
+ declare abstract class Shape extends Layout {
1820
+ readonly fill: CanvasStyleSignal<this>;
1821
+ readonly stroke: CanvasStyleSignal<this>;
1822
+ readonly strokeFirst: SimpleSignal<boolean, this>;
1823
+ readonly lineWidth: SimpleSignal<number, this>;
1824
+ readonly lineJoin: SimpleSignal<CanvasLineJoin, this>;
1825
+ readonly lineCap: SimpleSignal<CanvasLineCap, this>;
1826
+ readonly lineDash: SimpleSignal<number[], this>;
1827
+ readonly lineDashOffset: SimpleSignal<number, this>;
1828
+ readonly antialiased: SimpleSignal<boolean, this>;
1829
+ protected readonly rippleStrength: SimpleSignal<number, this>;
1830
+ protected rippleSize(): number;
1831
+ constructor(props: ShapeProps);
1832
+ protected applyText(context: CanvasRenderingContext2D): void;
1833
+ protected applyStyle(context: CanvasRenderingContext2D): void;
1834
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
1835
+ protected drawShape(context: CanvasRenderingContext2D): void;
1836
+ protected getCacheBBox(): BBox;
1837
+ protected getPath(): Path2D;
1838
+ protected getRipplePath(): Path2D;
1839
+ protected drawRipple(context: CanvasRenderingContext2D): void;
1840
+ ripple(duration?: number): Generator<void | _twick_core.ThreadGenerator | Promise<any> | _twick_core.Promisable<any>, void, any>;
1841
+ }
1842
+
1843
+ interface CurveProps extends ShapeProps {
1844
+ /**
1845
+ * {@inheritDoc Curve.closed}
1846
+ */
1847
+ closed?: SignalValue<boolean>;
1848
+ /**
1849
+ * {@inheritDoc Curve.start}
1850
+ */
1851
+ start?: SignalValue<number>;
1852
+ /**
1853
+ * {@inheritDoc Curve.startOffset}
1854
+ */
1855
+ startOffset?: SignalValue<number>;
1856
+ /**
1857
+ * {@inheritDoc Curve.startArrow}
1858
+ */
1859
+ startArrow?: SignalValue<boolean>;
1860
+ /**
1861
+ * {@inheritDoc Curve.end}
1862
+ */
1863
+ end?: SignalValue<number>;
1864
+ /**
1865
+ * {@inheritDoc Curve.endOffset}
1866
+ */
1867
+ endOffset?: SignalValue<number>;
1868
+ /**
1869
+ * {@inheritDoc Curve.endArrow}
1870
+ */
1871
+ endArrow?: SignalValue<boolean>;
1872
+ /**
1873
+ * {@inheritDoc Curve.arrowSize}
1874
+ */
1875
+ arrowSize?: SignalValue<number>;
1876
+ }
1877
+ declare abstract class Curve extends Shape {
1878
+ /**
1879
+ * Whether the curve should be closed.
1880
+ *
1881
+ * @remarks
1882
+ * Closed curves have their start and end points connected.
1883
+ */
1884
+ readonly closed: SimpleSignal<boolean, this>;
1885
+ /**
1886
+ * A percentage from the start before which the curve should be clipped.
1887
+ *
1888
+ * @remarks
1889
+ * The portion of the curve that comes before the given percentage will be
1890
+ * made invisible.
1891
+ *
1892
+ * This property is usefully for animating the curve appearing on the screen.
1893
+ * The value of `0` means the very start of the curve (accounting for the
1894
+ * {@link startOffset}) while `1` means the very end (accounting for the
1895
+ * {@link endOffset}).
1896
+ */
1897
+ readonly start: SimpleSignal<number, this>;
1898
+ /**
1899
+ * The offset in pixels from the start of the curve.
1900
+ *
1901
+ * @remarks
1902
+ * This property lets you specify where along the defined curve the actual
1903
+ * visible portion starts. For example, setting it to `20` will make the first
1904
+ * 20 pixels of the curve invisible.
1905
+ *
1906
+ * This property is useful for trimming the curve using a fixed distance.
1907
+ * If you want to animate the curve appearing on the screen, use {@link start}
1908
+ * instead.
1909
+ */
1910
+ readonly startOffset: SimpleSignal<number, this>;
1911
+ /**
1912
+ * Whether to display an arrow at the start of the visible curve.
1913
+ *
1914
+ * @remarks
1915
+ * Use {@link arrowSize} to control the size of the arrow.
1916
+ */
1917
+ readonly startArrow: SimpleSignal<boolean, this>;
1918
+ /**
1919
+ * A percentage from the start after which the curve should be clipped.
1920
+ *
1921
+ * @remarks
1922
+ * The portion of the curve that comes after the given percentage will be
1923
+ * made invisible.
1924
+ *
1925
+ * This property is usefully for animating the curve appearing on the screen.
1926
+ * The value of `0` means the very start of the curve (accounting for the
1927
+ * {@link startOffset}) while `1` means the very end (accounting for the
1928
+ * {@link endOffset}).
1929
+ */
1930
+ readonly end: SimpleSignal<number, this>;
1931
+ /**
1932
+ * The offset in pixels from the end of the curve.
1933
+ *
1934
+ * @remarks
1935
+ * This property lets you specify where along the defined curve the actual
1936
+ * visible portion ends. For example, setting it to `20` will make the last
1937
+ * 20 pixels of the curve invisible.
1938
+ *
1939
+ * This property is useful for trimming the curve using a fixed distance.
1940
+ * If you want to animate the curve appearing on the screen, use {@link end}
1941
+ * instead.
1942
+ */
1943
+ readonly endOffset: SimpleSignal<number, this>;
1944
+ /**
1945
+ * Whether to display an arrow at the end of the visible curve.
1946
+ *
1947
+ * @remarks
1948
+ * Use {@link arrowSize} to control the size of the arrow.
1949
+ */
1950
+ readonly endArrow: SimpleSignal<boolean, this>;
1951
+ /**
1952
+ * Controls the size of the end and start arrows.
1953
+ *
1954
+ * @remarks
1955
+ * To make the arrows visible make sure to enable {@link startArrow} and/or
1956
+ * {@link endArrow}.
1957
+ */
1958
+ readonly arrowSize: SimpleSignal<number, this>;
1959
+ protected canHaveSubpath: boolean;
1960
+ protected desiredSize(): SerializedVector2<DesiredLength>;
1961
+ constructor(props: CurveProps);
1962
+ protected abstract childrenBBox(): BBox;
1963
+ abstract profile(): CurveProfile;
1964
+ /**
1965
+ * Convert a percentage along the curve to a distance.
1966
+ *
1967
+ * @remarks
1968
+ * The returned distance is given in relation to the full curve, not
1969
+ * accounting for {@link startOffset} and {@link endOffset}.
1970
+ *
1971
+ * @param value - The percentage along the curve.
1972
+ */
1973
+ percentageToDistance(value: number): number;
1974
+ /**
1975
+ * Convert a distance along the curve to a percentage.
1976
+ *
1977
+ * @remarks
1978
+ * The distance should be given in relation to the full curve, not
1979
+ * accounting for {@link startOffset} and {@link endOffset}.
1980
+ *
1981
+ * @param value - The distance along the curve.
1982
+ */
1983
+ distanceToPercentage(value: number): number;
1984
+ /**
1985
+ * The base arc length of this curve.
1986
+ *
1987
+ * @remarks
1988
+ * This is the entire length of this curve, not accounting for
1989
+ * {@link startOffset | the offsets}.
1990
+ */
1991
+ baseArcLength(): number;
1992
+ /**
1993
+ * The offset arc length of this curve.
1994
+ *
1995
+ * @remarks
1996
+ * This is the length of the curve that accounts for
1997
+ * {@link startOffset | the offsets}.
1998
+ */
1999
+ offsetArcLength(): number;
2000
+ /**
2001
+ * The visible arc length of this curve.
2002
+ *
2003
+ * @remarks
2004
+ * This arc length accounts for both the offset and the {@link start} and
2005
+ * {@link end} properties.
2006
+ */
2007
+ arcLength(): number;
2008
+ /**
2009
+ * The percentage of the curve that's currently visible.
2010
+ *
2011
+ * @remarks
2012
+ * The returned value is the ratio between the visible length (as defined by
2013
+ * {@link start} and {@link end}) and the offset length of the curve.
2014
+ */
2015
+ completion(): number;
2016
+ protected processSubpath(_path: Path2D, _startPoint: Vector2 | null, _endPoint: Vector2 | null): void;
2017
+ protected curveDrawingInfo(): CurveDrawingInfo;
2018
+ protected getPointAtDistance(value: number): CurvePoint;
2019
+ getPointAtPercentage(value: number): CurvePoint;
2020
+ protected getComputedLayout(): BBox;
2021
+ protected offsetComputedLayout(box: BBox): BBox;
2022
+ protected getPath(): Path2D;
2023
+ protected getCacheBBox(): BBox;
2024
+ protected lineWidthCoefficient(): number;
2025
+ /**
2026
+ * Check if the path requires a profile.
2027
+ *
2028
+ * @remarks
2029
+ * The profile is only required if certain features are used. Otherwise, the
2030
+ * profile generation can be skipped, and the curve can be drawn directly
2031
+ * using the 2D context.
2032
+ */
2033
+ protected requiresProfile(): boolean;
2034
+ protected drawShape(context: CanvasRenderingContext2D): void;
2035
+ private drawArrows;
2036
+ private drawArrow;
2037
+ }
2038
+
2039
+ interface RectProps extends CurveProps {
2040
+ /**
2041
+ * {@inheritDoc Rect.radius}
2042
+ */
2043
+ radius?: SignalValue<PossibleSpacing>;
2044
+ /**
2045
+ * {@inheritDoc Rect.smoothCorners}
2046
+ */
2047
+ smoothCorners?: SignalValue<boolean>;
2048
+ /**
2049
+ * {@inheritDoc Rect.cornerSharpness}
2050
+ */
2051
+ cornerSharpness?: SignalValue<number>;
2052
+ }
2053
+ declare class Rect extends Curve {
2054
+ /**
2055
+ * Rounds the corners of this rectangle.
2056
+ *
2057
+ * @remarks
2058
+ * The value represents the radius of the quarter circle that is used to round
2059
+ * the corners. If the value is a number, the same radius is used for all
2060
+ * corners. Passing an array of two to four numbers will set individual radii
2061
+ * for each corner. Individual radii correspond to different corners depending
2062
+ * on the number of values passed:
2063
+ *
2064
+ * ```ts
2065
+ * // top-left-and-bottom-right | top-right-and-bottom-left
2066
+ * [10, 30]
2067
+ * // top-left | top-right-and-bottom-left | bottom-right
2068
+ * [10, 20, 30]
2069
+ * // top-left | top-right | bottom-right | bottom-left
2070
+ * [10, 20, 30, 40]
2071
+ * ```
2072
+ *
2073
+ * @example
2074
+ * One uniform radius:
2075
+ * ```tsx
2076
+ * <Rect
2077
+ * size={320}
2078
+ * radius={40}
2079
+ * fill={'white'}
2080
+ * />
2081
+ * ```
2082
+ * @example
2083
+ * Individual radii for each corner:
2084
+ * ```tsx
2085
+ * <Rect
2086
+ * size={320}
2087
+ * radius={[10, 20, 30, 40]}
2088
+ * fill={'white'}
2089
+ * />
2090
+ * ```
2091
+ */
2092
+ readonly radius: SpacingSignal<this>;
2093
+ /**
2094
+ * Enables corner smoothing.
2095
+ *
2096
+ * @remarks
2097
+ * This property only affects the way rounded corners are drawn. To control
2098
+ * the corner radius use the {@link radius} property.
2099
+ *
2100
+ * When enabled, rounded corners are drawn continuously using Bézier curves
2101
+ * rather than quarter circles. The sharpness of the curve can be controlled
2102
+ * with {@link cornerSharpness}.
2103
+ *
2104
+ * You can read more about corner smoothing in
2105
+ * [this article by Nick Lawrence](https://uxplanet.org/ui-ux-design-corner-smoothing-720509d1ae48).
2106
+ *
2107
+ * @example
2108
+ * ```tsx
2109
+ * <Rect
2110
+ * width={300}
2111
+ * height={300}
2112
+ * smoothCorners={true}
2113
+ * />
2114
+ * ```
2115
+ */
2116
+ readonly smoothCorners: SimpleSignal<boolean, this>;
2117
+ /**
2118
+ * Controls the sharpness of {@link smoothCorners}.
2119
+ *
2120
+ * @remarks
2121
+ * This property only affects the way rounded corners are drawn. To control
2122
+ * the corner radius use the {@link radius} property.
2123
+ *
2124
+ * Requires {@link smoothCorners} to be enabled to have any effect.
2125
+ * By default, corner sharpness is set to `0.6` which represents a smooth,
2126
+ * circle-like rounding. At `0` the edges are squared off.
2127
+ *
2128
+ * @example
2129
+ * ```tsx
2130
+ * <Rect
2131
+ * size={300}
2132
+ * smoothCorners={true}
2133
+ * cornerSharpness={0.7}
2134
+ * />
2135
+ * ```
2136
+ */
2137
+ readonly cornerSharpness: SimpleSignal<number, this>;
2138
+ constructor(props: RectProps);
2139
+ profile(): CurveProfile;
2140
+ protected desiredSize(): SerializedVector2<DesiredLength>;
2141
+ protected offsetComputedLayout(box: BBox): BBox;
2142
+ protected childrenBBox(): BBox;
2143
+ protected getPath(): Path2D;
2144
+ protected getCacheBBox(): BBox;
2145
+ protected getRipplePath(): Path2D;
2146
+ }
2147
+
2148
+ interface MediaProps extends RectProps {
2149
+ src?: SignalValue<string>;
2150
+ loop?: SignalValue<boolean>;
2151
+ playbackRate?: number;
2152
+ volume?: number;
2153
+ time?: SignalValue<number>;
2154
+ play?: boolean;
2155
+ awaitCanPlay?: SignalValue<boolean>;
2156
+ allowVolumeAmplificationInPreview?: SignalValue<boolean>;
2157
+ }
2158
+ declare abstract class Media extends Rect {
2159
+ readonly src: SimpleSignal<string, this>;
2160
+ readonly loop: SimpleSignal<boolean, this>;
2161
+ readonly playbackRate: SimpleSignal<number, this>;
2162
+ protected readonly time: SimpleSignal<number, this>;
2163
+ protected readonly playing: SimpleSignal<boolean, this>;
2164
+ protected readonly awaitCanPlay: SimpleSignal<boolean, this>;
2165
+ protected readonly allowVolumeAmplificationInPreview: SimpleSignal<boolean, this>;
2166
+ protected volume: number;
2167
+ protected static readonly amplificationPool: Record<string, {
2168
+ audioContext: AudioContext;
2169
+ sourceNode: MediaElementAudioSourceNode;
2170
+ gainNode: GainNode;
2171
+ }>;
2172
+ protected lastTime: number;
2173
+ private isSchedulingPlay;
2174
+ constructor(props: MediaProps);
2175
+ isPlaying(): boolean;
2176
+ getCurrentTime(): number;
2177
+ getDuration(): number;
2178
+ getVolume(): number;
2179
+ getUrl(): string;
2180
+ dispose(): void;
2181
+ completion(): number;
2182
+ protected abstract mediaElement(): HTMLMediaElement;
2183
+ protected abstract seekedMedia(): HTMLMediaElement;
2184
+ protected abstract fastSeekedMedia(): HTMLMediaElement;
2185
+ protected abstract draw(context: CanvasRenderingContext2D): Promise<void>;
2186
+ protected setCurrentTime(value: number): void;
2187
+ setVolume(volume: number): void;
2188
+ protected amplify(node: HTMLMediaElement, volume: number): void;
2189
+ protected setPlaybackRate(playbackRate: number): void;
2190
+ protected scheduleSeek(time: number): void;
2191
+ /**
2192
+ * Waits for the canplay event to be fired before calling onCanPlay.
2193
+ *
2194
+ * If the media is already ready to play, onCanPlay is called immediately.
2195
+ * @param onCanPlay - The function to call when the media is ready to play.
2196
+ * @returns
2197
+ */
2198
+ protected waitForCanPlay(media: HTMLMediaElement, onCanPlay: () => void): void;
2199
+ /**
2200
+ * Returns true if we should wait for the media to be ready to play.
2201
+ */
2202
+ protected waitForCanPlayNecessary(media: HTMLMediaElement): boolean;
2203
+ play(): void;
2204
+ protected schedulePlay(): void;
2205
+ private simplePlay;
2206
+ private actuallyPlay;
2207
+ pause(): void;
2208
+ clampTime(time: number): number;
2209
+ protected collectAsyncResources(): void;
2210
+ protected autoPlayBasedOnTwick(): void;
2211
+ protected getErrorReason(errCode?: number): string;
2212
+ protected isIOS(): boolean;
2213
+ }
2214
+
2215
+ declare class Audio extends Media {
2216
+ private static readonly pool;
2217
+ constructor(props: MediaProps);
2218
+ protected mediaElement(): HTMLAudioElement;
2219
+ protected seekedMedia(): HTMLAudioElement;
2220
+ protected fastSeekedMedia(): HTMLAudioElement;
2221
+ protected audio(): HTMLAudioElement;
2222
+ protected seekedAudio(): HTMLAudioElement;
2223
+ protected fastSeekedAudio(): HTMLAudioElement;
2224
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
2225
+ }
2226
+
2227
+ declare class CircleSegment extends Segment {
2228
+ private center;
2229
+ private radius;
2230
+ private from;
2231
+ private to;
2232
+ private counter;
2233
+ private readonly length;
2234
+ private readonly angle;
2235
+ readonly points: Vector2[];
2236
+ constructor(center: Vector2, radius: number, from: Vector2, to: Vector2, counter: boolean);
2237
+ get arcLength(): number;
2238
+ draw(context: CanvasRenderingContext2D | Path2D, from: number, to: number): [CurvePoint, CurvePoint];
2239
+ getPoint(distance: number): CurvePoint;
2240
+ }
2241
+
2242
+ /**
2243
+ * A polynomial in the form ax^3 + bx^2 + cx + d up to a cubic polynomial.
2244
+ *
2245
+ * Source code liberally taken from:
2246
+ * https://github.com/FreyaHolmer/Mathfs/blob/master/Runtime/Curves/Polynomial.cs
2247
+ */
2248
+ declare class Polynomial {
2249
+ readonly c0: number;
2250
+ readonly c1: number;
2251
+ readonly c2: number;
2252
+ readonly c3: number;
2253
+ /**
2254
+ * Constructs a constant polynomial
2255
+ *
2256
+ * @param c0 - The constant coefficient
2257
+ */
2258
+ static constant(c0: number): Polynomial;
2259
+ /**
2260
+ * Constructs a linear polynomial
2261
+ *
2262
+ * @param c0 - The constant coefficient
2263
+ * @param c1 - The linear coefficient
2264
+ */
2265
+ static linear(c0: number, c1: number): Polynomial;
2266
+ /**
2267
+ * Constructs a quadratic polynomial
2268
+ *
2269
+ * @param c0 - The constant coefficient
2270
+ * @param c1 - The linear coefficient
2271
+ * @param c2 - The quadratic coefficient
2272
+ */
2273
+ static quadratic(c0: number, c1: number, c2: number): Polynomial;
2274
+ /**
2275
+ * Constructs a cubic polynomial
2276
+ *
2277
+ * @param c0 - The constant coefficient
2278
+ * @param c1 - The linear coefficient
2279
+ * @param c2 - The quadratic coefficient
2280
+ * @param c3 - The cubic coefficient
2281
+ */
2282
+ static cubic(c0: number, c1: number, c2: number, c3: number): Polynomial;
2283
+ /**
2284
+ * The degree of the polynomial
2285
+ */
2286
+ get degree(): number;
2287
+ /**
2288
+ * @param c0 - The constant coefficient
2289
+ */
2290
+ constructor(c0: number);
2291
+ /**
2292
+ * @param c0 - The constant coefficient
2293
+ * @param c1 - The linear coefficient
2294
+ */
2295
+ constructor(c0: number, c1: number);
2296
+ /**
2297
+ * @param c0 - The constant coefficient
2298
+ * @param c1 - The linear coefficient
2299
+ * @param c2 - The quadratic coefficient
2300
+ */
2301
+ constructor(c0: number, c1: number, c2: number);
2302
+ /**
2303
+ * @param c0 - The constant coefficient
2304
+ * @param c1 - The linear coefficient
2305
+ * @param c2 - The quadratic coefficient
2306
+ * @param c3 - The cubic coefficient
2307
+ */
2308
+ constructor(c0: number, c1: number, c2: number, c3: number);
2309
+ /**
2310
+ * Return the nth derivative of the polynomial.
2311
+ *
2312
+ * @param n - The number of times to differentiate the polynomial.
2313
+ */
2314
+ differentiate(n?: number): Polynomial;
2315
+ /**
2316
+ * Evaluate the polynomial at the given value t.
2317
+ *
2318
+ * @param t - The value to sample at
2319
+ */
2320
+ eval(t: number): number;
2321
+ /**
2322
+ * Evaluate the nth derivative of the polynomial at the given value t.
2323
+ *
2324
+ * @param t - The value to sample at
2325
+ * @param derivative - The derivative of the polynomial to sample from
2326
+ */
2327
+ eval(t: number, derivative: number): number;
2328
+ /**
2329
+ * Split the polynomial into two polynomials of the same overall shape.
2330
+ *
2331
+ * @param u - The point at which to split the polynomial.
2332
+ */
2333
+ split(u: number): [Polynomial, Polynomial];
2334
+ /**
2335
+ * Calculate the roots (values where this polynomial = 0).
2336
+ *
2337
+ * @remarks
2338
+ * Depending on the degree of the polynomial, returns between 0 and 3 results.
2339
+ */
2340
+ roots(): number[];
2341
+ /**
2342
+ * Calculate the local extrema of the polynomial.
2343
+ */
2344
+ localExtrema(): number[];
2345
+ /**
2346
+ * Calculate the local extrema of the polynomial in the unit interval.
2347
+ */
2348
+ localExtrema01(): number[];
2349
+ /**
2350
+ * Return the output value range within the unit interval.
2351
+ */
2352
+ outputRange01(): number[];
2353
+ private solveCubicRoots;
2354
+ private solveDepressedCubicRoots;
2355
+ private solveQuadraticRoots;
2356
+ private solveLinearRoot;
2357
+ private almostZero;
2358
+ }
2359
+
2360
+ declare class Polynomial2D {
2361
+ readonly c0: Vector2 | Polynomial;
2362
+ readonly c1: Vector2 | Polynomial;
2363
+ readonly c2?: Vector2 | undefined;
2364
+ readonly c3?: Vector2 | undefined;
2365
+ readonly x: Polynomial;
2366
+ readonly y: Polynomial;
2367
+ constructor(c0: Vector2, c1: Vector2, c2: Vector2, c3: Vector2);
2368
+ constructor(c0: Vector2, c1: Vector2, c2: Vector2);
2369
+ constructor(x: Polynomial, y: Polynomial);
2370
+ eval(t: number, derivative?: number): Vector2;
2371
+ split(u: number): [Polynomial2D, Polynomial2D];
2372
+ differentiate(n?: number): Polynomial2D;
2373
+ evalDerivative(t: number): Vector2;
2374
+ /**
2375
+ * Calculate the tight axis-aligned bounds of the curve in the unit interval.
2376
+ */
2377
+ getBounds(): BBox;
2378
+ }
2379
+
2380
+ /**
2381
+ * Class to uniformly sample points on a given polynomial curve.
2382
+ *
2383
+ * @remarks
2384
+ * In order to uniformly sample points from non-linear curves, this sampler
2385
+ * re-parameterizes the curve by arclength.
2386
+ */
2387
+ declare class UniformPolynomialCurveSampler {
2388
+ private readonly curve;
2389
+ private sampledDistances;
2390
+ /**
2391
+ * @param curve - The curve to sample
2392
+ * @param samples - How many points to sample from the provided curve. The
2393
+ * more points get sampled, the higher the resolution–and
2394
+ * therefore precision–of the sampler.
2395
+ */
2396
+ constructor(curve: PolynomialSegment, samples?: number);
2397
+ /**
2398
+ * Discard all previously sampled points and resample the provided number of
2399
+ * points from the curve.
2400
+ *
2401
+ * @param samples - The number of points to sample.
2402
+ */
2403
+ resample(samples: number): void;
2404
+ /**
2405
+ * Return the point at the provided distance along the sampled curve's
2406
+ * arclength.
2407
+ *
2408
+ * @param distance - The distance along the curve's arclength for which to
2409
+ * retrieve the point.
2410
+ */
2411
+ pointAtDistance(distance: number): CurvePoint;
2412
+ /**
2413
+ * Return the t value for the point at the provided distance along the sampled
2414
+ * curve's arc length.
2415
+ *
2416
+ * @param distance - The distance along the arclength
2417
+ */
2418
+ distanceToT(distance: number): number;
2419
+ }
2420
+
2421
+ declare abstract class PolynomialSegment extends Segment {
2422
+ protected readonly curve: Polynomial2D;
2423
+ protected readonly length: number;
2424
+ protected readonly pointSampler: UniformPolynomialCurveSampler;
2425
+ get arcLength(): number;
2426
+ abstract get points(): Vector2[];
2427
+ protected constructor(curve: Polynomial2D, length: number);
2428
+ getBBox(): BBox;
2429
+ /**
2430
+ * Evaluate the polynomial at the given t value.
2431
+ *
2432
+ * @param t - The t value at which to evaluate the curve.
2433
+ */
2434
+ eval(t: number): CurvePoint;
2435
+ /**
2436
+ * Split the curve into two separate polynomials at the given t value. The two
2437
+ * resulting curves form the same overall shape as the original curve.
2438
+ *
2439
+ * @param t - The t value at which to split the curve.
2440
+ */
2441
+ abstract split(t: number): [PolynomialSegment, PolynomialSegment];
2442
+ getPoint(distance: number): CurvePoint;
2443
+ transformPoints(matrix: DOMMatrix): Vector2[];
2444
+ /**
2445
+ * Return the tangent of the point that sits at the provided t value on the
2446
+ * curve.
2447
+ *
2448
+ * @param t - The t value at which to evaluate the curve.
2449
+ */
2450
+ tangent(t: number): Vector2;
2451
+ draw(context: CanvasRenderingContext2D | Path2D, start?: number, end?: number, move?: boolean): [CurvePoint, CurvePoint];
2452
+ protected abstract doDraw(context: CanvasRenderingContext2D | Path2D): void;
2453
+ }
2454
+
2455
+ /**
2456
+ * A spline segment representing a cubic Bézier curve.
2457
+ */
2458
+ declare class CubicBezierSegment extends PolynomialSegment {
2459
+ readonly p0: Vector2;
2460
+ readonly p1: Vector2;
2461
+ readonly p2: Vector2;
2462
+ readonly p3: Vector2;
2463
+ private static el;
2464
+ get points(): Vector2[];
2465
+ constructor(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2);
2466
+ split(t: number): [PolynomialSegment, PolynomialSegment];
2467
+ protected doDraw(context: CanvasRenderingContext2D | Path2D): void;
2468
+ protected static getLength(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2): number;
2469
+ }
2470
+
2471
+ type KnotAutoHandles = {
2472
+ start: number;
2473
+ end: number;
2474
+ };
2475
+ interface KnotInfo {
2476
+ position: Vector2;
2477
+ startHandle: Vector2;
2478
+ endHandle: Vector2;
2479
+ auto: KnotAutoHandles;
2480
+ }
2481
+
2482
+ /**
2483
+ * Calculate the curve profile of a spline based on a set of knots.
2484
+ *
2485
+ * @param knots - The knots defining the spline
2486
+ * @param closed - Whether the spline should be closed or not
2487
+ * @param smoothness - The desired smoothness of the spline when using auto
2488
+ * calculated handles.
2489
+ */
2490
+ declare function getBezierSplineProfile(knots: KnotInfo[], closed: boolean, smoothness: number): CurveProfile;
2491
+
2492
+ declare function getCircleProfile(size: Vector2, startAngle: number, endAngle: number, closed: boolean, counterclockwise?: boolean): CurveProfile;
2493
+
2494
+ declare function getPointAtDistance(profile: CurveProfile, distance: number): CurvePoint;
2495
+
2496
+ declare function getPolylineProfile(points: readonly Vector2[], radius: number, closed: boolean): CurveProfile;
2497
+
2498
+ declare function getRectProfile(rect: BBox, radius: Spacing, smoothCorners: boolean, cornerSharpness: number): CurveProfile;
2499
+
2500
+ declare class LineSegment extends Segment {
2501
+ readonly from: Vector2;
2502
+ readonly to: Vector2;
2503
+ private readonly length;
2504
+ private readonly vector;
2505
+ private readonly normal;
2506
+ readonly points: Vector2[];
2507
+ constructor(from: Vector2, to: Vector2);
2508
+ get arcLength(): number;
2509
+ draw(context: CanvasRenderingContext2D | Path2D, start?: number, end?: number, move?: boolean): [CurvePoint, CurvePoint];
2510
+ getPoint(distance: number): CurvePoint;
2511
+ }
2512
+
2513
+ /**
2514
+ * A spline segment representing a quadratic Bézier curve.
2515
+ */
2516
+ declare class QuadBezierSegment extends PolynomialSegment {
2517
+ readonly p0: Vector2;
2518
+ readonly p1: Vector2;
2519
+ readonly p2: Vector2;
2520
+ private static el;
2521
+ get points(): Vector2[];
2522
+ constructor(p0: Vector2, p1: Vector2, p2: Vector2);
2523
+ split(t: number): [PolynomialSegment, PolynomialSegment];
2524
+ protected static getLength(p0: Vector2, p1: Vector2, p2: Vector2): number;
2525
+ protected doDraw(context: CanvasRenderingContext2D | Path2D): void;
2526
+ }
2527
+
2528
+ interface BezierOverlayInfo {
2529
+ curve: Path2D;
2530
+ handleLines: Path2D;
2531
+ controlPoints: Vector2[];
2532
+ startPoint: Vector2;
2533
+ endPoint: Vector2;
2534
+ }
2535
+ declare abstract class Bezier extends Curve {
2536
+ profile(): CurveProfile;
2537
+ protected abstract segment(): PolynomialSegment;
2538
+ protected abstract overlayInfo(matrix: DOMMatrix): BezierOverlayInfo;
2539
+ protected childrenBBox(): BBox;
2540
+ protected desiredSize(): SerializedVector2<DesiredLength>;
2541
+ protected offsetComputedLayout(box: BBox): BBox;
2542
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
2543
+ }
2544
+
2545
+ interface CircleProps extends CurveProps {
2546
+ /**
2547
+ * {@inheritDoc Circle.startAngle}
2548
+ */
2549
+ startAngle?: SignalValue<number>;
2550
+ /**
2551
+ * {@inheritDoc Circle.endAngle}
2552
+ */
2553
+ endAngle?: SignalValue<number>;
2554
+ /**
2555
+ * {@inheritDoc Circle.counterclockwise}
2556
+ */
2557
+ counterclockwise?: SignalValue<boolean>;
2558
+ /**
2559
+ * {@inheritDoc Circle.closed}
2560
+ */
2561
+ closed?: SignalValue<boolean>;
2562
+ }
2563
+ /**
2564
+ * A node for drawing circular shapes.
2565
+ *
2566
+ * @remarks
2567
+ * This node can be used to render shapes such as: circle, ellipse, arc, and
2568
+ * sector (pie chart).
2569
+ *
2570
+ * @preview
2571
+ * ```tsx editor
2572
+ * // snippet Simple circle
2573
+ * import {makeScene2D, Circle} from '@twick/2d';
2574
+ *
2575
+ * export default makeScene2D(function* (view) {
2576
+ * view.add(
2577
+ * <Circle
2578
+ * size={160}
2579
+ * fill={'lightseagreen'}
2580
+ * />
2581
+ * );
2582
+ * });
2583
+ *
2584
+ * // snippet Ellipse
2585
+ * import {makeScene2D, Circle} from '@twick/2d';
2586
+ *
2587
+ * export default makeScene2D(function* (view) {
2588
+ * view.add(
2589
+ * <Circle
2590
+ * width={160}
2591
+ * height={80}
2592
+ * fill={'lightseagreen'}
2593
+ * />
2594
+ * );
2595
+ * });
2596
+ *
2597
+ * // snippet Sector (pie chart):
2598
+ * import {makeScene2D, Circle} from '@twick/2d';
2599
+ * import {createRef} from '@twick/core';
2600
+ *
2601
+ * export default makeScene2D(function* (view) {
2602
+ * const ref = createRef<Circle>();
2603
+ * view.add(
2604
+ * <Circle
2605
+ * ref={ref}
2606
+ * size={160}
2607
+ * fill={'lightseagreen'}
2608
+ * startAngle={30}
2609
+ * endAngle={270}
2610
+ * closed={true}
2611
+ * />
2612
+ * );
2613
+ *
2614
+ * yield* ref().startAngle(270, 2).to(30, 2);
2615
+ * });
2616
+ *
2617
+ * // snippet Arc:
2618
+ * import {makeScene2D, Circle} from '@twick/2d';
2619
+ * import {createRef} from '@twick/core';
2620
+ *
2621
+ * export default makeScene2D(function* (view) {
2622
+ * const ref = createRef<Circle>();
2623
+ * view.add(
2624
+ * <Circle
2625
+ * ref={ref}
2626
+ * size={160}
2627
+ * stroke={'lightseagreen'}
2628
+ * lineWidth={8}
2629
+ * startAngle={-90}
2630
+ * endAngle={90}
2631
+ * />
2632
+ * );
2633
+ *
2634
+ * yield* ref().startAngle(-270, 2).to(-90, 2);
2635
+ * });
2636
+ *
2637
+ * // snippet Curve properties:
2638
+ * import {makeScene2D, Circle} from '@twick/2d';
2639
+ * import {all, createRef, easeInCubic, easeOutCubic} from '@twick/core';
2640
+ *
2641
+ * export default makeScene2D(function* (view) {
2642
+ * const ref = createRef<Circle>();
2643
+ * view.add(
2644
+ * <Circle
2645
+ * ref={ref}
2646
+ * size={160}
2647
+ * stroke={'lightseagreen'}
2648
+ * lineWidth={8}
2649
+ * endAngle={270}
2650
+ * endArrow
2651
+ * />,
2652
+ * );
2653
+ *
2654
+ * yield* all(ref().start(1, 1), ref().rotation(180, 1, easeInCubic));
2655
+ * ref().start(0).end(0);
2656
+ * yield* all(ref().end(1, 1), ref().rotation(360, 1, easeOutCubic));
2657
+ * });
2658
+ * ```
2659
+ */
2660
+ declare class Circle extends Curve {
2661
+ /**
2662
+ * The starting angle in degrees for the circle sector.
2663
+ *
2664
+ * @remarks
2665
+ * This property can be used together with {@link startAngle} to turn this
2666
+ * circle into a sector (when using fill) or an arc (when using stroke).
2667
+ *
2668
+ * @defaultValue 0
2669
+ */
2670
+ readonly startAngle: SimpleSignal<number, this>;
2671
+ /**
2672
+ * The ending angle in degrees for the circle sector.
2673
+ *
2674
+ * @remarks
2675
+ * This property can be used together with {@link endAngle} to turn this
2676
+ * circle into a sector (when using fill) or an arc (when using stroke).
2677
+ *
2678
+ * @defaultValue 360
2679
+ */
2680
+ readonly endAngle: SimpleSignal<number, this>;
2681
+ /**
2682
+ * Whether the circle sector should be drawn counterclockwise.
2683
+ *
2684
+ * @remarks
2685
+ * By default, the circle begins at {@link startAngle} and is drawn clockwise
2686
+ * until reaching {@link endAngle}. Setting this property to true will reverse
2687
+ * this direction.
2688
+ */
2689
+ readonly counterclockwise: SimpleSignal<boolean, this>;
2690
+ /**
2691
+ * Whether the path of this circle should be closed.
2692
+ *
2693
+ * @remarks
2694
+ * When set to true, the path of this circle will start and end at the center.
2695
+ * This can be used to fine-tune how sectors are rendered.
2696
+ *
2697
+ * @example
2698
+ * A closed circle will look like a pie chart:
2699
+ * ```tsx
2700
+ * <Circle
2701
+ * size={300}
2702
+ * fill={'lightseagreen'}
2703
+ * endAngle={230}
2704
+ * closed={true}
2705
+ * />
2706
+ * ```
2707
+ * An open one will look like an arc:
2708
+ * ```tsx
2709
+ * <Circle
2710
+ * size={300}
2711
+ * stroke={'lightseagreen'}
2712
+ * lineWidth={8}
2713
+ * endAngle={230}
2714
+ * closed={false}
2715
+ * />
2716
+ * ```
2717
+ *
2718
+ * @defaultValue false
2719
+ */
2720
+ readonly closed: SimpleSignal<boolean, this>;
2721
+ constructor(props: CircleProps);
2722
+ profile(): CurveProfile;
2723
+ protected desiredSize(): SerializedVector2<DesiredLength>;
2724
+ protected offsetComputedLayout(box: BBox): BBox;
2725
+ protected childrenBBox(): BBox;
2726
+ protected getPath(): Path2D;
2727
+ protected getRipplePath(): Path2D;
2728
+ protected getCacheBBox(): BBox;
2729
+ protected createPath(expand?: number): Path2D;
2730
+ }
2731
+
2732
+ interface DrawTokenHook {
2733
+ (ctx: CanvasRenderingContext2D, text: string, position: Vector2, color: string, selection: number): void;
2734
+ }
2735
+ /**
2736
+ * Describes custom drawing logic used by the Code node.
2737
+ */
2738
+ interface DrawHooks {
2739
+ /**
2740
+ * Custom drawing logic for individual code tokens.
2741
+ *
2742
+ * @example
2743
+ * ```ts
2744
+ * token(ctx, text, position, color, selection) {
2745
+ * const blur = map(3, 0, selection);
2746
+ * const alpha = map(0.5, 1, selection);
2747
+ * ctx.globalAlpha *= alpha;
2748
+ * ctx.filter = `blur(${blur}px)`;
2749
+ * ctx.fillStyle = color;
2750
+ * ctx.fillText(text, position.x, position.y);
2751
+ * }
2752
+ * ```
2753
+ */
2754
+ token: DrawTokenHook;
2755
+ }
2756
+ interface CodeProps extends ShapeProps {
2757
+ /**
2758
+ * {@inheritDoc Code.highlighter}
2759
+ */
2760
+ highlighter?: SignalValue<CodeHighlighter | null>;
2761
+ /**
2762
+ * {@inheritDoc Code.code}
2763
+ */
2764
+ code?: SignalValue<PossibleCodeScope>;
2765
+ /**
2766
+ * {@inheritDoc Code.selection}
2767
+ */
2768
+ selection?: SignalValue<PossibleCodeSelection>;
2769
+ /**
2770
+ * {@inheritDoc Code.drawHooks}
2771
+ */
2772
+ drawHooks?: SignalValue<DrawHooks>;
2773
+ }
2774
+ /**
2775
+ * A node for displaying and animating code.
2776
+ *
2777
+ * @experimental
2778
+ *
2779
+ * @preview
2780
+ * ```tsx editor
2781
+ * import {parser} from '@lezer/javascript';
2782
+ * import {Code, LezerHighlighter, makeScene2D} from '@twick/2d';
2783
+ * import {createRef} from '@twick/core';
2784
+ *
2785
+ * export default makeScene2D(function* (view) {
2786
+ * LezerHighlighter.registerParser(parser);
2787
+ * const code = createRef<Code>();
2788
+ *
2789
+ * view.add(
2790
+ * <Code
2791
+ * ref={code}
2792
+ * offset={-1}
2793
+ * position={view.size().scale(-0.5).add(60)}
2794
+ * fontFamily={'JetBrains Mono, monospace'}
2795
+ * fontSize={36}
2796
+ * code={`\
2797
+ * function hello() {
2798
+ * console.log('Hello');
2799
+ * }`}
2800
+ * />,
2801
+ * );
2802
+ *
2803
+ * yield* code()
2804
+ * .code(
2805
+ * `\
2806
+ * function hello() {
2807
+ * console.warn('Hello World');
2808
+ * }`,
2809
+ * 1,
2810
+ * )
2811
+ * .wait(0.5)
2812
+ * .back(1)
2813
+ * .wait(0.5);
2814
+ * });
2815
+ * ```
2816
+ */
2817
+ declare class Code extends Shape {
2818
+ /**
2819
+ * Create a standalone code signal.
2820
+ *
2821
+ * @param initial - The initial code.
2822
+ * @param highlighter - Custom highlighter to use.
2823
+ */
2824
+ static createSignal(initial: PossibleCodeScope, highlighter?: SignalValue<CodeHighlighter>): CodeSignal<void>;
2825
+ static defaultHighlighter: CodeHighlighter | null;
2826
+ /**
2827
+ * The code highlighter to use for this code node.
2828
+ *
2829
+ * @remarks
2830
+ * Defaults to a shared {@link code.LezerHighlighter}.
2831
+ */
2832
+ readonly highlighter: SimpleSignal<CodeHighlighter | null, this>;
2833
+ /**
2834
+ * The code to display.
2835
+ */
2836
+ readonly code: CodeSignal<this>;
2837
+ /**
2838
+ * Custom drawing logic for the code.
2839
+ *
2840
+ * @remarks
2841
+ * Check out {@link DrawHooks} for available render hooks.
2842
+ *
2843
+ * @example
2844
+ * Make the unselected code blurry and transparent:
2845
+ * ```tsx
2846
+ * <Code
2847
+ * drawHooks={{
2848
+ * token(ctx, text, position, color, selection) {
2849
+ * const blur = map(3, 0, selection);
2850
+ * const alpha = map(0.5, 1, selection);
2851
+ * ctx.globalAlpha *= alpha;
2852
+ * ctx.filter = `blur(${blur}px)`;
2853
+ * ctx.fillStyle = color;
2854
+ * ctx.fillText(text, position.x, position.y);
2855
+ * },
2856
+ * }}
2857
+ * // ...
2858
+ * />
2859
+ * ```
2860
+ */
2861
+ readonly drawHooks: SimpleSignal<DrawHooks, this>;
2862
+ protected setDrawHooks(value: DrawHooks): void;
2863
+ /**
2864
+ * The currently selected code range.
2865
+ *
2866
+ * @remarks
2867
+ * Either a single {@link code.CodeRange} or an array of them
2868
+ * describing which parts of the code should be visually emphasized.
2869
+ *
2870
+ * You can use {@link code.word} and
2871
+ * {@link code.lines} to quickly create ranges.
2872
+ *
2873
+ * @example
2874
+ * The following will select the word "console" in the code.
2875
+ * Both lines and columns are 0-based. So it will select a 7-character-long
2876
+ * (`7`) word in the second line (`1`) starting at the third character (`2`).
2877
+ * ```tsx
2878
+ * <Code
2879
+ * selection={word(1, 2, 7)}
2880
+ * code={`\
2881
+ * function hello() => {
2882
+ * console.log('Hello');
2883
+ * }`}
2884
+ * // ...
2885
+ * />
2886
+ * ```
2887
+ */
2888
+ readonly selection: Signal<PossibleCodeSelection, CodeSelection, this>;
2889
+ oldSelection: CodeSelection | null;
2890
+ selectionProgress: SimpleSignal<number | null, void>;
2891
+ protected tweenSelection(value: CodeRange[], duration: number, timingFunction: TimingFunction): ThreadGenerator;
2892
+ /**
2893
+ * Get the currently displayed code as a string.
2894
+ */
2895
+ parsed(): string;
2896
+ highlighterCache(): {
2897
+ before: unknown;
2898
+ after: unknown;
2899
+ } | null;
2900
+ private cursorCache;
2901
+ private get cursor();
2902
+ constructor(props: CodeProps);
2903
+ /**
2904
+ * Create a child code signal.
2905
+ *
2906
+ * @param initial - The initial code.
2907
+ */
2908
+ createSignal(initial: PossibleCodeScope): CodeSignal<this>;
2909
+ /**
2910
+ * Find all code ranges that match the given pattern.
2911
+ *
2912
+ * @param pattern - Either a string or a regular expression to match.
2913
+ */
2914
+ findAllRanges(pattern: string | RegExp): CodeRange[];
2915
+ /**
2916
+ * Find the first code range that matches the given pattern.
2917
+ *
2918
+ * @param pattern - Either a string or a regular expression to match.
2919
+ */
2920
+ findFirstRange(pattern: string | RegExp): CodeRange;
2921
+ /**
2922
+ * Find the last code range that matches the given pattern.
2923
+ *
2924
+ * @param pattern - Either a string or a regular expression to match.
2925
+ */
2926
+ findLastRange(pattern: string | RegExp): CodeRange;
2927
+ /**
2928
+ * Return the bounding box of the given point (character) in the code.
2929
+ *
2930
+ * @remarks
2931
+ * The returned bound box is in local space of the `Code` node.
2932
+ *
2933
+ * @param point - The point to get the bounding box for.
2934
+ */
2935
+ getPointBbox(point: CodePoint): BBox;
2936
+ /**
2937
+ * Return bounding boxes of all characters in the selection.
2938
+ *
2939
+ * @remarks
2940
+ * The returned bound boxes are in local space of the `Code` node.
2941
+ * Each line of code has a separate bounding box.
2942
+ *
2943
+ * @param selection - The selection to get the bounding boxes for.
2944
+ */
2945
+ getSelectionBbox(selection: PossibleCodeSelection): BBox[];
2946
+ protected drawingInfo(): {
2947
+ fragments: CodeFragmentDrawingInfo[];
2948
+ verticalOffset: number;
2949
+ fontHeight: number;
2950
+ };
2951
+ protected desiredSize(): SerializedVector2<DesiredLength>;
2952
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
2953
+ protected applyText(context: CanvasRenderingContext2D): void;
2954
+ protected collectAsyncResources(): void;
2955
+ }
2956
+
2957
+ interface CubicBezierProps extends CurveProps {
2958
+ p0?: SignalValue<PossibleVector2>;
2959
+ p0X?: SignalValue<number>;
2960
+ p0Y?: SignalValue<number>;
2961
+ p1?: SignalValue<PossibleVector2>;
2962
+ p1X?: SignalValue<number>;
2963
+ p1Y?: SignalValue<number>;
2964
+ p2?: SignalValue<PossibleVector2>;
2965
+ p2X?: SignalValue<number>;
2966
+ p2Y?: SignalValue<number>;
2967
+ p3?: SignalValue<PossibleVector2>;
2968
+ p3X?: SignalValue<number>;
2969
+ p3Y?: SignalValue<number>;
2970
+ }
2971
+ /**
2972
+ * A node for drawing a cubic Bézier curve.
2973
+ *
2974
+ * @preview
2975
+ * ```tsx editor
2976
+ * import {makeScene2D, CubicBezier} from '@twick/2d';
2977
+ * import {createRef} from '@twick/core';
2978
+ *
2979
+ * export default makeScene2D(function* (view) {
2980
+ * const bezier = createRef<CubicBezier>();
2981
+ *
2982
+ * view.add(
2983
+ * <CubicBezier
2984
+ * ref={bezier}
2985
+ * lineWidth={4}
2986
+ * stroke={'lightseagreen'}
2987
+ * p0={[-200, -100]}
2988
+ * p1={[100, -100]}
2989
+ * p2={[-100, 100]}
2990
+ * p3={[200, 100]}
2991
+ * end={0}
2992
+ * />
2993
+ * );
2994
+ *
2995
+ * yield* bezier().end(1, 1);
2996
+ * yield* bezier().start(1, 1).to(0, 1);
2997
+ * });
2998
+ * ```
2999
+ */
3000
+ declare class CubicBezier extends Bezier {
3001
+ /**
3002
+ * The start point of the Bézier curve.
3003
+ */
3004
+ readonly p0: Vector2Signal<this>;
3005
+ /**
3006
+ * The first control point of the Bézier curve.
3007
+ */
3008
+ readonly p1: Vector2Signal<this>;
3009
+ /**
3010
+ * The second control point of the Bézier curve.
3011
+ */
3012
+ readonly p2: Vector2Signal<this>;
3013
+ /**
3014
+ * The end point of the Bézier curve.
3015
+ */
3016
+ readonly p3: Vector2Signal<this>;
3017
+ constructor(props: CubicBezierProps);
3018
+ protected segment(): PolynomialSegment;
3019
+ protected overlayInfo(matrix: DOMMatrix): BezierOverlayInfo;
3020
+ }
3021
+
3022
+ interface GridProps extends ShapeProps {
3023
+ /**
3024
+ * {@inheritDoc Grid.spacing}
3025
+ */
3026
+ spacing?: SignalValue<PossibleVector2>;
3027
+ /**
3028
+ * {@inheritDoc Grid.start}
3029
+ */
3030
+ start?: SignalValue<number>;
3031
+ /**
3032
+ * {@inheritDoc Grid.end}
3033
+ */
3034
+ end?: SignalValue<number>;
3035
+ }
3036
+ /**
3037
+ * A node for drawing a two-dimensional grid.
3038
+ *
3039
+ * @preview
3040
+ * ```tsx editor
3041
+ * import {Grid, makeScene2D} from '@twick/2d';
3042
+ * import {all, createRef} from '@twick/core';
3043
+ *
3044
+ * export default makeScene2D(function* (view) {
3045
+ * const grid = createRef<Grid>();
3046
+ *
3047
+ * view.add(
3048
+ * <Grid
3049
+ * ref={grid}
3050
+ * width={'100%'}
3051
+ * height={'100%'}
3052
+ * stroke={'#666'}
3053
+ * start={0}
3054
+ * end={1}
3055
+ * />,
3056
+ * );
3057
+ *
3058
+ * yield* all(
3059
+ * grid().end(0.5, 1).to(1, 1).wait(1),
3060
+ * grid().start(0.5, 1).to(0, 1).wait(1),
3061
+ * );
3062
+ * });
3063
+ * ```
3064
+ */
3065
+ declare class Grid extends Shape {
3066
+ /**
3067
+ * The spacing between the grid lines.
3068
+ */
3069
+ readonly spacing: Vector2Signal<this>;
3070
+ /**
3071
+ * The percentage that should be clipped from the beginning of each grid line.
3072
+ *
3073
+ * @remarks
3074
+ * The portion of each grid line that comes before the given percentage will
3075
+ * be made invisible.
3076
+ *
3077
+ * This property is useful for animating the grid appearing on-screen.
3078
+ */
3079
+ readonly start: SimpleSignal<number, this>;
3080
+ /**
3081
+ * The percentage that should be clipped from the end of each grid line.
3082
+ *
3083
+ * @remarks
3084
+ * The portion of each grid line that comes after the given percentage will
3085
+ * be made invisible.
3086
+ *
3087
+ * This property is useful for animating the grid appearing on-screen.
3088
+ */
3089
+ readonly end: SimpleSignal<number, this>;
3090
+ constructor(props: GridProps);
3091
+ protected drawShape(context: CanvasRenderingContext2D): void;
3092
+ private mapPoints;
3093
+ }
3094
+
3095
+ interface ImgProps extends RectProps {
3096
+ /**
3097
+ * {@inheritDoc Img.src}
3098
+ */
3099
+ src?: SignalValue<string | null>;
3100
+ /**
3101
+ * {@inheritDoc Img.alpha}
3102
+ */
3103
+ alpha?: SignalValue<number>;
3104
+ /**
3105
+ * {@inheritDoc Img.smoothing}
3106
+ */
3107
+ smoothing?: SignalValue<boolean>;
3108
+ }
3109
+ /**
3110
+ * A node for displaying images.
3111
+ *
3112
+ * @preview
3113
+ * ```tsx editor
3114
+ * import {Img} from '@twick/2d';
3115
+ * import {all, waitFor} from '@twick/core';
3116
+ * import {createRef} from '@twick/core';
3117
+ * import {makeScene2D} from '@twick/2d';
3118
+ *
3119
+ * export default makeScene2D(function* (view) {
3120
+ * const ref = createRef<Img>();
3121
+ * yield view.add(
3122
+ * <Img
3123
+ * ref={ref}
3124
+ * src="https://images.unsplash.com/photo-1679218407381-a6f1660d60e9"
3125
+ * width={300}
3126
+ * radius={20}
3127
+ * />,
3128
+ * );
3129
+ *
3130
+ * // set the background using the color sampled from the image:
3131
+ * ref().fill(ref().getColorAtPoint(0));
3132
+ *
3133
+ * yield* all(
3134
+ * ref().size([100, 100], 1).to([300, null], 1),
3135
+ * ref().radius(50, 1).to(20, 1),
3136
+ * ref().alpha(0, 1).to(1, 1),
3137
+ * );
3138
+ * yield* waitFor(0.5);
3139
+ * });
3140
+ * ```
3141
+ */
3142
+ declare class Img extends Rect {
3143
+ private static pool;
3144
+ /**
3145
+ * The source of this image.
3146
+ *
3147
+ * @example
3148
+ * Using a local image:
3149
+ * ```tsx
3150
+ * import image from './example.png';
3151
+ * // ...
3152
+ * view.add(<Img src={image} />)
3153
+ * ```
3154
+ * Loading an image from the internet:
3155
+ * ```tsx
3156
+ * view.add(<Img src="https://example.com/image.png" />)
3157
+ * ```
3158
+ */
3159
+ readonly src: SimpleSignal<string, this>;
3160
+ /**
3161
+ * The alpha value of this image.
3162
+ *
3163
+ * @remarks
3164
+ * Unlike opacity, the alpha value affects only the image itself, leaving the
3165
+ * fill, stroke, and children intact.
3166
+ */
3167
+ readonly alpha: SimpleSignal<number, this>;
3168
+ /**
3169
+ * Whether the image should be smoothed.
3170
+ *
3171
+ * @remarks
3172
+ * When disabled, the image will be scaled using the nearest neighbor
3173
+ * interpolation with no smoothing. The resulting image will appear pixelated.
3174
+ *
3175
+ * @defaultValue true
3176
+ */
3177
+ readonly smoothing: SimpleSignal<boolean, this>;
3178
+ constructor(props: ImgProps);
3179
+ protected desiredSize(): SerializedVector2<DesiredLength>;
3180
+ protected image(): HTMLImageElement;
3181
+ protected imageCanvas(): CanvasRenderingContext2D;
3182
+ protected filledImageCanvas(): CanvasRenderingContext2D;
3183
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
3184
+ protected applyFlex(): void;
3185
+ /**
3186
+ * Get color of the image at the given position.
3187
+ *
3188
+ * @param position - The position in local space at which to sample the color.
3189
+ */
3190
+ getColorAtPoint(position: PossibleVector2): Color;
3191
+ /**
3192
+ * The natural size of this image.
3193
+ *
3194
+ * @remarks
3195
+ * The natural size is the size of the source image unaffected by the size
3196
+ * and scale properties.
3197
+ */
3198
+ naturalSize(): Vector2;
3199
+ /**
3200
+ * Get color of the image at the given pixel.
3201
+ *
3202
+ * @param position - The pixel's position.
3203
+ */
3204
+ getPixelColor(position: PossibleVector2): Color;
3205
+ protected collectAsyncResources(): void;
3206
+ }
3207
+
3208
+ interface IconProps extends ImgProps {
3209
+ /**
3210
+ * {@inheritDoc Icon.icon}
3211
+ */
3212
+ icon: SignalValue<string>;
3213
+ /**
3214
+ * {@inheritDoc Icon.color}
3215
+ */
3216
+ color?: SignalValue<PossibleColor>;
3217
+ }
3218
+ /**
3219
+ * An Icon Component that provides easy access to over 150k icons.
3220
+ * See https://icones.js.org/collection/all for all available Icons.
3221
+ */
3222
+ declare class Icon extends Img {
3223
+ /**
3224
+ * The identifier of the icon.
3225
+ *
3226
+ * @remarks
3227
+ * You can find identifiers on [Icônes](https://icones.js.org).
3228
+ * They can look like this:
3229
+ * * `mdi:language-typescript`
3230
+ * * `ph:anchor-simple-bold`
3231
+ * * `ph:activity-bold`
3232
+ */
3233
+ icon: SimpleSignal<string, this>;
3234
+ /**
3235
+ * The color of the icon
3236
+ *
3237
+ * @remarks
3238
+ * Provide the color in one of the following formats:
3239
+ * * named color like `red`, `darkgray`, …
3240
+ * * hexadecimal string with # like `#bada55`, `#141414`
3241
+ * Value can be either RGB or RGBA: `#bada55`, `#bada55aa` (latter is partially transparent)
3242
+ * The shorthand version (e.g. `#abc` for `#aabbcc` is also possible.)
3243
+ *
3244
+ * @defaultValue 'white'
3245
+ */
3246
+ color: ColorSignal<this>;
3247
+ constructor(props: IconProps);
3248
+ /**
3249
+ * Create the URL that will be used as the Image source
3250
+ * @returns Address to Iconify API for the requested Icon.
3251
+ */
3252
+ protected svgUrl(): string;
3253
+ /**
3254
+ * overrides `Image.src` getter
3255
+ */
3256
+ protected getSrc(): string;
3257
+ /**
3258
+ * overrides `Image.src` setter to warn the user that the value
3259
+ * is not used
3260
+ */
3261
+ protected setSrc(src: string | null): void;
3262
+ }
3263
+
3264
+ interface KnotProps extends NodeProps {
3265
+ /**
3266
+ * {@inheritDoc Knot.startHandle}
3267
+ */
3268
+ startHandle?: SignalValue<PossibleVector2>;
3269
+ /**
3270
+ * {@inheritDoc Knot.endHandle}
3271
+ */
3272
+ endHandle?: SignalValue<PossibleVector2>;
3273
+ /**
3274
+ * {@inheritDoc Knot.auto}
3275
+ */
3276
+ auto?: SignalValue<PossibleKnotAuto>;
3277
+ startHandleAuto?: SignalValue<number>;
3278
+ endHandleAuto?: SignalValue<number>;
3279
+ }
3280
+ type KnotAuto = {
3281
+ startHandle: number;
3282
+ endHandle: number;
3283
+ };
3284
+ type PossibleKnotAuto = KnotAuto | number | [number, number];
3285
+ type KnotAutoSignal<TOwner> = Signal<PossibleKnotAuto, KnotAuto, TOwner> & {
3286
+ endHandle: Signal<number, number, TOwner>;
3287
+ startHandle: Signal<number, number, TOwner>;
3288
+ };
3289
+ /**
3290
+ * A node representing a knot of a {@link Spline}.
3291
+ */
3292
+ declare class Knot extends Node {
3293
+ /**
3294
+ * The position of the knot's start handle. The position is provided relative
3295
+ * to the knot's position.
3296
+ *
3297
+ * @remarks
3298
+ * By default, the position of the start handle will be the mirrored position
3299
+ * of the {@link endHandle}.
3300
+ *
3301
+ * If neither an end handle nor a start handle is provided, the positions of
3302
+ * the handles gets calculated automatically to create smooth curve through
3303
+ * the knot. The smoothness of the resulting curve can be controlled via the
3304
+ * {@link Spline.smoothness} property.
3305
+ *
3306
+ * It is also possible to blend between a user-defined position and the
3307
+ * auto-calculated position by using the {@link auto} property.
3308
+ *
3309
+ * @defaultValue Mirrored position of the endHandle.
3310
+ */
3311
+ readonly startHandle: Vector2Signal<this>;
3312
+ /**
3313
+ * The position of the knot's end handle. The position is provided relative
3314
+ * to the knot's position.
3315
+ *
3316
+ * @remarks
3317
+ * By default, the position of the end handle will be the mirrored position
3318
+ * of the {@link startHandle}.
3319
+ *
3320
+ * If neither an end handle nor a start handle is provided, the positions of
3321
+ * the handles gets calculated automatically to create smooth curve through
3322
+ * the knot. The smoothness of the resulting curve can be controlled via the
3323
+ * {@link Spline.smoothness} property.
3324
+ *
3325
+ * It is also possible to blend between a user-defined position and the
3326
+ * auto-calculated position by using the {@link auto} property.
3327
+ *
3328
+ * @defaultValue Mirrored position of the startHandle.
3329
+ */
3330
+ readonly endHandle: Vector2Signal<this>;
3331
+ /**
3332
+ * How much to blend between the user-provided handles and the auto-calculated
3333
+ * handles.
3334
+ *
3335
+ * @remarks
3336
+ * This property has no effect if no explicit handles are provided for the
3337
+ * knot.
3338
+ *
3339
+ * @defaultValue 0
3340
+ */
3341
+ readonly auto: KnotAutoSignal<this>;
3342
+ get startHandleAuto(): Signal<number, number, this, _twick_core.SignalContext<number, number, this>>;
3343
+ get endHandleAuto(): Signal<number, number, this, _twick_core.SignalContext<number, number, this>>;
3344
+ constructor(props: KnotProps);
3345
+ points(): KnotInfo;
3346
+ private getDefaultEndHandle;
3347
+ private getDefaultStartHandle;
3348
+ }
3349
+
3350
+ interface LatexProps extends ImgProps {
3351
+ tex?: SignalValue<string>;
3352
+ renderProps?: SignalValue<OptionList>;
3353
+ }
3354
+ /**
3355
+ * A node for rendering equations with LaTeX.
3356
+ *
3357
+ * @preview
3358
+ * ```tsx editor
3359
+ * import {Latex, makeScene2D} from '@twick/2d';
3360
+ *
3361
+ * export default makeScene2D(function* (view) {
3362
+ * view.add(
3363
+ * <Latex
3364
+ * // Note how this uses \color to set the color.
3365
+ * tex="{\color{white} ax^2+bx+c=0 \implies x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}}"
3366
+ * width={600} // height and width can calculate based on each other
3367
+ * />,
3368
+ * );
3369
+ * });
3370
+ * ```
3371
+ */
3372
+ declare class Latex extends Img {
3373
+ private static svgContentsPool;
3374
+ private static mathJaxInitialized;
3375
+ private static adaptor;
3376
+ private static jaxDocument;
3377
+ private static initializeMathJax;
3378
+ private readonly imageElement;
3379
+ readonly options: SimpleSignal<OptionList, this>;
3380
+ readonly tex: SimpleSignal<string, this>;
3381
+ constructor(props: LatexProps);
3382
+ protected image(): HTMLImageElement;
3383
+ }
3384
+
3385
+ interface LineProps extends CurveProps {
3386
+ /**
3387
+ * {@inheritDoc Line.radius}
3388
+ */
3389
+ radius?: SignalValue<number>;
3390
+ /**
3391
+ * {@inheritDoc Line.points}
3392
+ */
3393
+ points?: SignalValue<SignalValue<PossibleVector2>[]>;
3394
+ }
3395
+ /**
3396
+ * A node for drawing lines and polygons.
3397
+ *
3398
+ * @remarks
3399
+ * This node can be used to render any polygonal shape defined by a set of
3400
+ * points.
3401
+ *
3402
+ * @preview
3403
+ * ```tsx editor
3404
+ * // snippet Simple line
3405
+ * import {makeScene2D, Line} from '@twick/2d';
3406
+ *
3407
+ * export default makeScene2D(function* (view) {
3408
+ * view.add(
3409
+ * <Line
3410
+ * points={[
3411
+ * [150, 50],
3412
+ * [0, -50],
3413
+ * [-150, 50],
3414
+ * ]}
3415
+ * stroke={'lightseagreen'}
3416
+ * lineWidth={8}
3417
+ * radius={40}
3418
+ * startArrow
3419
+ * />,
3420
+ * );
3421
+ * });
3422
+ *
3423
+ * // snippet Polygon
3424
+ * import {makeScene2D, Line} from '@twick/2d';
3425
+ *
3426
+ * export default makeScene2D(function* (view) {
3427
+ * view.add(
3428
+ * <Line
3429
+ * points={[
3430
+ * [-200, 70],
3431
+ * [150, 70],
3432
+ * [100, -70],
3433
+ * [-100, -70],
3434
+ * ]}
3435
+ * fill={'lightseagreen'}
3436
+ * closed
3437
+ * />,
3438
+ * );
3439
+ * });
3440
+ *
3441
+ * // snippet Using signals
3442
+ * import {makeScene2D, Line} from '@twick/2d';
3443
+ * import {createSignal} from '@twick/core';
3444
+ *
3445
+ * export default makeScene2D(function* (view) {
3446
+ * const tip = createSignal(-150);
3447
+ * view.add(
3448
+ * <Line
3449
+ * points={[
3450
+ * [-150, 70],
3451
+ * [150, 70],
3452
+ * // this point is dynamically calculated based on the signal:
3453
+ * () => [tip(), -70],
3454
+ * ]}
3455
+ * stroke={'lightseagreen'}
3456
+ * lineWidth={8}
3457
+ * closed
3458
+ * />,
3459
+ * );
3460
+ *
3461
+ * yield* tip(150, 1).back(1);
3462
+ * });
3463
+ *
3464
+ * // snippet Tweening points
3465
+ * import {makeScene2D, Line} from '@twick/2d';
3466
+ * import {createRef} from '@twick/core';
3467
+ *
3468
+ * export default makeScene2D(function* (view) {
3469
+ * const line = createRef<Line>();
3470
+ * view.add(
3471
+ * <Line
3472
+ * ref={line}
3473
+ * points={[
3474
+ * [-150, 70],
3475
+ * [150, 70],
3476
+ * [0, -70],
3477
+ * ]}
3478
+ * stroke={'lightseagreen'}
3479
+ * lineWidth={8}
3480
+ * radius={20}
3481
+ * closed
3482
+ * />,
3483
+ * );
3484
+ *
3485
+ * yield* line()
3486
+ * .points(
3487
+ * [
3488
+ * [-150, 0],
3489
+ * [0, 100],
3490
+ * [150, 0],
3491
+ * [150, -70],
3492
+ * [-150, -70],
3493
+ * ],
3494
+ * 2,
3495
+ * )
3496
+ * .back(2);
3497
+ * });
3498
+ * ```
3499
+ */
3500
+ declare class Line extends Curve {
3501
+ /**
3502
+ * Rotate the points to minimize the overall distance traveled when tweening.
3503
+ *
3504
+ * @param points - The points to rotate.
3505
+ * @param reference - The reference points to which the distance is measured.
3506
+ * @param closed - Whether the points form a closed polygon.
3507
+ */
3508
+ private static rotatePoints;
3509
+ /**
3510
+ * Distribute additional points along the polyline.
3511
+ *
3512
+ * @param points - The points of a polyline along which new points should be
3513
+ * distributed.
3514
+ * @param count - The number of points to add.
3515
+ */
3516
+ private static distributePoints;
3517
+ /**
3518
+ * The radius of the line's corners.
3519
+ */
3520
+ readonly radius: SimpleSignal<number, this>;
3521
+ /**
3522
+ * The points of the line.
3523
+ *
3524
+ * @remarks
3525
+ * When set to `null`, the Line will use the positions of its children as
3526
+ * points.
3527
+ */
3528
+ readonly points: SimpleSignal<SignalValue<PossibleVector2>[] | null, this>;
3529
+ protected tweenPoints(value: SignalValue<SignalValue<PossibleVector2>[] | null>, time: number, timingFunction: TimingFunction): ThreadGenerator;
3530
+ private tweenedPoints;
3531
+ constructor(props: LineProps);
3532
+ protected childrenBBox(): BBox;
3533
+ parsedPoints(): Vector2[];
3534
+ profile(): CurveProfile;
3535
+ protected lineWidthCoefficient(): number;
3536
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
3537
+ private parsePoints;
3538
+ }
3539
+
3540
+ interface PathProps extends CurveProps {
3541
+ data: SignalValue<string>;
3542
+ }
3543
+ declare class Path extends Curve {
3544
+ private currentProfile;
3545
+ readonly data: SimpleSignal<string, this>;
3546
+ constructor(props: PathProps);
3547
+ profile(): CurveProfile;
3548
+ protected childrenBBox(): BBox;
3549
+ protected lineWidthCoefficient(): number;
3550
+ protected processSubpath(path: Path2D, startPoint: Vector2 | null, endPoint: Vector2 | null): void;
3551
+ protected tweenData(newPath: SignalValue<string>, time: number, timingFunction: TimingFunction): Generator<void | _twick_core.ThreadGenerator | Promise<any> | _twick_core.Promisable<any>, void, any>;
3552
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
3553
+ }
3554
+
3555
+ interface PolygonProps extends CurveProps {
3556
+ /**
3557
+ * {@inheritDoc Polygon.sides}
3558
+ */
3559
+ sides?: SignalValue<number>;
3560
+ /**
3561
+ * {@inheritDoc Polygon.radius}
3562
+ */
3563
+ radius?: SignalValue<number>;
3564
+ }
3565
+ /**
3566
+ * A node for drawing regular polygons.
3567
+ *
3568
+ * @remarks
3569
+ * This node can be used to render shapes such as: triangle, pentagon,
3570
+ * hexagon and more.
3571
+ *
3572
+ * Note that the polygon is inscribed in a circle defined by the height
3573
+ * and width. If height and width are unequal, the polygon is inscribed
3574
+ * in the resulting ellipse.
3575
+ *
3576
+ * Since the polygon is inscribed in the circle, the actual displayed
3577
+ * height and width may differ somewhat from the bounding rectangle. This
3578
+ * will be particularly noticeable if the number of sides is low, e.g. for a
3579
+ * triangle.
3580
+ *
3581
+ * @preview
3582
+ * ```tsx editor
3583
+ * // snippet Polygon
3584
+ * import {makeScene2D, Polygon} from '@twick/2d';
3585
+ * import {createRef} from '@twick/core';
3586
+ *
3587
+ * export default makeScene2D(function* (view) {
3588
+ * const ref = createRef<Polygon>();
3589
+ * view.add(
3590
+ * <Polygon
3591
+ * ref={ref}
3592
+ * sides={6}
3593
+ * size={160}
3594
+ * fill={'lightseagreen'}
3595
+ * />
3596
+ * );
3597
+ *
3598
+ * yield* ref().sides(3, 2).to(6, 2);
3599
+ * });
3600
+ *
3601
+ * // snippet Pentagon outline
3602
+ * import {makeScene2D, Polygon} from '@twick/2d';
3603
+ *
3604
+ * export default makeScene2D(function* (view) {
3605
+ * view.add(
3606
+ * <Polygon
3607
+ * sides={5}
3608
+ * size={160}
3609
+ * radius={30}
3610
+ * stroke={'lightblue'}
3611
+ * lineWidth={8}
3612
+ * />
3613
+ * );
3614
+ * });
3615
+ * ```
3616
+ */
3617
+ declare class Polygon extends Curve {
3618
+ /**
3619
+ * The number of sides of the polygon.
3620
+ *
3621
+ * @remarks
3622
+ * For example, a value of 6 creates a hexagon.
3623
+ *
3624
+ * @example
3625
+ * ```tsx
3626
+ * <Polygon
3627
+ * size={320}
3628
+ * sides={7}
3629
+ * stroke={'#fff'}
3630
+ * lineWidth={8}
3631
+ * fill={'lightseagreen'}
3632
+ * />
3633
+ * ```
3634
+ */
3635
+ readonly sides: SimpleSignal<number, this>;
3636
+ /**
3637
+ * The radius of the polygon's corners.
3638
+ *
3639
+ * @example
3640
+ * ```tsx
3641
+ * <Polygon
3642
+ * radius={30}
3643
+ * size={320}
3644
+ * sides={3}
3645
+ * stroke={'#fff'}
3646
+ * lineWidth={8}
3647
+ * />
3648
+ * ```
3649
+ */
3650
+ readonly radius: SimpleSignal<number, this>;
3651
+ constructor(props: PolygonProps);
3652
+ profile(): CurveProfile;
3653
+ protected desiredSize(): SerializedVector2<DesiredLength>;
3654
+ protected offsetComputedLayout(box: BBox): BBox;
3655
+ protected childrenBBox(): BBox;
3656
+ protected requiresProfile(): boolean;
3657
+ protected getPath(): Path2D;
3658
+ protected getRipplePath(): Path2D;
3659
+ protected createPath(expand?: number): Path2D;
3660
+ }
3661
+
3662
+ interface QuadBezierProps extends CurveProps {
3663
+ p0?: SignalValue<PossibleVector2>;
3664
+ p0X?: SignalValue<number>;
3665
+ p0Y?: SignalValue<number>;
3666
+ p1?: SignalValue<PossibleVector2>;
3667
+ p1X?: SignalValue<number>;
3668
+ p1Y?: SignalValue<number>;
3669
+ p2?: SignalValue<PossibleVector2>;
3670
+ p2X?: SignalValue<number>;
3671
+ p2Y?: SignalValue<number>;
3672
+ }
3673
+ /**
3674
+ * A node for drawing a quadratic Bézier curve.
3675
+ *
3676
+ * @preview
3677
+ * ```tsx editor
3678
+ * import {makeScene2D, QuadBezier} from '@twick/2d';
3679
+ * import {createRef} from '@twick/core';
3680
+ *
3681
+ * export default makeScene2D(function* (view) {
3682
+ * const bezier = createRef<QuadBezier>();
3683
+ *
3684
+ * view.add(
3685
+ * <QuadBezier
3686
+ * ref={bezier}
3687
+ * lineWidth={4}
3688
+ * stroke={'lightseagreen'}
3689
+ * p0={[-200, 0]}
3690
+ * p1={[0, -200]}
3691
+ * p2={[200, 0]}
3692
+ * end={0}
3693
+ * />
3694
+ * );
3695
+ *
3696
+ * yield* bezier().end(1, 1);
3697
+ * yield* bezier().start(1, 1).to(0, 1);
3698
+ * });
3699
+ * ```
3700
+ */
3701
+ declare class QuadBezier extends Bezier {
3702
+ /**
3703
+ * The start point of the Bézier curve.
3704
+ */
3705
+ readonly p0: Vector2Signal<this>;
3706
+ /**
3707
+ * The control point of the Bézier curve.
3708
+ */
3709
+ readonly p1: Vector2Signal<this>;
3710
+ /**
3711
+ * The end point of the Bézier curve.
3712
+ */
3713
+ readonly p2: Vector2Signal<this>;
3714
+ constructor(props: QuadBezierProps);
3715
+ protected segment(): PolynomialSegment;
3716
+ protected overlayInfo(matrix: DOMMatrix): BezierOverlayInfo;
3717
+ }
3718
+
3719
+ interface RayProps extends CurveProps {
3720
+ /**
3721
+ * {@inheritDoc Ray.from}
3722
+ */
3723
+ from?: SignalValue<PossibleVector2>;
3724
+ fromX?: SignalValue<number>;
3725
+ fromY?: SignalValue<number>;
3726
+ /**
3727
+ * {@inheritDoc Ray.to}
3728
+ */
3729
+ to?: SignalValue<PossibleVector2>;
3730
+ toX?: SignalValue<number>;
3731
+ toY?: SignalValue<number>;
3732
+ }
3733
+ /**
3734
+ * A node for drawing an individual line segment.
3735
+ *
3736
+ * @preview
3737
+ * ```tsx editor
3738
+ * import {makeScene2D} from '@twick/2d';
3739
+ * import {Ray} from '@twick/2d';
3740
+ * import {createRef} from '@twick/core';
3741
+ *
3742
+ * export default makeScene2D(function* (view) {
3743
+ * const ray = createRef<Ray>();
3744
+ *
3745
+ * view.add(
3746
+ * <Ray
3747
+ * ref={ray}
3748
+ * lineWidth={8}
3749
+ * endArrow
3750
+ * stroke={'lightseagreen'}
3751
+ * fromX={-200}
3752
+ * toX={200}
3753
+ * />,
3754
+ * );
3755
+ *
3756
+ * yield* ray().start(1, 1);
3757
+ * yield* ray().start(0).end(0).start(1, 1);
3758
+ * });
3759
+ * ```
3760
+ */
3761
+ declare class Ray extends Curve {
3762
+ /**
3763
+ * The starting point of the ray.
3764
+ */
3765
+ readonly from: Vector2Signal<this>;
3766
+ /**
3767
+ * The ending point of the ray.
3768
+ */
3769
+ readonly to: Vector2Signal<this>;
3770
+ constructor(props: RayProps);
3771
+ protected childrenBBox(): BBox;
3772
+ profile(): CurveProfile;
3773
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
3774
+ }
3775
+
3776
+ interface RiveProps extends RectProps {
3777
+ src?: SignalValue<string>;
3778
+ artboardId?: SignalValue<string | number>;
3779
+ animationId?: SignalValue<string | number>;
3780
+ }
3781
+ declare class Rive extends Rect {
3782
+ readonly src: SimpleSignal<string, this>;
3783
+ readonly artboardId: SimpleSignal<number | string, this>;
3784
+ readonly animationId: SimpleSignal<number | string, this>;
3785
+ protected readonly time: SimpleSignal<number, this>;
3786
+ protected currentTime: number;
3787
+ protected lastTime: number;
3788
+ constructor(props: RiveProps);
3789
+ private rive;
3790
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
3791
+ private getArtboard;
3792
+ private getAnimation;
3793
+ }
3794
+
3795
+ interface SplineProps extends CurveProps {
3796
+ /**
3797
+ * {@inheritDoc Spline.smoothness}
3798
+ */
3799
+ smoothness?: SignalValue<number>;
3800
+ /**
3801
+ * {@inheritDoc Spline.points}
3802
+ */
3803
+ points?: SignalValue<SignalValue<PossibleVector2[]>>;
3804
+ }
3805
+ /**
3806
+ * A node for drawing a smooth line through a number of points.
3807
+ *
3808
+ * @remarks
3809
+ * This node uses Bézier curves for drawing each segment of the spline.
3810
+ *
3811
+ * @example
3812
+ * Defining knots using the `points` property. This will automatically
3813
+ * calculate the handle positions for each knot do draw a smooth curve. You
3814
+ * can control the smoothness of the resulting curve via the
3815
+ * {@link Spline.smoothness} property:
3816
+ *
3817
+ * ```tsx
3818
+ * <Spline
3819
+ * lineWidth={4}
3820
+ * stroke={'white'}
3821
+ * smoothness={0.4}
3822
+ * points={[
3823
+ * [-400, 0],
3824
+ * [-200, -300],
3825
+ * [0, 0],
3826
+ * [200, -300],
3827
+ * [400, 0],
3828
+ * ]}
3829
+ * />
3830
+ * ```
3831
+ *
3832
+ * Defining knots with {@link Knot} nodes:
3833
+ *
3834
+ * ```tsx
3835
+ * <Spline lineWidth={4} stroke={'white'}>
3836
+ * <Knot position={[-400, 0]} />
3837
+ * <Knot position={[-200, -300]} />
3838
+ * <Knot
3839
+ * position={[0, 0]}
3840
+ * startHandle={[-100, 200]}
3841
+ * endHandle={[100, 200]}
3842
+ * />
3843
+ * <Knot position={[200, -300]} />
3844
+ * <Knot position={[400, 0]} />
3845
+ * </Spline>
3846
+ * ```
3847
+ */
3848
+ declare class Spline extends Curve {
3849
+ /**
3850
+ * The smoothness of the spline when using auto-calculated handles.
3851
+ *
3852
+ * @remarks
3853
+ * This property is only applied to knots that don't use explicit handles.
3854
+ *
3855
+ * @defaultValue 0.4
3856
+ */
3857
+ readonly smoothness: SimpleSignal<number>;
3858
+ /**
3859
+ * The knots of the spline as an array of knots with auto-calculated handles.
3860
+ *
3861
+ * @remarks
3862
+ * You can control the smoothness of the resulting curve
3863
+ * via the {@link smoothness} property.
3864
+ */
3865
+ readonly points: SimpleSignal<SignalValue<PossibleVector2>[] | null, this>;
3866
+ constructor(props: SplineProps);
3867
+ profile(): CurveProfile;
3868
+ knots(): KnotInfo[];
3869
+ protected childrenBBox(): BBox;
3870
+ protected lineWidthCoefficient(): number;
3871
+ protected desiredSize(): SerializedVector2<DesiredLength>;
3872
+ protected offsetComputedLayout(box: BBox): BBox;
3873
+ private getTightBBox;
3874
+ drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
3875
+ private isKnot;
3876
+ }
3877
+
3878
+ /**
3879
+ * Represent SVG shape.
3880
+ * This only used single time because `node` may have reference to parent SVG renderer.
3881
+ */
3882
+ interface SVGShape {
3883
+ id: string;
3884
+ shape: Node;
3885
+ }
3886
+ /**
3887
+ * Data of SVGShape.
3888
+ * This can used many times because it do not reference parent SVG.
3889
+ * This must build into SVGShape
3890
+ */
3891
+ interface SVGShapeData {
3892
+ id: string;
3893
+ type: new (props: NodeProps) => Node;
3894
+ props: ShapeProps;
3895
+ children?: SVGShapeData[];
3896
+ }
3897
+ /**
3898
+ * Represent SVG document that contains SVG shapes.
3899
+ * This only used single time because `nodes` have reference to parent SVG renderer.
3900
+ */
3901
+ interface SVGDocument {
3902
+ size: Vector2;
3903
+ nodes: SVGShape[];
3904
+ }
3905
+ /**
3906
+ * Data of SVGDocument.
3907
+ * This can used many times because it do not reference parent SVG.
3908
+ * This must build into SVGDocument
3909
+ */
3910
+ interface SVGDocumentData {
3911
+ size: Vector2;
3912
+ nodes: SVGShapeData[];
3913
+ }
3914
+ interface SVGProps extends ShapeProps {
3915
+ svg: SignalValue<string>;
3916
+ }
3917
+ /**
3918
+ A Node for drawing and animating SVG images.
3919
+
3920
+ @remarks
3921
+ If you're not interested in animating SVG, you can use {@link Img} instead.
3922
+ */
3923
+ declare class SVG extends Shape {
3924
+ protected static containerElement: HTMLDivElement;
3925
+ private static svgNodesPool;
3926
+ /**
3927
+ * SVG string to be rendered
3928
+ */
3929
+ readonly svg: SimpleSignal<string, this>;
3930
+ /**
3931
+ * Child to wrap all SVG node
3932
+ */
3933
+ wrapper: Node;
3934
+ private lastTweenTargetSrc;
3935
+ private lastTweenTargetDocument;
3936
+ constructor(props: SVGProps);
3937
+ /**
3938
+ * Get all SVG nodes with the given id.
3939
+ * @param id - An id to query.
3940
+ */
3941
+ getChildrenById(id: string): Node[];
3942
+ protected desiredSize(): SerializedVector2<DesiredLength>;
3943
+ protected getCurrentSize(): {
3944
+ x: number | null;
3945
+ y: number | null;
3946
+ };
3947
+ protected calculateWrapperScale(documentSize: Vector2, parentSize: SerializedVector2<number | null>): Vector2;
3948
+ /**
3949
+ * Convert `SVGDocumentData` to `SVGDocument`.
3950
+ * @param data - `SVGDocumentData` to convert.
3951
+ */
3952
+ protected buildDocument(data: SVGDocumentData): SVGDocument;
3953
+ /**
3954
+ * Convert `SVGShapeData` to `SVGShape`.
3955
+ * @param data - `SVGShapeData` to convert.
3956
+ */
3957
+ protected buildShape({ id, type, props, children }: SVGShapeData): SVGShape;
3958
+ /**
3959
+ * Convert an SVG string to `SVGDocument`.
3960
+ * @param svg - An SVG string to be parsed.
3961
+ */
3962
+ protected parseSVG(svg: string): SVGDocument;
3963
+ /**
3964
+ * Create a tweening list to tween between two SVG nodes.
3965
+ * @param from - The initial node,
3966
+ * @param to - The final node.
3967
+ * @param duration - The duration of the tween.
3968
+ * @param timing - The timing function.
3969
+ */
3970
+ protected generateTransformer(from: Node, to: Node, duration: number, timing: TimingFunction): Generator<ThreadGenerator>;
3971
+ protected tweenSvg(value: SignalValue<string>, time: number, timingFunction: TimingFunction): Generator<void | ThreadGenerator | Promise<any> | _twick_core.Promisable<any>, void, any>;
3972
+ private wrapperScale;
3973
+ /**
3974
+ * Get the current `SVGDocument`.
3975
+ */
3976
+ private document;
3977
+ /**
3978
+ * Get current document nodes.
3979
+ */
3980
+ private documentNodes;
3981
+ /**
3982
+ * Convert SVG colors in Shape properties to Motion Canvas colors.
3983
+ * @param param - Shape properties.
3984
+ * @returns Converted Shape properties.
3985
+ */
3986
+ private processElementStyle;
3987
+ /**
3988
+ * Parse an SVG string as `SVGDocumentData`.
3989
+ * @param svg - And SVG string to be parsed.
3990
+ * @returns `SVGDocumentData` that can be used to build SVGDocument.
3991
+ */
3992
+ protected static parseSVGData(svg: string): SVGDocumentData;
3993
+ /**
3994
+ * Get position, rotation and scale from Matrix transformation as Shape properties
3995
+ * @param transform - Matrix transformation
3996
+ * @returns MotionCanvas Shape properties
3997
+ */
3998
+ protected static getMatrixTransformation(transform: DOMMatrix): ShapeProps;
3999
+ /**
4000
+ * Convert an SVG color into a Motion Canvas color.
4001
+ * @param color - SVG color.
4002
+ * @returns Motion Canvas color.
4003
+ */
4004
+ private static processSVGColor;
4005
+ /**
4006
+ * Get the final transformation matrix for the given SVG element.
4007
+ * @param element - SVG element.
4008
+ * @param parentTransform - The transformation matrix of the parent.
4009
+ */
4010
+ private static getElementTransformation;
4011
+ private static parseLineCap;
4012
+ private static parseLineJoin;
4013
+ private static parseLineDash;
4014
+ private static parseDashOffset;
4015
+ private static parseOpacity;
4016
+ /**
4017
+ * Convert the SVG element's style to a Motion Canvas Shape properties.
4018
+ * @param element - An SVG element whose style should be converted.
4019
+ * @param inheritedStyle - The parent style that should be inherited.
4020
+ */
4021
+ private static getElementStyle;
4022
+ /**
4023
+ * Extract `SVGShapeData` list from the SVG element's children.
4024
+ * This will not extract the current element's shape.
4025
+ * @param element - An element whose children will be extracted.
4026
+ * @param svgRoot - The SVG root ("svg" tag) of the element.
4027
+ * @param parentTransform - The transformation matrix applied to the parent.
4028
+ * @param inheritedStyle - The style of the current SVG `element` that the children should inherit.
4029
+ */
4030
+ private static extractGroupNodes;
4031
+ /**
4032
+ * Parse a number from an SVG element attribute.
4033
+ * @param element - SVG element whose attribute will be parsed.
4034
+ * @param name - The name of the attribute to parse.
4035
+ * @returns a parsed number or `0` if the attribute is not defined.
4036
+ */
4037
+ private static parseNumberAttribute;
4038
+ /**
4039
+ * Extract `SVGShapeData` list from the SVG element.
4040
+ * This will also recursively extract shapes from its children.
4041
+ * @param child - An SVG element to extract.
4042
+ * @param svgRoot - The SVG root ("svg" tag) of the element.
4043
+ * @param parentTransform - The transformation matrix applied to the parent.
4044
+ * @param inheritedStyle - The style of the parent SVG element that the element should inherit.
4045
+ */
4046
+ private static extractElementNodes;
4047
+ }
4048
+
4049
+ interface TxtLeafProps extends ShapeProps {
4050
+ children?: string;
4051
+ text?: SignalValue<string>;
4052
+ }
4053
+ declare const TXT_TYPE: unique symbol;
4054
+ declare class TxtLeaf extends Shape {
4055
+ protected static readonly segmenter: any;
4056
+ readonly text: SimpleSignal<string, this>;
4057
+ constructor({ children, ...rest }: TxtLeafProps);
4058
+ protected parentTxt(): (Node & Record<typeof TXT_TYPE, unknown>) | null;
4059
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
4060
+ protected drawText(context: CanvasRenderingContext2D, text: string, box: BBox): Promise<void>;
4061
+ protected getCacheBBox(): BBox;
4062
+ protected applyFlex(): void;
4063
+ protected updateLayout(): void;
4064
+ }
4065
+
4066
+ type TxtChildren = string | Node | (string | Node)[];
4067
+ type AnyTxt = Txt | TxtLeaf;
4068
+ interface TxtProps extends ShapeProps {
4069
+ children?: TxtChildren;
4070
+ text?: SignalValue<string>;
4071
+ }
4072
+ declare class Txt extends Shape {
4073
+ readonly [TXT_TYPE] = true;
4074
+ /**
4075
+ * Create a bold text node.
4076
+ *
4077
+ * @remarks
4078
+ * This is a shortcut for
4079
+ * ```tsx
4080
+ * <Txt fontWeight={700} />
4081
+ * ```
4082
+ *
4083
+ * @param props - Additional text properties.
4084
+ */
4085
+ static b(props: TxtProps): Txt;
4086
+ /**
4087
+ * Create an italic text node.
4088
+ *
4089
+ * @remarks
4090
+ * This is a shortcut for
4091
+ * ```tsx
4092
+ * <Txt fontStyle={'italic'} />
4093
+ * ```
4094
+ *
4095
+ * @param props - Additional text properties.
4096
+ */
4097
+ static i(props: TxtProps): Txt;
4098
+ readonly text: SimpleSignal<string, this>;
4099
+ protected getText(): string;
4100
+ protected setText(value: SignalValue<string>): void;
4101
+ protected setChildren(value: SignalValue<ComponentChildren>): void;
4102
+ protected tweenText(value: SignalValue<string>, time: number, timingFunction: TimingFunction, interpolationFunction: InterpolationFunction<string>): ThreadGenerator;
4103
+ protected getLayout(): boolean;
4104
+ constructor({ children, text, ...props }: TxtProps);
4105
+ protected innerText(): string;
4106
+ protected parentTxt(): Txt | null;
4107
+ protected parseChildren(children: ComponentChildren): AnyTxt[];
4108
+ protected applyFlex(): void;
4109
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
4110
+ }
4111
+
4112
+ interface VideoProps extends MediaProps {
4113
+ /**
4114
+ * {@inheritDoc Video.alpha}
4115
+ */
4116
+ alpha?: SignalValue<number>;
4117
+ /**
4118
+ * {@inheritDoc Video.smoothing}
4119
+ */
4120
+ smoothing?: SignalValue<boolean>;
4121
+ /**
4122
+ * {@inheritDoc Video.decoder}
4123
+ */
4124
+ decoder?: SignalValue<'web' | 'ffmpeg' | 'slow' | null>;
4125
+ }
4126
+ declare class Video extends Media {
4127
+ /**
4128
+ * The alpha value of this video.
4129
+ *
4130
+ * @remarks
4131
+ * Unlike opacity, the alpha value affects only the video itself, leaving the
4132
+ * fill, stroke, and children intact.
4133
+ */
4134
+ readonly alpha: SimpleSignal<number, this>;
4135
+ /**
4136
+ * Whether the video should be smoothed.
4137
+ *
4138
+ * @remarks
4139
+ * When disabled, the video will be scaled using the nearest neighbor
4140
+ * interpolation with no smoothing. The resulting video will appear pixelated.
4141
+ *
4142
+ * @defaultValue true
4143
+ */
4144
+ readonly smoothing: SimpleSignal<boolean, this>;
4145
+ /**
4146
+ * Which decoder to use during rendering. The `web` decoder is the fastest
4147
+ * but only supports MP4 files. The `ffmpeg` decoder is slower and more resource
4148
+ * intensive but supports more formats. The `slow` decoder is the slowest but
4149
+ * supports all formats.
4150
+ *
4151
+ * @defaultValue null
4152
+ */
4153
+ readonly decoder: SimpleSignal<'web' | 'ffmpeg' | 'slow' | null, this>;
4154
+ detectedFileType: 'mp4' | 'webm' | 'hls' | 'mov' | 'unknown';
4155
+ private fileTypeWasDetected;
4156
+ private static readonly pool;
4157
+ private static readonly imageCommunication;
4158
+ constructor(props: VideoProps);
4159
+ protected desiredSize(): SerializedVector2<DesiredLength>;
4160
+ protected mediaElement(): HTMLVideoElement;
4161
+ protected seekedMedia(): HTMLVideoElement;
4162
+ protected fastSeekedMedia(): HTMLVideoElement;
4163
+ private video;
4164
+ protected seekedVideo(): HTMLVideoElement;
4165
+ protected fastSeekedVideo(): HTMLVideoElement;
4166
+ protected lastFrame: ImageBitmap | null;
4167
+ protected webcodecSeekedVideo(): Promise<CanvasImageSource>;
4168
+ protected ffmpegSeekedVideo(): Promise<ImageBitmap>;
4169
+ protected seekFunction(): Promise<CanvasImageSource>;
4170
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
4171
+ protected applyFlex(): void;
4172
+ remove(): this;
4173
+ private handleUnknownFileType;
4174
+ private detectFileType;
4175
+ }
4176
+
4177
+ interface CodeMetrics {
4178
+ content: string;
4179
+ newRows: number;
4180
+ endColumn: number;
4181
+ firstWidth: number;
4182
+ maxWidth: number;
4183
+ lastWidth: number;
4184
+ }
4185
+
4186
+ interface CodeFragment {
4187
+ before: CodeMetrics;
4188
+ after: CodeMetrics;
4189
+ }
4190
+ interface RawCodeFragment {
4191
+ before: string;
4192
+ after: string;
4193
+ }
4194
+ type PossibleCodeFragment = CodeFragment | CodeMetrics | RawCodeFragment | string;
4195
+ declare function metricsToFragment(value: CodeMetrics): CodeFragment;
4196
+ declare function parseCodeFragment(value: PossibleCodeFragment, context: CanvasRenderingContext2D, monoWidth: number): CodeFragment;
4197
+ /**
4198
+ * Create a code fragment that represents an insertion of code.
4199
+ *
4200
+ * @remarks
4201
+ * Can be used in conjunction with {@link code.CodeSignalHelpers.edit}.
4202
+ *
4203
+ * @param code - The code to insert.
4204
+ */
4205
+ declare function insert(code: string): RawCodeFragment;
4206
+ /**
4207
+ * Create a code fragment that represents a change from one piece of code to
4208
+ * another.
4209
+ *
4210
+ * @remarks
4211
+ * Can be used in conjunction with {@link code.CodeSignalHelpers.edit}.
4212
+ *
4213
+ * @param before - The code to change from.
4214
+ * @param after - The code to change to.
4215
+ */
4216
+ declare function replace(before: string, after: string): RawCodeFragment;
4217
+ /**
4218
+ * Create a code fragment that represents a removal of code.
4219
+ *
4220
+ * @remarks
4221
+ * Can be used in conjunction with {@link code.CodeSignalHelpers.edit}.
4222
+ *
4223
+ * @param code - The code to remove.
4224
+ */
4225
+ declare function remove(code: string): RawCodeFragment;
4226
+
4227
+ interface CodeScope {
4228
+ progress: SignalValue<number>;
4229
+ fragments: CodeTag[];
4230
+ }
4231
+ type PossibleCodeScope = CodeScope | CodeTag[] | string;
4232
+ type CodeTag = SignalValue<PossibleCodeFragment | CodeScope | CodeTag[]>;
4233
+ declare function CODE(strings: TemplateStringsArray, ...tags: CodeTag[]): CodeTag[];
4234
+ declare function isCodeScope(value: any): value is CodeScope;
4235
+ declare function parseCodeScope(value: PossibleCodeScope): CodeScope;
4236
+ type IsAfterPredicate = ((scope: CodeScope) => boolean) | boolean;
4237
+ declare function resolveScope(scope: CodeScope, isAfter: IsAfterPredicate): string;
4238
+ declare function resolveCodeTag(wrapped: CodeTag, after: boolean, isAfter?: IsAfterPredicate): string;
4239
+
4240
+ interface CodeFragmentDrawingInfo {
4241
+ text: string;
4242
+ position: Vector2;
4243
+ characterSize: Vector2;
4244
+ cursor: Vector2;
4245
+ fill: string;
4246
+ time: number;
4247
+ alpha: number;
4248
+ }
4249
+ /**
4250
+ * A stateful class for recursively traversing a code scope.
4251
+ *
4252
+ * @internal
4253
+ */
4254
+ declare class CodeCursor {
4255
+ private readonly node;
4256
+ cursor: Vector2;
4257
+ beforeCursor: Vector2;
4258
+ afterCursor: Vector2;
4259
+ beforeIndex: number;
4260
+ afterIndex: number;
4261
+ private context;
4262
+ private monoWidth;
4263
+ private maxWidth;
4264
+ private lineHeight;
4265
+ private fallbackFill;
4266
+ private caches;
4267
+ private highlighter;
4268
+ private selection;
4269
+ private selectionProgress;
4270
+ private globalProgress;
4271
+ private fragmentDrawingInfo;
4272
+ private fontHeight;
4273
+ private verticalOffset;
4274
+ constructor(node: Code);
4275
+ /**
4276
+ * Prepare the cursor for the next traversal.
4277
+ *
4278
+ * @param context - The context used to measure and draw the code.
4279
+ */
4280
+ setupMeasure(context: CanvasRenderingContext2D): void;
4281
+ setupDraw(context: CanvasRenderingContext2D): void;
4282
+ /**
4283
+ * Measure the desired size of the code scope.
4284
+ *
4285
+ * @remarks
4286
+ * The result can be retrieved with {@link getSize}.
4287
+ *
4288
+ * @param scope - The code scope to measure.
4289
+ */
4290
+ measureSize(scope: CodeScope): void;
4291
+ /**
4292
+ * Get the size measured by the cursor.
4293
+ */
4294
+ getSize(): {
4295
+ x: number;
4296
+ y: number;
4297
+ };
4298
+ /**
4299
+ * Get the drawing information created by the cursor.
4300
+ */
4301
+ getDrawingInfo(): {
4302
+ fragments: CodeFragmentDrawingInfo[];
4303
+ verticalOffset: number;
4304
+ fontHeight: number;
4305
+ };
4306
+ /**
4307
+ * Draw the given code scope.
4308
+ *
4309
+ * @param scope - The code scope to draw.
4310
+ */
4311
+ drawScope(scope: CodeScope): void;
4312
+ private drawToken;
4313
+ private calculateWidth;
4314
+ private calculateMaxWidth;
4315
+ private currentProgress;
4316
+ private processSelection;
4317
+ private isSelected;
4318
+ }
4319
+
4320
+ type CodeTokenizer = (input: string) => string[];
4321
+ /**
4322
+ * Default tokenizer function used by ownerless code signals.
4323
+ *
4324
+ * @param input - The code to tokenize.
4325
+ */
4326
+ declare function defaultTokenize(input: string): string[];
4327
+
4328
+ /**
4329
+ * A function that compares two code snippets and returns a list of
4330
+ * {@link CodeTag}s describing a transition between them.
4331
+ */
4332
+ type CodeDiffer = (
4333
+ /**
4334
+ * The original code scope.
4335
+ */
4336
+ from: CodeScope,
4337
+ /**
4338
+ * The new code scope.
4339
+ */
4340
+ to: CodeScope,
4341
+ /**
4342
+ * The inherited tokenizer to use.
4343
+ */
4344
+ tokenize: CodeTokenizer) => CodeTag[];
4345
+ /**
4346
+ * Default diffing function utilizing {@link code.patienceDiff}.
4347
+ *
4348
+ * @param from - The original code scope.
4349
+ * @param to - The new code scope.
4350
+ * @param tokenize - The inherited tokenizer to use.
4351
+ */
4352
+ declare function defaultDiffer(from: CodeScope, to: CodeScope, tokenize: CodeTokenizer): CodeTag[];
4353
+
4354
+ /**
4355
+ * Describes the result of a highlight operation.
4356
+ */
4357
+ interface HighlightResult {
4358
+ /**
4359
+ * The color of the code at the given index.
4360
+ */
4361
+ color: string | null;
4362
+ /**
4363
+ * The number of characters to skip ahead.
4364
+ *
4365
+ * @remarks
4366
+ * This should be used to skip to the end of the currently highlighted token.
4367
+ * The returned style will be used for the skipped characters, and they will
4368
+ * be drawn as one continuous string keeping emojis and ligatures intact.
4369
+ *
4370
+ * The returned value is the number of characters to skip ahead, not the
4371
+ * index of the end of the token.
4372
+ */
4373
+ skipAhead: number;
4374
+ }
4375
+ /**
4376
+ * Describes custom highlighters used by the Code node.
4377
+ *
4378
+ * @typeParam T - The type of the cache used by the highlighter.
4379
+ */
4380
+ interface CodeHighlighter<T = unknown> {
4381
+ /**
4382
+ * Initializes the highlighter.
4383
+ *
4384
+ * @remarks
4385
+ * This method is called when collecting async resources for the node.
4386
+ * It can be called multiple times so caching the initialization is
4387
+ * recommended.
4388
+ *
4389
+ * If initialization is asynchronous, a promise should be registered using
4390
+ * {@link DependencyContext.collectPromise} and the value of `false` should
4391
+ * be returned. The hook will be called again when the promise resolves.
4392
+ * This process can be repeated until the value of `true` is returned which
4393
+ * will mark the highlighter as ready.
4394
+ */
4395
+ initialize(): boolean;
4396
+ /**
4397
+ * Prepares the code for highlighting.
4398
+ *
4399
+ * @remarks
4400
+ * This method is called each time the code changes. It can be used to do
4401
+ * any preprocessing of the code before highlighting. The result of this
4402
+ * method is cached and passed to {@link highlight} when the code is
4403
+ * highlighted.
4404
+ *
4405
+ * @param code - The code to prepare.
4406
+ * @param dialect - The language in which the code is written.
4407
+ */
4408
+ prepare(code: string): T;
4409
+ /**
4410
+ * Highlights the code at the given index.
4411
+ *
4412
+ * @param index - The index of the code to highlight.
4413
+ * @param cache - The result of {@link prepare}.
4414
+ */
4415
+ highlight(index: number, cache: T): HighlightResult;
4416
+ /**
4417
+ * Tokenize the code.
4418
+ *
4419
+ * @param code - The code to tokenize.
4420
+ * @param dialect - The language in which the code is written.
4421
+ */
4422
+ tokenize(code: string): string[];
4423
+ }
4424
+
4425
+ type CodePoint = [number, number];
4426
+ type CodeRange = [CodePoint, CodePoint];
4427
+ declare function isCodeRange(value: unknown): value is CodeRange;
4428
+ /**
4429
+ * Create a code range that spans the given lines.
4430
+ *
4431
+ * @param from - The line from which the range starts.
4432
+ * @param to - The line at which the range ends. If omitted, the range will
4433
+ * cover only one line.
4434
+ */
4435
+ declare function lines(from: number, to?: number): CodeRange;
4436
+ /**
4437
+ * Create a code range that highlights the given word.
4438
+ *
4439
+ * @param line - The line at which the word appears.
4440
+ * @param from - The column at which the word starts.
4441
+ * @param length - The length of the word. If omitted, the range will cover the
4442
+ * rest of the line.
4443
+ */
4444
+ declare function word(line: number, from: number, length?: number): CodeRange;
4445
+ /**
4446
+ * Create a custom selection range.
4447
+ *
4448
+ * @param startLine - The line at which the selection starts.
4449
+ * @param startColumn - The column at which the selection starts.
4450
+ * @param endLine - The line at which the selection ends.
4451
+ * @param endColumn - The column at which the selection ends.
4452
+ */
4453
+ declare function pointToPoint(startLine: number, startColumn: number, endLine: number, endColumn: number): CodeRange;
4454
+ declare function isPointInCodeRange(point: CodePoint, range: CodeRange): boolean;
4455
+ declare function consolidateCodeRanges(ranges: CodeRange[]): CodeRange[];
4456
+ declare function inverseCodeRange(ranges: CodeRange[]): CodeRange[];
4457
+ /**
4458
+ * Find all code ranges that match the given pattern.
4459
+ *
4460
+ * @param code - The code to search in.
4461
+ * @param pattern - Either a string or a regular expression to search for.
4462
+ * @param limit - An optional limit on the number of ranges to find.
4463
+ */
4464
+ declare function findAllCodeRanges(code: string, pattern: string | RegExp, limit?: number): CodeRange[];
4465
+
4466
+ type CodeSelection = CodeRange[];
4467
+ type PossibleCodeSelection = CodeRange | CodeRange[];
4468
+ declare function parseCodeSelection(value: PossibleCodeSelection): CodeSelection;
4469
+ declare function isPointInCodeSelection(point: CodePoint, selection: CodeSelection): boolean;
4470
+
4471
+ interface CodeModifier<TOwner> {
4472
+ (code: string): TOwner;
4473
+ (code: string, duration: number): ThreadGenerator;
4474
+ (duration?: number): TagGenerator;
4475
+ }
4476
+ interface CodeInsert<TOwner> {
4477
+ (point: CodePoint, code: string): TOwner;
4478
+ (point: CodePoint, code: string, duration: number): ThreadGenerator;
4479
+ }
4480
+ interface CodeRemove<TOwner> {
4481
+ (range: CodeRange): TOwner;
4482
+ (range: CodeRange, duration: number): ThreadGenerator;
4483
+ }
4484
+ interface CodeReplace<TOwner> {
4485
+ (range: CodeRange, code: string): TOwner;
4486
+ (range: CodeRange, code: string, duration: number): ThreadGenerator;
4487
+ }
4488
+ type TagGenerator = (strings: TemplateStringsArray, ...tags: CodeTag[]) => ThreadGenerator;
4489
+ interface CodeSignalHelpers<TOwner> {
4490
+ edit(duration?: number): TagGenerator;
4491
+ append: CodeModifier<TOwner>;
4492
+ prepend: CodeModifier<TOwner>;
4493
+ insert: CodeInsert<TOwner>;
4494
+ remove: CodeRemove<TOwner>;
4495
+ replace: CodeReplace<TOwner>;
4496
+ }
4497
+ type CodeSignal<TOwner> = Signal<PossibleCodeScope, CodeScope, TOwner, CodeSignalContext<TOwner>> & CodeSignalHelpers<TOwner>;
4498
+ declare class CodeSignalContext<TOwner> extends SignalContext<PossibleCodeScope, CodeScope, TOwner> implements CodeSignalHelpers<TOwner> {
4499
+ private readonly highlighter?;
4500
+ private readonly progress;
4501
+ constructor(initial: PossibleCodeScope, owner: TOwner, highlighter?: SignalValue<CodeHighlighter | null> | undefined);
4502
+ tweener(value: SignalValue<PossibleCodeScope>, duration: number, timingFunction: TimingFunction): ThreadGenerator;
4503
+ edit(duration?: number): TagGenerator;
4504
+ append(code: string): TOwner;
4505
+ append(code: string, duration: number): ThreadGenerator;
4506
+ append(duration?: number): TagGenerator;
4507
+ prepend(code: string): TOwner;
4508
+ prepend(code: string, duration: number): ThreadGenerator;
4509
+ prepend(duration?: number): TagGenerator;
4510
+ insert(point: CodePoint, code: string): TOwner;
4511
+ insert(point: CodePoint, code: string, duration: number): ThreadGenerator;
4512
+ remove(range: CodeRange): TOwner;
4513
+ remove(range: CodeRange, duration: number): ThreadGenerator;
4514
+ replace(range: CodeRange, code: string): TOwner;
4515
+ replace(range: CodeRange, code: string, duration: number): ThreadGenerator;
4516
+ private replaceTween;
4517
+ private editTween;
4518
+ private appendTween;
4519
+ private prependTween;
4520
+ parse(value: PossibleCodeScope): CodeScope;
4521
+ toSignal(): CodeSignal<TOwner>;
4522
+ }
4523
+ declare function codeSignal(): PropertyDecorator;
4524
+
4525
+ declare const DefaultHighlightStyle: HighlightStyle;
4526
+
4527
+ /**
4528
+ * Performs a patience diff on two arrays of strings, returning an object
4529
+ * containing the lines that were deleted, inserted, and potentially moved
4530
+ * lines. The plus parameter can result in a significant performance hit due
4531
+ * to additional Longest Common Substring searches.
4532
+ *
4533
+ * @param aLines - The original array of strings
4534
+ * @param bLines - The new array of strings
4535
+ * @param plus - Whether to return the moved lines
4536
+ *
4537
+ * Adapted from Jonathan "jonTrent" Trent's patience-diff algorithm.
4538
+ * Types and tests added by Hunter "hhenrichsen" Henrichsen.
4539
+ *
4540
+ * {@link https://github.com/jonTrent/PatienceDiff}
4541
+ */
4542
+ declare function patienceDiff(aLines: string[], bLines: string[]): {
4543
+ lines: {
4544
+ line: string;
4545
+ aIndex: number;
4546
+ bIndex: number;
4547
+ }[];
4548
+ lineCountDeleted: number;
4549
+ lineCountInserted: number;
4550
+ };
4551
+ /**
4552
+ * Utility function for debugging patienceDiff.
4553
+ *
4554
+ * @internal
4555
+ */
4556
+ declare function printDiff(diff: ReturnType<typeof patienceDiff>): void;
4557
+
4558
+ /**
4559
+ * Transform the fragments to isolate the given range into its own fragment.
4560
+ *
4561
+ * @remarks
4562
+ * This function will try to preserve the original fragments, resolving them
4563
+ * only if they overlap with the range.
4564
+ *
4565
+ * @param range - The range to extract.
4566
+ * @param fragments - The fragments to transform.
4567
+ *
4568
+ * @returns A tuple containing the transformed fragments and the index of the
4569
+ * isolated fragment within.
4570
+ */
4571
+ declare function extractRange(range: CodeRange, fragments: CodeTag[]): [CodeTag[], number];
4572
+
4573
+ interface LezerCache {
4574
+ tree: Tree;
4575
+ code: string;
4576
+ colorLookup: Map<string, string>;
4577
+ }
4578
+ declare class LezerHighlighter implements CodeHighlighter<LezerCache | null> {
4579
+ private readonly parser;
4580
+ private readonly style;
4581
+ private static classRegex;
4582
+ private readonly classLookup;
4583
+ constructor(parser: Parser, style?: HighlightStyle);
4584
+ initialize(): boolean;
4585
+ prepare(code: string): LezerCache | null;
4586
+ highlight(index: number, cache: LezerCache | null): HighlightResult;
4587
+ tokenize(code: string): string[];
4588
+ private getNodeId;
4589
+ }
4590
+
4591
+ declare namespace JSX {
4592
+ type Element = Node;
4593
+ type ElementClass = Node;
4594
+ interface ElementChildrenAttribute {
4595
+ children: any;
4596
+ }
4597
+ }
4598
+ declare const Fragment: FunctionComponent;
4599
+ declare function jsx(type: NodeConstructor | FunctionComponent | typeof Fragment, config: JSXProps, key?: any): ComponentChildren;
4600
+
4601
+ declare class Scene2D extends GeneratorScene<View2D> implements Inspectable {
4602
+ private view;
4603
+ private registeredNodes;
4604
+ private readonly nodeCounters;
4605
+ private assetHash;
4606
+ constructor(description: FullSceneDescription<ThreadGeneratorFactory<View2D>>);
4607
+ getView(): View2D;
4608
+ next(): Promise<void>;
4609
+ draw(context: CanvasRenderingContext2D): Promise<void>;
4610
+ reset(previousScene?: Scene): Promise<void>;
4611
+ inspectPosition(x: number, y: number): InspectedElement | null;
4612
+ getNodeByPosition(x: number, y: number): Node | null;
4613
+ validateInspection(element: InspectedElement | null): InspectedElement | null;
4614
+ inspectAttributes(element: InspectedElement): InspectedAttributes | null;
4615
+ drawOverlay(element: InspectedElement, matrix: DOMMatrix, context: CanvasRenderingContext2D): void;
4616
+ transformMousePosition(x: number, y: number): Vector2 | null;
4617
+ registerNode(node: Node, key?: string): [string, () => void];
4618
+ getNode(key: any): Node | null;
4619
+ getDetachedNodes(): Generator<Node, void, unknown>;
4620
+ getMediaAssets(): Array<AssetInfo>;
4621
+ stopAllMedia(): void;
4622
+ adjustVolume(volumeScale: number): void;
4623
+ protected recreateView(): void;
4624
+ }
4625
+
4626
+ declare function makeScene2D(name: string, runner: ThreadGeneratorFactory<View2D>): DescriptionOf<Scene2D>;
4627
+
4628
+ declare function useScene2D(): Scene2D;
4629
+
4630
+ declare function canvasStyleParser(style: PossibleCanvasStyle): Color | Gradient | Pattern | null;
4631
+ declare function resolveCanvasStyle(style: CanvasStyle, context: CanvasRenderingContext2D): string | CanvasGradient | CanvasPattern;
4632
+ declare function drawRoundRect(context: CanvasRenderingContext2D | Path2D, rect: BBox, radius: Spacing, smoothCorners: boolean, cornerSharpness: number): void;
4633
+ declare function adjustRectRadius(radius: number, horizontal: number, vertical: number, rect: BBox): number;
4634
+ declare function drawRect(context: CanvasRenderingContext2D | Path2D, rect: BBox): void;
4635
+ declare function fillRect(context: CanvasRenderingContext2D, rect: BBox): void;
4636
+ declare function strokeRect(context: CanvasRenderingContext2D, rect: BBox): void;
4637
+ declare function drawPolygon(path: CanvasRenderingContext2D | Path2D, rect: BBox, sides: number): void;
4638
+ declare function drawImage(context: CanvasRenderingContext2D, image: CanvasImageSource, destination: BBox): void;
4639
+ declare function drawImage(context: CanvasRenderingContext2D, image: CanvasImageSource, source: BBox, destination: BBox): void;
4640
+ declare function moveTo(context: CanvasRenderingContext2D | Path2D, position: Vector2): void;
4641
+ declare function lineTo(context: CanvasRenderingContext2D | Path2D, position: Vector2): void;
4642
+ declare function arcTo(context: CanvasRenderingContext2D | Path2D, through: Vector2, position: Vector2, radius: number): void;
4643
+ declare function drawLine(context: CanvasRenderingContext2D | Path2D, points: Vector2[]): void;
4644
+ declare function drawPivot(context: CanvasRenderingContext2D | Path2D, offset: Vector2, radius?: number): void;
4645
+ declare function arc(context: CanvasRenderingContext2D | Path2D, center: Vector2, radius: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void;
4646
+ declare function bezierCurveTo(context: CanvasRenderingContext2D | Path2D, controlPoint1: Vector2, controlPoint2: Vector2, to: Vector2): void;
4647
+ declare function quadraticCurveTo(context: CanvasRenderingContext2D | Path2D, controlPoint: Vector2, to: Vector2): void;
4648
+
4649
+ /**
4650
+ * Create a predicate that checks if the given object is an instance of the
4651
+ * given class.
4652
+ *
4653
+ * @param klass - The class to check against.
4654
+ */
4655
+ declare function is<T>(klass: new (...args: any[]) => T): (object: any) => object is T;
4656
+
4657
+ export { Audio, Bezier, type BezierOverlayInfo, CODE, type CanvasRepetition, type CanvasStyle, type CanvasStyleSignal, Circle, type CircleProps, CircleSegment, Code, CodeCursor, type CodeDiffer, type CodeFragment, type CodeFragmentDrawingInfo, type CodeHighlighter, type CodePoint, type CodeProps, type CodeRange, type CodeScope, type CodeSelection, type CodeSignal, CodeSignalContext, type CodeSignalHelpers, type CodeTag, type CodeTokenizer, type ComponentChild, type ComponentChildren, CubicBezier, type CubicBezierProps, CubicBezierSegment, Curve, type CurveDrawingInfo, type CurvePoint, type CurveProfile, type CurveProps, DefaultHighlightStyle, type DesiredLength, type DrawHooks, type DrawTokenHook, FILTERS, Filter, type FilterName, type FilterProps, type FiltersSignal, FiltersSignalContext, type FlexBasis, type FlexContent, type FlexDirection, type FlexItems, type FlexWrap, Fragment, type FunctionComponent, Gradient, type GradientProps, type GradientStop, type GradientType, Grid, type GridProps, type HighlightResult, Icon, type IconProps, Img, type ImgProps, type Initializer, JSX, type JSXProps, Knot, type KnotAuto, type KnotAutoHandles, type KnotAutoSignal, type KnotInfo, type KnotProps, Latex, type LatexProps, Layout, type LayoutMode, type LayoutProps, type Length, type LengthLimit, LezerHighlighter, Line, type LineProps, LineSegment, Media, type MediaProps, NODE_NAME, Node, type NodeChildren, type NodeConstructor, type NodeProps, type NodeState, Path, type PathProps, Pattern, type PatternProps, Polygon, type PolygonProps, Polynomial, Polynomial2D, type PossibleCanvasStyle, type PossibleCodeFragment, type PossibleCodeScope, type PossibleCodeSelection, type PossibleKnotAuto, type PropertyMetadata, type PropsOf, QuadBezier, type QuadBezierProps, QuadBezierSegment, type RawCodeFragment, Ray, type RayProps, Rect, type RectProps, Rive, type RiveProps, SVG, type SVGDocument, type SVGDocumentData, type SVGProps, type SVGShape, type SVGShapeData, Scene2D, Segment, Shape, type ShapeProps, Spline, type SplineProps, type TextWrap, Txt, type TxtProps, type Vector2LengthSignal, Video, type VideoProps, View2D, type View2DProps, addInitializer, adjustRectRadius, arc, arcTo, bezierCurveTo, blur, brightness, canvasStyleParser, canvasStyleSignal, cloneable, codeSignal, colorSignal, compound, computed, consolidateCodeRanges, contrast, defaultDiffer, defaultStyle, defaultTokenize, drawImage, drawLine, drawPivot, drawPolygon, drawRect, drawRoundRect, extractRange, fillRect, filtersSignal, findAllCodeRanges, getBezierSplineProfile, getCircleProfile, getPointAtDistance, getPolylineProfile, getPropertiesOf, getPropertyMeta, getPropertyMetaOrCreate, getRectProfile, grayscale, hue, initial, initialize, initializeSignals, insert, inspectable, interpolation, inverseCodeRange, invert, is, isCodeRange, isCodeScope, isPointInCodeRange, isPointInCodeSelection, jsx, jsx as jsxs, lineTo, lines, makeScene2D, metricsToFragment, moveTo, nodeName, parseCodeFragment, parseCodeScope, parseCodeSelection, parser, patienceDiff, pointToPoint, printDiff, quadraticCurveTo, remove, replace, resolveCanvasStyle, resolveCodeTag, resolveScope, saturate, sepia, signal, strokeRect, useScene2D, vector2Signal, word, wrapper };