turbo_boost-commands 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of turbo_boost-commands might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +4 -5
- data/app/assets/builds/@turbo-boost/commands.js +1 -1
- data/app/assets/builds/@turbo-boost/commands.js.map +3 -3
- data/app/assets/builds/@turbo-boost/commands.metafile.json +1 -1
- data/app/javascript/drivers/form.js +20 -2
- data/app/javascript/index.js +2 -1
- data/app/javascript/schema.js +5 -1
- data/lib/turbo_boost/commands/attribute_set.rb +2 -2
- data/lib/turbo_boost/commands/command.rb +3 -3
- data/lib/turbo_boost/commands/command_callbacks.rb +43 -16
- data/lib/turbo_boost/commands/engine.rb +1 -0
- data/lib/turbo_boost/commands/errors.rb +35 -3
- data/lib/turbo_boost/commands/http_status_codes.rb +19 -0
- data/lib/turbo_boost/commands/runner.rb +38 -22
- data/lib/turbo_boost/commands/sanitizer.rb +1 -1
- data/lib/turbo_boost/commands/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '03896d0847f47b30b0baa6251357572c9d03eb764e88cdf02efc888f43d5b7d7'
|
4
|
+
data.tar.gz: e76bec70fb1bd1f8cc9e4a974a867be56fa525af2233a58c3be1f162e3ae94a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dee19dc226ea80aa5cf7233fb3cad5a63fa2d39b97aa29bbeee4882ace90a561667bd0c67a1c61bc5767c4f7fceb62c77db23219886d46c68371f13752516fd
|
7
|
+
data.tar.gz: 3aa10da26edf138b8d5070b3436111e9966fc66abfcc57ee0bed2a282b5a1feb01cd45429ab61d716ed3559f1d8329298bd535b15940c7d7014532d48b4300fe
|
data/README.md
CHANGED
@@ -231,7 +231,7 @@ Just note that registered events are required to [bubble up through the DOM tree
|
|
231
231
|
// restrict `click` monitoring to <a> and <button> elements
|
232
232
|
TurboBoost.Commands.registerEventDelegate('click', [
|
233
233
|
'a[data-turbo-command]',
|
234
|
-
'button[data-command]'
|
234
|
+
'button[data-turbo-command]'
|
235
235
|
])
|
236
236
|
```
|
237
237
|
|
@@ -558,12 +558,11 @@ fly deploy
|
|
558
558
|
|
559
559
|
1. Run `yarn` and `bundle` to pick up the latest
|
560
560
|
1. Bump version number at `lib/turbo_boost-streams/version.rb`. Pre-release versions use `.preN`
|
561
|
-
1.
|
561
|
+
1. Bump version number at `package.json` _(make sure it matches)_. Pre-release versions use `-preN`
|
562
|
+
1. Run `yarn build` and `rake build`
|
562
563
|
1. Commit and push changes to GitHub
|
563
564
|
1. Run `rake release`
|
564
|
-
1. Run `yarn publish --no-git-tag-version --access public`
|
565
|
-
1. Yarn will prompt you for the new version. Pre-release versions use `-preN`
|
566
|
-
1. Commit and push changes to GitHub
|
565
|
+
1. Run `yarn publish --no-git-tag-version --access public --new-version X.X.X` _(use same version number)_
|
567
566
|
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
|
568
567
|
|
569
568
|
## About TurboBoost
|
@@ -1,2 +1,2 @@
|
|
1
|
-
var Z=Object.defineProperty,ee=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var _=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,s=(e,t)=>{for(var r in t||(t={}))re.call(t,r)&&_(e,r,t[r]);if(X)for(var r of X(t))oe.call(t,r)&&_(e,r,t[r]);return e},u=(e,t)=>ee(e,te(t));var O=class{get element(){return document.querySelector('meta[name="turbo-boost"]')}get token(){return this.element.getAttribute("content")}get busy(){return this.element.dataset.busy==="true"}set busy(t){return this.element.dataset.busy=!!t}},a=new O;var i={start:"turbo-boost:command:start",success:"turbo-boost:command:success",finish:"turbo-boost:command:finish",abort:"turbo-boost:command:abort",clientError:"turbo-boost:command:client-error",serverError:"turbo-boost:command:server-error"},l={stateLoad:"turbo-boost:state:load",stateChange:"turbo-boost:state:change"},f=s(s({},i),l);function d(e,t,r={}){return new Promise(o=>{r=r||{},r.detail=r.detail||{},t=t||document;let n=new CustomEvent(e,u(s({},r),{bubbles:!0}));t.dispatchEvent(n),o(n)})}var B;function k(e,t=null){if(!e||typeof e!="object")return e;let r=new Proxy(e,{deleteProperty(o,n){return delete o[n],d(l.stateChange,a.element,{detail:{state:B}}),!0},set(o,n,c,A){return o[n]=k(c,this),d(l.stateChange,a.element,{detail:{state:B}}),!0}});if(Array.isArray(e))e.forEach((o,n)=>e[n]=k(o,r));else if(typeof e=="object")for(let[o,n]of Object.entries(e))e[o]=k(n,r);return t||(B=r),r}var F=k;var D,g,C,N;function J(){if(!a.element)return E();let e=atob(a.element.dataset.state);C={},g=F(JSON.parse(e)),D=s({},g),delete a.element.dataset.clientStateChange,setTimeout(()=>d(l.stateLoad,a.element,{detail:{state:g}}))}function E(){clearTimeout(N),N=setTimeout(J,10)}D||J();addEventListener("DOMContentLoaded",E);addEventListener("load",E);addEventListener("turbo:load",E);addEventListener("turbo:frame-load",E);addEventListener(i.success,E);addEventListener(l.stateChange,e=>{C={};for(let[t,r]of Object.entries(g))D[t]!==r&&(C[t]=r);a.element.dataset.clientStateChange=!0,a.element.dataset.state=btoa(JSON.stringify(g))});var h={events:l,get current(){return g},get delta(){return C},get payloadChunks(){return btoa(JSON.stringify(C)).match(/.{1,2000}/g)}};function ne(e){let t="<html",r="</html",o=e.indexOf(t),n=e.lastIndexOf(r);if(o>=0&&n>=0){let c=e.slice(e.indexOf(">",o)+1,n);document.documentElement.innerHTML=c}}function se(e){document.body.insertAdjacentHTML("beforeend",e)}var v={append:se,replaceDocument:ne};var L={};function ae(e){L[e.id]=e}function ie(e){delete L[e]}var S={add:ae,remove:ie,get commands(){return[...Object.values(L)]},get length(){return Object.keys(L).length}};function M(e){e.detail.endedAt=Date.now(),e.detail.milliseconds=e.detail.endedAt-e.detail.startedAt,setTimeout(()=>d(i.finish,e.target,{detail:e.detail}),25)}addEventListener(i.serverError,M);addEventListener(i.success,M);addEventListener(i.finish,e=>S.remove(e.detail.id),!0);var T={events:i};var R={};addEventListener("turbo:before-fetch-request",e=>{let t=e.target.closest("turbo-frame"),{fetchOptions:r}=e.detail;if(a.busy){let o=["text/vnd.turbo-boost.html",r.headers.Accept];o=o.filter(n=>n&&n.trim().length>0).join(", "),r.headers.Accept=o,r.headers["TurboBoost-Token"]=a.token}h.payloadChunks.forEach((o,n)=>{r.headers[`TurboBoost-State-${n.toString().padStart(4,"0")}`]=o})});addEventListener("turbo:before-fetch-response",e=>{let t=e.target.closest("turbo-frame"),{fetchResponse:r}=e.detail;if(t&&(R[t.id]=t.src),r.header("TurboBoost")){if(r.statusCode<200||r.statusCode>399){let o=`Server returned a ${r.statusCode} status code! TurboBoost Commands require 2XX-3XX status codes.`;d(T.events.clientError,document,{detail:u(s({},e.detail),{error:o})},!0)}r.header("TurboBoost")==="Append"&&(e.preventDefault(),r.responseText.then(o=>v.append(o)))}});addEventListener("turbo:frame-load",e=>{let t=e.target.closest("turbo-frame");t.dataset.turboBoostSrc=R[t.id]||t.src||t.dataset.turboBoostSrc,delete R[t.id]});var de={frameAttribute:"data-turbo-frame",methodAttribute:"data-turbo-method",commandAttribute:"data-turbo-command",confirmAttribute:"data-turbo-confirm"},m=s({},de);var j={method:e=>Promise.resolve(confirm(e))},me=e=>e.detail.driver==="method",ue=e=>{if(e.detail.driver!=="form")return!1;let t=e.target,r=t.closest("turbo-frame"),o=t.closest(`[${m.frameAttribute}]`);return!!(r||o)},ce=e=>me(e)||ue(e);document.addEventListener(i.start,async e=>{let t=e.target.getAttribute(m.confirmAttribute);if(!t||(e.detail.confirmation=!0,ce(e)))return;await j.method(t)||e.preventDefault()});var W=j;var b=[],$;function le(e,t){let r=b.find(o=>o.name===e);return r&&b.splice(b.indexOf(r),1),b=[{name:e,selectors:t},...b],document.removeEventListener(e,$,!0),document.addEventListener(e,$,!0),s({},b.find(o=>o.name===e))}function fe(e){return b.find(t=>t.selectors.find(r=>Array.from(document.querySelectorAll(r)).find(o=>o===e)))}function be(e,t){let r=fe(t);return r&&r.name===e}var p={register:le,isRegisteredForElement:be,get events(){return[...b]},set handler(e){$=e}};function pe(e){return e.closest(`[${m.commandAttribute}]`)}function he(e){return e.closest("turbo-frame[src]")||e.closest("turbo-frame[data-turbo-frame-src]")||e.closest("turbo-frame")}function ve(e,t={}){if(e.tagName.toLowerCase()!=="select")return t.value=e.value||null;if(!e.multiple)return t.value=e.options[e.selectedIndex].value;t.values=Array.from(e.options).reduce((r,o)=>(o.selected&&r.push(o.value),r),[])}function ge(e){let t=Array.from(e.attributes).reduce((r,o)=>{let n=o.value;return r[o.name]=n,r},{});return t.tag=e.tagName,t.checked=!!e.checked,t.disabled=!!e.disabled,ve(e,t),delete t.class,delete t.action,delete t.href,delete t[m.commandAttribute],delete t[m.frameAttribute],t}var y={buildAttributePayload:ge,findClosestCommand:pe,findClosestFrameWithSource:he};function Ee(e,t={}){t.token=a.token;let r=document.createElement("input");r.type="hidden",r.name="turbo_boost_command",r.value=JSON.stringify(t),e.appendChild(r)}var U={invokeCommand:Ee};function xe(e,t={}){let r=document.createElement("a");r.href=e;let o=new URL(r);return o.searchParams.set("turbo_boost_command",JSON.stringify(t)),o}var x={build:xe};function Ce(e,t){let r=t.src;t=s({},t),delete t.src,e.src=x.build(r,t)}var H={invokeCommand:Ce};function Te(e,t={}){let r=t.src;t=s({},t),delete t.src,delete t.href,e.setAttribute("href",x.build(r,t))}var V={invokeCommand:Te};function ye(e){let t=e.target;d(T.events.abort,document,{detail:u(s({},e.detail),{xhr:t})})}function P(e){let t=e.target;t.getResponseHeader("TurboBoost")==="Append"||t.getResponseHeader("Content-Type").startsWith("text/vnd.turbo-boost.html")?v.append(t.responseText):v.replaceDocument(t.responseText);let o=`Server returned a ${t.status} status code! TurboBoost Commands require 2XX-3XX status codes.`;d(T.events.clientError,document,{detail:u(s({},e.detail),{error:o,xhr:t})},!0)}function Ae(e){let t=e.target;if(t.status<200||t.status>399)return P(e);let r=t.responseText;t.getResponseHeader("TurboBoost")==="Append"||t.getResponseHeader("Content-Type").startsWith("text/vnd.turbo-boost.html")?v.append(t.responseText):v.replaceDocument(t.responseText)}function ke(e){let t=e.src;e=s({},e),delete e.src;try{let r=new XMLHttpRequest;r.open("GET",x.build(t,e),!0),r.setRequestHeader("Accept","text/vnd.turbo-boost.html, text/html, application/xhtml+xml"),r.setRequestHeader("TurboBoost-Token",a.token),h.payloadChunks.forEach((o,n)=>r.setRequestHeader(`TurboBoost-State-${n.toString().padStart(4,"0")}`,o)),r.addEventListener("abort",ye),r.addEventListener("error",P),r.addEventListener("load",Ae),r.send()}catch(r){let o=`Unexpected error sending HTTP request! ${r.message}`;P(r,{detail:{message:o}})}}var G={invokeCommand:ke};function q(e,t){return t=t||{dataset:{}},e.href||t.src||t.dataset.turboBoostSrc||location.href}function Le(e){let t=y.findClosestFrameWithSource(e),{turboFrame:r,turboMethod:o}=e.dataset;return e.tagName.toLowerCase()==="form"?{name:"form",reason:"Element is a form.",frame:t,src:e.action,invokeCommand:U.invokeCommand}:o&&o.length>0?{name:"method",reason:"Element defines data-turbo-method.",frame:t,src:e.href,invokeCommand:V.invokeCommand}:r&&r!=="_self"?(t=document.getElementById(r),{name:"frame",reason:"element targets a frame that is not _self",frame:t,src:q(e,t),invokeCommand:H.invokeCommand}):(!r||r==="_self")&&t?{name:"frame",reason:"element does NOT target a frame or targets _self and is contained by a frame",frame:t,src:q(e,t),invokeCommand:H.invokeCommand}:{name:"window",reason:"element matches one or more of the following conditions (targets _top, does NOT target a frame, is NOT contained by a frame)",frame:null,src:q(e),invokeCommand:G.invokeCommand}}var I={find:Le};var w="unknown",z={debug:Object.values(f),info:Object.values(f),warn:[f.abort,f.clientError,f.serverError],error:[f.clientError,f.serverError],unknown:[]};Object.values(f).forEach(e=>{addEventListener(e,t=>{if(z[w].includes(t.type)){let{target:r,detail:o}=t;console[w](t.type,{target:r,detail:o})}})});var K={get level(){return w},set level(e){return Object.keys(z).includes(e)||(e="unknown"),w=e}};function Se(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}var Q={v4:Se};function Y(e,t){return{id:e,name:t.getAttribute(m.commandAttribute),elementId:t.id.length>0?t.id:null,elementAttributes:y.buildAttributePayload(t),startedAt:Date.now()}}async function we(e){let t,r={};try{if(t=y.findClosestCommand(e.target),!t||!p.isRegisteredForElement(e.type,t))return;let o=`turbo-command-${Q.v4()}`,n=I.find(t),c=u(s({},Y(o,t)),{driver:n.name,frameId:n.frame?n.frame.id:null,src:n.src}),A=await d(i.start,t,{cancelable:!0,detail:c});if(A.defaultPrevented||A.detail.confirmation&&e.defaultPrevented)return d(i.abort,t,{detail:{message:`An event handler for '${i.start}' prevented default behavior and blocked command invocation!`,source:A}});switch(n=I.find(t),c=u(s({},Y(o,t)),{driver:n.name,frameId:n.frame?n.frame.id:null,src:n.src}),S.add(c),["frame","window"].includes(n.name)&&e.preventDefault(),a.busy=!0,setTimeout(()=>a.busy=!1,10),n.name){case"method":return n.invokeCommand(t,c);case"form":return n.invokeCommand(t,c);case"frame":return n.invokeCommand(n.frame,c);case"window":return n.invokeCommand(c)}}catch(o){d(i.clientError,t,{detail:u(s({},r),{error:o})})}}self.TurboBoost=self.TurboBoost||{};self.TurboBoost=u(s({},self.TurboBoost),{stateEvents:l,get state(){return h.current},get stateDelta(){return h.delta}});self.TurboBoost.Commands||(p.handler=we,p.register("click",[`[${m.commandAttribute}]`]),p.register("submit",[`form[${m.commandAttribute}]`]),p.register("change",[`input[${m.commandAttribute}]`,`select[${m.commandAttribute}]`,`textarea[${m.commandAttribute}]`]),self.TurboBoost.Commands={confirmation:W,logger:K,schema:m,events:i,registerEventDelegate:p.register,get eventDelegates(){return p.events}});var Qt=self.TurboBoost.Commands;export{Qt as default};
|
1
|
+
var Z=Object.defineProperty,ee=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var I=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,a=(e,t)=>{for(var r in t||(t={}))re.call(t,r)&&I(e,r,t[r]);if(F)for(var r of F(t))oe.call(t,r)&&I(e,r,t[r]);return e},u=(e,t)=>ee(e,te(t));var B=class{get element(){return document.querySelector('meta[name="turbo-boost"]')}get token(){return this.element.getAttribute("content")}get busy(){return this.element.dataset.busy==="true"}set busy(t){return this.element.dataset.busy=!!t}},s=new B;var d={start:"turbo-boost:command:start",success:"turbo-boost:command:success",finish:"turbo-boost:command:finish",abort:"turbo-boost:command:abort",clientError:"turbo-boost:command:client-error",serverError:"turbo-boost:command:server-error"},l={stateLoad:"turbo-boost:state:load",stateChange:"turbo-boost:state:change"},f=a(a({},d),l);function m(e,t,r={}){return new Promise(o=>{r=r||{},r.detail=r.detail||{},t=t||document;let n=new CustomEvent(e,u(a({},r),{bubbles:!0}));t.dispatchEvent(n),o(n)})}var D;function k(e,t=null){if(!e||typeof e!="object")return e;let r=new Proxy(e,{deleteProperty(o,n){return delete o[n],m(l.stateChange,s.element,{detail:{state:D}}),!0},set(o,n,c,A){return o[n]=k(c,this),m(l.stateChange,s.element,{detail:{state:D}}),!0}});if(Array.isArray(e))e.forEach((o,n)=>e[n]=k(o,r));else if(typeof e=="object")for(let[o,n]of Object.entries(e))e[o]=k(n,r);return t||(D=r),r}var X=k;var S,g,C,N;function U(){if(!s.element)return E();let e=atob(s.element.dataset.state);C={},g=X(JSON.parse(e)),S=a({},g),delete s.element.dataset.clientStateChange,setTimeout(()=>m(l.stateLoad,s.element,{detail:{state:g}}))}function E(){clearTimeout(N),N=setTimeout(U,10)}S||U();addEventListener("DOMContentLoaded",E);addEventListener("load",E);addEventListener("turbo:load",E);addEventListener("turbo:frame-load",E);addEventListener(d.success,E);addEventListener(l.stateChange,e=>{C={};for(let[t,r]of Object.entries(g))S[t]!==r&&(C[t]=r);s.element.dataset.clientStateChange=!0,s.element.dataset.state=btoa(JSON.stringify(g))});var h={events:l,get current(){return g},get delta(){return C},get payloadChunks(){return btoa(JSON.stringify(C)).match(/.{1,2000}/g)}};function ne(e){let t="<html",r="</html",o=e.indexOf(t),n=e.lastIndexOf(r);if(o>=0&&n>=0){let c=e.slice(e.indexOf(">",o)+1,n);document.documentElement.innerHTML=c}}function ae(e){document.body.insertAdjacentHTML("beforeend",e)}var v={append:ae,replaceDocument:ne};var L={};function se(e){L[e.id]=e}function de(e){delete L[e]}var w={add:se,remove:de,get commands(){return[...Object.values(L)]},get length(){return Object.keys(L).length}};function M(e){e.detail.endedAt=Date.now(),e.detail.milliseconds=e.detail.endedAt-e.detail.startedAt,setTimeout(()=>m(d.finish,e.target,{detail:e.detail}),25)}addEventListener(d.serverError,M);addEventListener(d.success,M);addEventListener(d.finish,e=>w.remove(e.detail.id),!0);var y={events:d};var R={};addEventListener("turbo:before-fetch-request",e=>{let t=e.target.closest("turbo-frame"),{fetchOptions:r}=e.detail;if(s.busy){let o=["text/vnd.turbo-boost.html",r.headers.Accept];o=o.filter(n=>n&&n.trim().length>0).join(", "),r.headers.Accept=o,r.headers["TurboBoost-Token"]=s.token}h.payloadChunks.forEach((o,n)=>{r.headers[`TurboBoost-State-${n.toString().padStart(4,"0")}`]=o})});addEventListener("turbo:before-fetch-response",e=>{let t=e.target.closest("turbo-frame"),{fetchResponse:r}=e.detail;if(t&&(R[t.id]=t.src),r.header("TurboBoost")){if(r.statusCode<200||r.statusCode>399){let o=`Server returned a ${r.statusCode} status code! TurboBoost Commands require 2XX-3XX status codes.`;m(y.events.clientError,document,{detail:u(a({},e.detail),{error:o})},!0)}r.header("TurboBoost")==="Append"&&(e.preventDefault(),r.responseText.then(o=>v.append(o)))}});addEventListener("turbo:frame-load",e=>{let t=e.target.closest("turbo-frame");t.dataset.turboBoostSrc=R[t.id]||t.src||t.dataset.turboBoostSrc,delete R[t.id]});var ie={frameAttribute:"data-turbo-frame",methodAttribute:"data-turbo-method",commandAttribute:"data-turbo-command",confirmAttribute:"data-turbo-confirm",turboSubmitStartEvent:"turbo:submit-start"},i=a({},ie);var J={method:e=>Promise.resolve(confirm(e))},me=e=>e.detail.driver==="method",ue=e=>{if(e.detail.driver!=="form")return!1;let t=e.target,r=t.closest("turbo-frame"),o=t.closest(`[${i.frameAttribute}]`);return!!(r||o)},ce=e=>me(e)||ue(e);document.addEventListener(d.start,async e=>{let t=e.target.getAttribute(i.confirmAttribute);if(!t||(e.detail.confirmation=!0,ce(e)))return;await J.method(t)||e.preventDefault()});var j=J;var b=[],$;function le(e,t){let r=b.find(o=>o.name===e);return r&&b.splice(b.indexOf(r),1),b=[{name:e,selectors:t},...b],document.removeEventListener(e,$,!0),document.addEventListener(e,$,!0),a({},b.find(o=>o.name===e))}function fe(e){return b.find(t=>t.selectors.find(r=>Array.from(document.querySelectorAll(r)).find(o=>o===e)))}function pe(e,t){let r=fe(t);return r&&r.name===e}var p={register:le,isRegisteredForElement:pe,get events(){return[...b]},set handler(e){$=e}};function be(e){return e.closest(`[${i.commandAttribute}]`)}function he(e){return e.closest("turbo-frame[src]")||e.closest("turbo-frame[data-turbo-frame-src]")||e.closest("turbo-frame")}function ve(e,t={}){if(e.tagName.toLowerCase()!=="select")return t.value=e.value||null;if(!e.multiple)return t.value=e.options[e.selectedIndex].value;t.values=Array.from(e.options).reduce((r,o)=>(o.selected&&r.push(o.value),r),[])}function ge(e){let t=Array.from(e.attributes).reduce((r,o)=>{let n=o.value;return r[o.name]=n,r},{});return t.tag=e.tagName,t.checked=!!e.checked,t.disabled=!!e.disabled,ve(e,t),delete t.class,delete t.action,delete t.href,delete t[i.commandAttribute],delete t[i.frameAttribute],t}var T={buildAttributePayload:ge,findClosestCommand:be,findClosestFrameWithSource:he};function Ee(e){var r;if((e==null?void 0:e.formElement)instanceof HTMLFormElement&&(e==null?void 0:e.body)instanceof URLSearchParams&&((r=e==null?void 0:e.fetchRequest)==null?void 0:r.body)instanceof URLSearchParams){e.formData=new FormData(e.formElement);for(let[o,n]of e.formData.entries())e.fetchRequest.body.set(o,n),e.body.set(o,n);return e}}function xe(e,t={},r={}){t.token=s.token;let o=e.querySelector('input[name="turbo_boost_command"]')||document.createElement("input");o.type="hidden",o.name="turbo_boost_command",o.value=JSON.stringify(t),e.appendChild(o),Ee(r.detail.formSubmission)}var W={invokeCommand:xe};function Ce(e,t={}){let r=document.createElement("a");r.href=e;let o=new URL(r);return o.searchParams.set("turbo_boost_command",JSON.stringify(t)),o}var x={build:Ce};function ye(e,t){let r=t.src;t=a({},t),delete t.src,e.src=x.build(r,t)}var P={invokeCommand:ye};function Te(e,t={}){let r=t.src;t=a({},t),delete t.src,delete t.href,e.setAttribute("href",x.build(r,t))}var V={invokeCommand:Te};function Ae(e){let t=e.target;m(y.events.abort,document,{detail:u(a({},e.detail),{xhr:t})})}function q(e){let t=e.target;t.getResponseHeader("TurboBoost")==="Append"||t.getResponseHeader("Content-Type").startsWith("text/vnd.turbo-boost.html")?v.append(t.responseText):v.replaceDocument(t.responseText);let o=`Server returned a ${t.status} status code! TurboBoost Commands require 2XX-3XX status codes.`;m(y.events.clientError,document,{detail:u(a({},e.detail),{error:o,xhr:t})},!0)}function ke(e){let t=e.target;if(t.status<200||t.status>399)return q(e);let r=t.responseText;t.getResponseHeader("TurboBoost")==="Append"||t.getResponseHeader("Content-Type").startsWith("text/vnd.turbo-boost.html")?v.append(t.responseText):v.replaceDocument(t.responseText)}function Le(e){let t=e.src;e=a({},e),delete e.src;try{let r=new XMLHttpRequest;r.open("GET",x.build(t,e),!0),r.setRequestHeader("Accept","text/vnd.turbo-boost.html, text/html, application/xhtml+xml"),r.setRequestHeader("TurboBoost-Token",s.token),h.payloadChunks.forEach((o,n)=>r.setRequestHeader(`TurboBoost-State-${n.toString().padStart(4,"0")}`,o)),r.addEventListener("abort",Ae),r.addEventListener("error",q),r.addEventListener("load",ke),r.send()}catch(r){let o=`Unexpected error sending HTTP request! ${r.message}`;q(r,{detail:{message:o}})}}var G={invokeCommand:Le};function H(e,t){return t=t||{dataset:{}},e.href||t.src||t.dataset.turboBoostSrc||location.href}function we(e){let t=T.findClosestFrameWithSource(e),{turboFrame:r,turboMethod:o}=e.dataset;return e.tagName.toLowerCase()==="form"?{name:"form",reason:"Element is a form.",frame:t,src:e.action,invokeCommand:W.invokeCommand}:o&&o.length>0?{name:"method",reason:"Element defines data-turbo-method.",frame:t,src:e.href,invokeCommand:V.invokeCommand}:r&&r!=="_self"?(t=document.getElementById(r),{name:"frame",reason:"element targets a frame that is not _self",frame:t,src:H(e,t),invokeCommand:P.invokeCommand}):(!r||r==="_self")&&t?{name:"frame",reason:"element does NOT target a frame or targets _self and is contained by a frame",frame:t,src:H(e,t),invokeCommand:P.invokeCommand}:{name:"window",reason:"element matches one or more of the following conditions (targets _top, does NOT target a frame, is NOT contained by a frame)",frame:null,src:H(e),invokeCommand:G.invokeCommand}}var _={find:we};var O="unknown",z={debug:Object.values(f),info:Object.values(f),warn:[f.abort,f.clientError,f.serverError],error:[f.clientError,f.serverError],unknown:[]};Object.values(f).forEach(e=>{addEventListener(e,t=>{if(z[O].includes(t.type)){let{target:r,detail:o}=t;console[O](t.type,{target:r,detail:o})}})});var K={get level(){return O},set level(e){return Object.keys(z).includes(e)||(e="unknown"),O=e}};function Oe(){return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}var Q={v4:Oe};function Y(e,t){return{id:e,name:t.getAttribute(i.commandAttribute),elementId:t.id.length>0?t.id:null,elementAttributes:T.buildAttributePayload(t),startedAt:Date.now()}}async function Be(e){let t,r={};try{if(t=T.findClosestCommand(e.target),!t||!p.isRegisteredForElement(e.type,t))return;let o=`turbo-command-${Q.v4()}`,n=_.find(t),c=u(a({},Y(o,t)),{driver:n.name,frameId:n.frame?n.frame.id:null,src:n.src}),A=await m(d.start,t,{cancelable:!0,detail:c});if(A.defaultPrevented||A.detail.confirmation&&e.defaultPrevented)return m(d.abort,t,{detail:{message:`An event handler for '${d.start}' prevented default behavior and blocked command invocation!`,source:A}});switch(n=_.find(t),c=u(a({},Y(o,t)),{driver:n.name,frameId:n.frame?n.frame.id:null,src:n.src}),w.add(c),["frame","window"].includes(n.name)&&e.preventDefault(),s.busy=!0,setTimeout(()=>s.busy=!1,10),n.name){case"method":return n.invokeCommand(t,c);case"form":return n.invokeCommand(t,c,e);case"frame":return n.invokeCommand(n.frame,c);case"window":return n.invokeCommand(c)}}catch(o){m(d.clientError,t,{detail:u(a({},r),{error:o})})}}self.TurboBoost=self.TurboBoost||{};self.TurboBoost=u(a({},self.TurboBoost),{stateEvents:l,get state(){return h.current},get stateDelta(){return h.delta}});self.TurboBoost.Commands||(p.handler=Be,p.register("click",[`[${i.commandAttribute}]`]),p.register("submit",[`form[${i.commandAttribute}]`]),p.register(i.turboSubmitStartEvent,[`form[${i.commandAttribute}]`]),p.register("change",[`input[${i.commandAttribute}]`,`select[${i.commandAttribute}]`,`textarea[${i.commandAttribute}]`]),self.TurboBoost.Commands={confirmation:j,logger:K,schema:i,events:d,registerEventDelegate:p.register,get eventDelegates(){return p.events}});var Yt=self.TurboBoost.Commands;export{Yt as default};
|
2
2
|
//# sourceMappingURL=commands.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../javascript/meta.js", "../../../javascript/events.js", "../../../javascript/state/observable.js", "../../../javascript/state/index.js", "../../../javascript/renderer.js", "../../../javascript/activity.js", "../../../javascript/lifecycle.js", "../../../javascript/turbo.js", "../../../javascript/schema.js", "../../../javascript/confirmation.js", "../../../javascript/delegates.js", "../../../javascript/elements.js", "../../../javascript/drivers/form.js", "../../../javascript/urls.js", "../../../javascript/drivers/frame.js", "../../../javascript/drivers/method.js", "../../../javascript/drivers/window.js", "../../../javascript/drivers/index.js", "../../../javascript/logger.js", "../../../javascript/uuids.js", "../../../javascript/index.js"],
|
4
|
-
"sourcesContent": ["class Meta {\n get element() {\n return document.querySelector('meta[name=\"turbo-boost\"]')\n }\n\n get token() {\n return this.element.getAttribute('content')\n }\n\n get busy() {\n return this.element.dataset.busy === 'true'\n }\n\n set busy(value) {\n return (this.element.dataset.busy = !!value)\n }\n}\n\nexport default new Meta()\n", "export const commandEvents = {\n start: 'turbo-boost:command:start',\n success: 'turbo-boost:command:success',\n finish: 'turbo-boost:command:finish',\n abort: 'turbo-boost:command:abort',\n clientError: 'turbo-boost:command:client-error',\n serverError: 'turbo-boost:command:server-error'\n}\n\nexport const stateEvents = {\n stateLoad: 'turbo-boost:state:load',\n stateChange: 'turbo-boost:state:change'\n}\n\nexport const allEvents = { ...commandEvents, ...stateEvents }\n\nexport function dispatch(name, target, options = {}) {\n return new Promise(resolve => {\n options = options || {}\n options.detail = options.detail || {}\n target = target || document\n const evt = new CustomEvent(name, { ...options, bubbles: true })\n target.dispatchEvent(evt)\n resolve(evt)\n })\n}\n", "import meta from '../meta'\nimport { dispatch, stateEvents as events } from '../events'\n\nlet head\n\nfunction observable(object, parent = null) {\n if (!object || typeof object !== 'object') return object\n\n const proxy = new Proxy(object, {\n deleteProperty(target, key) {\n delete target[key]\n dispatch(events.stateChange, meta.element, { detail: { state: head } })\n return true\n },\n\n set(target, key, value, receiver) {\n target[key] = observable(value, this)\n dispatch(events.stateChange, meta.element, { detail: { state: head } })\n return true\n }\n })\n\n if (Array.isArray(object)) {\n object.forEach((value, index) => (object[index] = observable(value, proxy)))\n } else if (typeof object === 'object') {\n for (const [key, value] of Object.entries(object)) object[key] = observable(value, proxy)\n }\n\n if (!parent) head = proxy\n return proxy\n}\n\nexport default observable\n", "import meta from '../meta'\nimport observable from './observable'\nimport { dispatch, commandEvents, stateEvents } from '../events'\n\nlet loadedState, currentState, changedState\nlet loadStateTimeout\n\nfunction loadState() {\n if (!meta.element) return loadStateLater()\n const json = atob(meta.element.dataset.state)\n changedState = {}\n currentState = observable(JSON.parse(json))\n loadedState = { ...currentState }\n delete meta.element.dataset.clientStateChange\n setTimeout(() =>\n dispatch(stateEvents.stateLoad, meta.element, {\n detail: { state: currentState }\n })\n )\n}\n\nfunction loadStateLater() {\n clearTimeout(loadStateTimeout)\n loadStateTimeout = setTimeout(loadState, 10)\n}\n\nif (!loadedState) loadState()\n\naddEventListener('DOMContentLoaded', loadStateLater)\naddEventListener('load', loadStateLater)\naddEventListener('turbo:load', loadStateLater)\naddEventListener('turbo:frame-load', loadStateLater)\naddEventListener(commandEvents.success, loadStateLater)\n\naddEventListener(stateEvents.stateChange, event => {\n changedState = {}\n for (const [key, value] of Object.entries(currentState))\n if (loadedState[key] !== value) changedState[key] = value\n meta.element.dataset.clientStateChange = true\n meta.element.dataset.state = btoa(JSON.stringify(currentState))\n})\n\nexport default {\n events: stateEvents,\n\n get current() {\n return currentState\n },\n\n get delta() {\n return changedState\n },\n\n // The UI state changes are split into chunks and sent to the server in an HTTP request header.\n // Max size for an HTTP header is around 4k or 4,000 bytes.\n // A Base64 character is an 8-bit-padded ASCII character... or 1 byte\n //\n // SEE: lib/state.rb - for info on how `state` is serialized/deserialized\n get payloadChunks() {\n return btoa(JSON.stringify(changedState)).match(/.{1,2000}/g)\n }\n}\n", "function replaceDocument(content) {\n const head = '<html'\n const tail = '</html'\n const headIndex = content.indexOf(head)\n const tailIndex = content.lastIndexOf(tail)\n if (headIndex >= 0 && tailIndex >= 0) {\n const html = content.slice(content.indexOf('>', headIndex) + 1, tailIndex)\n document.documentElement.innerHTML = html\n }\n}\n\nfunction append(content) {\n document.body.insertAdjacentHTML('beforeend', content)\n}\n\nexport default { append, replaceDocument }\n", "const active = {}\n\nfunction add(payload) {\n active[payload.id] = payload\n}\n\nfunction remove(id) {\n delete active[id]\n}\n\nexport default {\n add,\n remove,\n get commands() {\n return [...Object.values(active)]\n },\n get length() {\n return Object.keys(active).length\n }\n}\n", "import activity from './activity'\nimport { dispatch, commandEvents } from './events'\n\nfunction finish(event) {\n event.detail.endedAt = Date.now()\n event.detail.milliseconds = event.detail.endedAt - event.detail.startedAt\n setTimeout(() => dispatch(commandEvents.finish, event.target, { detail: event.detail }), 25)\n}\n\n// TODO: forward source event to finish (error or success)\naddEventListener(commandEvents.serverError, finish)\naddEventListener(commandEvents.success, finish)\naddEventListener(commandEvents.finish, event => activity.remove(event.detail.id), true)\n\nexport default { events: commandEvents }\n", "import meta from './meta'\nimport state from './state'\nimport renderer from './renderer'\nimport { dispatch } from './events'\nimport lifecycle from './lifecycle'\n\nconst frameSources = {}\n\n// fires before making a turbo HTTP request\naddEventListener('turbo:before-fetch-request', event => {\n const frame = event.target.closest('turbo-frame')\n const { fetchOptions } = event.detail\n\n // command invoked and busy\n if (meta.busy) {\n let acceptHeaders = ['text/vnd.turbo-boost.html', fetchOptions.headers['Accept']]\n acceptHeaders = acceptHeaders.filter(entry => entry && entry.trim().length > 0).join(', ')\n fetchOptions.headers['Accept'] = acceptHeaders\n fetchOptions.headers['TurboBoost-Token'] = meta.token\n }\n\n // always send state\n state.payloadChunks.forEach((chunk, i) => {\n fetchOptions.headers[`TurboBoost-State-${i.toString().padStart(4, '0')}`] = chunk\n })\n})\n\n// fires after receiving a turbo HTTP response\naddEventListener('turbo:before-fetch-response', event => {\n const frame = event.target.closest('turbo-frame')\n const { fetchResponse: response } = event.detail\n\n if (frame) frameSources[frame.id] = frame.src\n\n if (response.header('TurboBoost')) {\n if (response.statusCode < 200 || response.statusCode > 399) {\n const error = `Server returned a ${response.statusCode} status code! TurboBoost Commands require 2XX-3XX status codes.`\n dispatch(lifecycle.events.clientError, document, { detail: { ...event.detail, error } }, true)\n }\n\n if (response.header('TurboBoost') === 'Append') {\n event.preventDefault()\n response.responseText.then(content => renderer.append(content))\n }\n }\n})\n\n// fires when a frame element is navigated and finishes loading\naddEventListener('turbo:frame-load', event => {\n const frame = event.target.closest('turbo-frame')\n frame.dataset.turboBoostSrc = frameSources[frame.id] || frame.src || frame.dataset.turboBoostSrc\n delete frameSources[frame.id]\n})\n", "const schema = {\n frameAttribute: 'data-turbo-frame',\n methodAttribute: 'data-turbo-method',\n commandAttribute: 'data-turbo-command',\n confirmAttribute: 'data-turbo-confirm'\n}\n\nexport default { ...schema }\n", "import { commandEvents } from './events'\nimport schema from './schema'\n\nconst confirmation = {\n method: message => Promise.resolve(confirm(message))\n}\n\nconst isTurboMethod = event => event.detail.driver === 'method'\n\nconst isTurboForm = event => {\n if (event.detail.driver !== 'form') return false\n\n const element = event.target\n const frame = element.closest('turbo-frame')\n const target = element.closest(`[${schema.frameAttribute}]`)\n return !!(frame || target)\n}\n\nconst shouldDelegate = event => isTurboMethod(event) || isTurboForm(event)\n\ndocument.addEventListener(commandEvents.start, async event => {\n const message = event.target.getAttribute(schema.confirmAttribute)\n if (!message) return\n\n event.detail.confirmation = true\n\n if (shouldDelegate(event)) return // delegate confirmation handling to Turbo\n\n const proceed = await confirmation.method(message)\n if (!proceed) event.preventDefault()\n})\n\nexport default confirmation\n", "let events = []\nlet eventListener\n\nfunction register(eventName, selectors) {\n const match = events.find(evt => evt.name === eventName)\n if (match) events.splice(events.indexOf(match), 1)\n events = [{ name: eventName, selectors }, ...events]\n\n document.removeEventListener(eventName, eventListener, true)\n document.addEventListener(eventName, eventListener, true)\n\n return { ...events.find(evt => evt.name === eventName) }\n}\n\nfunction getRegisteredEventForElement(element) {\n return events.find(evt =>\n evt.selectors.find(selector => Array.from(document.querySelectorAll(selector)).find(el => el === element))\n )\n}\n\nfunction isRegisteredForElement(eventName, element) {\n const evt = getRegisteredEventForElement(element)\n return evt && evt.name === eventName\n}\n\nexport default {\n register,\n isRegisteredForElement,\n get events() {\n return [...events]\n },\n set handler(fn) {\n eventListener = fn\n }\n}\n", "import schema from './schema'\nimport lifecycle from './lifecycle'\n\nfunction findClosestCommand(element) {\n return element.closest(`[${schema.commandAttribute}]`)\n}\n\nfunction findClosestFrameWithSource(element) {\n return (\n element.closest('turbo-frame[src]') ||\n element.closest('turbo-frame[data-turbo-frame-src]') ||\n element.closest('turbo-frame')\n )\n}\n\nfunction assignElementValueToPayload(element, payload = {}) {\n if (element.tagName.toLowerCase() !== 'select') return (payload.value = element.value || null)\n\n if (!element.multiple) return (payload.value = element.options[element.selectedIndex].value)\n\n payload.values = Array.from(element.options).reduce((memo, option) => {\n if (option.selected) memo.push(option.value)\n return memo\n }, [])\n}\n\nfunction buildAttributePayload(element) {\n const payload = Array.from(element.attributes).reduce((memo, attr) => {\n let value = attr.value\n memo[attr.name] = value\n return memo\n }, {})\n\n payload.tag = element.tagName\n payload.checked = !!element.checked\n payload.disabled = !!element.disabled\n assignElementValueToPayload(element, payload)\n\n // reduce payload size to keep URL length smaller\n delete payload.class\n delete payload.action\n delete payload.href\n delete payload[schema.commandAttribute]\n delete payload[schema.frameAttribute]\n\n return payload\n}\n\nexport default {\n buildAttributePayload,\n findClosestCommand,\n findClosestFrameWithSource\n}\n", "import meta from '../meta'\n\nfunction invokeCommand(form, payload = {}) {\n payload.token = meta.token\n const input = document.createElement('input')\n input.type = 'hidden'\n input.name = 'turbo_boost_command'\n input.value = JSON.stringify(payload)\n form.appendChild(input)\n}\n\nexport default { invokeCommand }\n", "function build(urlString, payload = {}) {\n const a = document.createElement('a')\n a.href = urlString\n const url = new URL(a)\n url.searchParams.set('turbo_boost_command', JSON.stringify(payload))\n return url\n}\n\nexport default { build }\n", "import urls from '../urls'\n\nfunction invokeCommand(frame, payload) {\n const src = payload.src\n payload = { ...payload }\n delete payload.src\n frame.src = urls.build(src, payload)\n}\n\nexport default { invokeCommand }\n", "import urls from '../urls'\n\nfunction invokeCommand(element, payload = {}) {\n const src = payload.src\n payload = { ...payload }\n delete payload.src\n delete payload.href\n element.setAttribute('href', urls.build(src, payload))\n}\n\nexport default { invokeCommand }\n", "import meta from '../meta'\nimport state from '../state'\nimport { dispatch } from '../events'\nimport lifecycle from '../lifecycle'\nimport urls from '../urls'\nimport renderer from '../renderer'\n\nfunction aborted(event) {\n const xhr = event.target\n dispatch(lifecycle.events.abort, document, {\n detail: { ...event.detail, xhr }\n })\n}\n\nfunction errored(event) {\n const xhr = event.target\n\n const append =\n xhr.getResponseHeader('TurboBoost') === 'Append' ||\n xhr.getResponseHeader('Content-Type').startsWith('text/vnd.turbo-boost.html')\n append ? renderer.append(xhr.responseText) : renderer.replaceDocument(xhr.responseText)\n\n const error = `Server returned a ${xhr.status} status code! TurboBoost Commands require 2XX-3XX status codes.`\n\n dispatch(lifecycle.events.clientError, document, { detail: { ...event.detail, error, xhr } }, true)\n}\n\nfunction loaded(event) {\n const xhr = event.target\n if (xhr.status < 200 || xhr.status > 399) return errored(event)\n const content = xhr.responseText\n const append =\n xhr.getResponseHeader('TurboBoost') === 'Append' ||\n xhr.getResponseHeader('Content-Type').startsWith('text/vnd.turbo-boost.html')\n append ? renderer.append(xhr.responseText) : renderer.replaceDocument(xhr.responseText)\n}\n\nfunction invokeCommand(payload) {\n const src = payload.src\n payload = { ...payload }\n delete payload.src\n\n try {\n const xhr = new XMLHttpRequest()\n xhr.open('GET', urls.build(src, payload), true)\n xhr.setRequestHeader('Accept', 'text/vnd.turbo-boost.html, text/html, application/xhtml+xml')\n xhr.setRequestHeader('TurboBoost-Token', meta.token)\n state.payloadChunks.forEach((chunk, i) =>\n xhr.setRequestHeader(`TurboBoost-State-${i.toString().padStart(4, '0')}`, chunk)\n )\n\n xhr.addEventListener('abort', aborted)\n xhr.addEventListener('error', errored)\n xhr.addEventListener('load', loaded)\n xhr.send()\n } catch (ex) {\n const message = `Unexpected error sending HTTP request! ${ex.message}`\n errored(ex, { detail: { message } })\n }\n}\n\nexport default { invokeCommand }\n", "import elements from '../elements'\nimport formDriver from './form'\nimport frameDriver from './frame'\nimport methodDriver from './method'\nimport windowDriver from './window'\n\nfunction src(element, frame) {\n frame = frame || { dataset: {} }\n return element.href || frame.src || frame.dataset.turboBoostSrc || location.href\n}\n\nfunction find(element) {\n let frame = elements.findClosestFrameWithSource(element)\n\n const { turboFrame, turboMethod } = element.dataset\n\n if (element.tagName.toLowerCase() === 'form')\n return {\n name: 'form',\n reason: 'Element is a form.',\n frame,\n src: element.action,\n invokeCommand: formDriver.invokeCommand\n }\n\n if (turboMethod && turboMethod.length > 0)\n return {\n name: 'method',\n reason: 'Element defines data-turbo-method.',\n frame,\n src: element.href,\n invokeCommand: methodDriver.invokeCommand\n }\n\n // element targets a frame that is not _self\n if (turboFrame && turboFrame !== '_self') {\n frame = document.getElementById(turboFrame)\n return {\n name: 'frame',\n reason: 'element targets a frame that is not _self',\n frame,\n src: src(element, frame),\n invokeCommand: frameDriver.invokeCommand\n }\n }\n\n // element does NOT target a frame or targets _self and is contained by a frame\n if ((!turboFrame || turboFrame === '_self') && frame)\n return {\n name: 'frame',\n reason: 'element does NOT target a frame or targets _self and is contained by a frame',\n frame,\n src: src(element, frame),\n invokeCommand: frameDriver.invokeCommand\n }\n\n // element matches one or more of the following conditions\n // - targets _top\n // - does NOT target a frame\n // - is NOT contained by a frame\n return {\n name: 'window',\n reason:\n 'element matches one or more of the following conditions (targets _top, does NOT target a frame, is NOT contained by a frame)',\n frame: null,\n src: src(element),\n invokeCommand: windowDriver.invokeCommand\n }\n}\n\nexport default { find }\n", "import { allEvents as events } from './events'\n\nlet currentLevel = 'unknown'\n\nconst logLevels = {\n debug: Object.values(events),\n info: Object.values(events),\n warn: [events.abort, events.clientError, events.serverError],\n error: [events.clientError, events.serverError],\n unknown: []\n}\n\nObject.values(events).forEach(name => {\n addEventListener(name, event => {\n if (logLevels[currentLevel].includes(event.type)) {\n const { target, detail } = event\n console[currentLevel](event.type, { target, detail })\n }\n })\n})\n\nexport default {\n get level() {\n return currentLevel\n },\n set level(value) {\n if (!Object.keys(logLevels).includes(value)) value = 'unknown'\n return (currentLevel = value)\n }\n}\n", "function v4() {\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>\n (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)\n )\n}\n\nexport default { v4 }\n", "import './turbo'\nimport schema from './schema'\nimport { dispatch, commandEvents, stateEvents } from './events'\nimport activity from './activity'\nimport confirmation from './confirmation'\nimport delegates from './delegates'\nimport drivers from './drivers'\nimport meta from './meta'\nimport elements from './elements'\nimport lifecycle from './lifecycle'\nimport logger from './logger'\nimport state from './state'\nimport urls from './urls'\nimport uuids from './uuids'\n\nfunction buildCommandPayload(id, element) {\n return {\n id, // uniquely identifies the command\n name: element.getAttribute(schema.commandAttribute),\n elementId: element.id.length > 0 ? element.id : null,\n elementAttributes: elements.buildAttributePayload(element),\n startedAt: Date.now()\n }\n}\n\nasync function invokeCommand(event) {\n let element\n let payload = {}\n\n try {\n element = elements.findClosestCommand(event.target)\n if (!element) return\n if (!delegates.isRegisteredForElement(event.type, element)) return\n\n const commandId = `turbo-command-${uuids.v4()}`\n let driver = drivers.find(element)\n let payload = {\n ...buildCommandPayload(commandId, element),\n driver: driver.name,\n frameId: driver.frame ? driver.frame.id : null,\n src: driver.src\n }\n\n const startEvent = await dispatch(commandEvents.start, element, {\n cancelable: true,\n detail: payload\n })\n\n if (startEvent.defaultPrevented || (startEvent.detail.confirmation && event.defaultPrevented))\n return dispatch(commandEvents.abort, element, {\n detail: {\n message: `An event handler for '${commandEvents.start}' prevented default behavior and blocked command invocation!`,\n source: startEvent\n }\n })\n\n // the element and thus the driver may have changed based on the start event handler(s)\n driver = drivers.find(element)\n payload = {\n ...buildCommandPayload(commandId, element),\n driver: driver.name,\n frameId: driver.frame ? driver.frame.id : null,\n src: driver.src\n }\n\n activity.add(payload)\n\n if (['frame', 'window'].includes(driver.name)) event.preventDefault()\n\n meta.busy = true\n setTimeout(() => (meta.busy = false), 10)\n\n switch (driver.name) {\n case 'method':\n return driver.invokeCommand(element, payload)\n case 'form':\n return driver.invokeCommand(element, payload)\n case 'frame':\n return driver.invokeCommand(driver.frame, payload)\n case 'window':\n return driver.invokeCommand(payload)\n }\n } catch (error) {\n dispatch(commandEvents.clientError, element, {\n detail: { ...payload, error }\n })\n }\n}\n\nself.TurboBoost = self.TurboBoost || {}\n\nself.TurboBoost = {\n ...self.TurboBoost,\n\n stateEvents,\n\n get state() {\n return state.current\n },\n\n get stateDelta() {\n return state.delta\n }\n}\n\nif (!self.TurboBoost.Commands) {\n // wire things up and setup defaults for event delegation\n delegates.handler = invokeCommand\n delegates.register('click', [`[${schema.commandAttribute}]`])\n delegates.register('submit', [`form[${schema.commandAttribute}]`])\n delegates.register('change', [\n `input[${schema.commandAttribute}]`,\n `select[${schema.commandAttribute}]`,\n `textarea[${schema.commandAttribute}]`\n ])\n\n self.TurboBoost.Commands = {\n confirmation,\n logger,\n schema,\n events: commandEvents,\n registerEventDelegate: delegates.register,\n get eventDelegates() {\n return delegates.events\n }\n }\n}\n\nexport default self.TurboBoost.Commands\n"],
|
5
|
-
"mappings": "qbAAA,IAAMA,EAAN,KAAW,CACT,IAAI,SAAU,CACZ,OAAO,SAAS,cAAc,0BAA0B,CAC1D,CAEA,IAAI,OAAQ,CACV,OAAO,KAAK,QAAQ,aAAa,SAAS,CAC5C,CAEA,IAAI,MAAO,CACT,OAAO,KAAK,QAAQ,QAAQ,OAAS,MACvC,CAEA,IAAI,KAAKC,EAAO,CACd,OAAQ,KAAK,QAAQ,QAAQ,KAAO,CAAC,CAACA,CACxC,CACF,EAEOC,EAAQ,IAAIF,EClBZ,IAAMG,EAAgB,CAC3B,MAAO,4BACP,QAAS,8BACT,OAAQ,6BACR,MAAO,4BACP,YAAa,mCACb,YAAa,kCACf,EAEaC,EAAc,CACzB,UAAW,yBACX,YAAa,0BACf,EAEaC,EAAYC,IAAA,GAAKH,GAAkBC,GAEzC,SAASG,EAASC,EAAMC,EAAQC,EAAU,CAAC,EAAG,CACnD,OAAO,IAAI,QAAQC,GAAW,CAC5BD,EAAUA,GAAW,CA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OA,EAAM,KACf,CACF,GAEK,KAAK,WAAW,WAEnBd,EAAU,QAAUH,GACpBG,EAAU,SAAS,QAAS,CAAC,IAAIL,EAAO,gBAAgB,GAAG,CAAC,EAC5DK,EAAU,SAAS,SAAU,CAAC,QAAQL,EAAO,gBAAgB,GAAG,CAAC,EACjEK,EAAU,SAAS,SAAU,CAC3B,SAASL,EAAO,gBAAgB,IAChC,UAAUA,EAAO,gBAAgB,IACjC,YAAYA,EAAO,gBAAgB,GACrC,CAAC,EAED,KAAK,WAAW,SAAW,CACzB,aAAAoB,EACA,OAAAC,EACA,OAAArB,EACA,OAAQc,EACR,sBAAuBT,EAAU,SACjC,IAAI,gBAAiB,CACnB,OAAOA,EAAU,MACnB,CACF,GAGF,IAAOiB,GAAQ,KAAK,WAAW",
|
6
|
-
"names": ["Meta", "value", "meta_default", "commandEvents", "stateEvents", "allEvents", "__spreadValues", "dispatch", "name", "target", "options", "resolve", "evt", "__spreadProps", "head", "observable", "object", "parent", "proxy", "target", "key", "dispatch", "stateEvents", "meta_default", "value", "receiver", "index", "observable_default", "loadedState", "currentState", "changedState", "loadStateTimeout", "loadState", "meta_default", "loadStateLater", "json", "observable_default", "__spreadValues", "dispatch", "stateEvents", "commandEvents", "event", "key", "value", "state_default", "replaceDocument", "content", "head", "tail", "headIndex", "tailIndex", "html", "append", "renderer_default", "active", "add", "payload", "remove", "id", "activity_default", "finish", "event", "dispatch", "commandEvents", "activity_default", "lifecycle_default", "frameSources", "event", "frame", "fetchOptions", "meta_default", "acceptHeaders", "entry", "state_default", "chunk", "i", "response", "error", "dispatch", "lifecycle_default", "__spreadProps", "__spreadValues", "content", "renderer_default", "schema", "schema_default", "__spreadValues", "confirmation", "message", "isTurboMethod", "event", "isTurboForm", "element", "frame", "target", "schema_default", "shouldDelegate", "commandEvents", "confirmation_default", "events", "eventListener", "register", "eventName", "selectors", "match", "evt", "__spreadValues", "getRegisteredEventForElement", "element", "selector", "el", "isRegisteredForElement", "delegates_default", "fn", "findClosestCommand", "element", "schema_default", "findClosestFrameWithSource", "assignElementValueToPayload", "payload", "memo", "option", "buildAttributePayload", "attr", "value", "elements_default", "invokeCommand", "form", "payload", "meta_default", "input", "form_default", "build", "urlString", "payload", "a", "url", "urls_default", "invokeCommand", "frame", "payload", "src", "__spreadValues", "urls_default", "frame_default", "invokeCommand", "element", "payload", "src", "__spreadValues", "urls_default", "method_default", "aborted", "event", "xhr", "dispatch", "lifecycle_default", "__spreadProps", "__spreadValues", "errored", "renderer_default", "error", "loaded", "content", "invokeCommand", "payload", "src", "urls_default", "meta_default", "state_default", "chunk", "i", "ex", "message", "window_default", "src", "element", "frame", "find", "elements_default", "turboFrame", "turboMethod", "form_default", "method_default", "frame_default", "window_default", "drivers_default", "currentLevel", "logLevels", "allEvents", "name", "event", "target", "detail", "logger_default", "value", "v4", "c", "uuids_default", "buildCommandPayload", "id", "element", "schema_default", "elements_default", "invokeCommand", "event", "payload", "delegates_default", "commandId", "uuids_default", "driver", "drivers_default", "__spreadProps", "__spreadValues", "startEvent", "dispatch", "commandEvents", "activity_default", "meta_default", "error", "stateEvents", "state_default", "confirmation_default", "logger_default", "javascript_default"]
|
4
|
+
"sourcesContent": ["class Meta {\n get element() {\n return document.querySelector('meta[name=\"turbo-boost\"]')\n }\n\n get token() {\n return this.element.getAttribute('content')\n }\n\n get busy() {\n return this.element.dataset.busy === 'true'\n }\n\n set busy(value) {\n return (this.element.dataset.busy = !!value)\n }\n}\n\nexport default new Meta()\n", "export const commandEvents = {\n start: 'turbo-boost:command:start',\n success: 'turbo-boost:command:success',\n finish: 'turbo-boost:command:finish',\n abort: 'turbo-boost:command:abort',\n clientError: 'turbo-boost:command:client-error',\n serverError: 'turbo-boost:command:server-error'\n}\n\nexport const stateEvents = {\n stateLoad: 'turbo-boost:state:load',\n stateChange: 'turbo-boost:state:change'\n}\n\nexport const allEvents = { ...commandEvents, ...stateEvents }\n\nexport function dispatch(name, target, options = {}) {\n return new Promise(resolve => {\n options = options || {}\n options.detail = options.detail || {}\n target = target || document\n const evt = new CustomEvent(name, { ...options, bubbles: true })\n target.dispatchEvent(evt)\n resolve(evt)\n })\n}\n", "import meta from '../meta'\nimport { dispatch, stateEvents as events } from '../events'\n\nlet head\n\nfunction observable(object, parent = null) {\n if (!object || typeof object !== 'object') return object\n\n const proxy = new Proxy(object, {\n deleteProperty(target, key) {\n delete target[key]\n dispatch(events.stateChange, meta.element, { detail: { state: head } })\n return true\n },\n\n set(target, key, value, receiver) {\n target[key] = observable(value, this)\n dispatch(events.stateChange, meta.element, { detail: { state: head } })\n return true\n }\n })\n\n if (Array.isArray(object)) {\n object.forEach((value, index) => (object[index] = observable(value, proxy)))\n } else if (typeof object === 'object') {\n for (const [key, value] of Object.entries(object)) object[key] = observable(value, proxy)\n }\n\n if (!parent) head = proxy\n return proxy\n}\n\nexport default observable\n", "import meta from '../meta'\nimport observable from './observable'\nimport { dispatch, commandEvents, stateEvents } from '../events'\n\nlet loadedState, currentState, changedState\nlet loadStateTimeout\n\nfunction loadState() {\n if (!meta.element) return loadStateLater()\n const json = atob(meta.element.dataset.state)\n changedState = {}\n currentState = observable(JSON.parse(json))\n loadedState = { ...currentState }\n delete meta.element.dataset.clientStateChange\n setTimeout(() =>\n dispatch(stateEvents.stateLoad, meta.element, {\n detail: { state: currentState }\n })\n )\n}\n\nfunction loadStateLater() {\n clearTimeout(loadStateTimeout)\n loadStateTimeout = setTimeout(loadState, 10)\n}\n\nif (!loadedState) loadState()\n\naddEventListener('DOMContentLoaded', loadStateLater)\naddEventListener('load', loadStateLater)\naddEventListener('turbo:load', loadStateLater)\naddEventListener('turbo:frame-load', loadStateLater)\naddEventListener(commandEvents.success, loadStateLater)\n\naddEventListener(stateEvents.stateChange, event => {\n changedState = {}\n for (const [key, value] of Object.entries(currentState))\n if (loadedState[key] !== value) changedState[key] = value\n meta.element.dataset.clientStateChange = true\n meta.element.dataset.state = btoa(JSON.stringify(currentState))\n})\n\nexport default {\n events: stateEvents,\n\n get current() {\n return currentState\n },\n\n get delta() {\n return changedState\n },\n\n // The UI state changes are split into chunks and sent to the server in an HTTP request header.\n // Max size for an HTTP header is around 4k or 4,000 bytes.\n // A Base64 character is an 8-bit-padded ASCII character... or 1 byte\n //\n // SEE: lib/state.rb - for info on how `state` is serialized/deserialized\n get payloadChunks() {\n return btoa(JSON.stringify(changedState)).match(/.{1,2000}/g)\n }\n}\n", "function replaceDocument(content) {\n const head = '<html'\n const tail = '</html'\n const headIndex = content.indexOf(head)\n const tailIndex = content.lastIndexOf(tail)\n if (headIndex >= 0 && tailIndex >= 0) {\n const html = content.slice(content.indexOf('>', headIndex) + 1, tailIndex)\n document.documentElement.innerHTML = html\n }\n}\n\nfunction append(content) {\n document.body.insertAdjacentHTML('beforeend', content)\n}\n\nexport default { append, replaceDocument }\n", "const active = {}\n\nfunction add(payload) {\n active[payload.id] = payload\n}\n\nfunction remove(id) {\n delete active[id]\n}\n\nexport default {\n add,\n remove,\n get commands() {\n return [...Object.values(active)]\n },\n get length() {\n return Object.keys(active).length\n }\n}\n", "import activity from './activity'\nimport { dispatch, commandEvents } from './events'\n\nfunction finish(event) {\n event.detail.endedAt = Date.now()\n event.detail.milliseconds = event.detail.endedAt - event.detail.startedAt\n setTimeout(() => dispatch(commandEvents.finish, event.target, { detail: event.detail }), 25)\n}\n\n// TODO: forward source event to finish (error or success)\naddEventListener(commandEvents.serverError, finish)\naddEventListener(commandEvents.success, finish)\naddEventListener(commandEvents.finish, event => activity.remove(event.detail.id), true)\n\nexport default { events: commandEvents }\n", "import meta from './meta'\nimport state from './state'\nimport renderer from './renderer'\nimport { dispatch } from './events'\nimport lifecycle from './lifecycle'\n\nconst frameSources = {}\n\n// fires before making a turbo HTTP request\naddEventListener('turbo:before-fetch-request', event => {\n const frame = event.target.closest('turbo-frame')\n const { fetchOptions } = event.detail\n\n // command invoked and busy\n if (meta.busy) {\n let acceptHeaders = ['text/vnd.turbo-boost.html', fetchOptions.headers['Accept']]\n acceptHeaders = acceptHeaders.filter(entry => entry && entry.trim().length > 0).join(', ')\n fetchOptions.headers['Accept'] = acceptHeaders\n fetchOptions.headers['TurboBoost-Token'] = meta.token\n }\n\n // always send state\n state.payloadChunks.forEach((chunk, i) => {\n fetchOptions.headers[`TurboBoost-State-${i.toString().padStart(4, '0')}`] = chunk\n })\n})\n\n// fires after receiving a turbo HTTP response\naddEventListener('turbo:before-fetch-response', event => {\n const frame = event.target.closest('turbo-frame')\n const { fetchResponse: response } = event.detail\n\n if (frame) frameSources[frame.id] = frame.src\n\n if (response.header('TurboBoost')) {\n if (response.statusCode < 200 || response.statusCode > 399) {\n const error = `Server returned a ${response.statusCode} status code! TurboBoost Commands require 2XX-3XX status codes.`\n dispatch(lifecycle.events.clientError, document, { detail: { ...event.detail, error } }, true)\n }\n\n if (response.header('TurboBoost') === 'Append') {\n event.preventDefault()\n response.responseText.then(content => renderer.append(content))\n }\n }\n})\n\n// fires when a frame element is navigated and finishes loading\naddEventListener('turbo:frame-load', event => {\n const frame = event.target.closest('turbo-frame')\n frame.dataset.turboBoostSrc = frameSources[frame.id] || frame.src || frame.dataset.turboBoostSrc\n delete frameSources[frame.id]\n})\n", "const schema = {\n // attributes\n frameAttribute: 'data-turbo-frame',\n methodAttribute: 'data-turbo-method',\n commandAttribute: 'data-turbo-command',\n confirmAttribute: 'data-turbo-confirm',\n\n // events\n turboSubmitStartEvent: 'turbo:submit-start'\n}\n\nexport default { ...schema }\n", "import { commandEvents } from './events'\nimport schema from './schema'\n\nconst confirmation = {\n method: message => Promise.resolve(confirm(message))\n}\n\nconst isTurboMethod = event => event.detail.driver === 'method'\n\nconst isTurboForm = event => {\n if (event.detail.driver !== 'form') return false\n\n const element = event.target\n const frame = element.closest('turbo-frame')\n const target = element.closest(`[${schema.frameAttribute}]`)\n return !!(frame || target)\n}\n\nconst shouldDelegate = event => isTurboMethod(event) || isTurboForm(event)\n\ndocument.addEventListener(commandEvents.start, async event => {\n const message = event.target.getAttribute(schema.confirmAttribute)\n if (!message) return\n\n event.detail.confirmation = true\n\n if (shouldDelegate(event)) return // delegate confirmation handling to Turbo\n\n const proceed = await confirmation.method(message)\n if (!proceed) event.preventDefault()\n})\n\nexport default confirmation\n", "let events = []\nlet eventListener\n\nfunction register(eventName, selectors) {\n const match = events.find(evt => evt.name === eventName)\n if (match) events.splice(events.indexOf(match), 1)\n events = [{ name: eventName, selectors }, ...events]\n\n document.removeEventListener(eventName, eventListener, true)\n document.addEventListener(eventName, eventListener, true)\n\n return { ...events.find(evt => evt.name === eventName) }\n}\n\nfunction getRegisteredEventForElement(element) {\n return events.find(evt =>\n evt.selectors.find(selector => Array.from(document.querySelectorAll(selector)).find(el => el === element))\n )\n}\n\nfunction isRegisteredForElement(eventName, element) {\n const evt = getRegisteredEventForElement(element)\n return evt && evt.name === eventName\n}\n\nexport default {\n register,\n isRegisteredForElement,\n get events() {\n return [...events]\n },\n set handler(fn) {\n eventListener = fn\n }\n}\n", "import schema from './schema'\nimport lifecycle from './lifecycle'\n\nfunction findClosestCommand(element) {\n return element.closest(`[${schema.commandAttribute}]`)\n}\n\nfunction findClosestFrameWithSource(element) {\n return (\n element.closest('turbo-frame[src]') ||\n element.closest('turbo-frame[data-turbo-frame-src]') ||\n element.closest('turbo-frame')\n )\n}\n\nfunction assignElementValueToPayload(element, payload = {}) {\n if (element.tagName.toLowerCase() !== 'select') return (payload.value = element.value || null)\n\n if (!element.multiple) return (payload.value = element.options[element.selectedIndex].value)\n\n payload.values = Array.from(element.options).reduce((memo, option) => {\n if (option.selected) memo.push(option.value)\n return memo\n }, [])\n}\n\nfunction buildAttributePayload(element) {\n const payload = Array.from(element.attributes).reduce((memo, attr) => {\n let value = attr.value\n memo[attr.name] = value\n return memo\n }, {})\n\n payload.tag = element.tagName\n payload.checked = !!element.checked\n payload.disabled = !!element.disabled\n assignElementValueToPayload(element, payload)\n\n // reduce payload size to keep URL length smaller\n delete payload.class\n delete payload.action\n delete payload.href\n delete payload[schema.commandAttribute]\n delete payload[schema.frameAttribute]\n\n return payload\n}\n\nexport default {\n buildAttributePayload,\n findClosestCommand,\n findClosestFrameWithSource\n}\n", "import meta from '../meta'\n\nfunction updateFormSubmission(formSubmission) {\n const shouldUpdate =\n formSubmission?.formElement instanceof HTMLFormElement &&\n formSubmission?.body instanceof URLSearchParams &&\n formSubmission?.fetchRequest?.body instanceof URLSearchParams\n\n if (!shouldUpdate) return\n\n formSubmission.formData = new FormData(formSubmission.formElement)\n for (const [key, value] of formSubmission.formData.entries()) {\n formSubmission.fetchRequest.body.set(key, value)\n formSubmission.body.set(key, value)\n }\n\n return formSubmission\n}\n\nfunction invokeCommand(form, payload = {}, event = {}) {\n payload.token = meta.token\n const input = form.querySelector('input[name=\"turbo_boost_command\"]') || document.createElement('input')\n input.type = 'hidden'\n input.name = 'turbo_boost_command'\n input.value = JSON.stringify(payload)\n form.appendChild(input)\n updateFormSubmission(event.detail.formSubmission)\n}\n\nexport default { invokeCommand }\n", "function build(urlString, payload = {}) {\n const a = document.createElement('a')\n a.href = urlString\n const url = new URL(a)\n url.searchParams.set('turbo_boost_command', JSON.stringify(payload))\n return url\n}\n\nexport default { build }\n", "import urls from '../urls'\n\nfunction invokeCommand(frame, payload) {\n const src = payload.src\n payload = { ...payload }\n delete payload.src\n frame.src = urls.build(src, payload)\n}\n\nexport default { invokeCommand }\n", "import urls from '../urls'\n\nfunction invokeCommand(element, payload = {}) {\n const src = payload.src\n payload = { ...payload }\n delete payload.src\n delete payload.href\n element.setAttribute('href', urls.build(src, payload))\n}\n\nexport default { invokeCommand }\n", "import meta from '../meta'\nimport state from '../state'\nimport { dispatch } from '../events'\nimport lifecycle from '../lifecycle'\nimport urls from '../urls'\nimport renderer from '../renderer'\n\nfunction aborted(event) {\n const xhr = event.target\n dispatch(lifecycle.events.abort, document, {\n detail: { ...event.detail, xhr }\n })\n}\n\nfunction errored(event) {\n const xhr = event.target\n\n const append =\n xhr.getResponseHeader('TurboBoost') === 'Append' ||\n xhr.getResponseHeader('Content-Type').startsWith('text/vnd.turbo-boost.html')\n append ? renderer.append(xhr.responseText) : renderer.replaceDocument(xhr.responseText)\n\n const error = `Server returned a ${xhr.status} status code! TurboBoost Commands require 2XX-3XX status codes.`\n\n dispatch(lifecycle.events.clientError, document, { detail: { ...event.detail, error, xhr } }, true)\n}\n\nfunction loaded(event) {\n const xhr = event.target\n if (xhr.status < 200 || xhr.status > 399) return errored(event)\n const content = xhr.responseText\n const append =\n xhr.getResponseHeader('TurboBoost') === 'Append' ||\n xhr.getResponseHeader('Content-Type').startsWith('text/vnd.turbo-boost.html')\n append ? renderer.append(xhr.responseText) : renderer.replaceDocument(xhr.responseText)\n}\n\nfunction invokeCommand(payload) {\n const src = payload.src\n payload = { ...payload }\n delete payload.src\n\n try {\n const xhr = new XMLHttpRequest()\n xhr.open('GET', urls.build(src, payload), true)\n xhr.setRequestHeader('Accept', 'text/vnd.turbo-boost.html, text/html, application/xhtml+xml')\n xhr.setRequestHeader('TurboBoost-Token', meta.token)\n state.payloadChunks.forEach((chunk, i) =>\n xhr.setRequestHeader(`TurboBoost-State-${i.toString().padStart(4, '0')}`, chunk)\n )\n\n xhr.addEventListener('abort', aborted)\n xhr.addEventListener('error', errored)\n xhr.addEventListener('load', loaded)\n xhr.send()\n } catch (ex) {\n const message = `Unexpected error sending HTTP request! ${ex.message}`\n errored(ex, { detail: { message } })\n }\n}\n\nexport default { invokeCommand }\n", "import elements from '../elements'\nimport formDriver from './form'\nimport frameDriver from './frame'\nimport methodDriver from './method'\nimport windowDriver from './window'\n\nfunction src(element, frame) {\n frame = frame || { dataset: {} }\n return element.href || frame.src || frame.dataset.turboBoostSrc || location.href\n}\n\nfunction find(element) {\n let frame = elements.findClosestFrameWithSource(element)\n\n const { turboFrame, turboMethod } = element.dataset\n\n if (element.tagName.toLowerCase() === 'form')\n return {\n name: 'form',\n reason: 'Element is a form.',\n frame,\n src: element.action,\n invokeCommand: formDriver.invokeCommand\n }\n\n if (turboMethod && turboMethod.length > 0)\n return {\n name: 'method',\n reason: 'Element defines data-turbo-method.',\n frame,\n src: element.href,\n invokeCommand: methodDriver.invokeCommand\n }\n\n // element targets a frame that is not _self\n if (turboFrame && turboFrame !== '_self') {\n frame = document.getElementById(turboFrame)\n return {\n name: 'frame',\n reason: 'element targets a frame that is not _self',\n frame,\n src: src(element, frame),\n invokeCommand: frameDriver.invokeCommand\n }\n }\n\n // element does NOT target a frame or targets _self and is contained by a frame\n if ((!turboFrame || turboFrame === '_self') && frame)\n return {\n name: 'frame',\n reason: 'element does NOT target a frame or targets _self and is contained by a frame',\n frame,\n src: src(element, frame),\n invokeCommand: frameDriver.invokeCommand\n }\n\n // element matches one or more of the following conditions\n // - targets _top\n // - does NOT target a frame\n // - is NOT contained by a frame\n return {\n name: 'window',\n reason:\n 'element matches one or more of the following conditions (targets _top, does NOT target a frame, is NOT contained by a frame)',\n frame: null,\n src: src(element),\n invokeCommand: windowDriver.invokeCommand\n }\n}\n\nexport default { find }\n", "import { allEvents as events } from './events'\n\nlet currentLevel = 'unknown'\n\nconst logLevels = {\n debug: Object.values(events),\n info: Object.values(events),\n warn: [events.abort, events.clientError, events.serverError],\n error: [events.clientError, events.serverError],\n unknown: []\n}\n\nObject.values(events).forEach(name => {\n addEventListener(name, event => {\n if (logLevels[currentLevel].includes(event.type)) {\n const { target, detail } = event\n console[currentLevel](event.type, { target, detail })\n }\n })\n})\n\nexport default {\n get level() {\n return currentLevel\n },\n set level(value) {\n if (!Object.keys(logLevels).includes(value)) value = 'unknown'\n return (currentLevel = value)\n }\n}\n", "function v4() {\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>\n (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)\n )\n}\n\nexport default { v4 }\n", "import './turbo'\nimport schema from './schema'\nimport { dispatch, commandEvents, stateEvents } from './events'\nimport activity from './activity'\nimport confirmation from './confirmation'\nimport delegates from './delegates'\nimport drivers from './drivers'\nimport meta from './meta'\nimport elements from './elements'\nimport lifecycle from './lifecycle'\nimport logger from './logger'\nimport state from './state'\nimport urls from './urls'\nimport uuids from './uuids'\n\nfunction buildCommandPayload(id, element) {\n return {\n id, // uniquely identifies the command\n name: element.getAttribute(schema.commandAttribute),\n elementId: element.id.length > 0 ? element.id : null,\n elementAttributes: elements.buildAttributePayload(element),\n startedAt: Date.now()\n }\n}\n\nasync function invokeCommand(event) {\n let element\n let payload = {}\n\n try {\n element = elements.findClosestCommand(event.target)\n if (!element) return\n if (!delegates.isRegisteredForElement(event.type, element)) return\n\n const commandId = `turbo-command-${uuids.v4()}`\n let driver = drivers.find(element)\n let payload = {\n ...buildCommandPayload(commandId, element),\n driver: driver.name,\n frameId: driver.frame ? driver.frame.id : null,\n src: driver.src\n }\n\n const startEvent = await dispatch(commandEvents.start, element, {\n cancelable: true,\n detail: payload\n })\n\n if (startEvent.defaultPrevented || (startEvent.detail.confirmation && event.defaultPrevented))\n return dispatch(commandEvents.abort, element, {\n detail: {\n message: `An event handler for '${commandEvents.start}' prevented default behavior and blocked command invocation!`,\n source: startEvent\n }\n })\n\n // the element and thus the driver may have changed based on the start event handler(s)\n driver = drivers.find(element)\n payload = {\n ...buildCommandPayload(commandId, element),\n driver: driver.name,\n frameId: driver.frame ? driver.frame.id : null,\n src: driver.src\n }\n\n activity.add(payload)\n\n if (['frame', 'window'].includes(driver.name)) event.preventDefault()\n\n meta.busy = true\n setTimeout(() => (meta.busy = false), 10)\n\n switch (driver.name) {\n case 'method':\n return driver.invokeCommand(element, payload)\n case 'form':\n return driver.invokeCommand(element, payload, event)\n case 'frame':\n return driver.invokeCommand(driver.frame, payload)\n case 'window':\n return driver.invokeCommand(payload)\n }\n } catch (error) {\n dispatch(commandEvents.clientError, element, {\n detail: { ...payload, error }\n })\n }\n}\n\nself.TurboBoost = self.TurboBoost || {}\n\nself.TurboBoost = {\n ...self.TurboBoost,\n\n stateEvents,\n\n get state() {\n return state.current\n },\n\n get stateDelta() {\n return state.delta\n }\n}\n\nif (!self.TurboBoost.Commands) {\n // wire things up and setup defaults for event delegation\n delegates.handler = invokeCommand\n delegates.register('click', [`[${schema.commandAttribute}]`])\n delegates.register('submit', [`form[${schema.commandAttribute}]`])\n delegates.register(schema.turboSubmitStartEvent, [`form[${schema.commandAttribute}]`])\n delegates.register('change', [\n `input[${schema.commandAttribute}]`,\n `select[${schema.commandAttribute}]`,\n `textarea[${schema.commandAttribute}]`\n ])\n\n self.TurboBoost.Commands = {\n confirmation,\n logger,\n schema,\n events: commandEvents,\n registerEventDelegate: delegates.register,\n get eventDelegates() {\n return delegates.events\n }\n }\n}\n\nexport default self.TurboBoost.Commands\n"],
|
5
|
+
"mappings": "qbAAA,IAAMA,EAAN,KAAW,CACT,IAAI,SAAU,CACZ,OAAO,SAAS,cAAc,0BAA0B,CAC1D,CAEA,IAAI,OAAQ,CACV,OAAO,KAAK,QAAQ,aAAa,SAAS,CAC5C,CAEA,IAAI,MAAO,CACT,OAAO,KAAK,QAAQ,QAAQ,OAAS,MACvC,CAEA,IAAI,KAAKC,EAAO,CACd,OAAQ,KAAK,QAAQ,QAAQ,KAAO,CAAC,CAACA,CACxC,CACF,EAEOC,EAAQ,IAAIF,EClBZ,IAAMG,EAAgB,CAC3B,MAAO,4BACP,QAAS,8BACT,OAAQ,6BACR,MAAO,4BACP,YAAa,mCACb,YAAa,kCACf,EAEaC,EAAc,CACzB,UAAW,yBACX,YAAa,0BACf,EAEaC,EAAYC,IAAA,GAAKH,GAAkBC,GAEzC,SAASG,EAASC,EAAMC,EAAQC,EAAU,CAAC,EAAG,CACnD,OAAO,IAAI,QAAQC,GAAW,CAC5BD,EAAUA,GAAW,CAAC,EACtBA,EAAQ,OAASA,EAAQ,QAAU,CAAC,EACpCD,EAASA,GAAU,SACnB,IAAMG,EAAM,IAAI,YAAYJ,EAAMK,EAAAP,EAAA,GAAKI,GAAL,CAAc,QAAS,EAAK,EAAC,EAC/DD,EAAO,cAAcG,CAAG,EACxBD,EAAQC,CAAG,CACb,CAAC,CACH,CCtBA,I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,CAC3C,OAAQW,EAAAC,EAAA,GAAKP,GAAL,CAAc,MAAAa,CAAM,EAC9B,CAAC,CACH,CACF,CAEA,KAAK,WAAa,KAAK,YAAc,CAAC,EAEtC,KAAK,WAAaP,EAAAC,EAAA,GACb,KAAK,YADQ,CAGhB,YAAAO,EAEA,IAAI,OAAQ,CACV,OAAOC,EAAM,OACf,EAEA,IAAI,YAAa,CACf,OAAOA,EAAM,KACf,CACF,GAEK,KAAK,WAAW,WAEnBd,EAAU,QAAUH,GACpBG,EAAU,SAAS,QAAS,CAAC,IAAIL,EAAO,gBAAgB,GAAG,CAAC,EAC5DK,EAAU,SAAS,SAAU,CAAC,QAAQL,EAAO,gBAAgB,GAAG,CAAC,EACjEK,EAAU,SAASL,EAAO,sBAAuB,CAAC,QAAQA,EAAO,gBAAgB,GAAG,CAAC,EACrFK,EAAU,SAAS,SAAU,CAC3B,SAASL,EAAO,gBAAgB,IAChC,UAAUA,EAAO,gBAAgB,IACjC,YAAYA,EAAO,gBAAgB,GACrC,CAAC,EAED,KAAK,WAAW,SAAW,CACzB,aAAAoB,EACA,OAAAC,EACA,OAAArB,EACA,OAAQc,EACR,sBAAuBT,EAAU,SACjC,IAAI,gBAAiB,CACnB,OAAOA,EAAU,MACnB,CACF,GAGF,IAAOiB,GAAQ,KAAK,WAAW",
|
6
|
+
"names": ["Meta", "value", "meta_default", "commandEvents", "stateEvents", "allEvents", "__spreadValues", "dispatch", "name", "target", "options", "resolve", "evt", "__spreadProps", "head", "observable", "object", "parent", "proxy", "target", "key", "dispatch", "stateEvents", "meta_default", "value", "receiver", "index", "observable_default", "loadedState", "currentState", "changedState", "loadStateTimeout", "loadState", "meta_default", "loadStateLater", "json", "observable_default", "__spreadValues", "dispatch", "stateEvents", "commandEvents", "event", "key", "value", "state_default", "replaceDocument", "content", "head", "tail", "headIndex", "tailIndex", "html", "append", "renderer_default", "active", "add", "payload", "remove", "id", "activity_default", "finish", "event", "dispatch", "commandEvents", "activity_default", "lifecycle_default", "frameSources", "event", "frame", "fetchOptions", "meta_default", "acceptHeaders", "entry", "state_default", "chunk", "i", "response", "error", "dispatch", "lifecycle_default", "__spreadProps", "__spreadValues", "content", "renderer_default", "schema", "schema_default", "__spreadValues", "confirmation", "message", "isTurboMethod", "event", "isTurboForm", "element", "frame", "target", "schema_default", "shouldDelegate", "commandEvents", "confirmation_default", "events", "eventListener", "register", "eventName", "selectors", "match", "evt", "__spreadValues", "getRegisteredEventForElement", "element", "selector", "el", "isRegisteredForElement", "delegates_default", "fn", "findClosestCommand", "element", "schema_default", "findClosestFrameWithSource", "assignElementValueToPayload", "payload", "memo", "option", "buildAttributePayload", "attr", "value", "elements_default", "updateFormSubmission", "formSubmission", "_a", "key", "value", "invokeCommand", "form", "payload", "event", "meta_default", "input", "form_default", "build", "urlString", "payload", "a", "url", "urls_default", "invokeCommand", "frame", "payload", "src", "__spreadValues", "urls_default", "frame_default", "invokeCommand", "element", "payload", "src", "__spreadValues", "urls_default", "method_default", "aborted", "event", "xhr", "dispatch", "lifecycle_default", "__spreadProps", "__spreadValues", "errored", "renderer_default", "error", "loaded", "content", "invokeCommand", "payload", "src", "urls_default", "meta_default", "state_default", "chunk", "i", "ex", "message", "window_default", "src", "element", "frame", "find", "elements_default", "turboFrame", "turboMethod", "form_default", "method_default", "frame_default", "window_default", "drivers_default", "currentLevel", "logLevels", "allEvents", "name", "event", "target", "detail", "logger_default", "value", "v4", "c", "uuids_default", "buildCommandPayload", "id", "element", "schema_default", "elements_default", "invokeCommand", "event", "payload", "delegates_default", "commandId", "uuids_default", "driver", "drivers_default", "__spreadProps", "__spreadValues", "startEvent", "dispatch", "commandEvents", "activity_default", "meta_default", "error", "stateEvents", "state_default", "confirmation_default", "logger_default", "javascript_default"]
|
7
7
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"inputs":{"app/javascript/meta.js":{"bytes":337,"imports":[],"format":"esm"},"app/javascript/events.js":{"bytes":783,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/state/observable.js":{"bytes":920,"imports":[{"path":"app/javascript/meta.js","kind":"import-statement","original":"../meta"},{"path":"app/javascript/events.js","kind":"import-statement","original":"../events"}],"format":"esm"},"app/javascript/state/index.js":{"bytes":1835,"imports":[{"path":"app/javascript/meta.js","kind":"import-statement","original":"../meta"},{"path":"app/javascript/state/observable.js","kind":"import-statement","original":"./observable"},{"path":"app/javascript/events.js","kind":"import-statement","original":"../events"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/renderer.js":{"bytes":475,"imports":[],"format":"esm"},"app/javascript/activity.js":{"bytes":279,"imports":[],"format":"esm"},"app/javascript/lifecycle.js":{"bytes":610,"imports":[{"path":"app/javascript/activity.js","kind":"import-statement","original":"./activity"},{"path":"app/javascript/events.js","kind":"import-statement","original":"./events"}],"format":"esm"},"app/javascript/turbo.js":{"bytes":1952,"imports":[{"path":"app/javascript/meta.js","kind":"import-statement","original":"./meta"},{"path":"app/javascript/state/index.js","kind":"import-statement","original":"./state"},{"path":"app/javascript/renderer.js","kind":"import-statement","original":"./renderer"},{"path":"app/javascript/events.js","kind":"import-statement","original":"./events"},{"path":"app/javascript/lifecycle.js","kind":"import-statement","original":"./lifecycle"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/schema.js":{"bytes":
|
1
|
+
{"inputs":{"app/javascript/meta.js":{"bytes":337,"imports":[],"format":"esm"},"app/javascript/events.js":{"bytes":783,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/state/observable.js":{"bytes":920,"imports":[{"path":"app/javascript/meta.js","kind":"import-statement","original":"../meta"},{"path":"app/javascript/events.js","kind":"import-statement","original":"../events"}],"format":"esm"},"app/javascript/state/index.js":{"bytes":1835,"imports":[{"path":"app/javascript/meta.js","kind":"import-statement","original":"../meta"},{"path":"app/javascript/state/observable.js","kind":"import-statement","original":"./observable"},{"path":"app/javascript/events.js","kind":"import-statement","original":"../events"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/renderer.js":{"bytes":475,"imports":[],"format":"esm"},"app/javascript/activity.js":{"bytes":279,"imports":[],"format":"esm"},"app/javascript/lifecycle.js":{"bytes":610,"imports":[{"path":"app/javascript/activity.js","kind":"import-statement","original":"./activity"},{"path":"app/javascript/events.js","kind":"import-statement","original":"./events"}],"format":"esm"},"app/javascript/turbo.js":{"bytes":1952,"imports":[{"path":"app/javascript/meta.js","kind":"import-statement","original":"./meta"},{"path":"app/javascript/state/index.js","kind":"import-statement","original":"./state"},{"path":"app/javascript/renderer.js","kind":"import-statement","original":"./renderer"},{"path":"app/javascript/events.js","kind":"import-statement","original":"./events"},{"path":"app/javascript/lifecycle.js","kind":"import-statement","original":"./lifecycle"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/schema.js":{"bytes":286,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/confirmation.js":{"bytes":947,"imports":[{"path":"app/javascript/events.js","kind":"import-statement","original":"./events"},{"path":"app/javascript/schema.js","kind":"import-statement","original":"./schema"}],"format":"esm"},"app/javascript/delegates.js":{"bytes":923,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/elements.js":{"bytes":1451,"imports":[{"path":"app/javascript/schema.js","kind":"import-statement","original":"./schema"},{"path":"app/javascript/lifecycle.js","kind":"import-statement","original":"./lifecycle"}],"format":"esm"},"app/javascript/drivers/form.js":{"bytes":980,"imports":[{"path":"app/javascript/meta.js","kind":"import-statement","original":"../meta"}],"format":"esm"},"app/javascript/urls.js":{"bytes":240,"imports":[],"format":"esm"},"app/javascript/drivers/frame.js":{"bytes":218,"imports":[{"path":"app/javascript/urls.js","kind":"import-statement","original":"../urls"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/drivers/method.js":{"bytes":265,"imports":[{"path":"app/javascript/urls.js","kind":"import-statement","original":"../urls"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/drivers/window.js":{"bytes":2074,"imports":[{"path":"app/javascript/meta.js","kind":"import-statement","original":"../meta"},{"path":"app/javascript/state/index.js","kind":"import-statement","original":"../state"},{"path":"app/javascript/events.js","kind":"import-statement","original":"../events"},{"path":"app/javascript/lifecycle.js","kind":"import-statement","original":"../lifecycle"},{"path":"app/javascript/urls.js","kind":"import-statement","original":"../urls"},{"path":"app/javascript/renderer.js","kind":"import-statement","original":"../renderer"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"app/javascript/drivers/index.js":{"bytes":2044,"imports":[{"path":"app/javascript/elements.js","kind":"import-statement","original":"../elements"},{"path":"app/javascript/drivers/form.js","kind":"import-statement","original":"./form"},{"path":"app/javascript/drivers/frame.js","kind":"import-statement","original":"./frame"},{"path":"app/javascript/drivers/method.js","kind":"import-statement","original":"./method"},{"path":"app/javascript/drivers/window.js","kind":"import-statement","original":"./window"}],"format":"esm"},"app/javascript/logger.js":{"bytes":729,"imports":[{"path":"app/javascript/events.js","kind":"import-statement","original":"./events"}],"format":"esm"},"app/javascript/uuids.js":{"bytes":202,"imports":[],"format":"esm"},"app/javascript/index.js":{"bytes":3647,"imports":[{"path":"app/javascript/turbo.js","kind":"import-statement","original":"./turbo"},{"path":"app/javascript/schema.js","kind":"import-statement","original":"./schema"},{"path":"app/javascript/events.js","kind":"import-statement","original":"./events"},{"path":"app/javascript/activity.js","kind":"import-statement","original":"./activity"},{"path":"app/javascript/confirmation.js","kind":"import-statement","original":"./confirmation"},{"path":"app/javascript/delegates.js","kind":"import-statement","original":"./delegates"},{"path":"app/javascript/drivers/index.js","kind":"import-statement","original":"./drivers"},{"path":"app/javascript/meta.js","kind":"import-statement","original":"./meta"},{"path":"app/javascript/elements.js","kind":"import-statement","original":"./elements"},{"path":"app/javascript/lifecycle.js","kind":"import-statement","original":"./lifecycle"},{"path":"app/javascript/logger.js","kind":"import-statement","original":"./logger"},{"path":"app/javascript/state/index.js","kind":"import-statement","original":"./state"},{"path":"app/javascript/urls.js","kind":"import-statement","original":"./urls"},{"path":"app/javascript/uuids.js","kind":"import-statement","original":"./uuids"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"app/assets/builds/@turbo-boost/commands.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":38891},"app/assets/builds/@turbo-boost/commands.js":{"imports":[],"exports":["default"],"entryPoint":"app/javascript/index.js","inputs":{"app/javascript/meta.js":{"bytesInOutput":252},"app/javascript/events.js":{"bytesInOutput":500},"app/javascript/state/observable.js":{"bytesInOutput":405},"app/javascript/state/index.js":{"bytesInOutput":762},"app/javascript/renderer.js":{"bytesInOutput":263},"app/javascript/activity.js":{"bytesInOutput":173},"app/javascript/lifecycle.js":{"bytesInOutput":294},"app/javascript/turbo.js":{"bytesInOutput":1024},"app/javascript/schema.js":{"bytesInOutput":209},"app/javascript/confirmation.js":{"bytesInOutput":424},"app/javascript/delegates.js":{"bytesInOutput":473},"app/javascript/elements.js":{"bytesInOutput":782},"app/javascript/drivers/form.js":{"bytesInOutput":620},"app/javascript/urls.js":{"bytesInOutput":166},"app/javascript/drivers/frame.js":{"bytesInOutput":96},"app/javascript/drivers/method.js":{"bytesInOutput":130},"app/javascript/drivers/window.js":{"bytesInOutput":1329},"app/javascript/drivers/index.js":{"bytesInOutput":991},"app/javascript/logger.js":{"bytesInOutput":399},"app/javascript/uuids.js":{"bytesInOutput":159},"app/javascript/index.js":{"bytesInOutput":1754}},"bytes":11702}}}
|
@@ -1,12 +1,30 @@
|
|
1
1
|
import meta from '../meta'
|
2
2
|
|
3
|
-
function
|
3
|
+
function updateFormSubmission(formSubmission) {
|
4
|
+
const shouldUpdate =
|
5
|
+
formSubmission?.formElement instanceof HTMLFormElement &&
|
6
|
+
formSubmission?.body instanceof URLSearchParams &&
|
7
|
+
formSubmission?.fetchRequest?.body instanceof URLSearchParams
|
8
|
+
|
9
|
+
if (!shouldUpdate) return
|
10
|
+
|
11
|
+
formSubmission.formData = new FormData(formSubmission.formElement)
|
12
|
+
for (const [key, value] of formSubmission.formData.entries()) {
|
13
|
+
formSubmission.fetchRequest.body.set(key, value)
|
14
|
+
formSubmission.body.set(key, value)
|
15
|
+
}
|
16
|
+
|
17
|
+
return formSubmission
|
18
|
+
}
|
19
|
+
|
20
|
+
function invokeCommand(form, payload = {}, event = {}) {
|
4
21
|
payload.token = meta.token
|
5
|
-
const input = document.createElement('input')
|
22
|
+
const input = form.querySelector('input[name="turbo_boost_command"]') || document.createElement('input')
|
6
23
|
input.type = 'hidden'
|
7
24
|
input.name = 'turbo_boost_command'
|
8
25
|
input.value = JSON.stringify(payload)
|
9
26
|
form.appendChild(input)
|
27
|
+
updateFormSubmission(event.detail.formSubmission)
|
10
28
|
}
|
11
29
|
|
12
30
|
export default { invokeCommand }
|
data/app/javascript/index.js
CHANGED
@@ -74,7 +74,7 @@ async function invokeCommand(event) {
|
|
74
74
|
case 'method':
|
75
75
|
return driver.invokeCommand(element, payload)
|
76
76
|
case 'form':
|
77
|
-
return driver.invokeCommand(element, payload)
|
77
|
+
return driver.invokeCommand(element, payload, event)
|
78
78
|
case 'frame':
|
79
79
|
return driver.invokeCommand(driver.frame, payload)
|
80
80
|
case 'window':
|
@@ -108,6 +108,7 @@ if (!self.TurboBoost.Commands) {
|
|
108
108
|
delegates.handler = invokeCommand
|
109
109
|
delegates.register('click', [`[${schema.commandAttribute}]`])
|
110
110
|
delegates.register('submit', [`form[${schema.commandAttribute}]`])
|
111
|
+
delegates.register(schema.turboSubmitStartEvent, [`form[${schema.commandAttribute}]`])
|
111
112
|
delegates.register('change', [
|
112
113
|
`input[${schema.commandAttribute}]`,
|
113
114
|
`select[${schema.commandAttribute}]`,
|
data/app/javascript/schema.js
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
const schema = {
|
2
|
+
// attributes
|
2
3
|
frameAttribute: 'data-turbo-frame',
|
3
4
|
methodAttribute: 'data-turbo-method',
|
4
5
|
commandAttribute: 'data-turbo-command',
|
5
|
-
confirmAttribute: 'data-turbo-confirm'
|
6
|
+
confirmAttribute: 'data-turbo-confirm',
|
7
|
+
|
8
|
+
// events
|
9
|
+
turboSubmitStartEvent: 'turbo:submit-start'
|
6
10
|
}
|
7
11
|
|
8
12
|
export default { ...schema }
|
@@ -24,12 +24,12 @@ class TurboBoost::Commands::AttributeSet
|
|
24
24
|
value = value.to_i if value.is_a?(String) && value.match?(/\A-?\d+\z/)
|
25
25
|
value = value == "true" if value.is_a?(String) && value.match?(/\A(true|false)\z/i)
|
26
26
|
|
27
|
-
instance_variable_set "@#{name}", value
|
27
|
+
instance_variable_set :"@#{name}", value
|
28
28
|
|
29
29
|
next if orig_respond_to_missing?(name, false)
|
30
30
|
|
31
31
|
self.class.define_method(name) { instance_variable_get :"@#{name}" }
|
32
|
-
self.class.define_method("#{name}?") { public_send(name).present? }
|
32
|
+
self.class.define_method(:"#{name}?") { public_send(name).present? }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -121,13 +121,13 @@ class TurboBoost::Commands::Command
|
|
121
121
|
options = options.symbolize_keys
|
122
122
|
|
123
123
|
ivars = options[:assigns]&.each_with_object({}) do |(key, value), memo|
|
124
|
-
memo[key] = controller.instance_variable_get("@#{key}")
|
125
|
-
controller.instance_variable_set "@#{key}", value
|
124
|
+
memo[key] = controller.instance_variable_get(:"@#{key}")
|
125
|
+
controller.instance_variable_set :"@#{key}", value
|
126
126
|
end
|
127
127
|
|
128
128
|
controller.view_context.render(options.except(:assigns), locals, &block)
|
129
129
|
ensure
|
130
|
-
ivars&.each { |key, value| controller.instance_variable_set "@#{key}", value }
|
130
|
+
ivars&.each { |key, value| controller.instance_variable_set :"@#{key}", value }
|
131
131
|
end
|
132
132
|
|
133
133
|
def turbo_stream
|
@@ -7,12 +7,13 @@ module TurboBoost::Commands::CommandCallbacks
|
|
7
7
|
|
8
8
|
include Observable
|
9
9
|
include ActiveSupport::Callbacks
|
10
|
+
include ActiveSupport::Rescuable
|
10
11
|
|
11
12
|
NAME = :perform_command
|
12
13
|
|
13
14
|
module ClassMethods
|
14
15
|
[:before, :after, :around].each do |type|
|
15
|
-
define_method "#{type}_command" do |*method_names, &
|
16
|
+
define_method :"#{type}_command" do |*method_names, &block|
|
16
17
|
options = callback_options(method_names.extract_options!)
|
17
18
|
|
18
19
|
# convert only to if
|
@@ -26,10 +27,11 @@ module TurboBoost::Commands::CommandCallbacks
|
|
26
27
|
end
|
27
28
|
|
28
29
|
options = options.slice(:if, :unless, :prepend).select { |_, val| val.present? }
|
29
|
-
|
30
|
+
set_callback(NAME, type, options, &block)
|
31
|
+
method_names.each { |method_name| set_callback(NAME, type, method_name, options, &block) }
|
30
32
|
end
|
31
33
|
|
32
|
-
define_method "skip_#{type}_command" do |*method_names, &
|
34
|
+
define_method :"skip_#{type}_command" do |*method_names, &block|
|
33
35
|
options = callback_options(method_names.extract_options!)
|
34
36
|
|
35
37
|
# convert only to if
|
@@ -43,7 +45,7 @@ module TurboBoost::Commands::CommandCallbacks
|
|
43
45
|
end
|
44
46
|
|
45
47
|
options = options.slice(:if, :unless, :prepend).select { |_, val| val.present? }
|
46
|
-
method_names.each { |method_name| skip_callback
|
48
|
+
method_names.each { |method_name| skip_callback(NAME, type, method_name, options, &block) }
|
47
49
|
end
|
48
50
|
|
49
51
|
private
|
@@ -61,15 +63,26 @@ module TurboBoost::Commands::CommandCallbacks
|
|
61
63
|
included do
|
62
64
|
define_callbacks NAME,
|
63
65
|
skip_after_callbacks_if_terminated: true,
|
64
|
-
terminator: ->(command, callback)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
terminator: ->(command, callback) do
|
67
|
+
halt = true # STOP the callback chain (pessimistic)
|
68
|
+
|
69
|
+
begin
|
70
|
+
catch :abort do
|
71
|
+
callback.call # execution halts here if the callback invokes `throw :abort`
|
72
|
+
halt = false # CONTINUE the callback chain
|
73
|
+
end
|
74
|
+
|
75
|
+
if halt # callback chain halted, meaning `throw` was invoked in a callback
|
76
|
+
command.send :aborted!, TurboBoost::Commands::AbortError.new(command: command)
|
77
|
+
end
|
78
|
+
rescue UncaughtThrowError => error
|
79
|
+
# `throw` was invoked without :abort
|
80
|
+
message = "Please use `throw :abort` to abort a command."
|
81
|
+
command.send :aborted!, TurboBoost::Commands::AbortError.new(message, command: command, cause: error)
|
82
|
+
end
|
83
|
+
|
84
|
+
halt
|
85
|
+
end
|
73
86
|
end
|
74
87
|
|
75
88
|
def perform_with_callbacks(method_name)
|
@@ -79,7 +92,7 @@ module TurboBoost::Commands::CommandCallbacks
|
|
79
92
|
performed!
|
80
93
|
end
|
81
94
|
rescue => error
|
82
|
-
errored! error
|
95
|
+
errored! TurboBoost::Commands::PerformError.new(command: self, cause: error)
|
83
96
|
ensure
|
84
97
|
@performing_method_name = nil
|
85
98
|
end
|
@@ -104,19 +117,33 @@ module TurboBoost::Commands::CommandCallbacks
|
|
104
117
|
performed? && !aborted? && !errored?
|
105
118
|
end
|
106
119
|
|
120
|
+
def abort_handler(error = nil)
|
121
|
+
# noop, override in subclasses via `on_abort`
|
122
|
+
end
|
123
|
+
|
124
|
+
def error_handler(error)
|
125
|
+
# noop, override in subclasses via `on_error`
|
126
|
+
end
|
127
|
+
|
107
128
|
private
|
108
129
|
|
109
130
|
def aborted!(error)
|
110
|
-
|
131
|
+
return if aborted? || errored? || performed?
|
132
|
+
changed @aborted = @performed = true
|
133
|
+
rescue_with_handler error
|
111
134
|
notify_observers :aborted, error: error
|
112
135
|
end
|
113
136
|
|
114
137
|
def errored!(error)
|
115
|
-
|
138
|
+
return if aborted? || errored? || performed?
|
139
|
+
changed @errored = @performed = true
|
140
|
+
error_handler error
|
141
|
+
rescue_with_handler error
|
116
142
|
notify_observers :errored, error: error
|
117
143
|
end
|
118
144
|
|
119
145
|
def performed!
|
146
|
+
return if performed?
|
120
147
|
changed @performed = true
|
121
148
|
notify_observers :performed
|
122
149
|
end
|
@@ -1,12 +1,44 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module TurboBoost::Commands
|
4
|
-
class InvalidClassError < StandardError
|
4
|
+
class InvalidClassError < StandardError; end
|
5
|
+
|
6
|
+
class InvalidMethodError < StandardError; end
|
7
|
+
|
8
|
+
class InvalidElementError < StandardError; end
|
9
|
+
|
10
|
+
class CommandError < StandardError
|
11
|
+
def initialize(*messages, command:, http_status:, cause: nil)
|
12
|
+
@cause = cause
|
13
|
+
@command = command
|
14
|
+
@http_status_code = TurboBoost::Commands.http_status_code(http_status)
|
15
|
+
|
16
|
+
messages.prepend "HTTP #{http_status_code} #{TurboBoost::Commands::HTTP_STATUS_CODES[http_status_code]}"
|
17
|
+
messages << cause.message if cause
|
18
|
+
messages << location
|
19
|
+
|
20
|
+
super(messages.uniq.select(&:present?).join("; "))
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :cause, :command, :http_status_code
|
24
|
+
|
25
|
+
def location
|
26
|
+
line = (cause&.backtrace || []).first.to_s
|
27
|
+
line.[](/[^\/]+\.rb:\d+/i)
|
28
|
+
end
|
5
29
|
end
|
6
30
|
|
7
|
-
class
|
31
|
+
class AbortError < CommandError
|
32
|
+
def initialize(*messages, **kwargs)
|
33
|
+
messages.prepend "TurboBoost Command intentionally aborted via `throw` in a `[before,after,around]_command` lifecycle callback!"
|
34
|
+
super(messages, http_status: :abort_turbo_boost_command, **kwargs)
|
35
|
+
end
|
8
36
|
end
|
9
37
|
|
10
|
-
class
|
38
|
+
class PerformError < CommandError
|
39
|
+
def initialize(*messages, **kwargs)
|
40
|
+
messages.prepend "Unexpected error encountered while performing a TurboBoost Command!"
|
41
|
+
super(messages, http_status: :internal_server_error, **kwargs)
|
42
|
+
end
|
11
43
|
end
|
12
44
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TurboBoost::Commands
|
4
|
+
HTTP_ABORT_STATUS_CODE = 285 # I-285 is the most congested highway in the US (traffic jams → halt/abort)
|
5
|
+
|
6
|
+
HTTP_STATUS_CODES = Rack::Utils::HTTP_STATUS_CODES.merge(
|
7
|
+
HTTP_ABORT_STATUS_CODE => "Abort TurboBoost Command"
|
8
|
+
).freeze
|
9
|
+
|
10
|
+
def self.http_status_code(value)
|
11
|
+
return value.to_i unless value.is_a?(String) || value.is_a?(Symbol)
|
12
|
+
return value.to_i if value.match?(/\A\d+\z/)
|
13
|
+
|
14
|
+
case value.to_sym
|
15
|
+
when :abort_turbo_boost_command then HTTP_ABORT_STATUS_CODE
|
16
|
+
else Rack::Utils::SYMBOL_TO_STATUS_CODE[value.to_sym]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -127,20 +127,25 @@ class TurboBoost::Commands::Runner
|
|
127
127
|
return if command_performing?
|
128
128
|
return if command_performed?
|
129
129
|
command_instance.perform_with_callbacks command_method_name
|
130
|
-
rescue => error
|
131
|
-
prevent_controller_action error: error
|
132
130
|
end
|
133
131
|
|
134
132
|
def prevent_controller_action(error: nil)
|
135
133
|
return if controller_action_prevented?
|
136
134
|
@controller_action_prevented = true
|
137
135
|
|
138
|
-
|
139
|
-
|
136
|
+
case error
|
137
|
+
when nil
|
138
|
+
render_response status: response_status
|
139
|
+
append_success_to_response
|
140
|
+
when TurboBoost::Commands::AbortError
|
141
|
+
render_response status: error.http_status_code, headers: {"TurboBoost-Command-Status": error.message}
|
142
|
+
append_streams_to_response_body
|
143
|
+
when TurboBoost::Commands::PerformError
|
144
|
+
render_response status: error.http_status_code, headers: {"TurboBoost-Command-Status": error.message}
|
140
145
|
append_error_to_response error
|
141
146
|
else
|
142
|
-
render_response
|
143
|
-
|
147
|
+
render_response status: :internal_server_error, headers: {"TurboBoost-Command-Status": error.message}
|
148
|
+
append_error_to_response error
|
144
149
|
end
|
145
150
|
|
146
151
|
append_meta_tag_to_response_body # called before `write_cookie` so all state is emitted to the DOM
|
@@ -148,10 +153,12 @@ class TurboBoost::Commands::Runner
|
|
148
153
|
end
|
149
154
|
|
150
155
|
def update_response
|
151
|
-
return if controller_action_prevented?
|
152
156
|
return if @update_response_performed
|
153
157
|
@update_response_performed = true
|
154
158
|
|
159
|
+
return if controller_action_prevented?
|
160
|
+
|
161
|
+
append_to_response_headers
|
155
162
|
append_meta_tag_to_response_body # called before `write_cookie` so all state is emitted to the DOM
|
156
163
|
state_manager.write_cookie # truncates state to stay within cookie size limits (4k)
|
157
164
|
append_success_to_response if command_succeeded?
|
@@ -159,9 +166,9 @@ class TurboBoost::Commands::Runner
|
|
159
166
|
Rails.logger.error "TurboBoost::Commands::Runner failed to update the response! #{error.message}"
|
160
167
|
end
|
161
168
|
|
162
|
-
def render_response(html: "", status: nil, headers: {
|
163
|
-
headers.each { |key, value| controller.response.set_header key.to_s, value.to_s }
|
169
|
+
def render_response(html: "", status: nil, headers: {})
|
164
170
|
controller.render html: html, layout: false, status: status || response_status
|
171
|
+
append_to_response_headers headers.merge(TurboBoost: :Append)
|
165
172
|
end
|
166
173
|
|
167
174
|
def turbo_stream
|
@@ -181,10 +188,7 @@ class TurboBoost::Commands::Runner
|
|
181
188
|
event = args.shift
|
182
189
|
options = args.extract_options!
|
183
190
|
case event
|
184
|
-
when :aborted
|
185
|
-
prevent_controller_action error: error
|
186
|
-
append_streams_to_response_body
|
187
|
-
when :errored then prevent_controller_action(**options)
|
191
|
+
when :aborted, :errored then prevent_controller_action error: options[:error]
|
188
192
|
when :performed then prevent_controller_action if should_prevent_controller_action?
|
189
193
|
end
|
190
194
|
end
|
@@ -243,10 +247,9 @@ class TurboBoost::Commands::Runner
|
|
243
247
|
end
|
244
248
|
|
245
249
|
def append_error_to_response(error)
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
append_error_alert_to_response_body message
|
250
|
+
Rails.logger.error error.message
|
251
|
+
append_error_event_to_response_body error.message
|
252
|
+
append_error_alert_to_response_body error.message
|
250
253
|
end
|
251
254
|
|
252
255
|
def append_streams_to_response_body
|
@@ -272,14 +275,14 @@ class TurboBoost::Commands::Runner
|
|
272
275
|
|
273
276
|
def append_error_alert_to_response_body(message)
|
274
277
|
return unless Rails.env.development?
|
275
|
-
message
|
276
|
-
#{message
|
278
|
+
message = <<~MSG
|
279
|
+
#{message}
|
277
280
|
|
278
|
-
|
281
|
+
See the HTTP header: `TurboBoost-Command-Status`
|
279
282
|
|
280
|
-
|
283
|
+
Also check the JavaScript console if `TurboBoost.Commands.logger.level` has been set.
|
281
284
|
|
282
|
-
|
285
|
+
Finally, check server logs for additional info.
|
283
286
|
MSG
|
284
287
|
append_to_response_body turbo_stream.invoke(:alert, args: [message])
|
285
288
|
end
|
@@ -321,4 +324,17 @@ class TurboBoost::Commands::Runner
|
|
321
324
|
rescue => error
|
322
325
|
Rails.logger.error "TurboBoost::Commands::Runner failed to append to the response! #{error.message}"
|
323
326
|
end
|
327
|
+
|
328
|
+
# Writes new header... will not overwrite existing header
|
329
|
+
def append_response_header(key, value)
|
330
|
+
return if controller.response.get_header key.to_s
|
331
|
+
controller.response.set_header key.to_s, value.to_s
|
332
|
+
end
|
333
|
+
|
334
|
+
def append_to_response_headers(headers = {})
|
335
|
+
return unless command_performed?
|
336
|
+
headers.each { |key, val| append_response_header key, val }
|
337
|
+
append_response_header "TurboBoost-Command", command_name
|
338
|
+
append_response_header "TurboBoost-Command-Status", "HTTP #{controller.response.status} #{TurboBoost::Commands::HTTP_STATUS_CODES[controller.response.status]}"
|
339
|
+
end
|
324
340
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo_boost-commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Hopkins (hopsoft)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -385,6 +385,7 @@ files:
|
|
385
385
|
- lib/turbo_boost/commands/controller_pack.rb
|
386
386
|
- lib/turbo_boost/commands/engine.rb
|
387
387
|
- lib/turbo_boost/commands/errors.rb
|
388
|
+
- lib/turbo_boost/commands/http_status_codes.rb
|
388
389
|
- lib/turbo_boost/commands/patches.rb
|
389
390
|
- lib/turbo_boost/commands/patches/action_view_helpers_tag_helper_tag_builder_patch.rb
|
390
391
|
- lib/turbo_boost/commands/runner.rb
|
@@ -410,14 +411,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
410
411
|
requirements:
|
411
412
|
- - ">="
|
412
413
|
- !ruby/object:Gem::Version
|
413
|
-
version:
|
414
|
+
version: 2.7.5
|
414
415
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
415
416
|
requirements:
|
416
417
|
- - ">="
|
417
418
|
- !ruby/object:Gem::Version
|
418
419
|
version: '0'
|
419
420
|
requirements: []
|
420
|
-
rubygems_version: 3.
|
421
|
+
rubygems_version: 3.5.3
|
421
422
|
signing_key:
|
422
423
|
specification_version: 4
|
423
424
|
summary: Commands to help you build robust reactive applications with Rails & Hotwire.
|