d2/d2js/d2wasm/types.go

79 lines
2 KiB
Go
Raw Permalink Normal View History

2024-12-21 01:08:19 +00:00
//go:build js && wasm
package d2wasm
2024-12-29 21:19:32 +00:00
import (
"oss.terrastruct.com/d2/d2ast"
"oss.terrastruct.com/d2/d2graph"
"oss.terrastruct.com/d2/d2target"
)
2024-12-21 01:08:19 +00:00
type WASMResponse struct {
Data interface{} `json:"data,omitempty"`
Error *WASMError `json:"error,omitempty"`
}
type WASMError struct {
Message string `json:"message"`
Code int `json:"code"`
}
func (e *WASMError) Error() string {
return e.Message
}
type RefRangesResponse struct {
Ranges []d2ast.Range `json:"ranges"`
ImportRanges []d2ast.Range `json:"importRanges"`
}
type BoardPositionResponse struct {
BoardPath []string `json:"boardPath"`
}
2024-12-29 21:19:32 +00:00
type CompileRequest struct {
2025-02-25 21:30:51 +00:00
FS map[string]string `json:"fs"`
InputPath *string `json:"inputPath"`
Opts *CompileOptions `json:"options"`
2024-12-29 21:19:32 +00:00
}
type RenderOptions struct {
Pad *int64 `json:"pad"`
Sketch *bool `json:"sketch"`
Center *bool `json:"center"`
ThemeID *int64 `json:"themeID"`
DarkThemeID *int64 `json:"darkThemeID"`
Scale *float64 `json:"scale"`
ForceAppendix *bool `json:"forceAppendix"`
Target *string `json:"target"`
AnimateInterval *int64 `json:"animateInterval"`
Salt *string `json:"salt"`
NoXMLTag *bool `json:"noXMLTag"`
2024-12-29 21:19:32 +00:00
}
2025-02-14 03:03:17 +00:00
type CompileOptions struct {
2025-02-14 22:04:30 +00:00
RenderOptions
2025-02-25 23:38:27 +00:00
Layout *string `json:"layout"`
FontRegular *[]byte `json:"FontRegular"`
FontItalic *[]byte `json:"FontItalic"`
FontBold *[]byte `json:"FontBold"`
FontSemibold *[]byte `json:"FontSemibold"`
2025-02-14 03:03:17 +00:00
}
2024-12-29 21:19:32 +00:00
type CompileResponse struct {
FS map[string]string `json:"fs"`
2025-02-25 21:30:51 +00:00
InputPath string `json:"inputPath"`
Diagram d2target.Diagram `json:"diagram"`
Graph d2graph.Graph `json:"graph"`
RenderOptions RenderOptions `json:"renderOptions"`
2024-12-29 21:19:32 +00:00
}
type CompletionResponse struct {
Items []map[string]interface{} `json:"items"`
}
type RenderRequest struct {
Diagram *d2target.Diagram `json:"diagram"`
Opts *RenderOptions `json:"options"`
}