@marketrix.ai/widget 1.0.15 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAmCH,iBAAS,eAAe,IAAI,IAAI,CAW/B;AAUD,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA2BH,iBAAS,eAAe,IAAI,IAAI,CAW/B;AA6BD,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAYjD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAIL,gBAAgB,EASjB,MAAM,mBAAmB,CAAC;AAoF3B,eAAO,MAAM,UAAU,GACrB,QAAQ,eAAe,EACvB,YAAY,WAAW,KACtB,OAAO,CAAC,IAAI,CA+Gd,CAAC;AAKF,eAAO,MAAM,aAAa,QAAO,IAwBhC,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAAU,WAAW,OAAO,CAAC,eAAe,CAAC,KAAG,OAAO,CAAC,IAAI,CAW7F,CAAC;AAGF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA0E1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAU,QAAQ,eAAe,KAAG,OAAO,CAAC,IAAI,CA4CvE,CAAC;AAYF,YAAY,EAAE,eAAe,EAAE,MAAM,OA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W,KACtB,OAAO,CAAC,IAAI,CAAC;yBAoHiB,IAAI;uCA2BkB,OAAO,CAAC,eAAe,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC;;;AAwK/F,wBAOE"}
package/dist/index.mjs CHANGED
@@ -18885,8 +18885,13 @@ function handleApiError(error, context = "Operation", config) {
18885
18885
  };
18886
18886
  }
18887
18887
 
18888
- const isDevelopment = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes("localhost");
18889
- const MIN_LOG_LEVEL = isDevelopment ? "debug" : "error";
18888
+ const getIsDevelopment = () => {
18889
+ if (typeof window === "undefined") {
18890
+ return false;
18891
+ }
18892
+ return window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes("localhost");
18893
+ };
18894
+ const MIN_LOG_LEVEL = getIsDevelopment() ? "debug" : "error";
18890
18895
  const LOG_LEVELS = {
18891
18896
  debug: 0,
18892
18897
  info: 1,
@@ -19577,6 +19582,9 @@ class SessionManager {
19577
19582
  tabId = null;
19578
19583
  initializationPromise = null;
19579
19584
  constructor() {
19585
+ if (typeof window === "undefined" || typeof document === "undefined") {
19586
+ return;
19587
+ }
19580
19588
  this.tabId = this.getOrCreateTabId();
19581
19589
  log$1.debug("Tab ID:", this.tabId);
19582
19590
  this.chatId = this.getStoredChatId();
@@ -19590,6 +19598,9 @@ class SessionManager {
19590
19598
  * This ensures the same tab_id is preserved when navigating to external domains.
19591
19599
  */
19592
19600
  setupLinkInterceptor() {
19601
+ if (typeof document === "undefined") {
19602
+ return;
19603
+ }
19593
19604
  document.addEventListener(
19594
19605
  "click",
19595
19606
  (event) => {
@@ -19621,6 +19632,9 @@ class SessionManager {
19621
19632
  * 3. Generate new - for new tabs
19622
19633
  */
19623
19634
  getOrCreateTabId() {
19635
+ if (typeof window === "undefined" || typeof sessionStorage === "undefined") {
19636
+ return this.generateTabId();
19637
+ }
19624
19638
  const urlParams = new URLSearchParams(window.location.search);
19625
19639
  const urlTabId = urlParams.get("_mktx_tab");
19626
19640
  if (urlTabId) {
@@ -19641,6 +19655,9 @@ class SessionManager {
19641
19655
  * Remove _mktx_tab parameter from URL without page reload
19642
19656
  */
19643
19657
  cleanupTabIdFromUrl() {
19658
+ if (typeof window === "undefined") {
19659
+ return;
19660
+ }
19644
19661
  const url = new URL(window.location.href);
19645
19662
  if (url.searchParams.has("_mktx_tab")) {
19646
19663
  url.searchParams.delete("_mktx_tab");
@@ -19663,6 +19680,15 @@ class SessionManager {
19663
19680
  * Get singleton instance
19664
19681
  */
19665
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
+ }
19666
19692
  if (!SessionManager.instance) {
19667
19693
  SessionManager.instance = new SessionManager();
19668
19694
  }
@@ -19739,9 +19765,15 @@ class SessionManager {
19739
19765
  SessionManager.instance = null;
19740
19766
  }
19741
19767
  getStoredChatId() {
19768
+ if (typeof localStorage === "undefined") {
19769
+ return null;
19770
+ }
19742
19771
  return localStorage.getItem(CHAT_ID_STORAGE_KEY);
19743
19772
  }
19744
19773
  storeChatId(id) {
19774
+ if (typeof localStorage === "undefined") {
19775
+ return;
19776
+ }
19745
19777
  localStorage.setItem(CHAT_ID_STORAGE_KEY, id);
19746
19778
  }
19747
19779
  }
@@ -38634,6 +38666,9 @@ const clearWidgetState = () => {
38634
38666
  currentConfig = null;
38635
38667
  };
38636
38668
  const showWidgetSettingsLoader = (message) => {
38669
+ if (typeof window === "undefined" || typeof document === "undefined") {
38670
+ return;
38671
+ }
38637
38672
  if (loaderInstance) {
38638
38673
  const loaderContainer2 = document.getElementById("marketrix-widget-loader-container");
38639
38674
  if (loaderContainer2) {
@@ -38675,6 +38710,9 @@ const hideWidgetSettingsLoader = () => {
38675
38710
  };
38676
38711
  let initWidgetFunction = null;
38677
38712
  const autoInitializeWidget = (retryCount = 0) => {
38713
+ if (typeof window === "undefined" || typeof document === "undefined") {
38714
+ return;
38715
+ }
38678
38716
  const MAX_RETRIES = 5;
38679
38717
  const RETRY_DELAYS = [0, 100, 500, 1e3, 2e3];
38680
38718
  if (!initWidgetFunction) {
@@ -39040,13 +39078,15 @@ const mountWidget = async (config) => {
39040
39078
  );
39041
39079
  }
39042
39080
  };
39043
- setTimeout(() => {
39044
- try {
39045
- registerAutoInit(initWidget);
39046
- } catch (error) {
39047
- console.debug("Marketrix Widget: Auto-init registration skipped", error);
39048
- }
39049
- }, 0);
39081
+ if (typeof window !== "undefined") {
39082
+ setTimeout(() => {
39083
+ try {
39084
+ registerAutoInit(initWidget);
39085
+ } catch (error) {
39086
+ console.debug("Marketrix Widget: Auto-init registration skipped", error);
39087
+ }
39088
+ }, 0);
39089
+ }
39050
39090
  const index = {
39051
39091
  MarketrixWidget,
39052
39092
  mountWidget,