stream-chat-react 13.1.0 → 13.1.1
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/components/Chat/hooks/useChat.js +1 -1
- package/dist/components/Message/MessageIsThreadReplyInChannelButtonIndicator.d.ts +2 -0
- package/dist/components/Message/{MessageThreadReplyInChannelButtonIndicator.js → MessageIsThreadReplyInChannelButtonIndicator.js} +2 -2
- package/dist/components/Message/MessageSimple.js +1 -1
- package/dist/context/ComponentContext.d.ts +2 -1
- package/dist/experimental/index.browser.cjs.map +2 -2
- package/dist/experimental/index.node.cjs.map +2 -2
- package/dist/i18n/TranslationBuilder/TranslationBuilder.d.ts +9 -5
- package/dist/i18n/TranslationBuilder/TranslationBuilder.js +37 -13
- package/dist/i18n/TranslationBuilder/notifications/index.d.ts +1 -0
- package/dist/i18n/TranslationBuilder/notifications/index.js +1 -0
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.browser.cjs +46 -18
- package/dist/index.browser.cjs.map +4 -4
- package/dist/index.node.cjs +47 -18
- package/dist/index.node.cjs.map +4 -4
- package/package.json +1 -1
- package/dist/components/Message/MessageThreadReplyInChannelButtonIndicator.d.ts +0 -2
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { i18n, TFunction } from 'i18next';
|
|
2
|
+
type TopicName = string;
|
|
3
|
+
type TranslatorName = string;
|
|
2
4
|
export type Translator<O extends Record<string, unknown> = Record<string, unknown>> = (params: {
|
|
3
5
|
key: string;
|
|
4
6
|
value: string;
|
|
@@ -22,10 +24,12 @@ export type TranslationTopicConstructor = new (options: TranslationTopicOptions)
|
|
|
22
24
|
export declare class TranslationBuilder {
|
|
23
25
|
private i18next;
|
|
24
26
|
private topics;
|
|
27
|
+
private translatorRegistrationsBuffer;
|
|
25
28
|
constructor(i18next: i18n);
|
|
26
|
-
registerTopic: (name:
|
|
27
|
-
disableTopic: (topicName:
|
|
28
|
-
getTopic: (topicName:
|
|
29
|
-
registerTranslators(topicName:
|
|
30
|
-
removeTranslators(topicName:
|
|
29
|
+
registerTopic: (name: TopicName, Topic: TranslationTopicConstructor) => TranslationTopic<Record<string, unknown>>;
|
|
30
|
+
disableTopic: (topicName: TopicName) => void;
|
|
31
|
+
getTopic: (topicName: TopicName) => TranslationTopic<Record<string, unknown>> | undefined;
|
|
32
|
+
registerTranslators(topicName: TopicName, translators: Record<TranslatorName, Translator>): void;
|
|
33
|
+
removeTranslators(topicName: TopicName, translators: TranslatorName[]): void;
|
|
31
34
|
}
|
|
35
|
+
export {};
|
|
@@ -21,19 +21,32 @@ export class TranslationBuilder {
|
|
|
21
21
|
constructor(i18next) {
|
|
22
22
|
this.i18next = i18next;
|
|
23
23
|
this.topics = new Map();
|
|
24
|
+
// need to keep a registration buffer so that translators can be registered once a topic is registered
|
|
25
|
+
// what does not happen when Streami18n is instantiated but rather once Streami18n.init() is invoked
|
|
26
|
+
this.translatorRegistrationsBuffer = {};
|
|
24
27
|
this.registerTopic = (name, Topic) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
let topic = this.topics.get(name);
|
|
29
|
+
if (!topic) {
|
|
30
|
+
topic = new Topic({ i18next: this.i18next });
|
|
31
|
+
this.topics.set(name, topic);
|
|
32
|
+
this.i18next.use({
|
|
33
|
+
name,
|
|
34
|
+
process: (value, key, options) => {
|
|
35
|
+
const topic = this.topics.get(name);
|
|
36
|
+
if (!topic)
|
|
37
|
+
return value;
|
|
38
|
+
return topic.translate(value, key, options);
|
|
39
|
+
},
|
|
40
|
+
type: 'postProcessor',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const additionalTranslatorsToRegister = this.translatorRegistrationsBuffer[name];
|
|
44
|
+
if (additionalTranslatorsToRegister) {
|
|
45
|
+
Object.entries(additionalTranslatorsToRegister).forEach(([translatorName, translator]) => {
|
|
46
|
+
topic.setTranslator(translatorName, translator);
|
|
47
|
+
});
|
|
48
|
+
delete this.translatorRegistrationsBuffer[name];
|
|
49
|
+
}
|
|
37
50
|
return topic;
|
|
38
51
|
};
|
|
39
52
|
this.disableTopic = (topicName) => {
|
|
@@ -51,14 +64,25 @@ export class TranslationBuilder {
|
|
|
51
64
|
}
|
|
52
65
|
registerTranslators(topicName, translators) {
|
|
53
66
|
const topic = this.getTopic(topicName);
|
|
54
|
-
if (!topic)
|
|
67
|
+
if (!topic) {
|
|
68
|
+
if (!this.translatorRegistrationsBuffer[topicName])
|
|
69
|
+
this.translatorRegistrationsBuffer[topicName] = {};
|
|
70
|
+
Object.entries(translators).forEach(([translatorName, translator]) => {
|
|
71
|
+
this.translatorRegistrationsBuffer[topicName][translatorName] = translator;
|
|
72
|
+
});
|
|
55
73
|
return;
|
|
74
|
+
}
|
|
56
75
|
Object.entries(translators).forEach(([name, translator]) => {
|
|
57
76
|
topic.setTranslator(name, translator);
|
|
58
77
|
});
|
|
59
78
|
}
|
|
60
79
|
removeTranslators(topicName, translators) {
|
|
61
80
|
const topic = this.getTopic(topicName);
|
|
81
|
+
if (this.translatorRegistrationsBuffer[topicName]) {
|
|
82
|
+
translators.forEach((translatorName) => {
|
|
83
|
+
delete this.translatorRegistrationsBuffer[topicName][translatorName];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
62
86
|
if (!topic)
|
|
63
87
|
return;
|
|
64
88
|
translators.forEach((name) => {
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './translations';
|
|
2
2
|
export * from './Streami18n';
|
|
3
|
-
export * from './TranslationBuilder
|
|
3
|
+
export * from './TranslationBuilder';
|
|
4
4
|
export { defaultDateTimeParser, defaultTranslatorFunction, isDate, isDayOrMoment, isLanguageSupported, isNumberOrString, } from './utils';
|
|
5
5
|
export * from './types';
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './translations';
|
|
2
2
|
export * from './Streami18n';
|
|
3
|
-
export * from './TranslationBuilder
|
|
3
|
+
export * from './TranslationBuilder';
|
|
4
4
|
export { defaultDateTimeParser, defaultTranslatorFunction, isDate, isDayOrMoment, isLanguageSupported, isNumberOrString, } from './utils';
|
|
5
5
|
export * from './types';
|
package/dist/index.browser.cjs
CHANGED
|
@@ -18017,6 +18017,7 @@ __export(src_exports, {
|
|
|
18017
18017
|
MicIcon: () => MicIcon,
|
|
18018
18018
|
Modal: () => Modal,
|
|
18019
18019
|
ModalGallery: () => ModalGallery,
|
|
18020
|
+
NotificationTranslationTopic: () => NotificationTranslationTopic,
|
|
18020
18021
|
PauseIcon: () => PauseIcon2,
|
|
18021
18022
|
PinIcon: () => PinIcon,
|
|
18022
18023
|
PinIndicator: () => PinIndicator,
|
|
@@ -44087,18 +44088,33 @@ var TranslationBuilder = class {
|
|
|
44087
44088
|
constructor(i18next) {
|
|
44088
44089
|
this.i18next = i18next;
|
|
44089
44090
|
this.topics = /* @__PURE__ */ new Map();
|
|
44091
|
+
// need to keep a registration buffer so that translators can be registered once a topic is registered
|
|
44092
|
+
// what does not happen when Streami18n is instantiated but rather once Streami18n.init() is invoked
|
|
44093
|
+
this.translatorRegistrationsBuffer = {};
|
|
44090
44094
|
this.registerTopic = (name2, Topic) => {
|
|
44091
|
-
|
|
44092
|
-
|
|
44093
|
-
|
|
44094
|
-
|
|
44095
|
-
|
|
44096
|
-
|
|
44097
|
-
|
|
44098
|
-
|
|
44099
|
-
|
|
44100
|
-
|
|
44101
|
-
|
|
44095
|
+
let topic = this.topics.get(name2);
|
|
44096
|
+
if (!topic) {
|
|
44097
|
+
topic = new Topic({ i18next: this.i18next });
|
|
44098
|
+
this.topics.set(name2, topic);
|
|
44099
|
+
this.i18next.use({
|
|
44100
|
+
name: name2,
|
|
44101
|
+
process: (value, key, options) => {
|
|
44102
|
+
const topic2 = this.topics.get(name2);
|
|
44103
|
+
if (!topic2) return value;
|
|
44104
|
+
return topic2.translate(value, key, options);
|
|
44105
|
+
},
|
|
44106
|
+
type: "postProcessor"
|
|
44107
|
+
});
|
|
44108
|
+
}
|
|
44109
|
+
const additionalTranslatorsToRegister = this.translatorRegistrationsBuffer[name2];
|
|
44110
|
+
if (additionalTranslatorsToRegister) {
|
|
44111
|
+
Object.entries(additionalTranslatorsToRegister).forEach(
|
|
44112
|
+
([translatorName, translator]) => {
|
|
44113
|
+
topic.setTranslator(translatorName, translator);
|
|
44114
|
+
}
|
|
44115
|
+
);
|
|
44116
|
+
delete this.translatorRegistrationsBuffer[name2];
|
|
44117
|
+
}
|
|
44102
44118
|
return topic;
|
|
44103
44119
|
};
|
|
44104
44120
|
this.disableTopic = (topicName) => {
|
|
@@ -44115,13 +44131,25 @@ var TranslationBuilder = class {
|
|
|
44115
44131
|
}
|
|
44116
44132
|
registerTranslators(topicName, translators) {
|
|
44117
44133
|
const topic = this.getTopic(topicName);
|
|
44118
|
-
if (!topic)
|
|
44134
|
+
if (!topic) {
|
|
44135
|
+
if (!this.translatorRegistrationsBuffer[topicName])
|
|
44136
|
+
this.translatorRegistrationsBuffer[topicName] = {};
|
|
44137
|
+
Object.entries(translators).forEach(([translatorName, translator]) => {
|
|
44138
|
+
this.translatorRegistrationsBuffer[topicName][translatorName] = translator;
|
|
44139
|
+
});
|
|
44140
|
+
return;
|
|
44141
|
+
}
|
|
44119
44142
|
Object.entries(translators).forEach(([name2, translator]) => {
|
|
44120
44143
|
topic.setTranslator(name2, translator);
|
|
44121
44144
|
});
|
|
44122
44145
|
}
|
|
44123
44146
|
removeTranslators(topicName, translators) {
|
|
44124
44147
|
const topic = this.getTopic(topicName);
|
|
44148
|
+
if (this.translatorRegistrationsBuffer[topicName]) {
|
|
44149
|
+
translators.forEach((translatorName) => {
|
|
44150
|
+
delete this.translatorRegistrationsBuffer[topicName][translatorName];
|
|
44151
|
+
});
|
|
44152
|
+
}
|
|
44125
44153
|
if (!topic) return;
|
|
44126
44154
|
translators.forEach((name2) => {
|
|
44127
44155
|
topic.removeTranslator(name2);
|
|
@@ -46738,10 +46766,10 @@ function VirtualizedMessageList(props) {
|
|
|
46738
46766
|
);
|
|
46739
46767
|
}
|
|
46740
46768
|
|
|
46741
|
-
// src/components/Message/
|
|
46769
|
+
// src/components/Message/MessageIsThreadReplyInChannelButtonIndicator.tsx
|
|
46742
46770
|
var import_react199 = __toESM(require("react"));
|
|
46743
46771
|
var import_stream_chat6 = require("stream-chat");
|
|
46744
|
-
var
|
|
46772
|
+
var MessageIsThreadReplyInChannelButtonIndicator = () => {
|
|
46745
46773
|
const { client } = useChatContext();
|
|
46746
46774
|
const { t } = useTranslationContext();
|
|
46747
46775
|
const { channel } = useChannelStateContext();
|
|
@@ -46762,7 +46790,7 @@ var MessageThreadReplyInChannelButtonIndicator = () => {
|
|
|
46762
46790
|
},
|
|
46763
46791
|
origin: {
|
|
46764
46792
|
context: { threadReply: message },
|
|
46765
|
-
emitter: "
|
|
46793
|
+
emitter: "MessageIsThreadReplyInChannelButtonIndicator"
|
|
46766
46794
|
}
|
|
46767
46795
|
});
|
|
46768
46796
|
});
|
|
@@ -47262,7 +47290,7 @@ var MessageSimpleWithContext = (props) => {
|
|
|
47262
47290
|
MessageBlocked: MessageBlocked2 = MessageBlocked,
|
|
47263
47291
|
MessageBouncePrompt: MessageBouncePrompt2 = MessageBouncePrompt,
|
|
47264
47292
|
MessageDeleted: MessageDeleted2 = MessageDeleted,
|
|
47265
|
-
MessageIsThreadReplyInChannelButtonIndicator =
|
|
47293
|
+
MessageIsThreadReplyInChannelButtonIndicator: MessageIsThreadReplyInChannelButtonIndicator2 = MessageIsThreadReplyInChannelButtonIndicator,
|
|
47266
47294
|
MessageRepliesCountButton: MessageRepliesCountButton2 = MessageRepliesCountButton,
|
|
47267
47295
|
MessageStatus: MessageStatus2 = MessageStatus,
|
|
47268
47296
|
MessageTimestamp: MessageTimestamp2 = MessageTimestamp,
|
|
@@ -47367,7 +47395,7 @@ var MessageSimpleWithContext = (props) => {
|
|
|
47367
47395
|
onClick: handleOpenThread,
|
|
47368
47396
|
reply_count: message.reply_count
|
|
47369
47397
|
}
|
|
47370
|
-
), showIsReplyInChannel && /* @__PURE__ */ import_react207.default.createElement(
|
|
47398
|
+
), showIsReplyInChannel && /* @__PURE__ */ import_react207.default.createElement(MessageIsThreadReplyInChannelButtonIndicator2, null), showMetadata && /* @__PURE__ */ import_react207.default.createElement("div", { className: "str-chat__message-metadata" }, /* @__PURE__ */ import_react207.default.createElement(MessageStatus2, null), !isMyMessage() && !!message.user && /* @__PURE__ */ import_react207.default.createElement("span", { className: "str-chat__message-simple-name" }, message.user.name || message.user.id), /* @__PURE__ */ import_react207.default.createElement(MessageTimestamp2, { customClass: "str-chat__message-simple-timestamp" }), isEdited && /* @__PURE__ */ import_react207.default.createElement("span", { className: "str-chat__mesage-simple-edited" }, t("Edited")), isEdited && /* @__PURE__ */ import_react207.default.createElement(MessageEditedTimestamp, { calendar: true, open: isEditedTimestampOpen }))));
|
|
47371
47399
|
};
|
|
47372
47400
|
var MemoizedMessageSimple = import_react207.default.memo(
|
|
47373
47401
|
MessageSimpleWithContext,
|
|
@@ -52623,7 +52651,7 @@ var useChat = ({
|
|
|
52623
52651
|
};
|
|
52624
52652
|
(0, import_react272.useEffect)(() => {
|
|
52625
52653
|
if (!client) return;
|
|
52626
|
-
const version = "13.1.
|
|
52654
|
+
const version = "13.1.1";
|
|
52627
52655
|
const userAgent = client.getUserAgent();
|
|
52628
52656
|
if (!userAgent.includes("stream-chat-react")) {
|
|
52629
52657
|
client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
|