penguin/AstroJS

Javascript framework for my blog

resolver-go/internal/closure/types.go

raw ยท 924 bytes

package closure

import "sync"

type CompileState int

const (
	CompileMissing CompileState = iota
	CompilePending
	CompileReady
	CompileFailed
)

type CompileRequest struct {
	ExternSources []SourceInput  `json:"externSources,omitempty"`
	JSSources     []SourceInput  `json:"jsSources"`
	Defines       map[string]any `json:"defines,omitempty"`
}

type SourceInput struct {
	Name   string `json:"name"`
	Source string `json:"source"`
}

type CompileJob struct {
	Hash string
	Mode string

	ExternSources []SourceInput
	JSSources     []SourceInput
	Defines       map[string]any
}

type CompileCache struct {
	client  *Client
	mu      sync.Mutex
	states  map[string]CompileState
	results map[string][]byte
	errors  map[string]error
	jobs    chan CompileJob
}

type CompileResponse struct {
	OK       bool     `json:"ok"`
	JS       string   `json:"js"`
	Warnings []string `json:"warnings"`
	Errors   []string `json:"errors"`
}