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