@galacean/effects-plugin-downgrade 0.0.0-experimental-20250512

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