@galacean/effects-plugin-alipay-downgrade 2.0.0-alpha.4 → 2.0.0-alpha.6

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 CHANGED
@@ -2,8 +2,8 @@
2
2
  * Name: @galacean/effects-plugin-alipay-downgrade
3
3
  * Description: Galacean Effects player downgrade plugin for Alipay
4
4
  * Author: Ant Group CO., Ltd.
5
- * Contributors: 燃然,意绮
6
- * Version: v2.0.0-alpha.4
5
+ * Contributors: 燃然,意绮,飂兮
6
+ * Version: v2.0.0-alpha.6
7
7
  */
8
8
 
9
9
  'use strict';
@@ -12,245 +12,326 @@ Object.defineProperty(exports, '__esModule', { value: true });
12
12
 
13
13
  var effects = require('@galacean/effects');
14
14
 
15
- /******************************************************************************
16
- Copyright (c) Microsoft Corporation.
17
-
18
- Permission to use, copy, modify, and/or distribute this software for any
19
- purpose with or without fee is hereby granted.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
22
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
23
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
24
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
25
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
- PERFORMANCE OF THIS SOFTWARE.
28
- ***************************************************************************** */
29
- /* global Reflect, Promise, SuppressedError, Symbol */
30
-
31
- var extendStatics = function(d, b) {
32
- extendStatics = Object.setPrototypeOf ||
33
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
35
- return extendStatics(d, b);
36
- };
37
-
38
- function __extends(d, b) {
39
- if (typeof b !== "function" && b !== null)
40
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
41
- extendStatics(d, b);
42
- function __() { this.constructor = d; }
43
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44
- }
45
-
46
- function __awaiter(thisArg, _arguments, P, generator) {
47
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
48
- return new (P || (P = Promise))(function (resolve, reject) {
49
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
50
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
51
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
52
- step((generator = generator.apply(thisArg, _arguments || [])).next());
53
- });
54
- }
55
-
56
- function __generator(thisArg, body) {
57
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
58
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
59
- function verb(n) { return function (v) { return step([n, v]); }; }
60
- function step(op) {
61
- if (f) throw new TypeError("Generator is already executing.");
62
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
63
- 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;
64
- if (y = 0, t) op = [op[0] & 2, t.value];
65
- switch (op[0]) {
66
- case 0: case 1: t = op; break;
67
- case 4: _.label++; return { value: op[1], done: false };
68
- case 5: _.label++; y = op[1]; op = [0]; continue;
69
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
70
- default:
71
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
72
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
73
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
74
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
75
- if (t[2]) _.ops.pop();
76
- _.trys.pop(); continue;
77
- }
78
- op = body.call(thisArg, _);
79
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
80
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
81
- }
82
- }
83
-
84
- function __read(o, n) {
85
- var m = typeof Symbol === "function" && o[Symbol.iterator];
86
- if (!m) return o;
87
- var i = m.call(o), r, ar = [], e;
88
- try {
89
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
90
- }
91
- catch (error) { e = { error: error }; }
92
- finally {
93
- try {
94
- if (r && !r.done && (m = i["return"])) m.call(i);
95
- }
96
- finally { if (e) throw e.error; }
97
- }
98
- return ar;
99
- }
100
-
101
- function __spreadArray(to, from, pack) {
102
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
103
- if (ar || !(i in from)) {
104
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
105
- ar[i] = from[i];
106
- }
107
- }
108
- return to.concat(ar || Array.prototype.slice.call(from));
109
- }
110
-
111
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
112
- var e = new Error(message);
113
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
114
- };
15
+ function _set_prototype_of(o, p) {
16
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
17
+ o.__proto__ = p;
18
+ return o;
19
+ };
20
+ return _set_prototype_of(o, p);
21
+ }
115
22
 
116
- var DowngradeVFXItem = /** @class */ (function (_super) {
117
- __extends(DowngradeVFXItem, _super);
23
+ function _inherits(subClass, superClass) {
24
+ if (typeof superClass !== "function" && superClass !== null) {
25
+ throw new TypeError("Super expression must either be null or a function");
26
+ }
27
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
28
+ constructor: {
29
+ value: subClass,
30
+ writable: true,
31
+ configurable: true
32
+ }
33
+ });
34
+ if (superClass) _set_prototype_of(subClass, superClass);
35
+ }
36
+
37
+ var DowngradeVFXItem = /*#__PURE__*/ function(VFXItem) {
38
+ _inherits(DowngradeVFXItem, VFXItem);
118
39
  function DowngradeVFXItem() {
119
- return _super !== null && _super.apply(this, arguments) || this;
40
+ return VFXItem.apply(this, arguments);
120
41
  }
121
42
  return DowngradeVFXItem;
122
- }(effects.VFXItem));
43
+ }(effects.VFXItem);
44
+
45
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
46
+ try {
47
+ var info = gen[key](arg);
48
+ var value = info.value;
49
+ } catch (error) {
50
+ reject(error);
51
+ return;
52
+ }
53
+ if (info.done) resolve(value);
54
+ else Promise.resolve(value).then(_next, _throw);
55
+ }
56
+ function _async_to_generator(fn) {
57
+ return function() {
58
+ var self = this, args = arguments;
59
+ return new Promise(function(resolve, reject) {
60
+ var gen = fn.apply(self, args);
61
+ function _next(value) {
62
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
63
+ }
64
+ function _throw(err) {
65
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
66
+ }
67
+ _next(undefined);
68
+ });
69
+ };
70
+ }
123
71
 
124
- var mockIdPass = 'mock-pass';
125
- var mockIdFail = 'mock-fail';
126
- var DEVICE_LEVEL_HIGH = 'high';
127
- var DEVICE_LEVEL_MEDIUM = 'medium';
128
- var DEVICE_LEVEL_LOW = 'low';
129
- var DEVICE_LEVEL_NONE = 'none';
72
+ function __generator(thisArg, body) {
73
+ var _ = {
74
+ label: 0,
75
+ sent: function sent() {
76
+ if (t[0] & 1) throw t[1];
77
+ return t[1];
78
+ },
79
+ trys: [],
80
+ ops: []
81
+ }, f, y, t, g;
82
+ return g = {
83
+ next: verb(0),
84
+ "throw": verb(1),
85
+ "return": verb(2)
86
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
87
+ return this;
88
+ }), g;
89
+ function verb(n) {
90
+ return function(v) {
91
+ return step([
92
+ n,
93
+ v
94
+ ]);
95
+ };
96
+ }
97
+ function step(op) {
98
+ if (f) throw new TypeError("Generator is already executing.");
99
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
100
+ 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;
101
+ if (y = 0, t) op = [
102
+ op[0] & 2,
103
+ t.value
104
+ ];
105
+ switch(op[0]){
106
+ case 0:
107
+ case 1:
108
+ t = op;
109
+ break;
110
+ case 4:
111
+ _.label++;
112
+ return {
113
+ value: op[1],
114
+ done: false
115
+ };
116
+ case 5:
117
+ _.label++;
118
+ y = op[1];
119
+ op = [
120
+ 0
121
+ ];
122
+ continue;
123
+ case 7:
124
+ op = _.ops.pop();
125
+ _.trys.pop();
126
+ continue;
127
+ default:
128
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
129
+ _ = 0;
130
+ continue;
131
+ }
132
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
133
+ _.label = op[1];
134
+ break;
135
+ }
136
+ if (op[0] === 6 && _.label < t[1]) {
137
+ _.label = t[1];
138
+ t = op;
139
+ break;
140
+ }
141
+ if (t && _.label < t[2]) {
142
+ _.label = t[2];
143
+ _.ops.push(op);
144
+ break;
145
+ }
146
+ if (t[2]) _.ops.pop();
147
+ _.trys.pop();
148
+ continue;
149
+ }
150
+ op = body.call(thisArg, _);
151
+ } catch (e) {
152
+ op = [
153
+ 6,
154
+ e
155
+ ];
156
+ y = 0;
157
+ } finally{
158
+ f = t = 0;
159
+ }
160
+ if (op[0] & 5) throw op[1];
161
+ return {
162
+ value: op[0] ? op[1] : void 0,
163
+ done: true
164
+ };
165
+ }
166
+ }
167
+ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
168
+ var e = new Error(message);
169
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
170
+ };
171
+
172
+ var mockIdPass = "mock-pass";
173
+ var mockIdFail = "mock-fail";
174
+ var DEVICE_LEVEL_HIGH = "high";
175
+ var DEVICE_LEVEL_MEDIUM = "medium";
176
+ var DEVICE_LEVEL_LOW = "low";
177
+ var DEVICE_LEVEL_NONE = "none";
130
178
  var hasRegisterEvent = false;
131
- function getDowngradeResult(bizId, options) {
132
- if (options === void 0) { options = {}; }
133
- return __awaiter(this, void 0, void 0, function () {
134
- var ap, now_1;
135
- return __generator(this, function (_a) {
179
+ function getDowngradeResult(bizId) {
180
+ return _getDowngradeResult.apply(this, arguments);
181
+ }
182
+ function _getDowngradeResult() {
183
+ _getDowngradeResult = _async_to_generator(function(bizId, options) {
184
+ var ap, now;
185
+ return __generator(this, function(_state) {
186
+ if (options === void 0) options = {};
136
187
  if (!hasRegisterEvent) {
137
188
  registerEvent(options);
138
189
  hasRegisterEvent = true;
139
190
  }
140
191
  if (bizId === mockIdFail || bizId === mockIdPass) {
141
- return [2 /*return*/, Promise.resolve({ mock: { downgrade: bizId === mockIdFail } })];
192
+ return [
193
+ 2,
194
+ Promise.resolve({
195
+ mock: {
196
+ downgrade: bizId === mockIdFail
197
+ }
198
+ })
199
+ ];
142
200
  }
143
201
  ap = window.AlipayJSBridge;
144
202
  if (ap) {
145
- now_1 = performance.now();
146
- return [2 /*return*/, getSystemInfo().then(function (systemInfo) {
147
- return new Promise(function (resolve) {
148
- var _a;
149
- var techPoint = ['mars'];
203
+ now = performance.now();
204
+ return [
205
+ 2,
206
+ getSystemInfo().then(function(systemInfo) {
207
+ return new Promise(function(resolve) {
208
+ var techPoint = [
209
+ "mars"
210
+ ];
150
211
  var tc = options.techPoint;
151
212
  if (tc) {
152
- techPoint.push.apply(techPoint, __spreadArray([], __read(tc), false));
213
+ var _techPoint;
214
+ (_techPoint = techPoint).push.apply(_techPoint, [].concat(tc));
153
215
  }
154
216
  var downgradeOptions = {
155
217
  bizId: bizId,
156
218
  scene: 0,
157
219
  ext: {
158
- techPoint: techPoint,
159
- },
220
+ techPoint: techPoint
221
+ }
160
222
  };
161
- var downgradeCallback = function (result) {
162
- var totalTime = performance.now() - now_1;
163
- console.info("downgrade time: ".concat(totalTime, "ms"));
164
- resolve({ bizId: bizId, systemInfo: systemInfo, downgradeResult: result, totalTime: totalTime });
223
+ var downgradeCallback = function(result) {
224
+ var totalTime = performance.now() - now;
225
+ console.info("downgrade time: " + totalTime + "ms");
226
+ resolve({
227
+ bizId: bizId,
228
+ systemInfo: systemInfo,
229
+ downgradeResult: result,
230
+ totalTime: totalTime
231
+ });
165
232
  };
166
- var callBridge = (_a = options.callBridge) !== null && _a !== void 0 ? _a : ap.call;
167
- callBridge('getDowngradeResult', downgradeOptions, downgradeCallback);
233
+ var _options_callBridge;
234
+ var callBridge = (_options_callBridge = options.callBridge) != null ? _options_callBridge : ap.call;
235
+ callBridge("getDowngradeResult", downgradeOptions, downgradeCallback);
168
236
  });
169
- })];
170
- }
171
- else {
172
- return [2 /*return*/, Promise.resolve({ noAlipayEnv: true })];
237
+ })
238
+ ];
239
+ } else {
240
+ return [
241
+ 2,
242
+ Promise.resolve({
243
+ noAlipayEnv: true
244
+ })
245
+ ];
173
246
  }
174
247
  });
175
248
  });
249
+ return _getDowngradeResult.apply(this, arguments);
176
250
  }
177
251
  function registerEvent(options) {
178
252
  var ignoreGLLost = options.ignoreGLLost, autoPause = options.autoPause;
179
253
  var downgradeWhenGLLost = ignoreGLLost !== true;
180
- window.addEventListener('unload', function () {
181
- effects.getActivePlayers().forEach(function (player) { return player.dispose(); });
254
+ window.addEventListener("unload", function() {
255
+ effects.getActivePlayers().forEach(function(player) {
256
+ return player.dispose();
257
+ });
182
258
  });
183
- window.addEventListener('webglcontextlost', function (e) {
259
+ window.addEventListener("webglcontextlost", function(e) {
184
260
  if (effects.isCanvasUsedByPlayer(e.target)) {
185
261
  AlipayDowngradePlugin.glLostOccurred = true;
186
- console.error('webgl lost occur');
262
+ console.error("webgl lost occur");
187
263
  if (downgradeWhenGLLost) {
188
- console.warn('webgl lost occur, all players will be downgraded from now on');
264
+ console.warn("webgl lost occur, all players will be downgraded from now on");
189
265
  effects.disableAllPlayer(true);
190
- effects.getActivePlayers().forEach(function (player) { return player.dispose(); });
266
+ effects.getActivePlayers().forEach(function(player) {
267
+ return player.dispose();
268
+ });
191
269
  }
192
270
  }
193
271
  }, true);
194
272
  if (autoPause) {
195
- document.addEventListener('pause', pauseAllActivePlayers);
196
- document.addEventListener('resume', resumePausedPlayers);
273
+ document.addEventListener("pause", pauseAllActivePlayers);
274
+ document.addEventListener("resume", resumePausedPlayers);
197
275
  }
198
276
  }
199
277
  function getSystemInfo() {
200
- return __awaiter(this, void 0, void 0, function () {
201
- return __generator(this, function (_a) {
202
- return [2 /*return*/, new Promise(function (resolve, reject) {
278
+ return _getSystemInfo.apply(this, arguments);
279
+ }
280
+ function _getSystemInfo() {
281
+ _getSystemInfo = _async_to_generator(function() {
282
+ return __generator(this, function(_state) {
283
+ return [
284
+ 2,
285
+ new Promise(function(resolve, reject) {
203
286
  var ap = window.AlipayJSBridge;
204
287
  if (ap) {
205
- ap.call('getSystemInfo', function (e) {
288
+ ap.call("getSystemInfo", function(e) {
206
289
  if (e.error) {
207
290
  reject(e);
208
- }
209
- else {
291
+ } else {
210
292
  resolve(e);
211
293
  }
212
294
  });
295
+ } else {
296
+ reject("no ap");
213
297
  }
214
- else {
215
- reject('no ap');
216
- }
217
- })];
298
+ })
299
+ ];
218
300
  });
219
301
  });
302
+ return _getSystemInfo.apply(this, arguments);
220
303
  }
221
- var DeviceProxy = /** @class */ (function () {
304
+ var DeviceProxy = /*#__PURE__*/ function() {
222
305
  function DeviceProxy() {
223
306
  this.isIOS = false;
224
- this.model = 'DESKTOP_DEBUG';
307
+ this.model = "DESKTOP_DEBUG";
225
308
  this.deviceLevel = DEVICE_LEVEL_NONE;
226
309
  this.isDowngrade = false;
227
310
  }
228
- DeviceProxy.prototype.getRenderLevel = function () {
311
+ var _proto = DeviceProxy.prototype;
312
+ _proto.getRenderLevel = function getRenderLevel() {
229
313
  if (this.deviceLevel === DEVICE_LEVEL_HIGH) {
230
314
  return effects.spec.RenderLevel.S;
231
- }
232
- else if (this.deviceLevel === DEVICE_LEVEL_MEDIUM) {
315
+ } else if (this.deviceLevel === DEVICE_LEVEL_MEDIUM) {
233
316
  return effects.spec.RenderLevel.A;
234
- }
235
- else if (this.deviceLevel === DEVICE_LEVEL_LOW) {
317
+ } else if (this.deviceLevel === DEVICE_LEVEL_LOW) {
236
318
  return effects.spec.RenderLevel.B;
237
- }
238
- else {
319
+ } else {
239
320
  return this.isIOS ? effects.spec.RenderLevel.S : effects.spec.RenderLevel.B;
240
321
  }
241
322
  };
242
- DeviceProxy.prototype.hasDeviceLevel = function () {
323
+ _proto.hasDeviceLevel = function hasDeviceLevel() {
243
324
  return isDeviceLevel(this.deviceLevel);
244
325
  };
245
- DeviceProxy.prototype.setBySystemInfo = function (systemInfo) {
246
- var performance = systemInfo.performance, platform = systemInfo.platform, _a = systemInfo.model, model = _a === void 0 ? 'UNKNOWN_DEVICE' : _a;
247
- this.isIOS = platform === 'iOS';
326
+ _proto.setBySystemInfo = function setBySystemInfo(systemInfo) {
327
+ var performance1 = systemInfo.performance, platform = systemInfo.platform, _systemInfo_model = systemInfo.model, model = _systemInfo_model === void 0 ? "UNKNOWN_DEVICE" : _systemInfo_model;
328
+ this.isIOS = platform === "iOS";
248
329
  this.model = model;
249
- if (performance && !this.hasDeviceLevel()) {
250
- this.deviceLevel = performance;
330
+ if (performance1 && !this.hasDeviceLevel()) {
331
+ this.deviceLevel = performance1;
251
332
  }
252
333
  };
253
- DeviceProxy.prototype.updateDeviceLevel = function () {
334
+ _proto.updateDeviceLevel = function updateDeviceLevel() {
254
335
  if (this.hasDeviceLevel()) {
255
336
  return;
256
337
  }
@@ -258,39 +339,49 @@ var DeviceProxy = /** @class */ (function () {
258
339
  var gen = +RegExp.$1;
259
340
  if (gen <= 9) {
260
341
  this.deviceLevel = DEVICE_LEVEL_LOW;
261
- }
262
- else if (gen < 10) {
342
+ } else if (gen < 10) {
263
343
  this.deviceLevel = DEVICE_LEVEL_MEDIUM;
264
- }
265
- else {
344
+ } else {
266
345
  this.deviceLevel = DEVICE_LEVEL_HIGH;
267
346
  }
268
347
  }
269
348
  };
270
- DeviceProxy.prototype.getDeviceInfo = function () {
349
+ _proto.getDeviceInfo = function getDeviceInfo() {
271
350
  return {
272
351
  isIOS: this.isIOS,
273
352
  model: this.model,
274
- deviceLevel: this.deviceLevel,
353
+ deviceLevel: this.deviceLevel
275
354
  };
276
355
  };
277
356
  return DeviceProxy;
278
- }());
357
+ }();
279
358
  var device = new DeviceProxy();
280
359
  function checkDowngradeResult(result) {
281
360
  if (result.mock) {
282
- var _a = result.mock, downgrade = _a.downgrade, _b = _a.deviceLevel, deviceLevel = _b === void 0 ? DEVICE_LEVEL_HIGH : _b;
361
+ var _result_mock = result.mock, downgrade = _result_mock.downgrade, _result_mock_deviceLevel = _result_mock.deviceLevel, deviceLevel = _result_mock_deviceLevel === void 0 ? DEVICE_LEVEL_HIGH : _result_mock_deviceLevel;
283
362
  device.deviceLevel = deviceLevel;
284
- return { downgrade: downgrade, reason: 'mock' };
363
+ return {
364
+ downgrade: downgrade,
365
+ reason: "mock"
366
+ };
285
367
  }
286
368
  if (result.noAlipayEnv) {
287
- return { downgrade: false, reason: 'no AP env' };
369
+ return {
370
+ downgrade: false,
371
+ reason: "no AP env"
372
+ };
288
373
  }
289
374
  if (!result.systemInfo) {
290
- return { downgrade: false, reason: 'systemInfo is required' };
375
+ return {
376
+ downgrade: false,
377
+ reason: "systemInfo is required"
378
+ };
291
379
  }
292
380
  if (!result.downgradeResult) {
293
- return { downgrade: false, reason: 'downgradeResult is required' };
381
+ return {
382
+ downgrade: false,
383
+ reason: "downgradeResult is required"
384
+ };
294
385
  }
295
386
  device.setBySystemInfo(result.systemInfo);
296
387
  return parseDowngradeResult(result.downgradeResult);
@@ -301,10 +392,9 @@ function parseDowngradeResult(result) {
301
392
  if (!result.error) {
302
393
  try {
303
394
  var ret = effects.isString(result) ? JSON.parse(result) : result;
304
- if ('downgradeResultType' in ret) {
395
+ if ("downgradeResultType" in ret) {
305
396
  resultType = ret.downgradeResultType;
306
- }
307
- else if ('resultType' in ret) {
397
+ } else if ("resultType" in ret) {
308
398
  resultType = ret.resultType;
309
399
  resultReason = ret.resultReason;
310
400
  }
@@ -318,71 +408,72 @@ function parseDowngradeResult(result) {
318
408
  }
319
409
  }
320
410
  device.updateDeviceLevel();
321
- }
322
- catch (ex) {
411
+ } catch (ex) {
323
412
  console.error(ex);
324
413
  }
325
414
  if (resultType === undefined) {
326
- return { downgrade: true, reason: 'call downgrade fail' };
327
- }
328
- else {
415
+ return {
416
+ downgrade: true,
417
+ reason: "call downgrade fail"
418
+ };
419
+ } else {
329
420
  if (resultType === 1) {
330
- return { downgrade: true, reason: getDowngradeReason(resultReason) };
331
- }
332
- else {
333
- return { downgrade: false, reason: resultType };
421
+ return {
422
+ downgrade: true,
423
+ reason: getDowngradeReason(resultReason)
424
+ };
425
+ } else {
426
+ return {
427
+ downgrade: false,
428
+ reason: resultType
429
+ };
334
430
  }
335
431
  }
336
- }
337
- else {
432
+ } else {
338
433
  // 无权调用的情况下不降级
339
- return { downgrade: result.error !== 4, reason: 'api error: ' + result.error };
434
+ return {
435
+ downgrade: result.error !== 4,
436
+ reason: "api error: " + result.error
437
+ };
340
438
  }
341
439
  }
342
440
  function getDowngradeReason(reason) {
343
441
  if (reason === -1) {
344
- return "".concat(reason, "-no config");
345
- }
346
- else if (reason === 0) {
347
- return "".concat(reason, "-none");
348
- }
349
- else if (reason === 1) {
350
- return "".concat(reason, "-downgrade by memory");
351
- }
352
- else if (reason === 2) {
353
- return "".concat(reason, "-downgrade by crash");
354
- }
355
- else if (reason === 3) {
356
- return "".concat(reason, "-downgrade by device");
357
- }
358
- else if (reason === 4) {
359
- return "".concat(reason, "-downgrade by force");
360
- }
361
- else {
362
- return "".concat(reason);
442
+ return "" + reason + "-no config";
443
+ } else if (reason === 0) {
444
+ return "" + reason + "-none";
445
+ } else if (reason === 1) {
446
+ return "" + reason + "-downgrade by memory";
447
+ } else if (reason === 2) {
448
+ return "" + reason + "-downgrade by crash";
449
+ } else if (reason === 3) {
450
+ return "" + reason + "-downgrade by device";
451
+ } else if (reason === 4) {
452
+ return "" + reason + "-downgrade by force";
453
+ } else {
454
+ return "" + reason;
363
455
  }
364
456
  }
365
457
  function getRenderLevelByDevice(renderLevel) {
366
458
  if (!renderLevel) {
367
459
  return device.getRenderLevel();
368
- }
369
- else {
460
+ } else {
370
461
  return /[ABS]/.test(renderLevel) ? renderLevel : effects.spec.RenderLevel.S;
371
462
  }
372
463
  }
373
464
  function isDeviceLevel(deviceLevel) {
374
- return deviceLevel === DEVICE_LEVEL_HIGH
375
- || deviceLevel === DEVICE_LEVEL_MEDIUM
376
- || deviceLevel === DEVICE_LEVEL_LOW;
465
+ return deviceLevel === DEVICE_LEVEL_HIGH || deviceLevel === DEVICE_LEVEL_MEDIUM || deviceLevel === DEVICE_LEVEL_LOW;
377
466
  }
378
- var internalPaused = Symbol('@@_inter_pause');
467
+ var internalPaused = Symbol("@@_inter_pause");
379
468
  function pauseAllActivePlayers(e) {
380
469
  if (e.target === document) {
381
- effects.logger.info('Auto pause all players with data offloaded');
470
+ effects.logger.info("Auto pause all players with data offloaded");
382
471
  var players = effects.getActivePlayers();
383
- players.forEach(function (player) {
472
+ players.forEach(function(player) {
384
473
  if (!player.paused) {
385
- player.pause({ offloadTexture: true });
474
+ player.pause({
475
+ offloadTexture: true
476
+ });
386
477
  // @ts-expect-error
387
478
  player[internalPaused] = true;
388
479
  }
@@ -391,9 +482,9 @@ function pauseAllActivePlayers(e) {
391
482
  }
392
483
  function resumePausedPlayers(e) {
393
484
  if (e.target === document) {
394
- effects.logger.info('auto resume all players');
485
+ effects.logger.info("auto resume all players");
395
486
  var players = effects.getActivePlayers();
396
- players.forEach(function (player) {
487
+ players.forEach(function(player) {
397
488
  // @ts-expect-error
398
489
  if (player[internalPaused]) {
399
490
  void player.resume();
@@ -404,119 +495,129 @@ function resumePausedPlayers(e) {
404
495
  }
405
496
  }
406
497
 
407
- var AlipayDowngradePlugin = /** @class */ (function (_super) {
408
- __extends(AlipayDowngradePlugin, _super);
498
+ var AlipayDowngradePlugin = /*#__PURE__*/ function(AbstractPlugin) {
499
+ _inherits(AlipayDowngradePlugin, AbstractPlugin);
409
500
  function AlipayDowngradePlugin() {
410
- return _super !== null && _super.apply(this, arguments) || this;
501
+ return AbstractPlugin.apply(this, arguments);
411
502
  }
412
- AlipayDowngradePlugin.onPlayerCreated = function (player) {
413
- return __awaiter(this, void 0, void 0, function () {
414
- return __generator(this, function (_a) {
503
+ AlipayDowngradePlugin.onPlayerCreated = function onPlayerCreated(player) {
504
+ return _async_to_generator(function() {
505
+ return __generator(this, function(_state) {
415
506
  if (AlipayDowngradePlugin.glLostOccurred) {
416
- console.warn('gl lost happened, new player will be destroyed.');
417
- return [2 /*return*/, player.dispose()];
507
+ console.warn("gl lost happened, new player will be destroyed.");
508
+ return [
509
+ 2,
510
+ player.dispose()
511
+ ];
418
512
  }
419
- return [2 /*return*/];
513
+ return [
514
+ 2
515
+ ];
420
516
  });
421
- });
517
+ })();
422
518
  };
423
- AlipayDowngradePlugin.processRawJSON = function (json, options) {
424
- var _a;
425
- if (options === void 0) { options = {}; }
426
- return __awaiter(this, void 0, void 0, function () {
427
- var downgradeResult, downgradeDecision;
428
- return __generator(this, function (_b) {
519
+ AlipayDowngradePlugin.processRawJSON = function processRawJSON(json, options) {
520
+ if (options === void 0) options = {};
521
+ return _async_to_generator(function() {
522
+ var _options_pluginData, downgradeResult, downgradeDecision;
523
+ return __generator(this, function(_state) {
429
524
  if (AlipayDowngradePlugin.glLostOccurred) {
430
- return [2 /*return*/, Promise.reject('gl lost happened')];
525
+ return [
526
+ 2,
527
+ Promise.reject("gl lost happened")
528
+ ];
431
529
  }
432
- downgradeResult = (_a = options.pluginData) === null || _a === void 0 ? void 0 : _a['downgrade'];
530
+ downgradeResult = (_options_pluginData = options.pluginData) == null ? void 0 : _options_pluginData["downgrade"];
433
531
  if (downgradeResult) {
434
532
  downgradeDecision = checkDowngradeResult(downgradeResult);
435
533
  if (downgradeDecision.downgrade) {
436
- throw new Error("downgraded, reason: ".concat(downgradeDecision.reason));
534
+ throw new Error("downgraded, reason: " + downgradeDecision.reason);
437
535
  }
438
- }
439
- else {
440
- console.warn('No downgrade result in pluginData of SceneLoadOptions');
536
+ } else {
537
+ console.warn("No downgrade result in pluginData of SceneLoadOptions");
441
538
  }
442
539
  if (!options.renderLevel) {
443
540
  options.renderLevel = getRenderLevelByDevice(options.renderLevel);
444
541
  }
445
- return [2 /*return*/];
542
+ return [
543
+ 2
544
+ ];
446
545
  });
447
- });
546
+ })();
448
547
  };
449
- AlipayDowngradePlugin.glLostOccurred = false;
450
548
  return AlipayDowngradePlugin;
451
- }(effects.AbstractPlugin));
549
+ }(effects.AbstractPlugin);
550
+ AlipayDowngradePlugin.glLostOccurred = false;
452
551
 
453
- var prefix = '[Galacean Effects]';
552
+ var prefix = "[Galacean Effects]";
454
553
  effects.logger.register(nativeLogger);
455
554
  function nativeLogger(type, msg) {
456
- var args = [];
457
- for (var _i = 2; _i < arguments.length; _i++) {
458
- args[_i - 2] = arguments[_i];
555
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
556
+ args[_key - 2] = arguments[_key];
459
557
  }
460
558
  if (effects.isAndroid()) {
461
- androidLogger.apply(void 0, __spreadArray([type, "".concat(prefix, " ").concat(msg)], __read(args), false));
462
- }
463
- else if (effects.isIOS()) {
464
- iOSLogger.apply(void 0, __spreadArray([type, msg], __read(args), false));
559
+ androidLogger.apply(void 0, [].concat([
560
+ type,
561
+ prefix + " " + msg
562
+ ], args));
563
+ } else if (effects.isIOS()) {
564
+ iOSLogger.apply(void 0, [].concat([
565
+ type,
566
+ msg
567
+ ], args));
465
568
  }
466
569
  }
467
570
  function iOSLogger(type, msg) {
468
- var args = [];
469
- for (var _i = 2; _i < arguments.length; _i++) {
470
- args[_i - 2] = arguments[_i];
571
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
572
+ args[_key - 2] = arguments[_key];
471
573
  }
472
574
  try {
473
575
  var ap = window.AlipayJSBridge;
474
- var content = formatMessage.apply(void 0, __spreadArray([type, msg], __read(args), false));
475
- ap === null || ap === void 0 ? void 0 : ap.call('H5APLog', {
476
- content: content,
576
+ var content = formatMessage.apply(void 0, [].concat([
577
+ type,
578
+ msg
579
+ ], args));
580
+ ap == null ? void 0 : ap.call("H5APLog", {
581
+ content: content
477
582
  });
478
- }
479
- catch (e) {
583
+ } catch (e) {
480
584
  console.error(e);
481
585
  }
482
586
  }
483
587
  // Android H5 容器支持 console 日志直接写入 aplog
484
588
  function androidLogger(type, msg) {
485
- var args = [];
486
- for (var _i = 2; _i < arguments.length; _i++) {
487
- args[_i - 2] = arguments[_i];
589
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
590
+ args[_key - 2] = arguments[_key];
488
591
  }
489
592
  try {
490
593
  var ap = window.AlipayJSBridge;
491
- ap === null || ap === void 0 ? void 0 : ap.call('localLog', {
492
- 'anr_info': 'mars',
493
- 'message': msg + args.join(''),
494
- 'level': type,
594
+ ap == null ? void 0 : ap.call("localLog", {
595
+ "anr_info": "mars",
596
+ "message": msg + args.join(""),
597
+ "level": type
495
598
  });
496
- }
497
- catch (e) {
599
+ } catch (e) {
498
600
  console.error(e);
499
601
  }
500
602
  }
501
603
  function formatMessage(level, msg) {
502
- var args = [];
503
- for (var _i = 2; _i < arguments.length; _i++) {
504
- args[_i - 2] = arguments[_i];
604
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
605
+ args[_key - 2] = arguments[_key];
505
606
  }
506
607
  var result = [
507
- '<MARS_PLAYER>',
508
- "(".concat(level, "):"),
509
- msg,
608
+ "<MARS_PLAYER>",
609
+ "(" + level + "):",
610
+ msg
510
611
  ];
511
- args.forEach(function (i) {
512
- result.push(i + '');
612
+ args.forEach(function(i) {
613
+ result.push(i + "");
513
614
  });
514
- return result.join(' ');
615
+ return result.join(" ");
515
616
  }
516
617
 
517
- var version = "2.0.0-alpha.4";
518
- effects.registerPlugin('alipay-downgrade', AlipayDowngradePlugin, DowngradeVFXItem, true);
519
- effects.logger.info('plugin alipay downgrade version: ' + version);
618
+ var version = "2.0.0-alpha.6";
619
+ effects.registerPlugin("alipay-downgrade", AlipayDowngradePlugin, DowngradeVFXItem, true);
620
+ effects.logger.info("plugin alipay downgrade version: " + version);
520
621
 
521
622
  exports.checkDowngradeResult = checkDowngradeResult;
522
623
  exports.getDowngradeResult = getDowngradeResult;