/** * @xmachines/play - the core protocol layer * * This package defines the architectural contracts that carry the communication * between the Actor and the infrastructure, with no direct dependency between them. * RFC section 5.2 gives these protocols. They are the base of the loose coupling * between the business logic and the runtime adapters. * * ## The exports * * **PlayEvent** - the generic event type of the Actor communication * - It is every object with a `type: string` property * - The generic `TPayload` parameter gives a type-safe event shape, and it is optional * - The default is `Record`, which accepts each shape * - It is framework-agnostic, and it is not bound to XState or to another library * * **Use:** * ```typescript * // Flexible, the default: * const event: PlayEvent = { type: 'auth.login', userId: '123' }; * * // Type-safe, with the generic parameter: * type LoginEvent = PlayEvent<{ userId: string }>; * const event: LoginEvent = { type: 'auth.login', userId: '123' }; * ``` * * **The common event patterns:** * - A domain event: `{ type: 'auth.login', userId: '123' }` * - Your own event: `{ type: 'form.submit', data: {...} }` * * **The routing events** come from @xmachines/play-router: * - PlayRouteEvent: the routing event with the parameters and the target state ID * - RouterBridge: the protocol that connects a router adapter to an actor * * **The browser navigation:** a router adapter handles the browser BACK and FORWARD * buttons, through the `popstate` event. The user presses BACK or FORWARD, the * router detects the new URL, and it sends a PlayRouteEvent to the actor. The actor * then checks the event. * * ```typescript * import type { PlayRouteEvent, RouterBridge } from "@xmachines/play-router"; * ``` * * ## The architectural invariants * * These protocols enforce the invariants below: * 1. **Actor Authority**: the infrastructure makes a request, and the Actor decides the validity * 2. **Strict Separation**: no layer depends on another layer directly * 3. **Atom-Only Reactivity**: every state change goes through an atom * 4. **Passive Infrastructure**: the infrastructure observes the Actor atoms. It never controls them * 5. **State-Driven Reset**: each navigation follows the transition rules of the state machine * * @packageDocumentation */ export * from "./types.js"; export * from "./utils.js"; //# sourceMappingURL=index.d.ts.map