UNPKG

@aiot-toolkit/server

Version:

aiot server

1 lines 1.08 MB
(this.nativeLog||function(e){console.log(e)})("### App framework ### Start: 0.0.6 Build 20201228 HEAD^ f02d5b92");var framework_VERSION="0.0.7",global=this,process={env:{}},setTimeout=global.setTimeout;!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e="0.0.6",t="0.0.5";let n=null;const i=["off","error","warn","info","log","debug","trace"];let o={};function s(e){const t=global.Env&&global.Env.logLevel||"log";return o[t]&&o[t][e]}var r={setNativeConsole:function(){n=global.console,i.forEach(e=>{const t=i.indexOf(e);o[e]={},i.forEach(n=>{i.indexOf(n)<=t&&(o[e][n]=!0)})});const{trace:e,debug:t,log:r,info:a,warn:l,error:c,time:d,timeEnd:h,record:p}=console,u=console;console._ori={trace:e,debug:t,log:r,info:a,warn:l,error:c,time:d,timeEnd:h,record:p},console._ori.record||(console._ori.record=console._ori.info),u.trace=(...e)=>{s("trace")&&console._ori.debug.apply(console,e)},u.debug=(...e)=>{s("debug")&&(console._ori.debug||console._ori.trace).apply(console,e)},u.log=(...e)=>{s("log")&&console._ori.log.apply(console,e)},u.info=(...e)=>{s("info")&&console._ori.info.apply(console,e)},u.warn=(...e)=>{s("warn")&&console._ori.warn.apply(console,e)},u.error=(...e)=>{s("error")&&console._ori.error.apply(console,e)},u.time=(...e)=>{global.Env&&global.Env.logPerf&&s("info")&&console._ori.time.apply(console,e)},u.timeEnd=(...e)=>{global.Env&&global.Env.logPerf&&s("info")&&console._ori.timeEnd.apply(console,e)},u.record=(...e)=>{global.Env&&global.Env.logPerf&&s("info")&&console._ori.record.apply(console,e)}},resetNativeConsole:function(){o={},global.console=n}};let a=null;var l={setNativeRouter:function(){a=global.history},resetNativeRouter:function(){global.history=a}};let c=null,d=null,h=null,p=null,u=null,g=null,m=null,A=null,f=null;var y={setNativeConsole:r.setNativeConsole,resetNativeConsole:r.resetNativeConsole,setNativeProfiler:function(){global.profiler||(global.profiler={isEnabled:()=>!1,saveProfilerData:()=>{},record:global.console.record,time:global.console.time,timeEnd:global.console.timeEnd}),global.profiler._isEnabled=global.profiler.isEnabled()},setNativeTimer:function(){global.setTimeoutNative=function(e,t,n){c((function(){global.setTimeoutCallback(t)}),n)},global.setIntervalNative=function(e,t,n){d((function(){global.setIntervalCallback(t)}),n)},global.requestAnimationFrameNative=function(e,t,n){h((function(){global.requestAnimationFrameCallback(t)}),n)},c=global.setTimeout,d=global.setInterval,h=global.requestAnimationFrame,p=global.clearTimeoutNative,u=global.setTimeoutNative,g=global.clearIntervalNative,m=global.setIntervalNative,A=global.cancelAnimationFrameNative,f=global.requestAnimationFrameNative;const e={};let t=0;"function"==typeof u&&(global.setTimeoutWrap=function(n,i,o){return e[++t]=i,global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### setTimeoutWrap ${t}----`),u(n,t,o||4),t},global.setTimeout=function(e,t){return global.setTimeoutWrap(-1,e,t)},global.setTimeoutCallback=function(t){global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### setTimeout 执行回调 ${t}----`),"function"==typeof e[t]&&(e[t](),delete e[t])},global.clearTimeout=global.clearTimeoutWrap=function(t){if("function"==typeof p){const e=parseInt(t);!isNaN(e)&&p(e)}"function"==typeof e[t]?delete e[t]:e[t]=void 0}),"function"==typeof m&&(global.setIntervalWrap=function(n,i,o){return e[++t]=i,global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### setIntervalWrap ${t}----`),m(n,t,o||4),t},global.setInterval=function(e,t){return global.setIntervalWrap(-1,e,t)},global.setIntervalCallback=function(t){global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### setInterval 执行回调 ${t}----`),"function"==typeof e[t]&&e[t]()},global.clearInterval=global.clearIntervalWrap=function(t){if("function"==typeof g){const e=parseInt(t);!isNaN(e)&&g(e)}"function"==typeof e[t]?delete e[t]:e[t]=void 0}),"function"==typeof f&&(global.requestAnimationFrameWrap=function(n,i){return e[++t]=i,global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### requestAnimationFrame ${t}----`),f(n,t),t},global.requestAnimationFrame=function(e){return global.requestAnimationFrameWrap(-1,e)},global.requestAnimationFrameCallback=function(n){global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### requestAnimationFrame 执行回调 ${t}----`),"function"==typeof e[n]&&e[n]()},global.cancelAnimationFrame=global.cancelAnimationFrameWrap=function(t){if("function"==typeof A){const e=parseInt(t);!isNaN(e)&&A(e)}"function"==typeof e[t]?delete e[t]:e[t]=void 0})},resetNativeTimer:function(){global.setTimeout=c,global.clearTimeout=p,global.clearTimeoutWrap=null,global.setTimeoutCallback=null,global.setTimeoutWrap=null,global.setInterval=d,global.clearInterval=g,global.clearIntervalWrap=null,global.setIntervalCallback=null,global.setIntervalWrap=null,global.requestAnimationFrame=h,global.cancelAnimationFrame=A,global.cancelAnimationFrameWrap=null,global.requestAnimationFrameCallback=null,global.requestAnimationFrameWrap=null},setNativeRouter:l.setNativeRouter,resetNativeRouter:l.resetNativeRouter,freezePrototype:function(){Object.freeze(Object),Object.freeze(Array),Object.freeze(Object.prototype),Object.freeze(Array.prototype),Object.freeze(String.prototype),Object.freeze(Number.prototype),Object.freeze(Boolean.prototype),Object.freeze(Error.prototype),Object.freeze(Date.prototype),Object.freeze(RegExp.prototype)}};function b(e,t,n){return"function"==typeof global.compileAndRunScript?function(e,t,n){let i="(function (";const o=[],s=[];for(const t in e)o.push(t),s.push(e[t]);for(let e=0;e<o.length-1;++e)i+=o[e],i+=",";i+=o[o.length-1],i+=") {",i+=t,i+="\n })";let r=global.compileAndRunScript(i,n);return r&&"function"==typeof r&&(r=r(...s)),r}(e,t,n):function(e,t){const n=[],i=[];for(const t in e)n.push(t),i.push(e[t]);n.push(t),profiler.record("### App Performance ### 编译JS[PERF:compileJS]开始:"+(new Date).toJSON()),profiler.time("PERF:compileJS");const o=new Function(...n);profiler.timeEnd("PERF:compileJS"),profiler.record("### App Performance ### 编译JS[PERF:compileJS]结束:"+(new Date).toJSON()),profiler.record("### App Performance ### 执行JS[PERF:executeJS]开始:"+(new Date).toJSON()),profiler.time("PERF:executeJS");const s=o(...i);return profiler.timeEnd("PERF:executeJS"),profiler.record("### App Performance ### 执行JS[PERF:executeJS]结束:"+(new Date).toJSON()),s}(e,t)}function v(e){const t=Object.prototype.toString.call(e);return t.substring(8,t.length-1).toLowerCase()}function E(e){const t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}const w=/-(\w)/g,C=E(e=>e.replace(w,B));function B(e,t){return t?t.toUpperCase():""}const I=/([a-z\d])([A-Z])/g,k=E(e=>e.replace(I,"$1-$2").toLowerCase());function S(e,...t){if("function"==typeof Object.assign)Object.assign(e,...t);else{const n=t.shift();for(const t in n)e[t]=n[t];t.length&&S(e,...t)}return e}function x(e){return"function"==typeof e}function T(e){return null!==e&&"object"==typeof e}const D=Object.prototype.toString;function M(e){return"[object Object]"===D.call(e)}function O(e){const t=(e+"").charCodeAt(0);return 36===t||95===t}const R=/^@(app)-application\//,L=/^@(app)-component\//,Q=/^@(app)-module\//,P=e=>!!e.match(R),F=e=>!!e.match(L);function N(e){return e.replace(R,"").replace(L,"").replace(Q,"")}let Y=0;function H(){return++Y}let j=!0;const U={},J={};let V={};const K={SYNC:0,CALLBACK:1,SUBSCRIBE:2},W={METHOD:0,ATTRIBUTE:1,EVENT:2},G={RAW:0,JSON:1},q={MODULE_INST:0},z={SINGLE:0,MULTI:1};function X(e,t,n){global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Framework ### require模块:"+t);const i=[t];let o,s={};if(t.indexOf(".")<0){const e=t+".";for(const t in oe())t.startsWith(e)&&i.push(t)}if(i.forEach(i=>{const r=oe()[i];if(!r)return;let a=i.replace(t,"");if("."===a.substr(0,1)&&(a=a.substr(1)),r.instantiable){const e=function(...t){const n=e.__init__(...t);Object.defineProperty(this,"_instId",{enumerable:!1,configurable:!1,writable:!1,value:n&&n.instId})};if(0===a.length)s=e;else{const t=a.split(".");if(t.length>0){const n=t.pop();Z(s,t)[n]=e}}}if(i===t)o=s;else if(a.length>0){const e=a.split(".");e.length>0&&(o=Z(s,e))}!function(e,t,n,i){const o=n.methods;for(const s in o){const r=o[s],a=r.instanceMethod?t.prototype:t;s in a&&console.warn(`### App Framework ### 模块${n.name}的接口函数${s}---- 重复定义`);const l=function(...t){if(e&&e._isApp&&!e._defined)throw new Error(`请确认Native方法调用[${n.name}.${s}()]发生在应用app的生命周期的创建['onCreate()']之后`);const o=Object.prototype.hasOwnProperty.call(this,"_instId")?this._instId:i;return $(e,n,r,t,o)};Object.defineProperty(a,s,{configurable:!1,enumerable:!0,get(){return l.bind(this)},set(e){console.warn(`### App Framework ### 接口${n.name}的方法(${s})为可读,不可覆盖`)}}),global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### require---- 模块${n.name}接口函数${s}`)}const s=n.attributes;for(const e in s){const i=s[e],o=i.instanceMethod?t.prototype:t;Object.defineProperty(o,e,{configurable:!1,enumerable:!0,get(){if(i[1]){let t=this[i[1].name]();if(i[1]&&i[1].subAttrs||i[2]&&i[2].subAttrs){const o=this;t||(t={});let s=[];i[1]&&i[1].subAttrs&&(s=s.concat(i[1].subAttrs)),i[2]&&i[2].subAttrs&&(s=s.concat(i[1].subAttrs));const r=new Set(s);s=Array.from(r);for(const r in s){const a=s[r];Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get(){if(i[1]&&i[1].subAttrs&&!(i[1].subAttrs.indexOf(a)<0))return o[i[1].name]()[a];console.warn(`### App Framework ### 模块${n.name}的接口属性(${e})的子属性(${a})不可读`)},set(t){if(!i[2]||!i[2].subAttrs||i[2].subAttrs.indexOf(a)<0)console.warn(`### App Framework ### 模块${n.name}的接口属性(${e})的子属性(${a})不可写`);else{const e={};e[a]=t,o[i[2].name]({value:e})}}})}}return t}console.warn(`### App Framework ### 模块${n.name}的接口属性(${e})不可读`)},set(t){i[2]?this[i[2].name]({value:t}):console.warn(`### App Framework ### 模块${n.name}的接口属性(${e})不可写`)}})}const r=n.events;for(const e in r){const i=r[e];i.cache=i.cache||{};const o=i.instanceMethod?t.prototype:t;Object.defineProperty(o,e,{configurable:!1,enumerable:!0,get(){const e=void 0===this._instId?-1:this._instId;return i.cache[e]},set(t){if("function"!=typeof t&&-1===[null,void 0].indexOf(t))console.warn(`### App Framework ### 模块${n.name}的接口事件(${e})值类型必须是函数或null`);else{const e=void 0===this._instId?-1:this._instId,n="function"==typeof t?t.bind(this):t;this[i.name]({success:n}),i.cache[e]=t}}})}}(e,o,r,n)}),0===Object.keys(s).length)throw new Error(`请确认引入的模块[${t}]:名称正确并且在manifest.json的features中声明`);return s}function Z(e,t){if(!e)return;let n=e;return t.forEach(e=>{e in n||(n[e]={}),n=n[e]}),n}const _=["success","cancel","fail","complete"];function $(e,t,n,i,o){const{name:s,type:r}=t,{name:a,mode:l,type:c,normalize:d,multiple:h}=n;if(!e||!e._callbacks)return console.warn(`### App Framework ### 容器已销毁,接口调用(${s}.${a}())无效`),new Error("invokeNative: 容器已销毁");if("feature"===r&&!global.JsBridge)return new Error("invokeNative: JsBridge没有初始化");if("module"===r&&!global.ModuleManager)return new Error("invokeNative: ModuleManager没有初始化");profiler.time(`PERF:invokeMod:${s}.${a}()`);const p="feature"===r?global.JsBridge:global.ModuleManager;i.length>0&&void 0===i[0]&&console.warn(`### App Framework ### 接口调用${s}.${a}的参数为 undefined`);const u=i.length>0?i[0]:{};u&&u.callback&&(u.success&&console.warn("### App Framework ### invoke函数不能同时出现'success'和'callback'参数"),u.success=u.callback);let g={};const m={};if(T(u))for(const t in u){const n=u[t];_.indexOf(t)>=0?"function"==typeof n?m[t]=n:console.warn(`### App Framework ### invoke函数的回调参数${t}类型不是function`):"callback"!==t&&(d===G.JSON?g[t]=te(n,e):g[t]="function"==typeof t?te(n,e):n)}else x(u)?m.success=u:g=u;if(d===G.JSON&&(g=JSON.stringify(g)),l===K.SYNC){let n="-1";if(h===z.MULTI&&x(u)&&(n=ne(u).toString(),global.Env&&"trace"===global.Env.logLevel&&console.trace(`${a} 方法的回调函数参数id:${n}`),"-1"===n))return;const i=p.invoke(s,a,g,n,o);return null==i?void console.warn(`### App Framework ### invoke函数 '${s}.${a}' 返回值为null`):(global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### invoke函数 '${s}.${a}' 调用成功,返回值为: ${i}`),ee(e,i,t,a).data)}{let n,i,r;c===W.METHOD&&l===K.CALLBACK&&(m.flagCallback=!0);const d=[];if(Object.keys(m).length){const o=global.isRpkMinPlatformVersionGEQ(1040)?void 0:m;let s=-1;h===z.MULTI?(s=ne(m.success),-1===s&&(global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Framework ### 新增监听实例,id:"+s),s=H())):s=H(),e._callbacks[s]=s=>{const l=m,c=ee(e,s,t,a),d=c.code,h=c.data;0===d&&l.success?l.success.call(o,h):100===d&&l.cancel?l.cancel.call(o):d>=200&&l.fail&&l.fail.call(o,h,d),l.complete&&l.complete.call(o,h),n&&(0===d?i({data:h}):r({data:h,code:d}))},U[s]={instance:e.id.toString(),preserved:l===K.SUBSCRIBE,cbFunc:m.success},d.push(g),d.push(s.toString())}else d.push(g),d.push("-1");if(p.invoke(s,a,...d,o),profiler.timeEnd(`PERF:invokeMod:${s}.${a}()`),c===W.METHOD&&l===K.CALLBACK&&1===Object.keys(m).length)return n=new Promise((e,t)=>{i=e,r=t})}}function ee(e,t,n,i){const o="string"==typeof t?JSON.parse(t):t||{},s=o.content;return s&&s._nativeType===q.MODULE_INST?(n.instantiable&&"__init__"===i?o.data=s:o.data=X(e,s.name,s.instId),e._nativeInstList&&e._nativeInstList.push(t),o.data.instHandler=s.instHandler):o.data=s,o}function te(e,t){switch(v(e)){case"undefined":case"null":return"";case"regexp":return e.toString();case"date":return e.toISOString();case"number":case"string":case"boolean":case"array":case"object":return e;case"function":const n=H();return t._callbacks?t._callbacks[n]=e:global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Framework ### normalize() inst实例已经销毁,不再注册回调"),U[n]={instance:t.id.toString(),preserved:!1,cbFunc:e},n.toString();default:return JSON.stringify(e)}}function ne(e){let t=-1;for(const n in U)if(U[n]&&U[n].cbFunc&&U[n].cbFunc===e){t=n;break}return t}function ie(e,t){J[e]=t}function oe(){return V}class se{constructor(e){this.id=e,this._callbacks={},this._nativeInstList=[],ie(e,this)}invoke(e,t,n,i){global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### 调用对象(${e.id})的回调(${t}) 参数:`,JSON.stringify(n));const o=e._callbacks[t];if("function"==typeof o){const s=o(n);return void 0!==i&&!1!==i||(e._callbacks[t]=void 0),s}return new Error(`invoke: 无效invoke回调函数Id "${t}"`)}destroy(){this._callbacks=null,this._nativeInstList=null,ie(this.id,null)}}class re{constructor(){this.eventMap={}}subscribe(e,t,n){if(n&&n.once){const n=i=>{t(i),this.remove(e,n)};return this.subscribe(e,n)}if(this.eventMap[e]=this.eventMap[e]||[],"function"==typeof t){const n=this.eventMap[e];-1===n.indexOf(t)&&n.push(t)}}publish(e,t,n){let i=null;const o=this.eventMap[e]||[];for(let e=0,n=o.length;e<n;e++)i=o[e](t,i);return i}remove(e,t){if(!this.eventMap[e])return;const n=this.eventMap[e],i=n.indexOf(t);i>-1&&n.splice(i,1)}}const ae=Symbol("connectionProperty"),le=Symbol("messageCallbacks"),ce=Symbol("nextId"),de=Symbol("onMessage");const he=new Map;let pe={};function ue(e){profiler.record("### App Performance ### 注册manifest[PERF:registerManifest]开始:"+(new Date).toJSON()),global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Framework ### 注册manifest:"+JSON.stringify(e)),"string"==typeof e&&(e=JSON.parse(e)),pe=e||{}}let ge=null;const me={};class Ae{constructor(e="message",t={}){this.type=e,this.data=t.data||null,this.timeStamp=Date.now()}}const fe={};function ye(e,t=null){fe[e]=t}var be={init:function(){global.QuickApp={},global.QuickApp.unhandledrejection=(e,t,n)=>{n.stack&&console.warn("Unhandled promise rejection: "+n.stack)},y.setNativeConsole(),y.setNativeProfiler(),y.setNativeTimer(),y.setNativeRouter()},exposeToNative:function(e){for(const t in e)global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Framework ### 注册全局函数----",t),global[t]=(...n)=>{const i=e[t](...n);return i instanceof Error&&console.error(i.toString()),i}},defineBundle:ye,Session:class extends re{constructor(){super(),this[ae]=null,this[ce]=1,this[le]=new Map}connect(){if(this[ae])throw new Error("The inspector session has already connected");this[ae]=new global.Connection(e=>this[de](e))}[de](e){const t=JSON.parse(e);try{if(t.id){const e=this[le].get(t.id);if(this[le].delete(t.id),e){if(t.error)return e(new Error(t.error.code,t.error.message));e(null,t.result)}}else this.publish(t.method,t,null),this.publish("inspectorNotification",t,null)}catch(e){console.log(e)}}post(e,t,n){if(i=e,"[object String]"!==Object.prototype.toString.call(i))throw new Error("method must be a string");var i;if(!n&&x(t)&&(n=t,t=null),t&&"object"!=typeof t)throw new Error("params not object");if(n&&"function"!=typeof n)throw new Error("callback is not valid");if(!this[ae])throw new Error("ERR_INSPECTOR_NOT_CONNECTED");const o=this[ce]++,s={id:o,method:e};t&&(s.params=t),n&&this[le].set(o,n),this[ae].dispatch(JSON.stringify(s))}disconnect(){if(!this[ae])return;this[ae].disconnect(),this[ae]=null,this[le].values().length>0&&console.warn("remainingCallbacks will not executed due to inspector closed"),this[le].clear(),this[ce]=1}},requireBundle:function(e){if(e=e.replace(/\.js$/,""),!fe[e]){let t=global.readResource(`assets:///js/bundles/${e}.js`);"string"==typeof t&&(t=b({},`${t}; return ${e}`,`/bundles/${e}.js`)),ye(e,t)}return fe[e]},loadResource:function(e){const t=global.readResource(e);return t||console.warn("文件不存在,请确认其路径:"+e),t},BroadcastChannel:class{constructor(e){if(global.Env.engine===global.ENGINE_TYPE.CARD)throw new Error("BroadcastChannel is not supported.");Object.defineProperty(this,"name",{configurable:!1,enumerable:!0,writable:!1,value:String(e)}),this._closed=!1,this.onmessage=null,me[this.name]||(me[this.name]=[]),me[this.name].push(this)}postMessage(e){if(this._closed)throw new Error(`BroadcastChannel "${this.name}" is closed.`);const t=me[this.name];if(t&&t.length)for(let n=0;n<t.length;++n){const i=t[n];i._closed||i===this||"function"==typeof i.onmessage&&i.onmessage(new Ae("message",{data:e}))}}close(){if(!this._closed&&(this._closed=!0,me[this.name])){const e=me[this.name].indexOf(this);e>-1?me[this.name].splice(e,1):delete me[this.name]}}},ENGINE_TYPE:{PAGE:"page",CARD:"card"},ModuleHost:se,requireModule:X,requireScriptFile:function(e,t){const n=function(e){const t=he.get(e);return t||console.warn("### App Framework ### 加载依赖的JS模块:路径不存在:"+e),t}(e);if(n&&"string"==typeof n)return b(t,`(function(global){"use strict"; ${n} \n })(Object.create(this))`,e)},initInterface:function(e){},exposure:{registerModules:function(e,t="feature"){profiler.record("### App Performance ### 注册模块[PERF:registerMod]开始:"+(new Date).toJSON()),"string"==typeof e&&(e=JSON.parse(e)),global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Framework ### registerModules---- ",JSON.stringify(e)),"object"==typeof(e=e.map((function(e){return e.__type__=t,e})))&&function(e,t=!0){let n=[];Array.isArray(e)?n=e:n.push(e),n.forEach(e=>{const n=e.name;global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### 注册模块---- ${n} <${e.__type__}>`);let i=V[n];i||(i={type:e.__type__,name:e.name,methods:{},attributes:{},events:{},instantiable:e.instantiable},V[n]=i),i.methods||(i.methods={});const o=i.methods;e.methods&&e.methods.length&&e.methods.forEach(e=>{const s=e.name;if(void 0===e.mode&&(e.mode=K.SYNC),void 0===e.type&&(e.type=W.METHOD),void 0===e.normalize&&(e.normalize=G.JSON),void 0===e.instanceMethod&&(e.instanceMethod=!1),!i.instantiable&&e.instanceMethod)throw new Error(`模块 ${i.name} 配置定义错误`);if(e.type===W.ATTRIBUTE){const t=e.alias,n=e.access;i.attributes[t]=i.attributes[t]||{},i.attributes[t][n]=e,i.attributes[t].instanceMethod=e.instanceMethod}else if(e.type===W.EVENT){const t=e.alias;i.events[t]=e}s?o[s]&&!t||(o[s]=e,global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Framework ### 注册模块 ${n} 接口---- ${s}`)):console.warn(`### App Framework ### 模块 ${n} 的接口没有name属性`)})})}(e),profiler.record("### App Performance ### 注册模块[PERF:registerMod]结束:"+(new Date).toJSON())},registerBundleChunks:function(e){"string"==typeof e&&(e=JSON.parse(e));for(const t in e){const n=e[t];he.set(t,n)}profiler.record("### App Performance ### 注册chunks[PERF:registerBundleChunks]开始:"+(new Date).toJSON()),global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Performance ### 注册chunks[PERF:registerBundleChunks]开始:"+(new Date).toJSON())},execInvokeCallback:function(e){"string"==typeof e&&(e=JSON.parse(e));const t=function(e){const t=U[e];return t&&!0===t.preserved||(U[e]=void 0),t}(e.callback);if(global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Framework ### 处理invoke回调----",JSON.stringify(t)),t){const n=function(e){return J[e]}(t.instance);if(n){const i=[n,e.callback,e.data,t.preserved];return n._callbacks?n.invoke(...i):new Error(`execInvokeCallback: 回调函数所属对象已经无效 "${n.id}"`)}}return new Error(`execInvokeCallback: 无效invoke回调Id "${t&&t.instance}"`)},registerManifest:ue,getManifestField:function(e){const t=e.split(".");let n=pe;for(let e=0,i=t.length;e<i&&(n=n[t[e]],null!=n);e++);return n},isRpkMinPlatformVersionGEQ:function(e){return pe.minPlatformVersion>=e},isRpkDebugMode:function(){return null!==ge||(ge=!1,pe.config&&!0===pe.config.debug&&(ge=!0)),ge}}};class ve{constructor(e,t={bubbles:!1,cancelable:!1}){if(arguments.length>1&&"object"!=typeof t)throw new Error("### App Runtime ### addEventListener() 参数2传递的话,必须是对象:"+t);this._type=e,this._bubbles=t.bubbles,this._cancelable=t.cancelable,this._target=null,this._currentTarget=null,this._eventPhase=ve.NONE,this._defaultPrevented=!1,this._timeStamp=Date.now(),this._supportW3C=!0,this._flagStopPropagation=!1,this._flagStopImmediatePropagation=!1,this._throwError=!0,this._listenNodes={}}get type(){return this._type}get bubbles(){return this._bubbles}get cancelable(){return this._cancelable}get target(){return this._target}get currentTarget(){return this._currentTarget}get eventPhase(){return this._eventPhase}get defaultPrevented(){return this._defaultPrevented}get timeStamp(){return this._timeStamp}stopPropagation(){this._flagStopPropagation=!0}stopImmediatePropagation(){this._flagStopImmediatePropagation=!0,this.stopPropagation()}preventDefault(){throw new Error("### App Runtime ### preventDefault() 暂不支持该方法")}toJSON(){return{type:this._type,target:this._target,currentTarget:this._currentTarget,timeStamp:this._timeStamp}}}ve.NONE=0,ve.CAPTURING_PHASE=1,ve.AT_TARGET=2,ve.BUBBLING_PHASE=3;class Ee extends ve{constructor(){super(...arguments),this._touches=null,this._changedTouches=null}get touches(){return this._touches}set touches(e){if(this._touches)throw new Error("### App Framework ### TouchEvent 不支持修改 touches 属性");this._touches=e}get changedTouches(){return this._changedTouches}set changedTouches(e){if(this._changedTouches)throw new Error("### App Framework ### TouchEvent 不支持修改 changedTouches 属性");this._changedTouches=e}toJSON(){const e=super.toJSON();return Object.assign(e,{touches:this._touches,changedTouches:this._changedTouches})}}const we={HTML_ID:"-1"},Ce={UNKNOWN:0,ELEMENT:1,ATTR:2,TEXT:3,COMMENT:8,DOCUMENT:9,DOCUMENT_FRAGMENT:11,FIGMENT:101};let Be=1;class Ie{constructor(){this._nodeType=Ie.NodeType.UNKNOWN,this._nodeName=null,this._nodeValue=null,this._ownerDocument=null,this._textContent=null,this.ref=(Be++).toString(),this.childNodes=[],this.layoutChildren=[],this.parentNode=null,this.nextSibling=null,this.previousSibling=null,this._docId=null,this._layout=!1,this._render=!1,this._renderCount=null}get nodeType(){return this._nodeType}get nodeName(){return this._nodeName}get nodeValue(){return this._nodeValue}get ownerDocument(){return this._ownerDocument}get textContent(){return this._textContent}set textContent(e){if(this.nodeType!==Ie.NodeType.TEXT){const t=this.ownerDocument.createTextNode(e);this.appendChild(t)}else this._textContent=e}}Ie.NodeRef=we,Ie.NodeType=Ce;const ke={};function Se(e){return ke[e]}function xe(e){const t=Se(e);return t&&t.listener?t.listener:null}function Te(e,t){if(e._docId===t)return;const n=Se(t);if(n){e._docId=t,n._nodeMap[e.ref]=e;for(let t=0,n=e.childNodes.length;t<n;t++)Te(e.childNodes[t],e._docId)}}function De(e,t){return e._nodeMap[t]}function Me(e,t){e.parentNode=t,t._docId&&(Te(e,t._docId),e._depth=t._depth+1);for(let t=0,n=e.childNodes.length;t<n;t++)Me(e.childNodes[t],e)}function Oe(e,t,n,i){n<0&&(n=0);const o=t[n-1],s=t[n];return t.splice(n,0,e),i&&(o&&(o.nextSibling=e||null),e.previousSibling=o||null,e.nextSibling=s||null,s&&(s.previousSibling=e||null)),n}function Re(e,t,n){const i=t.indexOf(e);if(!(i<0)){if(n){const n=t[i-1],o=t[i+1];n&&(n.nextSibling=o||null),o&&(o.previousSibling=n||null),e.previousSibling=null,e.nextSibling=null}t.splice(i,1)}}function Le(e,t,n,i){const o=t.indexOf(e);if(o<0||o===n)return-1;Re(e,t,i);let s=n;return o<=n&&(s=n-1),Oe(e,t,s,i),n}let Qe=1;const Pe=/^data.+/;function Fe(e,t){const n=[],i=Object.assign({},t);if(e)for(let t=0,o=e.length;t<o;t++){const o=e[t];i.hasOwnProperty(o.name)?(n.push({name:k(o.name),value:i[o.name],disabled:!1}),delete i[o.name]):o.disabled&&n.push({name:k(o.name),value:o.value,disabled:o.disabled})}for(const e in i)n.push({name:k(e),value:i[e],disabled:!1});return n}const Ne={};function Ye(e){"string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)||(e=[e]),e.forEach(e=>{if(!e)return;e.name||(e.name=e.type,delete e.type),e.methods=e.methods||[],global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Runtime ### 注册组件---- ",JSON.stringify(e));let t=Ne[e.name];t?t.methods=Array.from(new Set(t.methods.concat(e.methods))):(t=Ne[e.name]=JSON.parse(JSON.stringify(e)),t.def={})})}function He(e){return Ne[e]}function je(e){return e._attr}function Ue(e){return e._style}function Je(e){if(e._classList)return e._classList;const t=je(e);return e._classList=(t.class||"").split(/\s+/).filter(e=>""!==e).filter((e,t,n)=>n.indexOf(e)===t),e._classList}function Ve(e,t=!0,n=!1,i=!1){if(e.nodeType===Ce.ELEMENT){const o={ref:e.ref.toString(),type:e._type},s=function(e){if(e._styleObjectId)return e._styleObjectId;let t=e;for(;t&&!t._styleObjectId;)t=t.parentNode;return t&&(e._styleObjectId=t._styleObjectId),e._styleObjectId}(e);s&&(o.prop={_styleObjectId:s}),n&&e._styleObject&&(o.styleObject=e._styleObject),e._useParentStyle&&(o.prop=o.prop||{},o.prop._useParentStyle=!0);const r=je(e);if(r&&Object.keys(r).length){o.attr={};for(const e in r){const t=r[e];o.attr[e]=-1!==[null,void 0].indexOf(t)?"":t}}const a=Ue(e);if(a&&Object.keys(a).length&&(o.inlineStyle=a),i){const t=function(e){return e.mergedStyle}(e);t&&Object.keys(t).length&&(o.style=t)}const l=Object.keys(e._eventTargetListeners||{});l&&l.length&&(o.event=l);const c=e.layoutChildren||e.childNodes;if(t&&c&&c.length){const e=[];for(let o=0,s=c.length;o<s;o++){const s=c[o],r=Ve(s,t,n,i);We(s)?e.push(r):e.push.apply(e,r)}o.children=e}return o}if(e.nodeType===Ce.FIGMENT){const o=[];if(t&&e.layoutChildren&&e.layoutChildren.length)for(let s=0,r=e.layoutChildren.length;s<r;s++){const r=e.layoutChildren[s],a=Ve(r,t,n,i);r.nodeType===Ce.FIGMENT?o.push.apply(o,a):o.push(a)}return o}if(e.nodeType===Ce.COMMENT)return[];global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### getNodeAsJSON() 忽略该类型(${e.nodeType})的节点序列化`)}function Ke(e){return e._layout}function We(e){return e._render}function Ge(e,t=!1){let n=t?e:e.parentNode;for(;n&&!We(n);)n=n.parentNode;return n}function qe(e){if(null!==e._renderCount)return e._renderCount;let t=We(e)?1:0;if(Ke(e)&&!We(e))for(let n=0,i=e.layoutChildren.length;n<i;n++)t+=qe(e.layoutChildren[n]);return e._renderCount=t,t}function ze(e){let t=e;for(;t;)t._renderCount=null,t=t.parentNode}function Xe(e){const t=e.parentNode;if(e.nodeType===Ce.DOCUMENT||e.ref===we.HTML_ID)return 0;if(!t||!Ke(e))return-1;const n=Ze(e,t);let i=0;return We(t)||(i=Xe(t)),n<0||i<0?-1:n+i}function Ze(e,t){if(!t.layoutChildren||t.layoutChildren.length<=0)return-1;const n=t.layoutChildren.indexOf(e);if(n>0){let e=0;for(let i=0,o=n;i<o;i++)e+=qe(t.layoutChildren[i]);return e}return n}function _e(e){delete e._depth,delete e._tmpRenderIndexInParent,delete e._eventTargetListeners,delete e._bindWatcherList,delete e._vm,function(e){if(delete e._docId,delete e._layout,delete e._render,delete e._renderCount,delete e.nextSibling,delete e.previousSibling,delete e.parentNode,e.childNodes)for(let t=e.childNodes.length-1;t>=0;t--)$e(e.childNodes[t]);delete e.layoutChildren,delete e.childNodes,delete e._content,delete e._ownerDocument,global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### 销毁节点:节点(${e.ref})剩余属性有:[${Object.keys(e).join(", ")}]`)}(e)}function $e(e){global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Runtime ### 销毁元素:"+JSON.stringify(Ve(e,!1,!1,!1))),delete e._classList,delete e._styleObject,delete e._styleObjectId,delete e._useParentStyle,delete e._usedCSSPropertyCache,delete e._matchedCssRuleCache,delete e._mergedStyleCache,delete e._ownCssRuleCache,delete e._attr,delete e._style,delete e._dataset,_e(e)}function et(e,t,n){n instanceof Object||(n={capture:!!n}),t._currentTarget=e,t._target=e;const i=t.type,o=e._eventTargetListeners[i],s=n.capture?ve.CAPTURING_PHASE:ve.BUBBLING_PHASE;if(o&&o[s]&&o[s].list){const n=o[s].list;for(let o=0,s=n.length;o<s;o++){const s=n[o];if(global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### fireTargetEventListener() 事件响应:${t.type},节点:${e.ref}`),s){const n=s.call(t.target,t);if("key"===i)if(!0===n)global.callKeyEvent(n,t.hashcode);else{const{action:n,code:i,repeatCount:o}=t,s=global.keyPressPage(e._docId,{action:n,code:i,repeatCount:o});global.callKeyEvent(s,t.hashcode)}t._listenNodes[t.target.ref]=!0}}}}class tt extends Ie{constructor(){super(...arguments),this._eventTargetListeners={}}addEventListener(e,t,n){if(arguments.length<2)throw new Error("### App Runtime ### addEventListener() 至少需要传递两个参数:"+arguments.length);if("string"!=typeof e)throw new Error("### App Runtime ### addEventListener() 参数1必须是字符串,事件类型");if("function"!=typeof t)throw new Error("### App Runtime ### addEventListener() 参数2必须是函数,监听事件");global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### addEventListener() 节点(${this.ref})注册事件(${e})`),n instanceof Object||(n={capture:!!n,once:!1,passive:!1});const i=n.capture?ve.CAPTURING_PHASE:ve.BUBBLING_PHASE,o=this._eventTargetListeners[e]=this._eventTargetListeners[e]||{};if(o[i]=o[i]||{},o[i].list=o[i].list||[],o[i].hash=o[i].hash||{},-1===o[i].list.indexOf(t)){const e=o[i].list.push(t);o[i].hash[e-1]={capture:!!n.capture,once:!!n.once,passive:!!n.passive}}const s=xe(this._docId);s&&s.addEvent(this.ref,e)}removeEventListener(e,t,n){if(arguments.length<2)throw new Error("### App Runtime ### addEventListener() 至少需要传递两个参数:"+arguments.length);if("string"!=typeof e)throw new Error("### App Runtime ### addEventListener() 参数1必须是字符串,事件类型");if("function"!=typeof t)throw new Error("### App Runtime ### addEventListener() 参数2必须是函数,监听事件");global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### Element ${this.ref} 执行 removeEventListener(${e})---- `),n instanceof Object||(n={capture:!!n});const i=n.capture?ve.CAPTURING_PHASE:ve.BUBBLING_PHASE,o=this._eventTargetListeners[e]=this._eventTargetListeners[e]||{};o[i]=o[i]||{},o[i].list=o[i].list||[],o[i].hash=o[i].hash||{};const s=o[i].list.indexOf(t);-1!==s&&(o[i].list.splice(s,1),o[i].hash[s]=null),0===o[i].list.length&&(o[i]=null)}dispatchEvent(e){if(!(e instanceof ve))throw new Error("### App Runtime ### dispatchEvent() 参数1所属类必须是事件类");if(global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### dispatchEvent() 执行事件:${e.type}, 来自节点:${this.ref}`),e._supportW3C){e._target=this;const t=e.type,n=function(e,t=!1){const n=[];let i=Ge(e,t);for(;i;)n.push(i),i=Ge(i);return n}(this,!0),i=n.slice().reverse().concat(n);if(i[0]&&i[0].parentNode===i[0].ownerDocument){const e=i[0].ownerDocument;i.unshift(e),i.push(e)}for(;i.length>0;){const n=i[0],o=i.indexOf(n),s=i.indexOf(this);if(e._eventPhase=o<s?ve.CAPTURING_PHASE:o===s?ve.AT_TARGET:ve.BUBBLING_PHASE,e._currentTarget=n,!e.bubbles&&e.eventPhase===ve.BUBBLING_PHASE)break;global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### dispatchEvent() 执行事件:${t}, 阶段:${e.eventPhase}, Target:${e.target.ref}, CurrentTarget:${e.currentTarget.ref}`);const r=n._eventTargetListeners[t];let a=e.eventPhase;if(e.target===e.currentTarget&&(a=n===i[1]?ve.CAPTURING_PHASE:ve.BUBBLING_PHASE),r&&r[a]&&r[a].list){const t=r[a].hash,i=r[a].list.slice();for(let o=0,s=i.length;o<s&&!e._flagStopImmediatePropagation;o++){const s=i[o];try{global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### dispatchEvent() 事件响应:${e.type},阶段:${e.eventPhase}`),s&&(s.call(e.currentTarget,e),e._listenNodes[e.currentTarget.ref]=!0)}catch(t){console.error(`### App Runtime ### dispatchEvent() 事件响应:${e.type},阶段:${e.eventPhase}, JS报错:`,t.message,s),console.error(t.stack),e._throwError&&global.setTimeout(()=>{throw t},0)}t[o]&&t[o].once&&n.removeEventListener(e.type,s,t[o])}}if(e._flagStopImmediatePropagation||e._flagStopPropagation)break;i.shift()}e._currentTarget=null}else et(this,e);if("click"===e.type&&global.Env&&global.Env.engine===global.ENGINE_TYPE.CARD){const t=xe(this._docId);t&&t.collectStatistics({type:e.type,ref:this.ref,listeners:Object.keys(e._listenNodes)})}e._listenNodes={}}}function nt(e){if(e.nodeType===Ie.NodeType.ELEMENT&&e._docId)for(let t=0,n=e.layoutChildren.length;t<n;t++)nt(e.layoutChildren[t])}function it(e,t,n){if(t.nodeType===Ie.NodeType.DOCUMENT_FRAGMENT){const i=t.childNodes.slice();for(let o=0,s=i.length;o<s;o++)t.removeChild(i[o]),it(e,i[o],n);return t}const i=Ge(e,!0),o=n?e.childNodes.indexOf(n):e.childNodes.length,s=xe(e._docId);if(t.nodeType===Ie.NodeType.TEXT)throw new Error("### App Runtime ### 不支持在非渲染节点中添加文本节点:"+t.textContent);if(t.parentNode){if(Le(t,e.childNodes,o,!0),Ke(t))if(n){const o=Le(t,e.layoutChildren,e.layoutChildren.indexOf(n));ze(e);const r=Xe(t);if(s&&o>=0)return s.moveNode(t,i,r)}else{const n=Le(t,e.layoutChildren,e.layoutChildren.length);ze(e);const o=Xe(t);if(s&&n>=0)return s.moveNode(t,i,o)}}else if(Me(t,e),Oe(t,e.childNodes,o,!0),nt(t),Ke(t))if(n){Oe(t,e.layoutChildren,e.layoutChildren.indexOf(n)),ze(e);const o=Xe(t);if(s)return s.addNode(t,i,o)}else{Oe(t,e.layoutChildren,e.layoutChildren.length),ze(e);const n=e===i?-1:Xe(t);if(s)return s.addNode(t,i,n)}}class ot extends tt{constructor(){super(...arguments),this._depth=null,this._tmpRenderIndexInParent=null}appendChild(e){if(!(e&&e instanceof Ie))throw new Error("### App Runtime ### appendChild() 函数的node参数无效");if(e.parentNode&&e.parentNode!==this)throw new Error("### App Runtime ### appendChild() 参数node的父节点不匹配");return it(this,e,null)}insertBefore(e,t){if(!(e&&2===arguments.length&&e instanceof Ie))throw new Error("### App Runtime ### insertBefore() 函数的node/before参数无效");if(e.parentNode&&e.parentNode!==this)throw new Error("### App Runtime ### insertBefore() 参数node的父节点不匹配");return e===t||e.nextSibling&&e.nextSibling===t?e:it(this,e,t)}removeChild(e){if(!(e&&e instanceof Ie))throw new Error("### App Runtime ### removeChild() node参数无效");if(e.parentNode!==this)throw new Error("### App Runtime ### removeChild() 参数node的父节点不匹配");if(global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Runtime ### removeChild() 移除节点:"+JSON.stringify(Ve(e,!1,!1,!1))),ze(e),e.parentNode=null,Ke(e)){if(We(e)){const t=xe(e._docId);t&&t.removeElement(e.ref)}else{const t=e.childNodes.slice();for(let n=0;n<t.length;n++)e.removeChild(t[n])}Re(e,this.layoutChildren)}return Re(e,this.childNodes,!0),function e(t,n){if(t._docId!==n)return;const i=Se(n);if(i){for(let n=0,i=t.childNodes.length;n<i;n++)e(t.childNodes[n],t._docId);t._depth=null,i._nodeMap[t.ref]=null,t._docId=null}}(e,e._docId),e}toJSON(){return Ve(this,!0,!1,!1)}}class st extends ot{constructor(e){super(...arguments),this._nodeType=Ie.NodeType.COMMENT,this._nodeName="#comment",this._nodeValue=e,this._layout=!0,this._render=!1,this._data=e}get data(){return this._data}set data(e){const t=""+e;return this._nodeValue=t,this._data=t,this._data}appendChild(e){throw new Error("### App Runtime ### appendChild() 注释节点不支持插入子节点")}insertBefore(e,t){throw new Error("### App Runtime ### insertBefore() 注释节点不支持插入子节点")}toString(){return"\x3c!-- "+this._data+" --\x3e"}}function rt(e,t,n,i){if(!e._ownerDocument||"ref"===t)return;if(!T(n)&&je(e)[t]===n&&!1!==i)return;if("class"===t)e._classList=null;else if(Pe.test(t)){const i=t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()).replace(/^data-/,"").replace(/-([a-z])/g,(e,t)=>t.toUpperCase());e._dataset[i]=n}const o=je(e)[t];je(e)[t]=n,global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### 元素的属性(${t})更新(${o}=>${n})`),lt(e,i,t,n)}function at(e,t,n){if(!e._ownerDocument)return;if(t=t||"",Ue(e)===t&&!1!==n)return;!function(e,t){e._style=t||{}}(e,"string"==typeof t?function(e){const t={};return e.split(";").filter(e=>e.trim()).forEach(e=>{const n=e.indexOf(":");let i=e.substring(0,n).trim();i=C(i);const o=e.substring(n+1).trim();t[i]=o}),global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### 元素的样式转换:${e} 为${JSON.stringify(t)}`),t}(t):t),lt(e,n,"style")}function lt(e,t,n,i,o){const s=xe(e._docId);s&&("class"===n?!t&&s.setStyles(e.ref,null,{class:i}):"id"===n?!t&&s.setStyles(e.ref,null,{id:i}):"style"===n?o?!t&&s.setStyle(e.ref,...o):!t&&s.setStyles(e.ref,Ue(e)):!t&&s.setAttr(e.ref,n,i))}class ct extends ot{constructor(e){super(...arguments),this._nodeType=Ie.NodeType.ELEMENT,this._nodeName=e.toUpperCase(),this._tagName=e.toUpperCase(),this._type=e,this._attr={},this._style={},this._dataset={},this._layout=!0,this._render=!0,this._classList=null,this._styleObject=null,this._styleObjectId=null,this._useParentStyle=null,this._usedCSSPropertyCache={},this._matchedCssRuleCache={},this._mergedStyleCache=null,this._ownCssRuleCache={}}get style(){return this._style}get type(){return console.warn("### App Runtime ### type属性将被废弃,不推荐使用"),this._type}get id(){console.warn("### App Runtime ### id属性将被废弃,不推荐使用");const e=je(this);return e&&e.id}get dataset(){return this._dataset}get attr(){return console.warn("### App Runtime ### attr属性将被废弃,不推荐使用"),je(this)}get tagName(){return this._tagName}get mergedStyle(){return null}appendChild(e){return e.nodeType===Ie.NodeType.TEXT?(rt(this,"value",e.textContent),Me(e,this),e):super.appendChild(e)}insertBefore(e,t){return e.nodeType===Ie.NodeType.TEXT?(rt(this,"value",e.textContent),Me(e,this),e):super.insertBefore(e,t)}hasAttribute(e){const t=je(this);return t&&t.hasOwnProperty(e)}toString(){const e=je(this),t=Ue(this);return"<"+this._type+" attr="+JSON.stringify(e)+" style="+JSON.stringify(t)+">"+this.layoutChildren.map(e=>e.toString()).join("")+"</"+this._type+">"}}class dt extends ot{constructor(){super(...arguments),this._nodeType=Ie.NodeType.DOCUMENT_FRAGMENT,this._nodeName="#document-fragment",this._layout=!0,this._render=!1}}class ht extends ot{constructor(){super(...arguments),this._nodeType=Ie.NodeType.FIGMENT,this._nodeName="#figment",this._layout=!0,this._render=!1}toString(){let e="";return this.childNodes.length&&(e=this.childNodes.map(e=>e.toString()).join("")),e}}class pt extends ot{constructor(e){super(...arguments),this._nodeType=Ie.NodeType.TEXT,this._nodeName="#text",this._textContent=e,this._wholeText=e,this._layout=!1,this._render=!1}get wholeText(){return this._wholeText}appendChild(e){throw new Error("### App Runtime ### appendChild() 文本节点不支持插入子节点")}insertBefore(e,t){throw new Error("### App Runtime ### insertBefore() 文本节点不支持插入子节点")}}class ut extends ct{constructor(){super(...arguments),this.ref=Ie.NodeRef.HTML_ID,this._depth=0}appendChild(e){return function(e,t,n){if(e.layoutChildren.length>0||t.parentNode)return void console.warn("### App Runtime ### Document添加多个Body节点----");const i=Se(e._docId),o=e.childNodes,s=o.indexOf(n);if(s<0?o.push(t):o.splice(s,0,t),Ke(t)){Te(t,t._docId),Me(t,e),Oe(t,e.layoutChildren,e.layoutChildren.length),ze(e),nt(t),i.body=t,xe(e._docId).createBody(t)}else Me(t,e)}(this,e)}insertBefore(e,t){console.warn("### App Runtime ### 暂不支持nodeHtml.insertBefore()")}}class gt extends ct{get value(){return this._attr&&this._attr.value}set value(e){this._attr&&(this._attr.value=e)}get checked(){return this._attr&&this._attr.checked}set checked(e){this._attr&&(this._attr.checked=e)}}const mt=/^(touchstart|touchmove|touchcancel|touchend)$/,At=/^(touchstart|touchmove|touchcancel|touchend|click|longpress)$/;function ft(e,t){let n;return mt.test(e)?(n=new Ee(e,t),n._supportW3C=!1):(n=new ve(e,t),n._supportW3C=!1),At.test(e)&&global.isRpkMinPlatformVersionGEQ(1040)&&(n._supportW3C=!0,n._bubbles=!0),n}function yt(e){const t=new ut("html");return t._ownerDocument=e,Te(t,e._docId),t.parentNode=e,e.childNodes.push(t),e.layoutChildren.push(t),t}class bt extends ot{constructor(e,t){super(...arguments),this._nodeType=Ie.NodeType.DOCUMENT,this._nodeName="#document",this.body=null,e=e?e.toString():"",this._docId=e,this._nodeMap={},this.listener=t,this._styleSheetHash={},this._styleSheetHash[0]=[],this._styleObjectMap=new Map,function(e,t){e&&(ke[e]=t)}(this._docId,this),Object.defineProperty(this,"documentElement",{configurable:!0,enumerable:!1,writable:!1,value:yt(this)})}createElement(e){let t;return t="input"===e||"textarea"===e?new gt(e):new ct(e),t._ownerDocument=this,t}createDocumentFragment(){const e=new dt;return e._ownerDocument=this,e}createTextNode(e){const t=new pt(e);return t._ownerDocument=this,t}createComment(e){const t=new st(e);return t._ownerDocument=this,t}createEvent(e,t){return ft(e,t)}}function vt(e,t=[]){return{module:"dom",method:e,args:t}}class Et{constructor(e,t){this.id=e,this.streamer=t,this.actionLen=0}createFinish(e){global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Runtime ### createFinish---- ");const t=this.streamer.over(this.id,[vt("createFinish")],e);return this.resetActionLen(),t}updateFinish(e){global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Runtime ### updateFinish---- ");const t=this.streamer.over(this.id,[vt("updateFinish")],e);return this.resetActionLen(),t}createBody(e){const t=Ve(e,!0,!0,!1),n=t.children;delete t.children;const i=[vt("createBody",[t])];return n&&i.push.apply(i,n.map(e=>vt("addElement",[t.ref,e,-1]))),this.addActions(i)}addNode(e,t,n){let i;if(t&&We(t)||console.error(`### App Runtime ### addNode的parent(${t.type})必须是可渲染节点`),n<0&&(n=-1),We(e))i=this.addElement(e,t.ref,n);else{let o=n;e.layoutChildren.every(e=>(i=We(e)?this.addElement(e,t.ref,o):this.addNode(e,t,o),o+=qe(e),-1!==i))}return i}addElement(e,t,n){return n>=0||(n=-1),this.addActions(vt("addElement",[t,Ve(e,!0,!0,!1),n]))}removeNode(e){let t;return We(e)?t=this.removeElement(e.ref):e.layoutChildren.every(e=>(t=We(e)?this.removeElement(e.ref):this.removeNode(e),-1!==t)),t}removeElement(e){if(Array.isArray(e)){const t=e.map(e=>vt("removeElement",[e]));return this.addActions(t)}return this.addActions(vt("removeElement",[e]))}moveNode(e,t,n){let i;if(t&&We(t)||console.error("### App Runtime ### moveNode的parent必须是可渲染节点"),n>=0||(n=-1),We(e))i=this.moveElement(e.ref,t.ref,n);else{let o=n;e.layoutChildren.every(e=>(i=We(e)?this.moveElement(e.ref,t.ref,o):this.moveNode(e,t,o),o+=qe(e),-1!==i))}return i}moveElement(e,t,n){return this.addActions(vt("moveElement",[e,t,n]))}setProp(e,t,n){const i={prop:{}};return i.prop[t]=n,this.addActions(vt("updateProps",[e,i]))}setAttr(e,t,n){const i={attr:{}};return null==n?(console.warn(`### App Runtime ### 组件 ${e} 的属性 ${t} 被修改为 undefined/null, 自动修改为默认值或空值`),i.attr[t]=""):i.attr[t]=n,this.addActions(vt("updateAttrs",[e,i]))}setStyle(e,t,n){const i={style:{}};return null==n?(console.warn(`### App Runtime ### 组件 ${e} 的样式 ${t} 被修改为 undefined/null, 自动修改为默认值或空值`),i.style[t]=""):i.style[t]=n,this.addActions(vt("updateStyle",[e,i]))}setStyles(e,t,n){const i={attr:n};return t&&(i.style=t),this.addActions(vt("updateStyles",[e,i]))}setStyleObject(e,t,n,i,o){return this.addActions(vt("updateStyleObject",[e,t,n,i,o]))}addEvent(e,t){return this.addActions(vt("addEvent",[e,t]))}removeEvent(e,t){return this.addActions(vt("removeEvent",[e,t]))}updatePageTitleBar(e){return this.addActions(vt("updateTitleBar",[e]))}updatePageStatusBar(e){return this.addActions(vt("updateStatusBar",[e]))}setMeta(e){return this.addActions(vt("setMeta",[e]))}scrollTo(e){return this.addActions(vt("scrollTo",[e]))}scrollBy(e){return this.addActions(vt("scrollBy",[e]))}exitFullscreen(){return this.addActions(vt("exitFullscreen",[]))}hideSkeleton(e){return this.addActions(vt("hideSkeleton",[e]))}collectStatistics(e){return this.addActions(vt("statistics",[e]))}callHostFunction(e,t,n){return this.addActions(vt(e,[t,n]))}invokeComponentMethod(e,t,n,i){return this.addActions({component:e,ref:t,method:n,args:i})}addActions(e){Array.isArray(e)||(e=[e]),global.Env&&"trace"===global.Env.logLevel&&console.trace("### App Runtime ### addActions---- ",JSON.stringify(e)),this.actionLen+=e.length,this.streamer.push(this.id,e)}hasActions(){return!!this.actionLen}resetActionLen(){this.actionLen=0}}class wt{constructor(e,t){this.call=e,this.batchThreshold=void 0===t?50:t,this._boolDefineNextTick=!0,this.list=[]}push(e,t){let n;if(0===this.batchThreshold)this.list.push.apply(this.list,t);else if(1===this.batchThreshold)this.list.push.apply(this.list,t),n=this.call(e,this.list),this.list.splice(0);else{if(!(this.batchThreshold>1))throw new Error("### App Runtime ### push() 不支持的batchThreshold值:"+this.batchThreshold);for(this.list.push.apply(this.list,t);this.list.length>=this.batchThreshold;){const t=this.list.splice(0,this.batchThreshold);n=this.call(e,t)}}return this._boolDefineNextTick&&this._defineNextTick(e),n}over(e,t){return this.list.length&&(this.call(e,this.list),this.list.splice(0)),this.call(e,t)}_defineNextTick(e){this._nextTick||(this._nextTick=Promise.resolve().then(()=>{this.list.length&&console.warn(`### App Runtime ### _defineNextTick(${e}) 应该由框架保证及时发送`),this._nextTick=null}))}}let Ct=!0;const Bt=function(e,t,...n){return global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Bridge ### sendActions() 发送消息:${e},${t.length},${JSON.stringify(t)}`),Ct&&(global.profiler&&global.profiler.record(`### App Performance ### 首次发送消息[PERF:callNative]开始(${t.length}):${(new Date).toJSON()}`),Ct=!1),t=JSON.stringify(t,(function(e,t){return t&&t.constructor===RegExp?{type:v(t),source:t.source,flags:t.flags}:t})),global.callNative(e,t,...n)};var It={init:function(){Object.freeze(ve),Object.freeze(ve.prototype),Object.freeze(st),Object.freeze(st.prototype),Object.freeze(bt),Object.freeze(bt.prototype),Object.freeze(ct),Object.freeze(ct.prototype),Object.freeze(ht),Object.freeze(ht.prototype),Object.freeze(dt),Object.freeze(dt.prototype),Object.freeze(ut),Object.freeze(ut.prototype),Object.freeze(Ie),Object.freeze(Ie.prototype),Object.freeze(ot),Object.freeze(ot.prototype),Object.freeze(tt),Object.freeze(tt.prototype),Object.freeze(pt),Object.freeze(pt.prototype)},Node:Ie,Event:ve,TouchEvent:Ee,helper:{__proto__:null,registerComponents:Ye,getComponentDefaultOptions:He,bindComponentMethods:function(e){const t=He(e.tagName.toLowerCase());if(t&&t.methods){const n=t.methods.filter(e=>"animate"!==e);return n.forEach((function(n){e[n]||(e[n]=function(...i){const o=xe(e._docId);o?(o.invokeComponentMethod(t.name,e.ref,n,i),global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### 调用组件的方法:${t.name}.${n}()`,JSON.stringify(i))):console.warn(`### App Runtime ### 调用组件的方法无效:${t.name}.${n}(), 组件已销毁`)})})),n}return[]},createDocument:function(e){const t=new wt(Bt),n=new Et(e,t);return new bt(e,n)},registerStyleObject:function(e,t,n,i){if(global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### 基于节点(${i&&i.ref})注册样式节点(${n})`),!i._ownerDocument)return;let o;const s=t&&t["@info"]||{};s&&s.styleObjectId?(o=s.styleObjectId,t=null):o=function(e,t){let n;const i=Se(e);return i&&i._styleObjectMap?(n=i._styleObjectMap.get(t),n||(!function(e){for(const t in e){const n=e[t];n&&n._meta&&delete n._meta}}(t),n=Qe++,i._styleObjectMap.set(t,n))):(n=Qe++,global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### 获取样式对象ID:文档(${e})已销毁,生成无缓存时的ID:${n}`)),n}(i._ownerDocument._docId,t),n||(i._styleObject=t,i._styleObjectId=o);const r=xe(i._docId);r&&r.setStyleObject(i.ref,n,e,o,t)},createEvent:ft,createFigment:function(e){const t=new ht;return t._ownerDocument=e,t},updatePageTitleBar:function(e,t){const n=xe(e._docId);n&&n.updatePageTitleBar(t)},updatePageStatusBar:function(e,t){const n=xe(e._docId);n&&n.updatePageStatusBar(t)},setMeta:function(e,t){const n=xe(e._docId);n&&n.setMeta(t)},scrollTo:function(e,t){const n=xe(e._docId);n&&n.scrollTo(t)},scrollBy:function(e,t){const n=xe(e._docId);n&&n.scrollBy(t)},exitFullscreen:function(e){const t=xe(e._docId);t&&t.exitFullscreen()},hideSkeleton:function(e,t){const n=xe(e._docId);n&&n.hideSkeleton(t)},callHostFunction:function(e,t,n,i){const o=xe(e._docId);o&&o.callHostFunction(t,n,i)},setElementProp:function(e,t,n,i){if(!e._ownerDocument||"ref"===t)return;if(e[t]===n&&!1!==i)return;const o=e[t];e[t]=n,global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### 元素的内部属性(${t})更新(${o}=>${n})`);const s=xe(e._docId);s&&s.setProp(e.ref,t,n)},setElementAttr:rt,setElementStyle:function(e,t,n,i){e._ownerDocument&&(Ue(e)[t]===n&&!1!==i||(Ue(e)[t]=n,lt(e,i,"style",null,[t,n])))},setElementStyles:at,getElementMatchedCssRuleList:function(e,t){const n=Ue(e),i=[{editable:!0,styleSheetName:null,style:Fe(e._inlineStyleFullList,n)}],o=JSON.parse(JSON.stringify(i));return console.warn(`### App Runtime ### 获取样式:该平台版本仅支持获取节点${e.ref}的内联样式`),o},setElementMatchedCssRule:function(e,t,n){const i={},o=[];for(let e=0,t=n.length;e<t;e++){const t=n[e];o.push({name:t.name,value:t.value,disabled:t.disabled}),t.disabled||(i[t.name]=t.value)}"INLINE"===t?(at(e,i),e._inlineStyleFullList=o,global.Env&&"trace"===global.Env.logLevel&&console.trace(`### App Runtime ### 更新样式:元素(${e.ref})的内联样式:${t}:${JSON.stringify(i)}`)):console.warn