vitest-pool-assemblyscript 0.2.2 → 0.2.3

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.
package/README.md CHANGED
@@ -2,305 +2,160 @@
2
2
 
3
3
  AssemblyScript unit testing for your Vitest workflow: Simple, fast, familiar, AS-native.
4
4
 
5
- This is a [Vitest](https://vitest.dev) ["custom pool"](https://vitest.dev/guide/advanced/pool.html) which knows how to compile AssemblyScript to WASM, harness WASM to run tests, and report those results to vitest. It co-exists with existing JavaScript/TypeScript tests, and is designed for incremental adoption.
5
+ This is a [Vitest](https://vitest.dev) [custom pool](https://vitest.dev/guide/advanced/pool.html) which can compile AssemblyScript to WASM, harness WASM to run tests, and report those results to vitest. It co-exists with existing JavaScript/TypeScript tests, and is designed for incremental adoption.
6
6
 
7
- - [Quickstart](#quickstart)
7
+ - [Quick Start](#quick-start)
8
+ - [Compatibility](#compatibility)
8
9
  - [Features](#features)
9
- - [Configuration](#configuration)
10
- - [Writing Tests](#writing-tests)
10
+ - [Configuration Guide](docs/configuration-guide.md)
11
+ - [Providing WASM Imports](docs/providing-wasm-imports.md)
12
+ - [Writing Tests Guide](#writing-tests-guide)
11
13
  - [Matcher API](#matcher-api)
12
14
  - [Project Status & Expectations](#project-status--expectations)
13
- - [Installation Guide (Development Preview)](#installation-guide-development-preview)
15
+ - [License](#license)
14
16
 
15
- **Note: 🚧 This project is currently *Pre-Release, Pre-v1, Under Active Development* 🚧**
16
- - See [Project Status & Expectations](#project-status--expectations) for what's working now, and to see what's planned!
17
+ **Note: 🚧 This project is still early-stage and currently *Under Active Development* 🚧**
18
+ - All features listed in the [Features](#features) section are stable and assumed to be bug-free
19
+ - Native instrumentation prebuilds are available cross-platform
20
+ - Expect matchers are stable (except where noted below), with more coming soon
21
+ - See [Project Status & Expectations](#project-status--expectations) to see what's still planned!
17
22
 
18
- ---
19
-
20
- ## Quickstart
21
-
22
- Coming Soon!
23
+ Please [report a bug / request a feature](https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new) if you encounter something you'd like to share!
23
24
 
24
25
  ---
25
26
 
26
- ## Features
27
-
28
- ### Vitest Integration
29
- - Use familiar `vitest` commands, CLI spec and test filtering, watch mode
30
- - Works with Vitest UI, reporters, and coverage tools
31
- - Project (workspace) config allows coexisting AssemblyScript pools and JavaScript pools
32
- - Hybrid Coverage Provider unifies test reports from multiple pools (delegating to v8 for JS/TS coverage)
33
- - Coverage reporting using any vitest reporter (`html`, `lcov`, `json`, etc)
34
- - Dual vitest 3.x / 4.x support
35
-
36
- ### Per-Test WASM Isolation
37
- - Each AssemblyScript test file is compiled to a WASM binary once
38
- - Each test case runs in a fresh WASM instance (reusing the compiled binary)
39
- - One crashing test doesn't kill the rest within the same suite
40
- - `toThrowError()` matcher can be used to catch and expect specific errors (which trap and abort)
41
-
42
- ### Familiar Developer Experience
43
- - Suite and test definition using `describe()` and `test()` in AssemblyScript
44
- - Inline test option configuration for common vitest options: `timeout`, `retry`, `skip`, `only`, `fails`
45
- - Assertion matching API based on vitest/jest `expect()` API. See [Matcher API](#matcher-api) for the set of supported matchers and differences from JavaScript
46
- - Highlighted diffs for assertion and runtime failures, which point to source code
47
- - Source-mapped WASM error stack traces (accurate source `function file:line:column`)
48
- - AssemblyScript console output captured and provided to vitest for display
49
- - No boilerplate patterns for: `run()`, `endTest()`, `fs.readFile`, `WebAssembly.Instance`, etc
50
-
51
- ### Performance & Customization
52
- - Parallel execution thread pool
53
- - Lightweight coverage instrumentation using separate memory
54
- - In-memory binaries and source maps for minimal file I/O
55
- - Coverage for inlined (`@inline`) code
56
- - Enforced hard timeouts for long-running WASM via thread termination, with intelligent resume
57
- - Configurable AssemblyScript compiler options
58
- - Configurable test memory size
59
- - Configurable WASM imports with access to memory
60
-
61
- ### Why This Over [Alternative]?
27
+ ## Quick Start
62
28
 
63
- There are other standalone testing frameworks for AssemblyScript testing, including:
64
- - [assemblyscript-unittest-framework](https://github.com/wasm-ecosystem/assemblyscript-unittest-framework): A full-featured AS test framework
65
- - Many thanks owed to this project for inspiring parts of our discovery and instrumentation approach
66
- - [as-test](https://github.com/JairusSW/as-test): A minimal and fast AssemblyScript test framework and runner
67
- - [Built with AssemblyScript - Testing & Benchmarking](https://www.assemblyscript.org/built-with-assemblyscript.html#testing-benchmarking) may track more
29
+ ### 1. Install
68
30
 
69
- ---
31
+ ```bash
32
+ npm install -D vitest vitest-pool-assemblyscript assemblyscript
33
+ ```
70
34
 
71
- ## Configuration
35
+ ### 2. Configure Vitest
72
36
 
73
- In your project's `vitest.config.ts`:
74
- - The `test` project configuration helpers needed depend on which version of vitest you're using.
75
- - The `coverage` configuration is the same across versions (shown in the first example below).
37
+ Create or update `vitest.config.ts`. See the [Configuration Guide](docs/configuration-guide.md) for all supported vitest options, pool options, coverage configuration, and multi-project setups.
76
38
 
77
- ### vitest 4.x.x Multiple-Project Config:
39
+ **vitest 4.x:**
78
40
  ```typescript
79
- import { defineConfig, defineProject } from 'vitest/config';
41
+ import { defineConfig } from 'vitest/config';
80
42
  import { createAssemblyScriptPool } from 'vitest-pool-assemblyscript/config';
81
43
 
82
44
  export default defineConfig({
83
45
  test: {
84
- projects: [
85
- // AssemblyScript project
86
- defineProject({
87
- test: {
88
- name: {
89
- label: 'assemblyscript-tests',
90
- color: 'yellow'
91
- },
92
- include: ['test/assembly/**/*.as.{test,spec}.ts'],
93
-
94
- // supported vitest options
95
- bail: 2, // stop test run after this many failures
96
- retry: 0, // number of retries to attempt after initial failure
97
- testTimeout: 500, // ms to wait before terminating test
98
- // allowOnly: true, // whether or not to respect test.only and describe.only
99
- // maxWorkers: 8, // concurrent file execution threads (default: available parallelism)
100
-
101
- // configure vitest to use this custom pool for test files in `include`
102
- pool: createAssemblyScriptPool({
103
- stripInline: true, // true to remove @inline decorators for coverage (default: true)
104
- testMemoryPagesInitial: 2, // initial WASM memory size in pages (default: 1)
105
- testMemoryPagesMax: 4, // maximum WASM memory size in pages (default: undefined)
106
- extraCompilerFlags: ['--runtime', 'incremental'], // additional asc flags to customize AS compilation
107
- wasmImportsFactory: 'test-helpers/create-imports.js', // factory function to create your own WASM imports
108
- }),
109
- }
110
- }),
111
-
112
- // JavaScript/TypeScript project
113
- defineProject({
114
- test: {
115
- name: {
116
- label: 'javascript-typescript-tests',
117
- color: 'blue'
118
- },
119
- include: ['test/js/*.{test,spec}.{ts,js}'],
120
- }
121
- }),
122
- ]
46
+ include: ['test/assembly/**/*.as.test.ts'],
47
+ pool: createAssemblyScriptPool(),
123
48
  },
124
-
125
- // Coverage config must be at root level (applies to all projects).
126
- // The "hybrid" provider delegates JS to v8, and merges AS coverage into the final report
127
49
  coverage: {
128
50
  provider: 'custom',
129
51
  customProviderModule: 'vitest-pool-assemblyscript/coverage',
130
- assemblyScriptInclude: ['assembly/**/*.ts'], // example, include AS sources to report on
131
- assemblyScriptExclude: ['assembly/helpers/*.ts'], // example, exclude AS sources from reporting
132
-
133
- // all other v8 coverage options will be passed through to delegated v8 provider
52
+ assemblyScriptInclude: ['assembly/**/*.ts'],
134
53
  enabled: true,
135
- cleanOnRerun: true,
136
- reportsDirectory: './coverage',
137
- reporter: ['text', 'lcov', 'html'],
138
- include: ['src/**/*.ts'], // example, include JS/TS sources to report on
139
54
  },
140
55
  });
141
56
  ```
142
57
 
143
- ### vitest 4.x.x Single-Project Config:
58
+ **vitest 3.x:**
144
59
  ```typescript
145
- import { defineConfig } from 'vitest/config';
146
- import { createAssemblyScriptPool } from 'vitest-pool-assemblyscript/config';
60
+ import { defineAssemblyScriptConfig } from 'vitest-pool-assemblyscript/v3/config';
147
61
 
148
- export default defineConfig({
62
+ export default defineAssemblyScriptConfig({
149
63
  test: {
150
- pool: createAssemblyScriptPool({
151
- // no change to available options (stripInline, testMemoryPagesInitial, etc)
152
- }),
64
+ include: ['test/assembly/**/*.as.test.ts'],
65
+ pool: 'vitest-pool-assemblyscript/v3',
153
66
  },
154
- coverage: {
155
- // no change to available options
156
- }
67
+ // coverage configuration mirrors v4
157
68
  });
158
69
  ```
159
70
 
160
- ### vitest 3.2.x Multiple-Project Config:
71
+ ### 3. Write a Test
72
+
73
+ Create a test file (e.g. `test/assembly/example-file.as.test.ts`):
74
+
161
75
  ```typescript
162
- import { defineConfig, defineProject } from 'vitest/config';
163
- import { defineAssemblyScriptProject } from 'vitest-pool-assemblyscript/v3/config';
76
+ import { test, describe, expect } from "vitest-pool-assemblyscript/assembly";
164
77
 
165
- export default defineConfig({
166
- test: {
167
- projects: [
168
- defineProject({
169
- test: {
170
- // JS/TS project config...
171
- }
172
- }),
173
- defineAssemblyScriptProject({
174
- test: {
175
- // AS project config... (standard name/label, include, etc)
176
-
177
- pool: 'vitest-pool-assemblyscript/v3', // in v3, point to the module
178
- poolOptions: {
179
- assemblyScript: {
180
- // same available options as v4 createAssemblyScriptPool are passed here
181
-
182
- // Additonal - v3 Only
183
- // maxThreadsV3: 8 // concurrent test file threads to execute (default: availableParallelism - 1)
184
- }
185
- }
186
- }
187
- })
188
- ]
189
- },
190
-
78
+ test("basic math", () => {
79
+ expect(2 + 2).toBe(4);
80
+ });
81
+
82
+ describe("an example suite", () => {
83
+ test("string equality", () => {
84
+ expect("hello").toBe("hello");
85
+ expect("hello").not.toBe("world");
86
+ });
191
87
  });
192
88
  ```
193
89
 
194
- ### vitest 3.2.x Single-Project Config:
195
- ```typescript
196
- import { defineAssemblyScriptConfig } from 'vitest-pool-assemblyscript/v3/config';
90
+ ### 4. Run
197
91
 
198
- export default defineAssemblyScriptConfig({
199
- test: {
200
- pool: 'vitest-pool-assemblyscript/v3',
201
- poolOptions: {
202
- assemblyScript: {
203
- // same available options as v4 createAssemblyScriptPool and v3 multi-project
204
- }
205
- }
206
- },
207
- });
92
+ ```bash
93
+ npx vitest run
208
94
  ```
209
95
 
210
- ### Framework-Provided Imports
96
+ ---
211
97
 
212
- **`console`**
213
- The pool provides the full implementation of the [AssemblyScript `console` interface](https://www.assemblyscript.org/stdlib/console.html). This means you can transparently use `console.log("some string")` in your tests, and the output will be fed to vitest and displayed with the test results.
98
+ ## Compatibility
214
99
 
215
- If you prefer to do something else with your test console output, you may provide your own versions of these functions to the "env" module - See the next section for details on how to do this.
100
+ | Dependency | Supported Versions |
101
+ |---|---|
102
+ | Node.js | 20, 22, 24+ |
103
+ | Vitest | 3.2.x, 4.x |
104
+ | AssemblyScript | 0.28+ |
216
105
 
217
- **`trace`**
218
- The pool also provides an implementation for `trace`, which passes through to Node `console.trace()` immediately for debugging.
106
+ **Platforms with prebuilt native binaries:**
219
107
 
220
- **`abort`**
221
- The pool handles assertion errors, runtime errors, and expected throws by providing an abort handler. This cannot be user-overridden.
108
+ | | x64 | arm64 |
109
+ |---|---|---|
110
+ | Linux (glibc) | ✓ | ✓ |
111
+ | Linux (musl/Alpine) | ✓ | |
112
+ | macOS | ✓ | ✓ |
113
+ | Windows | ✓ | ✓ |
222
114
 
115
+ ---
223
116
 
224
- ### User-Provided Imports with `WasmImportsFactory`
225
- To provide your own WebAssembly imports, configure `wasmImportsFactory` to point to an ES module which exports a factory function to create your imports:
226
- ```typescript
227
- // v4
228
- // ...
229
- pool: createAssemblyScriptPool({
230
- wasmImportsFactory: 'test-helpers/create-imports.js',
231
- })
232
- // ...
233
-
234
- // v3
235
- // ...
236
- poolOptions: {
237
- assemblyScript: {
238
- wasmImportsFactory: 'test-helpers/create-imports.js',
239
- }
240
- }
241
- // ...
242
- ```
117
+ ## Features
243
118
 
244
- The type signature for this function looks like this:
245
- ```typescript
246
- type WasmImportsFactory = (moduleInfo: WasmImportsFactoryInfo) => WebAssembly.Imports;
247
- ```
119
+ ### Vitest Integration
120
+ - Use familiar `vitest` commands, CLI spec and test filtering, watch mode
121
+ - Works with Vitest UI, reporters, and coverage tools
122
+ - Project (workspace) config allows coexisting AssemblyScript pools and JavaScript pools
123
+ - Hybrid Coverage Provider unifies test reports from multiple pools (delegating to v8 for JS/TS coverage)
124
+ - Coverage reporting using any vitest reporter (`html`, `lcov`, `json`, etc)
125
+ - Dual vitest 3.x / 4.x support
248
126
 
249
- And the `moduleInfo` argument that it is provided with looks like this:
250
- ```typescript
251
- interface WasmImportsFactoryInfo {
252
- module: WebAssembly.Module;
253
- memory: WebAssembly.Memory;
254
- utils: {
255
- // convenience function for extracting returned strings from WASM memory
256
- liftString: (stringPtr: number) => string | undefined;
257
- }
258
- }
259
- ```
127
+ ### Per-Test WASM Isolation
128
+ - Each AssemblyScript test file is compiled to a WASM binary once
129
+ - Each test case runs in a fresh WASM instance (reusing the compiled binary)
130
+ - One crashing test doesn't kill the rest within the same suite
131
+ - `toThrowError()` matcher can be used to catch and expect specific errors (which trap and abort)
260
132
 
261
- You may provide imports for any module name you wish. Here is an example factory function which uses the "env" module:
262
- ```js
263
- export default function createWasmImports({ memory, module, utils }) {
264
- return {
265
- env: {
266
- parseIntStringFunction: (inputStrPtr) => {
267
- return parseInt(utils.liftString(inputStrPtr));
268
- }
269
- }
270
- };
271
- }
272
- ```
133
+ ### Familiar Developer Experience
134
+ - Suite and test definition using `describe()` and `test()` in AssemblyScript
135
+ - Inline test option configuration for common vitest options: `timeout`, `retry`, `skip`, `only`, `fails`
136
+ - Assertion matching API based on vitest/jest `expect()` API. See [Matcher API](#matcher-api) for the set of supported matchers and differences from JavaScript
137
+ - Highlighted diffs for assertion and runtime failures, which point to source code
138
+ - Source-mapped WASM error stack traces (accurate source `function file:line:column`)
139
+ - AssemblyScript console output captured and provided to vitest for display
140
+ - No boilerplate patterns for: `run()`, `endTest()`, `fs.readFile`, `WebAssembly.Instance`, etc
273
141
 
274
- Example AssemblyScript source code which uses this imported function (the "env" module name is specified):
275
- ```typescript
276
- @external("env", "parseIntStringFunction")
277
- declare function parseIntStringFunction(input: string): i32;
142
+ ### Performance & Customization
143
+ - Parallel execution thread pool
144
+ - Lightweight coverage instrumentation using separate memory
145
+ - In-memory binaries and source maps for minimal file I/O
146
+ - Coverage for inlined (`@inline`) code
147
+ - Enforced hard timeouts for long-running WASM via thread termination, with intelligent resume
148
+ - Configurable AssemblyScript compiler options
149
+ - Configurable test memory size
150
+ - Configurable WASM imports with access to memory
278
151
 
279
- export function runParseIntStringFunction(input: string): i32 {
280
- return parseIntStringFunction(input);
281
- }
282
- ```
152
+ ---
283
153
 
284
- #### Module Names
285
- If you omit the module name in `@external` (e.g. `@external("parseIntStringFunction")`) or omit `@external` entirely, AssemblyScript uses the source file's own name (without the last file extension) as the module name, making it impractical to provide matching imports to every source file independently if you use imported functions across multiple places in your source. It is recommended to always specify a shared module name (such as "env") for this reason.
286
-
287
- Conversely, if you need to provide imports targeted to a specific source file, this behavior provides a way to do that as well. For example, if you have a source AS file called `my-file.as.ts` with `declare function myFunc(input: string): i32;` in it and omit the `@external` decorator, then you can import the function *only to this file* with:
288
- ```js
289
- export default function createWasmImports({ utils }) {
290
- return {
291
- // default source file module name (omits the .ts extension)
292
- 'my-file.as': {
293
- myFunc: (inputStrPtr) => {
294
- return parseInt(utils.liftString(inputStrPtr));
295
- }
296
- }
297
- };
298
- }
299
- ```
154
+ See also: **[Configuration Guide](docs/configuration-guide.md)** | **[Providing WASM Imports](docs/providing-wasm-imports.md)**
300
155
 
301
156
  ---
302
157
 
303
- ## Writing Tests
158
+ ## Writing Tests Guide
304
159
 
305
160
  Import `test`, `describe`, `expect` (and `TestOptions` if needed) from `vitest-pool-assemblyscript/assembly`.
306
161
 
@@ -372,6 +227,10 @@ test.fails("expected failure with retry", TestOptions.retry(3), () => {
372
227
  });
373
228
  ```
374
229
 
230
+ ### Lifecycle Hooks (Setup & Teardown)
231
+
232
+ Coming Soon!
233
+
375
234
  ---
376
235
 
377
236
  ## Matcher API
@@ -503,13 +362,12 @@ expect(() => { throw new Error("boom"); }).toThrowError("boom");
503
362
 
504
363
  ## Project Status & Expectations
505
364
 
506
- **This is a pre-v1 project** being developed in the open by an interested individual. Most core functionality is working, with a long list of planned features and polish to be added as time allows.
507
-
508
- *(Note: Not yet published to npm - currently development only)*
365
+ **This is an early-stage project** being developed in the open by an interested individual with a career of experience shipping production code.
366
+ - All features listed in the [Features](#features) section are stable and assumed to be bug-free
367
+ - Native instrumentation prebuilds are available cross-platform
368
+ - Expect matchers are stable (except where noted above), with more coming soon
509
369
 
510
- ### Current State
511
-
512
- All features listed in the [Features](#features) section are working and assumed to be bug-free. Please [report a bug](https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new) if you encounter one.
370
+ Please [report a bug / request a feature](https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new) if you encounter something you'd like to share!
513
371
 
514
372
  **⚠️ Known Limitations - Coming Soon:**
515
373
  - **Function-level coverage only**: No statement, branch, or line coverage yet
@@ -540,82 +398,24 @@ All features listed in the [Features](#features) section are working and assumed
540
398
  - TBD
541
399
 
542
400
  **✖️ Out of Scope (Currently):**
543
- - Compiler integration with other compile-to-WASM languages (Rust, C++)
544
- - I would LOVE to expand this project to a more generic wasm pool, supporting pluggable compilers and ast parsing for different WASM ecosystems and toolchains
545
- - Not in scope now because of time and effort. If you want to pay me to work on this [get in touch](https://github.com/themattspiral)!
546
401
  - Generic JS-harness testing of any precompiled WASM binary
402
+ - Compiler & matcher integration with other compile-to-WASM languages (e.g. Rust and C++ with Emscripten)
403
+ - I would LOVE to expand this project to cover additional cases, supporting pluggable compilers, ast parsing, and matchers for different WASM ecosystems and toolchains
404
+ - Not in scope now because of time and effort
405
+ - If you want to pay me to work on this, please [get in touch](https://github.com/themattspiral)!
547
406
 
548
407
  ---
549
408
 
550
- ## Installation Guide (Development Preview)
551
-
552
- **⚠️ Important:** This project is under active development. Features and APIs may change without notice. No guarantees are made about stability or functionality.
409
+ ## Prior Work
553
410
 
554
- **Feedback Welcome:** If you try this out, please open an issue on GitHub with your experience, bugs, or suggestions!
411
+ There are other (standalone) testing frameworks for AssemblyScript testing which have inspired this project. In particular, many thanks are owed to [assemblyscript-unittest-framework](https://github.com/wasm-ecosystem/assemblyscript-unittest-framework) for inspiring parts of our test discovery and instrumentation walking approaches.
555
412
 
556
- ### Prerequisites
557
- - Node.js 20.0.0+ (required due to our multi-memory coverage approach)
558
- - Vitest 3.2.0+ or 4.0.0+
559
- - AssemblyScript 0.28+
560
- - C++ build tools (dev only - distributed package will include prebuilds):
561
- - GCC 7+ or Clang 5+ (C++17 support required)
562
- - Python 3.x (required by node-gyp)
563
-
564
- ### Setup
565
-
566
- 1. **Clone the repository:**
567
- ```bash
568
- git clone https://github.com/themattspiral/vitest-pool-assemblyscript.git
569
- cd vitest-pool-assemblyscript
570
- ```
571
-
572
- 2. **Install Binaryen C++ dependencies, then npm deps**
573
- ```bash
574
- npm run setup-binaryen
575
- npm install
576
- ```
577
- The `setup-binaryen` script downloads prebuilt Binaryen libraries and C++ headers to `third_party/binaryen/`. These are used to build the native addon that extracts debug info from WASM binaries.
578
-
579
- 3. **Build Native Addon**
580
- ```bash
581
- npm run build:native
582
- ```
583
-
584
- 4. **Build Pool**
585
- ```bash
586
- npm run build
587
- ```
588
-
589
- 5. **Link the pool to your project:**
590
- ```bash
591
- # In vitest-pool-assemblyscript:
592
- npm link
593
-
594
- # In your project directory:
595
- npm link vitest-pool-assemblyscript
596
- ```
597
-
598
- 6. **Configure Vitest**
599
-
600
- See the [Configuration](#configuration) section.
601
-
602
- 7. **Write your tests**
603
- See the [Writing Tests](#writing-tests) section.
604
-
605
- 8. **Run your tests:**
606
- ```bash
607
- # Run all tests once
608
- npx vitest run
609
-
610
- # Run specific test file
611
- npx vitest run example.as.test.ts
612
-
613
- # Run specific test in specific file
614
- npx vitest run example.as.test.ts -t "my test name"
615
- ```
413
+ See [Built with AssemblyScript - Testing & Benchmarking](https://www.assemblyscript.org/built-with-assemblyscript.html#testing-benchmarking) for other related work.
616
414
 
617
415
  ---
618
416
 
619
417
  ## License
620
418
 
621
419
  [MIT](LICENSE)
420
+ - Portions of this software have been derived from third-party works which are licenced under different terms. Individual code contributions have been noted where applicable and are accompanied by their respective licenses.
421
+ - See the license file and source code for details
@@ -3,6 +3,6 @@ import "../debug-IeEHsxy0.mjs";
3
3
  import "../vitest-file-tasks-BUwzh375.mjs";
4
4
  import "../vitest-tasks-BKS7689f.mjs";
5
5
  import "../worker-rpc-channel-lbhK7Qz8.mjs";
6
- import { createAssemblyScriptPool } from "../pool-runner-init-d5qScS41.mjs";
6
+ import { createAssemblyScriptPool } from "../pool-runner-init-Kuzz61rB.mjs";
7
7
 
8
8
  export { createAssemblyScriptPool };
@@ -6,7 +6,7 @@ import { ASTVisitor } from "../ast-visitor-DC3SuTzs.mjs";
6
6
  import { basename, parse, relative } from "node:path";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import v8CoverageModule from "@vitest/coverage-v8";
9
- import { createCoverageMap } from "istanbul-lib-coverage";
9
+ import istanbulCoverage from "istanbul-lib-coverage";
10
10
  import { Parser } from "assemblyscript";
11
11
  import { resolve as resolve$1 } from "path";
12
12
  import TestExclude from "test-exclude";
@@ -355,6 +355,7 @@ function globFiles(include, exclude, projectRoot) {
355
355
  * - Delegates JS coverage to Vitest's v8 provider
356
356
  * - Merges both into a unified coverage report
357
357
  */
358
+ const { createCoverageMap } = istanbulCoverage;
358
359
  var HybridCoverageProvider = class {
359
360
  name = "hybrid-assemblyscript-v8";
360
361
  v8Provider;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["parsePath","AssemblyScriptParser","resolve"],"sources":["../../src/coverage-provider/containment-matcher.ts","../../src/coverage-provider/istanbul-converter.ts","../../src/coverage-provider/ast-parser.ts","../../src/coverage-provider/glob-utils.ts","../../src/coverage-provider/hybrid-coverage-provider.ts","../../src/coverage-provider/index.ts"],"sourcesContent":["/**\n * Containment Matcher\n *\n * Provides containment-based matching for coverage mapping.\n * Binary debug info provides points (representativeLocation), source parsing provides ranges.\n * We find which source range contains each binary point.\n *\n * Usage by version:\n * - v1: Function containment matching (binary representativeLocation → source function range)\n * - v2: Function containment (same) + statement containment + branch path containment\n *\n * Why containment matching (not direct position lookup):\n * AS compiler generates source map entries differently by statement type:\n * - Variable declarations: source map points to statement start (keyword)\n * - Control flow (if/switch/for): source map points to condition EXPRESSION, not keyword\n *\n * Example: `if (n < 0)` → binary reports column 7 ('n'), not column 3 ('i' of 'if')\n *\n * Containment matching is more robust:\n * - Binary gives us a position (representativeLocation) somewhere in the function\n * - Source gives us function ranges (start/end line/column)\n * - We find which source function range contains the binary position\n * - Handles nested functions with \"tightest fit\" (innermost function wins)\n */\n\nimport type { ParsedSourceFunctionInfo, SourceRange } from '../types/types.js';\n\n/**\n * Functions indexed by file path, then by start line.\n * Multiple functions can start on the same line (e.g., nested arrow functions).\n */\nexport type FunctionsByFileAndStartLine = Record<string, Record<number, ParsedSourceFunctionInfo[]>>;\n\n/**\n * Find the source function whose range contains the given position.\n *\n * For nested functions, uses \"tightest fit\" - returns the innermost function\n * (the one with the largest start position among all containing functions).\n *\n * @param functionsByStartLine - Functions for a single file, indexed by start line\n * @param line - Target line number (1-based)\n * @param column - Target column number (1-based)\n * @returns The containing function, or undefined if no match\n */\nexport function findFunctionContainingPosition(\n functionsByStartLine: Record<number, ParsedSourceFunctionInfo[]>,\n line: number,\n column: number\n): ParsedSourceFunctionInfo | undefined {\n let bestMatch: ParsedSourceFunctionInfo | undefined;\n let bestStartLine = -1;\n let bestStartColumn = -1;\n\n // Check functions starting on lines <= target line\n for (const [startLineStr, functions] of Object.entries(functionsByStartLine)) {\n const startLine = Number(startLineStr);\n if (startLine > line) continue;\n\n for (const func of functions) {\n const { range } = func;\n\n // Check if position is within this function's range\n if (!isPositionInRange(line, column, range)) continue;\n\n // Tightest fit: prefer function with largest start position (innermost)\n if (startLine > bestStartLine ||\n (startLine === bestStartLine && range.startColumn > bestStartColumn)) {\n bestMatch = func;\n bestStartLine = startLine;\n bestStartColumn = range.startColumn;\n }\n }\n }\n\n return bestMatch;\n}\n\n/**\n * Check if a position (line, column) falls within a source range.\n *\n * @param line - Target line number (1-based)\n * @param column - Target column number (1-based)\n * @param range - Source range to check against\n * @returns true if position is within range (inclusive)\n */\nexport function isPositionInRange(\n line: number,\n column: number,\n range: SourceRange\n): boolean {\n // Outside line range entirely\n if (line < range.startLine || line > range.endLine) return false;\n\n // On start line but before start column\n if (line === range.startLine && column < range.startColumn) return false;\n\n // On end line but after end column\n if (line === range.endLine && column > range.endColumn) return false;\n\n return true;\n}\n","/**\n * Istanbul Format Converter\n *\n * Converts AssemblyScript coverage data to Istanbul's FileCoverageData format.\n * This enables integration with Vitest's coverage reporting system and standard\n * coverage tools like Codecov, Coveralls, etc.\n *\n * Current Implementation: Function-level coverage only\n * - Uses containment matching: binary positions → source function ranges\n * - Each function maps to both a function entry AND a statement entry\n * - Statement coverage matches function coverage (function-level granularity)\n * - Branch coverage is 0% (no branches tracked yet)\n * - Line coverage derived from statement coverage\n *\n * Future Enhancement (v2): Block-level statement and branch coverage\n */\n\nimport type { FileCoverageData, Range, FunctionMapping, BranchMapping } from 'istanbul-lib-coverage';\nimport type { ParsedSourceFunctionInfo } from '../types/types.js';\nimport { findFunctionContainingPosition } from './containment-matcher.js';\nimport { debug } from '../util/debug.js';\n\nconst DEBUG_ISTANBUL = false;\n\nfunction istanbulDebug(...args: any[]): void {\n if (DEBUG_ISTANBUL) {\n debug(...args);\n }\n};\n\n/**\n * Convert AssemblyScript coverage data to Istanbul format for a single file\n *\n * Algorithm (containment matching):\n * 1. For each hit position in fileHitCountsByPosition:\n * - Use containment matcher to find which source function contains this position\n * - Record the hit count for that function\n * 2. For each function in fileFunctionsByStartLine:\n * - Add function mapping to fnMap\n * - Add function hit count to f (from matched hits, or 0 if not hit)\n * - Add corresponding statement mapping to statementMap\n * - Add same hit count to s (statement coverage matches function coverage)\n *\n * @param fileFunctionsByStartLine - Functions for this file, keyed by start line (from AST parser)\n * @param fileHitCountsByPosition - Hit counts for this file, keyed by position \"line:column\" (from accumulated coverage)\n * @param absoluteFilePath - Absolute path to the source file (for Istanbul output)\n * @returns Istanbul FileCoverage object\n */\nexport async function convertToIstanbulFormat(\n fileFunctionsByStartLine: Record<number, ParsedSourceFunctionInfo[]>,\n fileHitCountsByPosition: Record<string, number>,\n absoluteFilePath: string\n): Promise<FileCoverageData> {\n const startMatch = performance.now();\n\n istanbulDebug(() => {\n const sourceFunctionCount = Object.values(fileFunctionsByStartLine).reduce((sum, funcs) => sum + funcs.length, 0);\n const uniqueHitPosCount = Object.keys(fileHitCountsByPosition).length;\n const coverageEstimate = sourceFunctionCount === 0 ? Infinity : ((uniqueHitPosCount * 100) / sourceFunctionCount).toFixed(2);\n\n return `[IstanbulConverter] Processing source file: \"${absoluteFilePath}\"\\n`\n + `[IstanbulConverter] Source: ${sourceFunctionCount} total functions, Coverage: ${uniqueHitPosCount} unique hit positions\\n`\n + `[IstanbulConverter] Sanity Check - AS File Coverage Estimate: ${coverageEstimate}%\\n`\n + `[IstanbulConverter] Containment matching functions: coverage hit positions to source functions by range`;\n });\n\n // Build a map of function → hit count using containment matching\n // Key: function source identity (qualifiedName), Value: hit count\n const hitCountsBySourceFunctionName = new Map<ParsedSourceFunctionInfo, number>();\n\n // For each hit position, find which function contains it\n for (const [positionKey, hitCount] of Object.entries(fileHitCountsByPosition)) {\n // Position key format is \"line:column\"\n const parts = positionKey.split(':');\n const lineStr = parts[0];\n const columnStr = parts[1];\n\n if (lineStr && columnStr) {\n const line = parseInt(lineStr, 10);\n const column = parseInt(columnStr, 10);\n\n const containingFunction = findFunctionContainingPosition(fileFunctionsByStartLine, line, column);\n if (containingFunction) {\n // Accumulate hits (in case multiple positions map to same function)\n const existingHits = hitCountsBySourceFunctionName.get(containingFunction);\n const existingHitsCount = existingHits ?? 0;\n const max = Math.max(existingHitsCount, hitCount);\n hitCountsBySourceFunctionName.set(containingFunction, max); // <-- TODO: Explain this max logic\n\n if (existingHits !== undefined) {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} → function \"${containingFunction.shortName}\" EXISTING HITS: ${existingHits} NEW COUNT: ${max}`);\n } else {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} → function \"${containingFunction.shortName}\" (hits: ${hitCount})`);\n }\n } else {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} has no containing function`);\n }\n }\n }\n\n const startConvert = performance.now();\n istanbulDebug(`[IstanbulConverter] Matching Complete - Converting to Istanbul format`);\n\n // Initialize Istanbul data structures\n const fnMap: { [key: string]: FunctionMapping } = {};\n const f: { [key: string]: number } = {};\n const statementMap: { [key: string]: Range } = {};\n const s: { [key: string]: number } = {};\n const branchMap: { [key: string]: BranchMapping } = {};\n const b: { [key: string]: number[] } = {};\n\n // Convert function coverage to Istanbul format\n // Iterate all functions from parsed source (ensures 0-hit functions are included)\n let funcIdx = 0;\n for (const functions of Object.values(fileFunctionsByStartLine)) {\n for (const funcInfo of functions) {\n const { range, shortName } = funcInfo;\n\n // Defensive: skip functions with invalid metadata (shouldn't happen - AST parser filters these)\n if (range.startLine === 0) {\n continue;\n }\n\n // Get hit count from containment matching (or 0 if not hit)\n const hitCount = hitCountsBySourceFunctionName.get(funcInfo) ?? 0;\n const displayShortName = shortName && shortName !== '' ? shortName : '<anonymous>';\n istanbulDebug(\n `[IstanbulConverter] Istanbul function index ${funcIdx}: \"${displayShortName}\"`\n + ` (source ${range.startLine}:${range.startColumn} - ${range.endLine}:${range.endColumn}), hits: ${hitCount}`\n );\n\n // Create function mapping\n // Both 'decl' (declaration) and 'loc' (location) use the same range\n // Internal ParsedSourceFunctionInfo uses 1-based columns, Istanbul expects 0-based\n const istanbulRange: Range = {\n start: { line: range.startLine, column: range.startColumn - 1 },\n end: { line: range.endLine, column: range.endColumn - 1 }\n };\n\n const idxStr = funcIdx.toString();\n fnMap[idxStr] = {\n name: shortName,\n decl: istanbulRange,\n loc: istanbulRange,\n line: range.startLine\n };\n f[idxStr] = hitCount;\n\n // Create corresponding statement mapping\n // For function-level coverage, each function is one \"statement\"\n // The statement range matches the function range\n // This gives us statement coverage at function granularity\n statementMap[idxStr] = istanbulRange;\n s[idxStr] = hitCount;\n\n funcIdx++;\n }\n }\n\n const done = performance.now();\n const matchingMs = (startConvert - startMatch).toFixed(2);\n const convertMs = (done - startConvert).toFixed(2);\n const totalMs = (done - startMatch).toFixed(2);\n\n istanbulDebug(\n `[IstanbulConverter] Coverage Coversion Complete: ${Object.keys(fnMap).length} functions,` \n + ` ${totalMs} ms total (matching: ${matchingMs} ms, convert: ${convertMs} ms)`\n );\n\n return {\n path: absoluteFilePath,\n fnMap,\n f,\n statementMap,\n s,\n branchMap,\n b\n };\n}\n","/**\n * AST Parser for AssemblyScript Source Files\n *\n * Parses AS source files to extract function metadata for coverage.\n * Used by generateCoverage to build empty coverage map from all source files.\n *\n * Source AST is the source of truth for what SHOULD be covered.\n * Binary instrumentation tells us what we CAN measure (hit counts).\n *\n * Functions are grouped by start line for efficient containment matching.\n *\n * Architecture:\n * - Uses shared ASTVisitor for complete NodeKind coverage\n * - Overrides hooks to extract function information during traversal\n */\n\nimport { readFile } from 'node:fs/promises';\nimport { parse as parsePath } from 'node:path';\nimport {\n Parser as AssemblyScriptParser,\n Source,\n BlockStatement,\n Node,\n FunctionDeclaration,\n MethodDeclaration,\n ClassDeclaration,\n VariableDeclaration,\n FunctionExpression,\n} from 'assemblyscript';\n\nimport type { ParsedSourceFunctionInfo, SourceRange } from '../types/types.js';\nimport { ASCommonFlags, ASNodeKind } from '../types/constants.js';\nimport { ASTVisitor } from '../util/ast-visitor.js';\n\n/**\n * Visitor that extracts function information from AST nodes\n */\nclass FunctionExtractorVisitor extends ASTVisitor {\n /** Source file being parsed */\n private source: Source;\n /** Module path for building qualified names */\n private modulePath: string;\n /** Absolute file path */\n private filePath: string;\n /** Accumulated function records, keyed by start line */\n readonly functions: Record<number, ParsedSourceFunctionInfo[]> = {};\n /** Current class name (when inside a class) */\n private currentClassName: string | null = null;\n\n constructor(source: Source, modulePath: string, filePath: string) {\n super();\n this.source = source;\n this.modulePath = modulePath;\n this.filePath = filePath;\n }\n\n /**\n * Track class context when entering a class\n */\n protected onClassEnter(node: ClassDeclaration): void {\n this.currentClassName = node.name?.text ?? 'Anonymous';\n }\n\n /**\n * Restore class context when exiting a class\n */\n protected onClassExit(_node: ClassDeclaration): void {\n this.currentClassName = null;\n }\n\n /**\n * Extract function info from function declarations\n */\n protected onFunctionDeclaration(node: FunctionDeclaration): boolean {\n if (node.body && this.hasBodyStatements(node.body)) {\n const shortName = node.name?.text ?? '~anonymous';\n const qualifiedName = `${this.modulePath}/${shortName}`;\n const range = this.buildRange(node, node.name ?? null);\n this.addFunction(qualifiedName, shortName, range);\n }\n return true; // Continue recursion into body\n }\n\n /**\n * Extract function info from method declarations\n */\n protected onMethodDeclaration(node: MethodDeclaration): boolean {\n if (node.body && this.hasBodyStatements(node.body)) {\n const methodName = node.name?.text ?? 'constructor';\n const className = this.currentClassName ?? 'Unknown';\n const flags = node.flags;\n\n // Determine method type from flags\n const isStatic = (flags & ASCommonFlags.Static) !== 0;\n const isGetter = (flags & ASCommonFlags.Get) !== 0;\n const isSetter = (flags & ASCommonFlags.Set) !== 0;\n\n // Build short name to match binary naming convention:\n // - Static: ClassName.methodName\n // - Getter: ClassName#get:propertyName\n // - Setter: ClassName#set:propertyName\n // - Instance: ClassName#methodName\n let shortName: string;\n if (isStatic) {\n shortName = `${className}.${methodName}`;\n } else if (isGetter) {\n shortName = `${className}#get:${methodName}`;\n } else if (isSetter) {\n shortName = `${className}#set:${methodName}`;\n } else {\n shortName = `${className}#${methodName}`;\n }\n\n const qualifiedName = `${this.modulePath}/${shortName}`;\n const range = this.buildRange(node, node.name ?? null);\n this.addFunction(qualifiedName, shortName, range);\n }\n return true; // Continue recursion into body\n }\n\n /**\n * Extract function info from variable declarations (arrow functions)\n */\n protected onVariableDeclaration(node: VariableDeclaration): boolean {\n if (node.initializer && node.initializer.kind === ASNodeKind.Function) {\n const funcExpr = node.initializer as FunctionExpression;\n const funcDecl = funcExpr.declaration;\n\n if (funcDecl.body && this.hasBodyStatements(funcDecl.body)) {\n // Use variable name for the function\n const shortName = node.name.text;\n const qualifiedName = `${this.modulePath}/${shortName}`;\n\n // Use the variable declaration's range\n const range: SourceRange = {\n filePath: this.filePath,\n startLine: this.source.lineAt(node.range.start),\n startColumn: this.source.columnAt(),\n endLine: this.source.lineAt(node.range.end),\n endColumn: this.source.columnAt(),\n };\n\n this.addFunction(qualifiedName, shortName, range);\n }\n\n // Visit the function body manually since we're handling this specially\n if (funcDecl.body) {\n this.visitNode(funcDecl.body);\n }\n return false; // Don't recurse again - we handled it\n }\n return true; // Continue recursion for non-function initializers\n }\n\n /**\n * Check if a function body has statements (non-empty body)\n */\n private hasBodyStatements(body: Node): boolean {\n if (body.kind === ASNodeKind.Block) {\n const blockBody = body as BlockStatement;\n return blockBody.statements.length > 0;\n }\n // Expression body (braceless arrow) - always has the expression\n return true;\n }\n\n /**\n * Add a function to the functions record, keyed by start line\n */\n private addFunction(qualifiedName: string, shortName: string, range: SourceRange): void {\n const startLine = range.startLine;\n if (!this.functions[startLine]) {\n this.functions[startLine] = [];\n }\n this.functions[startLine].push({ qualifiedName, shortName, range });\n }\n\n /**\n * Build a SourceRange for a node, using name.range.start to skip decorators\n */\n private buildRange(node: Node, nameNode: Node | null): SourceRange {\n const startNode = nameNode ?? node;\n return {\n filePath: this.filePath,\n startLine: this.source.lineAt(startNode.range.start),\n startColumn: this.source.columnAt(),\n endLine: this.source.lineAt(node.range.end),\n endColumn: this.source.columnAt(),\n };\n }\n}\n\n/**\n * Parse functions from a single AS source file\n *\n * @param absoluteSourceFilePath - Absolute path to AS source file\n * @param relativeSourceFilePath - Relative path to AS source file (derived once in caller and used several places)\n * @returns Record of start line to array of ParsedSourceFunctionInfo (multiple functions can start on same line)\n */\nexport async function parseFunctionsFromFile(\n absoluteSourceFilePath: string,\n relativeSourceFilePath: string,\n): Promise<Record<number, ParsedSourceFunctionInfo[]>> {\n const sourceCode = await readFile(absoluteSourceFilePath, 'utf8');\n\n // Build the module path (strip any extension, use forward slashes)\n const parsed = parsePath(relativeSourceFilePath);\n const modulePath = parsed.dir ? `${parsed.dir}/${parsed.name}` : parsed.name;\n\n // Parse with AssemblyScript parser\n const asParser = new AssemblyScriptParser();\n asParser.parseFile(sourceCode, relativeSourceFilePath, true);\n\n const source = asParser.currentSource;\n if (!source) {\n return {};\n }\n\n // Create visitor and traverse\n const visitor = new FunctionExtractorVisitor(source, modulePath, absoluteSourceFilePath);\n visitor.visitSource(source);\n\n return visitor.functions || {};\n}\n","/**\n * Glob Utilities for Coverage\n *\n * Uses test-exclude (same as Vitest's v8 coverage provider) to glob\n * AssemblyScript files matching coverage.include patterns.\n */\n\nimport { resolve } from 'path';\nimport TestExclude from 'test-exclude';\n\nimport { GlobResult } from '../types/types.js';\n\n/**\n * Glob files matching coverage include/exclude patterns\n *\n * Uses test-exclude for consistent behavior with Vitest's built-in\n * coverage providers.\n *\n * @param include - Include patterns (e.g., ['assembly/**\\/*.ts'])\n * @param exclude - Exclude patterns (e.g., ['**\\/*.test.ts'])\n * @param projectRoot - Project root directory\n * @returns Array of absolute file paths\n */\nexport function globFiles(\n include: string[],\n exclude: string[],\n projectRoot: string\n): GlobResult[] {\n // avoid issues with default behavior being grabbing from cwd\n if (include.length === 0) {\n return [];\n }\n\n const testExclude = new TestExclude({\n cwd: projectRoot,\n include,\n exclude,\n excludeNodeModules: true,\n });\n\n const includedFiles = testExclude.globSync(projectRoot);\n const results: GlobResult[] = includedFiles.map((file: string) => ({\n absolute: resolve(projectRoot, file),\n projectRootRelative: file\n })) || [];\n\n return results;\n}\n","/**\n * Hybrid Coverage Provider\n *\n * This provider handles both AssemblyScript and JavaScript and coverage\n * - Converts AS coverage to Istanbul format\n * - Delegates JS coverage to Vitest's v8 provider\n * - Merges both into a unified coverage report\n */\n\nimport { basename, relative } from 'node:path';\nimport type {\n CoverageProvider,\n Vitest,\n ReportContext,\n ResolvedCoverageOptions,\n CustomProviderOptions,\n ResolvedConfig,\n} from 'vitest/node';\nimport type { AfterSuiteRunMeta, SerializedConfig } from 'vitest';\nimport v8CoverageModule from '@vitest/coverage-v8';\nimport { type CoverageMap, createCoverageMap } from 'istanbul-lib-coverage';\n\n// pick up CustomProviderOptions module augmentation\nimport '../config/custom-provider-options.js';\n\nimport { convertToIstanbulFormat } from './istanbul-converter.js';\nimport { parseFunctionsFromFile } from './ast-parser.js';\nimport { globFiles } from './glob-utils.js';\nimport { getProjectSerializedOrGlobalConfig } from '../util/resolve-config.js';\nimport { mergeCoverageData } from './coverage-merge.js';\nimport { debug } from '../util/debug.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport type {\n AssemblyScriptCoveragePayload,\n CoverageData,\n GlobResult,\n ResolvedHybridProviderOptions,\n} from '../types/types.js';\nimport {\n POOL_ERROR_NAMES,\n COVERAGE_PAYLOAD_FORMATS\n} from '../types/constants.js';\n\nexport class HybridCoverageProvider implements CoverageProvider {\n name = 'hybrid-assemblyscript-v8' as const;\n\n private v8Provider: CoverageProvider | undefined;\n private accumulatedCoverageData: CoverageData = { hitCountsByFileAndPosition: {} };\n private projectConfig: SerializedConfig | ResolvedConfig = {} as SerializedConfig;\n private coverageOptions: ResolvedHybridProviderOptions = {} as ResolvedHybridProviderOptions;\n\n /**\n * Initialize the provider and get reference to v8 provider\n */\n async initialize(ctx: Vitest): Promise<void> {\n this.projectConfig = getProjectSerializedOrGlobalConfig(ctx).config;\n\n debug('[HybridCoverageProvider] Initializing Provider');\n\n // Get v8 provider from the coverage module\n this.v8Provider = await v8CoverageModule.getProvider();\n\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - initialize failed to get delegated v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n\n await this.v8Provider.initialize(ctx);\n this.v8Provider.name = 'hybrid-assemblyscript-v8 (delegated v8 reporter)' as const;\n debug('[HybridCoverageProvider] Initialized with delegated v8 provider');\n }\n\n /**\n * Handle suite completion - delegate based on coverage format marker\n */\n async onAfterSuiteRun(meta: AfterSuiteRunMeta): Promise<void> {\n const start = performance.now();\n const format: string | undefined = (meta?.coverage as any)?.__format;\n let suiteLogLabel = meta.testFiles.length > 0 ? basename(meta.testFiles[0]!) : '';\n\n // Check for AssemblyScript format marker\n if (format === COVERAGE_PAYLOAD_FORMATS.AssemblyScript) {\n const payload = meta.coverage as AssemblyScriptCoveragePayload;\n const { coverageData, suiteLogLabel: label } = payload;\n suiteLogLabel = label;\n\n debug(() => {\n const fileCount = Object.keys(coverageData.hitCountsByFileAndPosition).length;\n const positionCount = Object.values(coverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions).length, 0);\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun - Suite payload: ${positionCount} unique positions over ${fileCount} source files`;\n });\n\n // Merge incoming coverage data into accumulated (by position, summing hit counts)\n mergeCoverageData(this.accumulatedCoverageData, coverageData);\n\n debug(() => {\n const fileCount = Object.keys(this.accumulatedCoverageData.hitCountsByFileAndPosition).length;\n const positionCount = Object.values(this.accumulatedCoverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions).length, 0);\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun - Accumulated coverage: ${positionCount} unique positions over ${fileCount} source files`;\n });\n } else {\n // Delegate to v8 provider for all other formats (JS, etc.)\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - onAfterSuiteRun failed to delegate to v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n\n debug(`[HybridCoverageProvider] ${suiteLogLabel} - Delegating to v8 provider`);\n await this.v8Provider.onAfterSuiteRun(meta);\n }\n\n debug(() => {\n const files = meta.testFiles.map(tf => relative(this.projectConfig.root, tf)).join(',');\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun complete - TIMING ${(performance.now() - start).toFixed(2)} ms | testFiles: \"${files}\"`;\n });\n }\n\n /**\n * Generate unified coverage map (merging JS and AS coverage)\n *\n * Flow:\n * 1. Parse included AS source files to get sourceDebugInfo (source of truth for line numbers)\n * 1. Build merged CoverageData (all source functions + accumulated hit counts)\n * 4. Convert merged CoverageData to Istanbul format\n * 5. Get JS coverage from v8 provider\n * 6. Merge AS coverage into JS coverage\n */\n async generateCoverage(context: ReportContext): Promise<unknown> {\n const start = performance.now();\n\n debug('[HybridCoverageProvider] Generating coverage for test run');\n\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - generateCoverage failed to delegate to v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n\n // Build AS coverage map\n let asCoverageMap = createCoverageMap();\n\n if (this.coverageOptions.globbedAssemblyScriptInclude?.length > 0) {\n debug(`[HybridCoverageProvider] Building AS coverage map with ${this.coverageOptions.globbedAssemblyScriptInclude.length} source files `);\n debug(() => {\n const accumulatedPositionCount = Object.values(this.accumulatedCoverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions)?.length, 0);\n const files = Object.keys(this.accumulatedCoverageData.hitCountsByFileAndPosition).length;\n return `[HybridCoverageProvider] Accumulated coverage data has ${accumulatedPositionCount} unique positions hit across ${files} debug source files`;\n });\n\n // parse source files with AST parser, then match to hits and convert to istanbul format\n const fileProcessingPromises = this.coverageOptions.globbedAssemblyScriptInclude.map(async (include: GlobResult) => {\n debug(`[HybridCoverageProvider] Parsing AS source for expected coverage: \"${include.absolute}\" (file key: \"${include.projectRootRelative}\")`);\n \n const functionsByStartLine = await parseFunctionsFromFile(include.absolute, include.projectRootRelative) || {};\n debug(`[HybridCoverageProvider] Parsed ${Object.keys(functionsByStartLine).length} AS source functions in \"${include.projectRootRelative}\"`);\n\n const fileHitCountsByPosition = this.accumulatedCoverageData.hitCountsByFileAndPosition[include.projectRootRelative] ?? {};\n debug(`[HybridCoverageProvider] Accumulated AS coverage has ${Object.keys(fileHitCountsByPosition).length} positions for \"${include.projectRootRelative}\"`);\n\n // Containment matching (binary hit position → source) is performed during istanbul conversion\n return convertToIstanbulFormat(functionsByStartLine, fileHitCountsByPosition, include.absolute);\n });\n\n // Wait for all files to complete\n const istanbulResults = await Promise.all(fileProcessingPromises);\n\n // Add all results to coverage map\n for (const istanbulData of istanbulResults) {\n asCoverageMap.addFileCoverage(istanbulData);\n }\n\n debug(`[HybridCoverageProvider] Built AS coverage map with ${Object.keys(asCoverageMap.data).length} files`);\n } else {\n debug('[HybridCoverageProvider] WARNING: No assemblyScriptInclude patterns yieldled files - Coverage Map will be empty!');\n }\n\n const asGenerateEnd = performance.now();\n debug(`[HybridCoverageProvider] TIMING AS generateCoverage: ${(asGenerateEnd - start).toFixed(2)} ms`);\n\n // Get JS coverage from v8 provider\n debug('[HybridCoverageProvider] Getting JS coverage from v8 provider');\n const jsCoverage = await this.v8Provider.generateCoverage(context) as CoverageMap;\n debug(`[HybridCoverageProvider] JS coverage has ${Object.keys(jsCoverage.data).length} files`);\n debug(`[HybridCoverageProvider] TIMING JS generateCoverage: ${(performance.now() - asGenerateEnd).toFixed(2)} ms`);\n\n // Merge AS coverage into JS coverage\n debug('[HybridCoverageProvider] Merging AS coverage into JS coverage');\n jsCoverage.merge(asCoverageMap);\n debug(`[HybridCoverageProvider] Final merged coverage has ${Object.keys(jsCoverage.data).length} files`);\n\n debug(`[HybridCoverageProvider] TIMING Total generateCoverage: ${(performance.now() - start).toFixed(2)} ms`);\n\n return jsCoverage;\n }\n\n /**\n * Report coverage - delegate to v8 provider\n */\n async reportCoverage(coverageMap: unknown, context: ReportContext): Promise<void> {\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - reportCoverage failed to delegate to v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n\n debug(`[HybridCoverageProvider] Reporting coverage (allTestsRun=${context.allTestsRun})`);\n await this.v8Provider.reportCoverage(coverageMap, context);\n }\n\n /**\n * Resolve options\n */\n resolveOptions(): ResolvedHybridProviderOptions {\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - resolveOptions failed to delegate to v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n \n debug(`[HybridCoverageProvider] Resolving Coverage Options`);\n \n const definedCoverageOptions = this.projectConfig.coverage as CustomProviderOptions;\n const resolvedV8Options = this.v8Provider.resolveOptions() as ResolvedCoverageOptions<'v8'>;\n\n // For some reason the v8 provider builds its `excludes` values to include a null byte.\n // Remove null bytes for logging purposes so tools like grep won't complain about binary content.\n const sanitizedV8Options: ResolvedCoverageOptions<'v8'> = {\n ...resolvedV8Options,\n include: resolvedV8Options.include?.map(i => i.replace(/\\0/g, '')) || undefined,\n exclude: resolvedV8Options.exclude?.map(i => i.replace(/\\0/g, '')) || undefined\n };\n\n debug(`[HybridCoverageProvider] AS include: ${(definedCoverageOptions.assemblyScriptInclude || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] AS exclude: ${(definedCoverageOptions.assemblyScriptExclude || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] JS include: ${(sanitizedV8Options.include || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] JS exclude: ${(sanitizedV8Options.exclude || []).join(', ') || '(none)'}`);\n\n debug(`[HybridCoverageProvider] Globbing AS source files to include for coverage map basis`);\n const globbedAssemblyScriptInclude = globFiles(\n definedCoverageOptions.assemblyScriptInclude || [],\n definedCoverageOptions.assemblyScriptExclude || [],\n this.projectConfig.root\n );\n debug(`[HybridCoverageProvider] Including ${globbedAssemblyScriptInclude.length} AS files in coverage map`);\n \n const globbedAssemblyScriptExcludeOnly = globFiles(\n definedCoverageOptions.assemblyScriptExclude || [],\n [],\n this.projectConfig.root\n );\n debug(`[HybridCoverageProvider] Excluding ${globbedAssemblyScriptExcludeOnly.length} AS files from coverage map & instrumentation`);\n \n const resolvedCoverageOptions: ResolvedHybridProviderOptions = {\n ...resolvedV8Options,\n provider: 'custom',\n customProviderModule: definedCoverageOptions.customProviderModule,\n assemblyScriptInclude: definedCoverageOptions.assemblyScriptInclude ?? [],\n assemblyScriptExclude: definedCoverageOptions.assemblyScriptExclude ?? [],\n globbedAssemblyScriptInclude,\n globbedAssemblyScriptProjectRelativeExcludeOnly : globbedAssemblyScriptExcludeOnly.map(gr => gr.projectRootRelative)\n }; \n\n this.coverageOptions = resolvedCoverageOptions;\n return resolvedCoverageOptions;\n }\n\n async clean(clean: boolean = true): Promise<void> {\n debug('[HybridCoverageProvider] Clean coverage data - clean:', clean);\n if (clean) {\n this.accumulatedCoverageData = { hitCountsByFileAndPosition: {} };\n debug('[HybridCoverageProvider] Cleaned all internal coverage data');\n }\n\n if (this.v8Provider) {\n await this.v8Provider.clean(clean);\n debug(`[HybridCoverageProvider] V8 provider finished clean(${clean})`);\n }\n }\n}\n","/**\n * Coverage Provider Module Export\n *\n * This module exports the hybrid coverage provider for Vitest to load.\n * Users configure this via:\n * coverage.provider = 'custom'\n * coverage.customProviderModule = 'vitest-pool-assemblyscript/coverage'\n */\n\nimport { CoverageProviderModule } from 'vitest/node';\nimport v8CoverageModule from '@vitest/coverage-v8';\n\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport { HybridCoverageProvider } from './hybrid-coverage-provider.js';\n\n/**\n * Hybrid Coverage Provider\n *\n * This provider handles both AssemblyScript and JavaScript and coverage\n * - Converts AS coverage to Istanbul format\n * - Delegates JS coverage to Vitest's v8 provider\n * - Merges both into a unified coverage report\n */\nconst hybridProviderModule: CoverageProviderModule = {\n getProvider: (): HybridCoverageProvider => new HybridCoverageProvider(),\n\n startCoverage: async (runtimeOptions: {\n isolate: boolean\n }): Promise<unknown> => {\n if (v8CoverageModule.startCoverage) {\n return await v8CoverageModule.startCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n 'HybridCoverageProvider - v8 coverage module does not provide `startCoverage`',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n },\n \n takeCoverage: async (runtimeOptions?: any): Promise<unknown> => {\n if (v8CoverageModule.takeCoverage) {\n return await v8CoverageModule.takeCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n 'HybridCoverageProvider - v8 coverage module does not provide `takeCoverage`',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n },\n \n stopCoverage: async (runtimeOptions: {\n isolate: boolean\n }): Promise<unknown> => {\n if (v8CoverageModule.stopCoverage) {\n return await v8CoverageModule.stopCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n 'HybridCoverageProvider - v8 coverage module does not provide `stopCoverage`',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n },\n};\n\nexport default hybridProviderModule;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgB,+BACd,sBACA,MACA,QACsC;CACtC,IAAI;CACJ,IAAI,gBAAgB;CACpB,IAAI,kBAAkB;AAGtB,MAAK,MAAM,CAAC,cAAc,cAAc,OAAO,QAAQ,qBAAqB,EAAE;EAC5E,MAAM,YAAY,OAAO,aAAa;AACtC,MAAI,YAAY,KAAM;AAEtB,OAAK,MAAM,QAAQ,WAAW;GAC5B,MAAM,EAAE,UAAU;AAGlB,OAAI,CAAC,kBAAkB,MAAM,QAAQ,MAAM,CAAE;AAG7C,OAAI,YAAY,iBACX,cAAc,iBAAiB,MAAM,cAAc,iBAAkB;AACxE,gBAAY;AACZ,oBAAgB;AAChB,sBAAkB,MAAM;;;;AAK9B,QAAO;;;;;;;;;;AAWT,SAAgB,kBACd,MACA,QACA,OACS;AAET,KAAI,OAAO,MAAM,aAAa,OAAO,MAAM,QAAS,QAAO;AAG3D,KAAI,SAAS,MAAM,aAAa,SAAS,MAAM,YAAa,QAAO;AAGnE,KAAI,SAAS,MAAM,WAAW,SAAS,MAAM,UAAW,QAAO;AAE/D,QAAO;;;;;AC3ET,SAAS,cAAc,GAAG,MAAmB;;;;;;;;;;;;;;;;;;;AAwB7C,eAAsB,wBACpB,0BACA,yBACA,kBAC2B;CAC3B,MAAM,aAAa,YAAY,KAAK;AAEpC,qBAAoB;EAClB,MAAM,sBAAsB,OAAO,OAAO,yBAAyB,CAAC,QAAQ,KAAK,UAAU,MAAM,MAAM,QAAQ,EAAE;EACjH,MAAM,oBAAoB,OAAO,KAAK,wBAAwB,CAAC;AAG/D,SAAO,kDAAkD,iBAAiB,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AE,EAAE;AACjE,SAAM,8DAA8D;;AAGtE,MAAI,KAAK,YAAY;AACnB,SAAM,KAAK,WAAW,MAAM,MAAM;AAClC,SAAM,uDAAuD,MAAM,GAAG;;;;;;;;;;;;;;;ACrQ5E,MAAM,uBAA+C;CACnD,mBAA2C,IAAI,wBAAwB;CAEvE,eAAe,OAAO,mBAEE;AACtB,MAAI,iBAAiB,cACnB,QAAO,MAAM,iBAAiB,cAAc,eAAe;MAE3D,OAAM,gBACJ,gFACA,iBAAiB,4BAClB;;CAIL,cAAc,OAAO,mBAA2C;AAC9D,MAAI,iBAAiB,aACnB,QAAO,MAAM,iBAAiB,aAAa,eAAe;MAE1D,OAAM,gBACJ,+EACA,iBAAiB,4BAClB;;CAIL,cAAc,OAAO,mBAEG;AACtB,MAAI,iBAAiB,aACnB,QAAO,MAAM,iBAAiB,aAAa,eAAe;MAE1D,OAAM,gBACJ,+EACA,iBAAiB,4BAClB;;CAGN;AAED,gCAAe"}
1
+ {"version":3,"file":"index.mjs","names":["parsePath","AssemblyScriptParser","resolve"],"sources":["../../src/coverage-provider/containment-matcher.ts","../../src/coverage-provider/istanbul-converter.ts","../../src/coverage-provider/ast-parser.ts","../../src/coverage-provider/glob-utils.ts","../../src/coverage-provider/hybrid-coverage-provider.ts","../../src/coverage-provider/index.ts"],"sourcesContent":["/**\n * Containment Matcher\n *\n * Provides containment-based matching for coverage mapping.\n * Binary debug info provides points (representativeLocation), source parsing provides ranges.\n * We find which source range contains each binary point.\n *\n * Usage by version:\n * - v1: Function containment matching (binary representativeLocation → source function range)\n * - v2: Function containment (same) + statement containment + branch path containment\n *\n * Why containment matching (not direct position lookup):\n * AS compiler generates source map entries differently by statement type:\n * - Variable declarations: source map points to statement start (keyword)\n * - Control flow (if/switch/for): source map points to condition EXPRESSION, not keyword\n *\n * Example: `if (n < 0)` → binary reports column 7 ('n'), not column 3 ('i' of 'if')\n *\n * Containment matching is more robust:\n * - Binary gives us a position (representativeLocation) somewhere in the function\n * - Source gives us function ranges (start/end line/column)\n * - We find which source function range contains the binary position\n * - Handles nested functions with \"tightest fit\" (innermost function wins)\n */\n\nimport type { ParsedSourceFunctionInfo, SourceRange } from '../types/types.js';\n\n/**\n * Functions indexed by file path, then by start line.\n * Multiple functions can start on the same line (e.g., nested arrow functions).\n */\nexport type FunctionsByFileAndStartLine = Record<string, Record<number, ParsedSourceFunctionInfo[]>>;\n\n/**\n * Find the source function whose range contains the given position.\n *\n * For nested functions, uses \"tightest fit\" - returns the innermost function\n * (the one with the largest start position among all containing functions).\n *\n * @param functionsByStartLine - Functions for a single file, indexed by start line\n * @param line - Target line number (1-based)\n * @param column - Target column number (1-based)\n * @returns The containing function, or undefined if no match\n */\nexport function findFunctionContainingPosition(\n functionsByStartLine: Record<number, ParsedSourceFunctionInfo[]>,\n line: number,\n column: number\n): ParsedSourceFunctionInfo | undefined {\n let bestMatch: ParsedSourceFunctionInfo | undefined;\n let bestStartLine = -1;\n let bestStartColumn = -1;\n\n // Check functions starting on lines <= target line\n for (const [startLineStr, functions] of Object.entries(functionsByStartLine)) {\n const startLine = Number(startLineStr);\n if (startLine > line) continue;\n\n for (const func of functions) {\n const { range } = func;\n\n // Check if position is within this function's range\n if (!isPositionInRange(line, column, range)) continue;\n\n // Tightest fit: prefer function with largest start position (innermost)\n if (startLine > bestStartLine ||\n (startLine === bestStartLine && range.startColumn > bestStartColumn)) {\n bestMatch = func;\n bestStartLine = startLine;\n bestStartColumn = range.startColumn;\n }\n }\n }\n\n return bestMatch;\n}\n\n/**\n * Check if a position (line, column) falls within a source range.\n *\n * @param line - Target line number (1-based)\n * @param column - Target column number (1-based)\n * @param range - Source range to check against\n * @returns true if position is within range (inclusive)\n */\nexport function isPositionInRange(\n line: number,\n column: number,\n range: SourceRange\n): boolean {\n // Outside line range entirely\n if (line < range.startLine || line > range.endLine) return false;\n\n // On start line but before start column\n if (line === range.startLine && column < range.startColumn) return false;\n\n // On end line but after end column\n if (line === range.endLine && column > range.endColumn) return false;\n\n return true;\n}\n","/**\n * Istanbul Format Converter\n *\n * Converts AssemblyScript coverage data to Istanbul's FileCoverageData format.\n * This enables integration with Vitest's coverage reporting system and standard\n * coverage tools like Codecov, Coveralls, etc.\n *\n * Current Implementation: Function-level coverage only\n * - Uses containment matching: binary positions → source function ranges\n * - Each function maps to both a function entry AND a statement entry\n * - Statement coverage matches function coverage (function-level granularity)\n * - Branch coverage is 0% (no branches tracked yet)\n * - Line coverage derived from statement coverage\n *\n * Future Enhancement (v2): Block-level statement and branch coverage\n */\n\nimport type { FileCoverageData, Range, FunctionMapping, BranchMapping } from 'istanbul-lib-coverage';\nimport type { ParsedSourceFunctionInfo } from '../types/types.js';\nimport { findFunctionContainingPosition } from './containment-matcher.js';\nimport { debug } from '../util/debug.js';\n\nconst DEBUG_ISTANBUL = false;\n\nfunction istanbulDebug(...args: any[]): void {\n if (DEBUG_ISTANBUL) {\n debug(...args);\n }\n};\n\n/**\n * Convert AssemblyScript coverage data to Istanbul format for a single file\n *\n * Algorithm (containment matching):\n * 1. For each hit position in fileHitCountsByPosition:\n * - Use containment matcher to find which source function contains this position\n * - Record the hit count for that function\n * 2. For each function in fileFunctionsByStartLine:\n * - Add function mapping to fnMap\n * - Add function hit count to f (from matched hits, or 0 if not hit)\n * - Add corresponding statement mapping to statementMap\n * - Add same hit count to s (statement coverage matches function coverage)\n *\n * @param fileFunctionsByStartLine - Functions for this file, keyed by start line (from AST parser)\n * @param fileHitCountsByPosition - Hit counts for this file, keyed by position \"line:column\" (from accumulated coverage)\n * @param absoluteFilePath - Absolute path to the source file (for Istanbul output)\n * @returns Istanbul FileCoverage object\n */\nexport async function convertToIstanbulFormat(\n fileFunctionsByStartLine: Record<number, ParsedSourceFunctionInfo[]>,\n fileHitCountsByPosition: Record<string, number>,\n absoluteFilePath: string\n): Promise<FileCoverageData> {\n const startMatch = performance.now();\n\n istanbulDebug(() => {\n const sourceFunctionCount = Object.values(fileFunctionsByStartLine).reduce((sum, funcs) => sum + funcs.length, 0);\n const uniqueHitPosCount = Object.keys(fileHitCountsByPosition).length;\n const coverageEstimate = sourceFunctionCount === 0 ? Infinity : ((uniqueHitPosCount * 100) / sourceFunctionCount).toFixed(2);\n\n return `[IstanbulConverter] Processing source file: \"${absoluteFilePath}\"\\n`\n + `[IstanbulConverter] Source: ${sourceFunctionCount} total functions, Coverage: ${uniqueHitPosCount} unique hit positions\\n`\n + `[IstanbulConverter] Sanity Check - AS File Coverage Estimate: ${coverageEstimate}%\\n`\n + `[IstanbulConverter] Containment matching functions: coverage hit positions to source functions by range`;\n });\n\n // Build a map of function → hit count using containment matching\n // Key: function source identity (qualifiedName), Value: hit count\n const hitCountsBySourceFunctionName = new Map<ParsedSourceFunctionInfo, number>();\n\n // For each hit position, find which function contains it\n for (const [positionKey, hitCount] of Object.entries(fileHitCountsByPosition)) {\n // Position key format is \"line:column\"\n const parts = positionKey.split(':');\n const lineStr = parts[0];\n const columnStr = parts[1];\n\n if (lineStr && columnStr) {\n const line = parseInt(lineStr, 10);\n const column = parseInt(columnStr, 10);\n\n const containingFunction = findFunctionContainingPosition(fileFunctionsByStartLine, line, column);\n if (containingFunction) {\n // Accumulate hits (in case multiple positions map to same function)\n const existingHits = hitCountsBySourceFunctionName.get(containingFunction);\n const existingHitsCount = existingHits ?? 0;\n const max = Math.max(existingHitsCount, hitCount);\n hitCountsBySourceFunctionName.set(containingFunction, max); // <-- TODO: Explain this max logic\n\n if (existingHits !== undefined) {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} → function \"${containingFunction.shortName}\" EXISTING HITS: ${existingHits} NEW COUNT: ${max}`);\n } else {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} → function \"${containingFunction.shortName}\" (hits: ${hitCount})`);\n }\n } else {\n istanbulDebug(`[IstanbulConverter] Position ${positionKey} has no containing function`);\n }\n }\n }\n\n const startConvert = performance.now();\n istanbulDebug(`[IstanbulConverter] Matching Complete - Converting to Istanbul format`);\n\n // Initialize Istanbul data structures\n const fnMap: { [key: string]: FunctionMapping } = {};\n const f: { [key: string]: number } = {};\n const statementMap: { [key: string]: Range } = {};\n const s: { [key: string]: number } = {};\n const branchMap: { [key: string]: BranchMapping } = {};\n const b: { [key: string]: number[] } = {};\n\n // Convert function coverage to Istanbul format\n // Iterate all functions from parsed source (ensures 0-hit functions are included)\n let funcIdx = 0;\n for (const functions of Object.values(fileFunctionsByStartLine)) {\n for (const funcInfo of functions) {\n const { range, shortName } = funcInfo;\n\n // Defensive: skip functions with invalid metadata (shouldn't happen - AST parser filters these)\n if (range.startLine === 0) {\n continue;\n }\n\n // Get hit count from containment matching (or 0 if not hit)\n const hitCount = hitCountsBySourceFunctionName.get(funcInfo) ?? 0;\n const displayShortName = shortName && shortName !== '' ? shortName : '<anonymous>';\n istanbulDebug(\n `[IstanbulConverter] Istanbul function index ${funcIdx}: \"${displayShortName}\"`\n + ` (source ${range.startLine}:${range.startColumn} - ${range.endLine}:${range.endColumn}), hits: ${hitCount}`\n );\n\n // Create function mapping\n // Both 'decl' (declaration) and 'loc' (location) use the same range\n // Internal ParsedSourceFunctionInfo uses 1-based columns, Istanbul expects 0-based\n const istanbulRange: Range = {\n start: { line: range.startLine, column: range.startColumn - 1 },\n end: { line: range.endLine, column: range.endColumn - 1 }\n };\n\n const idxStr = funcIdx.toString();\n fnMap[idxStr] = {\n name: shortName,\n decl: istanbulRange,\n loc: istanbulRange,\n line: range.startLine\n };\n f[idxStr] = hitCount;\n\n // Create corresponding statement mapping\n // For function-level coverage, each function is one \"statement\"\n // The statement range matches the function range\n // This gives us statement coverage at function granularity\n statementMap[idxStr] = istanbulRange;\n s[idxStr] = hitCount;\n\n funcIdx++;\n }\n }\n\n const done = performance.now();\n const matchingMs = (startConvert - startMatch).toFixed(2);\n const convertMs = (done - startConvert).toFixed(2);\n const totalMs = (done - startMatch).toFixed(2);\n\n istanbulDebug(\n `[IstanbulConverter] Coverage Coversion Complete: ${Object.keys(fnMap).length} functions,` \n + ` ${totalMs} ms total (matching: ${matchingMs} ms, convert: ${convertMs} ms)`\n );\n\n return {\n path: absoluteFilePath,\n fnMap,\n f,\n statementMap,\n s,\n branchMap,\n b\n };\n}\n","/**\n * AST Parser for AssemblyScript Source Files\n *\n * Parses AS source files to extract function metadata for coverage.\n * Used by generateCoverage to build empty coverage map from all source files.\n *\n * Source AST is the source of truth for what SHOULD be covered.\n * Binary instrumentation tells us what we CAN measure (hit counts).\n *\n * Functions are grouped by start line for efficient containment matching.\n *\n * Architecture:\n * - Uses shared ASTVisitor for complete NodeKind coverage\n * - Overrides hooks to extract function information during traversal\n */\n\nimport { readFile } from 'node:fs/promises';\nimport { parse as parsePath } from 'node:path';\nimport {\n Parser as AssemblyScriptParser,\n Source,\n BlockStatement,\n Node,\n FunctionDeclaration,\n MethodDeclaration,\n ClassDeclaration,\n VariableDeclaration,\n FunctionExpression,\n} from 'assemblyscript';\n\nimport type { ParsedSourceFunctionInfo, SourceRange } from '../types/types.js';\nimport { ASCommonFlags, ASNodeKind } from '../types/constants.js';\nimport { ASTVisitor } from '../util/ast-visitor.js';\n\n/**\n * Visitor that extracts function information from AST nodes\n */\nclass FunctionExtractorVisitor extends ASTVisitor {\n /** Source file being parsed */\n private source: Source;\n /** Module path for building qualified names */\n private modulePath: string;\n /** Absolute file path */\n private filePath: string;\n /** Accumulated function records, keyed by start line */\n readonly functions: Record<number, ParsedSourceFunctionInfo[]> = {};\n /** Current class name (when inside a class) */\n private currentClassName: string | null = null;\n\n constructor(source: Source, modulePath: string, filePath: string) {\n super();\n this.source = source;\n this.modulePath = modulePath;\n this.filePath = filePath;\n }\n\n /**\n * Track class context when entering a class\n */\n protected onClassEnter(node: ClassDeclaration): void {\n this.currentClassName = node.name?.text ?? 'Anonymous';\n }\n\n /**\n * Restore class context when exiting a class\n */\n protected onClassExit(_node: ClassDeclaration): void {\n this.currentClassName = null;\n }\n\n /**\n * Extract function info from function declarations\n */\n protected onFunctionDeclaration(node: FunctionDeclaration): boolean {\n if (node.body && this.hasBodyStatements(node.body)) {\n const shortName = node.name?.text ?? '~anonymous';\n const qualifiedName = `${this.modulePath}/${shortName}`;\n const range = this.buildRange(node, node.name ?? null);\n this.addFunction(qualifiedName, shortName, range);\n }\n return true; // Continue recursion into body\n }\n\n /**\n * Extract function info from method declarations\n */\n protected onMethodDeclaration(node: MethodDeclaration): boolean {\n if (node.body && this.hasBodyStatements(node.body)) {\n const methodName = node.name?.text ?? 'constructor';\n const className = this.currentClassName ?? 'Unknown';\n const flags = node.flags;\n\n // Determine method type from flags\n const isStatic = (flags & ASCommonFlags.Static) !== 0;\n const isGetter = (flags & ASCommonFlags.Get) !== 0;\n const isSetter = (flags & ASCommonFlags.Set) !== 0;\n\n // Build short name to match binary naming convention:\n // - Static: ClassName.methodName\n // - Getter: ClassName#get:propertyName\n // - Setter: ClassName#set:propertyName\n // - Instance: ClassName#methodName\n let shortName: string;\n if (isStatic) {\n shortName = `${className}.${methodName}`;\n } else if (isGetter) {\n shortName = `${className}#get:${methodName}`;\n } else if (isSetter) {\n shortName = `${className}#set:${methodName}`;\n } else {\n shortName = `${className}#${methodName}`;\n }\n\n const qualifiedName = `${this.modulePath}/${shortName}`;\n const range = this.buildRange(node, node.name ?? null);\n this.addFunction(qualifiedName, shortName, range);\n }\n return true; // Continue recursion into body\n }\n\n /**\n * Extract function info from variable declarations (arrow functions)\n */\n protected onVariableDeclaration(node: VariableDeclaration): boolean {\n if (node.initializer && node.initializer.kind === ASNodeKind.Function) {\n const funcExpr = node.initializer as FunctionExpression;\n const funcDecl = funcExpr.declaration;\n\n if (funcDecl.body && this.hasBodyStatements(funcDecl.body)) {\n // Use variable name for the function\n const shortName = node.name.text;\n const qualifiedName = `${this.modulePath}/${shortName}`;\n\n // Use the variable declaration's range\n const range: SourceRange = {\n filePath: this.filePath,\n startLine: this.source.lineAt(node.range.start),\n startColumn: this.source.columnAt(),\n endLine: this.source.lineAt(node.range.end),\n endColumn: this.source.columnAt(),\n };\n\n this.addFunction(qualifiedName, shortName, range);\n }\n\n // Visit the function body manually since we're handling this specially\n if (funcDecl.body) {\n this.visitNode(funcDecl.body);\n }\n return false; // Don't recurse again - we handled it\n }\n return true; // Continue recursion for non-function initializers\n }\n\n /**\n * Check if a function body has statements (non-empty body)\n */\n private hasBodyStatements(body: Node): boolean {\n if (body.kind === ASNodeKind.Block) {\n const blockBody = body as BlockStatement;\n return blockBody.statements.length > 0;\n }\n // Expression body (braceless arrow) - always has the expression\n return true;\n }\n\n /**\n * Add a function to the functions record, keyed by start line\n */\n private addFunction(qualifiedName: string, shortName: string, range: SourceRange): void {\n const startLine = range.startLine;\n if (!this.functions[startLine]) {\n this.functions[startLine] = [];\n }\n this.functions[startLine].push({ qualifiedName, shortName, range });\n }\n\n /**\n * Build a SourceRange for a node, using name.range.start to skip decorators\n */\n private buildRange(node: Node, nameNode: Node | null): SourceRange {\n const startNode = nameNode ?? node;\n return {\n filePath: this.filePath,\n startLine: this.source.lineAt(startNode.range.start),\n startColumn: this.source.columnAt(),\n endLine: this.source.lineAt(node.range.end),\n endColumn: this.source.columnAt(),\n };\n }\n}\n\n/**\n * Parse functions from a single AS source file\n *\n * @param absoluteSourceFilePath - Absolute path to AS source file\n * @param relativeSourceFilePath - Relative path to AS source file (derived once in caller and used several places)\n * @returns Record of start line to array of ParsedSourceFunctionInfo (multiple functions can start on same line)\n */\nexport async function parseFunctionsFromFile(\n absoluteSourceFilePath: string,\n relativeSourceFilePath: string,\n): Promise<Record<number, ParsedSourceFunctionInfo[]>> {\n const sourceCode = await readFile(absoluteSourceFilePath, 'utf8');\n\n // Build the module path (strip any extension, use forward slashes)\n const parsed = parsePath(relativeSourceFilePath);\n const modulePath = parsed.dir ? `${parsed.dir}/${parsed.name}` : parsed.name;\n\n // Parse with AssemblyScript parser\n const asParser = new AssemblyScriptParser();\n asParser.parseFile(sourceCode, relativeSourceFilePath, true);\n\n const source = asParser.currentSource;\n if (!source) {\n return {};\n }\n\n // Create visitor and traverse\n const visitor = new FunctionExtractorVisitor(source, modulePath, absoluteSourceFilePath);\n visitor.visitSource(source);\n\n return visitor.functions || {};\n}\n","/**\n * Glob Utilities for Coverage\n *\n * Uses test-exclude (same as Vitest's v8 coverage provider) to glob\n * AssemblyScript files matching coverage.include patterns.\n */\n\nimport { resolve } from 'path';\nimport TestExclude from 'test-exclude';\n\nimport { GlobResult } from '../types/types.js';\n\n/**\n * Glob files matching coverage include/exclude patterns\n *\n * Uses test-exclude for consistent behavior with Vitest's built-in\n * coverage providers.\n *\n * @param include - Include patterns (e.g., ['assembly/**\\/*.ts'])\n * @param exclude - Exclude patterns (e.g., ['**\\/*.test.ts'])\n * @param projectRoot - Project root directory\n * @returns Array of absolute file paths\n */\nexport function globFiles(\n include: string[],\n exclude: string[],\n projectRoot: string\n): GlobResult[] {\n // avoid issues with default behavior being grabbing from cwd\n if (include.length === 0) {\n return [];\n }\n\n const testExclude = new TestExclude({\n cwd: projectRoot,\n include,\n exclude,\n excludeNodeModules: true,\n });\n\n const includedFiles = testExclude.globSync(projectRoot);\n const results: GlobResult[] = includedFiles.map((file: string) => ({\n absolute: resolve(projectRoot, file),\n projectRootRelative: file\n })) || [];\n\n return results;\n}\n","/**\n * Hybrid Coverage Provider\n *\n * This provider handles both AssemblyScript and JavaScript and coverage\n * - Converts AS coverage to Istanbul format\n * - Delegates JS coverage to Vitest's v8 provider\n * - Merges both into a unified coverage report\n */\n\nimport { basename, relative } from 'node:path';\nimport type {\n CoverageProvider,\n Vitest,\n ReportContext,\n ResolvedCoverageOptions,\n CustomProviderOptions,\n ResolvedConfig,\n} from 'vitest/node';\nimport type { AfterSuiteRunMeta, SerializedConfig } from 'vitest';\nimport v8CoverageModule from '@vitest/coverage-v8';\nimport type { CoverageMap } from 'istanbul-lib-coverage';\nimport istanbulCoverage from 'istanbul-lib-coverage';\nconst { createCoverageMap } = istanbulCoverage;\n\n// pick up CustomProviderOptions module augmentation\nimport '../config/custom-provider-options.js';\n\nimport { convertToIstanbulFormat } from './istanbul-converter.js';\nimport { parseFunctionsFromFile } from './ast-parser.js';\nimport { globFiles } from './glob-utils.js';\nimport { getProjectSerializedOrGlobalConfig } from '../util/resolve-config.js';\nimport { mergeCoverageData } from './coverage-merge.js';\nimport { debug } from '../util/debug.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport type {\n AssemblyScriptCoveragePayload,\n CoverageData,\n GlobResult,\n ResolvedHybridProviderOptions,\n} from '../types/types.js';\nimport {\n POOL_ERROR_NAMES,\n COVERAGE_PAYLOAD_FORMATS\n} from '../types/constants.js';\n\nexport class HybridCoverageProvider implements CoverageProvider {\n name = 'hybrid-assemblyscript-v8' as const;\n\n private v8Provider: CoverageProvider | undefined;\n private accumulatedCoverageData: CoverageData = { hitCountsByFileAndPosition: {} };\n private projectConfig: SerializedConfig | ResolvedConfig = {} as SerializedConfig;\n private coverageOptions: ResolvedHybridProviderOptions = {} as ResolvedHybridProviderOptions;\n\n /**\n * Initialize the provider and get reference to v8 provider\n */\n async initialize(ctx: Vitest): Promise<void> {\n this.projectConfig = getProjectSerializedOrGlobalConfig(ctx).config;\n\n debug('[HybridCoverageProvider] Initializing Provider');\n\n // Get v8 provider from the coverage module\n this.v8Provider = await v8CoverageModule.getProvider();\n\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - initialize failed to get delegated v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n\n await this.v8Provider.initialize(ctx);\n this.v8Provider.name = 'hybrid-assemblyscript-v8 (delegated v8 reporter)' as const;\n debug('[HybridCoverageProvider] Initialized with delegated v8 provider');\n }\n\n /**\n * Handle suite completion - delegate based on coverage format marker\n */\n async onAfterSuiteRun(meta: AfterSuiteRunMeta): Promise<void> {\n const start = performance.now();\n const format: string | undefined = (meta?.coverage as any)?.__format;\n let suiteLogLabel = meta.testFiles.length > 0 ? basename(meta.testFiles[0]!) : '';\n\n // Check for AssemblyScript format marker\n if (format === COVERAGE_PAYLOAD_FORMATS.AssemblyScript) {\n const payload = meta.coverage as AssemblyScriptCoveragePayload;\n const { coverageData, suiteLogLabel: label } = payload;\n suiteLogLabel = label;\n\n debug(() => {\n const fileCount = Object.keys(coverageData.hitCountsByFileAndPosition).length;\n const positionCount = Object.values(coverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions).length, 0);\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun - Suite payload: ${positionCount} unique positions over ${fileCount} source files`;\n });\n\n // Merge incoming coverage data into accumulated (by position, summing hit counts)\n mergeCoverageData(this.accumulatedCoverageData, coverageData);\n\n debug(() => {\n const fileCount = Object.keys(this.accumulatedCoverageData.hitCountsByFileAndPosition).length;\n const positionCount = Object.values(this.accumulatedCoverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions).length, 0);\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun - Accumulated coverage: ${positionCount} unique positions over ${fileCount} source files`;\n });\n } else {\n // Delegate to v8 provider for all other formats (JS, etc.)\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - onAfterSuiteRun failed to delegate to v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n\n debug(`[HybridCoverageProvider] ${suiteLogLabel} - Delegating to v8 provider`);\n await this.v8Provider.onAfterSuiteRun(meta);\n }\n\n debug(() => {\n const files = meta.testFiles.map(tf => relative(this.projectConfig.root, tf)).join(',');\n return `[HybridCoverageProvider] ${suiteLogLabel} - onAfterSuiteRun complete - TIMING ${(performance.now() - start).toFixed(2)} ms | testFiles: \"${files}\"`;\n });\n }\n\n /**\n * Generate unified coverage map (merging JS and AS coverage)\n *\n * Flow:\n * 1. Parse included AS source files to get sourceDebugInfo (source of truth for line numbers)\n * 1. Build merged CoverageData (all source functions + accumulated hit counts)\n * 4. Convert merged CoverageData to Istanbul format\n * 5. Get JS coverage from v8 provider\n * 6. Merge AS coverage into JS coverage\n */\n async generateCoverage(context: ReportContext): Promise<unknown> {\n const start = performance.now();\n\n debug('[HybridCoverageProvider] Generating coverage for test run');\n\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - generateCoverage failed to delegate to v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n\n // Build AS coverage map\n let asCoverageMap = createCoverageMap();\n\n if (this.coverageOptions.globbedAssemblyScriptInclude?.length > 0) {\n debug(`[HybridCoverageProvider] Building AS coverage map with ${this.coverageOptions.globbedAssemblyScriptInclude.length} source files `);\n debug(() => {\n const accumulatedPositionCount = Object.values(this.accumulatedCoverageData.hitCountsByFileAndPosition)\n .reduce((sum, positions) => sum + Object.keys(positions)?.length, 0);\n const files = Object.keys(this.accumulatedCoverageData.hitCountsByFileAndPosition).length;\n return `[HybridCoverageProvider] Accumulated coverage data has ${accumulatedPositionCount} unique positions hit across ${files} debug source files`;\n });\n\n // parse source files with AST parser, then match to hits and convert to istanbul format\n const fileProcessingPromises = this.coverageOptions.globbedAssemblyScriptInclude.map(async (include: GlobResult) => {\n debug(`[HybridCoverageProvider] Parsing AS source for expected coverage: \"${include.absolute}\" (file key: \"${include.projectRootRelative}\")`);\n \n const functionsByStartLine = await parseFunctionsFromFile(include.absolute, include.projectRootRelative) || {};\n debug(`[HybridCoverageProvider] Parsed ${Object.keys(functionsByStartLine).length} AS source functions in \"${include.projectRootRelative}\"`);\n\n const fileHitCountsByPosition = this.accumulatedCoverageData.hitCountsByFileAndPosition[include.projectRootRelative] ?? {};\n debug(`[HybridCoverageProvider] Accumulated AS coverage has ${Object.keys(fileHitCountsByPosition).length} positions for \"${include.projectRootRelative}\"`);\n\n // Containment matching (binary hit position → source) is performed during istanbul conversion\n return convertToIstanbulFormat(functionsByStartLine, fileHitCountsByPosition, include.absolute);\n });\n\n // Wait for all files to complete\n const istanbulResults = await Promise.all(fileProcessingPromises);\n\n // Add all results to coverage map\n for (const istanbulData of istanbulResults) {\n asCoverageMap.addFileCoverage(istanbulData);\n }\n\n debug(`[HybridCoverageProvider] Built AS coverage map with ${Object.keys(asCoverageMap.data).length} files`);\n } else {\n debug('[HybridCoverageProvider] WARNING: No assemblyScriptInclude patterns yieldled files - Coverage Map will be empty!');\n }\n\n const asGenerateEnd = performance.now();\n debug(`[HybridCoverageProvider] TIMING AS generateCoverage: ${(asGenerateEnd - start).toFixed(2)} ms`);\n\n // Get JS coverage from v8 provider\n debug('[HybridCoverageProvider] Getting JS coverage from v8 provider');\n const jsCoverage = await this.v8Provider.generateCoverage(context) as CoverageMap;\n debug(`[HybridCoverageProvider] JS coverage has ${Object.keys(jsCoverage.data).length} files`);\n debug(`[HybridCoverageProvider] TIMING JS generateCoverage: ${(performance.now() - asGenerateEnd).toFixed(2)} ms`);\n\n // Merge AS coverage into JS coverage\n debug('[HybridCoverageProvider] Merging AS coverage into JS coverage');\n jsCoverage.merge(asCoverageMap);\n debug(`[HybridCoverageProvider] Final merged coverage has ${Object.keys(jsCoverage.data).length} files`);\n\n debug(`[HybridCoverageProvider] TIMING Total generateCoverage: ${(performance.now() - start).toFixed(2)} ms`);\n\n return jsCoverage;\n }\n\n /**\n * Report coverage - delegate to v8 provider\n */\n async reportCoverage(coverageMap: unknown, context: ReportContext): Promise<void> {\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - reportCoverage failed to delegate to v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n\n debug(`[HybridCoverageProvider] Reporting coverage (allTestsRun=${context.allTestsRun})`);\n await this.v8Provider.reportCoverage(coverageMap, context);\n }\n\n /**\n * Resolve options\n */\n resolveOptions(): ResolvedHybridProviderOptions {\n if (!this.v8Provider) {\n throw createPoolError(\n 'HybridCoverageProvider - resolveOptions failed to delegate to v8 provider',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n \n debug(`[HybridCoverageProvider] Resolving Coverage Options`);\n \n const definedCoverageOptions = this.projectConfig.coverage as CustomProviderOptions;\n const resolvedV8Options = this.v8Provider.resolveOptions() as ResolvedCoverageOptions<'v8'>;\n\n // For some reason the v8 provider builds its `excludes` values to include a null byte.\n // Remove null bytes for logging purposes so tools like grep won't complain about binary content.\n const sanitizedV8Options: ResolvedCoverageOptions<'v8'> = {\n ...resolvedV8Options,\n include: resolvedV8Options.include?.map(i => i.replace(/\\0/g, '')) || undefined,\n exclude: resolvedV8Options.exclude?.map(i => i.replace(/\\0/g, '')) || undefined\n };\n\n debug(`[HybridCoverageProvider] AS include: ${(definedCoverageOptions.assemblyScriptInclude || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] AS exclude: ${(definedCoverageOptions.assemblyScriptExclude || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] JS include: ${(sanitizedV8Options.include || []).join(', ') || '(none)'}`);\n debug(`[HybridCoverageProvider] JS exclude: ${(sanitizedV8Options.exclude || []).join(', ') || '(none)'}`);\n\n debug(`[HybridCoverageProvider] Globbing AS source files to include for coverage map basis`);\n const globbedAssemblyScriptInclude = globFiles(\n definedCoverageOptions.assemblyScriptInclude || [],\n definedCoverageOptions.assemblyScriptExclude || [],\n this.projectConfig.root\n );\n debug(`[HybridCoverageProvider] Including ${globbedAssemblyScriptInclude.length} AS files in coverage map`);\n \n const globbedAssemblyScriptExcludeOnly = globFiles(\n definedCoverageOptions.assemblyScriptExclude || [],\n [],\n this.projectConfig.root\n );\n debug(`[HybridCoverageProvider] Excluding ${globbedAssemblyScriptExcludeOnly.length} AS files from coverage map & instrumentation`);\n \n const resolvedCoverageOptions: ResolvedHybridProviderOptions = {\n ...resolvedV8Options,\n provider: 'custom',\n customProviderModule: definedCoverageOptions.customProviderModule,\n assemblyScriptInclude: definedCoverageOptions.assemblyScriptInclude ?? [],\n assemblyScriptExclude: definedCoverageOptions.assemblyScriptExclude ?? [],\n globbedAssemblyScriptInclude,\n globbedAssemblyScriptProjectRelativeExcludeOnly : globbedAssemblyScriptExcludeOnly.map(gr => gr.projectRootRelative)\n }; \n\n this.coverageOptions = resolvedCoverageOptions;\n return resolvedCoverageOptions;\n }\n\n async clean(clean: boolean = true): Promise<void> {\n debug('[HybridCoverageProvider] Clean coverage data - clean:', clean);\n if (clean) {\n this.accumulatedCoverageData = { hitCountsByFileAndPosition: {} };\n debug('[HybridCoverageProvider] Cleaned all internal coverage data');\n }\n\n if (this.v8Provider) {\n await this.v8Provider.clean(clean);\n debug(`[HybridCoverageProvider] V8 provider finished clean(${clean})`);\n }\n }\n}\n","/**\n * Coverage Provider Module Export\n *\n * This module exports the hybrid coverage provider for Vitest to load.\n * Users configure this via:\n * coverage.provider = 'custom'\n * coverage.customProviderModule = 'vitest-pool-assemblyscript/coverage'\n */\n\nimport { CoverageProviderModule } from 'vitest/node';\nimport v8CoverageModule from '@vitest/coverage-v8';\n\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport { HybridCoverageProvider } from './hybrid-coverage-provider.js';\n\n/**\n * Hybrid Coverage Provider\n *\n * This provider handles both AssemblyScript and JavaScript and coverage\n * - Converts AS coverage to Istanbul format\n * - Delegates JS coverage to Vitest's v8 provider\n * - Merges both into a unified coverage report\n */\nconst hybridProviderModule: CoverageProviderModule = {\n getProvider: (): HybridCoverageProvider => new HybridCoverageProvider(),\n\n startCoverage: async (runtimeOptions: {\n isolate: boolean\n }): Promise<unknown> => {\n if (v8CoverageModule.startCoverage) {\n return await v8CoverageModule.startCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n 'HybridCoverageProvider - v8 coverage module does not provide `startCoverage`',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n },\n \n takeCoverage: async (runtimeOptions?: any): Promise<unknown> => {\n if (v8CoverageModule.takeCoverage) {\n return await v8CoverageModule.takeCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n 'HybridCoverageProvider - v8 coverage module does not provide `takeCoverage`',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n },\n \n stopCoverage: async (runtimeOptions: {\n isolate: boolean\n }): Promise<unknown> => {\n if (v8CoverageModule.stopCoverage) {\n return await v8CoverageModule.stopCoverage(runtimeOptions);\n } else {\n throw createPoolError(\n 'HybridCoverageProvider - v8 coverage module does not provide `stopCoverage`',\n POOL_ERROR_NAMES.HybridCoverageProviderError\n );\n }\n },\n};\n\nexport default hybridProviderModule;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgB,+BACd,sBACA,MACA,QACsC;CACtC,IAAI;CACJ,IAAI,gBAAgB;CACpB,IAAI,kBAAkB;AAGtB,MAAK,MAAM,CAAC,cAAc,cAAc,OAAO,QAAQ,qBAAqB,EAAE;EAC5E,MAAM,YAAY,OAAO,aAAa;AACtC,MAAI,YAAY,KAAM;AAEtB,OAAK,MAAM,QAAQ,WAAW;GAC5B,MAAM,EAAE,UAAU;AAGlB,OAAI,CAAC,kBAAkB,MAAM,QAAQ,MAAM,CAAE;AAG7C,OAAI,YAAY,iBACX,cAAc,iBAAiB,MAAM,cAAc,iBAAkB;AACxE,gBAAY;AACZ,oBAAgB;AAChB,sBAAkB,MAAM;;;;AAK9B,QAAO;;;;;;;;;;AAWT,SAAgB,kBACd,MACA,QACA,OACS;AAET,KAAI,OAAO,MAAM,aAAa,OAAO,MAAM,QAAS,QAAO;AAG3D,KAAI,SAAS,MAAM,aAAa,SAAS,MAAM,YAAa,QAAO;AAGnE,KAAI,SAAS,MAAM,WAAW,SAAS,MAAM,UAAW,QAAO;AAE/D,QAAO;;;;;AC3ET,SAAS,cAAc,GAAG,MAAmB;;;;;;;;;;;;;;;;;;;AAwB7C,eAAsB,wBACpB,0BACA,yBACA,kBAC2B;CAC3B,MAAM,aAAa,YAAY,KAAK;AAEpC,qBAAoB;EAClB,MAAM,sBAAsB,OAAO,OAAO,yBAAyB,CAAC,QAAQ,KAAK,UAAU,MAAM,MAAM,QAAQ,EAAE;EACjH,MAAM,oBAAoB,OAAO,KAAK,wBAAwB,CAAC;AAG/D,SAAO,kDAAkD,iBAAiB,mCACvC,oBAAoB,8BAA8B,kBAAkB,yFAH9E,wBAAwB,IA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8DAA8D;;AAGtE,MAAI,KAAK,YAAY;AACnB,SAAM,KAAK,WAAW,MAAM,MAAM;AAClC,SAAM,uDAAuD,MAAM,GAAG;;;;;;;;;;;;;;;ACvQ5E,MAAM,uBAA+C;CACnD,mBAA2C,IAAI,wBAAwB;CAEvE,eAAe,OAAO,mBAEE;AACtB,MAAI,iBAAiB,cACnB,QAAO,MAAM,iBAAiB,cAAc,eAAe;MAE3D,OAAM,gBACJ,gFACA,iBAAiB,4BAClB;;CAIL,cAAc,OAAO,mBAA2C;AAC9D,MAAI,iBAAiB,aACnB,QAAO,MAAM,iBAAiB,aAAa,eAAe;MAE1D,OAAM,gBACJ,+EACA,iBAAiB,4BAClB;;CAIL,cAAc,OAAO,mBAEG;AACtB,MAAI,iBAAiB,aACnB,QAAO,MAAM,iBAAiB,aAAa,eAAe;MAE1D,OAAM,gBACJ,+EACA,iBAAiB,4BAClB;;CAGN;AAED,gCAAe"}
package/dist/index.mjs CHANGED
@@ -3,6 +3,6 @@ import "./debug-IeEHsxy0.mjs";
3
3
  import "./vitest-file-tasks-BUwzh375.mjs";
4
4
  import "./vitest-tasks-BKS7689f.mjs";
5
5
  import "./worker-rpc-channel-lbhK7Qz8.mjs";
6
- import { createAssemblyScriptPool } from "./pool-runner-init-d5qScS41.mjs";
6
+ import { createAssemblyScriptPool } from "./pool-runner-init-Kuzz61rB.mjs";
7
7
 
8
8
  export { createAssemblyScriptPool };
@@ -50,7 +50,7 @@ var AssemblyScriptPoolWorker = class {
50
50
  if (results[0].status === "rejected") failedThreadAccess.push(COMPILE_WORKER_PATH);
51
51
  if (results[1].status === "rejected") failedThreadAccess.push(TEST_WORKER_PATH);
52
52
  if (failedThreadAccess.length) throw new Error(`Cannot access worker thread file(s) at path(s): ${failedThreadAccess}`);
53
- if (results[2].status === "rejected") throw new Error(`Cannot access user WasmImportsFactory at path: "${userImportsFactoryPath}". Ensure that your module path is relative to the project root (location of shallowest vitest config), and that it has a default export matching () => WebAssembly.Imports`);
53
+ if (results[2].status === "rejected") throw new Error(`Cannot access user WasmImportsFactory at path: "${userImportsFactoryPath}". Ensure that your module path is relative to the vitest project root (location of shallowest vitest config), and that it has a default export matching () => WebAssembly.Imports`);
54
54
  });
55
55
  setGlobalDebugMode(this.asPoolOptions.debug);
56
56
  debug(`[${this.logModule}] Created AssemblyScriptPoolWorker in ${(performance.now() - start).toFixed(2)} ms | method: "${this.poolOptions.method}" | project: "${this.poolOptions.project.name}"`);
@@ -397,4 +397,4 @@ function createAssemblyScriptPool(userPoolOptions) {
397
397
 
398
398
  //#endregion
399
399
  export { createAssemblyScriptPool };
400
- //# sourceMappingURL=pool-runner-init-d5qScS41.mjs.map
400
+ //# sourceMappingURL=pool-runner-init-Kuzz61rB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool-runner-init-Kuzz61rB.mjs","names":[],"sources":["../src/pool/pool-worker.ts","../src/pool/pool-runner-init.ts"],"sourcesContent":["import { availableParallelism } from 'node:os';\nimport { resolve } from 'node:path';\nimport { access } from 'node:fs/promises';\nimport type { MessagePort } from 'node:worker_threads';\nimport type { Test } from '@vitest/runner/types';\nimport type { SerializedConfig } from 'vitest';\nimport type { PoolWorker, PoolOptions, WorkerRequest, PoolTask, WorkerResponse } from 'vitest/node';\nimport Tinypool from 'tinypool';\n\nimport type {\n AssemblyScriptPoolWorkerMessage,\n ResolvedAssemblyScriptPoolOptions,\n ResolvedHybridProviderOptions,\n RunCompileAndDiscoverTask,\n RunTestsTask,\n TestExecutionEnd,\n TestExecutionStart,\n TestRunRecord,\n ThreadSpec,\n WorkerThreadInitData,\n} from '../types/types.js';\nimport { createInitialFileTask } from '../util/vitest-file-tasks.js';\nimport { failTestWithTimeoutError, flagTestTerminated } from '../util/vitest-tasks.js';\nimport {\n AS_POOL_WORKER_MSG_FLAG,\n ASSEMBLYSCRIPT_POOL_NAME,\n POOL_ERROR_NAMES,\n VITEST_WORKER_RESPONSE_MSG_FLAG\n} from '../types/constants.js';\nimport { debug, setGlobalDebugMode } from '../util/debug.js';\nimport { createPoolError, createPoolErrorFromAnyError, isAbortError } from '../util/pool-errors.js';\nimport { createWorkerRPCChannel } from './worker-rpc-channel.js';\n\ntype GlobalThreadPools = { compilePool: Tinypool, runPool: Tinypool };\ntype EventCallback = (arg: any) => void;\n\nconst THREAD_RESOLVE_TIMEOUT_MS = 2000 as const;\nconst POOL_THREAD_IDLE_TIMEOUT_MS = 3_600_000 as const;\nconst IDLE_RUN_THREADS_FACTOR = 1 as const;\n// @ts-ignore - see note in getGlobalThreadPools\nconst IDLE_COMPILE_THREADS_FACTOR = 0.25 as const;\n\n// path assumes that we're running from dist/\nconst COMPILE_WORKER_PATH = resolve(import.meta.dirname, 'pool-thread/compile-worker-thread.mjs');\nconst TEST_WORKER_PATH = resolve(import.meta.dirname, 'pool-thread/test-worker-thread.mjs');\n\nvar GLOBAL_POOLS_PROMISE: Promise<GlobalThreadPools> | undefined;\nvar GLOBAL_POOL_ABORT_CONTROLLER: AbortController | undefined;\nvar GLOBAL_RUNNING_POOLWORKER_COUNT: number = 0;\n\nexport class AssemblyScriptPoolWorker implements PoolWorker {\n readonly logModule = 'PoolWorker' as const;\n readonly name: typeof ASSEMBLYSCRIPT_POOL_NAME = ASSEMBLYSCRIPT_POOL_NAME;\n readonly poolOptions: PoolOptions;\n readonly asPoolOptions: ResolvedAssemblyScriptPoolOptions;\n readonly asCoverageOptions: ResolvedHybridProviderOptions;\n\n // for the currently running thread preforming a test run (if any)\n private threadAbortController: AbortController | undefined;\n private threadControlPort: MessagePort | undefined;\n private threadRunPromise: Promise<void> | undefined;\n\n private threadSpecs: ThreadSpec[] = [];\n \n // cached data for possible timeout resume\n private currentTestRun: TestRunRecord | undefined;\n \n // for this particular PoolWorker instance (1 per `maxWorkers`)\n private currentWorkerId: number | undefined;\n private isWorkerRunning: boolean = false;\n private config: SerializedConfig | undefined; // provided with \"start\" message\n\n // registry holding vitest callbacks so we can communicate on behalf of the worker thread\n private listenerRegistry: Map<string, Set<EventCallback>>;\n\n constructor(\n options: PoolOptions,\n resolvedUserPoolOptions: ResolvedAssemblyScriptPoolOptions,\n resolvedCoverageOptions: ResolvedHybridProviderOptions,\n ) {\n const start = performance.now();\n\n this.poolOptions = options;\n this.asPoolOptions = resolvedUserPoolOptions;\n this.asCoverageOptions = resolvedCoverageOptions;\n this.listenerRegistry = new Map<string, Set<EventCallback>>();\n\n setImmediate(async () => {\n const userImportsFactoryPath = resolve(\n this.poolOptions.project.config.root,\n this.asPoolOptions.wasmImportsFactory ?? ''\n );\n\n const results = await Promise.allSettled([\n access(COMPILE_WORKER_PATH),\n access(TEST_WORKER_PATH),\n this.asPoolOptions.wasmImportsFactory ? access(userImportsFactoryPath) : Promise.resolve()\n ]);\n\n const failedThreadAccess: string[] = [];\n if (results[0].status === 'rejected') failedThreadAccess.push(COMPILE_WORKER_PATH);\n if (results[1].status === 'rejected') failedThreadAccess.push(TEST_WORKER_PATH);\n\n if (failedThreadAccess.length) {\n throw new Error(`Cannot access worker thread file(s) at path(s): ${failedThreadAccess}`);\n }\n if (results[2].status === 'rejected') {\n throw new Error(`Cannot access user WasmImportsFactory at path: \"${userImportsFactoryPath}\".`\n + ` Ensure that your module path is relative to the vitest project root (location of shallowest vitest config),`\n + ` and that it has a default export matching () => WebAssembly.Imports`\n );\n }\n });\n \n setGlobalDebugMode(this.asPoolOptions.debug);\n\n debug(`[${this.logModule}] Created AssemblyScriptPoolWorker in ${(performance.now() - start).toFixed(2)} ms`\n + ` | method: \"${this.poolOptions.method}\" | project: \"${this.poolOptions.project.name}\"`\n );\n }\n\n private get isCollectTestsMode(): boolean {\n return this.poolOptions.method === 'collect';\n }\n\n async start(): Promise<void> {\n // do all work in send() message intercept handler so we have access to the config\n }\n\n async stop(): Promise<void> {\n debug(`[${this.logModuleWithId}] stop | running PoolWorker count: ${GLOBAL_RUNNING_POOLWORKER_COUNT}`);\n\n this.listenerRegistry.clear();\n GLOBAL_RUNNING_POOLWORKER_COUNT--;\n this.isWorkerRunning = false;\n\n debug(`[${this.logModuleWithId}] AssemblyScriptPoolWorker STOPPED | running PoolWorker count: ${GLOBAL_RUNNING_POOLWORKER_COUNT}`);\n this.currentWorkerId = undefined;\n }\n\n send(message: WorkerRequest): void {\n switch(message.type) {\n \n // this happens AFTER start() is called (start() is for PoolWorker, \"start\" is for thread)\n case 'start':\n this.currentWorkerId = message.workerId;\n this.config = message.context.config;\n debug(`[${this.logModuleWithId}] send: vitest sent \"start\" message | Captured workerId and config`);\n\n setImmediate(async () => {\n const start = performance.now();\n const { compilePool, runPool } = await this.getGlobalThreadPools(this.config?.maxWorkers);\n \n debug(`[${this.logModuleWithId}] start: fetched global thread pools in ${(performance.now() - start).toFixed(2)} ms`\n + ` | compilePool queueSize: ${compilePool.queueSize} | runPool queueSize: ${runPool.queueSize}`\n );\n \n this.isWorkerRunning = true;\n GLOBAL_RUNNING_POOLWORKER_COUNT++;\n debug(`[${this.logModuleWithId}] start | new running PoolWorker count: ${GLOBAL_RUNNING_POOLWORKER_COUNT}`);\n \n this.notifyVitest('started');\n debug(`[${this.logModuleWithId}] send: responded \"started\" to vitest`);\n });\n \n break;\n \n // this happens BEFORE stop() is called (stop() is for PoolWorker, \"stop\" is for thread)\n case 'stop':\n setImmediate(async () => {\n await this.stopThread();\n this.notifyVitest('stopped');\n });\n break;\n \n case 'cancel':\n debug(`[${this.logModuleWithId}] send: got \"cancel\" unexpectedly`, message);\n break;\n \n case 'collect':\n case 'run':\n this.currentWorkerId = message.context.workerId;\n this.threadSpecs = message.context.files.map((fileSpec): ThreadSpec => ({\n file: createInitialFileTask(\n fileSpec.filepath,\n this.config!.name ?? '',\n this.config!.root,\n this.config!.testTimeout,\n this.config!.retry\n )\n }));\n\n debug(`[${this.logModuleWithId}] send: vitest sent \"${message.type}\" message`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n\n setImmediate(async () => {\n debug(`[${this.logModuleWithId}] send: dispatched \"${message.type}\" job to worker thread`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n \n this.threadRunPromise = this.orchestrateFileRuns();\n\n try {\n await this.threadRunPromise;\n this.notifyVitest('testfileFinished');\n debug(`[${this.logModuleWithId}] send: responded \"testfileFinished\" to vitest`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n\n this.threadSpecs = [];\n } catch (error) {\n if (!isAbortError(error)) {\n throw createPoolErrorFromAnyError(`PoolWorker send() \"${message.type}\"`, POOL_ERROR_NAMES.PoolError, error);\n }\n } finally {\n this.threadControlPort?.close();\n this.threadAbortController = undefined;\n this.threadControlPort = undefined;\n this.threadRunPromise = undefined;\n }\n });\n break;\n }\n }\n\n on(event: string, callback: EventCallback): void {\n this.addEventCallback(event, callback);\n debug(`[${this.logModuleWithId}] ON \"${event}\" - saved listener`);\n }\n\n off(event: string, callback: EventCallback): void {\n if (this.removeEventCallback(event, callback)) {\n debug(`[${this.logModuleWithId}] OFF \"${event}\" - removed callback from registry`);\n } else {\n debug(`[${this.logModuleWithId}] OFF \"${event}\" - callback not found in registry`);\n }\n }\n\n deserialize(data: unknown): unknown {\n return data;\n }\n\n canReuse(_task: PoolTask): boolean {\n return true;\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Thread Pool Management\n // ─────────────────────────────────────────────────────────────────────────────\n\n private async getGlobalThreadPools(workerCount?: number): Promise<GlobalThreadPools> {\n if (GLOBAL_POOLS_PROMISE) {\n return GLOBAL_POOLS_PROMISE;\n }\n\n GLOBAL_POOLS_PROMISE = new Promise<GlobalThreadPools>(async (resolve, _reject) => {\n const workers = workerCount ?? availableParallelism();\n\n // TODO - decide which is better when scaling\n // Empirical observations seem to show that minimum parallelization for compilation\n // tends to *dramatically* improve compilation times because of v8 warmpup on repeated calls to asc.main,\n // so much so that this time savings **almost always** outweighs the benefits of speading over many\n // available threads. The **almost** is the key word here- this needs to be tested on platforms with\n // higher available paralellism (> 8) to see if it holds true.\n const actualCompileThreadCount = workers > 1 ? 2 : 1;\n // const actualCompileThreadCount = Math.max(Math.ceil(workers * IDLE_COMPILE_THREADS_FACTOR), 1);\n\n debug(`[${this.logModuleWithId}] Creating global compile thread pool | ${actualCompileThreadCount} threads`);\n \n const start = performance.now();\n \n const compilePool = new Tinypool({\n filename: COMPILE_WORKER_PATH,\n minThreads: 1,\n maxThreads: actualCompileThreadCount,\n isolateWorkers: false,\n idleTimeout: POOL_THREAD_IDLE_TIMEOUT_MS,\n env: this.poolOptions.env as Record<string, string>,\n execArgv: this.poolOptions.execArgv,\n workerData: {\n asPoolOptions: this.asPoolOptions,\n asCoverageOptions: this.asCoverageOptions,\n projectRoot: this.poolOptions.project.config.root,\n } satisfies WorkerThreadInitData\n });\n\n const actualRunThreadCount = Math.max(Math.ceil(workers * IDLE_RUN_THREADS_FACTOR), 1);\n debug(`[${this.logModuleWithId}] Creating global run thread pool | ${actualRunThreadCount} threads`);\n\n const runPool = new Tinypool({\n filename: TEST_WORKER_PATH,\n minThreads: 1,\n maxThreads: actualRunThreadCount,\n isolateWorkers: false,\n idleTimeout: POOL_THREAD_IDLE_TIMEOUT_MS,\n env: this.poolOptions.env as Record<string, string>,\n execArgv: this.poolOptions.execArgv,\n workerData: {\n asPoolOptions: this.asPoolOptions,\n asCoverageOptions: this.asCoverageOptions,\n projectRoot: this.poolOptions.project.config.root\n } satisfies WorkerThreadInitData\n });\n\n debug(`[${this.logModuleWithId}] Created global thread pools in ${(performance.now() - start).toFixed(2)} ms`);\n\n GLOBAL_POOL_ABORT_CONTROLLER = new AbortController();\n resolve({ compilePool, runPool });\n });\n \n return GLOBAL_POOLS_PROMISE;\n }\n\n // @ts-ignore\n private async destroyGlobalPoolsIfNeeded(): Promise<void> {\n if (GLOBAL_RUNNING_POOLWORKER_COUNT === 0 && GLOBAL_POOLS_PROMISE) {\n const destroyStart = performance.now();\n debug(`[${this.logModuleWithId}] Destroying Tinypools...`);\n\n try {\n const { compilePool, runPool } = await GLOBAL_POOLS_PROMISE;\n await Promise.all([ compilePool.destroy(), runPool.destroy() ]);\n } catch {}\n\n GLOBAL_POOLS_PROMISE = undefined;\n GLOBAL_POOL_ABORT_CONTROLLER = undefined;\n\n debug(`[${this.logModuleWithId}] Destroyed tinypools in ${(performance.now() - destroyStart).toFixed(2)} ms`);\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Listener Registry Helpers\n // ─────────────────────────────────────────────────────────────────────────────\n\n private getEventCallbacks(event: string): Set<EventCallback> {\n let callbacks: Set<EventCallback> | undefined = this.listenerRegistry.get(event);\n if (!callbacks) {\n callbacks = new Set<EventCallback>();\n this.listenerRegistry.set(event, callbacks);\n }\n return callbacks;\n }\n\n private addEventCallback(event: string, callback: EventCallback): void {\n this.getEventCallbacks(event).add(callback);\n }\n \n private removeEventCallback(event: string, callback: EventCallback): boolean {\n const callbacks = this.getEventCallbacks(event);\n if (callbacks) {\n return callbacks.delete(callback);\n } else {\n return false;\n }\n }\n\n private notifyVitest(responseType: WorkerResponse['type']): void {\n const messageCallbacks = this.getEventCallbacks('message');\n for (const cb of messageCallbacks) {\n cb({ type: responseType, [VITEST_WORKER_RESPONSE_MSG_FLAG]: true } satisfies WorkerResponse)\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Worker Thread Control/Orchestration\n // ─────────────────────────────────────────────────────────────────────────────\n \n private async dispatchCompile(\n spec: ThreadSpec,\n compilePool: Tinypool,\n ): Promise<void> {\n const { workerPort, poolPort } = createWorkerRPCChannel(this.poolOptions.project, this.isCollectTestsMode);\n this.threadControlPort = poolPort;\n \n const compilePromise: Promise<ThreadSpec> = compilePool.run({\n dispatchStart: Date.now(),\n workerId: this.currentWorkerId!,\n port: workerPort,\n file: spec.file,\n config: this.config!,\n isCollectTestsMode: this.isCollectTestsMode,\n } satisfies RunCompileAndDiscoverTask, {\n name: 'runCompileAndDisoverSpec',\n transferList: [workerPort],\n signal: GLOBAL_POOL_ABORT_CONTROLLER!.signal,\n });\n\n try {\n const { compilation, file } = await compilePromise;\n spec.file = file;\n spec.compilation = compilation;\n } finally {\n this.threadControlPort.close();\n this.threadControlPort = undefined;\n }\n }\n \n private async dispatchRunTests(\n spec: ThreadSpec,\n runPool: Tinypool,\n timedOutTest?: Test,\n ): Promise<void> {\n const { workerPort, poolPort } = createWorkerRPCChannel(this.poolOptions.project, this.isCollectTestsMode);\n \n this.threadAbortController = new AbortController();\n this.threadControlPort = poolPort;\n this.threadControlPort.on('message', this.getWorkerThreadMessageHandler());\n\n const runPromise: Promise<void> = !spec.compilation ? Promise.resolve() : runPool.run({\n dispatchStart: Date.now(),\n workerId: this.currentWorkerId!,\n port: workerPort,\n file: timedOutTest?.file ?? spec.file,\n compilation: spec.compilation,\n config: this.config!,\n isCollectTestsMode: this.isCollectTestsMode,\n timedOutTest,\n } satisfies RunTestsTask, {\n name: 'runFileSpec',\n transferList: [workerPort],\n signal: AbortSignal.any([this.threadAbortController.signal, GLOBAL_POOL_ABORT_CONTROLLER!.signal]),\n });\n\n try {\n return await runPromise;\n } finally {\n this.threadControlPort.close();\n this.threadControlPort = undefined;\n }\n }\n\n private async orchestrateFileRuns(timedOutTest?: Test): Promise<void> {\n const modeStr = this.isCollectTestsMode ? 'collectTests' : 'runTests';\n const isResume: boolean = !!timedOutTest;\n const desc = `${modeStr} ${isResume ? '(RESUME)' : '(INITIAL)'}`;\n\n debug(`[${this.logModuleWithId}] orchestrateFileRuns: dispatching ${desc} to worker thread`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n\n const { compilePool, runPool } = await this.getGlobalThreadPools(this.config?.maxWorkers);\n\n // compile\n if (!isResume) {\n await Promise.all(\n this.threadSpecs.map(spec => this.dispatchCompile(spec, compilePool))\n );\n }\n\n // test\n if (!this.isCollectTestsMode) {\n await Promise.all(\n this.threadSpecs.map(spec => this.dispatchRunTests(spec, runPool, timedOutTest))\n );\n }\n\n debug(`[${this.logModuleWithId}] orchestrateFileRuns: ${desc} thread work complete`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n }\n\n private async stopThread(): Promise<void> {\n this.clearTestTimeoutTimer(); // if any\n this.currentTestRun = undefined;\n \n const mod = this.logModuleWithId;\n const start = performance.now();\n\n debug('setting graceful resolve timeout');\n const abortTimeout = setTimeout(() => {\n debug(`[${mod}] stop: timed out waiting on pool worker run resolve ${(performance.now() - start).toFixed(2)} ms | Aborting thread`);\n this.threadAbortController?.abort();\n }, THREAD_RESOLVE_TIMEOUT_MS);\n \n try {\n debug(`[${mod}] stop: awaiting pool worker run resolve: ${!!this.threadRunPromise}`);\n await this.threadRunPromise;\n clearTimeout(abortTimeout);\n debug(`[${this.logModuleWithId}] stop: pool worker run resolved cleanly after ${(performance.now() - start).toFixed(2)} ms`);\n } catch {\n } finally {\n this.threadControlPort?.close();\n debug(`[${this.logModuleWithId}] stop: closed pool port`);\n }\n \n this.threadAbortController = undefined;\n this.threadControlPort = undefined;\n this.threadRunPromise = undefined;\n this.threadSpecs = [];\n }\n\n private getWorkerThreadMessageHandler(): EventCallback {\n return (message: any): void => {\n if (message[AS_POOL_WORKER_MSG_FLAG]) {\n const poolMessage = message as AssemblyScriptPoolWorkerMessage;\n\n switch (poolMessage.type) {\n case 'execution-start':\n this.handleTestExecutionStart(message);\n break;\n case 'execution-end':\n this.handleTestExecutionEnd(message);\n break;\n }\n\n return;\n }\n };\n }\n\n private handleTestExecutionStart(msg: TestExecutionStart): void {\n if (!this.isWorkerRunning) return;\n \n const { executionStart, test } = msg;\n const now = Date.now();\n const transitDuration = now - executionStart;\n const adjustedTimeout = Math.max(test.timeout - transitDuration, 0);\n\n this.currentTestRun = {\n test,\n executionStart,\n timeoutId: setTimeout(() => this.handleTimeout(), adjustedTimeout)\n };\n\n debug(`[${this.logModuleWithId}] START test timeout timer for \"${this.currentTestRun.test.name}\"`);\n }\n\n private handleTestExecutionEnd(_msg: TestExecutionEnd): void {\n this.clearTestTimeoutTimer();\n this.currentTestRun = undefined;\n }\n\n private clearTestTimeoutTimer(): void {\n if (this.currentTestRun) {\n const elapsed = Date.now() - this.currentTestRun.executionStart;\n debug(`[${this.logModuleWithId}] CLEAR test timeout timer (${elapsed.toFixed(2)} ms) for \"${this.currentTestRun?.test.name}\"`);\n clearTimeout(this.currentTestRun.timeoutId);\n }\n }\n\n private async handleTimeout(): Promise<void> {\n if (!this.isWorkerRunning) return;\n\n if (!this.threadSpecs.length || !this.currentTestRun || !this.currentTestRun.test) {\n const missingStr = \n + (this.threadSpecs.length ? '' : 'threadSpecs')\n + (this.currentTestRun ? '' : ' currentTestRecord')\n + (this.currentTestRun?.test ? '' : ' currentTestRecord.test')\n throw createPoolError(\n `Cannot timeout/resume worker thread for workerId ${this.currentWorkerId} - missing data: ${missingStr}`,\n POOL_ERROR_NAMES.PoolError\n );\n }\n\n const duration = Date.now() - this.currentTestRun.executionStart;\n failTestWithTimeoutError(this.currentTestRun.test, this.currentTestRun.executionStart, duration);\n\n // set termination time metadata for measuring resume latency\n flagTestTerminated(this.currentTestRun.test);\n\n debug(`[${this.logModuleWithId}] handleTimeout: TEST TIMEOUT \"${this.currentTestRun.test.name}\" after ${duration.toFixed(2)} ms`\n +` - Terminating worker thread job`\n );\n\n const termStart = performance.now();\n \n try {\n this.threadAbortController?.abort();\n await this.threadRunPromise;\n } catch (error) {\n if (!isAbortError(error)) {\n throw createPoolErrorFromAnyError(`PoolWorker handleTimeout`, POOL_ERROR_NAMES.PoolError, error);\n }\n } finally {\n this.threadControlPort?.close();\n this.threadAbortController = undefined;\n this.threadControlPort = undefined;\n this.threadRunPromise = undefined;\n }\n\n debug(`[${this.logModuleWithId}] handleTimeout: Worker thread job aborted for timeout in ${(performance.now() - termStart).toFixed(2)} ms`);\n \n if (!this.isWorkerRunning) return;\n\n // supply timed-out test (includes entire file hierarchy & coverage)\n // to resume testing where we leftoff when aborting for timeout\n this.threadRunPromise = this.orchestrateFileRuns(this.currentTestRun.test);\n\n debug(`[${this.logModuleWithId}] handleTimeout: re-dispatched job to worker thread`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n\n try {\n await this.threadRunPromise;\n this.notifyVitest('testfileFinished');\n debug(`[${this.logModuleWithId}] handleTimeout: file run completed - responded \"testfileFinished\" to vitest`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n \n this.threadSpecs = [];\n } catch (error) {\n if (!isAbortError(error)) {\n throw createPoolErrorFromAnyError(`PoolWorker handleTimeout`, POOL_ERROR_NAMES.PoolError, error);\n } else {\n debug(`[${this.logModuleWithId}] send: caught and ignored timeout awaiting timeout re-run`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n }\n } finally {\n //@ts-ignore\n this.threadControlPort?.close();\n this.threadControlPort = undefined;\n this.threadAbortController = undefined;\n this.threadRunPromise = undefined;\n }\n }\n\n private get logModuleWithId(): string {\n return `${this.logModule}${this.currentWorkerId === undefined ? '' : ` ${this.currentWorkerId}`}`;\n }\n}\n","import type { PoolOptions, PoolRunnerInitializer } from 'vitest/node';\n\nimport type {\n AssemblyScriptPoolOptions,\n ResolvedHybridProviderOptions\n} from '../types/types.js';\nimport { ASSEMBLYSCRIPT_POOL_NAME } from '../types/constants.js';\nimport { resolvePoolOptions } from '../util/resolve-config.js';\nimport { AssemblyScriptPoolWorker } from './pool-worker.js';\n\nexport function createAssemblyScriptPool(userPoolOptions?: AssemblyScriptPoolOptions): PoolRunnerInitializer {\n const resolvedUserPoolOptions = resolvePoolOptions(userPoolOptions);\n\n return {\n name: ASSEMBLYSCRIPT_POOL_NAME,\n createPoolWorker: (opts: PoolOptions) => {\n const resolvedCoverageOptions = opts.project.config.coverage as ResolvedHybridProviderOptions;\n return new AssemblyScriptPoolWorker(opts, resolvedUserPoolOptions, resolvedCoverageOptions);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;AAoCA,MAAM,4BAA4B;AAClC,MAAM,8BAA8B;AACpC,MAAM,0BAA0B;AAKhC,MAAM,sBA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,oBAAoB,KAAK,eAAe,KAAK;AAE1E,QAAM,IAAI,KAAK,gBAAgB,gEACb,KAAK,YAAY,KAAI,MAAK,EAAE,KAAK,SAAS,CAAC,KAAK,IAAI,CAAC,GACtE;AAED,MAAI;AACF,SAAM,KAAK;AACX,QAAK,aAAa,mBAAmB;AACrC,SAAM,IAAI,KAAK,gBAAgB,yFACb,KAAK,YAAY,KAAI,MAAK,EAAE,KAAK,SAAS,CAAC,KAAK,IAAI,CAAC,GACtE;AAED,QAAK,cAAc,EAAE;WACd,OAAO;AACd,OAAI,CAAC,aAAa,MAAM,CACtB,OAAM,4BAA4B,4BAA4B,iBAAiB,WAAW,MAAM;OAEhG,OAAM,IAAI,KAAK,gBAAgB,uEACb,KAAK,YAAY,KAAI,MAAK,EAAE,KAAK,SAAS,CAAC,KAAK,IAAI,CAAC,GACtE;YAEK;AAER,QAAK,mBAAmB,OAAO;AAC/B,QAAK,oBAAoB;AACzB,QAAK,wBAAwB;AAC7B,QAAK,mBAAmB;;;CAI5B,IAAY,kBAA0B;AACpC,SAAO,GAAG,KAAK,YAAY,KAAK,oBAAoB,SAAY,KAAK,IAAI,KAAK;;;;;;AClmBlF,SAAgB,yBAAyB,iBAAoE;CAC3G,MAAM,0BAA0B,mBAAmB,gBAAgB;AAEnE,QAAO;EACL;EACA,mBAAmB,SAAsB;GACvC,MAAM,0BAA0B,KAAK,QAAQ,OAAO;AACpD,UAAO,IAAI,yBAAyB,MAAM,yBAAyB,wBAAwB;;EAE9F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-pool-assemblyscript",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
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":"pool-runner-init-d5qScS41.mjs","names":[],"sources":["../src/pool/pool-worker.ts","../src/pool/pool-runner-init.ts"],"sourcesContent":["import { availableParallelism } from 'node:os';\nimport { resolve } from 'node:path';\nimport { access } from 'node:fs/promises';\nimport type { MessagePort } from 'node:worker_threads';\nimport type { Test } from '@vitest/runner/types';\nimport type { SerializedConfig } from 'vitest';\nimport type { PoolWorker, PoolOptions, WorkerRequest, PoolTask, WorkerResponse } from 'vitest/node';\nimport Tinypool from 'tinypool';\n\nimport type {\n AssemblyScriptPoolWorkerMessage,\n ResolvedAssemblyScriptPoolOptions,\n ResolvedHybridProviderOptions,\n RunCompileAndDiscoverTask,\n RunTestsTask,\n TestExecutionEnd,\n TestExecutionStart,\n TestRunRecord,\n ThreadSpec,\n WorkerThreadInitData,\n} from '../types/types.js';\nimport { createInitialFileTask } from '../util/vitest-file-tasks.js';\nimport { failTestWithTimeoutError, flagTestTerminated } from '../util/vitest-tasks.js';\nimport {\n AS_POOL_WORKER_MSG_FLAG,\n ASSEMBLYSCRIPT_POOL_NAME,\n POOL_ERROR_NAMES,\n VITEST_WORKER_RESPONSE_MSG_FLAG\n} from '../types/constants.js';\nimport { debug, setGlobalDebugMode } from '../util/debug.js';\nimport { createPoolError, createPoolErrorFromAnyError, isAbortError } from '../util/pool-errors.js';\nimport { createWorkerRPCChannel } from './worker-rpc-channel.js';\n\ntype GlobalThreadPools = { compilePool: Tinypool, runPool: Tinypool };\ntype EventCallback = (arg: any) => void;\n\nconst THREAD_RESOLVE_TIMEOUT_MS = 2000 as const;\nconst POOL_THREAD_IDLE_TIMEOUT_MS = 3_600_000 as const;\nconst IDLE_RUN_THREADS_FACTOR = 1 as const;\n// @ts-ignore - see note in getGlobalThreadPools\nconst IDLE_COMPILE_THREADS_FACTOR = 0.25 as const;\n\n// path assumes that we're running from dist/\nconst COMPILE_WORKER_PATH = resolve(import.meta.dirname, 'pool-thread/compile-worker-thread.mjs');\nconst TEST_WORKER_PATH = resolve(import.meta.dirname, 'pool-thread/test-worker-thread.mjs');\n\nvar GLOBAL_POOLS_PROMISE: Promise<GlobalThreadPools> | undefined;\nvar GLOBAL_POOL_ABORT_CONTROLLER: AbortController | undefined;\nvar GLOBAL_RUNNING_POOLWORKER_COUNT: number = 0;\n\nexport class AssemblyScriptPoolWorker implements PoolWorker {\n readonly logModule = 'PoolWorker' as const;\n readonly name: typeof ASSEMBLYSCRIPT_POOL_NAME = ASSEMBLYSCRIPT_POOL_NAME;\n readonly poolOptions: PoolOptions;\n readonly asPoolOptions: ResolvedAssemblyScriptPoolOptions;\n readonly asCoverageOptions: ResolvedHybridProviderOptions;\n\n // for the currently running thread preforming a test run (if any)\n private threadAbortController: AbortController | undefined;\n private threadControlPort: MessagePort | undefined;\n private threadRunPromise: Promise<void> | undefined;\n\n private threadSpecs: ThreadSpec[] = [];\n \n // cached data for possible timeout resume\n private currentTestRun: TestRunRecord | undefined;\n \n // for this particular PoolWorker instance (1 per `maxWorkers`)\n private currentWorkerId: number | undefined;\n private isWorkerRunning: boolean = false;\n private config: SerializedConfig | undefined; // provided with \"start\" message\n\n // registry holding vitest callbacks so we can communicate on behalf of the worker thread\n private listenerRegistry: Map<string, Set<EventCallback>>;\n\n constructor(\n options: PoolOptions,\n resolvedUserPoolOptions: ResolvedAssemblyScriptPoolOptions,\n resolvedCoverageOptions: ResolvedHybridProviderOptions,\n ) {\n const start = performance.now();\n\n this.poolOptions = options;\n this.asPoolOptions = resolvedUserPoolOptions;\n this.asCoverageOptions = resolvedCoverageOptions;\n this.listenerRegistry = new Map<string, Set<EventCallback>>();\n\n setImmediate(async () => {\n const userImportsFactoryPath = resolve(\n this.poolOptions.project.config.root,\n this.asPoolOptions.wasmImportsFactory ?? ''\n );\n\n const results = await Promise.allSettled([\n access(COMPILE_WORKER_PATH),\n access(TEST_WORKER_PATH),\n this.asPoolOptions.wasmImportsFactory ? access(userImportsFactoryPath) : Promise.resolve()\n ]);\n\n const failedThreadAccess: string[] = [];\n if (results[0].status === 'rejected') failedThreadAccess.push(COMPILE_WORKER_PATH);\n if (results[1].status === 'rejected') failedThreadAccess.push(TEST_WORKER_PATH);\n\n if (failedThreadAccess.length) {\n throw new Error(`Cannot access worker thread file(s) at path(s): ${failedThreadAccess}`);\n }\n if (results[2].status === 'rejected') {\n throw new Error(`Cannot access user WasmImportsFactory at path: \"${userImportsFactoryPath}\".`\n + ` Ensure that your module path is relative to the project root (location of shallowest vitest config),`\n + ` and that it has a default export matching () => WebAssembly.Imports`\n );\n }\n });\n \n setGlobalDebugMode(this.asPoolOptions.debug);\n\n debug(`[${this.logModule}] Created AssemblyScriptPoolWorker in ${(performance.now() - start).toFixed(2)} ms`\n + ` | method: \"${this.poolOptions.method}\" | project: \"${this.poolOptions.project.name}\"`\n );\n }\n\n private get isCollectTestsMode(): boolean {\n return this.poolOptions.method === 'collect';\n }\n\n async start(): Promise<void> {\n // do all work in send() message intercept handler so we have access to the config\n }\n\n async stop(): Promise<void> {\n debug(`[${this.logModuleWithId}] stop | running PoolWorker count: ${GLOBAL_RUNNING_POOLWORKER_COUNT}`);\n\n this.listenerRegistry.clear();\n GLOBAL_RUNNING_POOLWORKER_COUNT--;\n this.isWorkerRunning = false;\n\n debug(`[${this.logModuleWithId}] AssemblyScriptPoolWorker STOPPED | running PoolWorker count: ${GLOBAL_RUNNING_POOLWORKER_COUNT}`);\n this.currentWorkerId = undefined;\n }\n\n send(message: WorkerRequest): void {\n switch(message.type) {\n \n // this happens AFTER start() is called (start() is for PoolWorker, \"start\" is for thread)\n case 'start':\n this.currentWorkerId = message.workerId;\n this.config = message.context.config;\n debug(`[${this.logModuleWithId}] send: vitest sent \"start\" message | Captured workerId and config`);\n\n setImmediate(async () => {\n const start = performance.now();\n const { compilePool, runPool } = await this.getGlobalThreadPools(this.config?.maxWorkers);\n \n debug(`[${this.logModuleWithId}] start: fetched global thread pools in ${(performance.now() - start).toFixed(2)} ms`\n + ` | compilePool queueSize: ${compilePool.queueSize} | runPool queueSize: ${runPool.queueSize}`\n );\n \n this.isWorkerRunning = true;\n GLOBAL_RUNNING_POOLWORKER_COUNT++;\n debug(`[${this.logModuleWithId}] start | new running PoolWorker count: ${GLOBAL_RUNNING_POOLWORKER_COUNT}`);\n \n this.notifyVitest('started');\n debug(`[${this.logModuleWithId}] send: responded \"started\" to vitest`);\n });\n \n break;\n \n // this happens BEFORE stop() is called (stop() is for PoolWorker, \"stop\" is for thread)\n case 'stop':\n setImmediate(async () => {\n await this.stopThread();\n this.notifyVitest('stopped');\n });\n break;\n \n case 'cancel':\n debug(`[${this.logModuleWithId}] send: got \"cancel\" unexpectedly`, message);\n break;\n \n case 'collect':\n case 'run':\n this.currentWorkerId = message.context.workerId;\n this.threadSpecs = message.context.files.map((fileSpec): ThreadSpec => ({\n file: createInitialFileTask(\n fileSpec.filepath,\n this.config!.name ?? '',\n this.config!.root,\n this.config!.testTimeout,\n this.config!.retry\n )\n }));\n\n debug(`[${this.logModuleWithId}] send: vitest sent \"${message.type}\" message`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n\n setImmediate(async () => {\n debug(`[${this.logModuleWithId}] send: dispatched \"${message.type}\" job to worker thread`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n \n this.threadRunPromise = this.orchestrateFileRuns();\n\n try {\n await this.threadRunPromise;\n this.notifyVitest('testfileFinished');\n debug(`[${this.logModuleWithId}] send: responded \"testfileFinished\" to vitest`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n\n this.threadSpecs = [];\n } catch (error) {\n if (!isAbortError(error)) {\n throw createPoolErrorFromAnyError(`PoolWorker send() \"${message.type}\"`, POOL_ERROR_NAMES.PoolError, error);\n }\n } finally {\n this.threadControlPort?.close();\n this.threadAbortController = undefined;\n this.threadControlPort = undefined;\n this.threadRunPromise = undefined;\n }\n });\n break;\n }\n }\n\n on(event: string, callback: EventCallback): void {\n this.addEventCallback(event, callback);\n debug(`[${this.logModuleWithId}] ON \"${event}\" - saved listener`);\n }\n\n off(event: string, callback: EventCallback): void {\n if (this.removeEventCallback(event, callback)) {\n debug(`[${this.logModuleWithId}] OFF \"${event}\" - removed callback from registry`);\n } else {\n debug(`[${this.logModuleWithId}] OFF \"${event}\" - callback not found in registry`);\n }\n }\n\n deserialize(data: unknown): unknown {\n return data;\n }\n\n canReuse(_task: PoolTask): boolean {\n return true;\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Thread Pool Management\n // ─────────────────────────────────────────────────────────────────────────────\n\n private async getGlobalThreadPools(workerCount?: number): Promise<GlobalThreadPools> {\n if (GLOBAL_POOLS_PROMISE) {\n return GLOBAL_POOLS_PROMISE;\n }\n\n GLOBAL_POOLS_PROMISE = new Promise<GlobalThreadPools>(async (resolve, _reject) => {\n const workers = workerCount ?? availableParallelism();\n\n // TODO - decide which is better when scaling\n // Empirical observations seem to show that minimum parallelization for compilation\n // tends to *dramatically* improve compilation times because of v8 warmpup on repeated calls to asc.main,\n // so much so that this time savings **almost always** outweighs the benefits of speading over many\n // available threads. The **almost** is the key word here- this needs to be tested on platforms with\n // higher available paralellism (> 8) to see if it holds true.\n const actualCompileThreadCount = workers > 1 ? 2 : 1;\n // const actualCompileThreadCount = Math.max(Math.ceil(workers * IDLE_COMPILE_THREADS_FACTOR), 1);\n\n debug(`[${this.logModuleWithId}] Creating global compile thread pool | ${actualCompileThreadCount} threads`);\n \n const start = performance.now();\n \n const compilePool = new Tinypool({\n filename: COMPILE_WORKER_PATH,\n minThreads: 1,\n maxThreads: actualCompileThreadCount,\n isolateWorkers: false,\n idleTimeout: POOL_THREAD_IDLE_TIMEOUT_MS,\n env: this.poolOptions.env as Record<string, string>,\n execArgv: this.poolOptions.execArgv,\n workerData: {\n asPoolOptions: this.asPoolOptions,\n asCoverageOptions: this.asCoverageOptions,\n projectRoot: this.poolOptions.project.config.root,\n } satisfies WorkerThreadInitData\n });\n\n const actualRunThreadCount = Math.max(Math.ceil(workers * IDLE_RUN_THREADS_FACTOR), 1);\n debug(`[${this.logModuleWithId}] Creating global run thread pool | ${actualRunThreadCount} threads`);\n\n const runPool = new Tinypool({\n filename: TEST_WORKER_PATH,\n minThreads: 1,\n maxThreads: actualRunThreadCount,\n isolateWorkers: false,\n idleTimeout: POOL_THREAD_IDLE_TIMEOUT_MS,\n env: this.poolOptions.env as Record<string, string>,\n execArgv: this.poolOptions.execArgv,\n workerData: {\n asPoolOptions: this.asPoolOptions,\n asCoverageOptions: this.asCoverageOptions,\n projectRoot: this.poolOptions.project.config.root\n } satisfies WorkerThreadInitData\n });\n\n debug(`[${this.logModuleWithId}] Created global thread pools in ${(performance.now() - start).toFixed(2)} ms`);\n\n GLOBAL_POOL_ABORT_CONTROLLER = new AbortController();\n resolve({ compilePool, runPool });\n });\n \n return GLOBAL_POOLS_PROMISE;\n }\n\n // @ts-ignore\n private async destroyGlobalPoolsIfNeeded(): Promise<void> {\n if (GLOBAL_RUNNING_POOLWORKER_COUNT === 0 && GLOBAL_POOLS_PROMISE) {\n const destroyStart = performance.now();\n debug(`[${this.logModuleWithId}] Destroying Tinypools...`);\n\n try {\n const { compilePool, runPool } = await GLOBAL_POOLS_PROMISE;\n await Promise.all([ compilePool.destroy(), runPool.destroy() ]);\n } catch {}\n\n GLOBAL_POOLS_PROMISE = undefined;\n GLOBAL_POOL_ABORT_CONTROLLER = undefined;\n\n debug(`[${this.logModuleWithId}] Destroyed tinypools in ${(performance.now() - destroyStart).toFixed(2)} ms`);\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Listener Registry Helpers\n // ─────────────────────────────────────────────────────────────────────────────\n\n private getEventCallbacks(event: string): Set<EventCallback> {\n let callbacks: Set<EventCallback> | undefined = this.listenerRegistry.get(event);\n if (!callbacks) {\n callbacks = new Set<EventCallback>();\n this.listenerRegistry.set(event, callbacks);\n }\n return callbacks;\n }\n\n private addEventCallback(event: string, callback: EventCallback): void {\n this.getEventCallbacks(event).add(callback);\n }\n \n private removeEventCallback(event: string, callback: EventCallback): boolean {\n const callbacks = this.getEventCallbacks(event);\n if (callbacks) {\n return callbacks.delete(callback);\n } else {\n return false;\n }\n }\n\n private notifyVitest(responseType: WorkerResponse['type']): void {\n const messageCallbacks = this.getEventCallbacks('message');\n for (const cb of messageCallbacks) {\n cb({ type: responseType, [VITEST_WORKER_RESPONSE_MSG_FLAG]: true } satisfies WorkerResponse)\n }\n }\n\n // ─────────────────────────────────────────────────────────────────────────────\n // Worker Thread Control/Orchestration\n // ─────────────────────────────────────────────────────────────────────────────\n \n private async dispatchCompile(\n spec: ThreadSpec,\n compilePool: Tinypool,\n ): Promise<void> {\n const { workerPort, poolPort } = createWorkerRPCChannel(this.poolOptions.project, this.isCollectTestsMode);\n this.threadControlPort = poolPort;\n \n const compilePromise: Promise<ThreadSpec> = compilePool.run({\n dispatchStart: Date.now(),\n workerId: this.currentWorkerId!,\n port: workerPort,\n file: spec.file,\n config: this.config!,\n isCollectTestsMode: this.isCollectTestsMode,\n } satisfies RunCompileAndDiscoverTask, {\n name: 'runCompileAndDisoverSpec',\n transferList: [workerPort],\n signal: GLOBAL_POOL_ABORT_CONTROLLER!.signal,\n });\n\n try {\n const { compilation, file } = await compilePromise;\n spec.file = file;\n spec.compilation = compilation;\n } finally {\n this.threadControlPort.close();\n this.threadControlPort = undefined;\n }\n }\n \n private async dispatchRunTests(\n spec: ThreadSpec,\n runPool: Tinypool,\n timedOutTest?: Test,\n ): Promise<void> {\n const { workerPort, poolPort } = createWorkerRPCChannel(this.poolOptions.project, this.isCollectTestsMode);\n \n this.threadAbortController = new AbortController();\n this.threadControlPort = poolPort;\n this.threadControlPort.on('message', this.getWorkerThreadMessageHandler());\n\n const runPromise: Promise<void> = !spec.compilation ? Promise.resolve() : runPool.run({\n dispatchStart: Date.now(),\n workerId: this.currentWorkerId!,\n port: workerPort,\n file: timedOutTest?.file ?? spec.file,\n compilation: spec.compilation,\n config: this.config!,\n isCollectTestsMode: this.isCollectTestsMode,\n timedOutTest,\n } satisfies RunTestsTask, {\n name: 'runFileSpec',\n transferList: [workerPort],\n signal: AbortSignal.any([this.threadAbortController.signal, GLOBAL_POOL_ABORT_CONTROLLER!.signal]),\n });\n\n try {\n return await runPromise;\n } finally {\n this.threadControlPort.close();\n this.threadControlPort = undefined;\n }\n }\n\n private async orchestrateFileRuns(timedOutTest?: Test): Promise<void> {\n const modeStr = this.isCollectTestsMode ? 'collectTests' : 'runTests';\n const isResume: boolean = !!timedOutTest;\n const desc = `${modeStr} ${isResume ? '(RESUME)' : '(INITIAL)'}`;\n\n debug(`[${this.logModuleWithId}] orchestrateFileRuns: dispatching ${desc} to worker thread`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n\n const { compilePool, runPool } = await this.getGlobalThreadPools(this.config?.maxWorkers);\n\n // compile\n if (!isResume) {\n await Promise.all(\n this.threadSpecs.map(spec => this.dispatchCompile(spec, compilePool))\n );\n }\n\n // test\n if (!this.isCollectTestsMode) {\n await Promise.all(\n this.threadSpecs.map(spec => this.dispatchRunTests(spec, runPool, timedOutTest))\n );\n }\n\n debug(`[${this.logModuleWithId}] orchestrateFileRuns: ${desc} thread work complete`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n }\n\n private async stopThread(): Promise<void> {\n this.clearTestTimeoutTimer(); // if any\n this.currentTestRun = undefined;\n \n const mod = this.logModuleWithId;\n const start = performance.now();\n\n debug('setting graceful resolve timeout');\n const abortTimeout = setTimeout(() => {\n debug(`[${mod}] stop: timed out waiting on pool worker run resolve ${(performance.now() - start).toFixed(2)} ms | Aborting thread`);\n this.threadAbortController?.abort();\n }, THREAD_RESOLVE_TIMEOUT_MS);\n \n try {\n debug(`[${mod}] stop: awaiting pool worker run resolve: ${!!this.threadRunPromise}`);\n await this.threadRunPromise;\n clearTimeout(abortTimeout);\n debug(`[${this.logModuleWithId}] stop: pool worker run resolved cleanly after ${(performance.now() - start).toFixed(2)} ms`);\n } catch {\n } finally {\n this.threadControlPort?.close();\n debug(`[${this.logModuleWithId}] stop: closed pool port`);\n }\n \n this.threadAbortController = undefined;\n this.threadControlPort = undefined;\n this.threadRunPromise = undefined;\n this.threadSpecs = [];\n }\n\n private getWorkerThreadMessageHandler(): EventCallback {\n return (message: any): void => {\n if (message[AS_POOL_WORKER_MSG_FLAG]) {\n const poolMessage = message as AssemblyScriptPoolWorkerMessage;\n\n switch (poolMessage.type) {\n case 'execution-start':\n this.handleTestExecutionStart(message);\n break;\n case 'execution-end':\n this.handleTestExecutionEnd(message);\n break;\n }\n\n return;\n }\n };\n }\n\n private handleTestExecutionStart(msg: TestExecutionStart): void {\n if (!this.isWorkerRunning) return;\n \n const { executionStart, test } = msg;\n const now = Date.now();\n const transitDuration = now - executionStart;\n const adjustedTimeout = Math.max(test.timeout - transitDuration, 0);\n\n this.currentTestRun = {\n test,\n executionStart,\n timeoutId: setTimeout(() => this.handleTimeout(), adjustedTimeout)\n };\n\n debug(`[${this.logModuleWithId}] START test timeout timer for \"${this.currentTestRun.test.name}\"`);\n }\n\n private handleTestExecutionEnd(_msg: TestExecutionEnd): void {\n this.clearTestTimeoutTimer();\n this.currentTestRun = undefined;\n }\n\n private clearTestTimeoutTimer(): void {\n if (this.currentTestRun) {\n const elapsed = Date.now() - this.currentTestRun.executionStart;\n debug(`[${this.logModuleWithId}] CLEAR test timeout timer (${elapsed.toFixed(2)} ms) for \"${this.currentTestRun?.test.name}\"`);\n clearTimeout(this.currentTestRun.timeoutId);\n }\n }\n\n private async handleTimeout(): Promise<void> {\n if (!this.isWorkerRunning) return;\n\n if (!this.threadSpecs.length || !this.currentTestRun || !this.currentTestRun.test) {\n const missingStr = \n + (this.threadSpecs.length ? '' : 'threadSpecs')\n + (this.currentTestRun ? '' : ' currentTestRecord')\n + (this.currentTestRun?.test ? '' : ' currentTestRecord.test')\n throw createPoolError(\n `Cannot timeout/resume worker thread for workerId ${this.currentWorkerId} - missing data: ${missingStr}`,\n POOL_ERROR_NAMES.PoolError\n );\n }\n\n const duration = Date.now() - this.currentTestRun.executionStart;\n failTestWithTimeoutError(this.currentTestRun.test, this.currentTestRun.executionStart, duration);\n\n // set termination time metadata for measuring resume latency\n flagTestTerminated(this.currentTestRun.test);\n\n debug(`[${this.logModuleWithId}] handleTimeout: TEST TIMEOUT \"${this.currentTestRun.test.name}\" after ${duration.toFixed(2)} ms`\n +` - Terminating worker thread job`\n );\n\n const termStart = performance.now();\n \n try {\n this.threadAbortController?.abort();\n await this.threadRunPromise;\n } catch (error) {\n if (!isAbortError(error)) {\n throw createPoolErrorFromAnyError(`PoolWorker handleTimeout`, POOL_ERROR_NAMES.PoolError, error);\n }\n } finally {\n this.threadControlPort?.close();\n this.threadAbortController = undefined;\n this.threadControlPort = undefined;\n this.threadRunPromise = undefined;\n }\n\n debug(`[${this.logModuleWithId}] handleTimeout: Worker thread job aborted for timeout in ${(performance.now() - termStart).toFixed(2)} ms`);\n \n if (!this.isWorkerRunning) return;\n\n // supply timed-out test (includes entire file hierarchy & coverage)\n // to resume testing where we leftoff when aborting for timeout\n this.threadRunPromise = this.orchestrateFileRuns(this.currentTestRun.test);\n\n debug(`[${this.logModuleWithId}] handleTimeout: re-dispatched job to worker thread`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n\n try {\n await this.threadRunPromise;\n this.notifyVitest('testfileFinished');\n debug(`[${this.logModuleWithId}] handleTimeout: file run completed - responded \"testfileFinished\" to vitest`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n \n this.threadSpecs = [];\n } catch (error) {\n if (!isAbortError(error)) {\n throw createPoolErrorFromAnyError(`PoolWorker handleTimeout`, POOL_ERROR_NAMES.PoolError, error);\n } else {\n debug(`[${this.logModuleWithId}] send: caught and ignored timeout awaiting timeout re-run`\n + ` | files: \"${this.threadSpecs.map(s => s.file.filepath).join(',')}\"`\n );\n }\n } finally {\n //@ts-ignore\n this.threadControlPort?.close();\n this.threadControlPort = undefined;\n this.threadAbortController = undefined;\n this.threadRunPromise = undefined;\n }\n }\n\n private get logModuleWithId(): string {\n return `${this.logModule}${this.currentWorkerId === undefined ? '' : ` ${this.currentWorkerId}`}`;\n }\n}\n","import type { PoolOptions, PoolRunnerInitializer } from 'vitest/node';\n\nimport type {\n AssemblyScriptPoolOptions,\n ResolvedHybridProviderOptions\n} from '../types/types.js';\nimport { ASSEMBLYSCRIPT_POOL_NAME } from '../types/constants.js';\nimport { resolvePoolOptions } from '../util/resolve-config.js';\nimport { AssemblyScriptPoolWorker } from './pool-worker.js';\n\nexport function createAssemblyScriptPool(userPoolOptions?: AssemblyScriptPoolOptions): PoolRunnerInitializer {\n const resolvedUserPoolOptions = resolvePoolOptions(userPoolOptions);\n\n return {\n name: ASSEMBLYSCRIPT_POOL_NAME,\n createPoolWorker: (opts: PoolOptions) => {\n const resolvedCoverageOptions = opts.project.config.coverage as ResolvedHybridProviderOptions;\n return new AssemblyScriptPoolWorker(opts, resolvedUserPoolOptions, resolvedCoverageOptions);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;AAoCA,MAAM,4BAA4B;AAClC,MAAM,8BAA8B;AACpC,MAAM,0BAA0B;AAKhC,MAAM,sBAAsB,QAAQ,OAAO,KAAK,SAAS,wCAAwC;AACjG,MAAM,mBAAmB,QAAQ,OAAO,KAAK,SAAS,qCAAqC;AAE3F,IAAI;AACJ,IAAI;AACJ,IAAI,kCAA0C;AAE9C,IAAa,2BAAb,MAA4D;CAC1D,AAAS,YAAY;CACrB,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CAGT,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,AAAQ,cAA4B,EAAE;CAGtC,AAAQ;CAGR,AAAQ;CACR,AAAQ,kBAA2B;CACnC,AAAQ;CAGR,AAAQ;CAER,YACE,SACA,yBACA,yBACA;EACA,MAAM,QAAQ,YAAY,KAAK;AAE/B,OAAK,cAAc;AACnB,OAAK,gBAAgB;AACrB,OAAK,oBAAoB;AACzB,OAAK,mCAAmB,IAAI,KAAiC;AAE7D,eAAa,YAAY;GACvB,MAAM,yB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