Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Commit

Permalink
To fit a case that WX's code generater have a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty472123 committed Aug 15, 2018
1 parent c233c52 commit 73580c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Android 手机最近使用过的微信小程序所对应的 wxapkg 包文件都
npm install vm2 -g
npm install uglify-es -g
npm install js-beautify -g
npm install escodegen -g

此外,这些 node.js 程序之间也有一定的依赖关系,比如他们都依赖于 wuLib.js 。

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"dependencies": {
"css-tree": "^1.0.0-alpha.28",
"cssbeautify": "^0.3.1",
"escodegen": "^1.11.0",
"esprima": "^4.0.0",
"js-beautify": "^1.7.5",
"uglify-es": "^3.3.9",
"vm2": "^3.6.0",
"js-beautify": "^1.7.5"
"vm2": "^3.6.0"
}
}
7 changes: 4 additions & 3 deletions wuWxml.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fs=require('fs');
const path=require("path");
const esprima=require('esprima');
const {VM}=require('vm2');
const escodegen=require('escodegen');
function analyze(core,z,namePool,xPool,fakePool={},zMulName="0"){
function anaRecursion(core,fakePool={}){
return analyze(core,z,namePool,xPool,fakePool,zMulName);
Expand Down Expand Up @@ -38,7 +39,7 @@ function analyze(core,z,namePool,xPool,fakePool={},zMulName="0"){
let item=f.arguments[6].value;//def:item
let index=f.arguments[7].value;//def:index
let data=z[f.arguments[0].value];
let key=f.arguments[8].value;//def:""
let key=escodegen.generate(f.arguments[8]).slice(1,-1);//f.arguments[8].value;//def:""
let obj=namePool[f.arguments[5].name];
let gen=namePool[f.arguments[1].name];
if(gen.tag=="gen"){
Expand All @@ -56,7 +57,7 @@ function analyze(core,z,namePool,xPool,fakePool={},zMulName="0"){
let item=f.arguments[7].value;//def:item
let index=f.arguments[8].value;//def:index
let data=z.mul[zMulName][f.arguments[1].value];
let key=f.arguments[9].value;//def:""
let key=escodegen.generate(f.arguments[9]).slice(1,-1);//f.arguments[9].value;//def:""
let obj=namePool[f.arguments[6].name];
let gen=namePool[f.arguments[2].name];
if(gen.tag=="gen"){
Expand Down Expand Up @@ -237,7 +238,7 @@ function analyze(core,z,namePool,xPool,fakePool={},zMulName="0"){
}
}
function wxmlify(str,isText){
if(typeof str=="undefined"||str===null)throw Error("Empty str in "+(isText?"text":"prop"));
if(typeof str=="undefined"||str===null)return "Empty";//throw Error("Empty str in "+(isText?"text":"prop"));
if(isText)return str;//may have some bugs in some specific case(undocumented by tx)
else return str.replace(/"/g, '\\"');
}
Expand Down

0 comments on commit 73580c3

Please sign in to comment.