@revideo/2d 0.2.1 → 0.2.2

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