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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
1
2
|
import type { StreamChat } from '../client';
|
|
2
3
|
import type { LiveLocationManager, LiveLocationManagerConfig } from '../LiveLocationManager';
|
|
3
4
|
import type { SearchController, SearchControllerConfig } from '../search/SearchController';
|
|
@@ -6,6 +7,7 @@ import type { MessageComposerConfig } from '../messageComposer/configuration/typ
|
|
|
6
7
|
import type { Channel, ChannelConfig } from '../channel';
|
|
7
8
|
import type { Thread, ThreadConfig } from '../thread';
|
|
8
9
|
import type { ReminderManagerConfig } from '../reminders/ReminderManager';
|
|
10
|
+
import type { NotificationManager } from '../notifications/NotificationManager';
|
|
9
11
|
import type { NotificationManagerConfig } from '../notifications/types';
|
|
10
12
|
import type { MessageDeliveryReporterConfig } from '../messageDelivery/MessageDeliveryReporter';
|
|
11
13
|
import type { ThreadManagerConfig } from '../thread_manager';
|
|
@@ -14,12 +16,8 @@ import type { MessageOperationsConfig } from '../messageOperations/MessageOperat
|
|
|
14
16
|
import type { DeclarativePaginatorConfig as ImportedDeclarativePaginatorConfig } from '../pagination/paginators/BasePaginator';
|
|
15
17
|
import type { DeepPartial } from '../types.utility';
|
|
16
18
|
/**
|
|
17
|
-
* Maps a configuration key to the argument its setup function receives.
|
|
18
|
-
*
|
|
19
|
-
* A closed set, and deliberately not an `interface`: a type alias cannot be reached by module
|
|
20
|
-
* augmentation, so the key space cannot be extended from outside this package. Configuration for a class
|
|
21
|
-
* this package does not own belongs to whoever owns that class — a registry of its own, not a key in this
|
|
22
|
-
* one, which the SDK could neither type nor apply.
|
|
19
|
+
* Maps a configuration key to the argument its setup function receives. A type alias, so the key space
|
|
20
|
+
* is closed to module augmentation.
|
|
23
21
|
*/
|
|
24
22
|
export type InstanceSetupFunctionArgs = {
|
|
25
23
|
channel: {
|
|
@@ -42,24 +40,16 @@ export type InstanceSetupFunctionArgs = {
|
|
|
42
40
|
};
|
|
43
41
|
};
|
|
44
42
|
/**
|
|
45
|
-
* The keys that take a
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* Closed, and not extensible: an undeclared string is a compile error, and {@link
|
|
49
|
-
* InstanceSetupFunctionArgs} is a type alias rather than an interface, so a key cannot be added by module
|
|
50
|
-
* augmentation either. This key space describes what *this package* configures.
|
|
51
|
-
*
|
|
52
|
-
* A strict subset of {@link InstanceConfigKey}: `messagePaginator` and `messageOperations` take
|
|
53
|
-
* configuration but have no setup function, because they are not built one-per-key — a channel and every
|
|
54
|
-
* one of its threads each own one.
|
|
43
|
+
* The keys that take a setup function. A strict subset of {@link InstanceConfigKey}: `messagePaginator`
|
|
44
|
+
* and `messageOperations` take configuration but no setup function, since a channel and each of its
|
|
45
|
+
* threads own one.
|
|
55
46
|
*/
|
|
56
47
|
export type InstanceSetupKey = keyof InstanceSetupFunctionArgs;
|
|
57
48
|
export type InstanceSetupFunctionArgsOf<K extends InstanceSetupKey> = InstanceSetupFunctionArgs[K];
|
|
58
49
|
export type InstanceSetupTearDownFunction = () => void;
|
|
59
50
|
/**
|
|
60
|
-
* Runs against every instance of its class
|
|
61
|
-
*
|
|
62
|
-
* before the setup function is re-applied, and when the instance is disposed of.
|
|
51
|
+
* Runs against every instance of its class, existing and future. Return a function that undoes what you
|
|
52
|
+
* changed: it runs before the setup function is re-applied and when the instance is disposed of.
|
|
63
53
|
*/
|
|
64
54
|
export type InstanceSetupFunction<K extends InstanceSetupKey = InstanceSetupKey> = (args: InstanceSetupFunctionArgsOf<K>) => void | InstanceSetupTearDownFunction;
|
|
65
55
|
export type InstanceSetupState<K extends InstanceSetupKey = InstanceSetupKey> = {
|
|
@@ -68,22 +58,14 @@ export type InstanceSetupState<K extends InstanceSetupKey = InstanceSetupKey> =
|
|
|
68
58
|
/** Whether `jumpToTheFirstUnreadMessage` prefers the paginator's snapshot or the channel read state. */
|
|
69
59
|
export type UnreadReferencePolicy = 'snapshot' | 'read-state-only';
|
|
70
60
|
/**
|
|
71
|
-
* Paginator fields settable through the declarative tree.
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* Deliberately excluded there:
|
|
76
|
-
* - `itemIndex` / `createItemIndex` — an index instance and a factory, not configuration. Deep-merging
|
|
77
|
-
* a class instance is unsound, and swapping an index would drop already-loaded items.
|
|
78
|
-
* - `doRequest`, `itemOrderComparator`, `deriveCursor` — installed per paginator subclass
|
|
79
|
-
* (`PinnedMessagePaginator` supplies all three). Replace them through a setup function, where the
|
|
80
|
-
* existing value is visible and restorable.
|
|
81
|
-
*
|
|
82
|
-
* `initialCursor` and `initialOffset` are included but read only during construction — see
|
|
61
|
+
* Paginator fields settable through the declarative tree. Defined in `BasePaginator`, which excludes
|
|
62
|
+
* what is not plain configuration: `itemIndex` / `createItemIndex`, and the per-subclass `doRequest`,
|
|
63
|
+
* `itemOrderComparator` and `deriveCursor` (replace those through a setup function).
|
|
64
|
+
* `initialCursor` and `initialOffset` are read only during construction, see
|
|
83
65
|
* {@link CONSTRUCTION_ONLY_CONFIG_PATHS}.
|
|
84
66
|
*/
|
|
85
67
|
export type { DeclarativePaginatorConfig } from '../pagination/paginators/BasePaginator';
|
|
86
|
-
/** Adds the message-list-only
|
|
68
|
+
/** Adds the message-list-only `unreadReferencePolicy`. */
|
|
87
69
|
export type DeclarativeMessagePaginatorConfig = ImportedDeclarativePaginatorConfig & {
|
|
88
70
|
unreadReferencePolicy?: UnreadReferencePolicy;
|
|
89
71
|
};
|
|
@@ -112,96 +94,86 @@ export type ThreadDeclarativeConfig = {
|
|
|
112
94
|
};
|
|
113
95
|
export type ClientDeclarativeConfig = {
|
|
114
96
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
97
|
+
* Silences the warning `connectUser` / `connectAnonymousUser` log when called server-side, where a
|
|
98
|
+
* connection counts towards MAU and concurrent-connection billing. Read on every connect.
|
|
117
99
|
*/
|
|
100
|
+
allowServerSideConnect?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Axios request configuration (`timeout`, `headers`, `httpsAgent`, ...). Built into the client's axios
|
|
103
|
+
* instance once, at construction; `headers` and `params` are also read on every request. Copied when
|
|
104
|
+
* registered, so mutating the object afterwards has no effect.
|
|
105
|
+
*/
|
|
106
|
+
axiosRequestConfig?: AxiosRequestConfig;
|
|
107
|
+
/** Base URL of the API, such as `https://chat-proxy-dublin.stream-io-api.com`. Read once. */
|
|
108
|
+
baseURL?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Forces browser (`true`) or Node (`false`) mode; detected from the global `window` when absent. Read
|
|
111
|
+
* live, through `client.browser` and `client.node`.
|
|
112
|
+
*/
|
|
113
|
+
browser?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* A pre-built {@link NotificationManager} to use instead of constructing one, to share it between
|
|
116
|
+
* clients or hand over one that already holds notifications. Read once, at construction. The
|
|
117
|
+
* `notifications` slice is still applied to it.
|
|
118
|
+
*/
|
|
119
|
+
notificationManager?: NotificationManager;
|
|
120
|
+
/**
|
|
121
|
+
* When true, `client.user` is kept if `connectUser` fails, so an offline-capable app does not have to
|
|
122
|
+
* call `connectUser` again to retry. Read when a connect fails.
|
|
123
|
+
*/
|
|
124
|
+
persistUserOnConnectionFailure?: boolean;
|
|
118
125
|
connectionRecovery?: Partial<ConnectionRecoveryManagerConfig>;
|
|
119
126
|
messageDelivery?: Partial<MessageDeliveryReporterConfig>;
|
|
120
127
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* `
|
|
124
|
-
* into.
|
|
128
|
+
* The platform listener that reports the device's network, which React Native and other hosts supply
|
|
129
|
+
* here. Defaults to browser events, else a reporter that mirrors the WebSocket. `Partial`, not
|
|
130
|
+
* `DeepPartial`: the only field holds a function, which `DeepPartial` would descend into.
|
|
125
131
|
*/
|
|
126
132
|
networkConnection?: Partial<NetworkConnectionObserverConfig>;
|
|
127
133
|
threads?: Partial<ThreadManagerConfig>;
|
|
128
|
-
/**
|
|
129
|
-
* The WebSocket's timing: connect timeout, ping interval, and the health-check grace period on top of it.
|
|
130
|
-
* These three, and only these, because each was a public mutable field before it was configuration.
|
|
131
|
-
* `Partial`, not `DeepPartial`: every field is a flat number.
|
|
132
|
-
*/
|
|
134
|
+
/** `Partial`, not `DeepPartial`: fields are flat or class instances, which it would descend into. */
|
|
133
135
|
wsConnection?: Partial<WSConnectionConfig>;
|
|
134
136
|
notifications?: DeepPartial<NotificationManagerConfig>;
|
|
135
137
|
/**
|
|
136
138
|
* `Partial`, not `DeepPartial`: `scheduledOffsetsMs` is a `number[]`, and `DeepPartial` would widen
|
|
137
|
-
* its elements to `number | undefined`, which `ReminderManager.updateConfig`
|
|
139
|
+
* its elements to `number | undefined`, which `ReminderManager.updateConfig` rejects.
|
|
138
140
|
*/
|
|
139
141
|
reminders?: Partial<ReminderManagerConfig>;
|
|
140
142
|
};
|
|
141
143
|
/**
|
|
142
|
-
* Maps a configuration key to its declarative configuration subtree.
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* **When something gets its own key rather than being nested under a parent** — the rule that decides
|
|
147
|
-
* the shape of this interface:
|
|
148
|
-
*
|
|
149
|
-
* - **One parent type ⇒ nest it.** `channel.pinnedMessagesPaginator`, `channel.cooldownTimer`, the
|
|
150
|
-
* composer's own sub-managers. There is only one place it can be reached from.
|
|
151
|
-
* - **Several parent types, and the configuration means the same thing under each ⇒ own key.**
|
|
152
|
-
* `MessageComposer` hangs off a `Channel`, a `Thread`, *and* a message (the React SDK builds
|
|
153
|
-
* message-scoped composers for editing). `drafts.enabled` means the same in all three, so nesting it
|
|
154
|
-
* under `channel` would silently miss two thirds of the composers.
|
|
155
|
-
* - **Several parent types, but the configuration is inherently parent-specific ⇒ nest it anyway.**
|
|
156
|
-
* No built-in falls here today. It is kept as a case because it is the one that decides against a shared
|
|
157
|
-
* key, and the next entity to arrive may need it.
|
|
158
|
-
* - **Several parent types, mixed ⇒ both.** A shared top-level key for what means the same thing, plus
|
|
159
|
-
* per-parent paths that override it field by field (see {@link mergeDeclarativeMessageOperationsConfig}).
|
|
160
|
-
* Both shared keys are here: `MessagePaginator` backs the channel message list *and* thread replies
|
|
161
|
-
* (`stateThrottleMs` / `retryCount` have no reason to differ, `pageSize` legitimately does), and
|
|
162
|
-
* `MessageOperations` backs channel *and* thread sends. `messageOperations` was briefly nested under
|
|
163
|
-
* `channel` on the reasoning that a channel send and a thread reply are different operations — which made
|
|
164
|
-
* `thread.messageOperations` unconfigurable entirely (**DV-15**). Counting parents is the check.
|
|
144
|
+
* Maps a configuration key to its declarative configuration subtree. A class with one parent type is
|
|
145
|
+
* nested under that parent. A class held by several parents (`MessageComposer`, `MessagePaginator`,
|
|
146
|
+
* `MessageOperations`) gets its own shared key, and where parents need to differ they override it per
|
|
147
|
+
* field (see {@link mergeDeclarativeMessageOperationsConfig}).
|
|
165
148
|
*/
|
|
166
149
|
export type InstanceConfigTree = {
|
|
167
150
|
channel: ChannelDeclarativeConfig;
|
|
168
151
|
client: ClientDeclarativeConfig;
|
|
169
152
|
/**
|
|
170
|
-
* Constructed by
|
|
171
|
-
*
|
|
172
|
-
* registering itself against this key, so its owner does not have to thread a slice through.
|
|
153
|
+
* Constructed by the integrator or a UI SDK, never by this package. It reaches its configuration by
|
|
154
|
+
* registering itself against this key.
|
|
173
155
|
*/
|
|
174
156
|
liveLocationManager: Partial<LiveLocationManagerConfig>;
|
|
175
157
|
messageComposer: DeepPartial<MessageComposerConfig>;
|
|
176
158
|
/**
|
|
177
|
-
* Applies to
|
|
178
|
-
*
|
|
159
|
+
* Applies to every `MessageOperations`, the channel's and each thread's.
|
|
160
|
+
* `channel.messageOperations` and `thread.messageOperations` override it per parent.
|
|
179
161
|
*/
|
|
180
162
|
messageOperations: Partial<MessageOperationsConfig>;
|
|
181
163
|
/**
|
|
182
|
-
* Applies to
|
|
164
|
+
* Applies to every `MessagePaginator`, the channel message list and thread replies alike.
|
|
183
165
|
* `channel.messagePaginator` and `thread.messagePaginator` override it per parent.
|
|
184
|
-
*
|
|
185
|
-
* `channel.pinnedMessagesPaginator` is deliberately **not** included: it has a single parent, so by
|
|
186
|
-
* the rule above it stays nested. It is also a different class (`PinnedMessagePaginator`, with its own
|
|
187
|
-
* ordering and endpoint) rather than a `MessagePaginator`.
|
|
166
|
+
* `channel.pinnedMessagesPaginator` is not included: it is a different class with a single parent.
|
|
188
167
|
*/
|
|
189
168
|
messagePaginator: DeclarativeMessagePaginatorConfig;
|
|
190
169
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* SDK does not hand a client to. See `SearchControllerOptions.client`.
|
|
170
|
+
* Like {@link InstanceConfigTree.liveLocationManager}, but a `SearchController` reaches this key only
|
|
171
|
+
* when constructed with a `client` (see `SearchControllerOptions.client`).
|
|
194
172
|
*/
|
|
195
173
|
searchController: Partial<SearchControllerConfig>;
|
|
196
174
|
thread: ThreadDeclarativeConfig;
|
|
197
175
|
};
|
|
198
|
-
/**
|
|
199
|
-
* Every key that takes **declarative configuration** — {@link InstanceSetupKey} plus the two that are
|
|
200
|
-
* configuration-only.
|
|
201
|
-
*
|
|
202
|
-
* Closed for the same reason, and {@link InstanceConfigTree} is likewise a type alias, so this set is
|
|
203
|
-
* fixed by the package.
|
|
204
|
-
*/
|
|
176
|
+
/** Every key that takes declarative configuration: {@link InstanceSetupKey} plus the config-only ones. */
|
|
205
177
|
export type InstanceConfigKey = keyof InstanceConfigTree;
|
|
206
178
|
export type InstanceConfigOf<K extends InstanceConfigKey> = InstanceConfigTree[K];
|
|
207
179
|
export type InstanceConfigState<K extends InstanceConfigKey = InstanceConfigKey> = {
|
|
@@ -4,55 +4,33 @@ import type { DeepPartial } from '../../types.utility';
|
|
|
4
4
|
import type { Unsubscribe } from '@stream-io/state-store';
|
|
5
5
|
/** @internal */
|
|
6
6
|
export type ApplyInstanceConfigurationParams<K extends InstanceSetupKey> = {
|
|
7
|
-
/** The instance's argument for its setup function
|
|
7
|
+
/** The instance's argument for its setup function, such as `{ channel }`. */
|
|
8
8
|
args: InstanceSetupFunctionArgsOf<K>;
|
|
9
|
-
/** The client's configuration registry, i.e. `client.config`. */
|
|
10
9
|
config: InstanceConfigurationRegistry;
|
|
11
10
|
key: K;
|
|
12
11
|
/**
|
|
13
|
-
* Other keys this instance derives from
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* applied after tier 1.
|
|
17
|
-
*
|
|
18
|
-
* Keys rather than stores, which buys two things beyond brevity. The instance is registered as a
|
|
19
|
-
* live instance of each, so `hasLiveInstances` is true for a shared key and its construction-only paths get
|
|
20
|
-
* same late-registration warning the per-parent slices already got. And there is no longer a structural
|
|
21
|
-
* store type needed to work around `StateStore`'s invariance.
|
|
12
|
+
* Other keys this instance derives from (`Channel` and `Thread` read `messagePaginator` and
|
|
13
|
+
* `messageOperations`). A change there re-runs the whole cycle, so the setup function is re-applied
|
|
14
|
+
* over the new values. The instance is also registered as live under each.
|
|
22
15
|
*/
|
|
23
16
|
alsoWatch?: readonly InstanceConfigKey[];
|
|
24
17
|
/**
|
|
25
|
-
* Applies
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* Called on every cycle, **including when this key has no configuration of its own** — an instance may
|
|
29
|
-
* derive from other inputs too (`alsoWatch`, or the server), so it has to be told to re-derive rather
|
|
30
|
-
* than being skipped. Hence the optional argument.
|
|
18
|
+
* Applies the declarative slice to the instance. Omit it if the instance only wants the setup function.
|
|
19
|
+
* Called on every cycle, with `undefined` when the key has no configuration, since the instance may
|
|
20
|
+
* derive from other inputs too.
|
|
31
21
|
*/
|
|
32
22
|
applyConfig?: (config?: DeepPartial<InstanceConfigOf<K>>) => void;
|
|
33
23
|
/**
|
|
34
|
-
* The instance's
|
|
35
|
-
*
|
|
36
|
-
* clear-registrations-only reset semantics.
|
|
24
|
+
* The instance's `initializeConfig`, bound. `reset` calls it after clearing both slots. Without it,
|
|
25
|
+
* reset only clears registrations.
|
|
37
26
|
*/
|
|
38
27
|
reinitializeConfig?: () => void;
|
|
39
28
|
};
|
|
40
29
|
/**
|
|
41
|
-
* Subscribes one instance to the configuration registered for its key
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* - applies whatever is already registered, immediately;
|
|
47
|
-
* - re-applies on every change to either slot, declarative configuration first and the setup function
|
|
48
|
-
* second, so a setup function always wins for the same field;
|
|
49
|
-
* - runs the previous setup function's teardown before re-applying, and again on unsubscribe;
|
|
50
|
-
* - contains errors — a throwing setup function, teardown or applier is logged and never propagates,
|
|
51
|
-
* so it cannot break `client.channelManager.ensure()` or a `Thread` construction.
|
|
52
|
-
*
|
|
53
|
-
* Not exported from the package. It only does anything for a key in {@link InstanceSetupKey}, and those
|
|
54
|
-
* keys all belong to classes this package constructs, so there is no caller outside it. `ConfigController`
|
|
55
|
-
* _is_ exported, because resolution is reusable on its own — see `docs/instance-configuration.md` §6.
|
|
30
|
+
* Subscribes one instance to the configuration registered for its key and returns the unsubscribe.
|
|
31
|
+
* Applies what is registered immediately, then on every change: declarative configuration first and the
|
|
32
|
+
* setup function second (so it wins), running the previous teardown before each re-apply and on
|
|
33
|
+
* unsubscribe. A throwing setup function, teardown or applier is logged, never propagated.
|
|
56
34
|
*
|
|
57
35
|
* @internal
|
|
58
36
|
*/
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copies a caller-supplied configuration patch so the stored value shares no mutable object with the
|
|
3
|
+
* caller (`mergeWith` reuses source subtrees verbatim). Plain objects and arrays are copied; everything
|
|
4
|
+
* else (functions, `Date`s, class instances) passes through by reference. Not `structuredClone`, which
|
|
5
|
+
* throws on the functions configuration holds. Cycles terminate and shared references stay shared.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
1
9
|
export declare const copyConfigPatch: <T>(value: T) => T;
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
import type { DeclarativePaginatorConfig } from '../../pagination/paginators/BasePaginator';
|
|
2
2
|
import type { MessageOperationsConfig } from '../../messageOperations/MessageOperations';
|
|
3
3
|
import type { DeclarativeMessagePaginatorConfig } from '../types';
|
|
4
|
-
/** Layers `
|
|
4
|
+
/** Layers a per-parent `messageOperations` slice (channel or thread) over the shared key. */
|
|
5
5
|
export declare const mergeDeclarativeMessageOperationsConfig: (general?: Partial<MessageOperationsConfig>, specific?: Partial<MessageOperationsConfig>) => Partial<MessageOperationsConfig> | undefined;
|
|
6
|
-
/** Layers `
|
|
6
|
+
/** Layers a per-parent `messagePaginator` slice (channel or thread) over the shared key. */
|
|
7
7
|
export declare const mergeDeclarativePaginatorConfig: (general?: DeclarativeMessagePaginatorConfig, specific?: DeclarativeMessagePaginatorConfig) => DeclarativeMessagePaginatorConfig | undefined;
|
|
8
8
|
/**
|
|
9
|
-
* Drops
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `unreadReferencePolicy` rides in the same subtree for the integrator's convenience, but it is not a
|
|
13
|
-
* `BasePaginatorConfig` field — `MessagePaginator` reads it once into a private member. Passed through to
|
|
14
|
-
* `initializeConfig` it landed in the published `config` as an untyped key that nothing reads, and a
|
|
15
|
-
* registration arriving after construction made resolved configuration *contradict* behaviour: the
|
|
16
|
-
* construction-only warning correctly said the value would not apply, and then
|
|
17
|
-
* `paginator.config.unreadReferencePolicy` reported it as though it had. A settings UI reading resolved
|
|
18
|
-
* config showed `read-state-only` for a paginator behaving as `snapshot`.
|
|
19
|
-
*
|
|
20
|
-
* So the owning `Channel` / `Thread` splits the slice: the constructor argument goes to the constructor,
|
|
21
|
-
* and only this half reaches the paginator's configuration. Both already read the policy separately, so
|
|
22
|
-
* nothing is lost.
|
|
9
|
+
* Drops `unreadReferencePolicy` from a message-paginator slice. `MessagePaginator` reads it once as a
|
|
10
|
+
* constructor argument, so leaving it in would make the resolved `config` report a value that does not
|
|
11
|
+
* apply.
|
|
23
12
|
*/
|
|
24
13
|
export declare const toDeclarativePaginatorConfig: (slice?: DeclarativeMessagePaginatorConfig) => DeclarativePaginatorConfig | undefined;
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Recursively freezes a package-level default configuration
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* constants, and the merge only *copies* a subtree that some layer actually touches — so a subtree nobody
|
|
6
|
-
* configured stays identical by reference to the module-level default, and is reachable through the
|
|
7
|
-
* instance's public `config` getter. A write through it therefore changed the default for every instance
|
|
8
|
-
* of every client in the process, including ones created afterwards. `Readonly<T>` cannot catch that: it
|
|
9
|
-
* is shallow, so it rejects `config.pageSize = 5` but accepts `config.drafts.enabled = true` — and the
|
|
10
|
-
* nested form is the one that reaches shared state. In ESM, which is always strict, a write to a frozen
|
|
11
|
-
* object throws a `TypeError` at the offending line instead of silently succeeding somewhere else.
|
|
12
|
-
*
|
|
13
|
-
* Deliberately lives in its own module rather than `src/utils.ts`: that barrel is `vi.mock`ed wholesale by
|
|
14
|
-
* some suites, and a default-config constant must not depend on which of its exports a test happens to
|
|
15
|
-
* stub.
|
|
16
|
-
*
|
|
17
|
-
* Functions are frozen as values but not walked — a function's `prototype` is not configuration. Freezing
|
|
18
|
-
* is idempotent and stops at anything already frozen, so shared sub-configs cost one visit.
|
|
2
|
+
* Recursively freezes a package-level default configuration. Resolved config shares untouched subtrees
|
|
3
|
+
* with these defaults, so an unfrozen nested write through `config` would change them for every instance
|
|
4
|
+
* in the process (`Readonly<T>` is shallow and cannot catch it). Functions are left as they are.
|
|
19
5
|
*
|
|
20
6
|
* @internal
|
|
21
7
|
*/
|
|
@@ -1,40 +1,20 @@
|
|
|
1
1
|
import type { DeepPartial } from '../../types.utility';
|
|
2
2
|
/**
|
|
3
|
-
* The fields a server decides
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Only server-decided fields may appear. The merge below lets any scalar on this side win, so an
|
|
7
|
-
* unrelated field smuggled in here would override the caller's value while looking like a server
|
|
8
|
-
* restriction.
|
|
3
|
+
* The fields a server decides, with the values it reports. Include only those: a non-boolean scalar
|
|
4
|
+
* here overrides the caller's, and a boolean is ANDed with it.
|
|
9
5
|
*/
|
|
10
6
|
export type ServerRestrictions<TConfig extends object> = DeepPartial<TConfig>;
|
|
11
7
|
/**
|
|
12
|
-
*
|
|
13
|
-
* a
|
|
14
|
-
*
|
|
15
|
-
* Separate from {@link ServerRestrictions} because the two combine differently, and putting a ceiling in the
|
|
16
|
-
* wrong bucket is a silent bug rather than a type error: a restriction *replaces* the requested value, which
|
|
17
|
-
* for a limit would widen a caller who deliberately asked for something stricter.
|
|
8
|
+
* Fields where the server states a maximum (e.g. `max_message_length`). Separate from
|
|
9
|
+
* {@link ServerRestrictions} because a restriction replaces the value, which would widen a stricter
|
|
10
|
+
* caller.
|
|
18
11
|
*/
|
|
19
12
|
export type ServerUpperBounds<TConfig extends object> = DeepPartial<TConfig>;
|
|
20
13
|
/**
|
|
21
|
-
* Applies
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* configuration can change — construction, the declarative tree, a setup function, a direct
|
|
26
|
-
* `updateConfig` — because a restriction applied only at construction holds until the first time anything
|
|
27
|
-
* updates the configuration and then silently stops holding. `MessageComposer` learned this the hard way:
|
|
28
|
-
* only its `deriveConfig` applied the restrictions, so registering `location.enabled: true` on a running
|
|
29
|
-
* app widened past a `shared_locations: false` server and produced a composer offering a feature the API
|
|
30
|
-
* rejects (**DV-16**).
|
|
31
|
-
*
|
|
32
|
-
* **What it deliberately does not do.** It knows nothing about *where* restrictions come from. Reading
|
|
33
|
-
* them is the entity's job, because only the entity knows what to ask — a composer reads its channel's
|
|
34
|
-
* `serverConfig`, something else might read capabilities — and the answer depends on an instance that
|
|
35
|
-
* exists. That is also why this does not live in `InstanceConfigurationRegistry`: that service merges
|
|
36
|
-
* declarative layers before any instance exists, and its merges follow the opposite rule (a more specific
|
|
37
|
-
* layer *may* re-enable what a broader one disabled), which rule 1 would break.
|
|
14
|
+
* Applies server restrictions to a requested configuration, so the result never claims more than the
|
|
15
|
+
* server allows. Call it on every route that changes a configuration (construction, declarative tree,
|
|
16
|
+
* setup function, `updateConfig`), or the restrictions stop holding at the first update. Reading the
|
|
17
|
+
* restrictions is the entity's job.
|
|
38
18
|
*
|
|
39
19
|
* @example
|
|
40
20
|
* ```ts
|
|
@@ -1,66 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Holds the connection
|
|
3
|
-
*
|
|
2
|
+
* Holds the connection ID (the WebSocket's, or the long-poll's after an `enableWSFallback` switch)
|
|
3
|
+
* and lets callers await one that is still being negotiated.
|
|
4
4
|
*
|
|
5
|
-
* The server keys channel watches and presence subscriptions by connection
|
|
6
|
-
* while registering nothing when a request that needs one
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* The server keys channel watches and presence subscriptions by connection ID and answers `200`
|
|
6
|
+
* while registering nothing when a request that needs one carries none (see `requiresConnectionId`
|
|
7
|
+
* in `api-client.ts`), so such requests wait for the handshake. The ID lives only here, so a
|
|
8
|
+
* replaced socket cannot leave a stale copy behind.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* and a copy in `client.wsConnection.state` cannot be invalidated by a socket that has already been
|
|
12
|
-
* replaced; either way requests go out keyed to a connection the server has torn down. The long-poll
|
|
13
|
-
* keeps no copy either: `WSConnection.disconnect()` reads the id before the socket's `disconnect()`
|
|
14
|
-
* drops it, and hands it to the long-poll's close.
|
|
15
|
-
*
|
|
16
|
-
* {@link StableWSConnection} drives the lifecycle: {@link arm} before a socket opens,
|
|
17
|
-
* {@link resolveConnectionId} on the hello frame, {@link invalidate} when it drops or is closed
|
|
18
|
-
* deliberately, {@link rejectConnectionId} when a reconnect gives up. After an `enableWSFallback`
|
|
19
|
-
* switch, `WSConnectionFallback` drives it the same way instead.
|
|
10
|
+
* Driven by {@link StableWSConnection}, or by `WSConnectionFallback` after a fallback switch.
|
|
20
11
|
*/
|
|
21
12
|
export declare class ConnectionIdManager {
|
|
22
13
|
connectionId?: string;
|
|
23
14
|
loadConnectionIdPromise?: Promise<string>;
|
|
24
15
|
private resolve?;
|
|
25
16
|
private reject?;
|
|
26
|
-
/**
|
|
27
|
-
* Arms the deferred a connection attempt will settle, so requests issued while the handshake is in
|
|
28
|
-
* flight have something to await.
|
|
29
|
-
*/
|
|
17
|
+
/** Creates the deferred a connection attempt settles, so mid-handshake requests can await it. */
|
|
30
18
|
arm: () => void;
|
|
31
19
|
/**
|
|
32
|
-
* Publishes the
|
|
20
|
+
* Publishes the ID from the `connection.ok` event and releases anything waiting on one.
|
|
33
21
|
*
|
|
34
|
-
* @param connectionId - The connection
|
|
22
|
+
* @param connectionId - The connection ID carried by the `connection.ok` event.
|
|
35
23
|
*/
|
|
36
24
|
resolveConnectionId: (connectionId: string) => void;
|
|
37
25
|
/**
|
|
38
|
-
*
|
|
26
|
+
* Rejects pending waiters, for a connection attempt that will not be retried.
|
|
39
27
|
*
|
|
40
28
|
* @param reason - The error to reject pending waiters with.
|
|
41
29
|
*/
|
|
42
30
|
rejectConnectionId: (reason: unknown) => void;
|
|
43
|
-
/**
|
|
44
|
-
* Drops the id without failing anything waiting on one, for a socket that died but will be
|
|
45
|
-
* retried. Arming a fresh deferred is what makes those requests wait for the reconnect rather than
|
|
46
|
-
* race ahead with a dead id.
|
|
47
|
-
*/
|
|
31
|
+
/** Drops the ID for a socket that died but will be retried. New requests wait for the reconnect. */
|
|
48
32
|
invalidate: () => void;
|
|
49
|
-
/**
|
|
50
|
-
* Drops the id and fails any pending waiter, for a socket closed deliberately. The id is dead from
|
|
51
|
-
* that moment, and a request keyed by it would register a subscription on a connection that no
|
|
52
|
-
* longer exists.
|
|
53
|
-
*/
|
|
33
|
+
/** Drops the ID and rejects any pending waiter with a "connection closed" error. */
|
|
54
34
|
reset: () => void;
|
|
55
35
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* Throws when there is neither, because no amount of waiting would produce one: no socket is open
|
|
59
|
-
* and none is being opened.
|
|
36
|
+
* Returns the connection ID, waiting for the handshake when one is in flight.
|
|
60
37
|
*
|
|
61
|
-
* @param signal - Abandons the wait
|
|
62
|
-
*
|
|
63
|
-
*
|
|
38
|
+
* @param signal - Abandons the wait. Only the waiting path honours it; an ID already in hand is
|
|
39
|
+
* returned either way.
|
|
40
|
+
* @returns The current connection ID, or a promise for it while the handshake is in flight.
|
|
41
|
+
* @throws When no socket is open or being opened.
|
|
64
42
|
*/
|
|
65
43
|
getConnectionId: (signal?: AbortSignal) => string | Promise<string>;
|
|
66
44
|
private settle;
|