@vunk/plus 1.13.0 → 1.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,462 @@
1
- import { inject as ie, provide as le, watchEffect as T, onBeforeUnmount as R, defineComponent as E, useId as W, ref as $, onMounted as X, renderSlot as D, watch as G, computed as j, createElementBlock as pe, openBlock as N, resolveComponent as q, createBlock as U, withCtx as ce, createVNode as de } from "vue";
2
- import { TickerStatus as n } from "@vunk/shared/enum";
3
- import { TickerStatus as Oe } from "@vunk/shared/enum";
4
- import { Deferred as me, sleep as K } from "@vunk/shared/promise";
5
- import fe from "apng-js";
6
- import { Application as ve, Sprite as ye, Assets as P, Texture as Y, ImageSource as te, BufferImageSource as ge } from "pixi.js";
7
- import { pickObject as J } from "@vunk/shared/object";
8
- import { useModelComputed as Q, useDeferred as he } from "@vunk/core/composables";
1
+ import { inject as fe, provide as de, watchEffect as B, onBeforeUnmount as S, defineComponent as C, useId as ne, ref as U, onMounted as ae, renderSlot as V, watch as Q, computed as J, createElementBlock as me, openBlock as H, resolveComponent as K, createBlock as Y, withCtx as he, createVNode as ve } from "vue";
2
+ import { TickerStatus as m } from "@vunk/shared/enum";
3
+ import { TickerStatus as Ye } from "@vunk/shared/enum";
4
+ import { Deferred as ge, sleep as Z } from "@vunk/shared/promise";
5
+ import { Application as _e, Sprite as ye, Assets as R, Texture as ee, ImageSource as oe, BufferImageSource as we } from "pixi.js";
6
+ import { pickObject as se } from "@vunk/shared/object";
7
+ import { useModelComputed as ie, useDeferred as be } from "@vunk/core/composables";
9
8
  import { _ as xe } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
10
- const V = {
9
+ function Fe(o) {
10
+ return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
11
+ }
12
+ var X = { exports: {} }, ke = X.exports, ue;
13
+ function Pe() {
14
+ return ue || (ue = 1, (function(o, P) {
15
+ (function(r, p) {
16
+ o.exports = p();
17
+ })(ke, function() {
18
+ return (
19
+ /******/
20
+ (function(t) {
21
+ var r = {};
22
+ function p(l) {
23
+ if (r[l])
24
+ return r[l].exports;
25
+ var v = r[l] = {
26
+ /******/
27
+ exports: {},
28
+ /******/
29
+ id: l,
30
+ /******/
31
+ loaded: !1
32
+ /******/
33
+ };
34
+ return t[l].call(v.exports, v, v.exports, p), v.loaded = !0, v.exports;
35
+ }
36
+ return p.m = t, p.c = r, p.p = "", p(0);
37
+ })([
38
+ /* 0 */
39
+ /***/
40
+ (function(t, r, p) {
41
+ Object.defineProperty(r, "__esModule", {
42
+ value: !0
43
+ }), r.isNotPNG = a, r.isNotAPNG = u, r.default = s;
44
+ var l = p(1), v = w(l), _ = p(2);
45
+ function w(f) {
46
+ return f && f.__esModule ? f : { default: f };
47
+ }
48
+ var e = new Error("Not a PNG"), n = new Error("Not an animated PNG");
49
+ function a(f) {
50
+ return f === e;
51
+ }
52
+ function u(f) {
53
+ return f === n;
54
+ }
55
+ var i = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
56
+ function s(f) {
57
+ var g = new Uint8Array(f);
58
+ if (Array.prototype.some.call(i, function(T, D) {
59
+ return T !== g[D];
60
+ }))
61
+ return e;
62
+ var c = !1;
63
+ if (b(g, function(T) {
64
+ return !(c = T === "acTL");
65
+ }), !c)
66
+ return n;
67
+ var x = [], I = [], N = null, k = null, M = 0, O = new _.APNG();
68
+ if (b(g, function(T, D, E, $) {
69
+ var L = new DataView(D.buffer);
70
+ switch (T) {
71
+ case "IHDR":
72
+ N = D.subarray(E + 8, E + 8 + $), O.width = L.getUint32(E + 8), O.height = L.getUint32(E + 12);
73
+ break;
74
+ case "acTL":
75
+ O.numPlays = L.getUint32(E + 8 + 4);
76
+ break;
77
+ case "fcTL":
78
+ k && (O.frames.push(k), M++), k = new _.Frame(), k.width = L.getUint32(E + 8 + 4), k.height = L.getUint32(E + 8 + 8), k.left = L.getUint32(E + 8 + 12), k.top = L.getUint32(E + 8 + 16);
79
+ var pe = L.getUint16(E + 8 + 20), te = L.getUint16(E + 8 + 22);
80
+ te === 0 && (te = 100), k.delay = 1e3 * pe / te, k.delay <= 10 && (k.delay = 100), O.playTime += k.delay, k.disposeOp = L.getUint8(E + 8 + 24), k.blendOp = L.getUint8(E + 8 + 25), k.dataParts = [], M === 0 && k.disposeOp === 2 && (k.disposeOp = 1);
81
+ break;
82
+ case "fdAT":
83
+ k && k.dataParts.push(D.subarray(E + 8 + 4, E + 8 + $));
84
+ break;
85
+ case "IDAT":
86
+ k && k.dataParts.push(D.subarray(E + 8, E + 8 + $));
87
+ break;
88
+ case "IEND":
89
+ I.push(y(D, E, 12 + $));
90
+ break;
91
+ default:
92
+ x.push(y(D, E, 12 + $));
93
+ }
94
+ }), k && O.frames.push(k), O.frames.length == 0)
95
+ return n;
96
+ var G = new Blob(x), W = new Blob(I);
97
+ return O.frames.forEach(function(T) {
98
+ var D = [];
99
+ D.push(i), N.set(d(T.width), 0), N.set(d(T.height), 4), D.push(F("IHDR", N)), D.push(G), T.dataParts.forEach(function(E) {
100
+ return D.push(F("IDAT", E));
101
+ }), D.push(W), T.imageData = new Blob(D, { type: "image/png" }), delete T.dataParts, D = null;
102
+ }), O;
103
+ }
104
+ function b(f, g) {
105
+ var c = new DataView(f.buffer), x = 8, I = void 0, N = void 0, k = void 0;
106
+ do
107
+ N = c.getUint32(x), I = h(f, x + 4, 4), k = g(I, f, x, N), x += 12 + N;
108
+ while (k !== !1 && I != "IEND" && x < f.length);
109
+ }
110
+ function h(f, g, c) {
111
+ var x = Array.prototype.slice.call(f.subarray(g, g + c));
112
+ return String.fromCharCode.apply(String, x);
113
+ }
114
+ function A(f) {
115
+ for (var g = new Uint8Array(f.length), c = 0; c < f.length; c++)
116
+ g[c] = f.charCodeAt(c);
117
+ return g;
118
+ }
119
+ function y(f, g, c) {
120
+ var x = new Uint8Array(c);
121
+ return x.set(f.subarray(g, g + c)), x;
122
+ }
123
+ var F = function(g, c) {
124
+ var x = g.length + c.length, I = new Uint8Array(x + 8), N = new DataView(I.buffer);
125
+ N.setUint32(0, c.length), I.set(A(g), 4), I.set(c, 8);
126
+ var k = (0, v.default)(I, 4, x);
127
+ return N.setUint32(x + 4, k), I;
128
+ }, d = function(g) {
129
+ return new Uint8Array([g >>> 24 & 255, g >>> 16 & 255, g >>> 8 & 255, g & 255]);
130
+ };
131
+ }),
132
+ /* 1 */
133
+ /***/
134
+ (function(t, r) {
135
+ Object.defineProperty(r, "__esModule", {
136
+ value: !0
137
+ }), r.default = function(w) {
138
+ for (var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : w.length - e, a = -1, u = e, i = e + n; u < i; u++)
139
+ a = a >>> 8 ^ p[(a ^ w[u]) & 255];
140
+ return a ^ -1;
141
+ };
142
+ for (var p = new Uint32Array(256), l = 0; l < 256; l++) {
143
+ for (var v = l, _ = 0; _ < 8; _++)
144
+ v = (v & 1) !== 0 ? 3988292384 ^ v >>> 1 : v >>> 1;
145
+ p[l] = v;
146
+ }
147
+ }),
148
+ /* 2 */
149
+ /***/
150
+ (function(t, r, p) {
151
+ Object.defineProperty(r, "__esModule", {
152
+ value: !0
153
+ }), r.Frame = r.APNG = void 0;
154
+ var l = /* @__PURE__ */ (function() {
155
+ function n(a, u) {
156
+ for (var i = 0; i < u.length; i++) {
157
+ var s = u[i];
158
+ s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(a, s.key, s);
159
+ }
160
+ }
161
+ return function(a, u, i) {
162
+ return u && n(a.prototype, u), i && n(a, i), a;
163
+ };
164
+ })(), v = p(3), _ = w(v);
165
+ function w(n) {
166
+ return n && n.__esModule ? n : { default: n };
167
+ }
168
+ function e(n, a) {
169
+ if (!(n instanceof a))
170
+ throw new TypeError("Cannot call a class as a function");
171
+ }
172
+ r.APNG = (function() {
173
+ function n() {
174
+ e(this, n), this.width = 0, this.height = 0, this.numPlays = 0, this.playTime = 0, this.frames = [];
175
+ }
176
+ return l(n, [{
177
+ key: "createImages",
178
+ /**
179
+ *
180
+ * @return {Promise.<*>}
181
+ */
182
+ value: function() {
183
+ return Promise.all(this.frames.map(function(u) {
184
+ return u.createImage();
185
+ }));
186
+ }
187
+ /**
188
+ *
189
+ * @param {CanvasRenderingContext2D} context
190
+ * @param {boolean} autoPlay
191
+ * @return {Promise.<Player>}
192
+ */
193
+ }, {
194
+ key: "getPlayer",
195
+ value: function(u) {
196
+ var i = this, s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
197
+ return this.createImages().then(function() {
198
+ return new _.default(i, u, s);
199
+ });
200
+ }
201
+ }]), n;
202
+ })(), r.Frame = (function() {
203
+ function n() {
204
+ e(this, n), this.left = 0, this.top = 0, this.width = 0, this.height = 0, this.delay = 0, this.disposeOp = 0, this.blendOp = 0, this.imageData = null, this.imageElement = null;
205
+ }
206
+ return l(n, [{
207
+ key: "createImage",
208
+ value: function() {
209
+ var u = this;
210
+ return this.imageElement ? Promise.resolve() : new Promise(function(i, s) {
211
+ var b = URL.createObjectURL(u.imageData);
212
+ u.imageElement = document.createElement("img"), u.imageElement.onload = function() {
213
+ URL.revokeObjectURL(b), i();
214
+ }, u.imageElement.onerror = function() {
215
+ URL.revokeObjectURL(b), u.imageElement = null, s(new Error("Image creation error"));
216
+ }, u.imageElement.src = b;
217
+ });
218
+ }
219
+ }]), n;
220
+ })();
221
+ }),
222
+ /* 3 */
223
+ /***/
224
+ (function(t, r, p) {
225
+ Object.defineProperty(r, "__esModule", {
226
+ value: !0
227
+ });
228
+ var l = /* @__PURE__ */ (function() {
229
+ function i(s, b) {
230
+ for (var h = 0; h < b.length; h++) {
231
+ var A = b[h];
232
+ A.enumerable = A.enumerable || !1, A.configurable = !0, "value" in A && (A.writable = !0), Object.defineProperty(s, A.key, A);
233
+ }
234
+ }
235
+ return function(s, b, h) {
236
+ return b && i(s.prototype, b), h && i(s, h), s;
237
+ };
238
+ })(), v = p(4), _ = w(v);
239
+ function w(i) {
240
+ return i && i.__esModule ? i : { default: i };
241
+ }
242
+ function e(i, s) {
243
+ if (!(i instanceof s))
244
+ throw new TypeError("Cannot call a class as a function");
245
+ }
246
+ function n(i, s) {
247
+ if (!i)
248
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
249
+ return s && (typeof s == "object" || typeof s == "function") ? s : i;
250
+ }
251
+ function a(i, s) {
252
+ if (typeof s != "function" && s !== null)
253
+ throw new TypeError("Super expression must either be null or a function, not " + typeof s);
254
+ i.prototype = Object.create(s && s.prototype, { constructor: { value: i, enumerable: !1, writable: !0, configurable: !0 } }), s && (Object.setPrototypeOf ? Object.setPrototypeOf(i, s) : i.__proto__ = s);
255
+ }
256
+ var u = (function(i) {
257
+ a(s, i);
258
+ function s(b, h, A) {
259
+ e(this, s);
260
+ var y = n(this, (s.__proto__ || Object.getPrototypeOf(s)).call(this));
261
+ return y.playbackRate = 1, y._currentFrameNumber = 0, y._ended = !1, y._paused = !0, y._numPlays = 0, y._rafId = null, y._apng = b, y.context = h, y.stop(), A && y.play(), y;
262
+ }
263
+ return l(s, [{
264
+ key: "renderNextFrame",
265
+ value: function() {
266
+ this._currentFrameNumber = (this._currentFrameNumber + 1) % this._apng.frames.length, this._currentFrameNumber === this._apng.frames.length - 1 && (this._numPlays++, this._apng.numPlays !== 0 && this._numPlays >= this._apng.numPlays && (this._ended = !0, this._paused = !0)), this._prevFrame && this._prevFrame.disposeOp == 1 ? this.context.clearRect(this._prevFrame.left, this._prevFrame.top, this._prevFrame.width, this._prevFrame.height) : this._prevFrame && this._prevFrame.disposeOp == 2 && this.context.putImageData(this._prevFrameData, this._prevFrame.left, this._prevFrame.top);
267
+ var h = this.currentFrame;
268
+ this._prevFrame = h, this._prevFrameData = null, h.disposeOp == 2 && (this._prevFrameData = this.context.getImageData(h.left, h.top, h.width, h.height)), h.blendOp == 0 && this.context.clearRect(h.left, h.top, h.width, h.height), this.context.drawImage(h.imageElement, h.left, h.top), this.emit("frame", this._currentFrameNumber), this._ended && this.emit("end");
269
+ }
270
+ // playback
271
+ }, {
272
+ key: "play",
273
+ value: function() {
274
+ var h = this;
275
+ this._rafId && cancelAnimationFrame(this._rafId), this.emit("play"), this._ended && this.stop(), this._paused = !1;
276
+ var A = performance.now() + this.currentFrame.delay / this.playbackRate, y = function F(d) {
277
+ if (!(h._ended || h._paused)) {
278
+ if (d >= A) {
279
+ for (; d - A >= h._apng.playTime / h.playbackRate; )
280
+ A += h._apng.playTime / h.playbackRate, h._numPlays++;
281
+ do
282
+ h.renderNextFrame(), A += h.currentFrame.delay / h.playbackRate;
283
+ while (!h._ended && !h._paused && d > A);
284
+ }
285
+ h._rafId = requestAnimationFrame(F);
286
+ }
287
+ };
288
+ this._rafId = requestAnimationFrame(y);
289
+ }
290
+ }, {
291
+ key: "pause",
292
+ value: function() {
293
+ this._paused || (this._rafId && (cancelAnimationFrame(this._rafId), this._rafId = null), this.emit("pause"), this._paused = !0);
294
+ }
295
+ }, {
296
+ key: "stop",
297
+ value: function() {
298
+ this._rafId && (cancelAnimationFrame(this._rafId), this._rafId = null), this.emit("stop"), this._numPlays = 0, this._ended = !1, this._paused = !0, this._currentFrameNumber = -1, this.context.clearRect(0, 0, this._apng.width, this._apng.height), this.renderNextFrame();
299
+ }
300
+ }, {
301
+ key: "currentFrameNumber",
302
+ get: function() {
303
+ return this._currentFrameNumber;
304
+ }
305
+ /**
306
+ *
307
+ * @return {Frame}
308
+ */
309
+ }, {
310
+ key: "currentFrame",
311
+ get: function() {
312
+ return this._apng.frames[this._currentFrameNumber];
313
+ }
314
+ }, {
315
+ key: "paused",
316
+ get: function() {
317
+ return this._paused;
318
+ }
319
+ }, {
320
+ key: "ended",
321
+ get: function() {
322
+ return this._ended;
323
+ }
324
+ }]), s;
325
+ })(_.default);
326
+ r.default = u;
327
+ }),
328
+ /* 4 */
329
+ /***/
330
+ (function(t, r) {
331
+ function p() {
332
+ this._events = this._events || {}, this._maxListeners = this._maxListeners || void 0;
333
+ }
334
+ t.exports = p, p.EventEmitter = p, p.prototype._events = void 0, p.prototype._maxListeners = void 0, p.defaultMaxListeners = 10, p.prototype.setMaxListeners = function(e) {
335
+ if (!v(e) || e < 0 || isNaN(e))
336
+ throw TypeError("n must be a positive number");
337
+ return this._maxListeners = e, this;
338
+ }, p.prototype.emit = function(e) {
339
+ var n, a, u, i, s, b;
340
+ if (this._events || (this._events = {}), e === "error" && (!this._events.error || _(this._events.error) && !this._events.error.length)) {
341
+ if (n = arguments[1], n instanceof Error)
342
+ throw n;
343
+ var h = new Error('Uncaught, unspecified "error" event. (' + n + ")");
344
+ throw h.context = n, h;
345
+ }
346
+ if (a = this._events[e], w(a))
347
+ return !1;
348
+ if (l(a))
349
+ switch (arguments.length) {
350
+ // fast cases
351
+ case 1:
352
+ a.call(this);
353
+ break;
354
+ case 2:
355
+ a.call(this, arguments[1]);
356
+ break;
357
+ case 3:
358
+ a.call(this, arguments[1], arguments[2]);
359
+ break;
360
+ // slower
361
+ default:
362
+ i = Array.prototype.slice.call(arguments, 1), a.apply(this, i);
363
+ }
364
+ else if (_(a))
365
+ for (i = Array.prototype.slice.call(arguments, 1), b = a.slice(), u = b.length, s = 0; s < u; s++)
366
+ b[s].apply(this, i);
367
+ return !0;
368
+ }, p.prototype.addListener = function(e, n) {
369
+ var a;
370
+ if (!l(n))
371
+ throw TypeError("listener must be a function");
372
+ return this._events || (this._events = {}), this._events.newListener && this.emit(
373
+ "newListener",
374
+ e,
375
+ l(n.listener) ? n.listener : n
376
+ ), this._events[e] ? _(this._events[e]) ? this._events[e].push(n) : this._events[e] = [this._events[e], n] : this._events[e] = n, _(this._events[e]) && !this._events[e].warned && (w(this._maxListeners) ? a = p.defaultMaxListeners : a = this._maxListeners, a && a > 0 && this._events[e].length > a && (this._events[e].warned = !0, console.error(
377
+ "(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",
378
+ this._events[e].length
379
+ ), typeof console.trace == "function" && console.trace())), this;
380
+ }, p.prototype.on = p.prototype.addListener, p.prototype.once = function(e, n) {
381
+ if (!l(n))
382
+ throw TypeError("listener must be a function");
383
+ var a = !1;
384
+ function u() {
385
+ this.removeListener(e, u), a || (a = !0, n.apply(this, arguments));
386
+ }
387
+ return u.listener = n, this.on(e, u), this;
388
+ }, p.prototype.removeListener = function(e, n) {
389
+ var a, u, i, s;
390
+ if (!l(n))
391
+ throw TypeError("listener must be a function");
392
+ if (!this._events || !this._events[e])
393
+ return this;
394
+ if (a = this._events[e], i = a.length, u = -1, a === n || l(a.listener) && a.listener === n)
395
+ delete this._events[e], this._events.removeListener && this.emit("removeListener", e, n);
396
+ else if (_(a)) {
397
+ for (s = i; s-- > 0; )
398
+ if (a[s] === n || a[s].listener && a[s].listener === n) {
399
+ u = s;
400
+ break;
401
+ }
402
+ if (u < 0)
403
+ return this;
404
+ a.length === 1 ? (a.length = 0, delete this._events[e]) : a.splice(u, 1), this._events.removeListener && this.emit("removeListener", e, n);
405
+ }
406
+ return this;
407
+ }, p.prototype.removeAllListeners = function(e) {
408
+ var n, a;
409
+ if (!this._events)
410
+ return this;
411
+ if (!this._events.removeListener)
412
+ return arguments.length === 0 ? this._events = {} : this._events[e] && delete this._events[e], this;
413
+ if (arguments.length === 0) {
414
+ for (n in this._events)
415
+ n !== "removeListener" && this.removeAllListeners(n);
416
+ return this.removeAllListeners("removeListener"), this._events = {}, this;
417
+ }
418
+ if (a = this._events[e], l(a))
419
+ this.removeListener(e, a);
420
+ else if (a)
421
+ for (; a.length; )
422
+ this.removeListener(e, a[a.length - 1]);
423
+ return delete this._events[e], this;
424
+ }, p.prototype.listeners = function(e) {
425
+ var n;
426
+ return !this._events || !this._events[e] ? n = [] : l(this._events[e]) ? n = [this._events[e]] : n = this._events[e].slice(), n;
427
+ }, p.prototype.listenerCount = function(e) {
428
+ if (this._events) {
429
+ var n = this._events[e];
430
+ if (l(n))
431
+ return 1;
432
+ if (n)
433
+ return n.length;
434
+ }
435
+ return 0;
436
+ }, p.listenerCount = function(e, n) {
437
+ return e.listenerCount(n);
438
+ };
439
+ function l(e) {
440
+ return typeof e == "function";
441
+ }
442
+ function v(e) {
443
+ return typeof e == "number";
444
+ }
445
+ function _(e) {
446
+ return typeof e == "object" && e !== null;
447
+ }
448
+ function w(e) {
449
+ return e === void 0;
450
+ }
451
+ })
452
+ /******/
453
+ ])
454
+ );
455
+ });
456
+ })(X)), X.exports;
457
+ }
458
+ var Ae = Pe();
459
+ const Ee = /* @__PURE__ */ Fe(Ae), q = {
11
460
  url: {
12
461
  type: String,
13
462
  requierd: !1
@@ -28,7 +477,7 @@ const V = {
28
477
  */
29
478
  status: {
30
479
  type: String,
31
- default: n.pending
480
+ default: m.pending
32
481
  },
33
482
  frameRate: {
34
483
  type: Number,
@@ -53,157 +502,157 @@ const V = {
53
502
  type: Boolean,
54
503
  default: !0
55
504
  }
56
- }, S = {
505
+ }, j = {
57
506
  "update:status": null,
58
507
  "update:data": null,
59
508
  setData: null
60
- }, ae = /* @__PURE__ */ Symbol("appInjectKey");
61
- function we() {
62
- const a = new ve(), m = new me(), e = {
63
- whenDef: m,
64
- when: () => m.promise
509
+ }, le = /* @__PURE__ */ Symbol("appInjectKey");
510
+ function Ie() {
511
+ const o = new _e(), P = new ge(), t = {
512
+ whenDef: P,
513
+ when: () => P.promise
65
514
  };
66
- return le(ae, {
67
- application: a,
68
- context: e
69
- }), { application: a, context: e };
515
+ return de(le, {
516
+ application: o,
517
+ context: t
518
+ }), { application: o, context: t };
70
519
  }
71
- function ne() {
72
- const a = ie(ae);
73
- if (!a)
520
+ function ce() {
521
+ const o = fe(le);
522
+ if (!o)
74
523
  throw new Error("Pixi app not provided");
75
- return a;
524
+ return o;
76
525
  }
77
- function B(a) {
78
- const m = a.autoResize ?? !0, e = a.resize ?? f, { application: t, context: F } = ne(), l = new ye();
79
- t.stage.addChild(l), T(() => {
80
- l.visible = a.visible ?? !0;
81
- }), T(() => {
82
- a.label && (l.label = a.label);
83
- }), m && F.when().then((v) => {
84
- l.texture && (y(), v.renderer.on("resize", y));
526
+ function z(o) {
527
+ const P = o.autoResize ?? !0, t = o.resize ?? _, { application: r, context: p } = ce(), l = new ye();
528
+ r.stage.addChild(l), B(() => {
529
+ l.visible = o.visible ?? !0;
530
+ }), B(() => {
531
+ o.label && (l.label = o.label);
532
+ }), P && p.when().then((w) => {
533
+ l.texture && (v(), w.renderer.on("resize", v));
85
534
  });
86
- function y() {
87
- if (!t.renderer?.screen)
535
+ function v() {
536
+ if (!r.renderer?.screen)
88
537
  return;
89
- const v = l.texture._meta;
90
- e({
91
- application: t,
538
+ const w = l.texture._meta;
539
+ t({
540
+ application: r,
92
541
  sprite: l,
93
- meta: v
542
+ meta: w
94
543
  });
95
544
  }
96
- R(() => {
97
- t.renderer.off("resize", y), t.stage.removeChild(l);
545
+ S(() => {
546
+ r.renderer.off("resize", v), r.stage.removeChild(l);
98
547
  });
99
- function f() {
100
- const v = t.screen.width / l.texture.width, r = t.screen.height / l.texture.height, w = Math.min(v, r);
101
- l.scale.set(w), l.x = (t.screen.width - l.width) / 2, l.y = (t.screen.height - l.height) / 2;
548
+ function _() {
549
+ const w = r.screen.width / l.texture.width, e = r.screen.height / l.texture.height, n = Math.min(w, e);
550
+ l.scale.set(n), l.x = (r.screen.width - l.width) / 2, l.y = (r.screen.height - l.height) / 2;
102
551
  }
103
552
  return {
104
553
  sprite: l,
105
- resizeSprite: y,
106
- application: t
554
+ resizeSprite: v,
555
+ application: r
107
556
  };
108
557
  }
109
- const _e = /* @__PURE__ */ E({
558
+ const Ne = /* @__PURE__ */ C({
110
559
  __name: "apng",
111
560
  props: {
112
- ...V,
561
+ ...q,
113
562
  url: {
114
563
  type: String,
115
564
  required: !0
116
565
  }
117
566
  },
118
- emits: S,
119
- setup(a, { emit: m }) {
120
- const e = a, t = m, F = W(), l = (o) => `${F}-apng-frame-${o}`, { sprite: y, resizeSprite: f } = B(e), v = $([]), r = $(0), w = $(!1), g = $(""), i = /* @__PURE__ */ new Map();
121
- let u = null, c = null, k = null;
122
- X(() => I(e.url));
123
- function A(o, _) {
124
- return c || (c = document.createElement("canvas"), k = c.getContext("2d", {
567
+ emits: j,
568
+ setup(o, { emit: P }) {
569
+ const t = o, r = P, p = ne(), l = (c) => `${p}-apng-frame-${c}`, { sprite: v, resizeSprite: _ } = z(t), w = U([]), e = U(0), n = U(!1), a = U(""), u = /* @__PURE__ */ new Map();
570
+ let i = null, s = null, b = null;
571
+ ae(() => A(t.url));
572
+ function h(c, x) {
573
+ return s || (s = document.createElement("canvas"), b = s.getContext("2d", {
125
574
  willReadFrequently: !0
126
- })), (c.width !== o || c.height !== _) && (c.width = o, c.height = _), { canvas: c, ctx: k };
575
+ })), (s.width !== c || s.height !== x) && (s.width = c, s.height = x), { canvas: s, ctx: b };
127
576
  }
128
- async function I(o) {
577
+ async function A(c) {
129
578
  try {
130
- g.value = "", w.value = !1, await x();
131
- const _ = await fetch(o);
132
- if (!_.ok)
133
- throw new Error(`加载APNG失败: ${_.status}`);
134
- const b = await _.arrayBuffer(), C = fe(b);
135
- if (C instanceof Error)
136
- throw new TypeError(`APNG解析失败: ${C.message}`);
137
- const { canvas: z, ctx: L } = A(C.width, C.height), re = C.frames.map(async (O, Z) => {
138
- L.clearRect(0, 0, z.width, z.height), await O.createImage();
139
- const se = O.imageElement;
140
- L.drawImage(se, O.left, O.top);
141
- const oe = L.getImageData(0, 0, z.width, z.height), M = l(Z);
142
- i.set(M, void 0), L.putImageData(oe, 0, 0);
143
- const ue = z.toDataURL();
144
- P.add({ alias: M, src: ue });
145
- const ee = await P.load(M);
146
- return i.set(M, ee), Z === 0 && (y.texture = ee, f()), M;
579
+ a.value = "", n.value = !1, await g();
580
+ const x = await fetch(c);
581
+ if (!x.ok)
582
+ throw new Error(`加载APNG失败: ${x.status}`);
583
+ const I = await x.arrayBuffer(), N = Ee(I);
584
+ if (N instanceof Error)
585
+ throw new TypeError(`APNG解析失败: ${N.message}`);
586
+ const { canvas: k, ctx: M } = h(N.width, N.height), O = N.frames.map(async (G, W) => {
587
+ M.clearRect(0, 0, k.width, k.height), await G.createImage();
588
+ const T = G.imageElement;
589
+ M.drawImage(T, G.left, G.top);
590
+ const D = M.getImageData(0, 0, k.width, k.height), E = l(W);
591
+ u.set(E, void 0), M.putImageData(D, 0, 0);
592
+ const $ = k.toDataURL();
593
+ R.add({ alias: E, src: $ });
594
+ const L = await R.load(E);
595
+ return u.set(E, L), W === 0 && (v.texture = L, _()), E;
147
596
  });
148
- v.value = await Promise.all(re), w.value = !0;
149
- } catch (_) {
150
- console.error("加载APNG失败:", _), g.value = _ instanceof Error ? _.message : "加载APNG失败", t("update:status", n.stopped);
597
+ w.value = await Promise.all(O), n.value = !0;
598
+ } catch (x) {
599
+ console.error("加载APNG失败:", x), a.value = x instanceof Error ? x.message : "加载APNG失败", r("update:status", m.stopped);
151
600
  }
152
601
  }
153
- function h() {
154
- u === null && (u = window.setInterval(() => {
155
- if (v.value.length === 0 || e.status !== n.playing)
602
+ function y() {
603
+ i === null && (i = window.setInterval(() => {
604
+ if (w.value.length === 0 || t.status !== m.playing)
156
605
  return;
157
- const o = i.get(
158
- l(r.value)
606
+ const c = u.get(
607
+ l(e.value)
159
608
  );
160
- if (o) {
161
- const _ = r.value - 1;
162
- _ >= 0 && !e.loop && Promise.resolve().then(() => K(500)).then(() => {
163
- P.unload(l(_)), i.delete(l(_));
164
- }), y.texture = o, f(), r.value = e.loop ? (r.value + 1) % v.value.length : r.value + 1;
609
+ if (c) {
610
+ const x = e.value - 1;
611
+ x >= 0 && !t.loop && Promise.resolve().then(() => Z(500)).then(() => {
612
+ R.unload(l(x)), u.delete(l(x));
613
+ }), v.texture = c, _(), e.value = t.loop ? (e.value + 1) % w.value.length : e.value + 1;
165
614
  } else
166
- e.loop || t("update:status", n.paused);
167
- }, 1e3 / e.frameRate));
168
- }
169
- function p() {
170
- !w.value || v.value.length <= 1 || (t("update:status", n.playing), h());
615
+ t.loop || r("update:status", m.paused);
616
+ }, 1e3 / t.frameRate));
171
617
  }
172
- function s() {
173
- u !== null && (clearInterval(u), u = null), t("update:status", n.paused);
618
+ function F() {
619
+ !n.value || w.value.length <= 1 || (r("update:status", m.playing), y());
174
620
  }
175
621
  function d() {
176
- u !== null && (clearInterval(u), u = null), r.value = 0;
177
- const o = i.get(l(0));
178
- o && (y.texture = o, f()), t("update:status", n.stopped);
179
- }
180
- async function x() {
181
- u !== null && (clearInterval(u), u = null);
182
- const o = [];
183
- for (const [_, b] of i)
184
- b && b !== Y.EMPTY && o.push(P.unload(_));
185
- await Promise.all(o), i.clear(), v.value = [], r.value = 0, w.value = !1, g.value = "", c && (c.width = 0, c.height = 0);
186
- }
187
- return T(() => {
188
- switch (e.status) {
189
- case n.play:
190
- p();
191
- break;
192
- case n.pause:
193
- s();
622
+ i !== null && (clearInterval(i), i = null), r("update:status", m.paused);
623
+ }
624
+ function f() {
625
+ i !== null && (clearInterval(i), i = null), e.value = 0;
626
+ const c = u.get(l(0));
627
+ c && (v.texture = c, _()), r("update:status", m.stopped);
628
+ }
629
+ async function g() {
630
+ i !== null && (clearInterval(i), i = null);
631
+ const c = [];
632
+ for (const [x, I] of u)
633
+ I && I !== ee.EMPTY && c.push(R.unload(x));
634
+ await Promise.all(c), u.clear(), w.value = [], e.value = 0, n.value = !1, a.value = "", s && (s.width = 0, s.height = 0);
635
+ }
636
+ return B(() => {
637
+ switch (t.status) {
638
+ case m.play:
639
+ F();
194
640
  break;
195
- case n.stop:
641
+ case m.pause:
196
642
  d();
197
643
  break;
644
+ case m.stop:
645
+ f();
646
+ break;
198
647
  }
199
- }), R(async () => {
200
- await x(), c = null, k = null;
201
- }), (o, _) => D(o.$slots, "default");
648
+ }), S(async () => {
649
+ await g(), s = null, b = null;
650
+ }), (c, x) => V(c.$slots, "default");
202
651
  }
203
- }), Be = /* @__PURE__ */ E({
652
+ }), Ge = /* @__PURE__ */ C({
204
653
  __name: "bitmap-generator",
205
654
  props: {
206
- ...J(V, {
655
+ ...se(q, {
207
656
  excludes: ["loop"]
208
657
  }),
209
658
  generator: {
@@ -213,50 +662,50 @@ const _e = /* @__PURE__ */ E({
213
662
  },
214
663
  emits: {
215
664
  "update:status": null,
216
- load: (a) => a
665
+ load: (o) => o
217
666
  },
218
- setup(a, { emit: m }) {
219
- const e = a, t = m, { sprite: F, resizeSprite: l, application: y } = B(e), f = new Y({
667
+ setup(o, { emit: P }) {
668
+ const t = o, r = P, { sprite: p, resizeSprite: l, application: v } = z(t), _ = new ee({
220
669
  dynamic: !0
221
670
  });
222
- F.texture = f;
223
- function v(u) {
224
- f.source.destroy();
225
- const c = new te({
226
- resource: u
671
+ p.texture = _;
672
+ function w(i) {
673
+ _.source.destroy();
674
+ const s = new oe({
675
+ resource: i
227
676
  });
228
- f.source = c, f.update(), l();
677
+ _.source = s, _.update(), l();
229
678
  }
230
- t("load", {
231
- application: y,
232
- sprite: F
233
- }), G(() => e.status, (u) => {
234
- u === n.play && w(), u === n.pause && g(), u === n.stop && i();
679
+ r("load", {
680
+ application: v,
681
+ sprite: p
682
+ }), Q(() => t.status, (i) => {
683
+ i === m.play && n(), i === m.pause && a(), i === m.stop && u();
235
684
  }, { immediate: !0 });
236
- function r() {
237
- e.status === n.playing && e.generator.next().then(({ value: u, done: c }) => {
238
- if (c)
239
- return t("update:status", n.stopped);
240
- v(u);
685
+ function e() {
686
+ t.status === m.playing && t.generator.next().then(({ value: i, done: s }) => {
687
+ if (s)
688
+ return r("update:status", m.stopped);
689
+ w(i);
241
690
  });
242
691
  }
243
- function w() {
244
- y.ticker.minFPS = e.frameRate, y.ticker.maxFPS = e.frameRate, t("update:status", n.playing), y.ticker.add(r);
692
+ function n() {
693
+ v.ticker.minFPS = t.frameRate, v.ticker.maxFPS = t.frameRate, r("update:status", m.playing), v.ticker.add(e);
245
694
  }
246
- function g() {
247
- y.ticker.remove(r), t("update:status", n.paused);
695
+ function a() {
696
+ v.ticker.remove(e), r("update:status", m.paused);
248
697
  }
249
- function i() {
250
- y.ticker.remove(r), t("update:status", n.stopped);
698
+ function u() {
699
+ v.ticker.remove(e), r("update:status", m.stopped);
251
700
  }
252
- return R(() => {
253
- i(), f.destroy();
254
- }), (u, c) => D(u.$slots, "default");
701
+ return S(() => {
702
+ u(), _.destroy();
703
+ }), (i, s) => V(i.$slots, "default");
255
704
  }
256
- }), Fe = /* @__PURE__ */ E({
705
+ }), De = /* @__PURE__ */ C({
257
706
  __name: "bitmap",
258
707
  props: {
259
- ...J(V, {
708
+ ...se(q, {
260
709
  excludes: ["loop"]
261
710
  }),
262
711
  data: {
@@ -268,92 +717,92 @@ const _e = /* @__PURE__ */ E({
268
717
  }
269
718
  },
270
719
  emits: {
271
- ...S,
272
- load: (a) => a,
720
+ ...j,
721
+ load: (o) => o,
273
722
  "update:frameIndex": null,
274
- notFound: (a) => !0
723
+ notFound: (o) => !0
275
724
  },
276
- setup(a, { emit: m }) {
277
- const e = a, t = m, { sprite: F, resizeSprite: l, application: y } = B(e), f = new Y({
725
+ setup(o, { emit: P }) {
726
+ const t = o, r = P, { sprite: p, resizeSprite: l, application: v } = z(t), _ = new ee({
278
727
  dynamic: !0
279
728
  });
280
- F.texture = f;
281
- function v(s) {
282
- f.source?.resource?.close(), f.source?.destroy();
283
- const d = new te({
284
- resource: s
729
+ p.texture = _;
730
+ function w(d) {
731
+ _.source?.resource?.close(), _.source?.destroy();
732
+ const f = new oe({
733
+ resource: d
285
734
  });
286
- f.source = d, f.update(), l();
735
+ _.source = f, _.update(), l();
287
736
  }
288
- t("load", {
289
- application: y,
290
- sprite: F
737
+ r("load", {
738
+ application: v,
739
+ sprite: p
291
740
  });
292
- const r = Q({
741
+ const e = ie({
293
742
  default: 0,
294
743
  key: "frameIndex"
295
- }, e, t), w = $(-1);
296
- function g(s) {
297
- s <= w.value || (w.value = s, K(0).then(() => {
298
- t("setData", {
299
- k: s,
744
+ }, t, r), n = U(-1);
745
+ function a(d) {
746
+ d <= n.value || (n.value = d, Z(0).then(() => {
747
+ r("setData", {
748
+ k: d,
300
749
  v: null
301
750
  });
302
751
  }));
303
752
  }
304
- let i = null, u = 0, c = 0, k = 0;
305
- function A() {
306
- if (i !== null)
753
+ let u = null, i = 0, s = 0, b = 0;
754
+ function h() {
755
+ if (u !== null)
307
756
  return;
308
- u = performance.now(), k = u, c = 0;
309
- function s() {
310
- const x = performance.now(), o = 1e3 / e.frameRate, _ = x - u;
311
- if (_ >= o) {
312
- u = x - _ % o, d(), c++;
313
- const b = x - k;
314
- if (b >= 1e3) {
315
- const C = Math.round(c * 1e3 / b);
316
- console.log(`[Bitmap] FPS: ${C}`), c = 0, k = x;
757
+ i = performance.now(), b = i, s = 0;
758
+ function d() {
759
+ const g = performance.now(), c = 1e3 / t.frameRate, x = g - i;
760
+ if (x >= c) {
761
+ i = g - x % c, f(), s++;
762
+ const I = g - b;
763
+ if (I >= 1e3) {
764
+ const N = Math.round(s * 1e3 / I);
765
+ console.log(`[Bitmap] FPS: ${N}`), s = 0, b = g;
317
766
  }
318
767
  }
319
- e.status === n.playing ? i = requestAnimationFrame(s) : i = null;
768
+ t.status === m.playing ? u = requestAnimationFrame(d) : u = null;
320
769
  }
321
- function d() {
322
- if (e.data.length === 0 || e.status !== n.playing)
770
+ function f() {
771
+ if (t.data.length === 0 || t.status !== m.playing)
323
772
  return;
324
- const x = e.data[r.value];
325
- if (x) {
326
- const o = r.value - 1;
327
- o >= 0 && g(o), v(x), r.value = r.value + 1;
773
+ const g = t.data[e.value];
774
+ if (g) {
775
+ const c = e.value - 1;
776
+ c >= 0 && a(c), w(g), e.value = e.value + 1;
328
777
  } else
329
778
  console.warn(
330
- `Bitmap for index ${r.value} not found. Ensure the data is loaded.`
331
- ), t("notFound", r.value);
779
+ `Bitmap for index ${e.value} not found. Ensure the data is loaded.`
780
+ ), r("notFound", e.value);
332
781
  }
333
- i = requestAnimationFrame(s);
782
+ u = requestAnimationFrame(d);
334
783
  }
335
- T(() => {
336
- e.prerender && r.value === 0 && e.data.length > 0 && e.data[0] && v(e.data[0]);
337
- }), G(() => e.status, (s) => {
338
- s === n.play && I(), s === n.pause && h(), s === n.stop && p();
784
+ B(() => {
785
+ t.prerender && e.value === 0 && t.data.length > 0 && t.data[0] && w(t.data[0]);
786
+ }), Q(() => t.status, (d) => {
787
+ d === m.play && A(), d === m.pause && y(), d === m.stop && F();
339
788
  }, { immediate: !0 });
340
- function I() {
341
- e.data.length > 0 ? (t("update:status", n.playing), A()) : t("update:status", n.stopped);
789
+ function A() {
790
+ t.data.length > 0 ? (r("update:status", m.playing), h()) : r("update:status", m.stopped);
342
791
  }
343
- function h() {
344
- t("update:status", n.paused);
792
+ function y() {
793
+ r("update:status", m.paused);
345
794
  }
346
- function p() {
347
- t("update:status", n.stopped), i !== null && (cancelAnimationFrame(i), i = null), t("update:data", []), r.value = 0, w.value = -1;
795
+ function F() {
796
+ r("update:status", m.stopped), u !== null && (cancelAnimationFrame(u), u = null), r("update:data", []), e.value = 0, n.value = -1;
348
797
  }
349
- return R(() => {
350
- p(), f.destroy();
351
- }), (s, d) => D(s.$slots, "default");
798
+ return S(() => {
799
+ F(), _.destroy();
800
+ }), (d, f) => V(d.$slots, "default");
352
801
  }
353
- }), ze = /* @__PURE__ */ E({
802
+ }), je = /* @__PURE__ */ C({
354
803
  __name: "buffer-image",
355
804
  props: {
356
- ...J(V, {
805
+ ...se(q, {
357
806
  excludes: ["loop"]
358
807
  }),
359
808
  data: {
@@ -381,95 +830,95 @@ const _e = /* @__PURE__ */ E({
381
830
  }
382
831
  },
383
832
  emits: {
384
- ...S,
385
- load: (a) => a,
833
+ ...j,
834
+ load: (o) => o,
386
835
  "update:frameIndex": null,
387
- notFound: (a) => !0
836
+ notFound: (o) => !0
388
837
  },
389
- setup(a, { emit: m }) {
390
- const e = a, t = m, { sprite: F, resizeSprite: l, application: y } = B(e), f = new Y({
838
+ setup(o, { emit: P }) {
839
+ const t = o, r = P, { sprite: p, resizeSprite: l, application: v } = z(t), _ = new ee({
391
840
  dynamic: !0
392
841
  });
393
- F.texture = f;
394
- function v(s) {
395
- f.source?.destroy();
396
- const d = new ge({
397
- resource: s,
398
- height: e.height,
399
- width: e.width,
400
- format: e.format
842
+ p.texture = _;
843
+ function w(d) {
844
+ _.source?.destroy();
845
+ const f = new we({
846
+ resource: d,
847
+ height: t.height,
848
+ width: t.width,
849
+ format: t.format
401
850
  });
402
- f.source = d, f.update(), l();
851
+ _.source = f, _.update(), l();
403
852
  }
404
- t("load", {
405
- application: y,
406
- sprite: F
853
+ r("load", {
854
+ application: v,
855
+ sprite: p
407
856
  });
408
- const r = Q({
857
+ const e = ie({
409
858
  default: 0,
410
859
  key: "frameIndex"
411
- }, e, t), w = $(-1);
412
- function g(s) {
413
- s <= w.value || (w.value = s, K(0).then(() => {
414
- t("setData", {
415
- k: s,
860
+ }, t, r), n = U(-1);
861
+ function a(d) {
862
+ d <= n.value || (n.value = d, Z(0).then(() => {
863
+ r("setData", {
864
+ k: d,
416
865
  v: null
417
866
  });
418
867
  }));
419
868
  }
420
- let i = null, u = 0, c = 0, k = 0;
421
- function A() {
422
- if (i !== null)
869
+ let u = null, i = 0, s = 0, b = 0;
870
+ function h() {
871
+ if (u !== null)
423
872
  return;
424
- u = performance.now(), k = u, c = 0;
425
- function s() {
426
- const x = performance.now(), o = 1e3 / e.frameRate, _ = x - u;
427
- if (_ >= o) {
428
- u = x - _ % o, d(), c++;
429
- const b = x - k;
430
- if (b >= 1e3) {
431
- const C = Math.round(c * 1e3 / b);
432
- console.log(`[Bitmap] FPS: ${C}`), c = 0, k = x;
873
+ i = performance.now(), b = i, s = 0;
874
+ function d() {
875
+ const g = performance.now(), c = 1e3 / t.frameRate, x = g - i;
876
+ if (x >= c) {
877
+ i = g - x % c, f(), s++;
878
+ const I = g - b;
879
+ if (I >= 1e3) {
880
+ const N = Math.round(s * 1e3 / I);
881
+ console.log(`[Bitmap] FPS: ${N}`), s = 0, b = g;
433
882
  }
434
883
  }
435
- e.status === n.playing ? i = requestAnimationFrame(s) : i = null;
884
+ t.status === m.playing ? u = requestAnimationFrame(d) : u = null;
436
885
  }
437
- function d() {
438
- if (e.data.length === 0 || e.status !== n.playing)
886
+ function f() {
887
+ if (t.data.length === 0 || t.status !== m.playing)
439
888
  return;
440
- const x = e.data[r.value];
441
- if (x) {
442
- const o = r.value - 1;
443
- o >= 0 && g(o), v(x), r.value = r.value + 1;
889
+ const g = t.data[e.value];
890
+ if (g) {
891
+ const c = e.value - 1;
892
+ c >= 0 && a(c), w(g), e.value = e.value + 1;
444
893
  } else
445
894
  console.warn(
446
- `Bitmap for index ${r.value} not found. Ensure the data is loaded.`
447
- ), t("notFound", r.value);
895
+ `Bitmap for index ${e.value} not found. Ensure the data is loaded.`
896
+ ), r("notFound", e.value);
448
897
  }
449
- i = requestAnimationFrame(s);
898
+ u = requestAnimationFrame(d);
450
899
  }
451
- T(() => {
452
- e.prerender && r.value === 0 && e.data.length > 0 && e.data[0] && v(e.data[0]);
453
- }), G(() => e.status, (s) => {
454
- s === n.play && I(), s === n.pause && h(), s === n.stop && p();
900
+ B(() => {
901
+ t.prerender && e.value === 0 && t.data.length > 0 && t.data[0] && w(t.data[0]);
902
+ }), Q(() => t.status, (d) => {
903
+ d === m.play && A(), d === m.pause && y(), d === m.stop && F();
455
904
  }, { immediate: !0 });
456
- function I() {
457
- e.data.length > 0 ? (t("update:status", n.playing), A()) : t("update:status", n.stopped);
905
+ function A() {
906
+ t.data.length > 0 ? (r("update:status", m.playing), h()) : r("update:status", m.stopped);
458
907
  }
459
- function h() {
460
- t("update:status", n.paused);
908
+ function y() {
909
+ r("update:status", m.paused);
461
910
  }
462
- function p() {
463
- t("update:status", n.stopped), i !== null && (cancelAnimationFrame(i), i = null), t("update:data", []), r.value = 0, w.value = -1;
911
+ function F() {
912
+ r("update:status", m.stopped), u !== null && (cancelAnimationFrame(u), u = null), r("update:data", []), e.value = 0, n.value = -1;
464
913
  }
465
- return R(() => {
466
- p(), f.destroy();
467
- }), (s, d) => D(s.$slots, "default");
914
+ return S(() => {
915
+ F(), _.destroy();
916
+ }), (d, f) => V(d.$slots, "default");
468
917
  }
469
- }), Me = /* @__PURE__ */ E({
918
+ }), ze = /* @__PURE__ */ C({
470
919
  __name: "core",
471
920
  props: {
472
- ...V,
921
+ ...q,
473
922
  data: {
474
923
  type: void 0,
475
924
  required: !0
@@ -479,179 +928,179 @@ const _e = /* @__PURE__ */ E({
479
928
  }
480
929
  },
481
930
  emits: {
482
- ...S,
483
- load: (a) => a,
931
+ ...j,
932
+ load: (o) => o,
484
933
  "update:frameIndex": null,
485
- notFound: (a) => !0
934
+ notFound: (o) => !0
486
935
  },
487
- setup(a, { emit: m }) {
488
- const e = a, t = m, F = W(), l = (p) => `${F}-${p}`, { sprite: y, resizeSprite: f, application: v } = B(e), r = /* @__PURE__ */ new Map(), w = $(0), g = j(() => e.data.slice(w.value));
489
- T(() => {
490
- for (const p in g.value) {
491
- const s = +p + w.value, d = `${F}-${s}`, x = typeof g.value[p] == "string" ? g.value[p] : g.value[p]?.src;
492
- x && (r.has(d) || (P.add({
493
- alias: d,
494
- src: x,
936
+ setup(o, { emit: P }) {
937
+ const t = o, r = P, p = ne(), l = (F) => `${p}-${F}`, { sprite: v, resizeSprite: _, application: w } = z(t), e = /* @__PURE__ */ new Map(), n = U(0), a = J(() => t.data.slice(n.value));
938
+ B(() => {
939
+ for (const F in a.value) {
940
+ const d = +F + n.value, f = `${p}-${d}`, g = typeof a.value[F] == "string" ? a.value[F] : a.value[F]?.src;
941
+ g && (e.has(f) || (R.add({
942
+ alias: f,
943
+ src: g,
495
944
  loadParser: "loadTextures"
496
- }), r.set(d, void 0), P.load(d).then((o) => {
497
- o._meta = g.value[p], r.set(d, o), e.prerender && s === 0 && (y.texture = o, f());
945
+ }), e.set(f, void 0), R.load(f).then((c) => {
946
+ c._meta = a.value[F], e.set(f, c), t.prerender && d === 0 && (v.texture = c, _());
498
947
  })));
499
948
  }
500
- }), t("load", {
501
- application: v,
502
- sprite: y
949
+ }), r("load", {
950
+ application: w,
951
+ sprite: v
503
952
  });
504
- const i = Q({
953
+ const u = ie({
505
954
  default: 0,
506
955
  key: "frameIndex"
507
- }, e, t);
508
- let u = null, c = 0;
509
- function k() {
510
- if (u !== null)
956
+ }, t, r);
957
+ let i = null, s = 0;
958
+ function b() {
959
+ if (i !== null)
511
960
  return;
512
- c = performance.now();
513
- function p() {
514
- const d = performance.now(), x = 1e3 / e.frameRate, o = d - c;
515
- o >= x && (c = d - o % x, s()), e.status === n.playing ? u = requestAnimationFrame(p) : u = null;
961
+ s = performance.now();
962
+ function F() {
963
+ const f = performance.now(), g = 1e3 / t.frameRate, c = f - s;
964
+ c >= g && (s = f - c % g, d()), t.status === m.playing ? i = requestAnimationFrame(F) : i = null;
516
965
  }
517
- function s() {
518
- if (e.data.length === 0 || e.status !== n.playing)
966
+ function d() {
967
+ if (t.data.length === 0 || t.status !== m.playing)
519
968
  return;
520
- const d = r.get(
521
- l(i.value)
969
+ const f = e.get(
970
+ l(u.value)
522
971
  );
523
- if (d) {
524
- const x = y.texture, o = i.value - 1;
525
- x && o >= 0 && !e.loop && Promise.resolve(K(500)).then(() => P.unload(
526
- l(o)
972
+ if (f) {
973
+ const g = v.texture, c = u.value - 1;
974
+ g && c >= 0 && !t.loop && Promise.resolve(Z(500)).then(() => R.unload(
975
+ l(c)
527
976
  )).then(() => {
528
- r.set(
529
- l(o),
977
+ e.set(
978
+ l(c),
530
979
  void 0
531
- ), t("setData", {
532
- k: o,
980
+ ), r("setData", {
981
+ k: c,
533
982
  v: ""
534
- }), w.value = o;
535
- }), y.texture = d, f(), i.value = e.loop ? (i.value + 1) % e.data.length : i.value + 1;
983
+ }), n.value = c;
984
+ }), v.texture = f, _(), u.value = t.loop ? (u.value + 1) % t.data.length : u.value + 1;
536
985
  } else
537
986
  console.warn(
538
- `Texture for index ${i.value} not found. Ensure the texture is loaded.`
539
- ), t("notFound", i.value), e.loop || t("update:status", n.paused);
987
+ `Texture for index ${u.value} not found. Ensure the texture is loaded.`
988
+ ), r("notFound", u.value), t.loop || r("update:status", m.paused);
540
989
  }
541
- u = requestAnimationFrame(p);
990
+ i = requestAnimationFrame(F);
542
991
  }
543
- G(() => e.status, (p) => {
544
- p === n.play && A(), p === n.pause && I(), p === n.stop && h();
992
+ Q(() => t.status, (F) => {
993
+ F === m.play && h(), F === m.pause && A(), F === m.stop && y();
545
994
  }, { immediate: !0 });
546
- function A() {
547
- e.data.length > 0 ? (t("update:status", n.playing), k()) : t("update:status", n.stopped);
995
+ function h() {
996
+ t.data.length > 0 ? (r("update:status", m.playing), b()) : r("update:status", m.stopped);
548
997
  }
549
- function I() {
550
- t("update:status", n.paused);
998
+ function A() {
999
+ r("update:status", m.paused);
551
1000
  }
552
- function h() {
553
- t("update:status", n.stopped), u !== null && (cancelAnimationFrame(u), u = null), t("update:data", []), r.clear(), i.value = 0;
1001
+ function y() {
1002
+ r("update:status", m.stopped), i !== null && (cancelAnimationFrame(i), i = null), r("update:data", []), e.clear(), u.value = 0;
554
1003
  }
555
- return R(() => {
556
- Array.from(r.entries()).forEach(([s, d]) => {
557
- d && P.unload(s);
558
- }), h();
559
- }), (p, s) => D(p.$slots, "default");
1004
+ return S(() => {
1005
+ Array.from(e.entries()).forEach(([d, f]) => {
1006
+ f && R.unload(d);
1007
+ }), y();
1008
+ }), (F, d) => V(F.$slots, "default");
560
1009
  }
561
- }), ke = /* @__PURE__ */ E({
1010
+ }), Le = /* @__PURE__ */ C({
562
1011
  __name: "provider",
563
- setup(a) {
564
- return we(), (m, e) => D(m.$slots, "default");
1012
+ setup(o) {
1013
+ return Ie(), (P, t) => V(P.$slots, "default");
565
1014
  }
566
- }), Pe = /* @__PURE__ */ E({
1015
+ }), Re = /* @__PURE__ */ C({
567
1016
  __name: "video",
568
1017
  props: {
569
- ...V,
1018
+ ...q,
570
1019
  url: {
571
1020
  type: String,
572
1021
  required: !0
573
1022
  }
574
1023
  },
575
- emits: S,
576
- setup(a, { emit: m }) {
577
- const e = a, t = m, F = W(), l = () => `${F}-video`, { sprite: y, resizeSprite: f } = B(e), v = $(), r = j(() => {
578
- if (v.value?.source && v.value.source.resource) {
579
- const h = v.value.source.resource;
580
- if (h instanceof HTMLVideoElement)
581
- return h;
1024
+ emits: j,
1025
+ setup(o, { emit: P }) {
1026
+ const t = o, r = P, p = ne(), l = () => `${p}-video`, { sprite: v, resizeSprite: _ } = z(t), w = U(), e = J(() => {
1027
+ if (w.value?.source && w.value.source.resource) {
1028
+ const y = w.value.source.resource;
1029
+ if (y instanceof HTMLVideoElement)
1030
+ return y;
582
1031
  }
583
1032
  return null;
584
- }), w = he(), g = $("");
585
- w.promise.then(() => {
586
- e.status === n.play && k();
587
- }), T(() => {
588
- r.value && (r.value.loop = e.loop);
589
- }), X(() => i(e.url));
590
- async function i(h) {
1033
+ }), n = be(), a = U("");
1034
+ n.promise.then(() => {
1035
+ t.status === m.play && b();
1036
+ }), B(() => {
1037
+ e.value && (e.value.loop = t.loop);
1038
+ }), ae(() => u(t.url));
1039
+ async function u(y) {
591
1040
  try {
592
- g.value = "";
593
- const p = l();
594
- P.cache.has(p) && await P.unload(p), P.add({ alias: p, src: h });
595
- const s = await P.load(p);
596
- return v.value = s, y.texture = s, r.value && (r.value.loop = e.loop, r.value.muted = !0, r.value.crossOrigin = "anonymous", u(r.value), w.resolve()), f(), s;
597
- } catch (p) {
598
- return console.error("加载视频纹理失败:", p), g.value = "视频加载失败", null;
1041
+ a.value = "";
1042
+ const F = l();
1043
+ R.cache.has(F) && await R.unload(F), R.add({ alias: F, src: y });
1044
+ const d = await R.load(F);
1045
+ return w.value = d, v.texture = d, e.value && (e.value.loop = t.loop, e.value.muted = !0, e.value.crossOrigin = "anonymous", i(e.value), n.resolve()), _(), d;
1046
+ } catch (F) {
1047
+ return console.error("加载视频纹理失败:", F), a.value = "视频加载失败", null;
599
1048
  }
600
1049
  }
601
- function u(h) {
602
- h.addEventListener("play", () => {
603
- e.status !== n.playing && t("update:status", n.playing);
604
- }), h.addEventListener("pause", () => {
605
- e.status !== n.paused && t("update:status", n.paused);
606
- }), h.addEventListener("ended", () => {
607
- e.loop ? (h.currentTime = 0, h.play()) : t("update:status", n.stopped);
608
- }), h.addEventListener("error", (p) => {
609
- const s = h.error;
610
- let d = "视频播放失败";
611
- if (s)
612
- switch (s.code) {
613
- case s.MEDIA_ERR_ABORTED:
614
- d = "视频播放被中止";
1050
+ function i(y) {
1051
+ y.addEventListener("play", () => {
1052
+ t.status !== m.playing && r("update:status", m.playing);
1053
+ }), y.addEventListener("pause", () => {
1054
+ t.status !== m.paused && r("update:status", m.paused);
1055
+ }), y.addEventListener("ended", () => {
1056
+ t.loop ? (y.currentTime = 0, y.play()) : r("update:status", m.stopped);
1057
+ }), y.addEventListener("error", (F) => {
1058
+ const d = y.error;
1059
+ let f = "视频播放失败";
1060
+ if (d)
1061
+ switch (d.code) {
1062
+ case d.MEDIA_ERR_ABORTED:
1063
+ f = "视频播放被中止";
615
1064
  break;
616
- case s.MEDIA_ERR_NETWORK:
617
- d = "网络错误导致视频播放失败";
1065
+ case d.MEDIA_ERR_NETWORK:
1066
+ f = "网络错误导致视频播放失败";
618
1067
  break;
619
- case s.MEDIA_ERR_DECODE:
620
- d = "视频解码失败";
1068
+ case d.MEDIA_ERR_DECODE:
1069
+ f = "视频解码失败";
621
1070
  break;
622
- case s.MEDIA_ERR_SRC_NOT_SUPPORTED:
623
- d = "不支持的视频格式";
1071
+ case d.MEDIA_ERR_SRC_NOT_SUPPORTED:
1072
+ f = "不支持的视频格式";
624
1073
  break;
625
1074
  }
626
- console.error("视频播放错误:", d, p), g.value = d, t("update:status", n.stopped);
1075
+ console.error("视频播放错误:", f, F), a.value = f, r("update:status", m.stopped);
627
1076
  });
628
1077
  }
629
- async function c() {
630
- if (v.value) {
631
- const h = l();
632
- v.value.destroy(!0), v.value = void 0, P.cache.has(h) && await P.unload(h);
1078
+ async function s() {
1079
+ if (w.value) {
1080
+ const y = l();
1081
+ w.value.destroy(!0), w.value = void 0, R.cache.has(y) && await R.unload(y);
633
1082
  }
634
- g.value = "";
1083
+ a.value = "";
635
1084
  }
636
- T(() => {
637
- e.status === n.play && k(), e.status === n.pause && A(), e.status === n.stop && I();
638
- }), R(() => {
639
- c();
1085
+ B(() => {
1086
+ t.status === m.play && b(), t.status === m.pause && h(), t.status === m.stop && A();
1087
+ }), S(() => {
1088
+ s();
640
1089
  });
641
- function k() {
642
- r.value && r.value.play().catch((h) => {
643
- console.error("视频播放失败:", h), g.value = "视频播放失败";
1090
+ function b() {
1091
+ e.value && e.value.play().catch((y) => {
1092
+ console.error("视频播放失败:", y), a.value = "视频播放失败";
644
1093
  });
645
1094
  }
646
- function A() {
647
- r.value?.pause();
1095
+ function h() {
1096
+ e.value?.pause();
648
1097
  }
649
- function I() {
650
- r.value && (r.value.pause(), r.value.currentTime = 0), t("update:status", n.stopped);
1098
+ function A() {
1099
+ e.value && (e.value.pause(), e.value.currentTime = 0), r("update:status", m.stopped);
651
1100
  }
652
- return (h, p) => D(h.$slots, "default");
1101
+ return (y, F) => V(y.$slots, "default");
653
1102
  }
654
- }), be = /* @__PURE__ */ E({
1103
+ }), Te = /* @__PURE__ */ C({
655
1104
  __name: "view",
656
1105
  props: {
657
1106
  defaultOptions: {
@@ -659,97 +1108,97 @@ const _e = /* @__PURE__ */ E({
659
1108
  default: () => ({})
660
1109
  }
661
1110
  },
662
- setup(a) {
663
- const m = a, { application: e, context: t } = ne(), F = $();
664
- return X(async () => {
665
- await e.init({
666
- resizeTo: F.value,
667
- ...m.defaultOptions
668
- }), t.whenDef.resolve(e), F.value.appendChild(e.canvas);
669
- }), (l, y) => (N(), pe("div", {
1111
+ setup(o) {
1112
+ const P = o, { application: t, context: r } = ce(), p = U();
1113
+ return ae(async () => {
1114
+ await t.init({
1115
+ resizeTo: p.value,
1116
+ ...P.defaultOptions
1117
+ }), r.whenDef.resolve(t), p.value.appendChild(t.canvas);
1118
+ }), (l, v) => (H(), me("div", {
670
1119
  ref_key: "appRef",
671
- ref: F,
1120
+ ref: p,
672
1121
  class: "vk-pixi-frame"
673
1122
  }, null, 512));
674
1123
  }
675
- }), $e = E({
1124
+ }), Oe = C({
676
1125
  name: "VkPixiFrame",
677
1126
  components: {
678
- ApngComp: _e,
1127
+ ApngComp: Ne,
679
1128
  // CoreComp,
680
- ProviderComp: ke,
681
- ViewComp: be,
682
- VideoComp: Pe,
683
- Bitmap: Fe
1129
+ ProviderComp: Le,
1130
+ ViewComp: Te,
1131
+ VideoComp: Re,
1132
+ Bitmap: De
684
1133
  },
685
- props: V,
686
- emits: S,
687
- setup(a) {
688
- const m = j(() => {
689
- if (!a.url)
1134
+ props: q,
1135
+ emits: j,
1136
+ setup(o) {
1137
+ const P = J(() => {
1138
+ if (!o.url)
690
1139
  return !1;
691
- const t = a.url.toLowerCase();
692
- return t.includes(".png") && !t.includes(".mp4") && !t.includes(".webm");
693
- }), e = j(() => {
694
- if (!a.url)
1140
+ const r = o.url.toLowerCase();
1141
+ return r.includes(".png") && !r.includes(".mp4") && !r.includes(".webm");
1142
+ }), t = J(() => {
1143
+ if (!o.url)
695
1144
  return !1;
696
- const t = a.url.toLowerCase();
697
- return t.includes(".mp4") || t.includes(".webm") || t.includes(".mov");
1145
+ const r = o.url.toLowerCase();
1146
+ return r.includes(".mp4") || r.includes(".webm") || r.includes(".mov");
698
1147
  });
699
1148
  return {
700
- isApng: m,
701
- isVideo: e
1149
+ isApng: P,
1150
+ isVideo: t
702
1151
  };
703
1152
  }
704
1153
  });
705
- function Ae(a, m, e, t, F, l) {
706
- const y = q("ViewComp"), f = q("ApngComp"), v = q("VideoComp"), r = q("Bitmap"), w = q("ProviderComp");
707
- return N(), U(w, null, {
708
- default: ce(() => [
709
- de(y),
710
- a.isApng && a.url ? (N(), U(f, {
1154
+ function Ue(o, P, t, r, p, l) {
1155
+ const v = K("ViewComp"), _ = K("ApngComp"), w = K("VideoComp"), e = K("Bitmap"), n = K("ProviderComp");
1156
+ return H(), Y(n, null, {
1157
+ default: he(() => [
1158
+ ve(v),
1159
+ o.isApng && o.url ? (H(), Y(_, {
711
1160
  key: 0,
712
- url: a.url,
713
- loop: a.loop,
714
- status: a.status,
715
- "onUpdate:status": m[0] || (m[0] = (g) => a.$emit("update:status", g))
716
- }, null, 8, ["url", "loop", "status"])) : a.isVideo && a.url ? (N(), U(v, {
1161
+ url: o.url,
1162
+ loop: o.loop,
1163
+ status: o.status,
1164
+ "onUpdate:status": P[0] || (P[0] = (a) => o.$emit("update:status", a))
1165
+ }, null, 8, ["url", "loop", "status"])) : o.isVideo && o.url ? (H(), Y(w, {
717
1166
  key: 1,
718
- url: a.url,
719
- loop: a.loop,
720
- status: a.status,
721
- "onUpdate:status": m[1] || (m[1] = (g) => a.$emit("update:status", g))
722
- }, null, 8, ["url", "loop", "status"])) : (N(), U(r, {
1167
+ url: o.url,
1168
+ loop: o.loop,
1169
+ status: o.status,
1170
+ "onUpdate:status": P[1] || (P[1] = (a) => o.$emit("update:status", a))
1171
+ }, null, 8, ["url", "loop", "status"])) : (H(), Y(e, {
723
1172
  key: 2,
724
- data: a.data,
725
- loop: a.loop,
726
- status: a.status,
727
- onSetData: m[2] || (m[2] = (g) => a.$emit("setData", g)),
728
- "onUpdate:status": m[3] || (m[3] = (g) => a.$emit("update:status", g))
1173
+ data: o.data,
1174
+ loop: o.loop,
1175
+ status: o.status,
1176
+ onSetData: P[2] || (P[2] = (a) => o.$emit("setData", a)),
1177
+ "onUpdate:status": P[3] || (P[3] = (a) => o.$emit("update:status", a))
729
1178
  }, null, 8, ["data", "loop", "status"]))
730
1179
  ]),
731
1180
  _: 1
732
1181
  });
733
1182
  }
734
- const H = /* @__PURE__ */ xe($e, [["render", Ae]]), qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1183
+ const re = /* @__PURE__ */ xe(Oe, [["render", Ue]]), Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
735
1184
  __proto__: null
736
1185
  }, Symbol.toStringTag, { value: "Module" }));
737
- H.install = (a) => {
738
- a.component(H.name || "VkPixiFrame", H);
1186
+ re.install = (o) => {
1187
+ o.component(re.name || "VkPixiFrame", re);
739
1188
  };
740
1189
  export {
741
- Oe as TickerStatus,
742
- H as VkPixiFrame,
743
- _e as VkPixiFrameApng,
744
- Fe as VkPixiFrameBitmap,
745
- Be as VkPixiFrameBitmapGenerator,
746
- ze as VkPixiFrameBufferImage,
747
- Me as VkPixiFrameCore,
748
- ke as VkPixiFrameProvider,
749
- Pe as VkPixiFrameVideo,
750
- be as VkPixiFrameView,
751
- qe as __VkPixiFrame,
752
- H as default,
753
- ne as usePixiApp,
754
- B as useSprite
1190
+ Ye as TickerStatus,
1191
+ re as VkPixiFrame,
1192
+ Ne as VkPixiFrameApng,
1193
+ De as VkPixiFrameBitmap,
1194
+ Ge as VkPixiFrameBitmapGenerator,
1195
+ je as VkPixiFrameBufferImage,
1196
+ ze as VkPixiFrameCore,
1197
+ Le as VkPixiFrameProvider,
1198
+ Re as VkPixiFrameVideo,
1199
+ Te as VkPixiFrameView,
1200
+ Ke as __VkPixiFrame,
1201
+ re as default,
1202
+ ce as usePixiApp,
1203
+ z as useSprite
755
1204
  };