libpag 4.5.4 → 4.5.16
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/lib/libpag.cjs.js +5407 -5528
- package/lib/libpag.cjs.js.map +1 -1
- package/lib/libpag.esm.js +5407 -5528
- package/lib/libpag.esm.js.map +1 -1
- package/lib/libpag.min.js +1 -1
- package/lib/libpag.min.js.map +1 -1
- package/lib/libpag.umd.js +5407 -5528
- package/lib/libpag.umd.js.map +1 -1
- package/lib/libpag.wasm +0 -0
- package/package.json +10 -1
- package/src/.pag.wasm-mt.md5 +1 -1
- package/src/.pag.wasm.md5 +1 -1
- package/src/binding.ts +1 -0
- package/src/constant.ts +1 -1
- package/src/core/video-reader.ts +277 -263
- package/src/interfaces.ts +14 -7
- package/src/pag-composition.ts +185 -165
- package/src/pag-player.ts +390 -309
- package/src/pag-view.ts +11 -9
- package/src/types.ts +7 -1
- package/src/utils/mixin.ts +1 -0
- package/src/video-reader-manager.ts +140 -0
- package/src/wasm/libpag.js +7 -6
- package/src/wasm/libpag.wasm +0 -0
- package/src/wasm-mt/libpag.js +2 -10331
- package/src/wasm-mt/libpag.wasm +0 -0
- package/src/wechat/binding.ts +1 -0
- package/src/wechat/pag-view.ts +6 -1
- package/src/wechat/video-reader.ts +37 -11
- package/types/web/src/constant.d.ts +1 -1
- package/types/web/src/core/video-reader.d.ts +3 -1
- package/types/web/src/interfaces.d.ts +7 -1
- package/types/web/src/pag-player.d.ts +12 -1
- package/types/web/src/pag-view.d.ts +1 -1
- package/types/web/src/types.d.ts +7 -0
- package/types/web/src/video-reader-manager.d.ts +60 -0
- package/src/wasm/libpag.wasm.map +0 -1
package/src/interfaces.ts
CHANGED
|
@@ -16,13 +16,20 @@ export interface VideoReader {
|
|
|
16
16
|
stop: () => void;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
export interface VideoReaderManager{
|
|
20
|
+
getVideoReaderByID: (id: number) => VideoReader | undefined;
|
|
21
|
+
destroy: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface VideoDecoderConstructor {
|
|
25
|
+
create: (
|
|
26
|
+
mp4Data: Uint8Array,
|
|
27
|
+
width: number,
|
|
28
|
+
height: number,
|
|
29
|
+
frameRate: number,
|
|
30
|
+
staticTimeRanges: TimeRange[],
|
|
31
|
+
) => Promise<VideoReader>;
|
|
32
|
+
}
|
|
26
33
|
|
|
27
34
|
export interface FontMetrics {
|
|
28
35
|
ascent: number;
|
package/src/pag-composition.ts
CHANGED
|
@@ -1,170 +1,190 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import {PAGModule} from './pag-module';
|
|
2
|
+
import {PAGLayer} from './pag-layer';
|
|
3
|
+
import {destroyVerify} from './utils/decorators';
|
|
4
|
+
import {layer2typeLayer, proxyVector} from './utils/type-utils';
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import {type Marker, VecArray} from './types';
|
|
7
7
|
|
|
8
8
|
@destroyVerify
|
|
9
9
|
export class PAGComposition extends PAGLayer {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Make a empty PAGComposition with specified size.
|
|
12
|
+
*/
|
|
13
|
+
public static make(width: number, height: number): PAGComposition {
|
|
14
|
+
const wasmIns = PAGModule._PAGComposition._Make(width, height);
|
|
15
|
+
if (!wasmIns) throw new Error('Make PAGComposition fail!');
|
|
16
|
+
return new PAGComposition(wasmIns);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the width of the Composition.
|
|
21
|
+
*/
|
|
22
|
+
public width(): number {
|
|
23
|
+
return this.wasmIns._width() as number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns the height of the Composition.
|
|
28
|
+
*/
|
|
29
|
+
public height(): number {
|
|
30
|
+
return this.wasmIns._height() as number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Set the width and height of the Composition.
|
|
35
|
+
*/
|
|
36
|
+
public setContentSize(width: number, height: number): void {
|
|
37
|
+
this.wasmIns._setContentSize(width, height);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the number of child layers of this composition.
|
|
42
|
+
*/
|
|
43
|
+
public numChildren(): number {
|
|
44
|
+
return this.wasmIns._numChildren() as number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns the child layer that exists at the specified index.
|
|
49
|
+
* @param index The index position of the child layer.
|
|
50
|
+
* @returns The child layer at the specified index position.
|
|
51
|
+
*/
|
|
52
|
+
public getLayerAt(index: number) {
|
|
53
|
+
const wasmIns = this.wasmIns._getLayerAt(index);
|
|
54
|
+
if (!wasmIns) throw new Error(`Get layer at ${index} fail!`);
|
|
55
|
+
return layer2typeLayer(wasmIns);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns the index position of a child layer.
|
|
60
|
+
* @param pagLayer The layer instance to identify.
|
|
61
|
+
* @returns The index position of the child layer to identify.
|
|
62
|
+
*/
|
|
63
|
+
public getLayerIndex(pagLayer: PAGLayer): number {
|
|
64
|
+
return this.wasmIns._getLayerIndex(pagLayer.wasmIns) as number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Changes the position of an existing child layer in the composition. This affects the layering
|
|
69
|
+
* of child layers.
|
|
70
|
+
* @param pagLayer The child layer for which you want to change the index number.
|
|
71
|
+
* @param index The resulting index number for the child layer.
|
|
72
|
+
*/
|
|
73
|
+
public setLayerIndex(pagLayer: PAGLayer, index: number): number {
|
|
74
|
+
return this.wasmIns._setLayerIndex(pagLayer.wasmIns, index) as number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Add a PAGLayer to current PAGComposition at the top. If you add a layer that already has a
|
|
79
|
+
* different PAGComposition object as a parent, the layer is removed from the other PAGComposition
|
|
80
|
+
* object.
|
|
81
|
+
*/
|
|
82
|
+
public addLayer(pagLayer: PAGLayer): boolean {
|
|
83
|
+
return this.wasmIns._addLayer(pagLayer.wasmIns) as boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Add a PAGLayer to current PAGComposition at the top. If you add a layer that already has a
|
|
88
|
+
* different PAGComposition object as a parent, the layer is removed from the other PAGComposition
|
|
89
|
+
* object.
|
|
90
|
+
*/
|
|
91
|
+
public addLayerAt(pagLayer: PAGLayer, index: number): boolean {
|
|
92
|
+
return this.wasmIns._addLayerAt(pagLayer.wasmIns, index) as boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Check whether current PAGComposition contains the specified pagLayer.
|
|
97
|
+
*/
|
|
98
|
+
public contains(pagLayer: PAGLayer): boolean {
|
|
99
|
+
return this.wasmIns._contains(pagLayer.wasmIns) as boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Remove the specified PAGLayer from current PAGComposition.
|
|
104
|
+
*/
|
|
105
|
+
public removeLayer(pagLayer: PAGLayer) {
|
|
106
|
+
const wasmIns = this.wasmIns._removeLayer(pagLayer.wasmIns);
|
|
107
|
+
if (!wasmIns) throw new Error('Remove layer fail!');
|
|
108
|
+
return layer2typeLayer(wasmIns);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Remove the specified PAGLayer from current PAGComposition.
|
|
113
|
+
*/
|
|
114
|
+
public removeLayerAt(index: number) {
|
|
115
|
+
const wasmIns = this.wasmIns._removeLayerAt(index);
|
|
116
|
+
if (!wasmIns) throw new Error(`Remove layer at ${index} fail!`);
|
|
117
|
+
return layer2typeLayer(wasmIns);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Remove all PAGLayers from current PAGComposition.
|
|
122
|
+
*/
|
|
123
|
+
public removeAllLayers(): void {
|
|
124
|
+
this.wasmIns._removeAllLayers();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Swap the layers at the specified index.
|
|
129
|
+
*/
|
|
130
|
+
public swapLayer(pagLayer1: PAGLayer, pagLayer2: PAGLayer): void {
|
|
131
|
+
this.wasmIns._swapLayer(pagLayer1.wasmIns, pagLayer2.wasmIns);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Swap the layers at the specified index.
|
|
136
|
+
*/
|
|
137
|
+
public swapLayerAt(index1: number, index2: number): void {
|
|
138
|
+
this.wasmIns._swapLayerAt(index1, index2);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The audio data of this composition, which is an AAC audio in an MPEG-4 container.
|
|
143
|
+
*/
|
|
144
|
+
public audioBytes(): Uint8Array | null {
|
|
145
|
+
return this.wasmIns._audioBytes();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns the audio markers of this composition.
|
|
150
|
+
*/
|
|
151
|
+
public audioMarkers() {
|
|
152
|
+
const wasmIns = this.wasmIns._audioMarkers();
|
|
153
|
+
if (!wasmIns) throw new Error(`Get audioMarkers fail!`);
|
|
154
|
+
return proxyVector(wasmIns, (wasmIns: any) => wasmIns as Marker);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Indicates when the first frame of the audio plays in the composition's timeline.
|
|
159
|
+
*/
|
|
160
|
+
public audioStartTime(): number {
|
|
161
|
+
return this.wasmIns._audioStartTime() as number;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Returns an array of layers that match the specified layer name.
|
|
166
|
+
*/
|
|
167
|
+
public getLayersByName(layerName: string) {
|
|
168
|
+
const wasmIns = this.wasmIns._getLayersByName(layerName);
|
|
169
|
+
if (!wasmIns) throw new Error(`Get layers by ${layerName} fail!`);
|
|
170
|
+
const layerArray = VecArray.create();
|
|
171
|
+
for (const wasmIn of wasmIns) {
|
|
172
|
+
layerArray.push(layer2typeLayer(wasmIn));
|
|
173
|
+
}
|
|
174
|
+
return layerArray;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Returns an array of layers that lie under the specified point. The point is in pixels and from
|
|
179
|
+
* this PAGComposition's local coordinates.
|
|
180
|
+
*/
|
|
181
|
+
public getLayersUnderPoint(localX: number, localY: number) {
|
|
182
|
+
const wasmIns = this.wasmIns._getLayersUnderPoint(localX, localY);
|
|
183
|
+
if (!wasmIns) throw new Error(`Get layers under point ${localX},${localY} fail!`);
|
|
184
|
+
const layerArray = VecArray.create();
|
|
185
|
+
for (const wasmIn of wasmIns) {
|
|
186
|
+
layerArray.push(layer2typeLayer(wasmIn));
|
|
187
|
+
}
|
|
188
|
+
return layerArray;
|
|
189
|
+
}
|
|
170
190
|
}
|