import type { HttpContext } from '@adonisjs/core/http'; import type { ApplicationService } from '@adonisjs/core/types'; import { type Component, type Synth, type ViewComponent } from '../index.js'; import type ComponentContext from './component_context.js'; import type ComponentHook from './component_hook.js'; /** * Constructor type helper for mixins */ export type Constructor = new (...args: any[]) => T; /** * Snapshot structure for component state */ export type ComponentSnapshot = { /** * Component data (properties) */ data: Record; /** * Component metadata */ memo: ComponentMemo; /** * Checksum for integrity verification */ checksum: string; }; /** * Component metadata stored in snapshot */ export type ComponentMemo = { /** * Unique component ID */ id: string; /** * Component name */ name: string; /** * Request path where component was mounted */ path?: string; /** * HTTP method */ method?: string; /** * Child components */ children?: ComponentSnapshot[]; /** * Scripts to execute */ scripts?: string[]; /** * Assets to load */ assets?: string[]; /** * Validation errors */ errors?: Record; /** * Failed validation rules (field => rules) */ failedRules?: Record; /** * Locale */ locale?: string; }; /** * Component update payload */ export type ComponentUpdate = { /** * Snapshot to hydrate from */ snapshot: ComponentSnapshot; /** * Property updates */ updates: Record; /** * Method calls to execute */ calls: ComponentCall[]; }; /** * Component method call */ export type ComponentCall = { /** * Method name to call */ method: string; /** * Parameters to pass to method */ params: any[]; /** * Per-call metadata the client attaches (assets/livewire.js's Action * class always sends this key, defaulting to `{}`). `island` is set * when the action originated inside — or was explicitly scoped to via * `wire:island="name"` — an island fragment: `{ name, mode }` where * `mode` is `'morph' | 'append' | 'prepend'`. `mode` is only present * when the client attached it (`wire:island.append="name"`, etc.) — * `$wire.$island(name)` with no options omits it, defaulting to morph. */ metadata?: { island?: { name: string; mode?: 'morph' | 'append' | 'prepend'; }; [key: string]: any; }; }; /** * Component effects (responses to client) */ export type ComponentEffects = { /** * HTML to update */ html?: string; /** * Method return values */ returns?: any[]; /** * Events to dispatch */ dispatches?: (string | Record)[]; /** * Redirect URL */ redirect?: string; /** * Download file — the whole file travels base64-encoded in the response, * consumed client-side by building a Blob URL (see * assets/livewire.js's supportFileDownloads.js). No separate download * route/signed URL is involved. */ download?: { content: string; contentType: string; name: string; }; /** * Rendered island fragments (each already wrapped in * ``/`ENDFRAGMENT` markers, same format as * `slotFragments`) — sent instead of `html` when a request's calls * were entirely island-scoped, per `assets/livewire.js`'s * `supportIslands.js` (`payload.effects.islandFragments`). */ islandFragments?: string[]; /** * Browser events to fire */ browserEvent?: { event: string; params?: Record; }; /** * Validation errors (field => messages) */ errors?: Record; /** * Failed validation rules (field => rules) */ failedRules?: Record; /** * Raw JS expressions queued via component.js(expression, ...params) * Written by SupportJsEvaluation.dehydrate() */ xjs?: Array<{ expression: string; params: unknown[]; }>; /** * Allow dynamic properties for extensibility */ [key: string]: any; }; /** * Component mount options */ export type MountOptions = { /** * Layout to use for component */ layout?: { name: string; props?: Record; }; /** * Component key for re-mounting */ key?: string; }; /** * Base component interface */ export interface BaseComponent { /** * HTTP context */ ctx: HttpContext; /** * Application service */ app: ApplicationService; /** * Get component ID */ getId(): string; /** * Get component name */ getName(): string; /** * Set component ID */ setId(id: string): void; /** * Set component name */ setName(name: string): void; /** * Set view path */ setViewPath(path: string): void; /** * Render component template */ render(): Promise; /** * Skip rendering (return early) */ skipRender(html?: string): void; /** * Skip mounting */ skipMount(): void; /** * Skip hydration */ skipHydrate(): void; } export type ComponentConstructor = new (...args: any[]) => Component; export type ComponentHookConstructor = new (...args: any[]) => ComponentHook; export type ViewComponentConstructor = new (...args: any[]) => ViewComponent; export type SynthesizerConstructor = new (context: ComponentContext, path: string | null) => Synth; export type { PartialConfig as LivewireConfig, PartialConfig, Config } from './define_config.js';