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