hybrid

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 2 Imported by: 0

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
)

func (Kind) String

func (k Kind) String() string

String returns the lowercase declaration keyword.

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

func Analyze(filename string) (*Report, error)

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

func (r *Report) ExtractedNames() []string

ExtractedNames returns the names of accepted candidates in source order.

func (*Report) Stats

func (r *Report) Stats() (accepted, rejected, total int)

Stats returns (accepted, rejected, total) candidate counts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL