@stacksjs/stx 0.2.530 → 0.2.532
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-35j1evvy.js → chunk-03wggzg8.js} +3 -3
- package/dist/chunk-08emfsq3.js +2 -0
- package/dist/{chunk-2twfqcxm.js → chunk-0dqxnx20.js} +2 -2
- package/dist/chunk-0p9pwd61.js +2 -0
- package/dist/chunk-0pebjkzx.js +18 -0
- package/dist/{chunk-f1n4e4jy.js → chunk-0wvsfs4s.js} +2 -2
- package/dist/chunk-0zmv31nc.js +2 -0
- package/dist/{chunk-c322rrge.js → chunk-12e4a0ab.js} +2 -2
- package/dist/chunk-12v4d123.js +2 -0
- package/dist/{chunk-2m5mx0x8.js → chunk-15r72kw7.js} +1 -1
- package/dist/{chunk-gvngrxvb.js → chunk-1945hk44.js} +1 -1
- package/dist/chunk-28xtazwz.js +2 -0
- package/dist/{chunk-y8h823cb.js → chunk-292vew7b.js} +36 -36
- package/dist/chunk-2936t942.js +2 -0
- package/dist/chunk-29qwmthc.js +2 -0
- package/dist/chunk-2a4szpje.js +3 -0
- package/dist/{chunk-8m3k43d3.js → chunk-2dzd2h15.js} +7 -7
- package/dist/{chunk-0rt5ec7a.js → chunk-2jk0vceh.js} +4 -4
- package/dist/{chunk-ktvr45qg.js → chunk-2qbvsvwc.js} +2 -2
- package/dist/chunk-2y6tzn6d.js +3 -0
- package/dist/{chunk-csbft3wz.js → chunk-31c1g3rt.js} +3 -3
- package/dist/chunk-323cxa69.js +2 -0
- package/dist/chunk-375zp0vr.js +2 -0
- package/dist/{chunk-21rm5kv6.js → chunk-38w14qs7.js} +2 -2
- package/dist/{chunk-raqbqt1r.js → chunk-3vvppnws.js} +6 -6
- package/dist/chunk-3w49r16x.js +2 -0
- package/dist/chunk-3zyvhf4p.js +2 -0
- package/dist/chunk-458etq5a.js +4 -0
- package/dist/chunk-4cmqjmqr.js +3 -0
- package/dist/{chunk-37nybpw1.js → chunk-4gt0r98p.js} +65 -14
- package/dist/{chunk-3x9d58f4.js → chunk-4xxhprts.js} +11 -11
- package/dist/{chunk-4drgbkga.js → chunk-587ehsxn.js} +2 -2
- package/dist/{chunk-5tyes97j.js → chunk-5tj6expd.js} +2 -2
- package/dist/{chunk-kzztmawd.js → chunk-664503e6.js} +6 -6
- package/dist/{chunk-hkjqqx92.js → chunk-6abvk7vj.js} +3 -3
- package/dist/{chunk-ba88n1j7.js → chunk-6v1gwdbv.js} +2 -2
- package/dist/{chunk-y0c1srgj.js → chunk-7s14bthq.js} +5 -5
- package/dist/{chunk-2etevws0.js → chunk-7tabykst.js} +2 -2
- package/dist/{chunk-zw029e7n.js → chunk-7wfh2hqy.js} +4 -4
- package/dist/chunk-7ybgfk0m.js +3 -0
- package/dist/chunk-8bcvb86w.js +2 -0
- package/dist/chunk-8gmb3k1p.js +2 -0
- package/dist/{chunk-v2zxxjqn.js → chunk-90wh9zzy.js} +6 -6
- package/dist/{chunk-d8ramz4s.js → chunk-9a73re8k.js} +2 -2
- package/dist/{chunk-p4gbvge6.js → chunk-9pztpvvk.js} +1 -1
- package/dist/chunk-9skdekv5.js +2 -0
- package/dist/{chunk-7p0zerfj.js → chunk-9sqjmd9a.js} +10 -10
- package/dist/{chunk-czmw5xsd.js → chunk-9w2vmfha.js} +2 -2
- package/dist/chunk-9xq5yer8.js +2 -0
- package/dist/chunk-a15yzfc6.js +2 -0
- package/dist/{chunk-2hc5mbw8.js → chunk-azb58ven.js} +2 -2
- package/dist/{chunk-869wyw0j.js → chunk-b7xdk1g4.js} +6 -6
- package/dist/{chunk-9mjy16pw.js → chunk-bpr4bkde.js} +2 -2
- package/dist/chunk-cp4dr9ch.js +2 -0
- package/dist/{chunk-6t0rq51y.js → chunk-d2r8t40y.js} +2 -2
- package/dist/chunk-d4155ec5.js +2 -0
- package/dist/{chunk-6k7spr38.js → chunk-d7x6n702.js} +7 -7
- package/dist/chunk-dd31q423.js +2 -0
- package/dist/{chunk-qhg55cvv.js → chunk-ee4wwr89.js} +5 -5
- package/dist/{chunk-f5pmyxtn.js → chunk-ennxrn5g.js} +5 -5
- package/dist/{chunk-xevnx24r.js → chunk-er031j13.js} +2 -2
- package/dist/chunk-f2q5bckn.js +2 -0
- package/dist/chunk-fhx35529.js +2 -0
- package/dist/chunk-frw35d2v.js +2 -0
- package/dist/chunk-fyxydww2.js +4 -0
- package/dist/{chunk-nzk14k6w.js → chunk-g060jncp.js} +7 -7
- package/dist/{chunk-x1tzt7yc.js → chunk-g12j8ahm.js} +4 -4
- package/dist/chunk-g5t10z04.js +2837 -0
- package/dist/{chunk-x9mzfq3p.js → chunk-grb3kfya.js} +1 -1
- package/dist/{chunk-3cn7973z.js → chunk-gsxb0ry9.js} +1 -1
- package/dist/{chunk-619j0mnz.js → chunk-gvw8wh29.js} +5 -5
- package/dist/{chunk-e6y6s7q8.js → chunk-gxfnmjzp.js} +2 -2
- package/dist/chunk-h1y5q942.js +2 -0
- package/dist/chunk-h791c7sb.js +2 -0
- package/dist/chunk-h88jcr3k.js +2 -0
- package/dist/chunk-heq5c0gd.js +2 -0
- package/dist/{chunk-ravc60z0.js → chunk-hp1tnxzb.js} +8 -8
- package/dist/chunk-hpeg9erh.js +3 -0
- package/dist/chunk-j3b24e77.js +2 -0
- package/dist/{chunk-vrrqnp5k.js → chunk-j8pacd7m.js} +5 -5
- package/dist/{chunk-346zc43s.js → chunk-jjwg83xv.js} +1 -1
- package/dist/chunk-jpck8nm5.js +2 -0
- package/dist/{chunk-58jyc7kp.js → chunk-kg77xs08.js} +3 -3
- package/dist/{chunk-1te1s9fa.js → chunk-khwj964t.js} +4 -4
- package/dist/{chunk-299xbyhn.js → chunk-kwvexxey.js} +4 -4
- package/dist/chunk-ky25egh1.js +2 -0
- package/dist/{chunk-w6ys6eq4.js → chunk-m2v04c6v.js} +93 -93
- package/dist/chunk-m4d99a9r.js +2 -0
- package/dist/chunk-ndv44bgs.js +2 -0
- package/dist/chunk-ng2sdph7.js +2 -0
- package/dist/{chunk-yh3p86qa.js → chunk-p8qr0q85.js} +2 -2
- package/dist/{chunk-6k4f583z.js → chunk-p8yh7mgr.js} +2 -2
- package/dist/chunk-pkfwxp9n.js +2 -0
- package/dist/chunk-pr5q4wev.js +2 -0
- package/dist/{chunk-fk45zc1b.js → chunk-q6e45gnw.js} +5 -5
- package/dist/chunk-qs3p7sc6.js +2 -0
- package/dist/{chunk-wqxdx2td.js → chunk-r6gxy92f.js} +2 -2
- package/dist/chunk-rchwwcxy.js +2 -0
- package/dist/chunk-rk4mttds.js +2 -0
- package/dist/chunk-rma3bv36.js +2 -0
- package/dist/chunk-rp5a91ak.js +2 -0
- package/dist/{chunk-hhys3aaa.js → chunk-rs46hksk.js} +2 -2
- package/dist/{chunk-wn5zjs5m.js → chunk-rtk6n3vh.js} +3 -3
- package/dist/chunk-rwn3b21z.js +3 -0
- package/dist/chunk-sp5x96rn.js +2 -0
- package/dist/chunk-st79dqpz.js +2 -0
- package/dist/{chunk-8g1fx4mg.js → chunk-stbsqy7e.js} +2 -2
- package/dist/chunk-t2mjeezd.js +2 -0
- package/dist/chunk-t61j834x.js +2 -0
- package/dist/{chunk-s19r6qe3.js → chunk-t6769zcy.js} +55 -55
- package/dist/chunk-t94z65ry.js +2 -0
- package/dist/{chunk-0ytm2ecf.js → chunk-tkeabv04.js} +16 -16
- package/dist/{chunk-1e7g79x4.js → chunk-v1m9nrn9.js} +1 -1
- package/dist/chunk-v2vg5jqq.js +2 -0
- package/dist/{chunk-07abr1v4.js → chunk-vg8thz41.js} +3 -3
- package/dist/chunk-vmfw4svt.js +2 -0
- package/dist/chunk-w6ecbk3y.js +2 -0
- package/dist/chunk-wbv6vjhm.js +2 -0
- package/dist/chunk-wfbr3txe.js +2 -0
- package/dist/{chunk-1v6yyvxf.js → chunk-wk85dz07.js} +3 -3
- package/dist/chunk-wpnv0naj.js +2 -0
- package/dist/chunk-wwny5dk9.js +2 -0
- package/dist/chunk-wzymzex7.js +2 -0
- package/dist/chunk-x55avrcf.js +2 -0
- package/dist/{chunk-hbwmmt91.js → chunk-xab6b4mt.js} +2 -2
- package/dist/{chunk-fd795e6s.js → chunk-xb0785wp.js} +2 -2
- package/dist/{chunk-1s7qdv2h.js → chunk-xcfhy5bj.js} +3 -3
- package/dist/{chunk-b0zz4dbx.js → chunk-xdtz2v5r.js} +3 -3
- package/dist/chunk-xmwd2xm6.js +2 -0
- package/dist/chunk-xtknewf7.js +2 -0
- package/dist/{chunk-wm5b2y65.js → chunk-y4qks0bd.js} +2 -2
- package/dist/{chunk-1h4z3xpy.js → chunk-y7ds4qyb.js} +3 -3
- package/dist/{chunk-p8c5g5n2.js → chunk-yn3kp3qy.js} +5 -5
- package/dist/chunk-yts2745t.js +2 -0
- package/dist/chunk-zah67v44.js +2 -0
- package/dist/chunk-zpdq0kx1.js +2 -0
- package/dist/chunk-zpf9he2x.js +2 -0
- package/dist/chunk-zpftj8s8.js +2 -0
- package/dist/{chunk-xpvvne6r.js → chunk-zzphh8g9.js} +9 -9
- package/dist/cli.js +62 -62
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/image-optimization/processor.js +6 -8
- package/dist/native/runtime/native-host.js +4 -1
- package/dist/native-build.js +12 -7
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +13 -13
- package/dist/temp-dir.d.ts +52 -0
- package/dist/temp-dir.js +140 -0
- package/package.json +5 -5
- package/dist/chunk-088jh5zy.js +0 -2
- package/dist/chunk-089x96rp.js +0 -2
- package/dist/chunk-0fad6jf4.js +0 -2
- package/dist/chunk-0fna7gd0.js +0 -2
- package/dist/chunk-0ksq0e6s.js +0 -2
- package/dist/chunk-2bwhc8ea.js +0 -2
- package/dist/chunk-2fb4yx25.js +0 -4
- package/dist/chunk-2y82wf9d.js +0 -3
- package/dist/chunk-3bsnte2s.js +0 -2
- package/dist/chunk-3j02tj5n.js +0 -2
- package/dist/chunk-3j9de8yh.js +0 -2
- package/dist/chunk-3v2bf157.js +0 -2
- package/dist/chunk-62ry3ta3.js +0 -2
- package/dist/chunk-62s4jb6m.js +0 -2
- package/dist/chunk-6dd0zr74.js +0 -2
- package/dist/chunk-87zse67b.js +0 -2
- package/dist/chunk-9hx4s11k.js +0 -2
- package/dist/chunk-9z76qhdm.js +0 -2
- package/dist/chunk-a0pq8xg4.js +0 -2
- package/dist/chunk-ad0czgpa.js +0 -2
- package/dist/chunk-axjzqh7v.js +0 -2
- package/dist/chunk-bday3eyq.js +0 -2
- package/dist/chunk-c2243par.js +0 -2
- package/dist/chunk-csy2m03w.js +0 -2
- package/dist/chunk-d3qdcdz9.js +0 -2
- package/dist/chunk-dvph69ej.js +0 -2
- package/dist/chunk-e1c9gypy.js +0 -2
- package/dist/chunk-eadr1eph.js +0 -2
- package/dist/chunk-eh3nvr2g.js +0 -2
- package/dist/chunk-f3nxd8z8.js +0 -2
- package/dist/chunk-fanmabb0.js +0 -2
- package/dist/chunk-fjd5ka6v.js +0 -2
- package/dist/chunk-fq5xecrx.js +0 -2
- package/dist/chunk-g25n9e8z.js +0 -2
- package/dist/chunk-g7ey7mtw.js +0 -3
- package/dist/chunk-gaz311xs.js +0 -2
- package/dist/chunk-ggb57j6c.js +0 -3
- package/dist/chunk-hmk2x1t8.js +0 -2
- package/dist/chunk-j1tbfabt.js +0 -2
- package/dist/chunk-jftv278d.js +0 -2
- package/dist/chunk-jj8ssn0d.js +0 -3
- package/dist/chunk-jkd0c82m.js +0 -2
- package/dist/chunk-jw536pve.js +0 -2
- package/dist/chunk-jwx0h9qb.js +0 -2
- package/dist/chunk-k4p80n25.js +0 -2
- package/dist/chunk-kpvr93cb.js +0 -2
- package/dist/chunk-kxa069d6.js +0 -2
- package/dist/chunk-pkwed7dt.js +0 -2
- package/dist/chunk-pq5nywkf.js +0 -2
- package/dist/chunk-qfm2gy40.js +0 -2
- package/dist/chunk-r37sf7ys.js +0 -18
- package/dist/chunk-rnnead1w.js +0 -2
- package/dist/chunk-szbvewf8.js +0 -2
- package/dist/chunk-t2yrb7pt.js +0 -2
- package/dist/chunk-tjjvphx3.js +0 -2
- package/dist/chunk-tsdjwe93.js +0 -2
- package/dist/chunk-v70hfs6d.js +0 -2
- package/dist/chunk-vp37585y.js +0 -2
- package/dist/chunk-vr0fb0x1.js +0 -2
- package/dist/chunk-w5kx0qzg.js +0 -2
- package/dist/chunk-wy36z6qp.js +0 -2
- package/dist/chunk-wyxjsx4k.js +0 -2837
- package/dist/chunk-x7a4c0x1.js +0 -2
- package/dist/chunk-y0a89hgw.js +0 -2
- package/dist/chunk-y4b60ke0.js +0 -2
- package/dist/chunk-yn2d8x8m.js +0 -3
- package/dist/chunk-yqh6dny3.js +0 -2
- package/dist/chunk-z4f2msjp.js +0 -2
- package/dist/chunk-zmdyr321.js +0 -3
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ur,Io,Do}from"./chunk-31c1g3rt.js";import"./chunk-tkeabv04.js";import"./chunk-bpr4bkde.js";import"./chunk-4gt0r98p.js";import"./chunk-5tj6expd.js";import"./chunk-6v1gwdbv.js";import"./chunk-g5t10z04.js";import"./chunk-9sqjmd9a.js";import"./chunk-2dzd2h15.js";import"./chunk-p8yh7mgr.js";import"./chunk-y4qks0bd.js";import"./chunk-gxfnmjzp.js";import"./chunk-kwvexxey.js";import"./chunk-458etq5a.js";import{kd,Eo,Cd,Ed,To,Vr,_o,Td,$o,_d,$d,Ro,Ao,Po}from"./chunk-t6769zcy.js";import"./chunk-0pebjkzx.js";import"./chunk-kg77xs08.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
6
6
|
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
8
|
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
-
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{kd as CRAFT_BRIDGE_SCRIPT,Vr as CRAFT_COMPONENTS,Td as CRAFT_COMPONENT_RUNTIME,_o as CRAFT_COMPONENT_STYLES,Ur as NATIVE_COMPONENTS,Ro as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Io as compileToNative,Do as createHotReloadServer,Eo as generateCraftBridgeScript,V as generateCraftOptimizations,Po as getAvailableFormats,Ao as getAvailableTargets,$d as getCraftComponents,G as getSSRCacheStats,To as injectCraftBridge,Cd as isCraftEnvironment,Y as prerenderForCraft,$o as processCraftComponents,Ed as processCraftDirective,_d as registerCraftComponent,Q as renderSSR};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import os from "node:os";
|
|
4
3
|
import crypto from "node:crypto";
|
|
5
4
|
import { generatePlaceholder as tsGeneratePlaceholder, processImage as tsProcessImage } from "ts-images";
|
|
5
|
+
import { createTempDir, removeTempDir, withTempDir } from "../temp-dir.js";
|
|
6
6
|
export const DEFAULT_WIDTHS = [320, 640, 768, 1024, 1280, 1536, 1920], DEFAULT_FORMATS = ["webp", "jpeg"], DEFAULT_QUALITY = 80;
|
|
7
7
|
const IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png", ".webp", ".avif", ".gif", ".svg"], MIME_TYPES = {
|
|
8
8
|
webp: "image/webp",
|
|
@@ -158,8 +158,8 @@ export async function resizeAndConvert(buffer, options) {
|
|
|
158
158
|
}
|
|
159
159
|
return instance.toBuffer();
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
return await withTempDir("img", async (dir) => {
|
|
162
|
+
const tempOut = path.join(dir, `out.${options.format}`);
|
|
163
163
|
await tsProcessImage({
|
|
164
164
|
input: buffer,
|
|
165
165
|
output: tempOut,
|
|
@@ -172,9 +172,7 @@ export async function resizeAndConvert(buffer, options) {
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
return Buffer.from(await Bun.file(tempOut).arrayBuffer());
|
|
175
|
-
}
|
|
176
|
-
await fs.promises.unlink(tempOut).catch(() => {});
|
|
177
|
-
}
|
|
175
|
+
});
|
|
178
176
|
}
|
|
179
177
|
async function generatePlaceholder(buffer, type) {
|
|
180
178
|
const s = await loadSharp();
|
|
@@ -189,7 +187,7 @@ async function generatePlaceholder(buffer, type) {
|
|
|
189
187
|
}).catch(() => ({ dominant: { r: 128, g: 128, b: 128 } }));
|
|
190
188
|
return `rgb(${dominant.r}, ${dominant.g}, ${dominant.b})`;
|
|
191
189
|
}
|
|
192
|
-
const meta = await getImageMetadata(buffer), tempIn = path.join(
|
|
190
|
+
const meta = await getImageMetadata(buffer), scratch = createTempDir("ph"), tempIn = path.join(scratch, `in.${meta.format === "unknown" ? "bin" : meta.format}`);
|
|
193
191
|
try {
|
|
194
192
|
await Bun.write(tempIn, buffer);
|
|
195
193
|
const tsStrategy = type === "blur" ? "blur" : type === "thumbhash" ? "thumbhash" : "dominant-color", ph = await tsGeneratePlaceholder(tempIn, {
|
|
@@ -204,7 +202,7 @@ async function generatePlaceholder(buffer, type) {
|
|
|
204
202
|
} catch {
|
|
205
203
|
return "rgb(128, 128, 128)";
|
|
206
204
|
} finally {
|
|
207
|
-
|
|
205
|
+
removeTempDir(scratch);
|
|
208
206
|
}
|
|
209
207
|
}
|
|
210
208
|
export function generateSrcSet(variants, format) {
|
|
@@ -3,6 +3,9 @@ import { resolveIconName } from "../compiler/icons.js";
|
|
|
3
3
|
import { affectsGeometry, parseSvgMarkup, parseViewBox, SVG_NODE_TYPES, svgGeometry } from "../compiler/svg.js";
|
|
4
4
|
import { nativePropName } from "../prop-names.js";
|
|
5
5
|
import { cloneNativeBindingNode } from "./binding-tree.js";
|
|
6
|
+
function irDisplay(value) {
|
|
7
|
+
return value === "none" || value === "grid" || value === "flex" ? value : "flex";
|
|
8
|
+
}
|
|
6
9
|
function eventAt(payload, node) {
|
|
7
10
|
if (payload === void 0 || payload === null)
|
|
8
11
|
return { target: node, currentTarget: node };
|
|
@@ -449,7 +452,7 @@ export function createNativeHost(options) {
|
|
|
449
452
|
record.baseStyle.display = record.shownDisplay;
|
|
450
453
|
record.shownDisplay = void 0;
|
|
451
454
|
}
|
|
452
|
-
const display = visible ? resolveStyle(record).display
|
|
455
|
+
const display = visible ? irDisplay(resolveStyle(record).display) : "none";
|
|
453
456
|
if (record.materialized)
|
|
454
457
|
emit({ op: "updateNode", id: node.__stxId, patch: { style: { display } } });
|
|
455
458
|
return was;
|
package/dist/native-build.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
var {require}=import.meta;import { existsSync, mkdirSync, copyFileSync, chmodSync } from "node:fs";
|
|
2
2
|
import { join, dirname, basename, resolve } from "node:path";
|
|
3
3
|
import { spawn, execSync } from "node:child_process";
|
|
4
|
-
import {
|
|
4
|
+
import { homedir, platform as osPlatform } from "node:os";
|
|
5
5
|
import { injectCraftBridge } from "./craft-bridge.js";
|
|
6
6
|
import { processCraftComponents, CRAFT_COMPONENT_STYLES } from "./craft-components.js";
|
|
7
7
|
import { renderTemplate } from "./render.js";
|
|
8
|
+
import { createTempDir, removeTempDir } from "./temp-dir.js";
|
|
8
9
|
export async function buildNative(config) {
|
|
9
10
|
const startTime = Date.now();
|
|
10
11
|
try {
|
|
@@ -382,8 +383,9 @@ async function createZip(sourceDir, outputPath) {
|
|
|
382
383
|
}
|
|
383
384
|
async function createDEB(appDir, outputPath, appName, appVersion, config) {
|
|
384
385
|
return new Promise((resolve) => {
|
|
386
|
+
const scratch = createTempDir("deb");
|
|
385
387
|
try {
|
|
386
|
-
const tempDir = join(
|
|
388
|
+
const tempDir = join(scratch, "pkg"), debianDir = join(tempDir, "DEBIAN"), binDir = join(tempDir, "usr", "bin"), shareDir = join(tempDir, "usr", "share", "applications"), dataDir = join(tempDir, "usr", "share", appName.toLowerCase());
|
|
387
389
|
mkdirSync(debianDir, { recursive: !0 });
|
|
388
390
|
mkdirSync(binDir, { recursive: !0 });
|
|
389
391
|
mkdirSync(shareDir, { recursive: !0 });
|
|
@@ -407,25 +409,27 @@ Description: ${config.description || appName}
|
|
|
407
409
|
require("fs").writeFileSync(join(debianDir, "control"), control);
|
|
408
410
|
const proc = spawn("dpkg-deb", ["--build", tempDir, outputPath]);
|
|
409
411
|
proc.on("close", (code) => {
|
|
410
|
-
|
|
412
|
+
removeTempDir(scratch);
|
|
411
413
|
if (code === 0)
|
|
412
414
|
resolve({ success: !0 });
|
|
413
415
|
else
|
|
414
416
|
resolve({ success: !1, error: `dpkg-deb exited with code ${code}` });
|
|
415
417
|
});
|
|
416
418
|
proc.on("error", (err) => {
|
|
417
|
-
|
|
419
|
+
removeTempDir(scratch);
|
|
418
420
|
resolve({ success: !1, error: err.message });
|
|
419
421
|
});
|
|
420
422
|
} catch (error) {
|
|
423
|
+
removeTempDir(scratch);
|
|
421
424
|
resolve({ success: !1, error: error.message });
|
|
422
425
|
}
|
|
423
426
|
});
|
|
424
427
|
}
|
|
425
428
|
async function createAppImage(appDir, outputPath, appName, config) {
|
|
426
429
|
return new Promise((resolve) => {
|
|
430
|
+
const tempDir = createTempDir("appimage");
|
|
427
431
|
try {
|
|
428
|
-
const
|
|
432
|
+
const appDirPath = join(tempDir, `${appName}.AppDir`), usrDir = join(appDirPath, "usr"), binDir = join(usrDir, "bin"), shareDir = join(usrDir, "share");
|
|
429
433
|
mkdirSync(binDir, { recursive: !0 });
|
|
430
434
|
mkdirSync(shareDir, { recursive: !0 });
|
|
431
435
|
const dataDir = join(shareDir, appName.toLowerCase());
|
|
@@ -528,7 +532,7 @@ Icon=${appName.toLowerCase()}
|
|
|
528
532
|
env: { ...process.env, ARCH: "x86_64" }
|
|
529
533
|
});
|
|
530
534
|
proc.on("close", (code) => {
|
|
531
|
-
|
|
535
|
+
removeTempDir(tempDir);
|
|
532
536
|
if (code === 0) {
|
|
533
537
|
chmodSync(outputPath, 493);
|
|
534
538
|
resolve({ success: !0 });
|
|
@@ -539,10 +543,11 @@ Icon=${appName.toLowerCase()}
|
|
|
539
543
|
});
|
|
540
544
|
});
|
|
541
545
|
proc.on("error", (err) => {
|
|
542
|
-
|
|
546
|
+
removeTempDir(tempDir);
|
|
543
547
|
resolve({ success: !1, error: `appimagetool not found: ${err.message}` });
|
|
544
548
|
});
|
|
545
549
|
} catch (error) {
|
|
550
|
+
removeTempDir(tempDir);
|
|
546
551
|
resolve({ success: !1, error: error.message });
|
|
547
552
|
}
|
|
548
553
|
});
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-
|
|
2
|
+
import{Bn,Ne,Ho,Ga}from"./chunk-2jk0vceh.js";import{jn,Wr,qa,Ka,Xa}from"./chunk-d7x6n702.js";import{Bo,Fo,zo,Ua,Wa}from"./chunk-d2r8t40y.js";import{ie,ht,qr}from"./chunk-6abvk7vj.js";import{Zc,Qc,el,tl,mr,wu}from"./chunk-r6gxy92f.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-f2q5bckn.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
|
|
|
233
233
|
}, 5000);
|
|
234
234
|
</script>
|
|
235
235
|
</body>
|
|
236
|
-
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=
|
|
236
|
+
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=ie(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Bn(n,t);if(a){let s=Ne(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return Wr(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Fo as auditBuildOutput,Bo as auditConfig,re as buildPwaAssets,zo as calculateAuditResult,Wa as formatAuditResult,qr as formatSize,j as generateManifest,_ as generateManifestJson,Ka as generateManifestLink,F as generateOfflinePage,ie as generatePrecacheManifest,ht as generatePrecacheManifestJs,M as generatePwaIcons,jn as generatePwaTags,Bn as generateServiceWorker,Ga as generateServiceWorkerAuto,qa as generateSwRegistrationScript,Xa as generateThemeColorMeta,N as getExpectedIconPaths,Ne as getServiceWorkerFileName,Wr as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Ho as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,mr as pwaDirectives,Zc as pwaInstallDirective,el as pwaOfflineDirective,tl as pwaPushDirective,Qc as pwaUpdateDirective,wu as registerPwaDirectives,Ua as runPwaAudit,D as validateManifest};
|
package/dist/ssg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
3
|
-
`)}class
|
|
2
|
+
import"./chunk-azb58ven.js";import"./chunk-tkeabv04.js";import"./chunk-bpr4bkde.js";import{nt,rt,st,ot,it,at}from"./chunk-4gt0r98p.js";import"./chunk-5tj6expd.js";import"./chunk-6v1gwdbv.js";import{f,ze,N,X,n,o}from"./chunk-g5t10z04.js";import"./chunk-9sqjmd9a.js";import{sr}from"./chunk-2dzd2h15.js";import"./chunk-p8yh7mgr.js";import"./chunk-y4qks0bd.js";import"./chunk-gxfnmjzp.js";import"./chunk-kwvexxey.js";import"./chunk-ee4wwr89.js";import{ae,yt,bt}from"./chunk-664503e6.js";import{No,Lo,jo}from"./chunk-wk85dz07.js";import{mt,Qt,en}from"./chunk-hpeg9erh.js";import"./chunk-kg77xs08.js";import{a}from"./chunk-4cmqjmqr.js";import x from"fs";import g from"path";import{createHash as Dt}from"crypto";function Rt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ut(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(kt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Rt(h);let S=Ct(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Dt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Et=new Set(["visible","idle"]);function dt(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Et.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var It=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Bt(t){for(let i of It){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function gt(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function jt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=gt(e.default??e);if(l)return l}catch{}}return null}async function pt(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=gt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await jt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=Bt(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ht(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
|
+
`)}class ft{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class wt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function Ft(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${c[1]}
|
|
6
6
|
})()
|
|
@@ -8,10 +8,10 @@ import"./chunk-2hc5mbw8.js";import"./chunk-0ytm2ecf.js";import"./chunk-9mjy16pw.
|
|
|
8
8
|
return (async function getStaticProps() {
|
|
9
9
|
${e[1]}
|
|
10
10
|
})()
|
|
11
|
-
`)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function
|
|
12
|
-
resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(Lt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let p=await n(e,y,t.filePath,D,h);for(let b of[t.filePath,...h])for(let B of
|
|
11
|
+
`)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function St(t,i,s={},r,c){let e=await Bun.file(t.filePath).text(),l=await Tt(t.filePath),w=await At(e,i,t.filePath),y={...l||{},...w||{},...s,params:i,$route:{path:t.pattern,params:i}},h=new Set,S=[],P=[],D={...c,...r.partialsDir?{partialsDir:r.partialsDir}:{},...r.componentsDir?{componentsDir:r.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(b)=>{S.push(`${g.relative(process.cwd(),b.templatePath)}: ${b.message}
|
|
12
|
+
resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(Lt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let p=await n(e,y,t.filePath,D,h);for(let b of[t.filePath,...h])for(let B of ae(b))h.add(B);if(Object.keys(i).length>0){let b=`<script>if(window.stx)window.stx._rp=${JSON.stringify(i)};else window.__stx_rp=${JSON.stringify(i)};</script>`;if(p.includes("</head>"))p=p.replace("</head>",`${b}
|
|
13
13
|
</head>`);else p=`${b}
|
|
14
|
-
${p}`}if(p=await
|
|
14
|
+
${p}`}if(p=await X(p,{router:r.router}),p=await f(p),r.minify!==!1)return{html:Mt(p),dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P};return{html:p,dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P}}function Mt(t){let i=[],s=0,r=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=r.exec(t))!==null){let l=t.slice(s,c.index);i.push(l.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let w=c[1],y=c[2],h=c[3];y=y.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),i.push(w+y+h),s=c.index+c[0].length}let e=t.slice(s);return i.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),i.join("").trim()}function Ut(t){let i=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);i=(i<<5)-i+r,i=i&i}return`"${Math.abs(i).toString(36)}"`}function _t(t,i,s,r){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(i))return!0;return r.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function Gt(t,i){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
15
15
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
16
16
|
${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
17
17
|
<loc>${I(c)}</loc>`;if(r.lastmod)e+=`
|
|
@@ -41,16 +41,16 @@ ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
|
41
41
|
${s.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function zt(t={}){let i=Date.now();
|
|
45
|
-
const validate = ${
|
|
44
|
+
</rss>`}async function zt(t={}){let i=Date.now();bt();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ht());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-yts2745t.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-29qwmthc.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new ft(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-yts2745t.js");await u('<div class="bg-black"></div>')}catch{}nt();let xt=s?.routeMiddleware?.dir||"middleware";await st(process.cwd(),xt);let H=rt();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let vt=s?.routeMiddleware?.global||[];jo(s?.layoutsDir,a(process.cwd()));let V=N(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${V.length} routes`);let _=[];for(let u of V){let m=await Ot(u);for(let v of m)_.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=_.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],K=[];for(let u=0;u<_.length;u+=e.concurrency)K.push(_.slice(u,u+e.concurrency));for(let u of K)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:L,props:Pt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),$t=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],tt=[...vt,...$t];if(tt.length>0){let C=ot(d,L,F||{}),O=it(C,null,void 0,{isServer:!0}),E=await at(tt,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,U=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,U),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(U),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
|
|
45
|
+
const validate = ${et[1]};
|
|
46
46
|
return validate(route);
|
|
47
|
-
`)({params:L})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,ct=!1;if(e.cache){if(k=B.get(d,v.filePath),k)ct=!0,l.cachedCount++}if(!k){let C=await
|
|
47
|
+
`)({params:L})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,ct=!1;if(e.cache){if(k=B.get(d,v.filePath),k)ct=!0,l.cachedCount++}if(!k){let C=await St(v,L,Pt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
|
48
48
|
${C.includeFailures.join(`
|
|
49
49
|
`)}
|
|
50
50
|
Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&C.serverScriptFailures.length>0)throw Error(`${C.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
|
|
51
51
|
${C.serverScriptFailures.join(`
|
|
52
52
|
`)}
|
|
53
|
-
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let M;if(e.trailingSlash)M=g.join(e.outputDir,d,"index.html");else M=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:O}=ut(k,{integrity:e.integrityIslands,minify:e.minify});if(O.length>0){let E=g.join(e.outputDir,"_stx","islands");await x.promises.mkdir(E,{recursive:!0});for(let R of O){let U=g.join(E,`${R.hash}.js`);if(!await Bun.file(U).exists())await Bun.write(U,R.code);if(!w.has(R.hash)){w.add(R.hash);let T=Buffer.byteLength(R.code,"utf8");y+=T,h[R.hash]={bytes:T,file:`/_stx/islands/${R.hash}.js`}}}if(S[d]=O.map((R)=>R.hash),k=C,e.prefetchIslands)k=dt(k)}}if(await x.promises.mkdir(g.dirname(M),{recursive:!0}),await Bun.write(M,k),!_t(d,k,F,e.sitemapExclude))A.push({loc:d,lastmod:new Date().toISOString().split("T")[0],priority:d==="/"?1:0.8});let lt={route:d,outputPath:M,size:Buffer.byteLength(k,"utf8"),cached:ct};if(Q!==!1)lt.revalidateAt=Date.now()+Q*1000;l.pages.push(lt),l.successCount++,await e.hooks.onPageEnd?.(d,k)}catch(j){l.failedCount++,l.errors.push({route:d,error:j}),await e.hooks.onError?.(j,d),console.error(`Error generating ${d}:`,j)}}));let Y=
|
|
53
|
+
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let M;if(e.trailingSlash)M=g.join(e.outputDir,d,"index.html");else M=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:O}=ut(k,{integrity:e.integrityIslands,minify:e.minify});if(O.length>0){let E=g.join(e.outputDir,"_stx","islands");await x.promises.mkdir(E,{recursive:!0});for(let R of O){let U=g.join(E,`${R.hash}.js`);if(!await Bun.file(U).exists())await Bun.write(U,R.code);if(!w.has(R.hash)){w.add(R.hash);let T=Buffer.byteLength(R.code,"utf8");y+=T,h[R.hash]={bytes:T,file:`/_stx/islands/${R.hash}.js`}}}if(S[d]=O.map((R)=>R.hash),k=C,e.prefetchIslands)k=dt(k)}}if(await x.promises.mkdir(g.dirname(M),{recursive:!0}),await Bun.write(M,k),!_t(d,k,F,e.sitemapExclude))A.push({loc:d,lastmod:new Date().toISOString().split("T")[0],priority:d==="/"?1:0.8});let lt={route:d,outputPath:M,size:Buffer.byteLength(k,"utf8"),cached:ct};if(Q!==!1)lt.revalidateAt=Date.now()+Q*1000;l.pages.push(lt),l.successCount++,await e.hooks.onPageEnd?.(d,k)}catch(j){l.failedCount++,l.errors.push({route:d,error:j}),await e.hooks.onError?.(j,d),console.error(`Error generating ${d}:`,j)}}));let Y=yt();if(Y.length>0){let u=Y.map((m)=>`${m.filePath}: ${m.message}`).join(`
|
|
54
54
|
`);throw Error(`Client script bundling failed:
|
|
55
55
|
${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.stx");if(await Bun.file(u).exists()){let m=new Set,v={...s,debug:!1,cache:!1},d=await n(await Bun.file(u).text(),{},u,v,m);await Bun.write(g.join(e.outputDir,"404.html"),d)}else await Bun.write(g.join(e.outputDir,"404.html"),`<!DOCTYPE html>
|
|
56
56
|
<html lang="en">
|
|
@@ -73,7 +73,7 @@ ${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.
|
|
|
73
73
|
<a href="/">Go home</a>
|
|
74
74
|
</div>
|
|
75
75
|
</body>
|
|
76
|
-
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},L=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),L)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=
|
|
76
|
+
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},L=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),L)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=sr({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let G=No(e.outputDir);if(G.assets>0)console.log(`Externalized ${G.assets} asset(s) from ${G.pages} page(s) (${(G.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let z=Lo(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} repeated asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&x.existsSync(e.publicDir))await J(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Z=en();if(Z)await J(Z,g.join(e.outputDir,Qt)),console.log(`Copied assets from ${mt}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-i,w.size>0){l.islandChunks={count:w.size,totalBytes:y};let D={generatedChunks:w.size,totalBytes:y,chunks:h,pages:S};await Bun.write(g.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(D,null,2))}await e.hooks.onBuildEnd?.(l);let P=l.islandChunks?`
|
|
77
77
|
Island chunks: ${l.islandChunks.count} (${(l.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
|
|
78
78
|
Build complete!
|
|
79
79
|
Total: ${l.totalPages} pages
|
|
@@ -81,8 +81,8 @@ Build complete!
|
|
|
81
81
|
Cached: ${l.cachedCount}
|
|
82
82
|
Failed: ${l.failedCount}
|
|
83
83
|
Time: ${l.buildTime}ms${P}
|
|
84
|
-
`),l}async function J(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await J(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new
|
|
85
|
-
`)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return
|
|
84
|
+
`),l}async function J(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await J(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new wt(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=N(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!l){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(l.regex),y={};if(w)l.params.forEach((P,D)=>{y[P]=w[D+1]});let h=await o(),{html:S}=await St(l,y,{},t,h);await s.set(c,{html:S,generatedAt:Date.now(),revalidateAfter:Date.now()+r*1000,etag:Ut(S)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Wt(t){return async()=>({paths:await t(),fallback:!1})}function qt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let i=await Bun.file(t).text(),s=i.match(/^---\n([\s\S]*?)\n---/),r={},c=i;if(s){let h=s[1];c=i.slice(s[0].length).trim();for(let S of h.split(`
|
|
85
|
+
`)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return ze(t)}function Vt(t,i){return`<!DOCTYPE html>
|
|
86
86
|
<html>
|
|
87
87
|
<head>
|
|
88
88
|
<meta charset="utf-8">
|
|
@@ -94,4 +94,4 @@ Build complete!
|
|
|
94
94
|
<p>Redirecting to <a href="${t}">${t}</a>...</p>
|
|
95
95
|
<script>window.location.replace('${t}')</script>
|
|
96
96
|
</body>
|
|
97
|
-
</html>`}function Kt(t,i){if(t==="/"||t==="")return g.join(i.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(i.trailingSlash)return g.join(i.outputDir,s,"index.html");return g.join(i.outputDir,`${s}.html`)}var
|
|
97
|
+
</html>`}function Kt(t,i){if(t==="/"||t==="")return g.join(i.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(i.trailingSlash)return g.join(i.outputDir,s,"index.html");return g.join(i.outputDir,`${s}.html`)}var Se={generateStaticSite:zt,createISRHandler:Ht,defineStaticPaths:Wt,createMarkdownLoader:qt};export{Ht as createISRHandler,qt as createMarkdownLoader,Lt as declaresPageAction,Se as default,Wt as defineStaticPaths,zt as generateStaticSite,_t as isExcludedFromSitemap};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Remove every directory this process created and has not removed yet. */
|
|
2
|
+
export declare function removeAllTempDirs(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Remove stx temp directories whose owning process has exited.
|
|
5
|
+
*
|
|
6
|
+
* Only names this module produced are considered (`stx-…-p<pid>-XXXXXX`),
|
|
7
|
+
* so another tool's `stx-something` directory is never touched, and neither
|
|
8
|
+
* is one holding the keep marker. Returns the paths it removed.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sweepOrphanedTempDirs(options?: SweepOptions): string[];
|
|
11
|
+
/**
|
|
12
|
+
* The mkdtemp prefix for a label: `native-cli`, `stx-native-cli-` and
|
|
13
|
+
* `stx-native-cli` all become `stx-native-cli-p<pid>-`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function tempDirPrefix(label: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* The keep-for-inspection switch: `STX_KEEP_TEMP=1` keeps every directory
|
|
18
|
+
* this process creates (a failing test's project, a build's staging tree),
|
|
19
|
+
* marks it so no sweep removes it, and prints where it is.
|
|
20
|
+
*/
|
|
21
|
+
export declare function keepTempDirsRequested(env?: Record<string, string | undefined>): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Create a scratch directory in the OS temp folder (or `root`) that is
|
|
24
|
+
* removed when this process ends, however it ends. Remove it sooner with
|
|
25
|
+
* `removeTempDir`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createTempDir(label?: string, root?: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Remove a directory from `createTempDir` now rather than at exit. One kept
|
|
30
|
+
* with `keepTempDir` (or under `STX_KEEP_TEMP`) stays.
|
|
31
|
+
*/
|
|
32
|
+
export declare function removeTempDir(dir: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Let a directory from `createTempDir` outlive the process, for a harness
|
|
35
|
+
* asked to keep its output for inspection. The caller now owns it: the keep
|
|
36
|
+
* marker stops a later sweep from removing it, so delete it by hand.
|
|
37
|
+
*/
|
|
38
|
+
export declare function keepTempDir(dir: string): void;
|
|
39
|
+
/** Run `fn` with a fresh scratch directory that is removed when it settles. */
|
|
40
|
+
export declare function withTempDir<T>(label: string, fn: (dir: string) => T | Promise<T>): Promise<T>;
|
|
41
|
+
/** Directories created here and not yet removed. For tests and diagnostics. */
|
|
42
|
+
export declare function liveTempDirs(): string[];
|
|
43
|
+
/** A directory holding this file was kept on purpose and is never swept. */
|
|
44
|
+
export declare const KEEP_MARKER: '.stx-keep';
|
|
45
|
+
declare const SIGNALS: readonly ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
46
|
+
export declare interface SweepOptions {
|
|
47
|
+
root?: string
|
|
48
|
+
isAlive?: (pid: number) => boolean
|
|
49
|
+
minAgeMs?: number
|
|
50
|
+
now?: number
|
|
51
|
+
}
|
|
52
|
+
declare type CleanupSignal = typeof SIGNALS[number];
|
package/dist/temp-dir.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { existsSync, mkdtempSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { constants as osConstants, tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
const OWNED_NAME = /^stx-(?:.+-)?p(\d+)-\w{6}$/;
|
|
6
|
+
export const KEEP_MARKER = ".stx-keep";
|
|
7
|
+
const SWEEP_MIN_AGE_MS = 60000, SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"], live = new Set, kept = new Set;
|
|
8
|
+
let hooked = !1;
|
|
9
|
+
const sweptRoots = new Set;
|
|
10
|
+
function removeQuietly(dir) {
|
|
11
|
+
try {
|
|
12
|
+
rmSync(dir, { recursive: !0, force: !0 });
|
|
13
|
+
} catch {}
|
|
14
|
+
}
|
|
15
|
+
export function removeAllTempDirs() {
|
|
16
|
+
for (const dir of live)
|
|
17
|
+
removeQuietly(dir);
|
|
18
|
+
live.clear();
|
|
19
|
+
unhook();
|
|
20
|
+
}
|
|
21
|
+
function onExit() {
|
|
22
|
+
for (const dir of live)
|
|
23
|
+
removeQuietly(dir);
|
|
24
|
+
live.clear();
|
|
25
|
+
}
|
|
26
|
+
function onSignal(signal) {
|
|
27
|
+
removeAllTempDirs();
|
|
28
|
+
if (process.listenerCount(signal) === 0)
|
|
29
|
+
process.exit(128 + (osConstants.signals[signal] ?? 1));
|
|
30
|
+
}
|
|
31
|
+
const signalHandlers = new Map(SIGNALS.map((signal) => [signal, () => onSignal(signal)]));
|
|
32
|
+
function hook() {
|
|
33
|
+
if (hooked)
|
|
34
|
+
return;
|
|
35
|
+
hooked = !0;
|
|
36
|
+
process.on("exit", onExit);
|
|
37
|
+
for (const [signal, handler] of signalHandlers)
|
|
38
|
+
try {
|
|
39
|
+
process.on(signal, handler);
|
|
40
|
+
} catch {}
|
|
41
|
+
}
|
|
42
|
+
function unhook() {
|
|
43
|
+
if (!hooked)
|
|
44
|
+
return;
|
|
45
|
+
hooked = !1;
|
|
46
|
+
process.off("exit", onExit);
|
|
47
|
+
for (const [signal, handler] of signalHandlers)
|
|
48
|
+
process.off(signal, handler);
|
|
49
|
+
}
|
|
50
|
+
function pidIsAlive(pid) {
|
|
51
|
+
try {
|
|
52
|
+
process.kill(pid, 0);
|
|
53
|
+
return !0;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return error.code === "EPERM";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function sweepOrphanedTempDirs(options = {}) {
|
|
59
|
+
const root = options.root ?? tmpdir(), isAlive = options.isAlive ?? pidIsAlive, minAge = options.minAgeMs ?? SWEEP_MIN_AGE_MS, now = options.now ?? Date.now(), removed = [];
|
|
60
|
+
let names;
|
|
61
|
+
try {
|
|
62
|
+
names = readdirSync(root);
|
|
63
|
+
} catch {
|
|
64
|
+
return removed;
|
|
65
|
+
}
|
|
66
|
+
for (const name of names) {
|
|
67
|
+
const match = OWNED_NAME.exec(name);
|
|
68
|
+
if (!match)
|
|
69
|
+
continue;
|
|
70
|
+
const pid = Number(match[1]);
|
|
71
|
+
if (pid === process.pid || isAlive(pid))
|
|
72
|
+
continue;
|
|
73
|
+
const path = join(root, name);
|
|
74
|
+
try {
|
|
75
|
+
if (!statSync(path).isDirectory())
|
|
76
|
+
continue;
|
|
77
|
+
if (now - statSync(path).mtimeMs < minAge)
|
|
78
|
+
continue;
|
|
79
|
+
if (existsSync(join(path, KEEP_MARKER)))
|
|
80
|
+
continue;
|
|
81
|
+
} catch {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
removeQuietly(path);
|
|
85
|
+
removed.push(path);
|
|
86
|
+
}
|
|
87
|
+
return removed;
|
|
88
|
+
}
|
|
89
|
+
export function tempDirPrefix(label) {
|
|
90
|
+
const bare = label.replace(/^stx-/, "").replace(/-+$/, "");
|
|
91
|
+
return bare ? `stx-${bare}-p${process.pid}-` : `stx-p${process.pid}-`;
|
|
92
|
+
}
|
|
93
|
+
export function keepTempDirsRequested(env = process.env) {
|
|
94
|
+
const value = env.STX_KEEP_TEMP?.trim().toLowerCase();
|
|
95
|
+
return !!value && value !== "0" && value !== "false";
|
|
96
|
+
}
|
|
97
|
+
export function createTempDir(label = "stx", root = tmpdir()) {
|
|
98
|
+
if (!sweptRoots.has(root)) {
|
|
99
|
+
sweptRoots.add(root);
|
|
100
|
+
sweepOrphanedTempDirs({ root });
|
|
101
|
+
}
|
|
102
|
+
const dir = mkdtempSync(join(root, tempDirPrefix(label)));
|
|
103
|
+
if (keepTempDirsRequested()) {
|
|
104
|
+
keepTempDir(dir);
|
|
105
|
+
console.warn(`[stx] STX_KEEP_TEMP: keeping ${dir}`);
|
|
106
|
+
return dir;
|
|
107
|
+
}
|
|
108
|
+
hook();
|
|
109
|
+
live.add(dir);
|
|
110
|
+
return dir;
|
|
111
|
+
}
|
|
112
|
+
export function removeTempDir(dir) {
|
|
113
|
+
if (kept.has(dir))
|
|
114
|
+
return;
|
|
115
|
+
removeQuietly(dir);
|
|
116
|
+
live.delete(dir);
|
|
117
|
+
if (live.size === 0)
|
|
118
|
+
unhook();
|
|
119
|
+
}
|
|
120
|
+
export function keepTempDir(dir) {
|
|
121
|
+
try {
|
|
122
|
+
writeFileSync(join(dir, KEEP_MARKER), `kept by pid ${process.pid}
|
|
123
|
+
`);
|
|
124
|
+
} catch {}
|
|
125
|
+
kept.add(dir);
|
|
126
|
+
live.delete(dir);
|
|
127
|
+
if (live.size === 0)
|
|
128
|
+
unhook();
|
|
129
|
+
}
|
|
130
|
+
export async function withTempDir(label, fn) {
|
|
131
|
+
const dir = createTempDir(label);
|
|
132
|
+
try {
|
|
133
|
+
return await fn(dir);
|
|
134
|
+
} finally {
|
|
135
|
+
removeTempDir(dir);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export function liveTempDirs() {
|
|
139
|
+
return [...live];
|
|
140
|
+
}
|