Skip to content
Layers
Esc
navigateopen⌘Jpreview
On this page

Core API

Curated reference for LayerClient, LayerStack, layerOptions, typing helpers, and core utilities.

Symbols below are exported from @stainless-code/layers (packages/core). React/Preact/Solid/Angular/Vue/Lit/Alpine re-export the full core. Svelte re-exports selectively — core’s headless createLayer is createLayerHandle.

LayerClient

App-wide coordinator for named layer stacks.

class LayerClient {
  constructor(opts?: LayerClientOptions);
  open(options): Promise<R>;
  getStack(id?: string): LayerStack;
  ensureStack(id: string, options?: StackOptions): LayerStack;
  getStackIds(): string[];
  subscribeStacks(listener: (stackId: string) => void): () => void;
  subscribeNotify(listener: (event: StackNotifyEvent) => void): () => void;
  seedNotify(stackId?: string): void;
  dismissAll(
    stackId?: string,
    response?: unknown,
    opts?: DismissAllOptions,
  ): Promise<void>;
  cancelAll(
    stackId?: string,
    opts?: { reason?: LayerCancelReason },
  ): Promise<void>;
}
Method Purpose
open Opens a layer on a stack; resolves with the dismissal response (or rejects on load/validation/cancel)
getStack Returns a stack by id, creating the default stack on first access
ensureStack Returns a stack, applying StackOptions only when creating it
getStackIds Lists materialized stack ids
subscribeStacks Notifies when a stack is created for the first time
subscribeNotify Labeled stack transitions (StackNotifyEvent) for inspectors / Devtools
seedNotify Re-emits a register notify for one stack, or all materialized stacks when omitted
dismissAll Async bulk dismiss on one stack (honors blockers unless mode: "force"); completes with response
cancelAll Force-clear; rejects every open/queued caller with LayerCancelledError (skips blockers)
PropType
defaultStackOptions?StackDefaults
TypeStackDefaults

LayerStack

Ordered layers for one surface. Extends Subscribable — use subscribe for snapshot updates.

class LayerStack {
  readonly id: string;
  readonly options: StackOptions;

  getSnapshot(): LayerState[];
  getQueuedSnapshot(): LayerState[];
  subscribe(listener: () => void): () => void;

  find(key: LayerKey): Layer | undefined; // topmost same-key (findLast)
  getLayer(id: string): Layer | undefined;
  dismiss(layer, ...args: EndArgs<R>): Promise<boolean>;
  dismissAll(...args: DismissAllArgs<R>): Promise<void>;
  cancelAll(opts?: { reason?: LayerCancelReason }): Promise<void>;
  addBlocker(fn: StackBlockerFn): () => void;
  cancelQueued(key: LayerKey, ...args: CancelQueuedArgs<R>): boolean;
  settle(layer): void;
  setRunning(layer, running: boolean): void;
  update(layer, patch: Partial<P>): void;
}
Method Purpose
getSnapshot Stable-ref snapshot of mounted layers (pending/active/dismissed/error)
getQueuedSnapshot Serial-scope queue — layers waiting behind the occupying layer
subscribe Register for snapshot changes (batched via notifyManager)
find Topmost mounted layer for a logical key (key signature; findLast)
dismiss Resolve one layer; response optional when undefined extends R (EndArgs); blockers may veto
cancelQueued Resolve a serial queued layer without mounting; same response gate; omit { id } → FIFO, { id } → exact match
addBlocker Stack-scoped dismiss gate; returns a disposer

StackNotifyEvent

JSON-safe transition record for subscribeNotify (Devtools and headless inspectors). Distinct from subscribe snapshot identity — see Devtools.

PropType
toString() => string

Returns a string representation of a string.

Type() => string
charAt(pos: number) => string

Returns the character at the specified index.

Type(pos: number) => string
charCodeAt(index: number) => number

Returns the Unicode value of the character at the specified location.

Type(index: number) => number
concat(...strings: string[]) => string

Returns a string that contains the concatenation of two or more strings.

Type(...strings: string[]) => string
indexOf(searchString: string, position?: number | undefined) => number

Returns the position of the first occurrence of a substring, or -1 if it is not present.

Type(searchString: string, position?: number | undefined) => number
lastIndexOf(searchString: string, position?: number | undefined) => number

Returns the last occurrence of a substring in the string, or -1 if it is not present.

Type(searchString: string, position?: number | undefined) => number
localeCompare{ (that: string): number; (that: string, locales?: string | string[] | undefined, options?: CollatorOptions | undefined): number; (that: string, locales?: LocalesArgument, options?: CollatorOptions | undefined): number; }

Determines whether two strings are equivalent in the current locale. Determines whether two strings are equivalent in the current or specified locale.

Type{ (that: string): number; (that: string, locales?: string | string[] | undefined, options?: CollatorOptions | undefined): number; (that: string, locales?: LocalesArgument, options?: CollatorOptions | undefined): number; }
match{ (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; }

Matches a string with a regular expression, and returns an array containing the results of that search. Matches a string or an object that supports being matched against, and returns an array containing the results of that search, or null if no matches are found.

Type{ (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; }
replace{ (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: { ...; }, replaceValue: string): string; (searchValue: { ...; }, replacer: (substring: string, ...args: any[]) => string): string; }

Replaces text in a string, using a regular expression or search string. Passes a string and {@linkcode replaceValue} to the `[Symbol.replace]` method on {@linkcode searchValue}. This method is expected to implement its own replacement algorithm. Replaces text in a string, using an object that supports replacement within a string.

Type{ (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: { ...; }, replaceValue: string): string; (searchValue: { ...; }, replacer: (substring: string, ...args: any[]) => string): string; }
search{ (regexp: string | RegExp): number; (searcher: { [Symbol.search](string: string): number; }): number; }

Finds the first substring match in a regular expression search.

Type{ (regexp: string | RegExp): number; (searcher: { [Symbol.search](string: string): number; }): number; }
slice(start?: number | undefined, end?: number | undefined) => string

Returns a section of a string.

Type(start?: number | undefined, end?: number | undefined) => string
split{ (separator: string | RegExp, limit?: number | undefined): string[]; (splitter: { [Symbol.split](string: string, limit?: number | undefined): string[]; }, limit?: number | undefined): string[]; }

Split a string into substrings using the specified separator and return them as an array.

Type{ (separator: string | RegExp, limit?: number | undefined): string[]; (splitter: { [Symbol.split](string: string, limit?: number | undefined): string[]; }, limit?: number | undefined): string[]; }
substring(start: number, end?: number | undefined) => string

Returns the substring at the specified location within a String object.

Type(start: number, end?: number | undefined) => string
toLowerCase() => string

Converts all the alphabetic characters in a string to lowercase.

Type() => string
toLocaleLowerCase{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }

Converts all alphabetic characters to lowercase, taking into account the host environment's current locale.

Type{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }
toUpperCase() => string

Converts all the alphabetic characters in a string to uppercase.

Type() => string
toLocaleUpperCase{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }

Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale.

Type{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }
trim() => string

Removes the leading and trailing white space and line terminator characters from a string.

Type() => string
length

Returns the length of a String object.

Type
substr(from: number, length?: number | undefined) => string

Gets a substring beginning at the specified location and having the specified length.

Type(from: number, length?: number | undefined) => string
valueOf() => string

Returns the primitive value of the specified object.

Type() => string
codePointAt(pos: number) => number | undefined

Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point value of the UTF-16 encoded code point starting at the string element at position pos in the String resulting from converting this object to a String. If there is no element at that position, the result is undefined. If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.

Type(pos: number) => number | undefined
includes(searchString: string, position?: number | undefined) => boolean

Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false.

Type(searchString: string, position?: number | undefined) => boolean
endsWith(searchString: string, endPosition?: number | undefined) => boolean

Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at endPosition – length(this). Otherwise returns false.

Type(searchString: string, endPosition?: number | undefined) => boolean
normalize{ (form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; (form?: string | undefined): string; }

Returns the String value result of normalizing the string into the normalization form named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.

Type{ (form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; (form?: string | undefined): string; }
repeat(count: number) => string

Returns a String value that is made from count copies appended together. If count is 0, the empty string is returned.

Type(count: number) => string
startsWith(searchString: string, position?: number | undefined) => boolean

Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.

Type(searchString: string, position?: number | undefined) => boolean
anchor(name: string) => string

Returns an `<a>` HTML anchor element and sets the name attribute to the text value

Type(name: string) => string
big() => string

Returns a `<big>` HTML element

Type() => string
blink() => string

Returns a `<blink>` HTML element

Type() => string
bold() => string

Returns a `<b>` HTML element

Type() => string
fixed() => string

Returns a `<tt>` HTML element

Type() => string
fontcolor(color: string) => string

Returns a `<font>` HTML element and sets the color attribute value

Type(color: string) => string
fontsize{ (size: number): string; (size: string): string; }

Returns a `<font>` HTML element and sets the size attribute value

Type{ (size: number): string; (size: string): string; }
italics() => string

Returns an `<i>` HTML element

Type() => string
link(url: string) => string

Returns an `<a>` HTML element and sets the href attribute value

Type(url: string) => string
small() => string

Returns a `<small>` HTML element

Type() => string
strike() => string

Returns a `<strike>` HTML element

Type() => string
sub() => string

Returns a `<sub>` HTML element

Type() => string
sup() => string

Returns a `<sup>` HTML element

Type() => string
padStart(maxLength: number, fillString?: string | undefined) => string

Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. The padding is applied from the start (left) of the current string.

Type(maxLength: number, fillString?: string | undefined) => string
padEnd(maxLength: number, fillString?: string | undefined) => string

Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string.

Type(maxLength: number, fillString?: string | undefined) => string
trimEnd() => string

Removes the trailing white space and line terminator characters from a string.

Type() => string
trimStart() => string

Removes the leading white space and line terminator characters from a string.

Type() => string
trimLeft() => string

Removes the leading white space and line terminator characters from a string.

Type() => string
trimRight() => string

Removes the trailing white space and line terminator characters from a string.

Type() => string
matchAll(regexp: RegExp) => RegExpStringIterator<RegExpExecArray>

Matches a string with a regular expression, and returns an iterable of matches containing the results of that search.

Type(regexp: RegExp) => RegExpStringIterator<RegExpExecArray>
replaceAll{ (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; }

Replace all instances of a substring in a string, using a regular expression or search string.

Type{ (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; }
at(index: number) => string | undefined

Returns a new String consisting of the single UTF-16 code unit located at the specified index.

Type(index: number) => string | undefined
isWellFormed() => boolean

Returns true if all leading surrogates and trailing surrogates appear paired and in order.

Type() => boolean
toWellFormed() => string

Returns a string where all lone or out-of-order surrogates have been replaced by the Unicode replacement character (U+FFFD).

Type() => string
__@iterator@42() => StringIterator<string>

Iterator

Type() => StringIterator<string>
PropType
idstring
Typestring
keystring

Display string from {@link keySignature }.

Typestring
phaseLayerPhase
TypeLayerPhase
transitionLayerTransition
TypeLayerTransition
actionStatusLayerActionStatus
TypeLayerActionStatus
dismissingboolean
Typeboolean
endedboolean
Typeboolean
indexnumber
Typenumber
stackSizenumber
Typenumber
payload?unknown
Typeunknown
payloadTruncated?boolean

`true` when `payload` could not be JSON-cloned and was omitted.

Typeboolean
PropType
stackIdstring
Typestring
seqnumber
Typenumber
tsnumber
Typenumber
actionStackNotifyAction
TypeStackNotifyAction
activeLayerNotifyView[]
TypeLayerNotifyView[]
queuedLayerNotifyView[]
TypeLayerNotifyView[]

LayerState

Immutable snapshot of one layer, consumed by selectors.

PropType
idstring
Typestring
keyLayerKey
TypeLayerKey
payloadP
TypeP
data?D
TypeD
response?R
TypeR
error?E
TypeE
phaseLayerPhase
TypeLayerPhase
transitionLayerTransition
TypeLayerTransition
dismissingboolean

`true` while a user-intent dismiss is consulting blockers.

Typeboolean
actionStatusLayerActionStatus
TypeLayerActionStatus
endedboolean
Typeboolean
indexnumber
Typenumber
stackSizenumber
Typenumber

StackOptions

Per-stack options passed to ensureStack or LayerClientOptions.defaultStackOptions.

PropType
scope?{ strategy: "serial" | "parallel"; /** * Serial only. `block` — keep `phase: "error"` until dismiss. * `advance` — remove the failed layer and drain the next queued open. * @default "block" */ onLoadError?: SerialOnLoadError; }

Serial scope queues unmounted opens until the occupying layer leaves (`pending` / `active` / `error` for `onLoadError: "block"`).

Type{ strategy: "serial" | "parallel"; /** * Serial only. `block` — keep `phase: "error"` until dismiss. * `advance` — remove the failed layer and drain the next queued open. * @default "block" */ onLoadError?: SerialOnLoadError; }
Default{ strategy: "parallel" }
gcTime?number

Retains loaded data for same-key restoration.

Typenumber
Default0
dismissAllMode?DismissAllMode
TypeDismissAllMode
Default"skipBlocked"
PropType
toString() => string

Returns a string representation of a string.

Type() => string
charAt(pos: number) => string

Returns the character at the specified index.

Type(pos: number) => string
charCodeAt(index: number) => number

Returns the Unicode value of the character at the specified location.

Type(index: number) => number
concat(...strings: string[]) => string

Returns a string that contains the concatenation of two or more strings.

Type(...strings: string[]) => string
indexOf(searchString: string, position?: number | undefined) => number

Returns the position of the first occurrence of a substring, or -1 if it is not present.

Type(searchString: string, position?: number | undefined) => number
lastIndexOf(searchString: string, position?: number | undefined) => number

Returns the last occurrence of a substring in the string, or -1 if it is not present.

Type(searchString: string, position?: number | undefined) => number
localeCompare{ (that: string): number; (that: string, locales?: string | string[] | undefined, options?: CollatorOptions | undefined): number; (that: string, locales?: LocalesArgument, options?: CollatorOptions | undefined): number; }

Determines whether two strings are equivalent in the current locale. Determines whether two strings are equivalent in the current or specified locale.

Type{ (that: string): number; (that: string, locales?: string | string[] | undefined, options?: CollatorOptions | undefined): number; (that: string, locales?: LocalesArgument, options?: CollatorOptions | undefined): number; }
match{ (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; }

Matches a string with a regular expression, and returns an array containing the results of that search. Matches a string or an object that supports being matched against, and returns an array containing the results of that search, or null if no matches are found.

Type{ (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; }
replace{ (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: { ...; }, replaceValue: string): string; (searchValue: { ...; }, replacer: (substring: string, ...args: any[]) => string): string; }

Replaces text in a string, using a regular expression or search string. Passes a string and {@linkcode replaceValue} to the `[Symbol.replace]` method on {@linkcode searchValue}. This method is expected to implement its own replacement algorithm. Replaces text in a string, using an object that supports replacement within a string.

Type{ (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: { ...; }, replaceValue: string): string; (searchValue: { ...; }, replacer: (substring: string, ...args: any[]) => string): string; }
search{ (regexp: string | RegExp): number; (searcher: { [Symbol.search](string: string): number; }): number; }

Finds the first substring match in a regular expression search.

Type{ (regexp: string | RegExp): number; (searcher: { [Symbol.search](string: string): number; }): number; }
slice(start?: number | undefined, end?: number | undefined) => string

Returns a section of a string.

Type(start?: number | undefined, end?: number | undefined) => string
split{ (separator: string | RegExp, limit?: number | undefined): string[]; (splitter: { [Symbol.split](string: string, limit?: number | undefined): string[]; }, limit?: number | undefined): string[]; }

Split a string into substrings using the specified separator and return them as an array.

Type{ (separator: string | RegExp, limit?: number | undefined): string[]; (splitter: { [Symbol.split](string: string, limit?: number | undefined): string[]; }, limit?: number | undefined): string[]; }
substring(start: number, end?: number | undefined) => string

Returns the substring at the specified location within a String object.

Type(start: number, end?: number | undefined) => string
toLowerCase() => string

Converts all the alphabetic characters in a string to lowercase.

Type() => string
toLocaleLowerCase{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }

Converts all alphabetic characters to lowercase, taking into account the host environment's current locale.

Type{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }
toUpperCase() => string

Converts all the alphabetic characters in a string to uppercase.

Type() => string
toLocaleUpperCase{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }

Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale.

Type{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }
trim() => string

Removes the leading and trailing white space and line terminator characters from a string.

Type() => string
length

Returns the length of a String object.

Type
substr(from: number, length?: number | undefined) => string

Gets a substring beginning at the specified location and having the specified length.

Type(from: number, length?: number | undefined) => string
valueOf() => string

Returns the primitive value of the specified object.

Type() => string
codePointAt(pos: number) => number | undefined

Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point value of the UTF-16 encoded code point starting at the string element at position pos in the String resulting from converting this object to a String. If there is no element at that position, the result is undefined. If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.

Type(pos: number) => number | undefined
includes(searchString: string, position?: number | undefined) => boolean

Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false.

Type(searchString: string, position?: number | undefined) => boolean
endsWith(searchString: string, endPosition?: number | undefined) => boolean

Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at endPosition – length(this). Otherwise returns false.

Type(searchString: string, endPosition?: number | undefined) => boolean
normalize{ (form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; (form?: string | undefined): string; }

Returns the String value result of normalizing the string into the normalization form named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.

Type{ (form: "NFC" | "NFD" | "NFKC" | "NFKD"): string; (form?: string | undefined): string; }
repeat(count: number) => string

Returns a String value that is made from count copies appended together. If count is 0, the empty string is returned.

Type(count: number) => string
startsWith(searchString: string, position?: number | undefined) => boolean

Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.

Type(searchString: string, position?: number | undefined) => boolean
anchor(name: string) => string

Returns an `<a>` HTML anchor element and sets the name attribute to the text value

Type(name: string) => string
big() => string

Returns a `<big>` HTML element

Type() => string
blink() => string

Returns a `<blink>` HTML element

Type() => string
bold() => string

Returns a `<b>` HTML element

Type() => string
fixed() => string

Returns a `<tt>` HTML element

Type() => string
fontcolor(color: string) => string

Returns a `<font>` HTML element and sets the color attribute value

Type(color: string) => string
fontsize{ (size: number): string; (size: string): string; }

Returns a `<font>` HTML element and sets the size attribute value

Type{ (size: number): string; (size: string): string; }
italics() => string

Returns an `<i>` HTML element

Type() => string
link(url: string) => string

Returns an `<a>` HTML element and sets the href attribute value

Type(url: string) => string
small() => string

Returns a `<small>` HTML element

Type() => string
strike() => string

Returns a `<strike>` HTML element

Type() => string
sub() => string

Returns a `<sub>` HTML element

Type() => string
sup() => string

Returns a `<sup>` HTML element

Type() => string
padStart(maxLength: number, fillString?: string | undefined) => string

Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. The padding is applied from the start (left) of the current string.

Type(maxLength: number, fillString?: string | undefined) => string
padEnd(maxLength: number, fillString?: string | undefined) => string

Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. The padding is applied from the end (right) of the current string.

Type(maxLength: number, fillString?: string | undefined) => string
trimEnd() => string

Removes the trailing white space and line terminator characters from a string.

Type() => string
trimStart() => string

Removes the leading white space and line terminator characters from a string.

Type() => string
trimLeft() => string

Removes the leading white space and line terminator characters from a string.

Type() => string
trimRight() => string

Removes the trailing white space and line terminator characters from a string.

Type() => string
matchAll(regexp: RegExp) => RegExpStringIterator<RegExpExecArray>

Matches a string with a regular expression, and returns an iterable of matches containing the results of that search.

Type(regexp: RegExp) => RegExpStringIterator<RegExpExecArray>
replaceAll{ (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; }

Replace all instances of a substring in a string, using a regular expression or search string.

Type{ (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; }
at(index: number) => string | undefined

Returns a new String consisting of the single UTF-16 code unit located at the specified index.

Type(index: number) => string | undefined
isWellFormed() => boolean

Returns true if all leading surrogates and trailing surrogates appear paired and in order.

Type() => boolean
toWellFormed() => string

Returns a string where all lone or out-of-order surrogates have been replaced by the Unicode replacement character (U+FFFD).

Type() => string
__@iterator@285() => StringIterator<string>

Iterator

Type() => StringIterator<string>

layerOptions

Brands a reusable options object’s key with DataTag so open infers response and error types without an explicit generic.

function layerOptions<
  P,
  R = void,
  E = DefaultLayerError,
  D = unknown,
  RootProps = unknown,
>(
  options: LayerOptions<P, R, E, D, RootProps> & { key: Key },
): LayerOptions<P, R, E, D, RootProps> & { key: DataTag<Key, R, E> };
PropType
stack?string
Typestring
Default"default"
keyLayerKey

Stable identity; same key + `upsert` → update existing instance.

TypeLayerKey
component?LayerComponent
TypeLayerComponent
enteringDelay?number

Enter duration in milliseconds; `call.settle()` finishes it early.

Typenumber
Default0
exitingDelay?number

Exit duration in milliseconds; `call.settle()` finishes it early.

Typenumber
Default0
upsert?boolean

When true, reusing an active key updates its payload instead of stacking.

Typeboolean
loadFn?(ctx: { payload: P; signal: AbortSignal }) => Promise<D> | D

Loads data before activation; dismissal aborts the signal.

Type(ctx: { payload: P; signal: AbortSignal }) => Promise<D> | D
validate?Validator<P>

Validates payload before opening; the parsed output becomes the payload.

TypeValidator<P>
rootProps?RootProps

Props passed to every layer in the stack via `call.root`.

TypeRootProps
_payload?P
TypeP
_response?R
TypeR
_error?E
TypeE

layerKey and DataTag

layerKey<R, E>() tags a key at the call site. DataTag<Key, R, E> is the phantom brand type that carries inference through generics.

function layerKey<R, E = DefaultLayerError>(): <const Key extends LayerKey>(
  key: Key,
) => DataTag<Key, R, E>;

type DataTag<Key extends LayerKey, R, E = DefaultLayerError>;
type ResponseOf<Key, Fallback = void>;
type ErrorOf<Key, Fallback = DefaultLayerError>;

Register and DefaultLayerError

Module augmentation sets the app-wide error default once:

interface Register {}

type DefaultLayerError = Register extends { defaultError: infer E } ? E : Error;
export {};

declare module "@stainless-code/layers" {
  interface Register {
    defaultError: AppError;
  }
}

Payload validation errors

Optional validate on open / layerOptions rejects synchronously before mount.

class PayloadValidationError extends Error {
  readonly issues: ReadonlyArray<ValidationIssue>;
}

function isPayloadValidationError(
  value: unknown,
): value is PayloadValidationError;

Layer key errors

Non-JSON-safe keys throw LayerKeyError synchronously (not a Promise rejection). Throw sites: Identity & types.

class LayerKeyError extends Error {
  readonly path: ReadonlyArray<PropertyKey>;
}

function isLayerKeyError(value: unknown): value is LayerKeyError;

function assertLayerKey(key: unknown): asserts key is LayerKey;

Layer cancel errors

System teardown (cancelAll, parent-dismiss child drain, group dispose, host disconnect) rejects open() with LayerCancelledError. User dismiss / dismissAll complete open() with R — they do not reject. See Error handling.

type LayerCancelReason =
  | "parentDismiss"
  | "groupDispose"
  | "cancelAll"
  | "stackDisconnect";

class LayerCancelledError extends Error {
  readonly reason: LayerCancelReason;
}

function isLayerCancelledError(value: unknown): value is LayerCancelledError;

createLayer

Wire layerOptions + a LayerClient into a headless handle. Adapters wrap this in reactive useLayer / injectLayer / createLayer.

function createLayer<P, R, …>(
  options: LayerOptions<P, R, …> & { key: LayerKey },
  client: LayerClient,
): LayerHandle<P, R, …>;

function createLayer<V extends Validator<unknown>, R, …>(
  options: LayerOptions<InferValidatorOutput<V>, R, …> & { key: LayerKey; validate: V },
  client: LayerClient,
): ValidatedLayerHandle<V, R, …>;
const confirm = createLayer(confirmOptions, client); // R = boolean
const ok = await confirm.open({ title: "Remove?" });
confirm.dismiss(false);
confirm.cancelQueued(false, { id: "queued-id" }); // response required for boolean R
PropType
open(payload: PayloadArg<P>["payload"]) => Promise<R>
Type(payload: PayloadArg<P>["payload"]) => Promise<R>
upsert(payload: PayloadArg<P>["payload"]) => Promise<R>
Type(payload: PayloadArg<P>["payload"]) => Promise<R>
dismiss(...args: HandleDismissArgs<R>) => Promise<boolean>

Dismiss the bound instance (or `{ id }`). Response optional iff `undefined extends R` ({@link HandleDismissArgs} / {@link EndArgs } gate).

Type(...args: HandleDismissArgs<R>) => Promise<boolean>
update(patch: Partial<P>, opts?: { id?: string }) => void
Type(patch: Partial<P>, opts?: { id?: string }) => void
cancelQueued(...args: CancelQueuedArgs<R>) => boolean

Resolves and removes a serially queued layer without mounting (skips blockers). No `id` → FIFO head for this key; `{ id }` → exact queued match. Response may be omitted when `undefined extends R` ({@link CancelQueuedArgs} / {@link EndArgs } gate).

Type(...args: CancelQueuedArgs<R>) => boolean
clientLayerClient
TypeLayerClient
stackLayerStack<P, R, E, D>
TypeLayerStack<P, R, E, D>
optionsLayerOptions<P, R, E, D, RP> & { key: DataTag<LayerKey, R, E>; }
TypeLayerOptions<P, R, E, D, RP> & { key: DataTag<LayerKey, R, E>; }
currentLayer<P, R, E, D> | null

Live-checked bound instance (`null` when not in the stack).

TypeLayer<P, R, E, D> | null

When options.validate is set, ValidatedLayerHandle narrows open/upsert to schema input and current/update to parsed output.

createCallContext

Builds the imperative call object passed to layer components. Adapters call this when rendering.

function createCallContext<P, R, RootProps = unknown>(
  stack: LayerStack,
  layer: Layer,
  state: LayerState,
  rootProps?: RootProps,
): LayerCallContext<P, R, RootProps>;

LayerCallContext exposes end, dismiss, addBlocker, update, setRunning, settle, plus read-only ended, index, stackSize, root, stackId, and layerId. Omit the response on end/dismiss when undefined extends R (EndArgs — same gate as PayloadArg / .open()).

PropType
0?R | undefined
TypeR | undefined
1?DismissOptions | undefined
TypeDismissOptions | undefined
length0 | 1 | 2
Type0 | 1 | 2
toString(() => string) | (() => string)

Returns a string representation of an array.

Type(() => string) | (() => string)
toLocaleString{ (): string; (locales: string | string[], options?: (NumberFormatOptions & DateTimeFormatOptions) | undefined): string; } | { ...; }

Returns a string representation of an array. The elements are converted to string using their toLocaleString methods.

Type{ (): string; (locales: string | string[], options?: (NumberFormatOptions & DateTimeFormatOptions) | undefined): string; } | { ...; }
pop(() => R | DismissOptions | undefined) | (() => R | DismissOptions | undefined)

Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.

Type(() => R | DismissOptions | undefined) | (() => R | DismissOptions | undefined)
push((...items: (R | DismissOptions | undefined)[]) => number) | ((...items: (R | DismissOptions | undefined)[]) => number)

Appends new elements to the end of an array, and returns the new length of the array.

Type((...items: (R | DismissOptions | undefined)[]) => number) | ((...items: (R | DismissOptions | undefined)[]) => number)
concat{ (...items: ConcatArray<R | DismissOptions | undefined>[]): (R | DismissOptions | undefined)[]; (...items: (R | DismissOptions | ConcatArray<...> | undefined)[]): (R | ... 1 more ... | undefined)[]; } | { ...; }

Combines two or more arrays. This method returns a new array without modifying any existing arrays.

Type{ (...items: ConcatArray<R | DismissOptions | undefined>[]): (R | DismissOptions | undefined)[]; (...items: (R | DismissOptions | ConcatArray<...> | undefined)[]): (R | ... 1 more ... | undefined)[]; } | { ...; }
join((separator?: string | undefined) => string) | ((separator?: string | undefined) => string)

Adds all the elements of an array into a string, separated by the specified separator string.

Type((separator?: string | undefined) => string) | ((separator?: string | undefined) => string)
reverse(() => (R | DismissOptions | undefined)[]) | (() => (R | DismissOptions | undefined)[])

Reverses the elements in an array in place. This method mutates the array and returns a reference to the same array.

Type(() => (R | DismissOptions | undefined)[]) | (() => (R | DismissOptions | undefined)[])
shift(() => R | DismissOptions | undefined) | (() => R | DismissOptions | undefined)

Removes the first element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.

Type(() => R | DismissOptions | undefined) | (() => R | DismissOptions | undefined)
slice((start?: number | undefined, end?: number | undefined) => (R | DismissOptions | undefined)[]) | ((start?: number | undefined, end?: number | undefined) => (R | ... 1 more ... | undefined)[])

Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array.

Type((start?: number | undefined, end?: number | undefined) => (R | DismissOptions | undefined)[]) | ((start?: number | undefined, end?: number | undefined) => (R | ... 1 more ... | undefined)[])
sort((compareFn?: ((a: R | DismissOptions | undefined, b: R | DismissOptions | undefined) => number) | undefined) => [response?: R | undefined, opts?: DismissOptions | undefined]) | ((compareFn?: ((a: R | ... 1 more ... | undefined, b: R | ... 1 more ... | undefined) => number) | undefined) => [response: ...])

Sorts an array in place. This method mutates the array and returns a reference to the same array.

Type((compareFn?: ((a: R | DismissOptions | undefined, b: R | DismissOptions | undefined) => number) | undefined) => [response?: R | undefined, opts?: DismissOptions | undefined]) | ((compareFn?: ((a: R | ... 1 more ... | undefined, b: R | ... 1 more ... | undefined) => number) | undefined) => [response: ...])
splice{ (start: number, deleteCount?: number | undefined): (R | DismissOptions | undefined)[]; (start: number, deleteCount: number, ...items: (R | DismissOptions | undefined)[]): (R | ... 1 more ... | undefined)[]; } | { ...; }

Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

Type{ (start: number, deleteCount?: number | undefined): (R | DismissOptions | undefined)[]; (start: number, deleteCount: number, ...items: (R | DismissOptions | undefined)[]): (R | ... 1 more ... | undefined)[]; } | { ...; }
unshift((...items: (R | DismissOptions | undefined)[]) => number) | ((...items: (R | DismissOptions | undefined)[]) => number)

Inserts new elements at the start of an array, and returns the new length of the array.

Type((...items: (R | DismissOptions | undefined)[]) => number) | ((...items: (R | DismissOptions | undefined)[]) => number)
indexOf((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => number) | ((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => number)

Returns the index of the first occurrence of a value in an array, or -1 if it is not present.

Type((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => number) | ((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => number)
lastIndexOf((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => number) | ((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => number)

Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.

Type((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => number) | ((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => number)
every{ <S extends R | DismissOptions | undefined>(predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unknow...

Determines whether all the members of an array satisfy the specified test.

Type{ <S extends R | DismissOptions | undefined>(predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unknow...
some((predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => unknown, thisArg?: any) => boolean) | ((predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unknown, thisArg?: any) => boolean)

Determines whether the specified callback function returns true for any element of an array.

Type((predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => unknown, thisArg?: any) => boolean) | ((predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unknown, thisArg?: any) => boolean)
forEach((callbackfn: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => void, thisArg?: any) => void) | ((callbackfn: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => void, thisArg?: any) => void)

Performs the specified action for each element in an array.

Type((callbackfn: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => void, thisArg?: any) => void) | ((callbackfn: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => void, thisArg?: any) => void)
map(<U>(callbackfn: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => U, thisArg?: any) => U[]) | (<U>(callbackfn: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => U, thisArg?: any) => U[])

Calls a defined callback function on each element of an array, and returns an array that contains the results.

Type(<U>(callbackfn: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => U, thisArg?: any) => U[]) | (<U>(callbackfn: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => U, thisArg?: any) => U[])
filter{ <S extends R | DismissOptions | undefined>(predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => value is S, thisArg?: any): S[]; (predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unknown, thisA...

Returns the elements of an array that meet the condition specified in a callback function.

Type{ <S extends R | DismissOptions | undefined>(predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => value is S, thisArg?: any): S[]; (predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unknown, thisA...
reduce{ (callbackfn: (previousValue: R | DismissOptions | undefined, currentValue: R | DismissOptions | undefined, currentIndex: number, array: (R | DismissOptions | undefined)[]) => R | ... 1 more ... | undefined): R | ... 1 more ... | undefined; (callbackfn: (previousValue: R | ... 1 more ... | undefined, currentValue: ...

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Type{ (callbackfn: (previousValue: R | DismissOptions | undefined, currentValue: R | DismissOptions | undefined, currentIndex: number, array: (R | DismissOptions | undefined)[]) => R | ... 1 more ... | undefined): R | ... 1 more ... | undefined; (callbackfn: (previousValue: R | ... 1 more ... | undefined, currentValue: ...
reduceRight{ (callbackfn: (previousValue: R | DismissOptions | undefined, currentValue: R | DismissOptions | undefined, currentIndex: number, array: (R | DismissOptions | undefined)[]) => R | ... 1 more ... | undefined): R | ... 1 more ... | undefined; (callbackfn: (previousValue: R | ... 1 more ... | undefined, currentValue: ...

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Type{ (callbackfn: (previousValue: R | DismissOptions | undefined, currentValue: R | DismissOptions | undefined, currentIndex: number, array: (R | DismissOptions | undefined)[]) => R | ... 1 more ... | undefined): R | ... 1 more ... | undefined; (callbackfn: (previousValue: R | ... 1 more ... | undefined, currentValue: ...
find{ <S extends R | DismissOptions | undefined>(predicate: (value: R | DismissOptions | undefined, index: number, obj: (R | DismissOptions | undefined)[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: R | ... 1 more ... | undefined, index: number, obj: (R | ... 1 more ... | undefined)[]) => unknown,...

Returns the value of the first element in the array where predicate is true, and undefined otherwise.

Type{ <S extends R | DismissOptions | undefined>(predicate: (value: R | DismissOptions | undefined, index: number, obj: (R | DismissOptions | undefined)[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: R | ... 1 more ... | undefined, index: number, obj: (R | ... 1 more ... | undefined)[]) => unknown,...
findIndex((predicate: (value: R | DismissOptions | undefined, index: number, obj: (R | DismissOptions | undefined)[]) => unknown, thisArg?: any) => number) | ((predicate: (value: R | ... 1 more ... | undefined, index: number, obj: (R | ... 1 more ... | undefined)[]) => unknown, thisArg?: any) => number)

Returns the index of the first element in the array where predicate is true, and -1 otherwise.

Type((predicate: (value: R | DismissOptions | undefined, index: number, obj: (R | DismissOptions | undefined)[]) => unknown, thisArg?: any) => number) | ((predicate: (value: R | ... 1 more ... | undefined, index: number, obj: (R | ... 1 more ... | undefined)[]) => unknown, thisArg?: any) => number)
fill((value: R | DismissOptions | undefined, start?: number | undefined, end?: number | undefined) => [response?: R | undefined, opts?: DismissOptions | undefined]) | ((value: R | ... 1 more ... | undefined, start?: number | undefined, end?: number | undefined) => [response: ...])

Changes all array elements from `start` to `end` index to a static `value` and returns the modified array

Type((value: R | DismissOptions | undefined, start?: number | undefined, end?: number | undefined) => [response?: R | undefined, opts?: DismissOptions | undefined]) | ((value: R | ... 1 more ... | undefined, start?: number | undefined, end?: number | undefined) => [response: ...])
copyWithin((target: number, start: number, end?: number | undefined) => [response?: R | undefined, opts?: DismissOptions | undefined]) | ((target: number, start: number, end?: number | undefined) => [response: ...])

Returns the this object after copying a section of the array identified by start and end to the same array starting at position target

Type((target: number, start: number, end?: number | undefined) => [response?: R | undefined, opts?: DismissOptions | undefined]) | ((target: number, start: number, end?: number | undefined) => [response: ...])
entries(() => ArrayIterator<[number, R | DismissOptions | undefined]>) | (() => ArrayIterator<[number, R | DismissOptions | undefined]>)

Returns an iterable of key, value pairs for every entry in the array

Type(() => ArrayIterator<[number, R | DismissOptions | undefined]>) | (() => ArrayIterator<[number, R | DismissOptions | undefined]>)
keys(() => ArrayIterator<number>) | (() => ArrayIterator<number>)

Returns an iterable of keys in the array

Type(() => ArrayIterator<number>) | (() => ArrayIterator<number>)
values(() => ArrayIterator<R | DismissOptions | undefined>) | (() => ArrayIterator<R | DismissOptions | undefined>)

Returns an iterable of values in the array

Type(() => ArrayIterator<R | DismissOptions | undefined>) | (() => ArrayIterator<R | DismissOptions | undefined>)
includes((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => boolean) | ((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => boolean)

Determines whether an array includes a certain element, returning true or false as appropriate.

Type((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => boolean) | ((searchElement: R | DismissOptions | undefined, fromIndex?: number | undefined) => boolean)
flatMap(<U, This = undefined>(callback: (this: This, value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => U | readonly U[], thisArg?: This | undefined) => U[]) | (<U, This = undefined>(callback: (this: This, value: R | ... 1 more ... | undefined, index: number, array: (R | ......

Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1.

Type(<U, This = undefined>(callback: (this: This, value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => U | readonly U[], thisArg?: This | undefined) => U[]) | (<U, This = undefined>(callback: (this: This, value: R | ... 1 more ... | undefined, index: number, array: (R | ......
flat(<A, D extends number = 1>(this: A, depth?: D | undefined) => FlatArray<A, D>[]) | (<A, D extends number = 1>(this: A, depth?: D | undefined) => FlatArray<A, D>[])

Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.

Type(<A, D extends number = 1>(this: A, depth?: D | undefined) => FlatArray<A, D>[]) | (<A, D extends number = 1>(this: A, depth?: D | undefined) => FlatArray<A, D>[])
at((index: number) => R | DismissOptions | undefined) | ((index: number) => R | DismissOptions | undefined)

Returns the item located at the specified index.

Type((index: number) => R | DismissOptions | undefined) | ((index: number) => R | DismissOptions | undefined)
findLast{ <S extends R | DismissOptions | undefined>(predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unkn...

Returns the value of the last element in the array where predicate is true, and undefined otherwise.

Type{ <S extends R | DismissOptions | undefined>(predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unkn...
findLastIndex((predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => unknown, thisArg?: any) => number) | ((predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unknown, thisArg?: any) => number)

Returns the index of the last element in the array where predicate is true, and -1 otherwise.

Type((predicate: (value: R | DismissOptions | undefined, index: number, array: (R | DismissOptions | undefined)[]) => unknown, thisArg?: any) => number) | ((predicate: (value: R | ... 1 more ... | undefined, index: number, array: (R | ... 1 more ... | undefined)[]) => unknown, thisArg?: any) => number)
toReversed(() => (R | DismissOptions | undefined)[]) | (() => (R | DismissOptions | undefined)[])

Returns a copy of an array with its elements reversed.

Type(() => (R | DismissOptions | undefined)[]) | (() => (R | DismissOptions | undefined)[])
toSorted((compareFn?: ((a: R | DismissOptions | undefined, b: R | DismissOptions | undefined) => number) | undefined) => (R | DismissOptions | undefined)[]) | ((compareFn?: ((a: R | ... 1 more ... | undefined, b: R | ... 1 more ... | undefined) => number) | undefined) => (R | ... 1 more ... | undefined)[])

Returns a copy of an array with its elements sorted.

Type((compareFn?: ((a: R | DismissOptions | undefined, b: R | DismissOptions | undefined) => number) | undefined) => (R | DismissOptions | undefined)[]) | ((compareFn?: ((a: R | ... 1 more ... | undefined, b: R | ... 1 more ... | undefined) => number) | undefined) => (R | ... 1 more ... | undefined)[])
toSpliced{ (start: number, deleteCount: number, ...items: (R | DismissOptions | undefined)[]): (R | DismissOptions | undefined)[]; (start: number, deleteCount?: number | undefined): (R | ... 1 more ... | undefined)[]; } | { ...; }

Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. Copies an array and removes elements while returning the remaining elements.

Type{ (start: number, deleteCount: number, ...items: (R | DismissOptions | undefined)[]): (R | DismissOptions | undefined)[]; (start: number, deleteCount?: number | undefined): (R | ... 1 more ... | undefined)[]; } | { ...; }
with((index: number, value: R | DismissOptions | undefined) => (R | DismissOptions | undefined)[]) | ((index: number, value: R | DismissOptions | undefined) => (R | ... 1 more ... | undefined)[])

Copies an array, then overwrites the value at the provided index with the given value. If the index is negative, then it replaces from the end of the array.

Type((index: number, value: R | DismissOptions | undefined) => (R | DismissOptions | undefined)[]) | ((index: number, value: R | DismissOptions | undefined) => (R | ... 1 more ... | undefined)[])
__@iterator@539(() => ArrayIterator<R | DismissOptions | undefined>) | (() => ArrayIterator<R | DismissOptions | undefined>)

Iterator

Type(() => ArrayIterator<R | DismissOptions | undefined>) | (() => ArrayIterator<R | DismissOptions | undefined>)
__@unscopables@541ent = unknown; export interface LayerOptions<

Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement.

Typeent = unknown; export interface LayerOptions<
PropType
end(...args: EndArgs<R>) => Promise<boolean>

Resolve and dismiss — response optional iff `undefined extends R` ({@link EndArgs}).

Type(...args: EndArgs<R>) => Promise<boolean>
dismiss(...args: EndArgs<R>) => Promise<boolean>

Alias of {@link LayerCallContext.end}.

Type(...args: EndArgs<R>) => Promise<boolean>
addBlocker(fn: BlockerFn) => () => void
Type(fn: BlockerFn) => () => void
update(patch: Partial<P>) => void
Type(patch: Partial<P>) => void
setRunning(running: boolean) => void
Type(running: boolean) => void
settle() => void

Finishes the current transition immediately.

Type() => void
endedboolean
Typeboolean
indexnumber
Typenumber
stackSizenumber
Typenumber
rootRootProps
TypeRootProps
stackIdstring
Typestring
layerIdstring
Typestring

LayerComponentProps

Props passed to layer components by adapters when rendering a mounted layer.

PropType
callLayerCallContext<P, R, RootProps>
TypeLayerCallContext<P, R, RootProps>
payloadP
TypeP
data?D
TypeD
error?E
TypeE
phaseLayerPhase
TypeLayerPhase
transitionLayerTransition
TypeLayerTransition
dismissingboolean
Typeboolean
actionStatusLayerActionStatus
TypeLayerActionStatus

createLayerGroup

Child stack scoped to a parent layer’s lifetime on the same client.

function childStackId(
  parent: Pick<LayerCallContext, "stackId" | "layerId">,
  name?: string,
): string;

function createLayerGroup(
  client: LayerClient,
  parent: Pick<LayerCallContext, "stackId" | "layerId">,
  options?: LayerGroupOptions,
): LayerGroupHandle;

LayerGroupHandle provides stackId, open, dismissAll, and dispose.

notifyManager

Coalesces subscriber notifications within a synchronous batch.

const notifyManager = {
  batch<T>(fn: () => T): T;
  batchCalls(listener: () => void): () => void;
};

Wrap independent mutations that should produce one UI update: notifyManager.batch(() => { client.open(a); client.open(b); }).

Dismiss options

PropType
mode?DismissAllMode
TypeDismissAllMode
PropType
force?boolean
Typeboolean

Last updated on September 4, 2026

Was this page helpful?