d2wasm

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MPL-2.0 Imports: 30 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

View Source
const DEFAULT_INPUT_PATH = "index"

Variables

This section is empty.

Functions

func Compile

func Compile(args []js.Value) (interface{}, error)

func Decode

func Decode(args []js.Value) (interface{}, error)

func Encode

func Encode(args []js.Value) (interface{}, error)

func GetBoardAtPosition

func GetBoardAtPosition(args []js.Value) (interface{}, error)

func GetCompletions

func GetCompletions(args []js.Value) (interface{}, error)

func GetELKGraph deprecated

func GetELKGraph(args []js.Value) (interface{}, error)

GetELKGraph converts D2 source into the pre-layout ELK graph used by the legacy JavaScript ELK integration.

Deprecated: use the raw WASM compile API with options.layout set to "elk". ELK layout now runs inside D2, and this export will be removed after one compatibility release.

func GetJSVersion

func GetJSVersion(args []js.Value) (interface{}, error)

func GetObjOrder deprecated

func GetObjOrder(args []js.Value) (interface{}, error)

GetObjOrder returns the breadth-first object order for D2 source passed by a raw WASM caller.

Deprecated: use d2oracle.GetObjOrder in Go integrations. The raw WASM export will be removed after one compatibility release.

func GetParentID

func GetParentID(args []js.Value) (interface{}, error)

func GetRefRanges

func GetRefRanges(args []js.Value) (interface{}, error)

func GetVersion

func GetVersion(args []js.Value) (interface{}, error)

func Render

func Render(args []js.Value) (interface{}, error)

Types

type BoardPositionResponse

type BoardPositionResponse struct {
	BoardPath []string `json:"boardPath"`
	Err       string   `json:"err"`
}

type CompileOptions

type CompileOptions struct {
	RenderOptions
	Layout       *string `json:"layout"`
	FontRegular  *[]byte `json:"FontRegular"`
	FontItalic   *[]byte `json:"FontItalic"`
	FontBold     *[]byte `json:"FontBold"`
	FontSemibold *[]byte `json:"FontSemibold"`
}

type CompileRequest

type CompileRequest struct {
	FS        map[string]string `json:"fs"`
	InputPath *string           `json:"inputPath"`
	Opts      *CompileOptions   `json:"options"`
}

type CompileResponse

type CompileResponse struct {
	FS            map[string]string `json:"fs"`
	InputPath     string            `json:"inputPath"`
	Diagram       d2target.Diagram  `json:"diagram"`
	Graph         d2graph.Graph     `json:"graph"`
	RenderOptions RenderOptions     `json:"renderOptions"`
}

type CompletionResponse

type CompletionResponse struct {
	Items []map[string]interface{} `json:"items"`
}

type D2API

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

func NewD2API

func NewD2API() *D2API

func (*D2API) ExportTo

func (api *D2API) ExportTo(target js.Value)

func (*D2API) Register

func (api *D2API) Register(name string, fn func(args []js.Value) (interface{}, error))

type RefRangesResponse

type RefRangesResponse struct {
	Ranges       []d2ast.Range `json:"ranges"`
	ImportRanges []d2ast.Range `json:"importRanges"`
}

type RenderOptions

type RenderOptions struct {
	Pad                *int64                   `json:"pad"`
	Sketch             *bool                    `json:"sketch"`
	Center             *bool                    `json:"center"`
	ThemeID            *int64                   `json:"themeID"`
	DarkThemeID        *int64                   `json:"darkThemeID"`
	ThemeOverrides     *d2target.ThemeOverrides `json:"themeOverrides"`
	DarkThemeOverrides *d2target.ThemeOverrides `json:"darkThemeOverrides"`
	Scale              *float64                 `json:"scale"`
	ForceAppendix      *bool                    `json:"forceAppendix"`
	Target             *string                  `json:"target"`
	AnimateInterval    *int64                   `json:"animateInterval"`
	Salt               *string                  `json:"salt"`
	NoXMLTag           *bool                    `json:"noXMLTag"`
	ASCII              *bool                    `json:"ascii"`
	ASCIIMode          *string                  `json:"asciiMode"`
}

type RenderRequest

type RenderRequest struct {
	Diagram *d2target.Diagram `json:"diagram"`
	Opts    *RenderOptions    `json:"options"`
}

type WASMError

type WASMError struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

func (*WASMError) Error

func (e *WASMError) Error() string

type WASMResponse

type WASMResponse struct {
	Data  interface{} `json:"data,omitempty"`
	Error *WASMError  `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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