@galacean/effects-plugin-alipay-downgrade 2.0.0-alpha.7 → 2.0.0-alpha.8

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
@@ -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: v2.0.0-alpha.7
6
+ * Version: v2.0.0-alpha.8
7
7
  */
8
8
 
9
9
  'use strict';
@@ -615,7 +615,7 @@ function formatMessage(level, msg) {
615
615
  return result.join(" ");
616
616
  }
617
617
 
618
- var version = "2.0.0-alpha.7";
618
+ var version = "2.0.0-alpha.8";
619
619
  effects.registerPlugin("alipay-downgrade", AlipayDowngradePlugin, DowngradeVFXItem, true);
620
620
  effects.logger.info("plugin alipay downgrade version: " + version);
621
621
 
package/dist/index.min.js CHANGED
@@ -3,6 +3,6 @@
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.7
7
- */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";function r(e,n){return(r=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function o(e,n){if("function"!=typeof n&&null!==n)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&r(e,n)}var t=function(e){function n(){return e.apply(this,arguments)}return o(n,e),n}(n.VFXItem);function i(e,n,r,o,t,i,a){try{var l=e[i](a),c=l.value}catch(e){r(e);return}l.done?n(c):Promise.resolve(c).then(o,t)}function a(e){return function(){var n=this,r=arguments;return new Promise(function(o,t){var a=e.apply(n,r);function l(e){i(a,o,t,l,c,"next",e)}function c(e){i(a,o,t,l,c,"throw",e)}l(void 0)})}}function l(e,n){var r,o,t,i,a={label:0,sent:function(){if(1&t[0])throw t[1];return t[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 TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,o&&(t=2&l[0]?o.return:l[0]?o.throw||((t=o.return)&&t.call(o),0):o.next)&&!(t=t.call(o,l[1])).done)return t;switch(o=0,t&&(l=[2&l[0],t.value]),l[0]){case 0:case 1:t=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,o=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(t=(t=a.trys).length>0&&t[t.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!t||l[1]>t[0]&&l[1]<t[3])){a.label=l[1];break}if(6===l[0]&&a.label<t[1]){a.label=t[1],t=l;break}if(t&&a.label<t[2]){a.label=t[2],a.ops.push(l);break}t[2]&&a.ops.pop(),a.trys.pop();continue}l=n.call(e,a)}catch(e){l=[6,e],o=0}finally{r=t=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 c="mock-fail",s="high",u="medium",d=!1;function f(){return(f=a(function(e,r){var o,t;return l(this,function(i){var a,l,s,u;return(void 0===r&&(r={}),d||(l=(a=r).ignoreGLLost,s=a.autoPause,u=!0!==l,window.addEventListener("unload",function(){n.getActivePlayers().forEach(function(e){return e.dispose()})}),window.addEventListener("webglcontextlost",function(e){n.isCanvasUsedByPlayer(e.target)&&(b.glLostOccurred=!0,console.error("webgl lost occur"),u&&(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),s&&(document.addEventListener("pause",m),document.addEventListener("resume",L)),d=!0),e===c||"mock-pass"===e)?[2,Promise.resolve({mock:{downgrade:e===c}})]:(o=window.AlipayJSBridge)?(t=performance.now(),[2,(function(){return v.apply(this,arguments)})().then(function(n){return new Promise(function(i){var a,l=["mars"],c=r.techPoint;c&&l.push.apply(l,[].concat(c)),(null!=(a=r.callBridge)?a:o.call)("getDowngradeResult",{bizId:e,scene:0,ext:{techPoint:l}},function(r){var o=performance.now()-t;console.info("downgrade time: "+o+"ms"),i({bizId:e,systemInfo:n,downgradeResult:r,totalTime:o})})})})]):[2,Promise.resolve({noAlipayEnv:!0})]})})).apply(this,arguments)}function v(){return(v=a(function(){return l(this,function(e){return[2,new Promise(function(e,n){var r=window.AlipayJSBridge;r?r.call("getSystemInfo",function(r){r.error?n(r):e(r)}):n("no ap")})]})})).apply(this,arguments)}var p=new(function(){function e(){this.isIOS=!1,this.model="DESKTOP_DEBUG",this.deviceLevel="none",this.isDowngrade=!1}var r=e.prototype;return r.getRenderLevel=function(){return this.deviceLevel===s?n.spec.RenderLevel.S:this.deviceLevel===u?n.spec.RenderLevel.A:"low"===this.deviceLevel?n.spec.RenderLevel.B:this.isIOS?n.spec.RenderLevel.S:n.spec.RenderLevel.B},r.hasDeviceLevel=function(){return h(this.deviceLevel)},r.setBySystemInfo=function(e){var n=e.performance,r=e.platform,o=e.model;this.isIOS="iOS"===r,this.model=void 0===o?"UNKNOWN_DEVICE":o,n&&!this.hasDeviceLevel()&&(this.deviceLevel=n)},r.updateDeviceLevel=function(){if(!this.hasDeviceLevel()&&/iPhone(\d+),/.test(this.model)){var e=+RegExp.$1;e<=9?this.deviceLevel="low":e<10?this.deviceLevel=u:this.deviceLevel=s}},r.getDeviceInfo=function(){return{isIOS:this.isIOS,model:this.model,deviceLevel:this.deviceLevel}},e}());function g(e){if(e.mock){var r=e.mock,o=r.downgrade,t=r.deviceLevel,i=void 0===t?s:t;return p.deviceLevel=i,{downgrade:o,reason:"mock"}}return e.noAlipayEnv?{downgrade:!1,reason:"no AP env"}:e.systemInfo?e.downgradeResult?(p.setBySystemInfo(e.systemInfo),function(e){var r,o=void 0,t=void 0;if(e.error)return{downgrade:4!==e.error,reason:"api error: "+e.error};try{var i=n.isString(e)?JSON.parse(e):e;if("downgradeResultType"in i?o=i.downgradeResultType:"resultType"in i&&(o=i.resultType,t=i.resultReason),e.context){var a=e.context.deviceInfo;if(a){var l=a.deviceLevel;h(l)&&(p.deviceLevel=l)}}p.updateDeviceLevel()}catch(e){console.error(e)}return void 0===o?{downgrade:!0,reason:"call downgrade fail"}:1===o?{downgrade:!0,reason:-1===(r=t)?""+r+"-no config":0===r?""+r+"-none":1===r?""+r+"-downgrade by memory":2===r?""+r+"-downgrade by crash":3===r?""+r+"-downgrade by device":4===r?""+r+"-downgrade by force":""+r}:{downgrade:!1,reason:o}}(e.downgradeResult)):{downgrade:!1,reason:"downgradeResult is required"}:{downgrade:!1,reason:"systemInfo is required"}}function y(e){return e?/[ABS]/.test(e)?e:n.spec.RenderLevel.S:p.getRenderLevel()}function h(e){return e===s||e===u||"low"===e}var w=Symbol("@@_inter_pause");function m(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[w]=!0)}))}function L(e){e.target===document&&(n.logger.info("auto resume all players"),n.getActivePlayers().forEach(function(e){e[w]&&(e.resume(),e[w]=!1)}))}var b=function(e){function n(){return e.apply(this,arguments)}return o(n,e),n.onPlayerCreated=function(e){return a(function(){return l(this,function(r){return n.glLostOccurred?(console.warn("gl lost happened, new player will be destroyed."),[2,e.dispose()]):[2]})})()},n.processRawJSON=function(e,r){return void 0===r&&(r={}),a(function(){var e,o,t;return l(this,function(i){if(n.glLostOccurred)return[2,Promise.reject("gl lost happened")];if(o=null==(e=r.pluginData)?void 0:e.downgrade){if((t=g(o)).downgrade)throw Error("downgraded, reason: "+t.reason)}else console.warn("No downgrade result in pluginData of SceneLoadOptions");return r.renderLevel||(r.renderLevel=y(r.renderLevel)),[2]})})()},n}(n.AbstractPlugin);function S(e,n){for(var r=arguments.length,o=Array(r>2?r-2:0),t=2;t<r;t++)o[t-2]=arguments[t];try{var i=window.AlipayJSBridge,a=A.apply(void 0,[].concat([e,n],o));null==i||i.call("H5APLog",{content:a})}catch(e){console.error(e)}}function P(e,n){for(var r=arguments.length,o=Array(r>2?r-2:0),t=2;t<r;t++)o[t-2]=arguments[t];try{var i=window.AlipayJSBridge;null==i||i.call("localLog",{anr_info:"mars",message:n+o.join(""),level:e})}catch(e){console.error(e)}}function A(e,n){for(var r=arguments.length,o=Array(r>2?r-2:0),t=2;t<r;t++)o[t-2]=arguments[t];var i=["<MARS_PLAYER>","("+e+"):",n];return o.forEach(function(e){i.push(e+"")}),i.join(" ")}b.glLostOccurred=!1,n.logger.register(function(e,r){for(var o=arguments.length,t=Array(o>2?o-2:0),i=2;i<o;i++)t[i-2]=arguments[i];n.isAndroid()?P.apply(void 0,[].concat([e,"[Galacean Effects] "+r],t)):n.isIOS()&&S.apply(void 0,[].concat([e,r],t))});var E="2.0.0-alpha.7";n.registerPlugin("alipay-downgrade",b,t,!0),n.logger.info("plugin alipay downgrade version: "+E),e.checkDowngradeResult=g,e.getDowngradeResult=function(e){return f.apply(this,arguments)},e.getRenderLevelByDevice=y,e.version=E,Object.defineProperty(e,"__esModule",{value:!0})});
6
+ * Version: v2.0.0-alpha.8
7
+ */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";function r(e,n){return(r=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function o(e,n){if("function"!=typeof n&&null!==n)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&r(e,n)}var t=function(e){function n(){return e.apply(this,arguments)}return o(n,e),n}(n.VFXItem);function i(e,n,r,o,t,i,a){try{var l=e[i](a),c=l.value}catch(e){r(e);return}l.done?n(c):Promise.resolve(c).then(o,t)}function a(e){return function(){var n=this,r=arguments;return new Promise(function(o,t){var a=e.apply(n,r);function l(e){i(a,o,t,l,c,"next",e)}function c(e){i(a,o,t,l,c,"throw",e)}l(void 0)})}}function l(e,n){var r,o,t,i,a={label:0,sent:function(){if(1&t[0])throw t[1];return t[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 TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,o&&(t=2&l[0]?o.return:l[0]?o.throw||((t=o.return)&&t.call(o),0):o.next)&&!(t=t.call(o,l[1])).done)return t;switch(o=0,t&&(l=[2&l[0],t.value]),l[0]){case 0:case 1:t=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,o=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(t=(t=a.trys).length>0&&t[t.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!t||l[1]>t[0]&&l[1]<t[3])){a.label=l[1];break}if(6===l[0]&&a.label<t[1]){a.label=t[1],t=l;break}if(t&&a.label<t[2]){a.label=t[2],a.ops.push(l);break}t[2]&&a.ops.pop(),a.trys.pop();continue}l=n.call(e,a)}catch(e){l=[6,e],o=0}finally{r=t=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 c="mock-fail",s="high",u="medium",d=!1;function f(){return(f=a(function(e,r){var o,t;return l(this,function(i){var a,l,s,u;return(void 0===r&&(r={}),d||(l=(a=r).ignoreGLLost,s=a.autoPause,u=!0!==l,window.addEventListener("unload",function(){n.getActivePlayers().forEach(function(e){return e.dispose()})}),window.addEventListener("webglcontextlost",function(e){n.isCanvasUsedByPlayer(e.target)&&(b.glLostOccurred=!0,console.error("webgl lost occur"),u&&(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),s&&(document.addEventListener("pause",m),document.addEventListener("resume",L)),d=!0),e===c||"mock-pass"===e)?[2,Promise.resolve({mock:{downgrade:e===c}})]:(o=window.AlipayJSBridge)?(t=performance.now(),[2,(function(){return v.apply(this,arguments)})().then(function(n){return new Promise(function(i){var a,l=["mars"],c=r.techPoint;c&&l.push.apply(l,[].concat(c)),(null!=(a=r.callBridge)?a:o.call)("getDowngradeResult",{bizId:e,scene:0,ext:{techPoint:l}},function(r){var o=performance.now()-t;console.info("downgrade time: "+o+"ms"),i({bizId:e,systemInfo:n,downgradeResult:r,totalTime:o})})})})]):[2,Promise.resolve({noAlipayEnv:!0})]})})).apply(this,arguments)}function v(){return(v=a(function(){return l(this,function(e){return[2,new Promise(function(e,n){var r=window.AlipayJSBridge;r?r.call("getSystemInfo",function(r){r.error?n(r):e(r)}):n("no ap")})]})})).apply(this,arguments)}var p=new(function(){function e(){this.isIOS=!1,this.model="DESKTOP_DEBUG",this.deviceLevel="none",this.isDowngrade=!1}var r=e.prototype;return r.getRenderLevel=function(){return this.deviceLevel===s?n.spec.RenderLevel.S:this.deviceLevel===u?n.spec.RenderLevel.A:"low"===this.deviceLevel?n.spec.RenderLevel.B:this.isIOS?n.spec.RenderLevel.S:n.spec.RenderLevel.B},r.hasDeviceLevel=function(){return h(this.deviceLevel)},r.setBySystemInfo=function(e){var n=e.performance,r=e.platform,o=e.model;this.isIOS="iOS"===r,this.model=void 0===o?"UNKNOWN_DEVICE":o,n&&!this.hasDeviceLevel()&&(this.deviceLevel=n)},r.updateDeviceLevel=function(){if(!this.hasDeviceLevel()&&/iPhone(\d+),/.test(this.model)){var e=+RegExp.$1;e<=9?this.deviceLevel="low":e<10?this.deviceLevel=u:this.deviceLevel=s}},r.getDeviceInfo=function(){return{isIOS:this.isIOS,model:this.model,deviceLevel:this.deviceLevel}},e}());function g(e){if(e.mock){var r=e.mock,o=r.downgrade,t=r.deviceLevel,i=void 0===t?s:t;return p.deviceLevel=i,{downgrade:o,reason:"mock"}}return e.noAlipayEnv?{downgrade:!1,reason:"no AP env"}:e.systemInfo?e.downgradeResult?(p.setBySystemInfo(e.systemInfo),function(e){var r,o=void 0,t=void 0;if(e.error)return{downgrade:4!==e.error,reason:"api error: "+e.error};try{var i=n.isString(e)?JSON.parse(e):e;if("downgradeResultType"in i?o=i.downgradeResultType:"resultType"in i&&(o=i.resultType,t=i.resultReason),e.context){var a=e.context.deviceInfo;if(a){var l=a.deviceLevel;h(l)&&(p.deviceLevel=l)}}p.updateDeviceLevel()}catch(e){console.error(e)}return void 0===o?{downgrade:!0,reason:"call downgrade fail"}:1===o?{downgrade:!0,reason:-1===(r=t)?""+r+"-no config":0===r?""+r+"-none":1===r?""+r+"-downgrade by memory":2===r?""+r+"-downgrade by crash":3===r?""+r+"-downgrade by device":4===r?""+r+"-downgrade by force":""+r}:{downgrade:!1,reason:o}}(e.downgradeResult)):{downgrade:!1,reason:"downgradeResult is required"}:{downgrade:!1,reason:"systemInfo is required"}}function y(e){return e?/[ABS]/.test(e)?e:n.spec.RenderLevel.S:p.getRenderLevel()}function h(e){return e===s||e===u||"low"===e}var w=Symbol("@@_inter_pause");function m(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[w]=!0)}))}function L(e){e.target===document&&(n.logger.info("auto resume all players"),n.getActivePlayers().forEach(function(e){e[w]&&(e.resume(),e[w]=!1)}))}var b=function(e){function n(){return e.apply(this,arguments)}return o(n,e),n.onPlayerCreated=function(e){return a(function(){return l(this,function(r){return n.glLostOccurred?(console.warn("gl lost happened, new player will be destroyed."),[2,e.dispose()]):[2]})})()},n.processRawJSON=function(e,r){return void 0===r&&(r={}),a(function(){var e,o,t;return l(this,function(i){if(n.glLostOccurred)return[2,Promise.reject("gl lost happened")];if(o=null==(e=r.pluginData)?void 0:e.downgrade){if((t=g(o)).downgrade)throw Error("downgraded, reason: "+t.reason)}else console.warn("No downgrade result in pluginData of SceneLoadOptions");return r.renderLevel||(r.renderLevel=y(r.renderLevel)),[2]})})()},n}(n.AbstractPlugin);function S(e,n){for(var r=arguments.length,o=Array(r>2?r-2:0),t=2;t<r;t++)o[t-2]=arguments[t];try{var i=window.AlipayJSBridge,a=A.apply(void 0,[].concat([e,n],o));null==i||i.call("H5APLog",{content:a})}catch(e){console.error(e)}}function P(e,n){for(var r=arguments.length,o=Array(r>2?r-2:0),t=2;t<r;t++)o[t-2]=arguments[t];try{var i=window.AlipayJSBridge;null==i||i.call("localLog",{anr_info:"mars",message:n+o.join(""),level:e})}catch(e){console.error(e)}}function A(e,n){for(var r=arguments.length,o=Array(r>2?r-2:0),t=2;t<r;t++)o[t-2]=arguments[t];var i=["<MARS_PLAYER>","("+e+"):",n];return o.forEach(function(e){i.push(e+"")}),i.join(" ")}b.glLostOccurred=!1,n.logger.register(function(e,r){for(var o=arguments.length,t=Array(o>2?o-2:0),i=2;i<o;i++)t[i-2]=arguments[i];n.isAndroid()?P.apply(void 0,[].concat([e,"[Galacean Effects] "+r],t)):n.isIOS()&&S.apply(void 0,[].concat([e,r],t))});var E="2.0.0-alpha.8";n.registerPlugin("alipay-downgrade",b,t,!0),n.logger.info("plugin alipay downgrade version: "+E),e.checkDowngradeResult=g,e.getDowngradeResult=function(e){return f.apply(this,arguments)},e.getRenderLevelByDevice=y,e.version=E,Object.defineProperty(e,"__esModule",{value:!0})});
8
8
  //# 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: v2.0.0-alpha.7
6
+ * Version: v2.0.0-alpha.8
7
7
  */
8
8
 
9
9
  import { VFXItem, isString, spec, getActivePlayers, isCanvasUsedByPlayer, disableAllPlayer, logger, AbstractPlugin, isAndroid, isIOS, registerPlugin } from '@galacean/effects';
@@ -611,7 +611,7 @@ function formatMessage(level, msg) {
611
611
  return result.join(" ");
612
612
  }
613
613
 
614
- var version = "2.0.0-alpha.7";
614
+ var version = "2.0.0-alpha.8";
615
615
  registerPlugin("alipay-downgrade", AlipayDowngradePlugin, DowngradeVFXItem, true);
616
616
  logger.info("plugin alipay downgrade version: " + version);
617
617
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/effects-plugin-alipay-downgrade",
3
- "version": "2.0.0-alpha.7",
3
+ "version": "2.0.0-alpha.8",
4
4
  "description": "Galacean Effects player downgrade plugin for Alipay",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "registry": "https://registry.npmjs.org"
35
35
  },
36
36
  "devDependencies": {
37
- "@galacean/effects": "2.0.0-alpha.7"
37
+ "@galacean/effects": "2.0.0-alpha.8"
38
38
  },
39
39
  "scripts": {
40
40
  "dev": "vite",