@revideo/2d 0.4.7-alpha.1027 → 0.4.7-five.1022

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 (164) hide show
  1. package/editor/editor/tsconfig.build.tsbuildinfo +1 -1
  2. package/editor/index.js +380 -151
  3. package/editor/index.js.map +1 -1
  4. package/lib/code/CodeCursor.d.ts +74 -74
  5. package/lib/code/CodeDiffer.d.ts +21 -16
  6. package/lib/code/CodeDiffer.js +39 -41
  7. package/lib/code/CodeFragment.d.ts +16 -8
  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 +12 -8
  12. package/lib/code/CodeMetrics.js +26 -24
  13. package/lib/code/CodeRange.d.ts +21 -5
  14. package/lib/code/CodeRange.js +131 -124
  15. package/lib/code/CodeScope.d.ts +18 -8
  16. package/lib/code/CodeSelection.d.ts +9 -4
  17. package/lib/code/CodeSelection.js +8 -8
  18. package/lib/code/CodeSignal.d.ts +74 -47
  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 +21 -19
  24. package/lib/code/diff.d.ts +12 -9
  25. package/lib/code/diff.js +218 -205
  26. package/lib/code/extractRange.d.ts +7 -4
  27. package/lib/code/extractRange.js +79 -71
  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 +95 -90
  33. package/lib/components/Code.d.ts +244 -211
  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 +208 -198
  37. package/lib/components/Grid.d.ts +47 -42
  38. package/lib/components/HlsVideo.d.ts +62 -0
  39. package/lib/components/HlsVideo.d.ts.map +1 -0
  40. package/lib/components/HlsVideo.js +169 -0
  41. package/lib/components/Icon.d.ts +55 -50
  42. package/lib/components/Img.d.ts +86 -79
  43. package/lib/components/Knot.d.ts +97 -78
  44. package/lib/components/Latex.d.ts +12 -12
  45. package/lib/components/Layout.d.ts +455 -413
  46. package/lib/components/Line.d.ts +61 -49
  47. package/lib/components/Media.d.ts +37 -37
  48. package/lib/components/Node.d.ts +1 -1
  49. package/lib/components/Path.d.ts +1 -1
  50. package/lib/components/Polygon.d.ts +60 -55
  51. package/lib/components/QuadBezier.d.ts +29 -29
  52. package/lib/components/Ray.d.ts +28 -28
  53. package/lib/components/Rect.d.ts +115 -108
  54. package/lib/components/SVG.d.ts +1 -1
  55. package/lib/components/Shape.d.ts +1 -1
  56. package/lib/components/Spline.d.ts +46 -40
  57. package/lib/components/Txt.d.ts +55 -44
  58. package/lib/components/TxtLeaf.d.ts +20 -16
  59. package/lib/components/Video.d.ts +0 -1
  60. package/lib/components/Video.d.ts.map +1 -1
  61. package/lib/components/Video.js +2 -7
  62. package/lib/components/View2D.d.ts +22 -22
  63. package/lib/components/index.d.ts +1 -1
  64. package/lib/components/types.d.ts +22 -9
  65. package/lib/curves/ArcSegment.d.ts +36 -24
  66. package/lib/curves/CircleSegment.d.ts +26 -16
  67. package/lib/curves/CubicBezierSegment.d.ts +18 -13
  68. package/lib/curves/CurveDrawingInfo.d.ts +9 -9
  69. package/lib/curves/CurvePoint.d.ts +13 -13
  70. package/lib/curves/CurveProfile.d.ts +5 -5
  71. package/lib/curves/CurveProfile.js +1 -1
  72. package/lib/curves/KnotInfo.d.ts +8 -8
  73. package/lib/curves/LineSegment.d.ts +19 -14
  74. package/lib/curves/Polynomial.d.ts +110 -110
  75. package/lib/curves/Polynomial2D.d.ts +20 -20
  76. package/lib/curves/PolynomialSegment.d.ts +42 -37
  77. package/lib/curves/QuadBezierSegment.d.ts +12 -12
  78. package/lib/curves/Segment.d.ts +12 -7
  79. package/lib/curves/UniformPolynomialCurveSampler.d.ts +34 -34
  80. package/lib/curves/createCurveProfileLerp.d.ts +17 -6
  81. package/lib/curves/getBezierSplineProfile.d.ts +8 -4
  82. package/lib/curves/getCircleProfile.d.ts +10 -4
  83. package/lib/curves/getPathProfile.d.ts +2 -2
  84. package/lib/curves/getPointAtDistance.d.ts +7 -4
  85. package/lib/curves/getPolylineProfile.d.ts +8 -4
  86. package/lib/curves/getRectProfile.d.ts +9 -4
  87. package/lib/curves/index.d.ts +1 -1
  88. package/lib/curves/index.js +1 -1
  89. package/lib/decorators/canvasStyleSignal.d.ts +3 -3
  90. package/lib/decorators/colorSignal.d.ts +1 -1
  91. package/lib/decorators/compound.d.ts +4 -2
  92. package/lib/decorators/computed.d.ts +1 -1
  93. package/lib/decorators/defaultStyle.d.ts +5 -2
  94. package/lib/decorators/filtersSignal.d.ts +28 -8
  95. package/lib/decorators/index.d.ts +1 -1
  96. package/lib/decorators/index.js +1 -1
  97. package/lib/decorators/initializers.d.ts +5 -2
  98. package/lib/decorators/initializers.js +18 -19
  99. package/lib/decorators/nodeName.d.ts +1 -1
  100. package/lib/decorators/nodeName.js +4 -4
  101. package/lib/decorators/signal.d.ts +40 -20
  102. package/lib/decorators/spacingSignal.d.ts +1 -1
  103. package/lib/decorators/vector2Signal.d.ts +13 -7
  104. package/lib/index.d.ts +1 -1
  105. package/lib/index.js +1 -1
  106. package/lib/jsx-dev-runtime.d.ts +3 -3
  107. package/lib/jsx-dev-runtime.js +3 -3
  108. package/lib/jsx-runtime.d.ts +19 -9
  109. package/lib/jsx-runtime.js +18 -18
  110. package/lib/partials/Filter.d.ts +24 -16
  111. package/lib/partials/Gradient.d.ts +30 -24
  112. package/lib/partials/Pattern.d.ts +14 -9
  113. package/lib/partials/ShaderConfig.d.ts +81 -74
  114. package/lib/partials/index.d.ts +1 -1
  115. package/lib/partials/index.js +1 -1
  116. package/lib/partials/types.d.ts +19 -6
  117. package/lib/scenes/Scene2D.d.ts +42 -23
  118. package/lib/scenes/index.d.ts +1 -1
  119. package/lib/scenes/index.js +1 -1
  120. package/lib/scenes/makeScene2D.d.ts +7 -5
  121. package/lib/scenes/useScene2D.d.ts +2 -2
  122. package/lib/tsconfig.build.tsbuildinfo +1 -1
  123. package/lib/tsconfig.tsbuildinfo +1 -0
  124. package/lib/utils/diff.d.ts +25 -18
  125. package/lib/utils/diff.js +84 -87
  126. package/lib/utils/index.d.ts +1 -1
  127. package/lib/utils/index.js +1 -1
  128. package/lib/utils/is.d.ts +4 -2
  129. package/lib/utils/is.js +2 -2
  130. package/lib/utils/makeSignalExtensions.d.ts +11 -4
  131. package/lib/utils/video/mp4-parser-manager.d.ts +0 -1
  132. package/lib/utils/video/mp4-parser-manager.d.ts.map +1 -1
  133. package/lib/utils/video/mp4-parser-manager.js +4 -21
  134. package/lib/utils/video/mp4-parser.d.ts +63 -0
  135. package/lib/utils/video/mp4-parser.d.ts.map +1 -0
  136. package/lib/utils/video/mp4-parser.js +264 -0
  137. package/package.json +4 -4
  138. package/src/lib/components/Video.ts +1 -7
  139. package/src/lib/utils/video/mp4-parser-manager.ts +5 -24
  140. package/src/lib/utils/video/mp4-parser.ts +340 -0
  141. package/lib/utils/video/parser/index.d.ts +0 -2
  142. package/lib/utils/video/parser/index.d.ts.map +0 -1
  143. package/lib/utils/video/parser/index.js +0 -2
  144. package/lib/utils/video/parser/parser.d.ts +0 -21
  145. package/lib/utils/video/parser/parser.d.ts.map +0 -1
  146. package/lib/utils/video/parser/parser.js +0 -165
  147. package/lib/utils/video/parser/sampler.d.ts +0 -16
  148. package/lib/utils/video/parser/sampler.d.ts.map +0 -1
  149. package/lib/utils/video/parser/sampler.js +0 -56
  150. package/lib/utils/video/parser/segment.d.ts +0 -43
  151. package/lib/utils/video/parser/segment.d.ts.map +0 -1
  152. package/lib/utils/video/parser/segment.js +0 -153
  153. package/lib/utils/video/parser/sink.d.ts +0 -9
  154. package/lib/utils/video/parser/sink.d.ts.map +0 -1
  155. package/lib/utils/video/parser/sink.js +0 -22
  156. package/lib/utils/video/parser/utils.d.ts +0 -10
  157. package/lib/utils/video/parser/utils.d.ts.map +0 -1
  158. package/lib/utils/video/parser/utils.js +0 -22
  159. package/src/lib/utils/video/parser/index.ts +0 -1
  160. package/src/lib/utils/video/parser/parser.ts +0 -253
  161. package/src/lib/utils/video/parser/sampler.ts +0 -72
  162. package/src/lib/utils/video/parser/segment.ts +0 -202
  163. package/src/lib/utils/video/parser/sink.ts +0 -29
  164. package/src/lib/utils/video/parser/utils.ts +0 -31
@@ -1,202 +0,0 @@
1
- import {MP4FileSink} from './sink';
2
- import {Edit} from './utils';
3
-
4
- export class Segment {
5
- private done: boolean = false;
6
- private uri: string;
7
-
8
- private file: any;
9
- private edit: Edit;
10
-
11
- private responseFinished: boolean = false;
12
- private decoder: VideoDecoder;
13
-
14
- private framesProcessed = 0;
15
- private startTime: number;
16
- private framesDue = 0;
17
- private frameBuffer: VideoFrame[] = [];
18
-
19
- private readMore: () => Promise<void> = async () => {};
20
-
21
- public constructor(
22
- uri: string,
23
- file: any,
24
- edits: Edit[],
25
- currentSegment: number,
26
- startTime: number = 0,
27
- ) {
28
- this.uri = uri;
29
-
30
- this.file = file;
31
- this.file.onSamples = this.onSamples.bind(this);
32
- this.edit = edits[currentSegment];
33
-
34
- this.startTime = startTime;
35
-
36
- // Check how many frames we skipped because of the startTime and add them to the frames processed.
37
- const framesSkipped = Math.floor(this.startTime * this.edit.fps);
38
- this.framesProcessed += framesSkipped;
39
-
40
- this.decoder = new VideoDecoder({
41
- output: this.onFrame.bind(this),
42
- error(e) {
43
- console.error(e);
44
- },
45
- });
46
- }
47
-
48
- public async start(decoderConfig: VideoDecoderConfig) {
49
- this.decoder.configure(decoderConfig);
50
- const videoTrack = this.file.getInfo().videoTracks[0];
51
- const trak = this.file.getTrackById(videoTrack.id);
52
-
53
- const mediaTimeInTimescale = this.edit.mediaTime;
54
- const startTimeInTimescale = this.startTime * videoTrack.timescale;
55
- const seekTimeInTimescale = mediaTimeInTimescale + startTimeInTimescale;
56
-
57
- const seekTimeInSec = seekTimeInTimescale / videoTrack.timescale;
58
- const seekInfo = this.file.seekTrack(seekTimeInSec, true, trak);
59
- this.readMore = await this.startStreamingAtOffset(
60
- this.file,
61
- this.uri,
62
- seekInfo.offset,
63
- );
64
- }
65
-
66
- /**
67
- * Starts streaming the video at the given URI from the given offset.
68
- * @param file - MP4Box file. Needs to be created and configured before calling this function.
69
- * @param uri - URI of the video file.
70
- * @param offset - Offset to start streaming from.
71
- * @returns - A function to read more data from the response.
72
- */
73
- private async startStreamingAtOffset(file: any, uri: string, offset: number) {
74
- return fetch(uri, {
75
- headers: {
76
- /* eslint-disable-next-line @typescript-eslint/naming-convention */
77
- Range: `bytes=${offset}-`,
78
- },
79
- }).then(async response => {
80
- if (!response.body) {
81
- throw new Error('Response body is null');
82
- }
83
-
84
- const reader = response.body.getReader();
85
- const sink = new MP4FileSink(file, () => {}, offset);
86
-
87
- return async () => {
88
- return reader.read().then(({done, value}) => {
89
- // Request is done.
90
- if (done) {
91
- this.responseFinished = true;
92
- this.decoder.flush();
93
- sink.close();
94
- return;
95
- }
96
-
97
- sink.write(value);
98
- });
99
- };
100
- });
101
- }
102
-
103
- /**
104
- * Called when samples are available on the MP4 file.
105
- * Sends chunks to the decoder.
106
- */
107
- private onSamples(_unused1: any, _unused2: any, samples: any) {
108
- for (const sample of samples) {
109
- const chunk = new EncodedVideoChunk({
110
- type: sample.is_sync ? 'key' : 'delta',
111
- timestamp: (1e6 * sample.cts) / sample.timescale,
112
- duration: (1e6 * sample.duration) / sample.timescale,
113
- data: sample.data,
114
- });
115
- this.framesDue++;
116
- this.decoder.decode(chunk);
117
- }
118
- }
119
-
120
- /**
121
- * Called when the decoder has a frame ready.
122
- * Pushes the frame to the buffer so it can be consumed.
123
- */
124
- private onFrame(frame: VideoFrame) {
125
- this.framesDue--;
126
-
127
- // If the frame comes before the seek time, close it.
128
- const mediaTimeInSec =
129
- this.edit.mediaTime / this.file.getInfo().videoTracks[0].timescale;
130
- const seekTimeInSec = this.startTime + mediaTimeInSec;
131
- const frameTimeInSec = frame.timestamp / 1e6;
132
- if (frameTimeInSec < seekTimeInSec) {
133
- frame.close();
134
- return;
135
- }
136
-
137
- // Check if we are past the segment duration.
138
- const segmentDurationInSec =
139
- this.edit.segmentDuration /
140
- this.file.getInfo().videoTracks[0].movie_timescale;
141
- const segmentEndTime = mediaTimeInSec + segmentDurationInSec;
142
- if (frameTimeInSec > segmentEndTime) {
143
- frame.close();
144
- this.done = true;
145
- this.decoder.flush();
146
- return;
147
- }
148
-
149
- this.frameBuffer.push(frame);
150
- }
151
-
152
- private async populateBuffer() {
153
- // Fetch more frames if we don't have any.
154
- while (this.frameBuffer.length === 0 && !this.responseFinished) {
155
- await this.readMore();
156
- await new Promise(res => setTimeout(res, 0));
157
- }
158
-
159
- // Wait for decoder if there are frames due.
160
- if (this.frameBuffer.length === 0 && this.framesDue > 0) {
161
- let maxIterations = 1000;
162
- while (this.frameBuffer.length === 0) {
163
- await new Promise(res => setTimeout(res, 10));
164
- maxIterations--;
165
-
166
- if (this.done) {
167
- return;
168
- }
169
-
170
- if (maxIterations === 0) {
171
- throw new Error(
172
- `Timed out while waiting for VideoDecoder to produce a frame. Frames due: ${this.framesDue}`,
173
- );
174
- }
175
- }
176
- }
177
- }
178
-
179
- public async getNextFrame() {
180
- await this.populateBuffer();
181
- const frame = this.frameBuffer.shift();
182
- if (frame) {
183
- this.framesProcessed++;
184
- }
185
- return frame;
186
- }
187
-
188
- /**
189
- * Called when we are done with the extractor.
190
- */
191
- public close() {
192
- this.frameBuffer.forEach(frame => frame.close());
193
- }
194
-
195
- public getFramesProcessed() {
196
- return this.framesProcessed;
197
- }
198
-
199
- public getStartTime() {
200
- return this.startTime;
201
- }
202
- }
@@ -1,29 +0,0 @@
1
- // Wraps an MP4Box File as a WritableStream underlying sink.
2
- export class MP4FileSink {
3
- private setStatus;
4
- private file;
5
- private offset;
6
-
7
- public constructor(file: any, setStatus: any, offset: number = 0) {
8
- this.file = file;
9
- this.setStatus = setStatus;
10
- this.offset = offset;
11
- }
12
-
13
- public write(chunk: any) {
14
- const buffer = new ArrayBuffer(chunk.byteLength);
15
- new Uint8Array(buffer).set(chunk);
16
-
17
- // Inform MP4Box where in the file this chunk is from.
18
- (buffer as any).fileStart = this.offset;
19
- this.offset += buffer.byteLength;
20
-
21
- this.setStatus('fetch', (this.offset / 1024 ** 2).toFixed(1) + ' MiB');
22
- this.file.appendBuffer(buffer);
23
- }
24
-
25
- public close() {
26
- this.setStatus('fetch', 'Done');
27
- this.file.flush();
28
- }
29
- }
@@ -1,31 +0,0 @@
1
- import {DataStream} from 'mp4box';
2
-
3
- export function description(file: any, track: any) {
4
- const trak = file.getTrackById(track.id);
5
- for (const entry of trak.mdia.minf.stbl.stsd.entries) {
6
- const box = entry.avcC || entry.hvcC || entry.vpcC || entry.av1C;
7
- if (box) {
8
- const stream = new DataStream(undefined, 0, DataStream.BIG_ENDIAN);
9
- box.write(stream);
10
- return new Uint8Array(stream.buffer, 8); // Remove the box header.
11
- }
12
- }
13
- throw new Error('avcC, hvcC, vpcC, or av1C box not found');
14
- }
15
-
16
- export interface Edit {
17
- mediaTime: number;
18
- segmentDuration: number;
19
- mediaRateInteger: number;
20
- mediaRateFraction: number;
21
- fps: number;
22
- }
23
-
24
- export function mp4BoxEditToEdit(edit: any): Omit<Edit, 'fps'> {
25
- return {
26
- mediaTime: edit.media_time,
27
- segmentDuration: edit.segment_duration,
28
- mediaRateInteger: edit.media_rate_integer,
29
- mediaRateFraction: edit.media_rate_fraction,
30
- };
31
- }