vitest-pool-assemblyscript 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +3 -3
  2. package/dist/{addon-interface-DJB-K27u.mjs → addon-interface-BaUmn7uC.mjs} +2 -2
  3. package/dist/{addon-interface-DJB-K27u.mjs.map → addon-interface-BaUmn7uC.mjs.map} +1 -1
  4. package/dist/{compile-runner-D4SJWhMh.mjs → compile-runner-BGYyiUEf.mjs} +5 -5
  5. package/dist/{compile-runner-D4SJWhMh.mjs.map → compile-runner-BGYyiUEf.mjs.map} +1 -1
  6. package/dist/{compiler-DSKhQ5--.mjs → compiler-CXR5UJId.mjs} +4 -4
  7. package/dist/{compiler-DSKhQ5--.mjs.map → compiler-CXR5UJId.mjs.map} +1 -1
  8. package/dist/config/index-v3.d.mts +1 -1
  9. package/dist/config/index.d.mts +2 -2
  10. package/dist/config/index.mjs +3 -3
  11. package/dist/coverage-provider/index.mjs +2 -2
  12. package/dist/coverage-provider/index.mjs.map +1 -1
  13. package/dist/{feature-check-DLfJqIrE.mjs → feature-check-BJpc4LoO.mjs} +3 -3
  14. package/dist/{feature-check-DLfJqIrE.mjs.map → feature-check-BJpc4LoO.mjs.map} +1 -1
  15. package/dist/index-internal.d.mts +1 -1
  16. package/dist/index-internal.mjs +3 -3
  17. package/dist/index-v3.mjs +2 -2
  18. package/dist/index.d.mts +1 -1
  19. package/dist/index.mjs +3 -3
  20. package/dist/{load-user-imports-6Pv-9hRg.mjs → load-user-imports-iAQUMKAi.mjs} +22 -9
  21. package/dist/load-user-imports-iAQUMKAi.mjs.map +1 -0
  22. package/dist/{pool-errors-GWfwrsD7.mjs → pool-errors-Bn6YaguR.mjs} +4 -5
  23. package/dist/pool-errors-Bn6YaguR.mjs.map +1 -0
  24. package/dist/{pool-runner-init-CCvnKt5o.d.mts → pool-runner-init-CPQL6pVL.d.mts} +2 -2
  25. package/dist/pool-runner-init-CPQL6pVL.d.mts.map +1 -0
  26. package/dist/{pool-runner-init-Cta6aVJ6.mjs → pool-runner-init-CSJt3dHv.mjs} +3 -3
  27. package/dist/{pool-runner-init-Cta6aVJ6.mjs.map → pool-runner-init-CSJt3dHv.mjs.map} +1 -1
  28. package/dist/pool-thread/compile-worker-thread.d.mts +1 -1
  29. package/dist/pool-thread/compile-worker-thread.mjs +6 -6
  30. package/dist/pool-thread/test-worker-thread.d.mts +1 -1
  31. package/dist/pool-thread/test-worker-thread.mjs +5 -5
  32. package/dist/pool-thread/v3-tinypool-thread.d.mts +1 -1
  33. package/dist/pool-thread/v3-tinypool-thread.mjs +7 -7
  34. package/dist/{test-runner-M21HMDdH.mjs → test-runner-BDcm8vg0.mjs} +4 -4
  35. package/dist/{test-runner-M21HMDdH.mjs.map → test-runner-BDcm8vg0.mjs.map} +1 -1
  36. package/dist/{types-CoroKYxB.d.mts → types-CRbjiCC7.d.mts} +2 -2
  37. package/dist/{types-CoroKYxB.d.mts.map → types-CRbjiCC7.d.mts.map} +1 -1
  38. package/dist/{vitest-file-tasks-Coc4btUw.mjs → vitest-file-tasks-BBsZ_wS6.mjs} +5 -3
  39. package/dist/vitest-file-tasks-BBsZ_wS6.mjs.map +1 -0
  40. package/package.json +17 -10
  41. package/prebuilds/darwin-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  42. package/prebuilds/darwin-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  43. package/prebuilds/win32-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  44. package/prebuilds/win32-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  45. package/dist/load-user-imports-6Pv-9hRg.mjs.map +0 -1
  46. package/dist/pool-errors-GWfwrsD7.mjs.map +0 -1
  47. package/dist/pool-runner-init-CCvnKt5o.d.mts.map +0 -1
  48. package/dist/vitest-file-tasks-Coc4btUw.mjs.map +0 -1
package/README.md CHANGED
@@ -95,7 +95,7 @@ npm install -D vitest vitest-pool-assemblyscript assemblyscript
95
95
 
96
96
  Create or update `vitest.config.ts`. See the [Configuration Guide](docs/configuration-guide.md) for all supported vitest options, pool options, coverage configuration, and multi-project setups.
97
97
 
98
- **vitest 4.x:**
98
+ **vitest 5.x & 4.x:**
99
99
  ```typescript
100
100
  import { defineConfig } from 'vitest/config';
101
101
  import { createAssemblyScriptPool } from 'vitest-pool-assemblyscript/config';
@@ -161,7 +161,7 @@ npx vitest run
161
161
  - Works with Vitest UI, reporters, and coverage tools
162
162
  - Project (workspace) config allows coexisting AssemblyScript pools and JavaScript pools
163
163
  - Hybrid Coverage Provider unifies test reports (`html`, `lcov`, `json`, etc) from multiple pools (delegates to v8 provider for JS coverage)
164
- - Supports vitest 3.x and 4.x
164
+ - Supports vitest 3.2.x, 4.x, and 5.x
165
165
 
166
166
  ### Per-Test WASM Isolation
167
167
  - Each AssemblyScript test **file** is compiled to a WASM binary
@@ -277,7 +277,7 @@ The overall goal is tight vitest experience integration - most CLI commands, rep
277
277
  | Dependency | Supported Versions |
278
278
  |---|---|
279
279
  | Node.js | (20*), 22, 24+ |
280
- | Vitest | 3.2.x, 4.x.x |
280
+ | Vitest | 3.2.x, 4.x.x, 5.x.x |
281
281
  | AssemblyScript | 0.28.9+ ([more?](#frequently-asked-questions)) |
282
282
 
283
283
  >ℹ️ ***Node 20 Support:** If you don't need code coverage, Node 20 should continue to work for test execution.
@@ -1,5 +1,5 @@
1
1
  import { INTERNAL_PATH_LIB_PREFIX, POOL_ERROR_NAMES } from "./constants-Bq5KNxXJ.mjs";
2
- import { createPoolError, debug, getShortFunctionName, toForwardSlash } from "./pool-errors-GWfwrsD7.mjs";
2
+ import { createPoolError, debug, getShortFunctionName, toForwardSlash } from "./pool-errors-Bn6YaguR.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { dirname, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
@@ -204,4 +204,4 @@ const instrumentForCoverage = (wasmBuffer, sourceMapBuffer, instrumentationOptio
204
204
 
205
205
  //#endregion
206
206
  export { instrumentForCoverage };
207
- //# sourceMappingURL=addon-interface-DJB-K27u.mjs.map
207
+ //# sourceMappingURL=addon-interface-BaUmn7uC.mjs.map
@@ -1 +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":";;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WAAW;EACX,sBAAsB,uBAAuB;EAC7C,oBAAoB,uBAAuB;EAC5C;CACD,MAAM,eAA4C,MAAM,sBAAsB,YAAY,iBAAiB,QAAQ;CACnH,MAAM,YAAY,YAAY,KAAK;AACnC,OAAM,GAAG,mBAAmB,2BAA2B,YAAY,WAAW,QAAQ,EAAE,CAAC,KAAK;AAE9F,KAAI,aAAa,QAAQ,OACvB,OAAM,gBACJ,iBAAiB,0BACjB,sDAAsD,aAAa,OAAO,KAAK,KAAK,GACrF;CAGH,MAAM,YAAY,mBAAmB,aAAa,WAAW,oBAAoB,uBAAuB,YAAY;AAGpH,OAAM,GAAG,mBAAmB,kCADN,YAAY,KAAK,GACuC,WAAW,QAAQ,EAAE,CAAC,KAAK;AACzG,OAAM,GAAG,mBAAmB,kBAAkB,aAAa,iBAAiB,OAAO,4BAA4B,aAAa,UAAU,SAAS,EAAE,QAAQ;AAEzJ,QAAO;EACL,kBAAkB,aAAa;EAC/B,WAAW,aAAa;EACxB;EACD"}
1
+ {"version":3,"file":"addon-interface-BaUmn7uC.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,YAAW,eAAe,QAAQ,aAAa,S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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";
2
+ import { failFile, getFullTaskHierarchy, getTaskLogLabel, getTaskLogPrefix, prepareFileTaskForCollection } from "./vitest-file-tasks-BBsZ_wS6.mjs";
3
+ import { buildEnhancedFileError, debug, toForwardSlash } from "./pool-errors-Bn6YaguR.mjs";
4
+ import { executeWASMDiscovery, flushRpcUpdates, reportFileCollected, reportFileError, reportFileQueued, reportUserConsoleLogs } from "./load-user-imports-iAQUMKAi.mjs";
5
+ import { compileAssemblyScript } from "./compiler-CXR5UJId.mjs";
6
6
  import { basename, relative } from "node:path";
7
7
 
8
8
  //#region src/pool-thread/runner/compile-runner.ts
@@ -79,4 +79,4 @@ async function runCompileAndDiscover(file, logModule, rpc, asPoolOptions, projec
79
79
 
80
80
  //#endregion
81
81
  export { runCompileAndDiscover };
82
- //# sourceMappingURL=compile-runner-D4SJWhMh.mjs.map
82
+ //# sourceMappingURL=compile-runner-BGYyiUEf.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-runner-D4SJWhMh.mjs","names":[],"sources":["../src/pool-thread/runner/compile-runner.ts"],"sourcesContent":["/**\n * Worker thread test runner logic for AssemblyScript Pool\n */\n\nimport { basename, relative } from 'node:path';\nimport type { File } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\n\nimport type {\n AssemblyScriptCompilerOptions,\n AssemblyScriptConsoleLog,\n AssemblyScriptConsoleLogHandler,\n InstrumentationOptions,\n ResolvedAssemblyScriptPoolOptions,\n ThreadImports,\n WASMCompilation,\n WorkerRPC,\n} from '../../types/types.js';\nimport {\n AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME,\n AS_POOL_WASM_IMPORTS_MODULE_NAME,\n ASSEMBLYSCRIPT_LIB_PREFIX,\n INTERNAL_FUNCTION_NAME_SUBSTRING,\n INTERNAL_PATH_LIB_PREFIX,\n POOL_INTERNAL_PATHS,\n} from '../../types/constants.js';\nimport { executeWASMDiscovery } from '../../wasm-executor/index.js';\nimport { debug } from '../../util/debug.js';\nimport { toForwardSlash } from '../../util/path-utils.js';\nimport {\n reportFileQueued,\n reportFileCollected,\n reportUserConsoleLogs,\n flushRpcUpdates,\n reportFileError,\n} from '../rpc-reporter.js';\nimport { compileAssemblyScript } from '../../compiler/index.js';\nimport { getTaskLogLabel, getTaskLogPrefix } from '../../util/vitest-tasks.js';\nimport {\n failFile,\n getFullTaskHierarchy,\n prepareFileTaskForCollection,\n} from '../../util/vitest-file-tasks.js';\nimport { buildEnhancedFileError } from '../../util/pool-errors.js';\n\nlet threadCompilationCount: number = 0;\n\nexport async function runCompileAndDiscover(\n file: File,\n logModule: string,\n rpc: WorkerRPC,\n asPoolOptions: ResolvedAssemblyScriptPoolOptions,\n projectRoot: string,\n collectCoverage: boolean,\n relativeUserCoverageExclusions: string[],\n threadImports: ThreadImports,\n diffOptions?: SerializedDiffOptions,\n testNamePattern?: RegExp,\n allowOnly?: boolean,\n): Promise<WASMCompilation | undefined> {\n const base = basename(file.filepath);\n const fileLogPrefix = getTaskLogPrefix(logModule, base, file);\n const fileLogLabel = getTaskLogLabel(base, file);\n\n debug(`${fileLogPrefix} - Beginning runCompileAndDiscover for \"${file.filepath}\" at ${Date.now()}`);\n\n let compilation: WASMCompilation | undefined;\n let reportedQueued: boolean = false;\n \n const runStartPerf = performance.now();\n\n try {\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n reportedQueued = true;\n\n const relativeTestFilePath = toForwardSlash(relative(projectRoot, file.filepath));\n const instrumentationOptions: InstrumentationOptions = {\n projectRoot,\n relativeExcludedFiles: [\n relativeTestFilePath,\n ...(asPoolOptions._instrumentPoolInternals ? [] : POOL_INTERNAL_PATHS),\n ...relativeUserCoverageExclusions,\n ],\n excludedLibraryFilePrefix: ASSEMBLYSCRIPT_LIB_PREFIX,\n excludedLibraryFileOverridePrefix: asPoolOptions._instrumentPoolInternals ? INTERNAL_PATH_LIB_PREFIX : undefined,\n excludedInternalFunctionSubstring: INTERNAL_FUNCTION_NAME_SUBSTRING,\n coverageMemoryPagesMin: asPoolOptions.coverageMemoryPagesInitial ?? 1,\n coverageMemoryPagesMax: asPoolOptions.coverageMemoryPagesMax,\n debug: asPoolOptions.debugNative,\n coverageMemoryModule: AS_POOL_WASM_IMPORTS_MODULE_NAME,\n coverageMemoryName: AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME\n };\n const compilerOptions: AssemblyScriptCompilerOptions = {\n stripInline: asPoolOptions.stripInline,\n projectRoot,\n shouldInstrument: collectCoverage,\n instrumentationOptions,\n extraFlags: asPoolOptions.extraCompilerFlags\n };\n\n compilation = await compileAssemblyScript(\n file.filepath,\n compilerOptions,\n logModule,\n fileLogLabel\n );\n file.setupDuration = compilation.compileTiming;\n threadCompilationCount++;\n\n debug(`${fileLogPrefix} - TIMING compileAssemblyScript total `\n + `(thread comp # ${threadCompilationCount}): ${compilation.compileTiming.toFixed(2)} ms`\n );\n \n const logMessages: AssemblyScriptConsoleLog[] = [];\n const handleLog: AssemblyScriptConsoleLogHandler = (msg: string, isError: boolean = false): void => {\n logMessages.push({ msg, time: Date.now(), isError });\n };\n \n const discoverStartPerf = performance.now();\n\n await executeWASMDiscovery(\n compilation,\n asPoolOptions,\n collectCoverage,\n handleLog,\n file,\n logModule,\n threadImports,\n );\n\n // set skips when using only and/or user test name pattern, skip file task if all tests skipped\n prepareFileTaskForCollection(file, testNamePattern, allowOnly);\n\n file.collectDuration = performance.now() - discoverStartPerf;\n debug(`${fileLogPrefix} - TIMING Discovery Phase: ${file.collectDuration.toFixed(2)} ms`);\n\n // vitest collect - report discovery results\n await Promise.all([\n // Report user console logs\n reportUserConsoleLogs(rpc, logMessages, logModule, base, file),\n\n // Report onCollected with collected and filtered tasks\n reportFileCollected(rpc, file, logModule, fileLogLabel),\n ]);\n\n debug(() => `${fileLogPrefix} - Collected Test Suite Hierarchy:\\n${getFullTaskHierarchy(file)}`);\n\n const totalTime = performance.now() - runStartPerf;\n debug(`${fileLogPrefix} - TIMING Compilation and Discovery: ${totalTime.toFixed(2)} ms`);\n } catch (error) {\n const testError = await buildEnhancedFileError(\n error,\n file,\n compilation?.sourceMap,\n fileLogPrefix,\n projectRoot,\n 'compile runner',\n diffOptions\n );\n\n failFile(file, testError, runStartPerf);\n\n if (!reportedQueued) {\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n }\n await reportFileError(rpc, file, logModule, fileLogLabel);\n\n debug(`${fileLogPrefix} - runCompileAndDiscover - Reported file error:`, testError);\n } finally {\n await flushRpcUpdates(rpc);\n debug(`${fileLogPrefix} - runCompileAndDiscover Completed`);\n }\n\n return compilation;\n}\n"],"mappings":";;;;;;;;;;;AA6CA,IAAI,yBAAiC;AAErC,eAAsB,sBACpB,MACA,WACA,KACA,eACA,aACA,iBACA,gCACA,eACA,aACA,iBACA,WACsC;CACtC,MAAM,OAAO,SAAS,KAAK,SAAS;CACpC,MAAM,gBAAgB,iBAAiB,WAAW,MAAM,KAAK;CAC7D,MAAM,eAAe,gBAAgB,MAAM,KAAK;AAEhD,OAAM,GAAG,cAAc,0CAA0C,KAAK,SAAS,OAAO,KAAK,KAAK,GAAG;CAEnG,IAAI;CACJ,IAAI,iBAA0B;CAE9B,MAAM,eAAe,YAAY,KAAK;AAEtC,KAAI;AACF,QAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;AAC1D,mBAAiB;EAGjB,MAAM,yBAAiD;GACrD;GACA,uBAAuB;IAHI,eAAe,SAAS,aAAa,KAAK,SAAS,CAAC;IAK7E,GAAI,cAAc,2BAA2B,EAAE,GAAG;IAClD,GAAG;IACJ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zD,QAAM,GAAG,cAAc,kDAAkD,UAAU;WAC3E;AACR,QAAM,gBAAgB,IAAI;AAC1B,QAAM,GAAG,cAAc,oCAAoC;;AAG7D,QAAO"}
1
+ {"version":3,"file":"compile-runner-BGYyiUEf.mjs","names":[],"sources":["../src/pool-thread/runner/compile-runner.ts"],"sourcesContent":["/**\n * Worker thread test runner logic for AssemblyScript Pool\n */\n\nimport { basename, relative } from 'node:path';\nimport type { File } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\n\nimport type {\n AssemblyScriptCompilerOptions,\n AssemblyScriptConsoleLog,\n AssemblyScriptConsoleLogHandler,\n InstrumentationOptions,\n ResolvedAssemblyScriptPoolOptions,\n ThreadImports,\n WASMCompilation,\n WorkerRPC,\n} from '../../types/types.js';\nimport {\n AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME,\n AS_POOL_WASM_IMPORTS_MODULE_NAME,\n ASSEMBLYSCRIPT_LIB_PREFIX,\n INTERNAL_FUNCTION_NAME_SUBSTRING,\n INTERNAL_PATH_LIB_PREFIX,\n POOL_INTERNAL_PATHS,\n} from '../../types/constants.js';\nimport { executeWASMDiscovery } from '../../wasm-executor/index.js';\nimport { debug } from '../../util/debug.js';\nimport { toForwardSlash } from '../../util/path-utils.js';\nimport {\n reportFileQueued,\n reportFileCollected,\n reportUserConsoleLogs,\n flushRpcUpdates,\n reportFileError,\n} from '../rpc-reporter.js';\nimport { compileAssemblyScript } from '../../compiler/index.js';\nimport { getTaskLogLabel, getTaskLogPrefix } from '../../util/vitest-tasks.js';\nimport {\n failFile,\n getFullTaskHierarchy,\n prepareFileTaskForCollection,\n} from '../../util/vitest-file-tasks.js';\nimport { buildEnhancedFileError } from '../../util/pool-errors.js';\n\nlet threadCompilationCount: number = 0;\n\nexport async function runCompileAndDiscover(\n file: File,\n logModule: string,\n rpc: WorkerRPC,\n asPoolOptions: ResolvedAssemblyScriptPoolOptions,\n projectRoot: string,\n collectCoverage: boolean,\n relativeUserCoverageExclusions: string[],\n threadImports: ThreadImports,\n diffOptions?: SerializedDiffOptions,\n testNamePattern?: RegExp,\n allowOnly?: boolean,\n): Promise<WASMCompilation | undefined> {\n const base = basename(file.filepath);\n const fileLogPrefix = getTaskLogPrefix(logModule, base, file);\n const fileLogLabel = getTaskLogLabel(base, file);\n\n debug(`${fileLogPrefix} - Beginning runCompileAndDiscover for \"${file.filepath}\" at ${Date.now()}`);\n\n let compilation: WASMCompilation | undefined;\n let reportedQueued: boolean = false;\n \n const runStartPerf = performance.now();\n\n try {\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n reportedQueued = true;\n\n const relativeTestFilePath = toForwardSlash(relative(projectRoot, file.filepath));\n const instrumentationOptions: InstrumentationOptions = {\n projectRoot,\n relativeExcludedFiles: [\n relativeTestFilePath,\n ...(asPoolOptions._instrumentPoolInternals ? [] : POOL_INTERNAL_PATHS),\n ...relativeUserCoverageExclusions,\n ],\n excludedLibraryFilePrefix: ASSEMBLYSCRIPT_LIB_PREFIX,\n excludedLibraryFileOverridePrefix: asPoolOptions._instrumentPoolInternals ? INTERNAL_PATH_LIB_PREFIX : undefined,\n excludedInternalFunctionSubstring: INTERNAL_FUNCTION_NAME_SUBSTRING,\n coverageMemoryPagesMin: asPoolOptions.coverageMemoryPagesInitial ?? 1,\n coverageMemoryPagesMax: asPoolOptions.coverageMemoryPagesMax,\n debug: asPoolOptions.debugNative,\n coverageMemoryModule: AS_POOL_WASM_IMPORTS_MODULE_NAME,\n coverageMemoryName: AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME\n };\n const compilerOptions: AssemblyScriptCompilerOptions = {\n stripInline: asPoolOptions.stripInline,\n projectRoot,\n shouldInstrument: collectCoverage,\n instrumentationOptions,\n extraFlags: asPoolOptions.extraCompilerFlags\n };\n\n compilation = await compileAssemblyScript(\n file.filepath,\n compilerOptions,\n logModule,\n fileLogLabel\n );\n file.setupDuration = compilation.compileTiming;\n threadCompilationCount++;\n\n debug(`${fileLogPrefix} - TIMING compileAssemblyScript total `\n + `(thread comp # ${threadCompilationCount}): ${compilation.compileTiming.toFixed(2)} ms`\n );\n \n const logMessages: AssemblyScriptConsoleLog[] = [];\n const handleLog: AssemblyScriptConsoleLogHandler = (msg: string, isError: boolean = false): void => {\n logMessages.push({ msg, time: Date.now(), isError });\n };\n \n const discoverStartPerf = performance.now();\n\n await executeWASMDiscovery(\n compilation,\n asPoolOptions,\n collectCoverage,\n handleLog,\n file,\n logModule,\n threadImports,\n );\n\n // set skips when using only and/or user test name pattern, skip file task if all tests skipped\n prepareFileTaskForCollection(file, testNamePattern, allowOnly);\n\n file.collectDuration = performance.now() - discoverStartPerf;\n debug(`${fileLogPrefix} - TIMING Discovery Phase: ${file.collectDuration.toFixed(2)} ms`);\n\n // vitest collect - report discovery results\n await Promise.all([\n // Report user console logs\n reportUserConsoleLogs(rpc, logMessages, logModule, base, file),\n\n // Report onCollected with collected and filtered tasks\n reportFileCollected(rpc, file, logModule, fileLogLabel),\n ]);\n\n debug(() => `${fileLogPrefix} - Collected Test Suite Hierarchy:\\n${getFullTaskHierarchy(file)}`);\n\n const totalTime = performance.now() - runStartPerf;\n debug(`${fileLogPrefix} - TIMING Compilation and Discovery: ${totalTime.toFixed(2)} ms`);\n } catch (error) {\n const testError = await buildEnhancedFileError(\n error,\n file,\n compilation?.sourceMap,\n fileLogPrefix,\n projectRoot,\n 'compile runner',\n diffOptions\n );\n\n failFile(file, testError, runStartPerf);\n\n if (!reportedQueued) {\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n }\n await reportFileError(rpc, file, logModule, fileLogLabel);\n\n debug(`${fileLogPrefix} - runCompileAndDiscover - Reported file error:`, testError);\n } finally {\n await flushRpcUpdates(rpc);\n debug(`${fileLogPrefix} - runCompileAndDiscover Completed`);\n }\n\n return compilation;\n}\n"],"mappings":";;;;;;;;;;;AA6CA,IAAI,yBAAiC;AAErC,eAAsB,sBACpB,MACA,WACA,KACA,eACA,aACA,iBACA,gCACA,eACA,aAC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K;AAGzF,QAAM,QAAQ,IAAI,CAEhB,sBAAsB,KAAK,aAAa,WAAW,MAAM,KAAK,EAG9D,oBAAoB,KAAK,MAAM,WAAW,aAAa,CACxD,CAAC;AAEF,cAAY,GAAG,cAAc,sCAAsC,qBAAqB,KAAK,GAAG;AAGhG,QAAM,GAAG,cAAc,wCADL,YAAY,KAAK,GAAG,cACkC,QAAQ,EAAE,CAAC,KAAK;UACjF,OAAO;EACd,MAAM,YAAY,MAAM,uBACtB,OACA,MACA,aAAa,WACb,eACA,aACA,kBACA,YACD;AAED,WAAS,MAAM,WAAW,aAAa;AAEvC,MAAI,CAAC,eACH,OAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;AAE5D,QAAM,gBAAgB,KAAK,MAAM,WAAW,aAAa;AAEzD,QAAM,GAAG,cAAc,kDAAkD,UAAU;WAC3E;AACR,QAAM,gBAAgB,IAAI;AAC1B,QAAM,GAAG,cAAc,oCAAoC;;AAG7D,QAAO"}
@@ -1,7 +1,7 @@
1
1
  import { POOL_ERROR_NAMES } from "./constants-Bq5KNxXJ.mjs";
2
- import { createPoolError, debug, parseSourceMap, toForwardSlash } from "./pool-errors-GWfwrsD7.mjs";
2
+ import { createPoolError, debug, parseSourceMap, toForwardSlash } from "./pool-errors-Bn6YaguR.mjs";
3
3
  import { getWasmMemoryRequirements } from "./wasm-memory-C8Nkl2Sz.mjs";
4
- import { clearNativeBuildError, hasNativeBuildError, warnASInstrumentationNotLoaded } from "./feature-check-DLfJqIrE.mjs";
4
+ import { clearNativeBuildError, hasNativeBuildError, warnASInstrumentationNotLoaded } from "./feature-check-BJpc4LoO.mjs";
5
5
  import { basename, resolve } from "node:path";
6
6
  import { access, readFile } from "node:fs/promises";
7
7
  import { main } from "assemblyscript/asc";
@@ -15,7 +15,7 @@ import { main } from "assemblyscript/asc";
15
15
  */
16
16
  let nativeAddon;
17
17
  try {
18
- nativeAddon = await import("./addon-interface-DJB-K27u.mjs");
18
+ nativeAddon = await import("./addon-interface-BaUmn7uC.mjs");
19
19
  clearNativeBuildError();
20
20
  } catch (err) {
21
21
  if (await hasNativeBuildError()) debug(`[Compiler] Native instrumentation addon not loaded (known build failure): ${err?.message ?? String(err)}`);
@@ -182,4 +182,4 @@ async function compileAssemblyScript(filename, options, logModule, logLabel) {
182
182
 
183
183
  //#endregion
184
184
  export { compileAssemblyScript };
185
- //# sourceMappingURL=compiler-DSKhQ5--.mjs.map
185
+ //# sourceMappingURL=compiler-CXR5UJId.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler-DSKhQ5--.mjs","names":["ascMain"],"sources":["../src/compiler/index.ts"],"sourcesContent":["/**\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';\nimport type { RawSourceMap } from 'source-map';\n\nimport type {\n AssemblyScriptCompilerOptions,\n NativeAddonInterface,\n BinaryDebugInfo,\n WASMModuleMemoryRequirements,\n WASMCompilation\n} from '../types/types.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport { clearNativeBuildError, hasNativeBuildError, warnASInstrumentationNotLoaded } from '../util/feature-check.js';\nimport { toForwardSlash } from '../util/path-utils.js';\nimport { parseSourceMap } from '../wasm-executor/source-maps.js';\nimport { getWasmMemoryRequirements } from '../wasm-executor/wasm-memory.js';\n\nlet nativeAddon: NativeAddonInterface | undefined;\ntry {\n nativeAddon = await import('../instrumentation/addon-interface.js');\n // Addon loaded successfully — clear any stale build error marker (fire and forget)\n clearNativeBuildError();\n} catch (err: any) {\n const knownBuildFailure = await hasNativeBuildError();\n if (knownBuildFailure) {\n // Marker file exists — coverage provider will warn the user, just debug log here\n debug(`[Compiler] Native instrumentation addon not loaded (known build failure): ${err?.message ?? String(err)}`);\n } else {\n // Unexpected failure — no marker file, warn the user\n warnASInstrumentationNotLoaded(err?.message ?? String(err));\n }\n}\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 locally in-tree.\nconst POOL_ASSEMBLY_NODE_MODULES_PREFIX = 'node_modules/vitest-pool-assemblyscript/assembly/';\n\n// paths assume that we're running from dist/\nconst STRIP_INLINE_TRANSFORM = resolve(import.meta.dirname, './compiler/transforms/strip-inline.mjs');\nconst DEEP_EQUALS_TRANSFORM = resolve(import.meta.dirname, './compiler/transforms/deep-equals.mjs');\n\nsetImmediate(async () => {\n try {\n await access(STRIP_INLINE_TRANSFORM);\n } catch {\n throw createPoolError(\n POOL_ERROR_NAMES.CompilationError,\n `AS Compiler strip inline transform file not found at \"${STRIP_INLINE_TRANSFORM}\"`,\n );\n }\n\n try {\n await access(DEEP_EQUALS_TRANSFORM);\n } catch {\n throw createPoolError(\n POOL_ERROR_NAMES.CompilationError,\n `AS Compiler deep equals transform file not found at \"${DEEP_EQUALS_TRANSFORM}\"`,\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): Promise<WASMCompilation> {\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 POOL_ERROR_NAMES.CompilationError,\n 'Instrumentation options are required for coverage instrumentation',\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 // Injects deep equality comparison method into user-defined classes for toEqual support\n '--transform', DEEP_EQUALS_TRANSFORM,\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 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 const normalizedFilename = toForwardSlash(filename);\n if (normalizedFilename.startsWith(POOL_ASSEMBLY_NODE_MODULES_PREFIX)) {\n const localSubpath = normalizedFilename.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(\n POOL_ERROR_NAMES.CompilationError,\n errorMessage\n );\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(\n POOL_ERROR_NAMES.CompilationError,\n errorMessage\n );\n }\n\n if (!sourceMap) {\n throw createPoolError(\n POOL_ERROR_NAMES.CompilationError,\n 'Source map not captured from AssemblyScript Compiler'\n );\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 let compilationBinary: Uint8Array = cleanBinary;\n let compilationSourceMap: string = wasmSourceMap;\n let compilationDebugInfo: BinaryDebugInfo | undefined;\n let compilationIsInstrumented: boolean = false;\n \n // Instrument binary for coverage if requested and available\n if (options.shouldInstrument && nativeAddon) {\n const instrumentStart = performance.now();\n const wasmBuffer = Buffer.from(cleanBinary);\n const sourceMapBuffer = Buffer.from(wasmSourceMap);\n\n const instrumentResult = nativeAddon.instrumentForCoverage(wasmBuffer, sourceMapBuffer, options.instrumentationOptions!, logModule, logLabel);\n const instCount = instrumentResult.debugInfo.instrumentedFunctionCount;\n\n debug(`${logPrefix} - TIMING Instrumented ${instCount} functions: ${(performance.now() - instrumentStart).toFixed(2)} ms`);\n\n compilationBinary = instrumentResult.instrumentedWasm;\n compilationSourceMap = instrumentResult.sourceMap;\n compilationDebugInfo = instrumentResult.debugInfo;\n compilationIsInstrumented = true;\n }\n\n let parsedSourceMap: RawSourceMap;\n let compiledModule: WebAssembly.Module;\n let requiredMemory: WASMModuleMemoryRequirements;\n\n try {\n const s = performance.now();\n parsedSourceMap = parseSourceMap(compilationSourceMap);\n\n debug(`${logPrefix} - TIMING compileAssemblyScript - parseSourceMap:`\n + `${(performance.now() - s).toFixed(2)} ms`\n );\n } catch (error) {\n throw createPoolError(POOL_ERROR_NAMES.CompilationError, 'Error parsing WASM compilation source map', error, true);\n }\n \n try {\n const s = performance.now();\n compiledModule = await WebAssembly.compile(compilationBinary as BufferSource);\n\n debug(`${logPrefix} - TIMING compileAssemblyScript - WebAssembly.compile:`\n + `${(performance.now() - s).toFixed(2)} ms`\n );\n } catch (error) {\n throw createPoolError(POOL_ERROR_NAMES.CompilationError, 'Error running WebAssembly.compile on asc-compiled WASM binary', error, true);\n }\n\n try {\n const s = performance.now();\n requiredMemory = getWasmMemoryRequirements(compilationBinary);\n\n debug(`${logPrefix} - TIMING compileAssemblyScript - getWasmMemoryRequirements:`\n + `${(performance.now() - s).toFixed(2)} ms`\n );\n debug(`${logPrefix} - Required Memory:`, JSON.stringify(requiredMemory));\n } catch (error) {\n throw createPoolError(POOL_ERROR_NAMES.CompilationError, 'Error extracting memory requirements from asc-compiled WASM binary', error, true);\n }\n\n return {\n filePath: filename,\n sourceMap: parsedSourceMap,\n debugInfo: compilationDebugInfo,\n compiledModule,\n requiredMemory,\n isInstrumented: compilationIsInstrumented,\n compileTiming: performance.now() - compileStart,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,IAAI;AACJ,IAAI;AACF,eAAc,MAAM,OAAO;AAE3B,wBAAuB;SAChB,KAAU;AAEjB,KAD0B,MAAM,qBAAqB,CAGnD,OAAM,6EAA6E,KAAK,WAAW,OAAO,IAAI,GAAG;KAGjH,gCAA+B,KAAK,WAAW,OAAO,IAAI,CAAC;;AAQ/D,MAAM,oCAAoC;AAG1C,MAAM,yBAAyB,QAAQ,OAAO,KAAK,SAAS,yCAAyC;AACrG,MAAM,wBAAwB,QAAQ,OAAO,KAAK,SAAS,wCAAwC;AAEnG,aAAa,YAAY;AACvB,KAAI;AACF,QAAM,OAAO,uBAAuB;SAC9B;AACN,QAAM,gBACJ,iBAAiB,kBACjB,yDAAyD,uBAAuB,GACjF;;AAGH,KAAI;AACF,QAAM,OAAO,sBAAsB;SAC7B;AACN,QAAM,gBACJ,iBAAiB,kBACjB,wDAAwD,sBAAsB,GA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wBAAyB,WAAW,SAAS;EAC7I,MAAM,YAAY,iBAAiB,UAAU;AAE7C,QAAM,GAAG,UAAU,yBAAyB,UAAU,eAAe,YAAY,KAAK,GAAG,iBAAiB,QAAQ,EAAE,CAAC,KAAK;AAE1H,sBAAoB,iBAAiB;AACrC,yBAAuB,iBAAiB;AACxC,yBAAuB,iBAAiB;AACxC,8BAA4B;;CAG9B,IAAI;CACJ,IAAI;CACJ,IAAI;AAEJ,KAAI;EACF,MAAM,IAAI,YAAY,KAAK;AAC3B,oBAAkB,eAAe,qBAAqB;AAEtD,QAAM,GAAG,UAAU,oDACX,YAAY,KAAK,GAAG,GAAG,QAAQ,EAAE,CAAC,KACzC;UACM,OAAO;AACd,QAAM,gBAAgB,iBAAiB,kBAAkB,6CAA6C,OAAO,KAAK;;AAGpH,KAAI;EACF,MAAM,IAAI,YAAY,KAAK;AAC3B,mBAAiB,MAAM,YAAY,QAAQ,kBAAkC;AAE7E,QAAM,GAAG,UAAU,yDACX,YAAY,KAAK,GAAG,GAAG,QAAQ,EAAE,CAAC,KACzC;UACM,OAAO;AACd,QAAM,gBAAgB,iBAAiB,kBAAkB,iEAAiE,OAAO,KAAK;;AAGxI,KAAI;EACF,MAAM,IAAI,YAAY,KAAK;AAC3B,mBAAiB,0BAA0B,kBAAkB;AAE7D,QAAM,GAAG,UAAU,+DACX,YAAY,KAAK,GAAG,GAAG,QAAQ,EAAE,CAAC,KACzC;AACD,QAAM,GAAG,UAAU,sBAAsB,KAAK,UAAU,eAAe,CAAC;UACjE,OAAO;AACd,QAAM,gBAAgB,iBAAiB,kBAAkB,sEAAsE,OAAO,KAAK;;AAG7I,QAAO;EACL,UAAU;EACV,WAAW;EACX,WAAW;EACX;EACA;EACA,gBAAgB;EAChB,eAAe,YAAY,KAAK,GAAG;EACpC"}
1
+ {"version":3,"file":"compiler-CXR5UJId.mjs","names":["ascMain"],"sources":["../src/compiler/index.ts"],"sourcesContent":["/**\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';\nimport type { RawSourceMap } from 'source-map';\n\nimport type {\n AssemblyScriptCompilerOptions,\n NativeAddonInterface,\n BinaryDebugInfo,\n WASMModuleMemoryRequirements,\n WASMCompilation\n} from '../types/types.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport { clearNativeBuildError, hasNativeBuildError, warnASInstrumentationNotLoaded } from '../util/feature-check.js';\nimport { toForwardSlash } from '../util/path-utils.js';\nimport { parseSourceMap } from '../wasm-executor/source-maps.js';\nimport { getWasmMemoryRequirements } from '../wasm-executor/wasm-memory.js';\n\nlet nativeAddon: NativeAddonInterface | undefined;\ntry {\n nativeAddon = await import('../instrumentation/addon-interface.js');\n // Addon loaded successfully — clear any stale build error marker (fire and forget)\n clearNativeBuildError();\n} catch (err: any) {\n const knownBuildFailure = await hasNativeBuildError();\n if (knownBuildFailure) {\n // Marker file exists — coverage provider will warn the user, just debug log here\n debug(`[Compiler] Native instrumentation addon not loaded (known build failure): ${err?.message ?? String(err)}`);\n } else {\n // Unexpected failure — no marker file, warn the user\n warnASInstrumentationNotLoaded(err?.message ?? String(err));\n }\n}\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 locally in-tree.\nconst POOL_ASSEMBLY_NODE_MODULES_PREFIX = 'node_modules/vitest-pool-assemblyscript/assembly/';\n\n// paths assume that we're running from dist/\nconst STRIP_INLINE_TRANSFORM = resolve(import.meta.dirname, './compiler/transforms/strip-inline.mjs');\nconst DEEP_EQUALS_TRANSFORM = resolve(import.meta.dirname, './compiler/transforms/deep-equals.mjs');\n\nsetImmediate(async () => {\n try {\n await access(STRIP_INLINE_TRANSFORM);\n } catch {\n throw createPoolError(\n POOL_ERROR_NAMES.CompilationError,\n `AS Compiler strip inline transform file not found at \"${STRIP_INLINE_TRANSFORM}\"`,\n );\n }\n\n try {\n await access(DEEP_EQUALS_TRANSFORM);\n } catch {\n throw createPoolError(\n POOL_ERROR_NAMES.CompilationError,\n `AS Compiler deep equals transform file not found at \"${DEEP_EQUALS_TRANSFORM}\"`,\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): Promise<WASMCompilation> {\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 POOL_ERROR_NAMES.CompilationError,\n 'Instrumentation options are required for coverage instrumentation',\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 // Injects deep equality comparison method into user-defined classes for toEqual support\n '--transform', DEEP_EQUALS_TRANSFORM,\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 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 const normalizedFilename = toForwardSlash(filename);\n if (normalizedFilename.startsWith(POOL_ASSEMBLY_NODE_MODULES_PREFIX)) {\n const localSubpath = normalizedFilename.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(\n POOL_ERROR_NAMES.CompilationError,\n errorMessage\n );\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(\n POOL_ERROR_NAMES.CompilationError,\n errorMessage\n );\n }\n\n if (!sourceMap) {\n throw createPoolError(\n POOL_ERROR_NAMES.CompilationError,\n 'Source map not captured from AssemblyScript Compiler'\n );\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 let compilationBinary: Uint8Array = cleanBinary;\n let compilationSourceMap: string = wasmSourceMap;\n let compilationDebugInfo: BinaryDebugInfo | undefined;\n let compilationIsInstrumented: boolean = false;\n \n // Instrument binary for coverage if requested and available\n if (options.shouldInstrument && nativeAddon) {\n const instrumentStart = performance.now();\n const wasmBuffer = Buffer.from(cleanBinary);\n const sourceMapBuffer = Buffer.from(wasmSourceMap);\n\n const instrumentResult = nativeAddon.instrumentForCoverage(wasmBuffer, sourceMapBuffer, options.instrumentationOptions!, logModule, logLabel);\n const instCount = instrumentResult.debugInfo.instrumentedFunctionCount;\n\n debug(`${logPrefix} - TIMING Instrumented ${instCount} functions: ${(performance.now() - instrumentStart).toFixed(2)} ms`);\n\n compilationBinary = instrumentResult.instrumentedWasm;\n compilationSourceMap = instrumentResult.sourceMap;\n compilationDebugInfo = instrumentResult.debugInfo;\n compilationIsInstrumented = true;\n }\n\n let parsedSourceMap: RawSourceMap;\n let compiledModule: WebAssembly.Module;\n let requiredMemory: WASMModuleMemoryRequirements;\n\n try {\n const s = performance.now();\n parsedSourceMap = parseSourceMap(compilationSourceMap);\n\n debug(`${logPrefix} - TIMING compileAssemblyScript - parseSourceMap:`\n + `${(performance.now() - s).toFixed(2)} ms`\n );\n } catch (error) {\n throw createPoolError(POOL_ERROR_NAMES.CompilationError, 'Error parsing WASM compilation source map', error, true);\n }\n \n try {\n const s = performance.now();\n compiledModule = await WebAssembly.compile(compilationBinary as BufferSource);\n\n debug(`${logPrefix} - TIMING compileAssemblyScript - WebAssembly.compile:`\n + `${(performance.now() - s).toFixed(2)} ms`\n );\n } catch (error) {\n throw createPoolError(POOL_ERROR_NAMES.CompilationError, 'Error running WebAssembly.compile on asc-compiled WASM binary', error, true);\n }\n\n try {\n const s = performance.now();\n requiredMemory = getWasmMemoryRequirements(compilationBinary);\n\n debug(`${logPrefix} - TIMING compileAssemblyScript - getWasmMemoryRequirements:`\n + `${(performance.now() - s).toFixed(2)} ms`\n );\n debug(`${logPrefix} - Required Memory:`, JSON.stringify(requiredMemory));\n } catch (error) {\n throw createPoolError(POOL_ERROR_NAMES.CompilationError, 'Error extracting memory requirements from asc-compiled WASM binary', error, true);\n }\n\n return {\n filePath: filename,\n sourceMap: parsedSourceMap,\n debugInfo: compilationDebugInfo,\n compiledModule,\n requiredMemory,\n isInstrumented: compilationIsInstrumented,\n compileTiming: performance.now() - compileStart,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,IAAI;AACJ,IAAI;AACF,eAAc,MAAM,OAAO;AAE3B,wBAAuB;SAChB,KAAU;AAEjB,KAD0B,MAAM,qBAAqB,CAGnD,OAAM,6EAA6E,KAAK,WAAW,OAAO,IAAI,GAAG;KAGjH,gCAA+B,KAAK,WAAW,OAAO,IAAI,CAAC;;AAQ/D,MAAM,oCAAoC;AAG1C,MAAM,yBAAyB,QAAQ,OAAO,KAAK,SAAS,yCAAyC;AACrG,MAAM,wBAAwB,QAAQ,OAAO,KAAK,SAAS,wCAAwC;AAEnG,aAAa,YAAY;AACvB,KAAI;AACF,QAAM,OAAO,uBAAuB;SAC9B;AACN,QAAM,gBACJ,iBAAiB,kBACjB,yDAAyD,uBAAuB,GACjF;;AAGH,KAAI;AACF,QAAM,OAAO,sBAAsB;SAC7B;AACN,QAAM,gBACJ,iBAAiB,kBACjB,wDAAwD,sBAAsB,GAC/E;;EAEH;;;;AAKF,eAAsB,sBACpB,UACA,SACA,WACA,UAC0B;CAC1B,MAAM,eAAe,YAAY,KAAK;CACtC,MAAM,YAAY,IAAI,UAAU,QAAQ;CAExC,MAAM,EAAE,kBAAkB,wBAAwB,eAAe;AAEjE,KAAI,oBAAoB,CAAC,uBACvB,OAAM,gBACJ,iBAAiB,kBACjB,oEACD;CAGH,MAAM,cAAwB,EAAE;CAChC,MAAM,cAAwB,EAAE;CAChC,IAAI;CACJ,IAAI;CAGJ,MAAM,YAAY;CAElB,MAAM,aAAa;AAEnB,OAAM,GAAG,UAAU,iBAAiB,SAAS,GAAG;CAGhD,MAAM,SAAS,EACb,QAAQ,SAAiB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OAAO;AACd,QAAM,gBAAgB,iBAAiB,kBAAkB,6CAA6C,OAAO,KAAK;;AAGpH,KAAI;EACF,MAAM,IAAI,YAAY,KAAK;AAC3B,mBAAiB,MAAM,YAAY,QAAQ,kBAAkC;AAE7E,QAAM,GAAG,UAAU,yDACX,YAAY,KAAK,GAAG,GAAG,QAAQ,EAAE,CAAC,KACzC;UACM,OAAO;AACd,QAAM,gBAAgB,iBAAiB,kBAAkB,iEAAiE,OAAO,KAAK;;AAGxI,KAAI;EACF,MAAM,IAAI,YAAY,KAAK;AAC3B,mBAAiB,0BAA0B,kBAAkB;AAE7D,QAAM,GAAG,UAAU,+DACX,YAAY,KAAK,GAAG,GAAG,QAAQ,EAAE,CAAC,KACzC;AACD,QAAM,GAAG,UAAU,sBAAsB,KAAK,UAAU,eAAe,CAAC;UACjE,OAAO;AACd,QAAM,gBAAgB,iBAAiB,kBAAkB,sEAAsE,OAAO,KAAK;;AAG7I,QAAO;EACL,UAAU;EACV,WAAW;EACX,WAAW;EACX;EACA;EACA,gBAAgB;EAChB,eAAe,YAAY,KAAK,GAAG;EACpC"}
@@ -1,4 +1,4 @@
1
- import { AssemblyScriptPoolOptions, HybridProviderOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-CoroKYxB.mjs";
1
+ import { AssemblyScriptPoolOptions, HybridProviderOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-CRbjiCC7.mjs";
2
2
  import { CoverageV8Options } from "vitest/node";
3
3
  import { ConfigEnv, UserWorkspaceConfig, ViteUserConfig } from "vitest/config";
4
4
 
@@ -1,5 +1,5 @@
1
- import { AssemblyScriptPoolOptions, HybridProviderOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-CoroKYxB.mjs";
2
- import { createAssemblyScriptPool } from "../pool-runner-init-CCvnKt5o.mjs";
1
+ import { AssemblyScriptPoolOptions, HybridProviderOptions, WasmImportsFactory, WasmImportsFactoryInfo } from "../types-CRbjiCC7.mjs";
2
+ import { createAssemblyScriptPool } from "../pool-runner-init-CPQL6pVL.mjs";
3
3
 
4
4
  //#region src/config/coverage-options.d.ts
5
5
  /**
@@ -1,7 +1,7 @@
1
1
  import "../constants-Bq5KNxXJ.mjs";
2
- import "../vitest-file-tasks-Coc4btUw.mjs";
3
- import "../pool-errors-GWfwrsD7.mjs";
2
+ import "../vitest-file-tasks-BBsZ_wS6.mjs";
3
+ import "../pool-errors-Bn6YaguR.mjs";
4
4
  import "../worker-rpc-channel-CvCrc8aa.mjs";
5
- import { createAssemblyScriptPool } from "../pool-runner-init-Cta6aVJ6.mjs";
5
+ import { createAssemblyScriptPool } from "../pool-runner-init-CSJt3dHv.mjs";
6
6
 
7
7
  export { createAssemblyScriptPool };
@@ -1,6 +1,6 @@
1
1
  import { ASCommonFlags, ASNodeKind, COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES } from "../constants-Bq5KNxXJ.mjs";
2
- import { createPoolError, debug, debugOverride, toForwardSlash } from "../pool-errors-GWfwrsD7.mjs";
3
- import { warnIfASCoverageNotSupportedByNode, warnIfNativeBuildFailed } from "../feature-check-DLfJqIrE.mjs";
2
+ import { createPoolError, debug, debugOverride, toForwardSlash } from "../pool-errors-Bn6YaguR.mjs";
3
+ import { warnIfASCoverageNotSupportedByNode, warnIfNativeBuildFailed } from "../feature-check-BJpc4LoO.mjs";
4
4
  import { mergeCoverageData } from "../coverage-merge-0WqdC-dq.mjs";
5
5
  import { ASTVisitor } from "../ast-visitor-w1HMbuJR.mjs";
6
6
  import { Parser } from "assemblyscript";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["parsePath","AssemblyScriptParser"],"sources":["../../src/coverage-provider/containment-matcher.ts","../../src/coverage-provider/istanbul-converter.ts","../../src/coverage-provider/ast-parser.ts","../../src/coverage-provider/glob-utils.ts","../../src/coverage-provider/hybrid-coverage-provider.ts","../../src/coverage-provider/index.ts"],"sourcesContent":["/**\n * Containment Matcher\n *\n * Provides containment-based matching for coverage mapping.\n * Binary debug info provides points (representativeLocation), source parsing provides ranges.\n * We find which source range contains each binary point.\n *\n * Usage by version:\n * - v1: Function containment matching (binary representativeLocation → source function range)\n * - v2: Function containment (same) + statement containment + branch path containment\n *\n * Why containment matching (not direct position lookup):\n * AS compiler generates source map entries differently by statement type:\n * - Variable declarations: source map points to statement start (keyword)\n * - Control flow (if/switch/for): source map points to condition EXPRESSION, not keyword\n *\n * Example: `if (n < 0)` → binary reports column 7 ('n'), not column 3 ('i' of 'if')\n *\n * Containment matching is more robust:\n * - Binary gives us a position (representativeLocation) somewhere in the function\n * - Source gives us function ranges (start/end line/column)\n * - We find which source function range contains the binary position\n * - Handles nested functions with \"tightest fit\" (innermost function wins)\n */\n\nimport type { ParsedSourceFunctionInfo, SourceRange } from '../types/types.js';\n\n/**\n * Functions indexed by file path, then by start line.\n * Multiple functions can start on the same line (e.g., nested arrow functions).\n */\nexport type FunctionsByFileAndStartLine = Record<string, Record<number, ParsedSourceFunctionInfo[]>>;\n\n/**\n * Find the source function whose range contains the given position.\n *\n * For nested functions, uses \"tightest fit\" - returns the innermost function\n * (the one with the largest start position among all containing functions).\n *\n * @param functionsByStartLine - Functions for a single file, indexed by start line\n * @param line - Target line number (1-based)\n * @param column - Target column number (1-based)\n * @returns The containing function, or undefined if no match\n */\nexport function findFunctionContainingPosition(\n functionsByStartLine: Record<number, ParsedSourceFunctionInfo[]>,\n line: number,\n column: number\n): ParsedSourceFunctionInfo | undefined {\n let bestMatch: ParsedSourceFunctionInfo | undefined;\n let bestStartLine = -1;\n let bestStartColumn = -1;\n\n // Check functions starting on lines <= target line\n for (const [startLineStr, functions] of Object.entries(functionsByStartLine)) {\n const startLine = Number(startLineStr);\n if (startLine > line) continue;\n\n for (const func of functions) {\n const { range } = func;\n\n // Check if position is within this function's range\n if (!isPositionInRange(line, column, range)) continue;\n\n // Tightest fit: prefer function with largest start position (innermost)\n if (startLine > bestStartLine ||\n (startLine === bestStartLine && range.startColumn > bestStartColumn)) {\n bestMatch = func;\n bestStartLine = startLine;\n bestStartColumn = range.startColumn;\n }\n }\n }\n\n return bestMatch;\n}\n\n/**\n * Check if a position (line, column) falls within a source range.\n *\n * @param line - Target line number (1-based)\n * @param column - Target column number (1-based)\n * @param range - Source range to check against\n * @returns true if position is within range (inclusive)\n */\nexport function isPositionInRange(\n line: number,\n column: number,\n range: SourceRange\n): boolean {\n // Outside line range entirely\n if (line < range.startLine || line > range.endLine) return false;\n\n // On start line but before start column\n if (line === range.startLine && column < range.startColumn) return false;\n\n // On end line but after end column\n if (line === range.endLine && column > range.endColumn) return false;\n\n return true;\n}\n","/**\n * Istanbul Format Converter\n *\n * Converts AssemblyScript coverage data to Istanbul's FileCoverageData format.\n * This enables integration with Vitest's coverage reporting system and standard\n * coverage tools like Codecov, Coveralls, etc.\n *\n * Current Implementation: Function-level coverage only\n * - Uses containment matching: binary positions → source function ranges\n * - Each function maps to both a function entry AND a statement entry\n * - Statement coverage matches function coverage (function-level granularity)\n * - Branch coverage is 0% (no branches tracked yet)\n * - Line coverage derived from statement coverage\n *\n * Future Enhancement (v2): Block-level statement and branch coverage\n */\n\nimport type { FileCoverageData, Range, FunctionMapping, BranchMapping } from 'istanbul-lib-coverage';\nimport type { ParsedSourceFunctionInfo } from '../types/types.js';\nimport { findFunctionContainingPosition } from './containment-matcher.js';\nimport { debugOverride } from '../util/debug.js';\n\n/**\n * Convert AssemblyScript coverage data to Istanbul format for a single file\n *\n * Algorithm (containment matching):\n * 1. For each hit position in fileHitCountsByPosition:\n * - Use containment matcher to find which source function contains this position\n * - Record the hit count for that function\n * 2. For each function in fileFunctionsByStartLine:\n * - Add function mapping to fnMap\n * - Add function hit count to f (from matched hits, or 0 if not hit)\n * - Add corresponding statement mapping to statementMap\n * - Add same hit count to s (statement coverage matches function coverage)\n *\n * @param fileFunctionsByStartLine - Functions for this file, keyed by start line (from AST parser)\n * @param fileHitCountsByPosition - Hit counts for this file, keyed by position \"line:column\" (from accumulated coverage)\n * @param absoluteFilePath - Absolute path to the source file (for Istanbul output)\n * @returns Istanbul FileCoverage object\n */\nexport async function convertToIstanbulFormat(\n fileFunctionsByStartLine: Record<number, ParsedSourceFunctionInfo[]>,\n fileHitCountsByPosition: Record<string, number>,\n absoluteFilePath: string,\n istanbulDebugEnabled: boolean\n): Promise<FileCoverageData> {\n const startMatch = performance.now();\n\n function istanbulDebug(...args: any[]): void {\n if (istanbulDebugEnabled) {\n debugOverride(...args);\n }\n };\n\n istanbulDebug(() => {\n const sourceFunctionCount = Object.values(fileFunctionsByStartLine).reduce((sum, funcs) => sum + funcs.length, 0);\n const uniqueHitPosCount = Object.keys(fileHitCountsByPosition).length;\n const coverageEstimate = sourceFunctionCount === 0 ? Infinity : ((uniqueHitPosCount * 100) / sourceFunctionCount).toFixed(2);\n\n return `[IstanbulConverter] Processing source file: \"${absoluteFilePath}\"\\n`\n + `[IstanbulConverter] Source: ${sourceFunctionCount} total functions, Coverage: ${uniqueHitPosCount} unique hit positions\\n`\n + `[IstanbulConverter] Sanity Check - AS File Coverage Estimate: ${coverageEstimate}%\\n`\n + `[IstanbulConverter] Containment matching functions: coverage hit positions to source functions by range`;\n });\n\n // Build a map of function → hit count using containment matching\n // Key: function source identity (qualifiedName), Value: hit count\n const hitCountsBySourceFunctionName = new Map<ParsedSourceFunctionInfo, number>();\n\n // For each hit position, find which function contains it\n for (const [positionKey, hitCount] of Object.entries(fileHitCountsByPosition)) {\n // Position key format is \"line:column\"\n const parts = positionKey.split(':');\n const lineStr = parts[0];\n const columnStr = parts[1];\n\n if (lineStr && columnStr) {\n const line = parseInt(lineStr, 10);\n const column = parseInt(columnStr, 10);\n\n const containingFunction = findFunctionContainingPosition(fileFunctionsByStartLine, line, column);\n if (containingFunction) {\n // Accumulate hits (in case multiple positions map to same function)\n const existingHits = hitCountsBySourceFunctionName.get(containingFunction);\n const existingHitsCount = existingHits ?? 0;\n const max = Math.max(existingHitsCount, hitCount);\n hitCountsBySourceFunctionName.set(containingFunction, max); // <-- TODO: Explain this max logic\n\n if (existingHits !== undefined) {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} → function \"${containingFunction.shortName}\" EXISTING HITS: ${existingHits} NEW COUNT: ${max}`);\n } else {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} → function \"${containingFunction.shortName}\" (hits: ${hitCount})`);\n }\n } else {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} has no containing function`);\n }\n }\n }\n\n const startConvert = performance.now();\n istanbulDebug(`[IstanbulConverter] Matching Complete - Converting to Istanbul format`);\n\n // Initialize Istanbul data structures\n const fnMap: { [key: string]: FunctionMapping } = {};\n const f: { [key: string]: number } = {};\n const statementMap: { [key: string]: Range } = {};\n const s: { [key: string]: number } = {};\n const branchMap: { [key: string]: BranchMapping } = {};\n const b: { [key: string]: number[] } = {};\n\n // Convert function coverage to Istanbul format\n // Iterate all functions from parsed source (ensures 0-hit functions are included)\n let funcIdx = 0;\n for (const functions of Object.values(fileFunctionsByStartLine)) {\n for (const funcInfo of functions) {\n const { range, shortName } = funcInfo;\n\n // Defensive: skip functions with invalid metadata (shouldn't happen - AST parser filters these)\n if (range.startLine === 0) {\n continue;\n }\n\n // Get hit count from containment matching (or 0 if not hit)\n const hitCount = hitCountsBySourceFunctionName.get(funcInfo) ?? 0;\n const displayShortName = shortName && shortName !== '' ? shortName : '<anonymous>';\n istanbulDebug(\n `[IstanbulConverter] Istanbul function index ${funcIdx}: \"${displayShortName}\"`\n + ` (source ${range.startLine}:${range.startColumn} - ${range.endLine}:${range.endColumn}), hits: ${hitCount}`\n );\n\n // Create function mapping\n // Both 'decl' (declaration) and 'loc' (location) use the same range\n // Internal ParsedSourceFunctionInfo uses 1-based columns, Istanbul expects 0-based\n const istanbulRange: Range = {\n start: { line: range.startLine, column: range.startColumn - 1 },\n end: { line: range.endLine, column: range.endColumn - 1 }\n };\n\n const idxStr = funcIdx.toString();\n fnMap[idxStr] = {\n name: shortName,\n decl: istanbulRange,\n loc: istanbulRange,\n line: range.startLine\n };\n f[idxStr] = hitCount;\n\n // Create corresponding statement mapping\n // For function-level coverage, each function is one \"statement\"\n // The statement range matches the function range\n // This gives us statement coverage at function granularity\n statementMap[idxStr] = istanbulRange;\n s[idxStr] = hitCount;\n\n funcIdx++;\n }\n }\n\n const done = performance.now();\n const matchingMs = (startConvert - startMatch).toFixed(2);\n const convertMs = (done - startConvert).toFixed(2);\n const totalMs = (done - startMatch).toFixed(2);\n\n istanbulDebug(\n `[IstanbulConverter] Coverage Coversion Complete: ${Object.keys(fnMap).length} functions,` \n + ` ${totalMs} ms total (matching: ${matchingMs} ms, convert: ${convertMs} ms)`\n );\n\n return {\n path: absoluteFilePath,\n fnMap,\n f,\n statementMap,\n s,\n branchMap,\n b\n };\n}\n","/**\n * AST Parser for AssemblyScript Source Files\n *\n * Parses AS source files to extract function metadata for coverage.\n * Used by generateCoverage to build empty coverage map from all source files.\n *\n * Source AST is the source of truth for what SHOULD be covered.\n * Binary instrumentation tells us what we CAN measure (hit counts).\n *\n * Functions are grouped by start line for efficient containment matching.\n *\n * Architecture:\n * - Uses shared ASTVisitor for complete NodeKind coverage\n * - Overrides hooks to extract function information during traversal\n */\n\nimport { readFile } from 'node:fs/promises';\nimport { parse as parsePath } from 'node:path';\nimport {\n Parser as AssemblyScriptParser,\n Source,\n BlockStatement,\n Node,\n FunctionDeclaration,\n MethodDeclaration,\n ClassDeclaration,\n NamespaceDeclaration,\n VariableDeclaration,\n FunctionExpression,\n} from 'assemblyscript';\n\nimport type { ParsedSourceFunctionInfo, SourceRange } from '../types/types.js';\nimport { ASCommonFlags, ASNodeKind } from '../types/constants.js';\nimport { ASTVisitor } from '../util/ast-visitor.js';\n\n/**\n * Visitor that extracts function information from AST nodes\n */\nclass FunctionExtractorVisitor extends ASTVisitor {\n /** Source file being parsed */\n private source: Source;\n /** Module path for building qualified names */\n private modulePath: string;\n /** Absolute file path */\n private filePath: string;\n /** Accumulated function records, keyed by start line */\n readonly functions: Record<number, ParsedSourceFunctionInfo[]> = {};\n /** Namespace context stack (supports nested namespaces) */\n private namespaceStack: string[] = [];\n /** Current class name (when inside a class) */\n private currentClassName: string | null = null;\n\n constructor(source: Source, modulePath: string, filePath: string) {\n super();\n this.source = source;\n this.modulePath = modulePath;\n this.filePath = filePath;\n }\n\n /**\n * Track namespace context when entering a namespace.\n * Supports nesting — push onto the stack.\n */\n protected onNamespaceEnter(node: NamespaceDeclaration): void {\n this.namespaceStack.push(node.name?.text ?? 'Anonymous');\n }\n\n /**\n * Restore namespace context when exiting a namespace.\n */\n protected onNamespaceExit(_node: NamespaceDeclaration): void {\n this.namespaceStack.pop();\n }\n\n /**\n * Track class context when entering a class.\n * Includes namespace prefix when inside a namespace, matching binary naming convention\n * (e.g. \"NS_A.Item\" for class Item inside namespace NS_A).\n */\n protected onClassEnter(node: ClassDeclaration): void {\n const className = node.name?.text ?? 'Anonymous';\n if (this.namespaceStack.length > 0) {\n this.currentClassName = `${this.namespaceStack.join('.')}.${className}`;\n } else {\n this.currentClassName = className;\n }\n }\n\n /**\n * Restore class context when exiting a class\n */\n protected onClassExit(_node: ClassDeclaration): void {\n this.currentClassName = null;\n }\n\n /**\n * Extract function info from function declarations\n */\n protected onFunctionDeclaration(node: FunctionDeclaration): boolean {\n if (node.body && this.hasBodyStatements(node.body)) {\n const funcName = node.name?.text ?? '~anonymous';\n const shortName = this.namespaceStack.length > 0\n ? `${this.namespaceStack.join('.')}.${funcName}`\n : funcName;\n const qualifiedName = `${this.modulePath}/${shortName}`;\n const range = this.buildRange(node, node.name ?? null);\n this.addFunction(qualifiedName, shortName, range);\n }\n return true; // Continue recursion into body\n }\n\n /**\n * Extract function info from method declarations\n */\n protected onMethodDeclaration(node: MethodDeclaration): boolean {\n if (node.body && this.hasBodyStatements(node.body)) {\n const methodName = node.name?.text ?? 'constructor';\n const className = this.currentClassName ?? 'Unknown';\n const flags = node.flags;\n\n // Determine method type from flags\n const isStatic = (flags & ASCommonFlags.Static) !== 0;\n const isGetter = (flags & ASCommonFlags.Get) !== 0;\n const isSetter = (flags & ASCommonFlags.Set) !== 0;\n\n // Build short name to match binary naming convention:\n // - Static: ClassName.methodName\n // - Getter: ClassName#get:propertyName\n // - Setter: ClassName#set:propertyName\n // - Instance: ClassName#methodName\n let shortName: string;\n if (isStatic) {\n shortName = `${className}.${methodName}`;\n } else if (isGetter) {\n shortName = `${className}#get:${methodName}`;\n } else if (isSetter) {\n shortName = `${className}#set:${methodName}`;\n } else {\n shortName = `${className}#${methodName}`;\n }\n\n const qualifiedName = `${this.modulePath}/${shortName}`;\n const range = this.buildRange(node, node.name ?? null);\n this.addFunction(qualifiedName, shortName, range);\n }\n return true; // Continue recursion into body\n }\n\n /**\n * Extract function info from variable declarations (arrow functions)\n */\n protected onVariableDeclaration(node: VariableDeclaration): boolean {\n if (node.initializer && node.initializer.kind === ASNodeKind.Function) {\n const funcExpr = node.initializer as FunctionExpression;\n const funcDecl = funcExpr.declaration;\n\n if (funcDecl.body && this.hasBodyStatements(funcDecl.body)) {\n // Use variable name for the function\n const shortName = node.name.text;\n const qualifiedName = `${this.modulePath}/${shortName}`;\n\n // Use the variable declaration's range\n const range: SourceRange = {\n filePath: this.filePath,\n startLine: this.source.lineAt(node.range.start),\n startColumn: this.source.columnAt(),\n endLine: this.source.lineAt(node.range.end),\n endColumn: this.source.columnAt(),\n };\n\n this.addFunction(qualifiedName, shortName, range);\n }\n\n // Visit the function body manually since we're handling this specially\n if (funcDecl.body) {\n this.visitNode(funcDecl.body);\n }\n return false; // Don't recurse again - we handled it\n }\n return true; // Continue recursion for non-function initializers\n }\n\n /**\n * Check if a function body has statements (non-empty body)\n */\n private hasBodyStatements(body: Node): boolean {\n if (body.kind === ASNodeKind.Block) {\n const blockBody = body as BlockStatement;\n return blockBody.statements.length > 0;\n }\n // Expression body (braceless arrow) - always has the expression\n return true;\n }\n\n /**\n * Add a function to the functions record, keyed by start line\n */\n private addFunction(qualifiedName: string, shortName: string, range: SourceRange): void {\n const startLine = range.startLine;\n if (!this.functions[startLine]) {\n this.functions[startLine] = [];\n }\n this.functions[startLine].push({ qualifiedName, shortName, range });\n }\n\n /**\n * Build a SourceRange for a node, using name.range.start to skip decorators\n */\n private buildRange(node: Node, nameNode: Node | null): SourceRange {\n const startNode = nameNode ?? node;\n return {\n filePath: this.filePath,\n startLine: this.source.lineAt(startNode.range.start),\n startColumn: this.source.columnAt(),\n endLine: this.source.lineAt(node.range.end),\n endColumn: this.source.columnAt(),\n };\n }\n}\n\n/**\n * Parse functions from a single AS source file\n *\n * @param absoluteSourceFilePath - Absolute path to AS source file\n * @param relativeSourceFilePath - Relative path to AS source file (derived once in caller and used several places)\n * @returns Record of start line to array of ParsedSourceFunctionInfo (multiple functions can start on same line)\n */\nexport async function parseFunctionsFromFile(\n absoluteSourceFilePath: string,\n relativeSourceFilePath: string,\n): Promise<Record<number, ParsedSourceFunctionInfo[]>> {\n const sourceCode = await readFile(absoluteSourceFilePath, 'utf8');\n\n // Build the module path (strip any extension, use forward slashes)\n const parsed = parsePath(relativeSourceFilePath);\n const modulePath = parsed.dir ? `${parsed.dir}/${parsed.name}` : parsed.name;\n\n // Parse with AssemblyScript parser\n const asParser = new AssemblyScriptParser();\n asParser.parseFile(sourceCode, relativeSourceFilePath, true);\n\n const source = asParser.currentSource;\n if (!source) {\n return {};\n }\n\n // Create visitor and traverse\n const visitor = new FunctionExtractorVisitor(source, modulePath, absoluteSourceFilePath);\n visitor.visitSource(source);\n\n return visitor.functions || {};\n}\n","/**\n * Glob Utilities for Coverage\n *\n * Uses tinyglobby to glob AssemblyScript files matching coverage include/exclude patterns.\n * Supports ../ path traversals for projects that import source from outside the project root.\n *\n * Note: tinyglobby docs warn of a performance cost when globbing outside cwd (e.g. ../ patterns)\n * due to recalculating relative paths. Acceptable here since this runs once at startup.\n */\n\nimport { relative } from 'node:path';\nimport { globSync } from 'tinyglobby';\n\nimport { GlobResult } from '../types/types.js';\nimport { toForwardSlash } from '../util/path-utils.js';\n\nconst NODE_MODULES_GLOB = '**/node_modules/**';\n\n/**\n * Glob files matching coverage include/exclude patterns\n *\n * @param include - Include patterns (e.g., ['assembly/**\\/*.ts'])\n * @param exclude - Exclude patterns (e.g., ['**\\/*.test.ts'])\n * @param projectRoot - Project root directory\n * @returns Array of glob results with absolute and project-root-relative paths\n */\nexport function globFiles(\n include: string[],\n exclude: string[],\n projectRoot: string\n): GlobResult[] {\n if (include.length === 0) {\n return [];\n }\n\n const absolutePaths = globSync(include, {\n cwd: projectRoot,\n ignore: [NODE_MODULES_GLOB, ...exclude],\n absolute: true,\n });\n\n return absolutePaths.map((absolute) => ({\n absolute: toForwardSlash(absolute),\n projectRootRelative: toForwardSlash(relative(projectRoot, absolute)),\n }));\n}\n","/**\n * Hybrid Coverage Provider\n *\n * This provider handles both AssemblyScript and JavaScript and coverage\n * - Converts AS coverage to Istanbul format\n * - Delegates JS coverage to Vitest's v8 provider\n * - Merges both into a unified coverage report\n */\n\nimport { basename, relative } from 'node:path';\nimport type {\n CoverageProvider,\n Vitest,\n ReportContext,\n ResolvedCoverageOptions,\n} from 'vitest/node';\nimport type { AfterSuiteRunMeta } from 'vitest';\nimport v8CoverageModule from '@vitest/coverage-v8';\nimport type { CoverageMap } from 'istanbul-lib-coverage';\nimport istanbulCoverage from 'istanbul-lib-coverage';\nconst { createCoverageMap } = istanbulCoverage;\n\nimport { convertToIstanbulFormat } from './istanbul-converter.js';\nimport { parseFunctionsFromFile } from './ast-parser.js';\nimport { globFiles } from './glob-utils.js';\nimport { mergeCoverageData } from './coverage-merge.js';\nimport { debug } from '../util/debug.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport type {\n AssemblyScriptCoveragePayload,\n CoverageData,\n GlobResult,\n ResolvedHybridProviderOptions,\n} from '../types/types.js';\nimport {\n POOL_ERROR_NAMES,\n COVERAGE_PAYLOAD_FORMATS\n} from '../types/constants.js';\nimport { warnIfASCoverageNotSupportedByNode, warnIfNativeBuildFailed } from '../util/feature-check.js';\n\nexport class HybridCoverageProvider implements CoverageProvider {\n name = 'hybrid-assemblyscript-v8' as const;\n\n private v8Provider: CoverageProvider | undefined;\n private accumulatedCoverageData: CoverageData = { hitCountsByFileAndPosition: {} };\n private projectRoot: string = '';\n private definedCoverageOptions: ResolvedCoverageOptions = {} as ResolvedCoverageOptions;\n private resolvedProviderOptions: ResolvedHybridProviderOptions = {} as ResolvedHybridProviderOptions;\n\n /**\n * Initialize the provider and get reference to v8 provider\n */\n async initialize(ctx: Vitest): Promise<void> {\n this.projectRoot = ctx.config.root;\n this.definedCoverageOptions = ctx.config.coverage;\n\n debug('[HybridCoverageProvider] Initializing Provider');\n\n // Get v8 provider from the coverage module\n this.v8Provider = await v8CoverageModule.getProvider();\n\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'initialize failed to get delegated v8 provider',\n );\n }\n\n await this.v8Provider.initialize(ctx);\n this.v8Provider.name = 'hybrid-assemblyscript-v8 (delegated v8 reporter)' as const;\n debug('[HybridCoverageProvider] Initialized with delegated v8 provider');\n\n warnIfASCoverageNotSupportedByNode();\n await warnIfNativeBuildFailed();\n }\n\n /**\n * Handle suite completion - delegate based on coverage format marker\n */\n async onAfterSuiteRun(meta: AfterSuiteRunMeta): Promise<void> {\n const start = performance.now();\n const format: string | undefined = (meta?.coverage as any)?.__format;\n let suiteLogLabel = meta.testFiles.length > 0 ? basename(meta.testFiles[0]!) : '';\n\n // Check for AssemblyScript format marker\n if (format === COVERAGE_PAYLOAD_FORMATS.AssemblyScript) {\n const payload = meta.coverage as AssemblyScriptCoveragePayload;\n const { coverageData, suiteLogLabel: label } = payload;\n suiteLogLabel = label;\n\n debug(() => {\n const fileCount = Object.keys(coverageData.hitCountsByFileAndPosition).length;\n const positionCount = Object.values(coverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions).length, 0);\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun - Suite payload: ${positionCount} unique positions over ${fileCount} source files`;\n });\n\n // Merge incoming coverage data into accumulated (by position, summing hit counts)\n mergeCoverageData(this.accumulatedCoverageData, coverageData);\n\n debug(() => {\n const fileCount = Object.keys(this.accumulatedCoverageData.hitCountsByFileAndPosition).length;\n const positionCount = Object.values(this.accumulatedCoverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions).length, 0);\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun - Accumulated coverage: ${positionCount} unique positions over ${fileCount} source files`;\n });\n } else {\n // Delegate to v8 provider for all other formats (JS, etc.)\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'onAfterSuiteRun failed to delegate to v8 provider',\n );\n }\n\n debug(`[HybridCoverageProvider] ${suiteLogLabel} - Delegating to v8 provider`);\n await this.v8Provider.onAfterSuiteRun(meta);\n }\n\n debug(() => {\n const files = meta.testFiles.map(tf => relative(this.projectRoot, tf)).join(',');\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun complete - TIMING ${(performance.now() - start).toFixed(2)} ms | testFiles: \"${files}\"`;\n });\n }\n\n /**\n * Generate unified coverage map (merging JS and AS coverage)\n *\n * Flow:\n * 1. Parse included AS source files to get sourceDebugInfo (source of truth for line numbers)\n * 1. Build merged CoverageData (all source functions + accumulated hit counts)\n * 4. Convert merged CoverageData to Istanbul format\n * 5. Get JS coverage from v8 provider\n * 6. Merge AS coverage into JS coverage\n */\n async generateCoverage(context: ReportContext): Promise<unknown> {\n const start = performance.now();\n\n debug('[HybridCoverageProvider] Generating coverage for test run');\n\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'generateCoverage failed to delegate to v8 provider',\n );\n }\n\n // Build AS coverage map\n let asCoverageMap = createCoverageMap();\n\n if (this.resolvedProviderOptions.globbedAssemblyScriptInclude.length > 0) {\n debug(`[HybridCoverageProvider] Building AS coverage map with ${this.resolvedProviderOptions.globbedAssemblyScriptInclude.length} source files `);\n debug(() => {\n const accumulatedPositionCount = Object.values(this.accumulatedCoverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions)?.length, 0);\n const files = Object.keys(this.accumulatedCoverageData.hitCountsByFileAndPosition).length;\n return `[HybridCoverageProvider] Accumulated coverage data has ${accumulatedPositionCount} unique positions hit across ${files} debug source files`;\n });\n\n // parse source files with AST parser, then match to hits and convert to istanbul format\n const fileProcessingPromises = this.resolvedProviderOptions.globbedAssemblyScriptInclude.map(async (include: GlobResult) => {\n debug(`[HybridCoverageProvider] Parsing AS source for expected coverage: \"${include.absolute}\"`);\n \n const functionsByStartLine = await parseFunctionsFromFile(include.absolute, include.projectRootRelative) || {};\n debug(`[HybridCoverageProvider] Parsed ${Object.keys(functionsByStartLine).length} AS source functions in \"${include.absolute}\"`);\n\n const fileHitCountsByPosition = this.accumulatedCoverageData.hitCountsByFileAndPosition[include.absolute] ?? {};\n debug(`[HybridCoverageProvider] Accumulated AS coverage has ${Object.keys(fileHitCountsByPosition).length} positions for \"${include.absolute}\"`);\n\n // Containment matching (binary hit position → source) is performed during istanbul conversion\n return convertToIstanbulFormat(functionsByStartLine, fileHitCountsByPosition, include.absolute, this.resolvedProviderOptions.debugIstanbul);\n });\n\n // Wait for all files to complete\n const istanbulResults = await Promise.all(fileProcessingPromises);\n\n // Add all results to coverage map\n for (const istanbulData of istanbulResults) {\n asCoverageMap.addFileCoverage(istanbulData);\n }\n\n debug(`[HybridCoverageProvider] Built AS coverage map with ${Object.keys(asCoverageMap.data).length} files`);\n } else {\n debug('[HybridCoverageProvider] WARNING: No assemblyScriptInclude patterns yieldled files - Coverage Map will be empty!');\n }\n\n const asGenerateEnd = performance.now();\n debug(`[HybridCoverageProvider] TIMING AS generateCoverage: ${(asGenerateEnd - start).toFixed(2)} ms`);\n\n // Get JS coverage from v8 provider\n debug('[HybridCoverageProvider] Getting JS coverage from v8 provider');\n const jsCoverage = await this.v8Provider.generateCoverage(context) as CoverageMap;\n debug(`[HybridCoverageProvider] JS coverage has ${Object.keys(jsCoverage.data).length} files`);\n debug(`[HybridCoverageProvider] TIMING JS generateCoverage: ${(performance.now() - asGenerateEnd).toFixed(2)} ms`);\n\n // Merge AS coverage into JS coverage.\n // Use toJSON() to pass plain data instead of the CoverageMap instance. This avoids\n // instanceof failures when istanbul-lib-coverage is loaded from different module paths\n // (e.g. the pool workers resolve one copy while the coverage provider resolves another).\n if (asCoverageMap.files().length) {\n debug('[HybridCoverageProvider] Merging AS coverage into JS coverage');\n jsCoverage.merge(asCoverageMap.toJSON());\n } else {\n debug('[HybridCoverageProvider] AS coverage map empty, not merging into JS coverage');\n }\n debug(`[HybridCoverageProvider] Final merged coverage has ${Object.keys(jsCoverage.data).length} files`);\n\n debug(`[HybridCoverageProvider] TIMING Total generateCoverage: ${(performance.now() - start).toFixed(2)} ms`);\n\n return jsCoverage;\n }\n\n /**\n * Report coverage - delegate to v8 provider\n */\n async reportCoverage(coverageMap: unknown, context: ReportContext): Promise<void> {\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'reportCoverage failed to delegate to v8 provider',\n );\n }\n\n debug(`[HybridCoverageProvider] Reporting coverage (allTestsRun=${context.allTestsRun})`);\n await this.v8Provider.reportCoverage(coverageMap, context);\n }\n\n /**\n * Resolve options\n */\n resolveOptions(): ResolvedHybridProviderOptions {\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'resolveOptions failed to delegate to v8 provider',\n );\n }\n \n debug(`[HybridCoverageProvider] Resolving Coverage Options`);\n \n const resolvedV8Options = this.v8Provider.resolveOptions() as ResolvedCoverageOptions;\n\n // For some reason the v8 provider builds its `excludes` values to include a null byte.\n // Remove null bytes for logging purposes so tools like grep won't complain about binary content.\n const sanitizedV8Options: ResolvedCoverageOptions = {\n ...resolvedV8Options,\n include: resolvedV8Options.include?.map(i => i.replace(/\\0/g, '')) || undefined,\n exclude: resolvedV8Options.exclude?.map(i => i.replace(/\\0/g, '')) || undefined\n };\n\n debug(`[HybridCoverageProvider] AS include: ${(this.definedCoverageOptions.assemblyScriptInclude || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] AS exclude: ${(this.definedCoverageOptions.assemblyScriptExclude || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] JS include: ${(sanitizedV8Options.include || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] JS exclude: ${(sanitizedV8Options.exclude || []).join(', ') || '(none)'}`);\n\n debug(`[HybridCoverageProvider] Globbing AS source files to include for coverage map basis`);\n const globbedAssemblyScriptInclude = globFiles(\n this.definedCoverageOptions.assemblyScriptInclude || [],\n this.definedCoverageOptions.assemblyScriptExclude || [],\n this.projectRoot\n );\n debug(`[HybridCoverageProvider] Including ${globbedAssemblyScriptInclude.length} AS files in coverage map`);\n \n const globbedAssemblyScriptExcludeOnly = globFiles(\n this.definedCoverageOptions.assemblyScriptExclude || [],\n [],\n this.projectRoot\n );\n debug(`[HybridCoverageProvider] Excluding ${globbedAssemblyScriptExcludeOnly.length} AS files from coverage map & instrumentation`);\n \n const resolved: ResolvedHybridProviderOptions = {\n ...resolvedV8Options,\n provider: 'custom',\n customProviderModule: this.definedCoverageOptions.customProviderModule || '',\n debugIstanbul: this.definedCoverageOptions.debugIstanbul ?? false,\n assemblyScriptInclude: this.definedCoverageOptions.assemblyScriptInclude ?? [],\n assemblyScriptExclude: this.definedCoverageOptions.assemblyScriptExclude ?? [],\n globbedAssemblyScriptInclude,\n globbedAssemblyScriptProjectRelativeExcludeOnly : globbedAssemblyScriptExcludeOnly.map(gr => gr.projectRootRelative),\n isResolved: true\n }; \n\n this.resolvedProviderOptions = resolved;\n return resolved;\n }\n\n async clean(clean: boolean = true): Promise<void> {\n debug('[HybridCoverageProvider] Clean coverage data - clean:', clean);\n if (clean) {\n this.accumulatedCoverageData = { hitCountsByFileAndPosition: {} };\n debug('[HybridCoverageProvider] Cleaned all internal coverage data');\n }\n\n if (this.v8Provider) {\n await this.v8Provider.clean(clean);\n debug(`[HybridCoverageProvider] V8 provider finished clean(${clean})`);\n }\n }\n}\n","/**\n * Coverage Provider Module Export\n *\n * This module exports the hybrid coverage provider for Vitest to load.\n * Users configure this via:\n * coverage.provider = 'custom'\n * coverage.customProviderModule = 'vitest-pool-assemblyscript/coverage'\n */\n\nimport { CoverageProviderModule } from 'vitest/node';\nimport v8CoverageModule from '@vitest/coverage-v8';\n\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport { HybridCoverageProvider } from './hybrid-coverage-provider.js';\n\n/**\n * Hybrid Coverage Provider\n *\n * This provider handles both AssemblyScript and JavaScript and coverage\n * - Converts AS coverage to Istanbul format\n * - Delegates JS coverage to Vitest's v8 provider\n * - Merges both into a unified coverage report\n */\nconst hybridProviderModule: CoverageProviderModule = {\n getProvider: (): HybridCoverageProvider => new HybridCoverageProvider(),\n\n startCoverage: async (runtimeOptions: {\n isolate: boolean\n }): Promise<unknown> => {\n if (v8CoverageModule.startCoverage) {\n return await v8CoverageModule.startCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'HybridCoverageProvider - v8 coverage module does not provide `startCoverage`',\n );\n }\n },\n \n takeCoverage: async (runtimeOptions?: any): Promise<unknown> => {\n if (v8CoverageModule.takeCoverage) {\n return await v8CoverageModule.takeCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'HybridCoverageProvider - v8 coverage module does not provide `takeCoverage`',\n );\n }\n },\n \n stopCoverage: async (runtimeOptions: {\n isolate: boolean\n }): Promise<unknown> => {\n if (v8CoverageModule.stopCoverage) {\n return await v8CoverageModule.stopCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'HybridCoverageProvider - v8 coverage module does not provide `stopCoverage`',\n );\n }\n },\n};\n\nexport default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,EAAE,EACF,KAAK,YACN;AACD,QAAM,sCAAsC,iCAAiC,OAAO,+CAA+C;EAEnI,MAAM,WAA0C;GAC9C,GAAG;GACH,UAAU;GACV,sBAAsB,KAAK,uBAAuB,wBAAwB;GAC1E,eAAe,KAAK,uBAAuB,iBAAiB;GAC5D,uBAAuB,KAAK,uBAAuB,yBAAyB,EAAE;GAC9E,uBAAuB,KAAK,uBAAuB,yBAAyB,EAAE;GAC9E;GACA,iDAAkD,iCAAiC,KAAI,OAAM,GAAG,oBAAoB;GACpH,YAAY;GACb;AAED,OAAK,0BAA0B;AAC/B,SAAO;;CAGT,MAAM,MAAM,QAAiB,MAAqB;AAChD,QAAM,yDAAyD,MAAM;AACrE,MAAI,OAAO;AACT,QAAK,0BAA0B,EAAE,4BAA4B,EAAE,EAAE;AACjE,SAAM,8DAA8D;;AAGtE,MAAI,KAAK,YAAY;AACnB,SAAM,KAAK,WAAW,MAAM,MAAM;AAClC,SAAM,uDAAuD,MAAM,GAAG;;;;;;;;;;;;;;;AC/Q5E,MAAM,uBAA+C;CACnD,mBAA2C,IAAI,wBAAwB;CAEvE,eAAe,OAAO,mBAEE;AACtB,MAAI,iBAAiB,cACnB,QAAO,MAAM,iBAAiB,cAAc,eAAe;MAE3D,OAAM,gBACJ,iBAAiB,6BACjB,+EACD;;CAIL,cAAc,OAAO,mBAA2C;AAC9D,MAAI,iBAAiB,aACnB,QAAO,MAAM,iBAAiB,aAAa,eAAe;MAE1D,OAAM,gBACJ,iBAAiB,6BACjB,8EACD;;CAIL,cAAc,OAAO,mBAEG;AACtB,MAAI,iBAAiB,aACnB,QAAO,MAAM,iBAAiB,aAAa,eAAe;MAE1D,OAAM,gBACJ,iBAAiB,6BACjB,8EACD;;CAGN"}
1
+ {"version":3,"file":"index.mjs","names":["parsePath","AssemblyScriptParser"],"sources":["../../src/coverage-provider/containment-matcher.ts","../../src/coverage-provider/istanbul-converter.ts","../../src/coverage-provider/ast-parser.ts","../../src/coverage-provider/glob-utils.ts","../../src/coverage-provider/hybrid-coverage-provider.ts","../../src/coverage-provider/index.ts"],"sourcesContent":["/**\n * Containment Matcher\n *\n * Provides containment-based matching for coverage mapping.\n * Binary debug info provides points (representativeLocation), source parsing provides ranges.\n * We find which source range contains each binary point.\n *\n * Usage by version:\n * - v1: Function containment matching (binary representativeLocation → source function range)\n * - v2: Function containment (same) + statement containment + branch path containment\n *\n * Why containment matching (not direct position lookup):\n * AS compiler generates source map entries differently by statement type:\n * - Variable declarations: source map points to statement start (keyword)\n * - Control flow (if/switch/for): source map points to condition EXPRESSION, not keyword\n *\n * Example: `if (n < 0)` → binary reports column 7 ('n'), not column 3 ('i' of 'if')\n *\n * Containment matching is more robust:\n * - Binary gives us a position (representativeLocation) somewhere in the function\n * - Source gives us function ranges (start/end line/column)\n * - We find which source function range contains the binary position\n * - Handles nested functions with \"tightest fit\" (innermost function wins)\n */\n\nimport type { ParsedSourceFunctionInfo, SourceRange } from '../types/types.js';\n\n/**\n * Functions indexed by file path, then by start line.\n * Multiple functions can start on the same line (e.g., nested arrow functions).\n */\nexport type FunctionsByFileAndStartLine = Record<string, Record<number, ParsedSourceFunctionInfo[]>>;\n\n/**\n * Find the source function whose range contains the given position.\n *\n * For nested functions, uses \"tightest fit\" - returns the innermost function\n * (the one with the largest start position among all containing functions).\n *\n * @param functionsByStartLine - Functions for a single file, indexed by start line\n * @param line - Target line number (1-based)\n * @param column - Target column number (1-based)\n * @returns The containing function, or undefined if no match\n */\nexport function findFunctionContainingPosition(\n functionsByStartLine: Record<number, ParsedSourceFunctionInfo[]>,\n line: number,\n column: number\n): ParsedSourceFunctionInfo | undefined {\n let bestMatch: ParsedSourceFunctionInfo | undefined;\n let bestStartLine = -1;\n let bestStartColumn = -1;\n\n // Check functions starting on lines <= target line\n for (const [startLineStr, functions] of Object.entries(functionsByStartLine)) {\n const startLine = Number(startLineStr);\n if (startLine > line) continue;\n\n for (const func of functions) {\n const { range } = func;\n\n // Check if position is within this function's range\n if (!isPositionInRange(line, column, range)) continue;\n\n // Tightest fit: prefer function with largest start position (innermost)\n if (startLine > bestStartLine ||\n (startLine === bestStartLine && range.startColumn > bestStartColumn)) {\n bestMatch = func;\n bestStartLine = startLine;\n bestStartColumn = range.startColumn;\n }\n }\n }\n\n return bestMatch;\n}\n\n/**\n * Check if a position (line, column) falls within a source range.\n *\n * @param line - Target line number (1-based)\n * @param column - Target column number (1-based)\n * @param range - Source range to check against\n * @returns true if position is within range (inclusive)\n */\nexport function isPositionInRange(\n line: number,\n column: number,\n range: SourceRange\n): boolean {\n // Outside line range entirely\n if (line < range.startLine || line > range.endLine) return false;\n\n // On start line but before start column\n if (line === range.startLine && column < range.startColumn) return false;\n\n // On end line but after end column\n if (line === range.endLine && column > range.endColumn) return false;\n\n return true;\n}\n","/**\n * Istanbul Format Converter\n *\n * Converts AssemblyScript coverage data to Istanbul's FileCoverageData format.\n * This enables integration with Vitest's coverage reporting system and standard\n * coverage tools like Codecov, Coveralls, etc.\n *\n * Current Implementation: Function-level coverage only\n * - Uses containment matching: binary positions → source function ranges\n * - Each function maps to both a function entry AND a statement entry\n * - Statement coverage matches function coverage (function-level granularity)\n * - Branch coverage is 0% (no branches tracked yet)\n * - Line coverage derived from statement coverage\n *\n * Future Enhancement (v2): Block-level statement and branch coverage\n */\n\nimport type { FileCoverageData, Range, FunctionMapping, BranchMapping } from 'istanbul-lib-coverage';\nimport type { ParsedSourceFunctionInfo } from '../types/types.js';\nimport { findFunctionContainingPosition } from './containment-matcher.js';\nimport { debugOverride } from '../util/debug.js';\n\n/**\n * Convert AssemblyScript coverage data to Istanbul format for a single file\n *\n * Algorithm (containment matching):\n * 1. For each hit position in fileHitCountsByPosition:\n * - Use containment matcher to find which source function contains this position\n * - Record the hit count for that function\n * 2. For each function in fileFunctionsByStartLine:\n * - Add function mapping to fnMap\n * - Add function hit count to f (from matched hits, or 0 if not hit)\n * - Add corresponding statement mapping to statementMap\n * - Add same hit count to s (statement coverage matches function coverage)\n *\n * @param fileFunctionsByStartLine - Functions for this file, keyed by start line (from AST parser)\n * @param fileHitCountsByPosition - Hit counts for this file, keyed by position \"line:column\" (from accumulated coverage)\n * @param absoluteFilePath - Absolute path to the source file (for Istanbul output)\n * @returns Istanbul FileCoverage object\n */\nexport async function convertToIstanbulFormat(\n fileFunctionsByStartLine: Record<number, ParsedSourceFunctionInfo[]>,\n fileHitCountsByPosition: Record<string, number>,\n absoluteFilePath: string,\n istanbulDebugEnabled: boolean\n): Promise<FileCoverageData> {\n const startMatch = performance.now();\n\n function istanbulDebug(...args: any[]): void {\n if (istanbulDebugEnabled) {\n debugOverride(...args);\n }\n };\n\n istanbulDebug(() => {\n const sourceFunctionCount = Object.values(fileFunctionsByStartLine).reduce((sum, funcs) => sum + funcs.length, 0);\n const uniqueHitPosCount = Object.keys(fileHitCountsByPosition).length;\n const coverageEstimate = sourceFunctionCount === 0 ? Infinity : ((uniqueHitPosCount * 100) / sourceFunctionCount).toFixed(2);\n\n return `[IstanbulConverter] Processing source file: \"${absoluteFilePath}\"\\n`\n + `[IstanbulConverter] Source: ${sourceFunctionCount} total functions, Coverage: ${uniqueHitPosCount} unique hit positions\\n`\n + `[IstanbulConverter] Sanity Check - AS File Coverage Estimate: ${coverageEstimate}%\\n`\n + `[IstanbulConverter] Containment matching functions: coverage hit positions to source functions by range`;\n });\n\n // Build a map of function → hit count using containment matching\n // Key: function source identity (qualifiedName), Value: hit count\n const hitCountsBySourceFunctionName = new Map<ParsedSourceFunctionInfo, number>();\n\n // For each hit position, find which function contains it\n for (const [positionKey, hitCount] of Object.entries(fileHitCountsByPosition)) {\n // Position key format is \"line:column\"\n const parts = positionKey.split(':');\n const lineStr = parts[0];\n const columnStr = parts[1];\n\n if (lineStr && columnStr) {\n const line = parseInt(lineStr, 10);\n const column = parseInt(columnStr, 10);\n\n const containingFunction = findFunctionContainingPosition(fileFunctionsByStartLine, line, column);\n if (containingFunction) {\n // Accumulate hits (in case multiple positions map to same function)\n const existingHits = hitCountsBySourceFunctionName.get(containingFunction);\n const existingHitsCount = existingHits ?? 0;\n const max = Math.max(existingHitsCount, hitCount);\n hitCountsBySourceFunctionName.set(containingFunction, max); // <-- TODO: Explain this max logic\n\n if (existingHits !== undefined) {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} → function \"${containingFunction.shortName}\" EXISTING HITS: ${existingHits} NEW COUNT: ${max}`);\n } else {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} → function \"${containingFunction.shortName}\" (hits: ${hitCount})`);\n }\n } else {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} has no containing function`);\n }\n }\n }\n\n const startConvert = performance.now();\n istanbulDebug(`[IstanbulConverter] Matching Complete - Converting to Istanbul format`);\n\n // Initialize Istanbul data structures\n const fnMap: { [key: string]: FunctionMapping } = {};\n const f: { [key: string]: number } = {};\n const statementMap: { [key: string]: Range } = {};\n const s: { [key: string]: number } = {};\n const branchMap: { [key: string]: BranchMapping } = {};\n const b: { [key: string]: number[] } = {};\n\n // Convert function coverage to Istanbul format\n // Iterate all functions from parsed source (ensures 0-hit functions are included)\n let funcIdx = 0;\n for (const functions of Object.values(fileFunctionsByStartLine)) {\n for (const funcInfo of functions) {\n const { range, shortName } = funcInfo;\n\n // Defensive: skip functions with invalid metadata (shouldn't happen - AST parser filters these)\n if (range.startLine === 0) {\n continue;\n }\n\n // Get hit count from containment matching (or 0 if not hit)\n const hitCount = hitCountsBySourceFunctionName.get(funcInfo) ?? 0;\n const displayShortName = shortName && shortName !== '' ? shortName : '<anonymous>';\n istanbulDebug(\n `[IstanbulConverter] Istanbul function index ${funcIdx}: \"${displayShortName}\"`\n + ` (source ${range.startLine}:${range.startColumn} - ${range.endLine}:${range.endColumn}), hits: ${hitCount}`\n );\n\n // Create function mapping\n // Both 'decl' (declaration) and 'loc' (location) use the same range\n // Internal ParsedSourceFunctionInfo uses 1-based columns, Istanbul expects 0-based\n const istanbulRange: Range = {\n start: { line: range.startLine, column: range.startColumn - 1 },\n end: { line: range.endLine, column: range.endColumn - 1 }\n };\n\n const idxStr = funcIdx.toString();\n fnMap[idxStr] = {\n name: shortName,\n decl: istanbulRange,\n loc: istanbulRange,\n line: range.startLine\n };\n f[idxStr] = hitCount;\n\n // Create corresponding statement mapping\n // For function-level coverage, each function is one \"statement\"\n // The statement range matches the function range\n // This gives us statement coverage at function granularity\n statementMap[idxStr] = istanbulRange;\n s[idxStr] = hitCount;\n\n funcIdx++;\n }\n }\n\n const done = performance.now();\n const matchingMs = (startConvert - startMatch).toFixed(2);\n const convertMs = (done - startConvert).toFixed(2);\n const totalMs = (done - startMatch).toFixed(2);\n\n istanbulDebug(\n `[IstanbulConverter] Coverage Coversion Complete: ${Object.keys(fnMap).length} functions,` \n + ` ${totalMs} ms total (matching: ${matchingMs} ms, convert: ${convertMs} ms)`\n );\n\n return {\n path: absoluteFilePath,\n fnMap,\n f,\n statementMap,\n s,\n branchMap,\n b\n };\n}\n","/**\n * AST Parser for AssemblyScript Source Files\n *\n * Parses AS source files to extract function metadata for coverage.\n * Used by generateCoverage to build empty coverage map from all source files.\n *\n * Source AST is the source of truth for what SHOULD be covered.\n * Binary instrumentation tells us what we CAN measure (hit counts).\n *\n * Functions are grouped by start line for efficient containment matching.\n *\n * Architecture:\n * - Uses shared ASTVisitor for complete NodeKind coverage\n * - Overrides hooks to extract function information during traversal\n */\n\nimport { readFile } from 'node:fs/promises';\nimport { parse as parsePath } from 'node:path';\nimport {\n Parser as AssemblyScriptParser,\n Source,\n BlockStatement,\n Node,\n FunctionDeclaration,\n MethodDeclaration,\n ClassDeclaration,\n NamespaceDeclaration,\n VariableDeclaration,\n FunctionExpression,\n} from 'assemblyscript';\n\nimport type { ParsedSourceFunctionInfo, SourceRange } from '../types/types.js';\nimport { ASCommonFlags, ASNodeKind } from '../types/constants.js';\nimport { ASTVisitor } from '../util/ast-visitor.js';\n\n/**\n * Visitor that extracts function information from AST nodes\n */\nclass FunctionExtractorVisitor extends ASTVisitor {\n /** Source file being parsed */\n private source: Source;\n /** Module path for building qualified names */\n private modulePath: string;\n /** Absolute file path */\n private filePath: string;\n /** Accumulated function records, keyed by start line */\n readonly functions: Record<number, ParsedSourceFunctionInfo[]> = {};\n /** Namespace context stack (supports nested namespaces) */\n private namespaceStack: string[] = [];\n /** Current class name (when inside a class) */\n private currentClassName: string | null = null;\n\n constructor(source: Source, modulePath: string, filePath: string) {\n super();\n this.source = source;\n this.modulePath = modulePath;\n this.filePath = filePath;\n }\n\n /**\n * Track namespace context when entering a namespace.\n * Supports nesting — push onto the stack.\n */\n protected onNamespaceEnter(node: NamespaceDeclaration): void {\n this.namespaceStack.push(node.name?.text ?? 'Anonymous');\n }\n\n /**\n * Restore namespace context when exiting a namespace.\n */\n protected onNamespaceExit(_node: NamespaceDeclaration): void {\n this.namespaceStack.pop();\n }\n\n /**\n * Track class context when entering a class.\n * Includes namespace prefix when inside a namespace, matching binary naming convention\n * (e.g. \"NS_A.Item\" for class Item inside namespace NS_A).\n */\n protected onClassEnter(node: ClassDeclaration): void {\n const className = node.name?.text ?? 'Anonymous';\n if (this.namespaceStack.length > 0) {\n this.currentClassName = `${this.namespaceStack.join('.')}.${className}`;\n } else {\n this.currentClassName = className;\n }\n }\n\n /**\n * Restore class context when exiting a class\n */\n protected onClassExit(_node: ClassDeclaration): void {\n this.currentClassName = null;\n }\n\n /**\n * Extract function info from function declarations\n */\n protected onFunctionDeclaration(node: FunctionDeclaration): boolean {\n if (node.body && this.hasBodyStatements(node.body)) {\n const funcName = node.name?.text ?? '~anonymous';\n const shortName = this.namespaceStack.length > 0\n ? `${this.namespaceStack.join('.')}.${funcName}`\n : funcName;\n const qualifiedName = `${this.modulePath}/${shortName}`;\n const range = this.buildRange(node, node.name ?? null);\n this.addFunction(qualifiedName, shortName, range);\n }\n return true; // Continue recursion into body\n }\n\n /**\n * Extract function info from method declarations\n */\n protected onMethodDeclaration(node: MethodDeclaration): boolean {\n if (node.body && this.hasBodyStatements(node.body)) {\n const methodName = node.name?.text ?? 'constructor';\n const className = this.currentClassName ?? 'Unknown';\n const flags = node.flags;\n\n // Determine method type from flags\n const isStatic = (flags & ASCommonFlags.Static) !== 0;\n const isGetter = (flags & ASCommonFlags.Get) !== 0;\n const isSetter = (flags & ASCommonFlags.Set) !== 0;\n\n // Build short name to match binary naming convention:\n // - Static: ClassName.methodName\n // - Getter: ClassName#get:propertyName\n // - Setter: ClassName#set:propertyName\n // - Instance: ClassName#methodName\n let shortName: string;\n if (isStatic) {\n shortName = `${className}.${methodName}`;\n } else if (isGetter) {\n shortName = `${className}#get:${methodName}`;\n } else if (isSetter) {\n shortName = `${className}#set:${methodName}`;\n } else {\n shortName = `${className}#${methodName}`;\n }\n\n const qualifiedName = `${this.modulePath}/${shortName}`;\n const range = this.buildRange(node, node.name ?? null);\n this.addFunction(qualifiedName, shortName, range);\n }\n return true; // Continue recursion into body\n }\n\n /**\n * Extract function info from variable declarations (arrow functions)\n */\n protected onVariableDeclaration(node: VariableDeclaration): boolean {\n if (node.initializer && node.initializer.kind === ASNodeKind.Function) {\n const funcExpr = node.initializer as FunctionExpression;\n const funcDecl = funcExpr.declaration;\n\n if (funcDecl.body && this.hasBodyStatements(funcDecl.body)) {\n // Use variable name for the function\n const shortName = node.name.text;\n const qualifiedName = `${this.modulePath}/${shortName}`;\n\n // Use the variable declaration's range\n const range: SourceRange = {\n filePath: this.filePath,\n startLine: this.source.lineAt(node.range.start),\n startColumn: this.source.columnAt(),\n endLine: this.source.lineAt(node.range.end),\n endColumn: this.source.columnAt(),\n };\n\n this.addFunction(qualifiedName, shortName, range);\n }\n\n // Visit the function body manually since we're handling this specially\n if (funcDecl.body) {\n this.visitNode(funcDecl.body);\n }\n return false; // Don't recurse again - we handled it\n }\n return true; // Continue recursion for non-function initializers\n }\n\n /**\n * Check if a function body has statements (non-empty body)\n */\n private hasBodyStatements(body: Node): boolean {\n if (body.kind === ASNodeKind.Block) {\n const blockBody = body as BlockStatement;\n return blockBody.statements.length > 0;\n }\n // Expression body (braceless arrow) - always has the expression\n return true;\n }\n\n /**\n * Add a function to the functions record, keyed by start line\n */\n private addFunction(qualifiedName: string, shortName: string, range: SourceRange): void {\n const startLine = range.startLine;\n if (!this.functions[startLine]) {\n this.functions[startLine] = [];\n }\n this.functions[startLine].push({ qualifiedName, shortName, range });\n }\n\n /**\n * Build a SourceRange for a node, using name.range.start to skip decorators\n */\n private buildRange(node: Node, nameNode: Node | null): SourceRange {\n const startNode = nameNode ?? node;\n return {\n filePath: this.filePath,\n startLine: this.source.lineAt(startNode.range.start),\n startColumn: this.source.columnAt(),\n endLine: this.source.lineAt(node.range.end),\n endColumn: this.source.columnAt(),\n };\n }\n}\n\n/**\n * Parse functions from a single AS source file\n *\n * @param absoluteSourceFilePath - Absolute path to AS source file\n * @param relativeSourceFilePath - Relative path to AS source file (derived once in caller and used several places)\n * @returns Record of start line to array of ParsedSourceFunctionInfo (multiple functions can start on same line)\n */\nexport async function parseFunctionsFromFile(\n absoluteSourceFilePath: string,\n relativeSourceFilePath: string,\n): Promise<Record<number, ParsedSourceFunctionInfo[]>> {\n const sourceCode = await readFile(absoluteSourceFilePath, 'utf8');\n\n // Build the module path (strip any extension, use forward slashes)\n const parsed = parsePath(relativeSourceFilePath);\n const modulePath = parsed.dir ? `${parsed.dir}/${parsed.name}` : parsed.name;\n\n // Parse with AssemblyScript parser\n const asParser = new AssemblyScriptParser();\n asParser.parseFile(sourceCode, relativeSourceFilePath, true);\n\n const source = asParser.currentSource;\n if (!source) {\n return {};\n }\n\n // Create visitor and traverse\n const visitor = new FunctionExtractorVisitor(source, modulePath, absoluteSourceFilePath);\n visitor.visitSource(source);\n\n return visitor.functions || {};\n}\n","/**\n * Glob Utilities for Coverage\n *\n * Uses tinyglobby to glob AssemblyScript files matching coverage include/exclude patterns.\n * Supports ../ path traversals for projects that import source from outside the project root.\n *\n * Note: tinyglobby docs warn of a performance cost when globbing outside cwd (e.g. ../ patterns)\n * due to recalculating relative paths. Acceptable here since this runs once at startup.\n */\n\nimport { relative } from 'node:path';\nimport { globSync } from 'tinyglobby';\n\nimport { GlobResult } from '../types/types.js';\nimport { toForwardSlash } from '../util/path-utils.js';\n\nconst NODE_MODULES_GLOB = '**/node_modules/**';\n\n/**\n * Glob files matching coverage include/exclude patterns\n *\n * @param include - Include patterns (e.g., ['assembly/**\\/*.ts'])\n * @param exclude - Exclude patterns (e.g., ['**\\/*.test.ts'])\n * @param projectRoot - Project root directory\n * @returns Array of glob results with absolute and project-root-relative paths\n */\nexport function globFiles(\n include: string[],\n exclude: string[],\n projectRoot: string\n): GlobResult[] {\n if (include.length === 0) {\n return [];\n }\n\n const absolutePaths = globSync(include, {\n cwd: projectRoot,\n ignore: [NODE_MODULES_GLOB, ...exclude],\n absolute: true,\n });\n\n return absolutePaths.map((absolute) => ({\n absolute: toForwardSlash(absolute),\n projectRootRelative: toForwardSlash(relative(projectRoot, absolute)),\n }));\n}\n","/**\n * Hybrid Coverage Provider\n *\n * This provider handles both AssemblyScript and JavaScript and coverage\n * - Converts AS coverage to Istanbul format\n * - Delegates JS coverage to Vitest's v8 provider\n * - Merges both into a unified coverage report\n */\n\nimport { basename, relative } from 'node:path';\nimport type {\n CoverageProvider,\n Vitest,\n ReportContext,\n ResolvedCoverageOptions,\n} from 'vitest/node';\nimport type { AfterSuiteRunMeta } from 'vitest';\nimport v8CoverageModule from '@vitest/coverage-v8';\nimport type { CoverageMap } from 'istanbul-lib-coverage';\nimport istanbulCoverage from 'istanbul-lib-coverage';\nconst { createCoverageMap } = istanbulCoverage;\n\nimport { convertToIstanbulFormat } from './istanbul-converter.js';\nimport { parseFunctionsFromFile } from './ast-parser.js';\nimport { globFiles } from './glob-utils.js';\nimport { mergeCoverageData } from './coverage-merge.js';\nimport { debug } from '../util/debug.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport type {\n AssemblyScriptCoveragePayload,\n CoverageData,\n GlobResult,\n ResolvedHybridProviderOptions,\n} from '../types/types.js';\nimport {\n POOL_ERROR_NAMES,\n COVERAGE_PAYLOAD_FORMATS\n} from '../types/constants.js';\nimport { warnIfASCoverageNotSupportedByNode, warnIfNativeBuildFailed } from '../util/feature-check.js';\n\nexport class HybridCoverageProvider implements CoverageProvider {\n name = 'hybrid-assemblyscript-v8' as const;\n\n private v8Provider: CoverageProvider | undefined;\n private accumulatedCoverageData: CoverageData = { hitCountsByFileAndPosition: {} };\n private projectRoot: string = '';\n private definedCoverageOptions: ResolvedCoverageOptions = {} as ResolvedCoverageOptions;\n private resolvedProviderOptions: ResolvedHybridProviderOptions = {} as ResolvedHybridProviderOptions;\n\n /**\n * Initialize the provider and get reference to v8 provider\n */\n async initialize(ctx: Vitest): Promise<void> {\n this.projectRoot = ctx.config.root;\n this.definedCoverageOptions = ctx.config.coverage;\n\n debug('[HybridCoverageProvider] Initializing Provider');\n\n // Get v8 provider from the coverage module\n this.v8Provider = await v8CoverageModule.getProvider();\n\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'initialize failed to get delegated v8 provider',\n );\n }\n\n await this.v8Provider.initialize(ctx);\n this.v8Provider.name = 'hybrid-assemblyscript-v8 (delegated v8 reporter)' as const;\n debug('[HybridCoverageProvider] Initialized with delegated v8 provider');\n\n warnIfASCoverageNotSupportedByNode();\n await warnIfNativeBuildFailed();\n }\n\n /**\n * Handle suite completion - delegate based on coverage format marker\n */\n async onAfterSuiteRun(meta: AfterSuiteRunMeta): Promise<void> {\n const start = performance.now();\n const format: string | undefined = (meta?.coverage as any)?.__format;\n let suiteLogLabel = meta.testFiles.length > 0 ? basename(meta.testFiles[0]!) : '';\n\n // Check for AssemblyScript format marker\n if (format === COVERAGE_PAYLOAD_FORMATS.AssemblyScript) {\n const payload = meta.coverage as AssemblyScriptCoveragePayload;\n const { coverageData, suiteLogLabel: label } = payload;\n suiteLogLabel = label;\n\n debug(() => {\n const fileCount = Object.keys(coverageData.hitCountsByFileAndPosition).length;\n const positionCount = Object.values(coverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions).length, 0);\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun - Suite payload: ${positionCount} unique positions over ${fileCount} source files`;\n });\n\n // Merge incoming coverage data into accumulated (by position, summing hit counts)\n mergeCoverageData(this.accumulatedCoverageData, coverageData);\n\n debug(() => {\n const fileCount = Object.keys(this.accumulatedCoverageData.hitCountsByFileAndPosition).length;\n const positionCount = Object.values(this.accumulatedCoverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions).length, 0);\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun - Accumulated coverage: ${positionCount} unique positions over ${fileCount} source files`;\n });\n } else {\n // Delegate to v8 provider for all other formats (JS, etc.)\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'onAfterSuiteRun failed to delegate to v8 provider',\n );\n }\n\n debug(`[HybridCoverageProvider] ${suiteLogLabel} - Delegating to v8 provider`);\n await this.v8Provider.onAfterSuiteRun(meta);\n }\n\n debug(() => {\n const files = meta.testFiles.map(tf => relative(this.projectRoot, tf)).join(',');\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun complete - TIMING ${(performance.now() - start).toFixed(2)} ms | testFiles: \"${files}\"`;\n });\n }\n\n /**\n * Generate unified coverage map (merging JS and AS coverage)\n *\n * Flow:\n * 1. Parse included AS source files to get sourceDebugInfo (source of truth for line numbers)\n * 1. Build merged CoverageData (all source functions + accumulated hit counts)\n * 4. Convert merged CoverageData to Istanbul format\n * 5. Get JS coverage from v8 provider\n * 6. Merge AS coverage into JS coverage\n */\n async generateCoverage(context: ReportContext): Promise<unknown> {\n const start = performance.now();\n\n debug('[HybridCoverageProvider] Generating coverage for test run');\n\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'generateCoverage failed to delegate to v8 provider',\n );\n }\n\n // Build AS coverage map\n let asCoverageMap = createCoverageMap();\n\n if (this.resolvedProviderOptions.globbedAssemblyScriptInclude.length > 0) {\n debug(`[HybridCoverageProvider] Building AS coverage map with ${this.resolvedProviderOptions.globbedAssemblyScriptInclude.length} source files `);\n debug(() => {\n const accumulatedPositionCount = Object.values(this.accumulatedCoverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions)?.length, 0);\n const files = Object.keys(this.accumulatedCoverageData.hitCountsByFileAndPosition).length;\n return `[HybridCoverageProvider] Accumulated coverage data has ${accumulatedPositionCount} unique positions hit across ${files} debug source files`;\n });\n\n // parse source files with AST parser, then match to hits and convert to istanbul format\n const fileProcessingPromises = this.resolvedProviderOptions.globbedAssemblyScriptInclude.map(async (include: GlobResult) => {\n debug(`[HybridCoverageProvider] Parsing AS source for expected coverage: \"${include.absolute}\"`);\n \n const functionsByStartLine = await parseFunctionsFromFile(include.absolute, include.projectRootRelative) || {};\n debug(`[HybridCoverageProvider] Parsed ${Object.keys(functionsByStartLine).length} AS source functions in \"${include.absolute}\"`);\n\n const fileHitCountsByPosition = this.accumulatedCoverageData.hitCountsByFileAndPosition[include.absolute] ?? {};\n debug(`[HybridCoverageProvider] Accumulated AS coverage has ${Object.keys(fileHitCountsByPosition).length} positions for \"${include.absolute}\"`);\n\n // Containment matching (binary hit position → source) is performed during istanbul conversion\n return convertToIstanbulFormat(functionsByStartLine, fileHitCountsByPosition, include.absolute, this.resolvedProviderOptions.debugIstanbul);\n });\n\n // Wait for all files to complete\n const istanbulResults = await Promise.all(fileProcessingPromises);\n\n // Add all results to coverage map\n for (const istanbulData of istanbulResults) {\n asCoverageMap.addFileCoverage(istanbulData);\n }\n\n debug(`[HybridCoverageProvider] Built AS coverage map with ${Object.keys(asCoverageMap.data).length} files`);\n } else {\n debug('[HybridCoverageProvider] WARNING: No assemblyScriptInclude patterns yieldled files - Coverage Map will be empty!');\n }\n\n const asGenerateEnd = performance.now();\n debug(`[HybridCoverageProvider] TIMING AS generateCoverage: ${(asGenerateEnd - start).toFixed(2)} ms`);\n\n // Get JS coverage from v8 provider\n debug('[HybridCoverageProvider] Getting JS coverage from v8 provider');\n const jsCoverage = await this.v8Provider.generateCoverage(context) as CoverageMap;\n debug(`[HybridCoverageProvider] JS coverage has ${Object.keys(jsCoverage.data).length} files`);\n debug(`[HybridCoverageProvider] TIMING JS generateCoverage: ${(performance.now() - asGenerateEnd).toFixed(2)} ms`);\n\n // Merge AS coverage into JS coverage.\n // Use toJSON() to pass plain data instead of the CoverageMap instance. This avoids\n // instanceof failures when istanbul-lib-coverage is loaded from different module paths\n // (e.g. the pool workers resolve one copy while the coverage provider resolves another).\n if (asCoverageMap.files().length) {\n debug('[HybridCoverageProvider] Merging AS coverage into JS coverage');\n jsCoverage.merge(asCoverageMap.toJSON());\n } else {\n debug('[HybridCoverageProvider] AS coverage map empty, not merging into JS coverage');\n }\n debug(`[HybridCoverageProvider] Final merged coverage has ${Object.keys(jsCoverage.data).length} files`);\n\n debug(`[HybridCoverageProvider] TIMING Total generateCoverage: ${(performance.now() - start).toFixed(2)} ms`);\n\n return jsCoverage;\n }\n\n /**\n * Report coverage - delegate to v8 provider\n */\n async reportCoverage(coverageMap: unknown, context: ReportContext): Promise<void> {\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'reportCoverage failed to delegate to v8 provider',\n );\n }\n\n debug(`[HybridCoverageProvider] Reporting coverage (allTestsRun=${context.allTestsRun})`);\n await this.v8Provider.reportCoverage(coverageMap, context);\n }\n\n /**\n * Resolve options\n */\n resolveOptions(): ResolvedHybridProviderOptions {\n if (!this.v8Provider) {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'resolveOptions failed to delegate to v8 provider',\n );\n }\n \n debug(`[HybridCoverageProvider] Resolving Coverage Options`);\n \n const resolvedV8Options = this.v8Provider.resolveOptions() as ResolvedCoverageOptions;\n\n // For some reason the v8 provider builds its `excludes` values to include a null byte.\n // Remove null bytes for logging purposes so tools like grep won't complain about binary content.\n const sanitizedV8Options: ResolvedCoverageOptions = {\n ...resolvedV8Options,\n include: resolvedV8Options.include?.map(i => i.replace(/\\0/g, '')) || undefined,\n exclude: resolvedV8Options.exclude?.map(i => i.replace(/\\0/g, '')) || undefined\n };\n\n debug(`[HybridCoverageProvider] AS include: ${(this.definedCoverageOptions.assemblyScriptInclude || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] AS exclude: ${(this.definedCoverageOptions.assemblyScriptExclude || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] JS include: ${(sanitizedV8Options.include || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] JS exclude: ${(sanitizedV8Options.exclude || []).join(', ') || '(none)'}`);\n\n debug(`[HybridCoverageProvider] Globbing AS source files to include for coverage map basis`);\n const globbedAssemblyScriptInclude = globFiles(\n this.definedCoverageOptions.assemblyScriptInclude || [],\n this.definedCoverageOptions.assemblyScriptExclude || [],\n this.projectRoot\n );\n debug(`[HybridCoverageProvider] Including ${globbedAssemblyScriptInclude.length} AS files in coverage map`);\n \n const globbedAssemblyScriptExcludeOnly = globFiles(\n this.definedCoverageOptions.assemblyScriptExclude || [],\n [],\n this.projectRoot\n );\n debug(`[HybridCoverageProvider] Excluding ${globbedAssemblyScriptExcludeOnly.length} AS files from coverage map & instrumentation`);\n \n const resolved: ResolvedHybridProviderOptions = {\n ...resolvedV8Options,\n provider: 'custom',\n customProviderModule: this.definedCoverageOptions.customProviderModule || '',\n debugIstanbul: this.definedCoverageOptions.debugIstanbul ?? false,\n assemblyScriptInclude: this.definedCoverageOptions.assemblyScriptInclude ?? [],\n assemblyScriptExclude: this.definedCoverageOptions.assemblyScriptExclude ?? [],\n globbedAssemblyScriptInclude,\n globbedAssemblyScriptProjectRelativeExcludeOnly : globbedAssemblyScriptExcludeOnly.map(gr => gr.projectRootRelative),\n isResolved: true\n }; \n\n this.resolvedProviderOptions = resolved;\n return resolved;\n }\n\n async clean(clean: boolean = true): Promise<void> {\n debug('[HybridCoverageProvider] Clean coverage data - clean:', clean);\n if (clean) {\n this.accumulatedCoverageData = { hitCountsByFileAndPosition: {} };\n debug('[HybridCoverageProvider] Cleaned all internal coverage data');\n }\n\n if (this.v8Provider) {\n await this.v8Provider.clean(clean);\n debug(`[HybridCoverageProvider] V8 provider finished clean(${clean})`);\n }\n }\n}\n","/**\n * Coverage Provider Module Export\n *\n * This module exports the hybrid coverage provider for Vitest to load.\n * Users configure this via:\n * coverage.provider = 'custom'\n * coverage.customProviderModule = 'vitest-pool-assemblyscript/coverage'\n */\n\nimport { CoverageProviderModule } from 'vitest/node';\nimport v8CoverageModule from '@vitest/coverage-v8';\n\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport { HybridCoverageProvider } from './hybrid-coverage-provider.js';\n\n/**\n * Hybrid Coverage Provider\n *\n * This provider handles both AssemblyScript and JavaScript and coverage\n * - Converts AS coverage to Istanbul format\n * - Delegates JS coverage to Vitest's v8 provider\n * - Merges both into a unified coverage report\n */\nconst hybridProviderModule: CoverageProviderModule = {\n getProvider: (): HybridCoverageProvider => new HybridCoverageProvider(),\n\n startCoverage: async (runtimeOptions: {\n isolate: boolean,\n autoAttachSubprocess: boolean,\n reportsDirectory: string\n }): Promise<unknown> => {\n if (v8CoverageModule.startCoverage) {\n return await v8CoverageModule.startCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'HybridCoverageProvider - v8 coverage module does not provide `startCoverage`',\n );\n }\n },\n \n takeCoverage: async (runtimeOptions?: any): Promise<unknown> => {\n if (v8CoverageModule.takeCoverage) {\n return await v8CoverageModule.takeCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'HybridCoverageProvider - v8 coverage module does not provide `takeCoverage`',\n );\n }\n },\n \n stopCoverage: async (runtimeOptions: {\n isolate: boolean\n }): Promise<unknown> => {\n if (v8CoverageModule.stopCoverage) {\n return await v8CoverageModule.stopCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.HybridCoverageProviderError,\n 'HybridCoverageProvider - v8 coverage module does not provide `stopCoverage`',\n );\n }\n },\n};\n\nexport default hybridProviderModule;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgB,+BACd,sBACA,MACA,QACsC;CACtC,IAAI;CACJ,IAAI,gBAAgB;CACpB,IAAI,kBAAkB;AAGtB,MAAK,MAAM,CAAC,cAAc,cAAc,OAAO,QAAQ,qBAAqB,EAAE;EAC5E,MAAM,YAAY,OAAO,aAAa;AACtC,MAAI,YAAY,KAAM;AAEtB,OAAK,MAAM,QAAQ,WAAW;GAC5B,MAAM,EAAE,UAAU;AAGlB,OAAI,CAAC,kBAAkB,MAAM,QAAQ,MAAM,CAAE;AAG7C,OAAI,YAAY,iBACX,cAAc,iBAAiB,MAAM,cAAc,iBAAkB;AACxE,gBAAY;AACZ,oBAAgB;AAChB,sBAAkB,MAAM;;;;AAK9B,QAAO;;;;;;;;;;AAWT,SAAgB,kBACd,MACA,QACA,OACS;AAET,KAAI,OAAO,MAAM,aAAa,OAAO,MAAM,QAAS,QAAO;AAG3D,KAAI,SAAS,MAAM,aAAa,SAAS,MAAM,YAAa,QAAO;AAGnE,KAAI,SAAS,MAAM,WAAW,SAAS,MAAM,UAAW,QAAO;AAE/D,QAAO;;;;;;;;;;;;;;;;;;;;;;;AC3DT,eAAsB,wBACpB,0BACA,yBACA,kBACA,sBAC2B;CAC3B,MAAM,aAAa,YAAY,KAAK;CAEpC,SAAS,cAAc,GAAG,MAAmB;AAC3C,MAAI,qBACF,eAAc,GAAG,KAAK;;AAI1B,qBAAoB;EAClB,MAAM,sBAAsB,OAAO,OAAO,yBAAyB,CAAC,QAAQ,KAAK,UAAU,MAAM,MAAM,QAAQ,EAAE;EACjH,MAAM,oBAAoB,OAAO,KAAK,wBAAwB,CAAC;AAG/D,SAAO,kDAAkD,iBAAiB,mC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