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,108 @@
1
+ /**
2
+ * 🚀 WU-FRAMEWORK PREACT ADAPTER - TypeScript Declarations
3
+ */
4
+
5
+ import type { WuCore } from '../core/wu-core';
6
+
7
+ // Preact types (generics to avoid hard dependency)
8
+ type ComponentType<P = {}> = (props: P) => any;
9
+ type VNode = any;
10
+
11
+ /**
12
+ * Opciones de registro Preact
13
+ */
14
+ export interface PreactRegisterOptions {
15
+ /** Props iniciales */
16
+ props?: Record<string, any>;
17
+ /** Callback después de montar */
18
+ onMount?: (container: HTMLElement) => void;
19
+ /** Callback antes de desmontar */
20
+ onUnmount?: (container: HTMLElement) => void;
21
+ /** Permitir ejecución standalone */
22
+ standalone?: boolean;
23
+ /** Selector para modo standalone */
24
+ standaloneContainer?: string;
25
+ }
26
+
27
+ /**
28
+ * Props del componente WuSlot
29
+ */
30
+ export interface WuSlotProps {
31
+ name: string;
32
+ url: string;
33
+ appName?: string;
34
+ fallback?: VNode;
35
+ onLoad?: (data: { name: string; url: string }) => void;
36
+ onError?: (error: Error) => void;
37
+ className?: string;
38
+ style?: Record<string, string | number>;
39
+ }
40
+
41
+ /**
42
+ * Hooks de Preact necesarios para createUseWuEvents
43
+ */
44
+ export interface PreactHooks {
45
+ useCallback: <T extends (...args: any[]) => any>(callback: T, deps: any[]) => T;
46
+ useEffect: (effect: () => void | (() => void), deps?: any[]) => void;
47
+ useRef: <T>(initialValue: T) => { current: T };
48
+ }
49
+
50
+ /**
51
+ * Hooks para createUseWuStore
52
+ */
53
+ export interface PreactStoreHooks extends PreactHooks {
54
+ useState: <T>(initialValue: T | (() => T)) => [T, (value: T) => void];
55
+ }
56
+
57
+ /**
58
+ * Helper de eventos Wu para Preact
59
+ */
60
+ export interface UseWuEventsResult {
61
+ emit: (event: string, data?: any, options?: any) => void;
62
+ on: (event: string, callback: (data: any) => void) => () => void;
63
+ once: (event: string, callback: (data: any) => void) => () => void;
64
+ }
65
+
66
+ /**
67
+ * Helper de store Wu para Preact
68
+ */
69
+ export interface UseWuStoreResult {
70
+ state: any;
71
+ setState: (path: string, value: any) => void;
72
+ getState: (path?: string) => any;
73
+ }
74
+
75
+ export function register(
76
+ appName: string,
77
+ Component: ComponentType,
78
+ options?: PreactRegisterOptions
79
+ ): Promise<boolean>;
80
+
81
+ export function registerCompat(
82
+ appName: string,
83
+ Component: ComponentType,
84
+ options?: PreactRegisterOptions
85
+ ): Promise<boolean>;
86
+
87
+ export function createWuSlot(h: (type: any, props: any, ...children: any[]) => VNode): ComponentType<WuSlotProps>;
88
+
89
+ export function createUseWuEvents(hooks: PreactHooks): () => UseWuEventsResult;
90
+
91
+ export function createUseWuStore(hooks: PreactStoreHooks): (namespace?: string) => UseWuStoreResult;
92
+
93
+ export function getWuInstance(): WuCore | null;
94
+
95
+ export function waitForWu(timeout?: number): Promise<WuCore>;
96
+
97
+ export interface WuPreactAdapter {
98
+ register: typeof register;
99
+ registerCompat: typeof registerCompat;
100
+ createWuSlot: typeof createWuSlot;
101
+ createUseWuEvents: typeof createUseWuEvents;
102
+ createUseWuStore: typeof createUseWuStore;
103
+ getWuInstance: typeof getWuInstance;
104
+ waitForWu: typeof waitForWu;
105
+ }
106
+
107
+ export const wuPreact: WuPreactAdapter;
108
+ export default wuPreact;