-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
158 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.1.3 | ||
1.1.3.542 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const args = process.argv.slice(2) | ||
let src = args[0] || path.resolve(__dirname, '../app/app/main/index.js') | ||
let dist = args[1] || path.resolve(__dirname, '../app/app/main/index.dex.js') | ||
|
||
function parseSubFunc (str) { | ||
return str.replace( | ||
/(\w+|\S)\['([a-zA-Z_]*?)'\]/g, | ||
function ($0, $1, $2) { | ||
if($2.length===0)return $0 | ||
let result = $0 | ||
switch ($1) { | ||
case '{': | ||
result = `{${$2}` | ||
break | ||
case '}': | ||
result = `}${$2}` | ||
break | ||
case ']': | ||
result = `].${$2}` | ||
break | ||
case '.': | ||
case ':': | ||
result = `${$1}${$2}` | ||
break | ||
case 'async': | ||
case 'get': | ||
result = `${$1} ${$2}` | ||
break | ||
default: | ||
// console.log("---", $0, $1, $2) | ||
result = `${$1}.${$2}` | ||
break | ||
} | ||
// if($2 === "toString"){ | ||
// console.log("---", $0, $1, $2 , " result:", result) | ||
// } | ||
return result | ||
} | ||
) | ||
} | ||
|
||
function encodeUnicode (s) { | ||
return s.replace( | ||
/'(\\u([\da-f]{4})){1,}'/g, | ||
function ($0, $1, $2) { | ||
const result = eval('"' + $0 + '"') | ||
// console.log('---', $0, $1, $2) | ||
return result | ||
} | ||
) | ||
} | ||
|
||
const sourceCode = fs.readFileSync(src) | ||
|
||
let resultCode = sourceCode.toString() | ||
let i = 0; | ||
resultCode = resultCode.replace( | ||
/'(([\\xa-z0-9]{2,2})+)'/g, | ||
function ($0, $1, $2) { | ||
i++; | ||
// 二分法查找异常点 | ||
// 763 ok | ||
// 764 error | ||
// if(i >= 10830){ | ||
// if(i === 763){ | ||
// console.log("---", $0, $1, $2) | ||
// let result = eval('"' + $1 + '"') | ||
// console.log("---", result) | ||
// } | ||
// return $0 | ||
// } | ||
|
||
let result = eval('"' + $1 + '"') | ||
if (result.includes('*')) { | ||
// 不做处理 | ||
return $0 | ||
} | ||
if (result.includes("\\")) { | ||
result = result.replace(/\\/g, "\\\\") | ||
} | ||
if (result.includes("'")) { | ||
result = result.replace(/'/g, "\\'") | ||
} | ||
if (result.includes("\n")) { | ||
result = result.replace(/\n/g, "\\n") | ||
} | ||
if (result.includes("\r")) { | ||
result = result.replace(/\r/g, "\\r") | ||
} | ||
return `'${result}'` | ||
} | ||
) | ||
resultCode = encodeUnicode(resultCode) | ||
// fs.writeFileSync(path.resolve(__dirname, '../app/app/main/index1.js'), resultCode) | ||
resultCode = parseSubFunc(resultCode) | ||
resultCode = parseSubFunc(resultCode) | ||
resultCode = resultCode.replace(/'\+'/g, '') | ||
fs.writeFileSync(dist, resultCode) | ||
// fs.writeFileSync(path.resolve(__dirname, '../'), resultCode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters