Socket
Socket
Sign inDemoInstall

@ryangjchandler/spruce

Package Overview
Dependencies
1
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.5.0 to 2.5.1

2

dist/spruce.js

@@ -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(/\+.*$/,""),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 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 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}(),t=function(e){return null==e},r=function(e){return Object.getPrototypeOf(e)===Object.prototype},n=function(e){return Array.isArray(e)},i=function(e,s){return Object.entries(e).forEach(function(o){var a=o[0],c=o[1];t(c)||!r(c)&&!n(c)||(e[a]=i(c,s))}),new Proxy(e,{get:function(e,t,r){return s.get(e,t,r)},set:function(e,n,o,a){return!t(o)&&r(o)&&(o=i(o,s)),s.set(e,n,e[n]=o,a),!0}})},s={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,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&&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,(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]=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),n(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,i){if(!this.hasStarted)return this.watchers[e]||(this.watchers[e]=[]),void this.watchers[e].push(i);var s=e.split("."),o=s.reduce(function(e,i){var s=e[i];return t(s)||!r(s)&&!n(s)?e:s},this.stores),a=Object.is(o,this.get(e))?"__self":s[s.length-1];o.__watchers||(o.__watchers=new Map),o.__watchers.has(a)||o.__watchers.set(a,new Set),o.__watchers.get(a).add(i)},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=s;var o=window.deferLoadingAlpine||function(e){e()};window.deferLoadingAlpine=function(e){window.Spruce.start(),o(e)},module.exports=s;
"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;
//# 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(/\+.*$/,""),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 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 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}()}(e={exports:{}}),e.exports),r=function(e){return null==e},n=function(e){return Object.getPrototypeOf(e)===Object.prototype},i=function(e){return Array.isArray(e)},s=function(e,t){return Object.entries(e).forEach(function(o){var a=o[0],c=o[1];r(c)||!n(c)&&!i(c)||(e[a]=s(c,t))}),new Proxy(e,{get:function(e,r,n){return t.get(e,r,n)},set:function(e,i,o,a){return!r(o)&&n(o)&&(o=s(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=s(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,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&&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.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),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 s=e.split("."),o=s.reduce(function(e,t){var s=e[t];return r(s)||!n(s)&&!i(s)?e:s},this.stores),a=Object.is(o,this.get(e))?"__self":s[s.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=o;var a=window.deferLoadingAlpine||function(e){e()};window.deferLoadingAlpine=function(e){window.Spruce.start(),a(e)};export default o;
"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;
//# 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("-"),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 d=f.split(".").map(r),p=h.split(".").map(r);for(a=0;a<Math.max(d.length,p.length);a++){if(void 0===d[a]||"string"==typeof p[a]&&"number"==typeof d[a])return-1;if(void 0===p[a]||"string"==typeof d[a]&&"number"==typeof p[a])return 1;if(d[a]>p[a])return 1;if(p[a]>d[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}()}(e={exports:{}}),e.exports),r=function(e){return null==e},n=function(e){return Object.getPrototypeOf(e)===Object.prototype},i=function(e){return Array.isArray(e)},s=function(e,t){return Object.entries(e).forEach(function(o){var a=o[0],c=o[1];r(c)||!n(c)&&!i(c)||(e[a]=s(c,t))}),new Proxy(e,{get:function(e,r,n){return t.get(e,r,n)},set:function(e,i,o,a){return!r(o)&&n(o)&&(o=s(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=s(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,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&&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.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),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 s=e.split("."),o=s.reduce(function(e,t){var s=e[t];return r(s)||!n(s)&&!i(s)?e:s},this.stores),a=Object.is(o,this.get(e))?"__self":s[s.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=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(){"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});
//# sourceMappingURL=spruce.umd.js.map
{
"name": "@ryangjchandler/spruce",
"description": "A lightweight state management layer for Alpine.js",
"version": "2.5.0",
"version": "2.5.1",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

@@ -117,2 +117,13 @@ import { getMethods, checkForAlpine, isObject, isArray, isNullOrUndefined } from './utils'

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
}
this.stores[name] = state

@@ -235,3 +246,3 @@ },

if (target.__watchers.has(key)) {
if (target.__watchers.has(key) && key !== '__self') {
target.__watchers.get(key).forEach(f => f(value))

@@ -238,0 +249,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc