@gengage/assistant-fe 0.3.28 → 0.3.29

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/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, d as r, f as s, n, o as C, p as c, r as h, s as l, t as o } from "./chat-DaFZJmwK.js";
1
+ import { a as e, c as t, d as r, f as s, n, o as C, p as c, r as h, s as l, t as o } from "./chat-3M_eI0kY.js";
2
2
  export {
3
3
  r as CHAT_SCROLL_ELEMENT_ID,
4
4
  e as ChatPresentationState,
@@ -0,0 +1 @@
1
+ export declare function escapeCssIdentifier(value: string): string;
@@ -1,7 +1,7 @@
1
1
  import { OverlayWidgetsController, OverlayWidgetsOptions } from './overlay.js';
2
2
  export declare const DEFAULT_NATIVE_TRACKED_EVENTS: readonly ["gengage:chat:open", "gengage:chat:close", "gengage:chat:ready", "gengage:chat:add-to-cart", "gengage:qna:action", "gengage:qna:open-chat", "gengage:similar:product-click", "gengage:similar:add-to-cart", "gengage:global:error", "gengage:context:update"];
3
3
  export type NativeTrackedEvent = (typeof DEFAULT_NATIVE_TRACKED_EVENTS)[number];
4
- export type NativeInboundMessage = 'openChat' | 'closeChat' | 'updateContext' | 'updateSku' | 'setSession' | 'destroy';
4
+ export type NativeInboundMessage = 'openChat' | 'closeChat' | 'updateContext' | 'updatePageContext' | 'setPageContext' | 'updateSku' | 'setSession' | 'destroy';
5
5
  export type NativeBridgeEnvironment = 'ios' | 'android' | 'react-native' | 'browser';
6
6
  export interface NativeSessionPayload {
7
7
  sessionId?: string;
@@ -111,7 +111,18 @@ export interface OverlayWidgetsController {
111
111
  state?: 'half' | 'full';
112
112
  }): void;
113
113
  closeChat(): void;
114
+ /**
115
+ * Merges partial page context (SKU, page type, category, …) into the active
116
+ * widgets. Use after SPA navigation so chat and PDP stay aligned.
117
+ */
114
118
  updateContext(patch: Partial<PageContext>): Promise<void>;
119
+ /** @see {@link updateContext} */
120
+ updatePageContext(patch: Partial<PageContext>): Promise<void>;
121
+ /**
122
+ * Merge-only page context update. This is an alias of {@link updateContext},
123
+ * not a full replacement of the existing PageContext.
124
+ */
125
+ setPageContext(patch: Partial<PageContext>): Promise<void>;
115
126
  updateSku(sku: string, pageType?: PageContext['pageType']): Promise<void>;
116
127
  destroy(): void;
117
128
  }
@@ -1,5 +1,5 @@
1
- import { f as u } from "./schemas-DJ1qbfi8.js";
2
- import { h, l as f } from "./native-webview-CO5A74dl.js";
1
+ import { f as u } from "./schemas-BG_cvFvP.js";
2
+ import { h, l as f } from "./native-webview-3zNu74gQ.js";
3
3
  var m = {
4
4
  enabled: !0,
5
5
  endpoint: "/analytics",
package/dist/common.js CHANGED
@@ -1,9 +1,9 @@
1
- import { C as a, S as t, b as s, d as r, f as n, g as i, h as o, m as c, p as m, v as l, w as g, x as d, y as u } from "./schemas-DJ1qbfi8.js";
1
+ import { C as a, S as t, b as s, d as r, f as n, g as i, h as o, m as c, p as m, v as l, w as g, x as d, y as u } from "./schemas-BG_cvFvP.js";
2
2
  import { $ as E, A as S, D as h, E as v, F as y, G as C, H as f, I as A, J as T, K as w, L as U, M as W, N as I, O as P, P as D, Q as k, S as R, T as b, U as G, V as O, W as N, X as x, Y as L, Z as M, et as _, j as H, k as z, q as B, v as F, w as K, x as V, y as Q } from "./ga-datalayer-BwxWX-cr.js";
3
- import { i as Z, l as j, m as J, u as X } from "./chat-DaFZJmwK.js";
3
+ import { i as Z, l as j, m as J, u as X } from "./chat-3M_eI0kY.js";
4
4
  import { n as $, t as ee } from "./connection-warning-CHHi3BAf.js";
5
- import { a as te, c as se, d as re, f as ne, h as ie, i as oe, l as ce, m as me, n as le, o as ge, p as de, r as ue, s as pe, u as Ee } from "./native-webview-CO5A74dl.js";
6
- import { a as he, c as ve, d as ye, f as Ce, i as fe, l as Ae, n as Te, o as we, p as Ue, r as We, s as Ie, t as Pe, u as De } from "./common-CYirxrL9.js";
5
+ import { a as te, c as se, d as re, f as ne, h as ie, i as oe, l as ce, m as me, n as le, o as ge, p as de, r as ue, s as pe, u as Ee } from "./native-webview-3zNu74gQ.js";
6
+ import { a as he, c as ve, d as ye, f as Ce, i as fe, l as Ae, n as Te, o as we, p as Ue, r as We, s as Ie, t as Pe, u as De } from "./common-BYOYS_Ug.js";
7
7
  export {
8
8
  Ee as AccountRuntimeConfigSchema,
9
9
  re as AnalyticsAuthModeSchema,
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { C as a, b as t, d as s, f as i, w as n, x as r } from "./schemas-DJ1qbfi8.js";
1
+ import { C as a, b as t, d as s, f as i, w as n, x as r } from "./schemas-BG_cvFvP.js";
2
2
  import { A as c, D as m, E as l, F as d, I as g, L as p, N as u, O as S, P as f, k as C, v as U } from "./ga-datalayer-BwxWX-cr.js";
3
- import { c as A, i as I, l as y, m as R, n as D, o as E, s as T, t as W, u as w } from "./chat-DaFZJmwK.js";
3
+ import { c as A, i as I, l as y, m as R, n as D, o as E, s as T, t as W, u as w } from "./chat-3M_eI0kY.js";
4
4
  import { t as N } from "./connection-warning-CHHi3BAf.js";
5
- import { a as P, i as k, n as G, o as L, t as Q } from "./qna-D33BNaWd.js";
6
- import { a as b, i as x, n as B, o as F, t as M } from "./simrel-DstZ5m2H.js";
5
+ import { a as P, i as k, n as G, o as L, t as Q } from "./qna-R1-EoKwH.js";
6
+ import { a as b, i as x, n as B, o as F, t as M } from "./simrel-BREHamN-.js";
7
7
  import { n as H, t as K } from "./simbut-BBXTlzOg.js";
8
- import { a as Z, c as j, d as q, f as J, h as X, i as Y, l as $, m as ee, n as ae, o as te, p as se, r as ie, s as ne, u as re } from "./native-webview-CO5A74dl.js";
9
- import { a as ce, c as me, d as le, i as de, l as ge, n as pe, o as ue, p as Se, r as fe, s as Ce, t as Ue, u as he } from "./common-CYirxrL9.js";
8
+ import { a as Z, c as j, d as q, f as J, h as X, i as Y, l as $, m as ee, n as ae, o as te, p as se, r as ie, s as ne, u as re } from "./native-webview-3zNu74gQ.js";
9
+ import { a as ce, c as me, d as le, i as de, l as ge, n as pe, o as ue, p as Se, r as fe, s as Ce, t as Ue, u as he } from "./common-BYOYS_Ug.js";
10
10
  export {
11
11
  re as AccountRuntimeConfigSchema,
12
12
  q as AnalyticsAuthModeSchema,
@@ -1,8 +1,8 @@
1
- import { a as k, c as h, i as D, o as f, r as m, t as A } from "./schemas-DJ1qbfi8.js";
1
+ import { a as k, c as h, i as D, o as f, r as m, t as A } from "./schemas-BG_cvFvP.js";
2
2
  import { I as H, M as Q, b as M, z as K } from "./ga-datalayer-BwxWX-cr.js";
3
- import { t as V } from "./chat-DaFZJmwK.js";
4
- import { t as j } from "./qna-D33BNaWd.js";
5
- import { t as $ } from "./simrel-DstZ5m2H.js";
3
+ import { t as V } from "./chat-3M_eI0kY.js";
4
+ import { t as $ } from "./qna-R1-EoKwH.js";
5
+ import { t as j } from "./simrel-BREHamN-.js";
6
6
  import { t as G } from "./simbut-BBXTlzOg.js";
7
7
  var b = f({ enabled: m().default(!0) }), Y = f({
8
8
  chat: h().optional(),
@@ -101,7 +101,7 @@ function Se(e) {
101
101
  }
102
102
  });
103
103
  }
104
- var B = `${R}_overlay_`, se = "#gengage-qna", oe = "#gengage-simrel", ae = "#gengage-simbut";
104
+ var P = `${R}_overlay_`, se = "#gengage-qna", oe = "#gengage-simrel", ae = "#gengage-simbut";
105
105
  function q() {
106
106
  const e = window;
107
107
  return e.__gengageOverlayRegistry || (e.__gengageOverlayRegistry = {
@@ -124,12 +124,12 @@ function de(e, t) {
124
124
  function I(e) {
125
125
  return e instanceof HTMLElement || document.querySelector(e) ? e : null;
126
126
  }
127
- function O(e) {
128
- return e.idempotencyKey ?? `${B}${e.accountId}`;
127
+ function B(e) {
128
+ return e.idempotencyKey ?? `${P}${e.accountId}`;
129
129
  }
130
130
  var le = class {
131
131
  constructor(e, t) {
132
- this.options = e, this.onDestroy = t, this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, this._analyticsClient = 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 = O(e), this.session = Q(e.session), this._pageContext = re(e);
132
+ this.options = e, this.onDestroy = t, this._chat = null, this._qna = null, this._simrel = null, this._simbut = null, this._analyticsClient = 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 = B(e), this.session = Q(e.session), this._pageContext = re(e);
133
133
  }
134
134
  get chat() {
135
135
  return this._chat;
@@ -166,6 +166,12 @@ var le = class {
166
166
  pageType: t
167
167
  });
168
168
  }
169
+ async updatePageContext(e) {
170
+ await this.updateContext(e);
171
+ }
172
+ async setPageContext(e) {
173
+ await this.updateContext(e);
174
+ }
169
175
  destroy() {
170
176
  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());
171
177
  }
@@ -197,7 +203,7 @@ var le = class {
197
203
  sku: e
198
204
  });
199
205
  else {
200
- const o = new j(), n = {
206
+ const o = new $(), n = {
201
207
  accountId: this.options.accountId,
202
208
  middlewareUrl: t,
203
209
  session: this.session,
@@ -224,7 +230,7 @@ var le = class {
224
230
  sku: e
225
231
  });
226
232
  else {
227
- const o = new $(), n = {
233
+ const o = new j(), n = {
228
234
  accountId: this.options.accountId,
229
235
  middlewareUrl: t,
230
236
  session: this.session,
@@ -273,7 +279,7 @@ var le = class {
273
279
  }
274
280
  };
275
281
  async function ue(e) {
276
- const t = O(e), i = q(), s = i.instances[t];
282
+ const t = B(e), i = q(), s = i.instances[t];
277
283
  if (s) return s;
278
284
  const o = i.pending[t];
279
285
  if (o) return o;
@@ -292,7 +298,7 @@ function Ne(e) {
292
298
  ce(e)?.destroy();
293
299
  }
294
300
  function ke(e) {
295
- return `${B}${e}`;
301
+ return `${P}${e}`;
296
302
  }
297
303
  var ge = [
298
304
  "gengage:chat:open",
@@ -305,7 +311,7 @@ var ge = [
305
311
  "gengage:similar:add-to-cart",
306
312
  "gengage:global:error",
307
313
  "gengage:context:update"
308
- ], he = 32, U = "#gengage-qna", x = "#gengage-simrel";
314
+ ], he = 32, x = "#gengage-qna", U = "#gengage-simrel";
309
315
  function pe(e) {
310
316
  let t = e;
311
317
  if (typeof e == "string") {
@@ -369,7 +375,7 @@ function E(e, t, i) {
369
375
  const o = e.document.createElement("div");
370
376
  return o.id = i, e.document.body.appendChild(o), o;
371
377
  }
372
- function P(e, t) {
378
+ function O(e, t) {
373
379
  const i = e.webkit?.messageHandlers?.[t];
374
380
  return i && typeof i.postMessage == "function" ? i.postMessage.bind(i) : null;
375
381
  }
@@ -379,7 +385,7 @@ function w(e, t) {
379
385
  }
380
386
  function me(e = {}) {
381
387
  const t = e.win ?? window, i = e.iosHandlerName ?? "gengage", s = e.androidInterfaceName ?? "GengageNative", o = e.reactNativeInterfaceName ?? "ReactNativeWebView";
382
- return P(t, i) ? "ios" : w(t, s) ? "android" : w(t, o) ? "react-native" : "browser";
388
+ return O(t, i) ? "ios" : w(t, s) ? "android" : w(t, o) ? "react-native" : "browser";
383
389
  }
384
390
  function ve(e, t = {}) {
385
391
  const i = t.win ?? window;
@@ -412,7 +418,7 @@ function ye(e = {}) {
412
418
  payload: r
413
419
  };
414
420
  if (c === "ios") {
415
- P(t, s)?.(p);
421
+ O(t, s)?.(p);
416
422
  return;
417
423
  }
418
424
  if (c === "android") {
@@ -465,7 +471,9 @@ function ye(e = {}) {
465
471
  a ? a.closeChat() : _(r);
466
472
  return;
467
473
  case "updateContext":
468
- a && g && typeof g == "object" ? a.updateContext(g) : a ? console.warn("[gengage:native-bridge] updateContext: missing payload") : _(r);
474
+ case "updatePageContext":
475
+ case "setPageContext":
476
+ a && g && typeof g == "object" ? a.updateContext(g) : a ? console.warn(`[gengage:native-bridge] ${p}: missing payload`) : _(r);
469
477
  return;
470
478
  case "updateSku": {
471
479
  const T = fe(g);
@@ -522,23 +530,23 @@ async function Me(e) {
522
530
  const d = n.qna?.enabled === !0 || n.qna?.mountTarget !== void 0;
523
531
  if (n.qna?.enabled !== !1)
524
532
  if (d) {
525
- const u = E(window, n.qna?.mountTarget ?? U, "gengage-qna");
533
+ const u = E(window, n.qna?.mountTarget ?? x, "gengage-qna");
526
534
  n.qna = {
527
535
  ...n.qna,
528
536
  enabled: !0,
529
537
  mountTarget: u
530
538
  };
531
- } else S(window, U) || (n.qna = { enabled: !1 });
539
+ } else S(window, x) || (n.qna = { enabled: !1 });
532
540
  const c = n.simrel?.enabled === !0 || n.simrel?.mountTarget !== void 0;
533
541
  if (n.simrel?.enabled !== !1)
534
542
  if (c) {
535
- const u = E(window, n.simrel?.mountTarget ?? x, "gengage-simrel");
543
+ const u = E(window, n.simrel?.mountTarget ?? U, "gengage-simrel");
536
544
  n.simrel = {
537
545
  ...n.simrel,
538
546
  enabled: !0,
539
547
  mountTarget: u
540
548
  };
541
- } else S(window, x) || (n.simrel = { enabled: !1 });
549
+ } else S(window, U) || (n.simrel = { enabled: !1 });
542
550
  const a = await ue(n);
543
551
  return o.setController(a), i && o.sendToNative("ready", {
544
552
  sessionId: a.session.sessionId,