Skip to content

Interface: EditorSession ​

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

Properties ​

registry ​

readonly registry: Registry

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

Methods ​

addAsset() ​

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

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

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:115

Returns ​

boolean


canUndo() ​

canUndo(): boolean

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

Returns ​

boolean


dispatch() ​

dispatch(op): void

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

Parameters ​

op ​

OperationBase

Returns ​

void


dispose() ​

dispose(): void

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

Returns ​

void


download() ​

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

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

Exports like export and hands the file to saveFile.

Parameters ​

options? ​

DownloadOptions

Returns ​

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


export() ​

export(options): Promise<ExportResult>

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

Renders the full resolution in the browser. Throws NOT_RESIDENT when the image is above maxClientMegapixels: the host then renders the original elsewhere, from the log that getEditLog() returns.

Parameters ​

options ​

ExportOptions

Returns ​

Promise<ExportResult>


getDocument() ​

getDocument(): Document

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

Returns ​

Document


getEditLog() ​

getEditLog(): object

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

Returns ​

object

index ​

index: number

log ​

log: EditLog


getState() ​

getState(): SessionState

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

Returns ​

SessionState


load() ​

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

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

Loads an image, optionally resuming a saved state. On failure the session stays on the previous image: the state and the renderer keep describing it. When a newer load starts before this one finishes, this one rejects with ABORTED and the newer one wins.

Parameters ​

source ​

LoadSource

options? ​

LoadOptions

Returns ​

Promise<SourceDescriptor>


redo() ​

redo(): void

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

Returns ​

void


renderDetached() ​

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

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

Renders a working-copy-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:121

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

Returns ​

Promise<PreviewState>


setEditLog() ​

setEditLog(saved, index?): void

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

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:133

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:119

Parameters ​

listener ​

(state) => void

Returns ​

() => void


timeTravel() ​

timeTravel(index): void

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

Moves to index, clamped to the log. A non-finite index, such as NaN, changes nothing.

Parameters ​

index ​

number

Returns ​

void


undo() ​

undo(): void

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

Returns ​

void


whenIdle() ​

whenIdle(): Promise<void>

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

Resolves when no preview render is pending.

Returns ​

Promise<void>