@gengage/assistant-fe 0.6.50 → 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 (50) 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 +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-CeuGSwJL.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-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 +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-BLQy7llq.js} +478 -454
  34. package/dist/{runtime-Do3qShrH.js → runtime-BC8-a6Ql.js} +231 -219
  35. package/dist/{runtime-9f9SB4WE.js → runtime-BSIrZhF2.js} +2783 -2692
  36. package/dist/{runtime-rTw1jMhB.js → runtime-DiONTdBz.js} +230 -212
  37. package/dist/{simbut-DlWvDoPI.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-BFPU2n5p.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/widget-base-BwU6SI2o.js +0 -365
package/dist/native.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a, i, n as t, r, t as s } from "./native-webview-CYX30O3Q.js";
1
+ import { a, i, n as t, r, t as s } from "./native-webview-CHKpwixw.js";
2
2
  export {
3
3
  s as DEFAULT_NATIVE_TRACKED_EVENTS,
4
4
  t as applyNativeSession,
@@ -1,5 +1,6 @@
1
- import { j as g, r as m, s as f, y as v } from "./context-UTzCGyR9.js";
2
- var _ = "__gengageWidgetsInit", l = `${_}_overlay_`, y = "#gengage-qna", w = "#gengage-simrel", C = "#gengage-simbut";
1
+ import { E as g, R as f, m, u as _ } from "./global-error-toast-DvaKvPNA.js";
2
+ import { n as v } from "./connection-warning-C0e2byq5.js";
3
+ var y = "__gengageWidgetsInit", l = `${y}_overlay_`, w = "#gengage-qna", C = "#gengage-simrel", T = "#gengage-simbut";
3
4
  function d() {
4
5
  const i = window;
5
6
  return i.__gengageOverlayRegistry || (i.__gengageOverlayRegistry = {
@@ -7,11 +8,11 @@ function d() {
7
8
  pending: {}
8
9
  }), i.__gengageOverlayRegistry;
9
10
  }
10
- function T(i) {
11
+ function b(i) {
11
12
  const e = { pageType: i.pageContext?.pageType ?? (typeof i.sku == "string" ? "pdp" : "other") }, s = i.pageContext;
12
13
  return typeof s?.sku == "string" && (e.sku = s.sku), s?.skuList !== void 0 && (e.skuList = s.skuList), s?.price !== void 0 && (e.price = s.price), s?.categoryTree !== void 0 && (e.categoryTree = s.categoryTree), s?.url !== void 0 && (e.url = s.url), s?.extra !== void 0 && (e.extra = s.extra), typeof i.sku == "string" && (e.sku = i.sku), e;
13
14
  }
14
- function b(i, e) {
15
+ function q(i, e) {
15
16
  const s = {
16
17
  ...i,
17
18
  ...e,
@@ -25,9 +26,9 @@ function r(i) {
25
26
  function p(i) {
26
27
  return i.idempotencyKey ?? `${l}${i.accountId}`;
27
28
  }
28
- var q = class {
29
+ var S = class {
29
30
  constructor(i, e) {
30
- this.options = i, this.onDestroy = e, this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this.idempotencyKey = p(i), this.session = m(i.session), this._pageContext = T(i);
31
+ this.options = i, this.onDestroy = e, this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, this._offQnaWire = null, this._destroyed = !1, this._queue = Promise.resolve(), this._warnedQnaMountMissing = !1, this._warnedSimRelMountMissing = !1, this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this.idempotencyKey = p(i), this.session = _(i.session), this._pageContext = b(i);
31
32
  }
32
33
  get chat() {
33
34
  return this._chat;
@@ -42,7 +43,7 @@ var q = class {
42
43
  return this._simbut;
43
44
  }
44
45
  async init() {
45
- window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire = f()), await this._syncPdpWidgets(), window.gengage.overlay = this;
46
+ window.gengage || (window.gengage = {}), window.gengage.sessionId = this.session.sessionId, window.gengage.pageContext = this._pageContext, await this._initChat(), this.options.wireQnaToChat !== !1 && (this._offQnaWire = m()), await this._syncPdpWidgets(), window.gengage.overlay = this;
46
47
  }
47
48
  openChat(i) {
48
49
  this._chat?.open(i);
@@ -52,7 +53,7 @@ var q = class {
52
53
  }
53
54
  async updateContext(i) {
54
55
  this._destroyed || await this._enqueue(async () => {
55
- this._pageContext = b(this._pageContext, i), window.gengage || (window.gengage = {}), window.gengage.pageContext = this._pageContext, this._chat?.update(this._pageContext), this._qna?.update(this._pageContext), this._simrel?.update(this._pageContext), this._simbut?.update(this._pageContext), await this._syncPdpWidgets();
56
+ this._pageContext = q(this._pageContext, i), window.gengage || (window.gengage = {}), window.gengage.pageContext = this._pageContext, this._chat?.update(this._pageContext), this._qna?.update(this._pageContext), this._simrel?.update(this._pageContext), this._simbut?.update(this._pageContext), await this._syncPdpWidgets();
56
57
  });
57
58
  }
58
59
  async updateSku(i, e = "pdp") {
@@ -68,7 +69,7 @@ var q = class {
68
69
  await this.updateContext(i);
69
70
  }
70
71
  destroy() {
71
- this._destroyed || (this._destroyed = !0, this._offQnaWire?.(), this._offQnaWire = null, this._chat?.destroy(), this._qna?.destroy(), this._simrel?.destroy(), this._simbut?.destroy(), this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, window.gengage?.overlay === this && delete window.gengage.overlay, this.onDestroy());
72
+ this._destroyed || (this._destroyed = !0, this._offQnaWire?.(), this._offQnaWire = null, this._chat?.destroy(), this._qna?.destroy(), this._simrel?.destroy(), this._simbut?.destroy(), this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, window.gengage?.overlay === this && delete window.gengage.overlay, v(), this.onDestroy());
72
73
  }
73
74
  async _initChat() {
74
75
  if (this.options.chat?.enabled === !1) return;
@@ -92,7 +93,7 @@ var q = class {
92
93
  }
93
94
  const e = this.options.middlewareUrl;
94
95
  if (this.options.qna?.enabled !== !1) {
95
- const s = this.options.qna?.mountTarget ?? y, a = r(s);
96
+ const s = this.options.qna?.mountTarget ?? w, a = r(s);
96
97
  if (a)
97
98
  if (this._warnedQnaMountMissing = !1, this._qna)
98
99
  this._qna.show(), this._qna.update({
@@ -100,7 +101,9 @@ var q = class {
100
101
  sku: i
101
102
  });
102
103
  else {
103
- const { GengageQNA: t } = await import("./qna-runtime.js"), h = new t(), o = {
104
+ const { GengageQNA: t } = await import("./qna-runtime.js");
105
+ if (this._destroyed) return;
106
+ const h = new t(), o = {
104
107
  accountId: this.options.accountId,
105
108
  middlewareUrl: e,
106
109
  session: this.session,
@@ -112,14 +115,18 @@ var q = class {
112
115
  };
113
116
  this.options.theme !== void 0 && (o.theme = this.options.theme), this.options.qna?.chrome !== void 0 && (o.chrome = this.options.qna.chrome), this.options.qna?.ctaText !== void 0 && (o.ctaText = this.options.qna.ctaText), this.options.qna?.hideButtonRowCta !== void 0 && (o.hideButtonRowCta = this.options.qna.hideButtonRowCta), this.options.qna?.inputPlaceholder !== void 0 && (o.inputPlaceholder = this.options.qna.inputPlaceholder), this.options.qna?.inputAfterPills !== void 0 && (o.inputAfterPills = this.options.qna.inputAfterPills), this.options.qna?.i18n !== void 0 && (o.i18n = this.options.qna.i18n), this.options.qna?.renderer !== void 0 && (o.renderer = this.options.qna.renderer);
114
117
  const n = this.options.qna?.headerTitle ?? this.options.qna?.headingTitle;
115
- n !== void 0 && (o.headerTitle = n), await h.init(o), this._qna = h;
118
+ if (n !== void 0 && (o.headerTitle = n), await h.init(o), this._destroyed) {
119
+ h.destroy();
120
+ return;
121
+ }
122
+ this._qna = h;
116
123
  }
117
124
  else
118
125
  this._qna?.destroy(), this._qna = null, this._warnedQnaMountMissing || (console.warn(`[gengage] QNA mount target not found: ${s}`), this._warnedQnaMountMissing = !0);
119
126
  } else
120
127
  this._qna?.destroy(), this._qna = null;
121
128
  if (this.options.simrel !== void 0 && this.options.simrel.enabled !== !1) {
122
- const s = this.options.simrel?.mountTarget ?? w, a = r(s);
129
+ const s = this.options.simrel?.mountTarget ?? C, a = r(s);
123
130
  if (a)
124
131
  if (this._warnedSimRelMountMissing = !1, this._simrel)
125
132
  this._simrel.show(), this._simrel.update({
@@ -127,23 +134,29 @@ var q = class {
127
134
  sku: i
128
135
  });
129
136
  else {
130
- const { GengageSimRel: t } = await import("./simrel-runtime.js"), h = new t(), o = {
137
+ const { GengageSimRel: t } = await import("./simrel-runtime.js");
138
+ if (this._destroyed) return;
139
+ const h = new t(), o = {
131
140
  accountId: this.options.accountId,
132
141
  middlewareUrl: e,
133
142
  session: this.session,
134
143
  sku: i,
135
144
  mountTarget: a
136
145
  };
137
- this.options.locale !== void 0 && (o.locale = this.options.locale), this.options.theme !== void 0 && (o.theme = this.options.theme), this.options.pricing !== void 0 && (o.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (o.discountType = this.options.simrel.discountType), this.options.simrel?.gridColumns !== void 0 && (o.gridColumns = this.options.simrel.gridColumns), this.options.simrel?.enableProductGroupings !== void 0 && (o.enableProductGroupings = this.options.simrel.enableProductGroupings), this.options.simrel?.renderCardElement !== void 0 && (o.renderCardElement = this.options.simrel.renderCardElement), this.options.simrel?.renderer !== void 0 && (o.renderer = this.options.simrel.renderer), this.options.onAddToCart !== void 0 && (o.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? o.onProductNavigate = this.options.onProductNavigate : o.onProductNavigate = (n, c, u) => {
138
- g(n) && (this._chat?.saveSession(u ?? this.session.sessionId, c), window.location.href = n);
139
- }, await h.init(o), this._simrel = h;
146
+ if (this.options.locale !== void 0 && (o.locale = this.options.locale), this.options.theme !== void 0 && (o.theme = this.options.theme), this.options.pricing !== void 0 && (o.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (o.discountType = this.options.simrel.discountType), this.options.simrel?.gridColumns !== void 0 && (o.gridColumns = this.options.simrel.gridColumns), this.options.simrel?.enableProductGroupings !== void 0 && (o.enableProductGroupings = this.options.simrel.enableProductGroupings), this.options.simrel?.renderCardElement !== void 0 && (o.renderCardElement = this.options.simrel.renderCardElement), this.options.simrel?.renderer !== void 0 && (o.renderer = this.options.simrel.renderer), this.options.onAddToCart !== void 0 && (o.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? o.onProductNavigate = this.options.onProductNavigate : o.onProductNavigate = (n, u, c) => {
147
+ f(n) && (this._chat?.saveSession(c ?? this.session.sessionId, u), window.location.href = n);
148
+ }, await h.init(o), this._destroyed) {
149
+ h.destroy();
150
+ return;
151
+ }
152
+ this._simrel = h;
140
153
  }
141
154
  else
142
155
  this._simrel?.destroy(), this._simrel = null, this._warnedSimRelMountMissing || (console.warn(`[gengage] SimRel mount target not found: ${s}`), this._warnedSimRelMountMissing = !0);
143
156
  } else
144
157
  this._simrel?.destroy(), this._simrel = null;
145
158
  if (this.options.simbut && this.options.simbut.enabled !== !1) {
146
- const s = this.options.simbut.mountTarget ?? C, a = r(s), t = this._chat ?? this.options.simbut.onFindSimilar;
159
+ const s = this.options.simbut.mountTarget ?? T, a = r(s), t = this._chat ?? this.options.simbut.onFindSimilar;
147
160
  if (a && t)
148
161
  if (this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this._simbut)
149
162
  this._simbut.show(), this._simbut.setChat(this._chat), this._simbut.update({
@@ -151,7 +164,9 @@ var q = class {
151
164
  sku: i
152
165
  });
153
166
  else {
154
- const { GengageSimBut: h } = await import("./simbut.js"), o = new h(), n = {
167
+ const { GengageSimBut: h } = await import("./simbut.js");
168
+ if (this._destroyed) return;
169
+ const o = new h(), n = {
155
170
  accountId: this.options.accountId,
156
171
  middlewareUrl: e,
157
172
  session: this.session,
@@ -162,7 +177,11 @@ var q = class {
162
177
  mountTarget: a,
163
178
  chat: this._chat
164
179
  };
165
- this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.locale !== void 0 && (n.locale = this.options.locale), this.options.simbut.layout !== void 0 && (n.layout = this.options.simbut.layout), this.options.simbut.inlineCard !== void 0 && (n.inlineCard = this.options.simbut.inlineCard), this.options.simbut.imageUrl !== void 0 && (n.imageUrl = this.options.simbut.imageUrl), this.options.simbut.i18n !== void 0 && (n.i18n = this.options.simbut.i18n), this.options.simbut.onFindSimilar !== void 0 && (n.onFindSimilar = this.options.simbut.onFindSimilar), await o.init(n), this._simbut = o;
180
+ if (this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.locale !== void 0 && (n.locale = this.options.locale), this.options.simbut.layout !== void 0 && (n.layout = this.options.simbut.layout), this.options.simbut.inlineCard !== void 0 && (n.inlineCard = this.options.simbut.inlineCard), this.options.simbut.imageUrl !== void 0 && (n.imageUrl = this.options.simbut.imageUrl), this.options.simbut.i18n !== void 0 && (n.i18n = this.options.simbut.i18n), this.options.simbut.onFindSimilar !== void 0 && (n.onFindSimilar = this.options.simbut.onFindSimilar), await o.init(n), this._destroyed) {
181
+ o.destroy();
182
+ return;
183
+ }
184
+ this._simbut = o;
166
185
  }
167
186
  else
168
187
  this._simbut?.destroy(), this._simbut = null, !a && !this._warnedSimButMountMissing ? (console.warn(`[gengage] SimBut mount target not found: ${s}`), this._warnedSimButMountMissing = !0) : !t && !this._warnedSimButNoChat && (console.warn("[gengage] SimBut requires chat to be enabled or simbut.onFindSimilar"), this._warnedSimButNoChat = !0);
@@ -175,35 +194,35 @@ var q = class {
175
194
  }), e;
176
195
  }
177
196
  };
178
- async function k(i) {
197
+ async function M(i) {
179
198
  const e = p(i), s = d(), a = s.instances[e];
180
199
  if (a) return a;
181
200
  const t = s.pending[e];
182
201
  if (t) return t;
183
- const h = new q(i, () => {
202
+ const h = new S(i, () => {
184
203
  const n = d();
185
204
  delete n.instances[e], delete n.pending[e];
186
205
  }), o = h.init().then(() => (s.instances[e] = h, delete s.pending[e], h)).catch((n) => {
187
- throw delete s.pending[e], v({
206
+ throw delete s.pending[e], g({
188
207
  reason: "overlay_init_failed",
189
208
  message: n instanceof Error ? n.message : String(n)
190
209
  }), n;
191
210
  });
192
211
  return s.pending[e] = o, o;
193
212
  }
194
- function S(i) {
213
+ function x(i) {
195
214
  return d().instances[i] ?? null;
196
215
  }
197
- function L(i) {
198
- S(i)?.destroy();
216
+ function P(i) {
217
+ x(i)?.destroy();
199
218
  }
200
- function M(i) {
219
+ function U(i) {
201
220
  return `${l}${i}`;
202
221
  }
203
222
  export {
204
- _ as a,
205
- k as i,
206
- L as n,
207
- S as r,
208
- M as t
223
+ y as a,
224
+ M as i,
225
+ P as n,
226
+ x as r,
227
+ U as t
209
228
  };
package/dist/overlay.js CHANGED
@@ -1,10 +1,10 @@
1
- import { i as t, t as a } from "./context-UTzCGyR9.js";
2
- import { i as r, n as i, r as o, t as d } from "./overlay-BPZEIyo_.js";
1
+ import { c as t, d as a } from "./global-error-toast-DvaKvPNA.js";
2
+ import { i as r, n as o, r as i, t as d } from "./overlay-C3XzoSKd.js";
3
3
  export {
4
- a as bootstrapSession,
4
+ t as bootstrapSession,
5
5
  d as buildOverlayIdempotencyKey,
6
- i as destroyOverlayWidgets,
7
- o as getOverlayWidgets,
6
+ o as destroyOverlayWidgets,
7
+ i as getOverlayWidgets,
8
8
  r as initOverlayWidgets,
9
- t as updatePageContext
9
+ a as updatePageContext
10
10
  };
@@ -28,8 +28,9 @@ var m = {
28
28
  alwaysShowDecimals: !1
29
29
  };
30
30
  function y(e, o) {
31
+ if (typeof e != "string" || e.trim() === "") return e;
31
32
  const n = Number(e);
32
- if (!Number.isFinite(n) || n < 0) return e;
33
+ if (!Number.isFinite(n) || n < 0 || n >= 1e15) return e;
33
34
  const r = {
34
35
  ...m,
35
36
  ...o
@@ -34,6 +34,7 @@ import './components/qna.css';
34
34
  export declare class GengageQNA extends BaseWidget<QNAWidgetConfig> {
35
35
  private _abortController;
36
36
  private _debounceTimer;
37
+ private _dispatchTimers;
37
38
  private _contentEl;
38
39
  private _lastSku;
39
40
  private _i18n;
@@ -1,4 +1,4 @@
1
- import { a, i as r, n, r as t, t as s } from "./runtime-rTw1jMhB.js";
1
+ import { a, i as r, n, r as t, t as s } from "./runtime-DiONTdBz.js";
2
2
  export {
3
3
  s as GengageQNA,
4
4
  t as createDefaultQnaUISpecRegistry,