@botonic/webchat-core 2.23.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/CHANGELOG.md +247 -0
- package/PR-LOCALE-SUPPORT.md +156 -0
- package/README.md +11 -0
- package/package.json +29 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +15 -0
- package/src/index.js.map +1 -0
- package/src/lib/controllers/index.d.ts +2 -0
- package/src/lib/controllers/index.js +3 -0
- package/src/lib/controllers/index.js.map +1 -0
- package/src/lib/controllers/public.d.ts +383 -0
- package/src/lib/controllers/public.js +194 -0
- package/src/lib/controllers/public.js.map +1 -0
- package/src/lib/controllers/webchat.d.ts +414 -0
- package/src/lib/controllers/webchat.js +255 -0
- package/src/lib/controllers/webchat.js.map +1 -0
- package/src/lib/domain/index.d.ts +50 -0
- package/src/lib/domain/index.js +11 -0
- package/src/lib/domain/index.js.map +1 -0
- package/src/lib/infra/clients/hubtype-api.d.ts +53 -0
- package/src/lib/infra/clients/hubtype-api.js +189 -0
- package/src/lib/infra/clients/hubtype-api.js.map +1 -0
- package/src/lib/infra/clients/index.d.ts +3 -0
- package/src/lib/infra/clients/index.js +4 -0
- package/src/lib/infra/clients/index.js.map +1 -0
- package/src/lib/infra/clients/realtime.d.ts +92 -0
- package/src/lib/infra/clients/realtime.js +277 -0
- package/src/lib/infra/clients/realtime.js.map +1 -0
- package/src/lib/infra/clients/types.d.ts +21 -0
- package/src/lib/infra/clients/types.js +2 -0
- package/src/lib/infra/clients/types.js.map +1 -0
- package/src/lib/infra/repositories/index.d.ts +1 -0
- package/src/lib/infra/repositories/index.js +2 -0
- package/src/lib/infra/repositories/index.js.map +1 -0
- package/src/lib/infra/repositories/storage/base-storage.d.ts +23 -0
- package/src/lib/infra/repositories/storage/base-storage.js +102 -0
- package/src/lib/infra/repositories/storage/base-storage.js.map +1 -0
- package/src/lib/infra/repositories/storage/browser-storage.d.ts +9 -0
- package/src/lib/infra/repositories/storage/browser-storage.js +46 -0
- package/src/lib/infra/repositories/storage/browser-storage.js.map +1 -0
- package/src/lib/infra/repositories/storage/factory.d.ts +2 -0
- package/src/lib/infra/repositories/storage/factory.js +20 -0
- package/src/lib/infra/repositories/storage/factory.js.map +1 -0
- package/src/lib/infra/repositories/storage/in-memory.d.ts +9 -0
- package/src/lib/infra/repositories/storage/in-memory.js +21 -0
- package/src/lib/infra/repositories/storage/in-memory.js.map +1 -0
- package/src/lib/infra/repositories/storage/index.d.ts +7 -0
- package/src/lib/infra/repositories/storage/index.js +7 -0
- package/src/lib/infra/repositories/storage/index.js.map +1 -0
- package/src/lib/infra/repositories/storage/local-storage.d.ts +4 -0
- package/src/lib/infra/repositories/storage/local-storage.js +7 -0
- package/src/lib/infra/repositories/storage/local-storage.js.map +1 -0
- package/src/lib/infra/repositories/storage/session-storage.d.ts +4 -0
- package/src/lib/infra/repositories/storage/session-storage.js +7 -0
- package/src/lib/infra/repositories/storage/session-storage.js.map +1 -0
- package/src/lib/infra/repositories/storage/types.d.ts +30 -0
- package/src/lib/infra/repositories/storage/types.js +2 -0
- package/src/lib/infra/repositories/storage/types.js.map +1 -0
- package/src/lib/machines/message.d.ts +200 -0
- package/src/lib/machines/message.js +210 -0
- package/src/lib/machines/message.js.map +1 -0
- package/src/lib/machines/overlay.d.ts +299 -0
- package/src/lib/machines/overlay.js +217 -0
- package/src/lib/machines/overlay.js.map +1 -0
- package/src/lib/machines/webchat.d.ts +641 -0
- package/src/lib/machines/webchat.js +768 -0
- package/src/lib/machines/webchat.js.map +1 -0
- package/src/lib/services/webchat-service.d.ts +125 -0
- package/src/lib/services/webchat-service.js +339 -0
- package/src/lib/services/webchat-service.js.map +1 -0
- package/src/lib/utils/locale-detection.d.ts +2 -0
- package/src/lib/utils/locale-detection.js +20 -0
- package/src/lib/utils/locale-detection.js.map +1 -0
- package/src/lib/utils/timezone-to-country.d.ts +1 -0
- package/src/lib/utils/timezone-to-country.js +105 -0
- package/src/lib/utils/timezone-to-country.js.map +1 -0
- package/src/lib/webview/constants.d.ts +10 -0
- package/src/lib/webview/constants.js +10 -0
- package/src/lib/webview/constants.js.map +1 -0
- package/src/lib/webview/index.d.ts +3 -0
- package/src/lib/webview/index.js +4 -0
- package/src/lib/webview/index.js.map +1 -0
- package/src/lib/webview/types.d.ts +35 -0
- package/src/lib/webview/types.js +16 -0
- package/src/lib/webview/types.js.map +1 -0
- package/src/lib/webview/utils.d.ts +9 -0
- package/src/lib/webview/utils.js +33 -0
- package/src/lib/webview/utils.js.map +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
## 2.23.0 (2026-03-23)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 2.22.1 (2026-03-19)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
9
|
+
## 2.22.0 (2026-03-16)
|
|
10
|
+
|
|
11
|
+
### 🚀 Features
|
|
12
|
+
|
|
13
|
+
- webchat to retrieve pusher config from backend ([#742](https://github.com/metis-ai/hubtype-product/pull/742))
|
|
14
|
+
|
|
15
|
+
### ❤️ Thank You
|
|
16
|
+
|
|
17
|
+
- Marc Rabat @vanbasten17
|
|
18
|
+
|
|
19
|
+
## 2.21.0 (2026-03-16)
|
|
20
|
+
|
|
21
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
22
|
+
|
|
23
|
+
## 2.20.0 (2026-03-13)
|
|
24
|
+
|
|
25
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
26
|
+
|
|
27
|
+
## 2.19.0 (2026-03-12)
|
|
28
|
+
|
|
29
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
30
|
+
|
|
31
|
+
## 2.18.0 (2026-03-04)
|
|
32
|
+
|
|
33
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
34
|
+
|
|
35
|
+
## 2.17.0 (2026-03-02)
|
|
36
|
+
|
|
37
|
+
### 🚀 Features
|
|
38
|
+
|
|
39
|
+
- botonic working with v2 input format ([#660](https://github.com/metis-ai/hubtype-product/pull/660))
|
|
40
|
+
|
|
41
|
+
### ❤️ Thank You
|
|
42
|
+
|
|
43
|
+
- Marc Rabat @vanbasten17
|
|
44
|
+
|
|
45
|
+
## 2.16.0 (2026-02-23)
|
|
46
|
+
|
|
47
|
+
### 🚀 Features
|
|
48
|
+
|
|
49
|
+
- **webchat:** lazy loading trigger with optimized bundle splitting ([#614](https://github.com/metis-ai/hubtype-product/pull/614))
|
|
50
|
+
|
|
51
|
+
### 🩹 Fixes
|
|
52
|
+
|
|
53
|
+
- update webhook urls after backend changes ([#674](https://github.com/metis-ai/hubtype-product/pull/674))
|
|
54
|
+
|
|
55
|
+
### ❤️ Thank You
|
|
56
|
+
|
|
57
|
+
- David Hidalgo @Davidhidalgo
|
|
58
|
+
- Marc Rabat @vanbasten17
|
|
59
|
+
|
|
60
|
+
## 2.15.0 (2026-02-13)
|
|
61
|
+
|
|
62
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
63
|
+
|
|
64
|
+
## 2.14.0 (2026-02-05)
|
|
65
|
+
|
|
66
|
+
### 🩹 Fixes
|
|
67
|
+
|
|
68
|
+
- **botonic:** align tsconfig outDir with Nx outputPath to fix TS6305 errors ([#594](https://github.com/metis-ai/hubtype-product/pull/594))
|
|
69
|
+
|
|
70
|
+
### ❤️ Thank You
|
|
71
|
+
|
|
72
|
+
- Marc Rabat @vanbasten17
|
|
73
|
+
|
|
74
|
+
## 2.13.4 (2026-02-02)
|
|
75
|
+
|
|
76
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
77
|
+
|
|
78
|
+
## 2.13.3 (2026-01-30)
|
|
79
|
+
|
|
80
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
81
|
+
|
|
82
|
+
## 2.13.2 (2026-01-30)
|
|
83
|
+
|
|
84
|
+
### 🩹 Fixes
|
|
85
|
+
|
|
86
|
+
- broken styles after publishing packages and use of them along with generator ([#571](https://github.com/metis-ai/hubtype-product/pull/571))
|
|
87
|
+
|
|
88
|
+
### ❤️ Thank You
|
|
89
|
+
|
|
90
|
+
- Marc Rabat @vanbasten17
|
|
91
|
+
|
|
92
|
+
## 2.13.1 (2026-01-30)
|
|
93
|
+
|
|
94
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
95
|
+
|
|
96
|
+
## 2.13.0 (2026-01-29)
|
|
97
|
+
|
|
98
|
+
### 🚀 Features
|
|
99
|
+
|
|
100
|
+
- add generic overlay system for webviews and cover components ([#547](https://github.com/metis-ai/hubtype-product/pull/547))
|
|
101
|
+
|
|
102
|
+
### ❤️ Thank You
|
|
103
|
+
|
|
104
|
+
- Marc Rabat @vanbasten17
|
|
105
|
+
|
|
106
|
+
## 2.12.0 (2026-01-28)
|
|
107
|
+
|
|
108
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
109
|
+
|
|
110
|
+
## 2.11.5 (2026-01-28)
|
|
111
|
+
|
|
112
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
113
|
+
|
|
114
|
+
## 2.11.4 (2026-01-28)
|
|
115
|
+
|
|
116
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
117
|
+
|
|
118
|
+
## 2.11.3 (2026-01-28)
|
|
119
|
+
|
|
120
|
+
### 🩹 Fixes
|
|
121
|
+
|
|
122
|
+
- update entrypoints to use .js and .d.ts extensions for module and types ([#552](https://github.com/metis-ai/hubtype-product/pull/552))
|
|
123
|
+
|
|
124
|
+
### ❤️ Thank You
|
|
125
|
+
|
|
126
|
+
- David Hidalgo @Davidhidalgo
|
|
127
|
+
|
|
128
|
+
## 2.11.2 (2026-01-21)
|
|
129
|
+
|
|
130
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
131
|
+
|
|
132
|
+
## 2.11.1 (2026-01-21)
|
|
133
|
+
|
|
134
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
135
|
+
|
|
136
|
+
## 2.11.0 (2026-01-21)
|
|
137
|
+
|
|
138
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
139
|
+
|
|
140
|
+
## 2.10.1 (2026-01-19)
|
|
141
|
+
|
|
142
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
143
|
+
|
|
144
|
+
## 2.10.0 (2026-01-18)
|
|
145
|
+
|
|
146
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
147
|
+
|
|
148
|
+
## 2.9.1 (2026-01-17)
|
|
149
|
+
|
|
150
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
151
|
+
|
|
152
|
+
## 2.9.0 (2026-01-17)
|
|
153
|
+
|
|
154
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
155
|
+
|
|
156
|
+
## 2.8.1 (2026-01-16)
|
|
157
|
+
|
|
158
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
159
|
+
|
|
160
|
+
## 2.8.0 (2026-01-16)
|
|
161
|
+
|
|
162
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
163
|
+
|
|
164
|
+
## 2.7.1 (2026-01-16)
|
|
165
|
+
|
|
166
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
167
|
+
|
|
168
|
+
## 2.7.0 (2026-01-15)
|
|
169
|
+
|
|
170
|
+
### 🚀 Features
|
|
171
|
+
|
|
172
|
+
- webchat data persistence to support local, session and inMemory storages ([#506](https://github.com/metis-ai/hubtype-product/pull/506))
|
|
173
|
+
|
|
174
|
+
### ❤️ Thank You
|
|
175
|
+
|
|
176
|
+
- Marc Rabat @vanbasten17
|
|
177
|
+
|
|
178
|
+
## 2.6.0 (2025-12-09)
|
|
179
|
+
|
|
180
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
181
|
+
|
|
182
|
+
## 2.5.0 (2025-12-09)
|
|
183
|
+
|
|
184
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
185
|
+
|
|
186
|
+
## 2.4.1 (2025-12-08)
|
|
187
|
+
|
|
188
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
189
|
+
|
|
190
|
+
## 2.4.0 (2025-12-05)
|
|
191
|
+
|
|
192
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
193
|
+
|
|
194
|
+
## 2.3.3 (2025-12-04)
|
|
195
|
+
|
|
196
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
197
|
+
|
|
198
|
+
## 2.3.2 (2025-12-04)
|
|
199
|
+
|
|
200
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
201
|
+
|
|
202
|
+
## 2.3.1 (2025-12-04)
|
|
203
|
+
|
|
204
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
205
|
+
|
|
206
|
+
## 2.3.0 (2025-12-04)
|
|
207
|
+
|
|
208
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
209
|
+
|
|
210
|
+
## 2.2.1 (2025-12-04)
|
|
211
|
+
|
|
212
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
213
|
+
|
|
214
|
+
## 2.2.0 (2025-12-04)
|
|
215
|
+
|
|
216
|
+
### 🚀 Features
|
|
217
|
+
|
|
218
|
+
- receiving unsent messages through pusher auth ([#453](https://github.com/metis-ai/hubtype-product/pull/453))
|
|
219
|
+
- add Botonic Pusher configuration to environment files and enhance webchat rendering options ([#444](https://github.com/metis-ai/hubtype-product/pull/444))
|
|
220
|
+
- implement locale detection and user data handling in webchat, refactor user-related methods for consistency #BLT-2045 ([#435](https://github.com/metis-ai/hubtype-product/pull/435))
|
|
221
|
+
- fine tuning botonic release #BLT-2010 ([#428](https://github.com/metis-ai/hubtype-product/pull/428))
|
|
222
|
+
|
|
223
|
+
### 🩹 Fixes
|
|
224
|
+
|
|
225
|
+
- update user actions in WebchatMachine to include saveUser ([#451](https://github.com/metis-ai/hubtype-product/pull/451))
|
|
226
|
+
- pass botonic headers to webchat auth to avoid deduplicated chats ([#447](https://github.com/metis-ai/hubtype-product/pull/447))
|
|
227
|
+
|
|
228
|
+
### ❤️ Thank You
|
|
229
|
+
|
|
230
|
+
- David Hidalgo @Davidhidalgo
|
|
231
|
+
- Marc Rabat @vanbasten17
|
|
232
|
+
|
|
233
|
+
## 2.1.0 (2025-12-02)
|
|
234
|
+
|
|
235
|
+
### 🚀 Features
|
|
236
|
+
|
|
237
|
+
- add Botonic Pusher configuration to environment files and enhance webchat rendering options ([#444](https://github.com/metis-ai/hubtype-product/pull/444))
|
|
238
|
+
- implement locale detection and user data handling in webchat, refactor user-related methods for consistency #BLT-2045 ([#435](https://github.com/metis-ai/hubtype-product/pull/435))
|
|
239
|
+
- fine tuning botonic release #BLT-2010 ([#428](https://github.com/metis-ai/hubtype-product/pull/428))
|
|
240
|
+
|
|
241
|
+
### ❤️ Thank You
|
|
242
|
+
|
|
243
|
+
- David Hidalgo @Davidhidalgo
|
|
244
|
+
|
|
245
|
+
## 2.0.1-alpha.0 (2025-11-27)
|
|
246
|
+
|
|
247
|
+
This was a version bump only for @botonic/webchat-core to align it with other projects, there were no code changes.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# feat: Add HubtypeUserLocale support with autodetection
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Implements locale, country, and system_locale properties on the webchat user with automatic browser detection when not explicitly provided.
|
|
6
|
+
|
|
7
|
+
## Changes
|
|
8
|
+
|
|
9
|
+
### Type Definitions
|
|
10
|
+
|
|
11
|
+
**`HubtypeUserLocale`** (`@botonic/shared`)
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// Before
|
|
15
|
+
export type HubtypeUserLocale = {
|
|
16
|
+
locale?: string
|
|
17
|
+
country?: string
|
|
18
|
+
system_locale?: string
|
|
19
|
+
extra_data?: Record<string, any>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// After
|
|
23
|
+
export type HubtypeUserLocale = {
|
|
24
|
+
locale?: string
|
|
25
|
+
country?: string
|
|
26
|
+
system_locale?: string
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**`HubtypeUser`** (`@botonic/shared`)
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// Before
|
|
34
|
+
export type HubtypeUser = {
|
|
35
|
+
id: string
|
|
36
|
+
username?: string
|
|
37
|
+
name?: string
|
|
38
|
+
} & HubtypeUserLocale
|
|
39
|
+
|
|
40
|
+
// After
|
|
41
|
+
export type HubtypeUser = {
|
|
42
|
+
id: string
|
|
43
|
+
username?: string
|
|
44
|
+
name?: string
|
|
45
|
+
extra_data?: Record<string, any> // Moved here from HubtypeUserLocale
|
|
46
|
+
} & HubtypeUserLocale
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**`WebchatConfig`** (`@botonic/webchat-core`)
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// Before
|
|
53
|
+
export type WebchatConfig = WebchatConnectionConfig & HubtypeUserLocale
|
|
54
|
+
|
|
55
|
+
// After
|
|
56
|
+
export type WebchatConfig = WebchatConnectionConfig & HubtypeUserLocale & Pick<HubtypeUser, 'extra_data'>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**`WebchatControllerContext`** (`@botonic/webchat-core`)
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
// Before
|
|
63
|
+
export interface WebchatControllerContext {
|
|
64
|
+
config: WebchatConnectionConfig
|
|
65
|
+
// ...
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// After
|
|
69
|
+
export interface WebchatControllerContext {
|
|
70
|
+
config: WebchatConfig // Now includes locale props
|
|
71
|
+
// ...
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**WebchatMachine input type**
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
// Added explicit input type to machine
|
|
79
|
+
types: {} as {
|
|
80
|
+
context: WebchatControllerContext
|
|
81
|
+
events: WebchatControllerEvents
|
|
82
|
+
input: WebchatConfig // NEW: Typed machine input
|
|
83
|
+
emitted: // ...
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Locale Autodetection
|
|
88
|
+
|
|
89
|
+
- Created `libs/botonic/webchat-core/src/lib/utils/locale-detection.ts`
|
|
90
|
+
- `detectUserLocale()` function that autodetects locale props from browser
|
|
91
|
+
- Created `libs/botonic/webchat-core/src/lib/utils/timezone-to-country.ts`
|
|
92
|
+
- Timezone to ISO country code mapping for country detection
|
|
93
|
+
|
|
94
|
+
| Property | Detection Method |
|
|
95
|
+
| --------------- | -------------------------------------------------------------------- |
|
|
96
|
+
| `locale` | `navigator.language` |
|
|
97
|
+
| `country` | `Intl.DateTimeFormat().resolvedOptions().timeZone` → country mapping |
|
|
98
|
+
| `system_locale` | Falls back to detected/provided `locale` |
|
|
99
|
+
|
|
100
|
+
### Webchat Machine
|
|
101
|
+
|
|
102
|
+
- Updated `generateAnonymousUser()` to use `detectUserLocale()` utility
|
|
103
|
+
- Locale props are autodetected if not provided in config
|
|
104
|
+
- `extra_data` can be passed via config
|
|
105
|
+
|
|
106
|
+
### Controller API
|
|
107
|
+
|
|
108
|
+
Added setter methods for runtime locale updates:
|
|
109
|
+
|
|
110
|
+
| Method | Description |
|
|
111
|
+
| ------------------------------- | ---------------------- |
|
|
112
|
+
| `setUserLocale(locale)` | Set user locale |
|
|
113
|
+
| `setUserCountry(country)` | Set user country |
|
|
114
|
+
| `setSystemLocale(systemLocale)` | Set user system locale |
|
|
115
|
+
| `setUserExtraData(extraData)` | Set user extra data |
|
|
116
|
+
|
|
117
|
+
Available on both `WebchatController` and `PublicWebchatController` (window.botonic).
|
|
118
|
+
|
|
119
|
+
### Documentation
|
|
120
|
+
|
|
121
|
+
- Updated `ARCHITECTURE.md` with new utilities and locale autodetection section
|
|
122
|
+
|
|
123
|
+
## Usage
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// Config with explicit locale (optional - will autodetect if not provided)
|
|
127
|
+
const config: WebchatConfig = {
|
|
128
|
+
appId: 'my-app',
|
|
129
|
+
locale: 'es',
|
|
130
|
+
country: 'ES',
|
|
131
|
+
system_locale: 'es-ES',
|
|
132
|
+
extra_data: { customField: 'value' },
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Runtime updates via controller
|
|
136
|
+
controller.setUserLocale('en')
|
|
137
|
+
controller.setUserCountry('US')
|
|
138
|
+
|
|
139
|
+
// Or via window.botonic
|
|
140
|
+
botonic.setUserLocale('en')
|
|
141
|
+
botonic.setUserCountry('US')
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Files Changed
|
|
145
|
+
|
|
146
|
+
- `libs/botonic/shared/src/lib/services/webchat-api.ts`
|
|
147
|
+
- `libs/botonic/webchat-core/src/lib/domain/index.ts`
|
|
148
|
+
- `libs/botonic/webchat-core/src/lib/machines/webchat.ts`
|
|
149
|
+
- `libs/botonic/webchat-core/src/lib/controllers/webchat.ts`
|
|
150
|
+
- `libs/botonic/webchat-core/src/lib/controllers/public.ts`
|
|
151
|
+
- `libs/botonic/webchat-react/ARCHITECTURE.md`
|
|
152
|
+
|
|
153
|
+
## Files Created
|
|
154
|
+
|
|
155
|
+
- `libs/botonic/webchat-core/src/lib/utils/locale-detection.ts`
|
|
156
|
+
- `libs/botonic/webchat-core/src/lib/utils/timezone-to-country.ts`
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# webchat-core
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build webchat-core` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test webchat-core` to execute the unit tests via [Vitest](https://vitest.dev/).
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@botonic/webchat-core",
|
|
3
|
+
"version": "2.23.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
6
|
+
"module": "./src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"import": "./src/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@botonic/shared": "2.23.0",
|
|
15
|
+
"pusher-js": "^8.4.0",
|
|
16
|
+
"tslib": "^2.3.0",
|
|
17
|
+
"uuid": "^11.1.0",
|
|
18
|
+
"xstate": "^5.19.3"
|
|
19
|
+
},
|
|
20
|
+
"references": [
|
|
21
|
+
{
|
|
22
|
+
"path": "../shared/tsconfig.lib.json"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"main": "./src/index.js"
|
|
29
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './lib/domain';
|
|
2
|
+
export * from './lib/machines/message';
|
|
3
|
+
export * from './lib/machines/overlay';
|
|
4
|
+
export * from './lib/machines/webchat';
|
|
5
|
+
export * from './lib/controllers';
|
|
6
|
+
export type { WebchatEmittedEvent } from './lib/controllers/webchat';
|
|
7
|
+
export * from './lib/infra/clients';
|
|
8
|
+
export * from './lib/services/webchat-service';
|
|
9
|
+
export type { ConversationData, StorageConfig, StorageRepository, StorageType, StoredMessage, WebchatHubtypeUser, } from './lib/infra/repositories';
|
|
10
|
+
export { createStorageRepository, InMemoryRepository, LocalStorageRepository, SessionStorageRepository, } from './lib/infra/repositories';
|
|
11
|
+
export * from './lib/webview';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Domain types
|
|
2
|
+
export * from './lib/domain';
|
|
3
|
+
// XState machines (internal)
|
|
4
|
+
export * from './lib/machines/message';
|
|
5
|
+
export * from './lib/machines/overlay';
|
|
6
|
+
export * from './lib/machines/webchat';
|
|
7
|
+
// Webchat Internal and Public controllers
|
|
8
|
+
export * from './lib/controllers';
|
|
9
|
+
// Infrastructure clients
|
|
10
|
+
export * from './lib/infra/clients';
|
|
11
|
+
export * from './lib/services/webchat-service';
|
|
12
|
+
export { createStorageRepository, InMemoryRepository, LocalStorageRepository, SessionStorageRepository, } from './lib/infra/repositories';
|
|
13
|
+
// Webview utilities, constants, and types
|
|
14
|
+
export * from './lib/webview';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/botonic/webchat-core/src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,cAAc,cAAc,CAAA;AAE5B,6BAA6B;AAC7B,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AAEtC,0CAA0C;AAC1C,cAAc,mBAAmB,CAAA;AAKjC,yBAAyB;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAW9C,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,0BAA0B,CAAA;AAEjC,0CAA0C;AAC1C,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/webchat-core/src/lib/controllers/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA"}
|