From f0d100c761a23e0b1029bd00ca109124afd87910 Mon Sep 17 00:00:00 2001 From: msojocs Date: Thu, 24 Feb 2022 21:14:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=AF=E8=A7=86=E5=8C=96=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1,=20=E5=8F=AF=E8=A7=86=E5=8C=96wcc=E3=80=81wcsc=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compiler/wcc_node/index.js | 121 +++ compiler/wcc_node/src/wcc.js | 4 +- compiler/wcsc_node/index.js | 19 +- compiler/wcsc_node/src/wcsc.js | 18 +- test/wcc/viewedit/1/index.js | 186 ++++ test/wcc/viewedit/1/linux_output.js | 1251 +++++++++++++++++++++++++++ test/wcc/viewedit/1/node.json | 12 + test/wcc/viewedit/1/nodejs.json | 12 + test/wcc/viewedit/1/wine.json | 12 + test/wcc/viewedit/ll.sh | 19 + test/wcc/viewedit/ll1.sh | 18 + test/wcc/viewedit/result.json | 12 + test/wcc/viewedit/wcc.js | 21 + test/wcsc/viewedit/1/node.json | 8 + test/wcsc/viewedit/1/result.json | 8 + test/wcsc/viewedit/wcsc.js | 25 + 16 files changed, 1737 insertions(+), 9 deletions(-) create mode 100644 test/wcc/viewedit/1/index.js create mode 100644 test/wcc/viewedit/1/linux_output.js create mode 100644 test/wcc/viewedit/1/node.json create mode 100644 test/wcc/viewedit/1/nodejs.json create mode 100644 test/wcc/viewedit/1/wine.json create mode 100644 test/wcc/viewedit/ll.sh create mode 100644 test/wcc/viewedit/ll1.sh create mode 100644 test/wcc/viewedit/result.json create mode 100644 test/wcc/viewedit/wcc.js create mode 100644 test/wcsc/viewedit/1/node.json create mode 100644 test/wcsc/viewedit/1/result.json create mode 100644 test/wcsc/viewedit/wcsc.js diff --git a/compiler/wcc_node/index.js b/compiler/wcc_node/index.js index 0085896..d49283d 100644 --- a/compiler/wcc_node/index.js +++ b/compiler/wcc_node/index.js @@ -1,5 +1,6 @@ const util = require('./util') const path = require('path') +const nfs = require('fs') let wcc try { @@ -12,6 +13,58 @@ try { const fs = util.fs +function genFunctionContent_LL(wxmlName, config={}, source, funcName) { + // 起始 + let content = `${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[1].replace(new RegExp(`\\${funcName}`, 'g'), config.funcName) + + // gz函数 + // `function gz\\$gwx_${config.num+1}\\(\\){[\s\S]+_WXML_GLOBAL__\\.ops_cached\\.\\$gwx_${config.num+1}\\u000a}` + 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]){\u000awindow.__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(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)\u000a{\u000aenv=window.__mergeData__(env,dd);\u000a}\u000atry{\u000amain(env,{},root,global);\u000a_tsd(root)\u000aif(typeof(window.__webview_engine_version__)=='undefined'|| window.__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_LL(source, funcName){ + 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__||{};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&&window.__mergeData__)\u000a{\u000aenv=window.__mergeData__(env,dd);\u000a}\u000atry{\u000amain(env,{},root,global);\u000a_tsd(root)\u000aif(typeof(window.__webview_engine_version__)=='undefined'|| window.__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 +} exports = async function (options) { // console.warn('wcc init options:', options); if (!options) throw Error('options is required') @@ -40,6 +93,25 @@ exports = async function (options) { options, ) + // 创建临时目录 + const tmp = nfs.mkdtempSync('wcc_') + // 判断是否replace,是写入replace,否则拷贝文件到临时目录 + for(let file of options.files){ + if (typeof options.replaceContent[file] === 'string') { + // 写入替换内容 + nfs.mkdirSync(path.dirname(path.resolve(tmp, file)), {recursive:true}) + nfs.writeFileSync(path.resolve(tmp, file), options.replaceContent[file], { + + }) + }else{ + // 复制原文件 + nfs.mkdirSync(path.dirname(path.resolve(tmp, file)), {recursive:true}) + nfs.copyFileSync(path.resolve(options.cwd, file), path.resolve(tmp, file)) + } + } + // 使用临时目录执行wcc + options.cwd = tmp + return new Promise(async (resolve, reject) => { let st = Date.now() @@ -58,8 +130,56 @@ exports = async function (options) { try { // console.warn('final options:', options); result = wcc(options.cwd, options.files, {cut: options.isCut}, options) + if(options.lazyload){ + // 懒加载处理 + const str = result + const resultObj = { + generateFunctionName: { + __COMMON__: options.genfuncname, + }, + generateFunctionContent:{ + __COMMON__: genCommonContent_LL(str, options.genfuncname) + }, + } + // 获取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: `${options.genfuncname}_XC_${i}`, + num: i + } + }); + for(let key in pageConfig){ + resultObj.generateFunctionName[key] = pageConfig[key].funcName + resultObj.generateFunctionContent[key] = genFunctionContent_LL(key, pageConfig[key], str, options.genfuncname) + } + // console.log(pageConfig) + result = resultObj + // result = result.replace(/\\[\s\S]{1}/gi, function ($0, $1, $2) { + // // console.log($0, $1) + // 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") + // }) + // console.log(pageConfig) + } // console.warn('wcc result', result) } catch(errmsg) { + nfs.rmSync(tmp, {recursive:true, force:true}) reject(new Error(errmsg)) return } @@ -82,6 +202,7 @@ exports = async function (options) { await fs.writeFile(output, result, 'utf8') } console.warn('wcc get output', Date.now() - st) + nfs.rmSync(tmp, {recursive:true, force:true}) resolve(result) }) } diff --git a/compiler/wcc_node/src/wcc.js b/compiler/wcc_node/src/wcc.js index 2d5bb4b..4fa77d1 100644 --- a/compiler/wcc_node/src/wcc.js +++ b/compiler/wcc_node/src/wcc.js @@ -104,14 +104,14 @@ function wxmlToJS(rootPath, files, { cut } = {}, options={}) { // @TODO,如果遇到参数过长被操作系统干掉的情况,可以使用 --config-path FILE 配置,参数空格换成空行 // const componentArgs = getComponentArgs(files), componentArgs.join(' ') - const args = ['-d', '--split', options.wxmlCompileConfigSplit, type, options.wxmlCompileConfig] + let args = ['-d', '--split', options.wxmlCompileConfigSplit, type, options.wxmlCompileConfig] .concat(files) .concat(['-gn', '$gwx']) // wxs调试 if(options.debugWXS)args.unshift('-ds') // 懒加载 - if(options.lazyload)args=args.concat(['-ll', options.lazyloadConfig]) + // if(options.lazyload)args=args.concat(['-ll', options.lazyloadConfig]) // wxmlParserPath 二进制可执行文件路径 const wxmlParserPath = getWXMLParsePath() diff --git a/compiler/wcsc_node/index.js b/compiler/wcsc_node/index.js index 69d0842..ae324c0 100644 --- a/compiler/wcsc_node/index.js +++ b/compiler/wcsc_node/index.js @@ -56,15 +56,28 @@ exports = async function (options) { options.contents = await Promise.all(tasks) || [] } - let wccResult + let wcscResult try { console.warn('wcsc options', options) - wccResult = wcsc(options.cwd, options.files, options) + wcscResult = wcsc(options.cwd, options.files, options) + if(options.lazyload){ + const t = wcscResult + wcscResult = { + common: t.comm, + pageWxss: {} + } + for(let key in t){ + console.log(key) + if(key.endsWith('.wxss')){ + wcscResult.pageWxss[key] = t[key] + } + } + } } catch (errmsg) { throw new Error(errmsg) } - const result = options.lazyload ? wccResult : tranWcscResultToObject(wccResult) + const result = options.lazyload ? wcscResult : tranWcscResultToObject(wcscResult) if (options.output) { const output = path.resolve(options.cwd, options.output) diff --git a/compiler/wcsc_node/src/wcsc.js b/compiler/wcsc_node/src/wcsc.js index a19a6a2..047f635 100644 --- a/compiler/wcsc_node/src/wcsc.js +++ b/compiler/wcsc_node/src/wcsc.js @@ -58,19 +58,29 @@ function getAllFiles(rootPath, files) { * 编译 wxss 到 js */ function wxssToJS(rootPath, files, options) { - files = getAllFiles(rootPath, files) + // files = getAllFiles(rootPath, files) - const args = ['-db', '-pc', String(files.compWxssNum)].concat(files.list) + const args = ['-db', '-pc', String(options.pageCount)].concat(files) const wxssParserPath = getWXSSParsePath() console.warn('wcsc args: ', args) const wcsc = spawnSync(wxssParserPath, args, { cwd: rootPath }) if (wcsc.status === 0) { - const res = wcsc.stdout.toString().split('=') + let res = wcsc.stdout.toString(); + res = res.split('=') const funcList = {} for (let i = 0, len = res.length; i < len && res[i + 1]; i += 2) { - funcList[res[i]] = res[i + 1] + funcList[res[i]] = res[i + 1].replace( + /((\\x[\da-f]{2}|\\u[\da-f]{4})){1,}/gi, + function ($0, $1, $2) { + return eval('"' + $0 + '"'); + } + ).replace(/\\[\s\S]{1}/gi, function ($0, $1, $2) { + // console.log($0, $1) + const c = $0 === "\\n" ? "\n" : $0[1]; + return c + }) } return funcList } else { diff --git a/test/wcc/viewedit/1/index.js b/test/wcc/viewedit/1/index.js new file mode 100644 index 0000000..c5458d6 --- /dev/null +++ b/test/wcc/viewedit/1/index.js @@ -0,0 +1,186 @@ +$gwx_XC_0=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){ +if(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;} +if(typeof __WXML_GLOBAL__ === 'undefined') { + __WXML_GLOBAL__={}; +}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {}; +var e_={} +if(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys; +var d_={} +if(typeof(global.defines)==='undefined')global.defines={};d_=global.defines; +var f_={} +if(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {}; +var p_={} +var cs +__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {} +__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {}; +__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {}; +var z=__WXML_GLOBAL__.ops_set.$gwx_XC_0 || []; +function gz$gwx_XC_0_1(){ +if( __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1 +__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1=[]; +(function(z){var a=11;function Z(ops){z.push(ops)} +Z([3,'container']) +Z([3,'0']) +Z([3,'userinfo']) +Z([3,'1']) +Z([3,'2']) +Z([[7],[3,'canIUseOpenData']]) +Z([3,'bindViewTap']) +Z([3,'userinfo-avatar']) +Z([3,'3']) +Z([3,'width: 183rpx; height: 148rpx; display: block; box-sizing: border-box']) +Z([3,'4']) +Z([3,'userAvatarUrl']) +Z([3,'5']) +Z([3,'userNickName']) +Z([3,'6']) +Z([[2,'!'],[[7],[3,'hasUserInfo']]]) +Z([[7],[3,'canIUseGetUserProfile']]) +Z([3,'getUserProfile']) +Z([3,'7']) +Z([3,' 获取头像昵称 ']) +Z([[7],[3,'canIUse']]) +Z([3,'getUserInfo']) +Z([3,'8']) +Z(z[21]) +Z(z[19]) +Z([3,'9']) +Z([3,' 请使用1.4.4及以上版本基础库 ']) +Z([3,'10']) +Z(z[6]) +Z(z[7]) +Z([3,'11']) +Z([3,'cover']) +Z([[6],[[7],[3,'userInfo']],[3,'avatarUrl']]) +Z([3,'userinfo-nickname']) +Z([3,'12']) +Z([a,[[6],[[7],[3,'userInfo']],[3,'nickName']]]) +Z([3,'usermotto']) +Z([3,'13']) +Z([3,'user-motto']) +Z([3,'14']) +Z([a,[[7],[3,'motto']]]) +})(__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1 +} +__WXML_GLOBAL__.ops_set.$gwx_XC_0=z; +__WXML_GLOBAL__.ops_init.$gwx_XC_0=true; +var x=['./pages/index/index.wxml'];d_[x[0]]={} +var m0=function(e,s,r,gg){ +var z=gz$gwx_XC_0_1() +cs.push("./pages/index/index.wxml:view:2:2") +var oB=_mz(z,'view',['class',0,'data-ib-structured-id',1],[],e,s,gg) +cs.push("./pages/index/index.wxml:view:3:4") +var xC=_mz(z,'view',['class',2,'data-ib-structured-id',1],[],e,s,gg) +var oD=_v() +_(xC,oD) +if(_oz(z,5,e,s,gg)){oD.wxVkey=1 +cs.push("./pages/index/index.wxml:block:4:6") +cs.push("./pages/index/index.wxml:view:5:8") +var fE=_mz(z,'view',['bindtap',6,'class',1,'data-ib-structured-id',2,'style',3],[],e,s,gg) +cs.push("./pages/index/index.wxml:open-data:6:10") +var cF=_mz(z,'open-data',['data-ib-structured-id',10,'type',1],[],e,s,gg) +cs.pop() +_(fE,cF) +cs.pop() +_(oD,fE) +cs.push("./pages/index/index.wxml:open-data:8:8") +var hG=_mz(z,'open-data',['data-ib-structured-id',12,'type',1],[],e,s,gg) +cs.pop() +_(oD,hG) +cs.pop() +} +else if(_oz(z,15,e,s,gg)){oD.wxVkey=2 +cs.push("./pages/index/index.wxml:block:10:6") +var oH=_v() +_(oD,oH) +if(_oz(z,16,e,s,gg)){oH.wxVkey=1 +cs.push("./pages/index/index.wxml:button:11:8") +cs.push("./pages/index/index.wxml:button:11:8") +var cI=_mz(z,'button',['bindtap',17,'data-ib-structured-id',1],[],e,s,gg) +var oJ=_oz(z,19,e,s,gg) +_(cI,oJ) +cs.pop() +_(oH,cI) +cs.pop() +} +else if(_oz(z,20,e,s,gg)){oH.wxVkey=2 +cs.push("./pages/index/index.wxml:button:12:8") +cs.push("./pages/index/index.wxml:button:12:8") +var lK=_mz(z,'button',['bindgetuserinfo',21,'data-ib-structured-id',1,'openType',2],[],e,s,gg) +var aL=_oz(z,24,e,s,gg) +_(lK,aL) +cs.pop() +_(oH,lK) +cs.pop() +} +else{oH.wxVkey=3 +cs.push("./pages/index/index.wxml:view:13:8") +cs.push("./pages/index/index.wxml:view:13:8") +var tM=_n('view') +_rz(z,tM,'data-ib-structured-id',25,e,s,gg) +var eN=_oz(z,26,e,s,gg) +_(tM,eN) +cs.pop() +_(oH,tM) +cs.pop() +} +oH.wxXCkey=1 +cs.pop() +} +else{oD.wxVkey=3 +cs.push("./pages/index/index.wxml:block:15:6") +cs.push("./pages/index/index.wxml:image:16:8") +var bO=_mz(z,'image',['bindtap',28,'class',1,'data-ib-structured-id',2,'mode',3,'src',4],[],e,s,gg) +cs.pop() +_(oD,bO) +cs.push("./pages/index/index.wxml:text:17:8") +var oP=_mz(z,'text',['class',33,'data-ib-structured-id',1],[],e,s,gg) +var xQ=_oz(z,35,e,s,gg) +_(oP,xQ) +cs.pop() +_(oD,oP) +cs.pop() +} +oD.wxXCkey=1 +cs.pop() +_(oB,xC) +cs.push("./pages/index/index.wxml:view:20:4") +var oR=_mz(z,'view',['class',36,'data-ib-structured-id',1],[],e,s,gg) +cs.push("./pages/index/index.wxml:text:21:6") +var fS=_mz(z,'text',['class',38,'data-ib-structured-id',1],[],e,s,gg) +var cT=_oz(z,40,e,s,gg) +_(fS,cT) +cs.pop() +_(oR,fS) +cs.pop() +_(oB,oR) +cs.pop() +_(r,oB) +return r +} +e_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]} +if(path&&e_[path]){ +window.__wxml_comp_version__=0.02 +return function(env,dd,global){$gwxc=0;var root={"tag":"wx-page"};root.children=[] +;g="$gwx_XC_0";var main=e_[path].f +cs=[] +if (typeof global==="undefined")global={};global.f=$gdc(f_[path],"",1); +if(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__) +{ +env=window.__mergeData__(env,dd); +} +try{ +main(env,{},root,global); +_tsd(root) +if(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);} +}catch(err){ +console.log(cs, env); +console.log(err) +throw err +} +;g=""; +return root; +} +} +} +}(__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)$gwx_XC_0(); \ No newline at end of file diff --git a/test/wcc/viewedit/1/linux_output.js b/test/wcc/viewedit/1/linux_output.js new file mode 100644 index 0000000..3d51fd3 --- /dev/null +++ b/test/wcc/viewedit/1/linux_output.js @@ -0,0 +1,1251 @@ +/*v0.5vv_20200413_syb_scopedata*/window.__wcc_version__='v0.5vv_20200413_syb_scopedata';window.__wcc_version_info__={"customComponents":true,"fixZeroRpx":true,"propValueDeepCopy":false}; +var $gwxc +var $gaic={} +$gwx=function(path,global){ +if(typeof global === 'undefined') global={};if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={}; +}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {}; +function _(a,b){if(typeof(b)!='undefined')a.children.push(b);} +function _v(k){if(typeof(k)!='undefined')return {tag:'virtual','wxKey':k,children:[]};return {tag:'virtual',children:[]};} +function _n(tag){$gwxc++;if($gwxc>=16000){throw 'Dom limit exceeded, please check if there\'s any mistake you\'ve made.'};return {tag:'wx-'+tag,attr:{},children:[],n:[],raw:{},generics:{}}} +function _p(a,b){b&&a.properities.push(b);} +function _s(scope,env,key){return typeof(scope[key])!='undefined'?scope[key]:env[key]} +function _wp(m){console.warn("WXMLRT_$gwx:"+m)} +function _wl(tname,prefix){_wp(prefix+':-1:-1:-1: Template `' + tname + '` is being called recursively, will be stop.')} +$gwn=console.warn; +$gwl=console.log; +function $gwh() +{ +function x() +{ +} +x.prototype = +{ +hn: function( obj, all ) +{ +if( typeof(obj) == 'object' ) +{ +var cnt=0; +var any1=false,any2=false; +for(var x in obj) +{ +any1=any1|x==='__value__'; +any2=any2|x==='__wxspec__'; +cnt++; +if(cnt>2)break; +} +return cnt == 2 && any1 && any2 && ( all || obj.__wxspec__ !== 'm' || this.hn(obj.__value__) === 'h' ) ? "h" : "n"; +} +return "n"; +}, +nh: function( obj, special ) +{ +return { __value__: obj, __wxspec__: special ? special : true } +}, +rv: function( obj ) +{ +return this.hn(obj,true)==='n'?obj:this.rv(obj.__value__); +}, +hm: function( obj ) +{ +if( typeof(obj) == 'object' ) +{ +var cnt=0; +var any1=false,any2=false; +for(var x in obj) +{ +any1=any1|x==='__value__'; +any2=any2|x==='__wxspec__'; +cnt++; +if(cnt>2)break; +} +return cnt == 2 && any1 && any2 && (obj.__wxspec__ === 'm' || this.hm(obj.__value__) ); +} +return false; +} +} +return new x; +} +wh=$gwh(); +function $gstack(s){ +var tmp=s.split('\n '+' '+' '+' '); +for(var i=0;i=': +case '<=': +case '>': +case '<': +case '<<': +case '>>': +_a = rev( ops[1], e, s, g, o, _f ); +_b = rev( ops[2], e, s, g, o, _f ); +_c = should_pass_type_info && (wh.hn( _a ) === 'h' || wh.hn( _b ) === 'h'); +switch( rop ) +{ +case '+': +_d = wh.rv( _a ) + wh.rv( _b ); +break; +case '*': +_d = wh.rv( _a ) * wh.rv( _b ); +break; +case '/': +_d = wh.rv( _a ) / wh.rv( _b ); +break; +case '%': +_d = wh.rv( _a ) % wh.rv( _b ); +break; +case '|': +_d = wh.rv( _a ) | wh.rv( _b ); +break; +case '^': +_d = wh.rv( _a ) ^ wh.rv( _b ); +break; +case '&': +_d = wh.rv( _a ) & wh.rv( _b ); +break; +case '===': +_d = wh.rv( _a ) === wh.rv( _b ); +break; +case '==': +_d = wh.rv( _a ) == wh.rv( _b ); +break; +case '!=': +_d = wh.rv( _a ) != wh.rv( _b ); +break; +case '!==': +_d = wh.rv( _a ) !== wh.rv( _b ); +break; +case '>=': +_d = wh.rv( _a ) >= wh.rv( _b ); +break; +case '<=': +_d = wh.rv( _a ) <= wh.rv( _b ); +break; +case '>': +_d = wh.rv( _a ) > wh.rv( _b ); +break; +case '<': +_d = wh.rv( _a ) < wh.rv( _b ); +break; +case '<<': +_d = wh.rv( _a ) << wh.rv( _b ); +break; +case '>>': +_d = wh.rv( _a ) >> wh.rv( _b ); +break; +default: +break; +} +return _c ? wh.nh( _d, "c" ) : _d; +break; +case '-': +_a = ops.length === 3 ? rev( ops[1], e, s, g, o, _f ) : 0; +_b = ops.length === 3 ? rev( ops[2], e, s, g, o, _f ) : rev( ops[1], e, s, g, o, _f ); +_c = should_pass_type_info && (wh.hn( _a ) === 'h' || wh.hn( _b ) === 'h'); +_d = _c ? wh.rv( _a ) - wh.rv( _b ) : _a - _b; +return _c ? wh.nh( _d, "c" ) : _d; +break; +case '!': +_a = rev( ops[1], e, s, g, o, _f ); +_c = should_pass_type_info && (wh.hn( _a ) == 'h'); +_d = !wh.rv(_a); +return _c ? wh.nh( _d, "c" ) : _d; +case '~': +_a = rev( ops[1], e, s, g, o, _f ); +_c = should_pass_type_info && (wh.hn( _a ) == 'h'); +_d = ~wh.rv(_a); +return _c ? wh.nh( _d, "c" ) : _d; +default: +$gwn('unrecognized op' + rop ); +} +} +function rev( ops, e, s, g, o, newap ) +{ +var op = ops[0]; +var _f = false; +if ( typeof newap !== "undefined" ) o.ap = newap; +if( typeof(op)==='object' ) +{ +var vop=op[0]; +var _a, _aa, _b, _bb, _c, _d, _s, _e, _ta, _tb, _td; +switch(vop) +{ +case 2: +return ArithmeticEv(ops,e,s,g,o); +break; +case 4: +return rev( ops[1], e, s, g, o, _f ); +break; +case 5: +switch( ops.length ) +{ +case 2: +_a = rev( ops[1],e,s,g,o,_f ); +return should_pass_type_info?[_a]:[wh.rv(_a)]; +return [_a]; +break; +case 1: +return []; +break; +default: +_a = rev( ops[1],e,s,g,o,_f ); +_b = rev( ops[2],e,s,g,o,_f ); +_a.push( +should_pass_type_info ? +_b : +wh.rv( _b ) +); +return _a; +break; +} +break; +case 6: +_a = rev(ops[1],e,s,g,o); +var ap = o.ap; +_ta = wh.hn(_a)==='h'; +_aa = _ta ? wh.rv(_a) : _a; +o.is_affected |= _ta; +if( should_pass_type_info ) +{ +if( _aa===null || typeof(_aa) === 'undefined' ) +{ +return _ta ? wh.nh(undefined, 'e') : undefined; +} +_b = rev(ops[2],e,s,g,o,_f); +_tb = wh.hn(_b) === 'h'; +_bb = _tb ? wh.rv(_b) : _b; +o.ap = ap; +o.is_affected |= _tb; +if( _bb===null || typeof(_bb) === 'undefined' || +_bb === "__proto__" || _bb === "prototype" || _bb === "caller" ) +{ +return (_ta || _tb) ? wh.nh(undefined, 'e') : undefined; +} +_d = _aa[_bb]; +if ( typeof _d === 'function' && !ap ) _d = undefined; +_td = wh.hn(_d)==='h'; +o.is_affected |= _td; +return (_ta || _tb) ? (_td ? _d : wh.nh(_d, 'e')) : _d; +} +else +{ +if( _aa===null || typeof(_aa) === 'undefined' ) +{ +return undefined; +} +_b = rev(ops[2],e,s,g,o,_f); +_tb = wh.hn(_b) === 'h'; +_bb = _tb ? wh.rv(_b) : _b; +o.ap = ap; +o.is_affected |= _tb; +if( _bb===null || typeof(_bb) === 'undefined' || +_bb === "__proto__" || _bb === "prototype" || _bb === "caller" ) +{ +return undefined; +} +_d = _aa[_bb]; +if ( typeof _d === 'function' && !ap ) _d = undefined; +_td = wh.hn(_d)==='h'; +o.is_affected |= _td; +return _td ? wh.rv(_d) : _d; +} +case 7: +switch(ops[1][0]) +{ +case 11: +o.is_affected |= wh.hn(g)==='h'; +return g; +case 3: +_s = wh.rv( s ); +_e = wh.rv( e ); +_b = ops[1][1]; +if (g && g.f && g.f.hasOwnProperty(_b) ) +{ +_a = g.f; +o.ap = true; +} +else +{ +_a = _s && _s.hasOwnProperty(_b) ? +s : (_e && _e.hasOwnProperty(_b) ? e : undefined ); +} +if( should_pass_type_info ) +{ +if( _a ) +{ +_ta = wh.hn(_a) === 'h'; +_aa = _ta ? wh.rv( _a ) : _a; +_d = _aa[_b]; +_td = wh.hn(_d) === 'h'; +o.is_affected |= _ta || _td; +_d = _ta && !_td ? wh.nh(_d,'e') : _d; +return _d; +} +} +else +{ +if( _a ) +{ +_ta = wh.hn(_a) === 'h'; +_aa = _ta ? wh.rv( _a ) : _a; +_d = _aa[_b]; +_td = wh.hn(_d) === 'h'; +o.is_affected |= _ta || _td; +return wh.rv(_d); +} +} +return undefined; +} +break; +case 8: +_a = {}; +_a[ops[1]] = rev(ops[2],e,s,g,o,_f); +return _a; +break; +case 9: +_a = rev(ops[1],e,s,g,o,_f); +_b = rev(ops[2],e,s,g,o,_f); +function merge( _a, _b, _ow ) +{ +var ka, _bbk; +_ta = wh.hn(_a)==='h'; +_tb = wh.hn(_b)==='h'; +_aa = wh.rv(_a); +_bb = wh.rv(_b); +for(var k in _bb) +{ +if ( _ow || !_aa.hasOwnProperty(k) ) +{ +_aa[k] = should_pass_type_info ? (_tb ? wh.nh(_bb[k],'e') : _bb[k]) : wh.rv(_bb[k]); +} +} +return _a; +} +var _c = _a +var _ow = true +if ( typeof(ops[1][0]) === "object" && ops[1][0][0] === 10 ) { +_a = _b +_b = _c +_ow = false +} +if ( typeof(ops[1][0]) === "object" && ops[1][0][0] === 10 ) { +var _r = {} +return merge( merge( _r, _a, _ow ), _b, _ow ); +} +else +return merge( _a, _b, _ow ); +break; +case 10: +_a = rev(ops[1],e,s,g,o,_f); +_a = should_pass_type_info ? _a : wh.rv( _a ); +return _a ; +break; +case 12: +var _r; +_a = rev(ops[1],e,s,g,o); +if ( !o.ap ) +{ +return should_pass_type_info && wh.hn(_a)==='h' ? wh.nh( _r, 'f' ) : _r; +} +var ap = o.ap; +_b = rev(ops[2],e,s,g,o,_f); +o.ap = ap; +_ta = wh.hn(_a)==='h'; +_tb = _ca(_b); +_aa = wh.rv(_a); +_bb = wh.rv(_b); snap_bb=$gdc(_bb,"nv_"); +try{ +_r = typeof _aa === "function" ? $gdc(_aa.apply(null, snap_bb)) : undefined; +} catch (e){ +e.message = e.message.replace(/nv_/g,""); +e.stack = e.stack.substring(0,e.stack.indexOf("\n", e.stack.lastIndexOf("at nv_"))); +e.stack = e.stack.replace(/\snv_/g," "); +e.stack = $gstack(e.stack); +if(g.debugInfo) +{ +e.stack += "\n "+" "+" "+" at "+g.debugInfo[0]+":"+g.debugInfo[1]+":"+g.debugInfo[2]; +console.error(e); +} +_r = undefined; +} +return should_pass_type_info && (_tb || _ta) ? wh.nh( _r, 'f' ) : _r; +} +} +else +{ +if( op === 3 || op === 1) return ops[1]; +else if( op === 11 ) +{ +var _a=''; +for( var i = 1 ; i < ops.length ; i++ ) +{ +var xp = wh.rv(rev(ops[i],e,s,g,o,_f)); +_a += typeof(xp) === 'undefined' ? '' : xp; +} +return _a; +} +} +} +function wrapper( ops, e, s, g, o, newap ) +{ +if( ops[0] == '11182016' ) +{ +g.debugInfo = ops[2]; +return rev( ops[1], e, s, g, o, newap ); +} +else +{ +g.debugInfo = null; +return rev( ops, e, s, g, o, newap ); +} +} +return wrapper; +} +gra=$gwrt(true); +grb=$gwrt(false); +function TestTest( expr, ops, e,s,g, expect_a, expect_b, expect_affected ) +{ +{ +var o = {is_affected:false}; +var a = gra( ops, e,s,g, o ); +if( JSON.stringify(a) != JSON.stringify( expect_a ) +|| o.is_affected != expect_affected ) +{ +console.warn( "A. " + expr + " get result " + JSON.stringify(a) + ", " + o.is_affected + ", but " + JSON.stringify( expect_a ) + ", " + expect_affected + " is expected" ); +} +} +{ +var o = {is_affected:false}; +var a = grb( ops, e,s,g, o ); +if( JSON.stringify(a) != JSON.stringify( expect_b ) +|| o.is_affected != expect_affected ) +{ +console.warn( "B. " + expr + " get result " + JSON.stringify(a) + ", " + o.is_affected + ", but " + JSON.stringify( expect_b ) + ", " + expect_affected + " is expected" ); +} +} +} + +function wfor( to_iter, func, env, _s, global, father, itemname, indexname, keyname ) +{ +var _n = wh.hn( to_iter ) === 'n'; +var scope = wh.rv( _s ); +var has_old_item = scope.hasOwnProperty(itemname); +var has_old_index = scope.hasOwnProperty(indexname); +var old_item = scope[itemname]; +var old_index = scope[indexname]; +var full = Object.prototype.toString.call(wh.rv(to_iter)); +var type = full[8]; +if( type === 'N' && full[10] === 'l' ) type = 'X'; +var _y; +if( _n ) +{ +if( type === 'A' ) +{ +var r_iter_item; +for( var i = 0 ; i < to_iter.length ; i++ ) +{ +scope[itemname] = to_iter[i]; +scope[indexname] = _n ? i : wh.nh(i, 'h'); +r_iter_item = wh.rv(to_iter[i]); +var key = keyname && r_iter_item ? (keyname==="*this" ? r_iter_item : wh.rv(r_iter_item[keyname])) : undefined; +_y = _v(key); +_(father,_y); +func( env, scope, _y, global ); +} +} +else if( type === 'O' ) +{ +var i = 0; +var r_iter_item; +for( var k in to_iter ) +{ +scope[itemname] = to_iter[k]; +scope[indexname] = _n ? k : wh.nh(k, 'h'); +r_iter_item = wh.rv(to_iter[k]); +var key = keyname && r_iter_item ? (keyname==="*this" ? r_iter_item : wh.rv(r_iter_item[keyname])) : undefined; +_y = _v(key); +_(father,_y); +func( env,scope,_y,global ); +i++; +} +} +else if( type === 'S' ) +{ +for( var i = 0 ; i < to_iter.length ; i++ ) +{ +scope[itemname] = to_iter[i]; +scope[indexname] = _n ? i : wh.nh(i, 'h'); +_y = _v( to_iter[i] + i ); +_(father,_y); +func( env,scope,_y,global ); +} +} +else if( type === 'N' ) +{ +for( var i = 0 ; i < to_iter ; i++ ) +{ +scope[itemname] = i; +scope[indexname] = _n ? i : wh.nh(i, 'h'); +_y = _v( i ); +_(father,_y); +func(env,scope,_y,global); +} +} +else +{ +} +} +else +{ +var r_to_iter = wh.rv(to_iter); +var r_iter_item, iter_item; +if( type === 'A' ) +{ +for( var i = 0 ; i < r_to_iter.length ; i++ ) +{ +iter_item = r_to_iter[i]; +iter_item = wh.hn(iter_item)==='n' ? wh.nh(iter_item,'h') : iter_item; +r_iter_item = wh.rv( iter_item ); +scope[itemname] = iter_item +scope[indexname] = _n ? i : wh.nh(i, 'h'); +var key = keyname && r_iter_item ? (keyname==="*this" ? r_iter_item : wh.rv(r_iter_item[keyname])) : undefined; +_y = _v(key); +_(father,_y); +func( env, scope, _y, global ); +} +} +else if( type === 'O' ) +{ +var i=0; +for( var k in r_to_iter ) +{ +iter_item = r_to_iter[k]; +iter_item = wh.hn(iter_item)==='n'? wh.nh(iter_item,'h') : iter_item; +r_iter_item = wh.rv( iter_item ); +scope[itemname] = iter_item; +scope[indexname] = _n ? k : wh.nh(k, 'h'); +var key = keyname && r_iter_item ? (keyname==="*this" ? r_iter_item : wh.rv(r_iter_item[keyname])) : undefined; +_y=_v(key); +_(father,_y); +func( env, scope, _y, global ); +i++ +} +} +else if( type === 'S' ) +{ +for( var i = 0 ; i < r_to_iter.length ; i++ ) +{ +iter_item = wh.nh(r_to_iter[i],'h'); +scope[itemname] = iter_item; +scope[indexname] = _n ? i : wh.nh(i, 'h'); +_y = _v( to_iter[i] + i ); +_(father,_y); +func( env, scope, _y, global ); +} +} +else if( type === 'N' ) +{ +for( var i = 0 ; i < r_to_iter ; i++ ) +{ +iter_item = wh.nh(i,'h'); +scope[itemname] = iter_item; +scope[indexname]= _n ? i : wh.nh(i,'h'); +_y = _v( i ); +_(father,_y); +func(env,scope,_y,global); +} +} +else +{ +} +} +if(has_old_item) +{ +scope[itemname]=old_item; +} +else +{ +delete scope[itemname]; +} +if(has_old_index) +{ +scope[indexname]=old_index; +} +else +{ +delete scope[indexname]; +} +} + +function _ca(o) +{ +if ( wh.hn(o) == 'h' ) return true; +if ( typeof o !== "object" ) return false; +for(var i in o){ +if ( o.hasOwnProperty(i) ){ +if (_ca(o[i])) return true; +} +} +return false; +} +function _da( node, attrname, opindex, raw, o ) +{ +var isaffected = false; +var value = $gdc( raw, "", 2 ); +if ( o.ap && value && value.constructor===Function ) +{ +attrname = "$wxs:" + attrname; +node.attr["$gdc"] = $gdc; +} +if ( o.is_affected || _ca(raw) ) +{ +node.n.push( attrname ); +node.raw[attrname] = raw; +} +node.attr[attrname] = value; +} +function _r( node, attrname, opindex, env, scope, global ) +{ +global.opindex=opindex; +var o = {}, _env; +var a = grb( z[opindex], env, scope, global, o ); +_da( node, attrname, opindex, a, o ); +} +function _rz( z, node, attrname, opindex, env, scope, global ) +{ +global.opindex=opindex; +var o = {}, _env; +var a = grb( z[opindex], env, scope, global, o ); +_da( node, attrname, opindex, a, o ); +} +function _o( opindex, env, scope, global ) +{ +global.opindex=opindex; +var nothing = {}; +var r = grb( z[opindex], env, scope, global, nothing ); +return (r&&r.constructor===Function) ? undefined : r; +} +function _oz( z, opindex, env, scope, global ) +{ +global.opindex=opindex; +var nothing = {}; +var r = grb( z[opindex], env, scope, global, nothing ); +return (r&&r.constructor===Function) ? undefined : r; +} +function _1( opindex, env, scope, global, o ) +{ +var o = o || {}; +global.opindex=opindex; +return gra( z[opindex], env, scope, global, o ); +} +function _1z( z, opindex, env, scope, global, o ) +{ +var o = o || {}; +global.opindex=opindex; +return gra( z[opindex], env, scope, global, o ); +} +function _2( opindex, func, env, scope, global, father, itemname, indexname, keyname ) +{ +var o = {}; +var to_iter = _1( opindex, env, scope, global ); +wfor( to_iter, func, env, scope, global, father, itemname, indexname, keyname ); +} +function _2z( z, opindex, func, env, scope, global, father, itemname, indexname, keyname ) +{ +var o = {}; +var to_iter = _1z( z, opindex, env, scope, global ); +wfor( to_iter, func, env, scope, global, father, itemname, indexname, keyname ); +} + + +function _m(tag,attrs,generics,env,scope,global) +{ +var tmp=_n(tag); +var base=0; +for(var i = 0 ; i < attrs.length ; i+=2 ) +{ +if(base+attrs[i+1]<0) +{ +tmp.attr[attrs[i]]=true; +} +else +{ +_r(tmp,attrs[i],base+attrs[i+1],env,scope,global); +if(base===0)base=attrs[i+1]; +} +} +for(var i=0;i=0;x--){if(e[p].i[x]&&d[e[p].i[x]][c])return d[e[p].i[x]][c]};for(var x=e[p].ti.length-1;x>=0;x--){var q=_grp(e[p].ti[x],e,p);if(q&&d[q][c])return d[q][c]}var ii=_gapi(e,p);for(var x=0;x=0;k--)if(e[p].j[k]){for(var q=e[e[p].j[k]].ti.length-1;q>=0;q--){var pp=_grp(e[e[p].j[k]].ti[q],e,p);if(pp&&d[pp][c]){return d[pp][c]}}}} +function _gapi(e,p){if(!p)return [];if($gaic[p]){return $gaic[p]};var ret=[],q=[],h=0,t=0,put={},visited={};q.push(p);visited[p]=true;t++;while(h=0.02+1e-6&&window.__mergeData__) +{ +env=window.__mergeData__(env,dd); +} +try{ +main(env,{},root,global); +_tsd(root) +if(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);} +}catch(err){ +console.log(cs, env); +console.log(err) +throw err +} +return root; +} +} +} + diff --git a/test/wcc/viewedit/1/node.json b/test/wcc/viewedit/1/node.json new file mode 100644 index 0000000..17f1362 --- /dev/null +++ b/test/wcc/viewedit/1/node.json @@ -0,0 +1,12 @@ +{ + "generateFunctionName": { + "__COMMON__": "$gwx", + "pages/index/index": "$gwx_XC_0", + "pages/logs/logs": "$gwx_XC_1" + }, + "generateFunctionContent": { + "__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__||{};if(this&&this.__g===undefined)Object.defineProperty(this,\"__g\",{configurable:false,enumerable:false,writable:false,value:function(){function D(e,t){if(typeof t!=\"undefined\")e.children.push(t)}function S(e){if(typeof e!=\"undefined\")return{tag:\"virtual\",wxKey:e,children:[]};return{tag:\"virtual\",children:[]}}function v(e){$gwxc++;if($gwxc>=16e3){throw\"Dom limit exceeded, please check if there's any mistake you've made.\"}return{tag:\"wx-\"+e,attr:{},children:[],n:[],raw:{},generics:{}}}function e(e,t){t&&e.properities.push(t)}function t(e,t,r){return typeof e[r]!=\"undefined\"?e[r]:t[r]}function u(e){console.warn(\"WXMLRT_\"+g+\":\"+e)}function r(e,t){u(t+\":-1:-1:-1: Template `\"+e+\"` is being called recursively, will be stop.\")}var s=console.warn;var n=console.log;function o(){function e(){}e.prototype={hn:function(e,t){if(typeof e==\"object\"){var r=0;var n=false,o=false;for(var a in e){n=n|a===\"__value__\";o=o|a===\"__wxspec__\";r++;if(r>2)break}return r==2&&n&&o&&(t||e.__wxspec__!==\"m\"||this.hn(e.__value__)===\"h\")?\"h\":\"n\"}return\"n\"},nh:function(e,t){return{__value__:e,__wxspec__:t?t:true}},rv:function(e){return this.hn(e,true)===\"n\"?e:this.rv(e.__value__)},hm:function(e){if(typeof e==\"object\"){var t=0;var r=false,n=false;for(var o in e){r=r|o===\"__value__\";n=n|o===\"__wxspec__\";t++;if(t>2)break}return t==2&&r&&n&&(e.__wxspec__===\"m\"||this.hm(e.__value__))}return false}};return new e}var A=o();function T(e){var t=e.split(\"\\n \"+\" \"+\" \"+\" \");for(var r=0;r=\":case\"<=\":case\">\":case\"<\":case\"<<\":case\">>\":p=x(e[1],t,r,n,o,a);u=x(e[2],t,r,n,o,a);l=M&&(A.hn(p)===\"h\"||A.hn(u)===\"h\");switch(i){case\"+\":f=A.rv(p)+A.rv(u);break;case\"*\":f=A.rv(p)*A.rv(u);break;case\"/\":f=A.rv(p)/A.rv(u);break;case\"%\":f=A.rv(p)%A.rv(u);break;case\"|\":f=A.rv(p)|A.rv(u);break;case\"^\":f=A.rv(p)^A.rv(u);break;case\"&\":f=A.rv(p)&A.rv(u);break;case\"===\":f=A.rv(p)===A.rv(u);break;case\"==\":f=A.rv(p)==A.rv(u);break;case\"!=\":f=A.rv(p)!=A.rv(u);break;case\"!==\":f=A.rv(p)!==A.rv(u);break;case\">=\":f=A.rv(p)>=A.rv(u);break;case\"<=\":f=A.rv(p)<=A.rv(u);break;case\">\":f=A.rv(p)>A.rv(u);break;case\"<\":f=A.rv(p)>\":f=A.rv(p)>>A.rv(u);break;default:break}return l?A.nh(f,\"c\"):f;break;case\"-\":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)===\"h\"||A.hn(u)===\"h\");f=l?A.rv(p)-A.rv(u):p-u;return l?A.nh(f,\"c\"):f;break;case\"!\":p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\"h\";f=!A.rv(p);return l?A.nh(f,\"c\"):f;case\"~\":p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\"h\";f=~A.rv(p);return l?A.nh(f,\"c\"):f;default:s(\"unrecognized op\"+i)}}function x(e,t,r,n,o,a){var i=e[0];var p=false;if(typeof a!==\"undefined\")o.ap=a;if(typeof i===\"object\"){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)===\"h\";f=h?A.rv(l):l;o.is_affected|=h;if(M){if(f===null||typeof f===\"undefined\"){return h?A.nh(undefined,\"e\"):undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\"h\";c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\"undefined\"||c===\"__proto__\"||c===\"prototype\"||c===\"caller\"){return h||_?A.nh(undefined,\"e\"):undefined}y=f[c];if(typeof y===\"function\"&&!w)y=undefined;g=A.hn(y)===\"h\";o.is_affected|=g;return h||_?g?y:A.nh(y,\"e\"):y}else{if(f===null||typeof f===\"undefined\"){return undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\"h\";c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\"undefined\"||c===\"__proto__\"||c===\"prototype\"||c===\"caller\"){return undefined}y=f[c];if(typeof y===\"function\"&&!w)y=undefined;g=A.hn(y)===\"h\";o.is_affected|=g;return g?A.rv(y):y}case 7:switch(e[1][0]){case 11:o.is_affected|=A.hn(n)===\"h\";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)===\"h\";f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\"h\";o.is_affected|=h||g;y=h&&!g?A.nh(y,\"e\"):y;return y}}else{if(l){h=A.hn(l)===\"h\";f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\"h\";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)===\"h\";_=A.hn(t)===\"h\";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],\"e\"):c[a]:A.rv(c[a])}}return e}var s=l;var j=true;if(typeof e[1][0]===\"object\"&&e[1][0][0]===10){l=v;v=s;j=false}if(typeof e[1][0]===\"object\"&&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)===\"h\"?A.nh(P,\"f\"):P}var w=o.ap;v=x(e[2],t,r,n,o,p);o.ap=w;h=A.hn(l)===\"h\";_=N(v);f=A.rv(l);c=A.rv(v);snap_bb=K(c,\"nv_\");try{P=typeof f===\"function\"?K(f.apply(null,snap_bb)):undefined}catch(t){t.message=t.message.replace(/nv_/g,\"\");t.stack=t.stack.substring(0,t.stack.indexOf(\"\\n\",t.stack.lastIndexOf(\"at nv_\")));t.stack=t.stack.replace(/\\snv_/g,\" \");t.stack=T(t.stack);if(n.debugInfo){t.stack+=\"\\n \"+\" \"+\" \"+\" at \"+n.debugInfo[0]+\":\"+n.debugInfo[1]+\":\"+n.debugInfo[2];console.error(t)}P=undefined}return M&&(_||h)?A.nh(P,\"f\"):P}}else{if(i===3||i===1)return e[1];else if(i===11){var l=\"\";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&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx();;var __WXML_DEP__=__WXML_DEP__||{};", + "pages/index/index": "$gwx_XC_0=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){\nif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\n}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\nvar e_={}\nif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\nvar d_={}\nif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\nvar f_={}\nif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\nvar p_={}\nvar cs\n__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}\n__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};\n__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};\nvar z=__WXML_GLOBAL__.ops_set.$gwx_XC_0 || [];\nfunction gz$gwx_XC_0_1(){\nif( __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\n__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1=[];\n(function(z){var a=11;function Z(ops){z.push(ops)}\nZ([3,'container'])\nZ([3,'0'])\nZ([3,'userinfo'])\nZ([3,'1'])\nZ([3,'2'])\nZ([[7],[3,'canIUseOpenData']])\nZ([3,'bindViewTap'])\nZ([3,'userinfo-avatar'])\nZ([3,'3'])\nZ([3,'width: 183rpx; height: 148rpx; display: block; box-sizing: border-box'])\nZ([3,'4'])\nZ([3,'userAvatarUrl'])\nZ([3,'5'])\nZ([3,'userNickName'])\nZ([3,'6'])\nZ([[2,'!'],[[7],[3,'hasUserInfo']]])\nZ([[7],[3,'canIUseGetUserProfile']])\nZ([3,'getUserProfile'])\nZ([3,'7'])\nZ([3,' 获取头像昵称 '])\nZ([[7],[3,'canIUse']])\nZ([3,'getUserInfo'])\nZ([3,'8'])\nZ(z[21])\nZ(z[19])\nZ([3,'9'])\nZ([3,' 请使用1.4.4及以上版本基础库 '])\nZ([3,'10'])\nZ(z[6])\nZ(z[7])\nZ([3,'11'])\nZ([3,'cover'])\nZ([[6],[[7],[3,'userInfo']],[3,'avatarUrl']])\nZ([3,'userinfo-nickname'])\nZ([3,'12'])\nZ([a,[[6],[[7],[3,'userInfo']],[3,'nickName']]])\nZ([3,'usermotto'])\nZ([3,'13'])\nZ([3,'user-motto'])\nZ([3,'14'])\nZ([a,[[7],[3,'motto']]])\n})(__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\n}\n__WXML_GLOBAL__.ops_set.$gwx_XC_0=z;\n__WXML_GLOBAL__.ops_init.$gwx_XC_0=true;\nvar x=['./pages/index/index.wxml'];d_[x[0]]={}\nvar m0=function(e,s,r,gg){\nvar z=gz$gwx_XC_0_1()\ncs.push(\"./pages/index/index.wxml:view:2:2\")\nvar oB=_mz(z,'view',['class',0,'data-ib-structured-id',1],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:view:3:4\")\nvar xC=_mz(z,'view',['class',2,'data-ib-structured-id',1],[],e,s,gg)\nvar oD=_v()\n_(xC,oD)\nif(_oz(z,5,e,s,gg)){oD.wxVkey=1\ncs.push(\"./pages/index/index.wxml:block:4:6\")\ncs.push(\"./pages/index/index.wxml:view:5:8\")\nvar fE=_mz(z,'view',['bindtap',6,'class',1,'data-ib-structured-id',2,'style',3],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:open-data:6:10\")\nvar cF=_mz(z,'open-data',['data-ib-structured-id',10,'type',1],[],e,s,gg)\ncs.pop()\n_(fE,cF)\ncs.pop()\n_(oD,fE)\ncs.push(\"./pages/index/index.wxml:open-data:8:8\")\nvar hG=_mz(z,'open-data',['data-ib-structured-id',12,'type',1],[],e,s,gg)\ncs.pop()\n_(oD,hG)\ncs.pop()\n}\nelse if(_oz(z,15,e,s,gg)){oD.wxVkey=2\ncs.push(\"./pages/index/index.wxml:block:10:6\")\nvar oH=_v()\n_(oD,oH)\nif(_oz(z,16,e,s,gg)){oH.wxVkey=1\ncs.push(\"./pages/index/index.wxml:button:11:8\")\ncs.push(\"./pages/index/index.wxml:button:11:8\")\nvar cI=_mz(z,'button',['bindtap',17,'data-ib-structured-id',1],[],e,s,gg)\nvar oJ=_oz(z,19,e,s,gg)\n_(cI,oJ)\ncs.pop()\n_(oH,cI)\ncs.pop()\n}\nelse if(_oz(z,20,e,s,gg)){oH.wxVkey=2\ncs.push(\"./pages/index/index.wxml:button:12:8\")\ncs.push(\"./pages/index/index.wxml:button:12:8\")\nvar lK=_mz(z,'button',['bindgetuserinfo',21,'data-ib-structured-id',1,'openType',2],[],e,s,gg)\nvar aL=_oz(z,24,e,s,gg)\n_(lK,aL)\ncs.pop()\n_(oH,lK)\ncs.pop()\n}\nelse{oH.wxVkey=3\ncs.push(\"./pages/index/index.wxml:view:13:8\")\ncs.push(\"./pages/index/index.wxml:view:13:8\")\nvar tM=_n('view')\n_rz(z,tM,'data-ib-structured-id',25,e,s,gg)\nvar eN=_oz(z,26,e,s,gg)\n_(tM,eN)\ncs.pop()\n_(oH,tM)\ncs.pop()\n}\noH.wxXCkey=1\ncs.pop()\n}\nelse{oD.wxVkey=3\ncs.push(\"./pages/index/index.wxml:block:15:6\")\ncs.push(\"./pages/index/index.wxml:image:16:8\")\nvar bO=_mz(z,'image',['bindtap',28,'class',1,'data-ib-structured-id',2,'mode',3,'src',4],[],e,s,gg)\ncs.pop()\n_(oD,bO)\ncs.push(\"./pages/index/index.wxml:text:17:8\")\nvar oP=_mz(z,'text',['class',33,'data-ib-structured-id',1],[],e,s,gg)\nvar xQ=_oz(z,35,e,s,gg)\n_(oP,xQ)\ncs.pop()\n_(oD,oP)\ncs.pop()\n}\noD.wxXCkey=1\ncs.pop()\n_(oB,xC)\ncs.push(\"./pages/index/index.wxml:view:20:4\")\nvar oR=_mz(z,'view',['class',36,'data-ib-structured-id',1],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:text:21:6\")\nvar fS=_mz(z,'text',['class',38,'data-ib-structured-id',1],[],e,s,gg)\nvar cT=_oz(z,40,e,s,gg)\n_(fS,cT)\ncs.pop()\n_(oR,fS)\ncs.pop()\n_(oB,oR)\ncs.pop()\n_(r,oB)\nreturn r\n}\ne_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}\nif(path&&e_[path]){\nwindow.__wxml_comp_version__=0.02\nreturn function(env,dd,global){$gwxc=0;var root={\"tag\":\"wx-page\"};root.children=[]\n;g=\"$gwx_XC_0\";var main=e_[path].f\ncs=[]\nif (typeof global===\"undefined\")global={};global.f=$gdc(f_[path],\"\",1);\nif(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx_XC_0();", + "pages/logs/logs": "$gwx_XC_1=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){\nif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\n}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\nvar e_={}\nif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\nvar d_={}\nif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\nvar f_={}\nif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\nvar p_={}\nvar cs\n__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}\n__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};\n__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};\nvar z=__WXML_GLOBAL__.ops_set.$gwx_XC_1 || [];\nfunction gz$gwx_XC_1_1(){\nif( __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1\n__WXML_GLOBAL__.ops_cached.$gwx_XC_1_1=[];\n(function(z){var a=11;function Z(ops){z.push(ops)}\nZ([3,'container log-list'])\nZ([3,'log'])\nZ([[7],[3,'logs']])\nZ([3,'timeStamp'])\nZ([3,'log-item'])\nZ([a,[[2,'+'],[[7],[3,'index']],[1,1]],[3,'. '],[[6],[[7],[3,'log']],[3,'date']]])\n})(__WXML_GLOBAL__.ops_cached.$gwx_XC_1_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1\n}\n__WXML_GLOBAL__.ops_set.$gwx_XC_1=z;\n__WXML_GLOBAL__.ops_init.$gwx_XC_1=true;\nvar x=['./pages/logs/logs.wxml'];d_[x[0]]={}\nvar m0=function(e,s,r,gg){\nvar z=gz$gwx_XC_1_1()\ncs.push(\"./pages/logs/logs.wxml:view:2:2\")\nvar oV=_n('view')\n_rz(z,oV,'class',0,e,s,gg)\nvar cW=_v()\n_(oV,cW)\ncs.push(\"./pages/logs/logs.wxml:block:3:4\")\nvar oX=function(aZ,lY,t1,gg){\ncs.push(\"./pages/logs/logs.wxml:block:3:4\")\ncs.push(\"./pages/logs/logs.wxml:text:4:6\")\nvar b3=_n('text')\n_rz(z,b3,'class',4,aZ,lY,gg)\nvar o4=_oz(z,5,aZ,lY,gg)\n_(b3,o4)\ncs.pop()\n_(t1,b3)\ncs.pop()\nreturn t1\n}\ncW.wxXCkey=2\n_2z(z,2,oX,e,s,gg,cW,'log','index','timeStamp')\ncs.pop()\ncs.pop()\n_(r,oV)\nreturn r\n}\ne_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}\nif(path&&e_[path]){\nwindow.__wxml_comp_version__=0.02\nreturn function(env,dd,global){$gwxc=0;var root={\"tag\":\"wx-page\"};root.children=[]\n;g=\"$gwx_XC_1\";var main=e_[path].f\ncs=[]\nif (typeof global===\"undefined\")global={};global.f=$gdc(f_[path],\"\",1);\nif(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx_XC_1();" + } +} \ No newline at end of file diff --git a/test/wcc/viewedit/1/nodejs.json b/test/wcc/viewedit/1/nodejs.json new file mode 100644 index 0000000..03a9aa7 --- /dev/null +++ b/test/wcc/viewedit/1/nodejs.json @@ -0,0 +1,12 @@ +{ + "generateFunctionName": { + "__COMMON__": "$gwx", + "pages/index/index": "$gwx_XC_0", + "pages/logs/logs": "$gwx_XC_1" + }, + "generateFunctionContent": { + "__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__||{};if(this&&this.__g===undefined)Object.defineProperty(this,\"__g\",{configurable:false,enumerable:false,writable:false,value:function(){function D(e,t){if(typeof t!=\"undefined\")e.children.push(t)}function S(e){if(typeof e!=\"undefined\")return{tag:\"virtual\",wxKey:e,children:[]};return{tag:\"virtual\",children:[]}}function v(e){$gwxc++;if($gwxc>=16e3){throw\"Dom limit exceeded, please check if there's any mistake you've made.\"}return{tag:\"wx-\"+e,attr:{},children:[],n:[],raw:{},generics:{}}}function e(e,t){t&&e.properities.push(t)}function t(e,t,r){return typeof e[r]!=\"undefined\"?e[r]:t[r]}function u(e){console.warn(\"WXMLRT_\"+g+\":\"+e)}function r(e,t){u(t+\":-1:-1:-1: Template `\"+e+\"` is being called recursively, will be stop.\")}var s=console.warn;var n=console.log;function o(){function e(){}e.prototype={hn:function(e,t){if(typeof e==\"object\"){var r=0;var n=false,o=false;for(var a in e){n=n|a===\"__value__\";o=o|a===\"__wxspec__\";r++;if(r>2)break}return r==2&&n&&o&&(t||e.__wxspec__!==\"m\"||this.hn(e.__value__)===\"h\")?\"h\":\"n\"}return\"n\"},nh:function(e,t){return{__value__:e,__wxspec__:t?t:true}},rv:function(e){return this.hn(e,true)===\"n\"?e:this.rv(e.__value__)},hm:function(e){if(typeof e==\"object\"){var t=0;var r=false,n=false;for(var o in e){r=r|o===\"__value__\";n=n|o===\"__wxspec__\";t++;if(t>2)break}return t==2&&r&&n&&(e.__wxspec__===\"m\"||this.hm(e.__value__))}return false}};return new e}var A=o();function T(e){var t=e.split(\"\\n \"+\" \"+\" \"+\" \");for(var r=0;r=\":case\"<=\":case\">\":case\"<\":case\"<<\":case\">>\":p=x(e[1],t,r,n,o,a);u=x(e[2],t,r,n,o,a);l=M&&(A.hn(p)===\"h\"||A.hn(u)===\"h\");switch(i){case\"+\":f=A.rv(p)+A.rv(u);break;case\"*\":f=A.rv(p)*A.rv(u);break;case\"/\":f=A.rv(p)/A.rv(u);break;case\"%\":f=A.rv(p)%A.rv(u);break;case\"|\":f=A.rv(p)|A.rv(u);break;case\"^\":f=A.rv(p)^A.rv(u);break;case\"&\":f=A.rv(p)&A.rv(u);break;case\"===\":f=A.rv(p)===A.rv(u);break;case\"==\":f=A.rv(p)==A.rv(u);break;case\"!=\":f=A.rv(p)!=A.rv(u);break;case\"!==\":f=A.rv(p)!==A.rv(u);break;case\">=\":f=A.rv(p)>=A.rv(u);break;case\"<=\":f=A.rv(p)<=A.rv(u);break;case\">\":f=A.rv(p)>A.rv(u);break;case\"<\":f=A.rv(p)>\":f=A.rv(p)>>A.rv(u);break;default:break}return l?A.nh(f,\"c\"):f;break;case\"-\":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)===\"h\"||A.hn(u)===\"h\");f=l?A.rv(p)-A.rv(u):p-u;return l?A.nh(f,\"c\"):f;break;case\"!\":p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\"h\";f=!A.rv(p);return l?A.nh(f,\"c\"):f;case\"~\":p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\"h\";f=~A.rv(p);return l?A.nh(f,\"c\"):f;default:s(\"unrecognized op\"+i)}}function x(e,t,r,n,o,a){var i=e[0];var p=false;if(typeof a!==\"undefined\")o.ap=a;if(typeof i===\"object\"){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)===\"h\";f=h?A.rv(l):l;o.is_affected|=h;if(M){if(f===null||typeof f===\"undefined\"){return h?A.nh(undefined,\"e\"):undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\"h\";c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\"undefined\"||c===\"__proto__\"||c===\"prototype\"||c===\"caller\"){return h||_?A.nh(undefined,\"e\"):undefined}y=f[c];if(typeof y===\"function\"&&!w)y=undefined;g=A.hn(y)===\"h\";o.is_affected|=g;return h||_?g?y:A.nh(y,\"e\"):y}else{if(f===null||typeof f===\"undefined\"){return undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\"h\";c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\"undefined\"||c===\"__proto__\"||c===\"prototype\"||c===\"caller\"){return undefined}y=f[c];if(typeof y===\"function\"&&!w)y=undefined;g=A.hn(y)===\"h\";o.is_affected|=g;return g?A.rv(y):y}case 7:switch(e[1][0]){case 11:o.is_affected|=A.hn(n)===\"h\";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)===\"h\";f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\"h\";o.is_affected|=h||g;y=h&&!g?A.nh(y,\"e\"):y;return y}}else{if(l){h=A.hn(l)===\"h\";f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\"h\";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)===\"h\";_=A.hn(t)===\"h\";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],\"e\"):c[a]:A.rv(c[a])}}return e}var s=l;var j=true;if(typeof e[1][0]===\"object\"&&e[1][0][0]===10){l=v;v=s;j=false}if(typeof e[1][0]===\"object\"&&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)===\"h\"?A.nh(P,\"f\"):P}var w=o.ap;v=x(e[2],t,r,n,o,p);o.ap=w;h=A.hn(l)===\"h\";_=N(v);f=A.rv(l);c=A.rv(v);snap_bb=K(c,\"nv_\");try{P=typeof f===\"function\"?K(f.apply(null,snap_bb)):undefined}catch(t){t.message=t.message.replace(/nv_/g,\"\");t.stack=t.stack.substring(0,t.stack.indexOf(\"\\n\",t.stack.lastIndexOf(\"at nv_\")));t.stack=t.stack.replace(/\\snv_/g,\" \");t.stack=T(t.stack);if(n.debugInfo){t.stack+=\"\\n \"+\" \"+\" \"+\" at \"+n.debugInfo[0]+\":\"+n.debugInfo[1]+\":\"+n.debugInfo[2];console.error(t)}P=undefined}return M&&(_||h)?A.nh(P,\"f\"):P}}else{if(i===3||i===1)return e[1];else if(i===11){var l=\"\";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&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx();;var __WXML_DEP__=__WXML_DEP__||{};", + "pages/index/index": "$gwx_XC_0=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){\nif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\n}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\nvar e_={}\nif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\nvar d_={}\nif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\nvar f_={}\nif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\nvar p_={}\nvar cs\n__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}\n__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};\n__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};\nvar z=__WXML_GLOBAL__.ops_set.$gwx_XC_0 || [];\nfunction gz$gwx_XC_0_1(){\nif( __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\n__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1=[];\n(function(z){var a=11;function Z(ops){z.push(ops)}\nZ([3,'container'])\nZ([3,'userinfo'])\nZ([[7],[3,'canIUseOpenData']])\nZ([3,'bindViewTap'])\nZ([3,'userinfo-avatar'])\nZ([3,'width: 183rpx; height: 148rpx; display: block; box-sizing: border-box'])\nZ([3,'userAvatarUrl'])\nZ([3,'userNickName'])\nZ([[2,'!'],[[7],[3,'hasUserInfo']]])\nZ([[7],[3,'canIUseGetUserProfile']])\nZ([3,'getUserProfile'])\nZ([3,' 获取头像昵称 '])\nZ([[7],[3,'canIUse']])\nZ([3,'getUserInfo'])\nZ(z[13])\nZ(z[11])\nZ([3,' 请使用1.4.4及以上版本基础库 '])\nZ(z[3])\nZ(z[4])\nZ([3,'cover'])\nZ([[6],[[7],[3,'userInfo']],[3,'avatarUrl']])\nZ([3,'userinfo-nickname'])\nZ([a,[[6],[[7],[3,'userInfo']],[3,'nickName']]])\nZ([3,'usermotto'])\nZ([3,'user-motto'])\nZ([a,[[7],[3,'motto']]])\n})(__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\n}\n__WXML_GLOBAL__.ops_set.$gwx_XC_0=z;\n__WXML_GLOBAL__.ops_init.$gwx_XC_0=true;\nvar x=['./pages/index/index.wxml'];d_[x[0]]={}\nvar m0=function(e,s,r,gg){\nvar z=gz$gwx_XC_0_1()\ncs.push(\"./pages/index/index.wxml:view:2:2\")\nvar oB=_n('view')\n_rz(z,oB,'class',0,e,s,gg)\ncs.push(\"./pages/index/index.wxml:view:3:4\")\nvar xC=_n('view')\n_rz(z,xC,'class',1,e,s,gg)\nvar oD=_v()\n_(xC,oD)\nif(_oz(z,2,e,s,gg)){oD.wxVkey=1\ncs.push(\"./pages/index/index.wxml:block:4:6\")\ncs.push(\"./pages/index/index.wxml:view:5:8\")\nvar fE=_mz(z,'view',['bindtap',3,'class',1,'style',2],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:open-data:6:10\")\nvar cF=_n('open-data')\n_rz(z,cF,'type',6,e,s,gg)\ncs.pop()\n_(fE,cF)\ncs.pop()\n_(oD,fE)\ncs.push(\"./pages/index/index.wxml:open-data:8:8\")\nvar hG=_n('open-data')\n_rz(z,hG,'type',7,e,s,gg)\ncs.pop()\n_(oD,hG)\ncs.pop()\n}\nelse if(_oz(z,8,e,s,gg)){oD.wxVkey=2\ncs.push(\"./pages/index/index.wxml:block:10:6\")\nvar oH=_v()\n_(oD,oH)\nif(_oz(z,9,e,s,gg)){oH.wxVkey=1\ncs.push(\"./pages/index/index.wxml:button:11:8\")\ncs.push(\"./pages/index/index.wxml:button:11:8\")\nvar cI=_n('button')\n_rz(z,cI,'bindtap',10,e,s,gg)\nvar oJ=_oz(z,11,e,s,gg)\n_(cI,oJ)\ncs.pop()\n_(oH,cI)\ncs.pop()\n}\nelse if(_oz(z,12,e,s,gg)){oH.wxVkey=2\ncs.push(\"./pages/index/index.wxml:button:12:8\")\ncs.push(\"./pages/index/index.wxml:button:12:8\")\nvar lK=_mz(z,'button',['bindgetuserinfo',13,'openType',1],[],e,s,gg)\nvar aL=_oz(z,15,e,s,gg)\n_(lK,aL)\ncs.pop()\n_(oH,lK)\ncs.pop()\n}\nelse{oH.wxVkey=3\ncs.push(\"./pages/index/index.wxml:view:13:8\")\ncs.push(\"./pages/index/index.wxml:view:13:8\")\nvar tM=_n('view')\nvar eN=_oz(z,16,e,s,gg)\n_(tM,eN)\ncs.pop()\n_(oH,tM)\ncs.pop()\n}\noH.wxXCkey=1\ncs.pop()\n}\nelse{oD.wxVkey=3\ncs.push(\"./pages/index/index.wxml:block:15:6\")\ncs.push(\"./pages/index/index.wxml:image:16:8\")\nvar bO=_mz(z,'image',['bindtap',17,'class',1,'mode',2,'src',3],[],e,s,gg)\ncs.pop()\n_(oD,bO)\ncs.push(\"./pages/index/index.wxml:text:17:8\")\nvar oP=_n('text')\n_rz(z,oP,'class',21,e,s,gg)\nvar xQ=_oz(z,22,e,s,gg)\n_(oP,xQ)\ncs.pop()\n_(oD,oP)\ncs.pop()\n}\noD.wxXCkey=1\ncs.pop()\n_(oB,xC)\ncs.push(\"./pages/index/index.wxml:view:20:4\")\nvar oR=_n('view')\n_rz(z,oR,'class',23,e,s,gg)\ncs.push(\"./pages/index/index.wxml:text:21:6\")\nvar fS=_n('text')\n_rz(z,fS,'class',24,e,s,gg)\nvar cT=_oz(z,25,e,s,gg)\n_(fS,cT)\ncs.pop()\n_(oR,fS)\ncs.pop()\n_(oB,oR)\ncs.pop()\n_(r,oB)\nreturn r\n}\ne_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}\nif(path&&e_[path]){\nwindow.__wxml_comp_version__=0.02\nreturn function(env,dd,global){$gwxc=0;var root={\"tag\":\"wx-page\"};root.children=[]\n;g=\"$gwx_XC_0\";var main=e_[path].f\ncs=[]\nif (typeof global===\"undefined\")global={};global.f=$gdc(f_[path],\"\",1);\nif(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx_XC_0();", + "pages/logs/logs": "$gwx_XC_1=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){\nif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\n}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\nvar e_={}\nif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\nvar d_={}\nif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\nvar f_={}\nif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\nvar p_={}\nvar cs\n__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}\n__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};\n__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};\nvar z=__WXML_GLOBAL__.ops_set.$gwx_XC_1 || [];\nfunction gz$gwx_XC_1_1(){\nif( __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1\n__WXML_GLOBAL__.ops_cached.$gwx_XC_1_1=[];\n(function(z){var a=11;function Z(ops){z.push(ops)}\nZ([3,'container log-list'])\nZ([3,'log'])\nZ([[7],[3,'logs']])\nZ([3,'timeStamp'])\nZ([3,'log-item'])\nZ([a,[[2,'+'],[[7],[3,'index']],[1,1]],[3,'. '],[[6],[[7],[3,'log']],[3,'date']]])\n})(__WXML_GLOBAL__.ops_cached.$gwx_XC_1_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1\n}\n__WXML_GLOBAL__.ops_set.$gwx_XC_1=z;\n__WXML_GLOBAL__.ops_init.$gwx_XC_1=true;\nvar x=['./pages/logs/logs.wxml'];d_[x[0]]={}\nvar m0=function(e,s,r,gg){\nvar z=gz$gwx_XC_1_1()\ncs.push(\"./pages/logs/logs.wxml:view:2:2\")\nvar oV=_n('view')\n_rz(z,oV,'class',0,e,s,gg)\nvar cW=_v()\n_(oV,cW)\ncs.push(\"./pages/logs/logs.wxml:block:3:4\")\nvar oX=function(aZ,lY,t1,gg){\ncs.push(\"./pages/logs/logs.wxml:block:3:4\")\ncs.push(\"./pages/logs/logs.wxml:text:4:6\")\nvar b3=_n('text')\n_rz(z,b3,'class',4,aZ,lY,gg)\nvar o4=_oz(z,5,aZ,lY,gg)\n_(b3,o4)\ncs.pop()\n_(t1,b3)\ncs.pop()\nreturn t1\n}\ncW.wxXCkey=2\n_2z(z,2,oX,e,s,gg,cW,'log','index','timeStamp')\ncs.pop()\ncs.pop()\n_(r,oV)\nreturn r\n}\ne_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}\nif(path&&e_[path]){\nwindow.__wxml_comp_version__=0.02\nreturn function(env,dd,global){$gwxc=0;var root={\"tag\":\"wx-page\"};root.children=[]\n;g=\"$gwx_XC_1\";var main=e_[path].f\ncs=[]\nif (typeof global===\"undefined\")global={};global.f=$gdc(f_[path],\"\",1);\nif(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx_XC_1();" + } +} \ No newline at end of file diff --git a/test/wcc/viewedit/1/wine.json b/test/wcc/viewedit/1/wine.json new file mode 100644 index 0000000..a02c679 --- /dev/null +++ b/test/wcc/viewedit/1/wine.json @@ -0,0 +1,12 @@ +{ + "generateFunctionName": { + "__COMMON__": "$gwx", + "pages/index/index": "$gwx_XC_0", + "pages/logs/logs": "$gwx_XC_1" + }, + "generateFunctionContent": { + "__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__||{};if(this&&this.__g===undefined)Object.defineProperty(this,\"__g\",{configurable:false,enumerable:false,writable:false,value:function(){function D(e,t){if(typeof t!=\"undefined\")e.children.push(t)}function S(e){if(typeof e!=\"undefined\")return{tag:\"virtual\",wxKey:e,children:[]};return{tag:\"virtual\",children:[]}}function v(e){$gwxc++;if($gwxc>=16e3){throw\"Dom limit exceeded, please check if there's any mistake you've made.\"}return{tag:\"wx-\"+e,attr:{},children:[],n:[],raw:{},generics:{}}}function e(e,t){t&&e.properities.push(t)}function t(e,t,r){return typeof e[r]!=\"undefined\"?e[r]:t[r]}function u(e){console.warn(\"WXMLRT_\"+g+\":\"+e)}function r(e,t){u(t+\":-1:-1:-1: Template `\"+e+\"` is being called recursively, will be stop.\")}var s=console.warn;var n=console.log;function o(){function e(){}e.prototype={hn:function(e,t){if(typeof e==\"object\"){var r=0;var n=false,o=false;for(var a in e){n=n|a===\"__value__\";o=o|a===\"__wxspec__\";r++;if(r>2)break}return r==2&&n&&o&&(t||e.__wxspec__!==\"m\"||this.hn(e.__value__)===\"h\")?\"h\":\"n\"}return\"n\"},nh:function(e,t){return{__value__:e,__wxspec__:t?t:true}},rv:function(e){return this.hn(e,true)===\"n\"?e:this.rv(e.__value__)},hm:function(e){if(typeof e==\"object\"){var t=0;var r=false,n=false;for(var o in e){r=r|o===\"__value__\";n=n|o===\"__wxspec__\";t++;if(t>2)break}return t==2&&r&&n&&(e.__wxspec__===\"m\"||this.hm(e.__value__))}return false}};return new e}var A=o();function T(e){var t=e.split(\"\\n \"+\" \"+\" \"+\" \");for(var r=0;r=\":case\"<=\":case\">\":case\"<\":case\"<<\":case\">>\":p=x(e[1],t,r,n,o,a);u=x(e[2],t,r,n,o,a);l=M&&(A.hn(p)===\"h\"||A.hn(u)===\"h\");switch(i){case\"+\":f=A.rv(p)+A.rv(u);break;case\"*\":f=A.rv(p)*A.rv(u);break;case\"/\":f=A.rv(p)/A.rv(u);break;case\"%\":f=A.rv(p)%A.rv(u);break;case\"|\":f=A.rv(p)|A.rv(u);break;case\"^\":f=A.rv(p)^A.rv(u);break;case\"&\":f=A.rv(p)&A.rv(u);break;case\"===\":f=A.rv(p)===A.rv(u);break;case\"==\":f=A.rv(p)==A.rv(u);break;case\"!=\":f=A.rv(p)!=A.rv(u);break;case\"!==\":f=A.rv(p)!==A.rv(u);break;case\">=\":f=A.rv(p)>=A.rv(u);break;case\"<=\":f=A.rv(p)<=A.rv(u);break;case\">\":f=A.rv(p)>A.rv(u);break;case\"<\":f=A.rv(p)>\":f=A.rv(p)>>A.rv(u);break;default:break}return l?A.nh(f,\"c\"):f;break;case\"-\":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)===\"h\"||A.hn(u)===\"h\");f=l?A.rv(p)-A.rv(u):p-u;return l?A.nh(f,\"c\"):f;break;case\"!\":p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\"h\";f=!A.rv(p);return l?A.nh(f,\"c\"):f;case\"~\":p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\"h\";f=~A.rv(p);return l?A.nh(f,\"c\"):f;default:s(\"unrecognized op\"+i)}}function x(e,t,r,n,o,a){var i=e[0];var p=false;if(typeof a!==\"undefined\")o.ap=a;if(typeof i===\"object\"){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)===\"h\";f=h?A.rv(l):l;o.is_affected|=h;if(M){if(f===null||typeof f===\"undefined\"){return h?A.nh(undefined,\"e\"):undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\"h\";c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\"undefined\"||c===\"__proto__\"||c===\"prototype\"||c===\"caller\"){return h||_?A.nh(undefined,\"e\"):undefined}y=f[c];if(typeof y===\"function\"&&!w)y=undefined;g=A.hn(y)===\"h\";o.is_affected|=g;return h||_?g?y:A.nh(y,\"e\"):y}else{if(f===null||typeof f===\"undefined\"){return undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\"h\";c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\"undefined\"||c===\"__proto__\"||c===\"prototype\"||c===\"caller\"){return undefined}y=f[c];if(typeof y===\"function\"&&!w)y=undefined;g=A.hn(y)===\"h\";o.is_affected|=g;return g?A.rv(y):y}case 7:switch(e[1][0]){case 11:o.is_affected|=A.hn(n)===\"h\";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)===\"h\";f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\"h\";o.is_affected|=h||g;y=h&&!g?A.nh(y,\"e\"):y;return y}}else{if(l){h=A.hn(l)===\"h\";f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\"h\";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)===\"h\";_=A.hn(t)===\"h\";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],\"e\"):c[a]:A.rv(c[a])}}return e}var s=l;var j=true;if(typeof e[1][0]===\"object\"&&e[1][0][0]===10){l=v;v=s;j=false}if(typeof e[1][0]===\"object\"&&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)===\"h\"?A.nh(P,\"f\"):P}var w=o.ap;v=x(e[2],t,r,n,o,p);o.ap=w;h=A.hn(l)===\"h\";_=N(v);f=A.rv(l);c=A.rv(v);snap_bb=K(c,\"nv_\");try{P=typeof f===\"function\"?K(f.apply(null,snap_bb)):undefined}catch(t){t.message=t.message.replace(/nv_/g,\"\");t.stack=t.stack.substring(0,t.stack.indexOf(\"\\n\",t.stack.lastIndexOf(\"at nv_\")));t.stack=t.stack.replace(/\\snv_/g,\" \");t.stack=T(t.stack);if(n.debugInfo){t.stack+=\"\\n \"+\" \"+\" \"+\" at \"+n.debugInfo[0]+\":\"+n.debugInfo[1]+\":\"+n.debugInfo[2];console.error(t)}P=undefined}return M&&(_||h)?A.nh(P,\"f\"):P}}else{if(i===3||i===1)return e[1];else if(i===11){var l=\"\";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&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx();;var __WXML_DEP__=__WXML_DEP__||{};", + "pages/index/index": "$gwx_XC_0=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){\nif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\n}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\nvar e_={}\nif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\nvar d_={}\nif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\nvar f_={}\nif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\nvar p_={}\nvar cs\n__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}\n__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};\n__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};\nvar z=__WXML_GLOBAL__.ops_set.$gwx_XC_0 || [];\nfunction gz$gwx_XC_0_1(){\nif( __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\n__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1=[];\n(function(z){var a=11;function Z(ops){z.push(ops)}\nZ([3,'container'])\nZ([3,'0'])\nZ([3,'userinfo'])\nZ([3,'1'])\nZ([3,'2'])\nZ([[7],[3,'canIUseOpenData']])\nZ([3,'bindViewTap'])\nZ([3,'userinfo-avatar'])\nZ([3,'3'])\nZ([3,'width: 183rpx; height: 148rpx; display: block; box-sizing: border-box'])\nZ([3,'4'])\nZ([3,'userAvatarUrl'])\nZ([3,'5'])\nZ([3,'userNickName'])\nZ([3,'6'])\nZ([[2,'!'],[[7],[3,'hasUserInfo']]])\nZ([[7],[3,'canIUseGetUserProfile']])\nZ([3,'getUserProfile'])\nZ([3,'7'])\nZ([3,' 获取头像昵称 '])\nZ([[7],[3,'canIUse']])\nZ([3,'getUserInfo'])\nZ([3,'8'])\nZ(z[21])\nZ(z[19])\nZ([3,'9'])\nZ([3,' 请使用1.4.4及以上版本基础库 '])\nZ([3,'10'])\nZ(z[6])\nZ(z[7])\nZ([3,'11'])\nZ([3,'cover'])\nZ([[6],[[7],[3,'userInfo']],[3,'avatarUrl']])\nZ([3,'userinfo-nickname'])\nZ([3,'12'])\nZ([a,[[6],[[7],[3,'userInfo']],[3,'nickName']]])\nZ([3,'usermotto'])\nZ([3,'13'])\nZ([3,'user-motto'])\nZ([3,'14'])\nZ([a,[[7],[3,'motto']]])\n})(__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\n}\n__WXML_GLOBAL__.ops_set.$gwx_XC_0=z;\n__WXML_GLOBAL__.ops_init.$gwx_XC_0=true;\nvar x=['./pages/index/index.wxml'];d_[x[0]]={}\nvar m0=function(e,s,r,gg){\nvar z=gz$gwx_XC_0_1()\ncs.push(\"./pages/index/index.wxml:view:2:2\")\nvar oB=_mz(z,'view',['class',0,'data-ib-structured-id',1],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:view:3:4\")\nvar xC=_mz(z,'view',['class',2,'data-ib-structured-id',1],[],e,s,gg)\nvar oD=_v()\n_(xC,oD)\nif(_oz(z,5,e,s,gg)){oD.wxVkey=1\ncs.push(\"./pages/index/index.wxml:block:4:6\")\ncs.push(\"./pages/index/index.wxml:view:5:8\")\nvar fE=_mz(z,'view',['bindtap',6,'class',1,'data-ib-structured-id',2,'style',3],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:open-data:6:10\")\nvar cF=_mz(z,'open-data',['data-ib-structured-id',10,'type',1],[],e,s,gg)\ncs.pop()\n_(fE,cF)\ncs.pop()\n_(oD,fE)\ncs.push(\"./pages/index/index.wxml:open-data:8:8\")\nvar hG=_mz(z,'open-data',['data-ib-structured-id',12,'type',1],[],e,s,gg)\ncs.pop()\n_(oD,hG)\ncs.pop()\n}\nelse if(_oz(z,15,e,s,gg)){oD.wxVkey=2\ncs.push(\"./pages/index/index.wxml:block:10:6\")\nvar oH=_v()\n_(oD,oH)\nif(_oz(z,16,e,s,gg)){oH.wxVkey=1\ncs.push(\"./pages/index/index.wxml:button:11:8\")\ncs.push(\"./pages/index/index.wxml:button:11:8\")\nvar cI=_mz(z,'button',['bindtap',17,'data-ib-structured-id',1],[],e,s,gg)\nvar oJ=_oz(z,19,e,s,gg)\n_(cI,oJ)\ncs.pop()\n_(oH,cI)\ncs.pop()\n}\nelse if(_oz(z,20,e,s,gg)){oH.wxVkey=2\ncs.push(\"./pages/index/index.wxml:button:12:8\")\ncs.push(\"./pages/index/index.wxml:button:12:8\")\nvar lK=_mz(z,'button',['bindgetuserinfo',21,'data-ib-structured-id',1,'openType',2],[],e,s,gg)\nvar aL=_oz(z,24,e,s,gg)\n_(lK,aL)\ncs.pop()\n_(oH,lK)\ncs.pop()\n}\nelse{oH.wxVkey=3\ncs.push(\"./pages/index/index.wxml:view:13:8\")\ncs.push(\"./pages/index/index.wxml:view:13:8\")\nvar tM=_n('view')\n_rz(z,tM,'data-ib-structured-id',25,e,s,gg)\nvar eN=_oz(z,26,e,s,gg)\n_(tM,eN)\ncs.pop()\n_(oH,tM)\ncs.pop()\n}\noH.wxXCkey=1\ncs.pop()\n}\nelse{oD.wxVkey=3\ncs.push(\"./pages/index/index.wxml:block:15:6\")\ncs.push(\"./pages/index/index.wxml:image:16:8\")\nvar bO=_mz(z,'image',['bindtap',28,'class',1,'data-ib-structured-id',2,'mode',3,'src',4],[],e,s,gg)\ncs.pop()\n_(oD,bO)\ncs.push(\"./pages/index/index.wxml:text:17:8\")\nvar oP=_mz(z,'text',['class',33,'data-ib-structured-id',1],[],e,s,gg)\nvar xQ=_oz(z,35,e,s,gg)\n_(oP,xQ)\ncs.pop()\n_(oD,oP)\ncs.pop()\n}\noD.wxXCkey=1\ncs.pop()\n_(oB,xC)\ncs.push(\"./pages/index/index.wxml:view:20:4\")\nvar oR=_mz(z,'view',['class',36,'data-ib-structured-id',1],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:text:21:6\")\nvar fS=_mz(z,'text',['class',38,'data-ib-structured-id',1],[],e,s,gg)\nvar cT=_oz(z,40,e,s,gg)\n_(fS,cT)\ncs.pop()\n_(oR,fS)\ncs.pop()\n_(oB,oR)\ncs.pop()\n_(r,oB)\nreturn r\n}\ne_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}\nif(path&&e_[path]){\nwindow.__wxml_comp_version__=0.02\nreturn function(env,dd,global){$gwxc=0;var root={\"tag\":\"wx-page\"};root.children=[]\n;g=\"$gwx_XC_0\";var main=e_[path].f\ncs=[]\nif (typeof global===\"undefined\")global={};global.f=$gdc(f_[path],\"\",1);\nif(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx_XC_0();", + "pages/logs/logs": "$gwx_XC_1=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){\nif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\n}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\nvar e_={}\nif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\nvar d_={}\nif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\nvar f_={}\nif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\nvar p_={}\nvar cs\n__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}\n__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};\n__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};\nvar z=__WXML_GLOBAL__.ops_set.$gwx_XC_1 || [];\nfunction gz$gwx_XC_1_1(){\nif( __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1\n__WXML_GLOBAL__.ops_cached.$gwx_XC_1_1=[];\n(function(z){var a=11;function Z(ops){z.push(ops)}\nZ([3,'container log-list'])\nZ([3,'log'])\nZ([[7],[3,'logs']])\nZ([3,'timeStamp'])\nZ([3,'log-item'])\nZ([a,[[2,'+'],[[7],[3,'index']],[1,1]],[3,'. '],[[6],[[7],[3,'log']],[3,'date']]])\n})(__WXML_GLOBAL__.ops_cached.$gwx_XC_1_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1\n}\n__WXML_GLOBAL__.ops_set.$gwx_XC_1=z;\n__WXML_GLOBAL__.ops_init.$gwx_XC_1=true;\nvar x=['./pages/logs/logs.wxml'];d_[x[0]]={}\nvar m0=function(e,s,r,gg){\nvar z=gz$gwx_XC_1_1()\ncs.push(\"./pages/logs/logs.wxml:view:2:2\")\nvar oV=_n('view')\n_rz(z,oV,'class',0,e,s,gg)\nvar cW=_v()\n_(oV,cW)\ncs.push(\"./pages/logs/logs.wxml:block:3:4\")\nvar oX=function(aZ,lY,t1,gg){\ncs.push(\"./pages/logs/logs.wxml:block:3:4\")\ncs.push(\"./pages/logs/logs.wxml:text:4:6\")\nvar b3=_n('text')\n_rz(z,b3,'class',4,aZ,lY,gg)\nvar o4=_oz(z,5,aZ,lY,gg)\n_(b3,o4)\ncs.pop()\n_(t1,b3)\ncs.pop()\nreturn t1\n}\ncW.wxXCkey=2\n_2z(z,2,oX,e,s,gg,cW,'log','index','timeStamp')\ncs.pop()\ncs.pop()\n_(r,oV)\nreturn r\n}\ne_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}\nif(path&&e_[path]){\nwindow.__wxml_comp_version__=0.02\nreturn function(env,dd,global){$gwxc=0;var root={\"tag\":\"wx-page\"};root.children=[]\n;g=\"$gwx_XC_1\";var main=e_[path].f\ncs=[]\nif (typeof global===\"undefined\")global={};global.f=$gdc(f_[path],\"\",1);\nif(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx_XC_1();" + } +} \ No newline at end of file diff --git a/test/wcc/viewedit/ll.sh b/test/wcc/viewedit/ll.sh new file mode 100644 index 0000000..1998e4e --- /dev/null +++ b/test/wcc/viewedit/ll.sh @@ -0,0 +1,19 @@ +#!/bin/bash +root_dir=$(cd `dirname $0`/../../.. && pwd -P) +# pkg_dir="/mnt/disk1/Project/WeCuit-Project/WeCuit-Mini-uni-test_uni_vue-cli/dist/build/mp-weixin" +pkg_dir="/home/msojocs/Documents/we1" +store_dir="$root_dir/test/wcc/ll/1" + +# cd "$pkg_dir" && \ +# wine "$root_dir/package.nw/js/vendor/wcc.exe" "-d" \ +# "--split" ">_<6427" \ +# "-xc" "2>_<6427./pages/index/index.wxml>_<64270>_<6427./pages/logs/logs.wxml>_<64270" "./pages/index/index.wxml" "./pages/logs/logs.wxml" \ +# "-gn" "\$gwx" \ +# "-ll" "./pages/index/index>_<6427./pages/logs/logs" + +cd "$pkg_dir" && \ +/mnt/disk1/GitHub/wechat-devtools-linux/compiler/wcc "-d" \ +"--split" ">_<6427" \ +"-xc" "2>_<6427./pages/index/index.wxml>_<64270>_<6427./pages/logs/logs.wxml>_<64270" "./pages/index/index.wxml" "./pages/logs/logs.wxml" \ +"-gn" "\$gwx" \ +"-ll" "./pages/index/index>_<6427./pages/logs/logs" \ No newline at end of file diff --git a/test/wcc/viewedit/ll1.sh b/test/wcc/viewedit/ll1.sh new file mode 100644 index 0000000..53a6544 --- /dev/null +++ b/test/wcc/viewedit/ll1.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# 本脚本用于测试wcc编译器带ll参数时的编译结果 +root_dir=$(cd `dirname $0`/../../.. && pwd -P) +# pkg_dir="/mnt/disk1/Project/WeCuit-Project/WeCuit-Mini-uni-test_uni_vue-cli/dist/build/mp-weixin" +pkg_dir="/home/msojocs/Documents/we1" +store_dir="$root_dir/test/wcc/ll/1" + +cd "$pkg_dir" && \ +"$root_dir/compiler/nodejs/wcc" "-d" "--split" ">_<9657" "-cc" "2>_<9657./pages/index/index.wxml>_<96570>_<9657./pages/logs/logs.wxml>_<96570" "./pages/index/index>_<9657./pages/logs/logs" "./pages/index/index.wxml" "./pages/logs/logs.wxml" "-gn" "\$gwx" \ +"-ll" "./pages/index/index>_<7055./pages/logs/logs" \ + > "$store_dir/nodejs.json" + +diff "$store_dir/wine.json" "$store_dir/nodejs.json" >/dev/null +if [ "$?" == "0" ];then + echo "the file or dir is same!" +else + echo "the file or dir is different!" +fi \ No newline at end of file diff --git a/test/wcc/viewedit/result.json b/test/wcc/viewedit/result.json new file mode 100644 index 0000000..17f1362 --- /dev/null +++ b/test/wcc/viewedit/result.json @@ -0,0 +1,12 @@ +{ + "generateFunctionName": { + "__COMMON__": "$gwx", + "pages/index/index": "$gwx_XC_0", + "pages/logs/logs": "$gwx_XC_1" + }, + "generateFunctionContent": { + "__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__||{};if(this&&this.__g===undefined)Object.defineProperty(this,\"__g\",{configurable:false,enumerable:false,writable:false,value:function(){function D(e,t){if(typeof t!=\"undefined\")e.children.push(t)}function S(e){if(typeof e!=\"undefined\")return{tag:\"virtual\",wxKey:e,children:[]};return{tag:\"virtual\",children:[]}}function v(e){$gwxc++;if($gwxc>=16e3){throw\"Dom limit exceeded, please check if there's any mistake you've made.\"}return{tag:\"wx-\"+e,attr:{},children:[],n:[],raw:{},generics:{}}}function e(e,t){t&&e.properities.push(t)}function t(e,t,r){return typeof e[r]!=\"undefined\"?e[r]:t[r]}function u(e){console.warn(\"WXMLRT_\"+g+\":\"+e)}function r(e,t){u(t+\":-1:-1:-1: Template `\"+e+\"` is being called recursively, will be stop.\")}var s=console.warn;var n=console.log;function o(){function e(){}e.prototype={hn:function(e,t){if(typeof e==\"object\"){var r=0;var n=false,o=false;for(var a in e){n=n|a===\"__value__\";o=o|a===\"__wxspec__\";r++;if(r>2)break}return r==2&&n&&o&&(t||e.__wxspec__!==\"m\"||this.hn(e.__value__)===\"h\")?\"h\":\"n\"}return\"n\"},nh:function(e,t){return{__value__:e,__wxspec__:t?t:true}},rv:function(e){return this.hn(e,true)===\"n\"?e:this.rv(e.__value__)},hm:function(e){if(typeof e==\"object\"){var t=0;var r=false,n=false;for(var o in e){r=r|o===\"__value__\";n=n|o===\"__wxspec__\";t++;if(t>2)break}return t==2&&r&&n&&(e.__wxspec__===\"m\"||this.hm(e.__value__))}return false}};return new e}var A=o();function T(e){var t=e.split(\"\\n \"+\" \"+\" \"+\" \");for(var r=0;r=\":case\"<=\":case\">\":case\"<\":case\"<<\":case\">>\":p=x(e[1],t,r,n,o,a);u=x(e[2],t,r,n,o,a);l=M&&(A.hn(p)===\"h\"||A.hn(u)===\"h\");switch(i){case\"+\":f=A.rv(p)+A.rv(u);break;case\"*\":f=A.rv(p)*A.rv(u);break;case\"/\":f=A.rv(p)/A.rv(u);break;case\"%\":f=A.rv(p)%A.rv(u);break;case\"|\":f=A.rv(p)|A.rv(u);break;case\"^\":f=A.rv(p)^A.rv(u);break;case\"&\":f=A.rv(p)&A.rv(u);break;case\"===\":f=A.rv(p)===A.rv(u);break;case\"==\":f=A.rv(p)==A.rv(u);break;case\"!=\":f=A.rv(p)!=A.rv(u);break;case\"!==\":f=A.rv(p)!==A.rv(u);break;case\">=\":f=A.rv(p)>=A.rv(u);break;case\"<=\":f=A.rv(p)<=A.rv(u);break;case\">\":f=A.rv(p)>A.rv(u);break;case\"<\":f=A.rv(p)>\":f=A.rv(p)>>A.rv(u);break;default:break}return l?A.nh(f,\"c\"):f;break;case\"-\":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)===\"h\"||A.hn(u)===\"h\");f=l?A.rv(p)-A.rv(u):p-u;return l?A.nh(f,\"c\"):f;break;case\"!\":p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\"h\";f=!A.rv(p);return l?A.nh(f,\"c\"):f;case\"~\":p=x(e[1],t,r,n,o,a);l=M&&A.hn(p)==\"h\";f=~A.rv(p);return l?A.nh(f,\"c\"):f;default:s(\"unrecognized op\"+i)}}function x(e,t,r,n,o,a){var i=e[0];var p=false;if(typeof a!==\"undefined\")o.ap=a;if(typeof i===\"object\"){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)===\"h\";f=h?A.rv(l):l;o.is_affected|=h;if(M){if(f===null||typeof f===\"undefined\"){return h?A.nh(undefined,\"e\"):undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\"h\";c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\"undefined\"||c===\"__proto__\"||c===\"prototype\"||c===\"caller\"){return h||_?A.nh(undefined,\"e\"):undefined}y=f[c];if(typeof y===\"function\"&&!w)y=undefined;g=A.hn(y)===\"h\";o.is_affected|=g;return h||_?g?y:A.nh(y,\"e\"):y}else{if(f===null||typeof f===\"undefined\"){return undefined}v=x(e[2],t,r,n,o,p);_=A.hn(v)===\"h\";c=_?A.rv(v):v;o.ap=w;o.is_affected|=_;if(c===null||typeof c===\"undefined\"||c===\"__proto__\"||c===\"prototype\"||c===\"caller\"){return undefined}y=f[c];if(typeof y===\"function\"&&!w)y=undefined;g=A.hn(y)===\"h\";o.is_affected|=g;return g?A.rv(y):y}case 7:switch(e[1][0]){case 11:o.is_affected|=A.hn(n)===\"h\";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)===\"h\";f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\"h\";o.is_affected|=h||g;y=h&&!g?A.nh(y,\"e\"):y;return y}}else{if(l){h=A.hn(l)===\"h\";f=h?A.rv(l):l;y=f[v];g=A.hn(y)===\"h\";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)===\"h\";_=A.hn(t)===\"h\";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],\"e\"):c[a]:A.rv(c[a])}}return e}var s=l;var j=true;if(typeof e[1][0]===\"object\"&&e[1][0][0]===10){l=v;v=s;j=false}if(typeof e[1][0]===\"object\"&&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)===\"h\"?A.nh(P,\"f\"):P}var w=o.ap;v=x(e[2],t,r,n,o,p);o.ap=w;h=A.hn(l)===\"h\";_=N(v);f=A.rv(l);c=A.rv(v);snap_bb=K(c,\"nv_\");try{P=typeof f===\"function\"?K(f.apply(null,snap_bb)):undefined}catch(t){t.message=t.message.replace(/nv_/g,\"\");t.stack=t.stack.substring(0,t.stack.indexOf(\"\\n\",t.stack.lastIndexOf(\"at nv_\")));t.stack=t.stack.replace(/\\snv_/g,\" \");t.stack=T(t.stack);if(n.debugInfo){t.stack+=\"\\n \"+\" \"+\" \"+\" at \"+n.debugInfo[0]+\":\"+n.debugInfo[1]+\":\"+n.debugInfo[2];console.error(t)}P=undefined}return M&&(_||h)?A.nh(P,\"f\"):P}}else{if(i===3||i===1)return e[1];else if(i===11){var l=\"\";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&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx();;var __WXML_DEP__=__WXML_DEP__||{};", + "pages/index/index": "$gwx_XC_0=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){\nif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\n}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\nvar e_={}\nif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\nvar d_={}\nif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\nvar f_={}\nif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\nvar p_={}\nvar cs\n__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}\n__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};\n__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};\nvar z=__WXML_GLOBAL__.ops_set.$gwx_XC_0 || [];\nfunction gz$gwx_XC_0_1(){\nif( __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\n__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1=[];\n(function(z){var a=11;function Z(ops){z.push(ops)}\nZ([3,'container'])\nZ([3,'0'])\nZ([3,'userinfo'])\nZ([3,'1'])\nZ([3,'2'])\nZ([[7],[3,'canIUseOpenData']])\nZ([3,'bindViewTap'])\nZ([3,'userinfo-avatar'])\nZ([3,'3'])\nZ([3,'width: 183rpx; height: 148rpx; display: block; box-sizing: border-box'])\nZ([3,'4'])\nZ([3,'userAvatarUrl'])\nZ([3,'5'])\nZ([3,'userNickName'])\nZ([3,'6'])\nZ([[2,'!'],[[7],[3,'hasUserInfo']]])\nZ([[7],[3,'canIUseGetUserProfile']])\nZ([3,'getUserProfile'])\nZ([3,'7'])\nZ([3,' 获取头像昵称 '])\nZ([[7],[3,'canIUse']])\nZ([3,'getUserInfo'])\nZ([3,'8'])\nZ(z[21])\nZ(z[19])\nZ([3,'9'])\nZ([3,' 请使用1.4.4及以上版本基础库 '])\nZ([3,'10'])\nZ(z[6])\nZ(z[7])\nZ([3,'11'])\nZ([3,'cover'])\nZ([[6],[[7],[3,'userInfo']],[3,'avatarUrl']])\nZ([3,'userinfo-nickname'])\nZ([3,'12'])\nZ([a,[[6],[[7],[3,'userInfo']],[3,'nickName']]])\nZ([3,'usermotto'])\nZ([3,'13'])\nZ([3,'user-motto'])\nZ([3,'14'])\nZ([a,[[7],[3,'motto']]])\n})(__WXML_GLOBAL__.ops_cached.$gwx_XC_0_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_0_1\n}\n__WXML_GLOBAL__.ops_set.$gwx_XC_0=z;\n__WXML_GLOBAL__.ops_init.$gwx_XC_0=true;\nvar x=['./pages/index/index.wxml'];d_[x[0]]={}\nvar m0=function(e,s,r,gg){\nvar z=gz$gwx_XC_0_1()\ncs.push(\"./pages/index/index.wxml:view:2:2\")\nvar oB=_mz(z,'view',['class',0,'data-ib-structured-id',1],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:view:3:4\")\nvar xC=_mz(z,'view',['class',2,'data-ib-structured-id',1],[],e,s,gg)\nvar oD=_v()\n_(xC,oD)\nif(_oz(z,5,e,s,gg)){oD.wxVkey=1\ncs.push(\"./pages/index/index.wxml:block:4:6\")\ncs.push(\"./pages/index/index.wxml:view:5:8\")\nvar fE=_mz(z,'view',['bindtap',6,'class',1,'data-ib-structured-id',2,'style',3],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:open-data:6:10\")\nvar cF=_mz(z,'open-data',['data-ib-structured-id',10,'type',1],[],e,s,gg)\ncs.pop()\n_(fE,cF)\ncs.pop()\n_(oD,fE)\ncs.push(\"./pages/index/index.wxml:open-data:8:8\")\nvar hG=_mz(z,'open-data',['data-ib-structured-id',12,'type',1],[],e,s,gg)\ncs.pop()\n_(oD,hG)\ncs.pop()\n}\nelse if(_oz(z,15,e,s,gg)){oD.wxVkey=2\ncs.push(\"./pages/index/index.wxml:block:10:6\")\nvar oH=_v()\n_(oD,oH)\nif(_oz(z,16,e,s,gg)){oH.wxVkey=1\ncs.push(\"./pages/index/index.wxml:button:11:8\")\ncs.push(\"./pages/index/index.wxml:button:11:8\")\nvar cI=_mz(z,'button',['bindtap',17,'data-ib-structured-id',1],[],e,s,gg)\nvar oJ=_oz(z,19,e,s,gg)\n_(cI,oJ)\ncs.pop()\n_(oH,cI)\ncs.pop()\n}\nelse if(_oz(z,20,e,s,gg)){oH.wxVkey=2\ncs.push(\"./pages/index/index.wxml:button:12:8\")\ncs.push(\"./pages/index/index.wxml:button:12:8\")\nvar lK=_mz(z,'button',['bindgetuserinfo',21,'data-ib-structured-id',1,'openType',2],[],e,s,gg)\nvar aL=_oz(z,24,e,s,gg)\n_(lK,aL)\ncs.pop()\n_(oH,lK)\ncs.pop()\n}\nelse{oH.wxVkey=3\ncs.push(\"./pages/index/index.wxml:view:13:8\")\ncs.push(\"./pages/index/index.wxml:view:13:8\")\nvar tM=_n('view')\n_rz(z,tM,'data-ib-structured-id',25,e,s,gg)\nvar eN=_oz(z,26,e,s,gg)\n_(tM,eN)\ncs.pop()\n_(oH,tM)\ncs.pop()\n}\noH.wxXCkey=1\ncs.pop()\n}\nelse{oD.wxVkey=3\ncs.push(\"./pages/index/index.wxml:block:15:6\")\ncs.push(\"./pages/index/index.wxml:image:16:8\")\nvar bO=_mz(z,'image',['bindtap',28,'class',1,'data-ib-structured-id',2,'mode',3,'src',4],[],e,s,gg)\ncs.pop()\n_(oD,bO)\ncs.push(\"./pages/index/index.wxml:text:17:8\")\nvar oP=_mz(z,'text',['class',33,'data-ib-structured-id',1],[],e,s,gg)\nvar xQ=_oz(z,35,e,s,gg)\n_(oP,xQ)\ncs.pop()\n_(oD,oP)\ncs.pop()\n}\noD.wxXCkey=1\ncs.pop()\n_(oB,xC)\ncs.push(\"./pages/index/index.wxml:view:20:4\")\nvar oR=_mz(z,'view',['class',36,'data-ib-structured-id',1],[],e,s,gg)\ncs.push(\"./pages/index/index.wxml:text:21:6\")\nvar fS=_mz(z,'text',['class',38,'data-ib-structured-id',1],[],e,s,gg)\nvar cT=_oz(z,40,e,s,gg)\n_(fS,cT)\ncs.pop()\n_(oR,fS)\ncs.pop()\n_(oB,oR)\ncs.pop()\n_(r,oB)\nreturn r\n}\ne_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}\nif(path&&e_[path]){\nwindow.__wxml_comp_version__=0.02\nreturn function(env,dd,global){$gwxc=0;var root={\"tag\":\"wx-page\"};root.children=[]\n;g=\"$gwx_XC_0\";var main=e_[path].f\ncs=[]\nif (typeof global===\"undefined\")global={};global.f=$gdc(f_[path],\"\",1);\nif(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx_XC_0();", + "pages/logs/logs": "$gwx_XC_1=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){\nif(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};\n}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};\nvar e_={}\nif(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;\nvar d_={}\nif(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;\nvar f_={}\nif(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};\nvar p_={}\nvar cs\n__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}\n__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};\n__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};\nvar z=__WXML_GLOBAL__.ops_set.$gwx_XC_1 || [];\nfunction gz$gwx_XC_1_1(){\nif( __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1\n__WXML_GLOBAL__.ops_cached.$gwx_XC_1_1=[];\n(function(z){var a=11;function Z(ops){z.push(ops)}\nZ([3,'container log-list'])\nZ([3,'log'])\nZ([[7],[3,'logs']])\nZ([3,'timeStamp'])\nZ([3,'log-item'])\nZ([a,[[2,'+'],[[7],[3,'index']],[1,1]],[3,'. '],[[6],[[7],[3,'log']],[3,'date']]])\n})(__WXML_GLOBAL__.ops_cached.$gwx_XC_1_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_1_1\n}\n__WXML_GLOBAL__.ops_set.$gwx_XC_1=z;\n__WXML_GLOBAL__.ops_init.$gwx_XC_1=true;\nvar x=['./pages/logs/logs.wxml'];d_[x[0]]={}\nvar m0=function(e,s,r,gg){\nvar z=gz$gwx_XC_1_1()\ncs.push(\"./pages/logs/logs.wxml:view:2:2\")\nvar oV=_n('view')\n_rz(z,oV,'class',0,e,s,gg)\nvar cW=_v()\n_(oV,cW)\ncs.push(\"./pages/logs/logs.wxml:block:3:4\")\nvar oX=function(aZ,lY,t1,gg){\ncs.push(\"./pages/logs/logs.wxml:block:3:4\")\ncs.push(\"./pages/logs/logs.wxml:text:4:6\")\nvar b3=_n('text')\n_rz(z,b3,'class',4,aZ,lY,gg)\nvar o4=_oz(z,5,aZ,lY,gg)\n_(b3,o4)\ncs.pop()\n_(t1,b3)\ncs.pop()\nreturn t1\n}\ncW.wxXCkey=2\n_2z(z,2,oX,e,s,gg,cW,'log','index','timeStamp')\ncs.pop()\ncs.pop()\n_(r,oV)\nreturn r\n}\ne_[x[0]]={f:m0,j:[],i:[],ti:[],ic:[]}\nif(path&&e_[path]){\nwindow.__wxml_comp_version__=0.02\nreturn function(env,dd,global){$gwxc=0;var root={\"tag\":\"wx-page\"};root.children=[]\n;g=\"$gwx_XC_1\";var main=e_[path].f\ncs=[]\nif (typeof global===\"undefined\")global={};global.f=$gdc(f_[path],\"\",1);\nif(typeof(window.__webview_engine_version__)!='undefined'&&window.__webview_engine_version__+1e-6>=0.02+1e-6&&window.__mergeData__)\n{\nenv=window.__mergeData__(env,dd);\n}\ntry{\nmain(env,{},root,global);\n_tsd(root)\nif(typeof(window.__webview_engine_version__)=='undefined'|| window.__webview_engine_version__+1e-6<0.01+1e-6){return _ev(root);}\n}catch(err){\nconsole.log(cs, env);\nconsole.log(err)\nthrow err\n}\n;g=\"\";\nreturn root;\n}\n}\n}\n}(__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)$gwx_XC_1();" + } +} \ No newline at end of file diff --git a/test/wcc/viewedit/wcc.js b/test/wcc/viewedit/wcc.js new file mode 100644 index 0000000..8ee5713 --- /dev/null +++ b/test/wcc/viewedit/wcc.js @@ -0,0 +1,21 @@ +const wcc = require('../../../package.nw/node_modules/wcc') +const fs = require('fs') + +const options = { + "files": ["./pages/index/index.wxml", "./pages/logs/logs.wxml"], + "debugWXS": false, + "debug": true, + "genfuncname": "$gwx", + "wxmlCompileConfig": "2>_<7055./pages/index/index.wxml>_<70550>_<7055./pages/logs/logs.wxml>_<70550", + "wxmlCompileConfigSplit": ">_<7055", + "replaceContent": { + "./pages/index/index.wxml": "\n\n \n \n \n \n \n \n \n \n \n \n 请使用1.4.4及以上版本基础库 \n \n \n \n {{userInfo.nickName}}\n \n \n \n {{motto}}\n \n\n" + }, + "cwd": "/home/msojocs/Documents/we1", + "lazyloadConfig": "./pages/index/index>_<7055./pages/logs/logs" +} +wcc(options) +.then(res=>{ + console.log(res) + fs.writeFileSync('test/wcc/viewedit/1/node.json', res) +}) \ No newline at end of file diff --git a/test/wcsc/viewedit/1/node.json b/test/wcsc/viewedit/1/node.json new file mode 100644 index 0000000..31de7a3 --- /dev/null +++ b/test/wcsc/viewedit/1/node.json @@ -0,0 +1,8 @@ +{ + "common": "var BASE_DEVICE_WIDTH = 750;\nvar isIOS=navigator.userAgent.match(\"iPhone\");\nvar deviceWidth = window.screen.width || 375;\nvar deviceDPR = window.devicePixelRatio || 2;\nvar checkDeviceWidth = window.__checkDeviceWidth__ || function() {\nvar newDeviceWidth = window.screen.width || 375\nvar newDeviceDPR = window.devicePixelRatio || 2\nvar newDeviceHeight = window.screen.height || 375\nif (window.screen.orientation && /^landscape/.test(window.screen.orientation.type || '')) newDeviceWidth = newDeviceHeight\nif (newDeviceWidth !== deviceWidth || newDeviceDPR !== deviceDPR) {\ndeviceWidth = newDeviceWidth\ndeviceDPR = newDeviceDPR\n}\n}\ncheckDeviceWidth()\nvar eps = 1e-4;\nvar transformRPX = window.__transformRpx__ || function(number, newDeviceWidth) {\nif ( number === 0 ) return 0;\nnumber = number / BASE_DEVICE_WIDTH * ( newDeviceWidth || deviceWidth );\nnumber = Math.floor(number + eps);\nif (number === 0) {\nif (deviceDPR === 1 || !isIOS) {\nreturn 1;\n} else {\nreturn 0.5;\n}\n}\nreturn number;\n}\nwindow.__rpxRecalculatingFuncs__ = window.__rpxRecalculatingFuncs__ || [];\nvar __COMMON_STYLESHEETS__ = __COMMON_STYLESHEETS__||{}\n\nvar setCssToHead = function(file, _xcInvalid, info) {\nvar Ca = {};\nvar css_id;\nvar info = info || {};\nvar _C = __COMMON_STYLESHEETS__\nfunction makeup(file, opt) {\nvar _n = typeof(file) === \"string\";\nif ( _n && Ca.hasOwnProperty(file)) return \"\";\nif ( _n ) Ca[file] = 1;\nvar ex = _n ? _C[file] : file;\nvar res=\"\";\nfor (var i = ex.length - 1; i >= 0; i--) {\nvar content = ex[i];\nif (typeof(content) === \"object\")\n{\nvar op = content[0];\nif ( op == 0 )\nres = transformRPX(content[1], opt.deviceWidth) + \"px\" + res;\nelse if ( op == 1)\nres = opt.suffix + res;\nelse if ( op == 2 )\nres = makeup(content[1], opt) + res;\n}\nelse\nres = content + res\n}\nreturn res;\n}\nvar styleSheetManager = window.__styleSheetManager2__\nvar rewritor = function(suffix, opt, style){\nopt = opt || {};\nsuffix = suffix || \"\";\nopt.suffix = suffix;\nif ( opt.allowIllegalSelector != undefined && _xcInvalid != undefined )\n{\nif ( opt.allowIllegalSelector )\nconsole.warn( \"For developer:\" + _xcInvalid );\nelse\n{\nconsole.error( _xcInvalid );\n}\n}\nCa={};\ncss = makeup(file, opt);\nif (styleSheetManager) {\nvar key = (info.path || Math.random()) + ':' + suffix\nif (!style) {\nstyleSheetManager.addItem(key, info.path);\nwindow.__rpxRecalculatingFuncs__.push(function(size){\nopt.deviceWidth = size.width;\nrewritor(suffix, opt, true);\n});\n}\nstyleSheetManager.setCss(key, css);\nreturn;\n}\nif ( !style )\n{\nvar head = document.head || document.getElementsByTagName('head')[0];\nstyle = document.createElement('style');\nstyle.type = 'text/css';\nstyle.setAttribute( \"wxss:path\", info.path );\nhead.appendChild(style);\nwindow.__rpxRecalculatingFuncs__.push(function(size){\nopt.deviceWidth = size.width;\nrewritor(suffix, opt, style);\n});\n}\nif (style.styleSheet) {\nstyle.styleSheet.cssText = css;\n} else {\nif ( style.childNodes.length == 0 )\nstyle.appendChild(document.createTextNode(css));\nelse\nstyle.childNodes[0].nodeValue = css;\n}\n}\nreturn rewritor;\n}\nsetCssToHead([])();setCssToHead([\".\",[1],\"container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: \",[0,200],\" 0; ;wxcs_style_padding : 200rpx 0; box-sizing: border-box; ;wxcs_originclass: .container;;wxcs_fileinfo: ./app.wxss 2 1; }\\n\",],undefined,{path:\"./app.wxss\"})();", + "pageWxss": { + "./app.wxss": "setCssToHead([\".\",[1],\"container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: \",[0,200],\" 0; ;wxcs_style_padding : 200rpx 0; box-sizing: border-box; ;wxcs_originclass: .container;;wxcs_fileinfo: ./app.wxss 2 1; }\\n\",],undefined,{path:\"./app.wxss\"})", + "./pages/index/index.wxss": "setCssToHead([\".\",[1],\"userinfo { display: flex; flex-direction: column; align-items: center; color: #aaa; ;wxcs_originclass: .userinfo;;wxcs_fileinfo: ./pages/index/index.wxss 2 1; }\\n.\",[1],\"userinfo-avatar { overflow: hidden; width: \",[0,128],\"; ;wxcs_style_width : 128rpx; height: \",[0,128],\"; ;wxcs_style_height : 128rpx; margin: \",[0,20],\"; ;wxcs_style_margin : 20rpx; border-radius: 50%; ;wxcs_originclass: .userinfo-avatar;;wxcs_fileinfo: ./pages/index/index.wxss 9 1; }\\n.\",[1],\"usermotto { margin-top: 200px; ;wxcs_originclass: .usermotto;;wxcs_fileinfo: ./pages/index/index.wxss 17 1; }\\n\",],undefined,{path:\"./pages/index/index.wxss\"})", + "./pages/logs/logs.wxss": "setCssToHead([\".\",[1],\"log-list { display: flex; flex-direction: column; padding: \",[0,40],\"; ;wxcs_style_padding : 40rpx; ;wxcs_originclass: .log-list;;wxcs_fileinfo: ./pages/logs/logs.wxss 1 1; }\\n.\",[1],\"log-item { margin: \",[0,10],\"; ;wxcs_style_margin : 10rpx; ;wxcs_originclass: .log-item;;wxcs_fileinfo: ./pages/logs/logs.wxss 6 1; }\\n\",],undefined,{path:\"./pages/logs/logs.wxss\"})" + } +} \ No newline at end of file diff --git a/test/wcsc/viewedit/1/result.json b/test/wcsc/viewedit/1/result.json new file mode 100644 index 0000000..31de7a3 --- /dev/null +++ b/test/wcsc/viewedit/1/result.json @@ -0,0 +1,8 @@ +{ + "common": "var BASE_DEVICE_WIDTH = 750;\nvar isIOS=navigator.userAgent.match(\"iPhone\");\nvar deviceWidth = window.screen.width || 375;\nvar deviceDPR = window.devicePixelRatio || 2;\nvar checkDeviceWidth = window.__checkDeviceWidth__ || function() {\nvar newDeviceWidth = window.screen.width || 375\nvar newDeviceDPR = window.devicePixelRatio || 2\nvar newDeviceHeight = window.screen.height || 375\nif (window.screen.orientation && /^landscape/.test(window.screen.orientation.type || '')) newDeviceWidth = newDeviceHeight\nif (newDeviceWidth !== deviceWidth || newDeviceDPR !== deviceDPR) {\ndeviceWidth = newDeviceWidth\ndeviceDPR = newDeviceDPR\n}\n}\ncheckDeviceWidth()\nvar eps = 1e-4;\nvar transformRPX = window.__transformRpx__ || function(number, newDeviceWidth) {\nif ( number === 0 ) return 0;\nnumber = number / BASE_DEVICE_WIDTH * ( newDeviceWidth || deviceWidth );\nnumber = Math.floor(number + eps);\nif (number === 0) {\nif (deviceDPR === 1 || !isIOS) {\nreturn 1;\n} else {\nreturn 0.5;\n}\n}\nreturn number;\n}\nwindow.__rpxRecalculatingFuncs__ = window.__rpxRecalculatingFuncs__ || [];\nvar __COMMON_STYLESHEETS__ = __COMMON_STYLESHEETS__||{}\n\nvar setCssToHead = function(file, _xcInvalid, info) {\nvar Ca = {};\nvar css_id;\nvar info = info || {};\nvar _C = __COMMON_STYLESHEETS__\nfunction makeup(file, opt) {\nvar _n = typeof(file) === \"string\";\nif ( _n && Ca.hasOwnProperty(file)) return \"\";\nif ( _n ) Ca[file] = 1;\nvar ex = _n ? _C[file] : file;\nvar res=\"\";\nfor (var i = ex.length - 1; i >= 0; i--) {\nvar content = ex[i];\nif (typeof(content) === \"object\")\n{\nvar op = content[0];\nif ( op == 0 )\nres = transformRPX(content[1], opt.deviceWidth) + \"px\" + res;\nelse if ( op == 1)\nres = opt.suffix + res;\nelse if ( op == 2 )\nres = makeup(content[1], opt) + res;\n}\nelse\nres = content + res\n}\nreturn res;\n}\nvar styleSheetManager = window.__styleSheetManager2__\nvar rewritor = function(suffix, opt, style){\nopt = opt || {};\nsuffix = suffix || \"\";\nopt.suffix = suffix;\nif ( opt.allowIllegalSelector != undefined && _xcInvalid != undefined )\n{\nif ( opt.allowIllegalSelector )\nconsole.warn( \"For developer:\" + _xcInvalid );\nelse\n{\nconsole.error( _xcInvalid );\n}\n}\nCa={};\ncss = makeup(file, opt);\nif (styleSheetManager) {\nvar key = (info.path || Math.random()) + ':' + suffix\nif (!style) {\nstyleSheetManager.addItem(key, info.path);\nwindow.__rpxRecalculatingFuncs__.push(function(size){\nopt.deviceWidth = size.width;\nrewritor(suffix, opt, true);\n});\n}\nstyleSheetManager.setCss(key, css);\nreturn;\n}\nif ( !style )\n{\nvar head = document.head || document.getElementsByTagName('head')[0];\nstyle = document.createElement('style');\nstyle.type = 'text/css';\nstyle.setAttribute( \"wxss:path\", info.path );\nhead.appendChild(style);\nwindow.__rpxRecalculatingFuncs__.push(function(size){\nopt.deviceWidth = size.width;\nrewritor(suffix, opt, style);\n});\n}\nif (style.styleSheet) {\nstyle.styleSheet.cssText = css;\n} else {\nif ( style.childNodes.length == 0 )\nstyle.appendChild(document.createTextNode(css));\nelse\nstyle.childNodes[0].nodeValue = css;\n}\n}\nreturn rewritor;\n}\nsetCssToHead([])();setCssToHead([\".\",[1],\"container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: \",[0,200],\" 0; ;wxcs_style_padding : 200rpx 0; box-sizing: border-box; ;wxcs_originclass: .container;;wxcs_fileinfo: ./app.wxss 2 1; }\\n\",],undefined,{path:\"./app.wxss\"})();", + "pageWxss": { + "./app.wxss": "setCssToHead([\".\",[1],\"container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: \",[0,200],\" 0; ;wxcs_style_padding : 200rpx 0; box-sizing: border-box; ;wxcs_originclass: .container;;wxcs_fileinfo: ./app.wxss 2 1; }\\n\",],undefined,{path:\"./app.wxss\"})", + "./pages/index/index.wxss": "setCssToHead([\".\",[1],\"userinfo { display: flex; flex-direction: column; align-items: center; color: #aaa; ;wxcs_originclass: .userinfo;;wxcs_fileinfo: ./pages/index/index.wxss 2 1; }\\n.\",[1],\"userinfo-avatar { overflow: hidden; width: \",[0,128],\"; ;wxcs_style_width : 128rpx; height: \",[0,128],\"; ;wxcs_style_height : 128rpx; margin: \",[0,20],\"; ;wxcs_style_margin : 20rpx; border-radius: 50%; ;wxcs_originclass: .userinfo-avatar;;wxcs_fileinfo: ./pages/index/index.wxss 9 1; }\\n.\",[1],\"usermotto { margin-top: 200px; ;wxcs_originclass: .usermotto;;wxcs_fileinfo: ./pages/index/index.wxss 17 1; }\\n\",],undefined,{path:\"./pages/index/index.wxss\"})", + "./pages/logs/logs.wxss": "setCssToHead([\".\",[1],\"log-list { display: flex; flex-direction: column; padding: \",[0,40],\"; ;wxcs_style_padding : 40rpx; ;wxcs_originclass: .log-list;;wxcs_fileinfo: ./pages/logs/logs.wxss 1 1; }\\n.\",[1],\"log-item { margin: \",[0,10],\"; ;wxcs_style_margin : 10rpx; ;wxcs_originclass: .log-item;;wxcs_fileinfo: ./pages/logs/logs.wxss 6 1; }\\n\",],undefined,{path:\"./pages/logs/logs.wxss\"})" + } +} \ No newline at end of file diff --git a/test/wcsc/viewedit/wcsc.js b/test/wcsc/viewedit/wcsc.js new file mode 100644 index 0000000..4464d87 --- /dev/null +++ b/test/wcsc/viewedit/wcsc.js @@ -0,0 +1,25 @@ +const wcsc = require('../../../package.nw/node_modules/wcsc') +const fs = require('fs') + +const options = { + "files": [ + "./pages/index/index.wxss", + "./pages/logs/logs.wxss", + "./app.wxss"], + "contents": [ + "/**index.wxss**/\n.userinfo {\n display: flex;\n flex-direction: column;\n align-items: center;\n color: #aaa;\n}\n\n.userinfo-avatar {\n overflow: hidden;\n width: 128rpx;\n height: 128rpx;\n margin: 20rpx;\n border-radius: 50%;\n}\n\n.usermotto {\n margin-top: 200px;\n}", ".log-list {\n display: flex;\n flex-direction: column;\n padding: 40rpx;\n}\n.log-item {\n margin: 10rpx;\n}\n", "/**app.wxss**/\n.container {\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: space-between;\n padding: 200rpx 0;\n box-sizing: border-box;\n} \n" + ], + "pageCount": 2, + "cwd": "/home/msojocs/Documents/we1", + "replaceContent": { + "./pages/index/index.wxss": "/**index.wxss**/\n.userinfo {\n display: flex;\n flex-direction: column;\n align-items: center;\n color: #aaa;\n}\n\n.userinfo-avatar {\n overflow: hidden;\n width: 128rpx;\n height: 128rpx;\n margin: 20rpx;\n border-radius: 50%;\n}\n\n.usermotto {\n margin-top: 200px;\n}" + }, + "debug": true, + "classPrefix": "", + "lazyload": true +} +wcsc(options) +.then(res=>{ + console.log(res) + fs.writeFileSync('test/wcsc/viewedit/1/node.json', JSON.stringify(res, null, 2)) +}) \ No newline at end of file