@galacean/effects-plugin-alipay-downgrade 1.5.0 → 1.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alipay.js +14 -12
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +14 -12
- package/dist/alipay.mjs.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.mjs +15 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/alipay.js
CHANGED
|
@@ -394,7 +394,7 @@ var registered = false;
|
|
|
394
394
|
*/
|
|
395
395
|
function setAlipayDowngradeBizId(bizId, options) {
|
|
396
396
|
if (options === void 0) { options = {}; }
|
|
397
|
-
var ignoreGLLost = options.ignoreGLLost, autoPause = options.autoPause;
|
|
397
|
+
var ignoreGLLost = options.ignoreGLLost, autoPause = options.autoPause, _a = options.disableGLLostEvent, disableGLLostEvent = _a === void 0 ? false : _a;
|
|
398
398
|
var downgradeWhenGLLost = ignoreGLLost !== true;
|
|
399
399
|
AlipayDowngradePlugin.currentBizId = bizId;
|
|
400
400
|
if (registered) {
|
|
@@ -404,17 +404,19 @@ function setAlipayDowngradeBizId(bizId, options) {
|
|
|
404
404
|
alipay.window.addEventListener('unload', function () {
|
|
405
405
|
effects.getActivePlayers().forEach(function (player) { return player.dispose(); });
|
|
406
406
|
});
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
407
|
+
if (!disableGLLostEvent) {
|
|
408
|
+
alipay.window.addEventListener('webglcontextlost', function (e) {
|
|
409
|
+
if (effects.isCanvasUsedByPlayer(e.target)) {
|
|
410
|
+
AlipayDowngradePlugin.glLostOccurred = true;
|
|
411
|
+
console.error('webgl lost occur');
|
|
412
|
+
if (downgradeWhenGLLost) {
|
|
413
|
+
console.warn('webgl lost occur, all players will be downgraded from now on');
|
|
414
|
+
effects.disableAllPlayer(true);
|
|
415
|
+
effects.getActivePlayers().forEach(function (player) { return player.dispose(); });
|
|
416
|
+
}
|
|
415
417
|
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
+
}, true);
|
|
419
|
+
}
|
|
418
420
|
if (autoPause) {
|
|
419
421
|
document.addEventListener('pause', pauseAllActivePlayers);
|
|
420
422
|
document.addEventListener('resume', resumePausedPlayers);
|
|
@@ -457,7 +459,7 @@ function resumePausedPlayers(e) {
|
|
|
457
459
|
});
|
|
458
460
|
}
|
|
459
461
|
}
|
|
460
|
-
var version = "1.
|
|
462
|
+
var version = "1.6.0-beta.0";
|
|
461
463
|
effects.logger.info('plugin alipay downgrade version: ' + version);
|
|
462
464
|
|
|
463
465
|
exports.checkDowngrade = checkDowngrade;
|
package/dist/alipay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alipay.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alipay.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/alipay.mjs
CHANGED
|
@@ -390,7 +390,7 @@ var registered = false;
|
|
|
390
390
|
*/
|
|
391
391
|
function setAlipayDowngradeBizId(bizId, options) {
|
|
392
392
|
if (options === void 0) { options = {}; }
|
|
393
|
-
var ignoreGLLost = options.ignoreGLLost, autoPause = options.autoPause;
|
|
393
|
+
var ignoreGLLost = options.ignoreGLLost, autoPause = options.autoPause, _a = options.disableGLLostEvent, disableGLLostEvent = _a === void 0 ? false : _a;
|
|
394
394
|
var downgradeWhenGLLost = ignoreGLLost !== true;
|
|
395
395
|
AlipayDowngradePlugin.currentBizId = bizId;
|
|
396
396
|
if (registered) {
|
|
@@ -400,17 +400,19 @@ function setAlipayDowngradeBizId(bizId, options) {
|
|
|
400
400
|
window.addEventListener('unload', function () {
|
|
401
401
|
getActivePlayers().forEach(function (player) { return player.dispose(); });
|
|
402
402
|
});
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
403
|
+
if (!disableGLLostEvent) {
|
|
404
|
+
window.addEventListener('webglcontextlost', function (e) {
|
|
405
|
+
if (isCanvasUsedByPlayer(e.target)) {
|
|
406
|
+
AlipayDowngradePlugin.glLostOccurred = true;
|
|
407
|
+
console.error('webgl lost occur');
|
|
408
|
+
if (downgradeWhenGLLost) {
|
|
409
|
+
console.warn('webgl lost occur, all players will be downgraded from now on');
|
|
410
|
+
disableAllPlayer(true);
|
|
411
|
+
getActivePlayers().forEach(function (player) { return player.dispose(); });
|
|
412
|
+
}
|
|
411
413
|
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
+
}, true);
|
|
415
|
+
}
|
|
414
416
|
if (autoPause) {
|
|
415
417
|
document.addEventListener('pause', pauseAllActivePlayers);
|
|
416
418
|
document.addEventListener('resume', resumePausedPlayers);
|
|
@@ -453,7 +455,7 @@ function resumePausedPlayers(e) {
|
|
|
453
455
|
});
|
|
454
456
|
}
|
|
455
457
|
}
|
|
456
|
-
var version = "1.
|
|
458
|
+
var version = "1.6.0-beta.0";
|
|
457
459
|
logger.info('plugin alipay downgrade version: ' + version);
|
|
458
460
|
|
|
459
461
|
export { checkDowngrade, downgradeForMiniprogram, getAlipayDowngradeBizId, getDeviceName, getRenderLevelByDevice, getSystemInfo, resetDevicePending, setAlipayDowngradeBizId, version };
|
package/dist/alipay.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alipay.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alipay.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player downgrade plugin for Alipay
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,意绮
|
|
6
|
-
* Version: v1.
|
|
6
|
+
* Version: v1.6.0-beta.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -413,7 +413,7 @@ var registered = false;
|
|
|
413
413
|
*/
|
|
414
414
|
function setAlipayDowngradeBizId(bizId, options) {
|
|
415
415
|
if (options === void 0) { options = {}; }
|
|
416
|
-
var ignoreGLLost = options.ignoreGLLost, autoPause = options.autoPause;
|
|
416
|
+
var ignoreGLLost = options.ignoreGLLost, autoPause = options.autoPause, _a = options.disableGLLostEvent, disableGLLostEvent = _a === void 0 ? false : _a;
|
|
417
417
|
var downgradeWhenGLLost = ignoreGLLost !== true;
|
|
418
418
|
AlipayDowngradePlugin.currentBizId = bizId;
|
|
419
419
|
if (registered) {
|
|
@@ -423,17 +423,19 @@ function setAlipayDowngradeBizId(bizId, options) {
|
|
|
423
423
|
window.addEventListener('unload', function () {
|
|
424
424
|
effects.getActivePlayers().forEach(function (player) { return player.dispose(); });
|
|
425
425
|
});
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
426
|
+
if (!disableGLLostEvent) {
|
|
427
|
+
window.addEventListener('webglcontextlost', function (e) {
|
|
428
|
+
if (effects.isCanvasUsedByPlayer(e.target)) {
|
|
429
|
+
AlipayDowngradePlugin.glLostOccurred = true;
|
|
430
|
+
console.error('webgl lost occur');
|
|
431
|
+
if (downgradeWhenGLLost) {
|
|
432
|
+
console.warn('webgl lost occur, all players will be downgraded from now on');
|
|
433
|
+
effects.disableAllPlayer(true);
|
|
434
|
+
effects.getActivePlayers().forEach(function (player) { return player.dispose(); });
|
|
435
|
+
}
|
|
434
436
|
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
+
}, true);
|
|
438
|
+
}
|
|
437
439
|
if (autoPause) {
|
|
438
440
|
document.addEventListener('pause', pauseAllActivePlayers);
|
|
439
441
|
document.addEventListener('resume', resumePausedPlayers);
|
|
@@ -476,7 +478,7 @@ function resumePausedPlayers(e) {
|
|
|
476
478
|
});
|
|
477
479
|
}
|
|
478
480
|
}
|
|
479
|
-
var version = "1.
|
|
481
|
+
var version = "1.6.0-beta.0";
|
|
480
482
|
effects.logger.info('plugin alipay downgrade version: ' + version);
|
|
481
483
|
|
|
482
484
|
exports.checkDowngrade = checkDowngrade;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.min.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player downgrade plugin for Alipay
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,意绮
|
|
6
|
-
* Version: v1.
|
|
6
|
+
* Version: v1.6.0-beta.0
|
|
7
7
|
*/
|
|
8
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],n):n(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.alipayDowngradePlugin={}),e.ge)}(this,(function(e,n){"use strict";var r=function(e,n){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])},r(e,n)};function t(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function t(){this.constructor=e}r(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}function o(e,n,r,t){return new(r||(r=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function l(e){try{c(t.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(a,l)}c((t=t.apply(e,n||[])).next())}))}function i(e,n){var r,t,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,t&&(o=2&l[0]?t.return:l[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,l[1])).done)return o;switch(t=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,t=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=n.call(e,a)}catch(e){l=[6,e],t=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}"function"==typeof SuppressedError&&SuppressedError;var a,l,c="low",u="middle",s="high",d="DESKTOP_DEBUG",f="Unknown",p=!1;function v(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return a||(a=h().then((function(e){var n=e.performance,r=e.platform,t=e.model,o=void 0===t?"UNKNOWN_DEVICE":t,i=e.system;if(l||(l=n),p="iOS"===r,f=void 0===i?"Unknown":i,/iPhone(\d+),/.test(d=o)&&!l){var a=+RegExp.$1;l=a<=9?c:a<10?u:s}return 0===d.indexOf(e.brand)&&(d=d.replace(e.brand,"").trim()),d}),(function(e){}))),[2,a.then((function(){return d}),(function(){return d}))]}))}))}function g(e){return"auto"!==e&&e?/[ABS]/.test(e)?e:n.spec.RenderLevel.S:l===s?n.spec.RenderLevel.S:l===u?n.spec.RenderLevel.A:l===c?n.spec.RenderLevel.B:p?n.spec.RenderLevel.S:n.spec.RenderLevel.B}var y="mock-fail";function w(e,r){return void 0===r&&(r={}),o(this,void 0,void 0,(function(){var t,o;return i(this,(function(i){return e===y||"mock-pass"===e?[2,Promise.resolve({downgrade:e===y,reason:"mock"})]:(t=n.isAlipayMiniApp()?my:window.AlipayJSBridge)?(o=performance.now(),[2,v().then((function(){return new Promise((function(i){var a,d=["mars"],f=r.techPoint;f&&d.push.apply(d,function(e,n,r){if(r||2===arguments.length)for(var t,o=0,i=n.length;o<i;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}([],function(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,o,i=r.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(t=i.next()).done;)a.push(t.value)}catch(e){o={error:e}}finally{try{t&&!t.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}(f),!1)),(null!==(a=r.callBridge)&&void 0!==a?a:t.call)("getDowngradeResult",{bizId:e,scene:0,ext:{techPoint:d}},(function(e){var r=void 0;if(console.info("downgrade time: ".concat(performance.now()-o,"ms")),e.error)i({downgrade:4!==e.error,reason:"api error:"+e.error});else try{var t=n.isString(e)?JSON.parse(e):e;if("downgradeResultType"in t?r=t.downgradeResultType:"resultType"in t&&(r=t.resultType),e.context){var a=e.context.deviceInfo;if(a){var d=a.deviceLevel;d===s||d===c?l=d:"medium"===d&&(l=u)}}}catch(e){console.error(e)}void 0===r?i({downgrade:!0,reason:"call downgrade fail"}):n.isAlipayMiniApp()&&b()?i({downgrade:!0,reason:"Force downgrade by downgrade plugin"}):i({downgrade:1===r,reason:r})}))}))}))]):[2,Promise.resolve({downgrade:!1,reason:"no AP env"})]}))}))}function h(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,r){var t=n.isAlipayMiniApp()?my:window.AlipayJSBridge;t?t.call("getSystemInfo",(function(n){n.error?r(n):e(n)})):r("no ap")}))]}))}))}var m=["12,8","13,1","13,2","13,3","13,4"];function b(){if(p&&m.find((function(e){return e===d}))){var e=f.split(".");if(e.length>0&&"16"===e[0])return!0}return!1}var A=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.onPlayerCreated=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return n.glLostOccurred?(console.warn("gl lost happened, new player will be destroyed."),[2,e.dispose()]):n.currentBizId?[4,w(n.currentBizId)]:[3,2];case 1:r.sent().downgrade&&(console.warn("automatically destroy downgraded player."),e.dispose()),r.label=2;case 2:return[2]}}))}))},n.processRawJSON=function(e,r){var t,a;return void 0===r&&(r={}),o(this,void 0,void 0,(function(){var e;return i(this,(function(o){switch(o.label){case 0:return n.glLostOccurred?[2,Promise.reject("gl lost happened")]:[4,w(null!==(a=null===(t=r.pluginData)||void 0===t?void 0:t.alipayBizId)&&void 0!==a?a:n.currentBizId)];case 1:if((e=o.sent()).downgrade)throw new Error("downgraded, reason: ".concat(e.reason));return r.renderLevel||(r.renderLevel=g(r.renderLevel)),[2]}}))}))},n.currentBizId="",n.glLostOccurred=!1,n}(n.AbstractPlugin),P=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(n.VFXItem),L=n.isAlipayMiniApp()?my:window.AlipayJSBridge;n.logger.register((function(e,r){for(var t=[],o=2;o<arguments.length;o++)t[o-2]=arguments[o];var i={message:"".concat("[Galacean Effects]"," ").concat(r," ").concat(t.join("")),level:e};n.isAndroid()&&(i.anr_info="mars");try{null==L||L.call("localLog",i)}catch(e){console.error(e)}}));var S=!1;var
|
|
8
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],n):n(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.alipayDowngradePlugin={}),e.ge)}(this,(function(e,n){"use strict";var r=function(e,n){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])},r(e,n)};function t(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function t(){this.constructor=e}r(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}function o(e,n,r,t){return new(r||(r=Promise))((function(o,i){function a(e){try{c(t.next(e))}catch(e){i(e)}}function l(e){try{c(t.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(a,l)}c((t=t.apply(e,n||[])).next())}))}function i(e,n){var r,t,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,t&&(o=2&l[0]?t.return:l[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,l[1])).done)return o;switch(t=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,t=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=n.call(e,a)}catch(e){l=[6,e],t=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}"function"==typeof SuppressedError&&SuppressedError;var a,l,c="low",u="middle",s="high",d="DESKTOP_DEBUG",f="Unknown",p=!1;function v(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return a||(a=h().then((function(e){var n=e.performance,r=e.platform,t=e.model,o=void 0===t?"UNKNOWN_DEVICE":t,i=e.system;if(l||(l=n),p="iOS"===r,f=void 0===i?"Unknown":i,/iPhone(\d+),/.test(d=o)&&!l){var a=+RegExp.$1;l=a<=9?c:a<10?u:s}return 0===d.indexOf(e.brand)&&(d=d.replace(e.brand,"").trim()),d}),(function(e){}))),[2,a.then((function(){return d}),(function(){return d}))]}))}))}function g(e){return"auto"!==e&&e?/[ABS]/.test(e)?e:n.spec.RenderLevel.S:l===s?n.spec.RenderLevel.S:l===u?n.spec.RenderLevel.A:l===c?n.spec.RenderLevel.B:p?n.spec.RenderLevel.S:n.spec.RenderLevel.B}var y="mock-fail";function w(e,r){return void 0===r&&(r={}),o(this,void 0,void 0,(function(){var t,o;return i(this,(function(i){return e===y||"mock-pass"===e?[2,Promise.resolve({downgrade:e===y,reason:"mock"})]:(t=n.isAlipayMiniApp()?my:window.AlipayJSBridge)?(o=performance.now(),[2,v().then((function(){return new Promise((function(i){var a,d=["mars"],f=r.techPoint;f&&d.push.apply(d,function(e,n,r){if(r||2===arguments.length)for(var t,o=0,i=n.length;o<i;o++)!t&&o in n||(t||(t=Array.prototype.slice.call(n,0,o)),t[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}([],function(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,o,i=r.call(e),a=[];try{for(;(void 0===n||n-- >0)&&!(t=i.next()).done;)a.push(t.value)}catch(e){o={error:e}}finally{try{t&&!t.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}(f),!1)),(null!==(a=r.callBridge)&&void 0!==a?a:t.call)("getDowngradeResult",{bizId:e,scene:0,ext:{techPoint:d}},(function(e){var r=void 0;if(console.info("downgrade time: ".concat(performance.now()-o,"ms")),e.error)i({downgrade:4!==e.error,reason:"api error:"+e.error});else try{var t=n.isString(e)?JSON.parse(e):e;if("downgradeResultType"in t?r=t.downgradeResultType:"resultType"in t&&(r=t.resultType),e.context){var a=e.context.deviceInfo;if(a){var d=a.deviceLevel;d===s||d===c?l=d:"medium"===d&&(l=u)}}}catch(e){console.error(e)}void 0===r?i({downgrade:!0,reason:"call downgrade fail"}):n.isAlipayMiniApp()&&b()?i({downgrade:!0,reason:"Force downgrade by downgrade plugin"}):i({downgrade:1===r,reason:r})}))}))}))]):[2,Promise.resolve({downgrade:!1,reason:"no AP env"})]}))}))}function h(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,r){var t=n.isAlipayMiniApp()?my:window.AlipayJSBridge;t?t.call("getSystemInfo",(function(n){n.error?r(n):e(n)})):r("no ap")}))]}))}))}var m=["12,8","13,1","13,2","13,3","13,4"];function b(){if(p&&m.find((function(e){return e===d}))){var e=f.split(".");if(e.length>0&&"16"===e[0])return!0}return!1}var A=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.onPlayerCreated=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return n.glLostOccurred?(console.warn("gl lost happened, new player will be destroyed."),[2,e.dispose()]):n.currentBizId?[4,w(n.currentBizId)]:[3,2];case 1:r.sent().downgrade&&(console.warn("automatically destroy downgraded player."),e.dispose()),r.label=2;case 2:return[2]}}))}))},n.processRawJSON=function(e,r){var t,a;return void 0===r&&(r={}),o(this,void 0,void 0,(function(){var e;return i(this,(function(o){switch(o.label){case 0:return n.glLostOccurred?[2,Promise.reject("gl lost happened")]:[4,w(null!==(a=null===(t=r.pluginData)||void 0===t?void 0:t.alipayBizId)&&void 0!==a?a:n.currentBizId)];case 1:if((e=o.sent()).downgrade)throw new Error("downgraded, reason: ".concat(e.reason));return r.renderLevel||(r.renderLevel=g(r.renderLevel)),[2]}}))}))},n.currentBizId="",n.glLostOccurred=!1,n}(n.AbstractPlugin),P=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(n.VFXItem),L=n.isAlipayMiniApp()?my:window.AlipayJSBridge;n.logger.register((function(e,r){for(var t=[],o=2;o<arguments.length;o++)t[o-2]=arguments[o];var i={message:"".concat("[Galacean Effects]"," ").concat(r," ").concat(t.join("")),level:e};n.isAndroid()&&(i.anr_info="mars");try{null==L||L.call("localLog",i)}catch(e){console.error(e)}}));var S=!1;var E=Symbol("@@_inter_pause");function B(e){e.target===document&&(n.logger.info("Auto pause all players with data offloaded"),n.getActivePlayers().forEach((function(e){e.paused||(e.pause({offloadTexture:!0}),e[E]=!0)})))}function x(e){e.target===document&&(n.logger.info("auto resume all players"),n.getActivePlayers().forEach((function(e){e[E]&&(e.resume(),e[E]=!1)})))}var O="1.6.0-beta.0";n.logger.info("plugin alipay downgrade version: "+O),e.checkDowngrade=w,e.downgradeForMiniprogram=b,e.getAlipayDowngradeBizId=function(){return A.currentBizId},e.getDeviceName=v,e.getRenderLevelByDevice=g,e.getSystemInfo=h,e.resetDevicePending=function(){a=void 0},e.setAlipayDowngradeBizId=function(e,r){void 0===r&&(r={});var t=r.ignoreGLLost,o=r.autoPause,i=r.disableGLLostEvent,a=void 0!==i&&i,l=!0!==t;A.currentBizId=e,S||(n.registerPlugin("alipay-downgrade",A,P,!0),window.addEventListener("unload",(function(){n.getActivePlayers().forEach((function(e){return e.dispose()}))})),a||window.addEventListener("webglcontextlost",(function(e){n.isCanvasUsedByPlayer(e.target)&&(A.glLostOccurred=!0,console.error("webgl lost occur"),l&&(console.warn("webgl lost occur, all players will be downgraded from now on"),n.disableAllPlayer(!0),n.getActivePlayers().forEach((function(e){return e.dispose()}))))}),!0),o&&(document.addEventListener("pause",B),document.addEventListener("resume",x)),S=!0,v())},e.version=O,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
9
9
|
//# sourceMappingURL=index.min.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player downgrade plugin for Alipay
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,意绮
|
|
6
|
-
* Version: v1.
|
|
6
|
+
* Version: v1.6.0-beta.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { spec, isAlipayMiniApp, isString, AbstractPlugin, VFXItem, logger, isAndroid, registerPlugin, getActivePlayers, isCanvasUsedByPlayer, disableAllPlayer } from '@galacean/effects';
|
|
@@ -409,7 +409,7 @@ var registered = false;
|
|
|
409
409
|
*/
|
|
410
410
|
function setAlipayDowngradeBizId(bizId, options) {
|
|
411
411
|
if (options === void 0) { options = {}; }
|
|
412
|
-
var ignoreGLLost = options.ignoreGLLost, autoPause = options.autoPause;
|
|
412
|
+
var ignoreGLLost = options.ignoreGLLost, autoPause = options.autoPause, _a = options.disableGLLostEvent, disableGLLostEvent = _a === void 0 ? false : _a;
|
|
413
413
|
var downgradeWhenGLLost = ignoreGLLost !== true;
|
|
414
414
|
AlipayDowngradePlugin.currentBizId = bizId;
|
|
415
415
|
if (registered) {
|
|
@@ -419,17 +419,19 @@ function setAlipayDowngradeBizId(bizId, options) {
|
|
|
419
419
|
window.addEventListener('unload', function () {
|
|
420
420
|
getActivePlayers().forEach(function (player) { return player.dispose(); });
|
|
421
421
|
});
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
422
|
+
if (!disableGLLostEvent) {
|
|
423
|
+
window.addEventListener('webglcontextlost', function (e) {
|
|
424
|
+
if (isCanvasUsedByPlayer(e.target)) {
|
|
425
|
+
AlipayDowngradePlugin.glLostOccurred = true;
|
|
426
|
+
console.error('webgl lost occur');
|
|
427
|
+
if (downgradeWhenGLLost) {
|
|
428
|
+
console.warn('webgl lost occur, all players will be downgraded from now on');
|
|
429
|
+
disableAllPlayer(true);
|
|
430
|
+
getActivePlayers().forEach(function (player) { return player.dispose(); });
|
|
431
|
+
}
|
|
430
432
|
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
+
}, true);
|
|
434
|
+
}
|
|
433
435
|
if (autoPause) {
|
|
434
436
|
document.addEventListener('pause', pauseAllActivePlayers);
|
|
435
437
|
document.addEventListener('resume', resumePausedPlayers);
|
|
@@ -472,7 +474,7 @@ function resumePausedPlayers(e) {
|
|
|
472
474
|
});
|
|
473
475
|
}
|
|
474
476
|
}
|
|
475
|
-
var version = "1.
|
|
477
|
+
var version = "1.6.0-beta.0";
|
|
476
478
|
logger.info('plugin alipay downgrade version: ' + version);
|
|
477
479
|
|
|
478
480
|
export { checkDowngrade, downgradeForMiniprogram, getAlipayDowngradeBizId, getDeviceName, getRenderLevelByDevice, getSystemInfo, resetDevicePending, setAlipayDowngradeBizId, version };
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/effects-plugin-alipay-downgrade",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-beta.0",
|
|
4
4
|
"description": "Galacean Effects player downgrade plugin for Alipay",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"registry": "https://registry.npmjs.org"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@galacean/effects": "1.
|
|
39
|
+
"@galacean/effects": "1.6.0-beta.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "vite",
|