You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.1 KiB
104 lines
2.1 KiB
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.getFromScriptContent = getFromScriptContent;
|
|
exports.getBasicScriptContent = exports.default = void 0;
|
|
|
|
function _react() {
|
|
const data = _interopRequireDefault(require("react"));
|
|
|
|
_react = function _react() {
|
|
return data;
|
|
};
|
|
|
|
return data;
|
|
}
|
|
|
|
function _fs() {
|
|
const data = require("fs");
|
|
|
|
_fs = function _fs() {
|
|
return data;
|
|
};
|
|
|
|
return data;
|
|
}
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
var _default = scripts => getFromScriptContent(scripts.map(script => (0, _fs().readFileSync)(script, 'utf-8')));
|
|
|
|
exports.default = _default;
|
|
|
|
const getBasicScriptContent = script => {
|
|
const content = (0, _fs().readFileSync)(script, 'utf-8');
|
|
return `
|
|
window.g_uiBasicUI = [];
|
|
const oldDefine = window.define;
|
|
window.define = (deps, fn) => {
|
|
const map = {
|
|
react: window.React,
|
|
'react-dom': window.ReactDOM,
|
|
antd: window.antd,
|
|
};
|
|
if (!Array.isArray(deps)) {
|
|
fn = deps;
|
|
deps = [];
|
|
}
|
|
deps = deps.map(dep => {
|
|
return map[dep];
|
|
});
|
|
window.g_uiBasicUI.push(fn.apply(null, deps));
|
|
};
|
|
define.amd = true;
|
|
|
|
try {
|
|
${content}
|
|
} catch (e) {
|
|
console.error('basic script error', e);
|
|
}
|
|
|
|
window.define = oldDefine;`.trim();
|
|
};
|
|
|
|
exports.getBasicScriptContent = getBasicScriptContent;
|
|
|
|
function getFromScriptContent(scripts) {
|
|
return `
|
|
window.g_uiPlugins = [];
|
|
const oldDefine = window.define;
|
|
window.define = (deps, fn) => {
|
|
const map = {
|
|
react: window.React,
|
|
'react-dom': window.ReactDOM,
|
|
antd: window.antd,
|
|
};
|
|
if (!Array.isArray(deps)) {
|
|
fn = deps;
|
|
deps = [];
|
|
}
|
|
deps = deps.map(dep => {
|
|
return map[dep];
|
|
});
|
|
window.g_uiPlugins.push(fn.apply(null, deps));
|
|
};
|
|
define.amd = true;
|
|
|
|
${scripts.map(getFromScript).join('\n\n')}
|
|
|
|
window.define = oldDefine;
|
|
`.trim();
|
|
}
|
|
|
|
function getFromScript(script, index) {
|
|
return `
|
|
/* Plugin: ${index} */
|
|
try {
|
|
${script}
|
|
} catch (e) {
|
|
console.error('plugin ${index} error', e);
|
|
}
|
|
`.trim();
|
|
} |