@moonbase.sh/storefront-api 0.3.21 → 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/dist/index.cjs CHANGED
@@ -1033,6 +1033,32 @@ var LocalStorageStore = class {
1033
1033
  }
1034
1034
  }
1035
1035
  };
1036
+ var InMemoryStore = class {
1037
+ constructor() {
1038
+ this.store = {};
1039
+ this.listeners = {};
1040
+ }
1041
+ get(key) {
1042
+ var _a;
1043
+ return (_a = this.store[key]) != null ? _a : null;
1044
+ }
1045
+ set(key, item) {
1046
+ this.store[key] = item;
1047
+ for (const listener of this.listeners[key] || []) {
1048
+ listener(item);
1049
+ }
1050
+ }
1051
+ remove(key) {
1052
+ delete this.store[key];
1053
+ for (const listener of this.listeners[key] || []) {
1054
+ listener(null);
1055
+ }
1056
+ }
1057
+ listen(key, callback) {
1058
+ if (!this.listeners[key]) this.listeners[key] = [];
1059
+ this.listeners[key].push(callback);
1060
+ }
1061
+ };
1036
1062
 
1037
1063
  // src/utils/tokenStore.ts
1038
1064
  var _TokenStore = class _TokenStore {
@@ -1042,7 +1068,7 @@ var _TokenStore = class _TokenStore {
1042
1068
  this.refreshTimeoutId = null;
1043
1069
  this.refreshPromise = null;
1044
1070
  var _a;
1045
- this.store = (_a = configuration.store) != null ? _a : new LocalStorageStore();
1071
+ this.store = ((_a = configuration.store) != null ? _a : localStorage) ? new LocalStorageStore() : new InMemoryStore();
1046
1072
  const storedToken = this.store.get(_TokenStore.storageKey);
1047
1073
  if (storedToken) {
1048
1074
  this.tokens = {
package/dist/index.js CHANGED
@@ -985,6 +985,32 @@ var LocalStorageStore = class {
985
985
  }
986
986
  }
987
987
  };
988
+ var InMemoryStore = class {
989
+ constructor() {
990
+ this.store = {};
991
+ this.listeners = {};
992
+ }
993
+ get(key) {
994
+ var _a;
995
+ return (_a = this.store[key]) != null ? _a : null;
996
+ }
997
+ set(key, item) {
998
+ this.store[key] = item;
999
+ for (const listener of this.listeners[key] || []) {
1000
+ listener(item);
1001
+ }
1002
+ }
1003
+ remove(key) {
1004
+ delete this.store[key];
1005
+ for (const listener of this.listeners[key] || []) {
1006
+ listener(null);
1007
+ }
1008
+ }
1009
+ listen(key, callback) {
1010
+ if (!this.listeners[key]) this.listeners[key] = [];
1011
+ this.listeners[key].push(callback);
1012
+ }
1013
+ };
988
1014
 
989
1015
  // src/utils/tokenStore.ts
990
1016
  var _TokenStore = class _TokenStore {
@@ -994,7 +1020,7 @@ var _TokenStore = class _TokenStore {
994
1020
  this.refreshTimeoutId = null;
995
1021
  this.refreshPromise = null;
996
1022
  var _a;
997
- this.store = (_a = configuration.store) != null ? _a : new LocalStorageStore();
1023
+ this.store = ((_a = configuration.store) != null ? _a : localStorage) ? new LocalStorageStore() : new InMemoryStore();
998
1024
  const storedToken = this.store.get(_TokenStore.storageKey);
999
1025
  if (storedToken) {
1000
1026
  this.tokens = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/storefront-api",
3
3
  "type": "module",
4
- "version": "0.3.21",
4
+ "version": "0.3.22",
5
5
  "description": "Package to let you build storefronts with Moonbase.sh as payment and delivery provider",
6
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
7
7
  "license": "MIT",