From 9900bd4260e251cca7fbb0231825388fbf138b2c Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Sat, 25 Apr 2020 22:27:07 +0100 Subject: [PATCH] build --- .gitignore | 3 +-- dist/spruce.js | 2 ++ dist/spruce.js.map | 1 + dist/spruce.module.js | 2 ++ dist/spruce.module.js.map | 1 + dist/spruce.umd.js | 2 ++ dist/spruce.umd.js.map | 1 + 7 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 dist/spruce.js create mode 100644 dist/spruce.js.map create mode 100644 dist/spruce.module.js create mode 100644 dist/spruce.module.js.map create mode 100644 dist/spruce.umd.js create mode 100644 dist/spruce.umd.js.map diff --git a/.gitignore b/.gitignore index b2d59d1..30bc162 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -/node_modules -/dist \ No newline at end of file +/node_modules \ No newline at end of file diff --git a/dist/spruce.js b/dist/spruce.js new file mode 100644 index 0000000..6945f04 --- /dev/null +++ b/dist/spruce.js @@ -0,0 +1,2 @@ +var t=function(e,r){return Object.keys(e).forEach(function(n){Object.getPrototypeOf(e[n])===Object.prototype&&(e[n]=t(e[n],r))}),new Proxy(e,{set:function(e,n,i){return"object"==typeof i&&(i=t(i,r)),r(n,e[n]=i),!0}})},e={stores:{},subscribers:[],start:function(){try{var e=this;return Promise.resolve(new Promise(function(t){"loading"==document.readyState?document.addEventListener("DOMContentLoaded",t):t()})).then(function(){document.querySelectorAll("[x-subscribe]").forEach(function(t){t.setAttribute("x-init",function(t){var e="$store = Spruce.subscribe($el)";return t.hasAttribute("x-init")&&(e=e+"; "+t.getAttribute("x-init")),e}(t)),t.removeAttribute("x-subscribe")}),e.stores=t(e.stores,function(t,r){e.updateSubscribers(t,r)})})}catch(t){return Promise.reject(t)}},store:function(t,e){void 0===e&&(e={}),this.stores[t]||(this.stores[t]=e)},subscribe:function(t){return this.subscribers.push(t),this.stores},updateSubscribers:function(t,e){this.subscribers.forEach(function(r){"undefined"!==r.__x&&(r.__x.$data.spruce=[t,e])})}},r=window.deferLoadingAlpine||function(t){t()};window.deferLoadingAlpine=function(t){window.Spruce=e,window.Spruce.start(),r(t)},module.exports=e; +//# sourceMappingURL=spruce.js.map diff --git a/dist/spruce.js.map b/dist/spruce.js.map new file mode 100644 index 0000000..7ce504d --- /dev/null +++ b/dist/spruce.js.map @@ -0,0 +1 @@ +{"version":3,"file":"spruce.js","sources":["../src/utils.js","../src/observable.js","../src/index.js"],"sourcesContent":["export const domReady = () => {\n return new Promise(resolve => {\n if (document.readyState == \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", resolve)\n } else {\n resolve()\n }\n })\n}\n\nexport const buildInitExpression = el => {\n let expression = \"$store = Spruce.subscribe($el)\"\n\n if (el.hasAttribute('x-init')) {\n expression = `${expression}; ${el.getAttribute('x-init')}`\n }\n\n return expression\n}","export const create = (target, callback) => {\n Object.keys(target).forEach(key => {\n if (Object.getPrototypeOf(target[key]) === Object.prototype) {\n target[key] = create(target[key], callback)\n }\n })\n\n return new Proxy(target, {\n set(target, key, value) {\n if (typeof value === 'object') {\n value = create(value, callback)\n }\n\n callback(key, target[key] = value)\n\n return true\n }\n })\n}","import { domReady, buildInitExpression } from './utils'\nimport { create } from './observable'\n\nconst Spruce = {\n\n stores: {},\n\n subscribers: [],\n\n start: async function () {\n await domReady()\n\n document.querySelectorAll('[x-subscribe]').forEach(el => {\n el.setAttribute('x-init', buildInitExpression(el))\n el.removeAttribute('x-subscribe')\n })\n\n this.stores = create(this.stores, (key, value) => {\n this.updateSubscribers(key, value)\n })\n },\n\n store: function (name, state = {}) {\n if (! this.stores[name]) {\n this.stores[name] = state\n }\n },\n\n subscribe(el) {\n this.subscribers.push(el)\n\n return this.stores\n },\n\n updateSubscribers(key, value) {\n this.subscribers.forEach(el => {\n if (el.__x !== 'undefined') {\n el.__x.$data.spruce = [key, value]\n }\n })\n }\n}\n\nconst deferrer = window.deferLoadingAlpine || function (callback) { callback() }\n\nwindow.deferLoadingAlpine = function (callback) {\n window.Spruce = Spruce\n window.Spruce.start()\n\n deferrer(callback)\n}\n\nexport default Spruce"],"names":["const","create","target","callback","Object","keys","forEach","key","getPrototypeOf","prototype","Proxy","set","value","Spruce","stores","subscribers","start","this","Promise","resolve","document","readyState","addEventListener","querySelectorAll","el","setAttribute","expression","hasAttribute","getAttribute","buildInitExpression","removeAttribute","_this","updateSubscribers","store","name","state","subscribe","push","__x","$data","spruce","deferrer","window","deferLoadingAlpine"],"mappings":"AAAOA,ICAMC,WAAUC,EAAQC,UAC3BC,OAAOC,KAAKH,GAAQI,iBAAQC,GACpBH,OAAOI,eAAeN,EAAOK,MAAUH,OAAOK,YAC9CP,EAAOK,GAAON,EAAOC,EAAOK,GAAMJ,MAInC,IAAIO,MAAMR,EAAQ,CACrBS,aAAIT,EAAQK,EAAKK,SACQ,iBAAVA,IACPA,EAAQX,EAAOW,EAAOT,IAG1BA,EAASI,EAAKL,EAAOK,GAAOK,IAErB,MCZbC,EAAS,CAEXC,OAAQ,GAERC,YAAa,GAEbC,2BAQIC,4BFhBG,IAAIC,iBAAQC,GACY,WAAvBC,SAASC,WACTD,SAASE,iBAAiB,mBAAoBH,GAE9CA,uBEOJC,SAASG,iBAAiB,iBAAiBjB,iBAAQkB,GAC/CA,EAAGC,aAAa,kBFHOD,OAC3BE,EAAa,wCAEbF,EAAGG,aAAa,YAChBD,EAAgBA,OAAeF,EAAGI,aAAa,WAG5CF,EEJ2BG,CAAoBL,IAC9CA,EAAGM,gBAAgB,mBAGlBhB,OAASb,EAAO8B,EAAKjB,gBAASP,EAAKK,KAC/BoB,kBAAkBzB,EAAKK,2CAIpCqB,MAAO,SAAUC,EAAMC,kBAAQ,IACrBlB,KAAKH,OAAOoB,UACTpB,OAAOoB,GAAQC,IAI5BC,mBAAUZ,eACDT,YAAYsB,KAAKb,GAEfP,KAAKH,QAGhBkB,2BAAkBzB,EAAKK,QACdG,YAAYT,iBAAQkB,GACN,cAAXA,EAAGc,MACHd,EAAGc,IAAIC,MAAMC,OAAS,CAACjC,EAAKK,QAMtC6B,EAAWC,OAAOC,oBAAsB,SAAUxC,GAAYA,KAEpEuC,OAAOC,mBAAqB,SAAUxC,GAClCuC,OAAO7B,OAASA,EAChB6B,OAAO7B,OAAOG,QAEdyB,EAAStC"} \ No newline at end of file diff --git a/dist/spruce.module.js b/dist/spruce.module.js new file mode 100644 index 0000000..ad5b520 --- /dev/null +++ b/dist/spruce.module.js @@ -0,0 +1,2 @@ +var t=function(e,r){return Object.keys(e).forEach(function(n){Object.getPrototypeOf(e[n])===Object.prototype&&(e[n]=t(e[n],r))}),new Proxy(e,{set:function(e,n,i){return"object"==typeof i&&(i=t(i,r)),r(n,e[n]=i),!0}})},e={stores:{},subscribers:[],start:function(){try{var e=this;return Promise.resolve(new Promise(function(t){"loading"==document.readyState?document.addEventListener("DOMContentLoaded",t):t()})).then(function(){document.querySelectorAll("[x-subscribe]").forEach(function(t){t.setAttribute("x-init",function(t){var e="$store = Spruce.subscribe($el)";return t.hasAttribute("x-init")&&(e=e+"; "+t.getAttribute("x-init")),e}(t)),t.removeAttribute("x-subscribe")}),e.stores=t(e.stores,function(t,r){e.updateSubscribers(t,r)})})}catch(t){return Promise.reject(t)}},store:function(t,e){void 0===e&&(e={}),this.stores[t]||(this.stores[t]=e)},subscribe:function(t){return this.subscribers.push(t),this.stores},updateSubscribers:function(t,e){this.subscribers.forEach(function(r){"undefined"!==r.__x&&(r.__x.$data.spruce=[t,e])})}},r=window.deferLoadingAlpine||function(t){t()};window.deferLoadingAlpine=function(t){window.Spruce=e,window.Spruce.start(),r(t)};export default e; +//# sourceMappingURL=spruce.module.js.map diff --git a/dist/spruce.module.js.map b/dist/spruce.module.js.map new file mode 100644 index 0000000..22d29fd --- /dev/null +++ b/dist/spruce.module.js.map @@ -0,0 +1 @@ +{"version":3,"file":"spruce.module.js","sources":["../src/utils.js","../src/observable.js","../src/index.js"],"sourcesContent":["export const domReady = () => {\n return new Promise(resolve => {\n if (document.readyState == \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", resolve)\n } else {\n resolve()\n }\n })\n}\n\nexport const buildInitExpression = el => {\n let expression = \"$store = Spruce.subscribe($el)\"\n\n if (el.hasAttribute('x-init')) {\n expression = `${expression}; ${el.getAttribute('x-init')}`\n }\n\n return expression\n}","export const create = (target, callback) => {\n Object.keys(target).forEach(key => {\n if (Object.getPrototypeOf(target[key]) === Object.prototype) {\n target[key] = create(target[key], callback)\n }\n })\n\n return new Proxy(target, {\n set(target, key, value) {\n if (typeof value === 'object') {\n value = create(value, callback)\n }\n\n callback(key, target[key] = value)\n\n return true\n }\n })\n}","import { domReady, buildInitExpression } from './utils'\nimport { create } from './observable'\n\nconst Spruce = {\n\n stores: {},\n\n subscribers: [],\n\n start: async function () {\n await domReady()\n\n document.querySelectorAll('[x-subscribe]').forEach(el => {\n el.setAttribute('x-init', buildInitExpression(el))\n el.removeAttribute('x-subscribe')\n })\n\n this.stores = create(this.stores, (key, value) => {\n this.updateSubscribers(key, value)\n })\n },\n\n store: function (name, state = {}) {\n if (! this.stores[name]) {\n this.stores[name] = state\n }\n },\n\n subscribe(el) {\n this.subscribers.push(el)\n\n return this.stores\n },\n\n updateSubscribers(key, value) {\n this.subscribers.forEach(el => {\n if (el.__x !== 'undefined') {\n el.__x.$data.spruce = [key, value]\n }\n })\n }\n}\n\nconst deferrer = window.deferLoadingAlpine || function (callback) { callback() }\n\nwindow.deferLoadingAlpine = function (callback) {\n window.Spruce = Spruce\n window.Spruce.start()\n\n deferrer(callback)\n}\n\nexport default Spruce"],"names":["const","create","target","callback","Object","keys","forEach","key","getPrototypeOf","prototype","Proxy","set","value","Spruce","stores","subscribers","start","this","Promise","resolve","document","readyState","addEventListener","querySelectorAll","el","setAttribute","expression","hasAttribute","getAttribute","buildInitExpression","removeAttribute","_this","updateSubscribers","store","name","state","subscribe","push","__x","$data","spruce","deferrer","window","deferLoadingAlpine"],"mappings":"AAAOA,ICAMC,WAAUC,EAAQC,UAC3BC,OAAOC,KAAKH,GAAQI,iBAAQC,GACpBH,OAAOI,eAAeN,EAAOK,MAAUH,OAAOK,YAC9CP,EAAOK,GAAON,EAAOC,EAAOK,GAAMJ,MAInC,IAAIO,MAAMR,EAAQ,CACrBS,aAAIT,EAAQK,EAAKK,SACQ,iBAAVA,IACPA,EAAQX,EAAOW,EAAOT,IAG1BA,EAASI,EAAKL,EAAOK,GAAOK,IAErB,MCZbC,EAAS,CAEXC,OAAQ,GAERC,YAAa,GAEbC,2BAQIC,4BFhBG,IAAIC,iBAAQC,GACY,WAAvBC,SAASC,WACTD,SAASE,iBAAiB,mBAAoBH,GAE9CA,uBEOJC,SAASG,iBAAiB,iBAAiBjB,iBAAQkB,GAC/CA,EAAGC,aAAa,kBFHOD,OAC3BE,EAAa,wCAEbF,EAAGG,aAAa,YAChBD,EAAgBA,OAAeF,EAAGI,aAAa,WAG5CF,EEJ2BG,CAAoBL,IAC9CA,EAAGM,gBAAgB,mBAGlBhB,OAASb,EAAO8B,EAAKjB,gBAASP,EAAKK,KAC/BoB,kBAAkBzB,EAAKK,2CAIpCqB,MAAO,SAAUC,EAAMC,kBAAQ,IACrBlB,KAAKH,OAAOoB,UACTpB,OAAOoB,GAAQC,IAI5BC,mBAAUZ,eACDT,YAAYsB,KAAKb,GAEfP,KAAKH,QAGhBkB,2BAAkBzB,EAAKK,QACdG,YAAYT,iBAAQkB,GACN,cAAXA,EAAGc,MACHd,EAAGc,IAAIC,MAAMC,OAAS,CAACjC,EAAKK,QAMtC6B,EAAWC,OAAOC,oBAAsB,SAAUxC,GAAYA,KAEpEuC,OAAOC,mBAAqB,SAAUxC,GAClCuC,OAAO7B,OAASA,EAChB6B,OAAO7B,OAAOG,QAEdyB,EAAStC"} \ No newline at end of file diff --git a/dist/spruce.umd.js b/dist/spruce.umd.js new file mode 100644 index 0000000..26f2ea9 --- /dev/null +++ b/dist/spruce.umd.js @@ -0,0 +1,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(){var e=function(t,n){return Object.keys(t).forEach(function(r){Object.getPrototypeOf(t[r])===Object.prototype&&(t[r]=e(t[r],n))}),new Proxy(t,{set:function(t,r,i){return"object"==typeof i&&(i=e(i,n)),n(r,t[r]=i),!0}})},t={stores:{},subscribers:[],start:function(){try{var t=this;return Promise.resolve(new Promise(function(e){"loading"==document.readyState?document.addEventListener("DOMContentLoaded",e):e()})).then(function(){document.querySelectorAll("[x-subscribe]").forEach(function(e){e.setAttribute("x-init",function(e){var t="$store = Spruce.subscribe($el)";return e.hasAttribute("x-init")&&(t=t+"; "+e.getAttribute("x-init")),t}(e)),e.removeAttribute("x-subscribe")}),t.stores=e(t.stores,function(e,n){t.updateSubscribers(e,n)})})}catch(e){return Promise.reject(e)}},store:function(e,t){void 0===t&&(t={}),this.stores[e]||(this.stores[e]=t)},subscribe:function(e){return this.subscribers.push(e),this.stores},updateSubscribers:function(e,t){this.subscribers.forEach(function(n){"undefined"!==n.__x&&(n.__x.$data.spruce=[e,t])})}},n=window.deferLoadingAlpine||function(e){e()};return window.deferLoadingAlpine=function(e){window.Spruce=t,window.Spruce.start(),n(e)},t}); +//# sourceMappingURL=spruce.umd.js.map diff --git a/dist/spruce.umd.js.map b/dist/spruce.umd.js.map new file mode 100644 index 0000000..d845cba --- /dev/null +++ b/dist/spruce.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"spruce.umd.js","sources":["../src/utils.js","../src/observable.js","../src/index.js"],"sourcesContent":["export const domReady = () => {\n return new Promise(resolve => {\n if (document.readyState == \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", resolve)\n } else {\n resolve()\n }\n })\n}\n\nexport const buildInitExpression = el => {\n let expression = \"$store = Spruce.subscribe($el)\"\n\n if (el.hasAttribute('x-init')) {\n expression = `${expression}; ${el.getAttribute('x-init')}`\n }\n\n return expression\n}","export const create = (target, callback) => {\n Object.keys(target).forEach(key => {\n if (Object.getPrototypeOf(target[key]) === Object.prototype) {\n target[key] = create(target[key], callback)\n }\n })\n\n return new Proxy(target, {\n set(target, key, value) {\n if (typeof value === 'object') {\n value = create(value, callback)\n }\n\n callback(key, target[key] = value)\n\n return true\n }\n })\n}","import { domReady, buildInitExpression } from './utils'\nimport { create } from './observable'\n\nconst Spruce = {\n\n stores: {},\n\n subscribers: [],\n\n start: async function () {\n await domReady()\n\n document.querySelectorAll('[x-subscribe]').forEach(el => {\n el.setAttribute('x-init', buildInitExpression(el))\n el.removeAttribute('x-subscribe')\n })\n\n this.stores = create(this.stores, (key, value) => {\n this.updateSubscribers(key, value)\n })\n },\n\n store: function (name, state = {}) {\n if (! this.stores[name]) {\n this.stores[name] = state\n }\n },\n\n subscribe(el) {\n this.subscribers.push(el)\n\n return this.stores\n },\n\n updateSubscribers(key, value) {\n this.subscribers.forEach(el => {\n if (el.__x !== 'undefined') {\n el.__x.$data.spruce = [key, value]\n }\n })\n }\n}\n\nconst deferrer = window.deferLoadingAlpine || function (callback) { callback() }\n\nwindow.deferLoadingAlpine = function (callback) {\n window.Spruce = Spruce\n window.Spruce.start()\n\n deferrer(callback)\n}\n\nexport default Spruce"],"names":["const","create","target","callback","Object","keys","forEach","key","getPrototypeOf","prototype","Proxy","set","value","Spruce","stores","subscribers","start","this","Promise","resolve","document","readyState","addEventListener","querySelectorAll","el","setAttribute","expression","hasAttribute","getAttribute","buildInitExpression","removeAttribute","_this","updateSubscribers","store","name","state","subscribe","push","__x","$data","spruce","deferrer","window","deferLoadingAlpine"],"mappings":"qKAAOA,ICAMC,WAAUC,EAAQC,UAC3BC,OAAOC,KAAKH,GAAQI,iBAAQC,GACpBH,OAAOI,eAAeN,EAAOK,MAAUH,OAAOK,YAC9CP,EAAOK,GAAON,EAAOC,EAAOK,GAAMJ,MAInC,IAAIO,MAAMR,EAAQ,CACrBS,aAAIT,EAAQK,EAAKK,SACQ,iBAAVA,IACPA,EAAQX,EAAOW,EAAOT,IAG1BA,EAASI,EAAKL,EAAOK,GAAOK,IAErB,MCZbC,EAAS,CAEXC,OAAQ,GAERC,YAAa,GAEbC,2BAQIC,4BFhBG,IAAIC,iBAAQC,GACY,WAAvBC,SAASC,WACTD,SAASE,iBAAiB,mBAAoBH,GAE9CA,uBEOJC,SAASG,iBAAiB,iBAAiBjB,iBAAQkB,GAC/CA,EAAGC,aAAa,kBFHOD,OAC3BE,EAAa,wCAEbF,EAAGG,aAAa,YAChBD,EAAgBA,OAAeF,EAAGI,aAAa,WAG5CF,EEJ2BG,CAAoBL,IAC9CA,EAAGM,gBAAgB,mBAGlBhB,OAASb,EAAO8B,EAAKjB,gBAASP,EAAKK,KAC/BoB,kBAAkBzB,EAAKK,2CAIpCqB,MAAO,SAAUC,EAAMC,kBAAQ,IACrBlB,KAAKH,OAAOoB,UACTpB,OAAOoB,GAAQC,IAI5BC,mBAAUZ,eACDT,YAAYsB,KAAKb,GAEfP,KAAKH,QAGhBkB,2BAAkBzB,EAAKK,QACdG,YAAYT,iBAAQkB,GACN,cAAXA,EAAGc,MACHd,EAAGc,IAAIC,MAAMC,OAAS,CAACjC,EAAKK,QAMtC6B,EAAWC,OAAOC,oBAAsB,SAAUxC,GAAYA,YAEpEuC,OAAOC,mBAAqB,SAAUxC,GAClCuC,OAAO7B,OAASA,EAChB6B,OAAO7B,OAAOG,QAEdyB,EAAStC"} \ No newline at end of file