Commit 18776cf8 authored by rockyl's avatar rockyl

init

parents
Pipeline #188544 failed with stages
in 0 seconds
# 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 crypto from 'crypto';
/**
* 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);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
this.deal(subProcess);
}
}
}
put(process) {
const {id, name, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = {
script,
ids: [],
};
}
this.pool[hash].ids.push(`${id} - ${name}`);
return hash;
}
}
generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let {script, ids} = this.pool[hash];
let idsComment = ids.map(id => {
return `/*== ${id} ==*/`
}).join('\n');
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${idsComment}
${script}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
this.scripts += scripts;
this.pool = {};
return scripts;
}
coverScripts(scripts) {
this.scripts = scripts;
}
generate() {
this.generateCurrent();
let scripts = this.scripts;
return `
(function(){
var exports = {};
${scripts}
engine.setScriptMap(exports);
})();
`
}
}
/**
* 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-12-20.
*/
async function divideCode(data, {debug, compile, uglify, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
/*=====START process =====*/
console.log(TAG, 'start process');
let processIDs = [];
findDepPidsBat(processIDs, data.processes);
let builtinProcesses = data.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);
}
console.log(TAG, 'processManager.generateCurrent()');
let ptScript = processManager.generateCurrent();
if (compile) {
processManager.coverScripts(await compile(ptScript)); //自定义过程先编译
}
for (let process of builtinProcesses) {
processManager.deal(process);
}
let processScriptContent = processManager.generate();
//console.log(processScriptContent);
if (!debug) {
processScriptContent = uglify(processScriptContent);
}
/*=====END process =====*/
/*=====START script =====*/
console.log(TAG, 'start script');
let scriptIDs = [];
for (let view of data.views) {
traverseNode(view, (node) => {
if (node.scripts && node.scripts.length > 0) {
for (let {script} of node.scripts) {
if (!scriptIDs.includes(script)) {
scriptIDs.push(script);
}
}
}
});
}
//console.log('scriptIDs:', scriptIDs);
//let scriptsContainer = data.scripts = {};
//let scriptsCode = '';
if (scriptIDs.length > 0) {
const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) {
let script = JSON.parse(scriptData);
//scriptsContainer[id] = code;
scriptManager.deal(script);
}
//console.log('scripts:', scriptsContainer);
}
let scriptsContent = scriptManager.generate();
//console.log(scriptsContent);
if (!debug) {
scriptsContent = uglify(scriptsContent);
}
/*=====END script =====*/
/*=====START custom =====*/
console.log(TAG, 'start custom');
//data.customs = [];
if (data.customs && data.customs.length > 0) {
/*data.customs = */
(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 {
processScriptContent,
scriptsContent,
customScriptContent,
}
}
function findDepPids(list, process) {
if (process.sub) {
for (let key in process.sub) {
let p = process.sub[key];
if (!list.includes(p.meta)) {
list.push(p.meta);
}
}
}
}
function findDepPidsBat(list, processes) {
for (let process of processes) {
findDepPids(list, process);
}
}
async function addBuiltinProcesses(list, ids, getProcesses) {
let newPids = [];
if (ids.length > 0) {
let processes = await getProcesses(ids);
for (let processData of processes) {
let process = JSON.parse(processData);
list.push(process);
findDepPids(newPids, process);
}
}
return newPids;
}
function traverseNode(root, callback) {
callback(root);
if (root.children && root.children.length > 0) {
for (let childNode of root.children) {
traverseNode(childNode, callback);
}
}
}
export { divideCode };
//# sourceMappingURL=index.es.js.map
This diff is collapsed.
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var crypto = _interopDefault(require('crypto'));
/**
* 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);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
this.deal(subProcess);
}
}
}
put(process) {
const {id, name, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = {
script,
ids: [],
};
}
this.pool[hash].ids.push(`${id} - ${name}`);
return hash;
}
}
generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let {script, ids} = this.pool[hash];
let idsComment = ids.map(id => {
return `/*== ${id} ==*/`
}).join('\n');
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${idsComment}
${script}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
this.scripts += scripts;
this.pool = {};
return scripts;
}
coverScripts(scripts) {
this.scripts = scripts;
}
generate() {
this.generateCurrent();
let scripts = this.scripts;
return `
(function(){
var exports = {};
${scripts}
engine.setScriptMap(exports);
})();
`
}
}
/**
* 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-12-20.
*/
async function divideCode(data, {debug, compile, uglify, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
/*=====START process =====*/
console.log(TAG, 'start process');
let processIDs = [];
findDepPidsBat(processIDs, data.processes);
let builtinProcesses = data.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);
}
console.log(TAG, 'processManager.generateCurrent()');
let ptScript = processManager.generateCurrent();
if (compile) {
processManager.coverScripts(await compile(ptScript)); //自定义过程先编译
}
for (let process of builtinProcesses) {
processManager.deal(process);
}
let processScriptContent = processManager.generate();
//console.log(processScriptContent);
if (!debug) {
processScriptContent = uglify(processScriptContent);
}
/*=====END process =====*/
/*=====START script =====*/
console.log(TAG, 'start script');
let scriptIDs = [];
for (let view of data.views) {
traverseNode(view, (node) => {
if (node.scripts && node.scripts.length > 0) {
for (let {script} of node.scripts) {
if (!scriptIDs.includes(script)) {
scriptIDs.push(script);
}
}
}
});
}
//console.log('scriptIDs:', scriptIDs);
//let scriptsContainer = data.scripts = {};
//let scriptsCode = '';
if (scriptIDs.length > 0) {
const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) {
let script = JSON.parse(scriptData);
//scriptsContainer[id] = code;
scriptManager.deal(script);
}
//console.log('scripts:', scriptsContainer);
}
let scriptsContent = scriptManager.generate();
//console.log(scriptsContent);
if (!debug) {
scriptsContent = uglify(scriptsContent);
}
/*=====END script =====*/
/*=====START custom =====*/
console.log(TAG, 'start custom');
//data.customs = [];
if (data.customs && data.customs.length > 0) {
/*data.customs = */
(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 {
processScriptContent,
scriptsContent,
customScriptContent,
}
}
function findDepPids(list, process) {
if (process.sub) {
for (let key in process.sub) {
let p = process.sub[key];
if (!list.includes(p.meta)) {
list.push(p.meta);
}
}
}
}
function findDepPidsBat(list, processes) {
for (let process of processes) {
findDepPids(list, process);
}
}
async function addBuiltinProcesses(list, ids, getProcesses) {
let newPids = [];
if (ids.length > 0) {
let processes = await getProcesses(ids);
for (let processData of processes) {
let process = JSON.parse(processData);
list.push(process);
findDepPids(newPids, process);
}
}
return newPids;
}
function traverseNode(root, callback) {
callback(root);
if (root.children && root.children.length > 0) {
for (let childNode of root.children) {
traverseNode(childNode, callback);
}
}
}
exports.divideCode = divideCode;
//# sourceMappingURL=index.js.map
This diff is collapsed.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('crypto')) :
typeof define === 'function' && define.amd ? define(['exports', 'crypto'], factory) :
(global = global || self, factory(global['zeroing-pack'] = {}, global.crypto));
}(this, function (exports, crypto) { 'use strict';
crypto = crypto && crypto.hasOwnProperty('default') ? crypto['default'] : crypto;
/**
* 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);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
this.deal(subProcess);
}
}
}
put(process) {
const {id, name, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = {
script,
ids: [],
};
}
this.pool[hash].ids.push(`${id} - ${name}`);
return hash;
}
}
generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let {script, ids} = this.pool[hash];
let idsComment = ids.map(id => {
return `/*== ${id} ==*/`
}).join('\n');
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${idsComment}
${script}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
this.scripts += scripts;
this.pool = {};
return scripts;
}
coverScripts(scripts) {
this.scripts = scripts;
}
generate() {
this.generateCurrent();
let scripts = this.scripts;
return `
(function(){
var exports = {};
${scripts}
engine.setScriptMap(exports);
})();
`
}
}
/**
* 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-12-20.
*/
async function divideCode(data, {debug, compile, uglify, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
/*=====START process =====*/
console.log(TAG, 'start process');
let processIDs = [];
findDepPidsBat(processIDs, data.processes);
let builtinProcesses = data.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);
}
console.log(TAG, 'processManager.generateCurrent()');
let ptScript = processManager.generateCurrent();
if (compile) {
processManager.coverScripts(await compile(ptScript)); //自定义过程先编译
}
for (let process of builtinProcesses) {
processManager.deal(process);
}
let processScriptContent = processManager.generate();
//console.log(processScriptContent);
if (!debug) {
processScriptContent = uglify(processScriptContent);
}
/*=====END process =====*/
/*=====START script =====*/
console.log(TAG, 'start script');
let scriptIDs = [];
for (let view of data.views) {
traverseNode(view, (node) => {
if (node.scripts && node.scripts.length > 0) {
for (let {script} of node.scripts) {
if (!scriptIDs.includes(script)) {
scriptIDs.push(script);
}
}
}
});
}
//console.log('scriptIDs:', scriptIDs);
//let scriptsContainer = data.scripts = {};
//let scriptsCode = '';
if (scriptIDs.length > 0) {
const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) {
let script = JSON.parse(scriptData);
//scriptsContainer[id] = code;
scriptManager.deal(script);
}
//console.log('scripts:', scriptsContainer);
}
let scriptsContent = scriptManager.generate();
//console.log(scriptsContent);
if (!debug) {
scriptsContent = uglify(scriptsContent);
}
/*=====END script =====*/
/*=====START custom =====*/
console.log(TAG, 'start custom');
//data.customs = [];
if (data.customs && data.customs.length > 0) {
/*data.customs = */
(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 {
processScriptContent,
scriptsContent,
customScriptContent,
}
}
function findDepPids(list, process) {
if (process.sub) {
for (let key in process.sub) {
let p = process.sub[key];
if (!list.includes(p.meta)) {
list.push(p.meta);
}
}
}
}
function findDepPidsBat(list, processes) {
for (let process of processes) {
findDepPids(list, process);
}
}
async function addBuiltinProcesses(list, ids, getProcesses) {
let newPids = [];
if (ids.length > 0) {
let processes = await getProcesses(ids);
for (let processData of processes) {
let process = JSON.parse(processData);
list.push(process);
findDepPids(newPids, process);
}
}
return newPids;
}
function traverseNode(root, callback) {
callback(root);
if (root.children && root.children.length > 0) {
for (let childNode of root.children) {
traverseNode(childNode, callback);
}
}
}
exports.divideCode = divideCode;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=index.umd.js.map
This diff is collapsed.
{
"name": "zeroing-code-divider",
"version": "1.0.0",
"main": "dist/index.js",
"license": "MIT",
"dependencies": {
},
"scripts": {
"build": "rollup -c"
}
}
/**
* Created by rockyl on 2018/11/16.
*/
const name = 'zeroing-pack';
export default {
input: 'src/index.js',
output: [
{
file: `dist/index.js`,
format: 'cjs',
sourcemap: true,
},
{
file: `dist/index.es.js`,
format: 'es',
sourcemap: true,
},
{
file: `dist/index.umd.js`,
format: 'umd',
sourcemap: true,
name,
}
],
plugins: [
]
};
/**
* 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'
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);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
this.deal(subProcess);
}
}
}
put(process) {
const {id, name, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = {
script,
ids: [],
};
}
this.pool[hash].ids.push(`${id} - ${name}`);
return hash;
}
}
generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let {script, ids} = this.pool[hash];
let idsComment = ids.map(id => {
return `/*== ${id} ==*/`
}).join('\n');
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${idsComment}
${script}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
this.scripts += scripts;
this.pool = {};
return scripts;
}
coverScripts(scripts) {
this.scripts = scripts;
}
generate() {
this.generateCurrent();
let scripts = this.scripts;
return `
(function(){
var exports = {};
${scripts}
engine.setScriptMap(exports);
})();
`
}
}
/**
* 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-12-20.
*/
import ProcessManager from "./ProcessManager";
import ScriptManager from "./ScriptManager";
import CustomManager from "./CustomManager";
export async function divideCode(data, {debug, compile, uglify, getProcesses, getScripts, getCustoms}) {
const processManager = new ProcessManager();
const scriptManager = new ScriptManager();
const customManager = new CustomManager();
/*=====START process =====*/
console.log(TAG, 'start process');
let processIDs = [];
findDepPidsBat(processIDs, data.processes);
let builtinProcesses = data.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);
}
console.log(TAG, 'processManager.generateCurrent()');
let ptScript = processManager.generateCurrent();
if (compile) {
processManager.coverScripts(await compile(ptScript)); //自定义过程先编译
}
for (let process of builtinProcesses) {
processManager.deal(process);
}
let processScriptContent = processManager.generate();
//console.log(processScriptContent);
if (!debug) {
processScriptContent = uglify(processScriptContent);
}
/*=====END process =====*/
/*=====START script =====*/
console.log(TAG, 'start script');
let scriptIDs = [];
for (let view of data.views) {
traverseNode(view, (node) => {
if (node.scripts && node.scripts.length > 0) {
for (let {script} of node.scripts) {
if (!scriptIDs.includes(script)) {
scriptIDs.push(script);
}
}
}
});
}
//console.log('scriptIDs:', scriptIDs);
//let scriptsContainer = data.scripts = {};
//let scriptsCode = '';
if (scriptIDs.length > 0) {
const scripts = await getScripts(scriptIDs);
for (let scriptData of scripts) {
let script = JSON.parse(scriptData);
//scriptsContainer[id] = code;
scriptManager.deal(script);
}
//console.log('scripts:', scriptsContainer);
}
let scriptsContent = scriptManager.generate();
//console.log(scriptsContent);
if (!debug) {
scriptsContent = uglify(scriptsContent);
}
/*=====END script =====*/
/*=====START custom =====*/
console.log(TAG, 'start custom');
//data.customs = [];
if (data.customs && data.customs.length > 0) {
/*data.customs = */
(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 {
processScriptContent,
scriptsContent,
customScriptContent,
}
}
function findDepPids(list, process) {
if (process.sub) {
for (let key in process.sub) {
let p = process.sub[key];
if (!list.includes(p.meta)) {
list.push(p.meta);
}
}
}
}
function findDepPidsBat(list, processes) {
for (let process of processes) {
findDepPids(list, process);
}
}
async function addBuiltinProcesses(list, ids, getProcesses) {
let newPids = [];
if (ids.length > 0) {
let processes = await getProcesses(ids);
for (let processData of processes) {
let process = JSON.parse(processData);
list.push(process);
findDepPids(newPids, process);
}
}
return newPids;
}
function traverseNode(root, callback) {
callback(root);
if (root.children && root.children.length > 0) {
for (let childNode of root.children) {
traverseNode(childNode, callback);
}
}
}
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../zeroing-code-divider" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
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