Documentation
¶
Overview ¶
Package neith brings enhanced functionality to the Component interface.
Index ¶
- func AddClasses(ctx context.Context, id string, classes ...string)
- func Blur(ctx context.Context, id string)
- func Disable(ctx context.Context, id string)
- func Enable(ctx context.Context, id string)
- func EventData[T any](ctx context.Context) (T, error)
- func Focus(ctx context.Context, id string)
- func JS(ctx context.Context, fn string, arg any)
- func MiddleWareFn(h http.HandlerFunc, hf HandleFn) http.HandlerFunc
- func OnCacheChange[T any](c Cache[T], f func())
- func OnCacheTimeOut[T any](c Cache[T], f func())
- func RemoveAttribute(ctx context.Context, id string, name string)
- func RemoveClasses(ctx context.Context, id string, classes ...string)
- func RemoveElement(ctx context.Context, id string)
- func RemoveStyle(ctx context.Context, id string, name string)
- func RemoveTag(ctx context.Context, tag string)
- func RenderComponent(c ...Component) (html string)
- func ScrollIntoView(ctx context.Context, id string)
- func SetAttribute(ctx context.Context, id string, name string, value string)
- func SetConfig(c *Config)
- func SetStyle(ctx context.Context, id string, name string, value string)
- func SetText(ctx context.Context, id string, value string)
- func SetValue(ctx context.Context, id string, value string)
- type Cache
- func (c *Cache[T]) CreatedAt() time.Time
- func (c *Cache[T]) Delete()
- func (c *Cache[T]) Expiry() time.Time
- func (c *Cache[T]) History() (map[string]T, bool)
- func (c *Cache[T]) Record(record bool)
- func (c *Cache[T]) Set(data T, timeout ...time.Duration) error
- func (c *Cache[T]) TimeOut() time.Duration
- func (c *Cache[T]) UpdatedAt() time.Time
- func (c *Cache[T]) Value() T
- type CacheError
- type CacheOnFn
- type Component
- type Config
- type ContextKey
- type Dispatch
- type DispatchError
- type DragEvent
- type EventListener
- type EventTarget
- type FnClass
- type FnComponent
- func (f FnComponent) AppendElement(id string) FnComponent
- func (f FnComponent) AppendTag(tag string) FnComponent
- func (f FnComponent) Dispatch()
- func (f FnComponent) JS(fn string, arg any) FnComponent
- func (f FnComponent) PrependElement(id string) FnComponent
- func (f FnComponent) PrependTag(tag string) FnComponent
- func (f FnComponent) Render(ctx context.Context, w io.Writer) error
- func (f FnComponent) SwapElementInner(id string) FnComponent
- func (f FnComponent) SwapElementOuter(id string) FnComponent
- func (f FnComponent) SwapTagInner(tag string) FnComponent
- func (f FnComponent) SwapTagOuter(tag string) FnComponent
- func (f FnComponent) WithContext(ctx context.Context) FnComponent
- func (f FnComponent) WithError(err error) FnComponent
- func (f FnComponent) WithEvents(h HandleFn, e ...OnEvent) FnComponent
- func (f FnComponent) WithLabel(label string) FnComponent
- func (f FnComponent) WithRedirect(url string) FnComponent
- func (f FnComponent) Write(p []byte) (n int, err error)
- type FnCustom
- type FnDOM
- type FnError
- type FnPing
- type FnRedirect
- type FnRender
- type FormDataEvent
- type HTML
- type HandleFn
- type KeyboardEvent
- type LogLevel
- type MouseEvent
- type OnEvent
- type PointerEvent
- type Touch
- type TouchEvent
- type Upload
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddClasses ¶
AddClasses immediately adds CSS classes to one element by ID.
The mutation is sent as a class dispatch and runs through classList.add on the browser client.
func EventData ¶
EventData unmarshals the current event's client payload into T.
Handlers normally call EventData from inside a HandleFn. The payload shape depends on the browser event: form events usually decode into a map or struct, while pointer, keyboard, drag, mouse, and touch events can decode into the matching neith event structs.
func JS ¶
JS dispatches a custom JavaScript call immediately.
Unlike FnComponent.JS, this helper sends the dispatch right away and does not return a component for a handler to return.
func MiddleWareFn ¶
func MiddleWareFn(h http.HandlerFunc, hf HandleFn) http.HandlerFunc
func OnCacheChange ¶
OnCacheChange registers a callback to run after Set writes a cache value.
Updating metadata with helpers like Record uses saveCache and does not trigger this callback. Only value-changing Set calls trigger OnCacheChange.
func OnCacheTimeOut ¶
OnCacheTimeOut registers a callback to run when this cache entry expires.
The callback is keyed to this cache's client/key pair. It runs after an expiry watcher confirms the cache value is still the same update that started the watcher.
func RemoveAttribute ¶
RemoveAttribute immediately removes one attribute from an element by ID.
func RemoveClasses ¶
RemoveClasses immediately removes CSS classes from one element by ID.
The mutation is sent as a class dispatch and runs through classList.remove on the browser client.
func RemoveElement ¶
RemoveElement immediately removes one DOM element by ID.
This sends a render dispatch with Remove set and TargetID populated.
func RemoveStyle ¶
RemoveStyle immediately removes one inline style property from an element by ID.
func RemoveTag ¶
RemoveTag immediately removes the first matching DOM tag.
This sends a render dispatch with Remove set and Tag populated.
func RenderComponent ¶
RenderComponent renders one or more components into a single HTML string.
This helper is useful when code needs a component's HTML outside the live websocket dispatch path. It renders with context.Background and appends each component into the same buffer in the order provided.
func ScrollIntoView ¶
ScrollIntoView immediately scrolls an element into view by ID.
func SetAttribute ¶
SetAttribute immediately sets one attribute on an element by ID.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
func NewCache ¶
NewCache creates a typed cache entry for the current client session.
The client ID is read from the dispatch details stored in ctx by the neith middleware. Each client session gets its own cache store, so the same key can be reused safely across different browser clients. NewCache returns ErrCacheExists if the key already exists for this client session, including when the existing cache was created with a different type.
func UseCache ¶
UseCache retrieves a typed cache entry for the current client session.
The requested type T must match the type used when the cache was created. If the key does not exist, UseCache returns ErrCacheNotFound; if the key exists with a different type, it returns ErrCacheWrongType.
func (*Cache[T]) CreatedAt ¶
CreatedAt returns the time recorded when this cache entry was first created.
The timestamp is stored on the cache value itself and is preserved when Set updates the cache.
func (*Cache[T]) Delete ¶
func (c *Cache[T]) Delete()
Delete removes this cache entry from its client-session store.
Delete is idempotent from the caller's perspective: deleting a missing cache does not return an error, though a missing store may be logged at debug level.
func (*Cache[T]) Expiry ¶
Expiry returns the wall-clock time when the current cache value expires.
Expiry is calculated from UpdatedAt plus TimeOut. It is useful for inspection and tests; expiry deletion is handled internally by watchExpiry.
func (*Cache[T]) History ¶
History returns the recorded cache values for this cache entry.
The returned map is keyed by the time each value was recorded. The boolean is false when no history exists or when a stored history value cannot be asserted back to T.
func (*Cache[T]) Record ¶
Record controls whether future cache updates are stored in history.
The flag is persisted into the backing cache entry, so calling Record(true) before Set is enough to have later Set calls recorded even though Set reloads the current cache state from the store.
func (*Cache[T]) Set ¶
Set writes a new value into the cache and refreshes its expiry timer.
Passing a positive timeout shorter than config.CacheTimeOut uses that timeout for this cache update. Passing 0 keeps the previous timeout when one exists. Omitting timeout, passing a negative timeout, or passing a timeout greater than config.CacheTimeOut falls back to config.CacheTimeOut. Set also triggers OnCacheChange callbacks and starts an expiry watcher for this exact update.
func (*Cache[T]) TimeOut ¶
TimeOut returns the duration after UpdatedAt when this cache entry expires.
Expiry is checked by a background watcher created by Set. The watcher verifies the cache has not been updated since it started before deleting anything.
type CacheError ¶
type CacheError string
const ( ErrCacheNotFound CacheError = "cache not found" ErrStoreNotFound CacheError = "cache store not found; create cache first" ErrCacheWrongType CacheError = "cache wrong type" ErrCacheExists CacheError = "cache already exists; delete existing cache first" )
func (CacheError) Error ¶
func (e CacheError) Error() string
type Component ¶
Component is the minimal renderable unit neith can send to the browser.
It intentionally matches the shape used by templ and many simple Go HTML renderers: Render receives a context and writes HTML to the supplied writer.
type Config ¶
type Config struct {
Silent bool // If true, no logs will be printed
CacheTimeOut time.Duration // Default cache timeout
LogLevel LogLevel
Logger *log.Logger
UploadDir string // Directory for multipart event uploads; defaults to os.TempDir()/neith-uploads
UploadMaxBytes int64 // Maximum request size for one upload request
UploadMaxMemory int64 // Maximum multipart memory before files spill to disk
}
type ContextKey ¶
type ContextKey string
ContextKey is used to store values in context esp. for event listeners
const ( // EventKey is used to store EventListeners in context EventKey ContextKey = "event" // RequestKey is used to store http.Request in context RequestKey ContextKey = "request" // ResponseKey is used to store http.ResponseWriter in context ErrorKey ContextKey = "error" )
type Dispatch ¶
type Dispatch struct {
ID string `json:"id"`
Key string `json:"key"`
ConnID string `json:"conn_id"`
HandlerID string `json:"handler_id"`
Action string `json:"action"`
Label string `json:"label"`
Function functionName `json:"function"`
FnEvent EventListener `json:"event"`
FnPing FnPing `json:"ping"`
FnRender FnRender `json:"render"`
FnClass FnClass `json:"class"`
FnDOM FnDOM `json:"dom"`
FnRedirect FnRedirect `json:"redirect"`
FnCustom FnCustom `json:"custom"`
FnError FnError `json:"error"`
// contains filtered or unexported fields
}
Dispatch is the websocket message exchanged by Go and the browser client.
The flat JSON shape mirrors static/assets/neith_types.ts. Function selects which nested payload is active for a given message.
type DispatchError ¶
type DispatchError string
const ( ErrCtxMissingDispatch DispatchError = "context missing dispatch" ErrNoClientConnection DispatchError = "no connection to client" ErrConnectionNotFound DispatchError = "connection not found" ErrConnectionFailed DispatchError = "connection failed" ErrCtxMissingEvent DispatchError = "context missing event" )
func (DispatchError) Error ¶
func (e DispatchError) Error() string
type DragEvent ¶
type DragEvent struct {
IsTrusted bool `json:"isTrusted"`
AltKey bool `json:"altKey"`
Bubbles bool `json:"bubbles"`
Button int `json:"button"`
Buttons int `json:"buttons"`
Cancelable bool `json:"cancelable"`
ClientX int `json:"clientX"`
ClientY int `json:"clientY"`
Composed bool `json:"composed"`
CtrlKey bool `json:"ctrlKey"`
Component EventTarget `json:"component"`
DefaultPrevented bool `json:"defaultPrevented"`
Detail int `json:"detail"`
EventPhase int `json:"eventPhase"`
MetaKey bool `json:"metaKey"`
MovementX int `json:"movementX"`
MovementY int `json:"movementY"`
OffsetX int `json:"offsetX"`
OffsetY int `json:"offsetY"`
PageX int `json:"pageX"`
PageY int `json:"pageY"`
RelatedTarget EventTarget `json:"relatedTarget"`
Source EventTarget `json:"source"`
}
DragEvent contains the drag payload sent by the browser client.
type EventListener ¶
type EventListener struct {
context.Context `json:"-"`
ID string `json:"id"`
TargetID string `json:"target_id"`
Handler HandleFn `json:"-"`
On OnEvent `json:"on"`
Data any `json:"data"`
Uploads []Upload `json:"uploads,omitempty"`
Submitter *EventTarget `json:"submitter,omitempty"`
}
EventListener is the server-side handler metadata serialized into rendered components and echoed back by the browser when the matching DOM event fires.
type EventTarget ¶
type EventTarget struct {
ID string `json:"id"`
Name string `json:"name"`
ClassList []string `json:"classList"`
TagName string `json:"tagName"`
InnerHTML string `json:"innerHTML"`
OuterHTML string `json:"outerHTML"`
Value string `json:"value"`
Checked bool `json:"checked"`
Disabled bool `json:"disabled"`
Hidden bool `json:"hidden"`
Style string `json:"style"`
Attributes []string `json:"attributes"`
Dataset []string `json:"dataset"`
SelectedOptions []string `json:"selectedOptions"`
}
EventTarget is a JSON-safe snapshot of a DOM element involved in an event.
func EventSubmitter ¶
func EventSubmitter(ctx context.Context) (*EventTarget, error)
EventSubmitter returns the button or input that submitted a form event.
type FnClass ¶
type FnClass struct {
TargetID string `json:"target_id"`
Remove bool `json:"remove"`
Names []string `json:"names"`
}
FnClass adds or removes CSS classes from a browser element.
type FnComponent ¶
FnComponent is the server-side wrapper around rendered HTML and dispatch data.
It implements io.Writer so components can render directly into it. The dispatch field tracks how the browser should apply the rendered HTML, which client session it belongs to, and any event listeners attached to it.
func FnErr ¶
func FnErr(ctx context.Context, err error) FnComponent
FnErr creates an error dispatch from a context and error.
This is a convenience for event handlers that return FnComponent and want to surface an error through neith's normal error path.
func NewFn ¶
func NewFn(ctx context.Context, c Component) FnComponent
NewFn creates a new FnComponent from a Component.
The component is given a unique DOM wrapper ID and, when ctx was created by neith middleware, is attached to the active websocket dispatch context. NewFn defaults to swapping the inner HTML of <main>, which gives simple apps a useful render target without extra setup.
func RedirectURL ¶
func RedirectURL(ctx context.Context, url string) FnComponent
RedirectURL creates a redirect dispatch for handler return values.
Returning this from a HandleFn tells the browser client to navigate to url.
func (FnComponent) AppendElement ¶
func (f FnComponent) AppendElement(id string) FnComponent
AppendElement appends the rendered component to an element by ID.
The browser client finds document.getElementById(id) and appends the rendered HTML to that element's innerHTML.
func (FnComponent) AppendTag ¶
func (f FnComponent) AppendTag(tag string) FnComponent
AppendTag appends the rendered component to the first matching tag in the DOM.
The browser client finds document.getElementsByTagName(tag)[0] and appends the rendered HTML to that element's innerHTML.
func (FnComponent) Dispatch ¶
func (f FnComponent) Dispatch()
Dispatch immediately queues this component for the active browser connection.
Dispatch requires a client session and handler ID from middleware context. If the component was created outside an neith request/event context, Dispatch logs the missing connection and returns without sending anything.
func (FnComponent) JS ¶
func (f FnComponent) JS(fn string, arg any) FnComponent
JS changes this dispatch into a custom browser-side JavaScript call.
fn is the name of a function on window and arg is serialized as the payload. The browser client calls window[fn](arg) and sends the result back in the dispatch's custom result field.
func (FnComponent) PrependElement ¶
func (f FnComponent) PrependElement(id string) FnComponent
PrependElement prepends the rendered component to an element by ID.
The browser client finds document.getElementById(id) and inserts the rendered HTML before the element's existing innerHTML.
func (FnComponent) PrependTag ¶
func (f FnComponent) PrependTag(tag string) FnComponent
PrependTag prepends the rendered component to the first matching tag.
The browser client inserts the rendered HTML before the existing innerHTML of document.getElementsByTagName(tag)[0].
func (FnComponent) Render ¶
Render writes the component wrapper and buffered HTML.
The wrapper div carries the component ID, optional label, and serialized event listener metadata. The browser client reads those attributes after inserting the HTML so it can attach DOM listeners and route events back to Go.
func (FnComponent) SwapElementInner ¶
func (f FnComponent) SwapElementInner(id string) FnComponent
SwapElementInner replaces one element's inner HTML by ID.
Use this when the target element should remain in place but its contents should be replaced by the rendered component.
func (FnComponent) SwapElementOuter ¶
func (f FnComponent) SwapElementOuter(id string) FnComponent
SwapElementOuter replaces one element's outer HTML by ID.
Use this when the rendered component should replace the selected element itself, including its tag.
func (FnComponent) SwapTagInner ¶
func (f FnComponent) SwapTagInner(tag string) FnComponent
SwapTagInner replaces the first matching tag's inner HTML.
This is NewFn's default render mode for <main>, making it the common path for full-page or main-region updates.
func (FnComponent) SwapTagOuter ¶
func (f FnComponent) SwapTagOuter(tag string) FnComponent
SwapTagOuter replaces the first matching tag's outer HTML.
Use this when the rendered component should replace the target element itself, not just the target element's contents.
func (FnComponent) WithContext ¶
func (f FnComponent) WithContext(ctx context.Context) FnComponent
WithContext replaces the component context and refreshes dispatch details.
Use this when a component value is created outside the request/event context and later needs to be associated with the active client session before dispatch.
func (FnComponent) WithError ¶
func (f FnComponent) WithError(err error) FnComponent
WithError changes this dispatch into an error message.
The server-side handler pipeline logs these errors through the package logger unless logging is disabled. A nil error is normalized to a useful message so callers do not silently dispatch an empty error.
func (FnComponent) WithEvents ¶
func (f FnComponent) WithEvents(h HandleFn, e ...OnEvent) FnComponent
WithEvents attaches one server handler to one or more DOM event types.
Each event listener is registered in the client-session event registry and serialized into the component's wrapper metadata. When the browser receives this component, it attaches listeners and sends matching DOM events back to h.
func (FnComponent) WithLabel ¶
func (f FnComponent) WithLabel(label string) FnComponent
WithLabel sets a human-readable label on the component wrapper.
The label may be used to identify a component on the server and client, especially during debugging.
func (FnComponent) WithRedirect ¶
func (f FnComponent) WithRedirect(url string) FnComponent
WithRedirect changes this dispatch into a browser redirect.
Redirect components do not need rendered HTML. When returned from a handler or dispatched directly, the browser client sets window.location to url.
func (FnComponent) Write ¶
func (f FnComponent) Write(p []byte) (n int, err error)
Write appends rendered bytes to this component's dispatch buffer.
Component renderers call this indirectly when NewFn renders a Component into the FnComponent. The buffered bytes are later wrapped by Render and sent to the browser.
type FnCustom ¶
type FnCustom struct {
Function string `json:"function"`
Data any `json:"data"`
Result any `json:"result"`
}
FnCustom calls a named browser function and receives its result.
type FnDOM ¶
type FnDOM struct {
TargetID string `json:"target_id"`
Operation string `json:"operation"`
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
}
FnDOM applies a focused DOM mutation such as attribute, style, text, value, focus, blur, scroll, enable, disable, or removal.
type FnError ¶
type FnError struct {
Message string `json:"message"`
}
FnError carries an error message between Go and the browser client.
type FnRedirect ¶
type FnRedirect struct {
URL string `json:"url"`
}
FnRedirect sends the browser to a new URL.
type FnRender ¶
type FnRender struct {
TargetID string `json:"target_id"`
Tag string `json:"tag"`
Inner bool `json:"inner"`
Outer bool `json:"outer"`
Append bool `json:"append"`
Prepend bool `json:"prepend"`
Remove bool `json:"remove"`
HTML string `json:"html"`
EventListeners []EventListener `json:"event_listeners"`
}
FnRender describes how rendered HTML should be applied in the browser.
type FormDataEvent ¶
type FormDataEvent struct {
IsTrusted bool `json:"isTrusted"`
Bubbles bool `json:"bubbles"`
Cancelable bool `json:"cancelable"`
Composed bool `json:"composed"`
Component EventTarget `json:"component"`
DefaultPrevented bool `json:"defaultPrevented"`
EventPhase int `json:"eventPhase"`
FormData map[string]any `json:"formData"`
}
FormDataEvent contains the form payload sent by the browser client.
type HTML ¶
type HTML string
HTML adapts a raw HTML string to the Component interface.
It is useful for small examples, tests, and simple components that do not need a dedicated struct or templ-generated renderer.
type HandleFn ¶
type HandleFn func(context.Context) FnComponent
type KeyboardEvent ¶
type KeyboardEvent struct {
IsTrusted bool `json:"isTrusted"`
AltKey bool `json:"altKey"`
Bubbles bool `json:"bubbles"`
Cancelable bool `json:"cancelable"`
Code string `json:"code"`
Composed bool `json:"composed"`
CtrlKey bool `json:"ctrlKey"`
Component EventTarget `json:"component"`
DefaultPrevented bool `json:"defaultPrevented"`
Detail int `json:"detail"`
EventPhase int `json:"eventPhase"`
IsComposing bool `json:"isComposing"`
Key string `json:"key"`
Location int `json:"location"`
MetaKey bool `json:"metaKey"`
Repeat bool `json:"repeat"`
ShiftKey bool `json:"shiftKey"`
Source EventTarget `json:"source"`
}
KeyboardEvent contains the keyboard payload sent by the browser client.
type MouseEvent ¶
type MouseEvent struct {
IsTrusted bool `json:"isTrusted"`
AltKey bool `json:"altKey"`
Bubbles bool `json:"bubbles"`
Button int `json:"button"`
Buttons int `json:"buttons"`
Cancelable bool `json:"cancelable"`
ClientX int `json:"clientX"`
ClientY int `json:"clientY"`
Composed bool `json:"composed"`
CtrlKey bool `json:"ctrlKey"`
Component EventTarget `json:"component"`
DefaultPrevented bool `json:"defaultPrevented"`
Detail int `json:"detail"`
EventPhase int `json:"eventPhase"`
MetaKey bool `json:"metaKey"`
MovementX int `json:"movementX"`
MovementY int `json:"movementY"`
OffsetX int `json:"offsetX"`
OffsetY int `json:"offsetY"`
PageX int `json:"pageX"`
PageY int `json:"pageY"`
RelatedTarget EventTarget `json:"relatedTarget"`
Source EventTarget `json:"source"`
}
MouseEvent contains the mouse payload sent by the browser client.
type OnEvent ¶
type OnEvent string
const ( OnAbort OnEvent = "abort" OnAnimationEnd OnEvent = "animationend" OnAnimationIteration OnEvent = "animationiteration" OnAnimationStart OnEvent = "animationstart" OnBlur OnEvent = "blur" OnCanPlay OnEvent = "canplay" OnCanPlayThrough OnEvent = "canplaythrough" OnChange OnEvent = "change" OnChangeCapture OnEvent = "changecapture" OnClick OnEvent = "click" OnCompositionEnd OnEvent = "compositionend" OnCompositionStart OnEvent = "compositionstart" OnCompositionUpdate OnEvent = "compositionupdate" OnContextMenuCapture OnEvent = "contextmenucapture" OnCopy OnEvent = "copy" OnCut OnEvent = "cut" OnDoubleClickCapture OnEvent = "doubleclickcapture" OnDrag OnEvent = "drag" OnDragEnd OnEvent = "dragend" OnDragEnter OnEvent = "dragenter" OnDragExitCapture OnEvent = "dragexitcapture" OnDragLeave OnEvent = "dragleave" OnDragOver OnEvent = "dragover" OnDragStart OnEvent = "dragstart" OnDrop OnEvent = "drop" OnDurationChange OnEvent = "durationchange" OnEmptied OnEvent = "emptied" OnEncrypted OnEvent = "encrypted" OnEnded OnEvent = "ended" OnError OnEvent = "error" OnFocus OnEvent = "focus" OnGotPointerCapture OnEvent = "gotpointercapture" OnInput OnEvent = "input" OnInvalid OnEvent = "invalid" OnKeyDown OnEvent = "keydown" OnKeyPress OnEvent = "keypress" OnKeyUp OnEvent = "keyup" OnLoad OnEvent = "load" OnLoadEnd OnEvent = "loadend" OnLoadStart OnEvent = "loadstart" OnLoadedData OnEvent = "loadeddata" OnLoadedMetadata OnEvent = "loadedmetadata" OnLostPointerCapture OnEvent = "lostpointercapture" OnMouseDown OnEvent = "mousedown" OnMouseEnter OnEvent = "mouseenter" OnMouseLeave OnEvent = "mouseleave" OnMouseMove OnEvent = "mousemove" OnMouseOut OnEvent = "mouseout" OnMouseOver OnEvent = "mouseover" OnMouseUp OnEvent = "mouseup" OnPause OnEvent = "pause" OnPlay OnEvent = "play" OnPlaying OnEvent = "playing" OnPointerCancel OnEvent = "pointercancel" OnPointerDown OnEvent = "pointerdown" OnPointerEnter OnEvent = "pointerenter" OnPointerLeave OnEvent = "pointerleave" OnPointerMove OnEvent = "pointermove" OnPointerOut OnEvent = "pointerout" OnPointerOver OnEvent = "pointerover" OnPointerUp OnEvent = "pointerup" OnProgress OnEvent = "progress" OnRateChange OnEvent = "ratechange" OnResetCapture OnEvent = "resetcapture" OnScroll OnEvent = "scroll" OnSeeked OnEvent = "seeked" OnSeeking OnEvent = "seeking" OnSelectCapture OnEvent = "selectcapture" OnStalled OnEvent = "stalled" OnSubmit OnEvent = "submit" OnSuspend OnEvent = "suspend" OnTimeUpdate OnEvent = "timeupdate" OnToggle OnEvent = "toggle" OnTouchCancel OnEvent = "touchcancel" OnTouchEnd OnEvent = "touchend" OnTouchMove OnEvent = "touchmove" OnTouchStart OnEvent = "touchstart" OnTransitionEnd OnEvent = "transitionend" OnVolumeChange OnEvent = "volumechange" OnWaiting OnEvent = "waiting" OnWheel OnEvent = "wheel" )
DOM event types.
type PointerEvent ¶
type PointerEvent struct {
IsTrusted bool `json:"isTrusted"`
AltKey bool `json:"altKey"`
Bubbles bool `json:"bubbles"`
Button int `json:"button"`
Buttons int `json:"buttons"`
Cancelable bool `json:"cancelable"`
ClientX int `json:"clientX"`
ClientY int `json:"clientY"`
Composed bool `json:"composed"`
CtrlKey bool `json:"ctrlKey"`
Component EventTarget `json:"component"`
DefaultPrevented bool `json:"defaultPrevented"`
Detail int `json:"detail"`
EventPhase int `json:"eventPhase"`
Height int `json:"height"`
IsPrimary bool `json:"isPrimary"`
MetaKey bool `json:"metaKey"`
MovementX int `json:"movementX"`
MovementY int `json:"movementY"`
OffsetX int `json:"offsetX"`
OffsetY int `json:"offsetY"`
PageX int `json:"pageX"`
PageY int `json:"pageY"`
PointerId int `json:"pointerId"`
PointerType string `json:"pointerType"`
Pressure int `json:"pressure"`
RelatedTarget EventTarget `json:"relatedTarget"`
Source EventTarget `json:"source"`
}
PointerEvent contains the pointer payload sent by the browser client.
type Touch ¶
type Touch struct {
ClientX int `json:"clientX"`
ClientY int `json:"clientY"`
Identifier int `json:"identifier"`
PageX int `json:"pageX"`
PageY int `json:"pageY"`
RadiusX float64 `json:"radiusX"`
RadiusY float64 `json:"radiusY"`
RotationAngle int `json:"rotationAngle"`
ScreenX int `json:"screenX"`
ScreenY int `json:"screenY"`
Source EventTarget `json:"source"`
}
Touch contains one browser touch point from a TouchEvent.
type TouchEvent ¶
type TouchEvent struct {
ChangedTouches []Touch `json:"changedTouches"`
Component EventTarget `json:"component"`
Source EventTarget `json:"source"`
TargetTouches []Touch `json:"targetTouches"`
Touches []Touch `json:"touches"`
LayerX int `json:"layerX"`
LayerY int `json:"layerY"`
PageX int `json:"pageX"`
PageY int `json:"pageY"`
}
TouchEvent contains the touch payload sent by the browser client.
type Upload ¶
type Upload struct {
ID string `json:"id"`
FieldName string `json:"field_name"`
FileName string `json:"file_name"`
ContentType string `json:"content_type"`
Size int64 `json:"size"`
Path string `json:"path"`
}
Upload describes one file uploaded for an event.
func EventUploads ¶
EventUploads returns file metadata uploaded before the current event dispatch.
File bytes are posted to neith's upload endpoint over HTTP. EventData still contains normal form values, and EventUploads exposes the uploaded files.