|
|
@ -12,49 +12,49 @@ async function fix(path) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const target = [ |
|
|
|
|
|
|
|
"isNull", |
|
|
|
|
|
|
|
"toPix", |
|
|
|
|
|
|
|
"isKey", |
|
|
|
|
|
|
|
"isObject", |
|
|
|
|
|
|
|
"map", |
|
|
|
|
|
|
|
"extend", |
|
|
|
|
|
|
|
"isFunction", |
|
|
|
|
|
|
|
"isEmptyArray", |
|
|
|
|
|
|
|
"isArray", |
|
|
|
|
|
|
|
"Controller", |
|
|
|
|
|
|
|
"createWidget", |
|
|
|
|
|
|
|
"Events", |
|
|
|
|
|
|
|
"emptyFn", |
|
|
|
|
|
|
|
"nextTick", |
|
|
|
|
|
|
|
"bind", |
|
|
|
|
|
|
|
"i18nText", |
|
|
|
|
|
|
|
"isNotNull", |
|
|
|
|
|
|
|
"isString", |
|
|
|
|
|
|
|
"isNumber", |
|
|
|
|
|
|
|
"isEmpty", |
|
|
|
|
|
|
|
"isEmptyString", |
|
|
|
|
|
|
|
"any", |
|
|
|
|
|
|
|
"deepContains", |
|
|
|
|
|
|
|
"isNotEmptyString", |
|
|
|
|
|
|
|
"each", |
|
|
|
|
|
|
|
"contains", |
|
|
|
|
|
|
|
"remove", |
|
|
|
|
|
|
|
"createItems", |
|
|
|
|
|
|
|
"makeArrayByArray", |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
// 加载模块
|
|
|
|
// 加载模块
|
|
|
|
const loader = { |
|
|
|
const loader = { |
|
|
|
G: { "@/core": { shortcut: true } }, |
|
|
|
G: { "@/core": { shortcut: true } }, |
|
|
|
async load(srcName, module) { |
|
|
|
async load(srcName, module) { |
|
|
|
const G = loader.G; |
|
|
|
const G = loader.G; |
|
|
|
const target = [ |
|
|
|
|
|
|
|
"isNull", |
|
|
|
|
|
|
|
"toPix", |
|
|
|
|
|
|
|
"isKey", |
|
|
|
|
|
|
|
"isObject", |
|
|
|
|
|
|
|
"map", |
|
|
|
|
|
|
|
"extend", |
|
|
|
|
|
|
|
"isFunction", |
|
|
|
|
|
|
|
"isEmptyArray", |
|
|
|
|
|
|
|
"isArray", |
|
|
|
|
|
|
|
"Controller", |
|
|
|
|
|
|
|
"createWidget", |
|
|
|
|
|
|
|
"Events", |
|
|
|
|
|
|
|
"emptyFn", |
|
|
|
|
|
|
|
"nextTick", |
|
|
|
|
|
|
|
"bind", |
|
|
|
|
|
|
|
"i18nText", |
|
|
|
|
|
|
|
"isNotNull", |
|
|
|
|
|
|
|
"isString", |
|
|
|
|
|
|
|
"isNumber", |
|
|
|
|
|
|
|
"isEmpty", |
|
|
|
|
|
|
|
"isEmptyString", |
|
|
|
|
|
|
|
"any", |
|
|
|
|
|
|
|
"deepContains", |
|
|
|
|
|
|
|
"isNotEmptyString", |
|
|
|
|
|
|
|
"each", |
|
|
|
|
|
|
|
"contains", |
|
|
|
|
|
|
|
"remove", |
|
|
|
|
|
|
|
"createItems", |
|
|
|
|
|
|
|
"makeArrayByArray", |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
console.log(module); |
|
|
|
|
|
|
|
if (target.indexOf(module) >= 0) { |
|
|
|
if (target.indexOf(module) >= 0) { |
|
|
|
G["@/core"][module] = true; |
|
|
|
G["@/core"][module] = true; |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const key = search(srcName, module); |
|
|
|
const key = search(srcName, module); |
|
|
|
if (key) { |
|
|
|
if (key) { |
|
|
|
if (!G[key]) { |
|
|
|
if (!G[key]) { |
|
|
@ -67,7 +67,6 @@ const loader = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function handleFile(srcName) { |
|
|
|
async function handleFile(srcName) { |
|
|
|
const G = loader.G; |
|
|
|
const G = loader.G; |
|
|
|
|
|
|
|
|
|
|
@ -83,8 +82,6 @@ async function handleFile(srcName) { |
|
|
|
|
|
|
|
|
|
|
|
const superName = /inherit\(BI\.(.*?),/.exec(sourceCode)[1]; |
|
|
|
const superName = /inherit\(BI\.(.*?),/.exec(sourceCode)[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const xtype = /BI.shortcut\(\"(.*?)\"/.exec(sourceCode)[1];
|
|
|
|
// const xtype = /BI.shortcut\(\"(.*?)\"/.exec(sourceCode)[1];
|
|
|
|
|
|
|
|
|
|
|
|
const collection = { |
|
|
|
const collection = { |
|
|
@ -134,15 +131,17 @@ async function handleFile(srcName) { |
|
|
|
collection.methods.forEach(el => { |
|
|
|
collection.methods.forEach(el => { |
|
|
|
let f = `${el.toString().replace(/^function/, el.name)}\n`; |
|
|
|
let f = `${el.toString().replace(/^function/, el.name)}\n`; |
|
|
|
|
|
|
|
|
|
|
|
// 换 BI.Button.superclass
|
|
|
|
// 换 BI.Button.superclass,就说能不能跑吧
|
|
|
|
f = f.replace(`BI.${clzName}.superclass`, "super"); |
|
|
|
for (let i = 0; i < 100; i++) { |
|
|
|
|
|
|
|
f = f.replace(`BI.${clzName}.superclass`, "super"); |
|
|
|
|
|
|
|
} |
|
|
|
// 换 super._defaultConfig
|
|
|
|
// 换 super._defaultConfig
|
|
|
|
f = f.replace( |
|
|
|
f = f.replace( |
|
|
|
/super\._defaultConfig\.apply\(this,\sarguments\)/g, |
|
|
|
/super\._defaultConfig\.apply\(this,\sarguments\)/g, |
|
|
|
"super._defaultConfig(arguments)" |
|
|
|
"super._defaultConfig(...arguments)" |
|
|
|
); |
|
|
|
); |
|
|
|
// 换 super.xxx.apply
|
|
|
|
// 换 super.xxx.apply
|
|
|
|
f = f.replace(/super\.(.*?)\.apply\(this,\sarguments\)/, a => { |
|
|
|
f = f.replace(/super\.(.*?)\.apply\(this,\sarguments\)/g, a => { |
|
|
|
const f = /super\.(.*?)\.apply\(this,\sarguments\)/.exec(a); |
|
|
|
const f = /super\.(.*?)\.apply\(this,\sarguments\)/.exec(a); |
|
|
|
|
|
|
|
|
|
|
|
return `super.${f[1]}(...arguments)`; |
|
|
|
return `super.${f[1]}(...arguments)`; |
|
|
@ -159,7 +158,7 @@ async function handleFile(srcName) { |
|
|
|
return target + end; |
|
|
|
return target + end; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
console.log(`加载 ${target}失败`); |
|
|
|
console.log(`加载 ${target}失败`); |
|
|
|
|
|
|
|
|
|
|
|
return matchedSentence; |
|
|
|
return matchedSentence; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -167,9 +166,6 @@ async function handleFile(srcName) { |
|
|
|
M += `${f}\n`; |
|
|
|
M += `${f}\n`; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.keys(G).forEach(moduleKey => { |
|
|
|
Object.keys(G).forEach(moduleKey => { |
|
|
|
if (moduleKey === path.basename(srcName).replace(/.js$/g, "")) { |
|
|
|
if (moduleKey === path.basename(srcName).replace(/.js$/g, "")) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -181,7 +177,6 @@ async function handleFile(srcName) { |
|
|
|
I += `import {${i}} from '${moduleKey}'\n`; |
|
|
|
I += `import {${i}} from '${moduleKey}'\n`; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const outputCode = ` |
|
|
|
const outputCode = ` |
|
|
|
${I} |
|
|
|
${I} |
|
|
|
|
|
|
|
|
|
|
@ -233,7 +228,18 @@ async function traverse(srcName) { |
|
|
|
const srcName = process.argv[2]; |
|
|
|
const srcName = process.argv[2]; |
|
|
|
|
|
|
|
|
|
|
|
initDepts().then(() => { |
|
|
|
initDepts().then(() => { |
|
|
|
|
|
|
|
const content = fs.readFileSync("src/core/2.base.js").toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let result = content.match(/export function (.*?)\(/g); |
|
|
|
|
|
|
|
target.push( |
|
|
|
|
|
|
|
...result.map(el => |
|
|
|
|
|
|
|
el.replace("export function ", "").replace("(", "") |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
result = content.match(/export const (.*?) =/g); |
|
|
|
|
|
|
|
target.push( |
|
|
|
|
|
|
|
...result.map(el => el.replace("export const ", "").replace(" =", "")) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
traverse(srcName); |
|
|
|
traverse(srcName); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|