whet 0.0.18 → 0.0.20
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/README.md +9 -6
- package/bin/HxOverrides.d.ts +0 -1
- package/bin/HxOverrides.js +0 -7
- package/bin/haxe/Exception.d.ts +1 -0
- package/bin/haxe/Exception.js +9 -0
- package/bin/whet/Project.js +4 -25
- package/bin/whet/Source.d.ts +3 -2
- package/bin/whet/Source.js +15 -38
- package/bin/whet/SourceId.d.ts +17 -5
- package/bin/whet/SourceId.js +93 -68
- package/bin/whet/Stone.d.ts +11 -0
- package/bin/whet/Stone.js +52 -26
- package/bin/whet/Whet.js +12 -2
- package/bin/whet/cache/BaseCache.js +70 -85
- package/bin/whet/cache/CacheManager.js +18 -37
- package/bin/whet/cache/FileCache.js +28 -146
- package/bin/whet/magic/RoutePathType.js +8 -45
- package/bin/whet/route/Router.js +43 -136
- package/bin/whet/stones/Files.d.ts +1 -0
- package/bin/whet/stones/Files.js +56 -24
- package/bin/whet/stones/JsonStone.d.ts +2 -2
- package/bin/whet/stones/JsonStone.js +6 -13
- package/bin/whet/stones/RemoteFile.js +1 -10
- package/bin/whet/stones/Server.js +9 -52
- package/bin/whet/stones/Zip.d.ts +2 -2
- package/bin/whet/stones/Zip.js +4 -26
- package/bin/whet/stones/haxe/HaxeBuild.js +6 -35
- package/bin/whet/stones/haxe/Hxml.js +21 -67
- package/bin/whet.d.ts +1 -0
- package/bin/whet.js +1 -0
- package/package.json +1 -1
package/bin/whet/route/Router.js
CHANGED
|
@@ -3,12 +3,9 @@ import {RoutePathType_Fields_} from "../magic/RoutePathType.js"
|
|
|
3
3
|
import {MinimatchType_Fields_} from "../magic/MinimatchType.js"
|
|
4
4
|
import {Utils} from "../Utils.js"
|
|
5
5
|
import {Stone} from "../Stone.js"
|
|
6
|
-
import {SourceId} from "../SourceId.js"
|
|
7
6
|
import {SourceHash} from "../SourceHash.js"
|
|
8
7
|
import * as Path from "path"
|
|
9
8
|
import {Register} from "../../genes/Register.js"
|
|
10
|
-
import {StringTools} from "../../StringTools.js"
|
|
11
|
-
import {HxOverrides} from "../../HxOverrides.js"
|
|
12
9
|
|
|
13
10
|
const $global = Register.$global
|
|
14
11
|
|
|
@@ -41,103 +38,26 @@ class Router extends Register.inherits() {
|
|
|
41
38
|
while (_g1 < _g2.length) {
|
|
42
39
|
var route = [_g2[_g1]];
|
|
43
40
|
++_g1;
|
|
44
|
-
|
|
45
|
-
var tmp;
|
|
46
|
-
if (((route1[0].source) instanceof Stone)) {
|
|
47
|
-
var stone = [route1[0].source];
|
|
48
|
-
tmp = stone[0].list().then((function (stone, route) {
|
|
49
|
-
return function (list) {
|
|
50
|
-
var arr = [];
|
|
51
|
-
var _g = 0;
|
|
52
|
-
while (_g < list.length) {
|
|
53
|
-
var path = list[_g];
|
|
54
|
-
++_g;
|
|
55
|
-
var serveId = null;
|
|
56
|
-
if (route[0].filter == null || route[0].filter.match(path)) {
|
|
57
|
-
serveId = path;
|
|
58
|
-
if (route[0].extractDirs != null) {
|
|
59
|
-
var dir = path;
|
|
60
|
-
while (true) {
|
|
61
|
-
dir = dir.substring(0, dir.lastIndexOf("/"));
|
|
62
|
-
if (route[0].extractDirs.match(dir + "/")) {
|
|
63
|
-
var s = dir + "/";
|
|
64
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
65
|
-
if (str.length > 0) {
|
|
66
|
-
str = Path.posix.normalize(str);
|
|
67
|
-
str = StringTools.replace(str, "\\", "/");
|
|
68
|
-
};
|
|
69
|
-
s = str;
|
|
70
|
-
serveId = SourceId.relativeTo(path, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
|
|
71
|
-
break;
|
|
72
|
-
};
|
|
73
|
-
if (!(dir.length > 0)) {
|
|
74
|
-
break;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
var serveId1 = serveId;
|
|
80
|
-
if (serveId1 != null) {
|
|
81
|
-
arr.push(new RouteResult(serveId1, path, stone[0]));
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
return arr;
|
|
85
|
-
};
|
|
86
|
-
})(stone, route1));
|
|
87
|
-
} else if (((route1[0].source) instanceof Router)) {
|
|
88
|
-
tmp = route1[0].source.get().then((function (route) {
|
|
89
|
-
return function (list) {
|
|
90
|
-
var arr = [];
|
|
91
|
-
var _g = 0;
|
|
92
|
-
while (_g < list.length) {
|
|
93
|
-
var result = list[_g];
|
|
94
|
-
++_g;
|
|
95
|
-
var path = result.serveId;
|
|
96
|
-
var serveId = null;
|
|
97
|
-
if (route[0].filter == null || route[0].filter.match(path)) {
|
|
98
|
-
serveId = path;
|
|
99
|
-
if (route[0].extractDirs != null) {
|
|
100
|
-
var dir = path;
|
|
101
|
-
while (true) {
|
|
102
|
-
dir = dir.substring(0, dir.lastIndexOf("/"));
|
|
103
|
-
if (route[0].extractDirs.match(dir + "/")) {
|
|
104
|
-
var s = dir + "/";
|
|
105
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
106
|
-
if (str.length > 0) {
|
|
107
|
-
str = Path.posix.normalize(str);
|
|
108
|
-
str = StringTools.replace(str, "\\", "/");
|
|
109
|
-
};
|
|
110
|
-
s = str;
|
|
111
|
-
serveId = SourceId.relativeTo(path, (HxOverrides.cca(s, 0) == 47) ? s : "/" + s);
|
|
112
|
-
break;
|
|
113
|
-
};
|
|
114
|
-
if (!(dir.length > 0)) {
|
|
115
|
-
break;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
var serveId1 = serveId;
|
|
121
|
-
if (serveId1 != null) {
|
|
122
|
-
result.serveId = serveId1;
|
|
123
|
-
arr.push(result);
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
return arr;
|
|
127
|
-
};
|
|
128
|
-
})(route1));
|
|
129
|
-
} else {
|
|
130
|
-
throw new Error("Router source must be a Stone or a Router.");
|
|
131
|
-
};
|
|
132
|
-
_g.push(tmp.then((function (route) {
|
|
41
|
+
_g.push(_gthis.allFromRoute(route[0]).then((function (route) {
|
|
133
42
|
return function (list) {
|
|
134
|
-
var
|
|
135
|
-
var routeUnderIsDir =
|
|
43
|
+
var id = route[0].routeUnder;
|
|
44
|
+
var routeUnderIsDir = id.length == 0 || id.charCodeAt(id.length - 1) == 47;
|
|
136
45
|
var _g = 0;
|
|
137
46
|
while (_g < list.length) {
|
|
138
47
|
var item = list[_g];
|
|
139
48
|
++_g;
|
|
140
|
-
|
|
49
|
+
var tmp;
|
|
50
|
+
if (routeUnderIsDir) {
|
|
51
|
+
var id = item.serveId;
|
|
52
|
+
var dir = route[0].routeUnder;
|
|
53
|
+
if (!(dir.length == 0 || dir.charCodeAt(dir.length - 1) == 47)) {
|
|
54
|
+
throw new Error("\"" + dir + "\" is not a directory.");
|
|
55
|
+
};
|
|
56
|
+
tmp = Path.posix.join(dir, id);
|
|
57
|
+
} else {
|
|
58
|
+
tmp = route[0].routeUnder;
|
|
59
|
+
};
|
|
60
|
+
item.serveId = tmp;
|
|
141
61
|
if (filter.match(item.serveId)) {
|
|
142
62
|
result.push(item);
|
|
143
63
|
};
|
|
@@ -197,20 +117,7 @@ class Router extends Register.inherits() {
|
|
|
197
117
|
while (_g1 < result.length) {
|
|
198
118
|
var r = result[_g1];
|
|
199
119
|
++_g1;
|
|
200
|
-
var
|
|
201
|
-
var this1 = r.serveId;
|
|
202
|
-
var s = "/";
|
|
203
|
-
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
204
|
-
if (str.length > 0) {
|
|
205
|
-
str = Path.posix.normalize(str);
|
|
206
|
-
str = StringTools.replace(str, "\\", "/");
|
|
207
|
-
};
|
|
208
|
-
s = str;
|
|
209
|
-
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
210
|
-
if (this1.charAt(0) != "/") {
|
|
211
|
-
throw new Error("Badly formed SourceId.");
|
|
212
|
-
};
|
|
213
|
-
var p = [Path.join(saveInto1, Path.posix.join(".", root, ".", this1))];
|
|
120
|
+
var p = [Path.join(saveInto, Path.posix.join(".", "./", ".", r.serveId))];
|
|
214
121
|
_g.push(r.get().then((function (p) {
|
|
215
122
|
return function (src) {
|
|
216
123
|
return Utils.saveBytes(p[0], src.data);
|
|
@@ -261,14 +168,14 @@ class Router extends Register.inherits() {
|
|
|
261
168
|
while (true) {
|
|
262
169
|
dir = dir.substring(0, dir.lastIndexOf("/"));
|
|
263
170
|
if (route.extractDirs.match(dir + "/")) {
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
str = Path.posix.normalize(str);
|
|
268
|
-
str = StringTools.replace(str, "\\", "/");
|
|
171
|
+
var directory = dir + "/";
|
|
172
|
+
if (!(directory.length == 0 || directory.charCodeAt(directory.length - 1) == 47)) {
|
|
173
|
+
throw new Error("\"" + directory + "\" is not a directory.");
|
|
269
174
|
};
|
|
270
|
-
|
|
271
|
-
|
|
175
|
+
var serveId1;
|
|
176
|
+
var dir1 = path.substring(0, path.lastIndexOf("/") + 1);
|
|
177
|
+
serveId1 = ((dir1.length == 0) ? "./" : dir1).indexOf(directory) == 0;
|
|
178
|
+
serveId = (serveId1) ? path.substring(directory.length) : null;
|
|
272
179
|
break;
|
|
273
180
|
};
|
|
274
181
|
if (!(dir.length > 0)) {
|
|
@@ -277,9 +184,9 @@ class Router extends Register.inherits() {
|
|
|
277
184
|
};
|
|
278
185
|
};
|
|
279
186
|
};
|
|
280
|
-
var
|
|
281
|
-
if (
|
|
282
|
-
arr.push(new RouteResult(
|
|
187
|
+
var serveId2 = serveId;
|
|
188
|
+
if (serveId2 != null) {
|
|
189
|
+
arr.push(new RouteResult(serveId2, path, stone));
|
|
283
190
|
};
|
|
284
191
|
};
|
|
285
192
|
return arr;
|
|
@@ -300,14 +207,14 @@ class Router extends Register.inherits() {
|
|
|
300
207
|
while (true) {
|
|
301
208
|
dir = dir.substring(0, dir.lastIndexOf("/"));
|
|
302
209
|
if (route.extractDirs.match(dir + "/")) {
|
|
303
|
-
var
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
str = Path.posix.normalize(str);
|
|
307
|
-
str = StringTools.replace(str, "\\", "/");
|
|
210
|
+
var directory = dir + "/";
|
|
211
|
+
if (!(directory.length == 0 || directory.charCodeAt(directory.length - 1) == 47)) {
|
|
212
|
+
throw new Error("\"" + directory + "\" is not a directory.");
|
|
308
213
|
};
|
|
309
|
-
|
|
310
|
-
|
|
214
|
+
var serveId1;
|
|
215
|
+
var dir1 = path.substring(0, path.lastIndexOf("/") + 1);
|
|
216
|
+
serveId1 = ((dir1.length == 0) ? "./" : dir1).indexOf(directory) == 0;
|
|
217
|
+
serveId = (serveId1) ? path.substring(directory.length) : null;
|
|
311
218
|
break;
|
|
312
219
|
};
|
|
313
220
|
if (!(dir.length > 0)) {
|
|
@@ -316,9 +223,9 @@ class Router extends Register.inherits() {
|
|
|
316
223
|
};
|
|
317
224
|
};
|
|
318
225
|
};
|
|
319
|
-
var
|
|
320
|
-
if (
|
|
321
|
-
result.serveId =
|
|
226
|
+
var serveId2 = serveId;
|
|
227
|
+
if (serveId2 != null) {
|
|
228
|
+
result.serveId = serveId2;
|
|
322
229
|
arr.push(result);
|
|
323
230
|
};
|
|
324
231
|
};
|
|
@@ -337,14 +244,14 @@ class Router extends Register.inherits() {
|
|
|
337
244
|
while (true) {
|
|
338
245
|
dir = dir.substring(0, dir.lastIndexOf("/"));
|
|
339
246
|
if (route.extractDirs.match(dir + "/")) {
|
|
340
|
-
var
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
str = Path.posix.normalize(str);
|
|
344
|
-
str = StringTools.replace(str, "\\", "/");
|
|
247
|
+
var directory = dir + "/";
|
|
248
|
+
if (!(directory.length == 0 || directory.charCodeAt(directory.length - 1) == 47)) {
|
|
249
|
+
throw new Error("\"" + directory + "\" is not a directory.");
|
|
345
250
|
};
|
|
346
|
-
|
|
347
|
-
|
|
251
|
+
var serveId1;
|
|
252
|
+
var dir1 = path.substring(0, path.lastIndexOf("/") + 1);
|
|
253
|
+
serveId1 = ((dir1.length == 0) ? "./" : dir1).indexOf(directory) == 0;
|
|
254
|
+
serveId = (serveId1) ? path.substring(directory.length) : null;
|
|
348
255
|
break;
|
|
349
256
|
};
|
|
350
257
|
if (!(dir.length > 0)) {
|
package/bin/whet/stones/Files.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import {MaybeArray_Fields_} from "../magic/MaybeArray.js"
|
|
2
2
|
import {Utils} from "../Utils.js"
|
|
3
3
|
import {Stone} from "../Stone.js"
|
|
4
|
-
import {
|
|
4
|
+
import {IdUtils, RootDir} from "../SourceId.js"
|
|
5
5
|
import {SourceData} from "../Source.js"
|
|
6
|
-
import * as Path from "path"
|
|
7
6
|
import {Register} from "../../genes/Register.js"
|
|
8
|
-
import {StringTools} from "../../StringTools.js"
|
|
9
|
-
import {HxOverrides} from "../../HxOverrides.js"
|
|
10
7
|
|
|
11
8
|
const $global = Register.$global
|
|
12
9
|
|
|
@@ -18,39 +15,73 @@ class Files extends Register.inherits(Stone) {
|
|
|
18
15
|
initConfig() {
|
|
19
16
|
this.config.recursive = true;
|
|
20
17
|
}
|
|
21
|
-
|
|
18
|
+
list() {
|
|
22
19
|
var _gthis = this;
|
|
23
20
|
var _g = [];
|
|
24
21
|
var _g1 = 0;
|
|
25
22
|
var _g2 = MaybeArray_Fields_.makeArray(this.config.paths);
|
|
26
23
|
while (_g1 < _g2.length) {
|
|
27
|
-
var
|
|
24
|
+
var path = [_g2[_g1]];
|
|
28
25
|
++_g1;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
if (path[0].length == 0 || path[0].charCodeAt(path[0].length - 1) == 47) {
|
|
27
|
+
_g.push(Utils.listDirectoryFiles(this.cwdPath(path[0]), this.config.recursive).then((function (path) {
|
|
28
|
+
return function (arr) {
|
|
29
|
+
var result = new Array(arr.length);
|
|
30
|
+
var _g = 0;
|
|
31
|
+
var _g1 = arr.length;
|
|
32
|
+
while (_g < _g1) {
|
|
33
|
+
var i = _g++;
|
|
34
|
+
var pathId = IdUtils.fromCwdPath(arr[i], RootDir.fromProject(_gthis.project));
|
|
35
|
+
if (!(path[0].length == 0 || path[0].charCodeAt(path[0].length - 1) == 47)) {
|
|
36
|
+
throw new Error("\"" + path[0] + "\" is not a directory.");
|
|
37
|
+
};
|
|
38
|
+
var tmp;
|
|
39
|
+
var dir = pathId.substring(0, pathId.lastIndexOf("/") + 1);
|
|
40
|
+
tmp = ((dir.length == 0) ? "./" : dir).indexOf(path[0]) == 0;
|
|
41
|
+
result[i] = (tmp) ? pathId.substring(path[0].length) : null;
|
|
42
|
+
};
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})(path)));
|
|
46
|
+
} else {
|
|
47
|
+
var id = path[0];
|
|
48
|
+
_g.push(Promise.resolve([id.substring(id.lastIndexOf("/") + 1)]));
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
return Promise.all(_g).then(function (allPaths) {
|
|
52
|
+
var _g = [];
|
|
53
|
+
var _g_current = 0;
|
|
54
|
+
while (_g_current < allPaths.length) {
|
|
55
|
+
var x = Register.iter(allPaths[_g_current++]);
|
|
56
|
+
while (x.hasNext()) _g.push(x.next());
|
|
34
57
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
return _g;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
generate(hash) {
|
|
62
|
+
var _gthis = this;
|
|
63
|
+
var _g = [];
|
|
64
|
+
var _g1 = 0;
|
|
65
|
+
var _g2 = MaybeArray_Fields_.makeArray(this.config.paths);
|
|
66
|
+
while (_g1 < _g2.length) {
|
|
67
|
+
var path = [_g2[_g1]];
|
|
68
|
+
++_g1;
|
|
69
|
+
if (path[0].length == 0 || path[0].charCodeAt(path[0].length - 1) == 47) {
|
|
70
|
+
_g.push(Utils.listDirectoryFiles(this.cwdPath(path[0]), this.config.recursive).then((function (path) {
|
|
39
71
|
return function (arr) {
|
|
40
72
|
var _g = [];
|
|
41
73
|
var _g1 = 0;
|
|
42
74
|
while (_g1 < arr.length) {
|
|
43
75
|
var file = arr[_g1];
|
|
44
76
|
++_g1;
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
str = Path.posix.normalize(str);
|
|
49
|
-
str = StringTools.replace(str, "\\", "/");
|
|
77
|
+
var pathId = IdUtils.fromCwdPath(file, RootDir.fromProject(_gthis.project));
|
|
78
|
+
if (!(path[0].length == 0 || path[0].charCodeAt(path[0].length - 1) == 47)) {
|
|
79
|
+
throw new Error("\"" + path[0] + "\" is not a directory.");
|
|
50
80
|
};
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
|
|
81
|
+
var id;
|
|
82
|
+
var dir = pathId.substring(0, pathId.lastIndexOf("/") + 1);
|
|
83
|
+
id = ((dir.length == 0) ? "./" : dir).indexOf(path[0]) == 0;
|
|
84
|
+
_g.push(SourceData.fromFile((id) ? pathId.substring(path[0].length) : null, file, pathId));
|
|
54
85
|
};
|
|
55
86
|
return _g;
|
|
56
87
|
};
|
|
@@ -60,7 +91,8 @@ class Files extends Register.inherits(Stone) {
|
|
|
60
91
|
};
|
|
61
92
|
})()));
|
|
62
93
|
} else {
|
|
63
|
-
|
|
94
|
+
var id = path[0];
|
|
95
|
+
_g.push(SourceData.fromFile(id.substring(id.lastIndexOf("/") + 1), this.cwdPath(path[0]), path[0]).then((function () {
|
|
64
96
|
return function (src) {
|
|
65
97
|
return [src];
|
|
66
98
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import {Router} from "../route/Router"
|
|
1
2
|
import {StoneIdType} from "../magic/StoneId"
|
|
2
|
-
import {RoutePathType} from "../magic/RoutePathType"
|
|
3
3
|
import {MaybeArray} from "../magic/MaybeArray"
|
|
4
4
|
import {CacheStrategy} from "../cache/Cache"
|
|
5
5
|
import {Stone, AnyStone} from "../Stone"
|
|
@@ -39,7 +39,7 @@ export type JsonStoneConfig = {
|
|
|
39
39
|
Defaults to the Stone's class name.
|
|
40
40
|
*/
|
|
41
41
|
id?: null | StoneIdType,
|
|
42
|
-
mergeFiles?: null |
|
|
42
|
+
mergeFiles?: null | Router,
|
|
43
43
|
name?: null | string,
|
|
44
44
|
/**
|
|
45
45
|
Defaults to the last instanced project.
|
|
@@ -2,11 +2,8 @@ import {Router} from "../route/Router.js"
|
|
|
2
2
|
import {Stone} from "../Stone.js"
|
|
3
3
|
import {SourceHash} from "../SourceHash.js"
|
|
4
4
|
import {SourceData} from "../Source.js"
|
|
5
|
-
import * as Path from "path"
|
|
6
5
|
import {Register} from "../../genes/Register.js"
|
|
7
|
-
import {StringTools} from "../../StringTools.js"
|
|
8
6
|
import {Reflect as Reflect__1} from "../../Reflect.js"
|
|
9
|
-
import {HxOverrides} from "../../HxOverrides.js"
|
|
10
7
|
|
|
11
8
|
const $global = Register.$global
|
|
12
9
|
|
|
@@ -32,7 +29,7 @@ class JsonStone extends Register.inherits(Stone) {
|
|
|
32
29
|
var key = _g_keys[_g_index++];
|
|
33
30
|
obj[key] = access[key];
|
|
34
31
|
};
|
|
35
|
-
return
|
|
32
|
+
return this.config.mergeFiles.get().then(function (list) {
|
|
36
33
|
var result = new Array(list.length);
|
|
37
34
|
var _g = 0;
|
|
38
35
|
var _g1 = list.length;
|
|
@@ -57,24 +54,20 @@ class JsonStone extends Register.inherits(Stone) {
|
|
|
57
54
|
}
|
|
58
55
|
generateHash() {
|
|
59
56
|
var _gthis = this;
|
|
60
|
-
return
|
|
57
|
+
return this.config.mergeFiles.getHash().then(function (hash) {
|
|
61
58
|
return hash.add(SourceHash.fromString(JSON.stringify(_gthis.data)));
|
|
62
59
|
});
|
|
63
60
|
}
|
|
64
61
|
list() {
|
|
65
|
-
|
|
66
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
67
|
-
if (str.length > 0) {
|
|
68
|
-
str = Path.posix.normalize(str);
|
|
69
|
-
str = StringTools.replace(str, "\\", "/");
|
|
70
|
-
};
|
|
71
|
-
s = str;
|
|
72
|
-
return Promise.resolve([(HxOverrides.cca(s, 0) == 47) ? s : "/" + s]);
|
|
62
|
+
return Promise.resolve([this.config.name]);
|
|
73
63
|
}
|
|
74
64
|
initConfig() {
|
|
75
65
|
if (this.config.name == null) {
|
|
76
66
|
this.config.name = "data.json";
|
|
77
67
|
};
|
|
68
|
+
if (this.config.mergeFiles == null) {
|
|
69
|
+
this.config.mergeFiles = new Router();
|
|
70
|
+
};
|
|
78
71
|
super.initConfig();
|
|
79
72
|
}
|
|
80
73
|
static get __name__() {
|
|
@@ -8,8 +8,6 @@ import * as Path from "path"
|
|
|
8
8
|
import * as Https from "https"
|
|
9
9
|
import {Register} from "../../genes/Register.js"
|
|
10
10
|
import {Buffer} from "buffer"
|
|
11
|
-
import {StringTools} from "../../StringTools.js"
|
|
12
|
-
import {HxOverrides} from "../../HxOverrides.js"
|
|
13
11
|
|
|
14
12
|
const $global = Register.$global
|
|
15
13
|
|
|
@@ -50,14 +48,7 @@ class RemoteFile extends Register.inherits(Stone) {
|
|
|
50
48
|
return Promise.resolve(SourceHash.fromString(this.config.url));
|
|
51
49
|
}
|
|
52
50
|
getId() {
|
|
53
|
-
|
|
54
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
55
|
-
if (str.length > 0) {
|
|
56
|
-
str = Path.posix.normalize(str);
|
|
57
|
-
str = StringTools.replace(str, "\\", "/");
|
|
58
|
-
};
|
|
59
|
-
s = str;
|
|
60
|
-
return (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
51
|
+
return Path.basename(new URL(this.config.url).pathname);
|
|
61
52
|
}
|
|
62
53
|
static get __name__() {
|
|
63
54
|
return "whet.stones.RemoteFile"
|
|
@@ -5,10 +5,8 @@ import * as Path from "path"
|
|
|
5
5
|
import Mime from "mime"
|
|
6
6
|
import * as Http from "http"
|
|
7
7
|
import {Register} from "../../genes/Register.js"
|
|
8
|
-
import {StringTools} from "../../StringTools.js"
|
|
9
8
|
import {Std} from "../../Std.js"
|
|
10
9
|
import {Reflect as Reflect__1} from "../../Reflect.js"
|
|
11
|
-
import {HxOverrides} from "../../HxOverrides.js"
|
|
12
10
|
|
|
13
11
|
const $global = Register.$global
|
|
14
12
|
|
|
@@ -57,48 +55,18 @@ class Server extends Register.inherits(Stone) {
|
|
|
57
55
|
var _gthis = this;
|
|
58
56
|
Log.log(30, ...["Handling request.", {"url": req.url, "method": req.method}]);
|
|
59
57
|
var searchIndex = req.url.indexOf("?");
|
|
60
|
-
var id;
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
64
|
-
if (str.length > 0) {
|
|
65
|
-
str = Path.posix.normalize(str);
|
|
66
|
-
str = StringTools.replace(str, "\\", "/");
|
|
67
|
-
};
|
|
68
|
-
s = str;
|
|
69
|
-
id = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
70
|
-
} else {
|
|
71
|
-
var s = req.url;
|
|
72
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
73
|
-
if (str.length > 0) {
|
|
74
|
-
str = Path.posix.normalize(str);
|
|
75
|
-
str = StringTools.replace(str, "\\", "/");
|
|
76
|
-
};
|
|
77
|
-
s = str;
|
|
78
|
-
id = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
58
|
+
var id = decodeURI((searchIndex > 0 ? req.url.substring(0,searchIndex) : req.url));
|
|
59
|
+
if (id.charCodeAt(0) == 47) {
|
|
60
|
+
id = id.substring(1);
|
|
79
61
|
};
|
|
80
62
|
switch (req.method) {
|
|
81
63
|
case "GET":
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (str.length > 0) {
|
|
87
|
-
str = Path.posix.normalize(str);
|
|
88
|
-
str = StringTools.replace(str, "\\", "/");
|
|
89
|
-
};
|
|
90
|
-
s = str;
|
|
91
|
-
id = ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s) + "index.html";
|
|
92
|
-
};
|
|
64
|
+
if (id.length == 0 || id.charCodeAt(id.length - 1) == 47) {
|
|
65
|
+
var id1 = id;
|
|
66
|
+
var dir = id1.substring(0, id1.lastIndexOf("/") + 1);
|
|
67
|
+
id = Path.posix.join((dir.length == 0) ? "./" : dir, "index.html");
|
|
93
68
|
} else if (Path.posix.extname(id) == "") {
|
|
94
|
-
|
|
95
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
96
|
-
if (str.length > 0) {
|
|
97
|
-
str = Path.posix.normalize(str);
|
|
98
|
-
str = StringTools.replace(str, "\\", "/");
|
|
99
|
-
};
|
|
100
|
-
s = str;
|
|
101
|
-
id = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
69
|
+
id = "" + id + "/index.html";
|
|
102
70
|
};
|
|
103
71
|
this.config.router.get(id).then(function (routeResult) {
|
|
104
72
|
return ((routeResult.length > 0) ? routeResult[0].get() : (_gthis.routeDynamic != null) ? _gthis.routeDynamic(id) : Promise.resolve(null)).then(function (source) {
|
|
@@ -146,18 +114,7 @@ class Server extends Register.inherits(Stone) {
|
|
|
146
114
|
res.end();
|
|
147
115
|
break
|
|
148
116
|
case "PUT":
|
|
149
|
-
var
|
|
150
|
-
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
151
|
-
if (str.length > 0) {
|
|
152
|
-
str = Path.posix.normalize(str);
|
|
153
|
-
str = StringTools.replace(str, "\\", "/");
|
|
154
|
-
};
|
|
155
|
-
s = str;
|
|
156
|
-
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
157
|
-
if (id.charAt(0) != "/") {
|
|
158
|
-
throw new Error("Badly formed SourceId.");
|
|
159
|
-
};
|
|
160
|
-
var cmd = [Path.posix.join(".", root, ".", id)];
|
|
117
|
+
var cmd = [Path.posix.join(".", "./", ".", id)];
|
|
161
118
|
var body = "";
|
|
162
119
|
req.on("data", function (chunk) {
|
|
163
120
|
body += chunk;
|
package/bin/whet/stones/Zip.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import {Router} from "../route/Router"
|
|
1
2
|
import {StoneIdType} from "../magic/StoneId"
|
|
2
|
-
import {RoutePathType} from "../magic/RoutePathType"
|
|
3
3
|
import {MaybeArray} from "../magic/MaybeArray"
|
|
4
4
|
import {CacheStrategy} from "../cache/Cache"
|
|
5
5
|
import {Stone, AnyStone} from "../Stone"
|
|
@@ -43,5 +43,5 @@ export type ZipConfig = {
|
|
|
43
43
|
Defaults to the last instanced project.
|
|
44
44
|
*/
|
|
45
45
|
project?: null | Project,
|
|
46
|
-
sources:
|
|
46
|
+
sources: Router
|
|
47
47
|
}
|
package/bin/whet/stones/Zip.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {Router} from "../route/Router.js"
|
|
2
1
|
import {CacheStrategy, CacheDurability, DurabilityCheck} from "../cache/Cache.js"
|
|
3
2
|
import {Stone} from "../Stone.js"
|
|
4
3
|
import {SourceHash} from "../SourceHash.js"
|
|
@@ -12,9 +11,7 @@ import {BytesOutput} from "../../haxe/io/BytesOutput.js"
|
|
|
12
11
|
import {Crc32} from "../../haxe/crypto/Crc32.js"
|
|
13
12
|
import {Register} from "../../genes/Register.js"
|
|
14
13
|
import {Buffer} from "buffer"
|
|
15
|
-
import {StringTools} from "../../StringTools.js"
|
|
16
14
|
import {Lambda} from "../../Lambda.js"
|
|
17
|
-
import {HxOverrides} from "../../HxOverrides.js"
|
|
18
15
|
|
|
19
16
|
const $global = Register.$global
|
|
20
17
|
|
|
@@ -36,7 +33,7 @@ class ZipStone extends Register.inherits(Stone) {
|
|
|
36
33
|
}
|
|
37
34
|
generateHash() {
|
|
38
35
|
var _gthis = this;
|
|
39
|
-
return
|
|
36
|
+
return this.config.sources.getHash().then(function (hash) {
|
|
40
37
|
return SourceHash.fromString(_gthis.config.filename + _gthis.config.level).add(hash);
|
|
41
38
|
});
|
|
42
39
|
}
|
|
@@ -44,7 +41,7 @@ class ZipStone extends Register.inherits(Stone) {
|
|
|
44
41
|
var _gthis = this;
|
|
45
42
|
Log.log(30, ...["Zipping files."]);
|
|
46
43
|
var level = this.config.level;
|
|
47
|
-
return
|
|
44
|
+
return this.config.sources.get().then(function (files) {
|
|
48
45
|
var _g = [];
|
|
49
46
|
var _g1 = 0;
|
|
50
47
|
while (_g1 < files.length) {
|
|
@@ -53,19 +50,7 @@ class ZipStone extends Register.inherits(Stone) {
|
|
|
53
50
|
_g.push(file[0].get().then((function (file) {
|
|
54
51
|
return function (data) {
|
|
55
52
|
var bytes = Helper.bytesOfBuffer(data.data);
|
|
56
|
-
var
|
|
57
|
-
var s = "/";
|
|
58
|
-
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
59
|
-
if (str.length > 0) {
|
|
60
|
-
str = Path.posix.normalize(str);
|
|
61
|
-
str = StringTools.replace(str, "\\", "/");
|
|
62
|
-
};
|
|
63
|
-
s = str;
|
|
64
|
-
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
65
|
-
if (this1.charAt(0) != "/") {
|
|
66
|
-
throw new Error("Badly formed SourceId.");
|
|
67
|
-
};
|
|
68
|
-
var entry = {"fileName": Path.posix.join(".", root, ".", this1), "fileSize": data.data.length, "fileTime": new Date(data.source.ctime * 1000), "compressed": false, "dataSize": data.data.length, "data": bytes, "crc32": Crc32.make(bytes)};
|
|
53
|
+
var entry = {"fileName": Path.posix.join(".", "./", ".", file[0].serveId), "fileSize": data.data.length, "fileTime": new Date(data.source.ctime * 1000), "compressed": false, "dataSize": data.data.length, "data": bytes, "crc32": Crc32.make(bytes)};
|
|
69
54
|
Tools.compress(entry, level);
|
|
70
55
|
return entry;
|
|
71
56
|
};
|
|
@@ -82,14 +67,7 @@ class ZipStone extends Register.inherits(Stone) {
|
|
|
82
67
|
});
|
|
83
68
|
}
|
|
84
69
|
list() {
|
|
85
|
-
|
|
86
|
-
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
87
|
-
if (str.length > 0) {
|
|
88
|
-
str = Path.posix.normalize(str);
|
|
89
|
-
str = StringTools.replace(str, "\\", "/");
|
|
90
|
-
};
|
|
91
|
-
s = str;
|
|
92
|
-
return Promise.resolve([(HxOverrides.cca(s, 0) == 47) ? s : "/" + s]);
|
|
70
|
+
return Promise.resolve([this.config.filename]);
|
|
93
71
|
}
|
|
94
72
|
static get __name__() {
|
|
95
73
|
return "whet.stones.ZipStone"
|