Browse Source

feat(emit events to window)

Ryan Chandler 5 years ago
parent
commit
25e7afbf53
7 changed files with 7 additions and 3 deletions
  1. 1 1
      dist/spruce.js
  2. 0 0
      dist/spruce.js.map
  3. 1 1
      dist/spruce.module.js
  4. 0 0
      dist/spruce.module.js.map
  5. 0 1
      dist/spruce.umd.js
  6. 0 0
      dist/spruce.umd.js.map
  7. 5 0
      src/bus.js

+ 1 - 1
dist/spruce.js

@@ -1,2 +1,2 @@
-var t=function(t){return null==t},e=function(n,s){return Object.keys(n).forEach(function(o){t(n[o])||Object.getPrototypeOf(n[o])!==Object.prototype||(n[o]=e(n[o],s))}),new Proxy(n,{get:function(t,e){return s.hasOwnProperty("get")&&s.get(e),t[e]},set:function(n,o,r){return t(r)||"object"!=typeof r||(r=e(r,s)),s.set(o,n[o]=r),!0}})},n={options:{globalStoreVariable:!1},events:{events:{},on:function(t,e){this.events.hasOwnProperty(t)||(this.events[t]=[]),this.events[t].push(e)},emit:function(t,e){void 0===e&&(e={}),this.events.hasOwnProperty(t)&&this.events[t].forEach(function(t){t(e)})}},stores:{},subscribers:[],start:function(){try{var t=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")}),t.stores=e(t.stores,{set:function(e,n){t.updateSubscribers(e,n)}}),t.options.globalStoreVariable&&(document.querySelectorAll("[x-data]").forEach(function(e){t.subscribers.includes(e)||t.subscribers.push(e)}),window.$store=t.stores)})}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(t){void 0!==t.__x&&(t.__x.$data.spruce=e)})},config:function(t){void 0===t&&(t={}),this.options=Object.assign(this.options,t)},on:function(t,e){this.events.on(t,e)}},s=window.deferLoadingAlpine||function(t){t()};window.deferLoadingAlpine=function(t){window.Spruce=n,window.Spruce.start(),s(t)},module.exports=n;
+var t=function(t){return null==t},e=function(n,s){return Object.keys(n).forEach(function(o){t(n[o])||Object.getPrototypeOf(n[o])!==Object.prototype||(n[o]=e(n[o],s))}),new Proxy(n,{get:function(t,e){return s.hasOwnProperty("get")&&s.get(e),t[e]},set:function(n,o,r){return t(r)||"object"!=typeof r||(r=e(r,s)),s.set(o,n[o]=r),!0}})},n={options:{globalStoreVariable:!1},events:{events:{},on:function(t,e){this.events.hasOwnProperty(t)||(this.events[t]=[]),this.events[t].push(e)},emit:function(t,e){void 0===e&&(e={}),this.events.hasOwnProperty(t)&&this.events[t].forEach(function(t){t(e)}),window.dispatchEvent(new CustomEvent("spruce:"+t,{data:e,bubbles:!0}))}},stores:{},subscribers:[],start:function(){try{var t=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")}),t.stores=e(t.stores,{set:function(e,n){t.updateSubscribers(e,n)}}),t.options.globalStoreVariable&&(document.querySelectorAll("[x-data]").forEach(function(e){t.subscribers.includes(e)||t.subscribers.push(e)}),window.$store=t.stores)})}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(t){void 0!==t.__x&&(t.__x.$data.spruce=e)})},config:function(t){void 0===t&&(t={}),this.options=Object.assign(this.options,t)},on:function(t,e){this.events.on(t,e)}},s=window.deferLoadingAlpine||function(t){t()};window.deferLoadingAlpine=function(t){window.Spruce=n,window.Spruce.start(),s(t)},module.exports=n;
 //# sourceMappingURL=spruce.js.map
 //# sourceMappingURL=spruce.js.map

File diff suppressed because it is too large
+ 0 - 0
dist/spruce.js.map


+ 1 - 1
dist/spruce.module.js

@@ -1,2 +1,2 @@
-var t=function(t){return null==t},e=function(n,s){return Object.keys(n).forEach(function(r){t(n[r])||Object.getPrototypeOf(n[r])!==Object.prototype||(n[r]=e(n[r],s))}),new Proxy(n,{get:function(t,e){return s.hasOwnProperty("get")&&s.get(e),t[e]},set:function(n,r,o){return t(o)||"object"!=typeof o||(o=e(o,s)),s.set(r,n[r]=o),!0}})},n={options:{globalStoreVariable:!1},events:{events:{},on:function(t,e){this.events.hasOwnProperty(t)||(this.events[t]=[]),this.events[t].push(e)},emit:function(t,e){void 0===e&&(e={}),this.events.hasOwnProperty(t)&&this.events[t].forEach(function(t){t(e)})}},stores:{},subscribers:[],start:function(){try{var t=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")}),t.stores=e(t.stores,{set:function(e,n){t.updateSubscribers(e,n)}}),t.options.globalStoreVariable&&(document.querySelectorAll("[x-data]").forEach(function(e){t.subscribers.includes(e)||t.subscribers.push(e)}),window.$store=t.stores)})}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(t){void 0!==t.__x&&(t.__x.$data.spruce=e)})},config:function(t){void 0===t&&(t={}),this.options=Object.assign(this.options,t)},on:function(t,e){this.events.on(t,e)}},s=window.deferLoadingAlpine||function(t){t()};window.deferLoadingAlpine=function(t){window.Spruce=n,window.Spruce.start(),s(t)};export default n;
+var t=function(t){return null==t},e=function(n,s){return Object.keys(n).forEach(function(o){t(n[o])||Object.getPrototypeOf(n[o])!==Object.prototype||(n[o]=e(n[o],s))}),new Proxy(n,{get:function(t,e){return s.hasOwnProperty("get")&&s.get(e),t[e]},set:function(n,o,r){return t(r)||"object"!=typeof r||(r=e(r,s)),s.set(o,n[o]=r),!0}})},n={options:{globalStoreVariable:!1},events:{events:{},on:function(t,e){this.events.hasOwnProperty(t)||(this.events[t]=[]),this.events[t].push(e)},emit:function(t,e){void 0===e&&(e={}),this.events.hasOwnProperty(t)&&this.events[t].forEach(function(t){t(e)}),window.dispatchEvent(new CustomEvent("spruce:"+t,{data:e,bubbles:!0}))}},stores:{},subscribers:[],start:function(){try{var t=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")}),t.stores=e(t.stores,{set:function(e,n){t.updateSubscribers(e,n)}}),t.options.globalStoreVariable&&(document.querySelectorAll("[x-data]").forEach(function(e){t.subscribers.includes(e)||t.subscribers.push(e)}),window.$store=t.stores)})}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(t){void 0!==t.__x&&(t.__x.$data.spruce=e)})},config:function(t){void 0===t&&(t={}),this.options=Object.assign(this.options,t)},on:function(t,e){this.events.on(t,e)}},s=window.deferLoadingAlpine||function(t){t()};window.deferLoadingAlpine=function(t){window.Spruce=n,window.Spruce.start(),s(t)};export default n;
 //# sourceMappingURL=spruce.module.js.map
 //# sourceMappingURL=spruce.module.js.map

File diff suppressed because it is too large
+ 0 - 0
dist/spruce.module.js.map


File diff suppressed because it is too large
+ 0 - 1
dist/spruce.umd.js


File diff suppressed because it is too large
+ 0 - 0
dist/spruce.umd.js.map


+ 5 - 0
src/bus.js

@@ -15,5 +15,10 @@ export default {
                 callback(data)
                 callback(data)
             })
             })
         }
         }
+
+        window.dispatchEvent(new CustomEvent(`spruce:${name}`, {
+            data,
+            bubbles: true
+        }))
     }
     }
 }
 }

Some files were not shown because too many files changed in this diff