runtime

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package runtime はページで使用する交換可能なGo実行環境を定義する。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine added in v0.13.0

type Engine string

Engine はPage Scriptを評価する実行エンジンを識別する。

const (
	EngineGo         Engine = "go"
	EngineJavaScript Engine = "javascript"
)

func NormalizeEngine added in v0.13.0

func NormalizeEngine(engine Engine) Engine

NormalizeEngine は既存呼び出しのzero valueをGoとして扱う。

func (Engine) Valid added in v0.13.0

func (engine Engine) Valid() bool

Valid はGrowseが選択可能なEngineかを返す。

type EngineFactory added in v0.13.0

type EngineFactory func(Engine) Runtime

EngineFactory は選択Engineに対応する独立したRuntimeを生成する。

func ForGo added in v0.13.0

func ForGo(factory Factory) EngineFactory

ForGo は既存のGo専用Factoryを言語選択可能なFactoryへ変換する。 JavaScriptを要求された場合はnilを返し、暗黙にGoへfallbackしない。

type Environment

type Environment struct {
	Document        *dom.Document
	Events          *events.Dispatcher
	BaseURL         *url.URL
	Fetch           func(context.Context, *network.Request) (*network.Response, error)
	FetchLimiter    *fetchapi.Limiter
	Navigate        func(*url.URL) error
	HistoryPush     func(string, *url.URL) error
	HistoryReplace  func(string, *url.URL) error
	HistoryTraverse func(int) error
	HistoryInfo     func() (int, string)
	LocalStorage    *storagecore.Area
	SessionStorage  *storagecore.Area
	StorageSource   storagecore.MutationSource
	OnMutation      func()
	RequestFrame    func()
	FrameScope      func(time.Time, func())
	ConsoleLog      func(message string)
	ConsoleRecord   func(level, message string)
}

Environment はRuntimeへ公開するページの状態を保持する。

type Factory

type Factory func() Runtime

Factory はページごとに独立したRuntimeを生成する。

type LocationUpdater added in v0.9.0

type LocationUpdater interface {
	UpdateLocation(*url.URL)
}

LocationUpdater はsame-document Navigationを現在Runtimeへ通知する。

type NavigationEventDispatcher interface {
	DispatchPopState(state string)
	DispatchHashChange(oldURL, newURL string)
}

NavigationEventDispatcher はNavigation Eventを現在Runtimeへ配送する。

type Runtime

type Runtime interface {
	Load(ctx context.Context, scripts []Script, environment Environment) error
	Start(ctx context.Context) error
	Stop() error
}

Runtime は1ページに属するGoスクリプトを実行する。

type Script

type Script struct {
	Engine    Engine
	SourceURL *url.URL
	Source    string
	Inline    bool
}

Script は文書内で見つかった1つの実行ソースを表す。

Directories

Path Synopsis
Package javascript implements the page-scoped Growse JavaScript Runtime.
Package javascript implements the page-scoped Growse JavaScript Runtime.
Package yaegi はYaegiを使ったGrowseページのRuntimeを実装する。
Package yaegi はYaegiを使ったGrowseページのRuntimeを実装する。

Jump to

Keyboard shortcuts

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