|
|
|
@ -18,16 +18,16 @@ import SettingsPage from './components/Settings';
|
|
|
|
|
const regex = [
|
|
|
|
|
{
|
|
|
|
|
regex: /return Promise\.all\(\[(.*?)\]\)\.then\(\D+(.+?)\)\)/,
|
|
|
|
|
parse(match) {
|
|
|
|
|
parse (match) {
|
|
|
|
|
return {
|
|
|
|
|
imports: matchAll(/\(([\de]+)\)/g, match[0]).map(e => Number(e)),
|
|
|
|
|
main: match[1]
|
|
|
|
|
main: match[1]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
regex: /return Promise\.resolve\(\)\.then\(\D+(.+?)\)/,
|
|
|
|
|
parse(match) {
|
|
|
|
|
parse (match) {
|
|
|
|
|
return {
|
|
|
|
|
imports: [],
|
|
|
|
|
main: match[0]
|
|
|
|
@ -36,27 +36,29 @@ import SettingsPage from './components/Settings';
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
regex: /return [rn]\.e\((\d+)\)\.then\(\D+(\d+)\)\)/,
|
|
|
|
|
parse(match) {
|
|
|
|
|
parse (match) {
|
|
|
|
|
return {
|
|
|
|
|
imports: [match[0]],
|
|
|
|
|
imports: [ match[0] ],
|
|
|
|
|
main: match[0]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
function matchAll(regex, input, parent = false) {
|
|
|
|
|
let matches, output = [], lastIndex = 0;
|
|
|
|
|
function matchAll (regex, input, parent = false) {
|
|
|
|
|
let matches,
|
|
|
|
|
output = [],
|
|
|
|
|
lastIndex = 0;
|
|
|
|
|
while (matches = regex.exec(input.slice(lastIndex))) {
|
|
|
|
|
if (!regex.global) lastIndex += matches.index + matches[0].length;
|
|
|
|
|
if (parent) output.push(matches);
|
|
|
|
|
else {
|
|
|
|
|
const [, ...match] = matches;
|
|
|
|
|
const [ , ...match ] = matches;
|
|
|
|
|
output.push(match);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return output;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const found = [];
|
|
|
|
|
|
|
|
|
@ -64,23 +66,21 @@ import SettingsPage from './components/Settings';
|
|
|
|
|
const str = modules[i].toString();
|
|
|
|
|
|
|
|
|
|
for (let i2 = 0; i2 < regex.length; i2++) {
|
|
|
|
|
const {regex: reg, parse} = regex[i2];
|
|
|
|
|
const { regex: reg, parse } = regex[i2];
|
|
|
|
|
if (!reg.test(str)) continue;
|
|
|
|
|
const result = matchAll(reg, str).map(res => ({...parse(res), module: modules[i], reg}));
|
|
|
|
|
const result = matchAll(reg, str).map(res => ({ ...parse(res), module: modules[i], reg }));
|
|
|
|
|
found.push(...result);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Promise.all(found.map(item => {
|
|
|
|
|
try {
|
|
|
|
|
const imports = item.imports.map(i => instance.e(i));
|
|
|
|
|
|
|
|
|
|
return Promise.all(imports).then(instance.bind(instance, item.main)).catch(console.error);
|
|
|
|
|
return Promise.all(imports).then(instance.bind(instance, item.main)).catch(() => void 0);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
|
|
|
|
|
return Promise.resolve();
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|