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