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.
@@ -1,104 +0,0 @@
1
- import {Files} from "../stones/Files.js"
2
- import {RouteResult} from "../route/RouteResult.js"
3
- import {Route} from "../route/Route.js"
4
- import {MaybeArray_Fields_} from "./MaybeArray.js"
5
- import {Stone} from "../Stone.js"
6
- import {SourceId} from "../SourceId.js"
7
- import * as Path from "path"
8
- import {Register} from "../../genes/Register.js"
9
- import {StringTools} from "../../StringTools.js"
10
- import {Std} from "../../Std.js"
11
- import {HxOverrides} from "../../HxOverrides.js"
12
-
13
- const $global = Register.$global
14
-
15
- export const RouteType_Fields_ = Register.global("$hxClasses")["whet.magic._RouteType.RouteType_Fields_"] =
16
- class RouteType_Fields_ {
17
- static makeRoute(routeType) {
18
- if (((routeType) instanceof Route)) {
19
- return routeType;
20
- } else {
21
- return new Route(routeType);
22
- };
23
- }
24
- static makeRouteRoutes(routeType) {
25
- var _g = [];
26
- var _g1 = 0;
27
- var _g2 = MaybeArray_Fields_.makeArray(routeType);
28
- while (_g1 < _g2.length) {
29
- var tinner = MaybeArray_Fields_.makeArray(_g2[_g1++]);
30
- if (tinner.length == 1) {
31
- _g.push(RouteType_Fields_.getRoute(tinner[0]));
32
- } else if (tinner.length == 2) {
33
- if (typeof(tinner[1]) != "string") {
34
- throw new Error("Array-defined route's second element should be path (a string).");
35
- };
36
- var tinner1 = tinner[0];
37
- var s = tinner[1];
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));
45
- };
46
- };
47
- return _g;
48
- }
49
- static getRoute(t, path) {
50
- if (typeof(t) == "string") {
51
- var tmp = new Files({"paths": [t]});
52
- var tmp1;
53
- if (path != null) {
54
- tmp1 = path;
55
- } else {
56
- var s = t;
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;
64
- var s = p.substring(0, p.lastIndexOf("/") + 1);
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);
72
- };
73
- return {"stone": tmp, "path": tmp1};
74
- } else if (((t) instanceof Stone)) {
75
- var tmp;
76
- if (path != null) {
77
- tmp = path;
78
- } else {
79
- var s = "/";
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;
87
- };
88
- return {"stone": t, "path": tmp};
89
- } else if (((t) instanceof RouteResult)) {
90
- return {"stone": t.source, "path": t.sourceId};
91
- } else {
92
- throw new Error("Unsupported type for Route. Expected String, Stone or RouteResult, but got " + Std.string(t.constructor?.name) + ".");
93
- };
94
- }
95
- static get __name__() {
96
- return "whet.magic._RouteType.RouteType_Fields_"
97
- }
98
- get __class__() {
99
- return RouteType_Fields_
100
- }
101
- }
102
-
103
-
104
- export const makeRoute = RouteType_Fields_.makeRoute
@@ -1,19 +0,0 @@
1
- import {RouteResult} from "./RouteResult"
2
- import {RouteType} from "../magic/RouteType"
3
- import {AnyStone} from "../Stone"
4
- import {SourceHash} from "../SourceHash"
5
- import {SourceData} from "../Source"
6
-
7
- export declare class Route {
8
- constructor(route: RouteType)
9
- protected routes: RouteData[]
10
- add(r: RouteType): Route
11
- getHash(): Promise<SourceHash>
12
- list(): Promise<RouteResult[]>
13
- getData(): Promise<SourceData[]>
14
- }
15
-
16
- export type RouteData = {
17
- path: string,
18
- stone: AnyStone
19
- }
@@ -1,121 +0,0 @@
1
- import {RouteResult} from "./RouteResult.js"
2
- import {RouteType_Fields_} from "../magic/RouteType.js"
3
- import {SourceId} from "../SourceId.js"
4
- import {SourceHash} from "../SourceHash.js"
5
- import * as Path from "path"
6
- import {Register} from "../../genes/Register.js"
7
- import {StringTools} from "../../StringTools.js"
8
- import {HxOverrides} from "../../HxOverrides.js"
9
-
10
- const $global = Register.$global
11
-
12
- export const Route = Register.global("$hxClasses")["whet.route.Route"] =
13
- class Route extends Register.inherits() {
14
- new(route) {
15
- this.routes = (((route) instanceof Route)) ? route.routes.slice() : RouteType_Fields_.makeRouteRoutes(route);
16
- }
17
- add(r) {
18
- var _g = 0;
19
- var _g1 = RouteType_Fields_.makeRoute(r).routes;
20
- while (_g < _g1.length) this.routes.push(_g1[_g++]);
21
- return this;
22
- }
23
- getHash() {
24
- var _this = this.routes;
25
- var result = new Array(_this.length);
26
- var _g = 0;
27
- var _g1 = _this.length;
28
- while (_g < _g1) {
29
- var i = _g++;
30
- result[i] = _this[i].stone.getHash();
31
- };
32
- return Promise.all(result).then(function (hashes) {
33
- return SourceHash.merge(...hashes);
34
- });
35
- }
36
- list() {
37
- var _g = [];
38
- var _g1 = 0;
39
- var _g2 = this.routes;
40
- while (_g1 < _g2.length) {
41
- var r = [_g2[_g1]];
42
- ++_g1;
43
- _g.push(r[0].stone.list().then((function (r) {
44
- return function (list) {
45
- var arr = [];
46
- var this1 = r[0].path;
47
- if (HxOverrides.cca(this1, this1.length - 1) == 47) {
48
- var _g = 0;
49
- while (_g < list.length) {
50
- var path = list[_g];
51
- ++_g;
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
- };
69
- };
70
- } else {
71
- var _g = 0;
72
- while (_g < list.length) {
73
- var path = list[_g];
74
- ++_g;
75
- if (path == r[0].path) {
76
- var _g1 = r[0].stone;
77
- var s = path.substring(path.lastIndexOf("/"));
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));
85
- };
86
- };
87
- };
88
- return arr;
89
- };
90
- })(r)));
91
- };
92
- return Promise.all(_g).then(function (data) {
93
- var _g = [];
94
- var _g_current = 0;
95
- while (_g_current < data.length) {
96
- var x = Register.iter(data[_g_current++]);
97
- while (x.hasNext()) _g.push(x.next());
98
- };
99
- return _g;
100
- });
101
- }
102
- getData() {
103
- return this.list().then(function (l) {
104
- var result = new Array(l.length);
105
- var _g = 0;
106
- var _g1 = l.length;
107
- while (_g < _g1) {
108
- var i = _g++;
109
- result[i] = l[i].get();
110
- };
111
- return Promise.all(result);
112
- });
113
- }
114
- static get __name__() {
115
- return "whet.route.Route"
116
- }
117
- get __class__() {
118
- return Route
119
- }
120
- }
121
-