interop

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 11 Imported by: 0

README

GWC | Interop Library

GoWebComponents (GWC)

High-Level Overview

The interop library bridges Go values with JavaScript host capabilities and environment-specific adapters.

Start Here

Use interop when you need:

  • browser globals like window, document, history, or location
  • storage, timers, clipboard, and DOM observation
  • workers, message channels, cross-tab channels, or popup-window channels
  • typed encode/decode helpers around browser message payloads

Recommended reading order:

  1. ../README.md
  2. ../docs/REFERENCE_MANUAL/10-browser-interop-and-workers.md when the task is worker-related
  3. ../examples/README.md for runnable browser-interop examples

If you are only looking for the public surface, the summary above is the entry point. The exhaustive API inventory below is reference material, not the best first-read onboarding path.

Public APIs

github.com/monstercameron/GoWebComponents/interop (package interop)
  • Functions: AsError, Assign, Back, Backend, Blur, Bool, BoundingClientRect, Call, CallDefault, Cancel, ClassName, Clear, Click, ClientCanExchange, ClientProtocolCompatible, ClientSupportsEncoding, ClientSupportsTopic, Close, Closed, CodeOf, CurrentDocument, Decode, DecodeClientMessage, DecodeCrossTabEnvelope, DecodeCustomEvent, DecodeJSON, DecodeMessagePortMessage, DecodeSurfaceSignal, DecodeWindowEnvelope, DecodeWorkerMessage, Delete, Dispatch, Dispose, ElementByID, ElementsByID, Error, Events, Float, Focus, Forward, Get, GetClipboard, GetDocument, GetDocumentEvents, GetGlobalThis, GetItem, GetLocalStorage, GetMany, GetMediaQuery, GetSessionStorage, GetWindowEnv, GetWindowEvents, GetWindowHistory, GetWindowLocation, GetWorkerScope, GlobalThis, Go, Hash, Href, ID, ImportModule, Int, Invoke, IsCode, IsNull, IsUndefined, Key, Keys, Len, Listen, LoadPersistentJSON, LocalStorage, Lookup, LookupString, Matches, Media, Message, Name, NavigatorClipboard, NewGoWASMWorker, ObserveIntersection, ObserveResize, OpenCrossTabChannel, OpenGoWASMWorker, OpenMessageChannel, OpenPersistentStore, OpenSecondaryWindowChannel, OpenWindowOpenerChannel, OpenWorker, Origin, Pathname, Port1, Port2, Post, PostPorts, Present, Progress, Publish, PublishClientBinaryCrossTab, PublishClientBinaryWindow, PublishClientEvent, PublishClientGoodbye, PublishClientGoodbyeWindow, PublishClientHello, PublishClientHelloWindow, PublishClientHelloWindowWithCapabilities, PublishClientHelloWithCapabilities, PublishClientIntent, PublishClientInvalidation, PublishClientMessage, PublishClientQuery, PublishClientResult, PublishClientWindowMessage, PublishIntent, PublishLogout, PublishRouteFocus, PublishSelection, PublishSessionExpired, PublishSurfaceSignal, PushState, QuerySelector, ReadText, Ready, Reload, RemoveItem, Replace, ReplaceState, Request, RequestWorkerDecoded, Restart, Result, ScheduleInterval, ScheduleTimeout, ScrollIntoView, ScrollMetrics, Search, SessionStorage, Set, SetFunction, SetInterval, SetItem, SetJSON, SetScrollTop, SetTimeout, SharedWindowEnv, State, String, Subscribe, SubscribeClientMessages, SubscribeClientWindowMessages, SubscribeDecoded, SubscribeDecodedCrossTab, SubscribeDecodedMessagePort, SubscribeDecodedWindow, SubscribeDecodedWorker, SubscribeSurfaceSignals, TagName, TargetOrigin, Terminate, ToGo, Transport, Truthy, Unwrap, Value, WriteText
  • Types: BrowserEvent, ClientBinaryPayload, ClientCapabilities, ClientIdentity, ClientMessage, ClientMessageKind, ClientPayloadEncoding, Clipboard, CrossTabChannel, CrossTabChannelOptions, CrossTabEnvelope, CustomEvent, DecodedCrossTabEnvelope, DecodedCustomEvent, DecodedMessagePortMessage, DecodedWindowEnvelope, DecodedWorkerMessage, Document, Element, Error, ErrorCode, EventTarget, GoWASMWorkerOptions, History, IntersectionEntry, IntersectionObserverOptions, Location, MediaQueryEvent, MediaQueryList, MessageChannel, MessagePort, MessagePortMessage, Module, PersistentStore, PersistentStoreBlockedEvent, PersistentStoreOptions, Rect, ResizeEntry, ScrollIntoViewOptions, Storage, Subscription, SurfaceIntentAction, SurfaceIntentSignal, SurfaceRouteSignal, SurfaceSelectionSignal, SurfaceSessionSignal, SurfaceSignal, SurfaceSignalKind, Timer, Value, WindowChannel, WindowChannelOptions, WindowEnv, WindowEnvelope, Worker, WorkerMessage, WorkerOptions, WorkerScope
  • Variables: none
  • Constants: ClientError, ClientEvent, ClientGoodbye, ClientHello, ClientIntent, ClientInvalidate, ClientPayloadBinary, ClientPayloadJSON, ClientPresenceTopic, ClientQuery, ClientResult, CodeBlocked, CodeCancelled, CodeDecode, CodeDisposed, CodeEncode, CodeInvalid, CodeMissingExport, CodeNotFunction, CodePromiseRejected, CodeQuotaExceeded, CodeRemote, CodeTimeout, CodeUnauthorized, CodeUnavailable, SurfaceIntentCloseWindow, SurfaceIntentFocusPanel, SurfaceIntentFocusWindow, SurfaceIntentOpenPanel, SurfaceSignalIntent, SurfaceSignalRoute, SurfaceSignalSelection, SurfaceSignalSession

Subfiles And Purpose

  • compat.go - Core implementation for compat
  • doc.go - Package-level Go documentation
  • interop.go - Core implementation for interop
  • interop_core_zero_branches_test.go - Tests for interop_core_zero_branches behavior
  • interop_native.go - Native (non-WASM) implementation for interop
  • interop_native_test.go - Tests for interop_native behavior
  • interop_wasm.go - WebAssembly-specific implementation for interop
  • interop_wasm_test.go - Tests for interop_wasm behavior
  • interop_wrappers_test.go - Tests for interop_wrappers behavior
  • persistence_wasm.go - WebAssembly-specific implementation for persistence
  • README.md - Folder-level documentation
  • value_native.go - Native (non-WASM) implementation for value
  • value_wasm.go - WebAssembly-specific implementation for value

File Map

interop/
|-- compat.go
|-- doc.go
|-- interop.go
|-- interop_core_zero_branches_test.go
|-- interop_native.go
|-- interop_native_test.go
|-- interop_wasm.go
|-- interop_wasm_test.go
|-- interop_wrappers_test.go
|-- persistence_wasm.go
|-- README.md
|-- value_native.go
\-- value_wasm.go

Documentation

Overview

Package interop provides typed browser and JavaScript module helpers for routine client-side work without forcing applications to depend on raw syscall/js values for every storage, durable persistence, timer, clipboard, media-query, global bridge, custom event, or dynamic import interaction.

Index

Constants

View Source
const ClientPresenceTopic = "clients"

Variables

This section is empty.

Functions

func ClientCanExchange

func ClientCanExchange(parseLocal ClientCapabilities, parsePeer ClientCapabilities, parseTopic string, parseEncoding ClientPayloadEncoding) bool

ClientCanExchange reports whether two clients can communicate on a topic with a shared encoding.

func ClientProtocolCompatible

func ClientProtocolCompatible(parseLocal ClientCapabilities, parsePeer ClientCapabilities) bool

ClientProtocolCompatible reports whether two capability sets share a compatible protocol major version.

func ClientSupportsEncoding

func ClientSupportsEncoding(parseCapabilities ClientCapabilities, parseEncoding ClientPayloadEncoding) bool

ClientSupportsEncoding reports whether the capabilities include the given payload encoding.

func ClientSupportsTopic

func ClientSupportsTopic(parseCapabilities ClientCapabilities, parseTopic string) bool

ClientSupportsTopic reports whether the capabilities include the given topic (empty topic list means all).

func Decode

func Decode(parseValue any, parseTarget any) error

Decode projects JSON-shaped interop payloads into a typed target.

func Decrypt

func Decrypt(parseCtx context.Context, parseKey CryptoKey, parseCiphertext []byte, parseIV []byte) ([]byte, error)

Decrypt is a non-browser stub that always returns an unavailable error.

func Encrypt

func Encrypt(parseCtx context.Context, parseKey CryptoKey, parsePlaintext []byte) ([]byte, []byte, error)

Encrypt is a non-browser stub that always returns an unavailable error.

func ExpireCookie

func ExpireCookie(parseName string, parseOptions ...CookieOptions) error

ExpireCookie deletes a cookie by setting Max-Age to -1. Any options passed should match the path and domain used when the cookie was set.

func GetCookie

func GetCookie(parseName string) (string, bool, error)

GetCookie reads a cookie by name from document.cookie, returning the URL-decoded value and a found bool. An error is returned when the underlying platform read fails.

func IntlAvailable

func IntlAvailable() bool

IntlAvailable reports whether the browser Intl API is available. On native and SSR builds this always returns false; callers should fall back to the Go i18n formatters (e.g. i18n.FormatNumber / i18n.FormatDate). This bridge is browser-only by design.

func IntlFormatDate

func IntlFormatDate(parseLocale string, parseUnixMillis int64, parseOptions ...IntlDateOptions) (string, error)

IntlFormatDate is a non-browser stub that always returns an unavailable error. On native builds callers should fall back to the Go i18n formatters.

func IntlFormatNumber

func IntlFormatNumber(parseLocale string, parseValue float64, parseOptions ...IntlNumberOptions) (string, error)

IntlFormatNumber is a non-browser stub that always returns an unavailable error. On native builds callers should fall back to the Go i18n formatters.

func IsCode

func IsCode(parseErr error, parseCode ErrorCode) bool

IsCode reports whether err is an interop error with the provided code.

func IsStoragePersisted

func IsStoragePersisted(parseCtx context.Context) (bool, error)

IsStoragePersisted is a non-browser stub that always returns an unavailable error.

func KeepAlive

func KeepAlive()

KeepAlive blocks the calling goroutine forever.

In js/wasm programs it keeps main alive after the UI mounts: if main returned, the Go runtime would exit and invalidate every registered event callback, so the app would die on the first interaction. It is the single keep-alive primitive shared by utils.WaitForever and ui.Run, kept in this leaf package so both can reuse it without an import cycle.

func LoadPersistentJSON

func LoadPersistentJSON[T any](parseCtx context.Context, store PersistentStore, parseKey string) (T, bool, error)

func PostNotification

func PostNotification(parseTitle string, parseBody string) error

PostNotification is unavailable on non-browser builds.

func PublishClientBinaryCrossTab

func PublishClientBinaryCrossTab(parseChannel CrossTabChannel, parseTopic string, parseSelf ClientIdentity, parsePayload ClientBinaryPayload) error

PublishClientBinaryCrossTab sends a binary ClientEvent on a CrossTabChannel.

func PublishClientBinaryWindow

func PublishClientBinaryWindow(parseChannel WindowChannel, parseTopic string, parseSelf ClientIdentity, parseTarget string, parsePayload ClientBinaryPayload) error

PublishClientBinaryWindow sends a binary ClientEvent on a WindowChannel to a specific target.

func PublishClientEvent

func PublishClientEvent(parseChannel CrossTabChannel, parseTopic string, parseSelf ClientIdentity, parsePayload any) error

PublishClientEvent sends a ClientEvent message on a CrossTabChannel to a named topic.

func PublishClientGoodbye

func PublishClientGoodbye(parseChannel CrossTabChannel, parseSelf ClientIdentity) error

PublishClientGoodbye sends a ClientGoodbye presence message on a CrossTabChannel.

func PublishClientGoodbyeWindow

func PublishClientGoodbyeWindow(parseChannel WindowChannel, parseSelf ClientIdentity) error

PublishClientGoodbyeWindow sends a ClientGoodbye presence message on a WindowChannel.

func PublishClientHello

func PublishClientHello(parseChannel CrossTabChannel, parseSelf ClientIdentity) error

PublishClientHello sends a ClientHello presence message on a CrossTabChannel with default capabilities.

func PublishClientHelloWindow

func PublishClientHelloWindow(parseChannel WindowChannel, parseSelf ClientIdentity) error

PublishClientHelloWindow sends a ClientHello presence message on a WindowChannel with default capabilities.

func PublishClientHelloWindowWithCapabilities

func PublishClientHelloWindowWithCapabilities(parseChannel WindowChannel, parseSelf ClientIdentity, parseCapabilities ClientCapabilities) error

PublishClientHelloWindowWithCapabilities sends a ClientHello presence message on a WindowChannel with explicit capabilities.

func PublishClientHelloWithCapabilities

func PublishClientHelloWithCapabilities(parseChannel CrossTabChannel, parseSelf ClientIdentity, parseCapabilities ClientCapabilities) error

PublishClientHelloWithCapabilities sends a ClientHello presence message on a CrossTabChannel with explicit capabilities.

func PublishClientIntent

func PublishClientIntent(parseChannel WindowChannel, parseTopic string, parseSelf ClientIdentity, parseTarget string, parsePayload any) error

PublishClientIntent sends a directed ClientIntent message on a WindowChannel.

func PublishClientInvalidation

func PublishClientInvalidation(parseChannel CrossTabChannel, parseTopic string, parseSelf ClientIdentity, parseRevision string) error

PublishClientInvalidation sends a ClientInvalidate message on a CrossTabChannel for a given topic and revision.

func PublishClientMessage

func PublishClientMessage(parseChannel CrossTabChannel, parseMessage ClientMessage) error

PublishClientMessage encodes and sends a ClientMessage over a CrossTabChannel.

func PublishClientQuery

func PublishClientQuery(parseChannel CrossTabChannel, parseTopic string, parseSelf ClientIdentity) error

PublishClientQuery sends a ClientQuery message on a CrossTabChannel for a given topic.

func PublishClientResult

func PublishClientResult(parseChannel CrossTabChannel, parseTopic string, parseSelf ClientIdentity, parseTarget string, parsePayload any) error

PublishClientResult sends a directed ClientResult message on a CrossTabChannel.

func PublishClientWindowMessage

func PublishClientWindowMessage(parseChannel WindowChannel, parseMessage ClientMessage) error

PublishClientWindowMessage encodes and sends a ClientMessage over a WindowChannel.

func PublishIntent

func PublishIntent(parseChannel WindowChannel, parseAction SurfaceIntentAction, parseTarget string, parseParams map[string]string) error

PublishIntent sends an intent surface signal on a WindowChannel.

func PublishLogout

func PublishLogout(parseChannel WindowChannel, parseReason string) error

PublishLogout sends a signed-out session signal on a WindowChannel.

func PublishRouteFocus

func PublishRouteFocus(parseChannel WindowChannel, parsePath string, parseQuery string, parseFocusID string) error

PublishRouteFocus sends a route-focus surface signal on a WindowChannel.

func PublishSelection

func PublishSelection(parseChannel WindowChannel, parseScope string, parseId string, parseRevision string) error

PublishSelection sends a selection surface signal on a WindowChannel.

func PublishSessionExpired

func PublishSessionExpired(parseChannel WindowChannel, parseReason string, parseReturnTo string, parseExpiresAt time.Time) error

PublishSessionExpired sends a session-expired signal on a WindowChannel.

func PublishSurfaceSignal

func PublishSurfaceSignal(parseChannel WindowChannel, parseSignal SurfaceSignal) error

PublishSurfaceSignal validates and sends a SurfaceSignal over a WindowChannel.

func RecoverContainedPanic

func RecoverContainedPanic(parseSubject string)

RecoverContainedPanic contains a panic raised inside a host callback (js.FuncOf body, worker message handler, IndexedDB event). Deferred at the top of the callback it stops the panic from unwinding into the JS bridge, which would kill the whole wasm program and leave the page dead.

func RequestAnimationFrame

func RequestAnimationFrame(parseCallback func(parseTimestampMillis float64)) (parseCancel func())

RequestAnimationFrame is a non-browser stub. On native builds there is no display rendering pipeline, so the callback is never invoked. The returned cancel func is a no-op but is always non-nil so callers can call it unconditionally without a nil check.

Browser (GOOS=js GOARCH=wasm) builds use the real requestAnimationFrame API instead; see raf_wasm.go.

func RequestPersistentStorage

func RequestPersistentStorage(parseCtx context.Context) (bool, error)

RequestPersistentStorage is a non-browser stub that always returns an unavailable error.

func RequestWorkerDecoded

func RequestWorkerDecoded[Req any, Progress any, Result any](parseCtx context.Context, parseWorker WorkerRequester, parseName string, parsePayload Req, parseOnProgress func(DecodedWorkerMessage[Progress], error)) (Result, error)

RequestWorkerDecoded issues a typed request against any worker-compatible requester surface and decodes both progress and final result payloads.

func SetContainedPanicHandler

func SetContainedPanicHandler(parseHandler func(parseSubject string, parseRecovered any))

SetContainedPanicHandler installs the crash-report sink used by RecoverContainedPanic. Passing nil restores the plain-print fallback.

func SetCookie

func SetCookie(parseName string, parseValue string, parseOptions ...CookieOptions) error

SetCookie writes a cookie with the given name, value, and options. Passing no options produces a session cookie with no path, domain, or security attributes. When SameSite is SameSiteNone the Secure flag is forced on.

Types

type BrowserEvent

type BrowserEvent struct {
	Type          string
	Detail        any
	Target        Element
	CurrentTarget Element
}

type ClientBinaryPayload

type ClientBinaryPayload struct {
	ContentType string `json:"contentType,omitempty"`
	Bytes       []byte `json:"-"`
}

type ClientCapabilities

type ClientCapabilities struct {
	ProtocolVersion string   `json:"protocolVersion,omitempty"`
	Transports      []string `json:"transports,omitempty"`
	Encodings       []string `json:"encodings,omitempty"`
	Topics          []string `json:"topics,omitempty"`
	MaxJSONBytes    int      `json:"maxJsonBytes,omitempty"`
	MaxBinaryBytes  int      `json:"maxBinaryBytes,omitempty"`
}

type ClientIdentity

type ClientIdentity struct {
	ID      string `json:"id"`
	App     string `json:"app"`
	Surface string `json:"surface"`
	Role    string `json:"role,omitempty"`
	Version string `json:"version,omitempty"`
}

type ClientMessage

type ClientMessage struct {
	ID           string                `json:"id,omitempty"`
	Kind         ClientMessageKind     `json:"kind"`
	Topic        string                `json:"topic"`
	Source       ClientIdentity        `json:"source"`
	Capabilities *ClientCapabilities   `json:"capabilities,omitempty"`
	Target       string                `json:"target,omitempty"`
	Encoding     ClientPayloadEncoding `json:"encoding,omitempty"`
	ContentType  string                `json:"contentType,omitempty"`
	Payload      any                   `json:"payload,omitempty"`
	Revision     string                `json:"revision,omitempty"`
	Error        string                `json:"error,omitempty"`
	SentAt       time.Time             `json:"sentAt"`
}

func DecodeClientMessage

func DecodeClientMessage(parseValue any) (ClientMessage, error)

type ClientMessageKind

type ClientMessageKind string
const (
	ClientHello      ClientMessageKind = "hello"
	ClientGoodbye    ClientMessageKind = "goodbye"
	ClientEvent      ClientMessageKind = "event"
	ClientIntent     ClientMessageKind = "intent"
	ClientQuery      ClientMessageKind = "query"
	ClientResult     ClientMessageKind = "result"
	ClientInvalidate ClientMessageKind = "invalidate"
	ClientError      ClientMessageKind = "error"
)

type ClientPayloadEncoding

type ClientPayloadEncoding string
const (
	ClientPayloadJSON   ClientPayloadEncoding = "json"
	ClientPayloadBinary ClientPayloadEncoding = "binary"
)

type Clipboard

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

func GetClipboard

func GetClipboard() (Clipboard, error)

GetClipboard is a non-browser stub that always returns an unavailable error.

func NavigatorClipboard() (Clipboard, error)

NavigatorClipboard preserves the legacy clipboard accessor name.

func (Clipboard) ReadText

func (parseC Clipboard) ReadText(parseCtx context.Context) (string, error)

func (Clipboard) WriteText

func (parseC Clipboard) WriteText(parseCtx context.Context, parseText string) error

type CookieOptions

type CookieOptions struct {
	Path     string
	Domain   string
	MaxAge   int // seconds; 0 = session cookie; negative = expire now
	Secure   bool
	SameSite SameSite
}

CookieOptions configures optional cookie attributes.

type CrossTabChannel

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

func OpenCrossTabChannel

func OpenCrossTabChannel(parseChannelOptions CrossTabChannelOptions) (CrossTabChannel, error)

OpenCrossTabChannel is a non-browser stub that always returns an unavailable error.

func (CrossTabChannel) Close

func (parseC CrossTabChannel) Close() error

func (CrossTabChannel) Name

func (parseC CrossTabChannel) Name() string

func (CrossTabChannel) Publish

func (parseC CrossTabChannel) Publish(parsePayload any) error

func (CrossTabChannel) Subscribe

func (parseC CrossTabChannel) Subscribe(parseHandler func(CrossTabEnvelope, error)) (Subscription, error)

func (CrossTabChannel) Transport

func (parseC CrossTabChannel) Transport() string

type CrossTabChannelOptions

type CrossTabChannelOptions struct {
	Name       string
	StorageKey string
}

type CrossTabEnvelope

type CrossTabEnvelope struct {
	Name     string    `json:"name"`
	Payload  any       `json:"payload"`
	Source   string    `json:"source,omitempty"`
	Sequence int64     `json:"sequence,omitempty"`
	SentAt   time.Time `json:"sentAt"`
}

type CryptoKey

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

CryptoKey is an opaque handle wrapping a non-extractable AES-GCM key generated by the browser's WebCrypto API. On native builds the underlying field is always nil; on WASM builds it holds the live js.Value.

func GenerateAESKey

func GenerateAESKey(parseCtx context.Context) (CryptoKey, error)

GenerateAESKey is a non-browser stub that always returns an unavailable error.

type CustomEvent

type CustomEvent struct {
	Type   string
	Detail any
}

type DecodedCrossTabEnvelope

type DecodedCrossTabEnvelope[T any] struct {
	Name     string
	Payload  T
	Source   string
	Sequence int64
	SentAt   time.Time
}

func DecodeCrossTabEnvelope

func DecodeCrossTabEnvelope[T any](parseMessage CrossTabEnvelope) (DecodedCrossTabEnvelope[T], error)

type DecodedCustomEvent

type DecodedCustomEvent[T any] struct {
	Type   string
	Detail T
}

func DecodeCustomEvent

func DecodeCustomEvent[T any](parseEvent CustomEvent) (DecodedCustomEvent[T], error)

DecodeCustomEvent projects a custom-event detail payload into a typed value.

type DecodedMessagePortMessage

type DecodedMessagePortMessage[T any] struct {
	Payload T
	Ports   []MessagePort
}

DecodedMessagePortMessage carries a typed payload received on a MessagePort together with any transferred ports attached to the same event.

func DecodeMessagePortMessage

func DecodeMessagePortMessage[T any](parseMessage MessagePortMessage) (DecodedMessagePortMessage[T], error)

DecodeMessagePortMessage projects a message-port payload into a typed value.

type DecodedWindowEnvelope

type DecodedWindowEnvelope[T any] struct {
	Name    string
	Payload T
	Source  string
	SentAt  time.Time
}

func DecodeSurfaceSignal

func DecodeSurfaceSignal(parseMessage WindowEnvelope) (DecodedWindowEnvelope[SurfaceSignal], error)

DecodeSurfaceSignal decodes a WindowEnvelope payload as a SurfaceSignal.

func DecodeWindowEnvelope

func DecodeWindowEnvelope[T any](parseMessage WindowEnvelope) (DecodedWindowEnvelope[T], error)

type DecodedWorkerMessage

type DecodedWorkerMessage[T any] struct {
	ID      string
	Phase   string
	Name    string
	Payload T
	Error   string
	Ports   []MessagePort
}

func DecodeWorkerMessage

func DecodeWorkerMessage[T any](parseMessage WorkerMessage) (DecodedWorkerMessage[T], error)

type Document

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

func CurrentDocument

func CurrentDocument() (Document, error)

CurrentDocument preserves the legacy document accessor name.

func GetDocument

func GetDocument() (Document, error)

GetDocument is a non-browser stub that always returns an unavailable error.

func (Document) ElementByID

func (parseD Document) ElementByID(parseId string) (Element, bool, error)

func (Document) ElementsByID

func (parseD Document) ElementsByID(parseIds ...string) (map[string]Element, error)

func (Document) QuerySelector

func (parseD Document) QuerySelector(parseSelector string) (Element, bool, error)

func (Document) SetTitle

func (parseD Document) SetTitle(parseTitle string) error

SetTitle sets document.title (e.g. to reflect the active route or conversation in the tab strip). Unavailable on native/SSR builds.

func (Document) Title

func (parseD Document) Title() (string, error)

Title returns document.title. Unavailable on native/SSR builds.

type Element

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

func (Element) Blur

func (parseE Element) Blur() error

func (Element) BoundingClientRect

func (parseE Element) BoundingClientRect() (Rect, error)

func (Element) ClassName

func (parseE Element) ClassName() string

func (Element) Click

func (parseE Element) Click() error

func (Element) Dispatch

func (parseE Element) Dispatch(parseName string, parseDetail any) error

func (Element) Events

func (parseE Element) Events() (EventTarget, error)

func (Element) Focus

func (parseE Element) Focus() error

func (Element) ID

func (parseE Element) ID() string

func (Element) Listen

func (parseE Element) Listen(parseName string, parseHandler func(BrowserEvent)) (Subscription, error)

func (Element) ObserveIntersection

func (parseE Element) ObserveIntersection(parseHandler func(IntersectionEntry), parseOptions ...IntersectionObserverOptions) (Subscription, error)

func (Element) ObserveResize

func (parseE Element) ObserveResize(parseHandler func(ResizeEntry)) (Subscription, error)

func (Element) ScrollIntoView

func (parseE Element) ScrollIntoView(parseOptions ...ScrollIntoViewOptions) error

func (Element) ScrollMetrics

func (parseE Element) ScrollMetrics() (parseScrollTop, parseScrollHeight, parseClientHeight float64, parseErr error)

ScrollMetrics returns the scrollTop, scrollHeight, and clientHeight of the element — the three values needed to determine scroll position within a scrollable container.

func (Element) SetScrollTop

func (parseE Element) SetScrollTop(parseScrollTop float64) error

func (Element) Subscribe

func (parseE Element) Subscribe(parseName string, parseHandler func(CustomEvent)) (Subscription, error)

func (Element) TagName

func (parseE Element) TagName() string

type EncryptedStore

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

EncryptedStore combines a CryptoKey with a Storage backend to provide transparent JSON-marshal-then-encrypt persistence. Values are stored as a base64-encoded envelope: "<base64(iv)>:<base64(ciphertext)>".

func NewEncryptedStore

func NewEncryptedStore(parseKey CryptoKey) (EncryptedStore, error)

NewEncryptedStore returns a zero EncryptedStore; all methods on it return unavailable errors.

func (EncryptedStore) GetJSON

func (parseES EncryptedStore) GetJSON(parseCtx context.Context, parseStorageKey string, parseOut any) (bool, error)

GetJSON is a non-browser stub that always returns an unavailable error.

func (EncryptedStore) PutJSON

func (parseES EncryptedStore) PutJSON(parseCtx context.Context, parseStorageKey string, parseValue any) error

PutJSON is a non-browser stub that always returns an unavailable error.

type Error

type Error struct {
	Op     string
	Target string
	Code   ErrorCode
	Err    error
}

Error reports a structured interop failure.

func AsError

func AsError(parseErr error) (*Error, bool)

AsError unwraps an interop error into the structured Error form.

func (*Error) Error

func (parseE *Error) Error() string

func (*Error) Unwrap

func (parseE *Error) Unwrap() error

type ErrorCode

type ErrorCode string
const (
	CodeUnavailable     ErrorCode = "unavailable"
	CodePromiseRejected ErrorCode = "promise_rejected"
	CodeDisposed        ErrorCode = "disposed"
	CodeEncode          ErrorCode = "encode"
	CodeDecode          ErrorCode = "decode"
	CodeMissingExport   ErrorCode = "missing_export"
	CodeNotFunction     ErrorCode = "not_function"
	CodeInvalid         ErrorCode = "invalid"
	CodeBlocked         ErrorCode = "blocked"
	CodeQuotaExceeded   ErrorCode = "quota_exceeded"
	CodeUnauthorized    ErrorCode = "unauthorized"
	CodeCancelled       ErrorCode = "cancelled"
	CodeTimeout         ErrorCode = "timeout"
	CodeRemote          ErrorCode = "remote_error"
)

func CodeOf

func CodeOf(parseErr error) (ErrorCode, bool)

CodeOf returns the interop error code for err when available.

type EventTarget

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

func GetDocumentEvents

func GetDocumentEvents() (EventTarget, error)

GetDocumentEvents is a non-browser stub that always returns an unavailable error.

func GetWindowEvents

func GetWindowEvents() (EventTarget, error)

GetWindowEvents is a non-browser stub that always returns an unavailable error.

func (EventTarget) Dispatch

func (parseT EventTarget) Dispatch(parseName string, parseDetail any) error

func (EventTarget) Listen

func (parseT EventTarget) Listen(parseName string, parseHandler func(BrowserEvent)) (Subscription, error)

func (EventTarget) Subscribe

func (parseT EventTarget) Subscribe(parseName string, parseHandler func(CustomEvent)) (Subscription, error)

type GoWASMWorkerOptions

type GoWASMWorkerOptions struct {
	RuntimeURL   string
	WASMURL      string
	Name         string
	Ready        bool
	ReadyTimeout time.Duration
}

type History

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

func GetWindowHistory

func GetWindowHistory() (History, error)

GetWindowHistory is a non-browser stub that always returns an unavailable error.

func (History) Back

func (parseH History) Back() error

func (History) Forward

func (parseH History) Forward() error

func (History) Go

func (parseH History) Go(parseDelta int) error

func (History) Len

func (parseH History) Len() (int, error)

func (History) PushState

func (parseH History) PushState(parseState any, parseTitle string, parseRawURL string) error

func (History) ReplaceState

func (parseH History) ReplaceState(parseState any, parseTitle string, parseRawURL string) error

func (History) State

func (parseH History) State() (any, error)

type IntersectionEntry

type IntersectionEntry struct {
	Target             Element
	IsIntersecting     bool
	IntersectionRatio  float64
	BoundingClientRect Rect
	IntersectionRect   Rect
	RootBounds         *Rect
}

type IntersectionObserverOptions

type IntersectionObserverOptions struct {
	Root       Element
	RootMargin string
	Thresholds []float64
}

type IntlDateOptions

type IntlDateOptions struct {
	// DateStyle is the date display style: "full", "long", "medium", or
	// "short". Empty omits the option.
	DateStyle string
	// TimeStyle is the time display style: "full", "long", "medium", or
	// "short". Empty omits the option.
	TimeStyle string
	// TimeZone is the IANA time-zone name (e.g. "America/New_York"). Empty
	// omits the option, letting the browser use its local zone.
	TimeZone string
}

IntlDateOptions configures a browser Intl.DateTimeFormat instance. Fields map directly to the JS options bag passed to the Intl.DateTimeFormat constructor. Leaving DateStyle and TimeStyle empty lets the browser apply its defaults.

type IntlNumberOptions

type IntlNumberOptions struct {
	// Style is the formatting style: "decimal" (default), "currency", or
	// "percent".
	Style string
	// Currency is the ISO 4217 currency code (e.g. "USD"). Required when Style
	// is "currency".
	Currency string
	// MinimumFractionDigits sets the minimum number of fraction digits.
	MinimumFractionDigits int
	// MaximumFractionDigits sets the maximum number of fraction digits. A zero
	// value leaves the option unset (JS default applies).
	MaximumFractionDigits int
	// UseGrouping controls digit grouping separators (e.g. thousands commas).
	// Matches the JS useGrouping option. nil leaves the option unset so the
	// browser default applies (grouping on); a non-nil pointer forces the value.
	// A plain bool could not distinguish "unset" from "explicitly false", which
	// would wrongly suppress grouping on every call that did not set it.
	UseGrouping *bool
}

IntlNumberOptions configures a browser Intl.NumberFormat instance. Fields map directly to the JS options bag passed to the Intl.NumberFormat constructor. The zero value produces decimal formatting with grouping enabled.

type Location

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

func GetWindowLocation

func GetWindowLocation() (Location, error)

GetWindowLocation is a non-browser stub that always returns an unavailable error.

func (Location) Assign

func (parseL Location) Assign(parseRawURL string) error

func (Location) Hash

func (parseL Location) Hash() string

func (Location) Href

func (parseL Location) Href() string

func (Location) Origin

func (parseL Location) Origin() string

func (Location) Pathname

func (parseL Location) Pathname() string

func (Location) Reload

func (parseL Location) Reload() error

func (Location) Replace

func (parseL Location) Replace(parseRawURL string) error

func (Location) Search

func (parseL Location) Search() string

type MediaQueryEvent

type MediaQueryEvent struct {
	Matches bool
	Media   string
}

type MediaQueryList

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

func GetMediaQuery

func GetMediaQuery(parseMediaQuery string) (MediaQueryList, error)

GetMediaQuery is a non-browser stub that always returns an unavailable error.

func (MediaQueryList) Matches

func (parseM MediaQueryList) Matches() bool

func (MediaQueryList) Media

func (parseM MediaQueryList) Media() string

func (MediaQueryList) Subscribe

func (parseM MediaQueryList) Subscribe(parseHandler func(MediaQueryEvent)) (Subscription, error)

type MessageChannel

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

MessageChannel wraps the two linked endpoints produced by the browser MessageChannel constructor.

func OpenMessageChannel

func OpenMessageChannel() (MessageChannel, error)

OpenMessageChannel is a non-browser stub that always returns an unavailable error.

func (MessageChannel) Port1

func (parseC MessageChannel) Port1() MessagePort

Port1 returns the first endpoint of the message channel.

func (MessageChannel) Port2

func (parseC MessageChannel) Port2() MessagePort

Port2 returns the second endpoint of the message channel.

type MessagePort

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

MessagePort wraps a browser MessagePort with post, subscribe, and close helpers suitable for worker-owned subchannels.

func (MessagePort) Close

func (parseP MessagePort) Close() error

Close closes the message port.

func (MessagePort) GetMessagePortRaw

func (parseP MessagePort) GetMessagePortRaw() any

GetMessagePortRaw returns the platform-specific message-port handle.

func (MessagePort) Post

func (parseP MessagePort) Post(parsePayload any) error

Post sends a payload over the message port.

func (MessagePort) PostPorts

func (parseP MessagePort) PostPorts(parsePayload any, parsePorts ...MessagePort) error

PostPorts sends a payload over the message port together with transferred MessagePorts.

func (MessagePort) Subscribe

func (parseP MessagePort) Subscribe(parseHandler func(MessagePortMessage, error)) (Subscription, error)

Subscribe receives payloads from the message port.

type MessagePortMessage

type MessagePortMessage struct {
	Payload any
	Ports   []MessagePort
}

MessagePortMessage carries one payload received on a MessagePort together with any transferred ports attached to the same event.

type Module

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

func ImportModule

func ImportModule(parseImportCtx context.Context, parseImportSpecifier string) (Module, error)

ImportModule is a non-browser stub that always returns an unavailable error.

func (Module) Call

func (parseM Module) Call(parseCtx context.Context, parseExport string, parseArgs ...any) (any, error)

func (Module) CallDefault

func (parseM Module) CallDefault(parseCtx context.Context, parseArgs ...any) (any, error)

func (Module) Dispose

func (parseM Module) Dispose() error

func (Module) Value

func (parseM Module) Value(parseCtx context.Context, parseExport string) (any, error)

type NotificationPermission

type NotificationPermission string

NotificationPermission is the browser Notification permission state.

const (
	// NotificationDefault means the user has not yet granted or denied permission.
	NotificationDefault NotificationPermission = "default"
	// NotificationGranted means notifications are allowed.
	NotificationGranted NotificationPermission = "granted"
	// NotificationDenied means notifications are blocked.
	NotificationDenied NotificationPermission = "denied"
)

func NotificationPermissionState

func NotificationPermissionState() (NotificationPermission, error)

NotificationPermissionState is unavailable on non-browser builds.

func RequestNotificationPermission

func RequestNotificationPermission(parseCtx context.Context) (NotificationPermission, error)

RequestNotificationPermission is unavailable on non-browser builds.

type PersistentStore

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

func OpenPersistentStore

func OpenPersistentStore(parseStoreCtx context.Context, parseStoreOptions PersistentStoreOptions) (PersistentStore, error)

OpenPersistentStore is a non-browser stub that always returns an unavailable error.

func (PersistentStore) Backend

func (parseS PersistentStore) Backend() string

func (PersistentStore) Clear

func (parseS PersistentStore) Clear(parseCtx context.Context) error

func (PersistentStore) Close

func (parseS PersistentStore) Close() error

func (PersistentStore) DecodeJSON

func (parseS PersistentStore) DecodeJSON(parseCtx context.Context, parseKey string, parseTarget any) (bool, error)

func (PersistentStore) GetItem

func (parseS PersistentStore) GetItem(parseCtx context.Context, parseKey string) (string, bool, error)

func (PersistentStore) GetMany

func (parseS PersistentStore) GetMany(parseCtx context.Context, parseKeys ...string) (map[string]string, error)

func (PersistentStore) Keys

func (parseS PersistentStore) Keys(parseCtx context.Context) ([]string, error)

func (PersistentStore) Len

func (parseS PersistentStore) Len(parseCtx context.Context) (int, error)

func (PersistentStore) RemoveItem

func (parseS PersistentStore) RemoveItem(parseCtx context.Context, parseKey string) error

func (PersistentStore) SetItem

func (parseS PersistentStore) SetItem(parseCtx context.Context, parseKey string, parseValue string) error

func (PersistentStore) SetJSON

func (parseS PersistentStore) SetJSON(parseCtx context.Context, parseKey string, parseValue any) error

type PersistentStoreBlockedEvent

type PersistentStoreBlockedEvent struct {
	DatabaseName     string
	StoreName        string
	RequestedVersion int
}

type PersistentStoreOptions

type PersistentStoreOptions struct {
	Name               string
	DatabaseName       string
	Version            int
	DeleteOnCorruption bool
	OnBlocked          func(PersistentStoreBlockedEvent)
	FallbackResolver   func() (Storage, error)
	FallbackBackend    string
}

type Rect

type Rect struct {
	X      float64
	Y      float64
	Width  float64
	Height float64
	Top    float64
	Right  float64
	Bottom float64
	Left   float64
}

type ResizeEntry

type ResizeEntry struct {
	Target      Element
	ContentRect Rect
}

type SameSite

type SameSite string

SameSite controls the SameSite cookie attribute.

const (
	// SameSiteLax sets the SameSite attribute to Lax.
	SameSiteLax SameSite = "Lax"
	// SameSiteStrict sets the SameSite attribute to Strict.
	SameSiteStrict SameSite = "Strict"
	// SameSiteNone sets the SameSite attribute to None (requires Secure).
	SameSiteNone SameSite = "None"
)

type ScrollIntoViewOptions

type ScrollIntoViewOptions struct {
	Behavior string
	Block    string
	Inline   string
}

type SharedBuffer

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

SharedBuffer wraps a browser SharedArrayBuffer with byte access and int32 atomic helpers for worker coordination.

func OpenSharedBuffer

func OpenSharedBuffer(parseByteLength int) (SharedBuffer, error)

OpenSharedBuffer is a non-browser stub that always returns an unavailable error.

func (SharedBuffer) AddInt32

func (parseB SharedBuffer) AddInt32(parseIndex int, parseDelta int32) (int32, error)

AddInt32 atomically adds delta to the int32 slot at index and returns the previous value.

func (SharedBuffer) AndInt32

func (parseB SharedBuffer) AndInt32(parseIndex int, parseMask int32) (int32, error)

AndInt32 atomically ANDs mask with the int32 slot at index and returns the previous value.

func (SharedBuffer) CompareExchangeInt32

func (parseB SharedBuffer) CompareExchangeInt32(parseIndex int, parseOldValue int32, parseNewValue int32) (int32, error)

CompareExchangeInt32 atomically swaps newValue into the int32 slot at index when the current value equals oldValue, and returns the previous value.

func (SharedBuffer) ExchangeInt32

func (parseB SharedBuffer) ExchangeInt32(parseIndex int, parseValue int32) (int32, error)

ExchangeInt32 atomically swaps value into the int32 slot at index and returns the previous value.

func (SharedBuffer) GetByteLength

func (parseB SharedBuffer) GetByteLength() int

GetByteLength returns the SharedArrayBuffer length in bytes.

func (SharedBuffer) GetInt32Length

func (parseB SharedBuffer) GetInt32Length() int

GetInt32Length returns the number of addressable int32 slots in the shared buffer.

func (SharedBuffer) GetSharedBufferRaw

func (parseB SharedBuffer) GetSharedBufferRaw() any

func (SharedBuffer) LoadInt32

func (parseB SharedBuffer) LoadInt32(parseIndex int) (int32, error)

LoadInt32 atomically reads the int32 value at index.

func (SharedBuffer) NotifyInt32

func (parseB SharedBuffer) NotifyInt32(parseIndex int, parseCount int) (int, error)

NotifyInt32 wakes blocked waiters for the int32 slot at index and returns the number of workers notified.

func (SharedBuffer) OrInt32

func (parseB SharedBuffer) OrInt32(parseIndex int, parseMask int32) (int32, error)

OrInt32 atomically ORs mask with the int32 slot at index and returns the previous value.

func (SharedBuffer) ReadBytes

func (parseB SharedBuffer) ReadBytes(parseOffset int, parseDest []byte) (int, error)

ReadBytes copies shared-memory bytes starting at offset into dest.

func (SharedBuffer) StoreInt32

func (parseB SharedBuffer) StoreInt32(parseIndex int, parseValue int32) error

StoreInt32 atomically writes value to the int32 slot at index.

func (SharedBuffer) SubInt32

func (parseB SharedBuffer) SubInt32(parseIndex int, parseDelta int32) (int32, error)

SubInt32 atomically subtracts delta from the int32 slot at index and returns the previous value.

func (SharedBuffer) WaitInt32

func (parseB SharedBuffer) WaitInt32(parseIndex int, parseExpected int32, parseTimeout time.Duration) (WaitResult, error)

WaitInt32 blocks in a worker context until the int32 slot at index changes from expected or the optional timeout expires. The WaitResult names the outcome.

func (SharedBuffer) WriteBytes

func (parseB SharedBuffer) WriteBytes(parseOffset int, parseSource []byte) (int, error)

WriteBytes copies source bytes into shared memory starting at offset.

func (SharedBuffer) XorInt32

func (parseB SharedBuffer) XorInt32(parseIndex int, parseMask int32) (int32, error)

XorInt32 atomically XORs mask with the int32 slot at index and returns the previous value.

type SharedMemorySupport

type SharedMemorySupport struct {
	IsCrossOriginIsolated bool
	HasSharedArrayBuffer  bool
	HasAtomics            bool
	CanUseSharedMemory    bool
}

SharedMemorySupport reports whether the current browser context can use the shared-memory worker path.

func GetSharedMemorySupport

func GetSharedMemorySupport() (SharedMemorySupport, error)

GetSharedMemorySupport is a non-browser stub that always returns an unavailable error.

type Storage

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

func GetLocalStorage

func GetLocalStorage() (Storage, error)

GetLocalStorage returns an unavailable stub on non-browser builds.

func GetSessionStorage

func GetSessionStorage() (Storage, error)

GetSessionStorage returns an unavailable stub on non-browser builds.

func LocalStorage

func LocalStorage() (Storage, error)

LocalStorage preserves the legacy storage accessor name.

func SessionStorage

func SessionStorage() (Storage, error)

SessionStorage preserves the legacy storage accessor name.

func (Storage) Clear

func (parseS Storage) Clear() error

func (Storage) GetItem

func (parseS Storage) GetItem(parseKey string) (string, bool, error)

func (Storage) GetMany

func (parseS Storage) GetMany(parseKeys ...string) (map[string]string, error)

func (Storage) Key

func (parseS Storage) Key(parseIndex int) (string, bool, error)

func (Storage) Len

func (parseS Storage) Len() (int, error)

func (Storage) RemoveItem

func (parseS Storage) RemoveItem(parseKey string) error

func (Storage) SetItem

func (parseS Storage) SetItem(parseKey string, parseValue string) error

type Subscription

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

func SubscribeClientMessages

func SubscribeClientMessages(parseChannel CrossTabChannel, parseHandler func(ClientMessage, error)) (Subscription, error)

SubscribeClientMessages decodes incoming CrossTabChannel envelopes as ClientMessages and invokes handler.

func SubscribeClientWindowMessages

func SubscribeClientWindowMessages(parseChannel WindowChannel, parseHandler func(ClientMessage, error)) (Subscription, error)

SubscribeClientWindowMessages decodes incoming WindowChannel envelopes as ClientMessages and invokes handler.

func SubscribeDecoded

func SubscribeDecoded[T any](parseTarget EventTarget, parseName string, parseHandler func(DecodedCustomEvent[T], error)) (Subscription, error)

SubscribeDecoded decodes custom-event detail payloads before invoking the handler.

func SubscribeDecodedCrossTab

func SubscribeDecodedCrossTab[T any](parseChannel CrossTabChannel, parseHandler func(DecodedCrossTabEnvelope[T], error)) (Subscription, error)

func SubscribeDecodedMessagePort

func SubscribeDecodedMessagePort[T any](parsePort MessagePort, parseHandler func(DecodedMessagePortMessage[T], error)) (Subscription, error)

SubscribeDecodedMessagePort receives typed payloads from a MessagePort.

func SubscribeDecodedWindow

func SubscribeDecodedWindow[T any](parseChannel WindowChannel, parseHandler func(DecodedWindowEnvelope[T], error)) (Subscription, error)

func SubscribeDecodedWorker

func SubscribeDecodedWorker[T any](parseWorker Worker, parseHandler func(DecodedWorkerMessage[T], error)) (Subscription, error)

func SubscribeSurfaceSignals

func SubscribeSurfaceSignals(parseChannel WindowChannel, parseHandler func(DecodedWindowEnvelope[SurfaceSignal], error)) (Subscription, error)

SubscribeSurfaceSignals receives decoded SurfaceSignal messages on a WindowChannel.

func (Subscription) Cancel

func (parseS Subscription) Cancel()

type SurfaceIntentAction

type SurfaceIntentAction string
const (
	SurfaceIntentFocusWindow SurfaceIntentAction = "focus-window"
	SurfaceIntentFocusPanel  SurfaceIntentAction = "focus-panel"
	SurfaceIntentOpenPanel   SurfaceIntentAction = "open-panel"
	SurfaceIntentCloseWindow SurfaceIntentAction = "close-window"
)

type SurfaceIntentSignal

type SurfaceIntentSignal struct {
	Action SurfaceIntentAction `json:"action"`
	Target string              `json:"target,omitempty"`
	Params map[string]string   `json:"params,omitempty"`
}

type SurfaceRouteSignal

type SurfaceRouteSignal struct {
	Path    string `json:"path"`
	Query   string `json:"query,omitempty"`
	FocusID string `json:"focusId,omitempty"`
	Replace bool   `json:"replace,omitempty"`
}

type SurfaceSelectionSignal

type SurfaceSelectionSignal struct {
	Scope    string `json:"scope,omitempty"`
	ID       string `json:"id"`
	Revision string `json:"revision,omitempty"`
}

type SurfaceSessionSignal

type SurfaceSessionSignal struct {
	Status    string    `json:"status"`
	Reason    string    `json:"reason,omitempty"`
	ReturnTo  string    `json:"returnTo,omitempty"`
	ExpiresAt time.Time `json:"expiresAt"`
}

type SurfaceSignal

type SurfaceSignal struct {
	Kind      SurfaceSignalKind       `json:"kind"`
	Session   *SurfaceSessionSignal   `json:"session,omitempty"`
	Route     *SurfaceRouteSignal     `json:"route,omitempty"`
	Selection *SurfaceSelectionSignal `json:"selection,omitempty"`
	Intent    *SurfaceIntentSignal    `json:"intent,omitempty"`
}

type SurfaceSignalKind

type SurfaceSignalKind string
const (
	SurfaceSignalSession   SurfaceSignalKind = "session"
	SurfaceSignalRoute     SurfaceSignalKind = "route"
	SurfaceSignalSelection SurfaceSignalKind = "selection"
	SurfaceSignalIntent    SurfaceSignalKind = "intent"
)

type Timer

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

func ScheduleInterval

func ScheduleInterval(parseTimerInterval time.Duration, parseTimerFn func()) (Timer, error)

ScheduleInterval is a non-browser stub that always returns an unavailable error.

func ScheduleTimeout

func ScheduleTimeout(parseTimerDelay time.Duration, parseTimerFn func()) (Timer, error)

ScheduleTimeout is a non-browser stub that always returns an unavailable error.

func SetInterval

func SetInterval(parseTimerInterval time.Duration, parseTimerFn func()) (Timer, error)

SetInterval preserves the legacy interval helper name.

func SetTimeout

func SetTimeout(parseTimerDelay time.Duration, parseTimerFn func()) (Timer, error)

SetTimeout preserves the legacy timer helper name.

func (Timer) Cancel

func (parseT Timer) Cancel() error

type Value

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

Value wraps a browser JavaScript value behind a typed interop surface. Platform-specific methods are attached in build-tagged files.

func GetGlobalThis

func GetGlobalThis() (Value, error)

GetGlobalThis returns an unavailable stub on non-browser builds.

func GlobalThis

func GlobalThis() (Value, error)

GlobalThis preserves the legacy interop global accessor name.

func (Value) Await

func (parseV Value) Await(parseCtx context.Context) (Value, error)

Await is unavailable on non-browser builds. It returns a structured CodeUnavailable error so native unit tests of code paths that call Await fail loudly rather than silently.

func (Value) AwaitCall

func (parseV Value) AwaitCall(parseCtx context.Context, parseMethod string, parseArgs ...any) (Value, error)

AwaitCall is unavailable on non-browser builds.

func (Value) Bool

func (parseValue Value) Bool() bool

Bool returns the value as a boolean when possible.

func (Value) Call

func (parseValue Value) Call(parseMethodName string, parseMethodArgs ...any) (Value, error)

Call invokes a named method on the wrapped value.

func (Value) Delete

func (parseValue Value) Delete(parseValueName string) error

Delete removes a property from the wrapped value.

func (Value) Float

func (parseValue Value) Float() float64

Float returns the value as a float when possible.

func (Value) Get

func (parseValue Value) Get(parseValueName string) Value

Get reads a property from the wrapped value.

func (Value) Int

func (parseValue Value) Int() int

Int returns the value as an integer when possible.

func (Value) Invoke

func (parseValue Value) Invoke(parseCallArgs ...any) (Value, error)

Invoke calls the wrapped value as a function.

func (Value) IsNull

func (parseValue Value) IsNull() bool

IsNull reports whether the value is null.

func (Value) IsUndefined

func (parseValue Value) IsUndefined() bool

IsUndefined reports whether the value is undefined.

func (Value) Present

func (parseValue Value) Present() bool

Present reports whether the value is defined and non-null.

func (Value) Set

func (parseValue Value) Set(parseValueName string, parseValueData any) error

Set writes a property on the wrapped value.

func (Value) SetFunction

func (parseValue Value) SetFunction(parseFunctionName string, parseFunctionHandler func(args ...Value) any) (Subscription, error)

SetFunction binds a Go handler to a property on the wrapped value.

func (Value) String

func (parseValue Value) String() string

String returns the value as a string when possible.

func (Value) ToGo

func (parseValue Value) ToGo() (any, error)

ToGo converts the wrapped value into a JSON-shaped Go representation.

func (Value) Truthy

func (parseValue Value) Truthy() bool

Truthy reports whether the value is truthy in the JavaScript sense.

type WaitResult

type WaitResult string

WaitResult is the outcome of a SharedBuffer.WaitInt32 call — the typed form of JS Atomics.wait's three return states, so callers branch on named constants instead of magic string literals.

const (
	// WaitOK means the slot's value changed away from the expected value (the waiter was woken).
	WaitOK WaitResult = "ok"
	// WaitNotEqual means the slot did not hold the expected value, so the wait returned immediately.
	WaitNotEqual WaitResult = "not-equal"
	// WaitTimedOut means the optional timeout elapsed before the value changed.
	WaitTimedOut WaitResult = "timed-out"
)

type WindowChannel

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

func OpenSecondaryWindowChannel

func OpenSecondaryWindowChannel(parseWindowOptions WindowChannelOptions) (WindowChannel, error)

OpenSecondaryWindowChannel is a non-browser stub that always returns an unavailable error.

func OpenWindowOpenerChannel

func OpenWindowOpenerChannel(parseWindowOptions WindowChannelOptions) (WindowChannel, error)

OpenWindowOpenerChannel is a non-browser stub that always returns an unavailable error.

func (WindowChannel) Close

func (parseC WindowChannel) Close() error

func (WindowChannel) Closed

func (parseC WindowChannel) Closed() bool

func (WindowChannel) Focus

func (parseC WindowChannel) Focus() error

func (WindowChannel) Name

func (parseC WindowChannel) Name() string

func (WindowChannel) Publish

func (parseC WindowChannel) Publish(parsePayload any) error

func (WindowChannel) Subscribe

func (parseC WindowChannel) Subscribe(parseHandler func(WindowEnvelope, error)) (Subscription, error)

func (WindowChannel) TargetOrigin

func (parseC WindowChannel) TargetOrigin() string

type WindowChannelOptions

type WindowChannelOptions struct {
	URL          string
	Name         string
	Features     string
	TargetOrigin string
}

type WindowEnv

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

WindowEnv exposes shared values attached directly to the browser window object. It is intended for simple cross-surface configuration such as mount selectors, bootstrap flags, and other host-provided runtime settings.

func GetWindowEnv

func GetWindowEnv() (WindowEnv, error)

GetWindowEnv returns an empty reader on non-browser builds.

func SharedWindowEnv

func SharedWindowEnv() (WindowEnv, error)

SharedWindowEnv preserves the legacy shared window env accessor name.

func (WindowEnv) Lookup

func (parseE WindowEnv) Lookup(parseName string) (Value, bool)

Lookup returns the raw shared window value when present.

func (WindowEnv) LookupString

func (parseE WindowEnv) LookupString(parseName string) (string, bool)

LookupString resolves a shared window value as a normalized string. Empty strings and JavaScript stringified nullish sentinel values are treated as missing.

func (WindowEnv) String

func (parseE WindowEnv) String(parseName string, parseFallback string) string

String returns a normalized shared window string or the provided fallback.

type WindowEnvelope

type WindowEnvelope struct {
	Name    string    `json:"name"`
	Payload any       `json:"payload"`
	Source  string    `json:"source,omitempty"`
	SentAt  time.Time `json:"sentAt"`
}

type Worker

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

func NewGoWASMWorker

func NewGoWASMWorker(parseWorkerCtx context.Context, parseWorkerOptions GoWASMWorkerOptions) (Worker, error)

NewGoWASMWorker preserves the legacy Go WASM worker constructor name.

func OpenGoWASMWorker

func OpenGoWASMWorker(parseWorkerCtx context.Context, parseWorkerOptions GoWASMWorkerOptions) (Worker, error)

OpenGoWASMWorker is a non-browser stub that always returns an unavailable error.

func OpenWorker

func OpenWorker(parseWorkerCtx context.Context, parseWorkerOptions WorkerOptions) (Worker, error)

OpenWorker is a non-browser stub that always returns an unavailable error.

func (Worker) Post

func (parseW Worker) Post(parseMessage any) error

func (Worker) PostPorts

func (parseW Worker) PostPorts(parseMessage any, parsePorts ...MessagePort) error

PostPorts sends a payload to the worker together with transferred MessagePorts.

func (Worker) Request

func (parseW Worker) Request(parseCtx context.Context, parseName string, parsePayload any, parseOnProgress func(WorkerMessage, error)) (WorkerMessage, error)

func (Worker) Restart

func (parseW Worker) Restart(parseCtx context.Context) error

func (Worker) Subscribe

func (parseW Worker) Subscribe(parseHandler func(WorkerMessage, error)) (Subscription, error)

func (Worker) Terminate

func (parseW Worker) Terminate() error

type WorkerMessage

type WorkerMessage struct {
	ID      string `json:"id"`
	Phase   string `json:"phase"`
	Name    string `json:"name"`
	Payload any    `json:"payload"`
	Error   string `json:"error,omitempty"`
	Ports   []MessagePort
}

type WorkerOptions

type WorkerOptions struct {
	URL          string
	Name         string
	Type         string
	Ready        bool
	ReadyTimeout time.Duration
}

type WorkerPool

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

WorkerPool routes request-style jobs across a fixed worker set with bounded queueing and explicit shutdown controls.

func OpenWorkerPool

func OpenWorkerPool(parseCtx context.Context, parseOptions WorkerPoolOptions) (WorkerPool, error)

OpenWorkerPool creates a fixed-size worker pool with bounded queueing on top of the existing worker request surface.

func (WorkerPool) Close

func (parseP WorkerPool) Close() error

Close stops accepting work, terminates the worker set, and causes active or queued requests to fail promptly.

func (WorkerPool) Drain

func (parseP WorkerPool) Drain(parseCtx context.Context) error

Drain stops accepting new requests, waits for accepted work to finish, and then terminates the worker set.

func (WorkerPool) GetQueueLimit deprecated

func (parseP WorkerPool) GetQueueLimit() int

GetQueueLimit returns the configured number of queued requests allowed in addition to the running worker count.

Deprecated: use QueueLimit.

func (WorkerPool) GetSize deprecated

func (parseP WorkerPool) GetSize() int

GetSize returns the configured worker count for the pool.

Deprecated: use Size (the Get prefix is inconsistent with the package's other accessors).

func (WorkerPool) QueueLimit

func (parseP WorkerPool) QueueLimit() int

QueueLimit returns the configured number of queued requests allowed in addition to the running worker count.

func (WorkerPool) Request

func (parseP WorkerPool) Request(parseCtx context.Context, parseName string, parsePayload any, parseOnProgress func(WorkerMessage, error)) (WorkerMessage, error)

Request submits one job to the pool and waits for its final worker result.

func (WorkerPool) Size

func (parseP WorkerPool) Size() int

Size returns the configured worker count for the pool. (Named without a Get prefix to match the rest of the package's accessors — Name/Transport/Backend/Len/Closed.)

type WorkerPoolOptions

type WorkerPoolOptions struct {
	Size       int
	QueueLimit int
	OpenWorker func(context.Context) (Worker, error)
}

WorkerPoolOptions configures a fixed-size pool of request-capable workers.

type WorkerRequester

type WorkerRequester interface {
	Request(context.Context, string, any, func(WorkerMessage, error)) (WorkerMessage, error)
}

WorkerRequester defines the request-capable worker surface shared by single workers and worker pools.

type WorkerScope

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

func GetWorkerScope

func GetWorkerScope() (WorkerScope, error)

GetWorkerScope is a non-browser stub that always returns an unavailable error.

func (WorkerScope) Error

func (parseW WorkerScope) Error(parseId string, parseName string, parseErrText string, parsePayload any) error

func (WorkerScope) Message

func (parseW WorkerScope) Message(parseName string, parsePayload any) error

func (WorkerScope) Post

func (parseW WorkerScope) Post(parseMessage WorkerMessage) error

func (WorkerScope) PostPorts

func (parseW WorkerScope) PostPorts(parseMessage WorkerMessage, parsePorts ...MessagePort) error

PostPorts sends a worker-scope message together with transferred MessagePorts.

func (WorkerScope) Progress

func (parseW WorkerScope) Progress(parseId string, parseName string, parsePayload any) error

func (WorkerScope) Ready

func (parseW WorkerScope) Ready(parseName string) error

func (WorkerScope) Result

func (parseW WorkerScope) Result(parseId string, parseName string, parsePayload any) error

func (WorkerScope) Subscribe

func (parseW WorkerScope) Subscribe(parseHandler func(WorkerMessage, error)) (Subscription, error)

Jump to

Keyboard shortcuts

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