d2wasm

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MPL-2.0 Imports: 33 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 Format added in v0.10.0

func Format(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)

func RenderSVG added in v0.10.0

func RenderSVG(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
	AnimateDuration *int64  `json:"animateDuration"`
	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"`
	// contains filtered or unexported fields
}

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