/** * HyperCard stack model — the authored, JSON-serializable description of a * stack. This is the "document" a HyperCard stack file contains: a stack of * cards, each holding parts (buttons, fields, …) with placement, content, and * declarative behaviour. * * Behaviour is expressed as ordered lists of typed {@link HCAction} objects per * event (no HyperTalk text parser). Value strings inside actions are evaluated * by HyperCardExpression.ts; control state is executed by HyperCardEngine.ts. */ /** Default classic HyperCard card size, in pixels. */ export declare const DEFAULT_CARD_SIZE: [number, number]; export type HCValue = string | number; /** Rectangle as [x, y, width, height], in card-local pixels. */ export type HCRect = [number, number, number, number]; /** * Built-in part types. Plugins may register additional types (rendered by name * via registerHyperCardPart), so `HCPart.type` is a widened `string` — this * union documents the built-ins and gives authoring autocomplete. */ export type HCBuiltinPartType = "button" | "field" | "checkbox" | "radio" | "popup" | "slider" | "progress" | "label" | "image" | "group"; export type HCPartType = HCBuiltinPartType | (string & {}); export interface HCPartStyle { /** Button visual style. */ shape?: "rectangle" | "roundRect" | "transparent" | "default"; align?: "left" | "center" | "right"; fontSize?: "small" | "medium" | "large"; } export interface HCPart { id: string; name?: string; type: HCPartType; /** Absolute placement within the card canvas. */ rect?: HCRect; /** Initial visibility (default true). */ visible?: boolean; /** Authored content — a field's default text, a label's text, etc. */ content?: string; /** * Fields only: when true the field's text is shared across every card that * uses the same background; otherwise it is card-specific. */ shared?: boolean; /** Fields only: locked fields are display-only (rendered as a label). */ locked?: boolean; style?: HCPartStyle; /** Component-specific extras: popup `choices`, slider `min`/`max`, image `src`, field `multiline`, radio `family`, … */ options?: Record; /** Part-level message handlers (onMouseUp, …). */ script?: HCEventHandlers; } export interface HCCard { id: string; name?: string; /** Reference to a {@link HCBackground} id. */ background?: string; parts?: HCPart[]; script?: HCEventHandlers; } export interface HCBackground { id: string; name?: string; parts?: HCPart[]; script?: HCEventHandlers; } export interface HCEventHandlers { onOpenStack?: HCAction[]; onCloseStack?: HCAction[]; onOpenCard?: HCAction[]; onCloseCard?: HCAction[]; onOpenBackground?: HCAction[]; onMouseUp?: HCAction[]; onMouseDown?: HCAction[]; onIdle?: HCAction[]; } export type HCEventName = keyof HCEventHandlers; export declare const HC_EVENT_NAMES: HCEventName[]; /** A container reference — a variable or a field — that a value is written to. */ export interface HCContainerRef { /** Variable name. */ var?: string; /** Field (part) id. */ field?: string; } /** * A single declarative action. Discriminated by `do`. Value-bearing keys * (`value`, `to`, `condition`, …) are expression strings unless noted. */ export type HCAction = { do: "go"; to: string; } | ({ do: "put"; value: string; } & HCContainerRef) | ({ do: "add"; value: string; } & HCContainerRef) | ({ do: "subtract"; value: string; } & HCContainerRef) | ({ do: "multiply"; value: string; } & HCContainerRef) | ({ do: "divide"; value: string; } & HCContainerRef) | { do: "set"; part?: string; property: string; value: string; } | { do: "show"; part: string; } | { do: "hide"; part: string; } | { do: "beep"; } | { do: "play"; sound: string; } | ({ do: "answer"; message: string; buttons?: string[]; } & HCContainerRef) | ({ do: "ask"; prompt: string; default?: string; } & HCContainerRef) | { do: "visual"; effect: string; } | { do: "wait"; ms: number; } | { do: "if"; condition: string; then: HCAction[]; else?: HCAction[]; } | { do: "repeat"; times?: number; while?: string; body: HCAction[]; } | { do: "openApp"; app: string; event?: string; data?: Record; }; /** * A plugin command action — `do` is a registered command name * (see registerHyperCardCommand). Deliberately NOT part of the {@link HCAction} * union: a `{ do: string }` member would collapse the discriminated union and * break narrowing of the built-in actions. Stacks are JSON (untyped), so plugin * commands validate fine at runtime; the engine handles them in its default case. */ export type HCPluginAction = { do: string; } & Record; export interface HCStack { name: string; /** HyperCard major version this stack targets ("1" | "2"); informational. */ version?: string; /** Card canvas size [w, h]; defaults to {@link DEFAULT_CARD_SIZE}. */ size?: [number, number]; /** Stack-global variables, seeded into the runtime. */ variables?: Record; backgrounds?: HCBackground[]; cards: HCCard[]; stackScript?: HCEventHandlers; } export type HCValidateResult = { ok: true; stack: HCStack; } | { ok: false; errors: string[]; }; /** * Validate an untrusted parsed-JSON value as an {@link HCStack}. Returns the * typed stack on success or a list of human-readable errors. Kept intentionally * lenient about optional fields — only structural invariants the engine relies * on (ids, a non-empty cards array, part types) are enforced. */ export declare function validateStack(raw: unknown): HCValidateResult; //# sourceMappingURL=HyperCardModel.d.ts.map