@aicut/core 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -1
- package/dist/i18n-B-DFWgKe.d.cts +51 -0
- package/dist/i18n-B-DFWgKe.d.ts +51 -0
- package/dist/index.cjs +429 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +200 -6
- package/dist/index.d.ts +200 -6
- package/dist/index.js +371 -17
- package/dist/index.js.map +1 -1
- package/dist/lighting/index.d.cts +2 -1
- package/dist/lighting/index.d.ts +2 -1
- package/dist/playback/webcodecs/index.cjs +10572 -0
- package/dist/playback/webcodecs/index.cjs.map +1 -0
- package/dist/playback/webcodecs/index.d.cts +109 -0
- package/dist/playback/webcodecs/index.d.ts +109 -0
- package/dist/playback/webcodecs/index.js +10568 -0
- package/dist/playback/webcodecs/index.js.map +1 -0
- package/dist/types-CHplD9V5.d.cts +70 -0
- package/dist/types-CHplD9V5.d.ts +70 -0
- package/dist/types-DvKlxylu.d.cts +75 -0
- package/dist/types-rwZx6FxE.d.ts +75 -0
- package/package.json +15 -4
- package/styles/theme.css +7 -2
- package/dist/types-C95koNwJ.d.cts +0 -120
- package/dist/types-C95koNwJ.d.ts +0 -120
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { M as Ms, P as Project } from '../../types-CHplD9V5.cjs';
|
|
2
|
+
import { P as PlaybackEngine, a as PlaybackEngineOptions, b as PlaybackEngineFactory } from '../../types-DvKlxylu.cjs';
|
|
3
|
+
|
|
4
|
+
interface WebCodecsEngineOptions extends PlaybackEngineOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Show a corner HUD ("engine: webcodecs • t=… • decoded N • queue M").
|
|
7
|
+
* Off by default — production hosts get a clean canvas.
|
|
8
|
+
*/
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Frame-accurate single-track playback via WebCodecs `VideoDecoder`.
|
|
13
|
+
* Mp4Demuxer feeds encoded samples; the decoder emits VideoFrames we
|
|
14
|
+
* paint to a canvas on rAF. Seek snaps to the nearest keyframe at-or-
|
|
15
|
+
* before the target and decodes forward (true frame-accurate, not the
|
|
16
|
+
* browser's keyframe-snap).
|
|
17
|
+
*
|
|
18
|
+
* Scope of v1 (this PoC):
|
|
19
|
+
* - Single video clip per source (boundaries handled, but no
|
|
20
|
+
* transitions / compositing yet).
|
|
21
|
+
* - MP4 / MOV containers via mp4box.js (H.264 / HEVC / VP9 / AV1
|
|
22
|
+
* codecs, whatever the browser's VideoDecoder supports).
|
|
23
|
+
* - Audio not played.
|
|
24
|
+
*
|
|
25
|
+
* Follow-ups: multi-track compositing, audio, in/out trim cropping at
|
|
26
|
+
* the decoder level, segment-prefetch across clip boundaries.
|
|
27
|
+
*/
|
|
28
|
+
declare class WebCodecsEngine implements PlaybackEngine {
|
|
29
|
+
private host;
|
|
30
|
+
private mount;
|
|
31
|
+
private canvas;
|
|
32
|
+
private ctx;
|
|
33
|
+
private badge;
|
|
34
|
+
private project;
|
|
35
|
+
private currentClipId;
|
|
36
|
+
private sources;
|
|
37
|
+
private playing;
|
|
38
|
+
private timeMs;
|
|
39
|
+
private rafHandle;
|
|
40
|
+
private lastFrameTs;
|
|
41
|
+
private decodedFramesTotal;
|
|
42
|
+
private destroyed;
|
|
43
|
+
onTimeUpdate?: (ms: Ms) => void;
|
|
44
|
+
onEnded?: () => void;
|
|
45
|
+
onError?: (err: Error) => void;
|
|
46
|
+
onReady?: () => void;
|
|
47
|
+
onSourceMetadata?: (sourceId: string, durationMs: Ms) => void;
|
|
48
|
+
constructor(opts: WebCodecsEngineOptions);
|
|
49
|
+
setProject(next: Project): void;
|
|
50
|
+
play(): void;
|
|
51
|
+
pause(): void;
|
|
52
|
+
isPlaying(): boolean;
|
|
53
|
+
getTime(): Ms;
|
|
54
|
+
seek(timeMs: Ms): void;
|
|
55
|
+
destroy(): void;
|
|
56
|
+
private syncSources;
|
|
57
|
+
private teardownSource;
|
|
58
|
+
private onTrackReady;
|
|
59
|
+
private onDecodedFrame;
|
|
60
|
+
private activate;
|
|
61
|
+
private seekActiveTo;
|
|
62
|
+
private flushFrames;
|
|
63
|
+
/**
|
|
64
|
+
* Feed enough samples to keep the frame queue at FRAME_QUEUE_AHEAD.
|
|
65
|
+
* Called every paint() cycle plus immediately after seek.
|
|
66
|
+
*/
|
|
67
|
+
private feedDecoder;
|
|
68
|
+
private clipById;
|
|
69
|
+
private clipAtTime;
|
|
70
|
+
private nextClipAfterTime;
|
|
71
|
+
private totalDuration;
|
|
72
|
+
private resizeCanvas;
|
|
73
|
+
private startTickLoop;
|
|
74
|
+
private stopTickLoop;
|
|
75
|
+
private advance;
|
|
76
|
+
/**
|
|
77
|
+
* Render the frame matching the current playhead, top up the decoder
|
|
78
|
+
* queue, evict stale frames. Always runs (not just on play) so seek
|
|
79
|
+
* previews the target frame and the HUD stays current when paused.
|
|
80
|
+
*/
|
|
81
|
+
private paint;
|
|
82
|
+
private updateBadge;
|
|
83
|
+
}
|
|
84
|
+
/** Factory shorthand — defaults debug off. */
|
|
85
|
+
declare const webCodecsEngineFactory: PlaybackEngineFactory;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Feature detection — every API the engine needs must be present.
|
|
89
|
+
* Used both by the engine constructor (hard gate) and by hosts that
|
|
90
|
+
* want to conditionally render an engine selector.
|
|
91
|
+
*/
|
|
92
|
+
declare function isWebCodecsSupported(): boolean;
|
|
93
|
+
|
|
94
|
+
interface DemuxedTrack {
|
|
95
|
+
trackId: number;
|
|
96
|
+
/** WebCodecs codec string, e.g. "avc1.42E01E" / "hvc1.1.6.L93.B0". */
|
|
97
|
+
codec: string;
|
|
98
|
+
/** Raw bytes of the codec config box (avcC / hvcC / vpcC / av1C)
|
|
99
|
+
* — feed straight to `decoder.configure({ description })`. */
|
|
100
|
+
description: Uint8Array;
|
|
101
|
+
width: number;
|
|
102
|
+
height: number;
|
|
103
|
+
/** Track timescale (ticks per second in cts/dts). */
|
|
104
|
+
timescale: number;
|
|
105
|
+
/** Track duration in ms. */
|
|
106
|
+
durationMs: Ms;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { type DemuxedTrack, WebCodecsEngine, type WebCodecsEngineOptions, isWebCodecsSupported, webCodecsEngineFactory };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { M as Ms, P as Project } from '../../types-CHplD9V5.js';
|
|
2
|
+
import { P as PlaybackEngine, a as PlaybackEngineOptions, b as PlaybackEngineFactory } from '../../types-rwZx6FxE.js';
|
|
3
|
+
|
|
4
|
+
interface WebCodecsEngineOptions extends PlaybackEngineOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Show a corner HUD ("engine: webcodecs • t=… • decoded N • queue M").
|
|
7
|
+
* Off by default — production hosts get a clean canvas.
|
|
8
|
+
*/
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Frame-accurate single-track playback via WebCodecs `VideoDecoder`.
|
|
13
|
+
* Mp4Demuxer feeds encoded samples; the decoder emits VideoFrames we
|
|
14
|
+
* paint to a canvas on rAF. Seek snaps to the nearest keyframe at-or-
|
|
15
|
+
* before the target and decodes forward (true frame-accurate, not the
|
|
16
|
+
* browser's keyframe-snap).
|
|
17
|
+
*
|
|
18
|
+
* Scope of v1 (this PoC):
|
|
19
|
+
* - Single video clip per source (boundaries handled, but no
|
|
20
|
+
* transitions / compositing yet).
|
|
21
|
+
* - MP4 / MOV containers via mp4box.js (H.264 / HEVC / VP9 / AV1
|
|
22
|
+
* codecs, whatever the browser's VideoDecoder supports).
|
|
23
|
+
* - Audio not played.
|
|
24
|
+
*
|
|
25
|
+
* Follow-ups: multi-track compositing, audio, in/out trim cropping at
|
|
26
|
+
* the decoder level, segment-prefetch across clip boundaries.
|
|
27
|
+
*/
|
|
28
|
+
declare class WebCodecsEngine implements PlaybackEngine {
|
|
29
|
+
private host;
|
|
30
|
+
private mount;
|
|
31
|
+
private canvas;
|
|
32
|
+
private ctx;
|
|
33
|
+
private badge;
|
|
34
|
+
private project;
|
|
35
|
+
private currentClipId;
|
|
36
|
+
private sources;
|
|
37
|
+
private playing;
|
|
38
|
+
private timeMs;
|
|
39
|
+
private rafHandle;
|
|
40
|
+
private lastFrameTs;
|
|
41
|
+
private decodedFramesTotal;
|
|
42
|
+
private destroyed;
|
|
43
|
+
onTimeUpdate?: (ms: Ms) => void;
|
|
44
|
+
onEnded?: () => void;
|
|
45
|
+
onError?: (err: Error) => void;
|
|
46
|
+
onReady?: () => void;
|
|
47
|
+
onSourceMetadata?: (sourceId: string, durationMs: Ms) => void;
|
|
48
|
+
constructor(opts: WebCodecsEngineOptions);
|
|
49
|
+
setProject(next: Project): void;
|
|
50
|
+
play(): void;
|
|
51
|
+
pause(): void;
|
|
52
|
+
isPlaying(): boolean;
|
|
53
|
+
getTime(): Ms;
|
|
54
|
+
seek(timeMs: Ms): void;
|
|
55
|
+
destroy(): void;
|
|
56
|
+
private syncSources;
|
|
57
|
+
private teardownSource;
|
|
58
|
+
private onTrackReady;
|
|
59
|
+
private onDecodedFrame;
|
|
60
|
+
private activate;
|
|
61
|
+
private seekActiveTo;
|
|
62
|
+
private flushFrames;
|
|
63
|
+
/**
|
|
64
|
+
* Feed enough samples to keep the frame queue at FRAME_QUEUE_AHEAD.
|
|
65
|
+
* Called every paint() cycle plus immediately after seek.
|
|
66
|
+
*/
|
|
67
|
+
private feedDecoder;
|
|
68
|
+
private clipById;
|
|
69
|
+
private clipAtTime;
|
|
70
|
+
private nextClipAfterTime;
|
|
71
|
+
private totalDuration;
|
|
72
|
+
private resizeCanvas;
|
|
73
|
+
private startTickLoop;
|
|
74
|
+
private stopTickLoop;
|
|
75
|
+
private advance;
|
|
76
|
+
/**
|
|
77
|
+
* Render the frame matching the current playhead, top up the decoder
|
|
78
|
+
* queue, evict stale frames. Always runs (not just on play) so seek
|
|
79
|
+
* previews the target frame and the HUD stays current when paused.
|
|
80
|
+
*/
|
|
81
|
+
private paint;
|
|
82
|
+
private updateBadge;
|
|
83
|
+
}
|
|
84
|
+
/** Factory shorthand — defaults debug off. */
|
|
85
|
+
declare const webCodecsEngineFactory: PlaybackEngineFactory;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Feature detection — every API the engine needs must be present.
|
|
89
|
+
* Used both by the engine constructor (hard gate) and by hosts that
|
|
90
|
+
* want to conditionally render an engine selector.
|
|
91
|
+
*/
|
|
92
|
+
declare function isWebCodecsSupported(): boolean;
|
|
93
|
+
|
|
94
|
+
interface DemuxedTrack {
|
|
95
|
+
trackId: number;
|
|
96
|
+
/** WebCodecs codec string, e.g. "avc1.42E01E" / "hvc1.1.6.L93.B0". */
|
|
97
|
+
codec: string;
|
|
98
|
+
/** Raw bytes of the codec config box (avcC / hvcC / vpcC / av1C)
|
|
99
|
+
* — feed straight to `decoder.configure({ description })`. */
|
|
100
|
+
description: Uint8Array;
|
|
101
|
+
width: number;
|
|
102
|
+
height: number;
|
|
103
|
+
/** Track timescale (ticks per second in cts/dts). */
|
|
104
|
+
timescale: number;
|
|
105
|
+
/** Track duration in ms. */
|
|
106
|
+
durationMs: Ms;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { type DemuxedTrack, WebCodecsEngine, type WebCodecsEngineOptions, isWebCodecsSupported, webCodecsEngineFactory };
|