libpag 4.5.1 → 4.5.2

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.
Files changed (80) hide show
  1. package/LICENSE.txt +1589 -0
  2. package/README.md +172 -10
  3. package/README.zh_CN.md +114 -15
  4. package/lib/libpag.cjs.js +5418 -6177
  5. package/lib/libpag.cjs.js.map +1 -1
  6. package/lib/libpag.esm.js +5418 -6177
  7. package/lib/libpag.esm.js.map +1 -1
  8. package/lib/libpag.min.js +1 -1
  9. package/lib/libpag.min.js.map +1 -1
  10. package/lib/libpag.umd.js +5418 -6177
  11. package/lib/libpag.umd.js.map +1 -1
  12. package/lib/libpag.wasm +0 -0
  13. package/package.json +23 -11
  14. package/src/.pag.wasm-mt.md5 +1 -0
  15. package/src/.pag.wasm.md5 +1 -1
  16. package/src/core/matrix.ts +1 -2
  17. package/src/core/video-reader.ts +73 -94
  18. package/src/interfaces.ts +8 -17
  19. package/src/pag-composition.ts +12 -5
  20. package/src/pag-file.ts +146 -129
  21. package/src/pag-font.ts +1 -3
  22. package/src/pag-image-layer.ts +1 -2
  23. package/src/pag-image.ts +1 -3
  24. package/src/pag-layer.ts +2 -3
  25. package/src/pag-player.ts +7 -6
  26. package/src/pag-solid-layer.ts +1 -2
  27. package/src/pag-surface.ts +1 -2
  28. package/src/pag-text-layer.ts +1 -2
  29. package/src/pag-view.ts +3 -14
  30. package/src/pag.ts +0 -6
  31. package/src/types.ts +46 -3
  32. package/src/utils/decorators.ts +0 -42
  33. package/src/utils/type-utils.ts +1 -9
  34. package/src/utils/ua.ts +0 -1
  35. package/src/wasm/libpag.js +7 -6
  36. package/src/wasm/libpag.wasm +0 -0
  37. package/src/wasm-mt/libpag.js +2 -18
  38. package/src/wasm-mt/libpag.wasm +0 -0
  39. package/src/wechat/pag-file.ts +1 -2
  40. package/src/wechat/pag-image.ts +0 -2
  41. package/src/wechat/pag-view.ts +1 -2
  42. package/types/third_party/tgfx/web/src/core/path-rasterizer.d.ts +4 -0
  43. package/types/third_party/tgfx/web/src/core/scaler-context.d.ts +9 -2
  44. package/types/third_party/tgfx/web/src/utils/decorators.d.ts +0 -2
  45. package/types/web/src/core/video-reader.d.ts +4 -3
  46. package/types/web/src/interfaces.d.ts +8 -15
  47. package/types/web/src/pag-composition.d.ts +3 -3
  48. package/types/web/src/pag-file.d.ts +4 -4
  49. package/types/web/src/pag-player.d.ts +2 -2
  50. package/types/web/src/pag-view.d.ts +1 -1
  51. package/types/web/src/types.d.ts +12 -3
  52. package/types/web/src/utils/decorators.d.ts +0 -2
  53. package/types/web/src/utils/ua.d.ts +0 -1
  54. package/types/web/tsconfig.json +19 -0
  55. package/lib/libpag.worker.cjs.js +0 -798
  56. package/lib/libpag.worker.cjs.js.map +0 -1
  57. package/lib/libpag.worker.esm.js +0 -793
  58. package/lib/libpag.worker.esm.js.map +0 -1
  59. package/lib/libpag.worker.js +0 -804
  60. package/lib/libpag.worker.js.map +0 -1
  61. package/lib/libpag.worker.min.js +0 -2
  62. package/lib/libpag.worker.min.js.map +0 -1
  63. package/src/worker/client.ts +0 -80
  64. package/src/worker/events.ts +0 -41
  65. package/src/worker/pag-file.ts +0 -90
  66. package/src/worker/pag-image.ts +0 -43
  67. package/src/worker/pag-view.ts +0 -171
  68. package/src/worker/utils.ts +0 -29
  69. package/src/worker/video-reader.ts +0 -62
  70. package/src/worker/worker.ts +0 -169
  71. package/types/third_party/tgfx/web/src/core/web-mask.d.ts +0 -26
  72. package/types/web/src/utils/canvas.d.ts +0 -4
  73. package/types/web/src/worker/client.d.ts +0 -16
  74. package/types/web/src/worker/events.d.ts +0 -32
  75. package/types/web/src/worker/pag-file.d.ts +0 -33
  76. package/types/web/src/worker/pag-image.d.ts +0 -8
  77. package/types/web/src/worker/pag-view.d.ts +0 -67
  78. package/types/web/src/worker/utils.d.ts +0 -7
  79. package/types/web/src/worker/video-reader.d.ts +0 -16
  80. package/types/web/src/worker/worker.d.ts +0 -13
@@ -1,171 +0,0 @@
1
- import { WorkerMessageType } from './events';
2
- import { postMessage } from './utils';
3
- import { destroyVerify } from '../utils/decorators';
4
- import { calculateDisplaySize } from '../utils/canvas';
5
-
6
- import type { WorkerPAGFile } from './pag-file';
7
- import type { PAGViewOptions } from '../pag-view';
8
- import type { DebugData, PAGScaleMode } from '../types';
9
-
10
- @destroyVerify
11
- export class WorkerPAGView {
12
- /**
13
- * Create pag view.
14
- * @param file pag file.
15
- * @param canvas target render canvas.
16
- * @param initOptions pag view options
17
- * @returns
18
- */
19
- public static init(file: WorkerPAGFile, canvas: HTMLCanvasElement, initOptions?: PAGViewOptions) {
20
- const options = {
21
- ...{
22
- useScale: true,
23
- useCanvas2D: false,
24
- firstFrame: true,
25
- },
26
- ...initOptions,
27
- };
28
- if (options.useScale) {
29
- resizeCanvas(canvas);
30
- }
31
- const offscreen = canvas.transferControlToOffscreen();
32
- return postMessage(
33
- file.worker,
34
- { name: WorkerMessageType.PAGView_init, args: [file.key, offscreen, initOptions] },
35
- (key: number) => new WorkerPAGView(file.worker, key),
36
- [offscreen],
37
- );
38
- }
39
-
40
- public key: number;
41
- public worker: Worker;
42
- public isDestroyed = false;
43
-
44
- public constructor(worker: Worker, key: number) {
45
- this.worker = worker;
46
- this.key = key;
47
- }
48
- /**
49
- * The duration of current composition in microseconds.
50
- */
51
- public duration() {
52
- return postMessage(
53
- this.worker,
54
- { name: WorkerMessageType.PAGView_duration, args: [this.key] },
55
- (res: number) => res,
56
- );
57
- }
58
- /**
59
- * Start the animation.
60
- */
61
- public play() {
62
- return postMessage(this.worker, { name: WorkerMessageType.PAGView_play, args: [this.key] }, () => undefined);
63
- }
64
- /**
65
- * Pause the animation.
66
- */
67
- public pause(): Promise<void> {
68
- return postMessage(this.worker, { name: WorkerMessageType.PAGView_pause, args: [this.key] }, () => undefined);
69
- }
70
- /**
71
- * Stop the animation.
72
- */
73
- public stop(): Promise<void> {
74
- return postMessage(this.worker, { name: WorkerMessageType.PAGView_stop, args: [this.key] }, () => undefined);
75
- }
76
- /**
77
- * Set the number of times the animation will repeat. The default is 1, which means the animation
78
- * will play only once. 0 means the animation will play infinity times.
79
- */
80
- public setRepeatCount(repeatCount: number): Promise<void> {
81
- return postMessage(
82
- this.worker,
83
- { name: WorkerMessageType.PAGView_setRepeatCount, args: [this.key, repeatCount] },
84
- () => undefined,
85
- );
86
- }
87
- /**
88
- * Returns the current progress of play position, the value is from 0.0 to 1.0. It is applied only
89
- * when the composition is not null.
90
- */
91
- public getProgress() {
92
- return postMessage(
93
- this.worker,
94
- { name: WorkerMessageType.PAGView_getProgress, args: [this.key] },
95
- (res: number) => res,
96
- );
97
- }
98
- /**
99
- * Returns the current frame.
100
- */
101
- public currentFrame() {
102
- return postMessage(
103
- this.worker,
104
- { name: WorkerMessageType.PAGView_currentFrame, args: [this.key] },
105
- (res: number) => res,
106
- );
107
- }
108
- /**
109
- * Set the progress of play position, the value is from 0.0 to 1.0.
110
- */
111
- public setProgress(progress: number) {
112
- return postMessage(
113
- this.worker,
114
- {
115
- name: WorkerMessageType.PAGView_setProgress,
116
- args: [this.key, progress],
117
- },
118
- () => undefined,
119
- );
120
- }
121
- /**
122
- * Returns the current scale mode.
123
- */
124
- public scaleMode() {
125
- return postMessage(
126
- this.worker,
127
- { name: WorkerMessageType.PAGView_scaleMode, args: [this.key] },
128
- (res: number) => res,
129
- );
130
- }
131
- /**
132
- * Specifies the rule of how to scale the pag content to fit the surface size. The matrix
133
- * changes when this method is called.
134
- */
135
- public setScaleMode(value: PAGScaleMode): Promise<void> {
136
- return postMessage(
137
- this.worker,
138
- { name: WorkerMessageType.PAGView_setScaleMode, args: [this.key, value] },
139
- () => undefined,
140
- );
141
- }
142
- /**
143
- * Call this method to render current position immediately. If the play() method is already
144
- * called, there is no need to call it. Returns true if the content has changed.
145
- */
146
- public flush() {
147
- return postMessage(this.worker, { name: WorkerMessageType.PAGView_flush, args: [this.key] }, (res: boolean) => res);
148
- }
149
-
150
- public getDebugData() {
151
- return postMessage(
152
- this.worker,
153
- { name: WorkerMessageType.PAGView_getDebugData, args: [this.key] },
154
- (res: DebugData) => res,
155
- );
156
- }
157
-
158
- public destroy() {
159
- postMessage(this.worker, { name: WorkerMessageType.PAGView_destroy, args: [this.key] }, () => {
160
- this.isDestroyed = true;
161
- });
162
- }
163
- }
164
-
165
- const resizeCanvas = (canvas: HTMLCanvasElement) => {
166
- const displaySize = calculateDisplaySize(canvas);
167
- canvas.style.width = `${displaySize.width}px`;
168
- canvas.style.height = `${displaySize.height}px`;
169
- canvas.width = displaySize.width * globalThis.devicePixelRatio;
170
- canvas.height = displaySize.height * globalThis.devicePixelRatio;
171
- };
@@ -1,29 +0,0 @@
1
- import type { WorkerMessage } from './worker';
2
-
3
- let messageCount = 0;
4
- const generateMessageName = (name: string) => `${name}_${messageCount++}`;
5
-
6
- export interface WorkerInterface {
7
- postMessage: (message: any, transfer: Transferable[]) => void;
8
- addEventListener: (type: string, listener: (event: MessageEvent) => void) => void;
9
- removeEventListener: (type: string, listener: (event: MessageEvent) => void) => void;
10
- }
11
-
12
- export const postMessage = <T>(
13
- worker: WorkerInterface,
14
- message: WorkerMessage,
15
- callback: (...args: any[]) => T,
16
- transfer: (OffscreenCanvas | Transferable)[] = [],
17
- ): Promise<T> => {
18
- return new Promise((resolve) => {
19
- const name = generateMessageName(message.name);
20
- const handle = (event: MessageEvent<WorkerMessage>) => {
21
- if (event.data.name === name) {
22
- worker.removeEventListener('message', handle);
23
- resolve(callback(...event.data.args));
24
- }
25
- };
26
- worker.addEventListener('message', handle);
27
- worker.postMessage({ name, args: message.args }, transfer);
28
- });
29
- };
@@ -1,62 +0,0 @@
1
- import { WorkerMessageType } from './events';
2
- import { postMessage } from './utils';
3
-
4
- import { BitmapImage } from '@tgfx/core/bitmap-image';
5
-
6
- export class WorkerVideoReader {
7
- public bitmap: ImageBitmap | null = null;
8
- public isSought = false;
9
- public isPlaying = false;
10
-
11
- private proxyId: number;
12
- private bitmapImage: BitmapImage = new BitmapImage(null);
13
-
14
- public constructor(proxyId: number) {
15
- this.proxyId = proxyId;
16
- }
17
-
18
- public prepare(targetFrame: number, playbackRate: number) {
19
- return new Promise<void>((resolve) => {
20
- postMessage(
21
- self,
22
- { name: WorkerMessageType.VideoReader_prepare, args: [this.proxyId, targetFrame, playbackRate] },
23
- (res) => {
24
- this.bitmapImage.setBitmap(res);
25
- resolve();
26
- },
27
- );
28
- });
29
- }
30
-
31
- public getVideo() {
32
- return this.bitmapImage;
33
- }
34
-
35
- public onDestroy() {
36
- self.postMessage({ name: 'VideoReader.onDestroy', args: [this.proxyId] });
37
- }
38
-
39
- public play() {
40
- return new Promise<void>((resolve) => {
41
- postMessage(self, { name: WorkerMessageType.VideoReader_play, args: [this.proxyId] }, () => {
42
- resolve();
43
- });
44
- });
45
- }
46
-
47
- public pause() {
48
- postMessage(self, { name: WorkerMessageType.VideoReader_pause, args: [this.proxyId] }, () => {});
49
- }
50
-
51
- public stop() {
52
- postMessage(self, { name: WorkerMessageType.VideoReader_stop, args: [this.proxyId] }, () => {});
53
- }
54
-
55
- public getError() {
56
- return new Promise<any>((resolve) => {
57
- postMessage(self, { name: WorkerMessageType.VideoReader_getError, args: [this.proxyId] }, (res) => {
58
- resolve(res);
59
- });
60
- });
61
- }
62
- }
@@ -1,169 +0,0 @@
1
- import { WorkerMessageType } from './events';
2
- import * as types from '../types';
3
-
4
- import type { ModuleOption, PAGInit } from '../pag';
5
- import type { PAGFile } from '../pag-file';
6
- import type { PAGView } from '../pag-view';
7
- import type { PAGImage } from '../pag-image';
8
-
9
- declare global {
10
- interface Window {
11
- PAG: types.PAG;
12
- }
13
- }
14
-
15
- export interface WorkerMessage {
16
- name: string;
17
- args: any[];
18
- }
19
- const pagFiles: (PAGFile & { [prop: string]: any })[] = [];
20
- const registerPAGFile = (pagFile: PAGFile) => {
21
- pagFiles.push(pagFile);
22
- return pagFiles.length - 1;
23
- };
24
- const deletePAGFile = (key: number) => {
25
- (pagFiles[key] as any) = null;
26
- };
27
-
28
- const pagViews: (PAGView & { [prop: string]: any })[] = [];
29
- const registerPAGView = (pagView: PAGView) => {
30
- pagViews.push(pagView);
31
- return pagViews.length - 1;
32
- };
33
- const deletePAGView = (key: number) => {
34
- (pagViews[key] as any) = null;
35
- };
36
-
37
- const pagImages: PAGImage[] = [];
38
- const registerPAGImage = (pagImage: PAGImage) => {
39
- pagImages.push(pagImage);
40
- return pagImages.length - 1;
41
- };
42
- const deletePAGImage = (key: number) => {
43
- (pagImages[key] as any) = null;
44
- };
45
-
46
- const textDataMap: (types.TextDocument & { [prop: string]: any })[] = [];
47
- const registerTextData = (textData: types.TextDocument) => {
48
- textDataMap.push(textData);
49
- return textDataMap.length - 1;
50
- };
51
- const deleteTextData = (key: number) => {
52
- (textDataMap[key] as any) = null;
53
- };
54
-
55
- const workerInit = (init: typeof PAGInit) => {
56
- onmessage = async (event: MessageEvent<WorkerMessage>) => {
57
- const messageHandles: { [prop: string]: (event: MessageEvent<WorkerMessage>) => void } = {
58
- [WorkerMessageType.PAGInit]: (event) => {
59
- const option: ModuleOption = {};
60
- if (event.data.args[0]) {
61
- option.locateFile = () => event.data.args[0].fileUrl;
62
- }
63
- init(option).then((module: types.PAG) => {
64
- self.PAG = module;
65
- self.postMessage({ name: event.data.name, args: [] });
66
- });
67
- },
68
- [WorkerMessageType.PAGFile_load]: async (event) => {
69
- const key = registerPAGFile(await self.PAG.PAGFile.load(event.data.args[0]));
70
- self.postMessage({ name: event.data.name, args: [key] });
71
- },
72
- [WorkerMessageType.PAGView_init]: async (event) => {
73
- const [pagFileKey, canvas, option] = event.data.args;
74
- const key = registerPAGView((await self.PAG.PAGView.init(pagFiles[pagFileKey], canvas, option)) as PAGView);
75
- self.postMessage({ name: event.data.name, args: [key] });
76
- },
77
- [WorkerMessageType.PAGView_destroy]: async (event) => {
78
- const [pagViewKey] = event.data.args;
79
- pagViews[pagViewKey].destroy();
80
- deletePAGView(pagViewKey);
81
- self.postMessage({ name: event.data.name, args: [] });
82
- },
83
- [WorkerMessageType.PAGFile_getTextData]: async (event) => {
84
- const [pagFileKey, editableTextIndex] = event.data.args;
85
- const textData = pagFiles[pagFileKey].getTextData(editableTextIndex) as types.TextDocument & {
86
- [prop: string]: any;
87
- };
88
- let virtualTextData: { [key: string]: any } = {};
89
- for (const key in textData) {
90
- if (typeof textData[key] !== 'function') {
91
- virtualTextData[key] = textData[key];
92
- }
93
- }
94
- virtualTextData.key = registerTextData(textData);
95
- self.postMessage({ name: event.data.name, args: [virtualTextData] });
96
- },
97
- [WorkerMessageType.PAGFile_replaceText]: async (event) => {
98
- const [pagFileKey, editableTextIndex, virtualTextData] = event.data.args;
99
- const textData = textDataMap[virtualTextData.key];
100
- for (const key in virtualTextData) {
101
- if (key !== 'key') {
102
- textData[key] = virtualTextData[key];
103
- }
104
- }
105
- pagFiles[pagFileKey].replaceText(editableTextIndex, textData);
106
- self.postMessage({ name: event.data.name, args: [] });
107
- },
108
- [WorkerMessageType.PAGFile_replaceImage]: async (event) => {
109
- const [pagFileKey, editableImageIndex, pagImageKey] = event.data.args;
110
- const pagImage = pagImages[pagImageKey];
111
- pagFiles[pagFileKey].replaceImage(editableImageIndex, pagImage);
112
- self.postMessage({ name: event.data.name, args: [] });
113
- },
114
- [WorkerMessageType.PAGFile_destroy]: async (event) => {
115
- const [pagFileKey] = event.data.args;
116
- pagFiles[pagFileKey].destroy();
117
- deletePAGFile(pagFileKey);
118
- self.postMessage({ name: event.data.name, args: [] });
119
- },
120
- [WorkerMessageType.PAGImage_fromSource]: async (event) => {
121
- const [bitmap] = event.data.args;
122
- const key = registerPAGImage(self.PAG.PAGImage.fromSource(bitmap));
123
- self.postMessage({ name: event.data.name, args: [key] });
124
- },
125
- [WorkerMessageType.PAGImage_destroy]: async (event) => {
126
- const [pagImageKey] = event.data.args;
127
- pagImages[pagImageKey].destroy();
128
- deletePAGImage(pagImageKey);
129
- self.postMessage({ name: event.data.name, args: [] });
130
- },
131
- [WorkerMessageType.TextDocument_delete]: async (event) => {
132
- const [textDataKey] = event.data.args;
133
- textDataMap[textDataKey].delete();
134
- deleteTextData(textDataKey);
135
- self.postMessage({ name: event.data.name, args: [] });
136
- },
137
- };
138
-
139
- const name = event.data.name.split('_')[0];
140
-
141
- if (messageHandles[name]) {
142
- messageHandles[name](event);
143
- return;
144
- }
145
-
146
- const [type, fnName] = name.split('.') as [string, string];
147
- const key = event.data.args[0];
148
- if (type === 'PAGFile') {
149
- const pagFile = pagFiles[key];
150
- if (!pagFile) throw new Error("pagFile doesn't exist");
151
- const fn = pagFile[fnName] as Function;
152
- if (!fn) throw new Error(`PAGFile.${fnName} doesn't exist`);
153
- const res = await fn.call(pagFile, ...event.data.args.slice(1));
154
- self.postMessage({ name: event.data.name, args: [res] });
155
- return;
156
- }
157
- if (type === 'PAGView') {
158
- const pagView = pagViews[key];
159
- if (!pagView) throw new Error("pagView doesn't exist");
160
- const fn = pagView[fnName] as Function;
161
- if (!fn) throw new Error(`PAGView.${fnName} doesn't exist`);
162
- const res = await fn.call(pagView, ...event.data.args.slice(1));
163
- self.postMessage({ name: event.data.name, args: [res] });
164
- return;
165
- }
166
- };
167
- };
168
-
169
- export { workerInit };
@@ -1,26 +0,0 @@
1
- import { ctor, Point, Vector } from '../types';
2
- export interface WebFont {
3
- name: string;
4
- style: string;
5
- size: number;
6
- bold: boolean;
7
- italic: boolean;
8
- }
9
- export declare class WebMask {
10
- static create(canvas: HTMLCanvasElement | OffscreenCanvas): WebMask;
11
- private static getLineCap;
12
- private static getLineJoin;
13
- protected canvas: HTMLCanvasElement | OffscreenCanvas;
14
- private context;
15
- constructor(canvas: HTMLCanvasElement | OffscreenCanvas);
16
- updateCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void;
17
- fillPath(path: Path2D, fillType: ctor): void;
18
- fillText(webFont: WebFont, texts: Vector<string>, positions: Vector<Point>, matrixWasmIns: any): void;
19
- strokeText(webFont: WebFont, stroke: {
20
- width: number;
21
- cap: ctor;
22
- join: ctor;
23
- miterLimit: number;
24
- }, texts: Vector<string>, positions: Vector<Point>, matrixWasmIns: any): void;
25
- clear(): void;
26
- }
@@ -1,4 +0,0 @@
1
- export declare const calculateDisplaySize: (canvas: HTMLCanvasElement) => {
2
- width: number;
3
- height: number;
4
- };
@@ -1,16 +0,0 @@
1
- import { WorkerPAGFile } from './pag-file';
2
- import { WorkerPAGView } from './pag-view';
3
- import { WorkerPAGImage } from './pag-image';
4
- export declare const MAX_ACTIVE_WORKER_CONTEXTS = 4;
5
- export interface PAGWorkerOptions {
6
- /**
7
- * Link to wasm file and libpag core script.
8
- */
9
- locateFile?: (file: 'libpag.wasm' | 'libpag.js') => string;
10
- /**
11
- * Configure for worker.
12
- */
13
- workerOptions?: WorkerOptions;
14
- }
15
- export declare const createPAGWorker: (pagWorkerOptions?: PAGWorkerOptions) => Promise<Worker>;
16
- export { WorkerPAGFile, WorkerPAGView, WorkerPAGImage };
@@ -1,32 +0,0 @@
1
- export declare enum WorkerMessageType {
2
- PAGInit = "PAGInit",
3
- PAGView_init = "PAGView.init",
4
- PAGView_duration = "PAGView.duration",
5
- PAGView_play = "PAGView.play",
6
- PAGView_pause = "PAGView.pause",
7
- PAGView_stop = "PAGView.stop",
8
- PAGView_setRepeatCount = "PAGView.setRepeatCount",
9
- PAGView_getProgress = "PAGView.getProgress",
10
- PAGView_currentFrame = "PAGView.currentFrame",
11
- PAGView_setProgress = "PAGView.setProgress",
12
- PAGView_scaleMode = "PAGView.scaleMode",
13
- PAGView_setScaleMode = "PAGView.setScaleMode",
14
- PAGView_flush = "PAGView.flush",
15
- PAGView_getDebugData = "PAGView.getDebugData",
16
- PAGView_destroy = "PAGView.destroy",
17
- PAGFile_load = "PAGFile.load",
18
- PAGFile_getTextData = "PAGFile.getTextData",
19
- PAGFile_replaceText = "PAGFile.replaceText",
20
- PAGFile_replaceImage = "PAGFile.replaceImage",
21
- PAGFile_destroy = "PAGFile.destroy",
22
- PAGImage_fromSource = "PAGImage.fromSource",
23
- PAGImage_destroy = "PAGImage.destroy",
24
- VideoReader_constructor = "VideoReader.constructor",
25
- VideoReader_prepare = "VideoReader.prepare",
26
- VideoReader_play = "VideoReader.play",
27
- VideoReader_pause = "VideoReader.pause",
28
- VideoReader_stop = "VideoReader.stop",
29
- VideoReader_getError = "VideoReader.getError",
30
- PAGModule_linkVideoReader = "PAGModule.linkVideoReader",
31
- TextDocument_delete = "TextDocument.delete"
32
- }
@@ -1,33 +0,0 @@
1
- import type { WorkerPAGImage } from './pag-image';
2
- import type { TextDocument } from '../types';
3
- export declare class WorkerPAGFile {
4
- /**
5
- * Load pag file from file.
6
- */
7
- static load(worker: Worker, data: File | Blob | ArrayBuffer): Promise<WorkerPAGFile>;
8
- key: number;
9
- worker: Worker;
10
- isDestroyed: boolean;
11
- constructor(worker: Worker, key: number);
12
- /**
13
- * Get a text data of the specified index. The index ranges from 0 to numTexts - 1.
14
- * Note: It always returns the default text data.
15
- */
16
- getTextData(editableTextIndex: number): Promise<TextDocument & {
17
- key: number;
18
- }>;
19
- /**
20
- * Replace the text data of the specified index. The index ranges from 0 to PAGFile.numTexts - 1.
21
- * Passing in null for the textData parameter will reset it to default text data.
22
- */
23
- replaceText(editableTextIndex: number, textData: TextDocument & {
24
- [prop: string]: any;
25
- }): Promise<void>;
26
- /**
27
- * Replace the image content of the specified index with a PAGImage object. The index ranges from
28
- * 0 to PAGFile.numImages - 1. Passing in null for the image parameter will reset it to default
29
- * image content.
30
- */
31
- replaceImage(editableImageIndex: number, pagImage: WorkerPAGImage): Promise<any>;
32
- destroy(): Promise<void>;
33
- }
@@ -1,8 +0,0 @@
1
- export declare class WorkerPAGImage {
2
- static fromSource(worker: Worker, source: TexImageSource): Promise<WorkerPAGImage>;
3
- worker: Worker;
4
- key: number;
5
- isDestroyed: boolean;
6
- constructor(worker: Worker, key: number);
7
- destroy(): Promise<void>;
8
- }
@@ -1,67 +0,0 @@
1
- import type { WorkerPAGFile } from './pag-file';
2
- import type { PAGViewOptions } from '../pag-view';
3
- import type { DebugData, PAGScaleMode } from '../types';
4
- export declare class WorkerPAGView {
5
- /**
6
- * Create pag view.
7
- * @param file pag file.
8
- * @param canvas target render canvas.
9
- * @param initOptions pag view options
10
- * @returns
11
- */
12
- static init(file: WorkerPAGFile, canvas: HTMLCanvasElement, initOptions?: PAGViewOptions): Promise<WorkerPAGView>;
13
- key: number;
14
- worker: Worker;
15
- isDestroyed: boolean;
16
- constructor(worker: Worker, key: number);
17
- /**
18
- * The duration of current composition in microseconds.
19
- */
20
- duration(): Promise<number>;
21
- /**
22
- * Start the animation.
23
- */
24
- play(): Promise<any>;
25
- /**
26
- * Pause the animation.
27
- */
28
- pause(): Promise<void>;
29
- /**
30
- * Stop the animation.
31
- */
32
- stop(): Promise<void>;
33
- /**
34
- * Set the number of times the animation will repeat. The default is 1, which means the animation
35
- * will play only once. 0 means the animation will play infinity times.
36
- */
37
- setRepeatCount(repeatCount: number): Promise<void>;
38
- /**
39
- * Returns the current progress of play position, the value is from 0.0 to 1.0. It is applied only
40
- * when the composition is not null.
41
- */
42
- getProgress(): Promise<number>;
43
- /**
44
- * Returns the current frame.
45
- */
46
- currentFrame(): Promise<number>;
47
- /**
48
- * Set the progress of play position, the value is from 0.0 to 1.0.
49
- */
50
- setProgress(progress: number): Promise<any>;
51
- /**
52
- * Returns the current scale mode.
53
- */
54
- scaleMode(): Promise<number>;
55
- /**
56
- * Specifies the rule of how to scale the pag content to fit the surface size. The matrix
57
- * changes when this method is called.
58
- */
59
- setScaleMode(value: PAGScaleMode): Promise<void>;
60
- /**
61
- * Call this method to render current position immediately. If the play() method is already
62
- * called, there is no need to call it. Returns true if the content has changed.
63
- */
64
- flush(): Promise<boolean>;
65
- getDebugData(): Promise<DebugData>;
66
- destroy(): void;
67
- }
@@ -1,7 +0,0 @@
1
- import type { WorkerMessage } from './worker';
2
- export interface WorkerInterface {
3
- postMessage: (message: any, transfer: Transferable[]) => void;
4
- addEventListener: (type: string, listener: (event: MessageEvent) => void) => void;
5
- removeEventListener: (type: string, listener: (event: MessageEvent) => void) => void;
6
- }
7
- export declare const postMessage: <T>(worker: WorkerInterface, message: WorkerMessage, callback: (...args: any[]) => T, transfer?: (OffscreenCanvas | Transferable)[]) => Promise<T>;
@@ -1,16 +0,0 @@
1
- import { BitmapImage } from '@tgfx/core/bitmap-image';
2
- export declare class WorkerVideoReader {
3
- bitmap: ImageBitmap | null;
4
- isSought: boolean;
5
- isPlaying: boolean;
6
- private proxyId;
7
- private bitmapImage;
8
- constructor(proxyId: number);
9
- prepare(targetFrame: number, playbackRate: number): Promise<void>;
10
- getVideo(): BitmapImage;
11
- onDestroy(): void;
12
- play(): Promise<void>;
13
- pause(): void;
14
- stop(): void;
15
- getError(): Promise<any>;
16
- }
@@ -1,13 +0,0 @@
1
- import * as types from '../types';
2
- import type { PAGInit } from '../pag';
3
- declare global {
4
- interface Window {
5
- PAG: types.PAG;
6
- }
7
- }
8
- export interface WorkerMessage {
9
- name: string;
10
- args: any[];
11
- }
12
- declare const workerInit: (init: typeof PAGInit) => void;
13
- export { workerInit };