import { type CommandDefinition } from '../command/index.js'; import { type MountDefinition } from '../mount/index.js'; /** A Command in a test simulation. Carries `name` and optionally the `args` * the runtime captured at construction. Instance matchers (Command values * produced by calling a Definition) are matched against this shape; the * `effect` field on a real Command is irrelevant for matching, so we only * retain `name + args`. */ export type AnyCommand = Readonly<{ name: string; args?: Record; }>; /** Pattern for matching a Command in test assertions. A Definition matches * by name only ("a Command with this identity was dispatched"); an Instance * matches by name AND structural-equal args ("a Command with this identity * AND these args was dispatched"). Choose the form per assertion based on * whether the test cares about the args value. * * Two modes only: name-only or name + full args. Partial-args matching is * intentionally unsupported. If a subset of args carries the meaning the * test is verifying, the right assertion is usually against the Model that * the Command's result fed through update, not a partial Command shape. */ export type CommandMatcher = CommandDefinition | AnyCommand; /** Formats a Command matcher for display in error messages. Definition * matchers render as just the name; Instance matchers append the args. */ export declare const formatMatcher: (matcher: CommandMatcher) => string; /** Formats a pending Command for display in error messages. Same shape as * `formatMatcher` so failure messages diff visually at a glance. */ export declare const formatCommand: (command: AnyCommand) => string; /** A pending Mount in a Scene simulation. Identified by `name` and an * `occurrence` index that disambiguates same-named mounts in the rendered * tree (e.g. two open popovers each contributing an `AnchorPopover`). The * occurrence is the 0-based position among same-named markers in * tree-traversal order. `args` carries the runtime values used to construct * the MountAction when its definition declared an args record. */ export type PendingMount = Readonly<{ name: string; args?: Record; occurrence: number; }>; /** A Mount lifecycle event in a test simulation. Carries `name` and * optionally the `args` used to construct the MountAction. Mirrors * `AnyCommand` for Mount matchers. */ export type AnyMount = Readonly<{ name: string; args?: Record; }>; /** Pattern for matching a pending Mount in test assertions. A Definition * matches by name only ("a Mount with this identity is in the rendered * tree"); an Instance matches by name AND structural-equal args ("a Mount * with this identity AND these args"). Choose the form per assertion based * on whether the test cares about the args value. * * Two modes only: name-only or name + full args. Partial-args matching is * intentionally unsupported, mirroring `CommandMatcher`. */ export type MountMatcher = MountDefinition | AnyMount; /** Whether a `matcher` matches a pending Mount. Definition matchers match by * name. Instance matchers (with declared args) match by name + structural * args equality; instance matchers without args match by name. */ export declare const mountMatches: (matcher: MountMatcher, mount: AnyMount) => boolean; /** Formats a Mount matcher for display in error messages. Definition * matchers render as just the name; Instance matchers append the args. */ export declare const formatMountMatcher: (matcher: MountMatcher) => string; type UpdateResult = readonly [Model, ReadonlyArray] | readonly [Model, ReadonlyArray, OutMessage]; /** A Command matcher (Definition or Instance) with the result Message to * resolve a pending Command with. Definition matchers resolve by name; an * Instance matcher resolves only the pending Command whose name AND args * match. */ export type Resolver = readonly [CommandMatcher, ResultMessage] | readonly [ CommandMatcher, ResultMessage, (message: ResultMessage) => unknown ]; /** A Mount matcher (Definition or Instance) with the result Message to * resolve it with. Mirrors `Resolver` for Commands. The optional third * element lifts a child Mount result into the parent's Message universe * (mirrors `Mount.mapMessage`). */ export type MountResolver = readonly [MountMatcher, ResultMessage] | readonly [MountMatcher, ResultMessage, (message: ResultMessage) => unknown]; /** A resolver entry pairs a Command matcher with the Message that should be * fed back through update when a pending Command matches. Stored as a list * (not a name-keyed map) so Instance matchers with the same name but * different args can coexist. Each entry is consumed on its first matching * dispatch. */ export type ResolverEntry = Readonly<{ matcher: CommandMatcher; message: Message; }>; /** Base shape of an internal simulation — shared between Story and Scene. */ export type BaseInternal = Readonly<{ model: Model; message: Message | undefined; commands: ReadonlyArray; outMessage: OutMessage; updateFn: (model: Model, message: Message) => UpdateResult; resolvers: ReadonlyArray>; }>; /** Resolves the first pending Command that matches the given matcher and * feeds its result through update. Returns `undefined` when no pending * Command matches. Definition matchers match by name; Instance matchers * match by name + args. */ export declare const resolveByMatcher: (internal: BaseInternal, matcher: CommandMatcher, resolverMessage: Message) => BaseInternal | undefined; /** Resolves all listed Commands, cascading through any Commands produced by * the result. Each entry is consumed by exactly one matching dispatch in * declaration order; for N identical responses, compose with * `Array.makeBy(n, () => [Def, message])`. Across calls, new entries replace * any leftover resolvers sharing their fingerprint (latest wins). */ export declare const resolveAllInternal: (internal: BaseInternal, resolvers: ReadonlyArray) => BaseInternal; /** Throws if more than one pending Command matches the given matcher. Used * by single-resolve paths (`Story.Command.resolve`, `Scene.Command.resolve`) * where ambiguity is a bug. The test author can't have intended one specific * Command if multiple match. `resolveAll` consumes ordered pairings and * skips this check. */ export declare const assertResolveUnambiguous: (commands: ReadonlyArray, matcher: CommandMatcher) => void; /** Throws if any of the given matchers fail to match a pending Command. * Definition matchers match by name; Instance matchers match by name + args. */ export declare const assertHasCommands: (commands: ReadonlyArray, matchers: ReadonlyArray) => void; /** Throws if the pending Commands don't match the given matchers exactly * (order-independent). Definition matchers compare by name; Instance * matchers compare by name + args. Each matcher must consume exactly one * pending Command. */ export declare const assertExactCommands: (commands: ReadonlyArray, matchers: ReadonlyArray) => void; /** Throws if there are any pending Commands. */ export declare const assertZeroCommands: (commands: ReadonlyArray) => void; /** Throws when trying to send a message with unresolved Commands. */ export declare const assertNoUnresolvedCommands: (commands: ReadonlyArray, context: string) => void; /** Throws when Commands remain at the end of a test. */ export declare const assertAllCommandsResolved: (commands: ReadonlyArray) => void; /** Formats a list of pending Mounts (with args + occurrence suffix where * applicable) for display in error messages. Returns " (none)" when * empty, mirroring the Command-side formatters. */ export declare const formatMountList: (mounts: ReadonlyArray) => string; /** Resolves the first pending Mount that matches the given matcher and feeds * its result through update. Returns `undefined` when no pending Mount * matches. Definition matchers match by name; Instance matchers match by * name + args. */ export declare const resolveMountByMatcher: (internal: BaseInternal, pendingMounts: ReadonlyArray, matcher: MountMatcher, resolverMessage: Message) => Readonly<{ internal: BaseInternal; pendingMounts: ReadonlyArray; }> | undefined; /** Throws if any of the given matchers are missing from the pending mount * list. Definition matchers match by name; Instance matchers match by * name + structural-equal args. */ export declare const assertHasMounts: (pendingMounts: ReadonlyArray, matchers: ReadonlyArray) => void; /** Throws if the pending Mounts don't match the given matchers exactly. Each * matcher must consume exactly one pending Mount. Order-independent. * Definition matchers match by name; Instance matchers match by * name + structural-equal args. */ export declare const assertExactMounts: (pendingMounts: ReadonlyArray, matchers: ReadonlyArray) => void; /** Throws if there are any pending Mounts. */ export declare const assertZeroMounts: (pendingMounts: ReadonlyArray) => void; /** Throws when trying to send a Message with unresolved Mounts in the * rendered view. */ export declare const assertNoUnresolvedMounts: (pendingMounts: ReadonlyArray, context: string) => void; /** Throws when trying to send a Message with unacknowledged unmounts * from previous renders. */ export declare const assertNoUnacknowledgedUnmounts: (unacknowledgedEnded: ReadonlyArray, context: string) => void; /** Throws when Mounts remain at the end of a test. */ export declare const assertAllMountsResolved: (pendingMounts: ReadonlyArray) => void; /** Throws when Mounts ended (unmounted) without being acknowledged. */ export declare const assertAllUnmountsAcknowledged: (unacknowledgedEnded: ReadonlyArray) => void; export {}; //# sourceMappingURL=internal.d.ts.map