@stacksjs/stx 0.2.422 → 0.2.423
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-ep5jnqdb.js → chunk-02n071n7.js} +6 -6
- package/dist/chunk-03n23sh6.js +2 -0
- package/dist/chunk-07mxghsz.js +2 -0
- package/dist/{chunk-kjkwycce.js → chunk-0bmc75w6.js} +4 -4
- package/dist/{chunk-hyak4dzg.js → chunk-0hhq9hbq.js} +3 -3
- package/dist/{chunk-66k7yxnr.js → chunk-12pvnn1e.js} +4 -4
- package/dist/chunk-1497wcxc.js +2 -0
- package/dist/chunk-17n9e5wk.js +2 -0
- package/dist/chunk-1p8hc1ve.js +2 -0
- package/dist/chunk-1r3ghgsz.js +2 -0
- package/dist/{chunk-681cxw8j.js → chunk-24e7qjb8.js} +2 -2
- package/dist/chunk-259ecbwa.js +2 -0
- package/dist/chunk-26gfsa9w.js +2 -0
- package/dist/{chunk-zp0mg8b2.js → chunk-2bpjq1qz.js} +2 -2
- package/dist/{chunk-11ra3sbc.js → chunk-2x9jd5w0.js} +3 -3
- package/dist/{chunk-k31fwm2w.js → chunk-3hmy75tw.js} +5 -5
- package/dist/{chunk-12b8akfg.js → chunk-3pxp0r0a.js} +3 -3
- package/dist/{chunk-x5ks23vx.js → chunk-3ry9ca1s.js} +2 -2
- package/dist/{chunk-th9s15es.js → chunk-45rfv3a5.js} +2 -2
- package/dist/chunk-47apfsxp.js +2 -0
- package/dist/{chunk-w72p2ak0.js → chunk-48kgnqpk.js} +4 -4
- package/dist/{chunk-rsxvbnp4.js → chunk-4hd5wb8x.js} +3 -3
- package/dist/chunk-535nrr6j.js +2 -0
- package/dist/chunk-5mfhk69g.js +2 -0
- package/dist/{chunk-aync8qmk.js → chunk-5vwg3h5g.js} +2 -2
- package/dist/{chunk-tspmynvh.js → chunk-62chbqev.js} +1 -1
- package/dist/chunk-6c7294j8.js +2 -0
- package/dist/{chunk-qwgdtrhj.js → chunk-6cbvx87h.js} +5 -5
- package/dist/{chunk-q0cehgy2.js → chunk-6fsbny9m.js} +3 -3
- package/dist/chunk-6gh2rvyz.js +2 -0
- package/dist/chunk-6j6gbp0y.js +2 -0
- package/dist/chunk-6jgjmycb.js +2 -0
- package/dist/{chunk-w83djypm.js → chunk-6t278w29.js} +2 -2
- package/dist/{chunk-5vfyxxrp.js → chunk-6t7mxb0b.js} +2 -2
- package/dist/chunk-6wmxrn6x.js +2 -0
- package/dist/chunk-6wweqfg7.js +2 -0
- package/dist/{chunk-ja7znxnz.js → chunk-7a9h7ycs.js} +5 -5
- package/dist/chunk-7pbv9mg7.js +2 -0
- package/dist/{chunk-09hhrjk9.js → chunk-89b2r1q0.js} +6 -6
- package/dist/{chunk-0varh725.js → chunk-8a0r2j8f.js} +3 -3
- package/dist/{chunk-gp8xzbyt.js → chunk-8nsbf2mz.js} +1074 -1074
- package/dist/{chunk-mg13q1kd.js → chunk-8zf5q1m3.js} +2 -2
- package/dist/chunk-9d53d0t6.js +2 -0
- package/dist/chunk-9j72har9.js +2 -0
- package/dist/chunk-9yqz5ge5.js +2 -0
- package/dist/chunk-a5c9n7an.js +2 -0
- package/dist/chunk-a836zn7c.js +2 -0
- package/dist/{chunk-kzkjc12e.js → chunk-a8g6y9kw.js} +5 -5
- package/dist/{chunk-21a7p956.js → chunk-acwgap78.js} +1 -1
- package/dist/{chunk-qx3js9tk.js → chunk-aen2baze.js} +1 -1
- package/dist/chunk-ahgrkva8.js +2 -0
- package/dist/chunk-akbb6j7s.js +2 -0
- package/dist/chunk-avakcrbs.js +2 -0
- package/dist/{chunk-tafebmtg.js → chunk-axydabse.js} +2 -2
- package/dist/{chunk-4n6c5rp5.js → chunk-b7973zvk.js} +2 -2
- package/dist/{chunk-ebkpdc45.js → chunk-bxwe7wxj.js} +10 -10
- package/dist/{chunk-2ewa2sg5.js → chunk-c1dmr865.js} +3 -3
- package/dist/chunk-cenq2n6e.js +2 -0
- package/dist/{chunk-zvh2nnzr.js → chunk-cf6htz63.js} +1 -1
- package/dist/chunk-cnmz9543.js +2 -0
- package/dist/{chunk-h1585jbm.js → chunk-cx2rdew4.js} +13 -13
- package/dist/{chunk-wg1ttvs5.js → chunk-cznsm2n3.js} +2 -2
- package/dist/chunk-d1qzhawc.js +2 -0
- package/dist/chunk-d6hnvwre.js +2 -0
- package/dist/{chunk-7abgzdsm.js → chunk-dcwjxq8n.js} +2 -2
- package/dist/chunk-dhqwg62x.js +2 -0
- package/dist/{chunk-95e3rz88.js → chunk-dmd6yk2x.js} +5 -5
- package/dist/chunk-e18qfegt.js +2 -0
- package/dist/chunk-eej89wkt.js +2 -0
- package/dist/chunk-ekxffxbd.js +2 -0
- package/dist/{chunk-hy9e3ny6.js → chunk-ex0tq6x2.js} +1 -1
- package/dist/{chunk-nqr77pxk.js → chunk-fg5ve6ey.js} +2 -2
- package/dist/{chunk-dejsjk4h.js → chunk-fnt1q1sp.js} +11 -11
- package/dist/chunk-g67gg66e.js +2 -0
- package/dist/chunk-gq16fxc2.js +2 -0
- package/dist/{chunk-5e9zkd65.js → chunk-h3c7z73m.js} +2 -2
- package/dist/chunk-h4avjh3q.js +2 -0
- package/dist/chunk-h7qte7ye.js +2 -0
- package/dist/{chunk-hmdnn9ja.js → chunk-hb9gxad0.js} +3 -3
- package/dist/{chunk-dmxh7zwq.js → chunk-hg4k3nkr.js} +1 -1
- package/dist/{chunk-dhxbjw6k.js → chunk-hnep9jbj.js} +2 -2
- package/dist/chunk-hwycbxg7.js +2 -0
- package/dist/{chunk-34gy5zjm.js → chunk-j1q65enz.js} +2 -2
- package/dist/chunk-j5myfxe8.js +18 -0
- package/dist/{chunk-8jqy69td.js → chunk-j7zywbq0.js} +2 -2
- package/dist/{chunk-788g87ft.js → chunk-jbrdebzs.js} +7 -7
- package/dist/{chunk-wr6b99pw.js → chunk-jj4pyeyj.js} +1 -1
- package/dist/{chunk-g1fxmp9z.js → chunk-k8sqs7j2.js} +4 -4
- package/dist/chunk-mg7jhx5v.js +2 -0
- package/dist/chunk-n16wa755.js +2 -0
- package/dist/chunk-ngv1c807.js +2 -0
- package/dist/{chunk-krr2vb0s.js → chunk-p2x7tjbt.js} +3 -3
- package/dist/{chunk-62r4fa4q.js → chunk-ptjqacjd.js} +2 -2
- package/dist/{chunk-597rfddk.js → chunk-qm1tt8g1.js} +2334 -2334
- package/dist/chunk-r7r5h2eh.js +2 -0
- package/dist/chunk-rhkx17d9.js +2 -0
- package/dist/{chunk-b1fg9vg7.js → chunk-s28eh0jn.js} +2 -2
- package/dist/{chunk-837nb4zv.js → chunk-s295vp9x.js} +3 -3
- package/dist/chunk-sazpw71r.js +4 -0
- package/dist/{chunk-20tdz0zs.js → chunk-sbdzqqr1.js} +6 -6
- package/dist/{chunk-qby6wxat.js → chunk-spx27cs4.js} +2 -2
- package/dist/{chunk-n7jjp08m.js → chunk-stxmwytg.js} +2 -2
- package/dist/{chunk-2tfe2g58.js → chunk-t3wh1jbk.js} +6 -6
- package/dist/{chunk-802pr252.js → chunk-tfexmdkt.js} +2 -2
- package/dist/{chunk-2cn8krpp.js → chunk-tfz95n7j.js} +5 -5
- package/dist/chunk-thdbqsxq.js +2 -0
- package/dist/chunk-tpnfcb83.js +2 -0
- package/dist/chunk-tqkv4th9.js +2 -0
- package/dist/chunk-tznejj9h.js +2 -0
- package/dist/{chunk-ap6fehea.js → chunk-vfk725vm.js} +5 -5
- package/dist/chunk-vsrm9k7p.js +2 -0
- package/dist/chunk-vwms759h.js +2 -0
- package/dist/{chunk-xvzxrt9a.js → chunk-w2085fwx.js} +5 -5
- package/dist/chunk-w252cgnv.js +30 -0
- package/dist/chunk-whdw6dhb.js +2 -0
- package/dist/chunk-wtms9jhs.js +3 -0
- package/dist/chunk-wtqjfar3.js +2 -0
- package/dist/chunk-wx7kfet5.js +2 -0
- package/dist/chunk-wy873fy8.js +2 -0
- package/dist/{chunk-d2z6828s.js → chunk-xa3wsmt5.js} +11 -11
- package/dist/chunk-xrbqf77j.js +2 -0
- package/dist/{chunk-757ec865.js → chunk-yaebdyfr.js} +2 -2
- package/dist/chunk-ycpq3gxc.js +2 -0
- package/dist/chunk-yd50awqp.js +3 -0
- package/dist/{chunk-csjw5esc.js → chunk-ydz7w2mt.js} +2 -2
- package/dist/chunk-yjgbxf26.js +2 -0
- package/dist/{chunk-jjnfj9nf.js → chunk-yqsza22w.js} +2 -2
- package/dist/{chunk-3xm6dyab.js → chunk-zbr333kf.js} +88 -27
- package/dist/chunk-zcyjdcpx.js +33 -0
- package/dist/{chunk-tqnysw0k.js → chunk-zfzcedw4.js} +4 -4
- package/dist/chunk-zm73n103.js +2 -0
- package/dist/cli.js +20 -20
- package/dist/component-renderer.js +54 -2
- package/dist/composables/use-outbox.d.ts +1 -0
- package/dist/composables/use-outbox.js +14 -4
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/database.js +2 -2
- package/dist/native/bridge/protocol.d.ts +5 -0
- package/dist/native/bridge/protocol.js +3 -0
- package/dist/native/cli.js +12 -2
- package/dist/native/compiler/bundle.d.ts +4 -3
- package/dist/native/compiler/bundle.js +46 -51
- package/dist/native/compiler/component-mapping.d.ts +5 -0
- package/dist/native/compiler/component-mapping.js +90 -0
- package/dist/native/compiler/html-to-ir.js +42 -6
- package/dist/native/compiler/ir.d.ts +2 -0
- package/dist/native/compiler/render-screen.d.ts +4 -0
- package/dist/native/compiler/render-screen.js +10 -2
- package/dist/native/compiler/setup-script.d.ts +6 -0
- package/dist/native/compiler/setup-script.js +10 -0
- package/dist/native/components/primitives.d.ts +10 -0
- package/dist/native/index.d.ts +6 -24
- package/dist/native/index.js +1 -17
- package/dist/native/primitives/Button.stx +2 -1
- package/dist/native/primitives/Text.stx +2 -1
- package/dist/native/primitives/TextInput.stx +3 -1
- package/dist/native/prop-names.d.ts +2 -0
- package/dist/native/prop-names.js +71 -0
- package/dist/native/runtime/binding-tree.d.ts +31 -0
- package/dist/native/runtime/binding-tree.js +100 -0
- package/dist/native/runtime/craft-bridge.d.ts +9 -0
- package/dist/native/runtime/craft-bridge.js +231 -0
- package/dist/native/runtime/craft.d.ts +28 -3
- package/dist/native/runtime/jsc-globals.d.ts +16 -0
- package/dist/native/runtime/jsc-globals.js +64 -0
- package/dist/native/runtime/native-host.d.ts +3 -1
- package/dist/native/runtime/native-host.js +183 -33
- package/dist/native/runtime/shared-screen.d.ts +15 -0
- package/dist/native/runtime/shared-screen.js +41 -0
- package/dist/pwa.js +3 -3
- package/dist/signal-processing.d.ts +3 -1
- package/dist/signal-processing.js +4 -3
- package/dist/signals.js +77 -16
- package/dist/ssg.js +28 -28
- package/package.json +5 -5
- package/dist/chunk-10fh9qhe.js +0 -2
- package/dist/chunk-1569v24d.js +0 -2
- package/dist/chunk-18awnp9d.js +0 -2
- package/dist/chunk-1r0c5920.js +0 -30
- package/dist/chunk-2hswgxpb.js +0 -2
- package/dist/chunk-4363reg4.js +0 -2
- package/dist/chunk-48axv7bm.js +0 -2
- package/dist/chunk-50hgr79y.js +0 -2
- package/dist/chunk-54wczcee.js +0 -2
- package/dist/chunk-74gz26zs.js +0 -2
- package/dist/chunk-7906p8zs.js +0 -2
- package/dist/chunk-7dkfjmjw.js +0 -2
- package/dist/chunk-7vr5w75r.js +0 -4
- package/dist/chunk-7zn0yyqk.js +0 -2
- package/dist/chunk-8d2kamh2.js +0 -2
- package/dist/chunk-8ttvazck.js +0 -2
- package/dist/chunk-8y4bqsxz.js +0 -2
- package/dist/chunk-9bpnz431.js +0 -2
- package/dist/chunk-ac033b93.js +0 -2
- package/dist/chunk-aj43359g.js +0 -2
- package/dist/chunk-aj8yq228.js +0 -2
- package/dist/chunk-as72dvvm.js +0 -2
- package/dist/chunk-bfvaxrq0.js +0 -2
- package/dist/chunk-bkaw7sgz.js +0 -2
- package/dist/chunk-d0q2x8e3.js +0 -2
- package/dist/chunk-d2c5727w.js +0 -2
- package/dist/chunk-d5amzers.js +0 -2
- package/dist/chunk-dfchrqw5.js +0 -2
- package/dist/chunk-epv0ahg1.js +0 -2
- package/dist/chunk-f5489ese.js +0 -2
- package/dist/chunk-fqq1w9m1.js +0 -2
- package/dist/chunk-hcgsgnq8.js +0 -2
- package/dist/chunk-hgqcqg1h.js +0 -2
- package/dist/chunk-hjdwf9gp.js +0 -2
- package/dist/chunk-hp7ewdnp.js +0 -2
- package/dist/chunk-jjtzm6dn.js +0 -3
- package/dist/chunk-js79j12f.js +0 -18
- package/dist/chunk-kfsp322p.js +0 -2
- package/dist/chunk-kt557jaj.js +0 -2
- package/dist/chunk-n8kqvzba.js +0 -2
- package/dist/chunk-na70r4sp.js +0 -2
- package/dist/chunk-p083sckk.js +0 -2
- package/dist/chunk-pc178389.js +0 -2
- package/dist/chunk-psqk7932.js +0 -2
- package/dist/chunk-pv5nr9pd.js +0 -2
- package/dist/chunk-q1v0jwr4.js +0 -2
- package/dist/chunk-qeye0901.js +0 -2
- package/dist/chunk-qy59yp2v.js +0 -2
- package/dist/chunk-r5gjb55x.js +0 -2
- package/dist/chunk-tf44jyrh.js +0 -2
- package/dist/chunk-tfypkw4y.js +0 -3
- package/dist/chunk-vv4kkwhn.js +0 -2
- package/dist/chunk-vwhd3h8x.js +0 -2
- package/dist/chunk-vxj8kd2v.js +0 -2
- package/dist/chunk-vzzpvn21.js +0 -2
- package/dist/chunk-w1a2v264.js +0 -2
- package/dist/chunk-wcs7w8wv.js +0 -2
- package/dist/chunk-x6ndnpvr.js +0 -2
- package/dist/chunk-x8rckpyz.js +0 -2
- package/dist/chunk-ya0qecph.js +0 -27
- package/dist/chunk-ykwmqh8z.js +0 -2
- package/dist/chunk-ys71pmrb.js +0 -2
- package/dist/chunk-z5y4qyhg.js +0 -2
- package/dist/chunk-zpcz2kh6.js +0 -2
- package/dist/native/compiler/codegen.d.ts +0 -10
- package/dist/native/compiler/codegen.js +0 -145
- package/dist/native/compiler/parser.d.ts +0 -88
- package/dist/native/compiler/parser.js +0 -753
- package/dist/native/runtime/entry.d.ts +0 -1
- package/dist/native/runtime/entry.js +0 -3
- package/dist/native/runtime/index.d.ts +0 -45
- package/dist/native/runtime/index.js +0 -165
- package/dist/native/runtime/screen.d.ts +0 -43
- package/dist/native/runtime/screen.js +0 -808
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{h,d,
|
|
2
|
+
import{h,d,n,g,A}from"./chunk-qm1tt8g1.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,s;M.lastIndex=0;while((s=M.exec(e))!==null){if(s.index>o){let a=e.slice(o,s.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let r=s[1],i=s[2];t.push({type:"suspense",name:r,content:i}),o=s.index+s[0].length}if(o<e.length){let r=e.slice(o);if(r.trim())t.push({type:t.length===0?"shell":"content",content:r})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Jl(e,t={},o={}){let s={...A,...o,streaming:{...q,...o.streaming}},r=s.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(m.trim())await d(m,y,e);let E=H(c),u=new Set;if(!E.some((w)=>w.type==="suspense")){let w=s.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let p=await n(c,y,e,s,u);for(let b=0;b<p.length;b+=r)i.enqueue(p.slice(b,b+r)),await new Promise((f)=>setTimeout(f,0))}else{let p=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)p.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of p){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await n(I,y,e,s,u);i.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await n(_.content,y,e,s,u);i.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await n(_,y,e,s,u);i.enqueue(C)}}}}else{let w=new Map;for(let l of E)if(l.type==="shell"||l.type==="content"){let p=await n(l.content,y,e,s,u);i.enqueue(p)}else if(l.type==="suspense"&&l.name){let p=`stx-suspense-${l.name}`;i.enqueue(`<div id="${p}" data-suspense="${l.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
|
-
</div>`),w.set(l.name,
|
|
4
|
+
</div>`),w.set(l.name,n(l.content,y,e,s,u))}i.enqueue(`
|
|
5
5
|
<script>
|
|
6
6
|
(function() {
|
|
7
7
|
window.__stxSuspense = window.__stxSuspense || {
|
|
@@ -17,13 +17,13 @@ import{h,d,r,g,A}from"./chunk-597rfddk.js";import k from"path";var q={enabled:!0
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
})();
|
|
20
|
-
</script>`);let x=Array.from(w.entries()).map(async([l,p])=>{i.enqueue(await
|
|
20
|
+
</script>`);let x=Array.from(w.entries()).map(async([l,p])=>{i.enqueue(await fi(l,p))});await Promise.all(x)}i.close()}catch(a){i.error(a)}}})}async function fi(e,t){try{let s=(await t).replace(/`/g,"\\`").replace(/<\/script>/gi,"<\\/script>");return`
|
|
21
21
|
<script>
|
|
22
|
-
window.__stxSuspense.resolve('${e}', \`${
|
|
23
|
-
</script>`}catch(o){let
|
|
22
|
+
window.__stxSuspense.resolve('${e}', \`${s}\`);
|
|
23
|
+
</script>`}catch(o){let s=o instanceof Error?o.message:String(o);return`
|
|
24
24
|
<script>
|
|
25
|
-
window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading content: ${h(
|
|
26
|
-
</script>`}}var
|
|
25
|
+
window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading content: ${h(s)}</div>');
|
|
26
|
+
</script>`}}var $a=`
|
|
27
27
|
<script>
|
|
28
28
|
(function(){
|
|
29
29
|
window.__stxSuspense = window.__stxSuspense || {
|
|
@@ -43,12 +43,12 @@ window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading conte
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
})();
|
|
46
|
-
</script>`;function z(e,t,o){if(!t||t<=0)return e;let
|
|
46
|
+
</script>`;function z(e,t,o){if(!t||t<=0)return e;let s,r=new Promise((i,a)=>{s=setTimeout(()=>a(Error(`streaming boundary "${o}" timed out after ${t}ms`)),t)});return Promise.race([e,r]).finally(()=>clearTimeout(s))}function Yl(e,t=[],o={}){let s=o.timeoutMs??0;return new ReadableStream({async start(r){try{if(r.enqueue(e),t.length>0)r.enqueue($a),await Promise.all(t.map(async(i)=>{let a=z(i.render(),s,i.id);r.enqueue(await fi(i.id,a))}));r.close()}catch(i){r.error(i)}}})}var B=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;function Zl(e,t){return e.replace(B,(o,s,r)=>{let i=s.trim(),a=r.split(/@fallback/i),S=a[0].trim(),m=a.length>1?a.slice(1).join("@fallback").trim():"";if(!t.__streamTemplates)t.__streamTemplates={};return t.__streamTemplates[i]=S,`<div data-suspense="${i}">${m}</div>`})}function Ql(e){let t=e?.streamBoundaries;if(!t||typeof t!=="object")return;let o=Object.entries(t).filter(([,s])=>typeof s==="function");return o.length>0?o.map(([s,r])=>({id:s,render:r})):void 0}async function eu(e,t={},o={}){let s={...A,...o,streaming:{...q,...o.streaming}},r=s.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(m.trim())await d(m,y,e);let E=new Set,u=s.streaming?.strategy||"auto",R=new RegExp(T.source,"g");if(!(u!=="manual"&&R.test(c))){let x=await n(c,y,e,s,E);for(let l=0;l<x.length;l+=r)i.enqueue(x.slice(l,l+r))}else{let x=[],l=new RegExp(T.source,"g"),p;while((p=l.exec(c))!==null)x.push({name:p[1],content:p[2],start:p.index,end:p.index+p[0].length});let b=0;for(let f of x){if(f.start>b){let _=c.slice(b,f.start);if(_.trim()){let C=await n(_,y,e,s,E);i.enqueue(C)}}let v=await n(f.content,y,e,s,E);i.enqueue(v),b=f.end}if(b<c.length){let f=c.slice(b);if(f.trim()){let v=await n(f,y,e,s,E);i.enqueue(v)}}}i.close()}catch(a){i.error(a)}}})}async function tu(e,t={}){let o={...A,...t,streaming:{...q,...t.streaming}},s=await Bun.file(e).text(),r=s.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),i=r?r[1]:"",a=s.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S=a,m={},c;T.lastIndex=0;while((c=T.exec(a))!==null){let u=c[1],R=c[2];m[u]=R}let y=a.replace(T,"");return{renderShell:async(u={})=>{let R={...u,__filename:e,__dirname:k.dirname(e)};return await d(i,R,e),n(y,R,e,o,new Set)},renderSection:async(u,R={})=>{try{if(!m[u])return`<div class="error-message">Section "${h(u)}" not found in template "${h(e)}"</div>`;let w={...R,__filename:e,__dirname:k.dirname(e)};await d(i,w,e);let x=new Set;return await n(m[u],w,e,o,x)}catch(w){let x=w instanceof Error?w.message:String(w);return g("Expression",x,e,m[u]||"",0,m[u]||"")}},getSections:()=>Object.keys(m),getTemplate:()=>S}}var Ea={name:"suspense",hasEndTag:!0,handler:(e,t,o,s)=>{if(!t||t.length===0)throw Error("Suspense directive requires a name parameter");let r=t[0].replace(/['"`]/g,"");return`<!-- @suspense:${r} -->${e}<!-- @endsuspense:${r} -->`}},Ta={name:"island",hasEndTag:!0,handler:(e,t,o,s)=>{if(!t||t.length===0)throw Error("Island directive requires a name parameter");let r=t[0].replace(/['"`]/g,""),i=t[1]?t[1].replace(/['"`]/g,""):"lazy",a=`island-${r}-${Math.random().toString(36).substring(2,9)}`,S=e.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),m=S?S[1].trim():"",c=S?e.replace(S[0],""):e;return`<div data-island="${r}" data-island-id="${a}" data-priority="${i}">
|
|
47
47
|
${c}
|
|
48
48
|
<script type="application/json" data-island-props="${a}">
|
|
49
49
|
${m?`{${m}}`:"{}"}
|
|
50
50
|
</script>
|
|
51
|
-
</div>`}};function
|
|
51
|
+
</div>`}};function nu(e={}){let t=[];if(e.streaming?.enabled)t.push(Ea);if(e.hydration?.enabled)t.push(Ta);return t}async function ru(e,t,o,s={}){return e}function su(e,t={}){let o=new TextEncoder,s=e.pipeThrough(new TransformStream({transform(i,a){a.enqueue(o.encode(i))}})),r=new Headers(t.headers);if(!r.has("Content-Type"))r.set("Content-Type","text/html; charset=utf-8");if(!r.has("Transfer-Encoding"))r.set("Transfer-Encoding","chunked");if(!r.has("X-Content-Type-Options"))r.set("X-Content-Type-Options","nosniff");if(!r.has("X-Accel-Buffering"))r.set("X-Accel-Buffering","no");return new Response(s,{...t,headers:r})}function iu(e={mode:"full"}){let{mode:t,components:o={},dynamicImports:s=!0}=e,r=Object.entries(o).map(([i,a])=>`'${i}': ${s?`() => import('${a}')`:`require('${a}')`}`).join(`,
|
|
52
52
|
`);if(t==="loader")return`
|
|
53
53
|
(function() {
|
|
54
54
|
window.__stx = window.__stx || {};
|
|
@@ -64,7 +64,7 @@ window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading conte
|
|
|
64
64
|
const stx = {
|
|
65
65
|
// Component registry
|
|
66
66
|
components: {
|
|
67
|
-
${
|
|
67
|
+
${r}
|
|
68
68
|
},
|
|
69
69
|
|
|
70
70
|
// Loaded island instances
|
|
@@ -191,4 +191,4 @@ else {
|
|
|
191
191
|
stx.hydrate();
|
|
192
192
|
}
|
|
193
193
|
})();`}
|
|
194
|
-
export{
|
|
194
|
+
export{Jl,fi,$a,Yl,Zl,Ql,eu,tu,Ea,Ta,nu,ru,su,iu};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Jl,fi,$a,Yl,Zl,Ql,eu,tu,Ea,Ta,nu,ru,su,iu}from"./chunk-xa3wsmt5.js";import"./chunk-qm1tt8g1.js";import"./chunk-2x9jd5w0.js";import"./chunk-3ry9ca1s.js";import"./chunk-k8sqs7j2.js";import"./chunk-h3c7z73m.js";import"./chunk-ptjqacjd.js";import"./chunk-jbrdebzs.js";import"./chunk-48kgnqpk.js";import"./chunk-89b2r1q0.js";import"./chunk-axydabse.js";import"./chunk-yaebdyfr.js";import"./chunk-12pvnn1e.js";import"./chunk-b7973zvk.js";export{$a as SUSPENSE_RESOLVER_RUNTIME,fi as buildSuspenseResolveScript,tu as createStreamRenderer,Ql as extractStreamBoundaries,iu as generateHydrationRuntime,Ta as islandDirective,ru as processSectionDirectives,Zl as processStreamDirectives,nu as registerStreamingDirectives,Yl as renderStreamingPage,Jl as streamTemplate,eu as streamTemplateSimple,su as streamToResponse,Ea as streamingSuspenseDirective};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import u from"fs";import l from"path";var g=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^<>()]*>)?\s*\(/,x=/(?:^|\n)\s*(?:import|export)\s+(?:[^'"]*?\sfrom\s+)?['"](\.[^'"]*)['"]/g,b=["",".ts",".tsx",".js",".jsx",".mts",".mjs","/index.ts","/index.js"],h=3;function y(e,t){let r=l.resolve(l.dirname(t),e);for(let o of b){let s=r+o;try{if(u.statSync(s).isFile())return s}catch{}}return null}function
|
|
3
|
-
export{
|
|
2
|
+
import u from"fs";import l from"path";var g=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^<>()]*>)?\s*\(/,x=/(?:^|\n)\s*(?:import|export)\s+(?:[^'"]*?\sfrom\s+)?['"](\.[^'"]*)['"]/g,b=["",".ts",".tsx",".js",".jsx",".mts",".mjs","/index.ts","/index.js"],h=3;function y(e,t){let r=l.resolve(l.dirname(t),e);for(let o of b){let s=r+o;try{if(u.statSync(s).isFile())return s}catch{}}return null}function fn(e,t,r=0,o=new Set){if(!t||r>=h)return!1;for(let s of e.matchAll(x)){let n=y(s[1],t);if(!n||o.has(n))continue;o.add(n);let i;try{i=u.readFileSync(n,"utf8")}catch{continue}if(g.test(i))return!0;if(fn(i,n,r+1,o))return!0}return!1}var m=["batch","cachedQuery","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","flushKeptState","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refresh","registerStoresClient","setKeptScope","setRouteParams","state","untrack","useAsync","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useTimeout","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"],vo=["onMount","onDestroy"];function _t(e="const",t=[],r){let o=t.length?m.filter((s)=>!t.includes(s)):m;if(r!==void 0)o=o.filter((s)=>{let n=s.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(^|[^\\w$])${n}(?![\\w$])`).test(r)});return`${e} { ${o.join(", ")} } = window.stx;`}var E=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var S=m.filter((e)=>!E.includes(e));function Rs(e){if(!e)return!1;return S.some((t)=>new RegExp(`\\b${t}\\s*(?:<[^>]*>)?\\s*\\(`).test(e))}var v=[/@if\s*=/,/@for\s*=/,/@show\s*=/,/@model\s*=/,/@bind:/,/@class\s*=/,/@style\s*=/,/\bx-data\s*=/,/\bstate\s*(?:<[^>]*>)?\s*\(/,/\bderived\s*(?:<[^>]*>)?\s*\(/,/\beffect\s*(?:<[^>]*>)?\s*\(/,/\bref\s*(?:<[^>]*>)?\s*\(/,/\bcomputed\s*(?:<[^>]*>)?\s*\(/,/\breactive\s*(?:<[^>]*>)?\s*\(/,/\bwatch\s*(?:<[^>]*>)?\s*\(/,/\bwatchEffect\s*(?:<[^>]*>)?\s*\(/,/\s:[a-z][\w-]*\s*=\s*["']/i,/\s:(?:if|else-if|else|for|show|text|html|model)\s*=/,/data-stx(?:-auto)?(?![-\w])/,/data-stx-scoped/],T=/\s@[a-z][\w.:-]*\s*=/i;function wo(e,t){if(!e)return!1;let r=f(e);return d(r,t)}function d(e,t){if(v.some((r)=>r.test(e)))return!0;if(Rs(e))return!0;return R(e,t)}function R(e,t){if(!t)return!1;for(let r of e.matchAll(/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script\s*>/gi))if(fn(r[1],t))return!0;return!1}function xo(e,t){if(!e)return!1;let r=f(e);return T.test(r)||d(r,t)}var _=["if","else-if","elseif","else","for","show","key","text","html","model","ref"];function So(e){return _.includes(e.toLowerCase())}var rr=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],w=["x-init","x-transition","x-effect","x-on"],ko=[...rr,...w];function Co(){return`{${rr.map((e)=>`'${e}':1`).join(",")}}`}var As=["class","style","text","html","show","model","if","ref"];function $o(){return`{${As.map((e)=>e==="if"?"'if':1":`${e}:1`).join(",")}}`}var p=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","keydown","keyup","keypress","input","change","submit","focus","blur","scroll","resize","touchstart","touchend","touchmove","contextmenu","wheel","pointerdown","pointerup","pointermove"];function Eo(){return`/^(${p.join("|")})/`}function To(e){return p.some((t)=>e===t||e.startsWith(`${t}.`))}var A=65536,N=4,c=new Map;function f(e){if(!e)return e;if(!e.includes("<!--")&&!/<(?:pre|code)\b/i.test(e))return e;let t=e.length>=A;if(t){let s=c.get(e);if(s!==void 0)return s}let r=(s)=>s.replace(/(<[^>]*>)|([^<]+)/g,(n,i,a)=>i??" ".repeat(a.length)),o=e.replace(/(<pre\b[^>]*>)([\s\S]*?)(<\/pre>)/gi,(s,n,i,a)=>n+r(i)+a).replace(/(<code\b[^>]*>)([\s\S]*?)(<\/code>)/gi,(s,n,i,a)=>n+r(i)+a).replace(/<!--[\s\S]*?-->/g,(s)=>" ".repeat(s.length));if(t){while(c.size>=N){let s=c.keys().next();if(s.done)break;c.delete(s.value)}c.set(e,o)}return o}
|
|
3
|
+
export{fn,m,vo,_t,Rs,wo,xo,So,rr,ko,Co,As,$o,Eo,To};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Io,Do}from"./chunk-8nsbf2mz.js";import"./chunk-a8g6y9kw.js";import"./chunk-7a9h7ycs.js";import"./chunk-bxwe7wxj.js";import"./chunk-5vwg3h5g.js";import"./chunk-cx2rdew4.js";import"./chunk-sazpw71r.js";import"./chunk-spx27cs4.js";import"./chunk-stxmwytg.js";import"./chunk-2bpjq1qz.js";import"./chunk-dcwjxq8n.js";import{Qs}from"./chunk-w252cgnv.js";import"./chunk-aen2baze.js";import"./chunk-24e7qjb8.js";import"./chunk-6t278w29.js";import"./chunk-ex0tq6x2.js";import"./chunk-4hd5wb8x.js";import"./chunk-02n071n7.js";import"./chunk-t3wh1jbk.js";import"./chunk-s295vp9x.js";import"./chunk-s28eh0jn.js";import"./chunk-6fsbny9m.js";import"./chunk-j1q65enz.js";import"./chunk-8a0r2j8f.js";import"./chunk-vfk725vm.js";import"./chunk-w2085fwx.js";import"./chunk-zfzcedw4.js";import"./chunk-3hmy75tw.js";import"./chunk-hb9gxad0.js";import"./chunk-zbr333kf.js";import"./chunk-xa3wsmt5.js";import"./chunk-j5myfxe8.js";import"./chunk-c1dmr865.js";import"./chunk-tfz95n7j.js";import"./chunk-6cbvx87h.js";import{me,Zt,Qt,q,d,n,Wn,A,i,ce}from"./chunk-qm1tt8g1.js";import"./chunk-2x9jd5w0.js";import"./chunk-3ry9ca1s.js";import"./chunk-k8sqs7j2.js";import"./chunk-h3c7z73m.js";import"./chunk-ptjqacjd.js";import"./chunk-jbrdebzs.js";import"./chunk-48kgnqpk.js";import"./chunk-89b2r1q0.js";import"./chunk-axydabse.js";import"./chunk-yaebdyfr.js";import"./chunk-12pvnn1e.js";import"./chunk-b7973zvk.js";export{Wn as buildWebComponents,Qt as cacheTemplate,Zt as checkCache,Qs as classifyAllScripts,Io as createMiddleware,Do as createRoute,A as defaultConfig,d as extractVariables,q as injectRouterScript,i as loadStxConfig,me as processClientScript,n as processDirectives,ce as readMarkdownFile};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ie,
|
|
2
|
+
import{ie,pt}from"./chunk-p2x7tjbt.js";import{fe}from"./chunk-yqsza22w.js";function m(e){let t={"cache-first":{className:"CacheFirst",importFrom:"workbox-strategies"},"network-first":{className:"NetworkFirst",importFrom:"workbox-strategies"},"stale-while-revalidate":{className:"StaleWhileRevalidate",importFrom:"workbox-strategies"},"network-only":{className:"NetworkOnly",importFrom:"workbox-strategies"},"cache-only":{className:"CacheOnly",importFrom:"workbox-strategies"}};return t[e]||t["network-first"]}function g(e){return m(e).className}function d(e){let t=e.pwa;if(!t?.enabled)return"";let r=t.routes||[],n=t.cacheStorage,c=[];for(let a of r){let i=g(a.strategy),s=[];if(a.maxAgeSeconds||a.maxEntries||n?.maxEntries){let o=a.maxEntries||n?.maxEntries||100,u=a.maxAgeSeconds||(n?.maxAge?n.maxAge*24*60*60:void 0);s.push(`new ExpirationPlugin({
|
|
3
3
|
maxEntries: ${o},
|
|
4
4
|
${u?`maxAgeSeconds: ${u},`:""}
|
|
5
5
|
purgeOnQuotaError: true,
|
|
@@ -17,7 +17,7 @@ registerRoute(
|
|
|
17
17
|
],`:""}
|
|
18
18
|
})
|
|
19
19
|
);`)}return c.join(`
|
|
20
|
-
`)}function p(e){if(e.startsWith("*.")){let t=e.slice(2);return`({ request }) => request.destination === '${f(t)}'`}if(e.endsWith("/**"))return`({ url }) => url.pathname.startsWith('${e.slice(0,-3)}')`;if(e.endsWith("/*")){let t=e.slice(0,-2);return`({ url }) => url.pathname.startsWith('${t}') && !url.pathname.slice(${t.length+1}).includes('/')`}if(e.includes("*")&&!e.startsWith("*")){let[t,r]=e.split("*");return`({ url }) => url.pathname.startsWith('${t}') && url.pathname.endsWith('${r}')`}if(e==="/"||!e.includes("*"))return`({ url }) => url.pathname === '${e}'`;return`new RegExp('${x(e).replace(/\\\*/g,".*")}')`}function f(e){return{js:"script",mjs:"script",css:"style",html:"document",htm:"document",png:"image",jpg:"image",jpeg:"image",gif:"image",svg:"image",webp:"image",avif:"image",ico:"image",woff:"font",woff2:"font",ttf:"font",eot:"font",otf:"font"}[e.toLowerCase()]||"empty"}function h(e){return"stx-"+e.replace(/[^\w]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase().slice(0,30)+"-cache"}function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(e,t){let r=e.pwa;if(!r?.enabled)return{mode:"generate",modules:[],skipWaiting:!0,clientsClaim:!0};let n=r.serviceWorker||{},c=r.routes||[],a=[{name:"workbox-precaching",exports:["precacheAndRoute","cleanupOutdatedCaches"]},{name:"workbox-routing",exports:["registerRoute","NavigationRoute","setDefaultHandler"]}],i=new Set;for(let o of c)i.add(g(o.strategy));if(i.size>0)a.push({name:"workbox-strategies",exports:Array.from(i)});if(c.some((o)=>o.maxAgeSeconds||o.maxEntries)||r.cacheStorage)a.push({name:"workbox-expiration",exports:["ExpirationPlugin"]});if(c.some((o)=>o.strategy==="network-first"||o.strategy==="stale-while-revalidate"))a.push({name:"workbox-cacheable-response",exports:["CacheableResponsePlugin"]});if(r.backgroundSync?.enabled)a.push({name:"workbox-background-sync",exports:["BackgroundSyncPlugin","Queue"]});if(n.navigationPreload)a.push({name:"workbox-navigation-preload",exports:["enable"]});let l=t?ie(t,e):void 0;return{mode:"generate",modules:a,precacheManifest:l?.entries,skipWaiting:n.skipWaiting??!0,clientsClaim:n.clientsClaim??!0,offlineFallback:r.offline?.enabled?"/offline.html":void 0,navigationPreload:n.navigationPreload??!1,cacheVersion:n.cacheVersion||"1.0.0"}}function W(e,t){let r=e.pwa;if(!r?.enabled)return"";let n=b(e,t),c=r.serviceWorker||{},{push:a,backgroundSync:i}=r,s=t?ie(t,e):null,l=s?
|
|
20
|
+
`)}function p(e){if(e.startsWith("*.")){let t=e.slice(2);return`({ request }) => request.destination === '${f(t)}'`}if(e.endsWith("/**"))return`({ url }) => url.pathname.startsWith('${e.slice(0,-3)}')`;if(e.endsWith("/*")){let t=e.slice(0,-2);return`({ url }) => url.pathname.startsWith('${t}') && !url.pathname.slice(${t.length+1}).includes('/')`}if(e.includes("*")&&!e.startsWith("*")){let[t,r]=e.split("*");return`({ url }) => url.pathname.startsWith('${t}') && url.pathname.endsWith('${r}')`}if(e==="/"||!e.includes("*"))return`({ url }) => url.pathname === '${e}'`;return`new RegExp('${x(e).replace(/\\\*/g,".*")}')`}function f(e){return{js:"script",mjs:"script",css:"style",html:"document",htm:"document",png:"image",jpg:"image",jpeg:"image",gif:"image",svg:"image",webp:"image",avif:"image",ico:"image",woff:"font",woff2:"font",ttf:"font",eot:"font",otf:"font"}[e.toLowerCase()]||"empty"}function h(e){return"stx-"+e.replace(/[^\w]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase().slice(0,30)+"-cache"}function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(e,t){let r=e.pwa;if(!r?.enabled)return{mode:"generate",modules:[],skipWaiting:!0,clientsClaim:!0};let n=r.serviceWorker||{},c=r.routes||[],a=[{name:"workbox-precaching",exports:["precacheAndRoute","cleanupOutdatedCaches"]},{name:"workbox-routing",exports:["registerRoute","NavigationRoute","setDefaultHandler"]}],i=new Set;for(let o of c)i.add(g(o.strategy));if(i.size>0)a.push({name:"workbox-strategies",exports:Array.from(i)});if(c.some((o)=>o.maxAgeSeconds||o.maxEntries)||r.cacheStorage)a.push({name:"workbox-expiration",exports:["ExpirationPlugin"]});if(c.some((o)=>o.strategy==="network-first"||o.strategy==="stale-while-revalidate"))a.push({name:"workbox-cacheable-response",exports:["CacheableResponsePlugin"]});if(r.backgroundSync?.enabled)a.push({name:"workbox-background-sync",exports:["BackgroundSyncPlugin","Queue"]});if(n.navigationPreload)a.push({name:"workbox-navigation-preload",exports:["enable"]});let l=t?ie(t,e):void 0;return{mode:"generate",modules:a,precacheManifest:l?.entries,skipWaiting:n.skipWaiting??!0,clientsClaim:n.clientsClaim??!0,offlineFallback:r.offline?.enabled?"/offline.html":void 0,navigationPreload:n.navigationPreload??!1,cacheVersion:n.cacheVersion||"1.0.0"}}function W(e,t){let r=e.pwa;if(!r?.enabled)return"";let n=b(e,t),c=r.serviceWorker||{},{push:a,backgroundSync:i}=r,s=t?ie(t,e):null,l=s?pt(s):"[]",o=k(n.modules),u=d(e);return`/**
|
|
21
21
|
* Service Worker - Generated by stx with Workbox
|
|
22
22
|
* Cache Version: ${n.cacheVersion}
|
|
23
23
|
*
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function fe(){let{NODE_ENV:o}=process.env;return o==="production"}function D(){let{STX_DEBUG:o}=process.env;return!fe()||o==="true"}function
|
|
3
|
-
export{fe,D,
|
|
2
|
+
function fe(){let{NODE_ENV:o}=process.env;return o==="production"}function D(){let{STX_DEBUG:o}=process.env;return!fe()||o==="true"}function pn(){let{NODE_ENV:o}=process.env;return o==="test"}
|
|
3
|
+
export{fe,D,pn};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Co,$o,Eo}from"./chunk-yaebdyfr.js";import{z,En,Wt,Dr,Or,Tn,qt,Kt,Mr,_n}from"./chunk-fg5ve6ey.js";function W(r,d=!0,u){if(!d||!r||typeof window>"u")return;let o=window;if(!o.__STX_DATA__){let y=document.querySelector("script[data-stx-server-data]");try{let f=JSON.parse(y?.textContent||"{}");o.__STX_DATA__=f&&typeof f==="object"&&!Array.isArray(f)?f:{}}catch{o.__STX_DATA__={}}}let i=o.__STX_DATA__;if(i&&Object.prototype.hasOwnProperty.call(i,r))try{return{data:u?u(i[r]):i[r]}}catch(y){return{data:null,error:y instanceof Error?y:Error(String(y))}}return}function X(r){if(typeof window>"u")return;let d=window;if(r===void 0)d.__STX_DATA__={};else{if(!d.__STX_DATA__)try{let u=JSON.parse(document.querySelector("script[data-stx-server-data]")?.textContent||"{}");d.__STX_DATA__=u&&typeof u==="object"&&!Array.isArray(u)?u:{}}catch{d.__STX_DATA__={}}if(d.__STX_DATA__)delete d.__STX_DATA__[r]}}function Q(r){let d=null;try{d=typeof indexedDB<"u"?indexedDB:null}catch{d=null}if(!d)return null;let u=d,o=r||"stx-kept",i=null,y=()=>{if(!i)i=new Promise((h,l)=>{let a=u.open(o,1);a.onupgradeneeded=()=>{a.result.createObjectStore("kv")},a.onsuccess=()=>h(a.result),a.onerror=()=>l(a.error),a.onblocked=()=>l(Error("blocked"))}),i.catch(()=>{i=null});return i},f=(h,l)=>y().then((a)=>new Promise((v,g)=>{let t=a.transaction("kv",h),s=l(t.objectStore("kv"));t.oncomplete=()=>v(s?s.result:void 0),t.onerror=()=>g(t.error),t.onabort=()=>g(t.error)}));return{get:(h)=>f("readonly",(l)=>l.get(h)),set:(h,l)=>f("readwrite",(a)=>{a.put(l,h)}),remove:(h)=>f("readwrite",(l)=>{l.delete(h)}),removePrefix:(h)=>f("readwrite",(l)=>{l.delete(IDBKeyRange.bound(h,`${h}\uFFFF`))})}}function G(r,d){let u=r||{},o=null;if(u.storage!==void 0)o=u.storage;else try{o=typeof localStorage<"u"?localStorage:null}catch{o=null}let i=null,y=u.backend!==void 0;if(y)i=u.backend||null;let f=()=>{if(y)return i;y=!0;try{i=d?d():null}catch{i=null}if(i){let e=i;e.get("__stx_probe__").catch(()=>{if(i===e)i=null})}return i},h=u.limit||32768,l=u.defer||((e)=>{let n=typeof requestIdleCallback==="function"?requestIdleCallback:null;if(n)n(e,{timeout:200});else setTimeout(e,16)}),a=new Map,v=new Set,g=new Map,t=!1,s=Promise.resolve(),m=(e)=>{try{return JSON.parse(e)}catch{return e}},p=(e,n)=>{if(!o)return!1;try{return o.setItem(e,n),!0}catch{return!1}},T=(e)=>{try{if(o)o.removeItem(e)}catch{}},S=()=>{if(t=!1,!g.size)return s;let e=Array.from(g.entries());return g.clear(),s=s.then(()=>Promise.all(e.map(([n,c])=>{if(!i){v.delete(n);try{p(n,JSON.stringify(c===void 0?null:c))}catch{}return}let _;try{return _={v:c},i.set(n,_).catch(()=>{let w;try{w=JSON.stringify(c)}catch{return}return i?i.set(n,{j:w}).catch(()=>{p(n,w)}):void 0})}catch{return}}))).then(()=>{}),s},R=(e,n)=>{if(g.set(e,n),v.add(e),t)return;t=!0,l(()=>{S()})},O=(e)=>{if(!e||typeof e!=="object")return;let n=e;if("v"in n)return{value:n.v};if(typeof n.j==="string")return{value:m(n.j)};return},E={peek(e){if(a.has(e))return{value:a.get(e)};let n=null;try{n=o?o.getItem(e):null}catch{n=null}if(n===null||n===void 0)return;let c=m(n);return a.set(e,c),{value:c}},load(e){let n=E.peek(e),c=n?null:f();if(n||!c)return Promise.resolve(n);return c.get(e).then((_)=>{if(a.has(e))return{value:a.get(e)};let w=O(_);if(w)a.set(e,w.value),v.add(e);return w},()=>{return})},set(e,n){if(a.set(e,n),i&&v.has(e)){R(e,n);return}let c;try{c=JSON.stringify(n===void 0?null:n)}catch{return}if(c.length<=h&&p(e,c))return;if(!f()){if(c.length>h)p(e,c);return}T(e),R(e,n)},forget(e){for(let c of Array.from(a.keys()))if(c.indexOf(e)===0)a.delete(c);for(let c of Array.from(g.keys()))if(c.indexOf(e)===0)g.delete(c);for(let c of Array.from(v))if(c.indexOf(e)===0)v.delete(c);try{if(o)for(let c=o.length-1;c>=0;c--){let _=o.key(c);if(_&&_.indexOf(e)===0)o.removeItem(_)}}catch{}let n=f();if(!n)return s;return s=s.then(()=>n.removePrefix(e)).catch(()=>{}),s},flush(){return S()}};try{if(typeof document<"u"&&document.addEventListener)document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")S()});if(typeof addEventListener==="function")addEventListener("pagehide",()=>{S()})}catch{}return E}function J(r,d){if(!r)return!1;if(r===d.key)return!0;if(!d.url)return!1;if(r===d.url)return!0;try{let u=typeof location<"u"&&location.origin&&location.origin!=="null"?location.origin:"http://localhost",o=new URL(r,u),i=new URL(d.url,u);if(o.origin!==i.origin||o.pathname!==i.pathname)return!1;return!o.search||o.search===i.search}catch{return!1}}function Y(r){let d=r.prefix||"stx:kept:",u=r.matches||((t,s)=>t===s.key||t===s.url),o=new Set,i=new Map,y,f=(t)=>t===void 0?y:t,h=(t,s)=>{let m=f(s);if(m===!1||m===null||m==="")return null;return`${d}${m===void 0?"":`${m}:`}query:${t}`},l=(t)=>{let s=t&&t.value;if(!s||typeof s!=="object"||!("d"in s))return;return{data:s.d,at:Number(s.at)||0}},a=()=>{let t=globalThis;return t.__stx_outboxes instanceof Map?t.__stx_outboxes:null},v={setScope(t){y=t},scope:()=>y,keyFor:h,seed(t,s){let m=h(t,s);return m?l(r.kept.peek(m)):void 0},restore(t,s){let m=h(t,s);return m?r.kept.load(m).then(l):Promise.resolve(void 0)},persist(t,s,m){let p=h(t,m);if(p)r.kept.set(p,{d:s,at:Date.now()})},overlay(t,s,m){let p=a();if(!p||!p.size)return s;let T=s;return p.forEach((S)=>{try{T=S.overlay(t,T,m)}catch{}}),T},watch(t){return o.add(t),()=>{o.delete(t)}},cachedQuery(t,s){let m=i.get(t);if(m){if(s&&m.__options)m.__options(s);return m}let p=s||{},T=p.initial===void 0?null:p.initial,S=()=>typeof p.scope==="function"?p.scope():p.scope,R=()=>(typeof p.url==="function"?p.url():p.url)||null,O=()=>({key:t,url:R()}),E=S(),e=T,n=0,c=null,_=v.seed(t,E);if(_)e=_.data;let w=r.state(v.overlay(O(),e)),H=r.state(!1),V=r.state(!1),q=r.state(null),I=r.state(_?_.at:0),N=0,M=()=>{w.set(v.overlay(O(),e))},K=(b)=>{let x=N;v.restore(t,b).then((C)=>{if(!C||x!==N||n)return;e=C.data,I.set(C.at),M()})};if(!_)K(E);let ee=()=>{let b=S();if(b===E)return;E=b,N++,c=null,n=0;let x=v.seed(t,E);if(e=x?x.data:T,I.set(x?x.at:0),M(),!x)K(E)},te=(b)=>{let x=R(),C=p.timeoutMs||15000,A=typeof AbortController<"u"?new AbortController:null,k=null,ne=new Promise((D,L)=>{k=setTimeout(()=>{if(A)A.abort();L(Error("The request took too long."))},C)}),U;if(p.load)U=p.load({force:b,url:x,signal:A?A.signal:void 0});else if(x){let D=p.fetch||((P,F)=>fetch(P,F)),L={method:"GET",headers:{Accept:"application/json"}};if(b)L.cache="no-cache";if(A)L.signal=A.signal;U=D(x,L).then((P)=>{if(!P.ok)return P.json().catch(()=>null).then((F)=>{throw Error(F&&(F.error||F.message)||`Request failed (${P.status})`)});return P.json()})}else return Promise.resolve(w());return Promise.race([U,ne]).then((D)=>{if(k)clearTimeout(k);return p.transform?p.transform(D):D},(D)=>{if(k)clearTimeout(k);throw D})},B=(b)=>{if(c)return c;let x=N;if(V.set(!0),n===0&&!I())H.set(!0);let C=()=>{if(x!==N)return;c=null,V.set(!1),H.set(!1)},A=te(b).then((k)=>{if(x!==N)return w();return e=k,n=Date.now(),I.set(n),q.set(null),v.persist(t,k,E),M(),C(),w()},(k)=>{if(x===N)q.set(k&&k.message?k.message:"Could not load.");return C(),w()});return c=A,A},j={data:w,loading:H,isFetching:V,error:q,updatedAt:I,get key(){return t},load(b){if(ee(),!b&&n&&Date.now()-n<(p.staleTime||0))return Promise.resolve(w());return B(!!b)},refresh(){return j.load(!0)},set(b){e=typeof b==="function"?b(e):b,v.persist(t,e,E),M()},invalidate(){n=0},__options(b){p={...p,...b}}};if(o.add({target:O,updated:()=>{if(n||I())B(!1)},outbox:(b)=>{if(b)e=v.overlay(O(),e,b.id),n=0,B(!0);M()}}),i.set(t,j),p.immediate)j.load();return j}},g=typeof window<"u"?window:typeof addEventListener==="function"?globalThis:null;if(r.listen!==!1&&g&&typeof g.addEventListener==="function")g.addEventListener("stx:updated",(t)=>{let s=t.detail||{};if(s.kind!=="api"||typeof s.url!=="string")return;o.forEach((m)=>{if(u(s.url,m.target()))m.updated()})}),g.addEventListener("stx:outbox",(t)=>{let s=t.detail||{},m=s.sent&&typeof s.sent.id==="string"?s.sent:null;o.forEach((p)=>{if(m){let T=Array.isArray(m.affects)?m.affects:[],S=p.target();if(!T.some((R)=>u(R,S)))return}p.outbox(m)})});return v}function Z(r,d,u,o,i){let y=!0,f=new Set,h=(a)=>o.get?o.get(a):a,l=()=>h(r());return Object.defineProperty(l,"_isSignal",{value:!0}),Object.defineProperty(l,"modifiers",{get:d}),l.set=(a)=>{if(!y)return;let v=d(),g=o.set?o.set(a,v):a;if(v.trim&&typeof g==="string")g=g.trim();if(v.number&&typeof g==="string"&&g!==""){let t=Number(g);if(!Number.isNaN(t))g=t}if(Object.is(r(),g))return;r.set(g),u(g)},l.update=(a)=>l.set(a(l())),l.input=(a)=>{if(!d().lazy)l.set(a)},l.change=(a)=>{if(d().lazy)l.set(a)},l.subscribe=(a)=>{if(!y)return()=>{};let v=r.subscribe((g,t)=>a(h(g),h(t)));return f.add(v),()=>{v(),f.delete(v)}},Object.defineProperty(l,"value",{get:l,set:l.set}),i(()=>{y=!1,f.forEach((a)=>a()),f.clear()}),l}function Pe(){let r=re(Ut());try{let u=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(r);return u=u.replace(/\}(var |let |const |function )/g,"};$1"),u}catch{return r}}function re(r){let d=[],u=0,o="console.log(";while(u<r.length){let i=r.indexOf(o,u);if(i===-1){d.push(r.slice(u));break}d.push(r.slice(u,i));let y=1,f=i+o.length;while(f<r.length&&y>0){let h=r[f];if(h==='"'||h==="'"||h==="`"){let l=h;f++;while(f<r.length&&r[f]!==l){if(r[f]==="\\")f++;f++}f++;continue}if(h==="(")y++;else if(h===")")y--;f++}d.push("0"),u=f}return d.join("")}function Ut(){return`
|
|
3
3
|
// STX Signals Runtime (Development Build)
|
|
4
4
|
console.log('[stx] signals runtime loading');
|
|
5
5
|
// Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs
|
|
@@ -27,8 +27,19 @@ console.log('[stx] entering IIFE');
|
|
|
27
27
|
// exactly as it was: same calls, one property lookup earlier.
|
|
28
28
|
var stxHost = window.__stx_host || {
|
|
29
29
|
setText: function(node, value) { node.textContent = value; },
|
|
30
|
-
setAttribute: function(node, name, value) {
|
|
30
|
+
setAttribute: function(node, name, value) {
|
|
31
|
+
var next = value;
|
|
32
|
+
if (typeof value === 'object' && value !== null) {
|
|
33
|
+
try { next = JSON.stringify(value); }
|
|
34
|
+
catch (e) { next = String(value); }
|
|
35
|
+
}
|
|
36
|
+
node.setAttribute(name, next);
|
|
37
|
+
},
|
|
31
38
|
removeAttribute: function(node, name) { node.removeAttribute(name); },
|
|
39
|
+
setStyle: function(node, value) {
|
|
40
|
+
if (typeof value === 'object' && value !== null) Object.assign(node.style, value);
|
|
41
|
+
else if (typeof value === 'string') node.style.cssText = value;
|
|
42
|
+
},
|
|
32
43
|
|
|
33
44
|
// Structural operations, for the bindings that build rows rather than
|
|
34
45
|
// update one node (#1984).
|
|
@@ -1354,8 +1365,8 @@ finally {
|
|
|
1354
1365
|
// Declarative Data Fetching (Feature #6 - useFetch)
|
|
1355
1366
|
// ==========================================================================
|
|
1356
1367
|
|
|
1357
|
-
var readHydratedData = ${
|
|
1358
|
-
var clearServerData = ${
|
|
1368
|
+
var readHydratedData = ${W.toString()};
|
|
1369
|
+
var clearServerData = ${X.toString()};
|
|
1359
1370
|
|
|
1360
1371
|
function useFetch(urlOrFn, options = {}) {
|
|
1361
1372
|
const hydrated = readHydratedData(options.key, options.hydrate !== false, options.transform);
|
|
@@ -2788,21 +2799,72 @@ catch (e) {
|
|
|
2788
2799
|
* Absent a manifest nothing changes: the walk is still the default, and a
|
|
2789
2800
|
* page that ships no list hydrates exactly as it did.
|
|
2790
2801
|
*/
|
|
2791
|
-
function processFromManifest(root, scope, manifest) {
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2802
|
+
function processFromManifest(root, scope, manifest, resolvedNodes) {
|
|
2803
|
+
// Arrays have an entries() method too. Prefer the array itself before
|
|
2804
|
+
// accepting the compiled document shape { entries: [...] }.
|
|
2805
|
+
var entries = Array.isArray(manifest)
|
|
2806
|
+
? manifest
|
|
2807
|
+
: (manifest && Array.isArray(manifest.entries) ? manifest.entries : null);
|
|
2808
|
+
if (!entries || !entries.length || (!root && !resolvedNodes)) return false;
|
|
2809
|
+
for (var i = 0; i < entries.length; i++) {
|
|
2810
|
+
var entry = entries[i];
|
|
2795
2811
|
var id = entry && entry.id;
|
|
2796
2812
|
if (id === undefined || id === null) continue;
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2813
|
+
// Native compilation already has stable handles for every manifest id.
|
|
2814
|
+
// Accept those handles directly so a non-DOM host never needs selectors
|
|
2815
|
+
// or an attribute walk. The browser keeps its existing lookup fallback.
|
|
2816
|
+
var node = resolvedNodes
|
|
2817
|
+
? (typeof resolvedNodes.get === 'function' ? resolvedNodes.get(id) : resolvedNodes[id])
|
|
2818
|
+
: null;
|
|
2819
|
+
if (!node && root) {
|
|
2820
|
+
node = root.getAttribute && root.getAttribute('data-stx-b') === String(id)
|
|
2821
|
+
? root
|
|
2822
|
+
: (root.querySelector ? root.querySelector('[data-stx-b="' + id + '"]') : null);
|
|
2823
|
+
}
|
|
2800
2824
|
if (!node) continue;
|
|
2825
|
+
// A structural binding can detach its source before a later manifest
|
|
2826
|
+
// entry reaches one of that source's children. Native handles expose
|
|
2827
|
+
// this state directly; do not register effects or handlers for a view
|
|
2828
|
+
// that no longer exists in the host tree. Browser hydration keeps its
|
|
2829
|
+
// existing behaviour because it does not pass resolvedNodes here.
|
|
2830
|
+
if (resolvedNodes && node.__stxId !== undefined && node.isConnected === false) continue;
|
|
2801
2831
|
processElement(node, scope, true);
|
|
2802
2832
|
}
|
|
2803
2833
|
return true;
|
|
2804
2834
|
}
|
|
2805
2835
|
|
|
2836
|
+
// Bind a precompiled host tree without waiting for DOMContentLoaded. Native
|
|
2837
|
+
// passes its manifest id to node-handle table; browser hydration continues
|
|
2838
|
+
// through the document-ready path below. The same state, effect, expression,
|
|
2839
|
+
// event and host implementations are used by both.
|
|
2840
|
+
function hydrateHost(root, setup, manifest, resolvedNodes) {
|
|
2841
|
+
var mountStart = mountCallbacks.length;
|
|
2842
|
+
var destroyStart = destroyCallbacks.length;
|
|
2843
|
+
var outerSink = activeDestroySink;
|
|
2844
|
+
activeDestroySink = null;
|
|
2845
|
+
var values;
|
|
2846
|
+
try { values = typeof setup === 'function' ? setup() : setup; }
|
|
2847
|
+
finally { activeDestroySink = outerSink; }
|
|
2848
|
+
var localMountHooks = mountCallbacks.splice(mountStart);
|
|
2849
|
+
var localDestroyHooks = destroyCallbacks.splice(destroyStart);
|
|
2850
|
+
var scope = Object.assign({ $refs: {} }, values || {});
|
|
2851
|
+
var disposeEffects = trackEffects(function() {
|
|
2852
|
+
processFromManifest(root, scope, manifest, resolvedNodes);
|
|
2853
|
+
});
|
|
2854
|
+
runMountCallbacks(localMountHooks, localDestroyHooks);
|
|
2855
|
+
var mounted = true;
|
|
2856
|
+
return function disposeHost() {
|
|
2857
|
+
if (!mounted) return;
|
|
2858
|
+
mounted = false;
|
|
2859
|
+
disposeEffects();
|
|
2860
|
+
var hooks = localDestroyHooks.splice(0, localDestroyHooks.length);
|
|
2861
|
+
for (var i = 0; i < hooks.length; i++) {
|
|
2862
|
+
try { hooks[i](); }
|
|
2863
|
+
catch (e) { console.warn('[stx] native destroy error:', e); }
|
|
2864
|
+
}
|
|
2865
|
+
};
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2806
2868
|
// skipChildren: this element's bindings only, because something else already
|
|
2807
2869
|
// knows where the rest are. The manifest path passes it for every entry, so
|
|
2808
2870
|
// the tree is never walked; see processFromManifest.
|
|
@@ -3065,7 +3127,7 @@ catch (e2) {
|
|
|
3065
3127
|
};
|
|
3066
3128
|
|
|
3067
3129
|
// Known directive names to exclude from generic :attr binding
|
|
3068
|
-
var DIRECTIVE_NAMES = ${
|
|
3130
|
+
var DIRECTIVE_NAMES = ${$o()};
|
|
3069
3131
|
|
|
3070
3132
|
// A bound value cannot introduce a URL scheme the page did not ask for.
|
|
3071
3133
|
// This is the client half of url-safety.ts: the server refuses a scheme
|
|
@@ -3100,7 +3162,7 @@ catch (e2) {
|
|
|
3100
3162
|
// a dead duplicate attribute and the real viewBox never updates.
|
|
3101
3163
|
var SVG_ATTR_CASE = {attributename:'attributeName', attributetype:'attributeType', basefrequency:'baseFrequency', baseprofile:'baseProfile', calcmode:'calcMode', clippathunits:'clipPathUnits', diffuseconstant:'diffuseConstant', edgemode:'edgeMode', filterunits:'filterUnits', glyphref:'glyphRef', gradienttransform:'gradientTransform', gradientunits:'gradientUnits', kernelmatrix:'kernelMatrix', kernelunitlength:'kernelUnitLength', keypoints:'keyPoints', keysplines:'keySplines', keytimes:'keyTimes', lengthadjust:'lengthAdjust', limitingconeangle:'limitingConeAngle', markerheight:'markerHeight', markerunits:'markerUnits', markerwidth:'markerWidth', maskcontentunits:'maskContentUnits', maskunits:'maskUnits', numoctaves:'numOctaves', pathlength:'pathLength', patterncontentunits:'patternContentUnits', patterntransform:'patternTransform', patternunits:'patternUnits', pointsatx:'pointsAtX', pointsaty:'pointsAtY', pointsatz:'pointsAtZ', preservealpha:'preserveAlpha', preserveaspectratio:'preserveAspectRatio', primitiveunits:'primitiveUnits', refx:'refX', refy:'refY', repeatcount:'repeatCount', repeatdur:'repeatDur', requiredextensions:'requiredExtensions', requiredfeatures:'requiredFeatures', specularconstant:'specularConstant', specularexponent:'specularExponent', spreadmethod:'spreadMethod', startoffset:'startOffset', stddeviation:'stdDeviation', stitchtiles:'stitchTiles', surfacescale:'surfaceScale', systemlanguage:'systemLanguage', tablevalues:'tableValues', targetx:'targetX', targety:'targetY', textlength:'textLength', viewbox:'viewBox', viewtarget:'viewTarget', xchannelselector:'xChannelSelector', ychannelselector:'yChannelSelector', zoomandpan:'zoomAndPan'};
|
|
3102
3164
|
var SVG_NS = 'http://www.w3.org/2000/svg';
|
|
3103
|
-
var EVENT_RE = ${
|
|
3165
|
+
var EVENT_RE = ${Eo()};
|
|
3104
3166
|
var KEY_MAP = {enter:'Enter', tab:'Tab', escape:'Escape', space:' ', up:'ArrowUp', down:'ArrowDown', left:'ArrowLeft', right:'ArrowRight', 'delete':'Delete', backspace:'Backspace'};
|
|
3105
3167
|
|
|
3106
3168
|
// Handle attributes
|
|
@@ -3136,7 +3198,7 @@ catch (e2) {
|
|
|
3136
3198
|
// :attr still works for backward compat but is reserved for structural directives.
|
|
3137
3199
|
// x-text, x-html, x-model, x-show, x-if, x-for, x-cloak, x-ref, x-data are
|
|
3138
3200
|
// handled by their own code paths below \u2014 exclude them here.
|
|
3139
|
-
var X_HANDLED = ${
|
|
3201
|
+
var X_HANDLED = ${Co()};
|
|
3140
3202
|
if (name.startsWith('@bind:') || name.startsWith('x-bind:')
|
|
3141
3203
|
|| (name.startsWith(':') && !name.startsWith('::') && !DIRECTIVE_NAMES[name.slice(1).split('.')[0]] && !EVENT_RE.test(name.slice(1)))
|
|
3142
3204
|
|| (name.startsWith('x-') && !X_HANDLED[name.split('.')[0]] && !X_HANDLED[name])) {
|
|
@@ -3225,6 +3287,9 @@ else {
|
|
|
3225
3287
|
catch (e) { attrValue = String(v); }
|
|
3226
3288
|
}
|
|
3227
3289
|
var attrValueSafe = safeUrlAttr(attrName, attrValue);
|
|
3290
|
+
// Keep structured values structured for non-DOM hosts. The DOM
|
|
3291
|
+
// host serializes them at its boundary, preserving web output.
|
|
3292
|
+
var hostValue = (typeof v === 'object' && v !== null) ? v : attrValueSafe;
|
|
3228
3293
|
// Writing the value an attribute already has is not nothing: a
|
|
3229
3294
|
// frame given its own src again loads again (an entry in the
|
|
3230
3295
|
// page's history each time) and a video restarts. A player whose
|
|
@@ -3241,11 +3306,11 @@ else {
|
|
|
3241
3306
|
&& el.hasAttribute('src') && el.getAttribute('src') !== String(attrValueSafe)) {
|
|
3242
3307
|
var nextSibling = el.nextSibling;
|
|
3243
3308
|
parentNode.removeChild(el);
|
|
3244
|
-
stxHost.setAttribute(el, attrName,
|
|
3309
|
+
stxHost.setAttribute(el, attrName, hostValue);
|
|
3245
3310
|
parentNode.insertBefore(el, nextSibling);
|
|
3246
3311
|
}
|
|
3247
3312
|
else {
|
|
3248
|
-
stxHost.setAttribute(el, attrName,
|
|
3313
|
+
stxHost.setAttribute(el, attrName, hostValue);
|
|
3249
3314
|
}
|
|
3250
3315
|
}
|
|
3251
3316
|
});
|
|
@@ -3842,12 +3907,7 @@ catch (e2) {
|
|
|
3842
3907
|
effect(() => {
|
|
3843
3908
|
if (isVisible && !isVisible()) return;
|
|
3844
3909
|
const value = evalExpr();
|
|
3845
|
-
|
|
3846
|
-
Object.assign(el.style, value);
|
|
3847
|
-
}
|
|
3848
|
-
else if (typeof value === 'string') {
|
|
3849
|
-
el.style.cssText = value;
|
|
3850
|
-
}
|
|
3910
|
+
stxHost.setStyle(el, value);
|
|
3851
3911
|
});
|
|
3852
3912
|
}
|
|
3853
3913
|
|
|
@@ -6263,8 +6323,8 @@ catch (e) {} }
|
|
|
6263
6323
|
// off the critical path and read back asynchronously. Values kept before it
|
|
6264
6324
|
// are read where they are.
|
|
6265
6325
|
var STX_KEPT_PREFIX = 'stx:kept:';
|
|
6266
|
-
var __stxKept = (${
|
|
6267
|
-
var __stxQueries = (${
|
|
6326
|
+
var __stxKept = (${G.toString()})(undefined, ${Q.toString()});
|
|
6327
|
+
var __stxQueries = (${Y.toString()})({ state: state, kept: __stxKept, prefix: STX_KEPT_PREFIX, matches: ${J.toString()} });
|
|
6268
6328
|
function stxKeptPrefix(scope) {
|
|
6269
6329
|
return STX_KEPT_PREFIX + (scope === undefined || scope === null || scope === '' ? '' : String(scope) + ':');
|
|
6270
6330
|
}
|
|
@@ -6389,7 +6449,7 @@ catch (e) {} }
|
|
|
6389
6449
|
return normalizedPrefix + '-' + __stxGeneratedIdCounter;
|
|
6390
6450
|
}
|
|
6391
6451
|
|
|
6392
|
-
var createModelSignal = ${
|
|
6452
|
+
var createModelSignal = ${Z.toString()};
|
|
6393
6453
|
function useModel(name, options) {
|
|
6394
6454
|
if (typeof name !== 'string') { options = name || {}; name = 'modelValue'; }
|
|
6395
6455
|
options = options || {};
|
|
@@ -7315,6 +7375,7 @@ catch (e) {} }
|
|
|
7315
7375
|
// calling a detached one.
|
|
7316
7376
|
window.stx = Object.assign(window.stx || {}, {
|
|
7317
7377
|
hydrate: hydrateSubtree,
|
|
7378
|
+
hydrateHost,
|
|
7318
7379
|
state,
|
|
7319
7380
|
derived,
|
|
7320
7381
|
effect,
|
|
@@ -9265,5 +9326,5 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
|
|
|
9265
9326
|
}
|
|
9266
9327
|
}
|
|
9267
9328
|
})();
|
|
9268
|
-
`}var
|
|
9269
|
-
export{
|
|
9329
|
+
`}var Wl={state:z,derived:En,effect:Wt,batch:Dr,onMount:Or,onDestroy:Tn,isSignal:qt,isDerived:Kt,untrack:Mr,peek:_n,generateSignalsRuntime:Pe,generateSignalsRuntimeDev:Ut};
|
|
9330
|
+
export{Pe,Ut,Wl};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{rr,As,To}from"./chunk-yaebdyfr.js";import"./chunk-axydabse.js";import{Ln,n}from"./chunk-qm1tt8g1.js";import"./chunk-89b2r1q0.js";import"./chunk-ptjqacjd.js";import"./chunk-h3c7z73m.js";import"./chunk-48kgnqpk.js";import"./chunk-3ry9ca1s.js";import"./chunk-12pvnn1e.js";import"./chunk-jbrdebzs.js";import"./chunk-k8sqs7j2.js";import"./chunk-b7973zvk.js";import{Pe}from"./chunk-zbr333kf.js";import"./chunk-2x9jd5w0.js";import{existsSync as F,mkdirSync as rt,readFileSync as it}from"fs";import T from"path";import{mkdirSync as et}from"fs";import v from"path";import{existsSync as qe}from"fs";import C from"path";var le="data-stx-b",j=new Set(As),de=new Set(rr);function pe(t){if(t==="ref"||t==="data-stx-ref")return"ref";if(t.startsWith("::"))return null;if(t.startsWith("@bind:")||t.startsWith("x-bind:"))return"attr";if(t.startsWith("@")||t.startsWith(":")){let e=t.slice(1).split(".")[0];if(j.has(e))return e==="if"?"if":e;if(e==="for"||e==="else"||e==="else-if"||e==="elseif")return"for";if(To(e))return"event";if(t.startsWith("@"))return"event";return"attr"}if(t.startsWith("x-")){let e=t.split(".")[0];if(!de.has(e))return"attr";let r=e.slice(2);if(r==="cloak"||r==="data"||r==="bind")return null;if(r==="tooltip"||r==="tooltip-position")return null;return j.has(r)?r==="if"?"if":r:"attr"}return null}function ge(t){let e=[];for(let[r,i]of t){let o=pe(r);if(o)e.push({name:r,value:i,kind:o})}return e}var me=/<([a-z][\w-]*)((?:\s+[^\s"'=<>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)\s*\/?>/gi,D=/([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;function M(t){let e=[],r=0;return{html:t.replace(me,(o,s,c)=>{if(!c||!/[:@]|x-/.test(c))return o;let f=[];D.lastIndex=0;for(let l=D.exec(c);l;l=D.exec(c))f.push([l[1],l[2]??l[3]??l[4]??""]);let d=ge(f);if(!d.length)return o;let p={id:r++,bindings:d};if(d.some((l)=>l.kind==="for"))p.template=!0;e.push(p);let a=o.endsWith("/>");return`${o.slice(0,a?-2:-1).trimEnd()} ${le}="${p.id}"${a?"/>":">"}`}),manifest:{entries:e}}}var he=["accessibilityHint","accessibilityLabel","accessibilityRole","accessibilityState","accessibilityValue","activeOpacity","alwaysBounceHorizontal","alwaysBounceVertical","animationType","autoCapitalize","autoCorrect","autoFocus","blurRadius","contentContainerStyle","defaultSource","defaultValue","ellipsizeMode","fadeDuration","hidesWhenStopped","hitSlop","imageStyle","initialNumToRender","iosBackgroundColor","keyboardDismissMode","keyboardShouldPersistTaps","keyboardType","keyboardVerticalOffset","keyExtractor","maxLength","maximumTrackTintColor","maximumValue","maxToRenderPerBatch","minimumTrackTintColor","minimumValue","numberOfLines","numColumns","onEndReachedThreshold","pagingEnabled","placeholderTextColor","pointerEvents","presentationStyle","pressRetentionOffset","progressBackgroundColor","progressViewOffset","refreshControl","resizeMode","returnKeyType","scrollEnabled","scrollTarget","secureTextEntry","selectedValue","selectionColor","showsHorizontalScrollIndicator","showsVerticalScrollIndicator","statusBarTranslucent","stickyHeaderIndices","testID","thumbColor","thumbTintColor","titleColor","trackColor","underlayColor","windowSize"],be=new Map(he.map((t)=>[H(t),t]));function H(t){return t.replace(/[-_]/g,"").toLowerCase()}function L(t){return be.get(H(t))??t}var Se={view:"View",text:"Text",button:"Button",image:"Image",img:"Image",input:"TextInput",textarea:"TextInput",scroll:"ScrollView",scrollview:"ScrollView",list:"FlatList",flatlist:"FlatList",modal:"Modal",switch:"Switch",slider:"Slider",picker:"Picker",select:"Picker",loading:"ActivityIndicator",spinner:"ActivityIndicator",div:"View",span:"Text",p:"Text",h1:"Text",h2:"Text",h3:"Text",h4:"Text",h5:"Text",h6:"Text",a:"TouchableOpacity",section:"View",article:"View",header:"SafeAreaView",footer:"View",main:"View",nav:"View",aside:"View",form:"View",label:"Text",fieldset:"View",legend:"Text",option:"Text",dialog:"Modal",figure:"View",figcaption:"Text",picture:"View",hr:"View",ul:"View",ol:"View",li:"View",dl:"View",dt:"Text",dd:"Text",table:"View",thead:"View",tbody:"View",tfoot:"View",tr:"View",th:"Text",td:"Text",caption:"Text",strong:"Text",b:"Text",em:"Text",i:"Text",u:"Text",s:"Text",small:"Text",mark:"Text",abbr:"Text",time:"Text",code:"Text",kbd:"Text",samp:"Text",pre:"Text",blockquote:"Text",cite:"Text",q:"Text",sub:"Text",sup:"Text"};function G(t){return Se[t.toLowerCase()]||t}var xe={transparent:"transparent",current:"currentColor",black:"#000000",white:"#ffffff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},J={px:1,0:0,0.5:2,1:4,1.5:6,2:8,2.5:10,3:12,3.5:14,4:16,5:20,6:24,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384},U={xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48,"6xl":60,"7xl":72,"8xl":96,"9xl":128},w={none:0,sm:2,DEFAULT:4,md:6,lg:8,xl:12,"2xl":16,"3xl":24,full:9999};function W(t){let e=t.lastIndexOf("/");if(e>0&&!t.endsWith("]")){let i=W(t.slice(0,e)),o=t.slice(e+1),s=/^\[(.+)\]$/.test(o)?Number.parseFloat(o.slice(1,-1))*(o.includes("%")?1:100):Number.parseFloat(o);if(!i||!Number.isFinite(s))return;return we(i,s/100)}if(t==="transparent")return"transparent";if(t==="current")return"currentColor";if(t==="black")return"#000000";if(t==="white")return"#ffffff";let r=t.split("-");if(r.length===2){let[i,o]=r,s=xe[i];if(s&&typeof s==="object")return s[o]}if(t.startsWith("[")&&t.endsWith("]")){let i=t.slice(1,-1);return/^(#|rgba?\(|hsla?\(|[a-z]+$)/i.test(i)?i:void 0}return}function we(t,e){if(t==="transparent")return t;let r=t.startsWith("#")?t.slice(1):"";if(r.length===3)r=r.split("").map((o)=>o+o).join("");if(r.length===8)r=r.slice(0,6);if(r.length!==6)return;let i=Math.round(Math.min(1,Math.max(0,e))*255);return`#${r}${i.toString(16).padStart(2,"0")}`}function O(t,e=16){if(!t.startsWith("[")||!t.endsWith("]"))return;let r=t.slice(1,-1),i=Number.parseFloat(r);if(!Number.isFinite(i))return;if(r.endsWith("rem"))return i*16;if(r.endsWith("em"))return i*e;return i}function g(t){if(t.startsWith("[")&&t.endsWith("]")){let e=t.slice(1,-1),r=e.endsWith("rem")?Number.parseFloat(e)*16:Number.parseFloat(e);return Number.isFinite(r)?r:void 0}return J[t]}var Te={flex:(t,e)=>(e.display="flex",!0),hidden:(t,e)=>(e.display="none",!0),grid:(t,e)=>(e.display="grid",!0),"flex-row":(t,e)=>(e.flexDirection="row",!0),"flex-col":(t,e)=>(e.flexDirection="column",!0),"flex-row-reverse":(t,e)=>(e.flexDirection="row-reverse",!0),"flex-col-reverse":(t,e)=>(e.flexDirection="column-reverse",!0),"flex-wrap":(t,e)=>(e.flexWrap="wrap",!0),"flex-nowrap":(t,e)=>(e.flexWrap="nowrap",!0),"flex-wrap-reverse":(t,e)=>(e.flexWrap="wrap-reverse",!0),"flex-1":(t,e)=>(e.flex=1,e.flexGrow=1,e.flexShrink=1,e.flexBasis=0,!0),"flex-auto":(t,e)=>(e.flexGrow=1,e.flexShrink=1,!0),"flex-initial":(t,e)=>(e.flexGrow=0,e.flexShrink=1,!0),"flex-none":(t,e)=>(e.flexGrow=0,e.flexShrink=0,!0),grow:(t,e)=>(e.flexGrow=1,!0),"grow-0":(t,e)=>(e.flexGrow=0,!0),shrink:(t,e)=>(e.flexShrink=1,!0),"shrink-0":(t,e)=>(e.flexShrink=0,!0),"justify-start":(t,e)=>(e.justifyContent="flex-start",!0),"justify-center":(t,e)=>(e.justifyContent="center",!0),"justify-end":(t,e)=>(e.justifyContent="flex-end",!0),"justify-between":(t,e)=>(e.justifyContent="space-between",!0),"justify-around":(t,e)=>(e.justifyContent="space-around",!0),"justify-evenly":(t,e)=>(e.justifyContent="space-evenly",!0),"items-start":(t,e)=>(e.alignItems="flex-start",!0),"items-center":(t,e)=>(e.alignItems="center",!0),"items-end":(t,e)=>(e.alignItems="flex-end",!0),"items-stretch":(t,e)=>(e.alignItems="stretch",!0),"items-baseline":(t,e)=>(e.alignItems="baseline",!0),"self-auto":(t,e)=>(e.alignSelf="auto",!0),"self-start":(t,e)=>(e.alignSelf="flex-start",!0),"self-center":(t,e)=>(e.alignSelf="center",!0),"self-end":(t,e)=>(e.alignSelf="flex-end",!0),"self-stretch":(t,e)=>(e.alignSelf="stretch",!0),"self-baseline":(t,e)=>(e.alignSelf="baseline",!0),"min-w-0":(t,e)=>(e.minWidth=0,!0),"aspect-square":(t,e)=>(e.aspectRatio=1,!0),"inset-0":(t,e)=>(e.top=0,e.right=0,e.bottom=0,e.left=0,!0),"tracking-tighter":(t,e)=>(e.letterSpacing=-0.8,!0),"tracking-tight":(t,e)=>(e.letterSpacing=-0.4,!0),"tracking-normal":(t,e)=>(e.letterSpacing=0,!0),"tracking-wide":(t,e)=>(e.letterSpacing=0.4,!0),"tracking-wider":(t,e)=>(e.letterSpacing=0.8,!0),"tracking-widest":(t,e)=>(e.letterSpacing=1.6,!0),"tabular-nums":()=>!0,block:()=>!0,"inline-flex":(t,e)=>(e.display="flex",!0),truncate:()=>!0,relative:(t,e)=>(e.position="relative",!0),absolute:(t,e)=>(e.position="absolute",!0),"overflow-visible":(t,e)=>(e.overflow="visible",!0),"overflow-hidden":(t,e)=>(e.overflow="hidden",!0),"overflow-scroll":(t,e)=>(e.overflow="scroll",!0),"font-thin":(t,e)=>(e.fontWeight="100",!0),"font-extralight":(t,e)=>(e.fontWeight="200",!0),"font-light":(t,e)=>(e.fontWeight="300",!0),"font-normal":(t,e)=>(e.fontWeight="400",!0),"font-medium":(t,e)=>(e.fontWeight="500",!0),"font-semibold":(t,e)=>(e.fontWeight="600",!0),"font-bold":(t,e)=>(e.fontWeight="bold",!0),"font-extrabold":(t,e)=>(e.fontWeight="800",!0),"font-black":(t,e)=>(e.fontWeight="900",!0),italic:(t,e)=>(e.fontStyle="italic",!0),"not-italic":(t,e)=>(e.fontStyle="normal",!0),"text-left":(t,e)=>(e.textAlign="left",!0),"text-center":(t,e)=>(e.textAlign="center",!0),"text-right":(t,e)=>(e.textAlign="right",!0),"text-justify":(t,e)=>(e.textAlign="justify",!0),uppercase:(t,e)=>(e.textTransform="uppercase",!0),lowercase:(t,e)=>(e.textTransform="lowercase",!0),capitalize:(t,e)=>(e.textTransform="capitalize",!0),"normal-case":(t,e)=>(e.textTransform="none",!0),underline:(t,e)=>(e.textDecorationLine="underline",!0),"line-through":(t,e)=>(e.textDecorationLine="line-through",!0),"no-underline":(t,e)=>(e.textDecorationLine="none",!0)};function ye(t,e){if(!t.startsWith("bg-"))return!1;let r=t.slice(3),i=W(r);if(i)return e.backgroundColor=i,!0;return!1}function ve(t,e){if(!t.startsWith("text-"))return!1;let r=t.slice(5);if(U[r])return e.fontSize=U[r],!0;if(r.startsWith("[")&&r.endsWith("]")){let o=r.slice(1,-1);if(/^-?[\d.]+(?:px|r?em)?$/.test(o)){let s=o.endsWith("rem")||o.endsWith("em")?Number.parseFloat(o)*16:Number.parseFloat(o);if(Number.isFinite(s))return e.fontSize=s,!0}}let i=W(r);if(i)return e.color=i,!0;return!1}function Re(t,e){if(t.startsWith("p-")){let r=g(t.slice(2));if(r!==void 0)return e.padding=r,!0}if(t.startsWith("px-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingHorizontal=r,!0}if(t.startsWith("py-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingVertical=r,!0}if(t.startsWith("pt-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingTop=r,!0}if(t.startsWith("pr-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingRight=r,!0}if(t.startsWith("pb-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingBottom=r,!0}if(t.startsWith("pl-")){let r=g(t.slice(3));if(r!==void 0)return e.paddingLeft=r,!0}return!1}function _e(t,e){if(t.startsWith("m-")){let r=g(t.slice(2));if(r!==void 0)return e.margin=r,!0}if(t.startsWith("mx-")){let r=g(t.slice(3));if(r!==void 0)return e.marginHorizontal=r,!0}if(t.startsWith("my-")){let r=g(t.slice(3));if(r!==void 0)return e.marginVertical=r,!0}if(t.startsWith("mt-")){let r=g(t.slice(3));if(r!==void 0)return e.marginTop=r,!0}if(t.startsWith("mr-")){let r=g(t.slice(3));if(r!==void 0)return e.marginRight=r,!0}if(t.startsWith("mb-")){let r=g(t.slice(3));if(r!==void 0)return e.marginBottom=r,!0}if(t.startsWith("ml-")){let r=g(t.slice(3));if(r!==void 0)return e.marginLeft=r,!0}return!1}function ke(t,e){if(!t.startsWith("w-"))return!1;let r=t.slice(2);if(r==="full")return e.width="100%",!0;if(r==="screen")return e.width="100%",!0;if(r==="auto")return e.width="auto",!0;if(r.includes("/")){let[o,s]=r.split("/"),c=Number.parseInt(o)/Number.parseInt(s)*100;return e.width=`${c}%`,!0}let i=g(r);if(i!==void 0)return e.width=i,!0;return!1}function Ce(t,e){if(!t.startsWith("h-"))return!1;let r=t.slice(2);if(r==="full")return e.height="100%",!0;if(r==="screen")return e.height="100%",!0;if(r==="auto")return e.height="auto",!0;let i=g(r);if(i!==void 0)return e.height=i,!0;return!1}function We(t,e){if(!t.startsWith("rounded"))return!1;if(t==="rounded")return e.borderRadius=w.DEFAULT,!0;let r=t.slice(8);if(r==="")return!1;let i=/^(?:(t|b|l|r)-)?(\[[^\]]+\])$/.exec(r);if(i){let s=O(i[2]);if(s===void 0)return!1;let c={t:["borderTopLeftRadius","borderTopRightRadius"],b:["borderBottomLeftRadius","borderBottomRightRadius"],l:["borderTopLeftRadius","borderBottomLeftRadius"],r:["borderTopRightRadius","borderBottomRightRadius"]};for(let f of i[1]?c[i[1]]:["borderRadius"])e[f]=s;return!0}if(r.startsWith("t-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderTopLeftRadius=s,e.borderTopRightRadius=s,!0}if(r.startsWith("b-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderBottomLeftRadius=s,e.borderBottomRightRadius=s,!0}if(r.startsWith("l-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderTopLeftRadius=s,e.borderBottomLeftRadius=s,!0}if(r.startsWith("r-")){let s=w[r.slice(2)]??w.DEFAULT;return e.borderTopRightRadius=s,e.borderBottomRightRadius=s,!0}let o=w[r];if(o!==void 0)return e.borderRadius=o,!0;return!1}function Ne(t,e){if(!t.startsWith("border"))return!1;if(t==="border")return e.borderWidth=1,!0;let r=t.match(/^border-(\d+)$/);if(r)return e.borderWidth=Number.parseInt(r[1]),!0;let i=t.match(/^border-(t|r|b|l)-?(\d*)$/);if(i){let[,o,s]=i,c=s?Number.parseInt(s):1;switch(o){case"t":e.borderTopWidth=c;break;case"r":e.borderRightWidth=c;break;case"b":e.borderBottomWidth=c;break;case"l":e.borderLeftWidth=c;break}return!0}return!1}function Be(t,e){if(!t.startsWith("border-"))return!1;let r=t.slice(7),i=W(r);if(i)return e.borderColor=i,!0;return!1}function Ee(t,e){if(!t.startsWith("opacity-"))return!1;let r=Number.parseInt(t.slice(8));if(!Number.isNaN(r))return e.opacity=r/100,!0;return!1}function Xe(t,e){if(t.startsWith("tracking-[")){let r=O(t.slice(9),typeof e.fontSize==="number"?e.fontSize:16);if(r===void 0)return!1;return e.letterSpacing=r,!0}if(t.startsWith("leading-")){let r=t.slice(8),i=typeof e.fontSize==="number"?e.fontSize:16,o={none:1,tight:1.25,snug:1.375,normal:1.5,relaxed:1.625,loose:2},s=r.startsWith("[")?/^\[[\d.]+\]$/.test(r)?Number.parseFloat(r.slice(1,-1))*i:O(r,i):o[r]!==void 0?o[r]*i:J[r];if(s===void 0||!Number.isFinite(s))return!1;return e.lineHeight=s,!0}return!1}function Ie(t,e){let r=/^grid-cols-(\d+)$/.exec(t);if(!r)return!1;return e.gridColumns=Number(r[1]),!0}function De(t,e){if(!t.startsWith("size-"))return!1;let r=t.slice(5),i=r==="full"?"100%":g(r);if(i===void 0)return!1;return e.width=i,e.height=i,!0}function Le(t,e){let r=/^(-?)(top|right|bottom|left)-(.+)$/.exec(t);if(!r)return!1;let i=r[3]==="full"?"100%":g(r[3]);if(i===void 0)return!1;return e[r[2]]=typeof i==="number"&&r[1]?-i:i,!0}function Oe(t,e){let r=/^space-(x|y)-(.+)$/.exec(t);if(!r)return!1;let i=g(r[2]);if(i===void 0)return!1;return e.gap=i,!0}function Ve(t,e){if(t.startsWith("gap-")){let r=g(t.slice(4));if(r!==void 0)return e.gap=r,!0}if(t.startsWith("gap-x-")){let r=g(t.slice(6));if(r!==void 0)return e.columnGap=r,!0}if(t.startsWith("gap-y-")){let r=g(t.slice(6));if(r!==void 0)return e.rowGap=r,!0}return!1}function Y(t,e){let r={},i=t.split(/\s+/).filter(Boolean);for(let o of i){if(/^i-[a-z0-9]+-/.test(o))continue;let s=Te[o];if(s){s("",r);continue}if(ye(o,r))continue;if(ve(o,r))continue;if(Re(o,r))continue;if(_e(o,r))continue;if(ke(o,r))continue;if(Ce(o,r))continue;if(We(o,r))continue;if(Ne(o,r))continue;if(Be(o,r))continue;if(Ee(o,r))continue;if(Ve(o,r))continue;if(Xe(o,r))continue;if(De(o,r))continue;if(Ie(o,r))continue;if(Le(o,r))continue;if(Oe(o,r))continue;if(e?.push(o),typeof process<"u"&&process.env?.NODE_ENV==="development")console.warn(`[STX Native] Unknown Headwind class: ${o}`)}return r}function N(t,e={},r={},i={},o=[]){return{type:t,props:e,style:r,events:i,children:o}}function K(t,e,r={}){return{version:"1.0.0",root:t,script:e,meta:{source:r.source||"unknown",compiledAt:r.compiledAt||Date.now(),headwindConfig:r.headwindConfig}}}var q=new Set(["script","style","head","meta","link","title","base","noscript","svg"]),Z=new Set(["template","body","html","main","fragment"]),B=new Set(["svg"]),Ae={click:"onPress",press:"onPress",longpress:"onLongPress",contextmenu:"onLongPress",input:"onChangeText",change:"onValueChange",focus:"onFocus",focusin:"onFocus",blur:"onBlur",focusout:"onBlur",submit:"onSubmitEditing",scroll:"onScroll",close:"onRequestClose"},$e=new Set(["onBlur","onChangeText","onEndReached","onFocus","onLayout","onLongPress","onPress","onRequestClose","onScroll","onValueChange"]),V=new Set(["display","flex","flexGrow","flexShrink","flexBasis","flexDirection","flexWrap","justifyContent","alignItems","alignSelf","alignContent","position","top","right","bottom","left","zIndex","width","height","minWidth","maxWidth","minHeight","maxHeight","aspectRatio","margin","marginTop","marginRight","marginBottom","marginLeft","marginHorizontal","marginVertical","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingHorizontal","paddingVertical","gap","rowGap","columnGap","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","borderStyle","backgroundColor","backgroundImage","opacity","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","color","fontSize","fontWeight","fontStyle","fontFamily","lineHeight","letterSpacing","textAlign","textDecorationLine","textDecorationColor","textTransform","resizeMode","tintColor","transform","overflow"]),ze=new Set(["flex","flexGrow","flexShrink","zIndex","aspectRatio","gap","rowGap","columnGap","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","opacity","shadowOpacity","shadowRadius","elevation","fontSize","lineHeight","letterSpacing"]),Fe=new Set(["top","right","bottom","left","width","height","minWidth","maxWidth","minHeight","maxHeight","flexBasis","margin","marginTop","marginRight","marginBottom","marginLeft","marginHorizontal","marginVertical","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingHorizontal","paddingVertical"]),Q=new Set(["View","ScrollView","SafeAreaView","KeyboardAvoidingView","Text","TextInput","Button","TouchableOpacity","TouchableHighlight","Pressable","Image","ImageBackground","FlatList","SectionList","Switch","Slider","Picker","DatePicker","Modal","ActivityIndicator","StatusBar","RefreshControl"]),ee=new Set(["View","SafeAreaView","ScrollView","KeyboardAvoidingView"]),je={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ","#39":"'","#x27":"'"};function k(t){return t.replace(/&(#x?[0-9a-f]+|\w+);/gi,(e,r)=>{let i=je[r.toLowerCase()];if(i!==void 0)return i;if(r[0]==="#"){let o=r[1]==="x"||r[1]==="X"?Number.parseInt(r.slice(2),16):Number.parseInt(r.slice(1),10);return Number.isFinite(o)?String.fromCodePoint(o):e}return e})}function te(t){return t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase())}function ne(t){let e=/^(-?[\d.]+)px$/.exec(t);if(e)return Number.parseFloat(e[1]);let r=/^(-?[\d.]+)r?em$/.exec(t);if(r)return Number.parseFloat(r[1])*16;if(/^-?[\d.]+$/.test(t))return Number.parseFloat(t);return t}function Me(t,e,r){let i={},o={},s={},c="",f={};for(let[p,a]of e){let u=p.toLowerCase();if(u==="class"||u==="classname"){c=c?`${c} ${a}`:a;continue}if(u==="style"){f={...f,...He(t,a,r)};continue}if(u.startsWith(":")||u.startsWith("x-")&&u!=="x-cloak"){s[u.startsWith(":")?u.slice(1):u.slice(2)]=k(a);continue}if(u==="x-cloak")continue;if(u.startsWith("@")||u.startsWith("v-on:")){let b=u.startsWith("@")?u.slice(1):u.slice(5),[m]=b.split("."),S=Ae[m]??(m.startsWith("on")?m:"");if(!S||!$e.has(S)){r.push({kind:"unread-event",tag:t,name:p});continue}o[S]=k(a);continue}if(u==="key"){i.key=a;continue}let l=k(a);try{i[L(p)]=JSON.parse(l)}catch{i[L(p)]=l}}let d={...c?Y(c):{},...f};return{props:i,style:d,events:o,bindings:s,classes:c}}function re(t,e){if(ze.has(t))return!1;if(Fe.has(t))return/^-?[\d.]+%$/.test(e);return!0}function He(t,e,r){let i={},o=k(e);try{let s=JSON.parse(o);if(s&&typeof s==="object"&&!Array.isArray(s)){for(let[c,f]of Object.entries(s)){let d=V.has(c)?c:te(c.trim().toLowerCase());if(!V.has(d)){r.push({kind:"unknown-style",tag:t,name:d});continue}if(f===null||f===void 0)continue;let p=typeof f==="string"?ne(f):f;if(typeof p!=="string"&&typeof p!=="number")continue;if(typeof p==="string"&&!re(d,p)){r.push({kind:"non-numeric-style",tag:t,name:d});continue}i[d]=p}return i}}catch{}for(let s of o.split(";")){let c=s.indexOf(":");if(c===-1)continue;let f=te(s.slice(0,c).trim().toLowerCase()),d=s.slice(c+1).trim();if(!f||!d)continue;if(!V.has(f)){r.push({kind:"unknown-style",tag:t,name:f});continue}let p=ne(d);if(typeof p==="string"&&!re(f,p)){r.push({kind:"non-numeric-style",tag:t,name:f});continue}i[f]=p}return i}function ie(t){return t.children.map((e)=>typeof e==="string"?e:ie(e)).join("").replace(/\s+/g," ").trim()}function Ge(t,e){let r=t.node,i=r.children.filter((s)=>typeof s!=="string"),o=r.children.filter((s)=>typeof s==="string").join("").trim();if(ee.has(r.type)&&i.length===0&&o)return r.type="Text",r.children=[o],r;if(r.type==="Text"&&i.length>0){let s=ie(r);return e.push({kind:"flattened-text",tag:t.tag}),r.children=s?[s]:[],r}if(ee.has(r.type)&&i.length>0)r.children=i;return r}async function Ue(t,e={}){let r=[],i=[],o=[],s=new Set;function c(a){let u=o[o.length-1];if(!u)i.push(a);else if(!u.dropped)u.node.children.push(a)}function f(a){if(a.node.bindings&&Object.keys(a.node.bindings).length>0){let l=a.node.children,b=l.filter((S)=>typeof S!=="string"),m=b.length===1&&b.length===l.length?b[0]:N("View",{},{},{},l);if(m.bindings={...a.node.bindings,...m.bindings},m.bindingId===void 0&&a.node.bindingId!==void 0)m.bindingId=a.node.bindingId;c(m);return}let u=o[o.length-1];for(let l of a.node.children){if(typeof l==="string"){if(u&&!u.dropped)u.node.children.push(l);continue}if(!u)i.push(l);else if(!u.dropped)u.node.children.push(l)}}function d(a,u){let l=q.has(a)&&!B.has(a),b=o[o.length-1]?.dropped??!1,{props:m,style:S,events:h,bindings:x,classes:y}=l||b?{props:{},style:{},events:{},bindings:{},classes:""}:Me(a,u,r),X=m["data-native"],R;if(typeof X==="string"&&Q.has(X))R=X,delete m["data-native"];else R=B.has(a)?"View":G(a);if(R===a&&!Q.has(R)&&!q.has(a)&&!Z.has(a)&&!s.has(a))s.add(a),r.push({kind:"unmapped-tag",tag:a});if((l||B.has(a))&&!s.has(`drop:${a}`))s.add(`drop:${a}`),r.push({kind:"dropped-subtree",tag:a});let _=N(R,m,S,h),I=m["data-stx-b"];if(typeof I==="number"&&Number.isInteger(I))_.bindingId=I;if(delete m["data-stx-b"],y)_._classes=y;if(Object.keys(x).length>0)_.bindings=x;if(typeof m.key==="string")_.key=m.key,delete m.key;return{tag:a,node:_,dropped:l||b||B.has(a),discard:l||b,unwrap:Z.has(a)}}if(await new HTMLRewriter().on("*",{element(a){let u=a.tagName.toLowerCase(),l=d(u,[...a.attributes]),b=!0;try{a.onEndTag(()=>{if(o.pop(),l.discard)return;if(l.unwrap)f(l);else c(Ge(l,r))})}catch{b=!1}if(b)o.push(l);else if(!l.discard)c(l.node)},text(a){let u=o[o.length-1];if(!u||u.dropped)return;let l=k(a.text).replace(/\s+/g," ");if(!l.trim())return;u.node.children.push(l)}}).transform(new Response(t)).text(),i.length===0)throw Error(`No element to translate in the rendered output of ${e.source??"unknown"}`);return{root:i.length===1?i[0]:N("View",{},{},{},i),diagnostics:r}}async function oe(t,e={}){let{root:r,diagnostics:i}=await Ue(t,e),o=e.script??{exports:{},functions:[],code:""};return{document:K(r,o,{source:e.source??"unknown"}),diagnostics:i}}var se=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Je=/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([$\w]+)\s*\(/g,Ye=/(?:^|\n)\s*(?:export\s+)?(?:const|let|var)\s+([$\w]+)\s*=\s*(?:async\s*)?(?:\([^)]*\)|[$\w]+)\s*=>/g,ae=/(?:^|\n)\s*(?:export\s+)?const\s+([$\w]+)\s*=\s*(-?[\d.]+|true|false|'[^']*'|"[^"]*")\s*(?=;|\n|$)/g;function A(t){let e=[];se.lastIndex=0;for(let s of t.matchAll(se)){let c=s[1]??"";if(/\bserver\b/.test(c))continue;e.push(s[2].trim())}let r=e.filter(Boolean).join(`
|
|
3
|
+
|
|
4
|
+
`),i=[];for(let s of[Je,Ye]){s.lastIndex=0;for(let c of r.matchAll(s))if(!i.includes(c[1]))i.push(c[1])}let o={};ae.lastIndex=0;for(let s of r.matchAll(ae)){let c=s[2];try{o[s[1]]=JSON.parse(c.replace(/^'(.*)'$/,'"$1"'))}catch{o[s[1]]=c}}return{exports:o,functions:i,code:r}}var ce=/<script\b[^>]*\bdata-stx-scoped\b[^>]*>([\s\S]*?)<\/script>/gi,Ke=/function\s+(__stx_setup_[\w$]+)\s*\(/;function P(t){ce.lastIndex=0;for(let e of t.matchAll(ce)){let r=e[1].trim(),i=Ke.exec(r)?.[1];if(i)return{name:i,code:r}}return null}function Ze(){let t=[C.join(import.meta.dir,"..","primitives"),C.join(import.meta.dir,"native","primitives")];for(let e of t)if(qe(C.join(e,"View.stx")))return e;return t[0]}async function Qe(t,e,r={}){let i=r.root??C.dirname(e),o={root:i,componentsDir:r.componentsDir??C.join(i,"components"),buildMode:"serve",cache:!1,_pluginComponentDirs:[Ze()]},s={...r.context??{},__stx_inject_css:!1},c=await n(t,s,e,o,new Set),{html:f,manifest:d}=M(c),{document:p,diagnostics:a}=await oe(f,{source:e,script:A(t)}),u=P(f);if(A(t).code.trim()){let l=await Ln(t,e,r.context,{forceClientSetup:!0});u=P(l.setupCode??"")??u}return{document:p,manifest:d,setup:u,diagnostics:a,html:f}}async function E(t,e={}){return Qe(await Bun.file(t).text(),t,e)}async function tt(t,e,r){let i=await Bun.build({entrypoints:[t],target:"browser",format:"iife",minify:r,plugins:e,define:{"process.env.NODE_ENV":JSON.stringify(r?"production":"development")}});if(!i.success){let o=i.logs.map((s)=>String(s.message??s)).join(`
|
|
5
|
+
`);throw Error(`Could not bundle ${t}:
|
|
6
|
+
${o}`)}return(await i.outputs[0].text()).trim()}async function z(t){let e=Object.keys(t.screens);if(e.length===0)throw Error("screens must name at least one .stx file");let r=t.routed??!0,i=t.initialScreen??e[0];if(!t.screens[i])throw Error(`Initial screen ${i} is not in screens`);let o=v.resolve(t.root??process.cwd()),s=[];for(let h of e){let x=v.resolve(o,t.screens[h]);if(!x.endsWith(".stx"))throw Error(`Screen ${h} must name a .stx file`);s.push({name:h,file:x,compiled:await E(x,{root:o})})}let c=v.join(import.meta.dir,"..","runtime","jsc-globals.ts"),f=v.join(import.meta.dir,"..","runtime","shared-screen.ts"),d=r?`var routeName = g.__stxNativeRoute || ${JSON.stringify(i)};
|
|
7
|
+
if (routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));`:"var routeName = 'main';",p=s.map(({name:h,compiled:x},y)=>`${y===0?"if":"else if"} (routeName === ${JSON.stringify(r?h:"main")}) {
|
|
8
|
+
nativeDocument = ${JSON.stringify(x.document)};
|
|
9
|
+
manifest = ${JSON.stringify(x.manifest)};
|
|
10
|
+
}`).join(`
|
|
11
|
+
`),a=s.map(({name:h,compiled:x},y)=>`${y===0?"if":"else if"} (routeName === ${JSON.stringify(r?h:"main")}) {
|
|
12
|
+
${x.setup?.code??"g.__stx_latestSetup = null;"}
|
|
13
|
+
}`).join(`
|
|
14
|
+
`),u=`
|
|
15
|
+
import { installJSCGlobals } from ${JSON.stringify(c)};
|
|
16
|
+
import { prepareSharedNativeScreen } from ${JSON.stringify(f)};
|
|
17
|
+
var g = globalThis;
|
|
18
|
+
installJSCGlobals(g);
|
|
19
|
+
var bridge = g.__stxNativeBridge;
|
|
20
|
+
if (!bridge) throw new Error('Missing __stxNativeBridge');
|
|
21
|
+
var routeNames = ${JSON.stringify(r?e:["main"])};
|
|
22
|
+
${d}
|
|
23
|
+
g.__stxNativeRoute = routeName;
|
|
24
|
+
var nativeDocument;
|
|
25
|
+
var manifest;
|
|
26
|
+
${p}
|
|
27
|
+
var screen = prepareSharedNativeScreen(nativeDocument, manifest, bridge, { routeName: routeName, routeNames: routeNames });
|
|
28
|
+
g.__stx_host = screen.host;
|
|
29
|
+
g.__stxNativeUnmount = function() { screen.unmount(); };
|
|
30
|
+
${Pe()}
|
|
31
|
+
${a}
|
|
32
|
+
screen.mount(g.stx, g.__stx_latestSetup || null);
|
|
33
|
+
`,b=await tt("stx:native-shared-screens",[{name:"stx-native-shared-screens",setup(h){h.onResolve({filter:/^stx:native-shared-screens$/},()=>({path:"entry",namespace:"stx-native-shared-screens"})),h.onLoad({filter:/.*/,namespace:"stx-native-shared-screens"},()=>({contents:u,loader:"js"}))}}],t.minify??!1),m=s.flatMap(({compiled:h})=>h.diagnostics).map((h)=>({level:"warning",message:[h.kind,h.tag,h.name].filter(Boolean).join(": ")}));if(!t.outFile)return{code:b,diagnostics:m};let S=v.resolve(o,t.outFile);return et(v.dirname(S),{recursive:!0}),await Bun.write(S,b),{code:b,outFile:S,diagnostics:m}}async function nt(t,e={}){return z({...e,screens:{main:t},routed:!1})}function ue(t,e={}){return nt(t,e)}var fe=["native.config.json","stx-native.config.json"];function ot(t=process.cwd(),e){let r=e?T.resolve(t,e):fe.map((f)=>T.join(t,f)).find((f)=>F(f));if(!r)return null;if(!F(r))throw Error(`Native config not found: ${r}`);let i=JSON.parse(it(r,"utf8")),o=Object.entries(i.screens??{});if(o.length===0)throw Error(`${T.basename(r)} must name at least one screen in "screens"`);let s={};for(let[f,d]of o){if(!/^[A-Z][\w-]*$/i.test(f))throw Error(`Invalid native screen name: ${f}`);if(typeof d!=="string"||!d.endsWith(".stx"))throw Error(`Screen ${f} must name a .stx file`);if(s[f]=T.resolve(T.dirname(r),d),!F(s[f]))throw Error(`Screen ${f} not found: ${s[f]}`)}let c=i.initialScreen||o[0][0];if(!s[c])throw Error(`Initial screen ${c} is not in screens`);return{initialScreen:c,screens:s,file:r}}async function Vt(t,e={}){let r=T.resolve(e.cwd??process.cwd()),i=e.format??"ir";if(i!=="ir"&&i!=="bundle")throw Error(`Unknown compile format: ${i}. Expected ir or bundle.`);let o=t?null:ot(r,e.config);if(!t&&!o)throw Error(`Please specify an input file: stx native compile <file.stx>, or add ${fe[0]}`);let s,c=[];if(i==="bundle"){let d=o?await z({screens:o.screens,initialScreen:o.initialScreen,minify:e.minify,root:r}):await ue(T.resolve(r,t),{minify:e.minify});s=d.code,c=d.diagnostics}else{let d=async(a)=>{let u=await E(a);return c.push(...u.diagnostics.map((l)=>({level:"warning",message:[l.kind,l.tag,l.name].filter(Boolean).join(": ")}))),u.document},p=o?{initialScreen:o.initialScreen,screens:Object.fromEntries(await Promise.all(Object.entries(o.screens).map(async([a,u])=>[a,await d(u)])))}:await d(T.resolve(r,t));s=JSON.stringify(p,null,2)}if(!e.output)return{output:s,diagnostics:c};let f=T.resolve(r,e.output);return rt(T.dirname(f),{recursive:!0}),await Bun.write(f,s),{output:s,written:f,diagnostics:c}}export{Vt as runNativeCompile};
|