@ryangjchandler/spruce
Advanced tools
Comparing version 2.5.1 to 2.5.3
@@ -1,2 +0,2 @@ | ||
"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e=function(e,t){return function(e,t){e.exports=function(){var e=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;function t(e){var t,r=e.replace(/^v/,"").replace(/\+.*$/,""),s=-1===(t=r).indexOf("-")?t.length:t.indexOf("-"),n=r.substring(0,s).split(".");return n.push(r.substring(s+1)),n}function r(e){return isNaN(Number(e))?e:Number(e)}function s(t){if("string"!=typeof t)throw new TypeError("Invalid argument expected string");if(!e.test(t))throw new Error("Invalid argument not valid semver ('"+t+"' received)")}function n(e,n){[e,n].forEach(s);for(var i=t(e),o=t(n),a=0;a<Math.max(i.length-1,o.length-1);a++){var c=parseInt(i[a]||0,10),u=parseInt(o[a]||0,10);if(c>u)return 1;if(u>c)return-1}var h=i[i.length-1],f=o[o.length-1];if(h&&f){var d=h.split(".").map(r),l=f.split(".").map(r);for(a=0;a<Math.max(d.length,l.length);a++){if(void 0===d[a]||"string"==typeof l[a]&&"number"==typeof d[a])return-1;if(void 0===l[a]||"string"==typeof d[a]&&"number"==typeof l[a])return 1;if(d[a]>l[a])return 1;if(l[a]>d[a])return-1}}else if(h||f)return h?-1:1;return 0}var i=[">",">=","=","<","<="],o={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]};return n.validate=function(t){return"string"==typeof t&&e.test(t)},n.compare=function(e,t,r){!function(e){if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===i.indexOf(e))throw new TypeError("Invalid operator, expected one of "+i.join("|"))}(r);var s=n(e,t);return o[r].indexOf(s)>-1},n}()}(t={exports:{}}),t.exports}(),t=function(e){return null==e},r=function(e){return Object.getPrototypeOf(e)===Object.prototype},s=function(e){return Array.isArray(e)},n=function(e,i){return Object.entries(e).forEach(function(o){var a=o[0],c=o[1];t(c)||!r(c)&&!s(c)||(e[a]=n(c,i))}),new Proxy(e,{get:function(e,t,r){return i.get(e,t,r)},set:function(e,s,o,a){return!t(o)&&r(o)&&(o=n(o,i)),i.set(e,s,e[s]=o,a),!0}})},i={stores:{},persistenceDriver:window.localStorage,persisted:[],subscribers:[],watchers:{},disableReactivity:!1,startingCallbacks:[],startedCallbacks:[],hasStarted:!1,start:function(){var e=this;this.startingCallbacks.forEach(function(e){return e()}),this.attach(),this.stores=n(this.stores,{get:function(t,r,s){return["get","set","toggle","clear"].includes(r)?e[r].bind(e):Reflect.get(t,r,s)},set:function(t,r,s,n){if(!e.disableReactivity){e.updateSubscribers(),e.runWatchers(t,r,s,n),e.disableReactivity=!0;try{e.persisted.forEach(e.updateLocalStorage.bind(e))}catch(e){}e.disableReactivity=!1}}}),this.hasStarted=!0,this.disableReactivity=!0,Object.entries(this.watchers).forEach(function(t){var r=t[0];t[1].forEach(function(t){return e.watch(r,t)})}),this.disableReactivity=!1,this.startedCallbacks.forEach(function(e){return e()})},starting:function(e){this.startingCallbacks.push(e)},started:function(e){this.startedCallbacks.push(e)},attach:function(){if(!(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")||window.Alpine&&e.compare(window.Alpine.version,"2.7.0",">=")))throw new Error("[Spruce] You must be using Alpine >= 2.5.0 to use Spruce.");var t=this;window.Alpine.addMagicProperty("store",function(e){return t.subscribe(e),t.stores})},store:function(e,t,r){if(void 0===r&&(r=!1),"function"==typeof t&&(t=t()),r)try{this.stores[e]=this.retrieveFromLocalStorage(e,(s={},Object.entries(t).filter(function(e){return"function"==typeof e[1]}).forEach(function(e){return s[e[0]]=e[1]}),s)),this.persisted.includes(e)||this.persisted.push(e)}catch(e){}var s;return this.stores[e]||(this.stores[e]=t),this.stores[e]},reset:function(e,t){this.runWatchers(this.stores[e],"__self",t),t.__watchers||(t.__watchers=this.stores[e].__watchers),this.stores[e]=t},subscribe:function(e){return this.subscribers.includes(e)||this.subscribers.push(e),this.stores},updateSubscribers:function(){this.subscribers.filter(function(e){return!!e.__x}).forEach(function(e){e.__x.updateElements(e)})},retrieveFromLocalStorage:function(e,t){void 0===t&&(t={});var r=this.persistenceDriver.getItem("__spruce:"+e);if(!r)return null;var s=JSON.parse(r);return"object"==typeof s&&(delete(s=Object.assign(t,s)).__watchers,delete s.__key_name),s},updateLocalStorage:function(e){var t=this.store(e);delete t.__watchers,delete t.__key_name,this.persistenceDriver.setItem("__spruce:"+e,JSON.stringify(this.store(e)))},get:function(e,t){return void 0===t&&(t=this.stores),e.split(".").reduce(function(e,t){return e[t]},t)},set:function(e,t,r){return void 0===r&&(r=this.stores),s(e)||(e=e.split(".")),1===e.length?r[e[0]]=t:r[e[0]]?this.set(e.slice(1),t,r[e[0]]):(r[e[0]]={},this.set(e.slice(1),t,r[e[0]]))},toggle:function(e){return this.set(e,!this.get(e))},clear:function(e){return this.persistenceDriver.removeItem("__spruce:"+e)},watch:function(e,n){if(!this.hasStarted)return this.watchers[e]||(this.watchers[e]=[]),void this.watchers[e].push(n);var i=e.split("."),o=i.reduce(function(e,n){var i=e[n];return t(i)||!r(i)&&!s(i)?e:i},this.stores),a=Object.is(o,this.get(e))?"__self":i[i.length-1];o.__watchers||(o.__watchers=new Map),o.__watchers.has(a)||o.__watchers.set(a,new Set),o.__watchers.get(a).add(n)},runWatchers:function(e,t,r){e.__watchers&&(e.__watchers.has(t)&&"__self"!==t&&e.__watchers.get(t).forEach(function(e){return e(r)}),e.__watchers.has("__self")&&e.__watchers.get("__self").forEach(function(e){return e(r,t)}))},persistUsing:function(e){if(this.persisted.length>0&&console.warn("[Spruce] You have already initialised a persisted store. Changing the driver may cause issues."),"function"!=typeof e.getItem)throw new Error("[Spruce] The persistence driver must have a `getItem(key)` method.");if("function"!=typeof e.setItem)throw new Error("[Spruce] The persistence driver must have a `setItem(key, value)` method.");if("function"!=typeof e.removeItem)throw new Error("[Spruce] The persistence driver must have a `removeItem(name)` method.");this.persistenceDriver=e}};window.Spruce=i;var o=window.deferLoadingAlpine||function(e){e()};window.deferLoadingAlpine=function(e){window.Spruce.start(),o(e)},module.exports=i; | ||
function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r=function(e,t){return function(e,t){e.exports=function(){var e=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;function t(e){var t,r=e.replace(/^v/,"").replace(/\+.*$/,""),n=-1===(t=r).indexOf("-")?t.length:t.indexOf("-"),i=r.substring(0,n).split(".");return i.push(r.substring(n+1)),i}function r(e){return isNaN(Number(e))?e:Number(e)}function n(t){if("string"!=typeof t)throw new TypeError("Invalid argument expected string");if(!e.test(t))throw new Error("Invalid argument not valid semver ('"+t+"' received)")}function i(e,i){[e,i].forEach(n);for(var s=t(e),o=t(i),a=0;a<Math.max(s.length-1,o.length-1);a++){var c=parseInt(s[a]||0,10),u=parseInt(o[a]||0,10);if(c>u)return 1;if(u>c)return-1}var f=s[s.length-1],h=o[o.length-1];if(f&&h){var p=f.split(".").map(r),l=h.split(".").map(r);for(a=0;a<Math.max(p.length,l.length);a++){if(void 0===p[a]||"string"==typeof l[a]&&"number"==typeof p[a])return-1;if(void 0===l[a]||"string"==typeof p[a]&&"number"==typeof l[a])return 1;if(p[a]>l[a])return 1;if(l[a]>p[a])return-1}}else if(f||h)return f?-1:1;return 0}var s=[">",">=","=","<","<="],o={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]};return i.validate=function(t){return"string"==typeof t&&e.test(t)},i.compare=function(e,t,r){!function(e){if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===s.indexOf(e))throw new TypeError("Invalid operator, expected one of "+s.join("|"))}(r);var n=i(e,t);return o[r].indexOf(n)>-1},i}()}(t={exports:{}}),t.exports}(),n=function(e){return null==e},i=function(e){return Object.getPrototypeOf(e)===Object.prototype},s=function(e){return Array.isArray(e)},o=function(e,t){return Object.entries(e).forEach(function(r){var a=r[0],c=r[1];n(c)||!i(c)&&!s(c)||(e[a]=o(c,t))}),new Proxy(e,{get:function(e,r,n){return t.get(e,r,n)},set:function(e,r,s,a){return!n(s)&&i(s)&&(s=o(s,t)),t.set(e,r,e[r]=s,a),!0}})},a={stores:{},persistenceDriver:window.localStorage,persisted:[],subscribers:[],watchers:{},disableReactivity:!1,startingCallbacks:[],startedCallbacks:[],hasStarted:!1,start:function(){var e=this;this.startingCallbacks.forEach(function(e){return e()}),this.attach(),this.stores=o(this.stores,{get:function(t,r,n){return Object.is(n,e.stores)&&["get","set","toggle","clear"].includes(r)?e[r].bind(e):Reflect.get(t,r,n)},set:function(t,r,n,i){if(!e.disableReactivity){e.updateSubscribers(),e.runWatchers(t,r,n,i),e.disableReactivity=!0;try{e.persisted.forEach(e.updateLocalStorage.bind(e))}catch(e){}e.disableReactivity=!1}}}),this.hasStarted=!0,this.disableReactivity=!0,Object.entries(this.watchers).forEach(function(t){var r=t[0];t[1].forEach(function(t){return e.watch(r,t)})}),this.disableReactivity=!1,this.startedCallbacks.forEach(function(e){return e()})},starting:function(e){this.startingCallbacks.push(e)},started:function(e){this.startedCallbacks.push(e)},attach:function(){if(!(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")||window.Alpine&&r.compare(window.Alpine.version,"2.7.0",">=")))throw new Error("[Spruce] You must be using Alpine >= 2.5.0 to use Spruce.");var e=this;window.Alpine.addMagicProperty("store",function(t){return e.subscribe(t),e.stores})},store:function(e,t,r){if(void 0===r&&(r=!1),"function"==typeof t&&(t=t()),r)try{this.stores[e]=this.retrieveFromLocalStorage(e,(n={},Object.entries(t).filter(function(e){return"function"==typeof e[1]}).forEach(function(e){return n[e[0]]=e[1]}),n)),this.persisted.includes(e)||this.persisted.push(e)}catch(e){}var n;return this.stores[e]||(this.stores[e]=t),this.stores[e]},reset:function(e,t){this.stores[e]&&(this.stores[e]=t)},subscribe:function(e){return this.subscribers.includes(e)||this.subscribers.push(e),this.stores},updateSubscribers:function(){this.subscribers.filter(function(e){return!!e.__x}).forEach(function(e){e.__x.updateElements(e)})},retrieveFromLocalStorage:function(e,t){void 0===t&&(t={});var r=this.persistenceDriver.getItem("__spruce:"+e);if(!r)return null;var n=JSON.parse(r);return"object"==typeof n&&(delete(n=Object.assign(t,n)).__watchers,delete n.__key_name),n},updateLocalStorage:function(r){var n=function(r){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?t(Object(i),!0).forEach(function(t){e(r,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}({},this.store(r));delete n.__watchers,delete n.__key_name,this.persistenceDriver.setItem("__spruce:"+r,JSON.stringify(this.store(r)))},get:function(e,t){return void 0===t&&(t=this.stores),e.split(".").reduce(function(e,t){return e[t]},t)},set:function(e,t,r){return void 0===r&&(r=this.stores),s(e)||(e=e.split(".")),1===e.length?r[e[0]]=t:r[e[0]]?this.set(e.slice(1),t,r[e[0]]):(r[e[0]]={},this.set(e.slice(1),t,r[e[0]]))},toggle:function(e){return this.set(e,!this.get(e))},clear:function(e){return this.persistenceDriver.removeItem("__spruce:"+e)},watch:function(e,t){if(!this.hasStarted)return this.watchers[e]||(this.watchers[e]=[]),void this.watchers[e].push(t);var r=e.split("."),o=r.reduce(function(e,t){var r=e[t];return n(r)||!i(r)&&!s(r)?e:r},this.stores),a=Object.is(o,this.get(e))?"__self":r[r.length-1];o.__watchers||(o.__watchers=new Map),o.__watchers.has(a)||o.__watchers.set(a,new Set),o.__watchers.get(a).add(t)},runWatchers:function(e,t,r){e.__watchers&&(e.__watchers.has(t)&&e.__watchers.get(t).forEach(function(e){return e(r)}),e.__watchers.has("__self")&&e.__watchers.get("__self").forEach(function(e){return e(r,t)}))},persistUsing:function(e){if(this.persisted.length>0&&console.warn("[Spruce] You have already initialised a persisted store. Changing the driver may cause issues."),"function"!=typeof e.getItem)throw new Error("[Spruce] The persistence driver must have a `getItem(key)` method.");if("function"!=typeof e.setItem)throw new Error("[Spruce] The persistence driver must have a `setItem(key, value)` method.");if("function"!=typeof e.removeItem)throw new Error("[Spruce] The persistence driver must have a `removeItem(name)` method.");this.persistenceDriver=e}};window.Spruce=a;var c=window.deferLoadingAlpine||function(e){e()};window.deferLoadingAlpine=function(e){window.Spruce.start(),c(e)},module.exports=a; | ||
//# sourceMappingURL=spruce.js.map |
@@ -1,2 +0,2 @@ | ||
"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e,t=(function(e,t){e.exports=function(){var e=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;function t(e){var t,r=e.replace(/^v/,"").replace(/\+.*$/,""),s=-1===(t=r).indexOf("-")?t.length:t.indexOf("-"),i=r.substring(0,s).split(".");return i.push(r.substring(s+1)),i}function r(e){return isNaN(Number(e))?e:Number(e)}function s(t){if("string"!=typeof t)throw new TypeError("Invalid argument expected string");if(!e.test(t))throw new Error("Invalid argument not valid semver ('"+t+"' received)")}function i(e,i){[e,i].forEach(s);for(var n=t(e),o=t(i),a=0;a<Math.max(n.length-1,o.length-1);a++){var c=parseInt(n[a]||0,10),u=parseInt(o[a]||0,10);if(c>u)return 1;if(u>c)return-1}var h=n[n.length-1],f=o[o.length-1];if(h&&f){var d=h.split(".").map(r),l=f.split(".").map(r);for(a=0;a<Math.max(d.length,l.length);a++){if(void 0===d[a]||"string"==typeof l[a]&&"number"==typeof d[a])return-1;if(void 0===l[a]||"string"==typeof d[a]&&"number"==typeof l[a])return 1;if(d[a]>l[a])return 1;if(l[a]>d[a])return-1}}else if(h||f)return h?-1:1;return 0}var n=[">",">=","=","<","<="],o={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]};return i.validate=function(t){return"string"==typeof t&&e.test(t)},i.compare=function(e,t,r){!function(e){if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===n.indexOf(e))throw new TypeError("Invalid operator, expected one of "+n.join("|"))}(r);var s=i(e,t);return o[r].indexOf(s)>-1},i}()}(e={exports:{}}),e.exports),r=function(e){return null==e},s=function(e){return Object.getPrototypeOf(e)===Object.prototype},i=function(e){return Array.isArray(e)},n=function(e,t){return Object.entries(e).forEach(function(o){var a=o[0],c=o[1];r(c)||!s(c)&&!i(c)||(e[a]=n(c,t))}),new Proxy(e,{get:function(e,r,s){return t.get(e,r,s)},set:function(e,i,o,a){return!r(o)&&s(o)&&(o=n(o,t)),t.set(e,i,e[i]=o,a),!0}})},o={stores:{},persistenceDriver:window.localStorage,persisted:[],subscribers:[],watchers:{},disableReactivity:!1,startingCallbacks:[],startedCallbacks:[],hasStarted:!1,start:function(){var e=this;this.startingCallbacks.forEach(function(e){return e()}),this.attach(),this.stores=n(this.stores,{get:function(t,r,s){return["get","set","toggle","clear"].includes(r)?e[r].bind(e):Reflect.get(t,r,s)},set:function(t,r,s,i){if(!e.disableReactivity){e.updateSubscribers(),e.runWatchers(t,r,s,i),e.disableReactivity=!0;try{e.persisted.forEach(e.updateLocalStorage.bind(e))}catch(e){}e.disableReactivity=!1}}}),this.hasStarted=!0,this.disableReactivity=!0,Object.entries(this.watchers).forEach(function(t){var r=t[0];t[1].forEach(function(t){return e.watch(r,t)})}),this.disableReactivity=!1,this.startedCallbacks.forEach(function(e){return e()})},starting:function(e){this.startingCallbacks.push(e)},started:function(e){this.startedCallbacks.push(e)},attach:function(){if(!(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")||window.Alpine&&t.compare(window.Alpine.version,"2.7.0",">=")))throw new Error("[Spruce] You must be using Alpine >= 2.5.0 to use Spruce.");var e=this;window.Alpine.addMagicProperty("store",function(t){return e.subscribe(t),e.stores})},store:function(e,t,r){if(void 0===r&&(r=!1),"function"==typeof t&&(t=t()),r)try{this.stores[e]=this.retrieveFromLocalStorage(e,(s={},Object.entries(t).filter(function(e){return"function"==typeof e[1]}).forEach(function(e){return s[e[0]]=e[1]}),s)),this.persisted.includes(e)||this.persisted.push(e)}catch(e){}var s;return this.stores[e]||(this.stores[e]=t),this.stores[e]},reset:function(e,t){this.runWatchers(this.stores[e],"__self",t),t.__watchers||(t.__watchers=this.stores[e].__watchers),this.stores[e]=t},subscribe:function(e){return this.subscribers.includes(e)||this.subscribers.push(e),this.stores},updateSubscribers:function(){this.subscribers.filter(function(e){return!!e.__x}).forEach(function(e){e.__x.updateElements(e)})},retrieveFromLocalStorage:function(e,t){void 0===t&&(t={});var r=this.persistenceDriver.getItem("__spruce:"+e);if(!r)return null;var s=JSON.parse(r);return"object"==typeof s&&(delete(s=Object.assign(t,s)).__watchers,delete s.__key_name),s},updateLocalStorage:function(e){var t=this.store(e);delete t.__watchers,delete t.__key_name,this.persistenceDriver.setItem("__spruce:"+e,JSON.stringify(this.store(e)))},get:function(e,t){return void 0===t&&(t=this.stores),e.split(".").reduce(function(e,t){return e[t]},t)},set:function(e,t,r){return void 0===r&&(r=this.stores),i(e)||(e=e.split(".")),1===e.length?r[e[0]]=t:r[e[0]]?this.set(e.slice(1),t,r[e[0]]):(r[e[0]]={},this.set(e.slice(1),t,r[e[0]]))},toggle:function(e){return this.set(e,!this.get(e))},clear:function(e){return this.persistenceDriver.removeItem("__spruce:"+e)},watch:function(e,t){if(!this.hasStarted)return this.watchers[e]||(this.watchers[e]=[]),void this.watchers[e].push(t);var n=e.split("."),o=n.reduce(function(e,t){var n=e[t];return r(n)||!s(n)&&!i(n)?e:n},this.stores),a=Object.is(o,this.get(e))?"__self":n[n.length-1];o.__watchers||(o.__watchers=new Map),o.__watchers.has(a)||o.__watchers.set(a,new Set),o.__watchers.get(a).add(t)},runWatchers:function(e,t,r){e.__watchers&&(e.__watchers.has(t)&&"__self"!==t&&e.__watchers.get(t).forEach(function(e){return e(r)}),e.__watchers.has("__self")&&e.__watchers.get("__self").forEach(function(e){return e(r,t)}))},persistUsing:function(e){if(this.persisted.length>0&&console.warn("[Spruce] You have already initialised a persisted store. Changing the driver may cause issues."),"function"!=typeof e.getItem)throw new Error("[Spruce] The persistence driver must have a `getItem(key)` method.");if("function"!=typeof e.setItem)throw new Error("[Spruce] The persistence driver must have a `setItem(key, value)` method.");if("function"!=typeof e.removeItem)throw new Error("[Spruce] The persistence driver must have a `removeItem(name)` method.");this.persistenceDriver=e}};window.Spruce=o;var a=window.deferLoadingAlpine||function(e){e()};window.deferLoadingAlpine=function(e){window.Spruce.start(),a(e)};export default o; | ||
function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,n=(function(e,t){e.exports=function(){var e=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;function t(e){var t,r=e.replace(/^v/,"").replace(/\+.*$/,""),n=-1===(t=r).indexOf("-")?t.length:t.indexOf("-"),i=r.substring(0,n).split(".");return i.push(r.substring(n+1)),i}function r(e){return isNaN(Number(e))?e:Number(e)}function n(t){if("string"!=typeof t)throw new TypeError("Invalid argument expected string");if(!e.test(t))throw new Error("Invalid argument not valid semver ('"+t+"' received)")}function i(e,i){[e,i].forEach(n);for(var s=t(e),o=t(i),a=0;a<Math.max(s.length-1,o.length-1);a++){var c=parseInt(s[a]||0,10),u=parseInt(o[a]||0,10);if(c>u)return 1;if(u>c)return-1}var f=s[s.length-1],h=o[o.length-1];if(f&&h){var p=f.split(".").map(r),l=h.split(".").map(r);for(a=0;a<Math.max(p.length,l.length);a++){if(void 0===p[a]||"string"==typeof l[a]&&"number"==typeof p[a])return-1;if(void 0===l[a]||"string"==typeof p[a]&&"number"==typeof l[a])return 1;if(p[a]>l[a])return 1;if(l[a]>p[a])return-1}}else if(f||h)return f?-1:1;return 0}var s=[">",">=","=","<","<="],o={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]};return i.validate=function(t){return"string"==typeof t&&e.test(t)},i.compare=function(e,t,r){!function(e){if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===s.indexOf(e))throw new TypeError("Invalid operator, expected one of "+s.join("|"))}(r);var n=i(e,t);return o[r].indexOf(n)>-1},i}()}(r={exports:{}}),r.exports),i=function(e){return null==e},s=function(e){return Object.getPrototypeOf(e)===Object.prototype},o=function(e){return Array.isArray(e)},a=function(e,t){return Object.entries(e).forEach(function(r){var n=r[0],c=r[1];i(c)||!s(c)&&!o(c)||(e[n]=a(c,t))}),new Proxy(e,{get:function(e,r,n){return t.get(e,r,n)},set:function(e,r,n,o){return!i(n)&&s(n)&&(n=a(n,t)),t.set(e,r,e[r]=n,o),!0}})},c={stores:{},persistenceDriver:window.localStorage,persisted:[],subscribers:[],watchers:{},disableReactivity:!1,startingCallbacks:[],startedCallbacks:[],hasStarted:!1,start:function(){var e=this;this.startingCallbacks.forEach(function(e){return e()}),this.attach(),this.stores=a(this.stores,{get:function(t,r,n){return Object.is(n,e.stores)&&["get","set","toggle","clear"].includes(r)?e[r].bind(e):Reflect.get(t,r,n)},set:function(t,r,n,i){if(!e.disableReactivity){e.updateSubscribers(),e.runWatchers(t,r,n,i),e.disableReactivity=!0;try{e.persisted.forEach(e.updateLocalStorage.bind(e))}catch(e){}e.disableReactivity=!1}}}),this.hasStarted=!0,this.disableReactivity=!0,Object.entries(this.watchers).forEach(function(t){var r=t[0];t[1].forEach(function(t){return e.watch(r,t)})}),this.disableReactivity=!1,this.startedCallbacks.forEach(function(e){return e()})},starting:function(e){this.startingCallbacks.push(e)},started:function(e){this.startedCallbacks.push(e)},attach:function(){if(!(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")||window.Alpine&&n.compare(window.Alpine.version,"2.7.0",">=")))throw new Error("[Spruce] You must be using Alpine >= 2.5.0 to use Spruce.");var e=this;window.Alpine.addMagicProperty("store",function(t){return e.subscribe(t),e.stores})},store:function(e,t,r){if(void 0===r&&(r=!1),"function"==typeof t&&(t=t()),r)try{this.stores[e]=this.retrieveFromLocalStorage(e,(n={},Object.entries(t).filter(function(e){return"function"==typeof e[1]}).forEach(function(e){return n[e[0]]=e[1]}),n)),this.persisted.includes(e)||this.persisted.push(e)}catch(e){}var n;return this.stores[e]||(this.stores[e]=t),this.stores[e]},reset:function(e,t){this.stores[e]&&(this.stores[e]=t)},subscribe:function(e){return this.subscribers.includes(e)||this.subscribers.push(e),this.stores},updateSubscribers:function(){this.subscribers.filter(function(e){return!!e.__x}).forEach(function(e){e.__x.updateElements(e)})},retrieveFromLocalStorage:function(e,t){void 0===t&&(t={});var r=this.persistenceDriver.getItem("__spruce:"+e);if(!r)return null;var n=JSON.parse(r);return"object"==typeof n&&(delete(n=Object.assign(t,n)).__watchers,delete n.__key_name),n},updateLocalStorage:function(r){var n=function(r){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?t(Object(i),!0).forEach(function(t){e(r,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}({},this.store(r));delete n.__watchers,delete n.__key_name,this.persistenceDriver.setItem("__spruce:"+r,JSON.stringify(this.store(r)))},get:function(e,t){return void 0===t&&(t=this.stores),e.split(".").reduce(function(e,t){return e[t]},t)},set:function(e,t,r){return void 0===r&&(r=this.stores),o(e)||(e=e.split(".")),1===e.length?r[e[0]]=t:r[e[0]]?this.set(e.slice(1),t,r[e[0]]):(r[e[0]]={},this.set(e.slice(1),t,r[e[0]]))},toggle:function(e){return this.set(e,!this.get(e))},clear:function(e){return this.persistenceDriver.removeItem("__spruce:"+e)},watch:function(e,t){if(!this.hasStarted)return this.watchers[e]||(this.watchers[e]=[]),void this.watchers[e].push(t);var r=e.split("."),n=r.reduce(function(e,t){var r=e[t];return i(r)||!s(r)&&!o(r)?e:r},this.stores),a=Object.is(n,this.get(e))?"__self":r[r.length-1];n.__watchers||(n.__watchers=new Map),n.__watchers.has(a)||n.__watchers.set(a,new Set),n.__watchers.get(a).add(t)},runWatchers:function(e,t,r){e.__watchers&&(e.__watchers.has(t)&&e.__watchers.get(t).forEach(function(e){return e(r)}),e.__watchers.has("__self")&&e.__watchers.get("__self").forEach(function(e){return e(r,t)}))},persistUsing:function(e){if(this.persisted.length>0&&console.warn("[Spruce] You have already initialised a persisted store. Changing the driver may cause issues."),"function"!=typeof e.getItem)throw new Error("[Spruce] The persistence driver must have a `getItem(key)` method.");if("function"!=typeof e.setItem)throw new Error("[Spruce] The persistence driver must have a `setItem(key, value)` method.");if("function"!=typeof e.removeItem)throw new Error("[Spruce] The persistence driver must have a `removeItem(name)` method.");this.persistenceDriver=e}};window.Spruce=c;var u=window.deferLoadingAlpine||function(e){e()};window.deferLoadingAlpine=function(e){window.Spruce.start(),u(e)};export default c; | ||
//# sourceMappingURL=spruce.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.spruce=t()}(this,function(){"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e,t=(function(e,t){e.exports=function(){var e=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;function t(e){var t,r=e.replace(/^v/,"").replace(/\+.*$/,""),n=-1===(t=r).indexOf("-")?t.length:t.indexOf("-"),s=r.substring(0,n).split(".");return s.push(r.substring(n+1)),s}function r(e){return isNaN(Number(e))?e:Number(e)}function n(t){if("string"!=typeof t)throw new TypeError("Invalid argument expected string");if(!e.test(t))throw new Error("Invalid argument not valid semver ('"+t+"' received)")}function s(e,s){[e,s].forEach(n);for(var i=t(e),o=t(s),a=0;a<Math.max(i.length-1,o.length-1);a++){var c=parseInt(i[a]||0,10),u=parseInt(o[a]||0,10);if(c>u)return 1;if(u>c)return-1}var f=i[i.length-1],h=o[o.length-1];if(f&&h){var d=f.split(".").map(r),l=h.split(".").map(r);for(a=0;a<Math.max(d.length,l.length);a++){if(void 0===d[a]||"string"==typeof l[a]&&"number"==typeof d[a])return-1;if(void 0===l[a]||"string"==typeof d[a]&&"number"==typeof l[a])return 1;if(d[a]>l[a])return 1;if(l[a]>d[a])return-1}}else if(f||h)return f?-1:1;return 0}var i=[">",">=","=","<","<="],o={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]};return s.validate=function(t){return"string"==typeof t&&e.test(t)},s.compare=function(e,t,r){!function(e){if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===i.indexOf(e))throw new TypeError("Invalid operator, expected one of "+i.join("|"))}(r);var n=s(e,t);return o[r].indexOf(n)>-1},s}()}(e={exports:{}}),e.exports),r=function(e){return null==e},n=function(e){return Object.getPrototypeOf(e)===Object.prototype},s=function(e){return Array.isArray(e)},i=function(e,t){return Object.entries(e).forEach(function(o){var a=o[0],c=o[1];r(c)||!n(c)&&!s(c)||(e[a]=i(c,t))}),new Proxy(e,{get:function(e,r,n){return t.get(e,r,n)},set:function(e,s,o,a){return!r(o)&&n(o)&&(o=i(o,t)),t.set(e,s,e[s]=o,a),!0}})},o={stores:{},persistenceDriver:window.localStorage,persisted:[],subscribers:[],watchers:{},disableReactivity:!1,startingCallbacks:[],startedCallbacks:[],hasStarted:!1,start:function(){var e=this;this.startingCallbacks.forEach(function(e){return e()}),this.attach(),this.stores=i(this.stores,{get:function(t,r,n){return["get","set","toggle","clear"].includes(r)?e[r].bind(e):Reflect.get(t,r,n)},set:function(t,r,n,s){if(!e.disableReactivity){e.updateSubscribers(),e.runWatchers(t,r,n,s),e.disableReactivity=!0;try{e.persisted.forEach(e.updateLocalStorage.bind(e))}catch(e){}e.disableReactivity=!1}}}),this.hasStarted=!0,this.disableReactivity=!0,Object.entries(this.watchers).forEach(function(t){var r=t[0];t[1].forEach(function(t){return e.watch(r,t)})}),this.disableReactivity=!1,this.startedCallbacks.forEach(function(e){return e()})},starting:function(e){this.startingCallbacks.push(e)},started:function(e){this.startedCallbacks.push(e)},attach:function(){if(!(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")||window.Alpine&&t.compare(window.Alpine.version,"2.7.0",">=")))throw new Error("[Spruce] You must be using Alpine >= 2.5.0 to use Spruce.");var e=this;window.Alpine.addMagicProperty("store",function(t){return e.subscribe(t),e.stores})},store:function(e,t,r){if(void 0===r&&(r=!1),"function"==typeof t&&(t=t()),r)try{this.stores[e]=this.retrieveFromLocalStorage(e,(n={},Object.entries(t).filter(function(e){return"function"==typeof e[1]}).forEach(function(e){return n[e[0]]=e[1]}),n)),this.persisted.includes(e)||this.persisted.push(e)}catch(e){}var n;return this.stores[e]||(this.stores[e]=t),this.stores[e]},reset:function(e,t){this.runWatchers(this.stores[e],"__self",t),t.__watchers||(t.__watchers=this.stores[e].__watchers),this.stores[e]=t},subscribe:function(e){return this.subscribers.includes(e)||this.subscribers.push(e),this.stores},updateSubscribers:function(){this.subscribers.filter(function(e){return!!e.__x}).forEach(function(e){e.__x.updateElements(e)})},retrieveFromLocalStorage:function(e,t){void 0===t&&(t={});var r=this.persistenceDriver.getItem("__spruce:"+e);if(!r)return null;var n=JSON.parse(r);return"object"==typeof n&&(delete(n=Object.assign(t,n)).__watchers,delete n.__key_name),n},updateLocalStorage:function(e){var t=this.store(e);delete t.__watchers,delete t.__key_name,this.persistenceDriver.setItem("__spruce:"+e,JSON.stringify(this.store(e)))},get:function(e,t){return void 0===t&&(t=this.stores),e.split(".").reduce(function(e,t){return e[t]},t)},set:function(e,t,r){return void 0===r&&(r=this.stores),s(e)||(e=e.split(".")),1===e.length?r[e[0]]=t:r[e[0]]?this.set(e.slice(1),t,r[e[0]]):(r[e[0]]={},this.set(e.slice(1),t,r[e[0]]))},toggle:function(e){return this.set(e,!this.get(e))},clear:function(e){return this.persistenceDriver.removeItem("__spruce:"+e)},watch:function(e,t){if(!this.hasStarted)return this.watchers[e]||(this.watchers[e]=[]),void this.watchers[e].push(t);var i=e.split("."),o=i.reduce(function(e,t){var i=e[t];return r(i)||!n(i)&&!s(i)?e:i},this.stores),a=Object.is(o,this.get(e))?"__self":i[i.length-1];o.__watchers||(o.__watchers=new Map),o.__watchers.has(a)||o.__watchers.set(a,new Set),o.__watchers.get(a).add(t)},runWatchers:function(e,t,r){e.__watchers&&(e.__watchers.has(t)&&"__self"!==t&&e.__watchers.get(t).forEach(function(e){return e(r)}),e.__watchers.has("__self")&&e.__watchers.get("__self").forEach(function(e){return e(r,t)}))},persistUsing:function(e){if(this.persisted.length>0&&console.warn("[Spruce] You have already initialised a persisted store. Changing the driver may cause issues."),"function"!=typeof e.getItem)throw new Error("[Spruce] The persistence driver must have a `getItem(key)` method.");if("function"!=typeof e.setItem)throw new Error("[Spruce] The persistence driver must have a `setItem(key, value)` method.");if("function"!=typeof e.removeItem)throw new Error("[Spruce] The persistence driver must have a `removeItem(name)` method.");this.persistenceDriver=e}};window.Spruce=o;var a=window.deferLoadingAlpine||function(e){e()};return window.deferLoadingAlpine=function(e){window.Spruce.start(),a(e)},o}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.spruce=t()}(this,function(){function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,n=(function(e,t){e.exports=function(){var e=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;function t(e){var t,r=e.replace(/^v/,"").replace(/\+.*$/,""),n=-1===(t=r).indexOf("-")?t.length:t.indexOf("-"),i=r.substring(0,n).split(".");return i.push(r.substring(n+1)),i}function r(e){return isNaN(Number(e))?e:Number(e)}function n(t){if("string"!=typeof t)throw new TypeError("Invalid argument expected string");if(!e.test(t))throw new Error("Invalid argument not valid semver ('"+t+"' received)")}function i(e,i){[e,i].forEach(n);for(var s=t(e),o=t(i),c=0;c<Math.max(s.length-1,o.length-1);c++){var a=parseInt(s[c]||0,10),u=parseInt(o[c]||0,10);if(a>u)return 1;if(u>a)return-1}var f=s[s.length-1],h=o[o.length-1];if(f&&h){var p=f.split(".").map(r),d=h.split(".").map(r);for(c=0;c<Math.max(p.length,d.length);c++){if(void 0===p[c]||"string"==typeof d[c]&&"number"==typeof p[c])return-1;if(void 0===d[c]||"string"==typeof p[c]&&"number"==typeof d[c])return 1;if(p[c]>d[c])return 1;if(d[c]>p[c])return-1}}else if(f||h)return f?-1:1;return 0}var s=[">",">=","=","<","<="],o={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]};return i.validate=function(t){return"string"==typeof t&&e.test(t)},i.compare=function(e,t,r){!function(e){if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===s.indexOf(e))throw new TypeError("Invalid operator, expected one of "+s.join("|"))}(r);var n=i(e,t);return o[r].indexOf(n)>-1},i}()}(r={exports:{}}),r.exports),i=function(e){return null==e},s=function(e){return Object.getPrototypeOf(e)===Object.prototype},o=function(e){return Array.isArray(e)},c=function(e,t){return Object.entries(e).forEach(function(r){var n=r[0],a=r[1];i(a)||!s(a)&&!o(a)||(e[n]=c(a,t))}),new Proxy(e,{get:function(e,r,n){return t.get(e,r,n)},set:function(e,r,n,o){return!i(n)&&s(n)&&(n=c(n,t)),t.set(e,r,e[r]=n,o),!0}})},a={stores:{},persistenceDriver:window.localStorage,persisted:[],subscribers:[],watchers:{},disableReactivity:!1,startingCallbacks:[],startedCallbacks:[],hasStarted:!1,start:function(){var e=this;this.startingCallbacks.forEach(function(e){return e()}),this.attach(),this.stores=c(this.stores,{get:function(t,r,n){return Object.is(n,e.stores)&&["get","set","toggle","clear"].includes(r)?e[r].bind(e):Reflect.get(t,r,n)},set:function(t,r,n,i){if(!e.disableReactivity){e.updateSubscribers(),e.runWatchers(t,r,n,i),e.disableReactivity=!0;try{e.persisted.forEach(e.updateLocalStorage.bind(e))}catch(e){}e.disableReactivity=!1}}}),this.hasStarted=!0,this.disableReactivity=!0,Object.entries(this.watchers).forEach(function(t){var r=t[0];t[1].forEach(function(t){return e.watch(r,t)})}),this.disableReactivity=!1,this.startedCallbacks.forEach(function(e){return e()})},starting:function(e){this.startingCallbacks.push(e)},started:function(e){this.startedCallbacks.push(e)},attach:function(){if(!(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")||window.Alpine&&n.compare(window.Alpine.version,"2.7.0",">=")))throw new Error("[Spruce] You must be using Alpine >= 2.5.0 to use Spruce.");var e=this;window.Alpine.addMagicProperty("store",function(t){return e.subscribe(t),e.stores})},store:function(e,t,r){if(void 0===r&&(r=!1),"function"==typeof t&&(t=t()),r)try{this.stores[e]=this.retrieveFromLocalStorage(e,(n={},Object.entries(t).filter(function(e){return"function"==typeof e[1]}).forEach(function(e){return n[e[0]]=e[1]}),n)),this.persisted.includes(e)||this.persisted.push(e)}catch(e){}var n;return this.stores[e]||(this.stores[e]=t),this.stores[e]},reset:function(e,t){this.stores[e]&&(this.stores[e]=t)},subscribe:function(e){return this.subscribers.includes(e)||this.subscribers.push(e),this.stores},updateSubscribers:function(){this.subscribers.filter(function(e){return!!e.__x}).forEach(function(e){e.__x.updateElements(e)})},retrieveFromLocalStorage:function(e,t){void 0===t&&(t={});var r=this.persistenceDriver.getItem("__spruce:"+e);if(!r)return null;var n=JSON.parse(r);return"object"==typeof n&&(delete(n=Object.assign(t,n)).__watchers,delete n.__key_name),n},updateLocalStorage:function(r){var n=function(r){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?t(Object(i),!0).forEach(function(t){e(r,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}({},this.store(r));delete n.__watchers,delete n.__key_name,this.persistenceDriver.setItem("__spruce:"+r,JSON.stringify(this.store(r)))},get:function(e,t){return void 0===t&&(t=this.stores),e.split(".").reduce(function(e,t){return e[t]},t)},set:function(e,t,r){return void 0===r&&(r=this.stores),o(e)||(e=e.split(".")),1===e.length?r[e[0]]=t:r[e[0]]?this.set(e.slice(1),t,r[e[0]]):(r[e[0]]={},this.set(e.slice(1),t,r[e[0]]))},toggle:function(e){return this.set(e,!this.get(e))},clear:function(e){return this.persistenceDriver.removeItem("__spruce:"+e)},watch:function(e,t){if(!this.hasStarted)return this.watchers[e]||(this.watchers[e]=[]),void this.watchers[e].push(t);var r=e.split("."),n=r.reduce(function(e,t){var r=e[t];return i(r)||!s(r)&&!o(r)?e:r},this.stores),c=Object.is(n,this.get(e))?"__self":r[r.length-1];n.__watchers||(n.__watchers=new Map),n.__watchers.has(c)||n.__watchers.set(c,new Set),n.__watchers.get(c).add(t)},runWatchers:function(e,t,r){e.__watchers&&(e.__watchers.has(t)&&e.__watchers.get(t).forEach(function(e){return e(r)}),e.__watchers.has("__self")&&e.__watchers.get("__self").forEach(function(e){return e(r,t)}))},persistUsing:function(e){if(this.persisted.length>0&&console.warn("[Spruce] You have already initialised a persisted store. Changing the driver may cause issues."),"function"!=typeof e.getItem)throw new Error("[Spruce] The persistence driver must have a `getItem(key)` method.");if("function"!=typeof e.setItem)throw new Error("[Spruce] The persistence driver must have a `setItem(key, value)` method.");if("function"!=typeof e.removeItem)throw new Error("[Spruce] The persistence driver must have a `removeItem(name)` method.");this.persistenceDriver=e}};window.Spruce=a;var u=window.deferLoadingAlpine||function(e){e()};return window.deferLoadingAlpine=function(e){window.Spruce.start(),u(e)},a}); | ||
//# sourceMappingURL=spruce.umd.js.map |
{ | ||
"name": "@ryangjchandler/spruce", | ||
"description": "A lightweight state management layer for Alpine.js", | ||
"version": "2.5.1", | ||
"version": "2.5.3", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -30,3 +30,3 @@ import { getMethods, checkForAlpine, isObject, isArray, isNullOrUndefined } from './utils' | ||
get: (target, key, receiver) => { | ||
if (['get', 'set', 'toggle', 'clear'].includes(key)) { | ||
if (Object.is(receiver, this.stores) && ['get', 'set', 'toggle', 'clear'].includes(key)) { | ||
return this[key].bind(this) | ||
@@ -118,11 +118,4 @@ } | ||
reset(name, state) { | ||
// This line is needed to ensure any watchers on | ||
// the store itself are run when reset. | ||
this.runWatchers(this.stores[name], '__self', state) | ||
// This conditional will take any existing watchers on | ||
// the store being reset and apply them back to the new | ||
// state (see issue #105). | ||
if (! state['__watchers']) { | ||
state['__watchers'] = this.stores[name].__watchers | ||
if (! this.stores[name]) { | ||
return; | ||
} | ||
@@ -167,3 +160,3 @@ | ||
updateLocalStorage(name) { | ||
const store = this.store(name) | ||
const store = { ...this.store(name) } | ||
@@ -248,3 +241,3 @@ delete store.__watchers | ||
if (target.__watchers.has(key) && key !== '__self') { | ||
if (target.__watchers.has(key)) { | ||
target.__watchers.get(key).forEach(f => f(value)) | ||
@@ -251,0 +244,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
89410
333