whet 0.0.8 → 0.0.11
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/whet/Project.js +21 -10
- package/bin/whet/Source.d.ts +8 -1
- package/bin/whet/Source.js +26 -11
- package/bin/whet/SourceId.d.ts +1 -0
- package/bin/whet/SourceId.js +46 -20
- package/bin/whet/Stone.d.ts +17 -2
- package/bin/whet/Stone.js +62 -27
- package/bin/whet/Whet.js +1 -1
- package/bin/whet/cache/BaseCache.js +16 -8
- package/bin/whet/cache/CacheManager.d.ts +5 -0
- package/bin/whet/cache/CacheManager.js +53 -13
- package/bin/whet/cache/FileCache.js +64 -29
- package/bin/whet/magic/RoutePathType.js +7 -4
- package/bin/whet/magic/RouteType.js +29 -13
- package/bin/whet/route/Route.js +27 -7
- package/bin/whet/route/Router.js +34 -17
- package/bin/whet/stones/Files.d.ts +19 -3
- package/bin/whet/stones/Files.js +54 -59
- package/bin/whet/stones/JsonStone.d.ts +12 -1
- package/bin/whet/stones/JsonStone.js +7 -4
- package/bin/whet/stones/RemoteFile.d.ts +13 -1
- package/bin/whet/stones/RemoteFile.js +7 -4
- package/bin/whet/stones/Server.d.ts +13 -1
- package/bin/whet/stones/Server.js +53 -30
- package/bin/whet/stones/Zip.d.ts +13 -1
- package/bin/whet/stones/Zip.js +14 -7
- package/bin/whet/stones/haxe/HaxeBuild.d.ts +13 -1
- package/bin/whet/stones/haxe/HaxeBuild.js +16 -8
- package/bin/whet/stones/haxe/Hxml.d.ts +12 -1
- package/bin/whet/stones/haxe/Hxml.js +43 -19
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {BaseCache} from "./BaseCache.js"
|
|
2
2
|
import {Utils} from "../Utils.js"
|
|
3
|
-
import {SourceId_Fields_} from "../SourceId.js"
|
|
4
3
|
import {SourceHash} from "../SourceHash.js"
|
|
5
4
|
import {SourceData, Source} from "../Source.js"
|
|
6
5
|
import {Log} from "../Log.js"
|
|
@@ -21,9 +20,13 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
21
20
|
this.flushQueued = false;
|
|
22
21
|
super.new(rootDir, new StringMap());
|
|
23
22
|
var s = ".whet/cache.json";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
var str = (".whet/cache.json".length > 1 && HxOverrides.cca(".whet/cache.json", 0) == 47) ? ".whet/cache.json".substring(1) : ".whet/cache.json";
|
|
24
|
+
if (str.length > 0) {
|
|
25
|
+
str = Path.posix.normalize(str);
|
|
26
|
+
str = StringTools.replace(str, "\\", "/");
|
|
27
|
+
};
|
|
28
|
+
s = str;
|
|
29
|
+
var this1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
27
30
|
if (this1.charAt(0) != "/") {
|
|
28
31
|
throw new Error("Badly formed SourceId.");
|
|
29
32
|
};
|
|
@@ -44,9 +47,13 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
44
47
|
var tmp = SourceHash.fromHex(val.hash);
|
|
45
48
|
var val1 = val.ctime;
|
|
46
49
|
var s = val.baseDir;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
51
|
+
if (str.length > 0) {
|
|
52
|
+
str = Path.posix.normalize(str);
|
|
53
|
+
str = StringTools.replace(str, "\\", "/");
|
|
54
|
+
};
|
|
55
|
+
s = str;
|
|
56
|
+
var tmp1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
50
57
|
var _g2 = [];
|
|
51
58
|
var _g3 = 0;
|
|
52
59
|
var _g4 = val.files;
|
|
@@ -55,13 +62,21 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
55
62
|
++_g3;
|
|
56
63
|
var tmp2 = SourceHash.fromHex(file.fileHash);
|
|
57
64
|
var s1 = file.filePath;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
var str1 = (s1.length > 1 && HxOverrides.cca(s1, 0) == 47) ? s1.substring(1) : s1;
|
|
66
|
+
if (str1.length > 0) {
|
|
67
|
+
str1 = Path.posix.normalize(str1);
|
|
68
|
+
str1 = StringTools.replace(str1, "\\", "/");
|
|
69
|
+
};
|
|
70
|
+
s1 = str1;
|
|
71
|
+
var tmp3 = (HxOverrides.cca(s1, 0) == 47) ? s1 : "/" + s1;
|
|
61
72
|
var s2 = file.id;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
var str2 = (s2.length > 1 && HxOverrides.cca(s2, 0) == 47) ? s2.substring(1) : s2;
|
|
74
|
+
if (str2.length > 0) {
|
|
75
|
+
str2 = Path.posix.normalize(str2);
|
|
76
|
+
str2 = StringTools.replace(str2, "\\", "/");
|
|
77
|
+
};
|
|
78
|
+
s2 = str2;
|
|
79
|
+
_g2.push({"fileHash": tmp2, "filePath": tmp3, "id": (HxOverrides.cca(s2, 0) == 47) ? s2 : "/" + s2});
|
|
65
80
|
};
|
|
66
81
|
_g.push({"hash": tmp, "ctime": val1, "baseDir": tmp1, "files": _g2});
|
|
67
82
|
};
|
|
@@ -80,9 +95,13 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
80
95
|
var _g1 = _g.path;
|
|
81
96
|
if (source.data.length == 1) {
|
|
82
97
|
var s = _g1.substring(_g1.lastIndexOf("/"));
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
98
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
99
|
+
if (str.length > 0) {
|
|
100
|
+
str = Path.posix.normalize(str);
|
|
101
|
+
str = StringTools.replace(str, "\\", "/");
|
|
102
|
+
};
|
|
103
|
+
s = str;
|
|
104
|
+
idOverride = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
86
105
|
} else {
|
|
87
106
|
idOverride = null;
|
|
88
107
|
};
|
|
@@ -111,14 +130,18 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
111
130
|
if (_g._hx_index == 3) {
|
|
112
131
|
var _g1 = _g.path;
|
|
113
132
|
var invalidPath;
|
|
114
|
-
if (value.files.length == 1 &&
|
|
133
|
+
if (value.files.length == 1 && HxOverrides.cca(_g1, _g1.length - 1) != 47) {
|
|
115
134
|
invalidPath = value.files[0].filePath != _g1;
|
|
116
135
|
} else {
|
|
117
136
|
var value1 = value.baseDir;
|
|
118
137
|
var s = _g1.substring(0, _g1.lastIndexOf("/") + 1);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
138
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
139
|
+
if (str.length > 0) {
|
|
140
|
+
str = Path.posix.normalize(str);
|
|
141
|
+
str = StringTools.replace(str, "\\", "/");
|
|
142
|
+
};
|
|
143
|
+
s = str;
|
|
144
|
+
invalidPath = value1 != ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
|
|
122
145
|
};
|
|
123
146
|
if (invalidPath) {
|
|
124
147
|
return Promise.resolve(null);
|
|
@@ -292,9 +315,13 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
292
315
|
var tmp1 = HxOverrides.dateStr(new Date(val.ctime * 1000));
|
|
293
316
|
var this2 = val.baseDir;
|
|
294
317
|
var s = "/";
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
318
|
+
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
319
|
+
if (str.length > 0) {
|
|
320
|
+
str = Path.posix.normalize(str);
|
|
321
|
+
str = StringTools.replace(str, "\\", "/");
|
|
322
|
+
};
|
|
323
|
+
s = str;
|
|
324
|
+
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
298
325
|
if (this2.charAt(0) != "/") {
|
|
299
326
|
throw new Error("Badly formed SourceId.");
|
|
300
327
|
};
|
|
@@ -308,18 +335,26 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
308
335
|
var tmp3 = SourceHash.toHex(file.fileHash);
|
|
309
336
|
var this3 = file.filePath;
|
|
310
337
|
var s1 = "/";
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
338
|
+
var str1 = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
339
|
+
if (str1.length > 0) {
|
|
340
|
+
str1 = Path.posix.normalize(str1);
|
|
341
|
+
str1 = StringTools.replace(str1, "\\", "/");
|
|
342
|
+
};
|
|
343
|
+
s1 = str1;
|
|
344
|
+
var root1 = (HxOverrides.cca(s1, 0) == 47) ? s1 : "/" + s1;
|
|
314
345
|
if (this3.charAt(0) != "/") {
|
|
315
346
|
throw new Error("Badly formed SourceId.");
|
|
316
347
|
};
|
|
317
348
|
var tmp4 = Path.posix.join(".", root1, ".", this3);
|
|
318
349
|
var this4 = file.id;
|
|
319
350
|
var s2 = "/";
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
351
|
+
var str2 = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
352
|
+
if (str2.length > 0) {
|
|
353
|
+
str2 = Path.posix.normalize(str2);
|
|
354
|
+
str2 = StringTools.replace(str2, "\\", "/");
|
|
355
|
+
};
|
|
356
|
+
s2 = str2;
|
|
357
|
+
var root2 = (HxOverrides.cca(s2, 0) == 47) ? s2 : "/" + s2;
|
|
323
358
|
if (this4.charAt(0) != "/") {
|
|
324
359
|
throw new Error("Badly formed SourceId.");
|
|
325
360
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {Router} from "../route/Router.js"
|
|
2
2
|
import {Route} from "../route/Route.js"
|
|
3
3
|
import {RouteType_Fields_} from "./RouteType.js"
|
|
4
|
-
import {SourceId_Fields_} from "../SourceId.js"
|
|
5
4
|
import * as Path from "path"
|
|
6
5
|
import {Register} from "../../genes/Register.js"
|
|
7
6
|
import {StringTools} from "../../StringTools.js"
|
|
@@ -34,9 +33,13 @@ class RoutePathType_Fields_ {
|
|
|
34
33
|
throw new Error("RoutePath element should have at most 3 entries `[serveId, route, filter]`.");
|
|
35
34
|
};
|
|
36
35
|
var s = item[0];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
37
|
+
if (str.length > 0) {
|
|
38
|
+
str = Path.posix.normalize(str);
|
|
39
|
+
str = StringTools.replace(str, "\\", "/");
|
|
40
|
+
};
|
|
41
|
+
s = str;
|
|
42
|
+
var tmp = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
40
43
|
var _g3 = item.slice(1);
|
|
41
44
|
_g.push({"routeUnder": tmp, "route": (_g3.length == 1) ? (((item[1]) instanceof Route)) ? item[1] : RouteType_Fields_.makeRoute([_g3]) : RouteType_Fields_.makeRoute([_g3])});
|
|
42
45
|
};
|
|
@@ -3,7 +3,7 @@ import {RouteResult} from "../route/RouteResult.js"
|
|
|
3
3
|
import {Route} from "../route/Route.js"
|
|
4
4
|
import {MaybeArray_Fields_} from "./MaybeArray.js"
|
|
5
5
|
import {Stone} from "../Stone.js"
|
|
6
|
-
import {
|
|
6
|
+
import {SourceId} from "../SourceId.js"
|
|
7
7
|
import * as Path from "path"
|
|
8
8
|
import {Register} from "../../genes/Register.js"
|
|
9
9
|
import {StringTools} from "../../StringTools.js"
|
|
@@ -35,9 +35,13 @@ class RouteType_Fields_ {
|
|
|
35
35
|
};
|
|
36
36
|
var tinner1 = tinner[0];
|
|
37
37
|
var s = tinner[1];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
39
|
+
if (str.length > 0) {
|
|
40
|
+
str = Path.posix.normalize(str);
|
|
41
|
+
str = StringTools.replace(str, "\\", "/");
|
|
42
|
+
};
|
|
43
|
+
s = str;
|
|
44
|
+
_g.push(RouteType_Fields_.getRoute(tinner1, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s));
|
|
41
45
|
};
|
|
42
46
|
};
|
|
43
47
|
return _g;
|
|
@@ -50,13 +54,21 @@ class RouteType_Fields_ {
|
|
|
50
54
|
tmp1 = path;
|
|
51
55
|
} else {
|
|
52
56
|
var s = t;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
58
|
+
if (str.length > 0) {
|
|
59
|
+
str = Path.posix.normalize(str);
|
|
60
|
+
str = StringTools.replace(str, "\\", "/");
|
|
61
|
+
};
|
|
62
|
+
s = str;
|
|
63
|
+
var p = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
56
64
|
var s = p.substring(0, p.lastIndexOf("/") + 1);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
66
|
+
if (str.length > 0) {
|
|
67
|
+
str = Path.posix.normalize(str);
|
|
68
|
+
str = StringTools.replace(str, "\\", "/");
|
|
69
|
+
};
|
|
70
|
+
s = str;
|
|
71
|
+
tmp1 = SourceId.relativeTo(p, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
|
|
60
72
|
};
|
|
61
73
|
return {"stone": tmp, "path": tmp1};
|
|
62
74
|
} else if (((t) instanceof Stone)) {
|
|
@@ -65,9 +77,13 @@ class RouteType_Fields_ {
|
|
|
65
77
|
tmp = path;
|
|
66
78
|
} else {
|
|
67
79
|
var s = "/";
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
81
|
+
if (str.length > 0) {
|
|
82
|
+
str = Path.posix.normalize(str);
|
|
83
|
+
str = StringTools.replace(str, "\\", "/");
|
|
84
|
+
};
|
|
85
|
+
s = str;
|
|
86
|
+
tmp = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
71
87
|
};
|
|
72
88
|
return {"stone": t, "path": tmp};
|
|
73
89
|
} else if (((t) instanceof RouteResult)) {
|
package/bin/whet/route/Route.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {RouteResult} from "./RouteResult.js"
|
|
2
2
|
import {RouteType_Fields_} from "../magic/RouteType.js"
|
|
3
|
-
import {
|
|
3
|
+
import {SourceId} from "../SourceId.js"
|
|
4
4
|
import {SourceHash} from "../SourceHash.js"
|
|
5
5
|
import * as Path from "path"
|
|
6
6
|
import {Register} from "../../genes/Register.js"
|
|
@@ -43,13 +43,29 @@ class Route extends Register.inherits() {
|
|
|
43
43
|
_g.push(r[0].stone.list().then((function (r) {
|
|
44
44
|
return function (list) {
|
|
45
45
|
var arr = [];
|
|
46
|
-
|
|
46
|
+
var this1 = r[0].path;
|
|
47
|
+
if (HxOverrides.cca(this1, this1.length - 1) == 47) {
|
|
47
48
|
var _g = 0;
|
|
48
49
|
while (_g < list.length) {
|
|
49
50
|
var path = list[_g];
|
|
50
51
|
++_g;
|
|
51
|
-
var
|
|
52
|
-
|
|
52
|
+
var directory = r[0].path;
|
|
53
|
+
if (HxOverrides.cca(directory, directory.length - 1) != 47) {
|
|
54
|
+
throw new Error("\"" + directory + "\" is not a directory.");
|
|
55
|
+
};
|
|
56
|
+
var tmp;
|
|
57
|
+
var s = path.substring(0, path.lastIndexOf("/") + 1);
|
|
58
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
59
|
+
if (str.length > 0) {
|
|
60
|
+
str = Path.posix.normalize(str);
|
|
61
|
+
str = StringTools.replace(str, "\\", "/");
|
|
62
|
+
};
|
|
63
|
+
s = str;
|
|
64
|
+
tmp = ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s).indexOf(directory) == 0;
|
|
65
|
+
if (tmp) {
|
|
66
|
+
var _g1 = r[0].stone;
|
|
67
|
+
arr.push(new RouteResult(SourceId.relativeTo(path, r[0].path), path, _g1));
|
|
68
|
+
};
|
|
53
69
|
};
|
|
54
70
|
} else {
|
|
55
71
|
var _g = 0;
|
|
@@ -59,9 +75,13 @@ class Route extends Register.inherits() {
|
|
|
59
75
|
if (path == r[0].path) {
|
|
60
76
|
var _g1 = r[0].stone;
|
|
61
77
|
var s = path.substring(path.lastIndexOf("/"));
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
79
|
+
if (str.length > 0) {
|
|
80
|
+
str = Path.posix.normalize(str);
|
|
81
|
+
str = StringTools.replace(str, "\\", "/");
|
|
82
|
+
};
|
|
83
|
+
s = str;
|
|
84
|
+
arr.push(new RouteResult((HxOverrides.cca(s, 0) == 47) ? s : "/" + s, path, _g1));
|
|
65
85
|
};
|
|
66
86
|
};
|
|
67
87
|
};
|
package/bin/whet/route/Router.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {RoutePathType_Fields_} from "../magic/RoutePathType.js"
|
|
2
2
|
import {Utils} from "../Utils.js"
|
|
3
|
-
import {
|
|
3
|
+
import {SourceId} from "../SourceId.js"
|
|
4
4
|
import {SourceHash} from "../SourceHash.js"
|
|
5
5
|
import * as Path from "path"
|
|
6
6
|
import {Register} from "../../genes/Register.js"
|
|
@@ -27,12 +27,16 @@ class Router extends Register.inherits() {
|
|
|
27
27
|
find(id, firstOnly) {
|
|
28
28
|
var _gthis = this;
|
|
29
29
|
var s = id;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
var str = (id.length > 1 && HxOverrides.cca(id, 0) == 47) ? id.substring(1) : id;
|
|
31
|
+
if (str.length > 0) {
|
|
32
|
+
str = Path.posix.normalize(str);
|
|
33
|
+
str = StringTools.replace(str, "\\", "/");
|
|
34
|
+
};
|
|
35
|
+
s = str;
|
|
36
|
+
var sourceId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
33
37
|
return new Promise(function (res, rej) {
|
|
34
38
|
if (firstOnly == null) {
|
|
35
|
-
firstOnly =
|
|
39
|
+
firstOnly = HxOverrides.cca(sourceId, sourceId.length - 1) != 47;
|
|
36
40
|
};
|
|
37
41
|
var result = [];
|
|
38
42
|
var _g = [];
|
|
@@ -43,13 +47,14 @@ class Router extends Register.inherits() {
|
|
|
43
47
|
++_g1;
|
|
44
48
|
_g.push(path[0].route.list().then((function (path) {
|
|
45
49
|
return function (list) {
|
|
46
|
-
|
|
50
|
+
var this1 = path[0].routeUnder;
|
|
51
|
+
if (HxOverrides.cca(this1, this1.length - 1) == 47) {
|
|
47
52
|
var _g = 0;
|
|
48
53
|
while (_g < list.length) {
|
|
49
54
|
var item = list[_g];
|
|
50
55
|
++_g;
|
|
51
56
|
item.serveId = SourceId.getPutInDir(item.serveId, path[0].routeUnder);
|
|
52
|
-
if (
|
|
57
|
+
if (HxOverrides.cca(sourceId, sourceId.length - 1) == 47) {
|
|
53
58
|
var rel = SourceId.relativeTo(item.serveId, sourceId);
|
|
54
59
|
if (rel != null) {
|
|
55
60
|
item.serveId = rel;
|
|
@@ -57,9 +62,13 @@ class Router extends Register.inherits() {
|
|
|
57
62
|
};
|
|
58
63
|
} else if (sourceId == item.serveId) {
|
|
59
64
|
var s = sourceId.substring(sourceId.lastIndexOf("/"));
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
66
|
+
if (str.length > 0) {
|
|
67
|
+
str = Path.posix.normalize(str);
|
|
68
|
+
str = StringTools.replace(str, "\\", "/");
|
|
69
|
+
};
|
|
70
|
+
s = str;
|
|
71
|
+
item.serveId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
63
72
|
result.push(item);
|
|
64
73
|
};
|
|
65
74
|
};
|
|
@@ -69,7 +78,7 @@ class Router extends Register.inherits() {
|
|
|
69
78
|
var item = list[_g];
|
|
70
79
|
++_g;
|
|
71
80
|
item.serveId = path[0].routeUnder;
|
|
72
|
-
if (
|
|
81
|
+
if (HxOverrides.cca(sourceId, sourceId.length - 1) == 47) {
|
|
73
82
|
var rel = SourceId.relativeTo(item.serveId, sourceId);
|
|
74
83
|
if (rel != null) {
|
|
75
84
|
item.serveId = rel;
|
|
@@ -77,9 +86,13 @@ class Router extends Register.inherits() {
|
|
|
77
86
|
};
|
|
78
87
|
} else if (sourceId == item.serveId) {
|
|
79
88
|
var s = sourceId.substring(sourceId.lastIndexOf("/"));
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
90
|
+
if (str.length > 0) {
|
|
91
|
+
str = Path.posix.normalize(str);
|
|
92
|
+
str = StringTools.replace(str, "\\", "/");
|
|
93
|
+
};
|
|
94
|
+
s = str;
|
|
95
|
+
item.serveId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
83
96
|
result.push(item);
|
|
84
97
|
};
|
|
85
98
|
};
|
|
@@ -165,9 +178,13 @@ class Router extends Register.inherits() {
|
|
|
165
178
|
var saveInto1 = saveInto;
|
|
166
179
|
var this1 = r.serveId;
|
|
167
180
|
var s = "/";
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
181
|
+
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
182
|
+
if (str.length > 0) {
|
|
183
|
+
str = Path.posix.normalize(str);
|
|
184
|
+
str = StringTools.replace(str, "\\", "/");
|
|
185
|
+
};
|
|
186
|
+
s = str;
|
|
187
|
+
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
171
188
|
if (this1.charAt(0) != "/") {
|
|
172
189
|
throw new Error("Badly formed SourceId.");
|
|
173
190
|
};
|
|
@@ -1,28 +1,44 @@
|
|
|
1
1
|
import {StoneIdType} from "../magic/StoneId"
|
|
2
2
|
import {MaybeArray} from "../magic/MaybeArray"
|
|
3
3
|
import {CacheStrategy} from "../cache/Cache"
|
|
4
|
-
import {Stone} from "../Stone"
|
|
4
|
+
import {Stone, AnyStone} from "../Stone"
|
|
5
5
|
import {SourceHash} from "../SourceHash"
|
|
6
6
|
import {SourceData} from "../Source"
|
|
7
7
|
import {Project} from "../Project"
|
|
8
8
|
|
|
9
9
|
export declare class Files extends Stone<FilesConfig> {
|
|
10
10
|
constructor(config: FilesConfig)
|
|
11
|
+
protected initConfig(): void
|
|
11
12
|
protected generate(hash: SourceHash): Promise<SourceData[]>
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export type FilesConfig = {
|
|
15
16
|
cacheStrategy?: null | CacheStrategy,
|
|
16
17
|
/**
|
|
18
|
+
* Registers another stone as dependency of this one. Useful for external processes
|
|
19
|
+
* that use a source of some stone, but don't go via Whet to get it.
|
|
20
|
+
* Use with combination of `setAbsolutePath` on the dependency, so that the external process
|
|
21
|
+
* can rely on fixed path.
|
|
22
|
+
* Will make sure the cached file is up to date when generating this stone.
|
|
23
|
+
* Hash of the dependency is automatically combined with hash generated by this stone. There's no
|
|
24
|
+
* need to add it manually.
|
|
25
|
+
* Do not create cyclic dependencies!
|
|
26
|
+
*/
|
|
27
|
+
dependencies?: null | MaybeArray<AnyStone>,
|
|
28
|
+
/**
|
|
17
29
|
Defaults to the Stone's class name.
|
|
18
30
|
*/
|
|
19
31
|
id?: null | StoneIdType,
|
|
20
32
|
/**
|
|
21
|
-
Can be either a file, or a directory
|
|
33
|
+
Can be either a file, or a directory.
|
|
22
34
|
*/
|
|
23
35
|
paths: MaybeArray<string>,
|
|
24
36
|
/**
|
|
25
37
|
Defaults to the last instanced project.
|
|
26
38
|
*/
|
|
27
|
-
project?: null | Project
|
|
39
|
+
project?: null | Project,
|
|
40
|
+
/**
|
|
41
|
+
Whether to recurse directories. Defaults to `true`.
|
|
42
|
+
*/
|
|
43
|
+
recursive?: null | boolean
|
|
28
44
|
}
|
package/bin/whet/stones/Files.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {MaybeArray_Fields_} from "../magic/MaybeArray.js"
|
|
2
|
+
import {Utils} from "../Utils.js"
|
|
2
3
|
import {Stone} from "../Stone.js"
|
|
3
4
|
import {SourceId_Fields_, RootDir, SourceId} from "../SourceId.js"
|
|
4
5
|
import {SourceData} from "../Source.js"
|
|
5
6
|
import * as Path from "path"
|
|
6
7
|
import {Register} from "../../genes/Register.js"
|
|
7
|
-
import * as Fs from "fs"
|
|
8
8
|
import {StringTools} from "../../StringTools.js"
|
|
9
9
|
import {HxOverrides} from "../../HxOverrides.js"
|
|
10
10
|
|
|
@@ -15,72 +15,67 @@ class Files extends Register.inherits(Stone) {
|
|
|
15
15
|
new(config) {
|
|
16
16
|
super.new(config);
|
|
17
17
|
}
|
|
18
|
+
initConfig() {
|
|
19
|
+
this.config.recursive = true;
|
|
20
|
+
}
|
|
18
21
|
generate(hash) {
|
|
19
22
|
var _gthis = this;
|
|
20
|
-
var _g =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
var _g = [];
|
|
24
|
+
var _g1 = 0;
|
|
25
|
+
var _g2 = MaybeArray_Fields_.makeArray(this.config.paths);
|
|
26
|
+
while (_g1 < _g2.length) {
|
|
27
|
+
var pathString = _g2[_g1];
|
|
28
|
+
++_g1;
|
|
23
29
|
var s = pathString;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var file = files[_g1];
|
|
45
|
-
++_g1;
|
|
46
|
-
var s = file;
|
|
47
|
-
s = Path.posix.normalize((file.length > 1 && SourceId_Fields_.startsWithSlash(file)) ? HxOverrides.substr(file, 1, null) : file);
|
|
48
|
-
s = StringTools.replace(s, "\\", "/");
|
|
49
|
-
var filepath = SourceId.getPutInDir((SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s, path[0]);
|
|
50
|
-
_g.push({"id": SourceId.relativeTo(filepath, path[0]), "pathId": filepath});
|
|
51
|
-
};
|
|
52
|
-
res1(_g);
|
|
53
|
-
};
|
|
30
|
+
var str = (pathString.length > 1 && HxOverrides.cca(pathString, 0) == 47) ? pathString.substring(1) : pathString;
|
|
31
|
+
if (str.length > 0) {
|
|
32
|
+
str = Path.posix.normalize(str);
|
|
33
|
+
str = StringTools.replace(str, "\\", "/");
|
|
34
|
+
};
|
|
35
|
+
s = str;
|
|
36
|
+
var path = [(HxOverrides.cca(s, 0) == 47) ? s : "/" + s];
|
|
37
|
+
if (HxOverrides.cca(path[0], path[0].length - 1) == 47) {
|
|
38
|
+
_g.push(Utils.listDirectoryFiles(this.cwdPath(pathString), this.config.recursive).then((function (path) {
|
|
39
|
+
return function (arr) {
|
|
40
|
+
var _g = [];
|
|
41
|
+
var _g1 = 0;
|
|
42
|
+
while (_g1 < arr.length) {
|
|
43
|
+
var file = arr[_g1];
|
|
44
|
+
++_g1;
|
|
45
|
+
var s = SourceId_Fields_.fromCwdPath(file, RootDir.fromProject(_gthis.project));
|
|
46
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
47
|
+
if (str.length > 0) {
|
|
48
|
+
str = Path.posix.normalize(str);
|
|
49
|
+
str = StringTools.replace(str, "\\", "/");
|
|
54
50
|
};
|
|
55
|
-
|
|
51
|
+
s = str;
|
|
52
|
+
var pathId = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
53
|
+
_g.push(SourceData.fromFile(SourceId.relativeTo(pathId, path[0]), file, pathId));
|
|
54
|
+
};
|
|
55
|
+
return _g;
|
|
56
|
+
};
|
|
57
|
+
})(path)).then((function () {
|
|
58
|
+
return function (f) {
|
|
59
|
+
return Promise.all(f);
|
|
56
60
|
};
|
|
57
|
-
})(
|
|
61
|
+
})()));
|
|
58
62
|
} else {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
tmp = Promise.resolve([{"id": (SourceId_Fields_.startsWithSlash(s1)) ? s1 : "/" + s1, "pathId": path[0]}]);
|
|
63
|
-
};
|
|
64
|
-
return tmp.then((function () {
|
|
65
|
-
return function (files) {
|
|
66
|
-
var _g = [];
|
|
67
|
-
var _g1 = 0;
|
|
68
|
-
while (_g1 < files.length) {
|
|
69
|
-
var f = files[_g1];
|
|
70
|
-
++_g1;
|
|
71
|
-
var f1 = f.id;
|
|
72
|
-
var this1 = f.pathId;
|
|
73
|
-
var root = RootDir.fromProject(_gthis.project);
|
|
74
|
-
if (this1.charAt(0) != "/") {
|
|
75
|
-
throw new Error("Badly formed SourceId.");
|
|
76
|
-
};
|
|
77
|
-
_g.push(SourceData.fromFile(f1, Path.posix.join(".", root, ".", this1), f.pathId));
|
|
63
|
+
_g.push(SourceData.fromFile(path[0].substring(path[0].lastIndexOf("/")), this.cwdPath(path[0]), path[0]).then((function () {
|
|
64
|
+
return function (src) {
|
|
65
|
+
return [src];
|
|
78
66
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
})());
|
|
67
|
+
})()));
|
|
68
|
+
};
|
|
82
69
|
};
|
|
83
|
-
return
|
|
70
|
+
return Promise.all(_g).then(function (allSources) {
|
|
71
|
+
var _g = [];
|
|
72
|
+
var _g_current = 0;
|
|
73
|
+
while (_g_current < allSources.length) {
|
|
74
|
+
var x = Register.iter(allSources[_g_current++]);
|
|
75
|
+
while (x.hasNext()) _g.push(x.next());
|
|
76
|
+
};
|
|
77
|
+
return _g;
|
|
78
|
+
});
|
|
84
79
|
}
|
|
85
80
|
static get __name__() {
|
|
86
81
|
return "whet.stones.Files"
|
|
@@ -2,7 +2,7 @@ import {StoneIdType} from "../magic/StoneId"
|
|
|
2
2
|
import {RouteType} from "../magic/RouteType"
|
|
3
3
|
import {MaybeArray} from "../magic/MaybeArray"
|
|
4
4
|
import {CacheStrategy} from "../cache/Cache"
|
|
5
|
-
import {Stone} from "../Stone"
|
|
5
|
+
import {Stone, AnyStone} from "../Stone"
|
|
6
6
|
import {SourceHash} from "../SourceHash"
|
|
7
7
|
import {SourceData} from "../Source"
|
|
8
8
|
import {Project} from "../Project"
|
|
@@ -21,6 +21,17 @@ export declare class JsonStone extends Stone<JsonStoneConfig> {
|
|
|
21
21
|
export type JsonStoneConfig = {
|
|
22
22
|
cacheStrategy?: null | CacheStrategy,
|
|
23
23
|
/**
|
|
24
|
+
* Registers another stone as dependency of this one. Useful for external processes
|
|
25
|
+
* that use a source of some stone, but don't go via Whet to get it.
|
|
26
|
+
* Use with combination of `setAbsolutePath` on the dependency, so that the external process
|
|
27
|
+
* can rely on fixed path.
|
|
28
|
+
* Will make sure the cached file is up to date when generating this stone.
|
|
29
|
+
* Hash of the dependency is automatically combined with hash generated by this stone. There's no
|
|
30
|
+
* need to add it manually.
|
|
31
|
+
* Do not create cyclic dependencies!
|
|
32
|
+
*/
|
|
33
|
+
dependencies?: null | MaybeArray<AnyStone>,
|
|
34
|
+
/**
|
|
24
35
|
Defaults to the Stone's class name.
|
|
25
36
|
*/
|
|
26
37
|
id?: null | StoneIdType,
|