Skip to content

Interface: EditorSession

Defined in: packages/core/src/session.ts:95

Properties

registry

readonly registry: Registry

Defined in: packages/core/src/session.ts:96

Methods

addAsset()

addAsset(bytes, options?): Promise<AssetDeclaration>

Defined in: packages/core/src/session.ts:138

Registers an asset the user supplied (for example an uploaded sticker): stores the bytes in the renderer and records the declaration in the log so the log stays self-describing. Returns the declaration with its hash.

Parameters

bytes

Uint8Array

options?
id?

string

url?

string

Returns

Promise<AssetDeclaration>


canRedo()

canRedo(): boolean

Defined in: packages/core/src/session.ts:103

Returns

boolean


canUndo()

canUndo(): boolean

Defined in: packages/core/src/session.ts:102

Returns

boolean


dispatch()

dispatch(op): void

Defined in: packages/core/src/session.ts:98

Parameters

op

OperationBase

Returns

void


dispose()

dispose(): void

Defined in: packages/core/src/session.ts:149

Returns

void


download()

download(options?): Promise<{ filename: string; result: ExportResult | ServerRenderResult; }>

Defined in: packages/core/src/session.ts:140

Parameters

options?

DownloadOptions

Returns

Promise<{ filename: string; result: ExportResult | ServerRenderResult; }>


export()

export(options): Promise<ExportResult>

Defined in: packages/core/src/session.ts:139

Parameters

options

ExportOptions

Returns

Promise<ExportResult>


getDocument()

getDocument(): Document

Defined in: packages/core/src/session.ts:106

Returns

Document


getEditLog()

getEditLog(): object

Defined in: packages/core/src/session.ts:105

Returns

object

index

index: number

log

log: EditLog


getState()

getState(): SessionState

Defined in: packages/core/src/session.ts:104

Returns

SessionState


load()

load(source, options?): Promise<SourceDescriptor>

Defined in: packages/core/src/session.ts:97

Parameters

source

LoadSource

options?

LoadOptions

Returns

Promise<SourceDescriptor>


redo()

redo(): void

Defined in: packages/core/src/session.ts:100

Returns

void


renderDetached()

renderDetached(transform, options?): Promise<RgbaBuffer>

Defined in: packages/core/src/session.ts:129

Renders a proxy-sized image from the current log, transformed, and returns it without touching the stage, the state or the history. Tools use it to show what an edit the user has not made yet would look like: the filter tool renders its thumbnails from the log with the filter removed, so a chosen preset does not end up baked into the alternatives beside it.

Parameters

transform

(log) => EditLog

options?
signal?

AbortSignal

Returns

Promise<RgbaBuffer>


renderPreview()

renderPreview(): Promise<PreviewState>

Defined in: packages/core/src/session.ts:109

Forces a preview render now and resolves when it is applied.

Returns

Promise<PreviewState>


requestServerRender()

requestServerRender(options): Promise<ServerRenderResult>

Defined in: packages/core/src/session.ts:148

Renders on the server from the original bytes (inline) or a host-provided source reference. With destination: 's3' the server stores the object and returns its key and presigned url; otherwise the bytes come back.

Parameters

options

ServerRenderOptions

Returns

Promise<ServerRenderResult>


setEditLog()

setEditLog(saved, index?): void

Defined in: packages/core/src/session.ts:116

Replaces the history with a saved state for the loaded image (controlled mode). Validates through the registry and checks the source.

Parameters

saved

unknown

index?

number

Returns

void


setPreviewTransform()

setPreviewTransform(transform): void

Defined in: packages/core/src/session.ts:121

Transforms the log before preview rendering only. Tools use it to show, for example, the un-cropped image while the crop gizmo is active.

Parameters

transform

((log) => EditLog) | null

Returns

void


subscribe()

subscribe(listener): () => void

Defined in: packages/core/src/session.ts:107

Parameters

listener

(state) => void

Returns

() => void


timeTravel()

timeTravel(index): void

Defined in: packages/core/src/session.ts:101

Parameters

index

number

Returns

void


undo()

undo(): void

Defined in: packages/core/src/session.ts:99

Returns

void


whenIdle()

whenIdle(): Promise<void>

Defined in: packages/core/src/session.ts:111

Resolves when no preview render is pending.

Returns

Promise<void>