@securitydept/client 0.2.0 → 0.3.0-beta.10
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/README.md +6 -0
- package/dist/create-i5VyYgN6.mjs +989 -0
- package/dist/create-i5VyYgN6.mjs.map +1 -0
- package/dist/handle-DwMgqe7R.mjs +638 -0
- package/dist/handle-DwMgqe7R.mjs.map +1 -0
- package/dist/index-Bo1BtjZH.d.mts +132 -0
- package/dist/index-CFAJ969E.d.mts +674 -0
- package/dist/index-CbeZ3AfB.d.mts +1680 -0
- package/dist/index.d.mts +3 -353
- package/dist/index.mjs +1196 -401
- package/dist/index.mjs.map +1 -1
- package/dist/router-at5bTdJQ.mjs +245 -0
- package/dist/router-at5bTdJQ.mjs.map +1 -0
- package/dist/rx/index.d.mts +68 -0
- package/dist/rx/index.mjs +2 -0
- package/dist/rx-DM6Ouv-m.mjs +1119 -0
- package/dist/rx-DM6Ouv-m.mjs.map +1 -0
- package/dist/server/index.d.mts +20 -0
- package/dist/server/index.mjs +29 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/test/index.d.mts +101 -0
- package/dist/test/index.mjs +270 -0
- package/dist/test/index.mjs.map +1 -0
- package/dist/uri-string-BPNbIMgv.mjs +300 -0
- package/dist/uri-string-BPNbIMgv.mjs.map +1 -0
- package/dist/web/index.d.mts +82 -337
- package/dist/web/index.mjs +334 -337
- package/dist/web/index.mjs.map +1 -1
- package/dist/webext/index.d.mts +73 -0
- package/dist/webext/index.mjs +231 -0
- package/dist/webext/index.mjs.map +1 -0
- package/package.json +28 -21
- package/dist/auth-coordination/index.d.mts +0 -198
- package/dist/auth-coordination/index.mjs +0 -107
- package/dist/auth-coordination/index.mjs.map +0 -1
- package/dist/events/index.d.mts +0 -2
- package/dist/events/index.mjs +0 -2
- package/dist/events-BUlfsRfl.mjs +0 -127
- package/dist/events-BUlfsRfl.mjs.map +0 -1
- package/dist/fetch-transport-Bd5RyWj2.d.mts +0 -339
- package/dist/fetch-transport-DtnSRWAH.mjs +0 -631
- package/dist/fetch-transport-DtnSRWAH.mjs.map +0 -1
- package/dist/index-C_wgl6dW.d.mts +0 -102
- package/dist/index-DbYSFHDe.d.mts +0 -39
- package/dist/persistence/index.d.mts +0 -3
- package/dist/persistence/index.mjs +0 -2
- package/dist/persistence/web/index.d.mts +0 -16
- package/dist/persistence/web/index.mjs +0 -51
- package/dist/persistence/web/index.mjs.map +0 -1
- package/dist/persistence-CSB8770k.mjs +0 -108
- package/dist/persistence-CSB8770k.mjs.map +0 -1
- package/dist/planner-host-CPyGNyQV.d.mts +0 -190
- package/dist/planner-host-CV38bMSn.mjs +0 -195
- package/dist/planner-host-CV38bMSn.mjs.map +0 -1
- package/dist/types-C59fcM5W.d.mts +0 -52
- package/dist/types-DQc088ZP.d.mts +0 -32
- package/dist/web-router/index.d.mts +0 -259
- package/dist/web-router/index.mjs +0 -395
- package/dist/web-router/index.mjs.map +0 -1
package/dist/web/index.d.mts
CHANGED
|
@@ -1,52 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Ct as EventStreamTrait, T as TimeTrait, ln as WithTraitDeps } from "../index-CFAJ969E.mjs";
|
|
2
|
+
import { Bt as EnvironmentValidators, Er as PopupTrait, Hn as RouterTrait, Lt as CreateFoundationEnvironmentOptions, Mn as WithTraitInputValidator, Vt as FoundationEnvironment, dn as SyncStorageTrait } from "../index-CbeZ3AfB.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-Bo1BtjZH.mjs";
|
|
4
|
+
//#region src/web/popup.d.ts
|
|
5
|
+
interface PopupForNativeWebCreateOptions {
|
|
6
|
+
window?: unknown;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
interface PopupFeaturesOptions {
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
}
|
|
12
|
+
interface NativeWebPopupWindowLike {
|
|
13
|
+
closed: boolean;
|
|
14
|
+
close(): void;
|
|
15
|
+
postMessage(message: unknown, targetOrigin: string): void;
|
|
16
|
+
}
|
|
17
|
+
interface NativeWebWindowLike$1 {
|
|
18
|
+
open(url: string, target?: string, features?: string): NativeWebPopupWindowLike | null;
|
|
19
|
+
addEventListener(type: "message", handler: (event: MessageEvent) => void): void;
|
|
20
|
+
removeEventListener(type: "message", handler: (event: MessageEvent) => void): void;
|
|
21
|
+
location?: {
|
|
22
|
+
href?: string;
|
|
23
|
+
origin?: string;
|
|
24
|
+
};
|
|
25
|
+
screenX?: number;
|
|
26
|
+
screenY?: number;
|
|
27
|
+
innerWidth?: number;
|
|
28
|
+
innerHeight?: number;
|
|
29
|
+
close?(): void;
|
|
30
|
+
opener?: {
|
|
31
|
+
postMessage(message: unknown, targetOrigin: string): void;
|
|
32
|
+
} | null;
|
|
33
|
+
}
|
|
34
|
+
declare function createPopupForNativeWeb(options: PopupForNativeWebCreateOptions & WithTraitInputValidator<Pick<EnvironmentValidators, "popup">> & WithTraitDeps<{
|
|
35
|
+
time: TimeTrait;
|
|
36
|
+
}>): PopupTrait | null;
|
|
37
|
+
declare function computePopupFeatures(options?: PopupFeaturesOptions, windowLike?: Pick<NativeWebWindowLike$1, "screenX" | "screenY" | "innerWidth" | "innerHeight">): string;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/web/storage.d.ts
|
|
40
|
+
interface NativeWebStorageLike {
|
|
41
|
+
getItem(key: string): string | null;
|
|
42
|
+
setItem(key: string, value: string): void;
|
|
43
|
+
removeItem(key: string): void;
|
|
44
|
+
}
|
|
45
|
+
interface StorageForNativeWebCreateOptions {
|
|
46
|
+
storage?: NativeWebStorageLike | null;
|
|
47
|
+
storageEventTarget?: StorageEventTarget | null;
|
|
48
|
+
prefix?: string;
|
|
49
|
+
validatorKey: "persistentStorage" | "sessionStorage";
|
|
50
|
+
}
|
|
51
|
+
declare function createStorageForNativeWeb(options: StorageForNativeWebCreateOptions & WithTraitInputValidator<Pick<EnvironmentValidators, "persistentStorage" | "sessionStorage">>): SyncStorageTrait | null;
|
|
52
|
+
declare function createPersistentStorageForNativeWeb(options: Omit<StorageForNativeWebCreateOptions, "validatorKey"> & WithTraitInputValidator<Pick<EnvironmentValidators, "persistentStorage" | "sessionStorage">>): SyncStorageTrait | null;
|
|
53
|
+
declare function createSessionStorageForNativeWeb(options: Omit<StorageForNativeWebCreateOptions, "validatorKey"> & WithTraitInputValidator<Pick<EnvironmentValidators, "persistentStorage" | "sessionStorage">>): SyncStorageTrait | null;
|
|
22
54
|
//#endregion
|
|
23
|
-
//#region src/web/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
55
|
+
//#region src/web/environment.d.ts
|
|
56
|
+
interface NativeWebEnvironment extends FoundationEnvironment {
|
|
57
|
+
router: RouterTrait;
|
|
58
|
+
}
|
|
59
|
+
interface CreateEnvironmentForNativeWebOptions extends CreateFoundationEnvironmentOptions {
|
|
60
|
+
routerForNativeWebCreateOptions?: RouterForNativeWebCreateOptions;
|
|
61
|
+
pageLifecycleForNativeWebCreateOptions?: PageLifecycleForNativeWebCreateOptions;
|
|
62
|
+
popupForNativeWebCreateOptions?: PopupForNativeWebCreateOptions;
|
|
63
|
+
persistentStorageForNativeWebCreateOptions?: Omit<StorageForNativeWebCreateOptions, "validatorKey">;
|
|
64
|
+
sessionStorageForNativeWebCreateOptions?: Omit<StorageForNativeWebCreateOptions, "validatorKey">;
|
|
65
|
+
}
|
|
66
|
+
declare function createEnvironmentForNativeWeb(options: CreateEnvironmentForNativeWebOptions): NativeWebEnvironment;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/web/sync/cross-tab-sync.d.ts
|
|
69
|
+
/** Event emitted when a cross-tab storage change is detected for the watched key. */
|
|
70
|
+
interface CrossTabSyncEvent {
|
|
71
|
+
/** The new value written by the other tab, or null if the key was removed. */
|
|
72
|
+
newValue: string | null;
|
|
73
|
+
/** The old value before the other tab's write. */
|
|
27
74
|
oldValue: string | null;
|
|
28
|
-
}
|
|
75
|
+
}
|
|
29
76
|
/** Options for {@link createCrossTabSync}. */
|
|
30
77
|
interface CreateCrossTabSyncOptions {
|
|
31
78
|
/** The localStorage key to watch for cross-tab changes. */
|
|
32
79
|
key: string;
|
|
33
|
-
|
|
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;
|
|
80
|
+
storageEventTarget: StorageEventTarget;
|
|
50
81
|
}
|
|
51
82
|
/**
|
|
52
83
|
* Create a cross-tab sync listener for a specific localStorage key.
|
|
@@ -56,311 +87,25 @@ interface CrossTabSync {
|
|
|
56
87
|
*
|
|
57
88
|
* @example
|
|
58
89
|
* ```ts
|
|
59
|
-
* const
|
|
90
|
+
* const subscription = createCrossTabSync({
|
|
60
91
|
* key: "auth:v1",
|
|
61
|
-
*
|
|
92
|
+
* storageEventTarget: window,
|
|
93
|
+
* }).subscribe({
|
|
94
|
+
* next: ({ newValue }) => {
|
|
62
95
|
* if (newValue) {
|
|
63
96
|
* // Another tab updated auth state — reconcile
|
|
64
|
-
*
|
|
97
|
+
* client.restorePersistedState();
|
|
65
98
|
* } else {
|
|
66
99
|
* // Another tab cleared auth state — log out
|
|
67
|
-
* controller.clearState({
|
|
68
|
-
* }
|
|
69
|
-
* },
|
|
70
|
-
* });
|
|
71
|
-
* // Later:
|
|
72
|
-
* sync.dispose();
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
declare function createCrossTabSync(options: CreateCrossTabSyncOptions): CrossTabSync;
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/web/input-sources.d.ts
|
|
78
|
-
interface AbortSignalSource {
|
|
79
|
-
aborted: boolean;
|
|
80
|
-
reason: unknown;
|
|
81
|
-
addEventListener(type: string, listener: EventListener): void;
|
|
82
|
-
removeEventListener(type: string, listener: EventListener): void;
|
|
83
|
-
}
|
|
84
|
-
interface FromAbortSignalOptions {
|
|
85
|
-
/** AbortSignal to observe. */
|
|
86
|
-
signal?: AbortSignalSource;
|
|
87
|
-
/** Callback invoked when the signal aborts. */
|
|
88
|
-
callback: (reason: unknown) => void;
|
|
89
|
-
/**
|
|
90
|
-
* Emit immediately when the signal is already aborted at subscribe time.
|
|
91
|
-
* Defaults to `false`.
|
|
92
|
-
*/
|
|
93
|
-
emitIfAborted?: boolean;
|
|
94
|
-
}
|
|
95
|
-
interface StorageEventTarget {
|
|
96
|
-
addEventListener(type: string, listener: EventListener): void;
|
|
97
|
-
removeEventListener(type: string, listener: EventListener): void;
|
|
98
|
-
}
|
|
99
|
-
interface FromStorageEventOptions {
|
|
100
|
-
/**
|
|
101
|
-
* Storage-event target. Defaults to `globalThis`, which is appropriate for
|
|
102
|
-
* browser hosts and jsdom-based tests.
|
|
103
|
-
*/
|
|
104
|
-
target?: StorageEventTarget;
|
|
105
|
-
/** Callback invoked for each browser `storage` event. */
|
|
106
|
-
callback: (event: StorageEvent) => void;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Adapt a browser AbortSignal into the shared Subscription model.
|
|
110
|
-
*/
|
|
111
|
-
declare function fromAbortSignal(options: FromAbortSignalOptions): Subscription;
|
|
112
|
-
/**
|
|
113
|
-
* Adapt browser `storage` events into the shared Subscription model.
|
|
114
|
-
*/
|
|
115
|
-
declare function fromStorageEvent(options: FromStorageEventOptions): Subscription;
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/web/page-resume-reconciler.d.ts
|
|
118
|
-
declare const PageResumeTriggerKind: {
|
|
119
|
-
readonly Visibility: "visibility";
|
|
120
|
-
readonly PageShow: "pageshow";
|
|
121
|
-
readonly Focus: "focus";
|
|
122
|
-
readonly Online: "online";
|
|
123
|
-
};
|
|
124
|
-
type PageResumeTriggerKind = (typeof PageResumeTriggerKind)[keyof typeof PageResumeTriggerKind];
|
|
125
|
-
interface PageResumeEvent {
|
|
126
|
-
trigger: PageResumeTriggerKind;
|
|
127
|
-
persisted?: boolean;
|
|
128
|
-
}
|
|
129
|
-
type PageResumeCallback = (event: PageResumeEvent) => void | Promise<void>;
|
|
130
|
-
interface PageResumeDocumentTarget {
|
|
131
|
-
addEventListener(type: "visibilitychange", handler: EventListener): void;
|
|
132
|
-
removeEventListener(type: "visibilitychange", handler: EventListener): void;
|
|
133
|
-
visibilityState: DocumentVisibilityState;
|
|
134
|
-
}
|
|
135
|
-
interface PageResumeWindowTarget {
|
|
136
|
-
addEventListener(type: "pageshow" | "focus" | "online", handler: EventListener): void;
|
|
137
|
-
removeEventListener(type: "pageshow" | "focus" | "online", handler: EventListener): void;
|
|
138
|
-
}
|
|
139
|
-
interface CreatePageResumeReconcilerOptions {
|
|
140
|
-
onReconcile: PageResumeCallback;
|
|
141
|
-
/** Defaults to 5000ms. Use 0 in deterministic tests. */
|
|
142
|
-
throttleMs?: number;
|
|
143
|
-
document?: PageResumeDocumentTarget | null;
|
|
144
|
-
window?: PageResumeWindowTarget | null;
|
|
145
|
-
now?: () => number;
|
|
146
|
-
onError?: (error: unknown, event: PageResumeEvent) => void;
|
|
147
|
-
}
|
|
148
|
-
interface PageResumeReconciler {
|
|
149
|
-
dispose(): void;
|
|
150
|
-
readonly reconcileCount: number;
|
|
151
|
-
}
|
|
152
|
-
declare function createPageResumeReconciler(options: CreatePageResumeReconcilerOptions): PageResumeReconciler;
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/web/popup.d.ts
|
|
155
|
-
/** Stable error codes for popup-related failures. */
|
|
156
|
-
declare const PopupErrorCode: {
|
|
157
|
-
/** The browser blocked the popup window from opening. */readonly Blocked: "popup.blocked"; /** The popup was closed by the user before completing the flow. */
|
|
158
|
-
readonly Closed: "popup.closed_by_user"; /** The relay message was not received within the timeout. */
|
|
159
|
-
readonly Timeout: "popup.relay_timeout"; /** The relay message contained an error from the callback page. */
|
|
160
|
-
readonly RelayError: "popup.relay_error"; /** An unexpected error occurred during popup lifecycle. */
|
|
161
|
-
readonly Internal: "popup.internal";
|
|
162
|
-
};
|
|
163
|
-
type PopupErrorCode = (typeof PopupErrorCode)[keyof typeof PopupErrorCode];
|
|
164
|
-
/**
|
|
165
|
-
* Options for computing the popup window features string.
|
|
166
|
-
*/
|
|
167
|
-
interface PopupFeaturesOptions {
|
|
168
|
-
/** Width in pixels (default: 500). */
|
|
169
|
-
width?: number;
|
|
170
|
-
/** Height in pixels (default: 600). */
|
|
171
|
-
height?: number;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Compute the `features` string for `window.open()`, centered on screen.
|
|
175
|
-
*/
|
|
176
|
-
declare function computePopupFeatures(options?: PopupFeaturesOptions): string;
|
|
177
|
-
/**
|
|
178
|
-
* Result of opening a popup window.
|
|
179
|
-
*/
|
|
180
|
-
interface PopupWindowHandle {
|
|
181
|
-
/** The opened window reference. */
|
|
182
|
-
window: Window;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Open a popup window to the given URL.
|
|
186
|
-
*
|
|
187
|
-
* Throws a `ClientError` with code `popup.blocked` if the browser
|
|
188
|
-
* blocks the popup.
|
|
189
|
-
*/
|
|
190
|
-
declare function openPopupWindow(url: string, options?: PopupFeaturesOptions & {
|
|
191
|
-
target?: string;
|
|
192
|
-
}): PopupWindowHandle;
|
|
193
|
-
/**
|
|
194
|
-
* Expected shape of a relay message from the popup callback page.
|
|
195
|
-
*/
|
|
196
|
-
interface PopupRelayMessage {
|
|
197
|
-
/** Discriminator for the message type. */
|
|
198
|
-
type: "securitydept:popup_callback";
|
|
199
|
-
/** The callback URL or fragment received by the popup. */
|
|
200
|
-
payload: string;
|
|
201
|
-
/** Optional error from the callback page. */
|
|
202
|
-
error?: string;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Options for waiting for a popup relay message.
|
|
206
|
-
*/
|
|
207
|
-
interface WaitForPopupRelayOptions {
|
|
208
|
-
/** The popup window handle to monitor. */
|
|
209
|
-
popup: PopupWindowHandle;
|
|
210
|
-
/** Maximum time to wait in milliseconds (default: 120000 = 2 minutes). */
|
|
211
|
-
timeoutMs?: number;
|
|
212
|
-
/** Expected origin for the relay message (default: current origin). */
|
|
213
|
-
expectedOrigin?: string;
|
|
214
|
-
/** Poll interval for checking if the popup is closed (default: 500ms). */
|
|
215
|
-
pollIntervalMs?: number;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Wait for a relay message from a popup callback page.
|
|
219
|
-
*
|
|
220
|
-
* The popup callback page should call `relayPopupCallback()` to post
|
|
221
|
-
* the callback URL back to the opener.
|
|
222
|
-
*
|
|
223
|
-
* Resolves with the callback payload (URL or fragment string).
|
|
224
|
-
* Rejects with a `ClientError` if:
|
|
225
|
-
* - the popup is closed without relaying (popup.closed_by_user)
|
|
226
|
-
* - the timeout expires (popup.relay_timeout)
|
|
227
|
-
* - the relay message contains an error (popup.relay_error)
|
|
228
|
-
*/
|
|
229
|
-
declare function waitForPopupRelay(options: WaitForPopupRelayOptions): Promise<string>;
|
|
230
|
-
/**
|
|
231
|
-
* Options for relaying the callback from the popup window back to the opener.
|
|
232
|
-
*/
|
|
233
|
-
interface RelayPopupCallbackOptions {
|
|
234
|
-
/** The callback payload (URL or fragment) to relay. */
|
|
235
|
-
payload?: string;
|
|
236
|
-
/** An error message to relay instead of a successful payload. */
|
|
237
|
-
error?: string;
|
|
238
|
-
/** Whether to close the popup after relaying (default: true). */
|
|
239
|
-
closeAfterRelay?: boolean;
|
|
240
|
-
/** Target origin for the postMessage (default: current origin). */
|
|
241
|
-
targetOrigin?: string;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Relay the popup callback result back to the opener window.
|
|
245
|
-
*
|
|
246
|
-
* Call this function from the popup callback page to send the callback
|
|
247
|
-
* URL/fragment back to the parent window that initiated the popup login.
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* ```html
|
|
251
|
-
* <script type="module">
|
|
252
|
-
* import { relayPopupCallback } from "@securitydept/client/web";
|
|
253
|
-
* relayPopupCallback({ payload: window.location.href });
|
|
254
|
-
* </script>
|
|
255
|
-
* ```
|
|
256
|
-
*/
|
|
257
|
-
declare function relayPopupCallback(options?: RelayPopupCallbackOptions): void;
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region src/web/runtime.d.ts
|
|
260
|
-
interface CreateWebRuntimeOptions extends Partial<Omit<ClientRuntime, "transport">> {
|
|
261
|
-
transport?: ClientRuntime["transport"];
|
|
262
|
-
fetchTransport?: FetchTransportOptions;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Create a `ClientRuntime` for browser/Web-capable environments.
|
|
266
|
-
*/
|
|
267
|
-
declare function createWebRuntime(overrides?: CreateWebRuntimeOptions): ClientRuntime;
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/web/visibility.d.ts
|
|
270
|
-
/** Visibility state snapshot passed to the callback. */
|
|
271
|
-
declare const VisibilityState: {
|
|
272
|
-
readonly Visible: "visible";
|
|
273
|
-
readonly Hidden: "hidden";
|
|
274
|
-
};
|
|
275
|
-
type VisibilityState = (typeof VisibilityState)[keyof typeof VisibilityState];
|
|
276
|
-
/** Options for {@link fromVisibilityChange}. */
|
|
277
|
-
interface FromVisibilityChangeOptions {
|
|
278
|
-
/**
|
|
279
|
-
* Callback invoked when the document visibility state changes.
|
|
280
|
-
*
|
|
281
|
-
* The callback receives the new visibility state ("visible" or "hidden").
|
|
282
|
-
*/
|
|
283
|
-
callback: (state: VisibilityState) => void;
|
|
284
|
-
/**
|
|
285
|
-
* Override the document target (primarily for testing).
|
|
286
|
-
* Defaults to `globalThis.document`.
|
|
287
|
-
*/
|
|
288
|
-
document?: Pick<Document, "addEventListener" | "removeEventListener" | "visibilityState">;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Subscribe to browser document visibility changes.
|
|
292
|
-
*
|
|
293
|
-
* Built on {@link fromEventPattern} so it follows the same Subscription
|
|
294
|
-
* contract. Returns a {@link Subscription} handle for cleanup.
|
|
295
|
-
*
|
|
296
|
-
* @example
|
|
297
|
-
* ```ts
|
|
298
|
-
* const sub = fromVisibilityChange({
|
|
299
|
-
* callback: (state) => {
|
|
300
|
-
* if (state === VisibilityState.Visible) {
|
|
301
|
-
* scheduleRefresh();
|
|
302
|
-
* }
|
|
303
|
-
* },
|
|
304
|
-
* });
|
|
305
|
-
* // Cleanup:
|
|
306
|
-
* sub.unsubscribe();
|
|
307
|
-
* ```
|
|
308
|
-
*/
|
|
309
|
-
declare function fromVisibilityChange(options: FromVisibilityChangeOptions): Subscription;
|
|
310
|
-
//#endregion
|
|
311
|
-
//#region src/web/visibility-reconciler.d.ts
|
|
312
|
-
/** Callback invoked when the page becomes visible and reconciliation is needed. */
|
|
313
|
-
type ReconcileCallback = () => void | Promise<void>;
|
|
314
|
-
/** Options for {@link createVisibilityReconciler}. */
|
|
315
|
-
interface CreateVisibilityReconcilerOptions {
|
|
316
|
-
/**
|
|
317
|
-
* Called when the document transitions from hidden → visible.
|
|
318
|
-
* The reconciler only fires on the hidden→visible edge; repeated
|
|
319
|
-
* visible→visible events are suppressed.
|
|
320
|
-
*/
|
|
321
|
-
onReconcile: ReconcileCallback;
|
|
322
|
-
/**
|
|
323
|
-
* Minimum interval (ms) between reconciliation triggers.
|
|
324
|
-
* Prevents rapid-fire reconciliation when the user toggles tabs quickly.
|
|
325
|
-
* Defaults to 5000ms (5 seconds).
|
|
326
|
-
*/
|
|
327
|
-
throttleMs?: number;
|
|
328
|
-
/**
|
|
329
|
-
* Override the document target (primarily for testing).
|
|
330
|
-
* Defaults to `globalThis.document`.
|
|
331
|
-
*/
|
|
332
|
-
document?: FromVisibilityChangeOptions["document"];
|
|
333
|
-
/**
|
|
334
|
-
* Clock override for testing.
|
|
335
|
-
*/
|
|
336
|
-
now?: () => number;
|
|
337
|
-
}
|
|
338
|
-
/** Handle returned by {@link createVisibilityReconciler}. */
|
|
339
|
-
interface VisibilityReconciler {
|
|
340
|
-
/** Stop listening for visibility changes. */
|
|
341
|
-
dispose(): void;
|
|
342
|
-
/** Number of times reconciliation has been triggered. */
|
|
343
|
-
readonly reconcileCount: number;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Create a visibility reconciler that triggers a callback when the page
|
|
347
|
-
* transitions from hidden → visible.
|
|
348
|
-
*
|
|
349
|
-
* @example
|
|
350
|
-
* ```ts
|
|
351
|
-
* const reconciler = createVisibilityReconciler({
|
|
352
|
-
* onReconcile: () => {
|
|
353
|
-
* // Re-check token freshness or sync cross-tab state
|
|
354
|
-
* if (controller.snapshot?.tokens.accessTokenExpiresAt) {
|
|
355
|
-
* scheduleRefreshIfExpired();
|
|
100
|
+
* controller.clearState({ persistPolicy: "skip" });
|
|
356
101
|
* }
|
|
357
102
|
* },
|
|
358
103
|
* });
|
|
359
104
|
* // Later:
|
|
360
|
-
*
|
|
105
|
+
* subscription.unsubscribe();
|
|
361
106
|
* ```
|
|
362
107
|
*/
|
|
363
|
-
declare function
|
|
108
|
+
declare function createCrossTabSync(options: CreateCrossTabSyncOptions): EventStreamTrait<CrossTabSyncEvent>;
|
|
364
109
|
//#endregion
|
|
365
|
-
export { type
|
|
110
|
+
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 };
|
|
366
111
|
//# sourceMappingURL=index.d.mts.map
|