@galacean/effects-plugin-downgrade 2.0.0-alpha.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1120 @@
1
+ /*!
2
+ * Name: @galacean/effects-plugin-downgrade
3
+ * Description: Galacean Effects player downgrade plugin
4
+ * Author: Ant Group CO., Ltd.
5
+ * Contributors: 飂兮
6
+ * Version: v2.0.0-alpha.28
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ Object.defineProperty(exports, '__esModule', { value: true });
12
+
13
+ var EFFECTS = require('@galacean/effects');
14
+
15
+ function _interopNamespace(e) {
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
27
+ });
28
+ }
29
+ n["default"] = e;
30
+ return Object.freeze(n);
31
+ }
32
+
33
+ var EFFECTS__namespace = /*#__PURE__*/_interopNamespace(EFFECTS);
34
+
35
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
36
+ try {
37
+ var info = gen[key](arg);
38
+ var value = info.value;
39
+ } catch (error) {
40
+ reject(error);
41
+ return;
42
+ }
43
+ if (info.done) resolve(value);
44
+ else Promise.resolve(value).then(_next, _throw);
45
+ }
46
+ function _async_to_generator(fn) {
47
+ return function() {
48
+ var self = this, args = arguments;
49
+ return new Promise(function(resolve, reject) {
50
+ var gen = fn.apply(self, args);
51
+ function _next(value) {
52
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
53
+ }
54
+ function _throw(err) {
55
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
56
+ }
57
+ _next(undefined);
58
+ });
59
+ };
60
+ }
61
+
62
+ function _set_prototype_of(o, p) {
63
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
64
+ o.__proto__ = p;
65
+ return o;
66
+ };
67
+ return _set_prototype_of(o, p);
68
+ }
69
+
70
+ function _inherits(subClass, superClass) {
71
+ if (typeof superClass !== "function" && superClass !== null) {
72
+ throw new TypeError("Super expression must either be null or a function");
73
+ }
74
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
75
+ constructor: {
76
+ value: subClass,
77
+ writable: true,
78
+ configurable: true
79
+ }
80
+ });
81
+ if (superClass) _set_prototype_of(subClass, superClass);
82
+ }
83
+
84
+ function __generator(thisArg, body) {
85
+ var _ = {
86
+ label: 0,
87
+ sent: function sent() {
88
+ if (t[0] & 1) throw t[1];
89
+ return t[1];
90
+ },
91
+ trys: [],
92
+ ops: []
93
+ }, f, y, t, g;
94
+ return g = {
95
+ next: verb(0),
96
+ "throw": verb(1),
97
+ "return": verb(2)
98
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
99
+ return this;
100
+ }), g;
101
+ function verb(n) {
102
+ return function(v) {
103
+ return step([
104
+ n,
105
+ v
106
+ ]);
107
+ };
108
+ }
109
+ function step(op) {
110
+ if (f) throw new TypeError("Generator is already executing.");
111
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
112
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
113
+ if (y = 0, t) op = [
114
+ op[0] & 2,
115
+ t.value
116
+ ];
117
+ switch(op[0]){
118
+ case 0:
119
+ case 1:
120
+ t = op;
121
+ break;
122
+ case 4:
123
+ _.label++;
124
+ return {
125
+ value: op[1],
126
+ done: false
127
+ };
128
+ case 5:
129
+ _.label++;
130
+ y = op[1];
131
+ op = [
132
+ 0
133
+ ];
134
+ continue;
135
+ case 7:
136
+ op = _.ops.pop();
137
+ _.trys.pop();
138
+ continue;
139
+ default:
140
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
141
+ _ = 0;
142
+ continue;
143
+ }
144
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
145
+ _.label = op[1];
146
+ break;
147
+ }
148
+ if (op[0] === 6 && _.label < t[1]) {
149
+ _.label = t[1];
150
+ t = op;
151
+ break;
152
+ }
153
+ if (t && _.label < t[2]) {
154
+ _.label = t[2];
155
+ _.ops.push(op);
156
+ break;
157
+ }
158
+ if (t[2]) _.ops.pop();
159
+ _.trys.pop();
160
+ continue;
161
+ }
162
+ op = body.call(thisArg, _);
163
+ } catch (e) {
164
+ op = [
165
+ 6,
166
+ e
167
+ ];
168
+ y = 0;
169
+ } finally{
170
+ f = t = 0;
171
+ }
172
+ if (op[0] & 5) throw op[1];
173
+ return {
174
+ value: op[0] ? op[1] : void 0,
175
+ done: true
176
+ };
177
+ }
178
+ }
179
+ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
180
+ var e = new Error(message);
181
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
182
+ };
183
+
184
+ function _extends() {
185
+ _extends = Object.assign || function assign(target) {
186
+ for(var i = 1; i < arguments.length; i++){
187
+ var source = arguments[i];
188
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
189
+ }
190
+ return target;
191
+ };
192
+ return _extends.apply(this, arguments);
193
+ }
194
+
195
+ function _array_like_to_array(arr, len) {
196
+ if (len == null || len > arr.length) len = arr.length;
197
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
198
+ return arr2;
199
+ }
200
+
201
+ function _unsupported_iterable_to_array(o, minLen) {
202
+ if (!o) return;
203
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
204
+ var n = Object.prototype.toString.call(o).slice(8, -1);
205
+ if (n === "Object" && o.constructor) n = o.constructor.name;
206
+ if (n === "Map" || n === "Set") return Array.from(n);
207
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
208
+ }
209
+
210
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
211
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
212
+ if (it) return (it = it.call(o)).next.bind(it);
213
+ // Fallback for engines without symbol support
214
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
215
+ if (it) o = it;
216
+ var i = 0;
217
+ return function() {
218
+ if (i >= o.length) return {
219
+ done: true
220
+ };
221
+ return {
222
+ done: false,
223
+ value: o[i++]
224
+ };
225
+ };
226
+ }
227
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
228
+ }
229
+
230
+ var infoList = {
231
+ vender: [
232
+ "SAMSUNG"
233
+ ],
234
+ iPhone: [
235
+ {
236
+ name: "iPhone 15 Pro Max",
237
+ model: "iPhone16,2",
238
+ width: 1290,
239
+ height: 2796
240
+ },
241
+ {
242
+ name: "iPhone 15 Pro",
243
+ model: "iPhone16,1",
244
+ width: 1179,
245
+ height: 2556
246
+ },
247
+ {
248
+ name: "iPhone 15 Plus",
249
+ model: "iPhone15,5",
250
+ width: 1290,
251
+ height: 2796
252
+ },
253
+ {
254
+ name: "iPhone 15",
255
+ model: "iPhone15,4",
256
+ width: 1179,
257
+ height: 2556
258
+ },
259
+ {
260
+ name: "iPhone 14 Pro Max",
261
+ model: "iPhone15,3",
262
+ width: 1290,
263
+ height: 2796
264
+ },
265
+ {
266
+ name: "iPhone 14 Pro",
267
+ model: "iPhone15,2",
268
+ width: 1179,
269
+ height: 2556
270
+ },
271
+ {
272
+ name: "iPhone 14 Plus",
273
+ model: "iPhone14,8",
274
+ width: 1284,
275
+ height: 2778
276
+ },
277
+ {
278
+ name: "iPhone 14",
279
+ model: "iPhone14,7",
280
+ width: 1170,
281
+ height: 2532
282
+ },
283
+ {
284
+ name: "iPhone 13 Pro Max",
285
+ model: "iPhone14,3",
286
+ width: 1284,
287
+ height: 2778
288
+ },
289
+ {
290
+ name: "iPhone 13 Pro",
291
+ model: "iPhone14,2",
292
+ width: 1170,
293
+ height: 2532
294
+ },
295
+ {
296
+ name: "iPhone 13",
297
+ model: "iPhone14,5",
298
+ width: 1170,
299
+ height: 2532
300
+ },
301
+ {
302
+ name: "iPhone 13 mini",
303
+ model: "iPhone14,4",
304
+ width: 1080,
305
+ height: 2340
306
+ },
307
+ {
308
+ name: "iPhone SE (3rd gen)",
309
+ model: "iPhone14,6",
310
+ width: 750,
311
+ height: 1334
312
+ },
313
+ {
314
+ name: "iPhone 12 Pro Max",
315
+ model: "iPhone13,4",
316
+ width: 1284,
317
+ height: 2778
318
+ },
319
+ {
320
+ name: "iPhone 12 Pro",
321
+ model: "iPhone13,3",
322
+ width: 1170,
323
+ height: 2532
324
+ },
325
+ {
326
+ name: "iPhone 12",
327
+ model: "iPhone13,2",
328
+ width: 1170,
329
+ height: 2532
330
+ },
331
+ {
332
+ name: "iPhone 12 mini",
333
+ model: "iPhone13,1",
334
+ width: 1080,
335
+ height: 2340
336
+ },
337
+ {
338
+ name: "iPhone 11 Pro Max",
339
+ model: "iPhone12,5",
340
+ width: 1242,
341
+ height: 2688
342
+ },
343
+ {
344
+ name: "iPhone 11 Pro",
345
+ model: "iPhone12,3",
346
+ width: 1125,
347
+ height: 2436
348
+ },
349
+ {
350
+ name: "iPhone 11",
351
+ model: "iPhone12,1",
352
+ width: 828,
353
+ height: 1792
354
+ },
355
+ {
356
+ name: "iPhone SE (2nd gen)",
357
+ model: "iPhone12,8",
358
+ width: 750,
359
+ height: 1334
360
+ },
361
+ {
362
+ name: "iPhone XR",
363
+ model: "iPhone11,8",
364
+ width: 828,
365
+ height: 1792
366
+ },
367
+ {
368
+ name: "iPhone XS Max",
369
+ model: "iPhone11,6",
370
+ width: 1242,
371
+ height: 2688
372
+ },
373
+ {
374
+ name: "iPhone XS",
375
+ model: "iPhone11,2",
376
+ width: 1125,
377
+ height: 2436
378
+ },
379
+ {
380
+ name: "iPhone X",
381
+ model: "iPhone10,3",
382
+ width: 1125,
383
+ height: 2436
384
+ },
385
+ {
386
+ name: "iPhone 8 Plus",
387
+ model: "iPhone10,2",
388
+ width: 1080,
389
+ height: 1920
390
+ },
391
+ {
392
+ name: "iPhone 8",
393
+ model: "iPhone10,1",
394
+ width: 750,
395
+ height: 1334
396
+ },
397
+ {
398
+ name: "iPhone 7 Plus",
399
+ model: "iPhone9,2",
400
+ width: 1080,
401
+ height: 1920
402
+ },
403
+ {
404
+ name: "iPhone 7",
405
+ model: "iPhone9,1",
406
+ width: 750,
407
+ height: 1334
408
+ },
409
+ {
410
+ name: "iPhone 6s Plus",
411
+ model: "iPhone8,2",
412
+ width: 1080,
413
+ height: 1920
414
+ },
415
+ {
416
+ name: "iPhone 6s",
417
+ model: "iPhone8,1",
418
+ width: 750,
419
+ height: 1334
420
+ },
421
+ {
422
+ name: "iPhone SE (1st gen)",
423
+ model: "iPhone8,4",
424
+ width: 640,
425
+ height: 1136
426
+ },
427
+ {
428
+ name: "iPhone 6 Plus",
429
+ model: "iPhone7,1",
430
+ width: 1080,
431
+ height: 1920
432
+ },
433
+ {
434
+ name: "iPhone 6",
435
+ model: "iPhone7,2",
436
+ width: 750,
437
+ height: 1334
438
+ },
439
+ {
440
+ name: "iPhone 5C",
441
+ model: "iPhone5,3",
442
+ width: 640,
443
+ height: 1136
444
+ },
445
+ {
446
+ name: "iPhone 5S",
447
+ model: "iPhone6,1",
448
+ width: 640,
449
+ height: 1136
450
+ },
451
+ {
452
+ name: "iPhone 5",
453
+ model: "iPhone5,1",
454
+ width: 640,
455
+ height: 1136
456
+ },
457
+ {
458
+ name: "iPhone 4S",
459
+ model: "iPhone4,1",
460
+ width: 640,
461
+ height: 960
462
+ },
463
+ {
464
+ name: "iPhone 4",
465
+ model: "iPhone3,1",
466
+ width: 640,
467
+ height: 960
468
+ },
469
+ {
470
+ name: "iPhone 3GS",
471
+ model: "iPhone2,1",
472
+ width: 320,
473
+ height: 480
474
+ },
475
+ {
476
+ name: "iPhone 3G",
477
+ model: "iPhone1,2",
478
+ width: 320,
479
+ height: 480
480
+ },
481
+ {
482
+ name: "iPhone 1st gen",
483
+ model: "iPhone1,1",
484
+ width: 320,
485
+ height: 480
486
+ }
487
+ ]
488
+ };
489
+ var downgradeModels = {
490
+ android: [
491
+ "OPPO R9s Plus",
492
+ "GM1910",
493
+ "V1824A",
494
+ "V1916A",
495
+ "SM-G9650",
496
+ "V1936A",
497
+ "MI9 PRO 5G",
498
+ "REDMI K20",
499
+ "V1914A",
500
+ "GM1900",
501
+ "RMX1971",
502
+ "SM-A6060",
503
+ "SM-G9600",
504
+ "V1922A",
505
+ "PBAM00",
506
+ "PCAM10",
507
+ "PACT00",
508
+ "PBBM00",
509
+ "PCEM00",
510
+ "V1818A",
511
+ "vivo X6A",
512
+ "vivo X6Plus A"
513
+ ],
514
+ iPhone: [
515
+ "iPhone8,4",
516
+ "iPhone8,2",
517
+ "iPhone8,1",
518
+ "iPhone7,2",
519
+ "iPhone7,1",
520
+ "iPhone6,2",
521
+ "iPhone6,1",
522
+ "iPhone5,4",
523
+ "iPhone5,3",
524
+ "iPhone5,2",
525
+ "iPhone5,1",
526
+ "iPhone4,3",
527
+ "iPhone4,2",
528
+ "iPhone4,1",
529
+ "iPhone3,3",
530
+ "iPhone3,2",
531
+ "iPhone3,1",
532
+ "iPhone2,1",
533
+ "iPhone1,2",
534
+ "iPhone1,1"
535
+ ]
536
+ };
537
+ var downgradeVersions = {
538
+ android: [],
539
+ iOS: [
540
+ "16.7",
541
+ "16.7.1",
542
+ "16.7.2",
543
+ "16.7.3",
544
+ "16.7.4",
545
+ "16.7.5",
546
+ "16.7.6"
547
+ ]
548
+ };
549
+ var devtoolNameMap = {
550
+ wechat: {
551
+ "iPhone 6/7/8": "iPhone 8",
552
+ "iPhone 6/7/8 Plus": "iPhone 8 Plus",
553
+ "iPhone 12/13 mini": "iPhone 13 mini",
554
+ "iPhone 12/13 (Pro)": "iPhone 13 Pro",
555
+ "iPhone 12/13 Pro Max": "iPhone 13 Pro Max"
556
+ }
557
+ };
558
+
559
+ exports.DeviceLevel = void 0;
560
+ (function(DeviceLevel) {
561
+ DeviceLevel["High"] = "high";
562
+ DeviceLevel["Medium"] = "medium";
563
+ DeviceLevel["Low"] = "low";
564
+ DeviceLevel["Unknown"] = "unknown";
565
+ })(exports.DeviceLevel || (exports.DeviceLevel = {}));
566
+
567
+ var UADecoder = /*#__PURE__*/ function() {
568
+ function UADecoder(userAgent) {
569
+ this.device = {};
570
+ this.parse(userAgent != null ? userAgent : navigator.userAgent);
571
+ }
572
+ var _proto = UADecoder.prototype;
573
+ _proto.getDeviceInfo = function getDeviceInfo() {
574
+ return this.device;
575
+ };
576
+ _proto.isIOS = function isIOS() {
577
+ return this.device.platform === "iOS";
578
+ };
579
+ _proto.isAndroid = function isAndroid() {
580
+ return this.device.platform === "Android";
581
+ };
582
+ _proto.isHarmony = function isHarmony() {
583
+ return this.device.platform === "Harmony";
584
+ };
585
+ _proto.isWindows = function isWindows() {
586
+ return this.device.platform === "Windows";
587
+ };
588
+ _proto.isMacintosh = function isMacintosh() {
589
+ return this.device.platform === "Macintosh";
590
+ };
591
+ _proto.isMobile = function isMobile() {
592
+ return this.isIOS() || this.isAndroid() || this.isHarmony();
593
+ };
594
+ _proto.parse = function parse(ua) {
595
+ var pattern = /(\w+\/[\w.]+)(\s+\([^)]+\))?/g;
596
+ var productInfos = [];
597
+ var match;
598
+ while((match = pattern.exec(ua)) !== null){
599
+ var _match_;
600
+ var name = match[1];
601
+ var comment = (_match_ = match[2]) == null ? void 0 : _match_.trim();
602
+ productInfos.push({
603
+ name: name,
604
+ comment: comment
605
+ });
606
+ }
607
+ for(var _iterator = _create_for_of_iterator_helper_loose(productInfos), _step; !(_step = _iterator()).done;){
608
+ var productInfo = _step.value;
609
+ var name1 = productInfo.name, comment1 = productInfo.comment;
610
+ if (name1 == null ? void 0 : name1.startsWith("Mozilla/")) {
611
+ if (comment1) {
612
+ this.parseData(comment1);
613
+ }
614
+ break;
615
+ }
616
+ }
617
+ this.device.level = this.estimateDeviceLevel();
618
+ this.device.sourceData = ua;
619
+ };
620
+ _proto.parseData = function parseData(data) {
621
+ if (data.length && data[0] === "(") {
622
+ data = data.substring(1);
623
+ }
624
+ if (data.length && data[data.length - 1] == ")") {
625
+ data = data.substring(0, data.length - 1);
626
+ }
627
+ if (this.testIPhone(data)) {
628
+ this.device.platform = "iOS";
629
+ this.device.osVersion = this.parseIOSVersion(data);
630
+ this.device.model = this.getIPhoneModel();
631
+ } else if (this.testIPad(data)) {
632
+ this.device.platform = "iOS";
633
+ this.device.osVersion = this.parseIOSVersion(data);
634
+ this.device.model = "iPad";
635
+ } else if (this.testMacintosh(data)) {
636
+ this.device.platform = "Mac OS";
637
+ this.device.osVersion = this.parseMacOSVersion(data);
638
+ } else if (this.testAndroid(data)) {
639
+ this.device.platform = "Android";
640
+ this.device.osVersion = this.parseAndroidVersion(data);
641
+ this.device.model = this.parseAndroidModel(data);
642
+ } else if (this.testWindows(data)) {
643
+ this.device.platform = "Windows";
644
+ this.device.osVersion = this.parseWindowsVersion(data);
645
+ } else {
646
+ console.error("Unknown info: " + data + ".");
647
+ }
648
+ };
649
+ _proto.estimateDeviceLevel = function estimateDeviceLevel() {
650
+ if (this.isIOS()) {
651
+ if (this.device.osVersion) {
652
+ var osVersion = parseInt(this.device.osVersion.split(".")[0]);
653
+ if (osVersion < 12) {
654
+ return exports.DeviceLevel.Low;
655
+ } else if (osVersion < 16) {
656
+ return exports.DeviceLevel.Medium;
657
+ } else {
658
+ return exports.DeviceLevel.High;
659
+ }
660
+ } else {
661
+ return exports.DeviceLevel.Low;
662
+ }
663
+ }
664
+ if (this.isAndroid()) {
665
+ if (this.device.osVersion) {
666
+ var osVersion1 = parseInt(this.device.osVersion.split(".")[0]);
667
+ if (osVersion1 < 10) {
668
+ return exports.DeviceLevel.Low;
669
+ } else if (osVersion1 < 12) {
670
+ return exports.DeviceLevel.Medium;
671
+ } else {
672
+ return exports.DeviceLevel.High;
673
+ }
674
+ } else {
675
+ return exports.DeviceLevel.Low;
676
+ }
677
+ }
678
+ return exports.DeviceLevel.High;
679
+ };
680
+ _proto.parseIOSVersion = function parseIOSVersion(data) {
681
+ var pattern = /OS (\d+)(?:_(\d+))?_(\d+)/;
682
+ var match = data.match(pattern);
683
+ if (match) {
684
+ var versionList = [];
685
+ for(var i = 1; i <= 3; i++){
686
+ if (match[i]) {
687
+ versionList.push(match[i]);
688
+ }
689
+ }
690
+ return versionList.join(".");
691
+ }
692
+ };
693
+ _proto.getIPhoneModel = function getIPhoneModel() {
694
+ var screenWidth = window.screen.width * window.devicePixelRatio;
695
+ var screenHeight = window.screen.height * window.devicePixelRatio;
696
+ var match = infoList.iPhone.find(function(m) {
697
+ return m.width === screenWidth && m.height === screenHeight;
698
+ });
699
+ var _match_model;
700
+ return (_match_model = match == null ? void 0 : match.model) != null ? _match_model : "iPhone";
701
+ };
702
+ _proto.parseAndroidVersion = function parseAndroidVersion(data) {
703
+ var pattern = /Android ([\d.]+);/;
704
+ var match = data.match(pattern);
705
+ if (match && match.length >= 2) {
706
+ return match[1];
707
+ }
708
+ };
709
+ _proto.parseAndroidModel = function parseAndroidModel(data) {
710
+ var itemList = data.split(";");
711
+ var lastItem;
712
+ for(var _iterator = _create_for_of_iterator_helper_loose(itemList), _step; !(_step = _iterator()).done;){
713
+ var item = _step.value;
714
+ var modelPattern = /(.+?) Build/;
715
+ var modelMatch = item.match(modelPattern);
716
+ if (modelMatch && modelMatch.length >= 2) {
717
+ return modelMatch[1].trim();
718
+ }
719
+ if (item.includes("HMSCore") && lastItem) {
720
+ return lastItem.trim();
721
+ }
722
+ lastItem = item;
723
+ }
724
+ if (itemList.length > 0) {
725
+ var lastItem1 = itemList[itemList.length - 1].trim();
726
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(infoList.vender), _step1; !(_step1 = _iterator1()).done;){
727
+ var vender = _step1.value;
728
+ if (lastItem1.startsWith(vender)) {
729
+ return lastItem1.substring(vender.length).trim();
730
+ }
731
+ }
732
+ }
733
+ if (itemList.length == 3) {
734
+ return itemList[itemList.length - 1].trim();
735
+ } else if (itemList.length === 4) {
736
+ var len = itemList.length;
737
+ if (itemList[len - 1].trim() === "wv") {
738
+ return itemList[len - 2].trim();
739
+ }
740
+ }
741
+ };
742
+ _proto.parseWindowsVersion = function parseWindowsVersion(data) {
743
+ var pattern = /Windows NT ([\d.]+);/;
744
+ var match = data.match(pattern);
745
+ if (match && match.length >= 2) {
746
+ return match[1];
747
+ }
748
+ };
749
+ _proto.parseMacOSVersion = function parseMacOSVersion(data) {
750
+ var pattern = /OS X (\d+)(?:_(\d+))?_(\d+)/;
751
+ var match = data.match(pattern);
752
+ if (match) {
753
+ var versionList = [];
754
+ for(var i = 1; i <= 3; i++){
755
+ if (match[i]) {
756
+ versionList.push(match[i]);
757
+ }
758
+ }
759
+ return versionList.join(".");
760
+ }
761
+ };
762
+ _proto.testIPhone = function testIPhone(data) {
763
+ return data.includes("iPhone");
764
+ };
765
+ _proto.testIPad = function testIPad(data) {
766
+ return data.includes("iPad");
767
+ };
768
+ _proto.testAndroid = function testAndroid(data) {
769
+ return data.includes("Android");
770
+ };
771
+ _proto.testMacintosh = function testMacintosh(data) {
772
+ return data.includes("Macintosh");
773
+ };
774
+ _proto.testWindows = function testWindows(data) {
775
+ return data.includes("Windows");
776
+ };
777
+ return UADecoder;
778
+ }();
779
+
780
+ var AlipayMiniprogramParser = /*#__PURE__*/ function() {
781
+ function AlipayMiniprogramParser(info) {
782
+ this.device = {};
783
+ this.parse(info);
784
+ }
785
+ var _proto = AlipayMiniprogramParser.prototype;
786
+ _proto.getDeviceInfo = function getDeviceInfo() {
787
+ return this.device;
788
+ };
789
+ _proto.parse = function parse(info) {
790
+ this.device.platform = info.platform;
791
+ this.device.osVersion = info.system;
792
+ this.device.originalModel = info.model;
793
+ this.device.model = this.getDeviceModel(info.model);
794
+ this.device.level = this.getDeviceLevel(info.performance);
795
+ this.device.sourceData = info;
796
+ };
797
+ _proto.getDeviceModel = function getDeviceModel(model) {
798
+ if (model) {
799
+ var brandList = [
800
+ "Huawei",
801
+ "Xiaomi",
802
+ "samsung",
803
+ "vivo",
804
+ "OPPO"
805
+ ];
806
+ var brand = brandList.find(function(b) {
807
+ return (model != null ? model : "").toLowerCase().startsWith(b.toLowerCase());
808
+ });
809
+ if (brand) {
810
+ return model == null ? void 0 : model.substring(brand.length).trim();
811
+ }
812
+ }
813
+ return model;
814
+ };
815
+ _proto.getDeviceLevel = function getDeviceLevel(level) {
816
+ if (level === void 0) level = "";
817
+ var levelMap = {
818
+ "high": exports.DeviceLevel.High,
819
+ "medium": exports.DeviceLevel.Medium,
820
+ "middle": exports.DeviceLevel.Medium,
821
+ "low": exports.DeviceLevel.Low
822
+ };
823
+ return levelMap[level] || exports.DeviceLevel.Unknown;
824
+ };
825
+ return AlipayMiniprogramParser;
826
+ }();
827
+
828
+ var WechatMiniprogramParser = /*#__PURE__*/ function() {
829
+ function WechatMiniprogramParser(info) {
830
+ this.device = {};
831
+ this.parse(info);
832
+ }
833
+ var _proto = WechatMiniprogramParser.prototype;
834
+ _proto.getDeviceInfo = function getDeviceInfo() {
835
+ return this.device;
836
+ };
837
+ _proto.parse = function parse(info) {
838
+ var osNameMatch = info.system.match(/\w+/);
839
+ if (osNameMatch) {
840
+ this.device.platform = osNameMatch[0].trim();
841
+ }
842
+ var osVersionMatch = info.system.match(/[\d.]+/);
843
+ if (osVersionMatch) {
844
+ this.device.osVersion = osVersionMatch[0].trim();
845
+ }
846
+ if (info.platform === "devtools") {
847
+ var _devtoolNameMap_wechat_info_model;
848
+ var phoneName = (_devtoolNameMap_wechat_info_model = devtoolNameMap.wechat[info.model]) != null ? _devtoolNameMap_wechat_info_model : info.model;
849
+ for(var _iterator = _create_for_of_iterator_helper_loose(infoList.iPhone), _step; !(_step = _iterator()).done;){
850
+ var data = _step.value;
851
+ if (data.name === phoneName) {
852
+ info.model = data.model;
853
+ break;
854
+ }
855
+ }
856
+ }
857
+ if (this.device.platform === "iOS") {
858
+ var modelMatch = info.model.match(/^(.*?)<(.*?)>$/);
859
+ if (modelMatch) {
860
+ this.device.model = modelMatch[2].trim();
861
+ this.device.originalModel = info.model;
862
+ } else {
863
+ this.device.model = info.model;
864
+ }
865
+ } else {
866
+ this.device.model = info.model;
867
+ }
868
+ if (info.benchmarkLevel <= 0) {
869
+ this.device.level = exports.DeviceLevel.Unknown;
870
+ } else if (info.benchmarkLevel <= 10) {
871
+ this.device.level = exports.DeviceLevel.Low;
872
+ } else if (info.benchmarkLevel <= 20) {
873
+ this.device.level = exports.DeviceLevel.Medium;
874
+ } else {
875
+ this.device.level = exports.DeviceLevel.High;
876
+ }
877
+ this.device.memoryMB = info.memorySize;
878
+ this.device.sourceData = info;
879
+ };
880
+ return WechatMiniprogramParser;
881
+ }();
882
+
883
+ var DowngradeJudge = /*#__PURE__*/ function() {
884
+ function DowngradeJudge(options, device) {
885
+ this.options = options;
886
+ this.device = device;
887
+ this.isIOS = false;
888
+ }
889
+ var _proto = DowngradeJudge.prototype;
890
+ _proto.getDowngradeResult = function getDowngradeResult() {
891
+ var _this = this;
892
+ var downgradeCallback = this.options.downgradeCallback;
893
+ if (downgradeCallback) {
894
+ var result = downgradeCallback(this.device);
895
+ if (result) {
896
+ if (!result.reason) {
897
+ result.reason = "downgradeCallback";
898
+ }
899
+ return result;
900
+ }
901
+ }
902
+ this.isIOS = this.device.platform === "iOS";
903
+ this.level = this.getRenderLevel();
904
+ if (this.device.model) {
905
+ var deviceModel = this.device.model.toLowerCase();
906
+ var modelList = this.isIOS ? downgradeModels.iPhone : downgradeModels.android;
907
+ var findModel = modelList.find(function(m) {
908
+ var testModel = m.toLowerCase();
909
+ if (_this.isIOS) {
910
+ return testModel === deviceModel;
911
+ } else {
912
+ return testModel.includes(deviceModel) || deviceModel.includes(testModel);
913
+ }
914
+ });
915
+ if (findModel !== undefined) {
916
+ return {
917
+ downgrade: true,
918
+ level: this.level,
919
+ reason: "Downgrade by model list",
920
+ deviceInfo: this.device
921
+ };
922
+ }
923
+ }
924
+ var osVersionList = this.isIOS ? downgradeVersions.iOS : downgradeVersions.android;
925
+ var findOS = osVersionList.find(function(v) {
926
+ return v === _this.device.osVersion;
927
+ });
928
+ if (findOS !== undefined) {
929
+ return {
930
+ downgrade: true,
931
+ level: this.level,
932
+ reason: "Downgrade by OS version list",
933
+ deviceInfo: this.device
934
+ };
935
+ }
936
+ return {
937
+ downgrade: false,
938
+ level: this.level,
939
+ reason: "",
940
+ deviceInfo: this.device
941
+ };
942
+ };
943
+ _proto.getRenderLevel = function getRenderLevel() {
944
+ if (this.device.level) {
945
+ if (this.device.level === exports.DeviceLevel.High) {
946
+ return EFFECTS.spec.RenderLevel.S;
947
+ } else if (this.device.level === exports.DeviceLevel.Medium) {
948
+ return EFFECTS.spec.RenderLevel.A;
949
+ } else if (this.device.level === exports.DeviceLevel.Low) {
950
+ return EFFECTS.spec.RenderLevel.B;
951
+ }
952
+ }
953
+ if (this.device.memoryMB) {
954
+ if (this.device.memoryMB < 4000) {
955
+ return EFFECTS.spec.RenderLevel.B;
956
+ } else if (this.device.memoryMB < 6000) {
957
+ return EFFECTS.spec.RenderLevel.A;
958
+ } else {
959
+ return EFFECTS.spec.RenderLevel.S;
960
+ }
961
+ }
962
+ if (this.isIOS && this.device.model) {
963
+ if (/iPhone(\d+),/.test(this.device.model)) {
964
+ var gen = +RegExp.$1;
965
+ if (gen <= 9) {
966
+ return EFFECTS.spec.RenderLevel.B;
967
+ } else if (gen < 10) {
968
+ return EFFECTS.spec.RenderLevel.A;
969
+ } else {
970
+ return EFFECTS.spec.RenderLevel.S;
971
+ }
972
+ }
973
+ }
974
+ return this.isIOS ? EFFECTS.spec.RenderLevel.S : EFFECTS.spec.RenderLevel.B;
975
+ };
976
+ return DowngradeJudge;
977
+ }();
978
+
979
+ var internalPaused = Symbol("@@_inter_pause");
980
+ var hasRegisterEvent = false;
981
+ function getDowngradeResult(options) {
982
+ if (options === void 0) options = {};
983
+ if (!hasRegisterEvent) {
984
+ registerEvent(options);
985
+ hasRegisterEvent = true;
986
+ }
987
+ var mock = options.mock;
988
+ if (mock) {
989
+ return _extends({}, mock, {
990
+ reason: "mock"
991
+ });
992
+ }
993
+ var device = getDeviceInfo(options);
994
+ var judge = new DowngradeJudge(options, device);
995
+ return judge.getDowngradeResult();
996
+ }
997
+ function registerEvent(options) {
998
+ var autoPause = options.autoPause;
999
+ window.addEventListener("unload", function() {
1000
+ EFFECTS.getActivePlayers().forEach(function(player) {
1001
+ return player.dispose();
1002
+ });
1003
+ });
1004
+ if (autoPause) {
1005
+ document.addEventListener("pause", pauseAllActivePlayers);
1006
+ document.addEventListener("resume", resumePausedPlayers);
1007
+ }
1008
+ }
1009
+ function getDeviceInfo(options) {
1010
+ var queryDeviceInMiniApp = options.queryDeviceInMiniApp, deviceInfo = options.deviceInfo;
1011
+ if (deviceInfo) {
1012
+ return deviceInfo;
1013
+ }
1014
+ if (queryDeviceInMiniApp) {
1015
+ if (EFFECTS.isAlipayMiniApp()) {
1016
+ // 支付宝小程序
1017
+ if (my.canIUse("getSystemInfo")) {
1018
+ // https://opendocs.alipay.com/mini/api/system-info
1019
+ var info = my.getSystemInfo();
1020
+ var parser = new AlipayMiniprogramParser(info);
1021
+ return parser.getDeviceInfo();
1022
+ } else {
1023
+ EFFECTS.logger.error("Can't use getSystemInfo in Alipay MiniProgram.");
1024
+ }
1025
+ }
1026
+ if (EFFECTS.isWechatMiniApp()) {
1027
+ // 微信小程序
1028
+ // @ts-expect-error
1029
+ if (wx.canIUse("getDeviceInfo")) {
1030
+ // https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.getDeviceInfo.html
1031
+ // @ts-expect-error
1032
+ var info1 = wx.getDeviceInfo();
1033
+ var parser1 = new WechatMiniprogramParser(info1);
1034
+ return parser1.getDeviceInfo();
1035
+ } else {
1036
+ EFFECTS.logger.error("Can't use getDeviceInfo in WeChat MiniProgram.");
1037
+ }
1038
+ } else {
1039
+ EFFECTS.logger.error("Non-mini program environment and try to get device info from user agent.");
1040
+ }
1041
+ }
1042
+ return new UADecoder().getDeviceInfo();
1043
+ }
1044
+ function getDefaultRenderLevel() {
1045
+ return EFFECTS.isIOS() ? EFFECTS.spec.RenderLevel.S : EFFECTS.spec.RenderLevel.B;
1046
+ }
1047
+ function pauseAllActivePlayers(e) {
1048
+ if (e.target === document) {
1049
+ EFFECTS.logger.info("Auto pause all players with data offloaded.");
1050
+ var players = EFFECTS.getActivePlayers();
1051
+ players.forEach(function(player) {
1052
+ if (!player.paused) {
1053
+ player.pause({
1054
+ offloadTexture: true
1055
+ });
1056
+ // @ts-expect-error
1057
+ player[internalPaused] = true;
1058
+ }
1059
+ });
1060
+ }
1061
+ }
1062
+ function resumePausedPlayers(e) {
1063
+ if (e.target === document) {
1064
+ EFFECTS.logger.info("Auto resume all players.");
1065
+ var players = EFFECTS.getActivePlayers();
1066
+ players.forEach(function(player) {
1067
+ // @ts-expect-error
1068
+ if (player[internalPaused]) {
1069
+ void player.resume();
1070
+ // @ts-expect-error
1071
+ player[internalPaused] = false;
1072
+ }
1073
+ });
1074
+ }
1075
+ }
1076
+
1077
+ var DowngradePlugin = /*#__PURE__*/ function(AbstractPlugin) {
1078
+ _inherits(DowngradePlugin, AbstractPlugin);
1079
+ function DowngradePlugin() {
1080
+ return AbstractPlugin.apply(this, arguments);
1081
+ }
1082
+ DowngradePlugin.processRawJSON = function processRawJSON(json, options) {
1083
+ if (options === void 0) options = {};
1084
+ return _async_to_generator(function() {
1085
+ var _options_pluginData, downgradeResult, _downgradeResult_renderLevel;
1086
+ return __generator(this, function(_state) {
1087
+ downgradeResult = (_options_pluginData = options.pluginData) == null ? void 0 : _options_pluginData["downgrade"];
1088
+ if (downgradeResult) {
1089
+ if (downgradeResult.downgrade) {
1090
+ throw new Error("Downgraded, reason: " + downgradeResult.reason + ".");
1091
+ }
1092
+ } else {
1093
+ EFFECTS.logger.warn("No downgrade result in pluginData of SceneLoadOptions.");
1094
+ }
1095
+ if (!options.renderLevel) {
1096
+ options.renderLevel = (_downgradeResult_renderLevel = downgradeResult == null ? void 0 : downgradeResult.renderLevel) != null ? _downgradeResult_renderLevel : getDefaultRenderLevel();
1097
+ }
1098
+ return [
1099
+ 2
1100
+ ];
1101
+ });
1102
+ })();
1103
+ };
1104
+ return DowngradePlugin;
1105
+ }(EFFECTS.AbstractPlugin);
1106
+
1107
+ var version = "2.0.0-alpha.28";
1108
+ EFFECTS.registerPlugin("downgrade", DowngradePlugin, EFFECTS.VFXItem, true);
1109
+ EFFECTS.logger.info("Plugin downgrade version: " + version + ".");
1110
+ if (version !== EFFECTS__namespace.version) {
1111
+ console.error("注意:请统一 Downgrade 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Downgrade plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
1112
+ }
1113
+
1114
+ exports.AlipayMiniprogramParser = AlipayMiniprogramParser;
1115
+ exports.UADecoder = UADecoder;
1116
+ exports.WechatMiniprogramParser = WechatMiniprogramParser;
1117
+ exports.getDefaultRenderLevel = getDefaultRenderLevel;
1118
+ exports.getDowngradeResult = getDowngradeResult;
1119
+ exports.version = version;
1120
+ //# sourceMappingURL=index.js.map