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,7 +1,6 @@
|
|
|
1
1
|
import {RouteType_Fields_} from "../magic/RouteType.js"
|
|
2
2
|
import {MaybeArray_Fields_} from "../magic/MaybeArray.js"
|
|
3
3
|
import {Stone} from "../Stone.js"
|
|
4
|
-
import {SourceId_Fields_} from "../SourceId.js"
|
|
5
4
|
import {SourceHash} from "../SourceHash.js"
|
|
6
5
|
import {SourceData} from "../Source.js"
|
|
7
6
|
import * as Path from "path"
|
|
@@ -92,9 +91,13 @@ class JsonStone extends Register.inherits(Stone) {
|
|
|
92
91
|
}
|
|
93
92
|
list() {
|
|
94
93
|
var s = this.config.name;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
95
|
+
if (str.length > 0) {
|
|
96
|
+
str = Path.posix.normalize(str);
|
|
97
|
+
str = StringTools.replace(str, "\\", "/");
|
|
98
|
+
};
|
|
99
|
+
s = str;
|
|
100
|
+
return Promise.resolve([(HxOverrides.cca(s, 0) == 47) ? s : "/" + s]);
|
|
98
101
|
}
|
|
99
102
|
initConfig() {
|
|
100
103
|
if (this.config.name == null) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {StoneIdType} from "../magic/StoneId"
|
|
2
|
+
import {MaybeArray} from "../magic/MaybeArray"
|
|
2
3
|
import {CacheStrategy} from "../cache/Cache"
|
|
3
|
-
import {Stone} from "../Stone"
|
|
4
|
+
import {Stone, AnyStone} from "../Stone"
|
|
4
5
|
import {SourceHash} from "../SourceHash"
|
|
5
6
|
import {SourceData} from "../Source"
|
|
6
7
|
import {Project} from "../Project"
|
|
@@ -17,6 +18,17 @@ export declare class RemoteFile extends Stone<RemoteFileConfig> {
|
|
|
17
18
|
export type RemoteFileConfig = {
|
|
18
19
|
cacheStrategy?: null | CacheStrategy,
|
|
19
20
|
/**
|
|
21
|
+
* Registers another stone as dependency of this one. Useful for external processes
|
|
22
|
+
* that use a source of some stone, but don't go via Whet to get it.
|
|
23
|
+
* Use with combination of `setAbsolutePath` on the dependency, so that the external process
|
|
24
|
+
* can rely on fixed path.
|
|
25
|
+
* Will make sure the cached file is up to date when generating this stone.
|
|
26
|
+
* Hash of the dependency is automatically combined with hash generated by this stone. There's no
|
|
27
|
+
* need to add it manually.
|
|
28
|
+
* Do not create cyclic dependencies!
|
|
29
|
+
*/
|
|
30
|
+
dependencies?: null | MaybeArray<AnyStone>,
|
|
31
|
+
/**
|
|
20
32
|
Defaults to the Stone's class name.
|
|
21
33
|
*/
|
|
22
34
|
id?: null | StoneIdType,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {CacheStrategy, CacheDurability} from "../cache/Cache.js"
|
|
2
2
|
import {Stone} from "../Stone.js"
|
|
3
|
-
import {SourceId_Fields_} from "../SourceId.js"
|
|
4
3
|
import {SourceHash} from "../SourceHash.js"
|
|
5
4
|
import {SourceData} from "../Source.js"
|
|
6
5
|
import {Log} from "../Log.js"
|
|
@@ -52,9 +51,13 @@ class RemoteFile extends Register.inherits(Stone) {
|
|
|
52
51
|
}
|
|
53
52
|
getId() {
|
|
54
53
|
var s = Path.basename(new URL(this.config.url).pathname);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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;
|
|
58
61
|
}
|
|
59
62
|
static get __name__() {
|
|
60
63
|
return "whet.stones.RemoteFile"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {Router} from "../route/Router"
|
|
2
2
|
import {StoneIdType} from "../magic/StoneId"
|
|
3
|
+
import {MaybeArray} from "../magic/MaybeArray"
|
|
3
4
|
import {CacheStrategy} from "../cache/Cache"
|
|
4
|
-
import {Stone} from "../Stone"
|
|
5
|
+
import {Stone, AnyStone} from "../Stone"
|
|
5
6
|
import {SourceHash} from "../SourceHash"
|
|
6
7
|
import {SourceData} from "../Source"
|
|
7
8
|
import {Project} from "../Project"
|
|
@@ -26,6 +27,17 @@ export declare class Server extends Stone<ServerConfig> {
|
|
|
26
27
|
export type ServerConfig = {
|
|
27
28
|
cacheStrategy?: null | CacheStrategy,
|
|
28
29
|
/**
|
|
30
|
+
* Registers another stone as dependency of this one. Useful for external processes
|
|
31
|
+
* that use a source of some stone, but don't go via Whet to get it.
|
|
32
|
+
* Use with combination of `setAbsolutePath` on the dependency, so that the external process
|
|
33
|
+
* can rely on fixed path.
|
|
34
|
+
* Will make sure the cached file is up to date when generating this stone.
|
|
35
|
+
* Hash of the dependency is automatically combined with hash generated by this stone. There's no
|
|
36
|
+
* need to add it manually.
|
|
37
|
+
* Do not create cyclic dependencies!
|
|
38
|
+
*/
|
|
39
|
+
dependencies?: null | MaybeArray<AnyStone>,
|
|
40
|
+
/**
|
|
29
41
|
Defaults to the Stone's class name.
|
|
30
42
|
*/
|
|
31
43
|
id?: null | StoneIdType,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {Stone} from "../Stone.js"
|
|
2
|
-
import {SourceId_Fields_} from "../SourceId.js"
|
|
3
2
|
import {Log} from "../Log.js"
|
|
4
3
|
import * as Path from "path"
|
|
5
4
|
import Mime from "mime"
|
|
@@ -55,45 +54,69 @@ class Server extends Register.inherits(Stone) {
|
|
|
55
54
|
handler(req, res) {
|
|
56
55
|
var _gthis = this;
|
|
57
56
|
Log.log(30, ...["Handling request.", {"url": req.url, "method": req.method}]);
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
var searchIndex = req.url.indexOf("?");
|
|
58
|
+
var id;
|
|
59
|
+
if (searchIndex > 0) {
|
|
60
|
+
var s = req.url.substring(0, searchIndex);
|
|
61
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
62
|
+
if (str.length > 0) {
|
|
63
|
+
str = Path.posix.normalize(str);
|
|
64
|
+
str = StringTools.replace(str, "\\", "/");
|
|
65
|
+
};
|
|
66
|
+
s = str;
|
|
67
|
+
id = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
68
|
+
} else {
|
|
69
|
+
var s = req.url;
|
|
70
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
71
|
+
if (str.length > 0) {
|
|
72
|
+
str = Path.posix.normalize(str);
|
|
73
|
+
str = StringTools.replace(str, "\\", "/");
|
|
74
|
+
};
|
|
75
|
+
s = str;
|
|
76
|
+
id = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
77
|
+
};
|
|
62
78
|
if (req.method == "GET") {
|
|
63
|
-
if (
|
|
79
|
+
if (HxOverrides.cca(id, id.length - 1) == 47) {
|
|
64
80
|
if ("index.html".length > 0) {
|
|
65
81
|
var s = id.substring(0, id.lastIndexOf("/") + 1);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
82
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
83
|
+
if (str.length > 0) {
|
|
84
|
+
str = Path.posix.normalize(str);
|
|
85
|
+
str = StringTools.replace(str, "\\", "/");
|
|
86
|
+
};
|
|
87
|
+
s = str;
|
|
88
|
+
id = ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s) + "index.html";
|
|
69
89
|
};
|
|
70
90
|
} else if (Path.posix.extname(id) == "") {
|
|
71
91
|
var s = "" + id + "/index.html";
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
93
|
+
if (str.length > 0) {
|
|
94
|
+
str = Path.posix.normalize(str);
|
|
95
|
+
str = StringTools.replace(str, "\\", "/");
|
|
96
|
+
};
|
|
97
|
+
s = str;
|
|
98
|
+
id = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
75
99
|
};
|
|
76
100
|
this.config.router.find(id).then(function (routeResult) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
res.writeHead(200, {"Content-Type": Mime.getType(Path.posix.extname(id).toLowerCase()), "Last-Modified": new Date(source.source.ctime * 1000).toUTCString(), "Content-Length": Std.string(source.data.length), "Cache-Control": "no-store, no-cache"});
|
|
81
|
-
res.write(source.data, "binary");
|
|
101
|
+
return ((routeResult.length > 0) ? routeResult[0].get() : (_gthis.routeDynamic != null) ? _gthis.routeDynamic(id) : Promise.resolve(null)).then(function (source) {
|
|
102
|
+
if (source == null) {
|
|
103
|
+
res.writeHead(404, "File not found.");
|
|
82
104
|
res.end();
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
res.write(e.stack, "utf-8");
|
|
88
|
-
} else {
|
|
89
|
-
res.write(Std.string(e), "utf-8");
|
|
90
|
-
};
|
|
91
|
-
res.end();
|
|
92
|
-
});
|
|
93
|
-
} else {
|
|
94
|
-
res.writeHead(404, "File not found.");
|
|
105
|
+
return;
|
|
106
|
+
};
|
|
107
|
+
res.writeHead(200, {"Content-Type": Mime.getType(Path.posix.extname(id).toLowerCase()), "Last-Modified": new Date(source.source.ctime * 1000).toUTCString(), "Content-Length": Std.string(source.data.length), "Cache-Control": "no-store, no-cache"});
|
|
108
|
+
res.write(source.data, "binary");
|
|
95
109
|
res.end();
|
|
96
|
-
}
|
|
110
|
+
})["catch"](function (e) {
|
|
111
|
+
Log.log(40, ...["Server error.", {"error": e}]);
|
|
112
|
+
res.writeHead(500, "Error happened.");
|
|
113
|
+
if (((e) instanceof Error)) {
|
|
114
|
+
res.write(e.stack, "utf-8");
|
|
115
|
+
} else {
|
|
116
|
+
res.write(Std.string(e), "utf-8");
|
|
117
|
+
};
|
|
118
|
+
res.end();
|
|
119
|
+
});
|
|
97
120
|
})["catch"](function (e) {
|
|
98
121
|
Log.log(40, ...["Server error.", {"error": e}]);
|
|
99
122
|
res.writeHead(500, "Error happened.");
|
package/bin/whet/stones/Zip.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {StoneIdType} from "../magic/StoneId"
|
|
2
2
|
import {RoutePathType} from "../magic/RoutePathType"
|
|
3
|
+
import {MaybeArray} from "../magic/MaybeArray"
|
|
3
4
|
import {CacheStrategy} from "../cache/Cache"
|
|
4
|
-
import {Stone} from "../Stone"
|
|
5
|
+
import {Stone, AnyStone} from "../Stone"
|
|
5
6
|
import {SourceHash} from "../SourceHash"
|
|
6
7
|
import {SourceData} from "../Source"
|
|
7
8
|
import {Project} from "../Project"
|
|
@@ -16,6 +17,17 @@ export declare class ZipStone extends Stone<ZipConfig> {
|
|
|
16
17
|
|
|
17
18
|
export type ZipConfig = {
|
|
18
19
|
cacheStrategy?: null | CacheStrategy,
|
|
20
|
+
/**
|
|
21
|
+
* Registers another stone as dependency of this one. Useful for external processes
|
|
22
|
+
* that use a source of some stone, but don't go via Whet to get it.
|
|
23
|
+
* Use with combination of `setAbsolutePath` on the dependency, so that the external process
|
|
24
|
+
* can rely on fixed path.
|
|
25
|
+
* Will make sure the cached file is up to date when generating this stone.
|
|
26
|
+
* Hash of the dependency is automatically combined with hash generated by this stone. There's no
|
|
27
|
+
* need to add it manually.
|
|
28
|
+
* Do not create cyclic dependencies!
|
|
29
|
+
*/
|
|
30
|
+
dependencies?: null | MaybeArray<AnyStone>,
|
|
19
31
|
filename?: null | string,
|
|
20
32
|
/**
|
|
21
33
|
Defaults to the Stone's class name.
|
package/bin/whet/stones/Zip.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {Router} from "../route/Router.js"
|
|
2
2
|
import {CacheStrategy, CacheDurability, DurabilityCheck} from "../cache/Cache.js"
|
|
3
3
|
import {Stone} from "../Stone.js"
|
|
4
|
-
import {SourceId_Fields_} from "../SourceId.js"
|
|
5
4
|
import {SourceHash} from "../SourceHash.js"
|
|
6
5
|
import {SourceData} from "../Source.js"
|
|
7
6
|
import {Log} from "../Log.js"
|
|
@@ -76,9 +75,13 @@ class ZipStone extends Register.inherits(Stone) {
|
|
|
76
75
|
var bytes = Helper.bytesOfBuffer(data.data);
|
|
77
76
|
var this1 = file[0].serveId;
|
|
78
77
|
var s = "/";
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
79
|
+
if (str.length > 0) {
|
|
80
|
+
str = Path.posix.normalize(str);
|
|
81
|
+
str = StringTools.replace(str, "\\", "/");
|
|
82
|
+
};
|
|
83
|
+
s = str;
|
|
84
|
+
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
82
85
|
if (this1.charAt(0) != "/") {
|
|
83
86
|
throw new Error("Badly formed SourceId.");
|
|
84
87
|
};
|
|
@@ -100,9 +103,13 @@ class ZipStone extends Register.inherits(Stone) {
|
|
|
100
103
|
}
|
|
101
104
|
list() {
|
|
102
105
|
var s = this.config.filename;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
107
|
+
if (str.length > 0) {
|
|
108
|
+
str = Path.posix.normalize(str);
|
|
109
|
+
str = StringTools.replace(str, "\\", "/");
|
|
110
|
+
};
|
|
111
|
+
s = str;
|
|
112
|
+
return Promise.resolve([(HxOverrides.cca(s, 0) == 47) ? s : "/" + s]);
|
|
106
113
|
}
|
|
107
114
|
static get __name__() {
|
|
108
115
|
return "whet.stones.ZipStone"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {Hxml} from "./Hxml"
|
|
2
2
|
import {StoneIdType} from "../../magic/StoneId"
|
|
3
|
+
import {MaybeArray} from "../../magic/MaybeArray"
|
|
3
4
|
import {CacheStrategy} from "../../cache/Cache"
|
|
4
|
-
import {Stone} from "../../Stone"
|
|
5
|
+
import {Stone, AnyStone} from "../../Stone"
|
|
5
6
|
import {SourceHash} from "../../SourceHash"
|
|
6
7
|
import {SourceData} from "../../Source"
|
|
7
8
|
import {Project} from "../../Project"
|
|
@@ -22,6 +23,17 @@ export declare class HaxeBuild extends Stone<BuildConfig> {
|
|
|
22
23
|
|
|
23
24
|
export type BuildConfig = {
|
|
24
25
|
cacheStrategy?: null | CacheStrategy,
|
|
26
|
+
/**
|
|
27
|
+
* Registers another stone as dependency of this one. Useful for external processes
|
|
28
|
+
* that use a source of some stone, but don't go via Whet to get it.
|
|
29
|
+
* Use with combination of `setAbsolutePath` on the dependency, so that the external process
|
|
30
|
+
* can rely on fixed path.
|
|
31
|
+
* Will make sure the cached file is up to date when generating this stone.
|
|
32
|
+
* Hash of the dependency is automatically combined with hash generated by this stone. There's no
|
|
33
|
+
* need to add it manually.
|
|
34
|
+
* Do not create cyclic dependencies!
|
|
35
|
+
*/
|
|
36
|
+
dependencies?: null | MaybeArray<AnyStone>,
|
|
25
37
|
filename?: null | string,
|
|
26
38
|
hxml: Hxml,
|
|
27
39
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
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 {RootDir} from "../../SourceId.js"
|
|
5
5
|
import {SourceHash} from "../../SourceHash.js"
|
|
6
6
|
import {SourceData} from "../../Source.js"
|
|
7
7
|
import {Log} from "../../Log.js"
|
|
@@ -34,9 +34,13 @@ class HaxeBuild extends Register.inherits(Stone) {
|
|
|
34
34
|
var cwd = process.cwd();
|
|
35
35
|
var this1 = _gthis.project.rootDir;
|
|
36
36
|
var s = "/";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
40
44
|
if (this1.charAt(0) != "/") {
|
|
41
45
|
throw new Error("Badly formed SourceId.");
|
|
42
46
|
};
|
|
@@ -89,7 +93,7 @@ class HaxeBuild extends Register.inherits(Stone) {
|
|
|
89
93
|
addCommands() {
|
|
90
94
|
var _gthis = this;
|
|
91
95
|
this.project.addCommand("build", this).action(function (..._) {
|
|
92
|
-
return _gthis.
|
|
96
|
+
return _gthis.project.cache.refreshSource(_gthis);
|
|
93
97
|
});
|
|
94
98
|
}
|
|
95
99
|
list() {
|
|
@@ -107,9 +111,13 @@ class HaxeBuild extends Register.inherits(Stone) {
|
|
|
107
111
|
while (_g < _g1) {
|
|
108
112
|
var i = _g++;
|
|
109
113
|
var s = _this[i];
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
115
|
+
if (str.length > 0) {
|
|
116
|
+
str = Path.posix.normalize(str);
|
|
117
|
+
str = StringTools.replace(str, "\\", "/");
|
|
118
|
+
};
|
|
119
|
+
s = str;
|
|
120
|
+
var this1 = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
113
121
|
var root = RootDir.fromProject(this.config.hxml.project);
|
|
114
122
|
if (this1.charAt(0) != "/") {
|
|
115
123
|
throw new Error("Badly formed SourceId.");
|
|
@@ -2,7 +2,7 @@ import {HaxeBuild} from "./HaxeBuild"
|
|
|
2
2
|
import {StoneIdType} from "../../magic/StoneId"
|
|
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"
|
|
@@ -34,6 +34,17 @@ export type HxmlConfig = {
|
|
|
34
34
|
dce?: null | DCE,
|
|
35
35
|
debug?: null | boolean,
|
|
36
36
|
defines?: null | MaybeArray<string>,
|
|
37
|
+
/**
|
|
38
|
+
* Registers another stone as dependency of this one. Useful for external processes
|
|
39
|
+
* that use a source of some stone, but don't go via Whet to get it.
|
|
40
|
+
* Use with combination of `setAbsolutePath` on the dependency, so that the external process
|
|
41
|
+
* can rely on fixed path.
|
|
42
|
+
* Will make sure the cached file is up to date when generating this stone.
|
|
43
|
+
* Hash of the dependency is automatically combined with hash generated by this stone. There's no
|
|
44
|
+
* need to add it manually.
|
|
45
|
+
* Do not create cyclic dependencies!
|
|
46
|
+
*/
|
|
47
|
+
dependencies?: null | MaybeArray<AnyStone>,
|
|
37
48
|
flags?: null | MaybeArray<MaybeArray<string>>,
|
|
38
49
|
/**
|
|
39
50
|
Defaults to the Stone's class name.
|
|
@@ -3,7 +3,7 @@ import {StoneId_Fields_} from "../../magic/StoneId.js"
|
|
|
3
3
|
import {MaybeArray_Fields_} from "../../magic/MaybeArray.js"
|
|
4
4
|
import {CacheStrategy, CacheDurability} from "../../cache/Cache.js"
|
|
5
5
|
import {Stone} from "../../Stone.js"
|
|
6
|
-
import {SourceId
|
|
6
|
+
import {SourceId} from "../../SourceId.js"
|
|
7
7
|
import {SourceHash} from "../../SourceHash.js"
|
|
8
8
|
import {SourceData} from "../../Source.js"
|
|
9
9
|
import {Log} from "../../Log.js"
|
|
@@ -149,14 +149,22 @@ class Hxml extends Register.inherits(Stone) {
|
|
|
149
149
|
var filename;
|
|
150
150
|
if (this.build.config.filename != null) {
|
|
151
151
|
var s = this.build.config.filename;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
153
|
+
if (str.length > 0) {
|
|
154
|
+
str = Path.posix.normalize(str);
|
|
155
|
+
str = StringTools.replace(str, "\\", "/");
|
|
156
|
+
};
|
|
157
|
+
s = str;
|
|
158
|
+
filename = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
155
159
|
} else {
|
|
156
160
|
var s = "build";
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
161
|
+
var str = ("build".length > 1 && HxOverrides.cca("build", 0) == 47) ? "build".substring(1) : "build";
|
|
162
|
+
if (str.length > 0) {
|
|
163
|
+
str = Path.posix.normalize(str);
|
|
164
|
+
str = StringTools.replace(str, "\\", "/");
|
|
165
|
+
};
|
|
166
|
+
s = str;
|
|
167
|
+
filename = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
160
168
|
};
|
|
161
169
|
if (Path.posix.extname(filename) == "") {
|
|
162
170
|
var v = this.getBuildExtension();
|
|
@@ -164,9 +172,13 @@ class Hxml extends Register.inherits(Stone) {
|
|
|
164
172
|
v = "." + v;
|
|
165
173
|
};
|
|
166
174
|
var s = filename.substring(0, filename.lastIndexOf("/") + 1);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
175
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
176
|
+
if (str.length > 0) {
|
|
177
|
+
str = Path.posix.normalize(str);
|
|
178
|
+
str = StringTools.replace(str, "\\", "/");
|
|
179
|
+
};
|
|
180
|
+
s = str;
|
|
181
|
+
filename = ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s) + Path.posix.parse(filename.substring(filename.lastIndexOf("/"))).name + v;
|
|
170
182
|
};
|
|
171
183
|
return filename;
|
|
172
184
|
} else {
|
|
@@ -176,9 +188,13 @@ class Hxml extends Register.inherits(Stone) {
|
|
|
176
188
|
getPlatform() {
|
|
177
189
|
var this1 = this.getBuildExportPath();
|
|
178
190
|
var s = "/";
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
191
|
+
var str = ("/".length > 1 && HxOverrides.cca("/", 0) == 47) ? "/".substring(1) : "/";
|
|
192
|
+
if (str.length > 0) {
|
|
193
|
+
str = Path.posix.normalize(str);
|
|
194
|
+
str = StringTools.replace(str, "\\", "/");
|
|
195
|
+
};
|
|
196
|
+
s = str;
|
|
197
|
+
var root = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
182
198
|
if (this1.charAt(0) != "/") {
|
|
183
199
|
throw new Error("Badly formed SourceId.");
|
|
184
200
|
};
|
|
@@ -282,18 +298,26 @@ class Hxml extends Register.inherits(Stone) {
|
|
|
282
298
|
}
|
|
283
299
|
filename() {
|
|
284
300
|
var s = this.id;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
301
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
302
|
+
if (str.length > 0) {
|
|
303
|
+
str = Path.posix.normalize(str);
|
|
304
|
+
str = StringTools.replace(str, "\\", "/");
|
|
305
|
+
};
|
|
306
|
+
s = str;
|
|
307
|
+
var fn = (HxOverrides.cca(s, 0) == 47) ? s : "/" + s;
|
|
288
308
|
if (Path.posix.extname(fn) == "") {
|
|
289
309
|
var v = "hxml";
|
|
290
310
|
if ("hxml".length > 0 && HxOverrides.cca("hxml", 0) != 46) {
|
|
291
311
|
v = "." + "hxml";
|
|
292
312
|
};
|
|
293
313
|
var s = fn.substring(0, fn.lastIndexOf("/") + 1);
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
314
|
+
var str = (s.length > 1 && HxOverrides.cca(s, 0) == 47) ? s.substring(1) : s;
|
|
315
|
+
if (str.length > 0) {
|
|
316
|
+
str = Path.posix.normalize(str);
|
|
317
|
+
str = StringTools.replace(str, "\\", "/");
|
|
318
|
+
};
|
|
319
|
+
s = str;
|
|
320
|
+
fn = ((HxOverrides.cca(s, 0) == 47) ? s : "/" + s) + Path.posix.parse(fn.substring(fn.lastIndexOf("/"))).name + v;
|
|
297
321
|
};
|
|
298
322
|
return fn;
|
|
299
323
|
}
|