whet 0.1.1 → 0.4.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 (48) hide show
  1. package/bin/genes/util/EsMap.d.ts +1 -0
  2. package/bin/genes/util/EsMap.js +3 -0
  3. package/bin/haxe/Constraints.d.ts +1 -0
  4. package/bin/haxe/ds/IntMap.d.ts +6 -0
  5. package/bin/haxe/ds/IntMap.js +25 -0
  6. package/bin/haxe/ds/Vector.d.ts +2 -0
  7. package/bin/minimatch/MinimatchOptions.d.ts +28 -0
  8. package/bin/whet/Log.js +3 -0
  9. package/bin/whet/Project.d.ts +13 -0
  10. package/bin/whet/Project.js +26 -0
  11. package/bin/whet/Stone.d.ts +23 -0
  12. package/bin/whet/Stone.js +162 -7
  13. package/bin/whet/Whet.d.ts +1 -1
  14. package/bin/whet/Whet.js +68 -1
  15. package/bin/whet/cache/BaseCache.d.ts +7 -0
  16. package/bin/whet/cache/BaseCache.js +103 -7
  17. package/bin/whet/cache/CacheManager.d.ts +5 -0
  18. package/bin/whet/cache/CacheManager.js +97 -7
  19. package/bin/whet/cache/FileCache.d.ts +1 -0
  20. package/bin/whet/cache/FileCache.js +4 -0
  21. package/bin/whet/cache/MemoContext.d.ts +17 -0
  22. package/bin/whet/cache/MemoContext.js +35 -0
  23. package/bin/whet/magic/RoutePathType.js +5 -5
  24. package/bin/whet/profiler/Profiler.d.ts +65 -0
  25. package/bin/whet/profiler/Profiler.js +351 -0
  26. package/bin/whet/profiler/Span.d.ts +90 -0
  27. package/bin/whet/profiler/Span.js +56 -0
  28. package/bin/whet/profiler/SpanRecorder.d.ts +20 -0
  29. package/bin/whet/profiler/SpanRecorder.js +63 -0
  30. package/bin/whet/profiler/SpanStats.d.ts +15 -0
  31. package/bin/whet/profiler/SpanStats.js +49 -0
  32. package/bin/whet/route/Router.d.ts +5 -0
  33. package/bin/whet/route/Router.js +47 -33
  34. package/bin/whet/stones/Files.d.ts +5 -0
  35. package/bin/whet/stones/Files.js +20 -0
  36. package/bin/whet/stones/StoneFactory.d.ts +55 -0
  37. package/bin/whet/stones/StoneFactory.js +116 -0
  38. package/bin/whet.d.ts +2 -0
  39. package/bin/whet.js +1 -0
  40. package/package.json +2 -2
  41. package/bin/haxe/Log.d.ts +0 -33
  42. package/bin/haxe/Log.js +0 -61
  43. package/bin/pino_pretty/PrettyOptions.d.ts +0 -98
  44. package/bin/pino_pretty/default_/MessageFormatFunc.d.ts +0 -2
  45. package/bin/pino_pretty/default_/Prettifier.d.ts +0 -2
  46. package/bin/whet/extern/Minimatch.d.ts +0 -77
  47. package/bin/whet/stones/Server.d.ts +0 -59
  48. package/bin/whet/stones/Server.js +0 -261
@@ -23,12 +23,37 @@ class BaseCache extends Register.inherits() {
23
23
  get(stone, durability, check) {
24
24
  let _gthis = this;
25
25
  return stone.acquire(function () {
26
- return stone.finalMaybeHash().then(function (hash) {
26
+ let lockHeldSpan = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
27
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Hash", function () {
28
+ return stone.finalMaybeHash().then(function (hash) {
29
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
30
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
31
+ if (span != null) {
32
+ span.metadata = {"hashHex": meta};
33
+ };
34
+ return hash;
35
+ });
36
+ }, null) : stone.finalMaybeHash().then(function (hash) {
37
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
38
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
39
+ if (span != null) {
40
+ span.metadata = {"hashHex": meta};
41
+ };
42
+ return hash;
43
+ })).then(function (hash) {
27
44
  if (hash == null) {
28
45
  Log.log(20, ...["Generating source, because it does not supply a hash.", {"stone": stone, "cache": _gthis}]);
29
46
  };
30
47
  if (hash == null) {
31
- return stone.generateSource(null).then(function (generatedSource) {
48
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Generate", function () {
49
+ return stone.generateSource(null).then(function (src) {
50
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
51
+ return src;
52
+ });
53
+ }, null) : stone.generateSource(null).then(function (src) {
54
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
55
+ return src;
56
+ })).then(function (generatedSource) {
32
57
  return {"generatedSource": generatedSource, "hash": generatedSource.hash};
33
58
  });
34
59
  } else {
@@ -66,6 +91,9 @@ class BaseCache extends Register.inherits() {
66
91
  let srcPromise = ((value != null) ? _gthis.source(stone, value) : Promise.resolve(null)).then(function (src) {
67
92
  if (src == null) {
68
93
  Log.log(10, ...["Not cached.", {"stone": stone, "cache": _gthis}]);
94
+ if (lockHeldSpan != null) {
95
+ lockHeldSpan.metadata = {"cacheResult": "miss"};
96
+ };
69
97
  return ((value != null) ? _gthis.remove(stone, value) : Promise.resolve(null)).then(function (_) {
70
98
  if (check._hx_index == 1) {
71
99
  _gthis.checkDurability(stone, values, durability, function (v) {
@@ -74,19 +102,39 @@ class BaseCache extends Register.inherits() {
74
102
  return ageCount(v) + 1;
75
103
  });
76
104
  };
77
- return ((generatedSource != null) ? Promise.resolve(generatedSource) : stone.generateSource(hash)).then(function (src) {
78
- return _gthis.set(src);
105
+ return ((generatedSource != null) ? Promise.resolve(generatedSource) : (stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Generate", function () {
106
+ return stone.generateSource(hash).then(function (src) {
107
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
108
+ return src;
109
+ });
110
+ }, null) : stone.generateSource(hash).then(function (src) {
111
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
112
+ return src;
113
+ })).then(function (src) {
114
+ if (stone.project.profiler != null) {
115
+ return stone.project.profiler.withSpan(stone, "CacheWrite", function () {
116
+ return _gthis.set(src);
117
+ }, null);
118
+ } else {
119
+ return _gthis.set(src);
120
+ };
79
121
  }).then(function (val) {
80
122
  return _gthis.source(stone, val);
81
123
  });
82
124
  });
83
125
  } else if (!src.complete) {
84
126
  Log.log(10, ...["Found partial entry in cache, completing.", {"stone": stone, "cache": _gthis}]);
127
+ if (lockHeldSpan != null) {
128
+ lockHeldSpan.metadata = {"cacheResult": "partial"};
129
+ };
85
130
  return _gthis.completePartialEntry(stone, value, hash).then(function (val) {
86
131
  return _gthis.source(stone, val);
87
132
  });
88
133
  } else {
89
134
  Log.log(10, ...["Found in cache", {"stone": stone, "cache": _gthis}]);
135
+ if (lockHeldSpan != null) {
136
+ lockHeldSpan.metadata = {"cacheResult": "hit"};
137
+ };
90
138
  return Promise.resolve(src);
91
139
  };
92
140
  });
@@ -104,7 +152,23 @@ class BaseCache extends Register.inherits() {
104
152
  getPartial(stone, sourceId, durability, check) {
105
153
  let _gthis = this;
106
154
  return stone.acquire(function () {
107
- return stone.finalMaybeHash().then(function (hash) {
155
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Hash", function () {
156
+ return stone.finalMaybeHash().then(function (hash) {
157
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
158
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
159
+ if (span != null) {
160
+ span.metadata = {"hashHex": meta};
161
+ };
162
+ return hash;
163
+ });
164
+ }, null) : stone.finalMaybeHash().then(function (hash) {
165
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
166
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
167
+ if (span != null) {
168
+ span.metadata = {"hashHex": meta};
169
+ };
170
+ return hash;
171
+ })).then(function (hash) {
108
172
  let values = _gthis.cache.get(_gthis.key(stone));
109
173
  let value = null;
110
174
  if (values != null && values.length > 0) {
@@ -126,7 +190,9 @@ class BaseCache extends Register.inherits() {
126
190
  } else if (value != null && value.complete) {
127
191
  return Promise.resolve(null);
128
192
  } else {
129
- return stone.generatePartialSource(sourceId, hash).then(function (result) {
193
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "GeneratePartial", function () {
194
+ return stone.generatePartialSource(sourceId, hash);
195
+ }, {"sourceId": sourceId}) : stone.generatePartialSource(sourceId, hash)).then(function (result) {
130
196
  if (result.complete) {
131
197
  return ((value != null) ? _gthis.replaceEntry(stone, value, result.source) : _gthis.set(result.source)).then(function (_) {
132
198
  return result.source.filterTo(sourceId);
@@ -193,7 +259,21 @@ class BaseCache extends Register.inherits() {
193
259
  */
194
260
  completePartialEntry(stone, existing, hash) {
195
261
  let _gthis = this;
196
- return stone.list().then(function (allIds) {
262
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "List", function () {
263
+ return stone.list().then(function (ids) {
264
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
265
+ if (span != null) {
266
+ span.metadata = {"resultCount": (ids != null) ? ids.length : null};
267
+ };
268
+ return ids;
269
+ });
270
+ }, null) : stone.list().then(function (ids) {
271
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
272
+ if (span != null) {
273
+ span.metadata = {"resultCount": (ids != null) ? ids.length : null};
274
+ };
275
+ return ids;
276
+ })).then(function (allIds) {
197
277
  if (allIds != null) {
198
278
  let _g = [];
199
279
  let _g1 = 0;
@@ -281,10 +361,26 @@ class BaseCache extends Register.inherits() {
281
361
  HxOverrides.remove(this.cache.get(this.key(stone)), value);
282
362
  return Promise.resolve(null);
283
363
  }
364
+
365
+ /**
366
+ Remove all cached entries for a stone.
367
+ */
368
+ clearStone(stone) {
369
+ this.cache.remove(this.key(stone));
370
+ }
284
371
  toString() {
285
372
  let c = Boot.getClass(this);
286
373
  return c.__name__;
287
374
  }
375
+ static setGenerateMeta(span, src) {
376
+ if (span != null) {
377
+ let totalBytes = 0;
378
+ let _g = 0;
379
+ let _g1 = src.data;
380
+ while (_g < _g1.length) totalBytes += _g1[_g++].data.length;
381
+ span.metadata = {"outputCount": src.data.length, "totalBytes": totalBytes};
382
+ };
383
+ }
288
384
  static get __name__() {
289
385
  return "whet.cache.BaseCache"
290
386
  }
@@ -31,5 +31,10 @@ export declare class CacheManager {
31
31
  * The path is not reserved. Caching depends on stone's `cacheStrategy` and success of source generation.
32
32
  */
33
33
  getDir(stone: AnyStone, hash?: null | SourceHash): string
34
+
35
+ /**
36
+ Remove all cached entries for a stone. Opt-in – not called automatically by Project.removeStone.
37
+ */
38
+ clearStone(stone: AnyStone): void
34
39
  close(): Promise<void>
35
40
  }
@@ -1,7 +1,9 @@
1
1
  import {MemoryCache} from "./MemoryCache.js"
2
2
  import {FileCache} from "./FileCache.js"
3
3
  import {CacheStrategy, CacheDurability, DurabilityCheck} from "./Cache.js"
4
+ import {BaseCache} from "./BaseCache.js"
4
5
  import {RootDir} from "../SourceId.js"
6
+ import {SourceHash} from "../SourceHash.js"
5
7
  import {Log} from "../Log.js"
6
8
  import * as Path from "path"
7
9
  import {Register} from "../../genes/Register.js"
@@ -26,8 +28,36 @@ class CacheManager extends Register.inherits() {
26
28
  switch (_g._hx_index) {
27
29
  case 0:
28
30
  return stone.acquire(function () {
29
- return stone.finalMaybeHash().then(function (hash) {
30
- return stone.generateSource(hash);
31
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Hash", function () {
32
+ return stone.finalMaybeHash().then(function (hash) {
33
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
34
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
35
+ if (span != null) {
36
+ span.metadata = {"hashHex": meta};
37
+ };
38
+ return hash;
39
+ });
40
+ }, null) : stone.finalMaybeHash().then(function (hash) {
41
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
42
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
43
+ if (span != null) {
44
+ span.metadata = {"hashHex": meta};
45
+ };
46
+ return hash;
47
+ })).then(function (hash) {
48
+ if (stone.project.profiler != null) {
49
+ return stone.project.profiler.withSpan(stone, "Generate", function () {
50
+ return stone.generateSource(hash).then(function (src) {
51
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
52
+ return src;
53
+ });
54
+ }, null);
55
+ } else {
56
+ return stone.generateSource(hash).then(function (src) {
57
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
58
+ return src;
59
+ });
60
+ };
31
61
  });
32
62
  });
33
63
  break
@@ -51,10 +81,34 @@ class CacheManager extends Register.inherits() {
51
81
  switch (_g._hx_index) {
52
82
  case 0:
53
83
  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);
84
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Hash", function () {
85
+ return stone.finalMaybeHash().then(function (hash) {
86
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
87
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
88
+ if (span != null) {
89
+ span.metadata = {"hashHex": meta};
90
+ };
91
+ return hash;
57
92
  });
93
+ }, null) : stone.finalMaybeHash().then(function (hash) {
94
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
95
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
96
+ if (span != null) {
97
+ span.metadata = {"hashHex": meta};
98
+ };
99
+ return hash;
100
+ })).then(function (hash) {
101
+ if (stone.project.profiler != null) {
102
+ return stone.project.profiler.withSpan(stone, "GeneratePartial", function () {
103
+ return stone.generatePartialSource(sourceId, hash).then(function (r) {
104
+ return r.source.filterTo(sourceId);
105
+ });
106
+ }, {"sourceId": sourceId});
107
+ } else {
108
+ return stone.generatePartialSource(sourceId, hash).then(function (r) {
109
+ return r.source.filterTo(sourceId);
110
+ });
111
+ };
58
112
  });
59
113
  });
60
114
  break
@@ -82,8 +136,36 @@ class CacheManager extends Register.inherits() {
82
136
  switch (stone.cacheStrategy._hx_index) {
83
137
  case 0:
84
138
  return stone.acquire(function () {
85
- return stone.finalMaybeHash().then(function (hash) {
86
- return stone.generateSource(hash);
139
+ return ((stone.project.profiler != null) ? stone.project.profiler.withSpan(stone, "Hash", function () {
140
+ return stone.finalMaybeHash().then(function (hash) {
141
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
142
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
143
+ if (span != null) {
144
+ span.metadata = {"hashHex": meta};
145
+ };
146
+ return hash;
147
+ });
148
+ }, null) : stone.finalMaybeHash().then(function (hash) {
149
+ let span = (stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null;
150
+ let meta = (hash != null) ? SourceHash.toHex(hash) : null;
151
+ if (span != null) {
152
+ span.metadata = {"hashHex": meta};
153
+ };
154
+ return hash;
155
+ })).then(function (hash) {
156
+ if (stone.project.profiler != null) {
157
+ return stone.project.profiler.withSpan(stone, "Generate", function () {
158
+ return stone.generateSource(hash).then(function (src) {
159
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
160
+ return src;
161
+ });
162
+ }, null);
163
+ } else {
164
+ return stone.generateSource(hash).then(function (src) {
165
+ BaseCache.setGenerateMeta((stone.project.profiler != null) ? stone.project.profiler.getCurrentSpan() : null, src);
166
+ return src;
167
+ });
168
+ };
87
169
  });
88
170
  });
89
171
  break
@@ -151,6 +233,14 @@ class CacheManager extends Register.inherits() {
151
233
  };
152
234
  return id;
153
235
  }
236
+
237
+ /**
238
+ Remove all cached entries for a stone. Opt-in – not called automatically by Project.removeStone.
239
+ */
240
+ clearStone(stone) {
241
+ this.memCache.clearStone(stone);
242
+ this.fileCache.clearStone(stone);
243
+ }
154
244
  close() {
155
245
  return this.fileCache.close();
156
246
  }
@@ -15,6 +15,7 @@ export declare class FileCache extends BaseCache<string, RuntimeFileCacheValue>
15
15
  protected set(source: Source): Promise<RuntimeFileCacheValue>
16
16
  protected getExistingDirs(stone: AnyStone): string[]
17
17
  protected remove(stone: AnyStone, value: RuntimeFileCacheValue): Promise<any>
18
+ clearStone(stone: AnyStone): void
18
19
  protected setRecentUseOrder(values: RuntimeFileCacheValue[], value: RuntimeFileCacheValue): boolean
19
20
  protected getDirFor(value: RuntimeFileCacheValue): string
20
21
  protected hasSourceId(value: RuntimeFileCacheValue, sourceId: string): boolean
@@ -220,6 +220,10 @@ class FileCache extends Register.inherits(() => BaseCache, true) {
220
220
  });
221
221
  });
222
222
  }
223
+ clearStone(stone) {
224
+ super.clearStone(stone);
225
+ this.flush();
226
+ }
223
227
  setRecentUseOrder(values, value) {
224
228
  let changed = super.setRecentUseOrder(values, value);
225
229
  if (changed) {
@@ -0,0 +1,17 @@
1
+ import {AnyStone} from "../Stone"
2
+ import {SourceHash} from "../SourceHash"
3
+ import {Source} from "../Source"
4
+ import {AsyncLocalStorage} from "node:async_hooks"
5
+
6
+ export declare class MemoContext {
7
+ constructor()
8
+ protected sources: Map<AnyStone, Promise<Source>>
9
+ protected hashes: Map<AnyStone, Promise<SourceHash>>
10
+ protected partials: Map<AnyStone, Map<string, Promise<null | Source>>>
11
+ protected static als: AsyncLocalStorage<MemoContext>
12
+
13
+ /**
14
+ Execute fn within a MemoContext. Reuses existing context or creates a new one.
15
+ */
16
+ static ensure<T>(fn: (() => T)): T
17
+ }
@@ -0,0 +1,35 @@
1
+ import {AsyncLocalStorage} from "node:async_hooks"
2
+ import {Register} from "../../genes/Register.js"
3
+
4
+ const $global = Register.$global
5
+
6
+ export const MemoContext = Register.global("$hxClasses")["whet.cache.MemoContext"] =
7
+ class MemoContext extends Register.inherits() {
8
+ [Register.new]() {
9
+ this.partials = new Map();
10
+ this.hashes = new Map();
11
+ this.sources = new Map();
12
+ }
13
+
14
+ /**
15
+ Execute fn within a MemoContext. Reuses existing context or creates a new one.
16
+ */
17
+ static ensure(fn) {
18
+ if (MemoContext.als.getStore() != null) {
19
+ return fn();
20
+ };
21
+ return MemoContext.als.run(new MemoContext(), fn);
22
+ }
23
+ static get __name__() {
24
+ return "whet.cache.MemoContext"
25
+ }
26
+ get __class__() {
27
+ return MemoContext
28
+ }
29
+ }
30
+ MemoContext.prototype.sources = null;
31
+ MemoContext.prototype.hashes = null;
32
+ MemoContext.prototype.partials = null;
33
+
34
+
35
+ MemoContext.als = new AsyncLocalStorage()
@@ -11,7 +11,7 @@ export const RoutePathType_Fields_ = Register.global("$hxClasses")["whet.magic._
11
11
  class RoutePathType_Fields_ {
12
12
  static makeRoutePath(routerPathType) {
13
13
  if (((routerPathType) instanceof Router) || ((routerPathType) instanceof Stone) || typeof(routerPathType) == "string") {
14
- return [{"routeUnder": "", "source": (typeof(routerPathType) == "string") ? new Files({"paths": [routerPathType]}) : routerPathType, "filter": null, "extractDirs": null}];
14
+ return [{"routeUnder": "", "source": (typeof(routerPathType) == "string") ? Files.fromPath(routerPathType) : routerPathType, "filter": null, "extractDirs": null}];
15
15
  };
16
16
  if (!((routerPathType) instanceof Array)) {
17
17
  throw new Error("RoutePath should be a Stone, Router, or an array.");
@@ -23,7 +23,7 @@ class RoutePathType_Fields_ {
23
23
  let item = _g2[_g1];
24
24
  ++_g1;
25
25
  if (((item) instanceof Router) || ((item) instanceof Stone) || typeof(item) == "string") {
26
- _g.push({"routeUnder": "", "source": (typeof(item) == "string") ? new Files({"paths": [item]}) : item, "filter": null, "extractDirs": null});
26
+ _g.push({"routeUnder": "", "source": (typeof(item) == "string") ? Files.fromPath(item) : item, "filter": null, "extractDirs": null});
27
27
  } else if (((item) instanceof Array)) {
28
28
  let inner = item;
29
29
  if (typeof(inner[0]) != "string") {
@@ -36,12 +36,12 @@ class RoutePathType_Fields_ {
36
36
  switch (inner.length) {
37
37
  case 2:
38
38
  let src = inner[1];
39
- let tmp1 = (typeof(src) == "string") ? new Files({"paths": [src]}) : src;
39
+ let tmp1 = (typeof(src) == "string") ? Files.fromPath(src) : src;
40
40
  tmp = {"routeUnder": inner[0], "source": tmp1, "filter": null, "extractDirs": null};
41
41
  break
42
42
  case 3:
43
43
  let src1 = inner[1];
44
- let tmp2 = (typeof(src1) == "string") ? new Files({"paths": [src1]}) : src1;
44
+ let tmp2 = (typeof(src1) == "string") ? Files.fromPath(src1) : src1;
45
45
  if (!(typeof(inner[2]) == "string" || inner[2] instanceof Minimatch)) {
46
46
  throw new Error("Third" + " element of RoutePath array should be a glob pattern (string or `minimatch` object)");
47
47
  };
@@ -50,7 +50,7 @@ class RoutePathType_Fields_ {
50
50
  break
51
51
  case 4:
52
52
  let src2 = inner[1];
53
- let tmp4 = (typeof(src2) == "string") ? new Files({"paths": [src2]}) : src2;
53
+ let tmp4 = (typeof(src2) == "string") ? Files.fromPath(src2) : src2;
54
54
  if (!(typeof(inner[2]) == "string" || inner[2] instanceof Minimatch)) {
55
55
  throw new Error("Third" + " element of RoutePath array should be a glob pattern (string or `minimatch` object)");
56
56
  };
@@ -0,0 +1,65 @@
1
+ import {SpanStats} from "./SpanStats"
2
+ import {SpanRecorder} from "./SpanRecorder"
3
+ import {SpanEvent, AnySpan, SpanEventType} from "./Span"
4
+ import {AnyStone} from "../Stone"
5
+ import {AsyncLocalStorage} from "node:async_hooks"
6
+
7
+ export declare class Profiler {
8
+ constructor(config?: null | ProfilerConfig)
9
+ recorder: SpanRecorder
10
+ stats: SpanStats
11
+ protected listeners: ((arg0: SpanEvent) => void)[]
12
+ protected context: AsyncLocalStorage<AnySpan>
13
+ protected baseEpochUs: number
14
+ protected basePerfUs: number
15
+ protected nextSpanId: number
16
+
17
+ /**
18
+ Primary API: wraps an async operation with timing and ALS context.
19
+ */
20
+ withSpan<T, R>(stone: AnyStone, op: string, fn: (() => Promise<R>), meta?: null | T): Promise<R>
21
+
22
+ /**
23
+ Secondary API: manual start for spans where no function can be wrapped (e.g. LockWait).
24
+ */
25
+ startSpan<T>(stone: AnyStone, op: string, meta?: null | T): AnySpan
26
+
27
+ /**
28
+ Complete a manually started span.
29
+ */
30
+ endSpan(span: AnySpan): void
31
+
32
+ /**
33
+ Returns the current span from AsyncLocalStorage context, or null if none.
34
+ */
35
+ getCurrentSpan(): null | AnySpan
36
+
37
+ /**
38
+ Subscribe to span events. Returns unsubscribe function.
39
+ */
40
+ subscribe(listener: ((arg0: SpanEvent) => void)): (() => void)
41
+
42
+ /**
43
+ Export spans in the given format ("json" or "trace"). Defaults to "json".
44
+ */
45
+ export(format: string): any
46
+
47
+ /**
48
+ Return spans recorded since the given span ID (exclusive).
49
+ */
50
+ getSpansSince(sinceId: number): AnySpan[]
51
+
52
+ /**
53
+ Return aggregated profiling summary.
54
+ */
55
+ getSummary(): any
56
+ protected exportJson(): any
57
+ protected exportChromeTrace(): any
58
+ protected serializeSpan(span: AnySpan): any
59
+ protected emit(type: SpanEventType, span: AnySpan): void
60
+ protected static ensureStoneEntry(byStone: {[key: string]: any}, stone: string): void
61
+ }
62
+
63
+ export type ProfilerConfig = {
64
+ maxSpans?: null | number
65
+ }