@stacksjs/stx 0.2.195 → 0.2.196
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-0ae6chzd.js +4 -0
- package/dist/chunk-0w0mrtme.js +2 -0
- package/dist/chunk-0y46fbkx.js +3 -0
- package/dist/chunk-118a77bs.js +4471 -0
- package/dist/chunk-12nvcvtn.js +3 -0
- package/dist/chunk-14ynv5ah.js +2 -0
- package/dist/chunk-1e25ksp6.js +3 -0
- package/dist/chunk-1mhc4g86.js +43 -0
- package/dist/chunk-1thssz8x.js +2 -0
- package/dist/chunk-1yk07x7b.js +2 -0
- package/dist/chunk-2zkj69dg.js +13 -0
- package/dist/chunk-338316c2.js +2 -0
- package/dist/chunk-3952ykhb.js +1655 -0
- package/dist/chunk-3es366z4.js +3 -0
- package/dist/chunk-3m49eb4v.js +2 -0
- package/dist/chunk-3nmpfsw5.js +2 -0
- package/dist/chunk-3vy1q9da.js +2 -0
- package/dist/chunk-4a4h28pp.js +3022 -0
- package/dist/chunk-4pf61rcb.js +2 -0
- package/dist/chunk-5anpcnde.js +2 -0
- package/dist/chunk-5mkkre22.js +505 -0
- package/dist/chunk-5n0dt838.js +2 -0
- package/dist/chunk-5s2y052b.js +2 -0
- package/dist/chunk-5v64c8tr.js +2 -0
- package/dist/chunk-5xd7vge2.js +2 -0
- package/dist/chunk-6bxcjdp4.js +2 -0
- package/dist/chunk-6msvxnbr.js +2 -0
- package/dist/chunk-7kger0se.js +1280 -0
- package/dist/chunk-7ry55nms.js +3 -0
- package/dist/chunk-7s0wfa4e.js +24 -0
- package/dist/chunk-7w4c5w2b.js +2 -0
- package/dist/chunk-8src5smc.js +15 -0
- package/dist/chunk-937effkz.js +2 -0
- package/dist/chunk-9b82d4g5.js +3 -0
- package/dist/chunk-9xh78snm.js +3 -0
- package/dist/chunk-a2899x2t.js +2 -0
- package/dist/chunk-abpw3b39.js +2 -0
- package/dist/chunk-avwj12at.js +194 -0
- package/dist/chunk-b6jhznkh.js +71 -0
- package/dist/chunk-bpa2jeyw.js +3 -0
- package/dist/chunk-cbc56wpd.js +3 -0
- package/dist/chunk-dhpy0h9y.js +2 -0
- package/dist/chunk-dtmwr674.js +302 -0
- package/dist/chunk-dxfcyj8t.js +2 -0
- package/dist/chunk-e0460y7f.js +29 -0
- package/dist/chunk-ede7zpjf.js +2 -0
- package/dist/chunk-ehfzp7xe.js +2 -0
- package/dist/chunk-fd77g6t6.js +2 -0
- package/dist/chunk-fnkxbnka.js +30 -0
- package/dist/chunk-fvjh7rx0.js +84 -0
- package/dist/chunk-g19skgmw.js +18 -0
- package/dist/chunk-gcnrdgrq.js +3 -0
- package/dist/chunk-h2wpnxrh.js +8 -0
- package/dist/chunk-hb83d0qc.js +2 -0
- package/dist/chunk-hncp9gz6.js +8 -0
- package/dist/chunk-ht51fz7w.js +4 -0
- package/dist/chunk-hyrjade7.js +321 -0
- package/dist/chunk-hyyzp99b.js +2 -0
- package/dist/chunk-jpbk42j7.js +2 -0
- package/dist/chunk-jr5tp4ks.js +2 -0
- package/dist/chunk-k03b9z9e.js +898 -0
- package/dist/chunk-kjr22neh.js +3 -0
- package/dist/chunk-mjt5e2jy.js +2 -0
- package/dist/chunk-mkm91b6w.js +2 -0
- package/dist/chunk-mtr2f82n.js +2 -0
- package/dist/chunk-n8zpm7xb.js +397 -0
- package/dist/chunk-ndnc7k2n.js +22 -0
- package/dist/chunk-nenge2m2.js +2 -0
- package/dist/chunk-nngpktr2.js +2 -0
- package/dist/chunk-nsjyn31z.js +2 -0
- package/dist/chunk-nye9brje.js +147 -0
- package/dist/chunk-p5kp35dy.js +2 -0
- package/dist/chunk-pw0rzgpv.js +3 -0
- package/dist/chunk-q020t182.js +2 -0
- package/dist/chunk-q4gp9egt.js +4 -0
- package/dist/chunk-q8szpd6w.js +3 -0
- package/dist/chunk-q9n5swx7.js +3 -0
- package/dist/chunk-qpcwahse.js +2 -0
- package/dist/chunk-qz75kx6n.js +231 -0
- package/dist/chunk-r41nsgym.js +116 -0
- package/dist/chunk-r4qnvxhv.js +18 -0
- package/dist/chunk-r6p4ws0a.js +3809 -0
- package/dist/chunk-rdf7d42n.js +2 -0
- package/dist/chunk-rs2fa3g1.js +2 -0
- package/dist/chunk-ryjpp51z.js +499 -0
- package/dist/chunk-s018d32j.js +30 -0
- package/dist/chunk-spn8e3b3.js +2 -0
- package/dist/chunk-sry9atvv.js +2 -0
- package/dist/chunk-st5qggks.js +3 -0
- package/dist/chunk-tywvd1zc.js +11 -0
- package/dist/chunk-v3ryxw4v.js +2 -0
- package/dist/chunk-va9k88da.js +2 -0
- package/dist/chunk-vgk5v31k.js +216 -0
- package/dist/chunk-vj320kyr.js +2 -0
- package/dist/chunk-vr3qtsj4.js +2 -0
- package/dist/chunk-w0ng9e1m.js +341 -0
- package/dist/chunk-w29sv5jf.js +2 -0
- package/dist/chunk-whq99ytc.js +7987 -0
- package/dist/chunk-wnaddtv3.js +288 -0
- package/dist/chunk-wtengj6h.js +2 -0
- package/dist/chunk-x0ks1fer.js +1194 -0
- package/dist/chunk-x0zh76yv.js +4 -0
- package/dist/chunk-x13f5bbe.js +358 -0
- package/dist/chunk-xfp10a23.js +2 -0
- package/dist/chunk-xp3fp266.js +11 -0
- package/dist/chunk-xz019t7t.js +2 -0
- package/dist/chunk-y35rktea.js +12 -0
- package/dist/chunk-y4hkqsgw.js +4 -0
- package/dist/chunk-yab6d6kb.js +28 -0
- package/dist/chunk-yckd6ks5.js +3 -0
- package/dist/chunk-ycn1vnv2.js +5 -0
- package/dist/chunk-yf3bmmkk.js +8 -0
- package/dist/chunk-ygr11tgz.js +3 -0
- package/dist/chunk-ymccpdg6.js +351 -0
- package/dist/chunk-yr2wc2pa.js +3 -0
- package/dist/chunk-yv340gxj.js +2 -0
- package/dist/chunk-z2sp0k8d.js +3 -0
- package/dist/chunk-z5cm0bwn.js +11 -0
- package/dist/chunk-zda3hvde.js +14 -0
- package/dist/chunk-zgvga8rc.js +5 -0
- package/dist/chunk-zqbw8zqq.js +3 -0
- package/dist/cli.js +108 -27481
- package/dist/craft-entry.js +9 -5
- package/dist/craft.js +7 -18503
- package/dist/database.js +2 -2
- package/dist/pwa.js +8 -16603
- package/dist/ssg.js +52 -15512
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var{defineProperty:e,getOwnPropertyNames:g,getOwnPropertyDescriptor:h}=Object,i=Object.prototype.hasOwnProperty;function j(a){return this[a]}var m=(a)=>{var b=(f??=new WeakMap).get(a),c;if(b)return b;if(b=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function"){for(var d of g(a))if(!i.call(b,d))e(b,d,{get:j.bind(a,d),enumerable:!(c=h(a,d))||c.enumerable})}return f.set(a,b),b},f;var k=(a)=>a;function l(a,b){this[a]=k.bind(null,b)}var n=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0,configurable:!0,set:l.bind(b,c)})};var o=(a,b)=>()=>(a&&(b=a(a=0)),b);var p=import.meta.require;
|
|
3
|
+
export{m as eu,n as fu,o as gu,p as hu};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ir as a,Jr as b,Kr as c,Lr as d,Mr as e,Nr as f}from"./chunk-r6p4ws0a.js";import"./chunk-8src5smc.js";import"./chunk-gcnrdgrq.js";import"./chunk-xp3fp266.js";import"./chunk-nye9brje.js";import"./chunk-tywvd1zc.js";import"./chunk-cbc56wpd.js";import"./chunk-x0zh76yv.js";import"./chunk-0ae6chzd.js";import"./chunk-kjr22neh.js";import"./chunk-3952ykhb.js";import"./chunk-dtmwr674.js";import"./chunk-pw0rzgpv.js";export{f as validateConfig,b as resolveStxDirectories,c as loadStxConfig,e as defineStxConfig,a as defaultConfig,d as config};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Cg as a}from"./chunk-ndnc7k2n.js";import{Og as n,Qg as FF,Rg as YF,Sg as ZF}from"./chunk-s018d32j.js";import{xj as C,yj as D}from"./chunk-whq99ytc.js";import{Ak as XF,yk as JF,zk as QF}from"./chunk-yckd6ks5.js";import{Ir as c,Kr as N,Np as o,Up as e,Vp as t,Yl as l,_l as d,lq as u,zp as r}from"./chunk-r6p4ws0a.js";import{Gs as s}from"./chunk-tywvd1zc.js";import{Xt as S,Zt as zF}from"./chunk-3952ykhb.js";import G from"fs";import Z from"path";import{createHash as WF}from"crypto";zF();function g(J){return WF("sha256").update(J).digest("hex").slice(0,8)}function f(J=!1){let q=J?D():C(),z=g(q);return{content:q,filename:`runtime.${z}.js`,hash:z}}function m(){let J=S(),q=g(J);return{content:J,filename:`router.${q}.js`,hash:q}}function KF(J){return{runtimeTag:J.runtime?`<script src="/__stx/${J.runtime.filename}"></script>`:"",routerTag:J.router?`<script src="/__stx/${J.router.filename}"></script>`:"",cssTag:J.css?`<link rel="stylesheet" href="/__stx/${J.css.filename}">`:""}}import h from"path";import{createHash as $F}from"crypto";function GF(J={}){let q=new Set;return{context:new Proxy(J,{get(Q,X){if(X in Q)return Q[X];if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return},has(Q,X){if(X in Q)return!0;if(typeof X==="string"&&!X.startsWith("__"))q.add(X);return!1}}),accessedKeys:q}}async function p(J,q,z={}){let Q=h.resolve(J),X=await Bun.file(Q).text(),I=$F("sha256").update(X).digest("hex").slice(0,16);l();let K={};try{K=await N()}catch{}let B=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(X))!==null){let $=k[1];if(/\bserver\b/.test($))B.push(k[2])}let W=new Set(B.flatMap(($)=>a($))),{context:E}=GF({__filename:Q,__dirname:h.dirname(Q),__stx_serverDeclared:W}),L=new Set,_={...c,...K,...z,buildMode:"compile",strict:!1},w=await u(X,E,Q,_,L),U=n(w),H=d();return{route:q,sourceFile:J,html:w,fragment:U,placeholders:H,hasServerScripts:B.length>0,serverScriptContent:B,dependencies:Array.from(L),contentHash:I,streamTemplates:E.__streamTemplates}}var VF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function i(J,q){let z=0,Q=0;if(!G.existsSync(J))return{copied:z,bytes:Q};G.mkdirSync(q,{recursive:!0});function X(I,K){let B=G.readdirSync(I,{withFileTypes:!0});for(let V of B){if(VF.has(V.name))continue;let k=Z.join(I,V.name),W=Z.join(K,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),X(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),z++,Q+=G.statSync(W).size}}}return X(J,q),{copied:z,bytes:Q}}async function mF(J={}){let q=Date.now(),z=Z.resolve(J.root||process.cwd()),Q=Z.resolve(z,J.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await N()}catch{}let I=J.componentsDir??X.componentsDir??"components",K=J.partialsDir??X.partialsDir??"partials",B=J.layoutsDir??X.layoutsDir??"layouts",V=J.publicDir??X.publicDir??"public",k=X.app?.head||{},W=X.app?.colorMode,E=X.router?.container||"main";if(G.existsSync(Q))G.rmSync(Q,{recursive:!0});let L=[Z.join(Q,"public","__stx"),Z.join(Q,"public","assets"),Z.join(Q,"server","pages"),Z.join(Q,"server","fragments")];for(let Y of L)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let _=t(z),w=["components","layouts","partials"],U=_.filter((Y)=>{return!w.some((F)=>Y.pattern.startsWith(`/${F}/`)||Y.pattern===`/${F}`)});console.log(`[stx build] Found ${U.length} page routes (${_.length-U.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=f(J.debug),$=m();await Bun.write(Z.join(Q,"public","__stx",H.filename),H.content),await Bun.write(Z.join(Q,"public","__stx",$.filename),$.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${$.filename} (${($.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],j=[];for(let Y of U)try{let F=await p(Y.filePath,Y.pattern,{componentsDir:I,partialsDir:K,layoutsDir:B,debug:J.debug});if(O.push(F),F.html=F.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,$.filename),F.html=e(F.html,k,{bodyScripts:[`<script src="/__stx/${$.filename}"></script>`],...W&&{colorMode:W}}),W)F.html=r(F.html,W);if(k.htmlAttrs)F.html=o(F.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(F.html)){let T=F.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(T&&T[1]){let P=T[1];F.html=F.html.replace(" "+P,""),F.html=F.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}F.html=F.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),F.html=await s(F.html),F.fragment=FF(F.html,E);let y=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),b=Z.join("server","pages",`${y}.compiled.json`),A=Z.join("server","fragments",`${y}.html`);await Bun.write(Z.join(Q,b),JSON.stringify(F,null,2)),await Bun.write(Z.join(Q,A),F.fragment),j.push({pattern:Y.pattern,compiledPath:b,fragmentPath:A,isDynamic:F.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("[")}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(F){console.error(`[stx build] \u2717 ${Y.pattern}:`,F instanceof Error?F.message:F)}let M=Z.resolve(z,V);if(G.existsSync(M)){let{copied:Y,bytes:F}=i(M,Z.join(Q,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${V}/`)}let v=XF(z);if(v){let{copied:Y,bytes:F}=i(v,Z.join(Q,"public",QF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(F/1024).toFixed(1)}KB) from ${JF}/`)}let R={runtime:H.filename,router:$.filename},qF=YF(j,R,Q);ZF(qF,Q);let x=Date.now()-q;return console.log(`
|
|
3
|
+
[stx build] Done in ${x}ms \u2014 ${O.length} pages compiled`),{pageCount:O.length,assets:R,outputDir:Q,duration:x}}
|
|
4
|
+
export{g as sg,f as tg,m as ug,KF as vg,p as wg,mF as xg};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{createHash as Y}from"crypto";import{readFile as M,stat as w}from"fs/promises";async function G(q){try{let z=await M(q);return Y("sha256").update(z).digest("hex").slice(0,16)}catch{return""}}function u(q){return Y("sha256").update(q).digest("hex").slice(0,16)}function $(q){return Y("sha256").update(q).digest("hex").slice(0,16)}function X(q,z){let B=JSON.stringify(z,Object.keys(z).sort());return`${$(q)}-${$(B)}`}async function Z(q){try{return(await w(q)).mtimeMs}catch{return 0}}async function b(q){try{return await w(q),!0}catch{return!1}}import{mkdir as S,readFile as V,writeFile as E,readdir as A,rm as _,stat as j}from"fs/promises";import{join as U,dirname as x}from"path";var R=new Map,W={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500};async function F(q){try{await S(q,{recursive:!0})}catch{}}function K(q,z,B){return U(q,B,`${z}.json`)}async function v(q,z,B){if((Date.now()-q.createdAt)/86400000>B)return!1;if(await Z(z)!==q.srcMtime)return!1;return!0}async function g(q,z,B,J=W){if(!J.enabled)return null;let I=X(q,z),L=R.get(I);if(L){if(await v(L,q,J.maxAge))return L.lastAccessedAt=Date.now(),L.data;R.delete(I)}let Q=K(J.directory,I,B);if(await b(Q))try{let N=await V(Q,"utf-8"),O=JSON.parse(N);if(await v(O,q,J.maxAge))return O.lastAccessedAt=Date.now(),R.set(I,O),O.data}catch{}return null}async function l(q,z,B,J,I=W){if(!I.enabled)return;let L=X(q,z),Q=await G(q),N=await Z(q),O={key:L,src:q,srcHash:Q,srcMtime:N,optionsHash:X("",z),data:B,createdAt:Date.now(),lastAccessedAt:Date.now()};R.set(L,O);let T=K(I.directory,L,J);try{await F(x(T)),await E(T,JSON.stringify(O,null,2))}catch(H){console.warn(`[stx-media] Failed to write cache: ${H}`)}}async function m(q,z=W){if(q==="all")R.clear();else R.clear();let B=q==="all"?["image","video"]:[q];for(let J of B){let I=U(z.directory,J);try{await _(I,{recursive:!0,force:!0})}catch{}}}async function y(q=W){let z={memoryEntries:R.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let B of["image","video"]){let J=U(q.directory,B);try{let I=await A(J);z.diskEntries[B]=I.length;for(let L of I){let Q=U(J,L),N=await j(Q);z.totalSizeMB+=N.size/1048576}}catch{}}return z}async function f(q=W){let z=0,B=q.maxAge*24*60*60*1000;for(let J of["image","video"]){let I=U(q.directory,J);try{let L=await A(I);for(let Q of L){let N=U(I,Q);try{let O=await V(N,"utf-8"),T=JSON.parse(O);if(Date.now()-T.createdAt>B)await _(N),R.delete(T.key),z++}catch{await _(N).catch(()=>{}),z++}}}catch{}}return z}
|
|
3
|
+
export{G as Fh,u as Gh,$ as Hh,X as Ih,Z as Jh,b as Kh,g as Lh,l as Mh,m as Nh,y as Oh,f as Ph};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import N from"path";var D=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],E=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],H={file:"title",order:"asc",groups:[]},L={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:H,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:D,backgroundPresets:E,autoApplyContrastColor:!1,port:6006};function I(q){let j={...L,...q};return{enabled:j.enabled??!0,outDir:j.outDir??".stx/dist/story",storyMatch:j.storyMatch??["**/*.story.stx"],storyIgnored:j.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...H,...j.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...j.theme},responsivePresets:j.responsivePresets??D,backgroundPresets:j.backgroundPresets??E,autoApplyContrastColor:j.autoApplyContrastColor??!1,setupFile:j.setupFile,port:j.port??6006}}async function Y(q){let j=q.root??process.cwd(),z;try{let A=await import(N.join(j,"stx.config.ts"));z=(A.default||A).story}catch{}let J={...z,...q.config},K=I(J);return{root:j,config:K,storyFiles:[],tree:void 0,mode:q.mode}}function Z(q,j){q.storyFiles=j}function _(q,j){q.tree=j}
|
|
3
|
+
export{Y as l,Z as m,_ as n};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hf as t,If as u,Jf as v,Kf as w,Lf as x,Mf as y,Nf as z,Of as A,Pf as B,Qf as C,Rf as D,Sf as E}from"./chunk-1mhc4g86.js";import{Tf as r,Uf as s}from"./chunk-1e25ksp6.js";import{bg as b,cg as c,dg as d,eg as e,fg as f,gg as g,hg as h,jg as i,kg as j,lg as k,mg as l,ng as m,og as n,pg as o,qg as p,rg as q}from"./chunk-ygr11tgz.js";import{eh as a}from"./chunk-z2sp0k8d.js";import"./chunk-nye9brje.js";import"./chunk-pw0rzgpv.js";export{D as writeImageManifest,a as rewriteImagesWithSiblings,t as renderImageComponent,v as processImageComponents,g as processImage,u as parseImageComponent,A as optimizeImage,B as optimizeDirectory,e as isSharpAvailable,m as isImageFile,f as isImageBackendAvailable,y as imageDirective,r as handleImageRequest,l as groupVariantsByFormat,o as getTotalSize,n as getMimeType,h as getImageMetadata,k as getFallbackVariant,i as generateSrcSet,j as generateSizes,C as generateImageManifest,p as formatSize,E as defaultImageConfig,z as createImagePlugin,s as createImageHandler,x as createImageDirective,w as clearImageCache,q as ImageProcessingError,b as DEFAULT_WIDTHS,d as DEFAULT_QUALITY,c as DEFAULT_FORMATS};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./chunk-pw0rzgpv.js";var N=0;function P(){return`eb-${++N}-${Date.now().toString(36)}`}function W(q,z={},A){let j=/@errorBoundary(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@enderrorBoundary/gi;return q.replace(j,(D,F,J,K)=>{let L=P(),M=Q(F||"");return T(L,J.trim(),K.trim(),M)})}function Q(q){let z={},A=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\w+))/g,j;while((j=A.exec(q))!==null){let D=j[1],F=j[2]||j[3]||j[4];switch(D){case"id":z.id=F;break;case"logErrors":z.logErrors=F==="true";break}}return z}function T(q,z,A,j){let D=j.logErrors!==!1;return`
|
|
3
|
+
<div class="stx-error-boundary" data-boundary-id="${q}" data-has-error="false">
|
|
4
|
+
<div class="stx-error-boundary-content" data-boundary-content="${q}">
|
|
5
|
+
${z}
|
|
6
|
+
</div>
|
|
7
|
+
<div class="stx-error-boundary-fallback" data-boundary-fallback="${q}" style="display: none;">
|
|
8
|
+
${A}
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
<script>
|
|
12
|
+
(function() {
|
|
13
|
+
const boundaryId = '${q}';
|
|
14
|
+
const logErrors = ${D};
|
|
15
|
+
const boundary = document.querySelector('[data-boundary-id="' + boundaryId + '"]');
|
|
16
|
+
const contentEl = document.querySelector('[data-boundary-content="' + boundaryId + '"]');
|
|
17
|
+
const fallbackEl = document.querySelector('[data-boundary-fallback="' + boundaryId + '"]');
|
|
18
|
+
|
|
19
|
+
if (!boundary || !contentEl || !fallbackEl) return;
|
|
20
|
+
|
|
21
|
+
// Error state
|
|
22
|
+
let hasError = false;
|
|
23
|
+
let lastError = null;
|
|
24
|
+
|
|
25
|
+
// Show error fallback
|
|
26
|
+
function showFallback(error) {
|
|
27
|
+
hasError = true;
|
|
28
|
+
lastError = error;
|
|
29
|
+
boundary.setAttribute('data-has-error', 'true');
|
|
30
|
+
contentEl.style.display = 'none';
|
|
31
|
+
fallbackEl.style.display = '';
|
|
32
|
+
|
|
33
|
+
if (logErrors) {
|
|
34
|
+
console.error('[stx:errorBoundary:' + boundaryId + ']', error);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Dispatch error event
|
|
38
|
+
boundary.dispatchEvent(new CustomEvent('stx:error', {
|
|
39
|
+
detail: { error: error, boundaryId: boundaryId },
|
|
40
|
+
bubbles: true
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Retry function (resets the boundary)
|
|
45
|
+
function retry() {
|
|
46
|
+
hasError = false;
|
|
47
|
+
lastError = null;
|
|
48
|
+
boundary.setAttribute('data-has-error', 'false');
|
|
49
|
+
contentEl.style.display = '';
|
|
50
|
+
fallbackEl.style.display = 'none';
|
|
51
|
+
|
|
52
|
+
// Dispatch retry event
|
|
53
|
+
boundary.dispatchEvent(new CustomEvent('stx:retry', {
|
|
54
|
+
detail: { boundaryId: boundaryId },
|
|
55
|
+
bubbles: true
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Expose retry function
|
|
60
|
+
window['$stxRetry_' + boundaryId.replace(/-/g, '_')] = retry;
|
|
61
|
+
|
|
62
|
+
// Make $retry available within the fallback
|
|
63
|
+
fallbackEl.querySelectorAll('[onclick*="$retry"]').forEach(function(el) {
|
|
64
|
+
const onclick = el.getAttribute('onclick');
|
|
65
|
+
if (onclick) {
|
|
66
|
+
el.setAttribute('onclick', onclick.replace(/\\$retry\\(\\)/g, "window['$stxRetry_" + boundaryId.replace(/-/g, '_') + "']()"));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Handle @click="$retry()" syntax
|
|
71
|
+
fallbackEl.querySelectorAll('[\\\\@click*="$retry"]').forEach(function(el) {
|
|
72
|
+
el.addEventListener('click', function(e) {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
retry();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Also check for data-onclick
|
|
79
|
+
fallbackEl.querySelectorAll('[data-onclick*="$retry"]').forEach(function(el) {
|
|
80
|
+
el.addEventListener('click', function(e) {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
retry();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Catch errors in content
|
|
87
|
+
contentEl.addEventListener('error', function(e) {
|
|
88
|
+
showFallback(e.error || new Error('Unknown error'));
|
|
89
|
+
}, true);
|
|
90
|
+
|
|
91
|
+
// Wrap global error handler for this boundary
|
|
92
|
+
const originalOnError = window.onerror;
|
|
93
|
+
window.onerror = function(message, source, lineno, colno, error) {
|
|
94
|
+
// Check if error originated from within this boundary
|
|
95
|
+
if (contentEl.contains(document.activeElement) || isErrorFromBoundary(error)) {
|
|
96
|
+
showFallback(error || new Error(String(message)));
|
|
97
|
+
return true; // Prevent default handling
|
|
98
|
+
}
|
|
99
|
+
if (originalOnError) {
|
|
100
|
+
return originalOnError.apply(this, arguments);
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Helper to check if error is from this boundary (basic heuristic)
|
|
106
|
+
function isErrorFromBoundary(error) {
|
|
107
|
+
if (!error || !error.stack) return false;
|
|
108
|
+
return error.stack.includes(boundaryId);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Expose error info
|
|
112
|
+
window.STX = window.STX || {};
|
|
113
|
+
window.STX.errorBoundaries = window.STX.errorBoundaries || {};
|
|
114
|
+
window.STX.errorBoundaries[boundaryId] = {
|
|
115
|
+
hasError: function() { return hasError; },
|
|
116
|
+
getError: function() { return lastError; },
|
|
117
|
+
retry: retry,
|
|
118
|
+
showFallback: showFallback
|
|
119
|
+
};
|
|
120
|
+
})();
|
|
121
|
+
</script>
|
|
122
|
+
`}async function U(q,z,A){try{return await q()}catch(j){if(A)A(j instanceof Error?j:Error(String(j)));else console.error("[stx:errorBoundary] SSR Error:",j);return z}}function X(q,z={}){let A=z.onError?(j)=>z.onError(j,{timestamp:Date.now(),boundaryId:"ssr"}):void 0;return(j)=>U(j,q,A)}function Y(){return`
|
|
123
|
+
/* STX Error Boundary Styles */
|
|
124
|
+
.stx-error-boundary {
|
|
125
|
+
position: relative;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.stx-error-boundary[data-has-error="true"] .stx-error-boundary-content {
|
|
129
|
+
display: none;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.stx-error-boundary[data-has-error="true"] .stx-error-boundary-fallback {
|
|
133
|
+
display: block !important;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Default fallback styling (can be overridden) */
|
|
137
|
+
.stx-error-boundary-fallback {
|
|
138
|
+
padding: 1rem;
|
|
139
|
+
border: 1px solid #ef4444;
|
|
140
|
+
border-radius: 0.5rem;
|
|
141
|
+
background-color: #fef2f2;
|
|
142
|
+
color: #991b1b;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.stx-error-boundary-fallback button {
|
|
146
|
+
margin-top: 0.5rem;
|
|
147
|
+
padding: 0.5rem 1rem;
|
|
148
|
+
border: 1px solid #ef4444;
|
|
149
|
+
border-radius: 0.25rem;
|
|
150
|
+
background-color: #ef4444;
|
|
151
|
+
color: white;
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.stx-error-boundary-fallback button:hover {
|
|
156
|
+
background-color: #dc2626;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* Dark mode support */
|
|
160
|
+
@media (prefers-color-scheme: dark) {
|
|
161
|
+
.stx-error-boundary-fallback {
|
|
162
|
+
background-color: #450a0a;
|
|
163
|
+
color: #fecaca;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
`}function Z(){return`
|
|
167
|
+
// STX Error Boundary Runtime
|
|
168
|
+
(function() {
|
|
169
|
+
if (typeof window === 'undefined') return;
|
|
170
|
+
|
|
171
|
+
window.STX = window.STX || {};
|
|
172
|
+
window.STX.errorBoundaries = window.STX.errorBoundaries || {};
|
|
173
|
+
|
|
174
|
+
// Create an error boundary programmatically
|
|
175
|
+
window.STX.createErrorBoundary = function(element, options) {
|
|
176
|
+
options = options || {};
|
|
177
|
+
const boundaryId = 'eb-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2);
|
|
178
|
+
|
|
179
|
+
let hasError = false;
|
|
180
|
+
let lastError = null;
|
|
181
|
+
let fallbackContent = options.fallback || '<p>Something went wrong</p>';
|
|
182
|
+
|
|
183
|
+
const contentWrapper = document.createElement('div');
|
|
184
|
+
contentWrapper.className = 'stx-error-boundary-content';
|
|
185
|
+
|
|
186
|
+
const fallbackWrapper = document.createElement('div');
|
|
187
|
+
fallbackWrapper.className = 'stx-error-boundary-fallback';
|
|
188
|
+
fallbackWrapper.style.display = 'none';
|
|
189
|
+
fallbackWrapper.innerHTML = fallbackContent;
|
|
190
|
+
|
|
191
|
+
// Move element's children to content wrapper
|
|
192
|
+
while (element.firstChild) {
|
|
193
|
+
contentWrapper.appendChild(element.firstChild);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
element.appendChild(contentWrapper);
|
|
197
|
+
element.appendChild(fallbackWrapper);
|
|
198
|
+
element.classList.add('stx-error-boundary');
|
|
199
|
+
element.setAttribute('data-boundary-id', boundaryId);
|
|
200
|
+
|
|
201
|
+
function showFallback(error) {
|
|
202
|
+
hasError = true;
|
|
203
|
+
lastError = error;
|
|
204
|
+
element.setAttribute('data-has-error', 'true');
|
|
205
|
+
contentWrapper.style.display = 'none';
|
|
206
|
+
fallbackWrapper.style.display = '';
|
|
207
|
+
if (options.onError) options.onError(error);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function retry() {
|
|
211
|
+
hasError = false;
|
|
212
|
+
lastError = null;
|
|
213
|
+
element.setAttribute('data-has-error', 'false');
|
|
214
|
+
contentWrapper.style.display = '';
|
|
215
|
+
fallbackWrapper.style.display = 'none';
|
|
216
|
+
if (options.onRetry) options.onRetry();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
window.STX.errorBoundaries[boundaryId] = {
|
|
220
|
+
hasError: function() { return hasError; },
|
|
221
|
+
getError: function() { return lastError; },
|
|
222
|
+
retry: retry,
|
|
223
|
+
showFallback: showFallback
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
return window.STX.errorBoundaries[boundaryId];
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
console.log('[stx] Error boundary runtime initialized');
|
|
230
|
+
})();
|
|
231
|
+
`}export{U as withErrorBoundary,W as processErrorBoundaryDirectives,Z as generateErrorBoundaryRuntime,Y as generateErrorBoundaryCSS,X as createErrorBoundary};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{a as N,c as R,e as W,g as j,i as H,k as J}from"./chunk-0y46fbkx.js";import{l as k,m as w,n as B}from"./chunk-q9n5swx7.js";import"./chunk-pw0rzgpv.js";import E from"fs";import K from"path";var V=[];function _(U){V=[];for(let A of U.storyFiles)if(V.push({text:A.fileName.toLowerCase(),original:A.fileName,type:"story",storyId:A.id}),V.push({text:A.relativePath.toLowerCase(),original:A.relativePath,type:"story",storyId:A.id}),A.story)for(let z of A.story.variants)V.push({text:z.title.toLowerCase(),original:z.title,type:"story",storyId:A.id,variantId:z.id})}function $(){return JSON.stringify(V)}async function O(U={}){let A=Date.now();N();let z=await k({mode:"build"});if(!z.config.enabled){W("Story feature is disabled in config.");return}let P=await H(z);w(z,P);let Y=J(z.config,P);B(z,Y),R(P.length);let X=U.outDir??z.config.outDir,Q=K.resolve(z.root,X);await E.promises.mkdir(Q,{recursive:!0}),console.log(` Building to ${X}...`);let M=F(z);await E.promises.writeFile(K.join(Q,"index.html"),M);let v={files:P.map((G)=>({id:G.id,fileName:G.fileName,relativePath:G.relativePath,treePath:G.treePath})),tree:Y};await E.promises.writeFile(K.join(Q,"stories.json"),JSON.stringify(v,null,2));let L={theme:z.config.theme,responsivePresets:z.config.responsivePresets,backgroundPresets:z.config.backgroundPresets};await E.promises.writeFile(K.join(Q,"config.json"),JSON.stringify(L,null,2));let Z=K.join(Q,"stories");await E.promises.mkdir(Z,{recursive:!0});for(let G of P){let g=await E.promises.readFile(G.path,"utf-8");await E.promises.writeFile(K.join(Z,`${G.id}.stx`),g)}_(z);let T=$();await E.promises.writeFile(K.join(Q,"search-index.json"),T);let C=Date.now()-A;j(P.length,X,C)}function F(U){let{theme:A}=U.config,z=A.title||"STX Story";return`<!DOCTYPE html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>${z}</title>
|
|
8
|
+
<style>
|
|
9
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
10
|
+
:root {
|
|
11
|
+
--bg: #ffffff;
|
|
12
|
+
--bg-secondary: #f5f5f5;
|
|
13
|
+
--text: #333333;
|
|
14
|
+
--text-secondary: #666666;
|
|
15
|
+
--border: #e0e0e0;
|
|
16
|
+
--primary: #3b82f6;
|
|
17
|
+
}
|
|
18
|
+
.dark {
|
|
19
|
+
--bg: #1a1a1a;
|
|
20
|
+
--bg-secondary: #2a2a2a;
|
|
21
|
+
--text: #ffffff;
|
|
22
|
+
--text-secondary: #a0a0a0;
|
|
23
|
+
--border: #404040;
|
|
24
|
+
}
|
|
25
|
+
body {
|
|
26
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
27
|
+
background: var(--bg);
|
|
28
|
+
color: var(--text);
|
|
29
|
+
display: flex;
|
|
30
|
+
height: 100vh;
|
|
31
|
+
}
|
|
32
|
+
.sidebar {
|
|
33
|
+
width: 280px;
|
|
34
|
+
background: var(--bg-secondary);
|
|
35
|
+
border-right: 1px solid var(--border);
|
|
36
|
+
overflow-y: auto;
|
|
37
|
+
padding: 1rem;
|
|
38
|
+
}
|
|
39
|
+
.sidebar h1 {
|
|
40
|
+
font-size: 1.25rem;
|
|
41
|
+
margin-bottom: 1rem;
|
|
42
|
+
padding-bottom: 0.5rem;
|
|
43
|
+
border-bottom: 1px solid var(--border);
|
|
44
|
+
}
|
|
45
|
+
.story-list { list-style: none; }
|
|
46
|
+
.story-item {
|
|
47
|
+
padding: 0.5rem 0.75rem;
|
|
48
|
+
border-radius: 4px;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
margin-bottom: 2px;
|
|
51
|
+
}
|
|
52
|
+
.story-item:hover { background: var(--border); }
|
|
53
|
+
.story-item.active { background: var(--primary); color: white; }
|
|
54
|
+
.main { flex: 1; display: flex; flex-direction: column; }
|
|
55
|
+
.toolbar {
|
|
56
|
+
padding: 0.75rem 1rem;
|
|
57
|
+
border-bottom: 1px solid var(--border);
|
|
58
|
+
display: flex;
|
|
59
|
+
gap: 0.5rem;
|
|
60
|
+
}
|
|
61
|
+
.canvas { flex: 1; padding: 2rem; overflow: auto; }
|
|
62
|
+
.empty-state {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
height: 100%;
|
|
67
|
+
color: var(--text-secondary);
|
|
68
|
+
}
|
|
69
|
+
</style>
|
|
70
|
+
</head>
|
|
71
|
+
<body>
|
|
72
|
+
<aside class="sidebar">
|
|
73
|
+
<h1>\uD83D\uDCD6 ${z}</h1>
|
|
74
|
+
<ul class="story-list" id="story-list"></ul>
|
|
75
|
+
</aside>
|
|
76
|
+
<main class="main">
|
|
77
|
+
<div class="toolbar">
|
|
78
|
+
<button onclick="toggleTheme()">\uD83C\uDF13 Theme</button>
|
|
79
|
+
</div>
|
|
80
|
+
<div class="canvas" id="canvas">
|
|
81
|
+
<div class="empty-state">Select a story</div>
|
|
82
|
+
</div>
|
|
83
|
+
</main>
|
|
84
|
+
<script>
|
|
85
|
+
fetch('stories.json')
|
|
86
|
+
.then(r => r.json())
|
|
87
|
+
.then(data => {
|
|
88
|
+
const list = document.getElementById('story-list');
|
|
89
|
+
list.innerHTML = data.files.map(f =>
|
|
90
|
+
'<li class="story-item" onclick="selectStory(\\'' + f.id + '\\')">' + f.fileName + '</li>'
|
|
91
|
+
).join('');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
function selectStory(id) {
|
|
95
|
+
document.querySelectorAll('.story-item').forEach(el => el.classList.remove('active'));
|
|
96
|
+
event.target.classList.add('active');
|
|
97
|
+
fetch('stories/' + id + '.stx')
|
|
98
|
+
.then(r => r.text())
|
|
99
|
+
.then(content => {
|
|
100
|
+
document.getElementById('canvas').innerHTML =
|
|
101
|
+
'<pre style="padding:1rem;overflow:auto;height:100%">' + escapeHtml(content) + '</pre>';
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function escapeHtml(t) {
|
|
106
|
+
const d = document.createElement('div');
|
|
107
|
+
d.textContent = t;
|
|
108
|
+
return d.innerHTML;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function toggleTheme() {
|
|
112
|
+
document.documentElement.classList.toggle('dark');
|
|
113
|
+
}
|
|
114
|
+
</script>
|
|
115
|
+
</body>
|
|
116
|
+
</html>`}var p=O;export{O as buildCommand,p as build};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ag as i,Dg as t,Eg as e,Fg as HH,Gg as KH,Hg as QH,Ig as YH,yg as S,zg as s}from"./chunk-ndnc7k2n.js";import{Wi as a}from"./chunk-yab6d6kb.js";import{Ls as h}from"./chunk-cbc56wpd.js";import{dt as f}from"./chunk-kjr22neh.js";import{existsSync as ZH,readFileSync as XH}from"fs";import J from"path";function qH(K,Q="",V=""){let U=K.startLine>1?`
|
|
3
|
+
`.repeat(K.startLine-1):"",E=i(s(K.code)),X=K.kind==="client"||K.kind==="plain"?e(Q,K.code):"";return KH(`${U+E}
|
|
4
|
+
${X}
|
|
5
|
+
export {}
|
|
6
|
+
`,V)}function GH(K){let Q=K.length>0?J.dirname(J.resolve(K[0])):process.cwd();try{Bun.resolveSync("@stacksjs/stx",Q)}catch{return""}return["// Generated \u2014 `stx` is the virtual specifier client-script.ts strips.","declare module 'stx' {"," export * from '@stacksjs/stx'","}"].join(`
|
|
7
|
+
`)}var WH=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function AH(K){if(K.length===0)return"";let Q=["// Generated \u2014 the composables the runtime publishes as bare globals."],V=new Set(f),U=[];for(let{file:E,names:X}of K){let W=JSON.stringify(E.replace(/\\/g,"/").replace(/\.ts$/,""));U.push(` export * from ${W}`);for(let q of X){if(V.has(q)||WH.has(q))continue;V.add(q),Q.push(`declare const ${q}: typeof import(${W})[${JSON.stringify(q)}]`)}}return Q.push("declare module '@composables' {",...U,"}"),Q.join(`
|
|
8
|
+
`)}function r(K,Q,V){return`${K}.__stx_${Q}${V}.ts`}function wH(K){return K.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function MH(){for(let K of[J.resolve(import.meta.dir,"..","stx.d.ts"),J.resolve(import.meta.dir,"..","..","stx.d.ts")])if(ZH(K))return K;return null}var RH=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function IH(K){return K>=1000&&K<2000}function UH(K){let Q=J.resolve(K),V;for(;;){let Z=J.join(Q,"tsconfig.json");if(ZH(Z)){V=Z;break}let $=J.dirname(Q);if($===Q)break;Q=$}if(!V)return{};let U=(Z)=>{let $="",A=!1,R=!1;for(let j=0;j<Z.length;j++){let M=Z[j];if(A){if($+=M,R)R=!1;else if(M==="\\")R=!0;else if(M==='"')A=!1;continue}if(M==='"'){A=!0,$+=M;continue}if(M==="/"&&Z[j+1]==="/"){while(j<Z.length&&Z[j]!==`
|
|
9
|
+
`)j++;$+=`
|
|
10
|
+
`;continue}if(M==="/"&&Z[j+1]==="*"){j+=2;while(j<Z.length&&!(Z[j]==="*"&&Z[j+1]==="/"))j++;j++;continue}$+=M}return $.replace(/,(\s*[}\]])/g,"$1")},E=new Set,X=V,W,q,B=V;while(X&&!E.has(X)){E.add(X);let Z;try{Z=JSON.parse(U(XH(X,"utf8")))}catch{break}let $=Z?.compilerOptions??{};if(!W&&$.paths&&typeof $.paths==="object")W=$.paths,B=X;if(!q&&typeof $.baseUrl==="string")q=J.resolve(J.dirname(X),$.baseUrl);if(W&&q)break;X=typeof Z?.extends==="string"?J.resolve(J.dirname(X),Z.extends.endsWith(".json")?Z.extends:`${Z.extends}.json`):void 0}if(!W)return{};let T=q??J.dirname(B),L={};for(let[Z,$]of Object.entries(W)){if(!Array.isArray($))continue;L[Z]=$.map((A)=>typeof A==="string"&&!J.isAbsolute(A)?J.resolve(T,A):A)}return{paths:L}}async function TH(K,Q={}){let V=Q.client!==!1,U=Q.server!==!1,E=Q.templates!==!1,X=new Map,W=new Map,q=[],B=0,T=0,L=MH();for(let H of K){let Y=await Bun.file(H).text(),G=S(Y).filter((z)=>{if(z.kind==="server")return U;return V}),I=S(Y).filter((z)=>z.kind==="server").map((z)=>z.code).join(`
|
|
11
|
+
`);if(V&&I){let z=G.filter((O)=>O.kind!=="server"),F=[...new Set(z.flatMap((O)=>HH(I,O.code)))];if(F.length>0)W.set(H,{names:F,line:z[0].startLine,kind:z[0].kind})}let _=J.dirname(J.resolve(H)),N=E?QH(Y,{runtimeGlobals:!L,originDir:_}):null,C=N?[...N.lineMap.values()].filter((z)=>z.expression).length:0;if(G.length===0&&C===0)continue;if(q.push(H),B+=G.length,T+=C,G.forEach((z,F)=>{X.set(r(H,z.kind,F),{source:qH(z,I,_),origin:H,kind:z.kind})}),N&&C>0)X.set(r(H,"template",0),{source:N.text,origin:H,kind:"template",virtual:N})}if(X.size===0)return{diagnostics:[],checkedFiles:q,blockCount:0,expressionCount:0};let Z=(Q.extraLibs??[]).map((H)=>J.resolve(H));if(L)Z.push(L);let $=`${h()}/typecheck/__stx_globals.d.ts`,A=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",t(),...L?[]:["declare const window: any",...f.map((H)=>`declare const ${H}: any`)],GH(K),AH(await a())].filter(Boolean).join(`
|
|
12
|
+
`),R=`${h()}/typecheck`;await Bun.$`rm -rf ${R}`.quiet().nothrow(),await Bun.$`mkdir -p ${R}`.quiet().nothrow(),await Bun.write($,A);let j=new Map,M=0;for(let[H,Y]of X){let G=`${M++}_${H.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${R}/${G}`,Y.source),j.set(G,Y)}let $H={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...UH(K.length>0?J.dirname(J.resolve(K[0])):process.cwd()),...Q.compilerOptions??{}},m=async(H,Y)=>{let G=`${R}/tsconfig${Y===1?"":`.${Y}`}.json`;await Bun.write(G,JSON.stringify({compilerOptions:$H,files:H.map((_)=>`${R}/${_}`).concat($,...Z)},null,2));let I=Bun.spawnSync(["bun","x","tsc","-p",G,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(I.stdout)+new TextDecoder().decode(I.stderr),exitCode:I.exitCode??0}},k=await m([...j.keys()],1),b=k.output,v=[],u=k.exitCode,d=0,jH=new Set(Z.map((H)=>H.split("/").pop())),p=0,P=new Set,c=(H)=>{for(let Y of H.split(`
|
|
13
|
+
`)){let G=Y.match(RH);if(!G)continue;if(d++,jH.has(G[1].split("/").pop()))p++;let[,I,_,N,C,z,F]=G,O=I.split("/").pop(),w=j.get(O);if(!w)continue;if(IH(Number(z)))P.add(O);let g=Number(_),x=Number(N),o;if(w.virtual){let y=YH(w.virtual,g,x);if(!y?.expression)continue;if(Number(z)===2774)continue;g=y.line,x=y.column,o=y.expression.code.trim()}v.push({file:w.origin,line:g,column:x,code:Number(z),message:F,category:C==="error"?"error":"warning",blockKind:w.kind,expression:o})}};c(b);let zH=d,JH=p;if(P.size>0&&P.size<j.size){let H=[...j.keys()].filter((Y)=>!P.has(Y));c((await m(H,2)).output)}if(V)for(let[H,Y]of W){if(Y.names.length===0)continue;v.push({file:H,line:Y.line,column:1,code:0,message:`${Y.names.length===1?"1 value reaches":`${Y.names.length} values reach`} this block on the implicit bridge and ${Y.names.length===1?"is":"are"} untyped: ${Y.names.join(", ")}. Declare them with defineClientPayload({ ${Y.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:Y.kind})}let l=new Set,D=v.filter((H)=>{let Y=`${H.file}:${H.line}:${H.column}:${H.code}:${H.message}`;if(l.has(Y))return!1;return l.add(Y),!0});D.sort((H,Y)=>H.file.localeCompare(Y.file)||H.line-Y.line||H.column-Y.column);let n=JH>0&&D.length===0,VH=n||u!==0&&zH===0?`${n?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${u} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
|
|
14
|
+
${b.trim().split(`
|
|
15
|
+
`).slice(0,12).join(`
|
|
16
|
+
`)||"(no output)"}`:void 0;return{diagnostics:D,checkedFiles:q,blockCount:B,expressionCount:T,failure:VH}}function PH(K){return K.map((Q)=>{let V=Q.blockKind==="template"?`[template: ${Q.expression??""}]`:`[${Q.blockKind==="plain"?"<script>":`<script ${Q.blockKind}>`}]`;return`${Q.file}:${Q.line}:${Q.column} ${Q.category} TS${Q.code} ${Q.message} ${V}`}).join(`
|
|
17
|
+
`)}
|
|
18
|
+
export{qH as Ye,r as Ze,wH as _e,MH as $e,TH as af,PH as bf};
|