Commit 4e592f36 authored by rockyl's avatar rockyl

素材压缩

parent ea716a84
......@@ -230,7 +230,7 @@ function fillTpl(data, params) {
return newTpl;
}
async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
async function packData(data, {debug, packedAssets, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
......@@ -238,7 +238,7 @@ async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
let newData = {};
newData.options = data.options;
newData.views = data.views;
newData.assets = data.assets;
newData.assets = packedAssets || data.assets;
newData.dataMapping = data.dataMapping;
newData.processes = data.processes;
......
{"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);\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);\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(process) {\n\t\tconst {id, name, script} = process;\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] = {\n\t\t\t\t\tscript,\n\t\t\t\t\tids: [],\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.pool[hash].ids.push(name || id);\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tgenerateCurrent() {\n\t\tlet scripts = '';\n\t\tfor (let hash in this.pool) {\n\t\t\tlet {script, ids} = this.pool[hash];\n\t\t\tlet idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\\n');\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${idsComment}\n${script}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\t\tthis.scripts += scripts;\n\t\tthis.pool = {};\n\t}\n\n\tasync compile(){\n\t\ttry {\n\t\t\tconst {code ,sourcemap} = await compile(this.scripts, true);\n\t\t\tthis.scripts = code;\n\t\t}catch (e) {\n\t\t\tconsole.log('编译失败', e);\n\t\t}\n\t}\n\n\tgenerate() {\n\t\tthis.generateCurrent();\n\t\tlet scripts = this.scripts;\n\n\t\treturn `\n(function(){\nvar exports = {};\n${scripts}\n\n\tengine.setScriptMap(exports);\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'];\nconst TAG = 'zeroing-pack';\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\tconst newTpl = options.newTpl;\n\tdelete options.newTpl;\n\treturn 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\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tdelete newData.options.tpl;\n\tdeleteUnusedData(newData.processes);\n\n\tconsole.log(TAG, 'start');\n\n\t/*=====START process =====*/\n\tconsole.log(TAG, 'start process');\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, newData.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 newData.processes) {\n\t\tprocessManager.deal(process);\n\t}\n\n\tconsole.log(TAG, 'processManager.generateCurrent()');\n\n\tprocessManager.generateCurrent();\n\tawait processManager.compile(); //自定义过程先编译\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\tconsole.log(TAG, '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\tconsole.log(TAG, '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\nconst unusedFields = ['design'];\nfunction deleteUnusedData(processes){\n\tfor(let process of processes){\n\t\tif(process.sub){\n\t\t\tfor(let uuid in process.sub){\n\t\t\t\tlet subProcess = process.sub[uuid];\n\t\t\t\tfor(let field of unusedFields){\n\t\t\t\t\tif(subProcess.hasOwnProperty(field)){\n\t\t\t\t\t\tdelete subProcess[field];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(process.metas && process.metas.length > 0){\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\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}\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,YAA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,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
{"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);\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);\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(process) {\n\t\tconst {id, name, script} = process;\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] = {\n\t\t\t\t\tscript,\n\t\t\t\t\tids: [],\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.pool[hash].ids.push(name || id);\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tgenerateCurrent() {\n\t\tlet scripts = '';\n\t\tfor (let hash in this.pool) {\n\t\t\tlet {script, ids} = this.pool[hash];\n\t\t\tlet idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\\n');\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${idsComment}\n${script}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\t\tthis.scripts += scripts;\n\t\tthis.pool = {};\n\t}\n\n\tasync compile(){\n\t\ttry {\n\t\t\tconst {code ,sourcemap} = await compile(this.scripts, true);\n\t\t\tthis.scripts = code;\n\t\t}catch (e) {\n\t\t\tconsole.log('编译失败', e);\n\t\t}\n\t}\n\n\tgenerate() {\n\t\tthis.generateCurrent();\n\t\tlet scripts = this.scripts;\n\n\t\treturn `\n(function(){\nvar exports = {};\n${scripts}\n\n\tengine.setScriptMap(exports);\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'];\nconst TAG = 'zeroing-pack';\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\tconst newTpl = options.newTpl;\n\tdelete options.newTpl;\n\treturn newTpl;\n}\n\nasync function packData(data, {debug, packedAssets, 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\tnewData.views = data.views;\n\tnewData.assets = packedAssets || data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tdelete newData.options.tpl;\n\tdeleteUnusedData(newData.processes);\n\n\tconsole.log(TAG, 'start');\n\n\t/*=====START process =====*/\n\tconsole.log(TAG, 'start process');\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, newData.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 newData.processes) {\n\t\tprocessManager.deal(process);\n\t}\n\n\tconsole.log(TAG, 'processManager.generateCurrent()');\n\n\tprocessManager.generateCurrent();\n\tawait processManager.compile(); //自定义过程先编译\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\tconsole.log(TAG, '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\tconsole.log(TAG, '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\nconst unusedFields = ['design'];\nfunction deleteUnusedData(processes){\n\tfor(let process of processes){\n\t\tif(process.sub){\n\t\t\tfor(let uuid in process.sub){\n\t\t\t\tlet subProcess = process.sub[uuid];\n\t\t\t\tfor(let field of unusedFields){\n\t\t\t\t\tif(subProcess.hasOwnProperty(field)){\n\t\t\t\t\t\tdelete subProcess[field];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(process.metas && process.metas.length > 0){\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\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}\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,GA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K,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
......@@ -236,7 +236,7 @@ function fillTpl(data, params) {
return newTpl;
}
async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
async function packData(data, {debug, packedAssets, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
......@@ -244,7 +244,7 @@ async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
let newData = {};
newData.options = data.options;
newData.views = data.views;
newData.assets = data.assets;
newData.assets = packedAssets || data.assets;
newData.dataMapping = data.dataMapping;
newData.processes = data.processes;
......
{"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);\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);\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(process) {\n\t\tconst {id, name, script} = process;\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] = {\n\t\t\t\t\tscript,\n\t\t\t\t\tids: [],\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.pool[hash].ids.push(name || id);\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tgenerateCurrent() {\n\t\tlet scripts = '';\n\t\tfor (let hash in this.pool) {\n\t\t\tlet {script, ids} = this.pool[hash];\n\t\t\tlet idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\\n');\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${idsComment}\n${script}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\t\tthis.scripts += scripts;\n\t\tthis.pool = {};\n\t}\n\n\tasync compile(){\n\t\ttry {\n\t\t\tconst {code ,sourcemap} = await compile(this.scripts, true);\n\t\t\tthis.scripts = code;\n\t\t}catch (e) {\n\t\t\tconsole.log('编译失败', e);\n\t\t}\n\t}\n\n\tgenerate() {\n\t\tthis.generateCurrent();\n\t\tlet scripts = this.scripts;\n\n\t\treturn `\n(function(){\nvar exports = {};\n${scripts}\n\n\tengine.setScriptMap(exports);\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'];\nconst TAG = 'zeroing-pack';\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\tconst newTpl = options.newTpl;\n\tdelete options.newTpl;\n\treturn 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\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tdelete newData.options.tpl;\n\tdeleteUnusedData(newData.processes);\n\n\tconsole.log(TAG, 'start');\n\n\t/*=====START process =====*/\n\tconsole.log(TAG, 'start process');\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, newData.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 newData.processes) {\n\t\tprocessManager.deal(process);\n\t}\n\n\tconsole.log(TAG, 'processManager.generateCurrent()');\n\n\tprocessManager.generateCurrent();\n\tawait processManager.compile(); //自定义过程先编译\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\tconsole.log(TAG, '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\tconsole.log(TAG, '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\nconst unusedFields = ['design'];\nfunction deleteUnusedData(processes){\n\tfor(let process of processes){\n\t\tif(process.sub){\n\t\t\tfor(let uuid in process.sub){\n\t\t\t\tlet subProcess = process.sub[uuid];\n\t\t\t\tfor(let field of unusedFields){\n\t\t\t\t\tif(subProcess.hasOwnProperty(field)){\n\t\t\t\t\t\tdelete subProcess[field];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(process.metas && process.metas.length > 0){\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\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}\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":[],"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AAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;GAC9B;EACD;CACD,OAAO,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
{"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);\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);\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(process) {\n\t\tconst {id, name, script} = process;\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] = {\n\t\t\t\t\tscript,\n\t\t\t\t\tids: [],\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.pool[hash].ids.push(name || id);\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tgenerateCurrent() {\n\t\tlet scripts = '';\n\t\tfor (let hash in this.pool) {\n\t\t\tlet {script, ids} = this.pool[hash];\n\t\t\tlet idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\\n');\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${idsComment}\n${script}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\t\tthis.scripts += scripts;\n\t\tthis.pool = {};\n\t}\n\n\tasync compile(){\n\t\ttry {\n\t\t\tconst {code ,sourcemap} = await compile(this.scripts, true);\n\t\t\tthis.scripts = code;\n\t\t}catch (e) {\n\t\t\tconsole.log('编译失败', e);\n\t\t}\n\t}\n\n\tgenerate() {\n\t\tthis.generateCurrent();\n\t\tlet scripts = this.scripts;\n\n\t\treturn `\n(function(){\nvar exports = {};\n${scripts}\n\n\tengine.setScriptMap(exports);\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'];\nconst TAG = 'zeroing-pack';\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\tconst newTpl = options.newTpl;\n\tdelete options.newTpl;\n\treturn newTpl;\n}\n\nasync function packData(data, {debug, packedAssets, 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\tnewData.views = data.views;\n\tnewData.assets = packedAssets || data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tdelete newData.options.tpl;\n\tdeleteUnusedData(newData.processes);\n\n\tconsole.log(TAG, 'start');\n\n\t/*=====START process =====*/\n\tconsole.log(TAG, 'start process');\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, newData.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 newData.processes) {\n\t\tprocessManager.deal(process);\n\t}\n\n\tconsole.log(TAG, 'processManager.generateCurrent()');\n\n\tprocessManager.generateCurrent();\n\tawait processManager.compile(); //自定义过程先编译\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\tconsole.log(TAG, '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\tconsole.log(TAG, '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\nconst unusedFields = ['design'];\nfunction deleteUnusedData(processes){\n\tfor(let process of processes){\n\t\tif(process.sub){\n\t\t\tfor(let uuid in process.sub){\n\t\t\t\tlet subProcess = process.sub[uuid];\n\t\t\t\tfor(let field of unusedFields){\n\t\t\t\t\tif(subProcess.hasOwnProperty(field)){\n\t\t\t\t\t\tdelete subProcess[field];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(process.metas && process.metas.length > 0){\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\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}\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;EACf,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;EAClB;;CAED,IAAI,CAAC,OA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......@@ -236,7 +236,7 @@ ${scripts}
return newTpl;
}
async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
async function packData(data, {debug, packedAssets, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
......@@ -244,7 +244,7 @@ ${scripts}
let newData = {};
newData.options = data.options;
newData.views = data.views;
newData.assets = data.assets;
newData.assets = packedAssets || data.assets;
newData.dataMapping = data.dataMapping;
newData.processes = data.processes;
......
{"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);\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);\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(process) {\n\t\tconst {id, name, script} = process;\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] = {\n\t\t\t\t\tscript,\n\t\t\t\t\tids: [],\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.pool[hash].ids.push(name || id);\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tgenerateCurrent() {\n\t\tlet scripts = '';\n\t\tfor (let hash in this.pool) {\n\t\t\tlet {script, ids} = this.pool[hash];\n\t\t\tlet idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\\n');\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${idsComment}\n${script}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\t\tthis.scripts += scripts;\n\t\tthis.pool = {};\n\t}\n\n\tasync compile(){\n\t\ttry {\n\t\t\tconst {code ,sourcemap} = await compile(this.scripts, true);\n\t\t\tthis.scripts = code;\n\t\t}catch (e) {\n\t\t\tconsole.log('编译失败', e);\n\t\t}\n\t}\n\n\tgenerate() {\n\t\tthis.generateCurrent();\n\t\tlet scripts = this.scripts;\n\n\t\treturn `\n(function(){\nvar exports = {};\n${scripts}\n\n\tengine.setScriptMap(exports);\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'];\nconst TAG = 'zeroing-pack';\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\tconst newTpl = options.newTpl;\n\tdelete options.newTpl;\n\treturn 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\tnewData.views = data.views;\n\tnewData.assets = data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tdelete newData.options.tpl;\n\tdeleteUnusedData(newData.processes);\n\n\tconsole.log(TAG, 'start');\n\n\t/*=====START process =====*/\n\tconsole.log(TAG, 'start process');\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, newData.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 newData.processes) {\n\t\tprocessManager.deal(process);\n\t}\n\n\tconsole.log(TAG, 'processManager.generateCurrent()');\n\n\tprocessManager.generateCurrent();\n\tawait processManager.compile(); //自定义过程先编译\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\tconsole.log(TAG, '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\tconsole.log(TAG, '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\nconst unusedFields = ['design'];\nfunction deleteUnusedData(processes){\n\tfor(let process of processes){\n\t\tif(process.sub){\n\t\t\tfor(let uuid in process.sub){\n\t\t\t\tlet subProcess = process.sub[uuid];\n\t\t\t\tfor(let field of unusedFields){\n\t\t\t\t\tif(subProcess.hasOwnProperty(field)){\n\t\t\t\t\t\tdelete subProcess[field];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(process.metas && process.metas.length > 0){\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\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}\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,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KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACjC,EAAE;CACF,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC;;CAED,SAAS,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE;CAC5C,CAAC,KAAK,IAAI,KAAK,IAAI,MAAM,EAAE;CAC3B,EAAE,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;CAClD,EAAE,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;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
{"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);\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);\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(process) {\n\t\tconst {id, name, script} = process;\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] = {\n\t\t\t\t\tscript,\n\t\t\t\t\tids: [],\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.pool[hash].ids.push(name || id);\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tgenerateCurrent() {\n\t\tlet scripts = '';\n\t\tfor (let hash in this.pool) {\n\t\t\tlet {script, ids} = this.pool[hash];\n\t\t\tlet idsComment = ids.map(id=>{return `/*== ${id} ==*/`}).join('\\n');\n\t\t\tscripts += `\n\texports['${hash}'] = function(args, props, target, global, vm){\n\t\treturn new Promise(function(resolve, reject){\n\n${idsComment}\n${script}\n\n\t\tfunction next(type, payload){resolve({type: type, payload: payload})}\n\t\t});\n\t};\n`;\n\t\t}\n\t\tthis.scripts += scripts;\n\t\tthis.pool = {};\n\t}\n\n\tasync compile(){\n\t\ttry {\n\t\t\tconst {code ,sourcemap} = await compile(this.scripts, true);\n\t\t\tthis.scripts = code;\n\t\t}catch (e) {\n\t\t\tconsole.log('编译失败', e);\n\t\t}\n\t}\n\n\tgenerate() {\n\t\tthis.generateCurrent();\n\t\tlet scripts = this.scripts;\n\n\t\treturn `\n(function(){\nvar exports = {};\n${scripts}\n\n\tengine.setScriptMap(exports);\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'];\nconst TAG = 'zeroing-pack';\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\tconst newTpl = options.newTpl;\n\tdelete options.newTpl;\n\treturn newTpl;\n}\n\nasync function packData(data, {debug, packedAssets, 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\tnewData.views = data.views;\n\tnewData.assets = packedAssets || data.assets;\n\tnewData.dataMapping = data.dataMapping;\n\tnewData.processes = data.processes;\n\n\tdelete newData.options.tpl;\n\tdeleteUnusedData(newData.processes);\n\n\tconsole.log(TAG, 'start');\n\n\t/*=====START process =====*/\n\tconsole.log(TAG, 'start process');\n\tlet processIDs = [];\n\tfindDepPidsBat(processIDs, newData.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 newData.processes) {\n\t\tprocessManager.deal(process);\n\t}\n\n\tconsole.log(TAG, 'processManager.generateCurrent()');\n\n\tprocessManager.generateCurrent();\n\tawait processManager.compile(); //自定义过程先编译\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\tconsole.log(TAG, '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\tconsole.log(TAG, '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\nconst unusedFields = ['design'];\nfunction deleteUnusedData(processes){\n\tfor(let process of processes){\n\t\tif(process.sub){\n\t\t\tfor(let uuid in process.sub){\n\t\t\t\tlet subProcess = process.sub[uuid];\n\t\t\t\tfor(let field of unusedFields){\n\t\t\t\t\tif(subProcess.hasOwnProperty(field)){\n\t\t\t\t\t\tdelete subProcess[field];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(process.metas && process.metas.length > 0){\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\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}\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":";;;;;;;;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,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
......@@ -33,7 +33,7 @@ export function fillTpl(data, params) {
return newTpl;
}
async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
async function packData(data, {debug, packedAssets, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
......@@ -41,7 +41,7 @@ async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
let newData = {};
newData.options = data.options;
newData.views = data.views;
newData.assets = data.assets;
newData.assets = packedAssets || data.assets;
newData.dataMapping = data.dataMapping;
newData.processes = data.processes;
......
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