wu-framework 2.1.0 → 2.1.2
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.
- package/LICENSE +39 -39
- package/README.md +570 -570
- package/dist/adapters/angular/index.d.ts +154 -154
- package/dist/adapters/angular/index.js.map +1 -1
- package/dist/adapters/angular.d.ts +3 -3
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/lit/index.d.ts +120 -120
- package/dist/adapters/lit/index.js.map +1 -1
- package/dist/adapters/lit.d.ts +3 -3
- package/dist/adapters/preact/index.d.ts +108 -108
- package/dist/adapters/preact/index.js.map +1 -1
- package/dist/adapters/preact.d.ts +3 -3
- package/dist/adapters/qwik/index.js +1 -1
- package/dist/adapters/qwik/index.js.map +1 -1
- package/dist/adapters/react/index.d.ts +246 -246
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/react.d.ts +3 -3
- package/dist/adapters/shared.js.map +1 -1
- package/dist/adapters/solid/index.d.ts +101 -101
- package/dist/adapters/solid/index.js.map +1 -1
- package/dist/adapters/solid.d.ts +3 -3
- package/dist/adapters/svelte/index.d.ts +166 -166
- package/dist/adapters/svelte/index.js.map +1 -1
- package/dist/adapters/svelte.d.ts +3 -3
- package/dist/adapters/vanilla/index.d.ts +179 -179
- package/dist/adapters/vanilla/index.js.map +1 -1
- package/dist/adapters/vanilla.d.ts +3 -3
- package/dist/adapters/vue/index.d.ts +299 -299
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/adapters/vue.d.ts +3 -3
- package/dist/ai/wu-ai.js.map +1 -1
- package/dist/core/wu-html-parser.js +2 -0
- package/dist/core/wu-html-parser.js.map +1 -0
- package/dist/core/wu-iframe-sandbox.js +2 -0
- package/dist/core/wu-iframe-sandbox.js.map +1 -0
- package/dist/core/wu-loader.js +2 -0
- package/dist/core/wu-loader.js.map +1 -0
- package/dist/core/wu-mcp-bridge.js.map +1 -1
- package/dist/core/wu-script-executor.js +2 -0
- package/dist/core/wu-script-executor.js.map +1 -0
- package/dist/wu-ai-browser-primitives-BDKXJlwc.js.map +1 -1
- package/dist/wu-framework.cjs.js +2 -2
- package/dist/wu-framework.cjs.js.map +1 -1
- package/dist/wu-framework.dev.js +8697 -9142
- package/dist/wu-framework.dev.js.map +1 -1
- package/dist/wu-framework.esm.js +2 -2
- package/dist/wu-framework.esm.js.map +1 -1
- package/dist/wu-framework.umd.js +2 -2
- package/dist/wu-framework.umd.js.map +1 -1
- package/dist/wu-logger-fJfUHBGA.js.map +1 -1
- package/integrations/astro/README.md +127 -127
- package/integrations/astro/WuApp.astro +63 -63
- package/integrations/astro/WuShell.astro +39 -39
- package/integrations/astro/index.js +68 -68
- package/integrations/astro/package.json +38 -38
- package/integrations/astro/types.d.ts +53 -53
- package/package.json +218 -218
- package/dist/wu-html-parser.js +0 -2
- package/dist/wu-html-parser.js.map +0 -1
- package/dist/wu-iframe-sandbox.js +0 -2
- package/dist/wu-iframe-sandbox.js.map +0 -1
- package/dist/wu-script-executor.js +0 -2
- package/dist/wu-script-executor.js.map +0 -1
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 🚀 WU-FRAMEWORK LIT ADAPTER - TypeScript Declarations
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { WuCore } from '../core/wu-core';
|
|
6
|
-
|
|
7
|
-
// Lit types (generics to avoid hard dependency)
|
|
8
|
-
type LitElement = any;
|
|
9
|
-
type TemplateResult = any;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Opciones de registro Lit
|
|
13
|
-
*/
|
|
14
|
-
export interface LitRegisterOptions {
|
|
15
|
-
/** Nombre del custom element (auto-generado si no se provee) */
|
|
16
|
-
tagName?: string;
|
|
17
|
-
/** Propiedades iniciales */
|
|
18
|
-
properties?: Record<string, any>;
|
|
19
|
-
/** Callback después de montar */
|
|
20
|
-
onMount?: (container: HTMLElement, element: HTMLElement) => void;
|
|
21
|
-
/** Callback antes de desmontar */
|
|
22
|
-
onUnmount?: (container: HTMLElement, element: HTMLElement) => void;
|
|
23
|
-
/** Permitir ejecución standalone */
|
|
24
|
-
standalone?: boolean;
|
|
25
|
-
/** Selector para modo standalone */
|
|
26
|
-
standaloneContainer?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Configuración para crear elemento simple
|
|
31
|
-
*/
|
|
32
|
-
export interface SimpleElementConfig {
|
|
33
|
-
/** Nombre del custom element */
|
|
34
|
-
name: string;
|
|
35
|
-
/** Template HTML */
|
|
36
|
-
template: string | ((element: HTMLElement) => string);
|
|
37
|
-
/** Estilos CSS */
|
|
38
|
-
styles?: string;
|
|
39
|
-
/** Usar Shadow DOM */
|
|
40
|
-
shadow?: boolean;
|
|
41
|
-
/** Atributos observados */
|
|
42
|
-
observedAttributes?: string[];
|
|
43
|
-
/** Callback cuando se conecta */
|
|
44
|
-
connectedCallback?: (this: HTMLElement) => void;
|
|
45
|
-
/** Callback cuando se desconecta */
|
|
46
|
-
disconnectedCallback?: (this: HTMLElement) => void;
|
|
47
|
-
/** Callback cuando cambia un atributo */
|
|
48
|
-
attributeChangedCallback?: (this: HTMLElement, name: string, oldVal: string, newVal: string) => void;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Clase WuSlot Element
|
|
53
|
-
*/
|
|
54
|
-
export interface WuSlotElementClass {
|
|
55
|
-
new(): HTMLElement & {
|
|
56
|
-
name: string;
|
|
57
|
-
url: string;
|
|
58
|
-
appName: string | null;
|
|
59
|
-
fallbackText: string | null;
|
|
60
|
-
loading: boolean;
|
|
61
|
-
error: string | null;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Tipo para el Mixin de Wu
|
|
67
|
-
*/
|
|
68
|
-
export type WuMixinResult<T extends new (...args: any[]) => any> = T & {
|
|
69
|
-
new (...args: any[]): InstanceType<T> & {
|
|
70
|
-
readonly wu: WuCore | null;
|
|
71
|
-
wuEmit(event: string, data?: any, options?: any): void;
|
|
72
|
-
wuOn(event: string, callback: (data: any) => void): () => void;
|
|
73
|
-
wuOnce(event: string, callback: (data: any) => void): () => void;
|
|
74
|
-
wuGetState(path?: string): any;
|
|
75
|
-
wuSetState(path: string, value: any): void;
|
|
76
|
-
wuOnStateChange(pattern: string, callback: (value: any) => void): () => void;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export function register(
|
|
81
|
-
appName: string,
|
|
82
|
-
ElementClass: CustomElementConstructor,
|
|
83
|
-
options?: LitRegisterOptions
|
|
84
|
-
): Promise<boolean>;
|
|
85
|
-
|
|
86
|
-
export function registerWebComponent(
|
|
87
|
-
appName: string,
|
|
88
|
-
ElementClass: CustomElementConstructor,
|
|
89
|
-
options?: LitRegisterOptions
|
|
90
|
-
): Promise<boolean>;
|
|
91
|
-
|
|
92
|
-
export function createWuSlotElement(
|
|
93
|
-
LitElement: any,
|
|
94
|
-
html: (strings: TemplateStringsArray, ...values: any[]) => TemplateResult,
|
|
95
|
-
css?: (strings: TemplateStringsArray, ...values: any[]) => any
|
|
96
|
-
): WuSlotElementClass;
|
|
97
|
-
|
|
98
|
-
export function WuMixin<T extends new (...args: any[]) => any>(Base: T): WuMixinResult<T>;
|
|
99
|
-
|
|
100
|
-
export function wuProperty(storePath: string): PropertyDecorator;
|
|
101
|
-
|
|
102
|
-
export function createSimpleElement(config: SimpleElementConfig): CustomElementConstructor;
|
|
103
|
-
|
|
104
|
-
export function getWuInstance(): WuCore | null;
|
|
105
|
-
|
|
106
|
-
export function waitForWu(timeout?: number): Promise<WuCore>;
|
|
107
|
-
|
|
108
|
-
export interface WuLitAdapter {
|
|
109
|
-
register: typeof register;
|
|
110
|
-
registerWebComponent: typeof registerWebComponent;
|
|
111
|
-
createWuSlotElement: typeof createWuSlotElement;
|
|
112
|
-
WuMixin: typeof WuMixin;
|
|
113
|
-
wuProperty: typeof wuProperty;
|
|
114
|
-
createSimpleElement: typeof createSimpleElement;
|
|
115
|
-
getWuInstance: typeof getWuInstance;
|
|
116
|
-
waitForWu: typeof waitForWu;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export const wuLit: WuLitAdapter;
|
|
120
|
-
export default wuLit;
|
|
1
|
+
/**
|
|
2
|
+
* 🚀 WU-FRAMEWORK LIT ADAPTER - TypeScript Declarations
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { WuCore } from '../core/wu-core';
|
|
6
|
+
|
|
7
|
+
// Lit types (generics to avoid hard dependency)
|
|
8
|
+
type LitElement = any;
|
|
9
|
+
type TemplateResult = any;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Opciones de registro Lit
|
|
13
|
+
*/
|
|
14
|
+
export interface LitRegisterOptions {
|
|
15
|
+
/** Nombre del custom element (auto-generado si no se provee) */
|
|
16
|
+
tagName?: string;
|
|
17
|
+
/** Propiedades iniciales */
|
|
18
|
+
properties?: Record<string, any>;
|
|
19
|
+
/** Callback después de montar */
|
|
20
|
+
onMount?: (container: HTMLElement, element: HTMLElement) => void;
|
|
21
|
+
/** Callback antes de desmontar */
|
|
22
|
+
onUnmount?: (container: HTMLElement, element: HTMLElement) => void;
|
|
23
|
+
/** Permitir ejecución standalone */
|
|
24
|
+
standalone?: boolean;
|
|
25
|
+
/** Selector para modo standalone */
|
|
26
|
+
standaloneContainer?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Configuración para crear elemento simple
|
|
31
|
+
*/
|
|
32
|
+
export interface SimpleElementConfig {
|
|
33
|
+
/** Nombre del custom element */
|
|
34
|
+
name: string;
|
|
35
|
+
/** Template HTML */
|
|
36
|
+
template: string | ((element: HTMLElement) => string);
|
|
37
|
+
/** Estilos CSS */
|
|
38
|
+
styles?: string;
|
|
39
|
+
/** Usar Shadow DOM */
|
|
40
|
+
shadow?: boolean;
|
|
41
|
+
/** Atributos observados */
|
|
42
|
+
observedAttributes?: string[];
|
|
43
|
+
/** Callback cuando se conecta */
|
|
44
|
+
connectedCallback?: (this: HTMLElement) => void;
|
|
45
|
+
/** Callback cuando se desconecta */
|
|
46
|
+
disconnectedCallback?: (this: HTMLElement) => void;
|
|
47
|
+
/** Callback cuando cambia un atributo */
|
|
48
|
+
attributeChangedCallback?: (this: HTMLElement, name: string, oldVal: string, newVal: string) => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Clase WuSlot Element
|
|
53
|
+
*/
|
|
54
|
+
export interface WuSlotElementClass {
|
|
55
|
+
new(): HTMLElement & {
|
|
56
|
+
name: string;
|
|
57
|
+
url: string;
|
|
58
|
+
appName: string | null;
|
|
59
|
+
fallbackText: string | null;
|
|
60
|
+
loading: boolean;
|
|
61
|
+
error: string | null;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Tipo para el Mixin de Wu
|
|
67
|
+
*/
|
|
68
|
+
export type WuMixinResult<T extends new (...args: any[]) => any> = T & {
|
|
69
|
+
new (...args: any[]): InstanceType<T> & {
|
|
70
|
+
readonly wu: WuCore | null;
|
|
71
|
+
wuEmit(event: string, data?: any, options?: any): void;
|
|
72
|
+
wuOn(event: string, callback: (data: any) => void): () => void;
|
|
73
|
+
wuOnce(event: string, callback: (data: any) => void): () => void;
|
|
74
|
+
wuGetState(path?: string): any;
|
|
75
|
+
wuSetState(path: string, value: any): void;
|
|
76
|
+
wuOnStateChange(pattern: string, callback: (value: any) => void): () => void;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export function register(
|
|
81
|
+
appName: string,
|
|
82
|
+
ElementClass: CustomElementConstructor,
|
|
83
|
+
options?: LitRegisterOptions
|
|
84
|
+
): Promise<boolean>;
|
|
85
|
+
|
|
86
|
+
export function registerWebComponent(
|
|
87
|
+
appName: string,
|
|
88
|
+
ElementClass: CustomElementConstructor,
|
|
89
|
+
options?: LitRegisterOptions
|
|
90
|
+
): Promise<boolean>;
|
|
91
|
+
|
|
92
|
+
export function createWuSlotElement(
|
|
93
|
+
LitElement: any,
|
|
94
|
+
html: (strings: TemplateStringsArray, ...values: any[]) => TemplateResult,
|
|
95
|
+
css?: (strings: TemplateStringsArray, ...values: any[]) => any
|
|
96
|
+
): WuSlotElementClass;
|
|
97
|
+
|
|
98
|
+
export function WuMixin<T extends new (...args: any[]) => any>(Base: T): WuMixinResult<T>;
|
|
99
|
+
|
|
100
|
+
export function wuProperty(storePath: string): PropertyDecorator;
|
|
101
|
+
|
|
102
|
+
export function createSimpleElement(config: SimpleElementConfig): CustomElementConstructor;
|
|
103
|
+
|
|
104
|
+
export function getWuInstance(): WuCore | null;
|
|
105
|
+
|
|
106
|
+
export function waitForWu(timeout?: number): Promise<WuCore>;
|
|
107
|
+
|
|
108
|
+
export interface WuLitAdapter {
|
|
109
|
+
register: typeof register;
|
|
110
|
+
registerWebComponent: typeof registerWebComponent;
|
|
111
|
+
createWuSlotElement: typeof createWuSlotElement;
|
|
112
|
+
WuMixin: typeof WuMixin;
|
|
113
|
+
wuProperty: typeof wuProperty;
|
|
114
|
+
createSimpleElement: typeof createSimpleElement;
|
|
115
|
+
getWuInstance: typeof getWuInstance;
|
|
116
|
+
waitForWu: typeof waitForWu;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const wuLit: WuLitAdapter;
|
|
120
|
+
export default wuLit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/adapters/lit/ai.js","../../../src/adapters/lit/index.js"],"sourcesContent":["/**\r\n * WU-FRAMEWORK LIT AI INTEGRATION\r\n */\r\nfunction getWuInstance() {\r\n if (typeof window === 'undefined') return null;\r\n return window.wu || window.parent?.wu || window.top?.wu || null;\r\n}\r\n\r\nexport function WuAIMixin(Base) {\r\n return class extends Base {\r\n constructor() { super(); this._wuAINamespace = 'default'; }\r\n get wuAI() { return getWuInstance()?.ai || null; }\r\n async wuAISend(text, options = {}) {\r\n const ai = this.wuAI;\r\n if (!ai) { console.warn('[WuAIMixin] wu.ai not available'); return null; }\r\n return ai.send(text, { namespace: this._wuAINamespace, ...options });\r\n }\r\n wuAISetNamespace(ns) { this._wuAINamespace = ns; }\r\n };\r\n}\r\n","/**\r\n * 🚀 WU-FRAMEWORK LIT ADAPTER\r\n *\r\n * Simplifica la integración de Lit (Web Components) con Wu Framework.\r\n * Aprovecha los Web Components nativos con Shadow DOM incluido.\r\n *\r\n * @example\r\n * // Microfrontend (main.js)\r\n * import { wuLit } from 'wu-framework/adapters/lit';\r\n * import { MyApp } from './my-app';\r\n *\r\n * wuLit.register('my-app', MyApp);\r\n *\r\n * @example\r\n * // Usando LitElement\r\n * import { LitElement, html, css } from 'lit';\r\n *\r\n * class MyApp extends LitElement {\r\n * static styles = css`:host { display: block; }`;\r\n *\r\n * render() {\r\n * return html`<h1>Hello from Lit!</h1>`;\r\n * }\r\n * }\r\n *\r\n * wuLit.register('my-app', MyApp);\r\n */\r\n\r\n// Estado global del adapter\r\nconst adapterState = {\r\n apps: new Map(),\r\n elements: new Map(),\r\n lit: null,\r\n initialized: false\r\n};\r\n\r\n/**\r\n * Obtiene la instancia de Wu Framework\r\n */\r\nfunction getWuInstance() {\r\n if (typeof window === 'undefined') return null;\r\n\r\n return window.wu\r\n || window.parent?.wu\r\n || window.top?.wu\r\n || null;\r\n}\r\n\r\n/**\r\n * Espera a que Wu Framework esté disponible\r\n */\r\nfunction waitForWu(timeout = 5000) {\r\n return new Promise((resolve, reject) => {\r\n const wu = getWuInstance();\r\n if (wu) {\r\n resolve(wu);\r\n return;\r\n }\r\n\r\n const startTime = Date.now();\r\n\r\n const handleWuReady = () => {\r\n cleanup();\r\n resolve(getWuInstance());\r\n };\r\n\r\n window.addEventListener('wu:ready', handleWuReady);\r\n window.addEventListener('wu:app:ready', handleWuReady);\r\n\r\n const checkInterval = setInterval(() => {\r\n const wu = getWuInstance();\r\n if (wu) {\r\n cleanup();\r\n resolve(wu);\r\n return;\r\n }\r\n\r\n if (Date.now() - startTime > timeout) {\r\n cleanup();\r\n reject(new Error(`Wu Framework not found after ${timeout}ms`));\r\n }\r\n }, 200);\r\n\r\n function cleanup() {\r\n clearInterval(checkInterval);\r\n window.removeEventListener('wu:ready', handleWuReady);\r\n window.removeEventListener('wu:app:ready', handleWuReady);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Genera un nombre de tag válido para Custom Elements\r\n */\r\nfunction generateTagName(appName) {\r\n // Custom elements deben tener un guión\r\n if (appName.includes('-')) {\r\n return `wu-${appName}`;\r\n }\r\n return `wu-app-${appName}`;\r\n}\r\n\r\n/**\r\n * Registra un LitElement como microfrontend\r\n *\r\n * @param {string} appName - Nombre único del microfrontend\r\n * @param {typeof LitElement} ElementClass - Clase que extiende LitElement\r\n * @param {Object} options - Opciones adicionales\r\n * @param {string} options.tagName - Nombre del custom element (auto-generado si no se provee)\r\n * @param {Object} options.properties - Propiedades iniciales\r\n * @param {Function} options.onMount - Callback después de montar\r\n * @param {Function} options.onUnmount - Callback antes de desmontar\r\n * @param {boolean} options.standalone - Permitir ejecución standalone (default: true)\r\n * @param {string} options.standaloneContainer - Selector para modo standalone (default: '#root')\r\n *\r\n * @example\r\n * import { LitElement, html } from 'lit';\r\n *\r\n * class HeaderApp extends LitElement {\r\n * render() {\r\n * return html`<header><h1>My Header</h1></header>`;\r\n * }\r\n * }\r\n *\r\n * wuLit.register('header', HeaderApp);\r\n */\r\nasync function register(appName, ElementClass, options = {}) {\r\n const {\r\n tagName = null,\r\n properties = {},\r\n onMount = null,\r\n onUnmount = null,\r\n standalone = true,\r\n standaloneContainer = '#root'\r\n } = options;\r\n\r\n // Generar nombre de tag\r\n const customTagName = tagName || generateTagName(appName);\r\n\r\n // Registrar el Custom Element si no existe\r\n if (!customElements.get(customTagName)) {\r\n try {\r\n customElements.define(customTagName, ElementClass);\r\n console.log(`[WuLit] Custom element <${customTagName}> defined`);\r\n } catch (error) {\r\n console.error(`[WuLit] Failed to define custom element:`, error);\r\n throw error;\r\n }\r\n }\r\n\r\n // Guardar referencia de la clase\r\n adapterState.elements.set(appName, {\r\n ElementClass,\r\n tagName: customTagName\r\n });\r\n\r\n // Función de mount\r\n const mountApp = (container) => {\r\n if (!container) {\r\n console.error(`[WuLit] Mount failed for ${appName}: container is null`);\r\n return;\r\n }\r\n\r\n // Evitar doble mount\r\n if (adapterState.apps.has(appName)) {\r\n console.warn(`[WuLit] ${appName} already mounted, unmounting first`);\r\n unmountApp();\r\n }\r\n\r\n try {\r\n // Limpiar container\r\n container.innerHTML = '';\r\n\r\n // Crear elemento\r\n const element = document.createElement(customTagName);\r\n\r\n // Aplicar propiedades\r\n Object.entries(properties).forEach(([key, value]) => {\r\n element[key] = value;\r\n });\r\n\r\n // Inyectar información de Wu\r\n element.wuAppName = appName;\r\n element.wuInstance = getWuInstance();\r\n\r\n // Agregar al container\r\n container.appendChild(element);\r\n\r\n // Guardar referencia\r\n adapterState.apps.set(appName, {\r\n element,\r\n container,\r\n tagName: customTagName\r\n });\r\n\r\n console.log(`[WuLit] ✅ ${appName} (<${customTagName}>) mounted successfully`);\r\n\r\n if (onMount) {\r\n onMount(container, element);\r\n }\r\n } catch (error) {\r\n console.error(`[WuLit] Mount error for ${appName}:`, error);\r\n throw error;\r\n }\r\n };\r\n\r\n // Función de unmount\r\n const unmountApp = (container) => {\r\n const appData = adapterState.apps.get(appName);\r\n\r\n if (appData) {\r\n try {\r\n if (onUnmount) {\r\n onUnmount(appData.container, appData.element);\r\n }\r\n\r\n // Remover elemento\r\n if (appData.element && appData.element.parentNode) {\r\n appData.element.remove();\r\n }\r\n\r\n // Limpiar container\r\n appData.container.innerHTML = '';\r\n\r\n adapterState.apps.delete(appName);\r\n\r\n console.log(`[WuLit] ✅ ${appName} unmounted successfully`);\r\n } catch (error) {\r\n console.error(`[WuLit] Unmount error for ${appName}:`, error);\r\n }\r\n }\r\n\r\n if (container) {\r\n container.innerHTML = '';\r\n }\r\n };\r\n\r\n // Intentar registrar con Wu Framework\r\n try {\r\n const wu = await waitForWu(3000);\r\n\r\n wu.define(appName, {\r\n mount: mountApp,\r\n unmount: unmountApp\r\n });\r\n\r\n console.log(`[WuLit] ✅ ${appName} registered with Wu Framework`);\r\n return true;\r\n\r\n } catch (error) {\r\n console.warn(`[WuLit] Wu Framework not available for ${appName}`);\r\n\r\n if (standalone) {\r\n const containerElement = document.querySelector(standaloneContainer);\r\n\r\n if (containerElement) {\r\n console.log(`[WuLit] Running ${appName} in standalone mode`);\r\n mountApp(containerElement);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Registra un Web Component vanilla (sin Lit) como microfrontend\r\n *\r\n * @param {string} appName - Nombre del microfrontend\r\n * @param {typeof HTMLElement} ElementClass - Clase que extiende HTMLElement\r\n * @param {Object} options - Opciones\r\n *\r\n * @example\r\n * class MyWebComponent extends HTMLElement {\r\n * connectedCallback() {\r\n * this.attachShadow({ mode: 'open' });\r\n * this.shadowRoot.innerHTML = '<h1>Hello!</h1>';\r\n * }\r\n * }\r\n *\r\n * wuLit.registerWebComponent('my-component', MyWebComponent);\r\n */\r\nasync function registerWebComponent(appName, ElementClass, options = {}) {\r\n // Usar el mismo registro pero para HTMLElement vanilla\r\n return register(appName, ElementClass, options);\r\n}\r\n\r\n/**\r\n * Crea un LitElement wrapper que carga un microfrontend\r\n *\r\n * @example\r\n * import { html, LitElement } from 'lit';\r\n * import { createWuSlotElement } from 'wu-framework/adapters/lit';\r\n *\r\n * const WuSlot = createWuSlotElement(LitElement, html);\r\n *\r\n * // Uso en otro componente\r\n * render() {\r\n * return html`<wu-slot name=\"header\" url=\"http://localhost:3001\"></wu-slot>`;\r\n * }\r\n */\r\nfunction createWuSlotElement(LitElement, html, css) {\r\n class WuSlotElement extends LitElement {\r\n static properties = {\r\n name: { type: String },\r\n url: { type: String },\r\n appName: { type: String, attribute: 'app-name' },\r\n fallbackText: { type: String, attribute: 'fallback-text' },\r\n loading: { type: Boolean, state: true },\r\n error: { type: String, state: true }\r\n };\r\n\r\n static styles = css ? css`\r\n :host {\r\n display: block;\r\n min-height: 100px;\r\n position: relative;\r\n }\r\n\r\n .wu-slot-loading {\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n padding: 2rem;\r\n color: #666;\r\n }\r\n\r\n .wu-slot-error {\r\n padding: 1rem;\r\n border: 1px solid #f5c6cb;\r\n border-radius: 4px;\r\n background: #f8d7da;\r\n color: #721c24;\r\n }\r\n\r\n .wu-slot-error strong {\r\n display: block;\r\n margin-bottom: 0.5rem;\r\n }\r\n\r\n .wu-slot-content {\r\n width: 100%;\r\n height: 100%;\r\n }\r\n ` : [];\r\n\r\n constructor() {\r\n super();\r\n this.name = '';\r\n this.url = '';\r\n this.appName = null;\r\n this.fallbackText = null;\r\n this.loading = true;\r\n this.error = null;\r\n this._appInstance = null;\r\n }\r\n\r\n get actualAppName() {\r\n return this.appName || this.name;\r\n }\r\n\r\n async connectedCallback() {\r\n super.connectedCallback();\r\n await this.mountMicrofrontend();\r\n }\r\n\r\n disconnectedCallback() {\r\n super.disconnectedCallback();\r\n this.unmountMicrofrontend();\r\n }\r\n\r\n async mountMicrofrontend() {\r\n try {\r\n this.loading = true;\r\n this.error = null;\r\n\r\n const wu = getWuInstance();\r\n if (!wu) {\r\n throw new Error('Wu Framework not initialized');\r\n }\r\n\r\n // Esperar a que el componente se renderice\r\n await this.updateComplete;\r\n\r\n const contentSlot = this.shadowRoot.querySelector('.wu-slot-content');\r\n if (!contentSlot) return;\r\n\r\n const containerId = `wu-slot-${this.actualAppName}-${Date.now()}`;\r\n const innerContainer = document.createElement('div');\r\n innerContainer.id = containerId;\r\n innerContainer.style.cssText = 'width: 100%; height: 100%;';\r\n\r\n contentSlot.innerHTML = '';\r\n contentSlot.appendChild(innerContainer);\r\n\r\n const app = wu.app(this.actualAppName, {\r\n url: this.url,\r\n container: `#${containerId}`,\r\n autoInit: true\r\n });\r\n\r\n this._appInstance = app;\r\n await app.mount();\r\n\r\n this.loading = false;\r\n this.dispatchEvent(new CustomEvent('wu-load', {\r\n detail: { name: this.actualAppName, url: this.url },\r\n bubbles: true,\r\n composed: true\r\n }));\r\n\r\n } catch (err) {\r\n console.error(`[WuSlot] Error loading ${this.actualAppName}:`, err);\r\n this.error = err.message || 'Failed to load microfrontend';\r\n this.loading = false;\r\n this.dispatchEvent(new CustomEvent('wu-error', {\r\n detail: err,\r\n bubbles: true,\r\n composed: true\r\n }));\r\n }\r\n }\r\n\r\n async unmountMicrofrontend() {\r\n if (this._appInstance) {\r\n this.dispatchEvent(new CustomEvent('wu-unmount', {\r\n detail: { name: this.actualAppName },\r\n bubbles: true,\r\n composed: true\r\n }));\r\n\r\n try {\r\n await this._appInstance.unmount();\r\n } catch (e) {}\r\n\r\n this._appInstance = null;\r\n }\r\n }\r\n\r\n render() {\r\n if (this.error) {\r\n return html`\r\n <div class=\"wu-slot-error\">\r\n <strong>Error loading ${this.name}</strong>\r\n <span>${this.error}</span>\r\n </div>\r\n `;\r\n }\r\n\r\n if (this.loading) {\r\n return html`\r\n <div class=\"wu-slot-loading\">\r\n ${this.fallbackText || `Loading ${this.name}...`}\r\n </div>\r\n <div class=\"wu-slot-content\"></div>\r\n `;\r\n }\r\n\r\n return html`<div class=\"wu-slot-content\"></div>`;\r\n }\r\n }\r\n\r\n // Registrar el elemento\r\n if (!customElements.get('wu-slot')) {\r\n customElements.define('wu-slot', WuSlotElement);\r\n }\r\n\r\n return WuSlotElement;\r\n}\r\n\r\n/**\r\n * Mixin para agregar capacidades de Wu a cualquier LitElement\r\n *\r\n * @example\r\n * import { LitElement } from 'lit';\r\n * import { WuMixin } from 'wu-framework/adapters/lit';\r\n *\r\n * class MyElement extends WuMixin(LitElement) {\r\n * connectedCallback() {\r\n * super.connectedCallback();\r\n *\r\n * // Usar eventos de Wu\r\n * this.wuOn('user:login', (data) => {\r\n * console.log('User logged in:', data);\r\n * });\r\n * }\r\n *\r\n * handleClick() {\r\n * this.wuEmit('button:clicked', { id: this.id });\r\n * }\r\n * }\r\n */\r\nfunction WuMixin(Base) {\r\n return class extends Base {\r\n constructor() {\r\n super();\r\n this._wuSubscriptions = [];\r\n }\r\n\r\n get wu() {\r\n return getWuInstance();\r\n }\r\n\r\n // Event Bus methods\r\n wuEmit(event, data, options) {\r\n const wu = this.wu;\r\n if (wu?.eventBus) {\r\n wu.eventBus.emit(event, data, options);\r\n }\r\n }\r\n\r\n wuOn(event, callback) {\r\n const wu = this.wu;\r\n if (wu?.eventBus) {\r\n const unsubscribe = wu.eventBus.on(event, callback);\r\n this._wuSubscriptions.push(unsubscribe);\r\n return unsubscribe;\r\n }\r\n return () => {};\r\n }\r\n\r\n wuOnce(event, callback) {\r\n const wu = this.wu;\r\n if (wu?.eventBus) {\r\n return wu.eventBus.once(event, callback);\r\n }\r\n return () => {};\r\n }\r\n\r\n // Store methods\r\n wuGetState(path) {\r\n const wu = this.wu;\r\n return wu?.store?.get(path) || null;\r\n }\r\n\r\n wuSetState(path, value) {\r\n const wu = this.wu;\r\n if (wu?.store) {\r\n wu.store.set(path, value);\r\n }\r\n }\r\n\r\n wuOnStateChange(pattern, callback) {\r\n const wu = this.wu;\r\n if (wu?.store) {\r\n const unsubscribe = wu.store.on(pattern, callback);\r\n this._wuSubscriptions.push(unsubscribe);\r\n return unsubscribe;\r\n }\r\n return () => {};\r\n }\r\n\r\n // Cleanup\r\n disconnectedCallback() {\r\n super.disconnectedCallback();\r\n this._wuSubscriptions.forEach(unsub => unsub());\r\n this._wuSubscriptions = [];\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Decorador reactivo para propiedades conectadas al store de Wu\r\n *\r\n * @example\r\n * import { LitElement } from 'lit';\r\n * import { wuProperty } from 'wu-framework/adapters/lit';\r\n *\r\n * class MyElement extends LitElement {\r\n * @wuProperty('user.name')\r\n * userName;\r\n *\r\n * render() {\r\n * return html`<p>Hello, ${this.userName}</p>`;\r\n * }\r\n * }\r\n */\r\nfunction wuProperty(storePath) {\r\n return function(target, propertyKey) {\r\n const privateKey = `_wu_${propertyKey}`;\r\n let unsubscribe = null;\r\n\r\n Object.defineProperty(target, propertyKey, {\r\n get() {\r\n return this[privateKey];\r\n },\r\n set(value) {\r\n const wu = getWuInstance();\r\n if (wu?.store) {\r\n wu.store.set(storePath, value);\r\n }\r\n },\r\n configurable: true,\r\n enumerable: true\r\n });\r\n\r\n // Hook into connectedCallback\r\n const originalConnected = target.connectedCallback;\r\n target.connectedCallback = function() {\r\n if (originalConnected) originalConnected.call(this);\r\n\r\n const wu = getWuInstance();\r\n if (wu?.store) {\r\n // Set initial value\r\n this[privateKey] = wu.store.get(storePath);\r\n\r\n // Subscribe to changes\r\n unsubscribe = wu.store.on(storePath, (value) => {\r\n this[privateKey] = value;\r\n this.requestUpdate();\r\n });\r\n }\r\n };\r\n\r\n // Hook into disconnectedCallback\r\n const originalDisconnected = target.disconnectedCallback;\r\n target.disconnectedCallback = function() {\r\n if (originalDisconnected) originalDisconnected.call(this);\r\n if (unsubscribe) {\r\n unsubscribe();\r\n unsubscribe = null;\r\n }\r\n };\r\n };\r\n}\r\n\r\n/**\r\n * Helper para crear un Web Component simple sin Lit\r\n *\r\n * @example\r\n * const MyComponent = createSimpleElement({\r\n * name: 'my-component',\r\n * template: '<h1>Hello!</h1>',\r\n * styles: ':host { display: block; color: blue; }',\r\n * connectedCallback() {\r\n * console.log('Connected!');\r\n * }\r\n * });\r\n */\r\nfunction createSimpleElement(config) {\r\n const {\r\n name,\r\n template,\r\n styles = '',\r\n shadow = true,\r\n ...callbacks\r\n } = config;\r\n\r\n class SimpleElement extends HTMLElement {\r\n constructor() {\r\n super();\r\n if (shadow) {\r\n this.attachShadow({ mode: 'open' });\r\n }\r\n }\r\n\r\n connectedCallback() {\r\n const root = this.shadowRoot || this;\r\n\r\n if (styles) {\r\n const styleEl = document.createElement('style');\r\n styleEl.textContent = styles;\r\n root.appendChild(styleEl);\r\n }\r\n\r\n if (typeof template === 'function') {\r\n root.innerHTML += template(this);\r\n } else {\r\n root.innerHTML += template;\r\n }\r\n\r\n if (callbacks.connectedCallback) {\r\n callbacks.connectedCallback.call(this);\r\n }\r\n }\r\n\r\n disconnectedCallback() {\r\n if (callbacks.disconnectedCallback) {\r\n callbacks.disconnectedCallback.call(this);\r\n }\r\n }\r\n\r\n attributeChangedCallback(name, oldVal, newVal) {\r\n if (callbacks.attributeChangedCallback) {\r\n callbacks.attributeChangedCallback.call(this, name, oldVal, newVal);\r\n }\r\n }\r\n }\r\n\r\n if (callbacks.observedAttributes) {\r\n SimpleElement.observedAttributes = callbacks.observedAttributes;\r\n }\r\n\r\n if (!customElements.get(name)) {\r\n customElements.define(name, SimpleElement);\r\n }\r\n\r\n return SimpleElement;\r\n}\r\n\r\n// ============================================\r\n// AI INTEGRATION\r\n// ============================================\r\nimport { WuAIMixin } from './ai.js';\r\n\r\n// API pública del adapter\r\nexport const wuLit = {\r\n register,\r\n registerWebComponent,\r\n createWuSlotElement,\r\n WuMixin,\r\n WuAIMixin,\r\n wuProperty,\r\n createSimpleElement,\r\n getWuInstance,\r\n waitForWu\r\n};\r\n\r\nexport {\r\n register,\r\n registerWebComponent,\r\n createWuSlotElement,\r\n WuMixin,\r\n WuAIMixin,\r\n wuProperty,\r\n createSimpleElement,\r\n getWuInstance,\r\n waitForWu\r\n};\r\n\r\nexport default wuLit;\r\n"],"names":["WuAIMixin","Base","constructor","super","this","_wuAINamespace","wuAI","window","wu","parent","top","ai","wuAISend","text","options","send","namespace","console","warn","wuAISetNamespace","ns","adapterState","apps","Map","elements","lit","initialized","getWuInstance","waitForWu","timeout","Promise","resolve","reject","startTime","Date","now","handleWuReady","cleanup","addEventListener","checkInterval","setInterval","Error","clearInterval","removeEventListener","async","register","appName","ElementClass","tagName","properties","onMount","onUnmount","standalone","standaloneContainer","customTagName","includes","generateTagName","customElements","get","define","log","error","set","mountApp","container","has","unmountApp","innerHTML","element","document","createElement","Object","entries","forEach","key","value","wuAppName","wuInstance","appendChild","appData","parentNode","remove","delete","mount","unmount","containerElement","querySelector","registerWebComponent","createWuSlotElement","LitElement","html","css","WuSlotElement","static","name","type","String","url","attribute","fallbackText","loading","Boolean","state","_appInstance","actualAppName","connectedCallback","mountMicrofrontend","disconnectedCallback","unmountMicrofrontend","updateComplete","contentSlot","shadowRoot","containerId","innerContainer","id","style","cssText","app","autoInit","dispatchEvent","CustomEvent","detail","bubbles","composed","err","message","e","render","WuMixin","_wuSubscriptions","wuEmit","event","data","eventBus","emit","wuOn","callback","unsubscribe","on","push","wuOnce","once","wuGetState","path","store","wuSetState","wuOnStateChange","pattern","unsub","wuProperty","storePath","target","propertyKey","privateKey","defineProperty","configurable","enumerable","originalConnected","call","requestUpdate","originalDisconnected","createSimpleElement","config","template","styles","shadow","callbacks","SimpleElement","HTMLElement","attachShadow","mode","root","styleEl","textContent","attributeChangedCallback","oldVal","newVal","observedAttributes","wuLit"],"mappings":"AAQO,SAASA,EAAUC,GACxB,OAAO,cAAcA,EACnB,WAAAC,GAAgBC,QAASC,KAAKC,eAAiB,SAAW,CAC1D,QAAIC,GAAS,OAPO,oBAAXC,OAA+B,KACnCA,OAAOC,IAAMD,OAAOE,QAAQD,IAAMD,OAAOG,KAAKF,IAAM,OAMpBG,IAAM,IAAM,CACjD,cAAMC,CAASC,EAAMC,EAAU,IAC7B,MAAMH,EAAKP,KAAKE,KAChB,OAAKK,EACEA,EAAGI,KAAKF,EAAM,CAAEG,UAAWZ,KAAKC,kBAAmBS,KAD/CG,QAAQC,KAAK,mCAA2C,KAErE,CACA,gBAAAC,CAAiBC,GAAMhB,KAAKC,eAAiBe,CAAI,EAErD,CCUA,MAAMC,EAAe,CACnBC,KAAM,IAAIC,IACVC,SAAU,IAAID,IACdE,IAAK,KACLC,aAAa,GAMf,SAASC,IACP,MAAsB,oBAAXpB,OAA+B,KAEnCA,OAAOC,IACTD,OAAOE,QAAQD,IACfD,OAAOG,KAAKF,IACZ,IACP,CAKA,SAASoB,EAAUC,EAAU,KAC3B,OAAO,I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GAGhCb,EAAcjI,EAAGwI,MAAMN,GAAGY,EAAY3E,IACpCvE,KAAKqJ,GAAc9E,EACnBvE,KAAK2J,kBAGX,EAGA,MAAMC,EAAuBT,EAAO5C,qBACpC4C,EAAO5C,qBAAuB,WACxBqD,GAAsBA,EAAqBF,KAAK1J,MAChDqI,IACFA,IACAA,EAAc,KAElB,CACF,CACF,CAeA,SAASwB,EAAoBC,GAC3B,MAAMpE,KACJA,EAAIqE,SACJA,EAAQC,OACRA,EAAS,GAAEC,OACXA,GAAS,KACNC,GACDJ,EAEJ,MAAMK,UAAsBC,YAC1B,WAAAtK,GACEC,QACIkK,GACFjK,KAAKqK,aAAa,CAAEC,KAAM,QAE9B,CAEA,iBAAAjE,GACE,MAAMkE,EAAOvK,KAAK2G,YAAc3G,KAEhC,GAAIgK,EAAQ,CACV,MAAMQ,EAAUvG,SAASC,cAAc,SACvCsG,EAAQC,YAAcT,EACtBO,EAAK7F,YAAY8F,EACnB,CAGED,EAAKxG,WADiB,mBAAbgG,EACSA,EAAS/J,MAET+J,EAGhBG,EAAU7D,mBACZ6D,EAAU7D,kBAAkBqD,KAAK1J,KAErC,CAEA,oBAAAuG,GACM2D,EAAU3D,sBACZ2D,EAAU3D,qBAAqBmD,KAAK1J,KAExC,CAEA,wBAAA0K,CAAyBhF,EAAMiF,EAAQC,GACjCV,EAAUQ,0BACZR,EAAUQ,yBAAyBhB,KAAK1J,KAAM0F,EAAMiF,EAAQC,EAEhE,EAWF,OARIV,EAAUW,qBACZV,EAAcU,mBAAqBX,EAAUW,oBAG1CxH,eAAeC,IAAIoC,IACtBrC,eAAeE,OAAOmC,EAAMyE,GAGvBA,CACT,CAQY,MAACW,EAAQ,CACnBrI,WACA0C,uBACAC,sBACAwC,UACAhI,YACAqJ,aACAY,sBACAtI,gBACAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/adapters/lit/ai.js","../../../src/adapters/lit/index.js"],"sourcesContent":["/**\n * WU-FRAMEWORK LIT AI INTEGRATION\n */\nfunction getWuInstance() {\n if (typeof window === 'undefined') return null;\n return window.wu || window.parent?.wu || window.top?.wu || null;\n}\n\nexport function WuAIMixin(Base) {\n return class extends Base {\n constructor() { super(); this._wuAINamespace = 'default'; }\n get wuAI() { return getWuInstance()?.ai || null; }\n async wuAISend(text, options = {}) {\n const ai = this.wuAI;\n if (!ai) { console.warn('[WuAIMixin] wu.ai not available'); return null; }\n return ai.send(text, { namespace: this._wuAINamespace, ...options });\n }\n wuAISetNamespace(ns) { this._wuAINamespace = ns; }\n };\n}\n","/**\n * 🚀 WU-FRAMEWORK LIT ADAPTER\n *\n * Simplifica la integración de Lit (Web Components) con Wu Framework.\n * Aprovecha los Web Components nativos con Shadow DOM incluido.\n *\n * @example\n * // Microfrontend (main.js)\n * import { wuLit } from 'wu-framework/adapters/lit';\n * import { MyApp } from './my-app';\n *\n * wuLit.register('my-app', MyApp);\n *\n * @example\n * // Usando LitElement\n * import { LitElement, html, css } from 'lit';\n *\n * class MyApp extends LitElement {\n * static styles = css`:host { display: block; }`;\n *\n * render() {\n * return html`<h1>Hello from Lit!</h1>`;\n * }\n * }\n *\n * wuLit.register('my-app', MyApp);\n */\n\n// Estado global del adapter\nconst adapterState = {\n apps: new Map(),\n elements: new Map(),\n lit: null,\n initialized: false\n};\n\n/**\n * Obtiene la instancia de Wu Framework\n */\nfunction getWuInstance() {\n if (typeof window === 'undefined') return null;\n\n return window.wu\n || window.parent?.wu\n || window.top?.wu\n || null;\n}\n\n/**\n * Espera a que Wu Framework esté disponible\n */\nfunction waitForWu(timeout = 5000) {\n return new Promise((resolve, reject) => {\n const wu = getWuInstance();\n if (wu) {\n resolve(wu);\n return;\n }\n\n const startTime = Date.now();\n\n const handleWuReady = () => {\n cleanup();\n resolve(getWuInstance());\n };\n\n window.addEventListener('wu:ready', handleWuReady);\n window.addEventListener('wu:app:ready', handleWuReady);\n\n const checkInterval = setInterval(() => {\n const wu = getWuInstance();\n if (wu) {\n cleanup();\n resolve(wu);\n return;\n }\n\n if (Date.now() - startTime > timeout) {\n cleanup();\n reject(new Error(`Wu Framework not found after ${timeout}ms`));\n }\n }, 200);\n\n function cleanup() {\n clearInterval(checkInterval);\n window.removeEventListener('wu:ready', handleWuReady);\n window.removeEventListener('wu:app:ready', handleWuReady);\n }\n });\n}\n\n/**\n * Genera un nombre de tag válido para Custom Elements\n */\nfunction generateTagName(appName) {\n // Custom elements deben tener un guión\n if (appName.includes('-')) {\n return `wu-${appName}`;\n }\n return `wu-app-${appName}`;\n}\n\n/**\n * Registra un LitElement como microfrontend\n *\n * @param {string} appName - Nombre único del microfrontend\n * @param {typeof LitElement} ElementClass - Clase que extiende LitElement\n * @param {Object} options - Opciones adicionales\n * @param {string} options.tagName - Nombre del custom element (auto-generado si no se provee)\n * @param {Object} options.properties - Propiedades iniciales\n * @param {Function} options.onMount - Callback después de montar\n * @param {Function} options.onUnmount - Callback antes de desmontar\n * @param {boolean} options.standalone - Permitir ejecución standalone (default: true)\n * @param {string} options.standaloneContainer - Selector para modo standalone (default: '#root')\n *\n * @example\n * import { LitElement, html } from 'lit';\n *\n * class HeaderApp extends LitElement {\n * render() {\n * return html`<header><h1>My Header</h1></header>`;\n * }\n * }\n *\n * wuLit.register('header', HeaderApp);\n */\nasync function register(appName, ElementClass, options = {}) {\n const {\n tagName = null,\n properties = {},\n onMount = null,\n onUnmount = null,\n standalone = true,\n standaloneContainer = '#root'\n } = options;\n\n // Generar nombre de tag\n const customTagName = tagName || generateTagName(appName);\n\n // Registrar el Custom Element si no existe\n if (!customElements.get(customTagName)) {\n try {\n customElements.define(customTagName, ElementClass);\n console.log(`[WuLit] Custom element <${customTagName}> defined`);\n } catch (error) {\n console.error(`[WuLit] Failed to define custom element:`, error);\n throw error;\n }\n }\n\n // Guardar referencia de la clase\n adapterState.elements.set(appName, {\n ElementClass,\n tagName: customTagName\n });\n\n // Función de mount\n const mountApp = (container) => {\n if (!container) {\n console.error(`[WuLit] Mount failed for ${appName}: container is null`);\n return;\n }\n\n // Evitar doble mount\n if (adapterState.apps.has(appName)) {\n console.warn(`[WuLit] ${appName} already mounted, unmounting first`);\n unmountApp();\n }\n\n try {\n // Limpiar container\n container.innerHTML = '';\n\n // Crear elemento\n const element = document.createElement(customTagName);\n\n // Aplicar propiedades\n Object.entries(properties).forEach(([key, value]) => {\n element[key] = value;\n });\n\n // Inyectar información de Wu\n element.wuAppName = appName;\n element.wuInstance = getWuInstance();\n\n // Agregar al container\n container.appendChild(element);\n\n // Guardar referencia\n adapterState.apps.set(appName, {\n element,\n container,\n tagName: customTagName\n });\n\n console.log(`[WuLit] ✅ ${appName} (<${customTagName}>) mounted successfully`);\n\n if (onMount) {\n onMount(container, element);\n }\n } catch (error) {\n console.error(`[WuLit] Mount error for ${appName}:`, error);\n throw error;\n }\n };\n\n // Función de unmount\n const unmountApp = (container) => {\n const appData = adapterState.apps.get(appName);\n\n if (appData) {\n try {\n if (onUnmount) {\n onUnmount(appData.container, appData.element);\n }\n\n // Remover elemento\n if (appData.element && appData.element.parentNode) {\n appData.element.remove();\n }\n\n // Limpiar container\n appData.container.innerHTML = '';\n\n adapterState.apps.delete(appName);\n\n console.log(`[WuLit] ✅ ${appName} unmounted successfully`);\n } catch (error) {\n console.error(`[WuLit] Unmount error for ${appName}:`, error);\n }\n }\n\n if (container) {\n container.innerHTML = '';\n }\n };\n\n // Intentar registrar con Wu Framework\n try {\n const wu = await waitForWu(3000);\n\n wu.define(appName, {\n mount: mountApp,\n unmount: unmountApp\n });\n\n console.log(`[WuLit] ✅ ${appName} registered with Wu Framework`);\n return true;\n\n } catch (error) {\n console.warn(`[WuLit] Wu Framework not available for ${appName}`);\n\n if (standalone) {\n const containerElement = document.querySelector(standaloneContainer);\n\n if (containerElement) {\n console.log(`[WuLit] Running ${appName} in standalone mode`);\n mountApp(containerElement);\n return true;\n }\n }\n\n return false;\n }\n}\n\n/**\n * Registra un Web Component vanilla (sin Lit) como microfrontend\n *\n * @param {string} appName - Nombre del microfrontend\n * @param {typeof HTMLElement} ElementClass - Clase que extiende HTMLElement\n * @param {Object} options - Opciones\n *\n * @example\n * class MyWebComponent extends HTMLElement {\n * connectedCallback() {\n * this.attachShadow({ mode: 'open' });\n * this.shadowRoot.innerHTML = '<h1>Hello!</h1>';\n * }\n * }\n *\n * wuLit.registerWebComponent('my-component', MyWebComponent);\n */\nasync function registerWebComponent(appName, ElementClass, options = {}) {\n // Usar el mismo registro pero para HTMLElement vanilla\n return register(appName, ElementClass, options);\n}\n\n/**\n * Crea un LitElement wrapper que carga un microfrontend\n *\n * @example\n * import { html, LitElement } from 'lit';\n * import { createWuSlotElement } from 'wu-framework/adapters/lit';\n *\n * const WuSlot = createWuSlotElement(LitElement, html);\n *\n * // Uso en otro componente\n * render() {\n * return html`<wu-slot name=\"header\" url=\"http://localhost:3001\"></wu-slot>`;\n * }\n */\nfunction createWuSlotElement(LitElement, html, css) {\n class WuSlotElement extends LitElement {\n static properties = {\n name: { type: String },\n url: { type: String },\n appName: { type: String, attribute: 'app-name' },\n fallbackText: { type: String, attribute: 'fallback-text' },\n loading: { type: Boolean, state: true },\n error: { type: String, state: true }\n };\n\n static styles = css ? css`\n :host {\n display: block;\n min-height: 100px;\n position: relative;\n }\n\n .wu-slot-loading {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 2rem;\n color: #666;\n }\n\n .wu-slot-error {\n padding: 1rem;\n border: 1px solid #f5c6cb;\n border-radius: 4px;\n background: #f8d7da;\n color: #721c24;\n }\n\n .wu-slot-error strong {\n display: block;\n margin-bottom: 0.5rem;\n }\n\n .wu-slot-content {\n width: 100%;\n height: 100%;\n }\n ` : [];\n\n constructor() {\n super();\n this.name = '';\n this.url = '';\n this.appName = null;\n this.fallbackText = null;\n this.loading = true;\n this.error = null;\n this._appInstance = null;\n }\n\n get actualAppName() {\n return this.appName || this.name;\n }\n\n async connectedCallback() {\n super.connectedCallback();\n await this.mountMicrofrontend();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.unmountMicrofrontend();\n }\n\n async mountMicrofrontend() {\n try {\n this.loading = true;\n this.error = null;\n\n const wu = getWuInstance();\n if (!wu) {\n throw new Error('Wu Framework not initialized');\n }\n\n // Esperar a que el componente se renderice\n await this.updateComplete;\n\n const contentSlot = this.shadowRoot.querySelector('.wu-slot-content');\n if (!contentSlot) return;\n\n const containerId = `wu-slot-${this.actualAppName}-${Date.now()}`;\n const innerContainer = document.createElement('div');\n innerContainer.id = containerId;\n innerContainer.style.cssText = 'width: 100%; height: 100%;';\n\n contentSlot.innerHTML = '';\n contentSlot.appendChild(innerContainer);\n\n const app = wu.app(this.actualAppName, {\n url: this.url,\n container: `#${containerId}`,\n autoInit: true\n });\n\n this._appInstance = app;\n await app.mount();\n\n this.loading = false;\n this.dispatchEvent(new CustomEvent('wu-load', {\n detail: { name: this.actualAppName, url: this.url },\n bubbles: true,\n composed: true\n }));\n\n } catch (err) {\n console.error(`[WuSlot] Error loading ${this.actualAppName}:`, err);\n this.error = err.message || 'Failed to load microfrontend';\n this.loading = false;\n this.dispatchEvent(new CustomEvent('wu-error', {\n detail: err,\n bubbles: true,\n composed: true\n }));\n }\n }\n\n async unmountMicrofrontend() {\n if (this._appInstance) {\n this.dispatchEvent(new CustomEvent('wu-unmount', {\n detail: { name: this.actualAppName },\n bubbles: true,\n composed: true\n }));\n\n try {\n await this._appInstance.unmount();\n } catch (e) {}\n\n this._appInstance = null;\n }\n }\n\n render() {\n if (this.error) {\n return html`\n <div class=\"wu-slot-error\">\n <strong>Error loading ${this.name}</strong>\n <span>${this.error}</span>\n </div>\n `;\n }\n\n if (this.loading) {\n return html`\n <div class=\"wu-slot-loading\">\n ${this.fallbackText || `Loading ${this.name}...`}\n </div>\n <div class=\"wu-slot-content\"></div>\n `;\n }\n\n return html`<div class=\"wu-slot-content\"></div>`;\n }\n }\n\n // Registrar el elemento\n if (!customElements.get('wu-slot')) {\n customElements.define('wu-slot', WuSlotElement);\n }\n\n return WuSlotElement;\n}\n\n/**\n * Mixin para agregar capacidades de Wu a cualquier LitElement\n *\n * @example\n * import { LitElement } from 'lit';\n * import { WuMixin } from 'wu-framework/adapters/lit';\n *\n * class MyElement extends WuMixin(LitElement) {\n * connectedCallback() {\n * super.connectedCallback();\n *\n * // Usar eventos de Wu\n * this.wuOn('user:login', (data) => {\n * console.log('User logged in:', data);\n * });\n * }\n *\n * handleClick() {\n * this.wuEmit('button:clicked', { id: this.id });\n * }\n * }\n */\nfunction WuMixin(Base) {\n return class extends Base {\n constructor() {\n super();\n this._wuSubscriptions = [];\n }\n\n get wu() {\n return getWuInstance();\n }\n\n // Event Bus methods\n wuEmit(event, data, options) {\n const wu = this.wu;\n if (wu?.eventBus) {\n wu.eventBus.emit(event, data, options);\n }\n }\n\n wuOn(event, callback) {\n const wu = this.wu;\n if (wu?.eventBus) {\n const unsubscribe = wu.eventBus.on(event, callback);\n this._wuSubscriptions.push(unsubscribe);\n return unsubscribe;\n }\n return () => {};\n }\n\n wuOnce(event, callback) {\n const wu = this.wu;\n if (wu?.eventBus) {\n return wu.eventBus.once(event, callback);\n }\n return () => {};\n }\n\n // Store methods\n wuGetState(path) {\n const wu = this.wu;\n return wu?.store?.get(path) || null;\n }\n\n wuSetState(path, value) {\n const wu = this.wu;\n if (wu?.store) {\n wu.store.set(path, value);\n }\n }\n\n wuOnStateChange(pattern, callback) {\n const wu = this.wu;\n if (wu?.store) {\n const unsubscribe = wu.store.on(pattern, callback);\n this._wuSubscriptions.push(unsubscribe);\n return unsubscribe;\n }\n return () => {};\n }\n\n // Cleanup\n disconnectedCallback() {\n super.disconnectedCallback();\n this._wuSubscriptions.forEach(unsub => unsub());\n this._wuSubscriptions = [];\n }\n };\n}\n\n/**\n * Decorador reactivo para propiedades conectadas al store de Wu\n *\n * @example\n * import { LitElement } from 'lit';\n * import { wuProperty } from 'wu-framework/adapters/lit';\n *\n * class MyElement extends LitElement {\n * @wuProperty('user.name')\n * userName;\n *\n * render() {\n * return html`<p>Hello, ${this.userName}</p>`;\n * }\n * }\n */\nfunction wuProperty(storePath) {\n return function(target, propertyKey) {\n const privateKey = `_wu_${propertyKey}`;\n let unsubscribe = null;\n\n Object.defineProperty(target, propertyKey, {\n get() {\n return this[privateKey];\n },\n set(value) {\n const wu = getWuInstance();\n if (wu?.store) {\n wu.store.set(storePath, value);\n }\n },\n configurable: true,\n enumerable: true\n });\n\n // Hook into connectedCallback\n const originalConnected = target.connectedCallback;\n target.connectedCallback = function() {\n if (originalConnected) originalConnected.call(this);\n\n const wu = getWuInstance();\n if (wu?.store) {\n // Set initial value\n this[privateKey] = wu.store.get(storePath);\n\n // Subscribe to changes\n unsubscribe = wu.store.on(storePath, (value) => {\n this[privateKey] = value;\n this.requestUpdate();\n });\n }\n };\n\n // Hook into disconnectedCallback\n const originalDisconnected = target.disconnectedCallback;\n target.disconnectedCallback = function() {\n if (originalDisconnected) originalDisconnected.call(this);\n if (unsubscribe) {\n unsubscribe();\n unsubscribe = null;\n }\n };\n };\n}\n\n/**\n * Helper para crear un Web Component simple sin Lit\n *\n * @example\n * const MyComponent = createSimpleElement({\n * name: 'my-component',\n * template: '<h1>Hello!</h1>',\n * styles: ':host { display: block; color: blue; }',\n * connectedCallback() {\n * console.log('Connected!');\n * }\n * });\n */\nfunction createSimpleElement(config) {\n const {\n name,\n template,\n styles = '',\n shadow = true,\n ...callbacks\n } = config;\n\n class SimpleElement extends HTMLElement {\n constructor() {\n super();\n if (shadow) {\n this.attachShadow({ mode: 'open' });\n }\n }\n\n connectedCallback() {\n const root = this.shadowRoot || this;\n\n if (styles) {\n const styleEl = document.createElement('style');\n styleEl.textContent = styles;\n root.appendChild(styleEl);\n }\n\n if (typeof template === 'function') {\n root.innerHTML += template(this);\n } else {\n root.innerHTML += template;\n }\n\n if (callbacks.connectedCallback) {\n callbacks.connectedCallback.call(this);\n }\n }\n\n disconnectedCallback() {\n if (callbacks.disconnectedCallback) {\n callbacks.disconnectedCallback.call(this);\n }\n }\n\n attributeChangedCallback(name, oldVal, newVal) {\n if (callbacks.attributeChangedCallback) {\n callbacks.attributeChangedCallback.call(this, name, oldVal, newVal);\n }\n }\n }\n\n if (callbacks.observedAttributes) {\n SimpleElement.observedAttributes = callbacks.observedAttributes;\n }\n\n if (!customElements.get(name)) {\n customElements.define(name, SimpleElement);\n }\n\n return SimpleElement;\n}\n\n// ============================================\n// AI INTEGRATION\n// ============================================\nimport { WuAIMixin } from './ai.js';\n\n// API pública del adapter\nexport const wuLit = {\n register,\n registerWebComponent,\n createWuSlotElement,\n WuMixin,\n WuAIMixin,\n wuProperty,\n createSimpleElement,\n getWuInstance,\n waitForWu\n};\n\nexport {\n register,\n registerWebComponent,\n createWuSlotElement,\n WuMixin,\n WuAIMixin,\n wuProperty,\n createSimpleElement,\n getWuInstance,\n waitForWu\n};\n\nexport default wuLit;\n"],"names":["WuAIMixin","Base","constructor","super","this","_wuAINamespace","wuAI","window","wu","parent","top","ai","wuAISend","text","options","send","namespace","console","warn","wuAISetNamespace","ns","adapterState","apps","Map","elements","lit","initialized","getWuInstance","waitForWu","timeout","Promise","resolve","reject","startTime","Date","now","handleWuReady","cleanup","addEventListener","checkInterval","setInterval","Error","clearInterval","removeEventListener","async","register","appName","ElementClass","tagName","properties","onMount","onUnmount","standalone","standaloneContainer","customTagName","includes","generateTagName","customElements","get","define","log","error","set","mountApp","container","has","unmountApp","innerHTML","element","document","createElement","Object","entries","forEach","key","value","wuAppName","wuInstance","appendChild","appData","parentNode","remove","delete","mount","unmount","containerElement","querySelector","registerWebComponent","createWuSlotElement","LitElement","html","css","WuSlotElement","static","name","type","String","url","attribute","fallbackText","loading","Boolean","state","_appInstance","actualAppName","connectedCallback","mountMicrofrontend","disconnectedCallback","unmountMicrofrontend","updateComplete","contentSlot","shadowRoot","containerId","innerContainer","id","style","cssText","app","autoInit","dispatchEvent","CustomEvent","detail","bubbles","composed","err","message","e","render","WuMixin","_wuSubscriptions","wuEmit","event","data","eventBus","emit","wuOn","callback","unsubscribe","on","push","wuOnce","once","wuGetState","path","store","wuSetState","wuOnStateChange","pattern","unsub","wuProperty","storePath","target","propertyKey","privateKey","defineProperty","configurable","enumerable","originalConnected","call","requestUpdate","originalDisconnected","createSimpleElement","config","template","styles","shadow","callbacks","SimpleElement","HTMLElement","attachShadow","mode","root","styleEl","textContent","attributeChangedCallback","oldVal","newVal","observedAttributes","wuLit"],"mappings":"AAQO,SAASA,EAAUC,GACxB,OAAO,cAAcA,EACnB,WAAAC,GAAgBC,QAASC,KAAKC,eAAiB,SAAW,CAC1D,QAAIC,GAAS,OAPO,oBAAXC,OAA+B,KACnCA,OAAOC,IAAMD,OAAOE,QAAQD,IAAMD,OAAOG,KAAKF,IAAM,OAMpBG,IAAM,IAAM,CACjD,cAAMC,CAASC,EAAMC,EAAU,IAC7B,MAAMH,EAAKP,KAAKE,KAChB,OAAKK,EACEA,EAAGI,KAAKF,EAAM,CAAEG,UAAWZ,KAAKC,kBAAmBS,KAD/CG,QAAQC,KAAK,mCAA2C,KAErE,CACA,gBAAAC,CAAiBC,GAAMhB,KAAKC,eAAiBe,CAAI,EAErD,CCUA,MAAMC,EAAe,CACnBC,KAAM,IAAIC,IACVC,SAAU,IAAID,IACdE,IAAK,KACLC,aAAa,GAMf,SAASC,IACP,MAAsB,oBAAXpB,OAA+B,KAEnCA,OAAOC,IACTD,OAAOE,QAAQD,IACfD,OAAOG,KAAKF,IACZ,IACP,CAKA,SAASoB,EAAUC,EAAU,KAC3B,OAAO,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMxB,EAAKmB,IACX,GAAInB,EAEF,YADAuB,EAAQvB,GAIV,MAAMyB,EAAYC,KAAKC,MAEjBC,EAAgB,KACpBC,IACAN,EAAQJ,MAGVpB,OAAO+B,iBAAiB,WAAYF,GACpC7B,OAAO+B,iBAAiB,eAAgBF,GAExC,MAAMG,EAAgBC,YAAY,KAChC,MAAMhC,EAAKmB,IACX,GAAInB,EAGF,OAFA6B,SACAN,EAAQvB,GAIN0B,KAAKC,MAAQF,EAAYJ,IAC3BQ,IACAL,EAAO,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BC,YAC1B,WAAAtK,GACEC,QACIkK,GACFjK,KAAKqK,aAAa,CAAEC,KAAM,QAE9B,CAEA,iBAAAjE,GACE,MAAMkE,EAAOvK,KAAK2G,YAAc3G,KAEhC,GAAIgK,EAAQ,CACV,MAAMQ,EAAUvG,SAASC,cAAc,SACvCsG,EAAQC,YAAcT,EACtBO,EAAK7F,YAAY8F,EACnB,CAGED,EAAKxG,WADiB,mBAAbgG,EACSA,EAAS/J,MAET+J,EAGhBG,EAAU7D,mBACZ6D,EAAU7D,kBAAkBqD,KAAK1J,KAErC,CAEA,oBAAAuG,GACM2D,EAAU3D,sBACZ2D,EAAU3D,qBAAqBmD,KAAK1J,KAExC,CAEA,wBAAA0K,CAAyBhF,EAAMiF,EAAQC,GACjCV,EAAUQ,0BACZR,EAAUQ,yBAAyBhB,KAAK1J,KAAM0F,EAAMiF,EAAQC,EAEhE,EAWF,OARIV,EAAUW,qBACZV,EAAcU,mBAAqBX,EAAUW,oBAG1CxH,eAAeC,IAAIoC,IACtBrC,eAAeE,OAAOmC,EAAMyE,GAGvBA,CACT,CAQY,MAACW,EAAQ,CACnBrI,WACA0C,uBACAC,sBACAwC,UACAhI,YACAqJ,aACAY,sBACAtI,gBACAC"}
|
package/dist/adapters/lit.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
// Re-export from folder structure — backward compatibility
|
|
2
|
-
export * from './lit/index';
|
|
3
|
-
export { default } from './lit/index';
|
|
1
|
+
// Re-export from folder structure — backward compatibility
|
|
2
|
+
export * from './lit/index';
|
|
3
|
+
export { default } from './lit/index';
|
|
@@ -1,108 +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;
|
|
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;
|