default main/gapp as a dependency for all files forcing it to the top
This commit is contained in:
parent
fa65c7c67f
commit
b5ad39ee08
7 changed files with 20 additions and 21 deletions
23
app.js
23
app.js
|
|
@ -47,12 +47,12 @@ function init(mod) {
|
||||||
|
|
||||||
let depcache = {};
|
let depcache = {};
|
||||||
|
|
||||||
function find_deps(path, seen = []) {
|
function find_deps(path) {
|
||||||
let cached = depcache[path];
|
let cached = depcache[path];
|
||||||
if (cached) {
|
if (cached) {
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
let deps = [];
|
let deps = [ "main/gapp" ];
|
||||||
let lines = fs.readFileSync(`${dir}/src/${path}.js`)
|
let lines = fs.readFileSync(`${dir}/src/${path}.js`)
|
||||||
.toString()
|
.toString()
|
||||||
.split('\n');
|
.split('\n');
|
||||||
|
|
@ -60,21 +60,17 @@ function init(mod) {
|
||||||
let dpos = line.indexOf('// dep:');
|
let dpos = line.indexOf('// dep:');
|
||||||
if (dpos >= 0) {
|
if (dpos >= 0) {
|
||||||
let dep = line.substring(dpos+7).trim().replace('.','/');
|
let dep = line.substring(dpos+7).trim().replace('.','/');
|
||||||
if (seen.indexOf(dep) >= 0) {
|
|
||||||
dbug.warn(`circular ${dep} from ${path}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (deps.indexOf(dep) < 0) {
|
if (deps.indexOf(dep) < 0) {
|
||||||
deps.push(dep);
|
deps.push(dep);
|
||||||
}
|
}
|
||||||
let deep = find_deps(dep, seen);
|
let deep = find_deps(dep);
|
||||||
if (deep) {
|
deps = deps.filter(p => deep.indexOf(p) < 0);
|
||||||
// deeper dependencies go first
|
// deeper dependencies go first
|
||||||
deps = [...deep, ...deps];
|
deps = [...deep, ...deps];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
depcache[path] = deps;
|
||||||
return deps.length ? deps : undefined;
|
return deps;
|
||||||
}
|
}
|
||||||
|
|
||||||
// process script dependencies, expand paths
|
// process script dependencies, expand paths
|
||||||
|
|
@ -94,7 +90,6 @@ function init(mod) {
|
||||||
let deps = find_deps(path);
|
let deps = find_deps(path);
|
||||||
if (deps) {
|
if (deps) {
|
||||||
// remove deps already in list
|
// remove deps already in list
|
||||||
// todo: promote filtered deps order in path array
|
|
||||||
deps = deps.filter(p => nval.indexOf(p) < 0);
|
deps = deps.filter(p => nval.indexOf(p) < 0);
|
||||||
let ppos = nval.indexOf(path);
|
let ppos = nval.indexOf(path);
|
||||||
if (ppos < 0) {
|
if (ppos < 0) {
|
||||||
|
|
@ -479,18 +474,12 @@ const script = {
|
||||||
"main/meta",
|
"main/meta",
|
||||||
],
|
],
|
||||||
mesh : [
|
mesh : [
|
||||||
"main/gapp",
|
|
||||||
"moto/license",
|
|
||||||
"&main/mesh"
|
"&main/mesh"
|
||||||
],
|
],
|
||||||
mesh_work : [
|
mesh_work : [
|
||||||
"main/gapp",
|
|
||||||
"moto/license",
|
|
||||||
"&mesh/work"
|
"&mesh/work"
|
||||||
],
|
],
|
||||||
mesh_pool : [
|
mesh_pool : [
|
||||||
"main/gapp",
|
|
||||||
"moto/license",
|
|
||||||
"&mesh/pool"
|
"&mesh/pool"
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
// dep: ext.three
|
||||||
gapp.register('add.three');
|
gapp.register('add.three');
|
||||||
|
|
||||||
var MP = THREE.Mesh.prototype,
|
var MP = THREE.Mesh.prototype,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@ if (typeof(self) === 'undefined') {
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
|
/** satisfy earcut, tween, etc **/
|
||||||
|
|
||||||
|
if (!self.module) self.module = { exports: {} };
|
||||||
|
|
||||||
/** debug and logging **/
|
/** debug and logging **/
|
||||||
|
|
||||||
let mark = Date.now();
|
let mark = Date.now();
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,11 @@ document.onreadystatechange = function() {
|
||||||
|
|
||||||
// finalize modules
|
// finalize modules
|
||||||
gapp.finalize("main.mesh", [
|
gapp.finalize("main.mesh", [
|
||||||
|
"moto.license", // dep: moto.license
|
||||||
"moto.webui", // dep: moto.webui
|
"moto.webui", // dep: moto.webui
|
||||||
"moto.client", // dep: moto.client
|
"moto.client", // dep: moto.client
|
||||||
"moto.broker", // dep: moto.broker
|
"moto.broker", // dep: moto.broker
|
||||||
"moto.space" // dep: moto.space
|
"moto.space", // dep: moto.space
|
||||||
]);
|
]);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
gapp.finalize("mesh.pool", [
|
gapp.finalize("mesh.pool", [
|
||||||
|
"moto.license", // dep: moto.license
|
||||||
"moto.worker" // dep: moto.worker
|
"moto.worker" // dep: moto.worker
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
// dep: ext.three
|
// dep: ext.three
|
||||||
// dep: ext.three-bgu
|
// dep: ext.three-bgu
|
||||||
gapp.finalize("mesh.work", [
|
gapp.finalize("mesh.work", [
|
||||||
|
"moto.license", // dep: moto.license
|
||||||
"moto.client" // dep: moto.client
|
"moto.client" // dep: moto.client
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,10 @@
|
||||||
app.license = terms.LICENSE;
|
app.license = terms.LICENSE;
|
||||||
app.version = terms.VERSION;
|
app.version = terms.VERSION;
|
||||||
app.copyright = terms.COPYRIGHT;
|
app.copyright = terms.COPYRIGHT;
|
||||||
|
// satisfy resolver
|
||||||
|
gapp.register('moto.license');
|
||||||
// for earcut and other modules
|
// for earcut and other modules
|
||||||
self.module = { exports: terms };
|
(self.module = self.module || {}).exports = terms;
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue