use-everywhere 0.13.0 → 1.0.1

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,6 +1,6 @@
1
- import { SharedStore, LeaderOptions, Leader, MessageMap, ReplyMap, Channel, MessageMeta, ChannelOptions, PersistAdapter, RestoreError, Peer, LeaderSnapshot, Namespace, OpenedWindow, WindowClosedError } from '@use-everywhere/core';
2
- export { AskOptions, BroadcastChannelTransport, BusEvent, BusObserver, BusWire, CID_PARAM, Channel, ChannelOptions, CommonOptions, ConnectToOpenerOptions, DEFAULT_NAME, DebugOptions, HandshakeTimeoutError, IndexedDbAdapterOptions, InvalidPayload, Leader, LeaderOptions, LeaderSnapshot, LeaderStrategy, LockManagerLike, MessageEventLike, MessageMap, MessageMeta, MessagePortLike, Namespace, NoopTransport, OnInvalid, OnOptions, OpenWindowOptions, OpenedWindow, OpenerConnection, Peer, PeerKind, PersistAdapter, PersistOptions, Persisted, PostOptions, Presence, PresenceOptions, ReplyMap, RestoreError, SchemaMap, SchemaOptions, Serializer, SharedReducer, SharedReducerOptions, SharedStore, SharedStoreOptions, SharedWorkerLike, SharedWorkerTransport, SharedWorkerTransportOptions, StandardSchemaV1, StorageLike, StorageTransport, Transport, TransportKind, Version, WIRE_VERSION, WebStorageAdapterOptions, WindowClosedError, WindowEventTarget, WindowLike, connectToOpener, createChannel, createLeader, createPresence, createSharedReducer, createSharedStore, defaultTransport, enableDebug, getBusNames, getTransportKind, getWireSkew, indexedDbAdapter, isBroadcastChannelAvailable, isSharedWorkerAvailable, isStorageEventAvailable, jsonSerializer, localStorageAdapter, newer, observeBus, openWindow, sessionStorageAdapter, webStorageAdapter } from '@use-everywhere/core';
3
1
 
2
+ import { AskOptions, BroadcastChannelTransport, BusEvent, BusObserver, BusWire, CID_PARAM, Channel, Channel as Channel$1, ChannelOptions, ChannelOptions as ChannelOptions$1, CommonOptions, ConnectToOpenerOptions, DEFAULT_NAME, DebugOptions, HandshakeTimeoutError, IndexedDbAdapterOptions, InvalidPayload, Leader, Leader as Leader$1, LeaderOptions, LeaderOptions as LeaderOptions$1, LeaderSnapshot, LeaderSnapshot as LeaderSnapshot$1, LeaderStrategy, LockManagerLike, MessageEventLike, MessageMap, MessageMap as MessageMap$1, MessageMeta, MessageMeta as MessageMeta$1, MessagePortLike, Namespace, Namespace as Namespace$1, NoopTransport, OnInvalid, OnOptions, OpenWindowOptions, OpenedWindow, OpenedWindow as OpenedWindow$1, OpenerConnection, Peer, Peer as Peer$1, PeerKind, PersistAdapter, PersistAdapter as PersistAdapter$1, PersistOptions, Persisted, PostOptions, Presence, PresenceOptions, ReplyMap, ReplyMap as ReplyMap$1, RestoreError, RestoreError as RestoreError$1, SchemaMap, SchemaOptions, Serializer, SharedReducer, SharedReducerOptions, SharedStore, SharedStore as SharedStore$1, SharedStoreOptions, SharedWorkerLike, SharedWorkerTransport, SharedWorkerTransportOptions, StandardSchemaV1, StorageLike, StorageTransport, Transport, TransportKind, Version, WIRE_VERSION, WebStorageAdapterOptions, WindowClosedError, WindowClosedError as WindowClosedError$1, WindowEventTarget, WindowLike, connectToOpener, createChannel, createLeader, createPresence, createSharedReducer, createSharedStore, defaultTransport, enableDebug, getBusNames, getTransportKind, getWireSkew, indexedDbAdapter, isBroadcastChannelAvailable, isSharedWorkerAvailable, isStorageEventAvailable, jsonSerializer, localStorageAdapter, newer, observeBus, openWindow, sessionStorageAdapter, webStorageAdapter } from "@use-everywhere/core";
3
+ //#region src/use-shared-state.types.d.ts
4
4
  /**
5
5
  * How far a shared value travels:
6
6
  * - 'everywhere' — every tab, window, and worker on this origin (default)
@@ -9,12 +9,13 @@ export { AskOptions, BroadcastChannelTransport, BusEvent, BusObserver, BusWire,
9
9
  */
10
10
  type ShareScope = 'everywhere' | 'tabs' | 'tab';
11
11
  interface UseSharedStateOptions {
12
- /** Store name; keys live in a namespace per store. Default 'use-everywhere'. */
13
- store?: string;
14
- /** How much to share. Default 'everywhere'. */
15
- scope?: ShareScope;
12
+ /** Store name; keys live in a namespace per store. Default 'use-everywhere'. */
13
+ store?: string;
14
+ /** How much to share. Default 'everywhere'. */
15
+ scope?: ShareScope;
16
16
  }
17
-
17
+ //#endregion
18
+ //#region src/use-shared-state.d.ts
18
19
  /**
19
20
  * Like useState, but the value exists in every tab, window, and worker on
20
21
  * this origin. Late-joining tabs hydrate to the current value; concurrent
@@ -27,13 +28,14 @@ interface UseSharedStateOptions {
27
28
  * writes, drive them from a single tab (useLeaderEffect) until an op-based
28
29
  * primitive lands.
29
30
  */
30
- declare function useSharedState<T>(key: string, initial: T, options?: UseSharedStateOptions): [T, (next: T | ((prev: T) => T)) => void];
31
-
31
+ export declare function useSharedState<T>(key: string, initial: T, options?: UseSharedStateOptions): [T, (next: T | ((prev: T) => T)) => void];
32
+ //#endregion
33
+ //#region src/use-shared-reducer.d.ts
32
34
  interface UseSharedReducerOptions {
33
- /** Bus name. Default 'use-everywhere'. */
34
- name?: string;
35
- /** Which reducer this is, when several share a bus. Default 'default'. */
36
- key?: string;
35
+ /** Bus name. Default 'use-everywhere'. */
36
+ name?: string;
37
+ /** Which reducer this is, when several share a bus. Default 'default'. */
38
+ key?: string;
37
39
  }
38
40
  /**
39
41
  * Like `useReducer`, but every tab, window, and worker on this origin applies
@@ -70,17 +72,18 @@ interface UseSharedReducerOptions {
70
72
  * moments of the first tab — dispatches are held locally and ordered once it
71
73
  * is. They are never lost, only pending.
72
74
  */
73
- declare function useSharedReducer<S, A>(reducer: (state: S, action: A) => S, initial: S, options?: UseSharedReducerOptions): [S, (action: A) => void];
74
-
75
+ export declare function useSharedReducer<S, A>(reducer: (state: S, action: A) => S, initial: S, options?: UseSharedReducerOptions): [S, (action: A) => void];
76
+ //#endregion
77
+ //#region src/use-shared-selector.d.ts
75
78
  interface UseSharedSelectorOptions extends UseSharedStateOptions {
76
- /**
77
- * Whether two selected values count as the same. Default `Object.is`.
78
- *
79
- * A selector returning an object or array builds a new one every time it
80
- * runs, so `Object.is` never matches and the component re-renders on every
81
- * write to the store. Pass a shallow comparison for those.
82
- */
83
- equal?: (a: unknown, b: unknown) => boolean;
79
+ /**
80
+ * Whether two selected values count as the same. Default `Object.is`.
81
+ *
82
+ * A selector returning an object or array builds a new one every time it
83
+ * runs, so `Object.is` never matches and the component re-renders on every
84
+ * write to the store. Pass a shallow comparison for those.
85
+ */
86
+ equal?: (a: unknown, b: unknown) => boolean;
84
87
  }
85
88
  /**
86
89
  * Read a derived value from a shared store, re-rendering only when it changes.
@@ -111,42 +114,45 @@ interface UseSharedSelectorOptions extends UseSharedStateOptions {
111
114
  * selector runs against `{}`, and its result is what the server-rendered markup
112
115
  * shows.
113
116
  */
114
- declare function useSharedSelector<S extends Record<string, unknown>, T>(selector: (state: S) => T, options?: UseSharedSelectorOptions): T;
117
+ export declare function useSharedSelector<S extends Record<string, unknown>, T>(selector: (state: S) => T, options?: UseSharedSelectorOptions): T;
115
118
  /** Shallow equality over an object or array, for selectors that build one. */
116
- declare function shallowEqual(a: unknown, b: unknown): boolean;
117
-
119
+ export declare function shallowEqual(a: unknown, b: unknown): boolean;
120
+ //#endregion
121
+ //#region src/registry.types.d.ts
118
122
  /** Registry stores hold arbitrary keys — shape is decided by the hooks using them. */
119
- type AnyStore = SharedStore<Record<string, unknown>>;
120
-
123
+ type AnyStore = SharedStore$1<Record<string, unknown>>;
124
+ //#endregion
125
+ //#region src/registry.d.ts
121
126
  /** Imperative access to the store behind useSharedState (patch logs, non-React code). */
122
- declare function getSharedStore(name?: string, scope?: ShareScope): AnyStore;
127
+ export declare function getSharedStore(name?: string, scope?: ShareScope): AnyStore;
123
128
  /**
124
129
  * One Leader per name per tab. Eligibility is deliberately *not* part of the
125
130
  * key: two Leaders on one name would share a bus and a clientId, and since a
126
131
  * post never loops back locally, neither would ever see the other's claims.
127
132
  * Timing options are first-wins, like every other engine here.
128
133
  */
129
- declare function getLeader(name: string, options?: LeaderOptions): Leader;
130
-
134
+ export declare function getLeader(name: string, options?: LeaderOptions$1): Leader$1;
135
+ //#endregion
136
+ //#region src/use-on-message.d.ts
131
137
  /** Get the page-wide typed channel for `name` (one instance per name). */
132
- declare function useChannel<M extends MessageMap, R extends ReplyMap<M> = Record<never, never>>(name: string): Channel<M, R>;
138
+ export declare function useChannel<M extends MessageMap$1, R extends ReplyMap$1<M> = Record<never, never>>(name: string): Channel$1<M, R>;
133
139
  interface UseOnMessageOptions {
134
- /**
135
- * Subscribe at all. Default true.
136
- *
137
- * `false` unsubscribes rather than filtering inside the handler, so a
138
- * component that is not interested costs nothing — and the alternative,
139
- * calling the hook conditionally, is not allowed.
140
- */
141
- enabled?: boolean;
142
- /** Unsubscribe after the first message. */
143
- once?: boolean;
140
+ /**
141
+ * Subscribe at all. Default true.
142
+ *
143
+ * `false` unsubscribes rather than filtering inside the handler, so a
144
+ * component that is not interested costs nothing — and the alternative,
145
+ * calling the hook conditionally, is not allowed.
146
+ */
147
+ enabled?: boolean;
148
+ /** Unsubscribe after the first message. */
149
+ once?: boolean;
144
150
  }
145
151
  /**
146
152
  * Subscribe to one message type. The handler is kept fresh without
147
153
  * resubscribing, so it may close over render state.
148
154
  */
149
- declare function useOnMessage<M extends MessageMap, R extends ReplyMap<M>, K extends keyof M & string>(channel: Channel<M, R>, type: K, handler: (payload: M[K], meta: MessageMeta) => void, options?: UseOnMessageOptions): void;
155
+ export declare function useOnMessage<M extends MessageMap$1, R extends ReplyMap$1<M>, K extends keyof M & string>(channel: Channel$1<M, R>, type: K, handler: (payload: M[K], meta: MessageMeta$1) => void, options?: UseOnMessageOptions): void;
150
156
  /**
151
157
  * Answer `ask`s of one type for as long as this component is mounted.
152
158
  *
@@ -157,29 +163,29 @@ declare function useOnMessage<M extends MessageMap, R extends ReplyMap<M>, K ext
157
163
  * One responder per type per channel — registering a second replaces the first,
158
164
  * which is the same first-wins-then-replace rule `answer` has in core.
159
165
  */
160
- declare function useAnswer<M extends MessageMap, R extends ReplyMap<M>, K extends keyof M & keyof R & string>(channel: Channel<M, R>, type: K, responder: (payload: M[K], meta: MessageMeta) => R[K], options?: {
161
- enabled?: boolean;
166
+ export declare function useAnswer<M extends MessageMap$1, R extends ReplyMap$1<M>, K extends keyof M & keyof R & string>(channel: Channel$1<M, R>, type: K, responder: (payload: M[K], meta: MessageMeta$1) => R[K], options?: {
167
+ enabled?: boolean;
162
168
  }): void;
163
169
  /** The channel's post function (stable identity per channel). */
164
- declare function useSend<M extends MessageMap, R extends ReplyMap<M>>(channel: Channel<M, R>): Channel<M, R>['post'];
170
+ export declare function useSend<M extends MessageMap$1, R extends ReplyMap$1<M>>(channel: Channel$1<M, R>): Channel$1<M, R>['post'];
165
171
  /** The channel's ask function (stable identity per channel). */
166
- declare function useAsk<M extends MessageMap, R extends ReplyMap<M>>(channel: Channel<M, R>): Channel<M, R>['ask'];
167
-
172
+ export declare function useAsk<M extends MessageMap$1, R extends ReplyMap$1<M>>(channel: Channel$1<M, R>): Channel$1<M, R>['ask'];
173
+ //#endregion
174
+ //#region src/define-channel.types.d.ts
168
175
  /** A channel bound to a name and message map: typed hooks with no per-call generics. */
169
- interface ChannelHooks<M extends MessageMap> {
170
- /** The underlying channel instance (the same one the hooks use) — for non-React code. */
171
- get: () => Channel<M>;
172
- /** The channel's post function (stable identity). */
173
- useSend: () => Channel<M>['post'];
174
- /**
175
- * Subscribe to one message type. Same contract as the standalone
176
- * `useOnMessage`: the handler is kept fresh without resubscribing.
177
- */
178
- useOnMessage: <K extends keyof M & string>(type: K, handler: (payload: M[K], meta: MessageMeta) => void) => void;
179
- /** @deprecated Renamed to `useOnMessage`. Removed in 1.0 — `npx use-everywhere-codemod rename-1.0 src/`. */
180
- useMessage: <K extends keyof M & string>(type: K, handler: (payload: M[K], meta: MessageMeta) => void) => void;
176
+ interface ChannelHooks<M extends MessageMap$1> {
177
+ /** The underlying channel instance (the same one the hooks use) — for non-React code. */
178
+ get: () => Channel$1<M>;
179
+ /** The channel's post function (stable identity). */
180
+ useSend: () => Channel$1<M>['post'];
181
+ /**
182
+ * Subscribe to one message type. Same contract as the standalone
183
+ * `useOnMessage`: the handler is kept fresh without resubscribing.
184
+ */
185
+ useOnMessage: <K extends keyof M & string>(type: K, handler: (payload: M[K], meta: MessageMeta$1) => void) => void;
181
186
  }
182
-
187
+ //#endregion
188
+ //#region src/define-channel.d.ts
183
189
  /**
184
190
  * Bind a channel name and message map once, at module level, and get fully
185
191
  * typed hooks back. Sugar over useChannel/useOnMessage/useSend — the same
@@ -189,37 +195,37 @@ interface ChannelHooks<M extends MessageMap> {
189
195
  * Options are registered here and applied when the channel is first needed, so
190
196
  * declaring a `schema` at module scope still constructs nothing on import.
191
197
  */
192
- declare function defineChannel<M extends MessageMap>(name: string, options?: ChannelOptions<M>): ChannelHooks<M>;
193
-
198
+ export declare function defineChannel<M extends MessageMap$1>(name: string, options?: ChannelOptions$1<M>): ChannelHooks<M>;
199
+ //#endregion
200
+ //#region src/create-store-hooks.types.d.ts
194
201
  interface CreateStoreHooksOptions {
195
- /** Restore this store from disk on first use, and write it back as it changes. */
196
- persist?: PersistAdapter;
197
- /** Persist only these keys. Default: every key that has been written. */
198
- persistKeys?: string[];
199
- /** Coalesce disk writes for this long. Default 100. */
200
- persistDebounceMs?: number;
201
- /**
202
- * The version of your persisted state's shape. Bump it whenever a key changes
203
- * meaning or type, and supply `migrate` to carry old data forward. Default 0,
204
- * which is also what anything written before this existed reads as.
205
- */
206
- persistVersion?: number;
207
- /** Bring persisted state written at an older `persistVersion` up to the current one. */
208
- migrate?: (state: Record<string, unknown>, from: number) => Record<string, unknown>;
209
- /** Called when persisted state is refused instead of restored. Defaults to a development warning. */
210
- onRestoreError?: (error: RestoreError) => void;
211
- /** How far this store is shared. Default 'everywhere'. */
212
- scope?: ShareScope;
202
+ /** Restore this store from disk on first use, and write it back as it changes. */
203
+ persist?: PersistAdapter$1;
204
+ /** Persist only these keys. Default: every key that has been written. */
205
+ persistKeys?: string[];
206
+ /** Coalesce disk writes for this long. Default 100. */
207
+ persistDebounceMs?: number;
208
+ /**
209
+ * The version of your persisted state's shape. Bump it whenever a key changes
210
+ * meaning or type, and supply `migrate` to carry old data forward. Default 0,
211
+ * which is also what anything written before this existed reads as.
212
+ */
213
+ persistVersion?: number;
214
+ /** Bring persisted state written at an older `persistVersion` up to the current one. */
215
+ migrate?: (state: Record<string, unknown>, from: number) => Record<string, unknown>;
216
+ /** Called when persisted state is refused instead of restored. Defaults to a development warning. */
217
+ onRestoreError?: (error: RestoreError$1) => void;
218
+ /** How far this store is shared. Default 'everywhere'. */
219
+ scope?: ShareScope;
213
220
  }
214
221
  /** A store bound to a name and a shape: typed hooks with no per-call generics. */
215
222
  interface StoreHooks<S extends Record<string, unknown>> {
216
- /** The underlying store instance (the same one the hooks use) — for non-React code. */
217
- store: () => AnyStore;
218
- /** @deprecated Renamed to `store`. Removed in 1.0 — `npx use-everywhere-codemod rename-1.0 src/`. */
219
- get: () => AnyStore;
220
- useSharedState: <K extends keyof S & string>(key: K, initial: S[K]) => [S[K], (next: S[K] | ((prev: S[K]) => S[K])) => void];
223
+ /** The underlying store instance (the same one the hooks use) — for non-React code. */
224
+ store: () => AnyStore;
225
+ useSharedState: <K extends keyof S & string>(key: K, initial: S[K]) => [S[K], (next: S[K] | ((prev: S[K]) => S[K])) => void];
221
226
  }
222
-
227
+ //#endregion
228
+ //#region src/create-store-hooks.d.ts
223
229
  /**
224
230
  * Bind a store name — and optionally persistence — once, at module level.
225
231
  *
@@ -234,19 +240,20 @@ interface StoreHooks<S extends Record<string, unknown>> {
234
240
  * so intended usage is automatic; if it does run late it throws rather than
235
241
  * quietly handing back a store with no persistence.
236
242
  */
237
- declare function createStoreHooks<S extends Record<string, unknown> = Record<string, unknown>>(name: string, options?: CreateStoreHooksOptions): StoreHooks<S>;
238
-
243
+ export declare function createStoreHooks<S extends Record<string, unknown> = Record<string, unknown>>(name: string, options?: CreateStoreHooksOptions): StoreHooks<S>;
244
+ //#endregion
245
+ //#region src/use-peers.d.ts
239
246
  interface UsePeersOptions {
240
- /** Bus name. Default 'use-everywhere'. */
241
- name?: string;
242
- /**
243
- * Include this client in the list. Default false.
244
- *
245
- * The default answers "who *else* is here", which is what a presence strip
246
- * asks. Turn it on for an avatar list, where leaving yourself out means every
247
- * tab renders a different list of the same room.
248
- */
249
- includeSelf?: boolean;
247
+ /** Bus name. Default 'use-everywhere'. */
248
+ name?: string;
249
+ /**
250
+ * Include this client in the list. Default false.
251
+ *
252
+ * The default answers "who *else* is here", which is what a presence strip
253
+ * asks. Turn it on for an avatar list, where leaving yourself out means every
254
+ * tab renders a different list of the same room.
255
+ */
256
+ includeSelf?: boolean;
250
257
  }
251
258
  /**
252
259
  * The tabs/windows/workers currently alive on this origin.
@@ -254,7 +261,7 @@ interface UsePeersOptions {
254
261
  * Each peer carries whatever it published about itself as `metadata` — see
255
262
  * {@link usePresenceMetadata} for publishing this client's.
256
263
  */
257
- declare function usePeers(options?: UsePeersOptions): readonly Peer[];
264
+ export declare function usePeers(options?: UsePeersOptions): readonly Peer$1[];
258
265
  /**
259
266
  * This client's own id on the presence bus (matches patch origin ids).
260
267
  *
@@ -265,8 +272,8 @@ declare function usePeers(options?: UsePeersOptions): readonly Peer[];
265
272
  * React also uses for the client's hydrating render, so markup matches; the
266
273
  * real id arrives in the commit straight after. Treat `''` as "not known yet".
267
274
  */
268
- declare function useClientId(options?: {
269
- name?: string;
275
+ export declare function useClientId(options?: {
276
+ name?: string;
270
277
  }): string;
271
278
  /**
272
279
  * Publish what this client wants peers to know about it — a display name, a tab
@@ -283,8 +290,9 @@ declare function useClientId(options?: {
283
290
  * side effect on every other tab — and a render that React throws away must not
284
291
  * be one other tabs already saw.
285
292
  */
286
- declare function usePresenceMetadata(metadata: unknown, options?: UsePeersOptions): void;
287
-
293
+ export declare function usePresenceMetadata(metadata: unknown, options?: UsePeersOptions): void;
294
+ //#endregion
295
+ //#region src/use-hydrated.d.ts
288
296
  /**
289
297
  * Whether a persisted store has finished restoring.
290
298
  *
@@ -312,27 +320,30 @@ declare function usePresenceMetadata(metadata: unknown, options?: UsePeersOption
312
320
  * restored by the time the store is handed back, so there is no gap to guard
313
321
  * and this simply flips to `true` in the commit after mount.
314
322
  */
315
- declare function useHydrated(options?: UseSharedStateOptions): boolean;
316
-
317
- interface UseLeaderOptions extends LeaderOptions {
318
- /** Which bus to elect on. Defaults to the shared default name. */
319
- name?: string;
323
+ export declare function useHydrated(options?: UseSharedStateOptions): boolean;
324
+ //#endregion
325
+ //#region src/use-leader.types.d.ts
326
+ interface UseLeaderOptions extends LeaderOptions$1 {
327
+ /** Which bus to elect on. Defaults to the shared default name. */
328
+ name?: string;
320
329
  }
321
-
330
+ //#endregion
331
+ //#region src/use-leader.d.ts
322
332
  /**
323
333
  * Who currently holds the seat on this bus, and whether it is us. Exactly one
324
334
  * tab leads; opening another does not steal it, and closing the leader hands it
325
335
  * over at once.
326
336
  */
327
- declare function useLeader(options?: UseLeaderOptions): LeaderSnapshot;
337
+ export declare function useLeader(options?: UseLeaderOptions): LeaderSnapshot$1;
328
338
  /** Is this tab the leader? */
329
- declare function useIsLeader(options?: UseLeaderOptions): boolean;
339
+ export declare function useIsLeader(options?: UseLeaderOptions): boolean;
330
340
  /**
331
341
  * Run an effect only in the tab that holds the seat, and tear it down when the
332
342
  * seat moves. The one place to put "exactly one tab owns the socket".
333
343
  */
334
- declare function useLeaderEffect(effect: () => void | (() => void), options?: UseLeaderOptions): void;
335
-
344
+ export declare function useLeaderEffect(effect: () => void | (() => void), options?: UseLeaderOptions): void;
345
+ //#endregion
346
+ //#region src/namespace.d.ts
336
347
  /**
337
348
  * The React half of a namespace: the same hooks, with every bus name prefixed.
338
349
  *
@@ -340,25 +351,21 @@ declare function useLeaderEffect(effect: () => void | (() => void), options?: Us
340
351
  * `scope` still says how far a value travels, which is a different axis from
341
352
  * which namespace it lives in.
342
353
  */
343
- interface ReactNamespace extends Namespace {
344
- createStoreHooks<S extends Record<string, unknown> = Record<string, unknown>>(name: string, options?: CreateStoreHooksOptions): StoreHooks<S>;
345
- defineChannel<M extends MessageMap>(name?: string, options?: ChannelOptions<M>): ChannelHooks<M>;
346
- getSharedStore(name?: string, scope?: UseSharedStateOptions['scope']): AnyStore;
347
- useSharedState<T>(key: string, initial: T, options?: UseSharedStateOptions): [T, (next: T | ((prev: T) => T)) => void];
348
- useSharedSelector<S extends Record<string, unknown>, T>(selector: (state: S) => T, options?: UseSharedSelectorOptions): T;
349
- /** @deprecated Renamed to `createStoreHooks`. Removed in 1.0 — `npx use-everywhere-codemod rename-1.0 src/`. */
350
- defineStore<S extends Record<string, unknown> = Record<string, unknown>>(name: string, options?: CreateStoreHooksOptions): StoreHooks<S>;
351
- /** @deprecated Renamed to `useSharedSelector`. Removed in 1.0 — `npx use-everywhere-codemod rename-1.0 src/`. */
352
- useSharedStore<S extends Record<string, unknown>, T>(selector: (state: S) => T, options?: UseSharedSelectorOptions): T;
353
- usePeers(options?: UsePeersOptions): readonly Peer[];
354
- usePresenceMetadata(metadata: unknown, options?: UsePeersOptions): void;
355
- useHydrated(options?: UseSharedStateOptions): boolean;
356
- useClientId(options?: {
357
- name?: string;
358
- }): string;
359
- useLeader(options?: UseLeaderOptions): LeaderSnapshot;
360
- useIsLeader(options?: UseLeaderOptions): boolean;
361
- useLeaderEffect(effect: () => void | (() => void), options?: UseLeaderOptions): void;
354
+ interface ReactNamespace extends Namespace$1 {
355
+ createStoreHooks<S extends Record<string, unknown> = Record<string, unknown>>(name: string, options?: CreateStoreHooksOptions): StoreHooks<S>;
356
+ defineChannel<M extends MessageMap$1>(name?: string, options?: ChannelOptions$1<M>): ChannelHooks<M>;
357
+ getSharedStore(name?: string, scope?: UseSharedStateOptions['scope']): AnyStore;
358
+ useSharedState<T>(key: string, initial: T, options?: UseSharedStateOptions): [T, (next: T | ((prev: T) => T)) => void];
359
+ useSharedSelector<S extends Record<string, unknown>, T>(selector: (state: S) => T, options?: UseSharedSelectorOptions): T;
360
+ usePeers(options?: UsePeersOptions): readonly Peer$1[];
361
+ usePresenceMetadata(metadata: unknown, options?: UsePeersOptions): void;
362
+ useHydrated(options?: UseSharedStateOptions): boolean;
363
+ useClientId(options?: {
364
+ name?: string;
365
+ }): string;
366
+ useLeader(options?: UseLeaderOptions): LeaderSnapshot$1;
367
+ useIsLeader(options?: UseLeaderOptions): boolean;
368
+ useLeaderEffect(effect: () => void | (() => void), options?: UseLeaderOptions): void;
362
369
  }
363
370
  /**
364
371
  * Namespaced hooks and factories, so two independently deployed apps on one
@@ -381,8 +388,9 @@ interface ReactNamespace extends Namespace {
381
388
  * See the core `createNamespace` for what a namespace does and does not
382
389
  * guarantee. In short: it prevents collision, not access.
383
390
  */
384
- declare function createNamespace(namespace: string): ReactNamespace;
385
-
391
+ export declare function createNamespace(namespace: string): ReactNamespace;
392
+ //#endregion
393
+ //#region src/use-window-result.types.d.ts
386
394
  type OpenedWindowStatus = 'idle' | 'opening' | 'connected' | 'done' | 'closed-early' | 'error';
387
395
  /**
388
396
  * The flow's state as a discriminated union, so `status` narrows `result` and
@@ -391,43 +399,44 @@ type OpenedWindowStatus = 'idle' | 'opening' | 'connected' | 'done' | 'closed-ea
391
399
  * non-null assertion at every call site.
392
400
  */
393
401
  type OpenedWindowState<R> = {
394
- status: 'idle';
395
- result: undefined;
396
- error: undefined;
402
+ status: 'idle';
403
+ result: undefined;
404
+ error: undefined;
397
405
  } | {
398
- status: 'opening';
399
- result: undefined;
400
- error: undefined;
406
+ status: 'opening';
407
+ result: undefined;
408
+ error: undefined;
401
409
  } | {
402
- status: 'connected';
403
- result: undefined;
404
- error: undefined;
410
+ status: 'connected';
411
+ result: undefined;
412
+ error: undefined;
405
413
  } | {
406
- status: 'done';
407
- result: R;
408
- error: undefined;
409
- }
414
+ status: 'done';
415
+ result: R;
416
+ error: undefined;
417
+ } |
410
418
  /** The child window went away before calling finish(). */
411
- | {
412
- status: 'closed-early';
413
- result: undefined;
414
- error: WindowClosedError;
415
- }
419
+ {
420
+ status: 'closed-early';
421
+ result: undefined;
422
+ error: WindowClosedError$1;
423
+ } |
416
424
  /** The handshake timed out, the popup was blocked, or the factory threw. */
417
- | {
418
- status: 'error';
419
- result: undefined;
420
- error: unknown;
425
+ {
426
+ status: 'error';
427
+ result: undefined;
428
+ error: unknown;
421
429
  };
422
- interface OpenedWindowControls<Out extends MessageMap, In extends MessageMap, R> {
423
- /** Call from a click handler (popup blockers require a user gesture). */
424
- open: () => void;
425
- /** Post to the child; no-op while nothing is open. */
426
- post: OpenedWindow<Out, In, R>['post'];
427
- close: () => void;
430
+ interface OpenedWindowControls<Out extends MessageMap$1, In extends MessageMap$1, R> {
431
+ /** Call from a click handler (popup blockers require a user gesture). */
432
+ open: () => void;
433
+ /** Post to the child; no-op while nothing is open. */
434
+ post: OpenedWindow$1<Out, In, R>['post'];
435
+ close: () => void;
428
436
  }
429
- type UseWindowResult<Out extends MessageMap, In extends MessageMap, R> = OpenedWindowState<R> & OpenedWindowControls<Out, In, R>;
430
-
437
+ type UseWindowResult<Out extends MessageMap$1, In extends MessageMap$1, R> = OpenedWindowState<R> & OpenedWindowControls<Out, In, R>;
438
+ //#endregion
439
+ //#region src/use-window-result.d.ts
431
440
  /**
432
441
  * Drive an openWindow() flow from a component: the factory is called on
433
442
  * open(), and the child window's lifecycle is folded into render state.
@@ -437,29 +446,6 @@ type UseWindowResult<Out extends MessageMap, In extends MessageMap, R> = OpenedW
437
446
  * because a route changed would lose the user's in-flight transaction. Call
438
447
  * close() if the component owns the window's lifetime.
439
448
  */
440
- declare function useWindowResult<Out extends MessageMap, In extends MessageMap, R = unknown>(factory: () => OpenedWindow<Out, In, R>): UseWindowResult<Out, In, R>;
441
-
442
- /**
443
- * @deprecated Renamed to `useOnMessage`. Removed in 1.0 — `npx use-everywhere-codemod rename-1.0 src/`.
444
- */
445
- declare function useMessage<M extends MessageMap, R extends ReplyMap<M>, K extends keyof M & string>(channel: Channel<M, R>, type: K, handler: (payload: M[K], meta: MessageMeta) => void, options?: UseMessageOptions): void;
446
- /**
447
- * @deprecated Renamed to `useWindowResult`. Removed in 1.0 — `npx use-everywhere-codemod rename-1.0 src/`.
448
- */
449
- declare function useOpenedWindow<Out extends MessageMap, In extends MessageMap, R = unknown>(factory: () => OpenedWindow<Out, In, R>): UseWindowResult<Out, In, R>;
450
- /**
451
- * @deprecated Renamed to `useSharedSelector`. Removed in 1.0 — `npx use-everywhere-codemod rename-1.0 src/`.
452
- */
453
- declare function useSharedStore<S extends Record<string, unknown>, T>(selector: (state: S) => T, options?: UseSharedSelectorOptions): T;
454
- /**
455
- * @deprecated Renamed to `createStoreHooks`. Removed in 1.0 — `npx use-everywhere-codemod rename-1.0 src/`.
456
- */
457
- declare function defineStore<S extends Record<string, unknown> = Record<string, unknown>>(name: string, options?: DefineStoreOptions): StoreHooks<S>;
458
- /** @deprecated Renamed to `UseOnMessageOptions`. Removed in 1.0. */
459
- type UseMessageOptions = UseOnMessageOptions;
460
- /** @deprecated Renamed to `CreateStoreHooksOptions`. Removed in 1.0. */
461
- type DefineStoreOptions = CreateStoreHooksOptions;
462
- /** @deprecated Renamed to `UseWindowResult`. Removed in 1.0. */
463
- type UseOpenedWindow<Out extends MessageMap, In extends MessageMap, R> = UseWindowResult<Out, In, R>;
464
-
465
- export { type AnyStore, type ChannelHooks, type CreateStoreHooksOptions, type DefineStoreOptions, type OpenedWindowControls, type OpenedWindowState, type OpenedWindowStatus, type ReactNamespace, type ShareScope, type StoreHooks, type UseLeaderOptions, type UseMessageOptions, type UseOnMessageOptions, type UseOpenedWindow, type UsePeersOptions, type UseSharedReducerOptions, type UseSharedSelectorOptions, type UseSharedStateOptions, type UseWindowResult, createNamespace, createStoreHooks, defineChannel, defineStore, getLeader, getSharedStore, shallowEqual, useAnswer, useAsk, useChannel, useClientId, useHydrated, useIsLeader, useLeader, useLeaderEffect, useMessage, useOnMessage, useOpenedWindow, usePeers, usePresenceMetadata, useSend, useSharedReducer, useSharedSelector, useSharedState, useSharedStore, useWindowResult };
449
+ export declare function useWindowResult<Out extends MessageMap$1, In extends MessageMap$1, R = unknown>(factory: () => OpenedWindow$1<Out, In, R>): UseWindowResult<Out, In, R>;
450
+ //#endregion
451
+ export { type AnyStore, type AskOptions, BroadcastChannelTransport, type BusEvent, type BusObserver, type BusWire, CID_PARAM, type Channel, type ChannelHooks, type ChannelOptions, type CommonOptions, type ConnectToOpenerOptions, type CreateStoreHooksOptions, DEFAULT_NAME, type DebugOptions, HandshakeTimeoutError, type IndexedDbAdapterOptions, type InvalidPayload, type Leader, type LeaderOptions, type LeaderSnapshot, type LeaderStrategy, type LockManagerLike, type MessageEventLike, type MessageMap, type MessageMeta, type MessagePortLike, type Namespace, NoopTransport, type OnInvalid, type OnOptions, type OpenWindowOptions, type OpenedWindow, type OpenedWindowControls, type OpenedWindowState, type OpenedWindowStatus, type OpenerConnection, type Peer, type PeerKind, type PersistAdapter, type PersistOptions, type Persisted, type PostOptions, type Presence, type PresenceOptions, type ReactNamespace, type ReplyMap, type RestoreError, type SchemaMap, type SchemaOptions, type Serializer, type ShareScope, type SharedReducer, type SharedReducerOptions, type SharedStore, type SharedStoreOptions, type SharedWorkerLike, SharedWorkerTransport, type SharedWorkerTransportOptions, type StandardSchemaV1, type StorageLike, StorageTransport, type StoreHooks, type Transport, type TransportKind, type UseLeaderOptions, type UseOnMessageOptions, type UsePeersOptions, type UseSharedReducerOptions, type UseSharedSelectorOptions, type UseSharedStateOptions, type UseWindowResult, type Version, WIRE_VERSION, type WebStorageAdapterOptions, WindowClosedError, type WindowEventTarget, type WindowLike, connectToOpener, createChannel, createLeader, createPresence, createSharedReducer, createSharedStore, defaultTransport, enableDebug, getBusNames, getTransportKind, getWireSkew, indexedDbAdapter, isBroadcastChannelAvailable, isSharedWorkerAvailable, isStorageEventAvailable, jsonSerializer, localStorageAdapter, newer, observeBus, openWindow, sessionStorageAdapter, webStorageAdapter };