wu-framework 2.1.2 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +6 -1
  2. package/dist/adapters/alpine/index.d.ts +1 -1
  3. package/dist/adapters/angular/index.d.ts +1 -1
  4. package/dist/adapters/htmx/index.d.ts +1 -1
  5. package/dist/adapters/lit/index.d.ts +1 -1
  6. package/dist/adapters/lit/index.js +2 -2
  7. package/dist/adapters/lit/index.js.map +1 -1
  8. package/dist/adapters/preact/index.d.ts +1 -1
  9. package/dist/adapters/preact/index.js +1 -1
  10. package/dist/adapters/preact/index.js.map +1 -1
  11. package/dist/adapters/qwik/index.d.ts +3 -10
  12. package/dist/adapters/qwik/index.js +1 -1
  13. package/dist/adapters/qwik/index.js.map +1 -1
  14. package/dist/adapters/react/index.js +1 -1
  15. package/dist/adapters/react/index.js.map +1 -1
  16. package/dist/adapters/shared.d.ts +44 -0
  17. package/dist/adapters/shared.js +1 -1
  18. package/dist/adapters/shared.js.map +1 -1
  19. package/dist/adapters/solid/index.d.ts +1 -1
  20. package/dist/adapters/solid/index.js +1 -1
  21. package/dist/adapters/solid/index.js.map +1 -1
  22. package/dist/adapters/stencil/index.d.ts +1 -1
  23. package/dist/adapters/stimulus/index.d.ts +1 -1
  24. package/dist/adapters/svelte/index.d.ts +1 -1
  25. package/dist/adapters/svelte/index.js +1 -1
  26. package/dist/adapters/svelte/index.js.map +1 -1
  27. package/dist/adapters/vanilla/index.d.ts +1 -1
  28. package/dist/adapters/vanilla/index.js +1 -1
  29. package/dist/adapters/vanilla/index.js.map +1 -1
  30. package/dist/adapters/vue/index.js +1 -1
  31. package/dist/adapters/vue/index.js.map +1 -1
  32. package/dist/ai/wu-ai.js +1 -1
  33. package/dist/ai/wu-ai.js.map +1 -1
  34. package/dist/core/wu-devtools.js +2 -0
  35. package/dist/core/wu-devtools.js.map +1 -0
  36. package/dist/core/wu-html-parser.js +1 -1
  37. package/dist/core/wu-html-parser.js.map +1 -1
  38. package/dist/core/wu-iframe-sandbox.js +1 -1
  39. package/dist/core/wu-iframe-sandbox.js.map +1 -1
  40. package/dist/core/wu-loader.js +1 -1
  41. package/dist/core/wu-loader.js.map +1 -1
  42. package/dist/core/wu-logger.js +2 -0
  43. package/dist/core/wu-logger.js.map +1 -0
  44. package/dist/core/wu-mcp-bridge.js +1 -1
  45. package/dist/core/wu-mcp-bridge.js.map +1 -1
  46. package/dist/core/wu-script-executor.js +1 -1
  47. package/dist/core/wu-script-executor.js.map +1 -1
  48. package/dist/core/wu-store-sync.js +2 -0
  49. package/dist/core/wu-store-sync.js.map +1 -0
  50. package/dist/core/wu-timeline.js +2 -0
  51. package/dist/core/wu-timeline.js.map +1 -0
  52. package/dist/index.d.cts +739 -0
  53. package/dist/index.d.ts +295 -1
  54. package/dist/wu-ai-browser-primitives-CaUCk1Xl.js +2 -0
  55. package/dist/wu-ai-browser-primitives-CaUCk1Xl.js.map +1 -0
  56. package/dist/wu-framework.cjs +3 -0
  57. package/dist/wu-framework.cjs.map +1 -0
  58. package/dist/wu-framework.dev.js +1207 -275
  59. package/dist/wu-framework.dev.js.map +1 -1
  60. package/dist/wu-framework.esm.js +2 -2
  61. package/dist/wu-framework.esm.js.map +1 -1
  62. package/dist/wu-framework.umd.js +2 -2
  63. package/dist/wu-framework.umd.js.map +1 -1
  64. package/integrations/astro/WuApp.astro +16 -11
  65. package/integrations/astro/WuShell.astro +11 -3
  66. package/package.json +14 -6
  67. package/dist/wu-ai-browser-primitives-BDKXJlwc.js +0 -2
  68. package/dist/wu-ai-browser-primitives-BDKXJlwc.js.map +0 -1
  69. package/dist/wu-framework.cjs.js +0 -3
  70. package/dist/wu-framework.cjs.js.map +0 -1
  71. package/dist/wu-logger-fJfUHBGA.js +0 -2
  72. package/dist/wu-logger-fJfUHBGA.js.map +0 -1
@@ -0,0 +1,739 @@
1
+ // Wu Framework - Type Declarations (v2.0)
2
+ // AI classes moved to 'wu-framework/ai' subpath.
3
+ // Sandbox internals moved to 'wu-framework/sandbox/*' subpaths.
4
+
5
+ // --- Core Types ---
6
+
7
+ export interface WuEvent {
8
+ name: string;
9
+ data: any;
10
+ timestamp: number;
11
+ appName: string;
12
+ meta: Record<string, any>;
13
+ verified: boolean;
14
+ }
15
+
16
+ export interface WuAppConfig {
17
+ name: string;
18
+ url: string;
19
+ container?: string;
20
+ keepAlive?: boolean;
21
+ sandbox?: 'module' | 'strict' | 'eval';
22
+ /**
23
+ * Per-app override for `strict` mode CORS fallback (v2.1+).
24
+ * - `true` (default): degrade to `eval` on iframe import failure with a warning
25
+ * - `false`: throw on failure instead
26
+ */
27
+ strictFallback?: boolean;
28
+ /**
29
+ * CSS isolation mode. v2.1 aliases:
30
+ * - `none` is an alias for `isolated`
31
+ * - `own-only` is an alias for `fully-isolated`
32
+ */
33
+ styleMode?: 'shared' | 'isolated' | 'fully-isolated' | 'none' | 'own-only';
34
+ }
35
+
36
+ /**
37
+ * Runtime sandbox info reported by `wu.getSandboxInfo(appName)` (v2.1+).
38
+ */
39
+ export interface WuSandboxInfo {
40
+ /** What the caller asked for (from app config or global init) */
41
+ requestedMode: 'module' | 'strict' | 'eval';
42
+ /** What's actually running. Differs from requestedMode if strict fell back to eval. */
43
+ actualMode: 'module' | 'strict' | 'eval';
44
+ /** Human-readable isolation tier */
45
+ isolationLevel: 'none' | 'iframe' | 'proxy-trap';
46
+ /** Whether the app is currently mounted (vs hidden via keep-alive) */
47
+ mounted: boolean;
48
+ }
49
+
50
+ export interface WuLifecycle {
51
+ mount: (container: HTMLElement) => void | Promise<void>;
52
+ unmount?: (container: HTMLElement) => void | Promise<void>;
53
+ activate?: (container: HTMLElement) => void | Promise<void>;
54
+ deactivate?: (container: HTMLElement) => void | Promise<void>;
55
+ /**
56
+ * Live-props slot (v2.2+). Called by `wu.update(appName, props)` to push new
57
+ * props into a mounted app without remounting. Adapters built on
58
+ * `createWuAdapter` expose this when their framework can re-render in place.
59
+ */
60
+ update?: (container: HTMLElement, props: Record<string, any>) => void | Promise<void>;
61
+ }
62
+
63
+ /** Full-page diagnostic snapshot returned by `wu.inspect()` (v2.2+). */
64
+ export interface WuInspectSnapshot {
65
+ version: string | null;
66
+ timestamp: number;
67
+ summary: { registered: number; defined: number; mounted: number; hidden: number };
68
+ apps: Array<{
69
+ name: string;
70
+ status: 'mounted' | 'hidden';
71
+ framework: string | null;
72
+ containerSelector: string | null;
73
+ mountedAt: number | null;
74
+ liveProps: boolean;
75
+ props: Record<string, any> | null;
76
+ sandbox: WuSandboxInfo | null;
77
+ }>;
78
+ defined: string[];
79
+ registered: string[];
80
+ /** Registered capability contracts (v2.5+). */
81
+ capabilities: Array<{ name: string; version: string; app: string | null }>;
82
+ events: { recent: Array<{ type: string; appName?: string; timestamp?: number }>; stats: any };
83
+ store: { snapshot: any; metrics: any };
84
+ }
85
+
86
+ /** Options for `wu.provide()` (v2.5+). */
87
+ export interface WuProvideOptions {
88
+ /** Semver version the implementation satisfies (default '0.0.0'). */
89
+ version?: string;
90
+ /** Required keys (array) or key→typeof map; verified at provide() time. */
91
+ shape?: string[] | Record<string, string>;
92
+ /** Providing app — the capability auto-revokes when this app unmounts. */
93
+ app?: string;
94
+ }
95
+
96
+ /** Options for `wu.consume()` (v2.5+). */
97
+ export interface WuConsumeOptions {
98
+ /** Return a Promise that resolves once a satisfying provider appears. */
99
+ wait?: boolean;
100
+ /** ms; rejects the wait promise if exceeded. */
101
+ timeout?: number;
102
+ }
103
+
104
+ /** Handle returned by `wu.provide()` (v2.5+). */
105
+ export interface WuCapabilityHandle {
106
+ revoke(): void;
107
+ }
108
+
109
+ /**
110
+ * Typed, versioned, runtime-verified capability contracts (v2.5+). Apps
111
+ * declare what they provide and consume; the runtime negotiates semver and
112
+ * verifies shape — replacing Module Federation's fragile shared singletons.
113
+ */
114
+ export class WuContracts {
115
+ constructor(core: WuCore);
116
+ provide<T extends object>(name: string, impl: T, opts?: WuProvideOptions): WuCapabilityHandle;
117
+ consume<T = any>(name: string, range?: string, opts?: { wait?: false; timeout?: number }): T;
118
+ consume<T = any>(name: string, range: string, opts: { wait: true; timeout?: number }): Promise<T>;
119
+ has(name: string, range?: string): boolean;
120
+ revoke(name: string): boolean;
121
+ list(): Array<{ name: string; version: string; app: string | null }>;
122
+ cleanup(): void;
123
+ }
124
+
125
+ /** A single journal entry recorded by WuTimeline (v2.3+). */
126
+ export interface WuTimelineEntry {
127
+ /** Lamport clock — the (l, site) pair is the CRDT total order. */
128
+ l: number;
129
+ /** Originating site id. */
130
+ site: string;
131
+ /** Wall-clock timestamp (ms). */
132
+ t: number;
133
+ kind: 'store' | 'event';
134
+ /** store: ring-buffer sequence number */
135
+ seq?: number;
136
+ /** store: dot-path written ('' = full-state replace) */
137
+ path?: string;
138
+ /** store: written value (deep-cloned) */
139
+ value?: any;
140
+ /** event: event name */
141
+ name?: string;
142
+ /** event: source app */
143
+ appName?: string;
144
+ /** event (app:mounted): container selector */
145
+ container?: string | null;
146
+ /** event (app:updated): live props pushed */
147
+ props?: Record<string, any> | null;
148
+ }
149
+
150
+ /** Status of the time-travel recorder (v2.3+). */
151
+ export interface WuTimelineStatus {
152
+ loaded: boolean;
153
+ recording: boolean;
154
+ /** true when positioned at the journal end (the present) */
155
+ live: boolean;
156
+ /** number of journal entries applied */
157
+ position: number;
158
+ /** total journal length */
159
+ length: number;
160
+ site: string | null;
161
+ lamport: number;
162
+ snapshots: number;
163
+ }
164
+
165
+ /** Serializable journal — the reproducible bug report (v2.3+). */
166
+ export interface WuTimelineExport {
167
+ format: string;
168
+ wu: string | null;
169
+ site: string;
170
+ exportedAt: number;
171
+ baselineApps: Array<{ name: string; container: string | null; props: Record<string, any> | null }>;
172
+ entries: WuTimelineEntry[];
173
+ snapshots: Array<{ at: number; state: any }>;
174
+ }
175
+
176
+ /**
177
+ * The `wu.timeline` facade (v2.3+) — cross-framework time travel. Records every
178
+ * store write, event-bus emit, and app lifecycle change into one journal;
179
+ * seek() rewinds the whole multi-framework page in lockstep (store hydrate +
180
+ * live-props replay + app diff). Synchronous + chainable for the fire-and-forget
181
+ * controls (record/stop/clear); the seek family returns Promises. The recorder
182
+ * chunk is lazy-loaded on first use — `await wu.timelineReady()` to force it.
183
+ * See ROADMAP.md.
184
+ */
185
+ export interface WuTimelineFacade {
186
+ record(opts?: { snapshotEvery?: number; maxEntries?: number }): WuTimelineFacade;
187
+ stop(): WuTimelineFacade;
188
+ clear(): WuTimelineFacade;
189
+ /** Rewind/forward to a journal position (0..length). */
190
+ seek(pos: number, opts?: { store?: boolean; apps?: boolean; props?: boolean }): Promise<WuTimelineStatus>;
191
+ /** Return to the present (seek to journal end). */
192
+ live(): Promise<WuTimelineStatus>;
193
+ stepBack(): Promise<WuTimelineStatus>;
194
+ stepForward(): Promise<WuTimelineStatus>;
195
+ export(): Promise<WuTimelineExport>;
196
+ import(data: WuTimelineExport): Promise<WuTimelineStatus>;
197
+ /** Merge remote journal entries (CRDT seed for multiplayer sync, #2). */
198
+ ingest(remoteEntries: WuTimelineEntry[]): Promise<WuTimelineStatus>;
199
+ entries(): WuTimelineEntry[];
200
+ status(): WuTimelineStatus;
201
+ readonly loaded: boolean;
202
+ /** The underlying WuTimeline instance once loaded (lazy), else null. */
203
+ readonly instance: any;
204
+ }
205
+
206
+ /** A duck-typed sync transport (v2.4+). Bring your own, or use 'broadcast' / a WebSocket. */
207
+ export interface WuSyncTransport {
208
+ send(message: any): void;
209
+ onMessage(cb: (message: any) => void): void;
210
+ close(): void;
211
+ }
212
+
213
+ /** Options for `wu.store.sync()` (v2.4+). */
214
+ export interface WuSyncOptions {
215
+ /** 'broadcast' (cross-tab), a WebSocket / ws(s):// URL, or a custom transport. Default 'broadcast'. */
216
+ transport?: 'broadcast' | WuSyncTransport | WebSocket | string;
217
+ /** Channel name for the broadcast transport. Default 'default'. */
218
+ room?: string;
219
+ }
220
+
221
+ /** Live status of a store-sync session (v2.4+). */
222
+ export interface WuSyncStatus {
223
+ connected: boolean;
224
+ site: string | null;
225
+ lamport: number;
226
+ peers: number;
227
+ tracked?: number;
228
+ sent?: number;
229
+ received?: number;
230
+ applied?: number;
231
+ ignored?: number;
232
+ /** Local writes skipped because the value wasn't serializable. */
233
+ dropped?: number;
234
+ loading?: boolean;
235
+ stopped?: boolean;
236
+ /** Set if the connection failed (e.g. unknown transport). */
237
+ error?: string | null;
238
+ }
239
+
240
+ /** Handle returned by `wu.store.sync()` (v2.4+). */
241
+ export interface WuSyncHandle {
242
+ /** Stop syncing — detaches the store tap and closes the transport. */
243
+ stop(): void;
244
+ status(): WuSyncStatus;
245
+ /** Resolves once the sync chunk has loaded and the transport is connected. */
246
+ ready(): Promise<any>;
247
+ readonly connected: boolean;
248
+ readonly instance: any;
249
+ }
250
+
251
+ export interface WuPlugin {
252
+ name: string;
253
+ permissions?: Array<'mount' | 'events' | 'store' | 'apps' | 'config' | 'unsafe'>;
254
+ install?: (api: WuSandboxedApi, options?: any) => void;
255
+ uninstall?: (api: WuSandboxedApi) => void;
256
+ beforeInit?: (context: any) => void | Promise<void>;
257
+ afterInit?: (context: any) => void | Promise<void>;
258
+ beforeMount?: (context: any) => void | boolean | Promise<void | boolean>;
259
+ afterMount?: (context: any) => void | Promise<void>;
260
+ beforeUnmount?: (context: any) => void | Promise<void>;
261
+ afterUnmount?: (context: any) => void | Promise<void>;
262
+ onError?: (context: any) => void | Promise<void>;
263
+ onDestroy?: (context: any) => void | Promise<void>;
264
+ }
265
+
266
+ export interface WuSandboxedApi {
267
+ version: string;
268
+ info: { name: string; description: string; features: string[] };
269
+ getAppInfo(appName: string): { name: string; state: string; timestamp: number } | null;
270
+ getMountedApps(): string[];
271
+ getStats(): Record<string, any>;
272
+ emit?(event: string, data: any): boolean;
273
+ on?(event: string, cb: (event: WuEvent) => void): () => void;
274
+ off?(event: string, cb: (event: WuEvent) => void): void;
275
+ getState?(path: string): any;
276
+ setState?(path: string, value: any): number;
277
+ mount?(appName: string, container: string): Promise<void>;
278
+ unmount?(appName: string): Promise<void>;
279
+ }
280
+
281
+ // --- AI Lazy Proxy ---
282
+ // The wu.ai property is a Proxy backed by a lazy-loaded chunk. Methods that
283
+ // return `this` for chaining work synchronously (calls are queued and flushed
284
+ // after the chunk loads). Async methods return Promises/AsyncGenerators that
285
+ // await the load transparently. Use `wu.aiReady()` to get the real instance.
286
+
287
+ export interface WuAILazyProxy {
288
+ readonly isLazy: true;
289
+ readonly isLoaded: false;
290
+
291
+ // Chainable config (sync, queued — return the proxy for chaining)
292
+ provider(name: string, config: any): WuAILazyProxy;
293
+ action(name: string, config: any): WuAILazyProxy;
294
+ trigger(name: string, config: any): WuAILazyProxy;
295
+ capability(appName: string, actionName: string, config: any): WuAILazyProxy;
296
+ workflow(name: string, config: any): WuAILazyProxy;
297
+ removeApp(appName: string): WuAILazyProxy;
298
+ init(config?: any): WuAILazyProxy;
299
+
300
+ // Async — load chunk + delegate
301
+ send(message: string, options?: any): Promise<any>;
302
+ json(message: string, options?: any): Promise<any>;
303
+ intent(description: string, options?: any): Promise<any>;
304
+ execute(name: string, params: any): Promise<any>;
305
+ fireTrigger(name: string, eventData?: any): Promise<any>;
306
+
307
+ // Async generators
308
+ stream(message: string, options?: any): AsyncGenerator<any>;
309
+ agent(goal: string, options?: any): AsyncGenerator<any>;
310
+ runWorkflow(name: string, params?: any, options?: any): AsyncGenerator<any>;
311
+
312
+ // Sync-returning (faux defaults before load, real values after)
313
+ tools(): any[];
314
+ expose(): boolean;
315
+ getStats(): Record<string, any>;
316
+
317
+ // Sync void (queued)
318
+ abort(namespace?: string): void;
319
+ destroy(): void;
320
+ confirmTool(callId: string): void;
321
+ rejectTool(callId: string): void;
322
+
323
+ // Sub-objects
324
+ context: WuAISubProxy;
325
+ conversation: WuAISubProxy;
326
+ permissions: WuAISubProxy;
327
+ }
328
+
329
+ export interface WuAISubProxy {
330
+ [method: string]: (...args: any[]) => any;
331
+ }
332
+
333
+ // --- Core Classes ---
334
+
335
+ export class WuCore {
336
+ apps: Map<string, any>;
337
+ mounted: Map<string, any>;
338
+ hidden: Map<string, any>;
339
+ eventBus: WuEventBus;
340
+ store: WuStore;
341
+ pluginSystem: WuPluginSystem;
342
+ hooks: WuLifecycleHooks;
343
+ performance: WuPerformance;
344
+ prefetcher: WuPrefetch;
345
+ overrides: WuOverrides;
346
+ errorBoundary: WuErrorBoundary;
347
+ sandbox: WuSandbox;
348
+ cache: WuCache;
349
+ /** Capability-contract registry (v2.5+). */
350
+ contracts: WuContracts;
351
+
352
+ /**
353
+ * Lazy AI proxy. Auto-loads the AI chunk on first method call.
354
+ * Use `wu.aiReady()` to await the load explicitly.
355
+ */
356
+ readonly ai: WuAILazyProxy;
357
+ /** Resolve to the real WuAI instance (chunk loaded). */
358
+ aiReady(): Promise<any>;
359
+
360
+ /** MCP bridge for connecting to wu-mcp-server. */
361
+ mcp: {
362
+ connect(url?: string, options?: any): Promise<void>;
363
+ disconnect(): void;
364
+ isConnected(): boolean;
365
+ };
366
+
367
+ init(config: {
368
+ apps: WuAppConfig[];
369
+ sandbox?: 'module' | 'strict' | 'eval';
370
+ /** v2.1+: global default for whether strict mode degrades to eval on CORS */
371
+ strictFallback?: boolean;
372
+ overrides?: any;
373
+ }): Promise<void>;
374
+ mount(appName: string, containerSelector: string): Promise<void>;
375
+ unmount(appName: string, options?: { force?: boolean; keepAlive?: boolean }): Promise<void>;
376
+ /**
377
+ * Push new props into an already-mounted app without remounting (v2.2+).
378
+ * Resolves `true` if the app's adapter supports live props; resolves `false`
379
+ * (an honest no-op, never throws) when the app is not mounted or its adapter
380
+ * has no `update` slot.
381
+ */
382
+ update(appName: string, props: Record<string, any>): Promise<boolean>;
383
+ define(appName: string, lifecycle: WuLifecycle): void;
384
+ app(name: string, config: Partial<WuAppConfig>): WuApp;
385
+ hide(appName: string): Promise<void>;
386
+ show(appName: string): Promise<void>;
387
+ isHidden(appName: string): boolean;
388
+ destroy(): Promise<void>;
389
+ getStats(): Record<string, any>;
390
+
391
+ /**
392
+ * Inspect the actual JS isolation level for a mounted app (v2.1+).
393
+ * Useful to verify that `strict` didn't silently degrade to `eval` after
394
+ * a CORS failure.
395
+ */
396
+ getSandboxInfo(appName: string): WuSandboxInfo | null;
397
+
398
+ /**
399
+ * Register a capability another app can consume (typed/versioned contract, v2.5+).
400
+ */
401
+ provide<T extends object>(name: string, impl: T, opts?: WuProvideOptions): WuCapabilityHandle;
402
+ /**
403
+ * Consume a capability from another app (v2.5+). Returns a live proxy that
404
+ * fails loudly on access if unsatisfied, or a Promise with { wait: true }.
405
+ */
406
+ consume<T = any>(name: string, range?: string, opts?: { wait?: false; timeout?: number }): T;
407
+ consume<T = any>(name: string, range: string, opts: { wait: true; timeout?: number }): Promise<T>;
408
+
409
+ /**
410
+ * Full-page diagnostic snapshot — every mounted app, its sandbox mode and
411
+ * live-props capability, recent events, and a store snapshot in one object
412
+ * (v2.2+). Backs `wu.showInspector()` and `window.__WU_DEVTOOLS__`.
413
+ */
414
+ inspect(opts?: { events?: number }): WuInspectSnapshot;
415
+
416
+ /** Open the lazy, Shadow-DOM-isolated inspector overlay (v2.2+). */
417
+ showInspector(): Promise<{ close: () => void } | null>;
418
+ /** Close the inspector overlay if open (v2.2+). */
419
+ hideInspector(): Promise<void>;
420
+
421
+ /**
422
+ * Cross-framework time travel (v2.3+). Record store/event/lifecycle
423
+ * mutations and scrub the whole multi-framework page back and forth. The
424
+ * recorder is a lazy chunk loaded on first `wu.timeline.*` call — zero
425
+ * overhead until used. See ROADMAP.md.
426
+ */
427
+ timeline: WuTimelineFacade;
428
+
429
+ /**
430
+ * Force-load the timeline chunk and resolve the real WuTimeline (v2.3+).
431
+ * `await wu.timelineReady()` before the first write you want captured — after
432
+ * it resolves, `wu.timeline.record()` arms synchronously. Mirrors aiReady().
433
+ */
434
+ timelineReady(): Promise<any>;
435
+
436
+ /**
437
+ * Tag a <style> or <link> element as belonging to a specific app (v2.1+).
438
+ * Makes `fully-isolated` / `own-only` styleMode detect the style regardless
439
+ * of bundler. Necessary for webpack / esbuild / plain HTML apps; Vite is
440
+ * detected automatically.
441
+ */
442
+ tagStyleAsApp(el: HTMLElement, appName: string): void;
443
+
444
+ // Convenience proxies
445
+ emit(event: string, data?: any, opts?: any): boolean;
446
+ on(event: string, cb: (event: WuEvent) => void): () => void;
447
+ once(event: string, cb: (event: WuEvent) => void): () => void;
448
+ off(event: string, cb: (event: WuEvent) => void): void;
449
+ prefetch(appNames: string | string[], opts?: any): Promise<void> | (() => void);
450
+ prefetchAll(opts?: any): Promise<void> | (() => void);
451
+ override(name: string, url: string, opts?: any): void;
452
+ removeOverride(name: string): void;
453
+ getOverrides(): Record<string, string>;
454
+ clearOverrides(): void;
455
+ silence(): Promise<void>;
456
+ verbose(): Promise<void>;
457
+
458
+ version: string;
459
+ info: { name: string; description: string; features: string[] };
460
+ }
461
+
462
+ export class WuEventBus {
463
+ constructor();
464
+ authorizedApps: Map<string, any>;
465
+ trustedEvents: Set<string>;
466
+ trustedApps: Set<string>;
467
+ history: WuEvent[];
468
+
469
+ emit(eventName: string, data?: any, options?: { appName?: string; token?: string; meta?: any; history?: boolean }): boolean;
470
+ on(eventName: string, callback: (event: WuEvent) => void): () => void;
471
+ once(eventName: string, callback: (event: WuEvent) => void): () => void;
472
+ off(eventName: string, callback: (event: WuEvent) => void): void;
473
+ registerApp(appName: string, options?: { permissions?: string[]; token?: string }): string;
474
+ unregisterApp(appName: string): void;
475
+ replay(eventNameOrPattern: string, callback: (event: WuEvent) => void): void;
476
+ clearHistory(eventNameOrPattern?: string): void;
477
+ matchesWildcard(eventName: string, pattern: string): boolean;
478
+ /**
479
+ * Low-level emit tap (v2.3+). Fires for every emitted event (after history,
480
+ * before listeners), bypassing wildcard matching and authorization — the
481
+ * internal firehose WuTimeline journals from. Returns an unsubscribe fn.
482
+ */
483
+ tap(fn: (event: WuEvent) => void): () => void;
484
+ enableStrictMode(): void;
485
+ disableStrictMode(): void;
486
+ removeAll(): void;
487
+ getStats(): Record<string, any>;
488
+ configure(config: Partial<Record<string, any>>): void;
489
+ }
490
+
491
+ export class WuStore {
492
+ constructor(bufferSize?: number);
493
+ get(path?: string): any;
494
+ /** Throws on unsafe keys (__proto__, constructor, prototype). */
495
+ set(path: string, value: any): number;
496
+ on(pattern: string, callback: (value: any, path?: string) => void): () => void;
497
+ batch(updates: Record<string, any>): number[];
498
+ /**
499
+ * Low-level write tap (v2.3+). Fires synchronously inside set() for every
500
+ * write with the ring-buffer sequence — the substrate WuTimeline journals
501
+ * from. Returns an unsubscribe function.
502
+ */
503
+ tap(fn: (sequence: number, path: string, value: any) => void): () => void;
504
+ /**
505
+ * Replace the whole state and re-notify listeners (v2.3+) — the seek
506
+ * primitive for WuTimeline. Does not touch the ring buffer or taps.
507
+ */
508
+ hydrate(newState: any, opts?: { notifyPaths?: string[] }): void;
509
+ /**
510
+ * Start real-time collaborative sync across replicas (tabs/workers/clients)
511
+ * via a per-path Last-Writer-Wins CRDT (v2.4+). Lazy-loads the sync chunk.
512
+ * See ROADMAP.md (#2).
513
+ */
514
+ sync(opts?: WuSyncOptions): WuSyncHandle;
515
+ clear(): void;
516
+ getMetrics(): {
517
+ reads: number;
518
+ writes: number;
519
+ notifications: number;
520
+ bufferUtilization: number;
521
+ sequenceNumber: number;
522
+ bufferSize: number;
523
+ listenerCount: number;
524
+ };
525
+ }
526
+
527
+ export class WuLoader {
528
+ constructor(options?: { maxCacheSize?: number; cacheTTL?: number });
529
+ loadApp(appUrl: string, manifest?: any): Promise<string>;
530
+ loadComponent(appUrl: string, componentPath: string): Promise<any>;
531
+ preload(appConfigs: WuAppConfig[]): Promise<void>;
532
+ isAvailable(url: string): Promise<boolean>;
533
+ clearCache(pattern?: string): void;
534
+ getStats(): Record<string, any>;
535
+ }
536
+
537
+ export class WuSandbox {
538
+ create(appName: string, container: HTMLElement, options?: any): any;
539
+ cleanup(sandbox: any): void;
540
+ }
541
+
542
+ export class WuManifest {
543
+ load(appUrl: string): Promise<any>;
544
+ validate(manifest: any): any;
545
+ create(name: string, config?: any): any;
546
+ clearCache(pattern?: string): void;
547
+ }
548
+
549
+ export class WuApp {
550
+ mount(): Promise<void>;
551
+ unmount(): Promise<void>;
552
+ }
553
+
554
+ export class WuCache {
555
+ constructor(options?: { maxSize?: number; maxItems?: number; defaultTTL?: number; persistent?: boolean; storage?: string });
556
+ get(key: string): any;
557
+ set(key: string, value: any, ttl?: number): boolean;
558
+ delete(key: string): void;
559
+ clear(): void;
560
+ getStats(): Record<string, any>;
561
+ }
562
+
563
+ export class WuPerformance {
564
+ startMeasure(name: string, appName?: string): void;
565
+ endMeasure(name: string, appName?: string): number;
566
+ generateReport(): Record<string, any>;
567
+ getMetrics(appName: string): Record<string, any> | null;
568
+ getAllMetrics(): Record<string, any>;
569
+ clearMetrics(appName?: string): void;
570
+ configure(config: { enabled?: boolean; maxMeasurements?: number; devtoolsTimeline?: boolean; thresholds?: Record<string, number> }): void;
571
+
572
+ /** Read User Timing entries created by this framework. */
573
+ getDevToolsEntries(opts?: { type?: 'mark' | 'measure' | 'all'; appName?: string }): PerformanceEntry[];
574
+ /** Subscribe to wu:* User Timing entries via PerformanceObserver. */
575
+ observe(callback: (entry: PerformanceEntry) => void, opts?: { type?: 'mark' | 'measure' | 'all' }): () => void;
576
+ }
577
+
578
+ export class WuProxySandbox {
579
+ constructor(appName: string, options?: Record<string, any>);
580
+ activate(): any;
581
+ deactivate(): void;
582
+ patchWindow(): void;
583
+ unpatchWindow(): void;
584
+ setContainer(container: HTMLElement, shadowRoot: ShadowRoot): void;
585
+ getProxy(): any;
586
+ isActive(): boolean;
587
+ getStats(): Record<string, any>;
588
+ }
589
+
590
+ // WuSnapshotSandbox, WuHtmlParser, WuScriptExecutor, WuIframeSandbox, WuAI*,
591
+ // and AI helpers are no longer exported from the main entry. Import via:
592
+ // import { WuIframeSandbox } from 'wu-framework/sandbox/iframe';
593
+ // import { WuHtmlParser } from 'wu-framework/sandbox/html-parser';
594
+ // import { WuScriptExecutor } from 'wu-framework/sandbox/script-executor';
595
+ // import { WuAI, ... } from 'wu-framework/ai';
596
+
597
+ export class WuPluginSystem {
598
+ constructor(core: WuCore, options?: { hookTimeout?: number });
599
+ use(plugin: WuPlugin | ((options?: any) => WuPlugin), options?: any): void;
600
+ uninstall(pluginName: string): void;
601
+ getPlugin(pluginName: string): WuPlugin | undefined;
602
+ getStats(): Record<string, any>;
603
+ cleanup(): void;
604
+ }
605
+
606
+ export class WuLoadingStrategy {
607
+ constructor(core: WuCore);
608
+ }
609
+
610
+ export class WuPrefetch {
611
+ constructor(core: WuCore);
612
+ prefetch(appNames: string | string[], options?: any): Promise<void> | (() => void);
613
+ prefetchAll(options?: any): Promise<void> | (() => void);
614
+ }
615
+
616
+ export class WuOverrides {
617
+ constructor(config?: { enabled?: boolean; allowedDomains?: string[]; showIndicator?: boolean });
618
+ set(name: string, url: string, options?: { maxAge?: number; path?: string }): void;
619
+ remove(name: string): void;
620
+ getAll(): Record<string, string>;
621
+ clearAll(): void;
622
+ refresh(): void;
623
+ configure(config: { enabled?: boolean; allowedDomains?: string[]; showIndicator?: boolean }): void;
624
+ getStats(): Record<string, any>;
625
+ isEnabled(): boolean;
626
+ hasOverrides(): boolean;
627
+ }
628
+
629
+ export class WuErrorBoundary {
630
+ constructor(core: WuCore);
631
+ handle(error: Error, context?: any): Promise<{ recovered: boolean; action: string; message?: string }>;
632
+ register(handler: { name: string; canHandle: (error: Error) => boolean; handle: (error: Error, context: any) => Promise<any> }): void;
633
+ getErrorLog(limit?: number): any[];
634
+ getStats(): Record<string, any>;
635
+ }
636
+
637
+ export class WuLifecycleHooks {
638
+ constructor(core: WuCore);
639
+ use(phase: string, middleware: Function, options?: any): void;
640
+ execute(phase: string, context?: any): Promise<{ cancelled: boolean }>;
641
+ }
642
+
643
+ export class WuStyleBridge {
644
+ /** Returns an unsubscribe function. Multiple subscribers share one observer. */
645
+ observeStyleChanges(callback: () => void): () => void;
646
+ registerFullyIsolatedApp(appName: string, appUrl: string): void;
647
+ unregisterFullyIsolatedApp(appName: string): void;
648
+ injectStylesIntoShadow(shadowRoot: ShadowRoot, appName: string, styleMode?: string): Promise<number>;
649
+ cleanup(): void;
650
+ }
651
+
652
+ // --- Hook Factories ---
653
+
654
+ export function createSimpleHook(fn: Function): any;
655
+ export function createConditionalHook(condition: Function, fn: Function): any;
656
+ export function createGuardHook(fn: Function): any;
657
+ export function createTransformHook(fn: Function): any;
658
+ export function createTimedHook(fn: Function, timeout: number): any;
659
+ export function createPlugin(config: WuPlugin): WuPlugin;
660
+
661
+ // --- Convenience API ---
662
+
663
+ export const wu: WuCore;
664
+ export default wu;
665
+
666
+ export function init(apps: WuAppConfig[]): Promise<void>;
667
+ export function mount(name: string, container: string): Promise<void>;
668
+ export function unmount(name: string, opts?: any): Promise<void>;
669
+ export function define(name: string, lifecycle: WuLifecycle): void;
670
+ export function app(name: string, config: Partial<WuAppConfig>): WuApp;
671
+ export function destroy(): Promise<void>;
672
+ export function hide(name: string): Promise<void>;
673
+ export function show(name: string): Promise<void>;
674
+ export function isHidden(name: string): boolean;
675
+
676
+ export function emit(event: string, data?: any, opts?: any): boolean;
677
+ export function on(event: string, cb: (event: WuEvent) => void): () => void;
678
+ export function once(event: string, cb: (event: WuEvent) => void): () => void;
679
+ export function off(event: string, cb: (event: WuEvent) => void): void;
680
+
681
+ export function getState(path?: string): any;
682
+ export function setState(path: string, value: any): number;
683
+ export function onStateChange(pattern: string, cb: (value: any) => void): () => void;
684
+ export function syncStore(opts?: WuSyncOptions): WuSyncHandle;
685
+
686
+ export function provide<T extends object>(name: string, impl: T, opts?: WuProvideOptions): WuCapabilityHandle;
687
+ export function consume<T = any>(name: string, range?: string, opts?: { wait?: false; timeout?: number }): T;
688
+ export function consume<T = any>(name: string, range: string, opts: { wait: true; timeout?: number }): Promise<T>;
689
+
690
+ export function startMeasure(name: string, app?: string): void;
691
+ export function endMeasure(name: string, app?: string): number;
692
+ export function generatePerformanceReport(): Record<string, any>;
693
+
694
+ export function prefetch(appNames: string | string[], opts?: any): Promise<void> | (() => void);
695
+ export function prefetchAll(opts?: any): Promise<void> | (() => void);
696
+
697
+ export function override(name: string, url: string, opts?: any): void;
698
+ export function removeOverride(name: string): void;
699
+ export function getOverrides(): Record<string, string>;
700
+ export function clearOverrides(): void;
701
+
702
+ export function usePlugin(plugin: WuPlugin | Function, opts?: any): void;
703
+ export function useHook(phase: string, middleware: Function, opts?: any): void;
704
+
705
+ export function silenceAllLogs(): void;
706
+ export function enableAllLogs(): void;
707
+
708
+ // --- Semver (capability-contract range matching, v2.5+) ---
709
+ export function satisfies(version: string, range: string): boolean;
710
+ export function parseVersion(v: string): [number, number, number];
711
+ export function compareVersions(a: string | number[], b: string | number[]): number;
712
+
713
+ /**
714
+ * Canonicalize styleMode aliases (v2.1+).
715
+ * - `'none'` → `'isolated'`
716
+ * - `'own-only'` → `'fully-isolated'`
717
+ * - Other inputs pass through unchanged.
718
+ */
719
+ export function normalizeStyleMode(mode: string | undefined): string | undefined;
720
+
721
+ /**
722
+ * DevTools bridge (v2.2+). A tiny always-present global so external inspectors
723
+ * and the built-in overlay can detect Wu and pull a full-page snapshot.
724
+ */
725
+ export interface WuDevtoolsBridge {
726
+ version: string;
727
+ isWu: true;
728
+ inspect(opts?: { events?: number }): WuInspectSnapshot;
729
+ show(): Promise<{ close: () => void } | null>;
730
+ hide(): Promise<void>;
731
+ subscribe(cb: (event: WuEvent) => void): () => void;
732
+ }
733
+
734
+ declare global {
735
+ interface Window {
736
+ wu?: WuCore;
737
+ __WU_DEVTOOLS__?: WuDevtoolsBridge;
738
+ }
739
+ }