@polyv/vue-components 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/vue2/index.es.js +782 -34
- package/vue2/src/hooks/animation/types/common.d.ts +1 -1
- package/vue2/src/hooks/animation/types/index.d.ts +5 -0
- package/vue2/src/hooks/animation/use-gif-handler/index.d.ts +26 -0
- package/vue2/src/hooks/animation/use-special-effect/index.d.ts +9 -4
- package/vue2/src/hooks/exports.d.ts +1 -0
- package/vue3/index.es.js +782 -34
- package/vue3/src/hooks/animation/types/common.d.ts +1 -1
- package/vue3/src/hooks/animation/types/index.d.ts +5 -0
- package/vue3/src/hooks/animation/use-gif-handler/index.d.ts +26 -0
- package/vue3/src/hooks/animation/use-special-effect/index.d.ts +9 -4
- package/vue3/src/hooks/exports.d.ts +1 -0
package/vue3/index.es.js
CHANGED
|
@@ -19,7 +19,7 @@ import { changeProtocol } from "@polyv/utils/es/net";
|
|
|
19
19
|
import { formatDate, formatSeconds } from "@polyv/utils/es/date";
|
|
20
20
|
import { getFileType, convertFileSize, FileSizeUnit, getExtname } from "@polyv/utils/es/file";
|
|
21
21
|
import { sleep } from "@polyv/utils/es/async";
|
|
22
|
-
import { debounce as debounce$1 } from "lodash-es";
|
|
22
|
+
import { debounce as debounce$1, isNumber } from "lodash-es";
|
|
23
23
|
import { ossCompress, preloadImg } from "@polyv/utils/es/image";
|
|
24
24
|
import { isPhoneNO } from "@polyv/utils/es/validate";
|
|
25
25
|
import Swiper from "swiper";
|
|
@@ -23134,6 +23134,710 @@ var __component__ = /* @__PURE__ */ normalizeComponent(
|
|
|
23134
23134
|
const TableColumn = __component__.exports;
|
|
23135
23135
|
const PwcTable = withInstall("PwcTable", Table);
|
|
23136
23136
|
const PwcTableColumn = withInstall("PwcTableColumn", TableColumn);
|
|
23137
|
+
var omggif = {};
|
|
23138
|
+
var GifReader_1;
|
|
23139
|
+
var GifWriter_1;
|
|
23140
|
+
function GifWriter(buf, width, height, gopts) {
|
|
23141
|
+
var p2 = 0;
|
|
23142
|
+
var gopts = gopts === void 0 ? {} : gopts;
|
|
23143
|
+
var loop_count = gopts.loop === void 0 ? null : gopts.loop;
|
|
23144
|
+
var global_palette = gopts.palette === void 0 ? null : gopts.palette;
|
|
23145
|
+
if (width <= 0 || height <= 0 || width > 65535 || height > 65535)
|
|
23146
|
+
throw new Error("Width/Height invalid.");
|
|
23147
|
+
function check_palette_and_num_colors(palette) {
|
|
23148
|
+
var num_colors = palette.length;
|
|
23149
|
+
if (num_colors < 2 || num_colors > 256 || num_colors & num_colors - 1) {
|
|
23150
|
+
throw new Error(
|
|
23151
|
+
"Invalid code/color length, must be power of 2 and 2 .. 256."
|
|
23152
|
+
);
|
|
23153
|
+
}
|
|
23154
|
+
return num_colors;
|
|
23155
|
+
}
|
|
23156
|
+
buf[p2++] = 71;
|
|
23157
|
+
buf[p2++] = 73;
|
|
23158
|
+
buf[p2++] = 70;
|
|
23159
|
+
buf[p2++] = 56;
|
|
23160
|
+
buf[p2++] = 57;
|
|
23161
|
+
buf[p2++] = 97;
|
|
23162
|
+
var gp_num_colors_pow2 = 0;
|
|
23163
|
+
var background = 0;
|
|
23164
|
+
if (global_palette !== null) {
|
|
23165
|
+
var gp_num_colors = check_palette_and_num_colors(global_palette);
|
|
23166
|
+
while (gp_num_colors >>= 1) ++gp_num_colors_pow2;
|
|
23167
|
+
gp_num_colors = 1 << gp_num_colors_pow2;
|
|
23168
|
+
--gp_num_colors_pow2;
|
|
23169
|
+
if (gopts.background !== void 0) {
|
|
23170
|
+
background = gopts.background;
|
|
23171
|
+
if (background >= gp_num_colors)
|
|
23172
|
+
throw new Error("Background index out of range.");
|
|
23173
|
+
if (background === 0)
|
|
23174
|
+
throw new Error("Background index explicitly passed as 0.");
|
|
23175
|
+
}
|
|
23176
|
+
}
|
|
23177
|
+
buf[p2++] = width & 255;
|
|
23178
|
+
buf[p2++] = width >> 8 & 255;
|
|
23179
|
+
buf[p2++] = height & 255;
|
|
23180
|
+
buf[p2++] = height >> 8 & 255;
|
|
23181
|
+
buf[p2++] = (global_palette !== null ? 128 : 0) | // Global Color Table Flag.
|
|
23182
|
+
gp_num_colors_pow2;
|
|
23183
|
+
buf[p2++] = background;
|
|
23184
|
+
buf[p2++] = 0;
|
|
23185
|
+
if (global_palette !== null) {
|
|
23186
|
+
for (var i = 0, il = global_palette.length; i < il; ++i) {
|
|
23187
|
+
var rgb = global_palette[i];
|
|
23188
|
+
buf[p2++] = rgb >> 16 & 255;
|
|
23189
|
+
buf[p2++] = rgb >> 8 & 255;
|
|
23190
|
+
buf[p2++] = rgb & 255;
|
|
23191
|
+
}
|
|
23192
|
+
}
|
|
23193
|
+
if (loop_count !== null) {
|
|
23194
|
+
if (loop_count < 0 || loop_count > 65535)
|
|
23195
|
+
throw new Error("Loop count invalid.");
|
|
23196
|
+
buf[p2++] = 33;
|
|
23197
|
+
buf[p2++] = 255;
|
|
23198
|
+
buf[p2++] = 11;
|
|
23199
|
+
buf[p2++] = 78;
|
|
23200
|
+
buf[p2++] = 69;
|
|
23201
|
+
buf[p2++] = 84;
|
|
23202
|
+
buf[p2++] = 83;
|
|
23203
|
+
buf[p2++] = 67;
|
|
23204
|
+
buf[p2++] = 65;
|
|
23205
|
+
buf[p2++] = 80;
|
|
23206
|
+
buf[p2++] = 69;
|
|
23207
|
+
buf[p2++] = 50;
|
|
23208
|
+
buf[p2++] = 46;
|
|
23209
|
+
buf[p2++] = 48;
|
|
23210
|
+
buf[p2++] = 3;
|
|
23211
|
+
buf[p2++] = 1;
|
|
23212
|
+
buf[p2++] = loop_count & 255;
|
|
23213
|
+
buf[p2++] = loop_count >> 8 & 255;
|
|
23214
|
+
buf[p2++] = 0;
|
|
23215
|
+
}
|
|
23216
|
+
var ended = false;
|
|
23217
|
+
this.addFrame = function(x, y, w, h2, indexed_pixels, opts) {
|
|
23218
|
+
if (ended === true) {
|
|
23219
|
+
--p2;
|
|
23220
|
+
ended = false;
|
|
23221
|
+
}
|
|
23222
|
+
opts = opts === void 0 ? {} : opts;
|
|
23223
|
+
if (x < 0 || y < 0 || x > 65535 || y > 65535)
|
|
23224
|
+
throw new Error("x/y invalid.");
|
|
23225
|
+
if (w <= 0 || h2 <= 0 || w > 65535 || h2 > 65535)
|
|
23226
|
+
throw new Error("Width/Height invalid.");
|
|
23227
|
+
if (indexed_pixels.length < w * h2)
|
|
23228
|
+
throw new Error("Not enough pixels for the frame size.");
|
|
23229
|
+
var using_local_palette = true;
|
|
23230
|
+
var palette = opts.palette;
|
|
23231
|
+
if (palette === void 0 || palette === null) {
|
|
23232
|
+
using_local_palette = false;
|
|
23233
|
+
palette = global_palette;
|
|
23234
|
+
}
|
|
23235
|
+
if (palette === void 0 || palette === null)
|
|
23236
|
+
throw new Error("Must supply either a local or global palette.");
|
|
23237
|
+
var num_colors = check_palette_and_num_colors(palette);
|
|
23238
|
+
var min_code_size = 0;
|
|
23239
|
+
while (num_colors >>= 1) ++min_code_size;
|
|
23240
|
+
num_colors = 1 << min_code_size;
|
|
23241
|
+
var delay = opts.delay === void 0 ? 0 : opts.delay;
|
|
23242
|
+
var disposal = opts.disposal === void 0 ? 0 : opts.disposal;
|
|
23243
|
+
if (disposal < 0 || disposal > 3)
|
|
23244
|
+
throw new Error("Disposal out of range.");
|
|
23245
|
+
var use_transparency = false;
|
|
23246
|
+
var transparent_index = 0;
|
|
23247
|
+
if (opts.transparent !== void 0 && opts.transparent !== null) {
|
|
23248
|
+
use_transparency = true;
|
|
23249
|
+
transparent_index = opts.transparent;
|
|
23250
|
+
if (transparent_index < 0 || transparent_index >= num_colors)
|
|
23251
|
+
throw new Error("Transparent color index.");
|
|
23252
|
+
}
|
|
23253
|
+
if (disposal !== 0 || use_transparency || delay !== 0) {
|
|
23254
|
+
buf[p2++] = 33;
|
|
23255
|
+
buf[p2++] = 249;
|
|
23256
|
+
buf[p2++] = 4;
|
|
23257
|
+
buf[p2++] = disposal << 2 | (use_transparency === true ? 1 : 0);
|
|
23258
|
+
buf[p2++] = delay & 255;
|
|
23259
|
+
buf[p2++] = delay >> 8 & 255;
|
|
23260
|
+
buf[p2++] = transparent_index;
|
|
23261
|
+
buf[p2++] = 0;
|
|
23262
|
+
}
|
|
23263
|
+
buf[p2++] = 44;
|
|
23264
|
+
buf[p2++] = x & 255;
|
|
23265
|
+
buf[p2++] = x >> 8 & 255;
|
|
23266
|
+
buf[p2++] = y & 255;
|
|
23267
|
+
buf[p2++] = y >> 8 & 255;
|
|
23268
|
+
buf[p2++] = w & 255;
|
|
23269
|
+
buf[p2++] = w >> 8 & 255;
|
|
23270
|
+
buf[p2++] = h2 & 255;
|
|
23271
|
+
buf[p2++] = h2 >> 8 & 255;
|
|
23272
|
+
buf[p2++] = using_local_palette === true ? 128 | min_code_size - 1 : 0;
|
|
23273
|
+
if (using_local_palette === true) {
|
|
23274
|
+
for (var i2 = 0, il2 = palette.length; i2 < il2; ++i2) {
|
|
23275
|
+
var rgb2 = palette[i2];
|
|
23276
|
+
buf[p2++] = rgb2 >> 16 & 255;
|
|
23277
|
+
buf[p2++] = rgb2 >> 8 & 255;
|
|
23278
|
+
buf[p2++] = rgb2 & 255;
|
|
23279
|
+
}
|
|
23280
|
+
}
|
|
23281
|
+
p2 = GifWriterOutputLZWCodeStream(
|
|
23282
|
+
buf,
|
|
23283
|
+
p2,
|
|
23284
|
+
min_code_size < 2 ? 2 : min_code_size,
|
|
23285
|
+
indexed_pixels
|
|
23286
|
+
);
|
|
23287
|
+
return p2;
|
|
23288
|
+
};
|
|
23289
|
+
this.end = function() {
|
|
23290
|
+
if (ended === false) {
|
|
23291
|
+
buf[p2++] = 59;
|
|
23292
|
+
ended = true;
|
|
23293
|
+
}
|
|
23294
|
+
return p2;
|
|
23295
|
+
};
|
|
23296
|
+
this.getOutputBuffer = function() {
|
|
23297
|
+
return buf;
|
|
23298
|
+
};
|
|
23299
|
+
this.setOutputBuffer = function(v) {
|
|
23300
|
+
buf = v;
|
|
23301
|
+
};
|
|
23302
|
+
this.getOutputBufferPosition = function() {
|
|
23303
|
+
return p2;
|
|
23304
|
+
};
|
|
23305
|
+
this.setOutputBufferPosition = function(v) {
|
|
23306
|
+
p2 = v;
|
|
23307
|
+
};
|
|
23308
|
+
}
|
|
23309
|
+
function GifWriterOutputLZWCodeStream(buf, p2, min_code_size, index_stream) {
|
|
23310
|
+
buf[p2++] = min_code_size;
|
|
23311
|
+
var cur_subblock = p2++;
|
|
23312
|
+
var clear_code = 1 << min_code_size;
|
|
23313
|
+
var code_mask = clear_code - 1;
|
|
23314
|
+
var eoi_code = clear_code + 1;
|
|
23315
|
+
var next_code = eoi_code + 1;
|
|
23316
|
+
var cur_code_size = min_code_size + 1;
|
|
23317
|
+
var cur_shift = 0;
|
|
23318
|
+
var cur = 0;
|
|
23319
|
+
function emit_bytes_to_buffer(bit_block_size) {
|
|
23320
|
+
while (cur_shift >= bit_block_size) {
|
|
23321
|
+
buf[p2++] = cur & 255;
|
|
23322
|
+
cur >>= 8;
|
|
23323
|
+
cur_shift -= 8;
|
|
23324
|
+
if (p2 === cur_subblock + 256) {
|
|
23325
|
+
buf[cur_subblock] = 255;
|
|
23326
|
+
cur_subblock = p2++;
|
|
23327
|
+
}
|
|
23328
|
+
}
|
|
23329
|
+
}
|
|
23330
|
+
function emit_code(c2) {
|
|
23331
|
+
cur |= c2 << cur_shift;
|
|
23332
|
+
cur_shift += cur_code_size;
|
|
23333
|
+
emit_bytes_to_buffer(8);
|
|
23334
|
+
}
|
|
23335
|
+
var ib_code = index_stream[0] & code_mask;
|
|
23336
|
+
var code_table = {};
|
|
23337
|
+
emit_code(clear_code);
|
|
23338
|
+
for (var i = 1, il = index_stream.length; i < il; ++i) {
|
|
23339
|
+
var k = index_stream[i] & code_mask;
|
|
23340
|
+
var cur_key = ib_code << 8 | k;
|
|
23341
|
+
var cur_code = code_table[cur_key];
|
|
23342
|
+
if (cur_code === void 0) {
|
|
23343
|
+
cur |= ib_code << cur_shift;
|
|
23344
|
+
cur_shift += cur_code_size;
|
|
23345
|
+
while (cur_shift >= 8) {
|
|
23346
|
+
buf[p2++] = cur & 255;
|
|
23347
|
+
cur >>= 8;
|
|
23348
|
+
cur_shift -= 8;
|
|
23349
|
+
if (p2 === cur_subblock + 256) {
|
|
23350
|
+
buf[cur_subblock] = 255;
|
|
23351
|
+
cur_subblock = p2++;
|
|
23352
|
+
}
|
|
23353
|
+
}
|
|
23354
|
+
if (next_code === 4096) {
|
|
23355
|
+
emit_code(clear_code);
|
|
23356
|
+
next_code = eoi_code + 1;
|
|
23357
|
+
cur_code_size = min_code_size + 1;
|
|
23358
|
+
code_table = {};
|
|
23359
|
+
} else {
|
|
23360
|
+
if (next_code >= 1 << cur_code_size) ++cur_code_size;
|
|
23361
|
+
code_table[cur_key] = next_code++;
|
|
23362
|
+
}
|
|
23363
|
+
ib_code = k;
|
|
23364
|
+
} else {
|
|
23365
|
+
ib_code = cur_code;
|
|
23366
|
+
}
|
|
23367
|
+
}
|
|
23368
|
+
emit_code(ib_code);
|
|
23369
|
+
emit_code(eoi_code);
|
|
23370
|
+
emit_bytes_to_buffer(1);
|
|
23371
|
+
if (cur_subblock + 1 === p2) {
|
|
23372
|
+
buf[cur_subblock] = 0;
|
|
23373
|
+
} else {
|
|
23374
|
+
buf[cur_subblock] = p2 - cur_subblock - 1;
|
|
23375
|
+
buf[p2++] = 0;
|
|
23376
|
+
}
|
|
23377
|
+
return p2;
|
|
23378
|
+
}
|
|
23379
|
+
function GifReader(buf) {
|
|
23380
|
+
var p2 = 0;
|
|
23381
|
+
if (buf[p2++] !== 71 || buf[p2++] !== 73 || buf[p2++] !== 70 || buf[p2++] !== 56 || (buf[p2++] + 1 & 253) !== 56 || buf[p2++] !== 97) {
|
|
23382
|
+
throw new Error("Invalid GIF 87a/89a header.");
|
|
23383
|
+
}
|
|
23384
|
+
var width = buf[p2++] | buf[p2++] << 8;
|
|
23385
|
+
var height = buf[p2++] | buf[p2++] << 8;
|
|
23386
|
+
var pf0 = buf[p2++];
|
|
23387
|
+
var global_palette_flag = pf0 >> 7;
|
|
23388
|
+
var num_global_colors_pow2 = pf0 & 7;
|
|
23389
|
+
var num_global_colors = 1 << num_global_colors_pow2 + 1;
|
|
23390
|
+
buf[p2++];
|
|
23391
|
+
buf[p2++];
|
|
23392
|
+
var global_palette_offset = null;
|
|
23393
|
+
var global_palette_size = null;
|
|
23394
|
+
if (global_palette_flag) {
|
|
23395
|
+
global_palette_offset = p2;
|
|
23396
|
+
global_palette_size = num_global_colors;
|
|
23397
|
+
p2 += num_global_colors * 3;
|
|
23398
|
+
}
|
|
23399
|
+
var no_eof = true;
|
|
23400
|
+
var frames = [];
|
|
23401
|
+
var delay = 0;
|
|
23402
|
+
var transparent_index = null;
|
|
23403
|
+
var disposal = 0;
|
|
23404
|
+
var loop_count = null;
|
|
23405
|
+
this.width = width;
|
|
23406
|
+
this.height = height;
|
|
23407
|
+
while (no_eof && p2 < buf.length) {
|
|
23408
|
+
switch (buf[p2++]) {
|
|
23409
|
+
case 33:
|
|
23410
|
+
switch (buf[p2++]) {
|
|
23411
|
+
case 255:
|
|
23412
|
+
if (buf[p2] !== 11 || // 21 FF already read, check block size.
|
|
23413
|
+
// NETSCAPE2.0
|
|
23414
|
+
buf[p2 + 1] == 78 && buf[p2 + 2] == 69 && buf[p2 + 3] == 84 && buf[p2 + 4] == 83 && buf[p2 + 5] == 67 && buf[p2 + 6] == 65 && buf[p2 + 7] == 80 && buf[p2 + 8] == 69 && buf[p2 + 9] == 50 && buf[p2 + 10] == 46 && buf[p2 + 11] == 48 && // Sub-block
|
|
23415
|
+
buf[p2 + 12] == 3 && buf[p2 + 13] == 1 && buf[p2 + 16] == 0) {
|
|
23416
|
+
p2 += 14;
|
|
23417
|
+
loop_count = buf[p2++] | buf[p2++] << 8;
|
|
23418
|
+
p2++;
|
|
23419
|
+
} else {
|
|
23420
|
+
p2 += 12;
|
|
23421
|
+
while (true) {
|
|
23422
|
+
var block_size = buf[p2++];
|
|
23423
|
+
if (!(block_size >= 0)) throw Error("Invalid block size");
|
|
23424
|
+
if (block_size === 0) break;
|
|
23425
|
+
p2 += block_size;
|
|
23426
|
+
}
|
|
23427
|
+
}
|
|
23428
|
+
break;
|
|
23429
|
+
case 249:
|
|
23430
|
+
if (buf[p2++] !== 4 || buf[p2 + 4] !== 0)
|
|
23431
|
+
throw new Error("Invalid graphics extension block.");
|
|
23432
|
+
var pf1 = buf[p2++];
|
|
23433
|
+
delay = buf[p2++] | buf[p2++] << 8;
|
|
23434
|
+
transparent_index = buf[p2++];
|
|
23435
|
+
if ((pf1 & 1) === 0) transparent_index = null;
|
|
23436
|
+
disposal = pf1 >> 2 & 7;
|
|
23437
|
+
p2++;
|
|
23438
|
+
break;
|
|
23439
|
+
case 254:
|
|
23440
|
+
while (true) {
|
|
23441
|
+
var block_size = buf[p2++];
|
|
23442
|
+
if (!(block_size >= 0)) throw Error("Invalid block size");
|
|
23443
|
+
if (block_size === 0) break;
|
|
23444
|
+
p2 += block_size;
|
|
23445
|
+
}
|
|
23446
|
+
break;
|
|
23447
|
+
default:
|
|
23448
|
+
throw new Error(
|
|
23449
|
+
"Unknown graphic control label: 0x" + buf[p2 - 1].toString(16)
|
|
23450
|
+
);
|
|
23451
|
+
}
|
|
23452
|
+
break;
|
|
23453
|
+
case 44:
|
|
23454
|
+
var x = buf[p2++] | buf[p2++] << 8;
|
|
23455
|
+
var y = buf[p2++] | buf[p2++] << 8;
|
|
23456
|
+
var w = buf[p2++] | buf[p2++] << 8;
|
|
23457
|
+
var h2 = buf[p2++] | buf[p2++] << 8;
|
|
23458
|
+
var pf2 = buf[p2++];
|
|
23459
|
+
var local_palette_flag = pf2 >> 7;
|
|
23460
|
+
var interlace_flag = pf2 >> 6 & 1;
|
|
23461
|
+
var num_local_colors_pow2 = pf2 & 7;
|
|
23462
|
+
var num_local_colors = 1 << num_local_colors_pow2 + 1;
|
|
23463
|
+
var palette_offset = global_palette_offset;
|
|
23464
|
+
var palette_size = global_palette_size;
|
|
23465
|
+
var has_local_palette = false;
|
|
23466
|
+
if (local_palette_flag) {
|
|
23467
|
+
var has_local_palette = true;
|
|
23468
|
+
palette_offset = p2;
|
|
23469
|
+
palette_size = num_local_colors;
|
|
23470
|
+
p2 += num_local_colors * 3;
|
|
23471
|
+
}
|
|
23472
|
+
var data_offset = p2;
|
|
23473
|
+
p2++;
|
|
23474
|
+
while (true) {
|
|
23475
|
+
var block_size = buf[p2++];
|
|
23476
|
+
if (!(block_size >= 0)) throw Error("Invalid block size");
|
|
23477
|
+
if (block_size === 0) break;
|
|
23478
|
+
p2 += block_size;
|
|
23479
|
+
}
|
|
23480
|
+
frames.push({
|
|
23481
|
+
x,
|
|
23482
|
+
y,
|
|
23483
|
+
width: w,
|
|
23484
|
+
height: h2,
|
|
23485
|
+
has_local_palette,
|
|
23486
|
+
palette_offset,
|
|
23487
|
+
palette_size,
|
|
23488
|
+
data_offset,
|
|
23489
|
+
data_length: p2 - data_offset,
|
|
23490
|
+
transparent_index,
|
|
23491
|
+
interlaced: !!interlace_flag,
|
|
23492
|
+
delay,
|
|
23493
|
+
disposal
|
|
23494
|
+
});
|
|
23495
|
+
break;
|
|
23496
|
+
case 59:
|
|
23497
|
+
no_eof = false;
|
|
23498
|
+
break;
|
|
23499
|
+
default:
|
|
23500
|
+
throw new Error("Unknown gif block: 0x" + buf[p2 - 1].toString(16));
|
|
23501
|
+
}
|
|
23502
|
+
}
|
|
23503
|
+
this.numFrames = function() {
|
|
23504
|
+
return frames.length;
|
|
23505
|
+
};
|
|
23506
|
+
this.loopCount = function() {
|
|
23507
|
+
return loop_count;
|
|
23508
|
+
};
|
|
23509
|
+
this.frameInfo = function(frame_num) {
|
|
23510
|
+
if (frame_num < 0 || frame_num >= frames.length)
|
|
23511
|
+
throw new Error("Frame index out of range.");
|
|
23512
|
+
return frames[frame_num];
|
|
23513
|
+
};
|
|
23514
|
+
this.decodeAndBlitFrameBGRA = function(frame_num, pixels) {
|
|
23515
|
+
var frame = this.frameInfo(frame_num);
|
|
23516
|
+
var num_pixels = frame.width * frame.height;
|
|
23517
|
+
var index_stream = new Uint8Array(num_pixels);
|
|
23518
|
+
GifReaderLZWOutputIndexStream(
|
|
23519
|
+
buf,
|
|
23520
|
+
frame.data_offset,
|
|
23521
|
+
index_stream,
|
|
23522
|
+
num_pixels
|
|
23523
|
+
);
|
|
23524
|
+
var palette_offset2 = frame.palette_offset;
|
|
23525
|
+
var trans = frame.transparent_index;
|
|
23526
|
+
if (trans === null) trans = 256;
|
|
23527
|
+
var framewidth = frame.width;
|
|
23528
|
+
var framestride = width - framewidth;
|
|
23529
|
+
var xleft = framewidth;
|
|
23530
|
+
var opbeg = (frame.y * width + frame.x) * 4;
|
|
23531
|
+
var opend = ((frame.y + frame.height) * width + frame.x) * 4;
|
|
23532
|
+
var op = opbeg;
|
|
23533
|
+
var scanstride = framestride * 4;
|
|
23534
|
+
if (frame.interlaced === true) {
|
|
23535
|
+
scanstride += width * 4 * 7;
|
|
23536
|
+
}
|
|
23537
|
+
var interlaceskip = 8;
|
|
23538
|
+
for (var i = 0, il = index_stream.length; i < il; ++i) {
|
|
23539
|
+
var index2 = index_stream[i];
|
|
23540
|
+
if (xleft === 0) {
|
|
23541
|
+
op += scanstride;
|
|
23542
|
+
xleft = framewidth;
|
|
23543
|
+
if (op >= opend) {
|
|
23544
|
+
scanstride = framestride * 4 + width * 4 * (interlaceskip - 1);
|
|
23545
|
+
op = opbeg + (framewidth + framestride) * (interlaceskip << 1);
|
|
23546
|
+
interlaceskip >>= 1;
|
|
23547
|
+
}
|
|
23548
|
+
}
|
|
23549
|
+
if (index2 === trans) {
|
|
23550
|
+
op += 4;
|
|
23551
|
+
} else {
|
|
23552
|
+
var r = buf[palette_offset2 + index2 * 3];
|
|
23553
|
+
var g2 = buf[palette_offset2 + index2 * 3 + 1];
|
|
23554
|
+
var b = buf[palette_offset2 + index2 * 3 + 2];
|
|
23555
|
+
pixels[op++] = b;
|
|
23556
|
+
pixels[op++] = g2;
|
|
23557
|
+
pixels[op++] = r;
|
|
23558
|
+
pixels[op++] = 255;
|
|
23559
|
+
}
|
|
23560
|
+
--xleft;
|
|
23561
|
+
}
|
|
23562
|
+
};
|
|
23563
|
+
this.decodeAndBlitFrameRGBA = function(frame_num, pixels) {
|
|
23564
|
+
var frame = this.frameInfo(frame_num);
|
|
23565
|
+
var num_pixels = frame.width * frame.height;
|
|
23566
|
+
var index_stream = new Uint8Array(num_pixels);
|
|
23567
|
+
GifReaderLZWOutputIndexStream(
|
|
23568
|
+
buf,
|
|
23569
|
+
frame.data_offset,
|
|
23570
|
+
index_stream,
|
|
23571
|
+
num_pixels
|
|
23572
|
+
);
|
|
23573
|
+
var palette_offset2 = frame.palette_offset;
|
|
23574
|
+
var trans = frame.transparent_index;
|
|
23575
|
+
if (trans === null) trans = 256;
|
|
23576
|
+
var framewidth = frame.width;
|
|
23577
|
+
var framestride = width - framewidth;
|
|
23578
|
+
var xleft = framewidth;
|
|
23579
|
+
var opbeg = (frame.y * width + frame.x) * 4;
|
|
23580
|
+
var opend = ((frame.y + frame.height) * width + frame.x) * 4;
|
|
23581
|
+
var op = opbeg;
|
|
23582
|
+
var scanstride = framestride * 4;
|
|
23583
|
+
if (frame.interlaced === true) {
|
|
23584
|
+
scanstride += width * 4 * 7;
|
|
23585
|
+
}
|
|
23586
|
+
var interlaceskip = 8;
|
|
23587
|
+
for (var i = 0, il = index_stream.length; i < il; ++i) {
|
|
23588
|
+
var index2 = index_stream[i];
|
|
23589
|
+
if (xleft === 0) {
|
|
23590
|
+
op += scanstride;
|
|
23591
|
+
xleft = framewidth;
|
|
23592
|
+
if (op >= opend) {
|
|
23593
|
+
scanstride = framestride * 4 + width * 4 * (interlaceskip - 1);
|
|
23594
|
+
op = opbeg + (framewidth + framestride) * (interlaceskip << 1);
|
|
23595
|
+
interlaceskip >>= 1;
|
|
23596
|
+
}
|
|
23597
|
+
}
|
|
23598
|
+
if (index2 === trans) {
|
|
23599
|
+
op += 4;
|
|
23600
|
+
} else {
|
|
23601
|
+
var r = buf[palette_offset2 + index2 * 3];
|
|
23602
|
+
var g2 = buf[palette_offset2 + index2 * 3 + 1];
|
|
23603
|
+
var b = buf[palette_offset2 + index2 * 3 + 2];
|
|
23604
|
+
pixels[op++] = r;
|
|
23605
|
+
pixels[op++] = g2;
|
|
23606
|
+
pixels[op++] = b;
|
|
23607
|
+
pixels[op++] = 255;
|
|
23608
|
+
}
|
|
23609
|
+
--xleft;
|
|
23610
|
+
}
|
|
23611
|
+
};
|
|
23612
|
+
}
|
|
23613
|
+
function GifReaderLZWOutputIndexStream(code_stream, p2, output, output_length) {
|
|
23614
|
+
var min_code_size = code_stream[p2++];
|
|
23615
|
+
var clear_code = 1 << min_code_size;
|
|
23616
|
+
var eoi_code = clear_code + 1;
|
|
23617
|
+
var next_code = eoi_code + 1;
|
|
23618
|
+
var cur_code_size = min_code_size + 1;
|
|
23619
|
+
var code_mask = (1 << cur_code_size) - 1;
|
|
23620
|
+
var cur_shift = 0;
|
|
23621
|
+
var cur = 0;
|
|
23622
|
+
var op = 0;
|
|
23623
|
+
var subblock_size = code_stream[p2++];
|
|
23624
|
+
var code_table = new Int32Array(4096);
|
|
23625
|
+
var prev_code = null;
|
|
23626
|
+
while (true) {
|
|
23627
|
+
while (cur_shift < 16) {
|
|
23628
|
+
if (subblock_size === 0) break;
|
|
23629
|
+
cur |= code_stream[p2++] << cur_shift;
|
|
23630
|
+
cur_shift += 8;
|
|
23631
|
+
if (subblock_size === 1) {
|
|
23632
|
+
subblock_size = code_stream[p2++];
|
|
23633
|
+
} else {
|
|
23634
|
+
--subblock_size;
|
|
23635
|
+
}
|
|
23636
|
+
}
|
|
23637
|
+
if (cur_shift < cur_code_size)
|
|
23638
|
+
break;
|
|
23639
|
+
var code = cur & code_mask;
|
|
23640
|
+
cur >>= cur_code_size;
|
|
23641
|
+
cur_shift -= cur_code_size;
|
|
23642
|
+
if (code === clear_code) {
|
|
23643
|
+
next_code = eoi_code + 1;
|
|
23644
|
+
cur_code_size = min_code_size + 1;
|
|
23645
|
+
code_mask = (1 << cur_code_size) - 1;
|
|
23646
|
+
prev_code = null;
|
|
23647
|
+
continue;
|
|
23648
|
+
} else if (code === eoi_code) {
|
|
23649
|
+
break;
|
|
23650
|
+
}
|
|
23651
|
+
var chase_code = code < next_code ? code : prev_code;
|
|
23652
|
+
var chase_length = 0;
|
|
23653
|
+
var chase = chase_code;
|
|
23654
|
+
while (chase > clear_code) {
|
|
23655
|
+
chase = code_table[chase] >> 8;
|
|
23656
|
+
++chase_length;
|
|
23657
|
+
}
|
|
23658
|
+
var k = chase;
|
|
23659
|
+
var op_end = op + chase_length + (chase_code !== code ? 1 : 0);
|
|
23660
|
+
if (op_end > output_length) {
|
|
23661
|
+
console.log("Warning, gif stream longer than expected.");
|
|
23662
|
+
return;
|
|
23663
|
+
}
|
|
23664
|
+
output[op++] = k;
|
|
23665
|
+
op += chase_length;
|
|
23666
|
+
var b = op;
|
|
23667
|
+
if (chase_code !== code)
|
|
23668
|
+
output[op++] = k;
|
|
23669
|
+
chase = chase_code;
|
|
23670
|
+
while (chase_length--) {
|
|
23671
|
+
chase = code_table[chase];
|
|
23672
|
+
output[--b] = chase & 255;
|
|
23673
|
+
chase >>= 8;
|
|
23674
|
+
}
|
|
23675
|
+
if (prev_code !== null && next_code < 4096) {
|
|
23676
|
+
code_table[next_code++] = prev_code << 8 | k;
|
|
23677
|
+
if (next_code >= code_mask + 1 && cur_code_size < 12) {
|
|
23678
|
+
++cur_code_size;
|
|
23679
|
+
code_mask = code_mask << 1 | 1;
|
|
23680
|
+
}
|
|
23681
|
+
}
|
|
23682
|
+
prev_code = code;
|
|
23683
|
+
}
|
|
23684
|
+
if (op !== output_length) {
|
|
23685
|
+
console.log("Warning, gif stream shorter than expected.");
|
|
23686
|
+
}
|
|
23687
|
+
return output;
|
|
23688
|
+
}
|
|
23689
|
+
try {
|
|
23690
|
+
GifWriter_1 = omggif.GifWriter = GifWriter;
|
|
23691
|
+
GifReader_1 = omggif.GifReader = GifReader;
|
|
23692
|
+
} catch (e) {
|
|
23693
|
+
}
|
|
23694
|
+
class CacheControl {
|
|
23695
|
+
constructor(opt) {
|
|
23696
|
+
__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
23697
|
+
__publicField(this, "maxSize", 20);
|
|
23698
|
+
__publicField(this, "keys", []);
|
|
23699
|
+
this.maxSize = opt?.maxSize || this.maxSize;
|
|
23700
|
+
}
|
|
23701
|
+
/**
|
|
23702
|
+
* 获取缓存值
|
|
23703
|
+
*/
|
|
23704
|
+
get(key) {
|
|
23705
|
+
return this.cache.get(key);
|
|
23706
|
+
}
|
|
23707
|
+
/**
|
|
23708
|
+
* 设置缓存值
|
|
23709
|
+
*/
|
|
23710
|
+
set(key, value) {
|
|
23711
|
+
if (this.cache.has(key)) {
|
|
23712
|
+
this.cache.set(key, value);
|
|
23713
|
+
const index2 = this.keys.indexOf(key);
|
|
23714
|
+
if (index2 > -1) {
|
|
23715
|
+
this.keys.splice(index2, 1);
|
|
23716
|
+
this.keys.push(key);
|
|
23717
|
+
}
|
|
23718
|
+
return;
|
|
23719
|
+
}
|
|
23720
|
+
if (this.keys.length >= this.maxSize) {
|
|
23721
|
+
const oldestKey = this.keys.shift();
|
|
23722
|
+
if (oldestKey) {
|
|
23723
|
+
this.cache.delete(oldestKey);
|
|
23724
|
+
}
|
|
23725
|
+
}
|
|
23726
|
+
this.keys.push(key);
|
|
23727
|
+
this.cache.set(key, value);
|
|
23728
|
+
}
|
|
23729
|
+
/**
|
|
23730
|
+
* 检查缓存是否存在
|
|
23731
|
+
*/
|
|
23732
|
+
has(key) {
|
|
23733
|
+
return this.cache.has(key);
|
|
23734
|
+
}
|
|
23735
|
+
/**
|
|
23736
|
+
* 清空缓存
|
|
23737
|
+
*/
|
|
23738
|
+
clear() {
|
|
23739
|
+
this.cache.clear();
|
|
23740
|
+
this.keys = [];
|
|
23741
|
+
}
|
|
23742
|
+
/**
|
|
23743
|
+
* 获取当前缓存大小
|
|
23744
|
+
*/
|
|
23745
|
+
size() {
|
|
23746
|
+
return this.cache.size;
|
|
23747
|
+
}
|
|
23748
|
+
}
|
|
23749
|
+
function isGifUrl(url) {
|
|
23750
|
+
const gifRegex = /\.gif(?:\?.*)?$/i;
|
|
23751
|
+
return gifRegex.test(url);
|
|
23752
|
+
}
|
|
23753
|
+
const useGifHandler = (options = {}) => {
|
|
23754
|
+
const maxSize = options.maxCacheSize || 20;
|
|
23755
|
+
const gifDataCache = new CacheControl({ maxSize });
|
|
23756
|
+
const activeObjectUrls = /* @__PURE__ */ new Map();
|
|
23757
|
+
async function computeGifDuration(blobData) {
|
|
23758
|
+
const buffer = await blobData.arrayBuffer();
|
|
23759
|
+
const byteArray = new Uint8Array(buffer);
|
|
23760
|
+
const gifReader = new GifReader_1(byteArray);
|
|
23761
|
+
let totalDuration = 0;
|
|
23762
|
+
const numFrames = gifReader.numFrames();
|
|
23763
|
+
for (let i = 0; i < numFrames; i++) {
|
|
23764
|
+
const frameInfo = gifReader.frameInfo(i);
|
|
23765
|
+
const delay = (frameInfo.delay || 10) * 10;
|
|
23766
|
+
totalDuration += delay;
|
|
23767
|
+
}
|
|
23768
|
+
return totalDuration;
|
|
23769
|
+
}
|
|
23770
|
+
async function getGifData(url, defaultDuration = 2e3) {
|
|
23771
|
+
if (gifDataCache.has(url)) {
|
|
23772
|
+
return gifDataCache.get(url);
|
|
23773
|
+
}
|
|
23774
|
+
try {
|
|
23775
|
+
const response = await send(url, { responseType: "blob" });
|
|
23776
|
+
const blobData = response.data;
|
|
23777
|
+
const totalDuration = await computeGifDuration(blobData);
|
|
23778
|
+
const duration = totalDuration > 0 ? totalDuration : defaultDuration;
|
|
23779
|
+
const gifData = { blob: blobData, duration };
|
|
23780
|
+
gifDataCache.set(url, gifData);
|
|
23781
|
+
return gifData;
|
|
23782
|
+
} catch (error) {
|
|
23783
|
+
console.warn("Failed to fetch GIF data:", error);
|
|
23784
|
+
throw error;
|
|
23785
|
+
}
|
|
23786
|
+
}
|
|
23787
|
+
async function getGifDuration(url, defaultDuration = 2e3) {
|
|
23788
|
+
if (!isGifUrl(url)) {
|
|
23789
|
+
return defaultDuration;
|
|
23790
|
+
}
|
|
23791
|
+
try {
|
|
23792
|
+
const { duration } = await getGifData(url, defaultDuration);
|
|
23793
|
+
return duration;
|
|
23794
|
+
} catch (error) {
|
|
23795
|
+
console.warn("Failed to get GIF duration:", error);
|
|
23796
|
+
return defaultDuration;
|
|
23797
|
+
}
|
|
23798
|
+
}
|
|
23799
|
+
async function getGifObjectUrl(url) {
|
|
23800
|
+
if (!isGifUrl(url)) {
|
|
23801
|
+
return null;
|
|
23802
|
+
}
|
|
23803
|
+
if (activeObjectUrls.has(url)) {
|
|
23804
|
+
const oldUrl = activeObjectUrls.get(url);
|
|
23805
|
+
URL.revokeObjectURL(oldUrl);
|
|
23806
|
+
activeObjectUrls.delete(url);
|
|
23807
|
+
}
|
|
23808
|
+
try {
|
|
23809
|
+
const { blob } = await getGifData(url);
|
|
23810
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
23811
|
+
activeObjectUrls.set(url, objectUrl);
|
|
23812
|
+
return objectUrl;
|
|
23813
|
+
} catch (error) {
|
|
23814
|
+
console.warn("Failed to get GIF object URL:", error);
|
|
23815
|
+
return null;
|
|
23816
|
+
}
|
|
23817
|
+
}
|
|
23818
|
+
function revokeGifUrl(url) {
|
|
23819
|
+
if (!url) return;
|
|
23820
|
+
if (activeObjectUrls.has(url)) {
|
|
23821
|
+
const objectUrl = activeObjectUrls.get(url);
|
|
23822
|
+
URL.revokeObjectURL(objectUrl);
|
|
23823
|
+
activeObjectUrls.delete(url);
|
|
23824
|
+
}
|
|
23825
|
+
}
|
|
23826
|
+
function cleanupGifCache() {
|
|
23827
|
+
activeObjectUrls.forEach((objectUrl) => {
|
|
23828
|
+
URL.revokeObjectURL(objectUrl);
|
|
23829
|
+
});
|
|
23830
|
+
activeObjectUrls.clear();
|
|
23831
|
+
gifDataCache.clear();
|
|
23832
|
+
}
|
|
23833
|
+
return {
|
|
23834
|
+
isGifUrl,
|
|
23835
|
+
getGifDuration,
|
|
23836
|
+
getGifObjectUrl,
|
|
23837
|
+
revokeGifUrl,
|
|
23838
|
+
cleanupGifCache
|
|
23839
|
+
};
|
|
23840
|
+
};
|
|
23137
23841
|
const useCommonAnimation = (hookOptions, implement) => {
|
|
23138
23842
|
const wrapRef = hookOptions.wrapRef || ref();
|
|
23139
23843
|
const isPlayingAnimation = hookOptions.isPlayingAnimation ?? ref(false);
|
|
@@ -23206,7 +23910,7 @@ const useCommonAnimation = (hookOptions, implement) => {
|
|
|
23206
23910
|
await clearAnimation();
|
|
23207
23911
|
beforePlayCallback(options);
|
|
23208
23912
|
isPlayingAnimation.value = true;
|
|
23209
|
-
await implement.playSingleAnimation();
|
|
23913
|
+
await implement.playSingleAnimation(options);
|
|
23210
23914
|
if (loop.value) {
|
|
23211
23915
|
loopTimer = window.setTimeout(function() {
|
|
23212
23916
|
playAnimation();
|
|
@@ -23249,20 +23953,16 @@ const useCommonAnimation = (hookOptions, implement) => {
|
|
|
23249
23953
|
};
|
|
23250
23954
|
};
|
|
23251
23955
|
const useImageAnimation = (hookOptions = {}) => {
|
|
23252
|
-
const {
|
|
23253
|
-
wrapRef,
|
|
23254
|
-
currentUrl,
|
|
23255
|
-
clearAnimation,
|
|
23256
|
-
playAnimation
|
|
23257
|
-
} = useCommonAnimation(hookOptions, {
|
|
23956
|
+
const { wrapRef, currentUrl, clearAnimation, playAnimation } = useCommonAnimation(hookOptions, {
|
|
23258
23957
|
clearAnimation: clearImageAnimation,
|
|
23259
23958
|
playSingleAnimation
|
|
23260
23959
|
});
|
|
23960
|
+
const { isGifUrl: isGifUrl2, getGifDuration, getGifObjectUrl, revokeGifUrl, cleanupGifCache } = useGifHandler();
|
|
23261
23961
|
let imageWrapElem;
|
|
23262
23962
|
let hideTimer;
|
|
23263
23963
|
async function clearImageAnimation() {
|
|
23264
23964
|
if (hideTimer) {
|
|
23265
|
-
clearTimeout(hideTimer);
|
|
23965
|
+
window.clearTimeout(hideTimer);
|
|
23266
23966
|
hideTimer = void 0;
|
|
23267
23967
|
}
|
|
23268
23968
|
if (imageWrapElem) {
|
|
@@ -23270,38 +23970,74 @@ const useImageAnimation = (hookOptions = {}) => {
|
|
|
23270
23970
|
imageWrapElem = void 0;
|
|
23271
23971
|
}
|
|
23272
23972
|
}
|
|
23273
|
-
|
|
23973
|
+
function getProcessedImageUrl(url, forceRefresh) {
|
|
23974
|
+
if (!forceRefresh) {
|
|
23975
|
+
return url;
|
|
23976
|
+
}
|
|
23977
|
+
return concat(url, { _t: Date.now() });
|
|
23978
|
+
}
|
|
23979
|
+
async function getDisplayImageInfo(imageUrl, interval) {
|
|
23980
|
+
const defaultDuration = isNumber(interval) ? interval : 2e3;
|
|
23981
|
+
if (!isGifUrl2(imageUrl)) {
|
|
23982
|
+
return {
|
|
23983
|
+
cleanupUrl: null,
|
|
23984
|
+
displayUrl: imageUrl,
|
|
23985
|
+
duration: defaultDuration
|
|
23986
|
+
};
|
|
23987
|
+
}
|
|
23988
|
+
const objectUrl = await getGifObjectUrl(imageUrl);
|
|
23989
|
+
const duration = await getGifDuration(imageUrl, defaultDuration);
|
|
23990
|
+
return {
|
|
23991
|
+
displayUrl: objectUrl || imageUrl,
|
|
23992
|
+
duration,
|
|
23993
|
+
cleanupUrl: (url) => revokeGifUrl(url)
|
|
23994
|
+
};
|
|
23995
|
+
}
|
|
23996
|
+
async function playSingleAnimation(options) {
|
|
23274
23997
|
return new Promise((resolve, reject) => {
|
|
23275
23998
|
(async () => {
|
|
23276
|
-
if (!imageWrapElem) {
|
|
23277
|
-
imageWrapElem = document.createElement("div");
|
|
23278
|
-
}
|
|
23279
23999
|
const wrapElem = unref(wrapRef);
|
|
23280
24000
|
if (!wrapElem) {
|
|
23281
24001
|
reject(new Error("playSingleAnimation fail, wrapRef is undefined"));
|
|
23282
24002
|
return;
|
|
23283
24003
|
}
|
|
23284
|
-
|
|
24004
|
+
if (!currentUrl.value) {
|
|
24005
|
+
reject(new Error("playSingleAnimation fail, imageUrl is undefined"));
|
|
24006
|
+
return;
|
|
24007
|
+
}
|
|
24008
|
+
const imageUrl = getProcessedImageUrl(currentUrl.value, options?.forceRefresh || false);
|
|
24009
|
+
const { displayUrl, duration, cleanupUrl } = await getDisplayImageInfo(
|
|
24010
|
+
imageUrl,
|
|
24011
|
+
options?.loopTimeInterval
|
|
24012
|
+
// 此处暂时不新增字段,复用 loopTimeInterval,先留一个口子
|
|
24013
|
+
);
|
|
24014
|
+
if (!imageWrapElem) {
|
|
24015
|
+
imageWrapElem = document.createElement("div");
|
|
24016
|
+
}
|
|
23285
24017
|
imageWrapElem.style.width = "61.2%";
|
|
23286
24018
|
imageWrapElem.style.height = "80%";
|
|
23287
24019
|
imageWrapElem.style.backgroundSize = "contain";
|
|
23288
24020
|
imageWrapElem.style.backgroundPosition = "center center";
|
|
23289
24021
|
imageWrapElem.style.backgroundRepeat = "no-repeat";
|
|
23290
|
-
imageWrapElem.style.backgroundImage = `url(${
|
|
24022
|
+
imageWrapElem.style.backgroundImage = `url(${displayUrl})`;
|
|
23291
24023
|
imageWrapElem.style.position = "absolute";
|
|
23292
24024
|
imageWrapElem.style.left = "50%";
|
|
23293
24025
|
imageWrapElem.style.top = "50%";
|
|
23294
24026
|
imageWrapElem.style.transform = "translate(-50%, -50%)";
|
|
23295
24027
|
wrapElem.appendChild(imageWrapElem);
|
|
23296
24028
|
hideTimer = window.setTimeout(async () => {
|
|
24029
|
+
if (cleanupUrl) {
|
|
24030
|
+
cleanupUrl(displayUrl);
|
|
24031
|
+
}
|
|
23297
24032
|
await clearImageAnimation();
|
|
23298
24033
|
resolve();
|
|
23299
|
-
},
|
|
24034
|
+
}, duration);
|
|
23300
24035
|
})();
|
|
23301
24036
|
});
|
|
23302
24037
|
}
|
|
23303
24038
|
onBeforeUnmount(() => {
|
|
23304
24039
|
clearImageAnimation();
|
|
24040
|
+
cleanupGifCache();
|
|
23305
24041
|
});
|
|
23306
24042
|
return {
|
|
23307
24043
|
wrapRef,
|
|
@@ -23358,12 +24094,7 @@ function loadSvgaPlayer$1() {
|
|
|
23358
24094
|
return svgaPlayerLoader$1;
|
|
23359
24095
|
}
|
|
23360
24096
|
const useSvgaAnimation = (hookOptions = {}) => {
|
|
23361
|
-
const {
|
|
23362
|
-
wrapRef,
|
|
23363
|
-
currentUrl,
|
|
23364
|
-
playAnimation,
|
|
23365
|
-
clearAnimation
|
|
23366
|
-
} = useCommonAnimation(hookOptions, {
|
|
24097
|
+
const { wrapRef, currentUrl, playAnimation, clearAnimation } = useCommonAnimation(hookOptions, {
|
|
23367
24098
|
beforeAutoPlay,
|
|
23368
24099
|
clearAnimation: clearSvgaPlayer,
|
|
23369
24100
|
playSingleAnimation
|
|
@@ -23424,12 +24155,21 @@ const useSvgaAnimation = (hookOptions = {}) => {
|
|
|
23424
24155
|
svgaPlayer.clear();
|
|
23425
24156
|
svgaPlayer.clearDynamicObjects();
|
|
23426
24157
|
}
|
|
23427
|
-
function
|
|
24158
|
+
function getProcessedSvgaUrl(url, forceRefresh) {
|
|
24159
|
+
if (!forceRefresh) {
|
|
24160
|
+
return url;
|
|
24161
|
+
}
|
|
24162
|
+
return concat(url, { _t: Date.now() });
|
|
24163
|
+
}
|
|
24164
|
+
function playSingleAnimation(options) {
|
|
23428
24165
|
return new Promise((resolve, reject) => {
|
|
23429
24166
|
(async () => {
|
|
23430
24167
|
try {
|
|
23431
24168
|
const { svgaPlayer } = await getSvgaPlayer();
|
|
23432
|
-
|
|
24169
|
+
const originalUrl = currentUrl.value;
|
|
24170
|
+
const forceRefresh = options?.forceRefresh ?? false;
|
|
24171
|
+
const processedUrl = getProcessedSvgaUrl(originalUrl, forceRefresh);
|
|
24172
|
+
await setupSvgaUrl(processedUrl);
|
|
23433
24173
|
svgaPlayer.loops = 1;
|
|
23434
24174
|
svgaPlayer.startAnimation();
|
|
23435
24175
|
svgaPlayer.onFinished(() => {
|
|
@@ -23483,16 +24223,13 @@ const useSpecialEffect = (options = {}) => {
|
|
|
23483
24223
|
return;
|
|
23484
24224
|
}
|
|
23485
24225
|
if (isSvgaFileUrl(url)) {
|
|
23486
|
-
await svgaAnimation.playAnimation(
|
|
24226
|
+
await svgaAnimation.playAnimation(options2);
|
|
23487
24227
|
} else {
|
|
23488
|
-
await imageAnimation.playAnimation(
|
|
24228
|
+
await imageAnimation.playAnimation(options2);
|
|
23489
24229
|
}
|
|
23490
24230
|
}
|
|
23491
24231
|
async function clearAnimation() {
|
|
23492
|
-
await Promise.all([
|
|
23493
|
-
svgaAnimation.clearAnimation(),
|
|
23494
|
-
imageAnimation.clearAnimation()
|
|
23495
|
-
]);
|
|
24232
|
+
await Promise.all([svgaAnimation.clearAnimation(), imageAnimation.clearAnimation()]);
|
|
23496
24233
|
}
|
|
23497
24234
|
function pauseAnimationQueue() {
|
|
23498
24235
|
isPaused.value = true;
|
|
@@ -23505,7 +24242,13 @@ const useSpecialEffect = (options = {}) => {
|
|
|
23505
24242
|
animationQueue.value = [];
|
|
23506
24243
|
}
|
|
23507
24244
|
function pushAnimationQueue(options2) {
|
|
23508
|
-
const {
|
|
24245
|
+
const {
|
|
24246
|
+
url,
|
|
24247
|
+
forceRefresh = false,
|
|
24248
|
+
inHeader = false,
|
|
24249
|
+
filterRepeat = false,
|
|
24250
|
+
forceInsert = false
|
|
24251
|
+
} = options2;
|
|
23509
24252
|
if (!url) return;
|
|
23510
24253
|
if (getValue(disabled)) {
|
|
23511
24254
|
return;
|
|
@@ -23520,9 +24263,9 @@ const useSpecialEffect = (options = {}) => {
|
|
|
23520
24263
|
}
|
|
23521
24264
|
}
|
|
23522
24265
|
if (inHeader) {
|
|
23523
|
-
animationQueue.value.unshift({ url });
|
|
24266
|
+
animationQueue.value.unshift({ url, forceRefresh });
|
|
23524
24267
|
} else {
|
|
23525
|
-
animationQueue.value.push({ url });
|
|
24268
|
+
animationQueue.value.push({ url, forceRefresh });
|
|
23526
24269
|
}
|
|
23527
24270
|
checkAnimationQueue();
|
|
23528
24271
|
}
|
|
@@ -23533,7 +24276,10 @@ const useSpecialEffect = (options = {}) => {
|
|
|
23533
24276
|
const item = animationQueue.value.shift();
|
|
23534
24277
|
if (!item || !item.url) return;
|
|
23535
24278
|
currentAnimationItem.value = item;
|
|
23536
|
-
playAnimation({
|
|
24279
|
+
playAnimation({
|
|
24280
|
+
url: item.url,
|
|
24281
|
+
forceRefresh: item.forceRefresh
|
|
24282
|
+
});
|
|
23537
24283
|
}
|
|
23538
24284
|
watch(
|
|
23539
24285
|
() => getValue(disabled),
|
|
@@ -24116,6 +24862,7 @@ export {
|
|
|
24116
24862
|
inputNumberEmits,
|
|
24117
24863
|
inputNumberProps,
|
|
24118
24864
|
inputProps,
|
|
24865
|
+
isGifUrl,
|
|
24119
24866
|
loadSvgaPlayer,
|
|
24120
24867
|
loading,
|
|
24121
24868
|
loadingProps,
|
|
@@ -24217,6 +24964,7 @@ export {
|
|
|
24217
24964
|
useFormWrapInject,
|
|
24218
24965
|
useFormWrapPropsInject,
|
|
24219
24966
|
useFullscreen,
|
|
24967
|
+
useGifHandler,
|
|
24220
24968
|
useHover,
|
|
24221
24969
|
useHoverVisible,
|
|
24222
24970
|
useImageAnimation,
|