@omnimedia/omnitool 1.0.0 → 1.1.0-10
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.
- package/LICENSE +21 -0
- package/README.md +120 -2
- package/package.json +59 -27
- package/s/_archive/types.ts +107 -0
- package/s/context.ts +7 -0
- package/s/demo/demo.bundle.ts +68 -0
- package/s/demo/demo.css +59 -0
- package/s/demo/routines/filmstrip-test.ts +68 -0
- package/s/demo/routines/load-video.ts +7 -0
- package/s/demo/routines/transcode-test.ts +46 -0
- package/s/demo/routines/transcriber-test.ts +34 -0
- package/s/demo/routines/transitions-test.ts +43 -0
- package/s/demo/routines/waveform-test.ts +12 -0
- package/s/driver/driver.test.ts +15 -0
- package/s/driver/driver.ts +124 -0
- package/s/driver/driver.worker.bundle.ts +7 -0
- package/s/driver/fns/host.ts +13 -0
- package/s/driver/fns/schematic.ts +106 -0
- package/s/driver/fns/work.ts +249 -0
- package/s/driver/parts/constants.ts +17 -0
- package/s/driver/parts/machina.ts +27 -0
- package/s/driver/utils/load-decoder-source.ts +12 -0
- package/s/driver/utils/sleep.ts +3 -0
- package/s/features/speech/transcribe/default-spec.ts +11 -0
- package/s/features/speech/transcribe/parts/load-pipe.ts +19 -0
- package/s/features/speech/transcribe/parts/prep-audio.ts +23 -0
- package/s/features/speech/transcribe/parts/transcribe.ts +70 -0
- package/s/features/speech/transcribe/transcriber.ts +46 -0
- package/s/features/speech/transcribe/types.ts +82 -0
- package/s/features/speech/transcribe/worker.bundle.ts +40 -0
- package/s/features/transition/parts/fragment.ts +24 -0
- package/s/features/transition/parts/types.ts +94 -0
- package/s/features/transition/parts/uniforms.ts +29 -0
- package/s/features/transition/parts/vertex.ts +31 -0
- package/s/features/transition/transition.ts +60 -0
- package/s/index.html.ts +58 -0
- package/s/index.ts +2 -39
- package/s/tests.test.ts +8 -0
- package/s/timeline/index.ts +15 -0
- package/s/timeline/parts/basics.ts +17 -0
- package/s/timeline/parts/compositor/export.ts +77 -0
- package/s/timeline/parts/compositor/parts/html-tree.ts +37 -0
- package/s/timeline/parts/compositor/parts/schedulers.ts +85 -0
- package/s/timeline/parts/compositor/parts/tree-builder.ts +184 -0
- package/s/timeline/parts/compositor/parts/webcodecs-tree.ts +30 -0
- package/s/timeline/parts/compositor/playback.ts +81 -0
- package/s/timeline/parts/compositor/samplers/html.ts +115 -0
- package/s/timeline/parts/compositor/samplers/webcodecs.ts +60 -0
- package/s/timeline/parts/filmstrip.ts +159 -0
- package/s/timeline/parts/item.ts +90 -0
- package/s/timeline/parts/media.ts +35 -0
- package/s/timeline/parts/resource-pool.ts +27 -0
- package/s/timeline/parts/resource.ts +11 -0
- package/s/timeline/parts/waveform.ts +62 -0
- package/s/timeline/sugar/builders.ts +102 -0
- package/s/timeline/sugar/o.ts +150 -0
- package/s/timeline/sugar/omni-test.ts +38 -0
- package/s/timeline/sugar/omni.ts +40 -0
- package/s/timeline/types.ts +29 -0
- package/s/timeline/utils/audio-stream.ts +15 -0
- package/s/timeline/utils/checksum.ts +20 -0
- package/s/timeline/utils/datafile.ts +21 -0
- package/s/timeline/utils/dummy-data.ts +7 -0
- package/s/timeline/utils/matrix.ts +33 -0
- package/s/timeline/utils/video-cursor.ts +40 -0
- package/s/tools/common/loader.ts +26 -0
- package/s/tools/common/transformer-pipeline.ts +26 -0
- package/s/tools/speech-recognition/common/model.ts +26 -0
- package/s/tools/speech-recognition/whisper/fns/host.ts +25 -0
- package/s/tools/speech-recognition/whisper/fns/schematic.ts +23 -0
- package/s/tools/speech-recognition/whisper/fns/work.ts +91 -0
- package/s/tools/speech-recognition/whisper/parts/types.ts +38 -0
- package/s/tools/speech-recognition/whisper/parts/worker.bundle.ts +7 -0
- package/s/tools/speech-recognition/whisper/tool.ts +70 -0
- package/x/context.d.ts +4 -0
- package/x/context.js +6 -0
- package/x/context.js.map +1 -0
- package/x/demo/demo.bundle.d.ts +1 -0
- package/x/demo/demo.bundle.js +55 -0
- package/x/demo/demo.bundle.js.map +1 -0
- package/x/demo/demo.bundle.min.js +120 -0
- package/x/demo/demo.bundle.min.js.map +7 -0
- package/x/demo/demo.css +59 -0
- package/x/demo/routines/filmstrip-test.d.ts +1 -0
- package/x/demo/routines/filmstrip-test.js +62 -0
- package/x/demo/routines/filmstrip-test.js.map +1 -0
- package/x/demo/routines/load-video.d.ts +1 -0
- package/x/demo/routines/load-video.js +6 -0
- package/x/demo/routines/load-video.js.map +1 -0
- package/x/demo/routines/transcode-test.d.ts +6 -0
- package/x/demo/routines/transcode-test.js +40 -0
- package/x/demo/routines/transcode-test.js.map +1 -0
- package/x/demo/routines/transcriber-test.d.ts +4 -0
- package/x/demo/routines/transcriber-test.js +33 -0
- package/x/demo/routines/transcriber-test.js.map +1 -0
- package/x/demo/routines/transitions-test.d.ts +5 -0
- package/x/demo/routines/transitions-test.js +35 -0
- package/x/demo/routines/transitions-test.js.map +1 -0
- package/x/demo/routines/waveform-test.d.ts +1 -0
- package/x/demo/routines/waveform-test.js +11 -0
- package/x/demo/routines/waveform-test.js.map +1 -0
- package/x/driver/driver.d.ts +20 -0
- package/x/driver/driver.js +104 -0
- package/x/driver/driver.js.map +1 -0
- package/x/driver/driver.test.d.ts +5 -0
- package/x/driver/driver.test.js +12 -0
- package/x/driver/driver.test.js.map +1 -0
- package/x/driver/driver.worker.bundle.d.ts +1 -0
- package/x/driver/driver.worker.bundle.js +4 -0
- package/x/driver/driver.worker.bundle.js.map +1 -0
- package/x/driver/driver.worker.bundle.min.js +3537 -0
- package/x/driver/driver.worker.bundle.min.js.map +7 -0
- package/x/driver/fns/host.d.ts +25 -0
- package/x/driver/fns/host.js +7 -0
- package/x/driver/fns/host.js.map +1 -0
- package/x/driver/fns/schematic.d.ts +84 -0
- package/x/driver/fns/schematic.js +2 -0
- package/x/driver/fns/schematic.js.map +1 -0
- package/x/driver/fns/work.d.ts +26 -0
- package/x/driver/fns/work.js +201 -0
- package/x/driver/fns/work.js.map +1 -0
- package/x/driver/parts/constants.d.ts +2 -0
- package/x/driver/parts/constants.js +17 -0
- package/x/driver/parts/constants.js.map +1 -0
- package/x/driver/parts/machina.d.ts +23 -0
- package/x/driver/parts/machina.js +14 -0
- package/x/driver/parts/machina.js.map +1 -0
- package/x/driver/utils/load-decoder-source.d.ts +3 -0
- package/x/driver/utils/load-decoder-source.js +11 -0
- package/x/driver/utils/load-decoder-source.js.map +1 -0
- package/x/driver/utils/sleep.d.ts +1 -0
- package/x/driver/utils/sleep.js +4 -0
- package/x/driver/utils/sleep.js.map +1 -0
- package/x/features/speech/transcribe/default-spec.d.ts +2 -0
- package/x/features/speech/transcribe/default-spec.js +8 -0
- package/x/features/speech/transcribe/default-spec.js.map +1 -0
- package/x/features/speech/transcribe/parts/load-pipe.d.ts +2 -0
- package/x/features/speech/transcribe/parts/load-pipe.js +13 -0
- package/x/features/speech/transcribe/parts/load-pipe.js.map +1 -0
- package/x/features/speech/transcribe/parts/prep-audio.d.ts +5 -0
- package/x/features/speech/transcribe/parts/prep-audio.js +21 -0
- package/x/features/speech/transcribe/parts/prep-audio.js.map +1 -0
- package/x/features/speech/transcribe/parts/transcribe.d.ts +5 -0
- package/x/features/speech/transcribe/parts/transcribe.js +56 -0
- package/x/features/speech/transcribe/parts/transcribe.js.map +1 -0
- package/x/features/speech/transcribe/transcriber.d.ts +5 -0
- package/x/features/speech/transcribe/transcriber.js +33 -0
- package/x/features/speech/transcribe/transcriber.js.map +1 -0
- package/x/features/speech/transcribe/types.d.ts +66 -0
- package/x/features/speech/transcribe/types.js.map +1 -0
- package/x/features/speech/transcribe/worker.bundle.d.ts +1 -0
- package/x/features/speech/transcribe/worker.bundle.js +33 -0
- package/x/features/speech/transcribe/worker.bundle.js.map +1 -0
- package/x/features/speech/transcribe/worker.bundle.min.js +2916 -0
- package/x/features/speech/transcribe/worker.bundle.min.js.map +7 -0
- package/x/features/transition/parts/fragment.d.ts +1 -0
- package/x/features/transition/parts/fragment.js +25 -0
- package/x/features/transition/parts/fragment.js.map +1 -0
- package/x/features/transition/parts/types.d.ts +23 -0
- package/x/features/transition/parts/types.js +2 -0
- package/x/features/transition/parts/types.js.map +1 -0
- package/x/features/transition/parts/uniforms.d.ts +31 -0
- package/x/features/transition/parts/uniforms.js +27 -0
- package/x/features/transition/parts/uniforms.js.map +1 -0
- package/x/features/transition/parts/vertex.d.ts +1 -0
- package/x/features/transition/parts/vertex.js +32 -0
- package/x/features/transition/parts/vertex.js.map +1 -0
- package/x/features/transition/transition.d.ts +5 -0
- package/x/features/transition/transition.js +50 -0
- package/x/features/transition/transition.js.map +1 -0
- package/x/index.d.ts +2 -9
- package/x/index.html +115 -0
- package/x/index.html.d.ts +2 -0
- package/x/index.html.js +52 -0
- package/x/index.html.js.map +1 -0
- package/x/index.js +2 -29
- package/x/index.js.map +1 -1
- package/x/tests.test.d.ts +1 -0
- package/x/tests.test.js +6 -0
- package/x/tests.test.js.map +1 -0
- package/x/timeline/index.d.ts +11 -0
- package/x/timeline/index.js +12 -0
- package/x/timeline/index.js.map +1 -0
- package/x/timeline/parts/basics.d.ts +12 -0
- package/x/timeline/parts/basics.js +2 -0
- package/x/timeline/parts/basics.js.map +1 -0
- package/x/timeline/parts/compositor/export.d.ts +9 -0
- package/x/timeline/parts/compositor/export.js +64 -0
- package/x/timeline/parts/compositor/export.js.map +1 -0
- package/x/timeline/parts/compositor/parts/html-tree.d.ts +3 -0
- package/x/timeline/parts/compositor/parts/html-tree.js +40 -0
- package/x/timeline/parts/compositor/parts/html-tree.js.map +1 -0
- package/x/timeline/parts/compositor/parts/schedulers.d.ts +15 -0
- package/x/timeline/parts/compositor/parts/schedulers.js +64 -0
- package/x/timeline/parts/compositor/parts/schedulers.js.map +1 -0
- package/x/timeline/parts/compositor/parts/tree-builder.d.ts +37 -0
- package/x/timeline/parts/compositor/parts/tree-builder.js +147 -0
- package/x/timeline/parts/compositor/parts/tree-builder.js.map +1 -0
- package/x/timeline/parts/compositor/parts/webcodecs-tree.d.ts +3 -0
- package/x/timeline/parts/compositor/parts/webcodecs-tree.js +28 -0
- package/x/timeline/parts/compositor/parts/webcodecs-tree.js.map +1 -0
- package/x/timeline/parts/compositor/playback.d.ts +19 -0
- package/x/timeline/parts/compositor/playback.js +71 -0
- package/x/timeline/parts/compositor/playback.js.map +1 -0
- package/x/timeline/parts/compositor/samplers/html.d.ts +3 -0
- package/x/timeline/parts/compositor/samplers/html.js +106 -0
- package/x/timeline/parts/compositor/samplers/html.js.map +1 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.d.ts +2 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.js +55 -0
- package/x/timeline/parts/compositor/samplers/webcodecs.js.map +1 -0
- package/x/timeline/parts/filmstrip.d.ts +39 -0
- package/x/timeline/parts/filmstrip.js +117 -0
- package/x/timeline/parts/filmstrip.js.map +1 -0
- package/x/timeline/parts/item.d.ts +68 -0
- package/x/timeline/parts/item.js +16 -0
- package/x/timeline/parts/item.js.map +1 -0
- package/x/timeline/parts/media.d.ts +10 -0
- package/x/timeline/parts/media.js +30 -0
- package/x/timeline/parts/media.js.map +1 -0
- package/x/timeline/parts/resource-pool.d.ts +7 -0
- package/x/timeline/parts/resource-pool.js +19 -0
- package/x/timeline/parts/resource-pool.js.map +1 -0
- package/x/timeline/parts/resource.d.ts +8 -0
- package/x/timeline/parts/resource.js +2 -0
- package/x/timeline/parts/resource.js.map +1 -0
- package/x/timeline/parts/waveform.d.ts +8 -0
- package/x/timeline/parts/waveform.js +51 -0
- package/x/timeline/parts/waveform.js.map +1 -0
- package/x/timeline/sugar/builders.d.ts +1 -0
- package/x/timeline/sugar/builders.js +104 -0
- package/x/timeline/sugar/builders.js.map +1 -0
- package/x/timeline/sugar/o.d.ts +32 -0
- package/x/timeline/sugar/o.js +114 -0
- package/x/timeline/sugar/o.js.map +1 -0
- package/x/timeline/sugar/omni-test.d.ts +1 -0
- package/x/timeline/sugar/omni-test.js +22 -0
- package/x/timeline/sugar/omni-test.js.map +1 -0
- package/x/timeline/sugar/omni.d.ts +14 -0
- package/x/timeline/sugar/omni.js +28 -0
- package/x/timeline/sugar/omni.js.map +1 -0
- package/x/timeline/types.d.ts +24 -0
- package/x/timeline/types.js +2 -0
- package/x/timeline/types.js.map +1 -0
- package/x/timeline/utils/audio-stream.d.ts +6 -0
- package/x/timeline/utils/audio-stream.js +17 -0
- package/x/timeline/utils/audio-stream.js.map +1 -0
- package/x/timeline/utils/checksum.d.ts +8 -0
- package/x/timeline/utils/checksum.js +21 -0
- package/x/timeline/utils/checksum.js.map +1 -0
- package/x/timeline/utils/datafile.d.ts +9 -0
- package/x/timeline/utils/datafile.js +20 -0
- package/x/timeline/utils/datafile.js.map +1 -0
- package/x/timeline/utils/dummy-data.d.ts +2 -0
- package/x/timeline/utils/dummy-data.js +3 -0
- package/x/timeline/utils/dummy-data.js.map +1 -0
- package/x/timeline/utils/matrix.d.ts +8 -0
- package/x/timeline/utils/matrix.js +26 -0
- package/x/timeline/utils/matrix.js.map +1 -0
- package/x/timeline/utils/video-cursor.d.ts +10 -0
- package/x/timeline/utils/video-cursor.js +36 -0
- package/x/timeline/utils/video-cursor.js.map +1 -0
- package/x/tools/common/loader.d.ts +19 -0
- package/x/tools/common/loader.js +18 -0
- package/x/tools/common/loader.js.map +1 -0
- package/x/tools/common/transformer-pipeline.d.ts +8 -0
- package/x/tools/common/transformer-pipeline.js +24 -0
- package/x/tools/common/transformer-pipeline.js.map +1 -0
- package/x/tools/speech-recognition/common/model.d.ts +14 -0
- package/x/tools/speech-recognition/common/model.js +16 -0
- package/x/tools/speech-recognition/common/model.js.map +1 -0
- package/x/tools/speech-recognition/whisper/fns/host.d.ts +13 -0
- package/x/tools/speech-recognition/whisper/fns/host.js +19 -0
- package/x/tools/speech-recognition/whisper/fns/host.js.map +1 -0
- package/x/tools/speech-recognition/whisper/fns/schematic.d.ts +19 -0
- package/x/tools/speech-recognition/whisper/fns/schematic.js +2 -0
- package/x/tools/speech-recognition/whisper/fns/schematic.js.map +1 -0
- package/x/tools/speech-recognition/whisper/fns/work.d.ts +12 -0
- package/x/tools/speech-recognition/whisper/fns/work.js +74 -0
- package/x/tools/speech-recognition/whisper/fns/work.js.map +1 -0
- package/x/tools/speech-recognition/whisper/parts/types.d.ts +31 -0
- package/x/tools/speech-recognition/whisper/parts/types.js +2 -0
- package/x/tools/speech-recognition/whisper/parts/types.js.map +1 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.d.ts +1 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js +4 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.js.map +1 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js +8 -0
- package/x/tools/speech-recognition/whisper/parts/worker.bundle.min.js.map +7 -0
- package/x/tools/speech-recognition/whisper/tool.d.ts +12 -0
- package/x/tools/speech-recognition/whisper/tool.js +63 -0
- package/x/tools/speech-recognition/whisper/tool.js.map +1 -0
- package/s/parts/compositor.ts +0 -5
- package/s/parts/export.ts +0 -5
- package/s/parts/video-decoder.ts +0 -27
- package/s/parts/video-encoder.ts +0 -15
- package/s/tools/generate-id.ts +0 -7
- package/s/tools/mp4boxjs/LICENSE.md +0 -24
- package/s/tools/mp4boxjs/demuxer.ts +0 -106
- package/s/tools/mp4boxjs/mp4box.adapter.ts +0 -148
- package/s/tools/mp4boxjs/mp4box.js +0 -8206
- package/s/types.ts +0 -10
- package/x/parts/compositor.d.ts +0 -4
- package/x/parts/compositor.js +0 -5
- package/x/parts/compositor.js.map +0 -1
- package/x/parts/export.d.ts +0 -7
- package/x/parts/export.js +0 -5
- package/x/parts/export.js.map +0 -1
- package/x/parts/video-decoder.d.ts +0 -8
- package/x/parts/video-decoder.js +0 -20
- package/x/parts/video-decoder.js.map +0 -1
- package/x/parts/video-encoder.d.ts +0 -6
- package/x/parts/video-encoder.js +0 -12
- package/x/parts/video-encoder.js.map +0 -1
- package/x/tools/generate-id.d.ts +0 -1
- package/x/tools/generate-id.js +0 -8
- package/x/tools/generate-id.js.map +0 -1
- package/x/tools/mp4boxjs/demuxer.d.ts +0 -24
- package/x/tools/mp4boxjs/demuxer.js +0 -88
- package/x/tools/mp4boxjs/demuxer.js.map +0 -1
- package/x/tools/mp4boxjs/mp4box.adapter.d.ts +0 -128
- package/x/tools/mp4boxjs/mp4box.adapter.js +0 -11
- package/x/tools/mp4boxjs/mp4box.adapter.js.map +0 -1
- package/x/types.d.ts +0 -7
- package/x/types.js.map +0 -1
- /package/x/{types.js → features/speech/transcribe/types.js} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CanvasSinkOptions, WrappedCanvas } from "mediabunny";
|
|
2
|
+
import { DecoderSource } from '../../driver/fns/schematic.js';
|
|
3
|
+
export declare class Filmstrip {
|
|
4
|
+
#private;
|
|
5
|
+
private videoTrack;
|
|
6
|
+
private options;
|
|
7
|
+
private constructor();
|
|
8
|
+
static init(source: DecoderSource, options: FilmstripOptions): Promise<Filmstrip>;
|
|
9
|
+
/**
|
|
10
|
+
* Sets the frequency (granularity) of filmstrip thumbnails.
|
|
11
|
+
* Changing this triggers a filmstrip refresh after any ongoing update finishes.
|
|
12
|
+
* @param value - The new frequency in seconds.
|
|
13
|
+
*/
|
|
14
|
+
set frequency(value: number);
|
|
15
|
+
get frequency(): number;
|
|
16
|
+
/**
|
|
17
|
+
* Updates the visible time range for the filmstrip.
|
|
18
|
+
*
|
|
19
|
+
* Triggers a thumbnails update, with extended margins to preload
|
|
20
|
+
* thumbnails slightly outside the visible range.
|
|
21
|
+
* @param visibleRange - The current timeline viewport as a [start, end] tuple in seconds.
|
|
22
|
+
*/
|
|
23
|
+
set range(visibleRange: TimeRange);
|
|
24
|
+
/**
|
|
25
|
+
* Returns the cached thumbnail (if any) for a given timestamp.
|
|
26
|
+
* @param time - The timestamp to retrieve the canvas for.
|
|
27
|
+
*/
|
|
28
|
+
getThumbnail(time: number): any;
|
|
29
|
+
}
|
|
30
|
+
type TimeRange = [number, number];
|
|
31
|
+
interface FilmstripOptions {
|
|
32
|
+
frequency?: number;
|
|
33
|
+
canvasSinkOptions?: CanvasSinkOptions;
|
|
34
|
+
onChange: (tiles: {
|
|
35
|
+
time: number;
|
|
36
|
+
canvas: WrappedCanvas;
|
|
37
|
+
}[]) => void;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ALL_FORMATS, CanvasSink, Input, } from "mediabunny";
|
|
2
|
+
import { loadDecoderSource } from '../../driver/utils/load-decoder-source.js';
|
|
3
|
+
export class Filmstrip {
|
|
4
|
+
videoTrack;
|
|
5
|
+
options;
|
|
6
|
+
#sink;
|
|
7
|
+
#cache = new Map();
|
|
8
|
+
#activeRange = [0, 0];
|
|
9
|
+
constructor(videoTrack, options) {
|
|
10
|
+
this.videoTrack = videoTrack;
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.#sink = new CanvasSink(videoTrack, options.canvasSinkOptions);
|
|
13
|
+
}
|
|
14
|
+
static async init(source, options) {
|
|
15
|
+
const input = new Input({
|
|
16
|
+
formats: ALL_FORMATS,
|
|
17
|
+
source: await loadDecoderSource(source)
|
|
18
|
+
});
|
|
19
|
+
const videoTrack = await input.getPrimaryVideoTrack();
|
|
20
|
+
if (videoTrack)
|
|
21
|
+
return new Filmstrip(videoTrack, {
|
|
22
|
+
frequency: options.frequency ?? 1,
|
|
23
|
+
canvasSinkOptions: options.canvasSinkOptions ?? { width: 80, height: 50, fit: "fill" },
|
|
24
|
+
onChange: options.onChange
|
|
25
|
+
});
|
|
26
|
+
else
|
|
27
|
+
throw new Error("Source has no video track");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Sets the frequency (granularity) of filmstrip thumbnails.
|
|
31
|
+
* Changing this triggers a filmstrip refresh after any ongoing update finishes.
|
|
32
|
+
* @param value - The new frequency in seconds.
|
|
33
|
+
*/
|
|
34
|
+
set frequency(value) {
|
|
35
|
+
if (value !== this.options.frequency) {
|
|
36
|
+
this.options.frequency = value;
|
|
37
|
+
this.#update();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
get frequency() {
|
|
41
|
+
return this.options.frequency;
|
|
42
|
+
}
|
|
43
|
+
#computeActiveRange([start, end]) {
|
|
44
|
+
const tileSize = end - start;
|
|
45
|
+
return [start - tileSize, end + tileSize];
|
|
46
|
+
}
|
|
47
|
+
async #generateTiles() {
|
|
48
|
+
const [rangeStart, rangeEnd] = this.#activeRange;
|
|
49
|
+
const neededTimestamps = new Set();
|
|
50
|
+
// duration should be computed but with trim etc also
|
|
51
|
+
const duration = await this.videoTrack.computeDuration();
|
|
52
|
+
for (let timestamp = rangeStart; timestamp <= rangeEnd; timestamp += this.options.frequency) {
|
|
53
|
+
// Clamp to valid time range
|
|
54
|
+
if (timestamp >= 0 && timestamp <= duration)
|
|
55
|
+
neededTimestamps.add(+timestamp.toFixed(3));
|
|
56
|
+
}
|
|
57
|
+
const missingTimestamps = [...neededTimestamps]
|
|
58
|
+
.filter(t => !this.#cache.has(t));
|
|
59
|
+
let i = 0;
|
|
60
|
+
for await (const canvas of this.#sink.canvasesAtTimestamps(missingTimestamps)) {
|
|
61
|
+
if (canvas) {
|
|
62
|
+
const requestedTime = missingTimestamps[i++];
|
|
63
|
+
this.#cache.set(requestedTime, canvas);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Dispose canvases outside the new range
|
|
67
|
+
for (const key of this.#cache.keys()) {
|
|
68
|
+
if (!neededTimestamps.has(key)) {
|
|
69
|
+
this.#cache.delete(key);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const tiles = [...this.#cache.entries()]
|
|
73
|
+
.map(([time, canvas]) => ({ time, canvas }));
|
|
74
|
+
this.options.onChange(tiles);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Updates the visible time range for the filmstrip.
|
|
78
|
+
*
|
|
79
|
+
* Triggers a thumbnails update, with extended margins to preload
|
|
80
|
+
* thumbnails slightly outside the visible range.
|
|
81
|
+
* @param visibleRange - The current timeline viewport as a [start, end] tuple in seconds.
|
|
82
|
+
*/
|
|
83
|
+
set range(visibleRange) {
|
|
84
|
+
const newRange = this.#computeActiveRange(visibleRange);
|
|
85
|
+
// Avoid redundant updates
|
|
86
|
+
if (this.#activeRange[0] === newRange[0] &&
|
|
87
|
+
this.#activeRange[1] === newRange[1])
|
|
88
|
+
return;
|
|
89
|
+
this.#activeRange = newRange;
|
|
90
|
+
this.#update();
|
|
91
|
+
}
|
|
92
|
+
#updating = null;
|
|
93
|
+
#shouldRunAgain = false;
|
|
94
|
+
async #update() {
|
|
95
|
+
// Perform update immediately. If multiple updates are requested while updating,
|
|
96
|
+
// only the latest one will run after the current finishes (skips intermediate ones).
|
|
97
|
+
if (this.#updating) {
|
|
98
|
+
this.#shouldRunAgain = true;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.#updating = this.#generateTiles();
|
|
102
|
+
await this.#updating;
|
|
103
|
+
this.#updating = null;
|
|
104
|
+
if (this.#shouldRunAgain) {
|
|
105
|
+
this.#shouldRunAgain = false;
|
|
106
|
+
await this.#update();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the cached thumbnail (if any) for a given timestamp.
|
|
111
|
+
* @param time - The timestamp to retrieve the canvas for.
|
|
112
|
+
*/
|
|
113
|
+
getThumbnail(time) {
|
|
114
|
+
return this.#cache.get(time);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=filmstrip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filmstrip.js","sourceRoot":"","sources":["../../../s/timeline/parts/filmstrip.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EACX,UAAU,EAEV,KAAK,GAGL,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAC,iBAAiB,EAAC,MAAM,2CAA2C,CAAA;AAE3E,MAAM,OAAO,SAAS;IAMZ;IACA;IANT,KAAK,CAAY;IACjB,MAAM,GAA+B,IAAI,GAA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,eAAe,EAAE,CAAC;YACzB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAA;YAC5B,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;QACrB,CAAC;IACF,CAAC;IACD;;;MAGG;IACH,YAAY,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;CACD"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Id, Hash } from "./basics.js";
|
|
2
|
+
import { Transform } from "../types.js";
|
|
3
|
+
export declare enum Kind {
|
|
4
|
+
Sequence = 0,
|
|
5
|
+
Stack = 1,
|
|
6
|
+
Video = 2,
|
|
7
|
+
Audio = 3,
|
|
8
|
+
Text = 4,
|
|
9
|
+
Gap = 5,
|
|
10
|
+
Spatial = 6,
|
|
11
|
+
Transition = 7
|
|
12
|
+
}
|
|
13
|
+
export declare enum Effect {
|
|
14
|
+
Crossfade = 0
|
|
15
|
+
}
|
|
16
|
+
export declare namespace Item {
|
|
17
|
+
type Spatial = {
|
|
18
|
+
id: Id;
|
|
19
|
+
kind: Kind.Spatial;
|
|
20
|
+
transform: Transform;
|
|
21
|
+
};
|
|
22
|
+
type Gap = {
|
|
23
|
+
id: Id;
|
|
24
|
+
kind: Kind.Gap;
|
|
25
|
+
duration: number;
|
|
26
|
+
};
|
|
27
|
+
type Sequence = {
|
|
28
|
+
id: Id;
|
|
29
|
+
kind: Kind.Sequence;
|
|
30
|
+
childrenIds: Id[];
|
|
31
|
+
spatialId?: Id;
|
|
32
|
+
};
|
|
33
|
+
type Stack = {
|
|
34
|
+
id: Id;
|
|
35
|
+
kind: Kind.Stack;
|
|
36
|
+
childrenIds: Id[];
|
|
37
|
+
spatialId?: Id;
|
|
38
|
+
};
|
|
39
|
+
type Video = {
|
|
40
|
+
id: Id;
|
|
41
|
+
kind: Kind.Video;
|
|
42
|
+
mediaHash: Hash;
|
|
43
|
+
start: number;
|
|
44
|
+
duration: number;
|
|
45
|
+
spatialId?: Id;
|
|
46
|
+
};
|
|
47
|
+
type Audio = {
|
|
48
|
+
id: Id;
|
|
49
|
+
kind: Kind.Audio;
|
|
50
|
+
mediaHash: Hash;
|
|
51
|
+
start: number;
|
|
52
|
+
duration: number;
|
|
53
|
+
};
|
|
54
|
+
type Text = {
|
|
55
|
+
id: Id;
|
|
56
|
+
kind: Kind.Text;
|
|
57
|
+
content: string;
|
|
58
|
+
spatialId?: Id;
|
|
59
|
+
color: string;
|
|
60
|
+
};
|
|
61
|
+
type Transition = {
|
|
62
|
+
id: Id;
|
|
63
|
+
kind: Kind.Transition;
|
|
64
|
+
effect: Effect.Crossfade;
|
|
65
|
+
duration: number;
|
|
66
|
+
};
|
|
67
|
+
type Any = (Sequence | Stack | Video | Audio | Text | Gap | Transition | Spatial);
|
|
68
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var Kind;
|
|
2
|
+
(function (Kind) {
|
|
3
|
+
Kind[Kind["Sequence"] = 0] = "Sequence";
|
|
4
|
+
Kind[Kind["Stack"] = 1] = "Stack";
|
|
5
|
+
Kind[Kind["Video"] = 2] = "Video";
|
|
6
|
+
Kind[Kind["Audio"] = 3] = "Audio";
|
|
7
|
+
Kind[Kind["Text"] = 4] = "Text";
|
|
8
|
+
Kind[Kind["Gap"] = 5] = "Gap";
|
|
9
|
+
Kind[Kind["Spatial"] = 6] = "Spatial";
|
|
10
|
+
Kind[Kind["Transition"] = 7] = "Transition";
|
|
11
|
+
})(Kind || (Kind = {}));
|
|
12
|
+
export var Effect;
|
|
13
|
+
(function (Effect) {
|
|
14
|
+
Effect[Effect["Crossfade"] = 0] = "Crossfade";
|
|
15
|
+
})(Effect || (Effect = {}));
|
|
16
|
+
//# sourceMappingURL=item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../../s/timeline/parts/item.ts"],"names":[],"mappings":"AAIA,MAAM,CAAN,IAAY,IASX;AATD,WAAY,IAAI;IACf,uCAAQ,CAAA;IACR,iCAAK,CAAA;IACL,iCAAK,CAAA;IACL,iCAAK,CAAA;IACL,+BAAI,CAAA;IACJ,6BAAG,CAAA;IACH,qCAAO,CAAA;IACP,2CAAU,CAAA;AACX,CAAC,EATW,IAAI,KAAJ,IAAI,QASf;AAED,MAAM,CAAN,IAAY,MAEX;AAFD,WAAY,MAAM;IACjB,6CAAS,CAAA;AACV,CAAC,EAFW,MAAM,KAAN,MAAM,QAEjB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Datafile } from "../utils/datafile.js";
|
|
2
|
+
export declare class Media {
|
|
3
|
+
#private;
|
|
4
|
+
datafile: Datafile;
|
|
5
|
+
duration: number;
|
|
6
|
+
hasVideo: boolean;
|
|
7
|
+
hasAudio: boolean;
|
|
8
|
+
constructor(datafile: Datafile);
|
|
9
|
+
static analyze(datafile: Datafile): Promise<Media>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ALL_FORMATS, Input } from "mediabunny";
|
|
2
|
+
import { loadDecoderSource } from "../../driver/utils/load-decoder-source.js";
|
|
3
|
+
export class Media {
|
|
4
|
+
datafile;
|
|
5
|
+
duration = 0;
|
|
6
|
+
hasVideo = false;
|
|
7
|
+
hasAudio = false;
|
|
8
|
+
constructor(datafile) {
|
|
9
|
+
this.datafile = datafile;
|
|
10
|
+
}
|
|
11
|
+
static async analyze(datafile) {
|
|
12
|
+
const media = new this(datafile);
|
|
13
|
+
media.duration = 10;
|
|
14
|
+
const { video, audio } = await this.#has("/assets/temp/gl.mp4");
|
|
15
|
+
media.hasAudio = audio;
|
|
16
|
+
media.hasVideo = video;
|
|
17
|
+
return media;
|
|
18
|
+
}
|
|
19
|
+
static async #has(source) {
|
|
20
|
+
const input = new Input({
|
|
21
|
+
formats: ALL_FORMATS,
|
|
22
|
+
source: await loadDecoderSource(source)
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
audio: !!(await input.getPrimaryAudioTrack()),
|
|
26
|
+
video: !!(await input.getPrimaryVideoTrack())
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../../s/timeline/parts/media.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAE,KAAK,EAAC,MAAM,YAAY,CAAA;AAI7C,OAAO,EAAC,iBAAiB,EAAC,MAAM,2CAA2C,CAAA;AAE3E,MAAM,OAAO,KAAK;IAKE;IAJnB,QAAQ,GAAG,CAAC,CAAA;IACZ,QAAQ,GAAG,KAAK,CAAA;IAChB,QAAQ,GAAG,KAAK,CAAA;IAEhB,YAAmB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAEzC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAkB;QACtC,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAA;QAChC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAA;QACnB,MAAM,EAAC,KAAK,EAAE,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;QAC7D,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAA;QACtB,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAA;QACtB,OAAO,KAAK,CAAA;IACb,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAqB;QACtC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;YACvB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,MAAM,iBAAiB,CAAC,MAAM,CAAC;SACvC,CAAC,CAAA;QACF,OAAO;YACN,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC;YAC7C,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC;SAC7C,CAAA;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MapG } from "@e280/stz";
|
|
2
|
+
import { Media } from "./media.js";
|
|
3
|
+
export class ResourcePool {
|
|
4
|
+
#map = new MapG;
|
|
5
|
+
/** store a media file (avoids duplicates via hash) */
|
|
6
|
+
async store(datafile) {
|
|
7
|
+
const media = await Media.analyze(datafile);
|
|
8
|
+
const { hash } = media.datafile.checksum;
|
|
9
|
+
const { filename, bytes } = media.datafile;
|
|
10
|
+
if (this.#map.has(hash)) {
|
|
11
|
+
const alreadyExists = this.#map.require(hash);
|
|
12
|
+
alreadyExists.filename = filename;
|
|
13
|
+
}
|
|
14
|
+
else
|
|
15
|
+
this.#map.set(hash, { kind: "media", filename, bytes });
|
|
16
|
+
return media;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=resource-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-pool.js","sourceRoot":"","sources":["../../../s/timeline/parts/resource-pool.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAE9B,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAIhC,MAAM,OAAO,YAAY;IACxB,IAAI,GAAG,IAAI,IAAwB,CAAA;IAEnC,sDAAsD;IACtD,KAAK,CAAC,KAAK,CAAC,QAAkB;QAC7B,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAC3C,MAAM,EAAC,IAAI,EAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAA;QACtC,MAAM,EAAC,QAAQ,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC,QAAQ,CAAA;QAExC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC7C,aAAa,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAClC,CAAC;;YAEA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAA;QAEtD,OAAO,KAAK,CAAA;IACb,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../s/timeline/parts/resource.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import WaveSurfer from "wavesurfer.js";
|
|
2
|
+
import { DecoderSource } from "../../driver/fns/schematic.js";
|
|
3
|
+
export declare class Waveform {
|
|
4
|
+
wavesurfer: WaveSurfer;
|
|
5
|
+
constructor(peaks: number[], container: HTMLElement, duration: number);
|
|
6
|
+
static init(source: DecoderSource, container: HTMLElement): Promise<Waveform>;
|
|
7
|
+
set width(value: number);
|
|
8
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import WaveSurfer from "wavesurfer.js";
|
|
2
|
+
import { context } from "../../context.js";
|
|
3
|
+
export class Waveform {
|
|
4
|
+
wavesurfer;
|
|
5
|
+
constructor(peaks, container, duration) {
|
|
6
|
+
this.wavesurfer = WaveSurfer.create({
|
|
7
|
+
container,
|
|
8
|
+
waveColor: 'rgb(200, 0, 200)',
|
|
9
|
+
progressColor: 'rgb(100, 0, 100)',
|
|
10
|
+
barWidth: 10,
|
|
11
|
+
barRadius: 10,
|
|
12
|
+
barGap: 2,
|
|
13
|
+
peaks: [peaks],
|
|
14
|
+
duration
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
static async init(source, container) {
|
|
18
|
+
const driver = await context.driver;
|
|
19
|
+
const reader = driver.decodeAudio({ source }).getReader();
|
|
20
|
+
const peaks = [];
|
|
21
|
+
let buffer = [];
|
|
22
|
+
const samplesPerPeak = 1024;
|
|
23
|
+
const duration = await driver.getAudioDuration(source);
|
|
24
|
+
while (true) {
|
|
25
|
+
const { done, value: audioData } = await reader.read();
|
|
26
|
+
if (done)
|
|
27
|
+
break;
|
|
28
|
+
const frames = audioData.numberOfFrames;
|
|
29
|
+
const plane = new Float32Array(frames);
|
|
30
|
+
audioData.copyTo(plane, { planeIndex: 0 }); // Use left channel only
|
|
31
|
+
for (let i = 0; i < plane.length; i++) {
|
|
32
|
+
buffer.push(plane[i]);
|
|
33
|
+
if (buffer.length >= samplesPerPeak) {
|
|
34
|
+
const chunk = buffer.splice(0, samplesPerPeak);
|
|
35
|
+
const min = Math.min(...chunk);
|
|
36
|
+
const max = Math.max(...chunk);
|
|
37
|
+
peaks.push(min, max);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
audioData.close();
|
|
41
|
+
}
|
|
42
|
+
return new Waveform(peaks, container, duration ?? 0);
|
|
43
|
+
}
|
|
44
|
+
// set zoom(value: number) {
|
|
45
|
+
// this.wavesurfer.zoom(value)
|
|
46
|
+
// }
|
|
47
|
+
set width(value) {
|
|
48
|
+
this.wavesurfer.setOptions({ width: value });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=waveform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waveform.js","sourceRoot":"","sources":["../../../s/timeline/parts/waveform.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAA;AAEtC,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAA;AAGxC,MAAM,OAAO,QAAQ;IACpB,UAAU,CAAY;IAEtB,YAAY,KAAe,EAAE,SAAsB,EAAE,QAAgB;QACpE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;YAClC,SAAS;YACT,SAAS,EAAE,kBAAkB;YAC7B,aAAa,EAAE,kBAAkB;YACjC,QAA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G,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;oBAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;oBAC9B,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;gBACrB,CAAC;YACF,CAAC;YAED,SAAS,CAAC,KAAK,EAAE,CAAA;QAClB,CAAC;QAED,OAAO,IAAI,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAA;IACrD,CAAC;IAED,4BAA4B;IAC5B,+BAA+B;IAC/B,IAAI;IAEJ,IAAI,KAAK,CAAC,KAAa;QACtB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC,CAAA;IAC3C,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
// import {O} from "./o.js"
|
|
3
|
+
// import {Id} from "../parts/basics.js"
|
|
4
|
+
// import {Item} from "../parts/item.js"
|
|
5
|
+
//
|
|
6
|
+
// export class TimelineItem {
|
|
7
|
+
// public readonly id: Id
|
|
8
|
+
//
|
|
9
|
+
// constructor(public item: Item.Any) {
|
|
10
|
+
// this.id = item.id
|
|
11
|
+
// }
|
|
12
|
+
//
|
|
13
|
+
// toJSON() {
|
|
14
|
+
// return {
|
|
15
|
+
// ...this.item
|
|
16
|
+
// }
|
|
17
|
+
// }
|
|
18
|
+
// }
|
|
19
|
+
//
|
|
20
|
+
// abstract class VisualItem extends TimelineItem {
|
|
21
|
+
// abstract spatial(spatial: Spatial): TimelineItem
|
|
22
|
+
// }
|
|
23
|
+
//
|
|
24
|
+
// export class Stack extends VisualItem {
|
|
25
|
+
// constructor(private o: O, public item: Item.Stack) {
|
|
26
|
+
// super(item)
|
|
27
|
+
// }
|
|
28
|
+
//
|
|
29
|
+
// spatial(spatial: Spatial) {
|
|
30
|
+
// this.item.spatialId = spatial.item.id
|
|
31
|
+
// return this
|
|
32
|
+
// }
|
|
33
|
+
//
|
|
34
|
+
// addChildren(fn: (o: O) => TimelineItem | TimelineItem[]) {
|
|
35
|
+
// const result = fn(this.o)
|
|
36
|
+
// const items = Array.isArray(result) ? result : [result]
|
|
37
|
+
// this.item.childrenIds.push(...items.map(c => c.item.id))
|
|
38
|
+
// return this
|
|
39
|
+
// }
|
|
40
|
+
// }
|
|
41
|
+
//
|
|
42
|
+
// export class Spatial extends TimelineItem {
|
|
43
|
+
// constructor(public item: Item.Spatial) {super(item)}
|
|
44
|
+
// }
|
|
45
|
+
//
|
|
46
|
+
// export class Gap extends TimelineItem {
|
|
47
|
+
// constructor(public item: Item.Gap) {super(item)}
|
|
48
|
+
// }
|
|
49
|
+
//
|
|
50
|
+
// export class Audio extends TimelineItem {
|
|
51
|
+
// constructor(public item: Item.Audio) {super(item)}
|
|
52
|
+
// }
|
|
53
|
+
//
|
|
54
|
+
// export class Video extends VisualItem {
|
|
55
|
+
// constructor(public item: Item.Video) {
|
|
56
|
+
// super(item)
|
|
57
|
+
// }
|
|
58
|
+
//
|
|
59
|
+
// spatial(spatial: Spatial) {
|
|
60
|
+
// this.item.spatialId = spatial.item.id
|
|
61
|
+
// return this
|
|
62
|
+
// }
|
|
63
|
+
// }
|
|
64
|
+
//
|
|
65
|
+
// export class Text extends VisualItem {
|
|
66
|
+
// constructor(public item: Item.Text) {
|
|
67
|
+
// super(item)
|
|
68
|
+
// }
|
|
69
|
+
//
|
|
70
|
+
// color(color: string) {
|
|
71
|
+
// this.item.color = color
|
|
72
|
+
// return this
|
|
73
|
+
// }
|
|
74
|
+
//
|
|
75
|
+
// spatial(spatial: Spatial) {
|
|
76
|
+
// this.item.spatialId = spatial.item.id
|
|
77
|
+
// return this
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
//
|
|
81
|
+
// export class Sequence extends VisualItem {
|
|
82
|
+
// constructor(private o: O, public item: Item.Sequence) {
|
|
83
|
+
// super(item)
|
|
84
|
+
// }
|
|
85
|
+
//
|
|
86
|
+
// spatial(spatial: Spatial) {
|
|
87
|
+
// this.item.spatialId = spatial.item.id
|
|
88
|
+
// return this
|
|
89
|
+
// }
|
|
90
|
+
//
|
|
91
|
+
// addChildren(fn: (o: O) => TimelineItem | TimelineItem[]) {
|
|
92
|
+
// const result = fn(this.o)
|
|
93
|
+
// const items = Array.isArray(result) ? result : [result]
|
|
94
|
+
// this.item.childrenIds.push(...items.map(c => c.item.id))
|
|
95
|
+
// return this
|
|
96
|
+
// }
|
|
97
|
+
// }
|
|
98
|
+
//
|
|
99
|
+
// export class Transition extends TimelineItem {
|
|
100
|
+
// constructor(public item: Item.Transition) {
|
|
101
|
+
// super(item)
|
|
102
|
+
// }
|
|
103
|
+
// }
|
|
104
|
+
//# sourceMappingURL=builders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builders.js","sourceRoot":"","sources":["../../../s/timeline/sugar/builders.ts"],"names":[],"mappings":";AAAA,2BAA2B;AAC3B,wCAAwC;AACxC,wCAAwC;AACxC,EAAE;AACF,8BAA8B;AAC9B,0BAA0B;AAC1B,EAAE;AACF,wCAAwC;AACxC,sBAAsB;AACtB,KAAK;AACL,EAAE;AACF,cAAc;AACd,aAAa;AACb,kBAAkB;AAClB,MAAM;AACN,KAAK;AACL,IAAI;AACJ,EAAE;AACF,mDAAmD;AACnD,qDAAqD;AACrD,IAAI;AACJ,EAAE;AACF,0CAA0C;AAC1C,yDAAyD;AACzD,iBAAiB;AACjB,MAAM;AACN,EAAE;AACF,gCAAgC;AAChC,2CAA2C;AAC3C,kBAAkB;AAClB,MAAM;AACN,EAAE;AACF,+DAA+D;AAC/D,+BAA+B;AAC/B,6DAA6D;AAC7D,+DAA+D;AAC/D,kBAAkB;AAClB,MAAM;AACN,IAAI;AACJ,EAAE;AACF,8CAA8C;AAC9C,wDAAwD;AACxD,IAAI;AACJ,EAAE;AACF,0CAA0C;AAC1C,oDAAoD;AACpD,IAAI;AACJ,EAAE;AACF,4CAA4C;AAC5C,sDAAsD;AACtD,IAAI;AACJ,EAAE;AACF,0CAA0C;AAC1C,2CAA2C;AAC3C,iBAAiB;AACjB,MAAM;AACN,EAAE;AACF,gCAAgC;AAChC,2CAA2C;AAC3C,kBAAkB;AAClB,MAAM;AACN,IAAI;AACJ,EAAE;AACF,yCAAyC;AACzC,0CAA0C;AAC1C,iBAAiB;AACjB,MAAM;AACN,EAAE;AACF,2BAA2B;AAC3B,6BAA6B;AAC7B,gBAAgB;AAChB,MAAM;AACN,EAAE;AACF,gCAAgC;AAChC,2CAA2C;AAC3C,kBAAkB;AAClB,MAAM;AACN,IAAI;AACJ,EAAE;AACF,6CAA6C;AAC7C,2DAA2D;AAC3D,gBAAgB;AAChB,KAAK;AACL,EAAE;AACF,gCAAgC;AAChC,2CAA2C;AAC3C,kBAAkB;AAClB,MAAM;AACN,EAAE;AACF,+DAA+D;AAC/D,+BAA+B;AAC/B,6DAA6D;AAC7D,+DAA+D;AAC/D,kBAAkB;AAClB,MAAM;AACN,IAAI;AACJ,EAAE;AACF,iDAAiD;AACjD,+CAA+C;AAC/C,gBAAgB;AAChB,KAAK;AACL,IAAI"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Media } from "../parts/media.js";
|
|
2
|
+
import { Id, TimelineFile } from "../parts/basics.js";
|
|
3
|
+
import { Item } from "../parts/item.js";
|
|
4
|
+
import { Transform, TransformOptions } from "../types.js";
|
|
5
|
+
export declare class O {
|
|
6
|
+
#private;
|
|
7
|
+
state: {
|
|
8
|
+
project: TimelineFile;
|
|
9
|
+
};
|
|
10
|
+
constructor(state: {
|
|
11
|
+
project: TimelineFile;
|
|
12
|
+
});
|
|
13
|
+
require<T extends Item.Any>(id: Id): T;
|
|
14
|
+
spatial: (transform: Transform) => Item.Spatial;
|
|
15
|
+
sequence: (...items: Item.Any[]) => Item.Any;
|
|
16
|
+
stack: (...items: Item.Any[]) => Item.Any;
|
|
17
|
+
video: (media: Media, options?: {
|
|
18
|
+
start?: number;
|
|
19
|
+
duration?: number;
|
|
20
|
+
}) => Item.Video;
|
|
21
|
+
audio: (media: Media, options?: {
|
|
22
|
+
start?: number;
|
|
23
|
+
duration?: number;
|
|
24
|
+
}) => Item.Audio;
|
|
25
|
+
text: (content: string) => Item.Text;
|
|
26
|
+
gap: (duration: number) => Item.Gap;
|
|
27
|
+
transition: {
|
|
28
|
+
crossfade: (duration: number) => Item.Transition;
|
|
29
|
+
};
|
|
30
|
+
transform: (options?: TransformOptions) => Transform;
|
|
31
|
+
addChildren(parent: Item.Stack | Item.Sequence, ...items: Item.Any[]): void;
|
|
32
|
+
}
|