vitest-pool-assemblyscript 0.9.1 → 0.10.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 (100) hide show
  1. package/assembly/compare.ts +11 -12
  2. package/assembly/describe.ts +4 -4
  3. package/assembly/expect.ts +44 -26
  4. package/assembly/test.ts +9 -9
  5. package/assembly/utils.ts +218 -62
  6. package/dist/{addon-interface-CYFXMbK7.mjs → addon-interface-DJB-K27u.mjs} +12 -12
  7. package/dist/addon-interface-DJB-K27u.mjs.map +1 -0
  8. package/dist/{ast-visitor-CWEOd3UH.mjs → ast-visitor-w1HMbuJR.mjs} +2 -2
  9. package/dist/{ast-visitor-CWEOd3UH.mjs.map → ast-visitor-w1HMbuJR.mjs.map} +1 -1
  10. package/dist/compile-runner-D4SJWhMh.mjs +82 -0
  11. package/dist/compile-runner-D4SJWhMh.mjs.map +1 -0
  12. package/dist/compiler/transforms/deep-equals.d.mts.map +1 -1
  13. package/dist/compiler/transforms/deep-equals.mjs +61 -22
  14. package/dist/compiler/transforms/deep-equals.mjs.map +1 -1
  15. package/dist/compiler/transforms/strip-inline.mjs +2 -2
  16. package/dist/{compiler-Dqs-qd3I.mjs → compiler-DSKhQ5--.mjs} +55 -27
  17. package/dist/compiler-DSKhQ5--.mjs.map +1 -0
  18. package/dist/config/index-v3.d.mts +1 -1
  19. package/dist/config/index-v3.d.mts.map +1 -1
  20. package/dist/config/index-v3.mjs.map +1 -1
  21. package/dist/config/index.d.mts +2 -2
  22. package/dist/config/index.mjs +5 -7
  23. package/dist/{constants-DbxJ3hzg.mjs → constants-Bq5KNxXJ.mjs} +4 -2
  24. package/dist/constants-Bq5KNxXJ.mjs.map +1 -0
  25. package/dist/{coverage-merge-CBXkpM1O.mjs → coverage-merge-0WqdC-dq.mjs} +1 -1
  26. package/dist/{coverage-merge-CBXkpM1O.mjs.map → coverage-merge-0WqdC-dq.mjs.map} +1 -1
  27. package/dist/coverage-provider/index.mjs +36 -36
  28. package/dist/coverage-provider/index.mjs.map +1 -1
  29. package/dist/{feature-check-Bje3ntpV.mjs → feature-check-DLfJqIrE.mjs} +4 -4
  30. package/dist/{feature-check-Bje3ntpV.mjs.map → feature-check-DLfJqIrE.mjs.map} +1 -1
  31. package/dist/index-internal.d.mts +3 -3
  32. package/dist/index-internal.d.mts.map +1 -1
  33. package/dist/index-internal.mjs +5 -4
  34. package/dist/index-v3.d.mts.map +1 -1
  35. package/dist/index-v3.mjs +19 -33
  36. package/dist/index-v3.mjs.map +1 -1
  37. package/dist/index.d.mts +1 -1
  38. package/dist/index.mjs +5 -7
  39. package/dist/{load-user-imports-Bx5ZlhSm.mjs → load-user-imports-6Pv-9hRg.mjs} +103 -229
  40. package/dist/load-user-imports-6Pv-9hRg.mjs.map +1 -0
  41. package/dist/pool-errors-GWfwrsD7.mjs +631 -0
  42. package/dist/pool-errors-GWfwrsD7.mjs.map +1 -0
  43. package/dist/{pool-runner-init-CNpRdA5u.d.mts → pool-runner-init-CCvnKt5o.d.mts} +2 -2
  44. package/dist/pool-runner-init-CCvnKt5o.d.mts.map +1 -0
  45. package/dist/{pool-runner-init-BqkwQ2tk.mjs → pool-runner-init-Cta6aVJ6.mjs} +15 -30
  46. package/dist/pool-runner-init-Cta6aVJ6.mjs.map +1 -0
  47. package/dist/pool-thread/compile-worker-thread.d.mts +1 -1
  48. package/dist/pool-thread/compile-worker-thread.d.mts.map +1 -1
  49. package/dist/pool-thread/compile-worker-thread.mjs +29 -19
  50. package/dist/pool-thread/compile-worker-thread.mjs.map +1 -1
  51. package/dist/pool-thread/test-worker-thread.d.mts +1 -1
  52. package/dist/pool-thread/test-worker-thread.d.mts.map +1 -1
  53. package/dist/pool-thread/test-worker-thread.mjs +25 -18
  54. package/dist/pool-thread/test-worker-thread.mjs.map +1 -1
  55. package/dist/pool-thread/v3-tinypool-thread.d.mts +1 -1
  56. package/dist/pool-thread/v3-tinypool-thread.d.mts.map +1 -1
  57. package/dist/pool-thread/v3-tinypool-thread.mjs +43 -33
  58. package/dist/pool-thread/v3-tinypool-thread.mjs.map +1 -1
  59. package/dist/test-runner-M21HMDdH.mjs +147 -0
  60. package/dist/test-runner-M21HMDdH.mjs.map +1 -0
  61. package/dist/{types-DHVk5iAx.d.mts → types-CoroKYxB.d.mts} +39 -16
  62. package/dist/types-CoroKYxB.d.mts.map +1 -0
  63. package/dist/vitest-file-tasks-Coc4btUw.mjs +473 -0
  64. package/dist/vitest-file-tasks-Coc4btUw.mjs.map +1 -0
  65. package/dist/wasm-memory-C8Nkl2Sz.mjs +134 -0
  66. package/dist/wasm-memory-C8Nkl2Sz.mjs.map +1 -0
  67. package/dist/{worker-rpc-channel-CZZIxtv5.mjs → worker-rpc-channel-CvCrc8aa.mjs} +1 -1
  68. package/dist/{worker-rpc-channel-CZZIxtv5.mjs.map → worker-rpc-channel-CvCrc8aa.mjs.map} +1 -1
  69. package/package.json +1 -1
  70. package/prebuilds/darwin-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  71. package/prebuilds/darwin-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  72. package/prebuilds/linux-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  73. package/prebuilds/linux-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  74. package/prebuilds/linux-x64/vitest-pool-assemblyscript.musl.node +0 -0
  75. package/prebuilds/win32-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  76. package/prebuilds/win32-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  77. package/src/instrumentation/native/addon.cpp +71 -32
  78. package/dist/addon-interface-CYFXMbK7.mjs.map +0 -1
  79. package/dist/compile-runner-BNFHRGZO.mjs +0 -85
  80. package/dist/compile-runner-BNFHRGZO.mjs.map +0 -1
  81. package/dist/compiler-Dqs-qd3I.mjs.map +0 -1
  82. package/dist/constants-DbxJ3hzg.mjs.map +0 -1
  83. package/dist/debug-DtRAL4rM.mjs +0 -232
  84. package/dist/debug-DtRAL4rM.mjs.map +0 -1
  85. package/dist/load-user-imports-Bx5ZlhSm.mjs.map +0 -1
  86. package/dist/path-utils-t9OzjXYF.mjs +0 -24
  87. package/dist/path-utils-t9OzjXYF.mjs.map +0 -1
  88. package/dist/pool-runner-init-BqkwQ2tk.mjs.map +0 -1
  89. package/dist/pool-runner-init-CNpRdA5u.d.mts.map +0 -1
  90. package/dist/resolve-config-s9gSJSMc.mjs +0 -85
  91. package/dist/resolve-config-s9gSJSMc.mjs.map +0 -1
  92. package/dist/test-runner-BGqc9uCK.mjs +0 -138
  93. package/dist/test-runner-BGqc9uCK.mjs.map +0 -1
  94. package/dist/types-DHVk5iAx.d.mts.map +0 -1
  95. package/dist/vitest-file-tasks-D8sOClGX.mjs +0 -149
  96. package/dist/vitest-file-tasks-D8sOClGX.mjs.map +0 -1
  97. package/dist/vitest-tasks-BZ24sghI.mjs +0 -321
  98. package/dist/vitest-tasks-BZ24sghI.mjs.map +0 -1
  99. package/dist/wasm-names-BFtzQCH4.mjs +0 -124
  100. package/dist/wasm-names-BFtzQCH4.mjs.map +0 -1
package/assembly/utils.ts CHANGED
@@ -25,6 +25,42 @@ export function nan<T>(value: T): bool {
25
25
  }
26
26
  }
27
27
 
28
+ /**
29
+ * Encodes a string as a quoted diff-form literal, matching pretty-format's
30
+ * `escapeString: true` behavior (vitest's diff display default)
31
+ */
32
+ export function escapeToDiffString(value: string): string {
33
+ // Only `"` and `\` are escaped - All other characters (control chars, surrogates, etc)
34
+ // pass through raw so vitest's diff can break on newlines naturally
35
+ let firstEscape = -1;
36
+ for (let i = 0; i < value.length; i++) {
37
+ const c = value.charCodeAt(i);
38
+ if (c === 0x22 || c === 0x5C) {
39
+ firstEscape = i;
40
+ break;
41
+ }
42
+ }
43
+ // Fast path: no escapes needed
44
+ if (firstEscape === -1) return `"${value}"`;
45
+
46
+ // Array<string> + join("") avoids O(n^2) concatenation on the slow path
47
+ const parts = new Array<string>();
48
+ parts.push("\"");
49
+ parts.push(value.substring(0, firstEscape));
50
+ for (let i = firstEscape; i < value.length; i++) {
51
+ const code = value.charCodeAt(i);
52
+ if (code === 0x22) {
53
+ parts.push("\\\"");
54
+ } else if (code === 0x5C) {
55
+ parts.push("\\\\");
56
+ } else {
57
+ parts.push(value.charAt(i));
58
+ }
59
+ }
60
+ parts.push("\"");
61
+ return parts.join("");
62
+ }
63
+
28
64
  /**
29
65
  * Cycle detection for stringification. Tracks which object pointers are currently
30
66
  * being stringified to prevent infinite recursion on self-referential objects.
@@ -36,17 +72,64 @@ export function nan<T>(value: T): bool {
36
72
  */
37
73
  const stringifyVisited = new Set<usize>();
38
74
 
75
+ // @ts-ignore: top level decorators are supported in AssemblyScript
76
+ @inline
77
+ function stringifyIndent(depth: i32): string {
78
+ if (depth <= 0) return "";
79
+ let s = "";
80
+ for (let i = 0; i < depth; i++) s += " ";
81
+ return s;
82
+ }
83
+
84
+ /** Character budget for short-form (single-line) stringification */
85
+ export const STRINGIFY_SHORT_FORM_BUDGET: i32 = 40;
86
+
87
+ /**
88
+ * Returns true when the next piece + separator + truncation marker would push
89
+ * accumulated content past `budget` (`budget < 0` is the unlimited sentinel for diff mode)
90
+ */
91
+ // @ts-ignore: top level decorators are supported in AssemblyScript
92
+ @inline
93
+ function exceedsBudget(used: i32, pieceLen: i32, sepLen: i32, truncMarkerLen: i32, budget: i32): bool {
94
+ return budget >= 0 && used + pieceLen + sepLen + truncMarkerLen > budget;
95
+ }
96
+
97
+ /**
98
+ * Renders a string as a short-form literal `"<s>"` constrained by `budget`,
99
+ * producing `"<sliced>…"` when the full literal would overflow
100
+ * (`budget < 0` is the unlimited sentinel for diff mode)
101
+ */
102
+ function truncateStringContent(s: string, budget: i32): string {
103
+ if (budget < 0 || 2 + s.length <= budget) {
104
+ return `"${s}"`;
105
+ }
106
+ // Output scaffolding is opening quote + ellipsis + closing quote = 3 chars, always
107
+ // emitted even when budget < 3 so the user still sees an identifiable string token
108
+ let sliceLen = budget - 3;
109
+ if (sliceLen < 0) sliceLen = 0;
110
+ if (sliceLen > 0) {
111
+ const code = s.charCodeAt(sliceLen - 1);
112
+ // Don't leave a lone high surrogate from a surrogate pair
113
+ if (code >= 0xD800 && code <= 0xDBFF) {
114
+ sliceLen -= 1;
115
+ }
116
+ }
117
+ return `"${s.substring(0, sliceLen)}…"`;
118
+ }
119
+
39
120
  /**
40
121
  * Produces a human-readable string representation of a value for assertion messages.
41
122
  * Handles primitives, strings, arrays, Sets, Maps, ArrayBuffers, and user-defined objects.
42
123
  * Used by matchers to format actual/expected values in error output and diffs.
43
124
  */
44
- export function stringifyValue<T>(item: T): string {
125
+ export function stringifyValue<T>(item: T, formatForDiff: bool = true, depth: i32 = 0, budget: i32 = -1): string {
45
126
  if (isNull(item)) return "null";
46
127
  if (nan(item)) return "NaN";
47
128
 
48
129
  if (isReference<T>()) {
49
- if (isString<T>()) return `"${item}"`;
130
+ if (isString<T>()) {
131
+ return formatForDiff ? escapeToDiffString(<string>item) : truncateStringContent(<string>item, budget);
132
+ }
50
133
 
51
134
  // Cycle detection for all non-string reference types before recursive stringification
52
135
  const ptr = changetype<usize>(item);
@@ -57,24 +140,33 @@ export function stringifyValue<T>(item: T): string {
57
140
  if (item instanceof ArrayBuffer) {
58
141
  result = `ArrayBuffer[${item.byteLength}]`;
59
142
  } else if (isArrayLike<T>(item)) {
60
- result = arrayMessageString(item);
143
+ result = arrayMessageString(item, formatForDiff, depth, budget);
61
144
  } else if (item instanceof Set) {
62
- result = setMessageString(item);
145
+ result = setMessageString(item, formatForDiff, depth, budget);
63
146
  } else if (item instanceof Map) {
64
- result = mapMessageString(item);
65
- // @ts-ignore: __vitest_assemblyscript_typename is injected by the compiler transform
147
+ result = mapMessageString(item, formatForDiff, depth, budget);
148
+ // @ts-ignore
66
149
  } else if (isDefined(item.__vitest_assemblyscript_typename)) {
67
150
  // Cast to NonNullable<T> because AS doesn't narrow nullability from the earlier
68
151
  // null check — it requires explicit type narrowing to call methods on nullable types.
69
152
  // Safe because null case returns "null" at the top of this function.
70
153
  const nonNullItem = <NonNullable<T>>item;
154
+ const spaceAfterType = formatForDiff ? " " : "";
155
+ const nl = formatForDiff ? "\n" : " ";
156
+ // Close brace sits at this value's depth (one less than its inner content)
157
+ const closeIndent = formatForDiff ? stringifyIndent(depth) : "";
158
+
71
159
  // @ts-ignore
72
160
  const typeName: string = nonNullItem.__vitest_assemblyscript_typename();
73
161
  // @ts-ignore
74
162
  if (isDefined(nonNullItem.__vitest_assemblyscript_stringify)) {
163
+ // Reserve scaffolding (`${typeName}{ ` + ` }` = typeName.length + 4) from the budget
164
+ // before passing the remainder to the injected method, which emits only the content.
165
+ // max(0, ...) keeps tight arithmetic from crossing into the `< 0` unlimited sentinel.
166
+ const contentBudget = budget < 0 ? -1 : max(0, budget - typeName.length - 4);
75
167
  // @ts-ignore
76
- const fields: string = nonNullItem.__vitest_assemblyscript_stringify();
77
- result = fields != "" ? typeName + " { " + fields + " }" : typeName;
168
+ const fields: string = nonNullItem.__vitest_assemblyscript_stringify(formatForDiff, depth, contentBudget);
169
+ result = fields === "" ? typeName : `${typeName}${spaceAfterType}{${nl}${fields}${nl}${closeIndent}}`;
78
170
  } else {
79
171
  result = typeName;
80
172
  }
@@ -93,76 +185,140 @@ export function stringifyValue<T>(item: T): string {
93
185
  }
94
186
  }
95
187
 
96
- /**
97
- * Global bridge for the compiler transform's injected stringify methods.
98
- *
99
- * Transform-injected __vitest_assemblyscript_stringify methods call this to format each
100
- * field value. Declared global to make it available in all source files without import,
101
- * solving the afterParse import resolution limitation.
102
- *
103
- * Loaded into the compilation transitively: user test imports
104
- * vitest-pool-assemblyscript/assembly → index.ts → expect.ts → compare.ts → utils.ts.
105
- */
106
- // @ts-ignore: AS-specific global decorator
188
+ // Global bridge functions for the deep-equals transform's injected stringify methods.
189
+ // Declared global to make them available in all user source files without importing.
190
+ // (solves the `afterParse` import resolution limitation where injected import statements
191
+ // are not processed by the AS compiler)
192
+
193
+ // @ts-ignore: top level decorators are supported in AssemblyScript
107
194
  @global
108
- function __vitest_assemblyscript_stringify_value<T>(item: T): string {
109
- return stringifyValue<T>(item);
195
+ function __vitest_assemblyscript_stringify_value<T>(item: T, formatForDiff: bool = true, depth: i32 = 0, budget: i32 = -1): string {
196
+ return stringifyValue<T>(item, formatForDiff, depth, budget);
110
197
  }
111
198
 
112
- function arrayMessageString<T extends ArrayLike<unknown>>(array: T): string {
113
- if (isNullable<T>(array) && array == null) {
114
- return "null";
115
- }
199
+ // @ts-ignore: top level decorators are supported in AssemblyScript
200
+ @global
201
+ function __vitest_assemblyscript_escape_to_diff_string(str: string): string {
202
+ return escapeToDiffString(str);
203
+ }
204
+
205
+ // @ts-ignore: top level decorators are supported in AssemblyScript
206
+ @global @inline
207
+ function __vitest_assemblyscript_stringify_indent(depth: i32): string {
208
+ return stringifyIndent(depth);
209
+ }
210
+
211
+ // @ts-ignore: top level decorators are supported in AssemblyScript
212
+ @global @inline
213
+ function __vitest_assemblyscript_stringify_exceeds_budget(used: i32, pieceLen: i32, sepLen: i32, truncMarkerLen: i32, budget: i32): bool {
214
+ return exceedsBudget(used, pieceLen, sepLen, truncMarkerLen, budget);
215
+ }
216
+
217
+ function arrayMessageString<T extends ArrayLike<unknown>>(array: T, formatForDiff: bool, depth: i32, budget: i32): string {
218
+ if (isNullable<T>(array) && array == null) return "null";
219
+ if (array.length === 0) return "[]";
220
+
221
+ const open = formatForDiff ? "[\n" : "[";
222
+ const childIndent = formatForDiff ? stringifyIndent(depth + 1) : "";
223
+ const sep = formatForDiff ? ",\n" : ", ";
224
+ const close = formatForDiff ? `\n${stringifyIndent(depth)}]` : "]";
116
225
 
117
- let str = "[";
118
- for (let i = 0; i < array.length; i++) {
119
- str += stringifyValue(array[i]);
226
+ // Reserve open/close scaffolding from the budget. max(0, ...) keeps the truncMarker firing
227
+ // even when scaffolding consumed it all, and prevents crossing into the `< 0` sentinel.
228
+ const contentBudget = budget < 0 ? -1 : max(0, budget - open.length - close.length);
120
229
 
121
- if (i < array.length - 1) {
122
- str += ","
230
+ const n = array.length;
231
+ let str = open;
232
+ let used = 0;
233
+ for (let i = 0; i < n; i++) {
234
+ const isLast = i === n - 1;
235
+ const sepLen = isLast ? 0 : sep.length;
236
+ const truncMarker = contentBudget < 0 ? "" : `…(${n - i})`;
237
+ const childBudget = contentBudget < 0 ? -1 : max(0, contentBudget - used - sepLen - truncMarker.length);
238
+ const piece = `${childIndent}${stringifyValue(array[i], formatForDiff, depth + 1, childBudget)}`;
239
+ if (exceedsBudget(used, piece.length, sepLen, truncMarker.length, contentBudget)) {
240
+ str += truncMarker;
241
+ break;
123
242
  }
243
+ str += piece;
244
+ used += piece.length;
245
+ if (!isLast) { str += sep; used += sep.length; }
124
246
  }
125
- str += "]";
126
-
247
+ str += close;
127
248
  return str;
128
249
  }
129
250
 
130
- function setMessageString<T>(set: T): string {
131
- if (isNullable<T>(set) && set == null) {
132
- return "null";
133
- }
251
+ function setMessageString<T>(set: T, formatForDiff: bool, depth: i32, budget: i32): string {
252
+ if (isNullable<T>(set) && set == null) return "null";
253
+ if (!(set instanceof Set)) return nameof<T>(set);
254
+
255
+ const values = set.values();
256
+ if (values.length === 0) return "Set {}";
257
+
258
+ const open = formatForDiff ? "Set {\n" : "Set { ";
259
+ const childIndent = formatForDiff ? stringifyIndent(depth + 1) : "";
260
+ const sep = formatForDiff ? ",\n" : ", ";
261
+ const close = formatForDiff ? `\n${stringifyIndent(depth)}}` : " }";
134
262
 
135
- if (set instanceof Set) {
136
- const values = set.values();
137
- let str = "Set {";
138
- for (let i = 0; i < values.length; i++) {
139
- if (i > 0) str += ",";
140
- str += " " + stringifyValue(values[i]);
263
+ const contentBudget = budget < 0 ? -1 : max(0, budget - open.length - close.length);
264
+
265
+ const n = values.length;
266
+ let str = open;
267
+ let used = 0;
268
+ for (let i = 0; i < n; i++) {
269
+ const isLast = i === n - 1;
270
+ const sepLen = isLast ? 0 : sep.length;
271
+ const truncMarker = contentBudget < 0 ? "" : `…(${n - i})`;
272
+ const childBudget = contentBudget < 0 ? -1 : max(0, contentBudget - used - sepLen - truncMarker.length);
273
+ const piece = `${childIndent}${stringifyValue(values[i], formatForDiff, depth + 1, childBudget)}`;
274
+ if (exceedsBudget(used, piece.length, sepLen, truncMarker.length, contentBudget)) {
275
+ str += truncMarker;
276
+ break;
141
277
  }
142
- if (values.length > 0) str += " ";
143
- str += "}";
144
- return str;
278
+ str += piece;
279
+ used += piece.length;
280
+ if (!isLast) { str += sep; used += sep.length; }
145
281
  }
146
-
147
- return nameof<T>(set);
282
+ str += close;
283
+ return str;
148
284
  }
149
285
 
150
- function mapMessageString<T>(map: T): string {
151
- if (isNullable<T>(map) && map == null) {
152
- return "null";
153
- }
286
+ function mapMessageString<T>(map: T, formatForDiff: bool, depth: i32, budget: i32): string {
287
+ if (isNullable<T>(map) && map == null) return "null";
288
+ if (!(map instanceof Map)) return nameof<T>(map);
289
+
290
+ const keys = map.keys();
291
+ if (keys.length === 0) return "Map {}";
292
+
293
+ const open = formatForDiff ? "Map {\n" : "Map { ";
294
+ const childIndent = formatForDiff ? stringifyIndent(depth + 1) : "";
295
+ const sep = formatForDiff ? ",\n" : ", ";
296
+ const close = formatForDiff ? `\n${stringifyIndent(depth)}}` : " }";
154
297
 
155
- if (map instanceof Map) {
156
- const keys = map.keys();
157
- let str = "Map {";
158
- for (let i = 0; i < keys.length; i++) {
159
- if (i > 0) str += ",";
160
- str += " " + stringifyValue(keys[i]) + " => " + stringifyValue(map.get(keys[i]));
298
+ const contentBudget = budget < 0 ? -1 : max(0, budget - open.length - close.length);
299
+
300
+ const n = keys.length;
301
+ let str = open;
302
+ let used = 0;
303
+ for (let i = 0; i < n; i++) {
304
+ const isLast = i === n - 1;
305
+ const sepLen = isLast ? 0 : sep.length;
306
+ const truncMarker = contentBudget < 0 ? "" : `…(${n - i})`;
307
+ const childBudget = contentBudget < 0 ? -1 : max(0, contentBudget - used - sepLen - truncMarker.length);
308
+ // key gets the full remaining budget; value gets what's left after key + " => " (4 chars)
309
+ // (mirrors loupe lib used by chai/vitest)
310
+ const keyStr = stringifyValue(keys[i], formatForDiff, depth + 1, childBudget);
311
+ const valBudget = childBudget < 0 ? -1 : max(0, childBudget - keyStr.length - 4);
312
+ const valStr = stringifyValue(map.get(keys[i]), formatForDiff, depth + 1, valBudget);
313
+ const piece = `${childIndent}${keyStr} => ${valStr}`;
314
+ if (exceedsBudget(used, piece.length, sepLen, truncMarker.length, contentBudget)) {
315
+ str += truncMarker;
316
+ break;
161
317
  }
162
- if (keys.length > 0) str += " ";
163
- str += "}";
164
- return str;
318
+ str += piece;
319
+ used += piece.length;
320
+ if (!isLast) { str += sep; used += sep.length; }
165
321
  }
166
-
167
- return nameof<T>(map);
322
+ str += close;
323
+ return str;
168
324
  }
@@ -1,7 +1,5 @@
1
- import { INTERNAL_PATH_LIB_PREFIX, POOL_ERROR_NAMES } from "./constants-DbxJ3hzg.mjs";
2
- import { createPoolError, debug } from "./debug-DtRAL4rM.mjs";
3
- import { toForwardSlash } from "./path-utils-t9OzjXYF.mjs";
4
- import { getShortFunctionName } from "./wasm-names-BFtzQCH4.mjs";
1
+ import { INTERNAL_PATH_LIB_PREFIX, POOL_ERROR_NAMES } from "./constants-Bq5KNxXJ.mjs";
2
+ import { createPoolError, debug, getShortFunctionName, toForwardSlash } from "./pool-errors-GWfwrsD7.mjs";
5
3
  import { createRequire } from "node:module";
6
4
  import { dirname, resolve } from "node:path";
7
5
  import { fileURLToPath } from "node:url";
@@ -28,7 +26,7 @@ try {
28
26
  try {
29
27
  addon = nodeGypBuild(rootFromSrc);
30
28
  } catch (err) {
31
- throw createPoolError(`vitest-pool-assemblyscript native instrumentation addon not found. Searched from ${rootFromDist} and ${rootFromSrc}. Ensure prebuilds are available or run 'node node_modules/vitest-pool-assemblyscript/scripts/install-native-addon.js' to compile from source. Original error: ${err instanceof Error ? err.message : String(err)}`, POOL_ERROR_NAMES.WASMInstrumentationError);
29
+ throw createPoolError(POOL_ERROR_NAMES.WASMInstrumentationError, `vitest-pool-assemblyscript native instrumentation addon not found. Searched from ${rootFromDist} and ${rootFromSrc}. Ensure prebuilds are available or run 'node node_modules/vitest-pool-assemblyscript/scripts/install-native-addon.js' to compile from source. Original error:\n${err instanceof Error ? err.message : String(err)}`);
32
30
  }
33
31
  }
34
32
  /**
@@ -44,7 +42,7 @@ try {
44
42
  */
45
43
  function convertLocation(rawLocation, debugSourceFiles, projectRoot) {
46
44
  let filePath = debugSourceFiles[rawLocation.fileIndex];
47
- if (!filePath) throw createPoolError(`No debug source file with index: ${rawLocation.fileIndex}}`, POOL_ERROR_NAMES.WASMInstrumentationError);
45
+ if (!filePath) throw createPoolError(POOL_ERROR_NAMES.WASMInstrumentationError, `No debug source file with index: ${rawLocation.fileIndex}}`);
48
46
  if (filePath.startsWith(INTERNAL_PATH_LIB_PREFIX)) filePath = toForwardSlash(resolve(projectRoot, "assembly", filePath.slice(INTERNAL_PATH_LIB_PREFIX.length)));
49
47
  else filePath = toForwardSlash(resolve(projectRoot, filePath));
50
48
  return {
@@ -142,7 +140,7 @@ function transformDebugInfo(raw, logPrefix, projectRoot) {
142
140
  debug(`${logPrefix} - Generic monomorphization at ${filePath}:${positionKey}: "${getShortFunctionName(func.name)}" grouped with "${getShortFunctionName(existingName)}"`);
143
141
  continue;
144
142
  }
145
- throw createPoolError(`ERROR - Function Debug Position Collision at ${filePath}:${positionKey}: "${getShortFunctionName(existingName)}" will be replaced by "${getShortFunctionName(func.name)}". This is a bug. Please report it at: https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new`, POOL_ERROR_NAMES.WASMInstrumentationError);
143
+ throw createPoolError(POOL_ERROR_NAMES.WASMInstrumentationError, `Function Debug Position Collision at ${filePath}:${positionKey}: "${getShortFunctionName(existingName)}" will be replaced by "${getShortFunctionName(func.name)}". This is a bug. Please report it at: https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new`);
146
144
  }
147
145
  instrumentedFunctionCount++;
148
146
  if (!functionsByFileAndPosition[filePath]) functionsByFileAndPosition[filePath] = {};
@@ -172,8 +170,8 @@ function transformDebugInfo(raw, logPrefix, projectRoot) {
172
170
  * @throws {Error} If WASM binary or source map is invalid
173
171
  */
174
172
  const instrumentForCoverage = (wasmBuffer, sourceMapBuffer, instrumentationOptions, logModule, logLabel) => {
175
- if (!Buffer.isBuffer(wasmBuffer)) throw createPoolError("instrumentForCoverage - wasmBuffer must be a Buffer", POOL_ERROR_NAMES.WASMInstrumentationError);
176
- if (!Buffer.isBuffer(sourceMapBuffer)) throw createPoolError("instrumentForCoverage - sourceMapBuffer must be a Buffer", POOL_ERROR_NAMES.WASMInstrumentationError);
173
+ if (!Buffer.isBuffer(wasmBuffer)) throw createPoolError(POOL_ERROR_NAMES.WASMInstrumentationError, `instrumentForCoverage - wasmBuffer must be a Buffer (got ${typeof wasmBuffer})`);
174
+ if (!Buffer.isBuffer(sourceMapBuffer)) throw createPoolError(POOL_ERROR_NAMES.WASMInstrumentationError, `instrumentForCoverage - sourceMapBuffer must be a Buffer (got ${typeof sourceMapBuffer})`);
177
175
  const interfaceLogPrefix = `[${logModule} Inst] ${logLabel}`;
178
176
  const nativeLogPrefix = `[${logModule} InstNative] ${logLabel}`;
179
177
  debug(`${interfaceLogPrefix} - Calling native instrumentForCoverage`);
@@ -186,12 +184,14 @@ const instrumentForCoverage = (wasmBuffer, sourceMapBuffer, instrumentationOptio
186
184
  excludedLibraryFileOverridePrefix: instrumentationOptions.excludedLibraryFileOverridePrefix,
187
185
  excludedInternalFunctionSubstring: instrumentationOptions.excludedInternalFunctionSubstring,
188
186
  debug: instrumentationOptions.debug,
189
- logPrefix: nativeLogPrefix
187
+ logPrefix: nativeLogPrefix,
188
+ coverageMemoryModule: instrumentationOptions.coverageMemoryModule,
189
+ coverageMemoryName: instrumentationOptions.coverageMemoryName
190
190
  };
191
191
  const nativeResult = addon.instrumentForCoverage(wasmBuffer, sourceMapBuffer, options);
192
192
  const addonTime = performance.now();
193
193
  debug(`${interfaceLogPrefix} - TIMING Native addon: ${(addonTime - startTime).toFixed(2)} ms`);
194
- if (nativeResult.errors?.length) throw createPoolError(`Errors encountered duriing native instrumentation: ${nativeResult.errors.join("\n")}`, POOL_ERROR_NAMES.WASMInstrumentationError);
194
+ if (nativeResult.errors?.length) throw createPoolError(POOL_ERROR_NAMES.WASMInstrumentationError, `Errors encountered duriing native instrumentation: ${nativeResult.errors.join("\n")}`);
195
195
  const debugInfo = transformDebugInfo(nativeResult.debugInfo, interfaceLogPrefix, instrumentationOptions.projectRoot);
196
196
  debug(`${interfaceLogPrefix} - TIMING DebugInfo Transform: ${(performance.now() - addonTime).toFixed(2)} ms`);
197
197
  debug(`${interfaceLogPrefix} - Binary size: ${nativeResult.instrumentedWasm.length} bytes | Source map size: ${nativeResult.sourceMap.length * 2} bytes`);
@@ -204,4 +204,4 @@ const instrumentForCoverage = (wasmBuffer, sourceMapBuffer, instrumentationOptio
204
204
 
205
205
  //#endregion
206
206
  export { instrumentForCoverage };
207
- //# sourceMappingURL=addon-interface-CYFXMbK7.mjs.map
207
+ //# sourceMappingURL=addon-interface-DJB-K27u.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addon-interface-DJB-K27u.mjs","names":[],"sources":["../src/instrumentation/addon-interface.ts"],"sourcesContent":["/**\n * Native addon interface for extracting debug information from WebAssembly binaries\n *\n * This module wraps Binaryen's C++ API to provide expression-level debug locations\n * and basic block information that the JavaScript API doesn't expose.\n *\n * The native addon outputs raw data (0-based columns, relative paths) which this\n * wrapper transforms into the final BinaryDebugInfo format (1-based columns,\n * absolute paths, grouped by file and position).\n */\n\nimport { createRequire } from 'node:module';\nimport { resolve, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type {\n NativeAddon,\n NativeInstrumentationResult,\n NativeDebugInfoOutput,\n NativeFunctionDebugInfo,\n NativeExpressionDebugInfo,\n NativeSourceLocation,\n BinaryDebugInfo,\n FunctionDebugInfo,\n SourceLocation,\n ExpressionDebugInfo,\n InstrumentationResult,\n NativeInstrumentationOptions,\n InstrumentationOptions,\n InstrumentForCoverageFunc,\n} from '../types/types.js';\nimport {\n POOL_ERROR_NAMES,\n INTERNAL_PATH_LIB_PREFIX,\n} from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { toForwardSlash } from '../util/path-utils.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport { getShortFunctionName } from '../wasm-executor/wasm-names.js';\n\n// Load the native addon via node-gyp-build\n// node-gyp-build checks: prebuilds/ first, then build/Release/\n// It searches from the given directory for a package.json to find the package root.\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst rootFromDist = resolve(__dirname, '..');\n// TODO: Verify if this src fallback is still needed — pool always runs from dist/ even locally.\n// If confirmed dead code, remove this and simplify to a single nodeGypBuild call.\nconst rootFromSrc = resolve(__dirname, '../..');\n\nconst require = createRequire(import.meta.url);\nconst nodeGypBuild: (dir: string) => NativeAddon = require('node-gyp-build');\n\nlet addon: NativeAddon;\ntry {\n addon = nodeGypBuild(rootFromDist);\n} catch {\n try {\n addon = nodeGypBuild(rootFromSrc);\n } catch (err) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMInstrumentationError,\n `vitest-pool-assemblyscript native instrumentation addon not found. Searched from ${rootFromDist} and ${rootFromSrc}. `\n + `Ensure prebuilds are available or run 'node node_modules/vitest-pool-assemblyscript/scripts/install-native-addon.js'`\n + ` to compile from source. Original error:`\n + `\\n${err instanceof Error ? err.message : String(err)}`,\n );\n }\n}\n\n/**\n * Convert a raw location (0-indexed columns, path indexes) to\n * processed location (1-indexed columns, absolute path strings)\n *\n * Source map paths vary by import style and project structure:\n * - Relative imports: \"assembly/compare.ts\"\n * - Bare package imports: \"~lib/vitest-pool-assemblyscript/assembly/compare.ts\"\n * - Source outside project root: \"../assembly/compare.ts\" (e.g. test-external importing parent sources)\n *\n * All are normalized to absolute filesystem paths for consistent coverage key matching.\n */\nfunction convertLocation(\n rawLocation: NativeSourceLocation,\n debugSourceFiles: string[],\n projectRoot: string\n): SourceLocation {\n let filePath = debugSourceFiles[rawLocation.fileIndex];\n\n if (!filePath) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMInstrumentationError,\n `No debug source file with index: ${rawLocation.fileIndex}}`,\n );\n }\n\n // Normalize to absolute path for consistent coverage key matching\n if (filePath.startsWith(INTERNAL_PATH_LIB_PREFIX)) {\n // ~lib/vitest-pool-assemblyscript/assembly/X.ts -> projectRoot/assembly/X.ts\n const relativePart = filePath.slice(INTERNAL_PATH_LIB_PREFIX.length);\n filePath = toForwardSlash(resolve(projectRoot, 'assembly', relativePart));\n } else {\n // Resolve relative path (handles both 'assembly/X.ts' and '../assembly/X.ts')\n filePath = toForwardSlash(resolve(projectRoot, filePath));\n }\n\n return {\n filePath,\n line: rawLocation.line,\n column: rawLocation.column + 1, // convert from 0-indexed to 1-indexed\n };\n}\n\n/**\n * Convert a raw expression to processed format\n */\nfunction convertExpression(\n rawExpr: NativeExpressionDebugInfo,\n debugSourceFiles: string[],\n projectRoot: string\n): ExpressionDebugInfo {\n const converted: ExpressionDebugInfo = {\n type: rawExpr.type,\n isBranch: rawExpr.isBranch,\n };\n\n if (rawExpr.branchPaths !== undefined) {\n converted.branchPaths = rawExpr.branchPaths;\n }\n\n if (rawExpr.location) {\n const convertedLocation = convertLocation(rawExpr.location, debugSourceFiles, projectRoot);\n if (convertedLocation) {\n converted.location = convertedLocation;\n }\n }\n\n return converted;\n}\n\n/**\n * Generate a position key to identify the SourceLocation uniquely\n * within a file. Does NOT include the file identifier.\n */\nfunction getPositionKey(location: SourceLocation) {\n return `${location.line}:${location.column}`;\n}\n\n/**\n * Convert a raw function to processed format and compute position key\n * Returns undefined if function has no valid representative location\n */\nfunction convertFunction(\n rawFunc: NativeFunctionDebugInfo,\n debugSourceFiles: string[],\n projectRoot: string\n): { func: FunctionDebugInfo; filePath: string; positionKey: string } | undefined {\n const representativeLocation = convertLocation(rawFunc.representativeLocation, debugSourceFiles, projectRoot);\n\n // Convert expressions\n const expressions: ExpressionDebugInfo[] = [];\n if (rawFunc.expressions) {\n for (const expr of rawFunc.expressions) {\n expressions.push(convertExpression(expr, debugSourceFiles, projectRoot));\n }\n }\n\n const converted: FunctionDebugInfo = {\n wasmIndex: rawFunc.wasmIndex,\n name: rawFunc.name,\n representativeLocation,\n coverageMemoryIndex: rawFunc.coverageMemoryIndex,\n expressions,\n basicBlocks: rawFunc.basicBlocks,\n };\n\n const filePath = representativeLocation.filePath;\n const positionKey = getPositionKey(representativeLocation);\n\n return { func: converted, filePath, positionKey };\n}\n\n/**\n * Check if two WASM function names are monomorphizations of the same generic function.\n * Generic monomorphizations share the same base name and suffix, differing only in\n * the type parameters inside angle brackets.\n *\n * e.g. \"assembly/compare/closeTo<bool\\2cbool>\" and \"assembly/compare/closeTo<bool\\2cu8>\"\n * e.g. \"assembly/expect/BaseExpectMatcher<bool>#constructor\" and \"assembly/expect/BaseExpectMatcher<i8>#constructor\"\n */\nfunction isGenericMonomorphizationMatch(nameA: string, nameB: string): boolean {\n const openA = nameA.indexOf('<');\n const openB = nameB.indexOf('<');\n\n // Both must contain generic type parameters\n if (openA === -1 || openB === -1) return false;\n\n const lastCloseA = nameA.lastIndexOf('>');\n const lastCloseB = nameB.lastIndexOf('>');\n\n if (lastCloseA === -1 || lastCloseB === -1) return false;\n\n // Prefix before '<' must match (includes module path, class, function name)\n const prefixA = nameA.substring(0, openA);\n const prefixB = nameB.substring(0, openB);\n if (prefixA !== prefixB) return false;\n\n // Suffix after last '>' must match (e.g. \"#constructor\", or empty)\n const suffixA = nameA.substring(lastCloseA + 1);\n const suffixB = nameB.substring(lastCloseB + 1);\n if (suffixA !== suffixB) return false;\n\n return true;\n}\n\n/**\n * Transform raw native addon output to processed BinaryDebugInfo\n */\nfunction transformDebugInfo(\n raw: NativeDebugInfoOutput,\n logPrefix: string,\n projectRoot: string,\n): BinaryDebugInfo {\n const functionsByFileAndPosition: Record<string, Record<string, FunctionDebugInfo[]>> = {};\n\n debug(`${logPrefix} - Converting ${raw.functions.length} functions`);\n\n let genericCollisionCount = 0;\n let skippedCount = 0;\n let instrumentedFunctionCount = 0;\n\n for (const rawFunc of raw.functions) {\n const result = convertFunction(rawFunc, raw.debugSourceFiles, projectRoot);\n if (!result) {\n debug(`${logPrefix} - WARNING: Skipped function (bad conversion): \"${rawFunc.name}\"`);\n skippedCount++;\n continue;\n }\n\n const { func, filePath, positionKey } = result;\n\n // Check for position collisions\n const existingAtPosition = functionsByFileAndPosition[filePath]?.[positionKey];\n if (existingAtPosition) {\n const existingName = existingAtPosition[0]!.name;\n\n // Only allow collision if both are monomorphizations of the same generic\n if (isGenericMonomorphizationMatch(existingName, func.name)) {\n existingAtPosition.push(func);\n genericCollisionCount++;\n instrumentedFunctionCount++;\n debug(\n `${logPrefix} - Generic monomorphization at ${filePath}:${positionKey}:`\n + ` \"${getShortFunctionName(func.name)}\" grouped with \"${getShortFunctionName(existingName)}\"`\n );\n continue;\n }\n\n throw createPoolError(\n POOL_ERROR_NAMES.WASMInstrumentationError,\n `Function Debug Position Collision at ${filePath}:${positionKey}: \"${getShortFunctionName(existingName)}\"`\n + ` will be replaced by \"${getShortFunctionName(func.name)}\". This is a bug. Please report it at:`\n + ` https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new`,\n );\n }\n\n instrumentedFunctionCount++;\n\n // Group by file and position\n if (!functionsByFileAndPosition[filePath]) {\n functionsByFileAndPosition[filePath] = {};\n }\n\n functionsByFileAndPosition[filePath][positionKey] = [func];\n }\n\n debug(\n `${logPrefix} - BinaryDebugInfo transform complete: ${instrumentedFunctionCount} instrumented functions`\n + ` (${genericCollisionCount} generic collisions, ${skippedCount} skipped)`\n );\n\n return {\n debugSourceFiles: raw.debugSourceFiles,\n functionsByFileAndPosition,\n instrumentedFunctionCount,\n };\n}\n\n/**\n * Instrument a WASM binary for coverage collection and regenerate source map\n *\n * This function:\n * 1. Adds __coverage_memory import (multi-memory for coverage counters)\n * 2. Injects coverage counter increments at each function entry\n * 3. Regenerates source map with correct offsets after instrumentation\n * 4. Extracts debug info with coverageMemoryIndex assigned\n *\n * @param wasmBuffer - Buffer containing the clean WASM binary\n * @param sourceMapBuffer - Buffer containing the source map JSON\n * @returns Instrumented binary, regenerated source map, and debug info\n *\n * @throws {TypeError} If wasmBuffer or sourceMapBuffer are not Buffers\n * @throws {Error} If WASM binary or source map is invalid\n */\nexport const instrumentForCoverage: InstrumentForCoverageFunc = (\n wasmBuffer: Buffer,\n sourceMapBuffer: Buffer,\n instrumentationOptions: InstrumentationOptions,\n logModule: string,\n logLabel: string,\n): InstrumentationResult => {\n if (!Buffer.isBuffer(wasmBuffer)) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMInstrumentationError,\n `instrumentForCoverage - wasmBuffer must be a Buffer (got ${typeof wasmBuffer})`,\n );\n }\n if (!Buffer.isBuffer(sourceMapBuffer)) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMInstrumentationError,\n `instrumentForCoverage - sourceMapBuffer must be a Buffer (got ${typeof sourceMapBuffer})`,\n );\n }\n\n const interfaceLogPrefix = `[${logModule} Inst] ${logLabel}`;\n const nativeLogPrefix = `[${logModule} InstNative] ${logLabel}`;\n\n debug(`${interfaceLogPrefix} - Calling native instrumentForCoverage`);\n const startTime = performance.now();\n\n const options: NativeInstrumentationOptions = {\n coverageMemoryPagesMin: instrumentationOptions.coverageMemoryPagesMin,\n coverageMemoryPagesMax: instrumentationOptions.coverageMemoryPagesMax,\n excludedFiles: instrumentationOptions.relativeExcludedFiles,\n excludedLibraryFilePrefix: instrumentationOptions.excludedLibraryFilePrefix,\n excludedLibraryFileOverridePrefix: instrumentationOptions.excludedLibraryFileOverridePrefix,\n excludedInternalFunctionSubstring: instrumentationOptions.excludedInternalFunctionSubstring,\n debug: instrumentationOptions.debug,\n logPrefix: nativeLogPrefix,\n coverageMemoryModule: instrumentationOptions.coverageMemoryModule,\n coverageMemoryName: instrumentationOptions.coverageMemoryName\n };\n const nativeResult: NativeInstrumentationResult = addon.instrumentForCoverage(wasmBuffer, sourceMapBuffer, options);\n const addonTime = performance.now();\n debug(`${interfaceLogPrefix} - TIMING Native addon: ${(addonTime - startTime).toFixed(2)} ms`);\n\n if (nativeResult.errors?.length) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMInstrumentationError,\n `Errors encountered duriing native instrumentation: ${nativeResult.errors.join('\\n')}`,\n );\n }\n\n const debugInfo = transformDebugInfo(nativeResult.debugInfo, interfaceLogPrefix, instrumentationOptions.projectRoot);\n \n const transformTime = performance.now();\n debug(`${interfaceLogPrefix} - TIMING DebugInfo Transform: ${(transformTime - addonTime).toFixed(2)} ms`);\n debug(`${interfaceLogPrefix} - Binary size: ${nativeResult.instrumentedWasm.length} bytes | Source map size: ${nativeResult.sourceMap.length * 2} bytes`);\n\n return {\n instrumentedWasm: nativeResult.instrumentedWasm,\n sourceMap: nativeResult.sourceMap,\n debugInfo,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4CA,MAAM,YAAY,QADC,cAAc,OAAO,KAAK,IAAI,CACZ;AACrC,MAAM,eAAe,QAAQ,WAAW,KAAK;AAG7C,MAAM,cAAc,QAAQ,WAAW,QAAQ;AAG/C,MAAM,eADU,cAAc,OAAO,KAAK,IAAI,CACa,iBAAiB;AAE5E,IAAI;AACJ,IAAI;AACF,SAAQ,aAAa,aAAa;QAC5B;AACN,KAAI;AACF,UAAQ,aAAa,YAAY;UAC1B,KAAK;AACZ,QAAM,gBACJ,iBAAiB,0BACjB,oFAAoF,aAAa,OAAO,YAAY,kKAG3G,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAC1D;;;;;;;;;;;;;;AAeL,SAAS,gBACP,aACA,kBACA,aACgB;CAChB,IAAI,WAAW,iBAAiB,YAAY;AAE5C,KAAI,CAAC,SACH,OAAM,gBACJ,iBAAiB,0BACjB,oCAAoC,YAAY,UAAU,GAC3D;AAIH,KAAI,SAAS,WAAW,yBAAyB,CAG/C,YAAW,eAAe,QAAQ,aAAa,YAD1B,SAAS,MAAM,yBAAyB,OAAO,CACI,CAAC;KAGzE,YA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bq5KNxXJ.mjs";
2
2
 
3
3
  //#region src/util/ast-visitor.ts
4
4
  /**
@@ -320,4 +320,4 @@ var ASTVisitor = class {
320
320
 
321
321
  //#endregion
322
322
  export { ASTVisitor };
323
- //# sourceMappingURL=ast-visitor-CWEOd3UH.mjs.map
323
+ //# sourceMappingURL=ast-visitor-w1HMbuJR.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast-visitor-CWEOd3UH.mjs","names":[],"sources":["../src/util/ast-visitor.ts"],"sourcesContent":["/**\n * Base AST Visitor for AssemblyScript\n *\n * Provides reusable walking logic for traversing AS AST nodes.\n * Subclasses override hook methods to perform specific tasks.\n *\n * Used by:\n * - ast-parser.ts: Extract function metadata for coverage\n * - strip-inline.mts: Strip @inline decorators\n */\n\nimport {\n Node,\n Source,\n BlockStatement,\n FunctionDeclaration,\n MethodDeclaration,\n ClassDeclaration,\n NamespaceDeclaration,\n VariableStatement,\n VariableDeclaration,\n FunctionExpression,\n ExpressionStatement,\n BinaryExpression,\n PropertyAccessExpression,\n IfStatement,\n WhileStatement,\n DoStatement,\n ForStatement,\n ForOfStatement,\n SwitchStatement,\n SwitchCase,\n TryStatement,\n ThrowStatement,\n ReturnStatement,\n CallExpression,\n NewExpression,\n ParenthesizedExpression,\n TernaryExpression,\n CommaExpression,\n AssertionExpression,\n InstanceOfExpression,\n ElementAccessExpression,\n UnaryPostfixExpression,\n UnaryPrefixExpression,\n ClassExpression,\n ParameterNode,\n EnumDeclaration,\n EnumValueDeclaration,\n FieldDeclaration,\n InterfaceDeclaration,\n VoidStatement,\n} from 'assemblyscript';\n\nimport { ASNodeKind } from '../types/constants.js';\n\n/**\n * Abstract base class for AST visitors.\n *\n * Subclasses override hook methods to perform tasks during traversal:\n * - beforeVisit: Called before visiting each node (e.g., strip decorators)\n * - onFunctionDeclaration: Called when visiting a function declaration\n * - onMethodDeclaration: Called when visiting a method declaration\n * - onVariableDeclaration: Called when visiting a variable declaration\n * - onClassEnter/onClassExit: Called when entering/exiting a class\n * - onNamespaceEnter/onNamespaceExit: Called when entering/exiting a namespace\n */\nexport abstract class ASTVisitor {\n /**\n * Visit all statements in a source file\n */\n visitSource(source: Source): void {\n for (const stmt of source.statements) {\n this.visitNode(stmt);\n }\n }\n\n /**\n * Hook called before visiting each node.\n * Override to perform pre-visit tasks (e.g., stripping decorators).\n */\n protected beforeVisit(_node: Node): void {}\n\n /**\n * Hook called when entering a namespace declaration.\n * Override to track namespace context.\n */\n protected onNamespaceEnter(_node: NamespaceDeclaration): void {}\n\n /**\n * Hook called when exiting a namespace declaration.\n * Override to restore namespace context.\n */\n protected onNamespaceExit(_node: NamespaceDeclaration): void {}\n\n /**\n * Hook called when entering a class declaration.\n * Override to track class context.\n */\n protected onClassEnter(_node: ClassDeclaration): void {}\n\n /**\n * Hook called when exiting a class declaration.\n * Override to restore class context.\n */\n protected onClassExit(_node: ClassDeclaration): void {}\n\n /**\n * Hook called when visiting a function declaration.\n * Override to extract function info or perform other tasks.\n * Return false to skip recursing into the function body.\n */\n protected onFunctionDeclaration(_node: FunctionDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Hook called when visiting a method declaration.\n * Override to extract method info or perform other tasks.\n * Return false to skip recursing into the method body.\n */\n protected onMethodDeclaration(_node: MethodDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Hook called when visiting a variable declaration.\n * Override to handle variable declarations (e.g., arrow functions).\n * Return false to skip recursing into the initializer.\n */\n protected onVariableDeclaration(_node: VariableDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Main visitor dispatch - routes to specific handler based on node kind\n */\n visitNode(node: Node): void {\n // Call pre-visit hook\n this.beforeVisit(node);\n\n // Recurse into children based on node kind\n switch (node.kind) {\n // Type nodes - no children to visit\n case ASNodeKind.NamedType:\n case ASNodeKind.FunctionType:\n case ASNodeKind.TypeName:\n case ASNodeKind.TypeParameter:\n break;\n\n // Parameter - may have default value\n case ASNodeKind.Parameter: {\n const param = node as ParameterNode;\n if (param.initializer) this.visitNode(param.initializer);\n break;\n }\n\n // Simple expressions - no children\n case ASNodeKind.Identifier:\n case ASNodeKind.False:\n case ASNodeKind.Literal:\n case ASNodeKind.Null:\n case ASNodeKind.Omitted:\n case ASNodeKind.Super:\n case ASNodeKind.This:\n case ASNodeKind.True:\n case ASNodeKind.Constructor:\n case ASNodeKind.Compiled:\n break;\n\n // Expressions with children\n case ASNodeKind.Assertion: {\n const expr = node as AssertionExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.Binary: {\n const expr = node as BinaryExpression;\n this.visitNode(expr.left);\n this.visitNode(expr.right);\n break;\n }\n case ASNodeKind.Call: {\n const expr = node as CallExpression;\n this.visitNode(expr.expression);\n for (const arg of expr.args) this.visitNode(arg);\n break;\n }\n case ASNodeKind.Class: {\n const expr = node as ClassExpression;\n this.visitNode(expr.declaration);\n break;\n }\n case ASNodeKind.Comma: {\n const expr = node as CommaExpression;\n for (const e of expr.expressions) this.visitNode(e);\n break;\n }\n case ASNodeKind.ElementAccess: {\n const expr = node as ElementAccessExpression;\n this.visitNode(expr.expression);\n this.visitNode(expr.elementExpression);\n break;\n }\n case ASNodeKind.Function: {\n const expr = node as FunctionExpression;\n this.visitNode(expr.declaration);\n break;\n }\n case ASNodeKind.InstanceOf: {\n const expr = node as InstanceOfExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.New: {\n const expr = node as NewExpression;\n for (const arg of expr.args) this.visitNode(arg);\n break;\n }\n case ASNodeKind.Parenthesized: {\n const expr = node as ParenthesizedExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.PropertyAccess: {\n const expr = node as PropertyAccessExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.Ternary: {\n const expr = node as TernaryExpression;\n this.visitNode(expr.condition);\n this.visitNode(expr.ifThen);\n this.visitNode(expr.ifElse);\n break;\n }\n case ASNodeKind.UnaryPostfix: {\n const expr = node as UnaryPostfixExpression;\n this.visitNode(expr.operand);\n break;\n }\n case ASNodeKind.UnaryPrefix: {\n const expr = node as UnaryPrefixExpression;\n this.visitNode(expr.operand);\n break;\n }\n\n // Statements with no interesting children\n case ASNodeKind.Break:\n case ASNodeKind.Continue:\n case ASNodeKind.Empty:\n case ASNodeKind.Export:\n case ASNodeKind.ExportDefault:\n case ASNodeKind.ExportImport:\n case ASNodeKind.Import:\n case ASNodeKind.Module:\n break;\n\n // Statements with children\n case ASNodeKind.Block: {\n const stmt = node as BlockStatement;\n for (const s of stmt.statements) this.visitNode(s);\n break;\n }\n case ASNodeKind.Do: {\n const stmt = node as DoStatement;\n this.visitNode(stmt.body);\n this.visitNode(stmt.condition);\n break;\n }\n case ASNodeKind.Expression: {\n const stmt = node as ExpressionStatement;\n this.visitNode(stmt.expression);\n break;\n }\n case ASNodeKind.For: {\n const stmt = node as ForStatement;\n if (stmt.initializer) this.visitNode(stmt.initializer);\n if (stmt.condition) this.visitNode(stmt.condition);\n if (stmt.incrementor) this.visitNode(stmt.incrementor);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.ForOf: {\n const stmt = node as ForOfStatement;\n this.visitNode(stmt.variable);\n this.visitNode(stmt.iterable);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.If: {\n const stmt = node as IfStatement;\n this.visitNode(stmt.condition);\n this.visitNode(stmt.ifTrue);\n if (stmt.ifFalse) this.visitNode(stmt.ifFalse);\n break;\n }\n case ASNodeKind.Return: {\n const stmt = node as ReturnStatement;\n if (stmt.value) this.visitNode(stmt.value);\n break;\n }\n case ASNodeKind.Switch: {\n const stmt = node as SwitchStatement;\n this.visitNode(stmt.condition);\n for (const switchCase of stmt.cases) this.visitNode(switchCase);\n break;\n }\n case ASNodeKind.Throw: {\n const stmt = node as ThrowStatement;\n this.visitNode(stmt.value);\n break;\n }\n case ASNodeKind.Try: {\n const stmt = node as TryStatement;\n for (const s of stmt.bodyStatements) this.visitNode(s);\n if (stmt.catchStatements) {\n for (const s of stmt.catchStatements) this.visitNode(s);\n }\n if (stmt.finallyStatements) {\n for (const s of stmt.finallyStatements) this.visitNode(s);\n }\n break;\n }\n case ASNodeKind.Variable: {\n const stmt = node as VariableStatement;\n for (const decl of stmt.declarations) this.visitNode(decl);\n break;\n }\n case ASNodeKind.Void: {\n const stmt = node as VoidStatement;\n this.visitNode(stmt.expression);\n break;\n }\n case ASNodeKind.While: {\n const stmt = node as WhileStatement;\n this.visitNode(stmt.condition);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.SwitchCase: {\n const stmt = node as SwitchCase;\n if (stmt.label) this.visitNode(stmt.label);\n for (const s of stmt.statements) this.visitNode(s);\n break;\n }\n\n // Declaration statements\n case ASNodeKind.ImportDeclaration:\n case ASNodeKind.TypeDeclaration:\n break;\n\n case ASNodeKind.ClassDeclaration: {\n const decl = node as ClassDeclaration;\n this.onClassEnter(decl);\n for (const member of decl.members) this.visitNode(member);\n this.onClassExit(decl);\n break;\n }\n case ASNodeKind.EnumDeclaration: {\n const decl = node as EnumDeclaration;\n for (const value of decl.values) this.visitNode(value);\n break;\n }\n case ASNodeKind.EnumValueDeclaration: {\n const decl = node as EnumValueDeclaration;\n if (decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n case ASNodeKind.FieldDeclaration: {\n const decl = node as FieldDeclaration;\n if (decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n case ASNodeKind.FunctionDeclaration: {\n const decl = node as FunctionDeclaration;\n const shouldRecurse = this.onFunctionDeclaration(decl);\n if (shouldRecurse && decl.body) this.visitNode(decl.body);\n break;\n }\n case ASNodeKind.InterfaceDeclaration: {\n const decl = node as InterfaceDeclaration;\n for (const member of decl.members) this.visitNode(member);\n break;\n }\n case ASNodeKind.MethodDeclaration: {\n const decl = node as MethodDeclaration;\n const shouldRecurse = this.onMethodDeclaration(decl);\n if (shouldRecurse && decl.body) this.visitNode(decl.body);\n break;\n }\n case ASNodeKind.NamespaceDeclaration: {\n const decl = node as NamespaceDeclaration;\n this.onNamespaceEnter(decl);\n for (const member of decl.members) this.visitNode(member);\n this.onNamespaceExit(decl);\n break;\n }\n case ASNodeKind.VariableDeclaration: {\n const decl = node as VariableDeclaration;\n const shouldRecurse = this.onVariableDeclaration(decl);\n if (shouldRecurse && decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n\n // Special nodes - no action needed\n case ASNodeKind.ExportMember:\n case ASNodeKind.IndexSignature:\n case ASNodeKind.Comment:\n case ASNodeKind.Decorator:\n break;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAmEA,IAAsB,aAAtB,MAAiC;;;;CAI/B,YAAY,QAAsB;AAChC,OAAK,MAAM,QAAQ,OAAO,WACxB,MAAK,UAAU,KAAK;;;;;;CAQxB,AAAU,YAAY,OAAmB;;;;;CAMzC,AAAU,iBAAiB,OAAmC;;;;;CAM9D,AAAU,gBAAgB,OAAmC;;;;;CAM7D,AAAU,aAAa,OAA+B;;;;;CAMtD,AAAU,YAAY,OAA+B;;;;;;CAOrD,AAAU,sBAAsB,OAAqC;AACnE,SAAO;;;;;;;CAQT,AAAU,oBAAoB,OAAmC;AAC/D,SAAO;;;;;;;CAQT,AAAU,sBAAsB,OAAqC;AACnE,SAAO;;;;;CAMT,UAAU,MAAkB;AAE1B,OAAK,YAAY,KAAK;AAGtB,UAAQ,KAAK,MAAb;GAEE,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW,cACd;GAGF,KAAK,WAAW,WAAW;IACzB,MAAM,QAAQ;AACd,QAAI,MAAM,YAAa,MAAK,UAAU,MAAM,YAAY;AACxD;;GAIF,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW,SACd;GAGF,KAAK,WAAW,WAAW;IACzB,MAAM,OAAO;AACb,SAAK,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BAAkB;IAChC,MAAM,OAAO;AACb,QAAI,KAAK,YAAa,MAAK,UAAU,KAAK,YAAY;AACtD;;GAEF,KAAK,WAAW,qBAAqB;IACnC,MAAM,OAAO;AAEb,QADsB,KAAK,sBAAsB,KAAK,IACjC,KAAK,KAAM,MAAK,UAAU,KAAK,KAAK;AACzD;;GAEF,KAAK,WAAW,sBAAsB;IACpC,MAAM,OAAO;AACb,SAAK,MAAM,UAAU,KAAK,QAAS,MAAK,UAAU,OAAO;AACzD;;GAEF,KAAK,WAAW,mBAAmB;IACjC,MAAM,OAAO;AAEb,QADsB,KAAK,oBAAoB,KAAK,IAC/B,KAAK,KAAM,MAAK,UAAU,KAAK,KAAK;AACzD;;GAEF,KAAK,WAAW,sBAAsB;IACpC,MAAM,OAAO;AACb,SAAK,iBAAiB,KAAK;AAC3B,SAAK,MAAM,UAAU,KAAK,QAAS,MAAK,UAAU,OAAO;AACzD,SAAK,gBAAgB,KAAK;AAC1B;;GAEF,KAAK,WAAW,qBAAqB;IACnC,MAAM,OAAO;AAEb,QADsB,KAAK,sBAAsB,KAAK,IACjC,KAAK,YAAa,MAAK,UAAU,KAAK,YAAY;AACvE;;GAIF,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW,UACd"}
1
+ {"version":3,"file":"ast-visitor-w1HMbuJR.mjs","names":[],"sources":["../src/util/ast-visitor.ts"],"sourcesContent":["/**\n * Base AST Visitor for AssemblyScript\n *\n * Provides reusable walking logic for traversing AS AST nodes.\n * Subclasses override hook methods to perform specific tasks.\n *\n * Used by:\n * - ast-parser.ts: Extract function metadata for coverage\n * - strip-inline.mts: Strip @inline decorators\n */\n\nimport {\n Node,\n Source,\n BlockStatement,\n FunctionDeclaration,\n MethodDeclaration,\n ClassDeclaration,\n NamespaceDeclaration,\n VariableStatement,\n VariableDeclaration,\n FunctionExpression,\n ExpressionStatement,\n BinaryExpression,\n PropertyAccessExpression,\n IfStatement,\n WhileStatement,\n DoStatement,\n ForStatement,\n ForOfStatement,\n SwitchStatement,\n SwitchCase,\n TryStatement,\n ThrowStatement,\n ReturnStatement,\n CallExpression,\n NewExpression,\n ParenthesizedExpression,\n TernaryExpression,\n CommaExpression,\n AssertionExpression,\n InstanceOfExpression,\n ElementAccessExpression,\n UnaryPostfixExpression,\n UnaryPrefixExpression,\n ClassExpression,\n ParameterNode,\n EnumDeclaration,\n EnumValueDeclaration,\n FieldDeclaration,\n InterfaceDeclaration,\n VoidStatement,\n} from 'assemblyscript';\n\nimport { ASNodeKind } from '../types/constants.js';\n\n/**\n * Abstract base class for AST visitors.\n *\n * Subclasses override hook methods to perform tasks during traversal:\n * - beforeVisit: Called before visiting each node (e.g., strip decorators)\n * - onFunctionDeclaration: Called when visiting a function declaration\n * - onMethodDeclaration: Called when visiting a method declaration\n * - onVariableDeclaration: Called when visiting a variable declaration\n * - onClassEnter/onClassExit: Called when entering/exiting a class\n * - onNamespaceEnter/onNamespaceExit: Called when entering/exiting a namespace\n */\nexport abstract class ASTVisitor {\n /**\n * Visit all statements in a source file\n */\n visitSource(source: Source): void {\n for (const stmt of source.statements) {\n this.visitNode(stmt);\n }\n }\n\n /**\n * Hook called before visiting each node.\n * Override to perform pre-visit tasks (e.g., stripping decorators).\n */\n protected beforeVisit(_node: Node): void {}\n\n /**\n * Hook called when entering a namespace declaration.\n * Override to track namespace context.\n */\n protected onNamespaceEnter(_node: NamespaceDeclaration): void {}\n\n /**\n * Hook called when exiting a namespace declaration.\n * Override to restore namespace context.\n */\n protected onNamespaceExit(_node: NamespaceDeclaration): void {}\n\n /**\n * Hook called when entering a class declaration.\n * Override to track class context.\n */\n protected onClassEnter(_node: ClassDeclaration): void {}\n\n /**\n * Hook called when exiting a class declaration.\n * Override to restore class context.\n */\n protected onClassExit(_node: ClassDeclaration): void {}\n\n /**\n * Hook called when visiting a function declaration.\n * Override to extract function info or perform other tasks.\n * Return false to skip recursing into the function body.\n */\n protected onFunctionDeclaration(_node: FunctionDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Hook called when visiting a method declaration.\n * Override to extract method info or perform other tasks.\n * Return false to skip recursing into the method body.\n */\n protected onMethodDeclaration(_node: MethodDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Hook called when visiting a variable declaration.\n * Override to handle variable declarations (e.g., arrow functions).\n * Return false to skip recursing into the initializer.\n */\n protected onVariableDeclaration(_node: VariableDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Main visitor dispatch - routes to specific handler based on node kind\n */\n visitNode(node: Node): void {\n // Call pre-visit hook\n this.beforeVisit(node);\n\n // Recurse into children based on node kind\n switch (node.kind) {\n // Type nodes - no children to visit\n case ASNodeKind.NamedType:\n case ASNodeKind.FunctionType:\n case ASNodeKind.TypeName:\n case ASNodeKind.TypeParameter:\n break;\n\n // Parameter - may have default value\n case ASNodeKind.Parameter: {\n const param = node as ParameterNode;\n if (param.initializer) this.visitNode(param.initializer);\n break;\n }\n\n // Simple expressions - no children\n case ASNodeKind.Identifier:\n case ASNodeKind.False:\n case ASNodeKind.Literal:\n case ASNodeKind.Null:\n case ASNodeKind.Omitted:\n case ASNodeKind.Super:\n case ASNodeKind.This:\n case ASNodeKind.True:\n case ASNodeKind.Constructor:\n case ASNodeKind.Compiled:\n break;\n\n // Expressions with children\n case ASNodeKind.Assertion: {\n const expr = node as AssertionExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.Binary: {\n const expr = node as BinaryExpression;\n this.visitNode(expr.left);\n this.visitNode(expr.right);\n break;\n }\n case ASNodeKind.Call: {\n const expr = node as CallExpression;\n this.visitNode(expr.expression);\n for (const arg of expr.args) this.visitNode(arg);\n break;\n }\n case ASNodeKind.Class: {\n const expr = node as ClassExpression;\n this.visitNode(expr.declaration);\n break;\n }\n case ASNodeKind.Comma: {\n const expr = node as CommaExpression;\n for (const e of expr.expressions) this.visitNode(e);\n break;\n }\n case ASNodeKind.ElementAccess: {\n const expr = node as ElementAccessExpression;\n this.visitNode(expr.expression);\n this.visitNode(expr.elementExpression);\n break;\n }\n case ASNodeKind.Function: {\n const expr = node as FunctionExpression;\n this.visitNode(expr.declaration);\n break;\n }\n case ASNodeKind.InstanceOf: {\n const expr = node as InstanceOfExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.New: {\n const expr = node as NewExpression;\n for (const arg of expr.args) this.visitNode(arg);\n break;\n }\n case ASNodeKind.Parenthesized: {\n const expr = node as ParenthesizedExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.PropertyAccess: {\n const expr = node as PropertyAccessExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.Ternary: {\n const expr = node as TernaryExpression;\n this.visitNode(expr.condition);\n this.visitNode(expr.ifThen);\n this.visitNode(expr.ifElse);\n break;\n }\n case ASNodeKind.UnaryPostfix: {\n const expr = node as UnaryPostfixExpression;\n this.visitNode(expr.operand);\n break;\n }\n case ASNodeKind.UnaryPrefix: {\n const expr = node as UnaryPrefixExpression;\n this.visitNode(expr.operand);\n break;\n }\n\n // Statements with no interesting children\n case ASNodeKind.Break:\n case ASNodeKind.Continue:\n case ASNodeKind.Empty:\n case ASNodeKind.Export:\n case ASNodeKind.ExportDefault:\n case ASNodeKind.ExportImport:\n case ASNodeKind.Import:\n case ASNodeKind.Module:\n break;\n\n // Statements with children\n case ASNodeKind.Block: {\n const stmt = node as BlockStatement;\n for (const s of stmt.statements) this.visitNode(s);\n break;\n }\n case ASNodeKind.Do: {\n const stmt = node as DoStatement;\n this.visitNode(stmt.body);\n this.visitNode(stmt.condition);\n break;\n }\n case ASNodeKind.Expression: {\n const stmt = node as ExpressionStatement;\n this.visitNode(stmt.expression);\n break;\n }\n case ASNodeKind.For: {\n const stmt = node as ForStatement;\n if (stmt.initializer) this.visitNode(stmt.initializer);\n if (stmt.condition) this.visitNode(stmt.condition);\n if (stmt.incrementor) this.visitNode(stmt.incrementor);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.ForOf: {\n const stmt = node as ForOfStatement;\n this.visitNode(stmt.variable);\n this.visitNode(stmt.iterable);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.If: {\n const stmt = node as IfStatement;\n this.visitNode(stmt.condition);\n this.visitNode(stmt.ifTrue);\n if (stmt.ifFalse) this.visitNode(stmt.ifFalse);\n break;\n }\n case ASNodeKind.Return: {\n const stmt = node as ReturnStatement;\n if (stmt.value) this.visitNode(stmt.value);\n break;\n }\n case ASNodeKind.Switch: {\n const stmt = node as SwitchStatement;\n this.visitNode(stmt.condition);\n for (const switchCase of stmt.cases) this.visitNode(switchCase);\n break;\n }\n case ASNodeKind.Throw: {\n const stmt = node as ThrowStatement;\n this.visitNode(stmt.value);\n break;\n }\n case ASNodeKind.Try: {\n const stmt = node as TryStatement;\n for (const s of stmt.bodyStatements) this.visitNode(s);\n if (stmt.catchStatements) {\n for (const s of stmt.catchStatements) this.visitNode(s);\n }\n if (stmt.finallyStatements) {\n for (const s of stmt.finallyStatements) this.visitNode(s);\n }\n break;\n }\n case ASNodeKind.Variable: {\n const stmt = node as VariableStatement;\n for (const decl of stmt.declarations) this.visitNode(decl);\n break;\n }\n case ASNodeKind.Void: {\n const stmt = node as VoidStatement;\n this.visitNode(stmt.expression);\n break;\n }\n case ASNodeKind.While: {\n const stmt = node as WhileStatement;\n this.visitNode(stmt.condition);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.SwitchCase: {\n const stmt = node as SwitchCase;\n if (stmt.label) this.visitNode(stmt.label);\n for (const s of stmt.statements) this.visitNode(s);\n break;\n }\n\n // Declaration statements\n case ASNodeKind.ImportDeclaration:\n case ASNodeKind.TypeDeclaration:\n break;\n\n case ASNodeKind.ClassDeclaration: {\n const decl = node as ClassDeclaration;\n this.onClassEnter(decl);\n for (const member of decl.members) this.visitNode(member);\n this.onClassExit(decl);\n break;\n }\n case ASNodeKind.EnumDeclaration: {\n const decl = node as EnumDeclaration;\n for (const value of decl.values) this.visitNode(value);\n break;\n }\n case ASNodeKind.EnumValueDeclaration: {\n const decl = node as EnumValueDeclaration;\n if (decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n case ASNodeKind.FieldDeclaration: {\n const decl = node as FieldDeclaration;\n if (decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n case ASNodeKind.FunctionDeclaration: {\n const decl = node as FunctionDeclaration;\n const shouldRecurse = this.onFunctionDeclaration(decl);\n if (shouldRecurse && decl.body) this.visitNode(decl.body);\n break;\n }\n case ASNodeKind.InterfaceDeclaration: {\n const decl = node as InterfaceDeclaration;\n for (const member of decl.members) this.visitNode(member);\n break;\n }\n case ASNodeKind.MethodDeclaration: {\n const decl = node as MethodDeclaration;\n const shouldRecurse = this.onMethodDeclaration(decl);\n if (shouldRecurse && decl.body) this.visitNode(decl.body);\n break;\n }\n case ASNodeKind.NamespaceDeclaration: {\n const decl = node as NamespaceDeclaration;\n this.onNamespaceEnter(decl);\n for (const member of decl.members) this.visitNode(member);\n this.onNamespaceExit(decl);\n break;\n }\n case ASNodeKind.VariableDeclaration: {\n const decl = node as VariableDeclaration;\n const shouldRecurse = this.onVariableDeclaration(decl);\n if (shouldRecurse && decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n\n // Special nodes - no action needed\n case ASNodeKind.ExportMember:\n case ASNodeKind.IndexSignature:\n case ASNodeKind.Comment:\n case ASNodeKind.Decorator:\n break;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAmEA,IAAsB,aAAtB,MAAiC;;;;CAI/B,YAAY,QAAsB;AAChC,OAAK,MAAM,QAAQ,OAAO,WACxB,MAAK,UAAU,KAAK;;;;;;CAQxB,AAAU,YAAY,OAAmB;;;;;CAMzC,AAAU,iBAAiB,OAAmC;;;;;CAM9D,AAAU,gBAAgB,OAAmC;;;;;CAM7D,AAAU,aAAa,OAA+B;;;;;CAMtD,AAAU,YAAY,OAA+B;;;;;;CAOrD,AAAU,sBAAsB,OAAqC;AACnE,SAAO;;;;;;;CAQT,AA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AsB,KAAK,IACjC,KAAK,YAAa,MAAK,UAAU,KAAK,YAAY;AACvE;;GAIF,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW,UACd"}
@@ -0,0 +1,82 @@
1
+ import { INTERNAL_PATH_LIB_PREFIX, POOL_INTERNAL_PATHS } from "./constants-Bq5KNxXJ.mjs";
2
+ import { failFile, getFullTaskHierarchy, getTaskLogLabel, getTaskLogPrefix, prepareFileTaskForCollection } from "./vitest-file-tasks-Coc4btUw.mjs";
3
+ import { buildEnhancedFileError, debug, toForwardSlash } from "./pool-errors-GWfwrsD7.mjs";
4
+ import { executeWASMDiscovery, flushRpcUpdates, reportFileCollected, reportFileError, reportFileQueued, reportUserConsoleLogs } from "./load-user-imports-6Pv-9hRg.mjs";
5
+ import { compileAssemblyScript } from "./compiler-DSKhQ5--.mjs";
6
+ import { basename, relative } from "node:path";
7
+
8
+ //#region src/pool-thread/runner/compile-runner.ts
9
+ /**
10
+ * Worker thread test runner logic for AssemblyScript Pool
11
+ */
12
+ let threadCompilationCount = 0;
13
+ async function runCompileAndDiscover(file, logModule, rpc, asPoolOptions, projectRoot, collectCoverage, relativeUserCoverageExclusions, threadImports, diffOptions, testNamePattern, allowOnly) {
14
+ const base = basename(file.filepath);
15
+ const fileLogPrefix = getTaskLogPrefix(logModule, base, file);
16
+ const fileLogLabel = getTaskLogLabel(base, file);
17
+ debug(`${fileLogPrefix} - Beginning runCompileAndDiscover for "${file.filepath}" at ${Date.now()}`);
18
+ let compilation;
19
+ let reportedQueued = false;
20
+ const runStartPerf = performance.now();
21
+ try {
22
+ await reportFileQueued(rpc, file, logModule, fileLogLabel);
23
+ reportedQueued = true;
24
+ const instrumentationOptions = {
25
+ projectRoot,
26
+ relativeExcludedFiles: [
27
+ toForwardSlash(relative(projectRoot, file.filepath)),
28
+ ...asPoolOptions._instrumentPoolInternals ? [] : POOL_INTERNAL_PATHS,
29
+ ...relativeUserCoverageExclusions
30
+ ],
31
+ excludedLibraryFilePrefix: "~lib/",
32
+ excludedLibraryFileOverridePrefix: asPoolOptions._instrumentPoolInternals ? INTERNAL_PATH_LIB_PREFIX : void 0,
33
+ excludedInternalFunctionSubstring: "__vitest_assemblyscript_",
34
+ coverageMemoryPagesMin: asPoolOptions.coverageMemoryPagesInitial ?? 1,
35
+ coverageMemoryPagesMax: asPoolOptions.coverageMemoryPagesMax,
36
+ debug: asPoolOptions.debugNative,
37
+ coverageMemoryModule: "__as_pool_env__",
38
+ coverageMemoryName: "__coverage_memory"
39
+ };
40
+ const compilerOptions = {
41
+ stripInline: asPoolOptions.stripInline,
42
+ projectRoot,
43
+ shouldInstrument: collectCoverage,
44
+ instrumentationOptions,
45
+ extraFlags: asPoolOptions.extraCompilerFlags
46
+ };
47
+ compilation = await compileAssemblyScript(file.filepath, compilerOptions, logModule, fileLogLabel);
48
+ file.setupDuration = compilation.compileTiming;
49
+ threadCompilationCount++;
50
+ debug(`${fileLogPrefix} - TIMING compileAssemblyScript total (thread comp # ${threadCompilationCount}): ${compilation.compileTiming.toFixed(2)} ms`);
51
+ const logMessages = [];
52
+ const handleLog = (msg, isError = false) => {
53
+ logMessages.push({
54
+ msg,
55
+ time: Date.now(),
56
+ isError
57
+ });
58
+ };
59
+ const discoverStartPerf = performance.now();
60
+ await executeWASMDiscovery(compilation, asPoolOptions, collectCoverage, handleLog, file, logModule, threadImports);
61
+ prepareFileTaskForCollection(file, testNamePattern, allowOnly);
62
+ file.collectDuration = performance.now() - discoverStartPerf;
63
+ debug(`${fileLogPrefix} - TIMING Discovery Phase: ${file.collectDuration.toFixed(2)} ms`);
64
+ await Promise.all([reportUserConsoleLogs(rpc, logMessages, logModule, base, file), reportFileCollected(rpc, file, logModule, fileLogLabel)]);
65
+ debug(() => `${fileLogPrefix} - Collected Test Suite Hierarchy:\n${getFullTaskHierarchy(file)}`);
66
+ debug(`${fileLogPrefix} - TIMING Compilation and Discovery: ${(performance.now() - runStartPerf).toFixed(2)} ms`);
67
+ } catch (error) {
68
+ const testError = await buildEnhancedFileError(error, file, compilation?.sourceMap, fileLogPrefix, projectRoot, "compile runner", diffOptions);
69
+ failFile(file, testError, runStartPerf);
70
+ if (!reportedQueued) await reportFileQueued(rpc, file, logModule, fileLogLabel);
71
+ await reportFileError(rpc, file, logModule, fileLogLabel);
72
+ debug(`${fileLogPrefix} - runCompileAndDiscover - Reported file error:`, testError);
73
+ } finally {
74
+ await flushRpcUpdates(rpc);
75
+ debug(`${fileLogPrefix} - runCompileAndDiscover Completed`);
76
+ }
77
+ return compilation;
78
+ }
79
+
80
+ //#endregion
81
+ export { runCompileAndDiscover };
82
+ //# sourceMappingURL=compile-runner-D4SJWhMh.mjs.map