@taole/giftstage-plugin-multi-gift 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +207 -0
- package/dist/index.js +1513 -0
- package/package.json +26 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1513 @@
|
|
|
1
|
+
import "@taole/giftstage";
|
|
2
|
+
const ge = 0.42, Z = 8192, de = "LOTTIE_EFFECT_PARTICLE_CAPACITY_EXCEEDED", ve = Object.freeze([
|
|
3
|
+
Object.freeze({ batch: "main", rate: 105, phase: "launch" }),
|
|
4
|
+
Object.freeze({ batch: "main", rate: 78, phase: "launch" }),
|
|
5
|
+
Object.freeze({ batch: "main", rate: 48, phase: "launch" }),
|
|
6
|
+
Object.freeze({ batch: "smoke", rate: 18, phase: "launch" }),
|
|
7
|
+
Object.freeze({ batch: "main", rate: 390, phase: "burst" }),
|
|
8
|
+
Object.freeze({ batch: "main", rate: 275, phase: "burst" }),
|
|
9
|
+
Object.freeze({ batch: "main", rate: 145, phase: "burst" }),
|
|
10
|
+
Object.freeze({ batch: "main", rate: 265, phase: "secondary" }),
|
|
11
|
+
Object.freeze({ batch: "main", rate: 175, phase: "secondary" }),
|
|
12
|
+
Object.freeze({ batch: "main", rate: 48, phase: "secondary" })
|
|
13
|
+
]);
|
|
14
|
+
function Je(e, t, i) {
|
|
15
|
+
return Math.max(t, Math.min(i, e));
|
|
16
|
+
}
|
|
17
|
+
function $e(e = {}) {
|
|
18
|
+
const t = e.quality ?? "auto";
|
|
19
|
+
if (typeof t == "number") return Je(t, 0.25, 1.25);
|
|
20
|
+
if (t === "low") return 0.46;
|
|
21
|
+
if (t === "medium") return 0.72;
|
|
22
|
+
if (t === "high") return 1;
|
|
23
|
+
const i = Number.isFinite(e.deviceMemory) ? e.deviceMemory : 8, s = Number.isFinite(e.hardwareConcurrency) ? e.hardwareConcurrency : 8;
|
|
24
|
+
return i <= 4 || s <= 4 ? 0.52 : /Android|iPhone|iPad|iPod/i.test(e.userAgent || "") ? 0.72 : 1;
|
|
25
|
+
}
|
|
26
|
+
function Ue({
|
|
27
|
+
launchDuration: e,
|
|
28
|
+
density: t = 1,
|
|
29
|
+
resolvedQualityScale: i = 1
|
|
30
|
+
}) {
|
|
31
|
+
if (!Number.isFinite(e) || e < 0 || !Number.isFinite(t) || t < 0 || !Number.isFinite(i) || i < 0)
|
|
32
|
+
throw new Error("firework 粒子数量规划参数必须是有限非负数");
|
|
33
|
+
const s = t * i;
|
|
34
|
+
if (!Number.isFinite(s))
|
|
35
|
+
throw new Error("firework 粒子数量规划结果不是有限数值");
|
|
36
|
+
const r = {
|
|
37
|
+
launch: e * 0.84,
|
|
38
|
+
burst: 0.11,
|
|
39
|
+
secondary: 0.14
|
|
40
|
+
}, n = ve.map(({ rate: o, phase: c }) => Math.max(1, Math.round(o * r[c] * s)));
|
|
41
|
+
let l = 0, a = 0;
|
|
42
|
+
return n.forEach((o, c) => {
|
|
43
|
+
ve[c].batch === "smoke" ? l += o : a += o;
|
|
44
|
+
}), Object.freeze({
|
|
45
|
+
emitterCounts: Object.freeze(n),
|
|
46
|
+
smokeCount: l,
|
|
47
|
+
mainCount: a,
|
|
48
|
+
totalCount: l + a,
|
|
49
|
+
flashCount: 1
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function je(e, t = Z) {
|
|
53
|
+
if (!Number.isSafeInteger(e == null ? void 0 : e.smokeCount) || e.smokeCount < 0 || !Number.isSafeInteger(e == null ? void 0 : e.mainCount) || e.mainCount < 0)
|
|
54
|
+
throw new Error("firework smoke/main 粒子数量必须是非负安全整数");
|
|
55
|
+
if (!Number.isSafeInteger(t) || t < 1)
|
|
56
|
+
throw new Error("firework maxInstancesPerBatch 必须是正安全整数");
|
|
57
|
+
if (e.smokeCount > t || e.mainCount > t) {
|
|
58
|
+
const i = new RangeError(
|
|
59
|
+
`firework 粒子批次超过上限 ${t}(smoke=${e.smokeCount}, main=${e.mainCount})`
|
|
60
|
+
);
|
|
61
|
+
throw i.code = de, i.counts = e, i.maxInstancesPerBatch = t, i;
|
|
62
|
+
}
|
|
63
|
+
return e;
|
|
64
|
+
}
|
|
65
|
+
function Ge({
|
|
66
|
+
frameRate: e,
|
|
67
|
+
dismissFrame: t,
|
|
68
|
+
durationSeconds: i = ge
|
|
69
|
+
}) {
|
|
70
|
+
if (!Number.isFinite(e) || !(e > 0) || !Number.isFinite(t) || !Number.isFinite(i) || !(i > 0))
|
|
71
|
+
throw new Error("firework dismissDuration 必须生成有限且严格递增的毫秒区间");
|
|
72
|
+
const s = t / e, r = s * 1e3, n = (s + i) * 1e3;
|
|
73
|
+
if (!Number.isFinite(r) || !Number.isFinite(n) || !(n > r))
|
|
74
|
+
throw new Error("firework dismissDuration 必须生成有限且严格递增的毫秒区间");
|
|
75
|
+
return Object.freeze({ durationSeconds: i, startSeconds: s, startMs: r, endMs: n });
|
|
76
|
+
}
|
|
77
|
+
const Te = 150, Re = /* @__PURE__ */ new WeakMap();
|
|
78
|
+
function te(e, t) {
|
|
79
|
+
return Array.isArray(e) ? e : e != null ? [e] : Array.isArray(t) ? t : [t];
|
|
80
|
+
}
|
|
81
|
+
function oe(e, t, i) {
|
|
82
|
+
const s = e == null ? void 0 : e[t];
|
|
83
|
+
if (!s) return null;
|
|
84
|
+
if (Array.isArray(s))
|
|
85
|
+
return { x: s[0], y: s[1] ?? s[0] };
|
|
86
|
+
if (typeof s == "object") {
|
|
87
|
+
const r = (a) => {
|
|
88
|
+
const o = s[a];
|
|
89
|
+
return o == null ? null : Array.isArray(o) ? o[i] ?? o[0] : o;
|
|
90
|
+
}, n = r("x"), l = r("y");
|
|
91
|
+
return n == null || l == null ? null : { x: n, y: l };
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function qe(e, t, i) {
|
|
96
|
+
const s = 1 - e;
|
|
97
|
+
return 3 * s * s * e * t + 3 * s * e * e * i + e * e * e;
|
|
98
|
+
}
|
|
99
|
+
function Ze(e, t, i) {
|
|
100
|
+
const s = 1 - e;
|
|
101
|
+
return 3 * s * s * e * t + 3 * s * e * e * i + e * e * e;
|
|
102
|
+
}
|
|
103
|
+
class ae extends Error {
|
|
104
|
+
constructor(t, i, s = [], r = !1) {
|
|
105
|
+
super(i), this.name = "MultiGiftValidationError", this.code = t, this.findings = s, this.recoverable = r;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function F(e, t, i = {}) {
|
|
109
|
+
return {
|
|
110
|
+
code: e,
|
|
111
|
+
severity: i.severity || "error",
|
|
112
|
+
scope: i.scope || "slot",
|
|
113
|
+
where: t,
|
|
114
|
+
...i.layer ? { layer: i.layer } : {},
|
|
115
|
+
...Number.isInteger(i.effectIndex) ? { effectIndex: i.effectIndex } : {}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function L(e, t) {
|
|
119
|
+
e.some((i) => i.code === t.code && i.where === t.where) || e.push(t);
|
|
120
|
+
}
|
|
121
|
+
function ie(e) {
|
|
122
|
+
return !e || typeof e != "object" ? [] : e.a === 1 ? Array.isArray(e.k) ? e.k.flatMap((t) => [t == null ? void 0 : t.s, t == null ? void 0 : t.e]).filter((t) => t !== void 0) : [] : e.k === void 0 ? [] : [e.k];
|
|
123
|
+
}
|
|
124
|
+
function V(e) {
|
|
125
|
+
const t = Array.isArray(e) ? e : [e];
|
|
126
|
+
return t.length > 0 && t.every(Number.isFinite) ? t : null;
|
|
127
|
+
}
|
|
128
|
+
function Ye(e, t = /* @__PURE__ */ new Set()) {
|
|
129
|
+
return !e || typeof e != "object" || t.has(e) ? !1 : (t.add(e), typeof e.x == "string" ? !0 : Object.values(e).some((i) => Ye(i, t)));
|
|
130
|
+
}
|
|
131
|
+
function B(e, t, i, s, r) {
|
|
132
|
+
if (e == null) return;
|
|
133
|
+
const n = () => L(i, F("LOTTIE_INVALID_KEYFRAME", t, { layer: s }));
|
|
134
|
+
if (typeof e != "object" || e.k === void 0) {
|
|
135
|
+
n();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (typeof e.x == "string" && L(i, F("LOTTIE_UNSUPPORTED_TRANSFORM", `${t}.x`, { layer: s })), e.a !== 1) {
|
|
139
|
+
const o = V(e.k);
|
|
140
|
+
(!o || !r.includes(o.length)) && n();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!Array.isArray(e.k) || e.k.length === 0) {
|
|
144
|
+
n();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
let l = -1 / 0, a = null;
|
|
148
|
+
for (let o = 0; o < e.k.length; o += 1) {
|
|
149
|
+
const c = e.k[o];
|
|
150
|
+
if (!c || !Number.isFinite(c.t) || c.t < l) {
|
|
151
|
+
n();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
l = c.t;
|
|
155
|
+
const u = [c.s, c.e].filter((m) => m !== void 0);
|
|
156
|
+
if (c.s === void 0 || u.length === 0) {
|
|
157
|
+
n();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
for (const m of u) {
|
|
161
|
+
const p = V(m);
|
|
162
|
+
if (!p || !r.includes(p.length)) {
|
|
163
|
+
n();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (a == null && (a = p.length), a !== p.length) {
|
|
167
|
+
n();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function ue(e) {
|
|
174
|
+
var n, l, a, o, c, u;
|
|
175
|
+
const t = [], i = e.nm || `ind_${e.ind}`, s = { layer: i };
|
|
176
|
+
e.parent !== void 0 && t.push(F("LOTTIE_UNSUPPORTED_PARENT", i, s)), e.ddd === 1 && t.push(F("LOTTIE_UNSUPPORTED_3D", i, s));
|
|
177
|
+
const r = (n = e.ks) == null ? void 0 : n.p;
|
|
178
|
+
return r && (r.s === !0 || r.x !== void 0 || r.y !== void 0) && t.push(F("LOTTIE_UNSUPPORTED_SPLIT_POSITION", i, s)), (((l = e.ks) == null ? void 0 : l.rx) !== void 0 || ((a = e.ks) == null ? void 0 : a.ry) !== void 0 || ((o = e.ks) == null ? void 0 : o.or) !== void 0 || ((c = e.ks) == null ? void 0 : c.sk) !== void 0 || ((u = e.ks) == null ? void 0 : u.sa) !== void 0 || e.ao === 1 || e.sr !== void 0 && e.sr !== 1 || e.st !== void 0 && e.st !== 0 || e.tm !== void 0 || e.bm !== void 0 && e.bm !== 0 || e.tt !== void 0 || e.td !== void 0 || e.hasMask === !0 || Array.isArray(e.masksProperties) && e.masksProperties.length > 0 || Array.isArray(e.ef) && e.ef.length > 0 || Ye(e)) && t.push(F("LOTTIE_UNSUPPORTED_TRANSFORM", i, s)), (r == null ? void 0 : r.a) === 1 && Array.isArray(r.k) && r.k.forEach((m, p) => {
|
|
179
|
+
var w;
|
|
180
|
+
const v = (m == null ? void 0 : m.to) !== void 0, y = (m == null ? void 0 : m.ti) !== void 0;
|
|
181
|
+
if (!v && !y) return;
|
|
182
|
+
const b = m == null ? void 0 : m.s, g = (m == null ? void 0 : m.e) ?? ((w = r.k[p + 1]) == null ? void 0 : w.s), h = Array.isArray(b) ? b.length : -1, d = (k) => Array.isArray(k) && k.length === h && k.every(Number.isFinite);
|
|
183
|
+
(!d(b) || !d(g) || !d(m.to) || !d(m.ti)) && t.push(F("LOTTIE_INVALID_KEYFRAME", `${i}.ks.p[${p}]`, s));
|
|
184
|
+
}), t;
|
|
185
|
+
}
|
|
186
|
+
function He(e, t, i) {
|
|
187
|
+
let s = 0, r = 1;
|
|
188
|
+
for (let l = 0; l < 32; l += 1) {
|
|
189
|
+
const a = (s + r) / 2;
|
|
190
|
+
qe(a, t.x, i.x) < e ? s = a : r = a;
|
|
191
|
+
}
|
|
192
|
+
const n = (s + r) / 2;
|
|
193
|
+
return Ze(n, t.y, i.y);
|
|
194
|
+
}
|
|
195
|
+
function _t(e) {
|
|
196
|
+
return ((e == null ? void 0 : e.layers) || []).flatMap(ue);
|
|
197
|
+
}
|
|
198
|
+
function Qe(e, t = {}) {
|
|
199
|
+
var u, m, p, v, y, b, g;
|
|
200
|
+
const i = [], s = Array.isArray(e == null ? void 0 : e.layers) ? e.layers : [];
|
|
201
|
+
(!Number.isFinite(e == null ? void 0 : e.w) || e.w <= 0 || !Number.isFinite(e == null ? void 0 : e.h) || e.h <= 0 || !Number.isFinite(e == null ? void 0 : e.fr) || e.fr <= 0 || !Number.isFinite(e == null ? void 0 : e.ip) || !Number.isFinite(e == null ? void 0 : e.op) || e.op <= e.ip) && i.push(F("LOTTIE_INVALID_COMPOSITION", "composition", {
|
|
202
|
+
scope: "composition"
|
|
203
|
+
}));
|
|
204
|
+
const r = /^(slot|img_slot)_(\d+)$/, n = s.filter((h) => r.test((h == null ? void 0 : h.nm) || ""));
|
|
205
|
+
n.filter((h) => /^slot_\d+$/.test(h.nm)).length === 0 && i.push(F("LOTTIE_SLOT_MISSING", "layers", { scope: "composition" }));
|
|
206
|
+
for (const h of ["slot", "img_slot"]) {
|
|
207
|
+
const d = n.filter((O) => O.nm.startsWith(`${h}_`)), w = /* @__PURE__ */ new Set(), k = [];
|
|
208
|
+
for (const O of d)
|
|
209
|
+
w.has(O.nm) && L(i, F("LOTTIE_SLOT_DUPLICATED", O.nm, {
|
|
210
|
+
scope: "composition"
|
|
211
|
+
})), w.add(O.nm), k.push(Number((u = r.exec(O.nm)) == null ? void 0 : u[2]));
|
|
212
|
+
Array.from(new Set(k)).sort((O, C) => O - C).some((O, C) => O !== C + 1) && i.push(F("LOTTIE_SLOT_INDEX_GAP", h, { scope: "composition" }));
|
|
213
|
+
}
|
|
214
|
+
for (const h of n) {
|
|
215
|
+
const d = h.nm;
|
|
216
|
+
for (const M of ue(h)) L(i, M);
|
|
217
|
+
h.ty !== 3 && L(i, F("LOTTIE_UNSUPPORTED_LAYER_TYPE", d, {
|
|
218
|
+
layer: d
|
|
219
|
+
})), (!Number.isFinite(h.ip) || !Number.isFinite(h.op) || h.op <= h.ip) && L(i, F("LOTTIE_INVALID_KEYFRAME", `${d}.ip/op`, {
|
|
220
|
+
layer: d
|
|
221
|
+
}));
|
|
222
|
+
const w = h.ks || {};
|
|
223
|
+
B(w.p, `${d}.ks.p`, i, d, [2, 3]), B(w.s, `${d}.ks.s`, i, d, [2, 3]), B(w.r, `${d}.ks.r`, i, d, [1]), B(w.rz, `${d}.ks.rz`, i, d, [1]), B(w.o, `${d}.ks.o`, i, d, [1]), w.r !== void 0 && w.rz !== void 0 && L(i, F("LOTTIE_UNSUPPORTED_TRANSFORM", `${d}.ks.r/rz`, {
|
|
224
|
+
layer: d
|
|
225
|
+
}));
|
|
226
|
+
const k = w.a, E = ie(k);
|
|
227
|
+
((k == null ? void 0 : k.a) === 1 || E.some((M) => {
|
|
228
|
+
const T = V(M);
|
|
229
|
+
return !T || T.some((R) => R !== 0);
|
|
230
|
+
})) && L(i, F("LOTTIE_UNSUPPORTED_ANCHOR", `${d}.ks.a`, {
|
|
231
|
+
layer: d
|
|
232
|
+
})), ie(w.p).some((M) => {
|
|
233
|
+
const T = V(M);
|
|
234
|
+
return !!T && T.length > 2 && T[2] !== 0;
|
|
235
|
+
}) && L(i, F("LOTTIE_UNSUPPORTED_3D", `${d}.ks.p`, {
|
|
236
|
+
layer: d
|
|
237
|
+
})), ie(w.s).some((M) => {
|
|
238
|
+
const T = V(M);
|
|
239
|
+
return !!T && (T[0] < 0 || T[1] < 0 || T.length > 2 && T[2] !== 100);
|
|
240
|
+
}) && L(i, F("LOTTIE_UNSUPPORTED_TRANSFORM", `${d}.ks.s`, {
|
|
241
|
+
layer: d
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
const a = pe(e == null ? void 0 : e.markers, "target_flight");
|
|
245
|
+
(!a || !Number.isFinite(a.tm) || !Number.isFinite(a.dr) || a.dr <= 0 || a.tm < e.ip || a.tm + a.dr > e.op) && i.push(F("LOTTIE_TARGET_MARKER_MISSING", "markers.target_flight", {
|
|
246
|
+
scope: "composition",
|
|
247
|
+
severity: "warning"
|
|
248
|
+
}));
|
|
249
|
+
const o = new Map(((e == null ? void 0 : e.markers) || []).map((h) => [h == null ? void 0 : h.cm, h])), c = new Map(s.map((h) => [h == null ? void 0 : h.nm, h]));
|
|
250
|
+
for (const [h, d] of (t.effects || []).entries()) {
|
|
251
|
+
if ((d == null ? void 0 : d.type) !== "firework") continue;
|
|
252
|
+
for (const R of ["launch", "burst"]) {
|
|
253
|
+
const S = (m = d.anchors) == null ? void 0 : m[R], N = c.get(S);
|
|
254
|
+
if (!S || !((p = N == null ? void 0 : N.ks) != null && p.p)) {
|
|
255
|
+
L(i, F(
|
|
256
|
+
"LOTTIE_EFFECT_ANCHOR_MISSING",
|
|
257
|
+
`effects[${h}].anchors.${R}`,
|
|
258
|
+
{ scope: "effect", severity: "warning", effectIndex: h }
|
|
259
|
+
));
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const z = ue(N), P = [];
|
|
263
|
+
B(
|
|
264
|
+
N.ks.p,
|
|
265
|
+
`${S}.ks.p`,
|
|
266
|
+
P,
|
|
267
|
+
S,
|
|
268
|
+
[2, 3]
|
|
269
|
+
), ie(N.ks.p).some((f) => {
|
|
270
|
+
const A = V(f);
|
|
271
|
+
return !!A && A.length > 2 && A[2] !== 0;
|
|
272
|
+
}) && z.push(F("LOTTIE_UNSUPPORTED_3D", `${S}.ks.p`, {
|
|
273
|
+
layer: S
|
|
274
|
+
}));
|
|
275
|
+
for (const [f, A] of [
|
|
276
|
+
["s", [100, 100, 100]],
|
|
277
|
+
["r", [0]],
|
|
278
|
+
["rz", [0]],
|
|
279
|
+
["o", [100]],
|
|
280
|
+
["a", [0, 0, 0]]
|
|
281
|
+
]) {
|
|
282
|
+
const _ = N.ks[f];
|
|
283
|
+
if (_ == null) continue;
|
|
284
|
+
const D = ie(_);
|
|
285
|
+
_.a !== 1 && D.length > 0 && D.every((Y) => {
|
|
286
|
+
const W = V(Y);
|
|
287
|
+
return !!W && W.length === A.length && W.every((X, $) => X === A[$]);
|
|
288
|
+
}) || z.push(F(
|
|
289
|
+
"LOTTIE_UNSUPPORTED_TRANSFORM",
|
|
290
|
+
`${S}.ks.${f}`,
|
|
291
|
+
{ layer: S }
|
|
292
|
+
));
|
|
293
|
+
}
|
|
294
|
+
N.ty !== 3 && z.push(F("LOTTIE_UNSUPPORTED_LAYER_TYPE", S, {
|
|
295
|
+
layer: S
|
|
296
|
+
}));
|
|
297
|
+
for (const f of [...z, ...P])
|
|
298
|
+
L(i, F(f.code, f.where, {
|
|
299
|
+
scope: "effect",
|
|
300
|
+
severity: "warning",
|
|
301
|
+
effectIndex: h,
|
|
302
|
+
layer: S
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
for (const R of ["launch", "burst", "dismiss"]) {
|
|
306
|
+
const S = (v = d.markers) == null ? void 0 : v[R], N = o.get(S);
|
|
307
|
+
!S || !N ? L(i, F(
|
|
308
|
+
"LOTTIE_EFFECT_MARKER_MISSING",
|
|
309
|
+
`effects[${h}].markers.${R}`,
|
|
310
|
+
{ scope: "effect", severity: "warning", effectIndex: h }
|
|
311
|
+
)) : (!Number.isFinite(N.tm) || !Number.isFinite(N.dr) || N.dr < 0 || R === "launch" && N.dr <= 0) && L(i, F(
|
|
312
|
+
"LOTTIE_EFFECT_MARKER_INVALID",
|
|
313
|
+
`effects[${h}].markers.${R}`,
|
|
314
|
+
{ scope: "effect", severity: "warning", effectIndex: h }
|
|
315
|
+
));
|
|
316
|
+
}
|
|
317
|
+
const w = o.get((y = d.markers) == null ? void 0 : y.launch), k = o.get((b = d.markers) == null ? void 0 : b.burst), E = o.get((g = d.markers) == null ? void 0 : g.dismiss), O = d.dismissDuration ?? ge, C = Number.isFinite(O) && O > 0;
|
|
318
|
+
let M = null, T = C;
|
|
319
|
+
if (C && E && Number.isFinite(E.tm) && Number.isFinite(e.fr) && e.fr > 0)
|
|
320
|
+
try {
|
|
321
|
+
M = Ge({
|
|
322
|
+
frameRate: e.fr,
|
|
323
|
+
dismissFrame: E.tm,
|
|
324
|
+
durationSeconds: O
|
|
325
|
+
});
|
|
326
|
+
} catch {
|
|
327
|
+
T = !1;
|
|
328
|
+
}
|
|
329
|
+
if (T || L(i, F(
|
|
330
|
+
"LOTTIE_EFFECT_DISMISS_DURATION_INVALID",
|
|
331
|
+
`effects[${h}].dismissDuration`,
|
|
332
|
+
{ scope: "effect", severity: "warning", effectIndex: h }
|
|
333
|
+
)), w && Number.isFinite(w.dr) && w.dr > 0 && Number.isFinite(e.fr) && e.fr > 0)
|
|
334
|
+
try {
|
|
335
|
+
const R = t.fireworkEnvironment || {}, S = $e({
|
|
336
|
+
...R,
|
|
337
|
+
quality: d.quality ?? R.quality ?? "auto"
|
|
338
|
+
});
|
|
339
|
+
je(
|
|
340
|
+
Ue({
|
|
341
|
+
launchDuration: w.dr / e.fr,
|
|
342
|
+
density: d.density ?? 1,
|
|
343
|
+
resolvedQualityScale: S
|
|
344
|
+
}),
|
|
345
|
+
t.maxInstancesPerBatch ?? Z
|
|
346
|
+
);
|
|
347
|
+
} catch (R) {
|
|
348
|
+
L(i, F(
|
|
349
|
+
(R == null ? void 0 : R.code) === de ? de : "LOTTIE_EFFECT_PARTICLE_CONFIG_INVALID",
|
|
350
|
+
`effects[${h}]`,
|
|
351
|
+
{ scope: "effect", severity: "warning", effectIndex: h }
|
|
352
|
+
));
|
|
353
|
+
}
|
|
354
|
+
w && k && E && Number.isFinite(w.tm) && Number.isFinite(k.tm) && Number.isFinite(E.tm) && Number.isFinite(e.fr) && e.fr > 0 && M && !(w.tm / e.fr * 1e3 <= k.tm / e.fr * 1e3 && k.tm / e.fr * 1e3 < M.endMs) && L(i, F(
|
|
355
|
+
"LOTTIE_EFFECT_TIMING_INVALID",
|
|
356
|
+
`effects[${h}].markers`,
|
|
357
|
+
{ scope: "effect", severity: "warning", effectIndex: h }
|
|
358
|
+
));
|
|
359
|
+
}
|
|
360
|
+
return i;
|
|
361
|
+
}
|
|
362
|
+
function Ke(e, t, i, s) {
|
|
363
|
+
const r = Math.max(e.length, t.length, i.length, s.length), n = [];
|
|
364
|
+
let l = 0, a = null;
|
|
365
|
+
for (let o = 0; o < Te; o += 1) {
|
|
366
|
+
const c = o / (Te - 1), u = 1 - c, m = Array.from({ length: r }, (v, y) => {
|
|
367
|
+
const b = e[y] ?? 0, g = t[y] ?? b, h = b + (i[y] ?? 0), d = g + (s[y] ?? 0);
|
|
368
|
+
return u ** 3 * b + 3 * u ** 2 * c * h + 3 * u * c ** 2 * d + c ** 3 * g;
|
|
369
|
+
}), p = a ? Math.sqrt(m.reduce(
|
|
370
|
+
(v, y, b) => v + (y - a[b]) ** 2,
|
|
371
|
+
0
|
|
372
|
+
)) : 0;
|
|
373
|
+
l += p, n.push({ partialLength: p, point: m }), a = m;
|
|
374
|
+
}
|
|
375
|
+
return { points: n, segmentLength: l };
|
|
376
|
+
}
|
|
377
|
+
function et(e, t, i) {
|
|
378
|
+
let s = Re.get(e);
|
|
379
|
+
return s || (s = Ke(t, i, e.to, e.ti), Re.set(e, s)), s;
|
|
380
|
+
}
|
|
381
|
+
function We(e, t) {
|
|
382
|
+
const i = Math.max(0, Math.min(1, e)), s = t.segmentLength * i;
|
|
383
|
+
let r = 0;
|
|
384
|
+
for (let n = 0; n < t.points.length; n += 1) {
|
|
385
|
+
const l = t.points[n];
|
|
386
|
+
if (r += l.partialLength, s === 0 || i === 0 || n === t.points.length - 1)
|
|
387
|
+
return l.point.slice();
|
|
388
|
+
const a = t.points[n + 1];
|
|
389
|
+
if (s >= r && s < r + a.partialLength) {
|
|
390
|
+
const o = (s - r) / a.partialLength;
|
|
391
|
+
return l.point.map(
|
|
392
|
+
(c, u) => c + (a.point[u] - c) * o
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return t.points[t.points.length - 1].point.slice();
|
|
397
|
+
}
|
|
398
|
+
function Ct(e, t, i, s, r) {
|
|
399
|
+
return We(
|
|
400
|
+
e,
|
|
401
|
+
Ke(t, i, s, r)
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
function q(e, t, i) {
|
|
405
|
+
if (!e || e.a === 0) return te(e == null ? void 0 : e.k, i);
|
|
406
|
+
const s = e.k, r = s.findIndex((v, y) => {
|
|
407
|
+
const b = s[y + 1];
|
|
408
|
+
return !b || t < b.t;
|
|
409
|
+
}), n = s[Math.max(r, 0)], l = s[r + 1];
|
|
410
|
+
if (!l || t <= n.t || n.h === 1) return te(n.s, i);
|
|
411
|
+
const a = te(n.s, i), o = te(n.e || l.s, a), c = Math.max(0, Math.min(1, (t - n.t) / (l.t - n.t))), u = oe(n, "o", 0), m = oe(n, "i", 0) || oe(l, "i", 0), p = u && m ? He(c, u, m) : c;
|
|
412
|
+
return Array.isArray(n.to) && Array.isArray(n.ti) ? We(p, et(n, a, o)) : a.map((v, y) => v + ((o[y] ?? v) - v) * p);
|
|
413
|
+
}
|
|
414
|
+
function tt(e) {
|
|
415
|
+
return 1 - (1 - e) ** 3;
|
|
416
|
+
}
|
|
417
|
+
function Pt(e) {
|
|
418
|
+
return e < 0.5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2;
|
|
419
|
+
}
|
|
420
|
+
function pe(e, t) {
|
|
421
|
+
return e == null ? void 0 : e.find((i) => i.cm === t);
|
|
422
|
+
}
|
|
423
|
+
const le = Math.PI * 2, it = Object.freeze({
|
|
424
|
+
glow: [22, 22],
|
|
425
|
+
spark: [10, 22],
|
|
426
|
+
star: [24, 24],
|
|
427
|
+
smoke: [26, 26],
|
|
428
|
+
petal: [18, 24],
|
|
429
|
+
flash: [96, 96]
|
|
430
|
+
});
|
|
431
|
+
function st(e, { type: t, color: i, width: s, height: r }, n = 0, l = 0) {
|
|
432
|
+
e.save(), e.translate(n, l);
|
|
433
|
+
const a = s / 2, o = r / 2;
|
|
434
|
+
if (t === "glow" || t === "smoke" || t === "flash") {
|
|
435
|
+
const c = e.createRadialGradient(a, o, 0, a, o, s / 2);
|
|
436
|
+
c.addColorStop(0, t === "smoke" ? i : "#ffffff"), c.addColorStop(t === "flash" ? 0.22 : 0.3, i), c.addColorStop(1, "rgba(255,255,255,0)"), e.fillStyle = c, e.fillRect(0, 0, s, r);
|
|
437
|
+
} else if (t === "spark") {
|
|
438
|
+
const c = e.createLinearGradient(a, r, a, 0);
|
|
439
|
+
c.addColorStop(0, "rgba(255,255,255,0)"), c.addColorStop(0.46, i), c.addColorStop(1, "rgba(255,255,255,0)"), e.fillStyle = c, e.fillRect(0, 0, s, r), e.fillStyle = "#ffffff", e.beginPath(), e.arc(a, o * 0.72, 5, 0, le), e.fill();
|
|
440
|
+
} else if (t === "star")
|
|
441
|
+
e.strokeStyle = i, e.fillStyle = "#ffffff", e.lineCap = "round", e.lineWidth = 2, e.beginPath(), e.moveTo(a, 1), e.lineTo(a, r - 1), e.moveTo(1, o), e.lineTo(s - 1, o), e.moveTo(5, 5), e.lineTo(s - 5, r - 5), e.moveTo(s - 5, 5), e.lineTo(5, r - 5), e.stroke(), e.beginPath(), e.arc(a, o, 4, 0, le), e.fill();
|
|
442
|
+
else if (t === "petal") {
|
|
443
|
+
e.save(), e.translate(a, o), e.rotate(-0.32), e.scale(0.72, 1);
|
|
444
|
+
const c = e.createLinearGradient(0, -r / 2, 0, r / 2);
|
|
445
|
+
c.addColorStop(0, "#ffffff"), c.addColorStop(0.42, i), c.addColorStop(1, "rgba(105, 0, 25, 0.5)"), e.fillStyle = c, e.beginPath(), e.ellipse(0, 0, 8, 15, 0, 0, le), e.fill(), e.restore();
|
|
446
|
+
} else
|
|
447
|
+
throw e.restore(), new Error(`未知 firework texture 类型:${t}`);
|
|
448
|
+
e.restore();
|
|
449
|
+
}
|
|
450
|
+
const K = Math.PI * 2, rt = Object.freeze(["#ff385c", "#ffad38", "#ffe095"]), nt = 20260808;
|
|
451
|
+
function ot(e, t = 0, i = 1) {
|
|
452
|
+
return Math.max(t, Math.min(i, e));
|
|
453
|
+
}
|
|
454
|
+
function at(e) {
|
|
455
|
+
let t = e >>> 0;
|
|
456
|
+
return () => {
|
|
457
|
+
t += 1831565813;
|
|
458
|
+
let i = t;
|
|
459
|
+
return i = Math.imul(i ^ i >>> 15, i | 1), i ^= i + Math.imul(i ^ i >>> 7, i | 61), ((i ^ i >>> 14) >>> 0) / 4294967296;
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function lt(e) {
|
|
463
|
+
const t = e ?? nt;
|
|
464
|
+
if (!Number.isInteger(t) || t < 0 || t > 4294967295)
|
|
465
|
+
throw new Error("firework seed 必须是 0 到 4294967295 之间的整数");
|
|
466
|
+
return t;
|
|
467
|
+
}
|
|
468
|
+
function Ae(e, t, i = 1, s = !1) {
|
|
469
|
+
if (!Number.isFinite(t)) throw new Error("firework envelope 时间必须是有限毫秒值");
|
|
470
|
+
if (!(e != null && e.length)) return i;
|
|
471
|
+
const r = s ? t - 1e-6 : t;
|
|
472
|
+
if (r < e[0].startMs) return e[0].from;
|
|
473
|
+
let n = e[0].from;
|
|
474
|
+
for (const l of e) {
|
|
475
|
+
if (r < l.startMs) return n;
|
|
476
|
+
if (r < l.endMs) {
|
|
477
|
+
if (l.interpolation === "hold") return l.from;
|
|
478
|
+
const a = (r - l.startMs) / (l.endMs - l.startMs);
|
|
479
|
+
return l.from + (l.to - l.from) * a;
|
|
480
|
+
}
|
|
481
|
+
n = l.to;
|
|
482
|
+
}
|
|
483
|
+
return n;
|
|
484
|
+
}
|
|
485
|
+
function ct(e, t, i, s, r) {
|
|
486
|
+
const n = 1 - r, l = n ** 3, a = 3 * n * n * r, o = 3 * n * r * r, c = r ** 3;
|
|
487
|
+
return {
|
|
488
|
+
x: l * e.x + a * t.x + o * i.x + c * s.x,
|
|
489
|
+
y: l * e.y + a * t.y + o * i.y + c * s.y
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function ce(e, t) {
|
|
493
|
+
var r;
|
|
494
|
+
const i = e.markers || ((r = e.lottie) == null ? void 0 : r.markers) || [], s = i instanceof Map ? i.get(t) : pe(i, t);
|
|
495
|
+
if (!s) throw new Error(`Lottie 中缺少效果 marker:${t}`);
|
|
496
|
+
return s;
|
|
497
|
+
}
|
|
498
|
+
function Oe(e, t, i, s) {
|
|
499
|
+
var a, o;
|
|
500
|
+
if (typeof e.resolveAnchor == "function") {
|
|
501
|
+
const c = e.resolveAnchor(t, i);
|
|
502
|
+
return {
|
|
503
|
+
x: c.x * s.scale + s.offsetX,
|
|
504
|
+
y: c.y * s.scale + s.offsetY
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
const r = (a = e.layers) == null ? void 0 : a.get(t);
|
|
508
|
+
if (!((o = r == null ? void 0 : r.ks) != null && o.p)) throw new Error(`Lottie 中缺少效果锚点图层:${t}`);
|
|
509
|
+
const [n, l] = q(r.ks.p, i, [0, 0, 0]);
|
|
510
|
+
return {
|
|
511
|
+
x: n * s.scale + s.offsetX,
|
|
512
|
+
y: l * s.scale + s.offsetY
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
function me(e, t) {
|
|
516
|
+
return `${e}:${String(t).trim().toLowerCase()}`;
|
|
517
|
+
}
|
|
518
|
+
function Xe(e) {
|
|
519
|
+
return Object.freeze(rt.map((t, i) => {
|
|
520
|
+
const s = e == null ? void 0 : e[i];
|
|
521
|
+
return typeof s == "string" && s.trim() ? s.trim() : t;
|
|
522
|
+
}));
|
|
523
|
+
}
|
|
524
|
+
function Ve(e = {}) {
|
|
525
|
+
const t = Xe(e.colors), i = [
|
|
526
|
+
["glow", "#ffffff"],
|
|
527
|
+
["spark", t[1]],
|
|
528
|
+
["glow", t[0]],
|
|
529
|
+
["smoke", "rgba(184, 184, 184, 0.24)"],
|
|
530
|
+
["spark", t[0]],
|
|
531
|
+
["star", "#ffffff"],
|
|
532
|
+
["glow", t[2] || t[1]],
|
|
533
|
+
["petal", t[0]],
|
|
534
|
+
["flash", t[0]]
|
|
535
|
+
], s = [], r = /* @__PURE__ */ new Set();
|
|
536
|
+
for (const [n, l] of i) {
|
|
537
|
+
const a = me(n, l);
|
|
538
|
+
if (r.has(a)) continue;
|
|
539
|
+
r.add(a);
|
|
540
|
+
const [o, c] = it[n];
|
|
541
|
+
s.push(Object.freeze({ key: a, type: n, color: l, width: o, height: c }));
|
|
542
|
+
}
|
|
543
|
+
return Object.freeze({
|
|
544
|
+
key: JSON.stringify(s.map(({ key: n, width: l, height: a }) => [n, l, a])),
|
|
545
|
+
cells: Object.freeze(s)
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
function ft({ startMs: e, endMs: t }) {
|
|
549
|
+
return Object.freeze([Object.freeze({ startMs: e, endMs: t, from: 1, to: 0, interpolation: "linear" })]);
|
|
550
|
+
}
|
|
551
|
+
function ht(e) {
|
|
552
|
+
const t = e * 1e3;
|
|
553
|
+
return Object.freeze([
|
|
554
|
+
Object.freeze({ startMs: t, endMs: t + 28.8, from: 0, to: 1, interpolation: "linear" }),
|
|
555
|
+
Object.freeze({ startMs: t + 28.8, endMs: t + 100.8, from: 1, to: 0.72, interpolation: "linear" }),
|
|
556
|
+
Object.freeze({ startMs: t + 100.8, endMs: t + 360, from: 0.5184, to: 0, interpolation: "linear" })
|
|
557
|
+
]);
|
|
558
|
+
}
|
|
559
|
+
function dt(e) {
|
|
560
|
+
const t = e * 1e3;
|
|
561
|
+
return Object.freeze([
|
|
562
|
+
Object.freeze({ startMs: t, endMs: t + 43.2, from: 0.18, to: 1.35, interpolation: "linear" }),
|
|
563
|
+
Object.freeze({ startMs: t + 43.2, endMs: t + 115.2, from: 1.35, to: 0.78, interpolation: "linear" }),
|
|
564
|
+
Object.freeze({ startMs: t + 115.2, endMs: t + 360, from: 0.78, to: 2.25, interpolation: "linear" })
|
|
565
|
+
]);
|
|
566
|
+
}
|
|
567
|
+
function ut({
|
|
568
|
+
effect: e,
|
|
569
|
+
composition: t,
|
|
570
|
+
layout: i = { scale: 1, offsetX: 0, offsetY: 0 },
|
|
571
|
+
resolvedQualityScale: s = 1,
|
|
572
|
+
seed: r = e == null ? void 0 : e.seed,
|
|
573
|
+
maxParticleCount: n = Z * 2,
|
|
574
|
+
maxInstancesPerBatch: l = Z
|
|
575
|
+
}) {
|
|
576
|
+
var X, $, se, we, be, ye, Ee;
|
|
577
|
+
const a = lt(r), o = t.frameRate ?? ((X = t.lottie) == null ? void 0 : X.fr);
|
|
578
|
+
if (![o, i.scale, i.offsetX, i.offsetY, s].every(Number.isFinite) || !(o > 0)) throw new Error("firework 编译参数包含非有限数值");
|
|
579
|
+
const c = ce(t, ($ = e.markers) == null ? void 0 : $.launch), u = ce(t, (se = e.markers) == null ? void 0 : se.burst), m = ce(t, (we = e.markers) == null ? void 0 : we.dismiss);
|
|
580
|
+
for (const U of [c, u, m])
|
|
581
|
+
if (!Number.isFinite(U.tm) || !Number.isFinite(U.dr) || U.dr < 0)
|
|
582
|
+
throw new Error(`firework marker 无效:${U.cm}`);
|
|
583
|
+
const p = e.dismissDuration ?? ge, v = e.density ?? 1, y = e.formationRadius ?? 200;
|
|
584
|
+
if (!Number.isFinite(p) || p <= 0 || !Number.isFinite(v) || v < 0 || !Number.isFinite(y) || y < 0) throw new Error("firework dismissDuration 必须是正数,其他效果参数必须是有限非负数");
|
|
585
|
+
const b = c.tm / o, g = c.dr / o, h = u.tm / o, d = Ge({
|
|
586
|
+
frameRate: o,
|
|
587
|
+
dismissFrame: m.tm,
|
|
588
|
+
durationSeconds: p
|
|
589
|
+
}), w = d.startSeconds;
|
|
590
|
+
if (!(b <= h && h * 1e3 < d.endMs))
|
|
591
|
+
throw new Error("firework marker 时间顺序无效");
|
|
592
|
+
const k = Oe(t, (be = e.anchors) == null ? void 0 : be.launch, c.tm, i), E = Oe(t, (ye = e.anchors) == null ? void 0 : ye.burst, u.tm, i), O = (t.width ?? ((Ee = t.lottie) == null ? void 0 : Ee.w) ?? 0) * i.scale, C = y * i.scale, M = Xe(e.colors), T = v * s;
|
|
593
|
+
if (!Number.isFinite(T)) throw new Error("firework quality 参数无效");
|
|
594
|
+
const R = je(
|
|
595
|
+
Ue({
|
|
596
|
+
launchDuration: g,
|
|
597
|
+
density: v,
|
|
598
|
+
resolvedQualityScale: s
|
|
599
|
+
}),
|
|
600
|
+
l
|
|
601
|
+
);
|
|
602
|
+
if (R.totalCount > n)
|
|
603
|
+
throw new Error(`firework 粒子数量超过安全上限:${n}`);
|
|
604
|
+
const S = at(a), N = [], z = (U) => {
|
|
605
|
+
const I = ot((U - b) / Math.max(g, 1e-3)), ne = I * I, Q = Math.min(O * 0.08, 30 * i.scale), ee = Math.abs(k.y - E.y);
|
|
606
|
+
return ct(
|
|
607
|
+
k,
|
|
608
|
+
{ x: k.x - Q, y: k.y - ee * 0.34 },
|
|
609
|
+
{ x: E.x + Q * 0.55, y: E.y + ee * 0.28 },
|
|
610
|
+
E,
|
|
611
|
+
ne
|
|
612
|
+
);
|
|
613
|
+
}, P = (U, I) => {
|
|
614
|
+
const ne = R.emitterCounts[U];
|
|
615
|
+
for (let Q = 0; Q < ne; Q += 1) {
|
|
616
|
+
const ee = I.start + S() * (I.end - I.start), Se = I.angle + (S() - 0.5) * I.angleRange, ke = Math.max(0, I.velocity + (S() - 0.5) * 2 * I.velocityRange), Me = I.origin(ee);
|
|
617
|
+
N.push(Object.freeze({
|
|
618
|
+
emitterIndex: U,
|
|
619
|
+
type: I.type,
|
|
620
|
+
color: I.color,
|
|
621
|
+
cellKey: me(I.type, I.color),
|
|
622
|
+
blend: I.blend,
|
|
623
|
+
birthTime: ee,
|
|
624
|
+
lifetime: Math.max(0.08, I.lifetime + (S() - 0.5) * 2 * I.lifetimeRange),
|
|
625
|
+
x: Me.x,
|
|
626
|
+
y: Me.y,
|
|
627
|
+
vx: Math.cos(Se) * ke,
|
|
628
|
+
vy: Math.sin(Se) * ke,
|
|
629
|
+
ax: I.gravityX || 0,
|
|
630
|
+
ay: I.gravityY || 0,
|
|
631
|
+
scale: Math.max(0.08, I.scale + (S() - 0.5) * 2 * (I.scaleRange || 0)),
|
|
632
|
+
scaleSpeed: I.scaleSpeed || -0.16,
|
|
633
|
+
rotation: S() * K,
|
|
634
|
+
spin: (I.spin || 0) + (S() - 0.5) * 2 * (I.spinRange || 0)
|
|
635
|
+
}));
|
|
636
|
+
}
|
|
637
|
+
}, j = b + g * 0.84;
|
|
638
|
+
P(0, { type: "glow", color: "#ffffff", blend: "lighter", rate: 105, start: b, end: j, lifetime: 0.24, lifetimeRange: 0.08, velocity: 24 * i.scale, velocityRange: 10 * i.scale, angle: 0, angleRange: K, gravityY: 0, scale: 0.72, scaleRange: 0.24, origin: z }), P(1, { type: "spark", color: M[1], blend: "lighter", rate: 78, start: b, end: j, lifetime: 0.42, lifetimeRange: 0.12, velocity: 38 * i.scale, velocityRange: 18 * i.scale, angle: Math.PI / 2, angleRange: Math.PI * 0.72, gravityY: 38 * i.scale, scale: 0.9, scaleRange: 0.32, spin: 1.4, spinRange: 2.8, origin: z }), P(2, { type: "glow", color: M[0], blend: "lighter", rate: 48, start: b, end: j, lifetime: 0.5, lifetimeRange: 0.16, velocity: 30 * i.scale, velocityRange: 16 * i.scale, angle: Math.PI / 2, angleRange: Math.PI * 0.88, gravityY: 32 * i.scale, scale: 0.5, scaleRange: 0.2, origin: z }), P(3, { type: "smoke", color: "rgba(184, 184, 184, 0.24)", blend: "source-over", rate: 18, start: b, end: j, lifetime: 0.72, lifetimeRange: 0.18, velocity: 18 * i.scale, velocityRange: 9 * i.scale, angle: 0, angleRange: K, gravityY: -8 * i.scale, scale: 0.9, scaleRange: 0.32, scaleSpeed: 0.24, origin: z });
|
|
639
|
+
const f = Math.max(C * 1.22, 118 * i.scale);
|
|
640
|
+
P(4, { type: "spark", color: M[1], blend: "lighter", rate: 390, start: h, end: h + 0.11, lifetime: 1.18, lifetimeRange: 0.28, velocity: f, velocityRange: f * 0.42, angle: 0, angleRange: K, gravityY: 72 * i.scale, scale: 0.5, scaleRange: 0.19, scaleSpeed: -0.1, spin: 1.8, spinRange: 4.2, origin: () => E }), P(5, { type: "spark", color: M[0], blend: "lighter", rate: 275, start: h, end: h + 0.11, lifetime: 1.38, lifetimeRange: 0.34, velocity: f * 0.82, velocityRange: f * 0.46, angle: 0, angleRange: K, gravityY: 84 * i.scale, scale: 0.4, scaleRange: 0.15, scaleSpeed: -0.1, spin: -1.2, spinRange: 4.8, origin: () => E }), P(6, { type: "glow", color: "#ffffff", blend: "lighter", rate: 145, start: h, end: h + 0.11, lifetime: 0.62, lifetimeRange: 0.12, velocity: f * 0.68, velocityRange: f * 0.26, angle: 0, angleRange: K, gravityY: 46 * i.scale, scale: 0.44, scaleRange: 0.17, scaleSpeed: -0.1, origin: () => E });
|
|
641
|
+
const A = h + 0.12, _ = Math.max(C * 0.74, 76 * i.scale);
|
|
642
|
+
P(7, { type: "star", color: "#ffffff", blend: "lighter", rate: 265, start: A, end: A + 0.14, lifetime: 1.5, lifetimeRange: 0.38, velocity: _, velocityRange: _ * 0.48, angle: 0, angleRange: K, gravityY: 62 * i.scale, scale: 0.4, scaleRange: 0.18, scaleSpeed: -0.055, spin: 1.8, spinRange: 5.6, origin: () => E }), P(8, { type: "glow", color: M[2] || M[1], blend: "lighter", rate: 175, start: A, end: A + 0.14, lifetime: 1.72, lifetimeRange: 0.42, velocity: _ * 0.72, velocityRange: _ * 0.5, angle: 0, angleRange: K, gravityY: 74 * i.scale, scale: 0.24, scaleRange: 0.12, scaleSpeed: -0.035, origin: () => E }), P(9, { type: "petal", color: M[0], blend: "lighter", rate: 48, start: A, end: A + 0.14, lifetime: 1.55, lifetimeRange: 0.32, velocity: _ * 0.62, velocityRange: _ * 0.38, angle: 0, angleRange: K, gravityX: 5 * i.scale, gravityY: 86 * i.scale, scale: 0.62, scaleRange: 0.26, scaleSpeed: -0.08, spin: 2.4, spinRange: 6.2, origin: () => E });
|
|
643
|
+
const D = [], G = [];
|
|
644
|
+
for (const U of N) (U.blend === "source-over" ? D : G).push(U);
|
|
645
|
+
const Y = ft(d), W = Object.freeze({
|
|
646
|
+
type: "flash",
|
|
647
|
+
color: M[0],
|
|
648
|
+
cellKey: me("flash", M[0]),
|
|
649
|
+
x: E.x,
|
|
650
|
+
y: E.y,
|
|
651
|
+
birthTime: h,
|
|
652
|
+
lifetime: 0.36,
|
|
653
|
+
opacityEnvelope: ht(h),
|
|
654
|
+
sizeEnvelope: dt(h)
|
|
655
|
+
});
|
|
656
|
+
return Object.freeze({
|
|
657
|
+
seed: a,
|
|
658
|
+
palette: M,
|
|
659
|
+
atlasRecipeKey: Ve(e).key,
|
|
660
|
+
timeline: Object.freeze({ launchStart: b, launchDuration: g, burstStart: h, dismissStart: w, dismissDuration: p }),
|
|
661
|
+
launchPoint: Object.freeze(k),
|
|
662
|
+
burstPoint: Object.freeze(E),
|
|
663
|
+
particles: Object.freeze(N),
|
|
664
|
+
smoke: Object.freeze(D),
|
|
665
|
+
main: Object.freeze(G),
|
|
666
|
+
flash: W,
|
|
667
|
+
dismissEnvelope: Y
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
function Fe(e) {
|
|
671
|
+
return typeof e == "string" ? e.trim() : "";
|
|
672
|
+
}
|
|
673
|
+
function mt(e = {}) {
|
|
674
|
+
const t = e.playConfig || e, i = t.multiGiftEffect || {}, s = t.giftUrl || t.assetUrl || "", r = t.giftRealSize || t.giftBodySize || null;
|
|
675
|
+
let n = t.assetType;
|
|
676
|
+
n || (s === "box" ? n = "box" : typeof s == "string" && (/\.(png|jpe?g|webp|gif|bmp)($|\?)/i.test(s) || s.startsWith("data:image/")) ? n = "image" : n = "svga");
|
|
677
|
+
const l = i.lottie || t.lottieUrl || t.lottie, a = i.slotSize || t.slotSize || { width: 60, height: 60 }, o = Array.isArray(i.effects) ? i.effects : Array.isArray(t.effects) ? t.effects : [], c = Array.isArray(i.imgs) ? i.imgs : Array.isArray(t.imgs) ? t.imgs : [], u = e.imageSlots && e.imageSlots.length ? e.imageSlots : c.map((p) => ({
|
|
678
|
+
slot: p.slot,
|
|
679
|
+
width: p.width,
|
|
680
|
+
height: p.height,
|
|
681
|
+
radius: p.radius
|
|
682
|
+
})), m = {
|
|
683
|
+
...e.imageUrls || {},
|
|
684
|
+
...Object.fromEntries(
|
|
685
|
+
c.filter((p) => p.url !== void 0 && p.url !== null).map((p) => [p.slot, p.url])
|
|
686
|
+
)
|
|
687
|
+
};
|
|
688
|
+
return {
|
|
689
|
+
giftUrl: s,
|
|
690
|
+
giftRealSize: r,
|
|
691
|
+
giftBodySize: r,
|
|
692
|
+
assetType: n,
|
|
693
|
+
assetUrl: s,
|
|
694
|
+
lottie: l,
|
|
695
|
+
lottieUrl: l,
|
|
696
|
+
slotSize: a,
|
|
697
|
+
effects: o,
|
|
698
|
+
imgs: c,
|
|
699
|
+
imageSlots: u,
|
|
700
|
+
imageUrls: m
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
const gt = 16, Ie = 24;
|
|
704
|
+
function fe(e, t, i) {
|
|
705
|
+
if (!Number.isFinite(t) || t < 1)
|
|
706
|
+
throw new Error("firework GPU capability maxInstancesPerBatch 无效");
|
|
707
|
+
if (e > t)
|
|
708
|
+
throw new Error(`${i} 粒子数量超过 GPU batch 上限:${t}`);
|
|
709
|
+
}
|
|
710
|
+
function pt(e, t, i) {
|
|
711
|
+
e.set([
|
|
712
|
+
i.birthTime,
|
|
713
|
+
i.lifetime,
|
|
714
|
+
i.x,
|
|
715
|
+
i.y,
|
|
716
|
+
i.vx,
|
|
717
|
+
i.vy,
|
|
718
|
+
i.ax,
|
|
719
|
+
i.ay,
|
|
720
|
+
i.scale,
|
|
721
|
+
i.scaleSpeed,
|
|
722
|
+
i.rotation,
|
|
723
|
+
i.spin,
|
|
724
|
+
1,
|
|
725
|
+
1,
|
|
726
|
+
1,
|
|
727
|
+
1
|
|
728
|
+
], t);
|
|
729
|
+
}
|
|
730
|
+
function he(e, t, i) {
|
|
731
|
+
const s = new Float32Array(e.length * Ie);
|
|
732
|
+
return e.forEach((r, n) => {
|
|
733
|
+
const l = t.get(r.cellKey);
|
|
734
|
+
if (!l) throw new Error(`firework atlas 缺少 cell:${r.cellKey}`);
|
|
735
|
+
const a = n * Ie;
|
|
736
|
+
pt(s, a, r), s.set([
|
|
737
|
+
l.width * i,
|
|
738
|
+
l.height * i,
|
|
739
|
+
0.5,
|
|
740
|
+
0.5,
|
|
741
|
+
l.u0,
|
|
742
|
+
l.v0,
|
|
743
|
+
l.u1,
|
|
744
|
+
l.v1
|
|
745
|
+
], a + gt);
|
|
746
|
+
}), s;
|
|
747
|
+
}
|
|
748
|
+
function wt(e, t) {
|
|
749
|
+
var a, o;
|
|
750
|
+
const i = ((a = e[0]) == null ? void 0 : a.startMs) ?? 1 / 0, s = ((o = e.at(-1)) == null ? void 0 : o.endMs) ?? -1 / 0;
|
|
751
|
+
if (!Number.isFinite(i) || !Number.isFinite(s) || !(s > i)) return [];
|
|
752
|
+
const r = /* @__PURE__ */ new Set([i, s]);
|
|
753
|
+
for (const c of [...e, ...t])
|
|
754
|
+
c.startMs > i && c.startMs < s && r.add(c.startMs), c.endMs > i && c.endMs < s && r.add(c.endMs);
|
|
755
|
+
const n = [...r].sort((c, u) => c - u), l = [];
|
|
756
|
+
for (let c = 0; c < n.length - 1; c += 1) {
|
|
757
|
+
const u = n[c], m = n[c + 1];
|
|
758
|
+
if (!(m > u)) continue;
|
|
759
|
+
const p = (d, w = !1) => Ae(e, d, 1, w) * Ae(t, d, 1, w), v = p(u), y = p(m, !0), b = (u + m) * 0.5, h = Math.abs(p(b) - (v + y) * 0.5) > 1e-6 ? 4 : m - u;
|
|
760
|
+
for (let d = u; d < m; d += h) {
|
|
761
|
+
const w = Math.min(m, d + h);
|
|
762
|
+
l.push({
|
|
763
|
+
startMs: d,
|
|
764
|
+
endMs: w,
|
|
765
|
+
from: p(d),
|
|
766
|
+
to: p(w, !0),
|
|
767
|
+
interpolation: "linear"
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return l;
|
|
772
|
+
}
|
|
773
|
+
function bt({
|
|
774
|
+
effect: e,
|
|
775
|
+
composition: t,
|
|
776
|
+
layout: i,
|
|
777
|
+
resolvedQualityScale: s,
|
|
778
|
+
seed: r,
|
|
779
|
+
atlas: n,
|
|
780
|
+
atlasCells: l,
|
|
781
|
+
maxInstancesPerBatch: a
|
|
782
|
+
}) {
|
|
783
|
+
const o = ut({
|
|
784
|
+
effect: e,
|
|
785
|
+
composition: t,
|
|
786
|
+
layout: i,
|
|
787
|
+
resolvedQualityScale: s,
|
|
788
|
+
seed: r,
|
|
789
|
+
maxParticleCount: a * 2,
|
|
790
|
+
maxInstancesPerBatch: a
|
|
791
|
+
});
|
|
792
|
+
fe(o.smoke.length, a, "firework smoke"), fe(o.main.length, a, "firework main"), fe(1, a, "firework flash");
|
|
793
|
+
const c = {
|
|
794
|
+
birthTime: o.flash.birthTime,
|
|
795
|
+
lifetime: o.flash.lifetime,
|
|
796
|
+
x: o.flash.x,
|
|
797
|
+
y: o.flash.y,
|
|
798
|
+
vx: 0,
|
|
799
|
+
vy: 0,
|
|
800
|
+
ax: 0,
|
|
801
|
+
ay: 0,
|
|
802
|
+
scale: 1,
|
|
803
|
+
scaleSpeed: 0,
|
|
804
|
+
rotation: 0,
|
|
805
|
+
spin: 0,
|
|
806
|
+
cellKey: o.flash.cellKey
|
|
807
|
+
}, u = {
|
|
808
|
+
format: "sprite-v2",
|
|
809
|
+
atlas: n,
|
|
810
|
+
opacity: 1,
|
|
811
|
+
compositeLayer: "behind-media"
|
|
812
|
+
};
|
|
813
|
+
return Object.freeze({
|
|
814
|
+
model: o,
|
|
815
|
+
descriptors: Object.freeze([
|
|
816
|
+
Object.freeze({
|
|
817
|
+
...u,
|
|
818
|
+
count: o.smoke.length,
|
|
819
|
+
instances: he(o.smoke, l, i.scale),
|
|
820
|
+
fadeMode: "lifetime",
|
|
821
|
+
envelope: { opacity: o.dismissEnvelope },
|
|
822
|
+
zIndex: 0,
|
|
823
|
+
blend: "normal",
|
|
824
|
+
label: "multi-gift-firework-smoke"
|
|
825
|
+
}),
|
|
826
|
+
Object.freeze({
|
|
827
|
+
...u,
|
|
828
|
+
count: o.main.length,
|
|
829
|
+
instances: he(o.main, l, i.scale),
|
|
830
|
+
fadeMode: "lifetime",
|
|
831
|
+
envelope: { opacity: o.dismissEnvelope },
|
|
832
|
+
zIndex: 1,
|
|
833
|
+
blend: "additive",
|
|
834
|
+
label: "multi-gift-firework-main"
|
|
835
|
+
}),
|
|
836
|
+
Object.freeze({
|
|
837
|
+
...u,
|
|
838
|
+
count: 1,
|
|
839
|
+
instances: he([c], l, i.scale),
|
|
840
|
+
fadeMode: "none",
|
|
841
|
+
envelope: {
|
|
842
|
+
opacity: wt(o.flash.opacityEnvelope, o.dismissEnvelope),
|
|
843
|
+
size: o.flash.sizeEnvelope
|
|
844
|
+
},
|
|
845
|
+
zIndex: 2,
|
|
846
|
+
blend: "additive",
|
|
847
|
+
label: "multi-gift-firework-flash"
|
|
848
|
+
})
|
|
849
|
+
])
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
const re = 4, x = 256;
|
|
853
|
+
function yt(e, t, i) {
|
|
854
|
+
if (i) return i(e, t);
|
|
855
|
+
if (typeof OffscreenCanvas < "u") return new OffscreenCanvas(e, t);
|
|
856
|
+
if (typeof document < "u") {
|
|
857
|
+
const s = document.createElement("canvas");
|
|
858
|
+
return s.width = e, s.height = t, s;
|
|
859
|
+
}
|
|
860
|
+
throw new Error("当前环境无法生成 firework sprite atlas");
|
|
861
|
+
}
|
|
862
|
+
function Et(e) {
|
|
863
|
+
const t = /* @__PURE__ */ new Map();
|
|
864
|
+
let i = 0, s = 0, r = 0;
|
|
865
|
+
for (const n of e.cells) {
|
|
866
|
+
const l = n.width + re * 2, a = n.height + re * 2;
|
|
867
|
+
if (i + l > x && (i = 0, s += r, r = 0), s + a > x) throw new Error("firework atlas recipe exceeds 256x256");
|
|
868
|
+
const o = i + re, c = s + re;
|
|
869
|
+
t.set(n.key, Object.freeze({
|
|
870
|
+
...n,
|
|
871
|
+
x: o,
|
|
872
|
+
y: c,
|
|
873
|
+
// Use cell-edge coordinates. GPU raster pixel centres then sample the
|
|
874
|
+
// corresponding Canvas pixel centres without shrinking the sprite.
|
|
875
|
+
u0: o / x,
|
|
876
|
+
v0: c / x,
|
|
877
|
+
u1: (o + n.width) / x,
|
|
878
|
+
v1: (c + n.height) / x
|
|
879
|
+
})), i += l, r = Math.max(r, a);
|
|
880
|
+
}
|
|
881
|
+
return t;
|
|
882
|
+
}
|
|
883
|
+
function St(e, t = {}) {
|
|
884
|
+
const i = Ve(e), s = Et(i), r = yt(x, x, t.canvasFactory);
|
|
885
|
+
r.width = x, r.height = x;
|
|
886
|
+
const n = r.getContext("2d", { willReadFrequently: !0 });
|
|
887
|
+
if (!n) throw new Error("无法创建 firework atlas Canvas2D context");
|
|
888
|
+
n.clearRect(0, 0, x, x);
|
|
889
|
+
for (const o of s.values()) st(n, o, o.x, o.y);
|
|
890
|
+
const l = n.getImageData(0, 0, x, x), a = new Uint8Array(l.data.length);
|
|
891
|
+
for (let o = 0; o < l.data.length; o += 4) {
|
|
892
|
+
const c = l.data[o + 3];
|
|
893
|
+
a[o + 3] = c, c === 0 ? (a[o] = 0, a[o + 1] = 0, a[o + 2] = 0) : (a[o] = Math.round(l.data[o] * c / 255), a[o + 1] = Math.round(l.data[o + 1] * c / 255), a[o + 2] = Math.round(l.data[o + 2] * c / 255));
|
|
894
|
+
}
|
|
895
|
+
return Object.freeze({
|
|
896
|
+
key: i.key,
|
|
897
|
+
width: x,
|
|
898
|
+
height: x,
|
|
899
|
+
pixels: a,
|
|
900
|
+
cells: s
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
const Ne = 8, _e = 10;
|
|
904
|
+
function kt(e) {
|
|
905
|
+
const t = new RegExp(`^${e}_(\\d+)$`);
|
|
906
|
+
return (i, s) => {
|
|
907
|
+
var l, a;
|
|
908
|
+
const r = Number(((l = t.exec(i.nm)) == null ? void 0 : l[1]) ?? Number.MAX_SAFE_INTEGER), n = Number(((a = t.exec(s.nm)) == null ? void 0 : a[1]) ?? Number.MAX_SAFE_INTEGER);
|
|
909
|
+
return r - n;
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
function Ce(e, t, i, s) {
|
|
913
|
+
return !e || !t || !i || !s ? 1 : Math.min(i / e, s / t);
|
|
914
|
+
}
|
|
915
|
+
function Mt(e) {
|
|
916
|
+
return Number.isFinite(e == null ? void 0 : e.x) && Number.isFinite(e == null ? void 0 : e.y) ? { x: e.x, y: e.y } : null;
|
|
917
|
+
}
|
|
918
|
+
function J(e) {
|
|
919
|
+
const t = new Error(e);
|
|
920
|
+
return t.name = "AbortError", t;
|
|
921
|
+
}
|
|
922
|
+
function Pe(e) {
|
|
923
|
+
var i, s, r, n;
|
|
924
|
+
const t = (i = e == null ? void 0 : e.capabilities) == null ? void 0 : i.particles;
|
|
925
|
+
return (t == null ? void 0 : t.backend) === "unavailable" || !((s = t == null ? void 0 : t.formats) != null && s.includes("sprite-v2")) || ((r = t == null ? void 0 : t.spriteAtlas) == null ? void 0 : r.source) !== "rgba8-premultiplied" || !((n = t == null ? void 0 : t.compositeLayers) != null && n.includes("behind-media")) || (t == null ? void 0 : t.batchEnvelope) !== !0 || (t == null ? void 0 : t.atomicBatchGroup) !== !0 || !Number.isFinite(t == null ? void 0 : t.maxInstancesPerBatch) || typeof (e == null ? void 0 : e.createParticleAtlas) != "function" ? null : t;
|
|
926
|
+
}
|
|
927
|
+
function Le(e) {
|
|
928
|
+
const t = typeof navigator < "u" ? navigator : {};
|
|
929
|
+
return {
|
|
930
|
+
quality: e,
|
|
931
|
+
deviceMemory: t.deviceMemory,
|
|
932
|
+
hardwareConcurrency: t.hardwareConcurrency,
|
|
933
|
+
userAgent: t.userAgent
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
function vt(e, t) {
|
|
937
|
+
if (!Number.isFinite(e)) return t;
|
|
938
|
+
let i = t;
|
|
939
|
+
for (; i - e > Math.PI; ) i -= Math.PI * 2;
|
|
940
|
+
for (; i - e < -Math.PI; ) i += Math.PI * 2;
|
|
941
|
+
return i;
|
|
942
|
+
}
|
|
943
|
+
async function Tt(e, t) {
|
|
944
|
+
if (e && typeof e == "object") return e;
|
|
945
|
+
if (typeof e == "string" && e.trim().startsWith("{"))
|
|
946
|
+
try {
|
|
947
|
+
return JSON.parse(e);
|
|
948
|
+
} catch (s) {
|
|
949
|
+
throw new Error(`Lottie JSON 解析失败:${s.message || "格式错误"}`);
|
|
950
|
+
}
|
|
951
|
+
if (typeof e != "string" || !e.trim())
|
|
952
|
+
throw new Error("未提供有效的 Lottie 轨迹配置");
|
|
953
|
+
const i = await fetch(e, { signal: t });
|
|
954
|
+
if (!i.ok) throw new Error(`Lottie 加载失败 (${i.status})`);
|
|
955
|
+
return i.json();
|
|
956
|
+
}
|
|
957
|
+
function ze(e, t, i) {
|
|
958
|
+
var l;
|
|
959
|
+
const s = (l = e == null ? void 0 : e.capabilities) == null ? void 0 : l.motionTrack, r = (s == null ? void 0 : s.gpuMediaTypes) || [];
|
|
960
|
+
return (s == null ? void 0 : s.mode) === "gpu-table" && t === "svga" && r.includes(t) ? "gpu-table" : "cpu-reference";
|
|
961
|
+
}
|
|
962
|
+
function Rt(e) {
|
|
963
|
+
if (!e || typeof e.getRenderInfo != "function") return null;
|
|
964
|
+
try {
|
|
965
|
+
return e.getRenderInfo();
|
|
966
|
+
} catch {
|
|
967
|
+
return null;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
function At(e, t) {
|
|
971
|
+
var s, r;
|
|
972
|
+
const i = [];
|
|
973
|
+
return e.forEach((n, l) => {
|
|
974
|
+
if (n.kind !== "svga") return;
|
|
975
|
+
const a = t[l], o = Rt(a), c = {
|
|
976
|
+
slotId: n.id,
|
|
977
|
+
giftId: (a == null ? void 0 : a.id) ?? n.id,
|
|
978
|
+
svgaFramePath: (o == null ? void 0 : o.svgaFramePath) ?? (o == null ? void 0 : o.selectedPath) ?? (o == null ? void 0 : o.path) ?? null
|
|
979
|
+
};
|
|
980
|
+
o != null && o.parentMotionMode && (c.parentMotionMode = o.parentMotionMode);
|
|
981
|
+
for (const u of [
|
|
982
|
+
"backend",
|
|
983
|
+
"pathState",
|
|
984
|
+
"frameTableBytes",
|
|
985
|
+
"commandTableBytes",
|
|
986
|
+
"drawBatchMode",
|
|
987
|
+
"drawCompatibleInstanceCount",
|
|
988
|
+
"fallbackReasons"
|
|
989
|
+
])
|
|
990
|
+
(o == null ? void 0 : o[u]) != null && (c[u] = o[u]);
|
|
991
|
+
i.push(c);
|
|
992
|
+
}), {
|
|
993
|
+
// A formation uses one shared resource, so this is the primary path. The
|
|
994
|
+
// per-slot list remains available for mixed/future resource plans.
|
|
995
|
+
svgaFramePath: ((s = i.find((n) => n.svgaFramePath != null)) == null ? void 0 : s.svgaFramePath) ?? null,
|
|
996
|
+
parentMotionMode: ((r = i.find((n) => n.parentMotionMode != null)) == null ? void 0 : r.parentMotionMode) ?? null,
|
|
997
|
+
svgaFramePaths: i
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
class Ot {
|
|
1001
|
+
constructor(t, i, s, r, n) {
|
|
1002
|
+
this.id = t, this.scope = i, this.completion = s, this.onStop = r, this.diagnosticsProvider = n;
|
|
1003
|
+
}
|
|
1004
|
+
get diagnostics() {
|
|
1005
|
+
return this.diagnosticsProvider();
|
|
1006
|
+
}
|
|
1007
|
+
get state() {
|
|
1008
|
+
return this.scope.state;
|
|
1009
|
+
}
|
|
1010
|
+
pause() {
|
|
1011
|
+
this.scope.pause();
|
|
1012
|
+
}
|
|
1013
|
+
resume() {
|
|
1014
|
+
this.scope.resume();
|
|
1015
|
+
}
|
|
1016
|
+
seek(t) {
|
|
1017
|
+
this.scope.seek(t);
|
|
1018
|
+
}
|
|
1019
|
+
stop() {
|
|
1020
|
+
this.onStop();
|
|
1021
|
+
}
|
|
1022
|
+
destroy() {
|
|
1023
|
+
this.onStop();
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
class Ft {
|
|
1027
|
+
constructor(t, i = {}) {
|
|
1028
|
+
this.host = t, this.options = i, this.sampleRate = Math.max(30, Math.min(120, i.sampleRate || 60)), this.onStateChange = i.onStateChange || (() => {
|
|
1029
|
+
}), this.onRenderFrame = i.onRenderFrame || (() => {
|
|
1030
|
+
}), this.disabledSlotIds = new Set(i.disabledSlotIds || []), this.playConfig = null, this.composition = null, this.assetLease = null, this.imageLeases = /* @__PURE__ */ new Map(), this.activePlayback = null, this.pendingScope = null, this.playEpoch = 0, this.playIntentEpoch = 0, this.preloadController = null, this.preloadEpoch = 0, this._preloadDiagnostics = null, this.fireworkAtlas = null, this.fireworkAtlasCells = null, this.fireworkAtlasRecipeKey = null, this.fireworkQualityScale = 1, this.particleCapabilityWarningEmitted = !1, this.destroyed = !1;
|
|
1031
|
+
}
|
|
1032
|
+
get capabilities() {
|
|
1033
|
+
return this.host.capabilities;
|
|
1034
|
+
}
|
|
1035
|
+
get preloadDiagnostics() {
|
|
1036
|
+
return this._preloadDiagnostics;
|
|
1037
|
+
}
|
|
1038
|
+
async preload(t = this.options.playConfig, i = !1) {
|
|
1039
|
+
var v, y, b;
|
|
1040
|
+
if (this.assertAlive(), !t) throw new Error("未提供 playConfig");
|
|
1041
|
+
this.cancelPlayback(!i), this.releaseLeases(), this.playConfig = null, this.composition = null, this._preloadDiagnostics = null;
|
|
1042
|
+
const s = mt({ ...this.options, playConfig: t });
|
|
1043
|
+
if (s.assetType !== "svga" && s.assetType !== "image")
|
|
1044
|
+
throw new Error(`GiftStage 插件不支持的礼物类型:${s.assetType}`);
|
|
1045
|
+
this.emitStateChange({ status: "loading", message: "正在预加载 Lottie 与共享礼物资源" });
|
|
1046
|
+
const r = new AbortController();
|
|
1047
|
+
(v = this.preloadController) == null || v.abort(), this.preloadController = r;
|
|
1048
|
+
const n = ++this.preloadEpoch;
|
|
1049
|
+
let l = null, a = /* @__PURE__ */ new Map(), o = null, c = null, u = null, m = 1, p = !1;
|
|
1050
|
+
try {
|
|
1051
|
+
const g = await Tt(s.lottieUrl, r.signal);
|
|
1052
|
+
this.assertCurrentPreload(r, n);
|
|
1053
|
+
const h = Pe(this.host), d = Qe(g, {
|
|
1054
|
+
effects: s.effects,
|
|
1055
|
+
fireworkEnvironment: Le("auto"),
|
|
1056
|
+
maxInstancesPerBatch: Math.min(
|
|
1057
|
+
Z,
|
|
1058
|
+
(h == null ? void 0 : h.maxInstancesPerBatch) ?? Z
|
|
1059
|
+
)
|
|
1060
|
+
});
|
|
1061
|
+
d.length && this.emitStateChange({ validationFindings: d });
|
|
1062
|
+
const w = d.find((f) => f.code === "LOTTIE_TARGET_MARKER_MISSING");
|
|
1063
|
+
if (w)
|
|
1064
|
+
throw this.emitStateChange({
|
|
1065
|
+
status: "fallback",
|
|
1066
|
+
reason: w.code,
|
|
1067
|
+
message: "多礼物编排缺少 target_flight,交由宿主降级普通单礼物"
|
|
1068
|
+
}), new ae(
|
|
1069
|
+
w.code,
|
|
1070
|
+
"Lottie 中缺少有效的 target_flight marker",
|
|
1071
|
+
d,
|
|
1072
|
+
!0
|
|
1073
|
+
);
|
|
1074
|
+
const k = d.filter(
|
|
1075
|
+
(f) => f.scope === "composition" && f.severity === "error"
|
|
1076
|
+
);
|
|
1077
|
+
if (k.length)
|
|
1078
|
+
throw new ae(
|
|
1079
|
+
k[0].code,
|
|
1080
|
+
`Lottie 合成校验失败:${k.map((f) => `${f.code}@${f.where}`).join(", ")}`,
|
|
1081
|
+
d
|
|
1082
|
+
);
|
|
1083
|
+
const E = new Set(d.filter((f) => f.scope === "slot" && f.severity === "error" && f.layer).map((f) => f.layer)), O = new Set(d.filter((f) => f.scope === "effect" && Number.isInteger(f.effectIndex)).map((f) => f.effectIndex)), C = new Map((g.layers || []).map((f) => [f.nm, f])), M = (g.layers || []).filter((f) => /^slot_\d+$/.test(f.nm) && f.ks && !E.has(f.nm)).sort(kt("slot"));
|
|
1084
|
+
if (!M.length)
|
|
1085
|
+
throw new ae(
|
|
1086
|
+
"LOTTIE_SLOT_MISSING",
|
|
1087
|
+
"Lottie 中没有可播放的 slot_N 礼物插槽图层",
|
|
1088
|
+
d
|
|
1089
|
+
);
|
|
1090
|
+
const T = pe(g.markers, "target_flight"), R = s.effects.filter((f, A) => !O.has(A));
|
|
1091
|
+
l = await this.host.preload(
|
|
1092
|
+
s.assetType,
|
|
1093
|
+
s.assetUrl,
|
|
1094
|
+
r.signal
|
|
1095
|
+
), this.assertCurrentPreload(r, n);
|
|
1096
|
+
for (const f of s.imageSlots) {
|
|
1097
|
+
const A = Fe(s.imageUrls[f.slot]);
|
|
1098
|
+
if (!A || !((y = C.get(f.slot)) != null && y.ks) || E.has(f.slot)) continue;
|
|
1099
|
+
const _ = await this.host.preload("image", A, r.signal);
|
|
1100
|
+
(b = a.get(f.slot)) == null || b.release(), a.set(f.slot, _), this.assertCurrentPreload(r, n);
|
|
1101
|
+
}
|
|
1102
|
+
const S = {
|
|
1103
|
+
startFrame: T.tm,
|
|
1104
|
+
endFrame: T.tm + T.dr
|
|
1105
|
+
}, N = new Map(M.map((f) => {
|
|
1106
|
+
var W, X;
|
|
1107
|
+
const A = ((X = (W = f.ks) == null ? void 0 : W.s) == null ? void 0 : X.a) === 1 && Array.isArray(f.ks.s.k) ? f.ks.s.k.filter(($) => Number.isFinite($ == null ? void 0 : $.t) && $.t >= S.startFrame && $.t <= S.endFrame).sort(($, se) => $.t - se.t) : [], _ = A[0], D = A[A.length - 1];
|
|
1108
|
+
let G = Number.isFinite(_ == null ? void 0 : _.t) ? _.t : S.startFrame, Y = Number.isFinite(D == null ? void 0 : D.t) ? D.t : S.endFrame;
|
|
1109
|
+
return G = Math.max(S.startFrame, Math.min(S.endFrame, G)), Y = Math.max(S.startFrame, Math.min(S.endFrame, Y)), Y > G || (G = S.startFrame, Y = S.endFrame), [f.nm, { start: G, end: Y }];
|
|
1110
|
+
})), z = {
|
|
1111
|
+
lottie: g,
|
|
1112
|
+
width: g.w,
|
|
1113
|
+
height: g.h,
|
|
1114
|
+
frameRate: g.fr,
|
|
1115
|
+
inFrame: g.ip,
|
|
1116
|
+
outFrame: g.op,
|
|
1117
|
+
durationMs: (g.op - g.ip) / g.fr * 1e3,
|
|
1118
|
+
layers: C,
|
|
1119
|
+
timeline: M,
|
|
1120
|
+
targetFlight: S,
|
|
1121
|
+
flightWindows: N
|
|
1122
|
+
}, P = R.find((f) => f.type === "firework");
|
|
1123
|
+
if (P && h) {
|
|
1124
|
+
m = $e(
|
|
1125
|
+
Le(P.quality ?? "auto")
|
|
1126
|
+
);
|
|
1127
|
+
const f = St(P);
|
|
1128
|
+
if (f.width > h.spriteAtlas.maxSize || f.height > h.spriteAtlas.maxSize) throw new Error("firework atlas 超过当前 GPU capability");
|
|
1129
|
+
o = await this.host.createParticleAtlas({
|
|
1130
|
+
width: f.width,
|
|
1131
|
+
height: f.height,
|
|
1132
|
+
pixels: f.pixels,
|
|
1133
|
+
colorSpace: "srgb",
|
|
1134
|
+
alphaMode: "premultiplied",
|
|
1135
|
+
filter: "linear",
|
|
1136
|
+
label: `multi-gift-firework:${f.key}`
|
|
1137
|
+
}), c = f.cells, u = f.key, this.assertCurrentPreload(r, n);
|
|
1138
|
+
}
|
|
1139
|
+
this.assertCurrentPreload(r, n), this.playConfig = { ...s, effects: R }, this.assetLease = l, this.imageLeases = a, this.composition = z, this.fireworkAtlas = o, this.fireworkAtlasCells = c, this.fireworkAtlasRecipeKey = u, this.fireworkQualityScale = m, p = !0;
|
|
1140
|
+
const j = ze(
|
|
1141
|
+
this.host,
|
|
1142
|
+
s.assetType,
|
|
1143
|
+
l.metadata
|
|
1144
|
+
);
|
|
1145
|
+
this._preloadDiagnostics = Object.freeze({
|
|
1146
|
+
parentMotionMode: j,
|
|
1147
|
+
// Compatibility alias retained for existing host diagnostics.
|
|
1148
|
+
motionMode: j
|
|
1149
|
+
}), this.emitStateChange({
|
|
1150
|
+
status: "ready",
|
|
1151
|
+
message: `${M.length} 个礼物轨道已就绪`,
|
|
1152
|
+
slotCount: M.length,
|
|
1153
|
+
backend: this.host.capabilities.backend,
|
|
1154
|
+
...this._preloadDiagnostics
|
|
1155
|
+
});
|
|
1156
|
+
} catch (g) {
|
|
1157
|
+
if (!p) {
|
|
1158
|
+
l == null || l.release();
|
|
1159
|
+
for (const h of a.values()) h.release();
|
|
1160
|
+
o == null || o.destroy();
|
|
1161
|
+
}
|
|
1162
|
+
throw (g == null ? void 0 : g.name) === "AbortError" || this.destroyed || this.preloadEpoch !== n || r.signal.aborted ? J("多礼物资源预加载已取消") : g;
|
|
1163
|
+
} finally {
|
|
1164
|
+
this.preloadController === r && (this.preloadController = null);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
async play(t = {}) {
|
|
1168
|
+
var v, y, b;
|
|
1169
|
+
if (this.assertAlive(), !Object.prototype.hasOwnProperty.call(t, "target"))
|
|
1170
|
+
throw new Error("play() 必须显式传入 target,值可为 null 或 undefined");
|
|
1171
|
+
const i = ++this.playIntentEpoch;
|
|
1172
|
+
if (!this.composition && (await this.preload(void 0, !0), this.playIntentEpoch !== i) || (this.assertAlive(), this.playIntentEpoch !== i))
|
|
1173
|
+
throw J("多礼物播放已取消");
|
|
1174
|
+
this.cancelPlayback(!1);
|
|
1175
|
+
const s = this.composition, r = this.playConfig, n = Mt(t.target), l = this.host.getViewport(), a = s.width > 0 ? l.width / s.width : 1, o = 0, c = (l.height - s.height * a) * 0.5, u = this.host.createPlaybackScope(`multi-gift-${Date.now()}`), m = this.playEpoch;
|
|
1176
|
+
this.pendingScope = { scope: u, playEpoch: m };
|
|
1177
|
+
const p = s.timeline.map((g, h) => {
|
|
1178
|
+
var d, w, k, E, O, C, M, T;
|
|
1179
|
+
return {
|
|
1180
|
+
id: g.nm,
|
|
1181
|
+
layer: g,
|
|
1182
|
+
kind: r.assetType,
|
|
1183
|
+
source: r.assetUrl,
|
|
1184
|
+
width: this.assetLease.metadata.width * Ce(
|
|
1185
|
+
(d = r.giftBodySize) == null ? void 0 : d.width,
|
|
1186
|
+
(w = r.giftBodySize) == null ? void 0 : w.height,
|
|
1187
|
+
(k = r.slotSize) == null ? void 0 : k.width,
|
|
1188
|
+
(E = r.slotSize) == null ? void 0 : E.height
|
|
1189
|
+
) * a,
|
|
1190
|
+
height: this.assetLease.metadata.height * Ce(
|
|
1191
|
+
(O = r.giftBodySize) == null ? void 0 : O.width,
|
|
1192
|
+
(C = r.giftBodySize) == null ? void 0 : C.height,
|
|
1193
|
+
(M = r.slotSize) == null ? void 0 : M.width,
|
|
1194
|
+
(T = r.slotSize) == null ? void 0 : T.height
|
|
1195
|
+
) * a,
|
|
1196
|
+
zIndex: _e + h,
|
|
1197
|
+
redirect: !0
|
|
1198
|
+
};
|
|
1199
|
+
});
|
|
1200
|
+
for (const g of r.imageSlots) {
|
|
1201
|
+
const h = this.imageLeases.get(g.slot), d = s.layers.get(g.slot);
|
|
1202
|
+
!h || !(d != null && d.ks) || p.push({
|
|
1203
|
+
id: g.slot,
|
|
1204
|
+
layer: d,
|
|
1205
|
+
kind: "image",
|
|
1206
|
+
source: Fe(r.imageUrls[g.slot]),
|
|
1207
|
+
width: g.width * a,
|
|
1208
|
+
height: g.height * a,
|
|
1209
|
+
zIndex: _e + p.length,
|
|
1210
|
+
redirect: !1
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
try {
|
|
1214
|
+
const g = await Promise.all(p.map((f) => u.addGift({
|
|
1215
|
+
type: f.kind,
|
|
1216
|
+
source: f.source,
|
|
1217
|
+
x: 0,
|
|
1218
|
+
y: 0,
|
|
1219
|
+
width: f.width,
|
|
1220
|
+
height: f.height,
|
|
1221
|
+
zIndex: f.zIndex,
|
|
1222
|
+
opacity: 0,
|
|
1223
|
+
loop: f.kind === "svga" ? 0 : void 0,
|
|
1224
|
+
// A formation may contain dozens of copies of the same SVGA. The plugin owns visual
|
|
1225
|
+
// composition only, so embedded audio is muted to prevent N identical tracks stacking.
|
|
1226
|
+
mute: f.kind === "svga" ? !0 : void 0,
|
|
1227
|
+
clearsAfterStop: !1
|
|
1228
|
+
})));
|
|
1229
|
+
this.assertCurrentPlay(u, m);
|
|
1230
|
+
const h = this.compileMotionTrack(p, n, {
|
|
1231
|
+
scale: a,
|
|
1232
|
+
offsetX: o,
|
|
1233
|
+
offsetY: c
|
|
1234
|
+
}), d = u.createMotionTrack(h);
|
|
1235
|
+
g.forEach((f, A) => u.bindMotion(f, d, A));
|
|
1236
|
+
const w = () => {
|
|
1237
|
+
var _, D;
|
|
1238
|
+
const f = At(p, g), A = f.parentMotionMode ?? ((_ = this._preloadDiagnostics) == null ? void 0 : _.parentMotionMode) ?? ze(this.host, r.assetType, (D = this.assetLease) == null ? void 0 : D.metadata);
|
|
1239
|
+
return Object.freeze({
|
|
1240
|
+
...f,
|
|
1241
|
+
parentMotionMode: A,
|
|
1242
|
+
motionMode: A
|
|
1243
|
+
});
|
|
1244
|
+
}, k = w(), E = (v = r.effects) == null ? void 0 : v.find((f) => f.type === "firework"), O = Pe(this.host);
|
|
1245
|
+
if (E && O && this.fireworkAtlas && this.fireworkAtlasCells && typeof u.createParticleBatchGroup == "function")
|
|
1246
|
+
try {
|
|
1247
|
+
const f = bt({
|
|
1248
|
+
effect: E,
|
|
1249
|
+
composition: s,
|
|
1250
|
+
layout: { scale: a, offsetX: o, offsetY: c },
|
|
1251
|
+
resolvedQualityScale: this.fireworkQualityScale,
|
|
1252
|
+
seed: E.seed,
|
|
1253
|
+
atlas: this.fireworkAtlas,
|
|
1254
|
+
atlasCells: this.fireworkAtlasCells,
|
|
1255
|
+
maxInstancesPerBatch: O.maxInstancesPerBatch
|
|
1256
|
+
});
|
|
1257
|
+
u.createParticleBatchGroup(f.descriptors);
|
|
1258
|
+
} catch (f) {
|
|
1259
|
+
this.emitStateChange({
|
|
1260
|
+
effectWarning: `firework 编译失败,已跳过:${f instanceof Error ? f.message : String(f)}`
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
else E && (this.particleCapabilityWarningEmitted || (this.particleCapabilityWarningEmitted = !0, this.emitStateChange({
|
|
1264
|
+
effectWarning: "当前核心缺少 sprite-v2/atlas/envelope/atomic group 能力,已跳过 firework;未创建 Canvas2D 后端"
|
|
1265
|
+
})));
|
|
1266
|
+
let C;
|
|
1267
|
+
const M = new Promise((f) => {
|
|
1268
|
+
C = f;
|
|
1269
|
+
});
|
|
1270
|
+
let T = !1, R;
|
|
1271
|
+
const S = (f) => {
|
|
1272
|
+
T || (T = !0, C({ status: f }));
|
|
1273
|
+
}, N = () => {
|
|
1274
|
+
u.state !== "destroyed" && u.destroy(), this.activePlayback === R && (this.activePlayback = null), T || (this.emitStateChange({ status: "stopped", message: "播放已停止" }), S("stopped"));
|
|
1275
|
+
};
|
|
1276
|
+
R = new Ot(
|
|
1277
|
+
u.id,
|
|
1278
|
+
u,
|
|
1279
|
+
M,
|
|
1280
|
+
N,
|
|
1281
|
+
w
|
|
1282
|
+
), this.assertCurrentPlay(u, m), this.pendingScope = null, this.activePlayback = R;
|
|
1283
|
+
let z = 0, P = 0, j = !1;
|
|
1284
|
+
return u.onFrame(({ nowMs: f, deltaMs: A }) => {
|
|
1285
|
+
const _ = Math.min(
|
|
1286
|
+
s.outFrame,
|
|
1287
|
+
s.inFrame + f * s.frameRate / 1e3
|
|
1288
|
+
);
|
|
1289
|
+
this.emitRenderFrame(_), j || (j = !0, this.emitStateChange({
|
|
1290
|
+
status: "playing",
|
|
1291
|
+
diagnosticsRefreshed: !0,
|
|
1292
|
+
...R.diagnostics
|
|
1293
|
+
})), z += A, P += 1, z >= 500 && (this.emitStateChange({ fps: Math.round(P * 1e3 / z) }), z = 0, P = 0);
|
|
1294
|
+
}), u.onFinish(() => {
|
|
1295
|
+
T || (this.activePlayback === R && (this.activePlayback = null), u.destroy(), this.emitStateChange({ status: "finished", message: "本轮编排播放完成" }), S("finished"));
|
|
1296
|
+
}), u.start({ durationMs: s.durationMs }), this.emitStateChange({
|
|
1297
|
+
status: "playing",
|
|
1298
|
+
message: `${g.length} 个实例由 GiftStage 统一时钟驱动`,
|
|
1299
|
+
...k
|
|
1300
|
+
}), R;
|
|
1301
|
+
} catch (g) {
|
|
1302
|
+
throw ((y = this.pendingScope) == null ? void 0 : y.scope) === u && (this.pendingScope = null), ((b = this.activePlayback) == null ? void 0 : b.scope) === u ? this.activePlayback.stop() : u.state !== "destroyed" && u.destroy(), (g == null ? void 0 : g.name) === "AbortError" || this.destroyed || this.playEpoch !== m ? J("多礼物播放已取消") : g;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
compileMotionTrack(t, i, s) {
|
|
1306
|
+
const r = this.composition, n = 1e3 / this.sampleRate, l = Math.ceil(r.durationMs / n) + 1, a = new Float32Array(t.length * l * Ne);
|
|
1307
|
+
return t.forEach((o, c) => {
|
|
1308
|
+
let u = Number.NaN;
|
|
1309
|
+
for (let m = 0; m < l; m += 1) {
|
|
1310
|
+
const p = Math.min(r.durationMs, m * n), v = r.inFrame + p * r.frameRate / 1e3, y = this.evaluateLayer(o, v, i, s);
|
|
1311
|
+
y.rotation = vt(u, y.rotation), u = y.rotation;
|
|
1312
|
+
const b = (c * l + m) * Ne;
|
|
1313
|
+
a[b] = y.x, a[b + 1] = y.y, a[b + 2] = y.scaleX, a[b + 3] = y.scaleY, a[b + 4] = y.rotation, a[b + 5] = y.opacity, a[b + 6] = y.visible ? 1 : 0, a[b + 7] = m + 1 < l && y.interpolateToNext ? 1 : 0;
|
|
1314
|
+
}
|
|
1315
|
+
}), {
|
|
1316
|
+
trackCount: t.length,
|
|
1317
|
+
sampleCount: l,
|
|
1318
|
+
sampleIntervalMs: n,
|
|
1319
|
+
durationMs: r.durationMs,
|
|
1320
|
+
samples: a,
|
|
1321
|
+
label: "lottie-multi-gift"
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
evaluateLayer(t, i, s, r) {
|
|
1325
|
+
const n = t.layer;
|
|
1326
|
+
let [l, a] = q(n.ks.p, i, [0, 0, 0]);
|
|
1327
|
+
const [o, c] = q(n.ks.s, i, [100, 100, 100]), u = n.ks.r ?? n.ks.rz, [m] = q(u, i, [0]), [p] = q(n.ks.o, i, [100]), v = i >= n.ip && i < n.op && p > 0 && !this.disabledSlotIds.has(t.id);
|
|
1328
|
+
let y = l * r.scale + r.offsetX, b = a * r.scale + r.offsetY;
|
|
1329
|
+
if (t.redirect) {
|
|
1330
|
+
const h = this.composition.flightWindows.get(n.nm) || this.composition.targetFlight;
|
|
1331
|
+
if (i >= h.start) {
|
|
1332
|
+
const [d, w] = q(n.ks.p, h.start, [l, a, 0]), k = d * r.scale + r.offsetX, E = w * r.scale + r.offsetY;
|
|
1333
|
+
if (s) {
|
|
1334
|
+
const O = h.end - h.start, C = O > 0 ? Math.max(0, Math.min(1, (i - h.start) / O)) : 0, M = tt(C);
|
|
1335
|
+
y = k + (s.x - k) * M, b = E + (s.y - E) * M;
|
|
1336
|
+
} else
|
|
1337
|
+
y = k, b = E;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
const g = [n.ks.p, n.ks.s, u, n.ks.o].some((h) => {
|
|
1341
|
+
if ((h == null ? void 0 : h.a) !== 1) return !1;
|
|
1342
|
+
const d = h.k || [];
|
|
1343
|
+
return d.some((w, k) => {
|
|
1344
|
+
const E = d[k + 1];
|
|
1345
|
+
return E && i >= w.t && i < E.t && w.h === 1;
|
|
1346
|
+
});
|
|
1347
|
+
});
|
|
1348
|
+
return {
|
|
1349
|
+
x: y,
|
|
1350
|
+
y: b,
|
|
1351
|
+
scaleX: o / 100,
|
|
1352
|
+
scaleY: c / 100,
|
|
1353
|
+
rotation: m * Math.PI / 180,
|
|
1354
|
+
opacity: Math.max(0, Math.min(1, p / 100)),
|
|
1355
|
+
visible: v,
|
|
1356
|
+
interpolateToNext: !g
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
setDisabledSlots(t = []) {
|
|
1360
|
+
this.disabledSlotIds = new Set(t);
|
|
1361
|
+
}
|
|
1362
|
+
stop() {
|
|
1363
|
+
this.cancelPlayback(!0);
|
|
1364
|
+
}
|
|
1365
|
+
cancelPlayback(t) {
|
|
1366
|
+
t && (this.playIntentEpoch += 1), this.playEpoch += 1;
|
|
1367
|
+
const i = this.pendingScope;
|
|
1368
|
+
this.pendingScope = null, i && i.scope.state !== "destroyed" && i.scope.destroy();
|
|
1369
|
+
const s = this.activePlayback;
|
|
1370
|
+
this.activePlayback = null, s == null || s.stop();
|
|
1371
|
+
}
|
|
1372
|
+
destroy() {
|
|
1373
|
+
var t;
|
|
1374
|
+
this.destroyed || (this.destroyed = !0, this.preloadEpoch += 1, (t = this.preloadController) == null || t.abort(), this.preloadController = null, this.stop(), this.releaseLeases(), this.composition = null, this._preloadDiagnostics = null);
|
|
1375
|
+
}
|
|
1376
|
+
releaseLeases() {
|
|
1377
|
+
var t, i;
|
|
1378
|
+
(t = this.assetLease) == null || t.release(), this.assetLease = null;
|
|
1379
|
+
for (const s of this.imageLeases.values()) s.release();
|
|
1380
|
+
this.imageLeases.clear(), (i = this.fireworkAtlas) == null || i.destroy(), this.fireworkAtlas = null, this.fireworkAtlasCells = null, this.fireworkAtlasRecipeKey = null;
|
|
1381
|
+
}
|
|
1382
|
+
assertAlive() {
|
|
1383
|
+
if (this.destroyed) throw new Error("GiftStage multi-gift plugin is destroyed");
|
|
1384
|
+
}
|
|
1385
|
+
emitStateChange(t) {
|
|
1386
|
+
try {
|
|
1387
|
+
this.onStateChange(t);
|
|
1388
|
+
} catch {
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
emitRenderFrame(t) {
|
|
1392
|
+
try {
|
|
1393
|
+
this.onRenderFrame(t);
|
|
1394
|
+
} catch {
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
assertCurrentPlay(t, i) {
|
|
1398
|
+
var s;
|
|
1399
|
+
if (this.destroyed || this.playEpoch !== i || ((s = this.pendingScope) == null ? void 0 : s.scope) !== t || t.state === "destroyed")
|
|
1400
|
+
throw J("多礼物播放已取消");
|
|
1401
|
+
}
|
|
1402
|
+
assertCurrentPreload(t, i) {
|
|
1403
|
+
if (this.destroyed || t.signal.aborted || this.preloadEpoch !== i || this.preloadController !== t)
|
|
1404
|
+
throw J("多礼物资源预加载已取消");
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
function Lt(e = {}) {
|
|
1408
|
+
return {
|
|
1409
|
+
name: "giftstage-plugin-multi-gift",
|
|
1410
|
+
apiVersion: 1,
|
|
1411
|
+
setup(t) {
|
|
1412
|
+
return new Ft(t, e);
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
function H(e) {
|
|
1417
|
+
return e !== null && typeof e == "object" && !Array.isArray(e);
|
|
1418
|
+
}
|
|
1419
|
+
function xe(e, t) {
|
|
1420
|
+
let i;
|
|
1421
|
+
try {
|
|
1422
|
+
i = JSON.parse(e);
|
|
1423
|
+
} catch {
|
|
1424
|
+
throw new Error(`${t}不是合法 JSON`);
|
|
1425
|
+
}
|
|
1426
|
+
if (!H(i)) throw new Error(`${t}必须是 JSON 对象`);
|
|
1427
|
+
return i;
|
|
1428
|
+
}
|
|
1429
|
+
function Be(e, t) {
|
|
1430
|
+
if (!H(e) || !Number.isFinite(e.width) || e.width <= 0 || !Number.isFinite(e.height) || e.height <= 0)
|
|
1431
|
+
throw new Error(`${t}必须包含大于 0 的 width 和 height`);
|
|
1432
|
+
return { width: e.width, height: e.height };
|
|
1433
|
+
}
|
|
1434
|
+
function It(e) {
|
|
1435
|
+
if (e === void 0) return [];
|
|
1436
|
+
if (!Array.isArray(e)) throw new Error("multiGiftEffect.imgs 必须是数组");
|
|
1437
|
+
return e.map((t, i) => {
|
|
1438
|
+
if (!H(t) || typeof t.slot != "string" || !/^img_slot_\d+$/.test(t.slot))
|
|
1439
|
+
throw new Error(`multiGiftEffect.imgs[${i}].slot 必须是 img_slot_xx`);
|
|
1440
|
+
if (Be(t, `multiGiftEffect.imgs[${i}]`), t.radius !== void 0 && (!Number.isFinite(t.radius) || t.radius < 0))
|
|
1441
|
+
throw new Error(`multiGiftEffect.imgs[${i}].radius 必须是大于等于 0 的数字`);
|
|
1442
|
+
return { ...t };
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
function De(e) {
|
|
1446
|
+
if (!H(e) || !Array.isArray(e.layers))
|
|
1447
|
+
throw new Error("multiGiftEffect.lottie 必须包含 layers 数组");
|
|
1448
|
+
let t = 0;
|
|
1449
|
+
for (const i of e.layers) {
|
|
1450
|
+
const s = /^slot_(\d+)$/.exec((i == null ? void 0 : i.nm) || "");
|
|
1451
|
+
s && (t = Math.max(t, Number(s[1])));
|
|
1452
|
+
}
|
|
1453
|
+
if (!t) throw new Error("multiGiftEffect.lottie 中至少需要一个 slot_xx 礼物插槽");
|
|
1454
|
+
return t;
|
|
1455
|
+
}
|
|
1456
|
+
function zt(e) {
|
|
1457
|
+
const t = typeof e == "string" ? xe(e, "本地特效配置") : e;
|
|
1458
|
+
if (!H(t)) throw new Error("本地特效配置必须是 JSON 对象");
|
|
1459
|
+
if (!Object.prototype.hasOwnProperty.call(t, "lottie"))
|
|
1460
|
+
throw Array.isArray(t.layers) ? new Error("请上传 multiGiftEffect 配置,不能直接上传纯 Lottie JSON") : new Error("multiGiftEffect.lottie 不能为空");
|
|
1461
|
+
let i, s;
|
|
1462
|
+
if (H(t.lottie))
|
|
1463
|
+
i = t.lottie;
|
|
1464
|
+
else if (typeof t.lottie == "string" && t.lottie.trim()) {
|
|
1465
|
+
const l = t.lottie.trim();
|
|
1466
|
+
l.startsWith("{") ? i = xe(l, "multiGiftEffect.lottie") : s = l;
|
|
1467
|
+
} else
|
|
1468
|
+
throw new Error("multiGiftEffect.lottie 必须是 Lottie JSON 对象、JSON 字符串或 URL");
|
|
1469
|
+
const r = Be(t.slotSize, "multiGiftEffect.slotSize"), n = t.effects === void 0 ? [] : t.effects;
|
|
1470
|
+
if (!Array.isArray(n)) throw new Error("multiGiftEffect.effects 必须是数组");
|
|
1471
|
+
return {
|
|
1472
|
+
lottieJson: i,
|
|
1473
|
+
lottieUrl: s,
|
|
1474
|
+
slotSize: r,
|
|
1475
|
+
effects: n.map((l) => ({ ...l })),
|
|
1476
|
+
imgs: It(t.imgs)
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
async function xt(e, t = fetch) {
|
|
1480
|
+
if (e.lottieJson)
|
|
1481
|
+
return { lottieJson: e.lottieJson, slotCount: De(e.lottieJson) };
|
|
1482
|
+
let i;
|
|
1483
|
+
try {
|
|
1484
|
+
i = await t(e.lottieUrl);
|
|
1485
|
+
} catch (r) {
|
|
1486
|
+
throw new Error(`无法加载 lottie URL:${r.message || "网络错误"}`);
|
|
1487
|
+
}
|
|
1488
|
+
if (!i.ok) throw new Error(`无法加载 lottie URL(${i.status})`);
|
|
1489
|
+
let s;
|
|
1490
|
+
try {
|
|
1491
|
+
s = await i.json();
|
|
1492
|
+
} catch {
|
|
1493
|
+
throw new Error("lottie URL 返回的内容不是合法 JSON");
|
|
1494
|
+
}
|
|
1495
|
+
return { lottieJson: s, slotCount: De(s) };
|
|
1496
|
+
}
|
|
1497
|
+
export {
|
|
1498
|
+
Ft as GiftStageMultiGiftPluginApi,
|
|
1499
|
+
ae as MultiGiftValidationError,
|
|
1500
|
+
He as bezierEase,
|
|
1501
|
+
Lt as createGiftStageMultiGiftPlugin,
|
|
1502
|
+
Lt as default,
|
|
1503
|
+
Pt as easeInOutCubic,
|
|
1504
|
+
tt as easeOutCubic,
|
|
1505
|
+
pe as findMarker,
|
|
1506
|
+
_t as findUnsupportedCapabilities,
|
|
1507
|
+
xt as inspectLocalLottie,
|
|
1508
|
+
mt as normalizePlayConfig,
|
|
1509
|
+
zt as parseLocalMultiGiftEffect,
|
|
1510
|
+
Ct as spatialBezierPoint,
|
|
1511
|
+
Qe as validateMultiGiftComposition,
|
|
1512
|
+
q as valueAt
|
|
1513
|
+
};
|