nativepackage

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package nativepackage owns cached type information derived from native target-language packages. The cache is generated by trb install and keeps native declaration parsing out of ordinary compiler and language-service requests.

Index

Constants

View Source
const (
	// FormatVersion belongs only to the generated TypeScript native type cache.
	// Package-owned declaration adapters use their independent protocol version.
	FormatVersion = 4
)

Variables

This section is empty.

Functions

func ApplyDeclarationAdapterFiles added in v0.3.16

func ApplyDeclarationAdapterFiles(catalog *Catalog, sources []declarationadapterhost.Source) error

ApplyDeclarationAdapterFiles overlays package-owned semantic declarations on top of declarations inferred by the TypeScript adapter from .d.ts files. The extension host validates the shared data protocol; this adapter validates the remaining TypeScript-specific bridge kinds and dependency ownership.

func IndexPath

func IndexPath(root string) string

func Write

func Write(root string, catalog *Catalog) error

Types

type Catalog

type Catalog struct {
	FormatVersion               int               `json:"formatVersion"`
	TypeScriptVersion           string            `json:"typescriptVersion,omitempty"`
	Dependencies                map[string]string `json:"dependencies"`
	DeclarationAdapterChecksums map[string]string `json:"declarationAdapterChecksums,omitempty"`
	Modules                     map[string]Module `json:"modules"`
	UnavailableReason           string            `json:"-"`
}

func Empty

func Empty(dependencies map[string]string) *Catalog

func Generate

func Generate(root, packageManager string, dependencies map[string]string) (*Catalog, error)

func GenerateModules

func GenerateModules(root, packageManager string, dependencies map[string]string, requestedModules []string) (*Catalog, error)

func Load

func Load(root string, dependencies map[string]string) (*Catalog, error)

func LoadWithDeclarationAdapters added in v0.3.16

func LoadWithDeclarationAdapters(root string, dependencies map[string]string, adapters []declarationadapterhost.Source) (*Catalog, error)

func (*Catalog) Module

func (c *Catalog) Module(importPath string) (Module, bool)

func (*Catalog) Owns

func (c *Catalog) Owns(importPath string) bool

type Export

type Export struct {
	Kind              string            `json:"kind"`
	Type              Type              `json:"type"`
	AliasTarget       *Type             `json:"aliasTarget,omitempty"`
	Parameters        []Type            `json:"parameters,omitempty"`
	Required          int               `json:"required,omitempty"`
	Variadic          bool              `json:"variadic,omitempty"`
	TypeParameters    []string          `json:"typeParameters,omitempty"`
	Fields            []Field           `json:"fields,omitempty"`
	Members           map[string]Export `json:"members,omitempty"`
	InstanceMembers   map[string]Export `json:"instanceMembers,omitempty"`
	ClassMembers      map[string]Export `json:"classMembers,omitempty"`
	UnsupportedFields map[string]string `json:"unsupportedFields,omitempty"`
}

type Field

type Field struct {
	Name     string `json:"name"`
	Type     Type   `json:"type"`
	Optional bool   `json:"optional,omitempty"`
}

type Module

type Module struct {
	Exports     map[string]Export `json:"exports"`
	Records     map[string]Export `json:"records,omitempty"`
	Unsupported map[string]string `json:"unsupported,omitempty"`
}

type ResultBridge added in v0.3.0

type ResultBridge struct {
	Kind  string `json:"kind"`
	Error Type   `json:"error"`
}

ResultBridge describes a native callback boundary that resolves its success value through a Promise and rejects with the standard Result error payload.

type Type

type Type struct {
	Kind         string        `json:"kind"`
	Name         string        `json:"name,omitempty"`
	Args         []Type        `json:"args,omitempty"`
	ResultBridge *ResultBridge `json:"resultBridge,omitempty"`
	Nullable     bool          `json:"nullable,omitempty"`
	Readonly     bool          `json:"readonly,omitempty"`
}

Type is the stable on-disk form of a target-independent semantic type.

func FromSemantic

func FromSemantic(typ types.Type) Type

func (Type) Semantic

func (t Type) Semantic() types.Type

Jump to

Keyboard shortcuts

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