handlers

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedModule added in v0.3.0

type CachedModule struct {
	Exports      *js.Object
	LastModified time.Time
}

CachedModule represents a cached JavaScript module

type CachedResult added in v0.4.0

type CachedResult struct {
	HTML        string
	ContentHash string // MD5 hash of the source content
	ConfigHash  string // Hash of config for cache invalidation
}

type JSEnginePool added in v0.3.0

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

JSEnginePool manages a pool of JavaScript engines

func GetJSEnginePool added in v0.3.0

func GetJSEnginePool(fs filesystem.FileSystem, version string) *JSEnginePool

GetJSEnginePool returns a JavaScript engine pool for the given filesystem

func (*JSEnginePool) GetEngine added in v0.3.0

func (pool *JSEnginePool) GetEngine() (*SharedJSEngine, error)

GetEngine gets an available engine from the pool

func (*JSEnginePool) GetEngineForSession added in v0.3.0

func (pool *JSEnginePool) GetEngineForSession(sessionID string) (*SharedJSEngine, error)

GetEngineForSession gets an engine specifically for a session/client

func (*JSEnginePool) ReleaseSessionEngine added in v0.3.0

func (pool *JSEnginePool) ReleaseSessionEngine(sessionID string)

ReleaseSessionEngine releases an engine from a session (for cleanup)

func (*JSEnginePool) ReturnEngine added in v0.3.0

func (pool *JSEnginePool) ReturnEngine(engine *SharedJSEngine)

ReturnEngine returns an engine to the pool

func (*JSEnginePool) Stop added in v0.3.0

func (pool *JSEnginePool) Stop()

Stop stops all engines in the pool

type JavaScriptHandler

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

func NewJavaScriptHandler

func NewJavaScriptHandler(fs filesystem.FileSystem) *JavaScriptHandler

func NewJavaScriptHandlerWithVersion

func NewJavaScriptHandlerWithVersion(fs filesystem.FileSystem, version string) *JavaScriptHandler

func (*JavaScriptHandler) Handle

func (jh *JavaScriptHandler) Handle(route Route) http.HandlerFunc

type Route

type Route struct {
	Path      string
	FilePath  string
	FileType  string
	IsDynamic bool
	ParamName string
}

Route represents a single route in the application

type SharedJSEngine added in v0.3.0

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

SharedJSEngine manages a shared JavaScript environment with module caching

func (*SharedJSEngine) ExecuteHTTPMethod added in v0.3.0

func (engine *SharedJSEngine) ExecuteHTTPMethod(r *http.Request, w http.ResponseWriter, route Route) error

ExecuteHTTPMethod executes an HTTP method handler from a JavaScript module

func (*SharedJSEngine) Start added in v0.3.0

func (engine *SharedJSEngine) Start() error

Start initializes the shared JavaScript engine

func (*SharedJSEngine) Stop added in v0.3.0

func (engine *SharedJSEngine) Stop()

Stop shuts down the shared JavaScript engine

type SvelteCompileResult added in v0.4.0

type SvelteCompileResult struct {
	JS  string `json:"js"`
	CSS string `json:"css"`
}

type SvelteConfig added in v0.4.0

type SvelteConfig struct {
	// Minification settings
	MinifyRuntime    bool // Enable runtime minification
	MinifyComponents bool // Enable component code minification
	MinifyCSS        bool // Enable CSS minification
	DevMode          bool // Disable minification in development

	// Runtime resource settings
	UseExternalRuntime   bool          // Use external runtime file instead of inline
	RuntimePath          string        // Path for runtime resource (default: "/svelte-runtime.js")
	RuntimeCacheDuration time.Duration // Cache duration for runtime resource

	// Vimesh Style settings
	VimeshStyle     *utils.VimeshStyleConfig // Vimesh Style configuration
	VimeshStylePath string                   // Path for Vimesh Style resource (default: "/svelte-vimesh-style.js")
}

SvelteConfig holds all Svelte-related settings

func DefaultSvelteConfig added in v0.4.0

func DefaultSvelteConfig() *SvelteConfig

DefaultSvelteConfig returns default Svelte settings

type SvelteHandler added in v0.4.0

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

func NewSvelteHandler added in v0.4.0

func NewSvelteHandler(fs filesystem.FileSystem) *SvelteHandler

func NewSvelteHandlerWithConfig added in v0.4.0

func NewSvelteHandlerWithConfig(fs filesystem.FileSystem, config *SvelteConfig) *SvelteHandler

func NewSvelteHandlerWithRouter added in v0.4.0

func NewSvelteHandlerWithRouter(fs filesystem.FileSystem, config *SvelteConfig, router *mux.Router) *SvelteHandler

NewSvelteHandlerWithRouter creates a SvelteHandler and registers runtime routes

func (*SvelteHandler) Handle added in v0.4.0

func (sh *SvelteHandler) Handle(route Route) http.HandlerFunc

func (*SvelteHandler) RegisterRoutes added in v0.4.0

func (sh *SvelteHandler) RegisterRoutes(router *mux.Router)

RegisterRoutes registers Svelte-related routes

func (*SvelteHandler) ServeSvelteRuntime added in v0.4.0

func (sh *SvelteHandler) ServeSvelteRuntime(w http.ResponseWriter, r *http.Request)

ServeSvelteRuntime serves the Svelte runtime as a static resource

func (*SvelteHandler) ServeVimeshStyle added in v0.4.0

func (sh *SvelteHandler) ServeVimeshStyle(w http.ResponseWriter, r *http.Request)

ServeVimeshStyle serves the Vimesh Style JavaScript as a static resource

type TemplateHandler added in v0.3.0

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

func NewTemplateHandler added in v0.3.0

func NewTemplateHandler(fs filesystem.FileSystem) *TemplateHandler

func (*TemplateHandler) Handle added in v0.3.0

func (th *TemplateHandler) Handle(route Route) http.HandlerFunc

func (*TemplateHandler) RenderTemplate added in v0.3.0

func (th *TemplateHandler) RenderTemplate(templatePath, templateContent string, data interface{}, w http.ResponseWriter) error

RenderTemplate renders a template file with the given data

type VMManager added in v0.2.0

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

VMManager manages JavaScript VM creation and module initialization

func NewVMManager added in v0.2.0

func NewVMManager(fs filesystem.FileSystem, version string) *VMManager

NewVMManager creates a new VM manager

func (*VMManager) SetupRegistry added in v0.2.0

func (vm *VMManager) SetupRegistry(loop *eventloop.EventLoop, jsVM *js.Runtime, basePath string) (*require.Registry, *require.RequireModule, error)

SetupRegistry creates and configures a require registry with all modules

Jump to

Keyboard shortcuts

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