# Loading, cache, and diagnostic reference

Dynamic loading, priorities, overrides, cache, styles, and runtime observation.

<span id="elegir-el-nivel-de-carga"></span>

<span class="section-anchor" id="section-1"></span>

## Choosing the loading level

Use `wu.mount` for the complete lifecycle. `wu.prefetch` anticipates resources of registered applications, and `wu.use` loads components published through exports. `WuLoader` is an independent loader: it does not replace the core catalog, sandbox, or grants.

Overrides and inspection tools belong to the host. A metric measures an observed interval; it does not guarantee the browser has finished painting. See [application loading](/docs/framework/loading/) and [diagnostics](/docs/framework/troubleshooting/) for the complete flow.

<span class="section-anchor" id="section-2"></span>

## wu.use

Loads a component export declared by another application.

`wu.use("app.component"): Promise<unknown>`

- **Parameters:** Exact app.component name; the provider manifest must declare wu.exports.
- **Returns:** default export when present, otherwise the module namespace.
- **Errors:** Missing app/export, traversal, invalid URL, or failed import reject.
- **Permissions:** Host; a loaded component runs code in the consumer realm.
- **Cleanup:** The renderer instance using the component manages its cleanup.

```js
const ProductCard = await wu.use('catalog.ProductCard');
```

Present at runtime but absent from the WuCore declaration. Does not convert components between frameworks.

Reference: `src/core/wu-core.js`.

<span class="section-anchor" id="section-3"></span>

## wu.prefetchAll

Requests preloading for all registered applications.

`wu.prefetchAll(options?): Promise<void> | (() => void)`

- **Parameters:** Same trigger options as prefetch.
- **Returns:** Immediate promise or cleanup for deferred triggers.
- **Errors:** Preloading is a browser request; it does not confirm a renderer can mount.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Retain cleanup when choosing a deferred trigger.

```js
await wu.prefetchAll({ on: 'immediate' });
```

Reference: `src/core/wu-prefetch.js`.

<span class="section-anchor" id="section-4"></span>

## new WuLoader

Creates a code and component loader with caching and in-flight deduplication.

`new WuLoader({ maxCacheSize?, cacheTTL? }?): WuLoader`

- **Parameters:** maxCacheSize limits entries (50 by default); cacheTTL is in milliseconds (1800000 by default).
- **Returns:** Instance with loadApp, loadComponent, preload, isAvailable, and clearCache.
- **Errors:** Constructing it neither registers apps nor executes lifecycle.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** loader.clearCache() releases cached entries.

```js
import { WuLoader } from 'wu-framework';
const loader = new WuLoader({ maxCacheSize: 20, cacheTTL: 60000 });
```

Reference: `src/core/wu-loader.js`.

<span class="section-anchor" id="section-5"></span>

## WuLoader.loadApp

Downloads entrypoint code text for the loading pipeline.

`loader.loadApp(appUrl, manifest?): Promise<string>`

- **Parameters:** Base URL and manifest with optional entry.
- **Returns:** Code string; does not execute mount or register the app.
- **Errors:** Failed fetch, invalid response, or failed entry resolution reject.
- **Permissions:** Host; subject to environment network access.
- **Cleanup:** clearCache(base) discards cached reads for future requests.

```js
const code = await loader.loadApp('/apps/catalog', { entry: 'entry.js' });
```

Reference: `src/core/wu-loader.js`.

<span class="section-anchor" id="section-6"></span>

## WuLoader.loadComponent

Imports a component confined to an app base.

`loader.loadComponent(appUrl, componentPath): Promise<unknown>`

- **Parameters:** Base and relative component path; no absolute URLs or traversal.
- **Returns:** default export or imported namespace.
- **Errors:** Path outside the base or failed import rejects.
- **Permissions:** The module executes code in the same context; not scoped RPC.
- **Cleanup:** Native import retains its module cache.

```js
const card = await loader.loadComponent('/apps/catalog', 'components/card.js');
```

Reference: `src/core/wu-loader.js`.

<span class="section-anchor" id="section-7"></span>

## WuLoader.preload

Anticipates code downloads for a list of applications.

`loader.preload(appConfigs: WuAppConfig[]): Promise<void>`

- **Parameters:** Configuration array with name and url.
- **Returns:** Promise completing preload traversal.
- **Errors:** Preloading catches per-app failures; inspect availability before mounting.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Mounts no renderers; clearCache releases cached text.

```js
await loader.preload([{ name: 'catalog', url: '/apps/catalog' }]);
```

Reference: `src/core/wu-loader.js`.

<span class="section-anchor" id="section-8"></span>

## WuLoader.isAvailable

Checks whether a URL responds successfully to HEAD.

`loader.isAvailable(url): Promise<boolean>`

- **Parameters:** URL to check.
- **Returns:** Boolean; network errors become false.
- **Errors:** A server rejecting HEAD may return false even when GET works.
- **Permissions:** Host network access.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
const available = await loader.isAvailable('/apps/catalog/entry.js');
```

Reference: `src/core/wu-loader.js`.

<span class="section-anchor" id="section-9"></span>

## WuLoader.clearCache

Discards cached loader text and records.

`loader.clearCache(pattern?): void`

- **Parameters:** Optional pattern; without one, empties the loader cache.
- **Returns:** void.
- **Errors:** Does not invalidate the browser ESM cache.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
loader.clearCache('catalog');
```

Reference: `src/core/wu-loader.js`.

<span class="section-anchor" id="section-10"></span>

## WuLoader.getStats

Queries loader cache and in-flight imports.

`loader.getStats(): object`

- **Parameters:** No arguments.
- **Returns:** Metrics object.
- **Errors:** Does not represent apps' mounted state.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.log(loader.getStats());
```

Reference: `src/core/wu-loader.js`.

<span class="section-anchor" id="section-11"></span>

## wu.override

Configures a development URL override.

`wu.override(name, url, options?): void`

- **Parameters:** name and authorized URL; options.maxAge/path configure override persistence.
- **Returns:** void
- **Errors:** The system validates domains and configuration; an override is not automatic remounting.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Remove development overrides before sharing a session.

```js
wu.override('catalog', 'http://localhost:4101');
```

Reference: `src/core/wu-overrides.js`.

<span class="section-anchor" id="section-12"></span>

## wu.removeOverride

Removes a URL override.

`wu.removeOverride(name): void`

- **Parameters:** Exact app name.
- **Returns:** void
- **Errors:** The system validates domains and configuration; an override is not automatic remounting.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Remove development overrides before sharing a session.

```js
wu.removeOverride('catalog');
```

Reference: `src/core/wu-overrides.js`.

<span class="section-anchor" id="section-13"></span>

## wu.getOverrides

Queries active URL overrides.

`wu.getOverrides(): Record<string,string>`

- **Parameters:** No arguments.
- **Returns:** Record<string,string>
- **Errors:** The system validates domains and configuration; an override is not automatic remounting.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Remove development overrides before sharing a session.

```js
console.log(wu.getOverrides());
```

Reference: `src/core/wu-overrides.js`.

<span class="section-anchor" id="section-14"></span>

## wu.clearOverrides

Removes all active overrides.

`wu.clearOverrides(): void`

- **Parameters:** No arguments.
- **Returns:** void
- **Errors:** The system validates domains and configuration; an override is not automatic remounting.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Remove development overrides before sharing a session.

```js
wu.clearOverrides();
```

Reference: `src/core/wu-overrides.js`.

<span class="section-anchor" id="section-15"></span>

## normalizeStyleMode

Normalizes style configuration aliases.

`normalizeStyleMode(mode): string | undefined`

- **Parameters:** Mode string or undefined.
- **Returns:** none→isolated; own-only→fully-isolated; other values pass through without validation.
- **Errors:** Does not itself validate whether the manifest supports the mode.
- **Permissions:** Pure function; grants no permissions.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
import { normalizeStyleMode } from 'wu-framework';
console.log(normalizeStyleMode('own-only'));
```

Reference: `src/core/wu-sandbox.js`.

<span class="section-anchor" id="section-16"></span>

## resolveDomOwnership

Resolves explicit ownership and nativeShadow/framework aliases.

`resolveDomOwnership(options?): "wu" | "app" | "light"`

- **Parameters:** domOwnership takes precedence, then nativeShadow; Lit selects app by default.
- **Returns:** Effective ownership.
- **Errors:** Creates no Shadow DOM and does not validate whether a renderer implements its boundary.
- **Permissions:** Configuration function; not a security control.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
import { resolveDomOwnership } from 'wu-framework';
console.log(resolveDomOwnership({ framework: 'lit' }));
```

Reference: `src/core/wu-sandbox.js`.

<span class="section-anchor" id="section-17"></span>

## wu.tagStyleAsApp

Attributes a style/link sheet to an application for the CSS bridge.

`wu.tagStyleAsApp(element, appName): void`

- **Parameters:** style/link element and app name.
- **Returns:** void.
- **Errors:** Attribution does not replace manifest styleMode.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Remove the sheet when its owner ends.

```js
const style = document.createElement('style');
style.textContent = ':host { color: var(--accent); }';
wu.tagStyleAsApp(style, 'catalog');
document.head.append(style);
```

Reference: `src/core/wu-core.js`.

<span class="section-anchor" id="section-18"></span>

## new WuCache

Creates an LRU cache with TTL and optional storage.

`new WuCache(options?): WuCache`

- **Parameters:** maxSize in MB; maxItems; TTL in ms; persistent and storage memory/localStorage/sessionStorage.
- **Returns:** Cache instance.
- **Errors:** An oversized entry or operation limit may prevent storage.
- **Permissions:** Host; do not use persistent storage as authorization.
- **Cleanup:** cache.clear() releases entries and its persistent namespace.

```js
import { WuCache } from 'wu-framework';
const cache = new WuCache({ maxSize: 2, maxItems: 20, defaultTTL: 60000, storage: 'memory' });
```

Reference: `src/core/wu-cache.js`.

<span class="section-anchor" id="section-19"></span>

## WuCache.get

Reads an unexpired entry and updates its LRU order.

`cache.get(key): unknown | null`

- **Parameters:** Entry key.
- **Returns:** Saved value, or null for absence, expiration, or rate limit.
- **Errors:** null does not distinguish a miss, expiration, and cooldown; check metrics.
- **Permissions:** Access to the owned cache; store grants do not apply.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
const result = cache.get('catalog-result');
```

An in-memory read returns the saved reference; it is not a separate snapshot like WuStore.

Reference: `src/core/wu-cache.js`.

<span class="section-anchor" id="section-20"></span>

## WuCache.set

Stores a value and applies space and expiration limits.

`cache.set(key, value, ttl?): boolean`

- **Parameters:** Key, value, and TTL in ms; ttl=0 uses defaultTTL because of || selection.
- **Returns:** true if stored; false for size, error, or rate limit.
- **Errors:** Catches failures and returns false; storage quota may limit persistence.
- **Permissions:** Host; validate which data you persist.
- **Cleanup:** delete(key) removes one entry; clear() removes all.

```js
const cached = cache.set('catalog-result', { count: 12 }, 30000);
```

Reference: `src/core/wu-cache.js`.

<span class="section-anchor" id="section-21"></span>

## WuCache.delete

Deletes an entry from memory and configured backing storage.

`cache.delete(key): void`

- **Parameters:** Exact key.
- **Returns:** void
- **Errors:** Persistence depends on storage availability and quota.
- **Permissions:** Cache owner's authority.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
cache.delete('catalog-result');
```

Reference: `src/core/wu-cache.js`.

<span class="section-anchor" id="section-22"></span>

## WuCache.clear

Empties this instance's cache and configured storage.

`cache.clear(): void`

- **Parameters:** No arguments.
- **Returns:** void
- **Errors:** Persistence depends on storage availability and quota.
- **Permissions:** Cache owner's authority.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
cache.clear();
```

Reference: `src/core/wu-cache.js`.

<span class="section-anchor" id="section-23"></span>

## WuCache.getStats

Queries hits, misses, evictions, sizes, and rate limiting.

`cache.getStats(): object`

- **Parameters:** No arguments.
- **Returns:** object
- **Errors:** Persistence depends on storage availability and quota.
- **Permissions:** Cache owner's authority.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.log(cache.getStats());
```

Reference: `src/core/wu-cache.js`.

<span class="section-anchor" id="section-24"></span>

## WuCache.getRateLimitStatus

Queries whether operations are in cooldown and their quota.

`cache.getRateLimitStatus(): object`

- **Parameters:** No arguments.
- **Returns:** object
- **Errors:** Persistence depends on storage availability and quota.
- **Permissions:** Cache owner's authority.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.log(cache.getRateLimitStatus());
```

Reference: `src/core/wu-cache.js`.

<span class="section-anchor" id="section-25"></span>

## wu.getStats

Summarizes core subsystem state and metrics.

`wu.getStats(): object`

- **Parameters:** No arguments.
- **Returns:** Diagnostic object.
- **Errors:** Does not replace a mount test or HTTP check.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.log(wu.getStats());
```

Reference: `src/core/wu-core.js`.

<span class="section-anchor" id="section-26"></span>

## wu.getManifestDiagnostics

Reads declarative dependency errors between apps.

`wu.getManifestDiagnostics(): WuManifestImportDiagnostic[]`

- **Parameters:** No arguments; depends on import preflight.
- **Returns:** Diagnostic list by consumer/import/provider.
- **Errors:** Does not automatically check every transitive bundle import.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.table(wu.getManifestDiagnostics());
```

Reference: `src/core/wu-core.js`.

<span class="section-anchor" id="section-27"></span>

## wu.showInspector

Opens the visual inspector loaded on demand.

`wu.showInspector(): Promise<{ close(): void } | null>`

- **Parameters:** No arguments.
- **Returns:** close handle, or null if not opened.
- **Errors:** Chunk loading or the DOM environment may prevent opening.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** close() or wu.hideInspector() removes the overlay.

```js
const inspector = await wu.showInspector();
// Al cerrar tu herramienta:
inspector?.close();
```

Reference: `src/core/wu-core.js`.

<span class="section-anchor" id="section-28"></span>

## wu.hideInspector

Closes the inspection overlay if present.

`wu.hideInspector(): Promise<void>`

- **Parameters:** No arguments.
- **Returns:** Closure promise.
- **Errors:** Does not delete apps or store data.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Removes the diagnostic interface.

```js
await wu.hideInspector();
```

Reference: `src/core/wu-core.js`.

<span class="section-anchor" id="section-29"></span>

## wu.performance.startMeasure

Marks the start of an app-specific or global duration.

`wu.performance.startMeasure(name, appName?): void`

- **Parameters:** Measurement name; appName defaults to global.
- **Returns:** void.
- **Errors:** Disabled configuration skips recording.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Finish with endMeasure using the same name/app pair.

```js
wu.performance.startMeasure('load-catalog', 'catalog');
```

Reference: `src/core/wu-performance.js`.

<span class="section-anchor" id="section-30"></span>

## wu.performance.endMeasure

Ends a duration and publishes it to metrics/User Timing when enabled.

`wu.performance.endMeasure(name, appName?): number`

- **Parameters:** Same name/app as startMeasure.
- **Returns:** Milliseconds; 0 without a start mark.
- **Errors:** Missing mark returns 0 rather than inventing a duration.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Removes this measurement's start mark.

```js
const ms = wu.performance.endMeasure('load-catalog', 'catalog');
```

Reference: `src/core/wu-performance.js`.

<span class="section-anchor" id="section-31"></span>

## wu.performance.generateReport

Aggregates instance performance statistics.

`wu.performance.generateReport(): object`

- **Parameters:** No arguments.
- **Returns:** object
- **Errors:** User Timing availability depends on the environment.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.log(wu.performance.generateReport());
```

Reference: `src/core/wu-performance.js`.

<span class="section-anchor" id="section-32"></span>

## wu.performance.getMetrics

Reads metrics for a specific app.

`wu.performance.getMetrics(appName): object | null`

- **Parameters:** Exact name; null if no measurements exist.
- **Returns:** object | null
- **Errors:** User Timing availability depends on the environment.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.log(wu.performance.getMetrics('catalog'));
```

Reference: `src/core/wu-performance.js`.

<span class="section-anchor" id="section-33"></span>

## wu.performance.getAllMetrics

Reads metrics for every app registered with the measurer.

`wu.performance.getAllMetrics(): object`

- **Parameters:** No arguments.
- **Returns:** object
- **Errors:** User Timing availability depends on the environment.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.log(wu.performance.getAllMetrics());
```

Reference: `src/core/wu-performance.js`.

<span class="section-anchor" id="section-34"></span>

## wu.performance.clearMetrics

Clears measurements for one or all apps.

`wu.performance.clearMetrics(appName?): void`

- **Parameters:** Optional name.
- **Returns:** void
- **Errors:** User Timing availability depends on the environment.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
wu.performance.clearMetrics('catalog');
```

Reference: `src/core/wu-performance.js`.

<span class="section-anchor" id="section-35"></span>

## wu.performance.getDevToolsEntries

Reads User Timing entries emitted by WU.

`wu.performance.getDevToolsEntries(options?): PerformanceEntry[]`

- **Parameters:** type: mark, measure, or all; optional appName.
- **Returns:** PerformanceEntry[]
- **Errors:** User Timing availability depends on the environment.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.table(wu.performance.getDevToolsEntries({ type: 'measure', appName: 'catalog' }));
```

Reference: `src/core/wu-performance.js`.

<span class="section-anchor" id="section-36"></span>

## wu.performance.observe

Listens for new WU User Timing entries using PerformanceObserver.

`wu.performance.observe(callback, { type? }?): () => void`

- **Parameters:** PerformanceEntry callback; type defaults to measure.
- **Returns:** Cleanup; an empty function if the observer is unavailable.
- **Errors:** Missing PerformanceObserver does not throw; callback failures are logged.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** stop() disconnects the observer.

```js
const stop = wu.performance.observe(entry => console.log(entry.duration), { type: 'measure' });
```

Reference: `src/core/wu-performance.js`.

<span class="section-anchor" id="section-37"></span>

## wu.performance.configure

Configures measurement, history limits, User Timing, and thresholds.

`wu.performance.configure(options): void`

- **Parameters:** enabled, maxMeasurements, devtoolsTimeline, and thresholds by name.
- **Returns:** void.
- **Errors:** Exceeding a threshold generates a warning; it does not cancel an operation.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
wu.performance.configure({ enabled: true, maxMeasurements: 100, devtoolsTimeline: true });
```

Reference: `src/core/wu-performance.js`.

<span class="section-anchor" id="section-38"></span>

## wu.errorBoundary.register

Adds a failure classification and recovery handler.

`wu.errorBoundary.register(handler): void`

- **Parameters:** name, canHandle(error), and handle(error,context).
- **Returns:** void.
- **Errors:** Throws if any member is missing; handlers are traversed in order.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Returns no unsubscribe; manage these extensions during the host lifecycle.

```js
wu.errorBoundary.register({ name: 'catalog-error', canHandle: error => error.name === 'CatalogError', async handle(error) { return { recovered: false, action: 'none', message: error.message }; } });
```

The default generic fallback may precede handlers added later. Check ordering before relying on this registration.

Reference: `src/core/wu-error-boundary.js`.

<span class="section-anchor" id="section-39"></span>

## wu.errorBoundary.handle

Classifies a failure and obtains a recovery decision.

`wu.errorBoundary.handle(error, context?): Promise<object>`

- **Parameters:** Error and context; the core interprets some actions during mount.
- **Returns:** Result with recovered and action, plus handler information.
- **Errors:** An action name does not itself change URL, timeout, or permissions.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Recovery must release the failed attempt before retrying.

```js
const recovery = await wu.errorBoundary.handle(new Error('Entry no disponible'), { appName: 'catalog', phase: 'mount' });
```

Reference: `src/core/wu-error-boundary.js`.

<span class="section-anchor" id="section-40"></span>

## wu.errorBoundary.getErrorLog

Reads recent errors retained by the boundary.

`wu.errorBoundary.getErrorLog(limit?: number): object[]`

- **Parameters:** limit defaults to 10.
- **Returns:** Array of the latest entries.
- **Errors:** Diagnostic memory, not a durable record.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.table(wu.errorBoundary.getErrorLog(5));
```

Reference: `src/core/wu-error-boundary.js`.

<span class="section-anchor" id="section-41"></span>

## wu.errorBoundary.getStats

Summarizes error count, handlers, and types.

`wu.errorBoundary.getStats(): object`

- **Parameters:** No arguments.
- **Returns:** Object with totalErrors, handlers, errorsByType, and recentErrors.
- **Errors:** Excludes failures that never passed through this boundary.
- **Permissions:** Host API; not exposed by the scoped facade.
- **Cleanup:** Creates no subscriptions or persistent processes.

```js
console.log(wu.errorBoundary.getStats());
```

Reference: `src/core/wu-error-boundary.js`.

<span class="section-anchor" id="section-42"></span>

## WuLoadingStrategy

Creates loading strategies and starts idle processing.

`new WuLoadingStrategy(core)`

- **Parameters:** Core instance.
- **Returns:** Coordinator with default strategies.
- **Errors:** Propagates invalid-configuration errors; inspect asynchronous operation results.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** cleanup cancels idle callbacks and resolves the pending queue with null.

```js
import { WuLoadingStrategy } from 'wu-framework';
const strategies = new WuLoadingStrategy(wu);
strategies.cleanup();
```

Reference: `src/core/wu-strategies.js`.

<span class="section-anchor" id="section-43"></span>

## strategies.register

Registers or replaces a loading strategy.

`strategies.register(name, strategy): void`

- **Parameters:** Required strategy.load(appName,config); optional shouldPreload and priority.
- **Returns:** void.
- **Errors:** Throws if strategy.load is not a function.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** The runtime owner manages resources and their cleanup functions.

```js
strategies.register('custom', {
  shouldPreload: false,
  priority: 'low',
  load: async (name, config) => { console.log(name, config); return null; },
});
```

Reference: `src/core/wu-strategies.js`.

<span class="section-anchor" id="section-44"></span>

## strategies.load

Executes the strategy selected by config.strategy.

`strategies.load(appName, config): Promise<unknown>`

- **Parameters:** Name and config; lazy by default.
- **Returns:** Result of the registered load function.
- **Errors:** Unknown strategy logs a warning and falls back to lazy; load errors propagate.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** The runtime owner manages resources and their cleanup functions.

```js
await strategies.load('card', { strategy: 'custom' });
```

Reference: `src/core/wu-strategies.js`.

<span class="section-anchor" id="section-45"></span>

## strategies.preload

Sequentially preloads applications whose strategies request it.

`strategies.preload(apps): Promise<void>`

- **Parameters:** Configuration list with name and strategy.
- **Returns:** Traversal promise; catches individual failures.
- **Errors:** An individual failure is logged and allows continuation to the next app.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** The runtime owner manages resources and their cleanup functions.

```js
await strategies.preload([{ name: 'card', strategy: 'custom' }]);
```

Reference: `src/core/wu-strategies.js`.

<span class="section-anchor" id="section-46"></span>

## strategies.getStats

Queries registered strategies and idle queue size.

`strategies.getStats(): object`

- **Parameters:** No arguments.
- **Returns:** {totalStrategies,strategies,idleQueueSize,isIdle}.
- **Errors:** Local read without side effects.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** The runtime owner manages resources and their cleanup functions.

```js
console.log(strategies.getStats());
```

Reference: `src/core/wu-strategies.js`.

<span class="section-anchor" id="section-47"></span>

## strategies.cleanup

Stops the idle queue and releases pending waits.

`strategies.cleanup(): void`

- **Parameters:** No arguments.
- **Returns:** void.
- **Errors:** Cleanup attempts to complete each wait even if one resolution fails.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** Cancels idle/timer and empties the queue; pending entries resolve null.

```js
strategies.cleanup();
```

Reference: `src/core/wu-strategies.js`.

<span class="section-anchor" id="section-48"></span>

## wu.sandbox.addStyles

Inserts CSS into an existing sandbox.

`wu.sandbox.addStyles(appName, css): void`

- **Parameters:** Name and CSS string.
- **Returns:** void.
- **Errors:** Logs a warning and returns if the sandbox is missing.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** The runtime owner manages resources and their cleanup functions.

```js
wu.sandbox.addStyles('card', ':host{display:block}');
```

The sandbox property is core-managed. Do not call cleanupAll while applications are mounted: use wu.unmount to coordinate lifecycle.

Reference: `src/core/wu-sandbox.js`.

<span class="section-anchor" id="section-49"></span>

## wu.sandbox.loadExternalStyles

Inserts a stylesheet link into the sandbox.

`wu.sandbox.loadExternalStyles(appName, href): void`

- **Parameters:** Name and CSS URL.
- **Returns:** void; does not await stylesheet load.
- **Errors:** Missing sandbox produces a warning. Stylesheet network errors are not returned as a promise.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** The runtime owner manages resources and their cleanup functions.

```js
wu.sandbox.loadExternalStyles('card', '/styles/card.css');
```

The sandbox property is core-managed. Do not call cleanupAll while applications are mounted: use wu.unmount to coordinate lifecycle.

Reference: `src/core/wu-sandbox.js`.

<span class="section-anchor" id="section-50"></span>

## wu.sandbox.getStyleStats

Queries style-bridge statistics.

`wu.sandbox.getStyleStats(): object | null`

- **Parameters:** No arguments.
- **Returns:** Statistics object or null.
- **Errors:** Read without network operations.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** The runtime owner manages resources and their cleanup functions.

```js
console.log(wu.sandbox.getStyleStats());
```

The sandbox property is core-managed. Do not call cleanupAll while applications are mounted: use wu.unmount to coordinate lifecycle.

Reference: `src/core/wu-sandbox.js`.

<span class="section-anchor" id="section-51"></span>

## wu.sandbox.reinjectStyles

Reinjects styles according to the application's isolation mode.

`wu.sandbox.reinjectStyles(appName): Promise<void>`

- **Parameters:** Registered sandbox name.
- **Returns:** Promise<void>.
- **Errors:** Does nothing for a missing sandbox or isolated mode; other modes apply their style selection.
- **Permissions:** Host administration API; not included in a microapp's scoped facade.
- **Cleanup:** The runtime owner manages resources and their cleanup functions.

```js
await wu.sandbox.reinjectStyles('card');
```

The sandbox property is core-managed. Do not call cleanupAll while applications are mounted: use wu.unmount to coordinate lifecycle.

Reference: `src/core/wu-sandbox.js`.

In 4.0, an override without `allowedDomains` accepts only loopback hosts or the page’s hostname. Configure an explicit allowlist for another host. This restriction applies to programmatic overrides and those restored from cookies.