doors

package module
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

README

doors

Back-end UI Framework for feature-rich, secure, and fast web apps in Go.

⚠️ Beta - Not Ready for Production

Getting Started

  • See the Tutorial for building your first doors application.
  • Read the Docs to dive into details.
  • Check out the API Reference.

Philosophy

Explicid

Build direct connections between events, state, and HTML in a completely type-safe environment. It hits different.

Lightweight

Fast loading, non-blocking execution environment, minimal memory footprint

Server Centric

Business logic runs on the server, and the browser acts like a human I/O.

Straight

Native experience of classic MPA with natural reactive UI capabilities.

JS friendly

If you need - integration, bundling, and serving tools included.

How It Works

Stateful Server + Ultra-Thin Client

API-free architecture

  1. User loads page → Server creates instance and sets session cookie
  2. Server maintains state → Live representation of each user's page
  3. Persistent connection → Lightweight client syncs with server
  4. Events flow up → User interactions sent to Go handlers
  5. Updates flow down → Server sends specific DOM changes
Core Components

Door - Dynamic container in HTML where content can change:

  • Update, Replace, Remove, Clear, Reload operations
  • Form a tree structure, where each branch has its own lifecycle
  • Provides local context that can be used as an unmount hook.

Beam - Reactive state primitive on the server:

  • SourceBeam for mutable state
  • Derived beams for computed values
  • Respects the dynamic container tree, guaranteeing render consistency

Path Models - Type-safe routing through Go structs:

  • Declare multiple path variants (the matched field becomes true)
  • Use type-safe parameter capturing
  • Use splat parameter to capture the remaining path tail
  • Use almost any types for query parameters (go-playground/form under the hood)
Instance and Session Model
  • Each browser tab creates an instance (live server connection)
  • Multiple instances share a session (common state)
  • Navigation within same Path Model: reactive updates
  • Navigation to different Path Model: new instance created
Real-Time Sync Protocol
  • Client maintains a connection for synchronization via short-lived, handover HTTP requests
  • Works through proxies and firewalls
  • Takes advantage of QUIC
Event Handling
  • Secure session-scoped DOM event handeling in Go
  • Events as separate HTTP requests
  • Advanced concurrency control (blocking, debounce, and more)

When to use doors

Excellent for:

  • SaaS products
  • Business process automation (ERP, CRM, etc)
  • Administrative interfaces
  • Customer portals
  • Internal tools
  • Other form-heavy applications

Not ideal for:

  • Public marketing websites with minimal interactivity
  • Offline-first applications
  • Static content sites

Comparison

Unlike React/Vue: No business logic on the client side, no hydration, NPM-free.

Unlike htmx: Full type safety, reactive state, and programmatic control from Go.

Unlike Phoenix LiveView: Explicit update model, parallel rendering & non-blocking event handling and QUIC friendly

License

doors is source-available under the Business Source License 1.1 (BUSL-1.1) from doors dev LLC.

  • Free for development (non-production)
  • Free for non-commercial production (personal, education, research, non-profit) — optional pay-what-you-want support
  • Commercial production requires a paid license (lifetime, no subscription)

Each version of doors automatically converts to AGPL-3.0 after 4 years.

To purchase a license, visit https://doors.dev.
For Enterprise terms, you may also contact sales@doors.dev.

Full License Texts

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DocsFS embed.FS

DocsFS is the embedded documentation tree for internal purposes.

Functions

func AllowBlocking

func AllowBlocking(ctx context.Context) context.Context

AllowBlocking returns a context that suppresses warnings when used with blocking X* operations. Use with caution.

func Any

func Any(v any) templ.Component

func Attributes

func Attributes(a []Attr) templ.Component

func Call

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

Call dispatches an action to the client side. Returns a cancel function to abort the call (best-effort).

func E

E evaluates the provided function at render time and returns the resulting templ.Component.

This is useful when rendering logic is complex or better expressed in plain Go code, rather than templ syntax. The function is called with the current render context.

Example:

@doors.E(func(ctx context.Context) templ.Component {
    user, err := db.Get(id)
    if err != nil {
        return RenderError(err)
    }
    return RenderUser(user)
})

Parameters:

  • f: a function that returns a templ.Component, given the current render context

Returns:

  • A templ.Component produced by evaluating f during rendering

func F

F renders a Fragment as a templ.Component.

This helper wraps a Fragment and returns a valid templ.Component, enabling Fragments to be used inside other templ components.

Example:

templ Demo() {
    @doors.F(&Counter{})
}

func Go

func Go(f func(context.Context)) templ.Component

Go starts a goroutine at render time using a blocking-safe context tied to the component's lifecycle.

The goroutine runs only if the component is rendered. The context is canceled when the component is unmounted, allowing for proper cleanup. You must explicitly listen to ctx.Done() to stop work.

The context allows safe blocking operations, making it safe to use with X* operations (e.g., XUpdate, XRemove).

Example:

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

Parameters:

  • f: a function to run in a goroutine, scoped to the component's render lifecycle

Returns:

  • A non-visual templ.Component that starts the goroutine when rendered

func HashId

func HashId(string string) string

HashId creates ID using provided string, hashbased. For the same string outputs the same result. Suitable for HTML attributes.

func Head[M any](b Beam[M], cast func(M) HeadData) templ.Component

Head renders both <title> and <meta> elements that update dynamically based on a Beam value.

It outputs HTML <title> and <meta> tags, and includes the necessary script bindings to ensure all metadata updates reactively when the Beam changes on the server.

Example:

@doors.Head(beam, func(p Path) HeadData {
    return HeadData{
        Title: "Product: " + p.Name,
        Meta: map[string]string{
            "description": "Buy " + p.Name + " at the best price",
            "keywords": p.Name + ", product, buy",
            "og:title": p.Name,
            "og:description": "Check out this amazing product",
        },
    }
})

Parameters:

  • b: a Beam providing the input value (usually page path Beam)
  • cast: a function that maps the Beam value to a HeadData struct.

Returns:

  • A templ.Component that renders title and meta elements with remote call scripts.

func If

func If(beam Beam[bool]) templ.Component

If shows children if the beam value is true

func Include

func Include() templ.Component

Include returns a component that includes the framework's main client-side script and styles. This should be placed in the HTML head section and is required for the framework to function.

func Inject

func Inject[T any](key any, beam Beam[T]) templ.Component

Inject creates a reactive component that injects Beam values into the context for child components.

It subscribes to the Beam and re-renders its children whenever the value changes, making the current value available to child components via Extract().

This enables passing reactive values down the component tree without explicit prop drilling.

Example:

@Inject("user", userBeam) {
    @UserProfile() // Can use ctx.Value("user").(User) to get current user
}

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 InstanceLoad

func InstanceLoad(ctx context.Context, key any) any

InstanceLoad gets a value from instance-scoped storage by key. Returns nil if absent. Callers must type-assert the result.

func InstanceRemove

func InstanceRemove(ctx context.Context, key any) any

InstanceRemove deletes a key/value from instance-scoped storage. Returns the removed value or nil if absent.

func InstanceSave

func InstanceSave(ctx context.Context, key any, value any) any

InstanceSave stores a key/value in instance-scoped storage, isolated to the current instance. Returns the previous value.

func RandId

func RandId() string

RandId returns a cryptographically secure, URL-safe random ID. Suitable for sessions, instances, tokens, attributes. Case-sensitive.

func Run

func Run(f func(context.Context)) templ.Component

Run runs function at render time useful for intitialization logic

func Script

func Script() templ.Component

Script converts inline script content to an external resource. The JavaScript/TypeScript content is processed by esbuild and served as an external resource with a src attribute. This is the default mode - the resource is publicly accessible as a static asset.

The script content is automatically wrapped in an anonymous async function to support await and protect the global context. A special $d variable is provided to access frontend framework functions.

The content must be wrapped in <script> tags. TypeScript is supported by adding type="application/typescript" (or "text/typescript") attribute.

Example:

@Script() {
    <script>
        console.log("Hello from [not] inline script!");
        // $... provides access to framework functions
        // await is supported due to async wrapper
        await $hook("hello","world");
    </script>
}

Or with TypeScript:

@Script() {
    <script type="application/typescript">
        const message: string = "TypeScript works!";
        console.log(message);
    </script>
}

func ScriptDisposable

func ScriptDisposable() templ.Component

ScriptDisposable converts inline script content to an external resource within the current context scope without caching. The script is processed on every render and served with a src attribute, but not exposed as a static resource. The script content is wrapped in an anonymous async function and provides the $d variable. The content must be wrapped in <script> tags.

func ScriptPrivate

func ScriptPrivate() templ.Component

ScriptPrivate converts inline script content to an external resource that is served securely within the current context scope. The script is processed and served with a src attribute, but not exposed as a publicly accessible static asset. The script content is wrapped in an anonymous async function and provides the $d variable. The content must be wrapped in <script> tags.

func SessionEnd

func SessionEnd(ctx context.Context)

SessionEnd immediately ends the current session and all instances. Use 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 SessionLoad

func SessionLoad(ctx context.Context, key any) any

SessionLoad gets a value from session-scoped storage by key. Returns nil if absent. Callers must type-assert the result.

func SessionRemove

func SessionRemove(ctx context.Context, key any) any

SessionRemove deletes a key/value from session-scoped storage. Returns the removed value or nil if absent.

func SessionSave

func SessionSave(ctx context.Context, key any, value any) any

SessionSave stores a key/value in session-scoped storage shared by all instances in the session. Returns the previous value under the key.

func SetStatus

func SetStatus(ctx context.Context, statusCode int)

SetStatus sets an HTTP status code for the page. Makes effect only at initial page render

func Status

func Status(statusCode int) templ.Component

Status is a templ.Component that sets the HTTP status code when rendered in a template (e.g. @doors.Status(404)). Makes effect only at initial page render.

func Style

func Style() templ.Component

Style converts inline CSS content to an external resource. The CSS is minified and served as an external resource with an href attribute. This is the default mode - the resource is publicly accessible as a static asset.

The content must be wrapped in <style> tags.

Example:

@Style() {
    <style>
        .my-class {
            color: blue;
            font-size: 14px;
        }
    </style>
}

func StyleDisposable

func StyleDisposable() templ.Component

StyleDisposable converts inline CSS content to an external resource within the current context scope without caching. The CSS is processed on every render and served with an href attribute, but not exposed as a static resource. The content must be wrapped in <style> tags.

func StylePrivate

func StylePrivate() templ.Component

StylePrivate converts inline CSS content to an external resource that is served securely within the current context scope. The CSS is processed and served with an href attribute, but not exposed as a publicly accessible static asset. The content must be wrapped in <style> tags.

func Sub

func Sub[T any](beam Beam[T], render func(T) templ.Component) templ.Component

Sub creates a reactive component that automatically updates when a Beam value changes.

It subscribes to the Beam and re-renders the inner content whenever the value changes. The render function is called with the current Beam value and must return a templ.Component.

This is the preferred way to bind Beam values into the DOM in a declarative and reactive manner.

Example:

templ display(value int) {
    <span>{strconv.Itoa(value)}</span>
}

templ demo(beam Beam[int]) {
    @doors.Sub(beam, func(v int) templ.Component {
        return display(v)
    })
}

Parameters:

  • beam: the reactive Beam to observe
  • render: a function that maps the current Beam value to a templ.Component

Returns:

  • A templ.Component that updates reactively as the Beam value changes

func Text

func Text(value any) templ.Component

Text converts any value to a component with escaped string using default formats.

Example:

@Text("Hello <world>")  // Output: Hello &lt;world&gt;
@Text(42)               // Output: 42
@Text(user.Name)        // Output: John

func XCall

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

XCall dispatches an action to the client side and returns a result channel. The channel is closed without a value if the call is canceled. Cancellation is best-effort. Wait on the channel only in contexts where blocking is allowed (hooks, goroutines). The output value is unmarshaled into type T. For all actions, except ActionEmit, use json.RawMessage as T.

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, REvent[FocusEvent]) 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) Attr

func (b ABlur) Attr() AttrInit

func (ABlur) Init

func (b ABlur) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (ABlur) Render

func (b ABlur) Render(ctx context.Context, w io.Writer) 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, REvent[ChangeEvent]) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

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

func (AChange) Attr

func (p AChange) Attr() AttrInit

func (AChange) Init

func (p AChange) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AChange) Render

func (p AChange) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c AClick) Attr() AttrInit

func (AClick) Init

func (c AClick) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AClick) Render

func (p AClick) Render(ctx context.Context, w io.Writer) 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 server-provided data to JavaScript via $data(name).

The Value is marshaled to JSON and made available for client-side access. This is useful for passing initial state, configuration, or constants directly into the client runtime.

func (AData) Attr

func (a AData) Attr() AttrInit

func (AData) Init

func (a AData) Init(_ context.Context, n door.Core, _ instance.Core, attr *front.Attrs)

func (AData) Render

func (a AData) Render(ctx context.Context, w io.Writer) error

type ADataMap

type ADataMap map[string]any

func (ADataMap) Attr

func (dm ADataMap) Attr() AttrInit

func (ADataMap) Init

func (dm ADataMap) Init(_ context.Context, n door.Core, _ instance.Core, attr *front.Attrs)

func (ADataMap) Render

func (dm ADataMap) Render(ctx context.Context, w io.Writer) error

type ADyn

type ADyn interface {
	Attr
	// Value sets the attribute's value.
	Value(ctx context.Context, value string)
	// Enable adds or removes the attribute.
	Enable(ctx context.Context, enable bool)
}

ADyn is a dynamic attribute that can be updated at runtime.

func NewADyn

func NewADyn(name string, value string, enable bool) ADyn

NewADyn returns a new dynamic attribute with the given name, value, and state.

type AFileHref

type AFileHref struct {
	// If true, resource is available for download only once.
	Once bool
	// File name. Optional.
	Name string
	// File system path to serve.
	Path string
}

AFileHref prepares the href attribute for a downloadable resource served privately from a file system path.

func (AFileHref) Attr

func (s AFileHref) Attr() AttrInit

func (AFileHref) Init

func (s AFileHref) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AFileHref) Render

func (s AFileHref) Render(ctx context.Context, w io.Writer) 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, REvent[FocusEvent]) 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) Attr

func (f AFocus) Attr() AttrInit

func (AFocus) Init

func (f AFocus) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AFocus) Render

func (f AFocus) Render(ctx context.Context, w io.Writer) 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, REvent[FocusEvent]) 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) Attr

func (f AFocusIn) Attr() AttrInit

func (AFocusIn) Init

func (f AFocusIn) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AFocusIn) Render

func (f AFocusIn) Render(ctx context.Context, w io.Writer) 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, REvent[FocusEvent]) 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) Attr

func (f AFocusOut) Attr() AttrInit

func (AFocusOut) Init

func (f AFocusOut) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AFocusOut) Render

func (f AFocusOut) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c AGotPointerCapture) Attr() AttrInit

func (AGotPointerCapture) Init

func (c AGotPointerCapture) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AGotPointerCapture) Render

func (c AGotPointerCapture) Render(ctx context.Context, w io.Writer) 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 RHook[T]) (any, bool)
}

AHook binds a backend handler to a named client-side hook, allowing JavaScript code to call Go functions via $hook(name, ...).

Input data is unmarshaled from JSON into type T. Output data is marshaled to JSON from any.

Generic parameters:

  • T: input data type, sent from the client

func (AHook[T]) Attr

func (h AHook[T]) Attr() AttrInit

func (AHook[T]) Init

func (h AHook[T]) Init(ctx context.Context, n door.Core, inst instance.Core, attr *front.Attrs)

func (AHook[T]) Render

func (h AHook[T]) Render(ctx context.Context, w io.Writer) error

type AHref

type AHref struct {
	// Target path model value. Required.
	Model any
	// 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
}

AHref prepares the href attribute for internal navigation and configures dynamic link behavior.

func (AHref) Attr

func (h AHref) Attr() AttrInit

func (AHref) Init

func (h AHref) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AHref) Render

func (h AHref) Render(ctx context.Context, w io.Writer) 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, REvent[InputEvent]) bool
	// If true, does not include value in event
	// Optional.
	ExcludeValue bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

func (AInput) Attr

func (p AInput) Attr() AttrInit

func (AInput) Init

func (p AInput) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AInput) Render

func (p AInput) Render(ctx context.Context, w io.Writer) 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, REvent[KeyboardEvent]) 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) Attr

func (k AKeyDown) Attr() AttrInit

func (AKeyDown) Init

func (k AKeyDown) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AKeyDown) Render

func (k AKeyDown) Render(ctx context.Context, w io.Writer) 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, REvent[KeyboardEvent]) 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) Attr

func (k AKeyUp) Attr() AttrInit

func (AKeyUp) Init

func (k AKeyUp) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (AKeyUp) Render

func (k AKeyUp) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c ALostPointerCapture) Attr() AttrInit

func (ALostPointerCapture) Init

func (c ALostPointerCapture) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (ALostPointerCapture) Render

func (c ALostPointerCapture) Render(ctx context.Context, w io.Writer) error

type AMap

type AMap map[string]any

func (AMap) Attr

func (a AMap) Attr() AttrInit

func (AMap) Init

func (a AMap) Init(_ context.Context, _ door.Core, _ instance.Core, attrs *front.Attrs)

func (AMap) Render

func (a AMap) Render(ctx context.Context, w io.Writer) error

type AOne

type AOne [2]string

func AClass

func AClass(class ...string) AOne

func (AOne) Attr

func (a AOne) Attr() AttrInit

func (AOne) Init

func (a AOne) Init(_ context.Context, _ door.Core, _ instance.Core, attrs *front.Attrs)

func (AOne) Render

func (a AOne) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c APointerCancel) Attr() AttrInit

func (APointerCancel) Init

func (c APointerCancel) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (APointerCancel) Render

func (c APointerCancel) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c APointerDown) Attr() AttrInit

func (APointerDown) Init

func (c APointerDown) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (APointerDown) Render

func (c APointerDown) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c APointerEnter) Attr() AttrInit

func (APointerEnter) Init

func (c APointerEnter) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (APointerEnter) Render

func (c APointerEnter) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c APointerLeave) Attr() AttrInit

func (APointerLeave) Init

func (c APointerLeave) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (APointerLeave) Render

func (c APointerLeave) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c APointerMove) Attr() AttrInit

func (APointerMove) Init

func (c APointerMove) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (APointerMove) Render

func (c APointerMove) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c APointerOut) Attr() AttrInit

func (APointerOut) Init

func (c APointerOut) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (APointerOut) Render

func (c APointerOut) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c APointerOver) Attr() AttrInit

func (APointerOver) Init

func (c APointerOver) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (APointerOver) Render

func (c APointerOver) Render(ctx context.Context, w io.Writer) 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, REvent[PointerEvent]) 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) Attr

func (c APointerUp) Attr() AttrInit

func (APointerUp) Init

func (c APointerUp) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (APointerUp) Render

func (c APointerUp) Render(ctx context.Context, w io.Writer) error

type ARawFileHref

type ARawFileHref struct {
	// If true, resource is available for download only once.
	Once bool
	// File name. Optional.
	Name string
	// Handler for serving the resource request.
	Handler func(w http.ResponseWriter, r *http.Request)
}

ARawFileHref prepares the href attribute for a downloadable resource served privately and directly through a custom handler.

func (ARawFileHref) Attr

func (s ARawFileHref) Attr() AttrInit

func (ARawFileHref) Init

func (s ARawFileHref) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (ARawFileHref) Render

func (s ARawFileHref) Render(ctx context.Context, w io.Writer) 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 RRawHook) bool
}

ARawHook binds a backend handler to a named client-side hook, allowing JavaScript code to call Go functions via $hook(name, ...).

Unlike AHook, ARawHook does not perform JSON unmarshaling or marshaling. Instead, it gives full access to the raw request body and multipart form data, useful for streaming, custom parsing, or file uploads.

func (ARawHook) Attr

func (h ARawHook) Attr() AttrInit

func (ARawHook) Init

func (h ARawHook) Init(ctx context.Context, n door.Core, inst instance.Core, attr *front.Attrs)

func (ARawHook) Render

func (h ARawHook) Render(ctx context.Context, w io.Writer) error

type ARawSrc

type ARawSrc struct {
	// If true, resource is available for download only once.
	Once bool
	// File name. Optional.
	Name string
	// Handler for serving the resource request.
	Handler func(w http.ResponseWriter, r *http.Request)
}

ARawSrc prepares the src attribute for a downloadable resource served directly and privately through a custom handler.

func (ARawSrc) Attr

func (s ARawSrc) Attr() AttrInit

func (ARawSrc) Init

func (s ARawSrc) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (ARawSrc) Render

func (s ARawSrc) Render(ctx context.Context, w io.Writer) 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, RRawForm) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

ARawSubmit handles form submissions with raw multipart data, giving full control over uploads, streaming, and parsing.

func (ARawSubmit) Attr

func (s ARawSubmit) Attr() AttrInit

func (ARawSubmit) Init

func (s ARawSubmit) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (ARawSubmit) Render

func (s ARawSubmit) Render(ctx context.Context, w io.Writer) error

type ASrc

type ASrc struct {
	// If true, resource is available for download only once.
	Once bool
	// File name. Optional.
	Name string
	// File system path to serve.
	Path string
}

ASrc prepares the src attribute for a downloadable resource served privately from a file system path.

func (ASrc) Attr

func (s ASrc) Attr() AttrInit

func (ASrc) Init

func (s ASrc) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (ASrc) Render

func (s ASrc) Render(ctx context.Context, w io.Writer) error

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, RForm[T]) bool
	// Actions to run on error.
	// Optional.
	OnError []Action
}

ASubmit handles form submissions with decoded data of type T, which must be a struct annotated for go-playground/form.

func (ASubmit[V]) Attr

func (s ASubmit[V]) Attr() AttrInit

func (ASubmit[V]) Init

func (s ASubmit[V]) Init(ctx context.Context, n door.Core, inst instance.Core, attrs *front.Attrs)

func (ASubmit[V]) Render

func (s ASubmit[V]) Render(ctx context.Context, w io.Writer) 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 ActionOnlyLocationReload

func ActionOnlyLocationReload() []Action

ActionOnlyLocationReload returns a single ActionLocationReload.

func ActionOnlyLocationReplace

func ActionOnlyLocationReplace(model any) []Action

ActionOnlyLocationReplace returns a single ActionLocationReplace.

func ActionOnlyRawLocationAssign

func ActionOnlyRawLocationAssign(url string) []Action

ActionOnlyRawLocationAssign returns a single ActionLocationAssign.

func ActionOnlyScroll

func ActionOnlyScroll(selector string, smooth bool) []Action

ActionOnlyScroll returns a single ActionScroll.

type ActionEmit

type ActionEmit struct {
	Name string
	Arg  any
}

ActionEmit invokes a client-side handler registered with $on(name: string, func: (arg: any, err?: Error) => any).

type ActionIndicate

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

ActionIndicate applies indicators for a fixed duration.

type ActionLocationAssign

type ActionLocationAssign struct {
	Model any
}

ActionLocationAssign navigates to a model-derived URL.

type ActionLocationReload

type ActionLocationReload struct{}

ActionLocationReload reloads the current page.

type ActionLocationReplace

type ActionLocationReplace struct {
	Model any
}

ActionLocationReplace replaces the current location with a model-derived URL.

type ActionRawLocationAssign

type ActionRawLocationAssign struct {
	URL string
}

ActionRawLocationAssign navigates to a specified URL

type ActionScroll

type ActionScroll struct {
	Selector string
	Smooth   bool
}

ActionScroll scrolls to the first element matching Selector.

type Active

type Active struct {
	// Path match strategy
	PathMatcher PathMatcher
	// Query param match strategy, applied sequientially
	QueryMatcher []QueryMatcher
	// Indicators to apply when active
	Indicator []Indicator
}

Active configures active link indication

type App

type App[M any] interface {
	Render(SourceBeam[M]) templ.Component
}

App defines a renderable app component, where Render() must output page HTML M - the path model type.

type Attr

type Attr interface {
	Attr() AttrInit
	templ.Component
}

type AttrInit

type AttrInit = front.Attr

type Attrs

type Attrs = front.Attrs

Attrs is a renderable and spreadable set of HTML attributes.

func A

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

A builds an attribute set from the given attributes. It can be spread in templ tags or rendered inline before an element.

type Beam

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

Beam represents a reactive value stream that can be read, subscribed to, or watched.

When used in a render cycle, it is guaranteed that a Door and all of its children will observe the exact same value for a given Beam. This ensures stable and predictable rendering behavior, even when multiple components depend on the same reactive source.

func NewBeam

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

NewBeam derives a new Beam[T2] from an existing Beam[T] by applying a transformation function.

The cast function maps values from the source beam to the derived beam. Updates are only propagated when the new value passes the default equality function with != comparison to the old value

Parameters:

  • source: the source Beam[T] to derive from
  • cast: a function that transforms values from type T to type T2

Returns:

  • A new Beam[T2] that emits transformed values when they differ from the previous value

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 new Beam[T2] from an existing Beam[T] using custom transformation and filtering.

The cast function transforms source values from type T to type T2. The equality function determines whether updated values should be propagated by comparing new and old values. If equality function is nil, every transformation will be propagated regardless of value equality.

Parameters:

  • source: the source Beam[T] to derive from
  • cast: a function to transform T → T2
  • equality: a function to determine if transformed values should propagate (equal values ignored) or nil to always propagate

Returns:

  • A new Beam[T2] that emits transformed values filtered by the equality function

type CSP

type CSP = common.CSP

CSP represents Content Security Policy configuration.

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

type Door

type Door = door.Door

Door represents a dynamic placeholder in the DOM tree that can be updated, replaced, or removed at runtime.

It is a fundamental building block of the framework, used to manage dynamic HTML content. All changes made to a Door are automatically synchronized with the frontend DOM.

A Door is itself a templ.Component and can be used directly in templates:

@door
// or
@door {
    // initial HTML content
}

Doors start inactive and become active when rendered. Operations on inactive doors 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 its virtual state for potential future rendering.

The context used when rendering a Door's content follows the Door's lifecycle. This allows you to safely use `ctx.Done()` inside background goroutines that depend on the Door's presence in the DOM.

Extended methods (prefixed with X) return a channel that can be used to track when operations complete. The channel receives nil on success or an error on failure, then closes. For inactive doors, the channel closes immediately without sending a value.

During a single render cycle, Doors and their children are guaranteed to observe consistent state (Beam), ensuring stable and predictable rendering.

type ESConf

type ESConf = resources.BuildProfiles

type ESOptions

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

func (ESOptions) Options

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

type FocusEvent

type FocusEvent = front.FocusEvent

type Fragment

type Fragment interface {
	Render() templ.Component
}

Fragment is a helper interface for defining composable, stateful, and code-interactive components.

A Fragment groups fields, methods, and rendering logic into a reusable unit. This is especially useful when a simple templ function is not sufficient — for example, when you need to manage internal state, expose multiple methods, or control updates from Go code.

Fragments implement the Render method and can be rendered using the F() helper.

A Fragment can be stored in a variable, rendered once, and later updated by calling custom methods. These methods typically encapsulate internal Door updates — such as a Refresh() function that re-renders part of the fragment's content manually.

By default, a Fragment is static — its output does not change after rendering. To enable dynamic behavior, use a root-level Door to support targeted updates.

Example:

type Counter struct {
    door  doors.Door
    count int
}

func (c *Counter) Refresh(ctx context.Context) {
    c.door.Update(ctx, c.display())
}

templ (c *Counter) Render() {
    @c.door {
        @c.display()
    }
    <button { doors.A(ctx, doors.AClick{
        On: func(ctx context.Context, _ doors.REvent[doors.PointerEvent]) bool {
            c.count++
            c.Refresh(ctx)
            return false
        },
    })... }>
        Click Me!
    </button>
}

templ (c *Counter) display() {
    Clicked { fmt.Sprint(c.count) } time(s)!
}

type HeadData

type HeadData struct {
	Title string
	Meta  map[string]string
}

HeadData represents page metadata including title and meta tags

type HrefActiveMatch

type HrefActiveMatch int
const (
	MatchFull HrefActiveMatch = iota
	MatchPath
	MatchStarts
)

type ImportCommon

type ImportCommon struct {
	// File system path to the module.
	// Required.
	Path string
	// Custom name.
	// Optional.
	Name string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportCommon imports a Common JS from the provided path

func (ImportCommon) Render

func (m ImportCommon) Render(ctx context.Context, w io.Writer) error

type ImportCommonExternal

type ImportCommonExternal struct {
	// External URL to the module.
	// Required.
	Src string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportCommonExternal imports an external Common JS and adds it to CSP.

func (ImportCommonExternal) Render

type ImportCommonHosted

type ImportCommonHosted struct {
	// Full path to the hosted module (application root).
	// Required.
	Src string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportCommonHosted just generates script tag

func (ImportCommonHosted) Render

func (m ImportCommonHosted) Render(ctx context.Context, w io.Writer) error

type ImportModule

type ImportModule struct {
	// Import map specifier name.
	// Optional.
	Specifier string
	// File system path to the module.
	// Required.
	Path string
	// Build profile for esbuild options.
	// Optional.
	Profile string
	// Load the module immediately via a script tag.
	// Optional.
	Load bool
	// Custom name for the generated file.
	// Optional.
	Name string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportModule imports a JS/TS file, processes it with esbuild, and exposes it as an ES module.

func (ImportModule) Render

func (m ImportModule) Render(ctx context.Context, w io.Writer) error

type ImportModuleBundle

type ImportModuleBundle struct {
	// Import map specifier name.
	// Optional.
	Specifier string
	// Entry point file for the bundle.
	// Required.
	Entry string
	// Build profile for esbuild options.
	// Optional.
	Profile string
	// Load the module immediately via a script tag.
	// Optional.
	Load bool
	// Custom name for the generated file.
	// Optional.
	Name string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportModuleBundle bundles a JS entry with its deps into one file using esbuild.

func (ImportModuleBundle) Render

func (m ImportModuleBundle) Render(ctx context.Context, w io.Writer) error

type ImportModuleBundleFS

type ImportModuleBundleFS struct {
	// Unique cache key for this filesystem/bundle combination.
	// Required.
	CacheKey string
	// Import map specifier name.
	// Optional.
	Specifier string
	// File system to read from.
	// Required.
	FS fs.FS
	// Entry point file within the filesystem.
	// Required.
	Entry string
	// Build profile for esbuild options.
	// Optional.
	Profile string
	// Load the module immediately via a script tag.
	// Optional.
	Load bool
	// Custom name for the generated file.
	// Optional.
	Name string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportModuleBundleFS bundles a JS entry from an fs.FS using esbuild.

func (ImportModuleBundleFS) Render

type ImportModuleBytes

type ImportModuleBytes struct {
	// Import map specifier name.
	// Optional.
	Specifier string
	// Module source code.
	// Required.
	Content []byte
	// Build profile for esbuild options.
	// Optional.
	Profile string
	// Load the module immediately via a script tag.
	// Optional.
	Load bool
	// Custom name for the generated file.
	// Optional.
	Name string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportModuleBytes imports JS/TS content from bytes, processes it with esbuild, and exposes it as an ES module. Deprecated: use ImportModule instead.

func (ImportModuleBytes) Render

func (m ImportModuleBytes) Render(ctx context.Context, w io.Writer) error

type ImportModuleExternal

type ImportModuleExternal struct {
	// Import map specifier name.
	// Optional.
	Specifier string
	// Load the module immediately via a script tag.
	// Optional.
	Load bool
	// External URL to the module.
	// Required.
	Src string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportModuleExternal registers an external JS module URL and adds it to CSP.

func (ImportModuleExternal) Render

type ImportModuleHosted

type ImportModuleHosted struct {
	// Import map specifier name.
	// Optional.
	Specifier string
	// Load the module immediately via a script tag.
	// Optional.
	Load bool
	// Full path to the hosted module (application root).
	// Required.
	Src string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportModuleHosted registers a locally hosted JS module without processing.

func (ImportModuleHosted) Render

func (m ImportModuleHosted) Render(ctx context.Context, w io.Writer) error

type ImportModuleRaw

type ImportModuleRaw struct {
	// Import map specifier name.
	// Optional.
	Specifier string
	// File system path to the module.
	// Required.
	Path string
	// Load the module immediately via a script tag.
	// Optional.
	Load bool
	// Custom name for the generated file.
	// Optional.
	Name string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportModuleRaw imports a JS file as-is without processing.

func (ImportModuleRaw) Render

func (m ImportModuleRaw) Render(ctx context.Context, w io.Writer) error

type ImportModuleRawBytes

type ImportModuleRawBytes struct {
	// Import map specifier name.
	// Optional.
	Specifier string
	// Raw JavaScript content.
	// Required.
	Content []byte
	// Load the module immediately via a script tag.
	// Optional.
	Load bool
	// Custom name for the generated file.
	// Required.
	Name string
	// Additional HTML attributes for the script tag.
	// Optional.
	Attrs templ.Attributes
}

ImportModuleRawBytes serves raw JS content from bytes without processing. Deprecated: use ImportModuleRaw instead.

func (ImportModuleRawBytes) Render

type ImportStyle

type ImportStyle struct {
	// File system path to the CSS file.
	// Required.
	Path string
	// Custom name for the generated file.
	// Optional.
	Name string
	// Additional HTML attributes for the link tag.
	// Optional.
	Attrs templ.Attributes
}

ImportStyle processes a CSS file (e.g., minify) and links it.

func (ImportStyle) Render

func (m ImportStyle) Render(ctx context.Context, w io.Writer) error

type ImportStyleBytes

type ImportStyleBytes struct {
	// CSS source code.
	// Required.
	Content []byte
	// Custom name for the generated file.
	// Required.
	Name string
	// Additional HTML attributes for the link tag.
	// Optional.
	Attrs templ.Attributes
}

ImportStyleBytes processes CSS content from bytes (e.g., minify) and links it. Deprecated: use ImportStyle instead.

func (ImportStyleBytes) Render

func (m ImportStyleBytes) Render(ctx context.Context, w io.Writer) error

type ImportStyleExternal

type ImportStyleExternal struct {
	// External URL to the stylesheet.
	// Required.
	Href string
	// Additional HTML attributes for the link tag.
	// Optional.
	Attrs templ.Attributes
}

ImportStyleExternal links a CSS stylesheet from an external URL and adds it to CSP.

func (ImportStyleExternal) Render

func (m ImportStyleExternal) Render(ctx context.Context, w io.Writer) error

type ImportStyleHosted

type ImportStyleHosted struct {
	// Path to the hosted stylesheet.
	// Required.
	Href string
	// Additional HTML attributes for the link tag.
	// Optional.
	Attrs templ.Attributes
}

ImportStyleHosted links a locally hosted CSS file without processing.

func (ImportStyleHosted) Render

func (m ImportStyleHosted) Render(ctx context.Context, w io.Writer) error

type Indicator

type Indicator = front.Indicator

Indicator is a temporary DOM modification. It can change content, attributes, or classes, and is cleaned up automatically.

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 innerHTML on the selected element.

func (IndicatorContent) Indicate

func (c IndicatorContent) Indicate() *indicate

type InputEvent

type InputEvent = front.InputEvent

type JSX

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

func JSXPreact

func JSXPreact() JSX

func JSXReact

func JSXReact() JSX

type KeyboardEvent

type KeyboardEvent = front.KeyboardEvent

type Location

type Location = path.Location

Location represents a URL built from a path model: path plus query. Use with navigation functions or href attributes.

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. Returns an error if no adapter is registered or encoding fails.

type ModelRoute

type ModelRoute = router.Response

ModelRoute provides the response type for page handlers (page, redirect, reroute, or static content).

type ModelRouter

type ModelRouter[M any] interface {
	// Page renders a Page.
	App(app App[M]) ModelRoute
	// PageFunc renders a Page from a function.
	AppFunc(AppFunc func(SourceBeam[M]) templ.Component) ModelRoute
	// StaticPage returns a static page with status.
	StaticPage(content templ.Component, status int) ModelRoute
	// Reroute performs an internal reroute to model (detached=true disables path sync).
	Reroute(model any, detached bool) ModelRoute
	// Redirect issues an HTTP redirect to model with status.
	Redirect(model any, status int) ModelRoute
	// Redirect issues an HTTP redirect to URL with status.
	RawRedirect(url string, status int) ModelRoute
}

ModelRouter provides helpers to produce page responses.

type Page

type Page[M any] interface {
	Render(SourceBeam[M]) templ.Component
}

Page defines a renderable page component that the page must implement. M - the path model type. Deprecated: Use App[M]

type PageRoute

type PageRoute = ModelRoute

PageRoute provides the response type for page handlers (page, redirect, reroute, or static content). Deprecated: Use ModelRoute

type PageRouter

type PageRouter[M any] interface {
	// Page renders a Page.
	Page(page Page[M]) PageRoute
	// PageFunc renders a Page from a function.
	PageFunc(pageFunc func(SourceBeam[M]) templ.Component) PageRoute
	// StaticPage returns a static page with status.
	StaticPage(content templ.Component, status int) PageRoute
	// Reroute performs an internal reroute to model (detached=true disables path sync).
	Reroute(model any, detached bool) PageRoute
	// Redirect issues an HTTP redirect to model with status.
	Redirect(model any, status int) PageRoute
	// Redirect issues an HTTP redirect to URL with status.
	RawRedirect(url string, status int) PageRoute
}

PageRouter provides helpers to produce page responses. Deprecated: Use ModelRouter[M any]

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 form values and uploaded files.

type PathMatcher

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

func PathMatcherFull

func PathMatcherFull() PathMatcher

func PathMatcherParts

func PathMatcherParts(i ...int) PathMatcher

PathMatcherParts checks if path parts by specified indexes matche

func PathMatcherStarts

func PathMatcherStarts() PathMatcher

type PointerEvent

type PointerEvent = front.PointerEvent

type QueryMatcher

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

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 R

type R interface {
	// SetCookie adds a cookie to the response.
	SetCookie(cookie *http.Cookie)
	// GetCookie retrieves a cookie by name.
	GetCookie(name string) (*http.Cookie, error)
	// Done signals when the request context is canceled or completed.
	Done() <-chan struct{}
}

R provides basic request operations including cookie management.

type RAfter

type RAfter interface {
	// After sets client-side actions to run once the request finishes.
	After([]Action) error
}

RAfter allows setting client-side actions to run after a request completes.

type REvent

type REvent[E any] interface {
	R
	RAfter
	// Event returns the event payload.
	Event() E
}

REvent provides request handling for event hooks with typed event data.

type RForm

type RForm[D any] interface {
	R
	RAfter
	// Data returns the parsed form payload.
	Data() D
}

RForm provides request handling for form submissions with typed form data.

type RHook

type RHook[D any] interface {
	R
	RAfter
	// Data returns the parsed hook payload.
	Data() D
}

RHook provides request handling for hook handlers with typed data.

type RModel

type RModel[M any] interface {
	R
	// Model returns the decoded path model.
	Model() M
	// RequestHeader returns the incoming request headers.
	RequestHeader() http.Header
	// ResponseHeader returns the outgoing response headers.
	ResponseHeader() http.Header
}

RModel provides request data and response control for model handlers.

type RPage

type RPage[M any] = RModel[M]

RPage provides request data and response control for page handlers. Deprecated: Use RModel[M]

type RRawForm

type RRawForm interface {
	R
	RAfter
	// 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)
}

RRawForm provides access to raw multipart form data for streaming or custom parsing.

type RRawHook

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

RRawHook provides access to raw request data for hook handlers without parsing.

type Route

type Route = router.Route

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 a URL prefix. The prefix must not be root ("/").

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 a URL prefix. The prefix must not be root ("/").

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 a single file at a fixed URL path. The path must not be root ("/").

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 Router

type Router interface {
	http.Handler
	Use(...Use)
}

Router represents the main HTTP router that handles all requests. It implements http.Handler and provides configuration through Use().

func NewRouter

func NewRouter() Router

NewRouter creates a new router instance with default configuration. The router handles app routing, static files, hooks, and framework resources.

type Scope

type Scope = front.Scope

Scope controls concurrency for event processing. It defines how events are queued, blocked, debounced, or serialized.

func ScopeOnlyBlocking

func ScopeOnlyBlocking() []Scope

ScopeOnlyBlocking creates a blocking scope that cancels concurrent events.

func ScopeOnlyDebounce

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

ScopeOnlyDebounce creates a debounced scope with duration and limit.

func ScopeOnlySerial

func ScopeOnlySerial() []Scope

ScopeOnlySerial creates a serial scope that executes events sequentially.

type ScopeBlocking

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

ScopeBlocking cancels new events while one is processing. Useful for preventing double-clicks or duplicate submissions.

func (*ScopeBlocking) Scope

func (b *ScopeBlocking) Scope(inst instance.Core) *ScopeSet

type ScopeConcurrent

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

ScopeConcurrent can be occupied by events with the same groupId, other - blocked

func (*ScopeConcurrent) Scope

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

type ScopeDebounce

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

ScopeDebounce delays events by duration but guarantees execution within the specified limit. New events reset the delay.

func (*ScopeDebounce) Scope

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

Scope creates a debounced scope.

  • duration: debounce delay, reset by new events
  • limit: maximum wait before execution regardless of new events

type ScopeFrame

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

ScopeFrame distinguishes immediate and frame events. Immediate events run normally. Frame events wait for all prior events to finish, block new ones, then run exclusively.

func (*ScopeFrame) Scope

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

Scope creates a frame-based scope.

  • frame=false: execute immediately
  • frame=true: wait for completion of all events, then execute exclusively

type ScopeSerial

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

ScopeSerial queues events and processes them in order.

func (*ScopeSerial) Scope

func (b *ScopeSerial) Scope(inst instance.Core) *ScopeSet

type ScopeSet

type ScopeSet = front.ScopeSet

ScopeSet holds the configuration of a scope instance.

type Selector

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

Selector targets DOM elements for indicators. Select by event source, CSS query, or closest matching parent.

func SelectorParentQuery

func SelectorParentQuery(query string) Selector

SelectorParentQuery selects the closest ancestor matching a CSS query.

func SelectorQuery

func SelectorQuery(query string) Selector

SelectorQuery selects the first element matching a CSS query (e.g. "#id", ".class").

func SelectorQueryAll

func SelectorQueryAll(query string) Selector

SelectorQuery selects all elements matching a CSS query (e.g. "#id", ".class").

func SelectorTarget

func SelectorTarget() Selector

SelectorTarget selects the element that triggered the event.

type SessionCallback

type SessionCallback = router.SessionCallback

type SourceBeam

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

SourceBeam is the initial Beam (others are derived from it), which, in addition to its core functionality, includes the ability to update values and propagate changes to all subscribers and derived beams. It serves as the root of a reactive value chain. Updates and mutations are synchronized across all subscribers, ensuring consistent state during rendering cycles. During a render cycle, all consumers will see a consistent view of the latest value. The source maintains a sequence of values for synchronization purposes.

IMPORTANT: For reference types (slices, maps, pointers, structs), do not modify the data directly. Instead, create or provide a different instance. Direct modification can break the consistency guarantees since subscribers may observe partial changes or inconsistent state.

func NewSourceBeam

func NewSourceBeam[T comparable](init T) SourceBeam[T]

NewSourceBeam creates a new SourceBeam with the given initial value. Updates are only propagated when the new value passes the default distinct function with != comparison to the old value

Parameters:

  • init: the initial value for the SourceBeam

Returns:

  • A new SourceBeam[T] instance

func NewSourceBeamEqual

func NewSourceBeamEqual[T any](init T, equal func(new T, old T) bool) SourceBeam[T]

NewSourceBeamEqual creates a new SourceBeam with a custom equality function.

The equality function receives new and old values and should return true if the new value is considered different and should be propagated to subscribers. If equality is nil, every update will be propagated regardless of value equality.

Parameters:

  • init: the initial value for the SourceBeam
  • equality: a function to determine if transformed values should propagate (equal values ignored) or nil to always propagate

Returns:

  • A new SourceBeam[T] instance that uses the equality function for update filtering

type SystemConf

type SystemConf = common.SystemConf

SystemConf contains system-wide configuration options for the framework.

type Use

type Use = router.Use

Use represents a router modification that can be used to configure routing behavior.

func UseCSP

func UseCSP(csp CSP) Use

UseCSP configures Content Security Policy headers for enhanced security. This helps prevent XSS attacks and other security vulnerabilities.

func UseESConf

func UseESConf(conf ESConf) Use

UseESConf configures esbuild profiles for JavaScript/TypeScript processing. Different profiles can be used for development vs production builds.

func UseErrorPage

func UseErrorPage(page func(message string) templ.Component) Use

UseErrorPage sets a custom error page component for handling internal errors. The component receives the error message as a parameter.

func UseFallback

func UseFallback(handler http.Handler) Use

UseFallback sets a fallback handler for requests that don't match any routes. This is useful for integrating with other HTTP handlers or serving custom 404 pages.

func UseLicense

func UseLicense(cert string) Use

UseLicense verifies and adds license certificate. License is required for commercial production use. You can purchase suitable license at https://doors.dev or via email sales@doors.dev

func UseModel

func UseModel[M any](handler func(m ModelRouter[M], r RModel[M]) ModelRoute) Use

UseModel registers a model handler for a path model type M. The model defines path/query patterns via struct tags.

Example:

type BlogPath struct {
    Home bool   `path:"/"`                    // Match root path
    Post bool   `path:"/post/:ID"`           // Match /post/123, capture ID
    List bool   `path:"/posts"`              // Match /posts
    ID   int                                  // Captured from :ID parameter
    Tag  *string `query:"tag"`               // Query parameter ?tag=golang
}

func UsePage deprecated

func UsePage[M any](handler func(p PageRouter[M], r RPage[M]) PageRoute) Use

Deprecated: Use UseModel

func UseRoute

func UseRoute(r Route) Use

UseRoute adds a custom Route to the router. A Route must implement:

  • Match(*http.Request) bool: whether the route handles the request
  • Serve(http.ResponseWriter, *http.Request): serve the matched request

func UseSessionCallback

func UseSessionCallback(callback SessionCallback) Use

UseSessionCallback registers callbacks for session lifecycle events. The Create callback is called when a new session is created. The Delete callback is called when a session is removed.

func UseSystemConf

func UseSystemConf(conf SystemConf) Use

UseSystemConf applies system-wide configuration including timeouts, limits, and other framework behavior settings.

Jump to

Keyboard shortcuts

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