@web-ppt/viewer-core 0.5.0-beta.7 → 0.6.0-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/CHANGELOG.md +22 -1
- package/dist/video/media-overlay.d.ts +13 -7
- package/dist/video.js +578 -525
- package/package.json +2 -2
package/dist/video.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { transitionPreferredDirection as
|
|
2
|
-
const
|
|
1
|
+
import { transitionPreferredDirection as Mt, slideToSvgFile as xt, groupSteps as kt, placeGroupChild as $t, hiddenBefore as Et, staticHidden as Pt } from "@web-ppt/core";
|
|
2
|
+
const j = 6;
|
|
3
3
|
function M(r) {
|
|
4
4
|
return `${Math.round(r * 1e3) / 1e3}%`;
|
|
5
5
|
}
|
|
6
6
|
function ct(r, t) {
|
|
7
|
-
const e = r === "vert",
|
|
8
|
-
for (let
|
|
9
|
-
const o =
|
|
10
|
-
|
|
7
|
+
const e = r === "vert", n = [];
|
|
8
|
+
for (let a = 0; a < j; a++) {
|
|
9
|
+
const o = a / j * 100, s = (a + 1) / j * 100, l = t ? s : o;
|
|
10
|
+
n.push(e ? $(o, 0, l, 100) : $(0, o, 100, l));
|
|
11
11
|
}
|
|
12
|
-
return
|
|
12
|
+
return D(n);
|
|
13
13
|
}
|
|
14
14
|
const lt = [
|
|
15
15
|
"linear-gradient(#000,#000)",
|
|
16
16
|
"linear-gradient(#000,#000)",
|
|
17
17
|
"linear-gradient(#000,#000)",
|
|
18
18
|
"linear-gradient(#000,#000)"
|
|
19
|
-
].join(", "),
|
|
20
|
-
function
|
|
19
|
+
].join(", "), gt = { l: 0, t: 0, w: 100, h: 100 };
|
|
20
|
+
function bt(r) {
|
|
21
21
|
return r.l === 0 && r.t === 0 && r.w === 100 && r.h === 100;
|
|
22
22
|
}
|
|
23
|
-
function q(r, t =
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
23
|
+
function q(r, t = gt) {
|
|
24
|
+
if (bt(t)) {
|
|
25
|
+
const l = r ? 50 : 0, i = `100% ${l}%, 100% ${l}%, ${l}% 100%, ${l}% 100%`;
|
|
26
26
|
return {
|
|
27
27
|
opacity: 1,
|
|
28
28
|
maskImage: lt,
|
|
29
29
|
maskRepeat: "no-repeat",
|
|
30
30
|
maskPosition: "center top, center bottom, left center, right center",
|
|
31
|
-
maskSize:
|
|
31
|
+
maskSize: i,
|
|
32
32
|
maskOrigin: "fill-box",
|
|
33
33
|
maskClip: "fill-box"
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
const e = r ? 0.501 : 0,
|
|
36
|
+
const e = r ? 0.501 : 0, n = t.h * e, a = t.w * e, o = 100 - (t.t + t.h), s = 100 - (t.l + t.w);
|
|
37
37
|
return {
|
|
38
38
|
opacity: 1,
|
|
39
39
|
maskImage: lt,
|
|
@@ -46,29 +46,29 @@ function q(r, t = yt) {
|
|
|
46
46
|
`right ${M(s)} top ${M(t.t)}`
|
|
47
47
|
].join(", "),
|
|
48
48
|
maskSize: [
|
|
49
|
-
`${M(t.w)} ${M(
|
|
50
|
-
`${M(t.w)} ${M(
|
|
51
|
-
`${M(
|
|
52
|
-
`${M(
|
|
49
|
+
`${M(t.w)} ${M(n)}`,
|
|
50
|
+
`${M(t.w)} ${M(n)}`,
|
|
51
|
+
`${M(a)} ${M(t.h)}`,
|
|
52
|
+
`${M(a)} ${M(t.h)}`
|
|
53
53
|
].join(", "),
|
|
54
54
|
maskOrigin: "fill-box",
|
|
55
55
|
maskClip: "fill-box"
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
if (
|
|
58
|
+
function H(r, t = gt) {
|
|
59
|
+
if (bt(t))
|
|
60
60
|
return r ? "inset(0% 0% 0% 0%) fill-box" : "inset(50% 50% 50% 50%) fill-box";
|
|
61
|
-
const e = r ? t.t : t.t + t.h / 2,
|
|
62
|
-
return `inset(${M(e)} ${M(o)} ${M(
|
|
61
|
+
const e = r ? t.t : t.t + t.h / 2, n = r ? t.l : t.l + t.w / 2, a = r ? 100 - (t.t + t.h) : 100 - (t.t + t.h / 2), o = r ? 100 - (t.l + t.w) : 100 - (t.l + t.w / 2);
|
|
62
|
+
return `inset(${M(e)} ${M(o)} ${M(a)} ${M(n)}) fill-box`;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function D(r, t = []) {
|
|
65
65
|
return {
|
|
66
66
|
opacity: 1,
|
|
67
67
|
maskImage: r.map(() => "linear-gradient(#000,#000)").join(", "),
|
|
68
68
|
maskRepeat: "no-repeat",
|
|
69
|
-
maskPosition: r.map((e,
|
|
70
|
-
var
|
|
71
|
-
return `${((
|
|
69
|
+
maskPosition: r.map((e, n) => {
|
|
70
|
+
var a, o;
|
|
71
|
+
return `${((a = t[n]) == null ? void 0 : a.x) === "right" ? `right ${M(100 - e[2][0])}` : `left ${M(e[0][0])}`} ${((o = t[n]) == null ? void 0 : o.y) === "bottom" ? `bottom ${M(100 - e[2][1])}` : `top ${M(e[0][1])}`}`;
|
|
72
72
|
}).join(", "),
|
|
73
73
|
maskSize: r.map((e) => `${M(e[2][0] - e[0][0])} ${M(e[2][1] - e[0][1])}`).join(", "),
|
|
74
74
|
maskOrigin: "fill-box",
|
|
@@ -76,10 +76,10 @@ function z(r, t = []) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
function Q(r, t = !1) {
|
|
79
|
-
const e = (o) => Math.round(o * 1e3) / 1e3,
|
|
79
|
+
const e = (o) => Math.round(o * 1e3) / 1e3, n = r.map((o) => `M${e(o[0][0])} ${e(o[0][1])} ` + o.slice(1).map(([s, l]) => `L${e(s)} ${e(l)}`).join(" ") + " Z").join(" "), a = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path fill="#000" fill-rule="${t ? "evenodd" : "nonzero"}" d="${n}"/></svg>`;
|
|
80
80
|
return {
|
|
81
81
|
opacity: 1,
|
|
82
|
-
maskImage: `url("data:image/svg+xml,${encodeURIComponent(
|
|
82
|
+
maskImage: `url("data:image/svg+xml,${encodeURIComponent(a)}")`,
|
|
83
83
|
maskRepeat: "no-repeat",
|
|
84
84
|
maskPosition: "center",
|
|
85
85
|
maskSize: "100% 100%",
|
|
@@ -87,50 +87,50 @@ function Q(r, t = !1) {
|
|
|
87
87
|
maskClip: "fill-box"
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
return [[r, t], [e, t], [e,
|
|
90
|
+
function $(r, t, e, n) {
|
|
91
|
+
return [[r, t], [e, t], [e, n], [r, n]];
|
|
92
92
|
}
|
|
93
93
|
function ft(r, t) {
|
|
94
|
-
const e = (r == null ? void 0 : r.endsWith("vert")) ?? !0,
|
|
95
|
-
return
|
|
94
|
+
const e = (r == null ? void 0 : r.endsWith("vert")) ?? !0, n = (r == null ? void 0 : r.startsWith("in")) ?? !1, a = t ? 50 : 0;
|
|
95
|
+
return D(e ? n ? [$(0, 0, a, 100), $(100 - a, 0, 100, 100)] : [$(50 - a, 0, 50, 100), $(50, 0, 50 + a, 100)] : n ? [$(0, 0, 100, a), $(0, 100 - a, 100, 100)] : [$(0, 50 - a, 100, 50), $(0, 50, 100, 50 + a)]);
|
|
96
96
|
}
|
|
97
97
|
function ut(r, t) {
|
|
98
98
|
const e = [];
|
|
99
|
-
for (let
|
|
100
|
-
const o =
|
|
101
|
-
r === "down" ? e.push(
|
|
99
|
+
for (let n = 0; n < 6; n++) for (let a = 0; a < 8; a++) {
|
|
100
|
+
const o = a * 12.5, s = n * (100 / 6), l = o + 12.5, i = s + 100 / 6, f = (n + a) % 2 === 1;
|
|
101
|
+
r === "down" ? e.push($(
|
|
102
102
|
o,
|
|
103
|
-
f ?
|
|
104
|
-
|
|
105
|
-
f ?
|
|
106
|
-
)) : e.push(
|
|
107
|
-
f ?
|
|
103
|
+
f ? i - (t ? i - s : 0) : s,
|
|
104
|
+
l,
|
|
105
|
+
f ? i : s + (t ? i - s : 0)
|
|
106
|
+
)) : e.push($(
|
|
107
|
+
f ? l - (t ? l - o : 0) : o,
|
|
108
108
|
s,
|
|
109
|
-
f ?
|
|
110
|
-
|
|
109
|
+
f ? l : o + (t ? l - o : 0),
|
|
110
|
+
i
|
|
111
111
|
));
|
|
112
112
|
}
|
|
113
|
-
return
|
|
113
|
+
return D(e);
|
|
114
114
|
}
|
|
115
115
|
function Z(r, t) {
|
|
116
|
-
const e = r === "vert",
|
|
117
|
-
for (let s = 0; s <
|
|
118
|
-
const
|
|
119
|
-
o.push(e ?
|
|
116
|
+
const e = r === "vert", n = 128, a = typeof t == "boolean" ? Number(t) : t, o = [];
|
|
117
|
+
for (let s = 0; s < n; s++) {
|
|
118
|
+
const l = s * 100 / n, i = (s + 1) * 100 / n, f = s * 73 % n, u = Math.min(1, Math.max(0, a * n - f)) * (i - l);
|
|
119
|
+
o.push(e ? $(l, 0, l + u, 100) : $(0, l, 100, l + u));
|
|
120
120
|
}
|
|
121
|
-
return
|
|
121
|
+
return D(o);
|
|
122
122
|
}
|
|
123
123
|
function J(r, t) {
|
|
124
|
-
const e = (r == null ? void 0 : r.startsWith("l")) ?? !1,
|
|
125
|
-
for (let
|
|
126
|
-
const
|
|
127
|
-
s.push(e ?
|
|
124
|
+
const e = (r == null ? void 0 : r.startsWith("l")) ?? !1, n = (r == null ? void 0 : r.endsWith("u")) ?? !1, a = typeof t == "boolean" ? Number(t) : t, o = 8, s = [];
|
|
125
|
+
for (let l = 0; l < o; l++) {
|
|
126
|
+
const i = l * 100 / o, f = (l + 1) * 100 / o, u = (n ? o - l - 1 : l) / (2 * o), h = Math.min(1, Math.max(0, (a - u) / (1 - (o - 1) / (2 * o)))) * 100;
|
|
127
|
+
s.push(e ? $(100 - h, i, 100, f) : $(0, i, h, f));
|
|
128
128
|
}
|
|
129
|
-
return
|
|
129
|
+
return D(s, e ? s.map(() => ({ x: "right" })) : []);
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
if (r === "circle") return Array.from({ length: 40 }, (
|
|
133
|
-
const o =
|
|
131
|
+
function St(r, t) {
|
|
132
|
+
if (r === "circle") return Array.from({ length: 40 }, (n, a) => {
|
|
133
|
+
const o = a * Math.PI / 20 - Math.PI / 2;
|
|
134
134
|
return [50 + t * Math.cos(o), 50 + t * Math.sin(o)];
|
|
135
135
|
});
|
|
136
136
|
if (r === "diamond") return [
|
|
@@ -156,105 +156,105 @@ function $t(r, t) {
|
|
|
156
156
|
];
|
|
157
157
|
}
|
|
158
158
|
function tt(r, t, e) {
|
|
159
|
-
const
|
|
159
|
+
const n = typeof e == "boolean" ? Number(e) : e;
|
|
160
160
|
if (r === "plus" && t === "in") {
|
|
161
|
-
const
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
161
|
+
const l = n * 50;
|
|
162
|
+
return D([
|
|
163
|
+
$(0, 0, l, l),
|
|
164
|
+
$(100 - l, 0, 100, l),
|
|
165
|
+
$(0, 100 - l, l, 100),
|
|
166
|
+
$(100 - l, 100 - l, 100, 100)
|
|
167
167
|
], [{}, { x: "right" }, { y: "bottom" }, { x: "right", y: "bottom" }]);
|
|
168
168
|
}
|
|
169
|
-
const
|
|
170
|
-
return t === "in" ? Q([
|
|
169
|
+
const a = r === "circle" ? 72 : r === "diamond" ? 101 : 151, o = (t === "in" ? 1 - n : n) * a, s = St(r, o);
|
|
170
|
+
return t === "in" ? Q([$(0, 0, 100, 100), s], !0) : Q([s]);
|
|
171
171
|
}
|
|
172
172
|
function et(r, t) {
|
|
173
|
-
const e = [1, 2, 3, 4, 8].includes(Number(r)) ? Number(r) : 1,
|
|
173
|
+
const e = [1, 2, 3, 4, 8].includes(Number(r)) ? Number(r) : 1, n = typeof t == "boolean" ? Number(t) : t, a = [];
|
|
174
174
|
for (let o = 0; o < e; o++) {
|
|
175
|
-
const s = -Math.PI / 2 + o * 2 * Math.PI / e,
|
|
175
|
+
const s = -Math.PI / 2 + o * 2 * Math.PI / e, l = n * 2 * Math.PI / e, i = [[50, 50]];
|
|
176
176
|
for (let f = 0; f <= 16; f++) {
|
|
177
|
-
const u = s +
|
|
178
|
-
|
|
177
|
+
const u = s + l * f / 16;
|
|
178
|
+
i.push([50 + 200 * Math.cos(u), 50 + 200 * Math.sin(u)]);
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
a.push(i);
|
|
181
181
|
}
|
|
182
|
-
return Q(
|
|
182
|
+
return Q(a);
|
|
183
183
|
}
|
|
184
184
|
function rt(r, t) {
|
|
185
|
-
const e = typeof r == "boolean" ? Number(r) : r,
|
|
186
|
-
for (let
|
|
187
|
-
const s = o * 10,
|
|
188
|
-
let u = Math.imul(
|
|
185
|
+
const e = typeof r == "boolean" ? Number(r) : r, n = [];
|
|
186
|
+
for (let a = 0; a < 8; a++) for (let o = 0; o < 10; o++) {
|
|
187
|
+
const s = o * 10, l = a * 12.5, i = (o + 1) * 10, f = (a + 1) * 12.5;
|
|
188
|
+
let u = Math.imul(a * 10 + o + t * 101, 73244475);
|
|
189
189
|
u = Math.imul(u ^ u >>> 16, 73244475), u = (u ^ u >>> 16) >>> 0;
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
h + (s - h) *
|
|
193
|
-
d + (
|
|
194
|
-
h + (
|
|
195
|
-
d + (f - d) *
|
|
190
|
+
const c = u % 17 / 17, h = s + (i - s) * c, d = l + (f - l) * (1 - c), m = (u >>> 8) % 8, g = Math.min(1, Math.max(0, e * 8 - m));
|
|
191
|
+
n.push($(
|
|
192
|
+
h + (s - h) * g,
|
|
193
|
+
d + (l - d) * g,
|
|
194
|
+
h + (i - h) * g,
|
|
195
|
+
d + (f - d) * g
|
|
196
196
|
));
|
|
197
197
|
}
|
|
198
|
-
return
|
|
198
|
+
return D(n);
|
|
199
199
|
}
|
|
200
|
-
const
|
|
201
|
-
function
|
|
202
|
-
const
|
|
203
|
-
if (!
|
|
200
|
+
const At = 2147483647;
|
|
201
|
+
function Ct(r, t, e) {
|
|
202
|
+
const n = r.querySelector("audio,video");
|
|
203
|
+
if (!n) return null;
|
|
204
204
|
if (!Number.isFinite(e) || e < 0)
|
|
205
205
|
throw new Error(`媒体调用的起始时间无效:${e}ms`);
|
|
206
|
-
let
|
|
207
|
-
const u = new Promise((
|
|
208
|
-
|
|
209
|
-
}),
|
|
210
|
-
|
|
206
|
+
let a = null, o = e, s = !1, l = !1, i, f;
|
|
207
|
+
const u = new Promise((m, g) => {
|
|
208
|
+
i = m, f = g;
|
|
209
|
+
}), c = () => {
|
|
210
|
+
l = !0, Promise.resolve(n.play()).then(i, f);
|
|
211
211
|
}, h = () => {
|
|
212
|
-
if (
|
|
212
|
+
if (a = null, !s)
|
|
213
213
|
try {
|
|
214
214
|
switch (t.action) {
|
|
215
215
|
case "play":
|
|
216
|
-
t.fromSeconds !== void 0 && (
|
|
216
|
+
t.fromSeconds !== void 0 && (n.currentTime = t.fromSeconds), c();
|
|
217
217
|
return;
|
|
218
218
|
case "resume":
|
|
219
|
-
|
|
219
|
+
c();
|
|
220
220
|
return;
|
|
221
221
|
case "pause":
|
|
222
|
-
|
|
222
|
+
n.pause();
|
|
223
223
|
break;
|
|
224
224
|
case "stop":
|
|
225
|
-
|
|
225
|
+
n.pause(), n.currentTime = 0;
|
|
226
226
|
break;
|
|
227
227
|
case "togglePause":
|
|
228
|
-
if (
|
|
229
|
-
|
|
228
|
+
if (n.paused) {
|
|
229
|
+
c();
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
|
-
|
|
232
|
+
n.pause();
|
|
233
233
|
break;
|
|
234
234
|
}
|
|
235
|
-
|
|
236
|
-
} catch (
|
|
237
|
-
f(
|
|
235
|
+
i();
|
|
236
|
+
} catch (m) {
|
|
237
|
+
f(m);
|
|
238
238
|
}
|
|
239
239
|
}, d = () => {
|
|
240
240
|
if (o === 0) {
|
|
241
241
|
h();
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
o -=
|
|
247
|
-
},
|
|
244
|
+
const m = Math.min(o, At);
|
|
245
|
+
a = setTimeout(() => {
|
|
246
|
+
o -= m, d();
|
|
247
|
+
}, m);
|
|
248
248
|
};
|
|
249
249
|
return d(), {
|
|
250
250
|
finished: u,
|
|
251
251
|
cancel: () => {
|
|
252
|
-
s = !0,
|
|
252
|
+
s = !0, a !== null && clearTimeout(a), l && n.pause(), i();
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
const C = 1.15;
|
|
257
|
-
function
|
|
257
|
+
function Nt(r) {
|
|
258
258
|
switch (r) {
|
|
259
259
|
case "l":
|
|
260
260
|
return [-100 * C, 0];
|
|
@@ -276,56 +276,56 @@ function St(r) {
|
|
|
276
276
|
return [0, 100 * C];
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
function
|
|
280
|
-
const
|
|
281
|
-
if (!
|
|
282
|
-
const
|
|
283
|
-
if (
|
|
284
|
-
const s = (
|
|
285
|
-
return `translate(${u}%, ${
|
|
279
|
+
function Ot(r, t, e) {
|
|
280
|
+
const n = r.querySelector("svg");
|
|
281
|
+
if (!n || typeof n.getBoundingClientRect != "function" || typeof t.getBoundingClientRect != "function") return null;
|
|
282
|
+
const a = n.getBoundingClientRect(), o = t.getBoundingClientRect();
|
|
283
|
+
if (a.width < 1 || a.height < 1 || o.width < 1 || o.height < 1) return null;
|
|
284
|
+
const s = (a.left - o.right - 4) / o.width * 100, l = (a.right - o.left + 4) / o.width * 100, i = (a.top - o.bottom - 4) / o.height * 100, f = (a.bottom - o.top + 4) / o.height * 100, u = e != null && e.includes("l") ? s : e != null && e.includes("r") ? l : 0, c = e != null && e.includes("u") ? i : e != null && e.includes("d") || !e ? f : 0;
|
|
285
|
+
return `translate(${u}%, ${c}%)`;
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function L(r, t) {
|
|
288
288
|
return r === t ? `scale(${r})` : `scale(${r}, ${t})`;
|
|
289
289
|
}
|
|
290
|
-
const
|
|
291
|
-
function
|
|
292
|
-
var
|
|
293
|
-
const t = (
|
|
290
|
+
const Tt = ["maskImage", "maskRepeat", "maskPosition", "maskSize"];
|
|
291
|
+
function Ft(r) {
|
|
292
|
+
var c, h;
|
|
293
|
+
const t = (c = r.getBoundingClientRect) == null ? void 0 : c.call(r), e = (h = r.ownerDocument) == null ? void 0 : h.createRange;
|
|
294
294
|
if (!t || t.width < 1 || t.height < 1 || typeof e != "function") return null;
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
299
|
-
const o = Math.min(100, Math.max(0, (
|
|
295
|
+
const n = e.call(r.ownerDocument);
|
|
296
|
+
n.selectNodeContents(r);
|
|
297
|
+
const a = n.getBoundingClientRect();
|
|
298
|
+
if (a.width < 1 || a.height < 1) return null;
|
|
299
|
+
const o = Math.min(100, Math.max(0, (a.left - t.left) / t.width * 100)), s = Math.min(100, Math.max(0, (a.top - t.top) / t.height * 100)), l = Math.min(100, Math.max(o, (a.right - t.left) / t.width * 100)), i = Math.min(100, Math.max(s, (a.bottom - t.top) / t.height * 100)), f = l - o, u = i - s;
|
|
300
300
|
return f < 1 || u < 1 ? null : { l: o, t: s, w: f, h: u };
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function It(r, t) {
|
|
303
303
|
if (!t || typeof r.querySelectorAll != "function") return [];
|
|
304
304
|
const e = [];
|
|
305
|
-
for (const
|
|
306
|
-
const o = Number(
|
|
307
|
-
Number.isInteger(o) && o >= t.start && o <= t.end && e.push(
|
|
305
|
+
for (const a of r.querySelectorAll("[data-p]")) {
|
|
306
|
+
const o = Number(a.getAttribute("data-p"));
|
|
307
|
+
Number.isInteger(o) && o >= t.start && o <= t.end && e.push(a);
|
|
308
308
|
}
|
|
309
309
|
if (e.length) return e;
|
|
310
|
-
const
|
|
311
|
-
for (const
|
|
312
|
-
const o = [...
|
|
310
|
+
const n = [];
|
|
311
|
+
for (const a of r.querySelectorAll("foreignObject > :first-child")) {
|
|
312
|
+
const o = [...a.children].filter((s) => s.localName === "div");
|
|
313
313
|
for (let s = t.start; s <= t.end && s < o.length; s++)
|
|
314
|
-
|
|
314
|
+
n.push(o[s]);
|
|
315
315
|
}
|
|
316
|
-
return
|
|
316
|
+
return n;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function Rt(r, t, e) {
|
|
319
319
|
if (r.kind !== "emphasis" && r.kind !== "motion" && r.effect === "zoom" && (r.dir === "in" || r.dir === "out")) {
|
|
320
|
-
const
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
from: q(!1,
|
|
324
|
-
to: q(!0,
|
|
320
|
+
const n = Ft(t);
|
|
321
|
+
if (n) {
|
|
322
|
+
const a = r.dir === "in" ? {
|
|
323
|
+
from: q(!1, n),
|
|
324
|
+
to: q(!0, n)
|
|
325
325
|
} : {
|
|
326
|
-
from: { opacity: 1, clipPath:
|
|
327
|
-
to: { opacity: 1, clipPath:
|
|
328
|
-
}, o = r.kind === "exit" ? [
|
|
326
|
+
from: { opacity: 1, clipPath: H(!1, n) },
|
|
327
|
+
to: { opacity: 1, clipPath: H(!0, n) }
|
|
328
|
+
}, o = r.kind === "exit" ? [a.to, a.from] : [a.from, a.to];
|
|
329
329
|
return ot(o);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
@@ -334,10 +334,10 @@ function Ft(r, t, e) {
|
|
|
334
334
|
function ot(r) {
|
|
335
335
|
const t = (e) => e.clipPath !== void 0 || e.maskSize !== void 0;
|
|
336
336
|
return r.some(t) ? r.map((e) => {
|
|
337
|
-
const
|
|
338
|
-
e.clipPath !== void 0 && (
|
|
339
|
-
for (const
|
|
340
|
-
return e.maskSize !== void 0 && (
|
|
337
|
+
const n = {};
|
|
338
|
+
e.clipPath !== void 0 && (n.clipPath = String(e.clipPath).replace(/ fill-box/g, ""));
|
|
339
|
+
for (const a of Tt) e[a] !== void 0 && (n[a] = e[a]);
|
|
340
|
+
return e.maskSize !== void 0 && (n.maskOrigin = "border-box", n.maskClip = "border-box"), e.offset !== void 0 && (n.offset = e.offset), n;
|
|
341
341
|
}) : null;
|
|
342
342
|
}
|
|
343
343
|
function V(r, t) {
|
|
@@ -357,7 +357,7 @@ function V(r, t) {
|
|
|
357
357
|
return `inset(${e}% 0 0 0)`;
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
-
const
|
|
360
|
+
const Yt = {
|
|
361
361
|
d: { origin: "center bottom", axis: "scaleY" },
|
|
362
362
|
u: { origin: "center top", axis: "scaleY" },
|
|
363
363
|
l: { origin: "left center", axis: "scaleX" },
|
|
@@ -367,8 +367,8 @@ const Ot = {
|
|
|
367
367
|
ld: { origin: "left bottom", axis: "scale" },
|
|
368
368
|
rd: { origin: "right bottom", axis: "scale" }
|
|
369
369
|
};
|
|
370
|
-
function
|
|
371
|
-
return (r ?
|
|
370
|
+
function Wt(r) {
|
|
371
|
+
return (r ? Yt[r] : void 0) ?? { origin: "center", axis: "scaleX" };
|
|
372
372
|
}
|
|
373
373
|
function nt(r, t) {
|
|
374
374
|
const e = Math.round(Math.sin(2.5 * Math.PI * t) * 1e4) / 1e4;
|
|
@@ -378,29 +378,29 @@ function nt(r, t) {
|
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
380
|
function st(r) {
|
|
381
|
-
var t, e,
|
|
381
|
+
var t, e, n, a, o, s, l, i, f, u;
|
|
382
382
|
switch (r.effect) {
|
|
383
383
|
case "appear":
|
|
384
384
|
return { from: { opacity: 0 }, to: { opacity: 1 } };
|
|
385
385
|
case "fly": {
|
|
386
|
-
const [
|
|
386
|
+
const [c, h] = Nt(r.dir);
|
|
387
387
|
return {
|
|
388
|
-
from: { opacity: 0, transform: `translate(${
|
|
388
|
+
from: { opacity: 0, transform: `translate(${c}%, ${h}%)` },
|
|
389
389
|
to: { opacity: 1, transform: "translate(0, 0)" }
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
392
|
case "zoom":
|
|
393
393
|
return r.dir === "in" ? { from: q(!1), to: q(!0) } : r.dir === "out" ? {
|
|
394
|
-
from: { opacity: 1, clipPath:
|
|
395
|
-
to: { opacity: 1, clipPath:
|
|
394
|
+
from: { opacity: 1, clipPath: H(!1) },
|
|
395
|
+
to: { opacity: 1, clipPath: H(!0) }
|
|
396
396
|
} : {
|
|
397
|
-
from: { opacity: 0, transform:
|
|
398
|
-
to: { opacity: 1, transform:
|
|
397
|
+
from: { opacity: 0, transform: L(((t = r.scale) == null ? void 0 : t.fromX) ?? 0, ((e = r.scale) == null ? void 0 : e.fromY) ?? 0) },
|
|
398
|
+
to: { opacity: 1, transform: L(((n = r.scale) == null ? void 0 : n.toX) ?? 1, ((a = r.scale) == null ? void 0 : a.toY) ?? 1) }
|
|
399
399
|
};
|
|
400
400
|
case "grow":
|
|
401
401
|
return {
|
|
402
|
-
from: { opacity: 1, transform: `${
|
|
403
|
-
to: { opacity: 1, transform: `${
|
|
402
|
+
from: { opacity: 1, transform: `${L(((o = r.scale) == null ? void 0 : o.fromX) ?? 0, ((s = r.scale) == null ? void 0 : s.fromY) ?? 0)} rotate(${((l = r.rotation) == null ? void 0 : l.from) ?? 0}deg)` },
|
|
403
|
+
to: { opacity: 1, transform: `${L(((i = r.scale) == null ? void 0 : i.toX) ?? 1, ((f = r.scale) == null ? void 0 : f.toY) ?? 1)} rotate(${((u = r.rotation) == null ? void 0 : u.to) ?? 90}deg)` }
|
|
404
404
|
};
|
|
405
405
|
case "spin":
|
|
406
406
|
return { from: { opacity: 0, transform: "rotate(-180deg) scale(0.4)" }, to: { opacity: 1, transform: "rotate(0) scale(1)" } };
|
|
@@ -413,13 +413,13 @@ function st(r) {
|
|
|
413
413
|
case "stretch": {
|
|
414
414
|
if (r.scale)
|
|
415
415
|
return {
|
|
416
|
-
from: { opacity: 0, transform:
|
|
417
|
-
to: { opacity: 1, transform:
|
|
416
|
+
from: { opacity: 0, transform: L(r.scale.fromX, r.scale.fromY) },
|
|
417
|
+
to: { opacity: 1, transform: L(r.scale.toX, r.scale.toY) }
|
|
418
418
|
};
|
|
419
|
-
const { origin:
|
|
419
|
+
const { origin: c, axis: h } = Wt(r.dir);
|
|
420
420
|
return {
|
|
421
|
-
from: { opacity: 1, transform: `${h}(0)`, transformOrigin:
|
|
422
|
-
to: { opacity: 1, transform: `${h}(1)`, transformOrigin:
|
|
421
|
+
from: { opacity: 1, transform: `${h}(0)`, transformOrigin: c },
|
|
422
|
+
to: { opacity: 1, transform: `${h}(1)`, transformOrigin: c }
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
425
|
case "blinds":
|
|
@@ -476,132 +476,132 @@ function st(r) {
|
|
|
476
476
|
return { from: { opacity: 0 }, to: { opacity: 1 } };
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
|
-
function
|
|
479
|
+
function Xt(r) {
|
|
480
480
|
const t = st({ ...r, kind: "entrance" });
|
|
481
481
|
return { from: t.to, to: t.from };
|
|
482
482
|
}
|
|
483
|
-
function
|
|
484
|
-
var t, e,
|
|
483
|
+
function Lt(r) {
|
|
484
|
+
var t, e, n, a;
|
|
485
485
|
switch (r.effect) {
|
|
486
486
|
case "spin":
|
|
487
487
|
return { from: { transform: "rotate(0)" }, to: { transform: "rotate(360deg)" } };
|
|
488
488
|
case "grow":
|
|
489
489
|
return {
|
|
490
|
-
from: { transform:
|
|
491
|
-
to: { transform:
|
|
490
|
+
from: { transform: L(((t = r.scale) == null ? void 0 : t.fromX) ?? 1, ((e = r.scale) == null ? void 0 : e.fromY) ?? 1) },
|
|
491
|
+
to: { transform: L(((n = r.scale) == null ? void 0 : n.toX) ?? 1.25, ((a = r.scale) == null ? void 0 : a.toY) ?? 1.25) }
|
|
492
492
|
};
|
|
493
493
|
default:
|
|
494
494
|
return { from: { opacity: 1 }, to: { opacity: 0.5 } };
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
|
-
function
|
|
498
|
-
return r.kind === "exit" ?
|
|
497
|
+
function Vt(r) {
|
|
498
|
+
return r.kind === "exit" ? Xt(r) : r.kind === "emphasis" ? Lt(r) : r.kind === "motion" ? { from: { opacity: 1 }, to: { opacity: 1 } } : st(r);
|
|
499
499
|
}
|
|
500
|
-
function
|
|
501
|
-
var
|
|
502
|
-
const e = [],
|
|
503
|
-
let o = !1, s = 0,
|
|
504
|
-
for (const
|
|
505
|
-
const h =
|
|
506
|
-
s = h,
|
|
507
|
-
const d = r.querySelector(`[data-el="${
|
|
500
|
+
function Dt(r, t) {
|
|
501
|
+
var i, f, u;
|
|
502
|
+
const e = [], n = [], a = [];
|
|
503
|
+
let o = !1, s = 0, l = 0;
|
|
504
|
+
for (const c of t) {
|
|
505
|
+
const h = c.trigger === "afterPrev" ? l + c.delayMs : c.trigger === "withPrev" ? s + c.delayMs : c.delayMs;
|
|
506
|
+
s = h, l = h + c.durationMs;
|
|
507
|
+
const d = r.querySelector(`[data-el="${c.target}"]`);
|
|
508
508
|
if (!d) continue;
|
|
509
|
-
if (
|
|
510
|
-
const
|
|
511
|
-
|
|
509
|
+
if (c.mediaCommand) {
|
|
510
|
+
const b = Ct(d, c.mediaCommand, h);
|
|
511
|
+
b && a.push(b);
|
|
512
512
|
continue;
|
|
513
513
|
}
|
|
514
|
-
|
|
515
|
-
const { from:
|
|
516
|
-
if (d.style.visibility = "visible",
|
|
517
|
-
const
|
|
518
|
-
|
|
514
|
+
c.kind === "exit" && n.push(d);
|
|
515
|
+
const { from: m, to: g } = Vt(c);
|
|
516
|
+
if (d.style.visibility = "visible", c.kind === "entrance" && (d.style.opacity = ""), c.effect === "fly" && (c.kind === "entrance" || c.kind === "exit")) {
|
|
517
|
+
const b = Ot(r, d, c.dir);
|
|
518
|
+
b && (c.kind === "entrance" ? m.transform = b : g.transform = b);
|
|
519
519
|
}
|
|
520
|
-
const
|
|
521
|
-
transform: `translate(${
|
|
522
|
-
offset: A > 0 ?
|
|
523
|
-
})) :
|
|
524
|
-
...Z(
|
|
525
|
-
offset:
|
|
526
|
-
})) :
|
|
527
|
-
...J(
|
|
528
|
-
offset:
|
|
529
|
-
})) :
|
|
530
|
-
...et(
|
|
531
|
-
offset:
|
|
532
|
-
})) :
|
|
520
|
+
const k = (i = c.motionPath) == null ? void 0 : i.reduce((b, [p, R], N, y) => (N === 0 ? b.push(0) : b.push(b[N - 1] + Math.hypot(p - y[N - 1][0], R - y[N - 1][1])), b), []), A = (k == null ? void 0 : k[k.length - 1]) ?? 0, I = (f = c.motionPath) != null && f.length ? c.motionPath.map(([b, p], R) => ({
|
|
521
|
+
transform: `translate(${b}px, ${p}px)`,
|
|
522
|
+
offset: A > 0 ? k[R] / A : R / (c.motionPath.length - 1)
|
|
523
|
+
})) : c.effect === "randomBar" ? Array.from({ length: 13 }, (b, p) => ({
|
|
524
|
+
...Z(c.dir, c.kind === "exit" ? 1 - p / 12 : p / 12),
|
|
525
|
+
offset: p / 12
|
|
526
|
+
})) : c.effect === "strips" ? Array.from({ length: 21 }, (b, p) => ({
|
|
527
|
+
...J(c.dir, c.kind === "exit" ? 1 - p / 20 : p / 20),
|
|
528
|
+
offset: p / 20
|
|
529
|
+
})) : c.effect === "wheel" ? Array.from({ length: 73 }, (b, p) => ({
|
|
530
|
+
...et(c.dir, c.kind === "exit" ? 1 - p / 72 : p / 72),
|
|
531
|
+
offset: p / 72
|
|
532
|
+
})) : c.effect === "circle" || c.effect === "diamond" || c.effect === "plus" && c.dir !== "in" ? Array.from({ length: 37 }, (b, p) => ({
|
|
533
533
|
...tt(
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
534
|
+
c.effect,
|
|
535
|
+
c.dir,
|
|
536
|
+
c.kind === "exit" ? 1 - p / 36 : p / 36
|
|
537
537
|
),
|
|
538
|
-
offset:
|
|
539
|
-
})) :
|
|
540
|
-
...rt(
|
|
541
|
-
offset:
|
|
542
|
-
})) :
|
|
543
|
-
...nt(
|
|
544
|
-
offset:
|
|
545
|
-
})) :
|
|
538
|
+
offset: p / 36
|
|
539
|
+
})) : c.effect === "dissolve" ? Array.from({ length: 9 }, (b, p) => ({
|
|
540
|
+
...rt(c.kind === "exit" ? 1 - p / 8 : p / 8, c.target),
|
|
541
|
+
offset: p / 8
|
|
542
|
+
})) : c.effect === "swivel" && (c.kind === "entrance" || c.kind === "exit") ? Array.from({ length: 41 }, (b, p) => ({
|
|
543
|
+
...nt(c.dir, c.kind === "exit" ? 1 - p / 40 : p / 40),
|
|
544
|
+
offset: p / 40
|
|
545
|
+
})) : c.effect === "bounce" && c.kind === "entrance" ? [
|
|
546
546
|
{ opacity: 0, transform: "translateY(-60%)", offset: 0 },
|
|
547
547
|
{ opacity: 1, transform: "translateY(10%)", offset: 0.5 },
|
|
548
548
|
{ opacity: 1, transform: "translateY(-8%)", offset: 0.7 },
|
|
549
549
|
{ opacity: 1, transform: "translateY(3%)", offset: 0.85 },
|
|
550
550
|
{ opacity: 1, transform: "translateY(0)", offset: 1 }
|
|
551
|
-
] : [
|
|
551
|
+
] : [m, g];
|
|
552
552
|
try {
|
|
553
|
-
const
|
|
554
|
-
duration:
|
|
553
|
+
const b = (u = c.motionPath) != null && u.length || c.effect === "randomBar" || c.effect === "strips" || c.effect === "wheel" || c.effect === "circle" || c.effect === "diamond" || c.effect === "plus" || c.effect === "dissolve" || c.effect === "bounce" || c.effect === "swivel" ? "linear" : c.effect === "appear" && c.kind === "entrance" ? "steps(1, start)" : c.effect === "appear" && c.kind === "exit" ? "steps(1, end)" : "cubic-bezier(0.25, 0.46, 0.45, 0.94)", p = d.animate(I, {
|
|
554
|
+
duration: c.durationMs,
|
|
555
555
|
delay: h,
|
|
556
556
|
// 路径动画在 PowerPoint 里是匀速,不能套入场用的缓动
|
|
557
|
-
easing:
|
|
557
|
+
easing: b,
|
|
558
558
|
fill: "both"
|
|
559
559
|
});
|
|
560
|
-
|
|
560
|
+
c.kind === "exit" && p.finished.then(() => {
|
|
561
561
|
o || (d.style.visibility = "hidden");
|
|
562
562
|
}).catch(() => {
|
|
563
|
-
}), e.push(
|
|
563
|
+
}), e.push(p);
|
|
564
564
|
const R = ot(I);
|
|
565
565
|
if (!R || typeof d.querySelectorAll != "function") continue;
|
|
566
|
-
const N =
|
|
567
|
-
for (const
|
|
568
|
-
if (!(
|
|
569
|
-
const P = N.length ?
|
|
570
|
-
P && e.push(
|
|
571
|
-
duration:
|
|
566
|
+
const N = It(d, c.paragraphRange), y = N.length ? N : d.querySelectorAll("foreignObject > :first-child");
|
|
567
|
+
for (const v of y) {
|
|
568
|
+
if (!(v instanceof HTMLElement)) continue;
|
|
569
|
+
const P = N.length ? Rt(c, v, I) : R;
|
|
570
|
+
P && e.push(v.animate(P, {
|
|
571
|
+
duration: c.durationMs,
|
|
572
572
|
delay: h,
|
|
573
|
-
easing:
|
|
573
|
+
easing: b,
|
|
574
574
|
fill: "both"
|
|
575
575
|
}));
|
|
576
576
|
}
|
|
577
577
|
} catch {
|
|
578
|
-
Object.assign(d.style, I[I.length - 1] ??
|
|
578
|
+
Object.assign(d.style, I[I.length - 1] ?? g), c.kind === "exit" && (d.style.visibility = "hidden");
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
return {
|
|
582
582
|
animations: e,
|
|
583
583
|
cancel: () => {
|
|
584
|
-
o = !0, e.forEach((
|
|
584
|
+
o = !0, e.forEach((c) => {
|
|
585
585
|
try {
|
|
586
|
-
|
|
586
|
+
c.finish();
|
|
587
587
|
} catch {
|
|
588
588
|
}
|
|
589
|
-
}),
|
|
590
|
-
for (const
|
|
589
|
+
}), a.forEach((c) => c.cancel());
|
|
590
|
+
for (const c of n) c.style.visibility = "hidden";
|
|
591
591
|
},
|
|
592
592
|
// 等全部视觉与媒体调用落定后再报告:媒体失败不能让批次提前收尾、截断仍在播的视觉动画。
|
|
593
593
|
finished: Promise.all([
|
|
594
|
-
Promise.all(e.map((
|
|
594
|
+
Promise.all(e.map((c) => c.finished.catch(() => {
|
|
595
595
|
}))),
|
|
596
|
-
Promise.allSettled(
|
|
597
|
-
]).then(([,
|
|
598
|
-
const h =
|
|
596
|
+
Promise.allSettled(a.map((c) => c.finished))
|
|
597
|
+
]).then(([, c]) => {
|
|
598
|
+
const h = c.find((d) => d.status === "rejected");
|
|
599
599
|
if (h) throw h.reason;
|
|
600
600
|
})
|
|
601
601
|
};
|
|
602
602
|
}
|
|
603
603
|
function ht(r, t) {
|
|
604
|
-
const e = r.dir ??
|
|
604
|
+
const e = r.dir ?? Mt(r.type) ?? "", n = (o, s) => `translate(${o}, ${s})`, a = () => {
|
|
605
605
|
const o = {
|
|
606
606
|
l: ["-100%", "0"],
|
|
607
607
|
r: ["100%", "0"],
|
|
@@ -629,20 +629,20 @@ function ht(r, t) {
|
|
|
629
629
|
];
|
|
630
630
|
case "push":
|
|
631
631
|
case "pull": {
|
|
632
|
-
const [o, s] =
|
|
633
|
-
return t ? [{ transform:
|
|
632
|
+
const [o, s] = a(), l = r.type === "pull" ? -1 : 1, i = (f) => f === "0" ? "0" : `${-parseFloat(f) * l}%`;
|
|
633
|
+
return t ? [{ transform: n(l > 0 ? o : i(o), l > 0 ? s : i(s)) }, { transform: "translate(0,0)" }] : [{ transform: "translate(0,0)" }, { transform: n(i(o), i(s)) }];
|
|
634
634
|
}
|
|
635
635
|
case "cover": {
|
|
636
|
-
const [o, s] =
|
|
637
|
-
return t ? [{ transform:
|
|
636
|
+
const [o, s] = a();
|
|
637
|
+
return t ? [{ transform: n(o, s) }, { transform: "translate(0,0)" }] : [{ opacity: 1 }, { opacity: 1 }];
|
|
638
638
|
}
|
|
639
639
|
case "wipe": {
|
|
640
640
|
const o = V(e || "d", !0), s = V(e || "d", !1);
|
|
641
641
|
return t ? [{ clipPath: o }, { clipPath: s }] : [{ opacity: 1 }, { opacity: 1 }];
|
|
642
642
|
}
|
|
643
643
|
case "split": {
|
|
644
|
-
const o = e.startsWith("vert"), s = e.endsWith("out"),
|
|
645
|
-
return t ? s ? [{ clipPath:
|
|
644
|
+
const o = e.startsWith("vert"), s = e.endsWith("out"), l = o ? "inset(0 50% 0 50%)" : "inset(50% 0 50% 0)", i = "inset(0 0 0 0)";
|
|
645
|
+
return t ? s ? [{ clipPath: l }, { clipPath: i }] : [{ clipPath: i }, { clipPath: i }] : [{ clipPath: i }, { clipPath: l }];
|
|
646
646
|
}
|
|
647
647
|
case "zoom":
|
|
648
648
|
return t ? [{ opacity: 0, transform: e === "out" ? "scale(1.4)" : "scale(0.6)" }, { opacity: 1, transform: "scale(1)" }] : [{ opacity: 1 }, { opacity: 0 }];
|
|
@@ -663,8 +663,8 @@ function ht(r, t) {
|
|
|
663
663
|
return t ? [{ clipPath: `circle(0% at ${s})` }, { clipPath: `circle(145% at ${s})` }] : [{ opacity: 1 }, { opacity: 1 }];
|
|
664
664
|
}
|
|
665
665
|
case "vortex": {
|
|
666
|
-
const [o, s] =
|
|
667
|
-
return t ? [{ opacity: 0, transformOrigin: `${o === "0" ? "50%" : o.startsWith("-") ? "0%" : "100%"} ${s === "0" ? "50%" : s.startsWith("-") ? "0%" : "100%"}`, transform: `scale(0.2) rotate(${
|
|
666
|
+
const [o, s] = a(), l = e === "r" || e === "d" ? 180 : -180;
|
|
667
|
+
return t ? [{ opacity: 0, transformOrigin: `${o === "0" ? "50%" : o.startsWith("-") ? "0%" : "100%"} ${s === "0" ? "50%" : s.startsWith("-") ? "0%" : "100%"}`, transform: `scale(0.2) rotate(${l}deg)` }, { opacity: 1, transform: "none" }] : [{ opacity: 1 }, { opacity: 0 }];
|
|
668
668
|
}
|
|
669
669
|
case "honeycomb":
|
|
670
670
|
return t ? [{ opacity: 0, transform: "scale(0.85) rotate(-6deg)" }, { opacity: 1, transform: "none" }] : [{ opacity: 1, transform: "none" }, { opacity: 0, transform: "scale(1.1)" }];
|
|
@@ -677,8 +677,8 @@ function ht(r, t) {
|
|
|
677
677
|
case "flash":
|
|
678
678
|
return t ? [{ opacity: 0, filter: "brightness(3)" }, { opacity: 1, filter: "brightness(1)" }] : [{ opacity: 1, filter: "brightness(1)" }, { opacity: 0, filter: "brightness(3)" }];
|
|
679
679
|
case "reveal": {
|
|
680
|
-
const [o, s] =
|
|
681
|
-
return t ? [{ opacity: 0, transform:
|
|
680
|
+
const [o, s] = a();
|
|
681
|
+
return t ? [{ opacity: 0, transform: n(o, s) }, { opacity: 1, transform: "translate(0,0)" }] : [{ opacity: 1 }, { opacity: 0 }];
|
|
682
682
|
}
|
|
683
683
|
case "wheelReverse":
|
|
684
684
|
return t ? [{ opacity: 0, transform: "scale(1.3) rotate(20deg)" }, { opacity: 1, transform: "none" }] : [{ opacity: 1 }, { opacity: 0 }];
|
|
@@ -698,13 +698,13 @@ function ht(r, t) {
|
|
|
698
698
|
];
|
|
699
699
|
}
|
|
700
700
|
case "prism": {
|
|
701
|
-
const o = e === "u" || e === "d", s = e === "r" || e === "d" ? -1 : 1,
|
|
701
|
+
const o = e === "u" || e === "d", s = e === "r" || e === "d" ? -1 : 1, l = (i) => o ? `rotateX(${i}deg)` : `rotateY(${i}deg)`;
|
|
702
702
|
return t ? [
|
|
703
|
-
{ opacity: 0, transform: `perspective(1400px) ${
|
|
704
|
-
{ opacity: 1, transform: `perspective(1400px) ${
|
|
703
|
+
{ opacity: 0, transform: `perspective(1400px) ${l(s * -70)}` },
|
|
704
|
+
{ opacity: 1, transform: `perspective(1400px) ${l(0)}` }
|
|
705
705
|
] : [
|
|
706
|
-
{ opacity: 1, transform: `perspective(1400px) ${
|
|
707
|
-
{ opacity: 0, transform: `perspective(1400px) ${
|
|
706
|
+
{ opacity: 1, transform: `perspective(1400px) ${l(0)}` },
|
|
707
|
+
{ opacity: 0, transform: `perspective(1400px) ${l(s * 70)}` }
|
|
708
708
|
];
|
|
709
709
|
}
|
|
710
710
|
case "ferris": {
|
|
@@ -719,18 +719,18 @@ function ht(r, t) {
|
|
|
719
719
|
}
|
|
720
720
|
case "gallery":
|
|
721
721
|
case "conveyor": {
|
|
722
|
-
const o = r.type === "conveyor" ? 25 : 12, s = e.includes("l") ? "-100%" : "100%",
|
|
722
|
+
const o = r.type === "conveyor" ? 25 : 12, s = e.includes("l") ? "-100%" : "100%", l = e.includes("l") ? "100%" : "-100%";
|
|
723
723
|
return t ? [
|
|
724
724
|
{ transform: `perspective(1600px) translateX(${s}) rotateY(${o}deg)` },
|
|
725
725
|
{ transform: "perspective(1600px) translateX(0) rotateY(0)" }
|
|
726
726
|
] : [
|
|
727
727
|
{ transform: "perspective(1600px) translateX(0) rotateY(0)" },
|
|
728
|
-
{ transform: `perspective(1600px) translateX(${
|
|
728
|
+
{ transform: `perspective(1600px) translateX(${l}) rotateY(${-o}deg)` }
|
|
729
729
|
];
|
|
730
730
|
}
|
|
731
731
|
case "pan": {
|
|
732
|
-
const [o, s] =
|
|
733
|
-
return t ? [{ transform:
|
|
732
|
+
const [o, s] = a(), l = (i) => i === "0" ? "0" : `${-parseFloat(i)}%`;
|
|
733
|
+
return t ? [{ transform: n(o, s) }, { transform: "translate(0,0)" }] : [{ transform: "translate(0,0)" }, { transform: n(l(o), l(s)) }];
|
|
734
734
|
}
|
|
735
735
|
case "flythrough":
|
|
736
736
|
return t ? [{ opacity: 0, transform: `perspective(1000px) scale(${e === "out" ? 2.2 : 0.15})` }, { opacity: 1, transform: "none" }] : [{ opacity: 1, transform: "none" }, { opacity: 0, transform: `perspective(1000px) scale(${e === "out" ? 0.15 : 2.2})` }];
|
|
@@ -763,32 +763,32 @@ function ht(r, t) {
|
|
|
763
763
|
return t ? [{ opacity: 0 }, { opacity: 1 }] : [{ opacity: 1 }, { opacity: 0 }];
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
|
-
function
|
|
766
|
+
function zt(r, t) {
|
|
767
767
|
const e = /* @__PURE__ */ new Map();
|
|
768
|
-
r.querySelectorAll("[data-el]").forEach((
|
|
769
|
-
const o =
|
|
770
|
-
(o.width > 0 || o.height > 0) && e.set(
|
|
768
|
+
r.querySelectorAll("[data-el]").forEach((a) => {
|
|
769
|
+
const o = a.getBoundingClientRect();
|
|
770
|
+
(o.width > 0 || o.height > 0) && e.set(a.getAttribute("data-el") ?? "", o);
|
|
771
771
|
});
|
|
772
|
-
const
|
|
773
|
-
return t.querySelectorAll("[data-el]").forEach((
|
|
774
|
-
const o = e.get(
|
|
772
|
+
const n = [];
|
|
773
|
+
return t.querySelectorAll("[data-el]").forEach((a) => {
|
|
774
|
+
const o = e.get(a.getAttribute("data-el") ?? "");
|
|
775
775
|
if (!o) return;
|
|
776
|
-
const s =
|
|
777
|
-
s.width <= 0 && s.height <= 0 ||
|
|
778
|
-
}),
|
|
776
|
+
const s = a.getBoundingClientRect();
|
|
777
|
+
s.width <= 0 && s.height <= 0 || n.push({ node: a, from: o, to: s });
|
|
778
|
+
}), n;
|
|
779
779
|
}
|
|
780
780
|
const G = "http://www.w3.org/2000/svg", dt = ["transform", "transform-origin", "transform-box", "opacity", "clip-path", "filter", "visibility"];
|
|
781
|
-
class
|
|
781
|
+
class Bt {
|
|
782
782
|
constructor(t, e) {
|
|
783
783
|
this.pres = t, this.showComments = e, this.host = document.createElement("div"), this.svg = document.createElementNS(G, "svg"), this.animations = [], this.host.style.cssText = `position:fixed;left:-20000px;top:0;width:${t.width}px;height:${t.height}px;pointer-events:none;contain:layout style;`, this.host.setAttribute("aria-hidden", "true"), this.svg.setAttribute("xmlns", G), this.svg.setAttribute("width", String(t.width)), this.svg.setAttribute("height", String(t.height)), this.svg.setAttribute("viewBox", `0 0 ${t.width} ${t.height}`), this.host.append(this.svg), document.body.append(this.host);
|
|
784
784
|
}
|
|
785
785
|
async page(t, e) {
|
|
786
|
-
const
|
|
787
|
-
if (/<image\b[^>]*\bhref="(?:blob:|https?:)/.test(
|
|
788
|
-
const
|
|
789
|
-
if (
|
|
786
|
+
const n = await xt(this.pres, t, e, { showComments: this.showComments });
|
|
787
|
+
if (/<image\b[^>]*\bhref="(?:blob:|https?:)/.test(n) || /@font-face\{[^}]*src:url\(['"]?(?:blob:|https?:)/.test(n)) throw new Error("视频资源内联失败");
|
|
788
|
+
const a = new DOMParser().parseFromString(n, "image/svg+xml");
|
|
789
|
+
if (a.querySelector("parsererror")) throw new Error("视频页面 SVG 无效");
|
|
790
790
|
const o = document.createElementNS(G, "g");
|
|
791
|
-
return o.style.transformBox = "fill-box", o.style.transformOrigin = "center", o.append(document.importNode(
|
|
791
|
+
return o.style.transformBox = "fill-box", o.style.transformOrigin = "center", o.append(document.importNode(a.documentElement, !0)), this.svg.append(o), o;
|
|
792
792
|
}
|
|
793
793
|
pause(t) {
|
|
794
794
|
for (const e of t)
|
|
@@ -796,97 +796,97 @@ class Vt {
|
|
|
796
796
|
return this.animations.push(...t), [...t];
|
|
797
797
|
}
|
|
798
798
|
group(t, e) {
|
|
799
|
-
return this.pause(
|
|
799
|
+
return this.pause(Dt(t, e).animations);
|
|
800
800
|
}
|
|
801
|
-
transition(t, e,
|
|
802
|
-
const
|
|
803
|
-
if (!
|
|
804
|
-
const o = [], s = (
|
|
805
|
-
const f =
|
|
801
|
+
transition(t, e, n) {
|
|
802
|
+
const a = n.transition;
|
|
803
|
+
if (!a || a.type === "none") return [];
|
|
804
|
+
const o = [], s = (l, i) => {
|
|
805
|
+
const f = l.animate(i, { duration: a.durationMs, easing: "ease-in-out", fill: "both" });
|
|
806
806
|
f.finished.catch(() => {
|
|
807
807
|
}), o.push(f);
|
|
808
808
|
};
|
|
809
|
-
if (
|
|
810
|
-
const
|
|
811
|
-
for (const { node: f, from: u, to:
|
|
812
|
-
for (const f of t.querySelectorAll("[data-el]")) s(f,
|
|
813
|
-
for (const f of e.querySelectorAll("[data-el]"))
|
|
809
|
+
if (a.type === "morph") {
|
|
810
|
+
const l = zt(t, e), i = new Set(l.map((f) => f.node.getAttribute("data-el")));
|
|
811
|
+
for (const { node: f, from: u, to: c } of l) s(f, [{ transformOrigin: "left top", transform: `translate(${u.left - c.left}px,${u.top - c.top}px) scale(${c.width ? u.width / c.width : 1},${c.height ? u.height / c.height : 1})` }, { transformOrigin: "left top", transform: "none" }]);
|
|
812
|
+
for (const f of t.querySelectorAll("[data-el]")) s(f, i.has(f.getAttribute("data-el")) ? [{ opacity: 0 }, { opacity: 0 }] : [{ opacity: 1 }, { opacity: 0 }]);
|
|
813
|
+
for (const f of e.querySelectorAll("[data-el]")) i.has(f.getAttribute("data-el")) || s(f, [{ opacity: 0 }, { opacity: 1 }]);
|
|
814
814
|
} else
|
|
815
|
-
s(t, ht(
|
|
815
|
+
s(t, ht(a, !1)), s(e, ht(a, !0));
|
|
816
816
|
return this.pause(o);
|
|
817
817
|
}
|
|
818
818
|
settle(t) {
|
|
819
819
|
for (const e of t) {
|
|
820
|
-
const
|
|
821
|
-
if (
|
|
822
|
-
e.currentTime = Number(
|
|
823
|
-
const o = getComputedStyle(
|
|
824
|
-
for (const s of dt)
|
|
820
|
+
const n = e.effect, a = n == null ? void 0 : n.target;
|
|
821
|
+
if (n && a) {
|
|
822
|
+
e.currentTime = Number(n.getComputedTiming().endTime);
|
|
823
|
+
const o = getComputedStyle(a);
|
|
824
|
+
for (const s of dt) a.style.setProperty(s, o.getPropertyValue(s));
|
|
825
825
|
}
|
|
826
826
|
e.cancel(), this.animations.splice(this.animations.indexOf(e), 1);
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
|
-
async draw(t, e,
|
|
830
|
-
const
|
|
829
|
+
async draw(t, e, n) {
|
|
830
|
+
const a = this.svg.cloneNode(!0), o = [this.svg, ...this.svg.querySelectorAll("*")], s = [a, ...a.querySelectorAll("*")], l = new Set(this.animations.map((f) => {
|
|
831
831
|
var u;
|
|
832
832
|
return (u = f.effect) == null ? void 0 : u.target;
|
|
833
833
|
}));
|
|
834
|
-
for (let f = 0; f < o.length; f++) if (
|
|
834
|
+
for (let f = 0; f < o.length; f++) if (l.has(o[f])) {
|
|
835
835
|
const u = getComputedStyle(o[f]);
|
|
836
|
-
for (const
|
|
836
|
+
for (const c of dt) s[f].style.setProperty(c, u.getPropertyValue(c));
|
|
837
837
|
}
|
|
838
|
-
const
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
}), t.fillStyle = "#fff", t.fillRect(0, 0, e,
|
|
838
|
+
const i = new Image();
|
|
839
|
+
i.decoding = "sync", await new Promise((f, u) => {
|
|
840
|
+
i.onload = () => f(), i.onerror = () => u(new Error("视频帧 SVG 渲染失败")), i.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(a))}`;
|
|
841
|
+
}), t.fillStyle = "#fff", t.fillRect(0, 0, e, n), t.drawImage(i, 0, 0, e, n);
|
|
842
842
|
}
|
|
843
843
|
dispose() {
|
|
844
844
|
for (const t of this.animations) t.cancel();
|
|
845
845
|
this.animations.length = 0, this.host.remove();
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
-
const
|
|
848
|
+
const vt = (r) => new TextEncoder().encode(r);
|
|
849
849
|
function at(r, t = Math.max(1, Math.ceil(Math.log2(r + 1) / 8))) {
|
|
850
850
|
const e = new Uint8Array(t);
|
|
851
|
-
for (let
|
|
852
|
-
e[
|
|
851
|
+
for (let n = t - 1; n >= 0; n--)
|
|
852
|
+
e[n] = r % 256, r = Math.floor(r / 256);
|
|
853
853
|
return e;
|
|
854
854
|
}
|
|
855
|
-
function
|
|
856
|
-
const t = new Uint8Array(r.reduce((
|
|
855
|
+
function _t(r) {
|
|
856
|
+
const t = new Uint8Array(r.reduce((n, a) => n + a.length, 0));
|
|
857
857
|
let e = 0;
|
|
858
|
-
for (const
|
|
859
|
-
t.set(
|
|
858
|
+
for (const n of r)
|
|
859
|
+
t.set(n, e), e += n.length;
|
|
860
860
|
return t;
|
|
861
861
|
}
|
|
862
|
-
function
|
|
862
|
+
function E(r, ...t) {
|
|
863
863
|
const e = t.reduce((o, s) => o + s.length, 0);
|
|
864
|
-
let
|
|
865
|
-
for (; e >= 2 ** (7 *
|
|
866
|
-
const
|
|
867
|
-
return
|
|
864
|
+
let n = 1;
|
|
865
|
+
for (; e >= 2 ** (7 * n) - 1; ) n++;
|
|
866
|
+
const a = at(e, n);
|
|
867
|
+
return a[0] |= 1 << 8 - n, _t([at(r), a, ...t]);
|
|
868
868
|
}
|
|
869
|
-
const
|
|
869
|
+
const x = (r, t) => E(r, at(t)), B = (r, t) => E(r, vt(t));
|
|
870
870
|
function mt(r, t) {
|
|
871
871
|
const e = new Uint8Array(8);
|
|
872
|
-
return new DataView(e.buffer).setFloat64(0, t),
|
|
872
|
+
return new DataView(e.buffer).setFloat64(0, t), E(r, e);
|
|
873
873
|
}
|
|
874
|
-
class
|
|
875
|
-
constructor(t, e,
|
|
876
|
-
if (this.width = t, this.height = e, this.fps =
|
|
874
|
+
class qt {
|
|
875
|
+
constructor(t, e, n, a, o) {
|
|
876
|
+
if (this.width = t, this.height = e, this.fps = n, this.codec = a, this.audio = o, this.clusters = [], this.last = -1, this.audioLast = -1, this.audioBlocks = 0, this.duration = 0, this.length = 0, this.closed = !1, ![t, e, n].every((s) => Number.isInteger(s) && s > 0) || t * e > 8388608 || n > 60) throw new Error("WebM 视频尺寸或帧率无效");
|
|
877
877
|
if (o && (!Number.isInteger(o.sampleRate) || o.sampleRate <= 0)) throw new Error("WebM 音频采样率无效");
|
|
878
878
|
}
|
|
879
879
|
clusterFor(t, e) {
|
|
880
|
-
let
|
|
881
|
-
return (!
|
|
880
|
+
let n = this.clusters[this.clusters.length - 1];
|
|
881
|
+
return (!n || t - n.time > 32767 || e && t - n.time >= 1e3 || t - n.time >= 3e4) && (n = { time: t, blocks: [], key: e }, this.clusters.push(n)), n;
|
|
882
882
|
}
|
|
883
|
-
addFrame(t, e,
|
|
883
|
+
addFrame(t, e, n, a) {
|
|
884
884
|
if (this.closed) throw new Error("WebM 已结束");
|
|
885
|
-
if (!Number.isSafeInteger(e) || e <= this.last || e < 0 || !Number.isSafeInteger(
|
|
885
|
+
if (!Number.isSafeInteger(e) || e <= this.last || e < 0 || !Number.isSafeInteger(n) || n <= 0) throw new Error("WebM 帧时间必须严格递增");
|
|
886
886
|
if (!t.length || t.length > 32 * 1024 * 1024 || this.length + t.length > 256 * 1024 * 1024) throw new Error("WebM 视频超过导出大小限制");
|
|
887
|
-
if (!this.clusters.length && !
|
|
888
|
-
const o = Math.round(e / 1e3), s = this.clusterFor(o,
|
|
889
|
-
|
|
887
|
+
if (!this.clusters.length && !a) throw new Error("WebM 第一帧必须是关键帧");
|
|
888
|
+
const o = Math.round(e / 1e3), s = this.clusterFor(o, a), l = new Uint8Array(4);
|
|
889
|
+
l[0] = 129, new DataView(l.buffer).setInt16(1, o - s.time), l[3] = a ? 128 : 0, s.blocks.push(E(163, l, t)), this.length += t.length, this.last = e, this.duration = (e + n) / 1e3;
|
|
890
890
|
}
|
|
891
891
|
/** Opus 音频块:时间戳毫秒、流内严格递增;与视频块按簇交错 */
|
|
892
892
|
addAudio(t, e) {
|
|
@@ -894,151 +894,204 @@ class Bt {
|
|
|
894
894
|
if (!this.audio) throw new Error("WebM 未声明音频轨");
|
|
895
895
|
if (!Number.isSafeInteger(e) || e < 0 || e <= this.audioLast) throw new Error("WebM 音频时间必须严格递增");
|
|
896
896
|
if (!t.length || t.length > 1024 * 1024) throw new Error("WebM 音频块为空或超限");
|
|
897
|
-
const
|
|
898
|
-
o[0] = 130, new DataView(o.buffer).setInt16(1, Math.max(0,
|
|
897
|
+
const n = Math.round(e), a = this.clusterFor(n, !1), o = new Uint8Array(4);
|
|
898
|
+
o[0] = 130, new DataView(o.buffer).setInt16(1, Math.max(0, n - a.time)), a.blocks.push(E(163, o, t)), this.audioBlocks++, this.audioLast = e, this.length += t.length;
|
|
899
899
|
}
|
|
900
900
|
finish() {
|
|
901
901
|
if (this.closed) throw new Error("WebM 已结束");
|
|
902
902
|
if (!this.clusters.length) throw new Error("没有可导出的视频帧");
|
|
903
903
|
if (this.audio && !this.audioBlocks) throw new Error("声明了音频轨但没有音频块");
|
|
904
904
|
this.closed = !0;
|
|
905
|
-
const t =
|
|
905
|
+
const t = E(440786851, x(17030, 1), x(17143, 1), x(17138, 4), x(17139, 8), B(17026, "webm"), x(17031, 4), x(17029, 2)), e = E(357149030, x(2807729, 1e6), mt(17545, this.duration), B(19840, "Web-PPT"), B(22337, "Web-PPT")), a = [E(174, x(215, 1), x(29637, 1), x(131, 1), x(156, 0), B(134, `V_${this.codec}`), x(2352003, Math.round(1e9 / this.fps)), E(224, x(176, this.width), x(186, this.height)))];
|
|
906
906
|
if (this.audio) {
|
|
907
907
|
const u = new Uint8Array(19);
|
|
908
|
-
u.set(
|
|
908
|
+
u.set(vt("OpusHead"), 0), u[8] = 1, u[9] = this.audio.channels, new DataView(u.buffer).setUint16(10, 312, !0), new DataView(u.buffer).setUint32(12, this.audio.sampleRate, !0), a.push(E(
|
|
909
909
|
174,
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
910
|
+
x(215, 2),
|
|
911
|
+
x(29637, 2),
|
|
912
|
+
x(131, 2),
|
|
913
|
+
x(156, 0),
|
|
914
|
+
B(134, "A_OPUS"),
|
|
915
|
+
E(25506, u),
|
|
916
|
+
E(225, mt(181, this.audio.sampleRate), x(159, this.audio.channels))
|
|
917
917
|
));
|
|
918
918
|
}
|
|
919
|
-
const o =
|
|
920
|
-
let
|
|
919
|
+
const o = E(374648427, ...a), s = [], l = [];
|
|
920
|
+
let i = e.length + o.length;
|
|
921
921
|
for (const u of this.clusters) {
|
|
922
|
-
const
|
|
923
|
-
u.key &&
|
|
922
|
+
const c = E(524531317, x(231, u.time), ...u.blocks);
|
|
923
|
+
u.key && l.push(E(187, x(179, u.time), E(183, x(247, 1), x(241, i)))), s.push(c), i += c.length;
|
|
924
924
|
}
|
|
925
|
-
const f =
|
|
925
|
+
const f = E(408125543, e, o, ...s, E(475249515, ...l));
|
|
926
926
|
return this.clusters.length = 0, new Blob([t.buffer, f.buffer], { type: "video/webm" });
|
|
927
927
|
}
|
|
928
928
|
}
|
|
929
929
|
function _(r) {
|
|
930
|
-
let t = 0, e = 0,
|
|
931
|
-
for (const
|
|
932
|
-
if (![
|
|
933
|
-
t = (
|
|
930
|
+
let t = 0, e = 0, n = 0;
|
|
931
|
+
for (const a of r) {
|
|
932
|
+
if (![a.delayMs, a.durationMs].every((o) => Number.isFinite(o) && o >= 0 && o <= 36e5)) throw new Error("视频动画时长无效");
|
|
933
|
+
t = (a.trigger === "afterPrev" ? e : a.trigger === "withPrev" ? t : 0) + a.delayMs, e = t + a.durationMs, n = Math.max(n, e);
|
|
934
934
|
}
|
|
935
|
-
return
|
|
935
|
+
return n;
|
|
936
936
|
}
|
|
937
|
-
function
|
|
938
|
-
const e = t.fps ?? 24,
|
|
939
|
-
if (!Number.isInteger(e) || e < 1 || e > 60 || !Number.isFinite(
|
|
940
|
-
const s = Math.round(r.width *
|
|
941
|
-
if (![s,
|
|
942
|
-
const
|
|
943
|
-
if (!Number.isFinite(
|
|
937
|
+
function Ht(r, t) {
|
|
938
|
+
const e = t.fps ?? 24, n = t.scale ?? 1, a = t.slideDurationMs ?? 3e3, o = t.clickDelayMs ?? 700;
|
|
939
|
+
if (!Number.isInteger(e) || e < 1 || e > 60 || !Number.isFinite(n) || n <= 0 || ![a, o].every((h) => Number.isFinite(h) && h >= 0 && h <= 36e5)) throw new Error("视频帧率、倍率或停留时长无效");
|
|
940
|
+
const s = Math.round(r.width * n), l = Math.round(r.height * n);
|
|
941
|
+
if (![s, l].every((h) => Number.isFinite(h) && h > 0 && h <= 4096) || s * l > 8388608) throw new Error("视频尺寸需要在 4096 边长、800 万像素以内");
|
|
942
|
+
const i = t.bitrate ?? Math.max(1e6, s * l * e * 0.15);
|
|
943
|
+
if (!Number.isFinite(i) || i < 1e4 || i > 1e8) throw new Error("视频码率无效");
|
|
944
944
|
const f = (h) => Math.max(1, Math.ceil(h * e / 1e3)), u = r.slides.flatMap((h, d) => {
|
|
945
|
-
var A, I,
|
|
945
|
+
var A, I, b;
|
|
946
946
|
if (t.skipHidden && h.hidden) return [];
|
|
947
|
-
const
|
|
948
|
-
if (![
|
|
949
|
-
return [{ slide: h, slideNumber: d + 1, groups:
|
|
950
|
-
}),
|
|
947
|
+
const m = t.animations === !1 ? [] : kt(h.animations), g = t.transitions !== !1 && ((A = h.transition) == null ? void 0 : A.type) !== "none" ? ((I = h.transition) == null ? void 0 : I.durationMs) ?? 0 : 0, k = ((b = h.transition) == null ? void 0 : b.advanceAfterMs) ?? a;
|
|
948
|
+
if (![k, g].every((p) => Number.isFinite(p) && p >= 0 && p <= 36e5)) throw new Error("视频页面时长无效");
|
|
949
|
+
return [{ slide: h, slideNumber: d + 1, groups: m, transition: g, hold: k, click: o }];
|
|
950
|
+
}), c = u.reduce((h, d, m) => h + (m && d.transition ? f(d.transition) : 0) + f(d.hold) + d.groups.reduce((g, k) => g + (o ? f(o) : 0) + f(_(k)), 0), 0);
|
|
951
951
|
if (!u.length) throw new Error("没有可导出的视频页面");
|
|
952
|
-
if (
|
|
953
|
-
return { width: s, height:
|
|
952
|
+
if (c / e > 3600 || c > 108e3) throw new Error("视频不能超过一小时或 108000 帧");
|
|
953
|
+
return { width: s, height: l, fps: e, bitrate: Math.round(i), pages: u, total: c, frames: f };
|
|
954
954
|
}
|
|
955
|
-
function
|
|
956
|
-
const
|
|
957
|
-
if (!Number.isInteger(
|
|
958
|
-
let
|
|
959
|
-
if (r.loop)
|
|
960
|
-
else if (t < 0 || t >=
|
|
961
|
-
const o = Math.floor(
|
|
962
|
-
return
|
|
955
|
+
function Ut(r, t, e) {
|
|
956
|
+
const n = r.samples.length / r.channels;
|
|
957
|
+
if (!Number.isInteger(n)) return null;
|
|
958
|
+
let a = t;
|
|
959
|
+
if (r.loop) a %= n;
|
|
960
|
+
else if (t < 0 || t >= n) return null;
|
|
961
|
+
const o = Math.floor(a), s = a - o, l = Math.min(o + 1, n - 1), i = r.samples[o * r.channels + e], f = r.samples[l * r.channels + e];
|
|
962
|
+
return i + (f - i) * s;
|
|
963
963
|
}
|
|
964
|
-
function
|
|
965
|
-
const
|
|
964
|
+
function jt(r, t, e = {}) {
|
|
965
|
+
const n = e.sampleRate ?? 48e3, a = e.channels ?? 2;
|
|
966
966
|
if (!Number.isFinite(t) || t < 0) throw new Error("混音总时长必须是非负毫秒");
|
|
967
|
-
if (!Number.isInteger(
|
|
968
|
-
if (r.some((
|
|
969
|
-
if (r.some((
|
|
970
|
-
if (r.some((
|
|
971
|
-
if (r.some((
|
|
972
|
-
const o = r.map((
|
|
973
|
-
if (o.some((
|
|
974
|
-
const s = Math.ceil(t / 1e3 *
|
|
975
|
-
for (const [
|
|
967
|
+
if (!Number.isInteger(n) || n <= 0) throw new Error("输出采样率必须是正整数");
|
|
968
|
+
if (r.some((i) => !Number.isInteger(i.sampleRate) || i.sampleRate <= 0)) throw new Error("片段采样率必须是正整数");
|
|
969
|
+
if (r.some((i) => i.channels !== 1 && i.channels !== 2)) throw new Error("片段声道数只支持单声道或立体声");
|
|
970
|
+
if (r.some((i) => !Number.isFinite(i.startMs) || i.startMs < 0)) throw new Error("片段起始时间必须是非负毫秒");
|
|
971
|
+
if (r.some((i) => i.samples.length % i.channels !== 0)) throw new Error("片段样本长度必须是声道数的整数倍");
|
|
972
|
+
const o = r.map((i) => i.volume ?? 1);
|
|
973
|
+
if (o.some((i) => !Number.isFinite(i) || i < 0 || i > 1)) throw new Error("片段音量必须在 [0,1]");
|
|
974
|
+
const s = Math.ceil(t / 1e3 * n), l = new Float32Array(s * a);
|
|
975
|
+
for (const [i, f] of r.entries()) {
|
|
976
976
|
if (f.endMs !== void 0 && f.endMs < f.startMs) throw new Error("片段截止时间早于起始时间");
|
|
977
|
-
const u = f.endMs ?? Number.POSITIVE_INFINITY,
|
|
978
|
-
for (let h = Math.max(
|
|
979
|
-
const d = (h - f.startMs / 1e3 *
|
|
980
|
-
for (let
|
|
981
|
-
const
|
|
982
|
-
|
|
977
|
+
const u = f.endMs ?? Number.POSITIVE_INFINITY, c = Math.floor(f.startMs / 1e3 * n);
|
|
978
|
+
for (let h = Math.max(c, 0); h < s && !(h / n * 1e3 >= u); h++) {
|
|
979
|
+
const d = (h - f.startMs / 1e3 * n) * f.sampleRate / n;
|
|
980
|
+
for (let m = 0; m < a; m++) {
|
|
981
|
+
const g = Ut(f, d, f.channels === 1 ? 0 : m);
|
|
982
|
+
g !== null && (l[h * a + m] += g * o[i]);
|
|
983
983
|
}
|
|
984
984
|
}
|
|
985
985
|
}
|
|
986
|
-
for (let
|
|
987
|
-
return
|
|
986
|
+
for (let i = 0; i < l.length; i++) l[i] = Math.max(-1, Math.min(1, l[i]));
|
|
987
|
+
return l;
|
|
988
988
|
}
|
|
989
|
-
const
|
|
989
|
+
const Gt = 5e3, Kt = 500, Qt = (r) => new Promise((t) => {
|
|
990
990
|
const e = (s) => {
|
|
991
|
-
clearTimeout(o), r.removeEventListener("loadeddata",
|
|
992
|
-
},
|
|
993
|
-
r.addEventListener("loadeddata",
|
|
994
|
-
}),
|
|
995
|
-
const
|
|
996
|
-
clearTimeout(o), r.removeEventListener("seeked",
|
|
997
|
-
},
|
|
998
|
-
r.addEventListener("seeked",
|
|
991
|
+
clearTimeout(o), r.removeEventListener("loadeddata", n), r.removeEventListener("error", a), t(s && Number.isFinite(r.duration) && r.duration > 0);
|
|
992
|
+
}, n = () => e(!0), a = () => e(!1), o = setTimeout(a, Gt);
|
|
993
|
+
r.addEventListener("loadeddata", n), r.addEventListener("error", a), r.readyState >= 2 && e(!0);
|
|
994
|
+
}), Zt = (r, t) => new Promise((e) => {
|
|
995
|
+
const n = (s) => {
|
|
996
|
+
clearTimeout(o), r.removeEventListener("seeked", a), e(s);
|
|
997
|
+
}, a = () => n(!0), o = setTimeout(() => n(!1), Kt);
|
|
998
|
+
r.addEventListener("seeked", a), r.currentTime = t;
|
|
999
999
|
}), K = (r) => {
|
|
1000
1000
|
r.removeAttribute("src"), r.load();
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1001
|
+
}, pt = (r) => {
|
|
1002
|
+
const t = r.x + r.w / 2, e = r.y + r.h / 2, n = new DOMMatrix().translateSelf(t, e);
|
|
1003
|
+
return r.rot && n.rotateSelf(r.rot), n.translateSelf(-t, -e).translateSelf(r.x, r.y);
|
|
1004
|
+
}, yt = (r) => !r.flipH && !r.flipV ? new DOMMatrix() : new DOMMatrix().translateSelf(r.w / 2, r.h / 2).scaleSelf(r.flipH ? -1 : 1, r.flipV ? -1 : 1).translateSelf(-r.w / 2, -r.h / 2);
|
|
1005
|
+
class Jt {
|
|
1003
1006
|
constructor(t) {
|
|
1004
1007
|
this.warn = t, this.videos = /* @__PURE__ */ new Map(), this.disposed = !1;
|
|
1005
1008
|
}
|
|
1006
1009
|
/** 预加载页面的视频媒体(每页一个列表;须在导出循环前调用) */
|
|
1007
|
-
async load(t, e,
|
|
1008
|
-
const o = [], s = (f) => {
|
|
1009
|
-
for (const
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1010
|
+
async load(t, e, n, a) {
|
|
1011
|
+
const o = [], s = (f, u, c) => {
|
|
1012
|
+
for (const h of f) {
|
|
1013
|
+
const d = c ? $t(c, h) : h;
|
|
1014
|
+
if (d.kind === "group") {
|
|
1015
|
+
const m = [...u, pt(d), yt(d)];
|
|
1016
|
+
s(d.children, m, d);
|
|
1017
|
+
} else if (d.kind === "image" && d.media && d.media.kind === "video" && d.media.src) {
|
|
1018
|
+
const m = d.media.playback;
|
|
1019
|
+
if (!m) continue;
|
|
1020
|
+
const g = a.length ? a[Math.min(m.clickGroup, a.length - 1)] : 0, k = document.createElement("video");
|
|
1021
|
+
k.muted = !0, k.preload = "auto", k.playsInline = !0, k.src = d.media.src, o.push({
|
|
1022
|
+
el: k,
|
|
1023
|
+
x: d.x,
|
|
1024
|
+
y: d.y,
|
|
1025
|
+
w: d.w,
|
|
1026
|
+
h: d.h,
|
|
1027
|
+
rot: d.rot,
|
|
1028
|
+
flipH: d.flipH,
|
|
1029
|
+
flipV: d.flipV,
|
|
1030
|
+
crop: d.crop,
|
|
1031
|
+
alpha: d.alpha,
|
|
1032
|
+
clipPath: d.clipPath,
|
|
1033
|
+
filter: d.filter,
|
|
1034
|
+
chain: u,
|
|
1035
|
+
startMs: g,
|
|
1036
|
+
durationS: Number.isFinite(k.duration) ? k.duration : 0,
|
|
1037
|
+
loop: m.loop,
|
|
1038
|
+
name: d.name ?? "",
|
|
1039
|
+
frameWarned: !1
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1016
1043
|
};
|
|
1017
|
-
if (s(e.elements), !o.length) return;
|
|
1018
|
-
const
|
|
1044
|
+
if (s(e.elements, []), !o.length) return;
|
|
1045
|
+
const l = await Promise.all(o.map((f) => Qt(f.el)));
|
|
1019
1046
|
if (this.disposed) {
|
|
1020
1047
|
for (const f of o) K(f.el);
|
|
1021
1048
|
return;
|
|
1022
1049
|
}
|
|
1023
|
-
const
|
|
1024
|
-
var
|
|
1025
|
-
return
|
|
1050
|
+
const i = o.filter((f, u) => {
|
|
1051
|
+
var c;
|
|
1052
|
+
return l[u] ? (f.durationS = f.el.duration, !0) : (K(f.el), (c = this.warn) == null || c.call(this, "video-overlay-unavailable", { slideNumber: n, elementName: f.name }), !1);
|
|
1026
1053
|
});
|
|
1027
|
-
this.videos.set(
|
|
1054
|
+
this.videos.set(n, i);
|
|
1028
1055
|
}
|
|
1029
1056
|
/**
|
|
1030
|
-
* 把当前时间轴的视频帧画到画布。在 SVG
|
|
1057
|
+
* 把当前时间轴的视频帧画到画布。在 SVG 光栅化之后调用,叠加在海报帧之上;
|
|
1031
1058
|
* scaleX/scaleY 把幻灯片坐标换算到导出画布坐标。
|
|
1032
1059
|
*/
|
|
1033
|
-
async draw(t, e,
|
|
1034
|
-
var
|
|
1060
|
+
async draw(t, e, n, a, o) {
|
|
1061
|
+
var l;
|
|
1035
1062
|
const s = this.videos.get(e);
|
|
1036
1063
|
if (s)
|
|
1037
|
-
for (const
|
|
1038
|
-
const f = (
|
|
1064
|
+
for (const i of s) {
|
|
1065
|
+
const f = (n - i.startMs) / 1e3;
|
|
1039
1066
|
if (f < 0) continue;
|
|
1040
|
-
const u = Math.min(f,
|
|
1041
|
-
(!(Math.abs(
|
|
1067
|
+
const u = i.loop ? i.durationS > 0 ? f % i.durationS : 0 : Math.min(f, i.durationS);
|
|
1068
|
+
if ((!(Math.abs(i.el.currentTime - u) <= 1 / 30 || await Zt(i.el, u)) || i.el.readyState < 2) && (i.frameWarned || (i.frameWarned = !0, (l = this.warn) == null || l.call(this, "video-overlay-frame-unavailable", { slideNumber: e, elementName: i.name })), i.el.readyState < 2))
|
|
1069
|
+
continue;
|
|
1070
|
+
t.save(), t.setTransform(new DOMMatrix().scaleSelf(a, o));
|
|
1071
|
+
for (const m of i.chain) t.transform(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
1072
|
+
t.transform(...(() => {
|
|
1073
|
+
const m = pt(i);
|
|
1074
|
+
return [m.a, m.b, m.c, m.d, m.e, m.f];
|
|
1075
|
+
})());
|
|
1076
|
+
const h = yt(i);
|
|
1077
|
+
t.transform(h.a, h.b, h.c, h.d, h.e, h.f), i.clipPath && t.clip(new Path2D(i.clipPath)), i.alpha !== void 0 && (t.globalAlpha *= Math.max(0, Math.min(1, i.alpha))), i.filter && (t.filter = i.filter);
|
|
1078
|
+
const d = i.el;
|
|
1079
|
+
if (i.crop && (i.crop.l || i.crop.t || i.crop.r || i.crop.b)) {
|
|
1080
|
+
const m = d.videoWidth, g = d.videoHeight;
|
|
1081
|
+
t.drawImage(
|
|
1082
|
+
d,
|
|
1083
|
+
i.crop.l * m,
|
|
1084
|
+
i.crop.t * g,
|
|
1085
|
+
Math.max(1, (1 - i.crop.l - i.crop.r) * m),
|
|
1086
|
+
Math.max(1, (1 - i.crop.t - i.crop.b) * g),
|
|
1087
|
+
0,
|
|
1088
|
+
0,
|
|
1089
|
+
i.w,
|
|
1090
|
+
i.h
|
|
1091
|
+
);
|
|
1092
|
+
} else
|
|
1093
|
+
t.drawImage(d, 0, 0, i.w, i.h);
|
|
1094
|
+
t.restore();
|
|
1042
1095
|
}
|
|
1043
1096
|
}
|
|
1044
1097
|
dispose() {
|
|
@@ -1047,28 +1100,28 @@ class Kt {
|
|
|
1047
1100
|
this.videos.clear();
|
|
1048
1101
|
}
|
|
1049
1102
|
}
|
|
1050
|
-
const
|
|
1051
|
-
const t = [], e = (
|
|
1052
|
-
for (const
|
|
1053
|
-
|
|
1103
|
+
const wt = (r) => {
|
|
1104
|
+
const t = [], e = (n) => {
|
|
1105
|
+
for (const a of n)
|
|
1106
|
+
a.kind === "image" && a.media && a.media.playback && a.media.src ? t.push(a) : a.kind === "group" && e(a.children);
|
|
1054
1107
|
};
|
|
1055
1108
|
return e(r), t;
|
|
1056
1109
|
};
|
|
1057
|
-
async function
|
|
1110
|
+
async function te(r, t) {
|
|
1058
1111
|
const e = await fetch(r, { signal: t });
|
|
1059
1112
|
if (!e.ok) throw new Error(`音频媒体读取失败:HTTP ${e.status}`);
|
|
1060
|
-
const
|
|
1061
|
-
if (!
|
|
1062
|
-
const o = await new
|
|
1063
|
-
for (let
|
|
1064
|
-
s.set(o.getChannelData(
|
|
1113
|
+
const n = await e.arrayBuffer(), a = globalThis.OfflineAudioContext;
|
|
1114
|
+
if (!a) throw new Error("当前浏览器不支持音频解码(OfflineAudioContext 缺失)");
|
|
1115
|
+
const o = await new a(1, 1, 48e3).decodeAudioData(n), s = new Float32Array(o.length * o.numberOfChannels);
|
|
1116
|
+
for (let l = 0; l < o.numberOfChannels; l++)
|
|
1117
|
+
s.set(o.getChannelData(l), l * o.length);
|
|
1065
1118
|
return { samples: s, sampleRate: o.sampleRate, channels: Math.min(2, o.numberOfChannels) };
|
|
1066
1119
|
}
|
|
1067
|
-
async function
|
|
1068
|
-
const o = { codec: "opus", sampleRate: e, numberOfChannels:
|
|
1120
|
+
async function ee(r, t, e, n, a) {
|
|
1121
|
+
const o = { codec: "opus", sampleRate: e, numberOfChannels: n, bitrate: 96e3 };
|
|
1069
1122
|
if (typeof AudioEncoder > "u" || typeof AudioData > "u" || !(await AudioEncoder.isConfigSupported(o)).supported) throw new Error("当前浏览器不支持 Opus 音频编码");
|
|
1070
1123
|
let s;
|
|
1071
|
-
const
|
|
1124
|
+
const l = new AudioEncoder({ output: (f) => {
|
|
1072
1125
|
try {
|
|
1073
1126
|
const u = new Uint8Array(f.byteLength);
|
|
1074
1127
|
f.copyTo(u), r.addAudio(u, Math.round(f.timestamp / 1e3));
|
|
@@ -1077,172 +1130,172 @@ async function Zt(r, t, e, a, n) {
|
|
|
1077
1130
|
}
|
|
1078
1131
|
}, error: (f) => {
|
|
1079
1132
|
s = f;
|
|
1080
|
-
} }),
|
|
1081
|
-
|
|
1133
|
+
} }), i = () => {
|
|
1134
|
+
l.state !== "closed" && l.close();
|
|
1082
1135
|
};
|
|
1083
|
-
|
|
1136
|
+
a == null || a.addEventListener("abort", i, { once: !0 });
|
|
1084
1137
|
try {
|
|
1085
|
-
|
|
1138
|
+
l.configure(o);
|
|
1086
1139
|
const f = Math.round(e * 0.02);
|
|
1087
|
-
for (let u = 0; u *
|
|
1088
|
-
if (
|
|
1140
|
+
for (let u = 0; u * n < t.length; u += f) {
|
|
1141
|
+
if (a != null && a.aborted) throw new DOMException("视频导出已取消", "AbortError");
|
|
1089
1142
|
if (s) throw s;
|
|
1090
|
-
const
|
|
1091
|
-
if (
|
|
1143
|
+
const c = Math.min(f, Math.floor(t.length / n) - u);
|
|
1144
|
+
if (c <= 0) break;
|
|
1092
1145
|
const h = new AudioData({
|
|
1093
1146
|
format: "f32",
|
|
1094
1147
|
sampleRate: e,
|
|
1095
|
-
numberOfFrames:
|
|
1096
|
-
numberOfChannels:
|
|
1148
|
+
numberOfFrames: c,
|
|
1149
|
+
numberOfChannels: n,
|
|
1097
1150
|
timestamp: Math.round(u / e * 1e6),
|
|
1098
|
-
data: new Float32Array(t.subarray(u *
|
|
1151
|
+
data: new Float32Array(t.subarray(u * n, (u + c) * n))
|
|
1099
1152
|
});
|
|
1100
1153
|
try {
|
|
1101
|
-
|
|
1154
|
+
l.encode(h);
|
|
1102
1155
|
} finally {
|
|
1103
1156
|
h.close();
|
|
1104
1157
|
}
|
|
1105
|
-
|
|
1106
|
-
const
|
|
1107
|
-
(
|
|
1158
|
+
l.encodeQueueSize >= 16 && await new Promise((d) => {
|
|
1159
|
+
const m = () => {
|
|
1160
|
+
(l.encodeQueueSize < 16 || s) && (l.removeEventListener("dequeue", m), d());
|
|
1108
1161
|
};
|
|
1109
|
-
|
|
1162
|
+
l.addEventListener("dequeue", m), m();
|
|
1110
1163
|
});
|
|
1111
1164
|
}
|
|
1112
|
-
if (await
|
|
1165
|
+
if (await l.flush(), s) throw s;
|
|
1113
1166
|
} finally {
|
|
1114
|
-
|
|
1167
|
+
a == null || a.removeEventListener("abort", i), i();
|
|
1115
1168
|
}
|
|
1116
1169
|
}
|
|
1117
|
-
async function
|
|
1118
|
-
var
|
|
1119
|
-
const e =
|
|
1120
|
-
var
|
|
1121
|
-
if ((
|
|
1170
|
+
async function oe(r, t = {}) {
|
|
1171
|
+
var p, R, N;
|
|
1172
|
+
const e = Ht(r, t), n = () => {
|
|
1173
|
+
var y;
|
|
1174
|
+
if ((y = t.signal) != null && y.aborted) throw new DOMException("视频导出已取消", "AbortError");
|
|
1122
1175
|
};
|
|
1123
|
-
if (
|
|
1124
|
-
const
|
|
1125
|
-
if (!t.mediaPosters && e.pages.some((
|
|
1176
|
+
if (n(), typeof VideoEncoder > "u" || typeof VideoFrame > "u" || typeof document > "u") throw new Error("当前浏览器不支持 WebCodecs 视频编码,请使用支持的 HTTPS 或本机浏览器");
|
|
1177
|
+
const a = (y) => y.some((v) => v.kind === "image" && !!v.media || v.kind === "group" && a(v.children));
|
|
1178
|
+
if (!t.mediaPosters && e.pages.some((y) => a(y.slide.elements))) throw new Error("文稿含内嵌音视频,导出时可能以静态封面呈现(含 audio / videoOverlay 未覆盖或失败的媒体);请设置 mediaPosters: true 显式允许");
|
|
1126
1179
|
let o, s = "VP9";
|
|
1127
|
-
for (const
|
|
1128
|
-
const
|
|
1129
|
-
if ((await VideoEncoder.isConfigSupported(
|
|
1130
|
-
o =
|
|
1180
|
+
for (const y of ["vp09.00.10.08", "vp8"]) {
|
|
1181
|
+
const v = { codec: y, width: e.width, height: e.height, framerate: e.fps, bitrate: e.bitrate, latencyMode: "realtime" };
|
|
1182
|
+
if ((await VideoEncoder.isConfigSupported(v)).supported) {
|
|
1183
|
+
o = v, s = y === "vp8" ? "VP8" : "VP9";
|
|
1131
1184
|
break;
|
|
1132
1185
|
}
|
|
1133
1186
|
}
|
|
1134
1187
|
if (!o) throw new Error("当前浏览器没有支持此尺寸的 VP8/VP9 视频编码器");
|
|
1135
|
-
|
|
1136
|
-
const
|
|
1188
|
+
n();
|
|
1189
|
+
const l = !!t.audio && e.pages.some((y) => wt(y.slide.elements).length > 0), i = new qt(e.width, e.height, e.fps, s, l ? { sampleRate: 48e3, channels: 2 } : void 0);
|
|
1137
1190
|
let f, u = 0;
|
|
1138
|
-
const
|
|
1139
|
-
output: (
|
|
1191
|
+
const c = new VideoEncoder({
|
|
1192
|
+
output: (y) => {
|
|
1140
1193
|
try {
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
} catch (
|
|
1144
|
-
f =
|
|
1194
|
+
const v = new Uint8Array(y.byteLength);
|
|
1195
|
+
y.copyTo(v), i.addFrame(v, y.timestamp, y.duration ?? Math.round(1e6 / e.fps), y.type === "key");
|
|
1196
|
+
} catch (v) {
|
|
1197
|
+
f = v;
|
|
1145
1198
|
}
|
|
1146
1199
|
},
|
|
1147
|
-
error: (
|
|
1148
|
-
f =
|
|
1200
|
+
error: (y) => {
|
|
1201
|
+
f = y;
|
|
1149
1202
|
}
|
|
1150
1203
|
}), h = document.createElement("canvas");
|
|
1151
1204
|
h.width = e.width, h.height = e.height;
|
|
1152
1205
|
const d = h.getContext("2d");
|
|
1153
1206
|
if (!d)
|
|
1154
|
-
throw
|
|
1155
|
-
const
|
|
1156
|
-
|
|
1207
|
+
throw c.close(), new Error("无法获取视频画布");
|
|
1208
|
+
const m = new Bt(r, !!t.showComments), g = t.videoOverlay ? new Jt(t.onWarning) : null, k = () => {
|
|
1209
|
+
c.state !== "closed" && c.close();
|
|
1157
1210
|
};
|
|
1158
|
-
(
|
|
1211
|
+
(p = t.signal) == null || p.addEventListener("abort", k, { once: !0 });
|
|
1159
1212
|
const A = () => {
|
|
1160
|
-
if (
|
|
1213
|
+
if (n(), f) throw f;
|
|
1161
1214
|
}, I = async () => {
|
|
1162
|
-
|
|
1163
|
-
var
|
|
1215
|
+
c.encodeQueueSize < 8 || (await new Promise((y, v) => {
|
|
1216
|
+
var O;
|
|
1164
1217
|
const P = () => {
|
|
1165
|
-
var
|
|
1166
|
-
clearTimeout(W),
|
|
1167
|
-
},
|
|
1168
|
-
(
|
|
1218
|
+
var T;
|
|
1219
|
+
clearTimeout(W), c.removeEventListener("dequeue", w), (T = t.signal) == null || T.removeEventListener("abort", Y);
|
|
1220
|
+
}, w = () => {
|
|
1221
|
+
(c.encodeQueueSize < 8 || f) && (P(), y());
|
|
1169
1222
|
}, Y = () => {
|
|
1170
|
-
P(),
|
|
1223
|
+
P(), v(new DOMException("视频导出已取消", "AbortError"));
|
|
1171
1224
|
}, W = setTimeout(() => {
|
|
1172
|
-
P(),
|
|
1225
|
+
P(), v(new Error("视频编码器等待超时"));
|
|
1173
1226
|
}, 3e4);
|
|
1174
|
-
|
|
1227
|
+
c.addEventListener("dequeue", w), (O = t.signal) == null || O.addEventListener("abort", Y, { once: !0 }), w();
|
|
1175
1228
|
}), A());
|
|
1176
|
-
},
|
|
1229
|
+
}, b = async (y, v, P = [], w) => {
|
|
1177
1230
|
var W;
|
|
1178
|
-
const Y = e.frames(
|
|
1179
|
-
for (let
|
|
1231
|
+
const Y = e.frames(y);
|
|
1232
|
+
for (let O = 0; O < Y; O++) {
|
|
1180
1233
|
A();
|
|
1181
|
-
for (const
|
|
1182
|
-
await
|
|
1183
|
-
const
|
|
1234
|
+
for (const X of P) X.currentTime = y * O / Y;
|
|
1235
|
+
await m.draw(d, e.width, e.height), A(), g && await g.draw(d, v, (w ?? 0) + y * O / Y, e.width / r.width, e.height / r.height), await I();
|
|
1236
|
+
const T = Math.round(u * 1e6 / e.fps), F = Math.round((u + 1) * 1e6 / e.fps), S = new VideoFrame(h, { timestamp: T, duration: F - T });
|
|
1184
1237
|
try {
|
|
1185
|
-
|
|
1238
|
+
c.encode(S, { keyFrame: u % (e.fps * 2) === 0 });
|
|
1186
1239
|
} finally {
|
|
1187
1240
|
S.close();
|
|
1188
1241
|
}
|
|
1189
|
-
u++, (W = t.onProgress) == null || W.call(t, { completed: u, total: e.total, slideNumber:
|
|
1242
|
+
u++, (W = t.onProgress) == null || W.call(t, { completed: u, total: e.total, slideNumber: v });
|
|
1190
1243
|
}
|
|
1191
|
-
|
|
1244
|
+
m.settle(P), await Promise.resolve();
|
|
1192
1245
|
};
|
|
1193
1246
|
try {
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
let
|
|
1197
|
-
for (const
|
|
1247
|
+
const y = [];
|
|
1248
|
+
c.configure(o);
|
|
1249
|
+
let v, P = 0;
|
|
1250
|
+
for (const w of e.pages) {
|
|
1198
1251
|
A();
|
|
1199
|
-
const Y =
|
|
1252
|
+
const Y = w.groups.length ? Et(w.groups, 0) : Pt(w.slide), W = v && w.transition ? w.transition : 0, O = await m.page(w.slide, [...Y]);
|
|
1200
1253
|
A();
|
|
1201
|
-
const
|
|
1254
|
+
const T = [];
|
|
1202
1255
|
{
|
|
1203
1256
|
let S = P + W;
|
|
1204
|
-
for (const
|
|
1205
|
-
|
|
1257
|
+
for (const X of w.groups)
|
|
1258
|
+
T.push(S), S += (w.click ?? 0) + _(X);
|
|
1206
1259
|
}
|
|
1207
|
-
|
|
1208
|
-
let
|
|
1209
|
-
if (W && (await
|
|
1210
|
-
for (const S of
|
|
1211
|
-
const
|
|
1212
|
-
let
|
|
1260
|
+
g && await g.load(r, w.slide, w.slideNumber, T);
|
|
1261
|
+
let F = P;
|
|
1262
|
+
if (W && (await b(w.transition, w.slideNumber, m.transition(v, O, w.slide), F), F += W), v == null || v.remove(), t.audio)
|
|
1263
|
+
for (const S of wt(w.slide.elements)) {
|
|
1264
|
+
const X = S.media.playback, it = T.length ? T[Math.min(X.clickGroup, T.length - 1)] : P + W;
|
|
1265
|
+
let z;
|
|
1213
1266
|
try {
|
|
1214
|
-
|
|
1215
|
-
} catch (
|
|
1216
|
-
if (!(
|
|
1217
|
-
(R = t.onWarning) == null || R.call(t, "video-audio-decode-failed", { slideNumber:
|
|
1267
|
+
z = await te(S.media.src, t.signal);
|
|
1268
|
+
} catch (U) {
|
|
1269
|
+
if (!(U instanceof DOMException && U.name === "AbortError") && S.media.kind === "video") {
|
|
1270
|
+
(R = t.onWarning) == null || R.call(t, "video-audio-decode-failed", { slideNumber: w.slideNumber, elementName: S.name ?? "" });
|
|
1218
1271
|
continue;
|
|
1219
1272
|
}
|
|
1220
|
-
throw
|
|
1273
|
+
throw U;
|
|
1221
1274
|
}
|
|
1222
|
-
A(),
|
|
1223
|
-
samples:
|
|
1224
|
-
sampleRate:
|
|
1225
|
-
channels:
|
|
1275
|
+
A(), y.push({
|
|
1276
|
+
samples: z.samples,
|
|
1277
|
+
sampleRate: z.sampleRate,
|
|
1278
|
+
channels: z.channels,
|
|
1226
1279
|
startMs: it,
|
|
1227
|
-
loop:
|
|
1228
|
-
volume:
|
|
1229
|
-
endMs:
|
|
1280
|
+
loop: X.loop,
|
|
1281
|
+
volume: X.volume,
|
|
1282
|
+
endMs: X.loop ? void 0 : it + z.samples.length / z.channels / z.sampleRate * 1e3
|
|
1230
1283
|
});
|
|
1231
1284
|
}
|
|
1232
|
-
for (const S of
|
|
1233
|
-
|
|
1234
|
-
await
|
|
1285
|
+
for (const S of w.groups)
|
|
1286
|
+
w.click && (await b(w.click, w.slideNumber, void 0, F), F += w.click), await b(_(S), w.slideNumber, m.group(O, S), F), F += _(S);
|
|
1287
|
+
await b(w.hold, w.slideNumber, void 0, F), F += w.hold, P = F, v = O;
|
|
1235
1288
|
}
|
|
1236
|
-
if (await
|
|
1237
|
-
const
|
|
1238
|
-
await
|
|
1289
|
+
if (await c.flush(), A(), t.audio && y.length) {
|
|
1290
|
+
const w = Math.round(u / e.fps * 1e3), Y = jt(y, w, { sampleRate: 48e3, channels: 2 });
|
|
1291
|
+
await ee(i, Y, 48e3, 2, t.signal);
|
|
1239
1292
|
}
|
|
1240
|
-
return
|
|
1293
|
+
return i.finish();
|
|
1241
1294
|
} finally {
|
|
1242
|
-
(N = t.signal) == null || N.removeEventListener("abort",
|
|
1295
|
+
(N = t.signal) == null || N.removeEventListener("abort", k), k(), g == null || g.dispose(), m.dispose(), h.width = h.height = 0;
|
|
1243
1296
|
}
|
|
1244
1297
|
}
|
|
1245
1298
|
export {
|
|
1246
|
-
|
|
1247
|
-
|
|
1299
|
+
oe as presentationToVideo,
|
|
1300
|
+
Ht as videoPlan
|
|
1248
1301
|
};
|