#!/usr/bin/env node const { spawn } = require("child_process"); const version = "20220222" const path = require("path"); const args = process.argv.slice(2); const funcName = args[args.indexOf('-gn') + 1] const debugWXS = args.includes('-ds') const wccPath = path.resolve(__dirname, './wcc.bin') function genFunctionContent_LLW(wxmlName, config={}, source) { // 起始 let content = `var cs = cs || [];\u000a${config.funcName}` + "=function(_,_v,_n,_p,_s,_wp,_wl,$gwn,$gwl,$gwh,wh,$gstack,$gwrt,gra,grb,TestTest,wfor,_ca,_da,_r,_rz,_o,_oz,_1,_1z,_2,_2z,_m,_mz,nv_getDate,nv_getRegExp,nv_console,nv_parseInt,nv_parseFloat,nv_isNaN,nv_isFinite,nv_decodeURI,nv_decodeURIComponent,nv_encodeURI,nv_encodeURIComponent,$gdc,nv_JSON,_af,_gv,_ai,_grp,_gd,_gapi,$ixc,_ic,_w,_ev,_tsd){return function(path,global){\u000aif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\u000a}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\u000a" // content += "var e_={}\u000aif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\u000avar d_={}\u000aif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\u000avar f_={}\u000aif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\u000avar p_={}\u000a" // cs const cs = source.match(/var cs([\s\S]*?)function gz/) content += "var cs = cs || [];" + cs[1].replace(new RegExp(`\\${funcName}`, 'g'), config.funcName) // gz函数 const exp = `function gz\\${funcName}_${config.num+1}\\(\\)\\{[\\s\\S]*_WXML_GLOBAL__\\.ops_cached\\.\\${funcName}_${config.num+1}\n}` const gz = source.match(new RegExp(exp))[0] content += gz // debug let debug = source.match(new RegExp(`\\n__WXML_GLOBAL__\\.ops_set\\.\\${funcName}=[\\s\\S]*?\\nvar`)) debug = debug[0].substring(0, debug[0].length-3).replace(new RegExp(`\\${funcName}`, 'g'), config.funcName) content += debug content += `var x=['./${wxmlName}.wxml'];d_[x[0]]={}\u000a` // m0 --- m{num} const m0Exp = `var m${config.num}=function\\(e,s,r,gg\\){[\\s\\S]*{f:m${config.num},j:\\[\\],i:\\[\\],ti:\\[\\],ic:\\[\\]}` const m0 = source.match(new RegExp(m0Exp))[0].replace(new RegExp(`m${config.num}`, 'g'), 'm0').replace(new RegExp(`x\\[${config.num}\\]`, 'g'), 'x[0]') content += m0 // path content += `\u000aif(path&&e_[path]){\u000aouterGlobal.__wxml_comp_version__=0.02\u000areturn function(env,dd,global){$gwxc=0;var root={\u0022tag\u0022:\u0022wx-page\u0022};root.children=[]\u000a;g=\u0022${config.funcName}\u0022;var main=e_[path].f\u000acs=[]\u000aif (typeof global===\u0022undefined\u0022)global={};global.f=$gdc(f_[path],\u0022\u0022,1);\u000aif(typeof(outerGlobal.__webview_engine_version__)!='undefined'&&outerGlobal.__webview_engine_version__+1e-6>=0.02+1e-6&&outerGlobal.__mergeData__)\u000a{\u000aenv=outerGlobal.__mergeData__(env,dd);\u000a}\u000atry{\u000amain(env,{},root,global);\u000a_tsd(root)\u000aif(typeof(outerGlobal.__webview_engine_version__)=='undefined'|| outerGlobal.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\u000a}catch(err){\u000aconsole.log(cs, env);\u000aconsole.log(err)\u000athrow err\u000a}\u000a;g=\u0022\u0022;\u000areturn root;\u000a}\u000a}\u000a}\u000a}` // end content += `(__g.a,__g.b,__g.c,__g.d,__g.e,__g.f,__g.g,__g.h,__g.i,__g.j,__g.k,__g.l,__g.m,__g.n,__g.o,__g.p,__g.q,__g.r,__g.s,__g.t,__g.u,__g.v,__g.w,__g.x,__g.y,__g.z,__g.A,__g.B,__g.C,__g.D,__g.E,__g.F,__g.G,__g.H,__g.I,__g.J,__g.K,__g.L,__g.M,__g.N,__g.O,__g.P,__g.Q,__g.R,__g.S,__g.T,__g.U,__g.V,__g.W,__g.X,__g.Y,__g.Z,__g.aa);if(__vd_version_info__.delayedGwx||false)${config.funcName}();` content = content.replace(new RegExp(`\\${funcName}_${config.num+1}`, 'g'), `${config.funcName}_1`) // console.log(content) return content } function genCommonContent_LLW(source){ let common = "var __wxAppData=__wxAppData||{};var __wxAppCode__=__wxAppCode__||{};var global=global||{};var __WXML_GLOBAL__=__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_init:undefined,total_ops:0};var Component=Component||function(){};var definePlugin=definePlugin||function(){};var requirePlugin=requirePlugin||function(){};var Behavior=Behavior||function(){};var __vd_version_info__=__vd_version_info__||{};var __GWX_GLOBAL__=__GWX_GLOBAL__||{};var __globalThis=(typeof __vd_version_info__!=='undefined'&&typeof __vd_version_info__.globalThis!=='undefined')?__vd_version_info__.globalThis:(typeof window!=='undefined'?window:globalThis);if(this&&this.__g===undefined)Object.defineProperty(this,\u0022__g\u0022,{configurable:false,enumerable:false,writable:false,value:function(){function D(e,t){if(typeof t!=\u0022undefined\u0022)e.children.push(t)}function S(e){if(typeof e!=\u0022undefined\u0022)return{tag:\u0022virtual\u0022,wxKey:e,children:[]};return{tag:\u0022virtual\u0022,children:[]}}function v(e){$gwxc++;if($gwxc>=16e3){throw\u0022Dom limit exceeded, please check if there's any mistake you've made.\u0022}return{tag:\u0022wx-\u0022+e,attr:{},children:[],n:[],raw:{},generics:{}}}function e(e,t){t&&e.properities.push(t)}function t(e,t,r){return typeof e[r]!=\u0022undefined\u0022?e[r]:t[r]}function u(e){console.warn(\u0022WXMLRT_\u0022+g+\u0022:\u0022+e)}function r(e,t){u(t+\u0022:-1:-1:-1: Template `\u0022+e+\u0022` is being called recursively, will be stop.\u0022)}var s=console.warn;var n=console.log;function o(){function e(){}e.prototype={hn:function(e,t){if(typeof e==\u0022object\u0022){var r=0;var n=false,o=false;for(var a in e){n=n|a===\u0022__value__\u0022;o=o|a===\u0022__wxspec__\u0022;r++;if(r>2)break}return r==2&&n&&o&&(t||e.__wxspec__!==\u0022m\u0022||this.hn(e.__value__)===\u0022h\u0022)?\u0022h\u0022:\u0022n\u0022}return\u0022n\u0022},nh:function(e,t){return{__value__:e,__wxspec__:t?t:true}},rv:function(e){return this.hn(e,true)===\u0022n\u0022?e:this.rv(e.__value__)},hm:function(e){if(typeof e==\u0022object\u0022){var t=0;var r=false,n=false;for(var o in e){r=r|o===\u0022__value__\u0022;n=n|o===\u0022__wxspec__\u0022;t++;if(t>2)break}return t==2&&r&&n&&(e.__wxspec__===\u0022m\u0022||this.hm(e.__value__))}return false}};return new e}var A=o();function T(e){var t=e.split(\u0022\u005cn \u0022+\u0022 \u0022+\u0022 \u0022+\u0022 \u0022);for(var r=0;r=\u0022:case\u0022<=\u0022:case\u0022>\u0022:case\u0022<\u0022:case\u0022<<\u0022:case\u0022>>\u0022:p=x(e[1],t,r,n,o,a);u=x(e[2],t,r,n,o,a);l=M&&(A.hn(p)===\u0022h\u0022||A.hn(u)===\u0022h\u0022);switch(i){case\u0022+\u0022:f=A.rv(p)+A.rv(u);break;case\u0022*\u0022:f=A.rv(p)*A.rv(u);break;case\u0022/\u0022:f=A.rv(p)/A.rv(u);break;case\u0022%\u0022:f=A.rv(p)%A.rv(u);break;case\u0022|\u0022:f=A.rv(p)|A.rv(u);break;case\u0022^\u0022:f=A.rv(p)^A.rv(u);break;case\u0022&\u0022:f=A.rv(p)&A.rv(u);break;case\u0022===\u0022:f=A.rv(p)===A.rv(u);break;case\u0022==\u0022:f=A.rv(p)==A.rv(u);break;case\u0022!=\u0022:f=A.rv(p)!=A.rv(u);break;case\u0022!==\u0022:f=A.rv(p)!==A.rv(u);break;case\u0022>=\u0022:f=A.rv(p)>=A.rv(u);break;case\u0022<=\u0022:f=A.rv(p)<=A.rv(u);break;case\u0022>\u0022:f=A.rv(p)>A.rv(u);break;case\u0022<\u0022:f=A.rv(p)>\u0022:f=A.rv(p)>>A.rv(u);break;default:break}return l?A.nh(f,\u0022c\u0022):f;break;case\u0022-\u0022:p=e.length===3?x(e[1],t,r,n,o,a):0;u=e.length===3?x(e[2],t,r,n,o,a):x(e[1],t,r,n,o,a);l=M&&(A.hn(p)===\u0022h\u0022||A.hn(u)===\u0022h\u0022);f=l?A.rv(p)-A.rv(u):p-u;return l?A.nh(f,\u0022c\u0022):f;break;case\u0022!\u0022:p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\u0022h\u0022;f=!A.rv(p);return l?A.nh(f,\u0022c\u0022):f;case\u0022~\u0022:p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\u0022h\u0022;f=~A.rv(p);return l?A.nh(f,\u0022c\u0022):f;default:s(\u0022unrecognized op\u0022+i)}}function x(e,t,r,n,o,a){var i=e[0];var p=false;if(typeof a!==\u0022undefined\u0022)o.ap=a;if(typeof i===\u0022object\u0022){var u=i[0];var l,f,v,c,s,y,b,d,h,_,g;switch(u){case 2:return m(e,t,r,n,o);break;case 4:return x(e[1],t,r,n,o,p);break;case 5:switch(e.length){case 2:l=x(e[1],t,r,n,o,p);return M?[l]:[A.rv(l)];return[l];break;case 1:return[];break;default:l=x(e[1],t,r,n,o,p);v=x(e[2],t,r,n,o,p);l.push(M?v:A.rv(v));return l;break}break;case 6:l=x(e[1],t,r,n,o);var w=o.ap;h=A.hn(l)===\u0022h\u0022;f=h?A.rv(l):l;o.is_affected|=h;if(M){if(f===null||typeof f===\u0022undefined\u0022){return h?A.nh(undefined,\u0022e\u0022):undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\u0022h\u0022;c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\u0022undefined\u0022||c===\u0022__proto__\u0022||c===\u0022prototype\u0022||c===\u0022caller\u0022){return h||_?A.nh(undefined,\u0022e\u0022):undefined}y=f[c];if(typeof y===\u0022function\u0022&&!w)y=undefined;g=A.hn(y)===\u0022h\u0022;o.is_affected|=g;return h||_?g?y:A.nh(y,\u0022e\u0022):y}else{if(f===null||typeof f===\u0022undefined\u0022){return undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\u0022h\u0022;c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\u0022undefined\u0022||c===\u0022__proto__\u0022||c===\u0022prototype\u0022||c===\u0022caller\u0022){return undefined}y=f[c];if(typeof y===\u0022function\u0022&&!w)y=undefined;g=A.hn(y)===\u0022h\u0022;o.is_affected|=g;return g?A.rv(y):y}case 7:switch(e[1][0]){case 11:o.is_affected|=A.hn(n)===\u0022h\u0022;return n;case 3:b=A.rv(r);d=A.rv(t);v=e[1][1];if(n&&n.f&&n.f.hasOwnProperty(v)){l=n.f;o.ap=true}else{l=b&&b.hasOwnProperty(v)?r:d&&d.hasOwnProperty(v)?t:undefined}if(M){if(l){h=A.hn(l)===\u0022h\u0022;f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\u0022h\u0022;o.is_affected|=h||g;y=h&&!g?A.nh(y,\u0022e\u0022):y;return y}}else{if(l){h=A.hn(l)===\u0022h\u0022;f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\u0022h\u0022;o.is_affected|=h||g;return A.rv(y)}}return undefined}break;case 8:l={};l[e[1]]=x(e[2],t,r,n,o,p);return l;break;case 9:l=x(e[1],t,r,n,o,p);v=x(e[2],t,r,n,o,p);function O(e,t,r){var n,o;h=A.hn(e)===\u0022h\u0022;_=A.hn(t)===\u0022h\u0022;f=A.rv(e);c=A.rv(t);for(var a in c){if(r||!f.hasOwnProperty(a)){f[a]=M?_?A.nh(c[a],\u0022e\u0022):c[a]:A.rv(c[a])}}return e}var s=l;var j=true;if(typeof e[1][0]===\u0022object\u0022&&e[1][0][0]===10){l=v;v=s;j=false}if(typeof e[1][0]===\u0022object\u0022&&e[1][0][0]===10){var P={};return O(O(P,l,j),v,j)}else return O(l,v,j);break;case 10:l=x(e[1],t,r,n,o,p);l=M?l:A.rv(l);return l;break;case 12:var P;l=x(e[1],t,r,n,o);if(!o.ap){return M&&A.hn(l)===\u0022h\u0022?A.nh(P,\u0022f\u0022):P}var w=o.ap;v=x(e[2],t,r,n,o,p);o.ap=w;h=A.hn(l)===\u0022h\u0022;_=N(v);f=A.rv(l);c=A.rv(v);snap_bb=K(c,\u0022nv_\u0022);try{P=typeof f===\u0022function\u0022?K(f.apply(null,snap_bb)):undefined}catch(t){t.message=t.message.replace(/nv_/g,\u0022\u0022);t.stack=t.stack.substring(0,t.stack.indexOf(\u0022\u005cn\u0022,t.stack.lastIndexOf(\u0022at nv_\u0022)));t.stack=t.stack.replace(/\u005csnv_/g,\u0022 \u0022);t.stack=T(t.stack);if(n.debugInfo){t.stack+=\u0022\u005cn \u0022+\u0022 \u0022+\u0022 \u0022+\u0022 at \u0022+n.debugInfo[0]+\u0022:\u0022+n.debugInfo[1]+\u0022:\u0022+n.debugInfo[2];console.error(t)}P=undefined}return M&&(_||h)?A.nh(P,\u0022f\u0022):P}}else{if(i===3||i===1)return e[1];else if(i===11){var l=\u0022\u0022;for(var D=1;D=0;o--){if(r[e].i[o]&&n[r[e].i[o]][t])return n[r[e].i[o]][t]}for(var o=r[e].ti.length-1;o>=0;o--){var a=ne(r[e].ti[o],r,e);if(a&&n[a][t])return n[a][t]}var i=ae(r,e);for(var o=0;o=0;p--)if(r[e].j[p]){for(var a=r[r[e].j[p]].ti.length-1;a>=0;a--){var u=ne(r[r[e].j[p]].ti[a],r,e);if(u&&n[u][t]){return n[u][t]}}}}function ae(e,t){if(!t)return[];if($gaic[t]){return $gaic[t]}var r=[],n=[],o=0,a=0,i={},p={};n.push(t);p[t]=true;a++;while(o=0.02+1e-6&&outerGlobal.__mergeData__)\u000a{\u000aenv=outerGlobal.__mergeData__(env,dd);\u000a}\u000atry{\u000amain(env,{},root,global);\u000a_tsd(root)\u000aif(typeof(outerGlobal.__webview_engine_version__)=='undefined'|| outerGlobal.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\u000a}catch(err){\u000aconsole.log(cs, env);\u000aconsole.log(err)\u000athrow err\u000a}\u000a;g=\u0022\u0022;\u000areturn root;\u000a}\u000a}\u000a}\u000a}(__g.a,__g.b,__g.c,__g.d,__g.e,__g.f,__g.g,__g.h,__g.i,__g.j,__g.k,__g.l,__g.m,__g.n,__g.o,__g.p,__g.q,__g.r,__g.s,__g.t,__g.u,__g.v,__g.w,__g.x,__g.y,__g.z,__g.A,__g.B,__g.C,__g.D,__g.E,__g.F,__g.G,__g.H,__g.I,__g.J,__g.K,__g.L,__g.M,__g.N,__g.O,__g.P,__g.Q,__g.R,__g.S,__g.T,__g.U,__g.V,__g.W,__g.X,__g.Y,__g.Z,__g.aa);if(__vd_version_info__.delayedGwx||true)" + funcName + "();;var __WXML_DEP__=__WXML_DEP__||{};" return common } function genFunctionContent_LLA(wxmlName, config={}, source) { // 起始 let content = `var cs = cs || [];\u000a${config.funcName}=function(_,_v,_n,_p,_s,_wp,_wl,$gwn,$gwl,$gwh,wh,$gstack,$gwrt,gra,grb,TestTest,wfor,_ca,_da,_r,_rz,_o,_oz,_1,_1z,_2,_2z,_m,_mz,nv_getDate,nv_getRegExp,nv_console,nv_parseInt,nv_parseFloat,nv_isNaN,nv_isFinite,nv_decodeURI,nv_decodeURIComponent,nv_encodeURI,nv_encodeURIComponent,$gdc,nv_JSON,_af,_gv,_ai,_grp,_gd,_gapi,$ixc,_ic,_w,_ev,_tsd){return function(path,global){\u000aif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\u000a}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\u000avar e_={}\u000aif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\u000avar d_={}\u000aif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\u000avar f_={}\u000aif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\u000avar p_={}\u000a` // cs const cs = source.match(/var cs([\s\S]*?)function gz/) content += "var cs = cs || [];" + cs[1].replace(new RegExp(`\\${funcName}`, 'g'), config.funcName) // gz函数 if(!debugWXS){ const exp = `function gz\\${funcName}_${config.num+1}\\(\\)\\{[\\s\\S]*?\\)}` const gz = source.match(new RegExp(exp)) content += gz[0].replace(new RegExp(`\\${funcName}\\_\\d+`, 'g'), `${config.funcName}_1`) + `\u000a})(__WXML_GLOBAL__.ops_cached.${config.funcName}_1);return __WXML_GLOBAL__.ops_cached.${config.funcName}_1\u000a}` }else{ // gz函数2 const exp = `function gz\\${funcName}_${config.num+1}\\(\\)\\{[\\s\\S]*?__WXML_GLOBAL__\\.ops_cached\\.\\${funcName}_${config.num+1}\n}` const gz = source.match(new RegExp(exp)) content += gz[0].replace(new RegExp(`\\${funcName}\\_\\d+`, 'g'), `${config.funcName}_1`) } // debug let debug = source.match(new RegExp(`\\n__WXML_GLOBAL__\\.ops_set\\.\\${funcName}=[\\s\\S]*?\\nvar`)) debug = debug[0].substring(0, debug[0].length-3).replace(new RegExp(`\\${funcName}`, 'g'), config.funcName) content += debug content += `var x=['./${wxmlName}.wxml'];d_[x[0]]={}\u000a` // m0 --- m{num} if(!debugWXS){ content += `var m0=function(e,s,r,gg){\u000avar z=gz${config.funcName}_1()\u000areturn r\u000a}\u000ae_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}` }else{ // m0 --- m{num} const m0Exp = `var m${config.num}=function\\(e,s,r,gg\\){[\\s\\S]*{f:m${config.num},j:\\[\\],i:\\[\\],ti:\\[\\],ic:\\[\\]}` const m0 = source.match(new RegExp(m0Exp))[0].replace(new RegExp(`m${config.num}`, 'g'), 'm0').replace(new RegExp(`x\\[${config.num}\\]`, 'g'), 'x[0]') content += m0.replace(new RegExp(`\\${funcName}\\_\\d+`, 'g'), `${config.funcName}_1`) } content += `\u000aif(path&&e_[path]){\u000areturn function(env,dd,global){$gwxc=0;var root={\u0022tag\u0022:\u0022wx-page\u0022};root.children=[]\u000a;g=\u0022${config.funcName}\u0022;var main=e_[path].f\u000acs=[]\u000aif (typeof global===\u0022undefined\u0022)global={};global.f=$gdc(f_[path],\u0022\u0022,1);\u000atry{\u000amain(env,{},root,global);\u000a_tsd(root)\u000a}catch(err){\u000aconsole.log(cs, env);\u000aconsole.log(err)\u000athrow err\u000a}\u000a;g=\u0022\u0022;\u000areturn root;\u000a}\u000a}\u000a}\u000a}(__g.a,__g.b,__g.c,__g.d,__g.e,__g.f,__g.g,__g.h,__g.i,__g.j,__g.k,__g.l,__g.m,__g.n,__g.o,__g.p,__g.q,__g.r,__g.s,__g.t,__g.u,__g.v,__g.w,__g.x,__g.y,__g.z,__g.A,__g.B,__g.C,__g.D,__g.E,__g.F,__g.G,__g.H,__g.I,__g.J,__g.K,__g.L,__g.M,__g.N,__g.O,__g.P,__g.Q,__g.R,__g.S,__g.T,__g.U,__g.V,__g.W,__g.X,__g.Y,__g.Z,__g.aa);if(__vd_version_info__.delayedGwx||false)${config.funcName}();` // console.log(content) return content } function genCommonContent_LLA(source){ let common = "var __wxAppData=__wxAppData||{};var __wxAppCode__=__wxAppCode__||{};var global=global||{};var __WXML_GLOBAL__=__WXML_GLOBAL__||{entrys:{},defines:{},modules:{},ops:[],wxs_nf_init:undefined,total_ops:0};var Component=Component||function(){};var definePlugin=definePlugin||function(){};var requirePlugin=requirePlugin||function(){};var Behavior=Behavior||function(){};var __vd_version_info__=__vd_version_info__||{};var __GWX_GLOBAL__=__GWX_GLOBAL__||{};var __globalThis=(typeof __vd_version_info__!=='undefined'&&typeof __vd_version_info__.globalThis!=='undefined')?__vd_version_info__.globalThis:(typeof window!=='undefined'?window:globalThis);if(this&&this.__g===undefined)Object.defineProperty(this,\u0022__g\u0022,{configurable:false,enumerable:false,writable:false,value:function(){function D(e,t){if(typeof t!=\u0022undefined\u0022)e.children.push(t)}function S(e){if(typeof e!=\u0022undefined\u0022)return{tag:\u0022virtual\u0022,wxKey:e,children:[]};return{tag:\u0022virtual\u0022,children:[]}}function v(e){$gwxc++;if($gwxc>=16e3){throw\u0022Dom limit exceeded, please check if there's any mistake you've made.\u0022}return{tag:\u0022wx-\u0022+e,attr:{},children:[],n:[],raw:{},generics:{}}}function e(e,t){t&&e.properities.push(t)}function t(e,t,r){return typeof e[r]!=\u0022undefined\u0022?e[r]:t[r]}function u(e){console.warn(\u0022WXMLRT_\u0022+g+\u0022:\u0022+e)}function r(e,t){u(t+\u0022:-1:-1:-1: Template `\u0022+e+\u0022` is being called recursively, will be stop.\u0022)}var s=console.warn;var n=console.log;function o(){function e(){}e.prototype={hn:function(e,t){if(typeof e==\u0022object\u0022){var r=0;var n=false,o=false;for(var a in e){n=n|a===\u0022__value__\u0022;o=o|a===\u0022__wxspec__\u0022;r++;if(r>2)break}return r==2&&n&&o&&(t||e.__wxspec__!==\u0022m\u0022||this.hn(e.__value__)===\u0022h\u0022)?\u0022h\u0022:\u0022n\u0022}return\u0022n\u0022},nh:function(e,t){return{__value__:e,__wxspec__:t?t:true}},rv:function(e){return this.hn(e,true)===\u0022n\u0022?e:this.rv(e.__value__)},hm:function(e){if(typeof e==\u0022object\u0022){var t=0;var r=false,n=false;for(var o in e){r=r|o===\u0022__value__\u0022;n=n|o===\u0022__wxspec__\u0022;t++;if(t>2)break}return t==2&&r&&n&&(e.__wxspec__===\u0022m\u0022||this.hm(e.__value__))}return false}};return new e}var A=o();function T(e){var t=e.split(\u0022\u005cn \u0022+\u0022 \u0022+\u0022 \u0022+\u0022 \u0022);for(var r=0;r=\u0022:case\u0022<=\u0022:case\u0022>\u0022:case\u0022<\u0022:case\u0022<<\u0022:case\u0022>>\u0022:p=x(e[1],t,r,n,o,a);u=x(e[2],t,r,n,o,a);l=M&&(A.hn(p)===\u0022h\u0022||A.hn(u)===\u0022h\u0022);switch(i){case\u0022+\u0022:f=A.rv(p)+A.rv(u);break;case\u0022*\u0022:f=A.rv(p)*A.rv(u);break;case\u0022/\u0022:f=A.rv(p)/A.rv(u);break;case\u0022%\u0022:f=A.rv(p)%A.rv(u);break;case\u0022|\u0022:f=A.rv(p)|A.rv(u);break;case\u0022^\u0022:f=A.rv(p)^A.rv(u);break;case\u0022&\u0022:f=A.rv(p)&A.rv(u);break;case\u0022===\u0022:f=A.rv(p)===A.rv(u);break;case\u0022==\u0022:f=A.rv(p)==A.rv(u);break;case\u0022!=\u0022:f=A.rv(p)!=A.rv(u);break;case\u0022!==\u0022:f=A.rv(p)!==A.rv(u);break;case\u0022>=\u0022:f=A.rv(p)>=A.rv(u);break;case\u0022<=\u0022:f=A.rv(p)<=A.rv(u);break;case\u0022>\u0022:f=A.rv(p)>A.rv(u);break;case\u0022<\u0022:f=A.rv(p)>\u0022:f=A.rv(p)>>A.rv(u);break;default:break}return l?A.nh(f,\u0022c\u0022):f;break;case\u0022-\u0022:p=e.length===3?x(e[1],t,r,n,o,a):0;u=e.length===3?x(e[2],t,r,n,o,a):x(e[1],t,r,n,o,a);l=M&&(A.hn(p)===\u0022h\u0022||A.hn(u)===\u0022h\u0022);f=l?A.rv(p)-A.rv(u):p-u;return l?A.nh(f,\u0022c\u0022):f;break;case\u0022!\u0022:p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\u0022h\u0022;f=!A.rv(p);return l?A.nh(f,\u0022c\u0022):f;case\u0022~\u0022:p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\u0022h\u0022;f=~A.rv(p);return l?A.nh(f,\u0022c\u0022):f;default:s(\u0022unrecognized op\u0022+i)}}function x(e,t,r,n,o,a){var i=e[0];var p=false;if(typeof a!==\u0022undefined\u0022)o.ap=a;if(typeof i===\u0022object\u0022){var u=i[0];var l,f,v,c,s,y,b,d,h,_,g;switch(u){case 2:return m(e,t,r,n,o);break;case 4:return x(e[1],t,r,n,o,p);break;case 5:switch(e.length){case 2:l=x(e[1],t,r,n,o,p);return M?[l]:[A.rv(l)];return[l];break;case 1:return[];break;default:l=x(e[1],t,r,n,o,p);v=x(e[2],t,r,n,o,p);l.push(M?v:A.rv(v));return l;break}break;case 6:l=x(e[1],t,r,n,o);var w=o.ap;h=A.hn(l)===\u0022h\u0022;f=h?A.rv(l):l;o.is_affected|=h;if(M){if(f===null||typeof f===\u0022undefined\u0022){return h?A.nh(undefined,\u0022e\u0022):undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\u0022h\u0022;c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\u0022undefined\u0022||c===\u0022__proto__\u0022||c===\u0022prototype\u0022||c===\u0022caller\u0022){return h||_?A.nh(undefined,\u0022e\u0022):undefined}y=f[c];if(typeof y===\u0022function\u0022&&!w)y=undefined;g=A.hn(y)===\u0022h\u0022;o.is_affected|=g;return h||_?g?y:A.nh(y,\u0022e\u0022):y}else{if(f===null||typeof f===\u0022undefined\u0022){return undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\u0022h\u0022;c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\u0022undefined\u0022||c===\u0022__proto__\u0022||c===\u0022prototype\u0022||c===\u0022caller\u0022){return undefined}y=f[c];if(typeof y===\u0022function\u0022&&!w)y=undefined;g=A.hn(y)===\u0022h\u0022;o.is_affected|=g;return g?A.rv(y):y}case 7:switch(e[1][0]){case 11:o.is_affected|=A.hn(n)===\u0022h\u0022;return n;case 3:b=A.rv(r);d=A.rv(t);v=e[1][1];if(n&&n.f&&n.f.hasOwnProperty(v)){l=n.f;o.ap=true}else{l=b&&b.hasOwnProperty(v)?r:d&&d.hasOwnProperty(v)?t:undefined}if(M){if(l){h=A.hn(l)===\u0022h\u0022;f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\u0022h\u0022;o.is_affected|=h||g;y=h&&!g?A.nh(y,\u0022e\u0022):y;return y}}else{if(l){h=A.hn(l)===\u0022h\u0022;f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\u0022h\u0022;o.is_affected|=h||g;return A.rv(y)}}return undefined}break;case 8:l={};l[e[1]]=x(e[2],t,r,n,o,p);return l;break;case 9:l=x(e[1],t,r,n,o,p);v=x(e[2],t,r,n,o,p);function O(e,t,r){var n,o;h=A.hn(e)===\u0022h\u0022;_=A.hn(t)===\u0022h\u0022;f=A.rv(e);c=A.rv(t);for(var a in c){if(r||!f.hasOwnProperty(a)){f[a]=M?_?A.nh(c[a],\u0022e\u0022):c[a]:A.rv(c[a])}}return e}var s=l;var j=true;if(typeof e[1][0]===\u0022object\u0022&&e[1][0][0]===10){l=v;v=s;j=false}if(typeof e[1][0]===\u0022object\u0022&&e[1][0][0]===10){var P={};return O(O(P,l,j),v,j)}else return O(l,v,j);break;case 10:l=x(e[1],t,r,n,o,p);l=M?l:A.rv(l);return l;break;case 12:var P;l=x(e[1],t,r,n,o);if(!o.ap){return M&&A.hn(l)===\u0022h\u0022?A.nh(P,\u0022f\u0022):P}var w=o.ap;v=x(e[2],t,r,n,o,p);o.ap=w;h=A.hn(l)===\u0022h\u0022;_=N(v);f=A.rv(l);c=A.rv(v);snap_bb=K(c,\u0022nv_\u0022);try{P=typeof f===\u0022function\u0022?K(f.apply(null,snap_bb)):undefined}catch(t){t.message=t.message.replace(/nv_/g,\u0022\u0022);t.stack=t.stack.substring(0,t.stack.indexOf(\u0022\u005cn\u0022,t.stack.lastIndexOf(\u0022at nv_\u0022)));t.stack=t.stack.replace(/\u005csnv_/g,\u0022 \u0022);t.stack=T(t.stack);if(n.debugInfo){t.stack+=\u0022\u005cn \u0022+\u0022 \u0022+\u0022 \u0022+\u0022 at \u0022+n.debugInfo[0]+\u0022:\u0022+n.debugInfo[1]+\u0022:\u0022+n.debugInfo[2];console.error(t)}P=undefined}return M&&(_||h)?A.nh(P,\u0022f\u0022):P}}else{if(i===3||i===1)return e[1];else if(i===11){var l=\u0022\u0022;for(var D=1;D=0;o--){if(r[e].i[o]&&n[r[e].i[o]][t])return n[r[e].i[o]][t]}for(var o=r[e].ti.length-1;o>=0;o--){var a=ne(r[e].ti[o],r,e);if(a&&n[a][t])return n[a][t]}var i=ae(r,e);for(var o=0;o=0;p--)if(r[e].j[p]){for(var a=r[r[e].j[p]].ti.length-1;a>=0;a--){var u=ne(r[r[e].j[p]].ti[a],r,e);if(u&&n[u][t]){return n[u][t]}}}}function ae(e,t){if(!t)return[];if($gaic[t]){return $gaic[t]}var r=[],n=[],o=0,a=0,i={},p={};n.push(t);p[t]=true;a++;while(oe!='-llw') const wcc = spawn(wccPath, argss, { cwd: process.cwd(), }); const spwanData = [], errData = []; wcc.stdout.on("data", (e) => { spwanData.push(e); }); wcc.stderr.on("data", (e) => { errData.push(e); }); wcc.on("close", (n) => { if (0 === n) { const str = Buffer.concat(spwanData).toString() const resultObj = { generateFunctionContent:{ __COMMON__: genCommonContent_LLW(str) }, generateFunctionName: { "__COMMON__": funcName, } } // 获取Linux wcc的输出数据,用于分析 // process.stdout.write(str) // process.exit(1) const indexArr = eval(str.match(/var x=(\[.*\]);/)[1]) const pageConfig = {} indexArr.forEach((ele, i) => { pageConfig[ele.substring(2, ele.length - 5)] = { funcName: `${funcName}_XC_${i}`, num: i } }); for(let key in pageConfig){ resultObj.generateFunctionName[key] = pageConfig[key].funcName resultObj.generateFunctionContent[key] = genFunctionContent_LLW(key, pageConfig[key], str) } let result = JSON.stringify(resultObj) result = result.replace(/\\[\s\S]{1}/gi, function ($0, $1, $2) { let c switch ($0) { case "\\n": c = "\n" break; case "\\t": c = "\t" break; default: c = $0[1] break; } return "\\u" + c.charCodeAt(0).toString(16).padStart(4, "0") }) process.stdout.write(result) } }); } else if (args.includes("-lla")) { const argss = args.filter(e=>e!='-lla') const wcc = spawn(wccPath, argss, { cwd: process.cwd(), }); const spwanData = [], errData = []; wcc.stdout.on("data", (e) => { spwanData.push(e); }); wcc.stderr.on("data", (e) => { errData.push(e); }); wcc.on("close", (n) => { if (0 === n) { let str = Buffer.concat(spwanData).toString(); // 获取Linux wcc的输出数据,用于分析 // process.stdout.write(str) // process.exit(1) const resultObj = { generateFunctionContent:{ __COMMON__: genCommonContent_LLA(str) }, generateFunctionName: { "__COMMON__": funcName, } } const indexArr = eval(str.match(/var x=(\[.*\]);/)[1]) const pageConfig = {} indexArr.forEach((ele, i) => { pageConfig[ele.substring(2, ele.length - 5)] = { funcName: `${funcName}_XC_${i}`, num: i } }); for(let key in pageConfig){ resultObj.generateFunctionName[key] = pageConfig[key].funcName resultObj.generateFunctionContent[key] = genFunctionContent_LLA(key, pageConfig[key], str) } let result = JSON.stringify(resultObj) result = result.replace(/\\[\s\S]{1}/gi, function ($0, $1, $2) { let c switch ($0) { case "\\n": c = "\n" break; case "\\t": c = "\t" break; default: c = $0[1] break; } return "\\u" + c.charCodeAt(0).toString(16).padStart(4, "0") }) process.stdout.write(result) } }); } else { spawn(wccPath, args, { cwd: process.cwd(), stdio: "inherit", }); }