Commit fb1e8780 authored by rockyl's avatar rockyl

过程代码增加id注释

parent f25e9f8f
......@@ -50,13 +50,13 @@ class ProcessManager {
}
deal(process) {
let hash = this.put(process.script);
let hash = this.put(process);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess.script);
let hash = this.put(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
......@@ -64,12 +64,17 @@ class ProcessManager {
}
}
put(script) {
put(process) {
const {id, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = script;
this.pool[hash] = {
script,
ids: [],
};
}
this.pool[hash].ids.push(id);
return hash;
}
}
......@@ -77,12 +82,13 @@ class ProcessManager {
async generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let code = this.pool[hash];
let {script, ids} = this.pool[hash];
scripts += `
${ids.map(id=>{return `/*== ${id} *==/\n`})}
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
${script}
function next(type, payload){resolve({type: type, payload: payload})}
});
......
This diff is collapsed.
......@@ -56,13 +56,13 @@ class ProcessManager {
}
deal(process) {
let hash = this.put(process.script);
let hash = this.put(process);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess.script);
let hash = this.put(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
......@@ -70,12 +70,17 @@ class ProcessManager {
}
}
put(script) {
put(process) {
const {id, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = script;
this.pool[hash] = {
script,
ids: [],
};
}
this.pool[hash].ids.push(id);
return hash;
}
}
......@@ -83,12 +88,13 @@ class ProcessManager {
async generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let code = this.pool[hash];
let {script, ids} = this.pool[hash];
scripts += `
${ids.map(id=>{return `/*== ${id} *==/\n`})}
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
${script}
function next(type, payload){resolve({type: type, payload: payload})}
});
......
This diff is collapsed.
......@@ -56,13 +56,13 @@
}
deal(process) {
let hash = this.put(process.script);
let hash = this.put(process);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess.script);
let hash = this.put(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
......@@ -70,12 +70,17 @@
}
}
put(script) {
put(process) {
const {id, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = script;
this.pool[hash] = {
script,
ids: [],
};
}
this.pool[hash].ids.push(id);
return hash;
}
}
......@@ -83,12 +88,13 @@
async generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let code = this.pool[hash];
let {script, ids} = this.pool[hash];
scripts += `
${ids.map(id=>{return `/*== ${id} *==/\n`})}
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
${script}
function next(type, payload){resolve({type: type, payload: payload})}
});
......
This diff is collapsed.
......@@ -17,13 +17,13 @@ export default class ProcessManager {
}
deal(process) {
let hash = this.put(process.script);
let hash = this.put(process);
if (hash) {
process.script = 'link://' + hash;
}
if (process.metas) {
for (let subProcess of process.metas) {
let hash = this.put(subProcess.script);
let hash = this.put(subProcess);
if (hash) {
subProcess.script = 'link://' + hash;
}
......@@ -31,12 +31,17 @@ export default class ProcessManager {
}
}
put(script) {
put(process) {
const {id, script} = process;
if (script) {
let hash = md5(script);
if (!this.pool.hasOwnProperty(hash)) {
this.pool[hash] = script;
this.pool[hash] = {
script,
ids: [],
};
}
this.pool[hash].ids.push(id);
return hash;
}
}
......@@ -44,12 +49,13 @@ export default class ProcessManager {
async generateCurrent() {
let scripts = '';
for (let hash in this.pool) {
let code = this.pool[hash];
let {script, ids} = this.pool[hash];
scripts += `
${ids.map(id=>{return `/*== ${id} *==/\n`})}
exports['${hash}'] = function(args, props, target, global, vm){
return new Promise(function(resolve, reject){
${code}
${script}
function next(type, payload){resolve({type: type, payload: payload})}
});
......
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