qinternal

package
v0.0.0-...-3ce78d1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsRawBytes

func AsRawBytes(c Content) ([]byte, error)

func BuildContentRoutes

func BuildContentRoutes(contentRoot string, options RouteOptions) (map[string]ContentRoute, error)

func BuildViewSourceIndexHTML

func BuildViewSourceIndexHTML(recipeAssets []RecipeSourceAsset, markdownRequestPaths []string) []byte

func CanonicalRequestPath

func CanonicalRequestPath(requestPath string, options RouteOptions) (string, bool)

func CollectMarkdownRequestPathsFromRoutes

func CollectMarkdownRequestPathsFromRoutes(routes map[string]ContentRoute) []string

func ContentTypeOf

func ContentTypeOf(content Content) string

func DecodeBMPToRGBA

func DecodeBMPToRGBA(input []byte) (*image.RGBA, error)

func EncodeRGBAToBMP

func EncodeRGBAToBMP(img *image.RGBA) ([]byte, error)

func FilterMarkdownRequestPaths

func FilterMarkdownRequestPaths(paths []string) []string

func GetBMPDimensions

func GetBMPDimensions(data []byte) (int, int, error)

func NewRequestHandler

func NewRequestHandler(config RequestHandlerConfig) http.Handler

func RGBAF32ToRGBA

func RGBAF32ToRGBA(rgba RGBAF32Content) *image.RGBA

func RGBAToRGBAF32

func RGBAToRGBAF32(img *image.RGBA) []float32

func RunComplyCommand

func RunComplyCommand(args []string) error

func RunFormCommand

func RunFormCommand(args []string) error

Types

type BMPContent

type BMPContent interface {
	RawBytesContent
	ImageContent
}

BMPContent is a specialization for BMP file data.

func NewBMPContent

func NewBMPContent(data []byte, width, height int) BMPContent

func NewBMPContentWithType

func NewBMPContentWithType(data []byte, width, height int, contentType string) BMPContent

func ToBMPContent

func ToBMPContent(c Content) (BMPContent, error)

type Content

type Content interface {
	Encoding() Encoding
}

Content is the base interface for all data flowing through the pipeline.

func WithContentType

func WithContentType(content Content, contentType string) Content

type ContentRoute

type ContentRoute struct {
	FilePath   string
	SourceMIME string
}

func ResolveContentRoute

func ResolveContentRoute(routes map[string]ContentRoute, requestPath string, options RouteOptions) (ContentRoute, bool)

type Encoding

type Encoding int
const (
	EncodingRawBytes Encoding = iota
	EncodingUTF8
	EncodingI32Array
	EncodingBMP
	EncodingRGBAF32
)

func (Encoding) String

func (e Encoding) String() string

type I32ArrayContent

type I32ArrayContent interface {
	Content
	RawBytes() []byte // Still stored as bytes for WASM memory compatibility
}

I32ArrayContent is for modules that output arrays of 32-bit integers.

func NewI32ArrayContent

func NewI32ArrayContent(data []byte) I32ArrayContent

func NewI32ArrayContentWithType

func NewI32ArrayContentWithType(data []byte, contentType string) I32ArrayContent

type ImageContent

type ImageContent interface {
	Content
	Width() int
	Height() int
}

ImageContent provides metadata for image-based data.

type InProcessHTTPResponse

type InProcessHTTPResponse struct {
	StatusCode int
	Header     http.Header
	Body       []byte
}

func ServeInProcessHTTP

func ServeInProcessHTTP(handler http.Handler, method string, requestPath string, headers http.Header) (InProcessHTTPResponse, error)

type ModuleDriver

type ModuleDriver interface {
	Execute(ctx context.Context, input Content, requestID uint64) (Content, error)
	Close(ctx context.Context) error
}

ModuleDriver defines the interface for executing a specific type of Wasm module.

type Pipeline

type Pipeline struct {
	Stages    []Stage
	CloseFunc func(ctx context.Context) error
}

func (*Pipeline) Close

func (p *Pipeline) Close(ctx context.Context) error

func (*Pipeline) Process

func (p *Pipeline) Process(ctx context.Context, input Content, requestID uint64) (Content, error)

type RGBAF32Content

type RGBAF32Content interface {
	ImageContent
	Pixels() []float32
}

RGBAF32Content is high-precision float pixel data used for tile processing.

func NewRGBAF32Content

func NewRGBAF32Content(pixels []float32, width, height int) RGBAF32Content

func NewRGBAF32ContentWithType

func NewRGBAF32ContentWithType(pixels []float32, width, height int, contentType string) RGBAF32Content

type RawBytesContent

type RawBytesContent interface {
	Content
	RawBytes() []byte
}

RawBytesContent provides access to raw data.

func NewRawBytesContent

func NewRawBytesContent(data []byte) RawBytesContent

func NewRawBytesContentWithType

func NewRawBytesContentWithType(data []byte, contentType string) RawBytesContent

type RecipeSourceAsset

type RecipeSourceAsset struct {
	RequestPath string
	Body        []byte
	ContentType string
}

func CollectRecipeSourceAssets

func CollectRecipeSourceAssets(recipesRoot string) ([]RecipeSourceAsset, error)

type RequestHandlerConfig

type RequestHandlerConfig struct {
	LogPrefix      string
	RouteOptions   RouteOptions
	Reload         func()
	Resolve        func(r *http.Request, requestID uint64) (RoutedResponse, error)
	WriteError     func(http.ResponseWriter, error)
	FormatDuration func(total time.Duration, moduleDurations []time.Duration, instantiationDurations []time.Duration) string
	Logf           func(format string, args ...any)
}

type RouteOptions

type RouteOptions struct {
	TrailingSlashMode TrailingSlashMode
}

func DefaultRouteOptions

func DefaultRouteOptions() RouteOptions

type RoutedResponse

type RoutedResponse struct {
	StatusCode             int
	Header                 http.Header
	Body                   []byte
	ModuleDurations        []time.Duration
	InstantiationDurations []time.Duration
}

type RunStage

type RunStage struct {
	Driver ModuleDriver
}

func (*RunStage) Close

func (s *RunStage) Close(ctx context.Context) error

func (*RunStage) Process

func (s *RunStage) Process(ctx context.Context, input Content, requestID uint64) (Content, error)

type Stage

type Stage interface {
	Process(ctx context.Context, input Content, requestID uint64) (Content, error)
	Close(ctx context.Context) error
}

type StringContent

type StringContent interface {
	Content
	String() string
}

StringContent provides access to UTF-8 string data.

func NewStringContent

func NewStringContent(data string) StringContent

func NewStringContentWithType

func NewStringContentWithType(data string, contentType string) StringContent

func ToUTF8Content

func ToUTF8Content(c Content) (StringContent, error)

type TileGroupStage

type TileGroupStage struct {
	Drivers []TileModuleDriver
}

func (*TileGroupStage) Close

func (s *TileGroupStage) Close(ctx context.Context) error

func (*TileGroupStage) Process

func (s *TileGroupStage) Process(ctx context.Context, input Content, requestID uint64) (Content, error)

type TileModuleDriver

type TileModuleDriver interface {
	ExecuteTile(ctx context.Context, x, y float32, tilePixels []float32) ([]float32, error)
	SetImageSize(ctx context.Context, width, height int) error
	Close(ctx context.Context) error
	HaloPx() int
}

type TrailingSlashMode

type TrailingSlashMode string
const (
	TrailingSlashModeNever  TrailingSlashMode = "never"
	TrailingSlashModeAlways TrailingSlashMode = "always"
)

type WasmRunDriver

type WasmRunDriver struct {
	RunFunc   func(ctx context.Context, input []byte, requestID uint64) (Content, error)
	CloseFunc func(ctx context.Context) error
}

WasmRunDriver implements ModuleDriver for a single 'run' Wasm module.

func (*WasmRunDriver) Close

func (d *WasmRunDriver) Close(ctx context.Context) error

func (*WasmRunDriver) Execute

func (d *WasmRunDriver) Execute(ctx context.Context, input Content, requestID uint64) (Content, error)

type WasmTileModuleDriver

type WasmTileModuleDriver struct {
	TileFunc    func(ctx context.Context, x, y float32, tilePixels []float32) ([]float32, error)
	SetSizeFunc func(ctx context.Context, width, height int) error
	CloseFunc   func(ctx context.Context) error
	HaloValue   int
}

WasmTileModuleDriver implements TileModuleDriver for a 'tile' Wasm module.

func (*WasmTileModuleDriver) Close

func (d *WasmTileModuleDriver) Close(ctx context.Context) error

func (*WasmTileModuleDriver) ExecuteTile

func (d *WasmTileModuleDriver) ExecuteTile(ctx context.Context, x, y float32, tilePixels []float32) ([]float32, error)

func (*WasmTileModuleDriver) HaloPx

func (d *WasmTileModuleDriver) HaloPx() int

func (*WasmTileModuleDriver) SetImageSize

func (d *WasmTileModuleDriver) SetImageSize(ctx context.Context, width, height int) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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