vitest-pool-assemblyscript 0.10.0 → 0.10.1

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 (29) hide show
  1. package/dist/{addon-interface-DJB-K27u.mjs → addon-interface-BaUmn7uC.mjs} +2 -2
  2. package/dist/{addon-interface-DJB-K27u.mjs.map → addon-interface-BaUmn7uC.mjs.map} +1 -1
  3. package/dist/{compile-runner-D4SJWhMh.mjs → compile-runner-BGHM_85g.mjs} +5 -5
  4. package/dist/{compile-runner-D4SJWhMh.mjs.map → compile-runner-BGHM_85g.mjs.map} +1 -1
  5. package/dist/{compiler-DSKhQ5--.mjs → compiler-CXR5UJId.mjs} +4 -4
  6. package/dist/{compiler-DSKhQ5--.mjs.map → compiler-CXR5UJId.mjs.map} +1 -1
  7. package/dist/config/index.mjs +3 -3
  8. package/dist/coverage-provider/index.mjs +2 -2
  9. package/dist/{feature-check-DLfJqIrE.mjs → feature-check-BJpc4LoO.mjs} +3 -3
  10. package/dist/{feature-check-DLfJqIrE.mjs.map → feature-check-BJpc4LoO.mjs.map} +1 -1
  11. package/dist/index-internal.mjs +3 -3
  12. package/dist/index-v3.mjs +2 -2
  13. package/dist/index.mjs +3 -3
  14. package/dist/{load-user-imports-6Pv-9hRg.mjs → load-user-imports-Bcx9NOt9.mjs} +22 -9
  15. package/dist/load-user-imports-Bcx9NOt9.mjs.map +1 -0
  16. package/dist/{pool-errors-GWfwrsD7.mjs → pool-errors-Bn6YaguR.mjs} +4 -5
  17. package/dist/pool-errors-Bn6YaguR.mjs.map +1 -0
  18. package/dist/{pool-runner-init-Cta6aVJ6.mjs → pool-runner-init-DjRCbiX-.mjs} +3 -3
  19. package/dist/{pool-runner-init-Cta6aVJ6.mjs.map → pool-runner-init-DjRCbiX-.mjs.map} +1 -1
  20. package/dist/pool-thread/compile-worker-thread.mjs +6 -6
  21. package/dist/pool-thread/test-worker-thread.mjs +5 -5
  22. package/dist/pool-thread/v3-tinypool-thread.mjs +7 -7
  23. package/dist/{test-runner-M21HMDdH.mjs → test-runner-BeP8ClnE.mjs} +4 -4
  24. package/dist/{test-runner-M21HMDdH.mjs.map → test-runner-BeP8ClnE.mjs.map} +1 -1
  25. package/dist/{vitest-file-tasks-Coc4btUw.mjs → vitest-file-tasks-vvZzigcF.mjs} +2 -2
  26. package/dist/{vitest-file-tasks-Coc4btUw.mjs.map → vitest-file-tasks-vvZzigcF.mjs.map} +1 -1
  27. package/package.json +1 -1
  28. package/dist/load-user-imports-6Pv-9hRg.mjs.map +0 -1
  29. package/dist/pool-errors-GWfwrsD7.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"vitest-file-tasks-Coc4btUw.mjs","names":[],"sources":["../src/types/types.ts","../src/util/resolve-config.ts","../src/types/typed-constants.ts","../src/util/vitest-tasks.ts","../src/util/vitest-file-tasks.ts"],"sourcesContent":["/*\n * Shared TypeScript types and interfaces\n */\n\nimport type { MessagePort } from 'node:worker_threads';\nimport type { BirpcReturn } from 'birpc';\nimport type { RunnerRPC, RuntimeRPC, SerializedConfig } from 'vitest';\nimport type { TestError } from '@vitest/utils';\nimport type { ResolvedCoverageOptions } from 'vitest/node';\nimport type { File, Test, TaskMeta, TestOptions } from '@vitest/runner/types';\nimport type { RawSourceMap } from 'source-map';\n\nimport {\n AS_POOL_WORKER_MSG_FLAG,\n COVERAGE_PAYLOAD_FORMATS,\n POOL_ERROR_NAMES,\n TEST_ERROR_NAMES,\n AS_POOL_ERROR_FLAG,\n} from './constants.js';\n\n// ============================================================================\n// Errors\n// ============================================================================\n\n/** Error name type derived from TEST_ERROR_NAMES values */\nexport type TestErrorName = typeof TEST_ERROR_NAMES[keyof typeof TEST_ERROR_NAMES];\n\n/** Error name type derived from POOL_ERROR_NAMES values */\nexport type PoolErrorName = typeof POOL_ERROR_NAMES[keyof typeof POOL_ERROR_NAMES];\n\nexport interface AssemblyScriptPoolError {\n readonly [AS_POOL_ERROR_FLAG]: true;\n name: PoolErrorName;\n message?: string;\n originalErrorRawStack: NodeJS.CallSite[];\n originalErrorMayContainJS: boolean;\n applyStackToTestErrorCause: boolean;\n testError: AssemblyScriptTestError;\n}\n\n/**\n * Extended vitest TestError with required, strictly-typed name field.\n * This is an explicitly serializable error format constructred to report\n * Test/Suite failures to vitest.\n */\nexport interface AssemblyScriptTestError extends TestError {\n // reported error can originate as a test error (assertion/runtime),\n // or as a pool failnure (harness error due to OOM, other unexpected paths)\n name: TestErrorName | PoolErrorName\n}\n\n/**\n * Native build error marker file content.\n * Written by install script when native addon compilation fails.\n * Read at runtime to display detailed error information to users.\n */\nexport interface NativeBuildError {\n stage: 'binaryen-download' | 'native-compile';\n error: string;\n platform: string;\n timestamp: string;\n}\n\n// ============================================================================\n// User Configuration\n// ============================================================================\n\n/**\n * AssemblyScript pool configuration options\n */\nexport interface AssemblyScriptPoolOptions {\n /** Enable verbose debug logging */\n debug?: boolean;\n debugNative?: boolean;\n debugCoverageExtract?: boolean;\n\n /** enable to collect coverage instrumentation on the pool's assembly/* files */\n _instrumentPoolInternals?: boolean;\n\n /**\n * Strip `@inline` decorators during compilation to improve error message and coverage accuracy\n *\n * - When true (default): `@inline` decorators removed, functions become visible in coverage\n * and source mapped errors point to the correct lines\n * - When false: `@inline` functions are inlined by compiler, missing from coverage, and \n * error line numbers don't match the non-inlined source\n * @default true\n */\n stripInline?: boolean;\n\n /**\n * Maximum number of worker threads to spawn with vitest 3.x.\n * Defaults to os.availableParallelism() - 1\n * \n * Use project config `test.maxWorkers` with vitest 4.x to control\n * the number of cuncurrently executing tests. \n */\n maxThreadsV3?: number;\n\n coverageMemoryPagesInitial?: number;\n coverageMemoryPagesMax?: number;\n\n testMemoryPagesInitial?: number;\n testMemoryPagesMax?: number;\n\n extraCompilerFlags?: string[];\n\n wasmImportsFactory?: string;\n}\n\n/**\n * AssemblyScript-specific coverage fields contributed by the hybrid coverage\n * provider on top of vitest's standard coverage options.\n *\n * Single source of truth for these field declarations: extended by the\n * vitest module augmentation files in `src/config/` so users get autocomplete\n * on these fields in their `vitest.config.ts` coverage block, and consumed\n * internally via `Required<HybridProviderOptions>` in\n * `ResolvedHybridProviderOptions`.\n */\nexport interface HybridProviderOptions {\n debugIstanbul?: boolean;\n\n /**\n * Glob patterns for AssemblyScript source files to include in coverage.\n * Used to build the complete AS coverage map.\n *\n * The standard `include` patterns are used by the v8 provider for JS/TS files.\n *\n * @example ['assembly/**\\/*.as.ts']\n */\n assemblyScriptInclude?: string[];\n\n /**\n * Glob patterns for AssemblyScript files to exclude from coverage.\n *\n * @example ['**\\/*.as.test.ts']\n */\n assemblyScriptExclude?: string[];\n}\n\nexport interface WasmImportsFactoryInfo {\n module: WebAssembly.Module;\n memory: WebAssembly.Memory;\n utils: {\n liftString: (stringPtr: number) => string | undefined;\n }\n}\n\nexport type WasmImportsFactory = (moduleInfo: WasmImportsFactoryInfo) => WebAssembly.Imports;\n\n// define these constants here so they make sense in context\nexport const AS_POOL_FIELDS_WITH_DEFAULTS = [\n 'debug',\n 'debugNative',\n 'debugCoverageExtract',\n '_instrumentPoolInternals',\n 'stripInline',\n 'maxThreadsV3',\n 'extraCompilerFlags'\n] as const;\n\nexport const AS_POOL_OPTIONAL_FIELDS = [\n 'testMemoryPagesInitial',\n 'testMemoryPagesMax',\n 'coverageMemoryPagesInitial',\n 'coverageMemoryPagesMax',\n 'wasmImportsFactory'\n] as const;\n\n/** Fields that have default values. Internally these will always be defined. */\nexport type ASPoolOptionsFieldsWithDefaultValues = typeof AS_POOL_FIELDS_WITH_DEFAULTS[number];\n\n/** Fields with optional values and NO defaults */\nexport type ASPoolOptionsOptionalFields = typeof AS_POOL_OPTIONAL_FIELDS[number];\n// compatibility type for internal consumption - configs from all versions\n// of Vitest are converted to this format for internal consumption\nexport type SerializedConfigCompat = SerializedConfig & {\n retry: number;\n};\n\n /**\n * Pool options resolved so that all fields are filled with user values preferentially, \n * with required fields being guaranteed to be populated with defaults otherwise.\n */\nexport type ResolvedAssemblyScriptPoolOptions =\n Required<Pick<AssemblyScriptPoolOptions, ASPoolOptionsFieldsWithDefaultValues>>\n & Partial<Pick<AssemblyScriptPoolOptions, ASPoolOptionsOptionalFields>>\n & { readonly isResolved: true };\n\nexport type ResolvedHybridProviderOptions =\n Required<HybridProviderOptions>\n & Omit<ResolvedCoverageOptions, 'provider'>\n & {\n provider: 'custom';\n customProviderModule: string;\n globbedAssemblyScriptInclude: GlobResult[];\n globbedAssemblyScriptProjectRelativeExcludeOnly: string[];\n }\n & { readonly isResolved: true };\n\n// vitest TestOptions fields that are supported by AssemblyScript tests in this pool\nexport type AssemblyScriptTestOptions = Required<Pick<TestOptions, 'timeout' | 'retry' | 'skip' | 'only' | 'fails'>>;\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\nexport type VitestVersion = 'v3' | 'v4';\n\nexport interface ThreadImports {\n createUserWasmImports?: WasmImportsFactory;\n}\n\nexport interface GlobResult {\n absolute: string;\n projectRootRelative: string;\n}\n\n// ============================================================================\n// Compilation & Results\n// ============================================================================\n\nexport interface WASMCompilation {\n filePath: string;\n sourceMap: RawSourceMap;\n debugInfo?: BinaryDebugInfo;\n compiledModule: WebAssembly.Module;\n requiredMemory: WASMModuleMemoryRequirements;\n isInstrumented: boolean;\n compileTiming: number;\n}\n\nexport interface WASMImportMemoryRequirements {\n initialPages: number;\n maximumPages?: number;\n};\n\nexport interface WASMModuleMemoryRequirements {\n testMemory: WASMImportMemoryRequirements;\n coverageMemory: WASMImportMemoryRequirements;\n}\n\nexport interface AssemblyScriptCompilerOptions {\n shouldInstrument: boolean;\n projectRoot: string;\n instrumentationOptions?: InstrumentationOptions;\n stripInline?: boolean;\n extraFlags?: string[];\n}\n\nexport interface InstrumentationOptions {\n /** Project root for resolving source map paths to absolute paths */\n projectRoot: string;\n /** List of relative file paths to exclude from instrumentation */\n relativeExcludedFiles: string[];\n excludedLibraryFilePrefix: string;\n excludedLibraryFileOverridePrefix?: string;\n excludedInternalFunctionSubstring: string;\n coverageMemoryPagesMin: number;\n coverageMemoryPagesMax?: number;\n debug?: boolean;\n coverageMemoryModule: string;\n coverageMemoryName: string;\n}\n\n/**\n * Result of instrumenting a WASM binary for coverage\n */\nexport interface InstrumentationResult {\n /** Instrumented WASM binary with coverage counter increments */\n instrumentedWasm: Buffer;\n /** Regenerated source map (offsets adjusted for instrumentation) */\n sourceMap: string;\n /** Debug info with coverageMemoryIndex assigned to each function */\n debugInfo: BinaryDebugInfo;\n}\n\n// ============================================================================\n// Error Source Mapping\n// ============================================================================\n\n/**\n * Source location in original AssemblyScript code (a point, not a range)\n *\n * All values are 1-based for internal consistency.\n * Conversion to 0-based columns happens at Istanbul output boundary.\n */\nexport interface SourceLocation {\n /** Absolute file path (normalized from source map during debug info extraction) */\n filePath: string;\n line: number;\n column: number;\n}\n\n/**\n * WebAssembly call site with mapped source location\n */\nexport interface WebAssemblyCallSite {\n functionName: string;\n location: SourceLocation;\n}\n\n// ============================================================================\n// Coverage Data (Runtime Hit Counts)\n// ============================================================================\n\n/**\n * Coverage data collected during test execution\n *\n * Simple hit count storage using position-based keys for stable merging.\n * Note: Function source metadata (names, ranges) comes from ParsedSourceInfo.\n *\n * Outer Record: keyed by absolute file path\n * Inner Record: keyed by position (\"line:column\") → hit count\n */\nexport interface CoverageData {\n hitCountsByFileAndPosition: Record<string, Record<string, number>>;\n}\n\n/**\n * Coverage payload sent via RPC from worker to hybrid coverage provider\n *\n * The __format marker distinguishes AS coverage from JS coverage in onAfterSuiteRun.\n */\nexport interface AssemblyScriptCoveragePayload {\n readonly __format: typeof COVERAGE_PAYLOAD_FORMATS.AssemblyScript;\n coverageData: CoverageData;\n suiteLogLabel: string;\n}\n\n\n// ============================================================================\n// Binary Debug Info (returned from native instrumentation addon)\n// ============================================================================\n//\n// These types represent debug information extracted from compiled WASM binaries\n// via the native addon. Binary debug info only has POINTS (from source map),\n// not ranges. Ranges come from source parsing (ParsedSource* types below).\n//\n// Naming convention: *DebugInfo suffix indicates binary-extracted data.\n\n/**\n * Source range in original AssemblyScript code (start and end points)\n *\n * All values are 1-based for internal consistency.\n * Conversion to 0-based columns happens at Istanbul output boundary.\n */\nexport interface SourceRange {\n /** Relative file path */\n filePath: string;\n startLine: number;\n startColumn: number;\n endLine: number;\n endColumn: number;\n}\n\n/**\n * Branch edge in control flow graph\n */\nexport interface BranchEdgeDebugInfo {\n /** Target basic block index */\n targetBlockIndex: number;\n /** Index of the expression that creates this branch (e.g., if condition) */\n sourceExpressionIndex?: number;\n}\n\n/**\n * Expression debug info extracted from WASM binary\n *\n * Expressions are the smallest unit of execution in WASM.\n * In v2, each expression can be mapped to a source statement for line-level coverage.\n */\nexport interface ExpressionDebugInfo {\n /** WASM expression type (e.g., \"call\", \"if\", \"block\") */\n type: string;\n /** Source location (POINT, not range) from source map */\n location?: SourceLocation;\n /** Whether this expression is a branch point (if, switch, select) */\n isBranch: boolean;\n /** Number of branch paths (for branch coverage) */\n branchPaths?: number;\n /**\n * Index into coverage memory counters\n * v2 only: Propagated from containing BasicBlockDebugInfo by TS wrapper\n */\n coverageMemoryIndex?: number;\n}\n\n/**\n * Basic block debug info from CFG analysis\n *\n * Basic blocks are sequences of expressions with single entry/exit points.\n * In v2, counters are placed at basic block boundaries for efficient coverage.\n */\nexport interface BasicBlockDebugInfo {\n /** Block index within the function */\n index: number;\n /** Indices of expressions contained in this block */\n expressionIndices: number[];\n /** Outgoing branch edges */\n branches: BranchEdgeDebugInfo[];\n /**\n * Index into coverage memory counters\n * v2 only: Source of truth for block-level coverage\n */\n coverageMemoryIndex?: number;\n}\n\n/**\n * Function debug info extracted from WASM binary via native addon\n */\nexport interface FunctionDebugInfo {\n /** WASM function index */\n wasmIndex: number;\n /** Function name from WASM (informational) */\n name: string;\n /**\n * Representative source location (a point within the function).\n * Used for containment matching to find the parsedsource function.\n */\n representativeLocation: SourceLocation;\n /** Index into coverage memory counters */\n coverageMemoryIndex: number;\n /** All expressions in this function */\n expressions: ExpressionDebugInfo[];\n /** Basic blocks from CFG analysis */\n basicBlocks: BasicBlockDebugInfo[];\n}\n\n/**\n * Binary debug info extracted from WASM + source map via native addon\n *\n * This is the processed output after TS wrapper transforms NativeDebugInfoOutput.\n * Functions are grouped by file and keyed by position for stable identity.\n */\nexport interface BinaryDebugInfo {\n /** All source files represented in extracted debug info (directly or inlined) */\n debugSourceFiles: string[];\n /**\n * Functions grouped by file path, then keyed by position (\"line:column\").\n * Position key enables stable identity across compilations.\n * Array value accommodates generic monomorphizations that share a source position.\n */\n functionsByFileAndPosition: Record<string, Record<string, FunctionDebugInfo[]>>;\n\n instrumentedFunctionCount: number;\n}\n\n/**\n * Raw output from native addon's instrumentForCoverage() C++ function\n */\nexport interface NativeInstrumentationResult {\n instrumentedWasm: Buffer;\n sourceMap: string;\n debugInfo: NativeDebugInfoOutput;\n errors?: string[];\n}\n\nexport interface NativeDebugInfoOutput {\n /** All source files represented in extracted debug info (directly or inlined) */\n debugSourceFiles: string[];\n /** Flat list of all functions with their debug info */\n functions: NativeFunctionDebugInfo[];\n}\n\nexport interface NativeFunctionDebugInfo extends Omit<FunctionDebugInfo, 'expressions' | 'representativeLocation'> {\n representativeLocation: NativeSourceLocation;\n expressions: NativeExpressionDebugInfo[];\n}\n\nexport interface NativeExpressionDebugInfo extends Omit<ExpressionDebugInfo, 'location'> {\n location?: NativeSourceLocation;\n}\n\nexport interface NativeSourceLocation extends Omit<SourceLocation, 'filePath'> {\n /** Index into NativeDebugInfoOutput.debugSourceFiles */\n fileIndex: number;\n}\n\nexport interface NativeInstrumentationOptions extends Omit<InstrumentationOptions, 'relativeExcludedFiles' | 'projectRoot'> {\n excludedFiles?: string[];\n logPrefix?: string;\n}\n\nexport type InstrumentForCoverageFunc = (\n wasmBuffer: Buffer,\n sourceMapBuffer: Buffer,\n instrumentationOptions: InstrumentationOptions,\n logModule: string,\n logLabel: string,\n) => InstrumentationResult;\n\nexport interface NativeAddonInterface {\n instrumentForCoverage: InstrumentForCoverageFunc;\n}\n\n/**\n * Typed interface for the native addon's exported methods.\n * The addon is loaded via node-gyp-build at runtime (CJS .node binary).\n */\nexport interface NativeAddon {\n instrumentForCoverage(\n wasmBuffer: Buffer,\n sourceMapBuffer: Buffer,\n options: NativeInstrumentationOptions,\n ): NativeInstrumentationResult;\n}\n\n// ============================================================================\n// Parsed Source Info (from AST Parser)\n// ============================================================================\n//\n// These types represent information parsed from source files via AST.\n// Parsed source info has *ranges* (start and end positions) for containment matching.\n\n/**\n * Function info parsed from AssemblyScript source via AST\n */\nexport interface ParsedSourceFunctionInfo {\n /** Fully \"qualified\" (WASM debug) name */\n qualifiedName: string;\n /** Short name for display */\n shortName: string;\n /** Source range for containment matching */\n range: SourceRange;\n}\n\n/**\n * Statement info parsed from AssemblyScript source via AST\n *\n * v2 only: Used for line-level statement coverage.\n * Binary expression points are matched to source statement ranges.\n */\nexport interface ParsedSourceStatementInfo {\n /** Source range for containment matching */\n range: SourceRange;\n /** Statement type (e.g., \"variable\", \"expression\", \"return\") */\n statementType?: string;\n}\n\n/**\n * Branch info parsed from AssemblyScript source via AST\n *\n * v2 only: Used for branch coverage.\n * Binary branch expressions are matched to source branch ranges.\n */\nexport interface ParsedSourceBranchInfo {\n /** Source range for containment matching */\n range: SourceRange;\n /** Type of branch construct */\n branchType: 'if' | 'ternary' | 'switch' | 'logical';\n}\n\n/**\n * Complete parsed source info from AST parser\n *\n * Generated by coverage provider when processing coverage (not during compilation).\n * Provides the \"what SHOULD be covered\" view from source code.\n */\nexport interface ParsedSourceInfo {\n /**\n * Functions grouped by file path, then by start line for containment matching.\n * Multiple functions can start on the same line, but limiting matching to checking\n * only the functions grouped on the input position's line is very performant.\n */\n functionsByFileAndStartLine: Record<string, Record<number, ParsedSourceFunctionInfo[]>>;\n /**\n * Statements grouped by file path, then keyed by position (\"line:column\")\n * v2 only: For line-level statement coverage\n */\n statementsByFileAndPosition: Record<string, Record<string, ParsedSourceStatementInfo>>;\n /**\n * Branches grouped by file path, then keyed by position (\"line:column\")\n * v2 only: For branch coverage\n */\n branchesByFileAndPosition: Record<string, Record<string, ParsedSourceBranchInfo>>;\n}\n\n// ============================================================================\n// Worker Communication & RPC\n// ============================================================================\n\nexport interface AssemblyScriptConsoleLog {\n msg: string;\n time: number;\n isError: boolean;\n}\n\nexport type AssemblyScriptConsoleLogHandler = (msg: string, isError?: boolean) => void;\n\nexport interface FailedAssertion {\n expected?: string;\n actual?: string;\n valuesProvided: boolean;\n actualTypeName: string;\n expectedTypeName: string;\n message: string;\n}\n\nexport interface AssemblyScriptSuiteTaskMeta extends TaskMeta {\n idxInParentTasks: number;\n defaultTestOptions: AssemblyScriptTestOptions;\n suitePreparedSent: boolean;\n resultFinal: boolean;\n coverageData?: CoverageData;\n}\n\nexport interface AssemblyScriptTestTaskMeta extends TaskMeta {\n idxInParentTasks: number;\n fnIndex: number;\n assertionsPassedCount: number;\n assertionsFailed: FailedAssertion[];\n resultFinal: boolean;\n coverageData?: CoverageData;\n lastError?: AssemblyScriptTestError;\n lastErrorValuesProvided?: boolean;\n lastErrorRawCallStack?: NodeJS.CallSite[];\n lastErrorCallStackRef?: Error;\n lastErrorUnexpected?: boolean;\n lastTimeoutTerminationTime?: number;\n};\n\nexport interface WASMExecutorPerfTimings {\n /** function start */\n fnInit: number;\n /** test start: execStart - fnInit = env init time */\n execStart: number;\n /** test end: execEnd - execStart = test duration */\n execEnd: number;\n /** function end: fnFinal - execEnd = error prep and/or coverage extraction time */\n fnfinal: number;\n}\n\nexport type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;\n\n/**\n * Worker channel with RPC for suite-level communication\n */\nexport interface WorkerChannel {\n /** Port to send to worker for RPC communication */\n workerPort: MessagePort;\n /** Pool-side port for cleanup */\n poolPort: MessagePort;\n /** RPC client for calling Vitest methods (only remote functions matter for our usage) */\n rpc: WorkerRPC;\n}\n\nexport interface WorkerThreadInitData {\n asCoverageOptions: ResolvedHybridProviderOptions;\n}\n\nexport interface AssemblyScriptPoolWorkerMessageBase {\n readonly [AS_POOL_WORKER_MSG_FLAG]: true;\n readonly type: string;\n}\n\nexport interface TestFileCompiled extends AssemblyScriptPoolWorkerMessageBase {\n readonly type: 'file-compiled';\n compilation: WASMCompilation;\n}\n\n\nexport interface TestExecutionStart extends AssemblyScriptPoolWorkerMessageBase {\n readonly type: 'execution-start';\n executionStart: number;\n test: Test;\n}\n\nexport interface TestExecutionEnd extends AssemblyScriptPoolWorkerMessageBase {\n readonly type: 'execution-end';\n executionEnd: number;\n testTaskId: string;\n}\n\nexport type AssemblyScriptPoolWorkerMessage = TestExecutionStart | TestExecutionEnd | TestFileCompiled;\n\nexport interface TestRunRecord {\n test: Test;\n executionStart: number;\n timeoutId: NodeJS.Timeout;\n}\n\nexport interface ThreadSpec {\n file: File;\n compilation?: WASMCompilation;\n}\n\nexport interface RunCompileAndDiscoverTask {\n dispatchStart: number;\n workerId: number;\n port: MessagePort;\n file: File;\n config: SerializedConfigCompat;\n asPoolOptions: ResolvedAssemblyScriptPoolOptions;\n isCollectTestsMode: boolean;\n}\n\nexport interface RunTestsTask {\n dispatchStart: number;\n workerId: number;\n port: MessagePort;\n file: File;\n compilation: WASMCompilation;\n config: SerializedConfigCompat;\n asPoolOptions: ResolvedAssemblyScriptPoolOptions;\n isCollectTestsMode: boolean;\n timedOutTest?: Test;\n}\n\nexport interface ProcessPoolRunFileTask {\n dispatchStart: number;\n port: MessagePort;\n file: File;\n config: SerializedConfigCompat;\n asPoolOptions: ResolvedAssemblyScriptPoolOptions;\n isCollectTestsMode: boolean;\n timedOutTest?: Test;\n timedOutCompilation?: WASMCompilation;\n}\n","import { availableParallelism } from 'node:os';\nimport type { SerializedConfig } from 'vitest';\nimport type { Retry, SerializableRetry } from '@vitest/runner';\nimport type { Vitest } from 'vitest/node';\n\nimport type {\n AssemblyScriptPoolOptions,\n ASPoolOptionsFieldsWithDefaultValues,\n ResolvedAssemblyScriptPoolOptions,\n ResolvedHybridProviderOptions,\n SerializedConfigCompat,\n AssemblyScriptTestError,\n} from '../types/types.js';\nimport { AS_POOL_FIELDS_WITH_DEFAULTS } from '../types/types.js';\nimport { ASSEMBLYSCRIPT_POOL_NAME, POOL_ERROR_NAMES } from '../types/constants.js';\n\nconst DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS: Required<Pick<AssemblyScriptPoolOptions, ASPoolOptionsFieldsWithDefaultValues>> = {\n debug: false,\n debugNative: false,\n debugCoverageExtract: false,\n _instrumentPoolInternals: false,\n stripInline: true,\n maxThreadsV3: availableParallelism() - 1,\n extraCompilerFlags: [],\n} as const;\n\nfunction createPoolConfigError(message: string): AssemblyScriptTestError {\n return {\n name: POOL_ERROR_NAMES.PoolConfigError,\n message\n };\n}\n\n// v4: used in runner init to parse user-provided param directly\nexport function resolvePoolOptions(userPoolOptions?: any): ResolvedAssemblyScriptPoolOptions {\n const poolOptions: AssemblyScriptPoolOptions = userPoolOptions ?? DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS;\n\n // resolve fields with defaults if user hasn't provided them\n for (const configKey of AS_POOL_FIELDS_WITH_DEFAULTS) {\n if (poolOptions[configKey] === undefined) {\n poolOptions[configKey] = DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS[configKey] as any;\n }\n }\n\n const resolved = { ...poolOptions, isResolved: true } as ResolvedAssemblyScriptPoolOptions;\n\n if (\n (resolved.testMemoryPagesInitial !== undefined && resolved.testMemoryPagesInitial < 1)\n || (resolved.testMemoryPagesMax !== undefined && resolved.testMemoryPagesMax < 1)\n ) {\n throw createPoolConfigError(\n `AssemblyScript WASM test memory page size options must be positive if defined - testMemoryPagesMin: ${resolved.testMemoryPagesInitial}`\n + ` | testMemoryPagesMax: ${resolved.testMemoryPagesMax}`,\n );\n }\n\n if (\n (resolved.coverageMemoryPagesInitial !== undefined && resolved.coverageMemoryPagesInitial < 1)\n || (resolved.coverageMemoryPagesMax !== undefined && resolved.coverageMemoryPagesMax < 1)\n ) {\n throw createPoolConfigError(\n `AssemblyScript WASM coverage memory page size options must be positive if defined - coverageMemoryPagesMin: ${resolved.coverageMemoryPagesInitial}`\n + ` | coverageMemoryPagesMax: ${resolved.coverageMemoryPagesMax}`,\n );\n }\n\n return resolved;\n}\n\nexport function retryCompat(retry?: SerializableRetry | Retry): number {\n return typeof retry === 'number' ? retry : retry?.count ?? 0;\n}\n\nexport function getCompatConfig(config: SerializedConfig): SerializedConfigCompat {\n return {\n ...config,\n retry: retryCompat(config.retry)\n };\n}\n\nfunction getProjectConfigs(ctx: Vitest): {\n [key: string]: {\n config: SerializedConfigCompat,\n v3PoolOptions?: ResolvedAssemblyScriptPoolOptions\n }\n} {\n const configs = {} as {\n [key: string]: {\n config: SerializedConfigCompat,\n v3PoolOptions?: ResolvedAssemblyScriptPoolOptions\n }\n };\n\n ctx.projects\n // project.config.pool resolves to the *path of the dist file*\n .filter(p => p.config.pool.includes(ASSEMBLYSCRIPT_POOL_NAME))\n \n .forEach(project => {\n configs[project.name] = {\n config: getCompatConfig(project.serializedConfig),\n };\n\n // @ts-ignore - we build with v4, but this is correct for v3 (has config.poolOptions)\n const maybeOptions: any = project.config?.poolOptions?.assemblyScript;\n if (maybeOptions) {\n configs[project.name]!.v3PoolOptions = resolvePoolOptions(maybeOptions);\n }\n });\n \n return configs;\n}\n\nexport function getConfigs(ctx: Vitest): {\n coverage: ResolvedHybridProviderOptions;\n projects: {\n [key: string]: {\n config: SerializedConfigCompat,\n v3PoolOptions?: ResolvedAssemblyScriptPoolOptions\n }\n };\n fallbackPoolOptions: ResolvedAssemblyScriptPoolOptions;\n} {\n const coverage = ctx.config.coverage as unknown as ResolvedHybridProviderOptions;\n const projects = getProjectConfigs(ctx);\n\n // @ts-ignore - we build with v4, but this is correct for v3 (has config.poolOptions)\n let fallbackPoolOptions: ResolvedAssemblyScriptPoolOptions = resolvePoolOptions(ctx.config.poolOptions?.assemblyScript);\n\n const configs = Object.values(projects);\n if (configs.length > 0) {\n for (const config of configs) {\n if (config.v3PoolOptions?.debug) {\n fallbackPoolOptions.debug = true;\n }\n if (config.v3PoolOptions?.maxThreadsV3 !== undefined\n && config.v3PoolOptions.maxThreadsV3 > fallbackPoolOptions.maxThreadsV3\n ) {\n fallbackPoolOptions.maxThreadsV3 = config.v3PoolOptions.maxThreadsV3;\n }\n }\n }\n\n return {\n coverage,\n projects,\n fallbackPoolOptions\n };\n}\n","/**\n * Typed Constants\n * \n * Constants which require importing ./types\n */\n\nimport { AssemblyScriptTestOptions } from './types.js';\n\n// hard-coded defaults only - timeout and retry defaults always come from vitest config\nexport const DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS: Pick<AssemblyScriptTestOptions, 'fails' | 'skip' | 'only'> = {\n fails: false,\n skip: false,\n only: false\n};\n","import type { File, RunMode, Suite, Task, Test } from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptCoveragePayload,\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestError,\n AssemblyScriptTestOptions,\n AssemblyScriptTestTaskMeta,\n FailedAssertion,\n VitestVersion,\n WASMExecutorPerfTimings\n} from '../types/types.js';\nimport { TEST_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from './debug.js';\nimport { createTestExpectedToFailError, createTestTimeoutError } from './pool-errors.js';\nimport { retryCompat } from './resolve-config.js';\n\n// ============================================================================\n// Util\n// ============================================================================\n\nfunction positiveSum<T>(items: T[], getSummableValue: (_next: T) => number | undefined): number {\n return items.reduce((total, next) => {\n return total + Math.max(getSummableValue(next) || 0, 0)\n }, 0);\n}\n\nfunction hasNonFileParentSuite(suite: Suite): boolean {\n return !!suite.suite?.id && suite.suite.id !== suite.file.id;\n}\n\nfunction getSuiteHierarchyName(suite: Suite): string {\n let name = suite.name;\n let currentSuite = suite;\n \n while (hasNonFileParentSuite(currentSuite)) {\n name = `${currentSuite.suite!.name} > ${name}`;\n currentSuite = currentSuite.suite!;\n }\n \n return name;\n}\n\nexport function isSuiteOwnFile(suite: Suite): boolean {\n return suite.file.id === suite.id;\n}\n\nexport function getTaskLogLabel(base: string, task: Task): string {\n if (task.type === 'suite') {\n return isSuiteOwnFile(task) ?\n `${base}`\n : `${base} - \"${getSuiteHierarchyName(task)}\"`;\n } else {\n return `${base} - \"${getSuiteHierarchyName(task.suite!)} > ${task.name}\"`;\n }\n}\n\nexport function getTaskLogPrefix(logModule: string, base: string, task: Task): string {\n return `[${logModule}] ${getTaskLogLabel(base, task)}`;\n}\n\nexport function createAfterSuiteRunMeta(\n coverage: AssemblyScriptCoveragePayload,\n testFiles: string[],\n projectName: string = '',\n vitestVersion: VitestVersion = 'v4',\n): any {\n const base = { coverage, testFiles, projectName };\n\n if (vitestVersion) {\n return { ...base, transformMode: 'ssr' as const };\n } else {\n return { ...base, environment: 'node' as const };\n }\n}\n\n// ============================================================================\n// Task Creation\n// ============================================================================\n\nexport function getInitialTaskMode(options: AssemblyScriptTestOptions): RunMode {\n if (options.skip) {\n return 'skip';\n } else if (options.only) {\n return 'only';\n } else {\n return 'run';\n }\n}\n\nexport function getInitialTestTaskMeta(\n fnIndex: number,\n parentAfterAddingTask: Suite,\n): AssemblyScriptTestTaskMeta {\n return {\n fnIndex,\n idxInParentTasks: parentAfterAddingTask.tasks.length - 1,\n assertionsPassedCount: 0,\n assertionsFailed: [],\n resultFinal: false,\n };\n}\n\nexport function getInitialSuiteTaskMeta(\n parentAfterAddingTask: Suite,\n mergedOptions: AssemblyScriptTestOptions,\n): AssemblyScriptSuiteTaskMeta {\n return {\n idxInParentTasks: parentAfterAddingTask.tasks.length - 1,\n defaultTestOptions: mergedOptions,\n suitePreparedSent: false,\n resultFinal: false,\n };\n}\n\n\nfunction createTaskName(names: readonly (string | undefined)[], separator: string = ' > '): string {\n return names.filter(name => name !== undefined).join(separator);\n}\n\nexport function createTestTask(\n name: string,\n fnIndex: number,\n file: File,\n parent: Suite,\n mergedOptions: AssemblyScriptTestOptions,\n vitestVersion: VitestVersion = 'v4',\n): Test {\n const test: Test = {\n type: 'test',\n name,\n fullName: createTaskName([\n parent?.fullName ?? file?.fullName,\n name,\n ]),\n fullTestName: createTaskName([parent?.fullTestName, name]),\n id: '',\n file,\n suite: parent,\n context: {} as any,\n annotations: [],\n artifacts: [],\n meta: {},\n mode: getInitialTaskMode(mergedOptions),\n timeout: mergedOptions.timeout,\n retry: mergedOptions.retry,\n fails: mergedOptions.fails,\n };\n\n if (vitestVersion === 'v3') {\n // @ts-ignore\n delete test.fullName;\n // @ts-ignore\n delete test.fullTestName;\n // @ts-ignore\n delete test.artifacts;\n }\n\n parent.tasks.push(test);\n\n // use custom TaskMeta to capture fnIndex, parent task index, etc\n test.meta = getInitialTestTaskMeta(fnIndex, parent);\n\n return test;\n}\n\nexport function createSuiteTask(\n name: string,\n file: File,\n parent: Suite,\n mergedOptions: AssemblyScriptTestOptions,\n vitestVersion: VitestVersion = 'v4',\n): Suite {\n // const suiteIsFile = parent.file.id === parent.id;\n // const prefix = suiteIsFile ? parent.name : `${file.filepath}_${parent.name}`;\n const suite: Suite = {\n type: 'suite',\n name,\n fullName: createTaskName([\n parent?.fullName ?? file?.fullName,\n name,\n ]),\n fullTestName: createTaskName([parent?.fullTestName, name]),\n id: '',\n file,\n suite: parent,\n meta: {},\n tasks: [],\n mode: getInitialTaskMode(mergedOptions),\n };\n\n if (vitestVersion === 'v3') {\n // @ts-ignore\n delete suite.fullName;\n // @ts-ignore\n delete suite.fullTestName;\n }\n\n parent.tasks.push(suite);\n\n // use custom TaskMeta to capture parent task index and default options\n suite.meta = getInitialSuiteTaskMeta(parent, mergedOptions);\n\n return suite;\n}\n\n\n// ============================================================================\n// Dispatch Helpers\n// ============================================================================\n\nexport function getRunnableTasks(suite: Suite): Task[] {\n return suite.tasks.filter(t => t.mode === 'queued' || t.mode === 'run');\n}\n\n\n// ============================================================================\n// Result Handling Helpers\n// ============================================================================\n\nexport function shouldRetryTask(task: Task): boolean {\n const retry = retryCompat(task.retry);\n return task.result?.state === 'fail'\n && task.retry !== undefined\n && retry > 0\n && (\n task.result.retryCount === undefined\n || task.result.retryCount === 0\n || (task.result.retryCount < retry)\n );\n}\n\n/**\n * Invert result if test configured as 'fails'.\n */\nexport function checkFailsAndInvertResult(test: Test, logPrefix: string): void {\n if (test.fails) {\n if (test.result?.state === 'pass') {\n test.result.state = 'fail';\n\n debug(`${logPrefix} - Has 'fails' option set - inverted \"pass\" to \"fail\"`);\n\n const err = createTestExpectedToFailError(test);\n if (test.result.errors) {\n test.result.errors.push(err);\n } else {\n test.result.errors = [err];\n }\n } else if (test.result?.state === 'fail') {\n test.result.state = 'pass';\n test.result.errors = [];\n\n debug(`${logPrefix} - Has 'fails' option set - inverted \"fail\" to \"pass\"`);\n }\n }\n}\n\nexport function setTestResultForTestPrepare(test: Test, startTime: number): void {\n test.result = {\n state: 'run',\n startTime,\n retryCount: 0\n };\n};\n\nexport function updateTestResultAfterRun(test: Test, testTimings?: WASMExecutorPerfTimings): void {\n // while failed tests are actively set to failed, a passed test\n // will still be in the prepared result state (run), so set it to pass\n if (test.result?.state === 'run') {\n test.result.state = 'pass';\n }\n \n if (test.result && testTimings) {\n // accumulate duration for any retries that may be done\n test.result.duration = (test.result.duration ?? 0) + (testTimings.execEnd - testTimings.execStart);\n }\n}\n\nexport function flagTestTerminated(test: Test): void {\n (test.meta as AssemblyScriptTestTaskMeta).lastTimeoutTerminationTime = Date.now();\n}\n\nexport function flagTestFinalized(test: Test): void {\n (test.meta as AssemblyScriptTestTaskMeta).resultFinal = true;\n}\n\nfunction failTest(\n test: Test,\n testError: AssemblyScriptTestError,\n): void {\n if (test.result) {\n test.result.state = 'fail';\n } else {\n test.result = { state: 'fail' };\n }\n\n if (test.result.errors) {\n test.result.errors.push(testError);\n } else {\n test.result.errors = [testError];\n }\n}\n\nexport function failTestRuntimeError(\n test: Test,\n errorMessagePrefix: string,\n errorMessage: string,\n): AssemblyScriptTestError {\n const prefixStr = errorMessagePrefix ? `${errorMessagePrefix}: ` : '';\n const testError: AssemblyScriptTestError = {\n name: TEST_ERROR_NAMES.WASMRuntimeError,\n message: `${prefixStr}${errorMessage}`\n };\n\n failTest(test, testError);\n \n return testError;\n}\n\nexport function failTestAssertionError(\n test: Test,\n assertion: FailedAssertion\n): AssemblyScriptTestError {\n (test.meta as AssemblyScriptTestTaskMeta).assertionsFailed.push(assertion);\n\n const testError: AssemblyScriptTestError = {\n name: TEST_ERROR_NAMES.AssertionError,\n message: assertion.message\n };\n \n if (assertion?.valuesProvided) {\n testError.expected = assertion.expected !== undefined ? String(assertion.expected) : undefined;\n testError.actual = assertion.actual !== undefined ? String(assertion.actual) : undefined;\n }\n\n failTest(test, testError);\n \n return testError;\n}\n\nexport function failTestWithTimeoutError (test: Test, startTime: number, duration: number): void {\n const timeoutErr = createTestTimeoutError(test);\n\n if (test.result) {\n test.result.state = 'fail';\n test.result.startTime = startTime;\n \n // accumulate duration for any retries that may be done\n test.result.duration = (test.result.duration ?? 0) + duration;\n\n if (test.result.errors) {\n test.result.errors.push(timeoutErr)\n } else {\n test.result.errors = [timeoutErr];\n }\n } else {\n test.result = {\n state: 'fail',\n startTime,\n duration,\n errors: [timeoutErr],\n retryCount: 0,\n };\n }\n}\n\nexport function setSuitePrepareResult(suite: Suite): void {\n if (suite.mode === 'skip') {\n suite.result = {\n state: 'skip',\n duration: 0,\n };\n } else {\n suite.result = {\n state: 'run',\n startTime: Date.now(),\n };\n }\n}\n\nexport function updateSuiteFinishedResult(suite: Suite, logPrefix: string): void {\n if (suite.mode === 'skip') {\n suite.result = {\n state: 'skip',\n duration: 0,\n };\n } else {\n // update suite final result based on sub-task results\n const hasFailures = suite.tasks.some(({ result }) => result?.state === 'fail' );\n \n if (suite.result) {\n suite.result.duration = positiveSum(suite.tasks, t => t.result?.duration);\n suite.result.state = hasFailures ? 'fail' : 'pass';\n \n debug(`${logPrefix} - Set suite result: \"${suite.result.state}\" (hasFailures: ${hasFailures})`);\n }\n }\n}\n\nexport function finalizeSuiteResult(suite: Suite): void {\n (suite.meta as AssemblyScriptSuiteTaskMeta).resultFinal = true;\n}\n\nexport function resetTestForRetry(test: Test, startTime: number): void {\n if (test.result) {\n test.result!.state = 'run';\n test.result!.startTime = startTime;\n }\n\n const meta = test.meta as AssemblyScriptTestTaskMeta;\n\n // clear any custom metadata associated with the immediate last run\n meta.assertionsPassedCount = 0;\n meta.assertionsFailed = [];\n delete meta.lastError;\n delete meta.lastErrorValuesProvided;\n delete meta.lastErrorRawCallStack;\n delete meta.lastErrorCallStackRef;\n delete meta.lastTimeoutTerminationTime;\n delete meta.coverageData;\n}\n\n\n","import type { SerializedConfig } from 'vitest';\nimport type { File, Suite, Task, TaskBase } from '@vitest/runner/types';\nimport {\n calculateSuiteHash,\n createFileTask,\n someTasksAreOnly\n} from '@vitest/runner/utils';\nimport { processError } from '@vitest/utils/error';\n\nimport { ASSEMBLYSCRIPT_POOL_NAME } from '../types/constants.js';\nimport { DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS } from '../types/typed-constants.js';\nimport type {\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestError,\n AssemblyScriptTestOptions,\n} from '../types/types.js';\nimport { finalizeSuiteResult } from './vitest-tasks.js';\n\nexport function createInitialFileTask(\n testFile: string,\n projectName: string,\n projectRoot: string,\n configTestTimeout: number,\n configRetry: number,\n): File {\n const file: File = createFileTask(\n testFile,\n projectRoot,\n projectName,\n ASSEMBLYSCRIPT_POOL_NAME\n );\n\n file.mode = 'queued';\n file.environmentLoad = 0; // AS pool has no environment setup\n file.setupDuration = 0; // AS pool has no setup files\n\n const defaultTestOptions: AssemblyScriptTestOptions = {\n ...DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS,\n timeout: configTestTimeout,\n retry: configRetry,\n };\n\n const meta: AssemblyScriptSuiteTaskMeta = {\n idxInParentTasks: -1, // file task has no parent, should never be used anyway\n defaultTestOptions,\n suitePreparedSent: false,\n resultFinal: false,\n }\n file.meta = meta;\n\n return file;\n}\n\nexport function createFailedFileTask(\n testFile: string,\n projectName: string,\n config: SerializedConfig,\n error: AssemblyScriptTestError,\n): File {\n const file: File = createFileTask(\n testFile,\n config.root,\n projectName,\n ASSEMBLYSCRIPT_POOL_NAME\n );\n file.mode = 'run';\n file.result = {\n state: 'fail',\n errors: [error]\n };\n file.environmentLoad = 0;\n file.setupDuration = 0;\n file.collectDuration = 0;\n\n return file;\n}\n\nexport function prepareFileTaskForCollection(\n file: File,\n testNamePattern?: RegExp,\n allowOnly?: boolean,\n): void {\n calculateSuiteHash(file);\n\n // Interpret task modes does the following:\n // 1. If only mode enabled on any test, flip all non-only test.mode to skip\n // 2. Apply test name pattern filtering (from -t flag) to skip if needed\n // 3. If all test modes are skip, set file task mode to skip\n const hasOnly = someTasksAreOnly(file);\n interpretTaskModes(\n file,\n testNamePattern, // user regexp\n undefined, // testLocations\n undefined,\n undefined,\n hasOnly, // onlyMode - true if only is used anywhere\n false, // parentIsOnly - always false for the file task\n allowOnly\n );\n\n // update from queued (onQueued report) to run (onCollected report)\n if (file.mode === 'queued') {\n file.mode = 'run';\n }\n}\n\nexport function failFile(\n file: File,\n testError: AssemblyScriptTestError,\n runStartPerf: number,\n): AssemblyScriptTestError {\n file.mode = 'run';\n if (file.result) {\n file.result.state = 'fail';\n file.result.errors = file.result.errors ? file.result.errors.concat(testError) : [testError];\n } else {\n file.result = {\n state: 'fail',\n errors: [testError]\n };\n }\n file.environmentLoad = file.environmentLoad ?? 0;\n file.setupDuration = performance.now() - runStartPerf;\n file.collectDuration = file.collectDuration ?? 0;\n\n // we can always finalize on failing the file, no other work to do\n finalizeSuiteResult(file);\n\n return testError;\n}\n\nexport function getFullTaskHierarchy(file: File): string {\n function spacesForLevel(level: number): string {\n return new Array(level + 1).fill(' ').join('');\n }\n\n function taskStr(task: Task, level: number): string {\n if (task.type === 'test') {\n return `${spacesForLevel(level)}ID: ${task.id} Mode: \"${task.mode}\" Test: \"${task.name}\"`;\n } else {\n const suiteStr = `${spacesForLevel(level)}ID: ${task.id} Mode: \"${task.mode}\" Suite: \"${task.name}\"\\n`;\n return suiteStr + task.tasks.map(t => taskStr(t, level + 1)).join('\\n');\n }\n };\n\n return taskStr(file, 0);\n}\n\n\n// ============================================================================\n// interpretTaskModes function borrowed from Vitest\n// ============================================================================\n\n/**\n * Function interface changes from vitest 4.0.x -> 4.1.x, so now were' just handling this\n * functionality ourselves to prevent version compat conflicts.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v4.1.0/packages/runner/src/utils/collect.ts#L10\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nfunction interpretTaskModes(\n file: Suite,\n namePattern?: string | RegExp,\n testLocations?: number[] | undefined,\n testIds?: string[] | undefined,\n testTagsFilter?: ((testTags: string[]) => boolean) | undefined,\n onlyMode?: boolean,\n parentIsOnly?: boolean,\n allowOnly?: boolean,\n): void {\n const matchedLocations: number[] = [];\n\n const traverseSuite = (suite: Suite, parentIsOnly?: boolean, parentMatchedWithLocation?: boolean) => {\n const suiteIsOnly = parentIsOnly || suite.mode === 'only';\n\n // Check if any tasks in this suite have `.only` - if so, only those should run\n const hasSomeTasksOnly = onlyMode && suite.tasks.some(\n t => t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)),\n );\n\n suite.tasks.forEach((t) => {\n // Check if either the parent suite or the task itself are marked as included\n // If there are tasks with `.only` in this suite, only include those (not all tasks from describe.only)\n const includeTask = hasSomeTasksOnly\n ? (t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)))\n : (suiteIsOnly || t.mode === 'only');\n if (onlyMode) {\n if (t.type === 'suite' && (includeTask || someTasksAreOnly(t))) {\n // Don't skip this suite\n if (t.mode === 'only') {\n checkAllowOnly(t, allowOnly);\n t.mode = 'run';\n }\n }\n else if (t.mode === 'run' && !includeTask) {\n t.mode = 'skip';\n }\n else if (t.mode === 'only') {\n checkAllowOnly(t, allowOnly);\n t.mode = 'run';\n }\n }\n\n let hasLocationMatch = parentMatchedWithLocation\n // Match test location against provided locations, only run if present\n // in `testLocations`. Note: if `includeTaskLocation` is not enabled,\n // all test will be skipped.\n if (testLocations !== undefined && testLocations.length !== 0) {\n if (t.location && testLocations?.includes(t.location.line)) {\n t.mode = 'run';\n matchedLocations.push(t.location.line);\n hasLocationMatch = true;\n }\n else if (parentMatchedWithLocation) {\n t.mode = 'run';\n }\n else if (t.type === 'test') {\n t.mode = 'skip';\n }\n }\n\n if (t.type === 'test') {\n if (namePattern && !getTaskFullName(t).match(namePattern)) {\n t.mode = 'skip';\n }\n if (testIds && !testIds.includes(t.id)) {\n t.mode = 'skip';\n }\n if (testTagsFilter && !testTagsFilter(t.tags || [])) {\n t.mode = 'skip';\n }\n }\n else if (t.type === 'suite') {\n if (t.mode === 'skip') {\n skipAllTasks(t);\n }\n else if (t.mode === 'todo') {\n todoAllTasks(t);\n }\n else {\n traverseSuite(t, includeTask, hasLocationMatch);\n }\n }\n })\n\n // if all subtasks are skipped, mark as skip\n if (suite.mode === 'run' || suite.mode === 'queued') {\n if (suite.tasks.length && suite.tasks.every(i => i.mode !== 'run' && i.mode !== 'queued')) {\n suite.mode = 'skip';\n }\n }\n }\n\n traverseSuite(file, parentIsOnly, false);\n\n const nonMatching = testLocations?.filter(loc => !matchedLocations.includes(loc))\n if (nonMatching && nonMatching.length !== 0) {\n const message = nonMatching.length === 1\n ? `line ${nonMatching[0]}`\n : `lines ${nonMatching.join(', ')}`;\n\n if (file.result === undefined) {\n file.result = {\n state: 'fail',\n errors: [],\n };\n }\n if (file.result.errors === undefined) {\n file.result.errors = [];\n }\n\n file.result.errors.push(\n processError(new Error(`No test found in ${file.name} in ${message}`)),\n );\n }\n}\n\nfunction getTaskFullName(task: TaskBase): string {\n return `${task.suite ? `${getTaskFullName(task.suite)} ` : ''}${task.name}`;\n}\n\nfunction skipAllTasks(suite: Suite) {\n suite.tasks.forEach((t) => {\n if (t.mode === 'run' || t.mode === 'queued') {\n t.mode = 'skip';\n if (t.type === 'suite') {\n skipAllTasks(t);\n }\n }\n });\n}\n\nfunction todoAllTasks(suite: Suite) {\n suite.tasks.forEach((t) => {\n if (t.mode === 'run' || t.mode === 'queued') {\n t.mode = 'todo';\n if (t.type === 'suite') {\n todoAllTasks(t);\n }\n }\n });\n}\n\nfunction checkAllowOnly(task: TaskBase, allowOnly?: boolean) {\n if (allowOnly) {\n return;\n }\n const error = processError(\n new Error(\n '[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error',\n ),\n );\n task.result = {\n state: 'fail',\n errors: [error],\n };\n}\n"],"mappings":";;;;;;;AAwJA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;AChJD,MAAM,qCAAsH;CAC1H,OAAO;CACP,aAAa;CACb,sBAAsB;CACtB,0BAA0B;CAC1B,aAAa;CACb,cAAc,sBAAsB,GAAG;CACvC,oBAAoB,EAAE;CACvB;AAED,SAAS,sBAAsB,SAA0C;AACvE,QAAO;EACL,MAAM,iBAAiB;EACvB;EACD;;AAIH,SAAgB,mBAAmB,iBAA0D;CAC3F,MAAM,cAAyC,mBAAmB;AAGlE,MAAK,MAAM,aAAa,6BACtB,KAAI,YAAY,eAAe,OAC7B,aAAY,aAAa,mCAAmC;CAIhE,MAAM,WAAW;EAAE,GAAG;EAAa,YAAY;EAAM;AAErD,KACG,SAAS,2BAA2B,UAAa,SAAS,yBAAyB,KAChF,SAAS,uBAAuB,UAAa,SAAS,qBAAqB,EAE/E,OAAM,sBACJ,uGAAuG,SAAS,gDAClF,SAAS,qBACxC;AAGH,KACG,SAAS,+BAA+B,UAAa,SAAS,6BAA6B,KACxF,SAAS,2BAA2B,UAAa,SAAS,yBAAyB,EAEvF,OAAM,sBACJ,+GAA+G,SAAS,wDACtF,SAAS,yBAC5C;AAGH,QAAO;;AAGT,SAAgB,YAAY,OAA2C;AACrE,QAAO,OAAO,UAAU,WAAW,QAAQ,OAAO,SAAS;;AAG7D,SAAgB,gBAAgB,QAAkD;AAChF,QAAO;EACL,GAAG;EACH,OAAO,YAAY,OAAO,MAAM;EACjC;;AAGH,SAAS,kBAAkB,KAKzB;CACA,MAAM,UAAU,EAAE;AAOlB,KAAI,SAED,QAA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AAa,EAAE;;GAGnB;;AAGJ,SAAS,aAAa,OAAc;AAClC,OAAM,MAAM,SAAS,MAAM;AACzB,MAAI,EAAE,SAAS,SAAS,EAAE,SAAS,UAAU;AAC3C,KAAE,OAAO;AACT,OAAI,EAAE,SAAS,QACb,cAAa,EAAE;;GAGnB;;AAGJ,SAAS,eAAe,MAAgB,WAAqB;AAC3D,KAAI,UACF;AAOF,MAAK,SAAS;EACZ,OAAO;EACP,QAAQ,CAPI,6BACZ,IAAI,MACF,kGACD,CACF,CAGgB;EAChB"}
1
+ {"version":3,"file":"vitest-file-tasks-vvZzigcF.mjs","names":[],"sources":["../src/types/types.ts","../src/util/resolve-config.ts","../src/types/typed-constants.ts","../src/util/vitest-tasks.ts","../src/util/vitest-file-tasks.ts"],"sourcesContent":["/*\n * Shared TypeScript types and interfaces\n */\n\nimport type { MessagePort } from 'node:worker_threads';\nimport type { BirpcReturn } from 'birpc';\nimport type { RunnerRPC, RuntimeRPC, SerializedConfig } from 'vitest';\nimport type { TestError } from '@vitest/utils';\nimport type { ResolvedCoverageOptions } from 'vitest/node';\nimport type { File, Test, TaskMeta, TestOptions } from '@vitest/runner/types';\nimport type { RawSourceMap } from 'source-map';\n\nimport {\n AS_POOL_WORKER_MSG_FLAG,\n COVERAGE_PAYLOAD_FORMATS,\n POOL_ERROR_NAMES,\n TEST_ERROR_NAMES,\n AS_POOL_ERROR_FLAG,\n} from './constants.js';\n\n// ============================================================================\n// Errors\n// ============================================================================\n\n/** Error name type derived from TEST_ERROR_NAMES values */\nexport type TestErrorName = typeof TEST_ERROR_NAMES[keyof typeof TEST_ERROR_NAMES];\n\n/** Error name type derived from POOL_ERROR_NAMES values */\nexport type PoolErrorName = typeof POOL_ERROR_NAMES[keyof typeof POOL_ERROR_NAMES];\n\nexport interface AssemblyScriptPoolError {\n readonly [AS_POOL_ERROR_FLAG]: true;\n name: PoolErrorName;\n message?: string;\n originalErrorRawStack: NodeJS.CallSite[];\n originalErrorMayContainJS: boolean;\n applyStackToTestErrorCause: boolean;\n testError: AssemblyScriptTestError;\n}\n\n/**\n * Extended vitest TestError with required, strictly-typed name field.\n * This is an explicitly serializable error format constructred to report\n * Test/Suite failures to vitest.\n */\nexport interface AssemblyScriptTestError extends TestError {\n // reported error can originate as a test error (assertion/runtime),\n // or as a pool failnure (harness error due to OOM, other unexpected paths)\n name: TestErrorName | PoolErrorName\n}\n\n/**\n * Native build error marker file content.\n * Written by install script when native addon compilation fails.\n * Read at runtime to display detailed error information to users.\n */\nexport interface NativeBuildError {\n stage: 'binaryen-download' | 'native-compile';\n error: string;\n platform: string;\n timestamp: string;\n}\n\n// ============================================================================\n// User Configuration\n// ============================================================================\n\n/**\n * AssemblyScript pool configuration options\n */\nexport interface AssemblyScriptPoolOptions {\n /** Enable verbose debug logging */\n debug?: boolean;\n debugNative?: boolean;\n debugCoverageExtract?: boolean;\n\n /** enable to collect coverage instrumentation on the pool's assembly/* files */\n _instrumentPoolInternals?: boolean;\n\n /**\n * Strip `@inline` decorators during compilation to improve error message and coverage accuracy\n *\n * - When true (default): `@inline` decorators removed, functions become visible in coverage\n * and source mapped errors point to the correct lines\n * - When false: `@inline` functions are inlined by compiler, missing from coverage, and \n * error line numbers don't match the non-inlined source\n * @default true\n */\n stripInline?: boolean;\n\n /**\n * Maximum number of worker threads to spawn with vitest 3.x.\n * Defaults to os.availableParallelism() - 1\n * \n * Use project config `test.maxWorkers` with vitest 4.x to control\n * the number of cuncurrently executing tests. \n */\n maxThreadsV3?: number;\n\n coverageMemoryPagesInitial?: number;\n coverageMemoryPagesMax?: number;\n\n testMemoryPagesInitial?: number;\n testMemoryPagesMax?: number;\n\n extraCompilerFlags?: string[];\n\n wasmImportsFactory?: string;\n}\n\n/**\n * AssemblyScript-specific coverage fields contributed by the hybrid coverage\n * provider on top of vitest's standard coverage options.\n *\n * Single source of truth for these field declarations: extended by the\n * vitest module augmentation files in `src/config/` so users get autocomplete\n * on these fields in their `vitest.config.ts` coverage block, and consumed\n * internally via `Required<HybridProviderOptions>` in\n * `ResolvedHybridProviderOptions`.\n */\nexport interface HybridProviderOptions {\n debugIstanbul?: boolean;\n\n /**\n * Glob patterns for AssemblyScript source files to include in coverage.\n * Used to build the complete AS coverage map.\n *\n * The standard `include` patterns are used by the v8 provider for JS/TS files.\n *\n * @example ['assembly/**\\/*.as.ts']\n */\n assemblyScriptInclude?: string[];\n\n /**\n * Glob patterns for AssemblyScript files to exclude from coverage.\n *\n * @example ['**\\/*.as.test.ts']\n */\n assemblyScriptExclude?: string[];\n}\n\nexport interface WasmImportsFactoryInfo {\n module: WebAssembly.Module;\n memory: WebAssembly.Memory;\n utils: {\n liftString: (stringPtr: number) => string | undefined;\n }\n}\n\nexport type WasmImportsFactory = (moduleInfo: WasmImportsFactoryInfo) => WebAssembly.Imports;\n\n// define these constants here so they make sense in context\nexport const AS_POOL_FIELDS_WITH_DEFAULTS = [\n 'debug',\n 'debugNative',\n 'debugCoverageExtract',\n '_instrumentPoolInternals',\n 'stripInline',\n 'maxThreadsV3',\n 'extraCompilerFlags'\n] as const;\n\nexport const AS_POOL_OPTIONAL_FIELDS = [\n 'testMemoryPagesInitial',\n 'testMemoryPagesMax',\n 'coverageMemoryPagesInitial',\n 'coverageMemoryPagesMax',\n 'wasmImportsFactory'\n] as const;\n\n/** Fields that have default values. Internally these will always be defined. */\nexport type ASPoolOptionsFieldsWithDefaultValues = typeof AS_POOL_FIELDS_WITH_DEFAULTS[number];\n\n/** Fields with optional values and NO defaults */\nexport type ASPoolOptionsOptionalFields = typeof AS_POOL_OPTIONAL_FIELDS[number];\n// compatibility type for internal consumption - configs from all versions\n// of Vitest are converted to this format for internal consumption\nexport type SerializedConfigCompat = SerializedConfig & {\n retry: number;\n};\n\n /**\n * Pool options resolved so that all fields are filled with user values preferentially, \n * with required fields being guaranteed to be populated with defaults otherwise.\n */\nexport type ResolvedAssemblyScriptPoolOptions =\n Required<Pick<AssemblyScriptPoolOptions, ASPoolOptionsFieldsWithDefaultValues>>\n & Partial<Pick<AssemblyScriptPoolOptions, ASPoolOptionsOptionalFields>>\n & { readonly isResolved: true };\n\nexport type ResolvedHybridProviderOptions =\n Required<HybridProviderOptions>\n & Omit<ResolvedCoverageOptions, 'provider'>\n & {\n provider: 'custom';\n customProviderModule: string;\n globbedAssemblyScriptInclude: GlobResult[];\n globbedAssemblyScriptProjectRelativeExcludeOnly: string[];\n }\n & { readonly isResolved: true };\n\n// vitest TestOptions fields that are supported by AssemblyScript tests in this pool\nexport type AssemblyScriptTestOptions = Required<Pick<TestOptions, 'timeout' | 'retry' | 'skip' | 'only' | 'fails'>>;\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\nexport type VitestVersion = 'v3' | 'v4';\n\nexport interface ThreadImports {\n createUserWasmImports?: WasmImportsFactory;\n}\n\nexport interface GlobResult {\n absolute: string;\n projectRootRelative: string;\n}\n\n// ============================================================================\n// Compilation & Results\n// ============================================================================\n\nexport interface WASMCompilation {\n filePath: string;\n sourceMap: RawSourceMap;\n debugInfo?: BinaryDebugInfo;\n compiledModule: WebAssembly.Module;\n requiredMemory: WASMModuleMemoryRequirements;\n isInstrumented: boolean;\n compileTiming: number;\n}\n\nexport interface WASMImportMemoryRequirements {\n initialPages: number;\n maximumPages?: number;\n};\n\nexport interface WASMModuleMemoryRequirements {\n testMemory: WASMImportMemoryRequirements;\n coverageMemory: WASMImportMemoryRequirements;\n}\n\nexport interface AssemblyScriptCompilerOptions {\n shouldInstrument: boolean;\n projectRoot: string;\n instrumentationOptions?: InstrumentationOptions;\n stripInline?: boolean;\n extraFlags?: string[];\n}\n\nexport interface InstrumentationOptions {\n /** Project root for resolving source map paths to absolute paths */\n projectRoot: string;\n /** List of relative file paths to exclude from instrumentation */\n relativeExcludedFiles: string[];\n excludedLibraryFilePrefix: string;\n excludedLibraryFileOverridePrefix?: string;\n excludedInternalFunctionSubstring: string;\n coverageMemoryPagesMin: number;\n coverageMemoryPagesMax?: number;\n debug?: boolean;\n coverageMemoryModule: string;\n coverageMemoryName: string;\n}\n\n/**\n * Result of instrumenting a WASM binary for coverage\n */\nexport interface InstrumentationResult {\n /** Instrumented WASM binary with coverage counter increments */\n instrumentedWasm: Buffer;\n /** Regenerated source map (offsets adjusted for instrumentation) */\n sourceMap: string;\n /** Debug info with coverageMemoryIndex assigned to each function */\n debugInfo: BinaryDebugInfo;\n}\n\n// ============================================================================\n// Error Source Mapping\n// ============================================================================\n\n/**\n * Source location in original AssemblyScript code (a point, not a range)\n *\n * All values are 1-based for internal consistency.\n * Conversion to 0-based columns happens at Istanbul output boundary.\n */\nexport interface SourceLocation {\n /** Absolute file path (normalized from source map during debug info extraction) */\n filePath: string;\n line: number;\n column: number;\n}\n\n/**\n * WebAssembly call site with mapped source location\n */\nexport interface WebAssemblyCallSite {\n functionName: string;\n location: SourceLocation;\n}\n\n// ============================================================================\n// Coverage Data (Runtime Hit Counts)\n// ============================================================================\n\n/**\n * Coverage data collected during test execution\n *\n * Simple hit count storage using position-based keys for stable merging.\n * Note: Function source metadata (names, ranges) comes from ParsedSourceInfo.\n *\n * Outer Record: keyed by absolute file path\n * Inner Record: keyed by position (\"line:column\") → hit count\n */\nexport interface CoverageData {\n hitCountsByFileAndPosition: Record<string, Record<string, number>>;\n}\n\n/**\n * Coverage payload sent via RPC from worker to hybrid coverage provider\n *\n * The __format marker distinguishes AS coverage from JS coverage in onAfterSuiteRun.\n */\nexport interface AssemblyScriptCoveragePayload {\n readonly __format: typeof COVERAGE_PAYLOAD_FORMATS.AssemblyScript;\n coverageData: CoverageData;\n suiteLogLabel: string;\n}\n\n\n// ============================================================================\n// Binary Debug Info (returned from native instrumentation addon)\n// ============================================================================\n//\n// These types represent debug information extracted from compiled WASM binaries\n// via the native addon. Binary debug info only has POINTS (from source map),\n// not ranges. Ranges come from source parsing (ParsedSource* types below).\n//\n// Naming convention: *DebugInfo suffix indicates binary-extracted data.\n\n/**\n * Source range in original AssemblyScript code (start and end points)\n *\n * All values are 1-based for internal consistency.\n * Conversion to 0-based columns happens at Istanbul output boundary.\n */\nexport interface SourceRange {\n /** Relative file path */\n filePath: string;\n startLine: number;\n startColumn: number;\n endLine: number;\n endColumn: number;\n}\n\n/**\n * Branch edge in control flow graph\n */\nexport interface BranchEdgeDebugInfo {\n /** Target basic block index */\n targetBlockIndex: number;\n /** Index of the expression that creates this branch (e.g., if condition) */\n sourceExpressionIndex?: number;\n}\n\n/**\n * Expression debug info extracted from WASM binary\n *\n * Expressions are the smallest unit of execution in WASM.\n * In v2, each expression can be mapped to a source statement for line-level coverage.\n */\nexport interface ExpressionDebugInfo {\n /** WASM expression type (e.g., \"call\", \"if\", \"block\") */\n type: string;\n /** Source location (POINT, not range) from source map */\n location?: SourceLocation;\n /** Whether this expression is a branch point (if, switch, select) */\n isBranch: boolean;\n /** Number of branch paths (for branch coverage) */\n branchPaths?: number;\n /**\n * Index into coverage memory counters\n * v2 only: Propagated from containing BasicBlockDebugInfo by TS wrapper\n */\n coverageMemoryIndex?: number;\n}\n\n/**\n * Basic block debug info from CFG analysis\n *\n * Basic blocks are sequences of expressions with single entry/exit points.\n * In v2, counters are placed at basic block boundaries for efficient coverage.\n */\nexport interface BasicBlockDebugInfo {\n /** Block index within the function */\n index: number;\n /** Indices of expressions contained in this block */\n expressionIndices: number[];\n /** Outgoing branch edges */\n branches: BranchEdgeDebugInfo[];\n /**\n * Index into coverage memory counters\n * v2 only: Source of truth for block-level coverage\n */\n coverageMemoryIndex?: number;\n}\n\n/**\n * Function debug info extracted from WASM binary via native addon\n */\nexport interface FunctionDebugInfo {\n /** WASM function index */\n wasmIndex: number;\n /** Function name from WASM (informational) */\n name: string;\n /**\n * Representative source location (a point within the function).\n * Used for containment matching to find the parsedsource function.\n */\n representativeLocation: SourceLocation;\n /** Index into coverage memory counters */\n coverageMemoryIndex: number;\n /** All expressions in this function */\n expressions: ExpressionDebugInfo[];\n /** Basic blocks from CFG analysis */\n basicBlocks: BasicBlockDebugInfo[];\n}\n\n/**\n * Binary debug info extracted from WASM + source map via native addon\n *\n * This is the processed output after TS wrapper transforms NativeDebugInfoOutput.\n * Functions are grouped by file and keyed by position for stable identity.\n */\nexport interface BinaryDebugInfo {\n /** All source files represented in extracted debug info (directly or inlined) */\n debugSourceFiles: string[];\n /**\n * Functions grouped by file path, then keyed by position (\"line:column\").\n * Position key enables stable identity across compilations.\n * Array value accommodates generic monomorphizations that share a source position.\n */\n functionsByFileAndPosition: Record<string, Record<string, FunctionDebugInfo[]>>;\n\n instrumentedFunctionCount: number;\n}\n\n/**\n * Raw output from native addon's instrumentForCoverage() C++ function\n */\nexport interface NativeInstrumentationResult {\n instrumentedWasm: Buffer;\n sourceMap: string;\n debugInfo: NativeDebugInfoOutput;\n errors?: string[];\n}\n\nexport interface NativeDebugInfoOutput {\n /** All source files represented in extracted debug info (directly or inlined) */\n debugSourceFiles: string[];\n /** Flat list of all functions with their debug info */\n functions: NativeFunctionDebugInfo[];\n}\n\nexport interface NativeFunctionDebugInfo extends Omit<FunctionDebugInfo, 'expressions' | 'representativeLocation'> {\n representativeLocation: NativeSourceLocation;\n expressions: NativeExpressionDebugInfo[];\n}\n\nexport interface NativeExpressionDebugInfo extends Omit<ExpressionDebugInfo, 'location'> {\n location?: NativeSourceLocation;\n}\n\nexport interface NativeSourceLocation extends Omit<SourceLocation, 'filePath'> {\n /** Index into NativeDebugInfoOutput.debugSourceFiles */\n fileIndex: number;\n}\n\nexport interface NativeInstrumentationOptions extends Omit<InstrumentationOptions, 'relativeExcludedFiles' | 'projectRoot'> {\n excludedFiles?: string[];\n logPrefix?: string;\n}\n\nexport type InstrumentForCoverageFunc = (\n wasmBuffer: Buffer,\n sourceMapBuffer: Buffer,\n instrumentationOptions: InstrumentationOptions,\n logModule: string,\n logLabel: string,\n) => InstrumentationResult;\n\nexport interface NativeAddonInterface {\n instrumentForCoverage: InstrumentForCoverageFunc;\n}\n\n/**\n * Typed interface for the native addon's exported methods.\n * The addon is loaded via node-gyp-build at runtime (CJS .node binary).\n */\nexport interface NativeAddon {\n instrumentForCoverage(\n wasmBuffer: Buffer,\n sourceMapBuffer: Buffer,\n options: NativeInstrumentationOptions,\n ): NativeInstrumentationResult;\n}\n\n// ============================================================================\n// Parsed Source Info (from AST Parser)\n// ============================================================================\n//\n// These types represent information parsed from source files via AST.\n// Parsed source info has *ranges* (start and end positions) for containment matching.\n\n/**\n * Function info parsed from AssemblyScript source via AST\n */\nexport interface ParsedSourceFunctionInfo {\n /** Fully \"qualified\" (WASM debug) name */\n qualifiedName: string;\n /** Short name for display */\n shortName: string;\n /** Source range for containment matching */\n range: SourceRange;\n}\n\n/**\n * Statement info parsed from AssemblyScript source via AST\n *\n * v2 only: Used for line-level statement coverage.\n * Binary expression points are matched to source statement ranges.\n */\nexport interface ParsedSourceStatementInfo {\n /** Source range for containment matching */\n range: SourceRange;\n /** Statement type (e.g., \"variable\", \"expression\", \"return\") */\n statementType?: string;\n}\n\n/**\n * Branch info parsed from AssemblyScript source via AST\n *\n * v2 only: Used for branch coverage.\n * Binary branch expressions are matched to source branch ranges.\n */\nexport interface ParsedSourceBranchInfo {\n /** Source range for containment matching */\n range: SourceRange;\n /** Type of branch construct */\n branchType: 'if' | 'ternary' | 'switch' | 'logical';\n}\n\n/**\n * Complete parsed source info from AST parser\n *\n * Generated by coverage provider when processing coverage (not during compilation).\n * Provides the \"what SHOULD be covered\" view from source code.\n */\nexport interface ParsedSourceInfo {\n /**\n * Functions grouped by file path, then by start line for containment matching.\n * Multiple functions can start on the same line, but limiting matching to checking\n * only the functions grouped on the input position's line is very performant.\n */\n functionsByFileAndStartLine: Record<string, Record<number, ParsedSourceFunctionInfo[]>>;\n /**\n * Statements grouped by file path, then keyed by position (\"line:column\")\n * v2 only: For line-level statement coverage\n */\n statementsByFileAndPosition: Record<string, Record<string, ParsedSourceStatementInfo>>;\n /**\n * Branches grouped by file path, then keyed by position (\"line:column\")\n * v2 only: For branch coverage\n */\n branchesByFileAndPosition: Record<string, Record<string, ParsedSourceBranchInfo>>;\n}\n\n// ============================================================================\n// Worker Communication & RPC\n// ============================================================================\n\nexport interface AssemblyScriptConsoleLog {\n msg: string;\n time: number;\n isError: boolean;\n}\n\nexport type AssemblyScriptConsoleLogHandler = (msg: string, isError?: boolean) => void;\n\nexport interface FailedAssertion {\n expected?: string;\n actual?: string;\n valuesProvided: boolean;\n actualTypeName: string;\n expectedTypeName: string;\n message: string;\n}\n\nexport interface AssemblyScriptSuiteTaskMeta extends TaskMeta {\n idxInParentTasks: number;\n defaultTestOptions: AssemblyScriptTestOptions;\n suitePreparedSent: boolean;\n resultFinal: boolean;\n coverageData?: CoverageData;\n}\n\nexport interface AssemblyScriptTestTaskMeta extends TaskMeta {\n idxInParentTasks: number;\n fnIndex: number;\n assertionsPassedCount: number;\n assertionsFailed: FailedAssertion[];\n resultFinal: boolean;\n coverageData?: CoverageData;\n lastError?: AssemblyScriptTestError;\n lastErrorValuesProvided?: boolean;\n lastErrorRawCallStack?: NodeJS.CallSite[];\n lastErrorCallStackRef?: Error;\n lastErrorUnexpected?: boolean;\n lastTimeoutTerminationTime?: number;\n};\n\nexport interface WASMExecutorPerfTimings {\n /** function start */\n fnInit: number;\n /** test start: execStart - fnInit = env init time */\n execStart: number;\n /** test end: execEnd - execStart = test duration */\n execEnd: number;\n /** function end: fnFinal - execEnd = error prep and/or coverage extraction time */\n fnfinal: number;\n}\n\nexport type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;\n\n/**\n * Worker channel with RPC for suite-level communication\n */\nexport interface WorkerChannel {\n /** Port to send to worker for RPC communication */\n workerPort: MessagePort;\n /** Pool-side port for cleanup */\n poolPort: MessagePort;\n /** RPC client for calling Vitest methods (only remote functions matter for our usage) */\n rpc: WorkerRPC;\n}\n\nexport interface WorkerThreadInitData {\n asCoverageOptions: ResolvedHybridProviderOptions;\n}\n\nexport interface AssemblyScriptPoolWorkerMessageBase {\n readonly [AS_POOL_WORKER_MSG_FLAG]: true;\n readonly type: string;\n}\n\nexport interface TestFileCompiled extends AssemblyScriptPoolWorkerMessageBase {\n readonly type: 'file-compiled';\n compilation: WASMCompilation;\n}\n\n\nexport interface TestExecutionStart extends AssemblyScriptPoolWorkerMessageBase {\n readonly type: 'execution-start';\n executionStart: number;\n test: Test;\n}\n\nexport interface TestExecutionEnd extends AssemblyScriptPoolWorkerMessageBase {\n readonly type: 'execution-end';\n executionEnd: number;\n testTaskId: string;\n}\n\nexport type AssemblyScriptPoolWorkerMessage = TestExecutionStart | TestExecutionEnd | TestFileCompiled;\n\nexport interface TestRunRecord {\n test: Test;\n executionStart: number;\n timeoutId: NodeJS.Timeout;\n}\n\nexport interface ThreadSpec {\n file: File;\n compilation?: WASMCompilation;\n}\n\nexport interface RunCompileAndDiscoverTask {\n dispatchStart: number;\n workerId: number;\n port: MessagePort;\n file: File;\n config: SerializedConfigCompat;\n asPoolOptions: ResolvedAssemblyScriptPoolOptions;\n isCollectTestsMode: boolean;\n}\n\nexport interface RunTestsTask {\n dispatchStart: number;\n workerId: number;\n port: MessagePort;\n file: File;\n compilation: WASMCompilation;\n config: SerializedConfigCompat;\n asPoolOptions: ResolvedAssemblyScriptPoolOptions;\n isCollectTestsMode: boolean;\n timedOutTest?: Test;\n}\n\nexport interface ProcessPoolRunFileTask {\n dispatchStart: number;\n port: MessagePort;\n file: File;\n config: SerializedConfigCompat;\n asPoolOptions: ResolvedAssemblyScriptPoolOptions;\n isCollectTestsMode: boolean;\n timedOutTest?: Test;\n timedOutCompilation?: WASMCompilation;\n}\n","import { availableParallelism } from 'node:os';\nimport type { SerializedConfig } from 'vitest';\nimport type { Retry, SerializableRetry } from '@vitest/runner';\nimport type { Vitest } from 'vitest/node';\n\nimport type {\n AssemblyScriptPoolOptions,\n ASPoolOptionsFieldsWithDefaultValues,\n ResolvedAssemblyScriptPoolOptions,\n ResolvedHybridProviderOptions,\n SerializedConfigCompat,\n AssemblyScriptTestError,\n} from '../types/types.js';\nimport { AS_POOL_FIELDS_WITH_DEFAULTS } from '../types/types.js';\nimport { ASSEMBLYSCRIPT_POOL_NAME, POOL_ERROR_NAMES } from '../types/constants.js';\n\nconst DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS: Required<Pick<AssemblyScriptPoolOptions, ASPoolOptionsFieldsWithDefaultValues>> = {\n debug: false,\n debugNative: false,\n debugCoverageExtract: false,\n _instrumentPoolInternals: false,\n stripInline: true,\n maxThreadsV3: availableParallelism() - 1,\n extraCompilerFlags: [],\n} as const;\n\nfunction createPoolConfigError(message: string): AssemblyScriptTestError {\n return {\n name: POOL_ERROR_NAMES.PoolConfigError,\n message\n };\n}\n\n// v4: used in runner init to parse user-provided param directly\nexport function resolvePoolOptions(userPoolOptions?: any): ResolvedAssemblyScriptPoolOptions {\n const poolOptions: AssemblyScriptPoolOptions = userPoolOptions ?? DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS;\n\n // resolve fields with defaults if user hasn't provided them\n for (const configKey of AS_POOL_FIELDS_WITH_DEFAULTS) {\n if (poolOptions[configKey] === undefined) {\n poolOptions[configKey] = DEFAULT_ASSEMBLYSCRIPT_POOL_OTIONS[configKey] as any;\n }\n }\n\n const resolved = { ...poolOptions, isResolved: true } as ResolvedAssemblyScriptPoolOptions;\n\n if (\n (resolved.testMemoryPagesInitial !== undefined && resolved.testMemoryPagesInitial < 1)\n || (resolved.testMemoryPagesMax !== undefined && resolved.testMemoryPagesMax < 1)\n ) {\n throw createPoolConfigError(\n `AssemblyScript WASM test memory page size options must be positive if defined - testMemoryPagesMin: ${resolved.testMemoryPagesInitial}`\n + ` | testMemoryPagesMax: ${resolved.testMemoryPagesMax}`,\n );\n }\n\n if (\n (resolved.coverageMemoryPagesInitial !== undefined && resolved.coverageMemoryPagesInitial < 1)\n || (resolved.coverageMemoryPagesMax !== undefined && resolved.coverageMemoryPagesMax < 1)\n ) {\n throw createPoolConfigError(\n `AssemblyScript WASM coverage memory page size options must be positive if defined - coverageMemoryPagesMin: ${resolved.coverageMemoryPagesInitial}`\n + ` | coverageMemoryPagesMax: ${resolved.coverageMemoryPagesMax}`,\n );\n }\n\n return resolved;\n}\n\nexport function retryCompat(retry?: SerializableRetry | Retry): number {\n return typeof retry === 'number' ? retry : retry?.count ?? 0;\n}\n\nexport function getCompatConfig(config: SerializedConfig): SerializedConfigCompat {\n return {\n ...config,\n retry: retryCompat(config.retry)\n };\n}\n\nfunction getProjectConfigs(ctx: Vitest): {\n [key: string]: {\n config: SerializedConfigCompat,\n v3PoolOptions?: ResolvedAssemblyScriptPoolOptions\n }\n} {\n const configs = {} as {\n [key: string]: {\n config: SerializedConfigCompat,\n v3PoolOptions?: ResolvedAssemblyScriptPoolOptions\n }\n };\n\n ctx.projects\n // project.config.pool resolves to the *path of the dist file*\n .filter(p => p.config.pool.includes(ASSEMBLYSCRIPT_POOL_NAME))\n \n .forEach(project => {\n configs[project.name] = {\n config: getCompatConfig(project.serializedConfig),\n };\n\n // @ts-ignore - we build with v4, but this is correct for v3 (has config.poolOptions)\n const maybeOptions: any = project.config?.poolOptions?.assemblyScript;\n if (maybeOptions) {\n configs[project.name]!.v3PoolOptions = resolvePoolOptions(maybeOptions);\n }\n });\n \n return configs;\n}\n\nexport function getConfigs(ctx: Vitest): {\n coverage: ResolvedHybridProviderOptions;\n projects: {\n [key: string]: {\n config: SerializedConfigCompat,\n v3PoolOptions?: ResolvedAssemblyScriptPoolOptions\n }\n };\n fallbackPoolOptions: ResolvedAssemblyScriptPoolOptions;\n} {\n const coverage = ctx.config.coverage as unknown as ResolvedHybridProviderOptions;\n const projects = getProjectConfigs(ctx);\n\n // @ts-ignore - we build with v4, but this is correct for v3 (has config.poolOptions)\n let fallbackPoolOptions: ResolvedAssemblyScriptPoolOptions = resolvePoolOptions(ctx.config.poolOptions?.assemblyScript);\n\n const configs = Object.values(projects);\n if (configs.length > 0) {\n for (const config of configs) {\n if (config.v3PoolOptions?.debug) {\n fallbackPoolOptions.debug = true;\n }\n if (config.v3PoolOptions?.maxThreadsV3 !== undefined\n && config.v3PoolOptions.maxThreadsV3 > fallbackPoolOptions.maxThreadsV3\n ) {\n fallbackPoolOptions.maxThreadsV3 = config.v3PoolOptions.maxThreadsV3;\n }\n }\n }\n\n return {\n coverage,\n projects,\n fallbackPoolOptions\n };\n}\n","/**\n * Typed Constants\n * \n * Constants which require importing ./types\n */\n\nimport { AssemblyScriptTestOptions } from './types.js';\n\n// hard-coded defaults only - timeout and retry defaults always come from vitest config\nexport const DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS: Pick<AssemblyScriptTestOptions, 'fails' | 'skip' | 'only'> = {\n fails: false,\n skip: false,\n only: false\n};\n","import type { File, RunMode, Suite, Task, Test } from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptCoveragePayload,\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestError,\n AssemblyScriptTestOptions,\n AssemblyScriptTestTaskMeta,\n FailedAssertion,\n VitestVersion,\n WASMExecutorPerfTimings\n} from '../types/types.js';\nimport { TEST_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from './debug.js';\nimport { createTestExpectedToFailError, createTestTimeoutError } from './pool-errors.js';\nimport { retryCompat } from './resolve-config.js';\n\n// ============================================================================\n// Util\n// ============================================================================\n\nfunction positiveSum<T>(items: T[], getSummableValue: (_next: T) => number | undefined): number {\n return items.reduce((total, next) => {\n return total + Math.max(getSummableValue(next) || 0, 0)\n }, 0);\n}\n\nfunction hasNonFileParentSuite(suite: Suite): boolean {\n return !!suite.suite?.id && suite.suite.id !== suite.file.id;\n}\n\nfunction getSuiteHierarchyName(suite: Suite): string {\n let name = suite.name;\n let currentSuite = suite;\n \n while (hasNonFileParentSuite(currentSuite)) {\n name = `${currentSuite.suite!.name} > ${name}`;\n currentSuite = currentSuite.suite!;\n }\n \n return name;\n}\n\nexport function isSuiteOwnFile(suite: Suite): boolean {\n return suite.file.id === suite.id;\n}\n\nexport function getTaskLogLabel(base: string, task: Task): string {\n if (task.type === 'suite') {\n return isSuiteOwnFile(task) ?\n `${base}`\n : `${base} - \"${getSuiteHierarchyName(task)}\"`;\n } else {\n return `${base} - \"${getSuiteHierarchyName(task.suite!)} > ${task.name}\"`;\n }\n}\n\nexport function getTaskLogPrefix(logModule: string, base: string, task: Task): string {\n return `[${logModule}] ${getTaskLogLabel(base, task)}`;\n}\n\nexport function createAfterSuiteRunMeta(\n coverage: AssemblyScriptCoveragePayload,\n testFiles: string[],\n projectName: string = '',\n vitestVersion: VitestVersion = 'v4',\n): any {\n const base = { coverage, testFiles, projectName };\n\n if (vitestVersion) {\n return { ...base, transformMode: 'ssr' as const };\n } else {\n return { ...base, environment: 'node' as const };\n }\n}\n\n// ============================================================================\n// Task Creation\n// ============================================================================\n\nexport function getInitialTaskMode(options: AssemblyScriptTestOptions): RunMode {\n if (options.skip) {\n return 'skip';\n } else if (options.only) {\n return 'only';\n } else {\n return 'run';\n }\n}\n\nexport function getInitialTestTaskMeta(\n fnIndex: number,\n parentAfterAddingTask: Suite,\n): AssemblyScriptTestTaskMeta {\n return {\n fnIndex,\n idxInParentTasks: parentAfterAddingTask.tasks.length - 1,\n assertionsPassedCount: 0,\n assertionsFailed: [],\n resultFinal: false,\n };\n}\n\nexport function getInitialSuiteTaskMeta(\n parentAfterAddingTask: Suite,\n mergedOptions: AssemblyScriptTestOptions,\n): AssemblyScriptSuiteTaskMeta {\n return {\n idxInParentTasks: parentAfterAddingTask.tasks.length - 1,\n defaultTestOptions: mergedOptions,\n suitePreparedSent: false,\n resultFinal: false,\n };\n}\n\n\nfunction createTaskName(names: readonly (string | undefined)[], separator: string = ' > '): string {\n return names.filter(name => name !== undefined).join(separator);\n}\n\nexport function createTestTask(\n name: string,\n fnIndex: number,\n file: File,\n parent: Suite,\n mergedOptions: AssemblyScriptTestOptions,\n vitestVersion: VitestVersion = 'v4',\n): Test {\n const test: Test = {\n type: 'test',\n name,\n fullName: createTaskName([\n parent?.fullName ?? file?.fullName,\n name,\n ]),\n fullTestName: createTaskName([parent?.fullTestName, name]),\n id: '',\n file,\n suite: parent,\n context: {} as any,\n annotations: [],\n artifacts: [],\n meta: {},\n mode: getInitialTaskMode(mergedOptions),\n timeout: mergedOptions.timeout,\n retry: mergedOptions.retry,\n fails: mergedOptions.fails,\n };\n\n if (vitestVersion === 'v3') {\n // @ts-ignore\n delete test.fullName;\n // @ts-ignore\n delete test.fullTestName;\n // @ts-ignore\n delete test.artifacts;\n }\n\n parent.tasks.push(test);\n\n // use custom TaskMeta to capture fnIndex, parent task index, etc\n test.meta = getInitialTestTaskMeta(fnIndex, parent);\n\n return test;\n}\n\nexport function createSuiteTask(\n name: string,\n file: File,\n parent: Suite,\n mergedOptions: AssemblyScriptTestOptions,\n vitestVersion: VitestVersion = 'v4',\n): Suite {\n // const suiteIsFile = parent.file.id === parent.id;\n // const prefix = suiteIsFile ? parent.name : `${file.filepath}_${parent.name}`;\n const suite: Suite = {\n type: 'suite',\n name,\n fullName: createTaskName([\n parent?.fullName ?? file?.fullName,\n name,\n ]),\n fullTestName: createTaskName([parent?.fullTestName, name]),\n id: '',\n file,\n suite: parent,\n meta: {},\n tasks: [],\n mode: getInitialTaskMode(mergedOptions),\n };\n\n if (vitestVersion === 'v3') {\n // @ts-ignore\n delete suite.fullName;\n // @ts-ignore\n delete suite.fullTestName;\n }\n\n parent.tasks.push(suite);\n\n // use custom TaskMeta to capture parent task index and default options\n suite.meta = getInitialSuiteTaskMeta(parent, mergedOptions);\n\n return suite;\n}\n\n\n// ============================================================================\n// Dispatch Helpers\n// ============================================================================\n\nexport function getRunnableTasks(suite: Suite): Task[] {\n return suite.tasks.filter(t => t.mode === 'queued' || t.mode === 'run');\n}\n\n\n// ============================================================================\n// Result Handling Helpers\n// ============================================================================\n\nexport function shouldRetryTask(task: Task): boolean {\n const retry = retryCompat(task.retry);\n return task.result?.state === 'fail'\n && task.retry !== undefined\n && retry > 0\n && (\n task.result.retryCount === undefined\n || task.result.retryCount === 0\n || (task.result.retryCount < retry)\n );\n}\n\n/**\n * Invert result if test configured as 'fails'.\n */\nexport function checkFailsAndInvertResult(test: Test, logPrefix: string): void {\n if (test.fails) {\n if (test.result?.state === 'pass') {\n test.result.state = 'fail';\n\n debug(`${logPrefix} - Has 'fails' option set - inverted \"pass\" to \"fail\"`);\n\n const err = createTestExpectedToFailError(test);\n if (test.result.errors) {\n test.result.errors.push(err);\n } else {\n test.result.errors = [err];\n }\n } else if (test.result?.state === 'fail') {\n test.result.state = 'pass';\n test.result.errors = [];\n\n debug(`${logPrefix} - Has 'fails' option set - inverted \"fail\" to \"pass\"`);\n }\n }\n}\n\nexport function setTestResultForTestPrepare(test: Test, startTime: number): void {\n test.result = {\n state: 'run',\n startTime,\n retryCount: 0\n };\n};\n\nexport function updateTestResultAfterRun(test: Test, testTimings?: WASMExecutorPerfTimings): void {\n // while failed tests are actively set to failed, a passed test\n // will still be in the prepared result state (run), so set it to pass\n if (test.result?.state === 'run') {\n test.result.state = 'pass';\n }\n \n if (test.result && testTimings) {\n // accumulate duration for any retries that may be done\n test.result.duration = (test.result.duration ?? 0) + (testTimings.execEnd - testTimings.execStart);\n }\n}\n\nexport function flagTestTerminated(test: Test): void {\n (test.meta as AssemblyScriptTestTaskMeta).lastTimeoutTerminationTime = Date.now();\n}\n\nexport function flagTestFinalized(test: Test): void {\n (test.meta as AssemblyScriptTestTaskMeta).resultFinal = true;\n}\n\nfunction failTest(\n test: Test,\n testError: AssemblyScriptTestError,\n): void {\n if (test.result) {\n test.result.state = 'fail';\n } else {\n test.result = { state: 'fail' };\n }\n\n if (test.result.errors) {\n test.result.errors.push(testError);\n } else {\n test.result.errors = [testError];\n }\n}\n\nexport function failTestRuntimeError(\n test: Test,\n errorMessagePrefix: string,\n errorMessage: string,\n): AssemblyScriptTestError {\n const prefixStr = errorMessagePrefix ? `${errorMessagePrefix}: ` : '';\n const testError: AssemblyScriptTestError = {\n name: TEST_ERROR_NAMES.WASMRuntimeError,\n message: `${prefixStr}${errorMessage}`\n };\n\n failTest(test, testError);\n \n return testError;\n}\n\nexport function failTestAssertionError(\n test: Test,\n assertion: FailedAssertion\n): AssemblyScriptTestError {\n (test.meta as AssemblyScriptTestTaskMeta).assertionsFailed.push(assertion);\n\n const testError: AssemblyScriptTestError = {\n name: TEST_ERROR_NAMES.AssertionError,\n message: assertion.message\n };\n \n if (assertion?.valuesProvided) {\n testError.expected = assertion.expected !== undefined ? String(assertion.expected) : undefined;\n testError.actual = assertion.actual !== undefined ? String(assertion.actual) : undefined;\n }\n\n failTest(test, testError);\n \n return testError;\n}\n\nexport function failTestWithTimeoutError (test: Test, startTime: number, duration: number): void {\n const timeoutErr = createTestTimeoutError(test);\n\n if (test.result) {\n test.result.state = 'fail';\n test.result.startTime = startTime;\n \n // accumulate duration for any retries that may be done\n test.result.duration = (test.result.duration ?? 0) + duration;\n\n if (test.result.errors) {\n test.result.errors.push(timeoutErr)\n } else {\n test.result.errors = [timeoutErr];\n }\n } else {\n test.result = {\n state: 'fail',\n startTime,\n duration,\n errors: [timeoutErr],\n retryCount: 0,\n };\n }\n}\n\nexport function setSuitePrepareResult(suite: Suite): void {\n if (suite.mode === 'skip') {\n suite.result = {\n state: 'skip',\n duration: 0,\n };\n } else {\n suite.result = {\n state: 'run',\n startTime: Date.now(),\n };\n }\n}\n\nexport function updateSuiteFinishedResult(suite: Suite, logPrefix: string): void {\n if (suite.mode === 'skip') {\n suite.result = {\n state: 'skip',\n duration: 0,\n };\n } else {\n // update suite final result based on sub-task results\n const hasFailures = suite.tasks.some(({ result }) => result?.state === 'fail' );\n \n if (suite.result) {\n suite.result.duration = positiveSum(suite.tasks, t => t.result?.duration);\n suite.result.state = hasFailures ? 'fail' : 'pass';\n \n debug(`${logPrefix} - Set suite result: \"${suite.result.state}\" (hasFailures: ${hasFailures})`);\n }\n }\n}\n\nexport function finalizeSuiteResult(suite: Suite): void {\n (suite.meta as AssemblyScriptSuiteTaskMeta).resultFinal = true;\n}\n\nexport function resetTestForRetry(test: Test, startTime: number): void {\n if (test.result) {\n test.result!.state = 'run';\n test.result!.startTime = startTime;\n }\n\n const meta = test.meta as AssemblyScriptTestTaskMeta;\n\n // clear any custom metadata associated with the immediate last run\n meta.assertionsPassedCount = 0;\n meta.assertionsFailed = [];\n delete meta.lastError;\n delete meta.lastErrorValuesProvided;\n delete meta.lastErrorRawCallStack;\n delete meta.lastErrorCallStackRef;\n delete meta.lastTimeoutTerminationTime;\n delete meta.coverageData;\n}\n\n\n","import type { SerializedConfig } from 'vitest';\nimport type { File, Suite, Task, TaskBase } from '@vitest/runner/types';\nimport {\n calculateSuiteHash,\n createFileTask,\n someTasksAreOnly\n} from '@vitest/runner/utils';\nimport { processError } from '@vitest/utils/error';\n\nimport { ASSEMBLYSCRIPT_POOL_NAME } from '../types/constants.js';\nimport { DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS } from '../types/typed-constants.js';\nimport type {\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestError,\n AssemblyScriptTestOptions,\n} from '../types/types.js';\nimport { finalizeSuiteResult } from './vitest-tasks.js';\n\nexport function createInitialFileTask(\n testFile: string,\n projectName: string,\n projectRoot: string,\n configTestTimeout: number,\n configRetry: number,\n): File {\n const file: File = createFileTask(\n testFile,\n projectRoot,\n projectName,\n ASSEMBLYSCRIPT_POOL_NAME\n );\n\n file.mode = 'queued';\n file.environmentLoad = 0; // AS pool has no environment setup\n file.setupDuration = 0; // AS pool has no setup files\n\n const defaultTestOptions: AssemblyScriptTestOptions = {\n ...DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS,\n timeout: configTestTimeout,\n retry: configRetry,\n };\n\n const meta: AssemblyScriptSuiteTaskMeta = {\n idxInParentTasks: -1, // file task has no parent, should never be used anyway\n defaultTestOptions,\n suitePreparedSent: false,\n resultFinal: false,\n }\n file.meta = meta;\n\n return file;\n}\n\nexport function createFailedFileTask(\n testFile: string,\n projectName: string,\n config: SerializedConfig,\n error: AssemblyScriptTestError,\n): File {\n const file: File = createFileTask(\n testFile,\n config.root,\n projectName,\n ASSEMBLYSCRIPT_POOL_NAME\n );\n file.mode = 'run';\n file.result = {\n state: 'fail',\n errors: [error]\n };\n file.environmentLoad = 0;\n file.setupDuration = 0;\n file.collectDuration = 0;\n\n return file;\n}\n\nexport function prepareFileTaskForCollection(\n file: File,\n testNamePattern?: RegExp,\n allowOnly?: boolean,\n): void {\n calculateSuiteHash(file);\n\n // Interpret task modes does the following:\n // 1. If only mode enabled on any test, flip all non-only test.mode to skip\n // 2. Apply test name pattern filtering (from -t flag) to skip if needed\n // 3. If all test modes are skip, set file task mode to skip\n const hasOnly = someTasksAreOnly(file);\n interpretTaskModes(\n file,\n testNamePattern, // user regexp\n undefined, // testLocations\n undefined,\n undefined,\n hasOnly, // onlyMode - true if only is used anywhere\n false, // parentIsOnly - always false for the file task\n allowOnly\n );\n\n // update from queued (onQueued report) to run (onCollected report)\n if (file.mode === 'queued') {\n file.mode = 'run';\n }\n}\n\nexport function failFile(\n file: File,\n testError: AssemblyScriptTestError,\n runStartPerf: number,\n): AssemblyScriptTestError {\n file.mode = 'run';\n if (file.result) {\n file.result.state = 'fail';\n file.result.errors = file.result.errors ? file.result.errors.concat(testError) : [testError];\n } else {\n file.result = {\n state: 'fail',\n errors: [testError]\n };\n }\n file.environmentLoad = file.environmentLoad ?? 0;\n file.setupDuration = performance.now() - runStartPerf;\n file.collectDuration = file.collectDuration ?? 0;\n\n // we can always finalize on failing the file, no other work to do\n finalizeSuiteResult(file);\n\n return testError;\n}\n\nexport function getFullTaskHierarchy(file: File): string {\n function spacesForLevel(level: number): string {\n return new Array(level + 1).fill(' ').join('');\n }\n\n function taskStr(task: Task, level: number): string {\n if (task.type === 'test') {\n return `${spacesForLevel(level)}ID: ${task.id} Mode: \"${task.mode}\" Test: \"${task.name}\"`;\n } else {\n const suiteStr = `${spacesForLevel(level)}ID: ${task.id} Mode: \"${task.mode}\" Suite: \"${task.name}\"\\n`;\n return suiteStr + task.tasks.map(t => taskStr(t, level + 1)).join('\\n');\n }\n };\n\n return taskStr(file, 0);\n}\n\n\n// ============================================================================\n// interpretTaskModes function borrowed from Vitest\n// ============================================================================\n\n/**\n * Function interface changes from vitest 4.0.x -> 4.1.x, so now were' just handling this\n * functionality ourselves to prevent version compat conflicts.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v4.1.0/packages/runner/src/utils/collect.ts#L10\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nfunction interpretTaskModes(\n file: Suite,\n namePattern?: string | RegExp,\n testLocations?: number[] | undefined,\n testIds?: string[] | undefined,\n testTagsFilter?: ((testTags: string[]) => boolean) | undefined,\n onlyMode?: boolean,\n parentIsOnly?: boolean,\n allowOnly?: boolean,\n): void {\n const matchedLocations: number[] = [];\n\n const traverseSuite = (suite: Suite, parentIsOnly?: boolean, parentMatchedWithLocation?: boolean) => {\n const suiteIsOnly = parentIsOnly || suite.mode === 'only';\n\n // Check if any tasks in this suite have `.only` - if so, only those should run\n const hasSomeTasksOnly = onlyMode && suite.tasks.some(\n t => t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)),\n );\n\n suite.tasks.forEach((t) => {\n // Check if either the parent suite or the task itself are marked as included\n // If there are tasks with `.only` in this suite, only include those (not all tasks from describe.only)\n const includeTask = hasSomeTasksOnly\n ? (t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)))\n : (suiteIsOnly || t.mode === 'only');\n if (onlyMode) {\n if (t.type === 'suite' && (includeTask || someTasksAreOnly(t))) {\n // Don't skip this suite\n if (t.mode === 'only') {\n checkAllowOnly(t, allowOnly);\n t.mode = 'run';\n }\n }\n else if (t.mode === 'run' && !includeTask) {\n t.mode = 'skip';\n }\n else if (t.mode === 'only') {\n checkAllowOnly(t, allowOnly);\n t.mode = 'run';\n }\n }\n\n let hasLocationMatch = parentMatchedWithLocation\n // Match test location against provided locations, only run if present\n // in `testLocations`. Note: if `includeTaskLocation` is not enabled,\n // all test will be skipped.\n if (testLocations !== undefined && testLocations.length !== 0) {\n if (t.location && testLocations?.includes(t.location.line)) {\n t.mode = 'run';\n matchedLocations.push(t.location.line);\n hasLocationMatch = true;\n }\n else if (parentMatchedWithLocation) {\n t.mode = 'run';\n }\n else if (t.type === 'test') {\n t.mode = 'skip';\n }\n }\n\n if (t.type === 'test') {\n if (namePattern && !getTaskFullName(t).match(namePattern)) {\n t.mode = 'skip';\n }\n if (testIds && !testIds.includes(t.id)) {\n t.mode = 'skip';\n }\n if (testTagsFilter && !testTagsFilter(t.tags || [])) {\n t.mode = 'skip';\n }\n }\n else if (t.type === 'suite') {\n if (t.mode === 'skip') {\n skipAllTasks(t);\n }\n else if (t.mode === 'todo') {\n todoAllTasks(t);\n }\n else {\n traverseSuite(t, includeTask, hasLocationMatch);\n }\n }\n })\n\n // if all subtasks are skipped, mark as skip\n if (suite.mode === 'run' || suite.mode === 'queued') {\n if (suite.tasks.length && suite.tasks.every(i => i.mode !== 'run' && i.mode !== 'queued')) {\n suite.mode = 'skip';\n }\n }\n }\n\n traverseSuite(file, parentIsOnly, false);\n\n const nonMatching = testLocations?.filter(loc => !matchedLocations.includes(loc))\n if (nonMatching && nonMatching.length !== 0) {\n const message = nonMatching.length === 1\n ? `line ${nonMatching[0]}`\n : `lines ${nonMatching.join(', ')}`;\n\n if (file.result === undefined) {\n file.result = {\n state: 'fail',\n errors: [],\n };\n }\n if (file.result.errors === undefined) {\n file.result.errors = [];\n }\n\n file.result.errors.push(\n processError(new Error(`No test found in ${file.name} in ${message}`)),\n );\n }\n}\n\nfunction getTaskFullName(task: TaskBase): string {\n return `${task.suite ? `${getTaskFullName(task.suite)} ` : ''}${task.name}`;\n}\n\nfunction skipAllTasks(suite: Suite) {\n suite.tasks.forEach((t) => {\n if (t.mode === 'run' || t.mode === 'queued') {\n t.mode = 'skip';\n if (t.type === 'suite') {\n skipAllTasks(t);\n }\n }\n });\n}\n\nfunction todoAllTasks(suite: Suite) {\n suite.tasks.forEach((t) => {\n if (t.mode === 'run' || t.mode === 'queued') {\n t.mode = 'todo';\n if (t.type === 'suite') {\n todoAllTasks(t);\n }\n }\n });\n}\n\nfunction checkAllowOnly(task: TaskBase, allowOnly?: boolean) {\n if (allowOnly) {\n return;\n }\n const error = processError(\n new Error(\n '[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error',\n ),\n );\n task.result = {\n state: 'fail',\n errors: [error],\n };\n}\n"],"mappings":";;;;;;;AAwJA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;AChJD,MAAM,qCAAsH;CAC1H,OAAO;CACP,aAAa;CACb,sBAAsB;CACtB,0BAA0B;CAC1B,aAAa;CACb,cAAc,sBAAsB,GAAG;CACvC,oBAAoB,EAAE;CACvB;AAED,SAAS,sBAAsB,SAA0C;AACvE,QAAO;EACL,MAAM,iBAAiB;EACvB;EACD;;AAIH,SAAgB,mBAAmB,iBAA0D;CAC3F,MAAM,cAAyC,mBAAmB;AAGlE,MAAK,MAAM,aAAa,6BACtB,KAAI,YAAY,eAAe,OAC7B,aAAY,aAAa,mCAAmC;CAIhE,MAAM,WAAW;EAAE,GAAG;EAAa,YAAY;EAAM;AAErD,KACG,SAAS,2BAA2B,UAAa,SAAS,yBAAyB,KAChF,SAAS,uBAAuB,UAAa,SAAS,qBAAqB,EAE/E,OAAM,sBACJ,uGAAuG,SAAS,gDAClF,SAAS,qBACxC;AAGH,KACG,SAAS,+BAA+B,UAAa,SAAS,6BAA6B,KACxF,SAAS,2BAA2B,UAAa,SAAS,yBAAyB,EAEvF,OAAM,sBACJ,+GAA+G,SAAS,wDACtF,SAAS,yBAC5C;AAGH,QAAO;;AAGT,SAAgB,YAAY,OAA2C;AACrE,QAAO,OAAO,UAAU,WAAW,QAAQ,OAAO,SAAS;;AAG7D,SAAgB,gBAAgB,QAAkD;AAChF,QAAO;EACL,GAAG;EACH,OAAO,YAAY,OAAO,MAAM;EACjC;;AAGH,SAAS,kBAAkB,KAKzB;CACA,MAAM,UAAU,EAAE;AAOlB,KAAI,SAED,QAAO,MAAK,EAAE,OAAO,KAAK,0BAAkC,CAAC,CAE7D,SAAQ,YAAW;AACl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AAS,MAAM;AACzB,MAAI,EAAE,SAAS,SAAS,EAAE,SAAS,UAAU;AAC3C,KAAE,OAAO;AACT,OAAI,EAAE,SAAS,QACb,cAAa,EAAE;;GAGnB;;AAGJ,SAAS,eAAe,MAAgB,WAAqB;AAC3D,KAAI,UACF;AAOF,MAAK,SAAS;EACZ,OAAO;EACP,QAAQ,CAPI,6BACZ,IAAI,MACF,kGACD,CACF,CAGgB;EAChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-pool-assemblyscript",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "AssemblyScript testing with Vitest - Simple, fast, familiar, AS-native, with full coverage output",
5
5
  "author": "Matt Ritter <matthew.d.ritter@gmail.com>",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- {"version":3,"file":"load-user-imports-6Pv-9hRg.mjs","names":[],"sources":["../src/wasm-executor/wasm-console.ts","../src/wasm-executor/collect-options.ts","../src/wasm-executor/wasm-imports.ts","../src/wasm-executor/index.ts","../src/pool-thread/rpc-reporter.ts","../src/pool-thread/load-user-imports.ts"],"sourcesContent":["import type { AssemblyScriptConsoleLogHandler } from '../types/types.js';\nimport { liftString } from '../util/assemblyscript/binding-helpers.js';\n\nexport function createWasmConsole(\n memory: WebAssembly.Memory,\n handleLog: AssemblyScriptConsoleLogHandler\n) {\n const getMessage = (msgPtr: number, memory: WebAssembly.Memory, prefix: string = ''): string => {\n return `${prefix}${msgPtr ? liftString(memory, msgPtr) : '<no message>'}`;\n };\n\n const timersByLabel: { [label: string]: number } = {};\n\n // provides the AssemblyScript \"brower-like console\" from AS std lib\n // see https://github.com/AssemblyScript/assemblyscript/blob/v0.28.9/std/assembly/index.d.ts#L2609\n return {\n 'console.assert': <T>(assertion: T, msgPtr: number): void => {\n if (!assertion) {\n const msg = getMessage(msgPtr, memory);\n handleLog(`Assertion failed${msg ? `: ${msg}` : ''}`);\n }\n },\n 'console.log': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory));\n },\n 'console.debug': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory, 'Debug: '));\n },\n 'console.info': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory, 'Info: '));\n },\n 'console.warn': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory, 'Warning: '), true);\n },\n 'console.error': (msgPtr: number): void => {\n handleLog(getMessage(msgPtr, memory, 'Error: '), true);\n },\n 'console.time': (labelPtr?: number): void => {\n const label = labelPtr ? liftString(memory, labelPtr) ?? 'default' : 'default';\n timersByLabel[label] = performance.now();\n },\n 'console.timeLog': (labelPtr?: number): void => {\n const label = labelPtr ? liftString(memory, labelPtr) ?? 'default' : 'default';\n const start = timersByLabel[label];\n let msg = '';\n if (start === undefined) {\n msg = `Warning: No such label '${label}' for console.timeLog()`;\n } else {\n msg = `${label}: ${(performance.now() - start).toFixed(3)}ms`;\n }\n handleLog(msg);\n },\n 'console.timeEnd': (labelPtr?: number): void => {\n const label = labelPtr ? liftString(memory, labelPtr) ?? 'default' : 'default';\n const start = timersByLabel[label];\n let msg = '';\n if (start === undefined) {\n msg = `Warning: No such label '${label}' for console.timeLog()`;\n } else {\n msg = `${label}: ${(performance.now() - start).toFixed(3)}ms`;\n }\n handleLog(msg);\n delete timersByLabel[label];\n },\n\n trace(msgPtr: number, n: number, a0: any, a1: any, a2: any, a3: any): void {\n const msg = liftString(memory, msgPtr);\n const args: any[] = [a0, a1, a2, a3];\n const nArgs: any[] = n && n > 0 ? args.slice(0, n) : args;\n\n console.trace(`WASM Trace:${msg ? ` ${msg}` : ''}`, ...nArgs);\n },\n };\n}\n","import { AssemblyScriptTestOptions } from '../types/types.js';\n\nconst TEST_OPTION_UNDEFINED: number = -1;\nconst TEST_OPTION_TRUE: number = 1;\n\nexport function mergeAssemblyScriptTestOptions(\n baseOptions: AssemblyScriptTestOptions,\n timeout: number,\n retry: number,\n skip: number,\n only: number,\n fails: number,\n): AssemblyScriptTestOptions {\n const options: AssemblyScriptTestOptions = { ...baseOptions };\n \n // numerical options\n if (timeout > TEST_OPTION_UNDEFINED) {\n options.timeout = timeout;\n }\n if (retry > TEST_OPTION_UNDEFINED) {\n options.retry = retry;\n }\n\n // boolean options\n if (skip > TEST_OPTION_UNDEFINED) {\n options.skip = skip === TEST_OPTION_TRUE ? true : false;\n }\n if (only > TEST_OPTION_UNDEFINED) {\n options.only = only === TEST_OPTION_TRUE ? true : false;\n }\n if (fails > TEST_OPTION_UNDEFINED) {\n options.fails = fails === TEST_OPTION_TRUE ? true : false;\n }\n\n return options;\n}\n","import type { File, Suite, Test } from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptConsoleLogHandler,\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestError,\n AssemblyScriptTestTaskMeta,\n FailedAssertion,\n WasmImportsFactory,\n} from '../types/types.js';\nimport {\n AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME,\n AS_POOL_WASM_IMPORTS_MODULE_NAME,\n POOL_ERROR_NAMES,\n TEST_ERROR_NAMES\n} from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { abortWASMExecution, abortWASMExecutionOnSuccess, createPoolError, getExpectedMessageOrAny } from '../util/pool-errors.js';\nimport { liftString } from '../util/assemblyscript/binding-helpers.js';\nimport { decodeAbortInfo } from './wasm-memory.js';\nimport { createWasmConsole } from './wasm-console.js';\nimport { mergeAssemblyScriptTestOptions } from './collect-options.js';\nimport { createSuiteTask, createTestTask, failTestAssertionError, failTestRuntimeError } from '../util/vitest-tasks.js';\n\nfunction createUserWasmImports(\n createWasmImports: WasmImportsFactory | undefined,\n memory: WebAssembly.Memory,\n module: WebAssembly.Module,\n logPrefix: string\n) {\n let userEnvImports: WebAssembly.ModuleImports | undefined;\n let userCustomEnvImports: WebAssembly.Imports | undefined;\n\n if (createWasmImports) {\n try {\n const start = performance.now();\n const userImports: WebAssembly.Imports = createWasmImports({\n memory,\n module,\n utils: {\n liftString: (stringPtr: number) => liftString(memory, stringPtr)\n }\n });\n debug(`${logPrefix} Created user WASM imports for test execution in ${(performance.now() - start).toFixed(2)} ms`);\n\n userEnvImports = userImports?.env;\n \n if (userEnvImports) {\n userCustomEnvImports = { ...userImports };\n delete userCustomEnvImports.env;\n }\n } catch (error) {\n const msg = `Could not create user WasmImportsFactory.`\n + ` Ensure that your module has a default export matching () => WebAssembly.Imports`;\n throw createPoolError(\n POOL_ERROR_NAMES.WASMUserImportsError,\n msg,\n error,\n true\n );\n }\n }\n\n return { userEnvImports, userCustomEnvImports };\n}\n\n/**\n * Create import object for test discovery\n */\nexport function createDiscoveryImports(\n memory: WebAssembly.Memory,\n module: WebAssembly.Module,\n file: File,\n handleLog: AssemblyScriptConsoleLogHandler,\n logPrefix: string,\n coverageMemory?: WebAssembly.Memory,\n createWasmImports?: WasmImportsFactory,\n): WebAssembly.Imports {\n const suiteStack: Suite[] = [file];\n\n const {\n userEnvImports,\n userCustomEnvImports\n } = createUserWasmImports(createWasmImports, memory, module, logPrefix);\n \n return {\n env: {\n // users can choose to hide these with their own\n ...createWasmConsole(memory, handleLog),\n\n // user imports for \"env\"\n ...(userEnvImports ?? {}),\n\n memory,\n\n // handle runtime aborts, which are always unexpected during discovery\n abort(msgPtr: number, filePtr: number, line: number, column: number) {\n const { message, location } = decodeAbortInfo(memory, msgPtr, filePtr, line, column);\n const msgAtLoc = `${message}${location ? ` at ${location}` : ''}`;\n \n debug(`${logPrefix} - Unexpected abort during test discovery: ${msgAtLoc}`);\n\n const testError: AssemblyScriptTestError = {\n message,\n name: TEST_ERROR_NAMES.WASMRuntimeError,\n };\n\n throw abortWASMExecution(testError, new Error());\n },\n },\n\n [AS_POOL_WASM_IMPORTS_MODULE_NAME]: {\n\n ...(coverageMemory ? { [AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME]: coverageMemory } : {}),\n\n // stubs during discovery\n __assertion_pass() {},\n __assertion_fail() {},\n __expect_throw() {},\n __end_expect_throw() {},\n\n __begin_register_suite(\n namePtr: number,\n timeout: number,\n retry: number,\n skip: number,\n only: number,\n fails: number,\n ) {\n const parentSuite = suiteStack[suiteStack.length - 1]!;\n const defaultTestOptions = (parentSuite.meta as AssemblyScriptSuiteTaskMeta).defaultTestOptions;\n const suiteName = liftString(memory, namePtr) ?? 'unknown suite';\n const options = mergeAssemblyScriptTestOptions(defaultTestOptions, timeout, retry, skip, only, fails);\n const suite = createSuiteTask(suiteName, file, parentSuite, options);\n suiteStack.push(suite);\n\n debug(\n `${logPrefix} - Registering Suite \"${suite.name}\" | timeout: ${options.timeout} ms | retry: ${options.retry}`\n + ` | skip: ${options.skip} | only: ${options.only} | fails: ${options.fails} `\n + ` | parent: \"${suite.suite?.name}\" (parent idx: ${(suite.meta as AssemblyScriptSuiteTaskMeta).idxInParentTasks})`\n );\n },\n \n __end_register_suite(_namePtr: number) {\n const suite = suiteStack.pop();\n\n debug(\n `${logPrefix} - Registered Suite \"${suite?.name}\" | ${suite?.tasks.length} top-level tasks | mode: \"${suite?.mode}\"`\n + ` | parent: \"${suite?.suite?.name}\" (parent idx: ${(suite?.meta as AssemblyScriptSuiteTaskMeta)?.idxInParentTasks})`\n );\n },\n\n // called by test() to register test names and function indices\n __register_test(\n namePtr: number,\n fnIndex: number,\n timeout: number,\n retry: number,\n skip: number,\n only: number,\n fails: number,\n ) {\n const parentSuite = suiteStack[suiteStack.length - 1]!;\n const defaultTestOptions = (parentSuite.meta as AssemblyScriptSuiteTaskMeta).defaultTestOptions;\n const testName = liftString(memory, namePtr) ?? 'unknown test';\n const options = mergeAssemblyScriptTestOptions(defaultTestOptions, timeout, retry, skip, only, fails);\n const test = createTestTask(testName, fnIndex, file, parentSuite, options);\n \n debug(`${logPrefix} - Registered test \"${test.name}\" | mode (pre-interp): \"${test.mode}\"`\n + ` | fnIndex ${fnIndex} | timeout: ${options.timeout} ms | retry: ${options.retry} | skip: ${options.skip}`\n + ` | only: ${options.only} | fails: ${options.fails} | suite: \"${test.suite?.name}\"`\n + ` (parent idx: ${(test.meta as AssemblyScriptTestTaskMeta).idxInParentTasks})`\n );\n },\n },\n\n // user imports for any other environments they defined\n ...(userCustomEnvImports ?? {}),\n };\n}\n\n/**\n * Create import object for test execution\n *\n * Used during test execution to capture test results / assertions, and to handle\n * runtime aborts as expected cases for test execution by capturing the error on the test meta.\n */\nexport function createTestExecutionImports(\n memory: WebAssembly.Memory,\n module: WebAssembly.Module,\n test: Test,\n handleLog: AssemblyScriptConsoleLogHandler,\n logPrefix: string,\n coverageMemory?: WebAssembly.Memory,\n createWasmImports?: WasmImportsFactory,\n): { imports: WebAssembly.Imports; provideFunctionTable: (table: WebAssembly.Table) => void; } {\n // execution imports are created per-test, so these represent per-test state\n let lastFailedAssertion: FailedAssertion | undefined;\n let isExpectingError: boolean = false;\n let expectedErrorMsgStr: string | undefined;\n let wasmFunctionTable: WebAssembly.Table | undefined;\n\n const {\n userEnvImports,\n userCustomEnvImports\n } = createUserWasmImports(createWasmImports, memory, module, logPrefix);\n\n const imports = {\n env: {\n // users can choose to hide these with their own\n ...createWasmConsole(memory, handleLog),\n\n // user imports for \"env\"\n ...(userEnvImports ?? {}),\n\n memory,\n\n abort(msgPtr: number, filePtr: number, line: number, column: number) {\n const { message, location } = decodeAbortInfo(memory, msgPtr, filePtr, line, column);\n const msgAtLoc = `${message}${location ? ` at ${location}` : ''}`;\n \n debug(`${logPrefix} - Handling test execution abort: ${msgAtLoc}`);\n\n let failureMessage = message;\n\n // handle expected aborts for thrown errors\n if (isExpectingError) {\n // TODO: decide if .includes is correct here or not\n if (!expectedErrorMsgStr || message.includes(expectedErrorMsgStr)) {\n // either no specifically expected error (any error), or error message matches\n (test.meta as AssemblyScriptTestTaskMeta).assertionsPassedCount++;\n \n debug(`${logPrefix} - Thrown error matches expected - assertion passes`);\n\n // abort without failing the test\n throw abortWASMExecutionOnSuccess();\n } else {\n const expected = getExpectedMessageOrAny(expectedErrorMsgStr);\n\n // error message mismatch\n failureMessage = `expected function to throw error ${expected}, but received error \"${message}\"`;\n\n lastFailedAssertion = {\n message: failureMessage,\n actualTypeName: 'string',\n expectedTypeName: 'string',\n valuesProvided: true,\n actual: message,\n expected: expectedErrorMsgStr\n };\n\n const errStr = `Thrown error does not match expected | Expected: ${expected} | Actual: \"${message}\"`;\n debug(`${logPrefix} - Assertion failed: ${errStr}`);\n }\n }\n\n const testError = lastFailedAssertion\n ? failTestAssertionError(test, lastFailedAssertion)\n : failTestRuntimeError(test, '', failureMessage);\n\n throw abortWASMExecution(testError, new Error());\n },\n },\n\n [AS_POOL_WASM_IMPORTS_MODULE_NAME]: {\n \n ...(coverageMemory ? { [AS_POOL_WASM_COVERAGE_MEM_IMPORT_NAME]: coverageMemory } : {}),\n\n // stubs during execution\n __register_test() {},\n __begin_register_suite() {},\n __end_register_suite() {},\n\n __assertion_pass() {\n (test.meta as AssemblyScriptTestTaskMeta).assertionsPassedCount++;\n },\n\n __assertion_fail(msgPtr: number, actualTypeNamePtr: number, expectedTypeNamePtr: number, valuesProvided: boolean, actualPtr?: number, expectedPtr?: number) {\n const errorMsg = liftString(memory, msgPtr) ?? '';\n const actualTypeName = liftString(memory, actualTypeNamePtr) ?? '';\n const expectedTypeName = liftString(memory, expectedTypeNamePtr) ?? '';\n let valuesMsg = ' | No Values Provided';\n \n lastFailedAssertion = {\n actualTypeName,\n expectedTypeName,\n message: errorMsg,\n valuesProvided: Boolean(valuesProvided)\n };\n\n (test.meta as AssemblyScriptTestTaskMeta).assertionsFailed.push(lastFailedAssertion);\n \n if (valuesProvided && actualPtr && expectedPtr) {\n lastFailedAssertion.actual = liftString(memory, actualPtr);\n lastFailedAssertion.expected = liftString(memory, expectedPtr);\n valuesMsg = ` | Actual Type: ${actualTypeName} | Expected Type: ${expectedTypeName}`\n + ` | Actual Value: \\`${lastFailedAssertion.actual}\\` | Expected Value: \\`${lastFailedAssertion.expected}\\``;\n }\n \n debug(`${logPrefix} - Assertion failed: ${errorMsg}${valuesMsg}`);\n },\n\n __expect_throw(fnIndex: number, expectedErrorMsgPtr?: number) {\n isExpectingError = true;\n if (expectedErrorMsgPtr) {\n expectedErrorMsgStr = liftString(memory, expectedErrorMsgPtr);\n }\n\n debug(`${logPrefix} - Registered expected error throw: ${getExpectedMessageOrAny(expectedErrorMsgStr)}`);\n\n if (wasmFunctionTable && typeof wasmFunctionTable.get === 'function') {\n const fn = wasmFunctionTable.get(fnIndex);\n if (!fn) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n `Could not access function (fnPtr ${fnIndex}) which is expected to throw in test \"${test.name}\"`,\n );\n }\n\n // successful:\n // - throws in WASM, calls abort handler\n // - abort handler confirms error matches expected, does NOT fail test, halts execution with WASMExecutionAbortError\n // - executor catches WASMExecutionAbortError as 'known' and proceeds to process & report passed test\n // failure (wrong error):\n // - throws in WASM, calls abort handler\n // - abort handler confirms error matches mismatch, failTest packages up an appropriate test error\n // - abort handler halts execution with WASMExecutionAbortError containing test error\n // - executor catches WASMExecutionAbortError as 'known' and proceeds to process & report test error\n // failure (no error):\n // - does NOT throw in WASM\n // - WASM continues executing and calls __end_expect_throw\n // - __end_expect_throw sees it is STILL expecting an error, failTest packages up an appropriate test error\n // - __end_expect_throw halts execution with WASMExecutionAbortError containing test error\n // - executor catches WASMExecutionAbortError as 'known' and proceeds to process & report test error\n debug(`${logPrefix} - Calling function (idx ${fnIndex})`);\n fn();\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n `Could not access WASM function table to call function expected to throw`,\n );\n }\n },\n\n __end_expect_throw() {\n if (isExpectingError) {\n const errStr = `Expected thrown error but got none | Expected: \"${expectedErrorMsgStr}\"`;\n debug(`${logPrefix} - Assertion failed: ${errStr}`);\n \n const failureMessage = `function did not throw, but was expected to throw error: ${getExpectedMessageOrAny(expectedErrorMsgStr)}`;\n const testError = failTestAssertionError(test, {\n message: failureMessage,\n actualTypeName: 'undefined',\n expectedTypeName: 'string',\n valuesProvided: true,\n actual: undefined,\n expected: expectedErrorMsgStr\n });\n\n // Must throw here to halt WASM execution on an assertion or runtime failure for this test.\n // This will be caught by the executor and reported as an appropriate test error\n throw abortWASMExecution(testError);\n }\n },\n },\n\n // user imports for any other environments they defined\n ...(userCustomEnvImports ?? {}),\n };\n\n return {\n imports,\n provideFunctionTable: (table: WebAssembly.Table) => {\n debug(`${logPrefix} - Got WASM function table | length: ${table.length}`);\n wasmFunctionTable = table;\n },\n };\n}\n","import { basename } from 'node:path';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\nimport type { File, Test } from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptConsoleLogHandler,\n AssemblyScriptPoolError,\n AssemblyScriptTestError,\n AssemblyScriptTestTaskMeta,\n CoverageData,\n ResolvedAssemblyScriptPoolOptions,\n ThreadImports,\n WASMCompilation,\n WASMExecutorPerfTimings,\n} from '../types/types.js';\nimport { AS_POOL_ERROR_FLAG, POOL_ERROR_NAMES } from '../types/constants.js';\nimport { debug, debugOverride } from '../util/debug.js';\nimport { createMemory } from './wasm-memory.js';\nimport { createDiscoveryImports, createTestExecutionImports } from './wasm-imports.js';\nimport { enhanceTestError } from './wasm-errors.js';\nimport { createPoolError, wrapPoolError } from '../util/pool-errors.js';\nimport { failTestRuntimeError, getTaskLogLabel } from '../util/vitest-tasks.js';\nimport { extractCallStack } from './source-maps.js';\n\nconst SIG_MISMATCH_ERROR_MSG = `WASM function signature type mismatch during test collection.`\n + ` This is most likely caused by passing a type-inferred, non-void callback to expect().`\n + ` To fix, either explicitly define the non-void return type on the callback`\n + ` e.g. \\`expect((): i32 => failingFunction()).toThrowError()\\``\n + ` or use braces to make it void e.g. \\`expect(() => { failingFunction(); }).toThrowError()\\`.`\n + ` Look for the failing expect() within the describe() block indicated in the stack trace.`;\n\nfunction verifyMemoryRequirements(\n compilation: WASMCompilation,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n) {\n if (poolOptions.testMemoryPagesInitial && poolOptions.testMemoryPagesInitial < compilation.requiredMemory.testMemory.initialPages) {\n throw createPoolError(\n POOL_ERROR_NAMES.PoolConfigError,\n `WASM binary requires initial test memory pages (${compilation.requiredMemory.testMemory.initialPages}) exceeding configured \"testMemoryPagesInitial\"`\n + ` (${poolOptions.testMemoryPagesInitial}). Increase value, or remove for auto sizing.`,\n );\n }\n \n if (poolOptions.testMemoryPagesMax && compilation.requiredMemory.testMemory.maximumPages\n && poolOptions.testMemoryPagesMax < compilation.requiredMemory.testMemory.maximumPages\n ) {\n throw createPoolError(\n POOL_ERROR_NAMES.PoolConfigError,\n `WASM binary requires maximum test memory pages (${compilation.requiredMemory.testMemory.maximumPages}) exceeding configured \"testMemoryPagesMax\"`\n + ` (${poolOptions.testMemoryPagesMax}). Increase value, or remove for auto sizing.`,\n );\n }\n \n if (poolOptions.coverageMemoryPagesInitial && poolOptions.coverageMemoryPagesInitial < compilation.requiredMemory.coverageMemory.initialPages) {\n throw createPoolError(\n POOL_ERROR_NAMES.PoolConfigError,\n `WASM binary requires initial coverage memory pages (${compilation.requiredMemory.coverageMemory.initialPages}) exceeding configured \"coverageMemoryPagesInitial\"`\n + ` (${poolOptions.coverageMemoryPagesInitial}). Increase value, or remove for auto sizing.`,\n );\n }\n\n if (poolOptions.coverageMemoryPagesMax && compilation.requiredMemory.coverageMemory.maximumPages\n && poolOptions.coverageMemoryPagesMax < compilation.requiredMemory.coverageMemory.maximumPages\n ) {\n throw createPoolError(\n POOL_ERROR_NAMES.PoolConfigError,\n `WASM binary requires maximum coverage memory pages (${compilation.requiredMemory.coverageMemory.maximumPages}) exceeding configured \"coverageMemoryPagesMax\"`\n + ` (${poolOptions.coverageMemoryPagesMax}). Increase value, or remove for auto sizing.`,\n );\n }\n}\n\nfunction createExecutorMemories(\n compilation: WASMCompilation,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n includeCoverageMemory: boolean,\n): { testMemory: WebAssembly.Memory; coverageMemory?: WebAssembly.Memory } {\n verifyMemoryRequirements(compilation, poolOptions);\n\n const testMemory = createMemory(\n poolOptions.testMemoryPagesInitial ?? compilation.requiredMemory.testMemory.initialPages,\n poolOptions.testMemoryPagesMax ?? compilation.requiredMemory.testMemory.maximumPages\n );\n const coverageMemory = includeCoverageMemory ?\n createMemory(\n poolOptions.coverageMemoryPagesInitial ?? compilation.requiredMemory.coverageMemory.initialPages,\n poolOptions.coverageMemoryPagesMax ?? compilation.requiredMemory.coverageMemory.maximumPages\n )\n : undefined;\n\n return { testMemory, coverageMemory };\n}\n\n/**\n * Discover tests via test() and suites via describe() registration calls\n */\nexport async function executeWASMDiscovery(\n compilation: WASMCompilation,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n isBinaryInstrumented: boolean,\n handleLog: AssemblyScriptConsoleLogHandler,\n file: File,\n moduleLabel: string,\n threadImports: ThreadImports,\n): Promise<void> {\n const base = basename(file.filepath);\n const logPrefix = `[${moduleLabel} Exec] ${getTaskLogLabel(base, file)}`;\n \n try {\n const { testMemory, coverageMemory } = createExecutorMemories(compilation, poolOptions, isBinaryInstrumented);\n\n const importObject = createDiscoveryImports(\n testMemory,\n compilation.compiledModule,\n file,\n handleLog,\n logPrefix,\n coverageMemory,\n threadImports.createUserWasmImports\n );\n\n // Instantiate WASM module\n const instance = new WebAssembly.Instance(compilation.compiledModule, importObject);\n const exports = instance.exports as Record<string, unknown>;\n\n // Call _start to run top-level test() and describe()\n if (typeof exports._start === 'function') {\n exports._start();\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n 'no _start() export found on compiled WASM binary'\n );\n }\n } catch (error: any) {\n const isFunctionSignatureMismatch: boolean = error instanceof WebAssembly.RuntimeError\n && error?.message.includes('null function or function signature mismatch');\n if (isFunctionSignatureMismatch) {\n throw createPoolError(\n POOL_ERROR_NAMES.PoolSyntaxError,\n SIG_MISMATCH_ERROR_MSG,\n error\n );\n } \n\n if (error && error[AS_POOL_ERROR_FLAG]) {\n throw error;\n } else {\n throw wrapPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n error,\n true\n );\n }\n }\n\n debug(`${logPrefix} - Discovered ${file.tasks.length} top-level tasks`);\n return;\n}\n\n/**\n * Execute a single test with crash isolation\n */\nexport async function executeWASMTest(\n test: Test,\n compilation: WASMCompilation,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n collectCoverage: boolean,\n handleLog: AssemblyScriptConsoleLogHandler,\n moduleLabel: string,\n threadImports: ThreadImports,\n projectRoot: string,\n diffOptions?: SerializedDiffOptions,\n): Promise<{ test: Test, testTimings: WASMExecutorPerfTimings }> {\n const testTimings: WASMExecutorPerfTimings = {\n fnInit: performance.now(),\n execStart: 0,\n execEnd: 0,\n fnfinal: 0\n };\n const base = basename(test.file.filepath);\n const fullModuleLabel = `${moduleLabel} Exec`;\n const taskLabel = getTaskLogLabel(base, test);\n const logPrefix = `[${fullModuleLabel}] ${taskLabel}`;\n\n function covDebug(...args: any[]): void {\n if (poolOptions.debugCoverageExtract) {\n debugOverride(...args);\n }\n };\n\n const { testMemory, coverageMemory } = createExecutorMemories(compilation, poolOptions, collectCoverage);\n\n // Create import object with pool-side functions for capturing test execution results\n const { imports, provideFunctionTable } = createTestExecutionImports(\n testMemory,\n compilation.compiledModule,\n test,\n handleLog,\n logPrefix,\n coverageMemory,\n threadImports.createUserWasmImports\n );\n\n // Instantiate fresh WASM instance for this test\n const instance = new WebAssembly.Instance(compilation.compiledModule, imports);\n const exports = instance.exports as Record<string, unknown>;\n\n // Func table accessable because we're using the AS compiler --exportTable flag\n const table = exports.table as WebAssembly.Table | undefined;\n \n // allow imports to access table\n if (table && typeof table.get === 'function') {\n provideFunctionTable(table);\n }\n\n // Call _start to run top-level code. Test registration is stubbed/noop duing execution,\n // but this call is still needed to initialize any user-defined globals / other top level code.\n if (typeof exports._start === 'function') {\n // Not explicitly handling with try-catch here because failures in _start should be\n // caught during discovery and source-mapped. If this somehow fails, the worker still catches it.\n exports._start();\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n 'no _start() export found on compiled WASM binary'\n );\n }\n\n let testFn: (() => void) | null | undefined;\n \n if (table && typeof table.get === 'function') {\n const idx = (test.meta as AssemblyScriptTestTaskMeta).fnIndex;\n testFn = table.get(idx) as (() => void) | null;\n\n if (!testFn) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n `Test function at index ${idx} not found in function table`\n );\n }\n } else {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n 'Function table not found in WASM exports (missing --exportTable flag?)'\n );\n }\n\n // try-catch to ensure we capture known test errors to report\n // as AssemblyScriptTestErrors to vitest\n try {\n // Execute this test\n testTimings.execStart = performance.now();\n testFn();\n testTimings.execEnd = performance.now();\n\n // If we reach here, test passed, i.e. No abort occurred.\n // Proceed below to prepare the test result\n } catch (error: any) {\n testTimings.execEnd = performance.now();\n\n let testError: AssemblyScriptTestError;\n let stack: NodeJS.CallSite[];\n let allowStackJS: boolean;\n let applyStackToTestErrorCause: boolean;\n\n if (error && error[AS_POOL_ERROR_FLAG]) {\n const wrapper = error as AssemblyScriptPoolError;\n testError = wrapper.testError;\n stack = wrapper.originalErrorRawStack;\n allowStackJS = wrapper.originalErrorMayContainJS;\n applyStackToTestErrorCause = wrapper.applyStackToTestErrorCause;\n } else if (error instanceof Error) {\n testError = failTestRuntimeError(test, error.name, error.message);\n stack = extractCallStack(error);\n allowStackJS = true;\n applyStackToTestErrorCause = false;\n } else {\n testError = failTestRuntimeError(test, '', `Unexpected WASM test execution error: ${String(error)}`);\n stack = extractCallStack(new Error());\n allowStackJS = true;\n applyStackToTestErrorCause = false;\n }\n\n await enhanceTestError(\n testError,\n test,\n compilation.sourceMap,\n logPrefix,\n allowStackJS,\n projectRoot,\n applyStackToTestErrorCause,\n stack,\n diffOptions\n );\n }\n\n const meta = test.meta as AssemblyScriptTestTaskMeta;\n\n // Extract coverage hits from coverage memory\n if (collectCoverage && compilation.debugInfo) {\n if (!coverageMemory) {\n throw createPoolError(\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n 'Coverage memory not created despite collectCoverage=true'\n );\n }\n\n const coverage: CoverageData = {\n hitCountsByFileAndPosition: {},\n };\n\n // Read counters from coverage memory\n const extractedHitCounters = new Uint32Array(coverageMemory.buffer, 0, compilation.debugInfo.instrumentedFunctionCount);\n covDebug(`${logPrefix} - Read coverage memory for ${compilation.debugInfo.instrumentedFunctionCount} instrumented functions`);\n\n // Iterate all instrumented functions and build coverage data with hit counts extracted from coverage memory\n let functionsHit = 0;\n for (const [filePath, debugFunctions] of Object.entries(compilation.debugInfo.functionsByFileAndPosition)) {\n if (!coverage.hitCountsByFileAndPosition[filePath]) {\n coverage.hitCountsByFileAndPosition[filePath] = {};\n covDebug(`${logPrefix} - Extracting hits for source file \"${filePath}\"`);\n }\n\n for (const [positionKey, funcInfos] of Object.entries(debugFunctions)) {\n // Sum hit counts across all functions at this position (multiple for generic monomorphizations)\n let positionHitCount = 0;\n for (const funcInfo of funcInfos) {\n if (funcInfo.coverageMemoryIndex === undefined) {\n debug(`${logPrefix} - WARNING: NO COVERAGE MEMORY INDEX`\n + ` - func \"${funcInfo.name}\" (${positionKey}) Skipping hit extraction`\n );\n continue;\n }\n\n const hitCount = extractedHitCounters[funcInfo.coverageMemoryIndex] ?? 0;\n covDebug(`${logPrefix} - func \"${funcInfo.name}\" (${positionKey}) `\n + `[idx: ${funcInfo.coverageMemoryIndex}]: ${hitCount} hits`\n );\n positionHitCount += hitCount;\n }\n\n coverage.hitCountsByFileAndPosition[filePath][positionKey] = positionHitCount;\n\n if (positionHitCount > 0) {\n functionsHit++;\n }\n }\n }\n\n meta.coverageData = coverage;\n debug(`${logPrefix} - Extracted coverage data | ${functionsHit} functions hit`);\n }\n\n testTimings.fnfinal = performance.now();\n\n return { test, testTimings };\n}\n","/**\n * RPC Reporting Helpers\n *\n * This module provides helper functions for reporting test lifecycle events\n * to Vitest via RPC. All helpers are designed to be composable and reusable.\n */\n\nimport type { MessagePort } from 'node:worker_threads';\nimport { createBirpc } from 'birpc';\nimport type { RunnerRPC, RuntimeRPC, UserConsoleLog } from 'vitest';\nimport type {\n File,\n Suite,\n Test,\n Task,\n TaskEventPack, \n TaskResultPack,\n CancelReason,\n} from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptConsoleLog,\n AssemblyScriptCoveragePayload,\n AssemblyScriptSuiteTaskMeta,\n VitestVersion,\n WorkerRPC\n} from '../types/types.js';\nimport { debug } from '../util/debug.js';\nimport { COVERAGE_PAYLOAD_FORMATS } from '../types/constants.js';\nimport {\n createAfterSuiteRunMeta,\n getTaskLogLabel,\n isSuiteOwnFile\n} from '../util/vitest-tasks.js';\n\n// ============================================================================\n// RPC Client Factory\n// ============================================================================\n\n/** Create RPC client from MessagePort */\nexport function createRpcClient(port: MessagePort): WorkerRPC {\n return createBirpc<RuntimeRPC, RunnerRPC>(\n {\n onCancel: (_reason: CancelReason) => void { }\n },\n {\n post: (v) => port.postMessage(v),\n on: (fn) => port.on('message', fn),\n }\n );\n}\n\n// ============================================================================\n// File Task Reporting\n// ============================================================================\n\n/** Report file as queued (before compilation & discovery starts) */\nexport async function reportFileQueued(\n rpc: WorkerRPC,\n fileTask: File,\n logModule: string,\n logLabel: string,\n): Promise<void> {\n await rpc.onQueued(fileTask);\n debug(`[${logModule} RPC] ${logLabel} - Reported onQueued for file \"${fileTask.filepath}\"`\n + ` | mode: \"${fileTask.mode}\" | state: \"${fileTask.result ? fileTask.result.state : '--'}\"`\n );\n}\n\n/** Report file collection complete with full task tree */\nexport async function reportFileCollected(\n rpc: WorkerRPC,\n fileTask: File,\n logModule: string,\n logLabel: string,\n): Promise<void> {\n await rpc.onCollected([fileTask]);\n debug(`[${logModule} RPC] ${logLabel} - Reported onCollected for file \"${fileTask.filepath}\"`\n + ` | ${fileTask.tasks.length} tasks | mode: \"${fileTask.mode}\" | state: \"${fileTask.result?.state}\"`\n );\n}\n\n/** Report file-level error (compilation/discovery failure) as \"suite-failed-early\" */\nexport async function reportFileError(\n rpc: WorkerRPC,\n fileTask: File, \n logModule: string,\n logLabel: string,\n): Promise<void> {\n const taskPack: TaskResultPack = [fileTask.id, fileTask.result, {}];\n const eventPack: TaskEventPack = [fileTask.id, \"suite-failed-early\", undefined];\n await rpc.onTaskUpdate([taskPack], [eventPack]);\n\n debug(`[${logModule} RPC] ${logLabel} - Reported \"suite-failed-early\" task update for \"${fileTask.filepath}\"`);\n}\n\n// ============================================================================\n// Suite Lifecycle Reporting\n// ============================================================================\n\n/** Report suite-prepare event */\nexport async function reportSuitePrepare(\n rpc: WorkerRPC,\n suite: Suite,\n logModule: string,\n base: string,\n): Promise<void> {\n // Report suite event (without the custom task meta so reporters won't log it)\n const taskPack: TaskResultPack = [suite.id, suite.result, {}];\n const eventPack: TaskEventPack = [suite.id, 'suite-prepare', undefined];\n\n await rpc.onTaskUpdate([taskPack], [eventPack]);\n\n debug(`[${logModule} RPC] ${getTaskLogLabel(base, suite)} - Reported \"suite-prepare\" task update`\n + ` | state: \"${suite.result?.state}\"`\n );\n}\n\n/** Report suite-finished event */\nexport async function reportSuiteFinished(\n rpc: WorkerRPC,\n suite: Suite,\n logModule: string,\n base: string,\n vitestVersion: VitestVersion = 'v4',\n): Promise<void> {\n const suiteLabel = getTaskLogLabel(base, suite);\n const rpcLogPrefix = `[${logModule} RPC] ${suiteLabel}`;\n const meta = suite.meta as AssemblyScriptSuiteTaskMeta;\n const coverageKeys: number = Object.keys(meta.coverageData?.hitCountsByFileAndPosition ?? {}).length;\n let coveragePromise: Promise<void> = Promise.resolve();\n \n // Report coverage if this is a file task, and coverage is available\n if (isSuiteOwnFile(suite) && coverageKeys > 0) {\n const coverage: AssemblyScriptCoveragePayload = {\n __format: COVERAGE_PAYLOAD_FORMATS.AssemblyScript,\n coverageData: meta.coverageData!,\n suiteLogLabel: suiteLabel\n };\n \n const afterSuiteMeta = createAfterSuiteRunMeta(\n coverage,\n [suite.file.filepath],\n suite.file.projectName,\n vitestVersion\n );\n coveragePromise = rpc.onAfterSuiteRun(afterSuiteMeta);\n\n debug(`${rpcLogPrefix} - onAfterSuiteRun: Reported suite coverage (${coverageKeys} unique positions)`);\n } else if (coverageKeys === 0) {\n debug(`${rpcLogPrefix} - onAfterSuiteRun: No suite coverage to report`);\n }\n\n // Report suite event (without the custom task meta so reporters won't log it)\n const taskPack: TaskResultPack = [suite.id, suite.result, {}];\n const eventPack: TaskEventPack = [suite.id, \"suite-finished\", undefined];\n\n await Promise.all([\n coveragePromise,\n rpc.onTaskUpdate([taskPack], [eventPack])\n ]);\n\n debug(`${rpcLogPrefix} - Reported \"suite-finished\" task update | state: \"${suite.result?.state}\"`\n + ` | duration: ${suite.result?.duration?.toFixed(2) ?? '--'} ms`\n );\n}\n\n// ============================================================================\n// Test Lifecycle Reporting\n// ============================================================================\n\nasync function reportTestTaskUpdate(\n rpc: WorkerRPC,\n test: Test,\n logModule: string,\n base: string,\n updateEvent: 'test-prepare' | 'test-finished' | 'test-retried'\n): Promise<void> {\n // Report test event (without the custom task meta so reporters won't log it)\n const taskPack: TaskResultPack = [test.id, test.result, {}];\n const eventPack: TaskEventPack = [test.id, updateEvent, undefined];\n\n debug(`[${logModule} RPC] ${getTaskLogLabel(base, test)} - Reporting \"${updateEvent}\" task update...`\n + ` | state: \"${test.result?.state}\"`\n + `${updateEvent === 'test-prepare' ? '' : ` | duration: ${test.result?.duration?.toFixed(2) ?? '--'} ms`}`\n );\n await rpc.onTaskUpdate([taskPack], [eventPack]);\n debug(`[${logModule} RPC] ${getTaskLogLabel(base, test)} - Reported \"${updateEvent}\" task update`\n + ` | state: \"${test.result?.state}\"`\n + `${updateEvent === 'test-prepare' ? '' : ` | duration: ${test.result?.duration?.toFixed(2) ?? '--'} ms`}`\n );\n}\n\n/** Report test starting execution */\nexport async function reportTestPrepare(\n rpc: WorkerRPC,\n test: Test,\n logModule: string,\n base: string,\n): Promise<void> {\n return reportTestTaskUpdate(rpc, test, logModule, base, 'test-prepare');\n}\n\n/** Report test finished execution */\nexport async function reportTestFinished(\n rpc: WorkerRPC,\n test: Test,\n logModule: string,\n base: string,\n): Promise<void> {\n return reportTestTaskUpdate(rpc, test, logModule, base, 'test-finished');\n}\n\n/** Report test retried (sent when test failed and is going to be retried) */\nexport async function reportTestRetried(\n rpc: WorkerRPC,\n test: Test,\n logModule: string,\n base: string,\n): Promise<void> {\n return reportTestTaskUpdate(rpc, test, logModule, base, 'test-retried');\n}\n\n// ============================================================================\n// Other Reporting\n// ============================================================================\n\n/** Report user console log messages */\nexport async function reportUserConsoleLogs(\n rpc: WorkerRPC,\n logs: AssemblyScriptConsoleLog[],\n logModule: string,\n base: string,\n task: Task,\n): Promise<void> {\n if (logs.length === 0) {\n return;\n }\n\n const stdLogs = logs.filter(l => !l.isError);\n const errorLogs = logs.filter(l => l.isError);\n\n const stdContent: string = stdLogs.map(l => `${l.msg}`).join('\\n');\n const errorContent: string = errorLogs.filter(l => l.isError).map(l => `${l.msg}`).join('\\n');\n\n const stdLog: UserConsoleLog = {\n content: `${stdContent}\\n`,\n size: stdContent.length,\n browser: false,\n type: 'stdout',\n time: stdLogs.length > 0 ? stdLogs[0]!.time : Date.now(),\n taskId: task.id,\n origin: task.id\n };\n \n const errorLog: UserConsoleLog = {\n content: `${errorContent}\\n`,\n size: errorContent.length,\n browser: false,\n type: 'stderr',\n time: errorLogs.length > 0 ? errorLogs[0]!.time : Date.now(),\n taskId: task.id,\n origin: task.id\n };\n\n const reportPromises: Promise<void>[] = [];\n if (stdContent.length > 0) {\n reportPromises.push(rpc.onUserConsoleLog(stdLog));\n }\n if (errorContent.length > 0) {\n reportPromises.push(rpc.onUserConsoleLog(errorLog));\n }\n\n await Promise.all(reportPromises);\n\n debug(`[${logModule} RPC] ${getTaskLogLabel(base, task)} - Reported onUserConsoleLog | ${logs.length} messages`);\n}\n\n// ============================================================================\n// Final Flush\n// ============================================================================\n\n/** Flush any pending RPC updates */\nexport async function flushRpcUpdates(\n rpc: WorkerRPC,\n): Promise<void> {\n await rpc.onTaskUpdate([], []);\n}\n","import { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { WasmImportsFactory } from '../types/types.js';\nimport { debug } from '../util/debug.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { createPoolError } from '../util/pool-errors.js';\n\nexport async function loadUserWasmImportsFactory(\n relativePath: string | undefined,\n projectRoot: string,\n logModule: string,\n): Promise<WasmImportsFactory | undefined> {\n if (!relativePath) {\n return undefined;\n }\n\n const path = resolve(projectRoot, relativePath);\n const safeUrl = pathToFileURL(path).href;\n\n try {\n const start = performance.now();\n const createWasmImports = (await import(safeUrl)).default;\n debug(`[${logModule}] Imported user WasmImportsFactory \"${safeUrl}\" | TIMING ${(performance.now() - start).toFixed(2)} ms`);\n\n if (typeof createWasmImports !== 'function') {\n const msg = `Could not load user WasmImportsFactory from \"${safeUrl}\".`\n + ` Ensure that your module has a default export matching () => WebAssembly.Imports`\n + ` \\nDefault export type is currently \"${typeof createWasmImports}\"`;\n \n throw createPoolError(POOL_ERROR_NAMES.WASMUserImportsError, msg);\n } else {\n return createWasmImports;\n }\n } catch (error) {\n const msg = `Could not load user WasmImportsFactory from \"${safeUrl}\".`\n + ` Ensure that your module path is relative to the project root`\n + ` (location of shallowest vitest config), and that it has a`\n + ` default export matching () => WebAssembly.Imports`;\n throw createPoolError(\n POOL_ERROR_NAMES.WASMUserImportsError,\n msg,\n error,\n true\n );\n }\n};\n"],"mappings":";;;;;;;;;AAGA,SAAgB,kBACd,QACA,WACA;CACA,MAAM,cAAc,QAAgB,QAA4B,SAAiB,OAAe;AAC9F,SAAO,GAAG,SAAS,SAAS,WAAW,QAAQ,OAAO,GAAG;;CAG3D,MAAM,gBAA6C,EAAE;AAIrD,QAAO;EACL,mBAAsB,WAAc,WAAyB;AAC3D,OAAI,CAAC,WAAW;IACd,MAAM,MAAM,WAAW,QAAQ,OAAO;AACtC,cAAU,mBAAmB,MAAM,KAAK,QAAQ,KAAK;;;EAGzD,gBAAgB,WAAyB;AACvC,aAAU,WAAW,QAAQ,OAAO,CAA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,aAAa,SAAS,EACxB,gBAAe,KAAK,IAAI,iBAAiB,SAAS,CAAC;AAGrD,OAAM,QAAQ,IAAI,eAAe;AAEjC,OAAM,IAAI,UAAU,QAAQ,gBAAgB,MAAM,KAAK,CAAC,iCAAiC,KAAK,OAAO,WAAW;;;AAQlH,eAAsB,gBACpB,KACe;AACf,OAAM,IAAI,aAAa,EAAE,EAAE,EAAE,CAAC;;;;;ACtRhC,eAAsB,2BACpB,cACA,aACA,WACyC;AACzC,KAAI,CAAC,aACH;CAIF,MAAM,UAAU,cADH,QAAQ,aAAa,aAAa,CACZ,CAAC;AAEpC,KAAI;EACF,MAAM,QAAQ,YAAY,KAAK;EAC/B,MAAM,qBAAqB,MAAM,OAAO,UAAU;AAClD,QAAM,IAAI,UAAU,sCAAsC,QAAQ,cAAc,YAAY,KAAK,GAAG,OAAO,QAAQ,EAAE,CAAC,KAAK;AAE3H,MAAI,OAAO,sBAAsB,YAAY;GAC3C,MAAM,MAAM,gDAAgD,QAAQ,yHAExB,OAAO,kBAAkB;AAErE,SAAM,gBAAgB,iBAAiB,sBAAsB,IAAI;QAEjE,QAAO;UAEF,OAAO;EACd,MAAM,MAAM,gDAAgD,QAAQ;AAIpE,QAAM,gBACJ,iBAAiB,sBACjB,KACA,OACA,KACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pool-errors-GWfwrsD7.mjs","names":[],"sources":["../src/util/path-utils.ts","../src/util/debug.ts","../src/util/highlight-code.ts","../src/util/test-error-formatting.ts","../src/wasm-executor/source-maps.ts","../src/wasm-executor/wasm-names.ts","../src/wasm-executor/wasm-errors.ts","../src/util/pool-errors.ts"],"sourcesContent":["/**\n * Path Utilities\n *\n * Cross-platform path normalization for consistent path comparisons.\n * All internal paths use forward slashes.\n */\n\n/**\n * Convert path to forward slashes for consistent cross-platform comparison.\n *\n * Source maps always use forward slashes regardless of OS. By normalizing\n * all paths to forward slashes, we ensure consistent matching between:\n * - Source map paths (already forward slashes)\n * - Glob results (OS-native, need conversion on Windows)\n * - Relative paths from Node's path.relative() (OS-native)\n * - Resolved paths from Node's path.resolve() (OS-native)\n */\nexport function toForwardSlash(path: string): string {\n return path.replace(/\\\\/g, '/');\n}\n","/**\n * Debug logging utility\n */\n\ndeclare global {\n var AS_POOL_DEBUG: boolean | undefined;\n}\n\nglobalThis.AS_POOL_DEBUG = false;\n\nconst DEBUG_ENV_ENABLED_VALUE = 'vitest_as_pool' as const;\n\nfunction isEnabled(): boolean {\n return globalThis.AS_POOL_DEBUG === true || process.env.DEBUG === DEBUG_ENV_ENABLED_VALUE;\n}\n\n/**\n * Initialize debug mode for current async context (called by worker at task start)\n * @param {boolean} debugEnabled - Enable verbose debug logging\n */\nexport function setGlobalDebugMode(debugEnabled: boolean): void {\n globalThis.AS_POOL_DEBUG = debugEnabled;\n}\n\nfunction debugLog(...args: any): void {\n // if first arg is a function, execute it and then print the result\n if (args?.length > 0 && typeof args[0] === 'function') {\n const result = args[0]();\n const rest = args.length > 1 ? args.slice(1) : [];\n console.log(Date.now(), String(result), ...rest);\n } else {\n console.log(Date.now(), ...args);\n }\n}\n\n/**\n * Log debug message (only when debug enabled in current global context)\n * or when environment has a given DEBUG variable set.\n */\nexport function debug(...args: any): void {\n if (isEnabled()) {\n debugLog(...args);\n }\n}\n\n/**\n * Log debug message (caller expected to determine if enabled)\n */\nexport function debugOverride(...args: any): void {\n debugLog(...args);\n}\n\n/**\n * Determine if debug mode is enabled for the current global context\n */\nexport function isDebugModeEnabled(): boolean {\n return isEnabled();\n}\n\nexport async function delay(ms: number = 5000): Promise<void> {\n return new Promise<void>((resolve, _reject) => {\n setTimeout(resolve, ms);\n });\n}\n","import { highlight, type TokenColors } from 'tinyhighlight';\nimport c from 'tinyrainbow';\n\n/**\n * Adapted from vitest. The internal function was changed between vitest 3.2.x and 4.0.x,\n * and then removed from public exposure in 4.1.x, so now instead we recreate the same\n * highlighting color rules.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v4.1.0/packages/vitest/src/utils/colors.ts#L18\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nconst colors: TokenColors = {\n Keyword: c.magenta,\n IdentifierCapitalized: c.yellow,\n Punctuator: c.yellow,\n StringLiteral: c.green,\n NoSubstitutionTemplate: c.green,\n MultiLineComment: c.gray,\n SingleLineComment: c.gray,\n RegularExpressionLiteral: c.cyan,\n NumericLiteral: c.blue,\n TemplateHead: text =>\n c.green(text.slice(0, text.length - 2)) + c.cyan(text.slice(-2)),\n TemplateTail: text => c.cyan(text.slice(0, 1)) + c.green(text.slice(1)),\n TemplateMiddle: text =>\n c.cyan(text.slice(0, 1))\n + c.green(text.slice(1, text.length - 2))\n + c.cyan(text.slice(-2)),\n IdentifierCallable: c.blue,\n PrivateIdentifierCallable: text => `#${c.blue(text.slice(1))}`,\n Invalid: (text: string) => c.white(c.bgRed(c.bold(text)))\n};\n\nexport function highlightCode(source: string): string {\n return highlight(source, { colors });\n}\n","import { stripVTControlCharacters } from 'node:util';\nimport { fileURLToPath } from 'node:url';\nimport { readFile } from 'node:fs/promises';\nimport type { RawSourceMap } from 'source-map';\nimport type { ParsedStack } from '@vitest/utils';\nimport c from 'tinyrainbow';\n\nimport { highlightCode } from './highlight-code.js';\n\nconst FRAME_POINTER = '❯' as const;\nconst CODE_FRAME_INDENT_SPACES = 4 as const;\n\n// same performance guard used in vitest `printError`\nconst MAX_CODE_HIGHLIGHT_LENGTH = 100_000 as const;\n\nexport function getYellowString(str: string): string {\n return c.yellow(str);\n}\n\nexport function toPlaintextStackFrameString(frame: ParsedStack): string {\n return ` at ${frame.method} ${frame.file}:${frame.line}:${frame.column}`;\n}\n\nexport function toVitestLikeStackFrameString(frame: ParsedStack): string {\n return c.cyan(\n ` ${c.dim(FRAME_POINTER)} ${frame.method} ${frame.file}:${c.dim(`${frame.line}:${frame.column}`)}`\n );\n}\n\nexport async function getSourceCodeFrameString(\n sourceMap: RawSourceMap | undefined,\n frame: ParsedStack,\n): Promise<string | undefined> {\n let source: string | undefined;\n\n if (!sourceMap) {\n return undefined;\n }\n\n const fileIndex = sourceMap.sources.indexOf(frame.file);\n if (fileIndex < 0 || !sourceMap.sourcesContent) {\n const framePath = fileURLToPath(frame.file);\n source = await readFile(framePath, 'utf-8');\n } else {\n source = sourceMap.sourcesContent[fileIndex];\n }\n\n if (!source) {\n return undefined;\n }\n\n const highlightedSource = source.length < MAX_CODE_HIGHLIGHT_LENGTH\n ? highlightCode(source)\n : source;\n\n return generateCodeFrame(highlightedSource, CODE_FRAME_INDENT_SPACES, frame);\n}\n\n\n// ============================================================================\n// Source code formatting functions borrowed from Vitest\n// ============================================================================\n\n/**\n * Vitest doesn't expose generateCodeFrame as a util, so we have\n * recreated it here with minimal changes.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v3.2.4/packages/vitest/src/node/printError.ts#L424\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nconst lineSplitRE: RegExp = /\\r?\\n/;\n\nfunction generateCodeFrame(\n source: string,\n indent = 0,\n loc: { line: number; column: number } | number,\n range = 2,\n): string {\n const start\n = typeof loc === 'object'\n ? positionToOffset(source, loc.line, loc.column)\n : loc\n const end = start\n const lines = source.split(lineSplitRE)\n const nl = /\\r\\n/.test(source) ? 2 : 1\n let count = 0\n let res: string[] = []\n\n const columns = process.stdout?.columns || 80\n\n for (let i = 0; i < lines.length; i++) {\n count += lines[i]!.length + nl\n if (count >= start) {\n for (let j = i - range; j <= i + range || end > count; j++) {\n if (j < 0 || j >= lines.length) {\n continue\n }\n\n const lineLength = lines[j]!.length\n\n // too long, maybe it's a minified file, skip for codeframe\n if (stripVTControlCharacters(lines[j]!).length > 200) {\n return ''\n }\n\n res.push(\n lineNo(j + 1)\n + truncateString(lines[j]!.replace(/\\t/g, ' '), columns - 5 - indent),\n )\n\n if (j === i) {\n // push underline\n const pad = start - (count - lineLength) + (nl - 1)\n const length = Math.max(\n 1,\n end > count ? lineLength - pad : end - start,\n )\n res.push(lineNo() + ' '.repeat(pad) + c.red('^'.repeat(length)))\n }\n else if (j > i) {\n if (end > count) {\n const length = Math.max(1, Math.min(end - count, lineLength))\n res.push(lineNo() + c.red('^'.repeat(length)))\n }\n count += lineLength + 1\n }\n }\n break\n }\n }\n\n if (indent) {\n res = res.map(line => ' '.repeat(indent) + line)\n }\n\n return res.join('\\n')\n}\n\n\nfunction positionToOffset(\n source: string,\n lineNumber: number,\n columnNumber: number,\n): number {\n const lines = source.split(lineSplitRE)\n const nl = /\\r\\n/.test(source) ? 2 : 1\n let start = 0\n\n if (lineNumber > lines.length) {\n return source.length\n }\n\n for (let i = 0; i < lineNumber - 1; i++) {\n start += lines[i]!.length + nl\n }\n\n return start + columnNumber\n}\n\nfunction lineNo(no: number | string = '') {\n return c.gray(`${String(no).padStart(3, ' ')}| `)\n}\n\nfunction truncateString(text: string, maxLength: number): string {\n const plainText = stripVTControlCharacters(text)\n\n if (plainText.length <= maxLength) {\n return text\n }\n\n return `${plainText.slice(0, maxLength - 1)}…`\n}\n","/**\n * Source Map Utilities\n *\n * Maps WASM errors to AssemblyScript source locations using V8 stack traces + source maps.\n *\n * Approach: V8's Error.prepareStackTrace provides WAT (WebAssembly Text) line:column positions,\n * which can be mapped to AS source using the source maps generated by AS compiler.\n */\n\nimport { type RawSourceMap, SourceMapConsumer } from 'source-map';\n\nimport { debug } from '../util/debug.js';\nimport type { WebAssemblyCallSite } from '../types/types.js';\n\nexport function parseSourceMap(sourceMap: string): RawSourceMap {\n // Remove sourceRoot if present to prevent source-map library from prepending it to paths\n // AS compiler sets sourceRoot: \"./output\" which would make paths like \"output/tests/...\"\n // instead of \"tests/...\" - these paths don't exist and won't be found by Vitest\n const sourceMapObj: RawSourceMap = JSON.parse(sourceMap);\n delete sourceMapObj.sourceRoot;\n return sourceMapObj;\n}\n\n/**\n * Extract structured call stack from V8 using Error.prepareStackTrace\n *\n * V8 provides a special API to access structured stack traces with line:column info.\n * This gives us WAT text positions which can be mapped to AS source via source maps.\n *\n * @param capturedError - Error object to extract stack from\n * @returns Array of V8 CallSite objects\n */\nexport function extractCallStack(capturedError: Error): NodeJS.CallSite[] {\n let stackTrace: NodeJS.CallSite[] = [];\n\n const originalPrepareStackTrace = Error.prepareStackTrace;\n Error.prepareStackTrace = (_err: Error, structuredStackTrace: NodeJS.CallSite[]) => {\n stackTrace = structuredStackTrace;\n return ''; // Return empty string to avoid modifying error.stack\n };\n\n // Access error.stack to trigger prepareStackTrace (result unused, just triggers callback)\n capturedError.stack;\n\n // Restore original\n Error.prepareStackTrace = originalPrepareStackTrace;\n\n return stackTrace;\n}\n\n/**\n * Create WebAssembly call site with source mapping\n *\n * Takes a V8 CallSite and maps it to AS source location if possible.\n *\n * @param callSite - V8 CallSite object from Error.prepareStackTrace\n * @param sourceMapJson - Source map consumer initialized with WASM source map\n * @returns Mapped call site or null if not a WASM call site\n */\nexport function createWebAssemblyCallSite(\n callSite: NodeJS.CallSite,\n sourceMapConsumer: SourceMapConsumer,\n loggingPrefix: string,\n allowJS: boolean,\n): WebAssemblyCallSite | null {\n const fileName = callSite.getFileName();\n const watLine = callSite.getLineNumber();\n const watColumn = callSite.getColumnNumber();\n const functionName = callSite.getFunctionName() ?? 'function[unknown]';\n const debugString = `function: \"${functionName}\" | file: ${fileName}:${watLine}:${watColumn}`;\n\n // Only process WASM call sites\n if (!fileName) {\n debug(`${loggingPrefix} - Skipping source-mapping of invalid frame (no file): ${debugString}`);\n return null;\n }\n \n if (!fileName.startsWith('wasm://')) {\n if (allowJS) {\n if (!watLine || !watColumn) {\n debug(`${loggingPrefix} - Failed to pass through invalid JS stack location: ${debugString}`);\n return null;\n }\n\n debug(`${loggingPrefix} - Passing through JS stack location: ${debugString}`);\n return {\n functionName,\n location: {\n filePath: fileName,\n line: watLine,\n column: watColumn\n }\n }; \n } else {\n debug(`${loggingPrefix} - Skipping source-mapping of non-WASM stack location: ${debugString}`);\n return null;\n }\n }\n\n // Try to map WAT location to source location using source map\n if (watLine && watColumn) {\n const original = sourceMapConsumer.originalPositionFor({\n line: watLine,\n column: watColumn\n });\n \n if (!original.source || original.line === null || original.column === null) {\n debug(`${loggingPrefix} - Failed to source-map stack location: ${debugString}`);\n return null;\n }\n\n debug(`${loggingPrefix} - Source-mapped stack location: ${debugString} → ${original.source}:${original.line}:${original.column}`);\n return {\n functionName,\n location: {\n filePath: original.source,\n line: original.line,\n column: original.column\n }\n };\n }\n\n debug(`${loggingPrefix} - Cannot source-map stack-location: ${debugString}`);\n return null;\n}\n","/**\n * Extracts the short name from a WASM function table name identifier.\n */\nexport function getShortFunctionName(fullName: string): string {\n if (!fullName) {\n return '';\n }\n\n // URL decode first (handle potential decoding errors)\n let decoded: string;\n try {\n decoded = decodeURIComponent(fullName);\n \n // handle AS encoding quirk in generics\n // e.g. \"closeTo<bool\\2cbool>\" -> \"closeTo<bool,bool>\"\n decoded = decoded.replace('\\\\2c', ',');\n } catch {\n decoded = fullName;\n }\n\n // Find the last '/' that's not inside angle brackets or parens\n let angleBracketDepth = 0;\n let parenDepth = 0;\n let lastSlashOutsideBrackets = -1;\n\n for (let i = 0; i < decoded.length; i++) {\n const char = decoded[i];\n if (char === '<') {\n angleBracketDepth++;\n } else if (char === '>' && decoded[i - 1] !== '=') {\n angleBracketDepth--;\n } else if (char === '(') {\n parenDepth++;\n } else if (char === ')') {\n parenDepth--;\n } else if (char === '/' && angleBracketDepth === 0 && parenDepth === 0) {\n lastSlashOutsideBrackets = i;\n }\n }\n\n const functionPart = lastSlashOutsideBrackets >= 0\n ? decoded.substring(lastSlashOutsideBrackets + 1)\n : decoded;\n\n // Handle anonymous function case: \"file.as.test~anonymous|1\" → \"anonymous|1\"\n const anonymousMatch = functionPart.match(/^.+~(anonymous\\|\\d+)$/);\n if (anonymousMatch) {\n return anonymousMatch[1]!;\n }\n\n // Process any generics/paths in the function signature\n return shortenTypePart(functionPart);\n}\n\n/**\n * Finds the index of the closing '>' that matches the opening '<' at openIndex.\n */\nfunction findMatchingCloseBracket(str: string, openIndex: number): number {\n let angleBracketDepth = 1;\n\n for (let i = openIndex + 1; i < str.length; i++) {\n const char = str[i];\n if (char === '<') {\n angleBracketDepth++;\n } else if (char === '>' && str[i - 1] !== '=') {\n angleBracketDepth--;\n if (angleBracketDepth === 0) return i;\n }\n }\n return str.length - 1;\n}\n\n/**\n * Finds the index of the closing ')' that matches the opening '(' at openIndex.\n */\nfunction findMatchingCloseParen(str: string, openIndex: number): number {\n let parenDepth = 1;\n let angleBracketDepth = 0;\n\n for (let i = openIndex + 1; i < str.length; i++) {\n const char = str[i];\n if (char === '(') {\n parenDepth++;\n } else if (char === ')') {\n parenDepth--;\n if (parenDepth === 0) return i;\n } else if (char === '<') {\n angleBracketDepth++;\n } else if (char === '>' && str[i - 1] !== '=') {\n angleBracketDepth--;\n }\n }\n return str.length - 1;\n}\n\n/**\n * Splits a string by commas at the top level (not inside <> or ()).\n */\nfunction splitByTopLevelComma(str: string): string[] {\n const parts: string[] = [];\n let current = '';\n let angleBracketDepth = 0;\n let parenDepth = 0;\n\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n if (char === '<') {\n angleBracketDepth++;\n } else if (char === '>' && str[i - 1] !== '=') {\n angleBracketDepth--;\n } else if (char === '(') {\n parenDepth++;\n } else if (char === ')') {\n parenDepth--;\n } else if (char === ',' && angleBracketDepth === 0 && parenDepth === 0) {\n parts.push(current);\n current = '';\n continue;\n }\n current += char;\n }\n parts.push(current);\n return parts;\n}\n\n/**\n * Processes the content inside generic brackets or function args.\n */\nfunction shortenGenericContent(content: string): string {\n const parts = splitByTopLevelComma(content);\n return parts.map(part => shortenTypePart(part.trim())).join(',');\n}\n\n/**\n * Shortens a function type like (args)=>returnType.\n */\nfunction shortenFunctionType(part: string): string {\n const closeParenIndex = findMatchingCloseParen(part, 0);\n const argsContent = part.substring(1, closeParenIndex);\n const afterParen = part.substring(closeParenIndex + 1);\n\n const shortenedArgs = argsContent ? shortenGenericContent(argsContent) : '';\n\n let returnPart = afterParen;\n if (afterParen.startsWith('=>') && afterParen.length > 2) {\n const returnType = afterParen.substring(2);\n returnPart = '=>' + shortenTypePart(returnType);\n }\n\n return '(' + shortenedArgs + ')' + returnPart;\n}\n\n/**\n * Shortens a type/function part, processing paths and generics recursively.\n */\nfunction shortenTypePart(part: string): string {\n // Function types\n if (part.startsWith('(')) {\n return shortenFunctionType(part);\n }\n\n const openBracket = part.indexOf('<');\n\n if (openBracket === -1) {\n // No generics - extract last path segment if present\n if (!part.includes('/')) {\n return part;\n }\n return part.substring(part.lastIndexOf('/') + 1);\n }\n\n // Has generics - extract name and process content\n const namePart = part.substring(0, openBracket);\n const closeBracket = findMatchingCloseBracket(part, openBracket);\n const genericContent = part.substring(openBracket + 1, closeBracket);\n\n const name = namePart.includes('/')\n ? namePart.substring(namePart.lastIndexOf('/') + 1)\n : namePart;\n\n const shortenedContent = shortenGenericContent(genericContent);\n\n return name + '<' + shortenedContent + '>';\n}\n","/**\n * Error Enhancement and Source Mapping\n *\n * This module handles mapping WASM errors to AssemblyScript source locations\n * using source maps. It enhances error messages and stack traces with accurate\n * file:line:column information for better developer experience.\n */\n\nimport { relative } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { type ParsedStack } from '@vitest/utils';\nimport { diff, type SerializedDiffOptions } from '@vitest/utils/diff';\nimport type { Test, Suite } from '@vitest/runner/types';\nimport { type RawSourceMap, SourceMapConsumer } from 'source-map';\n\nimport type { AssemblyScriptTestError, WebAssemblyCallSite } from '../types/types.js';\nimport { POOL_INTERNAL_PATHS, TEST_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { createWebAssemblyCallSite } from './source-maps.js';\nimport { getShortFunctionName } from './wasm-names.js';\nimport {\n getSourceCodeFrameString,\n toPlaintextStackFrameString,\n toVitestLikeStackFrameString,\n} from '../util/test-error-formatting.js';\nimport { toForwardSlash } from '../util/path-utils.js';\n\nconst POOL_INTERNAL_PATHS_SET = new Set(POOL_INTERNAL_PATHS);\n\nfunction passthroughCallSite(callSite: NodeJS.CallSite): ParsedStack {\n const fileName = callSite.getFileName();\n const watLine = callSite.getLineNumber();\n const watColumn = callSite.getColumnNumber();\n const functionName = callSite.getFunctionName() || 'wasm-function[unknown]';\n\n return {\n method: functionName,\n file: fileName ?? 'unknown-file',\n line: watLine || -1,\n column: watColumn || -1\n };\n}\n\nasync function sourceMapRawCallStack(\n rawCallStack: NodeJS.CallSite[],\n sourceMap: RawSourceMap | undefined,\n loggingPrefix: string,\n allowJS: boolean,\n): Promise<WebAssemblyCallSite[]> {\n const mappedStack: WebAssemblyCallSite[] = [];\n\n if (!rawCallStack || rawCallStack.length === 0) {\n return mappedStack;\n }\n\n if (sourceMap) {\n const sourceMapConsumer = await new SourceMapConsumer(sourceMap);\n \n // map stack call sites from raw WASM locations to source locations \n rawCallStack.forEach(callSite => {\n const mappedCallSite = createWebAssemblyCallSite(callSite, sourceMapConsumer, loggingPrefix, allowJS);\n if (mappedCallSite) {\n mappedStack.push(mappedCallSite);\n }\n });\n \n sourceMapConsumer.destroy();\n }\n\n return mappedStack;\n}\n\n// Parse source-mapped stack array to Vitest TestError reporting format\nfunction parseMappedStack(mappedStack: WebAssemblyCallSite[]): ParsedStack[] {\n return mappedStack\n // filter out frames for internal assertion framework calls\n // (e.g. assert(), assertEqual(), etc) by known location, for more concise/meaningful error stack report\n .filter(frame => !(POOL_INTERNAL_PATHS_SET.has(frame.location.filePath)))\n \n // map to format that vitest reporter can display\n .map(frame => ({\n method: getShortFunctionName(frame.functionName),\n file: frame.location.filePath,\n line: frame.location.line,\n column: frame.location.filePath.startsWith('file')\n ? frame.location.column // unmapped file needs no change \n : frame.location.column + 1, // Convert from raw source-map's 0-indexed to 1-indexed for display\n }));\n}\n\nexport async function processWASMErrorStack(\n rawCallStack: NodeJS.CallSite[],\n sourceMap: RawSourceMap | undefined,\n loggingPrefix: string,\n allowJS: bool,\n): Promise<ParsedStack[]> {\n // map stack call sites from WASM locations to source code locations \n const sourceMappedStack = await sourceMapRawCallStack(rawCallStack, sourceMap, loggingPrefix, allowJS);\n debug(`${loggingPrefix} - Mapped ${rawCallStack.length} call sites to ${sourceMappedStack.length} source locations`);\n\n const parsedStack = parseMappedStack(sourceMappedStack);\n\n if (parsedStack.length === 0) {\n rawCallStack.forEach(callSite => {\n parsedStack.push(passthroughCallSite(callSite));\n });\n }\n\n return parsedStack;\n}\n\n/**\n * Enhance reportable test error on the provided test result with source mapped stack locations\n * and a formatted diff based on the error type\n */\nexport async function enhanceTestError(\n testError: AssemblyScriptTestError,\n task: Test | Suite,\n sourceMap: RawSourceMap | undefined,\n logPrefix: string,\n allowJS: boolean,\n projectRoot: string,\n applyStackToTestErrorCause: boolean,\n rawCallStack?: NodeJS.CallSite[],\n diffOptions?: SerializedDiffOptions\n): Promise<void> {\n let expectedVsActualDiffString: string | undefined;\n const isAssertionFailure = testError.name === TEST_ERROR_NAMES.AssertionError;\n const valuesProvided = testError.expected !== undefined && testError.actual !== undefined;\n\n if (isAssertionFailure && valuesProvided) {\n // remain undefined if there were no expected/actual values provided with the assertion failure\n expectedVsActualDiffString = diff(testError.expected, testError.actual, diffOptions) ?? '';\n }\n\n // if there's no stack to map, set the expected vs actual diff (if any) and return\n if (!rawCallStack || rawCallStack.length === 0) {\n testError.diff = expectedVsActualDiffString;\n\n // stack is used by vitest for error deduplication, so make sure it is set\n testError.stack = `${task.name} - ${testError.message}`;\n\n return;\n }\n\n const testErrorToUpdate: AssemblyScriptTestError = applyStackToTestErrorCause && testError.cause\n ? testError.cause as AssemblyScriptTestError : testError;\n\n // map stack call sites from WASM locations to source locations\n const parsedStack = await processWASMErrorStack(rawCallStack, sourceMap, logPrefix, allowJS);\n \n // build additional strings to add to test error's `diff` field based on parsed stack contents\n let primaryStackFrameString: string | undefined;\n let highlightedSourceCodeFrameString: string | undefined;\n \n if (parsedStack.length > 0) {\n // normalize all paths\n parsedStack.forEach((frame) => {\n\t\t\tif (frame.file.startsWith(\"file://\")) {\n\t\t\t\tframe.file = toForwardSlash(relative(projectRoot, fileURLToPath(frame.file)));\n testErrorToUpdate.stack += toPlaintextStackFrameString(frame) + '\\n';\n\t\t\t}\n\t\t});\n\n const primaryStackFrame = parsedStack[0]!;\n \n // Test error is set to rest of the stack without the first frame.\n // Vitest will report the ParsedStack[] on TestError.stacks below the diff we set.\n testErrorToUpdate.stacks = parsedStack.slice(1);\n\n // stack is used by vitest for error deduplication, so make sure it is set also\n testErrorToUpdate.stack = parsedStack.map(toPlaintextStackFrameString).join('\\n');\n\n try {\n highlightedSourceCodeFrameString = await getSourceCodeFrameString(sourceMap, primaryStackFrame);\n } catch (err) {\n debug(`${logPrefix} - Error reading source for primary stack frame file \"${primaryStackFrame.file}\":`, err);\n }\n\n primaryStackFrameString = toVitestLikeStackFrameString(primaryStackFrame);\n\n debug(`${logPrefix} - Enhanced ${testError.name} error with parsed source stack`);\n } else {\n testErrorToUpdate.stack = `${task.name} - ${testError.message}`;\n }\n\n // Use the diff field as our way to show all output (other than result.error.stacks)\n testErrorToUpdate.diff = [\n expectedVsActualDiffString,\n expectedVsActualDiffString ? '\\n\\n' : '',\n primaryStackFrameString ?? '',\n highlightedSourceCodeFrameString ? '\\n' : '',\n highlightedSourceCodeFrameString ?? ''\n ].join('');\n\n debug(`[${logPrefix} - Enhanced error with diffs`);\n\n return;\n}\n","import type { Suite, Test } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\nimport type { RawSourceMap } from 'source-map';\n\nimport type {\n AssemblyScriptPoolError,\n AssemblyScriptTestError,\n PoolErrorName,\n} from '../types/types.js';\nimport {\n AS_POOL_ERROR_FLAG,\n POOL_ERROR_NAMES,\n TEST_ERROR_NAMES\n} from '../types/constants.js';\nimport { getYellowString } from './test-error-formatting.js';\nimport { extractCallStack } from '../wasm-executor/source-maps.js';\nimport { enhanceTestError } from '../wasm-executor/wasm-errors.js';\n\nexport function abortWASMExecutionOnSuccess(): AssemblyScriptPoolError {\n return {\n [AS_POOL_ERROR_FLAG]: true,\n name: POOL_ERROR_NAMES.WASMExecutionAbortSuccess,\n testError: {} as AssemblyScriptTestError,\n originalErrorMayContainJS: false,\n originalErrorRawStack: [],\n applyStackToTestErrorCause: false\n };\n}\n\nexport function abortWASMExecution(\n testError: AssemblyScriptTestError,\n errorForStack?: Error,\n): AssemblyScriptPoolError {\n return {\n [AS_POOL_ERROR_FLAG]: true,\n name: POOL_ERROR_NAMES.WASMExecutionAbortError,\n testError,\n originalErrorMayContainJS: false,\n originalErrorRawStack: errorForStack ? extractCallStack(errorForStack) : [],\n applyStackToTestErrorCause: false\n };\n}\n\nexport function wrapPoolError(\n name: PoolErrorName,\n originalError: any,\n originalErrorMayContainJS: boolean = false,\n): AssemblyScriptPoolError {\n let originalErrorName: string | undefined;\n let originalErrorMessage: string;\n let originalErrorRawStack: NodeJS.CallSite[];\n\n if (originalError && originalError instanceof Error) {\n originalErrorName = originalError.name;\n originalErrorMessage = originalError.message;\n originalErrorRawStack = extractCallStack(originalError);\n } else if (originalError) {\n originalErrorMessage = String(originalError);\n originalErrorRawStack = [];\n } else {\n originalErrorMessage = 'Unknown Error';\n originalErrorRawStack = [];\n }\n\n const namePrefix = originalErrorName ? `${originalErrorName}: ` : '';\n const testError: AssemblyScriptTestError = {\n name,\n message: `${namePrefix}${originalErrorMessage}`\n };\n\n return {\n [AS_POOL_ERROR_FLAG]: true,\n name,\n message: 'Wrapped error',\n originalErrorRawStack,\n originalErrorMayContainJS,\n testError,\n applyStackToTestErrorCause: false\n };\n}\n\nexport function createPoolError(\n name: PoolErrorName,\n message: string,\n originalError?: any,\n originalErrorMayContainJS: boolean = true,\n): AssemblyScriptPoolError {\n if (originalError && originalError[AS_POOL_ERROR_FLAG]) {\n return originalError;\n }\n\n let originalErrorRawStack: NodeJS.CallSite[] = [];\n let applyStackToTestErrorCause: boolean = false;\n const testError: AssemblyScriptTestError = {\n name,\n message\n };\n\n if (originalError && originalError instanceof Error) {\n testError.cause = {\n name: originalError.name,\n message: `${originalError.message}`\n };\n originalErrorRawStack = extractCallStack(originalError);\n applyStackToTestErrorCause = true;\n } else if (originalError) {\n testError.cause = {\n name: POOL_ERROR_NAMES.PoolError,\n message: String(originalError)\n }\n }\n\n return {\n [AS_POOL_ERROR_FLAG]: true,\n name,\n message,\n originalErrorRawStack,\n originalErrorMayContainJS,\n testError,\n applyStackToTestErrorCause\n };\n}\n\nexport function createTestTimeoutError(\n test: Test\n): AssemblyScriptTestError {\n const message = `Test timed out after ${test.timeout}ms`;\n const err: AssemblyScriptTestError = {\n name: POOL_ERROR_NAMES.WASMExecutionTimeoutError,\n message,\n stack: `${test.id}_${message}`,\n diff: getYellowString(` Test Timeout Exceeded (${test.timeout}ms)`)\n };\n return err;\n}\n\nexport function createTestExpectedToFailError(test: Test): AssemblyScriptTestError {\n const message = `Test is expected to fail, but all assertion(s) passed`;\n const err: AssemblyScriptTestError = {\n name: TEST_ERROR_NAMES.AssertionError,\n message,\n stack: `${test.id}_${message}`,\n diff: getYellowString(` Expected to fail, but all assertion(s) passed`)\n };\n return err;\n}\n\nfunction isAbortErrorString(item: any): boolean {\n return item === POOL_ERROR_NAMES.PoolRunAbortedError || item === 'AbortError';\n}\n\nexport function isAbortError(error: any): boolean {\n return isAbortErrorString(error) \n || isAbortErrorString(error?.name)\n || error?.message === 'Terminating worker thread';\n}\n\nexport function getExpectedMessageOrAny(expectedMsgStr?: string): string {\n return expectedMsgStr ? `\"${expectedMsgStr}\"` : '<any>';\n}\n\nexport async function buildEnhancedFileError(\n error: any,\n task: Test | Suite,\n sourceMap: RawSourceMap | undefined,\n logPrefix: string,\n projectRoot: string,\n unexpectedContext: string,\n diffOptions?: SerializedDiffOptions,\n): Promise<AssemblyScriptTestError> {\n let testError: AssemblyScriptTestError;\n let stack: NodeJS.CallSite[];\n let applyStackToTestErrorCause: boolean;\n let allowStackJS: boolean;\n\n if (error && error[AS_POOL_ERROR_FLAG]) {\n const wrapper = error as AssemblyScriptPoolError;\n testError = wrapper.testError;\n stack = wrapper.originalErrorRawStack;\n applyStackToTestErrorCause = wrapper.applyStackToTestErrorCause;\n allowStackJS = wrapper.originalErrorMayContainJS;\n } else if (error instanceof Error) {\n testError = {\n name: POOL_ERROR_NAMES.PoolError,\n message: `${error.name}: ${error.message}`\n };\n stack = extractCallStack(error);\n allowStackJS = true;\n applyStackToTestErrorCause = false;\n } else {\n testError = {\n name: POOL_ERROR_NAMES.PoolError,\n message: `Unexpected error (${unexpectedContext}): ${String(error)}`\n };\n stack = extractCallStack(new Error());\n allowStackJS = true;\n applyStackToTestErrorCause = false;\n }\n\n await enhanceTestError(\n testError,\n task,\n sourceMap,\n logPrefix,\n allowStackJS,\n projectRoot,\n applyStackToTestErrorCause,\n stack,\n diffOptions\n );\n\n return testError;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,eAAe,MAAsB;AACnD,QAAO,KAAK,QAAQ,OAAO,IAAI;;;;;ACVjC,WAAW,gBAAgB;AAE3B,MAAM,0BAA0B;AAEhC,SAAS,YAAqB;AAC5B,QAAO,WAAW,kBAAkB,QAAQ,QAAQ,IAAI,UAAU;;;;;;AAOpE,SAAgB,mBAAmB,cAA6B;AAC9D,YAAW,gBAAgB;;AAG7B,SAAS,SAAS,GAAG,MAAiB;AAEpC,KAAI,MAAM,SAAS,KAAK,OAAO,KAAK,OAAO,YAAY;EACrD,MAAM,SAAS,KAAK,IAAI;EACxB,MAAM,OAAO,KAAK,SAAS,IAAI,KAAK,MAAM,EAAE,GAAG,EAAE;AACjD,UAAQ,IAAI,KAAK,KAAK,EAAE,OAAO,OAAO,EAAE,GAAG,KAAK;OAEhD,SAAQ,IAAI,KAAK,KAAK,EAAE,GAAG,KAAK;;;;;;AAQpC,SAAgB,MAAM,GAAG,MAAiB;AACxC,KAAI,WAAW,CACb,UAAS,GAAG,KAAK;;;;;AAOrB,SAAgB,cAAc,GAAG,MAAiB;AAChD,UAAS,GAAG,KAAK;;;;;;;;;;;;;;;ACnCnB,MAAM,SAAsB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