vitest-pool-assemblyscript 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +105 -35
  2. package/binding.gyp +6 -6
  3. package/dist/{compiler-CBBHCPAU.mjs → addon-interface-7FPjYh7J.mjs} +8 -138
  4. package/dist/addon-interface-7FPjYh7J.mjs.map +1 -0
  5. package/dist/{compile-runner-DrDjhdPG.mjs → compile-runner-C-05LdGX.mjs} +3 -3
  6. package/dist/{compile-runner-DrDjhdPG.mjs.map → compile-runner-C-05LdGX.mjs.map} +1 -1
  7. package/dist/compiler/transforms/strip-inline.mjs +1 -2
  8. package/dist/compiler/transforms/strip-inline.mjs.map +1 -1
  9. package/dist/compiler-YMrl5MY_.mjs +147 -0
  10. package/dist/compiler-YMrl5MY_.mjs.map +1 -0
  11. package/dist/config/index-v3.d.mts +2 -2
  12. package/dist/config/index.d.mts +3 -3
  13. package/dist/coverage-provider/index.mjs +4 -4
  14. package/dist/coverage-provider/index.mjs.map +1 -1
  15. package/dist/{custom-provider-options-39YrzdqD.d.mts → custom-provider-options-YTk1m7At.d.mts} +2 -2
  16. package/dist/{custom-provider-options-39YrzdqD.d.mts.map → custom-provider-options-YTk1m7At.d.mts.map} +1 -1
  17. package/dist/feature-check-CNyjFX9M.mjs +82 -0
  18. package/dist/feature-check-CNyjFX9M.mjs.map +1 -0
  19. package/dist/index-internal.d.mts +1 -1
  20. package/dist/index-internal.d.mts.map +1 -1
  21. package/dist/index-internal.mjs +2 -1
  22. package/dist/index.d.mts +2 -2
  23. package/dist/{load-user-imports-BIQvqM7K.mjs → load-user-imports-B3Iy_K8k.mjs} +2 -3
  24. package/dist/{load-user-imports-BIQvqM7K.mjs.map → load-user-imports-B3Iy_K8k.mjs.map} +1 -1
  25. package/dist/{pool-runner-init-DVk4hB5d.d.mts → pool-runner-init-CvnB0-iN.d.mts} +2 -2
  26. package/dist/pool-runner-init-CvnB0-iN.d.mts.map +1 -0
  27. package/dist/pool-thread/compile-worker-thread.d.mts +1 -1
  28. package/dist/pool-thread/compile-worker-thread.mjs +5 -5
  29. package/dist/pool-thread/compile-worker-thread.mjs.map +1 -1
  30. package/dist/pool-thread/test-worker-thread.d.mts +1 -1
  31. package/dist/pool-thread/test-worker-thread.mjs +4 -4
  32. package/dist/pool-thread/test-worker-thread.mjs.map +1 -1
  33. package/dist/pool-thread/v3-tinypool-thread.d.mts +1 -1
  34. package/dist/pool-thread/v3-tinypool-thread.mjs +6 -6
  35. package/dist/pool-thread/v3-tinypool-thread.mjs.map +1 -1
  36. package/dist/resolve-config-BFNr7LW7.mjs.map +1 -1
  37. package/dist/{test-runner-DNGLk7lx.mjs → test-runner-WF857_Bk.mjs} +2 -2
  38. package/dist/{test-runner-DNGLk7lx.mjs.map → test-runner-WF857_Bk.mjs.map} +1 -1
  39. package/dist/{types-6ta3lLJM.d.mts → types-D0nprJo1.d.mts} +1 -1
  40. package/dist/types-D0nprJo1.d.mts.map +1 -0
  41. package/package.json +17 -16
  42. package/prebuilds/darwin-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  43. package/prebuilds/darwin-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  44. package/prebuilds/linux-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  45. package/prebuilds/linux-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  46. package/prebuilds/linux-x64/vitest-pool-assemblyscript.musl.node +0 -0
  47. package/prebuilds/win32-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  48. package/prebuilds/win32-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  49. package/scripts/install.js +53 -16
  50. package/src/{native-instrumentation → instrumentation/native}/addon.cpp +8 -8
  51. package/dist/compiler-CBBHCPAU.mjs.map +0 -1
  52. package/dist/node-check-CcKfvjM4.mjs +0 -16
  53. package/dist/node-check-CcKfvjM4.mjs.map +0 -1
  54. package/dist/pool-runner-init-DVk4hB5d.d.mts.map +0 -1
  55. package/dist/types-6ta3lLJM.d.mts.map +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p align="center">
4
4
  <img src="docs/images/as-icon.svg" height="50" align="middle">
5
- &nbsp;&nbsp;&#10133;&nbsp;&nbsp;
5
+ &nbsp;&nbsp;&nbsp;&nbsp;&#10133;&nbsp;&nbsp;&nbsp;&nbsp;
6
6
  <picture>
7
7
  <source media="(prefers-color-scheme: dark)" srcset="docs/images/vitest-light.svg">
8
8
  <source media="(prefers-color-scheme: light)" srcset="docs/images/vitest-dark.svg">
@@ -28,29 +28,51 @@
28
28
  </p>
29
29
 
30
30
  <p align="center">
31
- <a href="#status">Status</a> | <a href="#quick-start">Quick Start</a> | <a href="#features">Features</a> | <a href="#compatibility">Compatibility</a> | <a href="#performance">Performance</a> | <a href="#prior-work">Prior Work</a> | <a href="#license">License</a>
31
+ Check it out:
32
32
  <br/>
33
- <a href="#writing-tests">Writing Tests</a> | <a href="docs/matchers-api.md">Matchers API</a> | <a href="docs/configuration-guide.md">Configuration Guide</a> | <a href="docs/providing-wasm-imports.md">Providing WASM Imports</a>
33
+ <a href="#status">Status</a> |
34
+ <a href="#quick-start">Quick Start</a> |
35
+ <a href="#features">Features</a> |
36
+ <a href="#frequently-asked-questions">Frequently Asked Questions</a>
37
+ <br/>
38
+ <a href="#compatibility">Compatibility</a> |
39
+ <a href="#performance">Performance</a> |
40
+ <a href="#prior-work">Prior Work</a> |
41
+ <a href="#license">License</a>
42
+ </p>
43
+ <p align="center">
44
+ Dig in:
45
+ <br/>
46
+ <a href="#writing-tests">Writing Tests</a> |
47
+ <a href="docs/matchers-api.md">Matchers API</a> |
48
+ <a href="docs/configuration-guide.md">Configuration Guide</a> |
49
+ <a href="docs/providing-wasm-imports.md">Providing WASM Imports</a>
34
50
  </p>
35
51
 
36
52
  ---
37
53
 
38
54
  <br/>
39
55
  <p align="center">
40
- <img src="docs/images/example-small.gif" alt="vitest-pool-assemblyscript demo">
56
+ <img src="docs/images/example-small.gif" alt="vitest-pool-assemblyscript quick demo">
41
57
  </p>
42
58
 
43
59
  ## Status
44
60
 
45
61
  This project is relatively new to the scene, but is being improved every day. Please give it a try!
46
62
 
47
- - All [listed features](#features) are working and assumed to be bug-free ([report](https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new))
48
- - [`describe()` and `test()` definition APIs](#writing-tests) are stable and not expected to change
49
- - [`expect()` matchers API](docs/matchers-api.md) is stable and not expected to change. More are coming soon
50
- - Native instrumentation prebuilds are available [across many platforms](#compatibility)
51
- - See [Current Limitations & Roadmap](#current-limitations--roadmap) for important limitations to be aware of, and to see what's still planned.
63
+ All [listed features](#features) are working and assumed to be bug-free ([please report any](https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new))
52
64
 
53
- Please [report a bug or request a feature](https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new) if you have something you'd like to share.
65
+ | Function | Status |
66
+ |---|---|
67
+ | [`describe()` and `test()` APIs](#writing-tests) | - stable<br/>- no breaking changes expected |
68
+ | [`expect()` API](docs/matchers-api.md) | - stable<br/>- no breaking changes expected<br/>- more coming soon |
69
+ | Code Coverage / Instrumentation | - function coverage stable [across platforms](#compatibility)<br/>- branch & line coverage coming soon |
70
+ | Hybrid Coverage Provider | - stable<br/>- v8 delegation, side-by-side JS coverage<br/>- istanbul delegation coming soon
71
+
72
+ See Also:
73
+ - [Current Limitations & Roadmap](#current-limitations--roadmap)
74
+ - [Frequently Asked Questions](#frequently-asked-questions)
75
+ - [Report a Bug / Request a Feature](https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new)
54
76
 
55
77
  ---
56
78
 
@@ -166,17 +188,47 @@ npx vitest run
166
188
 
167
189
  ---
168
190
 
191
+ ## Frequently Asked Questions
192
+
193
+ **Q: How does this work?**
194
+ <br/>
195
+ **A:** Vitest has a [custom pool API](https://vitest.dev/guide/advanced/pool.html) that lets you define the execution environment for the tests it runs (internally, vitest uses its own pools to run JavaScript and TypeScript tests). This custom pool uses the [AssemblyScript compiler](https://www.assemblyscript.org/compiler.html) to compile each test file to WASM, instruments the WASM binary for code coverage, then runs each test in an isolated WASM instance and reports results back to vitest through its standard RPC reporting mechanism.
196
+
197
+ **Q: So it is really using vitest?**
198
+ <br/>
199
+ **A:** Yes! It's a real vitest pool, not a clone of vitest - it hooks directly into the framework, receiving tests to run from vitest and reporting results back. The pool implements its own compilation, test execution, and [matchers in AS](docs/matchers-api.md), designed to mirror the [vitest expect() API](https://vitest.dev/api/expect.html). We don't use vite build integration, but that's the tradeoff of a custom pool - you can bring any execution environment to vitest.
200
+
201
+ The overall goal is tight vitest experience integration - most CLI commands, reporters, UI, and project configurations should work as you'd expect, and test runner behavior should match vitest's JS pool runner for features we've implemented (retries, timeouts, skip, only, fails, etc.). Some features aren't implemented yet due to effort and prioritization, and others necessarily differ given AssemblyScript's static typing and execution model. See the [configuration guide](docs/configuration-guide.md) and [limitations / roadmap](#current-limitations--roadmap) for specifics.
202
+
203
+ **Q: Will this work on my machine?**
204
+ <br/>
205
+ **A:** Probably! WASM coverage instrumentation requires native binaries, and we ship [prebuilt binaries for most common platforms](#compatibility). If your platform isn't listed, the npm package installation will fallback to trying to build the native code using a local C++ toolchain.
206
+
207
+ **Q: Do you support older versions of AssemblyScript?**
208
+ <br/>
209
+ **A:** It's tested against 0.28.9 currently, and that's the version I have any real experience with. Older versions might work but aren't actively tested. If you're stuck on an older version and run into issues, you're welcome to [open an issue](https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new).
210
+
211
+ **Q: Is this an official vitest project?**
212
+ <br/>
213
+ **A:** No, this is a third-party community project. It's not affiliated with or endorsed by the vitest team, though we're grateful for their extensible architecture that makes projects like this possible, and the [other open-source projects](#prior-work) that provide vital functionality and reference architecture.
214
+
215
+ **Q: Are you a company? A bot?**
216
+ <br/>
217
+ **A:** Just [a person](https://github.com/themattspiral)! This started as a hobby project to improve my own AssemblyScript testing workflow and learn something about WASM internals, and it's grown from there. I use Claude Code for initial scaffolding and to help dig into the native instrumentation side in particular, but everything goes through me, and my intention is to contribute something useful and high-quality to the community. Feedback and contributions are welcome.
218
+
219
+ ---
220
+
169
221
  ## Compatibility
170
222
 
171
223
  | Dependency | Supported Versions |
172
224
  |---|---|
173
225
  | Node.js | (20*), 22, 24+ |
174
- | Vitest | 3.2.x, 4.x |
175
- | AssemblyScript | 0.28+ |
226
+ | Vitest | 3.2.x, 4.x.x |
227
+ | AssemblyScript | 0.28.9+ ([more?](#frequently-asked-questions)) |
176
228
 
177
229
  >ℹ️ ***Node 20 Support:** If you don't need code coverage, Node 20 should continue to work for test execution.
178
230
  >
179
- >WASM coverage instrumentation is implemented using WebAssembly [multi-memory](https://github.com/WebAssembly/multi-memory) to isolate coverage counters from user test memory. This feature shipped in V8 12.0 / Node 22.
231
+ >WASM coverage instrumentation is implemented using [WebAssembly multi-memory](https://github.com/WebAssembly/multi-memory) to isolate coverage counters from user test memory. This feature shipped in V8 12.0 / Node 22.
180
232
 
181
233
  **Platforms with prebuilt native binaries for coverage instrumentation & debug info:**
182
234
 
@@ -194,8 +246,8 @@ npx vitest run
194
246
  Import `test`, `describe`, `expect` from `vitest-pool-assemblyscript/assembly`. These functions are designed to follow the vitest API as closely as possible, so that everything is familiar and easy to reason about.
195
247
 
196
248
  - `it` is available as an alias for `test`
197
- - `describe` and `test` have inline modifiers to quickly change their status (see below)
198
- - `TestOptions` allows per-test inline configuration of additional options
249
+ - `describe` and `test` have inline modifiers to quickly change their run mode (see below)
250
+ - `TestOptions` allows per-test inline configuration of additional options (aligned with vitest behavior)
199
251
 
200
252
  ```typescript
201
253
  import { test, it, describe, expect, TestOptions } from "vitest-pool-assemblyscript/assembly";
@@ -219,17 +271,29 @@ describe("a suite of math operations", () => {
219
271
  });
220
272
  ```
221
273
 
222
- ### Inline Modifiers: `.skip`, `.only`, `.fails`
274
+ ### Inline Run Mode Modifiers: `.skip`, `.only`, `.fails`
275
+
276
+ These modify the way in which tests run in relation to each other, and/or how they report results.
277
+
278
+ They follow vitest JS-pool behavior.
223
279
 
224
280
  ```typescript
225
- test.skip("not ready yet", () => { /* ... */ });
281
+ test.skip("not ready yet", () => {
282
+ // test will register it exists, show as skipped
283
+ });
226
284
 
227
- test.only("run only this test", () => { /* ... */ });
285
+ test.only("debugging this test", () => {
286
+ // test will run by itself in this file
287
+ });
228
288
 
229
- test.fails("expected to fail, so will actually pass", () => {
289
+ test.fails("conditions are expected to fail, so test will actually pass", () => {
230
290
  expect(false).toBeTruthy();
231
291
  });
232
292
 
293
+ test.fails("conditions are expected to fail but do not, so test will actually fail", () => {
294
+ expect(true).toBeTruthy();
295
+ });
296
+
233
297
  describe.skip("entire suite skipped", () => { /* ... */ });
234
298
 
235
299
  describe.only("only this suite runs", () => { /* ... */ });
@@ -237,9 +301,10 @@ describe.only("only this suite runs", () => { /* ... */ });
237
301
 
238
302
  ### Inline Test Options
239
303
 
240
- `TestOptions` provides chainable configuration for `timeout`, `retry`, `skip`, `only`, and `fails`.
304
+ `TestOptions` provides chainable configuration for the vitest behavioral options: `timeout`, `retry`, `skip`, `only`, and `fails`
305
+ - While you define them slightly differently in AssemblyScript than JavaScript, their behavior matches the same options in vitest
241
306
  - Options can be placed before or after the callback
242
- - Suite options are inherited by nested tests and suites
307
+ - Suite options (in `describe`) are inherited by nested tests and nested suites
243
308
 
244
309
  ```typescript
245
310
  // options before callback
@@ -265,12 +330,16 @@ test.fails("expected failure with retry", TestOptions.retry(3), () => {
265
330
  });
266
331
  ```
267
332
 
268
- See the [Matchers API documentation](docs/matchers-api.md) for details on the available `expect()` methods you can use within your tests.
269
-
270
333
  ### Lifecycle Hooks (Setup & Teardown)
271
334
 
272
335
  Coming Soon!
273
336
 
337
+ ### Test Matchers
338
+
339
+ We aim to follow the [vitest/jest `expect()` API](https://vitest.dev/api/expect.html) as closely as possible, with some necessary differences given AssemblyScript's static-typing.
340
+
341
+ See the AssemblyScript Pool [Matchers API documentation](docs/matchers-api.md) for details on the available `expect()` methods you can use within your tests.
342
+
274
343
  ---
275
344
 
276
345
  ## Current Limitations & Roadmap
@@ -318,16 +387,16 @@ These are known limitations which are currently being worked on.
318
387
 
319
388
  ## Performance
320
389
 
321
- Efforts have been made to compile and run tests as quickly as possible:
322
- - Separate compile and test execution thread pools, workers, and runners for quicker startup and respawn
323
- - Compile threads tuned to take advantage of significant Node V8 engine warmup time savings on consecutive AssemblyScript compilations
390
+ Many efforts have been made to compile and run tests as quickly as possible. Some optimizations that have been most useful:
391
+ - Separate compile and test execution thread pools, worker thread entry points, and runners for quicker startup and thread respawn after test timeouts
392
+ - Compile threads tuned to take advantage of significant Node V8 engine warmup time savings on consecutive AssemblyScript compilations (this is an ongoing investigation as I want to see how it behaves when scaled up significantly)
324
393
  - In-memory compiled files and source maps to eliminate intermediate disk I/O
325
394
  - Enforced hard timeouts for long-running WASM tests via thread termination, with intelligent resume
326
395
 
327
- As such, it is capable of compiling dozens of test files comprising hundreds of tests in a few seconds.
396
+ As such, it is capable of compiling dozens of test files comprising hundreds of tests in a few seconds, and is likely faster on your machine than mine:
328
397
 
329
398
  <p align="center">
330
- <img src="docs/images/example-fixtures-suite.gif" alt="vitest-pool-assemblyscript demo">
399
+ <img src="docs/images/example-fixtures-suite.gif" alt="vitest-pool-assemblyscript large suite performance demo">
331
400
  </p>
332
401
 
333
402
  ---
@@ -336,15 +405,16 @@ As such, it is capable of compiling dozens of test files comprising hundreds of
336
405
 
337
406
  There are several core pieces of software without which this project would not be possible.
338
407
 
339
- - This project makes direct use of the [AssemblyScript language](https://www.assemblyscript.org) and its fantastic [compiler](https://www.assemblyscript.org/compiler.html)
340
- - Thanks to the [Vitest team](https://github.com/vitest-dev) for creating the framework in the first place and making it pluggable for different runtimes. Their internal pools were used as extensive reference in early phase development.
341
- - The key component that allows us to perform WASM instrumentation is [Binaryen](https://github.com/WebAssembly/binaryen), a C++ toolchain infrastructure library for WebAssembly.
342
- - Particular gratitude is owed to [assemblyscript-unittest-framework](https://github.com/wasm-ecosystem/assemblyscript-unittest-framework) for inspiring parts of our test discovery and instrumentation walking approaches.
408
+ - This project makes direct use of the [AssemblyScript language](https://www.assemblyscript.org) and its fantastic [compiler](https://www.assemblyscript.org/compiler.html). AS is a joy to work with when it comes to WASM because it's so familiar to everyday TypeScript usage.
409
+ - The key component that allows us to perform WASM instrumentation is [Binaryen](https://github.com/WebAssembly/binaryen), a C++ toolchain infrastructure library for WebAssembly. We started by using the fantastic [binaryen.js](https://github.com/AssemblyScript/binaryen.js/) - a JS port also from the folks behind AssemblyScript, and eventually migrated to the native library for some advanced source-map regeneration features.
410
+ - Thanks to the [Vitest team](https://github.com/vitest-dev) for creating the framework in the first place and making it extensible for different runtimes. Their internal pools were used as reference throughout development.
411
+ - Thanks to [`@cloudflare/vitest-pool-workers`](https://github.com/cloudflare/workers-sdk/tree/main/packages/vitest-pool-workers) for providing the leading example of a 3rd party vitest custom pool out in the wild.
412
+ - Particular gratitude is also owed to [assemblyscript-unittest-framework](https://github.com/wasm-ecosystem/assemblyscript-unittest-framework) for inspiring our test discovery and instrumentation expression-walking approaches.
343
413
 
344
414
  ---
345
415
 
346
416
  ## License
347
417
 
348
- [MIT](LICENSE)
349
- - 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.
350
- - See the license file and source code for details
418
+ Licensed under the [MIT](LICENSE)
419
+
420
+ Portions of this software have been derived from third-party works which are licenced under different terms. These uses have been noted and are accompanied by their respective licenses in the [project license](LICENSE) and/or in applicable source code.
package/binding.gyp CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "targets": [
3
3
  {
4
- "target_name": "wasm_binaryen_debug",
4
+ "target_name": "wasm_binaryen_debug_instrumenter",
5
5
  "sources": [
6
- "src/native-instrumentation/addon.cpp"
6
+ "src/instrumentation/native/addon.cpp"
7
7
  ],
8
8
  "include_dirs": [
9
9
  # node-addon-api C++ headers (N-API wrapper)
@@ -27,7 +27,7 @@
27
27
  "-lpthread"
28
28
  ],
29
29
  # Enable C++ exceptions (node-gyp disables them by default)
30
- "cflags_cc": ["-std=c++20", "-fexceptions", "-O3"],
30
+ "cflags_cc": ["-std=c++17", "-fexceptions", "-O3"],
31
31
  "cflags!": ["-fno-exceptions"],
32
32
  "cflags_cc!": ["-fno-exceptions"]
33
33
  }],
@@ -38,9 +38,9 @@
38
38
  "xcode_settings": {
39
39
  "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
40
40
  "CLANG_CXX_LIBRARY": "libc++",
41
- # Minimum macOS deployment target for C++20 support
41
+ # Minimum macOS deployment target for C++17 support
42
42
  "MACOSX_DEPLOYMENT_TARGET": "10.15",
43
- "OTHER_CPLUSPLUSFLAGS": ["-std=c++20", "-fexceptions", "-O3"]
43
+ "OTHER_CPLUSPLUSFLAGS": ["-std=c++17", "-fexceptions", "-O3"]
44
44
  }
45
45
  }],
46
46
  ["OS=='win'", {
@@ -52,7 +52,7 @@
52
52
  "VCCLCompilerTool": {
53
53
  # Enable C++ exception handling (/EHsc)
54
54
  "ExceptionHandling": 1,
55
- "AdditionalOptions": ["/std:c++20"]
55
+ "AdditionalOptions": ["/std:c++17", "/permissive"]
56
56
  }
57
57
  }
58
58
  }]
@@ -1,14 +1,12 @@
1
1
  import { INTERNAL_PATH_LIB_PREFIX, POOL_ERROR_NAMES } from "./constants-DuBLuMjt.mjs";
2
- import { createPoolError, debug, throwPoolErrorIfAborted } from "./debug-Cm1VFmaz.mjs";
2
+ import { createPoolError, debug } from "./debug-Cm1VFmaz.mjs";
3
3
  import { toForwardSlash } from "./path-utils-t9OzjXYF.mjs";
4
4
  import { getShortFunctionName } from "./wasm-names-BFtzQCH4.mjs";
5
5
  import { createRequire } from "node:module";
6
- import { basename, dirname, resolve } from "node:path";
7
- import { access, readFile } from "node:fs/promises";
8
- import { main } from "assemblyscript/asc";
6
+ import { dirname, resolve } from "node:path";
9
7
  import { fileURLToPath } from "node:url";
10
8
 
11
- //#region src/native-instrumentation/addon-interface.ts
9
+ //#region src/instrumentation/addon-interface.ts
12
10
  /**
13
11
  * Native addon interface for extracting debug information from WebAssembly binaries
14
12
  *
@@ -30,7 +28,7 @@ try {
30
28
  try {
31
29
  addon = nodeGypBuild(rootFromSrc);
32
30
  } catch (err) {
33
- throw createPoolError(`Native addon not found. Searched from ${rootFromDist} and ${rootFromSrc}. Ensure prebuilds are available or run 'npm run build:native' to compile from source. Original error: ${err instanceof Error ? err.message : String(err)}`, POOL_ERROR_NAMES.WASMInstrumentationError);
31
+ throw createPoolError(`vitest-pool-assemblyscript native instrumentation addon not found. Searched from ${rootFromDist} and ${rootFromSrc}. Ensure prebuilds are available or run 'node node_modules/vitest-pool-assemblyscript/scripts/install.js' to compile from source. Original error: ${err instanceof Error ? err.message : String(err)}`, POOL_ERROR_NAMES.WASMInstrumentationError);
34
32
  }
35
33
  }
36
34
  /**
@@ -173,7 +171,7 @@ function transformDebugInfo(raw, logPrefix, projectRoot) {
173
171
  * @throws {TypeError} If wasmBuffer or sourceMapBuffer are not Buffers
174
172
  * @throws {Error} If WASM binary or source map is invalid
175
173
  */
176
- function instrumentForCoverage(wasmBuffer, sourceMapBuffer, instrumentationOptions, logModule, logLabel) {
174
+ const instrumentForCoverage = (wasmBuffer, sourceMapBuffer, instrumentationOptions, logModule, logLabel) => {
177
175
  if (!Buffer.isBuffer(wasmBuffer)) throw createPoolError("instrumentForCoverage - wasmBuffer must be a Buffer", POOL_ERROR_NAMES.WASMInstrumentationError);
178
176
  if (!Buffer.isBuffer(sourceMapBuffer)) throw createPoolError("instrumentForCoverage - sourceMapBuffer must be a Buffer", POOL_ERROR_NAMES.WASMInstrumentationError);
179
177
  const interfaceLogPrefix = `[${logModule} Inst] ${logLabel}`;
@@ -201,136 +199,8 @@ function instrumentForCoverage(wasmBuffer, sourceMapBuffer, instrumentationOptio
201
199
  sourceMap: nativeResult.sourceMap,
202
200
  debugInfo
203
201
  };
204
- }
205
-
206
- //#endregion
207
- //#region src/compiler/index.ts
208
- /**
209
- * AssemblyScript Compiler
210
- *
211
- * Handles compilation of AssemblyScript source code to WASM binaries.
212
- * Manages compiler options, transforms, and in-memory compilation.
213
- */
214
- const POOL_ASSEMBLY_NODE_MODULES_PREFIX = "node_modules/vitest-pool-assemblyscript/assembly/";
215
- const STRIP_INLINE_TRANSFORM = resolve(import.meta.dirname, "./compiler/transforms/strip-inline.mjs");
216
- setImmediate(async () => {
217
- try {
218
- await access(STRIP_INLINE_TRANSFORM);
219
- } catch {
220
- throw createPoolError(`AS Compiler strip inline transform file not found at "${STRIP_INLINE_TRANSFORM}"`, POOL_ERROR_NAMES.CompilationError);
221
- }
222
- });
223
- /**
224
- * Compile AssemblyScript source code to WASM binary
225
- */
226
- async function compileAssemblyScript(filename, options, logModule, logLabel, signal) {
227
- throwPoolErrorIfAborted(signal);
228
- const compileStart = performance.now();
229
- const logPrefix = `[${logModule} ASC] ${logLabel}`;
230
- const { shouldInstrument, instrumentationOptions, extraFlags } = options;
231
- if (shouldInstrument && !instrumentationOptions) throw createPoolError("Instrumentation options are required for coverage instrumentation", POOL_ERROR_NAMES.CompilationError);
232
- const stdoutLines = [];
233
- const stderrLines = [];
234
- let binary;
235
- let sourceMap;
236
- const entryFile = filename;
237
- const outputFile = "output.wasm";
238
- debug(`${logPrefix} - Compiling: "${filename}"`);
239
- const stdout = { write: (text) => {
240
- stdoutLines.push(text);
241
- return true;
242
- } };
243
- const stderr = { write: (text) => {
244
- stderrLines.push(text);
245
- return true;
246
- } };
247
- const compilerFlags = [
248
- entryFile,
249
- "--optimizeLevel",
250
- "0",
251
- "--shrinkLevel",
252
- "0",
253
- "--runtime",
254
- "stub",
255
- ...extraFlags || [],
256
- "--outFile",
257
- outputFile,
258
- "--importMemory",
259
- "--debug",
260
- "--sourceMap",
261
- "--exportStart",
262
- "_start",
263
- "--exportTable"
264
- ];
265
- if (options.stripInline === true) {
266
- compilerFlags.push("--transform", STRIP_INLINE_TRANSFORM);
267
- debug(`${logPrefix} - Added Transform - Stripping @inline decorators`);
268
- }
269
- const ascStart = performance.now();
270
- const result = await main(compilerFlags, {
271
- stdout,
272
- stderr,
273
- writeFile: (name, contents, _baseDir) => {
274
- throwPoolErrorIfAborted(signal);
275
- if (name.endsWith(".wasm") && contents instanceof Uint8Array) {
276
- binary = contents;
277
- debug(`${logPrefix} - Captured binary in memory: "${name}"`);
278
- } else if (name.endsWith(".wasm.map") && typeof contents === "string") {
279
- debug(`${logPrefix} - Captured source map in memory: "${name}"`);
280
- sourceMap = contents;
281
- } else debug(`${logPrefix} - WARNING - Captured Unexpected File: "${name}" at baseDir: "${_baseDir}"`);
282
- },
283
- readFile: async (filename, baseDir) => {
284
- const filePath = resolve(baseDir, filename);
285
- try {
286
- return await readFile(filePath, { encoding: "utf-8" });
287
- } catch {
288
- if (filename.startsWith(POOL_ASSEMBLY_NODE_MODULES_PREFIX)) {
289
- const localPath = resolve(baseDir, "assembly", filename.substring(49));
290
- try {
291
- return await readFile(localPath, { encoding: "utf-8" });
292
- } catch {
293
- return null;
294
- }
295
- }
296
- return null;
297
- }
298
- }
299
- });
300
- debug(`${logPrefix} - TIMING asc.main: ${(performance.now() - ascStart).toFixed(2)} ms`);
301
- if (result.error) {
302
- const errorMessage = stderrLines.length > 0 ? `${result.error.message}\n\n${stderrLines.join("")}` : result.error.message;
303
- throw createPoolError(errorMessage, POOL_ERROR_NAMES.CompilationError, errorMessage);
304
- }
305
- if (!binary) throw createPoolError(stderrLines.length > 0 ? `No WASM binary was generated\n\nAS Compiler output:\n${stderrLines.join("")}` : "No WASM binary was generated", POOL_ERROR_NAMES.CompilationError);
306
- if (!sourceMap) throw createPoolError("Source map not captured from AssemblyScript Compiler", POOL_ERROR_NAMES.CompilationError);
307
- const cleanBinary = binary;
308
- const wasmSourceMap = sourceMap;
309
- debug(`${logPrefix} - Compilation successful, clean binary size: ${cleanBinary.length} bytes`);
310
- debug(`${logPrefix} - Source map generated, size: ${wasmSourceMap.length * 2} bytes`);
311
- if (options.shouldInstrument) {
312
- throwPoolErrorIfAborted(signal);
313
- const instrumentStart = performance.now();
314
- const instrumentResult = instrumentForCoverage(Buffer.from(cleanBinary), Buffer.from(wasmSourceMap), options.instrumentationOptions, logModule, logLabel);
315
- const instCount = instrumentResult.debugInfo.instrumentedFunctionCount;
316
- const instrumentEnd = performance.now();
317
- debug(`${logPrefix} - TIMING Instrumented ${instCount} functions: ${(performance.now() - instrumentStart).toFixed(2)} ms`);
318
- return {
319
- binary: instrumentResult.instrumentedWasm,
320
- sourceMap: instrumentResult.sourceMap,
321
- debugInfo: instrumentResult.debugInfo,
322
- isInstrumented: true,
323
- compileTiming: instrumentEnd - compileStart
324
- };
325
- }
326
- return {
327
- binary: cleanBinary,
328
- sourceMap: wasmSourceMap,
329
- isInstrumented: false,
330
- compileTiming: performance.now() - compileStart
331
- };
332
- }
202
+ };
333
203
 
334
204
  //#endregion
335
- export { compileAssemblyScript };
336
- //# sourceMappingURL=compiler-CBBHCPAU.mjs.map
205
+ export { instrumentForCoverage };
206
+ //# sourceMappingURL=addon-interface-7FPjYh7J.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addon-interface-7FPjYh7J.mjs","names":[],"sources":["../src/instrumentation/addon-interface.ts"],"sourcesContent":["/**\n * Native addon interface for extracting debug information from WebAssembly binaries\n *\n * This module wraps Binaryen's C++ API to provide expression-level debug locations\n * and basic block information that the JavaScript API doesn't expose.\n *\n * The native addon outputs raw data (0-based columns, relative paths) which this\n * wrapper transforms into the final BinaryDebugInfo format (1-based columns,\n * absolute paths, grouped by file and position).\n */\n\nimport { createRequire } from 'node:module';\nimport { resolve, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type {\n NativeAddon,\n NativeInstrumentationResult,\n NativeDebugInfoOutput,\n NativeFunctionDebugInfo,\n NativeExpressionDebugInfo,\n NativeSourceLocation,\n BinaryDebugInfo,\n FunctionDebugInfo,\n SourceLocation,\n ExpressionDebugInfo,\n InstrumentationResult,\n NativeInstrumentationOptions,\n InstrumentationOptions,\n InstrumentForCoverageFunc,\n} from '../types/types.js';\nimport { POOL_ERROR_NAMES, INTERNAL_PATH_LIB_PREFIX } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { toForwardSlash } from '../util/path-utils.js';\nimport { createPoolError } from '../util/pool-errors.js';\nimport { getShortFunctionName } from '../wasm-executor/wasm-names.js';\n\n// Load the native addon via node-gyp-build\n// node-gyp-build checks: prebuilds/ first, then build/Release/\n// It searches from the given directory for a package.json to find the package root.\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst rootFromDist = resolve(__dirname, '..');\n// TODO: Verify if this src fallback is still needed — pool always runs from dist/ even locally.\n// If confirmed dead code, remove this and simplify to a single nodeGypBuild call.\nconst rootFromSrc = resolve(__dirname, '../..');\n\nconst require = createRequire(import.meta.url);\nconst nodeGypBuild: (dir: string) => NativeAddon = require('node-gyp-build');\n\nlet addon: NativeAddon;\ntry {\n addon = nodeGypBuild(rootFromDist);\n} catch {\n try {\n addon = nodeGypBuild(rootFromSrc);\n } catch (err) {\n throw createPoolError(\n `vitest-pool-assemblyscript native instrumentation addon not found. Searched from ${rootFromDist} and ${rootFromSrc}. `\n + `Ensure prebuilds are available or run 'node node_modules/vitest-pool-assemblyscript/scripts/install.js'`\n + ` to compile from source. Original error: ${err instanceof Error ? err.message : String(err)}`,\n POOL_ERROR_NAMES.WASMInstrumentationError\n );\n }\n}\n\n/**\n * Convert a raw location (0-indexed columns, path indexes) to\n * processed location (1-indexed columns, absolute path strings)\n *\n * Source map paths vary by import style and project structure:\n * - Relative imports: \"assembly/compare.ts\"\n * - Bare package imports: \"~lib/vitest-pool-assemblyscript/assembly/compare.ts\"\n * - Source outside project root: \"../assembly/compare.ts\" (e.g. test-external importing parent sources)\n *\n * All are normalized to absolute filesystem paths for consistent coverage key matching.\n */\nfunction convertLocation(\n rawLocation: NativeSourceLocation,\n debugSourceFiles: string[],\n projectRoot: string\n): SourceLocation {\n let filePath = debugSourceFiles[rawLocation.fileIndex];\n\n if (!filePath) {\n throw createPoolError(\n `No debug source file with index: ${rawLocation.fileIndex}}`,\n POOL_ERROR_NAMES.WASMInstrumentationError\n );\n }\n\n // Normalize to absolute path for consistent coverage key matching\n if (filePath.startsWith(INTERNAL_PATH_LIB_PREFIX)) {\n // ~lib/vitest-pool-assemblyscript/assembly/X.ts -> projectRoot/assembly/X.ts\n const relativePart = filePath.slice(INTERNAL_PATH_LIB_PREFIX.length);\n filePath = toForwardSlash(resolve(projectRoot, 'assembly', relativePart));\n } else {\n // Resolve relative path (handles both 'assembly/X.ts' and '../assembly/X.ts')\n filePath = toForwardSlash(resolve(projectRoot, filePath));\n }\n\n return {\n filePath,\n line: rawLocation.line,\n column: rawLocation.column + 1, // convert from 0-indexed to 1-indexed\n };\n}\n\n/**\n * Convert a raw expression to processed format\n */\nfunction convertExpression(\n rawExpr: NativeExpressionDebugInfo,\n debugSourceFiles: string[],\n projectRoot: string\n): ExpressionDebugInfo {\n const converted: ExpressionDebugInfo = {\n type: rawExpr.type,\n isBranch: rawExpr.isBranch,\n };\n\n if (rawExpr.branchPaths !== undefined) {\n converted.branchPaths = rawExpr.branchPaths;\n }\n\n if (rawExpr.location) {\n const convertedLocation = convertLocation(rawExpr.location, debugSourceFiles, projectRoot);\n if (convertedLocation) {\n converted.location = convertedLocation;\n }\n }\n\n return converted;\n}\n\n/**\n * Generate a position key to identify the SourceLocation uniquely\n * within a file. Does NOT include the file identifier.\n */\nfunction getPositionKey(location: SourceLocation) {\n return `${location.line}:${location.column}`;\n}\n\n/**\n * Convert a raw function to processed format and compute position key\n * Returns undefined if function has no valid representative location\n */\nfunction convertFunction(\n rawFunc: NativeFunctionDebugInfo,\n debugSourceFiles: string[],\n projectRoot: string\n): { func: FunctionDebugInfo; filePath: string; positionKey: string } | undefined {\n const representativeLocation = convertLocation(rawFunc.representativeLocation, debugSourceFiles, projectRoot);\n\n // Convert expressions\n const expressions: ExpressionDebugInfo[] = [];\n if (rawFunc.expressions) {\n for (const expr of rawFunc.expressions) {\n expressions.push(convertExpression(expr, debugSourceFiles, projectRoot));\n }\n }\n\n const converted: FunctionDebugInfo = {\n wasmIndex: rawFunc.wasmIndex,\n name: rawFunc.name,\n representativeLocation,\n coverageMemoryIndex: rawFunc.coverageMemoryIndex,\n expressions,\n basicBlocks: rawFunc.basicBlocks,\n };\n\n const filePath = representativeLocation.filePath;\n const positionKey = getPositionKey(representativeLocation);\n\n return { func: converted, filePath, positionKey };\n}\n\n/**\n * Check if two WASM function names are monomorphizations of the same generic function.\n * Generic monomorphizations share the same base name and suffix, differing only in\n * the type parameters inside angle brackets.\n *\n * e.g. \"assembly/compare/closeTo<bool\\2cbool>\" and \"assembly/compare/closeTo<bool\\2cu8>\"\n * e.g. \"assembly/expect/BaseExpectMatcher<bool>#constructor\" and \"assembly/expect/BaseExpectMatcher<i8>#constructor\"\n */\nfunction isGenericMonomorphizationMatch(nameA: string, nameB: string): boolean {\n const openA = nameA.indexOf('<');\n const openB = nameB.indexOf('<');\n\n // Both must contain generic type parameters\n if (openA === -1 || openB === -1) return false;\n\n const lastCloseA = nameA.lastIndexOf('>');\n const lastCloseB = nameB.lastIndexOf('>');\n\n if (lastCloseA === -1 || lastCloseB === -1) return false;\n\n // Prefix before '<' must match (includes module path, class, function name)\n const prefixA = nameA.substring(0, openA);\n const prefixB = nameB.substring(0, openB);\n if (prefixA !== prefixB) return false;\n\n // Suffix after last '>' must match (e.g. \"#constructor\", or empty)\n const suffixA = nameA.substring(lastCloseA + 1);\n const suffixB = nameB.substring(lastCloseB + 1);\n if (suffixA !== suffixB) return false;\n\n return true;\n}\n\n/**\n * Transform raw native addon output to processed BinaryDebugInfo\n */\nfunction transformDebugInfo(\n raw: NativeDebugInfoOutput,\n logPrefix: string,\n projectRoot: string,\n): BinaryDebugInfo {\n const functionsByFileAndPosition: Record<string, Record<string, FunctionDebugInfo[]>> = {};\n\n debug(`${logPrefix} - Converting ${raw.functions.length} functions`);\n\n let genericCollisionCount = 0;\n let skippedCount = 0;\n let instrumentedFunctionCount = 0;\n\n for (const rawFunc of raw.functions) {\n const result = convertFunction(rawFunc, raw.debugSourceFiles, projectRoot);\n if (!result) {\n debug(`${logPrefix} - WARNING: Skipped function (bad conversion): \"${rawFunc.name}\"`);\n skippedCount++;\n continue;\n }\n\n const { func, filePath, positionKey } = result;\n\n // Check for position collisions\n const existingAtPosition = functionsByFileAndPosition[filePath]?.[positionKey];\n if (existingAtPosition) {\n const existingName = existingAtPosition[0]!.name;\n\n // Only allow collision if both are monomorphizations of the same generic\n if (isGenericMonomorphizationMatch(existingName, func.name)) {\n existingAtPosition.push(func);\n genericCollisionCount++;\n instrumentedFunctionCount++;\n debug(\n `${logPrefix} - Generic monomorphization at ${filePath}:${positionKey}:`\n + ` \"${getShortFunctionName(func.name)}\" grouped with \"${getShortFunctionName(existingName)}\"`\n );\n continue;\n }\n\n throw createPoolError(\n `ERROR - Function Debug Position Collision at ${filePath}:${positionKey}: \"${getShortFunctionName(existingName)}\"`\n + ` will be replaced by \"${getShortFunctionName(func.name)}\". This is a bug. Please report it at:`\n + ` https://github.com/themattspiral/vitest-pool-assemblyscript/issues/new`,\n POOL_ERROR_NAMES.WASMInstrumentationError\n );\n }\n\n instrumentedFunctionCount++;\n\n // Group by file and position\n if (!functionsByFileAndPosition[filePath]) {\n functionsByFileAndPosition[filePath] = {};\n }\n\n functionsByFileAndPosition[filePath][positionKey] = [func];\n }\n\n debug(\n `${logPrefix} - BinaryDebugInfo transform complete: ${instrumentedFunctionCount} instrumented functions`\n + ` (${genericCollisionCount} generic collisions, ${skippedCount} skipped)`\n );\n\n return {\n debugSourceFiles: raw.debugSourceFiles,\n functionsByFileAndPosition,\n instrumentedFunctionCount,\n };\n}\n\n/**\n * Instrument a WASM binary for coverage collection and regenerate source map\n *\n * This function:\n * 1. Adds __coverage_memory import (multi-memory for coverage counters)\n * 2. Injects coverage counter increments at each function entry\n * 3. Regenerates source map with correct offsets after instrumentation\n * 4. Extracts debug info with coverageMemoryIndex assigned\n *\n * @param wasmBuffer - Buffer containing the clean WASM binary\n * @param sourceMapBuffer - Buffer containing the source map JSON\n * @returns Instrumented binary, regenerated source map, and debug info\n *\n * @throws {TypeError} If wasmBuffer or sourceMapBuffer are not Buffers\n * @throws {Error} If WASM binary or source map is invalid\n */\nexport const instrumentForCoverage: InstrumentForCoverageFunc = (\n wasmBuffer: Buffer,\n sourceMapBuffer: Buffer,\n instrumentationOptions: InstrumentationOptions,\n logModule: string,\n logLabel: string,\n): InstrumentationResult => {\n if (!Buffer.isBuffer(wasmBuffer)) {\n throw createPoolError(\n 'instrumentForCoverage - wasmBuffer must be a Buffer',\n POOL_ERROR_NAMES.WASMInstrumentationError\n );\n }\n if (!Buffer.isBuffer(sourceMapBuffer)) {\n throw createPoolError(\n 'instrumentForCoverage - sourceMapBuffer must be a Buffer',\n POOL_ERROR_NAMES.WASMInstrumentationError\n );\n }\n\n const interfaceLogPrefix = `[${logModule} Inst] ${logLabel}`;\n const nativeLogPrefix = `[${logModule} InstNative] ${logLabel}`;\n\n debug(`${interfaceLogPrefix} - Calling native instrumentForCoverage`);\n const startTime = performance.now();\n\n const options: NativeInstrumentationOptions = {\n coverageMemoryPagesMin: instrumentationOptions.coverageMemoryPagesMin,\n coverageMemoryPagesMax: instrumentationOptions.coverageMemoryPagesMax,\n excludedFiles: instrumentationOptions.relativeExcludedFiles,\n excludedLibraryFilePrefix: instrumentationOptions.excludedLibraryFilePrefix,\n excludedLibraryFileOverridePrefix: instrumentationOptions.excludedLibraryFileOverridePrefix,\n debug: instrumentationOptions.debug,\n logPrefix: nativeLogPrefix\n };\n const nativeResult: NativeInstrumentationResult = addon.instrumentForCoverage(wasmBuffer, sourceMapBuffer, options);\n const addonTime = performance.now();\n debug(`${interfaceLogPrefix} - TIMING Native addon: ${(addonTime - startTime).toFixed(2)} ms`);\n\n if (nativeResult.errors?.length) {\n throw createPoolError(\n `Errors encountered duriing native instrumentation: ${nativeResult.errors.join('\\n')}`,\n POOL_ERROR_NAMES.WASMInstrumentationError,\n );\n }\n\n const debugInfo = transformDebugInfo(nativeResult.debugInfo, interfaceLogPrefix, instrumentationOptions.projectRoot);\n \n const transformTime = performance.now();\n debug(`${interfaceLogPrefix} - TIMING DebugInfo Transform: ${(transformTime - addonTime).toFixed(2)} ms`);\n debug(`${interfaceLogPrefix} - Binary size: ${nativeResult.instrumentedWasm.length} bytes | Source map size: ${nativeResult.sourceMap.length * 2} bytes`);\n\n return {\n instrumentedWasm: nativeResult.instrumentedWasm,\n sourceMap: nativeResult.sourceMap,\n debugInfo,\n };\n}\n"],"mappings":"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"}
@@ -3,8 +3,8 @@ import { createPoolErrorFromAnyError, debug, getTestErrorFromPoolError } from ".
3
3
  import { toForwardSlash } from "./path-utils-t9OzjXYF.mjs";
4
4
  import { failFile, getFullTaskHierarchy, prepareFileTaskForCollection } from "./vitest-file-tasks-Bn9CrWt_.mjs";
5
5
  import { getTaskLogLabel, getTaskLogPrefix } from "./vitest-tasks--ow4pacR.mjs";
6
- import { executeWASMDiscovery, flushRpcUpdates, reportFileCollected, reportFileError, reportFileQueued, reportUserConsoleLogs } from "./load-user-imports-BIQvqM7K.mjs";
7
- import { compileAssemblyScript } from "./compiler-CBBHCPAU.mjs";
6
+ import { executeWASMDiscovery, flushRpcUpdates, reportFileCollected, reportFileError, reportFileQueued, reportUserConsoleLogs } from "./load-user-imports-B3Iy_K8k.mjs";
7
+ import { compileAssemblyScript } from "./compiler-YMrl5MY_.mjs";
8
8
  import { basename, relative } from "node:path";
9
9
 
10
10
  //#region src/pool-thread/runner/compile-runner.ts
@@ -81,4 +81,4 @@ async function runCompileAndDiscover(file, logModule, rpc, poolOptions, projectR
81
81
 
82
82
  //#endregion
83
83
  export { runCompileAndDiscover };
84
- //# sourceMappingURL=compile-runner-DrDjhdPG.mjs.map
84
+ //# sourceMappingURL=compile-runner-C-05LdGX.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-runner-DrDjhdPG.mjs","names":[],"sources":["../src/pool-thread/runner/compile-runner.ts"],"sourcesContent":["/**\n * Worker thread test runner logic for AssemblyScript Pool\n */\n\nimport { basename, relative } from 'node:path';\nimport type { File } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\n\nimport { toForwardSlash } from '../../util/path-utils.js';\n\nimport type {\n AssemblyScriptCompilerOptions,\n AssemblyScriptConsoleLog,\n AssemblyScriptConsoleLogHandler,\n InstrumentationOptions,\n ResolvedAssemblyScriptPoolOptions,\n ThreadImports,\n WASMCompilation,\n WorkerRPC,\n} from '../../types/types.js';\nimport {\n ASSEMBLYSCRIPT_LIB_PREFIX,\n INTERNAL_PATH_LIB_PREFIX,\n POOL_ERROR_NAMES,\n POOL_INTERNAL_PATHS,\n} from '../../types/constants.js';\nimport { executeWASMDiscovery } from '../../wasm-executor/index.js';\nimport { debug } from '../../util/debug.js';\nimport {\n reportFileQueued,\n reportFileCollected,\n reportUserConsoleLogs,\n flushRpcUpdates,\n reportFileError,\n} from '../rpc-reporter.js';\nimport { createPoolErrorFromAnyError, getTestErrorFromPoolError } from '../../util/pool-errors.js';\nimport { compileAssemblyScript } from '../../compiler/index.js';\nimport {\n getTaskLogLabel,\n getTaskLogPrefix,\n} from '../../util/vitest-tasks.js';\nimport {\n failFile,\n getFullTaskHierarchy,\n prepareFileTaskForCollection,\n} from '../../util/vitest-file-tasks.js';\n\nlet threadCompilationCount: number = 0;\n\nexport async function runCompileAndDiscover(\n file: File,\n logModule: string,\n rpc: WorkerRPC,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n projectRoot: string,\n collectCoverage: boolean,\n relativeUserCoverageExclusions: string[],\n threadImports: ThreadImports,\n diffOptions?: SerializedDiffOptions,\n testNamePattern?: RegExp,\n allowOnly?: boolean,\n): Promise<WASMCompilation | undefined> {\n const base = basename(file.filepath);\n const fileLogPrefix = getTaskLogPrefix(logModule, base, file);\n const fileLogLabel = getTaskLogLabel(base, file);\n\n debug(`${fileLogPrefix} - Beginning runCompileAndDiscover for \"${file.filepath}\" at ${Date.now()}`);\n\n const runStart = performance.now();\n let compilation: WASMCompilation | undefined;\n\n try {\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n\n const relativeTestFilePath = toForwardSlash(relative(projectRoot, file.filepath));\n const instrumentationOptions: InstrumentationOptions = {\n projectRoot,\n relativeExcludedFiles: [\n relativeTestFilePath,\n ...(poolOptions._instrumentPoolInternals ? [] : POOL_INTERNAL_PATHS),\n ...relativeUserCoverageExclusions,\n ],\n excludedLibraryFilePrefix: ASSEMBLYSCRIPT_LIB_PREFIX,\n excludedLibraryFileOverridePrefix: poolOptions._instrumentPoolInternals ? INTERNAL_PATH_LIB_PREFIX : undefined,\n coverageMemoryPagesMin: poolOptions.coverageMemoryPagesInitial,\n coverageMemoryPagesMax: poolOptions.coverageMemoryPagesMax,\n debug: poolOptions.debugNative,\n };\n const compilerOptions: AssemblyScriptCompilerOptions = {\n stripInline: poolOptions.stripInline,\n projectRoot: projectRoot,\n shouldInstrument: collectCoverage,\n instrumentationOptions,\n extraFlags: poolOptions.extraCompilerFlags\n };\n\n const { binary, sourceMap, debugInfo, compileTiming } = await compileAssemblyScript(\n file.filepath,\n compilerOptions,\n logModule,\n fileLogLabel\n );\n file.setupDuration = compileTiming;\n threadCompilationCount++;\n\n debug(`${fileLogPrefix} - TIMING compileAssemblyScript total `\n + `(thread comp # ${threadCompilationCount}): ${compileTiming.toFixed(2)} ms`\n );\n \n const logMessages: AssemblyScriptConsoleLog[] = [];\n const handleLog: AssemblyScriptConsoleLogHandler = (msg: string, isError: boolean = false): void => {\n logMessages.push({ msg, time: Date.now(), isError });\n };\n \n const discoverStart = performance.now();\n\n await executeWASMDiscovery(\n binary,\n sourceMap,\n base,\n poolOptions,\n collectCoverage,\n handleLog,\n file,\n logModule,\n threadImports,\n diffOptions\n );\n\n // set skips when using only and/or user test name pattern, skip file task if all tests skipped\n prepareFileTaskForCollection(file, testNamePattern, allowOnly);\n\n file.collectDuration = performance.now() - discoverStart;\n debug(`${fileLogPrefix} - TIMING Discovery Phase: ${file.collectDuration.toFixed(2)} ms`);\n\n // vitest collect - report discovery results\n await Promise.all([\n // Report user console logs\n reportUserConsoleLogs(rpc, logMessages, logModule, base, file),\n\n // Report onCollected with collected and filtered tasks\n reportFileCollected(rpc, file, logModule, fileLogLabel),\n ]);\n\n debug(() => `${fileLogPrefix} - Collected Test Suite Hierarchy:\\n${getFullTaskHierarchy(file)}`);\n\n const totalTime = performance.now() - runStart;\n debug(`${fileLogPrefix} - TIMING Compilation and Discovery: ${totalTime.toFixed(2)} ms`);\n\n compilation = {\n filePath: file.filepath,\n binary,\n sourceMap,\n debugInfo,\n };\n } catch (error) {\n const poolError = createPoolErrorFromAnyError(\n `${fileLogLabel} - runCompileAndDiscover failure in worker`,\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n error\n );\n const testError = getTestErrorFromPoolError(poolError);\n\n failFile(file, testError, runStart);\n\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n await reportFileError(rpc, file, logModule, fileLogLabel);\n\n debug(`${fileLogPrefix} - Reported file error`);\n } finally {\n await flushRpcUpdates(rpc);\n debug(`${fileLogPrefix} - runCompileAndDiscover Completed`);\n }\n\n return compilation;\n}\n"],"mappings":";;;;;;;;;;;;;AA+CA,IAAI,yBAAiC;AAErC,eAAsB,sBACpB,MACA,WACA,KACA,aACA,aACA,iBACA,gCACA,eACA,aACA,iBACA,WACsC;CACtC,MAAM,OAAO,SAAS,KAAK,SAAS;CACpC,MAAM,gBAAgB,iBAAiB,WAAW,MAAM,KAAK;CAC7D,MAAM,eAAe,gBAAgB,MAAM,KAAK;AAEhD,OAAM,GAAG,cAAc,0CAA0C,KAAK,SAAS,OAAO,KAAK,KAAK,GAAG;CAEnG,MAAM,WAAW,YAAY,KAAK;CAClC,IAAI;AAEJ,KAAI;AACF,QAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;EAG1D,MAAM,yBAAiD;GACrD;GACA,uBAAuB;IAHI,eAAe,SAAS,aAAa,KAAK,SAAS,CAAC;IAK7E,GAAI,YAAY,2BAA2B,EAAE,GAAG;IAChD,GAAG;IACJ;GACD;GACA,mCAAmC,YAAY,2BAA2B,2BAA2B;GACrG,wBAAwB,YAAY;GACpC,wBAAwB,YAAY;GACpC,OAAO,YAAY;GACpB;EACD,MAAM,kBAAiD;GACrD,aAAa,YAAY;GACZ;GACb,kBAAkB;GAClB;GACA,YAAY,YAAY;GACzB;EAED,MAAM,EAAE,QAAQ,WAAW,WAAW,kBAAkB,MAAM,sBAC5D,KAAK,UACL,iBACA,WACA,aACD;AACD,OAAK,gBAAgB;AACrB;AAEA,QAAM,GAAG,cAAc,uDACD,uBAAuB,KAAK,cAAc,QAAQ,EAAE,CAAC,KAC1E;EAED,MAAM,cAA0C,EAAE;EAClD,MAAM,aAA8C,KAAa,UAAmB,UAAgB;AAClG,eAAY,KAAK;IAAE;IAAK,MAAM,KAAK,KAAK;IAAE;IAAS,CAAC;;EAGtD,MAAM,gBAAgB,YAAY,KAAK;AAEvC,QAAM,qBACJ,QACA,WACA,MACA,aACA,iBACA,WACA,MACA,WACA,eACA,YACD;AAGD,+BAA6B,MAAM,iBAAiB,UAAU;AAE9D,OAAK,kBAAkB,YAAY,KAAK,GAAG;AAC3C,QAAM,GAAG,cAAc,6BAA6B,KAAK,gBAAgB,QAAQ,EAAE,CAAC,KAAK;AAGzF,QAAM,QAAQ,IAAI,CAEhB,sBAAsB,KAAK,aAAa,WAAW,MAAM,KAAK,EAG9D,oBAAoB,KAAK,MAAM,WAAW,aAAa,CACxD,CAAC;AAEF,cAAY,GAAG,cAAc,sCAAsC,qBAAqB,KAAK,GAAG;AAGhG,QAAM,GAAG,cAAc,wCADL,YAAY,KAAK,GAAG,UACkC,QAAQ,EAAE,CAAC,KAAK;AAExF,gBAAc;GACZ,UAAU,KAAK;GACf;GACA;GACA;GACD;UACM,OAAO;AAQd,WAAS,MAFS,0BALA,4BAChB,GAAG,aAAa,6CAChB,iBAAiB,2BACjB,MACD,CACqD,EAE5B,SAAS;AAEnC,QAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;AAC1D,QAAM,gBAAgB,KAAK,MAAM,WAAW,aAAa;AAEzD,QAAM,GAAG,cAAc,wBAAwB;WACvC;AACR,QAAM,gBAAgB,IAAI;AAC1B,QAAM,GAAG,cAAc,oCAAoC;;AAG7D,QAAO"}
1
+ {"version":3,"file":"compile-runner-C-05LdGX.mjs","names":[],"sources":["../src/pool-thread/runner/compile-runner.ts"],"sourcesContent":["/**\n * Worker thread test runner logic for AssemblyScript Pool\n */\n\nimport { basename, relative } from 'node:path';\nimport type { File } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\n\nimport { toForwardSlash } from '../../util/path-utils.js';\n\nimport type {\n AssemblyScriptCompilerOptions,\n AssemblyScriptConsoleLog,\n AssemblyScriptConsoleLogHandler,\n InstrumentationOptions,\n ResolvedAssemblyScriptPoolOptions,\n ThreadImports,\n WASMCompilation,\n WorkerRPC,\n} from '../../types/types.js';\nimport {\n ASSEMBLYSCRIPT_LIB_PREFIX,\n INTERNAL_PATH_LIB_PREFIX,\n POOL_ERROR_NAMES,\n POOL_INTERNAL_PATHS,\n} from '../../types/constants.js';\nimport { executeWASMDiscovery } from '../../wasm-executor/index.js';\nimport { debug } from '../../util/debug.js';\nimport {\n reportFileQueued,\n reportFileCollected,\n reportUserConsoleLogs,\n flushRpcUpdates,\n reportFileError,\n} from '../rpc-reporter.js';\nimport { createPoolErrorFromAnyError, getTestErrorFromPoolError } from '../../util/pool-errors.js';\nimport { compileAssemblyScript } from '../../compiler/index.js';\nimport {\n getTaskLogLabel,\n getTaskLogPrefix,\n} from '../../util/vitest-tasks.js';\nimport {\n failFile,\n getFullTaskHierarchy,\n prepareFileTaskForCollection,\n} from '../../util/vitest-file-tasks.js';\n\nlet threadCompilationCount: number = 0;\n\nexport async function runCompileAndDiscover(\n file: File,\n logModule: string,\n rpc: WorkerRPC,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n projectRoot: string,\n collectCoverage: boolean,\n relativeUserCoverageExclusions: string[],\n threadImports: ThreadImports,\n diffOptions?: SerializedDiffOptions,\n testNamePattern?: RegExp,\n allowOnly?: boolean,\n): Promise<WASMCompilation | undefined> {\n const base = basename(file.filepath);\n const fileLogPrefix = getTaskLogPrefix(logModule, base, file);\n const fileLogLabel = getTaskLogLabel(base, file);\n\n debug(`${fileLogPrefix} - Beginning runCompileAndDiscover for \"${file.filepath}\" at ${Date.now()}`);\n\n const runStart = performance.now();\n let compilation: WASMCompilation | undefined;\n\n try {\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n\n const relativeTestFilePath = toForwardSlash(relative(projectRoot, file.filepath));\n const instrumentationOptions: InstrumentationOptions = {\n projectRoot,\n relativeExcludedFiles: [\n relativeTestFilePath,\n ...(poolOptions._instrumentPoolInternals ? [] : POOL_INTERNAL_PATHS),\n ...relativeUserCoverageExclusions,\n ],\n excludedLibraryFilePrefix: ASSEMBLYSCRIPT_LIB_PREFIX,\n excludedLibraryFileOverridePrefix: poolOptions._instrumentPoolInternals ? INTERNAL_PATH_LIB_PREFIX : undefined,\n coverageMemoryPagesMin: poolOptions.coverageMemoryPagesInitial,\n coverageMemoryPagesMax: poolOptions.coverageMemoryPagesMax,\n debug: poolOptions.debugNative,\n };\n const compilerOptions: AssemblyScriptCompilerOptions = {\n stripInline: poolOptions.stripInline,\n projectRoot: projectRoot,\n shouldInstrument: collectCoverage,\n instrumentationOptions,\n extraFlags: poolOptions.extraCompilerFlags\n };\n\n const { binary, sourceMap, debugInfo, compileTiming } = await compileAssemblyScript(\n file.filepath,\n compilerOptions,\n logModule,\n fileLogLabel\n );\n file.setupDuration = compileTiming;\n threadCompilationCount++;\n\n debug(`${fileLogPrefix} - TIMING compileAssemblyScript total `\n + `(thread comp # ${threadCompilationCount}): ${compileTiming.toFixed(2)} ms`\n );\n \n const logMessages: AssemblyScriptConsoleLog[] = [];\n const handleLog: AssemblyScriptConsoleLogHandler = (msg: string, isError: boolean = false): void => {\n logMessages.push({ msg, time: Date.now(), isError });\n };\n \n const discoverStart = performance.now();\n\n await executeWASMDiscovery(\n binary,\n sourceMap,\n base,\n poolOptions,\n collectCoverage,\n handleLog,\n file,\n logModule,\n threadImports,\n diffOptions\n );\n\n // set skips when using only and/or user test name pattern, skip file task if all tests skipped\n prepareFileTaskForCollection(file, testNamePattern, allowOnly);\n\n file.collectDuration = performance.now() - discoverStart;\n debug(`${fileLogPrefix} - TIMING Discovery Phase: ${file.collectDuration.toFixed(2)} ms`);\n\n // vitest collect - report discovery results\n await Promise.all([\n // Report user console logs\n reportUserConsoleLogs(rpc, logMessages, logModule, base, file),\n\n // Report onCollected with collected and filtered tasks\n reportFileCollected(rpc, file, logModule, fileLogLabel),\n ]);\n\n debug(() => `${fileLogPrefix} - Collected Test Suite Hierarchy:\\n${getFullTaskHierarchy(file)}`);\n\n const totalTime = performance.now() - runStart;\n debug(`${fileLogPrefix} - TIMING Compilation and Discovery: ${totalTime.toFixed(2)} ms`);\n\n compilation = {\n filePath: file.filepath,\n binary,\n sourceMap,\n debugInfo,\n };\n } catch (error) {\n const poolError = createPoolErrorFromAnyError(\n `${fileLogLabel} - runCompileAndDiscover failure in worker`,\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n error\n );\n const testError = getTestErrorFromPoolError(poolError);\n\n failFile(file, testError, runStart);\n\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n await reportFileError(rpc, file, logModule, fileLogLabel);\n\n debug(`${fileLogPrefix} - Reported file error`);\n } finally {\n await flushRpcUpdates(rpc);\n debug(`${fileLogPrefix} - runCompileAndDiscover Completed`);\n }\n\n return compilation;\n}\n"],"mappings":";;;;;;;;;;;;;AA+CA,IAAI,yBAAiC;AAErC,eAAsB,sBACpB,MACA,WACA,KACA,aACA,aACA,iBACA,gCACA,eACA,aACA,iBACA,WACsC;CACtC,MAAM,OAAO,SAAS,KAAK,SAAS;CACpC,MAAM,gBAAgB,iBAAiB,WAAW,MAAM,KAAK;CAC7D,MAAM,eAAe,gBAAgB,MAAM,KAAK;AAEhD,OAAM,GAAG,cAAc,0CAA0C,KAAK,SAAS,OAAO,KAAK,KAAK,GAAG;CAEnG,MAAM,WAAW,YAAY,KAAK;CAClC,IAAI;AAEJ,KAAI;AACF,QAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;EAG1D,MAAM,yBAAiD;GACrD;GACA,uBAAuB;IAHI,eAAe,SAAS,aAAa,KAAK,SAAS,CAAC;IAK7E,GAAI,YAAY,2BAA2B,EAAE,GAAG;IAChD,GAAG;IACJ;GACD;GACA,mCAAmC,YAAY,2BAA2B,2BAA2B;GACrG,wBAAwB,YAAY;GACpC,wBAAwB,YAAY;GACpC,OAAO,YAAY;GACpB;EACD,MAAM,kBAAiD;GACrD,aAAa,YAAY;GACZ;GACb,kBAAkB;GAClB;GACA,YAAY,YAAY;GACzB;EAED,MAAM,EAAE,QAAQ,WAAW,WAAW,kBAAkB,MAAM,sBAC5D,KAAK,UACL,iBACA,WACA,aACD;AACD,OAAK,gBAAgB;AACrB;AAEA,QAAM,GAAG,cAAc,uDACD,uBAAuB,KAAK,cAAc,QAAQ,EAAE,CAAC,KAC1E;EAED,MAAM,cAA0C,EAAE;EAClD,MAAM,aAA8C,KAAa,UAAmB,UAAgB;AAClG,eAAY,KAAK;IAAE;IAAK,MAAM,KAAK,KAAK;IAAE;IAAS,CAAC;;EAGtD,MAAM,gBAAgB,YAAY,KAAK;AAEvC,QAAM,qBACJ,QACA,WACA,MACA,aACA,iBACA,WACA,MACA,WACA,eACA,YACD;AAGD,+BAA6B,MAAM,iBAAiB,UAAU;AAE9D,OAAK,kBAAkB,YAAY,KAAK,GAAG;AAC3C,QAAM,GAAG,cAAc,6BAA6B,KAAK,gBAAgB,QAAQ,EAAE,CAAC,KAAK;AAGzF,QAAM,QAAQ,IAAI,CAEhB,sBAAsB,KAAK,aAAa,WAAW,MAAM,KAAK,EAG9D,oBAAoB,KAAK,MAAM,WAAW,aAAa,CACxD,CAAC;AAEF,cAAY,GAAG,cAAc,sCAAsC,qBAAqB,KAAK,GAAG;AAGhG,QAAM,GAAG,cAAc,wCADL,YAAY,KAAK,GAAG,UACkC,QAAQ,EAAE,CAAC,KAAK;AAExF,gBAAc;GACZ,UAAU,KAAK;GACf;GACA;GACA;GACD;UACM,OAAO;AAQd,WAAS,MAFS,0BALA,4BAChB,GAAG,aAAa,6CAChB,iBAAiB,2BACjB,MACD,CACqD,EAE5B,SAAS;AAEnC,QAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;AAC1D,QAAM,gBAAgB,KAAK,MAAM,WAAW,aAAa;AAEzD,QAAM,GAAG,cAAc,wBAAwB;WACvC;AACR,QAAM,gBAAgB,IAAI;AAC1B,QAAM,GAAG,cAAc,oCAAoC;;AAG7D,QAAO"}
@@ -31,8 +31,7 @@ var StripInlineTransform = class extends Transform {
31
31
  for (const source of userSources) this.visitor.visitSource(source);
32
32
  }
33
33
  };
34
- var strip_inline_default = StripInlineTransform;
35
34
 
36
35
  //#endregion
37
- export { strip_inline_default as default };
36
+ export { StripInlineTransform as default };
38
37
  //# sourceMappingURL=strip-inline.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"strip-inline.mjs","names":[],"sources":["../../../src/compiler/transforms/strip-inline.mts"],"sourcesContent":["/**\n * AssemblyScript Transform to strip @inline decorators\n *\n * Production code uses @inline decorators for performance. When functions are inlined,\n * coverage instrumentation can't track their execution. This transform removes @inline\n * decorators from the AST during test compilation, allowing coverage instrumentation\n * to properly track function calls.\n * \n * - Hooks into the AssemblyScript compiler's `afterParse` lifecycle\n * - Walks through all parsed source files before compilation begins\n * - Uses shared ASTVisitor to recurse into ALL node types\n * - Strips @inline decorators from any node that has them in user code\n *\n * @see https://www.assemblyscript.org/compiler.html#transforms\n * @see https://github.com/AssemblyScript/assemblyscript/blob/main/src/ast.ts\n */\n\nimport { Node, Parser, Source, DecoratorNode } from 'assemblyscript';\nimport { Transform } from 'assemblyscript/transform';\n\nimport { ASTVisitor } from '../../util/ast-visitor.js';\nimport {\n ASSEMBLYSCRIPT_LIB_PREFIX,\n ASDecoratorKind,\n ASSourceKind,\n} from '../../types/constants.js';\n\n/**\n * Visitor that strips @inline decorators from nodes\n */\nclass StripInlineVisitor extends ASTVisitor {\n /**\n * Strip @inline decorator from a node if present\n */\n protected beforeVisit(node: Node): void {\n if ('decorators' in node && node.decorators) {\n const filtered = (node.decorators as DecoratorNode[]).filter(\n (decorator: DecoratorNode) => decorator.decoratorKind !== ASDecoratorKind.Inline\n );\n node.decorators = filtered.length > 0 ? filtered : null;\n }\n }\n}\n\n/**\n * AssemblyScript compiler transform that strips @inline decorators\n */\nclass StripInlineTransform extends Transform {\n private visitor = new StripInlineVisitor();\n\n /**\n * Called after parsing is complete, before the program is initialized.\n * This is the ideal time to modify the AST.\n */\n afterParse(_parser: Parser): void {\n const sources = (this as Transform).program.sources;\n\n // Filter to user source files only\n const userSources = sources.filter((source: Source) =>\n (source.sourceKind === ASSourceKind.User || source.sourceKind === ASSourceKind.UserEntry)\n && !source.normalizedPath.startsWith(ASSEMBLYSCRIPT_LIB_PREFIX)\n );\n\n for (const source of userSources) {\n this.visitor.visitSource(source);\n }\n }\n}\n\nexport default StripInlineTransform;\n"],"mappings":";;;;;;;;AA8BA,IAAM,qBAAN,cAAiC,WAAW;;;;CAI1C,AAAU,YAAY,MAAkB;AACtC,MAAI,gBAAgB,QAAQ,KAAK,YAAY;GAC3C,MAAM,WAAY,KAAK,WAA+B,QACnD,cAA6B,UAAU,kBAAkB,gBAAgB,OAC3E;AACD,QAAK,aAAa,SAAS,SAAS,IAAI,WAAW;;;;;;;AAQzD,IAAM,uBAAN,cAAmC,UAAU;CAC3C,AAAQ,UAAU,IAAI,oBAAoB;;;;;CAM1C,WAAW,SAAuB;EAIhC,MAAM,cAHW,KAAmB,QAAQ,QAGhB,QAAQ,YACjC,OAAO,eAAe,aAAa,QAAQ,OAAO,eAAe,aAAa,cAC5E,CAAC,OAAO,eAAe,mBAAqC,CAChE;AAED,OAAK,MAAM,UAAU,YACnB,MAAK,QAAQ,YAAY,OAAO;;;AAKtC,2BAAe"}
1
+ {"version":3,"file":"strip-inline.mjs","names":[],"sources":["../../../src/compiler/transforms/strip-inline.mts"],"sourcesContent":["/**\n * AssemblyScript Transform to strip @inline decorators\n *\n * Production code uses @inline decorators for performance. When functions are inlined,\n * coverage instrumentation can't track their execution. This transform removes @inline\n * decorators from the AST during test compilation, allowing coverage instrumentation\n * to properly track function calls.\n * \n * - Hooks into the AssemblyScript compiler's `afterParse` lifecycle\n * - Walks through all parsed source files before compilation begins\n * - Uses shared ASTVisitor to recurse into ALL node types\n * - Strips @inline decorators from any node that has them in user code\n *\n * @see https://www.assemblyscript.org/compiler.html#transforms\n * @see https://github.com/AssemblyScript/assemblyscript/blob/main/src/ast.ts\n */\n\nimport { Node, Parser, Source, DecoratorNode } from 'assemblyscript';\nimport { Transform } from 'assemblyscript/transform';\n\nimport { ASTVisitor } from '../../util/ast-visitor.js';\nimport {\n ASSEMBLYSCRIPT_LIB_PREFIX,\n ASDecoratorKind,\n ASSourceKind,\n} from '../../types/constants.js';\n\n/**\n * Visitor that strips @inline decorators from nodes\n */\nclass StripInlineVisitor extends ASTVisitor {\n /**\n * Strip @inline decorator from a node if present\n */\n protected beforeVisit(node: Node): void {\n if ('decorators' in node && node.decorators) {\n const filtered = (node.decorators as DecoratorNode[]).filter(\n (decorator: DecoratorNode) => decorator.decoratorKind !== ASDecoratorKind.Inline\n );\n node.decorators = filtered.length > 0 ? filtered : null;\n }\n }\n}\n\n/**\n * AssemblyScript compiler transform that strips @inline decorators\n */\nclass StripInlineTransform extends Transform {\n private visitor = new StripInlineVisitor();\n\n /**\n * Called after parsing is complete, before the program is initialized.\n * This is the ideal time to modify the AST.\n */\n afterParse(_parser: Parser): void {\n const sources = (this as Transform).program.sources;\n\n // Filter to user source files only\n const userSources = sources.filter((source: Source) =>\n (source.sourceKind === ASSourceKind.User || source.sourceKind === ASSourceKind.UserEntry)\n && !source.normalizedPath.startsWith(ASSEMBLYSCRIPT_LIB_PREFIX)\n );\n\n for (const source of userSources) {\n this.visitor.visitSource(source);\n }\n }\n}\n\nexport default StripInlineTransform;\n"],"mappings":";;;;;;;;AA8BA,IAAM,qBAAN,cAAiC,WAAW;;;;CAI1C,AAAU,YAAY,MAAkB;AACtC,MAAI,gBAAgB,QAAQ,KAAK,YAAY;GAC3C,MAAM,WAAY,KAAK,WAA+B,QACnD,cAA6B,UAAU,kBAAkB,gBAAgB,OAC3E;AACD,QAAK,aAAa,SAAS,SAAS,IAAI,WAAW;;;;;;;AAQzD,IAAM,uBAAN,cAAmC,UAAU;CAC3C,AAAQ,UAAU,IAAI,oBAAoB;;;;;CAM1C,WAAW,SAAuB;EAIhC,MAAM,cAHW,KAAmB,QAAQ,QAGhB,QAAQ,YACjC,OAAO,eAAe,aAAa,QAAQ,OAAO,eAAe,aAAa,cAC5E,CAAC,OAAO,eAAe,mBAAqC,CAChE;AAED,OAAK,MAAM,UAAU,YACnB,MAAK,QAAQ,YAAY,OAAO"}