import { R as Runtime, O as OnError, M as Migrated, S as Store } from '../runtime-types-f231H8Gq.js'; import { ReactNode } from 'react'; import { c as Sub } from '../core-sEWVgnpI.js'; import { S as SubscribeHandler } from '../types-CtM4tWPp.js'; import '@standard-schema/spec'; /** * Runtime bridge — expose a `@demlik/tea` runtime running in one chrome context * (typically the background service worker) to consumers in other contexts * (sidepanel, popup, devtools panel) over `chrome.runtime.sendMessage` / * `chrome.runtime.onMessage`. * * Two halves, one channel name string. * * ┌──── background (host) ────┐ ┌──── react surface ────┐ * │ bridgeRuntime(rt, {ch}) │ chrome.* │ useBackgroundRuntime │ * │ ├ observe → broadcast │ ──────────▶ │ ├ hydrate (initial) │ * │ └ onMessage(":dispatch") │ ◀────────── │ └ dispatch (msgs) │ * │ └ onMessage(":hydrate") │ │ │ * └────────────────────────────┘ └───────────────────────┘ * * Wire-shape (single `channel` string, three messages): * * { _tag: channel, msg, state } // background → surfaces (broadcast) * { _tag: `${channel}:hydrate` } // surface → background (request) * { _tag: `${channel}:dispatch`, msg } // surface → background (input) * * The `:hydrate` reply is the current `runtime.getState()` snapshot — * lets a newly-opened surface render the right view BEFORE the next * transition broadcast arrives. * * The bridge is intentionally agnostic to `chrome.runtime.sendMessage` * failure modes (no receiver, sender gone, etc.) — every cross-context send * is fire-and-forget with `.catch(() => {})`. Surfaces that need * delivery guarantees should layer their own retry, not bake it here. */ /** * Options for `bridgeRuntime`: the `channel` name, the required `parseMsg` for * inbound Msgs, and an optional `serialize` for the state sent to surfaces. */ interface BridgeRuntimeOpts { channel: string; /** * REQUIRED parse for inbound `msg` payloads on `:dispatch` envelopes. * Chrome runtime messages are an `unknown` boundary (Inv 8) — the same * JSON/chrome serialization seam the symmetric client side parses via * `BridgeClientOpts.parseMsg`. An untrusted surface can drive the host * reducer with an arbitrary `M`, so the host parses too — never casts. A * `msg` that parses to `null` is dropped: the dispatch never reaches the * reducer and the surface's `dispatch()` rejects with `{ ok: false }`. * * Hosts that trust the dispatch channel and treat the msg as opaque opt * out EXPLICITLY by passing the {@link passThroughMsg} helper — the unsound * cast is then a visible call-site decision, not a silent default. */ parseMsg: (raw: unknown) => M | null; /** * Optional projection from the runtime's live state `S` to a JSON-safe * view `V` that goes over the wire (broadcast + hydrate). Required when * `S` carries non-serializable values (DOM refs, Map, Date, …). * * Identity passthrough by default — existing callers with POJO state pass * `serialize` unset and `V = S`. * * Wire shape with `serialize`: * { _tag: channel, msg, state: serialize(currentState) } // broadcast * { _tag: hydrate } → { state: serialize(currentState) } // hydrate * * Dispatch is NOT affected — it carries `M` end-to-end. Surfaces parse the * `V` they receive (they should pick a type parameter matching the * projection). */ serialize?: (state: S) => V; /** * If > 0, the bridge composes a `historyTracker(runtime, size)` over the * runtime and returns the captured `(msg, state)` backlog in every * `:hydrate` reply. Late subscribers receive recent traffic on connect — * the inspector then sees prior tool calls / phase transitions instead * of just the current state snapshot. * * Defaults to 0 (no tracker, empty backlog). Composition stays opt-in: * the substrate is untouched, the dispatch loop is untouched, and the * bridge attaches the tracker only when this opt is set. Cleanup is * the bridge's responsibility — the disposer returned by `bridgeRuntime` * stops the tracker along with the observer. * * Memory cost: ~size × (msg + state) bytes, in-memory only, dies with * the bridge. Privacy: backlog entries flow to every `:hydrate` reply — * any surface that can hydrate sees them. Do not enable on bridges * carrying user secrets. */ historySize?: number; } /** * Install the bridge for a runtime. Returns a cleanup function that removes * the observer and the chrome listener. * * - **Broadcast:** every (msg, state) transition emits * `{ _tag: channel, msg, state }` via `chrome.runtime.sendMessage`. The * send is fire-and-forget — when no surface is listening, chrome.runtime * rejects with "Could not establish connection. Receiving end does not * exist." which we swallow. If `serialize` is provided, `state` carries * `serialize(state)` instead of the raw state. * - **Hydrate:** `{ _tag: ":hydrate" }` is answered via `sendResponse` with * the current (optionally projected) `runtime.getState()`. If the runtime * is mid-boot (store load not yet resolved), `getState()` throws — we * swallow and reply with `state: null`; surfaces should treat null as * "not ready yet" and wait for the first broadcast. * - **Dispatch:** `{ _tag: ":dispatch", msg }` is parsed through `parseMsg` * (Inv 8 — inbound msgs are an `unknown` boundary) and, if non-null, routes * to `runtime.dispatch`. Returns `true` from the listener so chrome keeps the * message channel open until dispatch's promise settles (we ack with * `{ ok: true }`). A msg that fails the parse is dropped — the reducer never * sees it and we reply `{ ok: false }`. */ declare function bridgeRuntime(runtime: Runtime, { channel, parseMsg, serialize, historySize }: BridgeRuntimeOpts): () => void; /** * The explicit opt-out of inbound msg parsing: an identity pass-through that * casts the raw `unknown` to `M`. Surfaces that gate only on state and treat * the broadcast msg as advisory pass this as `parseMsg` to acknowledge — at * the call site, in the types — that they are NOT parsing the msg boundary. * * This is the same behavior the old optional-`parseMsg` default had, but the * unsound cast now lives at one named, greppable, opt-in seam instead of being * the silent default for everyone. (Inv 8: the boundary parses; this helper is * the documented exception, chosen explicitly.) */ declare function passThroughMsg(raw: unknown): M | null; /** * A surface's handle on the background runtime: hydrate the current state, * dispatch Msgs, and subscribe to state broadcasts. `bridgeClient` and * `bridgeTabClient` return one. */ interface BridgeClient { /** Send the hydrate request; resolves with the initial snapshot (or null * if the host is still booting OR the response failed to parse). Also * primes `getSnapshot()` so React's `useSyncExternalStore` sees the * hydrated value on the next render. */ hydrate(): Promise; /** Send a dispatch envelope; resolves once the host's dispatch settles. */ dispatch(msg: M): Promise; /** Subscribe to broadcasts. Returns a cleanup function. Broadcasts whose * payload fails `parseState` or `parseMsg` are dropped silently — the * listener is not called. Each successful broadcast updates * `getSnapshot()`. */ subscribe(listener: (msg: M | null, state: S) => void): () => void; /** Synchronous accessor for the latest known state, or `null` until the * first successful hydrate or broadcast lands. Required reference stability * for `useSyncExternalStore`: returns the SAME object reference when the * underlying state hasn't changed since the prior call. */ getSnapshot(): S | null; } /** * Options for `bridgeClient`: the `channel` name and the required parsers for * inbound state and Msgs. */ interface BridgeClientOpts { channel: string; /** * REQUIRED parse for inbound `state` payloads (from `:hydrate` reply AND * every broadcast). Chrome runtime messages are an `unknown` boundary * (Inv 8) — the surface is the only party that knows the domain type `S`, * so it owns the boundary parse. Returning `null` drops the payload * silently (subscriber not called; hydrate resolves to `null`). The * parser MUST NOT throw — model rejection as `null`. */ parseState: (raw: unknown) => S | null; /** * REQUIRED parse for inbound `msg` payloads on broadcasts. Chrome runtime * messages are an `unknown` boundary (Inv 8) just like the `state` payload, * so the msg crosses the same JSON serialization seam and must be parsed — * never cast. Returning `null` drops the broadcast silently. * * Surfaces that treat the msg union as advisory and only gate on state opt * out EXPLICITLY by passing the {@link passThroughMsg} helper — the opt-out * is now a visible call-site decision, not a hidden default that lets an * unparsed `unknown` reach listeners typed as `M`. */ parseMsg: (raw: unknown) => M | null; } /** * Create a `BridgeClient` for a popup, side panel or content script, which * talks to the background runtime over `chrome.runtime` messages. */ declare function bridgeClient({ channel, parseState, parseMsg, }: BridgeClientOpts): BridgeClient; /** * Options for `bridgeTabClient`: the target `tabId`, the `channel` name, and * the required parsers. */ interface BridgeTabClientOpts { tabId: number; channel: string; /** * REQUIRED parse for inbound `state` payloads. See `BridgeClientOpts.parseState` * — same contract, same rationale. Chrome runtime messages from a tab are * an `unknown` boundary; the SW client owns the parse. */ parseState: (raw: unknown) => S | null; /** * REQUIRED parse for inbound `msg` payloads. See `BridgeClientOpts.parseMsg` * — same contract, same rationale. Opt out of msg parsing with * {@link passThroughMsg}. */ parseMsg: (raw: unknown) => M | null; } /** * SW-side client of a `bridgeRuntime` hosted in a content script. * * Identical contract to `bridgeClient` (same `BridgeClient` shape). * Differences are confined to transport: * * - `hydrate()` / `dispatch(msg)` send via `chrome.tabs.sendMessage(tabId, …)`. * If the tab is gone, `chrome.tabs.sendMessage` rejects (same shape as * `chrome.runtime.sendMessage` with no receiver) — the promise propagates * the rejection. Callers decide whether to retry, drop, or surface; the * bridge has no opinion. Fire-and-forget posture matches `bridgeRuntime`. * - `subscribe(listener)` registers a `chrome.runtime.onMessage` listener * filtered by both `envelope._tag === channel` AND `sender.tab?.id === tabId`, * so broadcasts from other tabs are ignored (no cross-contamination across * per-tab content-script runtimes). */ declare function bridgeTabClient({ tabId, channel, parseState, parseMsg, }: BridgeTabClientOpts): BridgeClient; /** * React adapters for the background TEA runtime. * * Two layers, both built on the same `bridgeClient`: * * 1. `useBackgroundRuntime(opts)` — direct hook. One bridge client per * call. Surfaces that only have a single consumer mount it inline. * * 2. `createBackgroundRuntimeContext()` → `{ Provider, useDispatch, * useState, useRuntime }` — factory-style React context. Mounts the * bridge client ONCE inside the Provider; child hooks read `state` / * `dispatch` from context. Surfaces that drill `dispatch` through * multiple component layers, or mount `useBackgroundRuntime` more * than once for the same channel, should use this instead. * * Why a factory (not a single global context): * - Type safety: each app types it against its own `S` / `M`. * - Tests can mount fresh contexts per test (no module-level state to * reset). * - Multiple-runtimes case: an app COULD theoretically have two * background-shaped runtimes (e.g. one per channel); the factory * pattern doesn't preclude it. * * Hook lifecycle (`useBackgroundRuntime`) — preserved from the prior * single-export module: * 1. `useSyncExternalStore` subscribes to broadcasts via * `bridgeClient.subscribe`, reading the latest state via * `bridgeClient.getSnapshot`. Reference stability is owned by the * bridge — `getSnapshot` returns the SAME `S` until a new broadcast * overwrites it, so React doesn't loop. * 2. A one-shot `hydrate()` call seeds `latestState` before the first * broadcast arrives. The hydrate side-effect runs in an effect so the * first render shows `null` and the subsequent render flips to the * hydrated snapshot (or stays null if the host is still booting). * 3. `dispatch(msg)` sends `:dispatch` envelopes. * * On unmount: `useSyncExternalStore` removes the listener; the host's * bridge stays installed. * * Canon §3.1: React adapters use `useSyncExternalStore`, not * `useState + useEffect`. `useMachine` and `useRuntime` already follow this * — `useBackgroundRuntime` (and by extension the Provider) does too. One * Way to Do Each Thing. * * NOTE: This is a separate entry from the main `index.ts` so apps that * never need React don't drag react into their type graph. The React * adapter peer-depends on react (you must have it installed in the app). */ /** * Options for `useBackgroundRuntime`: the `channel` name and the required * `parseState`. */ interface UseBackgroundRuntimeOpts { channel: string; /** * REQUIRED parse for inbound `state` payloads. Forwarded to * `bridgeClient` — see `BridgeClientOpts.parseState`. Surfaces own this * because the chrome.runtime boundary is `unknown` (Inv 8). Returning * `null` drops the payload silently. */ parseState: (raw: unknown) => S | null; /** Transport failures reach this sink under `phase: "follow-up"`. * Defaults to the default sink. Background step failures belong to the * background run's own `onError`. Read fresh on each send. */ onError?: OnError; } /** * What `useBackgroundRuntime` returns: the latest `state`, which is `null` * until the first one arrives, and `dispatch`. */ interface UseBackgroundRuntimeResult { /** Latest snapshot from the host. `null` until the first hydrate response * or the first broadcast arrives. Surfaces SHOULD render a placeholder * for the null window. */ state: S | null; /** Send a Msg to the host and return `undefined` immediately. Transport * failures go to `opts.onError`, never a rejected Promise. */ dispatch(msg: M): void; } /** * React hook for an extension surface: it subscribes to the background * runtime's state and returns it with a returnless `dispatch`. Use it in a * popup or side panel component. The bridge still waits for the host internally; * the click handler waits for nothing. Read state for the outcome. */ declare function useBackgroundRuntime({ channel, parseState, onError, }: UseBackgroundRuntimeOpts): UseBackgroundRuntimeResult; /** * What `createBackgroundRuntimeContext` returns: a `Provider`, plus the * `useState`, `useDispatch` and `useRuntime` hooks that read from it. */ interface BackgroundRuntimeContext { /** * Wrap a subtree to share a single background-runtime bridge client. * `opts` is forwarded verbatim to `useBackgroundRuntime` — same channel, * same parse contract. */ Provider: (props: { opts: UseBackgroundRuntimeOpts; children: ReactNode; }) => ReactNode; /** * Returns the dispatch function bound to this Provider's bridge client. * Reference is stable across renders (per `useBackgroundRuntime`'s * `useMemo`), so passing it to memoized children won't churn them. * Returns `undefined`; failures follow the Provider's `opts.onError` contract. */ useDispatch: () => (msg: M) => void; /** * Returns a slice of the latest state. `selector` defaults to identity * (returns the whole `S | null` snapshot). Selectors run on every state * change — surfaces with expensive transforms should memoize the * selector at call site. * * Returns `null` until the first hydrate / broadcast lands when the * selector is identity; for non-identity selectors the return type is * `T` and the caller's selector decides how to handle the pre-hydrate * `null` snapshot. */ useState: { (): S | null; (selector: (state: S | null) => T): T; }; /** * Escape hatch — returns the full `{ state, dispatch }` pair as-is. * Useful for consumers that want both the snapshot and the dispatch * fn in a single hook call (e.g. effects that read state THEN * dispatch in response). * * This is a bridge client view. It returns the same shape as `useBackgroundRuntime`, * just sourced from context instead of mounting a fresh client. */ useRuntime: () => UseBackgroundRuntimeResult; } /** * Create a React context that shares one background-runtime connection across a * component tree. Use it instead of calling `useBackgroundRuntime` in several * components. */ declare function createBackgroundRuntimeContext(): BackgroundRuntimeContext; type AlarmSubData = { readonly alarmName: string; }; /** * Build a Sub runner that dispatches `msgFn(alarm, sub)` when the * `chrome.alarms` alarm named `sub.deps.alarmName` fires. It only listens; * create and clear the alarm with Cmds. */ declare function fromChromeAlarm, M>(msgFn: (alarm: chrome.alarms.Alarm, sub: S) => M | null): SubscribeHandler; /** * Options for `fromChromeMessage`: an optional `filter`, and the `msgFn` that * maps a runtime message to a Msg. */ interface ChromeMessageOpts { /** * Pre-filter — when provided, the factory only dispatches when this * returns `true`. Cheap discriminant checks belong here. */ filter?: (message: unknown) => boolean; msgFn: (message: unknown, sender: chrome.runtime.MessageSender, sub: S) => M | null; } /** * Build a Sub runner that dispatches a Msg for each `chrome.runtime.onMessage` * message that passes the filter. It never sends a response. */ declare function fromChromeMessage(opts: ChromeMessageOpts): SubscribeHandler; /** * Options for `fromChromeStorageChange`: the storage `area`, an optional `keys` * filter, and the `msgFn` that maps the changes to a Msg. */ interface ChromeStorageChangeOpts { area: chrome.storage.AreaName; /** * If provided, only dispatch when at least one of the changed keys * overlaps with this set. Omitting means "any key in the area". */ keys?: readonly string[]; msgFn: (changes: Record, sub: S) => M | null; } /** * Build a Sub runner that dispatches a Msg when keys change in a * `chrome.storage` area. */ declare function fromChromeStorageChange(opts: ChromeStorageChangeOpts): SubscribeHandler; /** The `chrome.tabs` events `fromChromeTabsEvent` can listen to. */ type TabsEventName = "onActivated" | "onUpdated" | "onRemoved"; /** * Options for `fromChromeTabsEvent`: which tab `events` to listen to, whether * to fire once on mount, and the `msgFn` that builds the Msg. */ interface ChromeTabsEventOpts { events: readonly TabsEventName[]; /** * If `true`, the factory dispatches a synthetic `msgFn(sub)` once at * subscribe time — useful for "populate tab list on mount" patterns * where the first emission must not wait for chrome to fire an event. * Default `false`. */ fireOnMount?: boolean; msgFn: (sub: S) => M | null; } /** * Build a Sub runner that dispatches `msgFn(sub)` whenever one of the chosen * `chrome.tabs` events fires. */ declare function fromChromeTabsEvent(opts: ChromeTabsEventOpts): SubscribeHandler; /** * In-memory `chrome.*` mock for tests in this package and any downstream * consumer that wants to test against `chromeStorageStore` behavior without * a real chrome environment. * * Currently exposes `chrome.storage.local`, `chrome.runtime` (sendMessage + * onMessage), and `chrome.tabs` (sendMessage). The `runtime` and `tabs` * surfaces are used by the runtime-bridge tests (`bridge.ts`) to round-trip * envelopes between a host runtime and a surface client (sw↔surface) and * between a sw client and a per-tab content-script runtime (sw↔content). * * Extend additional surfaces (alarms, windows, …) only when real consumer * tests reach for them — earn each surface through a concrete need. */ type StorageChangeListener = (changes: Record, areaName: chrome.storage.AreaName) => void; type AlarmListener = (alarm: chrome.alarms.Alarm) => void; type TabActivatedListener = (info: chrome.tabs.OnActivatedInfo) => void; type TabUpdatedListener = (tabId: number, changeInfo: chrome.tabs.OnUpdatedInfo, tab: chrome.tabs.Tab) => void; type TabRemovedListener = (tabId: number, removeInfo: chrome.tabs.OnRemovedInfo) => void; /** * The in-memory `chrome` stand-in `fakeChrome` returns, with `__test.fire*` * helpers that drive its events from a test. */ interface FakeChrome { storage: { local: chrome.storage.StorageArea; /** * Top-level `chrome.storage.onChanged` event. Fires for ANY area; consumer * filters by the `areaName` arg. Real chrome semantics: every `set` / * `remove` / `clear` that materially changes a key emits a single * `changes` map keyed by the changed keys. */ onChanged: { addListener(listener: StorageChangeListener): void; removeListener(listener: StorageChangeListener): void; hasListener(listener: StorageChangeListener): boolean; hasListeners(): boolean; }; }; runtime: { sendMessage: typeof chrome.runtime.sendMessage; onMessage: typeof chrome.runtime.onMessage; }; tabs: { sendMessage: typeof chrome.tabs.sendMessage; /** * `chrome.tabs.onActivated` — fires when the active tab in a window * changes. The fake only models the listener registry; tests drive * fires via `__test.fireTabActivated(info)`. */ onActivated: { addListener(listener: TabActivatedListener): void; removeListener(listener: TabActivatedListener): void; hasListener(listener: TabActivatedListener): boolean; hasListeners(): boolean; }; /** * `chrome.tabs.onUpdated` — fires when a tab is updated (url, title, * status, etc.). Tests drive fires via `__test.fireTabUpdated(...)`. */ onUpdated: { addListener(listener: TabUpdatedListener): void; removeListener(listener: TabUpdatedListener): void; hasListener(listener: TabUpdatedListener): boolean; hasListeners(): boolean; }; /** * `chrome.tabs.onRemoved` — fires when a tab is closed. Tests drive * fires via `__test.fireTabRemoved(...)`. */ onRemoved: { addListener(listener: TabRemovedListener): void; removeListener(listener: TabRemovedListener): void; hasListener(listener: TabRemovedListener): boolean; hasListeners(): boolean; }; }; /** * `chrome.alarms` — the MV3 periodic timer primitive. The fake tracks * created alarms in a Map keyed by name, models `create` (dedupe by * name) + `clear` (remove from map), and exposes `onAlarm` as a * standard listener registry. Tests drive fires via * `__test.fireAlarm(name)`. */ alarms: { create(name: string, alarmInfo: chrome.alarms.AlarmCreateInfo): void; /** * `chrome.alarms.get(name)` — resolves to the Alarm shape Chrome would * return (with `scheduledTime` synthesized at lookup time), or * undefined if no alarm with that name exists. Mirrors the contract * the `ensureQueueAlarm` SW-module-top-level helper checks ("is this * alarm already present with the right period?") — see * the extension's background entrypoint. */ get(name: string): Promise; clear(name: string): Promise; onAlarm: { addListener(listener: AlarmListener): void; removeListener(listener: AlarmListener): void; hasListener(listener: AlarmListener): boolean; hasListeners(): boolean; }; }; /** * Test helpers — not part of the real chrome surface. Lets tests * simulate a content script issuing `chrome.runtime.sendMessage` from * inside a specific tab (chrome auto-tags `sender.tab.id` in that * direction) and remove a tab so `chrome.tabs.sendMessage` rejects * the way real chrome does when the receiver is gone. */ __test: { /** Simulate a content-script broadcast tagged with `sender.tab.id`. */ sendFromTab(tabId: number, message: unknown): Promise; /** Mark a tab as gone — `chrome.tabs.sendMessage(tabId, …)` will reject. */ removeTab(tabId: number): void; /** Mark a tab as alive (default for any tabId that hasn't been removed). */ addTab(tabId: number): void; /** Fire an alarm — invokes every onAlarm listener with `{ name, ...}`. */ fireAlarm(name: string): void; /** Snapshot the alarm registry — tests assert on created/cleared alarms. */ getAlarms(): readonly string[]; /** Fire `chrome.tabs.onActivated` — drives every listener. */ fireTabActivated(info: chrome.tabs.OnActivatedInfo): void; /** Fire `chrome.tabs.onUpdated` — drives every listener. */ fireTabUpdated(tabId: number, changeInfo: chrome.tabs.OnUpdatedInfo, tab: chrome.tabs.Tab): void; /** Fire `chrome.tabs.onRemoved` — drives every listener. */ fireTabRemoved(tabId: number, removeInfo: chrome.tabs.OnRemovedInfo): void; }; } /** * Create an in-memory fake of the `chrome` APIs this adapter uses. Use it to * test extension machines without a browser. */ declare function fakeChrome(): FakeChrome; /** * @packageDocumentation * @demlik/tea/extension — Chrome service-worker host adapter for @demlik/tea. * * Substrate-level companion to @demlik/tea/do (Durable Objects) and * @demlik/tea/react (React). Lets a chrome service worker run a @demlik/tea * machine with persistence backed by chrome.storage. * * Single export: chromeStorageStore(key, area?). Apps register chrome.* * listeners themselves and call runtime.dispatch from inside the handler — * those wiring patterns are app-specific (different extensions register * different listener sets, with different Msg adapters), so we don't * abstract them here until the shape stabilizes across consumers. */ /** * `Store` backed by `chrome.storage.local` (or any compatible * `StorageArea`). JSON.stringify on save, JSON.parse on load. Returns `null` * (typed as `unknown` per `Store.load` contract) when the key is absent. * * Throws on the structural layer if the stored value is malformed (non-string * at the key, or unparseable JSON) — matches @demlik/tea/do's "throw at boot via * store.load" contract so tea's `run()` surfaces it predictably. The * `parse` callback handles the semantic layer (shape mismatch → return * `refuse(reason)`, nothing saved → `null`); it must NOT throw, per the * `Store.migrate` contract. A throw or a refusal makes `ready` reject * with `StoreRefusedError`, and nothing is saved. * * `parse` is REQUIRED because chrome.storage is a real serialization boundary * — JSON to disk, then back — and the structural type of what comes back is * `unknown`. The caller (extension code that knows `S`) is the only party * with enough information to write the parse. There is no honest default. * * `area` defaults to `chrome.storage.local` for production. Tests pass a * `fakeChrome().storage.local` in. * * **Not fenced, deliberately (#143).** This is the one shipped factory that * does not implement `FencedStore`, and it opts out rather than faking a * generation counter: `chrome.storage` offers no atomic compare-and-swap and no * cross-context lock, so a version cell here would be read-then-written with a * real race between the two — a fence that reports success while both writers * win, which is worse than no fence. The honest guarantee is the one the * platform gives: a single background service worker per extension is the * single writer, and that is a precondition to keep, not one this store can * enforce. See `docs/explanation/durability-model.md`. */ declare function chromeStorageStore(key: string, parse: (raw: unknown) => Migrated, area?: chrome.storage.StorageArea): Store; export { type BackgroundRuntimeContext, type BridgeClient, type BridgeClientOpts, type BridgeRuntimeOpts, type BridgeTabClientOpts, type ChromeMessageOpts, type ChromeStorageChangeOpts, type ChromeTabsEventOpts, type FakeChrome, type TabsEventName, type UseBackgroundRuntimeOpts, type UseBackgroundRuntimeResult, bridgeClient, bridgeRuntime, bridgeTabClient, chromeStorageStore, createBackgroundRuntimeContext, fakeChrome, fromChromeAlarm, fromChromeMessage, fromChromeStorageChange, fromChromeTabsEvent, passThroughMsg, useBackgroundRuntime };