whet 0.0.26 → 0.0.28
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/bin/HxOverrides.js +6 -6
- package/bin/Lambda.js +10 -10
- package/bin/Reflect.js +2 -2
- package/bin/Std.js +1 -1
- package/bin/genes/Register.d.ts +11 -1
- package/bin/genes/Register.js +69 -40
- package/bin/genes/util/EsMap.js +5 -5
- package/bin/haxe/Exception.js +1 -1
- package/bin/haxe/crypto/Crc32.js +5 -5
- package/bin/haxe/ds/List.js +1 -1
- package/bin/haxe/io/Bytes.js +8 -8
- package/bin/haxe/io/BytesBuffer.js +6 -6
- package/bin/haxe/io/Output.js +7 -7
- package/bin/haxe/zip/Compress.js +2 -2
- package/bin/haxe/zip/Tools.js +1 -1
- package/bin/haxe/zip/Writer.js +18 -18
- package/bin/js/Boot.js +25 -25
- package/bin/js/node/buffer/Buffer.js +1 -1
- package/bin/whet/Log.js +7 -7
- package/bin/whet/Project.js +6 -6
- package/bin/whet/Source.js +7 -7
- package/bin/whet/SourceHash.js +49 -55
- package/bin/whet/SourceId.js +12 -12
- package/bin/whet/Stone.js +40 -40
- package/bin/whet/Utils.js +12 -12
- package/bin/whet/Whet.js +23 -23
- package/bin/whet/cache/BaseCache.js +23 -22
- package/bin/whet/cache/CacheManager.js +13 -13
- package/bin/whet/cache/FileCache.js +97 -101
- package/bin/whet/cache/MemoryCache.js +12 -12
- package/bin/whet/magic/RoutePathType.js +15 -15
- package/bin/whet/magic/StoneId.js +2 -2
- package/bin/whet/route/RouteResult.js +1 -1
- package/bin/whet/route/Router.js +128 -132
- package/bin/whet/stones/Files.js +47 -53
- package/bin/whet/stones/JsonStone.js +16 -16
- package/bin/whet/stones/RemoteFile.js +4 -4
- package/bin/whet/stones/Server.js +17 -17
- package/bin/whet/stones/Zip.js +16 -18
- package/bin/whet/stones/haxe/HaxeBuild.d.ts +1 -0
- package/bin/whet/stones/haxe/HaxeBuild.js +26 -24
- package/bin/whet/stones/haxe/Hxml.js +72 -71
- package/package.json +1 -1
- package/bin/haxe/Log.d.ts +0 -33
- package/bin/haxe/Log.js +0 -61
- package/bin/js/lib/ArrayBuffer.d.ts +0 -4
- package/bin/js/lib/ArrayBuffer.js +0 -24
|
@@ -6,7 +6,7 @@ const $global = Register.$global
|
|
|
6
6
|
export const Helper = Register.global("$hxClasses")["js.node.buffer._Buffer.Helper"] =
|
|
7
7
|
class Helper {
|
|
8
8
|
static bytesOfBuffer(b) {
|
|
9
|
-
|
|
9
|
+
let o = Object.create(Bytes.prototype);
|
|
10
10
|
o.length = b.byteLength;
|
|
11
11
|
o.b = b;
|
|
12
12
|
b.bufferValue = b;
|
package/bin/whet/Log.js
CHANGED
|
@@ -25,10 +25,10 @@ class Log {
|
|
|
25
25
|
}
|
|
26
26
|
static log(level, ...args) {
|
|
27
27
|
if (level >= Log.logLevel) {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let out = {"level": level, "time": Date.now(), "msg": null};
|
|
29
|
+
let _g_current = 0;
|
|
30
30
|
while (_g_current < args.length) {
|
|
31
|
-
|
|
31
|
+
let arg = args[_g_current++];
|
|
32
32
|
if (arg == null) {
|
|
33
33
|
continue;
|
|
34
34
|
};
|
|
@@ -41,11 +41,11 @@ class Log {
|
|
|
41
41
|
out["msg"].push(arg);
|
|
42
42
|
};
|
|
43
43
|
} else {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
let obj = arg;
|
|
45
|
+
let _g_keys = Reflect__1.fields(obj);
|
|
46
|
+
let _g_index = 0;
|
|
47
47
|
while (_g_index < _g_keys.length) {
|
|
48
|
-
|
|
48
|
+
let key = _g_keys[_g_index++];
|
|
49
49
|
out[key] = obj[key];
|
|
50
50
|
};
|
|
51
51
|
};
|
package/bin/whet/Project.js
CHANGED
|
@@ -27,21 +27,21 @@ class Project extends Register.inherits() {
|
|
|
27
27
|
this.options = (config.options == null) ? [] : config.options;
|
|
28
28
|
this.onInit = config.onInit;
|
|
29
29
|
if (config.rootDir == null) {
|
|
30
|
-
|
|
30
|
+
let oldValue = Error.prepareStackTrace;
|
|
31
31
|
Error.prepareStackTrace = function (_, stack) {
|
|
32
32
|
return stack;
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
let file = new Error().stack[3].getFileName();
|
|
35
35
|
Error.prepareStackTrace = oldValue;
|
|
36
36
|
file = decodeURI(file);
|
|
37
37
|
file = StringTools.replace(file, "file:///", "");
|
|
38
|
-
|
|
38
|
+
let str = Path.relative(process.cwd(), file);
|
|
39
39
|
if (str.length > 0) {
|
|
40
40
|
str = Path.posix.normalize(str);
|
|
41
41
|
str = StringTools.replace(str, "\\", "/");
|
|
42
42
|
};
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
let id = str;
|
|
44
|
+
let dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
45
45
|
this.rootDir = (dir.length == 0) ? "./" : dir;
|
|
46
46
|
} else {
|
|
47
47
|
this.rootDir = config.rootDir;
|
|
@@ -51,7 +51,7 @@ class Project extends Register.inherits() {
|
|
|
51
51
|
Log.log(30, ...["New project created.", {"project": this, "projectCount": Project.projects.length}]);
|
|
52
52
|
}
|
|
53
53
|
addCommand(name, stone) {
|
|
54
|
-
|
|
54
|
+
let cmd = new Command(name);
|
|
55
55
|
if (stone != null) {
|
|
56
56
|
cmd.alias(stone.id + "." + cmd.name());
|
|
57
57
|
};
|
package/bin/whet/Source.js
CHANGED
|
@@ -19,7 +19,7 @@ class Source extends Register.inherits() {
|
|
|
19
19
|
this.hash = hash;
|
|
20
20
|
this.origin = origin;
|
|
21
21
|
this.ctime = ctime;
|
|
22
|
-
|
|
22
|
+
let _g = 0;
|
|
23
23
|
while (_g < data.length) data[_g++].source = this;
|
|
24
24
|
}
|
|
25
25
|
tryDirPath() {
|
|
@@ -44,7 +44,7 @@ class Source extends Register.inherits() {
|
|
|
44
44
|
if (pattern == null) {
|
|
45
45
|
return this.data[0];
|
|
46
46
|
} else {
|
|
47
|
-
|
|
47
|
+
let filter = MinimatchType_Fields_.makeMinimatch(pattern);
|
|
48
48
|
return Lambda.find(this.data, function (entry) {
|
|
49
49
|
return filter.match(entry.id);
|
|
50
50
|
});
|
|
@@ -73,7 +73,7 @@ class SourceData extends Register.inherits() {
|
|
|
73
73
|
Same as `getFilePath` but relative to project, not CWD.
|
|
74
74
|
*/
|
|
75
75
|
getFilePathId(idOverride) {
|
|
76
|
-
|
|
76
|
+
let _gthis = this;
|
|
77
77
|
if (this.filePathId == null) {
|
|
78
78
|
return this.getFilePath(idOverride).then(function (_) {
|
|
79
79
|
return _gthis.filePathId;
|
|
@@ -89,13 +89,13 @@ class SourceData extends Register.inherits() {
|
|
|
89
89
|
* @param [idOverride] Use to change the name/directory of the file. Ignored if source already has a filepath.
|
|
90
90
|
*/
|
|
91
91
|
getFilePath(idOverride) {
|
|
92
|
-
|
|
92
|
+
let _gthis = this;
|
|
93
93
|
if (this.filePath == null) {
|
|
94
94
|
if (this.source == null) {
|
|
95
95
|
new Error("Data without source.");
|
|
96
96
|
};
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
let dir = this.source.getDirPath();
|
|
98
|
+
let name = (idOverride != null && !(idOverride.length == 0 || idOverride.charCodeAt(idOverride.length - 1) == 47)) ? idOverride : this.id;
|
|
99
99
|
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
100
100
|
throw new Error("\"" + dir + "\" is not a directory.");
|
|
101
101
|
};
|
|
@@ -122,7 +122,7 @@ class SourceData extends Register.inherits() {
|
|
|
122
122
|
Log.log(50, ...["File does not exist.", {"id": id, "path": path, "error": err}]);
|
|
123
123
|
rej(err);
|
|
124
124
|
} else {
|
|
125
|
-
|
|
125
|
+
let source = SourceData.fromBytes(id, buffer);
|
|
126
126
|
source.filePath = path;
|
|
127
127
|
source.filePathId = pathId;
|
|
128
128
|
res(source);
|
package/bin/whet/SourceHash.js
CHANGED
|
@@ -13,7 +13,7 @@ class SourceHash extends Register.inherits() {
|
|
|
13
13
|
this.bytes = bytes;
|
|
14
14
|
}
|
|
15
15
|
add(hash) {
|
|
16
|
-
|
|
16
|
+
let data = Buffer.alloc(64);
|
|
17
17
|
this.bytes.copy(data, 0, 0, 32);
|
|
18
18
|
hash.bytes.copy(data, 32, 0, 32);
|
|
19
19
|
return SourceHash.fromBytes(data);
|
|
@@ -40,60 +40,54 @@ class SourceHash extends Register.inherits() {
|
|
|
40
40
|
if (recursive == null) {
|
|
41
41
|
recursive = true;
|
|
42
42
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
let _g = [];
|
|
44
|
+
let _g1 = 0;
|
|
45
|
+
let _g2 = MaybeArray_Fields_.makeArray(paths);
|
|
46
46
|
while (_g1 < _g2.length) {
|
|
47
|
-
|
|
47
|
+
let src = _g2[_g1];
|
|
48
48
|
++_g1;
|
|
49
|
-
_g.push(new Promise(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
res([src[0]]);
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
})(src));
|
|
66
|
-
};
|
|
67
|
-
})(src)));
|
|
49
|
+
_g.push(new Promise(function (res, rej) {
|
|
50
|
+
Fs.stat(src, function (err, stats) {
|
|
51
|
+
if (err != null) {
|
|
52
|
+
rej(err);
|
|
53
|
+
} else if (stats.isDirectory()) {
|
|
54
|
+
Utils.listDirectoryFiles(src, recursive).then(function (files) {
|
|
55
|
+
res(files);
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
res([src]);
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}));
|
|
68
62
|
};
|
|
69
|
-
|
|
63
|
+
let allFilesProm = _g;
|
|
70
64
|
return Promise.all(allFilesProm).then(function (arrFiles) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
let result = new Array(arrFiles.length);
|
|
66
|
+
let _g = 0;
|
|
67
|
+
let _g1 = arrFiles.length;
|
|
74
68
|
while (_g < _g1) {
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
let i = _g++;
|
|
70
|
+
let files = arrFiles[i];
|
|
77
71
|
if (filter != null) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
while (
|
|
82
|
-
|
|
83
|
-
++
|
|
72
|
+
let _g = [];
|
|
73
|
+
let _g1 = 0;
|
|
74
|
+
let _g2 = files;
|
|
75
|
+
while (_g1 < _g2.length) {
|
|
76
|
+
let v = _g2[_g1];
|
|
77
|
+
++_g1;
|
|
84
78
|
if (filter(v)) {
|
|
85
|
-
|
|
79
|
+
_g.push(v);
|
|
86
80
|
};
|
|
87
81
|
};
|
|
88
|
-
files =
|
|
82
|
+
files = _g;
|
|
89
83
|
};
|
|
90
84
|
files.sort();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
while (
|
|
95
|
-
|
|
96
|
-
result1[
|
|
85
|
+
let result1 = new Array(files.length);
|
|
86
|
+
let _g1 = 0;
|
|
87
|
+
let _g2 = files.length;
|
|
88
|
+
while (_g1 < _g2) {
|
|
89
|
+
let i = _g1++;
|
|
90
|
+
result1[i] = SourceHash.fromFile(files[i]);
|
|
97
91
|
};
|
|
98
92
|
result[i] = Promise.all(result1);
|
|
99
93
|
};
|
|
@@ -101,14 +95,14 @@ class SourceHash extends Register.inherits() {
|
|
|
101
95
|
}).then(function (proms) {
|
|
102
96
|
return Promise.all(proms);
|
|
103
97
|
}).then(function (allHashes) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
let _g = [];
|
|
99
|
+
let _g_current = 0;
|
|
100
|
+
let _g_array = allHashes;
|
|
107
101
|
while (_g_current < _g_array.length) {
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
let e = _g_array[_g_current++];
|
|
103
|
+
let x = Register.getIterator(e);
|
|
110
104
|
while (x.hasNext()) {
|
|
111
|
-
|
|
105
|
+
let x1 = x.next();
|
|
112
106
|
_g.push(x1);
|
|
113
107
|
};
|
|
114
108
|
};
|
|
@@ -136,7 +130,7 @@ class SourceHash extends Register.inherits() {
|
|
|
136
130
|
};
|
|
137
131
|
}
|
|
138
132
|
static fromHex(hex) {
|
|
139
|
-
|
|
133
|
+
let hash = Buffer.from(hex, "hex");
|
|
140
134
|
if (hash.length != 32) {
|
|
141
135
|
return null;
|
|
142
136
|
} else {
|
|
@@ -147,9 +141,9 @@ class SourceHash extends Register.inherits() {
|
|
|
147
141
|
if (hash.length == 0) {
|
|
148
142
|
return SourceHash.EMPTY;
|
|
149
143
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
let h = hash[0];
|
|
145
|
+
let _g = 1;
|
|
146
|
+
let _g1 = hash.length;
|
|
153
147
|
while (_g < _g1) h = h.add(hash[_g++]);
|
|
154
148
|
return h;
|
|
155
149
|
}
|
|
@@ -163,7 +157,7 @@ class SourceHash extends Register.inherits() {
|
|
|
163
157
|
|
|
164
158
|
|
|
165
159
|
SourceHash.EMPTY = (function($this) {var $r0
|
|
166
|
-
|
|
160
|
+
let bytes = Buffer.alloc(32);
|
|
167
161
|
|
|
168
162
|
$r0 = new SourceHash(bytes)
|
|
169
163
|
return $r0})(this)
|
package/bin/whet/SourceId.js
CHANGED
|
@@ -24,10 +24,10 @@ class IdUtils {
|
|
|
24
24
|
throw new Error("\"" + directory + "\" is not a directory.");
|
|
25
25
|
};
|
|
26
26
|
if (nested) {
|
|
27
|
-
|
|
27
|
+
let dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
28
28
|
return ((dir.length == 0) ? "./" : dir).indexOf(directory) == 0;
|
|
29
29
|
} else {
|
|
30
|
-
|
|
30
|
+
let dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
31
31
|
return ((dir.length == 0) ? "./" : dir) == directory;
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -35,8 +35,8 @@ class IdUtils {
|
|
|
35
35
|
if (!(directory.length == 0 || directory.charCodeAt(directory.length - 1) == 47)) {
|
|
36
36
|
throw new Error("\"" + directory + "\" is not a directory.");
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
let tmp;
|
|
39
|
+
let dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
40
40
|
tmp = ((dir.length == 0) ? "./" : dir).indexOf(directory) == 0;
|
|
41
41
|
if (tmp) {
|
|
42
42
|
return id.substring(directory.length);
|
|
@@ -68,7 +68,7 @@ class IdUtils {
|
|
|
68
68
|
return id.substring(id.lastIndexOf("/") + 1);
|
|
69
69
|
}
|
|
70
70
|
static setWithExt(id, name) {
|
|
71
|
-
|
|
71
|
+
let dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
72
72
|
return Path.posix.join((dir.length == 0) ? "./" : dir, name);
|
|
73
73
|
}
|
|
74
74
|
static getExt(id) {
|
|
@@ -78,18 +78,18 @@ class IdUtils {
|
|
|
78
78
|
if (ext.length > 0 && ext.charCodeAt(0) != 46) {
|
|
79
79
|
ext = "." + ext;
|
|
80
80
|
};
|
|
81
|
-
|
|
81
|
+
let dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
82
82
|
return Path.posix.join((dir.length == 0) ? "./" : dir, Path.posix.parse(id).name) + ext;
|
|
83
83
|
}
|
|
84
84
|
static getWithoutExt(id) {
|
|
85
85
|
return Path.posix.parse(id).name;
|
|
86
86
|
}
|
|
87
87
|
static setWithoutExt(id, name) {
|
|
88
|
-
|
|
88
|
+
let dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
89
89
|
return Path.posix.join((dir.length == 0) ? "./" : dir, name) + Path.posix.extname(id);
|
|
90
90
|
}
|
|
91
91
|
static getDir(id) {
|
|
92
|
-
|
|
92
|
+
let dir = id.substring(0, id.lastIndexOf("/") + 1);
|
|
93
93
|
if (dir.length == 0) {
|
|
94
94
|
return "./";
|
|
95
95
|
} else {
|
|
@@ -100,14 +100,14 @@ class IdUtils {
|
|
|
100
100
|
return Path.posix.join(dir, id.substring(id.lastIndexOf("/") + 1));
|
|
101
101
|
}
|
|
102
102
|
static fromCwdPath(s, root) {
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
let absPath = Path.posix;
|
|
104
|
+
let str = s;
|
|
105
105
|
if (str.length > 0) {
|
|
106
106
|
str = Path.posix.normalize(str);
|
|
107
107
|
str = StringTools.replace(str, "\\", "/");
|
|
108
108
|
};
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
let absPath1 = absPath.resolve(str);
|
|
110
|
+
let rootStr = Path.posix.resolve(root);
|
|
111
111
|
return Path.posix.relative(rootStr, absPath1);
|
|
112
112
|
}
|
|
113
113
|
static normalize(str) {
|
package/bin/whet/Stone.js
CHANGED
|
@@ -53,13 +53,13 @@ class Stone extends Register.inherits() {
|
|
|
53
53
|
* Locks this stone for generating. Used to prevent parallel generation of the same sources.
|
|
54
54
|
*/
|
|
55
55
|
acquire(run) {
|
|
56
|
-
var _gthis = this;
|
|
57
56
|
Log.log(10, ...["Acquiring lock on a stone.", {"stone": this}]);
|
|
57
|
+
let _gthis = this;
|
|
58
58
|
if (this.locked) {
|
|
59
59
|
Log.log(20, ...["Stone is locked, waiting.", {"stone": this}]);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
let deferredRes;
|
|
61
|
+
let deferredRej;
|
|
62
|
+
let deferred = new Promise(function (res, rej) {
|
|
63
63
|
deferredRes = res;
|
|
64
64
|
deferredRej = rej;
|
|
65
65
|
});
|
|
@@ -67,11 +67,11 @@ class Stone extends Register.inherits() {
|
|
|
67
67
|
return deferred;
|
|
68
68
|
} else {
|
|
69
69
|
this.locked = true;
|
|
70
|
-
|
|
70
|
+
let runNext = null;
|
|
71
71
|
runNext = function () {
|
|
72
72
|
if (_gthis.lockQueue.length > 0) {
|
|
73
73
|
Log.log(20, ...["Running next queued-up lock acquire function.", {"stone": _gthis}]);
|
|
74
|
-
|
|
74
|
+
let queued = _gthis.lockQueue.shift();
|
|
75
75
|
queued.run().then(queued.res)["catch"](queued.rej)["finally"](runNext);
|
|
76
76
|
} else {
|
|
77
77
|
_gthis.locked = false;
|
|
@@ -97,8 +97,8 @@ class Stone extends Register.inherits() {
|
|
|
97
97
|
* Hashes of dependency stones (see `config.dependencies`) will be added to the hash.
|
|
98
98
|
*/
|
|
99
99
|
getHash() {
|
|
100
|
-
var _gthis = this;
|
|
101
100
|
Log.log(20, ...["Generating hash.", {"stone": this}]);
|
|
101
|
+
let _gthis = this;
|
|
102
102
|
return this.finalMaybeHash().then(function (hash) {
|
|
103
103
|
if (hash != null) {
|
|
104
104
|
return hash;
|
|
@@ -120,9 +120,9 @@ class Stone extends Register.inherits() {
|
|
|
120
120
|
if (hash == null || this.config.dependencies == null) {
|
|
121
121
|
return Promise.resolve(hash);
|
|
122
122
|
} else {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
let _g = [];
|
|
124
|
+
let _g1 = 0;
|
|
125
|
+
let _g2 = MaybeArray_Fields_.makeArray(this.config.dependencies);
|
|
126
126
|
while (_g1 < _g2.length) _g.push(_g2[_g1++].getHash());
|
|
127
127
|
return Promise.all(_g).then(function (hashes) {
|
|
128
128
|
return hash.add(SourceHash.merge(...hashes));
|
|
@@ -136,35 +136,35 @@ class Stone extends Register.inherits() {
|
|
|
136
136
|
* Hash passed should be the same as is this stone's current one. Passed in as optimization.
|
|
137
137
|
*/
|
|
138
138
|
generateSource(hash) {
|
|
139
|
-
var _gthis = this;
|
|
140
139
|
if (!this.locked) {
|
|
141
140
|
throw new Error("Acquire a lock before generating.");
|
|
142
141
|
};
|
|
143
142
|
Log.log(20, ...["Generating source.", {"stone": this, "hash": hash}]);
|
|
144
|
-
|
|
143
|
+
let init;
|
|
145
144
|
if (this.config.dependencies != null) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
let _g = [];
|
|
146
|
+
let _g1 = 0;
|
|
147
|
+
let _g2 = MaybeArray_Fields_.makeArray(this.config.dependencies);
|
|
149
148
|
while (_g1 < _g2.length) _g.push(_g2[_g1++].getSource());
|
|
150
149
|
init = Promise.all(_g);
|
|
151
150
|
} else {
|
|
152
151
|
init = Promise.resolve(null);
|
|
153
152
|
};
|
|
153
|
+
let _gthis = this;
|
|
154
154
|
return init.then(function (_) {
|
|
155
|
-
|
|
155
|
+
let dataPromise = _gthis.generate(hash);
|
|
156
156
|
if (dataPromise != null) {
|
|
157
157
|
return dataPromise.then(function (data) {
|
|
158
|
-
|
|
158
|
+
let finalHash;
|
|
159
159
|
if (hash != null) {
|
|
160
160
|
finalHash = Promise.resolve(hash);
|
|
161
161
|
} else {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
let _gthis1 = _gthis;
|
|
163
|
+
let result = new Array(data.length);
|
|
164
|
+
let _g = 0;
|
|
165
|
+
let _g1 = data.length;
|
|
166
166
|
while (_g < _g1) {
|
|
167
|
-
|
|
167
|
+
let i = _g++;
|
|
168
168
|
result[i] = SourceHash.fromBytes(data[i].data);
|
|
169
169
|
};
|
|
170
170
|
finalHash = _gthis1.finalizeHash(SourceHash.merge(...result));
|
|
@@ -179,11 +179,11 @@ class Stone extends Register.inherits() {
|
|
|
179
179
|
})["catch"](function (e) {
|
|
180
180
|
return _gthis.handleError(e).then(function (data) {
|
|
181
181
|
Log.log(40, ...["Error happened and was handled by `handleError`.", {"stone": _gthis, "error": e}]);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
let result = new Array(data.length);
|
|
183
|
+
let _g = 0;
|
|
184
|
+
let _g1 = data.length;
|
|
185
185
|
while (_g < _g1) {
|
|
186
|
-
|
|
186
|
+
let i = _g++;
|
|
187
187
|
result[i] = SourceHash.fromBytes(data[i].data);
|
|
188
188
|
};
|
|
189
189
|
return new Source(data, SourceHash.merge(...result), _gthis, Date.now() / 1000);
|
|
@@ -215,7 +215,7 @@ class Stone extends Register.inherits() {
|
|
|
215
215
|
* dependencies.
|
|
216
216
|
*/
|
|
217
217
|
finalMaybeHash() {
|
|
218
|
-
|
|
218
|
+
let _gthis = this;
|
|
219
219
|
return this.generateHash().then(function (hash) {
|
|
220
220
|
return _gthis.finalizeHash(hash);
|
|
221
221
|
});
|
|
@@ -229,12 +229,12 @@ class Stone extends Register.inherits() {
|
|
|
229
229
|
*/
|
|
230
230
|
list() {
|
|
231
231
|
return this.getSource().then(function (source) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
let _this = source.data;
|
|
233
|
+
let result = new Array(_this.length);
|
|
234
|
+
let _g = 0;
|
|
235
|
+
let _g1 = _this.length;
|
|
236
236
|
while (_g < _g1) {
|
|
237
|
-
|
|
237
|
+
let i = _g++;
|
|
238
238
|
result[i] = _this[i].id;
|
|
239
239
|
};
|
|
240
240
|
return result;
|
|
@@ -267,22 +267,22 @@ class Stone extends Register.inherits() {
|
|
|
267
267
|
* Can be a directory or a file path (only if this resource generates single source).
|
|
268
268
|
*/
|
|
269
269
|
exportTo(path) {
|
|
270
|
-
var _gthis = this;
|
|
271
270
|
Log.log(30, ...["Exporting file(s).", {"path": path, "stone": this}]);
|
|
272
|
-
|
|
271
|
+
let isDir = path.length == 0 || path.charCodeAt(path.length - 1) == 47;
|
|
272
|
+
let _gthis = this;
|
|
273
273
|
return this.getSource().then(function (src) {
|
|
274
274
|
if (src.data.length > 1 && !isDir) {
|
|
275
275
|
throw new Error("Path is not a directory for multiple source export.");
|
|
276
276
|
};
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
let _g = [];
|
|
278
|
+
let _g1 = 0;
|
|
279
|
+
let _g2 = src.data;
|
|
280
280
|
while (_g1 < _g2.length) {
|
|
281
|
-
|
|
281
|
+
let data = _g2[_g1];
|
|
282
282
|
++_g1;
|
|
283
|
-
|
|
283
|
+
let id;
|
|
284
284
|
if (isDir) {
|
|
285
|
-
|
|
285
|
+
let id1 = data.id;
|
|
286
286
|
if (!(path.length == 0 || path.charCodeAt(path.length - 1) == 47)) {
|
|
287
287
|
throw new Error("\"" + path + "\" is not a directory.");
|
|
288
288
|
};
|
package/bin/whet/Utils.js
CHANGED
|
@@ -9,14 +9,14 @@ const $global = Register.$global
|
|
|
9
9
|
export const Utils = Register.global("$hxClasses")["whet.Utils"] =
|
|
10
10
|
class Utils {
|
|
11
11
|
static makeUnique(val, isNotUnique, modify) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let unique = val;
|
|
13
|
+
let counter = 0;
|
|
14
14
|
while (isNotUnique(unique)) unique = modify(val, ++counter);
|
|
15
15
|
return unique;
|
|
16
16
|
}
|
|
17
17
|
static makeUniqueString(s, isNotUnique) {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
let unique = s;
|
|
19
|
+
let counter = 0;
|
|
20
20
|
while (isNotUnique(unique)) unique = s + ++counter;
|
|
21
21
|
return unique;
|
|
22
22
|
}
|
|
@@ -81,17 +81,17 @@ class Utils {
|
|
|
81
81
|
recursive = true;
|
|
82
82
|
};
|
|
83
83
|
return new Promise(function (res, rej) {
|
|
84
|
-
|
|
84
|
+
let result = [];
|
|
85
85
|
Fs.readdir(dir, { withFileTypes : true}, function(err,files) {
|
|
86
86
|
if(err != null) {
|
|
87
87
|
rej(err);
|
|
88
88
|
} else {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
let otherDirs = [];
|
|
90
|
+
let _g = 0;
|
|
91
91
|
while(_g < files.length) {
|
|
92
|
-
|
|
92
|
+
let file = files[_g];
|
|
93
93
|
++_g;
|
|
94
|
-
|
|
94
|
+
let path = Path.join(dir,file.name);
|
|
95
95
|
if(file.isDirectory()) {
|
|
96
96
|
if(recursive) {
|
|
97
97
|
otherDirs.push(Utils.listDirectoryFiles(path,true));
|
|
@@ -101,11 +101,11 @@ class Utils {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
Promise.all(otherDirs).then(function(arr) {
|
|
104
|
-
|
|
104
|
+
let _g = 0;
|
|
105
105
|
while(_g < arr.length) {
|
|
106
|
-
|
|
106
|
+
let a = arr[_g];
|
|
107
107
|
++_g;
|
|
108
|
-
|
|
108
|
+
let _g1 = 0;
|
|
109
109
|
while(_g1 < a.length) result.push(a[_g1++]);
|
|
110
110
|
}
|
|
111
111
|
res(result);
|