Every named declaration in the file, 663 of them, verbatim and in the order Claude Code wrote them, 50 to a page. This is the page to land on from a signature: a verb that returns ToolCallResult links here, at whichever page it is on, and what you get is the declaration itself rather than a description of it.
The source is 17,469 lines of TypeScript mined from build 2.1.319. Anything longer than 12 lines is folded; click the line count to open it. To find a name on another page, search every symbol.
Names on this page, 601 to 650 of 663
Fragment const
#
line 16232
In the first published surface (2.1.259)
<>...</>: a column Box around the children.
const Fragment: (props: { children?: RenderNode[] }) => RenderElement
JSX namespace
#
line 16239
In the first published surface (2.1.259) · changed in 2.1.260, 2.1.265, 2.1.267
JSX over the element table: every tag is a constructor from $.ui.resolve(e) (const { Box, Text } = $.ui.resolve(e)), typed by its props; there are no intrinsic (string) tags.
namespace JSX {
type Element = RenderElement
type Children = RenderChildren
type ElementType = (props: never) => RenderNode | null | undefined
interface IntrinsicElements {}
interface ElementChildrenAttribute {
children: unknown
}
interface IntrinsicAttributes {
key?: string
}
}
AbortSignal interface
#
line 16252
In the first published surface (2.1.259)
interface AbortSignal {
readonly aborted: boolean
readonly reason: unknown
throwIfAborted(): void
addEventListener(
type: 'abort',
listener: () => void,
options?: { once?: boolean },
): void
removeEventListener(type: 'abort', listener: () => void): void
}
AbortController interface
#
line 16269
In the first published surface (2.1.259)
interface AbortController {
readonly signal: AbortSignal
abort(reason?: unknown): void
}
TextEncoder interface
#
line 16277
In the first published surface (2.1.259)
interface TextEncoder {
readonly encoding: string
encode(input?: string): Uint8Array
}
TextDecoder interface
#
line 16282
In the first published surface (2.1.259)
interface TextDecoder {
readonly encoding: string
decode(input?: ArrayBufferView | ArrayBuffer): string
}
URLSearchParams interface
#
line 16287
In the first published surface (2.1.259)
interface URLSearchParams {
append(name: string, value: string): void
delete(name: string): void
get(name: string): string | null
getAll(name: string): string[]
has(name: string): boolean
set(name: string, value: string): void
toString(): string
forEach(callback: (value: string, key: string) => void): void
}
URL interface
#
line 16301
In the first published surface (2.1.259)
16 lines
interface URL {
hash: string
host: string
hostname: string
href: string
readonly origin: string
password: string
pathname: string
port: string
protocol: string
search: string
readonly searchParams: URLSearchParams
username: string
toString(): string
toJSON(): string
}
atob function
#
line 16322
In the first published surface (2.1.259)
function atob(data: string): string
function btoa(data: string): string
structuredClone function
#
line 16324
In the first published surface (2.1.259)
function structuredClone<T>(value: T): T
var crypto: {
readonly subtle: {
digest(
algorithm: string | { name: string },
data: ArrayBufferView | ArrayBuffer,
): Promise<ArrayBuffer>
}
randomUUID(): string
getRandomValues<T extends ArrayBufferView>(array: T): T
}
AsymmetricMatcher type
#
line 16378
Added in 2.1.271
A value that matches by a rule inside toEqual and its kin (expect.any, expect.objectContaining), known by its text in a failure.
export type AsymmetricMatcher = {
readonly text: string;
};
AsyncMatchers type
#
line 16386
Added in 2.1.271
The same checks on what a promise received settles with, each resolving once the promise has settled and the check passed.
export type AsyncMatchers = {
[K in keyof Matchers]: (...args: Parameters<Matchers[K]>) => Promise<void>;
};
ClassicEvent type
#
line 16398
Added in 2.1.280
A classic hook event the engine raises on its own, by its own name (SessionStart, Stop): all but PreToolUse, which rides tool.call.
$.tool.call raises classic.PreToolUse as a session does: beneath every plugin's tool.call hook and above the test's own, which a deny never reaches (the call resolves errored, the reason its text).
export type ClassicEvent = Exclude<ClassicEventName, 'classic.PreToolUse'> extends `classic.${infer E}` ? E : never;
ClassicFields type
#
line 16408
Added in 2.1.280
What $.classic.<Event> takes: the event's own fields as its hook sees them on e, less what the engine stamps at every call site.
hook_event_name is the call's; session_id, transcript_path and cwd are the session's unless the test gives them (the test session's id, '' for no local transcript, the plugin's folder).
export type ClassicFields<E extends ClassicEvent> = Omit<ClassicEventOf[`classic.${E}`], 'hook_event_name' | 'session_id' | 'transcript_path' | 'cwd'> & Partial<Pick<ClassicEventOf[`classic.${E}`], 'session_id' | 'transcript_path' | 'cwd'>>;
ClientScope type
#
line 16414
Added in 2.1.277
Which Client of a mounted drawing an act or a read means, by the key its element carries; optional while the drawing holds exactly one.
export type ClientScope = {
in?: string;
};
Constructor type
#
line 16421
Added in 2.1.271
A class, as toThrow, toBeInstanceOf and expect.any take it.
export type Constructor = abstract new (...args: never[]) => unknown;
describe const
#
line 16430
Added in 2.1.271
A group of tests: its name leads the title of each test declared inside, and its body runs at once, while the file loads.
name- the group's name
body- declares the group's tests
export const describe: (name: string, body: () => void) => void;
ElementOfAct type
#
line 16440
Added in 2.1.277
The element each surface-dependent act of a mounted drawing reaches: a handle carries the act only where the surface's table has the element.
input needs Input and select needs Select (every surface today); key, pointer, post, advance and resize reach a Client (terminal and desktop today). The rest need nothing but a tree.
export type ElementOfAct = {
input: 'Input';
select: 'Select';
key: 'Client';
pointer: 'Client';
post: 'Client';
advance: 'Client';
resize: 'Client';
};
ElementQuery type
#
line 16461
Added in 2.1.277
What a mounted drawing's find and findAll match an element on, every field given at once: its tag, its key, and the text it shows.
text matches the element's whole shown text (string children, a Button or Link's label, a Markdown's text, a Code's source, an Input's value): a string by inclusion, a RegExp by test.
await ui.findAll({ type: 'Text', text: /overdue/, in: 'board' })
export type ElementQuery = {
type?: string;
key?: string;
text?: string | RegExp;
/**
* Searches what this `Client`'s surface module drew (by the `Client`'s
* key) instead of the plugin's own tree.
*/
in?: string;
};
Engine type
#
line 16480
Added in 2.1.271 · changed in 2.1.275, 2.1.280
What a test holds as $, the engine's own: every call on it is made as the REPL, the query loop and the render sites make theirs, over every plugin.
next.origin is the engine, the chain every plugin loaded. $.ui.mount is a surface drawing an instance; press, input and select a person acting on an element the test drew; $.classic the classic hook events.
export type Engine = {
[N in keyof EventCalls]: N extends 'ui' ? EngineNoun<N> & EnginePress & EngineInput & EngineSelect & EngineMount : EngineNoun<N>;
} & {
classic: EngineClassic;
};
EngineCall type
#
line 16490
Added in 2.1.271
One call on the engine's $: the event's input whole, as an engine call site passes it, to its result, or for a streaming event to its stream.
export type EngineCall<E extends EventName> = E extends StreamingEventName ? (e: Args<E>) => HookStream<Chunk<E>, ResultOf[E]> : (e: Args<E>) => Promise<ResultOf[E]>;
EngineClassic type
#
line 16503
Added in 2.1.280
The classic (settings) hook events as the engine raises them: each a call running the classic.<Event> chain over every plugin hooked on it.
No settings hook runs beneath, so the test's on('classic.<Event>') is the bottom; the envelope (hook_event_name, session_id, transcript_path, cwd) is stamped unless given. PreToolUse rides $.tool.call instead.
await $.classic.SessionStart({ source: 'clear' })
export type EngineClassic = {
[E in ClassicEvent]: (e: ClassicFields<E>) => Promise<ClassicResultOf[`classic.${E}`]>;
};
EngineInput type
#
line 16511
Added in 2.1.280
A surface typing into an Input a test rendered: the ui.input chain over every plugin hooked on it, the Input's own handler last.
18 lines
export type EngineInput = {
/**
* Types into the Input, as an edit (`kind` `change`, reaching `onInput`) or
* Enter (`submit`, the default, reaching `onSubmit`) with that text.
*
* Resolves once the chain, the handler and the work it started settled.
* `e.surface` is the surface of the drawing that holds it.
*
* @param target whose Input, its key, the text, the kind, and the instance
* and surface when several hold it
* @returns what the chain settled on; rejects when no such Input is drawn, or
* several are and neither instance nor surface tells them apart
* @example
* await $.ui.input({ plugin: 'notes', key: 'q', text: 'g', kind: 'change' })
* await $.ui.input({ plugin: 'notes', key: 'q', text: 'groceries' })
*/
input: (target: InputTarget) => Promise<UiInputResult | undefined>;
};
EngineMount type
#
line 16541
Added in 2.1.275 · changed in 2.1.277
A surface drawing a component instance through the plugins, then driven by key through a handle typed by that surface (Mounted).
ui.render raised there for those props, the tree validated by that table, its Clients running; the reads and press on every surface, input where the table has Input, the Client acts where Client.
for (const surface of SURFACES) run(await $.ui.mount({ ...HINT, surface }))
15 lines
export type EngineMount = {
/**
* Raises the plugins' drawing of the component on the surface and holds
* it, as that surface showing the instance does.
*
* Resolves once the tree validated and every `Client` in it drew once.
*
* @param target whose elements, the surface, component, props and requestId
* @returns the mounted drawing; rejects when no `surface` (or an unknown
* one) is named, when the surface cannot draw the tree returned (with
* the reason: an element or a prop it lacks, a dialog's tree past its
* rows), or when a `Client`'s module failed or drew nothing
*/
mount: <P extends RenderSurface, C extends RenderComponent>(target: MountTarget<P, C>) => Promise<Mounted<P, C>>;
};
EngineNoun type
#
line 16564
Added in 2.1.271 · changed in 2.1.299, 2.1.307
One noun of the engine's $: each of its events as the engine calls it, tool.call typed per tool and ui.render per component, ui.resolve out.
skill.prompt takes a call's input: its frontmatter and source may be left out, as a test written before the event carried them does.
export type EngineNoun<N extends keyof EventCalls> = {
[V in EngineNounEvent<N>]: `${N}.${V}` extends 'tool.call' ? EngineToolCall : `${N}.${V}` extends 'ui.render' | 'skill.prompt' ? EventCalls[N][V] : EngineCall<`${N}.${V}` & EventName>;
};
EngineNounEvent type
#
line 16572
Added in 2.1.271
The events of one noun a test's $ carries: every one but ui.resolve, which a render hook calls on its own $ and the engine never raises.
export type EngineNounEvent<N extends keyof EventCalls> = Exclude<keyof EventCalls[N] & string, `${N}.resolve` extends 'ui.resolve' ? 'resolve' : never>;
EnginePress type
#
line 16578
Added in 2.1.271
A surface pressing a Button a test rendered, or a Markdown's link: the ui.press chain over every plugin hooked on it, its own closure last.
16 lines
export type EnginePress = {
/**
* Presses the Button, as a click or its hotkey does; with `link`, the
* Markdown's link, as a click on it does.
*
* Resolves once the chain, `onPress` and any work `onPress` left running
* unawaited have settled (work asleep on `mock.clock` waits for the test
* to advance it). `e.surface` is the surface of the drawing that holds it.
*
* @param target whose element, its key, the instance and surface when
* several hold it, and for a Markdown the link
* @returns what the chain settled on; rejects when no such element is
* drawn, or several are and neither instance nor surface tells them apart
*/
press: (target: PressTarget) => Promise<UiPressResult | undefined>;
};
EngineSelect type
#
line 16599
Added in 2.1.280
A surface picking an option of a Select a test rendered: the ui.select chain over every plugin hooked on it, the Select's own onSelect last.
16 lines
export type EngineSelect = {
/**
* Picks the option, as choosing it on the surface does; resolves once the
* chain, `onSelect` and the work it started have settled.
*
* `e.surface` is the surface of the drawing that holds it.
*
* @param target whose Select, its key, the option's value, and the
* instance and surface when several hold it
* @returns what the chain settled on; rejects when no such Select is
* drawn, or several are and neither instance nor surface tells them apart
* @example
* await $.ui.select({ plugin: 'notes', key: 'sort', value: 'date' })
*/
select: (target: SelectTarget) => Promise<UiSelectResult | undefined>;
};
EngineToolCall type
#
line 16627
Added in 2.1.307
$.tool.call on a test's $: a call as the engine raises one, agentId the loop it runs in (a subagent's, a teammate's); left out, the main loop.
A hooked tool.check runs as for a background subagent: a test's classic.PermissionRequest answers an ask; no test plays a person's yes. A test states isReadOnly on $.tool.check; $.ui.ask states its own.
await $.tool.call({ tool: 'Bash', command: 'ls', agentId: 'a1' })
export type EngineToolCall = {
<T extends string>(input: ToolCallArgs & Pick<ToolCallReserved<T>, 'tool'> & AgentLoop): Promise<ToolCallResult<T>>;
(input: ToolCallArgs & AgentLoop): Promise<ToolCallResult>;
};
Expect type
#
line 16640
Added in 2.1.271
The checks on a value (expect(received)), and with them the matchers that stand inside an expected value (expect.any(Number)).
A check that fails throws. In a hook the test registered with on the engine skips the hook as it skips any that throws, and the test fails all the same, with the check's message and the hook's event.
export type Expect = Expecting & Matching;
expect const
#
line 16649
Added in 2.1.271
Checks a value: expect(received).toEqual(expected) throws an AssertionError naming both sides when it fails, a message given leading.
.not negates; .resolves and .rejects check what a promise settles with; expect.any(Number) and its kin stand inside an expected value.
export const expect: Expect;
Expectation type
#
line 16655
Added in 2.1.271
What expect(received) answers: the checks, their negation, and the checks on what a promise received resolves or rejects with.
export type Expectation = Negatable<Matchers> & {
/**
* The checks on what the promise received resolves with; a rejection
* fails them.
*/
resolves: Negatable<AsyncMatchers>;
/**
* The checks on what the promise received rejects with; a resolution
* fails them.
*/
rejects: Negatable<AsyncMatchers>;
};
Expecting type
#
line 16672
Added in 2.1.271
expect(received, message?): the checks on a value, a message of the test's own leading a failure's.
export type Expecting = (received: unknown, message?: string) => Expectation;
FoundElement type
#
line 16681
Added in 2.1.277
One element of a mounted drawing as find returns it: the description the plugin's hook (or a Client's module) built, read as plain data.
What every surface is handed to draw, not what any surface painted: the same on the terminal, the desktop, VS Code and mobile.
24 lines
export type FoundElement = {
/**
* The element's tag: `Box`, `Text`, `Button`, `Input`, `Client`, ...
*/
type: string;
/**
* What its props carry as `key`, when they do.
*/
key: string | undefined;
/**
* Its props, plain data: a Button's `label`, a Text's `color`, ...;
* handlers never cross (a Button's `onPress` is not here).
*/
props: Record<string, unknown>;
/**
* What it shows: its string children in document order and, for the
* leaves that draw a prop as text, that prop (ElementQuery `text`).
*/
text: string;
/**
* Its children as drawn: strings and element descriptions.
*/
children: unknown[];
};
InputTarget type
#
line 16710
Added in 2.1.280
What $.ui.input takes: the plugin whose hook drew the Input, its key, the field's text, which input it is, instance and surface when several.
24 lines
export type InputTarget = {
plugin: string;
key: string;
/**
* The field's whole text at that moment: `e.value` for the chain.
*/
text: string;
/**
* `submit` (the default) is Enter with that text and reaches `onSubmit`;
* `change` is one edit left in the field and reaches `onInput`.
*
* A person typing is a run of `change`s, then a `submit`.
*/
kind?: UiInputArgument['kind'];
/**
* Which instance holds it, when the plugin drew the key in several.
*/
requestId?: string;
/**
* Which surface's drawing, when the key is drawn on more than one; the
* input carries the surface of the drawing it lands in either way.
*/
surface?: RenderSurface;
};
Matchers type
#
line 16739
Added in 2.1.271
The checks expect(received) offers; each throws an AssertionError when it fails, naming what was expected and what was received.
134 lines
export type Matchers = {
/**
* Passes when received is the value, by `Object.is`.
*
* @param expected the value
*/
toBe: (expected: unknown) => void;
/**
* Passes when received equals the value in structure, properties holding
* undefined ignored; `expect.any` and its kin match inside it.
*
* @param expected the value
*/
toEqual: (expected: unknown) => void;
/**
* As `toEqual`, but undefined properties and prototypes count.
*
* @param expected the value
*/
toStrictEqual: (expected: unknown) => void;
/**
* Passes when received holds at least the object's properties, equal.
*
* @param expected the object
*/
toMatchObject: (expected: object) => void;
/**
* Passes when a string received includes the item, or an iterable
* received has an element that is it.
*
* @param item the substring or element
*/
toContain: (item: unknown) => void;
/**
* Passes when an iterable received has an element equal to the item.
*
* @param item the element
*/
toContainEqual: (item: unknown) => void;
/**
* Passes when received's `length` is the number.
*
* @param length the number
*/
toHaveLength: (length: number) => void;
/**
* Passes when received holds a property at the path (`a.b`, or the keys
* in order), equal to the value when one is given.
*
* @param path the property's path
* @param value what it must equal, when given
*/
toHaveProperty: (path: string | readonly string[], value?: unknown) => void;
/**
* Passes when received is undefined.
*/
toBeUndefined: () => void;
/**
* Passes when received is anything but undefined.
*/
toBeDefined: () => void;
/**
* Passes when received is null.
*/
toBeNull: () => void;
/**
* Passes when received is truthy.
*/
toBeTruthy: () => void;
/**
* Passes when received is falsy.
*/
toBeFalsy: () => void;
/**
* Passes when received is NaN.
*/
toBeNaN: () => void;
/**
* Passes when received is greater than the bound.
*
* @param bound the bound
*/
toBeGreaterThan: (bound: number | bigint) => void;
/**
* Passes when received is the bound or greater.
*
* @param bound the bound
*/
toBeGreaterThanOrEqual: (bound: number | bigint) => void;
/**
* Passes when received is less than the bound.
*
* @param bound the bound
*/
toBeLessThan: (bound: number | bigint) => void;
/**
* Passes when received is the bound or less.
*
* @param bound the bound
*/
toBeLessThanOrEqual: (bound: number | bigint) => void;
/**
* Passes when a string received includes the text, or the pattern matches
* it.
*
* @param pattern the text or pattern
*/
toMatch: (pattern: string | RegExp) => void;
/**
* Passes when a string received starts with the prefix.
*
* @param prefix the prefix
*/
toStartWith: (prefix: string) => void;
/**
* Passes when a string received ends with the suffix.
*
* @param suffix the suffix
*/
toEndWith: (suffix: string) => void;
/**
* Passes when received is an instance of the class.
*
* @param expected the class
*/
toBeInstanceOf: (expected: Constructor) => void;
/**
* Passes when calling received throws (or, under `rejects`, the rejection
* is) an error as described: by substring, pattern, class or message.
*
* @param expected the description; any throw passes without one
*/
toThrow: (expected?: ThrowExpectation) => void;
};
Matching type
#
line 16878
Added in 2.1.271
The matchers that stand inside an expected value, each matching received there by a rule instead of by equality.
44 lines
export type Matching = {
/**
* Matches any instance of the class, a primitive by its wrapper
* (`expect.any(Number)`).
*
* @param expected the class
* @returns the matcher
*/
any: (expected: Constructor) => AsymmetricMatcher;
/**
* Matches anything but null and undefined.
*
* @returns the matcher
*/
anything: () => AsymmetricMatcher;
/**
* Matches a string that includes the text.
*
* @param text the substring
* @returns the matcher
*/
stringContaining: (text: string) => AsymmetricMatcher;
/**
* Matches a string the pattern matches.
*
* @param pattern the pattern, or the source of one
* @returns the matcher
*/
stringMatching: (pattern: string | RegExp) => AsymmetricMatcher;
/**
* Matches an object holding at least the shape's properties, equal.
*
* @param shape the properties
* @returns the matcher
*/
objectContaining: (shape: object) => AsymmetricMatcher;
/**
* Matches an array holding an element equal to each of the items.
*
* @param items the elements
* @returns the matcher
*/
arrayContaining: (items: readonly unknown[]) => AsymmetricMatcher;
};
Mock type
#
line 16927
Added in 2.1.271 · changed in 2.1.293
The world beneath the plugins, mocked noun by noun: each member registers hooks of the test's on on, visible where the test calls it.
42 lines
export type Mock = {
/**
* Answers `$.clock` from a clock in memory that moves only when the test
* moves it: `clock.now` reads it, and each wait is held.
*
* A held wait resolves when an advance crosses the time it is due, and is
* dropped when its dispatch aborts; one held past a hook's budget (ten
* seconds of real time) is let go, as a hook that overran.
*
* @param on the test's `on`
* @param options where the clock starts (`now`, 0 when not given)
* @returns the clock: its time, and the calls that move it
*/
clock: (on: On, options?: MockClockOptions) => MockClock;
/**
* Answers `$.store` from a store in memory: `get`, `set`, `delete` and
* `keys` over it, as the engine keeps a plugin's own.
*
* @param on the test's `on`
* @param entries what the store holds at the start (nothing when not given)
*/
store: (on: On, entries?: Readonly<Record<string, unknown>>) => void;
/**
* Answers `$.env.get` from a set of variables; one not listed is unset.
*
* @param on the test's `on`
* @param variables the environment the plugins read
*/
env: (on: On, variables: Readonly<Record<string, string>>) => void;
/**
* Records what is appended to the session's conversations: each row the
* kit stored for a plugin's `$.session.append`, or for the test's own.
*
* The kit answers with or without this, as a session stores the row: a
* plugin's minted or refused, a raised one's pinned blocks put back. This is
* the test's `session.append` hook: one more needs a matcher (`{ door }`).
*
* @param on the test's `on`
* @returns the session: the rows appended so far
*/
session: (on: On) => MockSession;
};
mock const
#
line 16977
Added in 2.1.271 · changed in 2.1.293
The world beneath the plugins, mocked noun by noun: mock.clock, mock.store, mock.env and mock.session.
Each registers hooks of the test's on the on it is handed, visible where the test calls it, and answers its noun from memory or records it.
export const mock: Mock;
MockClock type
#
line 16983
Added in 2.1.271
The clock mock.clock hands back: the time its hooks answer, and the only ways it moves.
45 lines
export type MockClock = {
/**
* The time now, in milliseconds: what `$.clock.now()` resolves beneath the
* plugins.
*
* @returns the time
*/
now: () => number;
/**
* Moves the clock on, resolving each wait due on the way (`$.clock.sleep`,
* `after`, `every`, this clock's `sleep`) in the order it comes due.
*
* The clock reads each wait's time as it resolves, and what one started
* runs before the next resolves.
*
* @param ms how far to move, in milliseconds
* @returns resolves once the clock is there and the event loop settled
*/
advance: (ms: number) => Promise<void>;
/**
* Moves the clock to a time at or past now, as `advance` would.
*
* @param ms the time, in milliseconds
* @returns resolves once the clock is there and the event loop settled
*/
set: (ms: number) => Promise<void>;
/**
* Lets what is already under way run as far as it can without the clock
* moving: every wait due now resolves and the event loop settles.
*
* The same as `advance(0)`; the name for the step between starting a
* dispatch unawaited and looking at what it did.
*
* @returns resolves once the event loop settled, the time where it was
*/
settle: () => Promise<void>;
/**
* Resolves once the clock has moved this far past now: how a hook of the
* test's answers late.
*
* @param ms how far, in milliseconds
* @returns resolves when an advance crosses that time
*/
sleep: (ms: number) => Promise<void>;
};
MockClockOptions type
#
line 17032
Added in 2.1.271
Where a mocked clock starts: now, in milliseconds (0 when not given).
export type MockClockOptions = {
now?: number;
};
MockSession type
#
line 17040
Added in 2.1.293
The session mock.session hands back: what was appended to its conversations while the test ran.
export type MockSession = {
/**
* The rows stored so far, oldest first, each as the event carried it:
* `message` as stored, `door`, `origin`, `uuid` and `agentId`.
*
* A plugin's own row has the door `note`, the plugin as `origin` and a
* fresh `uuid`; a row a hook above refused, or the kit, is left out.
*
* @returns the rows
*/
appended: () => readonly SessionAppendInput[];
};
Mounted type
#
line 17061
Added in 2.1.277
A drawing of component C the test mounted on surface P: reads over its description, acts on its elements by key, Client acts where P has one.
Narrowed by the surface the test passed, as e.surface narrows $.ui.resolve(e): no key on mobile or vscode, whose tables (Elements) lack Client; over a union, their meet.
export type Mounted<P extends RenderSurface = RenderSurface, C extends RenderComponent = RenderComponent> = {
[K in keyof MountedMembers<P, C> as K extends keyof ElementOfAct ? ElementOfAct[K] extends keyof Elements[P] ? K : never : K]: MountedMembers<P, C>[K];
};
MountedMembers type
#
line 17073
Added in 2.1.277
Every member a mounted drawing of component C can have; Mounted<P, C> keeps the ones surface P has the element for (ElementOfAct).
Each act resolves once the work it started settled (chain, handler, what the handler left running) and what a plugin invalidated was drawn again. The kit exercises the mod's hooks and modules, never a surface's paint.
146 lines
export type MountedMembers<P extends RenderSurface, C extends RenderComponent = RenderComponent> = {
/**
* Where this drawing is, as the test named it.
*/
readonly surface: P;
/**
* The tree as last drawn: what the plugins' `ui.render` chain returned
* for this instance, validated by the surface's table, as plain data.
*
* With `in`, what that `Client`'s surface module last drew instead.
*
* @param scope `{ in }`: a `Client`'s key, to read its module's tree
* @returns the tree; rejects with the refusal when the surface could not
* draw what the chain returned, or with a `Client`'s fault line
* @example
* expect(await ui.drawn()).toMatchObject({ type: 'Box' })
*/
drawn: (scope?: ClientScope) => Promise<RenderElement>;
/**
* The first element matching the query, outermost first in document
* order, or undefined.
*
* @param query tag, key and shown text to match; `in` to search a Client
* @returns the element's description, or undefined when none matches
* @example
* expect((await ui.find({ key: 'count' }))?.text).toBe('3 notes')
*/
find: (query: ElementQuery) => Promise<FoundElement | undefined>;
/**
* Every element matching the query, in document order.
*
* @param query tag, key and shown text to match; `in` to search a Client
* @returns the matching elements' descriptions
* @example
* expect(await ui.findAll({ type: 'Button' })).toHaveLength(2)
*/
findAll: (query: ElementQuery) => Promise<FoundElement[]>;
/**
* Presses the Button keyed `key`, as the person activating it on this
* surface does: the `ui.press` chain, the Button's own `onPress` last.
*
* `e.surface` is this drawing's. With `link`, presses that link of the
* Markdown keyed `key` instead. A Button a `Client`'s module drew is
* pressed the same way, by its key.
*
* @param target the key; another plugin's name to press its Button; a link
* @returns what the chain settled on
* @example
* await ui.press({ key: 'save' })
*/
press: (target: MountPressTarget) => Promise<UiPressResult | undefined>;
/**
* Types into the Input keyed `key`: the `ui.input` chain with the text as
* `e.value`, the Input's own handler last.
*
* `kind` `submit` (the default) is Enter with that text, `change` an edit
* that leaves it in the field.
*
* @param target the key and the text; `kind`; another plugin's name
* @returns what the chain settled on
* @example
* await ui.input({ key: 'title', text: 'groceries' })
*/
input: (target: MountInputTarget) => Promise<UiInputResult | undefined>;
/**
* Picks `value` in the Select keyed `key`: the `ui.select` chain, the
* Select's own `onSelect` last.
*
* @param target the key and the option's value; another plugin's name
* @returns what the chain settled on
* @example
* await ui.select({ key: 'sort', value: 'date' })
*/
select: (target: MountSelectTarget) => Promise<UiSelectResult | undefined>;
/**
* Hands a `Client`'s `onKey` listener one key, as a key pressed while
* its region has the focus does.
*
* `in` names the `Client` by key; optional when the drawing holds one.
*
* @param event the key (`{ key: 'right' }`, `{ key: 'a', ctrl: true }`)
* @example
* await ui.key({ key: 'return', in: 'board' })
*/
key: (event: MountKeyEvent) => Promise<void>;
/**
* Hands a `Client`'s `onPointer` listener one event, in the cells of its
* region as every surface that draws a `Client` reports them.
*
* @param event the event (`{ type: 'down', x: 3, y: 0, button: 'left' }`)
* @example
* await ui.pointer({ type: 'down', x: 2, y: 0, button: 'left' })
*/
pointer: (event: MountPointerEvent) => Promise<void>;
/**
* Posts as a `Client`'s own `surface.post(data)` does: the plugin's
* `ui.message` hooks run with `e.data`, `e.surface` this drawing's.
*
* A `{ props }` they answer reaches the instance, which redraws with
* its state kept.
*
* @param data plain data (JsonValue)
* @param scope `{ in }`: which `Client`, when the drawing holds several
* @example
* await ui.post({ pick: 2 })
*/
post: (data: JsonValue, scope?: ClientScope) => Promise<void>;
/**
* Moves the drawing's frame clock on: each `surface.every(ms, fn)` timer
* of its `Client`s fires at every interval of its own the move crosses.
*
* @param ms how far, in milliseconds
* @example
* await ui.advance(250)
*/
advance: (ms: number) => Promise<void>;
/**
* Lays a `Client`'s region out at a size, as the surface measuring it
* does: what its module reads as `surface.columns` and `surface.rows`.
*
* @param size cells across and down; `in`: which `Client`
* @example
* await ui.resize({ columns: 40, rows: 3 })
*/
resize: (size: MountResizeTarget) => Promise<void>;
/**
* Draws the instance again, as the engine does when its props change (a
* tool row's output arrived): the `ui.render` chain with the next props.
*
* A plugin's own `$.ui.invalidate` needs no call: the drawing follows it
* before the next read.
*
* @param props the component's next props; the current ones when absent
* @example
* await ui.redraw({ ...TOOL_ROW, isRunning: false, output: 'done' })
*/
redraw: (props?: RenderPropsOf[C]) => Promise<void>;
/**
* Lets the drawing go, as the surface dropping the instance does: its
* `Client`s and their timers end. Later acts on the handle reject.
*
* @example
* await ui.unmount()
*/
unmount: () => Promise<void>;
};
MountInputTarget type
#
line 17224
Added in 2.1.277
What a mounted drawing's input takes: the Input's key, the text, which of the two inputs it is (submit when unsaid), another plugin's name.
export type MountInputTarget = {
key: string;
text: string;
kind?: UiInputArgument['kind'];
plugin?: string;
};
MountKeyEvent type
#
line 17235
Added in 2.1.277
What a mounted drawing's key takes: the key as a Client's onKey listener receives it (ClientKeyEvent), and which Client when several.
export type MountKeyEvent = ClientKeyEvent & ClientScope;
MountPointerEvent type
#
line 17241
Added in 2.1.277
What a mounted drawing's pointer takes: the event as a Client's onPointer listener receives it, in its region's cells, and which one.
export type MountPointerEvent = ClientPointerEvent & ClientScope;
MountPressTarget type
#
line 17247
Added in 2.1.277
What a mounted drawing's press takes: the Button's key, another plugin's name when the Button is not the mounted plugin's, a link.
export type MountPressTarget = {
key: string;
plugin?: string;
/**
* Presses this link of the Markdown keyed `key` instead of a Button.
*/
link?: PressedLink;
};