@voltro/client 0.80.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
  *
@@ -388,6 +421,14 @@ export declare interface BuildApiRuntimeOptions {
388
421
  */
389
422
  readonly errorBus?: RpcErrorBus;
390
423
  readonly recovery?: RecoveryCoordinator;
424
+ /**
425
+ * Which of the server's published surfaces this group should match: the
426
+ * browser's client `surface` (default), or the `serviceSurface` another app
427
+ * of the project calls. A service client compared against the client
428
+ * surface would report every framework built-in as missing — true, and not
429
+ * its concern.
430
+ */
431
+ readonly surfaceAudience?: 'client' | 'service';
391
432
  }
392
433
 
393
434
  export declare type BuildClient = (api: MountedApi, generation: number, onSocketOpen: () => void, onSocketIssue: (kind: SocketIssueKind) => void,
@@ -499,7 +540,10 @@ export declare interface CacheSnapshot<T> {
499
540
  readonly revision: number;
500
541
  /** Wall-clock ms when the most recent server delta was emitted; undefined for snapshots. */
501
542
  readonly emittedAt: number | undefined;
502
- /** 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`. */
503
547
  readonly error: unknown | undefined;
504
548
  /** Number of live optimistic patches currently applied. */
505
549
  readonly pendingPatches: number;
@@ -513,6 +557,9 @@ export declare const canCall: (subjectScopes: ReadonlyArray<string>, required: s
513
557
  * An empty requirement is allowed (nothing is being demanded). Pure. */
514
558
  export declare const canCallAny: (subjectScopes: ReadonlyArray<string>, required: ReadonlyArray<string>) => boolean;
515
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
+
516
563
  /** Structural mirror of @voltro/cli's manifest column — the client stays
517
564
  * decoupled from the (node-only) cli package. */
518
565
  export declare interface CapabilityColumn {
@@ -601,11 +648,16 @@ export declare interface CapabilityTable {
601
648
  readonly editable?: boolean;
602
649
  }
603
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
+
604
654
  export declare const clearClientDiagnostics: () => void;
605
655
 
606
656
  /** Clear the buffer (devtools "Clear" button). */
607
657
  export declare const clearMutations: () => void;
608
658
 
659
+ export { clearPairing }
660
+
609
661
  /** Drop successfully-sent entries (call after a drain to compact the queue). */
610
662
  export declare const clearSent: (queue: Outbox) => Outbox;
611
663
 
@@ -887,6 +939,9 @@ export declare const createAnalytics: <const E extends ReadonlyArray<EventDescri
887
939
  */
888
940
  export declare const createHooks: <Procedures extends ProcedureTypeMap>(apiName: string) => ApiHooks<Procedures>;
889
941
 
942
+ /** The installed adapter, or the lazily-built browser default. */
943
+ export declare const currentPlatform: () => PlatformAdapter;
944
+
890
945
  export declare interface DataCopilotState<Row = Record<string, unknown>> {
891
946
  /** Ask a natural-language question. Resolves the typed answer (also stored
892
947
  * on `.answer`); rejects only on a transport / execution error. */
@@ -940,12 +995,81 @@ export declare const decideAccess: (guards: ReadonlyArray<ManifestGuard> | undef
940
995
  */
941
996
  export declare const decodeFieldIssues: (error: ParseResult.ParseError) => ReadonlyArray<FieldIssue>;
942
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
+
943
1064
  /** All defined stores, in definition order. */
944
1065
  export declare const definedStores: () => ReadonlyArray<StoreHandle<never>>;
945
1066
 
946
1067
  /** Declare a typed analytics event. */
947
1068
  export declare const defineEvent: <const Name extends string, A, I>(name: Name, payload: Schema.Schema<A, I>) => EventDescriptor<Name, A>;
948
1069
 
1070
+ /** Fill in the derived capabilities. Adapters are built through this. */
1071
+ export declare const definePlatform: (input: PlatformAdapterInput) => PlatformAdapter;
1072
+
949
1073
  /**
950
1074
  * Define a store.
951
1075
  *
@@ -983,10 +1107,63 @@ export declare const deriveEntityAdmins: (manifest: CapabilityManifest) => Reado
983
1107
 
984
1108
  export declare const disableClientDiagnosticsPersistence: () => void;
985
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
+
986
1128
  /** The document's locale per the framework contract (`<html lang>`); `'en'`
987
1129
  * outside a browser. Primary subtag only (`de-AT` → `de`). */
988
1130
  export declare const documentLocale: () => string;
989
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
+
990
1167
  /** The empty value — what an unfilled rich-text field holds. */
991
1168
  export declare const emptyRichTextDocument: RichTextDocument;
992
1169
 
@@ -1069,6 +1246,10 @@ declare interface EntryState<T> {
1069
1246
  /** Compares two selector results. Return true to keep the previous value. */
1070
1247
  export declare type Equals<T> = (a: T, b: T) => boolean;
1071
1248
 
1249
+ export { errorMessage }
1250
+
1251
+ export { errorTag }
1252
+
1072
1253
  export declare interface EventCatalog {
1073
1254
  readonly names: ReadonlyArray<string>;
1074
1255
  readonly get: (name: string) => EventDescriptor<string, unknown> | undefined;
@@ -1530,6 +1711,48 @@ export declare const getMutations: () => ReadonlyArray<MutationEvent>;
1530
1711
  */
1531
1712
  export declare const globalContext: <T>(key: string, initial: T) => Context<T>;
1532
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
+
1533
1756
  /**
1534
1757
  * The snapshot a coordinator has at construction, frozen and shared.
1535
1758
  *
@@ -1546,6 +1769,16 @@ export declare const globalContext: <T>(key: string, initial: T) => Context<T>;
1546
1769
  */
1547
1770
  export declare const INITIAL_RECOVERY_SNAPSHOT: RecoverySnapshot;
1548
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
+
1549
1782
  /** True when `value` is structurally a rich-text document (a cheap render-side
1550
1783
  * guard; the decode remains the boundary). */
1551
1784
  export declare const isRichTextDocument: (value: unknown) => value is RichTextDocument;
@@ -1560,6 +1793,9 @@ export declare const isRichTextDocument: (value: unknown) => value is RichTextDo
1560
1793
  */
1561
1794
  export declare const isSafeHref: (href: string) => boolean;
1562
1795
 
1796
+ /** Is this document running as an installed PWA (standalone display mode)? */
1797
+ export declare const isStandaloneDisplay: () => boolean;
1798
+
1563
1799
  /** Is this the framework's `Unauthenticated`? Matched on `_tag`, the wire
1564
1800
  * contract, rather than on an instance — the error crosses a package boundary
1565
1801
  * and may be re-created by the decoder. */
@@ -1589,6 +1825,15 @@ export declare const isUnauthenticated: (error: unknown) => boolean;
1589
1825
  */
1590
1826
  export declare const isUnresolvedApi: (handle: ApiHandle) => boolean;
1591
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
+
1592
1837
  declare type Listener = () => void;
1593
1838
 
1594
1839
  /**
@@ -1655,6 +1900,37 @@ export declare const markFailed: (queue: Outbox, id: string, error: unknown) =>
1655
1900
 
1656
1901
  export declare const markSent: (queue: Outbox, id: string) => Outbox;
1657
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
+
1658
1934
  /**
1659
1935
  * One api the client is mounted against: its name, its typed rpc surface, its
1660
1936
  * descriptor map and where to connect.
@@ -1772,6 +2048,29 @@ export declare type MutationStatus = 'pending' | 'success' | 'error';
1772
2048
 
1773
2049
  declare type MutationTag<P extends ProcedureTypeMap> = TagsOfKind<P, 'mutation'>;
1774
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
+
1775
2074
  /**
1776
2075
  * The reason a procedure declared itself open, or `undefined` if it did not.
1777
2076
  *
@@ -1823,6 +2122,11 @@ export declare type OptionalInputTag<P extends ProcedureTypeMap> = {
1823
2122
 
1824
2123
  export declare type Outbox = ReadonlyArray<OutboxEntry>;
1825
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
+
1826
2130
  export declare interface OutboxControls {
1827
2131
  readonly queue: Outbox;
1828
2132
  readonly enqueue: (tag: string, input: unknown) => void;
@@ -1862,6 +2166,20 @@ export declare interface OutboxPersistence {
1862
2166
 
1863
2167
  export declare type OutboxStatus = 'pending' | 'sent' | 'failed' | 'conflict';
1864
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
+
1865
2183
  /**
1866
2184
  * Parse the widget's markdown-subset SOURCE into a document. Total: every input
1867
2185
  * yields a valid document, because everything unrecognised is text. Not a
@@ -1909,6 +2227,62 @@ export declare interface PersistOptions<S> {
1909
2227
  readonly migrate?: (stored: unknown) => Partial<S> | undefined;
1910
2228
  }
1911
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
+
1912
2286
  /** Options `usePreloadedSubscription` accepts. It OWNS `initialSnapshot` (the
1913
2287
  * preload payload supplies it), so callers pass only `skip` — `fallback` and
1914
2288
  * `initialSnapshot` are its own concern. */
@@ -2107,6 +2481,8 @@ declare type QueryTag<P extends ProcedureTypeMap> = TagsOfKind<P, 'query'>;
2107
2481
 
2108
2482
  export declare type RawTransportStatus = 'connected' | 'disconnected';
2109
2483
 
2484
+ export { readPairing }
2485
+
2110
2486
  /**
2111
2487
  * Did the server attempt this preload, and did it work?
2112
2488
  *
@@ -2238,6 +2614,18 @@ export declare interface RecoverySnapshot {
2238
2614
  readonly mutationReplay: 'unknown' | 'enabled' | 'disabled';
2239
2615
  }
2240
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
+
2241
2629
  /**
2242
2630
  * Make an api's client descriptors visible to a SERVER render.
2243
2631
  *
@@ -2268,6 +2656,9 @@ export declare const requiredScopes: (guards: ReadonlyArray<ManifestGuard> | und
2268
2656
  * module-global flags + any pending grace-period timer). */
2269
2657
  export declare const _resetFrameworkRuntimesWarning: () => void;
2270
2658
 
2659
+ /** Test seam: forget the installed adapter and the cached default. */
2660
+ export declare const resetPlatformForTest: () => void;
2661
+
2271
2662
  /** Drop all applied client-side seeds. Tests only. */
2272
2663
  export declare const resetPreloadSeeds: () => void;
2273
2664
 
@@ -2579,12 +2970,12 @@ export declare const RichTextDocument: Schema.refine<{
2579
2970
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2580
2971
  } | {
2581
2972
  readonly type: "link";
2582
- readonly href: string;
2583
2973
  readonly content: readonly {
2584
2974
  readonly type: "text";
2585
2975
  readonly text: string;
2586
2976
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2587
2977
  }[];
2978
+ readonly href: string;
2588
2979
  })[];
2589
2980
  } | {
2590
2981
  readonly type: "heading";
@@ -2595,12 +2986,12 @@ export declare const RichTextDocument: Schema.refine<{
2595
2986
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2596
2987
  } | {
2597
2988
  readonly type: "link";
2598
- readonly href: string;
2599
2989
  readonly content: readonly {
2600
2990
  readonly type: "text";
2601
2991
  readonly text: string;
2602
2992
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2603
2993
  }[];
2994
+ readonly href: string;
2604
2995
  })[];
2605
2996
  } | {
2606
2997
  readonly type: "blockquote";
@@ -2610,12 +3001,12 @@ export declare const RichTextDocument: Schema.refine<{
2610
3001
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2611
3002
  } | {
2612
3003
  readonly type: "link";
2613
- readonly href: string;
2614
3004
  readonly content: readonly {
2615
3005
  readonly type: "text";
2616
3006
  readonly text: string;
2617
3007
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2618
3008
  }[];
3009
+ readonly href: string;
2619
3010
  })[];
2620
3011
  } | {
2621
3012
  readonly type: "bulletList";
@@ -2627,12 +3018,12 @@ export declare const RichTextDocument: Schema.refine<{
2627
3018
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2628
3019
  } | {
2629
3020
  readonly type: "link";
2630
- readonly href: string;
2631
3021
  readonly content: readonly {
2632
3022
  readonly type: "text";
2633
3023
  readonly text: string;
2634
3024
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2635
3025
  }[];
3026
+ readonly href: string;
2636
3027
  })[];
2637
3028
  }[];
2638
3029
  } | {
@@ -2645,12 +3036,12 @@ export declare const RichTextDocument: Schema.refine<{
2645
3036
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2646
3037
  } | {
2647
3038
  readonly type: "link";
2648
- readonly href: string;
2649
3039
  readonly content: readonly {
2650
3040
  readonly type: "text";
2651
3041
  readonly text: string;
2652
3042
  readonly marks?: readonly ("code" | "bold" | "strike" | "italic")[] | undefined;
2653
3043
  }[];
3044
+ readonly href: string;
2654
3045
  })[];
2655
3046
  }[];
2656
3047
  } | {
@@ -2875,6 +3266,14 @@ export declare type RpcErrorKind = 'transport' | 'handler' | 'client' | 'unknown
2875
3266
 
2876
3267
  export declare type RpcErrorListener = (event: RpcError) => void;
2877
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
+
2878
3277
  /** A call that SUCCEEDED. Carries only its source and tag — there is no payload
2879
3278
  * here on purpose: this channel exists so cross-cutting policy can tell
2880
3279
  * "working again" from "still broken", not so listeners can read data. */
@@ -2885,6 +3284,12 @@ export declare interface RpcSuccess {
2885
3284
 
2886
3285
  export declare type RpcSuccessListener = (event: RpcSuccess) => void;
2887
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
+
2888
3293
  /**
2889
3294
  * Run a sequence. Resolves with a discriminated result rather than rejecting —
2890
3295
  * the same "handled" semantics `useMutation`/`useAction` use, so the call site
@@ -3096,6 +3501,8 @@ export declare const shallow: <T>(a: T, b: T) => boolean;
3096
3501
  /** Shallow element-wise array equality. Pure — the cache-invalidation core. */
3097
3502
  export declare const shallowArrayEqual: (a: ReadonlyArray<unknown>, b: ReadonlyArray<unknown>) => boolean;
3098
3503
 
3504
+ export declare type ShellKind = 'browser' | 'expo' | 'tauri' | 'electron' | 'node' | 'test';
3505
+
3099
3506
  declare type SignalPayload<Messages extends WorkflowClientMessages, Name extends string> = NonNullable<Messages['signals']> extends Readonly<Record<Name, infer Payload>> ? Payload : unknown;
3100
3507
 
3101
3508
  export declare type SocketIssueKind = 'close' | 'error' | 'connect-timeout';
@@ -3636,9 +4043,9 @@ export declare interface SubscriptionCacheOptions {
3636
4043
  * CRDT cell merger for the downstream lane (plan 18): folds a
3637
4044
  * `mergeCells` delta op's incremental update into the held cell. The one
3638
4045
  * real implementation is `crdtMergeCell` from `@voltro/local-first` (this
3639
- * package stays CRDT-library-free). Absent → a mergeCells op replaces the
3640
- * cell (the producer only emits them when the app declares CRDT tables,
3641
- * 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.
3642
4049
  */
3643
4050
  readonly mergeCell?: (column: string, prevValue: unknown, update: unknown) => unknown;
3644
4051
  /** Milliseconds to keep an entry alive after the last subscriber leaves.
@@ -3683,7 +4090,15 @@ export declare interface SubscriptionFailed extends SubscriptionMeta {
3683
4090
  readonly idle: false;
3684
4091
  readonly failed: true;
3685
4092
  /** Non-optional here, and that is the point: this state exists precisely
3686
- * 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. */
3687
4102
  readonly error: unknown;
3688
4103
  }
3689
4104
 
@@ -3743,7 +4158,10 @@ export declare interface SubscriptionMeta {
3743
4158
  * comment predicted the consequence, a deployment hit it, and the fix was
3744
4159
  * to stop making `loading` mean two things rather than to keep warning
3745
4160
  * about it. Branching on `loading` alone no longer renders a skeleton
3746
- * forever. */
4161
+ * forever.
4162
+ *
4163
+ * The value is the one `useOnRpcError` receives for the same failure —
4164
+ * see {@link SubscriptionFailed.error}. */
3747
4165
  readonly error: unknown | undefined;
3748
4166
  /** Number of live optimistic patches currently applied. Useful for
3749
4167
  * rendering a faint "syncing…" indicator when > 0. */
@@ -3975,6 +4393,19 @@ export declare type TagsOfKind<P extends ProcedureTypeMap, K extends string> = {
3975
4393
  } ? T : never;
3976
4394
  }[keyof P] & keyof P;
3977
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
+
3978
4409
  /** A map entry: a bare event name, or a function of the component's props.
3979
4410
  *
3980
4411
  * `P` is the component's prop type. It defaults to an untyped bag so a
@@ -4117,6 +4548,20 @@ export declare interface UndoLogEntry {
4117
4548
  readonly createdAt: string;
4118
4549
  }
4119
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
+
4120
4565
  declare type UpdatePayload<Messages extends WorkflowClientMessages, Name extends string> = NonNullable<Messages['updates']> extends Readonly<Record<Name, infer Update>> ? Update extends {
4121
4566
  readonly payload: infer Payload;
4122
4567
  } ? Payload : unknown : unknown;
@@ -4549,6 +4994,10 @@ export declare interface UseOutboxOptions {
4549
4994
  /** The current subject's scopes (defaults to none if no provider). */
4550
4995
  export declare const usePermissions: () => PermissionState_2;
4551
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
+
4552
5001
  /**
4553
5002
  * Subscribe to a streaming rpc, seeding the first value from the SSR preload
4554
5003
  * payload when one exists.
@@ -4674,6 +5123,13 @@ export declare interface UseSequenceResult {
4674
5123
 
4675
5124
  export declare const useServerRequest: () => ServerRequestContextValue | null;
4676
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
+
4677
5133
  export declare function useSubscription<T = unknown>(apiName: string, rpcTag: string, input: Readonly<Record<string, unknown>>, options: SubscriptionOptions<T> & {
4678
5134
  readonly initialSnapshot: T;
4679
5135
  }): SubscriptionStateWithFallback<T>;