Documentation
¶
Overview ¶
Package hybrid exposes the read-only analysis side of Ramune's TS→Go hybrid transpiler.
The picker inside Ramune decides which top-level TypeScript declarations are "type-confirmed enough" to be lifted into native Go code at compile time. Analyze reports those decisions for a single worker source (with its imported helpers) so wrappers and platforms built on top of Ramune — notably openworkers — can surface extraction coverage without reimplementing tsgo plumbing.
This package does NOT emit Go code; for that, use `ramune compile --hybrid`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct {
// Name is the identifier as declared in TypeScript.
Name string
// Kind is Function / Class / Interface.
Kind Kind
// Extracted is true when the picker accepted this declaration
// for extraction into native Go. False means the declaration
// stays JS-side.
Extracted bool
// Reason is populated when Extracted is false.
Reason Reason
}
Candidate is one top-level declaration the picker considered.
type Kind ¶
type Kind int
Kind distinguishes extractable declaration kinds.
const ( // KindFunction is a top-level function declaration. KindFunction Kind = iota + 1 // KindClass is a top-level class declaration. KindClass // KindInterface is a top-level interface declaration. Interfaces // never extract to runtime Go; they inform type-confirmation but // are emitted as comments. KindInterface )
type Reason ¶
type Reason struct {
// Code is a stable, grep-friendly identifier such as
// "reasonGenericFunc" or "reasonClosureCapture".
Code string
// Detail is a human-readable description.
Detail string
}
Reason explains why a Candidate was rejected by the picker. The zero value indicates acceptance.
type Report ¶
type Report struct {
// Filename that was analyzed.
Filename string
// Candidates in source order, spanning every user file reachable
// from Filename (the entry plus its direct and transitive
// imports, excluding node_modules and .d.ts).
Candidates []Candidate
}
Report aggregates every candidate the picker considered while analyzing a worker.
func Analyze ¶
Analyze runs the picker over the worker source at filename (and its user-reachable imports) and returns the aggregated report.
filename must be a path to a .ts / .tsx / .mts / .js / .mjs file; the composer walks the import graph internally. Analyze does NOT write Go source to disk.
func (*Report) ExtractedNames ¶
ExtractedNames returns the names of accepted candidates in source order.