@gengage/assistant-fe 0.3.41 → 0.4.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.
- package/dist/chat/catalog.d.ts +10 -0
- package/dist/chat/types.d.ts +6 -0
- package/dist/{chat-CmGV3i0P.js → chat-C9l4oBJA.js} +363 -358
- package/dist/chat.iife.js +9 -9
- package/dist/chat.js +1 -1
- package/dist/common/client.d.ts +6 -1
- package/dist/common/config-schema.d.ts +1 -1
- package/dist/common/overlay.d.ts +2 -0
- package/dist/{common-ouVC4QMB.js → common-CiTC1BDg.js} +113 -102
- package/dist/common.js +4 -4
- package/dist/index.js +6 -6
- package/dist/{native-webview-Blw4xXPu.js → native-webview-FnIiDil0.js} +48 -49
- package/dist/native.iife.js +8 -8
- package/dist/native.js +1 -1
- package/dist/{qna-DrlYm1d8.js → qna-CQugVOHy.js} +1 -1
- package/dist/qna.iife.js +7 -7
- package/dist/qna.js +1 -1
- package/dist/{schemas-DnAo0x7A.js → schemas-JFGRVTVz.js} +3 -1
- package/dist/{simrel-BjNqBbmw.js → simrel-DjzpRZmZ.js} +1 -1
- package/dist/simrel.iife.js +6 -6
- package/dist/simrel.js +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as k, c as h, i as
|
|
1
|
+
import { a as k, c as h, i as W, o as f, r as m, t as A } from "./schemas-JFGRVTVz.js";
|
|
2
2
|
import { U as H, h as Q, j, r as M, y as K } from "./locale-MM0U5eeR.js";
|
|
3
|
-
import { t as V } from "./chat-
|
|
4
|
-
import { t as $ } from "./qna-
|
|
5
|
-
import { t as G } from "./simrel-
|
|
3
|
+
import { t as V } from "./chat-C9l4oBJA.js";
|
|
4
|
+
import { t as $ } from "./qna-CQugVOHy.js";
|
|
5
|
+
import { t as G } from "./simrel-DjzpRZmZ.js";
|
|
6
6
|
import { t as Y } from "./simbut-Cb5RfaAp.js";
|
|
7
7
|
var b = f({ enabled: m().default(!0) }), J = f({
|
|
8
8
|
chat: h().optional(),
|
|
@@ -42,14 +42,14 @@ var b = f({ enabled: m().default(!0) }), J = f({
|
|
|
42
42
|
unknownActionPolicy: ie.default("log-and-ignore"),
|
|
43
43
|
allowScriptCall: m().default(!1)
|
|
44
44
|
}), L = f({
|
|
45
|
-
version:
|
|
45
|
+
version: W("1", { error: 'version must be "1"' }),
|
|
46
46
|
accountId: h({ error: "accountId must be a non-empty string" }).min(1, { error: "accountId must be a non-empty string" }),
|
|
47
47
|
middlewareUrl: h({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }).url({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }),
|
|
48
48
|
locale: h().optional(),
|
|
49
49
|
widgets: f({
|
|
50
50
|
chat: b.default({ enabled: !0 }),
|
|
51
51
|
qna: b.default({ enabled: !0 }),
|
|
52
|
-
simrel: b.
|
|
52
|
+
simrel: b.optional(),
|
|
53
53
|
simbut: b.default({ enabled: !1 })
|
|
54
54
|
}),
|
|
55
55
|
mounts: J.default({}),
|
|
@@ -96,7 +96,6 @@ function Ne(e) {
|
|
|
96
96
|
widgets: {
|
|
97
97
|
chat: { enabled: !0 },
|
|
98
98
|
qna: { enabled: !0 },
|
|
99
|
-
simrel: { enabled: !0 },
|
|
100
99
|
simbut: { enabled: !1 }
|
|
101
100
|
}
|
|
102
101
|
});
|
|
@@ -127,7 +126,7 @@ function I(e) {
|
|
|
127
126
|
function B(e) {
|
|
128
127
|
return e.idempotencyKey ?? `${P}${e.accountId}`;
|
|
129
128
|
}
|
|
130
|
-
var
|
|
129
|
+
var ce = class {
|
|
131
130
|
constructor(e, t) {
|
|
132
131
|
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 = de(e);
|
|
133
132
|
}
|
|
@@ -184,7 +183,7 @@ var ue = class {
|
|
|
184
183
|
pageContext: this._pageContext,
|
|
185
184
|
variant: this.options.chat?.variant ?? "floating"
|
|
186
185
|
};
|
|
187
|
-
this.options.theme !== void 0 && (s.theme = this.options.theme), this.options.locale !== void 0 && (s.locale = this.options.locale), this.options.pricing !== void 0 && (s.pricing = this.options.pricing), this.options.chat?.mountTarget !== void 0 && (s.mountTarget = this.options.chat.mountTarget), this.options.chat?.pillLauncher !== void 0 && (s.pillLauncher = this.options.chat.pillLauncher), this.options.chat?.launcherImageUrl !== void 0 ? s.launcherImageUrl = this.options.chat.launcherImageUrl : this.options.chat?.launcherSvg !== void 0 && (s.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.headerTitle !== void 0 && (s.headerTitle = this.options.chat.headerTitle), this.options.chat?.headerAvatarUrl !== void 0 && (s.headerAvatarUrl = this.options.chat.headerAvatarUrl), this.options.chat?.headerBadge !== void 0 && (s.headerBadge = this.options.chat.headerBadge), this.options.chat?.headerCartUrl !== void 0 && (s.headerCartUrl = this.options.chat.headerCartUrl), this.options.chat?.headerFavoritesToggle !== void 0 && (s.headerFavoritesToggle = this.options.chat.headerFavoritesToggle), this.options.chat?.onFavoritesClick !== void 0 && (s.onFavoritesClick = this.options.chat.onFavoritesClick), this.options.chat?.hideMobileLauncher !== void 0 && (s.hideMobileLauncher = this.options.chat.hideMobileLauncher), this.options.chat?.mobileBreakpoint !== void 0 && (s.mobileBreakpoint = this.options.chat.mobileBreakpoint), this.options.chat?.mobileInitialState !== void 0 && (s.mobileInitialState = this.options.chat.mobileInitialState), this.options.chat?.i18n !== void 0 && (s.i18n = this.options.chat.i18n), this.options.chat?.actionHandling !== void 0 && (s.actionHandling = this.options.chat.actionHandling), this.options.chat?.renderer !== void 0 && (s.renderer = this.options.chat.renderer), t !== void 0 && (s.productDetailsExtended = t), i !== void 0 && (s.isDemoWebsite = i), this.options.chat?.productPriceUi !== void 0 && (s.productPriceUi = this.options.chat.productPriceUi), this.options.onScriptCall !== void 0 && (s.onScriptCall = this.options.onScriptCall), this.options.onAddToCart !== void 0 && (s.onAddToCart = this.options.onAddToCart), this.options.chat?.onOpen !== void 0 && (s.onOpen = this.options.chat.onOpen), this.options.chat?.onClose !== void 0 && (s.onClose = this.options.chat.onClose), this._chat = new V(), await this._chat.init(s);
|
|
186
|
+
this.options.theme !== void 0 && (s.theme = this.options.theme), this.options.locale !== void 0 && (s.locale = this.options.locale), this.options.pricing !== void 0 && (s.pricing = this.options.pricing), this.options.chat?.mountTarget !== void 0 && (s.mountTarget = this.options.chat.mountTarget), this.options.chat?.pillLauncher !== void 0 && (s.pillLauncher = this.options.chat.pillLauncher), this.options.chat?.launcherImageUrl !== void 0 ? s.launcherImageUrl = this.options.chat.launcherImageUrl : this.options.chat?.launcherSvg !== void 0 && (s.launcherSvg = this.options.chat.launcherSvg), this.options.chat?.headerTitle !== void 0 && (s.headerTitle = this.options.chat.headerTitle), this.options.chat?.headerAvatarUrl !== void 0 && (s.headerAvatarUrl = this.options.chat.headerAvatarUrl), this.options.chat?.headerBadge !== void 0 && (s.headerBadge = this.options.chat.headerBadge), this.options.chat?.headerCartUrl !== void 0 && (s.headerCartUrl = this.options.chat.headerCartUrl), this.options.chat?.headerFavoritesToggle !== void 0 && (s.headerFavoritesToggle = this.options.chat.headerFavoritesToggle), this.options.chat?.onFavoritesClick !== void 0 && (s.onFavoritesClick = this.options.chat.onFavoritesClick), this.options.chat?.hideMobileLauncher !== void 0 && (s.hideMobileLauncher = this.options.chat.hideMobileLauncher), this.options.chat?.mobileBreakpoint !== void 0 && (s.mobileBreakpoint = this.options.chat.mobileBreakpoint), this.options.chat?.mobileInitialState !== void 0 && (s.mobileInitialState = this.options.chat.mobileInitialState), this.options.chat?.i18n !== void 0 && (s.i18n = this.options.chat.i18n), this.options.chat?.actionHandling !== void 0 && (s.actionHandling = this.options.chat.actionHandling), this.options.chat?.renderer !== void 0 && (s.renderer = this.options.chat.renderer), t !== void 0 && (s.productDetailsExtended = t), i !== void 0 && (s.isDemoWebsite = i), this.options.chat?.productPriceUi !== void 0 && (s.productPriceUi = this.options.chat.productPriceUi), this.options.chat?.hideProductDiscountBadge !== void 0 && (s.hideProductDiscountBadge = this.options.chat.hideProductDiscountBadge), this.options.onScriptCall !== void 0 && (s.onScriptCall = this.options.onScriptCall), this.options.onAddToCart !== void 0 && (s.onAddToCart = this.options.onAddToCart), this.options.chat?.onOpen !== void 0 && (s.onOpen = this.options.chat.onOpen), this.options.chat?.onClose !== void 0 && (s.onClose = this.options.chat.onClose), this._chat = new V(), await this._chat.init(s);
|
|
188
187
|
}
|
|
189
188
|
async _syncPdpWidgets() {
|
|
190
189
|
if (this._destroyed) return;
|
|
@@ -221,7 +220,7 @@ var ue = class {
|
|
|
221
220
|
this._qna?.destroy(), this._qna = null, this._warnedQnaMountMissing || (console.warn(`[gengage] QNA mount target not found: ${i}`), this._warnedQnaMountMissing = !0);
|
|
222
221
|
} else
|
|
223
222
|
this._qna?.destroy(), this._qna = null;
|
|
224
|
-
if (this.options.simrel
|
|
223
|
+
if (this.options.simrel !== void 0 && this.options.simrel.enabled !== !1) {
|
|
225
224
|
const i = this.options.simrel?.mountTarget ?? ae, s = I(i);
|
|
226
225
|
if (s)
|
|
227
226
|
if (this._warnedSimRelMountMissing = !1, this._simrel)
|
|
@@ -278,12 +277,12 @@ var ue = class {
|
|
|
278
277
|
}), t;
|
|
279
278
|
}
|
|
280
279
|
};
|
|
281
|
-
async function
|
|
280
|
+
async function ue(e) {
|
|
282
281
|
const t = B(e), i = S(), s = i.instances[t];
|
|
283
282
|
if (s) return s;
|
|
284
283
|
const o = i.pending[t];
|
|
285
284
|
if (o) return o;
|
|
286
|
-
const n = new
|
|
285
|
+
const n = new ce(e, () => {
|
|
287
286
|
const l = S();
|
|
288
287
|
delete l.instances[t], delete l.pending[t];
|
|
289
288
|
}), d = n.init().then(() => (i.instances[t] = n, delete i.pending[t], n)).catch((l) => {
|
|
@@ -380,7 +379,7 @@ function E(e, t, i) {
|
|
|
380
379
|
const o = e.document.createElement("div");
|
|
381
380
|
return o.id = i, e.document.body.appendChild(o), o;
|
|
382
381
|
}
|
|
383
|
-
function
|
|
382
|
+
function D(e, t) {
|
|
384
383
|
const i = e.webkit?.messageHandlers?.[t];
|
|
385
384
|
return i && typeof i.postMessage == "function" ? i.postMessage.bind(i) : null;
|
|
386
385
|
}
|
|
@@ -390,7 +389,7 @@ function w(e, t) {
|
|
|
390
389
|
}
|
|
391
390
|
function ve(e = {}) {
|
|
392
391
|
const t = e.win ?? window, i = e.iosHandlerName ?? "gengage", s = e.androidInterfaceName ?? "GengageNative", o = e.reactNativeInterfaceName ?? "ReactNativeWebView";
|
|
393
|
-
return
|
|
392
|
+
return D(t, i) ? "ios" : w(t, s) ? "android" : w(t, o) ? "react-native" : "browser";
|
|
394
393
|
}
|
|
395
394
|
function ye(e, t = {}) {
|
|
396
395
|
const i = t.win ?? window;
|
|
@@ -417,13 +416,13 @@ function _e(e = {}) {
|
|
|
417
416
|
reactNativeInterfaceName: n
|
|
418
417
|
});
|
|
419
418
|
let a = t.gengage?.overlay ?? null;
|
|
420
|
-
const
|
|
421
|
-
const p = r === void 0 ? { type:
|
|
422
|
-
type:
|
|
419
|
+
const u = [], v = (c, r) => {
|
|
420
|
+
const p = r === void 0 ? { type: c } : {
|
|
421
|
+
type: c,
|
|
423
422
|
payload: r
|
|
424
423
|
};
|
|
425
424
|
if (l === "ios") {
|
|
426
|
-
|
|
425
|
+
D(t, s)?.(p);
|
|
427
426
|
return;
|
|
428
427
|
}
|
|
429
428
|
if (l === "android") {
|
|
@@ -434,8 +433,8 @@ function _e(e = {}) {
|
|
|
434
433
|
w(t, n)?.postMessage(JSON.stringify(p));
|
|
435
434
|
return;
|
|
436
435
|
}
|
|
437
|
-
}, y = (
|
|
438
|
-
const r =
|
|
436
|
+
}, y = (c) => {
|
|
437
|
+
const r = c.detail;
|
|
439
438
|
!r || typeof r.namespace != "string" || typeof r.type != "string" || v("bridge_message", {
|
|
440
439
|
namespace: r.namespace,
|
|
441
440
|
type: r.type,
|
|
@@ -443,28 +442,28 @@ function _e(e = {}) {
|
|
|
443
442
|
});
|
|
444
443
|
};
|
|
445
444
|
t.addEventListener("gengage:bridge:message", y);
|
|
446
|
-
const
|
|
445
|
+
const O = d.map((c) => {
|
|
447
446
|
const r = (p) => {
|
|
448
447
|
const g = p.detail;
|
|
449
448
|
v("widget_event", {
|
|
450
|
-
event:
|
|
449
|
+
event: c,
|
|
451
450
|
detail: g
|
|
452
451
|
});
|
|
453
452
|
};
|
|
454
|
-
return t.addEventListener(
|
|
455
|
-
event:
|
|
453
|
+
return t.addEventListener(c, r), {
|
|
454
|
+
event: c,
|
|
456
455
|
handler: r
|
|
457
456
|
};
|
|
458
|
-
}), _ = (
|
|
459
|
-
|
|
460
|
-
},
|
|
461
|
-
if (!a ||
|
|
462
|
-
const
|
|
463
|
-
for (const r of
|
|
464
|
-
}, N = (
|
|
465
|
-
const r = fe(
|
|
457
|
+
}), _ = (c) => {
|
|
458
|
+
u.length >= pe && u.shift(), u.push(c);
|
|
459
|
+
}, F = () => {
|
|
460
|
+
if (!a || u.length === 0) return;
|
|
461
|
+
const c = u.splice(0, u.length);
|
|
462
|
+
for (const r of c) N(r);
|
|
463
|
+
}, N = (c) => {
|
|
464
|
+
const r = fe(c);
|
|
466
465
|
if (!r || typeof r.type != "string") {
|
|
467
|
-
console.warn("[gengage:native-bridge] Invalid message:",
|
|
466
|
+
console.warn("[gengage:native-bridge] Invalid message:", c);
|
|
468
467
|
return;
|
|
469
468
|
}
|
|
470
469
|
const p = r.type, g = r.payload;
|
|
@@ -506,28 +505,28 @@ function _e(e = {}) {
|
|
|
506
505
|
env: l,
|
|
507
506
|
sendToNative: v,
|
|
508
507
|
receive: N,
|
|
509
|
-
setController(
|
|
510
|
-
a =
|
|
508
|
+
setController(c) {
|
|
509
|
+
a = c, F();
|
|
511
510
|
},
|
|
512
511
|
destroy() {
|
|
513
512
|
t.removeEventListener("gengage:bridge:message", y);
|
|
514
|
-
for (const
|
|
515
|
-
|
|
513
|
+
for (const c of O) t.removeEventListener(c.event, c.handler);
|
|
514
|
+
u.splice(0, u.length), t.gengageNative === C && delete t.gengageNative;
|
|
516
515
|
}
|
|
517
516
|
};
|
|
518
517
|
return i.gengageNative = C, C;
|
|
519
518
|
}
|
|
520
519
|
async function xe(e) {
|
|
521
520
|
const { nativeBridge: t, emitReadyEvent: i = !0, ...s } = e, o = _e(t), n = { ...s };
|
|
522
|
-
n.onAddToCart || (n.onAddToCart = (
|
|
521
|
+
n.onAddToCart || (n.onAddToCart = (u) => {
|
|
523
522
|
o.sendToNative("addToCart", {
|
|
524
|
-
sku:
|
|
525
|
-
quantity:
|
|
526
|
-
cartCode:
|
|
523
|
+
sku: u.sku,
|
|
524
|
+
quantity: u.quantity,
|
|
525
|
+
cartCode: u.cartCode
|
|
527
526
|
});
|
|
528
|
-
}), n.onProductNavigate || (n.onProductNavigate = (
|
|
527
|
+
}), n.onProductNavigate || (n.onProductNavigate = (u, v, y) => {
|
|
529
528
|
o.sendToNative("productNavigate", {
|
|
530
|
-
url:
|
|
529
|
+
url: u,
|
|
531
530
|
sku: v,
|
|
532
531
|
sessionId: y
|
|
533
532
|
});
|
|
@@ -535,24 +534,24 @@ async function xe(e) {
|
|
|
535
534
|
const d = n.qna?.enabled === !0 || n.qna?.mountTarget !== void 0;
|
|
536
535
|
if (n.qna?.enabled !== !1)
|
|
537
536
|
if (d) {
|
|
538
|
-
const
|
|
537
|
+
const u = E(window, n.qna?.mountTarget ?? x, "gengage-qna");
|
|
539
538
|
n.qna = {
|
|
540
539
|
...n.qna,
|
|
541
540
|
enabled: !0,
|
|
542
|
-
mountTarget:
|
|
541
|
+
mountTarget: u
|
|
543
542
|
};
|
|
544
543
|
} else q(window, x) || (n.qna = { enabled: !1 });
|
|
545
544
|
const l = n.simrel?.enabled === !0 || n.simrel?.mountTarget !== void 0;
|
|
546
545
|
if (n.simrel?.enabled !== !1)
|
|
547
546
|
if (l) {
|
|
548
|
-
const
|
|
547
|
+
const u = E(window, n.simrel?.mountTarget ?? U, "gengage-simrel");
|
|
549
548
|
n.simrel = {
|
|
550
549
|
...n.simrel,
|
|
551
550
|
enabled: !0,
|
|
552
|
-
mountTarget:
|
|
551
|
+
mountTarget: u
|
|
553
552
|
};
|
|
554
553
|
} else q(window, U) || (n.simrel = { enabled: !1 });
|
|
555
|
-
const a = await
|
|
554
|
+
const a = await ue(n);
|
|
556
555
|
return o.setController(a), i && o.sendToNative("ready", {
|
|
557
556
|
sessionId: a.session.sessionId,
|
|
558
557
|
widgets: {
|
|
@@ -575,7 +574,7 @@ export {
|
|
|
575
574
|
ie as f,
|
|
576
575
|
qe as h,
|
|
577
576
|
ve as i,
|
|
578
|
-
|
|
577
|
+
ue as l,
|
|
579
578
|
se as m,
|
|
580
579
|
ye as n,
|
|
581
580
|
Me as o,
|