whet 0.0.14 → 0.0.17
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/Source.d.ts +5 -3
- package/bin/whet/Source.js +5 -6
- package/bin/whet/Whet.js +7 -2
- package/bin/whet/cache/FileCache.js +1 -5
- package/bin/whet/extern/Minimatch.d.ts +77 -0
- package/bin/whet/magic/MinimatchType.d.ts +5 -0
- package/bin/whet/magic/MinimatchType.js +26 -0
- package/bin/whet/magic/RoutePathType.d.ts +12 -3
- package/bin/whet/magic/RoutePathType.js +87 -23
- package/bin/whet/route/RouteResult.js +0 -11
- package/bin/whet/route/Router.d.ts +19 -12
- package/bin/whet/route/Router.js +224 -91
- package/bin/whet/stones/JsonStone.d.ts +2 -3
- package/bin/whet/stones/JsonStone.js +19 -50
- package/bin/whet/stones/Server.js +2 -7
- package/bin/whet/stones/Zip.js +2 -22
- package/bin/whet.d.ts +0 -1
- package/bin/whet.js +0 -1
- package/package.json +4 -2
- package/bin/StringBuf.d.ts +0 -13
- package/bin/StringBuf.js +0 -25
- package/bin/haxe/CallStack.d.ts +0 -41
- package/bin/haxe/CallStack.js +0 -96
- package/bin/haxe/NativeStackTrace.js +0 -147
- package/bin/haxe/io/Path.d.ts +0 -109
- package/bin/haxe/io/Path.js +0 -217
- package/bin/whet/magic/RouteType.d.ts +0 -13
- package/bin/whet/magic/RouteType.js +0 -104
- package/bin/whet/route/Route.d.ts +0 -19
- package/bin/whet/route/Route.js +0 -121
package/bin/whet/Source.d.ts
CHANGED
|
@@ -39,12 +39,14 @@ export declare class SourceData {
|
|
|
39
39
|
/**
|
|
40
40
|
Same as `getFilePath` but relative to project, not CWD.
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
getFilePathId(idOverride?: null | string): Promise<string>
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
Path to a file for this source, relative to CWD.
|
|
45
|
+
* Path to a file for this source, relative to CWD.
|
|
46
|
+
* Useful for working with sources outside of Whet ecosystem.
|
|
47
|
+
* @param [idOverride] Use to change the name/directory of the file. Ignored if source already has a filepath.
|
|
46
48
|
*/
|
|
47
|
-
|
|
49
|
+
getFilePath(idOverride?: null | string): Promise<string>
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
52
|
* @param id Path id relative to stone that generates it.
|
package/bin/whet/Source.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {Utils} from "./Utils.js"
|
|
2
2
|
import {SourceId, RootDir} from "./SourceId.js"
|
|
3
3
|
import {SourceHash} from "./SourceHash.js"
|
|
4
|
-
import {Log
|
|
4
|
+
import {Log} from "./Log.js"
|
|
5
5
|
import * as Path from "path"
|
|
6
|
-
import {Log} from "../haxe/Log.js"
|
|
7
6
|
import {Register} from "../genes/Register.js"
|
|
8
7
|
import * as Fs from "fs"
|
|
9
8
|
import {Buffer} from "buffer"
|
|
@@ -83,7 +82,6 @@ class SourceData extends Register.inherits() {
|
|
|
83
82
|
*/
|
|
84
83
|
getFilePathId(idOverride) {
|
|
85
84
|
var _gthis = this;
|
|
86
|
-
Log.trace(this.filePath, {"fileName": "src/whet/Source.hx", "lineNumber": 106, "className": "whet.SourceData", "methodName": "getFilePathId", "customParams": [this.filePathId, idOverride]});
|
|
87
85
|
if (this.filePathId == null) {
|
|
88
86
|
return this.getFilePath(idOverride).then(function (_) {
|
|
89
87
|
return _gthis.filePathId;
|
|
@@ -94,7 +92,9 @@ class SourceData extends Register.inherits() {
|
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
/**
|
|
97
|
-
Path to a file for this source, relative to CWD.
|
|
95
|
+
* Path to a file for this source, relative to CWD.
|
|
96
|
+
* Useful for working with sources outside of Whet ecosystem.
|
|
97
|
+
* @param [idOverride] Use to change the name/directory of the file. Ignored if source already has a filepath.
|
|
98
98
|
*/
|
|
99
99
|
getFilePath(idOverride) {
|
|
100
100
|
var _gthis = this;
|
|
@@ -110,7 +110,6 @@ class SourceData extends Register.inherits() {
|
|
|
110
110
|
throw new Error("Badly formed SourceId.");
|
|
111
111
|
};
|
|
112
112
|
this.filePath = Path.posix.join(".", root, ".", this1);
|
|
113
|
-
Log.trace(dir, {"fileName": "src/whet/Source.hx", "lineNumber": 121, "className": "whet.SourceData", "methodName": "getFilePath", "customParams": [this.filePath, this.filePathId]});
|
|
114
113
|
return Utils.saveBytes(this.filePath, this.data).then(function (_) {
|
|
115
114
|
return _gthis.filePath;
|
|
116
115
|
});
|
|
@@ -129,7 +128,7 @@ class SourceData extends Register.inherits() {
|
|
|
129
128
|
return new Promise(function (res, rej) {
|
|
130
129
|
Fs.readFile(path, function (err, buffer) {
|
|
131
130
|
if (err != null) {
|
|
132
|
-
|
|
131
|
+
Log.log(50, ...["File does not exist.", {"id": id, "path": path}]);
|
|
133
132
|
res(null);
|
|
134
133
|
} else {
|
|
135
134
|
var source = SourceData.fromBytes(id, buffer);
|
package/bin/whet/Whet.js
CHANGED
|
@@ -2,7 +2,7 @@ import {Project} from "./Project.js"
|
|
|
2
2
|
import {LogLevel, Log} from "./Log.js"
|
|
3
3
|
import * as Url from "url"
|
|
4
4
|
import {Register} from "../genes/Register.js"
|
|
5
|
-
import {Command} from "commander"
|
|
5
|
+
import {Command, CommanderError} from "commander"
|
|
6
6
|
import {Std} from "../Std.js"
|
|
7
7
|
|
|
8
8
|
const $global = Register.$global
|
|
@@ -10,7 +10,7 @@ const $global = Register.$global
|
|
|
10
10
|
export const Whet_Fields_ = Register.global("$hxClasses")["whet._Whet.Whet_Fields_"] =
|
|
11
11
|
class Whet_Fields_ {
|
|
12
12
|
static main() {
|
|
13
|
-
Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.
|
|
13
|
+
Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.17", "-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").exitOverride();
|
|
14
14
|
Whet_Fields_.program.parse();
|
|
15
15
|
var options = Whet_Fields_.program.opts();
|
|
16
16
|
if (options.logLevel != null) {
|
|
@@ -87,6 +87,11 @@ class Whet_Fields_ {
|
|
|
87
87
|
Log.log(10, ...["Executing command.", {"commandArgs": c}]);
|
|
88
88
|
Whet_Fields_.program.parseAsync(c, {"from": "user"}).then(function (_) {
|
|
89
89
|
nextCommand();
|
|
90
|
+
})["catch"](function (err) {
|
|
91
|
+
if (((err) instanceof CommanderError) && err.code == "commander.help") {
|
|
92
|
+
return;
|
|
93
|
+
};
|
|
94
|
+
Log.log(50, ...["Error while executing command.", {"error": err}]);
|
|
90
95
|
});
|
|
91
96
|
};
|
|
92
97
|
initProm.then(function (_) {
|
|
@@ -94,7 +94,6 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
94
94
|
if (_g._hx_index == 3) {
|
|
95
95
|
var _g1 = _g.path;
|
|
96
96
|
if (source.data.length == 1) {
|
|
97
|
-
console.log("src/whet/cache/FileCache.hx:46:",_g1);
|
|
98
97
|
var s = _g1.substring(_g1.lastIndexOf("/"));
|
|
99
98
|
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
100
99
|
if (str.length > 0) {
|
|
@@ -109,7 +108,6 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
109
108
|
} else {
|
|
110
109
|
idOverride = null;
|
|
111
110
|
};
|
|
112
|
-
console.log("src/whet/cache/FileCache.hx:50:",idOverride);
|
|
113
111
|
var _g = [];
|
|
114
112
|
var _g1 = 0;
|
|
115
113
|
var _g2 = source.data;
|
|
@@ -118,9 +116,7 @@ class FileCache extends Register.inherits(BaseCache) {
|
|
|
118
116
|
++_g1;
|
|
119
117
|
_g.push(data[0].getFilePathId(idOverride).then((function (data) {
|
|
120
118
|
return function (filePath) {
|
|
121
|
-
|
|
122
|
-
console.log("src/whet/cache/FileCache.hx:53:",filePath);
|
|
123
|
-
return {"fileHash": tmp, "filePath": filePath, "id": data[0].id};
|
|
119
|
+
return {"fileHash": SourceHash.fromBytes(data[0].data), "filePath": filePath, "id": data[0].id};
|
|
124
120
|
};
|
|
125
121
|
})(data)));
|
|
126
122
|
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
export type IOptions = {
|
|
3
|
+
/**
|
|
4
|
+
Dump a ton of stuff to stderr.
|
|
5
|
+
*/
|
|
6
|
+
debug?: null | boolean,
|
|
7
|
+
/**
|
|
8
|
+
Allow patterns to match filenames starting with a period,
|
|
9
|
+
even if the pattern does not explicitly have a period in that spot.
|
|
10
|
+
|
|
11
|
+
Note that by default, `'a/**' + '/b'` will **not** match `a/.d/b`, unless `dot` is set.
|
|
12
|
+
*/
|
|
13
|
+
dot?: null | boolean,
|
|
14
|
+
/**
|
|
15
|
+
Returns from negate expressions the same as if they were not negated.
|
|
16
|
+
(Ie, true on a hit, false on a miss.)
|
|
17
|
+
*/
|
|
18
|
+
flipNegate?: null | boolean,
|
|
19
|
+
/**
|
|
20
|
+
If set, then patterns without slashes will be matched
|
|
21
|
+
against the basename of the path if it contains slashes. For example,
|
|
22
|
+
`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`.
|
|
23
|
+
*/
|
|
24
|
+
matchBase?: null | boolean,
|
|
25
|
+
/**
|
|
26
|
+
Do not expand `{a,b}` and `{1..3}` brace sets.
|
|
27
|
+
*/
|
|
28
|
+
nobrace?: null | boolean,
|
|
29
|
+
/**
|
|
30
|
+
Perform a case-insensitive match.
|
|
31
|
+
*/
|
|
32
|
+
nocase?: null | boolean,
|
|
33
|
+
/**
|
|
34
|
+
Suppress the behavior of treating `#` at the start of a pattern as a comment.
|
|
35
|
+
*/
|
|
36
|
+
nocomment?: null | boolean,
|
|
37
|
+
/**
|
|
38
|
+
Disable "extglob" style patterns like `+(a|b)`.
|
|
39
|
+
*/
|
|
40
|
+
noext?: null | boolean,
|
|
41
|
+
/**
|
|
42
|
+
Disable `**` matching against multiple folder names.
|
|
43
|
+
*/
|
|
44
|
+
noglobstar?: null | boolean,
|
|
45
|
+
/**
|
|
46
|
+
Suppress the behavior of treating a leading `!` character as negation.
|
|
47
|
+
*/
|
|
48
|
+
nonegate?: null | boolean,
|
|
49
|
+
/**
|
|
50
|
+
When a match is not found by `minimatch.match`,
|
|
51
|
+
return a list containing the pattern itself if this option is set.
|
|
52
|
+
Otherwise, an empty list is returned if there are no matches.
|
|
53
|
+
*/
|
|
54
|
+
nonull?: null | boolean,
|
|
55
|
+
/**
|
|
56
|
+
Compare a partial path to a pattern. As long as the parts of the path that
|
|
57
|
+
are present are not contradicted by the pattern, it will be treated as a
|
|
58
|
+
match. This is useful in applications where you're walking through a
|
|
59
|
+
folder structure, and don't yet have the full path, but want to ensure that
|
|
60
|
+
you do not walk down paths that can never be a match.
|
|
61
|
+
*/
|
|
62
|
+
partial?: null | boolean,
|
|
63
|
+
/**
|
|
64
|
+
Use `\\` as a path separator _only_, and _never_ as an escape
|
|
65
|
+
character. If set, all `\\` characters are replaced with `/` in
|
|
66
|
+
the pattern. Note that this makes it **impossible** to match
|
|
67
|
+
against paths containing literal glob pattern characters, but
|
|
68
|
+
allows matching with patterns constructed using `path.join()` and
|
|
69
|
+
`path.resolve()` on Windows platforms, mimicking the (buggy!)
|
|
70
|
+
behavior of earlier versions on Windows. Please use with
|
|
71
|
+
caution, and be mindful of the caveat about Windows paths
|
|
72
|
+
|
|
73
|
+
For legacy reasons, this is also set if
|
|
74
|
+
`options.allowWindowsEscape` is set to the exact value `false`.
|
|
75
|
+
*/
|
|
76
|
+
windowsPathsNoEscape?: null | boolean
|
|
77
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Minimatch from "minimatch"
|
|
2
|
+
import {Register} from "../../genes/Register.js"
|
|
3
|
+
|
|
4
|
+
const $global = Register.$global
|
|
5
|
+
|
|
6
|
+
export const MinimatchType_Fields_ = Register.global("$hxClasses")["whet.magic._MinimatchType.MinimatchType_Fields_"] =
|
|
7
|
+
class MinimatchType_Fields_ {
|
|
8
|
+
static makeMinimatch(src) {
|
|
9
|
+
if (typeof(src) == "string") {
|
|
10
|
+
return new Minimatch.Minimatch(src, null);
|
|
11
|
+
} else if (src instanceof Minimatch.Minimatch) {
|
|
12
|
+
return src;
|
|
13
|
+
} else {
|
|
14
|
+
throw new Error("Expected a string or Minimatch object.");
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
static get __name__() {
|
|
18
|
+
return "whet.magic._MinimatchType.MinimatchType_Fields_"
|
|
19
|
+
}
|
|
20
|
+
get __class__() {
|
|
21
|
+
return MinimatchType_Fields_
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export const makeMinimatch = MinimatchType_Fields_.makeMinimatch
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import {Router, RoutePath} from "../route/Router"
|
|
2
|
-
import {
|
|
2
|
+
import {MinimatchType} from "./MinimatchType"
|
|
3
|
+
import {AnyStone} from "../Stone"
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Anything that can be transformed into `
|
|
6
|
+
* Anything that can be transformed into `RoutePath`. Can be a Stone or Router.
|
|
7
|
+
* Can also be an array of Stones, Routers, or:
|
|
8
|
+
* - `[routeUnder, Stone|Router]`, where `routeUnder` is a string to serve the results under (directory or filename).
|
|
9
|
+
* - `[routeUnder, Stone|Router, filter]`, where `filter` can be a glob pattern string, or a `Minimatch` object.
|
|
10
|
+
* - `[routeUnder, Stone|Router, filter, extractDirs]`, where `extractDirs` can be a glob pattern,
|
|
11
|
+
* or a `Minimatch` object, and is used to remove the portion of results' directory that matches.
|
|
12
|
+
* Wherever Stone or Router is expected, a string can be used as a shortcut for `new Files({ paths: [<string>] })`.
|
|
6
13
|
*/
|
|
7
|
-
export type RoutePathType =
|
|
14
|
+
export type RoutePathType = BaseRouteType | BaseRouteType[] | BaseRouteType[][]
|
|
15
|
+
|
|
16
|
+
export type BaseRouteType = Router | AnyStone | MinimatchType | string
|
|
8
17
|
|
|
9
18
|
export const makeRoutePath: (routerPathType: RoutePathType) => RoutePath[]
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import {Files} from "../stones/Files.js"
|
|
1
2
|
import {Router} from "../route/Router.js"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import {MinimatchType_Fields_} from "./MinimatchType.js"
|
|
4
|
+
import {Stone} from "../Stone.js"
|
|
4
5
|
import * as Path from "path"
|
|
6
|
+
import Minimatch from "minimatch"
|
|
5
7
|
import {Register} from "../../genes/Register.js"
|
|
6
8
|
import {StringTools} from "../../StringTools.js"
|
|
7
9
|
import {HxOverrides} from "../../HxOverrides.js"
|
|
@@ -11,11 +13,18 @@ const $global = Register.$global
|
|
|
11
13
|
export const RoutePathType_Fields_ = Register.global("$hxClasses")["whet.magic._RoutePathType.RoutePathType_Fields_"] =
|
|
12
14
|
class RoutePathType_Fields_ {
|
|
13
15
|
static makeRoutePath(routerPathType) {
|
|
14
|
-
if (((routerPathType) instanceof Router)) {
|
|
15
|
-
|
|
16
|
+
if (((routerPathType) instanceof Router) || ((routerPathType) instanceof Stone) || typeof(routerPathType) == "string") {
|
|
17
|
+
var s = "/";
|
|
18
|
+
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
19
|
+
if (str.length > 0) {
|
|
20
|
+
str = Path.posix.normalize(str);
|
|
21
|
+
str = StringTools.replace(str, "\\", "/");
|
|
22
|
+
};
|
|
23
|
+
s = str;
|
|
24
|
+
return [{"routeUnder": (HxOverrides.cca(s, 0) == 47) ? s : "/" + s, "source": (typeof(routerPathType) == "string") ? new Files({"paths": [routerPathType]}) : routerPathType, "filter": null, "extractDirs": null}];
|
|
16
25
|
};
|
|
17
26
|
if (!((routerPathType) instanceof Array)) {
|
|
18
|
-
throw new Error("RoutePath should be an array.");
|
|
27
|
+
throw new Error("RoutePath should be a Stone, Router, or an array.");
|
|
19
28
|
};
|
|
20
29
|
var _g = [];
|
|
21
30
|
var _g1 = 0;
|
|
@@ -23,25 +32,80 @@ class RoutePathType_Fields_ {
|
|
|
23
32
|
while (_g1 < _g2.length) {
|
|
24
33
|
var item = _g2[_g1];
|
|
25
34
|
++_g1;
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
if (((item) instanceof Router) || ((item) instanceof Stone) || typeof(item) == "string") {
|
|
36
|
+
var s = "/";
|
|
37
|
+
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
38
|
+
if (str.length > 0) {
|
|
39
|
+
str = Path.posix.normalize(str);
|
|
40
|
+
str = StringTools.replace(str, "\\", "/");
|
|
41
|
+
};
|
|
42
|
+
s = str;
|
|
43
|
+
_g.push({"routeUnder": (HxOverrides.cca(s, 0) == 47) ? s : "/" + s, "source": (typeof(item) == "string") ? new Files({"paths": [item]}) : item, "filter": null, "extractDirs": null});
|
|
44
|
+
} else if (((item) instanceof Array)) {
|
|
45
|
+
var inner = item;
|
|
46
|
+
if (typeof(inner[0]) != "string") {
|
|
47
|
+
throw new Error("First element of RoutePath array should be `routeUnder` (a string).");
|
|
48
|
+
};
|
|
49
|
+
if (!(((inner[1]) instanceof Router) || ((inner[1]) instanceof Stone) || typeof(inner[1]) == "string")) {
|
|
50
|
+
throw new Error("Second element of RoutePath array should be a Stone or Router.");
|
|
51
|
+
};
|
|
52
|
+
var tmp;
|
|
53
|
+
switch (inner.length) {
|
|
54
|
+
case 2:
|
|
55
|
+
var s1 = inner[0];
|
|
56
|
+
var str1 = (s1.length > 1 && HxOverrides.cca(s1, 0) == 47) ? s1.substring(1) : s1;
|
|
57
|
+
if (str1.length > 0) {
|
|
58
|
+
str1 = Path.posix.normalize(str1);
|
|
59
|
+
str1 = StringTools.replace(str1, "\\", "/");
|
|
60
|
+
};
|
|
61
|
+
s1 = str1;
|
|
62
|
+
var src = inner[1];
|
|
63
|
+
tmp = {"routeUnder": (HxOverrides.cca(s1, 0) == 47) ? s1 : "/" + s1, "source": (typeof(src) == "string") ? new Files({"paths": [src]}) : src, "filter": null, "extractDirs": null};
|
|
64
|
+
break
|
|
65
|
+
case 3:
|
|
66
|
+
var s2 = inner[0];
|
|
67
|
+
var str2 = (s2.length > 1 && HxOverrides.cca(s2, 0) == 47) ? s2.substring(1) : s2;
|
|
68
|
+
if (str2.length > 0) {
|
|
69
|
+
str2 = Path.posix.normalize(str2);
|
|
70
|
+
str2 = StringTools.replace(str2, "\\", "/");
|
|
71
|
+
};
|
|
72
|
+
s2 = str2;
|
|
73
|
+
var tmp1 = (HxOverrides.cca(s2, 0) == 47) ? s2 : "/" + s2;
|
|
74
|
+
var src1 = inner[1];
|
|
75
|
+
var tmp2 = (typeof(src1) == "string") ? new Files({"paths": [src1]}) : src1;
|
|
76
|
+
if (!(typeof(inner[2]) == "string" || inner[2] instanceof Minimatch)) {
|
|
77
|
+
throw new Error("Third" + " element of RoutePath array should be a glob pattern (string or `minimatch` object)");
|
|
78
|
+
};
|
|
79
|
+
tmp = {"routeUnder": tmp1, "source": tmp2, "filter": MinimatchType_Fields_.makeMinimatch(inner[2]), "extractDirs": null};
|
|
80
|
+
break
|
|
81
|
+
case 4:
|
|
82
|
+
var s3 = inner[0];
|
|
83
|
+
var str3 = (s3.length > 1 && HxOverrides.cca(s3, 0) == 47) ? s3.substring(1) : s3;
|
|
84
|
+
if (str3.length > 0) {
|
|
85
|
+
str3 = Path.posix.normalize(str3);
|
|
86
|
+
str3 = StringTools.replace(str3, "\\", "/");
|
|
87
|
+
};
|
|
88
|
+
s3 = str3;
|
|
89
|
+
var tmp3 = (HxOverrides.cca(s3, 0) == 47) ? s3 : "/" + s3;
|
|
90
|
+
var src2 = inner[1];
|
|
91
|
+
var tmp4 = (typeof(src2) == "string") ? new Files({"paths": [src2]}) : src2;
|
|
92
|
+
if (!(typeof(inner[2]) == "string" || inner[2] instanceof Minimatch)) {
|
|
93
|
+
throw new Error("Third" + " element of RoutePath array should be a glob pattern (string or `minimatch` object)");
|
|
94
|
+
};
|
|
95
|
+
var tmp5 = MinimatchType_Fields_.makeMinimatch(inner[2]);
|
|
96
|
+
if (!(typeof(inner[3]) == "string" || inner[3] instanceof Minimatch)) {
|
|
97
|
+
throw new Error("Fourth" + " element of RoutePath array should be a glob pattern (string or `minimatch` object)");
|
|
98
|
+
};
|
|
99
|
+
tmp = {"routeUnder": tmp3, "source": tmp4, "filter": tmp5, "extractDirs": MinimatchType_Fields_.makeMinimatch(inner[3])};
|
|
100
|
+
break
|
|
101
|
+
default:
|
|
102
|
+
throw new Error("Invalid array for a RoutePath element.");
|
|
103
|
+
|
|
104
|
+
};
|
|
105
|
+
_g.push(tmp);
|
|
106
|
+
} else {
|
|
107
|
+
throw new Error("Unexpected RoutePath element.");
|
|
31
108
|
};
|
|
32
|
-
if (item.length > 3) {
|
|
33
|
-
throw new Error("RoutePath element should have at most 3 entries `[serveId, route, filter]`.");
|
|
34
|
-
};
|
|
35
|
-
var s = item[0];
|
|
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;
|
|
43
|
-
var _g3 = item.slice(1);
|
|
44
|
-
_g.push({"routeUnder": tmp, "route": (_g3.length == 1) ? (((item[1]) instanceof Route)) ? item[1] : RouteType_Fields_.makeRoute([_g3]) : RouteType_Fields_.makeRoute([_g3])});
|
|
45
109
|
};
|
|
46
110
|
return _g;
|
|
47
111
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {Log} from "../../haxe/Log.js"
|
|
2
1
|
import {Register} from "../../genes/Register.js"
|
|
3
2
|
|
|
4
3
|
const $global = Register.$global
|
|
@@ -13,16 +12,6 @@ class RouteResult extends Register.inherits() {
|
|
|
13
12
|
get() {
|
|
14
13
|
var _gthis = this;
|
|
15
14
|
return this.source.getSource().then(function (data) {
|
|
16
|
-
Log.trace("getting ", {"fileName": "src/whet/route/RouteResult.hx", "lineNumber": 17, "className": "whet.route.RouteResult", "methodName": "get", "customParams": [_gthis.sourceId, "has data:"]});
|
|
17
|
-
var _this = data.data;
|
|
18
|
-
var result = new Array(_this.length);
|
|
19
|
-
var _g = 0;
|
|
20
|
-
var _g1 = _this.length;
|
|
21
|
-
while (_g < _g1) {
|
|
22
|
-
var i = _g++;
|
|
23
|
-
result[i] = _this[i].id;
|
|
24
|
-
};
|
|
25
|
-
console.log("src/whet/route/RouteResult.hx:18:",result);
|
|
26
15
|
return data.get(_gthis.sourceId);
|
|
27
16
|
});
|
|
28
17
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {RouteResult} from "./RouteResult"
|
|
2
|
-
import {Route} from "./Route"
|
|
3
2
|
import {RoutePathType} from "../magic/RoutePathType"
|
|
3
|
+
import {MinimatchType} from "../magic/MinimatchType"
|
|
4
|
+
import {AnyStone} from "../Stone"
|
|
4
5
|
import {SourceHash} from "../SourceHash"
|
|
6
|
+
import Minimatch from "minimatch"
|
|
5
7
|
|
|
6
8
|
export declare class Router {
|
|
7
9
|
constructor(routes?: null | RoutePathType)
|
|
@@ -9,25 +11,30 @@ export declare class Router {
|
|
|
9
11
|
route(r: RoutePathType): void
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
* Find data sources routed under `
|
|
13
|
-
*
|
|
14
|
+
* Find data sources routed under `pattern`.
|
|
15
|
+
* @param pattern A glob pattern to search for.
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
get(pattern?: MinimatchType): Promise<RouteResult[]>
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
|
-
* Get combined hash of all sources that
|
|
20
|
+
* Get combined hash of all sources that fit the `pattern`.
|
|
19
21
|
*/
|
|
20
|
-
getHash(
|
|
21
|
-
getHashOfEverything(): Promise<SourceHash>
|
|
22
|
+
getHash(pattern?: MinimatchType): Promise<SourceHash>
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
|
-
* Save files filtered by `
|
|
25
|
+
* Save files filtered by `pattern` into provided `saveInto` folder.
|
|
25
26
|
*/
|
|
26
|
-
saveInto(
|
|
27
|
-
listContents(
|
|
27
|
+
saveInto(pattern: MinimatchType, saveInto: string, clearFirst?: boolean): Promise<any>
|
|
28
|
+
listContents(pattern?: MinimatchType): Promise<string>
|
|
29
|
+
protected allFromRoute(route: RoutePath): Promise<RouteResult[]>
|
|
30
|
+
protected getServeId(path: string, route: RoutePath): string
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
export type RoutePath = {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
extractDirs: Minimatch,
|
|
35
|
+
filter: Minimatch,
|
|
36
|
+
routeUnder: string,
|
|
37
|
+
source: RouterSource
|
|
33
38
|
}
|
|
39
|
+
|
|
40
|
+
export type RouterSource = AnyStone | Router
|