Help us shape the future of Go! Take the 2026 Go Developer Survey

jsruleset

package
v0.35.3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package jsruleset prepares local JavaScript rulesets for vacuum's rule engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsModule

func IsModule(path string) bool

IsModule reports supported executable entry extensions.

Types

type File

type File struct {
	Path   string
	SHA256 string
}

File records the exact bytes used when preparing a module graph.

type Prepared

type Prepared struct {
	// contains filtered or unexported fields
}

Prepared owns immutable compiled code and normalized rule data. It is safe to share across documents; each execution must open its own Scope.

func Prepare

func Prepare(ctx context.Context, entry string) (*Prepared, error)

Prepare compiles a local module graph without installing packages or loading remote code. Initialization and export inspection have a five-second limit.

func PrepareWithReader

func PrepareWithReader(ctx context.Context, entry string, readFile func(string) ([]byte, error)) (*Prepared, error)

PrepareWithReader compiles modules using the supplied reader for every captured file.

func (*Prepared) Data

func (p *Prepared) Data() []byte

Data returns the normalized declarative ruleset, with stable callable handles.

func (*Prepared) Files

func (p *Prepared) Files() []File

Files returns the local module and resolution metadata identities.

func (*Prepared) Functions

func (p *Prepared) Functions() map[string]model.RuleFunction

Functions returns validation-only callable adapters for a prepared ruleset.

func (*Prepared) Open

func (p *Prepared) Open(ctx context.Context, fetchConfig *config.FetchConfig) (*Scope, error)

Open initializes a fresh module instance and checks its exported contract against preparation. Module initialization must be deterministic.

type Scope

type Scope struct {
	// contains filtered or unexported fields
}

Scope owns one module instance and serializes JavaScript calls for a document. Close cancels pending work and waits for the VM owner before releasing it.

func (*Scope) Close

func (s *Scope) Close()

Close stops work owned by this scope. It is safe to call more than once.

func (*Scope) Functions

func (s *Scope) Functions() map[string]model.RuleFunction

Functions returns adapters bound to this document scope.

func (*Scope) MatchFormats

func (s *Scope) MatchFormats(ctx context.Context, data any, source string) (map[string]bool, error)

MatchFormats evaluates callable predicates against the original document once.

func (*Scope) SetNativeFunctions

func (s *Scope) SetNativeFunctions(functions map[string]model.RuleFunction)

SetNativeFunctions binds existing engine functions before document execution.

Jump to

Keyboard shortcuts

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