@securitydept/client 0.3.0-beta.3 → 0.3.0-beta.5

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.
Files changed (58) hide show
  1. package/README.md +6 -0
  2. package/dist/create-Bm-XRA3G.mjs +1573 -0
  3. package/dist/create-Bm-XRA3G.mjs.map +1 -0
  4. package/dist/index-BT-u3qNI.d.mts +133 -0
  5. package/dist/index-Ch8lrE44.d.mts +625 -0
  6. package/dist/index-D5mW18cM.d.mts +1648 -0
  7. package/dist/index.d.mts +3 -353
  8. package/dist/index.mjs +1124 -362
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/router-BJ8LqNJ1.mjs +245 -0
  11. package/dist/router-BJ8LqNJ1.mjs.map +1 -0
  12. package/dist/rx/index.d.mts +69 -0
  13. package/dist/rx/index.mjs +2 -0
  14. package/dist/rx-BoB32Dzg.mjs +1106 -0
  15. package/dist/rx-BoB32Dzg.mjs.map +1 -0
  16. package/dist/server/index.d.mts +21 -0
  17. package/dist/server/index.mjs +29 -0
  18. package/dist/server/index.mjs.map +1 -0
  19. package/dist/test/index.d.mts +102 -0
  20. package/dist/test/index.mjs +270 -0
  21. package/dist/test/index.mjs.map +1 -0
  22. package/dist/uri-string-BfnIT4gJ.mjs +298 -0
  23. package/dist/uri-string-BfnIT4gJ.mjs.map +1 -0
  24. package/dist/web/index.d.mts +82 -364
  25. package/dist/web/index.mjs +329 -428
  26. package/dist/web/index.mjs.map +1 -1
  27. package/dist/webext/index.d.mts +74 -0
  28. package/dist/webext/index.mjs +229 -0
  29. package/dist/webext/index.mjs.map +1 -0
  30. package/package.json +28 -21
  31. package/dist/auth-coordination/index.d.mts +0 -198
  32. package/dist/auth-coordination/index.mjs +0 -107
  33. package/dist/auth-coordination/index.mjs.map +0 -1
  34. package/dist/client-environment-CaumNmir.mjs +0 -812
  35. package/dist/client-environment-CaumNmir.mjs.map +0 -1
  36. package/dist/client-environment-CdHtVxKW.d.mts +0 -401
  37. package/dist/events/index.d.mts +0 -2
  38. package/dist/events/index.mjs +0 -2
  39. package/dist/events-BUlfsRfl.mjs +0 -127
  40. package/dist/events-BUlfsRfl.mjs.map +0 -1
  41. package/dist/index-C4xlKhG7.d.mts +0 -102
  42. package/dist/index-COUt5x9Z.d.mts +0 -39
  43. package/dist/persistence/index.d.mts +0 -3
  44. package/dist/persistence/index.mjs +0 -2
  45. package/dist/persistence/web/index.d.mts +0 -16
  46. package/dist/persistence/web/index.mjs +0 -2
  47. package/dist/persistence-CSB8770k.mjs +0 -108
  48. package/dist/persistence-CSB8770k.mjs.map +0 -1
  49. package/dist/planner-host-BTWie0lo.mjs +0 -197
  50. package/dist/planner-host-BTWie0lo.mjs.map +0 -1
  51. package/dist/planner-host-DN9dRsQx.d.mts +0 -190
  52. package/dist/types-BJqUdH2e.d.mts +0 -32
  53. package/dist/types-BwcnUGNl.d.mts +0 -52
  54. package/dist/web-DQmMqZnR.mjs +0 -51
  55. package/dist/web-DQmMqZnR.mjs.map +0 -1
  56. package/dist/web-router/index.d.mts +0 -259
  57. package/dist/web-router/index.mjs +0 -395
  58. package/dist/web-router/index.mjs.map +0 -1
@@ -1,52 +1,84 @@
1
- import { A as createFetchTransport, C as readPageLocationCapability, D as requirePageClientEnvironment, E as requireDefaultPageLocationHistoryCapability, K as ClientEnvironment, O as FetchTransportOptions, R as Subscription, S as readDefaultPageLocationHistoryCapability, T as requireDefaultPageLocationCapability, _ as createBrowserWorkerClientEnvironment, a as PageHistoryLike, b as deriveClientEnvironment, c as PageLocationLike, d as assertPageLocationCapability, f as assertPageLocationHistoryCapability, g as createBrowserPageClientEnvironment, h as createBrowserExtensionBackgroundClientEnvironment, i as PageClientEnvironment, k as FetchTransportRedirectKind, l as RequirePageClientEnvironmentOptions, lt as CancellationTokenTrait, m as assertResolveFromEnvironment, n as CreateBrowserPageClientEnvironmentOptions, o as PageLocationCapability, p as assertResolveEnvironment, r as CreateWebClientEnvironmentOptions, s as PageLocationHistoryCapability, t as ClientEnvironmentPreset, u as WebClientEnvironment, v as createServiceWorkerClientEnvironment, w as readPageLocationHistoryCapability, x as readDefaultPageLocationCapability, y as createWebClientEnvironment } from "../client-environment-CdHtVxKW.mjs";
1
+ import { E as TimeTrait, Xt as WithTraitDeps, ct as EventStreamTrait } from "../index-Ch8lrE44.mjs";
2
+ import { Dn as WithTraitInputValidator, Lt as EnvironmentValidators, Pt as CreateFoundationEnvironmentOptions, Rt as FoundationEnvironment, Tr as PopupTrait, Vn as RouterTrait, on as SyncStorageTrait } from "../index-D5mW18cM.mjs";
3
+ import { _ as createPageResumeSource, a as NativeWebWindowLike, b as fromStorageEvent, c as WebNavigationRouter, d as createPageLifecycleForNativeWeb, f as CreatePageResumeSourceOptions, g as PageResumeWindowTarget, h as PageResumeTriggerKind, i as NativeWebRouter, l as createRouterForNativeWeb, m as PageResumeEvent, n as NativeWebLocationLike, o as RouterForNativeWebCreateOptions, p as PageResumeDocumentTarget, r as NativeWebNavigationLike, s as WebLegacyRouter, t as NativeWebHistoryLike, u as PageLifecycleForNativeWebCreateOptions, v as FromStorageEventOptions, y as StorageEventTarget } from "../index-BT-u3qNI.mjs";
2
4
 
3
- //#region src/web/cancellation.d.ts
4
- interface AbortSignalBridge {
5
- signal?: AbortSignal;
6
- dispose(): void;
5
+ //#region src/web/popup.d.ts
6
+ interface PopupForNativeWebCreateOptions {
7
+ window?: unknown;
7
8
  }
8
- /**
9
- * Bridge a web `AbortSignal` back into the foundation cancellation contract.
10
- *
11
- * This is the canonical consumer-side path for browser hosts that receive an
12
- * `AbortSignal` from framework/runtime APIs (for example React Query queryFns)
13
- * but need to call SDK surfaces that accept `CancellationTokenTrait`.
14
- */
15
- declare function createCancellationTokenFromAbortSignal(signal?: AbortSignal): CancellationTokenTrait | undefined;
16
- /**
17
- * Bridge foundation cancellation to web `AbortSignal` without exposing
18
- * `AbortSignal` in core contracts.
19
- */
20
- declare function createAbortSignalBridge(token?: CancellationTokenTrait): AbortSignalBridge;
21
- declare function normalizeAbortError(token: CancellationTokenTrait | undefined, error: unknown): unknown;
9
+ interface PopupFeaturesOptions {
10
+ width?: number;
11
+ height?: number;
12
+ }
13
+ interface NativeWebPopupWindowLike {
14
+ closed: boolean;
15
+ close(): void;
16
+ postMessage(message: unknown, targetOrigin: string): void;
17
+ }
18
+ interface NativeWebWindowLike$1 {
19
+ open(url: string, target?: string, features?: string): NativeWebPopupWindowLike | null;
20
+ addEventListener(type: "message", handler: (event: MessageEvent) => void): void;
21
+ removeEventListener(type: "message", handler: (event: MessageEvent) => void): void;
22
+ location?: {
23
+ href?: string;
24
+ origin?: string;
25
+ };
26
+ screenX?: number;
27
+ screenY?: number;
28
+ innerWidth?: number;
29
+ innerHeight?: number;
30
+ close?(): void;
31
+ opener?: {
32
+ postMessage(message: unknown, targetOrigin: string): void;
33
+ } | null;
34
+ }
35
+ declare function createPopupForNativeWeb(options: PopupForNativeWebCreateOptions & WithTraitInputValidator<Pick<EnvironmentValidators, "popup">> & WithTraitDeps<{
36
+ time: TimeTrait;
37
+ }>): PopupTrait | null;
38
+ declare function computePopupFeatures(options?: PopupFeaturesOptions, windowLike?: Pick<NativeWebWindowLike$1, "screenX" | "screenY" | "innerWidth" | "innerHeight">): string;
39
+ //#endregion
40
+ //#region src/web/storage.d.ts
41
+ interface NativeWebStorageLike {
42
+ getItem(key: string): string | null;
43
+ setItem(key: string, value: string): void;
44
+ removeItem(key: string): void;
45
+ }
46
+ interface StorageForNativeWebCreateOptions {
47
+ storage?: NativeWebStorageLike | null;
48
+ storageEventTarget?: StorageEventTarget | null;
49
+ prefix?: string;
50
+ validatorKey: "persistentStorage" | "sessionStorage";
51
+ }
52
+ declare function createStorageForNativeWeb(options: StorageForNativeWebCreateOptions & WithTraitInputValidator<Pick<EnvironmentValidators, "persistentStorage" | "sessionStorage">>): SyncStorageTrait | null;
53
+ declare function createPersistentStorageForNativeWeb(options: Omit<StorageForNativeWebCreateOptions, "validatorKey"> & WithTraitInputValidator<Pick<EnvironmentValidators, "persistentStorage" | "sessionStorage">>): SyncStorageTrait | null;
54
+ declare function createSessionStorageForNativeWeb(options: Omit<StorageForNativeWebCreateOptions, "validatorKey"> & WithTraitInputValidator<Pick<EnvironmentValidators, "persistentStorage" | "sessionStorage">>): SyncStorageTrait | null;
55
+ //#endregion
56
+ //#region src/web/environment.d.ts
57
+ interface NativeWebEnvironment extends FoundationEnvironment {
58
+ router: RouterTrait;
59
+ }
60
+ interface CreateEnvironmentForNativeWebOptions extends CreateFoundationEnvironmentOptions {
61
+ routerForNativeWebCreateOptions?: RouterForNativeWebCreateOptions;
62
+ pageLifecycleForNativeWebCreateOptions?: PageLifecycleForNativeWebCreateOptions;
63
+ popupForNativeWebCreateOptions?: PopupForNativeWebCreateOptions;
64
+ persistentStorageForNativeWebCreateOptions?: Omit<StorageForNativeWebCreateOptions, "validatorKey">;
65
+ sessionStorageForNativeWebCreateOptions?: Omit<StorageForNativeWebCreateOptions, "validatorKey">;
66
+ }
67
+ declare function createEnvironmentForNativeWeb(options: CreateEnvironmentForNativeWebOptions): NativeWebEnvironment;
22
68
  //#endregion
23
- //#region src/web/cross-tab-sync.d.ts
24
- /** Callback invoked when a cross-tab storage change is detected for the watched key. */
25
- type CrossTabSyncCallback = (event: {
26
- /** The new value written by the other tab, or null if the key was removed. */newValue: string | null; /** The old value before the other tab's write. */
69
+ //#region src/web/sync/cross-tab-sync.d.ts
70
+ /** Event emitted when a cross-tab storage change is detected for the watched key. */
71
+ interface CrossTabSyncEvent {
72
+ /** The new value written by the other tab, or null if the key was removed. */
73
+ newValue: string | null;
74
+ /** The old value before the other tab's write. */
27
75
  oldValue: string | null;
28
- }) => void;
76
+ }
29
77
  /** Options for {@link createCrossTabSync}. */
30
78
  interface CreateCrossTabSyncOptions {
31
79
  /** The localStorage key to watch for cross-tab changes. */
32
80
  key: string;
33
- /** Called when another tab modifies the watched key. */
34
- onSync: CrossTabSyncCallback;
35
- /**
36
- * Override the window target (primarily for testing).
37
- * Defaults to `globalThis`.
38
- */
39
- target?: {
40
- addEventListener(type: string, listener: EventListener): void;
41
- removeEventListener(type: string, listener: EventListener): void;
42
- };
43
- }
44
- /** Handle returned by {@link createCrossTabSync}. */
45
- interface CrossTabSync {
46
- /** Stop listening for cross-tab storage events. */
47
- dispose(): void;
48
- /** Number of times a sync event has been received. */
49
- readonly syncCount: number;
81
+ storageEventTarget: StorageEventTarget;
50
82
  }
51
83
  /**
52
84
  * Create a cross-tab sync listener for a specific localStorage key.
@@ -56,339 +88,25 @@ interface CrossTabSync {
56
88
  *
57
89
  * @example
58
90
  * ```ts
59
- * const sync = createCrossTabSync({
91
+ * const subscription = createCrossTabSync({
60
92
  * key: "auth:v1",
61
- * onSync: ({ newValue }) => {
93
+ * storageEventTarget: window,
94
+ * }).subscribe({
95
+ * next: ({ newValue }) => {
62
96
  * if (newValue) {
63
97
  * // Another tab updated auth state — reconcile
64
- * controller.restoreFromPersistence();
98
+ * client.restorePersistedState();
65
99
  * } else {
66
100
  * // Another tab cleared auth state — log out
67
- * controller.clearState({ clearPersisted: false });
68
- * }
69
- * },
70
- * });
71
- * // Later:
72
- * sync.dispose();
73
- * ```
74
- */
75
- declare function createCrossTabSync(options: CreateCrossTabSyncOptions): CrossTabSync;
76
- //#endregion
77
- //#region src/web/environment-service.d.ts
78
- type MaybePromise<T> = T | Promise<T>;
79
- interface ClientEnvironmentServiceOptions<TClientEnvironment extends ClientEnvironment = ClientEnvironment, TWebEnvironment extends WebClientEnvironment = WebClientEnvironment, TPageEnvironment extends PageClientEnvironment = PageClientEnvironment> {
80
- createClientEnvironment?: () => MaybePromise<TClientEnvironment>;
81
- createWebEnvironment?: (clientEnvironment: TClientEnvironment) => MaybePromise<TWebEnvironment>;
82
- createPageEnvironment?: (webEnvironment: TWebEnvironment) => MaybePromise<TPageEnvironment>;
83
- }
84
- /**
85
- * Framework-neutral environment resolver with layered lazy materialization.
86
- *
87
- * `resolve*()` coalesces concurrent work into a single pending promise.
88
- * `read*()` is Suspense-compatible: pending resolutions throw the same promise,
89
- * rejections throw the cached error, and fulfilled layers return the value.
90
- *
91
- * `reset()` invalidates all cached layers. In-flight promises may still settle
92
- * for existing awaiters, but their results are discarded and never repopulate
93
- * the service cache after a reset.
94
- */
95
- declare class ClientEnvironmentService<TClientEnvironment extends ClientEnvironment = ClientEnvironment, TWebEnvironment extends WebClientEnvironment = WebClientEnvironment, TPageEnvironment extends PageClientEnvironment = PageClientEnvironment> {
96
- private readonly createClientEnvironmentImpl;
97
- private readonly createWebEnvironmentImpl;
98
- private readonly createPageEnvironmentImpl;
99
- private readonly clientState;
100
- private readonly webState;
101
- private readonly pageState;
102
- constructor(options?: ClientEnvironmentServiceOptions<TClientEnvironment, TWebEnvironment, TPageEnvironment>);
103
- resolveClientEnvironment(): Promise<TClientEnvironment>;
104
- resolveWebEnvironment(): Promise<TWebEnvironment>;
105
- resolvePageEnvironment(): Promise<TPageEnvironment>;
106
- readClientEnvironment(): TClientEnvironment;
107
- readWebEnvironment(): TWebEnvironment;
108
- readPageEnvironment(): TPageEnvironment;
109
- reset(): void;
110
- private resolveState;
111
- private readState;
112
- private resetState;
113
- }
114
- //#endregion
115
- //#region src/web/input-sources.d.ts
116
- interface AbortSignalSource {
117
- aborted: boolean;
118
- reason: unknown;
119
- addEventListener(type: string, listener: EventListener): void;
120
- removeEventListener(type: string, listener: EventListener): void;
121
- }
122
- interface FromAbortSignalOptions {
123
- /** AbortSignal to observe. */
124
- signal?: AbortSignalSource;
125
- /** Callback invoked when the signal aborts. */
126
- callback: (reason: unknown) => void;
127
- /**
128
- * Emit immediately when the signal is already aborted at subscribe time.
129
- * Defaults to `false`.
130
- */
131
- emitIfAborted?: boolean;
132
- }
133
- interface StorageEventTarget {
134
- addEventListener(type: string, listener: EventListener): void;
135
- removeEventListener(type: string, listener: EventListener): void;
136
- }
137
- interface FromStorageEventOptions {
138
- /**
139
- * Storage-event target. Defaults to `globalThis`, which is appropriate for
140
- * browser hosts and jsdom-based tests.
141
- */
142
- target?: StorageEventTarget;
143
- /** Callback invoked for each browser `storage` event. */
144
- callback: (event: StorageEvent) => void;
145
- }
146
- /**
147
- * Adapt a browser AbortSignal into the shared Subscription model.
148
- */
149
- declare function fromAbortSignal(options: FromAbortSignalOptions): Subscription;
150
- /**
151
- * Adapt browser `storage` events into the shared Subscription model.
152
- */
153
- declare function fromStorageEvent(options: FromStorageEventOptions): Subscription;
154
- //#endregion
155
- //#region src/web/page-resume-reconciler.d.ts
156
- declare const PageResumeTriggerKind: {
157
- readonly Visibility: "visibility";
158
- readonly PageShow: "pageshow";
159
- readonly Focus: "focus";
160
- readonly Online: "online";
161
- };
162
- type PageResumeTriggerKind = (typeof PageResumeTriggerKind)[keyof typeof PageResumeTriggerKind];
163
- interface PageResumeEvent {
164
- trigger: PageResumeTriggerKind;
165
- persisted?: boolean;
166
- }
167
- type PageResumeCallback = (event: PageResumeEvent) => void | Promise<void>;
168
- interface PageResumeDocumentTarget {
169
- addEventListener(type: "visibilitychange", handler: EventListener): void;
170
- removeEventListener(type: "visibilitychange", handler: EventListener): void;
171
- visibilityState: DocumentVisibilityState;
172
- }
173
- interface PageResumeWindowTarget {
174
- addEventListener(type: "pageshow" | "focus" | "online", handler: EventListener): void;
175
- removeEventListener(type: "pageshow" | "focus" | "online", handler: EventListener): void;
176
- }
177
- interface CreatePageResumeReconcilerOptions {
178
- onReconcile: PageResumeCallback;
179
- /** Defaults to 5000ms. Use 0 in deterministic tests. */
180
- throttleMs?: number;
181
- document?: PageResumeDocumentTarget | null;
182
- window?: PageResumeWindowTarget | null;
183
- now?: () => number;
184
- onError?: (error: unknown, event: PageResumeEvent) => void;
185
- }
186
- interface PageResumeReconciler {
187
- dispose(): void;
188
- readonly reconcileCount: number;
189
- }
190
- declare function createPageResumeReconciler(options: CreatePageResumeReconcilerOptions): PageResumeReconciler;
191
- //#endregion
192
- //#region src/web/popup.d.ts
193
- /** Stable error codes for popup-related failures. */
194
- declare const PopupErrorCode: {
195
- /** The browser blocked the popup window from opening. */readonly Blocked: "popup.blocked"; /** The popup was closed by the user before completing the flow. */
196
- readonly Closed: "popup.closed_by_user"; /** The relay message was not received within the timeout. */
197
- readonly Timeout: "popup.relay_timeout"; /** The relay message contained an error from the callback page. */
198
- readonly RelayError: "popup.relay_error"; /** An unexpected error occurred during popup lifecycle. */
199
- readonly Internal: "popup.internal";
200
- };
201
- type PopupErrorCode = (typeof PopupErrorCode)[keyof typeof PopupErrorCode];
202
- /**
203
- * Options for computing the popup window features string.
204
- */
205
- interface PopupFeaturesOptions {
206
- /** Width in pixels (default: 500). */
207
- width?: number;
208
- /** Height in pixels (default: 600). */
209
- height?: number;
210
- }
211
- /**
212
- * Compute the `features` string for `window.open()`, centered on screen.
213
- */
214
- declare function computePopupFeatures(options?: PopupFeaturesOptions): string;
215
- /**
216
- * Result of opening a popup window.
217
- */
218
- interface PopupWindowHandle {
219
- /** The opened window reference. */
220
- window: Window;
221
- }
222
- /**
223
- * Open a popup window to the given URL.
224
- *
225
- * Throws a `ClientError` with code `popup.blocked` if the browser
226
- * blocks the popup.
227
- */
228
- declare function openPopupWindow(url: string, options?: PopupFeaturesOptions & {
229
- target?: string;
230
- }): PopupWindowHandle;
231
- /**
232
- * Expected shape of a relay message from the popup callback page.
233
- */
234
- interface PopupRelayMessage {
235
- /** Discriminator for the message type. */
236
- type: "securitydept:popup_callback";
237
- /** The callback URL or fragment received by the popup. */
238
- payload: string;
239
- /** Optional error from the callback page. */
240
- error?: string;
241
- }
242
- /**
243
- * Options for waiting for a popup relay message.
244
- */
245
- interface WaitForPopupRelayOptions {
246
- /** The popup window handle to monitor. */
247
- popup: PopupWindowHandle;
248
- /** Maximum time to wait in milliseconds (default: 120000 = 2 minutes). */
249
- timeoutMs?: number;
250
- /** Expected origin for the relay message (default: current origin). */
251
- expectedOrigin?: string;
252
- /** Poll interval for checking if the popup is closed (default: 500ms). */
253
- pollIntervalMs?: number;
254
- }
255
- /**
256
- * Wait for a relay message from a popup callback page.
257
- *
258
- * The popup callback page should call `relayPopupCallback()` to post
259
- * the callback URL back to the opener.
260
- *
261
- * Resolves with the callback payload (URL or fragment string).
262
- * Rejects with a `ClientError` if:
263
- * - the popup is closed without relaying (popup.closed_by_user)
264
- * - the timeout expires (popup.relay_timeout)
265
- * - the relay message contains an error (popup.relay_error)
266
- */
267
- declare function waitForPopupRelay(options: WaitForPopupRelayOptions): Promise<string>;
268
- /**
269
- * Options for relaying the callback from the popup window back to the opener.
270
- */
271
- interface RelayPopupCallbackOptions {
272
- /** The callback payload (URL or fragment) to relay. */
273
- payload?: string;
274
- /** An error message to relay instead of a successful payload. */
275
- error?: string;
276
- /** Whether to close the popup after relaying (default: true). */
277
- closeAfterRelay?: boolean;
278
- /** Target origin for the postMessage (default: current origin). */
279
- targetOrigin?: string;
280
- }
281
- /**
282
- * Relay the popup callback result back to the opener window.
283
- *
284
- * Call this function from the popup callback page to send the callback
285
- * URL/fragment back to the parent window that initiated the popup login.
286
- *
287
- * @example
288
- * ```html
289
- * <script type="module">
290
- * import { relayPopupCallback } from "@securitydept/client/web";
291
- * relayPopupCallback({ payload: window.location.href });
292
- * </script>
293
- * ```
294
- */
295
- declare function relayPopupCallback(options?: RelayPopupCallbackOptions): void;
296
- //#endregion
297
- //#region src/web/visibility.d.ts
298
- /** Visibility state snapshot passed to the callback. */
299
- declare const VisibilityState: {
300
- readonly Visible: "visible";
301
- readonly Hidden: "hidden";
302
- };
303
- type VisibilityState = (typeof VisibilityState)[keyof typeof VisibilityState];
304
- /** Options for {@link fromVisibilityChange}. */
305
- interface FromVisibilityChangeOptions {
306
- /**
307
- * Callback invoked when the document visibility state changes.
308
- *
309
- * The callback receives the new visibility state ("visible" or "hidden").
310
- */
311
- callback: (state: VisibilityState) => void;
312
- /**
313
- * Override the document target (primarily for testing).
314
- * Defaults to `globalThis.document`.
315
- */
316
- document?: Pick<Document, "addEventListener" | "removeEventListener" | "visibilityState">;
317
- }
318
- /**
319
- * Subscribe to browser document visibility changes.
320
- *
321
- * Built on {@link fromEventPattern} so it follows the same Subscription
322
- * contract. Returns a {@link Subscription} handle for cleanup.
323
- *
324
- * @example
325
- * ```ts
326
- * const sub = fromVisibilityChange({
327
- * callback: (state) => {
328
- * if (state === VisibilityState.Visible) {
329
- * scheduleRefresh();
330
- * }
331
- * },
332
- * });
333
- * // Cleanup:
334
- * sub.unsubscribe();
335
- * ```
336
- */
337
- declare function fromVisibilityChange(options: FromVisibilityChangeOptions): Subscription;
338
- //#endregion
339
- //#region src/web/visibility-reconciler.d.ts
340
- /** Callback invoked when the page becomes visible and reconciliation is needed. */
341
- type ReconcileCallback = () => void | Promise<void>;
342
- /** Options for {@link createVisibilityReconciler}. */
343
- interface CreateVisibilityReconcilerOptions {
344
- /**
345
- * Called when the document transitions from hidden → visible.
346
- * The reconciler only fires on the hidden→visible edge; repeated
347
- * visible→visible events are suppressed.
348
- */
349
- onReconcile: ReconcileCallback;
350
- /**
351
- * Minimum interval (ms) between reconciliation triggers.
352
- * Prevents rapid-fire reconciliation when the user toggles tabs quickly.
353
- * Defaults to 5000ms (5 seconds).
354
- */
355
- throttleMs?: number;
356
- /**
357
- * Override the document target (primarily for testing).
358
- * Defaults to `globalThis.document`.
359
- */
360
- document?: FromVisibilityChangeOptions["document"];
361
- /**
362
- * Clock override for testing.
363
- */
364
- now?: () => number;
365
- }
366
- /** Handle returned by {@link createVisibilityReconciler}. */
367
- interface VisibilityReconciler {
368
- /** Stop listening for visibility changes. */
369
- dispose(): void;
370
- /** Number of times reconciliation has been triggered. */
371
- readonly reconcileCount: number;
372
- }
373
- /**
374
- * Create a visibility reconciler that triggers a callback when the page
375
- * transitions from hidden → visible.
376
- *
377
- * @example
378
- * ```ts
379
- * const reconciler = createVisibilityReconciler({
380
- * onReconcile: () => {
381
- * // Re-check token freshness or sync cross-tab state
382
- * if (controller.snapshot?.tokens.accessTokenExpiresAt) {
383
- * scheduleRefreshIfExpired();
101
+ * controller.clearState({ persistPolicy: "skip" });
384
102
  * }
385
103
  * },
386
104
  * });
387
105
  * // Later:
388
- * reconciler.dispose();
106
+ * subscription.unsubscribe();
389
107
  * ```
390
108
  */
391
- declare function createVisibilityReconciler(options: CreateVisibilityReconcilerOptions): VisibilityReconciler;
109
+ declare function createCrossTabSync(options: CreateCrossTabSyncOptions): EventStreamTrait<CrossTabSyncEvent>;
392
110
  //#endregion
393
- export { type AbortSignalBridge, type ClientEnvironment, ClientEnvironmentPreset, ClientEnvironmentService, type ClientEnvironmentServiceOptions, type CreateBrowserPageClientEnvironmentOptions, type CreateCrossTabSyncOptions, type CreatePageResumeReconcilerOptions, type CreateVisibilityReconcilerOptions, type CreateWebClientEnvironmentOptions, type CrossTabSync, type CrossTabSyncCallback, type FetchTransportOptions, FetchTransportRedirectKind, type FromAbortSignalOptions, type FromStorageEventOptions, type FromVisibilityChangeOptions, type PageClientEnvironment, type PageHistoryLike, type PageLocationCapability, type PageLocationHistoryCapability, type PageLocationLike, type PageResumeCallback, type PageResumeDocumentTarget, type PageResumeEvent, type PageResumeReconciler, PageResumeTriggerKind, type PageResumeWindowTarget, PopupErrorCode, type PopupFeaturesOptions, type PopupRelayMessage, type PopupWindowHandle, type ReconcileCallback, type RelayPopupCallbackOptions, type RequirePageClientEnvironmentOptions, type VisibilityReconciler, VisibilityState, type WaitForPopupRelayOptions, type WebClientEnvironment, assertPageLocationCapability, assertPageLocationHistoryCapability, assertResolveEnvironment, assertResolveFromEnvironment, computePopupFeatures, createAbortSignalBridge, createBrowserExtensionBackgroundClientEnvironment, createBrowserPageClientEnvironment, createBrowserWorkerClientEnvironment, createCancellationTokenFromAbortSignal, createCrossTabSync, createFetchTransport, createPageResumeReconciler, createServiceWorkerClientEnvironment, createVisibilityReconciler, createWebClientEnvironment, deriveClientEnvironment, fromAbortSignal, fromStorageEvent, fromVisibilityChange, normalizeAbortError, openPopupWindow, readDefaultPageLocationCapability, readDefaultPageLocationHistoryCapability, readPageLocationCapability, readPageLocationHistoryCapability, relayPopupCallback, requireDefaultPageLocationCapability, requireDefaultPageLocationHistoryCapability, requirePageClientEnvironment, waitForPopupRelay };
111
+ export { type CreateCrossTabSyncOptions, type CreateEnvironmentForNativeWebOptions, type CreatePageResumeSourceOptions, type CrossTabSyncEvent, type FoundationEnvironment, type FromStorageEventOptions, type NativeWebEnvironment, type NativeWebHistoryLike, type NativeWebLocationLike, type NativeWebNavigationLike, NativeWebRouter, type NativeWebStorageLike, type NativeWebWindowLike, type PageLifecycleForNativeWebCreateOptions, type PageResumeDocumentTarget, type PageResumeEvent, PageResumeTriggerKind, type PageResumeWindowTarget, type PopupFeaturesOptions, type PopupForNativeWebCreateOptions, type RouterForNativeWebCreateOptions, type StorageEventTarget, type StorageForNativeWebCreateOptions, WebLegacyRouter, WebNavigationRouter, computePopupFeatures, createCrossTabSync, createEnvironmentForNativeWeb, createPageLifecycleForNativeWeb, createPageResumeSource, createPersistentStorageForNativeWeb, createPopupForNativeWeb, createRouterForNativeWeb, createSessionStorageForNativeWeb, createStorageForNativeWeb, fromStorageEvent };
394
112
  //# sourceMappingURL=index.d.mts.map