wu-framework 1.1.6 → 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 +94 -74
- 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,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WU-FRAMEWORK VUE 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 createUseWuAI(Vue) {
|
|
10
|
+
const { ref } = Vue;
|
|
11
|
+
return function useWuAI(options = {}) {
|
|
12
|
+
const { namespace = 'default' } = options;
|
|
13
|
+
const messages = ref([]);
|
|
14
|
+
const isStreaming = ref(false);
|
|
15
|
+
const error = ref(null);
|
|
16
|
+
async function send(text) {
|
|
17
|
+
if (!text?.trim()) return;
|
|
18
|
+
const wu = getWuInstance();
|
|
19
|
+
if (!wu?.ai) { error.value = 'Wu AI not available'; return; }
|
|
20
|
+
messages.value = [...messages.value, { id: `user-${Date.now()}`, role: 'user', content: text, timestamp: Date.now() }];
|
|
21
|
+
error.value = null; isStreaming.value = true;
|
|
22
|
+
try {
|
|
23
|
+
const res = await wu.ai.send(text, { namespace });
|
|
24
|
+
messages.value = [...messages.value, { id: `assistant-${Date.now()}`, role: 'assistant', content: res.content, timestamp: Date.now() }];
|
|
25
|
+
} catch (err) { error.value = err.message || 'AI request failed'; }
|
|
26
|
+
isStreaming.value = false;
|
|
27
|
+
}
|
|
28
|
+
function clear() { messages.value = []; error.value = null; }
|
|
29
|
+
return { messages, isStreaming, error, send, clear };
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function useWuAI(options = {}) {
|
|
34
|
+
const { namespace = 'default' } = options;
|
|
35
|
+
const state = { messages: [], isStreaming: false, error: null };
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
async send(text) {
|
|
39
|
+
if (!text?.trim()) return null;
|
|
40
|
+
const wu = getWuInstance();
|
|
41
|
+
if (!wu?.ai) { state.error = 'Wu AI not available'; return null; }
|
|
42
|
+
state.messages.push({ id: `user-${Date.now()}`, role: 'user', content: text, timestamp: Date.now() });
|
|
43
|
+
state.isStreaming = true; state.error = null;
|
|
44
|
+
try {
|
|
45
|
+
const res = await wu.ai.send(text, { namespace });
|
|
46
|
+
state.messages.push({ id: `assistant-${Date.now()}`, role: 'assistant', content: res.content, timestamp: Date.now() });
|
|
47
|
+
state.isStreaming = false; return res;
|
|
48
|
+
} catch (err) { state.error = err.message; state.isStreaming = false; return null; }
|
|
49
|
+
},
|
|
50
|
+
clear() { state.messages.length = 0; state.error = null; },
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wu Framework Vue Adapter - TypeScript Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { App, Component, Ref, DefineComponent } from 'vue';
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Core Types (shared with React adapter)
|
|
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
|
+
// Vue Adapter Types
|
|
90
|
+
// ============================================================================
|
|
91
|
+
|
|
92
|
+
export interface VueRegisterOptions {
|
|
93
|
+
/**
|
|
94
|
+
* Function to configure the Vue app (install plugins, add global components, etc.)
|
|
95
|
+
* @param app - Vue app instance
|
|
96
|
+
*/
|
|
97
|
+
setup?: (app: App) => void;
|
|
98
|
+
/** Initial props for the component */
|
|
99
|
+
props?: Record<string, any>;
|
|
100
|
+
/** Callback after mounting */
|
|
101
|
+
onMount?: (container: HTMLElement, app: App) => void;
|
|
102
|
+
/** Callback before unmounting */
|
|
103
|
+
onUnmount?: (container: HTMLElement, app: App) => void;
|
|
104
|
+
/** Allow standalone execution (default: true) */
|
|
105
|
+
standalone?: boolean;
|
|
106
|
+
/** Selector for standalone mode (default: '#app') */
|
|
107
|
+
standaloneContainer?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Register a Vue component as a microfrontend
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* // Basic
|
|
115
|
+
* wuVue.register('my-app', App);
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* // With plugins
|
|
119
|
+
* wuVue.register('my-app', App, {
|
|
120
|
+
* setup: (app) => {
|
|
121
|
+
* app.use(createPinia());
|
|
122
|
+
* app.use(router);
|
|
123
|
+
* }
|
|
124
|
+
* });
|
|
125
|
+
*/
|
|
126
|
+
export function register(
|
|
127
|
+
appName: string,
|
|
128
|
+
RootComponent: Component,
|
|
129
|
+
options?: VueRegisterOptions
|
|
130
|
+
): Promise<boolean>;
|
|
131
|
+
|
|
132
|
+
// ============================================================================
|
|
133
|
+
// WuSlot Component Types
|
|
134
|
+
// ============================================================================
|
|
135
|
+
|
|
136
|
+
export interface WuSlotProps {
|
|
137
|
+
/** Display name for the microfrontend */
|
|
138
|
+
name: string;
|
|
139
|
+
/** URL where the microfrontend is hosted */
|
|
140
|
+
url: string;
|
|
141
|
+
/** App name from wu.json (defaults to name if not provided) */
|
|
142
|
+
appName?: string;
|
|
143
|
+
/** Custom fallback text while loading */
|
|
144
|
+
fallbackText?: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface WuSlotEmits {
|
|
148
|
+
/** Emitted when microfrontend loads successfully */
|
|
149
|
+
(e: 'load', info: { name: string; url: string }): void;
|
|
150
|
+
/** Emitted when loading fails */
|
|
151
|
+
(e: 'error', error: Error): void;
|
|
152
|
+
/** Emitted when microfrontend mounts */
|
|
153
|
+
(e: 'mount', info: { name: string; container: HTMLElement }): void;
|
|
154
|
+
/** Emitted when microfrontend unmounts */
|
|
155
|
+
(e: 'unmount', info: { name: string }): void;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Vue component for loading microfrontends
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* <WuSlot name="my-app" url="http://localhost:3001" @load="onLoad" />
|
|
163
|
+
*/
|
|
164
|
+
export const WuSlot: DefineComponent<WuSlotProps, {}, {}, {}, {}, {}, {}, WuSlotEmits>;
|
|
165
|
+
|
|
166
|
+
// ============================================================================
|
|
167
|
+
// Composables Types
|
|
168
|
+
// ============================================================================
|
|
169
|
+
|
|
170
|
+
export interface UseWuEventsReturn {
|
|
171
|
+
/** Emit an event to the event bus */
|
|
172
|
+
emit: (event: string, data?: any, options?: EmitOptions) => void;
|
|
173
|
+
/** Subscribe to an event */
|
|
174
|
+
on: (event: string, callback: EventCallback) => () => void;
|
|
175
|
+
/** Subscribe to an event once */
|
|
176
|
+
once: (event: string, callback: EventCallback) => () => void;
|
|
177
|
+
/** Unsubscribe from an event */
|
|
178
|
+
off: (event: string, callback?: EventCallback) => void;
|
|
179
|
+
/** Clean up all subscriptions (call in onUnmounted) */
|
|
180
|
+
cleanup: () => void;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Composable for using Wu Framework EventBus
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* const { emit, on, cleanup } = useWuEvents();
|
|
188
|
+
*
|
|
189
|
+
* onMounted(() => {
|
|
190
|
+
* on('user:login', handleLogin);
|
|
191
|
+
* });
|
|
192
|
+
*
|
|
193
|
+
* onUnmounted(() => {
|
|
194
|
+
* cleanup();
|
|
195
|
+
* });
|
|
196
|
+
*/
|
|
197
|
+
export function useWuEvents(): UseWuEventsReturn;
|
|
198
|
+
|
|
199
|
+
export interface UseWuStoreReturn<T = any> {
|
|
200
|
+
/** Reactive state value */
|
|
201
|
+
state: Ref<T | null>;
|
|
202
|
+
/** Set a value in the store */
|
|
203
|
+
setState: (path: string, value: any) => void;
|
|
204
|
+
/** Get a value from the store */
|
|
205
|
+
getState: (path?: string) => any;
|
|
206
|
+
/** Clean up subscription (call in onUnmounted) */
|
|
207
|
+
cleanup: () => void;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Composable for using Wu Framework Store
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* const { state, setState, getState, cleanup } = useWuStore('user');
|
|
215
|
+
*
|
|
216
|
+
* // state.value is reactive
|
|
217
|
+
* watchEffect(() => {
|
|
218
|
+
* console.log('User changed:', state.value);
|
|
219
|
+
* });
|
|
220
|
+
*
|
|
221
|
+
* onUnmounted(() => {
|
|
222
|
+
* cleanup();
|
|
223
|
+
* });
|
|
224
|
+
*/
|
|
225
|
+
export function useWuStore<T = any>(namespace?: string): UseWuStoreReturn<T>;
|
|
226
|
+
|
|
227
|
+
// ============================================================================
|
|
228
|
+
// Plugin Types
|
|
229
|
+
// ============================================================================
|
|
230
|
+
|
|
231
|
+
export interface WuVuePluginOptions {
|
|
232
|
+
// Reserved for future options
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Vue plugin to install Wu Framework globally
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* import { createApp } from 'vue';
|
|
240
|
+
* import { wuVuePlugin } from 'wu-framework/adapters/vue';
|
|
241
|
+
*
|
|
242
|
+
* const app = createApp(App);
|
|
243
|
+
* app.use(wuVuePlugin);
|
|
244
|
+
*
|
|
245
|
+
* // Now you can use:
|
|
246
|
+
* // - <WuSlot /> component globally
|
|
247
|
+
* // - this.$wu in Options API
|
|
248
|
+
* // - inject('wu') in Composition API
|
|
249
|
+
*/
|
|
250
|
+
export const wuVuePlugin: {
|
|
251
|
+
install: (app: App, options?: WuVuePluginOptions) => void;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// ============================================================================
|
|
255
|
+
// Utility Functions
|
|
256
|
+
// ============================================================================
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Get the Wu Framework instance
|
|
260
|
+
*/
|
|
261
|
+
export function getWuInstance(): WuInstance | null;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Wait for Wu Framework to be available
|
|
265
|
+
* @param timeout - Maximum time to wait in ms (default: 5000)
|
|
266
|
+
*/
|
|
267
|
+
export function waitForWu(timeout?: number): Promise<WuInstance>;
|
|
268
|
+
|
|
269
|
+
// ============================================================================
|
|
270
|
+
// Main Export
|
|
271
|
+
// ============================================================================
|
|
272
|
+
|
|
273
|
+
export interface WuVueAdapter {
|
|
274
|
+
register: typeof register;
|
|
275
|
+
WuSlot: typeof WuSlot;
|
|
276
|
+
useWuEvents: typeof useWuEvents;
|
|
277
|
+
useWuStore: typeof useWuStore;
|
|
278
|
+
wuVuePlugin: typeof wuVuePlugin;
|
|
279
|
+
getWuInstance: typeof getWuInstance;
|
|
280
|
+
waitForWu: typeof waitForWu;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export const wuVue: WuVueAdapter;
|
|
284
|
+
export default wuVue;
|
|
285
|
+
|
|
286
|
+
// ============================================================================
|
|
287
|
+
// Global Augmentations
|
|
288
|
+
// ============================================================================
|
|
289
|
+
|
|
290
|
+
declare module '@vue/runtime-core' {
|
|
291
|
+
interface ComponentCustomProperties {
|
|
292
|
+
/** Wu Framework instance */
|
|
293
|
+
$wu: WuInstance | null;
|
|
294
|
+
/** Wu Framework EventBus helpers */
|
|
295
|
+
$wuEvents: UseWuEventsReturn;
|
|
296
|
+
/** Wu Framework Store factory */
|
|
297
|
+
$wuStore: <T = any>(namespace?: string) => UseWuStoreReturn<T>;
|
|
298
|
+
}
|
|
299
|
+
}
|