From 3cf5e84efc8bc8e10e55622c9f653590f19a2835 Mon Sep 17 00:00:00 2001 From: Rafik El Hadi Houari Date: Mon, 17 May 2021 14:53:07 +0100 Subject: [PATCH] Add type Alpine The type may be helpful when building plugins in Typescript & just using `window.Alpine` in general --- src/index.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/index.ts b/src/index.ts index 278368a..332cac9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,28 @@ export abstract class AlpineComponent { [key: string]: any; } +export declare type Alpine = { + version: string; + pauseMutationObserver: boolean; + magicProperties: { [name: string]: function }; + ignoreFocusedForValueBinding: boolean; + pauseMutationObserver: boolean; + onComponentInitializeds: Array; + onBeforeComponentInitializeds: Array; + onComponentInitializeds: (callback: function) => void; + onBeforeComponentInitializeds: (callback: function) => void; + listenForNewUninitializedComponentsAtRunTime: () => undefined; + discoverUninitializedComponents: ( + callback: (rootEl: HTMLElement) => void, + el?: HTMLElement = null + ) => void; + discoverComponents: (callback: (rootEl: HTMLElement) => void) => void; + start: () => void; + addMagicProperty(name: string, callback: ($el: HTMLElement) => void); + clone: (component: any, newEl: HTMLElement) => void; +}; + + export function registerComponents(components: { [name: string]: Function }): { [name: string]: ComponentConstructor } { Object.entries(components).forEach(([name, file]) => { component(name, file);