From 3115133d3aa234689455ec5b8a0bd83396c35aa0 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 11 Jul 2024 09:49:19 +1000 Subject: [PATCH] Link preloading --- app/Http/Kernel.php | 1 + package-lock.json | 14 +++++++++++++ package.json | 1 + public/build/assets/app-3647e7c5.js | 24 +++++++++++++++++++++++ public/build/assets/app-f72b41bb.js | 24 ----------------------- public/build/manifest.json | 2 +- resources/js/app.js | 1 + resources/views/frontend.blade.php | 6 +++--- resources/views/marketing.blade.php | 6 +++--- resources/views/partials/header.blade.php | 4 ++-- 10 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 public/build/assets/app-3647e7c5.js delete mode 100644 public/build/assets/app-f72b41bb.js diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 3cbb2192..91118a05 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -36,6 +36,7 @@ class Kernel extends HttpKernel \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'cache.headers:public;max_age=300', ], 'api' => [ diff --git a/package-lock.json b/package-lock.json index 9bfa6892..73d59e63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,9 @@ "requires": true, "packages": { "": { + "dependencies": { + "instant.page": "^5.2.0" + }, "devDependencies": { "@alpinejs/focus": "^3.9.6", "@docsearch/css": "^3.3.3", @@ -1132,6 +1135,12 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "node_modules/instant.page": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/instant.page/-/instant.page-5.2.0.tgz", + "integrity": "sha512-DUSwWyoHFOQnmEwJtg9vzDx8Ef8uNNvTxTmHjd0vN9/XEIb5EQkm/itpZMypoH3dJLJvtkrD97WOCKuMqDdMHQ==", + "license": "MIT" + }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -2664,6 +2673,11 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "instant.page": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/instant.page/-/instant.page-5.2.0.tgz", + "integrity": "sha512-DUSwWyoHFOQnmEwJtg9vzDx8Ef8uNNvTxTmHjd0vN9/XEIb5EQkm/itpZMypoH3dJLJvtkrD97WOCKuMqDdMHQ==" + }, "is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", diff --git a/package.json b/package.json index 540f0a4f..9177f0e4 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "alpinejs": "^3.7.1", "autoprefixer": "^10.4.14", "clipboard": "^2.0.10", + "instant.page": "^5.2.0", "laravel-vite-plugin": "^0.7.6", "postcss": "^8.4.21", "postcss-import": "^14.0.0", diff --git a/public/build/assets/app-3647e7c5.js b/public/build/assets/app-3647e7c5.js new file mode 100644 index 00000000..ed6b45e7 --- /dev/null +++ b/public/build/assets/app-3647e7c5.js @@ -0,0 +1,24 @@ +var _r=!1,gr=!1,pe=[];function Ya(e){Xa(e)}function Xa(e){pe.includes(e)||pe.push(e),ec()}function Bo(e){let t=pe.indexOf(e);t!==-1&&pe.splice(t,1)}function ec(){!gr&&!_r&&(_r=!0,queueMicrotask(tc))}function tc(){_r=!1,gr=!0;for(let e=0;ee.effect(t,{scheduler:r=>{yr?Ya(r):r()}}),Ko=e.raw}function wn(e){at=e}function oc(e){let t=()=>{};return[n=>{let o=at(n);return e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(i=>i())}),e._x_effects.add(o),t=()=>{o!==void 0&&(e._x_effects.delete(o),qt(o))},o},()=>{t()}]}var $o=[],Vo=[],Wo=[];function ic(e){Wo.push(e)}function zo(e,t){typeof t=="function"?(e._x_cleanups||(e._x_cleanups=[]),e._x_cleanups.push(t)):(t=e,Vo.push(t))}function ac(e){$o.push(e)}function cc(e,t,r){e._x_attributeCleanups||(e._x_attributeCleanups={}),e._x_attributeCleanups[t]||(e._x_attributeCleanups[t]=[]),e._x_attributeCleanups[t].push(r)}function Jo(e,t){e._x_attributeCleanups&&Object.entries(e._x_attributeCleanups).forEach(([r,n])=>{(t===void 0||t.includes(r))&&(n.forEach(o=>o()),delete e._x_attributeCleanups[r])})}var Wr=new MutationObserver(Qr),zr=!1;function Qo(){Wr.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0}),zr=!0}function uc(){lc(),Wr.disconnect(),zr=!1}var Je=[],ir=!1;function lc(){Je=Je.concat(Wr.takeRecords()),Je.length&&!ir&&(ir=!0,queueMicrotask(()=>{sc(),ir=!1}))}function sc(){Qr(Je),Je.length=0}function L(e){if(!zr)return e();uc();let t=e();return Qo(),t}var Jr=!1,jt=[];function fc(){Jr=!0}function dc(){Jr=!1,Qr(jt),jt=[]}function Qr(e){if(Jr){jt=jt.concat(e);return}let t=[],r=[],n=new Map,o=new Map;for(let i=0;ia.nodeType===1&&t.push(a)),e[i].removedNodes.forEach(a=>a.nodeType===1&&r.push(a))),e[i].type==="attributes")){let a=e[i].target,c=e[i].attributeName,u=e[i].oldValue,l=()=>{n.has(a)||n.set(a,[]),n.get(a).push({name:c,value:a.getAttribute(c)})},s=()=>{o.has(a)||o.set(a,[]),o.get(a).push(c)};a.hasAttribute(c)&&u===null?l():a.hasAttribute(c)?(s(),l()):s()}o.forEach((i,a)=>{Jo(a,i)}),n.forEach((i,a)=>{$o.forEach(c=>c(a,i))});for(let i of r)if(!t.includes(i)&&(Vo.forEach(a=>a(i)),i._x_cleanups))for(;i._x_cleanups.length;)i._x_cleanups.pop()();t.forEach(i=>{i._x_ignoreSelf=!0,i._x_ignore=!0});for(let i of t)r.includes(i)||i.isConnected&&(delete i._x_ignoreSelf,delete i._x_ignore,Wo.forEach(a=>a(i)),i._x_ignore=!0,i._x_ignoreSelf=!0);t.forEach(i=>{delete i._x_ignoreSelf,delete i._x_ignore}),t=null,r=null,n=null,o=null}function Go(e){return ut(je(e))}function ct(e,t,r){return e._x_dataStack=[t,...je(r||e)],()=>{e._x_dataStack=e._x_dataStack.filter(n=>n!==t)}}function Sn(e,t){let r=e._x_dataStack[0];Object.entries(t).forEach(([n,o])=>{r[n]=o})}function je(e){return e._x_dataStack?e._x_dataStack:typeof ShadowRoot=="function"&&e instanceof ShadowRoot?je(e.host):e.parentNode?je(e.parentNode):[]}function ut(e){let t=new Proxy({},{ownKeys:()=>Array.from(new Set(e.flatMap(r=>Object.keys(r)))),has:(r,n)=>e.some(o=>o.hasOwnProperty(n)),get:(r,n)=>(e.find(o=>{if(o.hasOwnProperty(n)){let i=Object.getOwnPropertyDescriptor(o,n);if(i.get&&i.get._x_alreadyBound||i.set&&i.set._x_alreadyBound)return!0;if((i.get||i.set)&&i.enumerable){let a=i.get,c=i.set,u=i;a=a&&a.bind(t),c=c&&c.bind(t),a&&(a._x_alreadyBound=!0),c&&(c._x_alreadyBound=!0),Object.defineProperty(o,n,{...u,get:a,set:c})}return!0}return!1})||{})[n],set:(r,n,o)=>{let i=e.find(a=>a.hasOwnProperty(n));return i?i[n]=o:e[e.length-1][n]=o,!0}});return t}function Zo(e){let t=n=>typeof n=="object"&&!Array.isArray(n)&&n!==null,r=(n,o="")=>{Object.entries(Object.getOwnPropertyDescriptors(n)).forEach(([i,{value:a,enumerable:c}])=>{if(c===!1||a===void 0)return;let u=o===""?i:`${o}.${i}`;typeof a=="object"&&a!==null&&a._x_interceptor?n[i]=a.initialize(e,u,i):t(a)&&a!==n&&!(a instanceof Element)&&r(a,u)})};return r(e)}function Yo(e,t=()=>{}){let r={initialValue:void 0,_x_interceptor:!0,initialize(n,o,i){return e(this.initialValue,()=>pc(n,o),a=>br(n,o,a),o,i)}};return t(r),n=>{if(typeof n=="object"&&n!==null&&n._x_interceptor){let o=r.initialize.bind(r);r.initialize=(i,a,c)=>{let u=n.initialize(i,a,c);return r.initialValue=u,o(i,a,c)}}else r.initialValue=n;return r}}function pc(e,t){return t.split(".").reduce((r,n)=>r[n],e)}function br(e,t,r){if(typeof t=="string"&&(t=t.split(".")),t.length===1)e[t[0]]=r;else{if(t.length===0)throw error;return e[t[0]]||(e[t[0]]={}),br(e[t[0]],t.slice(1),r)}}var Xo={};function Q(e,t){Xo[e]=t}function Or(e,t){return Object.entries(Xo).forEach(([r,n])=>{Object.defineProperty(e,`$${r}`,{get(){let[o,i]=oi(t);return o={interceptor:Yo,...o},zo(t,i),n(t,o)},enumerable:!1})}),e}function hc(e,t,r,...n){try{return r(...n)}catch(o){tt(o,e,t)}}function tt(e,t,r=void 0){Object.assign(e,{el:t,expression:r}),console.warn(`Alpine Expression Error: ${e.message} + +${r?'Expression: "'+r+`" + +`:""}`,t),setTimeout(()=>{throw e},0)}function xe(e,t,r={}){let n;return U(e,t)(o=>n=o,r),n}function U(...e){return ei(...e)}var ei=ti;function mc(e){ei=e}function ti(e,t){let r={};Or(r,e);let n=[r,...je(e)];if(typeof t=="function")return vc(n,t);let o=gc(n,t,e);return hc.bind(null,e,t,o)}function vc(e,t){return(r=()=>{},{scope:n={},params:o=[]}={})=>{let i=t.apply(ut([n,...e]),o);It(r,i)}}var ar={};function _c(e,t){if(ar[e])return ar[e];let r=Object.getPrototypeOf(async function(){}).constructor,n=/^[\n\s]*if.*\(.*\)/.test(e)||/^(let|const)\s/.test(e)?`(() => { ${e} })()`:e,i=(()=>{try{return new r(["__self","scope"],`with (scope) { __self.result = ${n} }; __self.finished = true; return __self.result;`)}catch(a){return tt(a,t,e),Promise.resolve()}})();return ar[e]=i,i}function gc(e,t,r){let n=_c(t,r);return(o=()=>{},{scope:i={},params:a=[]}={})=>{n.result=void 0,n.finished=!1;let c=ut([i,...e]);if(typeof n=="function"){let u=n(n,c).catch(l=>tt(l,r,t));n.finished?(It(o,n.result,c,a,r),n.result=void 0):u.then(l=>{It(o,l,c,a,r)}).catch(l=>tt(l,r,t)).finally(()=>n.result=void 0)}}}function It(e,t,r,n,o){if(typeof t=="function"){let i=t.apply(r,n);i instanceof Promise?i.then(a=>It(e,a,r,n)).catch(a=>tt(a,o,t)):e(i)}else e(t)}var Gr="x-";function ke(e=""){return Gr+e}function yc(e){Gr=e}var ri={};function M(e,t){ri[e]=t}function Zr(e,t,r){let n={};return Array.from(t).map(ci((i,a)=>n[i]=a)).filter(li).map(Sc(n,r)).sort(Ec).map(i=>wc(e,i))}function bc(e){return Array.from(e).map(ci()).filter(t=>!li(t))}var wr=!1,Ve=new Map,ni=Symbol();function Oc(e){wr=!0;let t=Symbol();ni=t,Ve.set(t,[]);let r=()=>{for(;Ve.get(t).length;)Ve.get(t).shift()();Ve.delete(t)},n=()=>{wr=!1,r()};e(r),n()}function oi(e){let t=[],r=c=>t.push(c),[n,o]=oc(e);return t.push(o),[{Alpine:lt,effect:n,cleanup:r,evaluateLater:U.bind(U,e),evaluate:xe.bind(xe,e)},()=>t.forEach(c=>c())]}function wc(e,t){let r=()=>{},n=ri[t.type]||r,[o,i]=oi(e);cc(e,t.original,i);let a=()=>{e._x_ignore||e._x_ignoreSelf||(n.inline&&n.inline(e,t,o),n=n.bind(n,e,t,o),wr?Ve.get(ni).push(n):n())};return a.runCleanups=i,a}var ii=(e,t)=>({name:r,value:n})=>(r.startsWith(e)&&(r=r.replace(e,t)),{name:r,value:n}),ai=e=>e;function ci(e=()=>{}){return({name:t,value:r})=>{let{name:n,value:o}=ui.reduce((i,a)=>a(i),{name:t,value:r});return n!==t&&e(n,t),{name:n,value:o}}}var ui=[];function Yr(e){ui.push(e)}function li({name:e}){return si().test(e)}var si=()=>new RegExp(`^${Gr}([^:^.]+)\\b`);function Sc(e,t){return({name:r,value:n})=>{let o=r.match(si()),i=r.match(/:([a-zA-Z0-9\-:]+)/),a=r.match(/\.[^.\]]+(?=[^\]]*$)/g)||[],c=t||e[r]||r;return{type:o?o[1]:null,value:i?i[1]:null,modifiers:a.map(u=>u.replace(".","")),expression:n,original:c}}}var Sr="DEFAULT",dt=["ignore","ref","data","id","bind","init","for","model","modelable","transition","show","if",Sr,"teleport","element"];function Ec(e,t){let r=dt.indexOf(e.type)===-1?Sr:e.type,n=dt.indexOf(t.type)===-1?Sr:t.type;return dt.indexOf(r)-dt.indexOf(n)}function Qe(e,t,r={}){e.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0,cancelable:!0}))}var Er=[],Xr=!1;function fi(e){Er.push(e),queueMicrotask(()=>{Xr||setTimeout(()=>{xr()})})}function xr(){for(Xr=!1;Er.length;)Er.shift()()}function xc(){Xr=!0}function ve(e,t){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(o=>ve(o,t));return}let r=!1;if(t(e,()=>r=!0),r)return;let n=e.firstElementChild;for(;n;)ve(n,t),n=n.nextElementSibling}function Ie(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}function Pc(){document.body||Ie("Unable to initialize. Trying to load Alpine before `` is available. Did you forget to add `defer` in Alpine's `