whet 0.0.34 → 0.1.0

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 +39 -4
  42. package/bin/whet/Project.js +154 -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 +22 -1
  66. package/bin/whet/route/Router.js +121 -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
@@ -10,7 +10,7 @@ const $global = Register.$global
10
10
 
11
11
  export const CacheManager = Register.global("$hxClasses")["whet.cache.CacheManager"] =
12
12
  class CacheManager extends Register.inherits() {
13
- new(project) {
13
+ [Register.new](project) {
14
14
  this.defaultFileStrategy = CacheStrategy.InFile(CacheDurability.Any([CacheDurability.LimitCountByLastUse(1), CacheDurability.All([CacheDurability.MaxAge(86400), CacheDurability.LimitCountByLastUse(5)])]), DurabilityCheck.AllOnUse);
15
15
  this.fileCache = null;
16
16
  this.memCache = null;
@@ -46,6 +46,33 @@ class CacheManager extends Register.inherits() {
46
46
 
47
47
  };
48
48
  }
49
+ getPartialSource(stone, sourceId) {
50
+ let _g = stone.cacheStrategy;
51
+ switch (_g._hx_index) {
52
+ case 0:
53
+ return stone.acquire(function () {
54
+ return stone.finalMaybeHash().then(function (hash) {
55
+ return stone.generatePartialSource(sourceId, hash).then(function (r) {
56
+ return r.source.filterTo(sourceId);
57
+ });
58
+ });
59
+ });
60
+ break
61
+ case 1:
62
+ let _g1 = _g.check;
63
+ return this.memCache.getPartial(stone, sourceId, _g.durability, (_g1 != null) ? _g1 : DurabilityCheck.AllOnUse);
64
+ break
65
+ case 2:
66
+ let _g2 = _g.check;
67
+ return this.fileCache.getPartial(stone, sourceId, _g.durability, (_g2 != null) ? _g2 : DurabilityCheck.AllOnUse);
68
+ break
69
+ case 3:
70
+ let _g3 = _g.check;
71
+ return this.fileCache.getPartial(stone, sourceId, _g.durability, (_g3 != null) ? _g3 : DurabilityCheck.AllOnUse);
72
+ break
73
+
74
+ };
75
+ }
49
76
 
50
77
  /**
51
78
  * Re-generates source even if the currently cached value is valid.
@@ -79,7 +106,8 @@ class CacheManager extends Register.inherits() {
79
106
  * The path is not reserved. Caching depends on stone's `cacheStrategy` and success of source generation.
80
107
  */
81
108
  getDir(stone, hash) {
82
- let baseDir = stone.id + "/";
109
+ let _this_r = new RegExp("[^a-zA-Z0-9_\\-.]", "g".split("u").join(""));
110
+ let baseDir = stone.id.replace(_this_r, "_") + "/";
83
111
  let tmp;
84
112
  switch (stone.cacheStrategy._hx_index) {
85
113
  case 0:
@@ -123,6 +151,9 @@ class CacheManager extends Register.inherits() {
123
151
  };
124
152
  return id;
125
153
  }
154
+ close() {
155
+ return this.fileCache.close();
156
+ }
126
157
  static get __name__() {
127
158
  return "whet.cache.CacheManager"
128
159
  }
@@ -130,4 +161,9 @@ class CacheManager extends Register.inherits() {
130
161
  return CacheManager
131
162
  }
132
163
  }
164
+ CacheManager.prototype.project = null;
165
+ CacheManager.prototype.defaultStrategy = null;
166
+ CacheManager.prototype.memCache = null;
167
+ CacheManager.prototype.fileCache = null;
168
+ CacheManager.prototype.defaultFileStrategy = null;
133
169
 
@@ -6,7 +6,9 @@ import {Source} from "../Source"
6
6
  export declare class FileCache extends BaseCache<string, RuntimeFileCacheValue> {
7
7
  constructor(rootDir: string)
8
8
  protected dbFile: string
9
- protected flushQueued: boolean
9
+ protected flushTimerId: any
10
+ protected flushResolve: (arg0: any) => void
11
+ protected flushPromise: Promise<void>
10
12
  protected key(stone: AnyStone): string
11
13
  protected value(source: Source): Promise<RuntimeFileCacheValue>
12
14
  protected source(stone: AnyStone, value: RuntimeFileCacheValue): Promise<Source>
@@ -15,11 +17,17 @@ export declare class FileCache extends BaseCache<string, RuntimeFileCacheValue>
15
17
  protected remove(stone: AnyStone, value: RuntimeFileCacheValue): Promise<any>
16
18
  protected setRecentUseOrder(values: RuntimeFileCacheValue[], value: RuntimeFileCacheValue): boolean
17
19
  protected getDirFor(value: RuntimeFileCacheValue): string
18
- protected flush(): void
20
+ protected hasSourceId(value: RuntimeFileCacheValue, sourceId: string): boolean
21
+ protected mergePartial(stone: AnyStone, existing: RuntimeFileCacheValue, addition: Source, markComplete: boolean): Promise<RuntimeFileCacheValue>
22
+ protected replaceEntry(stone: AnyStone, existing: RuntimeFileCacheValue, replacement: Source): Promise<RuntimeFileCacheValue>
23
+ protected flush(): Promise<void>
24
+ protected doFlush(): void
25
+ close(): Promise<void>
19
26
  }
20
27
 
21
28
  export type FileCacheValue<H, S> = {
22
29
  baseDir: S,
30
+ complete: boolean,
23
31
  ctime: number,
24
32
  ctimePretty?: null | string,
25
33
  files: {
@@ -16,9 +16,11 @@ const $global = Register.$global
16
16
 
17
17
  export const FileCache = Register.global("$hxClasses")["whet.cache.FileCache"] =
18
18
  class FileCache extends Register.inherits(() => BaseCache, true) {
19
- new(rootDir) {
20
- this.flushQueued = false;
21
- super.new(rootDir, new StringMap());
19
+ [Register.new](rootDir) {
20
+ this.flushPromise = null;
21
+ this.flushResolve = null;
22
+ this.flushTimerId = null;
23
+ super[Register.new](rootDir, new StringMap());
22
24
  this.dbFile = Path.posix.join(".", rootDir, ".", ".whet/cache.json");
23
25
  try {
24
26
  let db = JSON.parse(Fs.readFileSync(this.dbFile, {"encoding": "utf-8"}));
@@ -36,6 +38,7 @@ class FileCache extends Register.inherits(() => BaseCache, true) {
36
38
  let tmp = SourceHash.fromHex(val.hash);
37
39
  let val1 = val.ctime;
38
40
  let val2 = val.baseDir;
41
+ let tmp1 = (val.complete != null) ? val.complete : true;
39
42
  let _g2 = [];
40
43
  let _g3 = 0;
41
44
  let _g4 = val.files;
@@ -44,7 +47,7 @@ class FileCache extends Register.inherits(() => BaseCache, true) {
44
47
  ++_g3;
45
48
  _g2.push({"fileHash": SourceHash.fromHex(file.fileHash), "filePath": file.filePath, "id": file.id, "mtime": file.mtime, "size": file.size});
46
49
  };
47
- _g.push({"hash": tmp, "ctime": val1, "baseDir": val2, "files": _g2});
50
+ _g.push({"hash": tmp, "ctime": val1, "baseDir": val2, "complete": tmp1, "files": _g2});
48
51
  };
49
52
  this1.inst.set(key, _g);
50
53
  };
@@ -78,7 +81,7 @@ class FileCache extends Register.inherits(() => BaseCache, true) {
78
81
  }));
79
82
  };
80
83
  return Promise.all(_g1).then(function (files) {
81
- return {"hash": source.hash, "ctime": source.ctime, "baseDir": source.getDirPath(), "ctimePretty": null, "files": files};
84
+ return {"hash": source.hash, "ctime": source.ctime, "baseDir": source.getDirPath(), "complete": source.complete, "ctimePretty": null, "files": files};
82
85
  });
83
86
  }
84
87
  source(stone, value) {
@@ -136,7 +139,7 @@ class FileCache extends Register.inherits(() => BaseCache, true) {
136
139
  }));
137
140
  };
138
141
  return Promise.all(_g1).then(function (data) {
139
- return new Source(data, value.hash, stone, value.ctime);
142
+ return new Source(data, value.hash, stone, value.ctime, (value.complete != null) ? value.complete : true);
140
143
  }, function (rejected) {
141
144
  if (rejected == "Invalid.") {
142
145
  return null;
@@ -227,47 +230,142 @@ class FileCache extends Register.inherits(() => BaseCache, true) {
227
230
  getDirFor(value) {
228
231
  return value.baseDir;
229
232
  }
230
- flush() {
231
- if (this.flushQueued) {
232
- return;
233
- };
234
- this.flushQueued = true;
233
+ hasSourceId(value, sourceId) {
234
+ return Lambda.exists(value.files, function (f) {
235
+ return f.id == sourceId;
236
+ });
237
+ }
238
+ mergePartial(stone, existing, addition, markComplete) {
239
+ let _g = [];
240
+ let _g1 = 0;
241
+ let _g2 = existing.files;
242
+ while (_g1 < _g2.length) _g.push(_g2[_g1++]);
243
+ let mergedFiles = _g;
235
244
  let _gthis = this;
236
- global.setTimeout(function () {
237
- _gthis.flushQueued = false;
238
- let db = {};
239
- let this1 = _gthis.cache;
240
- let _g_keys = this1.keys();
241
- while (_g_keys.hasNext()) {
242
- let key = _g_keys.next();
243
- let _g_value = this1.get(key);
244
- let _g = [];
245
- let _g1 = 0;
246
- while (_g1 < _g_value.length) {
247
- let val = _g_value[_g1];
248
- ++_g1;
249
- let tmp = SourceHash.toHex(val.hash);
250
- let val1 = val.ctime;
251
- let tmp1 = HxOverrides.dateStr(new Date(val.ctime * 1000));
252
- let tmp2 = Path.posix.join(".", "./", ".", val.baseDir);
253
- let _g2 = [];
254
- let _g3 = 0;
255
- let _g4 = val.files;
256
- while (_g3 < _g4.length) {
257
- let file = _g4[_g3];
258
- ++_g3;
259
- _g2.push({"fileHash": SourceHash.toHex(file.fileHash), "filePath": Path.posix.join(".", "./", ".", file.filePath), "id": Path.posix.join(".", "./", ".", file.id), "mtime": file.mtime, "size": file.size});
245
+ if (addition != null) {
246
+ return this.value(addition).then(function (addVal) {
247
+ let _g = 0;
248
+ let _g1 = addVal.files;
249
+ while (_g < _g1.length) {
250
+ let newFile = _g1[_g];
251
+ ++_g;
252
+ let replaced = false;
253
+ let _g2 = 0;
254
+ let _g3 = mergedFiles.length;
255
+ while (_g2 < _g3) {
256
+ let i = _g2++;
257
+ if (mergedFiles[i].id == newFile.id) {
258
+ mergedFiles[i] = newFile;
259
+ replaced = true;
260
+ break;
261
+ };
262
+ };
263
+ if (!replaced) {
264
+ mergedFiles.push(newFile);
260
265
  };
261
- _g.push({"hash": tmp, "ctime": val1, "ctimePretty": tmp1, "baseDir": tmp2, "files": _g2});
262
266
  };
263
- db[key] = _g;
267
+ let merged = {"hash": existing.hash, "ctime": existing.ctime, "baseDir": existing.baseDir, "complete": markComplete, "files": mergedFiles};
268
+ let this1 = _gthis.cache;
269
+ let key = _gthis.key(stone);
270
+ let values = this1.inst.get(key);
271
+ let idx = values.indexOf(existing);
272
+ if (idx >= 0) {
273
+ values[idx] = merged;
274
+ };
275
+ _gthis.flush();
276
+ return merged;
277
+ });
278
+ } else {
279
+ let merged = {"hash": existing.hash, "ctime": existing.ctime, "baseDir": existing.baseDir, "complete": markComplete, "files": mergedFiles};
280
+ let this1 = this.cache;
281
+ let key = this.key(stone);
282
+ let values = this1.inst.get(key);
283
+ let idx = values.indexOf(existing);
284
+ if (idx >= 0) {
285
+ values[idx] = merged;
264
286
  };
265
- Utils.saveContent(_gthis.dbFile, JSON.stringify(db, null, "\t")).then(function (_) {
266
- Log.log(10, ...["FileCache DB saved."]);
267
- }, function (err) {
268
- Log.log(50, ...["FileCache DB save error.", err]);
287
+ this.flush();
288
+ return Promise.resolve(merged);
289
+ };
290
+ }
291
+ replaceEntry(stone, existing, replacement) {
292
+ let _gthis = this;
293
+ return this.value(replacement).then(function (newVal) {
294
+ let this1 = _gthis.cache;
295
+ let key = _gthis.key(stone);
296
+ let values = this1.inst.get(key);
297
+ let idx = values.indexOf(existing);
298
+ if (idx >= 0) {
299
+ values[idx] = newVal;
300
+ };
301
+ _gthis.flush();
302
+ return newVal;
303
+ });
304
+ }
305
+ flush() {
306
+ let _gthis = this;
307
+ if (this.flushPromise == null) {
308
+ this.flushPromise = new Promise(function (res, _) {
309
+ _gthis.flushResolve = res;
269
310
  });
270
- }, 100);
311
+ };
312
+ if (this.flushTimerId == null) {
313
+ this.flushTimerId = global.setTimeout(Register.bind(this, this.doFlush), 100);
314
+ };
315
+ return this.flushPromise;
316
+ }
317
+ doFlush() {
318
+ this.flushTimerId = null;
319
+ let resolve = this.flushResolve;
320
+ this.flushPromise = null;
321
+ this.flushResolve = null;
322
+ let db = {};
323
+ let this1 = this.cache;
324
+ let _g_keys = this1.keys();
325
+ while (_g_keys.hasNext()) {
326
+ let key = _g_keys.next();
327
+ let _g_value = this1.get(key);
328
+ let _g = [];
329
+ let _g1 = 0;
330
+ while (_g1 < _g_value.length) {
331
+ let val = _g_value[_g1];
332
+ ++_g1;
333
+ let tmp = SourceHash.toHex(val.hash);
334
+ let val1 = val.ctime;
335
+ let tmp1 = HxOverrides.dateStr(new Date(val.ctime * 1000));
336
+ let tmp2 = Path.posix.join(".", "./", ".", val.baseDir);
337
+ let val2 = val.complete;
338
+ let _g2 = [];
339
+ let _g3 = 0;
340
+ let _g4 = val.files;
341
+ while (_g3 < _g4.length) {
342
+ let file = _g4[_g3];
343
+ ++_g3;
344
+ _g2.push({"fileHash": SourceHash.toHex(file.fileHash), "filePath": Path.posix.join(".", "./", ".", file.filePath), "id": Path.posix.join(".", "./", ".", file.id), "mtime": file.mtime, "size": file.size});
345
+ };
346
+ _g.push({"hash": tmp, "ctime": val1, "ctimePretty": tmp1, "baseDir": tmp2, "complete": val2, "files": _g2});
347
+ };
348
+ db[key] = _g;
349
+ };
350
+ Utils.saveContent(this.dbFile, JSON.stringify(db, null, "\t")).then(function (_) {
351
+ Log.log(10, ...["FileCache DB saved."]);
352
+ resolve(null);
353
+ }, function (err) {
354
+ Log.log(50, ...["FileCache DB save error.", err]);
355
+ resolve(null);
356
+ });
357
+ }
358
+ close() {
359
+ if (this.flushTimerId != null) {
360
+ global.clearTimeout(this.flushTimerId);
361
+ this.flushTimerId = null;
362
+ };
363
+ if (this.flushResolve != null) {
364
+ let p = this.flushPromise;
365
+ this.doFlush();
366
+ return p;
367
+ };
368
+ return Promise.resolve(null);
271
369
  }
272
370
  static get __name__() {
273
371
  return "whet.cache.FileCache"
@@ -279,4 +377,8 @@ class FileCache extends Register.inherits(() => BaseCache, true) {
279
377
  return FileCache
280
378
  }
281
379
  }
380
+ FileCache.prototype.dbFile = null;
381
+ FileCache.prototype.flushTimerId = null;
382
+ FileCache.prototype.flushResolve = null;
383
+ FileCache.prototype.flushPromise = null;
282
384
 
@@ -11,7 +11,7 @@ const $global = Register.$global
11
11
  */
12
12
  export const HashCache = Register.global("$hxClasses")["whet.cache.HashCache"] =
13
13
  class HashCache extends Register.inherits() {
14
- new() {
14
+ [Register.new]() {
15
15
  this.cache = new StringMap();
16
16
  }
17
17
 
@@ -76,4 +76,5 @@ class HashCache extends Register.inherits() {
76
76
  return HashCache
77
77
  }
78
78
  }
79
+ HashCache.prototype.cache = null;
79
80
 
@@ -9,4 +9,7 @@ export declare class MemoryCache extends BaseCache<AnyStone, Source> {
9
9
  protected source(stone: AnyStone, value: Source): Promise<Source>
10
10
  protected getExistingDirs(stone: AnyStone): string[]
11
11
  protected getDirFor(value: Source): string
12
+ protected hasSourceId(value: Source, sourceId: string): boolean
13
+ protected mergePartial(stone: AnyStone, existing: Source, addition: Source, markComplete: boolean): Promise<Source>
14
+ protected replaceEntry(stone: AnyStone, existing: Source, replacement: Source): Promise<Source>
12
15
  }
@@ -1,13 +1,15 @@
1
1
  import {BaseCache} from "./BaseCache.js"
2
+ import {Source} from "../Source.js"
2
3
  import {ObjectMap} from "../../haxe/ds/ObjectMap.js"
3
4
  import {Register} from "../../genes/Register.js"
5
+ import {Lambda} from "../../Lambda.js"
4
6
 
5
7
  const $global = Register.$global
6
8
 
7
9
  export const MemoryCache = Register.global("$hxClasses")["whet.cache.MemoryCache"] =
8
10
  class MemoryCache extends Register.inherits(() => BaseCache, true) {
9
- new(rootDir) {
10
- super.new(rootDir, new ObjectMap());
11
+ [Register.new](rootDir) {
12
+ super[Register.new](rootDir, new ObjectMap());
11
13
  }
12
14
  key(stone) {
13
15
  return stone;
@@ -45,6 +47,55 @@ class MemoryCache extends Register.inherits(() => BaseCache, true) {
45
47
  getDirFor(value) {
46
48
  return value.tryDirPath();
47
49
  }
50
+ hasSourceId(value, sourceId) {
51
+ return Lambda.exists(value.data, function (d) {
52
+ return d.id == sourceId;
53
+ });
54
+ }
55
+ mergePartial(stone, existing, addition, markComplete) {
56
+ let mergedData = existing.data.slice();
57
+ if (addition != null) {
58
+ let _g = 0;
59
+ let _g1 = addition.data;
60
+ while (_g < _g1.length) {
61
+ let newItem = _g1[_g];
62
+ ++_g;
63
+ let replaced = false;
64
+ let _g2 = 0;
65
+ let _g3 = mergedData.length;
66
+ while (_g2 < _g3) {
67
+ let i = _g2++;
68
+ if (mergedData[i].id == newItem.id) {
69
+ mergedData[i] = newItem;
70
+ replaced = true;
71
+ break;
72
+ };
73
+ };
74
+ if (!replaced) {
75
+ mergedData.push(newItem);
76
+ };
77
+ };
78
+ };
79
+ let merged = new Source(mergedData, existing.hash, stone, existing.ctime, markComplete);
80
+ let this1 = this.cache;
81
+ let key = this.key(stone);
82
+ let values = this1.inst.get(key);
83
+ let idx = values.indexOf(existing);
84
+ if (idx >= 0) {
85
+ values[idx] = merged;
86
+ };
87
+ return Promise.resolve(merged);
88
+ }
89
+ replaceEntry(stone, existing, replacement) {
90
+ let this1 = this.cache;
91
+ let key = this.key(stone);
92
+ let values = this1.inst.get(key);
93
+ let idx = values.indexOf(existing);
94
+ if (idx >= 0) {
95
+ values[idx] = replacement;
96
+ };
97
+ return Promise.resolve(replacement);
98
+ }
48
99
  static get __name__() {
49
100
  return "whet.cache.MemoryCache"
50
101
  }
@@ -1,4 +1,4 @@
1
- import Minimatch from "minimatch"
1
+ import {Minimatch} from "minimatch"
2
2
 
3
3
  export type MinimatchType = Minimatch | string
4
4
 
@@ -1,4 +1,4 @@
1
- import Minimatch from "minimatch"
1
+ import {Minimatch} from "minimatch"
2
2
  import {Register} from "../../genes/Register.js"
3
3
 
4
4
  const $global = Register.$global
@@ -7,8 +7,8 @@ export const MinimatchType_Fields_ = Register.global("$hxClasses")["whet.magic._
7
7
  class MinimatchType_Fields_ {
8
8
  static makeMinimatch(src) {
9
9
  if (typeof(src) == "string") {
10
- return new Minimatch.Minimatch(src, null);
11
- } else if (src instanceof Minimatch.Minimatch) {
10
+ return new Minimatch(src);
11
+ } else if (src instanceof Minimatch) {
12
12
  return src;
13
13
  } else {
14
14
  throw new Error("Expected a string or Minimatch object.");
@@ -2,7 +2,7 @@ import {Files} from "../stones/Files.js"
2
2
  import {Router} from "../route/Router.js"
3
3
  import {MinimatchType_Fields_} from "./MinimatchType.js"
4
4
  import {Stone} from "../Stone.js"
5
- import Minimatch from "minimatch"
5
+ import {Minimatch} from "minimatch"
6
6
  import {Register} from "../../genes/Register.js"
7
7
 
8
8
  const $global = Register.$global
@@ -1,4 +1,4 @@
1
- import Minimatch from "minimatch"
1
+ import {Minimatch} from "minimatch"
2
2
  import {Register} from "../../genes/Register.js"
3
3
 
4
4
  const $global = Register.$global
@@ -31,7 +31,7 @@ class OutputFilterMatcher {
31
31
  if (!queryIsPattern && filter.patterns != null) {
32
32
  let _g = 0;
33
33
  let _g1 = filter.patterns;
34
- while (_g < _g1.length) if (new Minimatch.Minimatch("**/" + _g1[_g++], null).match(query)) {
34
+ while (_g < _g1.length) if (new Minimatch("**/" + _g1[_g++]).match(query)) {
35
35
  return true;
36
36
  };
37
37
  return false;
@@ -1,5 +1,6 @@
1
1
  import {AnyStone} from "../Stone"
2
2
  import {SourceData} from "../Source"
3
+ import {Buffer} from "buffer"
3
4
 
4
5
  export declare class RouteResult {
5
6
  constructor(serveId: string, sourceId: string, source: AnyStone)
@@ -19,4 +20,19 @@ export declare class RouteResult {
19
20
  */
20
21
  source: AnyStone
21
22
  get(): Promise<SourceData>
23
+
24
+ /**
25
+ Get the raw Buffer directly.
26
+ */
27
+ getData(): Promise<Buffer>
28
+
29
+ /**
30
+ Get the output as a UTF-8 string.
31
+ */
32
+ getString(): Promise<string>
33
+
34
+ /**
35
+ Get the output parsed as JSON.
36
+ */
37
+ getJson(): Promise<any>
22
38
  }
@@ -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,7 +3,8 @@ 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)
@@ -27,6 +28,21 @@ export declare class Router {
27
28
  * Save files filtered by `pattern` into provided `saveInto` folder.
28
29
  */
29
30
  saveInto(pattern: MinimatchType, saveInto: string, clearFirst?: boolean): Promise<any>
31
+
32
+ /**
33
+ Get the raw Buffer of the first matching result.
34
+ */
35
+ getData(pattern?: null | MinimatchType): Promise<Buffer>
36
+
37
+ /**
38
+ Get the first matching result as a UTF-8 string.
39
+ */
40
+ getString(pattern?: null | MinimatchType): Promise<string>
41
+
42
+ /**
43
+ Get the first matching result parsed as JSON.
44
+ */
45
+ getJson(pattern?: null | MinimatchType): Promise<any>
30
46
  listContents(pattern?: null | MinimatchType): Promise<string>
31
47
 
32
48
  /**
@@ -44,6 +60,11 @@ export type Filter = {
44
60
  }
45
61
 
46
62
  export declare class Filters {
63
+
64
+ /**
65
+ Like finalize, but restores filter state afterwards. Returns serveId on match, null otherwise.
66
+ */
67
+ static tryFinalize($this: Filter[], finalPath: string): null | string
47
68
  protected static isPathPossible($this: Filter[], f: Filter): boolean
48
69
  }
49
70