annotator

package
v0.5.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Annotate

func Annotate(prog *ast.Program, cfg *config.Config, sourceFile string, rawSource string) *irtree.Annotations

Annotate performs static analysis on a parsed program to determine component tiers, signal declarations, streaming mode, and used components.

func BuildImportAliases added in v0.4.0

func BuildImportAliases(modules []ModuleSource) map[string]string

BuildImportAliases returns a map from import local binding to the declared function name it resolves to across the given modules. Default imports map to their module's default export; named imports map to the exported name (which equals the declared name for function declarations). Unresolvable bindings (namespace imports, re-exports, non-function exports) are skipped.

func FindDefaultExport added in v0.4.0

func FindDefaultExport(body []ast.Stmt) string

FindDefaultExport returns the identifier a program's default export resolves to: the declared name for `export default function Foo()`, or the local name for `export default Foo`. It returns "" when the default export is anonymous or unbound.

func MergeImportAliases added in v0.4.0

func MergeImportAliases(ann *irtree.Annotations, modules []ModuleSource, entry ModuleSource)

MergeImportAliases makes imported components resolvable under their local binding names. Bundled modules' function declarations are merged into one map keyed by declared name, so without aliasing a renamed import - e.g. `import FooLayout from "./theme/layout"` where the theme declares `export default function NightLayout` - renders nothing: `<FooLayout>` has no matching entry. Aliasing each import local to the function it actually resolves to fixes that, so page/theme authors can name exports freely. entry is the page's own module (its imports are the ones that matter most).

func MergeModuleFunctions

func MergeModuleFunctions(ann *irtree.Annotations, modules []ModuleSource)

MergeModuleFunctions collects function declarations from additional bundled modules and merges them into the annotations. Imported components (e.g. DocsLayout, SidebarNav) live in separate bundled modules that the entry module's AST doesn't contain. Each module's own source path/raw text is recorded so tier classification for imported components uses their own file conventions (e.g. *.runtime.tsx).

func ReclassifyTiers

func ReclassifyTiers(ann *irtree.Annotations, cfg *config.Config)

ReclassifyTiers re-runs tier classification for all used components. Call after MergeModuleFunctions so newly discovered components get classified against their own module sources.

Types

type ModuleSource

type ModuleSource struct {
	Program   *ast.Program
	Path      string
	RawSource string
}

ModuleSource carries a bundled module's program plus its source file path and raw text so imported components can be tier-classified against their own file.

Jump to

Keyboard shortcuts

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