openvideo 0.0.1
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 +63 -0
- package/dist/SharedSystems-pXK0PjzC.js +2691 -0
- package/dist/WebGLRenderer-B_y7ugdK.js +2639 -0
- package/dist/WebGPURenderer-ByeYcldK.js +1655 -0
- package/dist/browserAll-lTqv9nwW.js +1876 -0
- package/dist/clips/audio-clip.d.ts +128 -0
- package/dist/clips/base-clip.d.ts +116 -0
- package/dist/clips/caption-clip.d.ts +392 -0
- package/dist/clips/effect-clip.d.ts +37 -0
- package/dist/clips/iclip.d.ts +178 -0
- package/dist/clips/image-clip.d.ts +115 -0
- package/dist/clips/index.d.ts +14 -0
- package/dist/clips/placeholder-clip.d.ts +15 -0
- package/dist/clips/text-clip.d.ts +266 -0
- package/dist/clips/transition-clip.d.ts +45 -0
- package/dist/clips/video-clip.d.ts +238 -0
- package/dist/colorToUniform-C2jGzNe1.js +97 -0
- package/dist/compositor.d.ts +107 -0
- package/dist/effect/effect.d.ts +6 -0
- package/dist/effect/glsl/custom-glsl.d.ts +1017 -0
- package/dist/effect/glsl/gl-effect.d.ts +16 -0
- package/dist/effect/types.d.ts +24 -0
- package/dist/effect/vertex.d.ts +1 -0
- package/dist/event-emitter.d.ts +55 -0
- package/dist/index-CIRqJXOw.js +41882 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.es.js +28 -0
- package/dist/index.umd.js +7741 -0
- package/dist/json-serialization.d.ts +222 -0
- package/dist/mp4-utils/index.d.ts +31 -0
- package/dist/mp4-utils/mp4box-utils.d.ts +44 -0
- package/dist/mp4-utils/sample-transform.d.ts +26 -0
- package/dist/sprite/base-sprite.d.ts +183 -0
- package/dist/sprite/pixi-sprite-renderer.d.ts +49 -0
- package/dist/studio/history-manager.d.ts +46 -0
- package/dist/studio/resource-manager.d.ts +53 -0
- package/dist/studio/resource-manager.spec.d.ts +1 -0
- package/dist/studio/selection-manager.d.ts +50 -0
- package/dist/studio/timeline-model.d.ts +110 -0
- package/dist/studio/transport.d.ts +44 -0
- package/dist/studio.d.ts +380 -0
- package/dist/studio.spec.d.ts +1 -0
- package/dist/transfomer/parts/handle.d.ts +17 -0
- package/dist/transfomer/parts/snapping.d.ts +41 -0
- package/dist/transfomer/parts/wireframe.d.ts +5 -0
- package/dist/transfomer/transformer.d.ts +31 -0
- package/dist/transition/fragment.d.ts +1 -0
- package/dist/transition/glsl/custom-glsl.d.ts +231 -0
- package/dist/transition/glsl/gl-transition.d.ts +18 -0
- package/dist/transition/transition.d.ts +6 -0
- package/dist/transition/types.d.ts +29 -0
- package/dist/transition/uniforms.d.ts +35 -0
- package/dist/transition/vertex.d.ts +1 -0
- package/dist/utils/asset-manager.d.ts +6 -0
- package/dist/utils/audio-codec-detector.d.ts +28 -0
- package/dist/utils/audio.d.ts +82 -0
- package/dist/utils/chromakey.d.ts +24 -0
- package/dist/utils/color.d.ts +9 -0
- package/dist/utils/common.d.ts +7 -0
- package/dist/utils/dom.d.ts +48 -0
- package/dist/utils/fonts.d.ts +16 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/log.d.ts +27 -0
- package/dist/utils/srt-parser.d.ts +15 -0
- package/dist/utils/stream-utils.d.ts +9 -0
- package/dist/utils/video.d.ts +16 -0
- package/dist/utils/worker-timer.d.ts +1 -0
- package/dist/webworkerAll-BsrA7oC4.js +2670 -0
- package/package.json +63 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { IClip, ITransitionInfo } from './clips';
|
|
2
|
+
interface BaseClipJSON {
|
|
3
|
+
id?: string;
|
|
4
|
+
effects?: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
key: string;
|
|
7
|
+
startTime: number;
|
|
8
|
+
duration: number;
|
|
9
|
+
targets?: number[];
|
|
10
|
+
}>;
|
|
11
|
+
src: string;
|
|
12
|
+
display: {
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
};
|
|
16
|
+
playbackRate: number;
|
|
17
|
+
duration: number;
|
|
18
|
+
left: number;
|
|
19
|
+
top: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
angle: number;
|
|
23
|
+
zIndex: number;
|
|
24
|
+
opacity: number;
|
|
25
|
+
flip: 'horizontal' | 'vertical' | null;
|
|
26
|
+
trim?: {
|
|
27
|
+
from: number;
|
|
28
|
+
to: number;
|
|
29
|
+
};
|
|
30
|
+
transition?: ITransitionInfo;
|
|
31
|
+
style?: any;
|
|
32
|
+
animation?: {
|
|
33
|
+
keyFrames: Record<string, Partial<{
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
w: number;
|
|
37
|
+
h: number;
|
|
38
|
+
angle: number;
|
|
39
|
+
opacity: number;
|
|
40
|
+
}>>;
|
|
41
|
+
opts: {
|
|
42
|
+
duration: number;
|
|
43
|
+
delay?: number;
|
|
44
|
+
iterCount?: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
main?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface VideoJSON extends BaseClipJSON {
|
|
50
|
+
type: 'Video';
|
|
51
|
+
audio?: boolean;
|
|
52
|
+
volume?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface AudioJSON extends BaseClipJSON {
|
|
55
|
+
type: 'Audio';
|
|
56
|
+
loop?: boolean;
|
|
57
|
+
volume?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface ImageJSON extends BaseClipJSON {
|
|
60
|
+
type: 'Image';
|
|
61
|
+
}
|
|
62
|
+
export interface TextStyleJSON {
|
|
63
|
+
fontSize?: number;
|
|
64
|
+
fontFamily?: string;
|
|
65
|
+
fontWeight?: string | number;
|
|
66
|
+
fontStyle?: string;
|
|
67
|
+
color?: string | number | {
|
|
68
|
+
type: 'gradient';
|
|
69
|
+
x0: number;
|
|
70
|
+
y0: number;
|
|
71
|
+
x1: number;
|
|
72
|
+
y1: number;
|
|
73
|
+
colors: Array<{
|
|
74
|
+
ratio: number;
|
|
75
|
+
color: string | number;
|
|
76
|
+
}>;
|
|
77
|
+
};
|
|
78
|
+
align?: 'left' | 'center' | 'right';
|
|
79
|
+
fontUrl?: string;
|
|
80
|
+
stroke?: {
|
|
81
|
+
color: string | number;
|
|
82
|
+
width: number;
|
|
83
|
+
join?: 'miter' | 'round' | 'bevel';
|
|
84
|
+
cap?: 'butt' | 'round' | 'square';
|
|
85
|
+
miterLimit?: number;
|
|
86
|
+
};
|
|
87
|
+
shadow?: {
|
|
88
|
+
color: string | number;
|
|
89
|
+
alpha: number;
|
|
90
|
+
blur: number;
|
|
91
|
+
distance: number;
|
|
92
|
+
angle: number;
|
|
93
|
+
};
|
|
94
|
+
wordWrap?: boolean;
|
|
95
|
+
wordWrapWidth?: number;
|
|
96
|
+
lineHeight?: number;
|
|
97
|
+
letterSpacing?: number;
|
|
98
|
+
textCase?: 'none' | 'uppercase' | 'lowercase' | 'title';
|
|
99
|
+
verticalAlign?: 'top' | 'center' | 'bottom';
|
|
100
|
+
wordsPerLine?: 'single' | 'multiple';
|
|
101
|
+
}
|
|
102
|
+
export interface TextJSON extends BaseClipJSON {
|
|
103
|
+
type: 'Text';
|
|
104
|
+
text: string;
|
|
105
|
+
style?: TextStyleJSON;
|
|
106
|
+
}
|
|
107
|
+
export interface CaptionColorsJSON {
|
|
108
|
+
appeared?: string;
|
|
109
|
+
active?: string;
|
|
110
|
+
activeFill?: string;
|
|
111
|
+
background?: string;
|
|
112
|
+
keyword?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface CaptionPositioningJSON {
|
|
115
|
+
bottomOffset?: number;
|
|
116
|
+
videoWidth?: number;
|
|
117
|
+
videoHeight?: number;
|
|
118
|
+
}
|
|
119
|
+
export interface CaptionDataJSON {
|
|
120
|
+
words?: Array<{
|
|
121
|
+
text: string;
|
|
122
|
+
from: number;
|
|
123
|
+
to: number;
|
|
124
|
+
isKeyWord: boolean;
|
|
125
|
+
paragraphIndex?: number;
|
|
126
|
+
}>;
|
|
127
|
+
colors?: CaptionColorsJSON;
|
|
128
|
+
preserveKeywordColor?: boolean;
|
|
129
|
+
positioning?: CaptionPositioningJSON;
|
|
130
|
+
}
|
|
131
|
+
export interface CaptionJSON extends BaseClipJSON {
|
|
132
|
+
type: 'Caption';
|
|
133
|
+
text: string;
|
|
134
|
+
style?: TextStyleJSON;
|
|
135
|
+
caption?: CaptionDataJSON;
|
|
136
|
+
bottomOffset?: number;
|
|
137
|
+
words?: Array<{
|
|
138
|
+
text: string;
|
|
139
|
+
from: number;
|
|
140
|
+
to: number;
|
|
141
|
+
isKeyWord: boolean;
|
|
142
|
+
paragraphIndex?: number;
|
|
143
|
+
}>;
|
|
144
|
+
appearedColor?: string;
|
|
145
|
+
activeColor?: string;
|
|
146
|
+
activeFillColor?: string;
|
|
147
|
+
backgroundColor?: string;
|
|
148
|
+
isKeyWordColor?: string;
|
|
149
|
+
preservedColorKeyWord?: boolean;
|
|
150
|
+
videoWidth?: number;
|
|
151
|
+
videoHeight?: number;
|
|
152
|
+
fontUrl?: string;
|
|
153
|
+
mediaId?: string;
|
|
154
|
+
wordsPerLine?: 'single' | 'multiple';
|
|
155
|
+
}
|
|
156
|
+
export interface EffectJSON extends BaseClipJSON {
|
|
157
|
+
type: 'Effect';
|
|
158
|
+
effect: {
|
|
159
|
+
id: string;
|
|
160
|
+
key: string;
|
|
161
|
+
name: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export interface TransitionJSON extends BaseClipJSON {
|
|
165
|
+
type: 'Transition';
|
|
166
|
+
transitionEffect: {
|
|
167
|
+
id: string;
|
|
168
|
+
key: string;
|
|
169
|
+
name: string;
|
|
170
|
+
};
|
|
171
|
+
fromClipId: string | null;
|
|
172
|
+
toClipId: string | null;
|
|
173
|
+
}
|
|
174
|
+
export interface PlaceholderJSON extends BaseClipJSON {
|
|
175
|
+
type: 'Placeholder';
|
|
176
|
+
}
|
|
177
|
+
export interface GlobalTransitionJSON {
|
|
178
|
+
key: string;
|
|
179
|
+
duration: number;
|
|
180
|
+
clips: string[];
|
|
181
|
+
}
|
|
182
|
+
export type ClipJSON = VideoJSON | AudioJSON | ImageJSON | TextJSON | CaptionJSON | EffectJSON | TransitionJSON | PlaceholderJSON;
|
|
183
|
+
export interface StudioTrackJSON {
|
|
184
|
+
id: string;
|
|
185
|
+
name: string;
|
|
186
|
+
type: string;
|
|
187
|
+
clipIds: string[];
|
|
188
|
+
}
|
|
189
|
+
export interface ProjectJSON {
|
|
190
|
+
tracks?: StudioTrackJSON[];
|
|
191
|
+
clips: ClipJSON[];
|
|
192
|
+
transition?: GlobalTransitionJSON[];
|
|
193
|
+
transitions?: GlobalTransitionJSON[];
|
|
194
|
+
globalEffects?: Array<{
|
|
195
|
+
id: string;
|
|
196
|
+
key: string;
|
|
197
|
+
startTime: number;
|
|
198
|
+
duration: number;
|
|
199
|
+
}>;
|
|
200
|
+
settings?: {
|
|
201
|
+
width?: number;
|
|
202
|
+
height?: number;
|
|
203
|
+
fps?: number;
|
|
204
|
+
bgColor?: string;
|
|
205
|
+
videoCodec?: string;
|
|
206
|
+
bitrate?: number;
|
|
207
|
+
audio?: boolean;
|
|
208
|
+
metaDataTags?: Record<string, string>;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Serialize a clip to JSON format
|
|
213
|
+
* @param clip The clip to serialize
|
|
214
|
+
* @param main Whether this is the main clip (for Compositor)
|
|
215
|
+
*/
|
|
216
|
+
export declare function clipToJSON(clip: IClip, main?: boolean): ClipJSON;
|
|
217
|
+
/**
|
|
218
|
+
* Deserialize JSON to a clip instance
|
|
219
|
+
* Uses fromObject static method if available (fabric.js pattern), otherwise falls back to manual construction
|
|
220
|
+
*/
|
|
221
|
+
export declare function jsonToClip(json: ClipJSON): Promise<IClip>;
|
|
222
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quick concatenate multiple MP4 file streams, requires all MP4s to have consistent properties,
|
|
3
|
+
* properties include (but not limited to): audio/video codec format, resolution, sample rate
|
|
4
|
+
*
|
|
5
|
+
* @param streams An array of readable streams containing Uint8Array.
|
|
6
|
+
* @returns Returns a Promise that resolves to a readable stream containing merged MP4 data.
|
|
7
|
+
* @throws Will throw error if unable to generate file from streams.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const streams = [stream1, stream2, stream3];
|
|
11
|
+
* const resultStream = await fastConcatMP4(streams);
|
|
12
|
+
*/
|
|
13
|
+
export declare function fastConcatMP4(streams: ReadableStream<Uint8Array>[]): Promise<ReadableStream<Uint8Array>>;
|
|
14
|
+
/**
|
|
15
|
+
* Set correct duration value for fMP4 files generated
|
|
16
|
+
*/
|
|
17
|
+
export declare function fixFMP4Duration(stream: ReadableStream<Uint8Array>): Promise<ReadableStream<Uint8Array>>;
|
|
18
|
+
/**
|
|
19
|
+
* Video dubbing; mix MP4 with audio file, only re-encode audio, video track unchanged
|
|
20
|
+
* @param mp4Stream - MP4 stream
|
|
21
|
+
* @param audio - Audio information
|
|
22
|
+
* @param audio.stream - Audio data stream
|
|
23
|
+
* @param audio.volume - Audio volume
|
|
24
|
+
* @param audio.loop - When audio duration is less than video, whether to loop audio stream
|
|
25
|
+
* @returns Output mixed audio stream
|
|
26
|
+
*/
|
|
27
|
+
export declare function mixinMP4AndAudio(mp4Stream: ReadableStream<Uint8Array>, audio: {
|
|
28
|
+
stream: ReadableStream<Uint8Array>;
|
|
29
|
+
volume: number;
|
|
30
|
+
loop: boolean;
|
|
31
|
+
}): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AudioTrackOpts, MP4File, MP4Info, MP4Sample, VideoTrackOpts } from 'wrapbox';
|
|
2
|
+
import { file } from 'opfs-tools';
|
|
3
|
+
interface ExtractedConfig {
|
|
4
|
+
videoTrackConf?: VideoTrackOpts;
|
|
5
|
+
videoDecoderConf?: VideoDecoderConfig;
|
|
6
|
+
audioTrackConf?: AudioTrackOpts;
|
|
7
|
+
audioDecoderConf?: AudioDecoderConfig;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Extracts video and audio configurations from an MP4 file.
|
|
11
|
+
*/
|
|
12
|
+
export declare function extractFileConfig(file: MP4File, info: MP4Info): ExtractedConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Quick parse mp4 file, prioritizing header parsing to save memory.
|
|
15
|
+
*/
|
|
16
|
+
export declare function quickParseMP4File(reader: Awaited<ReturnType<ReturnType<typeof file>['createReader']>>, onReady: (data: {
|
|
17
|
+
mp4boxFile: MP4File;
|
|
18
|
+
info: MP4Info;
|
|
19
|
+
}) => void, onSamples: (id: number, sampleType: 'video' | 'audio', samples: MP4Sample[]) => void): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Parses transformation matrix to extract scale, rotation, and translation.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseMatrix(matrix?: Int32Array): {
|
|
24
|
+
scaleX?: undefined;
|
|
25
|
+
scaleY?: undefined;
|
|
26
|
+
rotationRad?: undefined;
|
|
27
|
+
rotationDeg?: undefined;
|
|
28
|
+
translateX?: undefined;
|
|
29
|
+
translateY?: undefined;
|
|
30
|
+
perspective?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
scaleX: number;
|
|
33
|
+
scaleY: number;
|
|
34
|
+
rotationRad: number;
|
|
35
|
+
rotationDeg: number;
|
|
36
|
+
translateX: number;
|
|
37
|
+
translateY: number;
|
|
38
|
+
perspective: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Creates a function to rotate VideoFrames using Canvas.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createVFRotater(width: number, height: number, rotationDeg: number): (vf: VideoFrame | null) => VideoFrame | null;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MP4File, MP4Info, MP4Sample } from 'wrapbox';
|
|
2
|
+
export type TransformChunk = {
|
|
3
|
+
chunkType: 'ready';
|
|
4
|
+
data: {
|
|
5
|
+
info: MP4Info;
|
|
6
|
+
file: MP4File;
|
|
7
|
+
};
|
|
8
|
+
} | {
|
|
9
|
+
chunkType: 'samples';
|
|
10
|
+
data: {
|
|
11
|
+
id: number;
|
|
12
|
+
type: 'video' | 'audio';
|
|
13
|
+
samples: MP4Sample[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Transforms a raw byte stream into an MP4Sample stream using mp4box.js.
|
|
18
|
+
*/
|
|
19
|
+
export declare class SampleTransform {
|
|
20
|
+
readonly readable: ReadableStream<TransformChunk>;
|
|
21
|
+
readonly writable: WritableStream<Uint8Array>;
|
|
22
|
+
private inputBufOffset;
|
|
23
|
+
private isStreamCancelled;
|
|
24
|
+
constructor();
|
|
25
|
+
private initMP4Box;
|
|
26
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { default as EventEmitter } from '../event-emitter';
|
|
2
|
+
type IRectBaseProps = any;
|
|
3
|
+
interface IAnimationOpts {
|
|
4
|
+
duration: number;
|
|
5
|
+
delay?: number;
|
|
6
|
+
iterCount?: number;
|
|
7
|
+
}
|
|
8
|
+
type TAnimateProps = IRectBaseProps & {
|
|
9
|
+
opacity: number;
|
|
10
|
+
};
|
|
11
|
+
export type TAnimationKeyFrame = Array<[number, Partial<TAnimateProps>]>;
|
|
12
|
+
type TKeyFrameOpts = Partial<Record<`${number}%` | 'from' | 'to', Partial<TAnimateProps>>>;
|
|
13
|
+
export interface BaseSpriteEvents {
|
|
14
|
+
propsChange: Partial<{
|
|
15
|
+
left: number;
|
|
16
|
+
top: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
angle: number;
|
|
20
|
+
zIndex: number;
|
|
21
|
+
opacity: number;
|
|
22
|
+
volume: number;
|
|
23
|
+
}>;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
[key: symbol]: any;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Sprite base class
|
|
29
|
+
*
|
|
30
|
+
* @see {@link OffscreenSprite}
|
|
31
|
+
*/
|
|
32
|
+
export declare abstract class BaseSprite<T extends BaseSpriteEvents = BaseSpriteEvents> extends EventEmitter<T> {
|
|
33
|
+
/**
|
|
34
|
+
* Unique identifier for the sprite/clip
|
|
35
|
+
*/
|
|
36
|
+
id: string;
|
|
37
|
+
/**
|
|
38
|
+
* Control display time range of clips, commonly used in editing scenario timeline (track) module
|
|
39
|
+
* from: start time offset in microseconds
|
|
40
|
+
* to: end time (from + duration) in microseconds
|
|
41
|
+
*/
|
|
42
|
+
display: {
|
|
43
|
+
from: number;
|
|
44
|
+
to: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Duration of the clip in microseconds
|
|
48
|
+
* Cannot exceed the duration of the referenced {@link IClip}
|
|
49
|
+
*/
|
|
50
|
+
duration: number;
|
|
51
|
+
/**
|
|
52
|
+
* Playback rate of current clip, 1 means normal playback
|
|
53
|
+
* **Note**
|
|
54
|
+
* 1. When setting playbackRate, duration must be actively corrected
|
|
55
|
+
* 2. Audio uses the simplest interpolation algorithm to change rate, so changing rate will cause pitch variation, for custom algorithm please use {@link Video.tickInterceptor} to implement
|
|
56
|
+
*/
|
|
57
|
+
playbackRate: number;
|
|
58
|
+
/**
|
|
59
|
+
* Trim range of the source media in microseconds
|
|
60
|
+
* from: start time in microseconds
|
|
61
|
+
* to: end time in microseconds
|
|
62
|
+
*/
|
|
63
|
+
trim: {
|
|
64
|
+
from: number;
|
|
65
|
+
to: number;
|
|
66
|
+
};
|
|
67
|
+
constructor();
|
|
68
|
+
protected _left: number;
|
|
69
|
+
/**
|
|
70
|
+
* Left position (x coordinate)
|
|
71
|
+
*/
|
|
72
|
+
get left(): number;
|
|
73
|
+
set left(v: number);
|
|
74
|
+
protected _top: number;
|
|
75
|
+
/**
|
|
76
|
+
* Top position (y coordinate)
|
|
77
|
+
*/
|
|
78
|
+
get top(): number;
|
|
79
|
+
set top(v: number);
|
|
80
|
+
protected _width: number;
|
|
81
|
+
/**
|
|
82
|
+
* Width
|
|
83
|
+
*/
|
|
84
|
+
get width(): number;
|
|
85
|
+
set width(v: number);
|
|
86
|
+
protected _height: number;
|
|
87
|
+
/**
|
|
88
|
+
* Height
|
|
89
|
+
*/
|
|
90
|
+
get height(): number;
|
|
91
|
+
set height(v: number);
|
|
92
|
+
private _angle;
|
|
93
|
+
/**
|
|
94
|
+
* Rotation angle in degrees
|
|
95
|
+
*/
|
|
96
|
+
get angle(): number;
|
|
97
|
+
set angle(v: number);
|
|
98
|
+
/**
|
|
99
|
+
* Center point calculated from position and dimensions
|
|
100
|
+
*/
|
|
101
|
+
get center(): {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
};
|
|
105
|
+
private _zIndex;
|
|
106
|
+
get zIndex(): number;
|
|
107
|
+
/**
|
|
108
|
+
* Control layering relationship between clips, clips with smaller zIndex will be occluded
|
|
109
|
+
*/
|
|
110
|
+
set zIndex(v: number);
|
|
111
|
+
private _opacity;
|
|
112
|
+
/**
|
|
113
|
+
* Opacity (0.0 to 1.0)
|
|
114
|
+
*/
|
|
115
|
+
get opacity(): number;
|
|
116
|
+
set opacity(v: number);
|
|
117
|
+
private _volume;
|
|
118
|
+
/**
|
|
119
|
+
* Audio volume level (0.0 to 1.0)
|
|
120
|
+
*/
|
|
121
|
+
get volume(): number;
|
|
122
|
+
set volume(v: number);
|
|
123
|
+
/**
|
|
124
|
+
* Flip clip horizontally or vertically
|
|
125
|
+
*/
|
|
126
|
+
flip: 'horizontal' | 'vertical' | null;
|
|
127
|
+
effects: Array<{
|
|
128
|
+
id: string;
|
|
129
|
+
key: string;
|
|
130
|
+
startTime: number;
|
|
131
|
+
duration: number;
|
|
132
|
+
targets?: number[];
|
|
133
|
+
}>;
|
|
134
|
+
/**
|
|
135
|
+
* Styling properties (e.g., stroke, dropShadow, borderRadius)
|
|
136
|
+
* This is a generic object to hold visual styles across different clip types
|
|
137
|
+
*/
|
|
138
|
+
protected _style: any;
|
|
139
|
+
get style(): any;
|
|
140
|
+
set style(v: any);
|
|
141
|
+
private animatKeyFrame;
|
|
142
|
+
private animatOpts;
|
|
143
|
+
/**
|
|
144
|
+
* @see {@link IClip.ready}
|
|
145
|
+
* For clips, this should be Promise<IClipMeta>, but for BaseSprite it's just Promise<void>
|
|
146
|
+
*/
|
|
147
|
+
ready: Promise<any>;
|
|
148
|
+
protected _render(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
149
|
+
/**
|
|
150
|
+
* Add animation to clip, usage reference CSS animation
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* sprite.setAnimation(
|
|
154
|
+
* {
|
|
155
|
+
* '0%': { x: 0, y: 0 },
|
|
156
|
+
* '25%': { x: 1200, y: 680 },
|
|
157
|
+
* '50%': { x: 1200, y: 0 },
|
|
158
|
+
* '75%': { x: 0, y: 680 },
|
|
159
|
+
* '100%': { x: 0, y: 0 },
|
|
160
|
+
* },
|
|
161
|
+
* { duration: 4e6, iterCount: 1 },
|
|
162
|
+
* );
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
setAnimation(keyFrame: TKeyFrameOpts, opts: IAnimationOpts): void;
|
|
166
|
+
/**
|
|
167
|
+
* If current sprite has animation set, set sprite's animation properties to state at specified time
|
|
168
|
+
*/
|
|
169
|
+
animate(time: number): void;
|
|
170
|
+
/**
|
|
171
|
+
* Copy current sprite's properties to target
|
|
172
|
+
*
|
|
173
|
+
* Used for cloning or copying state between {@link OffscreenSprite} instances
|
|
174
|
+
*/
|
|
175
|
+
copyStateTo<T extends BaseSprite>(target: T): void;
|
|
176
|
+
/**
|
|
177
|
+
* Update multiple properties at once
|
|
178
|
+
*/
|
|
179
|
+
update(updates: Partial<this>): void;
|
|
180
|
+
protected destroy(): void;
|
|
181
|
+
}
|
|
182
|
+
export declare function linearTimeFn(time: number, keyFrame: TAnimationKeyFrame, opts: Required<IAnimationOpts>): Partial<TAnimateProps>;
|
|
183
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Application, Sprite, Texture, Container } from 'pixi.js';
|
|
2
|
+
import { IClip } from '../clips/iclip';
|
|
3
|
+
/**
|
|
4
|
+
* Update sprite transform based on clip properties
|
|
5
|
+
* Utility function for updating standalone sprites (e.g., video sprites from HTMLVideoElement)
|
|
6
|
+
* For sprites managed by PixiSpriteRenderer, use renderer.updateTransforms() instead
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateSpriteTransform(clip: IClip, sprite: Sprite): void;
|
|
9
|
+
/**
|
|
10
|
+
* Renders video frames using Pixi.js
|
|
11
|
+
* Uses a canvas-based approach: draws frames to a canvas and creates texture from it
|
|
12
|
+
* This matches the pattern used in other video rendering libraries
|
|
13
|
+
*/
|
|
14
|
+
export declare class PixiSpriteRenderer {
|
|
15
|
+
private sprite;
|
|
16
|
+
private targetContainer;
|
|
17
|
+
private pixiSprite;
|
|
18
|
+
private texture;
|
|
19
|
+
private canvas;
|
|
20
|
+
private context;
|
|
21
|
+
private root;
|
|
22
|
+
private strokeGraphics;
|
|
23
|
+
private maskGraphics;
|
|
24
|
+
private shadowGraphics;
|
|
25
|
+
private shadowContainer;
|
|
26
|
+
private resolution;
|
|
27
|
+
private destroyed;
|
|
28
|
+
constructor(_pixiApp: Application | null, sprite: IClip, targetContainer?: Container | null);
|
|
29
|
+
/**
|
|
30
|
+
* Update the sprite with a new video frame or Texture
|
|
31
|
+
* @param frame ImageBitmap, Texture, or null to render
|
|
32
|
+
* (VideoFrames are converted to ImageBitmap in getFrame)
|
|
33
|
+
*/
|
|
34
|
+
updateFrame(frame: ImageBitmap | Texture | null): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Apply sprite transformations to the Pixi Sprite
|
|
37
|
+
*/
|
|
38
|
+
private applySpriteTransforms;
|
|
39
|
+
/**
|
|
40
|
+
* Apply all styles (stroke, borderRadius, dropShadow) to the sprite
|
|
41
|
+
*/
|
|
42
|
+
private applyStyle;
|
|
43
|
+
private applyStroke;
|
|
44
|
+
private applyShadow;
|
|
45
|
+
updateTransforms(): void;
|
|
46
|
+
getSprite(): Sprite | null;
|
|
47
|
+
getRoot(): Container | null;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Difference } from 'microdiff';
|
|
2
|
+
import { ClipJSON, ProjectJSON, StudioTrackJSON } from '../json-serialization';
|
|
3
|
+
export interface HistoryOptions {
|
|
4
|
+
maxSize?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface HistoryState {
|
|
7
|
+
clips: Record<string, ClipJSON>;
|
|
8
|
+
tracks: StudioTrackJSON[];
|
|
9
|
+
settings: any;
|
|
10
|
+
}
|
|
11
|
+
export declare class HistoryManager {
|
|
12
|
+
private past;
|
|
13
|
+
private future;
|
|
14
|
+
private lastState;
|
|
15
|
+
private maxSize;
|
|
16
|
+
constructor(options?: HistoryOptions);
|
|
17
|
+
private projectToHistoryState;
|
|
18
|
+
/**
|
|
19
|
+
* Initialize history with the starting state
|
|
20
|
+
*/
|
|
21
|
+
init(state: ProjectJSON): void;
|
|
22
|
+
/**
|
|
23
|
+
* Push a new state to history. Calculates the diff from the last state.
|
|
24
|
+
*/
|
|
25
|
+
push(newState: ProjectJSON): void;
|
|
26
|
+
/**
|
|
27
|
+
* Undo the last action. Returns the patches and the new target state.
|
|
28
|
+
*/
|
|
29
|
+
undo(currentState: ProjectJSON): {
|
|
30
|
+
patches: Difference[];
|
|
31
|
+
state: HistoryState;
|
|
32
|
+
} | null;
|
|
33
|
+
/**
|
|
34
|
+
* Redo the next action. Returns the patches and the new target state.
|
|
35
|
+
*/
|
|
36
|
+
redo(currentState: ProjectJSON): {
|
|
37
|
+
patches: Difference[];
|
|
38
|
+
state: HistoryState;
|
|
39
|
+
} | null;
|
|
40
|
+
/**
|
|
41
|
+
* Apply patches to an object.
|
|
42
|
+
*/
|
|
43
|
+
private applyPatches;
|
|
44
|
+
canUndo(): boolean;
|
|
45
|
+
canRedo(): boolean;
|
|
46
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { file } from 'opfs-tools';
|
|
2
|
+
export declare enum ResourceStatus {
|
|
3
|
+
PENDING = "pending",
|
|
4
|
+
LOADING = "loading",
|
|
5
|
+
COMPLETED = "completed",
|
|
6
|
+
FAILED = "failed"
|
|
7
|
+
}
|
|
8
|
+
export interface ResourceItem {
|
|
9
|
+
url: string;
|
|
10
|
+
status: ResourceStatus;
|
|
11
|
+
localFile?: ReturnType<typeof file>;
|
|
12
|
+
error?: Error;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* ResourceManager handles asset preloading and caching in OPFS.
|
|
16
|
+
* It ensures that resources are downloaded only once and reused across sessions.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ResourceManager {
|
|
19
|
+
private resources;
|
|
20
|
+
private loadingPromises;
|
|
21
|
+
/**
|
|
22
|
+
* Preload a batch of URLs in parallel.
|
|
23
|
+
* @param urls Array of URLs to preload
|
|
24
|
+
*/
|
|
25
|
+
preload(urls: string[]): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a ReadableStream for the given URL, with transparent caching.
|
|
28
|
+
* @param url URL to fetch
|
|
29
|
+
*/
|
|
30
|
+
static getReadableStream(url: string): Promise<ReadableStream<Uint8Array>>;
|
|
31
|
+
/**
|
|
32
|
+
* Get an ImageBitmap for the given URL, with transparent caching.
|
|
33
|
+
*/
|
|
34
|
+
static getImageBitmap(url: string): Promise<ImageBitmap>;
|
|
35
|
+
/**
|
|
36
|
+
* Load a single resource, using cache if available.
|
|
37
|
+
* @param url URL to load
|
|
38
|
+
*/
|
|
39
|
+
loadResource(url: string): Promise<ResourceItem>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a URL to its local OPFS file if available.
|
|
42
|
+
* @param url URL to resolve
|
|
43
|
+
*/
|
|
44
|
+
resolve(url: string): Promise<ReturnType<typeof file> | string>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the status of a specific resource.
|
|
47
|
+
*/
|
|
48
|
+
getStatus(url: string): ResourceItem | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Clear instance state (not OPFS cache).
|
|
51
|
+
*/
|
|
52
|
+
clear(): void;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|