@galacean/effects-plugin-downgrade 2.3.0-alpha.2 → 2.3.0-beta.0

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