turbo_boost-streams 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbf5c6f7d153530d60e070a09d8310ddd7e7f0b894125f5f5154b12257058f81
4
- data.tar.gz: b5715c20c9defc1887cec395f733a5ce7b0b1402ea35dd3b71d5c9ebe46ca48b
3
+ metadata.gz: 5b04a77630df412d42825f69b9c4d10584331dd2dfff56cb1ef5f26f75250612
4
+ data.tar.gz: 214a7513bb8bd1b86ae13abf98d0616f621878dfb55c92de17ec175688270395
5
5
  SHA512:
6
- metadata.gz: d212f56f49fd2974592d8a677179036e59a672724dc96ea9cea42b4241448efbc1c7c51d5464b69a36dd0d3339f6e79e88b4224154d63e735ae88a8081f2b296
7
- data.tar.gz: 5438fecc2b4d15fe04962000269b2f6248f1083265bb222dbab3b24793e44cdb8b1a28318cc42275719ad027f160c77ca6181b84022eed97c30cb6fa9b4d2de9
6
+ metadata.gz: 55fd519d2d7cfc052e1a774ba7e8a1c78e3911f672fc92e927bb59206973728bee9c08f9b7d9d4b2328621f7971d9977c4fd37136eb5684834a34f702ec9f5e4
7
+ data.tar.gz: 7e37aa041e0359e9c040f9644ae1b1564326c3040253c48a459cd96a20ea9d8f0953417fb43174f064dabcfdd91176fa775ebf0ae39e9c317628db71657f3fb9
data/README.md CHANGED
@@ -429,14 +429,16 @@ fly deploy
429
429
  > Run these commands on the host machine _(i.e. not inside the dev container)_
430
430
 
431
431
  1. Run `npm update` and `bundle update` to pick up the latest dependencies
432
- 1. Bump version number at `lib/turbo_boost-streams/version.rb`. Pre-release versions use `.preN`
433
- 1. Bump version number at `package.json` _(make sure it matches)_. Pre-release versions use `-preN`
432
+ 1. Update the version number consistently in the following files:
433
+ * `lib/turbo_boost-streams/version.rb` - pre-release versions should use `.preN`
434
+ * `app/javascript/version.js` - pre-release versions use `-preN`
435
+ * `package.json` - pre-release versions use `-preN`
434
436
  1. Run `bin/standardize`
435
437
  1. Run `rake build`
436
438
  1. Run `npm run build`
437
439
  1. Commit and push any changes to GitHub
438
440
  1. Run `rake release`
439
- 1. Run `npm publish ???? --access public`
441
+ 1. Run `npm publish --access public`
440
442
  1. Create a new release on GitHub ([here](https://github.com/hopsoft/turbo_boost-streams/releases)) and generate the changelog for the stable release for it
441
443
 
442
444
  ## About TurboBoost
@@ -1,2 +1,2 @@
1
- var y=Object.defineProperty,g=Object.defineProperties;var A=Object.getOwnPropertyDescriptors;var v=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var d=(t,e,o)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,E=(t,e)=>{for(var o in e||(e={}))x.call(e,o)&&d(t,o,e[o]);if(v)for(var o of v(e))C.call(e,o)&&d(t,o,e[o]);return t},w=(t,e)=>g(t,A(e));import T from"alpinejs";import N from"@alpinejs/morph";T.plugin(N);var S=/INPUT/i,j=/date|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/i,B=/TEXTAREA/i;function M(t,e,o,r){if(t.nodeType!==Node.ELEMENT_NODE||t!==document.activeElement)return;if(t.tagName.match(B)||t.tagName.match(S)&&t.getAttribute("type").match(j))return r()}function p(t,e){T.morph(t,e,{updating:M})}var u={before:"turbo-boost:stream:before-invoke",after:"turbo-boost:stream:after-invoke",finish:"turbo-boost:stream:finish-invoke"};function m(t,e,o){let{object:r,target:i}=t;e=e||{},e=w(E({},e),{object:t.object});let n={detail:e,bubbles:!0};i.dispatchEvent(new CustomEvent(u.before,n));let{delay:s}=e.invoke||{};s=s||0;let a=()=>{let c=o(r);n.detail.result=c,i.dispatchEvent(new CustomEvent(u.after,n));let f;c instanceof Animation&&(f=c.finished),c instanceof Promise&&(f=c),f?f.then(()=>{n.detail.promise="fulfilled",i.dispatchEvent(new CustomEvent(u.finish,n))},()=>{n.detail.promise="rejected",i.dispatchEvent(new CustomEvent(u.finish,n))}):i.dispatchEvent(new CustomEvent(u.finish,n))};s>0?setTimeout(a,s):a()}function O(t,e,o){let r=e[0],i=e[1],n={method:t,eventName:r,eventOptions:i};o.forEach(s=>m(s,n,a=>a.dispatchEvent(new CustomEvent(r,i))))}function I(t,e,o){let r=e[0],i={method:t,html:r};o.forEach(n=>m(n,i,s=>p(s,r)))}function D(t,e,o){let r=t.slice(0,-1).trim(),i=e[0],n={method:t,property:r,value:i};o.forEach(s=>m(s,n,a=>a[r]=i))}function P(t,e,o){let r={method:t,args:e};o.forEach(i=>m(i,r,n=>n[t].apply(n,e)))}function k(t,e,o){return t.match(/^dispatch(Event)?$/)?O(t,e,o):t.match(/^morph|mutate$/)?I(t,e,o):t.endsWith("=")?D(t,e,o):P(t,e,o)}function l(){let t=JSON.parse(this.templateContent.textContent),{id:e,selector:o,receiver:r,method:i,args:n,delay:s}=t,a=[{object:self,target:self}];o&&(a=Array.from(document.querySelectorAll(o)).map(c=>({object:c,target:c}))),r&&(a=a.map(c=>{let{object:f,target:h}=c,b=r.split(".");for(;b.length>0;)f=f[b.shift()],f.dispatchEvent&&(h=f);return{object:f,target:h}})),s>0?setTimeout(()=>k(i,n,a),s):k(i,n,a)}if(!self.Turbo)throw new Error("`Turbo` is not defined! Be sure to import `@turbo-boost/streams` after `@hotwired/turbo` or `@hotwired/turbo-rails`.");if(!Turbo.StreamActions)throw new Error("`Turbo.StreamActions` is not defined! Verify that you are running >= `7.2.0` of `@hotwired/turbo`.");Turbo.StreamActions.invoke=l;self.TurboBoost=self.TurboBoost||{};self.TurboBoost.Streams={invoke:l,invokeEvents:u};console.info("@turbo-boost/streams has initialized and registered new stream actions with Turbo.");var W=self.TurboBoost.Streams;export{W as default};
1
+ var g=Object.defineProperty,A=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var v=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var d=(t,e,o)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,E=(t,e)=>{for(var o in e||(e={}))N.call(e,o)&&d(t,o,e[o]);if(v)for(var o of v(e))C.call(e,o)&&d(t,o,e[o]);return t},w=(t,e)=>A(t,x(e));var T="0.1.8";import k from"alpinejs";import S from"@alpinejs/morph";k.plugin(S);var j=/INPUT/i,B=/date|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/i,O=/TEXTAREA/i;function I(t,e,o,r){if(t.nodeType!==Node.ELEMENT_NODE||t!==document.activeElement)return;if(t.tagName.match(O)||t.tagName.match(j)&&t.getAttribute("type").match(B))return r()}function p(t,e){k.morph(t,e,{updating:I})}var u={before:"turbo-boost:stream:before-invoke",after:"turbo-boost:stream:after-invoke",finish:"turbo-boost:stream:finish-invoke"};function m(t,e,o){let{object:r,target:i}=t;e=e||{},e=w(E({},e),{object:t.object});let n={detail:e,bubbles:!0};i.dispatchEvent(new CustomEvent(u.before,n));let{delay:s}=e.invoke||{};s=s||0;let a=()=>{let c=o(r);n.detail.result=c,i.dispatchEvent(new CustomEvent(u.after,n));let f;c instanceof Animation&&(f=c.finished),c instanceof Promise&&(f=c),f?f.then(()=>{n.detail.promise="fulfilled",i.dispatchEvent(new CustomEvent(u.finish,n))},()=>{n.detail.promise="rejected",i.dispatchEvent(new CustomEvent(u.finish,n))}):i.dispatchEvent(new CustomEvent(u.finish,n))};s>0?setTimeout(a,s):a()}function M(t,e,o){let r=e[0],i=e[1],n={method:t,eventName:r,eventOptions:i};o.forEach(s=>m(s,n,a=>a.dispatchEvent(new CustomEvent(r,i))))}function D(t,e,o){let r=e[0],i={method:t,html:r};o.forEach(n=>m(n,i,s=>p(s,r)))}function P(t,e,o){let r=t.slice(0,-1).trim(),i=e[0],n={method:t,property:r,value:i};o.forEach(s=>m(s,n,a=>a[r]=i))}function R(t,e,o){let r={method:t,args:e};o.forEach(i=>m(i,r,n=>n[t].apply(n,e)))}function y(t,e,o){return t.match(/^dispatch(Event)?$/)?M(t,e,o):t.match(/^morph|mutate$/)?D(t,e,o):t.endsWith("=")?P(t,e,o):R(t,e,o)}function l(){let t=JSON.parse(this.templateContent.textContent),{id:e,selector:o,receiver:r,method:i,args:n,delay:s}=t,a=[{object:self,target:self}];o&&(a=Array.from(document.querySelectorAll(o)).map(c=>({object:c,target:c}))),r&&(a=a.map(c=>{let{object:f,target:h}=c,b=r.split(".");for(;b.length>0;)f=f[b.shift()],f.dispatchEvent&&(h=f);return{object:f,target:h}})),s>0?setTimeout(()=>y(i,n,a),s):y(i,n,a)}if(!self.Turbo)throw new Error("`Turbo` is not defined! Be sure to import `@turbo-boost/streams` after `@hotwired/turbo` or `@hotwired/turbo-rails`.");if(!Turbo.StreamActions)throw new Error("`Turbo.StreamActions` is not defined! Verify that you are running >= `7.2.0` of `@hotwired/turbo`.");Turbo.StreamActions.invoke=l;self.TurboBoost=self.TurboBoost||{};self.TurboBoost.Streams={invoke:l,invokeEvents:u,VERSION:T};console.info("@turbo-boost/streams has initialized and registered new stream actions with Turbo.");var F=self.TurboBoost.Streams;export{F as default};
2
2
  //# sourceMappingURL=streams.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../javascript/morph.js", "../../../javascript/invoke.js", "../../../javascript/index.js"],
4
- "sourcesContent": ["import alpine from 'alpinejs'\nimport alpineMorph from '@alpinejs/morph'\n\nalpine.plugin(alpineMorph)\n\nconst input = /INPUT/i\nconst inputTypes = /date|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/i\nconst textarea = /TEXTAREA/i\n\nfunction updating(el, toEl, childrenOnly, skip) {\n if (el.nodeType !== Node.ELEMENT_NODE) return\n if (el !== document.activeElement) return\n\n const protect =\n el.tagName.match(textarea) || (el.tagName.match(input) && el.getAttribute('type').match(inputTypes))\n\n if (protect) return skip()\n}\n\nexport default function morph(element, html) {\n alpine.morph(element, html, { updating })\n}\n", "import morph from './morph'\n\nexport const invokeEvents = {\n before: 'turbo-boost:stream:before-invoke',\n after: 'turbo-boost:stream:after-invoke',\n finish: 'turbo-boost:stream:finish-invoke'\n}\n\n// Invokes the callback on a single receiver with before/after events\nfunction withInvokeEvents(receiver, detail, callback) {\n const { object, target } = receiver\n detail = detail || {}\n detail = { ...detail, object: receiver.object }\n const options = { detail, bubbles: true }\n\n target.dispatchEvent(new CustomEvent(invokeEvents.before, options))\n\n // the before event can provide invoke instructions my modifying the event detail\n // For example, { delay: 1000 } will delay the invocation by 1000ms\n let { delay } = detail.invoke || {}\n delay = delay || 0\n\n const execute = () => {\n const result = callback(object)\n options.detail.result = result\n target.dispatchEvent(new CustomEvent(invokeEvents.after, options))\n\n let promise\n if (result instanceof Animation) promise = result.finished\n if (result instanceof Promise) promise = result\n\n if (promise)\n promise.then(\n () => {\n options.detail.promise = 'fulfilled'\n target.dispatchEvent(new CustomEvent(invokeEvents.finish, options))\n },\n () => {\n options.detail.promise = 'rejected'\n target.dispatchEvent(new CustomEvent(invokeEvents.finish, options))\n }\n )\n else target.dispatchEvent(new CustomEvent(invokeEvents.finish, options))\n }\n\n if (delay > 0) setTimeout(execute, delay)\n else execute()\n}\n\nfunction invokeDispatchEvent(method, args, receivers) {\n const eventName = args[0]\n const eventOptions = args[1]\n const detail = { method, eventName, eventOptions }\n receivers.forEach(receiver =>\n withInvokeEvents(receiver, detail, object =>\n object.dispatchEvent(new CustomEvent(eventName, eventOptions))\n )\n )\n}\n\nfunction invokeMorph(method, args, receivers) {\n const html = args[0]\n const detail = { method, html }\n receivers.forEach(receiver => withInvokeEvents(receiver, detail, object => morph(object, html)))\n}\n\nfunction invokeAssignment(method, args, receivers) {\n const property = method.slice(0, -1).trim()\n const value = args[0]\n const detail = { method, property, value }\n receivers.forEach(receiver => withInvokeEvents(receiver, detail, object => (object[property] = value)))\n}\n\nfunction invokeMethod(method, args, receivers) {\n const detail = { method, args }\n receivers.forEach(receiver =>\n withInvokeEvents(receiver, detail, object => object[method].apply(object, args))\n )\n}\n\n// Performs an invocation on all receivers for the given method and args\nfunction performInvoke(method, args, receivers) {\n // dispatch ................................................................................................\n if (method.match(/^dispatch(Event)?$/)) return invokeDispatchEvent(method, args, receivers)\n\n // morph ...................................................................................................\n if (method.match(/^morph|mutate$/)) return invokeMorph(method, args, receivers)\n\n // assignment ..............................................................................................\n if (method.endsWith('=')) return invokeAssignment(method, args, receivers)\n\n // method ..................................................................................................\n return invokeMethod(method, args, receivers)\n}\n\nexport function invoke() {\n const payload = JSON.parse(this.templateContent.textContent)\n const { id, selector, receiver, method, args, delay } = payload\n let receivers = [{ object: self, target: self }]\n if (selector)\n receivers = Array.from(document.querySelectorAll(selector)).map(el => ({\n object: el,\n target: el\n }))\n\n if (receiver) {\n receivers = receivers.map(r => {\n let { object, target } = r\n const chain = receiver.split('.')\n while (chain.length > 0) {\n object = object[chain.shift()]\n if (object.dispatchEvent) target = object\n }\n return { object, target }\n })\n }\n\n if (delay > 0) setTimeout(() => performInvoke(method, args, receivers), delay)\n else performInvoke(method, args, receivers)\n}\n", "import { invoke, invokeEvents } from './invoke'\n\nif (!self['Turbo'])\n throw new Error(\n '`Turbo` is not defined! Be sure to import `@turbo-boost/streams` after `@hotwired/turbo` or `@hotwired/turbo-rails`.'\n )\n\nif (!Turbo['StreamActions'])\n throw new Error(\n '`Turbo.StreamActions` is not defined! Verify that you are running >= `7.2.0` of `@hotwired/turbo`.'\n )\n\nTurbo.StreamActions.invoke = invoke\nself.TurboBoost = self.TurboBoost || {}\nself.TurboBoost.Streams = { invoke, invokeEvents }\n\nconsole.info('@turbo-boost/streams has initialized and registered new stream actions with Turbo.')\n\nexport default self.TurboBoost.Streams\n"],
5
- "mappings": "6aAAA,OAAOA,MAAY,WACnB,OAAOC,MAAiB,kBAExBD,EAAO,OAAOC,CAAW,EAEzB,IAAMC,EAAQ,SACRC,EAAa,uFACbC,EAAW,YAEjB,SAASC,EAASC,EAAIC,EAAMC,EAAcC,EAAM,CAE9C,GADIH,EAAG,WAAa,KAAK,cACrBA,IAAO,SAAS,cAAe,OAKnC,GAFEA,EAAG,QAAQ,MAAMF,CAAQ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AAQC,EAAMC,CAAS,CAC7C,CAEO,SAASW,GAAS,CACvB,IAAMC,EAAU,KAAK,MAAM,KAAK,gBAAgB,WAAW,EACrD,CAAE,GAAAC,EAAI,SAAAC,EAAU,SAAA7B,EAAU,OAAAa,EAAQ,KAAAC,EAAM,MAAAN,CAAM,EAAImB,EACpDZ,EAAY,CAAC,CAAE,OAAQ,KAAM,OAAQ,IAAK,CAAC,EAC3Cc,IACFd,EAAY,MAAM,KAAK,SAAS,iBAAiBc,CAAQ,CAAC,EAAE,IAAIC,IAAO,CACrE,OAAQA,EACR,OAAQA,CACV,EAAE,GAEA9B,IACFe,EAAYA,EAAU,IAAIgB,GAAK,CAC7B,GAAI,CAAE,OAAA5B,EAAQ,OAAAC,CAAO,EAAI2B,EACnBC,EAAQhC,EAAS,MAAM,GAAG,EAChC,KAAOgC,EAAM,OAAS,GACpB7B,EAASA,EAAO6B,EAAM,MAAM,CAAC,EACzB7B,EAAO,gBAAeC,EAASD,GAErC,MAAO,CAAE,OAAAA,EAAQ,OAAAC,CAAO,CAC1B,CAAC,GAGCI,EAAQ,EAAG,WAAW,IAAMiB,EAAcZ,EAAQC,EAAMC,CAAS,EAAGP,CAAK,EACxEiB,EAAcZ,EAAQC,EAAMC,CAAS,CAC5C,CCrHA,GAAI,CAAC,KAAK,MACR,MAAM,IAAI,MACR,sHACF,EAEF,GAAI,CAAC,MAAM,cACT,MAAM,IAAI,MACR,oGACF,EAEF,MAAM,cAAc,OAASkB,EAC7B,KAAK,WAAa,KAAK,YAAc,CAAC,EACtC,KAAK,WAAW,QAAU,CAAE,OAAAA,EAAQ,aAAAC,CAAa,EAEjD,QAAQ,KAAK,oFAAoF,EAEjG,IAAOC,EAAQ,KAAK,WAAW",
6
- "names": ["alpine", "alpineMorph", "input", "inputTypes", "textarea", "updating", "el", "toEl", "childrenOnly", "skip", "morph", "element", "html", "invokeEvents", "withInvokeEvents", "receiver", "detail", "callback", "object", "target", "__spreadProps", "__spreadValues", "options", "delay", "execute", "result", "promise", "invokeDispatchEvent", "method", "args", "receivers", "eventName", "eventOptions", "invokeMorph", "html", "morph", "invokeAssignment", "property", "value", "invokeMethod", "performInvoke", "invoke", "payload", "id", "selector", "el", "r", "chain", "invoke", "invokeEvents", "javascript_default"]
3
+ "sources": ["../../../javascript/version.js", "../../../javascript/morph.js", "../../../javascript/invoke.js", "../../../javascript/index.js"],
4
+ "sourcesContent": ["export default '0.1.8'\n", "import alpine from 'alpinejs'\nimport alpineMorph from '@alpinejs/morph'\n\nalpine.plugin(alpineMorph)\n\nconst input = /INPUT/i\nconst inputTypes = /date|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/i\nconst textarea = /TEXTAREA/i\n\nfunction updating(el, toEl, childrenOnly, skip) {\n if (el.nodeType !== Node.ELEMENT_NODE) return\n if (el !== document.activeElement) return\n\n const protect =\n el.tagName.match(textarea) || (el.tagName.match(input) && el.getAttribute('type').match(inputTypes))\n\n if (protect) return skip()\n}\n\nexport default function morph(element, html) {\n alpine.morph(element, html, { updating })\n}\n", "import morph from './morph'\n\nexport const invokeEvents = {\n before: 'turbo-boost:stream:before-invoke',\n after: 'turbo-boost:stream:after-invoke',\n finish: 'turbo-boost:stream:finish-invoke'\n}\n\n// Invokes the callback on a single receiver with before/after events\nfunction withInvokeEvents(receiver, detail, callback) {\n const { object, target } = receiver\n detail = detail || {}\n detail = { ...detail, object: receiver.object }\n const options = { detail, bubbles: true }\n\n target.dispatchEvent(new CustomEvent(invokeEvents.before, options))\n\n // the before event can provide invoke instructions my modifying the event detail\n // For example, { delay: 1000 } will delay the invocation by 1000ms\n let { delay } = detail.invoke || {}\n delay = delay || 0\n\n const execute = () => {\n const result = callback(object)\n options.detail.result = result\n target.dispatchEvent(new CustomEvent(invokeEvents.after, options))\n\n let promise\n if (result instanceof Animation) promise = result.finished\n if (result instanceof Promise) promise = result\n\n if (promise)\n promise.then(\n () => {\n options.detail.promise = 'fulfilled'\n target.dispatchEvent(new CustomEvent(invokeEvents.finish, options))\n },\n () => {\n options.detail.promise = 'rejected'\n target.dispatchEvent(new CustomEvent(invokeEvents.finish, options))\n }\n )\n else target.dispatchEvent(new CustomEvent(invokeEvents.finish, options))\n }\n\n if (delay > 0) setTimeout(execute, delay)\n else execute()\n}\n\nfunction invokeDispatchEvent(method, args, receivers) {\n const eventName = args[0]\n const eventOptions = args[1]\n const detail = { method, eventName, eventOptions }\n receivers.forEach(receiver =>\n withInvokeEvents(receiver, detail, object =>\n object.dispatchEvent(new CustomEvent(eventName, eventOptions))\n )\n )\n}\n\nfunction invokeMorph(method, args, receivers) {\n const html = args[0]\n const detail = { method, html }\n receivers.forEach(receiver => withInvokeEvents(receiver, detail, object => morph(object, html)))\n}\n\nfunction invokeAssignment(method, args, receivers) {\n const property = method.slice(0, -1).trim()\n const value = args[0]\n const detail = { method, property, value }\n receivers.forEach(receiver => withInvokeEvents(receiver, detail, object => (object[property] = value)))\n}\n\nfunction invokeMethod(method, args, receivers) {\n const detail = { method, args }\n receivers.forEach(receiver =>\n withInvokeEvents(receiver, detail, object => object[method].apply(object, args))\n )\n}\n\n// Performs an invocation on all receivers for the given method and args\nfunction performInvoke(method, args, receivers) {\n // dispatch ................................................................................................\n if (method.match(/^dispatch(Event)?$/)) return invokeDispatchEvent(method, args, receivers)\n\n // morph ...................................................................................................\n if (method.match(/^morph|mutate$/)) return invokeMorph(method, args, receivers)\n\n // assignment ..............................................................................................\n if (method.endsWith('=')) return invokeAssignment(method, args, receivers)\n\n // method ..................................................................................................\n return invokeMethod(method, args, receivers)\n}\n\nexport function invoke() {\n const payload = JSON.parse(this.templateContent.textContent)\n const { id, selector, receiver, method, args, delay } = payload\n let receivers = [{ object: self, target: self }]\n if (selector)\n receivers = Array.from(document.querySelectorAll(selector)).map(el => ({\n object: el,\n target: el\n }))\n\n if (receiver) {\n receivers = receivers.map(r => {\n let { object, target } = r\n const chain = receiver.split('.')\n while (chain.length > 0) {\n object = object[chain.shift()]\n if (object.dispatchEvent) target = object\n }\n return { object, target }\n })\n }\n\n if (delay > 0) setTimeout(() => performInvoke(method, args, receivers), delay)\n else performInvoke(method, args, receivers)\n}\n", "import VERSION from './version'\nimport { invoke, invokeEvents } from './invoke'\n\nif (!self['Turbo'])\n throw new Error(\n '`Turbo` is not defined! Be sure to import `@turbo-boost/streams` after `@hotwired/turbo` or `@hotwired/turbo-rails`.'\n )\n\nif (!Turbo['StreamActions'])\n throw new Error(\n '`Turbo.StreamActions` is not defined! Verify that you are running >= `7.2.0` of `@hotwired/turbo`.'\n )\n\nTurbo.StreamActions.invoke = invoke\nself.TurboBoost = self.TurboBoost || {}\nself.TurboBoost.Streams = { invoke, invokeEvents, VERSION }\n\nconsole.info('@turbo-boost/streams has initialized and registered new stream actions with Turbo.')\n\nexport default self.TurboBoost.Streams\n"],
5
+ "mappings": "6aAAA,IAAOA,EAAQ,QCAf,OAAOC,MAAY,WACnB,OAAOC,MAAiB,kBAExBD,EAAO,OAAOC,CAAW,EAEzB,IAAMC,EAAQ,SACRC,EAAa,uFACbC,EAAW,YAEjB,SAASC,EAASC,EAAIC,EAAMC,EAAcC,EAAM,CAE9C,GADIH,EAAG,WAAa,KAAK,cACrBA,IAAO,SAAS,cAAe,OAKnC,GAFEA,EAAG,QAAQ,MAAMF,CAAQ,GAAME,EAAG,QAAQ,MAAMJ,CAAK,GAAKI,EAAG,aAAa,MAAM,EAAE,MAAMH,CAAU,EAEvF,OAAOM,EAAK,CAC3B,CAEe,SAARC,EAAuBC,EAASC,EAAM,CAC3CZ,EAAO,MAAMW,EAASC,EAAM,CAAE,SAAAP,CAAS,CAAC,CAC1C,CCnBO,IAAMQ,EAAe,CAC1B,OAAQ,mCACR,MAAO,kCACP,OAAQ,kCACV,EAGA,SAASC,EAAiBC,EAAUC,EAAQC,EAAU,CACpD,GAAM,CAAE,OAAAC,EAAQ,OAAAC,CAAO,EAAIJ,EAC3BC,EAASA,GAAU,CAAC,EACpBA,EAASI,EAAAC,EAAA,GAAKL,GAAL,CAAa,OAAQD,EAAS,MA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CAAO,EAAI2B,EACnBC,EAAQhC,EAAS,MAAM,GAAG,EAChC,KAAOgC,EAAM,OAAS,GACpB7B,EAASA,EAAO6B,EAAM,MAAM,CAAC,EACzB7B,EAAO,gBAAeC,EAASD,GAErC,MAAO,CAAE,OAAAA,EAAQ,OAAAC,CAAO,CAC1B,CAAC,GAGCI,EAAQ,EAAG,WAAW,IAAMiB,EAAcZ,EAAQC,EAAMC,CAAS,EAAGP,CAAK,EACxEiB,EAAcZ,EAAQC,EAAMC,CAAS,CAC5C,CCpHA,GAAI,CAAC,KAAK,MACR,MAAM,IAAI,MACR,sHACF,EAEF,GAAI,CAAC,MAAM,cACT,MAAM,IAAI,MACR,oGACF,EAEF,MAAM,cAAc,OAASkB,EAC7B,KAAK,WAAa,KAAK,YAAc,CAAC,EACtC,KAAK,WAAW,QAAU,CAAE,OAAAA,EAAQ,aAAAC,EAAc,QAAAC,CAAQ,EAE1D,QAAQ,KAAK,oFAAoF,EAEjG,IAAOC,EAAQ,KAAK,WAAW",
6
+ "names": ["version_default", "alpine", "alpineMorph", "input", "inputTypes", "textarea", "updating", "el", "toEl", "childrenOnly", "skip", "morph", "element", "html", "invokeEvents", "withInvokeEvents", "receiver", "detail", "callback", "object", "target", "__spreadProps", "__spreadValues", "options", "delay", "execute", "result", "promise", "invokeDispatchEvent", "method", "args", "receivers", "eventName", "eventOptions", "invokeMorph", "html", "morph", "invokeAssignment", "property", "value", "invokeMethod", "performInvoke", "invoke", "payload", "id", "selector", "el", "r", "chain", "invoke", "invokeEvents", "version_default", "javascript_default"]
7
7
  }
@@ -1,3 +1,4 @@
1
+ import VERSION from './version'
1
2
  import { invoke, invokeEvents } from './invoke'
2
3
 
3
4
  if (!self['Turbo'])
@@ -12,7 +13,7 @@ if (!Turbo['StreamActions'])
12
13
 
13
14
  Turbo.StreamActions.invoke = invoke
14
15
  self.TurboBoost = self.TurboBoost || {}
15
- self.TurboBoost.Streams = { invoke, invokeEvents }
16
+ self.TurboBoost.Streams = { invoke, invokeEvents, VERSION }
16
17
 
17
18
  console.info('@turbo-boost/streams has initialized and registered new stream actions with Turbo.')
18
19
 
@@ -0,0 +1 @@
1
+ export default '0.1.8'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TurboBoost
4
4
  module Streams
5
- VERSION = "0.1.7"
5
+ VERSION = "0.1.8"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_boost-streams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Hopkins (hopsoft)
@@ -312,6 +312,7 @@ files:
312
312
  - app/javascript/index.js
313
313
  - app/javascript/invoke.js
314
314
  - app/javascript/morph.js
315
+ - app/javascript/version.js
315
316
  - app/jobs/turbo_boost/streams/broadcast_invoke_job.rb
316
317
  - lib/turbo_boost/streams.rb
317
318
  - lib/turbo_boost/streams/engine.rb