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

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