redgin-store 0.1.4 → 0.1.5

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
- var i=class{_state;_listeners=new Set;_pending=!1;_storageKey;constructor(t={},s=null){if(this._storageKey=s,this._storageKey){let e=localStorage.getItem(this._storageKey);this._state=e?JSON.parse(e):t}else this._state=t}get state(){return this._state}set(t,s){this._state[t]!==s&&(this._state={...this._state,[t]:s},this._storageKey&&localStorage.setItem(this._storageKey,JSON.stringify(this._state)),this._notify())}_notify(){this._pending||(this._pending=!0,queueMicrotask(()=>{this._pending=!1,this._listeners.forEach(t=>t(this._state))}))}subscribe(t){return this._listeners.add(t),()=>this.unsubscribe(t)}unsubscribe(t){this._listeners.delete(t)}};export{i as Store};
1
+ var o=class{_state;_listeners=new Set;_pending=!1;_storageKey;_debug;constructor(t={},e={}){if(this._storageKey=e.storageKey||null,this._debug=e.debug||!1,this._storageKey){let s=localStorage.getItem(this._storageKey);this._state=s?JSON.parse(s):t}else this._state=t}get state(){return this._state}set(t,e,s){if(this._state[t]!==e){if(this._debug){let i=window.__redgin_current_instance,r=s||(i?`<${i.localName}>`:"External/Async");console.log(`%c \u{1F534} RedGin Store: %c${t} %cby %c${r} %cupdated to:`,"color: #ff4757; font-weight: bold;","color: #2ed573; font-weight: bold; text-decoration: underline;","color: #7f8c8d;","color: #3498db; font-weight: bold;","color: #7f8c8d;",e)}this._state={...this._state,[t]:e},this._storageKey&&localStorage.setItem(this._storageKey,JSON.stringify(this._state)),this._notify()}}_notify(){this._pending||(this._pending=!0,queueMicrotask(()=>{this._pending=!1,this._listeners.forEach(t=>t(this._state))}))}subscribe(t){return this._listeners.add(t),()=>this.unsubscribe(t)}unsubscribe(t){this._listeners.delete(t)}clear(){this._storageKey&&localStorage.removeItem(this._storageKey),location.reload()}};export{o as Store};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redgin-store",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "./dist/redgin-store.min.js",
6
6
  "module": "./dist/redgin-store.min.js",