whet 0.0.34 → 0.1.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.
Files changed (81) hide show
  1. package/bin/Reflect.d.ts +31 -12
  2. package/bin/Reflect.js +46 -19
  3. package/bin/commander/LiteralUnion.d.ts +2 -0
  4. package/bin/commander/OptionValueSource.d.ts +2 -1
  5. package/bin/commander/OutputConfiguration.d.ts +3 -0
  6. package/bin/genes/Register.d.ts +2 -0
  7. package/bin/genes/Register.js +15 -11
  8. package/bin/genes/util/EsMap.js +2 -1
  9. package/bin/haxe/Exception.js +6 -1
  10. package/bin/haxe/ValueException.js +3 -2
  11. package/bin/haxe/ds/List.js +7 -2
  12. package/bin/haxe/ds/ObjectMap.js +2 -2
  13. package/bin/haxe/ds/StringMap.js +2 -2
  14. package/bin/haxe/exceptions/NotImplementedException.js +2 -2
  15. package/bin/haxe/exceptions/PosException.js +3 -2
  16. package/bin/haxe/io/Bytes.js +3 -1
  17. package/bin/haxe/io/BytesBuffer.js +6 -1
  18. package/bin/haxe/io/BytesOutput.js +2 -1
  19. package/bin/haxe/io/Output.js +1 -0
  20. package/bin/haxe/iterators/ArrayIterator.js +3 -1
  21. package/bin/haxe/zip/Writer.js +3 -1
  22. package/bin/js/lib/ConcatArray.d.ts +6 -0
  23. package/bin/js/lib/IRegExp.d.ts +53 -0
  24. package/bin/js/lib/IterableIterator.d.ts +8 -0
  25. package/bin/js/lib/IteratorResult.d.ts +2 -0
  26. package/bin/js/lib/IteratorReturnResult.d.ts +5 -0
  27. package/bin/js/lib/IteratorYieldResult.d.ts +5 -0
  28. package/bin/js/lib/RegExpExecArray.d.ts +137 -0
  29. package/bin/minimatch/MMRegExp.d.ts +55 -0
  30. package/bin/minimatch/MinimatchOptions.d.ts +102 -0
  31. package/bin/minimatch/ParseReturn.d.ts +2 -0
  32. package/bin/minimatch/ParseReturnFiltered.d.ts +2 -0
  33. package/bin/minimatch/Platform.d.ts +2 -0
  34. package/bin/pino_pretty/PrettyOptions.d.ts +2 -2
  35. package/bin/pino_pretty/default_/MessageFormatFunc.d.ts +1 -2
  36. package/bin/pino_pretty/default_/Prettifier.d.ts +2 -0
  37. package/bin/pino_pretty/pinopretty/PrettyOptions.d.ts +118 -0
  38. package/bin/sys/FileStat.d.ts +50 -0
  39. package/bin/whet/ConfigStore.d.ts +32 -0
  40. package/bin/whet/ConfigStore.js +342 -0
  41. package/bin/whet/Project.d.ts +41 -4
  42. package/bin/whet/Project.js +191 -3
  43. package/bin/whet/Source.d.ts +7 -1
  44. package/bin/whet/Source.js +40 -3
  45. package/bin/whet/SourceHash.js +18 -10
  46. package/bin/whet/Stone.d.ts +60 -9
  47. package/bin/whet/Stone.js +180 -18
  48. package/bin/whet/Whet.d.ts +0 -1
  49. package/bin/whet/Whet.js +23 -12
  50. package/bin/whet/cache/BaseCache.d.ts +23 -0
  51. package/bin/whet/cache/BaseCache.js +93 -1
  52. package/bin/whet/cache/CacheManager.d.ts +2 -0
  53. package/bin/whet/cache/CacheManager.js +38 -2
  54. package/bin/whet/cache/FileCache.d.ts +10 -2
  55. package/bin/whet/cache/FileCache.js +144 -42
  56. package/bin/whet/cache/HashCache.js +2 -1
  57. package/bin/whet/cache/MemoryCache.d.ts +3 -0
  58. package/bin/whet/cache/MemoryCache.js +53 -2
  59. package/bin/whet/magic/MinimatchType.d.ts +1 -1
  60. package/bin/whet/magic/MinimatchType.js +3 -3
  61. package/bin/whet/magic/RoutePathType.js +1 -1
  62. package/bin/whet/route/OutputFilterMatcher.js +2 -2
  63. package/bin/whet/route/RouteResult.d.ts +16 -0
  64. package/bin/whet/route/RouteResult.js +37 -4
  65. package/bin/whet/route/Router.d.ts +27 -1
  66. package/bin/whet/route/Router.js +151 -40
  67. package/bin/whet/stones/Files.d.ts +6 -1
  68. package/bin/whet/stones/Files.js +3 -2
  69. package/bin/whet/stones/JsonStone.d.ts +6 -1
  70. package/bin/whet/stones/JsonStone.js +3 -2
  71. package/bin/whet/stones/RemoteFile.d.ts +7 -2
  72. package/bin/whet/stones/RemoteFile.js +7 -4
  73. package/bin/whet/stones/Zip.d.ts +6 -1
  74. package/bin/whet/stones/Zip.js +2 -2
  75. package/bin/whet/stones/haxe/HaxeBuild.d.ts +7 -1
  76. package/bin/whet/stones/haxe/HaxeBuild.js +8 -6
  77. package/bin/whet/stones/haxe/Hxml.d.ts +7 -1
  78. package/bin/whet/stones/haxe/Hxml.js +7 -5
  79. package/bin/whet.d.ts +1 -2
  80. package/bin/whet.js +1 -1
  81. package/package.json +9 -10
@@ -4,15 +4,45 @@ const $global = Register.$global
4
4
 
5
5
  export const RouteResult = Register.global("$hxClasses")["whet.route.RouteResult"] =
6
6
  class RouteResult extends Register.inherits() {
7
- new(serveId, sourceId, source) {
7
+ [Register.new](serveId, sourceId, source) {
8
8
  this.serveId = serveId;
9
9
  this.sourceId = sourceId;
10
10
  this.source = source;
11
11
  }
12
12
  get() {
13
- let _gthis = this;
14
- return this.source.getSource().then(function (data) {
15
- return data.get(_gthis.sourceId);
13
+ return this.source.getPartialSource(this.sourceId).then(function (s) {
14
+ if (s != null) {
15
+ return s.get();
16
+ } else {
17
+ return null;
18
+ };
19
+ });
20
+ }
21
+
22
+ /**
23
+ Get the raw Buffer directly.
24
+ */
25
+ getData() {
26
+ return this.get().then(function (sd) {
27
+ return sd.data;
28
+ });
29
+ }
30
+
31
+ /**
32
+ Get the output as a UTF-8 string.
33
+ */
34
+ getString() {
35
+ return this.getData().then(function (d) {
36
+ return d.toString("utf-8");
37
+ });
38
+ }
39
+
40
+ /**
41
+ Get the output parsed as JSON.
42
+ */
43
+ getJson() {
44
+ return this.getString().then(function (s) {
45
+ return JSON.parse(s);
16
46
  });
17
47
  }
18
48
  static get __name__() {
@@ -22,4 +52,7 @@ class RouteResult extends Register.inherits() {
22
52
  return RouteResult
23
53
  }
24
54
  }
55
+ RouteResult.prototype.serveId = null;
56
+ RouteResult.prototype.sourceId = null;
57
+ RouteResult.prototype.source = null;
25
58
 
@@ -3,13 +3,19 @@ import {RoutePathType} from "../magic/RoutePathType"
3
3
  import {MinimatchType} from "../magic/MinimatchType"
4
4
  import {OutputFilter, AnyStone} from "../Stone"
5
5
  import {SourceHash} from "../SourceHash"
6
- import Minimatch from "minimatch"
6
+ import {Minimatch} from "minimatch"
7
+ import {Buffer} from "buffer"
7
8
 
8
9
  export declare class Router {
9
10
  constructor(routes?: null | RoutePathType)
10
11
  protected routes: RoutePath[]
11
12
  route(r: RoutePathType): void
12
13
 
14
+ /**
15
+ Recursively collect all Stone IDs referenced in this Router's routes.
16
+ */
17
+ collectStoneIds(): string[]
18
+
13
19
  /**
14
20
  * Find data sources routed under `pattern`.
15
21
  * @param pattern A glob pattern to search for.
@@ -27,6 +33,21 @@ export declare class Router {
27
33
  * Save files filtered by `pattern` into provided `saveInto` folder.
28
34
  */
29
35
  saveInto(pattern: MinimatchType, saveInto: string, clearFirst?: boolean): Promise<any>
36
+
37
+ /**
38
+ Get the raw Buffer of the first matching result.
39
+ */
40
+ getData(pattern?: null | MinimatchType): Promise<Buffer>
41
+
42
+ /**
43
+ Get the first matching result as a UTF-8 string.
44
+ */
45
+ getString(pattern?: null | MinimatchType): Promise<string>
46
+
47
+ /**
48
+ Get the first matching result parsed as JSON.
49
+ */
50
+ getJson(pattern?: null | MinimatchType): Promise<any>
30
51
  listContents(pattern?: null | MinimatchType): Promise<string>
31
52
 
32
53
  /**
@@ -44,6 +65,11 @@ export type Filter = {
44
65
  }
45
66
 
46
67
  export declare class Filters {
68
+
69
+ /**
70
+ Like finalize, but restores filter state afterwards. Returns serveId on match, null otherwise.
71
+ */
72
+ static tryFinalize($this: Filter[], finalPath: string): null | string
47
73
  protected static isPathPossible($this: Filter[], f: Filter): boolean
48
74
  }
49
75
 
@@ -12,7 +12,7 @@ const $global = Register.$global
12
12
 
13
13
  export const Router = Register.global("$hxClasses")["whet.route.Router"] =
14
14
  class Router extends Register.inherits() {
15
- new(routes) {
15
+ [Register.new](routes) {
16
16
  this.routes = (routes != null) ? RoutePathType_Fields_.makeRoutePath(routes) : [];
17
17
  }
18
18
  route(r) {
@@ -21,6 +21,36 @@ class Router extends Register.inherits() {
21
21
  while (_g < _g1.length) this.routes.push(_g1[_g++]);
22
22
  }
23
23
 
24
+ /**
25
+ Recursively collect all Stone IDs referenced in this Router's routes.
26
+ */
27
+ collectStoneIds() {
28
+ let ids = [];
29
+ let _g = 0;
30
+ let _g1 = this.routes;
31
+ while (_g < _g1.length) {
32
+ let route = _g1[_g];
33
+ ++_g;
34
+ if (((route.source) instanceof Stone)) {
35
+ let id = route.source.id;
36
+ if (ids.indexOf(id) == -1) {
37
+ ids.push(id);
38
+ };
39
+ } else if (((route.source) instanceof Router)) {
40
+ let _g = 0;
41
+ let _g1 = route.source.collectStoneIds();
42
+ while (_g < _g1.length) {
43
+ let id = _g1[_g];
44
+ ++_g;
45
+ if (ids.indexOf(id) == -1) {
46
+ ids.push(id);
47
+ };
48
+ };
49
+ };
50
+ };
51
+ return ids;
52
+ }
53
+
24
54
  /**
25
55
  * Find data sources routed under `pattern`.
26
56
  * @param pattern A glob pattern to search for.
@@ -45,7 +75,7 @@ class Router extends Register.inherits() {
45
75
  while (_g2 < _g3) {
46
76
  let i = _g2++;
47
77
  let f = mainFilters[i];
48
- result[i] = {"filter": f.filter, "pathSoFar": f.pathSoFar.slice(), "inProgress": f.inProgress, "remDirs": f.remDirs.slice()};
78
+ result[i] = {"filter": f.filter, "pathSoFar": f.pathSoFar, "inProgress": f.inProgress, "remDirs": f.remDirs};
49
79
  };
50
80
  let routeFilters = result;
51
81
  let possible;
@@ -126,7 +156,10 @@ class Router extends Register.inherits() {
126
156
  let f = route.filter;
127
157
  let extractDir = route.extractDirs;
128
158
  if (extractDir != null && routeFilters.length > 0) {
129
- routeFilters[routeFilters.length - 1].remDirs.push(extractDir);
159
+ let routeFilters1 = routeFilters;
160
+ let tmp = routeFilters.length - 1;
161
+ let tmp1 = routeFilters[routeFilters.length - 1].remDirs.concat([extractDir]);
162
+ routeFilters1[tmp].remDirs = tmp1;
130
163
  };
131
164
  routeFilters.push({"pathSoFar": [], "filter": f, "inProgress": true, "remDirs": []});
132
165
  };
@@ -145,47 +178,13 @@ class Router extends Register.inherits() {
145
178
  let prom;
146
179
  if (((route.source) instanceof Stone)) {
147
180
  let stone = route.source;
148
- prom = stone.list().then(function (list) {
181
+ prom = stone.listIds().then(function (list) {
149
182
  let _g = 0;
150
183
  while (_g < list.length) {
151
184
  let sourceId = list[_g];
152
185
  ++_g;
153
- let result = new Array(routeFilters.length);
154
- let _g1 = 0;
155
- let _g2 = routeFilters.length;
156
- while (_g1 < _g2) {
157
- let i = _g1++;
158
- let f = routeFilters[i];
159
- result[i] = {"filter": f.filter, "pathSoFar": f.pathSoFar.slice(), "inProgress": f.inProgress, "remDirs": f.remDirs.slice()};
160
- };
161
- let finalFilters = result;
162
- let parts = sourceId.split("/");
163
- let res = true;
164
- let i = finalFilters.length;
165
- while (--i >= 0) {
166
- let f = finalFilters[i];
167
- if (f.inProgress) {
168
- f.inProgress = false;
169
- if (f.remDirs.length != 0) {
170
- let i = parts.length;
171
- while (--i >= 0) {
172
- let _g = 0;
173
- let _g1 = f.remDirs;
174
- while (_g < _g1.length) if (_g1[_g++].match(parts[i] + "/")) {
175
- parts.splice(i, 1);
176
- break;
177
- };
178
- };
179
- };
180
- f.pathSoFar = f.pathSoFar.concat(parts);
181
- if (!(f.filter == null || f.filter.match(Path.posix.join(...f.pathSoFar)))) {
182
- res = false;
183
- break;
184
- };
185
- };
186
- };
187
- if (res) {
188
- let serveId = Path.posix.join(...finalFilters[0].pathSoFar);
186
+ let serveId = Filters.tryFinalize(routeFilters, sourceId);
187
+ if (serveId != null) {
189
188
  results.push(new RouteResult(serveId, sourceId, stone));
190
189
  };
191
190
  };
@@ -275,6 +274,33 @@ class Router extends Register.inherits() {
275
274
  return Promise.all(_g);
276
275
  });
277
276
  }
277
+
278
+ /**
279
+ Get the raw Buffer of the first matching result.
280
+ */
281
+ getData(pattern) {
282
+ return this.get(pattern).then(function (r) {
283
+ return r[0].getData();
284
+ });
285
+ }
286
+
287
+ /**
288
+ Get the first matching result as a UTF-8 string.
289
+ */
290
+ getString(pattern) {
291
+ return this.get(pattern).then(function (r) {
292
+ return r[0].getString();
293
+ });
294
+ }
295
+
296
+ /**
297
+ Get the first matching result parsed as JSON.
298
+ */
299
+ getJson(pattern) {
300
+ return this.get(pattern).then(function (r) {
301
+ return r[0].getJson();
302
+ });
303
+ }
278
304
  listContents(pattern) {
279
305
  return this.get(pattern).then(function (files) {
280
306
  let result = new Array(files.length);
@@ -352,10 +378,95 @@ class Router extends Register.inherits() {
352
378
  return Router
353
379
  }
354
380
  }
381
+ Router.prototype.routes = null;
355
382
 
356
383
 
357
384
  export const Filters = Register.global("$hxClasses")["whet.route._Router.Filters"] =
358
385
  class Filters {
386
+
387
+ /**
388
+ Like finalize, but restores filter state afterwards. Returns serveId on match, null otherwise.
389
+ */
390
+ static tryFinalize(this1, finalPath) {
391
+ if (this1.length == 1) {
392
+ let f = this1[0];
393
+ let savedPath = f.pathSoFar;
394
+ let savedIP = f.inProgress;
395
+ let parts = finalPath.split("/");
396
+ let res = true;
397
+ let i = this1.length;
398
+ while (--i >= 0) {
399
+ let f = this1[i];
400
+ if (f.inProgress) {
401
+ f.inProgress = false;
402
+ if (f.remDirs.length != 0) {
403
+ let i = parts.length;
404
+ while (--i >= 0) {
405
+ let _g = 0;
406
+ let _g1 = f.remDirs;
407
+ while (_g < _g1.length) if (_g1[_g++].match(parts[i] + "/")) {
408
+ parts.splice(i, 1);
409
+ break;
410
+ };
411
+ };
412
+ };
413
+ f.pathSoFar = f.pathSoFar.concat(parts);
414
+ if (!(f.filter == null || f.filter.match(Path.posix.join(...f.pathSoFar)))) {
415
+ res = false;
416
+ break;
417
+ };
418
+ };
419
+ };
420
+ let serveId = (res) ? Path.posix.join(...this1[0].pathSoFar) : null;
421
+ f.pathSoFar = savedPath;
422
+ f.inProgress = savedIP;
423
+ return serveId;
424
+ };
425
+ let arr = this1;
426
+ let _g = [];
427
+ let _g1 = 0;
428
+ while (_g1 < arr.length) {
429
+ let f = arr[_g1];
430
+ ++_g1;
431
+ _g.push({"p": f.pathSoFar, "ip": f.inProgress});
432
+ };
433
+ let parts = finalPath.split("/");
434
+ let res = true;
435
+ let i = this1.length;
436
+ while (--i >= 0) {
437
+ let f = this1[i];
438
+ if (f.inProgress) {
439
+ f.inProgress = false;
440
+ if (f.remDirs.length != 0) {
441
+ let i = parts.length;
442
+ while (--i >= 0) {
443
+ let _g = 0;
444
+ let _g1 = f.remDirs;
445
+ while (_g < _g1.length) if (_g1[_g++].match(parts[i] + "/")) {
446
+ parts.splice(i, 1);
447
+ break;
448
+ };
449
+ };
450
+ };
451
+ f.pathSoFar = f.pathSoFar.concat(parts);
452
+ if (!(f.filter == null || f.filter.match(Path.posix.join(...f.pathSoFar)))) {
453
+ res = false;
454
+ break;
455
+ };
456
+ };
457
+ };
458
+ let serveId = (res) ? Path.posix.join(...this1[0].pathSoFar) : null;
459
+ let i1 = 0;
460
+ let _g2 = 0;
461
+ while (_g2 < arr.length) {
462
+ let f = arr[_g2];
463
+ ++_g2;
464
+ f.pathSoFar = _g[i1].p;
465
+ f.inProgress = _g[i1].ip;
466
+ ++i1;
467
+ };
468
+ return serveId;
469
+ }
359
470
  static isPathPossible(this1, f) {
360
471
  if (f.filter.options.matchBase) {
361
472
  return true;
@@ -5,12 +5,13 @@ import {Stone, AnyStone} from "../Stone"
5
5
  import {SourceHash} from "../SourceHash"
6
6
  import {SourceData} from "../Source"
7
7
  import {Project} from "../Project"
8
+ import {ConfigStore} from "../ConfigStore"
8
9
 
9
10
  export declare class Files extends Stone<FilesConfig> {
10
11
  constructor(config: FilesConfig)
11
12
  protected initConfig(): void
12
13
  protected generateHash(): Promise<SourceHash>
13
- list(): Promise<string[]>
14
+ protected list(): Promise<null | string[]>
14
15
  protected generate(hash: SourceHash): Promise<SourceData[]>
15
16
  protected walk<T>(onFile: ((arg0: string) => T), onDirFile: ((arg0: string, arg1: string) => T)): Promise<T[]>
16
17
  protected fromCwd(file: string, dir: string): {
@@ -27,6 +28,10 @@ export type FilesConfig = {
27
28
  */
28
29
  cacheStrategy?: null | CacheStrategy,
29
30
  /**
31
+ Optional ConfigStore for persistent per-stone config patching. Overrides project-level configStore.
32
+ */
33
+ configStore?: null | ConfigStore,
34
+ /**
30
35
  * Registers another stone(s) as dependency of this one. Useful for external processes
31
36
  * that use a source of some stone, but don't go via Whet to get it.
32
37
  * Use with combination of `setAbsolutePath` on the dependency, so that the external process
@@ -11,11 +11,12 @@ const $global = Register.$global
11
11
 
12
12
  export const Files = Register.global("$hxClasses")["whet.stones.Files"] =
13
13
  class Files extends Register.inherits(() => Stone, true) {
14
- new(config) {
15
- super.new(config);
14
+ [Register.new](config) {
15
+ super[Register.new](config);
16
16
  }
17
17
  initConfig() {
18
18
  this.config.recursive = (this.config.recursive != null) ? this.config.recursive : true;
19
+ this.config.id = (this.config.id != null) ? this.config.id : MaybeArray_Fields_.makeArray(this.config.paths)[0];
19
20
  }
20
21
  generateHash() {
21
22
  let hashCache = HashCache.get();
@@ -6,6 +6,7 @@ import {Stone, AnyStone} from "../Stone"
6
6
  import {SourceHash} from "../SourceHash"
7
7
  import {SourceData} from "../Source"
8
8
  import {Project} from "../Project"
9
+ import {ConfigStore} from "../ConfigStore"
9
10
 
10
11
  export declare class JsonStone extends Stone<JsonStoneConfig> {
11
12
  constructor(config: JsonStoneConfig)
@@ -13,7 +14,7 @@ export declare class JsonStone extends Stone<JsonStoneConfig> {
13
14
  addProjectData(): JsonStone
14
15
  protected generate(hash: SourceHash): Promise<SourceData[]>
15
16
  protected generateHash(): Promise<SourceHash>
16
- list(): Promise<string[]>
17
+ protected list(): Promise<null | string[]>
17
18
  protected initConfig(): void
18
19
  }
19
20
 
@@ -25,6 +26,10 @@ export type JsonStoneConfig = {
25
26
  */
26
27
  cacheStrategy?: null | CacheStrategy,
27
28
  /**
29
+ Optional ConfigStore for persistent per-stone config patching. Overrides project-level configStore.
30
+ */
31
+ configStore?: null | ConfigStore,
32
+ /**
28
33
  * Registers another stone(s) as dependency of this one. Useful for external processes
29
34
  * that use a source of some stone, but don't go via Whet to get it.
30
35
  * Use with combination of `setAbsolutePath` on the dependency, so that the external process
@@ -9,9 +9,9 @@ const $global = Register.$global
9
9
 
10
10
  export const JsonStone = Register.global("$hxClasses")["whet.stones.JsonStone"] =
11
11
  class JsonStone extends Register.inherits(Stone) {
12
- new(config) {
12
+ [Register.new](config) {
13
13
  this.data = {};
14
- super.new(config);
14
+ super[Register.new](config);
15
15
  }
16
16
  addProjectData() {
17
17
  this.data["name"] = this.project.name;
@@ -80,4 +80,5 @@ class JsonStone extends Register.inherits(Stone) {
80
80
  return JsonStone
81
81
  }
82
82
  }
83
+ JsonStone.prototype.data = null;
83
84
 
@@ -5,13 +5,14 @@ import {Stone, AnyStone} from "../Stone"
5
5
  import {SourceHash} from "../SourceHash"
6
6
  import {SourceData} from "../Source"
7
7
  import {Project} from "../Project"
8
+ import {ConfigStore} from "../ConfigStore"
8
9
 
9
10
  export declare class RemoteFile extends Stone<RemoteFileConfig> {
10
11
  constructor(config: RemoteFileConfig)
11
12
  protected initConfig(): void
12
13
  protected generate(hash: SourceHash): Promise<SourceData[]>
13
- protected get(url: string, res: ((arg0: SourceData[]) => void), rej: ((reason: any) => void)): void
14
- list(): Promise<string[]>
14
+ protected get(url: string, res: ((arg0: SourceData[]) => void), rej: ((arg0: Error) => void)): void
15
+ protected list(): Promise<null | string[]>
15
16
  generateHash(): Promise<SourceHash>
16
17
  protected getId(): string
17
18
  }
@@ -24,6 +25,10 @@ export type RemoteFileConfig = {
24
25
  */
25
26
  cacheStrategy?: null | CacheStrategy,
26
27
  /**
28
+ Optional ConfigStore for persistent per-stone config patching. Overrides project-level configStore.
29
+ */
30
+ configStore?: null | ConfigStore,
31
+ /**
27
32
  * Registers another stone(s) as dependency of this one. Useful for external processes
28
33
  * that use a source of some stone, but don't go via Whet to get it.
29
34
  * Use with combination of `setAbsolutePath` on the dependency, so that the external process
@@ -13,8 +13,8 @@ const $global = Register.$global
13
13
 
14
14
  export const RemoteFile = Register.global("$hxClasses")["whet.stones.RemoteFile"] =
15
15
  class RemoteFile extends Register.inherits(Stone) {
16
- new(config) {
17
- super.new(config);
16
+ [Register.new](config) {
17
+ super[Register.new](config);
18
18
  }
19
19
  initConfig() {
20
20
  if (this.config.cacheStrategy == null) {
@@ -30,24 +30,27 @@ class RemoteFile extends Register.inherits(Stone) {
30
30
  }
31
31
  get(url, res, rej) {
32
32
  let _gthis = this;
33
- Https.get(url, function (response) {
33
+ let req = Https.get(url, function (response) {
34
34
  if (response.statusCode == 301 || response.statusCode == 302) {
35
35
  _gthis.get(response.headers["location"], res, rej);
36
36
  return;
37
37
  };
38
38
  if (response.statusCode < 200 || response.statusCode >= 300) {
39
39
  response.resume();
40
- throw new Error("Error downloading file. " + response.statusCode + " – " + response.statusMessage);
40
+ rej(new Error("Error downloading file. " + response.statusCode + " – " + response.statusMessage));
41
+ return;
41
42
  };
42
43
  let bufs = [];
43
44
  response.on("data", function (d) {
44
45
  return bufs.push(d);
45
46
  });
47
+ response.on("error", rej);
46
48
  response.on("end", function () {
47
49
  let data = Buffer.concat(bufs);
48
50
  res([SourceData.fromBytes(_gthis.getId(), data)]);
49
51
  });
50
52
  });
53
+ req.on("error", rej);
51
54
  }
52
55
  list() {
53
56
  return Promise.resolve([this.getId()]);
@@ -6,6 +6,7 @@ import {Stone, AnyStone} from "../Stone"
6
6
  import {SourceHash} from "../SourceHash"
7
7
  import {SourceData} from "../Source"
8
8
  import {Project} from "../Project"
9
+ import {ConfigStore} from "../ConfigStore"
9
10
 
10
11
  export declare class ZipStone extends Stone<ZipConfig> {
11
12
  constructor(config: ZipConfig)
@@ -16,7 +17,7 @@ export declare class ZipStone extends Stone<ZipConfig> {
16
17
  */
17
18
  protected generateHash(): Promise<SourceHash>
18
19
  protected generate(hash: SourceHash): Promise<SourceData[]>
19
- list(): Promise<string[]>
20
+ protected list(): Promise<null | string[]>
20
21
  }
21
22
 
22
23
  export type ZipConfig = {
@@ -27,6 +28,10 @@ export type ZipConfig = {
27
28
  */
28
29
  cacheStrategy?: null | CacheStrategy,
29
30
  /**
31
+ Optional ConfigStore for persistent per-stone config patching. Overrides project-level configStore.
32
+ */
33
+ configStore?: null | ConfigStore,
34
+ /**
30
35
  * Registers another stone(s) as dependency of this one. Useful for external processes
31
36
  * that use a source of some stone, but don't go via Whet to get it.
32
37
  * Use with combination of `setAbsolutePath` on the dependency, so that the external process
@@ -17,8 +17,8 @@ const $global = Register.$global
17
17
 
18
18
  export const ZipStone = Register.global("$hxClasses")["whet.stones.ZipStone"] =
19
19
  class ZipStone extends Register.inherits(Stone) {
20
- new(config) {
21
- super.new(config);
20
+ [Register.new](config) {
21
+ super[Register.new](config);
22
22
  }
23
23
  initConfig() {
24
24
  if (this.config.filename == null) {
@@ -6,6 +6,7 @@ import {Stone, AnyStone} from "../../Stone"
6
6
  import {SourceHash} from "../../SourceHash"
7
7
  import {SourceData} from "../../Source"
8
8
  import {Project} from "../../Project"
9
+ import {ConfigStore} from "../../ConfigStore"
9
10
 
10
11
  export declare class HaxeBuild extends Stone<BuildConfig> {
11
12
  constructor(config: BuildConfig)
@@ -17,7 +18,7 @@ export declare class HaxeBuild extends Stone<BuildConfig> {
17
18
  build(): Promise<any>
18
19
  protected generate(hash: SourceHash): Promise<SourceData[]>
19
20
  protected addCommands(): void
20
- list(): Promise<string[]>
21
+ protected list(): Promise<null | string[]>
21
22
  protected generateHash(): Promise<SourceHash>
22
23
  }
23
24
 
@@ -28,6 +29,10 @@ export type BuildConfig = {
28
29
  * After stone is initialized, change `stone.cacheStrategy` directly.
29
30
  */
30
31
  cacheStrategy?: null | CacheStrategy,
32
+ /**
33
+ Optional ConfigStore for persistent per-stone config patching. Overrides project-level configStore.
34
+ */
35
+ configStore?: null | ConfigStore,
31
36
  cwd?: null | string,
32
37
  /**
33
38
  * Registers another stone(s) as dependency of this one. Useful for external processes
@@ -40,6 +45,7 @@ export type BuildConfig = {
40
45
  * Do not create cyclic dependencies!
41
46
  */
42
47
  dependencies?: null | MaybeArray<AnyStone>,
48
+ exposeCommands?: null | boolean,
43
49
  filename?: null | string,
44
50
  hxml: Hxml,
45
51
  /**
@@ -14,8 +14,8 @@ const $global = Register.$global
14
14
 
15
15
  export const HaxeBuild = Register.global("$hxClasses")["whet.stones.haxe.HaxeBuild"] =
16
16
  class HaxeBuild extends Register.inherits(Stone) {
17
- new(config) {
18
- super.new(config);
17
+ [Register.new](config) {
18
+ super[Register.new](config);
19
19
  }
20
20
  initConfig() {
21
21
  if (this.config.cacheStrategy == null) {
@@ -78,15 +78,17 @@ class HaxeBuild extends Register.inherits(Stone) {
78
78
  }
79
79
  addCommands() {
80
80
  let _gthis = this;
81
- this.project.addCommand("build", this).action(function (..._) {
82
- return _gthis.project.cache.refreshSource(_gthis);
83
- });
81
+ if (this.config.exposeCommands != false) {
82
+ this.project.addCommand("build", this).action(function (..._) {
83
+ return _gthis.project.cache.refreshSource(_gthis);
84
+ });
85
+ };
84
86
  }
85
87
  list() {
86
88
  if (this.config.hxml.isSingleFile()) {
87
89
  return Promise.resolve([this.config.hxml.getBuildFilename()]);
88
90
  } else {
89
- return super.list();
91
+ return Promise.resolve(null);
90
92
  };
91
93
  }
92
94
  generateHash() {
@@ -6,6 +6,7 @@ import {Stone, AnyStone} from "../../Stone"
6
6
  import {SourceHash} from "../../SourceHash"
7
7
  import {SourceData} from "../../Source"
8
8
  import {Project} from "../../Project"
9
+ import {ConfigStore} from "../../ConfigStore"
9
10
 
10
11
  export declare class Hxml extends Stone<HxmlConfig> {
11
12
  constructor(config: HxmlConfig)
@@ -22,7 +23,7 @@ export declare class Hxml extends Stone<HxmlConfig> {
22
23
  isSingleFile(): boolean
23
24
  getBuildExtension(): string
24
25
  protected generate(hash: SourceHash): Promise<SourceData[]>
25
- list(): Promise<string[]>
26
+ protected list(): Promise<null | string[]>
26
27
  protected filename(): string
27
28
  generateHash(): Promise<SourceHash>
28
29
  generateHashSync(): SourceHash
@@ -36,6 +37,10 @@ export type HxmlConfig = {
36
37
  * After stone is initialized, change `stone.cacheStrategy` directly.
37
38
  */
38
39
  cacheStrategy?: null | CacheStrategy,
40
+ /**
41
+ Optional ConfigStore for persistent per-stone config patching. Overrides project-level configStore.
42
+ */
43
+ configStore?: null | ConfigStore,
39
44
  dce?: null | DCE,
40
45
  debug?: null | boolean,
41
46
  defines?: null | MaybeArray<string>,
@@ -50,6 +55,7 @@ export type HxmlConfig = {
50
55
  * Do not create cyclic dependencies!
51
56
  */
52
57
  dependencies?: null | MaybeArray<AnyStone>,
58
+ exposeCommands?: null | boolean,
53
59
  flags?: null | MaybeArray<MaybeArray<string>>,
54
60
  /**
55
61
  Defaults to the Stone's class name.