@revideo/2d 0.4.7-two.1024 → 0.4.8-alpha.1032

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 (170) hide show
  1. package/editor/editor/tsconfig.build.tsbuildinfo +1 -1
  2. package/editor/index.js +151 -380
  3. package/editor/index.js.map +1 -1
  4. package/lib/code/CodeCursor.d.ts +74 -74
  5. package/lib/code/CodeDiffer.d.ts +16 -21
  6. package/lib/code/CodeDiffer.js +41 -39
  7. package/lib/code/CodeFragment.d.ts +8 -16
  8. package/lib/code/CodeFragment.js +36 -36
  9. package/lib/code/CodeHighlighter.d.ts +59 -59
  10. package/lib/code/CodeHighlighter.js +1 -1
  11. package/lib/code/CodeMetrics.d.ts +8 -12
  12. package/lib/code/CodeMetrics.js +24 -26
  13. package/lib/code/CodeRange.d.ts +5 -21
  14. package/lib/code/CodeRange.js +124 -131
  15. package/lib/code/CodeScope.d.ts +8 -18
  16. package/lib/code/CodeSelection.d.ts +4 -9
  17. package/lib/code/CodeSelection.js +8 -8
  18. package/lib/code/CodeSignal.d.ts +47 -74
  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/diff.d.ts +9 -12
  25. package/lib/code/diff.js +205 -218
  26. package/lib/code/extractRange.d.ts +4 -7
  27. package/lib/code/extractRange.js +71 -79
  28. package/lib/code/index.d.ts +1 -1
  29. package/lib/code/index.js +1 -1
  30. package/lib/components/Audio.d.ts +11 -11
  31. package/lib/components/Bezier.d.ts +18 -18
  32. package/lib/components/Circle.d.ts +90 -95
  33. package/lib/components/Code.d.ts +211 -244
  34. package/lib/components/CodeBlock.d.ts +1 -1
  35. package/lib/components/CubicBezier.d.ts +36 -36
  36. package/lib/components/Curve.d.ts +198 -208
  37. package/lib/components/Grid.d.ts +42 -47
  38. package/lib/components/Icon.d.ts +50 -55
  39. package/lib/components/Img.d.ts +79 -86
  40. package/lib/components/Knot.d.ts +78 -97
  41. package/lib/components/Latex.d.ts +12 -12
  42. package/lib/components/Layout.d.ts +413 -455
  43. package/lib/components/Line.d.ts +49 -61
  44. package/lib/components/Media.d.ts +37 -37
  45. package/lib/components/Node.d.ts +1 -1
  46. package/lib/components/Path.d.ts +1 -1
  47. package/lib/components/Polygon.d.ts +55 -60
  48. package/lib/components/QuadBezier.d.ts +29 -29
  49. package/lib/components/Ray.d.ts +28 -28
  50. package/lib/components/Rect.d.ts +108 -115
  51. package/lib/components/SVG.d.ts +1 -1
  52. package/lib/components/Shape.d.ts +1 -1
  53. package/lib/components/Spline.d.ts +40 -46
  54. package/lib/components/Txt.d.ts +44 -55
  55. package/lib/components/TxtLeaf.d.ts +16 -20
  56. package/lib/components/Video.d.ts +1 -0
  57. package/lib/components/Video.d.ts.map +1 -1
  58. package/lib/components/Video.js +9 -3
  59. package/lib/components/View2D.d.ts +22 -22
  60. package/lib/components/index.d.ts +2 -1
  61. package/lib/components/index.d.ts.map +1 -1
  62. package/lib/components/index.js +2 -1
  63. package/lib/components/types.d.ts +9 -22
  64. package/lib/curves/ArcSegment.d.ts +24 -36
  65. package/lib/curves/CircleSegment.d.ts +16 -26
  66. package/lib/curves/CubicBezierSegment.d.ts +13 -18
  67. package/lib/curves/CurveDrawingInfo.d.ts +9 -9
  68. package/lib/curves/CurvePoint.d.ts +13 -13
  69. package/lib/curves/CurveProfile.d.ts +5 -5
  70. package/lib/curves/CurveProfile.js +1 -1
  71. package/lib/curves/KnotInfo.d.ts +8 -8
  72. package/lib/curves/LineSegment.d.ts +14 -19
  73. package/lib/curves/Polynomial.d.ts +110 -110
  74. package/lib/curves/Polynomial2D.d.ts +20 -20
  75. package/lib/curves/PolynomialSegment.d.ts +37 -42
  76. package/lib/curves/QuadBezierSegment.d.ts +12 -12
  77. package/lib/curves/Segment.d.ts +7 -12
  78. package/lib/curves/UniformPolynomialCurveSampler.d.ts +34 -34
  79. package/lib/curves/createCurveProfileLerp.d.ts +6 -17
  80. package/lib/curves/getBezierSplineProfile.d.ts +4 -8
  81. package/lib/curves/getCircleProfile.d.ts +4 -10
  82. package/lib/curves/getPathProfile.d.ts +2 -2
  83. package/lib/curves/getPointAtDistance.d.ts +4 -7
  84. package/lib/curves/getPolylineProfile.d.ts +4 -8
  85. package/lib/curves/getRectProfile.d.ts +4 -9
  86. package/lib/curves/index.d.ts +1 -1
  87. package/lib/curves/index.js +1 -1
  88. package/lib/decorators/canvasStyleSignal.d.ts +3 -3
  89. package/lib/decorators/colorSignal.d.ts +1 -1
  90. package/lib/decorators/compound.d.ts +2 -4
  91. package/lib/decorators/computed.d.ts +1 -1
  92. package/lib/decorators/defaultStyle.d.ts +2 -5
  93. package/lib/decorators/filtersSignal.d.ts +8 -28
  94. package/lib/decorators/index.d.ts +1 -1
  95. package/lib/decorators/index.js +1 -1
  96. package/lib/decorators/initializers.d.ts +2 -5
  97. package/lib/decorators/initializers.js +19 -18
  98. package/lib/decorators/nodeName.d.ts +1 -1
  99. package/lib/decorators/nodeName.js +4 -4
  100. package/lib/decorators/signal.d.ts +20 -40
  101. package/lib/decorators/spacingSignal.d.ts +1 -1
  102. package/lib/decorators/vector2Signal.d.ts +7 -13
  103. package/lib/index.d.ts +1 -1
  104. package/lib/index.js +1 -1
  105. package/lib/jsx-dev-runtime.d.ts +3 -3
  106. package/lib/jsx-dev-runtime.js +3 -3
  107. package/lib/jsx-runtime.d.ts +9 -19
  108. package/lib/jsx-runtime.js +18 -18
  109. package/lib/partials/Filter.d.ts +16 -24
  110. package/lib/partials/Gradient.d.ts +24 -30
  111. package/lib/partials/Pattern.d.ts +9 -14
  112. package/lib/partials/ShaderConfig.d.ts +74 -81
  113. package/lib/partials/index.d.ts +1 -1
  114. package/lib/partials/index.js +1 -1
  115. package/lib/partials/types.d.ts +6 -19
  116. package/lib/scenes/Scene2D.d.ts +24 -42
  117. package/lib/scenes/Scene2D.d.ts.map +1 -1
  118. package/lib/scenes/Scene2D.js +10 -2
  119. package/lib/scenes/index.d.ts +1 -1
  120. package/lib/scenes/index.js +1 -1
  121. package/lib/scenes/makeScene2D.d.ts +5 -7
  122. package/lib/scenes/useScene2D.d.ts +2 -2
  123. package/lib/tsconfig.build.tsbuildinfo +1 -1
  124. package/lib/utils/diff.d.ts +18 -25
  125. package/lib/utils/diff.js +87 -84
  126. package/lib/utils/index.d.ts +1 -1
  127. package/lib/utils/index.js +1 -1
  128. package/lib/utils/is.d.ts +2 -4
  129. package/lib/utils/is.js +2 -2
  130. package/lib/utils/makeSignalExtensions.d.ts +4 -11
  131. package/lib/utils/video/mp4-parser-manager.d.ts +1 -0
  132. package/lib/utils/video/mp4-parser-manager.d.ts.map +1 -1
  133. package/lib/utils/video/mp4-parser-manager.js +21 -4
  134. package/lib/utils/video/parser/index.d.ts +2 -0
  135. package/lib/utils/video/parser/index.d.ts.map +1 -0
  136. package/lib/utils/video/parser/index.js +2 -0
  137. package/lib/utils/video/parser/parser.d.ts +21 -0
  138. package/lib/utils/video/parser/parser.d.ts.map +1 -0
  139. package/lib/utils/video/parser/parser.js +168 -0
  140. package/lib/utils/video/parser/sampler.d.ts +16 -0
  141. package/lib/utils/video/parser/sampler.d.ts.map +1 -0
  142. package/lib/utils/video/parser/sampler.js +56 -0
  143. package/lib/utils/video/parser/segment.d.ts +44 -0
  144. package/lib/utils/video/parser/segment.d.ts.map +1 -0
  145. package/lib/utils/video/parser/segment.js +195 -0
  146. package/lib/utils/video/parser/sink.d.ts +9 -0
  147. package/lib/utils/video/parser/sink.d.ts.map +1 -0
  148. package/lib/utils/video/parser/sink.js +22 -0
  149. package/lib/utils/video/parser/utils.d.ts +10 -0
  150. package/lib/utils/video/parser/utils.d.ts.map +1 -0
  151. package/lib/utils/video/parser/utils.js +22 -0
  152. package/package.json +4 -4
  153. package/src/lib/components/Video.ts +9 -2
  154. package/src/lib/components/index.ts +1 -0
  155. package/src/lib/scenes/Scene2D.ts +11 -1
  156. package/src/lib/utils/video/mp4-parser-manager.ts +24 -5
  157. package/src/lib/utils/video/parser/index.ts +1 -0
  158. package/src/lib/utils/video/parser/parser.ts +256 -0
  159. package/src/lib/utils/video/parser/sampler.ts +72 -0
  160. package/src/lib/utils/video/parser/segment.ts +252 -0
  161. package/src/lib/utils/video/parser/sink.ts +29 -0
  162. package/src/lib/utils/video/parser/utils.ts +31 -0
  163. package/lib/components/HlsVideo.d.ts +0 -62
  164. package/lib/components/HlsVideo.d.ts.map +0 -1
  165. package/lib/components/HlsVideo.js +0 -169
  166. package/lib/tsconfig.tsbuildinfo +0 -1
  167. package/lib/utils/video/mp4-parser.d.ts +0 -63
  168. package/lib/utils/video/mp4-parser.d.ts.map +0 -1
  169. package/lib/utils/video/mp4-parser.js +0 -264
  170. package/src/lib/utils/video/mp4-parser.ts +0 -340
@@ -1,77 +1,52 @@
1
- import {
2
- BBox,
3
- SerializedVector2,
4
- Signal,
5
- SignalValue,
6
- SimpleSignal,
7
- ThreadGenerator,
8
- TimingFunction,
9
- Vector2,
10
- } from '@revideo/core';
11
- import {
12
- CodeFragmentDrawingInfo,
13
- CodeHighlighter,
14
- CodePoint,
15
- CodeRange,
16
- CodeSelection,
17
- CodeSignal,
18
- LezerHighlighter,
19
- PossibleCodeScope,
20
- PossibleCodeSelection,
21
- } from '../code';
22
- import {DesiredLength} from '../partials';
23
- import {Shape, ShapeProps} from './Shape';
1
+ import { BBox, SerializedVector2, Signal, SignalValue, SimpleSignal, ThreadGenerator, TimingFunction, Vector2 } from '@revideo/core';
2
+ import { CodeFragmentDrawingInfo, CodeHighlighter, CodePoint, CodeRange, CodeSelection, CodeSignal, LezerHighlighter, PossibleCodeScope, PossibleCodeSelection } from '../code';
3
+ import { DesiredLength } from '../partials';
4
+ import { Shape, ShapeProps } from './Shape';
24
5
  export interface DrawTokenHook {
25
- (
26
- ctx: CanvasRenderingContext2D,
27
- text: string,
28
- position: Vector2,
29
- color: string,
30
- selection: number,
31
- ): void;
6
+ (ctx: CanvasRenderingContext2D, text: string, position: Vector2, color: string, selection: number): void;
32
7
  }
33
8
  /**
34
9
  * Describes custom drawing logic used by the Code node.
35
10
  */
36
11
  export interface DrawHooks {
37
- /**
38
- * Custom drawing logic for individual code tokens.
39
- *
40
- * @example
41
- * ```ts
42
- * token(ctx, text, position, color, selection) {
43
- * const blur = map(3, 0, selection);
44
- * const alpha = map(0.5, 1, selection);
45
- * ctx.globalAlpha *= alpha;
46
- * ctx.filter = `blur(${blur}px)`;
47
- * ctx.fillStyle = color;
48
- * ctx.fillText(text, position.x, position.y);
49
- * }
50
- * ```
51
- */
52
- token: DrawTokenHook;
12
+ /**
13
+ * Custom drawing logic for individual code tokens.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * token(ctx, text, position, color, selection) {
18
+ * const blur = map(3, 0, selection);
19
+ * const alpha = map(0.5, 1, selection);
20
+ * ctx.globalAlpha *= alpha;
21
+ * ctx.filter = `blur(${blur}px)`;
22
+ * ctx.fillStyle = color;
23
+ * ctx.fillText(text, position.x, position.y);
24
+ * }
25
+ * ```
26
+ */
27
+ token: DrawTokenHook;
53
28
  }
54
29
  export interface CodeProps extends ShapeProps {
55
- /**
56
- * {@inheritDoc Code.highlighter}
57
- */
58
- highlighter?: SignalValue<CodeHighlighter | null>;
59
- /**
60
- * {@inheritDoc Code.dialect}
61
- */
62
- dialect?: SignalValue<string>;
63
- /**
64
- * {@inheritDoc Code.code}
65
- */
66
- code?: SignalValue<PossibleCodeScope>;
67
- /**
68
- * {@inheritDoc Code.selection}
69
- */
70
- selection?: SignalValue<PossibleCodeSelection>;
71
- /**
72
- * {@inheritDoc Code.drawHooks}
73
- */
74
- drawHooks?: SignalValue<DrawHooks>;
30
+ /**
31
+ * {@inheritDoc Code.highlighter}
32
+ */
33
+ highlighter?: SignalValue<CodeHighlighter | null>;
34
+ /**
35
+ * {@inheritDoc Code.dialect}
36
+ */
37
+ dialect?: SignalValue<string>;
38
+ /**
39
+ * {@inheritDoc Code.code}
40
+ */
41
+ code?: SignalValue<PossibleCodeScope>;
42
+ /**
43
+ * {@inheritDoc Code.selection}
44
+ */
45
+ selection?: SignalValue<PossibleCodeSelection>;
46
+ /**
47
+ * {@inheritDoc Code.drawHooks}
48
+ */
49
+ drawHooks?: SignalValue<DrawHooks>;
75
50
  }
76
51
  /**
77
52
  * A node for displaying and animating code.
@@ -117,182 +92,174 @@ export interface CodeProps extends ShapeProps {
117
92
  * ```
118
93
  */
119
94
  export declare class Code extends Shape {
120
- /**
121
- * Create a standalone code signal.
122
- *
123
- * @param initial - The initial code.
124
- * @param highlighter - Custom highlighter to use.
125
- * @param dialect - Custom dialect to use.
126
- */
127
- static createSignal(
128
- initial: PossibleCodeScope,
129
- highlighter?: SignalValue<CodeHighlighter>,
130
- dialect?: SignalValue<string>,
131
- ): CodeSignal<void>;
132
- static readonly defaultHighlighter: LezerHighlighter;
133
- /**
134
- * The dialect to use for highlighting the code.
135
- *
136
- * @remarks
137
- * This value will be passed to the {@link code.CodeHighlighter}
138
- * defined by the {@link highlighter} property. Different highlighters may use
139
- * it differently.
140
- *
141
- * The default {@link code.LezerHighlighter} uses it to select
142
- * the language parser to use. The parser for the given dialect can be
143
- * registered as follows:
144
- * ```tsx
145
- * // Import the lezer parser:
146
- * import {parser} from '@lezer/javascript';
147
- *
148
- * // Register it in the highlighter:
149
- * LezerHighlighter.registerParser(parser, 'js');
150
- *
151
- * // Use the dialect in a code node:
152
- * <Code dialect="js" code="const a = 7;" />
153
- * ```
154
- * When no dialect is provided, the highlighter will use the default
155
- * parser:
156
- * ```tsx
157
- * // Register the default parser by omitting the dialect:
158
- * LezerHighlighter.registerParser(parser);
159
- *
160
- * // Code nodes with no dialect will now use the default parser:
161
- * <Code code="const a = 7;" />
162
- * ```
163
- */
164
- readonly dialect: SimpleSignal<string, this>;
165
- /**
166
- * The code highlighter to use for this code node.
167
- *
168
- * @remarks
169
- * Defaults to a shared {@link code.LezerHighlighter}.
170
- */
171
- readonly highlighter: SimpleSignal<CodeHighlighter, this>;
172
- /**
173
- * The code to display.
174
- */
175
- readonly code: CodeSignal<this>;
176
- /**
177
- * Custom drawing logic for the code.
178
- *
179
- * @remarks
180
- * Check out {@link DrawHooks} for available render hooks.
181
- *
182
- * @example
183
- * Make the unselected code blurry and transparent:
184
- * ```tsx
185
- * <Code
186
- * drawHooks={{
187
- * token(ctx, text, position, color, selection) {
188
- * const blur = map(3, 0, selection);
189
- * const alpha = map(0.5, 1, selection);
190
- * ctx.globalAlpha *= alpha;
191
- * ctx.filter = `blur(${blur}px)`;
192
- * ctx.fillStyle = color;
193
- * ctx.fillText(text, position.x, position.y);
194
- * },
195
- * }}
196
- * // ...
197
- * />
198
- * ```
199
- */
200
- readonly drawHooks: SimpleSignal<DrawHooks, this>;
201
- /**
202
- * The currently selected code range.
203
- *
204
- * @remarks
205
- * Either a single {@link code.CodeRange} or an array of them
206
- * describing which parts of the code should be visually emphasized.
207
- *
208
- * You can use {@link code.word} and
209
- * {@link code.lines} to quickly create ranges.
210
- *
211
- * @example
212
- * The following will select the word "console" in the code.
213
- * Both lines and columns are 0-based. So it will select a 7-character-long
214
- * (`7`) word in the second line (`1`) starting at the third character (`2`).
215
- * ```tsx
216
- * <Code
217
- * selection={word(1, 2, 7)}
218
- * code={`\
219
- * function hello() => {
220
- * console.log('Hello');
221
- * }`}
222
- * // ...
223
- * />
224
- * ```
225
- */
226
- readonly selection: Signal<PossibleCodeSelection, CodeSelection, this>;
227
- oldSelection: CodeSelection | null;
228
- selectionProgress: SimpleSignal<number | null, void>;
229
- protected tweenSelection(
230
- value: CodeRange[],
231
- duration: number,
232
- timingFunction: TimingFunction,
233
- ): ThreadGenerator;
234
- /**
235
- * Get the currently displayed code as a string.
236
- */
237
- parsed(): string;
238
- highlighterCache(): {
239
- before: unknown;
240
- after: unknown;
241
- } | null;
242
- private cursorCache;
243
- private get cursor();
244
- constructor(props: CodeProps);
245
- /**
246
- * Create a child code signal.
247
- *
248
- * @param initial - The initial code.
249
- */
250
- createSignal(initial: PossibleCodeScope): CodeSignal<this>;
251
- /**
252
- * Find all code ranges that match the given pattern.
253
- *
254
- * @param pattern - Either a string or a regular expression to match.
255
- */
256
- findAllRanges(pattern: string | RegExp): CodeRange[];
257
- /**
258
- * Find the first code range that matches the given pattern.
259
- *
260
- * @param pattern - Either a string or a regular expression to match.
261
- */
262
- findFirstRange(pattern: string | RegExp): CodeRange;
263
- /**
264
- * Find the last code range that matches the given pattern.
265
- *
266
- * @param pattern - Either a string or a regular expression to match.
267
- */
268
- findLastRange(pattern: string | RegExp): CodeRange;
269
- /**
270
- * Return the bounding box of the given point (character) in the code.
271
- *
272
- * @remarks
273
- * The returned bound box is in local space of the `Code` node.
274
- *
275
- * @param point - The point to get the bounding box for.
276
- */
277
- getPointBbox(point: CodePoint): BBox;
278
- /**
279
- * Return bounding boxes of all characters in the selection.
280
- *
281
- * @remarks
282
- * The returned bound boxes are in local space of the `Code` node.
283
- * Each line of code has a separate bounding box.
284
- *
285
- * @param selection - The selection to get the bounding boxes for.
286
- */
287
- getSelectionBbox(selection: PossibleCodeSelection): BBox[];
288
- protected drawingInfo(): {
289
- fragments: CodeFragmentDrawingInfo[];
290
- verticalOffset: number;
291
- fontHeight: number;
292
- };
293
- protected desiredSize(): SerializedVector2<DesiredLength>;
294
- protected draw(context: CanvasRenderingContext2D): Promise<void>;
295
- protected applyText(context: CanvasRenderingContext2D): void;
296
- protected collectAsyncResources(): void;
95
+ /**
96
+ * Create a standalone code signal.
97
+ *
98
+ * @param initial - The initial code.
99
+ * @param highlighter - Custom highlighter to use.
100
+ * @param dialect - Custom dialect to use.
101
+ */
102
+ static createSignal(initial: PossibleCodeScope, highlighter?: SignalValue<CodeHighlighter>, dialect?: SignalValue<string>): CodeSignal<void>;
103
+ static readonly defaultHighlighter: LezerHighlighter;
104
+ /**
105
+ * The dialect to use for highlighting the code.
106
+ *
107
+ * @remarks
108
+ * This value will be passed to the {@link code.CodeHighlighter}
109
+ * defined by the {@link highlighter} property. Different highlighters may use
110
+ * it differently.
111
+ *
112
+ * The default {@link code.LezerHighlighter} uses it to select
113
+ * the language parser to use. The parser for the given dialect can be
114
+ * registered as follows:
115
+ * ```tsx
116
+ * // Import the lezer parser:
117
+ * import {parser} from '@lezer/javascript';
118
+ *
119
+ * // Register it in the highlighter:
120
+ * LezerHighlighter.registerParser(parser, 'js');
121
+ *
122
+ * // Use the dialect in a code node:
123
+ * <Code dialect="js" code="const a = 7;" />
124
+ * ```
125
+ * When no dialect is provided, the highlighter will use the default
126
+ * parser:
127
+ * ```tsx
128
+ * // Register the default parser by omitting the dialect:
129
+ * LezerHighlighter.registerParser(parser);
130
+ *
131
+ * // Code nodes with no dialect will now use the default parser:
132
+ * <Code code="const a = 7;" />
133
+ * ```
134
+ */
135
+ readonly dialect: SimpleSignal<string, this>;
136
+ /**
137
+ * The code highlighter to use for this code node.
138
+ *
139
+ * @remarks
140
+ * Defaults to a shared {@link code.LezerHighlighter}.
141
+ */
142
+ readonly highlighter: SimpleSignal<CodeHighlighter, this>;
143
+ /**
144
+ * The code to display.
145
+ */
146
+ readonly code: CodeSignal<this>;
147
+ /**
148
+ * Custom drawing logic for the code.
149
+ *
150
+ * @remarks
151
+ * Check out {@link DrawHooks} for available render hooks.
152
+ *
153
+ * @example
154
+ * Make the unselected code blurry and transparent:
155
+ * ```tsx
156
+ * <Code
157
+ * drawHooks={{
158
+ * token(ctx, text, position, color, selection) {
159
+ * const blur = map(3, 0, selection);
160
+ * const alpha = map(0.5, 1, selection);
161
+ * ctx.globalAlpha *= alpha;
162
+ * ctx.filter = `blur(${blur}px)`;
163
+ * ctx.fillStyle = color;
164
+ * ctx.fillText(text, position.x, position.y);
165
+ * },
166
+ * }}
167
+ * // ...
168
+ * />
169
+ * ```
170
+ */
171
+ readonly drawHooks: SimpleSignal<DrawHooks, this>;
172
+ /**
173
+ * The currently selected code range.
174
+ *
175
+ * @remarks
176
+ * Either a single {@link code.CodeRange} or an array of them
177
+ * describing which parts of the code should be visually emphasized.
178
+ *
179
+ * You can use {@link code.word} and
180
+ * {@link code.lines} to quickly create ranges.
181
+ *
182
+ * @example
183
+ * The following will select the word "console" in the code.
184
+ * Both lines and columns are 0-based. So it will select a 7-character-long
185
+ * (`7`) word in the second line (`1`) starting at the third character (`2`).
186
+ * ```tsx
187
+ * <Code
188
+ * selection={word(1, 2, 7)}
189
+ * code={`\
190
+ * function hello() => {
191
+ * console.log('Hello');
192
+ * }`}
193
+ * // ...
194
+ * />
195
+ * ```
196
+ */
197
+ readonly selection: Signal<PossibleCodeSelection, CodeSelection, this>;
198
+ oldSelection: CodeSelection | null;
199
+ selectionProgress: SimpleSignal<number | null, void>;
200
+ protected tweenSelection(value: CodeRange[], duration: number, timingFunction: TimingFunction): ThreadGenerator;
201
+ /**
202
+ * Get the currently displayed code as a string.
203
+ */
204
+ parsed(): string;
205
+ highlighterCache(): {
206
+ before: unknown;
207
+ after: unknown;
208
+ } | null;
209
+ private cursorCache;
210
+ private get cursor();
211
+ constructor(props: CodeProps);
212
+ /**
213
+ * Create a child code signal.
214
+ *
215
+ * @param initial - The initial code.
216
+ */
217
+ createSignal(initial: PossibleCodeScope): CodeSignal<this>;
218
+ /**
219
+ * Find all code ranges that match the given pattern.
220
+ *
221
+ * @param pattern - Either a string or a regular expression to match.
222
+ */
223
+ findAllRanges(pattern: string | RegExp): CodeRange[];
224
+ /**
225
+ * Find the first code range that matches the given pattern.
226
+ *
227
+ * @param pattern - Either a string or a regular expression to match.
228
+ */
229
+ findFirstRange(pattern: string | RegExp): CodeRange;
230
+ /**
231
+ * Find the last code range that matches the given pattern.
232
+ *
233
+ * @param pattern - Either a string or a regular expression to match.
234
+ */
235
+ findLastRange(pattern: string | RegExp): CodeRange;
236
+ /**
237
+ * Return the bounding box of the given point (character) in the code.
238
+ *
239
+ * @remarks
240
+ * The returned bound box is in local space of the `Code` node.
241
+ *
242
+ * @param point - The point to get the bounding box for.
243
+ */
244
+ getPointBbox(point: CodePoint): BBox;
245
+ /**
246
+ * Return bounding boxes of all characters in the selection.
247
+ *
248
+ * @remarks
249
+ * The returned bound boxes are in local space of the `Code` node.
250
+ * Each line of code has a separate bounding box.
251
+ *
252
+ * @param selection - The selection to get the bounding boxes for.
253
+ */
254
+ getSelectionBbox(selection: PossibleCodeSelection): BBox[];
255
+ protected drawingInfo(): {
256
+ fragments: CodeFragmentDrawingInfo[];
257
+ verticalOffset: number;
258
+ fontHeight: number;
259
+ };
260
+ protected desiredSize(): SerializedVector2<DesiredLength>;
261
+ protected draw(context: CanvasRenderingContext2D): Promise<void>;
262
+ protected applyText(context: CanvasRenderingContext2D): void;
263
+ protected collectAsyncResources(): void;
297
264
  }
298
- //# sourceMappingURL=Code.d.ts.map
265
+ //# sourceMappingURL=Code.d.ts.map
@@ -65,7 +65,7 @@ export declare class CodeBlock extends Shape {
65
65
  * it instead.
66
66
  */
67
67
  edit(duration?: number, changeSelection?: CodeRange[] | boolean): (strings: TemplateStringsArray, ...rest: (Code | CodeModification)[]) => ThreadGenerator;
68
- tweenCode(code: CodeTree, time: number, timingFunction: TimingFunction): Generator<void | Promise<any> | ThreadGenerator | import("@revideo/core").Promisable<any>, void, any>;
68
+ tweenCode(code: CodeTree, time: number, timingFunction: TimingFunction): Generator<void | ThreadGenerator | Promise<any> | import("@revideo/core").Promisable<any>, void, any>;
69
69
  protected draw(context: CanvasRenderingContext2D): Promise<void>;
70
70
  protected selectionStrength(x: number, y: number): number;
71
71
  protected static selectionStrength(selection: CodeRange[], x: number, y: number): number;
@@ -1,20 +1,20 @@
1
- import {PossibleVector2, SignalValue, Vector2Signal} from '@revideo/core';
2
- import {PolynomialSegment} from '../curves/PolynomialSegment';
3
- import {Bezier, BezierOverlayInfo} from './Bezier';
4
- import {CurveProps} from './Curve';
1
+ import { PossibleVector2, SignalValue, Vector2Signal } from '@revideo/core';
2
+ import { PolynomialSegment } from '../curves/PolynomialSegment';
3
+ import { Bezier, BezierOverlayInfo } from './Bezier';
4
+ import { CurveProps } from './Curve';
5
5
  export interface CubicBezierProps extends CurveProps {
6
- p0?: SignalValue<PossibleVector2>;
7
- p0X?: SignalValue<number>;
8
- p0Y?: SignalValue<number>;
9
- p1?: SignalValue<PossibleVector2>;
10
- p1X?: SignalValue<number>;
11
- p1Y?: SignalValue<number>;
12
- p2?: SignalValue<PossibleVector2>;
13
- p2X?: SignalValue<number>;
14
- p2Y?: SignalValue<number>;
15
- p3?: SignalValue<PossibleVector2>;
16
- p3X?: SignalValue<number>;
17
- p3Y?: SignalValue<number>;
6
+ p0?: SignalValue<PossibleVector2>;
7
+ p0X?: SignalValue<number>;
8
+ p0Y?: SignalValue<number>;
9
+ p1?: SignalValue<PossibleVector2>;
10
+ p1X?: SignalValue<number>;
11
+ p1Y?: SignalValue<number>;
12
+ p2?: SignalValue<PossibleVector2>;
13
+ p2X?: SignalValue<number>;
14
+ p2Y?: SignalValue<number>;
15
+ p3?: SignalValue<PossibleVector2>;
16
+ p3X?: SignalValue<number>;
17
+ p3Y?: SignalValue<number>;
18
18
  }
19
19
  /**
20
20
  * A node for drawing a cubic Bézier curve.
@@ -46,24 +46,24 @@ export interface CubicBezierProps extends CurveProps {
46
46
  * ```
47
47
  */
48
48
  export declare class CubicBezier extends Bezier {
49
- /**
50
- * The start point of the Bézier curve.
51
- */
52
- readonly p0: Vector2Signal<this>;
53
- /**
54
- * The first control point of the Bézier curve.
55
- */
56
- readonly p1: Vector2Signal<this>;
57
- /**
58
- * The second control point of the Bézier curve.
59
- */
60
- readonly p2: Vector2Signal<this>;
61
- /**
62
- * The end point of the Bézier curve.
63
- */
64
- readonly p3: Vector2Signal<this>;
65
- constructor(props: CubicBezierProps);
66
- protected segment(): PolynomialSegment;
67
- protected overlayInfo(matrix: DOMMatrix): BezierOverlayInfo;
49
+ /**
50
+ * The start point of the Bézier curve.
51
+ */
52
+ readonly p0: Vector2Signal<this>;
53
+ /**
54
+ * The first control point of the Bézier curve.
55
+ */
56
+ readonly p1: Vector2Signal<this>;
57
+ /**
58
+ * The second control point of the Bézier curve.
59
+ */
60
+ readonly p2: Vector2Signal<this>;
61
+ /**
62
+ * The end point of the Bézier curve.
63
+ */
64
+ readonly p3: Vector2Signal<this>;
65
+ constructor(props: CubicBezierProps);
66
+ protected segment(): PolynomialSegment;
67
+ protected overlayInfo(matrix: DOMMatrix): BezierOverlayInfo;
68
68
  }
69
- //# sourceMappingURL=CubicBezier.d.ts.map
69
+ //# sourceMappingURL=CubicBezier.d.ts.map