Commit fb1e8780 authored by rockyl's avatar rockyl

过程代码增加id注释

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