nexusframework 0.3.0-beta.72 → 0.3.0-beta.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +55 -55
- package/README.md +12 -12
- package/about/index.json +5 -5
- package/about/index.nhp +4 -4
- package/icon.png +0 -0
- package/index.d.ts +12 -15
- package/index.js +94 -81
- package/index.js.map +1 -1
- package/index.ts +101 -89
- package/indexOfSkeleton.nhp +133 -133
- package/legacySkeleton.nhp +22 -22
- package/loader/overlay.css +1 -1
- package/loader/overlay.html +25 -25
- package/loader/overlay.scss +152 -152
- package/package.json +102 -89
- package/scripts/es5/compat.js +101 -0
- package/scripts/es5/compat.js.map +1 -0
- package/scripts/es5/compat.min.js +2 -0
- package/scripts/es5/compat.min.js.map +1 -0
- package/scripts/es5/loader.js +0 -0
- package/scripts/es5/loader.js.map +0 -0
- package/scripts/es5/loader.min.js +1 -1
- package/scripts/es5/loader.min.js.map +0 -0
- package/scripts/es5/nexusframeworkclient.js +1092 -1103
- package/scripts/es5/nexusframeworkclient.js.map +1 -1
- package/scripts/es5/nexusframeworkclient.min.js +1 -1
- package/scripts/es5/nexusframeworkclient.min.js.map +1 -1
- package/scripts/es6/compat.js +65 -0
- package/scripts/es6/compat.js.map +1 -0
- package/scripts/es6/compat.min.js +2 -0
- package/scripts/es6/compat.min.js.map +1 -0
- package/scripts/es6/loader.js +0 -0
- package/scripts/es6/loader.js.map +0 -0
- package/scripts/es6/loader.min.js +1 -1
- package/scripts/es6/loader.min.js.map +0 -0
- package/scripts/es6/nexusframeworkclient.js +1026 -1049
- package/scripts/es6/nexusframeworkclient.js.map +1 -1
- package/scripts/es6/nexusframeworkclient.min.js +1 -1
- package/scripts/es6/nexusframeworkclient.min.js.map +1 -1
- package/scripts/index.d.ts +259 -251
- package/scripts/src/compat.ts +62 -0
- package/scripts/src/loader.ts +385 -385
- package/scripts/src/nexusframeworkclient.ts +1163 -1185
- package/scripts/tsconfig.json +11 -11
- package/src/cli.d.ts +1 -0
- package/src/cli.js +102 -102
- package/src/cli.js.map +1 -1
- package/src/cli.ts +101 -101
- package/src/compileScripts.d.ts +2 -2
- package/src/compileScripts.js +145 -145
- package/src/compileScripts.js.map +1 -1
- package/src/compileScripts.ts +153 -153
- package/src/nexusframework.d.ts +177 -168
- package/src/nexusframework.js +3578 -3422
- package/src/nexusframework.js.map +1 -1
- package/src/nexusframework.ts +3631 -3473
- package/templates/basic/package.json +3 -3
- package/templates/basic/www/skeleton.nhp +1 -1
- package/templates/bootstrap/package.json +2 -2
- package/templates/bootstrap/www/skeleton.nhp +1 -1
- package/templates/bootstrap-material-design/package.json +2 -2
- package/templates/bootstrap-material-design/www/skeleton.nhp +1 -1
- package/tsconfig.json +25 -22
- package/types.d.ts +612 -564
package/src/compileScripts.js
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const child_process = require("child_process");
|
|
3
|
-
const uglifyJs = require("uglify-js");
|
|
4
|
-
const uglifyEs = require("uglify-es");
|
|
5
|
-
const logger = require("nulllogger");
|
|
6
|
-
const async = require("async");
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const _ = require("lodash");
|
|
9
|
-
const fs = require("fs");
|
|
10
|
-
const os = require("os");
|
|
11
|
-
const cpus = os.cpus().length;
|
|
12
|
-
const tsc = require.resolve("typescript/bin/tsc");
|
|
13
|
-
const typeOptions = {
|
|
14
|
-
"es5": ["--target", "ES5"],
|
|
15
|
-
"es6": ["--target", "ES6"]
|
|
16
|
-
};
|
|
17
|
-
const compile = function (indir, outdir, cb, types = ["es5", "es6"]) {
|
|
18
|
-
const log = new logger("NexusFramework");
|
|
19
|
-
const sourcemap = indir === outdir;
|
|
20
|
-
const options = {
|
|
21
|
-
mangle: true,
|
|
22
|
-
compress: true
|
|
23
|
-
};
|
|
24
|
-
if (sourcemap)
|
|
25
|
-
indir = path.resolve(indir, "src");
|
|
26
|
-
const _cpus = Math.max(1, Math.floor(cpus / types.length));
|
|
27
|
-
fs.readdir(indir, function (err, files) {
|
|
28
|
-
if (err)
|
|
29
|
-
return cb(err);
|
|
30
|
-
const compileDir = function (typeOutDir, _type, cb) {
|
|
31
|
-
const l = log.extend(_type);
|
|
32
|
-
l.info("Processing");
|
|
33
|
-
async.eachLimit(files, _cpus, function (tsRaw, cb) {
|
|
34
|
-
if (!/\.ts$/.test(tsRaw))
|
|
35
|
-
return cb();
|
|
36
|
-
const base = path.basename(tsRaw, ".ts");
|
|
37
|
-
const minOut = base + ".min.js";
|
|
38
|
-
const minOutJs = path.resolve(typeOutDir, minOut);
|
|
39
|
-
const jsOut = path.resolve(typeOutDir, base + ".js");
|
|
40
|
-
const tsIn = path.resolve(indir, tsRaw);
|
|
41
|
-
var inmtime, outmtime;
|
|
42
|
-
async.series([
|
|
43
|
-
function (cb) {
|
|
44
|
-
fs.stat(tsIn, function (err, stat) {
|
|
45
|
-
if (err)
|
|
46
|
-
return cb(err);
|
|
47
|
-
inmtime = stat.mtimeMs;
|
|
48
|
-
cb();
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
function (cb) {
|
|
52
|
-
fs.stat(minOutJs, function (err, stat) {
|
|
53
|
-
if (err) {
|
|
54
|
-
if (err.code === "ENOENT") {
|
|
55
|
-
outmtime = 0;
|
|
56
|
-
return cb();
|
|
57
|
-
}
|
|
58
|
-
return cb(err);
|
|
59
|
-
}
|
|
60
|
-
outmtime = stat.mtimeMs;
|
|
61
|
-
cb();
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
], function (err) {
|
|
65
|
-
if (err)
|
|
66
|
-
return cb(err);
|
|
67
|
-
if (outmtime >= inmtime)
|
|
68
|
-
return cb();
|
|
69
|
-
const args = ["--module", "AMD", "--out", jsOut];
|
|
70
|
-
const opts = typeOptions[_type];
|
|
71
|
-
if (sourcemap)
|
|
72
|
-
args.push("--sourceMap", "true");
|
|
73
|
-
if (opts)
|
|
74
|
-
args.push.apply(args, opts);
|
|
75
|
-
args.push(tsIn);
|
|
76
|
-
l.info("Compiling", tsIn);
|
|
77
|
-
const child = child_process.fork(tsc, args, { stdio: "inherit" });
|
|
78
|
-
child.on("exit", function (code, signal) {
|
|
79
|
-
if (signal)
|
|
80
|
-
return cb(new Error("Exited with signal " + signal));
|
|
81
|
-
if (code)
|
|
82
|
-
return cb(new Error("Exited with code " + code));
|
|
83
|
-
const uglify = _type === "es6" ? uglifyEs : uglifyJs;
|
|
84
|
-
l.info("uglify ", jsOut, minOut);
|
|
85
|
-
fs.readFile(jsOut, "utf8", function (err, code) {
|
|
86
|
-
if (err)
|
|
87
|
-
return cb(err);
|
|
88
|
-
const data = {};
|
|
89
|
-
data["../src/" + tsRaw] = code;
|
|
90
|
-
const _opts =
|
|
91
|
-
const next = function () {
|
|
92
|
-
const output = uglify.minify(data, _opts);
|
|
93
|
-
err = output['error'];
|
|
94
|
-
if (err)
|
|
95
|
-
return cb(err instanceof Error ? err : new Error(err));
|
|
96
|
-
if (sourcemap)
|
|
97
|
-
output.code += "\n//# sourceMappingURL=" + base + ".min.js.map";
|
|
98
|
-
fs.writeFile(minOutJs, output.code, "utf8", function (err) {
|
|
99
|
-
if (err)
|
|
100
|
-
return cb(err);
|
|
101
|
-
if (sourcemap)
|
|
102
|
-
fs.writeFile(path.resolve(typeOutDir, base + ".min.js.map"), output.map, "utf8", cb);
|
|
103
|
-
else
|
|
104
|
-
cb();
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
if (sourcemap)
|
|
108
|
-
fs.readFile(path.resolve(typeOutDir, base + ".js.map"), "utf8", function (err, smap) {
|
|
109
|
-
if (err)
|
|
110
|
-
return cb(err);
|
|
111
|
-
_opts.sourceMap = {
|
|
112
|
-
content: smap,
|
|
113
|
-
filename: base + ".min.js"
|
|
114
|
-
};
|
|
115
|
-
next();
|
|
116
|
-
});
|
|
117
|
-
else
|
|
118
|
-
fs.unlink(jsOut, function (err) {
|
|
119
|
-
if (err)
|
|
120
|
-
return cb(err);
|
|
121
|
-
next();
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}, cb);
|
|
127
|
-
};
|
|
128
|
-
if (types.length === 1)
|
|
129
|
-
compileDir(outdir, types[0], cb);
|
|
130
|
-
else
|
|
131
|
-
async.each(types, function (_type, cb) {
|
|
132
|
-
compileDir(path.resolve(outdir, _type), _type, cb);
|
|
133
|
-
}, cb);
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
if (require.main === module) {
|
|
137
|
-
const scriptsDir = path.resolve(__dirname, "../scripts");
|
|
138
|
-
compile(scriptsDir, scriptsDir, function (err) {
|
|
139
|
-
if (err)
|
|
140
|
-
throw err;
|
|
141
|
-
else
|
|
142
|
-
process.exit(0);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
module.exports = compile;
|
|
1
|
+
"use strict";
|
|
2
|
+
const child_process = require("child_process");
|
|
3
|
+
const uglifyJs = require("uglify-js");
|
|
4
|
+
const uglifyEs = require("uglify-es");
|
|
5
|
+
const logger = require("nulllogger");
|
|
6
|
+
const async = require("async");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const _ = require("lodash");
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const os = require("os");
|
|
11
|
+
const cpus = os.cpus().length;
|
|
12
|
+
const tsc = require.resolve("typescript/bin/tsc");
|
|
13
|
+
const typeOptions = {
|
|
14
|
+
"es5": ["--target", "ES5"],
|
|
15
|
+
"es6": ["--target", "ES6"]
|
|
16
|
+
};
|
|
17
|
+
const compile = function (indir, outdir, cb, types = ["es5", "es6"]) {
|
|
18
|
+
const log = new logger("NexusFramework");
|
|
19
|
+
const sourcemap = indir === outdir;
|
|
20
|
+
const options = {
|
|
21
|
+
mangle: true,
|
|
22
|
+
compress: true
|
|
23
|
+
};
|
|
24
|
+
if (sourcemap)
|
|
25
|
+
indir = path.resolve(indir, "src");
|
|
26
|
+
const _cpus = Math.max(1, Math.floor(cpus / types.length));
|
|
27
|
+
fs.readdir(indir, function (err, files) {
|
|
28
|
+
if (err)
|
|
29
|
+
return cb(err);
|
|
30
|
+
const compileDir = function (typeOutDir, _type, cb) {
|
|
31
|
+
const l = log.extend(_type);
|
|
32
|
+
l.info("Processing");
|
|
33
|
+
async.eachLimit(files, _cpus, function (tsRaw, cb) {
|
|
34
|
+
if (!/\.ts$/.test(tsRaw))
|
|
35
|
+
return cb();
|
|
36
|
+
const base = path.basename(tsRaw, ".ts");
|
|
37
|
+
const minOut = base + ".min.js";
|
|
38
|
+
const minOutJs = path.resolve(typeOutDir, minOut);
|
|
39
|
+
const jsOut = path.resolve(typeOutDir, base + ".js");
|
|
40
|
+
const tsIn = path.resolve(indir, tsRaw);
|
|
41
|
+
var inmtime, outmtime;
|
|
42
|
+
async.series([
|
|
43
|
+
function (cb) {
|
|
44
|
+
fs.stat(tsIn, function (err, stat) {
|
|
45
|
+
if (err)
|
|
46
|
+
return cb(err);
|
|
47
|
+
inmtime = stat.mtimeMs;
|
|
48
|
+
cb();
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
function (cb) {
|
|
52
|
+
fs.stat(minOutJs, function (err, stat) {
|
|
53
|
+
if (err) {
|
|
54
|
+
if (err.code === "ENOENT") {
|
|
55
|
+
outmtime = 0;
|
|
56
|
+
return cb();
|
|
57
|
+
}
|
|
58
|
+
return cb(err);
|
|
59
|
+
}
|
|
60
|
+
outmtime = stat.mtimeMs;
|
|
61
|
+
cb();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
], function (err) {
|
|
65
|
+
if (err)
|
|
66
|
+
return cb(err);
|
|
67
|
+
if (outmtime >= inmtime)
|
|
68
|
+
return cb();
|
|
69
|
+
const args = ["--module", "AMD", "--out", jsOut];
|
|
70
|
+
const opts = typeOptions[_type];
|
|
71
|
+
if (sourcemap)
|
|
72
|
+
args.push("--sourceMap", "true");
|
|
73
|
+
if (opts)
|
|
74
|
+
args.push.apply(args, opts);
|
|
75
|
+
args.push(tsIn);
|
|
76
|
+
l.info("Compiling", tsIn);
|
|
77
|
+
const child = child_process.fork(tsc, args, { stdio: "inherit" });
|
|
78
|
+
child.on("exit", function (code, signal) {
|
|
79
|
+
if (signal)
|
|
80
|
+
return cb(new Error("Exited with signal " + signal));
|
|
81
|
+
if (code)
|
|
82
|
+
return cb(new Error("Exited with code " + code));
|
|
83
|
+
const uglify = _type === "es6" ? uglifyEs : uglifyJs;
|
|
84
|
+
l.info("uglify ", jsOut, minOut);
|
|
85
|
+
fs.readFile(jsOut, "utf8", function (err, code) {
|
|
86
|
+
if (err)
|
|
87
|
+
return cb(err);
|
|
88
|
+
const data = {};
|
|
89
|
+
data["../src/" + tsRaw] = code;
|
|
90
|
+
const _opts = _.cloneDeep(options);
|
|
91
|
+
const next = function () {
|
|
92
|
+
const output = uglify.minify(data, _opts);
|
|
93
|
+
err = output['error'];
|
|
94
|
+
if (err)
|
|
95
|
+
return cb(err instanceof Error ? err : new Error(err));
|
|
96
|
+
if (sourcemap)
|
|
97
|
+
output.code += "\n//# sourceMappingURL=" + base + ".min.js.map";
|
|
98
|
+
fs.writeFile(minOutJs, output.code, "utf8", function (err) {
|
|
99
|
+
if (err)
|
|
100
|
+
return cb(err);
|
|
101
|
+
if (sourcemap)
|
|
102
|
+
fs.writeFile(path.resolve(typeOutDir, base + ".min.js.map"), output.map, "utf8", cb);
|
|
103
|
+
else
|
|
104
|
+
cb();
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
if (sourcemap)
|
|
108
|
+
fs.readFile(path.resolve(typeOutDir, base + ".js.map"), "utf8", function (err, smap) {
|
|
109
|
+
if (err)
|
|
110
|
+
return cb(err);
|
|
111
|
+
_opts.sourceMap = {
|
|
112
|
+
content: smap,
|
|
113
|
+
filename: base + ".min.js"
|
|
114
|
+
};
|
|
115
|
+
next();
|
|
116
|
+
});
|
|
117
|
+
else
|
|
118
|
+
fs.unlink(jsOut, function (err) {
|
|
119
|
+
if (err)
|
|
120
|
+
return cb(err);
|
|
121
|
+
next();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}, cb);
|
|
127
|
+
};
|
|
128
|
+
if (types.length === 1)
|
|
129
|
+
compileDir(outdir, types[0], cb);
|
|
130
|
+
else
|
|
131
|
+
async.each(types, function (_type, cb) {
|
|
132
|
+
compileDir(path.resolve(outdir, _type), _type, cb);
|
|
133
|
+
}, cb);
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
if (require.main === module) {
|
|
137
|
+
const scriptsDir = path.resolve(__dirname, "../scripts");
|
|
138
|
+
compile(scriptsDir, scriptsDir, function (err) {
|
|
139
|
+
if (err)
|
|
140
|
+
throw err;
|
|
141
|
+
else
|
|
142
|
+
process.exit(0);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
module.exports = compile;
|
|
146
146
|
//# sourceMappingURL=compileScripts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileScripts.js","sourceRoot":"","sources":["compileScripts.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"compileScripts.js","sourceRoot":"","sources":["compileScripts.ts"],"names":[],"mappings":";AAAA,MAAO,aAAa,4BAA4B;AAChD,MAAO,QAAQ,wBAAwB;AACvC,MAAO,QAAQ,wBAAwB;AACvC,MAAO,MAAM,yBAAyB;AACtC,MAAO,KAAK,oBAAoB;AAChC,MAAO,IAAI,mBAAmB;AAC9B,MAAO,CAAC,qBAAqB;AAC7B,MAAO,EAAE,iBAAiB;AAC1B,MAAO,EAAE,iBAAiB;AAE1B,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;AAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElD,MAAM,WAAW,GAAG;IAChB,KAAK,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC;IAC1B,KAAK,EAAE,CAAC,UAAU,EAAE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,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;YACP,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,CAAC,CAAA;QACD,IAAG,KAAK,CAAC,MAAM,KAAK,CAAC;YACjB,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;;YAEjC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,UAAS,KAAK,EAAE,EAAE;gBAChC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACvD,CAAC,EAAE,EAAE,CAAC,CAAC;IACf,CAAC,CAAC,CAAC;AACP,CAAC,CAAA;AAGD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACzD,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,UAAS,GAAW;QAChD,IAAI,GAAG;YACH,MAAM,GAAG,CAAC;;YAEV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACP,CAAC;AAVD,iBAAS,OAAO,CAAC"}
|
package/src/compileScripts.ts
CHANGED
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
import child_process = require("child_process");
|
|
2
|
-
import uglifyJs = require("uglify-js");
|
|
3
|
-
import uglifyEs = require("uglify-es");
|
|
4
|
-
import logger = require("nulllogger");
|
|
5
|
-
import async = require("async");
|
|
6
|
-
import path = require("path");
|
|
7
|
-
import _ = require("lodash");
|
|
8
|
-
import fs = require("fs");
|
|
9
|
-
import os = require("os");
|
|
10
|
-
|
|
11
|
-
const cpus = os.cpus().length;
|
|
12
|
-
const tsc = require.resolve("typescript/bin/tsc");
|
|
13
|
-
|
|
14
|
-
const typeOptions = {
|
|
15
|
-
"es5": ["--target", "ES5"],
|
|
16
|
-
"es6": ["--target", "ES6"]
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const compile = function(indir: string, outdir: string, cb: (err?: Error) => void, types = ["es5", "es6"]) {
|
|
20
|
-
const log = new logger("NexusFramework");
|
|
21
|
-
const sourcemap = indir === outdir;
|
|
22
|
-
const options: any = {
|
|
23
|
-
mangle: true,
|
|
24
|
-
compress: true
|
|
25
|
-
};
|
|
26
|
-
if (sourcemap)
|
|
27
|
-
indir = path.resolve(indir, "src");
|
|
28
|
-
const _cpus = Math.max(1, Math.floor(cpus / types.length));
|
|
29
|
-
fs.readdir(indir, function(err: Error, files?: string[]) {
|
|
30
|
-
if (err)
|
|
31
|
-
return cb(err);
|
|
32
|
-
const compileDir = function(typeOutDir: string, _type: string, cb: (err?: Error) => void) {
|
|
33
|
-
const l = log.extend(_type);
|
|
34
|
-
l.info("Processing");
|
|
35
|
-
async.eachLimit(files, _cpus, function(tsRaw, cb) {
|
|
36
|
-
if (!/\.ts$/.test(tsRaw))
|
|
37
|
-
return cb();
|
|
38
|
-
|
|
39
|
-
const base = path.basename(tsRaw, ".ts");
|
|
40
|
-
const minOut = base + ".min.js";
|
|
41
|
-
const minOutJs = path.resolve(typeOutDir, minOut);
|
|
42
|
-
const jsOut = path.resolve(typeOutDir, base + ".js");
|
|
43
|
-
const tsIn = path.resolve(indir, tsRaw);
|
|
44
|
-
|
|
45
|
-
var inmtime: number, outmtime: number;
|
|
46
|
-
async.series([
|
|
47
|
-
function(cb) {
|
|
48
|
-
fs.stat(tsIn, function(err, stat) {
|
|
49
|
-
if (err)
|
|
50
|
-
return cb(err);
|
|
51
|
-
inmtime = stat.mtimeMs;
|
|
52
|
-
cb();
|
|
53
|
-
})
|
|
54
|
-
},
|
|
55
|
-
function(cb) {
|
|
56
|
-
fs.stat(minOutJs, function(err, stat) {
|
|
57
|
-
if (err) {
|
|
58
|
-
if (err.code === "ENOENT") {
|
|
59
|
-
outmtime = 0;
|
|
60
|
-
return cb();
|
|
61
|
-
}
|
|
62
|
-
return cb(err);
|
|
63
|
-
}
|
|
64
|
-
outmtime = stat.mtimeMs;
|
|
65
|
-
cb();
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
], function(err: Error) {
|
|
69
|
-
if (err)
|
|
70
|
-
return cb(err);
|
|
71
|
-
if (outmtime >= inmtime)
|
|
72
|
-
return cb();
|
|
73
|
-
|
|
74
|
-
const args = ["--module", "AMD", "--out", jsOut];
|
|
75
|
-
const opts = typeOptions[_type];
|
|
76
|
-
if (sourcemap)
|
|
77
|
-
args.push("--sourceMap", "true");
|
|
78
|
-
if (opts)
|
|
79
|
-
args.push.apply(args, opts);
|
|
80
|
-
args.push(tsIn);
|
|
81
|
-
|
|
82
|
-
l.info("Compiling", tsIn);
|
|
83
|
-
const child = child_process.fork(tsc, args, {stdio:"inherit"} as any);
|
|
84
|
-
child.on("exit", function(code, signal) {
|
|
85
|
-
if(signal)
|
|
86
|
-
return cb(new Error("Exited with signal " + signal));
|
|
87
|
-
if(code)
|
|
88
|
-
return cb(new Error("Exited with code " + code));
|
|
89
|
-
|
|
90
|
-
const uglify = _type === "es6" ? uglifyEs : uglifyJs;
|
|
91
|
-
l.info("uglify ", jsOut, minOut);
|
|
92
|
-
fs.readFile(jsOut, "utf8", function(err, code) {
|
|
93
|
-
if(err)
|
|
94
|
-
return cb(err);
|
|
95
|
-
const data: any = {};
|
|
96
|
-
data["../src/" + tsRaw] = code;
|
|
97
|
-
const _opts: any =
|
|
98
|
-
const next = function() {
|
|
99
|
-
const output = uglify.minify(data as any, _opts);
|
|
100
|
-
err = output['error'];
|
|
101
|
-
if(err)
|
|
102
|
-
return cb(err instanceof Error ? err : new Error(err));
|
|
103
|
-
if (sourcemap)
|
|
104
|
-
output.code += "\n//# sourceMappingURL=" + base + ".min.js.map";
|
|
105
|
-
fs.writeFile(minOutJs, output.code, "utf8", function(err) {
|
|
106
|
-
if(err)
|
|
107
|
-
return cb(err);
|
|
108
|
-
if (sourcemap)
|
|
109
|
-
fs.writeFile(path.resolve(typeOutDir, base + ".min.js.map"), output.map, "utf8", cb);
|
|
110
|
-
else
|
|
111
|
-
cb();
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
if (sourcemap)
|
|
115
|
-
fs.readFile(path.resolve(typeOutDir, base + ".js.map"), "utf8", function(err, smap) {
|
|
116
|
-
if (err)
|
|
117
|
-
return cb(err);
|
|
118
|
-
_opts.sourceMap = {
|
|
119
|
-
content: smap,
|
|
120
|
-
filename: base + ".min.js"
|
|
121
|
-
};
|
|
122
|
-
next();
|
|
123
|
-
});
|
|
124
|
-
else
|
|
125
|
-
fs.unlink(jsOut, function(err) {
|
|
126
|
-
if (err)
|
|
127
|
-
return cb(err);
|
|
128
|
-
next();
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}, cb);
|
|
134
|
-
}
|
|
135
|
-
if(types.length === 1)
|
|
136
|
-
compileDir(outdir, types[0], cb);
|
|
137
|
-
else
|
|
138
|
-
async.each(types, function(_type, cb) {
|
|
139
|
-
compileDir(path.resolve(outdir, _type), _type, cb);
|
|
140
|
-
}, cb);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
export = compile;
|
|
144
|
-
|
|
145
|
-
if (require.main === module) {
|
|
146
|
-
const scriptsDir = path.resolve(__dirname, "../scripts");
|
|
147
|
-
compile(scriptsDir, scriptsDir, function(err?: Error) {
|
|
148
|
-
if (err)
|
|
149
|
-
throw err;
|
|
150
|
-
else
|
|
151
|
-
process.exit(0);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
1
|
+
import child_process = require("child_process");
|
|
2
|
+
import uglifyJs = require("uglify-js");
|
|
3
|
+
import uglifyEs = require("uglify-es");
|
|
4
|
+
import logger = require("nulllogger");
|
|
5
|
+
import async = require("async");
|
|
6
|
+
import path = require("path");
|
|
7
|
+
import _ = require("lodash");
|
|
8
|
+
import fs = require("fs");
|
|
9
|
+
import os = require("os");
|
|
10
|
+
|
|
11
|
+
const cpus = os.cpus().length;
|
|
12
|
+
const tsc = require.resolve("typescript/bin/tsc");
|
|
13
|
+
|
|
14
|
+
const typeOptions = {
|
|
15
|
+
"es5": ["--target", "ES5"],
|
|
16
|
+
"es6": ["--target", "ES6"]
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const compile = function(indir: string, outdir: string, cb: (err?: Error) => void, types = ["es5", "es6"]) {
|
|
20
|
+
const log = new logger("NexusFramework");
|
|
21
|
+
const sourcemap = indir === outdir;
|
|
22
|
+
const options: any = {
|
|
23
|
+
mangle: true,
|
|
24
|
+
compress: true
|
|
25
|
+
};
|
|
26
|
+
if (sourcemap)
|
|
27
|
+
indir = path.resolve(indir, "src");
|
|
28
|
+
const _cpus = Math.max(1, Math.floor(cpus / types.length));
|
|
29
|
+
fs.readdir(indir, function(err: Error, files?: string[]) {
|
|
30
|
+
if (err)
|
|
31
|
+
return cb(err);
|
|
32
|
+
const compileDir = function(typeOutDir: string, _type: string, cb: (err?: Error) => void) {
|
|
33
|
+
const l = log.extend(_type);
|
|
34
|
+
l.info("Processing");
|
|
35
|
+
async.eachLimit(files, _cpus, function(tsRaw, cb) {
|
|
36
|
+
if (!/\.ts$/.test(tsRaw))
|
|
37
|
+
return cb();
|
|
38
|
+
|
|
39
|
+
const base = path.basename(tsRaw, ".ts");
|
|
40
|
+
const minOut = base + ".min.js";
|
|
41
|
+
const minOutJs = path.resolve(typeOutDir, minOut);
|
|
42
|
+
const jsOut = path.resolve(typeOutDir, base + ".js");
|
|
43
|
+
const tsIn = path.resolve(indir, tsRaw);
|
|
44
|
+
|
|
45
|
+
var inmtime: number, outmtime: number;
|
|
46
|
+
async.series([
|
|
47
|
+
function(cb) {
|
|
48
|
+
fs.stat(tsIn, function(err, stat) {
|
|
49
|
+
if (err)
|
|
50
|
+
return cb(err);
|
|
51
|
+
inmtime = stat.mtimeMs;
|
|
52
|
+
cb();
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
function(cb) {
|
|
56
|
+
fs.stat(minOutJs, function(err, stat) {
|
|
57
|
+
if (err) {
|
|
58
|
+
if (err.code === "ENOENT") {
|
|
59
|
+
outmtime = 0;
|
|
60
|
+
return cb();
|
|
61
|
+
}
|
|
62
|
+
return cb(err);
|
|
63
|
+
}
|
|
64
|
+
outmtime = stat.mtimeMs;
|
|
65
|
+
cb();
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
], function(err: Error) {
|
|
69
|
+
if (err)
|
|
70
|
+
return cb(err);
|
|
71
|
+
if (outmtime >= inmtime)
|
|
72
|
+
return cb();
|
|
73
|
+
|
|
74
|
+
const args = ["--module", "AMD", "--out", jsOut];
|
|
75
|
+
const opts = typeOptions[_type];
|
|
76
|
+
if (sourcemap)
|
|
77
|
+
args.push("--sourceMap", "true");
|
|
78
|
+
if (opts)
|
|
79
|
+
args.push.apply(args, opts);
|
|
80
|
+
args.push(tsIn);
|
|
81
|
+
|
|
82
|
+
l.info("Compiling", tsIn);
|
|
83
|
+
const child = child_process.fork(tsc, args, {stdio:"inherit"} as any);
|
|
84
|
+
child.on("exit", function(code, signal) {
|
|
85
|
+
if(signal)
|
|
86
|
+
return cb(new Error("Exited with signal " + signal));
|
|
87
|
+
if(code)
|
|
88
|
+
return cb(new Error("Exited with code " + code));
|
|
89
|
+
|
|
90
|
+
const uglify = _type === "es6" ? uglifyEs : uglifyJs;
|
|
91
|
+
l.info("uglify ", jsOut, minOut);
|
|
92
|
+
fs.readFile(jsOut, "utf8", function(err, code) {
|
|
93
|
+
if(err)
|
|
94
|
+
return cb(err);
|
|
95
|
+
const data: any = {};
|
|
96
|
+
data["../src/" + tsRaw] = code;
|
|
97
|
+
const _opts: any = _.cloneDeep(options);
|
|
98
|
+
const next = function() {
|
|
99
|
+
const output = uglify.minify(data as any, _opts);
|
|
100
|
+
err = output['error'];
|
|
101
|
+
if(err)
|
|
102
|
+
return cb(err instanceof Error ? err : new Error(err));
|
|
103
|
+
if (sourcemap)
|
|
104
|
+
output.code += "\n//# sourceMappingURL=" + base + ".min.js.map";
|
|
105
|
+
fs.writeFile(minOutJs, output.code, "utf8", function(err) {
|
|
106
|
+
if(err)
|
|
107
|
+
return cb(err);
|
|
108
|
+
if (sourcemap)
|
|
109
|
+
fs.writeFile(path.resolve(typeOutDir, base + ".min.js.map"), output.map, "utf8", cb);
|
|
110
|
+
else
|
|
111
|
+
cb();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (sourcemap)
|
|
115
|
+
fs.readFile(path.resolve(typeOutDir, base + ".js.map"), "utf8", function(err, smap) {
|
|
116
|
+
if (err)
|
|
117
|
+
return cb(err);
|
|
118
|
+
_opts.sourceMap = {
|
|
119
|
+
content: smap,
|
|
120
|
+
filename: base + ".min.js"
|
|
121
|
+
};
|
|
122
|
+
next();
|
|
123
|
+
});
|
|
124
|
+
else
|
|
125
|
+
fs.unlink(jsOut, function(err) {
|
|
126
|
+
if (err)
|
|
127
|
+
return cb(err);
|
|
128
|
+
next();
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}, cb);
|
|
134
|
+
}
|
|
135
|
+
if(types.length === 1)
|
|
136
|
+
compileDir(outdir, types[0], cb);
|
|
137
|
+
else
|
|
138
|
+
async.each(types, function(_type, cb) {
|
|
139
|
+
compileDir(path.resolve(outdir, _type), _type, cb);
|
|
140
|
+
}, cb);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
export = compile;
|
|
144
|
+
|
|
145
|
+
if (require.main === module) {
|
|
146
|
+
const scriptsDir = path.resolve(__dirname, "../scripts");
|
|
147
|
+
compile(scriptsDir, scriptsDir, function(err?: Error) {
|
|
148
|
+
if (err)
|
|
149
|
+
throw err;
|
|
150
|
+
else
|
|
151
|
+
process.exit(0);
|
|
152
|
+
});
|
|
153
|
+
}
|