Commit d2d7a220 authored by 劳工's avatar 劳工

Merge branch 'dev' into 'master'

Dev

See merge request !5
parents ca323596 e4ae62fb
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
import decamelize from 'decamelize';
import crypto from 'crypto';
import babel from '@babel/core';
/**
* Created by rockyl on 2019-11-30.
*/
const UglifyJS = require('uglify-js');
async function compile(source, debug = false) {
const {code, map} = await babel.transformAsync(source, {
presets: [
['@babel/env', {}]
],
babelrc: false,
sourceMaps: debug,
});
const result = {
code,
};
if (map) {
result.sourcemap = map.mappings;
}
return result;
}
function uglify(source){
const uglifyResult = UglifyJS.minify(source, {
});
if (!uglifyResult.error) {
return uglifyResult.code;
}
}
/**
* Created by rockyl on 2019-11-29.
*/
function md5(source) {
const hash = crypto.createHash('md5');
return hash.update(source).digest('hex');
}
class ProcessManager {
constructor() {
this.pool = {};
this.scripts = '';
}
deal(process) {
let hash = this.put(process.script);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess.script);
if (hash) {
subProcess.script = 'link://' + hash;
}
}
}
}
put(script) {
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = script;
}
return hash;
}
}
async generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
this.pool = {};
const {code ,sourcemap} = await compile(scripts, true);
this.scripts = code;
}
generate() {
let scripts = this.scripts;
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
return `
(function(){
var processScripts = {};
(function(exports){
${scripts}
})(processScripts);
engine.setScriptMap(processScripts);
})();
`
}
}
/**
* Created by rockyl on 2019-11-29.
*/
class ScriptManager {
constructor() {
this.pool = [];
}
deal(script){
this.pool.push(script);
}
generate(){
let scripts = '';
for(let {id, code} of this.pool){
scripts += `
/*=====START ${id} START=====*/
(function(exports){
${code}
})(exports);
engine.registerScriptDef(exports.default.id, exports.default);
/*=====END ${id} END=====*/`;
}
return `
(function(){
var exports = {};
${scripts}
})();
`;
}
}
/**
* Created by rockyl on 2019-11-29.
*/
class CustomManager {
constructor() {
this.pool = [];
}
deal(custom) {
this.pool.push(custom);
}
generate(){
let scripts = '';
for(let {id, code} of this.pool){
scripts += `
/*=====START ${id} START=====*/
module = {
exports: {}
};
(function(module){
${code}
})(module);
exports['${id}'] = module.exports;
/*=====END ${id} END=====*/`;
}
return `
(function(){
var exports = {};
var module;
${scripts}
for(var key in exports){
engine.registerCustomModule(key, exports[key]);
}
})();
`
}
}
/** /**
* Created by rockyl on 2019-11-13. * Created by rockyl on 2019-11-13.
* *
* 项目打包 * 项目打包
*/ */
const camelcase = require('camelcase'); const replaceFields = ['pageTitle', 'containerId'];
const replaceFields = ['page_title', 'container_id', 'version'];
async function pack(project, options) { async function pack(data, options) {
let version = Date.now() + Math.floor(Math.random() * 1000); let version = Date.now() + Math.floor(Math.random() * 1000);
let data = JSON.parse(project.data); pageTemplate(data, data.options, version);
const newTpl = await pageTemplate(data, options, version);
const newData = await packData(data, options); const newData = await packData(data, options);
return { return {
version, version,
data: newData, data: newData,
tpl: newTpl,
} }
} }
async function packData(data, {getProcesses, getScripts, getCustoms}) { function fillTpl(data, params) {
const {options} = data;
fillTemplate(options.newTpl, options, params);
return options.newTpl;
}
async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
let newData = {}; let newData = {};
newData.options = data.options; newData.options = data.options;
delete newData.options.tpl; delete newData.options.tpl;
...@@ -30,6 +240,43 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) { ...@@ -30,6 +240,43 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) {
newData.dataMapping = data.dataMapping; newData.dataMapping = data.dataMapping;
newData.processes = data.processes; newData.processes = data.processes;
/*=====START process =====*/
let processIDs = [];
findDepPidsBat(processIDs, data.processes);
let builtinProcesses = newData.builtinProcesses = [];
let bProcessIDs = processIDs;
while (true) {
let newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);
bProcessIDs = [];
for (let id of newPids) {
if (!processIDs.includes(id)) {
bProcessIDs.push(id);
processIDs.push(id);
}
}
if (bProcessIDs.length === 0) {
break;
}
}
for (let process of data.processes) {
processManager.deal(process);
}
await processManager.generateCurrent(); //自定义过程先编译
for (let process of builtinProcesses) {
processManager.deal(process);
}
let processScriptContent = processManager.generate();
//console.log(processScriptContent);
if (!debug) {
processScriptContent = uglify(processScriptContent);
}
/*=====END process =====*/
/*=====START script =====*/
let scriptIDs = []; let scriptIDs = [];
for (let view of newData.views) { for (let view of newData.views) {
traverseNode(view, (node) => { traverseNode(view, (node) => {
...@@ -43,44 +290,47 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) { ...@@ -43,44 +290,47 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) {
}); });
} }
//console.log('scriptIDs:', scriptIDs); //console.log('scriptIDs:', scriptIDs);
let scriptsContainer = newData.scripts = {}; //let scriptsContainer = newData.scripts = {};
//let scriptsCode = '';
if (scriptIDs.length > 0) { if (scriptIDs.length > 0) {
const scripts = await getScripts(scriptIDs); const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) { for (let scriptData of scripts) {
let {id, code} = JSON.parse(scriptData); let script = JSON.parse(scriptData);
scriptsContainer[id] = code; //scriptsContainer[id] = code;
scriptManager.deal(script);
} }
//console.log('scripts:', scriptsContainer); //console.log('scripts:', scriptsContainer);
} }
let processIDs = []; let scriptsContent = scriptManager.generate();
findDepPidsBat(processIDs, newData.processes); //console.log(scriptsContent);
//console.log('processIDs:', processIDs); if (!debug) {
let builtinProcesses = newData.builtinProcesses = []; scriptsContent = uglify(scriptsContent);
let bProcessIDs = processIDs;
while (true) {
let newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);
bProcessIDs = [];
for (let id of newPids) {
if (!processIDs.includes(id)) {
bProcessIDs.push(id);
processIDs.push(id);
}
}
if (bProcessIDs.length === 0) {
break;
}
} }
/*=====END script =====*/
newData.customs = []; /*=====START custom =====*/
//newData.customs = [];
if (data.customs && data.customs.length > 0) { if (data.customs && data.customs.length > 0) {
newData.customs = (await getCustoms(data.customs)).map(item => { /*newData.customs = */
return JSON.parse(item); (await getCustoms(data.customs)).map(item => {
customManager.deal(JSON.parse(item));
//return JSON.parse(item);
}); });
} }
let customScriptContent = customManager.generate();
//console.log(customScriptContent);
if (!debug) {
customScriptContent = uglify(customScriptContent);
}
/*=====END custom =====*/
return JSON.stringify(newData); return {
data: JSON.stringify(newData),
processScriptContent,
scriptsContent,
customScriptContent,
};
} }
function findDepPids(list, process) { function findDepPids(list, process) {
...@@ -114,18 +364,23 @@ async function addBuiltinProcesses(list, ids, getProcesses) { ...@@ -114,18 +364,23 @@ async function addBuiltinProcesses(list, ids, getProcesses) {
return newPids; return newPids;
} }
async function pageTemplate(data, options, version) { function pageTemplate(tpl, options, version) {
const {tpl,} = data.options; const params = {
let newTpl = tpl;
let newOptions = Object.assign(data.options, {
version, version,
}); };
delete newOptions.tpl;
for (let field of replaceFields) { for (let field of replaceFields) {
const key = camelcase(field); params[field] = options[field];
newTpl = newTpl.replace(new RegExp(`\\$${field.toUpperCase()}\\$`, 'g'), newOptions[key]);
} }
return newTpl; fillTemplate(options.tpl, options, params);
}
function fillTemplate(tpl, options, params) {
for (let field in params) {
const pattern = decamelize(field).toUpperCase();
tpl = tpl.replace(new RegExp(`\\$${pattern}\\$`, 'g'), params[field]);
}
options.newTpl = tpl;
} }
function traverseNode(root, callback) { function traverseNode(root, callback) {
...@@ -137,5 +392,5 @@ function traverseNode(root, callback) { ...@@ -137,5 +392,5 @@ function traverseNode(root, callback) {
} }
} }
export { pack }; export { fillTpl, pack };
//# sourceMappingURL=index.es.js.map //# sourceMappingURL=index.es.js.map
{"version":3,"file":"index.es.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nconst camelcase = require('camelcase');\n\nconst replaceFields = ['page_title', 'container_id', 'version'];\n\nexport async function pack(project, options) {\n\tlet version = Date.now() + Math.floor(Math.random() * 1000);\n\tlet data = JSON.parse(project.data);\n\tconst newTpl = await pageTemplate(data, options, version);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t\ttpl: newTpl,\n\t}\n}\n\nasync function packData(data, {getProcesses, getScripts, getCustoms}) {\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\tlet scriptsContainer = newData.scripts = {};\n\tif (scriptIDs.length > 0) {\n\t\tconst scripts = await getScripts(scriptIDs);\n\t\tfor (let scriptData of scripts) {\n\t\t\tlet {id, code} = JSON.parse(scriptData);\n\t\t\tscriptsContainer[id] = code;\n\t\t}\n\t\t//console.log('scripts:', scriptsContainer);\n\t}\n\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, newData.processes);\n\t//console.log('processIDs:', processIDs);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\n\tlet bProcessIDs = processIDs;\n\twhile (true) {\n\t\tlet newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);\n\t\tbProcessIDs = [];\n\t\tfor (let id of newPids) {\n\t\t\tif (!processIDs.includes(id)) {\n\t\t\t\tbProcessIDs.push(id);\n\t\t\t\tprocessIDs.push(id);\n\t\t\t}\n\t\t}\n\t\tif (bProcessIDs.length === 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tnewData.customs = [];\n\tif (data.customs && data.customs.length > 0) {\n\t\tnewData.customs = (await getCustoms(data.customs)).map(item => {\n\t\t\treturn JSON.parse(item);\n\t\t})\n\t}\n\n\treturn JSON.stringify(newData);\n}\n\nfunction findDepPids(list, process) {\n\tif (process.sub) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!list.includes(p.meta)) {\n\t\t\t\tlist.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction findDepPidsBat(list, processes) {\n\tfor (let process of processes) {\n\t\tfindDepPids(list, process);\n\t}\n}\n\nasync function addBuiltinProcesses(list, ids, getProcesses) {\n\tlet newPids = [];\n\tif (ids.length > 0) {\n\t\tlet processes = await getProcesses(ids);\n\t\tfor (let processData of processes) {\n\t\t\tlet process = JSON.parse(processData);\n\t\t\tlist.push(process);\n\t\t\tfindDepPids(newPids, process);\n\t\t}\n\t\t//console.log('processes:', data.processes);\n\t}\n\treturn newPids;\n}\n\nasync function pageTemplate(data, options, version) {\n\tconst {tpl,} = data.options;\n\tlet newTpl = tpl;\n\tlet newOptions = Object.assign(data.options, {\n\t\tversion,\n\t});\n\tdelete newOptions.tpl;\n\tfor (let field of replaceFields) {\n\t\tconst key = camelcase(field);\n\t\tnewTpl = newTpl.replace(new RegExp(`\\\\$${field.toUpperCase()}\\\\$`, 'g'), newOptions[key]);\n\t}\n\treturn newTpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAAA;;;;;;AAMA,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;;AAEvC,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;;AAEhE,AAAO,eAAe,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE;CAC5C,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;CAC5D,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;CAC1D,MAAM,OAAO,GA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MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;EAC7B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;EAC1F;CACD,OAAO,MAAM,CAAC;CACd;;AAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACrC,QAAQ,CAAC,IAAI,CAAC,CAAC;CACf,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;EAC9C,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;GACpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;GAClC;EACD;CACD;;;;"} {"version":3,"file":"index.es.js","sources":["../src/code-process.js","../src/ProcessManager.js","../src/ScriptManager.js","../src/CustomManager.js","../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-30.\n */\n\nimport babel from '@babel/core';\n\nconst UglifyJS = require('uglify-js');\n\nexport async function compile(source, debug = false) {\n\tconst {code, map} = await babel.transformAsync(source, {\n\t\tpresets: [\n\t\t\t['@babel/env', {}]\n\t\t],\n\t\tbabelrc: false,\n\t\tsourceMaps: debug,\n\t});\n\n\tconst result = {\n\t\tcode,\n\t};\n\tif (map) {\n\t\tresult.sourcemap = map.mappings;\n\t}\n\treturn result;\n}\n\nexport function uglify(source){\n\tconst uglifyResult = UglifyJS.minify(source, {\n\t});\n\tif (!uglifyResult.error) {\n\t\treturn uglifyResult.code;\n\t}\n}","/**\n * Created by rockyl on 2019-11-29.\n */\n\nimport crypto from 'crypto'\nimport {compile} from \"./code-process\";\n\nfunction md5(source) {\n\tconst hash = crypto.createHash('md5');\n\treturn hash.update(source).digest('hex');\n}\n\nexport default class ProcessManager {\n\tconstructor() {\n\t\tthis.pool = {};\n\t\tthis.scripts = '';\n\t}\n\n\tdeal(process) {\n\t\tlet hash = this.put(process.script);\n\t\tif (hash) {\n\t\t\tprocess.script = 'link://' + hash;\n\t\t}\n\t\tif (process.metas) {\n\t\t\tfor (let subProcess of process.metas) {\n\t\t\t\tlet hash = this.put(subProcess.script);\n\t\t\t\tif (hash) {\n\t\t\t\t\tsubProcess.script = 'link://' + hash;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tput(script) {\n\t\tif (script) {\n\t\t\tlet hash = md5(script);\n\t\t\tif (!this.pool.hasOwnProperty(hash)) {\n\t\t\t\tthis.pool[hash] = script;\n\t\t\t}\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tasync generateCurrent() {\n\t\tlet scripts = '';\n\t\tfor (let hash in this.pool) {\n\t\t\tlet code = this.pool[hash];\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${code}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\t\tthis.pool = {};\n\n\t\tconst {code ,sourcemap} = await compile(scripts, true);\n\t\tthis.scripts = code;\n\t}\n\n\tgenerate() {\n\t\tlet scripts = this.scripts;\n\t\tfor (let hash in this.pool) {\n\t\t\tlet code = this.pool[hash];\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${code}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\n\t\treturn `\n(function(){\nvar processScripts = {};\n(function(exports){\n${scripts}\n})(processScripts);\n\n\tengine.setScriptMap(processScripts);\n})();\n`\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-29.\n */\n\nexport default class ScriptManager {\n\tconstructor() {\n\t\tthis.pool = [];\n\t}\n\n\tdeal(script){\n\t\tthis.pool.push(script);\n\t}\n\n\tgenerate(){\n\t\tlet scripts = '';\n\t\tfor(let {id, code} of this.pool){\n\t\t\tscripts += `\n/*=====START ${id} START=====*/\n(function(exports){\n${code}\n})(exports);\n\tengine.registerScriptDef(exports.default.id, exports.default);\n/*=====END ${id} END=====*/`;\n\t\t}\n\n\t\treturn `\n(function(){\nvar exports = {};\n${scripts}\n})();\n`;\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-29.\n */\n\nexport default class CustomManager {\n\tconstructor() {\n\t\tthis.pool = [];\n\t}\n\n\tdeal(custom) {\n\t\tthis.pool.push(custom);\n\t}\n\n\tgenerate(){\n\t\tlet scripts = '';\n\t\tfor(let {id, code} of this.pool){\n\t\t\tscripts += `\n/*=====START ${id} START=====*/\nmodule = {\n\texports: {}\n};\n(function(module){\n${code}\n})(module);\nexports['${id}'] = module.exports;\n/*=====END ${id} END=====*/`;\n\t\t}\n\n\t\treturn `\n(function(){\nvar exports = {};\nvar module;\n\n${scripts}\n\n\tfor(var key in exports){\n\t\tengine.registerCustomModule(key, exports[key]);\n\t}\n})();\n`\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nimport decamelize from 'decamelize'\nimport ProcessManager from './ProcessManager'\nimport ScriptManager from './ScriptManager'\nimport CustomManager from './CustomManager'\nimport {uglify} from \"./code-process\";\n\nconst replaceFields = ['pageTitle', 'containerId'];\n\nexport async function pack(data, options) {\n\tlet version = Date.now() + Math.floor(Math.random() * 1000);\n\tpageTemplate(data, data.options, version);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t}\n}\n\nexport function fillTpl(data, params) {\n\tconst {options} = data;\n\tfillTemplate(options.newTpl, options, params);\n\n\treturn options.newTpl;\n}\n\nasync function packData(data, {debug, getProcesses, getScripts, getCustoms}) {\n\tconst processManager = new ProcessManager();\n\tconst scriptManager = new ScriptManager();\n\tconst customManager = new CustomManager();\n\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\t/*=====START process =====*/\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, data.processes);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\n\tlet bProcessIDs = processIDs;\n\twhile (true) {\n\t\tlet newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);\n\t\tbProcessIDs = [];\n\t\tfor (let id of newPids) {\n\t\t\tif (!processIDs.includes(id)) {\n\t\t\t\tbProcessIDs.push(id);\n\t\t\t\tprocessIDs.push(id);\n\t\t\t}\n\t\t}\n\t\tif (bProcessIDs.length === 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor (let process of data.processes) {\n\t\tprocessManager.deal(process);\n\t}\n\tawait processManager.generateCurrent(); //自定义过程先编译\n\n\tfor (let process of builtinProcesses) {\n\t\tprocessManager.deal(process);\n\t}\n\n\tlet processScriptContent = processManager.generate();\n\t//console.log(processScriptContent);\n\tif (!debug) {\n\t\tprocessScriptContent = uglify(processScriptContent);\n\t}\n\t/*=====END process =====*/\n\n\t/*=====START script =====*/\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\t//let scriptsContainer = newData.scripts = {};\n\t//let scriptsCode = '';\n\tif (scriptIDs.length > 0) {\n\t\tconst scripts = await getScripts(scriptIDs);\n\t\tfor (let scriptData of scripts) {\n\t\t\tlet script = JSON.parse(scriptData);\n\t\t\t//scriptsContainer[id] = code;\n\t\t\tscriptManager.deal(script);\n\t\t}\n\t\t//console.log('scripts:', scriptsContainer);\n\t}\n\n\tlet scriptsContent = scriptManager.generate();\n\t//console.log(scriptsContent);\n\tif (!debug) {\n\t\tscriptsContent = uglify(scriptsContent);\n\t}\n\t/*=====END script =====*/\n\n\t/*=====START custom =====*/\n\t//newData.customs = [];\n\tif (data.customs && data.customs.length > 0) {\n\t\t/*newData.customs = */\n\t\t(await getCustoms(data.customs)).map(item => {\n\t\t\tcustomManager.deal(JSON.parse(item));\n\t\t\t//return JSON.parse(item);\n\t\t})\n\t}\n\tlet customScriptContent = customManager.generate();\n\t//console.log(customScriptContent);\n\tif (!debug) {\n\t\tcustomScriptContent = uglify(customScriptContent);\n\t}\n\t/*=====END custom =====*/\n\n\treturn {\n\t\tdata: JSON.stringify(newData),\n\t\tprocessScriptContent,\n\t\tscriptsContent,\n\t\tcustomScriptContent,\n\t};\n}\n\nfunction findDepPids(list, process) {\n\tif (process.sub) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!list.includes(p.meta)) {\n\t\t\t\tlist.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction findDepPidsBat(list, processes) {\n\tfor (let process of processes) {\n\t\tfindDepPids(list, process);\n\t}\n}\n\nasync function addBuiltinProcesses(list, ids, getProcesses) {\n\tlet newPids = [];\n\tif (ids.length > 0) {\n\t\tlet processes = await getProcesses(ids);\n\t\tfor (let processData of processes) {\n\t\t\tlet process = JSON.parse(processData);\n\t\t\tlist.push(process);\n\t\t\tfindDepPids(newPids, process);\n\t\t}\n\t\t//console.log('processes:', data.processes);\n\t}\n\treturn newPids;\n}\n\nfunction pageTemplate(tpl, options, version) {\n\tconst params = {\n\t\tversion,\n\t};\n\tfor (let field of replaceFields) {\n\t\tparams[field] = options[field];\n\t}\n\tfillTemplate(options.tpl, options, params);\n}\n\nfunction fillTemplate(tpl, options, params) {\n\tfor (let field in params) {\n\t\tconst pattern = decamelize(field).toUpperCase();\n\t\ttpl = tpl.replace(new RegExp(`\\\\$${pattern}\\\\$`, 'g'), params[field]);\n\t}\n\n\toptions.newTpl = tpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAAA;;;AAGA,AAEA;AACA,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;;AAEtC,AAAO,eAAe,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE;CACpD,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE;EACtD,OAAO,EAAE;GACR,CAAC,YAAY,EAAE,EAAE,CAAC;GAClB;EACD,OAAO,EAAE,KAAK;EACd,UAAU,EAAE,KAAK;EACjB,CAAC,CAAC;;CAEH,MAAM,MAAM,GAAG;EACd,IAAI;EACJ,CAAC;CACF,IAAI,GAAG,EAAE;EACR,MAAM,CAAC,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC;EAChC;CACD,OAAO,MAAM,CAAC;CACd;;AAED,AAAO,SAAS,MAAM,CAAC,MAAM,CAAC;CAC7B,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;EAC5C,CAAC,CAAC;CACH,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE;EACxB,OAAO,YAAY,CAAC,IAAI,CAAC;EACzB;;;AC/BF;;;AAGA,AAGA;AACA,SAAS,GAAG,CAAC,MAAM,EAAE;CACpB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;CACtC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;CACzC;;AAED,AAAe,MAAM,cAAc,CAAC;CACnC,WAAW,GAAG;EACb,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;EAC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O,OAAO,CAAC;CACf;;AAED,SAAS,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE;CAC5C,MAAM,MAAM,GAAG;EACd,OAAO;EACP,CAAC;CACF,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;EAChC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;EAC/B;CACD,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;CAC3C;;AAED,SAAS,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE;CAC3C,KAAK,IAAI,KAAK,IAAI,MAAM,EAAE;EACzB,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;EAChD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;EACtE;;CAED,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC;CACrB;;AAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACrC,QAAQ,CAAC,IAAI,CAAC,CAAC;CACf,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;EAC9C,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;GACpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;GAClC;EACD;CACD;;;;"}
\ No newline at end of file \ No newline at end of file
...@@ -2,30 +2,242 @@ ...@@ -2,30 +2,242 @@
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var decamelize = _interopDefault(require('decamelize'));
var crypto = _interopDefault(require('crypto'));
var babel = _interopDefault(require('@babel/core'));
/**
* Created by rockyl on 2019-11-30.
*/
const UglifyJS = require('uglify-js');
async function compile(source, debug = false) {
const {code, map} = await babel.transformAsync(source, {
presets: [
['@babel/env', {}]
],
babelrc: false,
sourceMaps: debug,
});
const result = {
code,
};
if (map) {
result.sourcemap = map.mappings;
}
return result;
}
function uglify(source){
const uglifyResult = UglifyJS.minify(source, {
});
if (!uglifyResult.error) {
return uglifyResult.code;
}
}
/**
* Created by rockyl on 2019-11-29.
*/
function md5(source) {
const hash = crypto.createHash('md5');
return hash.update(source).digest('hex');
}
class ProcessManager {
constructor() {
this.pool = {};
this.scripts = '';
}
deal(process) {
let hash = this.put(process.script);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess.script);
if (hash) {
subProcess.script = 'link://' + hash;
}
}
}
}
put(script) {
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = script;
}
return hash;
}
}
async generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
this.pool = {};
const {code ,sourcemap} = await compile(scripts, true);
this.scripts = code;
}
generate() {
let scripts = this.scripts;
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
return `
(function(){
var processScripts = {};
(function(exports){
${scripts}
})(processScripts);
engine.setScriptMap(processScripts);
})();
`
}
}
/**
* Created by rockyl on 2019-11-29.
*/
class ScriptManager {
constructor() {
this.pool = [];
}
deal(script){
this.pool.push(script);
}
generate(){
let scripts = '';
for(let {id, code} of this.pool){
scripts += `
/*=====START ${id} START=====*/
(function(exports){
${code}
})(exports);
engine.registerScriptDef(exports.default.id, exports.default);
/*=====END ${id} END=====*/`;
}
return `
(function(){
var exports = {};
${scripts}
})();
`;
}
}
/**
* Created by rockyl on 2019-11-29.
*/
class CustomManager {
constructor() {
this.pool = [];
}
deal(custom) {
this.pool.push(custom);
}
generate(){
let scripts = '';
for(let {id, code} of this.pool){
scripts += `
/*=====START ${id} START=====*/
module = {
exports: {}
};
(function(module){
${code}
})(module);
exports['${id}'] = module.exports;
/*=====END ${id} END=====*/`;
}
return `
(function(){
var exports = {};
var module;
${scripts}
for(var key in exports){
engine.registerCustomModule(key, exports[key]);
}
})();
`
}
}
/** /**
* Created by rockyl on 2019-11-13. * Created by rockyl on 2019-11-13.
* *
* 项目打包 * 项目打包
*/ */
const camelcase = require('camelcase'); const replaceFields = ['pageTitle', 'containerId'];
const replaceFields = ['page_title', 'container_id', 'version'];
async function pack(project, options) { async function pack(data, options) {
let version = Date.now() + Math.floor(Math.random() * 1000); let version = Date.now() + Math.floor(Math.random() * 1000);
let data = JSON.parse(project.data); pageTemplate(data, data.options, version);
const newTpl = await pageTemplate(data, options, version);
const newData = await packData(data, options); const newData = await packData(data, options);
return { return {
version, version,
data: newData, data: newData,
tpl: newTpl,
} }
} }
async function packData(data, {getProcesses, getScripts, getCustoms}) { function fillTpl(data, params) {
const {options} = data;
fillTemplate(options.newTpl, options, params);
return options.newTpl;
}
async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
let newData = {}; let newData = {};
newData.options = data.options; newData.options = data.options;
delete newData.options.tpl; delete newData.options.tpl;
...@@ -34,6 +246,43 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) { ...@@ -34,6 +246,43 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) {
newData.dataMapping = data.dataMapping; newData.dataMapping = data.dataMapping;
newData.processes = data.processes; newData.processes = data.processes;
/*=====START process =====*/
let processIDs = [];
findDepPidsBat(processIDs, data.processes);
let builtinProcesses = newData.builtinProcesses = [];
let bProcessIDs = processIDs;
while (true) {
let newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);
bProcessIDs = [];
for (let id of newPids) {
if (!processIDs.includes(id)) {
bProcessIDs.push(id);
processIDs.push(id);
}
}
if (bProcessIDs.length === 0) {
break;
}
}
for (let process of data.processes) {
processManager.deal(process);
}
await processManager.generateCurrent(); //自定义过程先编译
for (let process of builtinProcesses) {
processManager.deal(process);
}
let processScriptContent = processManager.generate();
//console.log(processScriptContent);
if (!debug) {
processScriptContent = uglify(processScriptContent);
}
/*=====END process =====*/
/*=====START script =====*/
let scriptIDs = []; let scriptIDs = [];
for (let view of newData.views) { for (let view of newData.views) {
traverseNode(view, (node) => { traverseNode(view, (node) => {
...@@ -47,44 +296,47 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) { ...@@ -47,44 +296,47 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) {
}); });
} }
//console.log('scriptIDs:', scriptIDs); //console.log('scriptIDs:', scriptIDs);
let scriptsContainer = newData.scripts = {}; //let scriptsContainer = newData.scripts = {};
//let scriptsCode = '';
if (scriptIDs.length > 0) { if (scriptIDs.length > 0) {
const scripts = await getScripts(scriptIDs); const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) { for (let scriptData of scripts) {
let {id, code} = JSON.parse(scriptData); let script = JSON.parse(scriptData);
scriptsContainer[id] = code; //scriptsContainer[id] = code;
scriptManager.deal(script);
} }
//console.log('scripts:', scriptsContainer); //console.log('scripts:', scriptsContainer);
} }
let processIDs = []; let scriptsContent = scriptManager.generate();
findDepPidsBat(processIDs, newData.processes); //console.log(scriptsContent);
//console.log('processIDs:', processIDs); if (!debug) {
let builtinProcesses = newData.builtinProcesses = []; scriptsContent = uglify(scriptsContent);
let bProcessIDs = processIDs;
while (true) {
let newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);
bProcessIDs = [];
for (let id of newPids) {
if (!processIDs.includes(id)) {
bProcessIDs.push(id);
processIDs.push(id);
}
}
if (bProcessIDs.length === 0) {
break;
}
} }
/*=====END script =====*/
newData.customs = []; /*=====START custom =====*/
//newData.customs = [];
if (data.customs && data.customs.length > 0) { if (data.customs && data.customs.length > 0) {
newData.customs = (await getCustoms(data.customs)).map(item => { /*newData.customs = */
return JSON.parse(item); (await getCustoms(data.customs)).map(item => {
customManager.deal(JSON.parse(item));
//return JSON.parse(item);
}); });
} }
let customScriptContent = customManager.generate();
//console.log(customScriptContent);
if (!debug) {
customScriptContent = uglify(customScriptContent);
}
/*=====END custom =====*/
return JSON.stringify(newData); return {
data: JSON.stringify(newData),
processScriptContent,
scriptsContent,
customScriptContent,
};
} }
function findDepPids(list, process) { function findDepPids(list, process) {
...@@ -118,18 +370,23 @@ async function addBuiltinProcesses(list, ids, getProcesses) { ...@@ -118,18 +370,23 @@ async function addBuiltinProcesses(list, ids, getProcesses) {
return newPids; return newPids;
} }
async function pageTemplate(data, options, version) { function pageTemplate(tpl, options, version) {
const {tpl,} = data.options; const params = {
let newTpl = tpl;
let newOptions = Object.assign(data.options, {
version, version,
}); };
delete newOptions.tpl;
for (let field of replaceFields) { for (let field of replaceFields) {
const key = camelcase(field); params[field] = options[field];
newTpl = newTpl.replace(new RegExp(`\\$${field.toUpperCase()}\\$`, 'g'), newOptions[key]);
} }
return newTpl; fillTemplate(options.tpl, options, params);
}
function fillTemplate(tpl, options, params) {
for (let field in params) {
const pattern = decamelize(field).toUpperCase();
tpl = tpl.replace(new RegExp(`\\$${pattern}\\$`, 'g'), params[field]);
}
options.newTpl = tpl;
} }
function traverseNode(root, callback) { function traverseNode(root, callback) {
...@@ -141,5 +398,6 @@ function traverseNode(root, callback) { ...@@ -141,5 +398,6 @@ function traverseNode(root, callback) {
} }
} }
exports.fillTpl = fillTpl;
exports.pack = pack; exports.pack = pack;
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nconst camelcase = require('camelcase');\n\nconst replaceFields = ['page_title', 'container_id', 'version'];\n\nexport async function pack(project, options) {\n\tlet version = Date.now() + Math.floor(Math.random() * 1000);\n\tlet data = JSON.parse(project.data);\n\tconst newTpl = await pageTemplate(data, options, version);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t\ttpl: newTpl,\n\t}\n}\n\nasync function packData(data, {getProcesses, getScripts, getCustoms}) {\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\tlet scriptsContainer = newData.scripts = {};\n\tif (scriptIDs.length > 0) {\n\t\tconst scripts = await getScripts(scriptIDs);\n\t\tfor (let scriptData of scripts) {\n\t\t\tlet {id, code} = JSON.parse(scriptData);\n\t\t\tscriptsContainer[id] = code;\n\t\t}\n\t\t//console.log('scripts:', scriptsContainer);\n\t}\n\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, newData.processes);\n\t//console.log('processIDs:', processIDs);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\n\tlet bProcessIDs = processIDs;\n\twhile (true) {\n\t\tlet newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);\n\t\tbProcessIDs = [];\n\t\tfor (let id of newPids) {\n\t\t\tif (!processIDs.includes(id)) {\n\t\t\t\tbProcessIDs.push(id);\n\t\t\t\tprocessIDs.push(id);\n\t\t\t}\n\t\t}\n\t\tif (bProcessIDs.length === 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tnewData.customs = [];\n\tif (data.customs && data.customs.length > 0) {\n\t\tnewData.customs = (await getCustoms(data.customs)).map(item => {\n\t\t\treturn JSON.parse(item);\n\t\t})\n\t}\n\n\treturn JSON.stringify(newData);\n}\n\nfunction findDepPids(list, process) {\n\tif (process.sub) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!list.includes(p.meta)) {\n\t\t\t\tlist.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction findDepPidsBat(list, processes) {\n\tfor (let process of processes) {\n\t\tfindDepPids(list, process);\n\t}\n}\n\nasync function addBuiltinProcesses(list, ids, getProcesses) {\n\tlet newPids = [];\n\tif (ids.length > 0) {\n\t\tlet processes = await getProcesses(ids);\n\t\tfor (let processData of processes) {\n\t\t\tlet process = JSON.parse(processData);\n\t\t\tlist.push(process);\n\t\t\tfindDepPids(newPids, process);\n\t\t}\n\t\t//console.log('processes:', data.processes);\n\t}\n\treturn newPids;\n}\n\nasync function pageTemplate(data, options, version) {\n\tconst {tpl,} = data.options;\n\tlet newTpl = tpl;\n\tlet newOptions = Object.assign(data.options, {\n\t\tversion,\n\t});\n\tdelete newOptions.tpl;\n\tfor (let field of replaceFields) {\n\t\tconst key = camelcase(field);\n\t\tnewTpl = newTpl.replace(new RegExp(`\\\\$${field.toUpperCase()}\\\\$`, 'g'), newOptions[key]);\n\t}\n\treturn newTpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;AAMA,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;;AAEvC,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,cAA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CAAC,CAAC;GAC9B;;EAED;CACD,OAAO,OAAO,CAAC;CACf;;AAED,eAAe,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;CACnD,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;CAC5B,IAAI,MAAM,GAAG,GAAG,CAAC;CACjB,IAAI,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE;EAC5C,OAAO;EACP,CAAC,CAAC;CACH,OAAO,UAAU,CAAC,GAAG,CAAC;CACtB,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;EAChC,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;EAC7B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;EAC1F;CACD,OAAO,MAAM,CAAC;CACd;;AAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACrC,QAAQ,CAAC,IAAI,CAAC,CAAC;CACf,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;EAC9C,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;GACpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;GAClC;EACD;CACD;;;;"} {"version":3,"file":"index.js","sources":["../src/code-process.js","../src/ProcessManager.js","../src/ScriptManager.js","../src/CustomManager.js","../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-30.\n */\n\nimport babel from '@babel/core';\n\nconst UglifyJS = require('uglify-js');\n\nexport async function compile(source, debug = false) {\n\tconst {code, map} = await babel.transformAsync(source, {\n\t\tpresets: [\n\t\t\t['@babel/env', {}]\n\t\t],\n\t\tbabelrc: false,\n\t\tsourceMaps: debug,\n\t});\n\n\tconst result = {\n\t\tcode,\n\t};\n\tif (map) {\n\t\tresult.sourcemap = map.mappings;\n\t}\n\treturn result;\n}\n\nexport function uglify(source){\n\tconst uglifyResult = UglifyJS.minify(source, {\n\t});\n\tif (!uglifyResult.error) {\n\t\treturn uglifyResult.code;\n\t}\n}","/**\n * Created by rockyl on 2019-11-29.\n */\n\nimport crypto from 'crypto'\nimport {compile} from \"./code-process\";\n\nfunction md5(source) {\n\tconst hash = crypto.createHash('md5');\n\treturn hash.update(source).digest('hex');\n}\n\nexport default class ProcessManager {\n\tconstructor() {\n\t\tthis.pool = {};\n\t\tthis.scripts = '';\n\t}\n\n\tdeal(process) {\n\t\tlet hash = this.put(process.script);\n\t\tif (hash) {\n\t\t\tprocess.script = 'link://' + hash;\n\t\t}\n\t\tif (process.metas) {\n\t\t\tfor (let subProcess of process.metas) {\n\t\t\t\tlet hash = this.put(subProcess.script);\n\t\t\t\tif (hash) {\n\t\t\t\t\tsubProcess.script = 'link://' + hash;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tput(script) {\n\t\tif (script) {\n\t\t\tlet hash = md5(script);\n\t\t\tif (!this.pool.hasOwnProperty(hash)) {\n\t\t\t\tthis.pool[hash] = script;\n\t\t\t}\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tasync generateCurrent() {\n\t\tlet scripts = '';\n\t\tfor (let hash in this.pool) {\n\t\t\tlet code = this.pool[hash];\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${code}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\t\tthis.pool = {};\n\n\t\tconst {code ,sourcemap} = await compile(scripts, true);\n\t\tthis.scripts = code;\n\t}\n\n\tgenerate() {\n\t\tlet scripts = this.scripts;\n\t\tfor (let hash in this.pool) {\n\t\t\tlet code = this.pool[hash];\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${code}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\n\t\treturn `\n(function(){\nvar processScripts = {};\n(function(exports){\n${scripts}\n})(processScripts);\n\n\tengine.setScriptMap(processScripts);\n})();\n`\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-29.\n */\n\nexport default class ScriptManager {\n\tconstructor() {\n\t\tthis.pool = [];\n\t}\n\n\tdeal(script){\n\t\tthis.pool.push(script);\n\t}\n\n\tgenerate(){\n\t\tlet scripts = '';\n\t\tfor(let {id, code} of this.pool){\n\t\t\tscripts += `\n/*=====START ${id} START=====*/\n(function(exports){\n${code}\n})(exports);\n\tengine.registerScriptDef(exports.default.id, exports.default);\n/*=====END ${id} END=====*/`;\n\t\t}\n\n\t\treturn `\n(function(){\nvar exports = {};\n${scripts}\n})();\n`;\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-29.\n */\n\nexport default class CustomManager {\n\tconstructor() {\n\t\tthis.pool = [];\n\t}\n\n\tdeal(custom) {\n\t\tthis.pool.push(custom);\n\t}\n\n\tgenerate(){\n\t\tlet scripts = '';\n\t\tfor(let {id, code} of this.pool){\n\t\t\tscripts += `\n/*=====START ${id} START=====*/\nmodule = {\n\texports: {}\n};\n(function(module){\n${code}\n})(module);\nexports['${id}'] = module.exports;\n/*=====END ${id} END=====*/`;\n\t\t}\n\n\t\treturn `\n(function(){\nvar exports = {};\nvar module;\n\n${scripts}\n\n\tfor(var key in exports){\n\t\tengine.registerCustomModule(key, exports[key]);\n\t}\n})();\n`\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nimport decamelize from 'decamelize'\nimport ProcessManager from './ProcessManager'\nimport ScriptManager from './ScriptManager'\nimport CustomManager from './CustomManager'\nimport {uglify} from \"./code-process\";\n\nconst replaceFields = ['pageTitle', 'containerId'];\n\nexport async function pack(data, options) {\n\tlet version = Date.now() + Math.floor(Math.random() * 1000);\n\tpageTemplate(data, data.options, version);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t}\n}\n\nexport function fillTpl(data, params) {\n\tconst {options} = data;\n\tfillTemplate(options.newTpl, options, params);\n\n\treturn options.newTpl;\n}\n\nasync function packData(data, {debug, getProcesses, getScripts, getCustoms}) {\n\tconst processManager = new ProcessManager();\n\tconst scriptManager = new ScriptManager();\n\tconst customManager = new CustomManager();\n\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\t/*=====START process =====*/\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, data.processes);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\n\tlet bProcessIDs = processIDs;\n\twhile (true) {\n\t\tlet newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);\n\t\tbProcessIDs = [];\n\t\tfor (let id of newPids) {\n\t\t\tif (!processIDs.includes(id)) {\n\t\t\t\tbProcessIDs.push(id);\n\t\t\t\tprocessIDs.push(id);\n\t\t\t}\n\t\t}\n\t\tif (bProcessIDs.length === 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor (let process of data.processes) {\n\t\tprocessManager.deal(process);\n\t}\n\tawait processManager.generateCurrent(); //自定义过程先编译\n\n\tfor (let process of builtinProcesses) {\n\t\tprocessManager.deal(process);\n\t}\n\n\tlet processScriptContent = processManager.generate();\n\t//console.log(processScriptContent);\n\tif (!debug) {\n\t\tprocessScriptContent = uglify(processScriptContent);\n\t}\n\t/*=====END process =====*/\n\n\t/*=====START script =====*/\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\t//let scriptsContainer = newData.scripts = {};\n\t//let scriptsCode = '';\n\tif (scriptIDs.length > 0) {\n\t\tconst scripts = await getScripts(scriptIDs);\n\t\tfor (let scriptData of scripts) {\n\t\t\tlet script = JSON.parse(scriptData);\n\t\t\t//scriptsContainer[id] = code;\n\t\t\tscriptManager.deal(script);\n\t\t}\n\t\t//console.log('scripts:', scriptsContainer);\n\t}\n\n\tlet scriptsContent = scriptManager.generate();\n\t//console.log(scriptsContent);\n\tif (!debug) {\n\t\tscriptsContent = uglify(scriptsContent);\n\t}\n\t/*=====END script =====*/\n\n\t/*=====START custom =====*/\n\t//newData.customs = [];\n\tif (data.customs && data.customs.length > 0) {\n\t\t/*newData.customs = */\n\t\t(await getCustoms(data.customs)).map(item => {\n\t\t\tcustomManager.deal(JSON.parse(item));\n\t\t\t//return JSON.parse(item);\n\t\t})\n\t}\n\tlet customScriptContent = customManager.generate();\n\t//console.log(customScriptContent);\n\tif (!debug) {\n\t\tcustomScriptContent = uglify(customScriptContent);\n\t}\n\t/*=====END custom =====*/\n\n\treturn {\n\t\tdata: JSON.stringify(newData),\n\t\tprocessScriptContent,\n\t\tscriptsContent,\n\t\tcustomScriptContent,\n\t};\n}\n\nfunction findDepPids(list, process) {\n\tif (process.sub) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!list.includes(p.meta)) {\n\t\t\t\tlist.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction findDepPidsBat(list, processes) {\n\tfor (let process of processes) {\n\t\tfindDepPids(list, process);\n\t}\n}\n\nasync function addBuiltinProcesses(list, ids, getProcesses) {\n\tlet newPids = [];\n\tif (ids.length > 0) {\n\t\tlet processes = await getProcesses(ids);\n\t\tfor (let processData of processes) {\n\t\t\tlet process = JSON.parse(processData);\n\t\t\tlist.push(process);\n\t\t\tfindDepPids(newPids, process);\n\t\t}\n\t\t//console.log('processes:', data.processes);\n\t}\n\treturn newPids;\n}\n\nfunction pageTemplate(tpl, options, version) {\n\tconst params = {\n\t\tversion,\n\t};\n\tfor (let field of replaceFields) {\n\t\tparams[field] = options[field];\n\t}\n\tfillTemplate(options.tpl, options, params);\n}\n\nfunction fillTemplate(tpl, options, params) {\n\tfor (let field in params) {\n\t\tconst pattern = decamelize(field).toUpperCase();\n\t\ttpl = tpl.replace(new RegExp(`\\\\$${pattern}\\\\$`, 'g'), params[field]);\n\t}\n\n\toptions.newTpl = tpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;AAGA,AAEA;AACA,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;;AAEtC,AAAO,eAAe,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE;CACpD,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE;EACtD,OAAO,EAAE;GACR,CAAC,YAAY,EAAE,EAAE,CAAC;GAClB;EACD,OAAO,EAAE,KAAK;EACd,UAAU,EAAE,KAAK;EACjB,CAAC,CAAC;;CAEH,MAAM,MAAM,GAAG;EACd,IAAI;EACJ,CAAC;CACF,IAAI,GAAG,EAAE;EACR,MAAM,CAAC,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC;EAChC;CACD,OAAO,MAAM,CAAC;CACd;;AAED,AAAO,SAAS,MAAM,CAAC,MAAM,CAAC;CAC7B,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;EAC5C,C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I,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;EAC9C,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;GACpC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;GAClC;EACD;CACD;;;;;"}
\ No newline at end of file \ No newline at end of file
(function (global, factory) { (function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('decamelize'), require('crypto'), require('@babel/core')) :
typeof define === 'function' && define.amd ? define(['exports'], factory) : typeof define === 'function' && define.amd ? define(['exports', 'decamelize', 'crypto', '@babel/core'], factory) :
(global = global || self, factory(global['zeroing-pack'] = {})); (global = global || self, factory(global['zeroing-pack'] = {}, global.decamelize, global.crypto, global.babel));
}(this, function (exports) { 'use strict'; }(this, function (exports, decamelize, crypto, babel) { 'use strict';
decamelize = decamelize && decamelize.hasOwnProperty('default') ? decamelize['default'] : decamelize;
crypto = crypto && crypto.hasOwnProperty('default') ? crypto['default'] : crypto;
babel = babel && babel.hasOwnProperty('default') ? babel['default'] : babel;
/**
* Created by rockyl on 2019-11-30.
*/
const UglifyJS = require('uglify-js');
async function compile(source, debug = false) {
const {code, map} = await babel.transformAsync(source, {
presets: [
['@babel/env', {}]
],
babelrc: false,
sourceMaps: debug,
});
const result = {
code,
};
if (map) {
result.sourcemap = map.mappings;
}
return result;
}
function uglify(source){
const uglifyResult = UglifyJS.minify(source, {
});
if (!uglifyResult.error) {
return uglifyResult.code;
}
}
/**
* Created by rockyl on 2019-11-29.
*/
function md5(source) {
const hash = crypto.createHash('md5');
return hash.update(source).digest('hex');
}
class ProcessManager {
constructor() {
this.pool = {};
this.scripts = '';
}
deal(process) {
let hash = this.put(process.script);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess.script);
if (hash) {
subProcess.script = 'link://' + hash;
}
}
}
}
put(script) {
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = script;
}
return hash;
}
}
async generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
this.pool = {};
const {code ,sourcemap} = await compile(scripts, true);
this.scripts = code;
}
generate() {
let scripts = this.scripts;
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
return `
(function(){
var processScripts = {};
(function(exports){
${scripts}
})(processScripts);
engine.setScriptMap(processScripts);
})();
`
}
}
/**
* Created by rockyl on 2019-11-29.
*/
class ScriptManager {
constructor() {
this.pool = [];
}
deal(script){
this.pool.push(script);
}
generate(){
let scripts = '';
for(let {id, code} of this.pool){
scripts += `
/*=====START ${id} START=====*/
(function(exports){
${code}
})(exports);
engine.registerScriptDef(exports.default.id, exports.default);
/*=====END ${id} END=====*/`;
}
return `
(function(){
var exports = {};
${scripts}
})();
`;
}
}
/**
* Created by rockyl on 2019-11-29.
*/
class CustomManager {
constructor() {
this.pool = [];
}
deal(custom) {
this.pool.push(custom);
}
generate(){
let scripts = '';
for(let {id, code} of this.pool){
scripts += `
/*=====START ${id} START=====*/
module = {
exports: {}
};
(function(module){
${code}
})(module);
exports['${id}'] = module.exports;
/*=====END ${id} END=====*/`;
}
return `
(function(){
var exports = {};
var module;
${scripts}
for(var key in exports){
engine.registerCustomModule(key, exports[key]);
}
})();
`
}
}
/** /**
* Created by rockyl on 2019-11-13. * Created by rockyl on 2019-11-13.
...@@ -10,24 +213,31 @@ ...@@ -10,24 +213,31 @@
* 项目打包 * 项目打包
*/ */
const camelcase = require('camelcase'); const replaceFields = ['pageTitle', 'containerId'];
const replaceFields = ['page_title', 'container_id', 'version'];
async function pack(project, options) { async function pack(data, options) {
let version = Date.now() + Math.floor(Math.random() * 1000); let version = Date.now() + Math.floor(Math.random() * 1000);
let data = JSON.parse(project.data); pageTemplate(data, data.options, version);
const newTpl = await pageTemplate(data, options, version);
const newData = await packData(data, options); const newData = await packData(data, options);
return { return {
version, version,
data: newData, data: newData,
tpl: newTpl,
} }
} }
async function packData(data, {getProcesses, getScripts, getCustoms}) { function fillTpl(data, params) {
const {options} = data;
fillTemplate(options.newTpl, options, params);
return options.newTpl;
}
async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
let newData = {}; let newData = {};
newData.options = data.options; newData.options = data.options;
delete newData.options.tpl; delete newData.options.tpl;
...@@ -36,6 +246,43 @@ ...@@ -36,6 +246,43 @@
newData.dataMapping = data.dataMapping; newData.dataMapping = data.dataMapping;
newData.processes = data.processes; newData.processes = data.processes;
/*=====START process =====*/
let processIDs = [];
findDepPidsBat(processIDs, data.processes);
let builtinProcesses = newData.builtinProcesses = [];
let bProcessIDs = processIDs;
while (true) {
let newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);
bProcessIDs = [];
for (let id of newPids) {
if (!processIDs.includes(id)) {
bProcessIDs.push(id);
processIDs.push(id);
}
}
if (bProcessIDs.length === 0) {
break;
}
}
for (let process of data.processes) {
processManager.deal(process);
}
await processManager.generateCurrent(); //自定义过程先编译
for (let process of builtinProcesses) {
processManager.deal(process);
}
let processScriptContent = processManager.generate();
//console.log(processScriptContent);
if (!debug) {
processScriptContent = uglify(processScriptContent);
}
/*=====END process =====*/
/*=====START script =====*/
let scriptIDs = []; let scriptIDs = [];
for (let view of newData.views) { for (let view of newData.views) {
traverseNode(view, (node) => { traverseNode(view, (node) => {
...@@ -49,44 +296,47 @@ ...@@ -49,44 +296,47 @@
}); });
} }
//console.log('scriptIDs:', scriptIDs); //console.log('scriptIDs:', scriptIDs);
let scriptsContainer = newData.scripts = {}; //let scriptsContainer = newData.scripts = {};
//let scriptsCode = '';
if (scriptIDs.length > 0) { if (scriptIDs.length > 0) {
const scripts = await getScripts(scriptIDs); const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) { for (let scriptData of scripts) {
let {id, code} = JSON.parse(scriptData); let script = JSON.parse(scriptData);
scriptsContainer[id] = code; //scriptsContainer[id] = code;
scriptManager.deal(script);
} }
//console.log('scripts:', scriptsContainer); //console.log('scripts:', scriptsContainer);
} }
let processIDs = []; let scriptsContent = scriptManager.generate();
findDepPidsBat(processIDs, newData.processes); //console.log(scriptsContent);
//console.log('processIDs:', processIDs); if (!debug) {
let builtinProcesses = newData.builtinProcesses = []; scriptsContent = uglify(scriptsContent);
let bProcessIDs = processIDs;
while (true) {
let newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);
bProcessIDs = [];
for (let id of newPids) {
if (!processIDs.includes(id)) {
bProcessIDs.push(id);
processIDs.push(id);
}
}
if (bProcessIDs.length === 0) {
break;
}
} }
/*=====END script =====*/
newData.customs = []; /*=====START custom =====*/
//newData.customs = [];
if (data.customs && data.customs.length > 0) { if (data.customs && data.customs.length > 0) {
newData.customs = (await getCustoms(data.customs)).map(item => { /*newData.customs = */
return JSON.parse(item); (await getCustoms(data.customs)).map(item => {
customManager.deal(JSON.parse(item));
//return JSON.parse(item);
}); });
} }
let customScriptContent = customManager.generate();
//console.log(customScriptContent);
if (!debug) {
customScriptContent = uglify(customScriptContent);
}
/*=====END custom =====*/
return JSON.stringify(newData); return {
data: JSON.stringify(newData),
processScriptContent,
scriptsContent,
customScriptContent,
};
} }
function findDepPids(list, process) { function findDepPids(list, process) {
...@@ -120,18 +370,23 @@ ...@@ -120,18 +370,23 @@
return newPids; return newPids;
} }
async function pageTemplate(data, options, version) { function pageTemplate(tpl, options, version) {
const {tpl,} = data.options; const params = {
let newTpl = tpl;
let newOptions = Object.assign(data.options, {
version, version,
}); };
delete newOptions.tpl;
for (let field of replaceFields) { for (let field of replaceFields) {
const key = camelcase(field); params[field] = options[field];
newTpl = newTpl.replace(new RegExp(`\\$${field.toUpperCase()}\\$`, 'g'), newOptions[key]); }
fillTemplate(options.tpl, options, params);
} }
return newTpl;
function fillTemplate(tpl, options, params) {
for (let field in params) {
const pattern = decamelize(field).toUpperCase();
tpl = tpl.replace(new RegExp(`\\$${pattern}\\$`, 'g'), params[field]);
}
options.newTpl = tpl;
} }
function traverseNode(root, callback) { function traverseNode(root, callback) {
...@@ -143,6 +398,7 @@ ...@@ -143,6 +398,7 @@
} }
} }
exports.fillTpl = fillTpl;
exports.pack = pack; exports.pack = pack;
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
......
{"version":3,"file":"index.umd.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nconst camelcase = require('camelcase');\n\nconst replaceFields = ['page_title', 'container_id', 'version'];\n\nexport async function pack(project, options) {\n\tlet version = Date.now() + Math.floor(Math.random() * 1000);\n\tlet data = JSON.parse(project.data);\n\tconst newTpl = await pageTemplate(data, options, version);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t\ttpl: newTpl,\n\t}\n}\n\nasync function packData(data, {getProcesses, getScripts, getCustoms}) {\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\tlet scriptsContainer = newData.scripts = {};\n\tif (scriptIDs.length > 0) {\n\t\tconst scripts = await getScripts(scriptIDs);\n\t\tfor (let scriptData of scripts) {\n\t\t\tlet {id, code} = JSON.parse(scriptData);\n\t\t\tscriptsContainer[id] = code;\n\t\t}\n\t\t//console.log('scripts:', scriptsContainer);\n\t}\n\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, newData.processes);\n\t//console.log('processIDs:', processIDs);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\n\tlet bProcessIDs = processIDs;\n\twhile (true) {\n\t\tlet newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);\n\t\tbProcessIDs = [];\n\t\tfor (let id of newPids) {\n\t\t\tif (!processIDs.includes(id)) {\n\t\t\t\tbProcessIDs.push(id);\n\t\t\t\tprocessIDs.push(id);\n\t\t\t}\n\t\t}\n\t\tif (bProcessIDs.length === 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tnewData.customs = [];\n\tif (data.customs && data.customs.length > 0) {\n\t\tnewData.customs = (await getCustoms(data.customs)).map(item => {\n\t\t\treturn JSON.parse(item);\n\t\t})\n\t}\n\n\treturn JSON.stringify(newData);\n}\n\nfunction findDepPids(list, process) {\n\tif (process.sub) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!list.includes(p.meta)) {\n\t\t\t\tlist.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction findDepPidsBat(list, processes) {\n\tfor (let process of processes) {\n\t\tfindDepPids(list, process);\n\t}\n}\n\nasync function addBuiltinProcesses(list, ids, getProcesses) {\n\tlet newPids = [];\n\tif (ids.length > 0) {\n\t\tlet processes = await getProcesses(ids);\n\t\tfor (let processData of processes) {\n\t\t\tlet process = JSON.parse(processData);\n\t\t\tlist.push(process);\n\t\t\tfindDepPids(newPids, process);\n\t\t}\n\t\t//console.log('processes:', data.processes);\n\t}\n\treturn newPids;\n}\n\nasync function pageTemplate(data, options, version) {\n\tconst {tpl,} = data.options;\n\tlet newTpl = tpl;\n\tlet newOptions = Object.assign(data.options, {\n\t\tversion,\n\t});\n\tdelete newOptions.tpl;\n\tfor (let field of replaceFields) {\n\t\tconst key = camelcase(field);\n\t\tnewTpl = newTpl.replace(new RegExp(`\\\\$${field.toUpperCase()}\\\\$`, 'g'), newOptions[key]);\n\t}\n\treturn newTpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;CAAA;CACA;CACA;CACA;CACA;;CAEA,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;;CAEvC,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;;AAEhE,CAAO,eAAe,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE;CAC7C,CAAC,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;CAC7D,CAAC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,CAAC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;CAC3D,CAAC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;CAE/C,CAAC,OAAO;CACR,EAAE,OAAO;CACT,EAAE,IAAI,EAAE,OAAO;CACf,EAAE,GAAG,EAAE,MAAM;CACb,EAAE;CACF,CAAC;;CAED,eAAe,QAAQ,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE;CACtE,CAAC,IAAI,OAAO,GAAG,EAAE,CAAC;C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AC7B,CAAC,IAAI,MAAM,GAAG,GAAG,CAAC;CAClB,CAAC,IAAI,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE;CAC9C,EAAE,OAAO;CACT,EAAE,CAAC,CAAC;CACJ,CAAC,OAAO,UAAU,CAAC,GAAG,CAAC;CACvB,CAAC,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;CAClC,EAAE,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;CAC/B,EAAE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;CAC5F,EAAE;CACF,CAAC,OAAO,MAAM,CAAC;CACf,CAAC;;CAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACtC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;CAChB,CAAC,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;CAChD,EAAE,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;CACvC,GAAG,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;CACrC,GAAG;CACH,EAAE;CACF,CAAC;;;;;;;;;;;;"} {"version":3,"file":"index.umd.js","sources":["../src/code-process.js","../src/ProcessManager.js","../src/ScriptManager.js","../src/CustomManager.js","../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-30.\n */\n\nimport babel from '@babel/core';\n\nconst UglifyJS = require('uglify-js');\n\nexport async function compile(source, debug = false) {\n\tconst {code, map} = await babel.transformAsync(source, {\n\t\tpresets: [\n\t\t\t['@babel/env', {}]\n\t\t],\n\t\tbabelrc: false,\n\t\tsourceMaps: debug,\n\t});\n\n\tconst result = {\n\t\tcode,\n\t};\n\tif (map) {\n\t\tresult.sourcemap = map.mappings;\n\t}\n\treturn result;\n}\n\nexport function uglify(source){\n\tconst uglifyResult = UglifyJS.minify(source, {\n\t});\n\tif (!uglifyResult.error) {\n\t\treturn uglifyResult.code;\n\t}\n}","/**\n * Created by rockyl on 2019-11-29.\n */\n\nimport crypto from 'crypto'\nimport {compile} from \"./code-process\";\n\nfunction md5(source) {\n\tconst hash = crypto.createHash('md5');\n\treturn hash.update(source).digest('hex');\n}\n\nexport default class ProcessManager {\n\tconstructor() {\n\t\tthis.pool = {};\n\t\tthis.scripts = '';\n\t}\n\n\tdeal(process) {\n\t\tlet hash = this.put(process.script);\n\t\tif (hash) {\n\t\t\tprocess.script = 'link://' + hash;\n\t\t}\n\t\tif (process.metas) {\n\t\t\tfor (let subProcess of process.metas) {\n\t\t\t\tlet hash = this.put(subProcess.script);\n\t\t\t\tif (hash) {\n\t\t\t\t\tsubProcess.script = 'link://' + hash;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tput(script) {\n\t\tif (script) {\n\t\t\tlet hash = md5(script);\n\t\t\tif (!this.pool.hasOwnProperty(hash)) {\n\t\t\t\tthis.pool[hash] = script;\n\t\t\t}\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tasync generateCurrent() {\n\t\tlet scripts = '';\n\t\tfor (let hash in this.pool) {\n\t\t\tlet code = this.pool[hash];\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${code}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\t\tthis.pool = {};\n\n\t\tconst {code ,sourcemap} = await compile(scripts, true);\n\t\tthis.scripts = code;\n\t}\n\n\tgenerate() {\n\t\tlet scripts = this.scripts;\n\t\tfor (let hash in this.pool) {\n\t\t\tlet code = this.pool[hash];\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${code}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\n\t\treturn `\n(function(){\nvar processScripts = {};\n(function(exports){\n${scripts}\n})(processScripts);\n\n\tengine.setScriptMap(processScripts);\n})();\n`\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-29.\n */\n\nexport default class ScriptManager {\n\tconstructor() {\n\t\tthis.pool = [];\n\t}\n\n\tdeal(script){\n\t\tthis.pool.push(script);\n\t}\n\n\tgenerate(){\n\t\tlet scripts = '';\n\t\tfor(let {id, code} of this.pool){\n\t\t\tscripts += `\n/*=====START ${id} START=====*/\n(function(exports){\n${code}\n})(exports);\n\tengine.registerScriptDef(exports.default.id, exports.default);\n/*=====END ${id} END=====*/`;\n\t\t}\n\n\t\treturn `\n(function(){\nvar exports = {};\n${scripts}\n})();\n`;\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-29.\n */\n\nexport default class CustomManager {\n\tconstructor() {\n\t\tthis.pool = [];\n\t}\n\n\tdeal(custom) {\n\t\tthis.pool.push(custom);\n\t}\n\n\tgenerate(){\n\t\tlet scripts = '';\n\t\tfor(let {id, code} of this.pool){\n\t\t\tscripts += `\n/*=====START ${id} START=====*/\nmodule = {\n\texports: {}\n};\n(function(module){\n${code}\n})(module);\nexports['${id}'] = module.exports;\n/*=====END ${id} END=====*/`;\n\t\t}\n\n\t\treturn `\n(function(){\nvar exports = {};\nvar module;\n\n${scripts}\n\n\tfor(var key in exports){\n\t\tengine.registerCustomModule(key, exports[key]);\n\t}\n})();\n`\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-13.\n *\n * 项目打包\n */\n\nimport decamelize from 'decamelize'\nimport ProcessManager from './ProcessManager'\nimport ScriptManager from './ScriptManager'\nimport CustomManager from './CustomManager'\nimport {uglify} from \"./code-process\";\n\nconst replaceFields = ['pageTitle', 'containerId'];\n\nexport async function pack(data, options) {\n\tlet version = Date.now() + Math.floor(Math.random() * 1000);\n\tpageTemplate(data, data.options, version);\n\tconst newData = await packData(data, options);\n\n\treturn {\n\t\tversion,\n\t\tdata: newData,\n\t}\n}\n\nexport function fillTpl(data, params) {\n\tconst {options} = data;\n\tfillTemplate(options.newTpl, options, params);\n\n\treturn options.newTpl;\n}\n\nasync function packData(data, {debug, getProcesses, getScripts, getCustoms}) {\n\tconst processManager = new ProcessManager();\n\tconst scriptManager = new ScriptManager();\n\tconst customManager = new CustomManager();\n\n\tlet newData = {};\n\tnewData.options = data.options;\n\tdelete newData.options.tpl;\n\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\t/*=====START process =====*/\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, data.processes);\n\tlet builtinProcesses = newData.builtinProcesses = [];\n\n\tlet bProcessIDs = processIDs;\n\twhile (true) {\n\t\tlet newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);\n\t\tbProcessIDs = [];\n\t\tfor (let id of newPids) {\n\t\t\tif (!processIDs.includes(id)) {\n\t\t\t\tbProcessIDs.push(id);\n\t\t\t\tprocessIDs.push(id);\n\t\t\t}\n\t\t}\n\t\tif (bProcessIDs.length === 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor (let process of data.processes) {\n\t\tprocessManager.deal(process);\n\t}\n\tawait processManager.generateCurrent(); //自定义过程先编译\n\n\tfor (let process of builtinProcesses) {\n\t\tprocessManager.deal(process);\n\t}\n\n\tlet processScriptContent = processManager.generate();\n\t//console.log(processScriptContent);\n\tif (!debug) {\n\t\tprocessScriptContent = uglify(processScriptContent);\n\t}\n\t/*=====END process =====*/\n\n\t/*=====START script =====*/\n\tlet scriptIDs = [];\n\tfor (let view of newData.views) {\n\t\ttraverseNode(view, (node) => {\n\t\t\tif (node.scripts && node.scripts.length > 0) {\n\t\t\t\tfor (let {script} of node.scripts) {\n\t\t\t\t\tif (!scriptIDs.includes(script)) {\n\t\t\t\t\t\tscriptIDs.push(script);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t//console.log('scriptIDs:', scriptIDs);\n\t//let scriptsContainer = newData.scripts = {};\n\t//let scriptsCode = '';\n\tif (scriptIDs.length > 0) {\n\t\tconst scripts = await getScripts(scriptIDs);\n\t\tfor (let scriptData of scripts) {\n\t\t\tlet script = JSON.parse(scriptData);\n\t\t\t//scriptsContainer[id] = code;\n\t\t\tscriptManager.deal(script);\n\t\t}\n\t\t//console.log('scripts:', scriptsContainer);\n\t}\n\n\tlet scriptsContent = scriptManager.generate();\n\t//console.log(scriptsContent);\n\tif (!debug) {\n\t\tscriptsContent = uglify(scriptsContent);\n\t}\n\t/*=====END script =====*/\n\n\t/*=====START custom =====*/\n\t//newData.customs = [];\n\tif (data.customs && data.customs.length > 0) {\n\t\t/*newData.customs = */\n\t\t(await getCustoms(data.customs)).map(item => {\n\t\t\tcustomManager.deal(JSON.parse(item));\n\t\t\t//return JSON.parse(item);\n\t\t})\n\t}\n\tlet customScriptContent = customManager.generate();\n\t//console.log(customScriptContent);\n\tif (!debug) {\n\t\tcustomScriptContent = uglify(customScriptContent);\n\t}\n\t/*=====END custom =====*/\n\n\treturn {\n\t\tdata: JSON.stringify(newData),\n\t\tprocessScriptContent,\n\t\tscriptsContent,\n\t\tcustomScriptContent,\n\t};\n}\n\nfunction findDepPids(list, process) {\n\tif (process.sub) {\n\t\tfor (let key in process.sub) {\n\t\t\tlet p = process.sub[key];\n\t\t\tif (!list.includes(p.meta)) {\n\t\t\t\tlist.push(p.meta);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction findDepPidsBat(list, processes) {\n\tfor (let process of processes) {\n\t\tfindDepPids(list, process);\n\t}\n}\n\nasync function addBuiltinProcesses(list, ids, getProcesses) {\n\tlet newPids = [];\n\tif (ids.length > 0) {\n\t\tlet processes = await getProcesses(ids);\n\t\tfor (let processData of processes) {\n\t\t\tlet process = JSON.parse(processData);\n\t\t\tlist.push(process);\n\t\t\tfindDepPids(newPids, process);\n\t\t}\n\t\t//console.log('processes:', data.processes);\n\t}\n\treturn newPids;\n}\n\nfunction pageTemplate(tpl, options, version) {\n\tconst params = {\n\t\tversion,\n\t};\n\tfor (let field of replaceFields) {\n\t\tparams[field] = options[field];\n\t}\n\tfillTemplate(options.tpl, options, params);\n}\n\nfunction fillTemplate(tpl, options, params) {\n\tfor (let field in params) {\n\t\tconst pattern = decamelize(field).toUpperCase();\n\t\ttpl = tpl.replace(new RegExp(`\\\\$${pattern}\\\\$`, 'g'), params[field]);\n\t}\n\n\toptions.newTpl = tpl;\n}\n\nfunction traverseNode(root, callback) {\n\tcallback(root);\n\tif (root.children && root.children.length > 0) {\n\t\tfor (let childNode of root.children) {\n\t\t\ttraverseNode(childNode, callback);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;CAAA;CACA;CACA;AACA,AAEA;CACA,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;;AAEtC,CAAO,eAAe,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE;CACrD,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE;CACxD,EAAE,OAAO,EAAE;CACX,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC;CACrB,GAAG;CACH,EAAE,OAAO,EAAE,KAAK;CAChB,EAAE,UAAU,EAAE,KAAK;CACnB,EAAE,CAAC,CAAC;;CAEJ,CAAC,MAAM,MAAM,GAAG;CAChB,EAAE,IAAI;CACN,EAAE,CAAC;CACH,CAAC,IAAI,GAAG,EAAE;CACV,EAAE,MAAM,CAAC,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC;CAClC,EAAE;CACF,CAAC,OAAO,MAAM,CAAC;CACf,CAAC;;AAED,CAAO,SAAS,MAAM,CAAC,MAAM,CAAC;CAC9B,CAAC,MAAM,YAAY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AAC,CAAC,CAAC;CACxE,EAAE;;CAEF,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC;CACtB,CAAC;;CAED,SAAS,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE;CACtC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;CAChB,CAAC,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;CAChD,EAAE,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;CACvC,GAAG,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;CACrC,GAAG;CACH,EAAE;CACF,CAAC;;;;;;;;;;;;;"}
\ No newline at end of file \ No newline at end of file
{
"systemParams": "darwin-x64-67",
"modulesFolders": [
"node_modules"
],
"flags": [],
"linkedModules": [
"game-cli",
"qunity-core",
"scilla",
"scilla-declare-generator",
"scilla-launcher",
"scilla-ts-compiler"
],
"topLevelPatterns": [
"camelcase@^5.3.1"
],
"lockfileEntries": {
"camelcase@^5.3.1": "https://registry.npm.taobao.org/camelcase/download/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
},
"files": [],
"artifacts": {}
}
\ No newline at end of file
declare namespace camelcase {
interface Options {
/**
Uppercase the first character: `foo-bar` → `FooBar`.
@default false
*/
readonly pascalCase?: boolean;
}
}
declare const camelcase: {
/**
Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`.
@param input - String to convert to camel case.
@example
```
import camelCase = require('camelcase');
camelCase('foo-bar');
//=> 'fooBar'
camelCase('foo_bar');
//=> 'fooBar'
camelCase('Foo-Bar');
//=> 'fooBar'
camelCase('Foo-Bar', {pascalCase: true});
//=> 'FooBar'
camelCase('--foo.bar', {pascalCase: false});
//=> 'fooBar'
camelCase('foo bar');
//=> 'fooBar'
console.log(process.argv[3]);
//=> '--foo-bar'
camelCase(process.argv[3]);
//=> 'fooBar'
camelCase(['foo', 'bar']);
//=> 'fooBar'
camelCase(['__foo__', '--bar'], {pascalCase: true});
//=> 'FooBar'
```
*/
(input: string | ReadonlyArray<string>, options?: camelcase.Options): string;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function camelcase(
// input: string | ReadonlyArray<string>,
// options?: camelcase.Options
// ): string;
// export = camelcase;
default: typeof camelcase;
};
export = camelcase;
'use strict';
const preserveCamelCase = string => {
let isLastCharLower = false;
let isLastCharUpper = false;
let isLastLastCharUpper = false;
for (let i = 0; i < string.length; i++) {
const character = string[i];
if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) {
string = string.slice(0, i) + '-' + string.slice(i);
isLastCharLower = false;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = true;
i++;
} else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(character) && character.toLowerCase() === character) {
string = string.slice(0, i - 1) + '-' + string.slice(i - 1);
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = false;
isLastCharLower = true;
} else {
isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
}
}
return string;
};
const camelCase = (input, options) => {
if (!(typeof input === 'string' || Array.isArray(input))) {
throw new TypeError('Expected the input to be `string | string[]`');
}
options = Object.assign({
pascalCase: false
}, options);
const postProcess = x => options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x;
if (Array.isArray(input)) {
input = input.map(x => x.trim())
.filter(x => x.length)
.join('-');
} else {
input = input.trim();
}
if (input.length === 0) {
return '';
}
if (input.length === 1) {
return options.pascalCase ? input.toUpperCase() : input.toLowerCase();
}
const hasUpperCase = input !== input.toLowerCase();
if (hasUpperCase) {
input = preserveCamelCase(input);
}
input = input
.replace(/^[_.\- ]+/, '')
.toLowerCase()
.replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase())
.replace(/\d+(\w|$)/g, m => m.toUpperCase());
return postProcess(input);
};
module.exports = camelCase;
// TODO: Remove this for the next major release
module.exports.default = camelCase;
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"name": "camelcase",
"version": "5.3.1",
"description": "Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`",
"license": "MIT",
"repository": "sindresorhus/camelcase",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"camelcase",
"camel-case",
"camel",
"case",
"dash",
"hyphen",
"dot",
"underscore",
"separator",
"string",
"text",
"convert",
"pascalcase",
"pascal-case"
],
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.1",
"xo": "^0.24.0"
}
}
# camelcase [![Build Status](https://travis-ci.org/sindresorhus/camelcase.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase)
> Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-camelcase?utm_source=npm-camelcase&utm_medium=referral&utm_campaign=readme">Get professional support for 'camelcase' with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
---
## Install
```
$ npm install camelcase
```
## Usage
```js
const camelCase = require('camelcase');
camelCase('foo-bar');
//=> 'fooBar'
camelCase('foo_bar');
//=> 'fooBar'
camelCase('Foo-Bar');
//=> 'fooBar'
camelCase('Foo-Bar', {pascalCase: true});
//=> 'FooBar'
camelCase('--foo.bar', {pascalCase: false});
//=> 'fooBar'
camelCase('foo bar');
//=> 'fooBar'
console.log(process.argv[3]);
//=> '--foo-bar'
camelCase(process.argv[3]);
//=> 'fooBar'
camelCase(['foo', 'bar']);
//=> 'fooBar'
camelCase(['__foo__', '--bar'], {pascalCase: true});
//=> 'FooBar'
```
## API
### camelCase(input, [options])
#### input
Type: `string` `string[]`
String to convert to camel case.
#### options
Type: `Object`
##### pascalCase
Type: `boolean`<br>
Default: `false`
Uppercase the first character: `foo-bar``FooBar`
## Security
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
## Related
- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
- [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string
- [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
"main": "dist/index.js", "main": "dist/index.js",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"camelcase": "^5.3.1" "@babel/core": "^7.7.4",
"decamelize": "^3.2.0",
"uglify-js": "^3.7.1"
},
"scripts": {
"build": "rollup -c"
} }
} }
/**
* Created by rockyl on 2019-11-29.
*/
export default class CustomManager {
constructor() {
this.pool = [];
}
deal(custom) {
this.pool.push(custom);
}
generate(){
let scripts = '';
for(let {id, code} of this.pool){
scripts += `
/*=====START ${id} START=====*/
module = {
exports: {}
};
(function(module){
${code}
})(module);
exports['${id}'] = module.exports;
/*=====END ${id} END=====*/`;
}
return `
(function(){
var exports = {};
var module;
${scripts}
for(var key in exports){
engine.registerCustomModule(key, exports[key]);
}
})();
`
}
}
/**
* Created by rockyl on 2019-11-29.
*/
import crypto from 'crypto'
import {compile} from "./code-process";
function md5(source) {
const hash = crypto.createHash('md5');
return hash.update(source).digest('hex');
}
export default class ProcessManager {
constructor() {
this.pool = {};
this.scripts = '';
}
deal(process) {
let hash = this.put(process.script);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess.script);
if (hash) {
subProcess.script = 'link://' + hash;
}
}
}
}
put(script) {
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = script;
}
return hash;
}
}
async generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
this.pool = {};
const {code ,sourcemap} = await compile(scripts, true);
this.scripts = code;
}
generate() {
let scripts = this.scripts;
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
return `
(function(){
var processScripts = {};
(function(exports){
${scripts}
})(processScripts);
engine.setScriptMap(processScripts);
})();
`
}
}
/**
* Created by rockyl on 2019-11-29.
*/
export default class ScriptManager {
constructor() {
this.pool = [];
}
deal(script){
this.pool.push(script);
}
generate(){
let scripts = '';
for(let {id, code} of this.pool){
scripts += `
/*=====START ${id} START=====*/
(function(exports){
${code}
})(exports);
engine.registerScriptDef(exports.default.id, exports.default);
/*=====END ${id} END=====*/`;
}
return `
(function(){
var exports = {};
${scripts}
})();
`;
}
}
/**
* Created by rockyl on 2019-11-30.
*/
import babel from '@babel/core';
const UglifyJS = require('uglify-js');
export async function compile(source, debug = false) {
const {code, map} = await babel.transformAsync(source, {
presets: [
['@babel/env', {}]
],
babelrc: false,
sourceMaps: debug,
});
const result = {
code,
};
if (map) {
result.sourcemap = map.mappings;
}
return result;
}
export function uglify(source){
const uglifyResult = UglifyJS.minify(source, {
});
if (!uglifyResult.error) {
return uglifyResult.code;
}
}
\ No newline at end of file
...@@ -4,24 +4,37 @@ ...@@ -4,24 +4,37 @@
* 项目打包 * 项目打包
*/ */
const camelcase = require('camelcase'); import decamelize from 'decamelize'
import ProcessManager from './ProcessManager'
import ScriptManager from './ScriptManager'
import CustomManager from './CustomManager'
import {uglify} from "./code-process";
const replaceFields = ['page_title', 'container_id', 'version']; const replaceFields = ['pageTitle', 'containerId'];
export async function pack(project, options) { export async function pack(data, options) {
let version = Date.now() + Math.floor(Math.random() * 1000); let version = Date.now() + Math.floor(Math.random() * 1000);
let data = JSON.parse(project.data); pageTemplate(data, data.options, version);
const newTpl = await pageTemplate(data, options, version);
const newData = await packData(data, options); const newData = await packData(data, options);
return { return {
version, version,
data: newData, data: newData,
tpl: newTpl,
} }
} }
async function packData(data, {getProcesses, getScripts, getCustoms}) { export function fillTpl(data, params) {
const {options} = data;
fillTemplate(options.newTpl, options, params);
return options.newTpl;
}
async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
let newData = {}; let newData = {};
newData.options = data.options; newData.options = data.options;
delete newData.options.tpl; delete newData.options.tpl;
...@@ -30,6 +43,43 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) { ...@@ -30,6 +43,43 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) {
newData.dataMapping = data.dataMapping; newData.dataMapping = data.dataMapping;
newData.processes = data.processes; newData.processes = data.processes;
/*=====START process =====*/
let processIDs = [];
findDepPidsBat(processIDs, data.processes);
let builtinProcesses = newData.builtinProcesses = [];
let bProcessIDs = processIDs;
while (true) {
let newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);
bProcessIDs = [];
for (let id of newPids) {
if (!processIDs.includes(id)) {
bProcessIDs.push(id);
processIDs.push(id);
}
}
if (bProcessIDs.length === 0) {
break;
}
}
for (let process of data.processes) {
processManager.deal(process);
}
await processManager.generateCurrent(); //自定义过程先编译
for (let process of builtinProcesses) {
processManager.deal(process);
}
let processScriptContent = processManager.generate();
//console.log(processScriptContent);
if (!debug) {
processScriptContent = uglify(processScriptContent);
}
/*=====END process =====*/
/*=====START script =====*/
let scriptIDs = []; let scriptIDs = [];
for (let view of newData.views) { for (let view of newData.views) {
traverseNode(view, (node) => { traverseNode(view, (node) => {
...@@ -43,44 +93,47 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) { ...@@ -43,44 +93,47 @@ async function packData(data, {getProcesses, getScripts, getCustoms}) {
}); });
} }
//console.log('scriptIDs:', scriptIDs); //console.log('scriptIDs:', scriptIDs);
let scriptsContainer = newData.scripts = {}; //let scriptsContainer = newData.scripts = {};
//let scriptsCode = '';
if (scriptIDs.length > 0) { if (scriptIDs.length > 0) {
const scripts = await getScripts(scriptIDs); const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) { for (let scriptData of scripts) {
let {id, code} = JSON.parse(scriptData); let script = JSON.parse(scriptData);
scriptsContainer[id] = code; //scriptsContainer[id] = code;
scriptManager.deal(script);
} }
//console.log('scripts:', scriptsContainer); //console.log('scripts:', scriptsContainer);
} }
let processIDs = []; let scriptsContent = scriptManager.generate();
findDepPidsBat(processIDs, newData.processes); //console.log(scriptsContent);
//console.log('processIDs:', processIDs); if (!debug) {
let builtinProcesses = newData.builtinProcesses = []; scriptsContent = uglify(scriptsContent);
let bProcessIDs = processIDs;
while (true) {
let newPids = await addBuiltinProcesses(builtinProcesses, bProcessIDs, getProcesses);
bProcessIDs = [];
for (let id of newPids) {
if (!processIDs.includes(id)) {
bProcessIDs.push(id);
processIDs.push(id);
}
}
if (bProcessIDs.length === 0) {
break;
}
} }
/*=====END script =====*/
newData.customs = []; /*=====START custom =====*/
//newData.customs = [];
if (data.customs && data.customs.length > 0) { if (data.customs && data.customs.length > 0) {
newData.customs = (await getCustoms(data.customs)).map(item => { /*newData.customs = */
return JSON.parse(item); (await getCustoms(data.customs)).map(item => {
customManager.deal(JSON.parse(item));
//return JSON.parse(item);
}) })
} }
let customScriptContent = customManager.generate();
//console.log(customScriptContent);
if (!debug) {
customScriptContent = uglify(customScriptContent);
}
/*=====END custom =====*/
return JSON.stringify(newData); return {
data: JSON.stringify(newData),
processScriptContent,
scriptsContent,
customScriptContent,
};
} }
function findDepPids(list, process) { function findDepPids(list, process) {
...@@ -114,18 +167,23 @@ async function addBuiltinProcesses(list, ids, getProcesses) { ...@@ -114,18 +167,23 @@ async function addBuiltinProcesses(list, ids, getProcesses) {
return newPids; return newPids;
} }
async function pageTemplate(data, options, version) { function pageTemplate(tpl, options, version) {
const {tpl,} = data.options; const params = {
let newTpl = tpl;
let newOptions = Object.assign(data.options, {
version, version,
}); };
delete newOptions.tpl;
for (let field of replaceFields) { for (let field of replaceFields) {
const key = camelcase(field); params[field] = options[field];
newTpl = newTpl.replace(new RegExp(`\\$${field.toUpperCase()}\\$`, 'g'), newOptions[key]); }
fillTemplate(options.tpl, options, params);
}
function fillTemplate(tpl, options, params) {
for (let field in params) {
const pattern = decamelize(field).toUpperCase();
tpl = tpl.replace(new RegExp(`\\$${pattern}\\$`, 'g'), params[field]);
} }
return newTpl;
options.newTpl = tpl;
} }
function traverseNode(root, callback) { function traverseNode(root, callback) {
......
...@@ -2,7 +2,301 @@ ...@@ -2,7 +2,301 @@
# yarn lockfile v1 # yarn lockfile v1
camelcase@^5.3.1: "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5":
version "5.3.1" version "7.5.5"
resolved "https://registry.npm.taobao.org/camelcase/download/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" resolved "https://registry.npm.taobao.org/@babel/code-frame/download/@babel/code-frame-7.5.5.tgz#bc0782f6d69f7b7d49531219699b988f669a8f9d"
integrity sha1-48mzFWnhBoEd8kL3FXJaH0xJQyA= integrity sha1-vAeC9tafe31JUxIZaZuYj2aaj50=
dependencies:
"@babel/highlight" "^7.0.0"
"@babel/core@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/core/download/@babel/core-7.7.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fcore%2Fdownload%2F%40babel%2Fcore-7.7.4.tgz#37e864532200cb6b50ee9a4045f5f817840166ab"
integrity sha1-N+hkUyIAy2tQ7ppARfX4F4QBZqs=
dependencies:
"@babel/code-frame" "^7.5.5"
"@babel/generator" "^7.7.4"
"@babel/helpers" "^7.7.4"
"@babel/parser" "^7.7.4"
"@babel/template" "^7.7.4"
"@babel/traverse" "^7.7.4"
"@babel/types" "^7.7.4"
convert-source-map "^1.7.0"
debug "^4.1.0"
json5 "^2.1.0"
lodash "^4.17.13"
resolve "^1.3.2"
semver "^5.4.1"
source-map "^0.5.0"
"@babel/generator@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/generator/download/@babel/generator-7.7.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fgenerator%2Fdownload%2F%40babel%2Fgenerator-7.7.4.tgz#db651e2840ca9aa66f327dcec1dc5f5fa9611369"
integrity sha1-22UeKEDKmqZvMn3OwdxfX6lhE2k=
dependencies:
"@babel/types" "^7.7.4"
jsesc "^2.5.1"
lodash "^4.17.13"
source-map "^0.5.0"
"@babel/helper-function-name@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/helper-function-name/download/@babel/helper-function-name-7.7.4.tgz?cache=0&sync_timestamp=1574465949765&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelper-function-name%2Fdownload%2F%40babel%2Fhelper-function-name-7.7.4.tgz#ab6e041e7135d436d8f0a3eca15de5b67a341a2e"
integrity sha1-q24EHnE11DbY8KPsoV3ltno0Gi4=
dependencies:
"@babel/helper-get-function-arity" "^7.7.4"
"@babel/template" "^7.7.4"
"@babel/types" "^7.7.4"
"@babel/helper-get-function-arity@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/helper-get-function-arity/download/@babel/helper-get-function-arity-7.7.4.tgz#cb46348d2f8808e632f0ab048172130e636005f0"
integrity sha1-y0Y0jS+ICOYy8KsEgXITDmNgBfA=
dependencies:
"@babel/types" "^7.7.4"
"@babel/helper-split-export-declaration@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/helper-split-export-declaration/download/@babel/helper-split-export-declaration-7.7.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelper-split-export-declaration%2Fdownload%2F%40babel%2Fhelper-split-export-declaration-7.7.4.tgz#57292af60443c4a3622cf74040ddc28e68336fd8"
integrity sha1-Vykq9gRDxKNiLPdAQN3Cjmgzb9g=
dependencies:
"@babel/types" "^7.7.4"
"@babel/helpers@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/helpers/download/@babel/helpers-7.7.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelpers%2Fdownload%2F%40babel%2Fhelpers-7.7.4.tgz#62c215b9e6c712dadc15a9a0dcab76c92a940302"
integrity sha1-YsIVuebHEtrcFamg3Kt2ySqUAwI=
dependencies:
"@babel/template" "^7.7.4"
"@babel/traverse" "^7.7.4"
"@babel/types" "^7.7.4"
"@babel/highlight@^7.0.0":
version "7.5.0"
resolved "https://registry.npm.taobao.org/@babel/highlight/download/@babel/highlight-7.5.0.tgz#56d11312bd9248fa619591d02472be6e8cb32540"
integrity sha1-VtETEr2SSPphlZHQJHK+boyzJUA=
dependencies:
chalk "^2.0.0"
esutils "^2.0.2"
js-tokens "^4.0.0"
"@babel/parser@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/parser/download/@babel/parser-7.7.4.tgz#75ab2d7110c2cf2fa949959afb05fa346d2231bb"
integrity sha1-dastcRDCzy+pSZWa+wX6NG0iMbs=
"@babel/runtime-corejs2@^7.2.0":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/runtime-corejs2/download/@babel/runtime-corejs2-7.7.4.tgz#b9c2b1b5882762005785bc47740195a0ac780888"
integrity sha1-ucKxtYgnYgBXhbxHdAGVoKx4CIg=
dependencies:
core-js "^2.6.5"
regenerator-runtime "^0.13.2"
"@babel/template@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/template/download/@babel/template-7.7.4.tgz?cache=0&sync_timestamp=1574465948896&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Ftemplate%2Fdownload%2F%40babel%2Ftemplate-7.7.4.tgz#428a7d9eecffe27deac0a98e23bf8e3675d2a77b"
integrity sha1-Qop9nuz/4n3qwKmOI7+ONnXSp3s=
dependencies:
"@babel/code-frame" "^7.0.0"
"@babel/parser" "^7.7.4"
"@babel/types" "^7.7.4"
"@babel/traverse@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/traverse/download/@babel/traverse-7.7.4.tgz#9c1e7c60fb679fe4fcfaa42500833333c2058558"
integrity sha1-nB58YPtnn+T8+qQlAIMzM8IFhVg=
dependencies:
"@babel/code-frame" "^7.5.5"
"@babel/generator" "^7.7.4"
"@babel/helper-function-name" "^7.7.4"
"@babel/helper-split-export-declaration" "^7.7.4"
"@babel/parser" "^7.7.4"
"@babel/types" "^7.7.4"
debug "^4.1.0"
globals "^11.1.0"
lodash "^4.17.13"
"@babel/types@^7.7.4":
version "7.7.4"
resolved "https://registry.npm.taobao.org/@babel/types/download/@babel/types-7.7.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Ftypes%2Fdownload%2F%40babel%2Ftypes-7.7.4.tgz#516570d539e44ddf308c07569c258ff94fde9193"
integrity sha1-UWVw1TnkTd8wjAdWnCWP+U/ekZM=
dependencies:
esutils "^2.0.2"
lodash "^4.17.13"
to-fast-properties "^2.0.0"
ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-3.2.1.tgz?cache=0&sync_timestamp=1573557674483&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
integrity sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=
dependencies:
color-convert "^1.9.0"
chalk@^2.0.0:
version "2.4.2"
resolved "https://registry.npm.taobao.org/chalk/download/chalk-2.4.2.tgz?cache=0&sync_timestamp=1573282918610&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fchalk%2Fdownload%2Fchalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
integrity sha1-zUJUFnelQzPPVBpJEIwUMrRMlCQ=
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
color-convert@^1.9.0:
version "1.9.3"
resolved "https://registry.npm.taobao.org/color-convert/download/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
integrity sha1-u3GFBpDh8TZWfeYp0tVHHe2kweg=
dependencies:
color-name "1.1.3"
color-name@1.1.3:
version "1.1.3"
resolved "https://registry.npm.taobao.org/color-name/download/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
commander@~2.20.3:
version "2.20.3"
resolved "https://registry.npm.taobao.org/commander/download/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha1-/UhehMA+tIgcIHIrpIA16FMa6zM=
convert-source-map@^1.7.0:
version "1.7.0"
resolved "https://registry.npm.taobao.org/convert-source-map/download/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442"
integrity sha1-F6LLiC1/d9NJBYXizmxSRCSjpEI=
dependencies:
safe-buffer "~5.1.1"
core-js@^2.6.5:
version "2.6.10"
resolved "https://registry.npm.taobao.org/core-js/download/core-js-2.6.10.tgz?cache=0&sync_timestamp=1574892698770&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcore-js%2Fdownload%2Fcore-js-2.6.10.tgz#8a5b8391f8cc7013da703411ce5b585706300d7f"
integrity sha1-iluDkfjMcBPacDQRzltYVwYwDX8=
debug@^4.1.0:
version "4.1.1"
resolved "https://registry.npm.taobao.org/debug/download/debug-4.1.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
integrity sha1-O3ImAlUQnGtYnO4FDx1RYTlmR5E=
dependencies:
ms "^2.1.1"
decamelize@^3.2.0:
version "3.2.0"
resolved "https://registry.npm.taobao.org/decamelize/download/decamelize-3.2.0.tgz#84b8e8f4f8c579f938e35e2cc7024907e0090851"
integrity sha1-hLjo9PjFefk4414sxwJJB+AJCFE=
dependencies:
xregexp "^4.2.4"
escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
esutils@^2.0.2:
version "2.0.3"
resolved "https://registry.npm.taobao.org/esutils/download/esutils-2.0.3.tgz?cache=0&sync_timestamp=1564535492241&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fesutils%2Fdownload%2Fesutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
integrity sha1-dNLrTeC42hKTcRkQ1Qd1ubcQ72Q=
globals@^11.1.0:
version "11.12.0"
resolved "https://registry.npm.taobao.org/globals/download/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
integrity sha1-q4eVM4hooLq9hSV1gBjCp+uVxC4=
has-flag@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=
js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.npm.taobao.org/js-tokens/download/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha1-GSA/tZmR35jjoocFDUZHzerzJJk=
jsesc@^2.5.1:
version "2.5.2"
resolved "https://registry.npm.taobao.org/jsesc/download/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4"
integrity sha1-gFZNLkg9rPbo7yCWUKZ98/DCg6Q=
json5@^2.1.0:
version "2.1.1"
resolved "https://registry.npm.taobao.org/json5/download/json5-2.1.1.tgz#81b6cb04e9ba496f1c7005d07b4368a2638f90b6"
integrity sha1-gbbLBOm6SW8ccAXQe0NoomOPkLY=
dependencies:
minimist "^1.2.0"
lodash@^4.17.13:
version "4.17.15"
resolved "https://registry.npm.taobao.org/lodash/download/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha1-tEf2ZwoEVbv+7dETku/zMOoJdUg=
minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=
ms@^2.1.1:
version "2.1.2"
resolved "https://registry.npm.taobao.org/ms/download/ms-2.1.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fms%2Fdownload%2Fms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk=
path-parse@^1.0.6:
version "1.0.6"
resolved "https://registry.npm.taobao.org/path-parse/download/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
integrity sha1-1i27VnlAXXLEc37FhgDp3c8G0kw=
regenerator-runtime@^0.13.2:
version "0.13.3"
resolved "https://registry.npm.taobao.org/regenerator-runtime/download/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5"
integrity sha1-fPanfY9cb2Drc8X8GVWyzrAea/U=
resolve@^1.3.2:
version "1.13.1"
resolved "https://registry.npm.taobao.org/resolve/download/resolve-1.13.1.tgz?cache=0&sync_timestamp=1574809298542&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fresolve%2Fdownload%2Fresolve-1.13.1.tgz#be0aa4c06acd53083505abb35f4d66932ab35d16"
integrity sha1-vgqkwGrNUwg1BauzX01mkyqzXRY=
dependencies:
path-parse "^1.0.6"
safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
integrity sha1-mR7GnSluAxN0fVm9/St0XDX4go0=
semver@^5.4.1:
version "5.7.1"
resolved "https://registry.npm.taobao.org/semver/download/semver-5.7.1.tgz?cache=0&sync_timestamp=1565627367398&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsemver%2Fdownload%2Fsemver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha1-qVT5Ma66UI0we78Gnv8MAclhFvc=
source-map@^0.5.0:
version "0.5.7"
resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=
source-map@~0.6.1:
version "0.6.1"
resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha1-dHIq8y6WFOnCh6jQu95IteLxomM=
supports-color@^5.3.0:
version "5.5.0"
resolved "https://registry.npm.taobao.org/supports-color/download/supports-color-5.5.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsupports-color%2Fdownload%2Fsupports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
integrity sha1-4uaaRKyHcveKHsCzW2id9lMO/I8=
dependencies:
has-flag "^3.0.0"
to-fast-properties@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/to-fast-properties/download/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=
uglify-js@^3.7.1:
version "3.7.1"
resolved "https://registry.npm.taobao.org/uglify-js/download/uglify-js-3.7.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fuglify-js%2Fdownload%2Fuglify-js-3.7.1.tgz#35c7de17971a4aa7689cd2eae0a5b39bb838c0c5"
integrity sha1-NcfeF5caSqdonNLq4KWzm7g4wMU=
dependencies:
commander "~2.20.3"
source-map "~0.6.1"
xregexp@^4.2.4:
version "4.2.4"
resolved "https://registry.npm.taobao.org/xregexp/download/xregexp-4.2.4.tgz#02a4aea056d65a42632c02f0233eab8e4d7e57ed"
integrity sha1-AqSuoFbWWkJjLALwIz6rjk1+V+0=
dependencies:
"@babel/runtime-corejs2" "^7.2.0"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment