Metastatic.Adapters.JavaScript (Metastatic v0.24.1)

View Source

JavaScript/TypeScript language adapter for MetaAST transformations.

Converts JS/TS source directly into MetaAST 3-tuples using regex-based line-by-line scanning. This is a BEAM-native adapter that does NOT require a subprocess or external parser.

M1 Representation

The "native AST" (M1) for this adapter IS the MetaAST itself — we perform a single-pass translation directly from source text to MetaAST rather than going through an intermediate language-specific AST. This means parse/1 returns the MetaAST tuple and to_meta/1 is an identity pass.

MetaAST Nodes Produced

  • {:container, meta, children} — ES6 classes and the file-level module
  • {:function_def, meta, body}function declarations, arrow functions, class methods, and object-literal methods
  • {:function_call, meta, args} — call expressions found on each line
  • {:import, meta, []}import … from and require(…) statements
  • {:param, meta, name} — function parameters

Limitations

  • Read-only adapter (analysis only, no code generation)
  • Computed / anonymous method names are skipped
  • TypeScript type annotations are stripped (parameter count preserved)
  • Generic/template types are ignored
  • Complex destructured parameter lists use param-count approximation

Summary

Functions

Not implemented — this adapter is read-only (analysis only).

Parse JS/TS source into a MetaAST (the M1 representation for this adapter).

Identity pass — M1 is the MetaAST for this adapter. Returns {:ok, meta_ast, %{}}.

Not implemented — this adapter is read-only (analysis only).

Functions

from_meta(meta_ast, metadata)

Not implemented — this adapter is read-only (analysis only).

parse(source)

Parse JS/TS source into a MetaAST (the M1 representation for this adapter).

to_meta(meta_ast)

Identity pass — M1 is the MetaAST for this adapter. Returns {:ok, meta_ast, %{}}.

unparse(native_ast)

Not implemented — this adapter is read-only (analysis only).