vorma

package
v0.83.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: BSD-3-Clause Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VormaPathsStageOneJSONFileName = "vorma_paths_stage_1.json"
	VormaPathsStageTwoJSONFileName = "vorma_paths_stage_2.json"
)
View Source
const VormaBuildIDHeaderKey = "X-Vorma-Build-Id"
View Source
const VormaJSONQueryKey = "vorma_json"
View Source
const (
	VormaSymbolStr = "__vorma_internal__"
)

Variables

View Source
var Log = colorlog.New("vorma")
View Source
var RouteTypes = struct {
	Loader   RouteType
	Query    RouteType
	Mutation RouteType
	NotFound RouteType
}{
	Loader:   "loader",
	Query:    "query",
	Mutation: "mutation",
	NotFound: "not-found",
}
View Source
var UIVariants = struct {
	React  UIVariant
	Preact UIVariant
	Solid  UIVariant
}{
	React:  "react",
	Preact: "preact",
	Solid:  "solid",
}

Functions

func IsJSONRequest

func IsJSONRequest(r *http.Request) bool

If true, is JSON, but may or may not be from an up-to-date client.

func PrettyPrintFS

func PrettyPrintFS(fsys fs.FS) error

Types

type ActionReqData

type ActionReqData[I any] = mux.ReqData[I]

type Actions

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

func (*Actions) Handler

func (h *Actions) Handler() http.Handler

func (*Actions) HandlerMountPattern

func (h *Actions) HandlerMountPattern() string

func (*Actions) SupportedMethods

func (h *Actions) SupportedMethods() map[string]bool

type ActionsRouter

type ActionsRouter struct {
	*mux.Router
	// contains filtered or unexported fields
}

type ActionsRouterOptions

type ActionsRouterOptions struct {
	// Default: ':' (e.g., /user/:id)
	DynamicParamPrefix rune
	// Default: '*' (e.g., /files/*)
	SplatSegmentIdentifier rune
	// Default: "/api/"
	MountRoot string
	// Default: []string{"GET", "POST", "PUT", "DELETE", "PATCH"}
	SupportedMethods []string
}

type AdHocType

type AdHocType = rpc.AdHocType

type BuildOptions

type BuildOptions struct {
	AdHocTypes  []*AdHocType
	ExtraTSCode string
}

type FormData

type FormData struct{}

func (FormData) TSTypeRaw

func (m FormData) TSTypeRaw() string

type GetDefaultHeadElsFunc

type GetDefaultHeadElsFunc func(r *http.Request, app *Vorma, head *headels.HeadEls) error

type GetHeadElUniqueRulesFunc

type GetHeadElUniqueRulesFunc func(head *headels.HeadEls)

type GetRootTemplateDataFunc

type GetRootTemplateDataFunc func(r *http.Request) (map[string]any, error)

type GetSSRInnerHTMLOutput

type GetSSRInnerHTMLOutput struct {
	Script     *template.HTML
	Sha256Hash string
}

type LoaderReqData

type LoaderReqData = mux.NestedReqData

type Loaders

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

func (*Loaders) Handler

func (h *Loaders) Handler() http.Handler

func (*Loaders) HandlerMountPattern

func (h *Loaders) HandlerMountPattern() string

type LoadersRouter

type LoadersRouter struct {
	*mux.NestedRouter
}

type LoadersRouterOptions

type LoadersRouterOptions struct {
	// Default: ':' (e.g., /user/:id)
	DynamicParamPrefix rune
	// Default: '*' (e.g., /files/*)
	SplatSegmentIdentifier rune
	// Default: "_index" (e.g., /blog/_index)
	IndexSegmentIdentifier string
}

type NodeScriptResult

type NodeScriptResult []NodeScriptResultItem

type NodeScriptResultItem

type NodeScriptResultItem struct {
	Pattern  string `json:"p"`
	Module   string `json:"m"`
	Key      string `json:"k"`
	ErrorKey string `json:"ek,omitempty"`
}

type Path

type Path struct {
	NestedRoute mux.AnyNestedRoute `json:"-"`

	// both stages one and two
	OriginalPattern string `json:"originalPattern"`
	SrcPath         string `json:"srcPath"`
	ExportKey       string `json:"exportKey"`
	ErrorExportKey  string `json:"errorExportKey,omitempty"`

	// stage two only
	OutPath string   `json:"outPath,omitempty"`
	Deps    []string `json:"deps,omitempty"`
}

type PathsFile

type PathsFile struct {
	// both stages one and two
	Stage             string           `json:"stage"`
	BuildID           string           `json:"buildID,omitempty"`
	ClientEntrySrc    string           `json:"clientEntrySrc"`
	Paths             map[string]*Path `json:"paths"`
	RouteManifestFile string           `json:"routeManifestFile"`

	// stage two only
	ClientEntryOut    string            `json:"clientEntryOut,omitempty"`
	ClientEntryDeps   []string          `json:"clientEntryDeps,omitempty"`
	DepToCSSBundleMap map[string]string `json:"depToCSSBundleMap,omitempty"`
}

type Route

type Route[I any, O any] = mux.Route[I, O]

type RouteCall

type RouteCall struct {
	Pattern  string
	Module   string
	Key      string
	ErrorKey string
}

RouteCall represents a parsed route() function call.

type RouteType

type RouteType = string

type SSRInnerHTMLInput

type SSRInnerHTMLInput struct {
	VormaSymbolStr string

	IsDev            bool
	ViteDevURL       string
	BuildID          string
	PublicPathPrefix string
	DeploymentID     string
	RouteManifestURL string

	CSSBundles []string
	// contains filtered or unexported fields
}

type SplatValues

type SplatValues []string

type TaskHandler

type TaskHandler[I any, O any] = mux.TaskHandler[I, O]

type UIVariant

type UIVariant string

type Vorma

type Vorma struct {
	*wave.Wave
	// contains filtered or unexported fields
}

func NewVormaApp

func NewVormaApp(o VormaAppConfig) *Vorma

func (*Vorma) Actions

func (v *Vorma) Actions() *Actions

func (*Vorma) ActionsRouter

func (v *Vorma) ActionsRouter() *ActionsRouter

func (*Vorma) Build

func (v *Vorma) Build(o ...BuildOptions)

func (*Vorma) GetActionsHandler

func (v *Vorma) GetActionsHandler(router *mux.Router) mux.TasksCtxRequirerFunc

func (*Vorma) GetCurrentBuildID

func (v *Vorma) GetCurrentBuildID() string

GetCurrentBuildID returns the current build ID of the Vorma instance.

func (*Vorma) GetLoadersHandler

func (v *Vorma) GetLoadersHandler(nestedRouter *mux.NestedRouter) mux.TasksCtxRequirerFunc

func (*Vorma) GetUIHandler deprecated

func (v *Vorma) GetUIHandler(nestedRouter *mux.NestedRouter) mux.TasksCtxRequirerFunc

Deprecated: use GetLoadersHandler instead.

func (*Vorma) Init

func (v *Vorma) Init()

Inits Vorma. Panics on error in production; logs error in dev mode.

func (*Vorma) InitWithDefaultRouter added in v0.83.0

func (v *Vorma) InitWithDefaultRouter() *mux.Router

Inits Vorma and returns a default mux.Router with all loaders and actions registered. To use a different router, call Vorma.Init() and then register the handlers manually with whatever third-party router you may want to use (see the implementation of this function for reference on how to do that).

func (*Vorma) IsCurrentBuildJSONRequest

func (v *Vorma) IsCurrentBuildJSONRequest(r *http.Request) bool

If true, is both (1) JSON and (2) guaranteed to be from a client that has knowledge of the latest build ID.

func (*Vorma) Loaders

func (v *Vorma) Loaders() *Loaders

func (*Vorma) LoadersRouter

func (v *Vorma) LoadersRouter() *LoadersRouter

func (*Vorma) ServeStatic

func (v *Vorma) ServeStatic() func(http.Handler) http.Handler

func (*Vorma) ServerAddr

func (v *Vorma) ServerAddr() string

type VormaAppConfig

type VormaAppConfig struct {
	Wave *wave.Wave

	GetDefaultHeadEls    GetDefaultHeadElsFunc
	GetHeadElUniqueRules GetHeadElUniqueRulesFunc
	GetRootTemplateData  GetRootTemplateDataFunc

	LoadersRouterOptions LoadersRouterOptions
	ActionsRouterOptions ActionsRouterOptions
}

Jump to

Keyboard shortcuts

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