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) |
defaultStackOptions?StackDefaults
StackDefaultsLayerStack
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.
toString() => string
Returns a string representation of a string.
() => stringcharAt(pos: number) => string
Returns the character at the specified index.
(pos: number) => stringcharCodeAt(index: number) => number
Returns the Unicode value of the character at the specified location.
(index: number) => numberconcat(...strings: string[]) => string
Returns a string that contains the concatenation of two or more strings.
(...strings: string[]) => stringindexOf(searchString: string, position?: number | undefined) => number
Returns the position of the first occurrence of a substring, or -1 if it is not present.
(searchString: string, position?: number | undefined) => numberlastIndexOf(searchString: string, position?: number | undefined) => number
Returns the last occurrence of a substring in the string, or -1 if it is not present.
(searchString: string, position?: number | undefined) => numberlocaleCompare{ (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.
{ (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.
{ (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.
{ (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.
{ (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.
(start?: number | undefined, end?: number | undefined) => stringsplit{ (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.
{ (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.
(start: number, end?: number | undefined) => stringtoLowerCase() => string
Converts all the alphabetic characters in a string to lowercase.
() => stringtoLocaleLowerCase{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }
Converts all alphabetic characters to lowercase, taking into account the host environment's current locale.
{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }toUpperCase() => string
Converts all the alphabetic characters in a string to uppercase.
() => stringtoLocaleUpperCase{ (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.
{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }trim() => string
Removes the leading and trailing white space and line terminator characters from a string.
() => stringlength
Returns the length of a String object.
substr(from: number, length?: number | undefined) => string
Gets a substring beginning at the specified location and having the specified length.
(from: number, length?: number | undefined) => stringvalueOf() => string
Returns the primitive value of the specified object.
() => stringcodePointAt(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.
(pos: number) => number | undefinedincludes(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.
(searchString: string, position?: number | undefined) => booleanendsWith(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.
(searchString: string, endPosition?: number | undefined) => booleannormalize{ (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.
{ (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.
(count: number) => stringstartsWith(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.
(searchString: string, position?: number | undefined) => booleananchor(name: string) => string
Returns an `<a>` HTML anchor element and sets the name attribute to the text value
(name: string) => stringbig() => string
Returns a `<big>` HTML element
() => stringblink() => string
Returns a `<blink>` HTML element
() => stringbold() => string
Returns a `<b>` HTML element
() => stringfixed() => string
Returns a `<tt>` HTML element
() => stringfontcolor(color: string) => string
Returns a `<font>` HTML element and sets the color attribute value
(color: string) => stringfontsize{ (size: number): string; (size: string): string; }
Returns a `<font>` HTML element and sets the size attribute value
{ (size: number): string; (size: string): string; }italics() => string
Returns an `<i>` HTML element
() => stringlink(url: string) => string
Returns an `<a>` HTML element and sets the href attribute value
(url: string) => stringsmall() => string
Returns a `<small>` HTML element
() => stringstrike() => string
Returns a `<strike>` HTML element
() => stringsub() => string
Returns a `<sub>` HTML element
() => stringsup() => string
Returns a `<sup>` HTML element
() => stringpadStart(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.
(maxLength: number, fillString?: string | undefined) => stringpadEnd(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.
(maxLength: number, fillString?: string | undefined) => stringtrimEnd() => string
Removes the trailing white space and line terminator characters from a string.
() => stringtrimStart() => string
Removes the leading white space and line terminator characters from a string.
() => stringtrimLeft() => string
Removes the leading white space and line terminator characters from a string.
() => stringtrimRight() => string
Removes the trailing white space and line terminator characters from a string.
() => stringmatchAll(regexp: RegExp) => RegExpStringIterator<RegExpExecArray>
Matches a string with a regular expression, and returns an iterable of matches containing the results of that search.
(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.
{ (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.
(index: number) => string | undefinedisWellFormed() => boolean
Returns true if all leading surrogates and trailing surrogates appear paired and in order.
() => booleantoWellFormed() => string
Returns a string where all lone or out-of-order surrogates have been replaced by the Unicode replacement character (U+FFFD).
() => string__@iterator@42() => StringIterator<string>
Iterator
() => StringIterator<string>idstring
stringkeystring
Display string from {@link keySignature }.
stringphaseLayerPhase
LayerPhasetransitionLayerTransition
LayerTransitionactionStatusLayerActionStatus
LayerActionStatusdismissingboolean
booleanendedboolean
booleanindexnumber
numberstackSizenumber
numberpayload?unknown
unknownpayloadTruncated?boolean
`true` when `payload` could not be JSON-cloned and was omitted.
booleanstackIdstring
stringseqnumber
numbertsnumber
numberactionStackNotifyAction
StackNotifyActionactiveLayerNotifyView[]
LayerNotifyView[]queuedLayerNotifyView[]
LayerNotifyView[]LayerState
Immutable snapshot of one layer, consumed by selectors.
idstring
stringkeyLayerKey
LayerKeypayloadP
Pdata?D
Dresponse?R
Rerror?E
EphaseLayerPhase
LayerPhasetransitionLayerTransition
LayerTransitiondismissingboolean
`true` while a user-intent dismiss is consulting blockers.
booleanactionStatusLayerActionStatus
LayerActionStatusendedboolean
booleanindexnumber
numberstackSizenumber
numberStackOptions
Per-stack options passed to ensureStack or LayerClientOptions.defaultStackOptions.
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"`).
{
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;
}{ strategy: "parallel" }gcTime?number
Retains loaded data for same-key restoration.
number0dismissAllMode?DismissAllMode
DismissAllMode"skipBlocked"toString() => string
Returns a string representation of a string.
() => stringcharAt(pos: number) => string
Returns the character at the specified index.
(pos: number) => stringcharCodeAt(index: number) => number
Returns the Unicode value of the character at the specified location.
(index: number) => numberconcat(...strings: string[]) => string
Returns a string that contains the concatenation of two or more strings.
(...strings: string[]) => stringindexOf(searchString: string, position?: number | undefined) => number
Returns the position of the first occurrence of a substring, or -1 if it is not present.
(searchString: string, position?: number | undefined) => numberlastIndexOf(searchString: string, position?: number | undefined) => number
Returns the last occurrence of a substring in the string, or -1 if it is not present.
(searchString: string, position?: number | undefined) => numberlocaleCompare{ (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.
{ (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.
{ (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.
{ (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.
{ (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.
(start?: number | undefined, end?: number | undefined) => stringsplit{ (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.
{ (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.
(start: number, end?: number | undefined) => stringtoLowerCase() => string
Converts all the alphabetic characters in a string to lowercase.
() => stringtoLocaleLowerCase{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }
Converts all alphabetic characters to lowercase, taking into account the host environment's current locale.
{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }toUpperCase() => string
Converts all the alphabetic characters in a string to uppercase.
() => stringtoLocaleUpperCase{ (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.
{ (locales?: string | string[] | undefined): string; (locales?: LocalesArgument): string; }trim() => string
Removes the leading and trailing white space and line terminator characters from a string.
() => stringlength
Returns the length of a String object.
substr(from: number, length?: number | undefined) => string
Gets a substring beginning at the specified location and having the specified length.
(from: number, length?: number | undefined) => stringvalueOf() => string
Returns the primitive value of the specified object.
() => stringcodePointAt(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.
(pos: number) => number | undefinedincludes(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.
(searchString: string, position?: number | undefined) => booleanendsWith(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.
(searchString: string, endPosition?: number | undefined) => booleannormalize{ (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.
{ (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.
(count: number) => stringstartsWith(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.
(searchString: string, position?: number | undefined) => booleananchor(name: string) => string
Returns an `<a>` HTML anchor element and sets the name attribute to the text value
(name: string) => stringbig() => string
Returns a `<big>` HTML element
() => stringblink() => string
Returns a `<blink>` HTML element
() => stringbold() => string
Returns a `<b>` HTML element
() => stringfixed() => string
Returns a `<tt>` HTML element
() => stringfontcolor(color: string) => string
Returns a `<font>` HTML element and sets the color attribute value
(color: string) => stringfontsize{ (size: number): string; (size: string): string; }
Returns a `<font>` HTML element and sets the size attribute value
{ (size: number): string; (size: string): string; }italics() => string
Returns an `<i>` HTML element
() => stringlink(url: string) => string
Returns an `<a>` HTML element and sets the href attribute value
(url: string) => stringsmall() => string
Returns a `<small>` HTML element
() => stringstrike() => string
Returns a `<strike>` HTML element
() => stringsub() => string
Returns a `<sub>` HTML element
() => stringsup() => string
Returns a `<sup>` HTML element
() => stringpadStart(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.
(maxLength: number, fillString?: string | undefined) => stringpadEnd(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.
(maxLength: number, fillString?: string | undefined) => stringtrimEnd() => string
Removes the trailing white space and line terminator characters from a string.
() => stringtrimStart() => string
Removes the leading white space and line terminator characters from a string.
() => stringtrimLeft() => string
Removes the leading white space and line terminator characters from a string.
() => stringtrimRight() => string
Removes the trailing white space and line terminator characters from a string.
() => stringmatchAll(regexp: RegExp) => RegExpStringIterator<RegExpExecArray>
Matches a string with a regular expression, and returns an iterable of matches containing the results of that search.
(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.
{ (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.
(index: number) => string | undefinedisWellFormed() => boolean
Returns true if all leading surrogates and trailing surrogates appear paired and in order.
() => booleantoWellFormed() => string
Returns a string where all lone or out-of-order surrogates have been replaced by the Unicode replacement character (U+FFFD).
() => string__@iterator@285() => StringIterator<string>
Iterator
() => 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> };
stack?string
string"default"keyLayerKey
Stable identity; same key + `upsert` → update existing instance.
LayerKeycomponent?LayerComponent
LayerComponententeringDelay?number
Enter duration in milliseconds; `call.settle()` finishes it early.
number0exitingDelay?number
Exit duration in milliseconds; `call.settle()` finishes it early.
number0upsert?boolean
When true, reusing an active key updates its payload instead of stacking.
booleanloadFn?(ctx: { payload: P; signal: AbortSignal }) => Promise<D> | D
Loads data before activation; dismissal aborts the signal.
(ctx: { payload: P; signal: AbortSignal }) => Promise<D> | Dvalidate?Validator<P>
Validates payload before opening; the parsed output becomes the payload.
Validator<P>rootProps?RootProps
Props passed to every layer in the stack via `call.root`.
RootProps_payload?P
P_response?R
R_error?E
ElayerKey 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
open(payload: PayloadArg<P>["payload"]) => Promise<R>
(payload: PayloadArg<P>["payload"]) => Promise<R>upsert(payload: PayloadArg<P>["payload"]) => Promise<R>
(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).
(...args: HandleDismissArgs<R>) => Promise<boolean>update(patch: Partial<P>, opts?: { id?: string }) => void
(patch: Partial<P>, opts?: { id?: string }) => voidcancelQueued(...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).
(...args: CancelQueuedArgs<R>) => booleanclientLayerClient
LayerClientstackLayerStack<P, R, E, D>
LayerStack<P, R, E, D>optionsLayerOptions<P, R, E, D, RP> & {
key: DataTag<LayerKey, R, E>;
}
LayerOptions<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).
Layer<P, R, E, D> | nullWhen 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()).
0?R | undefined
R | undefined1?DismissOptions | undefined
DismissOptions | undefinedlength0 | 1 | 2
0 | 1 | 2toString(() => string) | (() => string)
Returns a string representation of an array.
(() => 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.
{ (): 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.
(() => 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.
((...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.
{ (...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.
((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.
(() => (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.
(() => 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.
((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.
((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.
{ (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.
((...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.
((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.
((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.
{ <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.
((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.
((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.
(<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.
{ <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.
{ (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.
{ (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.
{ <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.
((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
((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
((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
(() => ArrayIterator<[number, R | DismissOptions | undefined]>) | (() => ArrayIterator<[number, R | DismissOptions | undefined]>)keys(() => ArrayIterator<number>) | (() => ArrayIterator<number>)
Returns an iterable of keys in the array
(() => ArrayIterator<number>) | (() => ArrayIterator<number>)values(() => ArrayIterator<R | DismissOptions | undefined>) | (() => ArrayIterator<R | DismissOptions | undefined>)
Returns an iterable of values in the array
(() => 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.
((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.
(<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.
(<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.
((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.
{ <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.
((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.
(() => (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.
((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.
{ (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.
((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
(() => 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.
ent = unknown;
export interface LayerOptions<end(...args: EndArgs<R>) => Promise<boolean>
Resolve and dismiss — response optional iff `undefined extends R` ({@link EndArgs}).
(...args: EndArgs<R>) => Promise<boolean>dismiss(...args: EndArgs<R>) => Promise<boolean>
Alias of {@link LayerCallContext.end}.
(...args: EndArgs<R>) => Promise<boolean>addBlocker(fn: BlockerFn) => () => void
(fn: BlockerFn) => () => voidupdate(patch: Partial<P>) => void
(patch: Partial<P>) => voidsetRunning(running: boolean) => void
(running: boolean) => voidsettle() => void
Finishes the current transition immediately.
() => voidendedboolean
booleanindexnumber
numberstackSizenumber
numberrootRootProps
RootPropsstackIdstring
stringlayerIdstring
stringLayerComponentProps
Props passed to layer components by adapters when rendering a mounted layer.
callLayerCallContext<P, R, RootProps>
LayerCallContext<P, R, RootProps>payloadP
Pdata?D
Derror?E
EphaseLayerPhase
LayerPhasetransitionLayerTransition
LayerTransitiondismissingboolean
booleanactionStatusLayerActionStatus
LayerActionStatuscreateLayerGroup
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
mode?DismissAllMode
DismissAllModeforce?boolean
boolean