stream-chat 10.0.0-rc.8 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/cjs/index.browser.js +22095 -22290
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +22143 -22298
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +22093 -22288
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +216 -135
- package/dist/types/CooldownTimer.d.ts +16 -27
- package/dist/types/EventHandlerPipeline.d.ts +18 -38
- package/dist/types/LiveLocationManager.d.ts +25 -47
- package/dist/types/api-client.d.ts +17 -5
- package/dist/types/channel.d.ts +435 -500
- package/dist/types/channel_state.d.ts +72 -112
- package/dist/types/client.d.ts +323 -440
- package/dist/types/client_state.d.ts +1 -3
- package/dist/types/configuration/ConfigController.d.ts +31 -125
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +32 -124
- 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 +64 -79
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +14 -36
- 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 +45 -0
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +84 -0
- package/dist/types/connection/index.d.ts +4 -0
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +82 -0
- package/dist/types/connection/networkConnection/index.d.ts +3 -0
- package/dist/types/connection/networkConnection/reporters.d.ts +20 -0
- package/dist/types/connection/networkConnection/types.d.ts +40 -0
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +137 -0
- package/dist/types/connection/wsConnection/WSConnection.d.ts +105 -0
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +47 -0
- package/dist/types/connection/wsConnection/config.d.ts +31 -0
- package/dist/types/connection/wsConnection/index.d.ts +4 -0
- package/dist/types/connection/wsConnection/types.d.ts +46 -0
- package/dist/types/constants.d.ts +3 -1
- package/dist/types/custom_types.d.ts +0 -2
- package/dist/types/entityStore/EntityStore.d.ts +226 -65
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +19 -33
- package/dist/types/entityStore/index.d.ts +0 -1
- package/dist/types/errors.d.ts +16 -19
- package/dist/types/formatMessageMemo.d.ts +5 -0
- package/dist/types/gen/chat/ChannelApi.d.ts +5 -1
- package/dist/types/gen/chat/ChatApi.d.ts +149 -105
- package/dist/types/gen/models/index.d.ts +2540 -698
- package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +37 -14
- package/dist/types/index.d.ts +10 -5
- package/dist/types/{i18n/languageNames.d.ts → languageNames.d.ts} +9 -24
- package/dist/types/logger.d.ts +1 -3
- package/dist/types/messageComposer/CustomDataManager.d.ts +7 -1
- package/dist/types/messageComposer/LocationComposer.d.ts +8 -2
- package/dist/types/messageComposer/attachmentIdentity.d.ts +24 -0
- package/dist/types/messageComposer/attachmentManager.d.ts +52 -24
- package/dist/types/messageComposer/attachmentUtils.d.ts +23 -0
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
- package/dist/types/messageComposer/configuration/types.d.ts +38 -50
- package/dist/types/messageComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +12 -9
- package/dist/types/messageComposer/messageComposer.d.ts +60 -123
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +10 -1
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +4 -0
- package/dist/types/messageComposer/middleware/messageComposer/commandInjection.d.ts +5 -0
- package/dist/types/messageComposer/middleware/messageComposer/index.d.ts +2 -0
- package/dist/types/messageComposer/middleware/messageComposer/pollOnly.d.ts +6 -0
- package/dist/types/messageComposer/middleware/messageComposer/userDataInjection.d.ts +5 -0
- 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/commandUtils.d.ts +4 -0
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +11 -2
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +20 -19
- 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 +15 -5
- package/dist/types/messageComposer/textComposer.d.ts +14 -7
- package/dist/types/messageComposer/types.d.ts +27 -7
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +27 -80
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +43 -73
- package/dist/types/messageOperations/FailedSendCache.d.ts +29 -0
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +16 -22
- package/dist/types/messageOperations/MessageOperations.d.ts +63 -34
- package/dist/types/messageOperations/applyReactionLocally.d.ts +15 -0
- package/dist/types/messageOperations/createMessageOperations.d.ts +9 -0
- package/dist/types/messageOperations/index.d.ts +6 -4
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +16 -0
- package/dist/types/messageOperations/sendOrdering.d.ts +14 -0
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +20 -0
- package/dist/types/messageOperations/types.d.ts +43 -14
- package/dist/types/middleware.d.ts +10 -0
- package/dist/types/moderation.d.ts +21 -14
- package/dist/types/notifications/NotificationManager.d.ts +10 -23
- package/dist/types/notifications/types.d.ts +21 -57
- package/dist/types/offline-support/offline_support_api.d.ts +150 -528
- package/dist/types/offline-support/offline_sync_manager.d.ts +21 -42
- package/dist/types/offline-support/queueableOperations.d.ts +35 -37
- package/dist/types/offline-support/types.d.ts +40 -185
- package/dist/types/pagination/FilterBuilder.d.ts +1 -18
- 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 +4 -5
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +19 -5
- package/dist/types/pagination/index.d.ts +1 -0
- package/dist/types/pagination/paginators/BasePaginator.d.ts +604 -550
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +123 -106
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +576 -327
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +237 -131
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +15 -26
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +4 -3
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +44 -0
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +5 -8
- package/dist/types/pagination/paginators/index.d.ts +1 -0
- package/dist/types/pagination/sortCompiler.d.ts +11 -22
- package/dist/types/pagination/utility.normalization.d.ts +8 -13
- package/dist/types/pagination/utility.search.d.ts +3 -8
- package/dist/types/poll.d.ts +35 -8
- package/dist/types/poll_manager.d.ts +12 -2
- package/dist/types/poll_optimistic_votes.d.ts +57 -0
- package/dist/types/reminders/Reminder.d.ts +17 -7
- package/dist/types/reminders/ReminderManager.d.ts +13 -25
- package/dist/types/search/BaseSearchSource.d.ts +10 -8
- package/dist/types/search/ChannelSearchSource.d.ts +16 -0
- package/dist/types/search/MessageSearchSource.d.ts +17 -0
- package/dist/types/search/SearchController.d.ts +26 -28
- package/dist/types/search/types.d.ts +6 -10
- package/dist/types/signing.d.ts +12 -3
- package/dist/types/thread.d.ts +67 -129
- package/dist/types/thread_manager.d.ts +95 -66
- package/dist/types/token_manager.d.ts +8 -13
- package/dist/types/types.d.ts +81 -197
- package/dist/types/types.utility.d.ts +3 -3
- package/dist/types/upload-utils.d.ts +5 -10
- package/dist/types/uploadManager.d.ts +31 -11
- package/dist/types/utils/FixedSizeQueueCache.d.ts +8 -11
- package/dist/types/utils/WithSubscriptions.d.ts +6 -16
- package/dist/types/utils/abort.d.ts +17 -0
- package/dist/types/utils/concurrency.d.ts +12 -20
- 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 +45 -0
- package/dist/types/utils.d.ts +74 -93
- package/package.json +14 -40
- package/src/ChannelManager.ts +494 -303
- package/src/CooldownTimer.ts +46 -59
- package/src/EventHandlerPipeline.ts +22 -45
- package/src/LiveLocationManager.ts +99 -91
- package/src/api-client.ts +113 -50
- package/src/campaign.ts +1 -1
- package/src/channel.ts +1098 -1351
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +81 -174
- package/src/client.ts +755 -970
- package/src/client_state.ts +3 -8
- package/src/configuration/ConfigController.ts +42 -158
- package/src/configuration/InstanceConfigurationRegistry.ts +43 -172
- package/src/configuration/index.ts +1 -1
- package/src/configuration/keys.ts +13 -32
- package/src/configuration/shape.ts +169 -59
- package/src/configuration/types.ts +69 -92
- package/src/configuration/utils/applyInstanceConfiguration.ts +22 -54
- 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 +111 -0
- package/src/connection/ConnectionRecoveryManager.ts +257 -0
- package/src/connection/index.ts +4 -0
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +204 -0
- package/src/connection/networkConnection/index.ts +3 -0
- package/src/connection/networkConnection/reporters.ts +58 -0
- package/src/connection/networkConnection/types.ts +45 -0
- package/src/{connection.ts → connection/wsConnection/StableWSConnection.ts} +230 -231
- package/src/connection/wsConnection/WSConnection.ts +270 -0
- package/src/connection/wsConnection/WSConnectionFallback.ts +250 -0
- package/src/connection/wsConnection/config.ts +73 -0
- package/src/connection/wsConnection/index.ts +4 -0
- package/src/connection/wsConnection/types.ts +48 -0
- package/src/constants.ts +7 -5
- package/src/custom_types.ts +0 -1
- package/src/entityStore/EntityStore.ts +415 -79
- package/src/entityStore/StoreBackedItemIndex.ts +37 -41
- package/src/entityStore/index.ts +0 -1
- package/src/errors.ts +39 -20
- package/src/formatMessageMemo.ts +17 -0
- package/src/gen/chat/ChannelApi.ts +122 -36
- package/src/gen/chat/ChatApi.ts +578 -1752
- package/src/gen/models/index.ts +2566 -3440
- package/src/gen/models/timestamp-guard.ts +27 -0
- package/src/gen/moderation/ModerationApi.ts +183 -406
- package/src/index.ts +32 -10
- package/src/languageNames.ts +88 -0
- package/src/logger.ts +1 -3
- package/src/messageComposer/CustomDataManager.ts +19 -6
- package/src/messageComposer/LocationComposer.ts +49 -9
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
- package/src/messageComposer/attachmentIdentity.ts +54 -0
- package/src/messageComposer/attachmentManager.ts +170 -185
- package/src/messageComposer/attachmentUtils.ts +44 -0
- package/src/messageComposer/configuration/configuration.ts +15 -8
- package/src/messageComposer/configuration/types.ts +38 -50
- package/src/messageComposer/fileUtils.ts +1 -1
- package/src/messageComposer/index.ts +1 -0
- package/src/messageComposer/linkPreviewsManager.ts +18 -21
- package/src/messageComposer/messageComposer.ts +234 -179
- package/src/messageComposer/middleware/attachmentManager/postUpload/AttachmentPostUploadMiddlewareExecutor.ts +1 -1
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +46 -33
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +4 -1
- package/src/messageComposer/middleware/attachmentManager/preUpload/blockedUploadNotification.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/MessageComposerMiddlewareExecutor.ts +6 -0
- package/src/messageComposer/middleware/messageComposer/attachments.ts +76 -5
- package/src/messageComposer/middleware/messageComposer/commandInjection.ts +10 -4
- package/src/messageComposer/middleware/messageComposer/customData.ts +17 -5
- package/src/messageComposer/middleware/messageComposer/index.ts +2 -0
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +22 -12
- package/src/messageComposer/middleware/messageComposer/pollOnly.ts +9 -1
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +7 -2
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +12 -12
- 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 +8 -6
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +10 -3
- 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 +21 -9
- package/src/messageComposer/textComposer.ts +37 -57
- package/src/messageComposer/types.ts +39 -11
- package/src/messageDelivery/MessageDeliveryReporter.ts +86 -124
- package/src/messageDelivery/MessageReceiptsTracker.ts +122 -139
- package/src/messageOperations/FailedSendCache.ts +85 -0
- package/src/messageOperations/MessageOperationStatePolicy.ts +124 -116
- package/src/messageOperations/MessageOperations.ts +297 -175
- package/src/{entityStore → messageOperations}/applyReactionLocally.ts +13 -25
- package/src/messageOperations/createMessageOperations.ts +176 -0
- package/src/messageOperations/index.ts +6 -14
- package/src/messageOperations/reflectReactionEvent.ts +43 -0
- package/src/messageOperations/sendOrdering.ts +25 -0
- package/src/messageOperations/settlePendingAttachmentUploads.ts +98 -0
- package/src/messageOperations/types.ts +51 -13
- package/src/middleware.ts +13 -5
- package/src/moderation.ts +25 -21
- package/src/notifications/NotificationManager.ts +19 -28
- package/src/notifications/types.ts +21 -57
- package/src/offline-support/offline_support_api.ts +231 -681
- package/src/offline-support/offline_sync_manager.ts +51 -90
- package/src/offline-support/queueableOperations.ts +98 -73
- package/src/offline-support/types.ts +43 -185
- package/src/pagination/FilterBuilder.ts +1 -22
- package/src/pagination/ItemIndex.ts +4 -12
- package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +17 -62
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +53 -33
- package/src/pagination/filterCompiler.ts +11 -25
- package/src/pagination/index.ts +1 -0
- package/src/pagination/paginators/BasePaginator.ts +1415 -1041
- package/src/pagination/paginators/ChannelPaginator.ts +481 -219
- package/src/pagination/paginators/MessageIntervalPaginator.ts +1362 -775
- package/src/pagination/paginators/MessagePaginator.ts +521 -240
- package/src/pagination/paginators/PinnedMessagePaginator.ts +32 -40
- package/src/pagination/paginators/ReminderPaginator.ts +21 -16
- package/src/pagination/paginators/ThreadPaginator.ts +170 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +18 -15
- package/src/pagination/paginators/index.ts +1 -0
- package/src/pagination/paginators/stateThrottling.ts +5 -10
- package/src/pagination/sortCompiler.ts +23 -50
- package/src/pagination/utility.normalization.ts +17 -24
- package/src/pagination/utility.search.ts +4 -11
- package/src/poll.ts +183 -102
- package/src/poll_manager.ts +24 -22
- package/src/poll_optimistic_votes.ts +335 -0
- package/src/reminders/Reminder.ts +33 -16
- package/src/reminders/ReminderManager.ts +23 -56
- package/src/reminders/ReminderTimer.ts +6 -6
- package/src/search/BaseSearchSource.ts +19 -25
- package/src/search/ChannelSearchSource.ts +43 -1
- package/src/search/MessageSearchSource.ts +77 -13
- package/src/search/SearchController.ts +39 -36
- package/src/search/types.ts +6 -10
- package/src/segment.ts +1 -1
- package/src/signing.ts +23 -3
- package/src/thread.ts +430 -712
- package/src/thread_manager.ts +300 -234
- package/src/token_manager.ts +12 -22
- package/src/types.ts +102 -214
- package/src/types.utility.ts +3 -3
- package/src/upload-utils.ts +5 -10
- package/src/uploadManager.ts +64 -18
- package/src/utils/FixedSizeQueueCache.ts +18 -21
- package/src/utils/WithSubscriptions.ts +6 -16
- package/src/utils/abort.ts +45 -0
- 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 +64 -0
- package/src/utils.ts +227 -174
- package/codegen/i18n/callSites.ts +0 -126
- package/codegen/i18n/generate.ts +0 -226
- package/codegen/i18n/guards.ts +0 -178
- package/codegen/i18n/index.ts +0 -29
- package/codegen/i18n/stringMaps.ts +0 -91
- package/codegen/i18n/types.ts +0 -100
- package/dist/cjs/i18n.browser.js +0 -1131
- package/dist/cjs/i18n.browser.js.map +0 -7
- package/dist/cjs/i18n.node.js +0 -1160
- package/dist/cjs/i18n.node.js.map +0 -7
- package/dist/esm/i18n-codegen.mjs +0 -409
- package/dist/esm/i18n-codegen.mjs.map +0 -7
- package/dist/esm/i18n.mjs +0 -1098
- package/dist/esm/i18n.mjs.map +0 -7
- package/dist/types/ConnectionRecoveryManager.d.ts +0 -156
- package/dist/types/connection.d.ts +0 -139
- package/dist/types/entityStore/applyReactionLocally.d.ts +0 -26
- package/dist/types/gen/model-decoders/decoders.d.ts +0 -3
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +0 -6
- package/dist/types/i18n/Streami18n.d.ts +0 -168
- package/dist/types/i18n/TranslationBuilder.d.ts +0 -70
- package/dist/types/i18n/TranslationStore.d.ts +0 -57
- package/dist/types/i18n/dayjs.d.ts +0 -104
- package/dist/types/i18n/formatters.d.ts +0 -91
- package/dist/types/i18n/index.d.ts +0 -15
- package/dist/types/i18n/translator.d.ts +0 -29
- package/dist/types/i18n/types.d.ts +0 -262
- package/dist/types/i18n-codegen/callSites.d.ts +0 -10
- package/dist/types/i18n-codegen/generate.d.ts +0 -15
- package/dist/types/i18n-codegen/guards.d.ts +0 -61
- package/dist/types/i18n-codegen/index.d.ts +0 -29
- package/dist/types/i18n-codegen/stringMaps.d.ts +0 -14
- package/dist/types/i18n-codegen/types.d.ts +0 -94
- package/dist/types/insights.d.ts +0 -56
- package/dist/types/messageOperations/optimistic.d.ts +0 -118
- package/dist/types/messageOperations/persistence.d.ts +0 -21
- package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
- package/dist/types/store.d.ts +0 -125
- package/src/ConnectionRecoveryManager.ts +0 -293
- package/src/gen/model-decoders/decoders.ts +0 -2710
- package/src/gen/model-decoders/event-decoder-mapping.ts +0 -198
- package/src/i18n/Streami18n.ts +0 -520
- package/src/i18n/TranslationBuilder.ts +0 -176
- package/src/i18n/TranslationStore.ts +0 -96
- package/src/i18n/dayjs.ts +0 -228
- package/src/i18n/formatters.ts +0 -461
- package/src/i18n/index.ts +0 -15
- package/src/i18n/languageNames.ts +0 -103
- package/src/i18n/translator.ts +0 -76
- package/src/i18n/types.ts +0 -375
- package/src/insights.ts +0 -82
- package/src/messageOperations/optimistic.ts +0 -249
- package/src/messageOperations/persistence.ts +0 -40
- package/src/pagination/utility.queryChannel.ts +0 -84
- package/src/store.ts +0 -304
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import type { i18n as I18nInstance, InitOptions } from 'i18next';
|
|
2
|
-
import { StateStore } from '../store';
|
|
3
|
-
import type { DayjsLocaleConfig } from './dayjs';
|
|
4
|
-
import { TranslationBuilder } from './TranslationBuilder';
|
|
5
|
-
import type { TranslationTopicConstructor } from './TranslationBuilder';
|
|
6
|
-
import type { AnyTranslationCatalog, CustomFormatters, DateTimeParserModule, PredefinedFormatters, StreamTFunctionFor, TDateTimeParser, TranslationDictionaryOf } from './types';
|
|
7
|
-
export type Streami18nOptions<C extends AnyTranslationCatalog = AnyTranslationCatalog> = {
|
|
8
|
-
/** A dayjs or moment module. Defaults to dayjs with the required plugins registered. */
|
|
9
|
-
DateTimeParser?: DateTimeParserModule;
|
|
10
|
-
dayjsLocaleConfigForLanguage?: DayjsLocaleConfig;
|
|
11
|
-
debug?: boolean;
|
|
12
|
-
/** Keep dates in English regardless of the active language. */
|
|
13
|
-
disableDateTimeTranslations?: boolean;
|
|
14
|
-
formatters?: Partial<PredefinedFormatters> & CustomFormatters;
|
|
15
|
-
/**
|
|
16
|
-
* Any i18next `InitOptions`. Applied over the SDK's defaults, so it can reach settings the SDK does
|
|
17
|
-
* not surface. `parseMissingKeyHandler` supplied here is guarded the same way as the top-level
|
|
18
|
-
* option.
|
|
19
|
-
*/
|
|
20
|
-
i18nextConfigOverrides?: Partial<InitOptions>;
|
|
21
|
-
language?: string;
|
|
22
|
-
logger?: (message?: string) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Called only for keys that are genuinely missing — one with no inline default and no bundled
|
|
25
|
-
* value. See {@link guardMissingKeyHandler} for why it cannot be passed straight to i18next.
|
|
26
|
-
*/
|
|
27
|
-
parseMissingKeyHandler?: (key: string, defaultValue?: string) => string;
|
|
28
|
-
/**
|
|
29
|
-
* The SDK's bundled translation data: the keys that cannot carry an inline `defaultValue` at their
|
|
30
|
-
* call site.
|
|
31
|
-
*
|
|
32
|
-
* Injected rather than imported because the catalog belongs to the UI SDK, not to core. Layered
|
|
33
|
-
* under **every** language, which is what stops a partial dictionary from knocking out formatter
|
|
34
|
-
* keys.
|
|
35
|
-
*/
|
|
36
|
-
runtimeDefaults?: Record<string, string>;
|
|
37
|
-
/** A valid TZ identifier, e.g. `Europe/Prague`. */
|
|
38
|
-
timezone?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Post-processor topics for copy that cannot be resolved from a key alone — see
|
|
41
|
-
* {@link TranslationBuilder}. The key here must match the post-processor name in the translation
|
|
42
|
-
* value, i.e. `{{ value, topicName }}`.
|
|
43
|
-
*/
|
|
44
|
-
translationBuilderTopics?: Record<string, TranslationTopicConstructor>;
|
|
45
|
-
translationsForLanguage?: TranslationDictionaryOf<C>;
|
|
46
|
-
};
|
|
47
|
-
export type Streami18nState<C extends AnyTranslationCatalog = AnyTranslationCatalog, Bundled extends string = never> = {
|
|
48
|
-
initialized: boolean;
|
|
49
|
-
language: string;
|
|
50
|
-
t: StreamTFunctionFor<C, Bundled>;
|
|
51
|
-
tDateTimeParser: TDateTimeParser;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Wrapper around [i18next](https://www.i18next.com/) for Stream's translations. A UI SDK passes an
|
|
55
|
-
* instance to its `<Chat>` component to control language and copy. Only English ships; every other
|
|
56
|
-
* language comes from the integrator, and a partial dictionary is safe.
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* import 'dayjs/locale/de';
|
|
60
|
-
*
|
|
61
|
-
* const i18n = new Streami18n({ language: 'de' });
|
|
62
|
-
* i18n.registerTranslation('de', de, { calendar: { sameDay: '[heute um] LT', ... } });
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* No dayjs locale file defines `calendar` — that field belongs to the calendar plugin — so a new
|
|
66
|
-
* language needs both the locale import and a `calendar` config, or relative dates render English
|
|
67
|
-
* scaffolding around translated day names.
|
|
68
|
-
*/
|
|
69
|
-
export declare class Streami18n<C extends AnyTranslationCatalog = AnyTranslationCatalog, Bundled extends string = never> {
|
|
70
|
-
readonly i18nInstance: I18nInstance;
|
|
71
|
-
readonly state: StateStore<Streami18nState<C, Bundled>>;
|
|
72
|
-
readonly translationBuilder: TranslationBuilder;
|
|
73
|
-
readonly logger: (message?: string) => void;
|
|
74
|
-
readonly DateTimeParser: DateTimeParserModule;
|
|
75
|
-
readonly formatters: PredefinedFormatters & CustomFormatters;
|
|
76
|
-
readonly timezone?: string;
|
|
77
|
-
private readonly translations;
|
|
78
|
-
/** Applied when the language becomes active, not on registration: `Dayjs.locale()` is global. */
|
|
79
|
-
private readonly dayjsLocales;
|
|
80
|
-
private readonly translationBuilderTopics;
|
|
81
|
-
private readonly disableDateTimeTranslations;
|
|
82
|
-
private readonly i18nextConfig;
|
|
83
|
-
private initPromise?;
|
|
84
|
-
/** Set by {@link overrideTFunction}, so `init()` does not clobber a swapped-in implementation. */
|
|
85
|
-
private tOverridden;
|
|
86
|
-
constructor(options?: Streami18nOptions<C>);
|
|
87
|
-
get t(): StreamTFunctionFor<C, Bundled>;
|
|
88
|
-
get tDateTimeParser(): TDateTimeParser;
|
|
89
|
-
get currentLanguage(): string;
|
|
90
|
-
get initialized(): boolean;
|
|
91
|
-
/** Read inside the constructor, before `state` getters are safe to rely on externally. */
|
|
92
|
-
private get currentLanguageValue();
|
|
93
|
-
/**
|
|
94
|
-
* Initializes i18next. Memoized, so concurrent callers share one initialization.
|
|
95
|
-
*
|
|
96
|
-
* **Rejects on failure**, so handle it. The instance stays usable either way: `initialized` stays
|
|
97
|
-
* false, keeping {@link Streami18n.registerTranslation} and {@link Streami18n.setLanguage} off a
|
|
98
|
-
* dead i18next instance, and `t` keeps returning each call site's inline English.
|
|
99
|
-
*/
|
|
100
|
-
init(): Promise<Streami18nState<C, Bundled>>;
|
|
101
|
-
private runInit;
|
|
102
|
-
/**
|
|
103
|
-
* Re-run on every language change, not just at `init()`: factories destructure the language out of
|
|
104
|
-
* their context, so one built once keeps formatting in the initial language forever. `formatter.add`
|
|
105
|
-
* replaces by name, which is what makes re-registering sufficient.
|
|
106
|
-
*/
|
|
107
|
-
private registerFormatters;
|
|
108
|
-
/**
|
|
109
|
-
* Accessors rather than snapshots, for a formatter that holds the context and reads per call; one
|
|
110
|
-
* that destructures is covered by {@link registerFormatters} re-running instead.
|
|
111
|
-
*
|
|
112
|
-
* The nested arrows are load-bearing: a getter in an object literal binds `this` to the literal.
|
|
113
|
-
*/
|
|
114
|
-
private createFormatterContext;
|
|
115
|
-
/** The store's flat dictionaries in i18next's nested `resources` shape. */
|
|
116
|
-
private i18nextResources;
|
|
117
|
-
/** The only route for a language added after `init()`. */
|
|
118
|
-
private ensureLanguage;
|
|
119
|
-
private addResources;
|
|
120
|
-
registerTranslation(language: string, translation: TranslationDictionaryOf<C>, dayjsLocaleConfig?: DayjsLocaleConfig): void;
|
|
121
|
-
/**
|
|
122
|
-
* Returns nothing: the new `t` is published to {@link Streami18n.state}. Handing one back would offer
|
|
123
|
-
* a value that goes stale on the next language change.
|
|
124
|
-
*/
|
|
125
|
-
setLanguage(language: string): Promise<void>;
|
|
126
|
-
/**
|
|
127
|
-
* Swaps in a different translation implementation, for an app that already has an i18n layer. Safe
|
|
128
|
-
* before `init()`, which will not overwrite it.
|
|
129
|
-
*/
|
|
130
|
-
overrideTFunction(t: StreamTFunctionFor<C, Bundled>): void;
|
|
131
|
-
/**
|
|
132
|
-
* Languages an integrator supplied a dictionary for. Read-only because adding to it would claim a
|
|
133
|
-
* language is registered with no dictionary behind it; use `registerTranslation`.
|
|
134
|
-
*/
|
|
135
|
-
get registeredLanguages(): ReadonlySet<string>;
|
|
136
|
-
/**
|
|
137
|
-
* Warns rather than falling back to `en`: the language renders English copy from the inline defaults
|
|
138
|
-
* while keeping its own date formats, and resetting it would discard the integrator's choice.
|
|
139
|
-
*/
|
|
140
|
-
private validateCurrentLanguage;
|
|
141
|
-
/**
|
|
142
|
-
* Checked against the module that actually formats the dates.
|
|
143
|
-
*
|
|
144
|
-
* A supplied dayjs copy has its own locale registry, so consulting ours would answer for the wrong
|
|
145
|
-
* one. True for a non-dayjs parser, whose registry we cannot inspect.
|
|
146
|
-
*/
|
|
147
|
-
private localeExists;
|
|
148
|
-
/**
|
|
149
|
-
* Registers a locale on the module that formats the dates, not on ours.
|
|
150
|
-
*
|
|
151
|
-
* Only dayjs has a registry we can write to. For a Moment the config cannot be applied at all, so it
|
|
152
|
-
* is reported -- previously it was written to core's own dayjs, where nothing would ever read it.
|
|
153
|
-
*/
|
|
154
|
-
private addOrUpdateLocale;
|
|
155
|
-
/**
|
|
156
|
-
* For formatters, which resolve keys handed to them at runtime -- including their own
|
|
157
|
-
* `relativeTime.*` copy, which no catalog declares.
|
|
158
|
-
*/
|
|
159
|
-
private translate;
|
|
160
|
-
/**
|
|
161
|
-
* Hermes ships a partial ICU: `Intl.PluralRules` silently falls back to root rules (`other` only) for
|
|
162
|
-
* locales it lacks, so a dictionary's `_few` / `_many` never render and nothing errors.
|
|
163
|
-
*
|
|
164
|
-
* Called from `init()` because i18next caches a resolver per language there — the last moment
|
|
165
|
-
* `intl-pluralrules` could still have been loaded in time.
|
|
166
|
-
*/
|
|
167
|
-
private assertPluralRulesCoverage;
|
|
168
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { i18n as I18nInstance } from 'i18next';
|
|
2
|
-
/**
|
|
3
|
-
* An i18next instance, as accepted by {@link TranslationTopic} and exposed as
|
|
4
|
-
* `Streami18n.i18nInstance`.
|
|
5
|
-
*
|
|
6
|
-
* Re-exported because it is part of this module's public surface: a consumer implementing a topic, or
|
|
7
|
-
* mocking one in a test, has to be able to name the type. Without this they would reach past
|
|
8
|
-
* `stream-chat` into `i18next` directly and have to declare it themselves — the same mistake the
|
|
9
|
-
* `moment-timezone` type leak was.
|
|
10
|
-
*/
|
|
11
|
-
export type { I18nInstance };
|
|
12
|
-
import type { LooseTranslateFunction } from './types';
|
|
13
|
-
/**
|
|
14
|
-
* i18next post-processor plumbing, for copy that cannot be resolved from a key alone.
|
|
15
|
-
*
|
|
16
|
-
* The motivating case is a notification: what to render depends on a runtime object, not just the key,
|
|
17
|
-
* so `t('translationBuilderTopic.notification', { notification })` dispatches through a *topic* which
|
|
18
|
-
* picks a *translator* based on that object. This is only the mechanism — the topics and their
|
|
19
|
-
* translators are SDK-specific and stay in the UI SDKs, since they reference SDK key names.
|
|
20
|
-
*
|
|
21
|
-
* A UI SDK may not need this at all: dispatching on the object at the render site instead is perfectly
|
|
22
|
-
* valid, and the React Native SDK does exactly that. The plumbing lives here so either approach is
|
|
23
|
-
* available without a core change.
|
|
24
|
-
*/
|
|
25
|
-
type TopicName = string;
|
|
26
|
-
type TranslatorName = string;
|
|
27
|
-
/**
|
|
28
|
-
* Resolves one case within a topic. Returning `null` means "not mine" and lets the next candidate try.
|
|
29
|
-
*
|
|
30
|
-
* `t` is loose rather than catalog-typed: a translator is handed keys by the post-processor at runtime,
|
|
31
|
-
* so it cannot be checked against a specific catalog.
|
|
32
|
-
*/
|
|
33
|
-
export type Translator<O extends Record<string, unknown> = Record<string, unknown>> = (params: {
|
|
34
|
-
key: string;
|
|
35
|
-
options: O;
|
|
36
|
-
t: LooseTranslateFunction;
|
|
37
|
-
value: string;
|
|
38
|
-
}) => string | null;
|
|
39
|
-
export type TranslationTopicOptions<O extends Record<string, unknown> = Record<string, unknown>> = {
|
|
40
|
-
i18next: I18nInstance;
|
|
41
|
-
translators?: Record<string, Translator<O>>;
|
|
42
|
-
};
|
|
43
|
-
export declare abstract class TranslationTopic<O extends Record<string, unknown> = Record<string, unknown>> {
|
|
44
|
-
protected options: TranslationTopicOptions<O>;
|
|
45
|
-
protected translators: Map<string, Translator<O>>;
|
|
46
|
-
protected i18next: I18nInstance;
|
|
47
|
-
constructor(options: TranslationTopicOptions<O>);
|
|
48
|
-
abstract translate(value: string, key: string, options: O): string;
|
|
49
|
-
setTranslator: (name: string, translator: Translator<O>) => void;
|
|
50
|
-
removeTranslator: (name: string) => void;
|
|
51
|
-
}
|
|
52
|
-
export type TranslationTopicConstructor = new (options: TranslationTopicOptions) => TranslationTopic;
|
|
53
|
-
export declare class TranslationBuilder {
|
|
54
|
-
private i18next;
|
|
55
|
-
private topics;
|
|
56
|
-
/**
|
|
57
|
-
* Translators registered before their topic exists.
|
|
58
|
-
*
|
|
59
|
-
* Topics are only created during `Streami18n.init()`, but an integrator registers translators against
|
|
60
|
-
* the constructed instance — so registrations that arrive first are buffered and flushed when the
|
|
61
|
-
* topic appears, rather than silently dropped.
|
|
62
|
-
*/
|
|
63
|
-
private translatorRegistrationsBuffer;
|
|
64
|
-
constructor(i18next: I18nInstance);
|
|
65
|
-
registerTopic: (name: TopicName, Topic: TranslationTopicConstructor) => TranslationTopic<Record<string, unknown>>;
|
|
66
|
-
disableTopic: (topicName: TopicName) => void;
|
|
67
|
-
getTopic: (topicName: TopicName) => TranslationTopic<Record<string, unknown>> | undefined;
|
|
68
|
-
registerTranslators(topicName: TopicName, translators: Record<TranslatorName, Translator>): void;
|
|
69
|
-
removeTranslators(topicName: TopicName, translators: TranslatorName[]): void;
|
|
70
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The translation dictionaries an instance holds, and the one rule that governs them.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from `Streami18n` because it is a self-contained concern with no dependency on i18next or
|
|
5
|
-
* dayjs: given the SDK's bundled defaults and whatever dictionaries an integrator supplies, produce the
|
|
6
|
-
* dictionary for a language. That makes the layering rule testable on its own rather than only through
|
|
7
|
-
* a fully initialized instance.
|
|
8
|
-
*
|
|
9
|
-
* Deliberately free of i18next concepts — no namespaces, no resource nesting. `Streami18n` adapts these
|
|
10
|
-
* flat dictionaries to i18next's shape, so the rule below stays readable without knowing that library.
|
|
11
|
-
*/
|
|
12
|
-
/** The one language whose dictionary always exists, because the bundled copy is English. */
|
|
13
|
-
export declare const DEFAULT_LANGUAGE = "en";
|
|
14
|
-
export declare class TranslationStore {
|
|
15
|
-
/**
|
|
16
|
-
* The SDK's bundled translation data: the keys that cannot carry an inline `defaultValue` at their
|
|
17
|
-
* call site — formatter expressions, and prose reaching `t()` as a runtime value.
|
|
18
|
-
*/
|
|
19
|
-
private readonly runtimeDefaults;
|
|
20
|
-
private readonly dictionaries;
|
|
21
|
-
private readonly registered;
|
|
22
|
-
constructor(runtimeDefaults?: Record<string, string>);
|
|
23
|
-
/**
|
|
24
|
-
* Languages an integrator actually supplied a dictionary for.
|
|
25
|
-
*
|
|
26
|
-
* Deliberately narrower than {@link TranslationStore.languages}, which also counts every language
|
|
27
|
-
* created just to carry the bundled defaults. Without the distinction there would be no way to warn
|
|
28
|
-
* that the active language has no translations — every language would look registered.
|
|
29
|
-
*/
|
|
30
|
-
get registeredLanguages(): ReadonlySet<string>;
|
|
31
|
-
/** Every language with a dictionary, including those carrying only the bundled defaults. */
|
|
32
|
-
get languages(): string[];
|
|
33
|
-
/** `language -> dictionary`, for a caller that has to hand them all over at once. */
|
|
34
|
-
entries(): Array<[string, Record<string, string>]>;
|
|
35
|
-
isRegistered(language: string): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Guarantees `language` has a dictionary, and returns it.
|
|
38
|
-
*
|
|
39
|
-
* Called for a language nobody registered, so that it still formats dates and renders the SDK's copy
|
|
40
|
-
* in English rather than raw dotted keys.
|
|
41
|
-
*/
|
|
42
|
-
ensure(language: string): Record<string, string>;
|
|
43
|
-
/**
|
|
44
|
-
* Layers a dictionary over what `language` already has, and marks it registered.
|
|
45
|
-
*
|
|
46
|
-
* **Merged, not replaced.** Repeated calls for one language accumulate, and — the reason this class
|
|
47
|
-
* exists — the bundled defaults survive a partial dictionary. A bundled key has no inline
|
|
48
|
-
* `defaultValue` at its call site and `fallbackLng` is false, so a language that loses them renders
|
|
49
|
-
* raw dotted keys and unformatted ISO timestamps. That is guarantee G1 of the i18n suite.
|
|
50
|
-
*/
|
|
51
|
-
register(language: string, dictionary: Record<string, string>): Record<string, string>;
|
|
52
|
-
/**
|
|
53
|
-
* Bundled defaults first, then whatever the language already had, then the incoming dictionary — so
|
|
54
|
-
* an integrator can override a bundled key, and a later registration wins over an earlier one.
|
|
55
|
-
*/
|
|
56
|
-
private merge;
|
|
57
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import Dayjs from 'dayjs';
|
|
2
|
-
import type { DateTimeLike, DateTimeParserModule, TDateTimeParserInput, TDateTimeParserOutput } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* The calendar-plugin config shape. Not part of dayjs's own `ILocale`, so it has to be declared here.
|
|
5
|
-
*
|
|
6
|
-
* Supplying it is how relative wording ("heute um", "ieri alle") gets localized — no dayjs locale file
|
|
7
|
-
* defines `calendar`, which is the single most common surprise when adding a language.
|
|
8
|
-
*/
|
|
9
|
-
export type CalendarFormats = {
|
|
10
|
-
lastDay: string;
|
|
11
|
-
lastWeek: string;
|
|
12
|
-
nextDay: string;
|
|
13
|
-
nextWeek: string;
|
|
14
|
-
sameDay: string;
|
|
15
|
-
sameElse: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* A dayjs locale config, as accepted by `dayjsLocaleConfigForLanguage` and by
|
|
19
|
-
* `registerTranslation`'s third argument.
|
|
20
|
-
*
|
|
21
|
-
* Typing this as a bare `Partial<ILocale>` makes passing a calendar config a TS2345 "no properties in
|
|
22
|
-
* common" error, which is exactly the wording an integrator hits first — hence the explicit
|
|
23
|
-
* `calendar`.
|
|
24
|
-
*/
|
|
25
|
-
export type DayjsLocaleConfig = Partial<ILocale> & {
|
|
26
|
-
calendar?: CalendarFormats;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* The dayjs module surface this file drives: our own `dayjs`, or a module an integrator supplied
|
|
30
|
-
* through `DateTimeParser`. Method shorthand, so a real `typeof dayjs` satisfies it -- as function
|
|
31
|
-
* properties these would be checked contravariantly and rejected.
|
|
32
|
-
*
|
|
33
|
-
* `Ls`, `locale` and `updateLocale` are optional because a module only has them once the plugins are
|
|
34
|
-
* registered, and because a non-dayjs parser (a Moment) has a different shape entirely.
|
|
35
|
-
*/
|
|
36
|
-
type DayjsExtendable = object & {
|
|
37
|
-
extend?(plugin: unknown, option?: unknown): unknown;
|
|
38
|
-
Ls?: Record<string, unknown>;
|
|
39
|
-
locale?(preset: unknown, object?: unknown, isLocal?: boolean): unknown;
|
|
40
|
-
updateLocale?(name: string, config: unknown): unknown;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Registers the dayjs plugins the formatters need, once per module.
|
|
44
|
-
*
|
|
45
|
-
* Takes the module to extend, defaulting to our own `dayjs`. Passing it matters: an integrator
|
|
46
|
-
* supplying `DateTimeParser` may hand over a *different physical copy* of dayjs, and extending ours
|
|
47
|
-
* leaves theirs without the plugins. That failure is silent and total -- `.calendar()` is simply
|
|
48
|
-
* absent, and `format('LT')` returns the literal string `"LT"` because `localizedFormat` never
|
|
49
|
-
* registered the token.
|
|
50
|
-
*
|
|
51
|
-
* Deliberately **not** done at module scope. Module-scope `Dayjs.extend(...)` is a side effect, which
|
|
52
|
-
* would force `stream-chat` to declare `sideEffects` and would make importing this module do work
|
|
53
|
-
* whether or not anything uses it. Calling it from both the constructor and `defaultDateTimeParser`
|
|
54
|
-
* covers the two ways the formatters can be reached, including a standalone `getDateString()` call
|
|
55
|
-
* with no `Streami18n` instance in play.
|
|
56
|
-
*
|
|
57
|
-
* Idempotent twice over: tracked here, and dayjs itself no-ops a repeated `extend` via the plugin's
|
|
58
|
-
* `$i` marker. The module is recorded *after* the extends run, so a throw does not leave it marked as
|
|
59
|
-
* done.
|
|
60
|
-
*
|
|
61
|
-
* `timezone` is included because it depends on `utc` and callers can set `timezone` at any point;
|
|
62
|
-
* registering it lazily on first use would leave the plugin missing for an instance that only sets
|
|
63
|
-
* `timezone` later.
|
|
64
|
-
*/
|
|
65
|
-
export declare const ensureDayjsPlugins: (module?: DayjsExtendable) => void;
|
|
66
|
-
/**
|
|
67
|
-
* The parser used when none is supplied, and by `getDateString()` called outside an instance.
|
|
68
|
-
*
|
|
69
|
-
* Note there is no `import 'dayjs/locale/en'` anywhere: dayjs bundles `en` and has it registered
|
|
70
|
-
* before any import runs (`Object.keys(Dayjs.Ls)` is already `['en']`), so that import — which both UI
|
|
71
|
-
* SDKs carried — was a no-op.
|
|
72
|
-
*/
|
|
73
|
-
export declare const defaultDateTimeParser: (input?: TDateTimeParserInput) => Dayjs.Dayjs;
|
|
74
|
-
/**
|
|
75
|
-
* The dayjs module itself, with plugins registered.
|
|
76
|
-
*
|
|
77
|
-
* `Streami18n.DateTimeParser` has to be the *module*, not a parse function, because
|
|
78
|
-
* `durationFormatter` calls `.duration()` — which lives on the module, not on a parsed instance.
|
|
79
|
-
*/
|
|
80
|
-
export declare const getDefaultDateTimeParserModule: () => DateTimeParserModule;
|
|
81
|
-
/**
|
|
82
|
-
* Registers or updates a dayjs locale without changing the global locale.
|
|
83
|
-
*
|
|
84
|
-
* Takes the module to register on, defaulting to ours. Passing it matters for the same reason
|
|
85
|
-
* {@link ensureDayjsPlugins} takes one: an integrator supplying `DateTimeParser` may hand over a second
|
|
86
|
-
* physical copy of dayjs, and registering on ours would leave the locale absent from the module that
|
|
87
|
-
* actually formats the dates -- so a `calendar` config or a `dayjsLocaleConfigForLanguage` would be
|
|
88
|
-
* silently ignored.
|
|
89
|
-
*/
|
|
90
|
-
export declare const addOrUpdateDayjsLocale: (language: string, config: DayjsLocaleConfig, module?: DayjsExtendable) => void;
|
|
91
|
-
export declare const dayjsLocaleExists: (language: string, module?: DayjsExtendable) => boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Whether a parser is dayjs, as opposed to a Moment the integrator brought.
|
|
94
|
-
*
|
|
95
|
-
* A property check rather than the `.extend !== undefined` both UI SDKs used, which throws on `null`.
|
|
96
|
-
*/
|
|
97
|
-
export declare const isDayjsLike: (parser: unknown) => parser is DateTimeParserModule;
|
|
98
|
-
/** Whether a parser supports `.tz()`, i.e. dayjs with the timezone plugin, or moment-timezone. */
|
|
99
|
-
export declare const supportsTimezone: (parser: unknown) => boolean;
|
|
100
|
-
export declare const isDate: (value: TDateTimeParserOutput) => value is Date;
|
|
101
|
-
export declare const isNumberOrString: (value: TDateTimeParserOutput) => value is number | string;
|
|
102
|
-
/** Whether a parser output is a dayjs or Moment object rather than a raw Date/string/number. */
|
|
103
|
-
export declare const isDayOrMoment: (value: TDateTimeParserOutput) => value is DateTimeLike;
|
|
104
|
-
export {};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { CalendarFormats } from './dayjs';
|
|
2
|
-
import type { LooseTranslateFunction, PredefinedFormatters, TDateTimeParser, TimestampFormatterOptions } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* The `relativeTime.*` keys this module renders, with their English copy.
|
|
5
|
-
*
|
|
6
|
-
* Exported as a catalog fragment because the *call sites* are here, in core, while the *catalog* is
|
|
7
|
-
* generated from each UI SDK's own source. Without this an SDK's codegen cannot see these keys, so they
|
|
8
|
-
* would drop out of its `TranslationCatalog` and an integrator could no longer type them in a
|
|
9
|
-
* dictionary — i.e. could no longer translate relative dates at all. A UI SDK intersects this into its
|
|
10
|
-
* catalog type.
|
|
11
|
-
*
|
|
12
|
-
* Plurals appear as `_one` / `_other` because that is how a dictionary supplies them; English needs no
|
|
13
|
-
* distinction, but a language with different forms does.
|
|
14
|
-
*/
|
|
15
|
-
export declare const RELATIVE_TIME_CATALOG: {
|
|
16
|
-
readonly 'relativeTime.daysAgo_one': "{{ count }}d ago";
|
|
17
|
-
readonly 'relativeTime.daysAgo_other': "{{ count }}d ago";
|
|
18
|
-
readonly 'relativeTime.today': "Today";
|
|
19
|
-
readonly 'relativeTime.weeksAgo_one': "{{ count }}w ago";
|
|
20
|
-
readonly 'relativeTime.weeksAgo_other': "{{ count }}w ago";
|
|
21
|
-
readonly 'relativeTime.yesterday': "Yesterday";
|
|
22
|
-
};
|
|
23
|
-
export type RelativeTimeCatalog = typeof RELATIVE_TIME_CATALOG;
|
|
24
|
-
/** The formatters registered with i18next by default. */
|
|
25
|
-
export declare const predefinedFormatters: PredefinedFormatters;
|
|
26
|
-
export type GetDateStringParams = TimestampFormatterOptions & {
|
|
27
|
-
/** The timestamp to render. */
|
|
28
|
-
messageCreatedAt?: string | Date;
|
|
29
|
-
/** An integrator-supplied override, which wins over everything else. */
|
|
30
|
-
formatDate?: (date: Date) => string;
|
|
31
|
-
/** The key carrying a formatter expression for this timestamp, if there is one. */
|
|
32
|
-
timestampTranslationKey?: string;
|
|
33
|
-
t?: LooseTranslateFunction;
|
|
34
|
-
tDateTimeParser?: TDateTimeParser;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Resolves a timestamp to a display string.
|
|
38
|
-
*
|
|
39
|
-
* Resolution order, and why: an integrator's `formatDate` wins outright; then the translation key, so
|
|
40
|
-
* a language can restyle the timestamp without touching component props; then the parser. Returns
|
|
41
|
-
* `null` rather than a placeholder when there is nothing sensible to render, so callers can omit the
|
|
42
|
-
* element entirely.
|
|
43
|
-
*/
|
|
44
|
-
export declare const getDateString: ({ calendar, calendarFormats, format, formatDate, messageCreatedAt, relativeCompact, relativeCompactMaxDays, relativeCompactMaxWeeks, relativeCompactWeekRounding, t, tDateTimeParser, timestampTranslationKey, }: GetDateStringParams) => string | number | null;
|
|
45
|
-
/**
|
|
46
|
-
* The same resolution as {@link getDateString}, but always spelling the date out in full.
|
|
47
|
-
*
|
|
48
|
-
* A screen reader announcing "14:32" with no date is ambiguous, so the a11y string ignores the compact
|
|
49
|
-
* and calendar options a visual timestamp uses.
|
|
50
|
-
*/
|
|
51
|
-
export declare const getDateStringForA11y: ({ messageCreatedAt, t, tDateTimeParser, timestampTranslationKey, }: Pick<GetDateStringParams, "messageCreatedAt" | "t" | "tDateTimeParser" | "timestampTranslationKey">) => string | number | null;
|
|
52
|
-
/**
|
|
53
|
-
* Calendar wording used by {@link getCalendarDateStringForA11y}, for the one bundled locale.
|
|
54
|
-
*
|
|
55
|
-
* Only English ships. A language an integrator registers supplies its own wording through
|
|
56
|
-
* `dayjsLocaleConfigForLanguage` (or `registerTranslation`'s third argument) — a per-locale block here
|
|
57
|
-
* is useless on its own without the matching `dayjs/locale/xx` beside it.
|
|
58
|
-
*/
|
|
59
|
-
export declare const A11Y_CALENDAR_FORMATS: Record<string, CalendarFormats>;
|
|
60
|
-
export type GetCalendarDateStringForA11yParams = {
|
|
61
|
-
/**
|
|
62
|
-
* Calendar-format overrides applied over the locale defaults and the `sameElse: 'LL'` substitution.
|
|
63
|
-
* Use it where the visible date deliberately diverges — a channel preview shows `sameDay: 'LT'`, the
|
|
64
|
-
* time rather than "Today".
|
|
65
|
-
*/
|
|
66
|
-
calendarFormatOverrides?: Partial<CalendarFormats>;
|
|
67
|
-
/** Calendar wording per language. Defaults to {@link A11Y_CALENDAR_FORMATS}. */
|
|
68
|
-
calendarFormats?: Record<string, CalendarFormats>;
|
|
69
|
-
messageCreatedAt?: string | Date;
|
|
70
|
-
tDateTimeParser?: TDateTimeParser;
|
|
71
|
-
/**
|
|
72
|
-
* The UI language, used to pick calendar wording. Plain `string`: it indexes `calendarFormats`, which
|
|
73
|
-
* an integrator extends for whatever language they registered — not `stream-chat`'s
|
|
74
|
-
* auto-translation `TranslationLanguage` union.
|
|
75
|
-
*/
|
|
76
|
-
userLanguage?: string;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* A TTS-friendly calendar string, preserving relative wording.
|
|
80
|
-
*
|
|
81
|
-
* Distinct from {@link getDateStringForA11y}, which spells the date out in full via `LLLL`. Both exist
|
|
82
|
-
* because the two UI SDKs arrived at different answers and both are defensible: this one keeps
|
|
83
|
-
* "Today"/"Yesterday"/weekday names from the locale's calendar and substitutes `LL` ("April 8, 2026")
|
|
84
|
-
* only into the `sameElse` slot, because iOS VoiceOver reads a numeric date like "04/08/2026"
|
|
85
|
-
* character by character. Do not collapse them into one — that would silently change one SDK's
|
|
86
|
-
* announced labels.
|
|
87
|
-
*
|
|
88
|
-
* Returns `undefined` when there is nothing to announce, including when the parser has no calendar
|
|
89
|
-
* plugin, so the caller omits the label rather than announcing a malformed date.
|
|
90
|
-
*/
|
|
91
|
-
export declare const getCalendarDateStringForA11y: ({ calendarFormatOverrides, calendarFormats, messageCreatedAt, tDateTimeParser, userLanguage, }: GetCalendarDateStringForA11yParams) => string | undefined;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The shared i18n layer, published as `stream-chat/i18n`.
|
|
3
|
-
*
|
|
4
|
-
* Deliberately **not** re-exported from `stream-chat`'s root barrel: this module pulls in `i18next` and
|
|
5
|
-
* `dayjs`, and keeping them out of the root bundle is the entire reason it is a separate entry point.
|
|
6
|
-
* `scripts/bundle.mts` asserts that boundary at build time.
|
|
7
|
-
*/
|
|
8
|
-
export * from './dayjs';
|
|
9
|
-
export * from './formatters';
|
|
10
|
-
export * from './languageNames';
|
|
11
|
-
export * from './Streami18n';
|
|
12
|
-
export * from './TranslationBuilder';
|
|
13
|
-
export * from './TranslationStore';
|
|
14
|
-
export * from './translator';
|
|
15
|
-
export * from './types';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { AnyTranslationCatalog, DynamicTranslationKey, StreamTFunctionFor } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Brands a runtime-resolved string as a translation key.
|
|
4
|
-
*
|
|
5
|
-
* The brand on {@link DynamicTranslationKey} is required, so this is the only way to pass a key the
|
|
6
|
-
* compiler cannot see — which keeps every such escape deliberate and greppable.
|
|
7
|
-
*/
|
|
8
|
-
export declare const asDynamicKey: (key: string) => DynamicTranslationKey;
|
|
9
|
-
/**
|
|
10
|
-
* The `t` in force before i18next has initialized, and the default for a UI SDK's translation context.
|
|
11
|
-
*
|
|
12
|
-
* It has to honour the inline `defaultValue`: every prose call site passes its English copy as the
|
|
13
|
-
* second argument, so echoing the key back would flash raw dotted paths on the first frame — and would
|
|
14
|
-
* render them permanently anywhere a context default is in play (a component used outside the SDK's
|
|
15
|
-
* provider).
|
|
16
|
-
*
|
|
17
|
-
* A ~30-line stand-in for i18next, deliberately: pulling i18next in just to render the first frame
|
|
18
|
-
* would defeat keeping it out of the default path.
|
|
19
|
-
*/
|
|
20
|
-
export declare const createDefaultTranslatorFunction: <C extends AnyTranslationCatalog = AnyTranslationCatalog, Bundled extends string = never>() => StreamTFunctionFor<C, Bundled>;
|
|
21
|
-
/**
|
|
22
|
-
* Wraps an integrator's `parseMissingKeyHandler` so it only sees genuinely missing translations.
|
|
23
|
-
*
|
|
24
|
-
* i18next counts every prose key as missing — they render from the inline `defaultValue`, not from a
|
|
25
|
-
* resource bundle — and lets the handler's return value replace the rendered string. An unguarded
|
|
26
|
-
* handler therefore blanks out most of the UI. A resolved default arrives as the second argument,
|
|
27
|
-
* which is how the two cases are told apart.
|
|
28
|
-
*/
|
|
29
|
-
export declare const guardMissingKeyHandler: (handler: (key: string, defaultValue?: string) => string) => (key: string, defaultValue?: string) => string;
|