d2/d2js/d2wasm/types.go
2025-02-13 21:59:29 +00:00

63 lines
1.4 KiB
Go

//go:build js && wasm
package d2wasm
import (
"oss.terrastruct.com/d2/d2ast"
"oss.terrastruct.com/d2/d2graph"
"oss.terrastruct.com/d2/d2target"
)
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"`
}
type CompileRequest struct {
FS map[string]string `json:"fs"`
Opts *RenderOptions `json:"options"`
}
type RenderOptions struct {
Layout *string `json:"layout"`
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"`
}
type CompileResponse struct {
FS map[string]string `json:"fs"`
Diagram d2target.Diagram `json:"diagram"`
Graph d2graph.Graph `json:"graph"`
}
type CompletionResponse struct {
Items []map[string]interface{} `json:"items"`
}
type RenderRequest struct {
Diagram *d2target.Diagram `json:"diagram"`
Opts *RenderOptions `json:"options"`
}