@stacksjs/stx 0.2.532 → 0.2.534
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-y4qks0bd.js → chunk-01343ehq.js} +2 -2
- package/dist/chunk-0e5nasyf.js +2 -0
- package/dist/chunk-13zbt9py.js +2 -0
- package/dist/{chunk-9w2vmfha.js → chunk-1c4t7ncb.js} +2 -2
- package/dist/{chunk-gxfnmjzp.js → chunk-1xgs9gd5.js} +2 -2
- package/dist/{chunk-4gt0r98p.js → chunk-2bvk0qyd.js} +2 -2
- package/dist/{chunk-y7ds4qyb.js → chunk-2h4f37kx.js} +2 -2
- package/dist/{chunk-q6e45gnw.js → chunk-2kvbg3t5.js} +3 -3
- package/dist/{chunk-xdtz2v5r.js → chunk-2n4je46m.js} +2 -2
- package/dist/{chunk-xcfhy5bj.js → chunk-33bzhsyw.js} +2 -2
- package/dist/{chunk-7ybgfk0m.js → chunk-3nk8cnrm.js} +2 -2
- package/dist/{chunk-gsxb0ry9.js → chunk-3r1m3tyr.js} +1 -1
- package/dist/chunk-3zs8yxy0.js +2 -0
- package/dist/{chunk-khwj964t.js → chunk-40hbpz2b.js} +3 -3
- package/dist/chunk-4a7v51vh.js +2 -0
- package/dist/{chunk-xtknewf7.js → chunk-4hyhr5r7.js} +1 -1
- package/dist/{chunk-hp1tnxzb.js → chunk-4pxc3r1p.js} +4 -4
- package/dist/chunk-4qts8zk7.js +2 -0
- package/dist/{chunk-587ehsxn.js → chunk-4r7s3862.js} +2 -2
- package/dist/chunk-4y2av4ev.js +2 -0
- package/dist/chunk-5g498pdp.js +2 -0
- package/dist/chunk-5gq8m2m7.js +2 -0
- package/dist/chunk-5wx323bm.js +2 -0
- package/dist/{chunk-d2r8t40y.js → chunk-66s4nhp7.js} +2 -2
- package/dist/{chunk-d7x6n702.js → chunk-6dtmants.js} +3 -3
- package/dist/chunk-6rcxtdh3.js +2 -0
- package/dist/{chunk-st79dqpz.js → chunk-6sd4zdtg.js} +1 -1
- package/dist/{chunk-zpdq0kx1.js → chunk-6tnh3cyq.js} +1 -1
- package/dist/chunk-6va8wt88.js +2 -0
- package/dist/chunk-7v2j9bmc.js +2 -0
- package/dist/chunk-7zgtdap7.js +2 -0
- package/dist/{chunk-0pebjkzx.js → chunk-843y0pfg.js} +4 -4
- package/dist/{chunk-4xxhprts.js → chunk-8chxczpj.js} +3 -3
- package/dist/{chunk-b7xdk1g4.js → chunk-8m1y1kyr.js} +5 -5
- package/dist/chunk-90kzf313.js +2 -0
- package/dist/{chunk-t6769zcy.js → chunk-93n6yv5x.js} +12 -12
- package/dist/chunk-94rg5s6c.js +2 -0
- package/dist/chunk-9674w2gm.js +2 -0
- package/dist/{chunk-gvw8wh29.js → chunk-9p6bt089.js} +3 -3
- package/dist/{chunk-kg77xs08.js → chunk-bczcm7jk.js} +2 -2
- package/dist/{chunk-rs46hksk.js → chunk-bxsehntq.js} +1 -1
- package/dist/{chunk-vg8thz41.js → chunk-c56qtne1.js} +1 -1
- package/dist/chunk-d1jxmhph.js +2 -0
- package/dist/{chunk-5tj6expd.js → chunk-d7zterbp.js} +2 -2
- package/dist/{chunk-664503e6.js → chunk-d871008z.js} +4 -4
- package/dist/chunk-dekpf1ry.js +2 -0
- package/dist/chunk-epa1c4q4.js +2 -0
- package/dist/{chunk-xb0785wp.js → chunk-f3q84h7b.js} +2 -2
- package/dist/{chunk-g060jncp.js → chunk-fqfqyn48.js} +4 -4
- package/dist/{chunk-g5t10z04.js → chunk-gnx0fzne.js} +60 -60
- package/dist/chunk-gsc5t942.js +2 -0
- package/dist/chunk-gsm1y1kb.js +2 -0
- package/dist/chunk-gxedmh17.js +2 -0
- package/dist/{chunk-9xq5yer8.js → chunk-h4crv0by.js} +1 -1
- package/dist/{chunk-pr5q4wev.js → chunk-hp8g2q2n.js} +1 -1
- package/dist/{chunk-38w14qs7.js → chunk-hvpzy98g.js} +1 -1
- package/dist/chunk-j9c0yam7.js +2 -0
- package/dist/{chunk-12e4a0ab.js → chunk-jbfad9cc.js} +2 -2
- package/dist/chunk-jv3jj612.js +2 -0
- package/dist/chunk-jvqas8y2.js +2 -0
- package/dist/{chunk-rwn3b21z.js → chunk-k3v13vfr.js} +2 -2
- package/dist/chunk-kcs7hyep.js +2 -0
- package/dist/chunk-kvp0at16.js +2 -0
- package/dist/{chunk-31c1g3rt.js → chunk-m011s2ha.js} +3 -3
- package/dist/{chunk-2jk0vceh.js → chunk-m56m95gk.js} +2 -2
- package/dist/{chunk-7s14bthq.js → chunk-m5fw8jq1.js} +2 -2
- package/dist/chunk-m7jmpech.js +2 -0
- package/dist/chunk-m8n9wxba.js +2 -0
- package/dist/{chunk-fyxydww2.js → chunk-mjdyyekx.js} +2 -2
- package/dist/{chunk-ennxrn5g.js → chunk-nd8v4xgb.js} +5 -5
- package/dist/chunk-ngma9vzc.js +2 -0
- package/dist/{chunk-rtk6n3vh.js → chunk-ngxqydsg.js} +3 -3
- package/dist/{chunk-ee4wwr89.js → chunk-nmy4x6dx.js} +4 -4
- package/dist/chunk-pz1mjgsp.js +2 -0
- package/dist/{chunk-er031j13.js → chunk-qfc912e5.js} +2 -2
- package/dist/chunk-qk3ptn6h.js +2 -0
- package/dist/{chunk-03wggzg8.js → chunk-qmza4327.js} +2 -2
- package/dist/{chunk-j8pacd7m.js → chunk-qqr4rn9p.js} +4 -4
- package/dist/chunk-rx4hz615.js +2 -0
- package/dist/chunk-shf0hd05.js +2 -0
- package/dist/{chunk-3vvppnws.js → chunk-sqb6gkzf.js} +8374 -8374
- package/dist/chunk-t1g1sp2z.js +2 -0
- package/dist/{chunk-m2v04c6v.js → chunk-tgc645pa.js} +45 -45
- package/dist/{chunk-2dzd2h15.js → chunk-tkvp3rz0.js} +1 -1
- package/dist/{chunk-458etq5a.js → chunk-tqnh98j7.js} +3 -3
- package/dist/chunk-tr9bjtqx.js +2 -0
- package/dist/{chunk-2y6tzn6d.js → chunk-ty1v368m.js} +2 -2
- package/dist/{chunk-grb3kfya.js → chunk-v4r8nzf3.js} +1 -1
- package/dist/{chunk-p8yh7mgr.js → chunk-v9vvzdag.js} +2 -2
- package/dist/{chunk-0wvsfs4s.js → chunk-vb4xxpa6.js} +2 -2
- package/dist/chunk-vfnerp7h.js +2 -0
- package/dist/{chunk-tkeabv04.js → chunk-vhfwnvmc.js} +5 -5
- package/dist/{chunk-15r72kw7.js → chunk-vjdj0ex3.js} +1 -1
- package/dist/{chunk-9pztpvvk.js → chunk-wh7xn313.js} +1 -1
- package/dist/chunk-wjt46tdp.js +2 -0
- package/dist/chunk-wxy9re1a.js +2 -0
- package/dist/{chunk-kwvexxey.js → chunk-x607yxrc.js} +3 -3
- package/dist/{chunk-3zyvhf4p.js → chunk-xey01yna.js} +1 -1
- package/dist/{chunk-stbsqy7e.js → chunk-xwrbrg1q.js} +1 -1
- package/dist/{chunk-9sqjmd9a.js → chunk-y18yvcjb.js} +5 -5
- package/dist/chunk-ydtnskdv.js +2 -0
- package/dist/{chunk-ky25egh1.js → chunk-yw3cqy43.js} +1 -1
- package/dist/{chunk-1945hk44.js → chunk-z9r3tqyr.js} +1 -1
- package/dist/chunk-zeve89kw.js +2 -0
- package/dist/cli.js +12 -12
- package/dist/client/signals-appearance-runtime.d.ts +2 -0
- package/dist/client/signals-appearance-runtime.js +283 -0
- package/dist/client/signals-authoring-runtime.d.ts +2 -0
- package/dist/client/signals-authoring-runtime.js +187 -0
- package/dist/client/signals-binding-utils-runtime.d.ts +2 -0
- package/dist/client/signals-binding-utils-runtime.js +130 -0
- package/dist/client/signals-bootstrap-runtime.d.ts +4 -0
- package/dist/client/signals-bootstrap-runtime.js +24 -0
- package/dist/client/signals-class-runtime.d.ts +2 -0
- package/dist/client/signals-class-runtime.js +69 -0
- package/dist/client/signals-component-api-runtime.d.ts +1 -0
- package/dist/client/signals-component-api-runtime.js +57 -0
- package/dist/client/signals-component-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-component-hydration-runtime.js +147 -0
- package/dist/client/signals-component-props-runtime.d.ts +2 -0
- package/dist/client/signals-component-props-runtime.js +90 -0
- package/dist/client/signals-conditional-chain-runtime.d.ts +2 -0
- package/dist/client/signals-conditional-chain-runtime.js +39 -0
- package/dist/client/signals-conditional-component-runtime.d.ts +2 -0
- package/dist/client/signals-conditional-component-runtime.js +82 -0
- package/dist/client/signals-container-cleanup-runtime.d.ts +2 -0
- package/dist/client/signals-container-cleanup-runtime.js +42 -0
- package/dist/client/signals-context-runtime.d.ts +2 -0
- package/dist/client/signals-context-runtime.js +48 -0
- package/dist/client/signals-cookie-runtime.d.ts +2 -0
- package/dist/client/signals-cookie-runtime.js +56 -0
- package/dist/client/signals-devtools-runtime.d.ts +2 -0
- package/dist/client/signals-devtools-runtime.js +136 -0
- package/dist/client/signals-dialog-runtime.d.ts +2 -0
- package/dist/client/signals-dialog-runtime.js +195 -0
- package/dist/client/signals-dom-ready-runtime.d.ts +2 -0
- package/dist/client/signals-dom-ready-runtime.js +306 -0
- package/dist/client/signals-drawer-runtime.d.ts +2 -0
- package/dist/client/signals-drawer-runtime.js +39 -0
- package/dist/client/signals-effect-runtime.d.ts +2 -0
- package/dist/client/signals-effect-runtime.js +157 -0
- package/dist/client/signals-event-shorthand-runtime.d.ts +2 -0
- package/dist/client/signals-event-shorthand-runtime.js +88 -0
- package/dist/client/signals-expression-compiler-runtime.d.ts +2 -0
- package/dist/client/signals-expression-compiler-runtime.js +59 -0
- package/dist/client/signals-expression-runtime.d.ts +2 -0
- package/dist/client/signals-expression-runtime.js +67 -0
- package/dist/client/signals-fetch-runtime.d.ts +2 -0
- package/dist/client/signals-fetch-runtime.js +144 -0
- package/dist/client/signals-fetch-transport-runtime.d.ts +2 -0
- package/dist/client/signals-fetch-transport-runtime.js +216 -0
- package/dist/client/signals-for-runtime.d.ts +2 -0
- package/dist/client/signals-for-runtime.js +647 -0
- package/dist/client/signals-globals-runtime.d.ts +2 -0
- package/dist/client/signals-globals-runtime.js +66 -0
- package/dist/client/signals-handler-runtime.d.ts +2 -0
- package/dist/client/signals-handler-runtime.js +80 -0
- package/dist/client/signals-head-runtime.d.ts +2 -0
- package/dist/client/signals-head-runtime.js +92 -0
- package/dist/client/signals-helpers-runtime.d.ts +2 -0
- package/dist/client/signals-helpers-runtime.js +137 -0
- package/dist/client/signals-host-runtime.d.ts +9 -0
- package/dist/client/signals-host-runtime.js +132 -0
- package/dist/client/signals-hydration-audit-runtime.d.ts +2 -0
- package/dist/client/signals-hydration-audit-runtime.js +209 -0
- package/dist/client/signals-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-hydration-runtime.js +52 -0
- package/dist/client/signals-if-chain-runtime.d.ts +2 -0
- package/dist/client/signals-if-chain-runtime.js +283 -0
- package/dist/client/signals-if-runtime.d.ts +2 -0
- package/dist/client/signals-if-runtime.js +346 -0
- package/dist/client/signals-kept-runtime.d.ts +2 -0
- package/dist/client/signals-kept-runtime.js +62 -0
- package/dist/client/signals-lazy-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-lazy-hydration-runtime.js +133 -0
- package/dist/client/signals-lifecycle-runtime.d.ts +2 -0
- package/dist/client/signals-lifecycle-runtime.js +114 -0
- package/dist/client/signals-loop-component-remap-runtime.d.ts +2 -0
- package/dist/client/signals-loop-component-remap-runtime.js +66 -0
- package/dist/client/signals-loop-conditional-runtime.d.ts +2 -0
- package/dist/client/signals-loop-conditional-runtime.js +48 -0
- package/dist/client/signals-loop-row-runtime.d.ts +2 -0
- package/dist/client/signals-loop-row-runtime.js +41 -0
- package/dist/client/signals-manifest-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-manifest-hydration-runtime.js +82 -0
- package/dist/client/signals-model-runtime.d.ts +2 -0
- package/dist/client/signals-model-runtime.js +156 -0
- package/dist/client/signals-mount-runtime.d.ts +1 -0
- package/dist/client/signals-mount-runtime.js +231 -0
- package/dist/client/signals-navigation-runtime.d.ts +2 -0
- package/dist/client/signals-navigation-runtime.js +198 -0
- package/dist/client/signals-optimistic-runtime.d.ts +2 -0
- package/dist/client/signals-optimistic-runtime.js +34 -0
- package/dist/client/signals-overlay-runtime.d.ts +2 -0
- package/dist/client/signals-overlay-runtime.js +352 -0
- package/dist/client/signals-pipe-runtime.d.ts +2 -0
- package/dist/client/signals-pipe-runtime.js +177 -0
- package/dist/client/signals-process-element-runtime.d.ts +1 -0
- package/dist/client/signals-process-element-runtime.js +696 -0
- package/dist/client/signals-proxy-runtime.d.ts +2 -0
- package/dist/client/signals-proxy-runtime.js +78 -0
- package/dist/client/signals-public-api-runtime.d.ts +1 -0
- package/dist/client/signals-public-api-runtime.js +120 -0
- package/dist/client/signals-query-runtime.d.ts +2 -0
- package/dist/client/signals-query-runtime.js +351 -0
- package/dist/client/signals-reactive-core-bootstrap-runtime.d.ts +1 -0
- package/dist/client/signals-reactive-core-bootstrap-runtime.js +30 -0
- package/dist/client/signals-reactive-runtime.d.ts +2 -0
- package/dist/client/signals-reactive-runtime.js +67 -0
- package/dist/client/signals-ref-runtime.d.ts +2 -0
- package/dist/client/signals-ref-runtime.js +33 -0
- package/dist/client/signals-scope-disposal-runtime.d.ts +2 -0
- package/dist/client/signals-scope-disposal-runtime.js +195 -0
- package/dist/client/signals-scope-traversal-runtime.d.ts +2 -0
- package/dist/client/signals-scope-traversal-runtime.js +42 -0
- package/dist/client/signals-show-runtime.d.ts +2 -0
- package/dist/client/signals-show-runtime.js +54 -0
- package/dist/client/signals-spa-load-control-runtime.d.ts +2 -0
- package/dist/client/signals-spa-load-control-runtime.js +42 -0
- package/dist/client/signals-spa-load-runtime.d.ts +2 -0
- package/dist/client/signals-spa-load-runtime.js +187 -0
- package/dist/client/signals-state-runtime.d.ts +2 -0
- package/dist/client/signals-state-runtime.js +125 -0
- package/dist/client/signals-storage-runtime.d.ts +2 -0
- package/dist/client/signals-storage-runtime.js +79 -0
- package/dist/client/signals-store-registry-runtime.d.ts +1 -0
- package/dist/client/signals-store-registry-runtime.js +461 -0
- package/dist/client/signals-style-runtime.d.ts +2 -0
- package/dist/client/signals-style-runtime.js +35 -0
- package/dist/client/signals-suspense-runtime.d.ts +2 -0
- package/dist/client/signals-suspense-runtime.js +59 -0
- package/dist/client/signals-timer-runtime.d.ts +2 -0
- package/dist/client/signals-timer-runtime.js +378 -0
- package/dist/client/signals-toast-runtime.d.ts +2 -0
- package/dist/client/signals-toast-runtime.js +206 -0
- package/dist/client/signals-tooltip-runtime.d.ts +2 -0
- package/dist/client/signals-tooltip-runtime.js +40 -0
- package/dist/client/signals-transition-group-runtime.d.ts +2 -0
- package/dist/client/signals-transition-group-runtime.js +92 -0
- package/dist/client/signals-websocket-runtime.d.ts +2 -0
- package/dist/client/signals-websocket-runtime.js +138 -0
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/pwa.js +3 -3
- package/dist/signals-context-runtime.d.ts +2 -0
- package/dist/signals-drawer-runtime.d.ts +2 -0
- package/dist/signals-host-runtime.d.ts +9 -0
- package/dist/signals-loop-conditional-runtime.d.ts +2 -0
- package/dist/signals-manifest-hydration-runtime.d.ts +2 -0
- package/dist/signals-optimistic-runtime.d.ts +2 -0
- package/dist/signals-overlay-runtime.d.ts +2 -0
- package/dist/signals-scope-disposal-runtime.d.ts +2 -0
- package/dist/signals-spa-load-control-runtime.d.ts +2 -0
- package/dist/signals-storage-runtime.d.ts +2 -0
- package/dist/signals.js +141 -9900
- package/dist/ssg.js +3 -3
- package/package.json +5 -5
- package/dist/chunk-0p9pwd61.js +0 -2
- package/dist/chunk-0zmv31nc.js +0 -2
- package/dist/chunk-28xtazwz.js +0 -2
- package/dist/chunk-2936t942.js +0 -2
- package/dist/chunk-29qwmthc.js +0 -2
- package/dist/chunk-323cxa69.js +0 -2
- package/dist/chunk-375zp0vr.js +0 -2
- package/dist/chunk-3w49r16x.js +0 -2
- package/dist/chunk-8bcvb86w.js +0 -2
- package/dist/chunk-8gmb3k1p.js +0 -2
- package/dist/chunk-a15yzfc6.js +0 -2
- package/dist/chunk-d4155ec5.js +0 -2
- package/dist/chunk-dd31q423.js +0 -2
- package/dist/chunk-f2q5bckn.js +0 -2
- package/dist/chunk-fhx35529.js +0 -2
- package/dist/chunk-h1y5q942.js +0 -2
- package/dist/chunk-h791c7sb.js +0 -2
- package/dist/chunk-h88jcr3k.js +0 -2
- package/dist/chunk-heq5c0gd.js +0 -2
- package/dist/chunk-j3b24e77.js +0 -2
- package/dist/chunk-jpck8nm5.js +0 -2
- package/dist/chunk-m4d99a9r.js +0 -2
- package/dist/chunk-ng2sdph7.js +0 -2
- package/dist/chunk-qs3p7sc6.js +0 -2
- package/dist/chunk-rchwwcxy.js +0 -2
- package/dist/chunk-rk4mttds.js +0 -2
- package/dist/chunk-rma3bv36.js +0 -2
- package/dist/chunk-rp5a91ak.js +0 -2
- package/dist/chunk-sp5x96rn.js +0 -2
- package/dist/chunk-t2mjeezd.js +0 -2
- package/dist/chunk-t61j834x.js +0 -2
- package/dist/chunk-v2vg5jqq.js +0 -2
- package/dist/chunk-vmfw4svt.js +0 -2
- package/dist/chunk-w6ecbk3y.js +0 -2
- package/dist/chunk-wbv6vjhm.js +0 -2
- package/dist/chunk-wfbr3txe.js +0 -2
- package/dist/chunk-wpnv0naj.js +0 -2
- package/dist/chunk-wwny5dk9.js +0 -2
- package/dist/chunk-x55avrcf.js +0 -2
- package/dist/chunk-yts2745t.js +0 -2
- package/dist/chunk-zah67v44.js +0 -2
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import"./chunk-
|
|
4
|
-
Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var J=n.argv.length>=3&&(U(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(J){let h=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=B(n.argv[++x]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),r=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of r)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await
|
|
3
|
+
import"./chunk-vhfwnvmc.js";import"./chunk-bpr4bkde.js";import"./chunk-2bvk0qyd.js";import"./chunk-d7zterbp.js";import"./chunk-6v1gwdbv.js";import{W}from"./chunk-gnx0fzne.js";import"./chunk-y18yvcjb.js";import"./chunk-tkvp3rz0.js";import"./chunk-v9vvzdag.js";import"./chunk-01343ehq.js";import"./chunk-1xgs9gd5.js";import"./chunk-x607yxrc.js";import"./chunk-33bzhsyw.js";import"./chunk-zzphh8g9.js";import"./chunk-tqnh98j7.js";import"./chunk-ty1v368m.js";import"./chunk-9a73re8k.js";import"./chunk-hvpzy98g.js";import"./chunk-2kvbg3t5.js";import"./chunk-4pxc3r1p.js";import"./chunk-g12j8ahm.js";import"./chunk-bxsehntq.js";import"./chunk-sqb6gkzf.js";import"./chunk-p8qr0q85.js";import"./chunk-xab6b4mt.js";import"./chunk-f3q84h7b.js";import"./chunk-0dqxnx20.js";import"./chunk-9p6bt089.js";import"./chunk-m5fw8jq1.js";import"./chunk-nmy4x6dx.js";import"./chunk-xwrbrg1q.js";import"./chunk-fqfqyn48.js";import"./chunk-yn3kp3qy.js";import"./chunk-qmza4327.js";import"./chunk-nd8v4xgb.js";import"./chunk-azb58ven.js";import{yt,bt}from"./chunk-d871008z.js";import"./chunk-2h4f37kx.js";import"./chunk-8chxczpj.js";import"./chunk-90wh9zzy.js";import"./chunk-8m1y1kyr.js";import"./chunk-vjdj0ex3.js";import"./chunk-ngxqydsg.js";import"./chunk-jjwg83xv.js";import"./chunk-2n4je46m.js";import"./chunk-k3v13vfr.js";import{Xs,Js,Ys,Zs,br,Qs,eo,to,wr,vr,_n,Tn,$n}from"./chunk-tgc645pa.js";import"./chunk-843y0pfg.js";import"./chunk-wk85dz07.js";import{xi}from"./chunk-bczcm7jk.js";import{p}from"./chunk-2a4szpje.js";import{spawn as R}from"child_process";import S from"fs";import f from"path";import n from"process";import{CLI as V}from"@stacksjs/clapp";var j="0.2.534";var __dirname="/home/runner/work/stx/stx/packages/stx/bin",y=new V("stx");function B(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(m<1024||m>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function A(h){try{if(!S.existsSync(h)){let x=f.dirname(h),t=f.basename(h);if(S.existsSync(x)){let o=S.readdirSync(x).filter((s)=>s.toLowerCase().includes(t.toLowerCase().substring(0,3))||s.endsWith(".stx")||s.endsWith(".md")),i=o.length>0?`File not found. Similar files in ${x}: ${o.slice(0,3).join(", ")}`:`File not found. Directory ${x} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${h}`,suggestion:i}}return{isValid:!1,error:`File does not exist: ${h}`,suggestion:"Check the file path and try again"}}if(S.statSync(h).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${h}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(m){return{isValid:!1,error:`Cannot access file: ${h}`,suggestion:"Check file permissions and path"}}}function z(h){let m=typeof h==="string"?Number.parseInt(h,10):h;if(Number.isNaN(m))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(m<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(m>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var O=(h)=>h.includes("*")||h.includes("?")||h.includes("{")||h.includes("["),U=(h)=>h.endsWith(".stx")||h.endsWith(".md");function F(h,m=1){if(console.error(`\u274C ${h.error}`),h.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${h.suggestion}`);n.exit(m)}function H(h){if(!h)return;let m;try{m=JSON.parse(h)}catch(x){console.error(`\u274C --info-plist is not valid JSON: ${x.message}`),n.exit(1)}if(typeof m!=="object"||m===null||Array.isArray(m))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),n.exit(1);for(let[x,t]of Object.entries(m))if(typeof t!=="string"&&typeof t!=="number"&&typeof t!=="boolean")console.error(`\u274C --info-plist value for "${x}" must be a string, number or boolean`),n.exit(1);return m}async function L(h,m){try{let x=["test"],t=[];if(h&&h.length>0)for(let c of h)if(O(c))try{let r=await Array.fromAsync(new Bun.Glob(c).scan({onlyFiles:!0,absolute:!0}));if(r.length===0)console.warn(`Warning: No files found matching pattern: ${c}`);else if(t.push(...r),m.verbose)console.log(`Found ${r.length} file(s) matching pattern: ${c}`)}catch(r){return console.error(`Error expanding glob pattern ${c}:`,r),!1}else t.push(c);if(t.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(x.push(...t),m.filter)x.push("--pattern",m.filter);if(m.timeout)x.push("--timeout",m.timeout.toString());if(m.reporter&&m.reporter!=="default")if(m.reporter==="junit"){let c=f.resolve("stx-test-report.xml");x.push("--reporter",m.reporter),x.push("--reporter-outfile",c),console.log(`JUnit report: ${c}`)}else console.warn(`Warning: Reporter '${m.reporter}' is not supported. Using default reporter.`);if(m.coverage)x.push("--coverage");if(m.watch)x.push("--watch");x.push("--preload",f.join(__dirname,"../../../test-utils/happy-dom.ts"));let e={...n.env,STX_TEST_MODE:"true",STX_TEST_UI:m.ui?"true":"false",STX_TEST_VERBOSE:m.verbose?"true":"false"},o="bun";if(m.verbose)console.log(`Running: ${o} ${x.join(" ")}`);let i=performance.now(),s=R(o,x,{stdio:"inherit",shell:!1,env:e});return new Promise((c)=>{s.on("close",(r)=>{let d=((performance.now()-i)/1000).toFixed(2);if(r===0)c(!0);else c(!1)}),n.on("SIGINT",()=>{console.log(`
|
|
4
|
+
Test run interrupted`),s.kill("SIGINT"),n.exit(1)})})}catch(x){return console.error("Error running tests:",x instanceof Error?x.message:String(x)),!1}}var J=n.argv.length>=3&&(U(n.argv[2])&&S.existsSync(n.argv[2])||O(n.argv[2]));if(J){let h=n.argv[2],m={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let x=3;x<n.argv.length;x++){let t=n.argv[x];if(t==="--port"&&x+1<n.argv.length){let e=B(n.argv[++x]);if(!e.isValid)F(e);m.port=Number.parseInt(n.argv[x],10)}else if(t==="--no-watch")m.watch=!1;else if(t==="--highlight-theme"&&x+1<n.argv.length){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.defaultTheme=n.argv[++x]}else if(t==="--no-highlight"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.enabled=!1}else if(t==="--no-highlight-unknown"){if(!m.markdown)m.markdown={};if(!m.markdown.syntaxHighlighting)m.markdown.syntaxHighlighting={};m.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(t==="--no-cache")m.cache=!1;else if(t==="--native")m.native=!0}if(O(h))try{let x=await Array.fromAsync(new Bun.Glob(h).scan({onlyFiles:!0,absolute:!0})),t=h.endsWith(".stx")?x.filter((s)=>s.endsWith(".stx")):h.endsWith(".md")?x.filter((s)=>s.endsWith(".md")):x.filter((s)=>s.endsWith(".stx")||s.endsWith(".md")),e=h.split("*")[0].replace(/\/$/,"")||".",o=f.resolve(e);try{let s=new Bun.Glob("**/*.stx"),r=(await Array.fromAsync(s.scan({cwd:o,onlyFiles:!0,absolute:!0}))).filter((l)=>/\[.+\]/.test(f.basename(l)));for(let l of r)if(!t.includes(l))t.push(l)}catch{}if(t.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${h}`),n.exit(1);if(!await Tn(t,m))n.exit(1)}catch(x){console.error("Failed to process files:",x),n.exit(1)}else _n(h,m).catch((x)=>{console.error("Failed to start dev server:",x),n.exit(1)})}else{let h=function(t,e){let o=[];for(let i=0;i<=e.length;i++)o[i]=[i];for(let i=0;i<=t.length;i++)o[0][i]=i;for(let i=1;i<=e.length;i++)for(let s=1;s<=t.length;s++)if(e.charAt(i-1)===t.charAt(s-1))o[i][s]=o[i-1][s-1];else o[i][s]=Math.min(o[i-1][s-1]+1,o[i][s-1]+1,o[i-1][s]+1);return o[e.length][t.length]};y.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(t)=>{try{if(await Zs(t))console.log("Documentation generated successfully."),n.exit(0);else console.error("Documentation generation failed."),n.exit(1)}catch(e){console.error("Error generating documentation:",e),n.exit(1)}}),y.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(t,e)=>{try{let{fetchCollections:o,generatePackage:i}=await import("./chunk-2qbvsvwc.js");if(t==="list"){console.log(`
|
|
5
5
|
\uD83D\uDCDA Fetching available icon collections...
|
|
6
6
|
`);let s=await o(),c=Object.entries(s).sort((r,l)=>l[1].total-r[1].total);console.log(`Available collections:
|
|
7
7
|
`);for(let[r,l]of c){let d=l;console.log(` ${r.padEnd(30)} ${d.name} (${d.total} icons)`)}console.log(`
|
|
8
8
|
Total: ${c.length} collections`)}else if(t.startsWith("generate")){let s=t==="generate"?"":t.replace("generate:","").replace("generate-","").replace("generate","").trim();if(!s)console.error("Error: Please specify a collection prefix"),console.error("Usage: stx iconify generate <prefix> [--icons icon1,icon2,...]"),n.exit(1);let c=e.output||f.join(n.cwd(),"packages/collections"),r=e.icons?e.icons.split(",").map((l)=>l.trim()):void 0;await i(s,c,r),console.log(`
|
|
9
9
|
\u2713 Package generated successfully!`),console.log(`
|
|
10
|
-
To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:i}=await import("./chunk-
|
|
10
|
+
To use the package:`),console.log(` 1. cd packages/collections/iconify-${s}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${t}`),console.error("Available commands: list, generate"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(t,e)=>{try{if(t==="audit"){let{runPwaAudit:o,formatAuditResult:i}=await import("./chunk-5gq8m2m7.js"),{loadConfig:s}=await import("./chunk-7zgtdap7.js");console.log(`
|
|
11
11
|
\uD83D\uDD0D Running PWA audit...
|
|
12
|
-
`);let c=await s(),r=e.output||"dist",l=o(c,r);if(console.log(i(l)),l.failed>0)n.exit(1)}else console.error(`Unknown pwa command: ${t}`),console.error("Available commands: audit"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("dev [file]","Start a development server for an STX app or file").option("--port <port>","Port to use for the dev server",{default:3000}).option("--pages <dir>",'Directory containing page templates (default: pagesDir from stx.config.ts, else "pages")').option("--no-watch","Disable file watching and auto-reload").option("--native","Open in a native desktop window using Zyte").option("--titlebar-hidden","Hide the native titlebar but keep the traffic-light buttons (web content draws under a transparent full-size titlebar). Implies --native.").option("--highlight-theme <theme>","Syntax highlighting theme for Markdown code blocks",{default:"github-dark"}).option("--no-highlight","Disable syntax highlighting for Markdown code blocks").option("--no-highlight-unknown","Disable syntax highlighting for unknown languages in Markdown").option("--no-cache","Disable caching of parsed files").option("--no-hmr","Disable HMR / live-reload script injection (useful for clean network traces)").option("--profile","Print per-directive timing for every page render via performanceMonitor").option("--debug-directives","Log directive ordering and intermediate template state during rendering").example("stx dev").example("stx dev --port 8080").example("stx dev --pages src/pages").example("stx dev template.stx").example("stx dev components/hero.stx --port 8080").example("stx dev **/*.stx").example("stx dev docs/guide.md").example("stx dev template.stx --native").action(async(t,e)=>{try{if(e.port!==void 0){let i=B(e.port);if(!i.isValid)F(i);e.port=Number.parseInt(String(e.port),10)}if(e.timeout!==void 0){let i=z(e.timeout);if(!i.isValid)F(i)}let o={syntaxHighlighting:{enabled:e.highlight!==!1,serverSide:!0,defaultTheme:e.highlightTheme||"github-dark",highlightUnknownLanguages:e.highlightUnknown!==!1}};if(!t){if(!await $n(".",{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}if(!O(t))try{let i=await import("fs");if(i.existsSync(t)&&i.statSync(t).isDirectory()){if(!await $n(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}}catch{}if(O(t)){console.log(`Expanding glob pattern: ${t}`);let i=await W.timeAsync("glob-expansion",async()=>Array.fromAsync(new Bun.Glob(t).scan({onlyFiles:!0,absolute:!0}))),s=t.endsWith(".stx")?i.filter((d)=>d.endsWith(".stx")):t.endsWith(".md")?i.filter((d)=>d.endsWith(".md")):i.filter((d)=>d.endsWith(".stx")||d.endsWith(".md"));if(s.length===0)console.error(`No STX or Markdown files found matching pattern: ${t}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),n.exit(1);let c=t.split("*")[0].replace(/\/$/,"")||".",r=f.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:r,onlyFiles:!0,absolute:!0}))).filter((g)=>/\[.+\]/.test(f.basename(g)));for(let g of u)if(!s.includes(g))s.push(g)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await
|
|
12
|
+
`);let c=await s(),r=e.output||"dist",l=o(c,r);if(console.log(i(l)),l.failed>0)n.exit(1)}else console.error(`Unknown pwa command: ${t}`),console.error("Available commands: audit"),n.exit(1)}catch(o){console.error("Error:",o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("dev [file]","Start a development server for an STX app or file").option("--port <port>","Port to use for the dev server",{default:3000}).option("--pages <dir>",'Directory containing page templates (default: pagesDir from stx.config.ts, else "pages")').option("--no-watch","Disable file watching and auto-reload").option("--native","Open in a native desktop window using Zyte").option("--titlebar-hidden","Hide the native titlebar but keep the traffic-light buttons (web content draws under a transparent full-size titlebar). Implies --native.").option("--highlight-theme <theme>","Syntax highlighting theme for Markdown code blocks",{default:"github-dark"}).option("--no-highlight","Disable syntax highlighting for Markdown code blocks").option("--no-highlight-unknown","Disable syntax highlighting for unknown languages in Markdown").option("--no-cache","Disable caching of parsed files").option("--no-hmr","Disable HMR / live-reload script injection (useful for clean network traces)").option("--profile","Print per-directive timing for every page render via performanceMonitor").option("--debug-directives","Log directive ordering and intermediate template state during rendering").example("stx dev").example("stx dev --port 8080").example("stx dev --pages src/pages").example("stx dev template.stx").example("stx dev components/hero.stx --port 8080").example("stx dev **/*.stx").example("stx dev docs/guide.md").example("stx dev template.stx --native").action(async(t,e)=>{try{if(e.port!==void 0){let i=B(e.port);if(!i.isValid)F(i);e.port=Number.parseInt(String(e.port),10)}if(e.timeout!==void 0){let i=z(e.timeout);if(!i.isValid)F(i)}let o={syntaxHighlighting:{enabled:e.highlight!==!1,serverSide:!0,defaultTheme:e.highlightTheme||"github-dark",highlightUnknownLanguages:e.highlightUnknown!==!1}};if(!t){if(!await $n(".",{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}if(!O(t))try{let i=await import("fs");if(i.existsSync(t)&&i.statSync(t).isDirectory()){if(!await $n(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,cache:e.cache!==!1,hotReload:e.hmr!==!1,profile:e.profile===!0,debugDirectives:e.debugDirectives===!0,...e.pages&&{pagesDir:e.pages}}))n.exit(1);return}}catch{}if(O(t)){console.log(`Expanding glob pattern: ${t}`);let i=await W.timeAsync("glob-expansion",async()=>Array.fromAsync(new Bun.Glob(t).scan({onlyFiles:!0,absolute:!0}))),s=t.endsWith(".stx")?i.filter((d)=>d.endsWith(".stx")):t.endsWith(".md")?i.filter((d)=>d.endsWith(".md")):i.filter((d)=>d.endsWith(".stx")||d.endsWith(".md"));if(s.length===0)console.error(`No STX or Markdown files found matching pattern: ${t}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),n.exit(1);let c=t.split("*")[0].replace(/\/$/,"")||".",r=f.resolve(c);try{let d=new Bun.Glob("**/*.stx"),u=(await Array.fromAsync(d.scan({cwd:r,onlyFiles:!0,absolute:!0}))).filter((g)=>/\[.+\]/.test(f.basename(g)));for(let g of u)if(!s.includes(g))s.push(g)}catch{}if(console.log(`Found ${s.length} ${s.length===1?"file":"files"} matching ${t}`),!await Tn(s,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}else{if(!O(t)){let s=A(t);if(!s.isValid)F(s)}if(!await _n(t,{port:e.port,watch:e.watch!==!1,native:e.native||e.titlebarHidden||!1,titlebarHidden:e.titlebarHidden===!0,markdown:o,cache:e.cache!==!1}))n.exit(1)}}catch(o){console.error("Error starting dev server:",o),n.exit(1)}}),y.command("a11y [target]","Scan .stx files for accessibility issues (directory, file, or glob)").option("--no-recursive","Disable recursive scanning of directories").option("--ignore <paths>","Comma-separated paths to ignore",{default:""}).option("--json","Output results as JSON").option("--output <file>","Write results to a file instead of stdout").option("--fix","Automatically fix common accessibility issues").example("stx a11y ./templates").example('stx a11y "resources/**/*.stx"').example("stx a11y resources/emails/welcome.stx").example("stx a11y --json --output a11y-report.json").action(async(t=".",e)=>{try{console.log(`Scanning ${t} for accessibility issues...`);let o=e.ignore?e.ignore.split(",").map((l)=>l.trim()):[],{results:i,scannedFiles:s}=await xi(t,{recursive:e.recursive!==!1,ignorePaths:o});if(s.length===0)console.log(`
|
|
13
13
|
No .stx files matched ${t}
|
|
14
14
|
`),n.exit(1);let c=Object.keys(i).length,r=Object.values(i).reduce((l,d)=>l+d.length,0);if(e.json){let l=JSON.stringify(i,null,2);if(e.output)await Bun.write(e.output,l),console.log(`A11y scan results written to ${e.output}`);else console.log(l)}else if(c===0)console.log(`\u2713 No accessibility issues found in ${s.length} file(s)!`);else{console.log(`Found ${r} accessibility issues in ${c} files:
|
|
15
15
|
`);for(let[l,d]of Object.entries(i)){let a=f.relative(n.cwd(),l);console.log(`
|
|
@@ -69,7 +69,7 @@ Total: ${r} issues in ${c} files`),e.output){let l=`
|
|
|
69
69
|
File not found: ${t}`),n.exit(1);if(!t.endsWith(".stx"))console.error(`
|
|
70
70
|
File must have .stx extension: ${t}`),n.exit(1)}let i=f.resolve(e.pages),s=f.resolve(e.out);if(!t&&!S.existsSync(i))console.error(`
|
|
71
71
|
Pages directory not found: ${i}`),console.log(`
|
|
72
|
-
Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-
|
|
72
|
+
Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),n.exit(1);let{buildApp:c}=await import("./chunk-pz1mjgsp.js");bt();let r=await c({root:t?f.dirname(t):void 0,debug:e.verbose,ssg:{pagesDir:e.pages,outputDir:e.out,domain:e.domain,baseUrl:e.base,sitemap:e.sitemap,rss:e.rss,minify:e.minify,cache:e.cache!==!1,cleanOutput:e.clean,concurrency:Number.parseInt(e.concurrency,10)||10,publicDir:e.public,trailingSlash:e.trailingSlash,generate404:!0,hooks:e.verbose?{onPageStart:(d)=>console.log(` Generating: ${d}`),onPageEnd:(d,a)=>console.log(` Generated: ${d} (${a.length} bytes)`),onError:(d,a)=>console.error(` Error in ${a}: ${d.message}`)}:void 0},ssr:{outputDir:e.out==="dist"?".output":e.out,debug:e.verbose}}),l=((performance.now()-o)/1000).toFixed(2);if(r.mode==="ssr"&&r.ssr)console.log(`
|
|
73
73
|
Build complete! (SSR)
|
|
74
74
|
`),console.log(` Pages compiled: ${r.ssr.pageCount}`),console.log(` Output: ${r.ssr.outputDir}`),console.log(` Duration: ${l}s
|
|
75
75
|
`);else if(r.ssg){if(console.log(`
|
|
@@ -84,7 +84,7 @@ Total: ${r} issues in ${c} files`),e.output){let l=`
|
|
|
84
84
|
Build completed with ${r.ssg.failedCount} error(s). Fix the issues above and try again.
|
|
85
85
|
`),n.exit(1);console.log(" To preview locally:"),console.log(` cd ${e.out||"dist"} && npx serve
|
|
86
86
|
`)}}catch(o){console.error(`
|
|
87
|
-
Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-
|
|
87
|
+
Build failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(t)=>{try{let e=f.resolve(t.output);if(!S.existsSync(f.join(e,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),n.exit(1);let{startProductionServer:o}=await import("./chunk-kvp0at16.js");await o({outputDir:e,port:Number.parseInt(t.port,10)||3000})}catch(e){console.error(`
|
|
88
88
|
Failed to start production server:`,e instanceof Error?e.message:String(e)),n.exit(1)}}),y.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(t,e)=>{try{let{deploy:o,initNetlify:i,DeployError:s}=await import("./chunk-frw35d2v.js");if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${j}\x1B[0m`),e.init){console.log(`
|
|
89
89
|
\uD83D\uDCDD Initializing Netlify configuration...
|
|
90
90
|
`);let r=await i({directory:t||n.cwd(),siteId:e.siteId});if(console.log(`\u2713 Created ${r.configPath}`),r.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
|
|
@@ -97,7 +97,7 @@ You can now deploy with: stx deploy`);return}if(e.build!==!1){if(console.log(`
|
|
|
97
97
|
`),console.log(` ${e.dryRun?"Would deploy":"Draft URL"}: ${c.url}`),c.siteUrl)console.log(` Site URL: ${c.siteUrl}`);if(!e.dryRun)console.log(`
|
|
98
98
|
Deploy ID: ${c.deployId}`),console.log(` Duration: ${(c.duration/1000).toFixed(1)}s`),console.log(` Files: ${c.filesUploaded}`)}}catch(o){if(o instanceof Error&&o.name==="DeployError")console.error(`
|
|
99
99
|
\u274C ${o.message}`),n.exit(1);console.error(`
|
|
100
|
-
\u274C Deploy failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(t,e)=>{try{let{optimizeDirectory:o,isSharpAvailable:i,formatSize:s}=await import("./chunk-
|
|
100
|
+
\u274C Deploy failed:`,o instanceof Error?o.message:String(o)),n.exit(1)}}),y.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(t,e)=>{try{let{optimizeDirectory:o,isSharpAvailable:i,formatSize:s}=await import("./chunk-6tnh3cyq.js"),c=await import("fs"),r=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${j}\x1B[0m`),!await i())console.error(`
|
|
101
101
|
\u274C sharp is required for image optimization.`),console.log(`
|
|
102
102
|
Install sharp with:`),console.log(" bun add sharp"),n.exit(1);let d=e.widths.split(",").map((v)=>Number.parseInt(v.trim(),10)).filter((v)=>!Number.isNaN(v)),a=e.formats.split(",").map((v)=>v.trim().toLowerCase()),u=Number.parseInt(e.quality,10)||80,g=e.placeholder,b=r.resolve(t);if(!c.existsSync(b))console.error(`
|
|
103
103
|
\u274C Input directory not found: ${b}`),n.exit(1);if(!c.statSync(b).isDirectory())console.error(`
|
|
@@ -124,9 +124,9 @@ To view it in the development server:`),console.log(` stx dev ${t}
|
|
|
124
124
|
\uD83D\uDCDD ${f.relative(n.cwd(),a)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${f.basename(a)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(a,b),console.log(`\u2705 Formatted ${f.relative(n.cwd(),a)}`),l++}catch(u){console.error(`\u274C Error formatting ${f.relative(n.cwd(),a)}:`,u),d++}if(e.check&&d>0)console.log(`
|
|
125
125
|
${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.check&&!e.diff)console.log(`\u2728 Formatted ${l} files successfully`)}catch(o){console.error("Error formatting files:",o),n.exit(1)}}),y.command("perf [command...]","Show performance statistics for STX operations").option("--clear","Clear performance statistics").option("--json","Output as JSON").example("stx perf").example("stx perf --clear").example("stx perf --json").action(async(t,e)=>{try{if(e.clear){W.clear(),console.log("\u2705 Performance statistics cleared");return}let o=W.getStats();if(Object.keys(o).length===0){if(e.json){console.log(JSON.stringify({},null,2));return}console.log("No performance data available. Run some STX commands first.");return}if(e.json)console.log(JSON.stringify(o,null,2));else{console.log(`
|
|
126
126
|
\uD83D\uDCCA STX Performance Statistics
|
|
127
|
-
`);for(let[i,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${i}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:i}=await import("./chunk-
|
|
127
|
+
`);for(let[i,s]of Object.entries(o))console.log(`\uD83D\uDD27 ${i}:`),console.log(` Count: ${s.count}`),console.log(` Average: ${s.avgTime.toFixed(2)}ms`),console.log(` Total: ${s.totalTime.toFixed(2)}ms`),console.log(` Min: ${s.minTime.toFixed(2)}ms`),console.log(` Max: ${s.maxTime.toFixed(2)}ms`),console.log("")}}catch(o){console.error("Error showing performance stats:",o),n.exit(1)}}),y.command("typecheck [patterns...]","Type-check the TypeScript inside .stx script blocks").option("--no-client","Skip <script client> and bare <script> blocks").option("--no-server","Skip <script server> blocks").option("--no-templates","Skip {{ }} and directive expressions in the markup").option("--lib <path>","Extra ambient declaration file (repeatable)").example("stx typecheck").example('stx typecheck "resources/views/**/*.stx"').action(async(t,e)=>{let{formatTypecheckDiagnostics:o,typecheckStxFiles:i}=await import("./chunk-7v2j9bmc.js"),{resolveStxTargets:s}=await import("./chunk-pkfwxp9n.js"),c=Array.isArray(t)?t:t?[t]:[],r=c.length?c:["**/*.stx"],l=await s(r);if(l.length===0){console.log(`
|
|
128
128
|
No .stx files matched ${r.join(", ")}
|
|
129
|
-
`);return}let d=
|
|
129
|
+
`);return}let d=Xs(n.argv,"--lib"),a=d.length>0?d:e.lib?Array.isArray(e.lib)?e.lib:[e.lib]:[],u=await i(l,{client:e.client!==!1,server:e.server!==!1,templates:e.templates!==!1,extraLibs:a});if(u.failure)console.error(`
|
|
130
130
|
Type-check did not run.
|
|
131
131
|
|
|
132
132
|
${u.failure.split(`
|
|
@@ -136,7 +136,7 @@ ${d} files need formatting. Run 'stx format' to fix.`),n.exit(1);else if(!e.chec
|
|
|
136
136
|
${o(u.diagnostics)}
|
|
137
137
|
`);if(console.log(` Checked ${u.blockCount} script block(s) and ${u.expressionCount} template expression(s) in ${u.checkedFiles.length} file(s) \u2014 `+`${g.length} error(s), ${u.diagnostics.length-g.length} warning(s)
|
|
138
138
|
`),g.length>0)n.exit(1)}),y.command("codemod [patterns...]","Find hand-rolled code that an stx primitive already covers").option("--fix","Write the safe rewrites (default is report-only)").option("--rule <rule>","Run one rule only: confirm | tooltip (rewritable) \xB7 alert | route-params | search-params | navigate | "+"fetch | polling | debounce | click-outside | focus | clipboard | watch (report-only)").example("stx codemod").example("stx codemod --rule route-params").example('stx codemod --fix "resources/views/**/*.stx"').action(async(t,e)=>{let{codemodSource:o,formatCodemodFindings:i}=await import("./chunk-v1m9nrn9.js"),s=globalThis.Bun.Glob,c=Array.isArray(t)?t:t?[t]:[],r=c.length?c:["**/*.stx","**/*.ts"],l=e.rule?[e.rule]:void 0;if(e.rule&&e.rule!=="confirm"&&e.rule!=="tooltip")console.error(`Unknown rule "${e.rule}". Expected: confirm | tooltip`),n.exit(1);let d=new Set,a=[],u=0,g=new Set;try{let b=Bun.spawnSync(["git","ls-files","--others","--ignored","--exclude-standard","-z"],{cwd:n.cwd(),stdout:"pipe",stderr:"pipe"});for(let w of new TextDecoder().decode(b.stdout).split("\x00"))if(w)g.add(f.resolve(n.cwd(),w))}catch{}for(let b of r)for await(let w of new s(b).scan({cwd:n.cwd(),absolute:!0})){if(w.includes("/node_modules/")||w.includes("/dist/")||d.has(w)||g.has(w))continue;d.add(w);let k=await Bun.file(w).text(),v=o(k,{file:w,rules:l});if(a.push(...v.findings),e.fix&&v.code!==k)await Bun.write(w,v.code),u++}if(console.error(i(a,Boolean(e.fix))),e.fix)console.error(`
|
|
139
|
-
${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime resolution + staleness chain").option("--json","Output the report as JSON").example("stx doctor").example("stx doctor --json").action(async(t)=>{try{let e;try{let i=await import("./chunk-
|
|
139
|
+
${u} file(s) written.`)}),y.command("doctor","Diagnose the stx framework-runtime resolution + staleness chain").option("--json","Output the report as JSON").example("stx doctor").example("stx doctor --json").action(async(t)=>{try{let e;try{let i=await import("./chunk-d1jxmhph.js");e=i.generateSignalsRuntime}catch{e=void 0}let o=await wr({generateRuntime:e});if(t.json)console.log(JSON.stringify(o,null,2));else console.log(vr(o));if(!o.ok)n.exit(1)}catch(e){console.error("Error running doctor:",e),n.exit(1)}}),y.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(t,e)=>{try{let o=A(t);if(!o.isValid)F(o);console.log(`\uD83D\uDD0D Debugging stx template: ${t}
|
|
140
140
|
`);let i={};if(e.context)try{i=JSON.parse(e.context)}catch(r){console.error("\u274C Invalid JSON in --context option"),n.exit(1)}let s=await Bun.file(t).text();console.log(`\uD83D\uDCC4 Template Content (${s.length} chars):`),console.log("\u2500".repeat(50)),console.log(s.substring(0,500)+(s.length>500?`
|
|
141
141
|
...
|
|
142
142
|
`:"")),console.log("\u2500".repeat(50));let c=s.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(c)console.log(`
|
|
@@ -160,11 +160,11 @@ Press Ctrl+C to stop watching...
|
|
|
160
160
|
\uD83D\uDCC4 Files with issues:`),d.forEach((a)=>{let u=a.issues.filter((g)=>s[g.type]>=c).length;if(u>0)console.log(` ${f.relative(n.cwd(),a.file)} (${u} issues)`)});if(e.saveReport){let a={summary:l,results:d,generatedAt:new Date().toISOString(),commandOptions:e};await Bun.write(e.saveReport,JSON.stringify(a,null,2)),console.log(`
|
|
161
161
|
\uD83D\uDCCB Analysis report saved to: ${e.saveReport}`)}console.log(`
|
|
162
162
|
\u2728 Analysis complete! Use --detailed for more information.`)}catch(o){console.error("Error analyzing templates:",o),n.exit(1)}}),y.command("screenshot [input]","Capture PNG screenshot(s) of page(s) via Bun WebView \u2014 a file, URL, or dist directory").option("--out <dir>","Output directory",{default:"screenshots"}).option("--width <px>","Viewport width",{default:"1440"}).option("--height <px>","Viewport height",{default:"2200"}).option("--wait <ms>","Settle time after navigation before capture",{default:"800"}).option("--timeout <ms>","Hard cap on waiting for navigation",{default:"15000"}).option("--full-page","Capture the entire scrollable page, not just the viewport").option("--wait-selector <sel>","Wait until a CSS selector exists before capturing").option("--format <fmt>","Image format: png | jpeg | webp",{default:"png"}).option("--backend <name>","WebView backend: webkit (macOS, default) | chrome").action(async(t,e)=>{let{captureScreenshots:o}=await import("./chunk-ndv44bgs.js"),i=t||"dist";try{let s=await o(i,e.out,{width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),waitMs:Number.parseInt(e.wait,10),timeoutMs:Number.parseInt(e.timeout,10),fullPage:Boolean(e.fullPage),waitSelector:e.waitSelector,format:e.format,backend:e.backend});for(let c of s)console.log(`\uD83D\uDCF8 ${c.output} (${(c.bytes/1024).toFixed(0)} KB)`);console.log(`
|
|
163
|
-
\u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(j)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-
|
|
163
|
+
\u2728 Captured ${s.length} screenshot(s) to ${e.out}/ via Bun WebView`)}catch(s){console.error(`Screenshot failed: ${s.message}`),n.exit(1)}}),y.command("version","Show the version of the CLI").action(()=>{console.log(j)}),y.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(t)=>{let{startInteractive:e}=await import("./chunk-4a7v51vh.js"),o={};if(t.context){let i=f.resolve(t.context);if(S.existsSync(i))try{let s=S.readFileSync(i,"utf-8");o=JSON.parse(s)}catch(s){console.error("Error loading context file:",s),n.exit(1)}else console.error(`Context file not found: ${i}`),n.exit(1)}await e({context:o,cwd:t.cwd?f.resolve(t.cwd):n.cwd(),verbose:t.verbose})}),y.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(t,e)=>{try{let{buildNative:o,getAvailableTargets:i,getAvailableFormats:s}=await import("./chunk-vfnerp7h.js"),c=f.resolve(t);if(!S.existsSync(c))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let r=i();if(e.target&&!["macos","windows","linux","ios","android"].includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${r.join(", ")}`),n.exit(1);let l=e.target||r[0],d=s(l);if(e.format&&!d.includes(e.format))console.error(`\u274C Invalid format for ${l}: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${d.join(", ")}`),n.exit(1);console.log(`
|
|
164
164
|
\uD83D\uDD28 Building native app...`),console.log(` Input: ${t}`),console.log(` Target: ${l}`),console.log(` Format: ${e.format||"default"}`),console.log(` Output: ${e.output}
|
|
165
165
|
`);let a=await o({input:c,output:f.resolve(e.output),target:l,format:e.format,name:e.name,version:e.version,description:e.description,author:e.author,bundleId:e.bundleId,icon:e.icon?f.resolve(e.icon):void 0,window:{title:e.title,width:Number.parseInt(e.width,10),height:Number.parseInt(e.height,10),frameless:e.frameless,alwaysOnTop:e.alwaysOnTop},systemTray:e.systemTray,menubarOnly:e.menubarOnly,category:e.category,copyright:e.copyright,minimumSystemVersion:e.minSystemVersion,infoPlist:H(e.infoPlist),devTools:e.devTools,craftPath:e.craftPath,verbose:e.verbose});if(a.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${a.outputPath}`),a.duration)console.log(` Duration: ${(a.duration/1000).toFixed(2)}s`);if(l==="macos"&&a.format==="app")console.log(`
|
|
166
166
|
\uD83D\uDCA1 To run: open "${a.outputPath}"`);else if(l==="linux"&&a.format==="appimage")console.log(`
|
|
167
|
-
\uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-
|
|
167
|
+
\uD83D\uDCA1 To run: chmod +x "${a.outputPath}" && "${a.outputPath}"`)}else console.error(`\u274C Build failed: ${a.error}`),n.exit(1)}catch(o){console.error(`\u274C Build error: ${o.message}`),n.exit(1)}}),y.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(t)=>{try{let{devCommand:e}=await import("./chunk-qqr4rn9p.js");await e({port:t.port?Number.parseInt(t.port,10):6006,open:t.open,host:t.host})}catch(e){console.error(`\u274C Story error: ${e.message}`),n.exit(1)}}),y.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(t)=>{try{let{buildCommand:e}=await import("./chunk-wh7xn313.js");await e({outDir:t.outDir})}catch(e){console.error(`\u274C Story build error: ${e.message}`),n.exit(1)}}),y.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(t)=>{try{let{createContext:e}=await import("./chunk-hp8g2q2n.js"),{runVisualTests:o,updateSnapshots:i,formatTestResults:s}=await import("./chunk-3r1m3tyr.js"),c=await e({mode:"build"});if(t.update){let r=await i(c,{filter:t.filter?[t.filter]:void 0});console.log(`Updated ${r} snapshots`)}else{let r=await o(c,{filter:t.filter?[t.filter]:void 0});if(console.log(s(r)),r.failed>0)n.exit(1)}}catch(e){console.error(`\u274C Story test error: ${e.message}`),n.exit(1)}}),y.command("native <action> [file]","Compile .stx screens into the JavaScriptCore bundle Craft renders natively").option("--format <format>","bundle (the JavaScriptCore bundle) or ir (the template as JSON)",{default:"ir"}).option("--output <path>","Write to this file instead of stdout").option("--minify","Minify the bundle",{default:!1}).option("--config <file>","Screens config (default: native.config.json in the working directory)").example("stx native compile Screen.stx --format bundle --output native-screen.js").example("stx native compile --format bundle --output native-screen.js --minify").example("stx native compile Screen.stx").action(async(t,e,o)=>{if(t!=="compile")console.error(`Unknown native command: ${t}`),console.error("Usage: stx native compile [file.stx] --format bundle|ir [--output <file>] [--minify] [--config <file>]"),n.exit(1);try{let{runNativeCompile:i}=await import("./chunk-40hbpz2b.js"),s=await i(e,{format:o.format,output:o.output,minify:Boolean(o.minify),config:o.config});for(let c of s.diagnostics)console.warn(`${c.level}: ${c.message}`);if(s.written)console.log(`Compiled: ${e??"screens"} \u2192 ${f.relative(n.cwd(),s.written)||s.written}`);else console.log(s.output)}catch(i){console.error(i instanceof Error?i.message:String(i)),n.exit(1)}}),y.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(t,e)=>{try{let{compileToNative:o}=await import("./chunk-4y2av4ev.js"),i=f.resolve(t);if(!S.existsSync(i))console.error(`\u274C Input file not found: ${t}`),n.exit(1);let s=["macos","windows","linux","ios","android","universal"];if(!s.includes(e.target))console.error(`\u274C Invalid target: ${e.target}`),console.error(`\uD83D\uDCA1 Available targets: ${s.join(", ")}`),n.exit(1);let c=["zig","typescript","json"];if(!c.includes(e.format))console.error(`\u274C Invalid format: ${e.format}`),console.error(`\uD83D\uDCA1 Available formats: ${c.join(", ")}`),n.exit(1);console.log(`
|
|
168
168
|
\uD83D\uDD27 Compiling stx template to native code...`),console.log(` Input: ${t}`),console.log(` Target: ${e.target}`),console.log(` Format: ${e.format}`),console.log(` Output: ${e.output}
|
|
169
169
|
`);let r=S.readFileSync(i,"utf-8"),l=await o(r,{target:e.target,format:e.format,optimize:e.optimize,treeShake:e.treeShake,hotReload:e.hotReload,debug:e.verbose,sourceMaps:e.sourcemaps,bundle:e.bundle,minify:e.minify}),d=f.resolve(e.output);if(!S.existsSync(d))S.mkdirSync(d,{recursive:!0});let a=f.basename(t,f.extname(t)),u=e.format==="typescript"?"ts":e.format==="json"?"json":"zig",g=f.join(d,`${a}.${u}`);S.writeFileSync(g,l.code);let b=f.join(d,`${a}.manifest.json`);if(S.writeFileSync(b,JSON.stringify(l.manifest,null,2)),e.sourcemaps&&l.sourceMaps){let w=f.join(d,`${a}.${u}.map`);S.writeFileSync(w,l.sourceMaps)}if(e.target==="universal"&&l.platformCode.size>0)for(let[w,k]of l.platformCode){let v=f.join(d,`${a}.${w}.${u}`);S.writeFileSync(v,k)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${g}`),console.log(` Manifest: ${b}`),console.log(`
|
|
170
170
|
\uD83D\uDCCA Statistics:`),console.log(` Compilation time: ${l.stats.compilationTime.toFixed(2)}ms`),console.log(` Total components: ${l.stats.totalComponents}`),console.log(` Native components: ${l.stats.nativeComponents}`),console.log(` Web fallback components: ${l.stats.webComponents}`),console.log(` Bundle size: ${(l.stats.bundleSize/1024).toFixed(2)}KB`),l.stats.warnings.length>0){console.log(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Color mode, media, visibility, and scroll-lock helpers for the client runtime. */
|
|
2
|
+
export declare const SIGNALS_APPEARANCE_RUNTIME = " function useColorMode(options) {\n options = options || {};\n // The pre-paint boot script (stacksjs/stx#1794) publishes the app's\n // configured options here. Reading them makes a bare useColorMode() agree\n // with whatever already landed on <html> before first paint \u2014 without this\n // the composable would fall back to its own defaults, read a different\n // storage key, and undo the theme on hydration, reintroducing the very\n // flash the boot script exists to prevent.\n var boot = null;\n try { boot = window.__STX_COLOR_MODE__ || null; } catch (e) {}\n // Explicit-undefined checks rather than ||, so an explicit darkClass:null\n // or attribute:null opts out instead of falling through to the default.\n // An explicit null means \"do not manage this\", from the call site OR from\n // app.colorMode. The boot payload is generated by stx and always carries\n // every key, so absent and explicitly-null ARE distinguishable there, and\n // rejecting null made the boot global the one path that could not say it\n // (#1813). The asymmetry hid because it only bites where the fallback is\n // non-null: attribute:null looked fine, darkClass:null silently became\n // 'dark' \u2014 so opting out of the class required repeating the option at\n // every call site, defeating the single-source arrangement the global\n // exists for.\n function pick(a, b, fallback) {\n if (a !== undefined) return a;\n if (b !== undefined) return b;\n return fallback;\n }\n // Read through a helper rather than a short-circuit on boot itself: that\n // expression yields undefined for an undefined boot but NULL for a null\n // one, which pick would now honour as an explicit opt-out.\n function fromBoot(key) {\n return (boot && typeof boot === 'object') ? boot[key] : undefined;\n }\n var storageKey = pick(options.storageKey, fromBoot('storageKey'), 'stx-color-mode');\n var initialMode = pick(options.initialMode, fromBoot('initialMode'), 'auto');\n var darkClass = pick(options.darkClass, fromBoot('darkClass'), 'dark');\n var attribute = pick(options.attribute, fromBoot('attribute'), null);\n var autoValueOption = pick(options.autoValue, fromBoot('autoValue'), undefined);\n var disableTransitions = options.disableTransitions !== false;\n // A mode the page was served already stamped with, which outranks this\n // composable's own resolution: for a page whose theme is not the visitor's\n // to choose (stacksjs/stx#2050). Taken from the boot global's forced key\n // rather than by reading the attribute, because the boot script has\n // stamped it by now either way and the DOM can no longer say which it was.\n //\n // No backticks in this comment, or any other in this file: the runtime is\n // generated from a template literal, so one would end the literal and\n // break the whole emitted script.\n var respectExisting = options.respectExisting === true || fromBoot('respectExisting') === true;\n var bootForced = fromBoot('forced');\n var forcedMode = (respectExisting && (bootForced === 'light' || bootForced === 'dark')) ? bootForced : null;\n var resolved = 'light';\n var listeners = [];\n var cleanups = [];\n\n // Storage tokens meaning \"follow the system\". 'system' is a common spelling\n // for the same concept; rejecting it used to send the app down a silent\n // data-loss path \u2014 read 'system', fail to recognise it, fall back to\n // 'auto', then OVERWRITE the stored value with 'auto' (#1788).\n function normalizeMode(v) {\n if (v === 'light' || v === 'dark') return v;\n if (v === 'auto' || v === 'system') return 'auto';\n return null;\n }\n var preference = normalizeMode(initialMode) || 'auto';\n\n function getSystem() {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n function resolve(pref) { return pref === 'auto' ? getSystem() : pref; }\n // Used wherever the resolved mode is assigned, so a forced page survives\n // a system-theme change and another tab's write, not just the first mount.\n function effective(pref) { return forcedMode || resolve(pref); }\n function applyDOM(mode) {\n var el = document.documentElement;\n if (disableTransitions) el.style.setProperty('transition', 'none', 'important');\n // Both, when both are configured. The class drives the utility\n // framework's dark: variants, the attribute drives everything else \u2014\n // complements, not alternatives.\n if (attribute) el.setAttribute(attribute, mode);\n // Explicit add/remove, not toggle(cls, force) \u2014 very-happy-dom ignores\n // the force argument and plain-toggles, inverting every light-mode test.\n if (darkClass) { if (mode === 'dark') el.classList.add(darkClass); else el.classList.remove(darkClass); }\n if (disableTransitions) { el.offsetHeight; el.style.removeProperty('transition'); }\n }\n function readRaw() {\n try { return localStorage.getItem(storageKey); }\ncatch (e) { return null; }\n }\n // The spelling written back for 'auto': an explicit option wins, else\n // whatever the app already stored, so its own pre-paint script keeps\n // reading a value it recognises.\n var storedRaw = readRaw();\n var autoValue = autoValueOption !== undefined\n ? autoValueOption\n : ((storedRaw === 'auto' || storedRaw === 'system') ? storedRaw : 'auto');\n\n function persist(pref) {\n try { localStorage.setItem(storageKey, pref === 'auto' ? autoValue : pref); }\ncatch (e) {} }\n // persistChoice: only an explicit user choice is written back. Persisting\n // on init would stamp the resolved default over a stored value this\n // composable didn't recognise, destroying it.\n // The boot script keeps the document in step for its whole life when it\n // was configured with what this instance manages (see color-mode-boot.ts):\n // then the system, the foreground and other tabs are its to follow, and\n // this instance only mirrors what it announces. Following them here as\n // well was what made the mode a component's: the listener left with the\n // component, and with it the page's following of the system.\n var bootSync = fromBoot('sync');\n var bootWatches = typeof bootSync === 'function' && fromBoot('watching') === true\n && fromBoot('storageKey') === storageKey && fromBoot('darkClass') === darkClass && fromBoot('attribute') === attribute;\n\n function update(pref, persistChoice) {\n preference = normalizeMode(pref) || 'auto';\n resolved = effective(preference);\n applyDOM(resolved);\n if (persistChoice !== false) persist(preference);\n listeners.forEach(function(fn) { fn(resolved, preference); });\n // A choice made here is announced to every other instance by the boot.\n if (persistChoice !== false && bootWatches) bootSync();\n }\n\n update(normalizeMode(storedRaw) || initialMode, false);\n\n if (bootWatches) {\n var onAnnounced = function(e) {\n var detail = (e && e.detail) || {};\n var pref = normalizeMode(detail.preference) || preference;\n var mode = forcedMode || (detail.mode === 'dark' ? 'dark' : 'light');\n if (pref === preference && mode === resolved) return;\n preference = pref;\n resolved = mode;\n listeners.forEach(function(fn) { fn(resolved, preference); });\n };\n window.addEventListener('stx:color-mode', onAnnounced);\n cleanups.push(function() { window.removeEventListener('stx:color-mode', onAnnounced); });\n onDestroy(function() { cleanups.forEach(function(fn) { fn(); }); listeners = []; });\n return colorModeHandle();\n }\n\n var mql = window.matchMedia('(prefers-color-scheme: dark)');\n var onSystemChange = function() {\n if (preference === 'auto') {\n resolved = forcedMode || getSystem();\n applyDOM(resolved);\n listeners.forEach(function(fn) { fn(resolved, preference); });\n }\n };\n mql.addEventListener('change', onSystemChange);\n cleanups.push(function() { mql.removeEventListener('change', onSystemChange); });\n\n var onStorage = function(e) {\n if (e.key !== storageKey) return;\n var v = normalizeMode(e.newValue);\n if (v) {\n // Track the other tab's spelling too, so a write from here doesn't\n // convert the key out from under it.\n if (v === 'auto' && (e.newValue === 'auto' || e.newValue === 'system')) autoValue = e.newValue;\n preference = v; resolved = effective(v); applyDOM(resolved);\n listeners.forEach(function(fn) { fn(resolved, preference); });\n }\n };\n window.addEventListener('storage', onStorage);\n cleanups.push(function() { window.removeEventListener('storage', onStorage); });\n\n onDestroy(function() { cleanups.forEach(function(fn) { fn(); }); listeners = []; });\n\n return colorModeHandle();\n\n function colorModeHandle() {\n return {\n get mode() { return resolved; },\n get preference() { return preference; },\n get isDark() { return resolved === 'dark'; },\n set: function(mode) { update(mode); },\n toggle: function() { update(resolved === 'dark' ? 'light' : 'dark'); },\n subscribe: function(fn) {\n listeners.push(fn);\n return function() { listeners = listeners.filter(function(f) { return f !== fn; }); };\n }\n };\n }\n }\n\n function useDark(options) {\n var cm = useColorMode(options);\n var dark = state(cm.isDark);\n var setSignal = dark.set;\n cm.subscribe(function(mode) { setSignal(mode === 'dark'); });\n dark.toggle = function() { cm.toggle(); };\n dark.set = function(value) { cm.set(value ? 'dark' : 'light'); };\n Object.defineProperty(dark, 'isDark', { get: function() { return dark(); } });\n return dark;\n }\n\n function useMediaQuery(query) {\n var mql = window.matchMedia(query);\n var matches = state(mql.matches);\n var onChange = function(event) { matches.set(event.matches); };\n if (mql.addEventListener) mql.addEventListener('change', onChange);\n else if (mql.addListener) mql.addListener(onChange);\n onDestroy(function() {\n if (mql.removeEventListener) mql.removeEventListener('change', onChange);\n else if (mql.removeListener) mql.removeListener(onChange);\n });\n Object.defineProperty(matches, 'matches', { get: function() { return matches(); } });\n Object.defineProperty(matches, 'value', { get: function() { return matches(); } });\n return matches;\n }\n\n // 'visible' or 'hidden', kept current: whether the page is on screen (the\n // app in the foreground, the tab in front). Built in rather than taken from\n // @stacksjs/browser, whose bundle a page then carried in full (~180KB) for\n // this one listener.\n function useDocumentVisibility() {\n var visibility = state(typeof document !== 'undefined' ? document.visibilityState : 'visible');\n if (typeof document === 'undefined') return visibility;\n var onChange = function() { visibility.set(document.visibilityState); };\n document.addEventListener('visibilitychange', onChange);\n onDestroy(function() { document.removeEventListener('visibilitychange', onChange); });\n return visibility;\n }\n\n var scrollLockStates = new WeakMap();\n\n function resolveScrollLockTarget(target) {\n var value = target;\n if (typeof value === 'function') value = value();\n if (value && typeof value === 'object' && 'current' in value) value = value.current;\n if (value && typeof value === 'object' && !value.nodeType && 'value' in value) value = value.value;\n return value || document.body || document.documentElement;\n }\n\n function acquireScrollLock(element) {\n if (!element) return;\n var existing = scrollLockStates.get(element);\n if (existing) {\n existing.count += 1;\n return;\n }\n scrollLockStates.set(element, { count: 1, overflow: element.style.overflow });\n element.style.overflow = 'hidden';\n }\n\n function releaseScrollLock(element) {\n if (!element) return;\n var existing = scrollLockStates.get(element);\n if (!existing) return;\n existing.count -= 1;\n if (existing.count > 0) return;\n element.style.overflow = existing.overflow;\n scrollLockStates.delete(element);\n }\n\n function useScrollLock(target) {\n var locked = state(false);\n var lockedElement = null;\n var unsubscribe = locked.subscribe(function(value) {\n if (value) {\n if (lockedElement) return;\n lockedElement = resolveScrollLockTarget(target);\n acquireScrollLock(lockedElement);\n }\n else if (lockedElement) {\n releaseScrollLock(lockedElement);\n lockedElement = null;\n }\n });\n onDestroy(function() {\n unsubscribe();\n if (lockedElement) {\n releaseScrollLock(lockedElement);\n lockedElement = null;\n }\n });\n return locked;\n }\n\n function usePreferredDark() { return useMediaQuery('(prefers-color-scheme: dark)'); }\n function usePreferredLight() { return useMediaQuery('(prefers-color-scheme: light)'); }\n function usePreferredReducedMotion() { return useMediaQuery('(prefers-reduced-motion: reduce)'); }\n function usePreferredContrast() { return useMediaQuery('(prefers-contrast: more)'); }\n";
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
export const SIGNALS_APPEARANCE_RUNTIME = ` function useColorMode(options) {
|
|
2
|
+
options = options || {};
|
|
3
|
+
// The pre-paint boot script (stacksjs/stx#1794) publishes the app's
|
|
4
|
+
// configured options here. Reading them makes a bare useColorMode() agree
|
|
5
|
+
// with whatever already landed on <html> before first paint \u2014 without this
|
|
6
|
+
// the composable would fall back to its own defaults, read a different
|
|
7
|
+
// storage key, and undo the theme on hydration, reintroducing the very
|
|
8
|
+
// flash the boot script exists to prevent.
|
|
9
|
+
var boot = null;
|
|
10
|
+
try { boot = window.__STX_COLOR_MODE__ || null; } catch (e) {}
|
|
11
|
+
// Explicit-undefined checks rather than ||, so an explicit darkClass:null
|
|
12
|
+
// or attribute:null opts out instead of falling through to the default.
|
|
13
|
+
// An explicit null means "do not manage this", from the call site OR from
|
|
14
|
+
// app.colorMode. The boot payload is generated by stx and always carries
|
|
15
|
+
// every key, so absent and explicitly-null ARE distinguishable there, and
|
|
16
|
+
// rejecting null made the boot global the one path that could not say it
|
|
17
|
+
// (#1813). The asymmetry hid because it only bites where the fallback is
|
|
18
|
+
// non-null: attribute:null looked fine, darkClass:null silently became
|
|
19
|
+
// 'dark' \u2014 so opting out of the class required repeating the option at
|
|
20
|
+
// every call site, defeating the single-source arrangement the global
|
|
21
|
+
// exists for.
|
|
22
|
+
function pick(a, b, fallback) {
|
|
23
|
+
if (a !== undefined) return a;
|
|
24
|
+
if (b !== undefined) return b;
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
27
|
+
// Read through a helper rather than a short-circuit on boot itself: that
|
|
28
|
+
// expression yields undefined for an undefined boot but NULL for a null
|
|
29
|
+
// one, which pick would now honour as an explicit opt-out.
|
|
30
|
+
function fromBoot(key) {
|
|
31
|
+
return (boot && typeof boot === 'object') ? boot[key] : undefined;
|
|
32
|
+
}
|
|
33
|
+
var storageKey = pick(options.storageKey, fromBoot('storageKey'), 'stx-color-mode');
|
|
34
|
+
var initialMode = pick(options.initialMode, fromBoot('initialMode'), 'auto');
|
|
35
|
+
var darkClass = pick(options.darkClass, fromBoot('darkClass'), 'dark');
|
|
36
|
+
var attribute = pick(options.attribute, fromBoot('attribute'), null);
|
|
37
|
+
var autoValueOption = pick(options.autoValue, fromBoot('autoValue'), undefined);
|
|
38
|
+
var disableTransitions = options.disableTransitions !== false;
|
|
39
|
+
// A mode the page was served already stamped with, which outranks this
|
|
40
|
+
// composable's own resolution: for a page whose theme is not the visitor's
|
|
41
|
+
// to choose (stacksjs/stx#2050). Taken from the boot global's forced key
|
|
42
|
+
// rather than by reading the attribute, because the boot script has
|
|
43
|
+
// stamped it by now either way and the DOM can no longer say which it was.
|
|
44
|
+
//
|
|
45
|
+
// No backticks in this comment, or any other in this file: the runtime is
|
|
46
|
+
// generated from a template literal, so one would end the literal and
|
|
47
|
+
// break the whole emitted script.
|
|
48
|
+
var respectExisting = options.respectExisting === true || fromBoot('respectExisting') === true;
|
|
49
|
+
var bootForced = fromBoot('forced');
|
|
50
|
+
var forcedMode = (respectExisting && (bootForced === 'light' || bootForced === 'dark')) ? bootForced : null;
|
|
51
|
+
var resolved = 'light';
|
|
52
|
+
var listeners = [];
|
|
53
|
+
var cleanups = [];
|
|
54
|
+
|
|
55
|
+
// Storage tokens meaning "follow the system". 'system' is a common spelling
|
|
56
|
+
// for the same concept; rejecting it used to send the app down a silent
|
|
57
|
+
// data-loss path \u2014 read 'system', fail to recognise it, fall back to
|
|
58
|
+
// 'auto', then OVERWRITE the stored value with 'auto' (#1788).
|
|
59
|
+
function normalizeMode(v) {
|
|
60
|
+
if (v === 'light' || v === 'dark') return v;
|
|
61
|
+
if (v === 'auto' || v === 'system') return 'auto';
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
var preference = normalizeMode(initialMode) || 'auto';
|
|
65
|
+
|
|
66
|
+
function getSystem() {
|
|
67
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
68
|
+
}
|
|
69
|
+
function resolve(pref) { return pref === 'auto' ? getSystem() : pref; }
|
|
70
|
+
// Used wherever the resolved mode is assigned, so a forced page survives
|
|
71
|
+
// a system-theme change and another tab's write, not just the first mount.
|
|
72
|
+
function effective(pref) { return forcedMode || resolve(pref); }
|
|
73
|
+
function applyDOM(mode) {
|
|
74
|
+
var el = document.documentElement;
|
|
75
|
+
if (disableTransitions) el.style.setProperty('transition', 'none', 'important');
|
|
76
|
+
// Both, when both are configured. The class drives the utility
|
|
77
|
+
// framework's dark: variants, the attribute drives everything else \u2014
|
|
78
|
+
// complements, not alternatives.
|
|
79
|
+
if (attribute) el.setAttribute(attribute, mode);
|
|
80
|
+
// Explicit add/remove, not toggle(cls, force) \u2014 very-happy-dom ignores
|
|
81
|
+
// the force argument and plain-toggles, inverting every light-mode test.
|
|
82
|
+
if (darkClass) { if (mode === 'dark') el.classList.add(darkClass); else el.classList.remove(darkClass); }
|
|
83
|
+
if (disableTransitions) { el.offsetHeight; el.style.removeProperty('transition'); }
|
|
84
|
+
}
|
|
85
|
+
function readRaw() {
|
|
86
|
+
try { return localStorage.getItem(storageKey); }
|
|
87
|
+
catch (e) { return null; }
|
|
88
|
+
}
|
|
89
|
+
// The spelling written back for 'auto': an explicit option wins, else
|
|
90
|
+
// whatever the app already stored, so its own pre-paint script keeps
|
|
91
|
+
// reading a value it recognises.
|
|
92
|
+
var storedRaw = readRaw();
|
|
93
|
+
var autoValue = autoValueOption !== undefined
|
|
94
|
+
? autoValueOption
|
|
95
|
+
: ((storedRaw === 'auto' || storedRaw === 'system') ? storedRaw : 'auto');
|
|
96
|
+
|
|
97
|
+
function persist(pref) {
|
|
98
|
+
try { localStorage.setItem(storageKey, pref === 'auto' ? autoValue : pref); }
|
|
99
|
+
catch (e) {} }
|
|
100
|
+
// persistChoice: only an explicit user choice is written back. Persisting
|
|
101
|
+
// on init would stamp the resolved default over a stored value this
|
|
102
|
+
// composable didn't recognise, destroying it.
|
|
103
|
+
// The boot script keeps the document in step for its whole life when it
|
|
104
|
+
// was configured with what this instance manages (see color-mode-boot.ts):
|
|
105
|
+
// then the system, the foreground and other tabs are its to follow, and
|
|
106
|
+
// this instance only mirrors what it announces. Following them here as
|
|
107
|
+
// well was what made the mode a component's: the listener left with the
|
|
108
|
+
// component, and with it the page's following of the system.
|
|
109
|
+
var bootSync = fromBoot('sync');
|
|
110
|
+
var bootWatches = typeof bootSync === 'function' && fromBoot('watching') === true
|
|
111
|
+
&& fromBoot('storageKey') === storageKey && fromBoot('darkClass') === darkClass && fromBoot('attribute') === attribute;
|
|
112
|
+
|
|
113
|
+
function update(pref, persistChoice) {
|
|
114
|
+
preference = normalizeMode(pref) || 'auto';
|
|
115
|
+
resolved = effective(preference);
|
|
116
|
+
applyDOM(resolved);
|
|
117
|
+
if (persistChoice !== false) persist(preference);
|
|
118
|
+
listeners.forEach(function(fn) { fn(resolved, preference); });
|
|
119
|
+
// A choice made here is announced to every other instance by the boot.
|
|
120
|
+
if (persistChoice !== false && bootWatches) bootSync();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
update(normalizeMode(storedRaw) || initialMode, false);
|
|
124
|
+
|
|
125
|
+
if (bootWatches) {
|
|
126
|
+
var onAnnounced = function(e) {
|
|
127
|
+
var detail = (e && e.detail) || {};
|
|
128
|
+
var pref = normalizeMode(detail.preference) || preference;
|
|
129
|
+
var mode = forcedMode || (detail.mode === 'dark' ? 'dark' : 'light');
|
|
130
|
+
if (pref === preference && mode === resolved) return;
|
|
131
|
+
preference = pref;
|
|
132
|
+
resolved = mode;
|
|
133
|
+
listeners.forEach(function(fn) { fn(resolved, preference); });
|
|
134
|
+
};
|
|
135
|
+
window.addEventListener('stx:color-mode', onAnnounced);
|
|
136
|
+
cleanups.push(function() { window.removeEventListener('stx:color-mode', onAnnounced); });
|
|
137
|
+
onDestroy(function() { cleanups.forEach(function(fn) { fn(); }); listeners = []; });
|
|
138
|
+
return colorModeHandle();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
142
|
+
var onSystemChange = function() {
|
|
143
|
+
if (preference === 'auto') {
|
|
144
|
+
resolved = forcedMode || getSystem();
|
|
145
|
+
applyDOM(resolved);
|
|
146
|
+
listeners.forEach(function(fn) { fn(resolved, preference); });
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
mql.addEventListener('change', onSystemChange);
|
|
150
|
+
cleanups.push(function() { mql.removeEventListener('change', onSystemChange); });
|
|
151
|
+
|
|
152
|
+
var onStorage = function(e) {
|
|
153
|
+
if (e.key !== storageKey) return;
|
|
154
|
+
var v = normalizeMode(e.newValue);
|
|
155
|
+
if (v) {
|
|
156
|
+
// Track the other tab's spelling too, so a write from here doesn't
|
|
157
|
+
// convert the key out from under it.
|
|
158
|
+
if (v === 'auto' && (e.newValue === 'auto' || e.newValue === 'system')) autoValue = e.newValue;
|
|
159
|
+
preference = v; resolved = effective(v); applyDOM(resolved);
|
|
160
|
+
listeners.forEach(function(fn) { fn(resolved, preference); });
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
window.addEventListener('storage', onStorage);
|
|
164
|
+
cleanups.push(function() { window.removeEventListener('storage', onStorage); });
|
|
165
|
+
|
|
166
|
+
onDestroy(function() { cleanups.forEach(function(fn) { fn(); }); listeners = []; });
|
|
167
|
+
|
|
168
|
+
return colorModeHandle();
|
|
169
|
+
|
|
170
|
+
function colorModeHandle() {
|
|
171
|
+
return {
|
|
172
|
+
get mode() { return resolved; },
|
|
173
|
+
get preference() { return preference; },
|
|
174
|
+
get isDark() { return resolved === 'dark'; },
|
|
175
|
+
set: function(mode) { update(mode); },
|
|
176
|
+
toggle: function() { update(resolved === 'dark' ? 'light' : 'dark'); },
|
|
177
|
+
subscribe: function(fn) {
|
|
178
|
+
listeners.push(fn);
|
|
179
|
+
return function() { listeners = listeners.filter(function(f) { return f !== fn; }); };
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function useDark(options) {
|
|
186
|
+
var cm = useColorMode(options);
|
|
187
|
+
var dark = state(cm.isDark);
|
|
188
|
+
var setSignal = dark.set;
|
|
189
|
+
cm.subscribe(function(mode) { setSignal(mode === 'dark'); });
|
|
190
|
+
dark.toggle = function() { cm.toggle(); };
|
|
191
|
+
dark.set = function(value) { cm.set(value ? 'dark' : 'light'); };
|
|
192
|
+
Object.defineProperty(dark, 'isDark', { get: function() { return dark(); } });
|
|
193
|
+
return dark;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function useMediaQuery(query) {
|
|
197
|
+
var mql = window.matchMedia(query);
|
|
198
|
+
var matches = state(mql.matches);
|
|
199
|
+
var onChange = function(event) { matches.set(event.matches); };
|
|
200
|
+
if (mql.addEventListener) mql.addEventListener('change', onChange);
|
|
201
|
+
else if (mql.addListener) mql.addListener(onChange);
|
|
202
|
+
onDestroy(function() {
|
|
203
|
+
if (mql.removeEventListener) mql.removeEventListener('change', onChange);
|
|
204
|
+
else if (mql.removeListener) mql.removeListener(onChange);
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(matches, 'matches', { get: function() { return matches(); } });
|
|
207
|
+
Object.defineProperty(matches, 'value', { get: function() { return matches(); } });
|
|
208
|
+
return matches;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 'visible' or 'hidden', kept current: whether the page is on screen (the
|
|
212
|
+
// app in the foreground, the tab in front). Built in rather than taken from
|
|
213
|
+
// @stacksjs/browser, whose bundle a page then carried in full (~180KB) for
|
|
214
|
+
// this one listener.
|
|
215
|
+
function useDocumentVisibility() {
|
|
216
|
+
var visibility = state(typeof document !== 'undefined' ? document.visibilityState : 'visible');
|
|
217
|
+
if (typeof document === 'undefined') return visibility;
|
|
218
|
+
var onChange = function() { visibility.set(document.visibilityState); };
|
|
219
|
+
document.addEventListener('visibilitychange', onChange);
|
|
220
|
+
onDestroy(function() { document.removeEventListener('visibilitychange', onChange); });
|
|
221
|
+
return visibility;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
var scrollLockStates = new WeakMap();
|
|
225
|
+
|
|
226
|
+
function resolveScrollLockTarget(target) {
|
|
227
|
+
var value = target;
|
|
228
|
+
if (typeof value === 'function') value = value();
|
|
229
|
+
if (value && typeof value === 'object' && 'current' in value) value = value.current;
|
|
230
|
+
if (value && typeof value === 'object' && !value.nodeType && 'value' in value) value = value.value;
|
|
231
|
+
return value || document.body || document.documentElement;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function acquireScrollLock(element) {
|
|
235
|
+
if (!element) return;
|
|
236
|
+
var existing = scrollLockStates.get(element);
|
|
237
|
+
if (existing) {
|
|
238
|
+
existing.count += 1;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
scrollLockStates.set(element, { count: 1, overflow: element.style.overflow });
|
|
242
|
+
element.style.overflow = 'hidden';
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function releaseScrollLock(element) {
|
|
246
|
+
if (!element) return;
|
|
247
|
+
var existing = scrollLockStates.get(element);
|
|
248
|
+
if (!existing) return;
|
|
249
|
+
existing.count -= 1;
|
|
250
|
+
if (existing.count > 0) return;
|
|
251
|
+
element.style.overflow = existing.overflow;
|
|
252
|
+
scrollLockStates.delete(element);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function useScrollLock(target) {
|
|
256
|
+
var locked = state(false);
|
|
257
|
+
var lockedElement = null;
|
|
258
|
+
var unsubscribe = locked.subscribe(function(value) {
|
|
259
|
+
if (value) {
|
|
260
|
+
if (lockedElement) return;
|
|
261
|
+
lockedElement = resolveScrollLockTarget(target);
|
|
262
|
+
acquireScrollLock(lockedElement);
|
|
263
|
+
}
|
|
264
|
+
else if (lockedElement) {
|
|
265
|
+
releaseScrollLock(lockedElement);
|
|
266
|
+
lockedElement = null;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
onDestroy(function() {
|
|
270
|
+
unsubscribe();
|
|
271
|
+
if (lockedElement) {
|
|
272
|
+
releaseScrollLock(lockedElement);
|
|
273
|
+
lockedElement = null;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
return locked;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function usePreferredDark() { return useMediaQuery('(prefers-color-scheme: dark)'); }
|
|
280
|
+
function usePreferredLight() { return useMediaQuery('(prefers-color-scheme: light)'); }
|
|
281
|
+
function usePreferredReducedMotion() { return useMediaQuery('(prefers-reduced-motion: reduce)'); }
|
|
282
|
+
function usePreferredContrast() { return useMediaQuery('(prefers-contrast: more)'); }
|
|
283
|
+
`;
|