@stacksjs/bun-router 0.0.26 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-0gjq8ttx.js +14 -0
- package/dist/chunk-0t5vz87j.js +35 -0
- package/dist/chunk-30rkn2ym.js +2 -0
- package/dist/chunk-38cmrard.js +2 -0
- package/dist/chunk-3qna6dwd.js +2 -0
- package/dist/chunk-4d5fmta0.js +2 -0
- package/dist/chunk-4x3b4b4q.js +2 -0
- package/dist/chunk-5be9x5cq.js +3 -0
- package/dist/chunk-5mxby3fd.js +1654 -0
- package/dist/chunk-5n0ckcmc.js +3 -0
- package/dist/chunk-5ncn73tp.js +3 -0
- package/dist/chunk-5s0pnsd6.js +12 -0
- package/dist/chunk-5s1pr62n.js +3 -0
- package/dist/chunk-67wgad4f.js +60 -0
- package/dist/chunk-6bbmkwng.js +3 -0
- package/dist/chunk-6s1kbajm.js +7851 -0
- package/dist/chunk-6sjvhy5f.js +3 -0
- package/dist/chunk-6xed4va1.js +2 -0
- package/dist/chunk-73k79n7q.js +15413 -0
- package/dist/chunk-748n6ydj.js +2 -0
- package/dist/chunk-7qnxdedn.js +321 -0
- package/dist/chunk-7rsf8tes.js +898 -0
- package/dist/chunk-8aspmtf1.js +2 -0
- package/dist/chunk-8wpj3fqe.js +351 -0
- package/dist/chunk-8yfdg595.js +2 -0
- package/dist/chunk-90eze7av.js +3 -0
- package/dist/chunk-9805tt8n.js +341 -0
- package/dist/chunk-9dvwyej7.js +2 -0
- package/dist/chunk-9ght4n4r.js +216 -0
- package/dist/chunk-a2w45krb.js +2 -0
- package/dist/chunk-a3wahyg7.js +3 -0
- package/dist/chunk-a547f2ab.js +48 -0
- package/dist/chunk-bqdycvtc.js +2 -0
- package/dist/chunk-brpgjyqg.js +3 -0
- package/dist/chunk-cd03rk3x.js +2 -0
- package/dist/chunk-csfrpsp7.js +185 -0
- package/dist/chunk-ct0m17q5.js +2 -0
- package/dist/chunk-dhbvvr5h.js +2 -0
- package/dist/chunk-dhptcsya.js +943 -0
- package/dist/chunk-dq93zag9.js +2 -0
- package/dist/chunk-dxg045wj.js +5 -0
- package/dist/chunk-e3qej0jr.js +4 -0
- package/dist/chunk-edrtesh7.js +2 -0
- package/dist/chunk-ejcws37w.js +2 -0
- package/dist/chunk-ex5fkjah.js +397 -0
- package/dist/chunk-ex890p45.js +51 -0
- package/dist/chunk-f69cpnhw.js +2 -0
- package/dist/chunk-fjf53b44.js +2 -0
- package/dist/chunk-fjzye4qj.js +2 -0
- package/dist/chunk-gfd23b6t.js +2 -0
- package/dist/chunk-habv0vef.js +12 -0
- package/dist/chunk-hmgedrmr.js +11 -0
- package/dist/chunk-hz6fc788.js +2 -0
- package/dist/chunk-jff6j9y3.js +10 -0
- package/dist/chunk-jmeb7n8k.js +70 -0
- package/dist/chunk-jrf5a2ap.js +2 -0
- package/dist/chunk-jy2jhcpy.js +246 -0
- package/dist/chunk-kc659vhx.js +4 -0
- package/dist/chunk-kjtjbcq4.js +71 -0
- package/dist/chunk-krkchy8v.js +4 -0
- package/dist/chunk-kxp888dn.js +4540 -0
- package/dist/chunk-m249t3je.js +3 -0
- package/dist/chunk-m9yabnjx.js +2 -0
- package/dist/chunk-mekrq9wd.js +2 -0
- package/dist/chunk-mmxv535f.js +82 -0
- package/dist/chunk-mypn7jss.js +2 -0
- package/dist/chunk-n18x1k3c.js +2 -0
- package/dist/chunk-nkddjzsa.js +2 -0
- package/dist/chunk-pjmhqmr9.js +2 -0
- package/dist/chunk-qyrnsaq1.js +2 -0
- package/dist/chunk-r19ff2qm.js +62 -0
- package/dist/chunk-r338fssq.js +2 -0
- package/dist/chunk-s36z58x2.js +29 -0
- package/dist/chunk-s3dn1kwx.js +231 -0
- package/dist/chunk-s79dd325.js +471 -0
- package/dist/chunk-sw0chtw4.js +4 -0
- package/dist/chunk-ta38j9em.js +2 -0
- package/dist/chunk-tpfgntwj.js +4211 -0
- package/dist/chunk-vr10sbbh.js +3 -0
- package/dist/chunk-vsh4390q.js +358 -0
- package/dist/chunk-vv3gb1m5.js +84 -0
- package/dist/chunk-vw8rwv6e.js +2 -0
- package/dist/chunk-w4r464v5.js +288 -0
- package/dist/chunk-wcrqs5z9.js +2 -0
- package/dist/chunk-x6d1rmwa.js +2 -0
- package/dist/chunk-x7ft15zz.js +2 -0
- package/dist/chunk-x8trwn7j.js +3 -0
- package/dist/chunk-xg9xscqz.js +1 -0
- package/dist/chunk-xhepdj1f.js +2 -0
- package/dist/chunk-xv2em0q4.js +4 -0
- package/dist/chunk-ypw6g0te.js +2 -0
- package/dist/chunk-z8szsm21.js +2 -0
- package/dist/chunk-zetqzgf3.js +194 -0
- package/dist/chunk-zfbh14qe.js +2 -0
- package/dist/chunk-zhx0hxdd.js +28 -0
- package/dist/cli.js +67 -3240
- package/dist/container/index.js +1 -321
- package/dist/index.js +80 -13987
- package/dist/types.d.ts +12 -2
- package/package.json +1 -1
- package/dist/chunk-1ahs68ys.js +0 -18
- package/dist/chunk-cgptvjdf.js +0 -18131
- package/dist/chunk-g3ybefhg.js +0 -1923
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{createHash as y}from"crypto";import{readFile as k,stat as x}from"fs/promises";async function g(t){try{let e=await k(t);return y("sha256").update(e).digest("hex").slice(0,16)}catch{return""}}function N(t){return y("sha256").update(t).digest("hex").slice(0,16)}function p(t){return y("sha256").update(t).digest("hex").slice(0,16)}function d(t,e){let a=JSON.stringify(e,Object.keys(e).sort());return`${p(t)}-${p(a)}`}async function m(t){try{return(await x(t)).mtimeMs}catch{return 0}}async function C(t){try{return await x(t),!0}catch{return!1}}import{mkdir as v,readFile as D,writeFile as E,readdir as S,rm as w,stat as z}from"fs/promises";import{join as h,dirname as O}from"path";var f=new Map,u={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500};async function P(t){try{await v(t,{recursive:!0})}catch{}}function F(t,e,a){return h(t,a,`${e}.json`)}async function A(t,e,a){if((Date.now()-t.createdAt)/86400000>a)return!1;if(await m(e)!==t.srcMtime)return!1;return!0}async function K(t,e,a,c=u){if(!c.enabled)return null;let r=d(t,e),i=f.get(r);if(i){if(await A(i,t,c.maxAge))return i.lastAccessedAt=Date.now(),i.data;f.delete(r)}let s=F(c.directory,r,a);if(await C(s))try{let n=await D(s,"utf-8"),o=JSON.parse(n);if(await A(o,t,c.maxAge))return o.lastAccessedAt=Date.now(),f.set(r,o),o.data}catch{}return null}async function V(t,e,a,c,r=u){if(!r.enabled)return;let i=d(t,e),s=await g(t),n=await m(t),o={key:i,src:t,srcHash:s,srcMtime:n,optionsHash:d("",e),data:a,createdAt:Date.now(),lastAccessedAt:Date.now()};f.set(i,o);let l=F(r.directory,i,c);try{await P(O(l)),await E(l,JSON.stringify(o,null,2))}catch(M){console.warn(`[stx-media] Failed to write cache: ${M}`)}}async function q(t,e=u){if(t==="all")f.clear();else f.clear();let a=t==="all"?["image","video"]:[t];for(let c of a){let r=h(e.directory,c);try{await w(r,{recursive:!0,force:!0})}catch{}}}async function G(t=u){let e={memoryEntries:f.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let a of["image","video"]){let c=h(t.directory,a);try{let r=await S(c);e.diskEntries[a]=r.length;for(let i of r){let s=h(c,i),n=await z(s);e.totalSizeMB+=n.size/1048576}}catch{}}return e}async function I(t=u){let e=0,a=t.maxAge*24*60*60*1000;for(let c of["image","video"]){let r=h(t.directory,c);try{let i=await S(r);for(let s of i){let n=h(r,s);try{let o=await D(n,"utf-8"),l=JSON.parse(o);if(Date.now()-l.createdAt>a)await w(n),f.delete(l.key),e++}catch{await w(n).catch(()=>{}),e++}}}catch{}}return e}
|
|
3
|
+
export{g as Fu,N as Gu,p as Hu,d as Iu,m as Ju,C as Ku,K as Lu,V as Mu,q as Nu,G as Ou,I as Pu};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Fj as S}from"./chunk-tpfgntwj.js";import{mn as x,on as w}from"./chunk-0t5vz87j.js";function $(t,o){let r=1,n=o,e="<template",l="</template";while(n<t.length&&r>0){let s=t.indexOf("<",n);if(s===-1)break;if(n=s,t.startsWith(e,n)&&(n+e.length>=t.length||/[\s>\/]/.test(t[n+e.length]))){r++,n+=e.length;continue}if(t.startsWith(l,n)){let i=t.indexOf(">",n+l.length);if(i!==-1){if(r--,r===0)return i+1;n=i+1;continue}}n++}return r===0?n:-1}var E=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function y(t,o){let r=null;for(let n=o;n<t.length;n++){let e=t[n];if(r){if(e==="\\"){n++;continue}if(e===r)r=null;continue}if(e==='"'||e==="'"){r=e;continue}if(e===">")return n+1}return-1}function N(t){let o=[],r=[],n=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let l=t.indexOf("<",e);if(l===-1)break;if(t.startsWith("<!--",l)){let u=t.indexOf("-->",l+4);e=u===-1?t.length:u+3;continue}let s=y(t,l+1);if(s===-1)break;let i=t.slice(l,s),a=i.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!a){e=s;continue}let c=a[1]==="/",f=a[2].toLowerCase();if(c){let u=r.lastIndexOf(f);if(u!==-1)r.splice(u);e=s;continue}if(f==="template"&&r.length===0){let u=i.match(n);if(u){let m=$(t,s);if(m!==-1){let p=u[1]||u[2]||u[3];o.push({start:l,end:m,slotName:p,content:t.slice(s,m-11).trim(),propsBinding:u[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(i)&&!E.has(f)){if(r.push(f),f==="script"||f==="style"){let u=t.toLowerCase().indexOf(`</${f}>`,s);if(u!==-1){e=u;continue}}}e=s}return o}function z(t){let o={default:"",named:new Map},r=t,n=N(t);for(let a of n)o.named.set(a.slotName,{name:a.slotName,content:a.content,propsBinding:a.propsBinding});n.sort((a,c)=>c.start-a.start);for(let a of n)r=r.slice(0,a.start)+r.slice(a.end);let e=[],l=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,s;while((s=l.exec(r))!==null){let[a,c,f,u,m,p]=s,d=f.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),h=m.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),g=(d+h).trim(),A=`<${c}${g?" "+g:""}>${p}</${c}>`;e.push({start:s.index,end:s.index+a.length,slotName:u,element:A})}let i=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((s=i.exec(r))!==null){let[a,c,f,u,m]=s,p=f.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),d=m.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),h=(p+d).trim(),g=`<${c}${h?" "+h:""} />`;e.push({start:s.index,end:s.index+a.length,slotName:u,element:g})}e.sort((a,c)=>c.start-a.start);for(let a of e){let c=o.named.get(a.slotName);if(c)c.content+=a.element;else o.named.set(a.slotName,{name:a.slotName,content:a.element});r=r.slice(0,a.start)+r.slice(a.end)}return o.default=r.trim(),o}function C(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),r=o?o[1]:"",n={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,l;while((l=e.exec(t))!==null)n[l[1]]=l[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),i=s?s[1].trim():"";return{name:r,props:n,defaultContent:i}}async function M(t,o,r,n){if(!t)return r;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let l=t.propsBinding.trim(),s={...n};if(l.startsWith("{")&&l.endsWith("}")){let i=l.slice(1,-1).split(",").map((a)=>a.trim()).filter(Boolean);for(let a of i){let[c,f]=a.split(":").map((m)=>m.trim()),u=f||c;if(o[c]!==void 0)s[u]=o[c]}}else s[l]=o;e=Z(e,s)}return e}function Z(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(r,n)=>{try{let e=n.trim(),l=b(e,o);return S(String(l??""))}catch{return`{{ ${n} }}`}})}function b(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let n=t.split("."),e=o;for(let l of n)if(e&&typeof e==="object"&&l in e)e=e[l];else return;return e}let r=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(r){let[,n,e,l]=r,s=o[n],i=parseInt(l,10);if(typeof s==="number")switch(e){case"+":return s+i;case"-":return s-i;case"*":return s*i;case"/":return s/i}}try{if(!x(t))return;return w(t,Object.keys(o))(...Object.values(o))}catch{return}}async function k(t,o,r){let n=t;n=await O(n,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(l,s,i,a)=>{let c=o.named.get(s),f=a?.trim()||"",u=i||"",m={},p=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,d;while((d=p.exec(u))!==null){let h=d[1],g=d[2];m[h]=b(g,r)}return await M(c,m,f,r)});let e=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return n=n.replace(e,(l,s)=>{if(l.includes("name="))return l;let i=s?.trim()||"";return o.default||i}),n}async function O(t,o,r){let n=[],e=[];t.replace(o,(i,...a)=>{let c=a[a.length-2];return e.push({match:i,index:c}),n.push(r(i,...a.slice(0,-2))),i});let l=await Promise.all(n),s=t;for(let i=e.length-1;i>=0;i--){let{match:a,index:c}=e[i];s=s.slice(0,c)+l[i]+s.slice(c+a.length)}return s}function R(t){let o=z(t);return{defaultSlot:o.default,namedSlots:o.named}}async function _(t,o,r,n){return await k(t,{default:o,named:r},n)}
|
|
3
|
+
export{z as o,C as p,M as q,k as r,R as s,_ as t};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Mo as x}from"./chunk-5be9x5cq.js";import"./chunk-a3wahyg7.js";import p from"path";var b=["broadcast","calculateDistance","canNotify","clearCookies","clearFetchCache","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],O=new Set(b);var u=new Map,h=new Set,k=new Set(b);function _(){u.clear()}function v(o){let r=new Map;for(let t of o){let i=p.basename(t);if(i.endsWith(".d.ts"))continue;let n=i.replace(/\.[jt]s$/,"");if(n==="index")continue;if(n===i)continue;let c=r.get(n);if(c&&!c.endsWith(".js"))continue;r.set(n,t)}return[...r.values()].sort()}function C(o,r){let t=r.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${t}\\b`).test(o)}function E(o){if(!o)return[];let r=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of k){if(h.has(i))continue;let n=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${n}\\s*\\(`).test(r))t.push(i)}return t.sort()}async function F(o,r){let t=E(o);if(t.length===0)return null;let i=r??p.join(import.meta.dir,"composables"),n=`${i}\x00${t.join(",")}`,c=u.get(n);if(c!==void 0)return c||null;let S=new Bun.Transpiler({loader:"ts",target:"browser",define:x()}),y=new Set(t),f=[],m=new Set,l=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:i,absolute:!0}))l.push(e)}catch{return u.set(n,""),null}l=v(l);for(let s of l){let e;try{e=await Bun.file(s).text()}catch{continue}let d=[];try{d=S.scan(e).exports.filter((a)=>a!=="default")}catch{continue}if(!d.some((a)=>y.has(a)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),f.push(`// ${p.basename(s).replace(/\.[jt]s$/,"")}
|
|
3
|
+
${S.transformSync(e).trim()}`);for(let a of d)m.add(a)}catch(a){console.warn(`[stx] framework composable ${p.basename(s)} could not be bundled:`,a)}}let g=t.filter((s)=>!m.has(s)&&!C(o,s));if(g.length>0)console.warn(`[stx] could not bundle ${g.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(f.length===0)return u.set(n,""),null;let $=[...m].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
|
|
4
|
+
`),w=`<script data-stx-framework-composables>
|
|
5
|
+
;(function(){
|
|
6
|
+
var __s = window.stx = window.stx || {};
|
|
7
|
+
${f.join(`
|
|
8
|
+
|
|
9
|
+
`)}
|
|
10
|
+
${$}
|
|
11
|
+
})();
|
|
12
|
+
</script>`;return u.set(n,w),w}function I(o){h.clear();for(let r of o)h.add(r)}export{v as selectComposableFiles,E as referencedFrameworkComposables,F as getFrameworkComposableScript,_ as clearFrameworkComposableCache,I as __setRuntimeOwnedForTest};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import s from"path";var x=new Set([".jpg",".jpeg",".png",".gif"]),d=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}];async function j(e,i){let a=i.formats??d;if(!i.publicDir)return e;let n=$(e),u=[],p=/<img\b[^>]*?>/gi,c=[],o;while((o=p.exec(e))!==null){let t=o[0],r=t.match(/\bsrc=["']([^"']+)["']/i);if(!r)continue;if(R(o.index,n))continue;c.push({idx:o.index,length:t.length,src:r[1],raw:t})}if(c.length===0)return e;let m=await Promise.all(c.map(async(t)=>{let r=await b(t.src,i.publicDir,a);return{match:t,sources:r}}));for(let{match:t,sources:r}of m){if(r.length===0)continue;let h=`<picture>${r.map((g)=>`<source type="${g.mime}" srcset="${S(g.url)}">`).join("")}${t.raw}</picture>`;u.push({start:t.idx,end:t.idx+t.length,replacement:h})}if(u.length===0)return e;let f="",l=0;for(let t of u)f+=e.slice(l,t.start),f+=t.replacement,l=t.end;return f+=e.slice(l),f}async function b(e,i,a){if(!w(e))return[];let n=s.extname(e).toLowerCase();if(!x.has(n))return[];if(!e.startsWith("/"))return[];let u=s.join(i,e.slice(1)),p=s.dirname(u),c=s.basename(u,n),o=s.resolve(p),m=s.resolve(i);if(!o.startsWith(m))return[];let f=s.posix.dirname(e),l=a.map(async(t)=>{let r=s.join(p,`${c}${t.ext}`);if(!await Bun.file(r).exists())return null;return{url:s.posix.join(f,`${c}${t.ext}`),mime:t.mime}});return(await Promise.all(l)).filter((t)=>t!==null)}function w(e){if(!e)return!1;if(e.startsWith("http://")||e.startsWith("https://"))return!1;if(e.startsWith("//"))return!1;if(e.startsWith("data:"))return!1;return!0}function $(e){let i=[],a=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,n;while((n=a.exec(e))!==null)i.push([n.index,n.index+n[0].length]);return i}function R(e,i){for(let[a,n]of i)if(e>=a&&e<n)return!0;return!1}function S(e){return e.replace(/&/g,"&").replace(/"/g,""")}
|
|
3
|
+
export{j as ve};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./chunk-a3wahyg7.js";function c(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function o(e){let t=e.pwa;if(!t?.enabled)return"";let r=t.manifest,n=t.icons?.outputDir?`/${t.icons.outputDir}`:"/pwa-icons",s=c(e),a=`
|
|
3
|
+
<!-- stx PWA Meta Tags -->
|
|
4
|
+
<link rel="manifest" href="/manifest.json">
|
|
5
|
+
<meta name="theme-color" content="${i(r?.themeColor||"#000000")}">
|
|
6
|
+
<meta name="mobile-web-app-capable" content="yes">
|
|
7
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
8
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
|
9
|
+
<meta name="apple-mobile-web-app-title" content="${i(r?.shortName||r?.name||"App")}">`;if(t.icons?.generateAppleIcons!==!1)a+=`
|
|
10
|
+
<link rel="apple-touch-icon" href="${n}/apple-touch-icon.png">
|
|
11
|
+
<link rel="apple-touch-icon" sizes="120x120" href="${n}/apple-touch-icon-120x120.png">
|
|
12
|
+
<link rel="apple-touch-icon" sizes="152x152" href="${n}/apple-touch-icon-152x152.png">
|
|
13
|
+
<link rel="apple-touch-icon" sizes="167x167" href="${n}/apple-touch-icon-167x167.png">
|
|
14
|
+
<link rel="apple-touch-icon" sizes="180x180" href="${n}/apple-touch-icon-180x180.png">`;return a+=`
|
|
15
|
+
<link rel="icon" type="image/png" sizes="32x32" href="${n}/favicon-32x32.png">
|
|
16
|
+
<link rel="icon" type="image/png" sizes="16x16" href="${n}/favicon-16x16.png">
|
|
17
|
+
<link rel="icon" type="image/png" sizes="192x192" href="${n}/icon-192x192.png">`,a+=`
|
|
18
|
+
<!-- stx Service Worker Registration -->
|
|
19
|
+
<script>
|
|
20
|
+
if ('serviceWorker' in navigator) {
|
|
21
|
+
window.addEventListener('load', function() {
|
|
22
|
+
navigator.serviceWorker.register('/${s}')
|
|
23
|
+
.then(function(registration) {
|
|
24
|
+
console.log('[PWA] Service Worker registered:', registration.scope);
|
|
25
|
+
|
|
26
|
+
// Check for updates
|
|
27
|
+
registration.addEventListener('updatefound', function() {
|
|
28
|
+
const newWorker = registration.installing;
|
|
29
|
+
if (newWorker) {
|
|
30
|
+
newWorker.addEventListener('statechange', function() {
|
|
31
|
+
if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
|
|
32
|
+
console.log('[PWA] New content available, refresh to update');
|
|
33
|
+
// Optionally dispatch a custom event for UI notification
|
|
34
|
+
window.dispatchEvent(new CustomEvent('pwa-update-available'));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
})
|
|
40
|
+
.catch(function(error) {
|
|
41
|
+
console.error('[PWA] Service Worker registration failed:', error);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
<!-- End stx PWA -->`,a}function m(e,t){let r=t.pwa;if(!r?.enabled||r.autoInject===!1)return e;if(e.includes("<!-- stx PWA Meta Tags -->"))return e;if(!e.includes("</head>")){let s=e.lastIndexOf("</body>");if(s!==-1){let a=o(t);return e.slice(0,s)+a+`
|
|
47
|
+
`+e.slice(s)}return e+o(t)}let n=o(t);return e.replace("</head>",`${n}
|
|
48
|
+
</head>`)}function y(e){if(!e.pwa?.enabled)return"";return`<script>
|
|
49
|
+
if ('serviceWorker' in navigator) {
|
|
50
|
+
window.addEventListener('load', function() {
|
|
51
|
+
navigator.serviceWorker.register('/${c(e)}')
|
|
52
|
+
.then(function(registration) {
|
|
53
|
+
console.log('[PWA] Service Worker registered:', registration.scope);
|
|
54
|
+
})
|
|
55
|
+
.catch(function(error) {
|
|
56
|
+
console.error('[PWA] Service Worker registration failed:', error);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
</script>`}function w(){return'<link rel="manifest" href="/manifest.json">'}function S(e){return`<meta name="theme-color" content="${i(e)}">`}function i(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}export{m as injectPwaTags,S as generateThemeColorMeta,y as generateSwRegistrationScript,o as generatePwaTags,w as generateManifestLink};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function a(e){return e}class c{plugins=new Map;sortedPlugins=[];initialized=!1;async register(e,r){if(this.plugins.has(e.name))throw Error(`Plugin "${e.name}" is already registered`);if(e.dependencies){for(let t of e.dependencies)if(!this.plugins.has(t))throw Error(`Plugin "${e.name}" depends on "${t}" which is not registered`)}if(this.plugins.set(e.name,e),e.onRegister)await e.onRegister(r);this.sortPlugins()}async unregister(e){let r=this.plugins.get(e);if(!r)return!1;for(let[t,s]of this.plugins)if(s.dependencies?.includes(e))throw Error(`Cannot unregister "${e}" because "${t}" depends on it`);if(r.onUnregister)await r.onUnregister();return this.plugins.delete(e),this.sortPlugins(),!0}get(e){return this.plugins.get(e)}has(e){return this.plugins.has(e)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let e=[];for(let r of this.sortedPlugins)if(r.registerDirectives)e.push(...r.registerDirectives());return e}getAllFilters(){let e={};for(let r of this.sortedPlugins)if(r.registerFilters)Object.assign(e,r.registerFilters());return e}async runBeforeProcess(e){return this.runHooks("beforeProcess",e)}async runAfterParse(e){return this.runHooks("afterParse",e)}async runBeforeDirective(e,r){return this.runDirectiveHooks("beforeDirective",e,r)}async runAfterDirective(e,r){return this.runDirectiveHooks("afterDirective",e,r)}async runBeforeRender(e){return this.runHooks("beforeRender",e)}async runAfterRender(e){return this.runHooks("afterRender",e)}async runOnError(e){for(let r of this.sortedPlugins)if(r.onError)try{let t=await r.onError(e);if(t){if(t.template!==void 0)e.template=t.template;if(t.context)e.context={...e.context,...t.context};if(t.metadata)e.metadata={...e.metadata,...t.metadata};if(t.skip)return e}}catch(t){console.error(`Error in plugin "${r.name}" onError hook:`,t)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort((e,r)=>(e.priority??100)-(r.priority??100))}async runHooks(e,r){let t={...r};for(let s of this.sortedPlugins){let o=s[e];if(o)try{let n=await o(t);if(n){if(n.template!==void 0)t.template=n.template;if(n.context)t.context={...t.context,...n.context};if(n.metadata)t.metadata={...t.metadata,...n.metadata};if(n.skip)break}}catch(n){console.error(`Error in plugin "${s.name}" ${e} hook:`,n)}}return t}async runDirectiveHooks(e,r,t){let s={...t};for(let o of this.sortedPlugins){let n=o[e];if(n)try{let i=await n(r,s);if(i){if(i.template!==void 0)s.template=i.template;if(i.context)s.context={...s.context,...i.context};if(i.metadata)s.metadata={...s.metadata,...i.metadata};if(i.skip)break}}catch(i){console.error(`Error in plugin "${o.name}" ${e} hook:`,i)}}return s}}var u=new c;function l(e,r,t={}){return{name:e,...t,registerDirectives:()=>r}}function g(e,r,t={}){return{name:e,...t,registerFilters:()=>r}}var f=a({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess(e){console.log("[stx-debug] beforeProcess:",e.filePath)},afterParse(e){console.log("[stx-debug] afterParse:",e.template.length,"chars")},beforeDirective(e,r){console.log("[stx-debug] beforeDirective:",e)},afterDirective(e,r){console.log("[stx-debug] afterDirective:",e)},beforeRender(e){console.log("[stx-debug] beforeRender")},afterRender(e){console.log("[stx-debug] afterRender:",e.template.length,"chars")},onError(e){console.error("[stx-debug] onError:",e.error.message,"in phase:",e.phase)}}),d=a({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess(e){e.metadata.startTime=performance.now()},afterRender(e){let r=e.metadata.startTime;if(r){let t=performance.now()-r;console.log(`[stx-timing] Processing took ${t.toFixed(2)}ms`)}}});function p(e){return a({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(r){return{context:{...r.context,...e}}}})}
|
|
3
|
+
export{a as Qu,c as Ru,u as Su,l as Tu,g as Uu,f as Vu,d as Wu,p as Xu};
|