@xapp/chat-widget 1.52.4 → 1.52.6

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.js CHANGED
@@ -31351,6 +31351,48 @@ function createDefaultState(state) {
31351
31351
  }
31352
31352
  var DEFAULT_STATE = createDefaultState();
31353
31353
 
31354
+ /**
31355
+ * Polyfill for Browser Local Storage
31356
+ *
31357
+ * Based on https://github.com/capaj/localstorage-polyfill/blob/master/localStorage.js
31358
+ */
31359
+ var LocalStorage = /** @class */ (function () {
31360
+ function LocalStorage() {
31361
+ this.valuesMap = new Map();
31362
+ }
31363
+ LocalStorage.prototype.getItem = function (key) {
31364
+ var stringKey = String(key);
31365
+ if (this.valuesMap.has(key)) {
31366
+ return String(this.valuesMap.get(stringKey));
31367
+ }
31368
+ return null;
31369
+ };
31370
+ LocalStorage.prototype.setItem = function (key, val) {
31371
+ this.valuesMap.set(String(key), String(val));
31372
+ };
31373
+ LocalStorage.prototype.removeItem = function (key) {
31374
+ this.valuesMap.delete(key);
31375
+ };
31376
+ LocalStorage.prototype.clear = function () {
31377
+ this.valuesMap.clear();
31378
+ };
31379
+ LocalStorage.prototype.key = function (i) {
31380
+ if (arguments.length === 0) {
31381
+ throw new TypeError("Failed to execute 'key' on 'Storage': 1 argument required, but only 0 present."); // this is a TypeError implemented on Chrome, Firefox throws Not enough arguments to Storage.key.
31382
+ }
31383
+ var arr = Array.from(this.valuesMap.keys());
31384
+ return arr[i];
31385
+ };
31386
+ Object.defineProperty(LocalStorage.prototype, "length", {
31387
+ get: function () {
31388
+ return this.valuesMap.size;
31389
+ },
31390
+ enumerable: false,
31391
+ configurable: true
31392
+ });
31393
+ return LocalStorage;
31394
+ }());
31395
+
31354
31396
  function persistStateReducer(storage, initialState, innerReducer) {
31355
31397
  var _a;
31356
31398
  var obj = (_a = storage.get()) !== null && _a !== void 0 ? _a : initialState;
@@ -31547,7 +31589,14 @@ function storeHandler(state, action) {
31547
31589
  }
31548
31590
 
31549
31591
  function createChatStore(config, dataStorage) {
31550
- if (dataStorage === void 0) { dataStorage = localStorage; }
31592
+ if (!dataStorage) {
31593
+ if (typeof window !== "undefined") {
31594
+ dataStorage = localStorage;
31595
+ }
31596
+ else {
31597
+ dataStorage = new LocalStorage();
31598
+ }
31599
+ }
31551
31600
  var connection = config.connection;
31552
31601
  var storage = new BrowserStateStorage(dataStorage, "xappchat.".concat(connection.serverUrl, ".").concat(connection.accountKey));
31553
31602
  var defaultState = createDefaultState({
@@ -31593,7 +31642,7 @@ function createStaticReducer(state) {
31593
31642
  return oldState;
31594
31643
  };
31595
31644
  }
31596
- var composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || redux.compose;
31645
+ var composeEnhancers = (globalThis === null || globalThis === void 0 ? void 0 : globalThis.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || redux.compose;
31597
31646
  var middlewares = [
31598
31647
  thunk__default["default"]
31599
31648
  ];