Commit 4034ca64 authored by rockyl's avatar rockyl

修复自定义模块的问题

parent 9587a0d8
...@@ -70,6 +70,7 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge ...@@ -70,6 +70,7 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
newData.assets = packedAssets || data.assets; newData.assets = packedAssets || data.assets;
newData.dataMapping = data.dataMapping; newData.dataMapping = data.dataMapping;
newData.processes = data.processes; newData.processes = data.processes;
newData.customs = data.customs;
delete newData.options.tpl; delete newData.options.tpl;
deleteUnusedData(newData.processes); deleteUnusedData(newData.processes);
...@@ -86,98 +87,6 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge ...@@ -86,98 +87,6 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
getProcesses, getScripts, getCustoms, getProcesses, getScripts, getCustoms,
}); });
/*/!*=====START process =====*!/
console.log(TAG, 'start process');
let processIDs = [];
findDepPidsBat(processIDs, newData.processes);
let builtinProcesses = newData.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 newData.processes) {
processManager.deal(process);
}
console.log(TAG, 'processManager.generateCurrent()');
processManager.generateCurrent();
await processManager.compile(); //自定义过程先编译
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 newData.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 = newData.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');
//newData.customs = [];
if (data.customs && data.customs.length > 0) {
/!*newData.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 { return {
data: JSON.stringify(newData), data: JSON.stringify(newData),
processScriptContent, processScriptContent,
......
This diff is collapsed.
...@@ -76,6 +76,7 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge ...@@ -76,6 +76,7 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
newData.assets = packedAssets || data.assets; newData.assets = packedAssets || data.assets;
newData.dataMapping = data.dataMapping; newData.dataMapping = data.dataMapping;
newData.processes = data.processes; newData.processes = data.processes;
newData.customs = data.customs;
delete newData.options.tpl; delete newData.options.tpl;
deleteUnusedData(newData.processes); deleteUnusedData(newData.processes);
...@@ -92,98 +93,6 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge ...@@ -92,98 +93,6 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
getProcesses, getScripts, getCustoms, getProcesses, getScripts, getCustoms,
}); });
/*/!*=====START process =====*!/
console.log(TAG, 'start process');
let processIDs = [];
findDepPidsBat(processIDs, newData.processes);
let builtinProcesses = newData.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 newData.processes) {
processManager.deal(process);
}
console.log(TAG, 'processManager.generateCurrent()');
processManager.generateCurrent();
await processManager.compile(); //自定义过程先编译
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 newData.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 = newData.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');
//newData.customs = [];
if (data.customs && data.customs.length > 0) {
/!*newData.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 { return {
data: JSON.stringify(newData), data: JSON.stringify(newData),
processScriptContent, processScriptContent,
......
This diff is collapsed.
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
newData.assets = packedAssets || data.assets; newData.assets = packedAssets || data.assets;
newData.dataMapping = data.dataMapping; newData.dataMapping = data.dataMapping;
newData.processes = data.processes; newData.processes = data.processes;
newData.customs = data.customs;
delete newData.options.tpl; delete newData.options.tpl;
deleteUnusedData(newData.processes); deleteUnusedData(newData.processes);
...@@ -91,98 +92,6 @@ ...@@ -91,98 +92,6 @@
getProcesses, getScripts, getCustoms, getProcesses, getScripts, getCustoms,
}); });
/*/!*=====START process =====*!/
console.log(TAG, 'start process');
let processIDs = [];
findDepPidsBat(processIDs, newData.processes);
let builtinProcesses = newData.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 newData.processes) {
processManager.deal(process);
}
console.log(TAG, 'processManager.generateCurrent()');
processManager.generateCurrent();
await processManager.compile(); //自定义过程先编译
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 newData.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 = newData.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');
//newData.customs = [];
if (data.customs && data.customs.length > 0) {
/!*newData.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 { return {
data: JSON.stringify(newData), data: JSON.stringify(newData),
processScriptContent, processScriptContent,
......
This diff is collapsed.
...@@ -38,6 +38,7 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge ...@@ -38,6 +38,7 @@ async function packData(data, {debug, packedAssets, getProcesses, getScripts, ge
newData.assets = packedAssets || data.assets; newData.assets = packedAssets || data.assets;
newData.dataMapping = data.dataMapping; newData.dataMapping = data.dataMapping;
newData.processes = data.processes; newData.processes = data.processes;
newData.customs = data.customs;
delete newData.options.tpl; delete newData.options.tpl;
deleteUnusedData(newData.processes); deleteUnusedData(newData.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