whet 0.0.23 → 0.0.25
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/Std.d.ts +12 -11
- package/bin/Std.js +17 -29
- package/bin/genes/Register.d.ts +1 -1
- package/bin/haxe/Constraints.js +2 -1
- package/bin/haxe/io/BytesBuffer.js +2 -1
- package/bin/haxe/macro/Expr.d.ts +8 -0
- package/bin/haxe/macro/Type.d.ts +4 -0
- package/bin/haxe/zip/Compress.js +2 -1
- package/bin/js/Boot.d.ts +2 -2
- package/bin/js/lib/ArrayBuffer.d.ts +1 -1
- package/bin/js/lib/Promise.d.ts +2 -2
- package/bin/js/node/Fs.d.ts +1 -7
- package/bin/js/node/Process.d.ts +8 -0
- package/bin/whet/Log.js +4 -4
- package/bin/whet/Project.js +2 -4
- package/bin/whet/Source.js +1 -1
- package/bin/whet/SourceHash.js +6 -3
- package/bin/whet/SourceId.d.ts +1 -0
- package/bin/whet/SourceId.js +7 -0
- package/bin/whet/Utils.js +1 -2
- package/bin/whet/Whet.js +5 -7
- package/bin/whet/cache/BaseCache.js +3 -2
- package/bin/whet/cache/Cache.js +2 -1
- package/bin/whet/cache/FileCache.js +6 -6
- package/bin/whet/route/Router.js +8 -5
- package/bin/whet/stones/RemoteFile.d.ts +1 -0
- package/bin/whet/stones/RemoteFile.js +21 -13
- package/bin/whet/stones/Server.js +13 -2
- package/bin/whet/stones/Zip.d.ts +4 -0
- package/bin/whet/stones/Zip.js +4 -0
- package/package.json +1 -1
package/bin/Std.d.ts
CHANGED
|
@@ -29,21 +29,22 @@ export declare class Std {
|
|
|
29
29
|
|
|
30
30
|
Leading whitespaces are ignored.
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
contain 0-9 and A-F.
|
|
32
|
+
`x` may optionally start with a + or - to denote a postive or negative value respectively.
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
If the optional sign is followed 0x or 0X, hexadecimal notation is recognized where the following
|
|
35
|
+
digits may contain 0-9 and A-F. Both the prefix and digits are case insensitive.
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
Otherwise `x` is read as decimal number with 0-9 being allowed characters. Octal and binary
|
|
38
|
+
notations are not supported.
|
|
39
|
+
|
|
40
|
+
Parsing continues until an invalid character is detected, in which case the result up to
|
|
41
|
+
that point is returned. Scientific notation is not supported. That is `Std.parseInt('10e2')` produces `10`.
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
If `x` is `null`, the result is `null`.
|
|
44
|
+
If `x` cannot be parsed as integer or is empty, the result is `null`.
|
|
44
45
|
|
|
45
|
-
If `x`
|
|
46
|
-
|
|
46
|
+
If `x` starts with a hexadecimal prefix which is not followed by at least one valid hexadecimal
|
|
47
|
+
digit, the result is unspecified.
|
|
47
48
|
*/
|
|
48
49
|
static parseInt(x: string): null | number
|
|
49
50
|
}
|
package/bin/Std.js
CHANGED
|
@@ -36,41 +36,29 @@ class Std {
|
|
|
36
36
|
|
|
37
37
|
Leading whitespaces are ignored.
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
contain 0-9 and A-F.
|
|
39
|
+
`x` may optionally start with a + or - to denote a postive or negative value respectively.
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
If the optional sign is followed 0x or 0X, hexadecimal notation is recognized where the following
|
|
42
|
+
digits may contain 0-9 and A-F. Both the prefix and digits are case insensitive.
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
Otherwise `x` is read as decimal number with 0-9 being allowed characters. Octal and binary
|
|
45
|
+
notations are not supported.
|
|
46
|
+
|
|
47
|
+
Parsing continues until an invalid character is detected, in which case the result up to
|
|
48
|
+
that point is returned. Scientific notation is not supported. That is `Std.parseInt('10e2')` produces `10`.
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
If `x` is `null`, the result is `null`.
|
|
51
|
+
If `x` cannot be parsed as integer or is empty, the result is `null`.
|
|
51
52
|
|
|
52
|
-
If `x`
|
|
53
|
-
|
|
53
|
+
If `x` starts with a hexadecimal prefix which is not followed by at least one valid hexadecimal
|
|
54
|
+
digit, the result is unspecified.
|
|
54
55
|
*/
|
|
55
56
|
static parseInt(x) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
while (_g < _g1) {
|
|
60
|
-
var i = _g++;
|
|
61
|
-
var c = x.charCodeAt(i);
|
|
62
|
-
if (c <= 8 || c >= 14 && c != 32 && c != 45) {
|
|
63
|
-
var nc = x.charCodeAt(i + 1);
|
|
64
|
-
var v = parseInt(x, (nc == 120 || nc == 88) ? 16 : 10);
|
|
65
|
-
if ((isNaN)(v)) {
|
|
66
|
-
return null;
|
|
67
|
-
} else {
|
|
68
|
-
return v;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
};
|
|
57
|
+
var v = parseInt(x);
|
|
58
|
+
if ((isNaN)(v)) {
|
|
59
|
+
return null;
|
|
72
60
|
};
|
|
73
|
-
return
|
|
61
|
+
return v;
|
|
74
62
|
}
|
|
75
63
|
static get __name__() {
|
|
76
64
|
return "Std"
|
|
@@ -82,7 +70,7 @@ class Std {
|
|
|
82
70
|
|
|
83
71
|
|
|
84
72
|
;{
|
|
85
|
-
String.prototype
|
|
73
|
+
Object.defineProperty(String.prototype, "__class__", {"value": String, "enumerable": false, "writable": true});
|
|
86
74
|
String.__name__ = "String";
|
|
87
75
|
Array.__name__ = "Array";
|
|
88
76
|
Date.prototype.__class__ = Date;
|
package/bin/genes/Register.d.ts
CHANGED
package/bin/haxe/Constraints.js
CHANGED
|
@@ -27,7 +27,8 @@ class BytesBuffer extends Register.inherits() {
|
|
|
27
27
|
if (this.size == 0) {
|
|
28
28
|
return;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
var sub = new Uint8Array(src.b.buffer, src.b.byteOffset + pos, len);
|
|
31
|
+
this.u8.set(sub, this.pos);
|
|
31
32
|
this.pos += len;
|
|
32
33
|
}
|
|
33
34
|
grow(delta) {
|
package/bin/haxe/macro/Expr.d.ts
CHANGED
|
@@ -72,6 +72,10 @@ export type Var = {
|
|
|
72
72
|
*/
|
|
73
73
|
isFinal?: null | boolean,
|
|
74
74
|
/**
|
|
75
|
+
Whether or not the variable is static.
|
|
76
|
+
*/
|
|
77
|
+
isStatic?: null | boolean,
|
|
78
|
+
/**
|
|
75
79
|
Metadata associatied with the variable, if available.
|
|
76
80
|
*/
|
|
77
81
|
meta?: null | MetadataEntry[],
|
|
@@ -154,6 +158,10 @@ export type TypeParamDecl = {
|
|
|
154
158
|
*/
|
|
155
159
|
constraints?: null | ComplexType[],
|
|
156
160
|
/**
|
|
161
|
+
The optional default type of the type parameter.
|
|
162
|
+
*/
|
|
163
|
+
defaultType?: null | ComplexType,
|
|
164
|
+
/**
|
|
157
165
|
The metadata of the type parameter.
|
|
158
166
|
*/
|
|
159
167
|
meta?: null | MetadataEntry[],
|
package/bin/haxe/macro/Type.d.ts
CHANGED
package/bin/haxe/zip/Compress.js
CHANGED
|
@@ -9,7 +9,8 @@ export const Compress = Register.global("$hxClasses")["haxe.zip.Compress"] =
|
|
|
9
9
|
class Compress {
|
|
10
10
|
static run(s, level) {
|
|
11
11
|
var data = s.b;
|
|
12
|
-
|
|
12
|
+
var buffer = Zlib.deflateSync(Buffer.from(data.buffer, data.byteOffset, s.length), {"level": level});
|
|
13
|
+
return Helper.bytesOfBuffer(buffer);
|
|
13
14
|
}
|
|
14
15
|
static get __name__() {
|
|
15
16
|
return "haxe.zip.Compress"
|
package/bin/js/Boot.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
export declare class Boot {
|
|
3
3
|
protected static getClass(o: null | any): null | any
|
|
4
|
-
protected static __string_rec(o: {
|
|
4
|
+
protected static __string_rec(o: null | {
|
|
5
5
|
__enum__: boolean,
|
|
6
6
|
_hx_index: number,
|
|
7
|
-
hasOwnProperty: (arg0: string) => boolean,
|
|
7
|
+
hasOwnProperty: null | ((arg0: string) => boolean),
|
|
8
8
|
length: number,
|
|
9
9
|
toString: () => string
|
|
10
10
|
}, s: string): string
|
package/bin/js/lib/Promise.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export type ThenableStruct<T> = {
|
|
|
3
3
|
then: <TOut>(onFulfilled: null | ((arg0: T) => any), onRejected?: ((arg0: any) => any)) => ThenableStruct<TOut>
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
export type PromiseSettleOutcome = {
|
|
6
|
+
export type PromiseSettleOutcome<T> = {
|
|
7
7
|
reason?: null | any,
|
|
8
8
|
status: string,
|
|
9
|
-
value?: null |
|
|
9
|
+
value?: null | T
|
|
10
10
|
}
|
package/bin/js/node/Fs.d.ts
CHANGED
package/bin/js/node/Process.d.ts
CHANGED
package/bin/whet/Log.js
CHANGED
|
@@ -42,10 +42,10 @@ class Log {
|
|
|
42
42
|
};
|
|
43
43
|
} else {
|
|
44
44
|
var obj = arg;
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
while (
|
|
48
|
-
var key =
|
|
45
|
+
var _g_keys = Reflect__1.fields(obj);
|
|
46
|
+
var _g_index = 0;
|
|
47
|
+
while (_g_index < _g_keys.length) {
|
|
48
|
+
var key = _g_keys[_g_index++];
|
|
49
49
|
out[key] = obj[key];
|
|
50
50
|
};
|
|
51
51
|
};
|
package/bin/whet/Project.js
CHANGED
|
@@ -13,8 +13,7 @@ class Project extends Register.inherits() {
|
|
|
13
13
|
new(config) {
|
|
14
14
|
this.stones = [];
|
|
15
15
|
this.cache = null;
|
|
16
|
-
|
|
17
|
-
Log.log(20, ...this1);
|
|
16
|
+
Log.log(20, ...["Instantiating new Project."]);
|
|
18
17
|
if (config == null || config.name == null) {
|
|
19
18
|
throw new Error("Must supply config and a name.");
|
|
20
19
|
};
|
|
@@ -49,8 +48,7 @@ class Project extends Register.inherits() {
|
|
|
49
48
|
};
|
|
50
49
|
this.cache = (config.cache == null) ? new CacheManager(this) : config.cache;
|
|
51
50
|
Project.projects.push(this);
|
|
52
|
-
|
|
53
|
-
Log.log(30, ...this1);
|
|
51
|
+
Log.log(30, ...["New project created.", {"project": this, "projectCount": Project.projects.length}]);
|
|
54
52
|
}
|
|
55
53
|
addCommand(name, stone) {
|
|
56
54
|
var cmd = new Command(name);
|
package/bin/whet/Source.js
CHANGED
|
@@ -119,7 +119,7 @@ class SourceData extends Register.inherits() {
|
|
|
119
119
|
return new Promise(function (res, rej) {
|
|
120
120
|
Fs.readFile(path, function (err, buffer) {
|
|
121
121
|
if (err != null) {
|
|
122
|
-
Log.log(50, ...["File does not exist.", {"id": id, "path": path}]);
|
|
122
|
+
Log.log(50, ...["File does not exist.", {"id": id, "path": path, "error": err}]);
|
|
123
123
|
rej(err);
|
|
124
124
|
} else {
|
|
125
125
|
var source = SourceData.fromBytes(id, buffer);
|
package/bin/whet/SourceHash.js
CHANGED
|
@@ -112,8 +112,7 @@ class SourceHash extends Register.inherits() {
|
|
|
112
112
|
_g.push(x1);
|
|
113
113
|
};
|
|
114
114
|
};
|
|
115
|
-
|
|
116
|
-
return SourceHash.merge(...this1);
|
|
115
|
+
return SourceHash.merge(..._g);
|
|
117
116
|
});
|
|
118
117
|
}
|
|
119
118
|
static fromBytes(data) {
|
|
@@ -163,4 +162,8 @@ class SourceHash extends Register.inherits() {
|
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
|
|
166
|
-
SourceHash.EMPTY =
|
|
165
|
+
SourceHash.EMPTY = (function($this) {var $r0
|
|
166
|
+
var bytes = Buffer.alloc(32);
|
|
167
|
+
|
|
168
|
+
$r0 = new SourceHash(bytes)
|
|
169
|
+
return $r0})(this)
|
package/bin/whet/SourceId.d.ts
CHANGED
package/bin/whet/SourceId.js
CHANGED
|
@@ -110,6 +110,13 @@ class IdUtils {
|
|
|
110
110
|
var rootStr = Path.posix.resolve(root);
|
|
111
111
|
return Path.posix.relative(rootStr, absPath1);
|
|
112
112
|
}
|
|
113
|
+
static normalize(str) {
|
|
114
|
+
if (str.length > 0) {
|
|
115
|
+
str = Path.posix.normalize(str);
|
|
116
|
+
str = StringTools.replace(str, "\\", "/");
|
|
117
|
+
};
|
|
118
|
+
return str;
|
|
119
|
+
}
|
|
113
120
|
static get __name__() {
|
|
114
121
|
return "whet.IdUtils"
|
|
115
122
|
}
|
package/bin/whet/Utils.js
CHANGED
|
@@ -21,8 +21,7 @@ class Utils {
|
|
|
21
21
|
return unique;
|
|
22
22
|
}
|
|
23
23
|
static ensureDirExist(dir) {
|
|
24
|
-
|
|
25
|
-
Log.log(10, ...this1);
|
|
24
|
+
Log.log(10, ...["Ensuring directory " + dir + " exists."]);
|
|
26
25
|
return new Promise(function (res, rej) {
|
|
27
26
|
Fs.stat(dir, function (err, stats) {
|
|
28
27
|
if (err != null) {
|
package/bin/whet/Whet.js
CHANGED
|
@@ -12,7 +12,7 @@ const $global = Register.$global
|
|
|
12
12
|
export const Whet_Fields_ = Register.global("$hxClasses")["whet._Whet.Whet_Fields_"] =
|
|
13
13
|
class Whet_Fields_ {
|
|
14
14
|
static main() {
|
|
15
|
-
Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.
|
|
15
|
+
Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.25", "-v, --version").allowUnknownOption(true).showSuggestionAfterError(true).option("-p, --project <file>", "project to run", "Project.mjs").option("-l, --log-level <level>", "log level, a string/number", "info").option("--no-pretty", "disable pretty logging").exitOverride();
|
|
16
16
|
try {
|
|
17
17
|
Whet_Fields_.program.parse();
|
|
18
18
|
}catch (_g) {
|
|
@@ -47,7 +47,8 @@ class Whet_Fields_ {
|
|
|
47
47
|
Log.log(30, ...["Loading project.", {"file": options.project}]);
|
|
48
48
|
var path = Url.pathToFileURL(options.project).href;
|
|
49
49
|
Log.log(20, ...["Resolved project path.", {"path": path}]);
|
|
50
|
-
import(path)
|
|
50
|
+
var projectProm = import(path);
|
|
51
|
+
projectProm.then(function (module) {
|
|
51
52
|
Log.log(10, ...["Project module imported."]);
|
|
52
53
|
Whet_Fields_.initProjects();
|
|
53
54
|
})["catch"](function (e) {
|
|
@@ -123,14 +124,11 @@ class Whet_Fields_ {
|
|
|
123
124
|
var commands = [];
|
|
124
125
|
var from = 0;
|
|
125
126
|
var to;
|
|
126
|
-
|
|
127
|
+
do {
|
|
127
128
|
to = args.indexOf("+", from);
|
|
128
129
|
commands.push((to < 0) ? args.slice(from) : args.slice(from, to));
|
|
129
130
|
from = to + 1;
|
|
130
|
-
|
|
131
|
-
break;
|
|
132
|
-
};
|
|
133
|
-
};
|
|
131
|
+
} while (to >= 0);
|
|
134
132
|
return commands;
|
|
135
133
|
}
|
|
136
134
|
static get __name__() {
|
|
@@ -62,7 +62,7 @@ class BaseCache extends Register.inherits() {
|
|
|
62
62
|
_gthis.setRecentUseOrder(values, value);
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
var srcPromise = ((value != null) ? _gthis.source(stone, value) : Promise.resolve(null)).then(function (src) {
|
|
66
66
|
if (src == null) {
|
|
67
67
|
Log.log(10, ...["Not cached.", {"stone": stone, "cache": _gthis}]);
|
|
68
68
|
return ((value != null) ? _gthis.remove(stone, value) : Promise.resolve(null)).then(function (_) {
|
|
@@ -83,7 +83,8 @@ class BaseCache extends Register.inherits() {
|
|
|
83
83
|
Log.log(10, ...["Found in cache", {"stone": stone, "cache": _gthis}]);
|
|
84
84
|
return Promise.resolve(src);
|
|
85
85
|
};
|
|
86
|
-
})
|
|
86
|
+
});
|
|
87
|
+
return srcPromise.then(function (src) {
|
|
87
88
|
if ((check == null) ? true : check._hx_index == 0) {
|
|
88
89
|
_gthis.checkDurability(stone, values, durability, function (v) {
|
|
89
90
|
return values.indexOf(v);
|
package/bin/whet/cache/Cache.js
CHANGED
|
@@ -2,7 +2,8 @@ import {Register} from "../../genes/Register.js"
|
|
|
2
2
|
|
|
3
3
|
const $global = Register.$global
|
|
4
4
|
|
|
5
|
-
export const Cache = {}
|
|
5
|
+
export const Cache = function() {};
|
|
6
|
+
Cache.__isInterface__ = true;
|
|
6
7
|
|
|
7
8
|
export const CacheStrategy =
|
|
8
9
|
Register.global("$hxEnums")["whet.cache.CacheStrategy"] =
|
|
@@ -25,12 +25,12 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
25
25
|
var _g_index = 0;
|
|
26
26
|
while (_g_index < _g_keys.length) {
|
|
27
27
|
var key = _g_keys[_g_index++];
|
|
28
|
-
var
|
|
28
|
+
var _g_value = db[key];
|
|
29
29
|
var this1 = this.cache;
|
|
30
30
|
var _g = [];
|
|
31
31
|
var _g1 = 0;
|
|
32
|
-
while (_g1 <
|
|
33
|
-
var val =
|
|
32
|
+
while (_g1 < _g_value.length) {
|
|
33
|
+
var val = _g_value[_g1];
|
|
34
34
|
++_g1;
|
|
35
35
|
var tmp = SourceHash.fromHex(val.hash);
|
|
36
36
|
var val1 = val.ctime;
|
|
@@ -224,11 +224,11 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
224
224
|
var _g_keys = this1.keys();
|
|
225
225
|
while (_g_keys.hasNext()) {
|
|
226
226
|
var key = _g_keys.next();
|
|
227
|
-
var
|
|
227
|
+
var _g_value = this1.get(key);
|
|
228
228
|
var _g = [];
|
|
229
229
|
var _g1 = 0;
|
|
230
|
-
while (_g1 <
|
|
231
|
-
var val =
|
|
230
|
+
while (_g1 < _g_value.length) {
|
|
231
|
+
var val = _g_value[_g1];
|
|
232
232
|
++_g1;
|
|
233
233
|
var tmp = SourceHash.toHex(val.hash);
|
|
234
234
|
var val1 = val.ctime;
|
package/bin/whet/route/Router.js
CHANGED
|
@@ -281,11 +281,14 @@ class Filters {
|
|
|
281
281
|
};
|
|
282
282
|
var _g = 0;
|
|
283
283
|
var _g1 = f.filter.set;
|
|
284
|
-
while (_g < _g1.length)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
284
|
+
while (_g < _g1.length) {
|
|
285
|
+
var hit = f.filter.matchOne(f.pathSoFar, _g1[_g++], true);
|
|
286
|
+
if (hit) {
|
|
287
|
+
if (f.filter.options.flipNegate) {
|
|
288
|
+
return true;
|
|
289
|
+
} else {
|
|
290
|
+
return true != f.filter.negate;
|
|
291
|
+
};
|
|
289
292
|
};
|
|
290
293
|
};
|
|
291
294
|
if (f.filter.options.flipNegate) {
|
|
@@ -10,6 +10,7 @@ export declare class RemoteFile extends Stone<RemoteFileConfig> {
|
|
|
10
10
|
constructor(config: RemoteFileConfig)
|
|
11
11
|
protected initConfig(): void
|
|
12
12
|
protected generate(hash: SourceHash): Promise<SourceData[]>
|
|
13
|
+
protected get(url: string, res: ((arg0: SourceData[]) => void), rej: ((reason: any) => void)): void
|
|
13
14
|
list(): Promise<string[]>
|
|
14
15
|
generateHash(): Promise<SourceHash>
|
|
15
16
|
protected getId(): string
|
|
@@ -25,19 +25,27 @@ class RemoteFile extends Register.inherits(Stone) {
|
|
|
25
25
|
var _gthis = this;
|
|
26
26
|
Log.log(30, ...["Downloading file.", {"url": this.config.url}]);
|
|
27
27
|
return new Promise(function (res, rej) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
_gthis.get(_gthis.config.url, res, rej);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
get(url, res, rej) {
|
|
32
|
+
var _gthis = this;
|
|
33
|
+
Https.get(url, function (response) {
|
|
34
|
+
if (response.statusCode == 301 || response.statusCode == 302) {
|
|
35
|
+
_gthis.get(response.headers["location"], res, rej);
|
|
36
|
+
return;
|
|
37
|
+
};
|
|
38
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
39
|
+
response.resume();
|
|
40
|
+
throw new Error("Error downloading file. " + response.statusCode + " – " + response.statusMessage);
|
|
41
|
+
};
|
|
42
|
+
var bufs = [];
|
|
43
|
+
response.on("data", function (d) {
|
|
44
|
+
return bufs.push(d);
|
|
45
|
+
});
|
|
46
|
+
response.on("end", function () {
|
|
47
|
+
var data = Buffer.concat(bufs);
|
|
48
|
+
res([SourceData.fromBytes(_gthis.getId(), data)]);
|
|
41
49
|
});
|
|
42
50
|
});
|
|
43
51
|
}
|
|
@@ -31,7 +31,17 @@ class Server extends Register.inherits(Stone) {
|
|
|
31
31
|
*/
|
|
32
32
|
serve() {
|
|
33
33
|
var _gthis = this;
|
|
34
|
-
Http.createServer(Register.bind(this, this.handler))
|
|
34
|
+
var server = Http.createServer(Register.bind(this, this.handler));
|
|
35
|
+
var nextRetry = 500;
|
|
36
|
+
server.on("error", function (err) {
|
|
37
|
+
Log.log(50, ...["Failed to open a server. Retrying in " + nextRetry + "ms.", {"error": err}]);
|
|
38
|
+
global.setTimeout(function () {
|
|
39
|
+
server.listen(_gthis.config.port);
|
|
40
|
+
}, nextRetry);
|
|
41
|
+
nextRetry *= 2;
|
|
42
|
+
return nextRetry;
|
|
43
|
+
});
|
|
44
|
+
server.listen(this.config.port, function () {
|
|
35
45
|
Log.log(30, ...["Started web server.", {"port": _gthis.config.port}]);
|
|
36
46
|
});
|
|
37
47
|
}
|
|
@@ -69,7 +79,8 @@ class Server extends Register.inherits(Stone) {
|
|
|
69
79
|
id = "" + id + "/index.html";
|
|
70
80
|
};
|
|
71
81
|
this.config.router.get(id).then(function (routeResult) {
|
|
72
|
-
|
|
82
|
+
var sourcePromise = (routeResult.length > 0) ? routeResult[0].get() : (_gthis.routeDynamic != null) ? _gthis.routeDynamic(id) : Promise.resolve(null);
|
|
83
|
+
return sourcePromise.then(function (source) {
|
|
73
84
|
if (source == null) {
|
|
74
85
|
res.writeHead(404, "File not found.");
|
|
75
86
|
res.end();
|
package/bin/whet/stones/Zip.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ import {Project} from "../Project"
|
|
|
10
10
|
export declare class ZipStone extends Stone<ZipConfig> {
|
|
11
11
|
constructor(config: ZipConfig)
|
|
12
12
|
protected initConfig(): void
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
Keep last used 5 for a day and last used 1 indefinitely.
|
|
16
|
+
*/
|
|
13
17
|
protected generateHash(): Promise<SourceHash>
|
|
14
18
|
protected generate(hash: SourceHash): Promise<SourceData[]>
|
|
15
19
|
list(): Promise<string[]>
|
package/bin/whet/stones/Zip.js
CHANGED
|
@@ -31,6 +31,10 @@ class ZipStone extends Register.inherits(Stone) {
|
|
|
31
31
|
this.config.cacheStrategy = CacheStrategy.InFile(CacheDurability.Any([CacheDurability.LimitCountByLastUse(1), CacheDurability.All([CacheDurability.MaxAge(86400), CacheDurability.LimitCountByLastUse(5)])]), DurabilityCheck.AllOnUse);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
Keep last used 5 for a day and last used 1 indefinitely.
|
|
37
|
+
*/
|
|
34
38
|
generateHash() {
|
|
35
39
|
var _gthis = this;
|
|
36
40
|
return this.config.sources.getHash().then(function (hash) {
|