wu-framework 1.1.15 → 1.1.17
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 +52 -20
- package/dist/wu-framework.cjs.js +1 -1
- package/dist/wu-framework.cjs.js.map +1 -1
- package/dist/wu-framework.dev.js +15511 -15146
- package/dist/wu-framework.dev.js.map +1 -1
- package/dist/wu-framework.esm.js +1 -1
- package/dist/wu-framework.esm.js.map +1 -1
- package/dist/wu-framework.umd.js +1 -1
- package/dist/wu-framework.umd.js.map +1 -1
- package/package.json +166 -161
- package/src/adapters/angular/ai.js +30 -30
- package/src/adapters/angular/index.d.ts +154 -154
- package/src/adapters/angular/index.js +932 -932
- package/src/adapters/angular.d.ts +3 -3
- package/src/adapters/angular.js +3 -3
- package/src/adapters/index.js +168 -168
- package/src/adapters/lit/ai.js +20 -20
- package/src/adapters/lit/index.d.ts +120 -120
- package/src/adapters/lit/index.js +721 -721
- package/src/adapters/lit.d.ts +3 -3
- package/src/adapters/lit.js +3 -3
- package/src/adapters/preact/ai.js +33 -33
- package/src/adapters/preact/index.d.ts +108 -108
- package/src/adapters/preact/index.js +661 -661
- package/src/adapters/preact.d.ts +3 -3
- package/src/adapters/preact.js +3 -3
- package/src/adapters/react/index.js +48 -54
- package/src/adapters/react.d.ts +3 -3
- package/src/adapters/react.js +3 -3
- package/src/adapters/shared.js +64 -64
- package/src/adapters/solid/ai.js +32 -32
- package/src/adapters/solid/index.d.ts +101 -101
- package/src/adapters/solid/index.js +586 -586
- package/src/adapters/solid.d.ts +3 -3
- package/src/adapters/solid.js +3 -3
- package/src/adapters/svelte/ai.js +31 -31
- package/src/adapters/svelte/index.d.ts +166 -166
- package/src/adapters/svelte/index.js +798 -798
- package/src/adapters/svelte.d.ts +3 -3
- package/src/adapters/svelte.js +3 -3
- package/src/adapters/vanilla/ai.js +30 -30
- package/src/adapters/vanilla/index.d.ts +179 -179
- package/src/adapters/vanilla/index.js +785 -785
- package/src/adapters/vanilla.d.ts +3 -3
- package/src/adapters/vanilla.js +3 -3
- package/src/adapters/vue/ai.js +52 -52
- package/src/adapters/vue/index.d.ts +299 -299
- package/src/adapters/vue/index.js +610 -610
- package/src/adapters/vue.d.ts +3 -3
- package/src/adapters/vue.js +3 -3
- package/src/ai/wu-ai-actions.js +261 -261
- package/src/ai/wu-ai-agent.js +546 -546
- package/src/ai/wu-ai-browser-primitives.js +354 -354
- package/src/ai/wu-ai-browser.js +380 -380
- package/src/ai/wu-ai-context.js +332 -332
- package/src/ai/wu-ai-conversation.js +613 -613
- package/src/ai/wu-ai-orchestrate.js +1021 -1021
- package/src/ai/wu-ai-permissions.js +381 -381
- package/src/ai/wu-ai-provider.js +700 -700
- package/src/ai/wu-ai-schema.js +225 -225
- package/src/ai/wu-ai-triggers.js +396 -396
- package/src/ai/wu-ai.js +804 -804
- package/src/core/wu-app.js +236 -236
- package/src/core/wu-cache.js +498 -477
- package/src/core/wu-core.js +1412 -1398
- package/src/core/wu-error-boundary.js +396 -382
- package/src/core/wu-event-bus.js +390 -348
- package/src/core/wu-hooks.js +350 -350
- package/src/core/wu-html-parser.js +199 -190
- package/src/core/wu-iframe-sandbox.js +328 -328
- package/src/core/wu-loader.js +385 -273
- package/src/core/wu-logger.js +142 -134
- package/src/core/wu-manifest.js +532 -509
- package/src/core/wu-mcp-bridge.js +432 -432
- package/src/core/wu-overrides.js +510 -510
- package/src/core/wu-performance.js +228 -228
- package/src/core/wu-plugin.js +401 -348
- package/src/core/wu-prefetch.js +414 -414
- package/src/core/wu-proxy-sandbox.js +477 -476
- package/src/core/wu-sandbox.js +779 -779
- package/src/core/wu-script-executor.js +161 -113
- package/src/core/wu-snapshot-sandbox.js +227 -227
- package/src/core/wu-store.js +13 -3
- package/src/core/wu-strategies.js +256 -256
- package/src/core/wu-style-bridge.js +477 -477
- package/src/index.d.ts +317 -0
- package/src/index.js +234 -224
- package/src/utils/dependency-resolver.js +327 -327
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// Wu Framework - Type Declarations
|
|
2
|
+
|
|
3
|
+
// --- Core Types ---
|
|
4
|
+
|
|
5
|
+
export interface WuEvent {
|
|
6
|
+
name: string;
|
|
7
|
+
data: any;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
appName: string;
|
|
10
|
+
meta: Record<string, any>;
|
|
11
|
+
verified: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface WuAppConfig {
|
|
15
|
+
name: string;
|
|
16
|
+
url: string;
|
|
17
|
+
container?: string;
|
|
18
|
+
keepAlive?: boolean;
|
|
19
|
+
sandbox?: 'module' | 'strict' | 'eval';
|
|
20
|
+
styleMode?: 'shared' | 'isolated' | 'fully-isolated';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface WuLifecycle {
|
|
24
|
+
mount: (container: HTMLElement) => void | Promise<void>;
|
|
25
|
+
unmount?: (container: HTMLElement) => void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface WuPlugin {
|
|
29
|
+
name: string;
|
|
30
|
+
permissions?: Array<'mount' | 'events' | 'store' | 'apps' | 'config' | 'unsafe'>;
|
|
31
|
+
install?: (api: WuSandboxedApi, options?: any) => void;
|
|
32
|
+
uninstall?: (api: WuSandboxedApi) => void;
|
|
33
|
+
beforeInit?: (context: any) => void | Promise<void>;
|
|
34
|
+
afterInit?: (context: any) => void | Promise<void>;
|
|
35
|
+
beforeMount?: (context: any) => void | boolean | Promise<void | boolean>;
|
|
36
|
+
afterMount?: (context: any) => void | Promise<void>;
|
|
37
|
+
beforeUnmount?: (context: any) => void | Promise<void>;
|
|
38
|
+
afterUnmount?: (context: any) => void | Promise<void>;
|
|
39
|
+
onError?: (context: any) => void | Promise<void>;
|
|
40
|
+
onDestroy?: (context: any) => void | Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface WuSandboxedApi {
|
|
44
|
+
version: string;
|
|
45
|
+
info: { name: string; description: string; features: string[] };
|
|
46
|
+
getAppInfo(appName: string): { name: string; state: string; timestamp: number } | null;
|
|
47
|
+
getMountedApps(): string[];
|
|
48
|
+
getStats(): Record<string, any>;
|
|
49
|
+
emit?(event: string, data: any): boolean;
|
|
50
|
+
on?(event: string, cb: (event: WuEvent) => void): () => void;
|
|
51
|
+
off?(event: string, cb: (event: WuEvent) => void): void;
|
|
52
|
+
getState?(path: string): any;
|
|
53
|
+
setState?(path: string, value: any): number;
|
|
54
|
+
mount?(appName: string, container: string): Promise<void>;
|
|
55
|
+
unmount?(appName: string): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// --- Core Classes ---
|
|
59
|
+
|
|
60
|
+
export class WuCore {
|
|
61
|
+
apps: Map<string, any>;
|
|
62
|
+
mounted: Map<string, any>;
|
|
63
|
+
eventBus: WuEventBus;
|
|
64
|
+
store: WuStore;
|
|
65
|
+
pluginSystem: WuPluginSystem;
|
|
66
|
+
hooks: WuLifecycleHooks;
|
|
67
|
+
performance: WuPerformance;
|
|
68
|
+
|
|
69
|
+
init(config: { apps: WuAppConfig[]; sandbox?: string; overrides?: any }): Promise<void>;
|
|
70
|
+
mount(appName: string, containerSelector: string): Promise<void>;
|
|
71
|
+
unmount(appName: string, options?: { force?: boolean; defer?: boolean }): Promise<void>;
|
|
72
|
+
define(appName: string, lifecycle: WuLifecycle): void;
|
|
73
|
+
app(name: string, config: Partial<WuAppConfig>): WuApp;
|
|
74
|
+
hide(appName: string): Promise<void>;
|
|
75
|
+
show(appName: string): Promise<void>;
|
|
76
|
+
isHidden(appName: string): boolean;
|
|
77
|
+
destroy(): void;
|
|
78
|
+
getStats(): Record<string, any>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class WuEventBus {
|
|
82
|
+
constructor();
|
|
83
|
+
emit(eventName: string, data?: any, options?: { appName?: string; token?: string; meta?: any }): boolean;
|
|
84
|
+
on(eventName: string, callback: (event: WuEvent) => void): () => void;
|
|
85
|
+
once(eventName: string, callback: (event: WuEvent) => void): () => void;
|
|
86
|
+
off(eventName: string, callback: (event: WuEvent) => void): void;
|
|
87
|
+
registerApp(appName: string, options?: { permissions?: string[]; token?: string }): string;
|
|
88
|
+
unregisterApp(appName: string): void;
|
|
89
|
+
replay(eventNameOrPattern: string, callback: (event: WuEvent) => void): void;
|
|
90
|
+
enableStrictMode(): void;
|
|
91
|
+
disableStrictMode(): void;
|
|
92
|
+
removeAll(): void;
|
|
93
|
+
getStats(): Record<string, any>;
|
|
94
|
+
configure(config: Partial<Record<string, any>>): void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class WuStore {
|
|
98
|
+
constructor(bufferSize?: number);
|
|
99
|
+
get(path?: string): any;
|
|
100
|
+
set(path: string, value: any): number;
|
|
101
|
+
on(pattern: string, callback: (value: any, path?: string) => void): () => void;
|
|
102
|
+
batch(updates: Record<string, any>): number[];
|
|
103
|
+
clear(): void;
|
|
104
|
+
getMetrics(): { reads: number; writes: number; notifications: number; bufferUtilization: number; listenerCount: number };
|
|
105
|
+
getRecentEvents(count?: number): Array<{ path: string; value: any; timestamp: number }>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class WuLoader {
|
|
109
|
+
constructor(options?: { maxCacheSize?: number; cacheTTL?: number });
|
|
110
|
+
loadApp(appUrl: string, manifest?: any): Promise<string>;
|
|
111
|
+
loadComponent(appUrl: string, componentPath: string): Promise<any>;
|
|
112
|
+
preload(appConfigs: WuAppConfig[]): Promise<void>;
|
|
113
|
+
isAvailable(url: string): Promise<boolean>;
|
|
114
|
+
clearCache(pattern?: string): void;
|
|
115
|
+
getStats(): Record<string, any>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class WuSandbox {
|
|
119
|
+
create(appName: string, container: HTMLElement, options?: any): any;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class WuManifest {
|
|
123
|
+
load(appUrl: string): Promise<any>;
|
|
124
|
+
validate(manifest: any): any;
|
|
125
|
+
create(name: string, config?: any): any;
|
|
126
|
+
clearCache(pattern?: string): void;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export class WuApp {
|
|
130
|
+
mount(): Promise<void>;
|
|
131
|
+
unmount(): Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export class WuCache {
|
|
135
|
+
constructor(options?: { maxSize?: number; maxItems?: number; defaultTTL?: number; persistent?: boolean; storage?: string });
|
|
136
|
+
get(key: string): any;
|
|
137
|
+
set(key: string, value: any, ttl?: number): boolean;
|
|
138
|
+
delete(key: string): void;
|
|
139
|
+
clear(): void;
|
|
140
|
+
getStats(): Record<string, any>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export class WuPerformance {
|
|
144
|
+
startMeasure(name: string, appName?: string): void;
|
|
145
|
+
endMeasure(name: string, appName?: string): number;
|
|
146
|
+
generateReport(): Record<string, any>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export class WuProxySandbox {
|
|
150
|
+
constructor(appName: string, options?: Record<string, any>);
|
|
151
|
+
activate(): any;
|
|
152
|
+
deactivate(): void;
|
|
153
|
+
patchWindow(): void;
|
|
154
|
+
unpatchWindow(): void;
|
|
155
|
+
setContainer(container: HTMLElement, shadowRoot: ShadowRoot): void;
|
|
156
|
+
getProxy(): any;
|
|
157
|
+
isActive(): boolean;
|
|
158
|
+
getStats(): Record<string, any>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export class WuSnapshotSandbox {
|
|
162
|
+
constructor(appName: string);
|
|
163
|
+
activate(): void;
|
|
164
|
+
deactivate(): void;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export class WuHtmlParser {
|
|
168
|
+
parse(html: string, appName: string, baseUrl: string): { dom: string; scripts: { inline: string[]; external: string[] }; styles: { inline: string[]; external: string[] } };
|
|
169
|
+
fetchHtml(url: string, appName: string): Promise<string>;
|
|
170
|
+
fetchAndParse(url: string, appName: string): Promise<any>;
|
|
171
|
+
clearCache(): void;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export class WuScriptExecutor {
|
|
175
|
+
execute(scriptText: string, appName: string, proxy: any, options?: { strictGlobal?: boolean; sourceUrl?: string }): any;
|
|
176
|
+
fetchScript(url: string): Promise<string>;
|
|
177
|
+
executeAll(scripts: Array<{ content?: string; src?: string }>, appName: string, proxy: any, options?: any): Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export class WuIframeSandbox {
|
|
181
|
+
constructor();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export class WuPluginSystem {
|
|
185
|
+
constructor(core: WuCore, options?: { hookTimeout?: number });
|
|
186
|
+
use(plugin: WuPlugin | ((options?: any) => WuPlugin), options?: any): void;
|
|
187
|
+
uninstall(pluginName: string): void;
|
|
188
|
+
getPlugin(pluginName: string): WuPlugin | undefined;
|
|
189
|
+
getStats(): Record<string, any>;
|
|
190
|
+
cleanup(): void;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export class WuLoadingStrategy {
|
|
194
|
+
constructor(core: WuCore);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export class WuPrefetch {
|
|
198
|
+
constructor(core: WuCore);
|
|
199
|
+
prefetch(appNames: string | string[], options?: any): Promise<void>;
|
|
200
|
+
prefetchAll(options?: any): Promise<void>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export class WuOverrides {
|
|
204
|
+
constructor();
|
|
205
|
+
set(name: string, url: string, options?: any): void;
|
|
206
|
+
remove(name: string): void;
|
|
207
|
+
getAll(): Record<string, string>;
|
|
208
|
+
clearAll(): void;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export class WuErrorBoundary {
|
|
212
|
+
constructor(core: WuCore);
|
|
213
|
+
handle(error: Error, context?: any): Promise<{ recovered: boolean; action: string; message?: string }>;
|
|
214
|
+
register(handler: { name: string; canHandle: (error: Error) => boolean; handle: (error: Error, context: any) => Promise<any> }): void;
|
|
215
|
+
getErrorLog(limit?: number): any[];
|
|
216
|
+
getStats(): Record<string, any>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export class WuLifecycleHooks {
|
|
220
|
+
constructor(core: WuCore);
|
|
221
|
+
use(phase: string, middleware: Function, options?: any): void;
|
|
222
|
+
execute(phase: string, context?: any): Promise<{ cancelled: boolean }>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export class WuStyleBridge {}
|
|
226
|
+
|
|
227
|
+
// --- Hook Factories ---
|
|
228
|
+
|
|
229
|
+
export function createSimpleHook(fn: Function): any;
|
|
230
|
+
export function createConditionalHook(condition: Function, fn: Function): any;
|
|
231
|
+
export function createGuardHook(fn: Function): any;
|
|
232
|
+
export function createTransformHook(fn: Function): any;
|
|
233
|
+
export function createTimedHook(fn: Function, timeout: number): any;
|
|
234
|
+
export function createPlugin(config: WuPlugin): WuPlugin;
|
|
235
|
+
|
|
236
|
+
// --- Convenience API ---
|
|
237
|
+
|
|
238
|
+
export const wu: WuCore;
|
|
239
|
+
export default wu;
|
|
240
|
+
|
|
241
|
+
export function init(apps: WuAppConfig[]): Promise<void>;
|
|
242
|
+
export function mount(name: string, container: string): Promise<void>;
|
|
243
|
+
export function unmount(name: string, opts?: any): Promise<void>;
|
|
244
|
+
export function define(name: string, lifecycle: WuLifecycle): void;
|
|
245
|
+
export function app(name: string, config: Partial<WuAppConfig>): WuApp;
|
|
246
|
+
export function destroy(): void;
|
|
247
|
+
export function hide(name: string): Promise<void>;
|
|
248
|
+
export function show(name: string): Promise<void>;
|
|
249
|
+
export function isHidden(name: string): boolean;
|
|
250
|
+
|
|
251
|
+
export function emit(event: string, data?: any, opts?: any): boolean;
|
|
252
|
+
export function on(event: string, cb: (event: WuEvent) => void): () => void;
|
|
253
|
+
export function once(event: string, cb: (event: WuEvent) => void): () => void;
|
|
254
|
+
export function off(event: string, cb: (event: WuEvent) => void): void;
|
|
255
|
+
|
|
256
|
+
export function getState(path?: string): any;
|
|
257
|
+
export function setState(path: string, value: any): number;
|
|
258
|
+
export function onStateChange(pattern: string, cb: (value: any) => void): () => void;
|
|
259
|
+
|
|
260
|
+
export function startMeasure(name: string, app?: string): void;
|
|
261
|
+
export function endMeasure(name: string, app?: string): number;
|
|
262
|
+
export function generatePerformanceReport(): Record<string, any>;
|
|
263
|
+
|
|
264
|
+
export function prefetch(appNames: string | string[], opts?: any): Promise<void>;
|
|
265
|
+
export function prefetchAll(opts?: any): Promise<void>;
|
|
266
|
+
|
|
267
|
+
export function override(name: string, url: string, opts?: any): void;
|
|
268
|
+
export function removeOverride(name: string): void;
|
|
269
|
+
export function getOverrides(): Record<string, string>;
|
|
270
|
+
export function clearOverrides(): void;
|
|
271
|
+
|
|
272
|
+
export function usePlugin(plugin: WuPlugin | Function, opts?: any): void;
|
|
273
|
+
export function useHook(phase: string, middleware: Function, opts?: any): void;
|
|
274
|
+
|
|
275
|
+
export function silenceAllLogs(): void;
|
|
276
|
+
export function enableAllLogs(): void;
|
|
277
|
+
|
|
278
|
+
// --- AI Classes ---
|
|
279
|
+
|
|
280
|
+
export class WuAI {
|
|
281
|
+
provider(name: string, config: any): void;
|
|
282
|
+
send(message: string, options?: any): Promise<any>;
|
|
283
|
+
stream(message: string, options?: any): AsyncGenerator<any>;
|
|
284
|
+
json(message: string, options?: any): Promise<any>;
|
|
285
|
+
action(name: string, config: any): void;
|
|
286
|
+
agent(goal: string, options?: any): Promise<any>;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export class WuAIProvider {}
|
|
290
|
+
export class WuAIPermissions {}
|
|
291
|
+
export class WuAIContext {}
|
|
292
|
+
export class WuAIActions {}
|
|
293
|
+
export class WuAIConversation {}
|
|
294
|
+
export class WuAITriggers {}
|
|
295
|
+
export class WuAIAgent {}
|
|
296
|
+
export class WuAIOrchestrate {}
|
|
297
|
+
|
|
298
|
+
export function sanitizeForPrompt(text: string): string;
|
|
299
|
+
export function redactSensitive(text: string): string;
|
|
300
|
+
export function interpolate(template: string, vars: Record<string, any>): string;
|
|
301
|
+
export function buildToolSchemas(actions: any): any;
|
|
302
|
+
export function normalizeParameters(params: any): any;
|
|
303
|
+
export function validateParams(params: any, schema: any): boolean;
|
|
304
|
+
export function estimateTokens(text: string): number;
|
|
305
|
+
export function truncateToTokenBudget(text: string, budget: number): string;
|
|
306
|
+
|
|
307
|
+
// --- MCP & Browser ---
|
|
308
|
+
|
|
309
|
+
export function createMcpBridge(core: WuCore): any;
|
|
310
|
+
export function registerBrowserActions(ai: WuAI): void;
|
|
311
|
+
export function ensureInterceptors(): void;
|
|
312
|
+
export function captureScreenshot(): Promise<string>;
|
|
313
|
+
export function buildA11yTree(): any;
|
|
314
|
+
export function clickElement(selector: string): Promise<void>;
|
|
315
|
+
export function typeIntoElement(selector: string, text: string): Promise<void>;
|
|
316
|
+
export function getFilteredNetwork(): any[];
|
|
317
|
+
export function getFilteredConsole(): any[];
|