wu-framework 1.0.6 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,179 @@
1
+ /**
2
+ * 🚀 WU-FRAMEWORK VANILLA JS ADAPTER - TypeScript Declarations
3
+ */
4
+
5
+ import type { WuCore } from '../core/wu-core';
6
+
7
+ /**
8
+ * Configuración de app Vanilla
9
+ */
10
+ export interface VanillaAppConfig {
11
+ /** Función para renderizar */
12
+ render: (container: HTMLElement, state?: any) => void;
13
+ /** Función para limpiar (opcional) */
14
+ destroy?: (container: HTMLElement, state?: any) => void;
15
+ /** Función de inicialización (opcional) */
16
+ init?: (container: HTMLElement, state?: any) => void;
17
+ /** Estado inicial */
18
+ state?: Record<string, any>;
19
+ }
20
+
21
+ /**
22
+ * Opciones de registro Vanilla
23
+ */
24
+ export interface VanillaRegisterOptions {
25
+ /** Callback después de montar */
26
+ onMount?: (container: HTMLElement, state: any) => void;
27
+ /** Callback antes de desmontar */
28
+ onUnmount?: (container: HTMLElement, state: any) => void;
29
+ /** Permitir ejecución standalone */
30
+ standalone?: boolean;
31
+ /** Selector para modo standalone */
32
+ standaloneContainer?: string;
33
+ }
34
+
35
+ /**
36
+ * Opciones para registrar clase
37
+ */
38
+ export interface VanillaClassOptions {
39
+ /** Argumentos para el constructor */
40
+ constructorArgs?: any[];
41
+ /** Callback después de montar */
42
+ onMount?: (container: HTMLElement, instance: any) => void;
43
+ /** Callback antes de desmontar */
44
+ onUnmount?: (container: HTMLElement, instance: any) => void;
45
+ /** Permitir ejecución standalone */
46
+ standalone?: boolean;
47
+ /** Selector para modo standalone */
48
+ standaloneContainer?: string;
49
+ }
50
+
51
+ /**
52
+ * Opciones para registrar template
53
+ */
54
+ export interface VanillaTemplateOptions {
55
+ /** Datos para el template */
56
+ data?: Record<string, any>;
57
+ /** Scripts a ejecutar */
58
+ scripts?: Array<(container: HTMLElement, data: any) => void>;
59
+ /** Estilos CSS */
60
+ styles?: string[];
61
+ /** Callback después de montar */
62
+ onMount?: (container: HTMLElement, data: any) => void;
63
+ /** Callback antes de desmontar */
64
+ onUnmount?: (container: HTMLElement, data: any) => void;
65
+ /** Permitir ejecución standalone */
66
+ standalone?: boolean;
67
+ /** Selector para modo standalone */
68
+ standaloneContainer?: string;
69
+ }
70
+
71
+ /**
72
+ * Configuración de componente reactivo
73
+ */
74
+ export interface ReactiveComponentConfig {
75
+ /** Estado inicial */
76
+ state?: Record<string, any>;
77
+ /** Función template */
78
+ template: (state: any) => string;
79
+ /** Acciones que modifican estado */
80
+ actions?: Record<string, (state: any, element?: HTMLElement) => any>;
81
+ /** Callback en init */
82
+ onInit?: (container: HTMLElement, state: any) => void;
83
+ /** Callback en destroy */
84
+ onDestroy?: (container: HTMLElement, state: any) => void;
85
+ }
86
+
87
+ /**
88
+ * Componente reactivo creado
89
+ */
90
+ export interface ReactiveComponent {
91
+ state: any;
92
+ init: (container: HTMLElement) => void;
93
+ render: (container: HTMLElement, state?: any) => void;
94
+ destroy: (container: HTMLElement) => void;
95
+ setState: (newState: Partial<any>) => void;
96
+ getState: () => any;
97
+ }
98
+
99
+ /**
100
+ * Helper de eventos Wu
101
+ */
102
+ export interface WuEventsHelper {
103
+ emit: (event: string, data?: any, options?: any) => void;
104
+ on: (event: string, callback: (data: any) => void) => () => void;
105
+ once: (event: string, callback: (data: any) => void) => () => void;
106
+ off: (event: string, callback: (data: any) => void) => void;
107
+ cleanup: () => void;
108
+ }
109
+
110
+ /**
111
+ * Helper de store Wu
112
+ */
113
+ export interface WuStoreHelper {
114
+ get: (path?: string) => any;
115
+ set: (path: string, value: any) => void;
116
+ onChange: (pattern: string, callback: (value: any) => void) => () => void;
117
+ }
118
+
119
+ /**
120
+ * Instancia de WuSlot
121
+ */
122
+ export interface WuSlotInstance {
123
+ container: HTMLElement;
124
+ destroy: () => Promise<void>;
125
+ }
126
+
127
+ export function register(
128
+ appName: string,
129
+ config: VanillaAppConfig,
130
+ options?: VanillaRegisterOptions
131
+ ): Promise<boolean>;
132
+
133
+ export function registerClass(
134
+ appName: string,
135
+ AppClass: new (container: HTMLElement, ...args: any[]) => any,
136
+ options?: VanillaClassOptions
137
+ ): Promise<boolean>;
138
+
139
+ export function registerTemplate(
140
+ appName: string,
141
+ template: string | ((data: any) => string),
142
+ options?: VanillaTemplateOptions
143
+ ): Promise<boolean>;
144
+
145
+ export function createComponent(config: ReactiveComponentConfig): ReactiveComponent;
146
+
147
+ export function createWuSlot(
148
+ target: HTMLElement,
149
+ props: {
150
+ name: string;
151
+ url: string;
152
+ fallbackText?: string;
153
+ onLoad?: (data: { name: string; url: string }) => void;
154
+ onError?: (error: Error) => void;
155
+ }
156
+ ): WuSlotInstance;
157
+
158
+ export function useWuEvents(): WuEventsHelper;
159
+
160
+ export function useWuStore(namespace?: string): WuStoreHelper;
161
+
162
+ export function getWuInstance(): WuCore | null;
163
+
164
+ export function waitForWu(timeout?: number): Promise<WuCore>;
165
+
166
+ export interface WuVanillaAdapter {
167
+ register: typeof register;
168
+ registerClass: typeof registerClass;
169
+ registerTemplate: typeof registerTemplate;
170
+ createComponent: typeof createComponent;
171
+ createWuSlot: typeof createWuSlot;
172
+ useWuEvents: typeof useWuEvents;
173
+ useWuStore: typeof useWuStore;
174
+ getWuInstance: typeof getWuInstance;
175
+ waitForWu: typeof waitForWu;
176
+ }
177
+
178
+ export const wuVanilla: WuVanillaAdapter;
179
+ export default wuVanilla;