@vunk/plus 1.4.6 → 1.5.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/components/WebGLRenderer.mjs +1 -0
- package/components/WebGPURenderer.mjs +1 -0
- package/components/broadcasting-markdown/index.mjs +82 -9
- package/components/browserAll.mjs +1 -0
- package/components/index2.mjs +1498 -62
- package/components/pixi-frame/index.mjs +2 -1
- package/components/text/index.mjs +106 -0
- package/components/typing-markdown/index.css +19 -0
- package/components/typing-markdown/index.mjs +17 -4
- package/components/webworkerAll.mjs +1 -0
- package/index.css +19 -0
- package/package.json +5 -1
- package/components/agent-chat-provider/index.d.ts +0 -7
- package/components/agent-chat-provider/src/api.d.ts +0 -3
- package/components/agent-chat-provider/src/const-roles.d.ts +0 -8
- package/components/agent-chat-provider/src/const.d.ts +0 -1
- package/components/agent-chat-provider/src/index.vue.d.ts +0 -47
- package/components/agent-chat-provider/src/types.d.ts +0 -43
- package/components/agent-chat-provider/src/use.d.ts +0 -29
- package/components/avatar/index.d.ts +0 -4
- package/components/avatar/src/ctx.d.ts +0 -18
- package/components/avatar/src/index.vue.d.ts +0 -121
- package/components/avatar/src/types.d.ts +0 -1
- package/components/broadcasting-markdown/index.d.ts +0 -7
- package/components/broadcasting-markdown/src/const.d.ts +0 -13
- package/components/broadcasting-markdown/src/ctx.d.ts +0 -115
- package/components/broadcasting-markdown/src/howler-speech.vue.d.ts +0 -97
- package/components/broadcasting-markdown/src/index.vue.d.ts +0 -383
- package/components/broadcasting-markdown/src/paragraph.vue.d.ts +0 -79
- package/components/broadcasting-markdown/src/speech-error.vue.d.ts +0 -60
- package/components/broadcasting-markdown/src/types.d.ts +0 -25
- package/components/broadcasting-markdown/src/use.d.ts +0 -21
- package/components/bubble-list/index.d.ts +0 -5
- package/components/bubble-list/src/ctx.d.ts +0 -30
- package/components/bubble-list/src/index.vue.d.ts +0 -867
- package/components/bubble-list/src/types.d.ts +0 -4
- package/components/bubble-templates/index.d.ts +0 -4
- package/components/bubble-templates/src/index.vue.d.ts +0 -539
- package/components/bubble-templates/src/types.d.ts +0 -40
- package/components/chat-independent/index.d.ts +0 -4
- package/components/chat-independent/src/const.d.ts +0 -13
- package/components/chat-independent/src/ctx.d.ts +0 -20
- package/components/chat-independent/src/index.vue.d.ts +0 -2345
- package/components/chat-independent/src/types.d.ts +0 -13
- package/components/index.d.ts +0 -0
- package/components/lottie-animation/index.d.ts +0 -4
- package/components/lottie-animation/src/ctx.d.ts +0 -10
- package/components/lottie-animation/src/index.vue.d.ts +0 -21
- package/components/lottie-animation/src/types.d.ts +0 -4
- package/components/monaco-editor/index.d.ts +0 -5
- package/components/monaco-editor/src/ctx.d.ts +0 -23
- package/components/monaco-editor/src/index.vue.d.ts +0 -40
- package/components/monaco-editor/src/types.d.ts +0 -1
- package/components/monaco-environment/index.d.ts +0 -4
- package/components/monaco-environment/src/ctx.d.ts +0 -8
- package/components/monaco-environment/src/index.vue.d.ts +0 -2
- package/components/monaco-environment/src/types.d.ts +0 -1
- package/components/pixi-frame/index.d.ts +0 -8
- package/components/pixi-frame/src/core.vue.d.ts +0 -131
- package/components/pixi-frame/src/ctx.d.ts +0 -44
- package/components/pixi-frame/src/index.vue.d.ts +0 -230
- package/components/pixi-frame/src/provider.vue.d.ts +0 -2
- package/components/pixi-frame/src/types.d.ts +0 -1
- package/components/pixi-frame/src/use.d.ts +0 -16
- package/components/pixi-frame/src/view.vue.d.ts +0 -29
- package/components/recorder-button/index.d.ts +0 -4
- package/components/recorder-button/src/ctx.d.ts +0 -41
- package/components/recorder-button/src/index.vue.d.ts +0 -300
- package/components/recorder-button/src/speech-to-text.d.ts +0 -1
- package/components/recorder-button/src/types.d.ts +0 -7
- package/components/routes-menu-content/index.d.ts +0 -4
- package/components/routes-menu-content/src/ctx.d.ts +0 -17
- package/components/routes-menu-content/src/index.vue.d.ts +0 -472
- package/components/routes-menu-content/src/item/core/ctx.d.ts +0 -18
- package/components/routes-menu-content/src/item/core/index.vue.d.ts +0 -307
- package/components/routes-menu-content/src/item/ctx.d.ts +0 -14
- package/components/routes-menu-content/src/item/index.vue.d.ts +0 -438
- package/components/routes-menu-content/src/types.d.ts +0 -1
- package/components/sender/index.d.ts +0 -4
- package/components/sender/src/SenderHeader.vue.d.ts +0 -256
- package/components/sender/src/ctx.d.ts +0 -62
- package/components/sender/src/index.vue.d.ts +0 -787
- package/components/sender/src/types.d.ts +0 -1
- package/components/speech-button/index.d.ts +0 -4
- package/components/speech-button/src/LoadingIcon.vue.d.ts +0 -2
- package/components/speech-button/src/RecordingIcon.vue.d.ts +0 -2
- package/components/speech-button/src/ctx.d.ts +0 -10
- package/components/speech-button/src/index.vue.d.ts +0 -22
- package/components/speech-button/src/types.d.ts +0 -1
- package/components/table-columns/index.d.ts +0 -5
- package/components/table-columns/src/ctx.d.ts +0 -66
- package/components/table-columns/src/el-ctx.d.ts +0 -63
- package/components/table-columns/src/index.vue.d.ts +0 -282
- package/components/table-columns/src/types.d.ts +0 -21
- package/components/tables-v1/index.d.ts +0 -5
- package/components/tables-v1/src/ctx.d.ts +0 -288
- package/components/tables-v1/src/el-ctx.d.ts +0 -269
- package/components/tables-v1/src/index.vue.d.ts +0 -3106
- package/components/tables-v1/src/types.d.ts +0 -3
- package/components/tables-v1-checkbox/index.d.ts +0 -5
- package/components/tables-v1-checkbox/src/ctx.d.ts +0 -325
- package/components/tables-v1-checkbox/src/index.vue.d.ts +0 -3898
- package/components/tables-v1-checkbox/src/types.d.ts +0 -1
- package/components/typing-markdown/index.d.ts +0 -4
- package/components/typing-markdown/src/core.d.ts +0 -2
- package/components/typing-markdown/src/ctx.d.ts +0 -33
- package/components/typing-markdown/src/index.vue.d.ts +0 -57
- package/components/typing-markdown/src/types.d.ts +0 -1
- package/components/vditor/index.d.ts +0 -5
- package/components/vditor/src/ctx.d.ts +0 -37
- package/components/vditor/src/handle-fullscreen.vue.d.ts +0 -18
- package/components/vditor/src/handle-value.vue.d.ts +0 -18
- package/components/vditor/src/index.vue.d.ts +0 -144
- package/components/vditor/src/types.d.ts +0 -9
- package/components/vditor/src/use.d.ts +0 -4
package/components/index2.mjs
CHANGED
|
@@ -1,9 +1,996 @@
|
|
|
1
|
-
import { inject, provide, defineComponent, useId,
|
|
1
|
+
import { inject, provide, watchEffect, onBeforeUnmount, defineComponent, useId, ref, onMounted, renderSlot, computed, watch, createElementBlock, openBlock, resolveComponent, createBlock, withCtx, createVNode, mergeProps } from 'vue';
|
|
2
2
|
import { TickerStatus } from '@vunk/shared/enum';
|
|
3
3
|
import { Deferred, sleep } from '@vunk/shared/promise';
|
|
4
|
-
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.mjs';
|
|
4
|
+
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers.mjs';
|
|
5
|
+
import { useModelComputed, useDeferred } from '@vunk/core/composables';
|
|
5
6
|
import { _ as _export_sfc } from './_plugin-vue_export-helper.mjs';
|
|
6
7
|
|
|
8
|
+
var lib = {exports: {}};
|
|
9
|
+
|
|
10
|
+
(function (module, exports) {
|
|
11
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
12
|
+
module.exports = factory();
|
|
13
|
+
})(commonjsGlobal, function() {
|
|
14
|
+
return /******/ (function(modules) { // webpackBootstrap
|
|
15
|
+
/******/ // The module cache
|
|
16
|
+
/******/ var installedModules = {};
|
|
17
|
+
|
|
18
|
+
/******/ // The require function
|
|
19
|
+
/******/ function __webpack_require__(moduleId) {
|
|
20
|
+
|
|
21
|
+
/******/ // Check if module is in cache
|
|
22
|
+
/******/ if(installedModules[moduleId])
|
|
23
|
+
/******/ return installedModules[moduleId].exports;
|
|
24
|
+
|
|
25
|
+
/******/ // Create a new module (and put it into the cache)
|
|
26
|
+
/******/ var module = installedModules[moduleId] = {
|
|
27
|
+
/******/ exports: {},
|
|
28
|
+
/******/ id: moduleId,
|
|
29
|
+
/******/ loaded: false
|
|
30
|
+
/******/ };
|
|
31
|
+
|
|
32
|
+
/******/ // Execute the module function
|
|
33
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
34
|
+
|
|
35
|
+
/******/ // Flag the module as loaded
|
|
36
|
+
/******/ module.loaded = true;
|
|
37
|
+
|
|
38
|
+
/******/ // Return the exports of the module
|
|
39
|
+
/******/ return module.exports;
|
|
40
|
+
/******/ }
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
44
|
+
/******/ __webpack_require__.m = modules;
|
|
45
|
+
|
|
46
|
+
/******/ // expose the module cache
|
|
47
|
+
/******/ __webpack_require__.c = installedModules;
|
|
48
|
+
|
|
49
|
+
/******/ // __webpack_public_path__
|
|
50
|
+
/******/ __webpack_require__.p = "";
|
|
51
|
+
|
|
52
|
+
/******/ // Load entry module and return exports
|
|
53
|
+
/******/ return __webpack_require__(0);
|
|
54
|
+
/******/ })
|
|
55
|
+
/************************************************************************/
|
|
56
|
+
/******/ ([
|
|
57
|
+
/* 0 */
|
|
58
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
59
|
+
|
|
60
|
+
Object.defineProperty(exports, "__esModule", {
|
|
61
|
+
value: true
|
|
62
|
+
});
|
|
63
|
+
exports.isNotPNG = isNotPNG;
|
|
64
|
+
exports.isNotAPNG = isNotAPNG;
|
|
65
|
+
exports.default = parseAPNG;
|
|
66
|
+
|
|
67
|
+
var _crc = __webpack_require__(1);
|
|
68
|
+
|
|
69
|
+
var _crc2 = _interopRequireDefault(_crc);
|
|
70
|
+
|
|
71
|
+
var _structs = __webpack_require__(2);
|
|
72
|
+
|
|
73
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
74
|
+
|
|
75
|
+
var errNotPNG = new Error('Not a PNG');
|
|
76
|
+
var errNotAPNG = new Error('Not an animated PNG');
|
|
77
|
+
|
|
78
|
+
function isNotPNG(err) {
|
|
79
|
+
return err === errNotPNG;
|
|
80
|
+
}
|
|
81
|
+
function isNotAPNG(err) {
|
|
82
|
+
return err === errNotAPNG;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// '\x89PNG\x0d\x0a\x1a\x0a'
|
|
86
|
+
var PNGSignature = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Parse APNG data
|
|
90
|
+
* @param {ArrayBuffer} buffer
|
|
91
|
+
* @return {APNG|Error}
|
|
92
|
+
*/
|
|
93
|
+
function parseAPNG(buffer) {
|
|
94
|
+
var bytes = new Uint8Array(buffer);
|
|
95
|
+
|
|
96
|
+
if (Array.prototype.some.call(PNGSignature, function (b, i) {
|
|
97
|
+
return b !== bytes[i];
|
|
98
|
+
})) {
|
|
99
|
+
return errNotPNG;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// fast animation test
|
|
103
|
+
var isAnimated = false;
|
|
104
|
+
eachChunk(bytes, function (type) {
|
|
105
|
+
return !(isAnimated = type === 'acTL');
|
|
106
|
+
});
|
|
107
|
+
if (!isAnimated) {
|
|
108
|
+
return errNotAPNG;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var preDataParts = [],
|
|
112
|
+
postDataParts = [];
|
|
113
|
+
var headerDataBytes = null,
|
|
114
|
+
frame = null,
|
|
115
|
+
frameNumber = 0,
|
|
116
|
+
apng = new _structs.APNG();
|
|
117
|
+
|
|
118
|
+
eachChunk(bytes, function (type, bytes, off, length) {
|
|
119
|
+
var dv = new DataView(bytes.buffer);
|
|
120
|
+
switch (type) {
|
|
121
|
+
case 'IHDR':
|
|
122
|
+
headerDataBytes = bytes.subarray(off + 8, off + 8 + length);
|
|
123
|
+
apng.width = dv.getUint32(off + 8);
|
|
124
|
+
apng.height = dv.getUint32(off + 12);
|
|
125
|
+
break;
|
|
126
|
+
case 'acTL':
|
|
127
|
+
apng.numPlays = dv.getUint32(off + 8 + 4);
|
|
128
|
+
break;
|
|
129
|
+
case 'fcTL':
|
|
130
|
+
if (frame) {
|
|
131
|
+
apng.frames.push(frame);
|
|
132
|
+
frameNumber++;
|
|
133
|
+
}
|
|
134
|
+
frame = new _structs.Frame();
|
|
135
|
+
frame.width = dv.getUint32(off + 8 + 4);
|
|
136
|
+
frame.height = dv.getUint32(off + 8 + 8);
|
|
137
|
+
frame.left = dv.getUint32(off + 8 + 12);
|
|
138
|
+
frame.top = dv.getUint32(off + 8 + 16);
|
|
139
|
+
var delayN = dv.getUint16(off + 8 + 20);
|
|
140
|
+
var delayD = dv.getUint16(off + 8 + 22);
|
|
141
|
+
if (delayD === 0) {
|
|
142
|
+
delayD = 100;
|
|
143
|
+
}
|
|
144
|
+
frame.delay = 1000 * delayN / delayD;
|
|
145
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=125137
|
|
146
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=139677
|
|
147
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=207059
|
|
148
|
+
if (frame.delay <= 10) {
|
|
149
|
+
frame.delay = 100;
|
|
150
|
+
}
|
|
151
|
+
apng.playTime += frame.delay;
|
|
152
|
+
frame.disposeOp = dv.getUint8(off + 8 + 24);
|
|
153
|
+
frame.blendOp = dv.getUint8(off + 8 + 25);
|
|
154
|
+
frame.dataParts = [];
|
|
155
|
+
if (frameNumber === 0 && frame.disposeOp === 2) {
|
|
156
|
+
frame.disposeOp = 1;
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
case 'fdAT':
|
|
160
|
+
if (frame) {
|
|
161
|
+
frame.dataParts.push(bytes.subarray(off + 8 + 4, off + 8 + length));
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case 'IDAT':
|
|
165
|
+
if (frame) {
|
|
166
|
+
frame.dataParts.push(bytes.subarray(off + 8, off + 8 + length));
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
case 'IEND':
|
|
170
|
+
postDataParts.push(subBuffer(bytes, off, 12 + length));
|
|
171
|
+
break;
|
|
172
|
+
default:
|
|
173
|
+
preDataParts.push(subBuffer(bytes, off, 12 + length));
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
if (frame) {
|
|
178
|
+
apng.frames.push(frame);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (apng.frames.length == 0) {
|
|
182
|
+
return errNotAPNG;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
var preBlob = new Blob(preDataParts),
|
|
186
|
+
postBlob = new Blob(postDataParts);
|
|
187
|
+
|
|
188
|
+
apng.frames.forEach(function (frame) {
|
|
189
|
+
var bb = [];
|
|
190
|
+
bb.push(PNGSignature);
|
|
191
|
+
headerDataBytes.set(makeDWordArray(frame.width), 0);
|
|
192
|
+
headerDataBytes.set(makeDWordArray(frame.height), 4);
|
|
193
|
+
bb.push(makeChunkBytes('IHDR', headerDataBytes));
|
|
194
|
+
bb.push(preBlob);
|
|
195
|
+
frame.dataParts.forEach(function (p) {
|
|
196
|
+
return bb.push(makeChunkBytes('IDAT', p));
|
|
197
|
+
});
|
|
198
|
+
bb.push(postBlob);
|
|
199
|
+
frame.imageData = new Blob(bb, { 'type': 'image/png' });
|
|
200
|
+
delete frame.dataParts;
|
|
201
|
+
bb = null;
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
return apng;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @param {Uint8Array} bytes
|
|
209
|
+
* @param {function(string, Uint8Array, int, int): boolean} callback
|
|
210
|
+
*/
|
|
211
|
+
function eachChunk(bytes, callback) {
|
|
212
|
+
var dv = new DataView(bytes.buffer);
|
|
213
|
+
var off = 8,
|
|
214
|
+
type = void 0,
|
|
215
|
+
length = void 0,
|
|
216
|
+
res = void 0;
|
|
217
|
+
do {
|
|
218
|
+
length = dv.getUint32(off);
|
|
219
|
+
type = readString(bytes, off + 4, 4);
|
|
220
|
+
res = callback(type, bytes, off, length);
|
|
221
|
+
off += 12 + length;
|
|
222
|
+
} while (res !== false && type != 'IEND' && off < bytes.length);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
*
|
|
227
|
+
* @param {Uint8Array} bytes
|
|
228
|
+
* @param {number} off
|
|
229
|
+
* @param {number} length
|
|
230
|
+
* @return {string}
|
|
231
|
+
*/
|
|
232
|
+
function readString(bytes, off, length) {
|
|
233
|
+
var chars = Array.prototype.slice.call(bytes.subarray(off, off + length));
|
|
234
|
+
return String.fromCharCode.apply(String, chars);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
*
|
|
239
|
+
* @param {string} x
|
|
240
|
+
* @return {Uint8Array}
|
|
241
|
+
*/
|
|
242
|
+
function makeStringArray(x) {
|
|
243
|
+
var res = new Uint8Array(x.length);
|
|
244
|
+
for (var i = 0; i < x.length; i++) {
|
|
245
|
+
res[i] = x.charCodeAt(i);
|
|
246
|
+
}
|
|
247
|
+
return res;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* @param {Uint8Array} bytes
|
|
252
|
+
* @param {int} start
|
|
253
|
+
* @param {int} length
|
|
254
|
+
* @return {Uint8Array}
|
|
255
|
+
*/
|
|
256
|
+
function subBuffer(bytes, start, length) {
|
|
257
|
+
var a = new Uint8Array(length);
|
|
258
|
+
a.set(bytes.subarray(start, start + length));
|
|
259
|
+
return a;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @param {string} type
|
|
264
|
+
* @param {Uint8Array} dataBytes
|
|
265
|
+
* @return {Uint8Array}
|
|
266
|
+
*/
|
|
267
|
+
var makeChunkBytes = function makeChunkBytes(type, dataBytes) {
|
|
268
|
+
var crcLen = type.length + dataBytes.length;
|
|
269
|
+
var bytes = new Uint8Array(crcLen + 8);
|
|
270
|
+
var dv = new DataView(bytes.buffer);
|
|
271
|
+
|
|
272
|
+
dv.setUint32(0, dataBytes.length);
|
|
273
|
+
bytes.set(makeStringArray(type), 4);
|
|
274
|
+
bytes.set(dataBytes, 8);
|
|
275
|
+
var crc = (0, _crc2.default)(bytes, 4, crcLen);
|
|
276
|
+
dv.setUint32(crcLen + 4, crc);
|
|
277
|
+
return bytes;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
var makeDWordArray = function makeDWordArray(x) {
|
|
281
|
+
return new Uint8Array([x >>> 24 & 0xff, x >>> 16 & 0xff, x >>> 8 & 0xff, x & 0xff]);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
/***/ }),
|
|
285
|
+
/* 1 */
|
|
286
|
+
/***/ (function(module, exports) {
|
|
287
|
+
|
|
288
|
+
Object.defineProperty(exports, "__esModule", {
|
|
289
|
+
value: true
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
exports.default = function (bytes) {
|
|
293
|
+
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
294
|
+
var length = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : bytes.length - start;
|
|
295
|
+
|
|
296
|
+
var crc = -1;
|
|
297
|
+
for (var _i = start, l = start + length; _i < l; _i++) {
|
|
298
|
+
crc = crc >>> 8 ^ table[(crc ^ bytes[_i]) & 0xFF];
|
|
299
|
+
}
|
|
300
|
+
return crc ^ -1;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
var table = new Uint32Array(256);
|
|
304
|
+
|
|
305
|
+
for (var i = 0; i < 256; i++) {
|
|
306
|
+
var c = i;
|
|
307
|
+
for (var k = 0; k < 8; k++) {
|
|
308
|
+
c = (c & 1) !== 0 ? 0xEDB88320 ^ c >>> 1 : c >>> 1;
|
|
309
|
+
}
|
|
310
|
+
table[i] = c;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
*
|
|
315
|
+
* @param {Uint8Array} bytes
|
|
316
|
+
* @param {number} start
|
|
317
|
+
* @param {number} length
|
|
318
|
+
* @return {number}
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
/***/ }),
|
|
322
|
+
/* 2 */
|
|
323
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
324
|
+
|
|
325
|
+
Object.defineProperty(exports, "__esModule", {
|
|
326
|
+
value: true
|
|
327
|
+
});
|
|
328
|
+
exports.Frame = exports.APNG = undefined;
|
|
329
|
+
|
|
330
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
331
|
+
|
|
332
|
+
var _player = __webpack_require__(3);
|
|
333
|
+
|
|
334
|
+
var _player2 = _interopRequireDefault(_player);
|
|
335
|
+
|
|
336
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
337
|
+
|
|
338
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* @property {number} currFrameNumber
|
|
342
|
+
* @property {Frame} currFrame
|
|
343
|
+
* @property {boolean} paused
|
|
344
|
+
* @property {boolean} ended
|
|
345
|
+
*/
|
|
346
|
+
exports.APNG = function () {
|
|
347
|
+
function APNG() {
|
|
348
|
+
_classCallCheck(this, APNG);
|
|
349
|
+
|
|
350
|
+
this.width = 0;
|
|
351
|
+
this.height = 0;
|
|
352
|
+
this.numPlays = 0;
|
|
353
|
+
this.playTime = 0;
|
|
354
|
+
this.frames = [];
|
|
355
|
+
}
|
|
356
|
+
/** @type {number} */
|
|
357
|
+
|
|
358
|
+
/** @type {number} */
|
|
359
|
+
|
|
360
|
+
/** @type {number} */
|
|
361
|
+
|
|
362
|
+
/** @type {number} */
|
|
363
|
+
|
|
364
|
+
/** @type {Frame[]} */
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
_createClass(APNG, [{
|
|
368
|
+
key: 'createImages',
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
*
|
|
373
|
+
* @return {Promise.<*>}
|
|
374
|
+
*/
|
|
375
|
+
value: function createImages() {
|
|
376
|
+
return Promise.all(this.frames.map(function (f) {
|
|
377
|
+
return f.createImage();
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
*
|
|
383
|
+
* @param {CanvasRenderingContext2D} context
|
|
384
|
+
* @param {boolean} autoPlay
|
|
385
|
+
* @return {Promise.<Player>}
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
}, {
|
|
389
|
+
key: 'getPlayer',
|
|
390
|
+
value: function getPlayer(context) {
|
|
391
|
+
var _this = this;
|
|
392
|
+
|
|
393
|
+
var autoPlay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
394
|
+
|
|
395
|
+
return this.createImages().then(function () {
|
|
396
|
+
return new _player2.default(_this, context, autoPlay);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}]);
|
|
400
|
+
|
|
401
|
+
return APNG;
|
|
402
|
+
}();
|
|
403
|
+
|
|
404
|
+
exports.Frame = function () {
|
|
405
|
+
function Frame() {
|
|
406
|
+
_classCallCheck(this, Frame);
|
|
407
|
+
|
|
408
|
+
this.left = 0;
|
|
409
|
+
this.top = 0;
|
|
410
|
+
this.width = 0;
|
|
411
|
+
this.height = 0;
|
|
412
|
+
this.delay = 0;
|
|
413
|
+
this.disposeOp = 0;
|
|
414
|
+
this.blendOp = 0;
|
|
415
|
+
this.imageData = null;
|
|
416
|
+
this.imageElement = null;
|
|
417
|
+
}
|
|
418
|
+
/** @type {number} */
|
|
419
|
+
|
|
420
|
+
/** @type {number} */
|
|
421
|
+
|
|
422
|
+
/** @type {number} */
|
|
423
|
+
|
|
424
|
+
/** @type {number} */
|
|
425
|
+
|
|
426
|
+
/** @type {number} */
|
|
427
|
+
|
|
428
|
+
/** @type {number} */
|
|
429
|
+
|
|
430
|
+
/** @type {number} */
|
|
431
|
+
|
|
432
|
+
/** @type {Blob} */
|
|
433
|
+
|
|
434
|
+
/** @type {HTMLImageElement} */
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
_createClass(Frame, [{
|
|
438
|
+
key: 'createImage',
|
|
439
|
+
value: function createImage() {
|
|
440
|
+
var _this2 = this;
|
|
441
|
+
|
|
442
|
+
if (this.imageElement) {
|
|
443
|
+
return Promise.resolve();
|
|
444
|
+
}
|
|
445
|
+
return new Promise(function (resolve, reject) {
|
|
446
|
+
var url = URL.createObjectURL(_this2.imageData);
|
|
447
|
+
_this2.imageElement = document.createElement('img');
|
|
448
|
+
_this2.imageElement.onload = function () {
|
|
449
|
+
URL.revokeObjectURL(url);
|
|
450
|
+
resolve();
|
|
451
|
+
};
|
|
452
|
+
_this2.imageElement.onerror = function () {
|
|
453
|
+
URL.revokeObjectURL(url);
|
|
454
|
+
_this2.imageElement = null;
|
|
455
|
+
reject(new Error("Image creation error"));
|
|
456
|
+
};
|
|
457
|
+
_this2.imageElement.src = url;
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}]);
|
|
461
|
+
|
|
462
|
+
return Frame;
|
|
463
|
+
}();
|
|
464
|
+
|
|
465
|
+
/***/ }),
|
|
466
|
+
/* 3 */
|
|
467
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
468
|
+
|
|
469
|
+
Object.defineProperty(exports, "__esModule", {
|
|
470
|
+
value: true
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
474
|
+
|
|
475
|
+
var _events = __webpack_require__(4);
|
|
476
|
+
|
|
477
|
+
var _events2 = _interopRequireDefault(_events);
|
|
478
|
+
|
|
479
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
480
|
+
|
|
481
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
482
|
+
|
|
483
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
484
|
+
|
|
485
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
486
|
+
|
|
487
|
+
var _class = function (_EventEmitter) {
|
|
488
|
+
_inherits(_class, _EventEmitter);
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* @param {APNG} apng
|
|
492
|
+
* @param {CanvasRenderingContext2D} context
|
|
493
|
+
* @param {boolean} autoPlay
|
|
494
|
+
*/
|
|
495
|
+
|
|
496
|
+
/** @type {number} */
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
/** @type {boolean} */
|
|
500
|
+
|
|
501
|
+
/** @type {ImageData} */
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
/** @type {APNG} */
|
|
505
|
+
|
|
506
|
+
/** @type {CanvasRenderingContext2D} */
|
|
507
|
+
function _class(apng, context, autoPlay) {
|
|
508
|
+
_classCallCheck(this, _class);
|
|
509
|
+
|
|
510
|
+
var _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this));
|
|
511
|
+
|
|
512
|
+
_this.playbackRate = 1.0;
|
|
513
|
+
_this._currentFrameNumber = 0;
|
|
514
|
+
_this._ended = false;
|
|
515
|
+
_this._paused = true;
|
|
516
|
+
_this._numPlays = 0;
|
|
517
|
+
_this._rafId = null;
|
|
518
|
+
|
|
519
|
+
_this._apng = apng;
|
|
520
|
+
_this.context = context;
|
|
521
|
+
_this.stop();
|
|
522
|
+
if (autoPlay) {
|
|
523
|
+
_this.play();
|
|
524
|
+
}
|
|
525
|
+
return _this;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
*
|
|
530
|
+
* @return {number}
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
/** @type {number|null} */
|
|
534
|
+
|
|
535
|
+
/** @type {boolean} */
|
|
536
|
+
|
|
537
|
+
/** @type {number} */
|
|
538
|
+
|
|
539
|
+
/** @type {Frame} */
|
|
540
|
+
|
|
541
|
+
/** @type {number} */
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
_createClass(_class, [{
|
|
545
|
+
key: 'renderNextFrame',
|
|
546
|
+
value: function renderNextFrame() {
|
|
547
|
+
this._currentFrameNumber = (this._currentFrameNumber + 1) % this._apng.frames.length;
|
|
548
|
+
if (this._currentFrameNumber === this._apng.frames.length - 1) {
|
|
549
|
+
this._numPlays++;
|
|
550
|
+
if (this._apng.numPlays !== 0 && this._numPlays >= this._apng.numPlays) {
|
|
551
|
+
this._ended = true;
|
|
552
|
+
this._paused = true;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if (this._prevFrame && this._prevFrame.disposeOp == 1) {
|
|
557
|
+
this.context.clearRect(this._prevFrame.left, this._prevFrame.top, this._prevFrame.width, this._prevFrame.height);
|
|
558
|
+
} else if (this._prevFrame && this._prevFrame.disposeOp == 2) {
|
|
559
|
+
this.context.putImageData(this._prevFrameData, this._prevFrame.left, this._prevFrame.top);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
var frame = this.currentFrame;
|
|
563
|
+
this._prevFrame = frame;
|
|
564
|
+
this._prevFrameData = null;
|
|
565
|
+
if (frame.disposeOp == 2) {
|
|
566
|
+
this._prevFrameData = this.context.getImageData(frame.left, frame.top, frame.width, frame.height);
|
|
567
|
+
}
|
|
568
|
+
if (frame.blendOp == 0) {
|
|
569
|
+
this.context.clearRect(frame.left, frame.top, frame.width, frame.height);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
this.context.drawImage(frame.imageElement, frame.left, frame.top);
|
|
573
|
+
|
|
574
|
+
this.emit('frame', this._currentFrameNumber);
|
|
575
|
+
if (this._ended) {
|
|
576
|
+
this.emit('end');
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// playback
|
|
581
|
+
|
|
582
|
+
}, {
|
|
583
|
+
key: 'play',
|
|
584
|
+
value: function play() {
|
|
585
|
+
var _this2 = this;
|
|
586
|
+
|
|
587
|
+
if (this._rafId) {
|
|
588
|
+
cancelAnimationFrame(this._rafId);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
this.emit('play');
|
|
592
|
+
|
|
593
|
+
if (this._ended) {
|
|
594
|
+
this.stop();
|
|
595
|
+
}
|
|
596
|
+
this._paused = false;
|
|
597
|
+
|
|
598
|
+
var nextRenderTime = performance.now() + this.currentFrame.delay / this.playbackRate;
|
|
599
|
+
var tick = function tick(now) {
|
|
600
|
+
if (_this2._ended || _this2._paused) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (now >= nextRenderTime) {
|
|
604
|
+
while (now - nextRenderTime >= _this2._apng.playTime / _this2.playbackRate) {
|
|
605
|
+
nextRenderTime += _this2._apng.playTime / _this2.playbackRate;
|
|
606
|
+
_this2._numPlays++;
|
|
607
|
+
}
|
|
608
|
+
do {
|
|
609
|
+
_this2.renderNextFrame();
|
|
610
|
+
nextRenderTime += _this2.currentFrame.delay / _this2.playbackRate;
|
|
611
|
+
} while (!_this2._ended && !_this2._paused && now > nextRenderTime);
|
|
612
|
+
}
|
|
613
|
+
_this2._rafId = requestAnimationFrame(tick);
|
|
614
|
+
};
|
|
615
|
+
this._rafId = requestAnimationFrame(tick);
|
|
616
|
+
}
|
|
617
|
+
}, {
|
|
618
|
+
key: 'pause',
|
|
619
|
+
value: function pause() {
|
|
620
|
+
if (!this._paused) {
|
|
621
|
+
if (this._rafId) {
|
|
622
|
+
cancelAnimationFrame(this._rafId);
|
|
623
|
+
this._rafId = null;
|
|
624
|
+
}
|
|
625
|
+
this.emit('pause');
|
|
626
|
+
this._paused = true;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}, {
|
|
630
|
+
key: 'stop',
|
|
631
|
+
value: function stop() {
|
|
632
|
+
if (this._rafId) {
|
|
633
|
+
cancelAnimationFrame(this._rafId);
|
|
634
|
+
this._rafId = null;
|
|
635
|
+
}
|
|
636
|
+
this.emit('stop');
|
|
637
|
+
this._numPlays = 0;
|
|
638
|
+
this._ended = false;
|
|
639
|
+
this._paused = true;
|
|
640
|
+
// render first frame
|
|
641
|
+
this._currentFrameNumber = -1;
|
|
642
|
+
this.context.clearRect(0, 0, this._apng.width, this._apng.height);
|
|
643
|
+
this.renderNextFrame();
|
|
644
|
+
}
|
|
645
|
+
}, {
|
|
646
|
+
key: 'currentFrameNumber',
|
|
647
|
+
get: function get() {
|
|
648
|
+
return this._currentFrameNumber;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
*
|
|
653
|
+
* @return {Frame}
|
|
654
|
+
*/
|
|
655
|
+
|
|
656
|
+
}, {
|
|
657
|
+
key: 'currentFrame',
|
|
658
|
+
get: function get() {
|
|
659
|
+
return this._apng.frames[this._currentFrameNumber];
|
|
660
|
+
}
|
|
661
|
+
}, {
|
|
662
|
+
key: 'paused',
|
|
663
|
+
get: function get() {
|
|
664
|
+
return this._paused;
|
|
665
|
+
}
|
|
666
|
+
}, {
|
|
667
|
+
key: 'ended',
|
|
668
|
+
get: function get() {
|
|
669
|
+
return this._ended;
|
|
670
|
+
}
|
|
671
|
+
}]);
|
|
672
|
+
|
|
673
|
+
return _class;
|
|
674
|
+
}(_events2.default);
|
|
675
|
+
|
|
676
|
+
exports.default = _class;
|
|
677
|
+
|
|
678
|
+
/***/ }),
|
|
679
|
+
/* 4 */
|
|
680
|
+
/***/ (function(module, exports) {
|
|
681
|
+
|
|
682
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
683
|
+
//
|
|
684
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
685
|
+
// copy of this software and associated documentation files (the
|
|
686
|
+
// "Software"), to deal in the Software without restriction, including
|
|
687
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
688
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
689
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
690
|
+
// following conditions:
|
|
691
|
+
//
|
|
692
|
+
// The above copyright notice and this permission notice shall be included
|
|
693
|
+
// in all copies or substantial portions of the Software.
|
|
694
|
+
//
|
|
695
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
696
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
697
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
698
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
699
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
700
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
701
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
702
|
+
|
|
703
|
+
function EventEmitter() {
|
|
704
|
+
this._events = this._events || {};
|
|
705
|
+
this._maxListeners = this._maxListeners || undefined;
|
|
706
|
+
}
|
|
707
|
+
module.exports = EventEmitter;
|
|
708
|
+
|
|
709
|
+
// Backwards-compat with node 0.10.x
|
|
710
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
711
|
+
|
|
712
|
+
EventEmitter.prototype._events = undefined;
|
|
713
|
+
EventEmitter.prototype._maxListeners = undefined;
|
|
714
|
+
|
|
715
|
+
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
716
|
+
// added to it. This is a useful default which helps finding memory leaks.
|
|
717
|
+
EventEmitter.defaultMaxListeners = 10;
|
|
718
|
+
|
|
719
|
+
// Obviously not all Emitters should be limited to 10. This function allows
|
|
720
|
+
// that to be increased. Set to zero for unlimited.
|
|
721
|
+
EventEmitter.prototype.setMaxListeners = function(n) {
|
|
722
|
+
if (!isNumber(n) || n < 0 || isNaN(n))
|
|
723
|
+
throw TypeError('n must be a positive number');
|
|
724
|
+
this._maxListeners = n;
|
|
725
|
+
return this;
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
EventEmitter.prototype.emit = function(type) {
|
|
729
|
+
var er, handler, len, args, i, listeners;
|
|
730
|
+
|
|
731
|
+
if (!this._events)
|
|
732
|
+
this._events = {};
|
|
733
|
+
|
|
734
|
+
// If there is no 'error' event listener then throw.
|
|
735
|
+
if (type === 'error') {
|
|
736
|
+
if (!this._events.error ||
|
|
737
|
+
(isObject(this._events.error) && !this._events.error.length)) {
|
|
738
|
+
er = arguments[1];
|
|
739
|
+
if (er instanceof Error) {
|
|
740
|
+
throw er; // Unhandled 'error' event
|
|
741
|
+
} else {
|
|
742
|
+
// At least give some kind of context to the user
|
|
743
|
+
var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
|
|
744
|
+
err.context = er;
|
|
745
|
+
throw err;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
handler = this._events[type];
|
|
751
|
+
|
|
752
|
+
if (isUndefined(handler))
|
|
753
|
+
return false;
|
|
754
|
+
|
|
755
|
+
if (isFunction(handler)) {
|
|
756
|
+
switch (arguments.length) {
|
|
757
|
+
// fast cases
|
|
758
|
+
case 1:
|
|
759
|
+
handler.call(this);
|
|
760
|
+
break;
|
|
761
|
+
case 2:
|
|
762
|
+
handler.call(this, arguments[1]);
|
|
763
|
+
break;
|
|
764
|
+
case 3:
|
|
765
|
+
handler.call(this, arguments[1], arguments[2]);
|
|
766
|
+
break;
|
|
767
|
+
// slower
|
|
768
|
+
default:
|
|
769
|
+
args = Array.prototype.slice.call(arguments, 1);
|
|
770
|
+
handler.apply(this, args);
|
|
771
|
+
}
|
|
772
|
+
} else if (isObject(handler)) {
|
|
773
|
+
args = Array.prototype.slice.call(arguments, 1);
|
|
774
|
+
listeners = handler.slice();
|
|
775
|
+
len = listeners.length;
|
|
776
|
+
for (i = 0; i < len; i++)
|
|
777
|
+
listeners[i].apply(this, args);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
return true;
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
EventEmitter.prototype.addListener = function(type, listener) {
|
|
784
|
+
var m;
|
|
785
|
+
|
|
786
|
+
if (!isFunction(listener))
|
|
787
|
+
throw TypeError('listener must be a function');
|
|
788
|
+
|
|
789
|
+
if (!this._events)
|
|
790
|
+
this._events = {};
|
|
791
|
+
|
|
792
|
+
// To avoid recursion in the case that type === "newListener"! Before
|
|
793
|
+
// adding it to the listeners, first emit "newListener".
|
|
794
|
+
if (this._events.newListener)
|
|
795
|
+
this.emit('newListener', type,
|
|
796
|
+
isFunction(listener.listener) ?
|
|
797
|
+
listener.listener : listener);
|
|
798
|
+
|
|
799
|
+
if (!this._events[type])
|
|
800
|
+
// Optimize the case of one listener. Don't need the extra array object.
|
|
801
|
+
this._events[type] = listener;
|
|
802
|
+
else if (isObject(this._events[type]))
|
|
803
|
+
// If we've already got an array, just append.
|
|
804
|
+
this._events[type].push(listener);
|
|
805
|
+
else
|
|
806
|
+
// Adding the second element, need to change to array.
|
|
807
|
+
this._events[type] = [this._events[type], listener];
|
|
808
|
+
|
|
809
|
+
// Check for listener leak
|
|
810
|
+
if (isObject(this._events[type]) && !this._events[type].warned) {
|
|
811
|
+
if (!isUndefined(this._maxListeners)) {
|
|
812
|
+
m = this._maxListeners;
|
|
813
|
+
} else {
|
|
814
|
+
m = EventEmitter.defaultMaxListeners;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if (m && m > 0 && this._events[type].length > m) {
|
|
818
|
+
this._events[type].warned = true;
|
|
819
|
+
console.error('(node) warning: possible EventEmitter memory ' +
|
|
820
|
+
'leak detected. %d listeners added. ' +
|
|
821
|
+
'Use emitter.setMaxListeners() to increase limit.',
|
|
822
|
+
this._events[type].length);
|
|
823
|
+
if (typeof console.trace === 'function') {
|
|
824
|
+
// not supported in IE 10
|
|
825
|
+
console.trace();
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
return this;
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
834
|
+
|
|
835
|
+
EventEmitter.prototype.once = function(type, listener) {
|
|
836
|
+
if (!isFunction(listener))
|
|
837
|
+
throw TypeError('listener must be a function');
|
|
838
|
+
|
|
839
|
+
var fired = false;
|
|
840
|
+
|
|
841
|
+
function g() {
|
|
842
|
+
this.removeListener(type, g);
|
|
843
|
+
|
|
844
|
+
if (!fired) {
|
|
845
|
+
fired = true;
|
|
846
|
+
listener.apply(this, arguments);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
g.listener = listener;
|
|
851
|
+
this.on(type, g);
|
|
852
|
+
|
|
853
|
+
return this;
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
// emits a 'removeListener' event iff the listener was removed
|
|
857
|
+
EventEmitter.prototype.removeListener = function(type, listener) {
|
|
858
|
+
var list, position, length, i;
|
|
859
|
+
|
|
860
|
+
if (!isFunction(listener))
|
|
861
|
+
throw TypeError('listener must be a function');
|
|
862
|
+
|
|
863
|
+
if (!this._events || !this._events[type])
|
|
864
|
+
return this;
|
|
865
|
+
|
|
866
|
+
list = this._events[type];
|
|
867
|
+
length = list.length;
|
|
868
|
+
position = -1;
|
|
869
|
+
|
|
870
|
+
if (list === listener ||
|
|
871
|
+
(isFunction(list.listener) && list.listener === listener)) {
|
|
872
|
+
delete this._events[type];
|
|
873
|
+
if (this._events.removeListener)
|
|
874
|
+
this.emit('removeListener', type, listener);
|
|
875
|
+
|
|
876
|
+
} else if (isObject(list)) {
|
|
877
|
+
for (i = length; i-- > 0;) {
|
|
878
|
+
if (list[i] === listener ||
|
|
879
|
+
(list[i].listener && list[i].listener === listener)) {
|
|
880
|
+
position = i;
|
|
881
|
+
break;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
if (position < 0)
|
|
886
|
+
return this;
|
|
887
|
+
|
|
888
|
+
if (list.length === 1) {
|
|
889
|
+
list.length = 0;
|
|
890
|
+
delete this._events[type];
|
|
891
|
+
} else {
|
|
892
|
+
list.splice(position, 1);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
if (this._events.removeListener)
|
|
896
|
+
this.emit('removeListener', type, listener);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
return this;
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
EventEmitter.prototype.removeAllListeners = function(type) {
|
|
903
|
+
var key, listeners;
|
|
904
|
+
|
|
905
|
+
if (!this._events)
|
|
906
|
+
return this;
|
|
907
|
+
|
|
908
|
+
// not listening for removeListener, no need to emit
|
|
909
|
+
if (!this._events.removeListener) {
|
|
910
|
+
if (arguments.length === 0)
|
|
911
|
+
this._events = {};
|
|
912
|
+
else if (this._events[type])
|
|
913
|
+
delete this._events[type];
|
|
914
|
+
return this;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// emit removeListener for all listeners on all events
|
|
918
|
+
if (arguments.length === 0) {
|
|
919
|
+
for (key in this._events) {
|
|
920
|
+
if (key === 'removeListener') continue;
|
|
921
|
+
this.removeAllListeners(key);
|
|
922
|
+
}
|
|
923
|
+
this.removeAllListeners('removeListener');
|
|
924
|
+
this._events = {};
|
|
925
|
+
return this;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
listeners = this._events[type];
|
|
929
|
+
|
|
930
|
+
if (isFunction(listeners)) {
|
|
931
|
+
this.removeListener(type, listeners);
|
|
932
|
+
} else if (listeners) {
|
|
933
|
+
// LIFO order
|
|
934
|
+
while (listeners.length)
|
|
935
|
+
this.removeListener(type, listeners[listeners.length - 1]);
|
|
936
|
+
}
|
|
937
|
+
delete this._events[type];
|
|
938
|
+
|
|
939
|
+
return this;
|
|
940
|
+
};
|
|
941
|
+
|
|
942
|
+
EventEmitter.prototype.listeners = function(type) {
|
|
943
|
+
var ret;
|
|
944
|
+
if (!this._events || !this._events[type])
|
|
945
|
+
ret = [];
|
|
946
|
+
else if (isFunction(this._events[type]))
|
|
947
|
+
ret = [this._events[type]];
|
|
948
|
+
else
|
|
949
|
+
ret = this._events[type].slice();
|
|
950
|
+
return ret;
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
EventEmitter.prototype.listenerCount = function(type) {
|
|
954
|
+
if (this._events) {
|
|
955
|
+
var evlistener = this._events[type];
|
|
956
|
+
|
|
957
|
+
if (isFunction(evlistener))
|
|
958
|
+
return 1;
|
|
959
|
+
else if (evlistener)
|
|
960
|
+
return evlistener.length;
|
|
961
|
+
}
|
|
962
|
+
return 0;
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
EventEmitter.listenerCount = function(emitter, type) {
|
|
966
|
+
return emitter.listenerCount(type);
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
function isFunction(arg) {
|
|
970
|
+
return typeof arg === 'function';
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
function isNumber(arg) {
|
|
974
|
+
return typeof arg === 'number';
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
function isObject(arg) {
|
|
978
|
+
return typeof arg === 'object' && arg !== null;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
function isUndefined(arg) {
|
|
982
|
+
return arg === void 0;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
/***/ })
|
|
987
|
+
/******/ ])
|
|
988
|
+
});
|
|
989
|
+
} (lib));
|
|
990
|
+
|
|
991
|
+
var libExports = lib.exports;
|
|
992
|
+
var parseAPNG = /*@__PURE__*/getDefaultExportFromCjs(libExports);
|
|
993
|
+
|
|
7
994
|
var ExtensionType = /* @__PURE__ */ ((ExtensionType2) => {
|
|
8
995
|
ExtensionType2["Application"] = "application";
|
|
9
996
|
ExtensionType2["WebGLPipes"] = "webgl-pipes";
|
|
@@ -20996,6 +21983,10 @@ extensions.handle(ExtensionType.Asset, (extension) => {
|
|
|
20996
21983
|
extensions.add(browserExt, webworkerExt);
|
|
20997
21984
|
|
|
20998
21985
|
const props = {
|
|
21986
|
+
url: {
|
|
21987
|
+
type: String,
|
|
21988
|
+
requierd: false
|
|
21989
|
+
},
|
|
20999
21990
|
data: {
|
|
21000
21991
|
type: Array,
|
|
21001
21992
|
default: () => []
|
|
@@ -21017,6 +22008,21 @@ const props = {
|
|
|
21017
22008
|
frameRate: {
|
|
21018
22009
|
type: Number,
|
|
21019
22010
|
default: 24
|
|
22011
|
+
},
|
|
22012
|
+
label: {
|
|
22013
|
+
type: String,
|
|
22014
|
+
default: ""
|
|
22015
|
+
},
|
|
22016
|
+
resize: {
|
|
22017
|
+
type: Function,
|
|
22018
|
+
default: void 0
|
|
22019
|
+
},
|
|
22020
|
+
/**
|
|
22021
|
+
* @description 是否在有资源时预渲染第一帧
|
|
22022
|
+
*/
|
|
22023
|
+
prerender: {
|
|
22024
|
+
type: Boolean,
|
|
22025
|
+
default: false
|
|
21020
22026
|
}
|
|
21021
22027
|
};
|
|
21022
22028
|
const emits = {
|
|
@@ -21047,67 +22053,315 @@ function usePixiApp() {
|
|
|
21047
22053
|
return core;
|
|
21048
22054
|
}
|
|
21049
22055
|
|
|
21050
|
-
|
|
21051
|
-
|
|
21052
|
-
props
|
|
22056
|
+
function useSprite(props) {
|
|
22057
|
+
const autoResize = props.autoResize ?? true;
|
|
22058
|
+
const resize = props.resize ?? defaultResize;
|
|
22059
|
+
const { application: app, context } = usePixiApp();
|
|
22060
|
+
const sprite = new Sprite();
|
|
22061
|
+
app.stage.addChild(sprite);
|
|
22062
|
+
watchEffect(() => {
|
|
22063
|
+
props.label && (sprite.label = props.label);
|
|
22064
|
+
});
|
|
22065
|
+
autoResize && context.when().then((app2) => {
|
|
22066
|
+
if (sprite.texture) {
|
|
22067
|
+
resizeSprite();
|
|
22068
|
+
app2.renderer.on("resize", resizeSprite);
|
|
22069
|
+
}
|
|
22070
|
+
});
|
|
22071
|
+
function resizeSprite() {
|
|
22072
|
+
if (!app.renderer?.screen)
|
|
22073
|
+
return;
|
|
22074
|
+
const meta = sprite.texture._meta;
|
|
22075
|
+
resize({
|
|
22076
|
+
application: app,
|
|
22077
|
+
sprite,
|
|
22078
|
+
meta
|
|
22079
|
+
});
|
|
22080
|
+
}
|
|
22081
|
+
onBeforeUnmount(() => {
|
|
22082
|
+
app.renderer.off("resize", resizeSprite);
|
|
22083
|
+
app.stage.removeChild(sprite);
|
|
22084
|
+
});
|
|
22085
|
+
function defaultResize() {
|
|
22086
|
+
const scaleX = app.screen.width / sprite.texture.width;
|
|
22087
|
+
const scaleY = app.screen.height / sprite.texture.height;
|
|
22088
|
+
const scale = Math.min(scaleX, scaleY);
|
|
22089
|
+
sprite.scale.set(scale);
|
|
22090
|
+
sprite.x = (app.screen.width - sprite.width) / 2;
|
|
22091
|
+
sprite.y = (app.screen.height - sprite.height) / 2;
|
|
22092
|
+
}
|
|
22093
|
+
return {
|
|
22094
|
+
sprite,
|
|
22095
|
+
resizeSprite,
|
|
22096
|
+
application: app
|
|
22097
|
+
};
|
|
22098
|
+
}
|
|
22099
|
+
|
|
22100
|
+
var _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
22101
|
+
__name: "apng",
|
|
22102
|
+
props: {
|
|
22103
|
+
...props,
|
|
22104
|
+
url: {
|
|
22105
|
+
type: String,
|
|
22106
|
+
required: true
|
|
22107
|
+
}
|
|
22108
|
+
},
|
|
21053
22109
|
emits,
|
|
21054
22110
|
setup(__props, { emit: __emit }) {
|
|
21055
22111
|
const props = __props;
|
|
21056
22112
|
const emit = __emit;
|
|
21057
|
-
const { application: app, context } = usePixiApp();
|
|
21058
22113
|
const compId = useId();
|
|
21059
|
-
const getAlias = (
|
|
21060
|
-
const sprite =
|
|
21061
|
-
|
|
21062
|
-
|
|
21063
|
-
|
|
21064
|
-
|
|
21065
|
-
|
|
21066
|
-
|
|
21067
|
-
|
|
22114
|
+
const getAlias = (frameIndex) => `${compId}-apng-frame-${frameIndex}`;
|
|
22115
|
+
const { sprite, resizeSprite } = useSprite(props);
|
|
22116
|
+
const frames = ref([]);
|
|
22117
|
+
const index = ref(0);
|
|
22118
|
+
const isLoaded = ref(false);
|
|
22119
|
+
const error = ref("");
|
|
22120
|
+
const textureMap = /* @__PURE__ */ new Map();
|
|
22121
|
+
let timer = null;
|
|
22122
|
+
let reusableCanvas = null;
|
|
22123
|
+
let reusableCtx = null;
|
|
22124
|
+
onMounted(() => loadAPNG(props.url));
|
|
22125
|
+
function getReusableCanvas(width, height) {
|
|
22126
|
+
if (!reusableCanvas) {
|
|
22127
|
+
reusableCanvas = document.createElement("canvas");
|
|
22128
|
+
reusableCtx = reusableCanvas.getContext("2d", {
|
|
22129
|
+
willReadFrequently: true
|
|
22130
|
+
});
|
|
22131
|
+
}
|
|
22132
|
+
if (reusableCanvas.width !== width || reusableCanvas.height !== height) {
|
|
22133
|
+
reusableCanvas.width = width;
|
|
22134
|
+
reusableCanvas.height = height;
|
|
22135
|
+
}
|
|
22136
|
+
return { canvas: reusableCanvas, ctx: reusableCtx };
|
|
22137
|
+
}
|
|
22138
|
+
async function loadAPNG(url) {
|
|
22139
|
+
try {
|
|
22140
|
+
error.value = "";
|
|
22141
|
+
isLoaded.value = false;
|
|
22142
|
+
await cleanup();
|
|
22143
|
+
const response = await fetch(url);
|
|
22144
|
+
if (!response.ok) {
|
|
22145
|
+
throw new Error(`\u52A0\u8F7DAPNG\u5931\u8D25: ${response.status}`);
|
|
22146
|
+
}
|
|
22147
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
22148
|
+
const apng = parseAPNG(arrayBuffer);
|
|
22149
|
+
if (apng instanceof Error) {
|
|
22150
|
+
throw new TypeError(`APNG\u89E3\u6790\u5931\u8D25: ${apng.message}`);
|
|
22151
|
+
}
|
|
22152
|
+
const { canvas, ctx } = getReusableCanvas(apng.width, apng.height);
|
|
22153
|
+
const framePromises = apng.frames.map(async (frame, frameIndex) => {
|
|
22154
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
22155
|
+
await frame.createImage();
|
|
22156
|
+
const img = frame.imageElement;
|
|
22157
|
+
ctx.drawImage(img, frame.left, frame.top);
|
|
22158
|
+
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
22159
|
+
const alias = getAlias(frameIndex);
|
|
22160
|
+
textureMap.set(alias, void 0);
|
|
22161
|
+
ctx.putImageData(imageData, 0, 0);
|
|
22162
|
+
const dataUrl = canvas.toDataURL();
|
|
22163
|
+
Assets.add({ alias, src: dataUrl });
|
|
22164
|
+
const texture = await Assets.load(alias);
|
|
22165
|
+
textureMap.set(alias, texture);
|
|
22166
|
+
if (frameIndex === 0) {
|
|
22167
|
+
sprite.texture = texture;
|
|
21068
22168
|
resizeSprite();
|
|
21069
22169
|
}
|
|
22170
|
+
return alias;
|
|
22171
|
+
});
|
|
22172
|
+
frames.value = await Promise.all(framePromises);
|
|
22173
|
+
isLoaded.value = true;
|
|
22174
|
+
} catch (err) {
|
|
22175
|
+
console.error("\u52A0\u8F7DAPNG\u5931\u8D25:", err);
|
|
22176
|
+
error.value = err instanceof Error ? err.message : "\u52A0\u8F7DAPNG\u5931\u8D25";
|
|
22177
|
+
emit("update:status", TickerStatus.stopped);
|
|
22178
|
+
}
|
|
22179
|
+
}
|
|
22180
|
+
function startFrameLoop() {
|
|
22181
|
+
if (timer !== null)
|
|
22182
|
+
return;
|
|
22183
|
+
timer = window.setInterval(() => {
|
|
22184
|
+
if (frames.value.length === 0 || props.status !== TickerStatus.playing) {
|
|
22185
|
+
return;
|
|
22186
|
+
}
|
|
22187
|
+
const currentTexture = textureMap.get(
|
|
22188
|
+
getAlias(index.value)
|
|
21070
22189
|
);
|
|
22190
|
+
if (currentTexture) {
|
|
22191
|
+
const originIndex = index.value - 1;
|
|
22192
|
+
if (originIndex >= 0 && !props.loop) {
|
|
22193
|
+
Promise.resolve().then(() => sleep(500)).then(() => {
|
|
22194
|
+
Assets.unload(getAlias(originIndex));
|
|
22195
|
+
textureMap.delete(getAlias(originIndex));
|
|
22196
|
+
});
|
|
22197
|
+
}
|
|
22198
|
+
sprite.texture = currentTexture;
|
|
22199
|
+
resizeSprite();
|
|
22200
|
+
index.value = props.loop ? (index.value + 1) % frames.value.length : index.value + 1;
|
|
22201
|
+
} else {
|
|
22202
|
+
if (!props.loop)
|
|
22203
|
+
emit("update:status", TickerStatus.paused);
|
|
22204
|
+
}
|
|
22205
|
+
}, 1e3 / props.frameRate);
|
|
22206
|
+
}
|
|
22207
|
+
function play() {
|
|
22208
|
+
if (!isLoaded.value || frames.value.length <= 1) {
|
|
22209
|
+
return;
|
|
22210
|
+
}
|
|
22211
|
+
emit("update:status", TickerStatus.playing);
|
|
22212
|
+
startFrameLoop();
|
|
22213
|
+
}
|
|
22214
|
+
function pause() {
|
|
22215
|
+
if (timer !== null) {
|
|
22216
|
+
clearInterval(timer);
|
|
22217
|
+
timer = null;
|
|
22218
|
+
}
|
|
22219
|
+
emit("update:status", TickerStatus.paused);
|
|
22220
|
+
}
|
|
22221
|
+
function stop() {
|
|
22222
|
+
if (timer !== null) {
|
|
22223
|
+
clearInterval(timer);
|
|
22224
|
+
timer = null;
|
|
22225
|
+
}
|
|
22226
|
+
index.value = 0;
|
|
22227
|
+
const firstTexture = textureMap.get(getAlias(0));
|
|
22228
|
+
if (firstTexture) {
|
|
22229
|
+
sprite.texture = firstTexture;
|
|
22230
|
+
resizeSprite();
|
|
22231
|
+
}
|
|
22232
|
+
emit("update:status", TickerStatus.stopped);
|
|
22233
|
+
}
|
|
22234
|
+
async function cleanup() {
|
|
22235
|
+
if (timer !== null) {
|
|
22236
|
+
clearInterval(timer);
|
|
22237
|
+
timer = null;
|
|
22238
|
+
}
|
|
22239
|
+
const unloadPromises = [];
|
|
22240
|
+
for (const [alias, texture] of textureMap) {
|
|
22241
|
+
if (texture && texture !== Texture.EMPTY) {
|
|
22242
|
+
unloadPromises.push(Assets.unload(alias));
|
|
22243
|
+
}
|
|
22244
|
+
}
|
|
22245
|
+
await Promise.all(unloadPromises);
|
|
22246
|
+
textureMap.clear();
|
|
22247
|
+
frames.value = [];
|
|
22248
|
+
index.value = 0;
|
|
22249
|
+
isLoaded.value = false;
|
|
22250
|
+
error.value = "";
|
|
22251
|
+
if (reusableCanvas) {
|
|
22252
|
+
reusableCanvas.width = 0;
|
|
22253
|
+
reusableCanvas.height = 0;
|
|
22254
|
+
}
|
|
22255
|
+
}
|
|
22256
|
+
watchEffect(() => {
|
|
22257
|
+
switch (props.status) {
|
|
22258
|
+
case TickerStatus.play:
|
|
22259
|
+
play();
|
|
22260
|
+
break;
|
|
22261
|
+
case TickerStatus.pause:
|
|
22262
|
+
pause();
|
|
22263
|
+
break;
|
|
22264
|
+
case TickerStatus.stop:
|
|
22265
|
+
stop();
|
|
22266
|
+
break;
|
|
21071
22267
|
}
|
|
21072
22268
|
});
|
|
21073
|
-
|
|
21074
|
-
|
|
21075
|
-
|
|
21076
|
-
|
|
21077
|
-
|
|
21078
|
-
|
|
21079
|
-
|
|
21080
|
-
|
|
21081
|
-
|
|
22269
|
+
onBeforeUnmount(async () => {
|
|
22270
|
+
await cleanup();
|
|
22271
|
+
reusableCanvas = null;
|
|
22272
|
+
reusableCtx = null;
|
|
22273
|
+
});
|
|
22274
|
+
return (_ctx, _cache) => {
|
|
22275
|
+
return renderSlot(_ctx.$slots, "default");
|
|
22276
|
+
};
|
|
22277
|
+
}
|
|
22278
|
+
});
|
|
22279
|
+
|
|
22280
|
+
var _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
22281
|
+
__name: "core",
|
|
22282
|
+
props: {
|
|
22283
|
+
...props,
|
|
22284
|
+
data: {
|
|
22285
|
+
type: void 0,
|
|
22286
|
+
required: true
|
|
22287
|
+
},
|
|
22288
|
+
frameIndex: {
|
|
22289
|
+
type: Number,
|
|
22290
|
+
default: 0
|
|
21082
22291
|
}
|
|
22292
|
+
},
|
|
22293
|
+
emits: {
|
|
22294
|
+
...emits,
|
|
22295
|
+
"load": (e) => e,
|
|
22296
|
+
"update:frameIndex": null,
|
|
22297
|
+
"notFound": (_index) => true
|
|
22298
|
+
},
|
|
22299
|
+
setup(__props, { emit: __emit }) {
|
|
22300
|
+
const props = __props;
|
|
22301
|
+
const emit = __emit;
|
|
22302
|
+
const compId = useId();
|
|
22303
|
+
const getAlias = (key) => `${compId}-${key}`;
|
|
22304
|
+
const { sprite, resizeSprite, application } = useSprite(props);
|
|
21083
22305
|
const textureMap = /* @__PURE__ */ new Map();
|
|
22306
|
+
const completedIndex = ref(0);
|
|
22307
|
+
const enabledData = computed(() => {
|
|
22308
|
+
return props.data.slice(completedIndex.value);
|
|
22309
|
+
});
|
|
21084
22310
|
watchEffect(() => {
|
|
21085
|
-
for (const key in
|
|
21086
|
-
const
|
|
21087
|
-
const
|
|
22311
|
+
for (const key in enabledData.value) {
|
|
22312
|
+
const theKey = +key + completedIndex.value;
|
|
22313
|
+
const alias = `${compId}-${theKey}`;
|
|
22314
|
+
const src = typeof enabledData.value[key] === "string" ? enabledData.value[key] : enabledData.value[key]?.src;
|
|
22315
|
+
if (!src) {
|
|
22316
|
+
continue;
|
|
22317
|
+
}
|
|
21088
22318
|
if (textureMap.has(alias)) {
|
|
21089
22319
|
continue;
|
|
21090
22320
|
}
|
|
21091
22321
|
Assets.add({
|
|
21092
22322
|
alias,
|
|
21093
|
-
src
|
|
22323
|
+
src
|
|
21094
22324
|
});
|
|
21095
22325
|
textureMap.set(alias, void 0);
|
|
21096
22326
|
Assets.load(alias).then((res) => {
|
|
22327
|
+
res._meta = enabledData.value[key];
|
|
21097
22328
|
textureMap.set(alias, res);
|
|
21098
|
-
if (
|
|
22329
|
+
if (props.prerender && theKey === 0) {
|
|
21099
22330
|
sprite.texture = res;
|
|
21100
22331
|
resizeSprite();
|
|
21101
22332
|
}
|
|
21102
22333
|
});
|
|
21103
22334
|
}
|
|
21104
22335
|
});
|
|
21105
|
-
|
|
21106
|
-
|
|
22336
|
+
emit("load", {
|
|
22337
|
+
application,
|
|
22338
|
+
sprite
|
|
22339
|
+
});
|
|
22340
|
+
const index = useModelComputed({
|
|
22341
|
+
default: 0,
|
|
22342
|
+
key: "frameIndex"
|
|
22343
|
+
}, props, emit);
|
|
22344
|
+
let animationId = null;
|
|
22345
|
+
let lastFrameTime = 0;
|
|
21107
22346
|
function startFrameLoop() {
|
|
21108
|
-
if (
|
|
22347
|
+
if (animationId !== null)
|
|
21109
22348
|
return;
|
|
21110
|
-
|
|
22349
|
+
lastFrameTime = performance.now();
|
|
22350
|
+
function renderFrame() {
|
|
22351
|
+
const now = performance.now();
|
|
22352
|
+
const frameDuration = 1e3 / props.frameRate;
|
|
22353
|
+
const delta = now - lastFrameTime;
|
|
22354
|
+
if (delta >= frameDuration) {
|
|
22355
|
+
lastFrameTime = now - delta % frameDuration;
|
|
22356
|
+
drawFrame();
|
|
22357
|
+
}
|
|
22358
|
+
if (props.status === TickerStatus.playing) {
|
|
22359
|
+
animationId = requestAnimationFrame(renderFrame);
|
|
22360
|
+
} else {
|
|
22361
|
+
animationId = null;
|
|
22362
|
+
}
|
|
22363
|
+
}
|
|
22364
|
+
function drawFrame() {
|
|
21111
22365
|
if (props.data.length === 0 || props.status !== TickerStatus.playing) {
|
|
21112
22366
|
return;
|
|
21113
22367
|
}
|
|
@@ -21129,17 +22383,29 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
21129
22383
|
k: originIndex,
|
|
21130
22384
|
v: ""
|
|
21131
22385
|
});
|
|
22386
|
+
completedIndex.value = originIndex;
|
|
21132
22387
|
});
|
|
21133
22388
|
}
|
|
21134
22389
|
sprite.texture = currentTexture;
|
|
21135
22390
|
resizeSprite();
|
|
21136
22391
|
index.value = props.loop ? (index.value + 1) % props.data.length : index.value + 1;
|
|
21137
22392
|
} else {
|
|
22393
|
+
console.warn(
|
|
22394
|
+
`Texture for index ${index.value} not found. Ensure the texture is loaded.`
|
|
22395
|
+
);
|
|
22396
|
+
emit("notFound", index.value);
|
|
21138
22397
|
if (!props.loop)
|
|
21139
22398
|
emit("update:status", TickerStatus.paused);
|
|
21140
22399
|
}
|
|
21141
|
-
}
|
|
21142
|
-
|
|
22400
|
+
}
|
|
22401
|
+
animationId = requestAnimationFrame(renderFrame);
|
|
22402
|
+
}
|
|
22403
|
+
onBeforeUnmount(stop);
|
|
22404
|
+
watch(() => props.status, (newStatus) => {
|
|
22405
|
+
newStatus === TickerStatus.play && play();
|
|
22406
|
+
newStatus === TickerStatus.pause && pause();
|
|
22407
|
+
newStatus === TickerStatus.stop && stop();
|
|
22408
|
+
}, { immediate: true });
|
|
21143
22409
|
function play() {
|
|
21144
22410
|
if (props.data.length > 0) {
|
|
21145
22411
|
emit("update:status", TickerStatus.playing);
|
|
@@ -21153,34 +22419,21 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
21153
22419
|
}
|
|
21154
22420
|
function stop() {
|
|
21155
22421
|
emit("update:status", TickerStatus.stopped);
|
|
21156
|
-
if (
|
|
21157
|
-
|
|
21158
|
-
|
|
22422
|
+
if (animationId !== null) {
|
|
22423
|
+
cancelAnimationFrame(animationId);
|
|
22424
|
+
animationId = null;
|
|
21159
22425
|
}
|
|
21160
22426
|
emit("update:data", []);
|
|
21161
22427
|
textureMap.clear();
|
|
21162
22428
|
index.value = 0;
|
|
21163
22429
|
}
|
|
21164
|
-
onBeforeUnmount(() => {
|
|
21165
|
-
stop();
|
|
21166
|
-
app.stage.removeChild(sprite);
|
|
21167
|
-
});
|
|
21168
|
-
watchEffect(() => {
|
|
21169
|
-
if (props.status === TickerStatus.play) {
|
|
21170
|
-
play();
|
|
21171
|
-
} else if (props.status === TickerStatus.pause) {
|
|
21172
|
-
pause();
|
|
21173
|
-
} else if (props.status === TickerStatus.stop) {
|
|
21174
|
-
stop();
|
|
21175
|
-
}
|
|
21176
|
-
});
|
|
21177
22430
|
return (_ctx, _cache) => {
|
|
21178
22431
|
return renderSlot(_ctx.$slots, "default");
|
|
21179
22432
|
};
|
|
21180
22433
|
}
|
|
21181
22434
|
});
|
|
21182
22435
|
|
|
21183
|
-
var _sfc_main$
|
|
22436
|
+
var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
21184
22437
|
__name: "provider",
|
|
21185
22438
|
setup(__props) {
|
|
21186
22439
|
initPixiApp();
|
|
@@ -21190,6 +22443,155 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
21190
22443
|
}
|
|
21191
22444
|
});
|
|
21192
22445
|
|
|
22446
|
+
var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
22447
|
+
__name: "video",
|
|
22448
|
+
props: {
|
|
22449
|
+
...props,
|
|
22450
|
+
url: {
|
|
22451
|
+
type: String,
|
|
22452
|
+
required: true
|
|
22453
|
+
}
|
|
22454
|
+
},
|
|
22455
|
+
emits,
|
|
22456
|
+
setup(__props, { emit: __emit }) {
|
|
22457
|
+
const props = __props;
|
|
22458
|
+
const emit = __emit;
|
|
22459
|
+
const compId = useId();
|
|
22460
|
+
const getAlias = () => `${compId}-video`;
|
|
22461
|
+
const { sprite, resizeSprite } = useSprite(props);
|
|
22462
|
+
const texture = ref();
|
|
22463
|
+
const video = computed(() => {
|
|
22464
|
+
if (texture.value?.source && texture.value.source.resource) {
|
|
22465
|
+
const resource = texture.value.source.resource;
|
|
22466
|
+
if (resource instanceof HTMLVideoElement) {
|
|
22467
|
+
return resource;
|
|
22468
|
+
}
|
|
22469
|
+
}
|
|
22470
|
+
return null;
|
|
22471
|
+
});
|
|
22472
|
+
const readyDef = useDeferred();
|
|
22473
|
+
const videoError = ref("");
|
|
22474
|
+
readyDef.promise.then(() => {
|
|
22475
|
+
if (props.status === TickerStatus.play) {
|
|
22476
|
+
play();
|
|
22477
|
+
}
|
|
22478
|
+
});
|
|
22479
|
+
watchEffect(() => {
|
|
22480
|
+
video.value && (video.value.loop = props.loop);
|
|
22481
|
+
});
|
|
22482
|
+
onMounted(() => loadVideoTexture(props.url));
|
|
22483
|
+
async function loadVideoTexture(url) {
|
|
22484
|
+
try {
|
|
22485
|
+
videoError.value = "";
|
|
22486
|
+
const alias = getAlias();
|
|
22487
|
+
if (Assets.cache.has(alias)) {
|
|
22488
|
+
await Assets.unload(alias);
|
|
22489
|
+
}
|
|
22490
|
+
Assets.add({ alias, src: url });
|
|
22491
|
+
const videoTexture = await Assets.load(alias);
|
|
22492
|
+
texture.value = videoTexture;
|
|
22493
|
+
sprite.texture = videoTexture;
|
|
22494
|
+
if (video.value) {
|
|
22495
|
+
video.value.loop = props.loop;
|
|
22496
|
+
video.value.muted = true;
|
|
22497
|
+
video.value.crossOrigin = "anonymous";
|
|
22498
|
+
setupVideoEvents(video.value);
|
|
22499
|
+
readyDef.resolve();
|
|
22500
|
+
}
|
|
22501
|
+
resizeSprite();
|
|
22502
|
+
return videoTexture;
|
|
22503
|
+
} catch (error) {
|
|
22504
|
+
console.error("\u52A0\u8F7D\u89C6\u9891\u7EB9\u7406\u5931\u8D25:", error);
|
|
22505
|
+
videoError.value = "\u89C6\u9891\u52A0\u8F7D\u5931\u8D25";
|
|
22506
|
+
return null;
|
|
22507
|
+
}
|
|
22508
|
+
}
|
|
22509
|
+
function setupVideoEvents(video2) {
|
|
22510
|
+
video2.addEventListener("play", () => {
|
|
22511
|
+
if (props.status !== TickerStatus.playing) {
|
|
22512
|
+
emit("update:status", TickerStatus.playing);
|
|
22513
|
+
}
|
|
22514
|
+
});
|
|
22515
|
+
video2.addEventListener("pause", () => {
|
|
22516
|
+
if (props.status !== TickerStatus.paused) {
|
|
22517
|
+
emit("update:status", TickerStatus.paused);
|
|
22518
|
+
}
|
|
22519
|
+
});
|
|
22520
|
+
video2.addEventListener("ended", () => {
|
|
22521
|
+
if (props.loop) {
|
|
22522
|
+
video2.currentTime = 0;
|
|
22523
|
+
video2.play();
|
|
22524
|
+
} else {
|
|
22525
|
+
emit("update:status", TickerStatus.stopped);
|
|
22526
|
+
}
|
|
22527
|
+
});
|
|
22528
|
+
video2.addEventListener("error", (e) => {
|
|
22529
|
+
const error = video2.error;
|
|
22530
|
+
let errorMessage = "\u89C6\u9891\u64AD\u653E\u5931\u8D25";
|
|
22531
|
+
if (error) {
|
|
22532
|
+
switch (error.code) {
|
|
22533
|
+
case error.MEDIA_ERR_ABORTED:
|
|
22534
|
+
errorMessage = "\u89C6\u9891\u64AD\u653E\u88AB\u4E2D\u6B62";
|
|
22535
|
+
break;
|
|
22536
|
+
case error.MEDIA_ERR_NETWORK:
|
|
22537
|
+
errorMessage = "\u7F51\u7EDC\u9519\u8BEF\u5BFC\u81F4\u89C6\u9891\u64AD\u653E\u5931\u8D25";
|
|
22538
|
+
break;
|
|
22539
|
+
case error.MEDIA_ERR_DECODE:
|
|
22540
|
+
errorMessage = "\u89C6\u9891\u89E3\u7801\u5931\u8D25";
|
|
22541
|
+
break;
|
|
22542
|
+
case error.MEDIA_ERR_SRC_NOT_SUPPORTED:
|
|
22543
|
+
errorMessage = "\u4E0D\u652F\u6301\u7684\u89C6\u9891\u683C\u5F0F";
|
|
22544
|
+
break;
|
|
22545
|
+
}
|
|
22546
|
+
}
|
|
22547
|
+
console.error("\u89C6\u9891\u64AD\u653E\u9519\u8BEF:", errorMessage, e);
|
|
22548
|
+
videoError.value = errorMessage;
|
|
22549
|
+
emit("update:status", TickerStatus.stopped);
|
|
22550
|
+
});
|
|
22551
|
+
}
|
|
22552
|
+
async function cleanupVideo() {
|
|
22553
|
+
if (texture.value) {
|
|
22554
|
+
const alias = getAlias();
|
|
22555
|
+
texture.value.destroy(true);
|
|
22556
|
+
texture.value = void 0;
|
|
22557
|
+
if (Assets.cache.has(alias)) {
|
|
22558
|
+
await Assets.unload(alias);
|
|
22559
|
+
}
|
|
22560
|
+
}
|
|
22561
|
+
videoError.value = "";
|
|
22562
|
+
}
|
|
22563
|
+
watchEffect(() => {
|
|
22564
|
+
props.status === TickerStatus.play && play();
|
|
22565
|
+
props.status === TickerStatus.pause && pause();
|
|
22566
|
+
props.status === TickerStatus.stop && stop();
|
|
22567
|
+
});
|
|
22568
|
+
onBeforeUnmount(() => {
|
|
22569
|
+
cleanupVideo();
|
|
22570
|
+
});
|
|
22571
|
+
function play() {
|
|
22572
|
+
if (video.value) {
|
|
22573
|
+
video.value.play().catch((error) => {
|
|
22574
|
+
console.error("\u89C6\u9891\u64AD\u653E\u5931\u8D25:", error);
|
|
22575
|
+
videoError.value = "\u89C6\u9891\u64AD\u653E\u5931\u8D25";
|
|
22576
|
+
});
|
|
22577
|
+
}
|
|
22578
|
+
}
|
|
22579
|
+
function pause() {
|
|
22580
|
+
video.value?.pause();
|
|
22581
|
+
}
|
|
22582
|
+
function stop() {
|
|
22583
|
+
if (video.value) {
|
|
22584
|
+
video.value.pause();
|
|
22585
|
+
video.value.currentTime = 0;
|
|
22586
|
+
}
|
|
22587
|
+
emit("update:status", TickerStatus.stopped);
|
|
22588
|
+
}
|
|
22589
|
+
return (_ctx, _cache) => {
|
|
22590
|
+
return renderSlot(_ctx.$slots, "default");
|
|
22591
|
+
};
|
|
22592
|
+
}
|
|
22593
|
+
});
|
|
22594
|
+
|
|
21193
22595
|
var _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
21194
22596
|
__name: "view",
|
|
21195
22597
|
props: {
|
|
@@ -21229,30 +22631,64 @@ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
21229
22631
|
var _sfc_main = defineComponent({
|
|
21230
22632
|
name: "VkPixiFrame",
|
|
21231
22633
|
components: {
|
|
21232
|
-
|
|
21233
|
-
|
|
21234
|
-
|
|
22634
|
+
ApngComp: _sfc_main$5,
|
|
22635
|
+
CoreComp: _sfc_main$4,
|
|
22636
|
+
ProviderComp: _sfc_main$3,
|
|
22637
|
+
ViewComp: _sfc_main$1,
|
|
22638
|
+
VideoComp: _sfc_main$2
|
|
21235
22639
|
},
|
|
21236
22640
|
props,
|
|
21237
|
-
emits
|
|
22641
|
+
emits,
|
|
22642
|
+
setup(props2) {
|
|
22643
|
+
const isApng = computed(() => {
|
|
22644
|
+
if (!props2.url)
|
|
22645
|
+
return false;
|
|
22646
|
+
const url = props2.url.toLowerCase();
|
|
22647
|
+
return url.includes(".png") && !url.includes(".mp4") && !url.includes(".webm");
|
|
22648
|
+
});
|
|
22649
|
+
const isVideo = computed(() => {
|
|
22650
|
+
if (!props2.url)
|
|
22651
|
+
return false;
|
|
22652
|
+
const url = props2.url.toLowerCase();
|
|
22653
|
+
return url.includes(".mp4") || url.includes(".webm") || url.includes(".mov");
|
|
22654
|
+
});
|
|
22655
|
+
return {
|
|
22656
|
+
isApng,
|
|
22657
|
+
isVideo
|
|
22658
|
+
};
|
|
22659
|
+
}
|
|
21238
22660
|
});
|
|
21239
22661
|
|
|
21240
22662
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
21241
22663
|
const _component_ViewComp = resolveComponent("ViewComp");
|
|
22664
|
+
const _component_ApngComp = resolveComponent("ApngComp");
|
|
22665
|
+
const _component_VideoComp = resolveComponent("VideoComp");
|
|
21242
22666
|
const _component_CoreComp = resolveComponent("CoreComp");
|
|
21243
22667
|
const _component_ProviderComp = resolveComponent("ProviderComp");
|
|
21244
22668
|
return openBlock(), createBlock(_component_ProviderComp, null, {
|
|
21245
22669
|
default: withCtx(() => [
|
|
21246
22670
|
createVNode(_component_ViewComp),
|
|
21247
|
-
|
|
22671
|
+
_ctx.isApng && _ctx.url ? (openBlock(), createBlock(_component_ApngComp, {
|
|
22672
|
+
key: 0,
|
|
22673
|
+
url: _ctx.url,
|
|
22674
|
+
loop: _ctx.loop,
|
|
22675
|
+
status: _ctx.status,
|
|
22676
|
+
"onUpdate:status": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:status", $event))
|
|
22677
|
+
}, null, 8, ["url", "loop", "status"])) : _ctx.isVideo && _ctx.url ? (openBlock(), createBlock(_component_VideoComp, {
|
|
22678
|
+
key: 1,
|
|
22679
|
+
url: _ctx.url,
|
|
22680
|
+
loop: _ctx.loop,
|
|
22681
|
+
status: _ctx.status,
|
|
22682
|
+
"onUpdate:status": _cache[1] || (_cache[1] = ($event) => _ctx.$emit("update:status", $event))
|
|
22683
|
+
}, null, 8, ["url", "loop", "status"])) : (openBlock(), createBlock(
|
|
21248
22684
|
_component_CoreComp,
|
|
21249
|
-
mergeProps(_ctx.$props, {
|
|
21250
|
-
"onUpdate:status": _cache[
|
|
22685
|
+
mergeProps({ key: 2 }, _ctx.$props, {
|
|
22686
|
+
"onUpdate:status": _cache[2] || (_cache[2] = ($event) => _ctx.$emit("update:status", $event))
|
|
21251
22687
|
}),
|
|
21252
22688
|
null,
|
|
21253
22689
|
16
|
|
21254
22690
|
/* FULL_PROPS */
|
|
21255
|
-
)
|
|
22691
|
+
))
|
|
21256
22692
|
]),
|
|
21257
22693
|
_: 1
|
|
21258
22694
|
/* STABLE */
|
|
@@ -21261,11 +22697,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
21261
22697
|
var VkPixiFrame = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
21262
22698
|
|
|
21263
22699
|
var types = /*#__PURE__*/Object.freeze({
|
|
21264
|
-
|
|
22700
|
+
__proto__: null
|
|
21265
22701
|
});
|
|
21266
22702
|
|
|
21267
22703
|
VkPixiFrame.install = (app) => {
|
|
21268
22704
|
app.component(VkPixiFrame.name || "VkPixiFrame", VkPixiFrame);
|
|
21269
22705
|
};
|
|
21270
22706
|
|
|
21271
|
-
export { VERSION as $, AbstractRenderer as A, BufferUsage as B, Container as C, DOMAdapter as D, ExtensionType as E, Bounds as F, GpuProgram as G, TexturePool as H, FilterEffect as I, Sprite as J, getAttributeInfoFromFormat as K, unsafeEvalSupported as L, Matrix as M, uid as N, Rectangle as O, Point as P, SystemRunner as Q, RendererType as R, STENCIL_MODES as S, Ticker as T, UPDATE_PRIORITY as U, multiplyColors as V, UPDATE_VISIBLE as W, UPDATE_COLOR as X, UPDATE_BLEND as Y, Color as Z, getLocalBounds as _, EventEmitter as a, deprecation as a0, v8_0_0 as a1, RendererInitHook as a2, Geometry as a3, compileHighShaderGlProgram as a4, colorBitGl as a5, generateTextureBatchBitGl as a6, roundPixelsBitGl as a7, getBatchSamplersUniformGroup as a8, ViewContainer as a9, GraphicsContext as aa, TextStyle as ab, generateTextStyleKey as ac, BatchableGraphics as ad, getAdjustedBlendModeBlend as ae, ViewableBuffer as af, TextureStyle as ag, BitmapFontManager as ah, getBitmapTextLayout as ai, Cache as aj, updateQuadBounds as ak, CanvasTextMetrics as al, nextPow2 as am, fontStringFromTextStyle as an, getCanvasFillStyle as ao, GraphicsContextSystem as ap, VkPixiFrame as aq, _sfc_main$
|
|
22707
|
+
export { VERSION as $, AbstractRenderer as A, BufferUsage as B, Container as C, DOMAdapter as D, ExtensionType as E, Bounds as F, GpuProgram as G, TexturePool as H, FilterEffect as I, Sprite as J, getAttributeInfoFromFormat as K, unsafeEvalSupported as L, Matrix as M, uid as N, Rectangle as O, Point as P, SystemRunner as Q, RendererType as R, STENCIL_MODES as S, Ticker as T, UPDATE_PRIORITY as U, multiplyColors as V, UPDATE_VISIBLE as W, UPDATE_COLOR as X, UPDATE_BLEND as Y, Color as Z, getLocalBounds as _, EventEmitter as a, deprecation as a0, v8_0_0 as a1, RendererInitHook as a2, Geometry as a3, compileHighShaderGlProgram as a4, colorBitGl as a5, generateTextureBatchBitGl as a6, roundPixelsBitGl as a7, getBatchSamplersUniformGroup as a8, ViewContainer as a9, GraphicsContext as aa, TextStyle as ab, generateTextStyleKey as ac, BatchableGraphics as ad, getAdjustedBlendModeBlend as ae, ViewableBuffer as af, TextureStyle as ag, BitmapFontManager as ah, getBitmapTextLayout as ai, Cache as aj, updateQuadBounds as ak, CanvasTextMetrics as al, nextPow2 as am, fontStringFromTextStyle as an, getCanvasFillStyle as ao, GraphicsContextSystem as ap, VkPixiFrame as aq, _sfc_main$5 as ar, _sfc_main$4 as as, _sfc_main$3 as at, _sfc_main$2 as au, _sfc_main$1 as av, types as aw, Buffer as b, BindGroup as c, createIdFromString as d, extensions as e, fastCopy as f, getTextureBatchBindGroup as g, CLEAR as h, CanvasSource as i, TextureSource as j, UniformGroup as k, CanvasPool as l, compileHighShaderGpuProgram as m, colorBit as n, generateTextureBatchBit as o, roundPixelsBit as p, getMaxTexturesPerBatch as q, removeItems as r, Shader as s, Texture as t, GlProgram as u, TextureMatrix as v, warn as w, DefaultBatcher as x, BigPool as y, getGlobalBounds as z };
|