Skip to main content

Class: SandpackClient

Constructors

constructor

new SandpackClient(selector, sandboxInfo, options?)

Parameters

NameType
selectorstring | HTMLIFrameElement
sandboxInfoSandboxInfo
optionsClientOptions

Defined in

client.ts:125

Properties

bundlerState

Optional bundlerState: BundlerState

Defined in

client.ts:116


bundlerURL

bundlerURL: string

Defined in

client.ts:115


element

element: Element

Defined in

client.ts:109


errors

errors: SandpackError[]

Defined in

client.ts:117


fileResolverProtocol

Optional fileResolverProtocol: default

Defined in

client.ts:114


iframe

iframe: HTMLIFrameElement

Defined in

client.ts:110


iframeProtocol

iframeProtocol: IFrameProtocol

Defined in

client.ts:111


options

options: ClientOptions

Defined in

client.ts:112


sandboxInfo

sandboxInfo: SandboxInfo

Defined in

client.ts:120


selector

selector: undefined | string

Defined in

client.ts:108


status

status: ClientStatus

Defined in

client.ts:118


unsubscribeChannelListener

unsubscribeChannelListener: UnsubscribeFunction

Defined in

client.ts:123


unsubscribeGlobalListener

unsubscribeGlobalListener: UnsubscribeFunction

Defined in

client.ts:122

Methods

cleanup

cleanup(): void

Returns

void

Defined in

client.ts:226


dispatch

dispatch(message): void

Parameters

NameType
messageSandpackMessage

Returns

void

Defined in

client.ts:312


getCodeSandboxURL

getCodeSandboxURL(): Promise<{ editorUrl: string ; embedUrl: string ; sandboxId: string }>

Get the URL of the contents of the current sandbox

Returns

Promise<{ editorUrl: string ; embedUrl: string ; sandboxId: string }>

Defined in

client.ts:323


getFiles

Private getFiles(): SandpackBundlerFiles

Returns

SandpackBundlerFiles

Defined in

client.ts:372


getTranspilerContext

getTranspilerContext(): Promise<Record<string, Record<string, unknown>>>

Returns

Promise<Record<string, Record<string, unknown>>>

Defined in

client.ts:357


initializeElement

Private initializeElement(): void

Returns

void

Defined in

client.ts:387


listen

listen(listener): UnsubscribeFunction

Parameters

NameType
listenerListenerFunction

Returns

UnsubscribeFunction

Defined in

client.ts:316


updateOptions

updateOptions(options): void

Parameters

NameType
optionsClientOptions

Returns

void

Defined in

client.ts:232


updatePreview

updatePreview(sandboxInfo?, isInitializationCompile?): void

Parameters

NameType
sandboxInfoSandboxInfo
isInitializationCompile?boolean

Returns

void

Defined in

client.ts:239