@galacean/effects-plugin-alipay-downgrade 2.0.0-alpha.26 → 2.0.0-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alipay.js +304 -301
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +305 -300
- package/dist/alipay.mjs.map +1 -1
- package/dist/device-proxy.d.ts +15 -0
- package/dist/index.js +305 -302
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +306 -301
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +59 -0
- package/dist/utils.d.ts +3 -43
- package/package.json +3 -3
- package/dist/downgrade-vfx-item.d.ts +0 -3
package/dist/index.mjs
CHANGED
|
@@ -3,44 +3,11 @@
|
|
|
3
3
|
* Description: Galacean Effects player downgrade plugin for Alipay
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,意绮,飂兮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.28
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
function _set_prototype_of(o, p) {
|
|
13
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
14
|
-
o.__proto__ = p;
|
|
15
|
-
return o;
|
|
16
|
-
};
|
|
17
|
-
return _set_prototype_of(o, p);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _inherits(subClass, superClass) {
|
|
21
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
22
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
23
|
-
}
|
|
24
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
25
|
-
constructor: {
|
|
26
|
-
value: subClass,
|
|
27
|
-
writable: true,
|
|
28
|
-
configurable: true
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// class DowngradeItem {
|
|
35
|
-
// // empty
|
|
36
|
-
// }
|
|
37
|
-
var DowngradeVFXItem = /*#__PURE__*/ function(VFXItem) {
|
|
38
|
-
_inherits(DowngradeVFXItem, VFXItem);
|
|
39
|
-
function DowngradeVFXItem() {
|
|
40
|
-
return VFXItem.apply(this, arguments);
|
|
41
|
-
}
|
|
42
|
-
return DowngradeVFXItem;
|
|
43
|
-
}(VFXItem);
|
|
10
|
+
import { isString, logger, isAlipayMiniApp, spec, isIOS, getActivePlayers, AbstractPlugin, isAndroid, registerPlugin, VFXItem } from '@galacean/effects';
|
|
44
11
|
|
|
45
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
46
13
|
try {
|
|
@@ -69,6 +36,28 @@ function _async_to_generator(fn) {
|
|
|
69
36
|
};
|
|
70
37
|
}
|
|
71
38
|
|
|
39
|
+
function _set_prototype_of(o, p) {
|
|
40
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
41
|
+
o.__proto__ = p;
|
|
42
|
+
return o;
|
|
43
|
+
};
|
|
44
|
+
return _set_prototype_of(o, p);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function _inherits(subClass, superClass) {
|
|
48
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
49
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
50
|
+
}
|
|
51
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
52
|
+
constructor: {
|
|
53
|
+
value: subClass,
|
|
54
|
+
writable: true,
|
|
55
|
+
configurable: true
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
59
|
+
}
|
|
60
|
+
|
|
72
61
|
function __generator(thisArg, body) {
|
|
73
62
|
var _ = {
|
|
74
63
|
label: 0,
|
|
@@ -169,81 +158,248 @@ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedEr
|
|
|
169
158
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
170
159
|
};
|
|
171
160
|
|
|
161
|
+
function _extends() {
|
|
162
|
+
_extends = Object.assign || function assign(target) {
|
|
163
|
+
for(var i = 1; i < arguments.length; i++){
|
|
164
|
+
var source = arguments[i];
|
|
165
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
166
|
+
}
|
|
167
|
+
return target;
|
|
168
|
+
};
|
|
169
|
+
return _extends.apply(this, arguments);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var DeviceLevel;
|
|
173
|
+
(function(DeviceLevel) {
|
|
174
|
+
DeviceLevel["High"] = "high";
|
|
175
|
+
DeviceLevel["Medium"] = "medium";
|
|
176
|
+
DeviceLevel["Low"] = "low";
|
|
177
|
+
DeviceLevel["Unknown"] = "unknown";
|
|
178
|
+
})(DeviceLevel || (DeviceLevel = {}));
|
|
179
|
+
|
|
180
|
+
var deviceModelList = [
|
|
181
|
+
"12,8",
|
|
182
|
+
"13,1",
|
|
183
|
+
"13,2",
|
|
184
|
+
"13,3",
|
|
185
|
+
"13,4"
|
|
186
|
+
];
|
|
187
|
+
var DeviceProxy = /*#__PURE__*/ function() {
|
|
188
|
+
function DeviceProxy() {
|
|
189
|
+
this.isIOS = false;
|
|
190
|
+
this.model = "DESKTOP_DEBUG";
|
|
191
|
+
this.system = "Unknown";
|
|
192
|
+
this.level = DeviceLevel.Unknown;
|
|
193
|
+
this.isDowngrade = false;
|
|
194
|
+
}
|
|
195
|
+
var _proto = DeviceProxy.prototype;
|
|
196
|
+
_proto.setSystemInfo = function setSystemInfo(systemInfo) {
|
|
197
|
+
var performance = systemInfo.performance, platform = systemInfo.platform, _systemInfo_model = systemInfo.model, model = _systemInfo_model === void 0 ? "UNKNOWN_DEVICE" : _systemInfo_model, _systemInfo_system = systemInfo.system, system = _systemInfo_system === void 0 ? "Unknown" : _systemInfo_system;
|
|
198
|
+
this.isIOS = platform === "iOS";
|
|
199
|
+
this.model = model;
|
|
200
|
+
this.system = system;
|
|
201
|
+
this.setLevel(performance);
|
|
202
|
+
};
|
|
203
|
+
_proto.getDowngradeDecision = function getDowngradeDecision(result) {
|
|
204
|
+
var resultType = undefined;
|
|
205
|
+
var resultReason = undefined;
|
|
206
|
+
if (result.error) {
|
|
207
|
+
// 无权调用的情况下不降级
|
|
208
|
+
return {
|
|
209
|
+
downgrade: result.error !== 4,
|
|
210
|
+
level: this.getRenderLevel(),
|
|
211
|
+
reason: "api error: " + result.error
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
var ret = isString(result) ? JSON.parse(result) : result;
|
|
216
|
+
if ("downgradeResultType" in ret) {
|
|
217
|
+
resultType = ret.downgradeResultType;
|
|
218
|
+
} else if ("resultType" in ret) {
|
|
219
|
+
resultType = ret.resultType;
|
|
220
|
+
resultReason = ret.resultReason;
|
|
221
|
+
}
|
|
222
|
+
if (result.context) {
|
|
223
|
+
var deviceInfo = result.context.deviceInfo;
|
|
224
|
+
if (deviceInfo) {
|
|
225
|
+
var deviceLevel = deviceInfo.deviceLevel;
|
|
226
|
+
var newLevel = getDeviceLevel(deviceLevel);
|
|
227
|
+
if (newLevel !== DeviceLevel.Unknown) {
|
|
228
|
+
this.level = newLevel;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
} catch (ex) {
|
|
233
|
+
logger.error(ex);
|
|
234
|
+
}
|
|
235
|
+
if (resultType === undefined) {
|
|
236
|
+
return {
|
|
237
|
+
downgrade: true,
|
|
238
|
+
level: this.getRenderLevel(),
|
|
239
|
+
reason: "call downgrade fail"
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
if (resultType === 1) {
|
|
243
|
+
return {
|
|
244
|
+
downgrade: true,
|
|
245
|
+
level: this.getRenderLevel(),
|
|
246
|
+
reason: getDowngradeReason(resultReason)
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (isAlipayMiniApp() && this.downgradeForMiniprogram()) {
|
|
250
|
+
return {
|
|
251
|
+
downgrade: true,
|
|
252
|
+
level: this.getRenderLevel(),
|
|
253
|
+
reason: "Force downgrade by downgrade plugin"
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
downgrade: false,
|
|
258
|
+
level: this.getRenderLevel(),
|
|
259
|
+
reason: resultType
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
_proto.getRenderLevel = function getRenderLevel() {
|
|
263
|
+
if (this.level === DeviceLevel.High) {
|
|
264
|
+
return spec.RenderLevel.S;
|
|
265
|
+
} else if (this.level === DeviceLevel.Medium) {
|
|
266
|
+
return spec.RenderLevel.A;
|
|
267
|
+
} else if (this.level === DeviceLevel.Low) {
|
|
268
|
+
return spec.RenderLevel.B;
|
|
269
|
+
} else {
|
|
270
|
+
return this.isIOS ? spec.RenderLevel.S : spec.RenderLevel.B;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
_proto.setLevel = function setLevel(level) {
|
|
274
|
+
this.level = getDeviceLevel(level);
|
|
275
|
+
if (this.level === DeviceLevel.Unknown) {
|
|
276
|
+
if (/iPhone(\d+),/.test(this.model)) {
|
|
277
|
+
var gen = +RegExp.$1;
|
|
278
|
+
if (gen <= 9) {
|
|
279
|
+
this.level = DeviceLevel.Low;
|
|
280
|
+
} else if (gen < 10) {
|
|
281
|
+
this.level = DeviceLevel.Medium;
|
|
282
|
+
} else {
|
|
283
|
+
this.level = DeviceLevel.High;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
_proto.downgradeForMiniprogram = function downgradeForMiniprogram() {
|
|
289
|
+
var _this = this;
|
|
290
|
+
if (this.isIOS) {
|
|
291
|
+
if (deviceModelList.find(function(v) {
|
|
292
|
+
return v === _this.model;
|
|
293
|
+
})) {
|
|
294
|
+
var versionList = this.system.split(".");
|
|
295
|
+
if (versionList.length > 0 && versionList[0] === "16") {
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
};
|
|
302
|
+
return DeviceProxy;
|
|
303
|
+
}();
|
|
304
|
+
function getDowngradeReason(reason) {
|
|
305
|
+
if (reason === -1) {
|
|
306
|
+
return "" + reason + ", unable to pull configuration";
|
|
307
|
+
} else if (reason === 0) {
|
|
308
|
+
return "" + reason + ", no downgrade";
|
|
309
|
+
} else if (reason === 1) {
|
|
310
|
+
return "" + reason + ", memory downgrade";
|
|
311
|
+
} else if (reason === 2) {
|
|
312
|
+
return "" + reason + ", crash downgrade";
|
|
313
|
+
} else if (reason === 3) {
|
|
314
|
+
return "" + reason + ", basic dimension downgrade";
|
|
315
|
+
} else if (reason === 4) {
|
|
316
|
+
return "" + reason + ", technical point downgrade";
|
|
317
|
+
} else if (reason === 5) {
|
|
318
|
+
return "" + reason + ", GPU downgrade";
|
|
319
|
+
} else if (reason === 6) {
|
|
320
|
+
return "" + reason + ", self-healing downgrade";
|
|
321
|
+
} else if (reason === 7) {
|
|
322
|
+
return "" + reason + ", 32-bit CPU downgrade";
|
|
323
|
+
} else {
|
|
324
|
+
return "" + reason;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function getDeviceLevel(level) {
|
|
328
|
+
if (level === "high") {
|
|
329
|
+
return DeviceLevel.High;
|
|
330
|
+
} else if (level === "medium" || level === "middle") {
|
|
331
|
+
return DeviceLevel.Medium;
|
|
332
|
+
} else if (level === "low") {
|
|
333
|
+
return DeviceLevel.Low;
|
|
334
|
+
} else {
|
|
335
|
+
return DeviceLevel.Unknown;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
var internalPaused = Symbol("@@_inter_pause");
|
|
172
340
|
var mockIdPass = "mock-pass";
|
|
173
341
|
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";
|
|
178
342
|
var hasRegisterEvent = false;
|
|
179
343
|
function getDowngradeResult(bizId) {
|
|
180
344
|
return _getDowngradeResult.apply(this, arguments);
|
|
181
345
|
}
|
|
182
346
|
function _getDowngradeResult() {
|
|
183
347
|
_getDowngradeResult = _async_to_generator(function(bizId, options) {
|
|
184
|
-
var ap,
|
|
348
|
+
var _options_level, ap, _options_level1, systemStartTime;
|
|
185
349
|
return __generator(this, function(_state) {
|
|
186
350
|
if (options === void 0) options = {};
|
|
187
351
|
if (!hasRegisterEvent) {
|
|
188
|
-
registerEvent(options);
|
|
189
352
|
hasRegisterEvent = true;
|
|
353
|
+
registerEvent(options);
|
|
190
354
|
}
|
|
191
355
|
if (bizId === mockIdFail || bizId === mockIdPass) {
|
|
192
356
|
return [
|
|
193
357
|
2,
|
|
194
358
|
Promise.resolve({
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
359
|
+
bizId: bizId,
|
|
360
|
+
downgrade: bizId === mockIdFail,
|
|
361
|
+
level: (_options_level = options.level) != null ? _options_level : spec.RenderLevel.S,
|
|
362
|
+
reason: "mock"
|
|
198
363
|
})
|
|
199
364
|
];
|
|
200
365
|
}
|
|
201
366
|
ap = isAlipayMiniApp() ? my : window.AlipayJSBridge;
|
|
202
|
-
if (ap) {
|
|
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
|
-
];
|
|
211
|
-
var tc = options.techPoint;
|
|
212
|
-
if (tc) {
|
|
213
|
-
var _techPoint;
|
|
214
|
-
(_techPoint = techPoint).push.apply(_techPoint, [].concat(tc));
|
|
215
|
-
}
|
|
216
|
-
var downgradeOptions = {
|
|
217
|
-
bizId: bizId,
|
|
218
|
-
scene: 0,
|
|
219
|
-
ext: {
|
|
220
|
-
techPoint: techPoint
|
|
221
|
-
}
|
|
222
|
-
};
|
|
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
|
-
});
|
|
232
|
-
};
|
|
233
|
-
var _options_callBridge;
|
|
234
|
-
var callBridge = (_options_callBridge = options.callBridge) != null ? _options_callBridge : ap.call;
|
|
235
|
-
callBridge("getDowngradeResult", downgradeOptions, downgradeCallback);
|
|
236
|
-
});
|
|
237
|
-
})
|
|
238
|
-
];
|
|
239
|
-
} else {
|
|
367
|
+
if (!ap) {
|
|
240
368
|
return [
|
|
241
369
|
2,
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
370
|
+
{
|
|
371
|
+
bizId: bizId,
|
|
372
|
+
downgrade: false,
|
|
373
|
+
level: (_options_level1 = options.level) != null ? _options_level1 : spec.RenderLevel.S,
|
|
374
|
+
reason: "Non-Alipay environment"
|
|
375
|
+
}
|
|
245
376
|
];
|
|
246
377
|
}
|
|
378
|
+
systemStartTime = performance.now();
|
|
379
|
+
return [
|
|
380
|
+
2,
|
|
381
|
+
getSystemInfoJSAPI(options, ap).then(function(systemInfo) {
|
|
382
|
+
var systemEndTime = performance.now();
|
|
383
|
+
return getDowngradeResultJSAPI(bizId, options, ap).then(function(downgradeResult) {
|
|
384
|
+
var downgradeEndTime = performance.now();
|
|
385
|
+
logger.info("Downgrade time: " + (downgradeEndTime - systemStartTime) + "ms.");
|
|
386
|
+
var device = new DeviceProxy();
|
|
387
|
+
device.setSystemInfo(systemInfo);
|
|
388
|
+
var decision = device.getDowngradeDecision(downgradeResult);
|
|
389
|
+
if (options.level) {
|
|
390
|
+
decision.level = options.level;
|
|
391
|
+
}
|
|
392
|
+
var result = _extends({}, decision, {
|
|
393
|
+
bizId: bizId,
|
|
394
|
+
systemInfo: systemInfo,
|
|
395
|
+
systemTime: systemEndTime - systemStartTime,
|
|
396
|
+
downgradeResult: downgradeResult,
|
|
397
|
+
downgradeTime: downgradeEndTime - systemEndTime
|
|
398
|
+
});
|
|
399
|
+
return result;
|
|
400
|
+
});
|
|
401
|
+
})
|
|
402
|
+
];
|
|
247
403
|
});
|
|
248
404
|
});
|
|
249
405
|
return _getDowngradeResult.apply(this, arguments);
|
|
@@ -260,17 +416,21 @@ function registerEvent(options) {
|
|
|
260
416
|
document.addEventListener("resume", resumePausedPlayers);
|
|
261
417
|
}
|
|
262
418
|
}
|
|
263
|
-
function
|
|
264
|
-
return
|
|
419
|
+
function getSystemInfoJSAPI(options, ap) {
|
|
420
|
+
return _getSystemInfoJSAPI.apply(this, arguments);
|
|
265
421
|
}
|
|
266
|
-
function
|
|
267
|
-
|
|
422
|
+
function _getSystemInfoJSAPI() {
|
|
423
|
+
_getSystemInfoJSAPI = _async_to_generator(function(options, ap) {
|
|
268
424
|
return __generator(this, function(_state) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
425
|
+
if (options.systemInfo) {
|
|
426
|
+
return [
|
|
427
|
+
2,
|
|
428
|
+
Promise.resolve(options.systemInfo)
|
|
429
|
+
];
|
|
430
|
+
} else {
|
|
431
|
+
return [
|
|
432
|
+
2,
|
|
433
|
+
new Promise(function(resolve, reject) {
|
|
274
434
|
ap.call("getSystemInfo", function(e) {
|
|
275
435
|
if (e.error) {
|
|
276
436
|
reject(e);
|
|
@@ -278,189 +438,58 @@ function _getSystemInfo() {
|
|
|
278
438
|
resolve(e);
|
|
279
439
|
}
|
|
280
440
|
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
})
|
|
285
|
-
];
|
|
441
|
+
})
|
|
442
|
+
];
|
|
443
|
+
}
|
|
286
444
|
});
|
|
287
445
|
});
|
|
288
|
-
return
|
|
446
|
+
return _getSystemInfoJSAPI.apply(this, arguments);
|
|
289
447
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
this.isIOS = false;
|
|
293
|
-
this.model = "DESKTOP_DEBUG";
|
|
294
|
-
this.system = "Unknown";
|
|
295
|
-
this.deviceLevel = DEVICE_LEVEL_NONE;
|
|
296
|
-
this.isDowngrade = false;
|
|
297
|
-
}
|
|
298
|
-
var _proto = DeviceProxy.prototype;
|
|
299
|
-
_proto.getRenderLevel = function getRenderLevel() {
|
|
300
|
-
if (this.deviceLevel === DEVICE_LEVEL_HIGH) {
|
|
301
|
-
return spec.RenderLevel.S;
|
|
302
|
-
} else if (this.deviceLevel === DEVICE_LEVEL_MEDIUM) {
|
|
303
|
-
return spec.RenderLevel.A;
|
|
304
|
-
} else if (this.deviceLevel === DEVICE_LEVEL_LOW) {
|
|
305
|
-
return spec.RenderLevel.B;
|
|
306
|
-
} else {
|
|
307
|
-
return this.isIOS ? spec.RenderLevel.S : spec.RenderLevel.B;
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
_proto.hasDeviceLevel = function hasDeviceLevel() {
|
|
311
|
-
return isDeviceLevel(this.deviceLevel);
|
|
312
|
-
};
|
|
313
|
-
_proto.setBySystemInfo = function setBySystemInfo(systemInfo) {
|
|
314
|
-
var performance1 = systemInfo.performance, platform = systemInfo.platform, _systemInfo_model = systemInfo.model, model = _systemInfo_model === void 0 ? "UNKNOWN_DEVICE" : _systemInfo_model, _systemInfo_system = systemInfo.system, system = _systemInfo_system === void 0 ? "Unknown" : _systemInfo_system;
|
|
315
|
-
this.isIOS = platform === "iOS";
|
|
316
|
-
this.model = model;
|
|
317
|
-
this.system = system;
|
|
318
|
-
if (performance1 && !this.hasDeviceLevel()) {
|
|
319
|
-
this.deviceLevel = performance1;
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
_proto.updateDeviceLevel = function updateDeviceLevel() {
|
|
323
|
-
if (this.hasDeviceLevel()) {
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (/iPhone(\d+),/.test(this.model)) {
|
|
327
|
-
var gen = +RegExp.$1;
|
|
328
|
-
if (gen <= 9) {
|
|
329
|
-
this.deviceLevel = DEVICE_LEVEL_LOW;
|
|
330
|
-
} else if (gen < 10) {
|
|
331
|
-
this.deviceLevel = DEVICE_LEVEL_MEDIUM;
|
|
332
|
-
} else {
|
|
333
|
-
this.deviceLevel = DEVICE_LEVEL_HIGH;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
_proto.getDeviceInfo = function getDeviceInfo() {
|
|
338
|
-
return {
|
|
339
|
-
isIOS: this.isIOS,
|
|
340
|
-
model: this.model,
|
|
341
|
-
system: this.system,
|
|
342
|
-
deviceLevel: this.deviceLevel
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
return DeviceProxy;
|
|
346
|
-
}();
|
|
347
|
-
var device = new DeviceProxy();
|
|
348
|
-
function checkDowngradeResult(result) {
|
|
349
|
-
if (result.mock) {
|
|
350
|
-
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;
|
|
351
|
-
device.deviceLevel = deviceLevel;
|
|
352
|
-
return {
|
|
353
|
-
downgrade: downgrade,
|
|
354
|
-
reason: "mock"
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
if (result.noAlipayEnv) {
|
|
358
|
-
return {
|
|
359
|
-
downgrade: false,
|
|
360
|
-
reason: "no AP env"
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
if (!result.systemInfo) {
|
|
364
|
-
return {
|
|
365
|
-
downgrade: false,
|
|
366
|
-
reason: "systemInfo is required"
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
if (!result.downgradeResult) {
|
|
370
|
-
return {
|
|
371
|
-
downgrade: false,
|
|
372
|
-
reason: "downgradeResult is required"
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
device.setBySystemInfo(result.systemInfo);
|
|
376
|
-
return parseDowngradeResult(result.downgradeResult);
|
|
448
|
+
function getDowngradeResultJSAPI(bizId, options, ap) {
|
|
449
|
+
return _getDowngradeResultJSAPI.apply(this, arguments);
|
|
377
450
|
}
|
|
378
|
-
function
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
} else if ("resultType" in ret) {
|
|
387
|
-
resultType = ret.resultType;
|
|
388
|
-
resultReason = ret.resultReason;
|
|
389
|
-
}
|
|
390
|
-
if (result.context) {
|
|
391
|
-
var deviceInfo = result.context.deviceInfo;
|
|
392
|
-
if (deviceInfo) {
|
|
393
|
-
var deviceLevel = deviceInfo.deviceLevel;
|
|
394
|
-
if (isDeviceLevel(deviceLevel)) {
|
|
395
|
-
device.deviceLevel = deviceLevel;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
device.updateDeviceLevel();
|
|
400
|
-
} catch (ex) {
|
|
401
|
-
console.error(ex);
|
|
402
|
-
}
|
|
403
|
-
if (resultType === undefined) {
|
|
404
|
-
return {
|
|
405
|
-
downgrade: true,
|
|
406
|
-
reason: "call downgrade fail"
|
|
407
|
-
};
|
|
408
|
-
} else {
|
|
409
|
-
if (resultType === 1) {
|
|
410
|
-
return {
|
|
411
|
-
downgrade: true,
|
|
412
|
-
reason: getDowngradeReason(resultReason)
|
|
413
|
-
};
|
|
451
|
+
function _getDowngradeResultJSAPI() {
|
|
452
|
+
_getDowngradeResultJSAPI = _async_to_generator(function(bizId, options, ap) {
|
|
453
|
+
return __generator(this, function(_state) {
|
|
454
|
+
if (options.downgradeResult) {
|
|
455
|
+
return [
|
|
456
|
+
2,
|
|
457
|
+
Promise.resolve(options.downgradeResult)
|
|
458
|
+
];
|
|
414
459
|
} else {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
460
|
+
return [
|
|
461
|
+
2,
|
|
462
|
+
new Promise(function(resolve, reject) {
|
|
463
|
+
var techPoint = [
|
|
464
|
+
"mars"
|
|
465
|
+
];
|
|
466
|
+
var tc = options.techPoint;
|
|
467
|
+
if (tc) {
|
|
468
|
+
var _techPoint;
|
|
469
|
+
(_techPoint = techPoint).push.apply(_techPoint, [].concat(tc));
|
|
470
|
+
}
|
|
471
|
+
var downgradeOptions = {
|
|
472
|
+
bizId: bizId,
|
|
473
|
+
scene: 0,
|
|
474
|
+
ext: {
|
|
475
|
+
techPoint: techPoint
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
var _options_callBridge;
|
|
479
|
+
var callBridge = (_options_callBridge = options.callBridge) != null ? _options_callBridge : ap.call;
|
|
480
|
+
callBridge("getDowngradeResult", downgradeOptions, function(result) {
|
|
481
|
+
resolve(result);
|
|
482
|
+
});
|
|
483
|
+
})
|
|
484
|
+
];
|
|
426
485
|
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
return {
|
|
431
|
-
downgrade: result.error !== 4,
|
|
432
|
-
reason: "api error: " + result.error
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
function getDowngradeReason(reason) {
|
|
437
|
-
if (reason === -1) {
|
|
438
|
-
return "" + reason + "-no config";
|
|
439
|
-
} else if (reason === 0) {
|
|
440
|
-
return "" + reason + "-none";
|
|
441
|
-
} else if (reason === 1) {
|
|
442
|
-
return "" + reason + "-downgrade by memory";
|
|
443
|
-
} else if (reason === 2) {
|
|
444
|
-
return "" + reason + "-downgrade by crash";
|
|
445
|
-
} else if (reason === 3) {
|
|
446
|
-
return "" + reason + "-downgrade by device";
|
|
447
|
-
} else if (reason === 4) {
|
|
448
|
-
return "" + reason + "-downgrade by force";
|
|
449
|
-
} else {
|
|
450
|
-
return "" + reason;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
function getRenderLevelByDevice(renderLevel) {
|
|
454
|
-
if (!renderLevel) {
|
|
455
|
-
return device.getRenderLevel();
|
|
456
|
-
} else {
|
|
457
|
-
return /[ABS]/.test(renderLevel) ? renderLevel : spec.RenderLevel.S;
|
|
458
|
-
}
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
return _getDowngradeResultJSAPI.apply(this, arguments);
|
|
459
489
|
}
|
|
460
|
-
function
|
|
461
|
-
return
|
|
490
|
+
function getDefaultRenderLevel() {
|
|
491
|
+
return isIOS() ? spec.RenderLevel.S : spec.RenderLevel.B;
|
|
462
492
|
}
|
|
463
|
-
var internalPaused = Symbol("@@_inter_pause");
|
|
464
493
|
function pauseAllActivePlayers(e) {
|
|
465
494
|
if (e.target === document) {
|
|
466
495
|
logger.info("Auto pause all players with data offloaded.");
|
|
@@ -490,29 +519,6 @@ function resumePausedPlayers(e) {
|
|
|
490
519
|
});
|
|
491
520
|
}
|
|
492
521
|
}
|
|
493
|
-
var deviceModelList = [
|
|
494
|
-
"12,8",
|
|
495
|
-
"13,1",
|
|
496
|
-
"13,2",
|
|
497
|
-
"13,3",
|
|
498
|
-
"13,4"
|
|
499
|
-
];
|
|
500
|
-
/**
|
|
501
|
-
* iPhone SE2 和 12 全系列机型,如果是 iOS16 系统,在小程序中强制降级
|
|
502
|
-
* @returns
|
|
503
|
-
*/ function downgradeForMiniprogram() {
|
|
504
|
-
if (device.isIOS) {
|
|
505
|
-
if (deviceModelList.find(function(v) {
|
|
506
|
-
return v === device.model;
|
|
507
|
-
})) {
|
|
508
|
-
var versionList = device.system.split(".");
|
|
509
|
-
if (versionList.length > 0 && versionList[0] === "16") {
|
|
510
|
-
return true;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
return false;
|
|
515
|
-
}
|
|
516
522
|
|
|
517
523
|
var AlipayDowngradePlugin = /*#__PURE__*/ function(AbstractPlugin) {
|
|
518
524
|
_inherits(AlipayDowngradePlugin, AbstractPlugin);
|
|
@@ -522,19 +528,18 @@ var AlipayDowngradePlugin = /*#__PURE__*/ function(AbstractPlugin) {
|
|
|
522
528
|
AlipayDowngradePlugin.processRawJSON = function processRawJSON(json, options) {
|
|
523
529
|
if (options === void 0) options = {};
|
|
524
530
|
return _async_to_generator(function() {
|
|
525
|
-
var _options_pluginData, downgradeResult,
|
|
531
|
+
var _options_pluginData, downgradeResult, _downgradeResult_level;
|
|
526
532
|
return __generator(this, function(_state) {
|
|
527
533
|
downgradeResult = (_options_pluginData = options.pluginData) == null ? void 0 : _options_pluginData["downgrade"];
|
|
528
534
|
if (downgradeResult) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
throw new Error("Downgraded, reason: " + downgradeDecision.reason + ".");
|
|
535
|
+
if (downgradeResult.downgrade) {
|
|
536
|
+
throw new Error("Downgraded, reason: " + downgradeResult.reason + ".");
|
|
532
537
|
}
|
|
533
538
|
} else {
|
|
534
|
-
|
|
539
|
+
logger.warn("No downgrade result in pluginData of SceneLoadOptions.");
|
|
535
540
|
}
|
|
536
541
|
if (!options.renderLevel) {
|
|
537
|
-
options.renderLevel =
|
|
542
|
+
options.renderLevel = (_downgradeResult_level = downgradeResult == null ? void 0 : downgradeResult.level) != null ? _downgradeResult_level : getDefaultRenderLevel();
|
|
538
543
|
}
|
|
539
544
|
return [
|
|
540
545
|
2
|
|
@@ -566,12 +571,12 @@ function nativeLogger(type, msg) {
|
|
|
566
571
|
}
|
|
567
572
|
}
|
|
568
573
|
|
|
569
|
-
var version = "2.0.0-alpha.
|
|
570
|
-
registerPlugin("alipay-downgrade", AlipayDowngradePlugin,
|
|
574
|
+
var version = "2.0.0-alpha.28";
|
|
575
|
+
registerPlugin("alipay-downgrade", AlipayDowngradePlugin, VFXItem, true);
|
|
571
576
|
logger.info("Plugin downgrade version: " + version + ".");
|
|
572
577
|
if (version !== EFFECTS.version) {
|
|
573
578
|
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!");
|
|
574
579
|
}
|
|
575
580
|
|
|
576
|
-
export {
|
|
581
|
+
export { getDefaultRenderLevel, getDowngradeResult, version };
|
|
577
582
|
//# sourceMappingURL=index.mjs.map
|