wu-framework 1.1.16 → 1.1.18

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.
Files changed (51) hide show
  1. package/README.md +52 -20
  2. package/package.json +48 -3
  3. package/src/adapters/alpine/index.d.ts +60 -0
  4. package/src/adapters/alpine/index.js +231 -0
  5. package/src/adapters/alpine.d.ts +3 -0
  6. package/src/adapters/alpine.js +3 -0
  7. package/src/adapters/htmx/index.d.ts +60 -0
  8. package/src/adapters/htmx/index.js +242 -0
  9. package/src/adapters/htmx.d.ts +3 -0
  10. package/src/adapters/htmx.js +3 -0
  11. package/src/adapters/index.js +60 -3
  12. package/src/adapters/qwik/index.d.ts +52 -0
  13. package/src/adapters/qwik/index.js +214 -0
  14. package/src/adapters/qwik.d.ts +3 -0
  15. package/src/adapters/qwik.js +3 -0
  16. package/src/adapters/react/ai.js +135 -135
  17. package/src/adapters/react/index.d.ts +246 -246
  18. package/src/adapters/react/index.js +695 -695
  19. package/src/adapters/stencil/index.d.ts +54 -0
  20. package/src/adapters/stencil/index.js +228 -0
  21. package/src/adapters/stencil.d.ts +3 -0
  22. package/src/adapters/stencil.js +3 -0
  23. package/src/adapters/stimulus/index.d.ts +60 -0
  24. package/src/adapters/stimulus/index.js +255 -0
  25. package/src/adapters/stimulus.d.ts +3 -0
  26. package/src/adapters/stimulus.js +3 -0
  27. package/src/adapters/svelte/index.js +1 -1
  28. package/src/adapters/vanilla/index.js +1 -1
  29. package/src/adapters/vue/index.js +8 -0
  30. package/src/core/wu-cache.js +24 -3
  31. package/src/core/wu-core.js +15 -1
  32. package/src/core/wu-error-boundary.js +17 -3
  33. package/src/core/wu-event-bus.js +43 -1
  34. package/src/core/wu-html-parser.js +13 -4
  35. package/src/core/wu-loader.js +162 -50
  36. package/src/core/wu-logger.js +21 -13
  37. package/src/core/wu-manifest.js +23 -0
  38. package/src/core/wu-plugin.js +57 -4
  39. package/src/core/wu-proxy-sandbox.js +2 -1
  40. package/src/core/wu-script-executor.js +48 -0
  41. package/src/core/wu-store.js +13 -3
  42. package/src/index.d.ts +317 -0
  43. package/src/index.js +11 -1
  44. package/dist/wu-framework.cjs.js +0 -3
  45. package/dist/wu-framework.cjs.js.map +0 -1
  46. package/dist/wu-framework.dev.js +0 -15302
  47. package/dist/wu-framework.dev.js.map +0 -1
  48. package/dist/wu-framework.esm.js +0 -3
  49. package/dist/wu-framework.esm.js.map +0 -1
  50. package/dist/wu-framework.umd.js +0 -3
  51. package/dist/wu-framework.umd.js.map +0 -1
@@ -1,246 +1,246 @@
1
- /**
2
- * Wu Framework React Adapter - TypeScript Definitions
3
- */
4
-
5
- import { ComponentType, ReactElement, CSSProperties, RefObject } from 'react';
6
-
7
- // ============================================================================
8
- // Core Types
9
- // ============================================================================
10
-
11
- export interface WuInstance {
12
- init: (config: WuConfig) => Promise<void>;
13
- mount: (appName: string, container: string) => Promise<void>;
14
- unmount: (appName: string) => Promise<void>;
15
- define: (appName: string, lifecycle: WuLifecycle) => void;
16
- app: (name: string, config: WuAppConfig) => WuApp;
17
- eventBus: WuEventBus;
18
- store: WuStore;
19
- }
20
-
21
- export interface WuConfig {
22
- apps: Array<{
23
- name: string;
24
- url: string;
25
- strategy?: 'lazy' | 'eager' | 'preload' | 'idle';
26
- }>;
27
- }
28
-
29
- export interface WuLifecycle {
30
- mount: (container: HTMLElement) => void | Promise<void>;
31
- unmount: (container?: HTMLElement) => void | Promise<void>;
32
- }
33
-
34
- export interface WuAppConfig {
35
- url: string;
36
- container: string;
37
- autoInit?: boolean;
38
- }
39
-
40
- export interface WuApp {
41
- mount: (container?: string) => Promise<void>;
42
- unmount: () => Promise<void>;
43
- remount: () => Promise<void>;
44
- reload: () => Promise<void>;
45
- destroy: () => Promise<void>;
46
- isMounted: boolean;
47
- info: WuAppInfo;
48
- }
49
-
50
- export interface WuAppInfo {
51
- name: string;
52
- url: string;
53
- mounted: boolean;
54
- status: 'stable' | 'refreshed' | 'unstable';
55
- }
56
-
57
- export interface WuEventBus {
58
- emit: (event: string, data?: any, options?: EmitOptions) => void;
59
- on: (event: string, callback: EventCallback) => () => void;
60
- once: (event: string, callback: EventCallback) => () => void;
61
- off: (event: string, callback?: EventCallback) => void;
62
- }
63
-
64
- export interface WuStore {
65
- get: (path?: string) => any;
66
- set: (path: string, value: any) => number;
67
- on: (pattern: string, callback: StoreCallback) => () => void;
68
- batch: (updates: Record<string, any>) => number[];
69
- clear: () => void;
70
- }
71
-
72
- export type EventCallback = (event: WuEvent) => void;
73
- export type StoreCallback = (change: { path: string; value: any }) => void;
74
-
75
- export interface WuEvent {
76
- name: string;
77
- data: any;
78
- timestamp: number;
79
- source?: string;
80
- }
81
-
82
- export interface EmitOptions {
83
- appName?: string;
84
- timestamp?: number;
85
- meta?: Record<string, any>;
86
- }
87
-
88
- // ============================================================================
89
- // React Adapter Types
90
- // ============================================================================
91
-
92
- export interface RegisterOptions {
93
- /** Wrap component in StrictMode (default: true) */
94
- strictMode?: boolean;
95
- /** Initial props for the component */
96
- props?: Record<string, any>;
97
- /** Callback after mounting */
98
- onMount?: (container: HTMLElement) => void;
99
- /** Callback before unmounting */
100
- onUnmount?: (container: HTMLElement) => void;
101
- /** Allow standalone execution (default: true) */
102
- standalone?: boolean;
103
- /** Selector for standalone mode (default: '#root') */
104
- standaloneContainer?: string;
105
- }
106
-
107
- /**
108
- * Register a React component as a microfrontend
109
- */
110
- export function register<P = {}>(
111
- appName: string,
112
- Component: ComponentType<P>,
113
- options?: RegisterOptions
114
- ): Promise<boolean>;
115
-
116
- // ============================================================================
117
- // WuSlot Component Types
118
- // ============================================================================
119
-
120
- export interface WuSlotProps {
121
- /** Display name for the microfrontend */
122
- name: string;
123
- /** URL where the microfrontend is hosted */
124
- url: string;
125
- /** App name from wu.json (defaults to name if not provided) */
126
- appName?: string;
127
- /** Custom fallback while loading */
128
- fallback?: ReactElement | null;
129
- /** Callback when microfrontend loads successfully */
130
- onLoad?: (info: { name: string; url: string }) => void;
131
- /** Callback when loading fails */
132
- onError?: (error: Error) => void;
133
- /** Callback when microfrontend mounts */
134
- onMount?: (info: { name: string; container: HTMLElement }) => void;
135
- /** Callback when microfrontend unmounts */
136
- onUnmount?: (info: { name: string }) => void;
137
- /** Additional CSS class */
138
- className?: string;
139
- /** Inline styles */
140
- style?: CSSProperties;
141
- }
142
-
143
- /**
144
- * Create a WuSlot component for loading microfrontends
145
- * @param React - React instance
146
- */
147
- export function createWuSlot(React: any): ComponentType<WuSlotProps>;
148
-
149
- // ============================================================================
150
- // Hooks Types
151
- // ============================================================================
152
-
153
- export interface UseWuEventsReturn {
154
- /** Emit an event to the event bus */
155
- emit: (event: string, data?: any, options?: EmitOptions) => void;
156
- /** Subscribe to an event */
157
- on: (event: string, callback: EventCallback) => () => void;
158
- /** Subscribe to an event once */
159
- once: (event: string, callback: EventCallback) => () => void;
160
- }
161
-
162
- /**
163
- * Create the useWuEvents hook
164
- * @param React - React instance
165
- */
166
- export function createUseWuEvents(React: any): () => UseWuEventsReturn;
167
-
168
- export interface UseWuStoreReturn<T = any> {
169
- /** Current state value (reactive) */
170
- state: T | null;
171
- /** Set a value in the store */
172
- setState: (path: string, value: any) => void;
173
- /** Get a value from the store */
174
- getState: (path?: string) => any;
175
- }
176
-
177
- /**
178
- * Create the useWuStore hook
179
- * @param React - React instance
180
- */
181
- export function createUseWuStore(React: any): <T = any>(namespace?: string) => UseWuStoreReturn<T>;
182
-
183
- // ============================================================================
184
- // AI Hook Types (Paradigma C: IA como Director de Orquesta)
185
- // ============================================================================
186
-
187
- export interface AIMessage {
188
- id: string;
189
- role: 'user' | 'assistant' | 'action';
190
- content: string;
191
- result?: any;
192
- timestamp: number;
193
- }
194
-
195
- export interface UseWuAIOptions {
196
- namespace?: string;
197
- onActionExecuted?: (data: { action: string; result: any }) => void;
198
- }
199
-
200
- export interface UseWuAIReturn {
201
- messages: AIMessage[];
202
- isStreaming: boolean;
203
- error: string | null;
204
- send: (text: string) => Promise<void>;
205
- sendSync: (text: string) => Promise<any | null>;
206
- abort: () => void;
207
- clear: () => void;
208
- }
209
-
210
- /**
211
- * Create the useWuAI hook for AI integration
212
- * @param React - React instance
213
- */
214
- export function createUseWuAI(React: any): (options?: UseWuAIOptions) => UseWuAIReturn;
215
-
216
- // ============================================================================
217
- // Utility Functions
218
- // ============================================================================
219
-
220
- /**
221
- * Get the Wu Framework instance
222
- */
223
- export function getWuInstance(): WuInstance | null;
224
-
225
- /**
226
- * Wait for Wu Framework to be available
227
- * @param timeout - Maximum time to wait in ms (default: 5000)
228
- */
229
- export function waitForWu(timeout?: number): Promise<WuInstance>;
230
-
231
- // ============================================================================
232
- // Main Export
233
- // ============================================================================
234
-
235
- export interface WuReactAdapter {
236
- register: typeof register;
237
- createWuSlot: typeof createWuSlot;
238
- createUseWuEvents: typeof createUseWuEvents;
239
- createUseWuStore: typeof createUseWuStore;
240
- createUseWuAI: typeof createUseWuAI;
241
- getWuInstance: typeof getWuInstance;
242
- waitForWu: typeof waitForWu;
243
- }
244
-
245
- export const wuReact: WuReactAdapter;
246
- export default wuReact;
1
+ /**
2
+ * Wu Framework React Adapter - TypeScript Definitions
3
+ */
4
+
5
+ import { ComponentType, ReactElement, CSSProperties, RefObject } from 'react';
6
+
7
+ // ============================================================================
8
+ // Core Types
9
+ // ============================================================================
10
+
11
+ export interface WuInstance {
12
+ init: (config: WuConfig) => Promise<void>;
13
+ mount: (appName: string, container: string) => Promise<void>;
14
+ unmount: (appName: string) => Promise<void>;
15
+ define: (appName: string, lifecycle: WuLifecycle) => void;
16
+ app: (name: string, config: WuAppConfig) => WuApp;
17
+ eventBus: WuEventBus;
18
+ store: WuStore;
19
+ }
20
+
21
+ export interface WuConfig {
22
+ apps: Array<{
23
+ name: string;
24
+ url: string;
25
+ strategy?: 'lazy' | 'eager' | 'preload' | 'idle';
26
+ }>;
27
+ }
28
+
29
+ export interface WuLifecycle {
30
+ mount: (container: HTMLElement) => void | Promise<void>;
31
+ unmount: (container?: HTMLElement) => void | Promise<void>;
32
+ }
33
+
34
+ export interface WuAppConfig {
35
+ url: string;
36
+ container: string;
37
+ autoInit?: boolean;
38
+ }
39
+
40
+ export interface WuApp {
41
+ mount: (container?: string) => Promise<void>;
42
+ unmount: () => Promise<void>;
43
+ remount: () => Promise<void>;
44
+ reload: () => Promise<void>;
45
+ destroy: () => Promise<void>;
46
+ isMounted: boolean;
47
+ info: WuAppInfo;
48
+ }
49
+
50
+ export interface WuAppInfo {
51
+ name: string;
52
+ url: string;
53
+ mounted: boolean;
54
+ status: 'stable' | 'refreshed' | 'unstable';
55
+ }
56
+
57
+ export interface WuEventBus {
58
+ emit: (event: string, data?: any, options?: EmitOptions) => void;
59
+ on: (event: string, callback: EventCallback) => () => void;
60
+ once: (event: string, callback: EventCallback) => () => void;
61
+ off: (event: string, callback?: EventCallback) => void;
62
+ }
63
+
64
+ export interface WuStore {
65
+ get: (path?: string) => any;
66
+ set: (path: string, value: any) => number;
67
+ on: (pattern: string, callback: StoreCallback) => () => void;
68
+ batch: (updates: Record<string, any>) => number[];
69
+ clear: () => void;
70
+ }
71
+
72
+ export type EventCallback = (event: WuEvent) => void;
73
+ export type StoreCallback = (change: { path: string; value: any }) => void;
74
+
75
+ export interface WuEvent {
76
+ name: string;
77
+ data: any;
78
+ timestamp: number;
79
+ source?: string;
80
+ }
81
+
82
+ export interface EmitOptions {
83
+ appName?: string;
84
+ timestamp?: number;
85
+ meta?: Record<string, any>;
86
+ }
87
+
88
+ // ============================================================================
89
+ // React Adapter Types
90
+ // ============================================================================
91
+
92
+ export interface RegisterOptions {
93
+ /** Wrap component in StrictMode (default: true) */
94
+ strictMode?: boolean;
95
+ /** Initial props for the component */
96
+ props?: Record<string, any>;
97
+ /** Callback after mounting */
98
+ onMount?: (container: HTMLElement) => void;
99
+ /** Callback before unmounting */
100
+ onUnmount?: (container: HTMLElement) => void;
101
+ /** Allow standalone execution (default: true) */
102
+ standalone?: boolean;
103
+ /** Selector for standalone mode (default: '#root') */
104
+ standaloneContainer?: string;
105
+ }
106
+
107
+ /**
108
+ * Register a React component as a microfrontend
109
+ */
110
+ export function register<P = {}>(
111
+ appName: string,
112
+ Component: ComponentType<P>,
113
+ options?: RegisterOptions
114
+ ): Promise<boolean>;
115
+
116
+ // ============================================================================
117
+ // WuSlot Component Types
118
+ // ============================================================================
119
+
120
+ export interface WuSlotProps {
121
+ /** Display name for the microfrontend */
122
+ name: string;
123
+ /** URL where the microfrontend is hosted */
124
+ url: string;
125
+ /** App name from wu.json (defaults to name if not provided) */
126
+ appName?: string;
127
+ /** Custom fallback while loading */
128
+ fallback?: ReactElement | null;
129
+ /** Callback when microfrontend loads successfully */
130
+ onLoad?: (info: { name: string; url: string }) => void;
131
+ /** Callback when loading fails */
132
+ onError?: (error: Error) => void;
133
+ /** Callback when microfrontend mounts */
134
+ onMount?: (info: { name: string; container: HTMLElement }) => void;
135
+ /** Callback when microfrontend unmounts */
136
+ onUnmount?: (info: { name: string }) => void;
137
+ /** Additional CSS class */
138
+ className?: string;
139
+ /** Inline styles */
140
+ style?: CSSProperties;
141
+ }
142
+
143
+ /**
144
+ * Create a WuSlot component for loading microfrontends
145
+ * @param React - React instance
146
+ */
147
+ export function createWuSlot(React: any): ComponentType<WuSlotProps>;
148
+
149
+ // ============================================================================
150
+ // Hooks Types
151
+ // ============================================================================
152
+
153
+ export interface UseWuEventsReturn {
154
+ /** Emit an event to the event bus */
155
+ emit: (event: string, data?: any, options?: EmitOptions) => void;
156
+ /** Subscribe to an event */
157
+ on: (event: string, callback: EventCallback) => () => void;
158
+ /** Subscribe to an event once */
159
+ once: (event: string, callback: EventCallback) => () => void;
160
+ }
161
+
162
+ /**
163
+ * Create the useWuEvents hook
164
+ * @param React - React instance
165
+ */
166
+ export function createUseWuEvents(React: any): () => UseWuEventsReturn;
167
+
168
+ export interface UseWuStoreReturn<T = any> {
169
+ /** Current state value (reactive) */
170
+ state: T | null;
171
+ /** Set a value in the store */
172
+ setState: (path: string, value: any) => void;
173
+ /** Get a value from the store */
174
+ getState: (path?: string) => any;
175
+ }
176
+
177
+ /**
178
+ * Create the useWuStore hook
179
+ * @param React - React instance
180
+ */
181
+ export function createUseWuStore(React: any): <T = any>(namespace?: string) => UseWuStoreReturn<T>;
182
+
183
+ // ============================================================================
184
+ // AI Hook Types (Paradigma C: IA como Director de Orquesta)
185
+ // ============================================================================
186
+
187
+ export interface AIMessage {
188
+ id: string;
189
+ role: 'user' | 'assistant' | 'action';
190
+ content: string;
191
+ result?: any;
192
+ timestamp: number;
193
+ }
194
+
195
+ export interface UseWuAIOptions {
196
+ namespace?: string;
197
+ onActionExecuted?: (data: { action: string; result: any }) => void;
198
+ }
199
+
200
+ export interface UseWuAIReturn {
201
+ messages: AIMessage[];
202
+ isStreaming: boolean;
203
+ error: string | null;
204
+ send: (text: string) => Promise<void>;
205
+ sendSync: (text: string) => Promise<any | null>;
206
+ abort: () => void;
207
+ clear: () => void;
208
+ }
209
+
210
+ /**
211
+ * Create the useWuAI hook for AI integration
212
+ * @param React - React instance
213
+ */
214
+ export function createUseWuAI(React: any): (options?: UseWuAIOptions) => UseWuAIReturn;
215
+
216
+ // ============================================================================
217
+ // Utility Functions
218
+ // ============================================================================
219
+
220
+ /**
221
+ * Get the Wu Framework instance
222
+ */
223
+ export function getWuInstance(): WuInstance | null;
224
+
225
+ /**
226
+ * Wait for Wu Framework to be available
227
+ * @param timeout - Maximum time to wait in ms (default: 5000)
228
+ */
229
+ export function waitForWu(timeout?: number): Promise<WuInstance>;
230
+
231
+ // ============================================================================
232
+ // Main Export
233
+ // ============================================================================
234
+
235
+ export interface WuReactAdapter {
236
+ register: typeof register;
237
+ createWuSlot: typeof createWuSlot;
238
+ createUseWuEvents: typeof createUseWuEvents;
239
+ createUseWuStore: typeof createUseWuStore;
240
+ createUseWuAI: typeof createUseWuAI;
241
+ getWuInstance: typeof getWuInstance;
242
+ waitForWu: typeof waitForWu;
243
+ }
244
+
245
+ export const wuReact: WuReactAdapter;
246
+ export default wuReact;