@marketrix.ai/widget 1.0.16 → 1.0.17
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/index.mjs
CHANGED
|
@@ -19582,6 +19582,9 @@ class SessionManager {
|
|
|
19582
19582
|
tabId = null;
|
|
19583
19583
|
initializationPromise = null;
|
|
19584
19584
|
constructor() {
|
|
19585
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
19586
|
+
return;
|
|
19587
|
+
}
|
|
19585
19588
|
this.tabId = this.getOrCreateTabId();
|
|
19586
19589
|
log$1.debug("Tab ID:", this.tabId);
|
|
19587
19590
|
this.chatId = this.getStoredChatId();
|
|
@@ -19595,6 +19598,9 @@ class SessionManager {
|
|
|
19595
19598
|
* This ensures the same tab_id is preserved when navigating to external domains.
|
|
19596
19599
|
*/
|
|
19597
19600
|
setupLinkInterceptor() {
|
|
19601
|
+
if (typeof document === "undefined") {
|
|
19602
|
+
return;
|
|
19603
|
+
}
|
|
19598
19604
|
document.addEventListener(
|
|
19599
19605
|
"click",
|
|
19600
19606
|
(event) => {
|
|
@@ -19626,6 +19632,9 @@ class SessionManager {
|
|
|
19626
19632
|
* 3. Generate new - for new tabs
|
|
19627
19633
|
*/
|
|
19628
19634
|
getOrCreateTabId() {
|
|
19635
|
+
if (typeof window === "undefined" || typeof sessionStorage === "undefined") {
|
|
19636
|
+
return this.generateTabId();
|
|
19637
|
+
}
|
|
19629
19638
|
const urlParams = new URLSearchParams(window.location.search);
|
|
19630
19639
|
const urlTabId = urlParams.get("_mktx_tab");
|
|
19631
19640
|
if (urlTabId) {
|
|
@@ -19646,6 +19655,9 @@ class SessionManager {
|
|
|
19646
19655
|
* Remove _mktx_tab parameter from URL without page reload
|
|
19647
19656
|
*/
|
|
19648
19657
|
cleanupTabIdFromUrl() {
|
|
19658
|
+
if (typeof window === "undefined") {
|
|
19659
|
+
return;
|
|
19660
|
+
}
|
|
19649
19661
|
const url = new URL(window.location.href);
|
|
19650
19662
|
if (url.searchParams.has("_mktx_tab")) {
|
|
19651
19663
|
url.searchParams.delete("_mktx_tab");
|
|
@@ -19668,6 +19680,15 @@ class SessionManager {
|
|
|
19668
19680
|
* Get singleton instance
|
|
19669
19681
|
*/
|
|
19670
19682
|
static getInstance() {
|
|
19683
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
19684
|
+
if (!SessionManager.instance) {
|
|
19685
|
+
SessionManager.instance = Object.create(SessionManager.prototype);
|
|
19686
|
+
SessionManager.instance.chatId = null;
|
|
19687
|
+
SessionManager.instance.tabId = null;
|
|
19688
|
+
SessionManager.instance.initializationPromise = null;
|
|
19689
|
+
}
|
|
19690
|
+
return SessionManager.instance;
|
|
19691
|
+
}
|
|
19671
19692
|
if (!SessionManager.instance) {
|
|
19672
19693
|
SessionManager.instance = new SessionManager();
|
|
19673
19694
|
}
|
|
@@ -19744,9 +19765,15 @@ class SessionManager {
|
|
|
19744
19765
|
SessionManager.instance = null;
|
|
19745
19766
|
}
|
|
19746
19767
|
getStoredChatId() {
|
|
19768
|
+
if (typeof localStorage === "undefined") {
|
|
19769
|
+
return null;
|
|
19770
|
+
}
|
|
19747
19771
|
return localStorage.getItem(CHAT_ID_STORAGE_KEY);
|
|
19748
19772
|
}
|
|
19749
19773
|
storeChatId(id) {
|
|
19774
|
+
if (typeof localStorage === "undefined") {
|
|
19775
|
+
return;
|
|
19776
|
+
}
|
|
19750
19777
|
localStorage.setItem(CHAT_ID_STORAGE_KEY, id);
|
|
19751
19778
|
}
|
|
19752
19779
|
}
|