@gengage/assistant-fe 0.3.20 → 0.3.22
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/README.md +18 -6
- package/dist/{chat-CuPO9t-Z.cjs → chat-BF5pt6iX.cjs} +5 -5
- package/dist/{chat-yAf9OADM.js → chat-CHAi6Xej.js} +476 -480
- package/dist/chat.cjs +1 -1
- package/dist/chat.iife.js +17 -17
- package/dist/chat.js +1 -1
- package/dist/common/client.d.ts +4 -0
- package/dist/common/config-schema.d.ts +4 -0
- package/dist/common/overlay.d.ts +4 -0
- package/dist/common/widget-base.d.ts +6 -0
- package/dist/{common-C8NRcP7O.js → common-Ct6r0F2s.js} +35 -26
- package/dist/common-DXdLT4e0.cjs +1 -0
- package/dist/common.cjs +1 -1
- package/dist/common.js +6 -6
- package/dist/{connection-warning-CVZzlGJt.js → connection-warning-CHHi3BAf.js} +1 -1
- package/dist/{connection-warning-CL1CReZo.cjs → connection-warning-YQiIRXrz.cjs} +1 -1
- package/dist/{ga-datalayer-DkfsAHf9.cjs → ga-datalayer-BVppFxqk.cjs} +1 -1
- package/dist/{ga-datalayer-CgI6Kb_i.js → ga-datalayer-BwxWX-cr.js} +35 -32
- package/dist/index.cjs +1 -1
- package/dist/index.js +9 -9
- package/dist/native-webview-BaW1H_nZ.cjs +1 -0
- package/dist/{native-webview-B8vOoxns.js → native-webview-Cf5WtlIH.js} +72 -69
- package/dist/native.cjs +1 -1
- package/dist/native.iife.js +11 -11
- package/dist/native.js +1 -1
- package/dist/{qna-YSaIDxjs.js → qna-DXCQtwLq.js} +3 -3
- package/dist/{qna-KizG_W1J.cjs → qna-DwG8AJJf.cjs} +1 -1
- package/dist/qna.cjs +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{schemas-B6RjqKrg.cjs → schemas-B7jnyzQI.cjs} +1 -1
- package/dist/{schemas-PkedCk_-.js → schemas-CTbgsvNJ.js} +1 -1
- package/dist/simbut/index.d.ts +3 -0
- package/dist/{simbut-BI054QK0.js → simbut-BBXTlzOg.js} +28 -20
- package/dist/simbut-D_ycY_MQ.cjs +1 -0
- package/dist/simbut.cjs +1 -1
- package/dist/simbut.iife.js +8 -8
- package/dist/simbut.js +1 -1
- package/dist/{simrel-C-DKpfVB.js → simrel-DP2EMyua.js} +3 -3
- package/dist/{simrel-vL0woDkE.cjs → simrel-DdP4lur9.cjs} +1 -1
- package/dist/simrel.cjs +1 -1
- package/dist/simrel.iife.js +1 -1
- package/dist/simrel.js +1 -1
- package/package.json +1 -1
- package/dist/common-BzegEdJs.cjs +0 -1
- package/dist/native-webview-D2lDXTh3.cjs +0 -1
- package/dist/simbut-B2jXtckF.cjs +0 -1
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-
|
|
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-
|
|
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-
|
|
4
|
-
import { t as N } from "./connection-warning-
|
|
5
|
-
import { a as P, i as k, n as G, o as L, t as Q } from "./qna-
|
|
6
|
-
import { a as b, i as x, n as B, o as F, t as M } from "./simrel-
|
|
7
|
-
import { n as H, t as K } from "./simbut-
|
|
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-
|
|
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-
|
|
1
|
+
import { C as a, b as t, d as s, f as i, w as n, x as r } from "./schemas-CTbgsvNJ.js";
|
|
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-CHAi6Xej.js";
|
|
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-DXCQtwLq.js";
|
|
6
|
+
import { a as b, i as x, n as B, o as F, t as M } from "./simrel-DP2EMyua.js";
|
|
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-Cf5WtlIH.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-Ct6r0F2s.js";
|
|
10
10
|
export {
|
|
11
11
|
re as AccountRuntimeConfigSchema,
|
|
12
12
|
q as AnalyticsAuthModeSchema,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a=require("./schemas-B7jnyzQI.cjs"),m=require("./ga-datalayer-BVppFxqk.cjs"),K=require("./chat-BF5pt6iX.cjs"),$=require("./qna-DwG8AJJf.cjs"),G=require("./simrel-DdP4lur9.cjs"),Y=require("./simbut-D_ycY_MQ.cjs");var b=a.object({enabled:a.boolean().default(!0)}),J=a.object({chat:a.string().optional(),qna:a.string().optional(),simrel:a.string().optional(),simbut:a.string().optional()}),X=a.object({}),k=a._enum(["none","x-api-key-header","bearer-header","body-api-key"]),z=a.object({mode:k.default("none"),key:a.string().optional(),headerName:a.string().optional(),bodyField:a.string().default("api_key")}),Z=a.object({enabled:a.boolean().default(!0),endpoint:a.string().default("/analytics"),auth:z.default({mode:"none",bodyField:"api_key"}),fireAndForget:a.boolean().default(!0),useBeacon:a.boolean().default(!0),keepaliveFetch:a.boolean().default(!0),timeoutMs:a.number().int().positive().default(4e3),maxRetries:a.number().int().min(0).max(5).default(1)}),U="__gengageWidgetsInit",ee=a.object({idempotencyKey:a.string().default(U),requireDomReady:a.boolean().default(!0)}),O=a._enum(["log-and-ignore","throw","delegate"]),te=a.object({unknownActionPolicy:O.default("log-and-ignore"),allowScriptCall:a.boolean().default(!1)}),N=a.object({version:a.literal("1",{error:'version must be "1"'}),accountId:a.string({error:"accountId must be a non-empty string"}).min(1,{error:"accountId must be a non-empty string"}),middlewareUrl:a.string({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")'}),locale:a.string().optional(),widgets:a.object({chat:b.default({enabled:!0}),qna:b.default({enabled:!0}),simrel:b.default({enabled:!0}),simbut:b.default({enabled:!1})}),mounts:J.default({}),transport:X.default({}),analytics:Z.default({enabled:!0,endpoint:"/analytics",auth:{mode:"none",bodyField:"api_key"},fireAndForget:!0,useBeacon:!0,keepaliveFetch:!0,timeoutMs:4e3,maxRetries:1}),gtm:ee.default({idempotencyKey:"__gengageWidgetsInit",requireDomReady:!0}),actionHandling:te.default({unknownActionPolicy:"log-and-ignore",allowScriptCall:!1})});function P(e){m.debugLog("config","parsing account runtime config",e);const t=N.parse(e);return m.debugLog("config","config resolved",{accountId:t.accountId,middlewareUrl:t.middlewareUrl}),t}function ie(e){return N.safeParse(e)}function ne(e){return P({version:"1",accountId:e.accountId,middlewareUrl:e.middlewareUrl,locale:e.locale,widgets:{chat:{enabled:!0},qna:{enabled:!0},simrel:{enabled:!0},simbut:{enabled:!1}}})}var x=`${U}_overlay_`,se="#gengage-qna",oe="#gengage-simrel",ae="#gengage-simbut";function q(){const e=window;return e.__gengageOverlayRegistry||(e.__gengageOverlayRegistry={instances:{},pending:{}}),e.__gengageOverlayRegistry}function re(e){const t={pageType:e.pageContext?.pageType??(e.sku!==void 0?"pdp":"other")},i=e.pageContext;return i?.sku!==void 0&&(t.sku=i.sku),i?.price!==void 0&&(t.price=i.price),i?.categoryTree!==void 0&&(t.categoryTree=i.categoryTree),i?.url!==void 0&&(t.url=i.url),i?.extra!==void 0&&(t.extra=i.extra),e.sku!==void 0&&(t.sku=e.sku),t}function de(e,t){const i={...e,...t,pageType:t.pageType??e.pageType};return t.sku===void 0&&e.sku!==void 0&&(i.sku=e.sku),i}function T(e){return e instanceof HTMLElement||document.querySelector(e)?e:null}function R(e){return e.idempotencyKey??`${x}${e.accountId}`}var ue=class{constructor(e,t){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=R(e),this.session=m.resolveSession(e.session),this._pageContext=re(e)}get chat(){return this._chat}get qna(){return this._qna}get simrel(){return this._simrel}get simbut(){return this._simbut}get analyticsClient(){return this._analyticsClient}async init(){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.wireQNAToChat()),await this._syncPdpWidgets(),window.gengage.overlay=this}openChat(e){this._chat?.open(e)}closeChat(){this._chat?.close()}async updateContext(e){this._destroyed||await this._enqueue(async()=>{this._pageContext=de(this._pageContext,e),window.gengage||(window.gengage={}),window.gengage.pageContext=this._pageContext,this._chat?.update(e),this._qna?.update(e),this._simrel?.update(e),this._simbut?.update(e),await this._syncPdpWidgets()})}async updateSku(e,t="pdp"){await this.updateContext({sku:e,pageType:t})}destroy(){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())}async _initChat(){if(this.options.chat?.enabled===!1)return;const e=this.options.middlewareUrl,t=this.options.chat?.productDetailsExtended??this.options.productDetailsExtended,i=this.options.chat?.isDemoWebsite??this.options.isDemoWebsite,s={accountId:this.options.accountId,middlewareUrl:e,session:this.session,pageContext:this._pageContext,variant:this.options.chat?.variant??"floating"};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 K.GengageChat,await this._chat.init(s)}async _syncPdpWidgets(){if(this._destroyed)return;const e=this._pageContext.sku;if(!(this._pageContext.pageType==="pdp"&&e!==void 0&&e.length>0)){this._qna?.hide(),this._simrel?.hide(),this._simbut?.hide();return}const t=this.options.middlewareUrl;if(this.options.qna?.enabled!==!1){const i=this.options.qna?.mountTarget??se,s=T(i);if(s)if(this._warnedQnaMountMissing=!1,this._qna)this._qna.show(),this._qna.update({pageType:"pdp",sku:e});else{const o=new $.GengageQNA,n={accountId:this.options.accountId,middlewareUrl:t,session:this.session,pageContext:{pageType:"pdp",sku:e},mountTarget:s};this.options.theme!==void 0&&(n.theme=this.options.theme),this.options.qna?.ctaText!==void 0&&(n.ctaText=this.options.qna.ctaText),this.options.qna?.hideButtonRowCta!==void 0&&(n.hideButtonRowCta=this.options.qna.hideButtonRowCta),this.options.qna?.inputPlaceholder!==void 0&&(n.inputPlaceholder=this.options.qna.inputPlaceholder),this.options.qna?.i18n!==void 0&&(n.i18n=this.options.qna.i18n),this.options.qna?.renderer!==void 0&&(n.renderer=this.options.qna.renderer);const u=this.options.qna?.headerTitle??this.options.qna?.headingTitle;u!==void 0&&(n.headerTitle=u),await o.init(n),this._qna=o}else this._qna?.destroy(),this._qna=null,this._warnedQnaMountMissing||(console.warn(`[gengage] QNA mount target not found: ${i}`),this._warnedQnaMountMissing=!0)}else this._qna?.destroy(),this._qna=null;if(this.options.simrel?.enabled!==!1){const i=this.options.simrel?.mountTarget??oe,s=T(i);if(s)if(this._warnedSimRelMountMissing=!1,this._simrel)this._simrel.show(),this._simrel.update({pageType:"pdp",sku:e});else{const o=new G.GengageSimRel,n={accountId:this.options.accountId,middlewareUrl:t,session:this.session,sku:e,mountTarget:s};this.options.theme!==void 0&&(n.theme=this.options.theme),this.options.pricing!==void 0&&(n.pricing=this.options.pricing),this.options.simrel?.discountType!==void 0&&(n.discountType=this.options.simrel.discountType),this.options.simrel?.renderCardElement!==void 0&&(n.renderCardElement=this.options.simrel.renderCardElement),this.options.simrel?.renderer!==void 0&&(n.renderer=this.options.simrel.renderer),this.options.onAddToCart!==void 0&&(n.onAddToCart=this.options.onAddToCart),this.options.onProductNavigate!==void 0?n.onProductNavigate=this.options.onProductNavigate:n.onProductNavigate=(u,g,r)=>{m.isSafeUrl(u)&&(this._chat?.saveSession(r??this.session.sessionId,g),window.location.href=u)},await o.init(n),this._simrel=o}else this._simrel?.destroy(),this._simrel=null,this._warnedSimRelMountMissing||(console.warn(`[gengage] SimRel mount target not found: ${i}`),this._warnedSimRelMountMissing=!0)}else this._simrel?.destroy(),this._simrel=null;if(this.options.simbut&&this.options.simbut.enabled!==!1){const i=this.options.simbut.mountTarget??ae,s=T(i),o=this._chat??this.options.simbut.onFindSimilar;if(s&&o)if(this._warnedSimButMountMissing=!1,this._warnedSimButNoChat=!1,this._simbut)this._simbut.show(),this._simbut.setChat(this._chat),this._simbut.update({pageType:"pdp",sku:e});else{const n=new Y.GengageSimBut,u={accountId:this.options.accountId,middlewareUrl:t,session:this.session,pageContext:{pageType:"pdp",sku:e},mountTarget:s,chat:this._chat};this.options.theme!==void 0&&(u.theme=this.options.theme),this.options.locale!==void 0&&(u.locale=this.options.locale),this.options.simbut.imageUrl!==void 0&&(u.imageUrl=this.options.simbut.imageUrl),this.options.simbut.i18n!==void 0&&(u.i18n=this.options.simbut.i18n),this.options.simbut.onFindSimilar!==void 0&&(u.onFindSimilar=this.options.simbut.onFindSimilar),await n.init(u),this._simbut=n}else this._simbut?.destroy(),this._simbut=null,!s&&!this._warnedSimButMountMissing?(console.warn(`[gengage] SimBut mount target not found: ${i}`),this._warnedSimButMountMissing=!0):!o&&!this._warnedSimButNoChat&&(console.warn("[gengage] SimBut requires chat to be enabled or simbut.onFindSimilar"),this._warnedSimButNoChat=!0)}else this._simbut?.destroy(),this._simbut=null}_enqueue(e){const t=this._queue.then(e);return this._queue=t.catch(i=>{}),t}};async function B(e){const t=R(e),i=q(),s=i.instances[t];if(s)return s;const o=i.pending[t];if(o)return o;const n=new ue(e,()=>{const g=q();delete g.instances[t],delete g.pending[t]}),u=n.init().then(()=>(i.instances[t]=n,delete i.pending[t],n)).catch(g=>{throw delete i.pending[t],g});return i.pending[t]=u,u}function W(e){return q().instances[e]??null}function le(e){W(e)?.destroy()}function ce(e){return`${x}${e}`}var j=["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"],ge=32,M="#gengage-qna",A="#gengage-simrel";function he(e){let t=e;if(typeof e=="string"){const n=e.trim();if(n.length===0)return null;if(!n.startsWith("{")&&!n.startsWith("["))return{type:n};try{t=JSON.parse(n)}catch{return null}}if(!t||typeof t!="object")return null;const i=t,s=[i.type,i.command,i.action,i.event].find(n=>typeof n=="string"&&n.length>0);if(!s)return null;let o=i.payload;if(o===void 0&&"data"in i&&(o=i.data),s==="setSession"&&o===void 0){const n={};typeof i.sessionId=="string"&&(n.sessionId=i.sessionId),typeof i.userId=="string"&&(n.userId=i.userId),(n.sessionId!==void 0||n.userId!==void 0)&&(o=n)}return o===void 0?{type:s}:{type:s,payload:o}}function fe(e){if(typeof e=="string"&&e.length>0)return{sku:e};if(e&&typeof e=="object"&&"sku"in e){const t=e.sku;if(typeof t=="string"&&t.length>0){const i=e.pageType;return i!==void 0?{sku:t,pageType:i}:{sku:t}}}return null}function I(e,t){return t instanceof HTMLElement?!0:typeof t!="string"?!1:e.document.querySelector(t)!==null}function E(e,t,i){if(t instanceof HTMLElement||I(e,t)||typeof t!="string")return t;if(t.startsWith("#")){const n=t.slice(1);if(n.length>0){const u=e.document.getElementById(n);if(u)return u;const g=e.document.createElement("div");return g.id=n,e.document.body.appendChild(g),g}}const s=e.document.getElementById(i);if(s)return s;const o=e.document.createElement("div");return o.id=i,e.document.body.appendChild(o),o}function L(e,t){const i=e.webkit?.messageHandlers?.[t];return i&&typeof i.postMessage=="function"?i.postMessage.bind(i):null}function _(e,t){const i=e[t];return i&&typeof i=="object"&&typeof i.postMessage=="function"?i:null}function D(e={}){const t=e.win??window,i=e.iosHandlerName??"gengage",s=e.androidInterfaceName??"GengageNative",o=e.reactNativeInterfaceName??"ReactNativeWebView";return L(t,i)?"ios":_(t,s)?"android":_(t,o)?"react-native":"browser"}function F(e,t={}){const i=t.win??window;if(e.sessionId!==void 0){i.__gengageSessionId=e.sessionId,i.gengage||(i.gengage={}),i.gengage.sessionId=e.sessionId;try{i.sessionStorage.setItem("gengage_session_id",e.sessionId)}catch{}}if(e.userId!==void 0){i.gengage||(i.gengage={});const s=i.gengage,o=s.session??{};o.userId=e.userId,s.session=o}}function H(e={}){const t=e.win??window,i=t;if(i.gengageNative)return i.gengageNative;const s=e.iosHandlerName??"gengage",o=e.androidInterfaceName??"GengageNative",n=e.reactNativeInterfaceName??"ReactNativeWebView",u=e.trackedEvents??[...j],g=D({win:t,iosHandlerName:s,androidInterfaceName:o,reactNativeInterfaceName:n});let r=t.gengage?.overlay??null;const c=[],p=(l,d)=>{const f=d===void 0?{type:l}:{type:l,payload:d};if(g==="ios"){L(t,s)?.(f);return}if(g==="android"){_(t,o)?.postMessage(JSON.stringify(f));return}if(g==="react-native"){_(t,n)?.postMessage(JSON.stringify(f));return}},v=l=>{const d=l.detail;!d||typeof d.namespace!="string"||typeof d.type!="string"||p("bridge_message",{namespace:d.namespace,type:d.type,payload:d.payload})};t.addEventListener("gengage:bridge:message",v);const Q=u.map(l=>{const d=f=>{const h=f.detail;p("widget_event",{event:l,detail:h})};return t.addEventListener(l,d),{event:l,handler:d}}),y=l=>{c.length>=ge&&c.shift(),c.push(l)},V=()=>{if(!r||c.length===0)return;const l=c.splice(0,c.length);for(const d of l)S(d)},S=l=>{const d=he(l);if(!d||typeof d.type!="string"){console.warn("[gengage:native-bridge] Invalid message:",l);return}const f=d.type,h=d.payload;switch(f){case"openChat":r?r.openChat(h&&typeof h=="object"?h:h==="half"||h==="full"?{state:h}:void 0):y(d);return;case"closeChat":r?r.closeChat():y(d);return;case"updateContext":r&&h&&typeof h=="object"?r.updateContext(h):r?console.warn("[gengage:native-bridge] updateContext: missing payload"):y(d);return;case"updateSku":{const C=fe(h);if(r&&C){r.updateSku(C.sku,C.pageType);return}r?console.warn("[gengage:native-bridge] updateSku: missing sku"):y(d);return}case"setSession":h&&typeof h=="object"&&F(h,{win:t});return;case"destroy":r?.destroy();return;default:t.postMessage({gengage:"native",type:f,payload:h},t.location.origin),e.logUnhandled&&console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:",f)}},w={env:g,sendToNative:p,receive:S,setController(l){r=l,V()},destroy(){t.removeEventListener("gengage:bridge:message",v);for(const l of Q)t.removeEventListener(l.event,l.handler);c.splice(0,c.length),t.gengageNative===w&&delete t.gengageNative}};return i.gengageNative=w,w}async function pe(e){const{nativeBridge:t,emitReadyEvent:i=!0,...s}=e,o=H(t),n={...s};n.onAddToCart||(n.onAddToCart=c=>{o.sendToNative("addToCart",{sku:c.sku,quantity:c.quantity,cartCode:c.cartCode})}),n.onProductNavigate||(n.onProductNavigate=(c,p,v)=>{o.sendToNative("productNavigate",{url:c,sku:p,sessionId:v})});const u=n.qna?.enabled===!0||n.qna?.mountTarget!==void 0;if(n.qna?.enabled!==!1)if(u){const c=E(window,n.qna?.mountTarget??M,"gengage-qna");n.qna={...n.qna,enabled:!0,mountTarget:c}}else I(window,M)||(n.qna={enabled:!1});const g=n.simrel?.enabled===!0||n.simrel?.mountTarget!==void 0;if(n.simrel?.enabled!==!1)if(g){const c=E(window,n.simrel?.mountTarget??A,"gengage-simrel");n.simrel={...n.simrel,enabled:!0,mountTarget:c}}else I(window,A)||(n.simrel={enabled:!1});const r=await B(n);return o.setController(r),i&&o.sendToNative("ready",{sessionId:r.session.sessionId,widgets:{chat:r.chat!==null,qna:r.qna!==null,simrel:r.simrel!==null}}),{controller:r,bridge:o,destroy(){r.destroy(),o.destroy()}}}Object.defineProperty(exports,"AccountRuntimeConfigSchema",{enumerable:!0,get:function(){return N}});Object.defineProperty(exports,"AnalyticsAuthModeSchema",{enumerable:!0,get:function(){return k}});Object.defineProperty(exports,"DEFAULT_NATIVE_TRACKED_EVENTS",{enumerable:!0,get:function(){return j}});Object.defineProperty(exports,"UnknownActionPolicySchema",{enumerable:!0,get:function(){return O}});Object.defineProperty(exports,"applyNativeSession",{enumerable:!0,get:function(){return F}});Object.defineProperty(exports,"buildOverlayIdempotencyKey",{enumerable:!0,get:function(){return ce}});Object.defineProperty(exports,"createDefaultAccountRuntimeConfig",{enumerable:!0,get:function(){return ne}});Object.defineProperty(exports,"createNativeWebViewBridge",{enumerable:!0,get:function(){return H}});Object.defineProperty(exports,"destroyOverlayWidgets",{enumerable:!0,get:function(){return le}});Object.defineProperty(exports,"detectNativeEnvironment",{enumerable:!0,get:function(){return D}});Object.defineProperty(exports,"getOverlayWidgets",{enumerable:!0,get:function(){return W}});Object.defineProperty(exports,"initNativeOverlayWidgets",{enumerable:!0,get:function(){return pe}});Object.defineProperty(exports,"initOverlayWidgets",{enumerable:!0,get:function(){return B}});Object.defineProperty(exports,"parseAccountRuntimeConfig",{enumerable:!0,get:function(){return P}});Object.defineProperty(exports,"safeParseAccountRuntimeConfig",{enumerable:!0,get:function(){return ie}});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { a as M, c as h, i as D, o as f, r as m, t as x } from "./schemas-
|
|
2
|
-
import { I as H, M as Q, b as k, z as K } from "./ga-datalayer-
|
|
3
|
-
import { t as V } from "./chat-
|
|
4
|
-
import { t as j } from "./qna-
|
|
5
|
-
import { t as $ } from "./simrel-
|
|
6
|
-
import { t as G } from "./simbut-
|
|
7
|
-
var
|
|
1
|
+
import { a as M, c as h, i as D, o as f, r as m, t as x } from "./schemas-CTbgsvNJ.js";
|
|
2
|
+
import { I as H, M as Q, b as k, z as K } from "./ga-datalayer-BwxWX-cr.js";
|
|
3
|
+
import { t as V } from "./chat-CHAi6Xej.js";
|
|
4
|
+
import { t as j } from "./qna-DXCQtwLq.js";
|
|
5
|
+
import { t as $ } from "./simrel-DP2EMyua.js";
|
|
6
|
+
import { t as G } from "./simbut-BBXTlzOg.js";
|
|
7
|
+
var b = f({ enabled: m().default(!0) }), Y = f({
|
|
8
8
|
chat: h().optional(),
|
|
9
9
|
qna: h().optional(),
|
|
10
|
-
simrel: h().optional()
|
|
10
|
+
simrel: h().optional(),
|
|
11
|
+
simbut: h().optional()
|
|
11
12
|
}), J = f({}), X = x([
|
|
12
13
|
"none",
|
|
13
14
|
"x-api-key-header",
|
|
@@ -46,9 +47,10 @@ var T = f({ enabled: m().default(!0) }), Y = f({
|
|
|
46
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")' }),
|
|
47
48
|
locale: h().optional(),
|
|
48
49
|
widgets: f({
|
|
49
|
-
chat:
|
|
50
|
-
qna:
|
|
51
|
-
simrel:
|
|
50
|
+
chat: b.default({ enabled: !0 }),
|
|
51
|
+
qna: b.default({ enabled: !0 }),
|
|
52
|
+
simrel: b.default({ enabled: !0 }),
|
|
53
|
+
simbut: b.default({ enabled: !1 })
|
|
52
54
|
}),
|
|
53
55
|
mounts: Y.default({}),
|
|
54
56
|
transport: J.default({}),
|
|
@@ -94,7 +96,8 @@ function Se(e) {
|
|
|
94
96
|
widgets: {
|
|
95
97
|
chat: { enabled: !0 },
|
|
96
98
|
qna: { enabled: !0 },
|
|
97
|
-
simrel: { enabled: !0 }
|
|
99
|
+
simrel: { enabled: !0 },
|
|
100
|
+
simbut: { enabled: !1 }
|
|
98
101
|
}
|
|
99
102
|
});
|
|
100
103
|
}
|
|
@@ -168,14 +171,14 @@ var le = class {
|
|
|
168
171
|
}
|
|
169
172
|
async _initChat() {
|
|
170
173
|
if (this.options.chat?.enabled === !1) return;
|
|
171
|
-
const e = this.options.middlewareUrl, t = {
|
|
174
|
+
const e = this.options.middlewareUrl, t = this.options.chat?.productDetailsExtended ?? this.options.productDetailsExtended, i = this.options.chat?.isDemoWebsite ?? this.options.isDemoWebsite, s = {
|
|
172
175
|
accountId: this.options.accountId,
|
|
173
176
|
middlewareUrl: e,
|
|
174
177
|
session: this.session,
|
|
175
178
|
pageContext: this._pageContext,
|
|
176
179
|
variant: this.options.chat?.variant ?? "floating"
|
|
177
180
|
};
|
|
178
|
-
this.options.theme !== void 0 && (
|
|
181
|
+
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);
|
|
179
182
|
}
|
|
180
183
|
async _syncPdpWidgets() {
|
|
181
184
|
if (this._destroyed) return;
|
|
@@ -186,15 +189,15 @@ var le = class {
|
|
|
186
189
|
}
|
|
187
190
|
const t = this.options.middlewareUrl;
|
|
188
191
|
if (this.options.qna?.enabled !== !1) {
|
|
189
|
-
const i = this.options.qna?.mountTarget ?? se,
|
|
190
|
-
if (
|
|
192
|
+
const i = this.options.qna?.mountTarget ?? se, s = I(i);
|
|
193
|
+
if (s)
|
|
191
194
|
if (this._warnedQnaMountMissing = !1, this._qna)
|
|
192
195
|
this._qna.show(), this._qna.update({
|
|
193
196
|
pageType: "pdp",
|
|
194
197
|
sku: e
|
|
195
198
|
});
|
|
196
199
|
else {
|
|
197
|
-
const
|
|
200
|
+
const o = new j(), n = {
|
|
198
201
|
accountId: this.options.accountId,
|
|
199
202
|
middlewareUrl: t,
|
|
200
203
|
session: this.session,
|
|
@@ -202,43 +205,43 @@ var le = class {
|
|
|
202
205
|
pageType: "pdp",
|
|
203
206
|
sku: e
|
|
204
207
|
},
|
|
205
|
-
mountTarget:
|
|
208
|
+
mountTarget: s
|
|
206
209
|
};
|
|
207
210
|
this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.qna?.ctaText !== void 0 && (n.ctaText = this.options.qna.ctaText), this.options.qna?.hideButtonRowCta !== void 0 && (n.hideButtonRowCta = this.options.qna.hideButtonRowCta), this.options.qna?.inputPlaceholder !== void 0 && (n.inputPlaceholder = this.options.qna.inputPlaceholder), this.options.qna?.i18n !== void 0 && (n.i18n = this.options.qna.i18n), this.options.qna?.renderer !== void 0 && (n.renderer = this.options.qna.renderer);
|
|
208
211
|
const d = this.options.qna?.headerTitle ?? this.options.qna?.headingTitle;
|
|
209
|
-
d !== void 0 && (n.headerTitle = d), await
|
|
212
|
+
d !== void 0 && (n.headerTitle = d), await o.init(n), this._qna = o;
|
|
210
213
|
}
|
|
211
214
|
else
|
|
212
215
|
this._qna?.destroy(), this._qna = null, this._warnedQnaMountMissing || (console.warn(`[gengage] QNA mount target not found: ${i}`), this._warnedQnaMountMissing = !0);
|
|
213
216
|
} else
|
|
214
217
|
this._qna?.destroy(), this._qna = null;
|
|
215
218
|
if (this.options.simrel?.enabled !== !1) {
|
|
216
|
-
const i = this.options.simrel?.mountTarget ?? oe,
|
|
217
|
-
if (
|
|
219
|
+
const i = this.options.simrel?.mountTarget ?? oe, s = I(i);
|
|
220
|
+
if (s)
|
|
218
221
|
if (this._warnedSimRelMountMissing = !1, this._simrel)
|
|
219
222
|
this._simrel.show(), this._simrel.update({
|
|
220
223
|
pageType: "pdp",
|
|
221
224
|
sku: e
|
|
222
225
|
});
|
|
223
226
|
else {
|
|
224
|
-
const
|
|
227
|
+
const o = new $(), n = {
|
|
225
228
|
accountId: this.options.accountId,
|
|
226
229
|
middlewareUrl: t,
|
|
227
230
|
session: this.session,
|
|
228
231
|
sku: e,
|
|
229
|
-
mountTarget:
|
|
232
|
+
mountTarget: s
|
|
230
233
|
};
|
|
231
234
|
this.options.theme !== void 0 && (n.theme = this.options.theme), this.options.pricing !== void 0 && (n.pricing = this.options.pricing), this.options.simrel?.discountType !== void 0 && (n.discountType = this.options.simrel.discountType), this.options.simrel?.renderCardElement !== void 0 && (n.renderCardElement = this.options.simrel.renderCardElement), this.options.simrel?.renderer !== void 0 && (n.renderer = this.options.simrel.renderer), this.options.onAddToCart !== void 0 && (n.onAddToCart = this.options.onAddToCart), this.options.onProductNavigate !== void 0 ? n.onProductNavigate = this.options.onProductNavigate : n.onProductNavigate = (d, u, a) => {
|
|
232
235
|
K(d) && (this._chat?.saveSession(a ?? this.session.sessionId, u), window.location.href = d);
|
|
233
|
-
}, await
|
|
236
|
+
}, await o.init(n), this._simrel = o;
|
|
234
237
|
}
|
|
235
238
|
else
|
|
236
239
|
this._simrel?.destroy(), this._simrel = null, this._warnedSimRelMountMissing || (console.warn(`[gengage] SimRel mount target not found: ${i}`), this._warnedSimRelMountMissing = !0);
|
|
237
240
|
} else
|
|
238
241
|
this._simrel?.destroy(), this._simrel = null;
|
|
239
242
|
if (this.options.simbut && this.options.simbut.enabled !== !1) {
|
|
240
|
-
const i = this.options.simbut.mountTarget ?? ae,
|
|
241
|
-
if (
|
|
243
|
+
const i = this.options.simbut.mountTarget ?? ae, s = I(i), o = this._chat ?? this.options.simbut.onFindSimilar;
|
|
244
|
+
if (s && o)
|
|
242
245
|
if (this._warnedSimButMountMissing = !1, this._warnedSimButNoChat = !1, this._simbut)
|
|
243
246
|
this._simbut.show(), this._simbut.setChat(this._chat), this._simbut.update({
|
|
244
247
|
pageType: "pdp",
|
|
@@ -253,13 +256,13 @@ var le = class {
|
|
|
253
256
|
pageType: "pdp",
|
|
254
257
|
sku: e
|
|
255
258
|
},
|
|
256
|
-
mountTarget:
|
|
259
|
+
mountTarget: s,
|
|
257
260
|
chat: this._chat
|
|
258
261
|
};
|
|
259
262
|
this.options.theme !== void 0 && (d.theme = this.options.theme), this.options.locale !== void 0 && (d.locale = this.options.locale), this.options.simbut.imageUrl !== void 0 && (d.imageUrl = this.options.simbut.imageUrl), this.options.simbut.i18n !== void 0 && (d.i18n = this.options.simbut.i18n), this.options.simbut.onFindSimilar !== void 0 && (d.onFindSimilar = this.options.simbut.onFindSimilar), await n.init(d), this._simbut = n;
|
|
260
263
|
}
|
|
261
264
|
else
|
|
262
|
-
this._simbut?.destroy(), this._simbut = null, !
|
|
265
|
+
this._simbut?.destroy(), this._simbut = null, !s && !this._warnedSimButMountMissing ? (console.warn(`[gengage] SimBut mount target not found: ${i}`), this._warnedSimButMountMissing = !0) : !o && !this._warnedSimButNoChat && (console.warn("[gengage] SimBut requires chat to be enabled or simbut.onFindSimilar"), this._warnedSimButNoChat = !0);
|
|
263
266
|
} else
|
|
264
267
|
this._simbut?.destroy(), this._simbut = null;
|
|
265
268
|
}
|
|
@@ -270,10 +273,10 @@ var le = class {
|
|
|
270
273
|
}
|
|
271
274
|
};
|
|
272
275
|
async function ce(e) {
|
|
273
|
-
const t = P(e), i = q(),
|
|
274
|
-
if (o) return o;
|
|
275
|
-
const s = i.pending[t];
|
|
276
|
+
const t = P(e), i = q(), s = i.instances[t];
|
|
276
277
|
if (s) return s;
|
|
278
|
+
const o = i.pending[t];
|
|
279
|
+
if (o) return o;
|
|
277
280
|
const n = new le(e, () => {
|
|
278
281
|
const u = q();
|
|
279
282
|
delete u.instances[t], delete u.pending[t];
|
|
@@ -302,7 +305,7 @@ var ge = [
|
|
|
302
305
|
"gengage:similar:add-to-cart",
|
|
303
306
|
"gengage:global:error",
|
|
304
307
|
"gengage:context:update"
|
|
305
|
-
], he = 32, U = "#gengage-qna",
|
|
308
|
+
], he = 32, U = "#gengage-qna", E = "#gengage-simrel";
|
|
306
309
|
function pe(e) {
|
|
307
310
|
let t = e;
|
|
308
311
|
if (typeof e == "string") {
|
|
@@ -316,21 +319,21 @@ function pe(e) {
|
|
|
316
319
|
}
|
|
317
320
|
}
|
|
318
321
|
if (!t || typeof t != "object") return null;
|
|
319
|
-
const i = t,
|
|
322
|
+
const i = t, s = [
|
|
320
323
|
i.type,
|
|
321
324
|
i.command,
|
|
322
325
|
i.action,
|
|
323
326
|
i.event
|
|
324
327
|
].find((n) => typeof n == "string" && n.length > 0);
|
|
325
|
-
if (!
|
|
326
|
-
let
|
|
327
|
-
if (
|
|
328
|
+
if (!s) return null;
|
|
329
|
+
let o = i.payload;
|
|
330
|
+
if (o === void 0 && "data" in i && (o = i.data), s === "setSession" && o === void 0) {
|
|
328
331
|
const n = {};
|
|
329
|
-
typeof i.sessionId == "string" && (n.sessionId = i.sessionId), typeof i.userId == "string" && (n.userId = i.userId), (n.sessionId !== void 0 || n.userId !== void 0) && (
|
|
332
|
+
typeof i.sessionId == "string" && (n.sessionId = i.sessionId), typeof i.userId == "string" && (n.userId = i.userId), (n.sessionId !== void 0 || n.userId !== void 0) && (o = n);
|
|
330
333
|
}
|
|
331
|
-
return
|
|
332
|
-
type:
|
|
333
|
-
payload:
|
|
334
|
+
return o === void 0 ? { type: s } : {
|
|
335
|
+
type: s,
|
|
336
|
+
payload: o
|
|
334
337
|
};
|
|
335
338
|
}
|
|
336
339
|
function fe(e) {
|
|
@@ -350,7 +353,7 @@ function fe(e) {
|
|
|
350
353
|
function S(e, t) {
|
|
351
354
|
return t instanceof HTMLElement ? !0 : typeof t != "string" ? !1 : e.document.querySelector(t) !== null;
|
|
352
355
|
}
|
|
353
|
-
function
|
|
356
|
+
function A(e, t, i) {
|
|
354
357
|
if (t instanceof HTMLElement || S(e, t) || typeof t != "string") return t;
|
|
355
358
|
if (t.startsWith("#")) {
|
|
356
359
|
const n = t.slice(1);
|
|
@@ -361,10 +364,10 @@ function E(e, t, i) {
|
|
|
361
364
|
return u.id = n, e.document.body.appendChild(u), u;
|
|
362
365
|
}
|
|
363
366
|
}
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
366
|
-
const
|
|
367
|
-
return
|
|
367
|
+
const s = e.document.getElementById(i);
|
|
368
|
+
if (s) return s;
|
|
369
|
+
const o = e.document.createElement("div");
|
|
370
|
+
return o.id = i, e.document.body.appendChild(o), o;
|
|
368
371
|
}
|
|
369
372
|
function F(e, t) {
|
|
370
373
|
const i = e.webkit?.messageHandlers?.[t];
|
|
@@ -375,8 +378,8 @@ function w(e, t) {
|
|
|
375
378
|
return i && typeof i == "object" && typeof i.postMessage == "function" ? i : null;
|
|
376
379
|
}
|
|
377
380
|
function me(e = {}) {
|
|
378
|
-
const t = e.win ?? window, i = e.iosHandlerName ?? "gengage",
|
|
379
|
-
return F(t, i) ? "ios" : w(t,
|
|
381
|
+
const t = e.win ?? window, i = e.iosHandlerName ?? "gengage", s = e.androidInterfaceName ?? "GengageNative", o = e.reactNativeInterfaceName ?? "ReactNativeWebView";
|
|
382
|
+
return F(t, i) ? "ios" : w(t, s) ? "android" : w(t, o) ? "react-native" : "browser";
|
|
380
383
|
}
|
|
381
384
|
function ve(e, t = {}) {
|
|
382
385
|
const i = t.win ?? window;
|
|
@@ -389,17 +392,17 @@ function ve(e, t = {}) {
|
|
|
389
392
|
}
|
|
390
393
|
if (e.userId !== void 0) {
|
|
391
394
|
i.gengage || (i.gengage = {});
|
|
392
|
-
const
|
|
393
|
-
|
|
395
|
+
const s = i.gengage, o = s.session ?? {};
|
|
396
|
+
o.userId = e.userId, s.session = o;
|
|
394
397
|
}
|
|
395
398
|
}
|
|
396
399
|
function ye(e = {}) {
|
|
397
400
|
const t = e.win ?? window, i = t;
|
|
398
401
|
if (i.gengageNative) return i.gengageNative;
|
|
399
|
-
const
|
|
402
|
+
const s = e.iosHandlerName ?? "gengage", o = e.androidInterfaceName ?? "GengageNative", n = e.reactNativeInterfaceName ?? "ReactNativeWebView", d = e.trackedEvents ?? [...ge], u = me({
|
|
400
403
|
win: t,
|
|
401
|
-
iosHandlerName:
|
|
402
|
-
androidInterfaceName:
|
|
404
|
+
iosHandlerName: s,
|
|
405
|
+
androidInterfaceName: o,
|
|
403
406
|
reactNativeInterfaceName: n
|
|
404
407
|
});
|
|
405
408
|
let a = t.gengage?.overlay ?? null;
|
|
@@ -409,11 +412,11 @@ function ye(e = {}) {
|
|
|
409
412
|
payload: r
|
|
410
413
|
};
|
|
411
414
|
if (u === "ios") {
|
|
412
|
-
F(t,
|
|
415
|
+
F(t, s)?.(p);
|
|
413
416
|
return;
|
|
414
417
|
}
|
|
415
418
|
if (u === "android") {
|
|
416
|
-
w(t,
|
|
419
|
+
w(t, o)?.postMessage(JSON.stringify(p));
|
|
417
420
|
return;
|
|
418
421
|
}
|
|
419
422
|
if (u === "react-native") {
|
|
@@ -465,9 +468,9 @@ function ye(e = {}) {
|
|
|
465
468
|
a && g && typeof g == "object" ? a.updateContext(g) : a ? console.warn("[gengage:native-bridge] updateContext: missing payload") : _(r);
|
|
466
469
|
return;
|
|
467
470
|
case "updateSku": {
|
|
468
|
-
const
|
|
469
|
-
if (a &&
|
|
470
|
-
a.updateSku(
|
|
471
|
+
const T = fe(g);
|
|
472
|
+
if (a && T) {
|
|
473
|
+
a.updateSku(T.sku, T.pageType);
|
|
471
474
|
return;
|
|
472
475
|
}
|
|
473
476
|
a ? console.warn("[gengage:native-bridge] updateSku: missing sku") : _(r);
|
|
@@ -486,7 +489,7 @@ function ye(e = {}) {
|
|
|
486
489
|
payload: g
|
|
487
490
|
}, t.location.origin), e.logUnhandled && console.warn("[gengage:native-bridge] Unhandled inbound type forwarded:", p);
|
|
488
491
|
}
|
|
489
|
-
},
|
|
492
|
+
}, C = {
|
|
490
493
|
env: u,
|
|
491
494
|
sendToNative: v,
|
|
492
495
|
receive: N,
|
|
@@ -496,21 +499,21 @@ function ye(e = {}) {
|
|
|
496
499
|
destroy() {
|
|
497
500
|
t.removeEventListener("gengage:bridge:message", y);
|
|
498
501
|
for (const l of L) t.removeEventListener(l.event, l.handler);
|
|
499
|
-
c.splice(0, c.length), t.gengageNative ===
|
|
502
|
+
c.splice(0, c.length), t.gengageNative === C && delete t.gengageNative;
|
|
500
503
|
}
|
|
501
504
|
};
|
|
502
|
-
return i.gengageNative =
|
|
505
|
+
return i.gengageNative = C, C;
|
|
503
506
|
}
|
|
504
507
|
async function ke(e) {
|
|
505
|
-
const { nativeBridge: t, emitReadyEvent: i = !0, ...
|
|
508
|
+
const { nativeBridge: t, emitReadyEvent: i = !0, ...s } = e, o = ye(t), n = { ...s };
|
|
506
509
|
n.onAddToCart || (n.onAddToCart = (c) => {
|
|
507
|
-
|
|
510
|
+
o.sendToNative("addToCart", {
|
|
508
511
|
sku: c.sku,
|
|
509
512
|
quantity: c.quantity,
|
|
510
513
|
cartCode: c.cartCode
|
|
511
514
|
});
|
|
512
515
|
}), n.onProductNavigate || (n.onProductNavigate = (c, v, y) => {
|
|
513
|
-
|
|
516
|
+
o.sendToNative("productNavigate", {
|
|
514
517
|
url: c,
|
|
515
518
|
sku: v,
|
|
516
519
|
sessionId: y
|
|
@@ -519,7 +522,7 @@ async function ke(e) {
|
|
|
519
522
|
const d = n.qna?.enabled === !0 || n.qna?.mountTarget !== void 0;
|
|
520
523
|
if (n.qna?.enabled !== !1)
|
|
521
524
|
if (d) {
|
|
522
|
-
const c =
|
|
525
|
+
const c = A(window, n.qna?.mountTarget ?? U, "gengage-qna");
|
|
523
526
|
n.qna = {
|
|
524
527
|
...n.qna,
|
|
525
528
|
enabled: !0,
|
|
@@ -529,15 +532,15 @@ async function ke(e) {
|
|
|
529
532
|
const u = n.simrel?.enabled === !0 || n.simrel?.mountTarget !== void 0;
|
|
530
533
|
if (n.simrel?.enabled !== !1)
|
|
531
534
|
if (u) {
|
|
532
|
-
const c =
|
|
535
|
+
const c = A(window, n.simrel?.mountTarget ?? E, "gengage-simrel");
|
|
533
536
|
n.simrel = {
|
|
534
537
|
...n.simrel,
|
|
535
538
|
enabled: !0,
|
|
536
539
|
mountTarget: c
|
|
537
540
|
};
|
|
538
|
-
} else S(window,
|
|
541
|
+
} else S(window, E) || (n.simrel = { enabled: !1 });
|
|
539
542
|
const a = await ce(n);
|
|
540
|
-
return
|
|
543
|
+
return o.setController(a), i && o.sendToNative("ready", {
|
|
541
544
|
sessionId: a.session.sessionId,
|
|
542
545
|
widgets: {
|
|
543
546
|
chat: a.chat !== null,
|
|
@@ -546,9 +549,9 @@ async function ke(e) {
|
|
|
546
549
|
}
|
|
547
550
|
}), {
|
|
548
551
|
controller: a,
|
|
549
|
-
bridge:
|
|
552
|
+
bridge: o,
|
|
550
553
|
destroy() {
|
|
551
|
-
a.destroy(),
|
|
554
|
+
a.destroy(), o.destroy();
|
|
552
555
|
}
|
|
553
556
|
};
|
|
554
557
|
}
|
package/dist/native.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./native-webview-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./native-webview-BaW1H_nZ.cjs");exports.DEFAULT_NATIVE_TRACKED_EVENTS=e.DEFAULT_NATIVE_TRACKED_EVENTS;exports.applyNativeSession=e.applyNativeSession;exports.createNativeWebViewBridge=e.createNativeWebViewBridge;exports.detectNativeEnvironment=e.detectNativeEnvironment;exports.initNativeOverlayWidgets=e.initNativeOverlayWidgets;
|