@gengage/assistant-fe 0.6.49 → 0.7.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.
Files changed (51) hide show
  1. package/dist/chat/api.d.ts +1 -1
  2. package/dist/chat/components/ChatDrawer.d.ts +3 -1
  3. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +1 -1
  4. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +7 -1
  5. package/dist/chat/history-storage.d.ts +36 -4
  6. package/dist/chat/runtime.d.ts +73 -3
  7. package/dist/chat/utils/chat-presentation-debug.d.ts +0 -14
  8. package/dist/chat-runtime.js +1 -1
  9. package/dist/chat.iife.js +72 -72
  10. package/dist/chat.js +1 -1
  11. package/dist/common/connection-warning.d.ts +10 -0
  12. package/dist/common/indexed-db.d.ts +35 -2
  13. package/dist/common/native-webview.d.ts +1 -1
  14. package/dist/common/streaming.d.ts +6 -1
  15. package/dist/common/transport.d.ts +2 -1
  16. package/dist/common/types.d.ts +16 -0
  17. package/dist/{common-nAeMxZrn.js → common-CeuGSwJL.js} +61 -65
  18. package/dist/common.js +30 -30
  19. package/dist/{connection-warning-CDtUX-ol.js → connection-warning-C0e2byq5.js} +31 -25
  20. package/dist/{fastIntent-D45C2rEO.js → fastIntent-BI7l1oDv.js} +2 -2
  21. package/dist/global-error-toast-DvaKvPNA.js +798 -0
  22. package/dist/index.js +29 -29
  23. package/dist/native-webview-CHKpwixw.js +303 -0
  24. package/dist/native.iife.js +30 -30
  25. package/dist/native.js +1 -1
  26. package/dist/{overlay-BPZEIyo_.js → overlay-C3XzoSKd.js} +51 -32
  27. package/dist/overlay.js +6 -6
  28. package/dist/{price-formatter-CHUmYq8I.js → price-formatter-Q3wUKrl1.js} +2 -1
  29. package/dist/qna/runtime.d.ts +1 -0
  30. package/dist/qna-runtime.js +1 -1
  31. package/dist/qna.iife.js +32 -32
  32. package/dist/qna.js +1 -1
  33. package/dist/{request-response-cache-CGxwN0CV.js → request-response-cache-BLQy7llq.js} +478 -454
  34. package/dist/{runtime-CNlICVeC.js → runtime-BC8-a6Ql.js} +231 -219
  35. package/dist/runtime-BSIrZhF2.js +8889 -0
  36. package/dist/{runtime-Cg-6aUps.js → runtime-DiONTdBz.js} +230 -212
  37. package/dist/{simbut-BtaGMLLn.js → simbut-BDbb3nMH.js} +5 -5
  38. package/dist/simbut.iife.js +2 -2
  39. package/dist/simbut.js +1 -1
  40. package/dist/simrel/components/GroupTabs.d.ts +6 -0
  41. package/dist/simrel/runtime.d.ts +8 -0
  42. package/dist/{simrel-iGl2aXiY.js → simrel-CdxDIKu3.js} +15 -15
  43. package/dist/simrel-runtime.js +1 -1
  44. package/dist/simrel.iife.js +22 -22
  45. package/dist/simrel.js +2 -2
  46. package/dist/widget-base-Cvxdrqqt.js +141 -0
  47. package/package.json +1 -1
  48. package/dist/context-UTzCGyR9.js +0 -543
  49. package/dist/native-webview-CYX30O3Q.js +0 -273
  50. package/dist/runtime-COLQGOkl.js +0 -8708
  51. package/dist/widget-base-AuwRxs2X.js +0 -365
@@ -1,273 +0,0 @@
1
- import { i as k } from "./overlay-BPZEIyo_.js";
2
- var _ = [
3
- "gengage:chat:open",
4
- "gengage:chat:close",
5
- "gengage:chat:ready",
6
- "gengage:chat:add-to-cart",
7
- "gengage:qna:action",
8
- "gengage:qna:open-chat",
9
- "gengage:similar:product-click",
10
- "gengage:similar:grouping-click",
11
- "gengage:similar:products-impression",
12
- "gengage:similar:add-to-cart",
13
- "gengage:global:error",
14
- "gengage:context:update"
15
- ], S = 32, E = "#gengage-qna", w = "#gengage-simrel";
16
- function A(n) {
17
- let e = n;
18
- if (typeof n == "string") {
19
- const s = n.trim();
20
- if (s.length === 0) return null;
21
- if (!s.startsWith("{") && !s.startsWith("[")) return { type: s };
22
- try {
23
- e = JSON.parse(s);
24
- } catch {
25
- return null;
26
- }
27
- }
28
- if (!e || typeof e != "object") return null;
29
- const t = e, d = [
30
- t.type,
31
- t.command,
32
- t.action,
33
- t.event
34
- ].find((s) => typeof s == "string" && s.length > 0);
35
- if (!d) return null;
36
- let a = t.payload;
37
- if (a === void 0 && "data" in t && (a = t.data), d === "setSession" && a === void 0) {
38
- const s = {};
39
- typeof t.sessionId == "string" && (s.sessionId = t.sessionId), typeof t.userId == "string" && (s.userId = t.userId), (s.sessionId !== void 0 || s.userId !== void 0) && (a = s);
40
- }
41
- return a === void 0 ? { type: d } : {
42
- type: d,
43
- payload: a
44
- };
45
- }
46
- function L(n) {
47
- if (typeof n == "string" && n.length > 0) return { sku: n };
48
- if (n && typeof n == "object" && "sku" in n) {
49
- const e = n.sku;
50
- if (typeof e == "string" && e.length > 0) {
51
- const t = n.pageType;
52
- return t !== void 0 ? {
53
- sku: e,
54
- pageType: t
55
- } : { sku: e };
56
- }
57
- }
58
- return null;
59
- }
60
- function b(n, e) {
61
- return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 : n.document.querySelector(e) !== null;
62
- }
63
- function T(n, e, t) {
64
- if (e instanceof HTMLElement || b(n, e) || typeof e != "string") return e;
65
- if (e.startsWith("#")) {
66
- const s = e.slice(1);
67
- if (s.length > 0) {
68
- const f = n.document.getElementById(s);
69
- if (f) return f;
70
- const u = n.document.createElement("div");
71
- return u.id = s, n.document.body.appendChild(u), u;
72
- }
73
- }
74
- const d = n.document.getElementById(t);
75
- if (d) return d;
76
- const a = n.document.createElement("div");
77
- return a.id = t, n.document.body.appendChild(a), a;
78
- }
79
- function C(n, e) {
80
- const t = n.webkit?.messageHandlers?.[e];
81
- return t && typeof t.postMessage == "function" ? t.postMessage.bind(t) : null;
82
- }
83
- function y(n, e) {
84
- const t = n[e];
85
- return t && typeof t == "object" && typeof t.postMessage == "function" ? t : null;
86
- }
87
- function O(n = {}) {
88
- const e = n.win ?? window, t = n.iosHandlerName ?? "gengage", d = n.androidInterfaceName ?? "GengageNative", a = n.reactNativeInterfaceName ?? "ReactNativeWebView";
89
- return C(e, t) ? "ios" : y(e, d) ? "android" : y(e, a) ? "react-native" : "browser";
90
- }
91
- function U(n, e = {}) {
92
- const t = e.win ?? window;
93
- if (n.sessionId !== void 0) {
94
- t.__gengageSessionId = n.sessionId, t.gengage || (t.gengage = {}), t.gengage.sessionId = n.sessionId;
95
- try {
96
- t.sessionStorage.setItem("gengage_session_id", n.sessionId);
97
- } catch {
98
- }
99
- }
100
- if (n.userId !== void 0) {
101
- t.gengage || (t.gengage = {});
102
- const d = t.gengage, a = d.session ?? {};
103
- a.userId = n.userId, d.session = a;
104
- }
105
- }
106
- function W(n = {}) {
107
- const e = n.win ?? window, t = e;
108
- if (t.gengageNative) return t.gengageNative;
109
- const d = n.iosHandlerName ?? "gengage", a = n.androidInterfaceName ?? "GengageNative", s = n.reactNativeInterfaceName ?? "ReactNativeWebView", f = n.trackedEvents ?? [..._], u = O({
110
- win: e,
111
- iosHandlerName: d,
112
- androidInterfaceName: a,
113
- reactNativeInterfaceName: s
114
- });
115
- let o = e.gengage?.overlay ?? null;
116
- const g = [], m = (r, i) => {
117
- const l = i === void 0 ? { type: r } : {
118
- type: r,
119
- payload: i
120
- };
121
- if (u === "ios") {
122
- C(e, d)?.(l);
123
- return;
124
- }
125
- if (u === "android") {
126
- y(e, a)?.postMessage(JSON.stringify(l));
127
- return;
128
- }
129
- if (u === "react-native") {
130
- y(e, s)?.postMessage(JSON.stringify(l));
131
- return;
132
- }
133
- }, v = (r) => {
134
- const i = r.detail;
135
- !i || typeof i.namespace != "string" || typeof i.type != "string" || m("bridge_message", {
136
- namespace: i.namespace,
137
- type: i.type,
138
- payload: i.payload
139
- });
140
- };
141
- e.addEventListener("gengage:bridge:message", v);
142
- const q = f.map((r) => {
143
- const i = (l) => {
144
- const c = l.detail;
145
- m("widget_event", {
146
- event: r,
147
- detail: c
148
- });
149
- };
150
- return e.addEventListener(r, i), {
151
- event: r,
152
- handler: i
153
- };
154
- }), p = (r) => {
155
- g.length >= S && g.shift(), g.push(r);
156
- }, M = () => {
157
- if (!o || g.length === 0) return;
158
- const r = g.splice(0, g.length);
159
- for (const i of r) I(i);
160
- }, I = (r) => {
161
- const i = A(r);
162
- if (!i || typeof i.type != "string") {
163
- console.warn("[gengage:native-bridge] Invalid message:", r);
164
- return;
165
- }
166
- const l = i.type, c = i.payload;
167
- switch (l) {
168
- case "openChat":
169
- o ? o.openChat(c && typeof c == "object" ? c : c === "half" || c === "full" ? { state: c } : void 0) : p(i);
170
- return;
171
- case "closeChat":
172
- o ? o.closeChat() : p(i);
173
- return;
174
- case "updateContext":
175
- case "updatePageContext":
176
- case "setPageContext":
177
- o && c && typeof c == "object" ? o.updateContext(c) : o ? console.warn(`[gengage:native-bridge] ${l}: missing payload`) : p(i);
178
- return;
179
- case "updateSku": {
180
- const h = L(c);
181
- if (o && h) {
182
- o.updateSku(h.sku, h.pageType);
183
- return;
184
- }
185
- o ? console.warn("[gengage:native-bridge] updateSku: missing sku") : p(i);
186
- return;
187
- }
188
- case "setSession":
189
- c && typeof c == "object" && U(c, { win: e });
190
- return;
191
- case "destroy":
192
- o?.destroy();
193
- return;
194
- default:
195
- e.postMessage({
196
- gengage: "native",
197
- type: l,
198
- payload: c
199
- }, e.location.origin), n.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", l);
200
- }
201
- }, N = {
202
- env: u,
203
- sendToNative: m,
204
- receive: I,
205
- setController(r) {
206
- o = r, M();
207
- },
208
- destroy() {
209
- e.removeEventListener("gengage:bridge:message", v);
210
- for (const r of q) e.removeEventListener(r.event, r.handler);
211
- g.splice(0, g.length), e.gengageNative === N && delete e.gengageNative;
212
- }
213
- };
214
- return t.gengageNative = N, N;
215
- }
216
- async function V(n) {
217
- const { nativeBridge: e, emitReadyEvent: t = !0, ...d } = n, a = W(e), s = { ...d };
218
- s.onAddToCart || (s.onAddToCart = (g) => {
219
- a.sendToNative("addToCart", {
220
- sku: g.sku,
221
- quantity: g.quantity,
222
- cartCode: g.cartCode
223
- });
224
- }), s.onProductNavigate || (s.onProductNavigate = (g, m, v) => {
225
- a.sendToNative("productNavigate", {
226
- url: g,
227
- sku: m,
228
- sessionId: v
229
- });
230
- });
231
- const f = s.qna?.enabled === !0 || s.qna?.mountTarget !== void 0;
232
- if (s.qna?.enabled !== !1)
233
- if (f) {
234
- const g = T(window, s.qna?.mountTarget ?? E, "gengage-qna");
235
- s.qna = {
236
- ...s.qna,
237
- enabled: !0,
238
- mountTarget: g
239
- };
240
- } else b(window, E) || (s.qna = { enabled: !1 });
241
- const u = s.simrel?.enabled === !0 || s.simrel?.mountTarget !== void 0;
242
- if (s.simrel?.enabled !== !1)
243
- if (u) {
244
- const g = T(window, s.simrel?.mountTarget ?? w, "gengage-simrel");
245
- s.simrel = {
246
- ...s.simrel,
247
- enabled: !0,
248
- mountTarget: g
249
- };
250
- } else b(window, w) || (s.simrel = { enabled: !1 });
251
- const o = await k(s);
252
- return a.setController(o), t && a.sendToNative("ready", {
253
- sessionId: o.session.sessionId,
254
- widgets: {
255
- chat: o.chat !== null,
256
- qna: o.qna !== null,
257
- simrel: o.simrel !== null
258
- }
259
- }), {
260
- controller: o,
261
- bridge: a,
262
- destroy() {
263
- o.destroy(), a.destroy();
264
- }
265
- };
266
- }
267
- export {
268
- V as a,
269
- O as i,
270
- U as n,
271
- W as r,
272
- _ as t
273
- };