From 5d9d683f570ef705ea062d7184c33c358a25248a Mon Sep 17 00:00:00 2001 From: "Nate Hopkins (hopsoft)" Date: Mon, 4 Mar 2024 00:12:51 -0700 Subject: [PATCH] Tweak log colors --- app/assets/builds/@turbo-boost/commands.js | 2 +- .../builds/@turbo-boost/commands.js.map | 4 ++-- app/javascript/index.js | 20 +++++++++---------- app/javascript/logger.js | 4 ++-- lib/turbo_boost/commands/runner.rb | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/assets/builds/@turbo-boost/commands.js b/app/assets/builds/@turbo-boost/commands.js index 2fca4a92..2d0579c9 100644 --- a/app/assets/builds/@turbo-boost/commands.js +++ b/app/assets/builds/@turbo-boost/commands.js @@ -1,2 +1,2 @@ -var it=Object.defineProperty,ct=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable;var F=(t,e,r)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,s=(t,e)=>{for(var r in e||(e={}))dt.call(e,r)&&F(t,r,e[r]);if(B)for(var r of B(e))ut.call(e,r)&&F(t,r,e[r]);return t},v=(t,e)=>ct(t,mt(e));var lt="TurboBoost-Command",h={boost:"text/vnd.turbo-boost.html",stream:"text/vnd.turbo-stream.html",html:"text/html",xhtml:"application/xhtml+xml",json:"application/json"},ft=(t={})=>{t=s({},t);let e=(t.Accept||"").split(",").map(r=>r.trim()).filter(r=>r.length);return e.unshift(h.boost,h.stream,h.html,h.xhtml),t.Accept=[...new Set(e)].join(", "),t["Content-Type"]=h.json,t["X-Requested-With"]="XMLHttpRequest",t},pt=t=>{if(t){let[e,r,o]=t.split(", ");return{name:e,status:r,strategy:o}}return{}},b={prepare:ft,tokenize:pt,RESPONSE_HEADER:lt};var A={};function bt(t){A[t.id]=t}function vt(t){delete A[t]}var x={add:bt,remove:vt,get commands(){return[...Object.values(A)]},get length(){return Object.keys(A).length}};var c={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"},u={stateLoad:"turbo-boost:state:load",stateChange:"turbo-boost:state:change"},d=s(s({},c),u);function m(t,e,r={}){return new Promise(o=>{r=r||{},r.detail=r.detail||{},e=e||document;let n=new CustomEvent(t,v(s({},r),{bubbles:!0}));e.dispatchEvent(n),o(n)})}function J(t){setTimeout(()=>m(c.finish,t.target,{detail:t.detail}))}addEventListener(c.serverError,J);addEventListener(c.success,J);addEventListener(c.finish,t=>x.remove(t.detail.id),!0);var z={events:c};function ht(){return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}var M={v4:ht};var gt=t=>{document.body.insertAdjacentHTML("beforeend",t)},Et=t=>{let r=new DOMParser().parseFromString(t,"text/html");TurboBoost.Streams.morph.method(document.documentElement,r.documentElement)},C=(t,e)=>{if(t&&e){if(t.match(/^Append$/i))return gt(e);if(t.match(/^Replace$/i))return Et(e)}};var R={};addEventListener("turbo:before-fetch-response",t=>{let e=t.target.closest("turbo-frame");e!=null&&e.id&&(e!=null&&e.src)&&(R[e.id]=e.src);let{fetchResponse:r}=t.detail,o=r.header(b.RESPONSE_HEADER);if(!o)return;t.preventDefault();let{strategy:n}=b.tokenize(o);r.responseHTML.then(i=>C(n,i))});addEventListener("turbo:frame-load",t=>{let e=t.target.closest("turbo-frame");e.dataset.src=R[e.id]||e.src||e.dataset.src,delete R[e.id]});var yt={frameAttribute:"data-turbo-frame",methodAttribute:"data-turbo-method",commandAttribute:"data-turbo-command",confirmAttribute:"data-turbo-confirm"},a=s({},yt);var H={method:t=>Promise.resolve(confirm(t))},At=t=>t.detail.driver==="method",xt=t=>{if(t.detail.driver!=="form")return!1;let e=t.target,r=e.closest("turbo-frame"),o=e.closest(`[${a.frameAttribute}]`);return!!(r||o)},Ct=t=>At(t)||xt(t);document.addEventListener(c.start,async t=>{let e=t.target.getAttribute(a.confirmAttribute);if(!e||(t.detail.confirmation=!0,Ct(t)))return;await H.method(e)||t.preventDefault()});var U=H;var l=[],T;function kt(t,e){let r=l.find(o=>o.name===t);return r&&l.splice(l.indexOf(r),1),l=[{name:t,selectors:e},...l],document.removeEventListener(t,T,!0),document.addEventListener(t,T,!0),s({},l.find(o=>o.name===t))}function St(t){return l.find(e=>e.selectors.find(r=>Array.from(document.querySelectorAll(r)).find(o=>o===t)))}function wt(t,e){let r=St(e);return r&&r.name===t}var f={register:kt,isRegisteredForElement:wt,get events(){return[...l]},set handler(t){T=t}};function Lt(t){return t.closest(`[${a.commandAttribute}]`)}function Ot(t){return t.closest("turbo-frame[src]")||t.closest("turbo-frame[data-turbo-frame-src]")||t.closest("turbo-frame")}function Rt(t,e={}){if(t.tagName.toLowerCase()!=="select")return e.value=t.value||null;if(!t.multiple)return e.value=t.options[t.selectedIndex].value;e.values=Array.from(t.options).reduce((r,o)=>(o.selected&&r.push(o.value),r),[])}function Tt(t){let e=Array.from(t.attributes).reduce((r,o)=>{let n=o.value;return r[o.name]=n,r},{});return e.tag=t.tagName,e.checked=!!t.checked,e.disabled=!!t.disabled,Rt(t,e),delete e.class,delete e.action,delete e.href,delete e[a.commandAttribute],delete e[a.frameAttribute],e}var g={buildAttributePayload:Tt,findClosestCommand:Lt,findClosestFrameWithSource:Ot};var $t=(t,e={})=>{let r=t.querySelector('input[name="turbo_boost_command"]')||document.createElement("input");r.type="hidden",r.name="turbo_boost_command",r.value=JSON.stringify(e),t.contains(r)||t.appendChild(r)},q={invokeCommand:$t};var Pt=t=>{let e=document.createElement("a");return e.href=t,new URL(e)},V={get commandInvocationURL(){return Pt("/turbo-boost-command-invocation")}};var W=t=>{let e=`Unexpected error performing a TurboBoost Command! ${t.message}`;m(z.events.clientError,document,{detail:{message:e,error:t}},!0)},_t=t=>{let{strategy:e}=b.tokenize(t.headers.get(b.RESPONSE_HEADER));t.text().then(r=>C(e,r))},k=(t={})=>{try{fetch(V.commandInvocationURL.href,{method:"POST",headers:b.prepare({}),body:JSON.stringify(t)}).then(_t).catch(W)}catch(e){W(e)}};var Nt=(t,e)=>k(e),$={invokeCommand:Nt};var E,P,Dt=()=>{E=null,P=null},It=(t,e={})=>{E=t,P=e},jt=t=>{try{if(!E||t.getAttribute("method")!==E.dataset.turboMethod||t.getAttribute("action")!==E.href)return;let e=t.querySelector('input[name="turbo_boost_command"]')||document.createElement("input");e.type="hidden",e.name="turbo_boost_command",e.value=JSON.stringify(P),t.contains(e)||t.appendChild(e)}finally{Dt()}};document.addEventListener("submit",t=>jt(t.target),!0);var X={invokeCommand:It};var Bt=(t,e={})=>k(e),G={invokeCommand:Bt};function _(t,e){return e=e||{dataset:{}},t.href||e.src||e.dataset.src||location.href}function Ft(t){let e=g.findClosestFrameWithSource(t),{turboFrame:r,turboMethod:o}=t.dataset;return t.tagName.toLowerCase()==="form"?{name:"form",reason:"Element is a form.",frame:e,src:t.action,invokeCommand:q.invokeCommand}:o&&o.length>0?{name:"method",reason:"Element defines data-turbo-method.",frame:e,src:t.href,invokeCommand:X.invokeCommand}:r&&r!=="_self"?(e=document.getElementById(r),{name:"frame",reason:"element targets a frame that is not _self",frame:e,src:_(t,e),invokeCommand:$.invokeCommand}):(!r||r==="_self")&&e?{name:"frame",reason:"element does NOT target a frame or targets _self and is contained by a frame",frame:e,src:_(t,e),invokeCommand:$.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:_(t),invokeCommand:G.invokeCommand}}var N={find:Ft};var w="unknown",K=!1,S=[],Q={debug:Object.values(d),info:Object.values(d),warn:[d.abort,d.clientError,d.serverError],error:[d.clientError,d.serverError],unknown:[]},Jt=t=>{if(!Q[w].includes(t.type)||typeof console[w]!="function")return!1;let{detail:e}=t;if(!e.id)return!0;let r=`${t.type}-${e.id}`;return S.includes(r)?!1:(S.length>16&&S.shift(),S.push(r),!0)},zt=t=>{if(Jt(t)){let{target:e,type:r,detail:o}=t,n=o.id||"",i=o.name||"",p="";o.startedAt&&(p=`${Date.now()-o.startedAt}ms `);let I=r.split(":"),st=I.pop(),j=`%c${I.join(":")}:%c${st}`,at=[`%c${i}`,`%c${p}`,j,`%c${n}`];console.log(at.join(" ").replace(/\s{2,}/g," "),"color:deepskyblue","color:lime","color:darkkhaki",j.match(/error/i)?"color:red":"color:gold","color:silver",{detail:o,target:e})}};K||(K=!0,Object.values(d).forEach(t=>addEventListener(t,e=>zt(e))));var Y={get level(){return w},set level(t){return Object.keys(Q).includes(t)||(t="unknown"),w=t}};var D;function L(t,e=null){if(!t||typeof t!="object")return t;let r=new Proxy(t,{deleteProperty(o,n){return delete o[n],m(u.stateChange,document,{detail:{state:D}}),!0},set(o,n,i,p){return o[n]=L(i,this),m(u.stateChange,document,{detail:{state:D}}),!0}});if(Array.isArray(t))t.forEach((o,n)=>t[n]=L(o,r));else if(typeof t=="object")for(let[o,n]of Object.entries(t))t[o]=L(n,r);return e||(D=r),r}var Z=L;function Mt(t,e){return typeof e!="object"&&(e={}),sessionStorage.setItem(String(t),JSON.stringify(e))}function Ht(t){let e=sessionStorage.getItem(String(t));return e?JSON.parse(e):{}}var O={save:Mt,find:Ht};var et={},tt={};function Ut(t,e){removeEventListener(u.stateChange,tt[t]),tt[t]=addEventListener(u.stateChange,r=>{for(let[o,n]of Object.entries(e.current))e.initial[o]!==n&&(e.changed[o]=n);O.save(t,JSON.stringify(e))})}function qt(t,e,r){let o=JSON.parse(e),n={name:t,signed:r,initial:s({},o),current:Z(s({},o)),changed:{}};et[t]=n,O.save(t,n),Ut(t,n),setTimeout(()=>m(u.stateLoad,document,{detail:n}))}function Vt(t){let e={name:t,initial:{},current:{},changed:{}},r=O.find(t);return s(s({},e),r)}function Wt(t){let e=`[${a.commandAttribute}]`,r=[],o=t.closest(e);for(;o;)r.push(Vt(o.getAttribute(a.commandAttribute))),o=o.parentElement.closest(e);return r}var y={initialize:qt,collect:Wt,entries:et};var rt="0.2.1";var Xt=self.TurboBoost||{},nt={VERSION:rt,active:!1,confirmation:U,logger:Y,schema:a,events:c,registerEventDelegate:f.register,get eventDelegates(){return f.events}};function ot(t,e){let r=y.collect(e).map(({name:o,signed:n,changed:i})=>({name:o,signed:n,changed:i}));return{id:t,name:e.getAttribute(a.commandAttribute),elementId:e.id.length>0?e.id:null,elementAttributes:g.buildAttributePayload(e),startedAt:Date.now(),stateCollection:r}}async function Gt(t){let e,r={};try{if(e=g.findClosestCommand(t.target),!e||!f.isRegisteredForElement(t.type,e))return;let o=M.v4(),n=N.find(e),i=v(s({},ot(o,e)),{driver:n.name,frameId:n.frame?n.frame.id:null,src:n.src}),p=await m(c.start,e,{cancelable:!0,detail:i});if(p.defaultPrevented||p.detail.confirmation&&t.defaultPrevented)return m(c.abort,e,{detail:{message:`An event handler for '${c.start}' prevented default behavior and blocked command invocation!`,source:p}});switch(n=N.find(e),i=v(s({},ot(o,e)),{driver:n.name,frameId:n.frame?n.frame.id:null,src:n.src}),x.add(i),["frame","window"].includes(n.name)&&t.preventDefault(),n.name){case"method":return n.invokeCommand(e,i);case"form":return n.invokeCommand(e,i,t);case"frame":return n.invokeCommand(n.frame,i);case"window":return n.invokeCommand(self,i)}}catch(o){m(c.clientError,e,{detail:v(s({},r),{error:o})})}}self.TurboBoost=s({},Xt);self.TurboBoost.Commands||(f.handler=Gt,f.register("click",[`[${a.commandAttribute}]`]),f.register("submit",[`form[${a.commandAttribute}]`]),f.register("change",[`input[${a.commandAttribute}]`,`select[${a.commandAttribute}]`,`textarea[${a.commandAttribute}]`]),self.TurboBoost.Commands=nt,self.TurboBoost.State={initialize:y.initialize,collect:y.collect,get entries(){return JSON.parse(JSON.stringify(y.entries))}});var gr=nt;export{gr as default}; +var it=Object.defineProperty,ct=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable;var F=(t,e,r)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,s=(t,e)=>{for(var r in e||(e={}))dt.call(e,r)&&F(t,r,e[r]);if(B)for(var r of B(e))ut.call(e,r)&&F(t,r,e[r]);return t},v=(t,e)=>ct(t,mt(e));var lt="TurboBoost-Command",h={boost:"text/vnd.turbo-boost.html",stream:"text/vnd.turbo-stream.html",html:"text/html",xhtml:"application/xhtml+xml",json:"application/json"},ft=(t={})=>{t=s({},t);let e=(t.Accept||"").split(",").map(r=>r.trim()).filter(r=>r.length);return e.unshift(h.boost,h.stream,h.html,h.xhtml),t.Accept=[...new Set(e)].join(", "),t["Content-Type"]=h.json,t["X-Requested-With"]="XMLHttpRequest",t},pt=t=>{if(t){let[e,r,o]=t.split(", ");return{name:e,status:r,strategy:o}}return{}},b={prepare:ft,tokenize:pt,RESPONSE_HEADER:lt};var A={};function bt(t){A[t.id]=t}function vt(t){delete A[t]}var x={add:bt,remove:vt,get commands(){return[...Object.values(A)]},get length(){return Object.keys(A).length}};var c={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"},u={stateLoad:"turbo-boost:state:load",stateChange:"turbo-boost:state:change"},d=s(s({},c),u);function m(t,e,r={}){return new Promise(o=>{r=r||{},r.detail=r.detail||{},e=e||document;let n=new CustomEvent(t,v(s({},r),{bubbles:!0}));e.dispatchEvent(n),o(n)})}function J(t){setTimeout(()=>m(c.finish,t.target,{detail:t.detail}))}addEventListener(c.serverError,J);addEventListener(c.success,J);addEventListener(c.finish,t=>x.remove(t.detail.id),!0);var z={events:c};function ht(){return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}var M={v4:ht};var gt=t=>{document.body.insertAdjacentHTML("beforeend",t)},Et=t=>{let r=new DOMParser().parseFromString(t,"text/html");TurboBoost.Streams.morph.method(document.documentElement,r.documentElement)},C=(t,e)=>{if(t&&e){if(t.match(/^Append$/i))return gt(e);if(t.match(/^Replace$/i))return Et(e)}};var R={};addEventListener("turbo:before-fetch-response",t=>{let e=t.target.closest("turbo-frame");e!=null&&e.id&&(e!=null&&e.src)&&(R[e.id]=e.src);let{fetchResponse:r}=t.detail,o=r.header(b.RESPONSE_HEADER);if(!o)return;t.preventDefault();let{strategy:n}=b.tokenize(o);r.responseHTML.then(i=>C(n,i))});addEventListener("turbo:frame-load",t=>{let e=t.target.closest("turbo-frame");e.dataset.src=R[e.id]||e.src||e.dataset.src,delete R[e.id]});var yt={frameAttribute:"data-turbo-frame",methodAttribute:"data-turbo-method",commandAttribute:"data-turbo-command",confirmAttribute:"data-turbo-confirm"},a=s({},yt);var H={method:t=>Promise.resolve(confirm(t))},At=t=>t.detail.driver==="method",xt=t=>{if(t.detail.driver!=="form")return!1;let e=t.target,r=e.closest("turbo-frame"),o=e.closest(`[${a.frameAttribute}]`);return!!(r||o)},Ct=t=>At(t)||xt(t);document.addEventListener(c.start,async t=>{let e=t.target.getAttribute(a.confirmAttribute);if(!e||(t.detail.confirmation=!0,Ct(t)))return;await H.method(e)||t.preventDefault()});var U=H;var l=[],T;function kt(t,e){let r=l.find(o=>o.name===t);return r&&l.splice(l.indexOf(r),1),l=[{name:t,selectors:e},...l],document.removeEventListener(t,T,!0),document.addEventListener(t,T,!0),s({},l.find(o=>o.name===t))}function St(t){return l.find(e=>e.selectors.find(r=>Array.from(document.querySelectorAll(r)).find(o=>o===t)))}function wt(t,e){let r=St(e);return r&&r.name===t}var f={register:kt,isRegisteredForElement:wt,get events(){return[...l]},set handler(t){T=t}};function Lt(t){return t.closest(`[${a.commandAttribute}]`)}function Ot(t){return t.closest("turbo-frame[src]")||t.closest("turbo-frame[data-turbo-frame-src]")||t.closest("turbo-frame")}function Rt(t,e={}){if(t.tagName.toLowerCase()!=="select")return e.value=t.value||null;if(!t.multiple)return e.value=t.options[t.selectedIndex].value;e.values=Array.from(t.options).reduce((r,o)=>(o.selected&&r.push(o.value),r),[])}function Tt(t){let e=Array.from(t.attributes).reduce((r,o)=>{let n=o.value;return r[o.name]=n,r},{});return e.tag=t.tagName,e.checked=!!t.checked,e.disabled=!!t.disabled,Rt(t,e),delete e.class,delete e.action,delete e.href,delete e[a.commandAttribute],delete e[a.frameAttribute],e}var g={buildAttributePayload:Tt,findClosestCommand:Lt,findClosestFrameWithSource:Ot};var $t=(t,e={})=>{let r=t.querySelector('input[name="turbo_boost_command"]')||document.createElement("input");r.type="hidden",r.name="turbo_boost_command",r.value=JSON.stringify(e),t.contains(r)||t.appendChild(r)},q={invokeCommand:$t};var Pt=t=>{let e=document.createElement("a");return e.href=t,new URL(e)},V={get commandInvocationURL(){return Pt("/turbo-boost-command-invocation")}};var W=t=>{let e=`Unexpected error performing a TurboBoost Command! ${t.message}`;m(z.events.clientError,document,{detail:{message:e,error:t}},!0)},_t=t=>{let{strategy:e}=b.tokenize(t.headers.get(b.RESPONSE_HEADER));t.text().then(r=>C(e,r))},k=(t={})=>{try{fetch(V.commandInvocationURL.href,{method:"POST",headers:b.prepare({}),body:JSON.stringify(t)}).then(_t).catch(W)}catch(e){W(e)}};var Nt=(t,e)=>k(e),$={invokeCommand:Nt};var E,P,Dt=()=>{E=null,P=null},It=(t,e={})=>{E=t,P=e},jt=t=>{try{if(!E||t.getAttribute("method")!==E.dataset.turboMethod||t.getAttribute("action")!==E.href)return;let e=t.querySelector('input[name="turbo_boost_command"]')||document.createElement("input");e.type="hidden",e.name="turbo_boost_command",e.value=JSON.stringify(P),t.contains(e)||t.appendChild(e)}finally{Dt()}};document.addEventListener("submit",t=>jt(t.target),!0);var X={invokeCommand:It};var Bt=(t,e={})=>k(e),G={invokeCommand:Bt};function _(t,e){return e=e||{dataset:{}},t.href||e.src||e.dataset.src||location.href}function Ft(t){let e=g.findClosestFrameWithSource(t),{turboFrame:r,turboMethod:o}=t.dataset;return t.tagName.toLowerCase()==="form"?{name:"form",reason:"Element is a form.",frame:e,src:t.action,invokeCommand:q.invokeCommand}:o&&o.length>0?{name:"method",reason:"Element defines data-turbo-method.",frame:e,src:t.href,invokeCommand:X.invokeCommand}:r&&r!=="_self"?(e=document.getElementById(r),{name:"frame",reason:"element targets a frame that is not _self",frame:e,src:_(t,e),invokeCommand:$.invokeCommand}):(!r||r==="_self")&&e?{name:"frame",reason:"element does NOT target a frame or targets _self and is contained by a frame",frame:e,src:_(t,e),invokeCommand:$.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:_(t),invokeCommand:G.invokeCommand}}var N={find:Ft};var w="unknown",K=!1,S=[],Q={debug:Object.values(d),info:Object.values(d),warn:[d.abort,d.clientError,d.serverError],error:[d.clientError,d.serverError],unknown:[]},Jt=t=>{if(!Q[w].includes(t.type)||typeof console[w]!="function")return!1;let{detail:e}=t;if(!e.id)return!0;let r=`${t.type}-${e.id}`;return S.includes(r)?!1:(S.length>16&&S.shift(),S.push(r),!0)},zt=t=>{if(Jt(t)){let{target:e,type:r,detail:o}=t,n=o.id||"",i=o.name||"",p="";o.startedAt&&(p=`${Date.now()-o.startedAt}ms `);let I=r.split(":"),st=I.pop(),j=`%c${I.join(":")}:%c${st}`,at=[`%c${i}`,`%c${p}`,j,`%c${n}`];console.log(at.join(" ").replace(/\s{2,}/g," "),"color:deepskyblue","color:lime","color:darkgray",j.match(/abort|error/i)?"color:red":"color:deepskyblue","color:silver",{detail:o,target:e})}};K||(K=!0,Object.values(d).forEach(t=>addEventListener(t,e=>zt(e))));var Y={get level(){return w},set level(t){return Object.keys(Q).includes(t)||(t="unknown"),w=t}};var D;function L(t,e=null){if(!t||typeof t!="object")return t;let r=new Proxy(t,{deleteProperty(o,n){return delete o[n],m(u.stateChange,document,{detail:{state:D}}),!0},set(o,n,i,p){return o[n]=L(i,this),m(u.stateChange,document,{detail:{state:D}}),!0}});if(Array.isArray(t))t.forEach((o,n)=>t[n]=L(o,r));else if(typeof t=="object")for(let[o,n]of Object.entries(t))t[o]=L(n,r);return e||(D=r),r}var Z=L;function Mt(t,e){return typeof e!="object"&&(e={}),sessionStorage.setItem(String(t),JSON.stringify(e))}function Ht(t){let e=sessionStorage.getItem(String(t));return e?JSON.parse(e):{}}var O={save:Mt,find:Ht};var et={},tt={};function Ut(t,e){removeEventListener(u.stateChange,tt[t]),tt[t]=addEventListener(u.stateChange,r=>{for(let[o,n]of Object.entries(e.current))e.initial[o]!==n&&(e.changed[o]=n);O.save(t,JSON.stringify(e))})}function qt(t,e,r){let o=JSON.parse(e),n={name:t,signed:r,initial:s({},o),current:Z(s({},o)),changed:{}};et[t]=n,O.save(t,n),Ut(t,n),setTimeout(()=>m(u.stateLoad,document,{detail:n}))}function Vt(t){let e={name:t,initial:{},current:{},changed:{}},r=O.find(t);return s(s({},e),r)}function Wt(t){let e=`[${a.commandAttribute}]`,r=[],o=t.closest(e);for(;o;)r.push(Vt(o.getAttribute(a.commandAttribute))),o=o.parentElement.closest(e);return r}var y={initialize:qt,collect:Wt,entries:et};var rt="0.2.1";var Xt=self.TurboBoost||{},nt={VERSION:rt,active:!1,confirmation:U,logger:Y,schema:a,events:c,registerEventDelegate:f.register,get eventDelegates(){return f.events}};function ot(t,e){let r=y.collect(e).map(({name:o,signed:n,changed:i})=>({name:o,signed:n,changed:i}));return{id:t,name:e.getAttribute(a.commandAttribute),elementId:e.id.length>0?e.id:null,elementAttributes:g.buildAttributePayload(e),startedAt:Date.now(),stateCollection:r}}async function Gt(t){let e,r={};try{if(e=g.findClosestCommand(t.target),!e||!f.isRegisteredForElement(t.type,e))return;let o=M.v4(),n=N.find(e),i=v(s({},ot(o,e)),{driver:n.name,frameId:n.frame?n.frame.id:null,src:n.src}),p=await m(c.start,e,{cancelable:!0,detail:i});if(p.defaultPrevented||p.detail.confirmation&&t.defaultPrevented)return m(c.abort,e,{detail:{message:`An event handler for '${c.start}' prevented default behavior and blocked command invocation!`,source:p}});switch(n=N.find(e),i=v(s({},ot(o,e)),{driver:n.name,frameId:n.frame?n.frame.id:null,src:n.src}),x.add(i),["frame","window"].includes(n.name)&&t.preventDefault(),n.name){case"method":return n.invokeCommand(e,i);case"form":return n.invokeCommand(e,i,t);case"frame":return n.invokeCommand(n.frame,i);case"window":return n.invokeCommand(self,i)}}catch(o){m(c.clientError,e,{detail:v(s({},r),{error:o})})}}self.TurboBoost=s({},Xt);self.TurboBoost.Commands||(f.handler=Gt,f.register("click",[`[${a.commandAttribute}]`]),f.register("submit",[`form[${a.commandAttribute}]`]),f.register("change",[`input[${a.commandAttribute}]`,`select[${a.commandAttribute}]`,`textarea[${a.commandAttribute}]`]),self.TurboBoost.Commands=nt,self.TurboBoost.State={initialize:y.initialize,collect:y.collect,get entries(){return JSON.parse(JSON.stringify(y.entries))}});var gr=nt;export{gr as default}; //# sourceMappingURL=commands.js.map diff --git a/app/assets/builds/@turbo-boost/commands.js.map b/app/assets/builds/@turbo-boost/commands.js.map index 8a54e524..7fc2d173 100644 --- a/app/assets/builds/@turbo-boost/commands.js.map +++ b/app/assets/builds/@turbo-boost/commands.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../../javascript/headers.js", "../../../javascript/activity.js", "../../../javascript/events.js", "../../../javascript/lifecycle.js", "../../../javascript/uuids.js", "../../../javascript/renderer.js", "../../../javascript/turbo.js", "../../../javascript/schema.js", "../../../javascript/confirmation.js", "../../../javascript/delegates.js", "../../../javascript/elements.js", "../../../javascript/drivers/form.js", "../../../javascript/urls.js", "../../../javascript/invoker.js", "../../../javascript/drivers/frame.js", "../../../javascript/drivers/method.js", "../../../javascript/drivers/window.js", "../../../javascript/drivers/index.js", "../../../javascript/logger.js", "../../../javascript/state/observable.js", "../../../javascript/state/storage.js", "../../../javascript/state/index.js", "../../../javascript/version.js", "../../../javascript/index.js"], - "sourcesContent": ["const RESPONSE_HEADER = 'TurboBoost-Command'\n\nconst types = {\n boost: 'text/vnd.turbo-boost.html',\n stream: 'text/vnd.turbo-stream.html',\n html: 'text/html',\n xhtml: 'application/xhtml+xml',\n json: 'application/json'\n}\n\n// Prepares request headers for TurboBoost Command invocations\nconst prepare = (headers = {}) => {\n headers = { ...headers }\n\n // Assign Accept values\n const accepts = (headers['Accept'] || '')\n .split(',')\n .map(val => val.trim())\n .filter(val => val.length)\n\n accepts.unshift(types.boost, types.stream, types.html, types.xhtml)\n headers['Accept'] = [...new Set(accepts)].join(', ')\n\n // Assign Content-Type (Commands POST JSON via fetch/XHR)\n headers['Content-Type'] = types.json\n\n // Assign X-Requested-With for XHR detection\n headers['X-Requested-With'] = 'XMLHttpRequest'\n\n return headers\n}\n\n// Tokenizes the 'TurboBoost-Command' HTTP response header value\nconst tokenize = value => {\n if (value) {\n const [name, status, strategy] = value.split(', ')\n return { name, status, strategy }\n }\n\n return {}\n}\n\nexport default { prepare, tokenize, RESPONSE_HEADER }\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", "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 activity from './activity'\nimport { dispatch, commandEvents } from './events'\n\nfunction finish(event) {\n setTimeout(() => dispatch(commandEvents.finish, event.target, { detail: event.detail }))\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", "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 uuids from './uuids'\n\nconst append = content => {\n document.body.insertAdjacentHTML('beforeend', content)\n}\n\nconst replace = content => {\n const parser = new DOMParser()\n const doc = parser.parseFromString(content, 'text/html')\n TurboBoost.Streams.morph.method(document.documentElement, doc.documentElement)\n}\n\nexport const render = (strategy, content) => {\n if (strategy && content) {\n if (strategy.match(/^Append$/i)) return append(content)\n if (strategy.match(/^Replace$/i)) return replace(content)\n }\n}\n\nexport default { render }\n", "import headers from './headers'\nimport lifecycle from './lifecycle'\nimport { dispatch } from './events'\nimport { render } from './renderer'\n\nconst frameSources = {}\n\n// fires after receiving a turbo HTTP response\naddEventListener('turbo:before-fetch-response', event => {\n const frame = event.target.closest('turbo-frame')\n if (frame?.id && frame?.src) frameSources[frame.id] = frame.src\n\n const { fetchResponse: response } = event.detail\n const header = response.header(headers.RESPONSE_HEADER)\n\n if (!header) return\n\n // We'll take it from here Hotwire...\n event.preventDefault()\n const { strategy } = headers.tokenize(header)\n response.responseHTML.then(content => render(strategy, content))\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.src = frameSources[frame.id] || frame.src || frame.dataset.src\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\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", "const invokeCommand = (form, payload = {}) => {\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 if (!form.contains(input)) form.appendChild(input)\n}\n\nexport default { invokeCommand }\n", "const buildURL = path => {\n const a = document.createElement('a')\n a.href = path\n return new URL(a)\n}\n\nexport default {\n get commandInvocationURL() {\n return buildURL('/turbo-boost-command-invocation')\n }\n}\n", "import headers from './headers'\nimport lifecycle from './lifecycle'\nimport urls from './urls'\nimport { dispatch } from './events'\nimport { render } from './renderer'\n\nconst parseError = error => {\n const message = `Unexpected error performing a TurboBoost Command! ${error.message}`\n dispatch(lifecycle.events.clientError, document, { detail: { message, error } }, true)\n}\n\nconst parseAndRenderResponse = response => {\n const { strategy } = headers.tokenize(response.headers.get(headers.RESPONSE_HEADER))\n response.text().then(content => render(strategy, content))\n}\n\nconst invoke = (payload = {}) => {\n try {\n fetch(urls.commandInvocationURL.href, {\n method: 'POST',\n headers: headers.prepare({}),\n body: JSON.stringify(payload)\n })\n .then(parseAndRenderResponse)\n .catch(parseError)\n } catch (error) {\n parseError(error)\n }\n}\n\nexport { invoke }\n", "import { invoke } from '../invoker'\n\nconst invokeCommand = (_, payload) => invoke(payload)\n\nexport default { invokeCommand }\n", "let activeElement\nlet activePayload\n\nconst reset = () => {\n activeElement = null\n activePayload = null\n}\n\nconst invokeCommand = (element, payload = {}) => {\n activeElement = element\n activePayload = payload\n}\n\nconst amendForm = form => {\n try {\n if (!activeElement) return\n if (form.getAttribute('method') !== activeElement.dataset.turboMethod) return\n if (form.getAttribute('action') !== activeElement.href) return\n\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(activePayload)\n if (!form.contains(input)) form.appendChild(input)\n } finally {\n reset() // ensure reset\n }\n}\n\ndocument.addEventListener('submit', event => amendForm(event.target), true)\n\nexport default { invokeCommand }\n", "import { invoke } from '../invoker'\n\nconst invokeCommand = (_, payload = {}) => invoke(payload)\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.src || 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'\nlet initialized = false\nlet history = []\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\nconst shouldLogEvent = event => {\n if (!logLevels[currentLevel].includes(event.type)) return false\n if (typeof console[currentLevel] !== 'function') return false\n\n const { detail } = event\n if (!detail.id) return true\n\n const key = `${event.type}-${detail.id}`\n if (history.includes(key)) return false\n\n if (history.length > 16) history.shift()\n history.push(key)\n\n return true\n}\n\nconst logEvent = event => {\n if (shouldLogEvent(event)) {\n const { target, type, detail } = event\n const id = detail.id || ''\n const commandName = detail.name || ''\n\n let duration = ''\n if (detail.startedAt) duration = `${Date.now() - detail.startedAt}ms `\n\n const typeParts = type.split(':')\n const lastPart = typeParts.pop()\n const eventName = `%c${typeParts.join(':')}:%c${lastPart}`\n const message = [`%c${commandName}`, `%c${duration}`, eventName, `%c${id}`]\n\n console.log(\n message.join(' ').replace(/\\s{2,}/g, ' '),\n 'color:deepskyblue',\n 'color:lime',\n 'color:darkkhaki',\n eventName.match(/error/i) ? 'color:red' : 'color:gold',\n 'color:silver',\n { detail, target }\n )\n }\n}\n\nif (!initialized) {\n initialized = true\n Object.values(events).forEach(name => addEventListener(name, event => logEvent(event)))\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", "import { 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, document, { detail: { state: head } })\n return true\n },\n\n set(target, key, value, receiver) {\n target[key] = observable(value, this)\n dispatch(events.stateChange, document, { 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", "function save(name, value) {\n if (typeof value !== 'object') value = {}\n return sessionStorage.setItem(String(name), JSON.stringify(value))\n}\n\nfunction find(name) {\n const stored = sessionStorage.getItem(String(name))\n return stored ? JSON.parse(stored) : {}\n}\n\nexport default { save, find }\n", "// TODO: Consider moving State to its own library\nimport schema from '../schema'\nimport observable from './observable'\nimport storage from './storage'\nimport { dispatch, commandEvents, stateEvents } from '../events'\n\nlet entries = {}\nlet observers = {}\n\nfunction observe(name, state) {\n removeEventListener(stateEvents.stateChange, observers[name])\n observers[name] = addEventListener(stateEvents.stateChange, event => {\n for (const [key, value] of Object.entries(state.current)) {\n if (state.initial[key] !== value) state.changed[key] = value\n }\n storage.save(name, JSON.stringify(state))\n })\n}\n\nfunction initialize(name, initial, signed) {\n const json = JSON.parse(initial)\n const state = {\n name,\n signed,\n initial: { ...json },\n current: observable({ ...json }),\n changed: {}\n }\n\n entries[name] = state\n storage.save(name, state)\n observe(name, state)\n setTimeout(() => dispatch(stateEvents.stateLoad, document, { detail: state }))\n}\n\nfunction find(name) {\n const stub = { name, initial: {}, current: {}, changed: {} }\n const stored = storage.find(name)\n return { ...stub, ...stored }\n}\n\nfunction collect(element) {\n const selector = `[${schema.commandAttribute}]`\n const list = []\n let context = element.closest(selector)\n while (context) {\n list.push(find(context.getAttribute(schema.commandAttribute)))\n context = context.parentElement.closest(selector)\n }\n return list\n}\n\nexport default {\n initialize,\n collect,\n entries\n}\n", "export default '0.2.1'\n", "import './turbo'\nimport schema from './schema'\nimport { dispatch, commandEvents } from './events'\nimport activity from './activity'\nimport confirmation from './confirmation'\nimport delegates from './delegates'\nimport drivers from './drivers'\nimport elements from './elements'\nimport lifecycle from './lifecycle'\nimport logger from './logger'\nimport state from './state'\nimport uuids from './uuids'\nimport VERSION from './version'\n\nconst TurboBoost = self.TurboBoost || {}\n\nconst Commands = {\n VERSION,\n active: false,\n confirmation,\n logger,\n schema,\n events: commandEvents,\n registerEventDelegate: delegates.register,\n get eventDelegates() {\n return delegates.events\n },\n}\n\nfunction buildCommandPayload(id, element) {\n const stateCollection = state\n .collect(element)\n .map(({ name, signed, changed }) => ({ name, signed, changed }))\n\n return {\n id, //----------------------------------------------------------- Uniquely identifies the command invocation\n name: element.getAttribute(schema.commandAttribute), //---------- Command name\n elementId: element.id.length > 0 ? element.id : null, //--------- ID of the element that triggered the command\n elementAttributes: elements.buildAttributePayload(element), //--- Attributes of the element that triggered the command\n startedAt: Date.now(), //---------------------------------------- Start time of when the command was invoked\n stateCollection, //----------------------------------------------- All command state for the triggering element and its ancestors\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 = 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 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(self, payload)\n }\n } catch (error) {\n dispatch(commandEvents.clientError, element, {\n detail: { ...payload, error },\n })\n }\n}\n\nself.TurboBoost = { ...TurboBoost }\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 = Commands\n self.TurboBoost.State = {\n initialize: state.initialize,\n collect: state.collect,\n get entries() {\n return JSON.parse(JSON.stringify(state.entries))\n },\n }\n}\n\nexport default Commands\n"], - "mappings": "ubAAA,IAAMA,GAAkB,qBAElBC,EAAQ,CACZ,MAAO,4BACP,OAAQ,6BACR,KAAM,YACN,MAAO,wBACP,KAAM,kBACR,EAGMC,GAAU,CAACC,EAAU,CAAC,IAAM,CAChCA,EAAUC,EAAA,GAAKD,GAGf,IAAME,GAAWF,EAAQ,QAAa,IACnC,MAAM,GAAG,EACT,IAAIG,GAAOA,EAAI,KAAK,CAAC,EACrB,OAAOA,GAAOA,EAAI,MAAM,EAE3B,OAAAD,EAAQ,QAAQJ,EAAM,MAAOA,EAAM,OAAQA,EAAM,KAAMA,EAAM,KAAK,EAClEE,EAAQ,OAAY,CAAC,GAAG,IAAI,IAAIE,CAAO,CAAC,EAAE,KAAK,IAAI,EAGnDF,EAAQ,cAAc,EAAIF,EAAM,KAGhCE,EAAQ,kBAAkB,EAAI,iBAEvBA,CACT,EAGMI,GAAWC,GAAS,CACxB,GAAIA,EAAO,CACT,GAAM,CAACC,EAAMC,EAAQC,CAAQ,EAAIH,EAAM,MAAM,IAAI,EACjD,MA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,CAAO,GADjC,CAER,OAAQY,EAAO,KACf,QAASA,EAAO,MAAQA,EAAO,MAAM,GAAK,KAC1C,IAAKA,EAAO,GACd,GAEAM,EAAS,IAAIT,CAAO,EAEhB,CAAC,QAAS,QAAQ,EAAE,SAASG,EAAO,IAAI,GAAGJ,EAAM,eAAe,EAE5DI,EAAO,KAAM,CACnB,IAAK,SACH,OAAOA,EAAO,cAAcZ,EAASS,CAAO,EAC9C,IAAK,OACH,OAAOG,EAAO,cAAcZ,EAASS,EAASD,CAAK,EACrD,IAAK,QACH,OAAOI,EAAO,cAAcA,EAAO,MAAOH,CAAO,EACnD,IAAK,SACH,OAAOG,EAAO,cAAc,KAAMH,CAAO,CAC7C,CACF,OAASU,EAAO,CACdF,EAASrB,EAAc,YAAaI,EAAS,CAC3C,OAAQc,EAAAC,EAAA,GAAKN,GAAL,CAAc,MAAAU,CAAM,EAC9B,CAAC,CACH,CACF,CAEA,KAAK,WAAaJ,EAAA,GAAKzB,IAElB,KAAK,WAAW,WAEnBO,EAAU,QAAUU,GACpBV,EAAU,SAAS,QAAS,CAAC,IAAIF,EAAO,gBAAgB,GAAG,CAAC,EAC5DE,EAAU,SAAS,SAAU,CAAC,QAAQF,EAAO,gBAAgB,GAAG,CAAC,EACjEE,EAAU,SAAS,SAAU,CAC3B,SAASF,EAAO,gBAAgB,IAChC,UAAUA,EAAO,gBAAgB,IACjC,YAAYA,EAAO,gBAAgB,GACrC,CAAC,EAED,KAAK,WAAW,SAAWJ,GAC3B,KAAK,WAAW,MAAQ,CACtB,WAAYW,EAAM,WAClB,QAASA,EAAM,QACf,IAAI,SAAU,CACZ,OAAO,KAAK,MAAM,KAAK,UAAUA,EAAM,OAAO,CAAC,CACjD,CACF,GAGF,IAAOkB,GAAQ7B", + "sourcesContent": ["const RESPONSE_HEADER = 'TurboBoost-Command'\n\nconst types = {\n boost: 'text/vnd.turbo-boost.html',\n stream: 'text/vnd.turbo-stream.html',\n html: 'text/html',\n xhtml: 'application/xhtml+xml',\n json: 'application/json'\n}\n\n// Prepares request headers for TurboBoost Command invocations\nconst prepare = (headers = {}) => {\n headers = { ...headers }\n\n // Assign Accept values\n const accepts = (headers['Accept'] || '')\n .split(',')\n .map(val => val.trim())\n .filter(val => val.length)\n\n accepts.unshift(types.boost, types.stream, types.html, types.xhtml)\n headers['Accept'] = [...new Set(accepts)].join(', ')\n\n // Assign Content-Type (Commands POST JSON via fetch/XHR)\n headers['Content-Type'] = types.json\n\n // Assign X-Requested-With for XHR detection\n headers['X-Requested-With'] = 'XMLHttpRequest'\n\n return headers\n}\n\n// Tokenizes the 'TurboBoost-Command' HTTP response header value\nconst tokenize = value => {\n if (value) {\n const [name, status, strategy] = value.split(', ')\n return { name, status, strategy }\n }\n\n return {}\n}\n\nexport default { prepare, tokenize, RESPONSE_HEADER }\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", "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 activity from './activity'\nimport { dispatch, commandEvents } from './events'\n\nfunction finish(event) {\n setTimeout(() => dispatch(commandEvents.finish, event.target, { detail: event.detail }))\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", "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 uuids from './uuids'\n\nconst append = content => {\n document.body.insertAdjacentHTML('beforeend', content)\n}\n\nconst replace = content => {\n const parser = new DOMParser()\n const doc = parser.parseFromString(content, 'text/html')\n TurboBoost.Streams.morph.method(document.documentElement, doc.documentElement)\n}\n\nexport const render = (strategy, content) => {\n if (strategy && content) {\n if (strategy.match(/^Append$/i)) return append(content)\n if (strategy.match(/^Replace$/i)) return replace(content)\n }\n}\n\nexport default { render }\n", "import headers from './headers'\nimport lifecycle from './lifecycle'\nimport { dispatch } from './events'\nimport { render } from './renderer'\n\nconst frameSources = {}\n\n// fires after receiving a turbo HTTP response\naddEventListener('turbo:before-fetch-response', event => {\n const frame = event.target.closest('turbo-frame')\n if (frame?.id && frame?.src) frameSources[frame.id] = frame.src\n\n const { fetchResponse: response } = event.detail\n const header = response.header(headers.RESPONSE_HEADER)\n\n if (!header) return\n\n // We'll take it from here Hotwire...\n event.preventDefault()\n const { strategy } = headers.tokenize(header)\n response.responseHTML.then(content => render(strategy, content))\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.src = frameSources[frame.id] || frame.src || frame.dataset.src\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\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", "const invokeCommand = (form, payload = {}) => {\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 if (!form.contains(input)) form.appendChild(input)\n}\n\nexport default { invokeCommand }\n", "const buildURL = path => {\n const a = document.createElement('a')\n a.href = path\n return new URL(a)\n}\n\nexport default {\n get commandInvocationURL() {\n return buildURL('/turbo-boost-command-invocation')\n }\n}\n", "import headers from './headers'\nimport lifecycle from './lifecycle'\nimport urls from './urls'\nimport { dispatch } from './events'\nimport { render } from './renderer'\n\nconst parseError = error => {\n const message = `Unexpected error performing a TurboBoost Command! ${error.message}`\n dispatch(lifecycle.events.clientError, document, { detail: { message, error } }, true)\n}\n\nconst parseAndRenderResponse = response => {\n const { strategy } = headers.tokenize(response.headers.get(headers.RESPONSE_HEADER))\n response.text().then(content => render(strategy, content))\n}\n\nconst invoke = (payload = {}) => {\n try {\n fetch(urls.commandInvocationURL.href, {\n method: 'POST',\n headers: headers.prepare({}),\n body: JSON.stringify(payload)\n })\n .then(parseAndRenderResponse)\n .catch(parseError)\n } catch (error) {\n parseError(error)\n }\n}\n\nexport { invoke }\n", "import { invoke } from '../invoker'\n\nconst invokeCommand = (_, payload) => invoke(payload)\n\nexport default { invokeCommand }\n", "let activeElement\nlet activePayload\n\nconst reset = () => {\n activeElement = null\n activePayload = null\n}\n\nconst invokeCommand = (element, payload = {}) => {\n activeElement = element\n activePayload = payload\n}\n\nconst amendForm = form => {\n try {\n if (!activeElement) return\n if (form.getAttribute('method') !== activeElement.dataset.turboMethod) return\n if (form.getAttribute('action') !== activeElement.href) return\n\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(activePayload)\n if (!form.contains(input)) form.appendChild(input)\n } finally {\n reset() // ensure reset\n }\n}\n\ndocument.addEventListener('submit', event => amendForm(event.target), true)\n\nexport default { invokeCommand }\n", "import { invoke } from '../invoker'\n\nconst invokeCommand = (_, payload = {}) => invoke(payload)\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.src || 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'\nlet initialized = false\nlet history = []\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\nconst shouldLogEvent = event => {\n if (!logLevels[currentLevel].includes(event.type)) return false\n if (typeof console[currentLevel] !== 'function') return false\n\n const { detail } = event\n if (!detail.id) return true\n\n const key = `${event.type}-${detail.id}`\n if (history.includes(key)) return false\n\n if (history.length > 16) history.shift()\n history.push(key)\n\n return true\n}\n\nconst logEvent = event => {\n if (shouldLogEvent(event)) {\n const { target, type, detail } = event\n const id = detail.id || ''\n const commandName = detail.name || ''\n\n let duration = ''\n if (detail.startedAt) duration = `${Date.now() - detail.startedAt}ms `\n\n const typeParts = type.split(':')\n const lastPart = typeParts.pop()\n const eventName = `%c${typeParts.join(':')}:%c${lastPart}`\n const message = [`%c${commandName}`, `%c${duration}`, eventName, `%c${id}`]\n\n console.log(\n message.join(' ').replace(/\\s{2,}/g, ' '),\n 'color:deepskyblue',\n 'color:lime',\n 'color:darkgray',\n eventName.match(/abort|error/i) ? 'color:red' : 'color:deepskyblue',\n 'color:silver',\n { detail, target }\n )\n }\n}\n\nif (!initialized) {\n initialized = true\n Object.values(events).forEach(name => addEventListener(name, event => logEvent(event)))\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", "import { 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, document, { detail: { state: head } })\n return true\n },\n\n set(target, key, value, receiver) {\n target[key] = observable(value, this)\n dispatch(events.stateChange, document, { 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", "function save(name, value) {\n if (typeof value !== 'object') value = {}\n return sessionStorage.setItem(String(name), JSON.stringify(value))\n}\n\nfunction find(name) {\n const stored = sessionStorage.getItem(String(name))\n return stored ? JSON.parse(stored) : {}\n}\n\nexport default { save, find }\n", "// TODO: Consider moving State to its own library\nimport schema from '../schema'\nimport observable from './observable'\nimport storage from './storage'\nimport { dispatch, commandEvents, stateEvents } from '../events'\n\nlet entries = {}\nlet observers = {}\n\nfunction observe(name, state) {\n removeEventListener(stateEvents.stateChange, observers[name])\n observers[name] = addEventListener(stateEvents.stateChange, event => {\n for (const [key, value] of Object.entries(state.current)) {\n if (state.initial[key] !== value) state.changed[key] = value\n }\n storage.save(name, JSON.stringify(state))\n })\n}\n\nfunction initialize(name, initial, signed) {\n const json = JSON.parse(initial)\n const state = {\n name,\n signed,\n initial: { ...json },\n current: observable({ ...json }),\n changed: {}\n }\n\n entries[name] = state\n storage.save(name, state)\n observe(name, state)\n setTimeout(() => dispatch(stateEvents.stateLoad, document, { detail: state }))\n}\n\nfunction find(name) {\n const stub = { name, initial: {}, current: {}, changed: {} }\n const stored = storage.find(name)\n return { ...stub, ...stored }\n}\n\nfunction collect(element) {\n const selector = `[${schema.commandAttribute}]`\n const list = []\n let context = element.closest(selector)\n while (context) {\n list.push(find(context.getAttribute(schema.commandAttribute)))\n context = context.parentElement.closest(selector)\n }\n return list\n}\n\nexport default {\n initialize,\n collect,\n entries\n}\n", "export default '0.2.1'\n", "import './turbo'\nimport schema from './schema'\nimport { dispatch, commandEvents } from './events'\nimport activity from './activity'\nimport confirmation from './confirmation'\nimport delegates from './delegates'\nimport drivers from './drivers'\nimport elements from './elements'\nimport lifecycle from './lifecycle'\nimport logger from './logger'\nimport state from './state'\nimport uuids from './uuids'\nimport VERSION from './version'\n\nconst TurboBoost = self.TurboBoost || {}\n\nconst Commands = {\n VERSION,\n active: false,\n confirmation,\n logger,\n schema,\n events: commandEvents,\n registerEventDelegate: delegates.register,\n get eventDelegates() {\n return delegates.events\n }\n}\n\nfunction buildCommandPayload(id, element) {\n const stateCollection = state\n .collect(element)\n .map(({ name, signed, changed }) => ({ name, signed, changed }))\n\n return {\n id, //----------------------------------------------------------- Uniquely identifies the command invocation\n name: element.getAttribute(schema.commandAttribute), //---------- Command name\n elementId: element.id.length > 0 ? element.id : null, //--------- ID of the element that triggered the command\n elementAttributes: elements.buildAttributePayload(element), //--- Attributes of the element that triggered the command\n startedAt: Date.now(), //---------------------------------------- Start time of when the command was invoked\n stateCollection //----------------------------------------------- All command state for the triggering element and its ancestors\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 = 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 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(self, payload)\n }\n } catch (error) {\n dispatch(commandEvents.clientError, element, {\n detail: { ...payload, error }\n })\n }\n}\n\nself.TurboBoost = { ...TurboBoost }\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 = Commands\n self.TurboBoost.State = {\n initialize: state.initialize,\n collect: state.collect,\n get entries() {\n return JSON.parse(JSON.stringify(state.entries))\n }\n }\n}\n\nexport default Commands\n"], + "mappings": "ubAAA,IAAMA,GAAkB,qBAElBC,EAAQ,CACZ,MAAO,4BACP,OAAQ,6BACR,KAAM,YACN,MAAO,wBACP,KAAM,kBACR,EAGMC,GAAU,CAACC,EAAU,CAAC,IAAM,CAChCA,EAAUC,EAAA,GAAKD,GAGf,IAAME,GAAWF,EAAQ,QAAa,IACnC,MAAM,GAAG,EACT,IAAIG,GAAOA,EAAI,KAAK,CAAC,EACrB,OAAOA,GAAOA,EAAI,MAAM,EAE3B,OAAAD,EAAQ,QAAQJ,EAAM,MAAOA,EAAM,OAAQA,EAAM,KAAMA,EAAM,KAAK,EAClEE,EAAQ,OAAY,CAAC,GAAG,IAAI,IAAIE,CAAO,CAAC,EAAE,KAAK,IAAI,EAGnDF,EAAQ,cAAc,EAAIF,EAAM,KAGhCE,EAAQ,kBAAkB,EAAI,iBAEvBA,CACT,EAGMI,GAAWC,GAAS,CACxB,GAAIA,EAAO,CACT,GAAM,CAACC,EAAMC,EAAQC,CAAQ,EAAIH,EAAM,MAAM,IAAI,EACjD,MAAO,CAAE,KAAAC,EAAM,OAAAC,EAAQ,SAAAC,CAAS,CAClC,CAEA,MAAO,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AK,KAC1C,IAAKA,EAAO,GACd,GAEAM,EAAS,IAAIT,CAAO,EAEhB,CAAC,QAAS,QAAQ,EAAE,SAASG,EAAO,IAAI,GAAGJ,EAAM,eAAe,EAE5DI,EAAO,KAAM,CACnB,IAAK,SACH,OAAOA,EAAO,cAAcZ,EAASS,CAAO,EAC9C,IAAK,OACH,OAAOG,EAAO,cAAcZ,EAASS,EAASD,CAAK,EACrD,IAAK,QACH,OAAOI,EAAO,cAAcA,EAAO,MAAOH,CAAO,EACnD,IAAK,SACH,OAAOG,EAAO,cAAc,KAAMH,CAAO,CAC7C,CACF,OAASU,EAAO,CACdF,EAASrB,EAAc,YAAaI,EAAS,CAC3C,OAAQc,EAAAC,EAAA,GAAKN,GAAL,CAAc,MAAAU,CAAM,EAC9B,CAAC,CACH,CACF,CAEA,KAAK,WAAaJ,EAAA,GAAKzB,IAElB,KAAK,WAAW,WAEnBO,EAAU,QAAUU,GACpBV,EAAU,SAAS,QAAS,CAAC,IAAIF,EAAO,gBAAgB,GAAG,CAAC,EAC5DE,EAAU,SAAS,SAAU,CAAC,QAAQF,EAAO,gBAAgB,GAAG,CAAC,EACjEE,EAAU,SAAS,SAAU,CAC3B,SAASF,EAAO,gBAAgB,IAChC,UAAUA,EAAO,gBAAgB,IACjC,YAAYA,EAAO,gBAAgB,GACrC,CAAC,EAED,KAAK,WAAW,SAAWJ,GAC3B,KAAK,WAAW,MAAQ,CACtB,WAAYW,EAAM,WAClB,QAASA,EAAM,QACf,IAAI,SAAU,CACZ,OAAO,KAAK,MAAM,KAAK,UAAUA,EAAM,OAAO,CAAC,CACjD,CACF,GAGF,IAAOkB,GAAQ7B", "names": ["RESPONSE_HEADER", "types", "prepare", "headers", "__spreadValues", "accepts", "val", "tokenize", "value", "name", "status", "strategy", "headers_default", "active", "add", "payload", "remove", "id", "activity_default", "commandEvents", "stateEvents", "allEvents", "__spreadValues", "dispatch", "name", "target", "options", "resolve", "evt", "__spreadProps", "finish", "event", "dispatch", "commandEvents", "activity_default", "lifecycle_default", "v4", "c", "uuids_default", "append", "content", "replace", "doc", "render", "strategy", "frameSources", "event", "frame", "response", "header", "headers_default", "strategy", "content", "render", "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", "input", "form_default", "buildURL", "path", "a", "urls_default", "parseError", "error", "message", "dispatch", "lifecycle_default", "parseAndRenderResponse", "response", "strategy", "headers_default", "content", "render", "invoke", "payload", "urls_default", "invokeCommand", "_", "payload", "invoke", "frame_default", "activeElement", "activePayload", "reset", "invokeCommand", "element", "payload", "amendForm", "form", "input", "event", "method_default", "invokeCommand", "_", "payload", "invoke", "window_default", "src", "element", "frame", "find", "elements_default", "turboFrame", "turboMethod", "form_default", "method_default", "frame_default", "window_default", "drivers_default", "currentLevel", "initialized", "history", "logLevels", "allEvents", "shouldLogEvent", "event", "detail", "key", "logEvent", "target", "type", "id", "commandName", "duration", "typeParts", "lastPart", "eventName", "message", "name", "logger_default", "value", "head", "observable", "object", "parent", "proxy", "target", "key", "dispatch", "stateEvents", "value", "receiver", "index", "observable_default", "save", "name", "value", "find", "stored", "storage_default", "entries", "observers", "observe", "name", "state", "stateEvents", "event", "key", "value", "storage_default", "initialize", "initial", "signed", "json", "__spreadValues", "observable_default", "dispatch", "find", "stub", "stored", "collect", "element", "selector", "schema_default", "list", "context", "state_default", "version_default", "TurboBoost", "Commands", "version_default", "confirmation_default", "logger_default", "schema_default", "commandEvents", "delegates_default", "buildCommandPayload", "id", "element", "stateCollection", "state_default", "name", "signed", "changed", "elements_default", "invokeCommand", "event", "payload", "commandId", "uuids_default", "driver", "drivers_default", "__spreadProps", "__spreadValues", "startEvent", "dispatch", "activity_default", "error", "javascript_default"] } diff --git a/app/javascript/index.js b/app/javascript/index.js index 685702c6..c1e08b4e 100644 --- a/app/javascript/index.js +++ b/app/javascript/index.js @@ -24,7 +24,7 @@ const Commands = { registerEventDelegate: delegates.register, get eventDelegates() { return delegates.events - }, + } } function buildCommandPayload(id, element) { @@ -38,7 +38,7 @@ function buildCommandPayload(id, element) { elementId: element.id.length > 0 ? element.id : null, //--------- ID of the element that triggered the command elementAttributes: elements.buildAttributePayload(element), //--- Attributes of the element that triggered the command startedAt: Date.now(), //---------------------------------------- Start time of when the command was invoked - stateCollection, //----------------------------------------------- All command state for the triggering element and its ancestors + stateCollection //----------------------------------------------- All command state for the triggering element and its ancestors } } @@ -57,20 +57,20 @@ async function invokeCommand(event) { ...buildCommandPayload(commandId, element), driver: driver.name, frameId: driver.frame ? driver.frame.id : null, - src: driver.src, + src: driver.src } const startEvent = await dispatch(commandEvents.start, element, { cancelable: true, - detail: payload, + detail: payload }) if (startEvent.defaultPrevented || (startEvent.detail.confirmation && event.defaultPrevented)) return dispatch(commandEvents.abort, element, { detail: { message: `An event handler for '${commandEvents.start}' prevented default behavior and blocked command invocation!`, - source: startEvent, - }, + source: startEvent + } }) // the element and thus the driver may have changed based on the start event handler(s) @@ -79,7 +79,7 @@ async function invokeCommand(event) { ...buildCommandPayload(commandId, element), driver: driver.name, frameId: driver.frame ? driver.frame.id : null, - src: driver.src, + src: driver.src } activity.add(payload) @@ -98,7 +98,7 @@ async function invokeCommand(event) { } } catch (error) { dispatch(commandEvents.clientError, element, { - detail: { ...payload, error }, + detail: { ...payload, error } }) } } @@ -113,7 +113,7 @@ if (!self.TurboBoost.Commands) { delegates.register('change', [ `input[${schema.commandAttribute}]`, `select[${schema.commandAttribute}]`, - `textarea[${schema.commandAttribute}]`, + `textarea[${schema.commandAttribute}]` ]) self.TurboBoost.Commands = Commands @@ -122,7 +122,7 @@ if (!self.TurboBoost.Commands) { collect: state.collect, get entries() { return JSON.parse(JSON.stringify(state.entries)) - }, + } } } diff --git a/app/javascript/logger.js b/app/javascript/logger.js index 689c97c7..1bcd4d82 100644 --- a/app/javascript/logger.js +++ b/app/javascript/logger.js @@ -46,8 +46,8 @@ const logEvent = event => { message.join(' ').replace(/\s{2,}/g, ' '), 'color:deepskyblue', 'color:lime', - 'color:darkkhaki', - eventName.match(/error/i) ? 'color:red' : 'color:gold', + 'color:darkgray', + eventName.match(/abort|error/i) ? 'color:red' : 'color:deepskyblue', 'color:silver', { detail, target } ) diff --git a/lib/turbo_boost/commands/runner.rb b/lib/turbo_boost/commands/runner.rb index 8126a1df..c5372c4e 100644 --- a/lib/turbo_boost/commands/runner.rb +++ b/lib/turbo_boost/commands/runner.rb @@ -248,7 +248,7 @@ def client_render_strategy def respond_with_abort Rails.logger.error error.message - add_abort_event error.message + add_abort_event end def respond_with_error