import { z } from 'zod'; import { HCAction, HCBackground, HCCard, HCContainerRef, HCPart, HCStack, HCValue } from './HyperCardModel'; export declare const HyperCardAppInfo: { readonly id: "HyperCard.app"; readonly name: "HyperCard"; readonly icon: string; }; /** Prefix for all HyperCard action types routed to the app reducer. */ export declare const HYPERCARD_EVENT_PREFIX = "ClassicyAppHyperCard"; /** * Shallow manifest schema for HyperCard.app's data. Covers BOTH writers of * `apps["HyperCard.app"].data`: the player (activeStackId/openStacks/ * openFiles, HyperCardContext) and the editor (`edits`, * Editor/HyperCardEditorContext) — one app id, one state schema, per the * manifest registry's first-schema-wins merge rule. Interpreter runtime * inside each open stack is deliberately loose-typed. */ export declare const HyperCardStateSchema: z.ZodObject<{ activeStackId: z.ZodOptional; openStacks: z.ZodOptional>>; openFiles: z.ZodOptional>; edits: z.ZodOptional>>; }, z.core.$loose>; /** * A reified interpreter frame. The frame stack fully captures control state so * it can be serialized/suspended at any instant (no host recursion). `if` * branches simply push a `seq` frame for the chosen branch. */ export type HCFrame = { kind: "seq"; body: HCAction[]; ip: number; } | { kind: "repeat"; body: HCAction[]; ip: number; /** Remaining iterations for a counted repeat (Infinity for while-loops). */ remaining: number; /** Condition expression for a `while` repeat; re-checked each iteration. */ while?: string; }; export type HCRunStatus = "idle" | "running" | "awaitingDialog" | "awaitingWait" | "awaitingTransition" | "awaitingCustom"; export type HCPendingEffect = { id: number; kind: "beep"; } | { id: number; kind: "play"; sound: string; } | { id: number; kind: "openApp"; appId: string; event?: string; data?: Record; } | { id: number; kind: "custom"; name: string; args: Record; token?: string; }; export interface HCDialog { kind: "answer" | "ask"; message: string; buttons?: string[]; /** ask only: seeded default text. */ defaultValue?: string; token: string; } export interface HCTransition { effect: string; toCardId: string; token: string; } export interface HCRuntime { frames: HCFrame[]; status: HCRunStatus; /** Where a dialog/wait/transition result resumes; token guards stale resumes. */ resume?: { token: string; container?: HCContainerRef; }; /** Per-dispatch step budget guard. */ steps: number; /** Single monotonic counter for effect ids and suspend tokens (deterministic — not Date.now/random). */ seq: number; pendingEffects: HCPendingEffect[]; dialog?: HCDialog; transition?: HCTransition; /** Pending `wait`; the component sets a timer and resumes on the token. */ wait?: { ms: number; token: string; }; /** One-shot visual effect set by `visual`, applied to the next `go`. */ pendingVisual?: string; /** Navigation depth guard against go-loops within a single run. */ navDepth: number; } export declare function makeInitialRuntime(): HCRuntime; export interface HCOpenStack { /** Reference to the stack source (bundle key / url); re-parsed on open. */ stackSource: string; /** Parsed stack — held in memory for the session, re-hydrated on load. */ stack: HCStack; currentCardId: string; /** Card ids visited, for `go back`. */ history: string[]; variables: Record; /** Field value OVERRIDES only, keyed by {@link fieldKey}. */ fieldValues: Record; partVisibility: Record; /** Bumped by programmatic put/set to force an input remount. */ fieldRev: Record; runtime: HCRuntime; } export interface HyperCardData { activeStackId?: string; openStacks: Record; /** * File-system paths of `.stack` documents awaiting load — written by the * kernel's generic *OpenFile handler (Finder routing for * ClassicyFileSystemEntryFileType.Stack) or by * ClassicyAppHyperCardOpenFile. The HyperCard component fetches, validates, * and opens each, then consumes the path (OpenFileConsumed/OpenFileFailed). */ openFiles?: string[]; } export declare function isHyperCardData(d: unknown): d is HyperCardData; /** * Compute the storage key for a field's value. Shared fields collapse to a * single per-background entry; all other fields are per-card. */ export declare function fieldKey(part: Pick, cardId: string, backgroundId?: string): string; export declare function findCardIndexById(stack: HCStack, id: string): number; export declare function getCard(stack: HCStack, cardId: string): HCCard | undefined; export declare function getBackgroundForCard(stack: HCStack, card: HCCard): HCBackground | undefined; /** * Resolve a `go` target reference to a card id. Handles the keywords * next/prev/previous/first/last and matches by card id then card name. * Returns undefined for `back` (handled via history) or an unknown reference. */ export declare function resolveCardRef(stack: HCStack, currentCardId: string, ref: string): string | undefined; /** Collect a card's effective parts: its background's parts then its own. */ export declare function collectCardParts(stack: HCStack, card: HCCard): { part: HCPart; backgroundId?: string; }[]; /** Find a part by id across a card and its background. */ export declare function findPart(stack: HCStack, card: HCCard, partId: string): { part: HCPart; backgroundId?: string; } | undefined; //# sourceMappingURL=HyperCardUtils.d.ts.map