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