Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteSSE(urlFormat string, args ...any) string
- func GetSSE(urlFormat string, args ...any) string
- func ParseIncoming(r *http.Request, store any) error
- func PatchSSE(urlFormat string, args ...any) string
- func PostSSE(urlFormat string, args ...any) string
- func PutSSE(urlFormat string, args ...any) string
- type ConsoleMode
- type EventType
- type FragmentMergeMode
- type PatchStoreOption
- type PatchStoreOptions
- type RemoveFragmentOption
- type RemoveFragmentOptions
- type RenderFragmentOption
- func WithMergeAfter() RenderFragmentOption
- func WithMergeAppend() RenderFragmentOption
- func WithMergeBefore() RenderFragmentOption
- func WithMergeMode(merge FragmentMergeMode) RenderFragmentOption
- func WithMergeMorph() RenderFragmentOption
- func WithMergePrepend() RenderFragmentOption
- func WithMergeUpsertAttributes() RenderFragmentOption
- func WithQuerySelectorID(id string) RenderFragmentOption
- func WithSelector(selector string) RenderFragmentOption
- func WithSelectorf(selectorFormat string, args ...any) RenderFragmentOption
- func WithSettleDuration(d time.Duration) RenderFragmentOption
- func WithUseViewTransitions(useViewTransition bool) RenderFragmentOption
- func WithViewTransitions() RenderFragmentOption
- func WithoutViewTransitions() RenderFragmentOption
- type RenderFragmentOptions
- type SSEEventOption
- type ServerSentEventData
- type ServerSentEventGenerator
- func (sse *ServerSentEventGenerator) Console(mode ConsoleMode, message string, opts ...SSEEventOption) error
- func (sse *ServerSentEventGenerator) ConsoleDebug(message string, opts ...SSEEventOption) error
- func (sse *ServerSentEventGenerator) ConsoleDebugf(format string, args ...any) error
- func (sse *ServerSentEventGenerator) ConsoleErr(err error) error
- func (sse *ServerSentEventGenerator) ConsoleError(message string, opts ...SSEEventOption) error
- func (sse *ServerSentEventGenerator) ConsoleErrorf(format string, args ...any) error
- func (sse *ServerSentEventGenerator) ConsoleGroup(label string, opts ...SSEEventOption) error
- func (sse *ServerSentEventGenerator) ConsoleGroupEnd(opts ...SSEEventOption) error
- func (sse *ServerSentEventGenerator) ConsoleGroupf(labelFormat string, args ...any) error
- func (sse *ServerSentEventGenerator) ConsoleInfo(message string, opts ...SSEEventOption) error
- func (sse *ServerSentEventGenerator) ConsoleInfof(format string, args ...any) error
- func (sse *ServerSentEventGenerator) ConsoleLog(message string, opts ...SSEEventOption) error
- func (sse *ServerSentEventGenerator) ConsoleLogf(format string, args ...any) error
- func (sse *ServerSentEventGenerator) ConsoleWarn(message string, opts ...SSEEventOption) error
- func (sse *ServerSentEventGenerator) ConsoleWarnf(format string, args ...any) error
- func (sse *ServerSentEventGenerator) Consolef(mode ConsoleMode, messageFormat string, args ...any) error
- func (sse *ServerSentEventGenerator) Context() context.Context
- func (sse *ServerSentEventGenerator) DeleteFromStore(paths ...string) error
- func (sse *ServerSentEventGenerator) MarshalAndPatchStore(store any, opts ...PatchStoreOption) error
- func (sse *ServerSentEventGenerator) MarshalAndPatchStoreIfMissing(store any, opts ...PatchStoreOption) error
- func (sse *ServerSentEventGenerator) PatchStore(storeContents []byte, opts ...PatchStoreOption) error
- func (sse *ServerSentEventGenerator) PatchStoreIfMissingRaw(storeJSON string) error
- func (sse *ServerSentEventGenerator) Redirect(url string, opts ...SSEEventOption) error
- func (sse *ServerSentEventGenerator) Redirectf(format string, args ...any) error
- func (sse *ServerSentEventGenerator) RemoveFragments(selector string, opts ...RemoveFragmentOption) error
- func (sse *ServerSentEventGenerator) RenderFragment(fragment string, opts ...RenderFragmentOption) error
- func (sse *ServerSentEventGenerator) RenderFragmentGostar(child elements.ElementRenderer, opts ...RenderFragmentOption) error
- func (sse *ServerSentEventGenerator) RenderFragmentTempl(c templ.Component, opts ...RenderFragmentOption) error
- func (sse *ServerSentEventGenerator) RenderFragmentf(format string, args ...any) error
Constants ¶
View Source
const ( DatastarKey = "datastar" Version = "0.20.0" VersionClientByteSize = 43803 VersionClientByteSizeGzip = 14866 DefaultSettleDuration = 300 * time.Millisecond DefaultSSERetryDuration = 1000 * time.Millisecond DefaultUseViewTransitions = false DefaultOnlyIfMissing = false SelectorDatalineLiteral = "selector " MergeDatalineLiteral = "merge " SettleDurationDatalineLiteral = "settleDuration " FragmentDatalineLiteral = "fragment " UseViewTransitionDatalineLiteral = "useViewTransition " StoreDatalineLiteral = "store " OnlyIfMissingDatalineLiteral = "onlyIfMissing " UrlDatalineLiteral = "url " PathsDatalineLiteral = "paths " )
Variables ¶
View Source
var (
ErrEventTypeError = errors.New("event type is required")
)
View Source
var (
ErrNoPathsProvided = errors.New("no paths provided")
)
Functions ¶
Types ¶
type ConsoleMode ¶
type ConsoleMode string
const ( // Writes an error message to the console if the assertion is false. If the assertion is true, nothing happens. ConsoleModeAssert ConsoleMode = "assert" // Clears the console if the console allows it. A graphical console, like those running on browsers, will allow it; a console displaying on the terminal, like the one running on Node, will not support it, and will have no effect (and no error). ConsoleModeClear ConsoleMode = "clear" // Logs the number of times that this particular call to count() has been called. ConsoleModeCount ConsoleMode = "count" // Resets counter used with console.count(). ConsoleModeCountReset ConsoleMode = "countReset" // Outputs a message to the console at the 'debug' log level. The message is only displayed to the user if the console is configured to display debug output. In most cases, the log level is configured within the console UI. This log level might correspond to the Debug or Verbose log level. ConsoleModeDebug ConsoleMode = "debug" // Displays a list of the properties of the specified JavaScript object. In browser consoles, the output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects. Unlike other logging methods, console.dir() does not attempt to pretty-print the object. For example, if you pass a DOM element to console.dir(), it will not be displayed like in the element inspector, but will instead show a list of properties. ConsoleModeDir ConsoleMode = "dir" // Displays an interactive tree of the descendant elements of the specified XML/HTML element. If it is not possible to display as an element the JavaScript Object view is shown instead. The output is presented as a hierarchical listing of expandable nodes that let you see the contents of child nodes. ConsoleModeDirxml ConsoleMode = "dirxml" // Outputs a message to the console at the 'error' log level. ConsoleModeError ConsoleMode = "error" // Creates a new inline group in the Web console log, causing any subsequent console messages to be indented by an additional level, until console.groupEnd() is called. ConsoleModeGroup ConsoleMode = "group" // Creates a new inline group in the console. Unlike console.group(), however, the new group is created collapsed. The user will need to use the disclosure button next to it to expand it, revealing the entries created in the group. Call console.groupEnd() to back out to the parent group. ConsoleModeGroupCollapsed ConsoleMode = "groupCollapsed" // Exits the current inline group in the console. ConsoleModeGroupEnd ConsoleMode = "groupEnd" // Outputs a message to the console at the 'info' log level. ConsoleModeInfo ConsoleMode = "info" // Outputs a message to the console. ConsoleModeLog ConsoleMode = "log" // Displays tabular data as a table. ConsoleModeTable ConsoleMode = "table" // Starts a timer you can use to track how long an operation takes. You give each timer a unique name, and may have up to 10,000 timers running on a given page. When you call console.timeEnd() with the same name, the browser will output the time, in milliseconds, that elapsed since the timer was started. ConsoleModeTime ConsoleMode = "time" // The console.timeEnd() static method stops a timer that was previously started by calling console.time(). ConsoleModeTimeEnd ConsoleMode = "timeEnd" // Logs the current value of a timer that was previously started by calling console.time(). ConsoleModeTimeLog ConsoleMode = "timeLog" // Outputs a stack trace to the console. ConsoleModeTrace ConsoleMode = "trace" // Outputs a warning message to the console at the 'warning' log level. ConsoleModeWarn ConsoleMode = "warn" )
type EventType ¶
type EventType string
const ( // An event dealing with HTML fragments EventTypeFragment EventType = "datastar-fragment" // An event dealing with fine grain signals EventTypeSignal EventType = "datastar-signal" // An event dealing with removing elements or signals EventTypeRemove EventType = "datastar-remove" // An event dealing with redirecting the browser EventTypeRedirect EventType = "datastar-redirect" // An event dealing with console messages EventTypeConsole EventType = "datastar-console" )
type FragmentMergeMode ¶
type FragmentMergeMode string
const ( // Default value for FragmentMergeMode DefaultFragmentMergeMode = FragmentMergeModeMorph // Morphs the fragment into the existing element using idiomorph. FragmentMergeModeMorph FragmentMergeMode = "morph" // Replaces the inner HTML of the existing element. FragmentMergeModeInner FragmentMergeMode = "inner" // Replaces the outer HTML of the existing element. FragmentMergeModeOuter FragmentMergeMode = "outer" // Prepends the fragment to the existing element. FragmentMergeModePrepend FragmentMergeMode = "prepend" // Appends the fragment to the existing element. FragmentMergeModeAppend FragmentMergeMode = "append" // Inserts the fragment before the existing element. FragmentMergeModeBefore FragmentMergeMode = "before" // Inserts the fragment after the existing element. FragmentMergeModeAfter FragmentMergeMode = "after" // Upserts the attributes of the existing element. FragmentMergeModeUpsertAttributes FragmentMergeMode = "upsertAttributes" )
func FragmentMergeTypeFromString ¶
func FragmentMergeTypeFromString(s string) (FragmentMergeMode, error)
type PatchStoreOption ¶
type PatchStoreOption func(*PatchStoreOptions)
func WithOnlyIfMissing ¶
func WithOnlyIfMissing(onlyIfMissing bool) PatchStoreOption
func WithPatchStoreEventID ¶
func WithPatchStoreEventID(id string) PatchStoreOption
func WithPatchStoreRetryDuration ¶
func WithPatchStoreRetryDuration(retryDuration time.Duration) PatchStoreOption
type PatchStoreOptions ¶
type RemoveFragmentOption ¶
type RemoveFragmentOption func(*RemoveFragmentOptions)
func WithRemoveEventID ¶
func WithRemoveEventID(id string) RemoveFragmentOption
func WithRemoveRetryDuration ¶
func WithRemoveRetryDuration(d time.Duration) RemoveFragmentOption
func WithRemoveSettleDuration ¶
func WithRemoveSettleDuration(d time.Duration) RemoveFragmentOption
func WithRemoveUseViewTransitions ¶
func WithRemoveUseViewTransitions(useViewTransition bool) RemoveFragmentOption
type RemoveFragmentOptions ¶
type RenderFragmentOption ¶
type RenderFragmentOption func(*RenderFragmentOptions)
func WithMergeAfter ¶
func WithMergeAfter() RenderFragmentOption
func WithMergeAppend ¶
func WithMergeAppend() RenderFragmentOption
func WithMergeBefore ¶
func WithMergeBefore() RenderFragmentOption
func WithMergeMode ¶
func WithMergeMode(merge FragmentMergeMode) RenderFragmentOption
func WithMergeMorph ¶
func WithMergeMorph() RenderFragmentOption
func WithMergePrepend ¶
func WithMergePrepend() RenderFragmentOption
func WithMergeUpsertAttributes ¶
func WithMergeUpsertAttributes() RenderFragmentOption
func WithQuerySelectorID ¶
func WithQuerySelectorID(id string) RenderFragmentOption
func WithSelector ¶
func WithSelector(selector string) RenderFragmentOption
func WithSelectorf ¶
func WithSelectorf(selectorFormat string, args ...any) RenderFragmentOption
func WithSettleDuration ¶
func WithSettleDuration(d time.Duration) RenderFragmentOption
func WithUseViewTransitions ¶
func WithUseViewTransitions(useViewTransition bool) RenderFragmentOption
func WithViewTransitions ¶
func WithViewTransitions() RenderFragmentOption
func WithoutViewTransitions ¶
func WithoutViewTransitions() RenderFragmentOption
type RenderFragmentOptions ¶
type SSEEventOption ¶
type SSEEventOption func(*ServerSentEventData)
func WithSSEEventId ¶
func WithSSEEventId(id string) SSEEventOption
func WithSSERetryDuration ¶
func WithSSERetryDuration(retryDuration time.Duration) SSEEventOption
type ServerSentEventData ¶
type ServerSentEventGenerator ¶
type ServerSentEventGenerator struct {
// contains filtered or unexported fields
}
func NewSSE ¶
func NewSSE(w http.ResponseWriter, r *http.Request) *ServerSentEventGenerator
func (*ServerSentEventGenerator) Console ¶
func (sse *ServerSentEventGenerator) Console(mode ConsoleMode, message string, opts ...SSEEventOption) error
func (*ServerSentEventGenerator) ConsoleDebug ¶
func (sse *ServerSentEventGenerator) ConsoleDebug(message string, opts ...SSEEventOption) error
func (*ServerSentEventGenerator) ConsoleDebugf ¶
func (sse *ServerSentEventGenerator) ConsoleDebugf(format string, args ...any) error
func (*ServerSentEventGenerator) ConsoleErr ¶
func (sse *ServerSentEventGenerator) ConsoleErr(err error) error
func (*ServerSentEventGenerator) ConsoleError ¶
func (sse *ServerSentEventGenerator) ConsoleError(message string, opts ...SSEEventOption) error
func (*ServerSentEventGenerator) ConsoleErrorf ¶
func (sse *ServerSentEventGenerator) ConsoleErrorf(format string, args ...any) error
func (*ServerSentEventGenerator) ConsoleGroup ¶
func (sse *ServerSentEventGenerator) ConsoleGroup(label string, opts ...SSEEventOption) error
func (*ServerSentEventGenerator) ConsoleGroupEnd ¶
func (sse *ServerSentEventGenerator) ConsoleGroupEnd(opts ...SSEEventOption) error
func (*ServerSentEventGenerator) ConsoleGroupf ¶
func (sse *ServerSentEventGenerator) ConsoleGroupf(labelFormat string, args ...any) error
func (*ServerSentEventGenerator) ConsoleInfo ¶
func (sse *ServerSentEventGenerator) ConsoleInfo(message string, opts ...SSEEventOption) error
func (*ServerSentEventGenerator) ConsoleInfof ¶
func (sse *ServerSentEventGenerator) ConsoleInfof(format string, args ...any) error
func (*ServerSentEventGenerator) ConsoleLog ¶
func (sse *ServerSentEventGenerator) ConsoleLog(message string, opts ...SSEEventOption) error
func (*ServerSentEventGenerator) ConsoleLogf ¶
func (sse *ServerSentEventGenerator) ConsoleLogf(format string, args ...any) error
func (*ServerSentEventGenerator) ConsoleWarn ¶
func (sse *ServerSentEventGenerator) ConsoleWarn(message string, opts ...SSEEventOption) error
func (*ServerSentEventGenerator) ConsoleWarnf ¶
func (sse *ServerSentEventGenerator) ConsoleWarnf(format string, args ...any) error
func (*ServerSentEventGenerator) Consolef ¶
func (sse *ServerSentEventGenerator) Consolef(mode ConsoleMode, messageFormat string, args ...any) error
func (*ServerSentEventGenerator) Context ¶
func (sse *ServerSentEventGenerator) Context() context.Context
func (*ServerSentEventGenerator) DeleteFromStore ¶
func (sse *ServerSentEventGenerator) DeleteFromStore(paths ...string) error
func (*ServerSentEventGenerator) MarshalAndPatchStore ¶
func (sse *ServerSentEventGenerator) MarshalAndPatchStore(store any, opts ...PatchStoreOption) error
func (*ServerSentEventGenerator) MarshalAndPatchStoreIfMissing ¶
func (sse *ServerSentEventGenerator) MarshalAndPatchStoreIfMissing(store any, opts ...PatchStoreOption) error
func (*ServerSentEventGenerator) PatchStore ¶
func (sse *ServerSentEventGenerator) PatchStore(storeContents []byte, opts ...PatchStoreOption) error
func (*ServerSentEventGenerator) PatchStoreIfMissingRaw ¶
func (sse *ServerSentEventGenerator) PatchStoreIfMissingRaw(storeJSON string) error
func (*ServerSentEventGenerator) Redirect ¶
func (sse *ServerSentEventGenerator) Redirect(url string, opts ...SSEEventOption) error
func (*ServerSentEventGenerator) Redirectf ¶
func (sse *ServerSentEventGenerator) Redirectf(format string, args ...any) error
func (*ServerSentEventGenerator) RemoveFragments ¶
func (sse *ServerSentEventGenerator) RemoveFragments(selector string, opts ...RemoveFragmentOption) error
func (*ServerSentEventGenerator) RenderFragment ¶
func (sse *ServerSentEventGenerator) RenderFragment(fragment string, opts ...RenderFragmentOption) error
func (*ServerSentEventGenerator) RenderFragmentGostar ¶
func (sse *ServerSentEventGenerator) RenderFragmentGostar(child elements.ElementRenderer, opts ...RenderFragmentOption) error
func (*ServerSentEventGenerator) RenderFragmentTempl ¶
func (sse *ServerSentEventGenerator) RenderFragmentTempl(c templ.Component, opts ...RenderFragmentOption) error
func (*ServerSentEventGenerator) RenderFragmentf ¶
func (sse *ServerSentEventGenerator) RenderFragmentf(format string, args ...any) error
Click to show internal directories.
Click to hide internal directories.