|
|
|
@ -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 = { |
|
|
|
|
G: { "@/core": { shortcut: true } }, |
|
|
|
|
async load(srcName, module) { |
|
|
|
|
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) { |
|
|
|
|
G["@/core"][module] = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const key = search(srcName, module); |
|
|
|
|
if (key) { |
|
|
|
|
if (!G[key]) { |
|
|
|
@ -67,7 +67,6 @@ const loader = {
|
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function handleFile(srcName) { |
|
|
|
|
const G = loader.G; |
|
|
|
|
|
|
|
|
@ -83,8 +82,6 @@ async function handleFile(srcName) {
|
|
|
|
|
|
|
|
|
|
const superName = /inherit\(BI\.(.*?),/.exec(sourceCode)[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const xtype = /BI.shortcut\(\"(.*?)\"/.exec(sourceCode)[1];
|
|
|
|
|
|
|
|
|
|
const collection = { |
|
|
|
@ -134,15 +131,17 @@ async function handleFile(srcName) {
|
|
|
|
|
collection.methods.forEach(el => { |
|
|
|
|
let f = `${el.toString().replace(/^function/, el.name)}\n`; |
|
|
|
|
|
|
|
|
|
// 换 BI.Button.superclass
|
|
|
|
|
f = f.replace(`BI.${clzName}.superclass`, "super"); |
|
|
|
|
// 换 BI.Button.superclass,就说能不能跑吧
|
|
|
|
|
for (let i = 0; i < 100; i++) { |
|
|
|
|
f = f.replace(`BI.${clzName}.superclass`, "super"); |
|
|
|
|
} |
|
|
|
|
// 换 super._defaultConfig
|
|
|
|
|
f = f.replace( |
|
|
|
|
/super\._defaultConfig\.apply\(this,\sarguments\)/g, |
|
|
|
|
"super._defaultConfig(arguments)" |
|
|
|
|
"super._defaultConfig(...arguments)" |
|
|
|
|
); |
|
|
|
|
// 换 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); |
|
|
|
|
|
|
|
|
|
return `super.${f[1]}(...arguments)`; |
|
|
|
@ -159,7 +158,7 @@ async function handleFile(srcName) {
|
|
|
|
|
return target + end; |
|
|
|
|
} else { |
|
|
|
|
console.log(`加载 ${target}失败`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return matchedSentence; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -167,9 +166,6 @@ async function handleFile(srcName) {
|
|
|
|
|
M += `${f}\n`; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.keys(G).forEach(moduleKey => { |
|
|
|
|
if (moduleKey === path.basename(srcName).replace(/.js$/g, "")) { |
|
|
|
|
return; |
|
|
|
@ -181,7 +177,6 @@ async function handleFile(srcName) {
|
|
|
|
|
I += `import {${i}} from '${moduleKey}'\n`; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const outputCode = ` |
|
|
|
|
${I} |
|
|
|
|
|
|
|
|
@ -233,7 +228,18 @@ async function traverse(srcName) {
|
|
|
|
|
const srcName = process.argv[2]; |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|