wu-framework 1.1.7 → 1.1.8
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/README.md +511 -977
- package/dist/wu-framework.cjs.js +3 -1
- package/dist/wu-framework.cjs.js.map +1 -0
- package/dist/wu-framework.dev.js +7533 -2761
- package/dist/wu-framework.dev.js.map +1 -1
- package/dist/wu-framework.esm.js +3 -0
- package/dist/wu-framework.esm.js.map +1 -0
- package/dist/wu-framework.umd.js +3 -1
- package/dist/wu-framework.umd.js.map +1 -0
- package/integrations/astro/README.md +127 -0
- package/integrations/astro/WuApp.astro +63 -0
- package/integrations/astro/WuShell.astro +39 -0
- package/integrations/astro/index.js +68 -0
- package/integrations/astro/package.json +38 -0
- package/integrations/astro/types.d.ts +53 -0
- package/package.json +89 -71
- package/src/adapters/angular/ai.js +30 -0
- package/src/adapters/angular/index.d.ts +154 -0
- package/src/adapters/angular/index.js +932 -0
- package/src/adapters/angular.d.ts +3 -154
- package/src/adapters/angular.js +3 -813
- package/src/adapters/index.js +35 -24
- package/src/adapters/lit/ai.js +20 -0
- package/src/adapters/lit/index.d.ts +120 -0
- package/src/adapters/lit/index.js +721 -0
- package/src/adapters/lit.d.ts +3 -120
- package/src/adapters/lit.js +3 -726
- package/src/adapters/preact/ai.js +33 -0
- package/src/adapters/preact/index.d.ts +108 -0
- package/src/adapters/preact/index.js +661 -0
- package/src/adapters/preact.d.ts +3 -108
- package/src/adapters/preact.js +3 -665
- package/src/adapters/react/ai.js +135 -0
- package/src/adapters/react/index.d.ts +246 -0
- package/src/adapters/react/index.js +689 -0
- package/src/adapters/react.d.ts +3 -212
- package/src/adapters/react.js +3 -513
- package/src/adapters/shared.js +64 -0
- package/src/adapters/solid/ai.js +32 -0
- package/src/adapters/solid/index.d.ts +101 -0
- package/src/adapters/solid/index.js +586 -0
- package/src/adapters/solid.d.ts +3 -101
- package/src/adapters/solid.js +3 -591
- package/src/adapters/svelte/ai.js +31 -0
- package/src/adapters/svelte/index.d.ts +166 -0
- package/src/adapters/svelte/index.js +798 -0
- package/src/adapters/svelte.d.ts +3 -166
- package/src/adapters/svelte.js +3 -803
- package/src/adapters/vanilla/ai.js +30 -0
- package/src/adapters/vanilla/index.d.ts +179 -0
- package/src/adapters/vanilla/index.js +785 -0
- package/src/adapters/vanilla.d.ts +3 -179
- package/src/adapters/vanilla.js +3 -791
- package/src/adapters/vue/ai.js +52 -0
- package/src/adapters/vue/index.d.ts +299 -0
- package/src/adapters/vue/index.js +608 -0
- package/src/adapters/vue.d.ts +3 -299
- package/src/adapters/vue.js +3 -611
- package/src/ai/wu-ai-actions.js +261 -0
- package/src/ai/wu-ai-browser.js +663 -0
- package/src/ai/wu-ai-context.js +332 -0
- package/src/ai/wu-ai-conversation.js +554 -0
- package/src/ai/wu-ai-permissions.js +381 -0
- package/src/ai/wu-ai-provider.js +605 -0
- package/src/ai/wu-ai-schema.js +225 -0
- package/src/ai/wu-ai-triggers.js +396 -0
- package/src/ai/wu-ai.js +474 -0
- package/src/core/wu-app.js +50 -8
- package/src/core/wu-cache.js +1 -1
- package/src/core/wu-core.js +645 -677
- package/src/core/wu-html-parser.js +121 -211
- package/src/core/wu-iframe-sandbox.js +328 -0
- package/src/core/wu-mcp-bridge.js +647 -0
- package/src/core/wu-overrides.js +510 -0
- package/src/core/wu-prefetch.js +414 -0
- package/src/core/wu-proxy-sandbox.js +398 -75
- package/src/core/wu-sandbox.js +86 -268
- package/src/core/wu-script-executor.js +79 -182
- package/src/core/wu-snapshot-sandbox.js +149 -106
- package/src/core/wu-strategies.js +13 -0
- package/src/core/wu-style-bridge.js +0 -2
- package/src/index.js +139 -665
- package/dist/wu-framework.hex.js +0 -23
- package/dist/wu-framework.min.js +0 -1
- package/dist/wu-framework.obf.js +0 -1
- package/scripts/build-protected.js +0 -366
- package/scripts/build.js +0 -212
- package/scripts/rollup-plugin-hex.js +0 -143
- package/src/core/wu-registry.js +0 -60
- package/src/core/wu-sandbox-pool.js +0 -390
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WU-FRAMEWORK VANILLA JS AI INTEGRATION
|
|
3
|
+
*/
|
|
4
|
+
function getWuInstance() {
|
|
5
|
+
if (typeof window === 'undefined') return null;
|
|
6
|
+
return window.wu || window.parent?.wu || window.top?.wu || null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function useWuAI(options = {}) {
|
|
10
|
+
const { namespace = 'default' } = options;
|
|
11
|
+
const state = { messages: [], isStreaming: false, error: null };
|
|
12
|
+
return {
|
|
13
|
+
async send(text) {
|
|
14
|
+
if (!text?.trim()) return null;
|
|
15
|
+
const wu = getWuInstance();
|
|
16
|
+
if (!wu?.ai) { state.error = 'Wu AI not available'; return null; }
|
|
17
|
+
state.messages.push({ id: `user-${Date.now()}`, role: 'user', content: text, timestamp: Date.now() });
|
|
18
|
+
state.isStreaming = true; state.error = null;
|
|
19
|
+
try {
|
|
20
|
+
const res = await wu.ai.send(text, { namespace });
|
|
21
|
+
state.messages.push({ id: `assistant-${Date.now()}`, role: 'assistant', content: res.content, timestamp: Date.now() });
|
|
22
|
+
state.isStreaming = false; return res;
|
|
23
|
+
} catch (err) { state.error = err.message; state.isStreaming = false; return null; }
|
|
24
|
+
},
|
|
25
|
+
clear() { state.messages.length = 0; state.error = null; },
|
|
26
|
+
getMessages() { return [...state.messages]; },
|
|
27
|
+
getError() { return state.error; },
|
|
28
|
+
isStreaming() { return state.isStreaming; },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -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;
|