@helpway/react 0.13.1 → 0.13.3

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/index.js CHANGED
@@ -87,6 +87,227 @@ function isRealtimeEvent(data) {
87
87
  return typeof data === "object" && data !== null && "type" in data && typeof data.type === "string";
88
88
  }
89
89
 
90
+ // ../types/src/doc-nav-icons.ts
91
+ var DOC_NAV_ICONS = [
92
+ {
93
+ name: "globe",
94
+ label: "Globe",
95
+ shapes: [
96
+ { t: "circle", cx: 12, cy: 12, r: 10 },
97
+ { t: "path", d: "M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" }
98
+ ]
99
+ },
100
+ {
101
+ name: "code",
102
+ label: "Code",
103
+ shapes: [
104
+ { t: "polyline", points: "16 18 22 12 16 6" },
105
+ { t: "polyline", points: "8 6 2 12 8 18" }
106
+ ]
107
+ },
108
+ {
109
+ name: "book",
110
+ label: "Book",
111
+ shapes: [
112
+ { t: "path", d: "M4 19.5A2.5 2.5 0 0 1 6.5 17H20" },
113
+ { t: "path", d: "M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z" }
114
+ ]
115
+ },
116
+ {
117
+ name: "rocket",
118
+ label: "Rocket",
119
+ shapes: [
120
+ { t: "path", d: "M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z" },
121
+ { t: "path", d: "m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z" },
122
+ { t: "path", d: "M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5" }
123
+ ]
124
+ },
125
+ {
126
+ name: "terminal",
127
+ label: "Terminal",
128
+ shapes: [
129
+ { t: "polyline", points: "4 17 10 11 4 5" },
130
+ { t: "line", x1: 12, y1: 19, x2: 20, y2: 19 }
131
+ ]
132
+ },
133
+ {
134
+ name: "server",
135
+ label: "Server",
136
+ shapes: [
137
+ { t: "rect", x: 2, y: 2, width: 20, height: 8, rx: 2 },
138
+ { t: "rect", x: 2, y: 14, width: 20, height: 8, rx: 2 },
139
+ { t: "line", x1: 6, y1: 6, x2: 6.01, y2: 6 },
140
+ { t: "line", x1: 6, y1: 18, x2: 6.01, y2: 18 }
141
+ ]
142
+ },
143
+ {
144
+ name: "key",
145
+ label: "Key",
146
+ shapes: [
147
+ { t: "circle", cx: 7.5, cy: 15.5, r: 5.5 },
148
+ { t: "path", d: "m21 2-9.6 9.6M16 6l4 4" }
149
+ ]
150
+ },
151
+ {
152
+ name: "puzzle",
153
+ label: "Puzzle",
154
+ shapes: [
155
+ { t: "path", d: "M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.704.706 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.28 8.687c.24-.24.581-.353.925-.29.493.074.84.504 1.02.968a2.5 2.5 0 1 0 3.237-3.237c-.464-.18-.894-.527-.967-1.02a1.026 1.026 0 0 1 .289-.877l1.568-1.568A2.402 2.402 0 0 1 12 1.998c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.18.464-.527.894-1.02.968z" }
156
+ ]
157
+ },
158
+ {
159
+ name: "file",
160
+ label: "File",
161
+ shapes: [
162
+ { t: "path", d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" },
163
+ { t: "polyline", points: "14 2 14 8 20 8" }
164
+ ]
165
+ },
166
+ {
167
+ name: "settings",
168
+ label: "Settings",
169
+ shapes: [
170
+ { t: "circle", cx: 12, cy: 12, r: 3 },
171
+ { t: "path", d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" }
172
+ ]
173
+ },
174
+ {
175
+ name: "zap",
176
+ label: "Zap",
177
+ shapes: [{ t: "polygon", points: "13 2 3 14 12 14 11 22 21 10 12 10 13 2" }]
178
+ },
179
+ {
180
+ name: "layers",
181
+ label: "Layers",
182
+ shapes: [
183
+ { t: "polygon", points: "12 2 2 7 12 12 22 7 12 2" },
184
+ { t: "polyline", points: "2 17 12 22 22 17" },
185
+ { t: "polyline", points: "2 12 12 17 22 12" }
186
+ ]
187
+ },
188
+ {
189
+ name: "plug",
190
+ label: "Plug",
191
+ shapes: [
192
+ { t: "path", d: "M12 22v-5" },
193
+ { t: "path", d: "M9 8V2M15 8V2" },
194
+ { t: "path", d: "M18 8v5a6 6 0 0 1-12 0V8z" }
195
+ ]
196
+ },
197
+ {
198
+ name: "message",
199
+ label: "Message",
200
+ shapes: [{ t: "path", d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }]
201
+ },
202
+ {
203
+ name: "inbox",
204
+ label: "Inbox",
205
+ shapes: [
206
+ { t: "polyline", points: "22 12 16 12 14 15 10 15 8 12 2 12" },
207
+ { t: "path", d: "M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" }
208
+ ]
209
+ },
210
+ {
211
+ name: "users",
212
+ label: "Users",
213
+ shapes: [
214
+ { t: "path", d: "M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" },
215
+ { t: "circle", cx: 9, cy: 7, r: 4 },
216
+ { t: "path", d: "M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" }
217
+ ]
218
+ },
219
+ {
220
+ name: "mail",
221
+ label: "Mail",
222
+ shapes: [
223
+ { t: "rect", x: 2, y: 4, width: 20, height: 16, rx: 2 },
224
+ { t: "path", d: "m22 7-10 5L2 7" }
225
+ ]
226
+ },
227
+ {
228
+ name: "credit-card",
229
+ label: "Credit card",
230
+ shapes: [
231
+ { t: "rect", x: 1, y: 4, width: 22, height: 16, rx: 2 },
232
+ { t: "line", x1: 1, y1: 10, x2: 23, y2: 10 }
233
+ ]
234
+ },
235
+ {
236
+ name: "sparkles",
237
+ label: "Sparkles",
238
+ shapes: [
239
+ { t: "path", d: "m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z" }
240
+ ]
241
+ },
242
+ {
243
+ name: "bell",
244
+ label: "Bell",
245
+ shapes: [
246
+ { t: "path", d: "M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9" },
247
+ { t: "path", d: "M10.3 21a1.94 1.94 0 0 0 3.4 0" }
248
+ ]
249
+ },
250
+ {
251
+ name: "search",
252
+ label: "Search",
253
+ shapes: [
254
+ { t: "circle", cx: 11, cy: 11, r: 8 },
255
+ { t: "path", d: "m21 21-4.3-4.3" }
256
+ ]
257
+ },
258
+ {
259
+ name: "wrench",
260
+ label: "Wrench",
261
+ shapes: [
262
+ { t: "path", d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" }
263
+ ]
264
+ },
265
+ {
266
+ name: "shield",
267
+ label: "Shield",
268
+ shapes: [
269
+ { t: "path", d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" },
270
+ { t: "path", d: "m9 12 2 2 4-4" }
271
+ ]
272
+ },
273
+ {
274
+ name: "lifebuoy",
275
+ label: "Life buoy",
276
+ shapes: [
277
+ { t: "circle", cx: 12, cy: 12, r: 10 },
278
+ { t: "circle", cx: 12, cy: 12, r: 4 },
279
+ { t: "line", x1: 4.93, y1: 4.93, x2: 9.17, y2: 9.17 },
280
+ { t: "line", x1: 14.83, y1: 14.83, x2: 19.07, y2: 19.07 },
281
+ { t: "line", x1: 14.83, y1: 9.17, x2: 19.07, y2: 4.93 },
282
+ { t: "line", x1: 4.93, y1: 19.07, x2: 9.17, y2: 14.83 }
283
+ ]
284
+ },
285
+ {
286
+ name: "chart",
287
+ label: "Chart",
288
+ shapes: [
289
+ { t: "line", x1: 12, y1: 20, x2: 12, y2: 10 },
290
+ { t: "line", x1: 18, y1: 20, x2: 18, y2: 4 },
291
+ { t: "line", x1: 6, y1: 20, x2: 6, y2: 16 }
292
+ ]
293
+ },
294
+ {
295
+ name: "share",
296
+ label: "Share",
297
+ shapes: [
298
+ { t: "circle", cx: 18, cy: 5, r: 3 },
299
+ { t: "circle", cx: 6, cy: 12, r: 3 },
300
+ { t: "circle", cx: 18, cy: 19, r: 3 },
301
+ { t: "line", x1: 8.59, y1: 13.51, x2: 15.42, y2: 17.49 },
302
+ { t: "line", x1: 15.41, y1: 6.51, x2: 8.59, y2: 10.49 }
303
+ ]
304
+ }
305
+ ];
306
+ var DOC_NAV_ICON_NAMES = DOC_NAV_ICONS.map((i) => i.name);
307
+ var DOC_NAV_ICON_MAP = Object.fromEntries(
308
+ DOC_NAV_ICONS.map((i) => [i.name, i])
309
+ );
310
+
90
311
  // ../widget-core/src/ws.ts
91
312
  var WebSocketManager = class {
92
313
  ws = null;
@@ -127,7 +348,8 @@ var WebSocketManager = class {
127
348
  const params = new URLSearchParams({
128
349
  type: "visitor",
129
350
  id: this.config.visitorId,
130
- websiteId: this.config.websiteId
351
+ websiteId: this.config.websiteId,
352
+ key: this.config.apiKey
131
353
  });
132
354
  const ws = new WebSocket(`${base}/ws?${params}`);
133
355
  ws.onopen = () => {
@@ -335,7 +557,10 @@ function createWidgetStore() {
335
557
  next.set(
336
558
  conversationId,
337
559
  existing.map(
338
- (m) => m.id === oldId ? { ...item, _stableKey: m._stableKey ?? oldId } : m
560
+ (m) => m.id === oldId ? {
561
+ ...item,
562
+ _stableKey: m._stableKey ?? oldId
563
+ } : m
339
564
  )
340
565
  );
341
566
  return { messages: next };
@@ -369,9 +594,21 @@ function createWidgetStore() {
369
594
  merged.push(m);
370
595
  if (isAgentMsg(m) && merged.length === 1) keptAgentWelcome = true;
371
596
  }
597
+ const serverVisitorTs = existingItems.find((x) => x.visitorId)?.createdAt;
598
+ let graftedWelcome = false;
372
599
  for (const m of existingItems) {
373
600
  if (seen.has(m.id)) continue;
374
- if (isAgentMsg(m) && keptAgentWelcome) continue;
601
+ const isWelcomeEcho = isAgentMsg(m) && keptAgentWelcome && !graftedWelcome && (!serverVisitorTs || m.createdAt <= serverVisitorTs);
602
+ if (isWelcomeEcho) {
603
+ const seed = merged[0];
604
+ merged[0] = {
605
+ ...m,
606
+ _stableKey: seed ? seed._stableKey ?? seed.id : m.id
607
+ };
608
+ seen.add(m.id);
609
+ graftedWelcome = true;
610
+ continue;
611
+ }
375
612
  seen.add(m.id);
376
613
  merged.push(m);
377
614
  }
@@ -484,9 +721,14 @@ function createWidgetStore() {
484
721
  const isAgentAuthored = !!event.item.aiAgentId && !event.item.visitorId && !event.item.userId;
485
722
  const existing = state.messages.get(event.conversationId);
486
723
  const seedId = existing?.[0]?.id;
487
- const isSeedWelcomeEcho = isAgentAuthored && !!existing && existing.length === 1 && typeof seedId === "string" && seedId.startsWith("seed-welcome-") && seedId !== event.item.id;
488
- if (isSeedWelcomeEcho) {
489
- break;
724
+ const hasSeedWelcome = typeof seedId === "string" && seedId.startsWith("seed-welcome-");
725
+ if (isAgentAuthored && hasSeedWelcome) {
726
+ const firstVisitorTs = existing?.find((m) => m.visitorId)?.createdAt;
727
+ const isWelcomeEcho = !firstVisitorTs || event.item.createdAt <= firstVisitorTs;
728
+ if (isWelcomeEcho) {
729
+ state.replaceMessage(event.conversationId, seedId, event.item);
730
+ break;
731
+ }
490
732
  }
491
733
  state.addMessage(event.conversationId, event.item);
492
734
  }
@@ -1054,7 +1296,8 @@ function SupportProvider({
1054
1296
  const ws2 = new WebSocketManager({
1055
1297
  apiUrl: resolvedApiUrl,
1056
1298
  visitorId: "",
1057
- websiteId: ""
1299
+ websiteId: "",
1300
+ apiKey
1058
1301
  });
1059
1302
  const identify2 = async (data) => {
1060
1303
  try {
@@ -4954,6 +5197,7 @@ function DefaultWidget({ hideLauncher = false } = {}) {
4954
5197
  onSelectEntry: (slug) => {
4955
5198
  setContentDetailSlug(slug);
4956
5199
  setSubView("content-detail");
5200
+ markEntrySeen(slug);
4957
5201
  },
4958
5202
  onSelectCategory: (cat) => {
4959
5203
  setContentCategoryName(cat.title);