@voltro/client 0.81.0 → 0.82.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.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,26 @@
1
+ import { applyPairing } from '@voltro/protocol';
2
+ import { clearPairing } from '@voltro/protocol';
1
3
  import { ClientDescriptor } from '@voltro/protocol';
2
4
  import { ClipboardEvent as ClipboardEvent_2 } from 'react';
3
5
  import { Context } from 'react';
4
6
  import { DragEvent as DragEvent_2 } from 'react';
5
7
  import { Effect } from 'effect';
8
+ import { errorMessage } from '@voltro/protocol';
9
+ import { errorTag } from '@voltro/protocol';
6
10
  import { EventDescriptor as EventDescriptor_2 } from '@voltro/protocol';
7
11
  import { Fiber } from 'effect';
8
12
  import { ManagedRuntime } from 'effect';
13
+ import { Pairing } from '@voltro/protocol';
14
+ import { PAIRING_HOST } from '@voltro/protocol';
15
+ import { PAIRING_SCHEME } from '@voltro/protocol';
16
+ import { PAIRING_STORAGE_KEY } from '@voltro/protocol';
17
+ import { pairingLink } from '@voltro/protocol';
18
+ import { PairingStorage } from '@voltro/protocol';
19
+ import { parsePairingLink } from '@voltro/protocol';
9
20
  import { ParseResult } from 'effect';
10
21
  import { ReactElement } from 'react';
11
22
  import { ReactNode } from 'react';
23
+ import { readPairing } from '@voltro/protocol';
12
24
  import { Rpc } from '@effect/rpc';
13
25
  import { RpcClient } from '@effect/rpc';
14
26
  import { RpcClientError } from '@effect/rpc';
@@ -251,6 +263,8 @@ export declare interface ApiHooks<P extends ProcedureTypeMap> {
251
263
  readonly useAction: <Tag extends ActionTag<P>>(tag: Tag) => ActionState<ProcedureInput<P[Tag]>, ProcedureOutput<P[Tag]>>;
252
264
  }
253
265
 
266
+ export { applyPairing }
267
+
254
268
  /**
255
269
  * Apply preload seeds from the hydration payload, BEFORE the first client
256
270
  * render. Idempotent (a Map upsert) so a re-hydration or a repeated key is
@@ -337,6 +351,25 @@ export declare interface AutoApplyTarget {
337
351
  readonly relations?: TargetRelations | undefined;
338
352
  }
339
353
 
354
+ export declare interface BiometricSource {
355
+ readonly available: () => Promise<boolean>;
356
+ readonly authenticate: (reason: string) => Promise<boolean>;
357
+ }
358
+
359
+ /** The browser's `navigator.onLine` + its events. Optimistic where the API is
360
+ * absent (server render), because the real value arrives on the first commit
361
+ * and a page that hydrates as "offline" is wrong for every reader online. */
362
+ export declare const browserOnlineSource: OnlineSource;
363
+
364
+ /**
365
+ * The browser adapter. `@voltro/web` installs it at mount; it is also the
366
+ * lazy default so hooks answer sensibly in a tab that never called
367
+ * `installPlatform` (and under jsdom, where the shell reads as `'test'`).
368
+ */
369
+ export declare const browserPlatform: (overrides?: Partial<PlatformAdapterInput>) => PlatformAdapter;
370
+
371
+ export declare const browserStoreStorage: StoreStorageProvider;
372
+
340
373
  /**
341
374
  * Build one api's runtime + rpc client + subscription cache over a WebSocket.
342
375
  *
@@ -507,7 +540,10 @@ export declare interface CacheSnapshot<T> {
507
540
  readonly revision: number;
508
541
  /** Wall-clock ms when the most recent server delta was emitted; undefined for snapshots. */
509
542
  readonly emittedAt: number | undefined;
510
- /** Error from the underlying stream (if no snapshot has ever arrived). */
543
+ /** Why the stream failed, if no snapshot has ever arrived — the value the
544
+ * api's error bus carries in `RpcError.error` for the same failure: the
545
+ * declared error itself (match on `_tag`), an `RpcClientError` for a
546
+ * transport failure, or the defect. Never an Effect `Cause`. */
511
547
  readonly error: unknown | undefined;
512
548
  /** Number of live optimistic patches currently applied. */
513
549
  readonly pendingPatches: number;
@@ -521,6 +557,9 @@ export declare const canCall: (subjectScopes: ReadonlyArray<string>, required: s
521
557
  * An empty requirement is allowed (nothing is being demanded). Pure. */
522
558
  export declare const canCallAny: (subjectScopes: ReadonlyArray<string>, required: ReadonlyArray<string>) => boolean;
523
559
 
560
+ /** Derive capabilities from the ports present; `overrides` narrows or widens. */
561
+ export declare const capabilitiesOf: (input: Omit<PlatformAdapterInput, "capabilities">, overrides?: Partial<PlatformCapabilities>) => PlatformCapabilities;
562
+
524
563
  /** Structural mirror of @voltro/cli's manifest column — the client stays
525
564
  * decoupled from the (node-only) cli package. */
526
565
  export declare interface CapabilityColumn {
@@ -609,11 +648,16 @@ export declare interface CapabilityTable {
609
648
  readonly editable?: boolean;
610
649
  }
611
650
 
651
+ /** Fold an incremental update into the value a cell held. */
652
+ export declare type CellMerger = (column: string, prevValue: unknown, update: unknown) => unknown;
653
+
612
654
  export declare const clearClientDiagnostics: () => void;
613
655
 
614
656
  /** Clear the buffer (devtools "Clear" button). */
615
657
  export declare const clearMutations: () => void;
616
658
 
659
+ export { clearPairing }
660
+
617
661
  /** Drop successfully-sent entries (call after a drain to compact the queue). */
618
662
  export declare const clearSent: (queue: Outbox) => Outbox;
619
663
 
@@ -895,6 +939,9 @@ export declare const createAnalytics: <const E extends ReadonlyArray<EventDescri
895
939
  */
896
940
  export declare const createHooks: <Procedures extends ProcedureTypeMap>(apiName: string) => ApiHooks<Procedures>;
897
941
 
942
+ /** The installed adapter, or the lazily-built browser default. */
943
+ export declare const currentPlatform: () => PlatformAdapter;
944
+
898
945
  export declare interface DataCopilotState<Row = Record<string, unknown>> {
899
946
  /** Ask a natural-language question. Resolves the typed answer (also stored
900
947
  * on `.answer`); rejects only on a transport / execution error. */
@@ -948,12 +995,81 @@ export declare const decideAccess: (guards: ReadonlyArray<ManifestGuard> | undef
948
995
  */
949
996
  export declare const decodeFieldIssues: (error: ParseResult.ParseError) => ReadonlyArray<FieldIssue>;
950
997
 
998
+ /**
999
+ * The descriptor a `*.deepLink.ts` file default-exports. `_tag` marks it for
1000
+ * the (future) discovery walk without relying on structural guessing.
1001
+ */
1002
+ export declare interface DeepLinkDescriptor<Pattern extends string = string> {
1003
+ readonly _tag: 'VoltroDeepLink';
1004
+ readonly pattern: Pattern;
1005
+ readonly handler: DeepLinkHandler<Pattern>;
1006
+ }
1007
+
1008
+ /** A handler for a matched deep link. May be async (navigation can await). */
1009
+ export declare type DeepLinkHandler<Pattern extends string> = (params: DeepLinkParams<Pattern>) => void | Promise<void>;
1010
+
1011
+ /**
1012
+ * Substitute captured params back into a pattern, producing a concrete path.
1013
+ *
1014
+ * `deepLinkHref('/orders/:id', { id: '42' })` → `'/orders/42'`. This is the
1015
+ * inverse of {@link matchDeepLink} and it exists because a DERIVED deep link
1016
+ * (one the generator built from an Expo Router screen) navigates to the very
1017
+ * path it matched — the screen's own route.
1018
+ *
1019
+ * It lives here rather than being emitted into the generated module on purpose:
1020
+ * generated code that carries logic is logic nothing tests. A missing param
1021
+ * would silently produce `/orders/` (a different, probably-existing route), so
1022
+ * it throws instead.
1023
+ */
1024
+ export declare const deepLinkHref: (pattern: string, params: Readonly<Record<string, string>>) => string;
1025
+
1026
+ /**
1027
+ * The params a pattern yields, inferred from its `:name` segments.
1028
+ *
1029
+ * `'/orders/:id'` → `{ id: string }`, `'/t/:tenant/u/:user'` →
1030
+ * `{ tenant: string; user: string }`, a param-less pattern →
1031
+ * `Record<string, never>`. This is what makes `handler: ({ id }) => …`
1032
+ * type-check against exactly the params the pattern declares.
1033
+ */
1034
+ export declare type DeepLinkParams<Pattern extends string> = Pattern extends `${string}:${infer Param}/${infer Rest}` ? {
1035
+ readonly [K in Param | keyof DeepLinkParams<`/${Rest}`>]: string;
1036
+ } : Pattern extends `${string}:${infer Param}` ? {
1037
+ readonly [K in Param]: string;
1038
+ } : Record<string, never>;
1039
+
1040
+ /** Inbound URLs: the one the app was opened with, and the ones that arrive
1041
+ * while it runs (universal links, custom schemes, protocol handlers). */
1042
+ export declare interface DeepLinkSource {
1043
+ readonly initialUrl: () => Promise<string | null>;
1044
+ readonly subscribe: (onUrl: (url: string) => void) => () => void;
1045
+ }
1046
+
1047
+ /**
1048
+ * Declare a deep link.
1049
+ *
1050
+ * ```ts
1051
+ * export default defineDeepLink({
1052
+ * pattern: '/orders/:id',
1053
+ * handler: ({ id }) => navigateTo(`/orders/${id}`),
1054
+ * })
1055
+ * ```
1056
+ */
1057
+ export declare const defineDeepLink: <const Pattern extends string>(config: DefineDeepLinkConfig<Pattern>) => DeepLinkDescriptor<Pattern>;
1058
+
1059
+ export declare interface DefineDeepLinkConfig<Pattern extends string> {
1060
+ readonly pattern: Pattern;
1061
+ readonly handler: DeepLinkHandler<Pattern>;
1062
+ }
1063
+
951
1064
  /** All defined stores, in definition order. */
952
1065
  export declare const definedStores: () => ReadonlyArray<StoreHandle<never>>;
953
1066
 
954
1067
  /** Declare a typed analytics event. */
955
1068
  export declare const defineEvent: <const Name extends string, A, I>(name: Name, payload: Schema.Schema<A, I>) => EventDescriptor<Name, A>;
956
1069
 
1070
+ /** Fill in the derived capabilities. Adapters are built through this. */
1071
+ export declare const definePlatform: (input: PlatformAdapterInput) => PlatformAdapter;
1072
+
957
1073
  /**
958
1074
  * Define a store.
959
1075
  *
@@ -991,10 +1107,63 @@ export declare const deriveEntityAdmins: (manifest: CapabilityManifest) => Reado
991
1107
 
992
1108
  export declare const disableClientDiagnosticsPersistence: () => void;
993
1109
 
1110
+ /**
1111
+ * Match `path` against the table and RUN the winning handler. Returns the
1112
+ * captured params, or `null` when nothing matched.
1113
+ *
1114
+ * This exists because `matchFirstDeepLink` alone is not usable for the thing it
1115
+ * is for. Its descriptors come from a HETEROGENEOUS array, so `Pattern` erases
1116
+ * to `string`, and `DeepLinkParams<string>` is `Record<string, never>` — the
1117
+ * handler it hands back rejects the params it hands back with it. Every caller
1118
+ * had to cast, and the template's did not, which nothing noticed because no
1119
+ * harness typechecked the template.
1120
+ *
1121
+ * The erasure happens ONCE, here, where it is defensible: at runtime a matched
1122
+ * pattern's params ARE `Record<string, string>`, and the per-pattern type is a
1123
+ * derivation of a literal the caller no longer has. `runDeepLink` keeps the
1124
+ * fully-typed single-descriptor path for a caller that does.
1125
+ */
1126
+ export declare const dispatchDeepLink: (descriptors: ReadonlyArray<DeepLinkDescriptor>, path: string) => Record<string, string> | null;
1127
+
994
1128
  /** The document's locale per the framework contract (`<html lang>`); `'en'`
995
1129
  * outside a browser. Primary subtag only (`de-AT` → `de`). */
996
1130
  export declare const documentLocale: () => string;
997
1131
 
1132
+ /** What the worker runs on `sync`: load, drain over HTTP, save. */
1133
+ export declare const drainOutboxInWorker: (options: {
1134
+ readonly url: string;
1135
+ readonly persistence?: OutboxPersistence;
1136
+ readonly headers?: Readonly<Record<string, string>>;
1137
+ }) => Promise<DrainOverHttpResult>;
1138
+
1139
+ /** Replay every replayable entry over HTTP, in order; stop at the first transient failure. */
1140
+ export declare const drainOutboxOverHttp: (options: DrainOverHttpOptions) => Promise<DrainOverHttpResult>;
1141
+
1142
+ export declare interface DrainOverHttpOptions {
1143
+ /** The api's rpc endpoint — `/_voltro/api/<name>/rpc` behind the web proxy. */
1144
+ readonly url: string;
1145
+ readonly queue: Outbox;
1146
+ readonly fetch?: (url: string, init: {
1147
+ method: 'POST';
1148
+ headers: Record<string, string>;
1149
+ body: string;
1150
+ }) => Promise<{
1151
+ readonly ok: boolean;
1152
+ readonly status: number;
1153
+ readonly json: () => Promise<unknown>;
1154
+ }>;
1155
+ /** Extra headers on every request — the session header, typically. */
1156
+ readonly headers?: Readonly<Record<string, string>>;
1157
+ readonly isConflict?: (error: unknown) => boolean;
1158
+ }
1159
+
1160
+ export declare interface DrainOverHttpResult {
1161
+ readonly queue: Outbox;
1162
+ readonly sent: number;
1163
+ readonly failed: number;
1164
+ readonly conflicts: number;
1165
+ }
1166
+
998
1167
  /** The empty value — what an unfilled rich-text field holds. */
999
1168
  export declare const emptyRichTextDocument: RichTextDocument;
1000
1169
 
@@ -1077,6 +1246,10 @@ declare interface EntryState<T> {
1077
1246
  /** Compares two selector results. Return true to keep the previous value. */
1078
1247
  export declare type Equals<T> = (a: T, b: T) => boolean;
1079
1248
 
1249
+ export { errorMessage }
1250
+
1251
+ export { errorTag }
1252
+
1080
1253
  export declare interface EventCatalog {
1081
1254
  readonly names: ReadonlyArray<string>;
1082
1255
  readonly get: (name: string) => EventDescriptor<string, unknown> | undefined;
@@ -1538,6 +1711,48 @@ export declare const getMutations: () => ReadonlyArray<MutationEvent>;
1538
1711
  */
1539
1712
  export declare const globalContext: <T>(key: string, initial: T) => Context<T>;
1540
1713
 
1714
+ export declare interface IDBDatabaseLike {
1715
+ readonly objectStoreNames: {
1716
+ contains: (name: string) => boolean;
1717
+ };
1718
+ createObjectStore: (name: string) => unknown;
1719
+ transaction: (store: string, mode: 'readonly' | 'readwrite') => {
1720
+ objectStore: (name: string) => IDBObjectStoreLike;
1721
+ };
1722
+ close: () => void;
1723
+ }
1724
+
1725
+ export declare interface IDBObjectStoreLike {
1726
+ get: (key: string) => IDBRequestLike;
1727
+ put: (value: unknown, key: string) => IDBRequestLike;
1728
+ }
1729
+
1730
+ export declare interface IDBOpenDBRequestLike {
1731
+ onupgradeneeded: ((ev: unknown) => void) | null;
1732
+ onsuccess: ((ev: unknown) => void) | null;
1733
+ onerror: ((ev: unknown) => void) | null;
1734
+ readonly result: IDBDatabaseLike;
1735
+ readonly error?: unknown;
1736
+ }
1737
+
1738
+ export declare interface IDBRequestLike {
1739
+ onsuccess: ((ev: unknown) => void) | null;
1740
+ onerror: ((ev: unknown) => void) | null;
1741
+ readonly result?: unknown;
1742
+ readonly error?: unknown;
1743
+ }
1744
+
1745
+ /** The minimal IndexedDB surface this persistence touches — injectable for tests. */
1746
+ export declare interface IndexedDbLike {
1747
+ readonly open: (name: string, version: number) => IDBOpenDBRequestLike;
1748
+ }
1749
+
1750
+ /** `OutboxPersistence` over IndexedDB — readable from the page AND its worker. */
1751
+ export declare const indexedDbOutboxPersistence: (options?: {
1752
+ readonly name?: string;
1753
+ readonly indexedDB?: IndexedDbLike;
1754
+ }) => OutboxPersistence;
1755
+
1541
1756
  /**
1542
1757
  * The snapshot a coordinator has at construction, frozen and shared.
1543
1758
  *
@@ -1554,6 +1769,16 @@ export declare const globalContext: <T>(key: string, initial: T) => Context<T>;
1554
1769
  */
1555
1770
  export declare const INITIAL_RECOVERY_SNAPSHOT: RecoverySnapshot;
1556
1771
 
1772
+ /**
1773
+ * Install the platform adapter. Call it once, before the first render — on
1774
+ * React Native after the persistence adapter has hydrated, because this also
1775
+ * installs the adapter's `storage` as the persisted-store backing.
1776
+ */
1777
+ export declare const installPlatform: (adapter: PlatformAdapter) => void;
1778
+
1779
+ /** Is an adapter installed (as opposed to the lazy browser default)? */
1780
+ export declare const isPlatformInstalled: () => boolean;
1781
+
1557
1782
  /** True when `value` is structurally a rich-text document (a cheap render-side
1558
1783
  * guard; the decode remains the boundary). */
1559
1784
  export declare const isRichTextDocument: (value: unknown) => value is RichTextDocument;
@@ -1568,6 +1793,9 @@ export declare const isRichTextDocument: (value: unknown) => value is RichTextDo
1568
1793
  */
1569
1794
  export declare const isSafeHref: (href: string) => boolean;
1570
1795
 
1796
+ /** Is this document running as an installed PWA (standalone display mode)? */
1797
+ export declare const isStandaloneDisplay: () => boolean;
1798
+
1571
1799
  /** Is this the framework's `Unauthenticated`? Matched on `_tag`, the wire
1572
1800
  * contract, rather than on an instance — the error crosses a package boundary
1573
1801
  * and may be re-created by the decoder. */
@@ -1597,6 +1825,15 @@ export declare const isUnauthenticated: (error: unknown) => boolean;
1597
1825
  */
1598
1826
  export declare const isUnresolvedApi: (handle: ApiHandle) => boolean;
1599
1827
 
1828
+ /** Foreground/background transitions — `AppState` on React Native,
1829
+ * `visibilitychange` in a browser, window focus in a desktop shell. */
1830
+ export declare interface LifecycleSource {
1831
+ readonly read: () => LifecycleState;
1832
+ readonly subscribe: (onChange: (state: LifecycleState) => void) => () => void;
1833
+ }
1834
+
1835
+ export declare type LifecycleState = 'active' | 'inactive' | 'background';
1836
+
1600
1837
  declare type Listener = () => void;
1601
1838
 
1602
1839
  /**
@@ -1663,6 +1900,37 @@ export declare const markFailed: (queue: Outbox, id: string, error: unknown) =>
1663
1900
 
1664
1901
  export declare const markSent: (queue: Outbox, id: string) => Outbox;
1665
1902
 
1903
+ /**
1904
+ * Match a `pattern` against a `path`, returning the captured params or `null`
1905
+ * when it does not match. Pure — no navigation, no side effects.
1906
+ *
1907
+ * ```ts
1908
+ * matchDeepLink('/orders/:id', '/orders/42') // → { id: '42' }
1909
+ * matchDeepLink('/orders/:id', '/orders/42/edit') // → null
1910
+ * matchDeepLink('/health', '/health') // → {}
1911
+ * ```
1912
+ *
1913
+ * A `*` segment matches exactly one segment without capturing; a trailing `*`
1914
+ * is not a catch-all (keep the model boringly predictable — one pattern
1915
+ * segment matches one path segment).
1916
+ */
1917
+ export declare const matchDeepLink: <Pattern extends string>(pattern: Pattern, path: string) => DeepLinkParams<Pattern> | null;
1918
+
1919
+ /**
1920
+ * First descriptor whose pattern matches `path`, with its captured params.
1921
+ * Declaration order wins, so list more-specific patterns first — which is why
1922
+ * the generated table puts hand-written `*.deepLink.ts` descriptors ahead of
1923
+ * the router-derived ones.
1924
+ */
1925
+ export declare const matchFirstDeepLink: (descriptors: ReadonlyArray<DeepLinkDescriptor>, path: string) => {
1926
+ readonly descriptor: DeepLinkDescriptor;
1927
+ readonly params: Record<string, string>;
1928
+ } | null;
1929
+
1930
+ /** A token store over process memory — a test double, and the honest answer
1931
+ * for a shell whose secure store is not wired yet (it survives nothing). */
1932
+ export declare const memoryTokenStore: () => TokenStore;
1933
+
1666
1934
  /**
1667
1935
  * One api the client is mounted against: its name, its typed rpc surface, its
1668
1936
  * descriptor map and where to connect.
@@ -1780,6 +2048,29 @@ export declare type MutationStatus = 'pending' | 'success' | 'error';
1780
2048
 
1781
2049
  declare type MutationTag<P extends ProcedureTypeMap> = TagsOfKind<P, 'mutation'>;
1782
2050
 
2051
+ declare type NotificationPermission_2 = 'granted' | 'denied' | 'prompt';
2052
+ export { NotificationPermission_2 as NotificationPermission }
2053
+
2054
+ export declare interface NotificationSurface {
2055
+ readonly permission: () => Promise<NotificationPermission_2>;
2056
+ readonly requestPermission: () => Promise<NotificationPermission_2>;
2057
+ /** The push token/subscription to register with the server — present only
2058
+ * where the shell has a push channel (Expo push token, Web Push). */
2059
+ readonly pushToken?: () => Promise<string | null>;
2060
+ /** Show a local/system notification — present where the shell can. */
2061
+ readonly show?: (notification: {
2062
+ readonly title: string;
2063
+ readonly body?: string;
2064
+ readonly data?: Readonly<Record<string, unknown>>;
2065
+ }) => Promise<void>;
2066
+ }
2067
+
2068
+ /** A reachability signal: a synchronous read plus change notifications. */
2069
+ export declare interface OnlineSource {
2070
+ readonly read: () => boolean;
2071
+ readonly subscribe: (onChange: (online: boolean) => void) => () => void;
2072
+ }
2073
+
1783
2074
  /**
1784
2075
  * The reason a procedure declared itself open, or `undefined` if it did not.
1785
2076
  *
@@ -1831,6 +2122,11 @@ export declare type OptionalInputTag<P extends ProcedureTypeMap> = {
1831
2122
 
1832
2123
  export declare type Outbox = ReadonlyArray<OutboxEntry>;
1833
2124
 
2125
+ export declare const OUTBOX_DB_NAME = "voltro-outbox";
2126
+
2127
+ /** Background Sync's tag — the page registers it, the worker answers it. */
2128
+ export declare const OUTBOX_SYNC_TAG = "voltro:outbox";
2129
+
1834
2130
  export declare interface OutboxControls {
1835
2131
  readonly queue: Outbox;
1836
2132
  readonly enqueue: (tag: string, input: unknown) => void;
@@ -1870,6 +2166,20 @@ export declare interface OutboxPersistence {
1870
2166
 
1871
2167
  export declare type OutboxStatus = 'pending' | 'sent' | 'failed' | 'conflict';
1872
2168
 
2169
+ export { Pairing }
2170
+
2171
+ export { PAIRING_HOST }
2172
+
2173
+ export { PAIRING_SCHEME }
2174
+
2175
+ export { PAIRING_STORAGE_KEY }
2176
+
2177
+ export { pairingLink }
2178
+
2179
+ export { PairingStorage }
2180
+
2181
+ export { parsePairingLink }
2182
+
1873
2183
  /**
1874
2184
  * Parse the widget's markdown-subset SOURCE into a document. Total: every input
1875
2185
  * yields a valid document, because everything unrecognised is text. Not a
@@ -1917,6 +2227,62 @@ export declare interface PersistOptions<S> {
1917
2227
  readonly migrate?: (stored: unknown) => Partial<S> | undefined;
1918
2228
  }
1919
2229
 
2230
+ export declare interface PlatformAdapter {
2231
+ readonly platform: PlatformInfo;
2232
+ readonly capabilities: PlatformCapabilities;
2233
+ /** The WebSocket the api runtime opens — `buildApiRuntime`'s constructor. */
2234
+ readonly webSocket: (url: string, protocols?: string | ReadonlyArray<string>) => WebSocket;
2235
+ /** Backing store for `defineStore({ persist })`; installed via `setStoreStorage`. */
2236
+ readonly storage: StoreStorageProvider;
2237
+ readonly secureStorage: TokenStore;
2238
+ readonly online: OnlineSource;
2239
+ readonly lifecycle: LifecycleSource;
2240
+ readonly links: DeepLinkSource;
2241
+ readonly notifications?: NotificationSurface;
2242
+ readonly updates?: UpdateChannel;
2243
+ readonly biometrics?: BiometricSource;
2244
+ readonly clock: {
2245
+ readonly now: () => number;
2246
+ };
2247
+ /** Shell-specific surfaces, keyed by shell (`tauri`, `electron`, `expo`).
2248
+ * See `useShellExtension`. */
2249
+ readonly extensions?: Readonly<Record<string, unknown>>;
2250
+ }
2251
+
2252
+ /** The adapter minus what `definePlatform` derives. */
2253
+ export declare type PlatformAdapterInput = Omit<PlatformAdapter, 'capabilities'> & {
2254
+ readonly capabilities?: Partial<PlatformCapabilities>;
2255
+ };
2256
+
2257
+ /** What the running shell can do. Derived from the ports an adapter fills in
2258
+ * (`capabilitiesOf`); an adapter may narrow a derived `true` it cannot honour. */
2259
+ export declare interface PlatformCapabilities {
2260
+ readonly offlineStart: boolean;
2261
+ readonly secureTokenStorage: boolean;
2262
+ readonly push: boolean;
2263
+ readonly localNotifications: boolean;
2264
+ readonly updates: boolean;
2265
+ readonly deepLinks: boolean;
2266
+ readonly biometrics: boolean;
2267
+ readonly backgroundSync: boolean;
2268
+ readonly installPrompt: boolean;
2269
+ }
2270
+
2271
+ export declare interface PlatformInfo {
2272
+ readonly kind: PlatformKind;
2273
+ readonly shell: ShellKind;
2274
+ /** True when running as an installed app (a PWA in standalone mode, any
2275
+ * native shell); false in a browser tab. */
2276
+ readonly installed: boolean;
2277
+ /** The app's own version, where the shell knows it (a store build, a
2278
+ * desktop release). Undefined in a browser tab. */
2279
+ readonly appVersion?: string;
2280
+ /** The build the running code came from — what an update feed compares. */
2281
+ readonly buildId?: string;
2282
+ }
2283
+
2284
+ export declare type PlatformKind = 'web' | 'pwa' | 'ios' | 'android' | 'macos' | 'windows' | 'linux' | 'unknown';
2285
+
1920
2286
  /** Options `usePreloadedSubscription` accepts. It OWNS `initialSnapshot` (the
1921
2287
  * preload payload supplies it), so callers pass only `skip` — `fallback` and
1922
2288
  * `initialSnapshot` are its own concern. */
@@ -2115,6 +2481,8 @@ declare type QueryTag<P extends ProcedureTypeMap> = TagsOfKind<P, 'query'>;
2115
2481
 
2116
2482
  export declare type RawTransportStatus = 'connected' | 'disconnected';
2117
2483
 
2484
+ export { readPairing }
2485
+
2118
2486
  /**
2119
2487
  * Did the server attempt this preload, and did it work?
2120
2488
  *
@@ -2246,6 +2614,18 @@ export declare interface RecoverySnapshot {
2246
2614
  readonly mutationReplay: 'unknown' | 'enabled' | 'disabled';
2247
2615
  }
2248
2616
 
2617
+ /** A token store for a shell with nowhere safe to put one. Reads answer
2618
+ * `null`; a write is refused with the reason, never downgraded to plain
2619
+ * storage. The browser's session is an HttpOnly cookie for exactly this
2620
+ * reason — it has no secure store the page can read. */
2621
+ export declare const refusingTokenStore: (reason: string) => TokenStore;
2622
+
2623
+ /** Register the merger `mergeCells` delta ops fold with. The last registration wins. */
2624
+ export declare const registerCellMerger: (merge: CellMerger) => void;
2625
+
2626
+ /** The registered merger, or undefined. */
2627
+ export declare const registeredCellMerger: () => CellMerger | undefined;
2628
+
2249
2629
  /**
2250
2630
  * Make an api's client descriptors visible to a SERVER render.
2251
2631
  *
@@ -2276,6 +2656,9 @@ export declare const requiredScopes: (guards: ReadonlyArray<ManifestGuard> | und
2276
2656
  * module-global flags + any pending grace-period timer). */
2277
2657
  export declare const _resetFrameworkRuntimesWarning: () => void;
2278
2658
 
2659
+ /** Test seam: forget the installed adapter and the cached default. */
2660
+ export declare const resetPlatformForTest: () => void;
2661
+
2279
2662
  /** Drop all applied client-side seeds. Tests only. */
2280
2663
  export declare const resetPreloadSeeds: () => void;
2281
2664
 
@@ -2587,12 +2970,12 @@ export declare const RichTextDocument: Schema.refine<{
2587
2970
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2588
2971
  } | {
2589
2972
  readonly type: "link";
2590
- readonly href: string;
2591
2973
  readonly content: readonly {
2592
2974
  readonly type: "text";
2593
2975
  readonly text: string;
2594
2976
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2595
2977
  }[];
2978
+ readonly href: string;
2596
2979
  })[];
2597
2980
  } | {
2598
2981
  readonly type: "heading";
@@ -2603,12 +2986,12 @@ export declare const RichTextDocument: Schema.refine<{
2603
2986
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2604
2987
  } | {
2605
2988
  readonly type: "link";
2606
- readonly href: string;
2607
2989
  readonly content: readonly {
2608
2990
  readonly type: "text";
2609
2991
  readonly text: string;
2610
2992
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2611
2993
  }[];
2994
+ readonly href: string;
2612
2995
  })[];
2613
2996
  } | {
2614
2997
  readonly type: "blockquote";
@@ -2618,12 +3001,12 @@ export declare const RichTextDocument: Schema.refine<{
2618
3001
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2619
3002
  } | {
2620
3003
  readonly type: "link";
2621
- readonly href: string;
2622
3004
  readonly content: readonly {
2623
3005
  readonly type: "text";
2624
3006
  readonly text: string;
2625
3007
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2626
3008
  }[];
3009
+ readonly href: string;
2627
3010
  })[];
2628
3011
  } | {
2629
3012
  readonly type: "bulletList";
@@ -2635,12 +3018,12 @@ export declare const RichTextDocument: Schema.refine<{
2635
3018
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2636
3019
  } | {
2637
3020
  readonly type: "link";
2638
- readonly href: string;
2639
3021
  readonly content: readonly {
2640
3022
  readonly type: "text";
2641
3023
  readonly text: string;
2642
3024
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2643
3025
  }[];
3026
+ readonly href: string;
2644
3027
  })[];
2645
3028
  }[];
2646
3029
  } | {
@@ -2653,12 +3036,12 @@ export declare const RichTextDocument: Schema.refine<{
2653
3036
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2654
3037
  } | {
2655
3038
  readonly type: "link";
2656
- readonly href: string;
2657
3039
  readonly content: readonly {
2658
3040
  readonly type: "text";
2659
3041
  readonly text: string;
2660
3042
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2661
3043
  }[];
3044
+ readonly href: string;
2662
3045
  })[];
2663
3046
  }[];
2664
3047
  } | {
@@ -2883,6 +3266,14 @@ export declare type RpcErrorKind = 'transport' | 'handler' | 'client' | 'unknown
2883
3266
 
2884
3267
  export declare type RpcErrorListener = (event: RpcError) => void;
2885
3268
 
3269
+ /** The outcome of one rpc HTTP answer: `null` for success, else the error. */
3270
+ export declare const rpcHttpOutcome: (body: unknown) => {
3271
+ readonly ok: true;
3272
+ } | {
3273
+ readonly ok: false;
3274
+ readonly error: unknown;
3275
+ };
3276
+
2886
3277
  /** A call that SUCCEEDED. Carries only its source and tag — there is no payload
2887
3278
  * here on purpose: this channel exists so cross-cutting policy can tell
2888
3279
  * "working again" from "still broken", not so listeners can read data. */
@@ -2893,6 +3284,12 @@ export declare interface RpcSuccess {
2893
3284
 
2894
3285
  export declare type RpcSuccessListener = (event: RpcSuccess) => void;
2895
3286
 
3287
+ /**
3288
+ * Match `path` against a descriptor and, on a hit, invoke its handler with the
3289
+ * captured params. Returns the params (so callers know it matched) or `null`.
3290
+ */
3291
+ export declare const runDeepLink: <Pattern extends string>(descriptor: DeepLinkDescriptor<Pattern>, path: string) => DeepLinkParams<Pattern> | null;
3292
+
2896
3293
  /**
2897
3294
  * Run a sequence. Resolves with a discriminated result rather than rejecting —
2898
3295
  * the same "handled" semantics `useMutation`/`useAction` use, so the call site
@@ -3104,6 +3501,8 @@ export declare const shallow: <T>(a: T, b: T) => boolean;
3104
3501
  /** Shallow element-wise array equality. Pure — the cache-invalidation core. */
3105
3502
  export declare const shallowArrayEqual: (a: ReadonlyArray<unknown>, b: ReadonlyArray<unknown>) => boolean;
3106
3503
 
3504
+ export declare type ShellKind = 'browser' | 'expo' | 'tauri' | 'electron' | 'node' | 'test';
3505
+
3107
3506
  declare type SignalPayload<Messages extends WorkflowClientMessages, Name extends string> = NonNullable<Messages['signals']> extends Readonly<Record<Name, infer Payload>> ? Payload : unknown;
3108
3507
 
3109
3508
  export declare type SocketIssueKind = 'close' | 'error' | 'connect-timeout';
@@ -3644,9 +4043,9 @@ export declare interface SubscriptionCacheOptions {
3644
4043
  * CRDT cell merger for the downstream lane (plan 18): folds a
3645
4044
  * `mergeCells` delta op's incremental update into the held cell. The one
3646
4045
  * real implementation is `crdtMergeCell` from `@voltro/local-first` (this
3647
- * package stays CRDT-library-free). Absent → a mergeCells op replaces the
3648
- * cell (the producer only emits them when the app declares CRDT tables,
3649
- * so an app without the binding never sees one).
4046
+ * package stays CRDT-library-free). Absent → the merger registered with
4047
+ * `registerCellMerger` (`@voltro/local-first` registers `crdtMergeCell` on
4048
+ * import); with none at all, a mergeCells op replaces the cell.
3650
4049
  */
3651
4050
  readonly mergeCell?: (column: string, prevValue: unknown, update: unknown) => unknown;
3652
4051
  /** Milliseconds to keep an entry alive after the last subscriber leaves.
@@ -3691,7 +4090,15 @@ export declare interface SubscriptionFailed extends SubscriptionMeta {
3691
4090
  readonly idle: false;
3692
4091
  readonly failed: true;
3693
4092
  /** Non-optional here, and that is the point: this state exists precisely
3694
- * because there is an error to show. */
4093
+ * because there is an error to show.
4094
+ *
4095
+ * It is the value the rpc failed with — the SAME value `useOnRpcError`
4096
+ * receives in `event.error` for this failure, and the same shape a rejected
4097
+ * `mutate` / `run` has: the declared error itself for a declared failure
4098
+ * (match on `_tag`, or `errorTag(error)` from `@voltro/protocol`; decoded
4099
+ * from JSON, so not an `instanceof` match), an `RpcClientError` for a
4100
+ * transport failure, the defect for a defect. Never an Effect `Cause`.
4101
+ * `unknown` because a defect can be any value. */
3695
4102
  readonly error: unknown;
3696
4103
  }
3697
4104
 
@@ -3751,7 +4158,10 @@ export declare interface SubscriptionMeta {
3751
4158
  * comment predicted the consequence, a deployment hit it, and the fix was
3752
4159
  * to stop making `loading` mean two things rather than to keep warning
3753
4160
  * about it. Branching on `loading` alone no longer renders a skeleton
3754
- * forever. */
4161
+ * forever.
4162
+ *
4163
+ * The value is the one `useOnRpcError` receives for the same failure —
4164
+ * see {@link SubscriptionFailed.error}. */
3755
4165
  readonly error: unknown | undefined;
3756
4166
  /** Number of live optimistic patches currently applied. Useful for
3757
4167
  * rendering a faint "syncing…" indicator when > 0. */
@@ -3983,6 +4393,19 @@ export declare type TagsOfKind<P extends ProcedureTypeMap, K extends string> = {
3983
4393
  } ? T : never;
3984
4394
  }[keyof P] & keyof P;
3985
4395
 
4396
+ /**
4397
+ * Where a credential lives. `kind` says how it is protected; a store that
4398
+ * cannot protect anything says so (`'none'`) and refuses to write, rather
4399
+ * than falling back to plain storage — a session token in a key-value store
4400
+ * is the defect this port exists to make impossible.
4401
+ */
4402
+ export declare interface TokenStore {
4403
+ readonly kind: 'keychain' | 'keystore' | 'credential-manager' | 'stronghold' | 'memory' | 'none';
4404
+ readonly get: (key: string) => Promise<string | null>;
4405
+ readonly set: (key: string, value: string) => Promise<void>;
4406
+ readonly delete: (key: string) => Promise<void>;
4407
+ }
4408
+
3986
4409
  /** A map entry: a bare event name, or a function of the component's props.
3987
4410
  *
3988
4411
  * `P` is the component's prop type. It defaults to an untyped bag so a
@@ -4125,6 +4548,20 @@ export declare interface UndoLogEntry {
4125
4548
  readonly createdAt: string;
4126
4549
  }
4127
4550
 
4551
+ /** How the running code gets replaced: a service worker, a desktop updater,
4552
+ * an OTA bundle. `apply` is the restart/reload; callers gate it on an empty
4553
+ * outbox. */
4554
+ export declare interface UpdateChannel {
4555
+ readonly check: () => Promise<UpdateInfo | null>;
4556
+ readonly apply: () => Promise<void>;
4557
+ readonly subscribe?: (onAvailable: (update: UpdateInfo) => void) => () => void;
4558
+ }
4559
+
4560
+ export declare interface UpdateInfo {
4561
+ readonly version: string;
4562
+ readonly notes?: string;
4563
+ }
4564
+
4128
4565
  declare type UpdatePayload<Messages extends WorkflowClientMessages, Name extends string> = NonNullable<Messages['updates']> extends Readonly<Record<Name, infer Update>> ? Update extends {
4129
4566
  readonly payload: infer Payload;
4130
4567
  } ? Payload : unknown : unknown;
@@ -4557,6 +4994,10 @@ export declare interface UseOutboxOptions {
4557
4994
  /** The current subject's scopes (defaults to none if no provider). */
4558
4995
  export declare const usePermissions: () => PermissionState_2;
4559
4996
 
4997
+ /** The running platform: info, capabilities and ports. Re-renders when an
4998
+ * adapter is installed after mount. */
4999
+ export declare const usePlatform: () => PlatformAdapter;
5000
+
4560
5001
  /**
4561
5002
  * Subscribe to a streaming rpc, seeding the first value from the SSR preload
4562
5003
  * payload when one exists.
@@ -4682,6 +5123,13 @@ export declare interface UseSequenceResult {
4682
5123
 
4683
5124
  export declare const useServerRequest: () => ServerRequestContextValue | null;
4684
5125
 
5126
+ /**
5127
+ * A shell-specific surface (`'tauri'`, `'electron'`, `'expo'`), or `null`
5128
+ * on every other shell. Using one ties the app to that shell; declare it in
5129
+ * the app's config so the build refuses the other targets with a reason.
5130
+ */
5131
+ export declare const useShellExtension: <T = unknown>(shell: string) => T | null;
5132
+
4685
5133
  export declare function useSubscription<T = unknown>(apiName: string, rpcTag: string, input: Readonly<Record<string, unknown>>, options: SubscriptionOptions<T> & {
4686
5134
  readonly initialSnapshot: T;
4687
5135
  }): SubscriptionStateWithFallback<T>;