@video-editor/protocol 0.0.1-beta.2 → 0.0.1-beta.21
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/dist/index.d.ts +121 -20
- package/dist/index.js +7605 -7825
- package/package.json +9 -4
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { IEffectSegment } from '@video-editor/shared';
|
|
|
6
6
|
import { IFillMode } from '@video-editor/shared';
|
|
7
7
|
import { IFilterSegment } from '@video-editor/shared';
|
|
8
8
|
import { IFramesSegmentUnion } from '@video-editor/shared';
|
|
9
|
-
import { IImageSegment } from '@video-editor/shared';
|
|
10
9
|
import { ISamples } from './fetch';
|
|
10
|
+
import { IStickerSegment } from '@video-editor/shared';
|
|
11
11
|
import { ITextSegment } from '@video-editor/shared';
|
|
12
12
|
import { ITrackType } from '@video-editor/shared';
|
|
13
13
|
import { ITransition } from '@video-editor/shared';
|
|
@@ -23,7 +23,9 @@ import { TrackUnion } from '@video-editor/shared';
|
|
|
23
23
|
export declare function createResourceManager(opts?: {
|
|
24
24
|
dir?: string;
|
|
25
25
|
}): {
|
|
26
|
-
add: (url: string
|
|
26
|
+
add: (url: string, opts?: {
|
|
27
|
+
body?: ReadableStream<BufferSource>;
|
|
28
|
+
}) => Promise<void>;
|
|
27
29
|
get: (url: string) => Promise<void | HTMLImageElement | ISamples[]>;
|
|
28
30
|
remove: (url: string) => Promise<void>;
|
|
29
31
|
clear: () => Promise<void>;
|
|
@@ -36,7 +38,7 @@ export declare function createValidator(): {
|
|
|
36
38
|
};
|
|
37
39
|
verifyFramesSegment: (o: object) => IFramesSegmentUnion;
|
|
38
40
|
verifyTextSegment: (o: object) => ITextSegment;
|
|
39
|
-
|
|
41
|
+
verifyStickerSegment: (o: object) => IStickerSegment;
|
|
40
42
|
verifyAudioSegment: (o: object) => IAudioSegment;
|
|
41
43
|
verifyEffectSegment: (o: object) => IEffectSegment;
|
|
42
44
|
verifyFilterSegment: (o: object) => IFilterSegment;
|
|
@@ -45,10 +47,15 @@ export declare function createValidator(): {
|
|
|
45
47
|
};
|
|
46
48
|
verifySegment: (o: object & {
|
|
47
49
|
segmentType: ITrackType;
|
|
48
|
-
}) => IFramesSegmentUnion | IAudioSegment | IEffectSegment | IFilterSegment |
|
|
50
|
+
}) => IFramesSegmentUnion | IAudioSegment | IEffectSegment | IFilterSegment | IStickerSegment | ITextSegment;
|
|
49
51
|
};
|
|
50
52
|
|
|
51
|
-
export declare function createVideoProtocolManager(protocol: IVideoProtocol
|
|
53
|
+
export declare function createVideoProtocolManager(protocol: IVideoProtocol, options?: {
|
|
54
|
+
idFactory?: {
|
|
55
|
+
segment?: () => string;
|
|
56
|
+
track?: () => string;
|
|
57
|
+
};
|
|
58
|
+
}): {
|
|
52
59
|
videoBasicInfo: {
|
|
53
60
|
version: `${number}.${number}.${number}`;
|
|
54
61
|
width: number;
|
|
@@ -112,7 +119,7 @@ export declare function createVideoProtocolManager(protocol: IVideoProtocol): {
|
|
|
112
119
|
readonly endTime: number;
|
|
113
120
|
readonly segmentType: "frames";
|
|
114
121
|
readonly extra?: {
|
|
115
|
-
readonly [x: string]:
|
|
122
|
+
readonly [x: string]: never;
|
|
116
123
|
} | null | undefined;
|
|
117
124
|
} | {
|
|
118
125
|
readonly type: "image";
|
|
@@ -162,7 +169,7 @@ export declare function createVideoProtocolManager(protocol: IVideoProtocol): {
|
|
|
162
169
|
readonly endTime: number;
|
|
163
170
|
readonly segmentType: "frames";
|
|
164
171
|
readonly extra?: {
|
|
165
|
-
readonly [x: string]:
|
|
172
|
+
readonly [x: string]: never;
|
|
166
173
|
} | null | undefined;
|
|
167
174
|
} | {
|
|
168
175
|
readonly type: "3D";
|
|
@@ -211,9 +218,12 @@ export declare function createVideoProtocolManager(protocol: IVideoProtocol): {
|
|
|
211
218
|
readonly endTime: number;
|
|
212
219
|
readonly segmentType: "frames";
|
|
213
220
|
readonly extra?: {
|
|
214
|
-
readonly [x: string]:
|
|
221
|
+
readonly [x: string]: never;
|
|
215
222
|
} | null | undefined;
|
|
216
223
|
})[];
|
|
224
|
+
readonly extra?: {
|
|
225
|
+
readonly [x: string]: never;
|
|
226
|
+
} | null | undefined;
|
|
217
227
|
readonly isMain?: boolean | undefined;
|
|
218
228
|
}[];
|
|
219
229
|
text: readonly {
|
|
@@ -267,15 +277,18 @@ export declare function createVideoProtocolManager(protocol: IVideoProtocol): {
|
|
|
267
277
|
readonly endTime: number;
|
|
268
278
|
readonly url?: string | undefined;
|
|
269
279
|
readonly extra?: {
|
|
270
|
-
readonly [x: string]:
|
|
280
|
+
readonly [x: string]: never;
|
|
271
281
|
} | null | undefined;
|
|
272
282
|
}[];
|
|
283
|
+
readonly extra?: {
|
|
284
|
+
readonly [x: string]: never;
|
|
285
|
+
} | null | undefined;
|
|
273
286
|
}[];
|
|
274
|
-
|
|
287
|
+
sticker: readonly {
|
|
275
288
|
readonly trackId: string;
|
|
276
|
-
readonly trackType: "
|
|
289
|
+
readonly trackType: "sticker";
|
|
277
290
|
readonly children: readonly {
|
|
278
|
-
readonly segmentType: "
|
|
291
|
+
readonly segmentType: "sticker";
|
|
279
292
|
readonly format: "img" | "gif";
|
|
280
293
|
readonly url: string;
|
|
281
294
|
readonly fillMode?: IFillMode | undefined;
|
|
@@ -309,9 +322,12 @@ export declare function createVideoProtocolManager(protocol: IVideoProtocol): {
|
|
|
309
322
|
readonly startTime: number;
|
|
310
323
|
readonly endTime: number;
|
|
311
324
|
readonly extra?: {
|
|
312
|
-
readonly [x: string]:
|
|
325
|
+
readonly [x: string]: never;
|
|
313
326
|
} | null | undefined;
|
|
314
327
|
}[];
|
|
328
|
+
readonly extra?: {
|
|
329
|
+
readonly [x: string]: never;
|
|
330
|
+
} | null | undefined;
|
|
315
331
|
}[];
|
|
316
332
|
audio: readonly {
|
|
317
333
|
readonly trackId: string;
|
|
@@ -328,9 +344,12 @@ export declare function createVideoProtocolManager(protocol: IVideoProtocol): {
|
|
|
328
344
|
readonly startTime: number;
|
|
329
345
|
readonly endTime: number;
|
|
330
346
|
readonly extra?: {
|
|
331
|
-
readonly [x: string]:
|
|
347
|
+
readonly [x: string]: never;
|
|
332
348
|
} | null | undefined;
|
|
333
349
|
}[];
|
|
350
|
+
readonly extra?: {
|
|
351
|
+
readonly [x: string]: never;
|
|
352
|
+
} | null | undefined;
|
|
334
353
|
}[];
|
|
335
354
|
effect: readonly {
|
|
336
355
|
readonly trackId: string;
|
|
@@ -344,9 +363,12 @@ export declare function createVideoProtocolManager(protocol: IVideoProtocol): {
|
|
|
344
363
|
readonly endTime: number;
|
|
345
364
|
readonly url?: string | undefined;
|
|
346
365
|
readonly extra?: {
|
|
347
|
-
readonly [x: string]:
|
|
366
|
+
readonly [x: string]: never;
|
|
348
367
|
} | null | undefined;
|
|
349
368
|
}[];
|
|
369
|
+
readonly extra?: {
|
|
370
|
+
readonly [x: string]: never;
|
|
371
|
+
} | null | undefined;
|
|
350
372
|
}[];
|
|
351
373
|
filter: readonly {
|
|
352
374
|
readonly trackId: string;
|
|
@@ -361,22 +383,81 @@ export declare function createVideoProtocolManager(protocol: IVideoProtocol): {
|
|
|
361
383
|
readonly endTime: number;
|
|
362
384
|
readonly url?: string | undefined;
|
|
363
385
|
readonly extra?: {
|
|
364
|
-
readonly [x: string]:
|
|
386
|
+
readonly [x: string]: never;
|
|
365
387
|
} | null | undefined;
|
|
366
388
|
}[];
|
|
389
|
+
readonly extra?: {
|
|
390
|
+
readonly [x: string]: never;
|
|
391
|
+
} | null | undefined;
|
|
367
392
|
}[];
|
|
368
393
|
}>;
|
|
369
394
|
segmentMap: ComputedRef<Record<string, DeepReadonly<SegmentUnion | undefined>>>;
|
|
395
|
+
protocol: ComputedRef<IVideoProtocol>;
|
|
370
396
|
getSegment: <T extends ITrackType>(id: SegmentUnion["id"], type?: T) => DeepReadonly<TrackTypeMapSegment[T]> | undefined;
|
|
371
|
-
addSegment: (segment: PartialByKeys<TrackTypeMapSegment[ITrackType], "id"
|
|
372
|
-
|
|
397
|
+
addSegment: (segment: PartialByKeys<TrackTypeMapSegment[ITrackType], "id">, trackId?: string) => {
|
|
398
|
+
id: string;
|
|
399
|
+
affectedSegments: SegmentUnion[];
|
|
400
|
+
affectedTracks: TrackUnion[];
|
|
401
|
+
createdTracks: TrackUnion[];
|
|
402
|
+
removedTrackIds: string[];
|
|
403
|
+
};
|
|
404
|
+
removeSegment: (id: SegmentUnion["id"]) => {
|
|
405
|
+
success: boolean;
|
|
406
|
+
affectedSegments: SegmentUnion[];
|
|
407
|
+
affectedTracks: TrackUnion[];
|
|
408
|
+
createdTracks: TrackUnion[];
|
|
409
|
+
removedTrackIds: string[];
|
|
410
|
+
};
|
|
373
411
|
updateSegment: <T extends ITrackType>(updater: (segment: TrackTypeMapSegment[T]) => void, id?: string, type?: T) => void;
|
|
412
|
+
moveSegment: (moveOptions: {
|
|
413
|
+
segmentId: string;
|
|
414
|
+
sourceTrackId: string;
|
|
415
|
+
targetTrackId?: string;
|
|
416
|
+
startTime: number;
|
|
417
|
+
endTime: number;
|
|
418
|
+
isNewTrack?: boolean;
|
|
419
|
+
newTrackInsertIndex?: number;
|
|
420
|
+
newTrackId?: string;
|
|
421
|
+
}) => {
|
|
422
|
+
success: boolean;
|
|
423
|
+
affectedSegments: SegmentUnion[];
|
|
424
|
+
affectedTracks: TrackUnion[];
|
|
425
|
+
createdTracks: TrackUnion[];
|
|
426
|
+
removedTrackIds: string[];
|
|
427
|
+
};
|
|
428
|
+
resizeSegment: (options: {
|
|
429
|
+
segmentId: string;
|
|
430
|
+
trackId: string;
|
|
431
|
+
startTime: number;
|
|
432
|
+
endTime: number;
|
|
433
|
+
}) => {
|
|
434
|
+
success: boolean;
|
|
435
|
+
affectedSegments: SegmentUnion[];
|
|
436
|
+
affectedTracks: TrackUnion[];
|
|
437
|
+
createdTracks: TrackUnion[];
|
|
438
|
+
removedTrackIds: string[];
|
|
439
|
+
};
|
|
374
440
|
exportProtocol: () => IVideoProtocol;
|
|
375
441
|
addTransition: (transition: ITransition, addTime?: number) => boolean;
|
|
376
442
|
removeTransition: (segmentId: string) => boolean;
|
|
377
443
|
updateTransition: (segmentId: string, updater: (transition: ITransition) => void) => boolean;
|
|
378
|
-
|
|
379
|
-
|
|
444
|
+
replaceTrackId: (oldTrackId: string, newTrackId: string) => boolean;
|
|
445
|
+
undo: () => {
|
|
446
|
+
success: boolean;
|
|
447
|
+
affectedSegments: SegmentUnion[];
|
|
448
|
+
affectedTracks: TrackUnion[];
|
|
449
|
+
createdTracks: TrackUnion[];
|
|
450
|
+
removedTrackIds: string[];
|
|
451
|
+
removedSegmentIds: string[];
|
|
452
|
+
};
|
|
453
|
+
redo: () => {
|
|
454
|
+
success: boolean;
|
|
455
|
+
affectedSegments: SegmentUnion[];
|
|
456
|
+
affectedTracks: TrackUnion[];
|
|
457
|
+
createdTracks: TrackUnion[];
|
|
458
|
+
removedTrackIds: string[];
|
|
459
|
+
removedSegmentIds: string[];
|
|
460
|
+
};
|
|
380
461
|
redoCount: ComputedRef<number>;
|
|
381
462
|
undoCount: ComputedRef<number>;
|
|
382
463
|
};
|
|
@@ -421,6 +502,17 @@ declare interface GenerateThumbnailsOptions {
|
|
|
421
502
|
resourceDir?: string;
|
|
422
503
|
}
|
|
423
504
|
|
|
505
|
+
export declare function getMp4Meta(url: string, options?: {
|
|
506
|
+
resourceDir?: string;
|
|
507
|
+
}): Promise<Mp4Meta>;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Convert a user-provided URL into a stable, OPFS-safe key.
|
|
511
|
+
* - Removes query/hash so signed URLs map to a single cached entry.
|
|
512
|
+
* - Avoids `://` and other path-unfriendly sequences by encoding segments.
|
|
513
|
+
*/
|
|
514
|
+
export declare function getResourceKey(url: string): string;
|
|
515
|
+
|
|
424
516
|
export declare function getResourceType(url: string): Promise<{
|
|
425
517
|
type: IResType;
|
|
426
518
|
totalSize: number;
|
|
@@ -446,6 +538,15 @@ export { ITrackType }
|
|
|
446
538
|
|
|
447
539
|
export { IVideoProtocol }
|
|
448
540
|
|
|
541
|
+
declare interface Mp4Meta {
|
|
542
|
+
durationUs: number;
|
|
543
|
+
durationMs: number;
|
|
544
|
+
width: number;
|
|
545
|
+
height: number;
|
|
546
|
+
audioSampleRate: number;
|
|
547
|
+
audioChanCount: number;
|
|
548
|
+
}
|
|
549
|
+
|
|
449
550
|
declare type OPFSToolFile = ReturnType<typeof file>;
|
|
450
551
|
|
|
451
552
|
export declare const parse: parseFn;
|