Commit 86d6f6e6 authored by rockyl's avatar rockyl

过程代码增加id注释

parent fb1e8780
......@@ -65,7 +65,7 @@ class ProcessManager {
}
put(process) {
const {id, script} = process;
const {id, name, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
......@@ -74,20 +74,21 @@ class ProcessManager {
ids: [],
};
}
this.pool[hash].ids.push(id);
this.pool[hash].ids.push(name || id);
return hash;
}
}
async generateCurrent() {
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 += `
${ids.map(id=>{return `/*== ${id} *==/\n`})}
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})}
......@@ -95,12 +96,13 @@ ${script}
};
`;
}
this.scripts += scripts;
this.pool = {};
}
//console.log('scripts', scripts);
async compile(){
try {
const {code ,sourcemap} = await compile(scripts, true);
const {code ,sourcemap} = await compile(this.scripts, true);
this.scripts = code;
}catch (e) {
console.log('编译失败', e);
......@@ -108,20 +110,8 @@ ${script}
}
generate() {
this.generateCurrent();
let scripts = this.scripts;
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
return `
(function(){
......@@ -281,7 +271,9 @@ async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
}
console.log(TAG, 'processManager.generateCurrent()');
await processManager.generateCurrent(); //自定义过程先编译
processManager.generateCurrent();
await processManager.compile(); //自定义过程先编译
for (let process of builtinProcesses) {
processManager.deal(process);
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ class ProcessManager {
}
put(process) {
const {id, script} = process;
const {id, name, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
......@@ -80,20 +80,21 @@ class ProcessManager {
ids: [],
};
}
this.pool[hash].ids.push(id);
this.pool[hash].ids.push(name || id);
return hash;
}
}
async generateCurrent() {
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 += `
${ids.map(id=>{return `/*== ${id} *==/\n`})}
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})}
......@@ -101,12 +102,13 @@ ${script}
};
`;
}
this.scripts += scripts;
this.pool = {};
}
//console.log('scripts', scripts);
async compile(){
try {
const {code ,sourcemap} = await compile(scripts, true);
const {code ,sourcemap} = await compile(this.scripts, true);
this.scripts = code;
}catch (e) {
console.log('编译失败', e);
......@@ -114,20 +116,8 @@ ${script}
}
generate() {
this.generateCurrent();
let scripts = this.scripts;
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
return `
(function(){
......@@ -287,7 +277,9 @@ async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
}
console.log(TAG, 'processManager.generateCurrent()');
await processManager.generateCurrent(); //自定义过程先编译
processManager.generateCurrent();
await processManager.compile(); //自定义过程先编译
for (let process of builtinProcesses) {
processManager.deal(process);
......
This diff is collapsed.
......@@ -71,7 +71,7 @@
}
put(process) {
const {id, script} = process;
const {id, name, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
......@@ -80,20 +80,21 @@
ids: [],
};
}
this.pool[hash].ids.push(id);
this.pool[hash].ids.push(name || id);
return hash;
}
}
async generateCurrent() {
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 += `
${ids.map(id=>{return `/*== ${id} *==/\n`})}
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})}
......@@ -101,12 +102,13 @@ ${script}
};
`;
}
this.scripts += scripts;
this.pool = {};
}
//console.log('scripts', scripts);
async compile(){
try {
const {code ,sourcemap} = await compile(scripts, true);
const {code ,sourcemap} = await compile(this.scripts, true);
this.scripts = code;
}catch (e) {
console.log('编译失败', e);
......@@ -114,20 +116,8 @@ ${script}
}
generate() {
this.generateCurrent();
let scripts = this.scripts;
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
return `
(function(){
......@@ -287,7 +277,9 @@ ${scripts}
}
console.log(TAG, 'processManager.generateCurrent()');
await processManager.generateCurrent(); //自定义过程先编译
processManager.generateCurrent();
await processManager.compile(); //自定义过程先编译
for (let process of builtinProcesses) {
processManager.deal(process);
......
This diff is collapsed.
......@@ -32,7 +32,7 @@ export default class ProcessManager {
}
put(process) {
const {id, script} = process;
const {id, name, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
......@@ -41,20 +41,21 @@ export default class ProcessManager {
ids: [],
};
}
this.pool[hash].ids.push(id);
this.pool[hash].ids.push(name || id);
return hash;
}
}
async generateCurrent() {
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 += `
${ids.map(id=>{return `/*== ${id} *==/\n`})}
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})}
......@@ -62,12 +63,13 @@ ${script}
};
`;
}
this.scripts += scripts;
this.pool = {};
}
//console.log('scripts', scripts);
async compile(){
try {
const {code ,sourcemap} = await compile(scripts, true);
const {code ,sourcemap} = await compile(this.scripts, true);
this.scripts = code;
}catch (e) {
console.log('编译失败', e);
......@@ -75,20 +77,8 @@ ${script}
}
generate() {
this.generateCurrent();
let scripts = this.scripts;
for (let hash in this.pool) {
let code = this.pool[hash];
scripts += `
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
function next(type, payload){resolve({type: type, payload: payload})}
});
};
`;
}
return `
(function(){
......
......@@ -72,7 +72,9 @@ async function packData(data, {debug, getProcesses, getScripts, getCustoms}) {
}
console.log(TAG, 'processManager.generateCurrent()');
await processManager.generateCurrent(); //自定义过程先编译
processManager.generateCurrent();
await processManager.compile(); //自定义过程先编译
for (let process of builtinProcesses) {
processManager.deal(process);
......
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