doors

package module
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: AGPL-3.0 Imports: 0 Imported by: 0

README

codecov Go Report Card Go Reference

Doors

Doors is a server-driven UI runtime for building reactive web applications in Go.

In Doors, the server owns the interaction flow and the browser acts as a renderer and input layer. You build interactive UI in Go, keep state and capabilities on the server, and let the runtime synchronize updates back to the page.

Example

type Search struct {
    input doors.Source[string] // reactive state
}

elem (s Search) Main() {
    <input
        (doors.AInput{
            On: func(ctx context.Context, r doors.RequestInput) bool {
                s.input.Update(ctx, r.Event().Value) // update state
                return false
            },
        })
        type="text"
        placeholder="search">

    ~(doors.Sub(s.input, s.results)) // subscribe results to state changes
}

elem (s Search) results(input string) {
    ~(for _, user := range Users.Search(input) {
        <card>
            ~(user.Name)
        </card>
    })
}

What it includes

  • Reactive web applications written in Go
  • A stack with no public or hand-written API
  • JavaScript as an option, not a requirement
  • Asset serving and delivery that fit a single-binary deployment model
  • Real-time capabilities out of the box
  • A Go language extension with first-class HTML templating and its own language server

Core model

Doors applications run on a stateful Go server. The browser acts as a remote renderer and input layer.

That means you can keep:

  • event handling
  • permissions
  • business rules
  • data access
  • UI rendering

in one execution flow instead of splitting them between browser code, handlers, API contracts, and state reassembly.

Your Go server is the UI runtime

In Doors, the web app runs as a stateful Go process. The browser acts as a remote renderer and input layer, while application flow, state, and side effects stay on the server.

Less drift between UI and backend logic

Because interactions are handled in Go, you do not have to split core behavior across separate frontend and backend implementations. That reduces duplication and makes changes more consistent.

Smaller exposed surface area

Doors does not turn every UI action into a public API endpoint. Session-scoped communication happens internally, so the client only gets rendered output and user-specific interaction paths.

Designed as a cohesive stack

From template syntax and concurrency engine to synchronization protocol — each layer was designed together to max out.

Key ideas

  • gox for writing HTML-like UI directly as Go expressions
  • Reactive state primitives that can be subscribed to, derived, and mutated
  • Dynamic containers that can be updated, replaced, or removed at runtime
  • Type-safe routing with URLs represented as Go structs
  • Real-time client sync without making WebSockets or SSE your app architecture
  • Secure by default — every user can interact only with what you render to them

Where Doors fits best

  • SaaS products
  • Business systems
  • Customer portals
  • Admin panels
  • Internal tools
  • Real-time apps with meaningful server-side workflows

Where it is not the right fit

  • Static or mostly non-interactive sites
  • Client-first apps with minimal server behavior
  • Offline-first PWAs where the browser must be the primary runtime

Comparisons

Doors vs HTMX

HTMX enhances HTML by coordinating behavior through attributes and endpoints. Doors is a UI runtime: you write the interaction flow directly in Go and let the runtime handle synchronization.

Doors vs React, Next.js, and similar stacks

Typical JavaScript stacks place much of the interaction model in the browser while the server acts mainly as a data service. Doors keeps that flow on the server in Go, with the browser focused on display and input.

Learn more

Status

Doors is in beta. It is ready for development and can be used in production with care, but the ecosystem is still maturing. Expect fixes, refinements, and some breaking changes as it evolves.

Licensing

Doors is dual-licensed by doors dev LLC.

  • Open-source use: available under AGPL-3.0-only
  • Commercial use: required for proprietary / closed-source use or other use that cannot comply with AGPL-3.0-only
  • Commercial licensing details: doors.dev/license

Commercial licenses are issued through an Order Form and a separate commercial agreement. The signed agreement controls.

Contact: sales@doors.dev

See also:

Documentation

Overview

Package doors builds server-rendered web apps with typed routing, reactive state, and server-handled browser interactions.

Most apps start with NewRouter, register one or more page models with UseModel, and render dynamic fragments with Door, Source, and Beam. Event attrs such as AClick, ASubmit, and ALink connect DOM events, forms, and navigation to Go handlers while still producing regular HTML.

For a guided introduction, see the documents embedded in DocsFS.

Index

Examples

Constants

This section is empty.

Variables

View Source
var DocsFS embed.FS

DocsFS is the embedded documentation tree for internal purposes.

Functions

func Call

func Call(ctx context.Context, action Action) context.CancelFunc

Call dispatches action to the client and returns a best-effort cancel function.

func Free

func Free(ctx context.Context) context.Context

Free returns a context that is safe to use with extended Doors operations that may wait for asynchronous completion, such as X-prefixed methods, and with long-running goroutines tied to the page runtime.

The returned context keeps the original Values from ctx, but uses the root Doors context for framework features such as beam reads/subscriptions and uses the instance runtime for cancellation, deadline, and lifetime.

func Go

func Go(f func(context.Context)) gox.Editor

Go starts f when the surrounding component is rendered.

The passed context is canceled when the dynamic owner is unmounted, which makes Go a good fit for background loops that should stop with the page. The context is also equivalent to calling Free on the surrounding context, so it is safe to use with X* operations and other long-running runtime work.

Example:

@doors.Go(func(ctx context.Context) {
    for {
        select {
        case <-time.After(time.Second):
            door.Update(ctx, currentTime())
        case <-ctx.Done():
            return
        }
    }
})

func IDBytes

func IDBytes(b []byte) string

IDBytes returns a stable URL-safe identifier derived from b.

func IDRand

func IDRand() string

IDRand returns a cryptographically secure, URL-safe identifier.

func IDString

func IDString(string string) string

IDString returns a stable URL-safe identifier derived from string.

func Inject

func Inject[T any](key any, beam Beam[T]) gox.Proxy

Inject renders el with the latest beam value stored in the child context under key.

Example:

~>doors.Inject("user", userBeam) <section>
	~{
		user := ctx.Value("user").(User)
	}
	<span>~(user.Name)</span>
</section>

func InstanceEnd

func InstanceEnd(ctx context.Context)

InstanceEnd ends the current instance (tab/window) but keeps the session and other instances active.

func InstanceId

func InstanceId(ctx context.Context) string

InstanceId returns the unique ID of the current instance. Useful for logging, debugging, and tracking connections.

func SessionEnd

func SessionEnd(ctx context.Context)

SessionEnd immediately ends the current session and all instances. Use it during logout to close authorized pages and free server resources.

func SessionExpire

func SessionExpire(ctx context.Context, d time.Duration)

SessionExpire sets the maximum lifetime of the current session.

func SessionId

func SessionId(ctx context.Context) string

SessionId returns the unique ID of the current session. All instances in the same browser share this ID via a session cookie.

func Status

func Status(statusCode int) gox.Editor

Status sets the initial HTTP status code for the current page render.

Example:

~(doors.Status(http.StatusNotFound))

func Sub

func Sub[T any](beam Beam[T], el func(T) gox.Elem) gox.EditorComp

Sub renders a dynamic fragment driven by beam.

It subscribes to beam and re-renders the inner content whenever the value changes. Returning nil from el clears the fragment.

Example:

elem demo(beam Beam[int]) {
	~(doors.Sub(beam, elem(v int) {
		<span>~(v)</span>
	}))
}

func UseCSP

func UseCSP(r Router, csp CSP)

UseCSP configures the Content-Security-Policy header for r.

func UseESConf

func UseESConf(r Router, conf ESConf)

UseESConf configures esbuild profiles used by script and style imports.

func UseErrorPage

func UseErrorPage(r Router, page func(l Location, err error) gox.Comp)

UseErrorPage renders page when Doors hits an internal routing, instance, or rendering error.

func UseFallback

func UseFallback(r Router, handler http.Handler)

UseFallback sends unmatched requests to handler.

This is useful when Doors is mounted inside a larger HTTP server.

func UseLicence

func UseLicence(r Router, license string)

UseLicence is an alias of UseLicense.

func UseLicense

func UseLicense(r Router, license string)

UseLicense stores a license string on the managed Doors client script. When omitted, the client prints the AGPL notice. You can purchase suitable license at https://doors.dev or via email sales@doors.dev

func UseModel

func UseModel[M any](r Router, handler func(r RequestModel, s Source[M]) Response)

UseModel registers a page model and its handler on r.

The model type M defines matching and URL generation through `path` and `query` struct tags. The handler receives the request metadata and the current route as a Source.

Example:

type BlogPath struct {
	Home bool    `path:"/"`
	Post bool    `path:"/posts/:ID"`
	ID   int
	Tag  *string `query:"tag"`
}

doors.UseModel(router, func(r doors.RequestModel, s doors.Source[BlogPath]) doors.Response {
	return doors.ResponseComp(Page(s))
})

func UseRoute

func UseRoute(r Router, rt Route)

UseRoute adds rt to r before model-based page routing.

func UseServerID

func UseServerID(r Router, id string)

UseServerID sets the stable server identifier used in Doors-generated paths and cookies.

id must already be URL-safe.

func UseSessionCallback

func UseSessionCallback(r Router, callback SessionCallback)

UseSessionCallback registers session lifecycle callbacks on r.

func UseSystemConf

func UseSystemConf(r Router, conf SystemConf)

UseSystemConf applies conf to r after filling in Doors defaults.

func XCall

func XCall[T any](ctx context.Context, action Action) (<-chan CallResult[T], context.CancelFunc)

XCall dispatches action to the client and returns a result channel.

The channel closes without a value if the call is canceled. Do not wait on it during rendering. If you need to wait, do it in a hook, inside Go, or in your own goroutine with Free. T is the expected decoded payload type. For actions other than ActionEmit, json.RawMessage is usually the right choice.

Types

type ABlur

type ABlur struct {
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[FocusEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestFocus) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

ABlur prepares a blur event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (ABlur) Modify

func (b ABlur) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ABlur) Proxy

func (b ABlur) Proxy(cur gox.Cursor, elem gox.Elem) error

type AChange

type AChange struct {
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[ChangeEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestChange) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

AChange handles the browser `change` event.

Use it for committed values such as blur-triggered input changes or select changes.

func (AChange) Modify

func (p AChange) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AChange) Proxy

func (p AChange) Proxy(cur gox.Cursor, elem gox.Elem) error

type AClick

type AClick struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

AClick prepares a click event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.

func (AClick) Modify

func (p AClick) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AClick) Proxy

func (p AClick) Proxy(cur gox.Cursor, elem gox.Elem) error

type AData

type AData struct {
	// Name of the data entry to read via JavaScript with $data(name).
	// Required.
	Name string
	// Value to expose to the client. Marshaled to JSON.
	// Required.
	Value any
}

AData exposes Value to browser code through `$data(name)`.

`$data(...)` returns strings and JSON-backed values directly. For `[]byte`, it returns a promise that resolves to an `ArrayBuffer`.

func (AData) Modify

func (a AData) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AData) Proxy

func (a AData) Proxy(cur gox.Cursor, elem gox.Elem) error

type AFocus

type AFocus struct {
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[FocusEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestFocus) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

AFocus prepares a focus event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (AFocus) Modify

func (f AFocus) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AFocus) Proxy

func (f AFocus) Proxy(cur gox.Cursor, elem gox.Elem) error

type AFocusIn

type AFocusIn struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[FocusEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestFocus) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

AFocusIn prepares a focusin event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (AFocusIn) Modify

func (f AFocusIn) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AFocusIn) Proxy

func (f AFocusIn) Proxy(cur gox.Cursor, elem gox.Elem) error

type AFocusOut

type AFocusOut struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[FocusEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestFocus) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

AFocusOut prepares a focusout event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (AFocusOut) Modify

func (f AFocusOut) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AFocusOut) Proxy

func (f AFocusOut) Proxy(cur gox.Cursor, elem gox.Elem) error

type AGotPointerCapture

type AGotPointerCapture struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

AGotPointerCapture prepares a gotpointercapture event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (AGotPointerCapture) Modify

func (p AGotPointerCapture) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AGotPointerCapture) Proxy

func (p AGotPointerCapture) Proxy(cur gox.Cursor, elem gox.Elem) error

type AHook

type AHook[T any] struct {
	// Name of the hook to call from JavaScript via $hook(name, ...).
	// Required.
	Name string
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Backend handler for the hook.
	// Receives typed input (T, unmarshaled from JSON) through RHook,
	// and returns any output which will be marshaled to JSON.
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(ctx context.Context, r RequestHook[T]) (any, bool)
}

AHook exposes a named Go handler to the browser through `$hook(name, ...)`.

Input data is unmarshaled from JSON into type T. The returned value is encoded back to JSON.

func (AHook[T]) Modify

func (h AHook[T]) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AHook[T]) Proxy

func (h AHook[T]) Proxy(cur gox.Cursor, elem gox.Elem) error

type AInput

type AInput struct {
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[InputEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestInput) bool
	// If true, does not include value in event
	// Optional.
	ExcludeValue bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

AInput handles the browser `input` event.

Use it for live updates while the user is still editing a value.

func (AInput) Modify

func (p AInput) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AInput) Proxy

func (p AInput) Proxy(cur gox.Cursor, elem gox.Elem) error

type AKeyDown

type AKeyDown struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Filters by event.key if provided.
	// Optional.
	Filter []string
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Backend event handler.
	// Receives a typed REvent[KeyboardEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestKeyboard) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
	// Actions to run before the hook request.
	// Optional.
	Before []Action
}

AKeyDown prepares a key down event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (AKeyDown) Modify

func (k AKeyDown) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AKeyDown) Proxy

func (k AKeyDown) Proxy(cur gox.Cursor, elem gox.Elem) error

type AKeyUp

type AKeyUp struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Filters by event.key if provided.
	// Optional.
	Filter []string
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Backend event handler.
	// Receives a typed REvent[KeyboardEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestKeyboard) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
	// Actions to run before the hook request.
	// Optional.
	Before []Action
}

AKeyUp prepares a key up event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (AKeyUp) Modify

func (k AKeyUp) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AKeyUp) Proxy

func (k AKeyUp) Proxy(cur gox.Cursor, elem gox.Elem) error
type ALink struct {
	// Target path model value. Required.
	Model any
	// Fragment identifier
	// Optional
	Fragment string
	// Active link indicator configuration. Optional.
	Active Active
	// Stop event propagation (for dynamic links). Optional.
	StopPropagation bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running
	// (for dynamic links). Optional.
	Indicator []Indicator
	// Actions to run before the hook request (for dynamic links). Optional.
	Before []Action
	// Actions to run after the hook request (for dynamic links). Optional.
	After []Action
	// Actions to run on error (for dynamic links).
	// Default (nil) triggers a location reload.
	OnError []Action
}

ALink builds a real `href` from Model and, when possible, upgrades the link to same-model client navigation.

Example:

attrs := doors.A(ctx, doors.ALink{
	Model: Path{Home: true},
})

func (ALink) Modify

func (h ALink) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ALink) Proxy

func (h ALink) Proxy(cur gox.Cursor, elem gox.Elem) error

type ALostPointerCapture

type ALostPointerCapture struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

ALostPointerCapture prepares a lostpointercapture event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (ALostPointerCapture) Modify

func (p ALostPointerCapture) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ALostPointerCapture) Proxy

func (p ALostPointerCapture) Proxy(cur gox.Cursor, elem gox.Elem) error

type APointerCancel

type APointerCancel struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

APointerCancel prepares a pointer cancel event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (APointerCancel) Modify

func (p APointerCancel) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerCancel) Proxy

func (p APointerCancel) Proxy(cur gox.Cursor, elem gox.Elem) error

type APointerDown

type APointerDown struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

APointerDown prepares a pointer down event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.

func (APointerDown) Modify

func (p APointerDown) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerDown) Proxy

func (p APointerDown) Proxy(cur gox.Cursor, elem gox.Elem) error

type APointerEnter

type APointerEnter struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

APointerEnter prepares a pointer enter event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (APointerEnter) Modify

func (p APointerEnter) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerEnter) Proxy

func (p APointerEnter) Proxy(cur gox.Cursor, elem gox.Elem) error

type APointerLeave

type APointerLeave struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

APointerLeave prepares a pointer leave event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (APointerLeave) Modify

func (p APointerLeave) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerLeave) Proxy

func (p APointerLeave) Proxy(cur gox.Cursor, elem gox.Elem) error

type APointerMove

type APointerMove struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

APointerMove prepares a pointer move event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.

func (APointerMove) Modify

func (p APointerMove) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerMove) Proxy

func (p APointerMove) Proxy(cur gox.Cursor, elem gox.Elem) error

type APointerOut

type APointerOut struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

APointerOut prepares a pointer out event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.

func (APointerOut) Modify

func (p APointerOut) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerOut) Proxy

func (p APointerOut) Proxy(cur gox.Cursor, elem gox.Elem) error

type APointerOver

type APointerOver struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

APointerOver prepares a pointer over event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.

func (APointerOver) Modify

func (p APointerOver) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerOver) Proxy

func (p APointerOver) Proxy(cur gox.Cursor, elem gox.Elem) error

type APointerUp

type APointerUp struct {
	// If true, stops the event from bubbling up the DOM.
	// Optional.
	StopPropagation bool
	// If true, prevents the browser's default action for the event.
	// Optional.
	PreventDefault bool
	// If true, only fires when the event occurs on this element itself.
	// Optional.
	ExactTarget bool
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend event handler.
	// Receives a typed REvent[PointerEvent].
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestPointer) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

APointerUp prepares a pointer up event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.

func (APointerUp) Modify

func (p APointerUp) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (APointerUp) Proxy

func (p APointerUp) Proxy(cur gox.Cursor, elem gox.Elem) error

type ARawHook

type ARawHook struct {
	// Name of the hook to call from JavaScript via $hook(name, ...).
	// Required.
	Name string
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Backend handler for the hook.
	// Provides raw access via RRawHook (body reader, multipart parser).
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(ctx context.Context, r RequestRawHook) bool
}

ARawHook exposes a named Go handler to the browser through `$hook(name, ...)` without JSON decoding or encoding.

Use it for streaming, custom protocols, or file uploads.

func (ARawHook) Modify

func (h ARawHook) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ARawHook) Proxy

func (h ARawHook) Proxy(cur gox.Cursor, elem gox.Elem) error

type ARawSubmit

type ARawSubmit struct {
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend form handler.
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestRawForm) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

ARawSubmit handles a form submission with raw multipart access.

func (ARawSubmit) Modify

func (s ARawSubmit) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ARawSubmit) Proxy

func (s ARawSubmit) Proxy(cur gox.Cursor, elem gox.Elem) error

type AShared

type AShared = *aShared

AShared is a reusable dynamic attribute handle shared across every element it is attached to.

func NewAShared

func NewAShared(name string, value string) AShared

NewAShared returns an enabled shared attribute handle.

Update, Enable, and Disable affect every attached element together.

func (AShared) Disable

func (a AShared) Disable(ctx context.Context)

Disable removes the attribute from attached elements.

func (AShared) Enable

func (a AShared) Enable(ctx context.Context)

Enable adds the attribute to attached elements.

func (AShared) Modify

func (a AShared) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (AShared) Proxy

func (a AShared) Proxy(cur gox.Cursor, elem gox.Elem) error

func (AShared) Update

func (a AShared) Update(ctx context.Context, value string)

Update sets the attribute's value.

type ASubmit

type ASubmit[T any] struct {
	// MaxMemory sets the maximum number of bytes to parse into memory.
	// It is passed to ParseMultipartForm.
	// Defaults to 8 MB if zero.
	MaxMemory int
	// Defines how the hook is scheduled (e.g. blocking, debounce).
	// Optional.
	Scope []Scope
	// Visual indicators while the hook is running.
	// Optional.
	Indicator []Indicator
	// Actions to run before the hook request.
	// Optional.
	Before []Action
	// Backend form handler.
	// Should return true when the hook is complete and can be removed.
	// Required.
	On func(context.Context, RequestForm[T]) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

ASubmit handles a form submission by decoding it into T with go-playground/form.

func (ASubmit[V]) Modify

func (s ASubmit[V]) Modify(ctx context.Context, _ string, attrs gox.Attrs) error

func (ASubmit[V]) Proxy

func (s ASubmit[V]) Proxy(cur gox.Cursor, elem gox.Elem) error

type Action

type Action interface {
	// contains filtered or unexported methods
}

Action performs a client-side operation.

func ActionOnlyEmit

func ActionOnlyEmit(name string, arg any) []Action

ActionOnlyEmit returns a single ActionEmit.

func ActionOnlyIndicate

func ActionOnlyIndicate(indicator []Indicator, duration time.Duration) []Action

ActionOnlyIndicate returns a single ActionIndicate.

func ActionOnlyLocationAssign

func ActionOnlyLocationAssign(model any) []Action

ActionOnlyLocationAssign returns a single ActionLocationAssign.

func ActionOnlyLocationRawAssign

func ActionOnlyLocationRawAssign(url string) []Action

ActionOnlyLocationRawAssign returns a single ActionLocationRawAssign.

func ActionOnlyLocationReload

func ActionOnlyLocationReload() []Action

ActionOnlyLocationReload returns a single ActionLocationReload.

func ActionOnlyLocationReplace

func ActionOnlyLocationReplace(model any) []Action

ActionOnlyLocationReplace returns a single ActionLocationReplace.

func ActionOnlyScroll

func ActionOnlyScroll(selector string) []Action

ActionOnlyScroll returns a single ActionScroll with default scroll behavior.

type ActionEmit

type ActionEmit struct {
	Name string
	Arg  any
}

ActionEmit invokes a client-side handler registered with `$on(name, handler)`.

type ActionIndicate

type ActionIndicate struct {
	Indicator []Indicator
	Duration  time.Duration
}

ActionIndicate applies indicators for Duration.

type ActionLocationAssign

type ActionLocationAssign struct {
	Model any
}

ActionLocationAssign navigates to a model-derived URL.

type ActionLocationRawAssign

type ActionLocationRawAssign struct {
	URL string
}

ActionLocationRawAssign navigates to url without first encoding a path model.

type ActionLocationReload

type ActionLocationReload struct{}

ActionLocationReload reloads the current page.

type ActionLocationReplace

type ActionLocationReplace struct {
	Model any
}

ActionLocationReplace replaces the current history entry with a model-derived URL.

type ActionScroll

type ActionScroll struct {
	// CSS selector for the element to scroll into view.
	Selector string
	// Browser scroll options forwarded to `scrollIntoView(...)`.
	Options any
}

ActionScroll scrolls the first element matching Selector into view.

Options is passed to the browser scroll call as-is and should match the shape accepted by `Element.scrollIntoView(...)`, for example: `map[string]any{"behavior": "smooth", "block": "center"}`.

type Active

type Active struct {
	// Path match strategy
	PathMatcher PathMatcher
	// Query param match strategy, applied sequentially.
	QueryMatcher []QueryMatcher
	// Match fragment, false by default
	FragmentMatch bool
	// Indicators to apply when active
	Indicator []Indicator
}

Active configures how ALink marks itself as active.

type Attr

type Attr interface {
	gox.Modify
	gox.Proxy
}

Attr is a Doors attribute modifier that can be attached directly to an element or applied through a proxy component.

func A

func A(ctx context.Context, a ...Attr) Attr

A combines one or more Attr values into a single modifier.

Example:

attrs := doors.A(ctx,
	doors.AClick{On: onClick},
	doors.AData{Name: "user", Value: user},
)

type Beam

type Beam[T any] = beam.Beam[T]

Beam is a read-only reactive value.

Use a Beam to read, subscribe to, or derive a smaller view of state. During one render/update cycle, a Door subtree observes one consistent value for the same beam.

func NewBeam

func NewBeam[T any, T2 comparable](source Beam[T], cast func(T) T2) Beam[T2]

NewBeam derives a Beam from source and uses `==` to suppress equal derived values.

Example:

fullName := doors.NewBeam(user, func(u User) string {
	return u.FirstName + " " + u.LastName
})

func NewBeamEqual

func NewBeamEqual[T any, T2 any](source Beam[T], cast func(T) T2, equal func(new T2, old T2) bool) Beam[T2]

NewBeamEqual derives a Beam from source with a custom equality function.

equal should report whether new and old should be treated as equal and therefore not propagated. If equal is nil, every derived value propagates.

type CSP

type CSP = common.CSP

CSP configures the Content-Security-Policy header generated by Doors.

type CallResult

type CallResult[T any] struct {
	Ok  T     // Result value
	Err error // Error if the call failed
}

CallResult holds the outcome of an XCall. Either Ok is set with the result, or Err is non-nil.

type ChangeEvent

type ChangeEvent = front.ChangeEvent

ChangeEvent is the payload sent to AChange handlers.

type Door

type Door = door.Door

Door is a dynamic placeholder in the DOM tree that can be updated, replaced, or removed after render.

Doors start inactive and become active when rendered. Operations on an inactive door are stored virtually and applied when the door becomes active. If a door is removed or replaced, it becomes inactive again, but operations continue to update that virtual state for future rendering.

The context used while rendering a door's content follows the door's lifecycle, which makes `ctx.Done()` safe to use in background goroutines that depend on the door staying mounted.

X-prefixed methods return a channel that reports completion. For inactive doors, that channel closes immediately without sending a value.

type ESConf

type ESConf = resources.BuildProfiles

ESConf provides named esbuild profiles for script and style processing.

type ESOptions

type ESOptions struct {
	External []string
	Minify   bool
	JSX      JSX
}

ESOptions is a simple ESConf implementation for one build profile.

func (ESOptions) Options

func (opt ESOptions) Options(_profile string) api.BuildOptions

Options implements ESConf.

type FocusEvent

type FocusEvent = front.FocusEvent

FocusEvent is the payload sent to focus event handlers.

type HrefActiveMatch

type HrefActiveMatch int

HrefActiveMatch describes a path matching strategy for active links.

const (
	// MatchFull requires the entire path to match.
	MatchFull HrefActiveMatch = iota
	// MatchPath requires the same path but ignores the query.
	MatchPath
	// MatchStarts requires the current path to start with the target path.
	MatchStarts
)

type Indicator

type Indicator = front.Indicator

Indicator is a temporary DOM change applied on the client.

Indicators are commonly used for pending states such as "Loading..." text, temporary classes, or transient attributes while a request is in flight.

func IndicatorOnlyAttr

func IndicatorOnlyAttr(attr string, value string) []Indicator

IndicatorOnlyAttr sets an attribute on the event target element.

func IndicatorOnlyAttrQuery

func IndicatorOnlyAttrQuery(query string, attr string, value string) []Indicator

IndicatorOnlyAttrQuery sets an attribute on the first element matching a CSS query.

func IndicatorOnlyAttrQueryAll

func IndicatorOnlyAttrQueryAll(query string, attr string, value string) []Indicator

IndicatorOnlyAttrQueryAll sets an attribute on all elements matching a CSS query.

func IndicatorOnlyAttrQueryParent

func IndicatorOnlyAttrQueryParent(query string, attr string, value string) []Indicator

IndicatorOnlyAttrQueryParent sets an attribute on the closest ancestor matching a CSS query.

func IndicatorOnlyClass

func IndicatorOnlyClass(class string) []Indicator

IndicatorOnlyClass adds classes to the event target element.

func IndicatorOnlyClassQuery

func IndicatorOnlyClassQuery(query string, class string) []Indicator

IndicatorOnlyClassQuery adds classes to the first element matching a CSS query.

func IndicatorOnlyClassQueryAll

func IndicatorOnlyClassQueryAll(query string, class string) []Indicator

IndicatorOnlyClassQueryAll adds classes to all elements matching a CSS query.

func IndicatorOnlyClassQueryParent

func IndicatorOnlyClassQueryParent(query string, class string) []Indicator

IndicatorOnlyClassQueryParent adds classes to the closest ancestor matching a CSS query.

func IndicatorOnlyClassRemove

func IndicatorOnlyClassRemove(class string) []Indicator

IndicatorOnlyClassRemove removes classes from the event target element.

func IndicatorOnlyClassRemoveQuery

func IndicatorOnlyClassRemoveQuery(query string, class string) []Indicator

IndicatorOnlyClassRemoveQuery removes classes from the first element matching a CSS query.

func IndicatorOnlyClassRemoveQueryAll

func IndicatorOnlyClassRemoveQueryAll(query string, class string) []Indicator

IndicatorOnlyClassRemoveQueryAll removes classes from all elements matching a CSS query.

func IndicatorOnlyClassRemoveQueryParent

func IndicatorOnlyClassRemoveQueryParent(query string, class string) []Indicator

IndicatorOnlyClassRemoveQueryParent removes classes from the closest ancestor matching a CSS query.

func IndicatorOnlyContent

func IndicatorOnlyContent(content string) []Indicator

IndicatorOnlyContent sets content on the event target element.

func IndicatorOnlyContentQuery

func IndicatorOnlyContentQuery(query string, content string) []Indicator

IndicatorOnlyContentQuery sets content on the first element matching a CSS query.

func IndicatorOnlyContentQueryAll

func IndicatorOnlyContentQueryAll(query string, content string) []Indicator

IndicatorOnlyContentQueryAll sets content on all elements matching a CSS query.

func IndicatorOnlyContentQueryParent

func IndicatorOnlyContentQueryParent(query string, content string) []Indicator

IndicatorOnlyContentQueryParent sets content on the closest ancestor matching a CSS query.

type IndicatorAttr

type IndicatorAttr struct {
	Selector Selector // Target element
	Name     string   // Attribute name
	Value    string   // Attribute value
}

IndicatorAttr temporarily sets an attribute on the selected element.

func (IndicatorAttr) Indicate

func (c IndicatorAttr) Indicate() indicate

type IndicatorClass

type IndicatorClass struct {
	Selector Selector // Target element
	Class    string   // Space-separated classes
}

IndicatorClass temporarily adds CSS classes to the selected element.

func (IndicatorClass) Indicate

func (c IndicatorClass) Indicate() indicate

type IndicatorClassRemove

type IndicatorClassRemove struct {
	Selector Selector // Target element
	Class    string   // Space-separated classes
}

IndicatorClassRemove temporarily removes CSS classes from the selected element.

func (IndicatorClassRemove) Indicate

func (c IndicatorClassRemove) Indicate() indicate

type IndicatorContent

type IndicatorContent struct {
	Selector Selector // Target element
	Content  string   // Replacement content
}

IndicatorContent temporarily replaces the selected element's inner HTML.

func (IndicatorContent) Indicate

func (c IndicatorContent) Indicate() indicate

type InputEvent

type InputEvent = front.InputEvent

InputEvent is the payload sent to AInput handlers.

type JSX

type JSX struct {
	JSX          api.JSX
	Factory      string
	ImportSource string
	Fragment     string
	SideEffects  bool
	Dev          bool
}

JSX configures how esbuild should transform JSX input.

func JSXPreact

func JSXPreact() JSX

JSXPreact returns JSX settings suitable for classic Preact transforms.

func JSXReact

func JSXReact() JSX

JSXReact returns JSX settings suitable for React's automatic runtime.

type KeyboardEvent

type KeyboardEvent = front.KeyboardEvent

KeyboardEvent is the payload sent to keyboard event handlers.

type Location

type Location = path.Location

Location is a parsed or generated URL path plus query string.

Example
loc := Location{
	Segments: []string{"posts", "42"},
	Query: url.Values{
		"tag":  []string{"go"},
		"page": []string{"2"},
	},
}

fmt.Println(loc.String())
Output:

/posts/42?page=2&tag=go

func NewLocation

func NewLocation(ctx context.Context, model any) (Location, error)

NewLocation encodes model into a Location using the registered adapter for the model's type. It returns an error if no adapter is registered or encoding fails.

type ParsedForm

type ParsedForm interface {
	// FormValues returns all parsed form values.
	FormValues() url.Values
	// FormValue returns the first value for the given key.
	FormValue(key string) string
	// FormFile returns the uploaded file for the given key.
	FormFile(key string) (multipart.File, *multipart.FileHeader, error)
	// Form returns the underlying multipart.Form.
	Form() *multipart.Form
}

ParsedForm exposes parsed multipart form values and files.

type PathMatcher

type PathMatcher interface {
	// contains filtered or unexported methods
}

PathMatcher customizes how the path participates in active-link matching.

func PathMatcherFull

func PathMatcherFull() PathMatcher

PathMatcherFull matches the full generated path.

func PathMatcherSegments

func PathMatcherSegments(i ...int) PathMatcher

PathMatcherSegments matches only the listed path segment indexes (zero-based).

func PathMatcherStarts

func PathMatcherStarts() PathMatcher

PathMatcherStarts matches when the current path starts with the link path.

type PointerEvent

type PointerEvent = front.PointerEvent

PointerEvent is the payload sent to pointer event handlers.

type QueryMatcher

type QueryMatcher interface {
	// contains filtered or unexported methods
}

QueryMatcher customizes how query parameters participate in active-link matching.

func QueryMatcherIfPresent

func QueryMatcherIfPresent(params ...string) QueryMatcher

QueryMatcherIfPresent matches the given parameters only if they are present.

func QueryMatcherIgnoreAll

func QueryMatcherIgnoreAll() QueryMatcher

QueryMatcherIgnoreAll excludes all remaining query parameters from comparison.

func QueryMatcherIgnoreSome

func QueryMatcherIgnoreSome(params ...string) QueryMatcher

QueryMatcherIgnoreSome excludes the given query parameters from comparison.

func QueryMatcherOnlyIfPresent

func QueryMatcherOnlyIfPresent(params ...string) []QueryMatcher

QueryMatcherOnlyIfPresent matches the given parameters if present and ignores all others.

func QueryMatcherOnlyIgnoreAll

func QueryMatcherOnlyIgnoreAll() []QueryMatcher

QueryMatcherOnlyIgnoreAll ignores all query parameters.

func QueryMatcherOnlyIgnoreSome

func QueryMatcherOnlyIgnoreSome(params ...string) []QueryMatcher

QueryMatcherOnlyIgnoreSome ignores the given parameters and matches all remaining.

func QueryMatcherOnlySome

func QueryMatcherOnlySome(params ...string) []QueryMatcher

QueryMatcherOnlySome matches the provided query parameters and ignores all others.

func QueryMatcherSome

func QueryMatcherSome(params ...string) QueryMatcher

QueryMatcherSome matches only the provided query parameters.

type Request

type Request interface {
	// SetCookie adds a cookie to the response.
	SetCookie(cookie *http.Cookie)
	// GetCookie retrieves a cookie by name.
	GetCookie(name string) (*http.Cookie, error)
}

Request exposes the common server-side request helpers available to Doors handlers.

type RequestAfter

type RequestAfter interface {
	// After appends client-side actions to the successful response.
	After([]Action) error
}

RequestAfter schedules client-side actions to run after a successful request.

type RequestChange

type RequestChange = RequestEvent[ChangeEvent]

RequestChange is the typed request passed to AChange handlers.

type RequestEvent

type RequestEvent[E any] interface {
	Request
	RequestAfter
	// Event returns the event payload.
	Event() E
}

RequestEvent is the request context passed to event handlers.

type RequestFocus

type RequestFocus = RequestEvent[FocusEvent]

RequestFocus is the typed request passed to focus event handlers.

type RequestForm

type RequestForm[D any] interface {
	Request
	RequestAfter
	// Data returns the parsed form payload.
	Data() D
}

RequestForm is the request context passed to decoded form handlers.

type RequestHook

type RequestHook[D any] interface {
	Request
	RequestAfter
	// Data returns the parsed hook payload.
	Data() D
}

RequestHook is the request context passed to typed JavaScript hook handlers.

type RequestInput

type RequestInput = RequestEvent[InputEvent]

RequestInput is the typed request passed to AInput handlers.

type RequestKeyboard

type RequestKeyboard = RequestEvent[KeyboardEvent]

RequestKeyboard is the typed request passed to keyboard event handlers.

type RequestModel

type RequestModel interface {
	Request
	// SessionStore returns session-scoped storage.
	SessionStore() Store
	// RequestHeader returns the incoming request headers.
	RequestHeader() http.Header
	// ResponseHeader returns the outgoing response headers.
	ResponseHeader() http.Header
}

RequestModel is the request context passed to UseModel handlers.

Use it for cookies, request and response headers, and session-scoped state while deciding which Response to return.

type RequestPointer

type RequestPointer = RequestEvent[PointerEvent]

RequestPointer is the typed request passed to pointer event handlers.

type RequestRawForm

type RequestRawForm interface {
	Request
	RequestAfter
	// W returns the HTTP response writer.
	W() http.ResponseWriter
	// Reader returns a multipart reader for streaming form parts.
	Reader() (*multipart.Reader, error)
	// ParseForm parses the form data with a memory limit.
	ParseForm(maxMemory int) (ParsedForm, error)
}

RequestRawForm is the request context passed to raw multipart form handlers.

type RequestRawHook

type RequestRawHook interface {
	RequestRawForm
	// Body returns the raw request body reader.
	Body() io.ReadCloser
}

RequestRawHook is the request context passed to raw JavaScript hook handlers.

type Resource

type Resource = printer.Source

Resource describes content or a URL that can be attached to HTML resource attributes and, when needed, hosted by Doors.

func ResourceExternal

func ResourceExternal(path string) Resource

ResourceExternal points at an already-hosted URL.

func ResourceHandler

func ResourceHandler(handler func(w http.ResponseWriter, r *http.Request)) Resource

ResourceHandler serves content through a standard library-style handler.

func ResourceHook

func ResourceHook(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request) bool) Resource

ResourceHook serves content through a custom handler.

Returning true tells Doors it may remove the generated private resource after the request.

func ResourceProxy

func ResourceProxy(url string) Resource

ResourceProxy reverse-proxies requests to url.

type ResourceStatic

type ResourceStatic = printer.SourceStatic

ResourceStatic is a Resource that can also be mounted at a stable public path with RouteResource.

func ResourceBytes

func ResourceBytes(content []byte) ResourceStatic

ResourceBytes serves content from content.

func ResourceFS

func ResourceFS(fsys fs.FS, entry string) ResourceStatic

ResourceFS serves one file from fsys.

func ResourceLocalFS

func ResourceLocalFS(path string) ResourceStatic

ResourceLocalFS serves one local file from path.

func ResourceString

func ResourceString(content string) ResourceStatic

ResourceString serves content from content.

type Response

type Response = model.Res

Response describes how a matched page model should be handled.

Use ResponseComp to render a page, ResponseRedirect to send an HTTP redirect, or ResponseReroute to hand the request to another registered model without redirecting the browser.

func ResponseComp

func ResponseComp(comp gox.Comp) Response

ResponseComp returns a Response that renders comp for the matched model.

func ResponseRedirect

func ResponseRedirect(m any, status int) Response

ResponseRedirect returns a Response that redirects to model.

status may be 0 to let Doors choose its default redirect status.

func ResponseReroute

func ResponseReroute(m any) Response

ResponseReroute returns a Response that resolves another registered model on the server without changing the current HTTP response into a redirect.

type Route

type Route = router.Route

Route handles a non-page GET endpoint inside a Router.

Use UseRoute for endpoints such as health checks, stable file mounts, or other GET handlers that should live beside model-based pages.

type RouteDir

type RouteDir struct {
	// URL prefix under which files are served.
	// Required.
	Prefix string
	// Filesystem directory path to serve.
	// Required.
	DirPath string
	// Cache-Control header applied to responses.
	// Optional.
	CacheControl string
}

RouteDir serves files from a local directory under Prefix.

func (RouteDir) Match

func (rt RouteDir) Match(r *http.Request) bool

func (RouteDir) Serve

func (rt RouteDir) Serve(w http.ResponseWriter, r *http.Request)

type RouteFS

type RouteFS struct {
	// URL prefix under which files are served.
	// Required.
	Prefix string
	// Filesystem to serve files from.
	// Required.
	FS fs.FS
	// Optional Cache-Control header applied to responses.
	// Optional.
	CacheControl string
}

RouteFS serves files from an fs.FS under Prefix.

func (RouteFS) Match

func (rt RouteFS) Match(r *http.Request) bool

func (RouteFS) Serve

func (rt RouteFS) Serve(w http.ResponseWriter, r *http.Request)

type RouteFile

type RouteFile struct {
	// URL path at which the file is served.
	// Required.
	Path string
	// Filesystem path to the file to serve.
	// Reuired.
	FilePath string
	// Cache-Control header applied to the response.
	// Optional.
	CacheControl string
}

RouteFile serves one local file at Path.

func (RouteFile) Match

func (rt RouteFile) Match(r *http.Request) bool

func (RouteFile) Serve

func (rt RouteFile) Serve(w http.ResponseWriter, r *http.Request)

type RouteResource

type RouteResource struct {
	// URL path at which the file is served.
	// Required.
	Path     string
	Resource ResourceStatic
	// ContentType header
	ContentType string
}

RouteResource serves one static ResourceStatic at a fixed public path.

Use it when you want a stable URL but still want Doors to prepare the resource through its registry.

func (RouteResource) Match

func (rt RouteResource) Match(r *http.Request) bool

func (RouteResource) Serve

func (rt RouteResource) Serve(w http.ResponseWriter, r *http.Request)

type Router

type Router interface {
	http.Handler
	// Count returns the current number of live sessions and live page
	// instances.
	Count() (sessions int, instances int)
	Use(r Use)
}

Router serves a Doors application over HTTP.

Use NewRouter to create one, register page models with UseModel, and then pass it to an HTTP server.

func NewRouter

func NewRouter() Router

NewRouter returns a router with the default Doors configuration.

Example:

router := doors.NewRouter()
doors.UseModel(router, func(r doors.RequestModel, s doors.Source[Path]) doors.Response {
	return doors.ResponseComp(Page(s))
})
Example
router := NewRouter()

UseModel(router, func(r RequestModel, s Source[examplePath]) Response {
	return ResponseRedirect(examplePath{Post: true, ID: 42}, http.StatusFound)
})

type Scope

type Scope = front.Scope

Scope controls how overlapping client-side events coordinate before the backend request starts.

func ScopeOnlyBlocking

func ScopeOnlyBlocking() []Scope

ScopeOnlyBlocking returns a single ScopeBlocking.

func ScopeOnlyDebounce

func ScopeOnlyDebounce(duration, limit time.Duration) []Scope

ScopeOnlyDebounce returns one debounced Scope.

func ScopeOnlyLatest

func ScopeOnlyLatest() []Scope

ScopeOnlyLatest returns a single ScopeLatest.

func ScopeOnlySerial

func ScopeOnlySerial() []Scope

ScopeOnlySerial returns a single ScopeSerial.

type ScopeBlocking

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

ScopeBlocking rejects a new event while another event in the same shared scope is still running.

func (*ScopeBlocking) Scope

func (b *ScopeBlocking) Scope(core core.Core) ScopeSet

type ScopeConcurrent

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

ScopeConcurrent allows overlap only for events that use the same group id.

func (*ScopeConcurrent) Scope

func (d *ScopeConcurrent) Scope(groupId int) Scope

Scope returns a concurrent Scope for groupId.

type ScopeDebounce

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

ScopeDebounce delays a burst of events and keeps the latest pending one.

func (*ScopeDebounce) Scope

func (d *ScopeDebounce) Scope(duration, limit time.Duration) Scope

Scope returns a debounced Scope.

duration is the resettable delay. limit is the maximum total wait; 0 means no maximum.

type ScopeFrame

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

ScopeFrame coordinates normal events with a barrier event.

Normal members use Scope(false). The barrier member uses Scope(true), waits for earlier members to finish, and then runs exclusively.

func (*ScopeFrame) Scope

func (d *ScopeFrame) Scope(frame bool) Scope

Scope returns a frame member or a frame barrier depending on frame.

type ScopeLatest

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

ScopeLatest keeps only the newest event in a shared scope. When a new event arrives, any currently processing event is canceled and the new event takes priority.

func (*ScopeLatest) Scope

func (b *ScopeLatest) Scope(core core.Core) ScopeSet

type ScopeSerial

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

ScopeSerial queues accepted events and runs them in arrival order.

func (*ScopeSerial) Scope

func (b *ScopeSerial) Scope(core core.Core) ScopeSet

type ScopeSet

type ScopeSet = front.ScopeSet

ScopeSet is the serialized form of a Scope.

type Selector

type Selector interface {
	// contains filtered or unexported methods
}

Selector chooses which DOM nodes an Indicator should target.

func SelectorQuery

func SelectorQuery(query string) Selector

SelectorQuery selects the first element matching query.

func SelectorQueryAll

func SelectorQueryAll(query string) Selector

SelectorQueryAll selects every element matching query.

func SelectorQueryParent

func SelectorQueryParent(query string) Selector

SelectorQueryParent selects the closest ancestor matching query.

func SelectorTarget

func SelectorTarget() Selector

SelectorTarget selects the element that triggered the event.

type SessionCallback

type SessionCallback = router.SessionCallback

SessionCallback observes session creation and removal.

type Source

type Source[T any] = beam.Source[T]

Source is a writable Beam.

Create a source with NewSource or NewSourceEqual, then derive smaller beams with NewBeam or NewBeamEqual. For reference types such as slices, maps, pointers, or mutable structs, replace the stored value instead of mutating it in place.

func NewSource

func NewSource[T comparable](init T) Source[T]

NewSource creates a Source that uses `==` to suppress equal updates.

Example:

count := doors.NewSource(0)
Example
count := NewSource(1)
label := NewBeam(count, func(v int) string {
	return fmt.Sprintf("count:%d", v)
})

fmt.Println(count.Get())
_ = label
Output:

1

func NewSourceEqual

func NewSourceEqual[T any](init T, equal func(new T, old T) bool) Source[T]

NewSourceEqual creates a Source with a custom equality function.

equal should report whether new and old should be treated as equal and therefore not propagated. If equal is nil, every update propagates.

type Store

type Store = ctex.Store

Store is goroutine-safe key-value storage used for session and instance state.

func InstanceStore

func InstanceStore(ctx context.Context) Store

InstanceStore returns storage scoped to the current instance only.

func SessionStore

func SessionStore(ctx context.Context) Store

SessionStore returns storage shared by all instances in the current session.

type SystemConf

type SystemConf = common.SystemConf

SystemConf configures router, instance, and transport behavior.

type Use

type Use = router.Use

Use configures a Router.

Jump to

Keyboard shortcuts

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