@stacksjs/stx 0.2.824 → 0.2.826
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-vvvaf66t.js → chunk-0scyzg9r.js} +3 -1
- package/dist/chunk-19gk9k01.js +2 -0
- package/dist/{chunk-x4pzwbns.js → chunk-1d67wtj4.js} +1 -1
- package/dist/{chunk-kqbkvfmg.js → chunk-21syn2j5.js} +1 -1
- package/dist/{chunk-fr1585t7.js → chunk-2c5bwrnh.js} +1 -1
- package/dist/{chunk-skh6pwy7.js → chunk-2fwssv2z.js} +1 -1
- package/dist/chunk-2v3r330m.js +3 -0
- package/dist/{chunk-hgwkrd4d.js → chunk-2vk7dtvs.js} +1 -1
- package/dist/{chunk-ejr5k9np.js → chunk-4amybnpc.js} +1 -1
- package/dist/{chunk-5rxd1r60.js → chunk-4qhz8q0d.js} +1 -1
- package/dist/{chunk-281eg1pf.js → chunk-4zjxj8ex.js} +1 -1
- package/dist/chunk-58e92xts.js +2 -0
- package/dist/{chunk-ccvcq9ve.js → chunk-82v1egn6.js} +1 -1
- package/dist/{chunk-phs7n6tk.js → chunk-897gqcby.js} +1 -1
- package/dist/{chunk-nx6kvnhw.js → chunk-8p86mpfv.js} +1 -1
- package/dist/{chunk-8nb1z4af.js → chunk-8qy616yt.js} +1 -1
- package/dist/{chunk-a2xy4z6q.js → chunk-8ycrmsba.js} +1 -1
- package/dist/{chunk-36ga0q0r.js → chunk-928y0wer.js} +6 -6
- package/dist/{chunk-9r0cx3k4.js → chunk-9kj5p5jq.js} +1 -1
- package/dist/{chunk-d6jcyxad.js → chunk-9z9c025j.js} +1 -1
- package/dist/{chunk-n2zger20.js → chunk-b64y3yh0.js} +1 -1
- package/dist/{chunk-0vtdhckb.js → chunk-bq7cfqk3.js} +1 -1
- package/dist/{chunk-56brw839.js → chunk-bwsz6sv4.js} +1 -1
- package/dist/{chunk-97d46jvh.js → chunk-cgtpbr01.js} +5 -5
- package/dist/{chunk-k5s6ngaf.js → chunk-cmf6ar8v.js} +2 -2
- package/dist/chunk-d0jcw9h6.js +2 -0
- package/dist/{chunk-w992as39.js → chunk-d9yjpdyn.js} +4 -4
- package/dist/{chunk-kfvbd9c9.js → chunk-e648sx8w.js} +1 -1
- package/dist/chunk-erf2g5b2.js +2 -0
- package/dist/{chunk-zxnfpy6r.js → chunk-exke928x.js} +1 -1
- package/dist/{chunk-z73wddy9.js → chunk-eycaj8mk.js} +1 -1
- package/dist/{chunk-kgjtq6fb.js → chunk-f05tmz4z.js} +2 -2
- package/dist/{chunk-3smq9j5a.js → chunk-fwk0gjbq.js} +1 -1
- package/dist/{chunk-jntc0v38.js → chunk-g25rz48g.js} +1 -1
- package/dist/{chunk-jbv8197c.js → chunk-gnt36wgk.js} +1 -1
- package/dist/{chunk-jkyw0xmt.js → chunk-h864en4b.js} +1 -1
- package/dist/{chunk-12g7me4m.js → chunk-he5njpsd.js} +1 -1
- package/dist/{chunk-jy0tvbtg.js → chunk-hhats9b3.js} +1 -1
- package/dist/{chunk-xjtm9gde.js → chunk-htdbm0sd.js} +1 -1
- package/dist/chunk-jzc3rw49.js +2 -0
- package/dist/{chunk-0hs4nee7.js → chunk-kep17bvj.js} +1 -1
- package/dist/{chunk-7vvhdrby.js → chunk-kfn7g24h.js} +1 -1
- package/dist/{chunk-akd4f3pg.js → chunk-kq5k2qbz.js} +1 -1
- package/dist/chunk-ksxtrmy2.js +2 -0
- package/dist/{chunk-cqq026d3.js → chunk-mfc5d181.js} +1 -1
- package/dist/{chunk-01d9sd40.js → chunk-mfy2ayv0.js} +1 -1
- package/dist/{chunk-aq5xxevm.js → chunk-p1sfwzmb.js} +1 -1
- package/dist/chunk-p9dma8k0.js +2 -0
- package/dist/{chunk-ct4qnbtn.js → chunk-pby6dxnc.js} +1 -1
- package/dist/chunk-q2ynwst2.js +2 -0
- package/dist/{chunk-9cpg01sv.js → chunk-q45xwvf6.js} +1 -1
- package/dist/{chunk-qsdwmymw.js → chunk-qp7dajd2.js} +1 -1
- package/dist/{chunk-n5kg8njw.js → chunk-rptnx3s6.js} +2 -2
- package/dist/{chunk-h1djr7rt.js → chunk-s8b6re34.js} +1 -1
- package/dist/{chunk-q5vej1ft.js → chunk-sk0tmtd3.js} +4 -4
- package/dist/{chunk-c9dywwkx.js → chunk-t9vwggkw.js} +3 -3
- package/dist/{chunk-wfh3g5w4.js → chunk-tgk2hcxv.js} +2 -2
- package/dist/{chunk-t9hrbrw0.js → chunk-tjhcrj3z.js} +4 -4
- package/dist/chunk-v2ps4gnx.js +2 -0
- package/dist/{chunk-zb3g4qvd.js → chunk-vwtejkb5.js} +27 -27
- package/dist/{chunk-pxm90y95.js → chunk-w45njn1r.js} +1 -1
- package/dist/chunk-x5r1cty7.js +2 -0
- package/dist/{chunk-caz5a61p.js → chunk-x5vxkypk.js} +1 -1
- package/dist/{chunk-nfzm71pr.js → chunk-x6863pzd.js} +2 -2
- package/dist/{chunk-w01f9n4r.js → chunk-y2bf32vg.js} +2 -2
- package/dist/{chunk-dd74gjmv.js → chunk-zd3dsp6p.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/client/signals-component-props-runtime.js +3 -1
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/process.js +8 -0
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-4ka2g6bp.js +0 -2
- package/dist/chunk-88th2wz6.js +0 -2
- package/dist/chunk-9cp6whxd.js +0 -2
- package/dist/chunk-aqesy5ac.js +0 -2
- package/dist/chunk-cknd3nb7.js +0 -2
- package/dist/chunk-crxtxw1d.js +0 -2
- package/dist/chunk-ezm9jzz1.js +0 -2
- package/dist/chunk-f6dm5a98.js +0 -2
- package/dist/chunk-kd8w41p2.js +0 -3
- package/dist/chunk-stp2hgag.js +0 -2
- package/dist/chunk-y9ak2xcy.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{kn}from"./chunk-8ttmzcxb.js";import{W,y,It,Ot,_r,m,tl,wi,U,R}from"./chunk-
|
|
3
|
-
`}import O from"path";var Y="stx-page-head:",Z=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function Q(){let t=K()?"dev":"prod",r=v[t];if(r!==null)return r;try{let e=import.meta.require("./chunk-c1e45rtv.js"),s=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${s()}</script>`}catch{v[t]=""}return v[t]}async function ca(t,r){if(r===!1)return null;if(r&&typeof r==="string"){let s=O.resolve(t,r);if(await Bun.file(s).exists())return s;return null}let e=O.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function mo(t,r){try{let e=await Bun.file(t).text(),s=e,a=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(a)s=a[1].trim();let i=Qt(e),o=[...i.client.map((g)=>g.fullTag),...i.signals.map((g)=>g.fullTag)],c=[],l=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=l.exec(e))!==null)c.push(u[0]);let f=s;for(let g of i.server)f=f.replace(g.fullTag,"");for(let g of i.client)f=f.replace(g.fullTag,"");f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let p="<!--__STX_PAGE_SLOT__-->";if(f=f.replace(/<slot\s*\/>/gi,p).replace(/<slot\s*>\s*<\/slot>/gi,p),!f.includes(p))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:h,extractVariables:S,defaultConfig:w,loadStxConfig:b}=await import("./chunk-
|
|
2
|
+
import{kn}from"./chunk-8ttmzcxb.js";import{W,y,It,Ot,_r,m,tl,wi,U,R}from"./chunk-928y0wer.js";import{Qt}from"./chunk-bq7cfqk3.js";import{n}from"./chunk-2v3r330m.js";import{K}from"./chunk-wpendr22.js";var q=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function z(t){let r=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,s;while((s=e.exec(t))!==null)r.push({start:s.index,end:s.index+s[0].length});return r}function I(t,r){return r.some((e)=>t>=e.start&&t<e.end)}function G(t){let r=(t||"").trim();if(!r)return null;if(/[\s>+~,:]/.test(r))return null;let e={},s=r,a=s.match(/^[a-z][\w-]*/i);if(a)e.tag=a[0].toLowerCase(),s=s.slice(a[0].length);while(s.length>0){let i=s.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(i){if(e.attr=i[1],i[3]!==void 0&&i[3]!=="")e.attrValue=i[3];s=s.slice(i[0].length);continue}let o=s.match(/^#([\w-]+)/);if(o){e.id=o[1],s=s.slice(o[0].length);continue}let c=s.match(/^\.([\w-]+)/);if(c){e.className=c[1],s=s.slice(c[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function X(t,r){if(r.attr){if(!(r.attrValue===void 0?new RegExp(`\\b${r.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${r.attr}\\s*=\\s*(["'])\\s*${r.attrValue}\\s*\\1`,"i")).test(t))return!1}if(r.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${r.id}\\s*\\1`,"i").test(t))return!1}if(r.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(r.className))return!1}return!0}function P(t,r="main"){let e=G(r);if(!e)return null;let s=/<([a-z][\w-]*)\b([^>]*)>/gi,a=z(t),i;while((i=s.exec(t))!==null){if(I(i.index,a))continue;let o=i[1].toLowerCase(),c=i[2]||"";if(c.trimEnd().endsWith("/")||q.has(o))continue;if(e.tag&&e.tag!==o)continue;if(!X(c,e))continue;let l=i[0],u=i.index+l.length,f=new RegExp(`<(/?)${o}\\b([^>]*)>`,"gi");f.lastIndex=u;let p=1,h;while((h=f.exec(t))!==null){if(I(h.index,a))continue;let S=h[1]==="/";if(!S&&(h[2]||"").trimEnd().endsWith("/"))continue;if(p+=S?-1:1,p===0)return{openTag:l,openIndex:i.index,start:u,end:h.index,tagName:o}}return null}return null}var ft="private, no-store";function An(t){return t.replace(/&#(\d+);/g,(r,e)=>N(Number(e),r)).replace(/&#x([0-9a-f]+);/gi,(r,e)=>N(Number.parseInt(e,16),r)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function N(t,r){if(!Number.isInteger(t)||t<0||t>1114111)return r;try{return String.fromCodePoint(t)}catch{return r}}function Ce(t){return t.headers.get("X-STX-Router")==="true"}function J(t,r){if(!t)return r;return t.split(",").some((s)=>s.trim().toLowerCase()===r.toLowerCase())?t:`${t}, ${r}`}function L(t){return{Vary:J(t,"X-STX-Router")}}function k(t){return t.replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Pn(t){let r=/<head\b[^>]*>([\s\S]*?)<\/head\s*>/i.exec(t)?.[1]??"",e=/<(meta|link)\b(?:[^>"']|"[^"]*"|'[^']*')*>|<title\b[^>]*>[\s\S]*?<\/title\s*>/giy,s=y(r,(i,o)=>(e.lastIndex=o,e.exec(i)?e.lastIndex:-1)),a=[];for(let{token:i}of s){if(/^<title\b/i.test(i)){a.push(`<title>${k(i.replace(/^<title\b[^>]*>|<\/title\s*>$/gi,""))}</title>`);continue}let o=Object.create(null),c=i.replace(/^<\w+\b|>$/g,"");for(let l of c.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let u=l[1].toLowerCase();if(!(u in o))o[u]=l[2]??l[3]??l[4]??""}if(/^<meta\b/i.test(i)){let l=o.property?"property":"name",u=An(o[l]??"").toLowerCase();if(u==="description"||/^(?:og|twitter):[\w:]+$/.test(u))a.push(`<meta ${l}="${n(u)}" content="${k(o.content??"")}">`)}else{let l=An(o.rel??"").toLowerCase();if(l==="canonical"||l==="alternate"&&o.hreflang)a.push(`<link rel="${l}" href="${k(o.href??"")}"${l==="alternate"?` hreflang="${k(o.hreflang)}"`:""}>`)}}return`<template data-stx-page-head="1">${a.join("")}</template>
|
|
3
|
+
`}import O from"path";var Y="stx-page-head:",Z=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function Q(){let t=K()?"dev":"prod",r=v[t];if(r!==null)return r;try{let e=import.meta.require("./chunk-c1e45rtv.js"),s=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${s()}</script>`}catch{v[t]=""}return v[t]}async function ca(t,r){if(r===!1)return null;if(r&&typeof r==="string"){let s=O.resolve(t,r);if(await Bun.file(s).exists())return s;return null}let e=O.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function mo(t,r){try{let e=await Bun.file(t).text(),s=e,a=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(a)s=a[1].trim();let i=Qt(e),o=[...i.client.map((g)=>g.fullTag),...i.signals.map((g)=>g.fullTag)],c=[],l=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=l.exec(e))!==null)c.push(u[0]);let f=s;for(let g of i.server)f=f.replace(g.fullTag,"");for(let g of i.client)f=f.replace(g.fullTag,"");f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let p="<!--__STX_PAGE_SLOT__-->";if(f=f.replace(/<slot\s*\/>/gi,p).replace(/<slot\s*>\s*<\/slot>/gi,p),!f.includes(p))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:h,extractVariables:S,defaultConfig:w,loadStxConfig:b}=await import("./chunk-jzc3rw49.js"),E=await b(),d={__filename:t,__dirname:O.dirname(t)};for(let g of o){let A=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(A&&!g.includes("client")&&!g.includes('type="module"'))await S(A[1],d,t)}let x=await h(f,d,t,{...w,...E,...r},new Set),C=x.indexOf(p);if(C===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:x.substring(0,C),afterSlot:x.substring(C+p.length),filePath:t,shellScripts:o,shellStyles:c}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function qr(t,r,e){let s,a="",i=r.match(Z);if(i){r=r.replace(i[0],"");try{let f=Buffer.from(i[1],"base64").toString("utf8"),p=f.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(p)s=p[1].trim();a=f.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let o=e||s||"stx App",c=Q(),l="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -28,5 +28,5 @@ ${c}
|
|
|
28
28
|
`));if(i.length>0)d.push(i.filter((x)=>!u.has(x)).join(`
|
|
29
29
|
`));if(w.length>0)d.push(w.filter((x)=>!u.has(x)).join(`
|
|
30
30
|
`));return d.push(S),d.join(`
|
|
31
|
-
`)}import T from"fs";import H from"path";function ua(t,r,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:r,outputDir:e}}function da(t,r){let e=H.join(r,"manifest.json");T.writeFileSync(e,JSON.stringify(t,null,2))}function pa(t){let r=H.join(t,"manifest.json");if(!T.existsSync(r))return null;try{let e=T.readFileSync(r,"utf-8"),s=JSON.parse(e);if(s.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${s.version}`),null;return s}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function M(t,r,e={}){let s=`${encodeURIComponent(t)}=${encodeURIComponent(r)}`;if(e.maxAge!==void 0)s+=`; Max-Age=${e.maxAge}`;if(e.expires)s+=`; Expires=${e.expires.toUTCString()}`;if(e.path)s+=`; Path=${e.path}`;if(e.domain)s+=`; Domain=${e.domain}`;if(e.secure)s+="; Secure";if(e.httpOnly)s+="; HttpOnly";if(e.sameSite)s+=`; SameSite=${e.sameSite}`;return s}async function et(t){let r=t.headers.get("content-type")||"",e={},s=(a,i)=>{let o=e[a];if(o===void 0)e[a]=i;else if(Array.isArray(o))o.push(i);else e[a]=[o,i]};if(r.includes("multipart/form-data")){let a=await t.formData();for(let[i,o]of a.entries())if(typeof o==="string")s(i,o);return e}if(r.includes("application/x-www-form-urlencoded")){for(let[a,i]of new URLSearchParams(await t.text()).entries())s(a,i);return e}return e}function ho(t){if(!t)return!1;let r=t.toUpperCase();return r!=="GET"&&r!=="HEAD"}async function V(t,r={}){let e=r.request,s=r.method??e?.method;if(!e||!ho(s))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let a={};try{a=await et(e)}catch{}let i=await t.action({request:e,form:a,params:r.params??{},query:t.query??{},cookies:r.cookies??{}});if(i&&typeof i==="object"){let o=i,c=nt(o.cookies),l=o.redirect;if(typeof l==="string"&&l)return{redirect:l,ran:!0,...c.length>0?{cookies:c}:{}};let{cookies:u,redirect:f,...p}=o;if(Object.assign(t,p),c.length>0)return{ran:!0,cookies:c}}return{ran:!0}}function nt(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let r=[];for(let[e,s]of Object.entries(t)){if(!e)continue;if(typeof s==="string"){r.push(M(e,s));continue}if(s&&typeof s==="object"){let a=s;if(typeof a.value!=="string")continue;r.push(M(e,a.value,a))}}return r}function fa(t,r=[],e){let s=new Headers({Location:t,"Cache-Control":"no-store"});for(let a of r)s.append("Set-Cookie",a);for(let[a,i]of Object.entries(e??{}))if(a.toLowerCase()!=="location")s.set(a,i);return new Response(null,{status:303,headers:s})}async function In(t,r={}){let{html:e,context:s,redirect:a,cookies:i}=await rt(t,r),o=It(s),c=Ot(s);if(a)return{html:e,redirect:a,cookies:i,status:o,headers:c};let{extractStreamBoundaries:l}=await import("./chunk-
|
|
31
|
+
`)}import T from"fs";import H from"path";function ua(t,r,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:r,outputDir:e}}function da(t,r){let e=H.join(r,"manifest.json");T.writeFileSync(e,JSON.stringify(t,null,2))}function pa(t){let r=H.join(t,"manifest.json");if(!T.existsSync(r))return null;try{let e=T.readFileSync(r,"utf-8"),s=JSON.parse(e);if(s.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${s.version}`),null;return s}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function M(t,r,e={}){let s=`${encodeURIComponent(t)}=${encodeURIComponent(r)}`;if(e.maxAge!==void 0)s+=`; Max-Age=${e.maxAge}`;if(e.expires)s+=`; Expires=${e.expires.toUTCString()}`;if(e.path)s+=`; Path=${e.path}`;if(e.domain)s+=`; Domain=${e.domain}`;if(e.secure)s+="; Secure";if(e.httpOnly)s+="; HttpOnly";if(e.sameSite)s+=`; SameSite=${e.sameSite}`;return s}async function et(t){let r=t.headers.get("content-type")||"",e={},s=(a,i)=>{let o=e[a];if(o===void 0)e[a]=i;else if(Array.isArray(o))o.push(i);else e[a]=[o,i]};if(r.includes("multipart/form-data")){let a=await t.formData();for(let[i,o]of a.entries())if(typeof o==="string")s(i,o);return e}if(r.includes("application/x-www-form-urlencoded")){for(let[a,i]of new URLSearchParams(await t.text()).entries())s(a,i);return e}return e}function ho(t){if(!t)return!1;let r=t.toUpperCase();return r!=="GET"&&r!=="HEAD"}async function V(t,r={}){let e=r.request,s=r.method??e?.method;if(!e||!ho(s))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let a={};try{a=await et(e)}catch{}let i=await t.action({request:e,form:a,params:r.params??{},query:t.query??{},cookies:r.cookies??{}});if(i&&typeof i==="object"){let o=i,c=nt(o.cookies),l=o.redirect;if(typeof l==="string"&&l)return{redirect:l,ran:!0,...c.length>0?{cookies:c}:{}};let{cookies:u,redirect:f,...p}=o;if(Object.assign(t,p),c.length>0)return{ran:!0,cookies:c}}return{ran:!0}}function nt(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let r=[];for(let[e,s]of Object.entries(t)){if(!e)continue;if(typeof s==="string"){r.push(M(e,s));continue}if(s&&typeof s==="object"){let a=s;if(typeof a.value!=="string")continue;r.push(M(e,a.value,a))}}return r}function fa(t,r=[],e){let s=new Headers({Location:t,"Cache-Control":"no-store"});for(let a of r)s.append("Set-Cookie",a);for(let[a,i]of Object.entries(e??{}))if(a.toLowerCase()!=="location")s.set(a,i);return new Response(null,{status:303,headers:s})}async function In(t,r={}){let{html:e,context:s,redirect:a,cookies:i}=await rt(t,r),o=It(s),c=Ot(s);if(a)return{html:e,redirect:a,cookies:i,status:o,headers:c};let{extractStreamBoundaries:l}=await import("./chunk-9z9c025j.js"),u=l(s),f=t.streamTemplates;if(f&&Object.keys(f).length>0){let{processDirectives:p}=await import("./chunk-x5r1cty7.js"),{defaultConfig:h}=await import("./chunk-kfn7g24h.js"),S=s.streamBoundaries||{},w={...h,autoShell:!1},b=Object.keys(f).map((d)=>({id:d,render:async()=>{let x=typeof S[d]==="function"?await S[d]():void 0;return p(f[d],{...s,$boundary:x},t.sourceFile,w,new Set)}})),E=new Set(b.map((d)=>d.id));u=[...(u||[]).filter((d)=>!E.has(d.id)),...b]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:i,status:o,headers:c}}async function rt(t,r){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...r};if(!t.hasServerScripts&&!wi(t.html))return{html:t.html,context:e};for(let o of t.serverScriptContent)try{await m(o,e,t.sourceFile)}catch(c){if(r.__stx_strict_hydration)throw c;console.warn(`[stx] Server script error in ${t.sourceFile}:`,c)}let s=await V(e,{request:r.request,method:r.method,params:r.params??{},cookies:r.cookies??{}}),a=(o)=>{let c=o.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),l=_r(e);if(!l)return c;let u=c.indexOf("</head>");return u<0?l+c:c.slice(0,u)+l+c.slice(u)};if(s.redirect)return{html:t.html,context:e,redirect:s.redirect,cookies:s.cookies};if(!wi(t.html))return{html:a(t.html),context:e,cookies:s.cookies};let i=new Map;for(let[o,c]of Object.entries(t.placeholders))if(c.expression)try{let l=R(c.expression,e);if(c.type==="raw")i.set(o,l!==void 0&&l!==null?String(l):"");else i.set(o,l!==void 0&&l!==null?U(String(l)):"")}catch(l){if(r.__stx_strict_hydration)throw l;i.set(o,"")}return{html:a(tl(t.html,i)),context:e,cookies:s.cookies}}
|
|
32
32
|
export{ft,An,Ce,L,Pn,ca,mo,qr,We,la,qe,Ee,ua,da,pa,ho,fa,In};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-bt0amey5.js";import"./chunk-r9e0r6jx.js";import"./chunk-8ttmzcxb.js";import{m}from"./chunk-
|
|
2
|
+
import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-bt0amey5.js";import"./chunk-r9e0r6jx.js";import"./chunk-8ttmzcxb.js";import{m}from"./chunk-928y0wer.js";import"./chunk-2vqpz4qv.js";import"./chunk-e648sx8w.js";import{Vt,no,Ut,Ui,ct,Wi,ro,Wt,Ki,qt}from"./chunk-q7zwv88b.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Wi("Config file changed, restarting...");try{await e.onChange()}catch(p){ct(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",pt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:pt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:mt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function mt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -556,7 +556,7 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-x5r1cty7.js"),p={},g=h(n);if(g)try{await m(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await m(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-x5r1cty7.js"),c={...r},n=h(e);if(n)try{await m(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
561
|
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await Wt(t);ut(t,r);let s=qt(t.config,r);dt(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=Ki(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let u=await Wt(t);ut(t,u);let f=qt(t.config,u);if(dt(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=g;try{let{exec:l}=await import("child_process"),u=process.platform;l(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:g,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],g=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((u)=>u.id===p);if(!l)return new Response("Story not found",{status:404});try{let u=await Y(t,l,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((g)=>g.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{T,u,f,A,d,q}from"./chunk-8ttmzcxb.js";import{H,Ps,Oe,de,kr,je,Be,s,h,Se,_}from"./chunk-
|
|
2
|
+
import{T,u,f,A,d,q}from"./chunk-8ttmzcxb.js";import{H,Ps,Oe,de,kr,je,Be,s,h,Se,_}from"./chunk-928y0wer.js";import{at}from"./chunk-bt0amey5.js";import{P}from"./chunk-r9e0r6jx.js";import{se}from"./chunk-wceg59n0.js";import{j,Ye}from"./chunk-cmnze7at.js";import{E,_n}from"./chunk-wpendr22.js";import C from"path";import{existsSync as St}from"fs";function ct(a,t){let c=0;for(let i=t;i<a.length;i++){let S=a[i];if(S==="("||S==="["||S==="{")c++;else if(S===")"||S==="]"||S==="}")c--;else if(S===","&&c===0)return i}return-1}function yt(a,t,c){let i=a,S=new RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),n=S.exec(i);while(n){let g=n.index,e=g+n[0].length-1,D=1,U=e+1;while(U<i.length&&D>0){if(i[U]==="(")D++;else if(i[U]===")")D--;U++}if(D!==0)break;let rt=i.substring(e+1,U-1),N=`${c}(${rt})`;i=i.substring(0,g)+N+i.substring(U),S.lastIndex=g+N.length,n=S.exec(i)}return i}function $t(a){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(a)}function mt(a){let t=a,c=[],i=new Set,S=0,n=0,g=t.length,e=(N)=>{n++;while(n<g){if(t[n]==="\\"){n+=2;continue}if(t[n]===N){n++;return}n++}},D=()=>{n++;while(n<g){if(t[n]==="\\"){n+=2;continue}if(t[n]==="`"){n++;return}if(t[n]==="$"&&t[n+1]==="{"){n+=2;let N=1;while(n<g&&N>0)if(t[n]==="{")N++,n++;else if(t[n]==="}")N--,n++;else if(t[n]==="'"||t[n]==='"')e(t[n]);else if(t[n]==="`")D();else n++;continue}n++}},U=()=>{if(t[n]==="/"&&t[n+1]==="/"){while(n<g&&t[n]!==`
|
|
3
3
|
`)n++;return!0}if(t[n]==="/"&&t[n+1]==="*"){n+=2;while(n<g-1&&!(t[n]==="*"&&t[n+1]==="/"))n++;return n+=2,!0}return!1},rt=()=>{if(S!==0)return;let N=t.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(N){let Z=N[2];if(!i.has(Z))c.push(Z),i.add(Z);return}let et=t.slice(n).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(et){let Z=et[1];if(!i.has(Z))c.push(Z),i.add(Z);return}let Y=t.slice(n).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let Z=Y[1];if(!i.has(Z))c.push(Z),i.add(Z)}};while(n<g){if(U())continue;if(t[n]==="'"||t[n]==='"'){e(t[n]);continue}if(t[n]==="`"){D();continue}if(t[n]==="{"){S++,n++;continue}if(t[n]==="}"){S--,n++;continue}if(S===0&&/[a-z]/i.test(t[n])&&(n===0||/\s|[;{}()]/.test(t[n-1])))rt();n++}return c.join(", ")}function Et(a,t=""){let c=mt(a).split(",").map((i)=>i.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${at("var",c)}
|
|
@@ -44,10 +44,10 @@ ${n}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return c+a+i}function It(a,t){if(j(a)){let S=j(a).tag.match(/data-stx-scope="([^"]*)"/);if(S)return{html:a,mergedIntoExisting:S[1],stamped:!0,root:"body"};return{html:Ye(a,(n,g)=>`<body${g} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],S=c[2].slice(1),n=i.match(/data-stx-scope="([^"]*)"/);if(n)return{html:a,mergedIntoExisting:n[1],stamped:!0,root:S};let g=c[1],e=c[2],D=c[3];return{html:`${g}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:S}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=C.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function Ah(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Of(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],S=0,n=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,g;while((g=n.exec(c))!==null){let e=g[1]==="/",D=g[2],U=g[3]==="/"||Tt.has(D.toLowerCase());if(e){S=Math.max(0,S-1);continue}if(S===0)i.push(D);if(!U)S++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var Je=new T(500),ac=new Set;function Ph(){ac.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return ac}async function is(a,t,c,i,S,n=new Set){let g=i.partialsDir||C.join(C.dirname(c),"partials");if(g&&!C.isAbsolute(g))g=C.resolve(process.cwd(),g);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(m,k,x)=>{let p=k.trim(),r=`${c}:${p}`;if(D.has(r))return"";return D.add(r),k});{let m=/@includeIf\s*\(/g,k;while((k=m.exec(e))!==null){let x=k.index,p=x+k[0].length-1,r=1,w=p+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")")r--;w++}if(r!==0)break;let l=e.substring(p+1,w-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){m.lastIndex=w;continue}let O=o[1],W=U(O,g,c),R="";if(W&&await Bun.file(W).exists())S.add(W),R=`@include(${l})`;e=e.substring(0,x)+R+e.substring(w),m.lastIndex=0}}for(let[m,k]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),p;while((p=x.exec(e))!==null){let r=p.index,w=r+p[0].length-1,l=1,o=w+1;while(o<e.length&&l>0){if(e[o]==="(")l++;else if(e[o]===")")l--;o++}if(l!==0)break;let O=e.substring(w+1,o-1),W=ct(O,0);if(W===-1){x.lastIndex=o;continue}let R=O.substring(0,W).trim(),V=O.substring(W+1).trim(),z=V.match(/^\s*['"]([^'"]+)['"]/);if(!z){x.lastIndex=o;continue}let b=z[1],J=V.substring(z[0].length),B,I=ct(J,0);if(I!==-1)B=J.substring(I+1).trim();try{let M=`Boolean(${R})`,L;if(f(M)){let it=d(M,Object.keys(t));L=Boolean(it(...Object.values(t)))}else L=Boolean(u(M,t));let tt=k?!L:L,nt="";if(tt){let it=U(b,g,c);if(it&&await Bun.file(it).exists())S.add(it);nt=`@include('${b}'${B?`, ${B}`:""})`}e=e.substring(0,r)+nt+e.substring(o),x.lastIndex=0}catch(M){let L=M instanceof Error?M.message:String(M),tt=h("Include",`Error evaluating ${m} condition: ${L}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),x.lastIndex=0}}}{let m=/@each\s*\(/g,k;while((k=m.exec(e))!==null){let x=k.index,p=x+k[0].length-1,r=1,w=p+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let l=e.substring(p+1,w),o=e.substring(x,w+1),O=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){m.lastIndex=0,e=e.replace(o,"");continue}let[,W,R,V,z]=O;try{let b,J=R.trim();if(f(J))b=d(J,Object.keys(t))(...Object.values(t));else b=u(J,t);let B="";if(Array.isArray(b)&&b.length>0)for(let I of b){let M={...t,[V]:I},L=await et(W,M,a,x);B+=L}else if(z)B=await et(z,{},a,x);e=e.substring(0,x)+B+e.substring(w+1),m.lastIndex=0}catch(b){let J=b instanceof Error?b.message:String(b);e=e.substring(0,x)+h("Each",`Error in @each: ${J}`,c,a,x)+e.substring(w+1),m.lastIndex=0}}}{let m=/@includeFirst\s*\(/g,k;while((k=m.exec(e))!==null){let x=k.index,p=x+k[0].length-1,r=1,w=p+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let l=e.substring(p+1,w),o=e.substring(x,w+1),O=l.match(/^\s*(\[[^\]]+\])/);if(!O){m.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],R=l.slice(O[0].length),V,z=R.match(/^\s*,\s*\{/);if(z){R=R.slice(z[0].length-1);let B=1,I=1;while(I<R.length&&B>0){if(R[I]==="{")B++;else if(R[I]==="}"){if(B--,B===0)break}I++}V=R.substring(0,I+1),R=R.slice(I+1)}let b,J=R.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)b=J[1];try{let B=JSON.parse(W.replace(/'/g,'"')),I={};if(V)try{I=A(V,t)}catch(L){let tt=L instanceof Error?L.message:String(L);if(i.debug){let nt=h("Include",`Error parsing includeFirst variables: ${tt}`,c,a,x,o);e=e.replace(o,()=>nt)}else e=e.replace(o,()=>b||"");continue}let M=!1;for(let L of B){let tt=U(L,g,c);if(!tt)continue;if(await s(tt)){let nt=await et(L,I,a,x);e=e.replace(o,()=>nt),M=!0;break}}if(!M)if(b!==void 0)e=e.replace(o,()=>b);else if(i.debug){let L=h("Include",`None of the includeFirst paths exist: ${W}`,c,a,x,o);e=e.replace(o,()=>L)}else e=e.replace(o,"")}catch(B){let I=B instanceof Error?B.message:String(B),M=h("Include",`Error processing @includeFirst: ${I}`,c,a,x,o);e=e.replace(o,()=>M)}m.lastIndex=0}}function U(m,k,x){try{let p=m;if(!m.endsWith(".stx"))p=`${m}.stx`;let r=C.resolve(k),w=C.resolve(C.dirname(x)),l;if(!p.startsWith("./")&&!p.startsWith("../")){for(let z of i._layerPartialDirs??[]){let b=C.resolve(z,p);if(b.startsWith(`${C.resolve(z)}${C.sep}`)&&St(b))return b}l=C.resolve(k,p)}else l=C.resolve(w,p);let o=C.normalize(l),O=o.startsWith(r+C.sep)||o===r,W=o.startsWith(w+C.sep)||o===w,R=!1,V=C.dirname(w);if(o.startsWith(V+C.sep)){if(!C.relative(V,o).split(C.sep).some((B)=>B.startsWith(".")&&B!=="."&&B!==".."))R=!0}if(!O&&!W&&!R)return console.error(`Security: Path traversal attempt blocked for include path: ${m}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${w}`),null;return o}catch(p){return console.error(`Error resolving path ${m}: ${p}`),null}}let rt=C.resolve(c);n.add(rt);function N(m,k,x,p){return i.onIncludeError?.({includePath:m,templatePath:c,message:k,partialsDir:g}),h("Include",k,c,x,p)}async function et(m,k={},x,p){let r=U(m,g,c);if(!r)return N(m,`Could not resolve path for include: ${m}`,x,p);let w=C.resolve(r);if(n.has(w)){let l=[...n,w].map((o)=>C.basename(o)).join(" -> ");return N(m,`Circular include detected: ${l}`,x,p)}try{S.add(r);let l;if(!l)try{l=await Bun.file(r).text()}catch(v){let K=v instanceof Error?v.message:String(v);return N(m,`Error loading include file ${m}: ${K}`,x,p)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:v}=await import("./chunk-
|
|
47
|
+
})();`;return c+a+i}function It(a,t){if(j(a)){let S=j(a).tag.match(/data-stx-scope="([^"]*)"/);if(S)return{html:a,mergedIntoExisting:S[1],stamped:!0,root:"body"};return{html:Ye(a,(n,g)=>`<body${g} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],S=c[2].slice(1),n=i.match(/data-stx-scope="([^"]*)"/);if(n)return{html:a,mergedIntoExisting:n[1],stamped:!0,root:S};let g=c[1],e=c[2],D=c[3];return{html:`${g}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:S}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=C.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function Ah(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Of(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],S=0,n=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,g;while((g=n.exec(c))!==null){let e=g[1]==="/",D=g[2],U=g[3]==="/"||Tt.has(D.toLowerCase());if(e){S=Math.max(0,S-1);continue}if(S===0)i.push(D);if(!U)S++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var Je=new T(500),ac=new Set;function Ph(){ac.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return ac}async function is(a,t,c,i,S,n=new Set){let g=i.partialsDir||C.join(C.dirname(c),"partials");if(g&&!C.isAbsolute(g))g=C.resolve(process.cwd(),g);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(m,k,x)=>{let p=k.trim(),r=`${c}:${p}`;if(D.has(r))return"";return D.add(r),k});{let m=/@includeIf\s*\(/g,k;while((k=m.exec(e))!==null){let x=k.index,p=x+k[0].length-1,r=1,w=p+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")")r--;w++}if(r!==0)break;let l=e.substring(p+1,w-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){m.lastIndex=w;continue}let O=o[1],W=U(O,g,c),R="";if(W&&await Bun.file(W).exists())S.add(W),R=`@include(${l})`;e=e.substring(0,x)+R+e.substring(w),m.lastIndex=0}}for(let[m,k]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),p;while((p=x.exec(e))!==null){let r=p.index,w=r+p[0].length-1,l=1,o=w+1;while(o<e.length&&l>0){if(e[o]==="(")l++;else if(e[o]===")")l--;o++}if(l!==0)break;let O=e.substring(w+1,o-1),W=ct(O,0);if(W===-1){x.lastIndex=o;continue}let R=O.substring(0,W).trim(),V=O.substring(W+1).trim(),z=V.match(/^\s*['"]([^'"]+)['"]/);if(!z){x.lastIndex=o;continue}let b=z[1],J=V.substring(z[0].length),B,I=ct(J,0);if(I!==-1)B=J.substring(I+1).trim();try{let M=`Boolean(${R})`,L;if(f(M)){let it=d(M,Object.keys(t));L=Boolean(it(...Object.values(t)))}else L=Boolean(u(M,t));let tt=k?!L:L,nt="";if(tt){let it=U(b,g,c);if(it&&await Bun.file(it).exists())S.add(it);nt=`@include('${b}'${B?`, ${B}`:""})`}e=e.substring(0,r)+nt+e.substring(o),x.lastIndex=0}catch(M){let L=M instanceof Error?M.message:String(M),tt=h("Include",`Error evaluating ${m} condition: ${L}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),x.lastIndex=0}}}{let m=/@each\s*\(/g,k;while((k=m.exec(e))!==null){let x=k.index,p=x+k[0].length-1,r=1,w=p+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let l=e.substring(p+1,w),o=e.substring(x,w+1),O=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){m.lastIndex=0,e=e.replace(o,"");continue}let[,W,R,V,z]=O;try{let b,J=R.trim();if(f(J))b=d(J,Object.keys(t))(...Object.values(t));else b=u(J,t);let B="";if(Array.isArray(b)&&b.length>0)for(let I of b){let M={...t,[V]:I},L=await et(W,M,a,x);B+=L}else if(z)B=await et(z,{},a,x);e=e.substring(0,x)+B+e.substring(w+1),m.lastIndex=0}catch(b){let J=b instanceof Error?b.message:String(b);e=e.substring(0,x)+h("Each",`Error in @each: ${J}`,c,a,x)+e.substring(w+1),m.lastIndex=0}}}{let m=/@includeFirst\s*\(/g,k;while((k=m.exec(e))!==null){let x=k.index,p=x+k[0].length-1,r=1,w=p+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let l=e.substring(p+1,w),o=e.substring(x,w+1),O=l.match(/^\s*(\[[^\]]+\])/);if(!O){m.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],R=l.slice(O[0].length),V,z=R.match(/^\s*,\s*\{/);if(z){R=R.slice(z[0].length-1);let B=1,I=1;while(I<R.length&&B>0){if(R[I]==="{")B++;else if(R[I]==="}"){if(B--,B===0)break}I++}V=R.substring(0,I+1),R=R.slice(I+1)}let b,J=R.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)b=J[1];try{let B=JSON.parse(W.replace(/'/g,'"')),I={};if(V)try{I=A(V,t)}catch(L){let tt=L instanceof Error?L.message:String(L);if(i.debug){let nt=h("Include",`Error parsing includeFirst variables: ${tt}`,c,a,x,o);e=e.replace(o,()=>nt)}else e=e.replace(o,()=>b||"");continue}let M=!1;for(let L of B){let tt=U(L,g,c);if(!tt)continue;if(await s(tt)){let nt=await et(L,I,a,x);e=e.replace(o,()=>nt),M=!0;break}}if(!M)if(b!==void 0)e=e.replace(o,()=>b);else if(i.debug){let L=h("Include",`None of the includeFirst paths exist: ${W}`,c,a,x,o);e=e.replace(o,()=>L)}else e=e.replace(o,"")}catch(B){let I=B instanceof Error?B.message:String(B),M=h("Include",`Error processing @includeFirst: ${I}`,c,a,x,o);e=e.replace(o,()=>M)}m.lastIndex=0}}function U(m,k,x){try{let p=m;if(!m.endsWith(".stx"))p=`${m}.stx`;let r=C.resolve(k),w=C.resolve(C.dirname(x)),l;if(!p.startsWith("./")&&!p.startsWith("../")){for(let z of i._layerPartialDirs??[]){let b=C.resolve(z,p);if(b.startsWith(`${C.resolve(z)}${C.sep}`)&&St(b))return b}l=C.resolve(k,p)}else l=C.resolve(w,p);let o=C.normalize(l),O=o.startsWith(r+C.sep)||o===r,W=o.startsWith(w+C.sep)||o===w,R=!1,V=C.dirname(w);if(o.startsWith(V+C.sep)){if(!C.relative(V,o).split(C.sep).some((B)=>B.startsWith(".")&&B!=="."&&B!==".."))R=!0}if(!O&&!W&&!R)return console.error(`Security: Path traversal attempt blocked for include path: ${m}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${w}`),null;return o}catch(p){return console.error(`Error resolving path ${m}: ${p}`),null}}let rt=C.resolve(c);n.add(rt);function N(m,k,x,p){return i.onIncludeError?.({includePath:m,templatePath:c,message:k,partialsDir:g}),h("Include",k,c,x,p)}async function et(m,k={},x,p){let r=U(m,g,c);if(!r)return N(m,`Could not resolve path for include: ${m}`,x,p);let w=C.resolve(r);if(n.has(w)){let l=[...n,w].map((o)=>C.basename(o)).join(" -> ");return N(m,`Circular include detected: ${l}`,x,p)}try{S.add(r);let l;if(!l)try{l=await Bun.file(r).text()}catch(v){let K=v instanceof Error?v.message:String(v);return N(m,`Error loading include file ${m}: ${K}`,x,p)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:v}=await import("./chunk-9z9c025j.js");l=v(l,t)}if(l&&(i.debug||!E()&&!_n()))try{let{warnUnbalancedTags:v}=await import("./chunk-kgn911k7.js");v(l,r)}catch{}try{let{processESImports:v}=await import("./chunk-2vk7dtvs.js");l=await v(l,t,r,i,S)}catch(v){if(i.debug)console.warn(`[stx] partial ES import extraction skipped for ${r}:`,v instanceof Error?v.message:v)}let o=l,O=de(o);if(O)o=O.content.trim();let R=l.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),V="";if(R)V=`<style${R[1]}>${R[2]}</style>`;let z=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(v,K,y)=>{if(!ft(K))return"";return z.push({attrs:K,body:y}),`__STX_DATA_BLOCK_${z.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let b={...t};b.__stx_signals_gate=Se(l,r);for(let[v,K]of Object.entries(k))b[v]=K;let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,B=[...l.matchAll(J)].sort((v,K)=>{let y=(v[1]||"").includes("server"),X=(K[1]||"").includes("server");return Number(X)-Number(y)}),I="",M=null,L=!1,tt=!1;for(let v of B){let K=v[1]||"",y=v[2]||"";if(ft(K))continue;let X=K.includes("server"),wt=je(K);if(!X&&!/\bsrc\s*=/i.test(K))Oe(y,r,i.strict);if(!X&&y.trim()){let{interpolateScriptExpressions:F}=await import("./chunk-mfc5d181.js");y=F(y,b,m)}let ot="";try{let{extractAndStripCssImports:F,renderVendorStyleTags:Q}=await import("./chunk-2c5bwrnh.js"),st=F(y,{filePath:r,projectRoot:process.cwd()});y=st.code,ot=Q(st.styles)}catch(F){if(i.debug)console.warn(`[stx] vendor-css extractor skipped for ${r}:`,F instanceof Error?F.message:F)}if(wt&&y.trim())y=Be(y);if(!X){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-2c5bwrnh.js");y=Q(y).code;let{hasUserImports:st,bundleClientScript:bt}=await import("./chunk-897gqcby.js");if(st(y))y=await bt(y,r,{projectRoot:process.cwd()})}catch(Q){if(i.debug)console.warn(`[stx] bundler skipped for ${r}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:F}=await import("./chunk-htdbm0sd.js");y=F(y)}let dt=$t(y);if(!X){let{extractBridgeData:F,generateServerDataBridge:Q}=await import("./chunk-2c5bwrnh.js"),st=Q(y,F(b));if(st)y=`${st}
|
|
48
48
|
${y}`}if(dt&&!X){L=!0,M=ut(r,t);let F=P(y),Q=gt(F,M);I+=`${ot}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}">${Q}</script>
|
|
49
|
-
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-
|
|
50
|
-
`}}if(z.length>0){let{interpolateScriptExpressions:v}=await import("./chunk-
|
|
49
|
+
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-exke928x.js");await F(y,b,r)}catch(F){if(i.debug)console.warn(`Warning: Could not extract variables from server script in ${r}:`,F)}if(!X&&!dt){let F=K.replace(/\bclient\b/i,"").trim();M=ut(r,t);let Q=P(y),st=gt(Q,M);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(st))tt=!0;I+=`${ot}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}"${F?` ${F}`:""}>${st}</script>
|
|
50
|
+
`}}if(z.length>0){let{interpolateScriptExpressions:v}=await import("./chunk-mfc5d181.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(K,y)=>{let X=z[Number(y)];return`<script${X.attrs}>${v(X.body,b,m)}</script>`})}if(M){let v=It(o,M);if(o=v.html,v.mergedIntoExisting){let y=M,X=v.mergedIntoExisting;I=I.split(`'${y}'`).join(`'${X}'`).split(`"${y}"`).join(`"${X}"`),M=X}else if(!v.stamped&&L&&!lt.has(r))lt.add(r),console.warn(`[stx] ${C.relative(process.cwd(),r)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(v.stamped&&v.root!=="body"&&(L||tt)&&!pt.has(r)){let y=Of(o);if(y.length>1)pt.add(r),console.warn(`[stx] ${C.relative(process.cwd(),r)} declares ${L?"signals":"bindings"} and has ${y.length} top-level elements (${y.map((X)=>`<${X}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let K=v.stamped&&v.root!==null&&kr(v.root);I=Rt(I,K?M:null)}if(o.includes("@include")||o.includes("@partial"))o=await is(o,b,r,i,S,n);let{processLoops:nt,reportDeferredLoopWarnings:it}=await import("./chunk-d0jcw9h6.js"),G=nt(o,b,r,void 0,!0);G=se(G,b,r),G=it(G);let{processMetaDirectives:ht,processSeoDirective:xt,processStructuredData:_t}=await import("./chunk-vafxrky2.js");if(G=ht(G,b,r,i),G=_t(G,b,r),G=xt(G,b,r,i),G=_(G,b,r),V)G+=`
|
|
51
51
|
`+V;if(I)G+=`
|
|
52
52
|
`+I;return G}catch(l){if(l instanceof q)throw l;let o=l instanceof Error?l.message:String(l);return N(m,`Error processing include ${m}: ${o}`,x,p)}}let Y=/@include\s*\(/g,Z;while((Z=Y.exec(e))!==null){let m=Z.index,k=m+Z[0].length-1,x=1,p=k+1;while(p<e.length&&x>0){if(e[p]==="(")x++;else if(e[p]===")")x--;p++}if(x!==0)break;let r=e.substring(m,p),w=e.substring(k+1,p-1),l=w.match(/^\s*['"]([^'"]+)['"]/);if(!l){Y.lastIndex=p;continue}let o=l[1],O,W=w.substring(l[0].length),R=ct(W,0);if(R!==-1)O=W.substring(R+1).trim();let V={};if(O)try{V=A(O,t)}catch(b){let J=b instanceof Error?b.message:String(b);e=e.replace(r,h("Include",`Error parsing include variables for ${o}: ${J}`,c,a,m)),Y.lastIndex=0;continue}let z=await et(o,V,a,m);e=e.substring(0,m)+z+e.substring(p),Y.lastIndex=0}return e}function as(a,t){let c=a;function i(S,n,g,e){let D=S,U=!0;while(U){U=!1;let rt=new RegExp(`@${n}\\(['"]([^'"]+)['"]\\)`),N=D.match(rt);if(!N||N.index===void 0)break;let et=N.index,Y=N[1],Z=et+N[0].length,m=new RegExp(`@${n}\\(`),k=new RegExp(`@${g}(?![a-z])`),x=1,p=Z,r=-1;while(x>0&&p<D.length){let l=D.slice(p),o=l.match(m),O=l.match(k),W=o?p+o.index:1/0,R=O?p+O.index:1/0;if(W<R)x++,p=W+(o[0].length||1);else if(R<1/0){if(x--,x===0){r=R;break}p=R+g.length+1}else break}if(r===-1)break;let w=D.slice(Z,r);if(!t[Y])t[Y]=[];if(e)t[Y].unshift(w);else t[Y].push(w);D=D.substring(0,et)+D.substring(r+`@${g}`.length),U=!0}return D}return c=i(c,"push","endpush",!1),c=i(c,"prepend","endprepend",!0),c}function cs(a,t){return a.replace(/@stack\(['"]([^'"]+)['"]\)/g,(c,i)=>{if(!t[i]||t[i].length===0)return"";return t[i].join(`
|
|
53
53
|
`)})}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{oh,bo,ih,ah,ch,lh}from"./chunk-g25rz48g.js";import"./chunk-9kj5p5jq.js";import"./chunk-bwsz6sv4.js";import"./chunk-7sh9fa3q.js";import"./chunk-f05tmz4z.js";import"./chunk-d9yjpdyn.js";import"./chunk-2nj9aewf.js";import"./chunk-rptnx3s6.js";import"./chunk-1d67wtj4.js";import"./chunk-k81trehg.js";import"./chunk-wf0n9gpj.js";import"./chunk-xpy9yjyx.js";import"./chunk-qj4r08jb.js";import"./chunk-928y0wer.js";import"./chunk-e648sx8w.js";import"./chunk-2vqpz4qv.js";import"./chunk-8ttmzcxb.js";import"./chunk-r9e0r6jx.js";import"./chunk-bt0amey5.js";export{lh as clearStoreCache,oh as getStoreScript,ch as getStoreScriptFor,ah as pageStoresAll,bo as storesRead,ih as storesReadInFiles};
|