vitest-pool-assemblyscript 0.3.1 → 0.5.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 (76) hide show
  1. package/README.md +8 -4
  2. package/assembly/compare.ts +127 -0
  3. package/assembly/expect.ts +116 -11
  4. package/dist/{ast-visitor-lTahoS9R.mjs → ast-visitor-DJLJd5dt.mjs} +2 -2
  5. package/dist/{ast-visitor-lTahoS9R.mjs.map → ast-visitor-DJLJd5dt.mjs.map} +1 -1
  6. package/dist/{compile-runner-C2eh_xLp.mjs → compile-runner-BJ_ZF3Ma.mjs} +11 -8
  7. package/dist/compile-runner-BJ_ZF3Ma.mjs.map +1 -0
  8. package/dist/compiler/transforms/strip-inline.mjs +2 -2
  9. package/dist/{compiler-BaNECXMW.mjs → compiler-CscxCJw3.mjs} +78 -38
  10. package/dist/compiler-CscxCJw3.mjs.map +1 -0
  11. package/dist/config/index-v3.d.mts +2 -2
  12. package/dist/config/index.d.mts +3 -3
  13. package/dist/config/index.mjs +5 -5
  14. package/dist/{constants-DX9yo-el.mjs → constants-DuBLuMjt.mjs} +9 -9
  15. package/dist/constants-DuBLuMjt.mjs.map +1 -0
  16. package/dist/{coverage-merge-0WqdC-dq.mjs → coverage-merge-DCEwyjMy.mjs} +1 -1
  17. package/dist/{coverage-merge-0WqdC-dq.mjs.map → coverage-merge-DCEwyjMy.mjs.map} +1 -1
  18. package/dist/coverage-provider/index.mjs +35 -28
  19. package/dist/coverage-provider/index.mjs.map +1 -1
  20. package/dist/{custom-provider-options-CF5C1kXb.d.mts → custom-provider-options-i_O0OSTV.d.mts} +2 -2
  21. package/dist/{custom-provider-options-CF5C1kXb.d.mts.map → custom-provider-options-i_O0OSTV.d.mts.map} +1 -1
  22. package/dist/{debug-Cf2jt1kg.mjs → debug-Cm1VFmaz.mjs} +16 -13
  23. package/dist/{debug-Cf2jt1kg.mjs.map → debug-Cm1VFmaz.mjs.map} +1 -1
  24. package/dist/index-internal.d.mts +1 -14
  25. package/dist/index-internal.d.mts.map +1 -1
  26. package/dist/index-internal.mjs +3 -3
  27. package/dist/index-v3.mjs +4 -4
  28. package/dist/index-v3.mjs.map +1 -1
  29. package/dist/index.d.mts +2 -2
  30. package/dist/index.mjs +5 -5
  31. package/dist/{load-user-imports-eGZuxeNp.mjs → load-user-imports-CYTTU22Q.mjs} +30 -149
  32. package/dist/load-user-imports-CYTTU22Q.mjs.map +1 -0
  33. package/dist/node-check-CooGQMLH.mjs +16 -0
  34. package/dist/node-check-CooGQMLH.mjs.map +1 -0
  35. package/dist/{pool-runner-init-Cdpz_B-F.mjs → pool-runner-init-D1QamWkS.mjs} +5 -5
  36. package/dist/{pool-runner-init-Cdpz_B-F.mjs.map → pool-runner-init-D1QamWkS.mjs.map} +1 -1
  37. package/dist/{pool-runner-init-CEwLyNI3.d.mts → pool-runner-init-D56aVMMD.d.mts} +2 -2
  38. package/dist/pool-runner-init-D56aVMMD.d.mts.map +1 -0
  39. package/dist/pool-thread/compile-worker-thread.d.mts +1 -1
  40. package/dist/pool-thread/compile-worker-thread.d.mts.map +1 -1
  41. package/dist/pool-thread/compile-worker-thread.mjs +11 -9
  42. package/dist/pool-thread/compile-worker-thread.mjs.map +1 -1
  43. package/dist/pool-thread/test-worker-thread.d.mts +1 -1
  44. package/dist/pool-thread/test-worker-thread.d.mts.map +1 -1
  45. package/dist/pool-thread/test-worker-thread.mjs +10 -8
  46. package/dist/pool-thread/test-worker-thread.mjs.map +1 -1
  47. package/dist/pool-thread/v3-tinypool-thread.d.mts +1 -1
  48. package/dist/pool-thread/v3-tinypool-thread.d.mts.map +1 -1
  49. package/dist/pool-thread/v3-tinypool-thread.mjs +14 -12
  50. package/dist/pool-thread/v3-tinypool-thread.mjs.map +1 -1
  51. package/dist/{resolve-config-BKjJQyy5.mjs → resolve-config-BFNr7LW7.mjs} +9 -3
  52. package/dist/resolve-config-BFNr7LW7.mjs.map +1 -0
  53. package/dist/{test-runner-vGpTcXsw.mjs → test-runner-CfhzcYNS.mjs} +5 -5
  54. package/dist/{test-runner-vGpTcXsw.mjs.map → test-runner-CfhzcYNS.mjs.map} +1 -1
  55. package/dist/{types-8KKo9Hbf.d.mts → types-DmyeERkL.d.mts} +15 -6
  56. package/dist/types-DmyeERkL.d.mts.map +1 -0
  57. package/dist/{vitest-tasks-Cbri6MWZ.mjs → vitest-tasks-ByPK8DvF.mjs} +3 -3
  58. package/dist/{vitest-tasks-Cbri6MWZ.mjs.map → vitest-tasks-ByPK8DvF.mjs.map} +1 -1
  59. package/dist/wasm-names-CydfYzQK.mjs +124 -0
  60. package/dist/wasm-names-CydfYzQK.mjs.map +1 -0
  61. package/package.json +11 -5
  62. package/prebuilds/darwin-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  63. package/prebuilds/darwin-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  64. package/prebuilds/linux-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  65. package/prebuilds/linux-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  66. package/prebuilds/linux-x64/vitest-pool-assemblyscript.musl.node +0 -0
  67. package/prebuilds/win32-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  68. package/prebuilds/win32-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  69. package/src/native-instrumentation/addon.cpp +28 -2
  70. package/dist/compile-runner-C2eh_xLp.mjs.map +0 -1
  71. package/dist/compiler-BaNECXMW.mjs.map +0 -1
  72. package/dist/constants-DX9yo-el.mjs.map +0 -1
  73. package/dist/load-user-imports-eGZuxeNp.mjs.map +0 -1
  74. package/dist/pool-runner-init-CEwLyNI3.d.mts.map +0 -1
  75. package/dist/resolve-config-BKjJQyy5.mjs.map +0 -1
  76. package/dist/types-8KKo9Hbf.d.mts.map +0 -1
@@ -1,8 +1,9 @@
1
- import { POOL_ERROR_NAMES } from "./constants-DX9yo-el.mjs";
2
- import { createPoolError, debug, throwPoolErrorIfAborted } from "./debug-Cf2jt1kg.mjs";
1
+ import { INTERNAL_PATH_LIB_PREFIX, POOL_ERROR_NAMES } from "./constants-DuBLuMjt.mjs";
2
+ import { createPoolError, debug, throwPoolErrorIfAborted } from "./debug-Cm1VFmaz.mjs";
3
+ import { getShortFunctionName } from "./wasm-names-CydfYzQK.mjs";
3
4
  import { createRequire } from "node:module";
4
5
  import { basename, dirname, resolve } from "node:path";
5
- import { access } from "node:fs/promises";
6
+ import { access, readFile } from "node:fs/promises";
6
7
  import { main } from "assemblyscript/asc";
7
8
  import { fileURLToPath } from "node:url";
8
9
 
@@ -17,7 +18,6 @@ import { fileURLToPath } from "node:url";
17
18
  * wrapper transforms into the final BinaryDebugInfo format (1-based columns,
18
19
  * absolute paths, grouped by file and position).
19
20
  */
20
- const DEBUG_NATIVE_ADDON = false;
21
21
  const __dirname = dirname(fileURLToPath(import.meta.url));
22
22
  const rootFromDist = resolve(__dirname, "..");
23
23
  const rootFromSrc = resolve(__dirname, "../..");
@@ -33,12 +33,21 @@ try {
33
33
  }
34
34
  }
35
35
  /**
36
- * Convert a raw location (0-indexed columns, path indexes) to
37
- * processed location (1-indexed columns, path strings)
36
+ * Convert a raw location (0-indexed columns, path indexes) to
37
+ * processed location (1-indexed columns, absolute path strings)
38
+ *
39
+ * Source map paths vary by import style and project structure:
40
+ * - Relative imports: "assembly/compare.ts"
41
+ * - Bare package imports: "~lib/vitest-pool-assemblyscript/assembly/compare.ts"
42
+ * - Source outside project root: "../assembly/compare.ts" (e.g. test-external importing parent sources)
43
+ *
44
+ * All are normalized to absolute filesystem paths for consistent coverage key matching.
38
45
  */
39
- function convertLocation(rawLocation, debugSourceFiles) {
40
- const filePath = debugSourceFiles[rawLocation.fileIndex];
46
+ function convertLocation(rawLocation, debugSourceFiles, projectRoot) {
47
+ let filePath = debugSourceFiles[rawLocation.fileIndex];
41
48
  if (!filePath) throw createPoolError(`No debug source file with index: ${rawLocation.fileIndex}}`, POOL_ERROR_NAMES.WASMInstrumentationError);
49
+ if (filePath.startsWith(INTERNAL_PATH_LIB_PREFIX)) filePath = resolve(projectRoot, "assembly", filePath.slice(INTERNAL_PATH_LIB_PREFIX.length));
50
+ else filePath = resolve(projectRoot, filePath);
42
51
  return {
43
52
  filePath,
44
53
  line: rawLocation.line,
@@ -48,14 +57,14 @@ function convertLocation(rawLocation, debugSourceFiles) {
48
57
  /**
49
58
  * Convert a raw expression to processed format
50
59
  */
51
- function convertExpression(rawExpr, debugSourceFiles) {
60
+ function convertExpression(rawExpr, debugSourceFiles, projectRoot) {
52
61
  const converted = {
53
62
  type: rawExpr.type,
54
63
  isBranch: rawExpr.isBranch
55
64
  };
56
65
  if (rawExpr.branchPaths !== void 0) converted.branchPaths = rawExpr.branchPaths;
57
66
  if (rawExpr.location) {
58
- const convertedLocation = convertLocation(rawExpr.location, debugSourceFiles);
67
+ const convertedLocation = convertLocation(rawExpr.location, debugSourceFiles, projectRoot);
59
68
  if (convertedLocation) converted.location = convertedLocation;
60
69
  }
61
70
  return converted;
@@ -71,10 +80,10 @@ function getPositionKey(location) {
71
80
  * Convert a raw function to processed format and compute position key
72
81
  * Returns undefined if function has no valid representative location
73
82
  */
74
- function convertFunction(rawFunc, debugSourceFiles) {
75
- const representativeLocation = convertLocation(rawFunc.representativeLocation, debugSourceFiles);
83
+ function convertFunction(rawFunc, debugSourceFiles, projectRoot) {
84
+ const representativeLocation = convertLocation(rawFunc.representativeLocation, debugSourceFiles, projectRoot);
76
85
  const expressions = [];
77
- if (rawFunc.expressions) for (const expr of rawFunc.expressions) expressions.push(convertExpression(expr, debugSourceFiles));
86
+ if (rawFunc.expressions) for (const expr of rawFunc.expressions) expressions.push(convertExpression(expr, debugSourceFiles, projectRoot));
78
87
  return {
79
88
  func: {
80
89
  wasmIndex: rawFunc.wasmIndex,
@@ -89,32 +98,58 @@ function convertFunction(rawFunc, debugSourceFiles) {
89
98
  };
90
99
  }
91
100
  /**
101
+ * Check if two WASM function names are monomorphizations of the same generic function.
102
+ * Generic monomorphizations share the same base name and suffix, differing only in
103
+ * the type parameters inside angle brackets.
104
+ *
105
+ * e.g. "assembly/compare/closeTo<bool\2cbool>" and "assembly/compare/closeTo<bool\2cu8>"
106
+ * e.g. "assembly/expect/BaseExpectMatcher<bool>#constructor" and "assembly/expect/BaseExpectMatcher<i8>#constructor"
107
+ */
108
+ function isGenericMonomorphizationMatch(nameA, nameB) {
109
+ const openA = nameA.indexOf("<");
110
+ const openB = nameB.indexOf("<");
111
+ if (openA === -1 || openB === -1) return false;
112
+ const lastCloseA = nameA.lastIndexOf(">");
113
+ const lastCloseB = nameB.lastIndexOf(">");
114
+ if (lastCloseA === -1 || lastCloseB === -1) return false;
115
+ if (nameA.substring(0, openA) !== nameB.substring(0, openB)) return false;
116
+ if (nameA.substring(lastCloseA + 1) !== nameB.substring(lastCloseB + 1)) return false;
117
+ return true;
118
+ }
119
+ /**
92
120
  * Transform raw native addon output to processed BinaryDebugInfo
93
121
  */
94
- function transformDebugInfo(raw, logPrefix) {
122
+ function transformDebugInfo(raw, logPrefix, projectRoot) {
95
123
  const functionsByFileAndPosition = {};
96
124
  debug(`${logPrefix} - Converting ${raw.functions.length} functions`);
97
- let positionCollisionCount = 0;
125
+ let genericCollisionCount = 0;
98
126
  let skippedCount = 0;
99
127
  let instrumentedFunctionCount = 0;
100
128
  for (const rawFunc of raw.functions) {
101
- const result = convertFunction(rawFunc, raw.debugSourceFiles);
129
+ const result = convertFunction(rawFunc, raw.debugSourceFiles, projectRoot);
102
130
  if (!result) {
103
131
  debug(`${logPrefix} - WARNING: Skipped function (bad conversion): "${rawFunc.name}"`);
104
132
  skippedCount++;
105
133
  continue;
106
134
  }
107
135
  const { func, filePath, positionKey } = result;
108
- if (functionsByFileAndPosition[filePath]?.[positionKey]) {
109
- const existing = functionsByFileAndPosition[filePath][positionKey];
110
- positionCollisionCount++;
111
- throw createPoolError(`ERROR - Function Debug Position Collision at ${filePath}:${positionKey}: "${existing.name}" will be replaced by "${func.name}"`, POOL_ERROR_NAMES.WASMInstrumentationError);
136
+ const existingAtPosition = functionsByFileAndPosition[filePath]?.[positionKey];
137
+ if (existingAtPosition) {
138
+ const existingName = existingAtPosition[0].name;
139
+ if (isGenericMonomorphizationMatch(existingName, func.name)) {
140
+ existingAtPosition.push(func);
141
+ genericCollisionCount++;
142
+ instrumentedFunctionCount++;
143
+ debug(`${logPrefix} - Generic monomorphization at ${filePath}:${positionKey}: "${getShortFunctionName(func.name)}" grouped with "${getShortFunctionName(existingName)}"`);
144
+ continue;
145
+ }
146
+ 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);
112
147
  }
113
148
  instrumentedFunctionCount++;
114
149
  if (!functionsByFileAndPosition[filePath]) functionsByFileAndPosition[filePath] = {};
115
- functionsByFileAndPosition[filePath][positionKey] = func;
150
+ functionsByFileAndPosition[filePath][positionKey] = [func];
116
151
  }
117
- debug(`${logPrefix} - BinaryDebugInfo transform complete: ${instrumentedFunctionCount} instrumented functions (${positionCollisionCount} position collisions, ${skippedCount} skipped)`);
152
+ debug(`${logPrefix} - BinaryDebugInfo transform complete: ${instrumentedFunctionCount} instrumented functions (${genericCollisionCount} generic collisions, ${skippedCount} skipped)`);
118
153
  return {
119
154
  debugSourceFiles: raw.debugSourceFiles,
120
155
  functionsByFileAndPosition,
@@ -149,14 +184,15 @@ function instrumentForCoverage(wasmBuffer, sourceMapBuffer, instrumentationOptio
149
184
  coverageMemoryPagesMax: instrumentationOptions.coverageMemoryPagesMax,
150
185
  excludedFiles: instrumentationOptions.relativeExcludedFiles,
151
186
  excludedLibraryFilePrefix: instrumentationOptions.excludedLibraryFilePrefix,
152
- debug: DEBUG_NATIVE_ADDON,
187
+ excludedLibraryFileOverridePrefix: instrumentationOptions.excludedLibraryFileOverridePrefix,
188
+ debug: instrumentationOptions.debug,
153
189
  logPrefix: nativeLogPrefix
154
190
  };
155
191
  const nativeResult = addon.instrumentForCoverage(wasmBuffer, sourceMapBuffer, options);
156
192
  const addonTime = performance.now();
157
193
  debug(`${interfaceLogPrefix} - TIMING Native addon: ${(addonTime - startTime).toFixed(2)} ms`);
158
194
  if (nativeResult.errors?.length) throw createPoolError(`Errors encountered duriing native instrumentation: ${nativeResult.errors.join("\n")}`, POOL_ERROR_NAMES.WASMInstrumentationError);
159
- const debugInfo = transformDebugInfo(nativeResult.debugInfo, interfaceLogPrefix);
195
+ const debugInfo = transformDebugInfo(nativeResult.debugInfo, interfaceLogPrefix, instrumentationOptions.projectRoot);
160
196
  debug(`${interfaceLogPrefix} - TIMING DebugInfo Transform: ${(performance.now() - addonTime).toFixed(2)} ms`);
161
197
  debug(`${interfaceLogPrefix} - Binary size: ${nativeResult.instrumentedWasm.length} bytes | Source map size: ${nativeResult.sourceMap.length * 2} bytes`);
162
198
  return {
@@ -174,6 +210,7 @@ function instrumentForCoverage(wasmBuffer, sourceMapBuffer, instrumentationOptio
174
210
  * Handles compilation of AssemblyScript source code to WASM binaries.
175
211
  * Manages compiler options, transforms, and in-memory compilation.
176
212
  */
213
+ const POOL_ASSEMBLY_NODE_MODULES_PREFIX = "node_modules/vitest-pool-assemblyscript/assembly/";
177
214
  const STRIP_INLINE_TRANSFORM = resolve(import.meta.dirname, "./compiler/transforms/strip-inline.mjs");
178
215
  setImmediate(async () => {
179
216
  try {
@@ -184,19 +221,6 @@ setImmediate(async () => {
184
221
  });
185
222
  /**
186
223
  * Compile AssemblyScript source code to WASM binary
187
- *
188
- * Features:
189
- * - In-memory compilation (binary captured via writeFile callback)
190
- * - Filesystem reading enabled (for import resolution)
191
- * - Uses stub runtime and imported memory pattern
192
- * - Exports _start function for explicit initialization control
193
- * - Always returns clean binary
194
- * - Conditionally returns instrumented binary when coverage enabled
195
- *
196
- * @param filename - Full path to the source file (used as entry point)
197
- * @param options - Compilation options (coverage mode, etc.)
198
- * @returns Compilation result with clean binary and optional instrumented binary
199
- * @throws Error if compilation fails
200
224
  */
201
225
  async function compileAssemblyScript(filename, options, logModule, logLabel, signal) {
202
226
  throwPoolErrorIfAborted(signal);
@@ -254,6 +278,22 @@ async function compileAssemblyScript(filename, options, logModule, logLabel, sig
254
278
  debug(`${logPrefix} - Captured source map in memory: "${name}"`);
255
279
  sourceMap = contents;
256
280
  } else debug(`${logPrefix} - WARNING - Captured Unexpected File: "${name}" at baseDir: "${_baseDir}"`);
281
+ },
282
+ readFile: async (filename, baseDir) => {
283
+ const filePath = resolve(baseDir, filename);
284
+ try {
285
+ return await readFile(filePath, { encoding: "utf-8" });
286
+ } catch {
287
+ if (filename.startsWith(POOL_ASSEMBLY_NODE_MODULES_PREFIX)) {
288
+ const localPath = resolve(baseDir, "assembly", filename.substring(49));
289
+ try {
290
+ return await readFile(localPath, { encoding: "utf-8" });
291
+ } catch {
292
+ return null;
293
+ }
294
+ }
295
+ return null;
296
+ }
257
297
  }
258
298
  });
259
299
  debug(`${logPrefix} - TIMING asc.main: ${(performance.now() - ascStart).toFixed(2)} ms`);
@@ -292,4 +332,4 @@ async function compileAssemblyScript(filename, options, logModule, logLabel, sig
292
332
 
293
333
  //#endregion
294
334
  export { compileAssemblyScript };
295
- //# sourceMappingURL=compiler-BaNECXMW.mjs.map
335
+ //# sourceMappingURL=compiler-CscxCJw3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler-CscxCJw3.mjs","names":["ascMain"],"sources":["../src/native-instrumentation/addon-interface.ts","../src/compiler/index.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';\nimport { debug } from '../util/debug.js';\nimport {\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} from '../types/types.js';\nimport { POOL_ERROR_NAMES, INTERNAL_PATH_LIB_PREFIX } from '../types/constants.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.\n// We run from dist/ (published) or src/ (dev/tests), so we try both root paths.\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst rootFromDist = resolve(__dirname, '..');\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 `Native addon not found. Searched from ${rootFromDist} and ${rootFromSrc}. ` +\n `Ensure prebuilds are available or run 'npm run build:native' to compile from source. ` +\n `Original error: ${err instanceof Error ? err.message : String(err)}`,\n POOL_ERROR_NAMES.WASMInstrumentationError\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 `No debug source file with index: ${rawLocation.fileIndex}}`,\n POOL_ERROR_NAMES.WASMInstrumentationError\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 = resolve(projectRoot, 'assembly', relativePart);\n } else {\n // Resolve relative path (handles both 'assembly/X.ts' and '../assembly/X.ts')\n filePath = 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 `ERROR - 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 POOL_ERROR_NAMES.WASMInstrumentationError\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 function instrumentForCoverage(\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 'instrumentForCoverage - wasmBuffer must be a Buffer',\n POOL_ERROR_NAMES.WASMInstrumentationError\n );\n }\n if (!Buffer.isBuffer(sourceMapBuffer)) {\n throw createPoolError(\n 'instrumentForCoverage - sourceMapBuffer must be a Buffer',\n POOL_ERROR_NAMES.WASMInstrumentationError\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 debug: instrumentationOptions.debug,\n logPrefix: nativeLogPrefix\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 `Errors encountered duriing native instrumentation: ${nativeResult.errors.join('\\n')}`,\n POOL_ERROR_NAMES.WASMInstrumentationError,\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","/**\n * AssemblyScript Compiler\n *\n * Handles compilation of AssemblyScript source code to WASM binaries.\n * Manages compiler options, transforms, and in-memory compilation.\n */\n\nimport { main as ascMain } from 'assemblyscript/asc';\nimport { basename, resolve } from 'node:path';\nimport { access, readFile, writeFile, mkdir } from 'node:fs/promises';\n\nimport { AssemblyScriptCompilerResult, AssemblyScriptCompilerOptions } from '../types/types.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { instrumentForCoverage } from '../native-instrumentation/addon-interface.js';\nimport { createPoolError, throwPoolErrorIfAborted } from '../util/pool-errors.js';\n\nconst DEBUG_WRITE_FILES = false;\n\n// Path prefix the AS compiler uses when resolving bare `vitest-pool-assemblyscript/assembly` imports\n// via node_modules. Used to detect self-imports and redirect to local assembly/ dir when running in-tree.\nconst POOL_ASSEMBLY_NODE_MODULES_PREFIX = 'node_modules/vitest-pool-assemblyscript/assembly/';\n\n// path assumes that we're running from dist/\nconst STRIP_INLINE_TRANSFORM = resolve(import.meta.dirname, './compiler/transforms/strip-inline.mjs');\n\nsetImmediate(async () => {\n try {\n await access(STRIP_INLINE_TRANSFORM);\n } catch {\n throw createPoolError(\n `AS Compiler strip inline transform file not found at \"${STRIP_INLINE_TRANSFORM}\"`,\n POOL_ERROR_NAMES.CompilationError\n );\n }\n});\n\n/**\n * Compile AssemblyScript source code to WASM binary\n */\nexport async function compileAssemblyScript(\n filename: string,\n options: AssemblyScriptCompilerOptions,\n logModule: string,\n logLabel: string,\n signal?: AbortSignal\n): Promise<AssemblyScriptCompilerResult> {\n throwPoolErrorIfAborted(signal);\n\n const compileStart = performance.now();\n const logPrefix = `[${logModule} ASC] ${logLabel}`;\n\n const { shouldInstrument, instrumentationOptions, extraFlags } = options;\n\n if (shouldInstrument && !instrumentationOptions) {\n throw createPoolError(\n 'Instrumentation options are required for coverage instrumentation',\n POOL_ERROR_NAMES.CompilationError\n );\n }\n\n const stdoutLines: string[] = [];\n const stderrLines: string[] = [];\n let binary: Uint8Array | undefined;\n let sourceMap: string | undefined;\n\n // Use full path as entry file so AS compiler can resolve relative imports\n const entryFile = filename;\n // Use simple output name to avoid AS compiler prepending it to source map paths\n const outputFile = 'output.wasm';\n\n debug(`${logPrefix} - Compiling: \"${filename}\"`);\n\n // Capture stdout/stderr (for potential error reporting)\n const stdout = {\n write: (text: string) => {\n stdoutLines.push(text);\n return true;\n }\n };\n\n const stderr = {\n write: (text: string) => {\n stderrLines.push(text);\n return true;\n }\n };\n\n // Build compiler flags\n const compilerFlags = [\n entryFile,\n\n // overrideable, though not recommended\n '--optimizeLevel', '0', // No optimization for easier debugging\n '--shrinkLevel', '0', // No shrink\n '--runtime', 'stub', // stub runtime (no GC)\n\n ...(extraFlags || []),\n\n // non-overrideable\n '--outFile', outputFile,\n '--importMemory', // Import memory from JS (enables imports during WASM start)\n '--debug', // Include debug info\n '--sourceMap', // Generate source maps for error reporting\n '--exportStart', '_start', // Export start function for explicit initialization control\n '--exportTable' // Export function table for direct test execution\n ];\n\n // Add transform to strip @inline decorators if requested\n // This improves coverage accuracy by preventing functions from being inlined,\n // and enables correct source-mapped error reporting for errors originating\n // inside inlined functions.\n if (options.stripInline === true) {\n compilerFlags.push(\n '--transform', STRIP_INLINE_TRANSFORM\n );\n debug(`${logPrefix} - Added Transform - Stripping @inline decorators`);\n }\n\n // Compile with AssemblyScript compiler\n const ascStart = performance.now();\n const result = await ascMain(compilerFlags, {\n stdout,\n stderr,\n // Let AS read from filesystem for import resolution\n // WASM binary and source map are captured in memory via writeFile callback\n writeFile: (name: string, contents: string | Uint8Array, _baseDir: string) => {\n throwPoolErrorIfAborted(signal);\n\n if (name.endsWith('.wasm') && contents instanceof Uint8Array) {\n binary = contents;\n debug(`${logPrefix} - Captured binary in memory: \"${name}\"`);\n } else if (name.endsWith('.wasm.map') && typeof contents === 'string') {\n debug(`${logPrefix} - Captured source map in memory: \"${name}\"`);\n sourceMap = contents;\n } else {\n debug(`${logPrefix} - WARNING - Captured Unexpected File: \"${name}\" at baseDir: \"${_baseDir}\"`);\n }\n },\n \n // Custom readFile enables in-tree resolution of bare pool assembly imports.\n // When a test file imports 'vitest-pool-assemblyscript/assembly', the AS compiler\n // resolves it to a node_modules path. This works when the package is installed,\n // but fails in-tree (the package isn't in its own node_modules). The fallback\n // redirects these to the local assembly/ directory when the normal path isn't found.\n readFile: async (filename, baseDir): Promise<string | null> => {\n const filePath = resolve(baseDir, filename);\n\n try {\n return await readFile(filePath, { encoding: 'utf-8' });\n } catch {\n // Fallback: when running in-tree, redirect pool assembly imports to local assembly/ dir\n if (filename.startsWith(POOL_ASSEMBLY_NODE_MODULES_PREFIX)) {\n const localSubpath = filename.substring(POOL_ASSEMBLY_NODE_MODULES_PREFIX.length);\n const localPath = resolve(baseDir, 'assembly', localSubpath);\n\n try {\n return await readFile(localPath, { encoding: 'utf-8' });\n } catch {\n return null;\n }\n }\n\n return null;\n }\n },\n });\n\n debug(`${logPrefix} - TIMING asc.main: ${(performance.now() - ascStart).toFixed(2)} ms`);\n\n if (result.error) {\n const errorMessage = stderrLines.length > 0\n ? `${result.error.message}\\n\\n${stderrLines.join('')}`\n : result.error.message;\n\n throw createPoolError(errorMessage, POOL_ERROR_NAMES.CompilationError, errorMessage);\n }\n\n if (!binary) {\n const errorMessage = stderrLines.length > 0\n ? `No WASM binary was generated\\n\\nAS Compiler output:\\n${stderrLines.join('')}`\n : 'No WASM binary was generated';\n\n throw createPoolError(errorMessage, POOL_ERROR_NAMES.CompilationError);\n }\n\n if (!sourceMap) {\n throw createPoolError('Source map not captured from AssemblyScript Compiler', POOL_ERROR_NAMES.CompilationError);\n }\n\n const cleanBinary: Uint8Array = binary;\n const wasmSourceMap: string = sourceMap;\n\n debug(`${logPrefix} - Compilation successful, clean binary size: ${cleanBinary.length} bytes`);\n debug(`${logPrefix} - Source map generated, size: ${wasmSourceMap.length * 2} bytes`);\n \n if (DEBUG_WRITE_FILES) {\n // Write source map for debugging\n const dir = './debug';\n // TODO - handle non-.ts extensions\n const sourceMapFileName = `${basename(filename, '.ts')}.ts.map`;\n const sourceMapPath = `${dir}/${sourceMapFileName}`;\n\n // Create directory if it doesn't exist\n try {\n await mkdir(dir, { recursive: true });\n } catch {\n // Directory already exists or creation failed, continue\n }\n\n // Format as well-formed JSON\n const formattedSourceMap = JSON.stringify(JSON.parse(wasmSourceMap), null, 2);\n\n writeFile(sourceMapPath, formattedSourceMap, { encoding: 'utf8' });\n debug(`${logPrefix} - Wrote source map to: \"${sourceMapPath}\"`);\n\n // Also write WASM binary for inspection\n const wasmPath = sourceMapPath.replace('.map', '.wasm');\n writeFile(wasmPath, cleanBinary);\n debug(`${logPrefix} - Wrote WASM binary to: \"${wasmPath}\"`);\n }\n\n // Instrument binary for coverage if requested\n if (options.shouldInstrument) {\n throwPoolErrorIfAborted(signal);\n\n const instrumentStart = performance.now();\n const wasmBuffer = Buffer.from(cleanBinary);\n const sourceMapBuffer = Buffer.from(wasmSourceMap);\n\n const instrumentResult = instrumentForCoverage(wasmBuffer, sourceMapBuffer, options.instrumentationOptions!, logModule, logLabel);\n const instCount = instrumentResult.debugInfo.instrumentedFunctionCount;\n\n const instrumentEnd = performance.now();\n debug(`${logPrefix} - TIMING Instrumented ${instCount} functions: ${(performance.now() - instrumentStart).toFixed(2)} ms`);\n\n return {\n binary: instrumentResult.instrumentedWasm,\n sourceMap: instrumentResult.sourceMap,\n debugInfo: instrumentResult.debugInfo,\n isInstrumented: true,\n compileTiming: instrumentEnd - compileStart,\n };\n }\n\n // No instrumentation requested\n return {\n binary: cleanBinary,\n sourceMap: wasmSourceMap,\n isInstrumented: false,\n compileTiming: performance.now() - compileStart,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,YAAY,QADC,cAAc,OAAO,KAAK,IAAI,CACZ;AACrC,MAAM,eAAe,QAAQ,WAAW,KAAK;AAC7C,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,yCAAyC,aAAa,OAAO,YAAY,yGAEtD,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,IACnE,iBAAiB,yBAClB;;;;;;;;;;;;;;AAeL,SAAS,gBACP,aACA,kBACA,aACgB;CAChB,IAAI,WAAW,iBAAiB,YAAY;AAE5C,KAAI,CAAC,SACH,OAAM,gBACJ,oCAAoC,YAAY,UAAU,IAC1D,iBAAiB,yBAClB;AAIH,KAAI,SAAS,WAAW,yBAAyB,CAG/C,YAAW,QAAQ,aAAa,YADX,SAAS,MAAM,yBAAyB,OAAO,CACX;KAGzD,YAAW,QAAQ,aAAa,SAAS;AAG3C,QAAO;EACL;EACA,MAAM,YAAY;EAClB,QAAQ,YAAY,SAAS;EAC9B;;;;;AAMH,SAAS,kBACP,SACA,kBACA,aACqB;CACrB,MAAM,YAAiC;EACrC,MAAM,QAAQ;EACd,UAAU,QAAQ;EACnB;AAED,KAAI,QAAQ,gBAAgB,OAC1B,WAAU,cAAc,QAAQ;AAGlC,KAAI,QAAQ,UAAU;EACpB,MAAM,oBAAoB,gBAAgB,QAAQ,UAAU,kBAAkB,YAAY;AAC1F,MAAI,kBACF,WAA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s";
2
- import "../custom-provider-options-CF5C1kXb.mjs";
1
+ import { AssemblyScriptPoolOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-DmyeERkL.mjs";
2
+ import "../custom-provider-options-i_O0OSTV.mjs";
3
3
  import { ConfigEnv, UserWorkspaceConfig, ViteUserConfig } from "vitest/config";
4
4
 
5
5
  //#region src/config/config-helpers-v3.d.ts
@@ -1,4 +1,4 @@
1
- import { AssemblyScriptPoolOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-8KKo9Hbf.mjs";
2
- import "../custom-provider-options-CF5C1kXb.mjs";
3
- import { createAssemblyScriptPool } from "../pool-runner-init-CEwLyNI3.mjs";
1
+ import { AssemblyScriptPoolOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-DmyeERkL.mjs";
2
+ import "../custom-provider-options-i_O0OSTV.mjs";
3
+ import { createAssemblyScriptPool } from "../pool-runner-init-D56aVMMD.mjs";
4
4
  export { type AssemblyScriptPoolOptions, type WasmImportsFactory, type WasmImportsFactoryInfo, createAssemblyScriptPool };
@@ -1,9 +1,9 @@
1
- import "../constants-DX9yo-el.mjs";
2
- import "../resolve-config-BKjJQyy5.mjs";
3
- import "../debug-Cf2jt1kg.mjs";
1
+ import "../constants-DuBLuMjt.mjs";
2
+ import "../resolve-config-BFNr7LW7.mjs";
3
+ import "../debug-Cm1VFmaz.mjs";
4
4
  import "../vitest-file-tasks-BUwzh375.mjs";
5
- import "../vitest-tasks-Cbri6MWZ.mjs";
5
+ import "../vitest-tasks-ByPK8DvF.mjs";
6
6
  import "../worker-rpc-channel-lbhK7Qz8.mjs";
7
- import { createAssemblyScriptPool } from "../pool-runner-init-Cdpz_B-F.mjs";
7
+ import { createAssemblyScriptPool } from "../pool-runner-init-D1QamWkS.mjs";
8
8
 
9
9
  export { createAssemblyScriptPool };
@@ -2,7 +2,7 @@
2
2
  const COVERAGE_PAYLOAD_FORMATS = { AssemblyScript: "assemblyscript" };
3
3
  /** Prefix for AssemblyScript compiler strip-inline exclusions and instrumentation exclusions */
4
4
  const ASSEMBLYSCRIPT_LIB_PREFIX = "~lib/";
5
- const INTERNAL_PATH_LIB_PREFIX = `${"~lib/"}vitest-pool-assemblyscript/`;
5
+ const INTERNAL_PATH_LIB_PREFIX = `${"~lib/"}vitest-pool-assemblyscript/assembly/`;
6
6
  /** Paths instrumentation exclusions and assetion error stack frame filtering */
7
7
  const POOL_INTERNAL_PATHS = [
8
8
  "assembly/compare.ts",
@@ -11,12 +11,12 @@ const POOL_INTERNAL_PATHS = [
11
11
  "assembly/index.ts",
12
12
  "assembly/options.ts",
13
13
  "assembly/test.ts",
14
- `${INTERNAL_PATH_LIB_PREFIX}assembly/compare.ts`,
15
- `${INTERNAL_PATH_LIB_PREFIX}assembly/describe.ts`,
16
- `${INTERNAL_PATH_LIB_PREFIX}assembly/expect.ts`,
17
- `${INTERNAL_PATH_LIB_PREFIX}assembly/index.ts`,
18
- `${INTERNAL_PATH_LIB_PREFIX}assembly/options.ts`,
19
- `${INTERNAL_PATH_LIB_PREFIX}assembly/test.ts`
14
+ `${INTERNAL_PATH_LIB_PREFIX}compare.ts`,
15
+ `${INTERNAL_PATH_LIB_PREFIX}describe.ts`,
16
+ `${INTERNAL_PATH_LIB_PREFIX}expect.ts`,
17
+ `${INTERNAL_PATH_LIB_PREFIX}index.ts`,
18
+ `${INTERNAL_PATH_LIB_PREFIX}options.ts`,
19
+ `${INTERNAL_PATH_LIB_PREFIX}test.ts`
20
20
  ];
21
21
  /** Error names for AssemblyScript test failures reported to vitest */
22
22
  const TEST_ERROR_NAMES = {
@@ -135,5 +135,5 @@ const ASSourceKind = {
135
135
  };
136
136
 
137
137
  //#endregion
138
- export { ASCommonFlags, ASDecoratorKind, ASNodeKind, ASSourceKind, COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES, POOL_INTERNAL_PATHS, TEST_ERROR_NAMES };
139
- //# sourceMappingURL=constants-DX9yo-el.mjs.map
138
+ export { ASCommonFlags, ASDecoratorKind, ASNodeKind, ASSourceKind, COVERAGE_PAYLOAD_FORMATS, INTERNAL_PATH_LIB_PREFIX, POOL_ERROR_NAMES, POOL_INTERNAL_PATHS, TEST_ERROR_NAMES };
139
+ //# sourceMappingURL=constants-DuBLuMjt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-DuBLuMjt.mjs","names":[],"sources":["../src/types/constants.ts"],"sourcesContent":["/**\n * Plain Constants\n * \n * Only things that don't require importing ./types to avoid circular dependencies.\n */\n\n\n// ============================================================================\n// General / Shared Constants\n// ============================================================================\n\nexport const ASSEMBLYSCRIPT_POOL_NAME = 'assemblyscript' as const;\n\nexport const AS_POOL_ERROR_TYPE_FLAG = '__as_pool__' as const;\n\nexport const AS_POOL_WORKER_MSG_FLAG = '__as_pool__' as const;\n\nexport const AS_POOL_WASM_IMPORTS_ENV = '__as_pool_env__' as const;\n\nexport const VITEST_WORKER_REQUEST_MSG_FLAG = '__vitest_worker_request__' as const;\n\nexport const VITEST_WORKER_RESPONSE_MSG_FLAG = '__vitest_worker_response__' as const;\n\nexport const COVERAGE_PAYLOAD_FORMATS = {\n AssemblyScript: 'assemblyscript',\n} as const;\n\n/** Prefix for AssemblyScript compiler strip-inline exclusions and instrumentation exclusions */\nexport const ASSEMBLYSCRIPT_LIB_PREFIX = '~lib/' as const;\n\nexport const INTERNAL_PATH_LIB_PREFIX: string = `${ASSEMBLYSCRIPT_LIB_PREFIX}vitest-pool-assemblyscript/assembly/` as const;\n\n/** Paths instrumentation exclusions and assetion error stack frame filtering */\nexport const POOL_INTERNAL_PATHS: string[] = [\n // AS compiler source maps these as relative paths when running locally\n 'assembly/compare.ts',\n 'assembly/describe.ts',\n 'assembly/expect.ts',\n 'assembly/index.ts',\n 'assembly/options.ts',\n 'assembly/test.ts',\n\n // AS compiler source maps these as library paths when running published version\n `${INTERNAL_PATH_LIB_PREFIX}compare.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}describe.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}expect.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}index.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}options.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}test.ts`,\n] as const;\n\n/** Error names for AssemblyScript test failures reported to vitest */\nexport const TEST_ERROR_NAMES = {\n /** Assertion evaluated to false within a test function */\n AssertionError: 'AssertionError',\n /** WASM runtime called abort after a non-planned user code error */\n WASMRuntimeError: 'WASMRuntimeError',\n} as const;\n\n/** Error names for internal AssemblyScript pool failures */\nexport const POOL_ERROR_NAMES = {\n /** AssemblyScript compiler (asc) error */\n CompilationError: 'CompilationError',\n /** Native instrumentation and debug info extraction error */\n WASMInstrumentationError: 'WASMInstrumentationError',\n /** Unexpected WASM execution error (not a known test error path) */\n WASMExecutionHarnessError: 'WASMExecutionHarnessError',\n /** Hybrid coverage provider error */\n HybridCoverageProviderError: 'HybridCoverageProviderError',\n /** vitest RPC reporting error */\n PoolReportingError: 'PoolReportingError',\n /** User configuration error */\n PoolConfigError: 'PoolConfigError',\n /** Generic AssemblyScript pool error */\n PoolError: 'PoolError',\n /** User syntax error in test/suite/expect */\n PoolSyntaxError: 'PoolSyntaxError',\n\n /** Flow Control: Indicates intentional abort */\n PoolRunAbortedError: 'PoolRunAbortedError',\n /**\n * Flow Control: Indicates WASM execution halt through abort() handler,\n * and should be handled by reporting an AssemblyScriptTestError to vitest\n */\n WASMExecutionAbortError: 'WASMExecutionAbortError',\n /** Flow Control: Indicates WASM execution halt because test timeout elapsed */\n WASMExecutionTimeoutError: 'WASMExecutionTimeoutError',\n} as const;\n\n// ============================================================================\n// AssemblyScript Compiler\n// ============================================================================\n\n// Redefined locally to avoid isolatedModules const enum access issues\n// with assemmblyscript enum exports. Reference assemblyscript.generated.d.ts\n\nexport const ASCommonFlags = {\n Static: 32,\n Get: 2048,\n Set: 4096,\n} as const;\n\nexport const ASNodeKind = {\n Source: 0,\n NamedType: 1,\n FunctionType: 2,\n TypeName: 3,\n TypeParameter: 4,\n Parameter: 5,\n Identifier: 6,\n Assertion: 7,\n Binary: 8,\n Call: 9,\n Class: 10,\n Comma: 11,\n ElementAccess: 12,\n False: 13,\n Function: 14,\n InstanceOf: 15,\n Literal: 16,\n New: 17,\n Null: 18,\n Omitted: 19,\n Parenthesized: 20,\n PropertyAccess: 21,\n Ternary: 22,\n Super: 23,\n This: 24,\n True: 25,\n Constructor: 26,\n UnaryPostfix: 27,\n UnaryPrefix: 28,\n Compiled: 29,\n Block: 30,\n Break: 31,\n Continue: 32,\n Do: 33,\n Empty: 34,\n Export: 35,\n ExportDefault: 36,\n ExportImport: 37,\n Expression: 38,\n For: 39,\n ForOf: 40,\n If: 41,\n Import: 42,\n Return: 43,\n Switch: 44,\n Throw: 45,\n Try: 46,\n Variable: 47,\n Void: 48,\n While: 49,\n Module: 50,\n ClassDeclaration: 51,\n EnumDeclaration: 52,\n EnumValueDeclaration: 53,\n FieldDeclaration: 54,\n FunctionDeclaration: 55,\n ImportDeclaration: 56,\n InterfaceDeclaration: 57,\n MethodDeclaration: 58,\n NamespaceDeclaration: 59,\n TypeDeclaration: 60,\n VariableDeclaration: 61,\n Decorator: 62,\n ExportMember: 63,\n SwitchCase: 64,\n IndexSignature: 65,\n Comment: 66,\n} as const;\n\nexport const ASDecoratorKind = {\n Custom: 0,\n Global: 1,\n Operator: 2,\n OperatorBinary: 3,\n OperatorPrefix: 4,\n OperatorPostfix: 5,\n Unmanaged: 6,\n Final: 7,\n Inline: 8,\n External: 9,\n ExternalJs: 10,\n Builtin: 11,\n Lazy: 12,\n Unsafe: 13\n} as const;\n\nexport const ASSourceKind = {\n User: 0,\n UserEntry: 1,\n Library: 2,\n LibraryEntry: 3\n} as const;\n"],"mappings":";AAuBA,MAAa,2BAA2B,EACtC,gBAAgB,kBACjB;;AAGD,MAAa,4BAA4B;AAEzC,MAAa,2BAAmC,WAA6B;;AAG7E,MAAa,sBAAgC;CAE3C;CACA;CACA;CACA;CACA;CACA;CAGA,GAAG,yBAAyB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SAAS;CACV;AAED,MAAa,kBAAkB;CAC7B,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,gBAAgB;CAChB,gBAAgB;CAChB,iBAAiB;CACjB,WAAW;CACX,OAAO;CACP,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,SAAS;CACT,MAAM;CACN,QAAQ;CACT;AAED,MAAa,eAAe;CAC1B,MAAM;CACN,WAAW;CACX,SAAS;CACT,cAAc;CACf"}
@@ -19,4 +19,4 @@ function mergeCoverageData(accumulated, incoming) {
19
19
 
20
20
  //#endregion
21
21
  export { mergeCoverageData };
22
- //# sourceMappingURL=coverage-merge-0WqdC-dq.mjs.map
22
+ //# sourceMappingURL=coverage-merge-DCEwyjMy.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"coverage-merge-0WqdC-dq.mjs","names":[],"sources":["../src/coverage-provider/coverage-merge.ts"],"sourcesContent":["/**\n * Coverage Data Merge Utilities\n *\n * Functions for merging CoverageData objects\n */\n\nimport type { CoverageData } from '../types/types.js';\n\n/**\n * Merge incoming CoverageData into accumulated CoverageData\n *\n * Combines by filepath + position, summing hit counts.\n * Mutates the accumulated object in place.\n *\n * @param accumulated - Accumulated coverage data (mutated)\n * @param incoming - New coverage data to merge in\n */\nexport function mergeCoverageData(\n accumulated: CoverageData,\n incoming: CoverageData\n): void {\n for (const [filePath, positions] of Object.entries(incoming.hitCountsByFileAndPosition)) {\n // Ensure file exists in accumulated\n if (!accumulated.hitCountsByFileAndPosition[filePath]) {\n accumulated.hitCountsByFileAndPosition[filePath] = {};\n }\n\n const accumulatedPositions = accumulated.hitCountsByFileAndPosition[filePath];\n\n for (const [positionKey, hitCount] of Object.entries(positions)) {\n if (accumulatedPositions[positionKey] !== undefined) {\n // Position exists - sum hit counts\n accumulatedPositions[positionKey] += hitCount;\n } else {\n // New position - set hit count\n accumulatedPositions[positionKey] = hitCount;\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,kBACd,aACA,UACM;AACN,MAAK,MAAM,CAAC,UAAU,cAAc,OAAO,QAAQ,SAAS,2BAA2B,EAAE;AAEvF,MAAI,CAAC,YAAY,2BAA2B,UAC1C,aAAY,2BAA2B,YAAY,EAAE;EAGvD,MAAM,uBAAuB,YAAY,2BAA2B;AAEpE,OAAK,MAAM,CAAC,aAAa,aAAa,OAAO,QAAQ,UAAU,CAC7D,KAAI,qBAAqB,iBAAiB,OAExC,sBAAqB,gBAAgB;MAGrC,sBAAqB,eAAe"}
1
+ {"version":3,"file":"coverage-merge-DCEwyjMy.mjs","names":[],"sources":["../src/coverage-provider/coverage-merge.ts"],"sourcesContent":["/**\n * Coverage Data Merge Utilities\n *\n * Functions for merging CoverageData objects\n */\n\nimport type { CoverageData } from '../types/types.js';\n\n/**\n * Merge incoming CoverageData into accumulated CoverageData\n *\n * Combines by filepath + position, summing hit counts.\n * Mutates the accumulated object in place.\n *\n * @param accumulated - Accumulated coverage data (mutated)\n * @param incoming - New coverage data to merge in\n */\nexport function mergeCoverageData(\n accumulated: CoverageData,\n incoming: CoverageData\n): void {\n for (const [filePath, positions] of Object.entries(incoming.hitCountsByFileAndPosition)) {\n // Ensure file exists in accumulated\n if (!accumulated.hitCountsByFileAndPosition[filePath]) {\n accumulated.hitCountsByFileAndPosition[filePath] = {};\n }\n\n const accumulatedPositions = accumulated.hitCountsByFileAndPosition[filePath];\n\n for (const [positionKey, hitCount] of Object.entries(positions)) {\n if (accumulatedPositions[positionKey] !== undefined) {\n // Position exists - sum hit counts\n accumulatedPositions[positionKey] += hitCount;\n } else {\n // New position - set hit count\n accumulatedPositions[positionKey] = hitCount;\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,kBACd,aACA,UACM;AACN,MAAK,MAAM,CAAC,UAAU,cAAc,OAAO,QAAQ,SAAS,2BAA2B,EAAE;AAEvF,MAAI,CAAC,YAAY,2BAA2B,UAC1C,aAAY,2BAA2B,YAAY,EAAE;EAGvD,MAAM,uBAAuB,YAAY,2BAA2B;AAEpE,OAAK,MAAM,CAAC,aAAa,aAAa,OAAO,QAAQ,UAAU,CAC7D,KAAI,qBAAqB,iBAAiB,OAExC,sBAAqB,gBAAgB;MAGrC,sBAAqB,eAAe"}
@@ -1,15 +1,16 @@
1
- import { ASCommonFlags, ASNodeKind, COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES } from "../constants-DX9yo-el.mjs";
2
- import { getProjectSerializedOrGlobalConfig } from "../resolve-config-BKjJQyy5.mjs";
3
- import { createPoolError, debug } from "../debug-Cf2jt1kg.mjs";
4
- import { mergeCoverageData } from "../coverage-merge-0WqdC-dq.mjs";
5
- import { ASTVisitor } from "../ast-visitor-lTahoS9R.mjs";
1
+ import { ASCommonFlags, ASNodeKind, COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES } from "../constants-DuBLuMjt.mjs";
2
+ import { getProjectSerializedOrGlobalConfig } from "../resolve-config-BFNr7LW7.mjs";
3
+ import { createPoolError, debug, debugOverride } from "../debug-Cm1VFmaz.mjs";
4
+ import { warnIfASCoverageNotSupported } from "../node-check-CooGQMLH.mjs";
5
+ import { mergeCoverageData } from "../coverage-merge-DCEwyjMy.mjs";
6
+ import { ASTVisitor } from "../ast-visitor-DJLJd5dt.mjs";
6
7
  import { basename, parse, relative } from "node:path";
7
8
  import { readFile } from "node:fs/promises";
8
9
  import v8CoverageModule from "@vitest/coverage-v8";
9
10
  import istanbulCoverage from "istanbul-lib-coverage";
10
11
  import { Parser } from "assemblyscript";
11
- import { resolve as resolve$1 } from "path";
12
- import TestExclude from "test-exclude";
12
+ import { relative as relative$1 } from "path";
13
+ import { globSync } from "tinyglobby";
13
14
 
14
15
  //#region src/coverage-provider/containment-matcher.ts
15
16
  /**
@@ -59,7 +60,6 @@ function isPositionInRange(line, column, range) {
59
60
 
60
61
  //#endregion
61
62
  //#region src/coverage-provider/istanbul-converter.ts
62
- function istanbulDebug(...args) {}
63
63
  /**
64
64
  * Convert AssemblyScript coverage data to Istanbul format for a single file
65
65
  *
@@ -78,8 +78,11 @@ function istanbulDebug(...args) {}
78
78
  * @param absoluteFilePath - Absolute path to the source file (for Istanbul output)
79
79
  * @returns Istanbul FileCoverage object
80
80
  */
81
- async function convertToIstanbulFormat(fileFunctionsByStartLine, fileHitCountsByPosition, absoluteFilePath) {
81
+ async function convertToIstanbulFormat(fileFunctionsByStartLine, fileHitCountsByPosition, absoluteFilePath, istanbulDebugEnabled) {
82
82
  const startMatch = performance.now();
83
+ function istanbulDebug(...args) {
84
+ if (istanbulDebugEnabled) debugOverride(...args);
85
+ }
83
86
  istanbulDebug(() => {
84
87
  const sourceFunctionCount = Object.values(fileFunctionsByStartLine).reduce((sum, funcs) => sum + funcs.length, 0);
85
88
  const uniqueHitPosCount = Object.keys(fileHitCountsByPosition).length;
@@ -318,31 +321,31 @@ async function parseFunctionsFromFile(absoluteSourceFilePath, relativeSourceFile
318
321
  /**
319
322
  * Glob Utilities for Coverage
320
323
  *
321
- * Uses test-exclude (same as Vitest's v8 coverage provider) to glob
322
- * AssemblyScript files matching coverage.include patterns.
324
+ * Uses tinyglobby to glob AssemblyScript files matching coverage include/exclude patterns.
325
+ * Supports ../ path traversals for projects that import source from outside the project root.
326
+ *
327
+ * Note: tinyglobby docs warn of a performance cost when globbing outside cwd (e.g. ../ patterns)
328
+ * due to recalculating relative paths. Acceptable here since this runs once at startup.
323
329
  */
330
+ const NODE_MODULES_GLOB = "**/node_modules/**";
324
331
  /**
325
332
  * Glob files matching coverage include/exclude patterns
326
333
  *
327
- * Uses test-exclude for consistent behavior with Vitest's built-in
328
- * coverage providers.
329
- *
330
334
  * @param include - Include patterns (e.g., ['assembly/**\/*.ts'])
331
335
  * @param exclude - Exclude patterns (e.g., ['**\/*.test.ts'])
332
336
  * @param projectRoot - Project root directory
333
- * @returns Array of absolute file paths
337
+ * @returns Array of glob results with absolute and project-root-relative paths
334
338
  */
335
339
  function globFiles(include, exclude, projectRoot) {
336
340
  if (include.length === 0) return [];
337
- return new TestExclude({
341
+ return globSync(include, {
338
342
  cwd: projectRoot,
339
- include,
340
- exclude,
341
- excludeNodeModules: true
342
- }).globSync(projectRoot).map((file) => ({
343
- absolute: resolve$1(projectRoot, file),
344
- projectRootRelative: file
345
- })) || [];
343
+ ignore: [NODE_MODULES_GLOB, ...exclude],
344
+ absolute: true
345
+ }).map((absolute) => ({
346
+ absolute,
347
+ projectRootRelative: relative$1(projectRoot, absolute)
348
+ }));
346
349
  }
347
350
 
348
351
  //#endregion
@@ -373,6 +376,7 @@ var HybridCoverageProvider = class {
373
376
  await this.v8Provider.initialize(ctx);
374
377
  this.v8Provider.name = "hybrid-assemblyscript-v8 (delegated v8 reporter)";
375
378
  debug("[HybridCoverageProvider] Initialized with delegated v8 provider");
379
+ warnIfASCoverageNotSupported();
376
380
  }
377
381
  /**
378
382
  * Handle suite completion - delegate based on coverage format marker
@@ -429,9 +433,9 @@ var HybridCoverageProvider = class {
429
433
  debug(`[HybridCoverageProvider] Parsing AS source for expected coverage: "${include.absolute}" (file key: "${include.projectRootRelative}")`);
430
434
  const functionsByStartLine = await parseFunctionsFromFile(include.absolute, include.projectRootRelative) || {};
431
435
  debug(`[HybridCoverageProvider] Parsed ${Object.keys(functionsByStartLine).length} AS source functions in "${include.projectRootRelative}"`);
432
- const fileHitCountsByPosition = this.accumulatedCoverageData.hitCountsByFileAndPosition[include.projectRootRelative] ?? {};
433
- debug(`[HybridCoverageProvider] Accumulated AS coverage has ${Object.keys(fileHitCountsByPosition).length} positions for "${include.projectRootRelative}"`);
434
- return convertToIstanbulFormat(functionsByStartLine, fileHitCountsByPosition, include.absolute);
436
+ const fileHitCountsByPosition = this.accumulatedCoverageData.hitCountsByFileAndPosition[include.absolute] ?? {};
437
+ debug(`[HybridCoverageProvider] Accumulated AS coverage has ${Object.keys(fileHitCountsByPosition).length} positions for "${include.absolute}"`);
438
+ return convertToIstanbulFormat(functionsByStartLine, fileHitCountsByPosition, include.absolute, this.coverageOptions.debugIstanbul);
435
439
  });
436
440
  const istanbulResults = await Promise.all(fileProcessingPromises);
437
441
  for (const istanbulData of istanbulResults) asCoverageMap.addFileCoverage(istanbulData);
@@ -443,8 +447,10 @@ var HybridCoverageProvider = class {
443
447
  const jsCoverage = await this.v8Provider.generateCoverage(context);
444
448
  debug(`[HybridCoverageProvider] JS coverage has ${Object.keys(jsCoverage.data).length} files`);
445
449
  debug(`[HybridCoverageProvider] TIMING JS generateCoverage: ${(performance.now() - asGenerateEnd).toFixed(2)} ms`);
446
- debug("[HybridCoverageProvider] Merging AS coverage into JS coverage");
447
- jsCoverage.merge(asCoverageMap);
450
+ if (asCoverageMap.files().length) {
451
+ debug("[HybridCoverageProvider] Merging AS coverage into JS coverage");
452
+ jsCoverage.merge(asCoverageMap.toJSON());
453
+ } else debug("[HybridCoverageProvider] AS coverage map empty, not merging into JS coverage");
448
454
  debug(`[HybridCoverageProvider] Final merged coverage has ${Object.keys(jsCoverage.data).length} files`);
449
455
  debug(`[HybridCoverageProvider] TIMING Total generateCoverage: ${(performance.now() - start).toFixed(2)} ms`);
450
456
  return jsCoverage;
@@ -483,6 +489,7 @@ var HybridCoverageProvider = class {
483
489
  ...resolvedV8Options,
484
490
  provider: "custom",
485
491
  customProviderModule: definedCoverageOptions.customProviderModule,
492
+ debugIstanbul: definedCoverageOptions.debugIstanbul ?? false,
486
493
  assemblyScriptInclude: definedCoverageOptions.assemblyScriptInclude ?? [],
487
494
  assemblyScriptExclude: definedCoverageOptions.assemblyScriptExclude ?? [],
488
495
  globbedAssemblyScriptInclude,