Browse Source

Pull request #3369: KERNEL-14076 feat:把 base 里面的函数都加进来

Merge in VISUAL/fineui from ~TREECAT/fineui:es6 to es6

* commit '175bbf178b98dc54273487b40febd91ff6fd91b2':
  KERNEL-14076 feat:把 base 里面的函数都加进来
es6
treecat-罗群 2 years ago
parent
commit
06d71638a1
  1. 96
      es6.js

96
es6.js

@ -12,43 +12,43 @@ 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;
@ -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)`;
@ -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);
});

Loading…
Cancel
Save