whet 0.0.3 → 0.0.6
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/StringBuf.d.ts +13 -0
- package/bin/StringBuf.js +25 -0
- package/bin/haxe/CallStack.d.ts +41 -0
- package/bin/haxe/CallStack.js +96 -0
- package/bin/haxe/Log.d.ts +33 -0
- package/bin/haxe/Log.js +61 -0
- package/bin/haxe/NativeStackTrace.js +147 -0
- package/bin/whet/Log.js +3 -0
- package/bin/whet/Project.d.ts +1 -0
- package/bin/whet/Project.js +13 -8
- package/bin/whet/Source.d.ts +2 -2
- package/bin/whet/Source.js +20 -5
- package/bin/whet/SourceHash.d.ts +8 -1
- package/bin/whet/SourceHash.js +105 -7
- package/bin/whet/SourceId.d.ts +1 -0
- package/bin/whet/SourceId.js +37 -28
- package/bin/whet/Stone.d.ts +12 -2
- package/bin/whet/Stone.js +25 -13
- package/bin/whet/Utils.d.ts +8 -1
- package/bin/whet/Utils.js +56 -3
- package/bin/whet/Whet.js +5 -1
- package/bin/whet/cache/BaseCache.js +23 -20
- package/bin/whet/cache/CacheManager.d.ts +5 -0
- package/bin/whet/cache/CacheManager.js +22 -14
- package/bin/whet/cache/FileCache.js +89 -35
- package/bin/whet/magic/RoutePathType.js +10 -5
- package/bin/whet/magic/RouteType.d.ts +2 -2
- package/bin/whet/magic/RouteType.js +28 -14
- package/bin/whet/magic/StoneId.d.ts +1 -0
- package/bin/whet/magic/StoneId.js +11 -1
- package/bin/whet/route/Route.d.ts +5 -1
- package/bin/whet/route/Route.js +33 -14
- package/bin/whet/route/Router.js +27 -37
- package/bin/whet/stones/Files.js +25 -17
- package/bin/whet/stones/JsonStone.js +7 -7
- package/bin/whet/stones/RemoteFile.js +5 -8
- package/bin/whet/stones/Server.js +28 -19
- package/bin/whet/stones/Zip.js +17 -12
- package/bin/whet/stones/haxe/HaxeBuild.d.ts +3 -0
- package/bin/whet/stones/haxe/HaxeBuild.js +58 -16
- package/bin/whet/stones/haxe/Hxml.js +56 -34
- package/bin/whet.d.ts +2 -0
- package/bin/whet.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
A String buffer is an efficient way to build a big string by appending small
|
|
4
|
+
elements together.
|
|
5
|
+
|
|
6
|
+
Unlike String, an instance of StringBuf is not immutable in the sense that
|
|
7
|
+
it can be passed as argument to functions which modify it by appending more
|
|
8
|
+
values.
|
|
9
|
+
*/
|
|
10
|
+
export declare class StringBuf {
|
|
11
|
+
constructor()
|
|
12
|
+
protected b: string
|
|
13
|
+
}
|
package/bin/StringBuf.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {Register} from "./genes/Register.js"
|
|
2
|
+
|
|
3
|
+
const $global = Register.$global
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
A String buffer is an efficient way to build a big string by appending small
|
|
7
|
+
elements together.
|
|
8
|
+
|
|
9
|
+
Unlike String, an instance of StringBuf is not immutable in the sense that
|
|
10
|
+
it can be passed as argument to functions which modify it by appending more
|
|
11
|
+
values.
|
|
12
|
+
*/
|
|
13
|
+
export const StringBuf = Register.global("$hxClasses")["StringBuf"] =
|
|
14
|
+
class StringBuf extends Register.inherits() {
|
|
15
|
+
new() {
|
|
16
|
+
this.b = "";
|
|
17
|
+
}
|
|
18
|
+
static get __name__() {
|
|
19
|
+
return "StringBuf"
|
|
20
|
+
}
|
|
21
|
+
get __class__() {
|
|
22
|
+
return StringBuf
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {StringBuf} from "../StringBuf"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Elements return by `CallStack` methods.
|
|
5
|
+
*/
|
|
6
|
+
export declare namespace StackItem {
|
|
7
|
+
export type Module = {_hx_index: 1, m: string, __enum__: "haxe.StackItem"}
|
|
8
|
+
export const Module: (m: string) => StackItem
|
|
9
|
+
export type Method = {_hx_index: 3, classname: null | string, method: string, __enum__: "haxe.StackItem"}
|
|
10
|
+
export const Method: (classname: null | string, method: string) => StackItem
|
|
11
|
+
export type LocalFunction = {_hx_index: 4, v: null | number, __enum__: "haxe.StackItem"}
|
|
12
|
+
export const LocalFunction: (v: null | number) => StackItem
|
|
13
|
+
export type FilePos = {_hx_index: 2, s: null | StackItem, file: string, line: number, column: null | number, __enum__: "haxe.StackItem"}
|
|
14
|
+
export const FilePos: (s: null | StackItem, file: string, line: number, column: null | number) => StackItem
|
|
15
|
+
export type CFunction = {_hx_index: 0, __enum__: "haxe.StackItem"}
|
|
16
|
+
export const CFunction: CFunction
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
Elements return by `CallStack` methods.
|
|
21
|
+
*/
|
|
22
|
+
export declare type StackItem =
|
|
23
|
+
| StackItem.Module
|
|
24
|
+
| StackItem.Method
|
|
25
|
+
| StackItem.LocalFunction
|
|
26
|
+
| StackItem.FilePos
|
|
27
|
+
| StackItem.CFunction
|
|
28
|
+
|
|
29
|
+
export declare class CallStack {
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
Return the call stack elements, or an empty array if not available.
|
|
33
|
+
*/
|
|
34
|
+
static callStack(): StackItem[]
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
Returns a representation of the stack as a printable string.
|
|
38
|
+
*/
|
|
39
|
+
static toString(stack: StackItem[]): string
|
|
40
|
+
protected static itemToString(b: StringBuf, s: StackItem): void
|
|
41
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {NativeStackTrace} from "./NativeStackTrace.js"
|
|
2
|
+
import {Register} from "../genes/Register.js"
|
|
3
|
+
import {StringBuf} from "../StringBuf.js"
|
|
4
|
+
import {Std} from "../Std.js"
|
|
5
|
+
|
|
6
|
+
const $global = Register.$global
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
Elements return by `CallStack` methods.
|
|
10
|
+
*/
|
|
11
|
+
export const StackItem =
|
|
12
|
+
Register.global("$hxEnums")["haxe.StackItem"] =
|
|
13
|
+
{
|
|
14
|
+
__ename__: "haxe.StackItem",
|
|
15
|
+
|
|
16
|
+
CFunction: {_hx_name: "CFunction", _hx_index: 0, __enum__: "haxe.StackItem"},
|
|
17
|
+
Module: Object.assign((m) => ({_hx_index: 1, __enum__: "haxe.StackItem", "m": m}), {_hx_name: "Module", __params__: ["m"]}),
|
|
18
|
+
FilePos: Object.assign((s, file, line, column) => ({_hx_index: 2, __enum__: "haxe.StackItem", "s": s, "file": file, "line": line, "column": column}), {_hx_name: "FilePos", __params__: ["s", "file", "line", "column"]}),
|
|
19
|
+
Method: Object.assign((classname, method) => ({_hx_index: 3, __enum__: "haxe.StackItem", "classname": classname, "method": method}), {_hx_name: "Method", __params__: ["classname", "method"]}),
|
|
20
|
+
LocalFunction: Object.assign((v) => ({_hx_index: 4, __enum__: "haxe.StackItem", "v": v}), {_hx_name: "LocalFunction", __params__: ["v"]})
|
|
21
|
+
}
|
|
22
|
+
StackItem.__constructs__ = [StackItem.CFunction, StackItem.Module, StackItem.FilePos, StackItem.Method, StackItem.LocalFunction]
|
|
23
|
+
StackItem.__empty_constructs__ = [StackItem.CFunction]
|
|
24
|
+
|
|
25
|
+
export const CallStack = Register.global("$hxClasses")["haxe._CallStack.CallStack"] =
|
|
26
|
+
class CallStack {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
Return the call stack elements, or an empty array if not available.
|
|
30
|
+
*/
|
|
31
|
+
static callStack() {
|
|
32
|
+
return NativeStackTrace.toHaxe(NativeStackTrace.callStack());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
Returns a representation of the stack as a printable string.
|
|
37
|
+
*/
|
|
38
|
+
static toString(stack) {
|
|
39
|
+
var b = new StringBuf();
|
|
40
|
+
var _g = 0;
|
|
41
|
+
var _g1 = stack;
|
|
42
|
+
while (_g < _g1.length) {
|
|
43
|
+
var s = _g1[_g++];
|
|
44
|
+
b.b += "\nCalled from ";
|
|
45
|
+
CallStack.itemToString(b, s);
|
|
46
|
+
};
|
|
47
|
+
return b.b;
|
|
48
|
+
}
|
|
49
|
+
static itemToString(b, s) {
|
|
50
|
+
switch (s._hx_index) {
|
|
51
|
+
case 0:
|
|
52
|
+
b.b += "a C function";
|
|
53
|
+
break
|
|
54
|
+
case 1:
|
|
55
|
+
var _g = s.m;
|
|
56
|
+
b.b = (b.b += "module ") + ((_g == null) ? "null" : "" + _g);
|
|
57
|
+
break
|
|
58
|
+
case 2:
|
|
59
|
+
var _g = s.s;
|
|
60
|
+
var _g1 = s.file;
|
|
61
|
+
var _g2 = s.line;
|
|
62
|
+
var _g3 = s.column;
|
|
63
|
+
if (_g != null) {
|
|
64
|
+
CallStack.itemToString(b, _g);
|
|
65
|
+
b.b += " (";
|
|
66
|
+
};
|
|
67
|
+
b.b = (b.b += (_g1 == null) ? "null" : "" + _g1) + " line ";
|
|
68
|
+
b.b += (_g2 == null) ? "null" : "" + _g2;
|
|
69
|
+
if (_g3 != null) {
|
|
70
|
+
b.b = (b.b += " column ") + ((_g3 == null) ? "null" : "" + _g3);
|
|
71
|
+
};
|
|
72
|
+
if (_g != null) {
|
|
73
|
+
b.b += ")";
|
|
74
|
+
};
|
|
75
|
+
break
|
|
76
|
+
case 3:
|
|
77
|
+
var _g = s.classname;
|
|
78
|
+
var _g1 = s.method;
|
|
79
|
+
b.b = (b.b += Std.string((_g == null) ? "<unknown>" : _g)) + ".";
|
|
80
|
+
b.b += (_g1 == null) ? "null" : "" + _g1;
|
|
81
|
+
break
|
|
82
|
+
case 4:
|
|
83
|
+
var _g = s.v;
|
|
84
|
+
b.b = (b.b += "local function #") + ((_g == null) ? "null" : "" + _g);
|
|
85
|
+
break
|
|
86
|
+
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
static get __name__() {
|
|
90
|
+
return "haxe._CallStack.CallStack_Impl_"
|
|
91
|
+
}
|
|
92
|
+
get __class__() {
|
|
93
|
+
return CallStack
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {PosInfos} from "./PosInfos"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Log primarily provides the `trace()` method, which is invoked upon a call to
|
|
5
|
+
`trace()` in Haxe code.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Log {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
Format the output of `trace` before printing it.
|
|
11
|
+
*/
|
|
12
|
+
static formatOutput(v: any, infos: PosInfos): string
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
Outputs `v` in a platform-dependent way.
|
|
16
|
+
|
|
17
|
+
The second parameter `infos` is injected by the compiler and contains
|
|
18
|
+
information about the position where the `trace()` call was made.
|
|
19
|
+
|
|
20
|
+
This method can be rebound to a custom function:
|
|
21
|
+
|
|
22
|
+
var oldTrace = haxe.Log.trace; // store old function
|
|
23
|
+
haxe.Log.trace = function(v, ?infos) {
|
|
24
|
+
// handle trace
|
|
25
|
+
}
|
|
26
|
+
...
|
|
27
|
+
haxe.Log.trace = oldTrace;
|
|
28
|
+
|
|
29
|
+
If it is bound to null, subsequent calls to `trace()` will cause an
|
|
30
|
+
exception.
|
|
31
|
+
*/
|
|
32
|
+
static trace(v: any, infos?: null | PosInfos): void
|
|
33
|
+
}
|
package/bin/haxe/Log.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {Register} from "../genes/Register.js"
|
|
2
|
+
import {Std} from "../Std.js"
|
|
3
|
+
|
|
4
|
+
const $global = Register.$global
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
Log primarily provides the `trace()` method, which is invoked upon a call to
|
|
8
|
+
`trace()` in Haxe code.
|
|
9
|
+
*/
|
|
10
|
+
export const Log = Register.global("$hxClasses")["haxe.Log"] =
|
|
11
|
+
class Log {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
Format the output of `trace` before printing it.
|
|
15
|
+
*/
|
|
16
|
+
static formatOutput(v, infos) {
|
|
17
|
+
var str = Std.string(v);
|
|
18
|
+
if (infos == null) {
|
|
19
|
+
return str;
|
|
20
|
+
};
|
|
21
|
+
var pstr = infos.fileName + ":" + infos.lineNumber;
|
|
22
|
+
if (infos.customParams != null) {
|
|
23
|
+
var _g = 0;
|
|
24
|
+
var _g1 = infos.customParams;
|
|
25
|
+
while (_g < _g1.length) str += ", " + Std.string(_g1[_g++]);
|
|
26
|
+
};
|
|
27
|
+
return pstr + ": " + str;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
Outputs `v` in a platform-dependent way.
|
|
32
|
+
|
|
33
|
+
The second parameter `infos` is injected by the compiler and contains
|
|
34
|
+
information about the position where the `trace()` call was made.
|
|
35
|
+
|
|
36
|
+
This method can be rebound to a custom function:
|
|
37
|
+
|
|
38
|
+
var oldTrace = haxe.Log.trace; // store old function
|
|
39
|
+
haxe.Log.trace = function(v, ?infos) {
|
|
40
|
+
// handle trace
|
|
41
|
+
}
|
|
42
|
+
...
|
|
43
|
+
haxe.Log.trace = oldTrace;
|
|
44
|
+
|
|
45
|
+
If it is bound to null, subsequent calls to `trace()` will cause an
|
|
46
|
+
exception.
|
|
47
|
+
*/
|
|
48
|
+
static trace(v, infos) {
|
|
49
|
+
var str = Log.formatOutput(v, infos);
|
|
50
|
+
if (typeof(console) != "undefined" && console.log != null) {
|
|
51
|
+
console.log(str);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
static get __name__() {
|
|
55
|
+
return "haxe.Log"
|
|
56
|
+
}
|
|
57
|
+
get __class__() {
|
|
58
|
+
return Log
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {StackItem} from "./CallStack.js"
|
|
2
|
+
import {Register} from "../genes/Register.js"
|
|
3
|
+
import {StringTools} from "../StringTools.js"
|
|
4
|
+
import {Std} from "../Std.js"
|
|
5
|
+
|
|
6
|
+
const $global = Register.$global
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
Do not use manually.
|
|
10
|
+
*/
|
|
11
|
+
export const NativeStackTrace = Register.global("$hxClasses")["haxe.NativeStackTrace"] =
|
|
12
|
+
class NativeStackTrace {
|
|
13
|
+
static callStack() {
|
|
14
|
+
var e = new Error("");
|
|
15
|
+
var stack = NativeStackTrace.tryHaxeStack(e);
|
|
16
|
+
if (typeof(stack) == "undefined") {
|
|
17
|
+
try {
|
|
18
|
+
throw e;
|
|
19
|
+
}catch (_g) {
|
|
20
|
+
};
|
|
21
|
+
stack = e.stack;
|
|
22
|
+
};
|
|
23
|
+
return NativeStackTrace.normalize(stack, 2);
|
|
24
|
+
}
|
|
25
|
+
static toHaxe(s, skip) {
|
|
26
|
+
if (skip == null) {
|
|
27
|
+
skip = 0;
|
|
28
|
+
};
|
|
29
|
+
if (s == null) {
|
|
30
|
+
return [];
|
|
31
|
+
} else if (typeof(s) == "string") {
|
|
32
|
+
var stack = s.split("\n");
|
|
33
|
+
if (stack[0] == "Error") {
|
|
34
|
+
stack.shift();
|
|
35
|
+
};
|
|
36
|
+
var m = [];
|
|
37
|
+
var _g = 0;
|
|
38
|
+
var _g1 = stack.length;
|
|
39
|
+
while (_g < _g1) {
|
|
40
|
+
var i = _g++;
|
|
41
|
+
if (skip > i) {
|
|
42
|
+
continue;
|
|
43
|
+
};
|
|
44
|
+
var line = stack[i];
|
|
45
|
+
var matched = line.match(/^ at ([A-Za-z0-9_. ]+) \(([^)]+):([0-9]+):([0-9]+)\)$/);
|
|
46
|
+
if (matched != null) {
|
|
47
|
+
var path = matched[1].split(".");
|
|
48
|
+
if (path[0] == "$hxClasses") {
|
|
49
|
+
path.shift();
|
|
50
|
+
};
|
|
51
|
+
var meth = path.pop();
|
|
52
|
+
var file = matched[2];
|
|
53
|
+
var line1 = Std.parseInt(matched[3]);
|
|
54
|
+
var column = Std.parseInt(matched[4]);
|
|
55
|
+
m.push(StackItem.FilePos((meth == "Anonymous function") ? StackItem.LocalFunction() : (meth == "Global code") ? null : StackItem.Method(path.join("."), meth), file, line1, column));
|
|
56
|
+
} else {
|
|
57
|
+
m.push(StackItem.Module(StringTools.trim(line)));
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
return m;
|
|
61
|
+
} else if (skip > 0 && Array.isArray(s)) {
|
|
62
|
+
return s.slice(skip);
|
|
63
|
+
} else {
|
|
64
|
+
return s;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
static tryHaxeStack(e) {
|
|
68
|
+
if (e == null) {
|
|
69
|
+
return [];
|
|
70
|
+
};
|
|
71
|
+
var oldValue = Error.prepareStackTrace;
|
|
72
|
+
Error.prepareStackTrace = NativeStackTrace.prepareHxStackTrace;
|
|
73
|
+
Error.prepareStackTrace = oldValue;
|
|
74
|
+
return e.stack;
|
|
75
|
+
}
|
|
76
|
+
static prepareHxStackTrace(e, callsites) {
|
|
77
|
+
var stack = [];
|
|
78
|
+
var _g = 0;
|
|
79
|
+
while (_g < callsites.length) {
|
|
80
|
+
var site = callsites[_g];
|
|
81
|
+
++_g;
|
|
82
|
+
if (NativeStackTrace.wrapCallSite != null) {
|
|
83
|
+
site = NativeStackTrace.wrapCallSite(site);
|
|
84
|
+
};
|
|
85
|
+
var method = null;
|
|
86
|
+
var fullName = site.getFunctionName();
|
|
87
|
+
if (fullName != null) {
|
|
88
|
+
var idx = fullName.lastIndexOf(".");
|
|
89
|
+
if (idx >= 0) {
|
|
90
|
+
method = StackItem.Method(fullName.substring(0, idx), fullName.substring(idx + 1));
|
|
91
|
+
} else {
|
|
92
|
+
method = StackItem.Method(null, fullName);
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
var fileName = site.getFileName();
|
|
96
|
+
var fileAddr = (fileName == null) ? -1 : fileName.indexOf("file:");
|
|
97
|
+
if (NativeStackTrace.wrapCallSite != null && fileAddr > 0) {
|
|
98
|
+
fileName = fileName.substring(fileAddr + 6);
|
|
99
|
+
};
|
|
100
|
+
stack.push(StackItem.FilePos(method, fileName, site.getLineNumber(), site.getColumnNumber()));
|
|
101
|
+
};
|
|
102
|
+
return stack;
|
|
103
|
+
}
|
|
104
|
+
static normalize(stack, skipItems) {
|
|
105
|
+
if (skipItems == null) {
|
|
106
|
+
skipItems = 0;
|
|
107
|
+
};
|
|
108
|
+
if (Array.isArray(stack) && skipItems > 0) {
|
|
109
|
+
return stack.slice(skipItems);
|
|
110
|
+
} else if (typeof(stack) == "string") {
|
|
111
|
+
switch (stack.substring(0, 6)) {
|
|
112
|
+
case "Error\n":case "Error:":
|
|
113
|
+
++skipItems;
|
|
114
|
+
break
|
|
115
|
+
default:
|
|
116
|
+
|
|
117
|
+
};
|
|
118
|
+
return NativeStackTrace.skipLines(stack, skipItems);
|
|
119
|
+
} else {
|
|
120
|
+
return stack;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
static skipLines(stack, skip, pos) {
|
|
124
|
+
if (pos == null) {
|
|
125
|
+
pos = 0;
|
|
126
|
+
};
|
|
127
|
+
while (true) if (skip > 0) {
|
|
128
|
+
pos = stack.indexOf("\n", pos);
|
|
129
|
+
if (pos < 0) {
|
|
130
|
+
return "";
|
|
131
|
+
} else {
|
|
132
|
+
skip = --skip;
|
|
133
|
+
pos += 1;
|
|
134
|
+
continue;
|
|
135
|
+
};
|
|
136
|
+
} else {
|
|
137
|
+
return stack.substring(pos);
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
static get __name__() {
|
|
141
|
+
return "haxe.NativeStackTrace"
|
|
142
|
+
}
|
|
143
|
+
get __class__() {
|
|
144
|
+
return NativeStackTrace
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
package/bin/whet/Log.js
CHANGED
package/bin/whet/Project.d.ts
CHANGED
package/bin/whet/Project.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {CacheManager} from "./cache/CacheManager.js"
|
|
2
2
|
import {Whet_Fields_} from "./Whet.js"
|
|
3
|
+
import {SourceId_Fields_} from "./SourceId.js"
|
|
3
4
|
import {Log} from "./Log.js"
|
|
4
5
|
import * as Path from "path"
|
|
5
|
-
import {Path as Path__1} from "../haxe/io/Path.js"
|
|
6
6
|
import {Register} from "../genes/Register.js"
|
|
7
7
|
import {StringTools} from "../StringTools.js"
|
|
8
|
-
import {HxOverrides} from "../HxOverrides.js"
|
|
9
8
|
|
|
10
9
|
const $global = Register.$global
|
|
11
10
|
|
|
12
11
|
export const Project = Register.global("$hxClasses")["whet.Project"] =
|
|
13
12
|
class Project extends Register.inherits() {
|
|
14
13
|
new(config) {
|
|
14
|
+
this.stones = [];
|
|
15
15
|
this.cache = null;
|
|
16
16
|
var this1 = ["Instantiating new Project."];
|
|
17
17
|
Log.log(20, ...this1);
|
|
@@ -34,16 +34,21 @@ class Project extends Register.inherits() {
|
|
|
34
34
|
};
|
|
35
35
|
var file = new Error().stack[3].getFileName();
|
|
36
36
|
Error.prepareStackTrace = oldValue;
|
|
37
|
+
file = decodeURI(file);
|
|
37
38
|
file = StringTools.replace(file, "file:///", "");
|
|
38
39
|
var s = Path.relative(process.cwd(), file);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
40
|
+
s = Path.posix.normalize(s);
|
|
41
|
+
s = StringTools.replace(s, "\\", "/");
|
|
42
|
+
var this1 = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
|
|
43
|
+
var s = this1.substring(0, this1.lastIndexOf("/") + 1);
|
|
44
|
+
s = Path.posix.normalize(s);
|
|
45
|
+
s = StringTools.replace(s, "\\", "/");
|
|
46
|
+
this.rootDir = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
|
|
43
47
|
} else {
|
|
44
48
|
var s = config.rootDir;
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
s = Path.posix.normalize(s);
|
|
50
|
+
s = StringTools.replace(s, "\\", "/");
|
|
51
|
+
this.rootDir = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
|
|
47
52
|
};
|
|
48
53
|
this.cache = (config.cache == null) ? new CacheManager(this) : config.cache;
|
|
49
54
|
Project.projects.push(this);
|
package/bin/whet/Source.d.ts
CHANGED
|
@@ -35,12 +35,12 @@ export declare class SourceData {
|
|
|
35
35
|
/**
|
|
36
36
|
Same as `getFilePath` but relative to project, not CWD.
|
|
37
37
|
*/
|
|
38
|
-
getFilePathId(idOverride?: null | string): Promise<string>
|
|
38
|
+
protected getFilePathId(idOverride?: null | string): Promise<string>
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
Path to a file for this source, relative to CWD.
|
|
42
42
|
*/
|
|
43
|
-
getFilePath(idOverride?: null | string): Promise<string>
|
|
43
|
+
protected getFilePath(idOverride?: null | string): Promise<string>
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* `path` is the actual cwd-relative path. `pathId` is the project-relative source Id.
|
package/bin/whet/Source.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {Utils} from "./Utils.js"
|
|
2
|
-
import {SourceId, RootDir} from "./SourceId.js"
|
|
2
|
+
import {SourceId_Fields_, SourceId, RootDir} from "./SourceId.js"
|
|
3
3
|
import {SourceHash} from "./SourceHash.js"
|
|
4
4
|
import {Log} from "./Log.js"
|
|
5
|
+
import * as Path from "path"
|
|
5
6
|
import {Register} from "../genes/Register.js"
|
|
6
7
|
import * as Fs from "fs"
|
|
7
8
|
import {Buffer} from "buffer"
|
|
9
|
+
import {StringTools} from "../StringTools.js"
|
|
8
10
|
import {Lambda} from "../Lambda.js"
|
|
9
11
|
|
|
10
12
|
const $global = Register.$global
|
|
@@ -42,8 +44,12 @@ class Source extends Register.inherits() {
|
|
|
42
44
|
if (id == null) {
|
|
43
45
|
return this.data[0];
|
|
44
46
|
} else {
|
|
47
|
+
var s = id;
|
|
48
|
+
s = Path.posix.normalize(id);
|
|
49
|
+
s = StringTools.replace(s, "\\", "/");
|
|
50
|
+
var sid = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
|
|
45
51
|
return Lambda.find(this.data, function (entry) {
|
|
46
|
-
return entry.id ==
|
|
52
|
+
return entry.id == sid;
|
|
47
53
|
});
|
|
48
54
|
};
|
|
49
55
|
}
|
|
@@ -93,7 +99,10 @@ class SourceData extends Register.inherits() {
|
|
|
93
99
|
this.filePathId = SourceId.getPutInDir((idOverride != null) ? idOverride : this.id, dir);
|
|
94
100
|
var this1 = this.filePathId;
|
|
95
101
|
var root = RootDir.fromProject(this.source.origin.project);
|
|
96
|
-
|
|
102
|
+
if (this1.charAt(0) != "/") {
|
|
103
|
+
throw new Error("Badly formed SourceId.");
|
|
104
|
+
};
|
|
105
|
+
this.filePath = Path.posix.join(".", root, ".", this1);
|
|
97
106
|
return Utils.saveBytes(this.filePath, this.data).then(function (_) {
|
|
98
107
|
return _gthis.filePath;
|
|
99
108
|
});
|
|
@@ -114,7 +123,10 @@ class SourceData extends Register.inherits() {
|
|
|
114
123
|
} else {
|
|
115
124
|
var source = SourceData.fromBytes(id, buffer);
|
|
116
125
|
source.filePath = path;
|
|
117
|
-
|
|
126
|
+
var s = pathId;
|
|
127
|
+
s = Path.posix.normalize(s);
|
|
128
|
+
s = StringTools.replace(s, "\\", "/");
|
|
129
|
+
source.filePathId = (SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s;
|
|
118
130
|
res(source);
|
|
119
131
|
};
|
|
120
132
|
});
|
|
@@ -124,7 +136,10 @@ class SourceData extends Register.inherits() {
|
|
|
124
136
|
return SourceData.fromBytes(id, Buffer.from(s, "utf-8"));
|
|
125
137
|
}
|
|
126
138
|
static fromBytes(id, data) {
|
|
127
|
-
|
|
139
|
+
var s = id;
|
|
140
|
+
s = Path.posix.normalize(id);
|
|
141
|
+
s = StringTools.replace(s, "\\", "/");
|
|
142
|
+
return new SourceData((SourceId_Fields_.startsWithSlash(s)) ? s : "/" + s, data);
|
|
128
143
|
}
|
|
129
144
|
static get __name__() {
|
|
130
145
|
return "whet.SourceData"
|
package/bin/whet/SourceHash.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import {MaybeArray} from "./magic/MaybeArray"
|
|
1
2
|
import {Buffer} from "buffer"
|
|
2
3
|
|
|
3
4
|
export declare class SourceHash {
|
|
4
5
|
protected constructor(bytes: Buffer)
|
|
5
6
|
protected bytes: Buffer
|
|
7
|
+
add(hash: SourceHash): SourceHash
|
|
6
8
|
toString(): string
|
|
7
9
|
static EMPTY: SourceHash
|
|
10
|
+
static fromFile(path: string): Promise<SourceHash>
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates hashes of all files and or content of directories, optionally recursive.
|
|
14
|
+
*/
|
|
15
|
+
static fromFiles(paths: MaybeArray<string>, filter?: null | ((arg0: string) => boolean), recursive?: boolean): Promise<SourceHash>
|
|
8
16
|
static fromBytes(data: Buffer): SourceHash
|
|
9
17
|
static fromString(data: string): SourceHash
|
|
10
|
-
static add(a: SourceHash, b: SourceHash): SourceHash
|
|
11
18
|
static equals(a: SourceHash, b: SourceHash): boolean
|
|
12
19
|
static toHex(hash: SourceHash): string
|
|
13
20
|
static fromHex(hex: string): SourceHash
|