@video-editor/shared 0.0.1-beta.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/README.md +3 -0
- package/dist/index.d.ts +263 -0
- package/dist/videoEditorShared.js +46 -0
- package/package.json +25 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
declare interface AudioSegment<T extends ITrackType> extends ISegment<T> {
|
|
2
|
+
segmentType: T;
|
|
3
|
+
url: string;
|
|
4
|
+
fromTime?: number;
|
|
5
|
+
volume?: number;
|
|
6
|
+
fadeInDuration?: number;
|
|
7
|
+
fadeOutDuration?: number;
|
|
8
|
+
playRate?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Protocol version constant
|
|
13
|
+
*/
|
|
14
|
+
export declare const CURRENT_PROTOCOL_VERSION: "1.0.0";
|
|
15
|
+
|
|
16
|
+
declare interface EffectSegment<T extends ITrackType> extends ISegment<T> {
|
|
17
|
+
segmentType: T;
|
|
18
|
+
effectId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare interface FilterSegment<T extends ITrackType> extends ISegment<T> {
|
|
23
|
+
segmentType: T;
|
|
24
|
+
filterId: string;
|
|
25
|
+
name: string;
|
|
26
|
+
intensity?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get segment duration in milliseconds
|
|
31
|
+
*/
|
|
32
|
+
export declare function getSegmentDuration(segment: SegmentUnion): number;
|
|
33
|
+
|
|
34
|
+
export declare interface I3DFramesSegment extends IFramesSegment {
|
|
35
|
+
type: '3D';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export declare interface IAnimation {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
duration: number;
|
|
42
|
+
type: 'in' | 'out' | 'combo';
|
|
43
|
+
url?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare type IAudioSegment = AudioSegment<'audio'>;
|
|
47
|
+
|
|
48
|
+
export declare interface IBackground {
|
|
49
|
+
color?: string;
|
|
50
|
+
opacity?: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare interface IDropShadow {
|
|
54
|
+
color?: string;
|
|
55
|
+
opacity?: number;
|
|
56
|
+
blur?: number;
|
|
57
|
+
distance?: number;
|
|
58
|
+
angle?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare type IEffectSegment = EffectSegment<'effect'>;
|
|
62
|
+
|
|
63
|
+
export declare type IFillMode = 'none' | 'contain' | 'cover' | 'stretch';
|
|
64
|
+
|
|
65
|
+
export declare type IFilterSegment = FilterSegment<'filter'>;
|
|
66
|
+
|
|
67
|
+
declare interface IFramesSegment extends ISegment<'frames'> {
|
|
68
|
+
type: 'image' | 'video' | '3D';
|
|
69
|
+
url: string;
|
|
70
|
+
transform?: ITransform;
|
|
71
|
+
opacity?: number;
|
|
72
|
+
fillMode?: IFillMode;
|
|
73
|
+
animation?: IAnimation;
|
|
74
|
+
transitionIn?: ITransition;
|
|
75
|
+
transitionOut?: ITransition;
|
|
76
|
+
palette?: IPalette;
|
|
77
|
+
background?: `rgba(${number},${number},${number},${number})`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export declare type IFramesSegmentUnion = IVideoFramesSegment | IImageFramesSegment | I3DFramesSegment;
|
|
81
|
+
|
|
82
|
+
export declare interface IImageFramesSegment extends IFramesSegment {
|
|
83
|
+
type: 'image';
|
|
84
|
+
format: 'img' | 'gif';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare type IImageSegment = ImageSegment<'image'>;
|
|
88
|
+
|
|
89
|
+
declare interface ImageSegment<T extends ITrackType> extends ISegment<T> {
|
|
90
|
+
segmentType: T;
|
|
91
|
+
format: 'img' | 'gif';
|
|
92
|
+
url: string;
|
|
93
|
+
fillMode?: IFillMode;
|
|
94
|
+
animation?: IAnimation;
|
|
95
|
+
transform?: ITransform;
|
|
96
|
+
palette?: IPalette;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export declare interface IPalette {
|
|
100
|
+
temperature: number;
|
|
101
|
+
hue: number;
|
|
102
|
+
saturation: number;
|
|
103
|
+
brightness: number;
|
|
104
|
+
contrast: number;
|
|
105
|
+
shine: number;
|
|
106
|
+
highlight: number;
|
|
107
|
+
shadow: number;
|
|
108
|
+
sharpness: number;
|
|
109
|
+
vignette: number;
|
|
110
|
+
fade: number;
|
|
111
|
+
grain: number;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Type guard: check if segment is audio segment
|
|
116
|
+
*/
|
|
117
|
+
export declare function isAudioSegment(segment: SegmentUnion): segment is IAudioSegment;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Type guard: check if segment is effect segment
|
|
121
|
+
*/
|
|
122
|
+
export declare function isEffectSegment(segment: SegmentUnion): segment is IEffectSegment;
|
|
123
|
+
|
|
124
|
+
export declare interface ISegment<T extends ITrackType> {
|
|
125
|
+
id: string;
|
|
126
|
+
startTime: number;
|
|
127
|
+
endTime: number;
|
|
128
|
+
segmentType: T;
|
|
129
|
+
url?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Type guard: check if segment is filter segment
|
|
134
|
+
*/
|
|
135
|
+
export declare function isFilterSegment(segment: SegmentUnion): segment is IFilterSegment;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Type guard: check if segment is frames segment
|
|
139
|
+
*/
|
|
140
|
+
export declare function isFramesSegment(segment: SegmentUnion): segment is IFramesSegmentUnion;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Type guard: check if segment is image segment
|
|
144
|
+
*/
|
|
145
|
+
export declare function isImageSegment(segment: SegmentUnion): segment is IImageSegment;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Type guard: check if segment is text segment
|
|
149
|
+
*/
|
|
150
|
+
export declare function isTextSegment(segment: SegmentUnion): segment is ITextSegment;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Check if a time point is within a segment's time range
|
|
154
|
+
*/
|
|
155
|
+
export declare function isTimeInSegment(time: number, segment: SegmentUnion): boolean;
|
|
156
|
+
|
|
157
|
+
export declare interface IStroke {
|
|
158
|
+
color?: string;
|
|
159
|
+
width?: number;
|
|
160
|
+
opacity?: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Check if a string is a valid track type
|
|
165
|
+
*/
|
|
166
|
+
export declare function isValidTrackType(type: string): type is ITrackType;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Type guard: check if segment is video frames segment
|
|
170
|
+
*/
|
|
171
|
+
export declare function isVideoFramesSegment(segment: SegmentUnion): segment is IVideoFramesSegment;
|
|
172
|
+
|
|
173
|
+
export declare interface ITextBasic {
|
|
174
|
+
content: string;
|
|
175
|
+
align?: 'left' | 'center' | 'right' | 'justify';
|
|
176
|
+
dropShadow?: IDropShadow;
|
|
177
|
+
fontFamily?: string | string[];
|
|
178
|
+
fontSize?: number;
|
|
179
|
+
fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
180
|
+
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
181
|
+
underline?: boolean;
|
|
182
|
+
fill?: string;
|
|
183
|
+
letterSpacing?: number;
|
|
184
|
+
leading?: number;
|
|
185
|
+
stroke?: IStroke;
|
|
186
|
+
background?: IBackground;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export declare type ITextSegment = TextSegment<'text'>;
|
|
190
|
+
|
|
191
|
+
export declare type ITrack<T extends ITrackType> = {
|
|
192
|
+
trackId: string;
|
|
193
|
+
trackType: T;
|
|
194
|
+
children: TrackTypeMapSegment[T][];
|
|
195
|
+
} & (T extends 'frames' ? {
|
|
196
|
+
isMain?: boolean;
|
|
197
|
+
} : object);
|
|
198
|
+
|
|
199
|
+
export declare type ITrackType = keyof TrackTypeMapSegment;
|
|
200
|
+
|
|
201
|
+
export declare interface ITransform {
|
|
202
|
+
position: [number, number, number];
|
|
203
|
+
rotation: [number, number, number];
|
|
204
|
+
scale: [number, number, number];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export declare interface ITransition {
|
|
208
|
+
id: string;
|
|
209
|
+
name: string;
|
|
210
|
+
duration: number;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export declare interface IVideoFramesSegment extends IFramesSegment {
|
|
214
|
+
type: 'video';
|
|
215
|
+
fromTime?: number;
|
|
216
|
+
volume?: number;
|
|
217
|
+
playRate?: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* NOTE: that without special explanation:
|
|
222
|
+
* the time related value is in ms
|
|
223
|
+
* the numerical value is normalized in range [0, 1] unless otherwise specified
|
|
224
|
+
*/
|
|
225
|
+
export declare interface IVideoProtocol {
|
|
226
|
+
version: `${number}.${number}.${number}`;
|
|
227
|
+
width: number;
|
|
228
|
+
height: number;
|
|
229
|
+
fps: number;
|
|
230
|
+
tracks: TrackUnion[];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export declare type SegmentUnion = TrackTypeMapSegment[ITrackType];
|
|
234
|
+
|
|
235
|
+
declare interface TextSegment<T extends ITrackType> extends ISegment<T> {
|
|
236
|
+
segmentType: T;
|
|
237
|
+
texts: ITextBasic[];
|
|
238
|
+
transform?: ITransform;
|
|
239
|
+
opacity?: number;
|
|
240
|
+
animation?: IAnimation;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Track type constants
|
|
245
|
+
*/
|
|
246
|
+
export declare const TRACK_TYPES: readonly ITrackType[];
|
|
247
|
+
|
|
248
|
+
export declare interface TrackTypeMapSegment {
|
|
249
|
+
frames: IFramesSegmentUnion;
|
|
250
|
+
text: TextSegment<'text'>;
|
|
251
|
+
image: ImageSegment<'image'>;
|
|
252
|
+
audio: AudioSegment<'audio'>;
|
|
253
|
+
effect: EffectSegment<'effect'>;
|
|
254
|
+
filter: FilterSegment<'filter'>;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export declare type TrackTypeMapTrack = {
|
|
258
|
+
[Key in ITrackType]: ITrack<Key>;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export declare type TrackUnion = TrackTypeMapTrack[ITrackType];
|
|
262
|
+
|
|
263
|
+
export { }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const i = "1.0.0";
|
|
2
|
+
function r(e) {
|
|
3
|
+
return e.segmentType === "frames";
|
|
4
|
+
}
|
|
5
|
+
function u(e) {
|
|
6
|
+
return e.segmentType === "frames" && "type" in e && e.type === "video";
|
|
7
|
+
}
|
|
8
|
+
function m(e) {
|
|
9
|
+
return e.segmentType === "text";
|
|
10
|
+
}
|
|
11
|
+
function s(e) {
|
|
12
|
+
return e.segmentType === "image";
|
|
13
|
+
}
|
|
14
|
+
function f(e) {
|
|
15
|
+
return e.segmentType === "audio";
|
|
16
|
+
}
|
|
17
|
+
function o(e) {
|
|
18
|
+
return e.segmentType === "effect";
|
|
19
|
+
}
|
|
20
|
+
function T(e) {
|
|
21
|
+
return e.segmentType === "filter";
|
|
22
|
+
}
|
|
23
|
+
function c(e) {
|
|
24
|
+
return e.endTime - e.startTime;
|
|
25
|
+
}
|
|
26
|
+
function g(e, t) {
|
|
27
|
+
return e >= t.startTime && e < t.endTime;
|
|
28
|
+
}
|
|
29
|
+
const n = ["frames", "text", "image", "audio", "effect", "filter"];
|
|
30
|
+
function a(e) {
|
|
31
|
+
return n.includes(e);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
i as CURRENT_PROTOCOL_VERSION,
|
|
35
|
+
n as TRACK_TYPES,
|
|
36
|
+
c as getSegmentDuration,
|
|
37
|
+
f as isAudioSegment,
|
|
38
|
+
o as isEffectSegment,
|
|
39
|
+
T as isFilterSegment,
|
|
40
|
+
r as isFramesSegment,
|
|
41
|
+
s as isImageSegment,
|
|
42
|
+
m as isTextSegment,
|
|
43
|
+
g as isTimeInSegment,
|
|
44
|
+
a as isValidTrackType,
|
|
45
|
+
u as isVideoFramesSegment
|
|
46
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@video-editor/shared",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1-beta.1",
|
|
5
|
+
"description": "video editor shared libs",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"module": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "vite build --config vite.config.ts"
|
|
24
|
+
}
|
|
25
|
+
}
|