@gengage/assistant-fe 0.6.50 → 0.7.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.
Files changed (50) hide show
  1. package/dist/chat/api.d.ts +1 -1
  2. package/dist/chat/components/ChatDrawer.d.ts +4 -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 +2 -2
  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 +56 -56
  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-DJFI5t11.js → common-CW6814pZ.js} +61 -65
  18. package/dist/common.js +30 -30
  19. package/dist/{connection-warning-TXqyeFaf.js → connection-warning-C0e2byq5.js} +31 -25
  20. package/dist/{fastIntent-539wPavr.js → fastIntent-CJGhUTpS.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 +27 -27
  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-DwADBDeB.js → request-response-cache-DItrp4fO.js} +478 -454
  34. package/dist/{runtime-9f9SB4WE.js → runtime-B9m0kyTB.js} +2796 -2697
  35. package/dist/{runtime-Do3qShrH.js → runtime-CZ363BP8.js} +231 -219
  36. package/dist/{runtime-rTw1jMhB.js → runtime-DKkw_dca.js} +230 -212
  37. package/dist/{simbut-DlWvDoPI.js → simbut-D_j8YgHS.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-BFPU2n5p.js → simrel-BkAtQjNa.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-BnUjuCt7.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/widget-base-BwU6SI2o.js +0 -365
package/dist/index.js CHANGED
@@ -1,39 +1,39 @@
1
- import { f as a, g as t, h as r, n as i, p as s, r as n } from "./request-response-cache-DwADBDeB.js";
2
- import { a as c, c as m, i as p, k as g, o as d, s as l, t as f } from "./context-UTzCGyR9.js";
3
- import { d as S, f as U, n as C, p as I, r as R, u as h } from "./widget-base-BwU6SI2o.js";
4
- import { c as E, l as y, n as G, s as T, t as W } from "./runtime-9f9SB4WE.js";
5
- import { a as w, c as N, f as O, i as v, l as _, n as P, o as k, r as L, s as Q } from "./fastIntent-539wPavr.js";
6
- import { t as F } from "./connection-warning-TXqyeFaf.js";
7
- import { a as b, i as x, n as M, r as H, t as K } from "./runtime-rTw1jMhB.js";
8
- import { a as Z, i as j, n as q, r as J, t as X } from "./runtime-Do3qShrH.js";
9
- import { n as $ } from "./simrel-BFPU2n5p.js";
10
- import { n as ae, t as te } from "./simbut-DlWvDoPI.js";
11
- import { i as ie, n as se, r as ne, t as oe } from "./overlay-BPZEIyo_.js";
12
- import { a as me, i as pe, n as ge, r as de } from "./native-webview-CYX30O3Q.js";
13
- import { a as fe, c as ue, i as Se, l as Ue, n as Ce, o as Ie, r as Re, s as he, t as Ae, u as Ee } from "./common-DJFI5t11.js";
1
+ import { f as a, g as t, h as r, n as i, p as s, r as n } from "./request-response-cache-DItrp4fO.js";
2
+ import { I as c, c as m, d as p, f as g, h as d, m as l, o as f, p as S, s as u } from "./global-error-toast-DvaKvPNA.js";
3
+ import { a as I, n as C, o as R, r as h } from "./widget-base-BnUjuCt7.js";
4
+ import { c as E, l as y, n as G, s as T, t as W } from "./runtime-B9m0kyTB.js";
5
+ import { a as w, c as N, f as O, i as v, l as _, n as P, o as L, r as k, s as Q } from "./fastIntent-CJGhUTpS.js";
6
+ import { t as F } from "./connection-warning-C0e2byq5.js";
7
+ import { a as b, i as x, n as M, r as H, t as K } from "./runtime-DKkw_dca.js";
8
+ import { a as Z, i as j, n as q, r as J, t as X } from "./runtime-CZ363BP8.js";
9
+ import { n as $ } from "./simrel-BkAtQjNa.js";
10
+ import { n as ae, t as te } from "./simbut-D_j8YgHS.js";
11
+ import { i as ie, n as se, r as ne, t as oe } from "./overlay-C3XzoSKd.js";
12
+ import { a as me, i as pe, n as ge, r as de } from "./native-webview-CHKpwixw.js";
13
+ import { a as fe, c as Se, i as ue, l as Ue, n as Ie, o as Ce, r as Re, s as he, t as Ae, u as Ee } from "./common-CW6814pZ.js";
14
14
  export {
15
- Ie as AccountRuntimeConfigSchema,
16
- h as BASE_WIDGET_THEME,
15
+ Ce as AccountRuntimeConfigSchema,
16
+ f as BASE_WIDGET_THEME,
17
17
  w as DEFAULT_CUSTOMIZATION_LOCALE,
18
- U as DEFAULT_WIDGET_THEME_TOKENS,
18
+ I as DEFAULT_WIDGET_THEME_TOKENS,
19
19
  C as GENGAGE_BUILD_FLAVOR,
20
- R as GENGAGE_VERSION,
20
+ h as GENGAGE_VERSION,
21
21
  W as GengageChat,
22
22
  K as GengageQNA,
23
23
  te as GengageSimBut,
24
24
  X as GengageSimRel,
25
25
  he as UnknownActionPolicySchema,
26
- L as VoiceInput,
26
+ k as VoiceInput,
27
27
  ge as applyNativeSession,
28
28
  Ae as autoDetectPageContext,
29
- f as bootstrapSession,
29
+ m as bootstrapSession,
30
30
  i as buildChatEndpointUrl,
31
31
  oe as buildOverlayIdempotencyKey,
32
32
  F as configureConnectionWarning,
33
33
  a as consumeStream,
34
- k as createAccountIdentity,
34
+ L as createAccountIdentity,
35
35
  G as createChatWidget,
36
- ue as createDefaultAccountRuntimeConfig,
36
+ Se as createDefaultAccountRuntimeConfig,
37
37
  T as createDefaultChatUISpecRegistry,
38
38
  H as createDefaultQnaUISpecRegistry,
39
39
  J as createDefaultSimRelUISpecRegistry,
@@ -51,15 +51,15 @@ export {
51
51
  r as defaultUnknownUISpecRenderer,
52
52
  se as destroyOverlayWidgets,
53
53
  pe as detectNativeEnvironment,
54
- Ce as detectPageType,
55
- c as dispatch,
54
+ Ie as detectPageType,
55
+ g as dispatch,
56
56
  Re as extractSkuFromUrl,
57
57
  ne as getOverlayWidgets,
58
- Se as initGengageClient,
58
+ ue as initGengageClient,
59
59
  me as initNativeOverlayWidgets,
60
60
  ie as initOverlayWidgets,
61
61
  v as isVoiceInputSupported,
62
- d as listen,
62
+ S as listen,
63
63
  P as makePillLauncher,
64
64
  n as normalizeMiddlewareUrl,
65
65
  Ue as parseAccountRuntimeConfig,
@@ -72,9 +72,9 @@ export {
72
72
  Ee as safeParseAccountRuntimeConfig,
73
73
  s as streamPost,
74
74
  p as updatePageContext,
75
- g as wireGADataLayer,
75
+ c as wireGADataLayer,
76
76
  l as wireQNAToChat,
77
- m as wireSimilarToChat,
78
- S as withBaseTheme,
79
- I as withDefaultWidgetTheme
77
+ d as wireSimilarToChat,
78
+ u as withBaseTheme,
79
+ R as withDefaultWidgetTheme
80
80
  };
@@ -0,0 +1,303 @@
1
+ import { i as S } from "./overlay-C3XzoSKd.js";
2
+ var M = [
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
+ ], L = 32, T = "#gengage-qna", E = "#gengage-simrel";
16
+ function x(n) {
17
+ let e = n;
18
+ if (typeof n == "string") {
19
+ const a = n.trim();
20
+ if (a.length === 0) return null;
21
+ if (!a.startsWith("{") && !a.startsWith("[")) return { type: a };
22
+ try {
23
+ e = JSON.parse(a);
24
+ } catch {
25
+ return null;
26
+ }
27
+ }
28
+ if (!e || typeof e != "object") return null;
29
+ const t = e, i = [
30
+ t.type,
31
+ t.command,
32
+ t.action,
33
+ t.event
34
+ ].find((a) => typeof a == "string" && a.length > 0);
35
+ if (!i) return null;
36
+ let s = t.payload;
37
+ if (s === void 0 && "data" in t && (s = t.data), i === "setSession" && s === void 0) {
38
+ const a = {};
39
+ typeof t.sessionId == "string" && (a.sessionId = t.sessionId), typeof t.userId == "string" && (a.userId = t.userId), (a.sessionId !== void 0 || a.userId !== void 0) && (s = a);
40
+ }
41
+ return s === void 0 ? { type: i } : {
42
+ type: i,
43
+ payload: s
44
+ };
45
+ }
46
+ function O(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
+ var P = [
61
+ "pdp",
62
+ "plp",
63
+ "home",
64
+ "cart",
65
+ "search",
66
+ "other"
67
+ ];
68
+ function k(n) {
69
+ return Array.isArray(n) && n.every((e) => typeof e == "string");
70
+ }
71
+ function W(n) {
72
+ const e = n, t = {}, i = e.pageType;
73
+ typeof i == "string" && P.includes(i) && (t.pageType = i), typeof e.sku == "string" && (t.sku = e.sku), k(e.skuList) && (t.skuList = e.skuList), typeof e.price == "string" && (t.price = e.price), k(e.categoryTree) && (t.categoryTree = e.categoryTree), typeof e.url == "string" && (t.url = e.url);
74
+ const s = e.extra;
75
+ return s !== null && typeof s == "object" && !Array.isArray(s) && (t.extra = s), t;
76
+ }
77
+ function I(n, e) {
78
+ return e instanceof HTMLElement ? !0 : typeof e != "string" ? !1 : n.document.querySelector(e) !== null;
79
+ }
80
+ function C(n, e, t) {
81
+ if (e instanceof HTMLElement || I(n, e) || typeof e != "string") return e;
82
+ if (e.startsWith("#")) {
83
+ const a = e.slice(1);
84
+ if (a.length > 0) {
85
+ const p = n.document.getElementById(a);
86
+ if (p) return p;
87
+ const l = n.document.createElement("div");
88
+ return l.id = a, n.document.body.appendChild(l), l;
89
+ }
90
+ }
91
+ const i = n.document.getElementById(t);
92
+ if (i) return i;
93
+ const s = n.document.createElement("div");
94
+ return s.id = t, n.document.body.appendChild(s), s;
95
+ }
96
+ function q(n, e) {
97
+ const t = n.webkit?.messageHandlers?.[e];
98
+ return t && typeof t.postMessage == "function" ? t.postMessage.bind(t) : null;
99
+ }
100
+ function N(n, e) {
101
+ const t = n[e];
102
+ return t && typeof t == "object" && typeof t.postMessage == "function" ? t : null;
103
+ }
104
+ function U(n = {}) {
105
+ const e = n.win ?? window, t = n.iosHandlerName ?? "gengage", i = n.androidInterfaceName ?? "GengageNative", s = n.reactNativeInterfaceName ?? "ReactNativeWebView";
106
+ return q(e, t) ? "ios" : N(e, i) ? "android" : N(e, s) ? "react-native" : "browser";
107
+ }
108
+ function H(n, e = {}) {
109
+ const t = e.win ?? window;
110
+ if (n.sessionId !== void 0) {
111
+ try {
112
+ t.__gengageSessionId = n.sessionId, t.gengage || (t.gengage = {}), t.gengage.sessionId = n.sessionId;
113
+ } catch (i) {
114
+ console.warn("[gengage:native-bridge] Failed to apply native sessionId:", i);
115
+ }
116
+ try {
117
+ t.sessionStorage.setItem("gengage_session_id", n.sessionId);
118
+ } catch {
119
+ }
120
+ }
121
+ if (n.userId !== void 0) try {
122
+ t.gengage || (t.gengage = {});
123
+ const i = t.gengage, s = i.session ?? {};
124
+ s.userId = n.userId, i.session = s;
125
+ } catch (i) {
126
+ console.warn("[gengage:native-bridge] Failed to apply native userId:", i);
127
+ }
128
+ }
129
+ function j(n = {}) {
130
+ const e = n.win ?? window, t = e;
131
+ if (t.gengageNative) return t.gengageNative;
132
+ const i = n.iosHandlerName ?? "gengage", s = n.androidInterfaceName ?? "GengageNative", a = n.reactNativeInterfaceName ?? "ReactNativeWebView", p = n.trackedEvents ?? [...M], l = U({
133
+ win: e,
134
+ iosHandlerName: i,
135
+ androidInterfaceName: s,
136
+ reactNativeInterfaceName: a
137
+ });
138
+ let o = e.gengage?.overlay ?? null;
139
+ const c = [], v = (g, r) => {
140
+ const u = r === void 0 ? { type: g } : {
141
+ type: g,
142
+ payload: r
143
+ };
144
+ if (l === "ios") {
145
+ q(e, i)?.(u);
146
+ return;
147
+ }
148
+ if (l === "android") {
149
+ N(e, s)?.postMessage(JSON.stringify(u));
150
+ return;
151
+ }
152
+ if (l === "react-native") {
153
+ N(e, a)?.postMessage(JSON.stringify(u));
154
+ return;
155
+ }
156
+ }, m = (g) => {
157
+ const r = g.detail;
158
+ !r || typeof r.namespace != "string" || typeof r.type != "string" || v("bridge_message", {
159
+ namespace: r.namespace,
160
+ type: r.type,
161
+ payload: r.payload
162
+ });
163
+ };
164
+ e.addEventListener("gengage:bridge:message", m);
165
+ const _ = p.map((g) => {
166
+ const r = (u) => {
167
+ const d = u.detail;
168
+ v("widget_event", {
169
+ event: g,
170
+ detail: d
171
+ });
172
+ };
173
+ return e.addEventListener(g, r), {
174
+ event: g,
175
+ handler: r
176
+ };
177
+ }), y = (g) => {
178
+ c.length >= L && c.shift(), c.push(g);
179
+ }, A = () => {
180
+ if (!o || c.length === 0) return;
181
+ const g = c.splice(0, c.length);
182
+ for (const r of g) w(r);
183
+ }, w = (g) => {
184
+ const r = x(g);
185
+ if (!r || typeof r.type != "string") {
186
+ console.warn("[gengage:native-bridge] Invalid message:", g);
187
+ return;
188
+ }
189
+ const u = r.type, d = r.payload;
190
+ try {
191
+ switch (u) {
192
+ case "openChat":
193
+ o ? o.openChat(d && typeof d == "object" ? d : d === "half" || d === "full" ? { state: d } : void 0) : y(r);
194
+ return;
195
+ case "closeChat":
196
+ o ? o.closeChat() : y(r);
197
+ return;
198
+ case "updateContext":
199
+ case "updatePageContext":
200
+ case "setPageContext":
201
+ if (o && d && typeof d == "object") {
202
+ const f = W(d);
203
+ o.updateContext(f).catch((b) => {
204
+ console.warn(`[gengage:native-bridge] ${u} failed:`, b);
205
+ });
206
+ } else o ? console.warn(`[gengage:native-bridge] ${u}: missing payload`) : y(r);
207
+ return;
208
+ case "updateSku": {
209
+ const f = O(d);
210
+ if (o && f) {
211
+ o.updateSku(f.sku, f.pageType).catch((b) => {
212
+ console.warn("[gengage:native-bridge] updateSku failed:", b);
213
+ });
214
+ return;
215
+ }
216
+ o ? console.warn("[gengage:native-bridge] updateSku: missing sku") : y(r);
217
+ return;
218
+ }
219
+ case "setSession":
220
+ d && typeof d == "object" && H(d, { win: e });
221
+ return;
222
+ case "destroy":
223
+ o?.destroy();
224
+ return;
225
+ default:
226
+ n.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type:", u);
227
+ }
228
+ } catch (f) {
229
+ console.warn(`[gengage:native-bridge] Failed to handle inbound message "${u}":`, f);
230
+ }
231
+ }, h = {
232
+ env: l,
233
+ sendToNative: v,
234
+ receive: w,
235
+ setController(g) {
236
+ o = g, A();
237
+ },
238
+ destroy() {
239
+ e.removeEventListener("gengage:bridge:message", m);
240
+ for (const g of _) e.removeEventListener(g.event, g.handler);
241
+ c.splice(0, c.length), e.gengageNative === h && delete e.gengageNative;
242
+ }
243
+ };
244
+ return t.gengageNative = h, h;
245
+ }
246
+ async function R(n) {
247
+ const { nativeBridge: e, emitReadyEvent: t = !0, ...i } = n, s = j(e), a = { ...i };
248
+ a.onAddToCart || (a.onAddToCart = (c) => {
249
+ s.sendToNative("addToCart", {
250
+ sku: c.sku,
251
+ quantity: c.quantity,
252
+ cartCode: c.cartCode
253
+ });
254
+ }), a.onProductNavigate || (a.onProductNavigate = (c, v, m) => {
255
+ s.sendToNative("productNavigate", {
256
+ url: c,
257
+ sku: v,
258
+ sessionId: m
259
+ });
260
+ });
261
+ const p = a.qna?.enabled === !0 || a.qna?.mountTarget !== void 0;
262
+ if (a.qna?.enabled !== !1)
263
+ if (p) {
264
+ const c = C(window, a.qna?.mountTarget ?? T, "gengage-qna");
265
+ a.qna = {
266
+ ...a.qna,
267
+ enabled: !0,
268
+ mountTarget: c
269
+ };
270
+ } else I(window, T) || (a.qna = { enabled: !1 });
271
+ const l = a.simrel?.enabled === !0 || a.simrel?.mountTarget !== void 0;
272
+ if (a.simrel?.enabled !== !1)
273
+ if (l) {
274
+ const c = C(window, a.simrel?.mountTarget ?? E, "gengage-simrel");
275
+ a.simrel = {
276
+ ...a.simrel,
277
+ enabled: !0,
278
+ mountTarget: c
279
+ };
280
+ } else I(window, E) || (a.simrel = { enabled: !1 });
281
+ const o = await S(a);
282
+ return s.setController(o), t && s.sendToNative("ready", {
283
+ sessionId: o.session.sessionId,
284
+ widgets: {
285
+ chat: o.chat !== null,
286
+ qna: o.qna !== null,
287
+ simrel: o.simrel !== null
288
+ }
289
+ }), {
290
+ controller: o,
291
+ bridge: s,
292
+ destroy() {
293
+ o.destroy(), s.destroy();
294
+ }
295
+ };
296
+ }
297
+ export {
298
+ R as a,
299
+ U as i,
300
+ H as n,
301
+ j as r,
302
+ M as t
303
+ };