import { type AddonKeyMatcher } from './metadata-cache'; /** * `type` string the kernel/bridge emits. Exported so consumers can subscribe * manually if they prefer to skip the hook/wire helper. Matches * `bridge.WSManifestChangedType` in metacore-kernel. */ export declare const ADDON_MANIFEST_CHANGED_TYPE: "ADDON_MANIFEST_CHANGED"; /** * Shape of the WebSocket message the kernel emits. The keys mirror the * `bridge.manifestChangedPayload` map in metacore-kernel/bridge — keep them * in sync if the bridge ever evolves. */ export interface AddonManifestChangedMessage { type: typeof ADDON_MANIFEST_CHANGED_TYPE; payload: { orgId?: string; addonKey: string; oldHash?: string; newHash?: string; version?: string; timestamp?: string; }; } /** * Structural client contract. The SDK's `@asteby/metacore-websocket` * provider exposes `subscribe(type, handler)` (see `useWebSocket().subscribe`) * that satisfies this interface — but any object with a compatible method * works, so hosts that wrap their own transport (link's MQTT bridge, the * kitchen-display ZeroMQ stub, …) can plug in without depending on the * SDK websocket package. */ export interface ManifestHotSwapClient { subscribe: (type: string, handler: (message: AddonManifestChangedMessage) => void) => () => void; } export interface WireHotSwapInvalidationOptions { /** * Optional matcher overriding the default cache-key heuristic * (see `defaultAddonKeyMatcher`). Hosts that namespace cached * `model` keys under prefixes other than `${addonKey}.|:|/` should * supply one. */ matcher?: AddonKeyMatcher; /** * Optional side-effect hook invoked after the cache invalidation. * Useful for hosts that want to log/observe hot-swaps or trigger a * `window.location.reload()` when the running addon's bundle hash * changes (see the module-level comment above for the trade-off). * `removed` is the number of cache entries flushed for this addon, or * `-1` when the scoped matcher found nothing and the whole metadata * cache was cleared as a fallback (see `wireHotSwapInvalidation`). */ onSwap?: (msg: AddonManifestChangedMessage, removed: number) => void; } /** * Imperative wire-up — no React required. Hosts that own a long-lived * WebSocket client (link, ops, the kitchen-display Tauri shell) call this * once at boot, after the client has been created. The returned function * unsubscribes; most hosts will never call it because the subscription * lives for the lifetime of the app. * * const ws = createWebSocket(...) * const unsubscribe = wireHotSwapInvalidation(ws) * // …later, if needed: * unsubscribe() * * Accepts `undefined` so the call site does not need to branch when the * client is constructed lazily — it returns a no-op unsubscribe. */ export declare function wireHotSwapInvalidation(client: ManifestHotSwapClient | undefined | null, options?: WireHotSwapInvalidationOptions): () => void; /** * React-flavoured wrapper around {@link wireHotSwapInvalidation}. Mount it * once high in the tree (typically next to the WebSocket provider) so the * subscription lifetime matches the host shell. Passing `undefined` for * the client is supported — the hook becomes a no-op until a real client * is available, mirroring how `useWebSocket().subscribe` behaves before * the socket opens. * * function HostShell() { * const ws = useWebSocket() * useManifestHotSwapSubscriber(ws) * return * } */ export declare function useManifestHotSwapSubscriber(client: ManifestHotSwapClient | undefined | null, options?: WireHotSwapInvalidationOptions): void; //# sourceMappingURL=manifest-hotswap-subscriber.d.ts.map