import type { Alpine as _AlpineType } from 'alpinejs'; import type { Magics } from 'alpinejs'; import type { ComponentObjectPropsOptions, EmitsOptions, ObjectEmitsOptions, InjectionKey } from 'vue'; import type { EmitsToProps, EmitKeys, EmitsToEmitFns } from './emit'; import type { ReactivityAPI } from './reactivity'; declare module 'alpinejs' { interface Magics { $provide: | string | number>(key: K, value: K extends InjectionKey ? V : T) => void; $inject: (key: InjectionKey | string, defaultVal?: T) => T; } } export type AlpineType = _AlpineType; export type Data = Record; export interface AlpineInstance extends Magics

{ /** Name of the component. */ $name: Readonly; /** Props passed to the component as reactive object. */ $props: Readonly

; /** HTML attributes (as object) of the element where the `x-data` was defined. */ $attrs: Readonly>; /** Initial component definition. */ $options: Readonly>; /** * Normalized declaration of custom events emitted by the component. * * See https://vuejs.org/api/options-state.html#emits */ $emitsOptions: Readonly; /** * Vue-like `emit()` method. Unlike `$dispatch`, `$emit` expects event handlers * to be set as props (e.g. `onClickButton` or `onClickButtonOnce` for event * `clickButton`). * * Thus, handlers for events emitted with `$emit()` must be explicitly defined * on the component that emits that event. In other words, the even does NOT * bubble up. When no event handler is passed as a prop, the event is NOT sent. */ $emit: >(name: K, ...args: Parameters[K], undefined>>) => void; $onBeforeUnmount: (cb: () => void) => void; init: (this: Magics) => void; destroy: (this: Magics) => void; } export interface ComponentOptions { [key: string]: any; name: string; props?: ComponentObjectPropsOptions

| undefined | null; /** * Declare the custom events emitted by the component. * * See https://vuejs.org/api/options-state.html#emits */ emits?: E | undefined | null; setup?: (props: Readonly

>, vm: AlpineInstance, reactivity: ReactivityAPI, ...args: any[]) => T | Promise; /** If `isolated`, the component DOES NOT have access to variables defined in parent components. */ isolated?: boolean; /** * Initial component state can be passed to the component as JSON via `data-x-init` HTML attribute. * Change this option to override which `data-x-` key will be used. */ initKey?: string; } /** Convert ComponentOptions to AlpineInstance */ export type AlpineInstanceFromOptions> = T extends ComponentOptions ? AlpineInstance : never;