package datastar import ( "fmt" "strconv" "strings" "time" ) // executeScriptOptions hold script options that will be translated to [SSEEventOptions]. type executeScriptOptions struct { EventID string RetryDuration time.Duration Attributes []string AutoRemove *bool } // ExecuteScriptOption configures script execution event that will be sent to the client. type ExecuteScriptOption func(*executeScriptOptions) // WithExecuteScriptEventID configures an optional event ID for the script execution event. // The client message field [lastEventId] will be set to this value. // If the next event does not have an event ID, the last used event ID will remain. // // [lastEventId]: https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/lastEventId func WithExecuteScriptEventID(id string) ExecuteScriptOption { return func(o *executeScriptOptions) { o.EventID = id } } // WithExecuteScriptRetryDuration overrides the [DefaultSseRetryDuration] for this script // execution only. func WithExecuteScriptRetryDuration(retryDuration time.Duration) ExecuteScriptOption { return func(o *executeScriptOptions) { o.RetryDuration = retryDuration } } // WithExecuteScriptAttributes overrides the default script attribute // value `type module`, which renders as `