whet 0.0.1
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/LICENSE +21 -0
- package/README.md +47 -0
- package/bin/HxOverrides.d.ts +8 -0
- package/bin/HxOverrides.js +54 -0
- package/bin/Lambda.d.ts +86 -0
- package/bin/Lambda.js +141 -0
- package/bin/Map.d.ts +5 -0
- package/bin/Reflect.d.ts +19 -0
- package/bin/Reflect.js +41 -0
- package/bin/Std.d.ts +49 -0
- package/bin/Std.js +96 -0
- package/bin/StdTypes.d.ts +57 -0
- package/bin/StringTools.d.ts +23 -0
- package/bin/StringTools.js +36 -0
- package/bin/commander/AddHelpTextContext.d.ts +6 -0
- package/bin/commander/AddHelpTextPosition.d.ts +2 -0
- package/bin/commander/CommandOptions.d.ts +6 -0
- package/bin/commander/ErrorOptions.d.ts +11 -0
- package/bin/commander/ExecutableCommandOptions.d.ts +7 -0
- package/bin/commander/HelpContext.d.ts +4 -0
- package/bin/commander/HookEvent.d.ts +2 -0
- package/bin/commander/OptionValueSource.d.ts +2 -0
- package/bin/commander/OutputConfiguration.d.ts +8 -0
- package/bin/commander/ParseOptions.d.ts +4 -0
- package/bin/commander/ParseOptionsResult.d.ts +5 -0
- package/bin/genes/Register.d.ts +15 -0
- package/bin/genes/Register.js +107 -0
- package/bin/genes/util/EsMap.d.ts +12 -0
- package/bin/genes/util/EsMap.js +51 -0
- package/bin/haxe/Constraints.d.ts +8 -0
- package/bin/haxe/Constraints.js +5 -0
- package/bin/haxe/Exception.d.ts +66 -0
- package/bin/haxe/Exception.js +88 -0
- package/bin/haxe/NativeStackTrace.d.ts +7 -0
- package/bin/haxe/PosInfos.d.ts +19 -0
- package/bin/haxe/Rest.d.ts +2 -0
- package/bin/haxe/ValueException.d.ts +24 -0
- package/bin/haxe/ValueException.js +36 -0
- package/bin/haxe/crypto/Crc32.d.ts +12 -0
- package/bin/haxe/crypto/Crc32.js +40 -0
- package/bin/haxe/ds/List.d.ts +31 -0
- package/bin/haxe/ds/List.js +55 -0
- package/bin/haxe/ds/ObjectMap.d.ts +7 -0
- package/bin/haxe/ds/ObjectMap.js +25 -0
- package/bin/haxe/ds/StringMap.d.ts +6 -0
- package/bin/haxe/ds/StringMap.js +25 -0
- package/bin/haxe/exceptions/NotImplementedException.d.ts +10 -0
- package/bin/haxe/exceptions/NotImplementedException.js +27 -0
- package/bin/haxe/exceptions/PosException.d.ts +19 -0
- package/bin/haxe/exceptions/PosException.js +36 -0
- package/bin/haxe/extern/Rest.d.ts +11 -0
- package/bin/haxe/io/ArrayBufferView.d.ts +2 -0
- package/bin/haxe/io/Bytes.d.ts +19 -0
- package/bin/haxe/io/Bytes.js +78 -0
- package/bin/haxe/io/BytesBuffer.d.ts +19 -0
- package/bin/haxe/io/BytesBuffer.js +67 -0
- package/bin/haxe/io/BytesData.d.ts +2 -0
- package/bin/haxe/io/BytesOutput.d.ts +18 -0
- package/bin/haxe/io/BytesOutput.js +39 -0
- package/bin/haxe/io/Encoding.d.ts +20 -0
- package/bin/haxe/io/Encoding.js +20 -0
- package/bin/haxe/io/Error.d.ts +35 -0
- package/bin/haxe/io/Error.js +31 -0
- package/bin/haxe/io/Output.d.ts +63 -0
- package/bin/haxe/io/Output.js +126 -0
- package/bin/haxe/io/Path.d.ts +109 -0
- package/bin/haxe/io/Path.js +217 -0
- package/bin/haxe/io/UInt8Array.d.ts +2 -0
- package/bin/haxe/iterators/ArrayIterator.d.ts +19 -0
- package/bin/haxe/iterators/ArrayIterator.js +35 -0
- package/bin/haxe/macro/Expr.d.ts +331 -0
- package/bin/haxe/macro/Type.d.ts +609 -0
- package/bin/haxe/zip/Compress.d.ts +5 -0
- package/bin/haxe/zip/Compress.js +21 -0
- package/bin/haxe/zip/Entry.d.ts +27 -0
- package/bin/haxe/zip/Entry.js +15 -0
- package/bin/haxe/zip/Tools.d.ts +5 -0
- package/bin/haxe/zip/Tools.js +24 -0
- package/bin/haxe/zip/Writer.d.ts +22 -0
- package/bin/haxe/zip/Writer.js +149 -0
- package/bin/js/Boot.d.ts +18 -0
- package/bin/js/Boot.js +225 -0
- package/bin/js/Node.d.ts +6 -0
- package/bin/js/lib/ArrayBuffer.d.ts +4 -0
- package/bin/js/lib/ArrayBuffer.js +24 -0
- package/bin/js/lib/Iterator.d.ts +23 -0
- package/bin/js/lib/Map.d.ts +2 -0
- package/bin/js/lib/Object.d.ts +82 -0
- package/bin/js/lib/Promise.d.ts +10 -0
- package/bin/js/lib/intl/NumberFormat.d.ts +114 -0
- package/bin/js/node/Buffer.d.ts +3 -0
- package/bin/js/node/ChildProcess.d.ts +424 -0
- package/bin/js/node/Crypto.d.ts +21 -0
- package/bin/js/node/Dns.d.ts +57 -0
- package/bin/js/node/Fs.d.ts +308 -0
- package/bin/js/node/Http.d.ts +114 -0
- package/bin/js/node/Https.d.ts +330 -0
- package/bin/js/node/Iterator.d.ts +5 -0
- package/bin/js/node/Path.d.ts +44 -0
- package/bin/js/node/Process.d.ts +6 -0
- package/bin/js/node/Tls.d.ts +304 -0
- package/bin/js/node/Url.d.ts +126 -0
- package/bin/js/node/Util.d.ts +115 -0
- package/bin/js/node/Zlib.d.ts +29 -0
- package/bin/js/node/buffer/Buffer.d.ts +23 -0
- package/bin/js/node/buffer/Buffer.js +24 -0
- package/bin/js/node/child_process/ChildProcess.d.ts +11 -0
- package/bin/js/node/console/Console.d.ts +26 -0
- package/bin/js/node/http/Agent.d.ts +40 -0
- package/bin/js/node/http/ClientRequest.d.ts +10 -0
- package/bin/js/node/https/Agent.d.ts +50 -0
- package/bin/js/node/net/Server.d.ts +22 -0
- package/bin/js/node/net/Socket.d.ts +101 -0
- package/bin/js/node/stream/Duplex.d.ts +86 -0
- package/bin/js/node/stream/Readable.d.ts +41 -0
- package/bin/js/node/stream/Transform.d.ts +92 -0
- package/bin/js/node/stream/Writable.d.ts +57 -0
- package/bin/js/node/tls/SecureContext.d.ts +74 -0
- package/bin/js/node/tls/TLSSocket.d.ts +47 -0
- package/bin/ts/Undefined.d.ts +5 -0
- package/bin/whet/Log.d.ts +16 -0
- package/bin/whet/Log.js +106 -0
- package/bin/whet/Project.d.ts +33 -0
- package/bin/whet/Project.js +71 -0
- package/bin/whet/Source.d.ts +51 -0
- package/bin/whet/Source.js +136 -0
- package/bin/whet/SourceHash.d.ts +15 -0
- package/bin/whet/SourceHash.js +68 -0
- package/bin/whet/SourceId.d.ts +10 -0
- package/bin/whet/SourceId.js +74 -0
- package/bin/whet/Stone.d.ts +88 -0
- package/bin/whet/Stone.js +157 -0
- package/bin/whet/Utils.d.ts +16 -0
- package/bin/whet/Utils.js +72 -0
- package/bin/whet/Whet.d.ts +4 -0
- package/bin/whet/Whet.js +117 -0
- package/bin/whet/cache/BaseCache.d.ts +27 -0
- package/bin/whet/cache/BaseCache.js +210 -0
- package/bin/whet/cache/Cache.d.ts +72 -0
- package/bin/whet/cache/Cache.js +57 -0
- package/bin/whet/cache/CacheManager.d.ts +23 -0
- package/bin/whet/cache/CacheManager.js +103 -0
- package/bin/whet/cache/FileCache.d.ts +35 -0
- package/bin/whet/cache/FileCache.js +295 -0
- package/bin/whet/cache/MemoryCache.d.ts +12 -0
- package/bin/whet/cache/MemoryCache.js +58 -0
- package/bin/whet/magic/MaybeArray.d.ts +4 -0
- package/bin/whet/magic/MaybeArray.js +25 -0
- package/bin/whet/magic/RoutePathType.d.ts +9 -0
- package/bin/whet/magic/RoutePathType.js +48 -0
- package/bin/whet/magic/RouteType.d.ts +12 -0
- package/bin/whet/magic/RouteType.js +70 -0
- package/bin/whet/magic/StoneId.d.ts +5 -0
- package/bin/whet/magic/StoneId.js +32 -0
- package/bin/whet/route/Route.d.ts +15 -0
- package/bin/whet/route/Route.js +81 -0
- package/bin/whet/route/RouteResult.d.ts +22 -0
- package/bin/whet/route/RouteResult.js +25 -0
- package/bin/whet/route/Router.d.ts +33 -0
- package/bin/whet/route/Router.js +224 -0
- package/bin/whet/stones/Files.d.ts +28 -0
- package/bin/whet/stones/Files.js +86 -0
- package/bin/whet/stones/JsonStone.d.ts +33 -0
- package/bin/whet/stones/JsonStone.js +117 -0
- package/bin/whet/stones/RemoteFile.d.ts +28 -0
- package/bin/whet/stones/RemoteFile.js +71 -0
- package/bin/whet/stones/Server.d.ts +42 -0
- package/bin/whet/stones/Server.js +113 -0
- package/bin/whet/stones/Zip.d.ts +30 -0
- package/bin/whet/stones/Zip.js +111 -0
- package/bin/whet/stones/haxe/HaxeBuild.d.ts +34 -0
- package/bin/whet/stones/haxe/HaxeBuild.js +89 -0
- package/bin/whet/stones/haxe/Hxml.d.ts +102 -0
- package/bin/whet/stones/haxe/Hxml.js +348 -0
- package/bin/whet.d.ts +20 -0
- package/bin/whet.js +18 -0
- package/package.json +32 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {Router} from "../route/Router"
|
|
2
|
+
import {StoneIdType} from "../magic/StoneId"
|
|
3
|
+
import {CacheStrategy} from "../cache/Cache"
|
|
4
|
+
import {Stone} from "../Stone"
|
|
5
|
+
import {SourceHash} from "../SourceHash"
|
|
6
|
+
import {SourceData} from "../Source"
|
|
7
|
+
import {Project} from "../Project"
|
|
8
|
+
import {IncomingMessage, ServerResponse} from "http"
|
|
9
|
+
import {Command} from "commander"
|
|
10
|
+
|
|
11
|
+
export declare class Server extends Stone<ServerConfig> {
|
|
12
|
+
constructor(config: ServerConfig)
|
|
13
|
+
readonly router: Router
|
|
14
|
+
protected get_router(): Router
|
|
15
|
+
routeDynamic: (arg0: string) => Promise<SourceData>
|
|
16
|
+
protected generate(hash: SourceHash): Promise<SourceData[]>
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
Starts a static server hosting attached resources.
|
|
20
|
+
*/
|
|
21
|
+
serve(): void
|
|
22
|
+
protected initConfig(): void
|
|
23
|
+
protected getCommands(): Command[]
|
|
24
|
+
protected handler(req: IncomingMessage, res: ServerResponse): void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type ServerConfig = {
|
|
28
|
+
cacheStrategy?: null | CacheStrategy,
|
|
29
|
+
/**
|
|
30
|
+
Defaults to the Stone's class name.
|
|
31
|
+
*/
|
|
32
|
+
id?: null | StoneIdType,
|
|
33
|
+
/**
|
|
34
|
+
Defaults to 7000.
|
|
35
|
+
*/
|
|
36
|
+
port: number,
|
|
37
|
+
/**
|
|
38
|
+
Defaults to the last instanced project.
|
|
39
|
+
*/
|
|
40
|
+
project?: null | Project,
|
|
41
|
+
router: Router
|
|
42
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {Stone} from "../Stone.js"
|
|
2
|
+
import {Log} from "../Log.js"
|
|
3
|
+
import Mime from "mime"
|
|
4
|
+
import * as Http from "http"
|
|
5
|
+
import {Path} from "../../haxe/io/Path.js"
|
|
6
|
+
import {Register} from "../../genes/Register.js"
|
|
7
|
+
import {Command} from "commander"
|
|
8
|
+
import {Std} from "../../Std.js"
|
|
9
|
+
import {HxOverrides} from "../../HxOverrides.js"
|
|
10
|
+
|
|
11
|
+
const $global = Register.$global
|
|
12
|
+
|
|
13
|
+
export const Server = Register.global("$hxClasses")["whet.stones.Server"] =
|
|
14
|
+
class Server extends Register.inherits(Stone) {
|
|
15
|
+
new(config) {
|
|
16
|
+
this.routeDynamic = null;
|
|
17
|
+
super.new(config);
|
|
18
|
+
}
|
|
19
|
+
get router() {
|
|
20
|
+
return this.get_router()
|
|
21
|
+
}
|
|
22
|
+
get_router() {
|
|
23
|
+
return this.config.router;
|
|
24
|
+
}
|
|
25
|
+
generate(hash) {
|
|
26
|
+
throw new Error("Does not generate.");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
Starts a static server hosting attached resources.
|
|
31
|
+
*/
|
|
32
|
+
serve() {
|
|
33
|
+
var _gthis = this;
|
|
34
|
+
Http.createServer(Register.bind(this, this.handler)).listen(this.config.port, function () {
|
|
35
|
+
Log.log(30, ...["Started web server.", {"port": _gthis.config.port}]);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
initConfig() {
|
|
39
|
+
super.initConfig();
|
|
40
|
+
if (this.config.port == null) {
|
|
41
|
+
this.config.port = 7000;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
getCommands() {
|
|
45
|
+
var _gthis = this;
|
|
46
|
+
return [new Command("serve").option("-p, --port <port>", "server port", "" + this.config.port).action(function (...args) {
|
|
47
|
+
if (args[0].port != null) {
|
|
48
|
+
_gthis.config.port = Std.parseInt(args[0].port);
|
|
49
|
+
};
|
|
50
|
+
_gthis.serve();
|
|
51
|
+
return null;
|
|
52
|
+
})];
|
|
53
|
+
}
|
|
54
|
+
handler(req, res) {
|
|
55
|
+
var _gthis = this;
|
|
56
|
+
Log.log(30, ...["Handling request.", {"url": req.url, "method": req.method}]);
|
|
57
|
+
var id;
|
|
58
|
+
var s = req.url;
|
|
59
|
+
var norm = "/" + Path.normalize((s.charAt(0) == "/") ? HxOverrides.substr(s, 1, null) : s);
|
|
60
|
+
id = (s.lastIndexOf("/") == s.length - 1) ? Path.addTrailingSlash(norm) : norm;
|
|
61
|
+
if (req.method == "GET") {
|
|
62
|
+
var norm = "/" + Path.normalize((id.charAt(0) == "/") ? HxOverrides.substr(id, 1, null) : id);
|
|
63
|
+
var tmp = (id.lastIndexOf("/") == id.length - 1) ? Path.addTrailingSlash(norm) : norm;
|
|
64
|
+
var s = Path.addTrailingSlash(Path.directory(id));
|
|
65
|
+
var norm = "/" + Path.normalize((s.charAt(0) == "/") ? HxOverrides.substr(s, 1, null) : s);
|
|
66
|
+
if (tmp == ((s.lastIndexOf("/") == s.length - 1) ? Path.addTrailingSlash(norm) : norm)) {
|
|
67
|
+
if ("index.html".length > 0) {
|
|
68
|
+
var s = Path.addTrailingSlash(Path.directory(id));
|
|
69
|
+
var norm = "/" + Path.normalize((s.charAt(0) == "/") ? HxOverrides.substr(s, 1, null) : s);
|
|
70
|
+
id = ((s.lastIndexOf("/") == s.length - 1) ? Path.addTrailingSlash(norm) : norm) + "index.html";
|
|
71
|
+
};
|
|
72
|
+
} else if (Path.extension(id) == "") {
|
|
73
|
+
var s = "" + id + "/index.html";
|
|
74
|
+
var norm = "/" + Path.normalize((s.charAt(0) == "/") ? HxOverrides.substr(s, 1, null) : s);
|
|
75
|
+
id = (s.lastIndexOf("/") == s.length - 1) ? Path.addTrailingSlash(norm) : norm;
|
|
76
|
+
};
|
|
77
|
+
this.config.router.find(id).then(function (routeResult) {
|
|
78
|
+
var sourcePromise = (routeResult.length > 0) ? routeResult[0].get() : (_gthis.routeDynamic != null) ? _gthis.routeDynamic(id) : null;
|
|
79
|
+
if (sourcePromise != null) {
|
|
80
|
+
sourcePromise.then(function (source) {
|
|
81
|
+
res.writeHead(200, {"Content-Type": Mime.getType(Path.extension(id).toLowerCase()), "Last-Modified": new Date(source.source.ctime * 1000).toUTCString(), "Content-Length": Std.string(source.data.length), "Cache-Control": "no-store, no-cache"});
|
|
82
|
+
res.write(source.data, "binary");
|
|
83
|
+
res.end();
|
|
84
|
+
})["catch"](function (e) {
|
|
85
|
+
res.writeHead(500, "Error happened.");
|
|
86
|
+
res.write(Std.string(e), "utf-8");
|
|
87
|
+
res.end();
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
res.writeHead(404, "File not found.");
|
|
91
|
+
res.end();
|
|
92
|
+
};
|
|
93
|
+
})["catch"](function (e) {
|
|
94
|
+
res.writeHead(500, "Error happened.");
|
|
95
|
+
res.write(Std.string(e), "utf-8");
|
|
96
|
+
res.end();
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
99
|
+
res.writeHead(400, "Unsupported method.");
|
|
100
|
+
res.end();
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
static get __name__() {
|
|
104
|
+
return "whet.stones.Server"
|
|
105
|
+
}
|
|
106
|
+
static get __super__() {
|
|
107
|
+
return Stone
|
|
108
|
+
}
|
|
109
|
+
get __class__() {
|
|
110
|
+
return Server
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {StoneIdType} from "../magic/StoneId"
|
|
2
|
+
import {RoutePathType} from "../magic/RoutePathType"
|
|
3
|
+
import {CacheStrategy} from "../cache/Cache"
|
|
4
|
+
import {Stone} from "../Stone"
|
|
5
|
+
import {SourceHash} from "../SourceHash"
|
|
6
|
+
import {SourceData} from "../Source"
|
|
7
|
+
import {Project} from "../Project"
|
|
8
|
+
|
|
9
|
+
export declare class ZipStone extends Stone<ZipConfig> {
|
|
10
|
+
constructor(config: ZipConfig)
|
|
11
|
+
protected initConfig(): void
|
|
12
|
+
protected generateHash(): Promise<SourceHash>
|
|
13
|
+
protected generate(hash: SourceHash): Promise<SourceData[]>
|
|
14
|
+
list(): Promise<string[]>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type ZipConfig = {
|
|
18
|
+
cacheStrategy?: null | CacheStrategy,
|
|
19
|
+
filename?: null | string,
|
|
20
|
+
/**
|
|
21
|
+
Defaults to the Stone's class name.
|
|
22
|
+
*/
|
|
23
|
+
id?: null | StoneIdType,
|
|
24
|
+
level?: null | number,
|
|
25
|
+
/**
|
|
26
|
+
Defaults to the last instanced project.
|
|
27
|
+
*/
|
|
28
|
+
project?: null | Project,
|
|
29
|
+
sources: RoutePathType
|
|
30
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {Router} from "../route/Router.js"
|
|
2
|
+
import {CacheStrategy, CacheDurability, DurabilityCheck} from "../cache/Cache.js"
|
|
3
|
+
import {Stone} from "../Stone.js"
|
|
4
|
+
import {SourceHash} from "../SourceHash.js"
|
|
5
|
+
import {SourceData} from "../Source.js"
|
|
6
|
+
import {Log} from "../Log.js"
|
|
7
|
+
import {Helper} from "../../js/node/buffer/Buffer.js"
|
|
8
|
+
import {Writer} from "../../haxe/zip/Writer.js"
|
|
9
|
+
import {Tools} from "../../haxe/zip/Tools.js"
|
|
10
|
+
import {Path} from "../../haxe/io/Path.js"
|
|
11
|
+
import {BytesOutput} from "../../haxe/io/BytesOutput.js"
|
|
12
|
+
import {Crc32} from "../../haxe/crypto/Crc32.js"
|
|
13
|
+
import {Register} from "../../genes/Register.js"
|
|
14
|
+
import {Buffer} from "buffer"
|
|
15
|
+
import {Lambda} from "../../Lambda.js"
|
|
16
|
+
import {HxOverrides} from "../../HxOverrides.js"
|
|
17
|
+
|
|
18
|
+
const $global = Register.$global
|
|
19
|
+
|
|
20
|
+
export const ZipStone = Register.global("$hxClasses")["whet.stones.ZipStone"] =
|
|
21
|
+
class ZipStone extends Register.inherits(Stone) {
|
|
22
|
+
new(config) {
|
|
23
|
+
super.new(config);
|
|
24
|
+
}
|
|
25
|
+
initConfig() {
|
|
26
|
+
if (this.config.filename == null) {
|
|
27
|
+
this.config.filename = "data.zip";
|
|
28
|
+
};
|
|
29
|
+
if (this.config.level == null) {
|
|
30
|
+
this.config.level = 9;
|
|
31
|
+
};
|
|
32
|
+
if (this.config.cacheStrategy == null) {
|
|
33
|
+
this.config.cacheStrategy = CacheStrategy.InFile(CacheDurability.Any([CacheDurability.LimitCountByLastUse(1), CacheDurability.All([CacheDurability.MaxAge(86400), CacheDurability.LimitCountByLastUse(5)])]), DurabilityCheck.AllOnUse);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
generateHash() {
|
|
37
|
+
var _gthis = this;
|
|
38
|
+
var _this = new Router(this.config.sources).routes;
|
|
39
|
+
var result = new Array(_this.length);
|
|
40
|
+
var _g = 0;
|
|
41
|
+
var _g1 = _this.length;
|
|
42
|
+
while (_g < _g1) {
|
|
43
|
+
var i = _g++;
|
|
44
|
+
var _this1 = _this[i].route.routes;
|
|
45
|
+
var result1 = new Array(_this1.length);
|
|
46
|
+
var _g2 = 0;
|
|
47
|
+
var _g3 = _this1.length;
|
|
48
|
+
while (_g2 < _g3) {
|
|
49
|
+
var i1 = _g2++;
|
|
50
|
+
result1[i1] = _this1[i1].stone.getHash();
|
|
51
|
+
};
|
|
52
|
+
result[i] = Promise.all(result1).then(function (hashes) {
|
|
53
|
+
return SourceHash.merge(...hashes);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return Promise.all(result).then(function (hashes) {
|
|
57
|
+
return SourceHash.merge(...hashes);
|
|
58
|
+
}).then(function (hash) {
|
|
59
|
+
return SourceHash.add(SourceHash.fromString(_gthis.config.filename + _gthis.config.level), hash);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
generate(hash) {
|
|
63
|
+
var _gthis = this;
|
|
64
|
+
Log.log(30, ...["Zipping files."]);
|
|
65
|
+
var level = this.config.level;
|
|
66
|
+
return new Router(this.config.sources).find("/").then(function (files) {
|
|
67
|
+
var _g = [];
|
|
68
|
+
var _g1 = 0;
|
|
69
|
+
while (_g1 < files.length) {
|
|
70
|
+
var file = [files[_g1]];
|
|
71
|
+
++_g1;
|
|
72
|
+
_g.push(file[0].get().then((function (file) {
|
|
73
|
+
return function (data) {
|
|
74
|
+
var bytes = Helper.bytesOfBuffer(data.data);
|
|
75
|
+
var this1 = file[0].serveId;
|
|
76
|
+
var norm = "/" + Path.normalize(("/".charAt(0) == "/") ? HxOverrides.substr("/", 1, null) : "/");
|
|
77
|
+
var root = ("/".lastIndexOf("/") == "/".length - 1) ? Path.addTrailingSlash(norm) : norm;
|
|
78
|
+
var entry = {"fileName": (root.length == 1) ? this1.substring(1) : root.substring(1, root.length - 1) + this1, "fileSize": data.data.length, "fileTime": new Date(data.source.ctime * 1000), "compressed": false, "dataSize": data.data.length, "data": bytes, "crc32": Crc32.make(bytes)};
|
|
79
|
+
Tools.compress(entry, level);
|
|
80
|
+
return entry;
|
|
81
|
+
};
|
|
82
|
+
})(file)));
|
|
83
|
+
};
|
|
84
|
+
return Promise.all(_g).then(function (entries) {
|
|
85
|
+
var out = new BytesOutput();
|
|
86
|
+
new Writer(out).write(Lambda.list(entries));
|
|
87
|
+
var s = _gthis.config.filename;
|
|
88
|
+
var norm = "/" + Path.normalize((s.charAt(0) == "/") ? HxOverrides.substr(s, 1, null) : s);
|
|
89
|
+
var tmp = (s.lastIndexOf("/") == s.length - 1) ? Path.addTrailingSlash(norm) : norm;
|
|
90
|
+
var b = out.getBytes();
|
|
91
|
+
var data = b.b;
|
|
92
|
+
return [SourceData.fromBytes(tmp, Buffer.from(data.buffer, data.byteOffset, b.length))];
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
list() {
|
|
97
|
+
var s = this.config.filename;
|
|
98
|
+
var norm = "/" + Path.normalize((s.charAt(0) == "/") ? HxOverrides.substr(s, 1, null) : s);
|
|
99
|
+
return Promise.resolve([(s.lastIndexOf("/") == s.length - 1) ? Path.addTrailingSlash(norm) : norm]);
|
|
100
|
+
}
|
|
101
|
+
static get __name__() {
|
|
102
|
+
return "whet.stones.ZipStone"
|
|
103
|
+
}
|
|
104
|
+
static get __super__() {
|
|
105
|
+
return Stone
|
|
106
|
+
}
|
|
107
|
+
get __class__() {
|
|
108
|
+
return ZipStone
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {Hxml} from "./Hxml"
|
|
2
|
+
import {StoneIdType} from "../../magic/StoneId"
|
|
3
|
+
import {CacheStrategy} from "../../cache/Cache"
|
|
4
|
+
import {Stone} from "../../Stone"
|
|
5
|
+
import {SourceHash} from "../../SourceHash"
|
|
6
|
+
import {SourceData} from "../../Source"
|
|
7
|
+
import {Project} from "../../Project"
|
|
8
|
+
|
|
9
|
+
export declare class HaxeBuild extends Stone<BuildConfig> {
|
|
10
|
+
constructor(config: BuildConfig)
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
Build the given hxml.
|
|
14
|
+
*/
|
|
15
|
+
build(): Promise<any>
|
|
16
|
+
protected generate(hash: SourceHash): Promise<SourceData[]>
|
|
17
|
+
list(): Promise<string[]>
|
|
18
|
+
protected generateHash(): Promise<SourceHash>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type BuildConfig = {
|
|
22
|
+
cacheStrategy?: null | CacheStrategy,
|
|
23
|
+
filename?: null | string,
|
|
24
|
+
hxml: Hxml,
|
|
25
|
+
/**
|
|
26
|
+
Defaults to the Stone's class name.
|
|
27
|
+
*/
|
|
28
|
+
id?: null | StoneIdType,
|
|
29
|
+
/**
|
|
30
|
+
Defaults to the last instanced project.
|
|
31
|
+
*/
|
|
32
|
+
project?: null | Project,
|
|
33
|
+
useNpx?: null | boolean
|
|
34
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {Utils} from "../../Utils.js"
|
|
2
|
+
import {Stone} from "../../Stone.js"
|
|
3
|
+
import {RootDir} from "../../SourceId.js"
|
|
4
|
+
import {SourceData} from "../../Source.js"
|
|
5
|
+
import {Log} from "../../Log.js"
|
|
6
|
+
import * as Path__1 from "path"
|
|
7
|
+
import {Path, Path as Path__2} from "../../../haxe/io/Path.js"
|
|
8
|
+
import {Register} from "../../../genes/Register.js"
|
|
9
|
+
import * as ChildProcess from "child_process"
|
|
10
|
+
import {HxOverrides} from "../../../HxOverrides.js"
|
|
11
|
+
|
|
12
|
+
const $global = Register.$global
|
|
13
|
+
|
|
14
|
+
export const HaxeBuild = Register.global("$hxClasses")["whet.stones.haxe.HaxeBuild"] =
|
|
15
|
+
class HaxeBuild extends Register.inherits(Stone) {
|
|
16
|
+
new(config) {
|
|
17
|
+
super.new(config);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
Build the given hxml.
|
|
22
|
+
*/
|
|
23
|
+
build() {
|
|
24
|
+
var _gthis = this;
|
|
25
|
+
return new Promise(function (res, rej) {
|
|
26
|
+
var cwd = process.cwd();
|
|
27
|
+
var this1 = _gthis.project.rootDir;
|
|
28
|
+
var norm = "/" + Path.normalize(("/".charAt(0) == "/") ? HxOverrides.substr("/", 1, null) : "/");
|
|
29
|
+
var root = ("/".lastIndexOf("/") == "/".length - 1) ? Path.addTrailingSlash(norm) : norm;
|
|
30
|
+
var cwd1 = Path__1.join(cwd, (root.length == 1) ? this1.substring(1) : root.substring(1, root.length - 1) + this1);
|
|
31
|
+
var _g = [];
|
|
32
|
+
var e = Register.iter(_gthis.config.hxml.getBuildArgs());
|
|
33
|
+
while (e.hasNext()) {
|
|
34
|
+
var x = Register.iter(e.next());
|
|
35
|
+
while (x.hasNext()) _g.push(x.next());
|
|
36
|
+
};
|
|
37
|
+
_g.unshift((_gthis.config.useNpx) ? "npx haxe" : "haxe");
|
|
38
|
+
ChildProcess.exec(_g.join(" "), {"cwd": cwd1, "windowsHide": true}, function (err, stdout, stderr) {
|
|
39
|
+
if (err != null) {
|
|
40
|
+
rej(err);
|
|
41
|
+
} else {
|
|
42
|
+
res(null);
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
generate(hash) {
|
|
48
|
+
var _gthis = this;
|
|
49
|
+
if (this.config.hxml.isSingleFile()) {
|
|
50
|
+
var pathId = this.config.hxml.getBuildExportPath();
|
|
51
|
+
var root = RootDir.fromProject(this.project);
|
|
52
|
+
var path = (root.length == 1) ? pathId.substring(1) : root.substring(1, root.length - 1) + pathId;
|
|
53
|
+
return Utils.deleteAll(path).then(function (_) {
|
|
54
|
+
return _gthis.build();
|
|
55
|
+
}).then(function (_) {
|
|
56
|
+
var s = Path.withoutDirectory(pathId);
|
|
57
|
+
var norm = "/" + Path.normalize((s.charAt(0) == "/") ? HxOverrides.substr(s, 1, null) : s);
|
|
58
|
+
return SourceData.fromFile((s.lastIndexOf("/") == s.length - 1) ? Path.addTrailingSlash(norm) : norm, path, pathId).then(function (file) {
|
|
59
|
+
return [file];
|
|
60
|
+
});
|
|
61
|
+
})["catch"](function (err) {
|
|
62
|
+
Log.log(50, ...[err]);
|
|
63
|
+
return null;
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
throw new Error("Cannot get source of a multi-file build. Not implemented yet.");
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
list() {
|
|
70
|
+
if (this.config.hxml.isSingleFile()) {
|
|
71
|
+
return Promise.resolve([this.config.hxml.getBuildFilename()]);
|
|
72
|
+
} else {
|
|
73
|
+
return super.list();
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
generateHash() {
|
|
77
|
+
return this.config.hxml.generateHash();
|
|
78
|
+
}
|
|
79
|
+
static get __name__() {
|
|
80
|
+
return "whet.stones.haxe.HaxeBuild"
|
|
81
|
+
}
|
|
82
|
+
static get __super__() {
|
|
83
|
+
return Stone
|
|
84
|
+
}
|
|
85
|
+
get __class__() {
|
|
86
|
+
return HaxeBuild
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {HaxeBuild} from "./HaxeBuild"
|
|
2
|
+
import {StoneIdType} from "../../magic/StoneId"
|
|
3
|
+
import {MaybeArray} from "../../magic/MaybeArray"
|
|
4
|
+
import {CacheStrategy} from "../../cache/Cache"
|
|
5
|
+
import {Stone} from "../../Stone"
|
|
6
|
+
import {SourceHash} from "../../SourceHash"
|
|
7
|
+
import {SourceData} from "../../Source"
|
|
8
|
+
import {Project} from "../../Project"
|
|
9
|
+
|
|
10
|
+
export declare class Hxml extends Stone<HxmlConfig> {
|
|
11
|
+
constructor(config: HxmlConfig)
|
|
12
|
+
build: HaxeBuild
|
|
13
|
+
protected initConfig(): void
|
|
14
|
+
clone(id?: null | StoneIdType): Hxml
|
|
15
|
+
mergeConfig(additionalConfig: HxmlConfig): Hxml
|
|
16
|
+
getBuildArgs(): string[][]
|
|
17
|
+
protected getBaseArgs(): string[][]
|
|
18
|
+
protected getFileContent(): string
|
|
19
|
+
protected getBuildExportPath(): string
|
|
20
|
+
protected getBuildFilename(): string
|
|
21
|
+
protected getPlatform(): string[]
|
|
22
|
+
isSingleFile(): boolean
|
|
23
|
+
getBuildExtension(): string
|
|
24
|
+
protected generate(hash: SourceHash): Promise<SourceData[]>
|
|
25
|
+
list(): Promise<string[]>
|
|
26
|
+
protected filename(): string
|
|
27
|
+
generateHash(): Promise<SourceHash>
|
|
28
|
+
generateHashSync(): SourceHash
|
|
29
|
+
protected cloneConfig(config: HxmlConfig): HxmlConfig
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type HxmlConfig = {
|
|
33
|
+
cacheStrategy?: null | CacheStrategy,
|
|
34
|
+
dce?: null | DCE,
|
|
35
|
+
debug?: null | boolean,
|
|
36
|
+
defines?: null | MaybeArray<string>,
|
|
37
|
+
flags?: null | MaybeArray<MaybeArray<string>>,
|
|
38
|
+
/**
|
|
39
|
+
Defaults to the Stone's class name.
|
|
40
|
+
*/
|
|
41
|
+
id?: null | StoneIdType,
|
|
42
|
+
libs?: null | MaybeArray<string>,
|
|
43
|
+
main?: null | string,
|
|
44
|
+
paths?: null | MaybeArray<string>,
|
|
45
|
+
platform?: null | BuildPlatform,
|
|
46
|
+
/**
|
|
47
|
+
Defaults to the last instanced project.
|
|
48
|
+
*/
|
|
49
|
+
project?: null | Project
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare namespace DCE {
|
|
53
|
+
export type STD = {_hx_index: 0, __enum__: "whet.stones.haxe.DCE"}
|
|
54
|
+
export const STD: STD
|
|
55
|
+
export type NO = {_hx_index: 2, __enum__: "whet.stones.haxe.DCE"}
|
|
56
|
+
export const NO: NO
|
|
57
|
+
export type FULL = {_hx_index: 1, __enum__: "whet.stones.haxe.DCE"}
|
|
58
|
+
export const FULL: FULL
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare type DCE =
|
|
62
|
+
| DCE.STD
|
|
63
|
+
| DCE.NO
|
|
64
|
+
| DCE.FULL
|
|
65
|
+
|
|
66
|
+
export declare namespace BuildPlatform {
|
|
67
|
+
export type SWF = {_hx_index: 1, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
68
|
+
export const SWF: SWF
|
|
69
|
+
export type PYTHON = {_hx_index: 7, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
70
|
+
export const PYTHON: PYTHON
|
|
71
|
+
export type PHP = {_hx_index: 3, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
72
|
+
export const PHP: PHP
|
|
73
|
+
export type NEKO = {_hx_index: 2, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
74
|
+
export const NEKO: NEKO
|
|
75
|
+
export type LUA = {_hx_index: 8, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
76
|
+
export const LUA: LUA
|
|
77
|
+
export type JS = {_hx_index: 0, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
78
|
+
export const JS: JS
|
|
79
|
+
export type JAVA = {_hx_index: 6, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
80
|
+
export const JAVA: JAVA
|
|
81
|
+
export type HL = {_hx_index: 9, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
82
|
+
export const HL: HL
|
|
83
|
+
export type CS = {_hx_index: 5, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
84
|
+
export const CS: CS
|
|
85
|
+
export type CPPIA = {_hx_index: 10, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
86
|
+
export const CPPIA: CPPIA
|
|
87
|
+
export type CPP = {_hx_index: 4, __enum__: "whet.stones.haxe.BuildPlatform"}
|
|
88
|
+
export const CPP: CPP
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export declare type BuildPlatform =
|
|
92
|
+
| BuildPlatform.SWF
|
|
93
|
+
| BuildPlatform.PYTHON
|
|
94
|
+
| BuildPlatform.PHP
|
|
95
|
+
| BuildPlatform.NEKO
|
|
96
|
+
| BuildPlatform.LUA
|
|
97
|
+
| BuildPlatform.JS
|
|
98
|
+
| BuildPlatform.JAVA
|
|
99
|
+
| BuildPlatform.HL
|
|
100
|
+
| BuildPlatform.CS
|
|
101
|
+
| BuildPlatform.CPPIA
|
|
102
|
+
| BuildPlatform.CPP
|