vitest-pool-assemblyscript 0.2.3 → 0.2.4

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 (34) hide show
  1. package/dist/{ast-visitor-DC3SuTzs.mjs → ast-visitor-lTahoS9R.mjs} +2 -2
  2. package/dist/{ast-visitor-DC3SuTzs.mjs.map → ast-visitor-lTahoS9R.mjs.map} +1 -1
  3. package/dist/{compile-runner-xGvQwgNf.mjs → compile-runner-C9TJrfCl.mjs} +6 -6
  4. package/dist/{compile-runner-xGvQwgNf.mjs.map → compile-runner-C9TJrfCl.mjs.map} +1 -1
  5. package/dist/compiler/transforms/strip-inline.mjs +2 -2
  6. package/dist/{compiler-CN6BRK_N.mjs → compiler-BaNECXMW.mjs} +3 -3
  7. package/dist/{compiler-CN6BRK_N.mjs.map → compiler-BaNECXMW.mjs.map} +1 -1
  8. package/dist/config/index.mjs +5 -4
  9. package/dist/{constants-CA50WBdr.mjs → constants-DX9yo-el.mjs} +11 -2
  10. package/dist/constants-DX9yo-el.mjs.map +1 -0
  11. package/dist/coverage-provider/index.mjs +4 -4
  12. package/dist/{debug-IeEHsxy0.mjs → debug-Cf2jt1kg.mjs} +2 -2
  13. package/dist/{debug-IeEHsxy0.mjs.map → debug-Cf2jt1kg.mjs.map} +1 -1
  14. package/dist/index-internal.mjs +3 -2
  15. package/dist/index-v3.mjs +4 -4
  16. package/dist/index.mjs +5 -4
  17. package/dist/{load-user-imports-Bbmpaciu.mjs → load-user-imports-CcIdE4_0.mjs} +4 -4
  18. package/dist/{load-user-imports-Bbmpaciu.mjs.map → load-user-imports-CcIdE4_0.mjs.map} +1 -1
  19. package/dist/{pool-runner-init-Kuzz61rB.mjs → pool-runner-init-Cdpz_B-F.mjs} +5 -5
  20. package/dist/{pool-runner-init-Kuzz61rB.mjs.map → pool-runner-init-Cdpz_B-F.mjs.map} +1 -1
  21. package/dist/pool-thread/compile-worker-thread.mjs +6 -5
  22. package/dist/pool-thread/compile-worker-thread.mjs.map +1 -1
  23. package/dist/pool-thread/test-worker-thread.mjs +5 -4
  24. package/dist/pool-thread/test-worker-thread.mjs.map +1 -1
  25. package/dist/pool-thread/v3-tinypool-thread.mjs +7 -6
  26. package/dist/pool-thread/v3-tinypool-thread.mjs.map +1 -1
  27. package/dist/{resolve-config-as1w-Qyz.mjs → resolve-config-BKjJQyy5.mjs} +3 -3
  28. package/dist/{resolve-config-as1w-Qyz.mjs.map → resolve-config-BKjJQyy5.mjs.map} +1 -1
  29. package/dist/{test-runner-BR4XyhMA.mjs → test-runner-DZd3SxEc.mjs} +4 -4
  30. package/dist/{test-runner-BR4XyhMA.mjs.map → test-runner-DZd3SxEc.mjs.map} +1 -1
  31. package/dist/{vitest-tasks-BKS7689f.mjs → vitest-tasks-Cbri6MWZ.mjs} +3 -3
  32. package/dist/{vitest-tasks-BKS7689f.mjs.map → vitest-tasks-Cbri6MWZ.mjs.map} +1 -1
  33. package/package.json +1 -1
  34. package/dist/constants-CA50WBdr.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { ASNodeKind } from "./constants-CA50WBdr.mjs";
1
+ import { ASNodeKind } from "./constants-DX9yo-el.mjs";
2
2
 
3
3
  //#region src/util/ast-visitor.ts
4
4
  /**
@@ -307,4 +307,4 @@ var ASTVisitor = class {
307
307
 
308
308
  //#endregion
309
309
  export { ASTVisitor };
310
- //# sourceMappingURL=ast-visitor-DC3SuTzs.mjs.map
310
+ //# sourceMappingURL=ast-visitor-lTahoS9R.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast-visitor-DC3SuTzs.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,AAAU,aAAa,OAA+B;;;;;CAMtD,AAAU,YAAY,OAA+B;;;;;;CAOrD,AAAU,sBAAsB,OAAqC;AACnE,SAAO;;;;;;;CAQT,AAAU,oBAAoB,OAAmC;AAC/D,SAAO;;;;;;;CAQT,AAAU,sBAAsB,OAAqC;AACnE,SAAO;;;;;CAMT,UAAU,MAAkB;AAE1B,OAAK,YAAY,KAAK;AAGtB,UAAQ,KAAK,MAAb;GAEE,KAAK,WAA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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,AAAU,aAAa,OAA+B;;;;;CAMtD,AAAU,YAAY,OAA+B;;;;;;CAOrD,AAAU,sBAAsB,OAAqC;AACnE,SA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AAU,KAAK,YAAY;AACvE;;GAIF,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW,UACd"}
@@ -1,9 +1,9 @@
1
- import { POOL_ERROR_NAMES, POOL_INTERNAL_PATHS } from "./constants-CA50WBdr.mjs";
2
- import { createPoolErrorFromAnyError, debug, getTestErrorFromPoolError } from "./debug-IeEHsxy0.mjs";
1
+ import { POOL_ERROR_NAMES, POOL_INTERNAL_PATHS } from "./constants-DX9yo-el.mjs";
2
+ import { createPoolErrorFromAnyError, debug, getTestErrorFromPoolError } from "./debug-Cf2jt1kg.mjs";
3
3
  import { failFile, getFullTaskHierarchy, prepareFileTaskForCollection } from "./vitest-file-tasks-BUwzh375.mjs";
4
- import { getTaskLogLabel, getTaskLogPrefix } from "./vitest-tasks-BKS7689f.mjs";
5
- import { executeWASMDiscovery, flushRpcUpdates, reportFileCollected, reportFileError, reportFileQueued, reportUserConsoleLogs } from "./load-user-imports-Bbmpaciu.mjs";
6
- import { compileAssemblyScript } from "./compiler-CN6BRK_N.mjs";
4
+ import { getTaskLogLabel, getTaskLogPrefix } from "./vitest-tasks-Cbri6MWZ.mjs";
5
+ import { executeWASMDiscovery, flushRpcUpdates, reportFileCollected, reportFileError, reportFileQueued, reportUserConsoleLogs } from "./load-user-imports-CcIdE4_0.mjs";
6
+ import { compileAssemblyScript } from "./compiler-BaNECXMW.mjs";
7
7
  import { basename, relative } from "node:path";
8
8
 
9
9
  //#region src/pool-thread/runner/compile-runner.ts
@@ -77,4 +77,4 @@ async function runCompileAndDiscover(file, logModule, rpc, poolOptions, projectR
77
77
 
78
78
  //#endregion
79
79
  export { runCompileAndDiscover };
80
- //# sourceMappingURL=compile-runner-xGvQwgNf.mjs.map
80
+ //# sourceMappingURL=compile-runner-C9TJrfCl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-runner-xGvQwgNf.mjs","names":[],"sources":["../src/pool-thread/runner/compile-runner.ts"],"sourcesContent":["/**\n * Worker thread test runner logic for AssemblyScript Pool\n */\n\nimport { basename, relative } from 'node:path';\nimport type { File } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\n\nimport type {\n AssemblyScriptCompilerOptions,\n AssemblyScriptConsoleLog,\n AssemblyScriptConsoleLogHandler,\n InstrumentationOptions,\n ResolvedAssemblyScriptPoolOptions,\n ThreadImports,\n WASMCompilation,\n WorkerRPC,\n} from '../../types/types.js';\nimport {\n ASSEMBLYSCRIPT_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 // TODO - move to options helpers\n const relativeTestFilePath = relative(projectRoot, file.filepath);\n const instrumentationOptions: InstrumentationOptions = {\n relativeExcludedFiles: [\n relativeTestFilePath,\n ...POOL_INTERNAL_PATHS,\n ...relativeUserCoverageExclusions,\n ],\n excludedLibraryFilePrefix: ASSEMBLYSCRIPT_LIB_PREFIX,\n coverageMemoryPagesMin: poolOptions.coverageMemoryPagesInitial,\n coverageMemoryPagesMax: poolOptions.coverageMemoryPagesMax,\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":";;;;;;;;;;;;AA4CA,IAAI,yBAAiC;AAErC,eAAsB,sBACpB,MACA,WACA,KACA,aACA,aACA,iBACA,gCACA,eACA,aACA,iBACA,WACsC;CACtC,MAAM,OAAO,SAAS,KAAK,SAAS;CACpC,MAAM,gBAAgB,iBAAiB,WAAW,MAAM,KAAK;CAC7D,MAAM,eAAe,gBAAgB,MAAM,KAAK;AAEhD,OAAM,GAAG,cAAc,0CAA0C,KAAK,SAAS,OAAO,KAAK,KAAK,GAAG;CAEnG,MAAM,WAAW,YAAY,KAAK;CAClC,IAAI;AAEJ,KAAI;AACF,QAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;EAI1D,MAAM,yBAAiD;GACrD,uBAAuB;IAFI,SAAS,aAAa,KAAK,SAAS;IAI7D,GAAG;IACH,GAAG;IACJ;GACD;GACA,wBAAwB,YAAY;GACpC,wBAAwB,YAAY;GACrC;EACD,MAAM,kBAAiD;GACrD,aAAa,YAAY;GACZ;GACb,kBAAkB;GAClB;GACA,YAAY,YAAY;GACzB;EAED,MAAM,EAAE,QAAQ,WAAW,WAAW,kBAAkB,MAAM,sBAC5D,KAAK,UACL,iBACA,WACA,aACD;AACD,OAAK,gBAAgB;AACrB;AAEA,QAAM,GAAG,cAAc,uDACD,uBAAuB,KAAK,cAAc,QAAQ,EAAE,CAAC,KAC1E;EAED,MAAM,cAA0C,EAAE;EAClD,MAAM,aAA8C,KAAa,UAAmB,UAAgB;AAClG,eAAY,KAAK;IAAE;IAAK,MAAM,KAAK,KAAK;IAAE;IAAS,CAAC;;EAGtD,MAAM,gBAAgB,YAAY,KAAK;AAEvC,QAAM,qBACJ,QACA,WACA,MACA,aACA,iBACA,WACA,MACA,WACA,eACA,YACD;AAGD,+BAA6B,MAAM,iBAAiB,UAAU;AAE9D,OAAK,kBAAkB,YAAY,KAAK,GAAG;AAC3C,QAAM,GAAG,cAAc,6BAA6B,KAAK,gBAAgB,QAAQ,EAAE,CAAC,KAAK;AAGzF,QAAM,QAAQ,IAAI,CAEhB,sBAAsB,KAAK,aAAa,WAAW,MAAM,KAAK,EAG9D,oBAAoB,KAAK,MAAM,WAAW,aAAa,CACxD,CAAC;AAEF,cAAY,GAAG,cAAc,sCAAsC,qBAAqB,KAAK,GAAG;AAGhG,QAAM,GAAG,cAAc,wCADL,YAAY,KAAK,GAAG,UACkC,QAAQ,EAAE,CAAC,KAAK;AAExF,gBAAc;GACZ,UAAU,KAAK;GACf;GACA;GACA;GACD;UACM,OAAO;AAQd,WAAS,MAFS,0BALA,4BAChB,GAAG,aAAa,6CAChB,iBAAiB,2BACjB,MACD,CACqD,EAE5B,SAAS;AAEnC,QAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;AAC1D,QAAM,gBAAgB,KAAK,MAAM,WAAW,aAAa;AAEzD,QAAM,GAAG,cAAc,wBAAwB;WACvC;AACR,QAAM,gBAAgB,IAAI;AAC1B,QAAM,GAAG,cAAc,oCAAoC;;AAG7D,QAAO"}
1
+ {"version":3,"file":"compile-runner-C9TJrfCl.mjs","names":[],"sources":["../src/pool-thread/runner/compile-runner.ts"],"sourcesContent":["/**\n * Worker thread test runner logic for AssemblyScript Pool\n */\n\nimport { basename, relative } from 'node:path';\nimport type { File } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\n\nimport type {\n AssemblyScriptCompilerOptions,\n AssemblyScriptConsoleLog,\n AssemblyScriptConsoleLogHandler,\n InstrumentationOptions,\n ResolvedAssemblyScriptPoolOptions,\n ThreadImports,\n WASMCompilation,\n WorkerRPC,\n} from '../../types/types.js';\nimport {\n ASSEMBLYSCRIPT_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 // TODO - move to options helpers\n const relativeTestFilePath = relative(projectRoot, file.filepath);\n const instrumentationOptions: InstrumentationOptions = {\n relativeExcludedFiles: [\n relativeTestFilePath,\n ...POOL_INTERNAL_PATHS,\n ...relativeUserCoverageExclusions,\n ],\n excludedLibraryFilePrefix: ASSEMBLYSCRIPT_LIB_PREFIX,\n coverageMemoryPagesMin: poolOptions.coverageMemoryPagesInitial,\n coverageMemoryPagesMax: poolOptions.coverageMemoryPagesMax,\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":";;;;;;;;;;;;AA4CA,IAAI,yBAAiC;AAErC,eAAsB,sBACpB,MACA,WACA,KACA,aACA,aACA,iBACA,gCACA,eACA,aACA,iBACA,WACsC;CACtC,MAAM,OAAO,SAAS,KAAK,SAAS;CACpC,MAAM,gBAAgB,iBAAiB,WAAW,MAAM,KAAK;CAC7D,MAAM,eAAe,gBAAgB,MAAM,KAAK;AAEhD,OAAM,GAAG,cAAc,0CAA0C,KAAK,SAAS,OAAO,KAAK,KAAK,GAAG;CAEnG,MAAM,WAAW,YAAY,KAAK;CAClC,IAAI;AAEJ,KAAI;AACF,QAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;EAI1D,MAAM,yBAAiD;GACrD,uBAAuB;IAFI,SAAS,aAAa,KAAK,SAAS;IAI7D,GAAG;IACH,GAAG;IACJ;GACD;GACA,wBAAwB,YAAY;GACpC,wBAAwB,YAAY;GACrC;EACD,MAAM,kBAAiD;GACrD,aAAa,YAAY;GACZ;GACb,kBAAkB;GAClB;GACA,YAAY,YAAY;GACzB;EAED,MAAM,EAAE,QAAQ,WAAW,WAAW,kBAAkB,MAA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-visitor-DC3SuTzs.mjs";
1
+ import { ASDecoratorKind, ASSourceKind } from "../../constants-DX9yo-el.mjs";
2
+ import { ASTVisitor } from "../../ast-visitor-lTahoS9R.mjs";
3
3
  import { Transform } from "assemblyscript/transform";
4
4
 
5
5
  //#region src/compiler/transforms/strip-inline.mts
@@ -1,5 +1,5 @@
1
- import { POOL_ERROR_NAMES } from "./constants-CA50WBdr.mjs";
2
- import { createPoolError, debug, throwPoolErrorIfAborted } from "./debug-IeEHsxy0.mjs";
1
+ import { POOL_ERROR_NAMES } from "./constants-DX9yo-el.mjs";
2
+ import { createPoolError, debug, throwPoolErrorIfAborted } from "./debug-Cf2jt1kg.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { basename, dirname, resolve } from "node:path";
5
5
  import { access } from "node:fs/promises";
@@ -292,4 +292,4 @@ async function compileAssemblyScript(filename, options, logModule, logLabel, sig
292
292
 
293
293
  //#endregion
294
294
  export { compileAssemblyScript };
295
- //# sourceMappingURL=compiler-CN6BRK_N.mjs.map
295
+ //# sourceMappingURL=compiler-BaNECXMW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler-CN6BRK_N.mjs","names":["ascMain"],"sources":["../src/native-instrumentation/addon-interface.ts","../src/compiler/index.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';\nimport { debug } from '../util/debug.js';\nimport {\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} from '../types/types.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { createPoolError } from '../util/pool-errors.js';\n\nconst DEBUG_NATIVE_ADDON = false;\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.\n// We run from dist/ (published) or src/ (dev/tests), so we try both root paths.\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst rootFromDist = resolve(__dirname, '..');\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 `Native addon not found. Searched from ${rootFromDist} and ${rootFromSrc}. ` +\n `Ensure prebuilds are available or run 'npm run build:native' to compile from source. ` +\n `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, path strings)\n */\nfunction convertLocation(\n rawLocation: NativeSourceLocation,\n debugSourceFiles: string[]\n): SourceLocation {\n const 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 return {\n filePath: 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): 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);\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): { func: FunctionDebugInfo; filePath: string; positionKey: string } | undefined {\n const representativeLocation = convertLocation(rawFunc.representativeLocation, debugSourceFiles);\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));\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 * Transform raw native addon output to processed BinaryDebugInfo\n */\nfunction transformDebugInfo(\n raw: NativeDebugInfoOutput,\n logPrefix: string,\n): BinaryDebugInfo {\n const functionsByFileAndPosition: Record<string, Record<string, FunctionDebugInfo>> = {};\n\n debug(`${logPrefix} - Converting ${raw.functions.length} functions`);\n\n let positionCollisionCount = 0;\n let skippedCount = 0;\n let instrumentedFunctionCount = 0;\n \n for (const rawFunc of raw.functions) {\n const result = convertFunction(rawFunc, raw.debugSourceFiles);\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 if (functionsByFileAndPosition[filePath]?.[positionKey]) {\n const existing = functionsByFileAndPosition[filePath][positionKey];\n positionCollisionCount++;\n throw createPoolError(\n `ERROR - Function Debug Position Collision at ${filePath}:${positionKey}: \"${existing.name}\" will be replaced by \"${func.name}\"`,\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 +` (${positionCollisionCount} position 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 function instrumentForCoverage(\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 debug: DEBUG_NATIVE_ADDON,\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);\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","/**\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 } from 'node:fs/promises';\nimport { writeFile, mkdir } from 'node:fs/promises';\n\nimport { AssemblyScriptCompilerResult, AssemblyScriptCompilerOptions } from '../types/types.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { instrumentForCoverage } from '../native-instrumentation/addon-interface.js';\nimport { createPoolError, throwPoolErrorIfAborted } from '../util/pool-errors.js';\n\nconst DEBUG_WRITE_FILES = false;\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 *\n * Features:\n * - In-memory compilation (binary captured via writeFile callback)\n * - Filesystem reading enabled (for import resolution)\n * - Uses stub runtime and imported memory pattern\n * - Exports _start function for explicit initialization control\n * - Always returns clean binary\n * - Conditionally returns instrumented binary when coverage enabled\n *\n * @param filename - Full path to the source file (used as entry point)\n * @param options - Compilation options (coverage mode, etc.)\n * @returns Compilation result with clean binary and optional instrumented binary\n * @throws Error if compilation fails\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\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 to project maps directory for debugging\n const dir = './debug';\n const sourceMapFileName = `${basename(filename, '.ts')}.as.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\n if (options.shouldInstrument) {\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 = 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":";;;;;;;;;;;;;;;;;;;AAiCA,MAAM,qBAAqB;AAO3B,MAAM,YAAY,QADC,cAAc,OAAO,KAAK,IAAI,CACZ;AACrC,MAAM,eAAe,QAAQ,WAAW,KAAK;AAC7C,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,yCAAyC,aAAa,OAAO,YAAY,yGAEtD,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,IACnE,iBAAiB,yBAClB;;;;;;;AAQL,SAAS,gBACP,aACA,kBACgB;CAChB,MAAM,WAAW,iBAAiB,YAAY;AAE9C,KAAI,CAAC,SACH,OAAM,gBACJ,oCAAoC,YAAY,UAAU,IAC1D,iBAAiB,yBAClB;AAGH,QAAO;EACK;EACV,MAAM,YAAY;EAClB,QAAQ,YAAY,SAAS;EAC9B;;;;;AAMH,SAAS,kBACP,SACA,kBACqB;CACrB,MAAM,YAAiC;EACrC,MAAM,QAAQ;EACd,UAAU,QAAQ;EACnB;AAED,KAAI,QAAQ,gBAAgB,OAC1B,WAAU,cAAc,QAAQ;AAGlC,KAAI,QAAQ,UAAU;EACpB,MAAM,oBAAoB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,gBAAgB;EAChB,eAAe,YAAY,KAAK,GAAG;EACpC"}
1
+ {"version":3,"file":"compiler-BaNECXMW.mjs","names":["ascMain"],"sources":["../src/native-instrumentation/addon-interface.ts","../src/compiler/index.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';\nimport { debug } from '../util/debug.js';\nimport {\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} from '../types/types.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { createPoolError } from '../util/pool-errors.js';\n\nconst DEBUG_NATIVE_ADDON = false;\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.\n// We run from dist/ (published) or src/ (dev/tests), so we try both root paths.\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst rootFromDist = resolve(__dirname, '..');\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 `Native addon not found. Searched from ${rootFromDist} and ${rootFromSrc}. ` +\n `Ensure prebuilds are available or run 'npm run build:native' to compile from source. ` +\n `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, path strings)\n */\nfunction convertLocation(\n rawLocation: NativeSourceLocation,\n debugSourceFiles: string[]\n): SourceLocation {\n const 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 return {\n filePath: 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): 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);\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): { func: FunctionDebugInfo; filePath: string; positionKey: string } | undefined {\n const representativeLocation = convertLocation(rawFunc.representativeLocation, debugSourceFiles);\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));\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 * Transform raw native addon output to processed BinaryDebugInfo\n */\nfunction transformDebugInfo(\n raw: NativeDebugInfoOutput,\n logPrefix: string,\n): BinaryDebugInfo {\n const functionsByFileAndPosition: Record<string, Record<string, FunctionDebugInfo>> = {};\n\n debug(`${logPrefix} - Converting ${raw.functions.length} functions`);\n\n let positionCollisionCount = 0;\n let skippedCount = 0;\n let instrumentedFunctionCount = 0;\n \n for (const rawFunc of raw.functions) {\n const result = convertFunction(rawFunc, raw.debugSourceFiles);\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 if (functionsByFileAndPosition[filePath]?.[positionKey]) {\n const existing = functionsByFileAndPosition[filePath][positionKey];\n positionCollisionCount++;\n throw createPoolError(\n `ERROR - Function Debug Position Collision at ${filePath}:${positionKey}: \"${existing.name}\" will be replaced by \"${func.name}\"`,\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 +` (${positionCollisionCount} position 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 function instrumentForCoverage(\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 debug: DEBUG_NATIVE_ADDON,\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);\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","/**\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 } from 'node:fs/promises';\nimport { writeFile, mkdir } from 'node:fs/promises';\n\nimport { AssemblyScriptCompilerResult, AssemblyScriptCompilerOptions } from '../types/types.js';\nimport { POOL_ERROR_NAMES } from '../types/constants.js';\nimport { debug } from '../util/debug.js';\nimport { instrumentForCoverage } from '../native-instrumentation/addon-interface.js';\nimport { createPoolError, throwPoolErrorIfAborted } from '../util/pool-errors.js';\n\nconst DEBUG_WRITE_FILES = false;\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 *\n * Features:\n * - In-memory compilation (binary captured via writeFile callback)\n * - Filesystem reading enabled (for import resolution)\n * - Uses stub runtime and imported memory pattern\n * - Exports _start function for explicit initialization control\n * - Always returns clean binary\n * - Conditionally returns instrumented binary when coverage enabled\n *\n * @param filename - Full path to the source file (used as entry point)\n * @param options - Compilation options (coverage mode, etc.)\n * @returns Compilation result with clean binary and optional instrumented binary\n * @throws Error if compilation fails\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\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 to project maps directory for debugging\n const dir = './debug';\n const sourceMapFileName = `${basename(filename, '.ts')}.as.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\n if (options.shouldInstrument) {\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 = 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":";;;;;;;;;;;;;;;;;;;AAiCA,MAAM,qBAAqB;AAO3B,MAAM,YAAY,QADC,cAAc,OAAO,KAAK,IAAI,CACZ;AACrC,MAAM,eAAe,QAAQ,WAAW,KAAK;AAC7C,MAAM,cAAc,QAAQ,WAAW,QAAQ;AAG/C,MAAM,eADU,cAAc,OAAO,KAAK,IAAI,CACa,iBAAiB;AAE5E,IAAI;AACJ,IAAI;AACF,SAAQ,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gD,YAAY,OAAO,QAAQ;AAC9F,OAAM,GAAG,UAAU,iCAAiC,cAAc,SAAS,EAAE,QAAQ;AA4BrF,KAAI,QAAQ,kBAAkB;AAC5B,0BAAwB,OAAO;EAE/B,MAAM,kBAAkB,YAAY,KAAK;EAIzC,MAAM,mBAAmB,sBAHN,OAAO,KAAK,YAAY,EACnB,OAAO,KAAK,cAAc,EAE0B,QAAQ,wBAAyB,WAAW,SAAS;EACjI,MAAM,YAAY,iBAAiB,UAAU;EAE7C,MAAM,gBAAgB,YAAY,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,8 +1,9 @@
1
- import "../resolve-config-as1w-Qyz.mjs";
2
- import "../debug-IeEHsxy0.mjs";
1
+ import "../constants-DX9yo-el.mjs";
2
+ import "../resolve-config-BKjJQyy5.mjs";
3
+ import "../debug-Cf2jt1kg.mjs";
3
4
  import "../vitest-file-tasks-BUwzh375.mjs";
4
- import "../vitest-tasks-BKS7689f.mjs";
5
+ import "../vitest-tasks-Cbri6MWZ.mjs";
5
6
  import "../worker-rpc-channel-lbhK7Qz8.mjs";
6
- import { createAssemblyScriptPool } from "../pool-runner-init-Kuzz61rB.mjs";
7
+ import { createAssemblyScriptPool } from "../pool-runner-init-Cdpz_B-F.mjs";
7
8
 
8
9
  export { createAssemblyScriptPool };
@@ -1,5 +1,8 @@
1
1
  //#region src/types/constants.ts
2
2
  const COVERAGE_PAYLOAD_FORMATS = { AssemblyScript: "assemblyscript" };
3
+ /** Prefix for AssemblyScript compiler strip-inline exclusions and instrumentation exclusions */
4
+ const ASSEMBLYSCRIPT_LIB_PREFIX = "~lib/";
5
+ const INTERNAL_PATH_LIB_PREFIX = `${"~lib/"}vitest-pool-assemblyscript/`;
3
6
  /** Paths instrumentation exclusions and assetion error stack frame filtering */
4
7
  const POOL_INTERNAL_PATHS = [
5
8
  "assembly/compare.ts",
@@ -7,7 +10,13 @@ const POOL_INTERNAL_PATHS = [
7
10
  "assembly/expect.ts",
8
11
  "assembly/index.ts",
9
12
  "assembly/options.ts",
10
- "assembly/test.ts"
13
+ "assembly/test.ts",
14
+ `${INTERNAL_PATH_LIB_PREFIX}assembly/compare.ts`,
15
+ `${INTERNAL_PATH_LIB_PREFIX}assembly/describe.ts`,
16
+ `${INTERNAL_PATH_LIB_PREFIX}assembly/expect.ts`,
17
+ `${INTERNAL_PATH_LIB_PREFIX}assembly/index.ts`,
18
+ `${INTERNAL_PATH_LIB_PREFIX}assembly/options.ts`,
19
+ `${INTERNAL_PATH_LIB_PREFIX}assembly/test.ts`
11
20
  ];
12
21
  /** Error names for AssemblyScript test failures reported to vitest */
13
22
  const TEST_ERROR_NAMES = {
@@ -127,4 +136,4 @@ const ASSourceKind = {
127
136
 
128
137
  //#endregion
129
138
  export { ASCommonFlags, ASDecoratorKind, ASNodeKind, ASSourceKind, COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES, POOL_INTERNAL_PATHS, TEST_ERROR_NAMES };
130
- //# sourceMappingURL=constants-CA50WBdr.mjs.map
139
+ //# sourceMappingURL=constants-DX9yo-el.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-DX9yo-el.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\nconst INTERNAL_PATH_LIB_PREFIX = `${ASSEMBLYSCRIPT_LIB_PREFIX}vitest-pool-assemblyscript/`\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}assembly/compare.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}assembly/describe.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}assembly/expect.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}assembly/index.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}assembly/options.ts`,\n `${INTERNAL_PATH_LIB_PREFIX}assembly/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,gBAAgB,kBACjB;;AAGD,MAAa,4BAA4B;AAEzC,MAAM,2BAA2B,WAA6B;;AAG9D,MAAa,sBAAgC;CAE3C;CACA;CACA;CACA;CACA;CACA;CAGA,GAAG,yBAAyB;CAC5B,GAAG,yBAAyB;CAC5B,GAAG,yBAAyB;CAC5B,GAAG,yBAAyB;CAC5B,GAAG,yBAAyB;CAC5B,GAAG,yBAAyB;CAC7B;;AAGD,MAAa,mBAAmB;CAE9B,gBAAgB;CAEhB,kBAAkB;CACnB;;AAGD,MAAa,mBAAmB;CAE9B,kBAAkB;CAElB,0BAA0B;CAE1B,2BAA2B;CAE3B,6BAA6B;CAE7B,oBAAoB;CAEpB,iBAAiB;CAEjB,WAAW;CAEX,iBAAiB;CAGjB,qBAAqB;CAKrB,yBAAyB;CAEzB,2BAA2B;CAC5B;AASD,MAAa,gBAAgB;CAC3B,QAAQ;CACR,KAAK;CACL,KAAK;CACN;AAED,MAAa,aAAa;CACxB,QAAQ;CACR,WAAW;CACX,cAAc;CACd,UAAU;CACV,eAAe;CACf,WAAW;CACX,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,MAAM;CACN,OAAO;CACP,OAAO;CACP,eAAe;CACf,OAAO;CACP,UAAU;CACV,YAAY;CACZ,SAAS;CACT,KAAK;CACL,MAAM;CACN,SAAS;CACT,eAAe;CACf,gBAAgB;CAChB,SAAS;CACT,OAAO;CACP,MAAM;CACN,MAAM;CACN,aAAa;CACb,cAAc;CACd,aAAa;CACb,UAAU;CACV,OAAO;CACP,OAAO;CACP,UAAU;CACV,IAAI;CACJ,OAAO;CACP,QAAQ;CACR,eAAe;CACf,cAAc;CACd,YAAY;CACZ,KAAK;CACL,OAAO;CACP,IAAI;CACJ,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;CACN,OAAO;CACP,QAAQ;CACR,kBAAkB;CAClB,iBAAiB;CACjB,sBAAsB;CACtB,kBAAkB;CAClB,qBAAqB;CACrB,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,8 +1,8 @@
1
- import { ASCommonFlags, ASNodeKind, COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES } from "../constants-CA50WBdr.mjs";
2
- import { getProjectSerializedOrGlobalConfig } from "../resolve-config-as1w-Qyz.mjs";
3
- import { createPoolError, debug } from "../debug-IeEHsxy0.mjs";
1
+ import { ASCommonFlags, ASNodeKind, COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES } from "../constants-DX9yo-el.mjs";
2
+ import { getProjectSerializedOrGlobalConfig } from "../resolve-config-BKjJQyy5.mjs";
3
+ import { createPoolError, debug } from "../debug-Cf2jt1kg.mjs";
4
4
  import { mergeCoverageData } from "../coverage-merge-0WqdC-dq.mjs";
5
- import { ASTVisitor } from "../ast-visitor-DC3SuTzs.mjs";
5
+ import { ASTVisitor } from "../ast-visitor-lTahoS9R.mjs";
6
6
  import { basename, parse, relative } from "node:path";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import v8CoverageModule from "@vitest/coverage-v8";
@@ -1,4 +1,4 @@
1
- import { POOL_ERROR_NAMES, TEST_ERROR_NAMES } from "./constants-CA50WBdr.mjs";
1
+ import { POOL_ERROR_NAMES, TEST_ERROR_NAMES } from "./constants-DX9yo-el.mjs";
2
2
  import { stripVTControlCharacters } from "node:util";
3
3
  import c from "tinyrainbow";
4
4
 
@@ -192,4 +192,4 @@ function isDebugModeEnabled() {
192
192
 
193
193
  //#endregion
194
194
  export { createPoolError, createPoolErrorFromAnyError, createTestExpectedToFailError, createTestTimeoutError, debug, getSourceCodeFrameString, getTestErrorFromPoolError, isAbortError, isDebugModeEnabled, setGlobalDebugMode, throwPoolErrorIfAborted, toPlaintextStackFrameString, toVitestLikeStackFrameString };
195
- //# sourceMappingURL=debug-IeEHsxy0.mjs.map
195
+ //# sourceMappingURL=debug-Cf2jt1kg.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug-IeEHsxy0.mjs","names":[],"sources":["../src/util/test-error-formatting.ts","../src/util/pool-errors.ts","../src/util/debug.ts"],"sourcesContent":["import { stripVTControlCharacters } from 'node:util';\nimport type { RawSourceMap } from 'source-map';\nimport c from 'tinyrainbow';\nimport type { ParsedStack } from '@vitest/utils';\n\nimport { HighlightFunc } from '../types/types.js';\n\nconst FRAME_POINTER = '❯' as const;\nconst CODE_FRAME_INDENT_SPACES = 4 as const;\n\n// same performance guard used in vitest `printError`\nconst MAX_CODE_HIGHLIGHT_LENGTH = 100_000 as const;\n\nexport function getYellowString(str: string): string {\n return c.yellow(str);\n}\n\nexport function toPlaintextStackFrameString(frame: ParsedStack): string {\n return ` at ${frame.method} ${frame.file}:${frame.line}:${frame.column}`;\n}\n\nexport function toVitestLikeStackFrameString(frame: ParsedStack): string {\n return c.cyan(\n ` ${c.dim(FRAME_POINTER)} ${frame.method} ${frame.file}:${c.dim(`${frame.line}:${frame.column}`)}`\n );\n}\n\nexport function getSourceCodeFrameString(\n sourceMap: RawSourceMap,\n frame: ParsedStack,\n highlight: HighlightFunc,\n): string | undefined {\n if (!sourceMap.sourcesContent) {\n return undefined;\n }\n\n const fileIndex = sourceMap.sources.indexOf(frame.file);\n if (fileIndex < 0) {\n return undefined;\n }\n\n const source = sourceMap.sourcesContent[fileIndex];\n if (!source) {\n return undefined;\n }\n\n const highlightedSource = source.length < MAX_CODE_HIGHLIGHT_LENGTH\n ? highlight(source, { colors: c })\n : source;\n\n return generateCodeFrame(highlightedSource, CODE_FRAME_INDENT_SPACES, frame);\n}\n\n\n// ============================================================================\n// Source code formatting functions borrowed from Vitest\n// ============================================================================\n\n/**\n * Vitest doesn't expose generateCodeFrame as a util, so we have\n * recreated it here with minimal changes.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v3.2.4/packages/vitest/src/node/printError.ts#L424\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nconst lineSplitRE: RegExp = /\\r?\\n/;\n\nfunction generateCodeFrame(\n source: string,\n indent = 0,\n loc: { line: number; column: number } | number,\n range = 2,\n): string {\n const start\n = typeof loc === 'object'\n ? positionToOffset(source, loc.line, loc.column)\n : loc\n const end = start\n const lines = source.split(lineSplitRE)\n const nl = /\\r\\n/.test(source) ? 2 : 1\n let count = 0\n let res: string[] = []\n\n const columns = process.stdout?.columns || 80\n\n for (let i = 0; i < lines.length; i++) {\n count += lines[i]!.length + nl\n if (count >= start) {\n for (let j = i - range; j <= i + range || end > count; j++) {\n if (j < 0 || j >= lines.length) {\n continue\n }\n\n const lineLength = lines[j]!.length\n\n // too long, maybe it's a minified file, skip for codeframe\n if (stripVTControlCharacters(lines[j]!).length > 200) {\n return ''\n }\n\n res.push(\n lineNo(j + 1)\n + truncateString(lines[j]!.replace(/\\t/g, ' '), columns - 5 - indent),\n )\n\n if (j === i) {\n // push underline\n const pad = start - (count - lineLength) + (nl - 1)\n const length = Math.max(\n 1,\n end > count ? lineLength - pad : end - start,\n )\n res.push(lineNo() + ' '.repeat(pad) + c.red('^'.repeat(length)))\n }\n else if (j > i) {\n if (end > count) {\n const length = Math.max(1, Math.min(end - count, lineLength))\n res.push(lineNo() + c.red('^'.repeat(length)))\n }\n count += lineLength + 1\n }\n }\n break\n }\n }\n\n if (indent) {\n res = res.map(line => ' '.repeat(indent) + line)\n }\n\n return res.join('\\n')\n}\n\n\nfunction positionToOffset(\n source: string,\n lineNumber: number,\n columnNumber: number,\n): number {\n const lines = source.split(lineSplitRE)\n const nl = /\\r\\n/.test(source) ? 2 : 1\n let start = 0\n\n if (lineNumber > lines.length) {\n return source.length\n }\n\n for (let i = 0; i < lineNumber - 1; i++) {\n start += lines[i]!.length + nl\n }\n\n return start + columnNumber\n}\n\nfunction lineNo(no: number | string = '') {\n return c.gray(`${String(no).padStart(3, ' ')}| `)\n}\n\nfunction truncateString(text: string, maxLength: number): string {\n const plainText = stripVTControlCharacters(text)\n\n if (plainText.length <= maxLength) {\n return text\n }\n\n return `${plainText.slice(0, maxLength - 1)}…`\n}\n","import type { Test } from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptPoolError,\n AssemblyScriptTestError,\n PoolErrorName,\n TestErrorName\n} from '../types/types.js';\nimport {\n AS_POOL_ERROR_TYPE_FLAG,\n POOL_ERROR_NAMES,\n TEST_ERROR_NAMES\n} from '../types/constants.js';\nimport { getYellowString } from './test-error-formatting.js';\n\nexport function createPoolError(\n message: string,\n name: PoolErrorName,\n stack?: string,\n cause?: any,\n rawCallStack?: NodeJS.CallSite[],\n): AssemblyScriptPoolError {\n return { name, message, stack, cause, rawCallStack, [AS_POOL_ERROR_TYPE_FLAG]: true };\n}\n\nexport function createTestTimeoutError(\n test: Test\n): AssemblyScriptTestError {\n const message = `Test timed out after ${test.timeout}ms`;\n const err: AssemblyScriptTestError = {\n name: POOL_ERROR_NAMES.WASMExecutionTimeoutError,\n message,\n stack: `${test.id}_${message}`,\n diff: getYellowString(` Test Timeout Exceeded (${test.timeout}ms)`)\n };\n return err;\n}\n\nexport function createTestExpectedToFailError(test: Test): AssemblyScriptTestError {\n const message = `Test is expected to fail, but all assertions passed`;\n const err: AssemblyScriptTestError = {\n name: TEST_ERROR_NAMES.AssertionError,\n message,\n stack: `${test.id}_${message}`,\n diff: getYellowString(` Expected to fail, but all assertions passed`)\n };\n return err;\n}\n\nexport function throwPoolErrorIfAborted(signal?: AbortSignal): void {\n if (!signal || !signal.aborted) {\n return;\n }\n\n throw createPoolError(signal.reason, POOL_ERROR_NAMES.PoolRunAbortedError);\n}\n\nexport function isAbortErrorString(item: any): boolean {\n return item === POOL_ERROR_NAMES.PoolRunAbortedError || item === 'AbortError';\n}\n\nexport function isAbortError(error: any): boolean {\n return isAbortErrorString(error) \n || isAbortErrorString(error?.name)\n || error?.message === 'Terminating worker thread';\n}\n\nexport function createPoolErrorFromAnyError(\n context: string,\n contextErrorName: PoolErrorName,\n error: any\n): AssemblyScriptPoolError {\n const isErrorAbortString = isAbortErrorString(error);\n if (isErrorAbortString) {\n const msg = `${contextErrorName}: ${context} - Aborted, Unknown Cause`;\n return createPoolError(msg, POOL_ERROR_NAMES.PoolRunAbortedError);\n }\n\n if (error[AS_POOL_ERROR_TYPE_FLAG]) {\n return error as AssemblyScriptPoolError;\n }\n\n if (error instanceof Error) {\n const isAbortError = isAbortErrorString(error.name);\n const asErr = createPoolError(\n `${context} - ${error.name}: ${error.message}`,\n isAbortError ? POOL_ERROR_NAMES.PoolRunAbortedError : contextErrorName,\n error.stack,\n error.cause\n );\n return asErr;\n }\n\n const errorMsg = String(error);\n return createPoolError(`${context} - ${errorMsg}`, contextErrorName);\n}\n\nexport function getTestErrorFromPoolError(error: AssemblyScriptPoolError): AssemblyScriptTestError {\n const anyCause: any = error?.cause;\n if (error.causeIsEnhancedError) {\n return error.cause as AssemblyScriptTestError;\n }\n\n const message = error.message ?? anyCause.message ?? 'Unknown error';\n return {\n name: error.name ?? anyCause.name ?? POOL_ERROR_NAMES.PoolError,\n message,\n stack: anyCause?.stack ?? error.stack ?? message,\n stacks: anyCause?.stacks ,\n cause: getTestErrorFromAnyError(anyCause?.cause),\n diff: anyCause?.diff\n };\n}\n\nexport function getTestErrorFromAnyError(\n error: any,\n context: string = '',\n fallbackName: TestErrorName | PoolErrorName = POOL_ERROR_NAMES.PoolError\n): AssemblyScriptTestError | undefined {\n if (!error) {\n return undefined;\n }\n\n const message = `${context ?? ''}${error?.message ?? ''}`;\n return {\n name: error?.name ?? fallbackName,\n message,\n stack: error?.stack ?? message,\n stacks: error?.stacks,\n cause: getTestErrorFromAnyError(error?.cause)\n };\n}\n","/**\n * Debug logging utility\n */\n\ndeclare global {\n var AS_POOL_DEBUG: boolean | undefined;\n}\n\nglobalThis.AS_POOL_DEBUG = false;\n\nconst DEBUG_ENV_ENABLED_VALUE = '1' as const;\n\nfunction isEnabled(): boolean {\n return globalThis.AS_POOL_DEBUG === true || process.env.DEBUG === DEBUG_ENV_ENABLED_VALUE;\n}\n\n/**\n * Initialize debug mode for current async context (called by worker at task start)\n * @param {boolean} debugEnabled - Enable verbose debug logging\n */\nexport function setGlobalDebugMode(debugEnabled: boolean): void {\n globalThis.AS_POOL_DEBUG = debugEnabled;\n}\n\n/**\n * Log debug message (only when debug enabled in current global context)\n * or when environment has a truthy DEBUG variable set.\n */\nexport function debug(...args: any): void {\n if (isEnabled()) {\n // if first arg is a function, execute it and then print the result\n if (args?.length > 0 && typeof args[0] === 'function') {\n const result = args[0]();\n const rest = args.length > 1 ? args.slice(1) : [];\n console.log(Date.now(), String(result), ...rest);\n } else {\n console.log(Date.now(), ...args);\n }\n }\n}\n\n/**\n * Determine if debug mode is enabled for the current global context\n */\nexport function isDebugModeEnabled(): boolean {\n return isEnabled();\n}\n\nexport async function delay(ms: number = 5000): Promise<void> {\n return new Promise<void>((resolve, _reject) => {\n setTimeout(resolve, ms);\n });\n}\n"],"mappings":";;;;;AAOA,MAAM,gBAAgB;AACtB,MAAM,2BAA2B;AAGjC,MAAM,4BAA4B;AAElC,SAAgB,gBAAgB,KAAqB;AACnD,QAAO,EAAE,OAAO,IAAI;;AAGtB,SAAgB,4BAA4B,OAA4B;AACtE,QAAO,UAAU,MAAM,OAAO,GAAG,MAAM,KAAK,GAAG,MAAM,KAAK,GAAG,MAAM;;AAGrE,SAAgB,6BAA6B,OAA4B;AACvE,QAAO,EAAE,KACP,IAAI,EAAE,IAAI,cAAc,CAAC,GAAG,MAAM,OAAO,GAAG,MAAM,KAAK,GAAG,EAAE,IAAI,GAAG,MAAM,KAAK,GAAG,MAAM,SAAS,GACjG;;AAGH,SAAgB,yBACd,WACA,OACA,WACoB;AACpB,KAAI,CAAC,UAAU,eACb;CAGF,MAAM,YAAY,UAAU,QAAQ,QAAQ,MAAM,KAAK;AACvD,KAAI,YAAY,EACd;CAGF,MAAM,SAAS,UAAU,eAAe;AACxC,KAAI,CAAC,OACH;AAOF,QAAO,kBAJmB,OAAO,SAAS,4BACtC,UAAU,QAAQ,EAAE,QAAQ,GAAG,CAAC,GAChC,QAEwC,0BAA0B,MAAM;;;;;;;;;;;AAkB9E,MAAM,cAAsB;AAE5B,SAAS,kBACP,QACA,SAAS,GACT,KACA,QAAQ,GACA;CACR,MAAM,QACF,OAAO,QAAQ,WACb,iBAAiB,QAAQ,IAAI,MAAM,IAAI,OAAO,GAC9C;CACN,MAAM,MAAM;CACZ,MAAM,QAAQ,OAA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AAO,KAAK,OAAO,YAAY;EACrD,MAAM,SAAS,KAAK,IAAI;EACxB,MAAM,OAAO,KAAK,SAAS,IAAI,KAAK,MAAM,EAAE,GAAG,EAAE;AACjD,UAAQ,IAAI,KAAK,KAAK,EAAE,OAAO,OAAO,EAAE,GAAG,KAAK;OAEhD,SAAQ,IAAI,KAAK,KAAK,EAAE,GAAG,KAAK;;;;;AAQtC,SAAgB,qBAA8B;AAC5C,QAAO,WAAW"}
1
+ {"version":3,"file":"debug-Cf2jt1kg.mjs","names":[],"sources":["../src/util/test-error-formatting.ts","../src/util/pool-errors.ts","../src/util/debug.ts"],"sourcesContent":["import { stripVTControlCharacters } from 'node:util';\nimport type { RawSourceMap } from 'source-map';\nimport c from 'tinyrainbow';\nimport type { ParsedStack } from '@vitest/utils';\n\nimport { HighlightFunc } from '../types/types.js';\n\nconst FRAME_POINTER = '❯' as const;\nconst CODE_FRAME_INDENT_SPACES = 4 as const;\n\n// same performance guard used in vitest `printError`\nconst MAX_CODE_HIGHLIGHT_LENGTH = 100_000 as const;\n\nexport function getYellowString(str: string): string {\n return c.yellow(str);\n}\n\nexport function toPlaintextStackFrameString(frame: ParsedStack): string {\n return ` at ${frame.method} ${frame.file}:${frame.line}:${frame.column}`;\n}\n\nexport function toVitestLikeStackFrameString(frame: ParsedStack): string {\n return c.cyan(\n ` ${c.dim(FRAME_POINTER)} ${frame.method} ${frame.file}:${c.dim(`${frame.line}:${frame.column}`)}`\n );\n}\n\nexport function getSourceCodeFrameString(\n sourceMap: RawSourceMap,\n frame: ParsedStack,\n highlight: HighlightFunc,\n): string | undefined {\n if (!sourceMap.sourcesContent) {\n return undefined;\n }\n\n const fileIndex = sourceMap.sources.indexOf(frame.file);\n if (fileIndex < 0) {\n return undefined;\n }\n\n const source = sourceMap.sourcesContent[fileIndex];\n if (!source) {\n return undefined;\n }\n\n const highlightedSource = source.length < MAX_CODE_HIGHLIGHT_LENGTH\n ? highlight(source, { colors: c })\n : source;\n\n return generateCodeFrame(highlightedSource, CODE_FRAME_INDENT_SPACES, frame);\n}\n\n\n// ============================================================================\n// Source code formatting functions borrowed from Vitest\n// ============================================================================\n\n/**\n * Vitest doesn't expose generateCodeFrame as a util, so we have\n * recreated it here with minimal changes.\n * \n * @see https://github.com/vitest-dev/vitest/blob/v3.2.4/packages/vitest/src/node/printError.ts#L424\n * \n * Vitest is released under the MIT license, included in this project's root.\n * Copyright (c) 2021-Present Vitest Team\n */\n\nconst lineSplitRE: RegExp = /\\r?\\n/;\n\nfunction generateCodeFrame(\n source: string,\n indent = 0,\n loc: { line: number; column: number } | number,\n range = 2,\n): string {\n const start\n = typeof loc === 'object'\n ? positionToOffset(source, loc.line, loc.column)\n : loc\n const end = start\n const lines = source.split(lineSplitRE)\n const nl = /\\r\\n/.test(source) ? 2 : 1\n let count = 0\n let res: string[] = []\n\n const columns = process.stdout?.columns || 80\n\n for (let i = 0; i < lines.length; i++) {\n count += lines[i]!.length + nl\n if (count >= start) {\n for (let j = i - range; j <= i + range || end > count; j++) {\n if (j < 0 || j >= lines.length) {\n continue\n }\n\n const lineLength = lines[j]!.length\n\n // too long, maybe it's a minified file, skip for codeframe\n if (stripVTControlCharacters(lines[j]!).length > 200) {\n return ''\n }\n\n res.push(\n lineNo(j + 1)\n + truncateString(lines[j]!.replace(/\\t/g, ' '), columns - 5 - indent),\n )\n\n if (j === i) {\n // push underline\n const pad = start - (count - lineLength) + (nl - 1)\n const length = Math.max(\n 1,\n end > count ? lineLength - pad : end - start,\n )\n res.push(lineNo() + ' '.repeat(pad) + c.red('^'.repeat(length)))\n }\n else if (j > i) {\n if (end > count) {\n const length = Math.max(1, Math.min(end - count, lineLength))\n res.push(lineNo() + c.red('^'.repeat(length)))\n }\n count += lineLength + 1\n }\n }\n break\n }\n }\n\n if (indent) {\n res = res.map(line => ' '.repeat(indent) + line)\n }\n\n return res.join('\\n')\n}\n\n\nfunction positionToOffset(\n source: string,\n lineNumber: number,\n columnNumber: number,\n): number {\n const lines = source.split(lineSplitRE)\n const nl = /\\r\\n/.test(source) ? 2 : 1\n let start = 0\n\n if (lineNumber > lines.length) {\n return source.length\n }\n\n for (let i = 0; i < lineNumber - 1; i++) {\n start += lines[i]!.length + nl\n }\n\n return start + columnNumber\n}\n\nfunction lineNo(no: number | string = '') {\n return c.gray(`${String(no).padStart(3, ' ')}| `)\n}\n\nfunction truncateString(text: string, maxLength: number): string {\n const plainText = stripVTControlCharacters(text)\n\n if (plainText.length <= maxLength) {\n return text\n }\n\n return `${plainText.slice(0, maxLength - 1)}…`\n}\n","import type { Test } from '@vitest/runner/types';\n\nimport type {\n AssemblyScriptPoolError,\n AssemblyScriptTestError,\n PoolErrorName,\n TestErrorName\n} from '../types/types.js';\nimport {\n AS_POOL_ERROR_TYPE_FLAG,\n POOL_ERROR_NAMES,\n TEST_ERROR_NAMES\n} from '../types/constants.js';\nimport { getYellowString } from './test-error-formatting.js';\n\nexport function createPoolError(\n message: string,\n name: PoolErrorName,\n stack?: string,\n cause?: any,\n rawCallStack?: NodeJS.CallSite[],\n): AssemblyScriptPoolError {\n return { name, message, stack, cause, rawCallStack, [AS_POOL_ERROR_TYPE_FLAG]: true };\n}\n\nexport function createTestTimeoutError(\n test: Test\n): AssemblyScriptTestError {\n const message = `Test timed out after ${test.timeout}ms`;\n const err: AssemblyScriptTestError = {\n name: POOL_ERROR_NAMES.WASMExecutionTimeoutError,\n message,\n stack: `${test.id}_${message}`,\n diff: getYellowString(` Test Timeout Exceeded (${test.timeout}ms)`)\n };\n return err;\n}\n\nexport function createTestExpectedToFailError(test: Test): AssemblyScriptTestError {\n const message = `Test is expected to fail, but all assertions passed`;\n const err: AssemblyScriptTestError = {\n name: TEST_ERROR_NAMES.AssertionError,\n message,\n stack: `${test.id}_${message}`,\n diff: getYellowString(` Expected to fail, but all assertions passed`)\n };\n return err;\n}\n\nexport function throwPoolErrorIfAborted(signal?: AbortSignal): void {\n if (!signal || !signal.aborted) {\n return;\n }\n\n throw createPoolError(signal.reason, POOL_ERROR_NAMES.PoolRunAbortedError);\n}\n\nexport function isAbortErrorString(item: any): boolean {\n return item === POOL_ERROR_NAMES.PoolRunAbortedError || item === 'AbortError';\n}\n\nexport function isAbortError(error: any): boolean {\n return isAbortErrorString(error) \n || isAbortErrorString(error?.name)\n || error?.message === 'Terminating worker thread';\n}\n\nexport function createPoolErrorFromAnyError(\n context: string,\n contextErrorName: PoolErrorName,\n error: any\n): AssemblyScriptPoolError {\n const isErrorAbortString = isAbortErrorString(error);\n if (isErrorAbortString) {\n const msg = `${contextErrorName}: ${context} - Aborted, Unknown Cause`;\n return createPoolError(msg, POOL_ERROR_NAMES.PoolRunAbortedError);\n }\n\n if (error[AS_POOL_ERROR_TYPE_FLAG]) {\n return error as AssemblyScriptPoolError;\n }\n\n if (error instanceof Error) {\n const isAbortError = isAbortErrorString(error.name);\n const asErr = createPoolError(\n `${context} - ${error.name}: ${error.message}`,\n isAbortError ? POOL_ERROR_NAMES.PoolRunAbortedError : contextErrorName,\n error.stack,\n error.cause\n );\n return asErr;\n }\n\n const errorMsg = String(error);\n return createPoolError(`${context} - ${errorMsg}`, contextErrorName);\n}\n\nexport function getTestErrorFromPoolError(error: AssemblyScriptPoolError): AssemblyScriptTestError {\n const anyCause: any = error?.cause;\n if (error.causeIsEnhancedError) {\n return error.cause as AssemblyScriptTestError;\n }\n\n const message = error.message ?? anyCause.message ?? 'Unknown error';\n return {\n name: error.name ?? anyCause.name ?? POOL_ERROR_NAMES.PoolError,\n message,\n stack: anyCause?.stack ?? error.stack ?? message,\n stacks: anyCause?.stacks ,\n cause: getTestErrorFromAnyError(anyCause?.cause),\n diff: anyCause?.diff\n };\n}\n\nexport function getTestErrorFromAnyError(\n error: any,\n context: string = '',\n fallbackName: TestErrorName | PoolErrorName = POOL_ERROR_NAMES.PoolError\n): AssemblyScriptTestError | undefined {\n if (!error) {\n return undefined;\n }\n\n const message = `${context ?? ''}${error?.message ?? ''}`;\n return {\n name: error?.name ?? fallbackName,\n message,\n stack: error?.stack ?? message,\n stacks: error?.stacks,\n cause: getTestErrorFromAnyError(error?.cause)\n };\n}\n","/**\n * Debug logging utility\n */\n\ndeclare global {\n var AS_POOL_DEBUG: boolean | undefined;\n}\n\nglobalThis.AS_POOL_DEBUG = false;\n\nconst DEBUG_ENV_ENABLED_VALUE = '1' as const;\n\nfunction isEnabled(): boolean {\n return globalThis.AS_POOL_DEBUG === true || process.env.DEBUG === DEBUG_ENV_ENABLED_VALUE;\n}\n\n/**\n * Initialize debug mode for current async context (called by worker at task start)\n * @param {boolean} debugEnabled - Enable verbose debug logging\n */\nexport function setGlobalDebugMode(debugEnabled: boolean): void {\n globalThis.AS_POOL_DEBUG = debugEnabled;\n}\n\n/**\n * Log debug message (only when debug enabled in current global context)\n * or when environment has a truthy DEBUG variable set.\n */\nexport function debug(...args: any): void {\n if (isEnabled()) {\n // if first arg is a function, execute it and then print the result\n if (args?.length > 0 && typeof args[0] === 'function') {\n const result = args[0]();\n const rest = args.length > 1 ? args.slice(1) : [];\n console.log(Date.now(), String(result), ...rest);\n } else {\n console.log(Date.now(), ...args);\n }\n }\n}\n\n/**\n * Determine if debug mode is enabled for the current global context\n */\nexport function isDebugModeEnabled(): boolean {\n return isEnabled();\n}\n\nexport async function delay(ms: number = 5000): Promise<void> {\n return new Promise<void>((resolve, _reject) => {\n setTimeout(resolve, ms);\n });\n}\n"],"mappings":";;;;;AAOA,MAAM,gBAAgB;AACtB,MAAM,2BAA2B;AAGjC,MAAM,4BAA4B;AAElC,SAAgB,gBAAgB,KAAqB;AACnD,QAAO,EAAE,OAAO,IAAI;;AAGtB,SAAgB,4BAA4B,OAA4B;AACtE,QAAO,UAAU,MAAM,OAAO,GAAG,MAAM,KAAK,GAAG,MAAM,KAAK,GAAG,MAAM;;AAGrE,SAAgB,6BAA6B,OAA4B;AACvE,QAAO,EAAE,KACP,IAAI,EAAE,IAAI,cAAc,CAAC,GAAG,MAAM,OAAO,GAAG,MAAM,KAAK,GAAG,EAAE,IAAI,GAAG,MAAM,KA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EACjB;;AAGH,SAAgB,yBACd,OACA,UAAkB,IAClB,eAA8C,iBAAiB,WAC1B;AACrC,KAAI,CAAC,MACH;CAGF,MAAM,UAAU,GAAG,WAAW,KAAK,OAAO,WAAW;AACrD,QAAO;EACL,MAAM,OAAO,QAAQ;EACrB;EACA,OAAO,OAAO,SAAS;EACvB,QAAQ,OAAO;EACf,OAAO,yBAAyB,OAAO,MAAM;EAC9C;;;;;AC1HH,WAAW,gBAAgB;AAE3B,MAAM,0BAA0B;AAEhC,SAAS,YAAqB;AAC5B,QAAO,WAAW,kBAAkB,QAAQ,QAAQ,IAAI,UAAU;;;;;;AAOpE,SAAgB,mBAAmB,cAA6B;AAC9D,YAAW,gBAAgB;;;;;;AAO7B,SAAgB,MAAM,GAAG,MAAiB;AACxC,KAAI,WAAW,CAEb,KAAI,MAAM,SAAS,KAAK,OAAO,KAAK,OAAO,YAAY;EACrD,MAAM,SAAS,KAAK,IAAI;EACxB,MAAM,OAAO,KAAK,SAAS,IAAI,KAAK,MAAM,EAAE,GAAG,EAAE;AACjD,UAAQ,IAAI,KAAK,KAAK,EAAE,OAAO,OAAO,EAAE,GAAG,KAAK;OAEhD,SAAQ,IAAI,KAAK,KAAK,EAAE,GAAG,KAAK;;;;;AAQtC,SAAgB,qBAA8B;AAC5C,QAAO,WAAW"}
@@ -1,4 +1,5 @@
1
- import "./debug-IeEHsxy0.mjs";
2
- import { compileAssemblyScript } from "./compiler-CN6BRK_N.mjs";
1
+ import "./constants-DX9yo-el.mjs";
2
+ import "./debug-Cf2jt1kg.mjs";
3
+ import { compileAssemblyScript } from "./compiler-BaNECXMW.mjs";
3
4
 
4
5
  export { compileAssemblyScript };
package/dist/index-v3.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { POOL_ERROR_NAMES } from "./constants-CA50WBdr.mjs";
2
- import { getProjectSerializedOrGlobalConfig, resolvePoolOptions } from "./resolve-config-as1w-Qyz.mjs";
3
- import { createPoolErrorFromAnyError, debug, isAbortError, setGlobalDebugMode } from "./debug-IeEHsxy0.mjs";
1
+ import { POOL_ERROR_NAMES } from "./constants-DX9yo-el.mjs";
2
+ import { getProjectSerializedOrGlobalConfig, resolvePoolOptions } from "./resolve-config-BKjJQyy5.mjs";
3
+ import { createPoolErrorFromAnyError, debug, isAbortError, setGlobalDebugMode } from "./debug-Cf2jt1kg.mjs";
4
4
  import { createInitialFileTask } from "./vitest-file-tasks-BUwzh375.mjs";
5
- import { failTestWithTimeoutError, flagTestTerminated } from "./vitest-tasks-BKS7689f.mjs";
5
+ import { failTestWithTimeoutError, flagTestTerminated } from "./vitest-tasks-Cbri6MWZ.mjs";
6
6
  import { createWorkerRPCChannel } from "./worker-rpc-channel-lbhK7Qz8.mjs";
7
7
  import { basename, resolve } from "node:path";
8
8
  import { access } from "node:fs/promises";
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
- import "./resolve-config-as1w-Qyz.mjs";
2
- import "./debug-IeEHsxy0.mjs";
1
+ import "./constants-DX9yo-el.mjs";
2
+ import "./resolve-config-BKjJQyy5.mjs";
3
+ import "./debug-Cf2jt1kg.mjs";
3
4
  import "./vitest-file-tasks-BUwzh375.mjs";
4
- import "./vitest-tasks-BKS7689f.mjs";
5
+ import "./vitest-tasks-Cbri6MWZ.mjs";
5
6
  import "./worker-rpc-channel-lbhK7Qz8.mjs";
6
- import { createAssemblyScriptPool } from "./pool-runner-init-Kuzz61rB.mjs";
7
+ import { createAssemblyScriptPool } from "./pool-runner-init-Cdpz_B-F.mjs";
7
8
 
8
9
  export { createAssemblyScriptPool };
@@ -1,6 +1,6 @@
1
- import { COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES, POOL_INTERNAL_PATHS, TEST_ERROR_NAMES } from "./constants-CA50WBdr.mjs";
2
- import { createPoolError, createPoolErrorFromAnyError, debug, getSourceCodeFrameString, isDebugModeEnabled, toPlaintextStackFrameString, toVitestLikeStackFrameString } from "./debug-IeEHsxy0.mjs";
3
- import { createAfterSuiteRunMeta, createSuiteTask, createTestTask, createWebAssemblyCallSite, extractCallStack, failTest, getTaskLogLabel, isSuiteOwnFile, parseSourceMap } from "./vitest-tasks-BKS7689f.mjs";
1
+ import { COVERAGE_PAYLOAD_FORMATS, POOL_ERROR_NAMES, POOL_INTERNAL_PATHS, TEST_ERROR_NAMES } from "./constants-DX9yo-el.mjs";
2
+ import { createPoolError, createPoolErrorFromAnyError, debug, getSourceCodeFrameString, isDebugModeEnabled, toPlaintextStackFrameString, toVitestLikeStackFrameString } from "./debug-Cf2jt1kg.mjs";
3
+ import { createAfterSuiteRunMeta, createSuiteTask, createTestTask, createWebAssemblyCallSite, extractCallStack, failTest, getTaskLogLabel, isSuiteOwnFile, parseSourceMap } from "./vitest-tasks-Cbri6MWZ.mjs";
4
4
  import { basename, resolve } from "node:path";
5
5
  import { createBirpc } from "birpc";
6
6
  import { diff } from "@vitest/utils/diff";
@@ -799,4 +799,4 @@ async function loadUserWasmImportsFactory(relativePath, projectRoot, logModule)
799
799
 
800
800
  //#endregion
801
801
  export { createRpcClient, executeWASMDiscovery, executeWASMTest, flushRpcUpdates, loadUserWasmImportsFactory, reportFileCollected, reportFileError, reportFileQueued, reportSuiteFinished, reportSuitePrepare, reportTestFinished, reportTestPrepare, reportTestRetried, reportUserConsoleLogs };
802
- //# sourceMappingURL=load-user-imports-Bbmpaciu.mjs.map
802
+ //# sourceMappingURL=load-user-imports-CcIdE4_0.mjs.map