vitest-pool-assemblyscript 0.8.0 → 0.9.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 (93) hide show
  1. package/README.md +10 -13
  2. package/assembly/compare.ts +453 -95
  3. package/assembly/expect.ts +113 -62
  4. package/assembly/index.ts +0 -10
  5. package/assembly/utils.ts +168 -0
  6. package/dist/{addon-interface-_pNXcbib.mjs → addon-interface-CYFXMbK7.mjs} +4 -3
  7. package/dist/addon-interface-CYFXMbK7.mjs.map +1 -0
  8. package/dist/{ast-visitor-C5gQqWD2.mjs → ast-visitor-CWEOd3UH.mjs} +15 -2
  9. package/dist/ast-visitor-CWEOd3UH.mjs.map +1 -0
  10. package/dist/{compile-runner-DOMhsLQE.mjs → compile-runner-BGQhBkBo.mjs} +8 -7
  11. package/dist/compile-runner-BGQhBkBo.mjs.map +1 -0
  12. package/dist/compiler/transforms/deep-equals.d.mts +14 -0
  13. package/dist/compiler/transforms/deep-equals.d.mts.map +1 -0
  14. package/dist/compiler/transforms/deep-equals.mjs +245 -0
  15. package/dist/compiler/transforms/deep-equals.mjs.map +1 -0
  16. package/dist/compiler/transforms/strip-inline.mjs +2 -2
  17. package/dist/{compiler-CIXpfKq0.mjs → compiler-hUlDr5vL.mjs} +14 -6
  18. package/dist/compiler-hUlDr5vL.mjs.map +1 -0
  19. package/dist/config/index-v3.d.mts +33 -3
  20. package/dist/config/index-v3.d.mts.map +1 -1
  21. package/dist/config/index-v3.mjs.map +1 -1
  22. package/dist/config/index.d.mts +29 -4
  23. package/dist/config/index.d.mts.map +1 -0
  24. package/dist/config/index.mjs +6 -6
  25. package/dist/{constants-DuBLuMjt.mjs → constants-DbxJ3hzg.mjs} +10 -97
  26. package/dist/constants-DbxJ3hzg.mjs.map +1 -0
  27. package/dist/coverage-provider/index.mjs +30 -10
  28. package/dist/coverage-provider/index.mjs.map +1 -1
  29. package/dist/{debug-Cm1VFmaz.mjs → debug-DtRAL4rM.mjs} +38 -4
  30. package/dist/debug-DtRAL4rM.mjs.map +1 -0
  31. package/dist/{feature-check-ELxw_Mji.mjs → feature-check-Bje3ntpV.mjs} +2 -2
  32. package/dist/{feature-check-ELxw_Mji.mjs.map → feature-check-Bje3ntpV.mjs.map} +1 -1
  33. package/dist/index-internal.d.mts +1 -1
  34. package/dist/index-internal.d.mts.map +1 -1
  35. package/dist/index-internal.mjs +4 -4
  36. package/dist/index-v3.d.mts.map +1 -1
  37. package/dist/index-v3.mjs +8 -7
  38. package/dist/index-v3.mjs.map +1 -1
  39. package/dist/index.d.mts +1 -2
  40. package/dist/index.mjs +6 -6
  41. package/dist/{load-user-imports-B3Iy_K8k.mjs → load-user-imports-Bx5ZlhSm.mjs} +9 -9
  42. package/dist/load-user-imports-Bx5ZlhSm.mjs.map +1 -0
  43. package/dist/{pool-runner-init-BDQtAGwQ.mjs → pool-runner-init-BqkwQ2tk.mjs} +7 -7
  44. package/dist/pool-runner-init-BqkwQ2tk.mjs.map +1 -0
  45. package/dist/{pool-runner-init-CvnB0-iN.d.mts → pool-runner-init-CNpRdA5u.d.mts} +2 -2
  46. package/dist/pool-runner-init-CNpRdA5u.d.mts.map +1 -0
  47. package/dist/pool-thread/compile-worker-thread.d.mts +1 -1
  48. package/dist/pool-thread/compile-worker-thread.d.mts.map +1 -1
  49. package/dist/pool-thread/compile-worker-thread.mjs +10 -13
  50. package/dist/pool-thread/compile-worker-thread.mjs.map +1 -1
  51. package/dist/pool-thread/test-worker-thread.d.mts +1 -1
  52. package/dist/pool-thread/test-worker-thread.d.mts.map +1 -1
  53. package/dist/pool-thread/test-worker-thread.mjs +8 -11
  54. package/dist/pool-thread/test-worker-thread.mjs.map +1 -1
  55. package/dist/pool-thread/v3-tinypool-thread.d.mts +1 -1
  56. package/dist/pool-thread/v3-tinypool-thread.d.mts.map +1 -1
  57. package/dist/pool-thread/v3-tinypool-thread.mjs +12 -18
  58. package/dist/pool-thread/v3-tinypool-thread.mjs.map +1 -1
  59. package/dist/{resolve-config-DhZ4lOSK.mjs → resolve-config-s9gSJSMc.mjs} +14 -5
  60. package/dist/resolve-config-s9gSJSMc.mjs.map +1 -0
  61. package/dist/{test-runner-C4I9VknR.mjs → test-runner-BGqc9uCK.mjs} +4 -4
  62. package/dist/{test-runner-C4I9VknR.mjs.map → test-runner-BGqc9uCK.mjs.map} +1 -1
  63. package/dist/{types-D0nprJo1.d.mts → types-DHVk5iAx.d.mts} +17 -11
  64. package/dist/types-DHVk5iAx.d.mts.map +1 -0
  65. package/dist/vitest-file-tasks-D8sOClGX.mjs +149 -0
  66. package/dist/vitest-file-tasks-D8sOClGX.mjs.map +1 -0
  67. package/dist/{vitest-tasks--ow4pacR.mjs → vitest-tasks-BZ24sghI.mjs} +6 -4
  68. package/dist/vitest-tasks-BZ24sghI.mjs.map +1 -0
  69. package/package.json +11 -14
  70. package/prebuilds/darwin-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  71. package/prebuilds/darwin-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  72. package/prebuilds/linux-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  73. package/prebuilds/linux-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  74. package/prebuilds/linux-x64/vitest-pool-assemblyscript.musl.node +0 -0
  75. package/prebuilds/win32-arm64/vitest-pool-assemblyscript.glibc.node +0 -0
  76. package/prebuilds/win32-x64/vitest-pool-assemblyscript.glibc.node +0 -0
  77. package/src/instrumentation/native/addon.cpp +29 -3
  78. package/dist/addon-interface-_pNXcbib.mjs.map +0 -1
  79. package/dist/ast-visitor-C5gQqWD2.mjs.map +0 -1
  80. package/dist/compile-runner-DOMhsLQE.mjs.map +0 -1
  81. package/dist/compiler-CIXpfKq0.mjs.map +0 -1
  82. package/dist/constants-DuBLuMjt.mjs.map +0 -1
  83. package/dist/custom-provider-options-YTk1m7At.d.mts +0 -26
  84. package/dist/custom-provider-options-YTk1m7At.d.mts.map +0 -1
  85. package/dist/debug-Cm1VFmaz.mjs.map +0 -1
  86. package/dist/load-user-imports-B3Iy_K8k.mjs.map +0 -1
  87. package/dist/pool-runner-init-BDQtAGwQ.mjs.map +0 -1
  88. package/dist/pool-runner-init-CvnB0-iN.d.mts.map +0 -1
  89. package/dist/resolve-config-DhZ4lOSK.mjs.map +0 -1
  90. package/dist/types-D0nprJo1.d.mts.map +0 -1
  91. package/dist/vitest-file-tasks-Bn9CrWt_.mjs +0 -61
  92. package/dist/vitest-file-tasks-Bn9CrWt_.mjs.map +0 -1
  93. package/dist/vitest-tasks--ow4pacR.mjs.map +0 -1
@@ -0,0 +1,149 @@
1
+ import { calculateSuiteHash, createFileTask, someTasksAreOnly } from "@vitest/runner/utils";
2
+ import { processError } from "@vitest/utils/error";
3
+
4
+ //#region src/types/typed-constants.ts
5
+ const DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS = {
6
+ fails: false,
7
+ skip: false,
8
+ only: false
9
+ };
10
+
11
+ //#endregion
12
+ //#region src/util/vitest-file-tasks.ts
13
+ function createInitialFileTask(testFile, projectName, projectRoot, configTestTimeout, configRetry) {
14
+ const file = createFileTask(testFile, projectRoot, projectName, "assemblyscript");
15
+ file.mode = "queued";
16
+ file.environmentLoad = 0;
17
+ file.setupDuration = 0;
18
+ file.meta = {
19
+ idxInParentTasks: -1,
20
+ defaultTestOptions: {
21
+ ...DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS,
22
+ timeout: configTestTimeout,
23
+ retry: configRetry
24
+ },
25
+ suitePreparedSent: false,
26
+ resultFinal: false
27
+ };
28
+ return file;
29
+ }
30
+ function prepareFileTaskForCollection(file, testNamePattern, allowOnly) {
31
+ calculateSuiteHash(file);
32
+ interpretTaskModes(file, testNamePattern, void 0, void 0, void 0, someTasksAreOnly(file), false, allowOnly);
33
+ if (file.mode === "queued") file.mode = "run";
34
+ }
35
+ function failFile(file, error, runStartPerf) {
36
+ file.mode = "run";
37
+ if (file.result) {
38
+ file.result.state = "fail";
39
+ file.result.errors = file.result.errors ? file.result.errors.concat(error) : [error];
40
+ } else file.result = {
41
+ state: "fail",
42
+ errors: [error]
43
+ };
44
+ file.environmentLoad = file.environmentLoad ?? 0;
45
+ file.setupDuration = performance.now() - runStartPerf;
46
+ file.collectDuration = file.collectDuration ?? 0;
47
+ return file;
48
+ }
49
+ function getFullTaskHierarchy(file) {
50
+ function spacesForLevel(level) {
51
+ return new Array(level + 1).fill(" ").join("");
52
+ }
53
+ function taskStr(task, level) {
54
+ if (task.type === "test") return `${spacesForLevel(level)}ID: ${task.id} Mode: "${task.mode}" Test: "${task.name}"`;
55
+ else return `${spacesForLevel(level)}ID: ${task.id} Mode: "${task.mode}" Suite: "${task.name}"\n` + task.tasks.map((t) => taskStr(t, level + 1)).join("\n");
56
+ }
57
+ return taskStr(file, 0);
58
+ }
59
+ /**
60
+ * Function interface changes from vitest 4.0.x -> 4.1.x, so now were' just handling this
61
+ * functionality ourselves to prevent version compat conflicts.
62
+ *
63
+ * @see https://github.com/vitest-dev/vitest/blob/v4.1.0/packages/runner/src/utils/collect.ts#L10
64
+ *
65
+ * Vitest is released under the MIT license, included in this project's root.
66
+ * Copyright (c) 2021-Present Vitest Team
67
+ */
68
+ function interpretTaskModes(file, namePattern, testLocations, testIds, testTagsFilter, onlyMode, parentIsOnly, allowOnly) {
69
+ const matchedLocations = [];
70
+ const traverseSuite = (suite, parentIsOnly, parentMatchedWithLocation) => {
71
+ const suiteIsOnly = parentIsOnly || suite.mode === "only";
72
+ const hasSomeTasksOnly = onlyMode && suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
73
+ suite.tasks.forEach((t) => {
74
+ const includeTask = hasSomeTasksOnly ? t.mode === "only" || t.type === "suite" && someTasksAreOnly(t) : suiteIsOnly || t.mode === "only";
75
+ if (onlyMode) {
76
+ if (t.type === "suite" && (includeTask || someTasksAreOnly(t))) {
77
+ if (t.mode === "only") {
78
+ checkAllowOnly(t, allowOnly);
79
+ t.mode = "run";
80
+ }
81
+ } else if (t.mode === "run" && !includeTask) t.mode = "skip";
82
+ else if (t.mode === "only") {
83
+ checkAllowOnly(t, allowOnly);
84
+ t.mode = "run";
85
+ }
86
+ }
87
+ let hasLocationMatch = parentMatchedWithLocation;
88
+ if (testLocations !== void 0 && testLocations.length !== 0) {
89
+ if (t.location && testLocations?.includes(t.location.line)) {
90
+ t.mode = "run";
91
+ matchedLocations.push(t.location.line);
92
+ hasLocationMatch = true;
93
+ } else if (parentMatchedWithLocation) t.mode = "run";
94
+ else if (t.type === "test") t.mode = "skip";
95
+ }
96
+ if (t.type === "test") {
97
+ if (namePattern && !getTaskFullName(t).match(namePattern)) t.mode = "skip";
98
+ if (testIds && !testIds.includes(t.id)) t.mode = "skip";
99
+ if (testTagsFilter && !testTagsFilter(t.tags || [])) t.mode = "skip";
100
+ } else if (t.type === "suite") if (t.mode === "skip") skipAllTasks(t);
101
+ else if (t.mode === "todo") todoAllTasks(t);
102
+ else traverseSuite(t, includeTask, hasLocationMatch);
103
+ });
104
+ if (suite.mode === "run" || suite.mode === "queued") {
105
+ if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run" && i.mode !== "queued")) suite.mode = "skip";
106
+ }
107
+ };
108
+ traverseSuite(file, parentIsOnly, false);
109
+ const nonMatching = testLocations?.filter((loc) => !matchedLocations.includes(loc));
110
+ if (nonMatching && nonMatching.length !== 0) {
111
+ const message = nonMatching.length === 1 ? `line ${nonMatching[0]}` : `lines ${nonMatching.join(", ")}`;
112
+ if (file.result === void 0) file.result = {
113
+ state: "fail",
114
+ errors: []
115
+ };
116
+ if (file.result.errors === void 0) file.result.errors = [];
117
+ file.result.errors.push(processError(/* @__PURE__ */ new Error(`No test found in ${file.name} in ${message}`)));
118
+ }
119
+ }
120
+ function getTaskFullName(task) {
121
+ return `${task.suite ? `${getTaskFullName(task.suite)} ` : ""}${task.name}`;
122
+ }
123
+ function skipAllTasks(suite) {
124
+ suite.tasks.forEach((t) => {
125
+ if (t.mode === "run" || t.mode === "queued") {
126
+ t.mode = "skip";
127
+ if (t.type === "suite") skipAllTasks(t);
128
+ }
129
+ });
130
+ }
131
+ function todoAllTasks(suite) {
132
+ suite.tasks.forEach((t) => {
133
+ if (t.mode === "run" || t.mode === "queued") {
134
+ t.mode = "todo";
135
+ if (t.type === "suite") todoAllTasks(t);
136
+ }
137
+ });
138
+ }
139
+ function checkAllowOnly(task, allowOnly) {
140
+ if (allowOnly) return;
141
+ task.result = {
142
+ state: "fail",
143
+ errors: [processError(/* @__PURE__ */ new Error("[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error"))]
144
+ };
145
+ }
146
+
147
+ //#endregion
148
+ export { createInitialFileTask, failFile, getFullTaskHierarchy, prepareFileTaskForCollection };
149
+ //# sourceMappingURL=vitest-file-tasks-D8sOClGX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest-file-tasks-D8sOClGX.mjs","names":[],"sources":["../src/types/typed-constants.ts","../src/util/vitest-file-tasks.ts"],"sourcesContent":["/**\n * Typed Constants\n * \n * Constants which require importing ./types\n */\n\nimport { AssemblyScriptTestOptions } from './types.js';\n\n// hard-coded defaults only - timeout and retry defaults always come from vitest config\nexport const DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS: Pick<AssemblyScriptTestOptions, 'fails' | 'skip' | 'only'> = {\n fails: false,\n skip: false,\n only: false\n};\n","import type { SerializedConfig } from 'vitest';\nimport type { File, Suite, Task, TaskBase } from '@vitest/runner/types';\nimport {\n calculateSuiteHash,\n createFileTask,\n someTasksAreOnly\n} from '@vitest/runner/utils';\nimport { processError } from '@vitest/utils/error';\n\nimport { ASSEMBLYSCRIPT_POOL_NAME } from '../types/constants.js';\nimport { DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS } from '../types/typed-constants.js';\nimport type {\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestError,\n AssemblyScriptTestOptions,\n} from '../types/types.js';\n\nexport function createInitialFileTask(\n testFile: string,\n projectName: string,\n projectRoot: string,\n configTestTimeout: number,\n configRetry: number,\n): File {\n const file: File = createFileTask(\n testFile,\n projectRoot,\n projectName,\n ASSEMBLYSCRIPT_POOL_NAME\n );\n\n file.mode = 'queued';\n file.environmentLoad = 0; // AS pool has no environment setup\n file.setupDuration = 0; // AS pool has no setup files\n\n const defaultTestOptions: AssemblyScriptTestOptions = {\n ...DEFAULT_ASSEMBLYSCRIPT_TEST_OPTIONS,\n timeout: configTestTimeout,\n retry: configRetry,\n };\n\n const meta: AssemblyScriptSuiteTaskMeta = {\n idxInParentTasks: -1, // file task has no parent, should never be used anyway\n defaultTestOptions,\n suitePreparedSent: false,\n resultFinal: false,\n }\n file.meta = meta;\n\n return file;\n}\n\nexport function createFailedFileTask(\n testFile: string,\n projectName: string,\n config: SerializedConfig,\n error: AssemblyScriptTestError,\n): File {\n const file: File = createFileTask(\n testFile,\n config.root,\n projectName,\n ASSEMBLYSCRIPT_POOL_NAME\n );\n file.mode = 'run';\n file.result = {\n state: 'fail',\n errors: [error]\n };\n file.environmentLoad = 0;\n file.setupDuration = 0;\n file.collectDuration = 0;\n\n return file;\n}\n\nexport function prepareFileTaskForCollection(\n file: File,\n testNamePattern?: RegExp,\n allowOnly?: boolean,\n): void {\n calculateSuiteHash(file);\n\n // Interpret task modes does the following:\n // 1. If only mode enabled on any test, flip all non-only test.mode to skip\n // 2. Apply test name pattern filtering (from -t flag) to skip if needed\n // 3. If all test modes are skip, set file task mode to skip\n const hasOnly = someTasksAreOnly(file);\n interpretTaskModes(\n file,\n testNamePattern, // user regexp\n undefined, // testLocations\n undefined,\n undefined,\n hasOnly, // onlyMode - true if only is used anywhere\n false, // parentIsOnly - always false for the file task\n allowOnly\n );\n\n // update from queued (onQueued report) to run (onCollected report)\n if (file.mode === 'queued') {\n file.mode = 'run';\n }\n}\n\nexport function failFile(\n file: File,\n error: AssemblyScriptTestError,\n runStartPerf: number,\n): File {\n file.mode = 'run';\n\n if (file.result) {\n file.result.state = 'fail';\n file.result.errors = file.result.errors ? file.result.errors.concat(error) : [error];\n } else {\n file.result = {\n state: 'fail',\n errors: [error]\n };\n }\n file.environmentLoad = file.environmentLoad ?? 0;\n file.setupDuration = performance.now() - runStartPerf;\n file.collectDuration = file.collectDuration ?? 0;\n\n return file;\n}\n\n\n\nexport function getFullTaskHierarchy(file: File): string {\n function spacesForLevel(level: number): string {\n return new Array(level + 1).fill(' ').join('');\n }\n\n function taskStr(task: Task, level: number): string {\n if (task.type === 'test') {\n return `${spacesForLevel(level)}ID: ${task.id} Mode: \"${task.mode}\" Test: \"${task.name}\"`;\n } else {\n const suiteStr = `${spacesForLevel(level)}ID: ${task.id} Mode: \"${task.mode}\" Suite: \"${task.name}\"\\n`;\n return suiteStr + task.tasks.map(t => taskStr(t, level + 1)).join('\\n');\n }\n };\n\n return taskStr(file, 0);\n}\n\n\n// ============================================================================\n// interpretTaskModes function borrowed from Vitest\n// ============================================================================\n\n/**\n * Function interface changes from vitest 4.0.x -> 4.1.x, so now were' just handling this\n * functionality ourselves to prevent version compat conflicts.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v4.1.0/packages/runner/src/utils/collect.ts#L10\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nfunction interpretTaskModes(\n file: Suite,\n namePattern?: string | RegExp,\n testLocations?: number[] | undefined,\n testIds?: string[] | undefined,\n testTagsFilter?: ((testTags: string[]) => boolean) | undefined,\n onlyMode?: boolean,\n parentIsOnly?: boolean,\n allowOnly?: boolean,\n): void {\n const matchedLocations: number[] = [];\n\n const traverseSuite = (suite: Suite, parentIsOnly?: boolean, parentMatchedWithLocation?: boolean) => {\n const suiteIsOnly = parentIsOnly || suite.mode === 'only';\n\n // Check if any tasks in this suite have `.only` - if so, only those should run\n const hasSomeTasksOnly = onlyMode && suite.tasks.some(\n t => t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)),\n );\n\n suite.tasks.forEach((t) => {\n // Check if either the parent suite or the task itself are marked as included\n // If there are tasks with `.only` in this suite, only include those (not all tasks from describe.only)\n const includeTask = hasSomeTasksOnly\n ? (t.mode === 'only' || (t.type === 'suite' && someTasksAreOnly(t)))\n : (suiteIsOnly || t.mode === 'only');\n if (onlyMode) {\n if (t.type === 'suite' && (includeTask || someTasksAreOnly(t))) {\n // Don't skip this suite\n if (t.mode === 'only') {\n checkAllowOnly(t, allowOnly);\n t.mode = 'run';\n }\n }\n else if (t.mode === 'run' && !includeTask) {\n t.mode = 'skip';\n }\n else if (t.mode === 'only') {\n checkAllowOnly(t, allowOnly);\n t.mode = 'run';\n }\n }\n\n let hasLocationMatch = parentMatchedWithLocation\n // Match test location against provided locations, only run if present\n // in `testLocations`. Note: if `includeTaskLocation` is not enabled,\n // all test will be skipped.\n if (testLocations !== undefined && testLocations.length !== 0) {\n if (t.location && testLocations?.includes(t.location.line)) {\n t.mode = 'run';\n matchedLocations.push(t.location.line);\n hasLocationMatch = true;\n }\n else if (parentMatchedWithLocation) {\n t.mode = 'run';\n }\n else if (t.type === 'test') {\n t.mode = 'skip';\n }\n }\n\n if (t.type === 'test') {\n if (namePattern && !getTaskFullName(t).match(namePattern)) {\n t.mode = 'skip';\n }\n if (testIds && !testIds.includes(t.id)) {\n t.mode = 'skip';\n }\n if (testTagsFilter && !testTagsFilter(t.tags || [])) {\n t.mode = 'skip';\n }\n }\n else if (t.type === 'suite') {\n if (t.mode === 'skip') {\n skipAllTasks(t);\n }\n else if (t.mode === 'todo') {\n todoAllTasks(t);\n }\n else {\n traverseSuite(t, includeTask, hasLocationMatch);\n }\n }\n })\n\n // if all subtasks are skipped, mark as skip\n if (suite.mode === 'run' || suite.mode === 'queued') {\n if (suite.tasks.length && suite.tasks.every(i => i.mode !== 'run' && i.mode !== 'queued')) {\n suite.mode = 'skip';\n }\n }\n }\n\n traverseSuite(file, parentIsOnly, false);\n\n const nonMatching = testLocations?.filter(loc => !matchedLocations.includes(loc))\n if (nonMatching && nonMatching.length !== 0) {\n const message = nonMatching.length === 1\n ? `line ${nonMatching[0]}`\n : `lines ${nonMatching.join(', ')}`;\n\n if (file.result === undefined) {\n file.result = {\n state: 'fail',\n errors: [],\n };\n }\n if (file.result.errors === undefined) {\n file.result.errors = [];\n }\n\n file.result.errors.push(\n processError(new Error(`No test found in ${file.name} in ${message}`)),\n );\n }\n}\n\nfunction getTaskFullName(task: TaskBase): string {\n return `${task.suite ? `${getTaskFullName(task.suite)} ` : ''}${task.name}`;\n}\n\nfunction skipAllTasks(suite: Suite) {\n suite.tasks.forEach((t) => {\n if (t.mode === 'run' || t.mode === 'queued') {\n t.mode = 'skip';\n if (t.type === 'suite') {\n skipAllTasks(t);\n }\n }\n });\n}\n\nfunction todoAllTasks(suite: Suite) {\n suite.tasks.forEach((t) => {\n if (t.mode === 'run' || t.mode === 'queued') {\n t.mode = 'todo';\n if (t.type === 'suite') {\n todoAllTasks(t);\n }\n }\n });\n}\n\nfunction checkAllowOnly(task: TaskBase, allowOnly?: boolean) {\n if (allowOnly) {\n return;\n }\n const error = processError(\n new Error(\n '[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error',\n ),\n );\n task.result = {\n state: 'fail',\n errors: [error],\n };\n}\n"],"mappings":";;;;AASA,MAAa,sCAAkG;CAC7G,OAAO;CACP,MAAM;CACN,MAAM;CACP;;;;ACID,SAAgB,sBACd,UACA,aACA,aACA,mBACA,aACM;CACN,MAAM,OAAa,eACjB,UACA,aACA,8BAED;AAED,MAAK,OAAO;AACZ,MAAK,kBAAkB;AACvB,MAAK,gBAAgB;AAcrB,MAAK,OANqC;EACxC,kBAAkB;EAClB,oBARoD;GACpD,GAAG;GACH,SAAS;GACT,OAAO;GACR;EAKC,mBAAmB;EACnB,aAAa;EACd;AAGD,QAAO;;AA2BT,SAAgB,6BACd,MACA,iBACA,WACM;AACN,oBAAmB,KAAK;AAOxB,oBACE,MACA,iBACA,QACA,QACA,QANc,iBAAiB,KAAK,EAQpC,OACA,UACD;AAGD,KAAI,KAAK,SAAS,SAChB,MAAK,OA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AAW,GAAG;EAC3C,MAAM,UAAU,YAAY,WAAW,IACnC,QAAQ,YAAY,OACpB,SAAS,YAAY,KAAK,KAAK;AAEnC,MAAI,KAAK,WAAW,OAClB,MAAK,SAAS;GACZ,OAAO;GACP,QAAQ,EAAE;GACX;AAEH,MAAI,KAAK,OAAO,WAAW,OACzB,MAAK,OAAO,SAAS,EAAE;AAGzB,OAAK,OAAO,OAAO,KACjB,6BAAa,IAAI,MAAM,oBAAoB,KAAK,KAAK,MAAM,UAAU,CAAC,CACvE;;;AAIL,SAAS,gBAAgB,MAAwB;AAC/C,QAAO,GAAG,KAAK,QAAQ,GAAG,gBAAgB,KAAK,MAAM,CAAC,KAAK,KAAK,KAAK;;AAGvE,SAAS,aAAa,OAAc;AAClC,OAAM,MAAM,SAAS,MAAM;AACzB,MAAI,EAAE,SAAS,SAAS,EAAE,SAAS,UAAU;AAC3C,KAAE,OAAO;AACT,OAAI,EAAE,SAAS,QACb,cAAa,EAAE;;GAGnB;;AAGJ,SAAS,aAAa,OAAc;AAClC,OAAM,MAAM,SAAS,MAAM;AACzB,MAAI,EAAE,SAAS,SAAS,EAAE,SAAS,UAAU;AAC3C,KAAE,OAAO;AACT,OAAI,EAAE,SAAS,QACb,cAAa,EAAE;;GAGnB;;AAGJ,SAAS,eAAe,MAAgB,WAAqB;AAC3D,KAAI,UACF;AAOF,MAAK,SAAS;EACZ,OAAO;EACP,QAAQ,CAPI,6BACZ,IAAI,MACF,kGACD,CACF,CAGgB;EAChB"}
@@ -1,5 +1,6 @@
1
- import { POOL_ERROR_NAMES, TEST_ERROR_NAMES } from "./constants-DuBLuMjt.mjs";
2
- import { createPoolErrorFromAnyError, createTestExpectedToFailError, createTestTimeoutError, debug } from "./debug-Cm1VFmaz.mjs";
1
+ import { POOL_ERROR_NAMES, TEST_ERROR_NAMES } from "./constants-DbxJ3hzg.mjs";
2
+ import { retryCompat } from "./resolve-config-s9gSJSMc.mjs";
3
+ import { createPoolErrorFromAnyError, createTestExpectedToFailError, createTestTimeoutError, debug } from "./debug-DtRAL4rM.mjs";
3
4
 
4
5
  //#region src/wasm-executor/source-maps.ts
5
6
  function parseSourceMap(sourceMap) {
@@ -198,7 +199,8 @@ function getRunnableTasks(suite) {
198
199
  return suite.tasks.filter((t) => t.mode === "queued" || t.mode === "run");
199
200
  }
200
201
  function shouldRetryTask(task) {
201
- return task.result?.state === "fail" && task.retry !== void 0 && task.retry > 0 && (task.result.retryCount === void 0 || task.result.retryCount === 0 || task.result.retryCount < task.retry);
202
+ const retry = retryCompat(task.retry);
203
+ return task.result?.state === "fail" && task.retry !== void 0 && retry > 0 && (task.result.retryCount === void 0 || task.result.retryCount === 0 || task.result.retryCount < retry);
202
204
  }
203
205
  /**
204
206
  * Invert result if test configured as 'fails'.
@@ -316,4 +318,4 @@ function resetTestForRetry(test, startTime) {
316
318
 
317
319
  //#endregion
318
320
  export { checkFailsAndInvertResult, createAfterSuiteRunMeta, createSuiteTask, createTestTask, createWebAssemblyCallSite, extractCallStack, failTest, failTestWithTimeoutError, finalizeSuiteResult, flagTestFinalized, flagTestTerminated, getRunnableTasks, getTaskLogLabel, getTaskLogPrefix, isSuiteOwnFile, parseSourceMap, resetTestForRetry, setSuitePrepareResult, setTestResultForTestPrepare, shouldRetryTask, updateSuiteFinishedResult, updateTestResultAfterRun };
319
- //# sourceMappingURL=vitest-tasks--ow4pacR.mjs.map
321
+ //# sourceMappingURL=vitest-tasks-BZ24sghI.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest-tasks-BZ24sghI.mjs","names":[],"sources":["../src/wasm-executor/source-maps.ts","../src/util/vitest-tasks.ts"],"sourcesContent":["/**\n * Source Map Utilities\n *\n * Maps WASM errors to AssemblyScript source locations using V8 stack traces + source maps.\n *\n * Approach: V8's Error.prepareStackTrace provides WAT (WebAssembly Text) line:column positions,\n * which can be mapped to AS source using the source maps generated by AS compiler.\n */\n\nimport { type RawSourceMap, SourceMapConsumer } from 'source-map';\n\nimport { debug } from '../util/debug.js';\nimport type { WebAssemblyCallSite } from '../types/types.js';\nimport { createPoolErrorFromAnyError } from '../util/pool-errors.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\n\nexport function parseSourceMap(sourceMap: string): RawSourceMap {\n // Remove sourceRoot if present to prevent source-map library from prepending it to paths\n // AS compiler sets sourceRoot: \"./output\" which would make paths like \"output/tests/...\"\n // instead of \"tests/...\" - these paths don't exist and won't be found by Vitest\n try {\n const sourceMapObj: RawSourceMap = JSON.parse(sourceMap);\n delete sourceMapObj.sourceRoot;\n return sourceMapObj;\n }\n catch (err) {\n throw createPoolErrorFromAnyError(\n `parseSourceMap error`,\n POOL_ERROR_NAMES.PoolError,\n err\n )\n }\n}\n\n/**\n * Extract structured call stack from V8 using Error.prepareStackTrace\n *\n * V8 provides a special API to access structured stack traces with line:column info.\n * This gives us WAT text positions which can be mapped to AS source via source maps.\n *\n * @param capturedError - Error object to extract stack from\n * @returns Array of V8 CallSite objects\n */\nexport function extractCallStack(capturedError: Error): NodeJS.CallSite[] {\n let stackTrace: NodeJS.CallSite[] = [];\n\n const originalPrepareStackTrace = Error.prepareStackTrace;\n Error.prepareStackTrace = (_err: Error, structuredStackTrace: NodeJS.CallSite[]) => {\n stackTrace = structuredStackTrace;\n return ''; // Return empty string to avoid modifying error.stack\n };\n\n // Access error.stack to trigger prepareStackTrace (result unused, just triggers callback)\n capturedError.stack;\n\n // Restore original\n Error.prepareStackTrace = originalPrepareStackTrace;\n\n return stackTrace;\n}\n\n/**\n * Create WebAssembly call site with source mapping\n *\n * Takes a V8 CallSite and maps it to AS source location if possible.\n *\n * @param callSite - V8 CallSite object from Error.prepareStackTrace\n * @param sourceMapJson - Source map consumer initialized with WASM source map\n * @returns Mapped call site or null if not a WASM call site\n */\nexport function createWebAssemblyCallSite(\n callSite: NodeJS.CallSite,\n sourceMapConsumer: SourceMapConsumer,\n loggingPrefix: string,\n): WebAssemblyCallSite | null {\n const fileName = callSite.getFileName();\n\n // Only process WASM call sites\n if (!fileName || !fileName.startsWith('wasm://')) {\n return null;\n }\n\n const watLine = callSite.getLineNumber();\n const watColumn = callSite.getColumnNumber();\n const functionName = callSite.getFunctionName() || 'wasm-function[unknown]';\n const debugString = `function: \"${functionName}\" | wasm: ${fileName}:${watLine}:${watColumn}`;\n\n // Try to map to source\n if (watLine && watColumn) {\n const original = sourceMapConsumer.originalPositionFor({\n line: watLine,\n column: watColumn\n });\n \n if (!original.source || original.line === null || original.column === null) {\n debug(`${loggingPrefix} - Failed to source-map stack location: ${debugString}`);\n return null;\n }\n\n debug(`${loggingPrefix} - Source-mapped stack location: ${debugString} → ${original.source}:${original.line}:${original.column}`);\n \n const callSite: WebAssemblyCallSite = {\n functionName,\n location: {\n filePath: original.source,\n line: original.line,\n column: original.column\n }\n };\n\n return callSite;\n }\n\n debug(`${loggingPrefix} - Failed to source-map stack-location: ${debugString}`);\n\n // Fallback to WAT position\n return {\n functionName,\n location: {\n filePath: fileName,\n line: watLine || -1,\n column: watColumn || -1\n }\n };\n}\n","import type { File, RunMode, Suite, Task, Test } from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptCoveragePayload,\n AssemblyScriptSuiteTaskMeta,\n AssemblyScriptTestError,\n AssemblyScriptTestOptions,\n AssemblyScriptTestTaskMeta,\n FailedAssertion,\n VitestVersion,\n WASMExecutorPerfTimings\n} from '../types/types.js';\nimport { TEST_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from './debug.js';\nimport { createTestExpectedToFailError, createTestTimeoutError } from './pool-errors.js';\nimport { extractCallStack } from '../wasm-executor/source-maps.js';\nimport { retryCompat } from './resolve-config.js';\n\n// ============================================================================\n// Util\n// ============================================================================\n\nfunction positiveSum<T>(items: T[], getSummableValue: (_next: T) => number | undefined): number {\n return items.reduce((total, next) => {\n return total + Math.max(getSummableValue(next) || 0, 0)\n }, 0);\n}\n\nfunction hasNonFileParentSuite(suite: Suite): boolean {\n return !!suite.suite?.id && suite.suite.id !== suite.file.id;\n}\n\nfunction getSuiteHierarchyName(suite: Suite): string {\n let name = suite.name;\n let currentSuite = suite;\n \n while (hasNonFileParentSuite(currentSuite)) {\n name = `${currentSuite.suite!.name} > ${name}`;\n currentSuite = currentSuite.suite!;\n }\n \n return name;\n}\n\nexport function isSuiteOwnFile(suite: Suite): boolean {\n return suite.file.id === suite.id;\n}\n\nexport function getTaskLogLabel(base: string, task: Task): string {\n if (task.type === 'suite') {\n return isSuiteOwnFile(task) ?\n `${base}`\n : `${base} - \"${getSuiteHierarchyName(task)}\"`;\n } else {\n return `${base} - \"${getSuiteHierarchyName(task.suite!)} > ${task.name}\"`;\n }\n}\n\nexport function getTaskLogPrefix(logModule: string, base: string, task: Task): string {\n return `[${logModule}] ${getTaskLogLabel(base, task)}`;\n}\n\nexport function createAfterSuiteRunMeta(\n coverage: AssemblyScriptCoveragePayload,\n testFiles: string[],\n projectName: string = '',\n vitestVersion: VitestVersion = 'v4',\n): any {\n const base = { coverage, testFiles, projectName };\n\n if (vitestVersion) {\n return { ...base, transformMode: 'ssr' as const };\n } else {\n return { ...base, environment: 'node' as const };\n }\n}\n\n// ============================================================================\n// Task Creation\n// ============================================================================\n\nexport function getInitialTaskMode(options: AssemblyScriptTestOptions): RunMode {\n if (options.skip) {\n return 'skip';\n } else if (options.only) {\n return 'only';\n } else {\n return 'run';\n }\n}\n\nexport function getInitialTestTaskMeta(\n fnIndex: number,\n parentAfterAddingTask: Suite,\n): AssemblyScriptTestTaskMeta {\n return {\n fnIndex,\n idxInParentTasks: parentAfterAddingTask.tasks.length - 1,\n assertionsPassedCount: 0,\n assertionsFailed: [],\n resultFinal: false,\n };\n}\n\nexport function getInitialSuiteTaskMeta(\n parentAfterAddingTask: Suite,\n mergedOptions: AssemblyScriptTestOptions,\n): AssemblyScriptSuiteTaskMeta {\n return {\n idxInParentTasks: parentAfterAddingTask.tasks.length - 1,\n defaultTestOptions: mergedOptions,\n suitePreparedSent: false,\n resultFinal: false,\n };\n}\n\n\nfunction createTaskName(names: readonly (string | undefined)[], separator: string = ' > '): string {\n return names.filter(name => name !== undefined).join(separator);\n}\n\nexport function createTestTask(\n name: string,\n fnIndex: number,\n file: File,\n parent: Suite,\n mergedOptions: AssemblyScriptTestOptions,\n vitestVersion: VitestVersion = 'v4',\n): Test {\n const test: Test = {\n type: 'test',\n name,\n fullName: createTaskName([\n parent?.fullName ?? file?.fullName,\n name,\n ]),\n fullTestName: createTaskName([parent?.fullTestName, name]),\n id: '',\n file,\n suite: parent,\n context: {} as any,\n annotations: [],\n artifacts: [],\n meta: {},\n mode: getInitialTaskMode(mergedOptions),\n timeout: mergedOptions.timeout,\n retry: mergedOptions.retry,\n fails: mergedOptions.fails,\n };\n\n if (vitestVersion === 'v3') {\n // @ts-ignore\n delete test.fullName;\n // @ts-ignore\n delete test.fullTestName;\n // @ts-ignore\n delete test.artifacts;\n }\n\n parent.tasks.push(test);\n\n // use custom TaskMeta to capture fnIndex, parent task index, etc\n test.meta = getInitialTestTaskMeta(fnIndex, parent);\n\n return test;\n}\n\nexport function createSuiteTask(\n name: string,\n file: File,\n parent: Suite,\n mergedOptions: AssemblyScriptTestOptions,\n vitestVersion: VitestVersion = 'v4',\n): Suite {\n // const suiteIsFile = parent.file.id === parent.id;\n // const prefix = suiteIsFile ? parent.name : `${file.filepath}_${parent.name}`;\n const suite: Suite = {\n type: 'suite',\n name,\n fullName: createTaskName([\n parent?.fullName ?? file?.fullName,\n name,\n ]),\n fullTestName: createTaskName([parent?.fullTestName, name]),\n id: '',\n file,\n suite: parent,\n meta: {},\n tasks: [],\n mode: getInitialTaskMode(mergedOptions),\n };\n\n if (vitestVersion === 'v3') {\n // @ts-ignore\n delete suite.fullName;\n // @ts-ignore\n delete suite.fullTestName;\n }\n\n parent.tasks.push(suite);\n\n // use custom TaskMeta to capture parent task index and default options\n suite.meta = getInitialSuiteTaskMeta(parent, mergedOptions);\n\n return suite;\n}\n\n\n// ============================================================================\n// Dispatch Helpers\n// ============================================================================\n\nexport function getRunnableTasks(suite: Suite): Task[] {\n return suite.tasks.filter(t => t.mode === 'queued' || t.mode === 'run');\n}\n\n\n// ============================================================================\n// Result Handling Helpers\n// ============================================================================\n\nexport function shouldRetryTask(task: Task): boolean {\n const retry = retryCompat(task.retry);\n return task.result?.state === 'fail'\n && task.retry !== undefined\n && retry > 0\n && (\n task.result.retryCount === undefined\n || task.result.retryCount === 0\n || (task.result.retryCount < retry)\n );\n}\n\n/**\n * Invert result if test configured as 'fails'.\n */\nexport function checkFailsAndInvertResult(test: Test, logPrefix: string): void {\n if (test.fails) {\n if (test.result?.state === 'pass') {\n test.result.state = 'fail';\n\n debug(`${logPrefix} - Has 'fails' option set - inverted \"pass\" to \"fail\"`);\n\n const err = createTestExpectedToFailError(test);\n if (test.result.errors) {\n test.result.errors.push(err);\n } else {\n test.result.errors = [err];\n }\n } else if (test.result?.state === 'fail') {\n test.result.state = 'pass';\n test.result.errors = [];\n\n debug(`${logPrefix} - Has 'fails' option set - inverted \"fail\" to \"pass\"`);\n }\n }\n}\n\nexport function setTestResultForTestPrepare(test: Test, startTime: number): void {\n test.result = {\n state: 'run',\n startTime,\n retryCount: 0\n };\n};\n\nexport function updateTestResultAfterRun(test: Test, testTimings?: WASMExecutorPerfTimings): void {\n // while failed tests are actively set to failed, a passed test\n // will still be in the prepared result state (run), so set it to pass\n if (test.result?.state === 'run') {\n test.result.state = 'pass';\n }\n \n if (test.result && testTimings) {\n // accumulate duration for any retries that may be done\n test.result.duration = (test.result.duration ?? 0) + (testTimings.execEnd - testTimings.execStart);\n }\n}\n\nexport function flagTestTerminated(test: Test): void {\n (test.meta as AssemblyScriptTestTaskMeta).lastTimeoutTerminationTime = Date.now();\n}\n\nexport function flagTestFinalized(test: Test): void {\n (test.meta as AssemblyScriptTestTaskMeta).resultFinal = true;\n}\n\nexport function failTest(\n test: Test,\n errorMessage: string,\n capturedError: Error,\n logPrefix: string,\n): void {\n if (test.result) {\n test.result.state = 'fail';\n } else {\n test.result = { state: 'fail' };\n }\n\n const testError: AssemblyScriptTestError = {\n name: TEST_ERROR_NAMES.WASMRuntimeError,\n message: errorMessage\n };\n\n const meta = test.meta as AssemblyScriptTestTaskMeta;\n \n // determine if this was an assertion failure\n if (meta.assertionsFailed?.length > 0) {\n testError.name = TEST_ERROR_NAMES.AssertionError;\n\n const assertion: FailedAssertion = meta.assertionsFailed[meta.assertionsFailed.length - 1]!;\n\n // set actual and expected values as strings, if provided\n if (assertion.valuesProvided) {\n meta.lastErrorValuesProvided = true;\n testError.expected = assertion.expected !== undefined ? String(assertion.expected) : undefined;\n testError.actual = assertion.actual !== undefined ? String(assertion.actual) : undefined;\n }\n }\n \n // Set error to report to vitest on the test meta.\n // Stack gets updated when executor enhances/source-maps the error, post-abort\n meta.lastError = testError;\n\n // Create error to capture V8 stack trace and extract V8 call stack before throwing.\n // This gives us WAT line:column positions that can be mapped to AS source\n meta.lastErrorRawCallStack = extractCallStack(capturedError);\n\n debug(`${logPrefix} - Captured raw V8 call stack with ${meta.lastErrorRawCallStack.length} frames`);\n}\n\nexport function failTestWithTimeoutError (test: Test, startTime: number, duration: number): void {\n const timeoutErr = createTestTimeoutError(test);\n\n if (test.result) {\n test.result.state = 'fail';\n test.result.startTime = startTime;\n \n // accumulate duration for any retries that may be done\n test.result.duration = (test.result.duration ?? 0) + duration;\n\n if (test.result.errors) {\n test.result.errors.push(timeoutErr)\n } else {\n test.result.errors = [timeoutErr];\n }\n } else {\n test.result = {\n state: 'fail',\n startTime,\n duration,\n errors: [timeoutErr],\n retryCount: 0,\n };\n }\n}\n\nexport function setSuitePrepareResult(suite: Suite): void {\n if (suite.mode === 'skip') {\n suite.result = {\n state: 'skip',\n duration: 0,\n };\n } else {\n suite.result = {\n state: 'run',\n startTime: Date.now(),\n };\n }\n}\n\nexport function updateSuiteFinishedResult(suite: Suite, logPrefix: string): void {\n if (suite.mode === 'skip') {\n suite.result = {\n state: 'skip',\n duration: 0,\n };\n } else {\n // update suite final result based on sub-task results\n const hasFailures = suite.tasks.some(({ result }) => result?.state === 'fail' );\n \n if (suite.result) {\n suite.result.duration = positiveSum(suite.tasks, t => t.result?.duration);\n suite.result.state = hasFailures ? 'fail' : 'pass';\n \n debug(`${logPrefix} - Set suite result: \"${suite.result.state}\" (hasFailures: ${hasFailures})`);\n }\n }\n}\n\nexport function finalizeSuiteResult(suite: Suite): void {\n (suite.meta as AssemblyScriptSuiteTaskMeta).resultFinal = true;\n}\n\nexport function resetTestForRetry(test: Test, startTime: number): void {\n if (test.result) {\n test.result!.state = 'run';\n test.result!.startTime = startTime;\n }\n\n const meta = test.meta as AssemblyScriptTestTaskMeta;\n\n // clear any custom metadata associated with the immediate last run\n meta.assertionsPassedCount = 0;\n meta.assertionsFailed = [];\n delete meta.lastError;\n delete meta.lastErrorValuesProvided;\n delete meta.lastErrorRawCallStack;\n delete meta.lastTimeoutTerminationTime;\n delete meta.coverageData;\n}\n\n\n"],"mappings":";;;;;AAgBA,SAAgB,eAAe,WAAiC;AAI9D,KAAI;EACF,MAAM,eAA6B,KAAK,MAAM,UAAU;AACxD,SAAO,aAAa;AACpB,SAAO;UAEF,KAAK;AACV,QAAM,4BACJ,wBACA,iBAAiB,WACjB,IACD;;;;;;;;;;;;AAaL,SAAgB,iBAAiB,eAAyC;CACxE,IAAI,aAAgC,EAAE;CAEtC,MAAM,4BAA4B,MAAM;AACxC,OAAM,qBAAqB,MAAa,yBAA4C;AAClF,eAAa;AACb,SAAO;;AAIT,eAAc;AAGd,OAAM,oBAAoB;AAE1B,QAAO;;;;;;;;;;;AAYT,SAAgB,0BACd,UACA,mBACA,eAC4B;CAC5B,MAAM,WAAW,SAAS,aAAa;AAGvC,KAAI,CAAC,YAAY,CAAC,SAAS,WAAW,UAAU,CAC9C,QAAO;CAGT,MAAM,UAAU,SAAS,eAAe;CACxC,MAAM,YAAY,SAAS,iBAAiB;CAC5C,MAAM,eAAe,SAAS,iBAAiB,IAAI;CACnD,MAAM,cAAc,cAAc,aAAa,YAAY,SAAS,GAAG,QAAQ,GAAG;AAGlF,KAAI,W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AErD,MAAI,KAAK,OAAO,OACd,MAAK,OAAO,OAAO,KAAK,WAAW;MAEnC,MAAK,OAAO,SAAS,CAAC,WAAW;OAGnC,MAAK,SAAS;EACZ,OAAO;EACP;EACA;EACA,QAAQ,CAAC,WAAW;EACpB,YAAY;EACb;;AAIL,SAAgB,sBAAsB,OAAoB;AACxD,KAAI,MAAM,SAAS,OACjB,OAAM,SAAS;EACb,OAAO;EACP,UAAU;EACX;KAED,OAAM,SAAS;EACb,OAAO;EACP,WAAW,KAAK,KAAK;EACtB;;AAIL,SAAgB,0BAA0B,OAAc,WAAyB;AAC/E,KAAI,MAAM,SAAS,OACjB,OAAM,SAAS;EACb,OAAO;EACP,UAAU;EACX;MACI;EAEL,MAAM,cAAc,MAAM,MAAM,MAAM,EAAE,aAAa,QAAQ,UAAU,OAAQ;AAE/E,MAAI,MAAM,QAAQ;AAChB,SAAM,OAAO,WAAW,YAAY,MAAM,QAAO,MAAK,EAAE,QAAQ,SAAS;AACzE,SAAM,OAAO,QAAQ,cAAc,SAAS;AAE5C,SAAM,GAAG,UAAU,wBAAwB,MAAM,OAAO,MAAM,kBAAkB,YAAY,GAAG;;;;AAKrG,SAAgB,oBAAoB,OAAoB;AACtD,CAAC,MAAM,KAAqC,cAAc;;AAG5D,SAAgB,kBAAkB,MAAY,WAAyB;AACrE,KAAI,KAAK,QAAQ;AACf,OAAK,OAAQ,QAAQ;AACrB,OAAK,OAAQ,YAAY;;CAG3B,MAAM,OAAO,KAAK;AAGlB,MAAK,wBAAwB;AAC7B,MAAK,mBAAmB,EAAE;AAC1B,QAAO,KAAK;AACZ,QAAO,KAAK;AACZ,QAAO,KAAK;AACZ,QAAO,KAAK;AACZ,QAAO,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-pool-assemblyscript",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
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",
@@ -42,13 +42,9 @@
42
42
  "types": "./dist/coverage-provider/index.d.mts",
43
43
  "default": "./dist/coverage-provider/index.mjs"
44
44
  },
45
- "./assembly": {
46
- "types": "./assembly/index.mts",
47
- "default": "./assembly/index.mts"
48
- },
49
45
  "./__internal": {
50
- "types": "./dist/internal-test-entry.d.mts",
51
- "default": "./dist/internal-test-entry.mjs"
46
+ "types": "./dist/internal.d.mts",
47
+ "default": "./dist/internal.mjs"
52
48
  }
53
49
  },
54
50
  "files": [
@@ -132,13 +128,14 @@
132
128
  "source-map": "~0.7.6",
133
129
  "tinyglobby": "~0.2.15",
134
130
  "tinypool": "^2.1.0",
135
- "tinyrainbow": "^3.0.3"
131
+ "tinyhighlight": "^0.3.2",
132
+ "tinyrainbow": "^3.1.0"
136
133
  },
137
134
  "peerDependencies": {
138
135
  "@vitest/coverage-v8": "^3.2.0 || ^4.0.0",
139
136
  "@vitest/runner": "^3.2.0 || ^4.0.0",
140
137
  "@vitest/utils": "^3.2.0 || ^4.0.0",
141
- "assemblyscript": "^0.28.9",
138
+ "assemblyscript": "~0.28.9",
142
139
  "istanbul-lib-coverage": "^3.2.2",
143
140
  "vitest": "^3.2.0 || ^4.0.0"
144
141
  },
@@ -148,10 +145,10 @@
148
145
  "@types/istanbul-lib-coverage": "^2.0.6",
149
146
  "@types/node": "22.19.1",
150
147
  "@types/source-map": "~0.5.2",
151
- "@vitest/coverage-v8": "^4.0.18",
152
- "@vitest/runner": "^4.0.18",
153
- "@vitest/utils": "^4.0.18",
154
- "assemblyscript": "~0.28.9",
148
+ "@vitest/coverage-v8": "^4.1.5",
149
+ "@vitest/runner": "^4.1.5",
150
+ "@vitest/utils": "^4.1.5",
151
+ "assemblyscript": "0.28.16",
155
152
  "conventional-changelog-conventionalcommits": "^9.1.0",
156
153
  "cross-env": "^10.1.0",
157
154
  "istanbul-lib-coverage": "^3.2.2",
@@ -161,6 +158,6 @@
161
158
  "tsdown": "^0.20.3",
162
159
  "tsx": "^4.21.0",
163
160
  "typescript": "^5.9.3",
164
- "vitest": "^4.0.18"
161
+ "vitest": "^4.1.5"
165
162
  }
166
163
  }
@@ -213,7 +213,12 @@ bool startsWith(const std::string& str, const std::string& prefix) {
213
213
  /**
214
214
  * Check if a function should be instrumented for coverage
215
215
  */
216
- bool shouldInstrumentFunction(Function* func, std::string& excludedLibraryFilePrefix, std::string& excludedLibraryFileOverridePrefix) {
216
+ bool shouldInstrumentFunction(
217
+ Function* func,
218
+ std::string& excludedLibraryFilePrefix,
219
+ std::string& excludedLibraryFileOverridePrefix,
220
+ std::string& excludedInternalFunctionSubstring
221
+ ) {
217
222
  const std::string& name = func->name.toString();
218
223
 
219
224
  // Skip functions without a body
@@ -232,6 +237,14 @@ bool shouldInstrumentFunction(Function* func, std::string& excludedLibraryFilePr
232
237
  return false;
233
238
  }
234
239
 
240
+ // Skip Internal function (synthetic / injected by a transform)
241
+ if (name.find(excludedInternalFunctionSubstring) != std::string::npos) {
242
+ if (DEBUG) {
243
+ std::cout << LOG_PREFIX << " - Skip Reason: Internal-only function" << std::endl;
244
+ }
245
+ return false;
246
+ }
247
+
235
248
  // Skip library functions
236
249
  if (excludedLibraryFilePrefix.length() > 0 && startsWith(name, excludedLibraryFilePrefix)) {
237
250
  if (excludedLibraryFileOverridePrefix.length() != 0) {
@@ -254,7 +267,7 @@ bool shouldInstrumentFunction(Function* func, std::string& excludedLibraryFilePr
254
267
  return false;
255
268
  }
256
269
 
257
- // Compiler-generated entry point
270
+ // Skip Compiler-generated entry point
258
271
  if (name.compare("~start") == 0) {
259
272
  if (DEBUG) {
260
273
  std::cout << LOG_PREFIX << " - Skip Reason: Module entry point" << std::endl;
@@ -423,6 +436,8 @@ Napi::Object InstrumentForCoverage(const Napi::CallbackInfo& info) {
423
436
  std::unordered_set<std::string> excludedFiles;
424
437
  std::string excludedLibraryFilePrefix;
425
438
  std::string excludedLibraryFileOverridePrefix = "";
439
+ std::string excludedInternalFunctionSubstring = "";
440
+
426
441
  // 1 page = 64KB / 4bytes (32bits) each = 16384 counters
427
442
  uint32_t coverageMemoryPagesMin = 1;
428
443
  // 4 pages = 256KB / 4bytes (32bits) each = 65536 counters
@@ -494,6 +509,17 @@ Napi::Object InstrumentForCoverage(const Napi::CallbackInfo& info) {
494
509
  }
495
510
  }
496
511
 
512
+ if (options.Has("excludedInternalFunctionSubstring")) {
513
+ Napi::Value internalFunctionSubstringProperty = options.Get("excludedInternalFunctionSubstring");
514
+ if (internalFunctionSubstringProperty.IsString()) {
515
+ excludedInternalFunctionSubstring = internalFunctionSubstringProperty.As<Napi::String>().Utf8Value();
516
+
517
+ if (DEBUG) {
518
+ std::cout << LOG_PREFIX << " - OPTIONS - Excluded Internal Function Name Substring: \"" << excludedInternalFunctionSubstring << "\"" << std::endl;
519
+ }
520
+ }
521
+ }
522
+
497
523
  if (options.Has("coverageMemoryPagesMin")) {
498
524
  Napi::Value coverageMinProperty = options.Get("coverageMemoryPagesMin");
499
525
  if (coverageMinProperty.IsNumber()) {
@@ -575,7 +601,7 @@ Napi::Object InstrumentForCoverage(const Napi::CallbackInfo& info) {
575
601
  }
576
602
 
577
603
  // Check if this function should be instrumented
578
- if (!shouldInstrumentFunction(func, excludedLibraryFilePrefix, excludedLibraryFileOverridePrefix)) {
604
+ if (!shouldInstrumentFunction(func, excludedLibraryFilePrefix, excludedLibraryFileOverridePrefix, excludedInternalFunctionSubstring)) {
579
605
  if (DEBUG) {
580
606
  std::cout << LOG_PREFIX << " - SKIP function (quick filtered): \"" << funcName << "\"" << std::endl;
581
607
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"addon-interface-_pNXcbib.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-native-addon.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":";;;;;;;;;;;;;;;;;;;AAyCA,MAAM,YAAY,QADC,cAAc,OAAO,KAAK,IAAI,CACZ;AACrC,MAAM,eAAe,QAAQ,WAAW,KAAK;AAG7C,MAAM,cAAc,QAAQ,WAAW,QAAQ;AAG/C,MAAM,eADU,cAAc,OAAO,KAAK,IAAI,CACa,iBAAiB;AAE5E,IAAI;AACJ,IAAI;AACF,SAAQ,aAAa,aAAa;QAC5B;AACN,KAAI;AACF,UAAQ,aAAa,YAAY;UAC1B,KAAK;AACZ,QAAM,gBACJ,oFAAoF,aAAa,OAAO,YAAY,iKAEtE,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,IAC9F,iBAAiB,yBAClB;;;;;;;;;;;;;;AAeL,SAAS,gBACP,aACA,kBACA,aACgB;CAChB,IAAI,WAAW,iBAAiB,YAAY;AAE5C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0,0 @@
1
- {"version":3,"file":"ast-visitor-C5gQqWD2.mjs","names":[],"sources":["../src/util/ast-visitor.ts"],"sourcesContent":["/**\n * Base AST Visitor for AssemblyScript\n *\n * Provides reusable walking logic for traversing AS AST nodes.\n * Subclasses override hook methods to perform specific tasks.\n *\n * Used by:\n * - ast-parser.ts: Extract function metadata for coverage\n * - strip-inline.mts: Strip @inline decorators\n */\n\nimport {\n Node,\n Source,\n BlockStatement,\n FunctionDeclaration,\n MethodDeclaration,\n ClassDeclaration,\n NamespaceDeclaration,\n VariableStatement,\n VariableDeclaration,\n FunctionExpression,\n ExpressionStatement,\n BinaryExpression,\n PropertyAccessExpression,\n IfStatement,\n WhileStatement,\n DoStatement,\n ForStatement,\n ForOfStatement,\n SwitchStatement,\n SwitchCase,\n TryStatement,\n ThrowStatement,\n ReturnStatement,\n CallExpression,\n NewExpression,\n ParenthesizedExpression,\n TernaryExpression,\n CommaExpression,\n AssertionExpression,\n InstanceOfExpression,\n ElementAccessExpression,\n UnaryPostfixExpression,\n UnaryPrefixExpression,\n ClassExpression,\n ParameterNode,\n EnumDeclaration,\n EnumValueDeclaration,\n FieldDeclaration,\n InterfaceDeclaration,\n VoidStatement,\n} from 'assemblyscript';\n\nimport { ASNodeKind } from '../types/constants.js';\n\n/**\n * Abstract base class for AST visitors.\n *\n * Subclasses override hook methods to perform tasks during traversal:\n * - beforeVisit: Called before visiting each node (e.g., strip decorators)\n * - onFunctionDeclaration: Called when visiting a function declaration\n * - onMethodDeclaration: Called when visiting a method declaration\n * - onVariableDeclaration: Called when visiting a variable declaration\n * - onClassEnter/onClassExit: Called when entering/exiting a class\n */\nexport abstract class ASTVisitor {\n /**\n * Visit all statements in a source file\n */\n visitSource(source: Source): void {\n for (const stmt of source.statements) {\n this.visitNode(stmt);\n }\n }\n\n /**\n * Hook called before visiting each node.\n * Override to perform pre-visit tasks (e.g., stripping decorators).\n */\n protected beforeVisit(_node: Node): void {}\n\n /**\n * Hook called when entering a class declaration.\n * Override to track class context.\n */\n protected onClassEnter(_node: ClassDeclaration): void {}\n\n /**\n * Hook called when exiting a class declaration.\n * Override to restore class context.\n */\n protected onClassExit(_node: ClassDeclaration): void {}\n\n /**\n * Hook called when visiting a function declaration.\n * Override to extract function info or perform other tasks.\n * Return false to skip recursing into the function body.\n */\n protected onFunctionDeclaration(_node: FunctionDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Hook called when visiting a method declaration.\n * Override to extract method info or perform other tasks.\n * Return false to skip recursing into the method body.\n */\n protected onMethodDeclaration(_node: MethodDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Hook called when visiting a variable declaration.\n * Override to handle variable declarations (e.g., arrow functions).\n * Return false to skip recursing into the initializer.\n */\n protected onVariableDeclaration(_node: VariableDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Main visitor dispatch - routes to specific handler based on node kind\n */\n visitNode(node: Node): void {\n // Call pre-visit hook\n this.beforeVisit(node);\n\n // Recurse into children based on node kind\n switch (node.kind) {\n // Type nodes - no children to visit\n case ASNodeKind.NamedType:\n case ASNodeKind.FunctionType:\n case ASNodeKind.TypeName:\n case ASNodeKind.TypeParameter:\n break;\n\n // Parameter - may have default value\n case ASNodeKind.Parameter: {\n const param = node as ParameterNode;\n if (param.initializer) this.visitNode(param.initializer);\n break;\n }\n\n // Simple expressions - no children\n case ASNodeKind.Identifier:\n case ASNodeKind.False:\n case ASNodeKind.Literal:\n case ASNodeKind.Null:\n case ASNodeKind.Omitted:\n case ASNodeKind.Super:\n case ASNodeKind.This:\n case ASNodeKind.True:\n case ASNodeKind.Constructor:\n case ASNodeKind.Compiled:\n break;\n\n // Expressions with children\n case ASNodeKind.Assertion: {\n const expr = node as AssertionExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.Binary: {\n const expr = node as BinaryExpression;\n this.visitNode(expr.left);\n this.visitNode(expr.right);\n break;\n }\n case ASNodeKind.Call: {\n const expr = node as CallExpression;\n this.visitNode(expr.expression);\n for (const arg of expr.args) this.visitNode(arg);\n break;\n }\n case ASNodeKind.Class: {\n const expr = node as ClassExpression;\n this.visitNode(expr.declaration);\n break;\n }\n case ASNodeKind.Comma: {\n const expr = node as CommaExpression;\n for (const e of expr.expressions) this.visitNode(e);\n break;\n }\n case ASNodeKind.ElementAccess: {\n const expr = node as ElementAccessExpression;\n this.visitNode(expr.expression);\n this.visitNode(expr.elementExpression);\n break;\n }\n case ASNodeKind.Function: {\n const expr = node as FunctionExpression;\n this.visitNode(expr.declaration);\n break;\n }\n case ASNodeKind.InstanceOf: {\n const expr = node as InstanceOfExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.New: {\n const expr = node as NewExpression;\n for (const arg of expr.args) this.visitNode(arg);\n break;\n }\n case ASNodeKind.Parenthesized: {\n const expr = node as ParenthesizedExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.PropertyAccess: {\n const expr = node as PropertyAccessExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.Ternary: {\n const expr = node as TernaryExpression;\n this.visitNode(expr.condition);\n this.visitNode(expr.ifThen);\n this.visitNode(expr.ifElse);\n break;\n }\n case ASNodeKind.UnaryPostfix: {\n const expr = node as UnaryPostfixExpression;\n this.visitNode(expr.operand);\n break;\n }\n case ASNodeKind.UnaryPrefix: {\n const expr = node as UnaryPrefixExpression;\n this.visitNode(expr.operand);\n break;\n }\n\n // Statements with no interesting children\n case ASNodeKind.Break:\n case ASNodeKind.Continue:\n case ASNodeKind.Empty:\n case ASNodeKind.Export:\n case ASNodeKind.ExportDefault:\n case ASNodeKind.ExportImport:\n case ASNodeKind.Import:\n case ASNodeKind.Module:\n break;\n\n // Statements with children\n case ASNodeKind.Block: {\n const stmt = node as BlockStatement;\n for (const s of stmt.statements) this.visitNode(s);\n break;\n }\n case ASNodeKind.Do: {\n const stmt = node as DoStatement;\n this.visitNode(stmt.body);\n this.visitNode(stmt.condition);\n break;\n }\n case ASNodeKind.Expression: {\n const stmt = node as ExpressionStatement;\n this.visitNode(stmt.expression);\n break;\n }\n case ASNodeKind.For: {\n const stmt = node as ForStatement;\n if (stmt.initializer) this.visitNode(stmt.initializer);\n if (stmt.condition) this.visitNode(stmt.condition);\n if (stmt.incrementor) this.visitNode(stmt.incrementor);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.ForOf: {\n const stmt = node as ForOfStatement;\n this.visitNode(stmt.variable);\n this.visitNode(stmt.iterable);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.If: {\n const stmt = node as IfStatement;\n this.visitNode(stmt.condition);\n this.visitNode(stmt.ifTrue);\n if (stmt.ifFalse) this.visitNode(stmt.ifFalse);\n break;\n }\n case ASNodeKind.Return: {\n const stmt = node as ReturnStatement;\n if (stmt.value) this.visitNode(stmt.value);\n break;\n }\n case ASNodeKind.Switch: {\n const stmt = node as SwitchStatement;\n this.visitNode(stmt.condition);\n for (const switchCase of stmt.cases) this.visitNode(switchCase);\n break;\n }\n case ASNodeKind.Throw: {\n const stmt = node as ThrowStatement;\n this.visitNode(stmt.value);\n break;\n }\n case ASNodeKind.Try: {\n const stmt = node as TryStatement;\n for (const s of stmt.bodyStatements) this.visitNode(s);\n if (stmt.catchStatements) {\n for (const s of stmt.catchStatements) this.visitNode(s);\n }\n if (stmt.finallyStatements) {\n for (const s of stmt.finallyStatements) this.visitNode(s);\n }\n break;\n }\n case ASNodeKind.Variable: {\n const stmt = node as VariableStatement;\n for (const decl of stmt.declarations) this.visitNode(decl);\n break;\n }\n case ASNodeKind.Void: {\n const stmt = node as VoidStatement;\n this.visitNode(stmt.expression);\n break;\n }\n case ASNodeKind.While: {\n const stmt = node as WhileStatement;\n this.visitNode(stmt.condition);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.SwitchCase: {\n const stmt = node as SwitchCase;\n if (stmt.label) this.visitNode(stmt.label);\n for (const s of stmt.statements) this.visitNode(s);\n break;\n }\n\n // Declaration statements\n case ASNodeKind.ImportDeclaration:\n case ASNodeKind.TypeDeclaration:\n break;\n\n case ASNodeKind.ClassDeclaration: {\n const decl = node as ClassDeclaration;\n this.onClassEnter(decl);\n for (const member of decl.members) this.visitNode(member);\n this.onClassExit(decl);\n break;\n }\n case ASNodeKind.EnumDeclaration: {\n const decl = node as EnumDeclaration;\n for (const value of decl.values) this.visitNode(value);\n break;\n }\n case ASNodeKind.EnumValueDeclaration: {\n const decl = node as EnumValueDeclaration;\n if (decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n case ASNodeKind.FieldDeclaration: {\n const decl = node as FieldDeclaration;\n if (decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n case ASNodeKind.FunctionDeclaration: {\n const decl = node as FunctionDeclaration;\n const shouldRecurse = this.onFunctionDeclaration(decl);\n if (shouldRecurse && decl.body) this.visitNode(decl.body);\n break;\n }\n case ASNodeKind.InterfaceDeclaration: {\n const decl = node as InterfaceDeclaration;\n for (const member of decl.members) this.visitNode(member);\n break;\n }\n case ASNodeKind.MethodDeclaration: {\n const decl = node as MethodDeclaration;\n const shouldRecurse = this.onMethodDeclaration(decl);\n if (shouldRecurse && decl.body) this.visitNode(decl.body);\n break;\n }\n case ASNodeKind.NamespaceDeclaration: {\n const decl = node as NamespaceDeclaration;\n for (const member of decl.members) this.visitNode(member);\n break;\n }\n case ASNodeKind.VariableDeclaration: {\n const decl = node as VariableDeclaration;\n const shouldRecurse = this.onVariableDeclaration(decl);\n if (shouldRecurse && decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n\n // Special nodes - no action needed\n case ASNodeKind.ExportMember:\n case ASNodeKind.IndexSignature:\n case ASNodeKind.Comment:\n case ASNodeKind.Decorator:\n break;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkEA,IAAsB,aAAtB,MAAiC;;;;CAI/B,YAAY,QAAsB;AAChC,OAAK,MAAM,QAAQ,OAAO,WACxB,MAAK,UAAU,KAAK;;;;;;CAQxB,AAAU,YAAY,OAAmB;;;;;CAMzC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AAK,WAAW,qBAAqB;IACnC,MAAM,OAAO;AAEb,QADsB,KAAK,sBAAsB,KAAK,IACjC,KAAK,YAAa,MAAK,UAAU,KAAK,YAAY;AACvE;;GAIF,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW,UACd"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"compile-runner-DOMhsLQE.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,KA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,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 +0,0 @@
1
- {"version":3,"file":"compiler-CIXpfKq0.mjs","names":["ascMain"],"sources":["../src/compiler/index.ts"],"sourcesContent":["/**\n * AssemblyScript Compiler\n *\n * Handles compilation of AssemblyScript source code to WASM binaries.\n * Manages compiler options, transforms, and in-memory compilation.\n */\n\nimport { main as ascMain } from 'assemblyscript/asc';\nimport { basename, resolve } from 'node:path';\nimport { access, readFile, writeFile, mkdir } from 'node:fs/promises';\n\nimport type {\n AssemblyScriptCompilerResult,\n AssemblyScriptCompilerOptions,\n NativeAddonInterface\n} from '../types/types.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { createPoolError, throwPoolErrorIfAborted } from '../util/pool-errors.js';\nimport { clearNativeBuildError, hasNativeBuildError, warnASInstrumentationNotLoaded } from '../util/feature-check.js';\n\nlet nativeAddon: NativeAddonInterface | undefined;\ntry {\n nativeAddon = await import('../instrumentation/addon-interface.js');\n // Addon loaded successfully — clear any stale build error marker (fire and forget)\n clearNativeBuildError();\n} catch (err: any) {\n const knownBuildFailure = await hasNativeBuildError();\n if (knownBuildFailure) {\n // Marker file exists — coverage provider will warn the user, just debug log here\n debug(`[Compiler] Native instrumentation addon not loaded (known build failure): ${err?.message ?? String(err)}`);\n } else {\n // Unexpected failure — no marker file, warn the user\n warnASInstrumentationNotLoaded(err?.message ?? String(err));\n }\n}\n\nconst DEBUG_WRITE_FILES = false;\n\n// Path prefix the AS compiler uses when resolving bare `vitest-pool-assemblyscript/assembly` imports\n// via node_modules. Used to detect self-imports and redirect to local assembly/ dir when running in-tree.\nconst POOL_ASSEMBLY_NODE_MODULES_PREFIX = 'node_modules/vitest-pool-assemblyscript/assembly/';\n\n// path assumes that we're running from dist/\nconst STRIP_INLINE_TRANSFORM = resolve(import.meta.dirname, './compiler/transforms/strip-inline.mjs');\n\nsetImmediate(async () => {\n try {\n await access(STRIP_INLINE_TRANSFORM);\n } catch {\n throw createPoolError(\n `AS Compiler strip inline transform file not found at \"${STRIP_INLINE_TRANSFORM}\"`,\n POOL_ERROR_NAMES.CompilationError\n );\n }\n});\n\n/**\n * Compile AssemblyScript source code to WASM binary\n */\nexport async function compileAssemblyScript(\n filename: string,\n options: AssemblyScriptCompilerOptions,\n logModule: string,\n logLabel: string,\n signal?: AbortSignal\n): Promise<AssemblyScriptCompilerResult> {\n throwPoolErrorIfAborted(signal);\n\n const compileStart = performance.now();\n const logPrefix = `[${logModule} ASC] ${logLabel}`;\n\n const { shouldInstrument, instrumentationOptions, extraFlags } = options;\n\n if (shouldInstrument && !instrumentationOptions) {\n throw createPoolError(\n 'Instrumentation options are required for coverage instrumentation',\n POOL_ERROR_NAMES.CompilationError\n );\n }\n\n const stdoutLines: string[] = [];\n const stderrLines: string[] = [];\n let binary: Uint8Array | undefined;\n let sourceMap: string | undefined;\n\n // Use full path as entry file so AS compiler can resolve relative imports\n const entryFile = filename;\n // Use simple output name to avoid AS compiler prepending it to source map paths\n const outputFile = 'output.wasm';\n\n debug(`${logPrefix} - Compiling: \"${filename}\"`);\n\n // Capture stdout/stderr (for potential error reporting)\n const stdout = {\n write: (text: string) => {\n stdoutLines.push(text);\n return true;\n }\n };\n\n const stderr = {\n write: (text: string) => {\n stderrLines.push(text);\n return true;\n }\n };\n\n // Build compiler flags\n const compilerFlags = [\n entryFile,\n\n // overrideable, though not recommended\n '--optimizeLevel', '0', // No optimization for easier debugging\n '--shrinkLevel', '0', // No shrink\n '--runtime', 'stub', // stub runtime (no GC)\n\n ...(extraFlags || []),\n\n // non-overrideable\n '--outFile', outputFile,\n '--importMemory', // Import memory from JS (enables imports during WASM start)\n '--debug', // Include debug info\n '--sourceMap', // Generate source maps for error reporting\n '--exportStart', '_start', // Export start function for explicit initialization control\n '--exportTable' // Export function table for direct test execution\n ];\n\n // Add transform to strip @inline decorators if requested\n // This improves coverage accuracy by preventing functions from being inlined,\n // and enables correct source-mapped error reporting for errors originating\n // inside inlined functions.\n if (options.stripInline === true) {\n compilerFlags.push(\n '--transform', STRIP_INLINE_TRANSFORM\n );\n debug(`${logPrefix} - Added Transform - Stripping @inline decorators`);\n }\n\n // Compile with AssemblyScript compiler\n const ascStart = performance.now();\n const result = await ascMain(compilerFlags, {\n stdout,\n stderr,\n // Let AS read from filesystem for import resolution\n // WASM binary and source map are captured in memory via writeFile callback\n writeFile: (name: string, contents: string | Uint8Array, _baseDir: string) => {\n throwPoolErrorIfAborted(signal);\n\n if (name.endsWith('.wasm') && contents instanceof Uint8Array) {\n binary = contents;\n debug(`${logPrefix} - Captured binary in memory: \"${name}\"`);\n } else if (name.endsWith('.wasm.map') && typeof contents === 'string') {\n debug(`${logPrefix} - Captured source map in memory: \"${name}\"`);\n sourceMap = contents;\n } else {\n debug(`${logPrefix} - WARNING - Captured Unexpected File: \"${name}\" at baseDir: \"${_baseDir}\"`);\n }\n },\n \n // Custom readFile enables in-tree resolution of bare pool assembly imports.\n // When a test file imports 'vitest-pool-assemblyscript/assembly', the AS compiler\n // resolves it to a node_modules path. This works when the package is installed,\n // but fails in-tree (the package isn't in its own node_modules). The fallback\n // redirects these to the local assembly/ directory when the normal path isn't found.\n readFile: async (filename, baseDir): Promise<string | null> => {\n const filePath = resolve(baseDir, filename);\n\n try {\n return await readFile(filePath, { encoding: 'utf-8' });\n } catch {\n // Fallback: when running in-tree, redirect pool assembly imports to local assembly/ dir\n if (filename.startsWith(POOL_ASSEMBLY_NODE_MODULES_PREFIX)) {\n const localSubpath = filename.substring(POOL_ASSEMBLY_NODE_MODULES_PREFIX.length);\n const localPath = resolve(baseDir, 'assembly', localSubpath);\n\n try {\n return await readFile(localPath, { encoding: 'utf-8' });\n } catch {\n return null;\n }\n }\n\n return null;\n }\n },\n });\n\n debug(`${logPrefix} - TIMING asc.main: ${(performance.now() - ascStart).toFixed(2)} ms`);\n\n if (result.error) {\n const errorMessage = stderrLines.length > 0\n ? `${result.error.message}\\n\\n${stderrLines.join('')}`\n : result.error.message;\n\n throw createPoolError(errorMessage, POOL_ERROR_NAMES.CompilationError, errorMessage);\n }\n\n if (!binary) {\n const errorMessage = stderrLines.length > 0\n ? `No WASM binary was generated\\n\\nAS Compiler output:\\n${stderrLines.join('')}`\n : 'No WASM binary was generated';\n\n throw createPoolError(errorMessage, POOL_ERROR_NAMES.CompilationError);\n }\n\n if (!sourceMap) {\n throw createPoolError('Source map not captured from AssemblyScript Compiler', POOL_ERROR_NAMES.CompilationError);\n }\n\n const cleanBinary: Uint8Array = binary;\n const wasmSourceMap: string = sourceMap;\n\n debug(`${logPrefix} - Compilation successful, clean binary size: ${cleanBinary.length} bytes`);\n debug(`${logPrefix} - Source map generated, size: ${wasmSourceMap.length * 2} bytes`);\n \n if (DEBUG_WRITE_FILES) {\n // Write source map for debugging\n const dir = './debug';\n // TODO - handle non-.ts extensions\n const sourceMapFileName = `${basename(filename, '.ts')}.ts.map`;\n const sourceMapPath = `${dir}/${sourceMapFileName}`;\n\n // Create directory if it doesn't exist\n try {\n await mkdir(dir, { recursive: true });\n } catch {\n // Directory already exists or creation failed, continue\n }\n\n // Format as well-formed JSON\n const formattedSourceMap = JSON.stringify(JSON.parse(wasmSourceMap), null, 2);\n\n writeFile(sourceMapPath, formattedSourceMap, { encoding: 'utf8' });\n debug(`${logPrefix} - Wrote source map to: \"${sourceMapPath}\"`);\n\n // Also write WASM binary for inspection\n const wasmPath = sourceMapPath.replace('.map', '.wasm');\n writeFile(wasmPath, cleanBinary);\n debug(`${logPrefix} - Wrote WASM binary to: \"${wasmPath}\"`);\n }\n\n // Instrument binary for coverage if requested and available\n if (options.shouldInstrument && nativeAddon) {\n throwPoolErrorIfAborted(signal);\n\n const instrumentStart = performance.now();\n const wasmBuffer = Buffer.from(cleanBinary);\n const sourceMapBuffer = Buffer.from(wasmSourceMap);\n\n const instrumentResult = nativeAddon.instrumentForCoverage(wasmBuffer, sourceMapBuffer, options.instrumentationOptions!, logModule, logLabel);\n const instCount = instrumentResult.debugInfo.instrumentedFunctionCount;\n\n const instrumentEnd = performance.now();\n debug(`${logPrefix} - TIMING Instrumented ${instCount} functions: ${(performance.now() - instrumentStart).toFixed(2)} ms`);\n\n return {\n binary: instrumentResult.instrumentedWasm,\n sourceMap: instrumentResult.sourceMap,\n debugInfo: instrumentResult.debugInfo,\n isInstrumented: true,\n compileTiming: instrumentEnd - compileStart,\n };\n }\n\n // No instrumentation requested\n return {\n binary: cleanBinary,\n sourceMap: wasmSourceMap,\n isInstrumented: false,\n compileTiming: performance.now() - compileStart,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAI;AACJ,IAAI;AACF,eAAc,MAAM,OAAO;AAE3B,wBAAuB;SAChB,KAAU;AAEjB,KAD0B,MAAM,qBAAqB,CAGnD,OAAM,6EAA6E,KAAK,WAAW,OAAO,IAAI,GAAG;KAGjH,gCAA+B,KAAK,WAAW,OAAO,IAAI,CAAC;;AAQ/D,MAAM,oCAAoC;AAG1C,MAAM,yBAAyB,QAAQ,OAAO,KAAK,SAAS,yCAAyC;AAErG,aAAa,YAAY;AACvB,KAAI;AACF,QAAM,OAAO,uBAAuB;SAC9B;AACN,QAAM,gBACJ,yDAAyD,uBAAuB,IAChF,iBAAiB,iBAClB;;EAEH;;;;AAK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KAAK;AACvC,QAAM,GAAG,UAAU,yBAAyB,UAAU,eAAe,YAAY,KAAK,GAAG,iBAAiB,QAAQ,EAAE,CAAC,KAAK;AAE1H,SAAO;GACL,QAAQ,iBAAiB;GACzB,WAAW,iBAAiB;GAC5B,WAAW,iBAAiB;GAC5B,gBAAgB;GAChB,eAAe,gBAAgB;GAChC;;AAIH,QAAO;EACL,QAAQ;EACR,WAAW;EACX,gBAAgB;EAChB,eAAe,YAAY,KAAK,GAAG;EACpC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants-DuBLuMjt.mjs","names":[],"sources":["../src/types/constants.ts"],"sourcesContent":["/**\n * Plain Constants\n * \n * Only things that don't require importing ./types to avoid circular dependencies.\n */\n\n\n// ============================================================================\n// General / Shared Constants\n// ============================================================================\n\nexport const ASSEMBLYSCRIPT_POOL_NAME = 'assemblyscript' as const;\n\nexport const AS_POOL_ERROR_TYPE_FLAG = '__as_pool__' as const;\n\nexport const AS_POOL_WORKER_MSG_FLAG = '__as_pool__' as const;\n\nexport const AS_POOL_WASM_IMPORTS_ENV = '__as_pool_env__' as const;\n\nexport const VITEST_WORKER_REQUEST_MSG_FLAG = '__vitest_worker_request__' as const;\n\nexport const VITEST_WORKER_RESPONSE_MSG_FLAG = '__vitest_worker_response__' as const;\n\nexport const COVERAGE_PAYLOAD_FORMATS = {\n AssemblyScript: 'assemblyscript',\n} as const;\n\n/** Prefix for AssemblyScript compiler strip-inline exclusions and instrumentation exclusions */\nexport const ASSEMBLYSCRIPT_LIB_PREFIX = '~lib/' as const;\n\nexport const INTERNAL_PATH_LIB_PREFIX: string = `${ASSEMBLYSCRIPT_LIB_PREFIX}vitest-pool-assemblyscript/assembly/` as const;\n\n/** Paths instrumentation exclusions and assetion error stack frame filtering */\nexport const POOL_INTERNAL_PATHS: string[] = [\n // AS compiler source maps these as relative paths when running locally\n 'assembly/compare.ts',\n 'assembly/describe.ts',\n 'assembly/expect.ts',\n 'assembly/index.ts',\n 'assembly/options.ts',\n 'assembly/test.ts',\n\n // AS compiler source maps these as library paths when running published version\n `${INTERNAL_PATH_LIB_PREFIX}compare.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}describe.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}expect.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}index.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}options.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}test.ts`,\n] as const;\n\n/** Error names for AssemblyScript test failures reported to vitest */\nexport const TEST_ERROR_NAMES = {\n /** Assertion evaluated to false within a test function */\n AssertionError: 'AssertionError',\n /** WASM runtime called abort after a non-planned user code error */\n WASMRuntimeError: 'WASMRuntimeError',\n} as const;\n\n/** Error names for internal AssemblyScript pool failures */\nexport const POOL_ERROR_NAMES = {\n /** AssemblyScript compiler (asc) error */\n CompilationError: 'CompilationError',\n /** Native instrumentation and debug info extraction error */\n WASMInstrumentationError: 'WASMInstrumentationError',\n /** Unexpected WASM execution error (not a known test error path) */\n WASMExecutionHarnessError: 'WASMExecutionHarnessError',\n /** Hybrid coverage provider error */\n HybridCoverageProviderError: 'HybridCoverageProviderError',\n /** vitest RPC reporting error */\n PoolReportingError: 'PoolReportingError',\n /** User configuration error */\n PoolConfigError: 'PoolConfigError',\n /** Generic AssemblyScript pool error */\n PoolError: 'PoolError',\n /** User syntax error in test/suite/expect */\n PoolSyntaxError: 'PoolSyntaxError',\n\n /** Flow Control: Indicates intentional abort */\n PoolRunAbortedError: 'PoolRunAbortedError',\n /**\n * Flow Control: Indicates WASM execution halt through abort() handler,\n * and should be handled by reporting an AssemblyScriptTestError to vitest\n */\n WASMExecutionAbortError: 'WASMExecutionAbortError',\n /** Flow Control: Indicates WASM execution halt because test timeout elapsed */\n WASMExecutionTimeoutError: 'WASMExecutionTimeoutError',\n} as const;\n\n// ============================================================================\n// AssemblyScript Compiler\n// ============================================================================\n\n// Redefined locally to avoid isolatedModules const enum access issues\n// with assemmblyscript enum exports. Reference assemblyscript.generated.d.ts\n\nexport const ASCommonFlags = {\n Static: 32,\n Get: 2048,\n Set: 4096,\n} as const;\n\nexport const ASNodeKind = {\n Source: 0,\n NamedType: 1,\n FunctionType: 2,\n TypeName: 3,\n TypeParameter: 4,\n Parameter: 5,\n Identifier: 6,\n Assertion: 7,\n Binary: 8,\n Call: 9,\n Class: 10,\n Comma: 11,\n ElementAccess: 12,\n False: 13,\n Function: 14,\n InstanceOf: 15,\n Literal: 16,\n New: 17,\n Null: 18,\n Omitted: 19,\n Parenthesized: 20,\n PropertyAccess: 21,\n Ternary: 22,\n Super: 23,\n This: 24,\n True: 25,\n Constructor: 26,\n UnaryPostfix: 27,\n UnaryPrefix: 28,\n Compiled: 29,\n Block: 30,\n Break: 31,\n Continue: 32,\n Do: 33,\n Empty: 34,\n Export: 35,\n ExportDefault: 36,\n ExportImport: 37,\n Expression: 38,\n For: 39,\n ForOf: 40,\n If: 41,\n Import: 42,\n Return: 43,\n Switch: 44,\n Throw: 45,\n Try: 46,\n Variable: 47,\n Void: 48,\n While: 49,\n Module: 50,\n ClassDeclaration: 51,\n EnumDeclaration: 52,\n EnumValueDeclaration: 53,\n FieldDeclaration: 54,\n FunctionDeclaration: 55,\n ImportDeclaration: 56,\n InterfaceDeclaration: 57,\n MethodDeclaration: 58,\n NamespaceDeclaration: 59,\n TypeDeclaration: 60,\n VariableDeclaration: 61,\n Decorator: 62,\n ExportMember: 63,\n SwitchCase: 64,\n IndexSignature: 65,\n Comment: 66,\n} as const;\n\nexport const ASDecoratorKind = {\n Custom: 0,\n Global: 1,\n Operator: 2,\n OperatorBinary: 3,\n OperatorPrefix: 4,\n OperatorPostfix: 5,\n Unmanaged: 6,\n Final: 7,\n Inline: 8,\n External: 9,\n ExternalJs: 10,\n Builtin: 11,\n Lazy: 12,\n Unsafe: 13\n} as const;\n\nexport const ASSourceKind = {\n User: 0,\n UserEntry: 1,\n Library: 2,\n LibraryEntry: 3\n} as const;\n"],"mappings":";AAuBA,MAAa,2BAA2B,EACtC,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ACrB,mBAAmB;CACnB,sBAAsB;CACtB,mBAAmB;CACnB,sBAAsB;CACtB,iBAAiB;CACjB,qBAAqB;CACrB,WAAW;CACX,cAAc;CACd,YAAY;CACZ,gBAAgB;CAChB,SAAS;CACV;AAED,MAAa,kBAAkB;CAC7B,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,gBAAgB;CAChB,gBAAgB;CAChB,iBAAiB;CACjB,WAAW;CACX,OAAO;CACP,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,SAAS;CACT,MAAM;CACN,QAAQ;CACT;AAED,MAAa,eAAe;CAC1B,MAAM;CACN,WAAW;CACX,SAAS;CACT,cAAc;CACf"}
@@ -1,26 +0,0 @@
1
- import { HybridProviderOptions } from "./types-D0nprJo1.mjs";
2
- import { CoverageV8Options } from "vitest/node";
3
-
4
- //#region src/config/custom-provider-options.d.ts
5
- /**
6
- * Module augmentation for CustomProviderOptions
7
- *
8
- * Vitest v3's CustomProviderOptions only includes fields with default values,
9
- * but users should be able to configure all optional fields from BaseCoverageOptions.
10
- * This augmentation adds the missing optional fields that work at runtime but
11
- * aren't typed in vitest v3.
12
- *
13
- * Additionally, we add AssemblyScript-specific coverage fields that our hybrid
14
- * coverage provider uses to glob AS source files separately from JS sources.
15
- *
16
- * By placing this augmentation here, it automatically loads when users import
17
- * our config helpers, providing proper coverage typing alongside pool typing.
18
- */
19
- declare module "vitest/node" {
20
- interface CustomProviderOptions extends HybridProviderOptions, Omit<CoverageV8Options, "provider"> {
21
- provider: "custom";
22
- /** Name of the module or path to a file to load the custom provider from */
23
- customProviderModule: string;
24
- }
25
- }
26
- //# sourceMappingURL=custom-provider-options-YTk1m7At.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"custom-provider-options-YTk1m7At.d.mts","names":[],"sources":["../src/config/custom-provider-options.ts"],"mappings":";;;;;;AAE2C;;;;;;;;;;;;;YAiB/B,qBAAA,SAA8B,qBAAA,EAAuB,IAAA,CAAK,iBAAA;IAClE,QAAA;IAGD;IAAA,oBAAA;EAAA;AAAA"}