stream-chat 10.0.0-rc.21 → 10.0.0-rc.23
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/cjs/index.browser.js +2196 -3902
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +2197 -3902
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +2199 -3905
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +120 -233
- package/dist/types/CooldownTimer.d.ts +8 -23
- package/dist/types/EventHandlerPipeline.d.ts +17 -37
- package/dist/types/LiveLocationManager.d.ts +22 -50
- package/dist/types/api-client.d.ts +9 -14
- package/dist/types/channel.d.ts +253 -448
- package/dist/types/channel_state.d.ts +48 -95
- package/dist/types/client.d.ts +245 -370
- package/dist/types/client_state.d.ts +1 -3
- package/dist/types/configuration/ConfigController.d.ts +30 -124
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
- package/dist/types/configuration/keys.d.ts +5 -19
- package/dist/types/configuration/shape.d.ts +12 -29
- package/dist/types/configuration/types.d.ts +59 -87
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
- package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
- package/dist/types/connection/ConnectionIdManager.d.ts +18 -40
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
- package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
- package/dist/types/connection/networkConnection/types.d.ts +12 -27
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
- package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
- package/dist/types/connection/wsConnection/config.d.ts +8 -28
- package/dist/types/connection/wsConnection/types.d.ts +17 -70
- package/dist/types/entityStore/EntityStore.d.ts +153 -113
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
- package/dist/types/errors.d.ts +7 -19
- package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
- package/dist/types/gen/chat/ChatApi.d.ts +28 -14
- package/dist/types/gen/models/index.d.ts +769 -86
- package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
- package/dist/types/index.d.ts +2 -4
- package/dist/types/languageNames.d.ts +9 -24
- package/dist/types/logger.d.ts +1 -3
- package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
- package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
- package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
- package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
- package/dist/types/messageComposer/configuration/types.d.ts +29 -56
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
- package/dist/types/messageComposer/messageComposer.d.ts +30 -164
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +9 -0
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -18
- package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
- package/dist/types/messageComposer/pollComposer.d.ts +8 -4
- package/dist/types/messageComposer/textComposer.d.ts +3 -9
- package/dist/types/messageComposer/types.d.ts +5 -8
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
- package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
- package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
- package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
- package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
- package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
- package/dist/types/messageOperations/types.d.ts +15 -30
- package/dist/types/middleware.d.ts +7 -5
- package/dist/types/moderation.d.ts +21 -14
- package/dist/types/notifications/NotificationManager.d.ts +8 -31
- package/dist/types/notifications/types.d.ts +19 -59
- package/dist/types/offline-support/offline_support_api.d.ts +145 -539
- package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
- package/dist/types/offline-support/queueableOperations.d.ts +24 -52
- package/dist/types/offline-support/types.d.ts +24 -187
- package/dist/types/pagination/ItemIndex.d.ts +4 -12
- package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -4
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
- package/dist/types/pagination/sortCompiler.d.ts +11 -22
- package/dist/types/pagination/utility.normalization.d.ts +5 -23
- package/dist/types/pagination/utility.search.d.ts +3 -8
- package/dist/types/poll.d.ts +14 -14
- package/dist/types/poll_manager.d.ts +11 -2
- package/dist/types/poll_optimistic_votes.d.ts +10 -14
- package/dist/types/reminders/Reminder.d.ts +4 -4
- package/dist/types/reminders/ReminderManager.d.ts +7 -20
- package/dist/types/search/BaseSearchSource.d.ts +7 -12
- package/dist/types/search/ChannelSearchSource.d.ts +7 -7
- package/dist/types/search/MessageSearchSource.d.ts +7 -9
- package/dist/types/search/SearchController.d.ts +17 -22
- package/dist/types/search/types.d.ts +6 -10
- package/dist/types/signing.d.ts +12 -3
- package/dist/types/thread.d.ts +23 -71
- package/dist/types/thread_manager.d.ts +45 -70
- package/dist/types/token_manager.d.ts +8 -13
- package/dist/types/types.d.ts +64 -125
- package/dist/types/types.utility.d.ts +3 -3
- package/dist/types/upload-utils.d.ts +5 -10
- package/dist/types/uploadManager.d.ts +17 -45
- package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
- package/dist/types/utils/WithSubscriptions.d.ts +5 -15
- package/dist/types/utils/concurrency.d.ts +11 -19
- package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
- package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
- package/dist/types/utils/objectPath.d.ts +6 -41
- package/dist/types/utils/retryable.d.ts +8 -12
- package/dist/types/utils/throttling/throttle.d.ts +8 -23
- package/dist/types/utils/time.d.ts +24 -64
- package/dist/types/utils.d.ts +40 -86
- package/package.json +7 -2
- package/src/ChannelManager.ts +159 -300
- package/src/CooldownTimer.ts +11 -29
- package/src/EventHandlerPipeline.ts +21 -44
- package/src/LiveLocationManager.ts +35 -74
- package/src/api-client.ts +43 -61
- package/src/campaign.ts +1 -1
- package/src/channel.ts +396 -749
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +50 -105
- package/src/client.ts +360 -588
- package/src/client_state.ts +1 -6
- package/src/configuration/ConfigController.ts +41 -157
- package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
- package/src/configuration/index.ts +1 -1
- package/src/configuration/keys.ts +13 -32
- package/src/configuration/shape.ts +67 -70
- package/src/configuration/types.ts +60 -100
- package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
- package/src/configuration/utils/copyConfigPatch.ts +11 -32
- package/src/configuration/utils/declarativeSlices.ts +9 -39
- package/src/configuration/utils/deepFreezeConfig.ts +3 -17
- package/src/configuration/utils/index.ts +2 -4
- package/src/configuration/utils/serverAuthority.ts +20 -68
- package/src/connection/ConnectionIdManager.ts +20 -49
- package/src/connection/ConnectionRecoveryManager.ts +51 -178
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
- package/src/connection/networkConnection/reporters.ts +9 -36
- package/src/connection/networkConnection/types.ts +12 -27
- package/src/connection/wsConnection/StableWSConnection.ts +73 -193
- package/src/connection/wsConnection/WSConnection.ts +56 -131
- package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
- package/src/connection/wsConnection/config.ts +13 -48
- package/src/connection/wsConnection/types.ts +17 -70
- package/src/constants.ts +4 -4
- package/src/entityStore/EntityStore.ts +162 -167
- package/src/entityStore/StoreBackedItemIndex.ts +14 -47
- package/src/errors.ts +7 -19
- package/src/formatMessageMemo.ts +3 -9
- package/src/gen/chat/ChannelApi.ts +19 -0
- package/src/gen/chat/ChatApi.ts +87 -13
- package/src/gen/models/index.ts +793 -71
- package/src/gen/moderation/ModerationApi.ts +0 -4
- package/src/index.ts +10 -14
- package/src/languageNames.ts +9 -24
- package/src/logger.ts +1 -3
- package/src/messageComposer/LocationComposer.ts +7 -23
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
- package/src/messageComposer/attachmentIdentity.ts +2 -13
- package/src/messageComposer/attachmentManager.ts +17 -63
- package/src/messageComposer/attachmentUtils.ts +3 -17
- package/src/messageComposer/configuration/configuration.ts +5 -8
- package/src/messageComposer/configuration/types.ts +29 -56
- package/src/messageComposer/fileUtils.ts +1 -1
- package/src/messageComposer/linkPreviewsManager.ts +8 -20
- package/src/messageComposer/messageComposer.ts +54 -222
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
- package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
- package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +1 -6
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
- package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
- package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
- package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
- package/src/messageComposer/middleware/textComposer/types.ts +1 -6
- package/src/messageComposer/pollComposer.ts +11 -8
- package/src/messageComposer/textComposer.ts +9 -59
- package/src/messageComposer/types.ts +9 -12
- package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
- package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
- package/src/messageOperations/FailedSendCache.ts +4 -9
- package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
- package/src/messageOperations/MessageOperations.ts +33 -62
- package/src/messageOperations/applyReactionLocally.ts +9 -28
- package/src/messageOperations/createMessageOperations.ts +17 -33
- package/src/messageOperations/reflectReactionEvent.ts +5 -13
- package/src/messageOperations/sendOrdering.ts +4 -7
- package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
- package/src/messageOperations/types.ts +15 -30
- package/src/middleware.ts +7 -10
- package/src/moderation.ts +25 -21
- package/src/notifications/NotificationManager.ts +11 -35
- package/src/notifications/types.ts +19 -59
- package/src/offline-support/offline_support_api.ts +178 -608
- package/src/offline-support/offline_sync_manager.ts +25 -69
- package/src/offline-support/queueableOperations.ts +31 -84
- package/src/offline-support/types.ts +25 -188
- package/src/pagination/ItemIndex.ts +4 -12
- package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
- package/src/pagination/filterCompiler.ts +11 -25
- package/src/pagination/paginators/BasePaginator.ts +422 -976
- package/src/pagination/paginators/ChannelPaginator.ts +130 -190
- package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
- package/src/pagination/paginators/MessagePaginator.ts +135 -175
- package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
- package/src/pagination/paginators/ReminderPaginator.ts +12 -15
- package/src/pagination/paginators/ThreadPaginator.ts +16 -26
- package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
- package/src/pagination/paginators/stateThrottling.ts +5 -10
- package/src/pagination/sortCompiler.ts +23 -50
- package/src/pagination/utility.normalization.ts +8 -30
- package/src/pagination/utility.search.ts +4 -11
- package/src/poll.ts +19 -19
- package/src/poll_manager.ts +16 -20
- package/src/poll_optimistic_votes.ts +17 -22
- package/src/reminders/Reminder.ts +5 -6
- package/src/reminders/ReminderManager.ts +9 -34
- package/src/reminders/ReminderTimer.ts +1 -2
- package/src/search/BaseSearchSource.ts +14 -29
- package/src/search/ChannelSearchSource.ts +8 -8
- package/src/search/MessageSearchSource.ts +19 -25
- package/src/search/SearchController.ts +18 -24
- package/src/search/types.ts +6 -10
- package/src/segment.ts +1 -1
- package/src/signing.ts +23 -3
- package/src/thread.ts +72 -173
- package/src/thread_manager.ts +59 -76
- package/src/token_manager.ts +11 -21
- package/src/types.ts +78 -126
- package/src/types.utility.ts +3 -3
- package/src/upload-utils.ts +5 -10
- package/src/uploadManager.ts +22 -54
- package/src/utils/FixedSizeQueueCache.ts +13 -21
- package/src/utils/WithSubscriptions.ts +5 -15
- package/src/utils/concurrency.ts +16 -55
- package/src/utils/mergeWith/mergeWith.ts +10 -13
- package/src/utils/mergeWith/mergeWithCore.ts +24 -81
- package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
- package/src/utils/objectPath.ts +6 -41
- package/src/utils/retryable.ts +10 -14
- package/src/utils/throttling/throttle.ts +9 -25
- package/src/utils/time.ts +26 -66
- package/src/utils.ts +72 -128
|
@@ -2,163 +2,72 @@ import { WithSubscriptions } from '../utils/WithSubscriptions';
|
|
|
2
2
|
import type { StreamChat } from '../client';
|
|
3
3
|
import type { StateStore } from '@stream-io/state-store';
|
|
4
4
|
export type ConnectionRecoveryManagerConfig = {
|
|
5
|
-
/**
|
|
6
|
-
* Whether the client recovers its own state when the connection comes back.
|
|
7
|
-
*
|
|
8
|
-
* Set it to `false` only if the application recovers state itself — nothing is then re-queried or
|
|
9
|
-
* re-watched on reconnect, and refreshing whatever is on screen becomes the consumer's job.
|
|
10
|
-
* Read when a recovery actually runs, so flipping it takes effect from the next reconnect.
|
|
11
|
-
*/
|
|
5
|
+
/** Whether the client recovers its own state on reconnect. Set `false` if the app does it itself. */
|
|
12
6
|
enabled: boolean;
|
|
13
7
|
};
|
|
14
8
|
export declare const DEFAULT_CONNECTION_RECOVERY_MANAGER_CONFIG: ConnectionRecoveryManagerConfig;
|
|
15
9
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* 1. **Every loaded channel list re-runs its own first-page query** (`ChannelManager.recover`). Since
|
|
22
|
-
* `queryChannels` watches by default, that also re-establishes the watches for the channels on
|
|
23
|
-
* that page.
|
|
24
|
-
* 2. **Every active channel reloads itself** (`Channel.reload`), because a list page carries far fewer
|
|
25
|
-
* messages per channel than an open channel's loaded window, so the open channel cannot be served
|
|
26
|
-
* by the list query.
|
|
27
|
-
* 3. **Every active thread reloads its replies** (`Thread.reload`), because none of the above touches
|
|
28
|
-
* them: a channel reload refreshes the main message list, and `ThreadManager`'s own recovery
|
|
29
|
-
* refreshes the thread *list*, reusing thread instances without rehydrating them unless something
|
|
30
|
-
* separately marked them stale.
|
|
31
|
-
*
|
|
32
|
-
* It is explicitly **not** a sweep over the channel store (`client.channelManager.values()`). Watches
|
|
33
|
-
* are a bounded server resource, and after any scrolling that store holds far more channels than a query returns — so
|
|
34
|
-
* re-watching all of them would be both wasteful and a watch-limit hazard. Channels outside the
|
|
35
|
-
* refreshed pages come back demand-driven, when an event proves them relevant (see
|
|
36
|
-
* `restoreInterruptedWatch` in `ChannelManager`).
|
|
37
|
-
*
|
|
38
|
-
* This replaces the removed `client.recoverState()` bulk query
|
|
39
|
-
* (`cid: { $in: <every loaded channel> }, limit: 30`), which invented its own query shape unrelated to any
|
|
40
|
-
* list's filters and silently dropped everything past the thirtieth channel.
|
|
41
|
-
*
|
|
42
|
-
* ### Triggers, and why there are two
|
|
10
|
+
* After a reconnect, brings what the app is consuming back in line with the server:
|
|
11
|
+
* 1. loaded channel lists re-run their first-page query (`ChannelManager.recover`), re-watching it;
|
|
12
|
+
* 2. active channels reload (`Channel.reload`);
|
|
13
|
+
* 3. active threads reload their replies (`Thread.reload`).
|
|
43
14
|
*
|
|
44
|
-
*
|
|
15
|
+
* It does not sweep the channel store (watches are a bounded server resource). Other channels recover
|
|
16
|
+
* on demand, when an event proves them relevant.
|
|
45
17
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* offline sync.
|
|
49
|
-
* - **Active channels** — the offline DB's *sync-status edge* when offline support is enabled, and
|
|
50
|
-
* that same store otherwise. `Channel.reload()` has no deferral of its own, so it has to be
|
|
51
|
-
* triggered by something that is already post-sync.
|
|
52
|
-
*
|
|
53
|
-
* The edge is what guarantees `executePendingTasks()` → `sync()` → query ordering, on every reconnect
|
|
54
|
-
* path: `OfflineDBSyncManager` calls `invokeSyncStatusListeners(true)` **unconditionally** after
|
|
55
|
-
* `syncAndExecutePendingTasks()` on each online transition — it does not require `isSynced` to have
|
|
56
|
-
* been `false` first. That matters because the sync edge, unlike anything derived from a single
|
|
57
|
-
* transition, is guaranteed to land after the replay and the sync rather than alongside them.
|
|
58
|
-
*
|
|
59
|
-
* Recovery deliberately keeps no "did we drop?" flag of its own: `ChannelWatchStatus.WasWatching`
|
|
60
|
-
* already records exactly that, written from the truthful hooks
|
|
61
|
-
* (`StableWSConnection._setHealth(false)` and `closeConnection()`, plus
|
|
62
|
-
* `WSConnectionFallback._setState()` after an `enableWSFallback` switch).
|
|
63
|
-
*
|
|
64
|
-
* The status store it follows is the long-poll's once `enableWSFallback` has switched to it, so a
|
|
65
|
-
* long-poll reconnect recovers the same way a WebSocket reconnect does.
|
|
18
|
+
* Lists recover when the socket goes online. Active channels recover on the offline DB's sync-status
|
|
19
|
+
* edge when offline support is on (it lands after pending tasks replay), else on the same socket status.
|
|
66
20
|
*/
|
|
67
21
|
export declare class ConnectionRecoveryManager extends WithSubscriptions {
|
|
68
22
|
client: StreamChat;
|
|
69
|
-
/** The shared configuration machinery — see {@link ConfigController}. */
|
|
70
23
|
private readonly configController;
|
|
71
24
|
/** Set while a pass over the active channels and threads is in flight. */
|
|
72
25
|
private isRecovering;
|
|
73
|
-
/**
|
|
74
|
-
* A reconnect that arrived while a pass was already running, so the pass re-runs when it finishes.
|
|
75
|
-
*
|
|
76
|
-
* A second pass cannot start alongside the first: they would reload every active channel twice and
|
|
77
|
-
* race on {@link isRecovering}, the earlier one clearing it while the later is still going. Nor can
|
|
78
|
-
* the reconnect simply be dropped — the running pass will withhold its `connection.recovered`
|
|
79
|
-
* precisely because the socket moved under it, so nothing else would bring the newer connection's
|
|
80
|
-
* state back in line.
|
|
81
|
-
*
|
|
82
|
-
* Re-entry is not hypothetical. The trigger is a subscription to the socket's status store, and a
|
|
83
|
-
* reload that moves that status calls straight back into here before the first `await`.
|
|
84
|
-
*/
|
|
26
|
+
/** A reconnect that arrived mid-pass: re-run once when the pass finishes, not concurrently. */
|
|
85
27
|
private recoveryRequestedAgain;
|
|
86
|
-
/** Undone by `unregisterSubscriptions`, so re-registering does not stack listeners. */
|
|
87
28
|
private unsubscribeSyncStatus?;
|
|
88
29
|
constructor({ client }: {
|
|
89
30
|
client: StreamChat;
|
|
90
31
|
});
|
|
91
|
-
/**
|
|
92
|
-
* Resolved configuration, as a store — the shape every configurable class exposes
|
|
93
|
-
* (`configState` / `config` / `updateConfig`).
|
|
94
|
-
*/
|
|
95
32
|
get configState(): StateStore<ConnectionRecoveryManagerConfig>;
|
|
96
|
-
/** The current resolved configuration. `Readonly` — change it through {@link updateConfig}. */
|
|
97
33
|
get config(): Readonly<ConnectionRecoveryManagerConfig>;
|
|
98
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Merges a partial configuration into the resolved config.
|
|
36
|
+
*
|
|
37
|
+
* @param config - Fields to merge into the resolved config.
|
|
38
|
+
*/
|
|
99
39
|
updateConfig(config: Partial<ConnectionRecoveryManagerConfig>): void;
|
|
100
40
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
41
|
+
* Re-derives the configuration from the declarative slice.
|
|
42
|
+
*
|
|
43
|
+
* @param config - The declarative slice. Leave it out to rebuild from the defaults.
|
|
104
44
|
*/
|
|
105
45
|
initializeConfig(config?: Partial<ConnectionRecoveryManagerConfig>): void;
|
|
106
46
|
registerSubscriptions: () => () => symbol;
|
|
107
47
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* deferred rather than handed in. Doing it from the status handler is safe even when this manager's
|
|
113
|
-
* subscription runs before the sync manager's: `OfflineDBSyncManager` awaits
|
|
114
|
-
* `syncAndExecutePendingTasks()` before publishing, so the edge cannot land in the same synchronous
|
|
115
|
-
* notification that registers us.
|
|
116
|
-
*
|
|
117
|
-
* An offline DB whose `init()` never succeeded publishes no edge, so it must not be treated as the
|
|
118
|
-
* trigger — hence the `initialized` check, which also means a later successful init is picked up on
|
|
119
|
-
* the next reconnect.
|
|
120
|
-
*
|
|
121
|
-
* @returns whether the sync-status edge is now driving active-channel recovery.
|
|
48
|
+
* Binds to the offline DB's sync-status edge once the DB is initialized (an uninitialized one
|
|
49
|
+
* publishes no edge). Safe from the status handler: the edge is published only after
|
|
50
|
+
* `syncAndExecutePendingTasks()` resolves. Returns whether the edge now drives active-channel
|
|
51
|
+
* recovery.
|
|
122
52
|
*/
|
|
123
53
|
private ensureSyncStatusSubscription;
|
|
124
54
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* Deliberately NOT filtered on `watchStatus`. A channel opened while offline never reached
|
|
128
|
-
* `Watching` at all (its `watch()` threw, leaving `offlineMode`), so a `WasWatching` filter here
|
|
129
|
-
* would permanently strand the single most important offline case. `Channel.reload()`'s own
|
|
130
|
-
* `initialized || offlineMode` guard is the correct gate, and this is not a "restore a lost watch"
|
|
131
|
-
* decision anyway — it is "the channel being read must show the truth".
|
|
55
|
+
* Channels a consumer is reading. Not filtered on `watchStatus`: a channel opened while offline never
|
|
56
|
+
* reached `Watching`, and `Channel.reload()` has its own `initialized || offlineMode` guard.
|
|
132
57
|
*/
|
|
133
58
|
private get recoverableActiveChannels();
|
|
134
59
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* Threads need their own pass because nothing else brings an open thread's replies back — a
|
|
138
|
-
* channel reload refreshes the main message list, `ChannelManager.recover()` refreshes the channel
|
|
139
|
-
* lists*, and `ThreadManager`'s own recovery refreshes the thread *list*, reusing existing
|
|
140
|
-
* instances without rehydrating them unless they were separately marked stale.
|
|
141
|
-
*
|
|
142
|
-
* `active` is the filter that matters: the registry also holds every thread the list has paged
|
|
143
|
-
* in, which is not what should be re-fetched on a reconnect — only what someone is actually
|
|
144
|
-
* reading. An active thread is always registered, listed or not (`thread.activate()` registers it).
|
|
145
|
-
* Guarded on the owning channel the same way active channels are: a thread whose channel was
|
|
146
|
-
* disconnected (`disconnect()`) has nothing to recover into.
|
|
60
|
+
* Threads a consumer is displaying. They need their own pass: channel reloads and the thread list
|
|
61
|
+
* refresh do not rehydrate them. Threads of a disconnected channel are skipped.
|
|
147
62
|
*/
|
|
148
63
|
private get recoverableActiveThreads();
|
|
149
64
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* and any other reloads on its next `activate()`.
|
|
65
|
+
* Flags closed threads stale, since they miss events during a drop. A listed thread rehydrates via the
|
|
66
|
+
* thread list reload, any other on its next `activate()`.
|
|
153
67
|
*/
|
|
154
68
|
private markInactiveThreadsStale;
|
|
155
69
|
private recoverChannelLists;
|
|
156
70
|
private recoverActiveChannels;
|
|
157
|
-
/**
|
|
158
|
-
* Run a full recovery now, without waiting for a connection event.
|
|
159
|
-
*
|
|
160
|
-
* A no-op while one is already running: {@link recoverActiveChannels} defers the request to the
|
|
161
|
-
* end of the pass in flight rather than stacking a second one alongside it.
|
|
162
|
-
*/
|
|
71
|
+
/** Runs a full recovery now, without waiting for a connection event. A no-op while one is running. */
|
|
163
72
|
recover: () => Promise<void>;
|
|
164
73
|
}
|
|
@@ -4,150 +4,79 @@ import type { NetworkConnectionObserverConfig, NetworkConnectionState, NetworkSt
|
|
|
4
4
|
import type { StreamChat } from '../../client';
|
|
5
5
|
export declare const DEFAULT_NETWORK_CONNECTION_OBSERVER_CONFIG: NetworkConnectionObserverConfig;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Device network status as reactive `state`, written only through {@link setStatus} (by a
|
|
8
|
+
* {@link NetworkStatusReporter}). It is a separate fact from the WebSocket status in
|
|
9
|
+
* `client.wsConnection.state`: a socket can die on a working network, and a device can go offline
|
|
10
|
+
* before the socket notices. Read both and branch; network status must never gate requests.
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* has not noticed yet and keeps looking healthy for up to its 35s connection-check window. Conflating them is
|
|
13
|
-
* what makes offline UI blame the network for a dead socket, so nothing here derives one from the
|
|
14
|
-
* other:
|
|
15
|
-
*
|
|
16
|
-
* - the `network*` fields are written **only** via {@link setStatus}, from the platform
|
|
17
|
-
* listener the integrator registers ({@link NetworkStatusReporter}). The SDK cannot detect
|
|
18
|
-
* device network status itself — every platform reports it differently — so it has to be told. A
|
|
19
|
-
* browser reports it properly and that reporter is installed automatically; everywhere else the
|
|
20
|
-
* stand-in mirrors the WebSocket until a real reporter is installed, and `isOnline` stays
|
|
21
|
-
* `undefined` — *unknown* rather than offline — until the socket has been up once.
|
|
22
|
-
* Combining the two is a presentation decision and deliberately absent: whether "network down and
|
|
23
|
-
* socket down" reads as *no network* or as *reconnecting* is copy taxonomy, and a boolean named for
|
|
24
|
-
* reachability invites gating requests on it, which network status must never do. Read both and branch.
|
|
25
|
-
*
|
|
26
|
-
* The store is the whole interface. There is no companion event: a store already says both what the
|
|
27
|
-
* status is and that it just changed, and publishing the same fact twice only created the chance for
|
|
28
|
-
* the two to disagree.
|
|
12
|
+
* Browsers get their reporter automatically. Elsewhere a stand-in mirrors the WebSocket until a real
|
|
13
|
+
* one is installed, and `isOnline` stays `undefined` (unknown) until the socket has been up once.
|
|
29
14
|
*/
|
|
30
15
|
export declare class NetworkConnectionObserver extends WithSubscriptions {
|
|
31
16
|
client: StreamChat;
|
|
32
17
|
state: StateStore<NetworkConnectionState>;
|
|
33
|
-
/** The shared configuration machinery — see {@link ConfigController}. */
|
|
34
18
|
private readonly configController;
|
|
35
|
-
/**
|
|
36
|
-
* Held separately from `addUnsubscribeFunction` because it has to be **replaced**, not just torn
|
|
37
|
-
* down: that set only clears on unregister, so it cannot express a swap.
|
|
38
|
-
*/
|
|
19
|
+
/** Replaced on each install, which `addUnsubscribeFunction` (cleared on unregister) cannot do. */
|
|
39
20
|
private unsubscribeStatusReporter?;
|
|
40
|
-
/**
|
|
41
|
-
* The reporter currently installed, so re-installing the same one is a no-op. Configuration is
|
|
42
|
-
* re-derived more than once — the client calls `initializeConfig` directly and again through the
|
|
43
|
-
* config store's immediate subscribe — and tearing a platform listener down only to recreate it
|
|
44
|
-
* identical is wasteful at best and, for something like `NetInfo`, a needless native round trip.
|
|
45
|
-
*/
|
|
21
|
+
/** The installed reporter, so re-installing the same one (config is re-derived) is a no-op. */
|
|
46
22
|
private installedReporter?;
|
|
47
23
|
/**
|
|
48
|
-
* What
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* Held here rather than written into the resolved configuration, which a derivation rebuilds from
|
|
52
|
-
* the declarative tree: a reporter set imperatively has to survive `client.config.set` on any
|
|
53
|
-
* `client` key.
|
|
24
|
+
* What `setStatusReporter` was last given (`null` clears, `undefined` if never called). Kept out
|
|
25
|
+
* of the resolved config, which derivations rebuild.
|
|
54
26
|
*/
|
|
55
27
|
private imperativeReporter?;
|
|
56
|
-
/**
|
|
57
|
-
* The declared reporter the last installation saw, so a *change* to it can be told apart from a
|
|
58
|
-
* re-derivation that named the same thing. Whichever source spoke last wins, and this is what makes
|
|
59
|
-
* that comparison possible.
|
|
60
|
-
*/
|
|
28
|
+
/** The declared reporter the last install saw, to tell a changed declaration from a re-derive. */
|
|
61
29
|
private declaredReporter?;
|
|
62
30
|
/**
|
|
63
|
-
* Whether
|
|
64
|
-
* the client
|
|
65
|
-
* reporter there on the first call could report a status into a half-built client.
|
|
31
|
+
* Whether config was derived at least once. `registerSubscriptions` runs mid-construction, when
|
|
32
|
+
* the client cannot take a status report yet.
|
|
66
33
|
*/
|
|
67
34
|
private configInitialized;
|
|
68
|
-
/**
|
|
69
|
-
* The host default, built once. {@link getDefaultNetworkStatusReporter} returns a fresh closure for
|
|
70
|
-
* the socket-derived variant, and a fresh identity every derivation would defeat the
|
|
71
|
-
* re-installation guard below — tearing a platform listener down only to recreate it identical.
|
|
72
|
-
*/
|
|
35
|
+
/** The host default, built once: the socket-mirroring one is a fresh closure per call. */
|
|
73
36
|
private defaultReporter?;
|
|
74
37
|
constructor({ client }: {
|
|
75
38
|
client: StreamChat;
|
|
76
39
|
});
|
|
77
|
-
/**
|
|
78
|
-
* Resolved configuration, as a store — the shape every configurable class exposes
|
|
79
|
-
* (`configState` / `config` / `updateConfig`).
|
|
80
|
-
*/
|
|
81
40
|
get configState(): StateStore<NetworkConnectionObserverConfig>;
|
|
82
|
-
/** The current resolved configuration. `Readonly` — change it through {@link updateConfig}. */
|
|
83
41
|
get config(): Readonly<NetworkConnectionObserverConfig>;
|
|
84
42
|
/**
|
|
85
|
-
* Merges a partial configuration into the resolved config
|
|
43
|
+
* Merges a partial configuration into the resolved config. Also re-installs the reporter: the
|
|
44
|
+
* `setStatusReporter` one unless the configured reporter has changed since (set, replaced or
|
|
45
|
+
* cleared), else the configured one, else the host default.
|
|
86
46
|
*
|
|
87
|
-
*
|
|
88
|
-
* {@link setStatusReporter} rather than a write nobody acts on. Without it the field was
|
|
89
|
-
* stored and never invoked, leaving `isOnline` `undefined` forever with no error anywhere.
|
|
47
|
+
* @param config - Fields to merge into the resolved config.
|
|
90
48
|
*/
|
|
91
49
|
updateConfig(config: Partial<NetworkConnectionObserverConfig>): void;
|
|
92
50
|
/**
|
|
93
|
-
* Rebuilds the resolved configuration from package defaults plus the declarative slice
|
|
94
|
-
*
|
|
95
|
-
*
|
|
51
|
+
* Rebuilds the resolved configuration from package defaults plus the declarative slice. Also
|
|
52
|
+
* re-installs the reporter: the `setStatusReporter` one unless the configured reporter has changed
|
|
53
|
+
* since (set, replaced or cleared), else the configured one, else the host default.
|
|
96
54
|
*
|
|
97
|
-
*
|
|
98
|
-
* is what makes `client.config.set({ client: { connections: { statusReporter } } })` work.
|
|
55
|
+
* @param config - The declarative slice. Leave it out to rebuild from the defaults.
|
|
99
56
|
*/
|
|
100
57
|
initializeConfig(config?: Partial<NetworkConnectionObserverConfig>): void;
|
|
101
|
-
/** The reporter for this host, resolved once. See {@link defaultReporter}. */
|
|
102
58
|
private get hostDefaultReporter();
|
|
103
|
-
/**
|
|
104
|
-
* Installs the reporter the resolved configuration names, falling back to the host default.
|
|
105
|
-
*
|
|
106
|
-
* The single place installation happens, so every path that can change what should be installed —
|
|
107
|
-
* a derivation, a patch — goes through the same resolution instead of each reimplementing it.
|
|
108
|
-
*/
|
|
59
|
+
/** Installs the imperative reporter if set, else the declared one, else the host default. */
|
|
109
60
|
private installConfiguredReporter;
|
|
110
|
-
/**
|
|
111
|
-
* Device network status. `undefined` means unknown — see {@link NetworkConnectionState.isOnline}.
|
|
112
|
-
* Guards must test `=== false`, never `!isOnline`.
|
|
113
|
-
*/
|
|
61
|
+
/** Device network status; `undefined` is unknown, so test `=== false`, never `!isOnline`. */
|
|
114
62
|
get isOnline(): boolean | undefined;
|
|
115
63
|
/**
|
|
116
|
-
* Whether the installed reporter is the
|
|
117
|
-
* (`createWSConnectionNetworkStatusReporter`)
|
|
118
|
-
* down", not "the device is offline".
|
|
64
|
+
* Whether the installed reporter is the default that mirrors the WebSocket
|
|
65
|
+
* (`createWSConnectionNetworkStatusReporter`), where `isOnline === false` means "socket down".
|
|
119
66
|
*
|
|
120
67
|
* @internal
|
|
121
68
|
*/
|
|
122
69
|
get usesDefaultWSConnectionNetworkStatusReporter(): boolean;
|
|
123
70
|
/**
|
|
124
|
-
* Installs the platform listener that reports device network status,
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* Available as a setter, not just a constructor option, because React Native registers its native
|
|
129
|
-
* handlers *after* the client exists.
|
|
130
|
-
*
|
|
131
|
-
* What is set here survives every later configuration derivation, and is only superseded by the
|
|
132
|
-
* declarative tree naming a *different* reporter — `client.config.set({ client: { networkConnection:
|
|
133
|
-
* { statusReporter } } })`.
|
|
71
|
+
* Installs the platform listener that reports device network status, replacing the previous one.
|
|
72
|
+
* `null` clears it and keeps the last known status. It survives later config derivations and is
|
|
73
|
+
* superseded only when the config names a different reporter
|
|
74
|
+
* (`client.config.set({ client: { networkConnection: { statusReporter } } })`).
|
|
134
75
|
*/
|
|
135
76
|
setStatusReporter(reporter: NetworkStatusReporter | null | undefined): void;
|
|
136
|
-
/** Installs one reporter, unsubscribing whatever was there. */
|
|
137
77
|
private installReporter;
|
|
138
|
-
/**
|
|
139
|
-
* Reports device network status.
|
|
140
|
-
*
|
|
141
|
-
* The reporter calls this; so may a host with no listener API to register at all, and it is the
|
|
142
|
-
* supported replacement for reaching into `client.wsConnection.onlineStatusChanged` with a
|
|
143
|
-
* synthesized DOM event.
|
|
144
|
-
*/
|
|
78
|
+
/** Reports device network status. Called by the reporter, or by a host with no listener API. */
|
|
145
79
|
setStatus(isOnline: boolean): void;
|
|
146
|
-
/**
|
|
147
|
-
* Nothing to subscribe to beyond the reporter, which {@link initializeConfig} installs — this
|
|
148
|
-
* class has no client events to listen to, by design: deriving either status from an event would
|
|
149
|
-
* be the conflation it exists to prevent. Present because `WithSubscriptions` requires it, and so
|
|
150
|
-
* that teardown releases the platform listener.
|
|
151
|
-
*/
|
|
80
|
+
/** Listens to no client events; teardown only releases the platform listener. */
|
|
152
81
|
registerSubscriptions: () => () => symbol;
|
|
153
82
|
}
|
|
@@ -1,43 +1,20 @@
|
|
|
1
1
|
import type { NetworkStatusReporter } from './types';
|
|
2
2
|
import type { WSConnection } from '../wsConnection/WSConnection';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Feature-detects rather than trusting its own name. It is exported, so it can be handed to
|
|
8
|
-
* `client.config.set` on any host — a Node process, a server-side render of code written for the
|
|
9
|
-
* browser — and dereferencing `window` there threw, where a reporter is meant to fail quietly.
|
|
4
|
+
* Reports `navigator.onLine` and `online`/`offline` events. Installed automatically in browsers.
|
|
5
|
+
* It reports nothing (so `isOnline` stays `undefined`) on a host without those APIs, where it can
|
|
6
|
+
* still be passed in the config.
|
|
10
7
|
*/
|
|
11
8
|
export declare const browserNetworkStatusReporter: NetworkStatusReporter;
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* Native has no built-in way to answer the question, so an integrator who forgets to install
|
|
18
|
-
* `@react-native-community/netinfo` would otherwise leave `isOnline` unknown forever, and every
|
|
19
|
-
* consumer branching on it dead. Mirroring the socket is wrong in the cases where the two disagree,
|
|
20
|
-
* and right in the common case where the device really did lose its network and took the socket with
|
|
21
|
-
* it.
|
|
22
|
-
*
|
|
23
|
-
* Nothing is reported until the socket has been up once. `isHealthy` on the WebSocket store is
|
|
24
|
-
* `false` from construction, and forwarding that would claim the device is offline before
|
|
25
|
-
* anything had been attempted — a fabricated reading, which is the one thing this module refuses
|
|
26
|
-
* to produce. Until then the device's status stays `undefined`, meaning unknown.
|
|
27
|
-
*
|
|
28
|
-
* Install a real reporter wherever one exists. This one can only ever repeat what the socket already
|
|
29
|
-
* said, so it cannot tell you that the network came back before the socket noticed, which is the
|
|
30
|
-
* whole reason the network signal is worth having.
|
|
10
|
+
* Stand-in for hosts that cannot report their own network status: mirrors this client's WebSocket,
|
|
11
|
+
* which is not a measurement of the device's network (a socket can die on a working network). It
|
|
12
|
+
* reports nothing until the socket has been up once, so a client that never connected stays unknown.
|
|
13
|
+
* Install a real reporter where one exists.
|
|
31
14
|
*/
|
|
32
15
|
export declare const createWSConnectionNetworkStatusReporter: (wsConnection: WSConnection) => NetworkStatusReporter;
|
|
33
16
|
/**
|
|
34
|
-
* The reporter
|
|
35
|
-
*
|
|
36
|
-
* {@link browserNetworkStatusReporter} in a browser, where the platform answers the question
|
|
37
|
-
* properly, and {@link createWSConnectionNetworkStatusReporter} everywhere else.
|
|
38
|
-
*
|
|
39
|
-
* Always returns something, so an integration missing a line of setup gets a coarse signal rather
|
|
40
|
-
* than none at all, which would fail silently. Nothing is fabricated: the stand-in reports nothing
|
|
41
|
-
* until the socket has been up once, so a client that has never connected still answers `undefined`.
|
|
17
|
+
* The reporter installed when none is configured: {@link browserNetworkStatusReporter} in a browser,
|
|
18
|
+
* {@link createWSConnectionNetworkStatusReporter} elsewhere.
|
|
42
19
|
*/
|
|
43
20
|
export declare const getDefaultNetworkStatusReporter: (wsConnection: WSConnection) => NetworkStatusReporter;
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import type { Unsubscribe } from '@stream-io/state-store';
|
|
2
2
|
/**
|
|
3
|
-
* Registers a platform
|
|
3
|
+
* Registers a platform network status listener and returns a function that removes it. The SDK
|
|
4
|
+
* cannot detect the device's network status itself, so the host reports it (browser
|
|
5
|
+
* `online`/`offline` events, `@react-native-community/netinfo`, ...).
|
|
4
6
|
*
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* to be told, and this one function is the whole contract.
|
|
9
|
-
*
|
|
10
|
-
* The reporter **MUST** call `onStatusChange` with the current status as soon as it is known —
|
|
11
|
-
* synchronously where the platform allows it (`navigator.onLine`), after an await where it does not
|
|
12
|
-
* (`NetInfo.fetch()`) — and again on every subsequent change. Making initial emission the reporter's
|
|
13
|
-
* job is what lets one function cover both shapes, and it matches this package's convention:
|
|
14
|
-
* `StateStore.subscribe` also fires once with the current value before returning.
|
|
15
|
-
*
|
|
16
|
-
* A reporter that never emits leaves {@link NetworkConnectionState.isOnline} as `undefined`, which is
|
|
17
|
-
* a safe state rather than a broken one — see that field.
|
|
18
|
-
*
|
|
19
|
-
* @returns A function that removes the listener.
|
|
7
|
+
* The reporter **MUST** call `onStatusChange` with the current status as soon as it is known
|
|
8
|
+
* (synchronously or after an await) and again on every change. One that never emits leaves
|
|
9
|
+
* {@link NetworkConnectionState.isOnline} `undefined`.
|
|
20
10
|
*
|
|
21
11
|
* @example React Native
|
|
22
12
|
* ```ts
|
|
@@ -31,23 +21,18 @@ import type { Unsubscribe } from '@stream-io/state-store';
|
|
|
31
21
|
export type NetworkStatusReporter = (onStatusChange: (isOnline: boolean) => void) => Unsubscribe;
|
|
32
22
|
export type NetworkConnectionObserverConfig = {
|
|
33
23
|
/**
|
|
34
|
-
* The platform listener that feeds `client.networkConnection`. `undefined
|
|
35
|
-
*
|
|
24
|
+
* The platform listener that feeds `client.networkConnection`. When `undefined`, browsers use the
|
|
25
|
+
* built-in browser reporter and other hosts a reporter that mirrors the WebSocket.
|
|
36
26
|
*/
|
|
37
27
|
statusReporter: NetworkStatusReporter | undefined;
|
|
38
28
|
};
|
|
39
29
|
export type NetworkConnectionState = {
|
|
40
30
|
/**
|
|
41
|
-
* Device network status, as reported by the
|
|
42
|
-
*
|
|
43
|
-
* `undefined` means **unknown**: no reporter is installed, or it has not reported yet. It does not
|
|
44
|
-
* mean offline, and guards must therefore test `isOnline === false` rather than `!isOnline` —
|
|
45
|
-
* treating unknown as offline silently disables behaviour on every host without a built-in
|
|
46
|
-
* reporter, React Native among them.
|
|
31
|
+
* Device network status, as reported by the installed reporter. `undefined` means unknown (no
|
|
32
|
+
* reporter, or none has reported yet), not offline: test `isOnline === false`, never `!isOnline`.
|
|
47
33
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* while the socket has not noticed yet.
|
|
34
|
+
* Outside the browser the default reporter mirrors the WebSocket, so `false` then means the socket
|
|
35
|
+
* is down.
|
|
51
36
|
*/
|
|
52
37
|
isOnline: boolean | undefined;
|
|
53
38
|
lastOnlineAt: Date | null;
|