@stacksjs/stx 0.2.850 → 0.2.851
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-y8qdpb0p.js → chunk-036pnz1y.js} +1 -1
- package/dist/chunk-2vfhzn8m.js +2 -0
- package/dist/chunk-30y1dbcf.js +2 -0
- package/dist/{chunk-sznk5c66.js → chunk-3m3jny87.js} +1 -1
- package/dist/{chunk-8hkgycpm.js → chunk-422eg7vs.js} +1 -1
- package/dist/{chunk-jqsn4sgv.js → chunk-45yytzyd.js} +1 -1
- package/dist/{chunk-xa1f13nk.js → chunk-4jf18yed.js} +4 -4
- package/dist/chunk-5bbwdv4y.js +3 -0
- package/dist/{chunk-z46mk8ym.js → chunk-5gfg2tqg.js} +1 -1
- package/dist/{chunk-je8ma636.js → chunk-5yy40vxk.js} +1 -1
- package/dist/{chunk-62k66qj9.js → chunk-69kbw21c.js} +1 -1
- package/dist/{chunk-qa1pcm7n.js → chunk-69nhstnz.js} +1 -1
- package/dist/{chunk-m6nhh5xf.js → chunk-6dqafrq5.js} +2 -2
- package/dist/{chunk-5wk40kjd.js → chunk-6ekgf3b3.js} +1 -1
- package/dist/{chunk-6rd4phe3.js → chunk-6rk18x14.js} +1 -1
- package/dist/{chunk-td6b41vj.js → chunk-7hv190bd.js} +2 -2
- package/dist/chunk-8qqrrbap.js +2 -0
- package/dist/chunk-8spe7avc.js +2 -0
- package/dist/{chunk-k0pm7p0f.js → chunk-8wnkh2ss.js} +1 -1
- package/dist/{chunk-5p6vpvmz.js → chunk-93kdj0t4.js} +1 -1
- package/dist/chunk-9frv1kpd.js +2 -0
- package/dist/chunk-9pzbesp6.js +2 -0
- package/dist/{chunk-98qgcmxr.js → chunk-ark6w80h.js} +1 -1
- package/dist/{chunk-sy0jtgmv.js → chunk-cct2fzth.js} +1 -1
- package/dist/{chunk-eh8g8kr1.js → chunk-dy31f39m.js} +4 -4
- package/dist/{chunk-ar1prdev.js → chunk-e6qam3x3.js} +2 -2
- package/dist/{chunk-hhk46fzp.js → chunk-e9qgyvz5.js} +1 -1
- package/dist/{chunk-ryb4jesm.js → chunk-evyspfm5.js} +1 -1
- package/dist/{chunk-9mryv01z.js → chunk-eyp7rr70.js} +2 -2
- package/dist/{chunk-qahz3n8z.js → chunk-ezzskm4a.js} +1 -1
- package/dist/{chunk-j6r964wk.js → chunk-fj18grh2.js} +1 -1
- package/dist/{chunk-918ws1g7.js → chunk-hdep0xcy.js} +3 -3
- package/dist/{chunk-hg9354gt.js → chunk-htsqfx9m.js} +1 -1
- package/dist/{chunk-7zxce1yw.js → chunk-j5pgwqwp.js} +1 -1
- package/dist/{chunk-d4kystzh.js → chunk-j882bpqq.js} +1 -1
- package/dist/{chunk-tbs24vx1.js → chunk-j8f4tb4p.js} +1 -1
- package/dist/{chunk-sjpya8wm.js → chunk-jxzcwjx4.js} +1 -1
- package/dist/{chunk-jpyk0gtr.js → chunk-kf5fsz9b.js} +1 -1
- package/dist/{chunk-kybes29w.js → chunk-knapnbwv.js} +1 -1
- package/dist/{chunk-btkazgdb.js → chunk-m9kkd9f2.js} +1 -1
- package/dist/{chunk-x80b12gr.js → chunk-ngdye54z.js} +1 -1
- package/dist/{chunk-jt5cqq09.js → chunk-nqv66ehx.js} +1 -1
- package/dist/{chunk-t7ws9sth.js → chunk-p2gsezmj.js} +1 -1
- package/dist/{chunk-xe8m66a3.js → chunk-p4ytnee6.js} +65 -64
- package/dist/{chunk-p2chmq36.js → chunk-pg2dxnry.js} +1 -1
- package/dist/{chunk-r2p2nyyq.js → chunk-q5rw0d2m.js} +1 -1
- package/dist/{chunk-e46n406k.js → chunk-qk2herh9.js} +1 -1
- package/dist/{chunk-9yp0t7zc.js → chunk-taf784yy.js} +1 -1
- package/dist/{chunk-jqjw00qm.js → chunk-tr5r70yr.js} +4 -4
- package/dist/{chunk-nq2z2yrz.js → chunk-ty915d4h.js} +1 -1
- package/dist/{chunk-zteccxj9.js → chunk-vk9zpckc.js} +1 -1
- package/dist/{chunk-w8aj3f9v.js → chunk-vvr19nq7.js} +1 -1
- package/dist/chunk-wjf69hmc.js +2 -0
- package/dist/{chunk-ab1vk7jv.js → chunk-wn8qkcaw.js} +2 -2
- package/dist/{chunk-brheng7x.js → chunk-wtahqbxe.js} +4 -4
- package/dist/{chunk-660g9vjn.js → chunk-x9a2agqk.js} +1 -1
- package/dist/{chunk-5jqz5qff.js → chunk-xj5jdy7n.js} +2 -2
- package/dist/{chunk-5m4txcry.js → chunk-xsavnbkv.js} +1 -1
- package/dist/{chunk-tmftv8na.js → chunk-xz4yq7gh.js} +5 -5
- package/dist/{chunk-gr8q8xqz.js → chunk-yvfzvygh.js} +1 -1
- package/dist/{chunk-sa18tper.js → chunk-yza0mj53.js} +1 -1
- package/dist/{chunk-6q6atv4g.js → chunk-zjm67zx2.js} +1 -1
- package/dist/chunk-zwy89pzx.js +2 -0
- package/dist/chunk-zz1n2ake.js +2 -0
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/stx-virtual-ts.d.ts +7 -0
- package/dist/stx-virtual-ts.js +83 -3
- package/package.json +5 -5
- package/dist/chunk-4pbrszgz.js +0 -2
- package/dist/chunk-5be6p256.js +0 -2
- package/dist/chunk-9bkgbyrs.js +0 -2
- package/dist/chunk-a2shk93y.js +0 -3
- package/dist/chunk-nnbr1q94.js +0 -2
- package/dist/chunk-r0btg48x.js +0 -2
- package/dist/chunk-tpax2gpz.js +0 -2
- package/dist/chunk-ts6sm467.js +0 -2
- package/dist/chunk-w005b56n.js +0 -2
- package/dist/chunk-xrdh4at4.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ln,No,Mo,Do,Oh,Lo}from"./chunk-
|
|
2
|
+
import{ln,No,Mo,Do,Oh,Lo}from"./chunk-69nhstnz.js";import"./chunk-2rg9pqmh.js";import"./chunk-8cvgm13s.js";import"./chunk-v4bqmzj9.js";export{Mo as buildServerApi,Oh as createServerApi,ln as discoverServerApi,No as generateApiTypes,Lo as isServerApiSource,Do as productionApiDispatcher};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{P,t,l}from"./chunk-k47addf7.js";import{Q}from"./chunk-
|
|
2
|
+
import{P,t,l}from"./chunk-k47addf7.js";import{Q}from"./chunk-p4ytnee6.js";import{ti}from"./chunk-jtccqpwa.js";import E from"path";var S;async function W(){if(S!==void 0)return S;try{let e=await import("@stacksjs/ts-i18n");S=e.loadLocale??null}catch{S=null}return S}var T={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},v={},L={},k={};function J(e,s=0){if(s<=0)return!1;return Date.now()-e.loadedAt>s}async function G(e,s){if({...T,...s.i18n}.cache&&v[e]){let r=v[e],o=s.i18n?.cacheMaxAge??0;if(!J(r,o))return r.translations}if(L[e]?.state==="loading")return L[e].promise;k[e]="loading";let n=C(e,s).then((r)=>(k[e]="loaded",delete L[e],r)).catch((r)=>{throw k[e]="error",L[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return L[e]={promise:n,state:"loading"},n}async function C(e,s){let i={...T,...s.i18n},n=E.isAbsolute(i.translationsDir)?i.translationsDir:E.resolve(s.root||process.cwd(),i.translationsDir);try{let r=await W(),o=r?await r(e,{translationsDir:n,defaultLocale:i.defaultLocale,sources:te(i.format)}):await Y(e,i,n);if(o===void 0){let u=e!==i.defaultLocale?await C(i.defaultLocale,s):{};if(i.cache)v[e]={translations:u,loadedAt:Date.now(),locale:e};return u}let c=o;if(i.cache)v[e]={translations:c,loadedAt:Date.now(),locale:e};return c}catch(r){if(s.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==i.defaultLocale)return C(i.defaultLocale,s);return{}}}async function Y(e,s,i){let n=E.join(i,`${e}${Z(s.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let o=await Bun.file(n).text();if(s.format==="yaml"||s.format==="yml")return X(o);if(s.format==="json")return JSON.parse(o);throw r}catch{return}}}function Z(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function X(e){let s={},i=e.split(`
|
|
3
3
|
`),n=[{obj:s,indent:-1}];for(let r of i){let o=r.replace(/#.*$/,"").trimEnd();if(!o.trim())continue;let c=o.search(/\S/);if(c===-1)continue;while(n.length>1&&n[n.length-1].indent>=c)n.pop();let u=n[n.length-1].obj,a=o.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(a){let[,,g,p]=a,f=g.trim(),m=p.trim();if(m==="")u[f]={},n.push({obj:u[f],indent:c});else u[f]=ee(m)}}return s}function ee(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);let s=e.toLowerCase();if(s==="true"||s==="yes")return!0;if(s==="false"||s==="no")return!1;if(s==="null"||s==="~")return null;let i=Number(e);if(!Number.isNaN(i)&&e!=="")return i;return e}function te(e){switch(e){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function re(e,s){return G(e,s)}function ne(e,s){for(let i of e){let n=i.trim(),r=n.match(/^\{(\d+)\}\s*(.*)$/);if(r){let c=Number.parseInt(r[1],10);if(s===c)return r[2];continue}let o=n.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(o){let c=Number.parseInt(o[1],10),u=o[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(o[2],10);if(s>=c&&s<=u)return o[3];continue}}if(e.length===2)return s===1?e[0].trim():e[1].trim();if(s<e.length)return e[s].trim();return e[e.length-1].trim()}function ie(e,s={}){return j(e,s)}function j(e,s){let i="",n=0;while(n<e.length)if(e[n]==="{"){let r=se(e,n);if(r===-1){i+=e[n],n++;continue}let o=e.slice(n+1,r);i+=ae(o,s),n=r+1}else if(e[n]==="'"&&n+1<e.length)if(e[n+1]==="'")i+="'",n+=2;else if(e[n+1]==="{"||e[n+1]==="}")i+=e[n+1],n+=2;else i+=e[n],n++;else i+=e[n],n++;return i}function se(e,s){let i=0;for(let n=s;n<e.length;n++)if(e[n]==="{")i++;else if(e[n]==="}"){if(i--,i===0)return n}return-1}function ae(e,s){let i=oe(e);if(i.length===0)return`{${e}}`;let n=i[0].trim(),r=s[n];if(i.length===1)return r!==void 0?String(r):`{${n}}`;switch(i[1].trim().toLowerCase()){case"plural":return le(r,i.slice(2).join(","),s);case"select":return ue(r,i.slice(2).join(","));case"selectordinal":return de(r,i.slice(2).join(","));case"number":return pe(r,i[2]?.trim());case"date":return fe(r,i[2]?.trim());case"time":return me(r,i[2]?.trim());default:return r!==void 0?String(r):`{${e}}`}}function oe(e){let s=[],i="",n=0;for(let r=0;r<e.length;r++){let o=e[r];if(o==="{")n++,i+=o;else if(o==="}")n--,i+=o;else if(o===","&&n===0)s.push(i),i="";else i+=o}if(i)s.push(i);return s}function le(e,s,i){let n=Number(e)||0,r=I(s),o=`=${n}`;if(r[o])return R(r[o],n,i);let c=ce(n);if(r[c])return R(r[c],n,i);if(r.other)return R(r.other,n,i);return String(n)}function R(e,s,i){let n=e.replace(/#/g,String(s));return j(n,i)}function ce(e){let s=Math.abs(e),i=Math.floor(s),n=String(e).includes(".")?String(e).split(".")[1].length:0;if(i===1&&n===0)return"one";return"other"}function ue(e,s){let i=String(e||""),n=I(s);if(n[i])return n[i];return n.other||String(e)}function de(e,s){let i=Number(e)||0,n=I(s),r=ge(i);if(n[r])return n[r].replace(/#/g,String(i));if(n.other)return n.other.replace(/#/g,String(i));return String(i)}function ge(e){let s=Math.abs(e),i=s%10,n=s%100;if(i===1&&n!==11)return"one";if(i===2&&n!==12)return"two";if(i===3&&n!==13)return"few";return"other"}function I(e){let s={},i=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,n=i.exec(e);while(n!==null)s[n[1]]=n[2],n=i.exec(e);return s}function pe(e,s){let i=Number(e);if(Number.isNaN(i))return String(e);switch(s){case"integer":return Math.floor(i).toLocaleString();case"percent":return`${(i*100).toFixed(0)}%`;case"currency":return i.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return i.toLocaleString()}}function fe(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.dateStyle="short";break;case"medium":n.dateStyle="medium";break;case"long":n.dateStyle="long";break;case"full":n.dateStyle="full";break;default:n.dateStyle="medium"}return i.toLocaleDateString(void 0,n)}function me(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.timeStyle="short";break;case"medium":n.timeStyle="medium";break;case"long":n.timeStyle="long";break;case"full":n.timeStyle="full";break;default:n.timeStyle="short"}return i.toLocaleTimeString(void 0,n)}function be(e){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test(e)}function O(e,s,i=!0,n={}){let r=e.split("."),o=s;for(let u of r){if(o===void 0||o===null)break;o=o[u]}if(o===void 0||o===null)return i?e:"";let c=String(o);if(be(c))return ie(c,n);if(c.includes("|")&&"count"in n){let u=Number(n.count),a=c.split("|");c=ne(a,u)}for(let[u,a]of Object.entries(n)){let g=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");c=c.replace(new RegExp(`:${g}`,"g"),()=>String(a))}return c}var D=new Set(["ar","arc","ckb","dv","fa","he","khw","ks","nqo","prs","ps","sd","syr","ug","ur","uz-af","yi"]),he=new Set(["adlm","arab","aran","hebr","nkoo","rohg","syrc","thaa","yezi"]);function q(e){if(!e)return"ltr";let s=e.trim().toLowerCase().replace(/_/g,"-").split("-"),i=s[0];if(!i)return"ltr";let n=s[1]?.length===4?s[1]:void 0;if(n)return he.has(n)?"rtl":"ltr";if(s.length>1&&D.has(`${i}-${s[1]}`))return"rtl";return D.has(i)?"rtl":"ltr"}async function Sc(e,s,i,n){let r=e,o=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,c={...T,...n.i18n},u=await re(c.locale,n);s.__translations=u,s.__locale=c.locale,s.__i18nConfig=c,r=await F(r,o,async(p,f,m,w,h)=>{try{let b={};if(m)try{let d=[()=>JSON.parse(m),()=>{let x=`{"data":${m}}`,A=JSON.parse(x);return typeof A.data==="object"?A.data:{}},()=>P(m,s)];for(let x of d)try{if(b=x(),Object.keys(b).length>0)break}catch{}}catch(d){if(n.debug)console.error("Error parsing parameters for @translate directive:",d)}let y=O(f,u,c.fallbackToKey,b);return y?Q(r,h,y,!1,p.length):w.trim()}catch(b){if(n.debug)console.error("Error processing @translate directive:",b);return l("Translate",`Error in @translate('${f}'): ${b instanceof Error?b.message:String(b)}`,t.EVALUATION_ERROR)}});let a=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(n.debug){console.warn(`Processing translations in template. Sections: ${r.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let p=[...r.matchAll(a)];console.warn(`Found ${p.length} @translate matches`),p.forEach((f,m)=>console.warn(`Match ${m}: ${f[0]}, Key: ${f[1]}, Params: ${f[2]||"none"}`))}return r=await F(r,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(p,f,m,w)=>{try{let h={};if(m)try{let b=[()=>JSON.parse(m),()=>{let y=`{"data":${m}}`,d=JSON.parse(y);return typeof d.data==="object"?d.data:{}},()=>P(m,s)];for(let y of b)try{if(h=y(),Object.keys(h).length>0)break}catch{}}catch(b){if(n.debug)console.error("Error parsing parameters for @translate directive:",b)}return Q(r,w,O(f,u,c.fallbackToKey,h),!1,p.length)}catch(h){if(n.debug)console.error("Error processing @translate directive:",h);return l("Translate",`Error in @translate('${f}'): ${h instanceof Error?h.message:String(h)}`,t.EVALUATION_ERROR)}}),r}async function F(e,s,i){let n=[];return e.replace(s,(o,...c)=>{let u=i(o,...c).then((a)=>({match:o,replacement:a}));return n.push(u),o}),(await Promise.all(n)).reduce((o,{match:c,replacement:u})=>o.replace(c,()=>u),e)}function _(e,s){if(!e||q(e)!=="rtl")return!1;return!s||s.trim().toLowerCase()!=="rtl"}function V(e){if(!e)return!1;return e.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||e.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function U(e,s){let i=new RegExp(`\\b${s}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);if(!i)return null;return i[2]??i[3]??i[4]??null}function kc(e,s,i,n){let r=e;r=r.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,u,a)=>{let p={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[u]||"Make this element accessible";return`<!-- a11y-hint: ${a||p} -->`});let o=/@screenReader\(([^@]*)\)@endScreenReader/g;return r=r.replace(o,(c,u)=>`<span class="sr-only">${u.trim()}</span>`),r=r.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(c,u,a)=>`<span id="${`desc-${u}`}" class="sr-only">${a}</span>`),r}function ye(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function xe(e){let s=new Map,i=e.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,(r,o,c)=>{let u=s.get(c);if(!u)u=`stx-a11y-component-${s.size}`,s.set(c,u);return`<${o}${u}`}),n=new Map([...s.entries()].map(([r,o])=>[o,r]));return{protectedSource:i,restore:(r)=>r.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(o,c,u)=>{let a=n.get(u);return a?`<${c}${a}`:o})}}function we(e,s){let i=[],n=/<img\s+([^>]*)>/gi,r;r=n.exec(e);while(r!==null){let d=r[1];if(!/\balt\s*=/i.test(d))i.push({type:"missing-alt",element:r[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});r=n.exec(e)}let o=/<button([^>]*)>\s*<\/button>/gi;r=o.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"missing-accessible-name",element:r[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});r=o.exec(e)}let c=/<a\s+([^>]*)>\s*<\/a>/gi;r=c.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"link-missing-text",element:r[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});r=c.exec(e)}let u=/<(input|select|textarea)\s+([^>]*)>/gi;r=u.exec(e);while(r!==null){let d=r[2];if(/\btype\s*=\s*["']hidden["']/i.test(d)){r=u.exec(e);continue}let x=/\baria-label\s*=/i.test(d)||/\baria-labelledby\s*=/i.test(d),A=d.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!x){let B=A&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${A[1]}["']`,"i").test(e),M=r.index,N=e.substring(0,M),Se=e.substring(M),H=(N.match(/<label\b/gi)||[]).length,z=(N.match(/<\/label>/gi)||[]).length,K=H>z;if(!B&&!K)i.push({type:"input-missing-label",element:r[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}r=u.exec(e)}let a=/<h([1-6])[^>]*>/gi,g=[];r=a.exec(e);while(r!==null)g.push(Number.parseInt(r[1],10)),r=a.exec(e);let p=0;for(let d of g){if(p>0&&d>p+1)i.push({type:"heading-skip",element:`<h${d}>`,message:`Heading level skipped from h${p} to h${d}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});p=d}if(/<html\b/i.test(e)&&!/<html[^>]*\slang\s*=/i.test(e))i.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let f=e.match(/<html\b([^>]*)>/i);if(f&&_(U(f[1],"lang"),U(f[1],"dir")))i.push({type:"missing-dir",element:f[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let m=/<table([^>]*)>([\s\S]*?)<\/table>/gi;r=m.exec(e);while(r!==null){let d=r[2];if(!V(U(r[1],"role"))&&!/<th\b/i.test(d))i.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});r=m.exec(e)}let w=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;r=w.exec(e);while(r!==null){if(!/\bmuted\b/i.test(r[0]))i.push({type:"autoplay-audio",element:`<${r[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});r=w.exec(e)}let h=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;r=h.exec(e);while(r!==null)i.push({type:"positive-tabindex",element:`tabindex="${r[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),r=h.exec(e);let b=/<iframe\s+([^>]*)>/gi;r=b.exec(e);while(r!==null){let d=r[1];if(!/\btitle\s*=/i.test(d)&&!/\baria-label\s*=/i.test(d))i.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});r=b.exec(e)}let y=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;r=y.exec(e);while(r!==null){let d=r[1].toLowerCase(),x=r[2];if(d!=="button"&&!/\btabindex\s*=/i.test(x))i.push({type:"button-not-focusable",element:r[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});r=y.exec(e)}return i}async function Ae(e,s){let{protectedSource:i}=xe(e);if(!ye())return we(i,s);let n=[];try{let r=globalThis.document.createElement("div");r.innerHTML=i,r.querySelectorAll("img").forEach((a)=>{if(!a.hasAttribute("alt"))n.push({type:"missing-alt",element:`<${a.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),r.querySelectorAll('button, a, [role="button"]').forEach((a)=>{if(!(a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby")||a.textContent&&a.textContent.trim().length>0))n.push({type:"missing-accessible-name",element:`<${a.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),r.querySelectorAll("input, select, textarea").forEach((a)=>{let g=a.getAttribute("id"),p=g&&r.querySelector(`label[for="${g}"]`),f=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),m=a.closest("label")!==null;if(!p&&!f&&!m)n.push({type:"input-missing-label",element:`<${a.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let o=Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")),c=0;for(let a of o){let g=Number.parseInt(a.tagName.charAt(1));if(c>0&&g>c+1)n.push({type:"heading-skip",element:`<${a.outerHTML}>`,message:`Heading level skipped from h${c} to h${g}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});c=g}let u=r.querySelector("html");if(i.includes("<html")&&u&&!u.hasAttribute("lang"))n.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(u&&_(u.getAttribute("lang"),u.getAttribute("dir")))n.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if(r.querySelectorAll("a").forEach((a)=>{let g=a.textContent&&a.textContent.trim().length>0,p=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),f=a.hasAttribute("title"),m=a.querySelector("img[alt]");if(!g&&!p&&!f&&!m)n.push({type:"link-missing-text",element:`<${a.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),i.includes("<nav")||i.includes("<header")){if(!r.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&r.querySelectorAll("a").length>5)n.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(r.querySelectorAll("table").forEach((a)=>{if(V(a.getAttribute("role")))return;let g=a.querySelector("caption");if(!a.querySelector("th"))n.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!g&&!a.hasAttribute("aria-label")&&!a.hasAttribute("aria-labelledby"))n.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),r.querySelectorAll('[style*="color"]').forEach((a)=>{let g=a.getAttribute("style")||"";if(g.includes("color:")&&!g.includes("background"))n.push({type:"potential-contrast-issue",element:`<${a.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),r.querySelectorAll("video[autoplay], audio[autoplay]").forEach((a)=>{if(!a.hasAttribute("muted"))n.push({type:"autoplay-audio",element:`<${a.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),r.querySelectorAll("[tabindex]").forEach((a)=>{if(Number.parseInt(a.getAttribute("tabindex")||"0")>0)n.push({type:"positive-tabindex",element:`<${a.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),r.querySelectorAll('[role="button"]').forEach((a)=>{if(!a.hasAttribute("tabindex"))n.push({type:"button-not-focusable",element:`<${a.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),i.includes("<body")&&!r.querySelector('main, [role="main"]'))n.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});r.querySelectorAll("iframe").forEach((a)=>{if(!a.hasAttribute("title")&&!a.hasAttribute("aria-label"))n.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(r){console.error(`Error checking accessibility in ${s}:`,r)}return n}async function _c(e,s={}){let i={},{recursive:n=!0,ignorePaths:r=[]}=s,o=Array.isArray(e)?e:[e],c=await ti(o,{recursive:n,ignorePaths:r}),u=[];for(let a of c)try{let g=await Bun.file(a).text();if(a.endsWith("good-a11y.stx"))continue;let p=await Ae(g,a);if(u.push(a),p.length>0)i[a]=p}catch(g){console.error(`Error scanning ${a}:`,g)}return{results:i,scannedFiles:u}}var Cc={name:"a11y",handler:(e,s,i,n)=>{if(!s.length)return e;let r=s[0].replace(/['"]/g,""),o=s.length>1?s[1].replace(/['"]/g,""):"",u={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[r]||"Make this element accessible";return`<!-- a11y-hint: ${o||u} -->${e}`},hasEndTag:!1},Ec={name:"screenReader",handler:(e)=>`<span class="sr-only">${e}</span>`,hasEndTag:!0};
|
|
4
4
|
export{Sc,kc,_c,Cc,Ec};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rs,ss}from"./chunk-0dnetjh8.js";import{y}from"./chunk-
|
|
2
|
+
import{rs,ss}from"./chunk-0dnetjh8.js";import{y}from"./chunk-p4ytnee6.js";import{a}from"./chunk-eyp7rr70.js";import{Ge,se}from"./chunk-t74qb5ej.js";import{nc}from"./chunk-7hv190bd.js";import{B}from"./chunk-ybq56wam.js";import{g}from"./chunk-0dve54ne.js";import{existsSync as z,mkdirSync as S,copyFileSync as P,chmodSync as I,rmSync as ve}from"fs";import{join as c,basename as xe,resolve as X}from"path";import{spawn as _}from"child_process";import{platform as ye}from"os";function O(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=y(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var vu=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{He,M,jt}from"./chunk-v4bqmzj9.js";import{R}from"./chunk-k47addf7.js";import{mt,Ee,j,Ke,Te,ba,vo,wa,Dn}from"./chunk-918ws1g7.js";import{_t,de,tt}from"./chunk-8cvgm13s.js";import{Do}from"./chunk-qa1pcm7n.js";import{Ln}from"./chunk-12r22pf0.js";import{we}from"./chunk-eh8g8kr1.js";import Z from"fs";import P from"path";var{serve:ae}=globalThis.Bun;import H from"zlib";import{promisify as Y}from"util";var K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function se(t){if(!t)return null;let e=re(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,F=new Map,z=0;function oe(t,e){if(e.length>J/8)return;F.set(t,e),z+=e.length;for(let[a,r]of F){if(z<=J)break;F.delete(a),z-=r.length}}async function In(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let r=se(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(i.length<(a.threshold??te))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=F.get(g);if(!l)l=r==="br"?await Y(H.brotliCompress)(i,{params:{[H.constants.BROTLI_PARAM_QUALITY]:h,[H.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Y(H.gzip)(i),oe(g,l);if(l.length>=i.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new R(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",j(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ee(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await a();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((C)=>C.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((C)=>C!=="x-stx-router"&&C!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",j(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return i();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):i()}}var ie={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function nm(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=ba(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=Ln(r.routeRules),f=new G,h=Do(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?M(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let C=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(C).text());if(m)c.html=jt(c.html,m);b.set(n.pattern,c),v.set(n.pattern,tt(c.html)),E.set(n.pattern,we(c.html));let _=P.join(e,n.fragmentPath);if(Ke(c.html,r.routerContainer||"main")&&await Bun.file(_).exists()){let A=await Bun.file(_).text();k.set(n.pattern,m?jt(A,m):A)}}catch(C){console.warn(`[stx] Failed to load route ${n.pattern}:`,C)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:C,params:c}=de(n.pattern,{page:!0});S.push({regex:C,route:n,paramNames:c})}else s.set(n.pattern,n);let B=ae({port:a,async fetch(n){return In(n,await He(m??M(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let _=await h(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let y=P.extname(u).toLowerCase(),L=ie[y]||"application/octet-stream",N=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ee(n),w=null,q={};if(w=s.get(c)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let o=c.match(p);if(o){w=d,u.forEach((y,L)=>{q[y]=o[L+1]});break}}if(!w){let p=_t(c)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.get(w.pattern);if(o){let y=v.get(w.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...y?{"X-STX-Layout":y.layout,"X-STX-Layout-Group":y.group}:{},...j(),...O.cache?{}:{"Cache-Control":mt}}})}}let d=vo(n.method),u=b.get(w.pattern);if(!u){let o=s.get("/500")||null;if(o){let y=b.get(o.pattern);if(y)return new Response(y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...j(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:y,redirect:L,cookies:N,status:I,headers:D}=await Dn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return wa(L,N,D);if(y&&y.length>0){let{renderStreamingPage:T,streamToResponse:U}=await import("./chunk-sznk5c66.js"),X=new Headers({...j(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])X.append("Set-Cookie",V);if(A&&!d&&Ke(o,r.routerContainer||"main")){let V=tt(o);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",we(o)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return U(T(A&&!d&&Ke(o,r.routerContainer||"main")?Te(o,r.routerContainer||"main",!0):o,y,{timeoutMs:30000}),{status:I??u.status??200,headers:X})}let x=new Headers({"Content-Type":"text/html",...j(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,U]of Object.entries(D??{}))x.set(T,U);if(x.set("Vary",j(x.get("Vary")).Vary),A&&!d&&Ke(o,r.routerContainer||"main")){let T=tt(o);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",we(o)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(Te(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:x})}return new Response(o,{status:I??u.status??200,headers:x})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
2
|
+
import{He,M,jt}from"./chunk-v4bqmzj9.js";import{R}from"./chunk-k47addf7.js";import{mt,Ee,j,Ke,Te,ba,vo,wa,Dn}from"./chunk-hdep0xcy.js";import{_t,de,tt}from"./chunk-8cvgm13s.js";import{Do}from"./chunk-69nhstnz.js";import{Ln}from"./chunk-12r22pf0.js";import{we}from"./chunk-dy31f39m.js";import Z from"fs";import P from"path";var{serve:ae}=globalThis.Bun;import H from"zlib";import{promisify as Y}from"util";var K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function ne(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((a)=>e.startsWith(a)))return!1;return K.some((a)=>e.startsWith(a))}function re(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function se(t){if(!t)return null;let e=re(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,F=new Map,z=0;function oe(t,e){if(e.length>J/8)return;F.set(t,e),z+=e.length;for(let[a,r]of F){if(z<=J)break;F.delete(a),z-=r.length}}async function In(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ne(e.headers.get("content-type")))return e;let r=se(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(i.length<(a.threshold??te))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=F.get(g);if(!l)l=r==="br"?await Y(H.brotliCompress)(i,{params:{[H.constants.BROTLI_PARAM_QUALITY]:h,[H.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await Y(H.gzip)(i),oe(g,l);if(l.length>=i.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new R(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",j(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ee(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await a();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((C)=>C.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((C)=>C!=="x-stx-router"&&C!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",j(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return i();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):i()}}var ie={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function nm(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=ba(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=Ln(r.routeRules),f=new G,h=Do(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?M(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let C=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(C).text());if(m)c.html=jt(c.html,m);b.set(n.pattern,c),v.set(n.pattern,tt(c.html)),E.set(n.pattern,we(c.html));let _=P.join(e,n.fragmentPath);if(Ke(c.html,r.routerContainer||"main")&&await Bun.file(_).exists()){let A=await Bun.file(_).text();k.set(n.pattern,m?jt(A,m):A)}}catch(C){console.warn(`[stx] Failed to load route ${n.pattern}:`,C)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:C,params:c}=de(n.pattern,{page:!0});S.push({regex:C,route:n,paramNames:c})}else s.set(n.pattern,n);let B=ae({port:a,async fetch(n){return In(n,await He(m??M(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let _=await h(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let y=P.extname(u).toLowerCase(),L=ie[y]||"application/octet-stream",N=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ee(n),w=null,q={};if(w=s.get(c)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let o=c.match(p);if(o){w=d,u.forEach((y,L)=>{q[y]=o[L+1]});break}}if(!w){let p=_t(c)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.get(w.pattern);if(o){let y=v.get(w.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...y?{"X-STX-Layout":y.layout,"X-STX-Layout-Group":y.group}:{},...j(),...O.cache?{}:{"Cache-Control":mt}}})}}let d=vo(n.method),u=b.get(w.pattern);if(!u){let o=s.get("/500")||null;if(o){let y=b.get(o.pattern);if(y)return new Response(y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...j(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:y,redirect:L,cookies:N,status:I,headers:D}=await Dn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return wa(L,N,D);if(y&&y.length>0){let{renderStreamingPage:T,streamToResponse:U}=await import("./chunk-3m3jny87.js"),X=new Headers({...j(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])X.append("Set-Cookie",V);if(A&&!d&&Ke(o,r.routerContainer||"main")){let V=tt(o);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",we(o)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return U(T(A&&!d&&Ke(o,r.routerContainer||"main")?Te(o,r.routerContainer||"main",!0):o,y,{timeoutMs:30000}),{status:I??u.status??200,headers:X})}let x=new Headers({"Content-Type":"text/html",...j(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,U]of Object.entries(D??{}))x.set(T,U);if(x.set("Vary",j(x.get("Vary")).Vary),A&&!d&&Ke(o,r.routerContainer||"main")){let T=tt(o);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",we(o)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(Te(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:x})}return new Response(o,{status:I??u.status??200,headers:x})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
3
|
export{In,nm};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{R,u,f,P,d,K}from"./chunk-k47addf7.js";import{V,Ms,Ne,pe,It,Tr,Be,Fe,s,h,ke,E}from"./chunk-
|
|
2
|
+
import{R,u,f,P,d,K}from"./chunk-k47addf7.js";import{V,Ms,Ne,pe,It,Tr,Be,Fe,s,h,ke,E}from"./chunk-p4ytnee6.js";import{lt}from"./chunk-agbkv9ab.js";import{I}from"./chunk-xppm4cs4.js";import{oe}from"./chunk-m710wkr4.js";import{B,Ze}from"./chunk-ybq56wam.js";import{T,$n}from"./chunk-ym5qgw03.js";import C from"path";import{existsSync as ye}from"fs";function ae(c,e){let a=0;for(let r=e;r<c.length;r++){let S=c[r];if(S==="("||S==="["||S==="{")a++;else if(S===")"||S==="]"||S==="}")a--;else if(S===","&&a===0)return r}return-1}function $e(c,e,a){let r=c,S=new RegExp(`${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),n=S.exec(r);while(n){let g=n.index,t=g+n[0].length-1,D=1,W=t+1;while(W<r.length&&D>0){if(r[W]==="(")D++;else if(r[W]===")")D--;W++}if(D!==0)break;let re=r.substring(t+1,W-1),N=`${a}(${re})`;r=r.substring(0,g)+N+r.substring(W),S.lastIndex=g+N.length,n=S.exec(r)}return r}function Ee(c){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(c)}function he(c){let e=c,a=[],r=new Set,S=0,n=0,g=e.length,t=(N)=>{n++;while(n<g){if(e[n]==="\\"){n+=2;continue}if(e[n]===N){n++;return}n++}},D=()=>{n++;while(n<g){if(e[n]==="\\"){n+=2;continue}if(e[n]==="`"){n++;return}if(e[n]==="$"&&e[n+1]==="{"){n+=2;let N=1;while(n<g&&N>0)if(e[n]==="{")N++,n++;else if(e[n]==="}")N--,n++;else if(e[n]==="'"||e[n]==='"')t(e[n]);else if(e[n]==="`")D();else n++;continue}n++}},W=()=>{if(e[n]==="/"&&e[n+1]==="/"){while(n<g&&e[n]!==`
|
|
3
3
|
`)n++;return!0}if(e[n]==="/"&&e[n+1]==="*"){n+=2;while(n<g-1&&!(e[n]==="*"&&e[n+1]==="/"))n++;return n+=2,!0}return!1},re=()=>{if(S!==0)return;let N=e.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(N){let Z=N[2];if(!r.has(Z))a.push(Z),r.add(Z);return}let te=e.slice(n).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(te){let Z=te[1];if(!r.has(Z))a.push(Z),r.add(Z);return}let Y=e.slice(n).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let Z=Y[1];if(!r.has(Z))a.push(Z),r.add(Z)}};while(n<g){if(W())continue;if(e[n]==="'"||e[n]==='"'){t(e[n]);continue}if(e[n]==="`"){D();continue}if(e[n]==="{"){S++,n++;continue}if(e[n]==="}"){S--,n++;continue}if(S===0&&/[a-z]/i.test(e[n])&&(n===0||/\s|[;{}()]/.test(e[n-1])))re();n++}return a.join(", ")}function ve(c,e=""){let a=he(c).split(",").map((r)=>r.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${lt("var",a)}
|
|
@@ -44,10 +44,10 @@ ${n}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return a+c+r}function Te(c,e){if(B(c)){let n=B(c).tag.match(/data-stx-scope="([^"]*)"/);if(n)return{html:c,mergedIntoExisting:n[1],stamped:!0,root:"body"};return{html:Ze(c,(g,t)=>`<body${t} data-stx-scope="${e}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let a=It(c),r=c.slice(a).match(/^(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(r){let S=r[1]+r[2],n=r[1].slice(1),g=S.match(/data-stx-scope="([^"]*)"/);if(g)return{html:c,mergedIntoExisting:g[1],stamped:!0,root:n};let t=c.slice(0,a),D=r[1],W=r[2];return{html:`${t}${D} data-stx-scope="${e}"${W}${c.slice(a+r[0].length)}`,mergedIntoExisting:null,stamped:!0,root:n}}return{html:c,mergedIntoExisting:null,stamped:!1,root:null}}var Ae=0;function fe(c,e){let a=C.basename(c,".stx").replace(/[^a-zA-Z0-9]/g,"_"),r=e.__stx_scope_seq;return r?`stx_scope_${a}_${++r.n}_${r.key}`:`stx_scope_${a}_${++Ae}`}var le=new Set,de=new Set;function Lh(){le.clear(),de.clear()}var Ce=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Bf(c){let e=(t)=>t.replace(/[^\n]/g," "),a=c.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,e).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,e).replace(/<!--[\s\S]*?-->/g,e).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,e).replace(/\{\{[\s\S]*?\}\}/g,e).replace(/\{!![\s\S]*?!!\}/g,e),r=[],S=0,n=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,g;while((g=n.exec(a))!==null){let t=g[1]==="/",D=g[2],W=g[3]==="/"||Ce.has(D.toLowerCase());if(t){S=Math.max(0,S-1);continue}if(S===0)r.push(D);if(!W)S++}return r}function me(c){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(c)}var Ye=new R(500),fc=new Set;function jh(){fc.clear()}function De(c){if(c.__onceStore instanceof Set)return c.__onceStore;return fc}async function us(c,e,a,r,S,n=new Set){let g=r.partialsDir||C.join(C.dirname(a),"partials");if(g&&!C.isAbsolute(g))g=C.resolve(process.cwd(),g);let t=$e(c,"@partial","@include"),D=De(e);t=t.replace(/@once([\s\S]*?)@endonce/g,(m,k,x)=>{let p=k.trim(),i=`${a}:${p}`;if(D.has(i))return"";return D.add(i),k});{let m=/@includeIf\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")")i--;_++}if(i!==0)break;let l=t.substring(p+1,_-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){m.lastIndex=_;continue}let O=o[1],z=W(O,g,a),v="";if(z&&await Bun.file(z).exists())S.add(z),v=`@include(${l})`;t=t.substring(0,x)+v+t.substring(_),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(t))!==null){let i=p.index,_=i+p[0].length-1,l=1,o=_+1;while(o<t.length&&l>0){if(t[o]==="(")l++;else if(t[o]===")")l--;o++}if(l!==0)break;let O=t.substring(_+1,o-1),z=ae(O,0);if(z===-1){x.lastIndex=o;continue}let v=O.substring(0,z).trim(),H=O.substring(z+1).trim(),F=H.match(/^\s*['"]([^'"]+)['"]/);if(!F){x.lastIndex=o;continue}let w=F[1],J=H.substring(F[0].length),j,M=ae(J,0);if(M!==-1)j=J.substring(M+1).trim();try{let A=`Boolean(${v})`,L;if(f(A)){let ie=d(A,Object.keys(e));L=Boolean(ie(...Object.values(e)))}else L=Boolean(u(A,e));let ee=k?!L:L,ne="";if(ee){let ie=W(w,g,a);if(ie&&await Bun.file(ie).exists())S.add(ie);ne=`@include('${w}'${j?`, ${j}`:""})`}t=t.substring(0,i)+ne+t.substring(o),x.lastIndex=0}catch(A){let L=A instanceof Error?A.message:String(A),ee=h("Include",`Error evaluating ${m} condition: ${L}`,a,c,i);t=t.substring(0,i)+ee+t.substring(o),x.lastIndex=0}}}{let m=/@each\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")"){if(i--,i===0)break}_++}if(i!==0)break;let l=t.substring(p+1,_),o=t.substring(x,_+1),O=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){m.lastIndex=0,t=t.replace(o,"");continue}let[,z,v,H,F]=O;try{let w,J=v.trim();if(f(J))w=d(J,Object.keys(e))(...Object.values(e));else w=u(J,e);let j="";if(Array.isArray(w)&&w.length>0)for(let M of w){let A={...e,[H]:M},L=await te(z,A,c,x);j+=L}else if(F)j=await te(F,{},c,x);t=t.substring(0,x)+j+t.substring(_+1),m.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);t=t.substring(0,x)+h("Each",`Error in @each: ${J}`,a,c,x)+t.substring(_+1),m.lastIndex=0}}}{let m=/@includeFirst\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")"){if(i--,i===0)break}_++}if(i!==0)break;let l=t.substring(p+1,_),o=t.substring(x,_+1),O=l.match(/^\s*(\[[^\]]+\])/);if(!O){m.lastIndex=0,t=t.replace(o,"");continue}let z=O[1],v=l.slice(O[0].length),H,F=v.match(/^\s*,\s*\{/);if(F){v=v.slice(F[0].length-1);let j=1,M=1;while(M<v.length&&j>0){if(v[M]==="{")j++;else if(v[M]==="}"){if(j--,j===0)break}M++}H=v.substring(0,M+1),v=v.slice(M+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let j=JSON.parse(z.replace(/'/g,'"')),M={};if(H)try{M=P(H,e)}catch(L){let ee=L instanceof Error?L.message:String(L);if(r.debug){let ne=h("Include",`Error parsing includeFirst variables: ${ee}`,a,c,x,o);t=t.replace(o,()=>ne)}else t=t.replace(o,()=>w||"");continue}let A=!1;for(let L of j){let ee=W(L,g,a);if(!ee)continue;if(await s(ee)){let ne=await te(L,M,c,x);t=t.replace(o,()=>ne),A=!0;break}}if(!A)if(w!==void 0)t=t.replace(o,()=>w);else if(r.debug){let L=h("Include",`None of the includeFirst paths exist: ${z}`,a,c,x,o);t=t.replace(o,()=>L)}else t=t.replace(o,"")}catch(j){let M=j instanceof Error?j.message:String(j),A=h("Include",`Error processing @includeFirst: ${M}`,a,c,x,o);t=t.replace(o,()=>A)}m.lastIndex=0}}function W(m,k,x){try{let p=m;if(!m.endsWith(".stx"))p=`${m}.stx`;let i=C.resolve(k),_=C.resolve(C.dirname(x)),l;if(!p.startsWith("./")&&!p.startsWith("../")){for(let F of r._layerPartialDirs??[]){let w=C.resolve(F,p);if(w.startsWith(`${C.resolve(F)}${C.sep}`)&&ye(w))return w}l=C.resolve(k,p)}else l=C.resolve(_,p);let o=C.normalize(l),O=o.startsWith(i+C.sep)||o===i,z=o.startsWith(_+C.sep)||o===_,v=!1,H=C.dirname(_);if(o.startsWith(H+C.sep)){if(!C.relative(H,o).split(C.sep).some((j)=>j.startsWith(".")&&j!=="."&&j!==".."))v=!0}if(!O&&!z&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${m}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${i}, ${_}`),null;return o}catch(p){return console.error(`Error resolving path ${m}: ${p}`),null}}let re=C.resolve(a);n.add(re);function N(m,k,x,p){return r.onIncludeError?.({includePath:m,templatePath:a,message:k,partialsDir:g}),h("Include",k,a,x,p)}async function te(m,k={},x,p){let i=W(m,g,a);if(!i)return N(m,`Could not resolve path for include: ${m}`,x,p);let _=C.resolve(i);if(n.has(_)){let l=[...n,_].map((o)=>C.basename(o)).join(" -> ");return N(m,`Circular include detected: ${l}`,x,p)}try{S.add(i);let l;if(!l)try{l=await Bun.file(i).text()}catch(y){let q=y instanceof Error?y.message:String(y);return N(m,`Error loading include file ${m}: ${q}`,x,p)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-
|
|
47
|
+
})();`;return a+c+r}function Te(c,e){if(B(c)){let n=B(c).tag.match(/data-stx-scope="([^"]*)"/);if(n)return{html:c,mergedIntoExisting:n[1],stamped:!0,root:"body"};return{html:Ze(c,(g,t)=>`<body${t} data-stx-scope="${e}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let a=It(c),r=c.slice(a).match(/^(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(r){let S=r[1]+r[2],n=r[1].slice(1),g=S.match(/data-stx-scope="([^"]*)"/);if(g)return{html:c,mergedIntoExisting:g[1],stamped:!0,root:n};let t=c.slice(0,a),D=r[1],W=r[2];return{html:`${t}${D} data-stx-scope="${e}"${W}${c.slice(a+r[0].length)}`,mergedIntoExisting:null,stamped:!0,root:n}}return{html:c,mergedIntoExisting:null,stamped:!1,root:null}}var Ae=0;function fe(c,e){let a=C.basename(c,".stx").replace(/[^a-zA-Z0-9]/g,"_"),r=e.__stx_scope_seq;return r?`stx_scope_${a}_${++r.n}_${r.key}`:`stx_scope_${a}_${++Ae}`}var le=new Set,de=new Set;function Lh(){le.clear(),de.clear()}var Ce=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Bf(c){let e=(t)=>t.replace(/[^\n]/g," "),a=c.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,e).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,e).replace(/<!--[\s\S]*?-->/g,e).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,e).replace(/\{\{[\s\S]*?\}\}/g,e).replace(/\{!![\s\S]*?!!\}/g,e),r=[],S=0,n=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,g;while((g=n.exec(a))!==null){let t=g[1]==="/",D=g[2],W=g[3]==="/"||Ce.has(D.toLowerCase());if(t){S=Math.max(0,S-1);continue}if(S===0)r.push(D);if(!W)S++}return r}function me(c){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(c)}var Ye=new R(500),fc=new Set;function jh(){fc.clear()}function De(c){if(c.__onceStore instanceof Set)return c.__onceStore;return fc}async function us(c,e,a,r,S,n=new Set){let g=r.partialsDir||C.join(C.dirname(a),"partials");if(g&&!C.isAbsolute(g))g=C.resolve(process.cwd(),g);let t=$e(c,"@partial","@include"),D=De(e);t=t.replace(/@once([\s\S]*?)@endonce/g,(m,k,x)=>{let p=k.trim(),i=`${a}:${p}`;if(D.has(i))return"";return D.add(i),k});{let m=/@includeIf\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")")i--;_++}if(i!==0)break;let l=t.substring(p+1,_-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){m.lastIndex=_;continue}let O=o[1],z=W(O,g,a),v="";if(z&&await Bun.file(z).exists())S.add(z),v=`@include(${l})`;t=t.substring(0,x)+v+t.substring(_),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(t))!==null){let i=p.index,_=i+p[0].length-1,l=1,o=_+1;while(o<t.length&&l>0){if(t[o]==="(")l++;else if(t[o]===")")l--;o++}if(l!==0)break;let O=t.substring(_+1,o-1),z=ae(O,0);if(z===-1){x.lastIndex=o;continue}let v=O.substring(0,z).trim(),H=O.substring(z+1).trim(),F=H.match(/^\s*['"]([^'"]+)['"]/);if(!F){x.lastIndex=o;continue}let w=F[1],J=H.substring(F[0].length),j,M=ae(J,0);if(M!==-1)j=J.substring(M+1).trim();try{let A=`Boolean(${v})`,L;if(f(A)){let ie=d(A,Object.keys(e));L=Boolean(ie(...Object.values(e)))}else L=Boolean(u(A,e));let ee=k?!L:L,ne="";if(ee){let ie=W(w,g,a);if(ie&&await Bun.file(ie).exists())S.add(ie);ne=`@include('${w}'${j?`, ${j}`:""})`}t=t.substring(0,i)+ne+t.substring(o),x.lastIndex=0}catch(A){let L=A instanceof Error?A.message:String(A),ee=h("Include",`Error evaluating ${m} condition: ${L}`,a,c,i);t=t.substring(0,i)+ee+t.substring(o),x.lastIndex=0}}}{let m=/@each\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")"){if(i--,i===0)break}_++}if(i!==0)break;let l=t.substring(p+1,_),o=t.substring(x,_+1),O=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){m.lastIndex=0,t=t.replace(o,"");continue}let[,z,v,H,F]=O;try{let w,J=v.trim();if(f(J))w=d(J,Object.keys(e))(...Object.values(e));else w=u(J,e);let j="";if(Array.isArray(w)&&w.length>0)for(let M of w){let A={...e,[H]:M},L=await te(z,A,c,x);j+=L}else if(F)j=await te(F,{},c,x);t=t.substring(0,x)+j+t.substring(_+1),m.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);t=t.substring(0,x)+h("Each",`Error in @each: ${J}`,a,c,x)+t.substring(_+1),m.lastIndex=0}}}{let m=/@includeFirst\s*\(/g,k;while((k=m.exec(t))!==null){let x=k.index,p=x+k[0].length-1,i=1,_=p+1;while(_<t.length&&i>0){if(t[_]==="(")i++;else if(t[_]===")"){if(i--,i===0)break}_++}if(i!==0)break;let l=t.substring(p+1,_),o=t.substring(x,_+1),O=l.match(/^\s*(\[[^\]]+\])/);if(!O){m.lastIndex=0,t=t.replace(o,"");continue}let z=O[1],v=l.slice(O[0].length),H,F=v.match(/^\s*,\s*\{/);if(F){v=v.slice(F[0].length-1);let j=1,M=1;while(M<v.length&&j>0){if(v[M]==="{")j++;else if(v[M]==="}"){if(j--,j===0)break}M++}H=v.substring(0,M+1),v=v.slice(M+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let j=JSON.parse(z.replace(/'/g,'"')),M={};if(H)try{M=P(H,e)}catch(L){let ee=L instanceof Error?L.message:String(L);if(r.debug){let ne=h("Include",`Error parsing includeFirst variables: ${ee}`,a,c,x,o);t=t.replace(o,()=>ne)}else t=t.replace(o,()=>w||"");continue}let A=!1;for(let L of j){let ee=W(L,g,a);if(!ee)continue;if(await s(ee)){let ne=await te(L,M,c,x);t=t.replace(o,()=>ne),A=!0;break}}if(!A)if(w!==void 0)t=t.replace(o,()=>w);else if(r.debug){let L=h("Include",`None of the includeFirst paths exist: ${z}`,a,c,x,o);t=t.replace(o,()=>L)}else t=t.replace(o,"")}catch(j){let M=j instanceof Error?j.message:String(j),A=h("Include",`Error processing @includeFirst: ${M}`,a,c,x,o);t=t.replace(o,()=>A)}m.lastIndex=0}}function W(m,k,x){try{let p=m;if(!m.endsWith(".stx"))p=`${m}.stx`;let i=C.resolve(k),_=C.resolve(C.dirname(x)),l;if(!p.startsWith("./")&&!p.startsWith("../")){for(let F of r._layerPartialDirs??[]){let w=C.resolve(F,p);if(w.startsWith(`${C.resolve(F)}${C.sep}`)&&ye(w))return w}l=C.resolve(k,p)}else l=C.resolve(_,p);let o=C.normalize(l),O=o.startsWith(i+C.sep)||o===i,z=o.startsWith(_+C.sep)||o===_,v=!1,H=C.dirname(_);if(o.startsWith(H+C.sep)){if(!C.relative(H,o).split(C.sep).some((j)=>j.startsWith(".")&&j!=="."&&j!==".."))v=!0}if(!O&&!z&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${m}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${i}, ${_}`),null;return o}catch(p){return console.error(`Error resolving path ${m}: ${p}`),null}}let re=C.resolve(a);n.add(re);function N(m,k,x,p){return r.onIncludeError?.({includePath:m,templatePath:a,message:k,partialsDir:g}),h("Include",k,a,x,p)}async function te(m,k={},x,p){let i=W(m,g,a);if(!i)return N(m,`Could not resolve path for include: ${m}`,x,p);let _=C.resolve(i);if(n.has(_)){let l=[...n,_].map((o)=>C.basename(o)).join(" -> ");return N(m,`Circular include detected: ${l}`,x,p)}try{S.add(i);let l;if(!l)try{l=await Bun.file(i).text()}catch(y){let q=y instanceof Error?y.message:String(y);return N(m,`Error loading include file ${m}: ${q}`,x,p)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-3m3jny87.js");l=y(l,e)}if(l&&(r.debug||!T()&&!$n()))try{let{warnUnbalancedTags:y}=await import("./chunk-7ycmnsh5.js");y(l,i)}catch{}try{let{processESImports:y}=await import("./chunk-p2gsezmj.js");l=await y(l,e,i,r,S)}catch(y){if(r.debug)console.warn(`[stx] partial ES import extraction skipped for ${i}:`,y instanceof Error?y.message:y)}let o=l,O=pe(o);if(O)o=O.content.trim();let v=l.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),H="";if(v)H=`<style${v[1]}>${v[2]}</style>`;let F=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(y,q,b)=>{if(!me(q))return"";return F.push({attrs:q,body:b}),`__STX_DATA_BLOCK_${F.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let w={...e};w.__stx_signals_gate=ke(l,i);for(let[y,q]of Object.entries(k))w[y]=q;let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,j=[...l.matchAll(J)].sort((y,q)=>{let b=(y[1]||"").includes("server"),X=(q[1]||"").includes("server");return Number(X)-Number(b)}),M="",A=null,L=!1,ee=!1;for(let y of j){let q=y[1]||"",b=y[2]||"";if(me(q))continue;let X=q.includes("server"),be=Be(q);if(!X&&!/\bsrc\s*=/i.test(q))Ne(b,i,r.strict);if(!X&&b.trim()){let{interpolateScriptExpressions:U}=await import("./chunk-j882bpqq.js");b=U(b,w,m)}let ce="";try{let{extractAndStripCssImports:U,renderVendorStyleTags:Q}=await import("./chunk-jxzcwjx4.js"),se=U(b,{filePath:i,projectRoot:process.cwd()});b=se.code,ce=Q(se.styles)}catch(U){if(r.debug)console.warn(`[stx] vendor-css extractor skipped for ${i}:`,U instanceof Error?U.message:U)}if(be&&b.trim())b=Fe(b);if(!X){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-jxzcwjx4.js");b=Q(b).code;let{hasUserImports:se,bundleClientScript:Se}=await import("./chunk-vk9zpckc.js");if(se(b))b=await Se(b,i,{projectRoot:process.cwd()})}catch(Q){if(r.debug)console.warn(`[stx] bundler skipped for ${i}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:U}=await import("./chunk-xsavnbkv.js");b=U(b)}let ge=Ee(b);if(!X){let{extractBridgeData:U,generateServerDataBridge:Q}=await import("./chunk-jxzcwjx4.js"),se=Q(b,U(w));if(se)b=`${se}
|
|
48
48
|
${b}`}if(ge&&!X){L=!0,A=fe(i,e);let U=I(b),Q=ue(U,A);M+=`${ce}<script data-stx-scoped data-stx-run="always" data-stx-owner="${A}">${Q}</script>
|
|
49
|
-
`;continue}if(X)try{let{extractVariables:U}=await import("./chunk-
|
|
50
|
-
`}}if(F.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-
|
|
49
|
+
`;continue}if(X)try{let{extractVariables:U}=await import("./chunk-ty915d4h.js");await U(b,w,i)}catch(U){if(r.debug)console.warn(`Warning: Could not extract variables from server script in ${i}:`,U)}if(!X&&!ge){let U=q.replace(/\bclient\b/i,"").trim();A=fe(i,e);let Q=I(b),se=ue(Q,A);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(se))ee=!0;M+=`${ce}<script data-stx-scoped data-stx-run="always" data-stx-owner="${A}"${U?` ${U}`:""}>${se}</script>
|
|
50
|
+
`}}if(F.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-j882bpqq.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(q,b)=>{let X=F[Number(b)];return`<script${X.attrs}>${y(X.body,w,m)}</script>`})}if(A){let y=Te(o,A);if(o=y.html,y.mergedIntoExisting){let b=A,X=y.mergedIntoExisting;M=M.split(`'${b}'`).join(`'${X}'`).split(`"${b}"`).join(`"${X}"`),A=X}else if(!y.stamped&&L&&!le.has(i))le.add(i),console.warn(`[stx] ${C.relative(process.cwd(),i)} 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(y.stamped&&y.root!=="body"&&(L||ee)&&!de.has(i)){let b=Bf(o);if(b.length>1)de.add(i),console.warn(`[stx] ${C.relative(process.cwd(),i)} declares ${L?"signals":"bindings"} and has ${b.length} top-level elements (${b.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 q=y.stamped&&y.root!==null&&Tr(y.root);M=Ie(M,q?A:null)}if(o.includes("@include")||o.includes("@partial"))o=await us(o,w,i,r,S,n);let{processLoops:ne,reportDeferredLoopWarnings:ie}=await import("./chunk-036pnz1y.js"),G=ne(o,w,i,void 0,!0);G=oe(G,w,i),G=ie(G);let{processMetaDirectives:xe,processSeoDirective:_e,processStructuredData:we}=await import("./chunk-8k6cd1e0.js");if(G=xe(G,w,i,r),G=we(G,w,i),G=_e(G,w,i,r),G=E(G,w,i),H)G+=`
|
|
51
51
|
`+H;if(M)G+=`
|
|
52
52
|
`+M;return G}catch(l){if(l instanceof K)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(t))!==null){let m=Z.index,k=m+Z[0].length-1,x=1,p=k+1;while(p<t.length&&x>0){if(t[p]==="(")x++;else if(t[p]===")")x--;p++}if(x!==0)break;let i=t.substring(m,p),_=t.substring(k+1,p-1),l=_.match(/^\s*['"]([^'"]+)['"]/);if(!l){Y.lastIndex=p;continue}let o=l[1],O,z=_.substring(l[0].length),v=ae(z,0);if(v!==-1)O=z.substring(v+1).trim();let H={};if(O)try{H=P(O,e)}catch(w){let J=w instanceof Error?w.message:String(w);t=t.replace(i,h("Include",`Error parsing include variables for ${o}: ${J}`,a,c,m)),Y.lastIndex=0;continue}let F=await te(o,H,c,m);t=t.substring(0,m)+F+t.substring(p),Y.lastIndex=0}return t}function ds(c,e){let a=c;function r(S,n,g,t){let D=S,W=!0;while(W){W=!1;let re=new RegExp(`@${n}\\(['"]([^'"]+)['"]\\)`),N=D.match(re);if(!N||N.index===void 0)break;let te=N.index,Y=N[1],Z=te+N[0].length,m=new RegExp(`@${n}\\(`),k=new RegExp(`@${g}(?![a-z])`),x=1,p=Z,i=-1;while(x>0&&p<D.length){let l=D.slice(p),o=l.match(m),O=l.match(k),z=o?p+o.index:1/0,v=O?p+O.index:1/0;if(z<v)x++,p=z+(o[0].length||1);else if(v<1/0){if(x--,x===0){i=v;break}p=v+g.length+1}else break}if(i===-1)break;let _=D.slice(Z,i);if(!e[Y])e[Y]=[];if(t)e[Y].unshift(_);else e[Y].push(_);D=D.substring(0,te)+D.substring(i+`@${g}`.length),W=!0}return D}return a=r(a,"push","endpush",!1),a=r(a,"prepend","endprepend",!0),a}function ps(c,e){return c.replace(/@stack\(['"]([^'"]+)['"]\)/g,(a,r)=>{if(!e[r]||e[r].length===0)return"";return e[r].join(`
|
|
53
53
|
`)})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{wn,ig,ag,cg,lg,ug,m,dg,vi,pg,Zc,Qc}from"./chunk-
|
|
2
|
+
import{wn,ig,ag,cg,lg,ug,m,dg,vi,pg,Zc,Qc}from"./chunk-p4ytnee6.js";import"./chunk-ezzskm4a.js";import"./chunk-v4bqmzj9.js";import"./chunk-k47addf7.js";import"./chunk-xppm4cs4.js";import"./chunk-agbkv9ab.js";export{wn as STX_ENGINE_BINDING_NAMES,vi as convertToCommonJS,Zc as extractScriptFromTemplate,m as extractVariables,Qc as hasVariables,dg as isCompleteImport,ug as isMissingBindingFailure,cg as isModuleResolutionFailure,lg as isSyntaxFailure,pg as splitDeclaration,ig as stripTypeScript,ag as withoutStxReferrer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Tf,$f,ye,Rf,ac,rn,sn,Ph,cc,on,rr,Af,Pf,If,cs,an,Of,cn,lc,Ih}from"./chunk-
|
|
2
|
+
import{Tf,$f,ye,Rf,ac,rn,sn,Ph,cc,on,rr,Af,Pf,If,cs,an,Of,cn,lc,Ih}from"./chunk-5gfg2tqg.js";import"./chunk-69nhstnz.js";import"./chunk-hpwtjb4a.js";import"./chunk-eyp7rr70.js";import"./chunk-q5rw0d2m.js";import"./chunk-jtccqpwa.js";import"./chunk-2rg9pqmh.js";import"./chunk-0rszcb0m.js";import"./chunk-8cvgm13s.js";import"./chunk-p4ytnee6.js";import"./chunk-ezzskm4a.js";import"./chunk-v4bqmzj9.js";import"./chunk-k47addf7.js";import"./chunk-xppm4cs4.js";import"./chunk-agbkv9ab.js";export{rr as MODULE_SPECIFIER_PREFIX,Tf as bundleCacheDir,$f as bundleCacheEntryLimit,Ih as bundleClientEntriesSplit,cn as bundleClientScript,sn as clearBundleFailures,ye as clientBundleDependencies,rn as getBundleFailures,on as hasUserImports,an as moduleSubstitutionKey,Pf as normalizeRegistrySpecifiers,Of as queueClientBundleBuild,ac as recordBundleFailure,Af as registryIdForPath,cc as resolveBundlerFallback,If as rewriteRegistryImports,Ph as setBundlerFallbackMode,Rf as shouldLogBundlerDiagnostics,lc as tempBuildName,cs as withModuleSubstitutes};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Wf,Uh,Wh,qh,Kh,qf,Kf,Gh,Xh,Qo,Jh,fr,gr,ks}from"./chunk-
|
|
2
|
+
import{Wf,Uh,Wh,qh,Kh,qf,Kf,Gh,Xh,Qo,Jh,fr,gr,ks}from"./chunk-kf5fsz9b.js";import{rt}from"./chunk-car6nhfe.js";import"./chunk-p4ytnee6.js";import"./chunk-ezzskm4a.js";import"./chunk-v4bqmzj9.js";import"./chunk-k47addf7.js";import"./chunk-xppm4cs4.js";import"./chunk-agbkv9ab.js";export{Kh as __setSignalsGeneratorsForTest,rt as cacheEngineFingerprint,gr as cacheTemplate,fr as checkCache,Jh as clearDevCaches,Kf as getCachedRouterScript,qf as getCachedSignalsRuntime,Gh as getServeClientAsset,Qo as getServeModuleBundle,ks as hashFilePath,Wh as invalidateFileCache,qh as invalidateFileCacheByDir,Uh as readFileCached,Xh as registerServeModuleBundle,Wf as templateCache};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{um}from"./chunk-m9kkd9f2.js";import"./chunk-hdep0xcy.js";import"./chunk-tm1ec751.js";import"./chunk-j8f4tb4p.js";import"./chunk-69nhstnz.js";import"./chunk-4jf18yed.js";import"./chunk-e6qam3x3.js";import"./chunk-tr5r70yr.js";import"./chunk-t5q31st4.js";import"./chunk-cct2fzth.js";import"./chunk-5bbwdv4y.js";import"./chunk-j5pgwqwp.js";import"./chunk-m710wkr4.js";import"./chunk-6dqafrq5.js";import"./chunk-dy31f39m.js";import"./chunk-833y1ndd.js";import"./chunk-kf5fsz9b.js";import"./chunk-eyp7rr70.js";import"./chunk-q5rw0d2m.js";import"./chunk-jtccqpwa.js";import"./chunk-2rg9pqmh.js";import"./chunk-0rszcb0m.js";import"./chunk-8cvgm13s.js";import"./chunk-p4ytnee6.js";import"./chunk-ezzskm4a.js";import"./chunk-v4bqmzj9.js";import"./chunk-k47addf7.js";import"./chunk-xppm4cs4.js";import"./chunk-agbkv9ab.js";export{um as buildForProduction};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import R from"path";var O=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function zr(...g){let d=new Set;for(let c of g){if(!c||!c.includes("__stxModules["))continue;for(let s of c.matchAll(O))try{d.add(JSON.parse(`"${s[1]}"`))}catch{}}return[...d].sort()}function co(...g){let d=new Map,c=(s,e)=>{let r=d.get(s);if(r===null)return;if(e===null){d.set(s,null);return}let n=r??new Set;for(let i of e)n.add(i);d.set(s,n)};for(let s of g){if(!s||!s.includes("__stxModules["))continue;let e=[];for(let n of s.matchAll(/([\w$]+)\s*=\s*globalThis\.__stxModules\s*&&\s*globalThis\.__stxModules\["((?:[^"\\]|\\.)*)"\]/g)){let i;try{i=JSON.parse(`"${n[2]}"`)}catch{continue}e.push({variable:n[1],id:i,start:n.index+n[0].length,end:s.length})}let r=s.match(/__stxModules\["(?:[^"\\]|\\.)*"\]/g)?.length??0;if(e.length===0||r!==e.length){for(let n of zr(s))c(n,null);continue}for(let[n,i]of e.entries()){let p=e.slice(n+1).find((h)=>h.variable===i.variable);i.end=p?p.start:s.length}for(let n of e){let i=new Set,p=!1,h=n.variable.replace(/[$]/g,"\\$&"),o=s.slice(n.start,n.end);for(let l of o.matchAll(new RegExp(`(?<![\\w$.])${h}(?![\\w$])`,"g"))){let f=o.slice(l.index+n.variable.length,l.index+n.variable.length+200),a=/^\s*\[\s*(["'])([A-Za-z_$][\w$]*)\1\s*\]/.exec(f)??/^\s*\.\s*([A-Za-z_$][\w$]*)/.exec(f);if(a){i.add(a[a.length-1]);continue}if(/^\s*[!=]==?\s*(?:undefined|void 0)\b/.test(f))continue;p=!0;break}c(n.id,p?null:i)}}return d}function v(g,d,c){let s=[],e=[];return g.forEach((r,n)=>{let i=r.startsWith("npm:")?r.slice(4):R.resolve(d,r),p=`__stxRegistered${n}`,h=JSON.stringify(r),o=c?.get(r);if(o&&[...o].every((l)=>/^[A-Za-z_$][\w$]*$/.test(l))){let l=[...o].sort(),f=l.map((m,_)=>`${m} as ${p}_${_}`);s.push(l.length>0?`import { ${f.join(", ")} } from ${JSON.stringify(i)};`:`import ${JSON.stringify(i)};`);let a=l.map((m,_)=>`get ${JSON.stringify(m)}() { return ${p}_${_}; }`).join(", ");e.push(`if (!globalThis.__stxModules[${h}]) globalThis.__stxModules[${h}] = { ${a} };`);return}s.push(`import * as ${p} from ${JSON.stringify(i)};`),e.push(`if (!globalThis.__stxModules[${h}]) globalThis.__stxModules[${h}] = ${p};`)}),[...s,"globalThis.__stxModules = globalThis.__stxModules || {};",...e].join(`
|
|
3
|
-
`)}async function Kg(g,d={}){if(g.length===0)return null;let c=process.cwd(),s=v(g,c,d.names),e;try{let{bundleClientScript:l}=await import("./chunk-
|
|
3
|
+
`)}async function Kg(g,d={}){if(g.length===0)return null;let c=process.cwd(),s=v(g,c,d.names),e;try{let{bundleClientScript:l}=await import("./chunk-vk9zpckc.js"),f=()=>l(s,R.join(c,".stx-module-registry.ts"),{projectRoot:c,minify:d.minify,externalizeUserModules:!1,collectInputs:d.collectInputs,throwOnFailure:!0});try{e=await f()}catch(a){if(!d.names)throw a;s=v(g,c,void 0),e=await f()}}catch(l){let{formatBuildFailure:f}=await import("./chunk-1p968nww.js"),a=f(l);console.warn(`[stx] could not build the page module registry (#1957): ${a}`);let m=`[stx] the page module registry did not build, so ${g.join(", ")} cannot load (#1957): ${a}`;return`;console.error(${JSON.stringify(m)});`}let{transformAutoImports:r,generateAutoImportDestructuring:n}=await import("./chunk-jxzcwjx4.js"),i=r(e),p=n(i.stxImports,i.browserImports),{transformStoreImports:h}=await import("./chunk-f18rxz70.js");e=h(i.code);let o=JSON.stringify(new Bun.CryptoHasher("md5").update(s).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${o}]) return;`,` __stxBundles[${o}] = true;`,p,e,"})();"].join(`
|
|
4
4
|
`)}var P=/^import(?:[ \t]*(\{[^}]*\})[ \t]*from|[ \t]*\*[ \t]*as[ \t]+([\w$]+)[ \t]+from)?[ \t]*["']\.\/(chunk-[\w-]+)\.js["'][ \t]*;?[ \t]*$/gm,j=/^export\s*\{([^}]*)\}\s*;?[ \t]*$/gm,I=new Set(["__preload","__chunks"]),N=/^("[^"]*"|[\w$]+)(?:\s+as\s+("[^"]*"|[\w$]+))?$/;function J(g){let d=[],c=[],s=!0,r=g.replace(/^var __chunkGraphs;[\s\S]*?^var __chunks = [\s\S]*?^\};[ \t]*\n?/m,"").replace(/^__chunks\(import\.meta\.url,[^\n]*\);[ \t]*\n?/gm,"").replace(P,(h,o,l,f)=>{let a=`__stxChunkExports${d.length}`;if(d.push(f),c.push(`var ${a} = __stxChunk(${JSON.stringify(f)});`),l)c.push(`var ${l} = ${a};`);else if(o)for(let m of o.slice(1,-1).split(",")){let _=m.trim();if(!_)continue;let w=N.exec(_);if(!w){s=!1;continue}if(I.has(w[1]))continue;let M=w[1].startsWith('"')?JSON.parse(w[1]):w[1],t=w[2]??w[1];if(t.startsWith('"')){s=!1;continue}c.push(`var ${t} = ${a}[${JSON.stringify(M)}];`)}return""});if(!s)throw Error("an import it does not read");let n=[];r=r.replace(/\(\s*__preload\([^)]*\)\s*,\s*import\(\s*["']\.\/(chunk-[\w-]+)\.js["']\s*\)\s*\)|\bimport\(\s*["']\.\/(chunk-[\w-]+)\.js["']\s*\)/g,(h,o,l)=>{let f=o??l;return n.push(f),`Promise.resolve().then(function () { return __stxChunk(${JSON.stringify(f)}); })`});let i=[];r=r.replace(j,(h,o)=>{for(let l of o.split(",")){let f=l.trim();if(!f)continue;let a=N.exec(f);if(!a||a[1].startsWith('"')){s=!1;continue}if(I.has(a[1]))continue;let m=a[2]??a[1];i.push([a[1],m.startsWith('"')?JSON.parse(m):m])}return""});let p=[/\bimport\.meta\b/,/\b__chunks\b/,/\b__preload\b/,/^\s*export\s+(?:default\b|const\b|let\b|var\b|function\b|class\b|async\b|\*|\{)/m,/\bfrom\s*["']\.\/chunk-/,/^\s*import\s*["']\.\/chunk-/m].find((h)=>h.test(r));if(!s||p)throw Error(`${p?`${p.source} is left in it`:"an export it does not read"}`);return{reads:c.join(`
|
|
5
5
|
`),chunks:d,lazy:n,body:r,exports:i}}function Il(g){if(/\bexport\s+(?:let|var)\b/.test(g))return!0;if(g.length/Math.max(1,g.split(`
|
|
6
|
-
`).length)>200)return!1;for(let d of g.matchAll(/\bexport\s*\{([^}]*)\}(?!\s*from\b)/g))for(let c of d[1].split(",")){let s=c.trim().split(/\s+as\s+/)[0].trim();if(!/^[A-Za-z_$][\w$]*$/.test(s))continue;let e=s.replace(/[$]/g,"\\$&");if(!new RegExp(`(?<![\\w$.])(?:let|var)\\s+${e}(?![\\w$])`,"g").test(g))continue;let n=new RegExp(`(?<![\\w$.])${e}\\s*(?:=(?![=>])|[-+*/%&|^]=|\\*\\*=|<<=|>>>?=|&&=|\\|\\|=|\\?\\?=|\\+\\+|--)|(?:\\+\\+|--)\\s*${e}(?![\\w$])`,"g"),i=new RegExp(`(?<![\\w$.])(?:let|var|const)\\s+${e}\\s*=`,"g");if((g.match(n)?.length??0)>(g.match(i)?.length??0))return!0}return!1}async function lo(g,d={}){let c=g.filter((e)=>e.ids.length>0);if(c.length===0)return{chunks:new Map,routes:new Map,reads:new Map};let s=process.cwd();try{let{bundleClientEntriesSplit:e}=await import("./chunk-
|
|
6
|
+
`).length)>200)return!1;for(let d of g.matchAll(/\bexport\s*\{([^}]*)\}(?!\s*from\b)/g))for(let c of d[1].split(",")){let s=c.trim().split(/\s+as\s+/)[0].trim();if(!/^[A-Za-z_$][\w$]*$/.test(s))continue;let e=s.replace(/[$]/g,"\\$&");if(!new RegExp(`(?<![\\w$.])(?:let|var)\\s+${e}(?![\\w$])`,"g").test(g))continue;let n=new RegExp(`(?<![\\w$.])${e}\\s*(?:=(?![=>])|[-+*/%&|^]=|\\*\\*=|<<=|>>>?=|&&=|\\|\\|=|\\?\\?=|\\+\\+|--)|(?:\\+\\+|--)\\s*${e}(?![\\w$])`,"g"),i=new RegExp(`(?<![\\w$.])(?:let|var|const)\\s+${e}\\s*=`,"g");if((g.match(n)?.length??0)>(g.match(i)?.length??0))return!0}return!1}async function lo(g,d={}){let c=g.filter((e)=>e.ids.length>0);if(c.length===0)return{chunks:new Map,routes:new Map,reads:new Map};let s=process.cwd();try{let{bundleClientEntriesSplit:e}=await import("./chunk-vk9zpckc.js"),r=[],n=await e(new Map(c.map((t)=>[t.name,v(t.ids,s,t.names)])),{projectRoot:s,filePath:R.join(s,".stx-module-registry.ts"),collectInputs:r});d.collectInputs?.push(...r);let{transformAutoImports:i,generateAutoImportDestructuring:p}=await import("./chunk-jxzcwjx4.js"),{transformStoreImports:h}=await import("./chunk-f18rxz70.js"),o=new Map;for(let[t,u]of[...n.chunks,...n.entries])try{o.set(t,J(u))}catch(b){throw Error(`cannot read ${t}: ${b instanceof Error?b.message:String(b)}`)}for(let[t,u]of[...n.chunks,...n.entries])if(/\b__esm\(/.test(u))throw Error(`${t} initialises a module lazily`);for(let t of r)if(/\.(?:[cm]?[jt]sx?)$/.test(t)&&Il(await Bun.file(t).text()))throw Error(`${t} exports a binding that changes after it is read`);let l=new Set,f=new Set,a=(t)=>{if(f.has(t))return;if(l.has(t))throw Error(`the chunks import each other (${t})`);l.add(t);for(let u of o.get(t)?.chunks??[]){if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);a(u)}for(let u of o.get(t)?.lazy??[])if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);l.delete(t),f.add(t)};for(let t of o.keys())a(t);let m=(t)=>{let u=i(t.body);return{prelude:p(u.stxImports,u.browserImports),body:h(u.code)}},_=new Map;for(let t of n.chunks.keys()){let u=o.get(t),{prelude:b,body:k}=m(u),y=u.exports.map(([S,x])=>`get ${JSON.stringify(x)}() { return ${S}; }`).join(", ");_.set(t,`function (__stxChunk) {
|
|
7
7
|
${b}
|
|
8
8
|
${u.reads}
|
|
9
9
|
${k}
|