@stacksjs/stx 0.2.629 → 0.2.632
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-05zhvg8t.js +20 -0
- package/dist/chunk-0c31twby.js +2 -0
- package/dist/{chunk-0s1hpqas.js → chunk-0jeqp6yz.js} +2 -2
- package/dist/chunk-0nvb2x2f.js +2 -0
- package/dist/chunk-0whv8hnp.js +4 -0
- package/dist/{chunk-q1983d5e.js → chunk-179c1rdn.js} +2 -2
- package/dist/chunk-1e25xd0z.js +6 -0
- package/dist/{chunk-jp6yn9mj.js → chunk-1ma56c2h.js} +2 -2
- package/dist/{chunk-3ap1vsh3.js → chunk-27h1xs4k.js} +12 -12
- package/dist/{chunk-5m0r0j79.js → chunk-2vqz7v37.js} +3 -3
- package/dist/{chunk-10s16tad.js → chunk-2wvz3fd2.js} +2 -2
- package/dist/chunk-3jda301z.js +2 -0
- package/dist/{chunk-gc1dzxee.js → chunk-3p2b88pd.js} +2 -2
- package/dist/chunk-46qg1tqe.js +2 -0
- package/dist/{chunk-66e4ga0z.js → chunk-4fv3jq16.js} +2 -2
- package/dist/{chunk-k1k2t4ez.js → chunk-4y06ekvt.js} +1 -1
- package/dist/chunk-5fjb6avv.js +2 -0
- package/dist/chunk-5kprybdd.js +2 -0
- package/dist/{chunk-n5xbv1a9.js → chunk-62kxavc5.js} +3 -3
- package/dist/{chunk-rdm35qqn.js → chunk-6684b8ym.js} +11 -11
- package/dist/{chunk-6kd84jx3.js → chunk-6mtth8d1.js} +3 -3
- package/dist/chunk-6n6nnt33.js +2 -0
- package/dist/chunk-6per0k6j.js +2 -0
- package/dist/{chunk-aktzv0x2.js → chunk-70npkeh2.js} +2 -2
- package/dist/{chunk-4tyj5vpw.js → chunk-776f05vk.js} +4 -4
- package/dist/{chunk-szjgbjw1.js → chunk-7a8jkwah.js} +2 -2
- package/dist/{chunk-wbhzt74k.js → chunk-7cw0wkbx.js} +1 -1
- package/dist/chunk-7f1dw9r4.js +2 -0
- package/dist/{chunk-khzyc41k.js → chunk-7ky2ny63.js} +13 -13
- package/dist/{chunk-h431swg6.js → chunk-7mpv1a02.js} +9 -9
- package/dist/chunk-7zjv015g.js +2 -0
- package/dist/{chunk-q35z0cyg.js → chunk-85bbtv3m.js} +1 -1
- package/dist/{chunk-qb7a4am2.js → chunk-85g35me6.js} +2 -2
- package/dist/chunk-87nt0kty.js +2 -0
- package/dist/{chunk-3dth76ce.js → chunk-88d5s6v3.js} +3 -3
- package/dist/chunk-8a3sdg2y.js +2 -0
- package/dist/chunk-8e9hd2jq.js +4 -0
- package/dist/{chunk-0c7ss25y.js → chunk-8gksvwsm.js} +3 -3
- package/dist/chunk-8vbfbtke.js +2 -0
- package/dist/chunk-91ranpvz.js +2 -0
- package/dist/chunk-96ypgjm4.js +2 -0
- package/dist/{chunk-1gtrs8va.js → chunk-9b4e815s.js} +8 -8
- package/dist/chunk-9cg6q8mw.js +2 -0
- package/dist/{chunk-gd7vq083.js → chunk-a2ztn8cr.js} +1 -1
- package/dist/chunk-ag4eck6d.js +2 -0
- package/dist/chunk-aq02drjz.js +2 -0
- package/dist/{chunk-jsw5yby0.js → chunk-aqra0qcg.js} +3 -3
- package/dist/{chunk-xheh68kv.js → chunk-av9zf0zb.js} +5 -5
- package/dist/chunk-ayt4qd82.js +2 -0
- package/dist/{chunk-m735gtc4.js → chunk-az1y9jks.js} +2 -2
- package/dist/chunk-b3mazye4.js +2 -0
- package/dist/chunk-b5cv9xp7.js +2852 -0
- package/dist/{chunk-dayjd2sj.js → chunk-b7p3yca7.js} +4 -4
- package/dist/chunk-bn6sarwd.js +2 -0
- package/dist/chunk-c7xt5gyb.js +2 -0
- package/dist/chunk-cac98pkx.js +2 -0
- package/dist/{chunk-6j4f8dwx.js → chunk-cbj2hmx5.js} +5 -5
- package/dist/chunk-czg6ewy3.js +2 -0
- package/dist/{chunk-sxpnpvt5.js → chunk-d1ya7f79.js} +4 -4
- package/dist/chunk-dcwmcqbr.js +2 -0
- package/dist/{chunk-19bhnbyn.js → chunk-dz4hrgw8.js} +83 -64
- package/dist/chunk-ed1qn902.js +2 -0
- package/dist/chunk-ev479f3z.js +2 -0
- package/dist/{chunk-x6pz1h3x.js → chunk-evs5gb3q.js} +10 -10
- package/dist/{chunk-crws777p.js → chunk-fskpdva4.js} +46 -46
- package/dist/{chunk-5rtatjwq.js → chunk-gh34r6qb.js} +2 -2
- package/dist/chunk-gmg6aj7y.js +2 -0
- package/dist/{chunk-fhxfh4nf.js → chunk-h4ashx84.js} +1 -1
- package/dist/chunk-hc1m2psz.js +3 -0
- package/dist/{chunk-4hmdcmw1.js → chunk-hfe8g644.js} +6 -6
- package/dist/chunk-htaed68z.js +2 -0
- package/dist/{chunk-g8gzxhp8.js → chunk-j1rnhv0w.js} +3 -3
- package/dist/chunk-j2jm2nqz.js +2 -0
- package/dist/chunk-jb8d4n60.js +2 -0
- package/dist/{chunk-mktk70gq.js → chunk-k2nrx78c.js} +2 -2
- package/dist/chunk-kdnbxwkb.js +2 -0
- package/dist/{chunk-8zqgb3q9.js → chunk-kf2vas4j.js} +5 -5
- package/dist/chunk-kt5mzw2w.js +2 -0
- package/dist/chunk-kt994306.js +2 -0
- package/dist/{chunk-6qvskcwp.js → chunk-mer3aea0.js} +4 -4
- package/dist/chunk-mezphhpa.js +2 -0
- package/dist/{chunk-5wrmcbch.js → chunk-myhxapnn.js} +2 -2
- package/dist/chunk-n7d69a2q.js +2 -0
- package/dist/{chunk-z4te6223.js → chunk-nz6bzffm.js} +4 -4
- package/dist/{chunk-ksn8mf12.js → chunk-pfas39mf.js} +9 -9
- package/dist/{chunk-j18z5nxq.js → chunk-phbnrw2h.js} +2 -2
- package/dist/{chunk-9g5sv1p6.js → chunk-q2p6y0cn.js} +7 -7
- package/dist/{chunk-jm478rek.js → chunk-qfppetcn.js} +1 -1
- package/dist/{chunk-wsbccxwy.js → chunk-qpbd2fwp.js} +9 -9
- package/dist/{chunk-qx2ra6fk.js → chunk-qvqgbvfa.js} +6 -6
- package/dist/chunk-qz3tnvwm.js +2 -0
- package/dist/{chunk-dvbgbd06.js → chunk-rns21kkv.js} +2 -2
- package/dist/{chunk-08jyyegp.js → chunk-rq9cbw2y.js} +1 -1
- package/dist/{chunk-q7wj2ypd.js → chunk-s0ar60ng.js} +6 -6
- package/dist/chunk-sddytf9n.js +2 -0
- package/dist/chunk-spvr2vvh.js +2 -0
- package/dist/{chunk-0z189871.js → chunk-t84ww3qb.js} +2 -2
- package/dist/chunk-t91250ag.js +2 -0
- package/dist/{chunk-n8595zaf.js → chunk-tmbqz710.js} +1 -1
- package/dist/{chunk-hjp38m0w.js → chunk-tme29zh9.js} +2 -2
- package/dist/chunk-txkc9w9q.js +2 -0
- package/dist/chunk-ty1c2276.js +2 -0
- package/dist/{chunk-det49x62.js → chunk-v5500ews.js} +2 -2
- package/dist/chunk-vepjs3tg.js +2 -0
- package/dist/{chunk-v3anfm9d.js → chunk-vfbdxxbf.js} +2 -2
- package/dist/{chunk-7mehf3h5.js → chunk-w9c7z8p3.js} +2 -2
- package/dist/chunk-wfp754ya.js +2 -0
- package/dist/chunk-wp3qcfb4.js +3 -0
- package/dist/{chunk-qxtgxcm8.js → chunk-x17fpc0x.js} +6 -6
- package/dist/chunk-x3sbsxdq.js +2 -0
- package/dist/chunk-xdcvp8tt.js +2 -0
- package/dist/{chunk-ebkjpj5m.js → chunk-xh98er3b.js} +2 -2
- package/dist/{chunk-9z9f3d6b.js → chunk-xrj3tekf.js} +2 -2
- package/dist/chunk-xxnh7gv8.js +2 -0
- package/dist/{chunk-tchpwc6h.js → chunk-y2t8xd39.js} +2 -2
- package/dist/chunk-y4egzqqf.js +2 -0
- package/dist/chunk-y4nm9wq4.js +2 -0
- package/dist/{chunk-ygkwp4sf.js → chunk-y5hdc1sb.js} +2 -2
- package/dist/chunk-ygx0akfn.js +2 -0
- package/dist/chunk-yn9fwnq2.js +2 -0
- package/dist/{chunk-nhmqd1g9.js → chunk-yq9rfnd6.js} +1 -1
- package/dist/chunk-z0gfb7b4.js +2 -0
- package/dist/chunk-z3e54btj.js +2 -0
- package/dist/{chunk-773vgw1k.js → chunk-z6fb4m1j.js} +3 -3
- package/dist/cli.js +21 -21
- package/dist/client/signals-class-runtime.js +1 -1
- package/dist/client/signals-component-hydration-runtime.js +1 -1
- package/dist/client/signals-component-props-runtime.js +3 -3
- package/dist/client/signals-container-cleanup-runtime.js +1 -1
- package/dist/client/signals-dom-ready-runtime.js +4 -4
- package/dist/client/signals-event-shorthand-runtime.js +2 -2
- package/dist/client/signals-expression-runtime.js +21 -2
- package/dist/client/signals-for-runtime.js +6 -6
- package/dist/client/signals-handler-runtime.js +1 -1
- package/dist/client/signals-hydration-audit-runtime.js +1 -1
- package/dist/client/signals-hydration-runtime.js +1 -1
- package/dist/client/signals-if-chain-runtime.js +3 -3
- package/dist/client/signals-if-runtime.js +7 -7
- package/dist/client/signals-lazy-hydration-runtime.js +1 -1
- package/dist/client/signals-manifest-hydration-runtime.js +1 -1
- package/dist/client/signals-model-runtime.js +1 -1
- package/dist/client/signals-mount-runtime.js +3 -3
- package/dist/client/signals-process-element-runtime.js +7 -7
- package/dist/client/signals-show-runtime.js +1 -1
- package/dist/client/signals-spa-load-runtime.js +5 -5
- package/dist/client/signals-style-runtime.js +1 -1
- package/dist/client-scope-bindings.d.ts +6 -0
- package/dist/client-scope-bindings.js +98 -0
- package/dist/client-script-bundler.js +9 -3
- package/dist/client-script.js +2 -1
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/includes.js +4 -2
- package/dist/native/components/primitives.d.ts +1 -0
- package/dist/pwa.js +3 -3
- package/dist/signal-processing.d.ts +2 -6
- package/dist/signal-processing.js +4 -80
- package/dist/ssg.js +10 -10
- package/dist/stx-virtual-ts.js +4 -2
- package/dist/utils.js +5 -3
- package/package.json +5 -5
- package/dist/chunk-0fcxfd5f.js +0 -2
- package/dist/chunk-0fgp13q4.js +0 -2
- package/dist/chunk-2340emvg.js +0 -2
- package/dist/chunk-317xf7hx.js +0 -2
- package/dist/chunk-4kyrzkvg.js +0 -2
- package/dist/chunk-5q7gcr0f.js +0 -2
- package/dist/chunk-5s91drvs.js +0 -2
- package/dist/chunk-6377p5ry.js +0 -2
- package/dist/chunk-7h4mxhkh.js +0 -2
- package/dist/chunk-7zdefvrn.js +0 -2
- package/dist/chunk-8898f767.js +0 -2
- package/dist/chunk-8jgrakqd.js +0 -2850
- package/dist/chunk-9j2tpg46.js +0 -2
- package/dist/chunk-9wbraw07.js +0 -2
- package/dist/chunk-b7fgatb5.js +0 -3
- package/dist/chunk-c0yb755y.js +0 -2
- package/dist/chunk-chaee0vj.js +0 -2
- package/dist/chunk-dn050jj1.js +0 -2
- package/dist/chunk-dyp3vncz.js +0 -2
- package/dist/chunk-e876sg0j.js +0 -2
- package/dist/chunk-ekfmad19.js +0 -2
- package/dist/chunk-fnzv245x.js +0 -2
- package/dist/chunk-g9sv00hm.js +0 -15
- package/dist/chunk-hjkm6k8c.js +0 -2
- package/dist/chunk-hpvkkke2.js +0 -2
- package/dist/chunk-hsmaakds.js +0 -2
- package/dist/chunk-k1vjhhd4.js +0 -2
- package/dist/chunk-kp4j8vja.js +0 -2
- package/dist/chunk-mb8c650x.js +0 -2
- package/dist/chunk-pbk2kwec.js +0 -2
- package/dist/chunk-ppaj0hef.js +0 -2
- package/dist/chunk-pz5zh3tg.js +0 -2
- package/dist/chunk-q068mc46.js +0 -2
- package/dist/chunk-q4a2j4qr.js +0 -3
- package/dist/chunk-q9dh9dte.js +0 -2
- package/dist/chunk-qnjhh828.js +0 -2
- package/dist/chunk-qz7fyxwp.js +0 -2
- package/dist/chunk-rj0nyb2t.js +0 -2
- package/dist/chunk-s63fkwzc.js +0 -2
- package/dist/chunk-sgn1h15s.js +0 -2
- package/dist/chunk-smpyb21z.js +0 -2
- package/dist/chunk-snd65r8z.js +0 -2
- package/dist/chunk-sp94c1vv.js +0 -2
- package/dist/chunk-swv69q75.js +0 -4
- package/dist/chunk-th9wcse5.js +0 -2
- package/dist/chunk-v1ck0wd3.js +0 -2
- package/dist/chunk-vhak3tvx.js +0 -2
- package/dist/chunk-w24zd7sj.js +0 -2
- package/dist/chunk-wda1fsbk.js +0 -2
- package/dist/chunk-wfettff6.js +0 -2
- package/dist/chunk-wq97shs3.js +0 -2
- package/dist/chunk-xfvbm4pn.js +0 -2
- package/dist/chunk-xg1jtz8h.js +0 -2
- package/dist/chunk-xppat53n.js +0 -2
- package/dist/chunk-xxv8rfxs.js +0 -2
- package/dist/chunk-y17jdnrm.js +0 -4
- package/dist/chunk-yceb9scc.js +0 -2
- package/dist/chunk-z04480ar.js +0 -2
- package/dist/chunk-z4xqznsb.js +0 -2
- package/dist/chunk-zedvwcta.js +0 -6
package/dist/includes.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { extractExports as scopeExports, scopePropertyDescriptor } from "./client-scope-bindings.js";
|
|
1
2
|
import { StxValidationError } from "./errors/types.js";
|
|
2
3
|
import { validateClientScript } from "./script-validation.js";
|
|
3
4
|
import { findSfcTemplateBlock } from "./sfc-template.js";
|
|
@@ -198,7 +199,7 @@ ${tail}})();
|
|
|
198
199
|
`;
|
|
199
200
|
}
|
|
200
201
|
function buildScopeRegistrationTail(scriptContent, scopeId) {
|
|
201
|
-
const
|
|
202
|
+
const exportNames = extractExports(scriptContent).split(",").map((s) => s.trim()).filter(Boolean), mutable = new Set(scopeExports(scriptContent, !0).split(",").map((name) => name.trim())), scopeAssign = exportNames.map((name) => mutable.has(name) ? ` try { ${name}; Object.defineProperty(__scopeRegistration, ${JSON.stringify(name)}, ${scopePropertyDescriptor(name)}); } catch (e) { /* not actually top-level */ }` : ` try { __scopeRegistration[${JSON.stringify(name)}] = ${name}; } catch (e) { /* not actually top-level */ }`).join(`
|
|
202
203
|
`);
|
|
203
204
|
return `
|
|
204
205
|
// Register scope variables for STX runtime
|
|
@@ -210,6 +211,7 @@ ${scopeAssign}
|
|
|
210
211
|
// renamed declaration so it resolves to the component's value, not the
|
|
211
212
|
// shadowing import. __stxScopeRenames is emitted by bundleClientScript.
|
|
212
213
|
try { if (typeof __stxScopeRenames !== 'undefined' && __stxScopeRenames) { for (var __stxRK in __stxScopeRenames) __scopeRegistration[__stxRK] = __stxScopeRenames[__stxRK]; } } catch (e) { /* no renames */ }
|
|
214
|
+
if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeRegistration, Object.getOwnPropertyDescriptors(__stxLiveBindings));
|
|
213
215
|
window.stx._scopes['${scopeId}'] = __scopeRegistration;
|
|
214
216
|
`;
|
|
215
217
|
}
|
|
@@ -728,7 +730,7 @@ ${scriptContent}`;
|
|
|
728
730
|
const extraAttrs = scriptAttrs.replace(/\bclient\b/i, "").trim();
|
|
729
731
|
signalScopeId = includeScopeId(includeFilePath, context);
|
|
730
732
|
const resolvedContent = transformStoreImports(scriptContent), wrapped = transformScopedScript(resolvedContent, signalScopeId);
|
|
731
|
-
if (/__scopeRegistration\["(?!__stx)[^"]+"\]\s
|
|
733
|
+
if (/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(wrapped))
|
|
732
734
|
registersBindings = !0;
|
|
733
735
|
preservedScript += `${vendorStyleTags}<script data-stx-scoped data-stx-run="always" data-stx-owner="${signalScopeId}"${extraAttrs ? ` ${extraAttrs}` : ""}>${wrapped}</script>
|
|
734
736
|
`;
|
|
@@ -313,6 +313,7 @@ export declare interface MapMarkerOverlay {
|
|
|
313
313
|
export declare interface MapProps extends BaseProps {
|
|
314
314
|
region?: MapRegion
|
|
315
315
|
initialRegion?: MapRegion
|
|
316
|
+
basemap?: 'standard' | 'outdoors' | 'satellite' | 'hybrid'
|
|
316
317
|
tileOverlay?: MapTileOverlay
|
|
317
318
|
edgePadding?: MapEdgePadding
|
|
318
319
|
fitToBounds?: boolean
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-
|
|
2
|
+
import{rr,We,ai,gc}from"./chunk-b7p3yca7.js";import{nr,ls,dc,pc,fc}from"./chunk-q2p6y0cn.js";import{si,oi,ii,lc,uc}from"./chunk-vfbdxxbf.js";import{de,Et,us}from"./chunk-j1rnhv0w.js";import{ml,hl,yl,bl,Nr,jd}from"./chunk-y5hdc1sb.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-wfp754ya.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
|
|
|
233
233
|
}, 5000);
|
|
234
234
|
</script>
|
|
235
235
|
</body>
|
|
236
|
-
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=
|
|
236
|
+
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=de(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=rr(n,t);if(a){let s=We(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return ls(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,oi as auditBuildOutput,si as auditConfig,re as buildPwaAssets,ii as calculateAuditResult,uc as formatAuditResult,us as formatSize,j as generateManifest,_ as generateManifestJson,pc as generateManifestLink,F as generateOfflinePage,de as generatePrecacheManifest,Et as generatePrecacheManifestJs,M as generatePwaIcons,nr as generatePwaTags,rr as generateServiceWorker,gc as generateServiceWorkerAuto,dc as generateSwRegistrationScript,fc as generateThemeColorMeta,N as getExpectedIconPaths,We as getServiceWorkerFileName,ls as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,ai as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Nr as pwaDirectives,ml as pwaInstallDirective,yl as pwaOfflineDirective,bl as pwaPushDirective,hl as pwaUpdateDirective,jd as registerPwaDirectives,lc as runPwaAudit,D as validateManifest};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { extractExports } from './client-scope-bindings';
|
|
1
2
|
import type { StxOptions } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Drop cached script scans.
|
|
@@ -131,12 +132,6 @@ export declare function preEvalLiteralReactiveIfs(template: string): string;
|
|
|
131
132
|
export declare function convertServerLoopAttributesToDirectives(template: string, context?: Record<string, any>): string;
|
|
132
133
|
export declare function convertSignalLoopsToAttributes(template: string, context?: Record<string, any>): string;
|
|
133
134
|
export declare function processScriptSetup(template: string, filePath?: string, serverData?: Record<string, unknown>, options?: { forceClientSetup?: boolean }): Promise<{ output: string, setupCode: string | null }>;
|
|
134
|
-
/**
|
|
135
|
-
* Extract exported variable names from setup script.
|
|
136
|
-
* Returns variables that should be exposed to the template.
|
|
137
|
-
* Only extracts TOP-LEVEL declarations, not variables inside nested functions.
|
|
138
|
-
*/
|
|
139
|
-
export declare function extractExports(setupContent: string): string;
|
|
140
135
|
/**
|
|
141
136
|
* Main orchestrator for signal processing.
|
|
142
137
|
*
|
|
@@ -224,3 +219,4 @@ export declare interface ParsedLoopExpression {
|
|
|
224
219
|
itemVar: string | null
|
|
225
220
|
indexVar: string | null
|
|
226
221
|
}
|
|
222
|
+
export { extractExports } from './client-scope-bindings';
|
|
@@ -9,6 +9,8 @@ import { evictOldest, matchScriptElement, scanAtElementPosition } from "./html-m
|
|
|
9
9
|
import { importOnce } from "./lazy-module.js";
|
|
10
10
|
import { findBodyOpenTag } from "./find-body-tag.js";
|
|
11
11
|
import { stripCommentsAndLiterals } from "./strip-literals.js";
|
|
12
|
+
import { extractExports, scopeObject } from "./client-scope-bindings.js";
|
|
13
|
+
export { extractExports } from "./client-scope-bindings.js";
|
|
12
14
|
let signalSetupCounter = 0;
|
|
13
15
|
const TAG_ATTR_RUN = `(?:"[^"]*"|'[^']*'|[^>"'])*`, SINGLE_ELEMENT_RE = /^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s, SCRIPT_SCAN_CACHE_MIN_BYTES = 65536, SCRIPT_SCAN_CACHE_MAX_ENTRIES = 4, scriptScanCache = new Map;
|
|
14
16
|
export function clearScriptScanCache() {
|
|
@@ -849,96 +851,18 @@ ${resolved}`);
|
|
|
849
851
|
|
|
850
852
|
`);
|
|
851
853
|
mergedContent = dedupeTopLevelDeclarations(mergedContent);
|
|
852
|
-
const
|
|
854
|
+
const mergedExportNames = extractExports(mergedContent).split(",").map((name) => name.trim()).filter(Boolean), bridge = generateServerDataBridge(mergedContent, serverData), setupCode = `
|
|
853
855
|
<script data-stx-scoped>
|
|
854
856
|
function ${setupFnName}() {
|
|
855
857
|
${buildRuntimeGlobalsDestructure("const", mergedExportNames)}
|
|
856
858
|
${escapeScriptBody(`${bridge}${mergedContent}`)}
|
|
857
|
-
return
|
|
859
|
+
return ${scopeObject(mergedContent, mergedExportNames)};
|
|
858
860
|
}
|
|
859
861
|
window.__stx_latestSetup=${setupFnName};
|
|
860
862
|
if(window.stx)window.stx._latestSetup=${setupFnName};
|
|
861
863
|
</script>`, markerAt = findSetupMarkerInsertion(template, signalScripts);
|
|
862
864
|
return { output: rebuildSetupOwner(template, signalScripts, markerAt, setupFnName), setupCode };
|
|
863
865
|
}
|
|
864
|
-
export function extractExports(setupContent) {
|
|
865
|
-
const code = stripCommentsAndLiterals(setupContent), names = [], seen = new Set;
|
|
866
|
-
let depth = 0, i = 0;
|
|
867
|
-
const len = code.length, checkDeclaration = () => {
|
|
868
|
-
if (depth !== 0)
|
|
869
|
-
return;
|
|
870
|
-
const declMatch = code.slice(i).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);
|
|
871
|
-
if (declMatch) {
|
|
872
|
-
const varName = declMatch[2];
|
|
873
|
-
if (!seen.has(varName)) {
|
|
874
|
-
names.push(varName);
|
|
875
|
-
seen.add(varName);
|
|
876
|
-
}
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
const destructMatch = code.slice(i).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);
|
|
880
|
-
if (destructMatch) {
|
|
881
|
-
destructMatch[1].split(",").forEach((s) => {
|
|
882
|
-
const trimmed = s.trim();
|
|
883
|
-
if (!trimmed)
|
|
884
|
-
return;
|
|
885
|
-
const colonIdx = trimmed.indexOf(":"), name = (colonIdx >= 0 ? trimmed.slice(colonIdx + 1).trim() : trimmed).split(/[\s=]/)[0];
|
|
886
|
-
if (name && !seen.has(name)) {
|
|
887
|
-
names.push(name);
|
|
888
|
-
seen.add(name);
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
|
-
return;
|
|
892
|
-
}
|
|
893
|
-
const arrayDestructMatch = code.slice(i).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);
|
|
894
|
-
if (arrayDestructMatch) {
|
|
895
|
-
arrayDestructMatch[1].split(",").forEach((s) => {
|
|
896
|
-
const trimmed = s.trim().replace(/^\.\.\./, "");
|
|
897
|
-
if (!trimmed)
|
|
898
|
-
return;
|
|
899
|
-
const name = trimmed.split(/[\s=]/)[0];
|
|
900
|
-
if (name && !seen.has(name)) {
|
|
901
|
-
names.push(name);
|
|
902
|
-
seen.add(name);
|
|
903
|
-
}
|
|
904
|
-
});
|
|
905
|
-
return;
|
|
906
|
-
}
|
|
907
|
-
const funcMatch = code.slice(i).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);
|
|
908
|
-
if (funcMatch) {
|
|
909
|
-
const funcName = funcMatch[1];
|
|
910
|
-
if (!seen.has(funcName)) {
|
|
911
|
-
names.push(funcName);
|
|
912
|
-
seen.add(funcName);
|
|
913
|
-
}
|
|
914
|
-
return;
|
|
915
|
-
}
|
|
916
|
-
const asyncMatch = code.slice(i).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);
|
|
917
|
-
if (asyncMatch) {
|
|
918
|
-
const funcName = asyncMatch[1];
|
|
919
|
-
if (!seen.has(funcName)) {
|
|
920
|
-
names.push(funcName);
|
|
921
|
-
seen.add(funcName);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
while (i < len) {
|
|
926
|
-
if (code[i] === "{") {
|
|
927
|
-
depth++;
|
|
928
|
-
i++;
|
|
929
|
-
continue;
|
|
930
|
-
}
|
|
931
|
-
if (code[i] === "}") {
|
|
932
|
-
depth--;
|
|
933
|
-
i++;
|
|
934
|
-
continue;
|
|
935
|
-
}
|
|
936
|
-
if (depth === 0 && /[a-z]/i.test(code[i]) && (i === 0 || /\s|[;{}()]/.test(code[i - 1])))
|
|
937
|
-
checkDeclaration();
|
|
938
|
-
i++;
|
|
939
|
-
}
|
|
940
|
-
return names.join(", ");
|
|
941
|
-
}
|
|
942
866
|
export async function processSignals(template, options, filePath, serverData) {
|
|
943
867
|
if (!hasSignalsSyntax(template, filePath))
|
|
944
868
|
return template;
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-gh34r6qb.js";import"./chunk-9b4e815s.js";import"./chunk-2wvz3fd2.js";import{pt,ft,gt,mt,ht,yt}from"./chunk-d1ya7f79.js";import"./chunk-rns21kkv.js";import"./chunk-4fv3jq16.js";import{f,Je,j,Q,n,o}from"./chunk-b5cv9xp7.js";import"./chunk-evs5gb3q.js";import{Sr}from"./chunk-7ky2ny63.js";import"./chunk-3p2b88pd.js";import"./chunk-70npkeh2.js";import"./chunk-1ma56c2h.js";import"./chunk-nz6bzffm.js";import"./chunk-1e25xd0z.js";import{pe,Tt,$t}from"./chunk-05zhvg8t.js";import{ti,ni,ri}from"./chunk-z6fb4m1j.js";import{Ct,gn,mn}from"./chunk-tme29zh9.js";import"./chunk-62kxavc5.js";import{a}from"./chunk-wp3qcfb4.js";import x from"fs";import g from"path";import{createHash as bt}from"crypto";function Pt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Dt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Rt(t){return Bun.hash(t).toString(16)}function it(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(Dt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Pt(h);let S=Rt(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${bt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var kt=new Set(["visible","idle"]);function st(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(kt.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var Et=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function It(t){for(let i of Et){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function at(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function Bt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=at(e.default??e);if(l)return l}catch{}}return null}async function ot(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=at(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await Bt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=It(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ct(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
3
|
`)}class lt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class ut{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function jt(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${c[1]}
|
|
@@ -8,10 +8,10 @@ import"./chunk-5rtatjwq.js";import"./chunk-1gtrs8va.js";import"./chunk-10s16tad.
|
|
|
8
8
|
return (async function getStaticProps() {
|
|
9
9
|
${e[1]}
|
|
10
10
|
})()
|
|
11
|
-
`)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function
|
|
12
|
-
resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(Lt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let p=await n(e,y,t.filePath,D,h);for(let b of[t.filePath,...h])for(let B of
|
|
11
|
+
`)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function Lt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function dt(t,i,s={},r,c){let e=await Bun.file(t.filePath).text(),l=await Ot(t.filePath),w=await At(e,i,t.filePath),y={...l||{},...w||{},...s,params:i,$route:{path:t.pattern,params:i}},h=new Set,S=[],P=[],D={...c,...r.partialsDir?{partialsDir:r.partialsDir}:{},...r.componentsDir?{componentsDir:r.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(b)=>{S.push(`${g.relative(process.cwd(),b.templatePath)}: ${b.message}
|
|
12
|
+
resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(Lt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let p=await n(e,y,t.filePath,D,h);for(let b of[t.filePath,...h])for(let B of pe(b))h.add(B);if(Object.keys(i).length>0){let b=`<script>if(window.stx)window.stx._rp=${JSON.stringify(i)};else window.__stx_rp=${JSON.stringify(i)};</script>`;if(p.includes("</head>"))p=p.replace("</head>",`${b}
|
|
13
13
|
</head>`);else p=`${b}
|
|
14
|
-
${p}`}if(p=await
|
|
14
|
+
${p}`}if(p=await Q(p,{router:r.router}),p=await f(p),r.minify!==!1)return{html:Mt(p),dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P};return{html:p,dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P}}function Mt(t){let i=[],s=0,r=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=r.exec(t))!==null){let l=t.slice(s,c.index);i.push(l.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let w=c[1],y=c[2],h=c[3];y=y.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),i.push(w+y+h),s=c.index+c[0].length}let e=t.slice(s);return i.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),i.join("").trim()}function Ut(t){let i=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);i=(i<<5)-i+r,i=i&i}return`"${Math.abs(i).toString(36)}"`}function _t(t,i,s,r){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(i))return!0;return r.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function Gt(t,i){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
15
15
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
16
16
|
${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
17
17
|
<loc>${I(c)}</loc>`;if(r.lastmod)e+=`
|
|
@@ -41,16 +41,16 @@ ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
|
41
41
|
${s.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function zt(t={}){let i=Date.now()
|
|
44
|
+
</rss>`}async function zt(t={}){let i=Date.now();$t();let s=await o(process.cwd()),r=s.build||{},c=await ot({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ct());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-t91250ag.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-aq02drjz.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new lt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-t91250ag.js");await u('<div class="bg-black"></div>')}catch{}pt();let wt=s?.routeMiddleware?.dir||"middleware";await gt(process.cwd(),wt);let H=ft();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let St=s?.routeMiddleware?.global||[];ri(s?.layoutsDir,a(process.cwd()));let V=j(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${V.length} routes`);let G=[];for(let u of V){let m=await Ft(u);for(let v of m)G.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=G.length,console.log(`Generating ${l.totalPages} pages...`);let L=[],K=[];for(let u=0;u<G.length;u+=e.concurrency)K.push(G.slice(u,u+e.concurrency));for(let u of K)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:M,props:xt,revalidate:Z}=m;try{await e.hooks.onPageStart?.(d);let F=await Bun.file(v.filePath).text(),O=Jt(F),vt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],tt=[...St,...vt];if(tt.length>0){let C=mt(d,M,O||{}),T=ht(C,null,void 0,{isServer:!0}),E=await yt(tt,T);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),A=Kt(d,e);await x.promises.mkdir(g.dirname(A),{recursive:!0}),await Bun.write(A,_),l.successCount++,l.pages.push({route:d,outputPath:A,size:Buffer.byteLength(_),cached:!1}),L.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=F.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${et[1]};
|
|
46
46
|
return validate(route);
|
|
47
|
-
`)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,rt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)rt=!0,l.cachedCount++}if(!k){let C=await
|
|
47
|
+
`)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,rt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)rt=!0,l.cachedCount++}if(!k){let C=await dt(v,M,xt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
|
48
48
|
${C.includeFailures.join(`
|
|
49
49
|
`)}
|
|
50
50
|
Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&C.serverScriptFailures.length>0)throw Error(`${C.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
|
|
51
51
|
${C.serverScriptFailures.join(`
|
|
52
52
|
`)}
|
|
53
|
-
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let U;if(e.trailingSlash)U=g.join(e.outputDir,d,"index.html");else U=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:
|
|
53
|
+
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let U;if(e.trailingSlash)U=g.join(e.outputDir,d,"index.html");else U=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:T}=it(k,{integrity:e.integrityIslands,minify:e.minify});if(T.length>0){let E=g.join(e.outputDir,"_stx","islands");await x.promises.mkdir(E,{recursive:!0});for(let R of T){let _=g.join(E,`${R.hash}.js`);if(!await Bun.file(_).exists())await Bun.write(_,R.code);if(!w.has(R.hash)){w.add(R.hash);let A=Buffer.byteLength(R.code,"utf8");y+=A,h[R.hash]={bytes:A,file:`/_stx/islands/${R.hash}.js`}}}if(S[d]=T.map((R)=>R.hash),k=C,e.prefetchIslands)k=st(k)}}if(await x.promises.mkdir(g.dirname(U),{recursive:!0}),await Bun.write(U,k),!_t(d,k,O,e.sitemapExclude))L.push({loc:d,lastmod:new Date().toISOString().split("T")[0],priority:d==="/"?1:0.8});let nt={route:d,outputPath:U,size:Buffer.byteLength(k,"utf8"),cached:rt};if(Z!==!1)nt.revalidateAt=Date.now()+Z*1000;l.pages.push(nt),l.successCount++,await e.hooks.onPageEnd?.(d,k)}catch(F){l.failedCount++,l.errors.push({route:d,error:F}),await e.hooks.onError?.(F,d),console.error(`Error generating ${d}:`,F)}}));let X=Tt();if(X.length>0){let u=X.map((m)=>`${m.filePath}: ${m.message}`).join(`
|
|
54
54
|
`);throw Error(`Client script bundling failed:
|
|
55
55
|
${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.stx");if(await Bun.file(u).exists()){let m=new Set,v={...s,debug:!1,cache:!1},d=await n(await Bun.file(u).text(),{},u,v,m);await Bun.write(g.join(e.outputDir,"404.html"),d)}else await Bun.write(g.join(e.outputDir,"404.html"),`<!DOCTYPE html>
|
|
56
56
|
<html lang="en">
|
|
@@ -73,7 +73,7 @@ ${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.
|
|
|
73
73
|
<a href="/">Go home</a>
|
|
74
74
|
</div>
|
|
75
75
|
</body>
|
|
76
|
-
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&
|
|
76
|
+
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&L.length>0){let u=Gt(L,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${L.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=Sr({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let N=ti(e.outputDir);if(N.assets>0)console.log(`Externalized ${N.assets} asset(s) from ${N.pages} page(s) (${(N.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let z=ni(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} repeated asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&x.existsSync(e.publicDir))await J(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Y=mn();if(Y)await J(Y,g.join(e.outputDir,gn)),console.log(`Copied assets from ${Ct}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-i,w.size>0){l.islandChunks={count:w.size,totalBytes:y};let D={generatedChunks:w.size,totalBytes:y,chunks:h,pages:S};await Bun.write(g.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(D,null,2))}await e.hooks.onBuildEnd?.(l);let P=l.islandChunks?`
|
|
77
77
|
Island chunks: ${l.islandChunks.count} (${(l.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
|
|
78
78
|
Build complete!
|
|
79
79
|
Total: ${l.totalPages} pages
|
|
@@ -81,8 +81,8 @@ Build complete!
|
|
|
81
81
|
Cached: ${l.cachedCount}
|
|
82
82
|
Failed: ${l.failedCount}
|
|
83
83
|
Time: ${l.buildTime}ms${P}
|
|
84
|
-
`),l}async function J(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await J(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new ut(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=
|
|
85
|
-
`)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return
|
|
84
|
+
`),l}async function J(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await J(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new ut(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=j(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!l){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(l.regex),y={};if(w)l.params.forEach((P,D)=>{y[P]=w[D+1]});let h=await o(),{html:S}=await dt(l,y,{},t,h);await s.set(c,{html:S,generatedAt:Date.now(),revalidateAfter:Date.now()+r*1000,etag:Ut(S)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Wt(t){return async()=>({paths:await t(),fallback:!1})}function qt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let i=await Bun.file(t).text(),s=i.match(/^---\n([\s\S]*?)\n---/),r={},c=i;if(s){let h=s[1];c=i.slice(s[0].length).trim();for(let S of h.split(`
|
|
85
|
+
`)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return Je(t)}function Vt(t,i){return`<!DOCTYPE html>
|
|
86
86
|
<html>
|
|
87
87
|
<head>
|
|
88
88
|
<meta charset="utf-8">
|
package/dist/stx-virtual-ts.js
CHANGED
|
@@ -776,8 +776,10 @@ export function buildVirtualTypeScript(source, options = {}) {
|
|
|
776
776
|
let indent = 0;
|
|
777
777
|
if (shadowed.length > 0) {
|
|
778
778
|
append(UNWRAP_HELPER_DECL);
|
|
779
|
-
for (const name of shadowed)
|
|
780
|
-
append(`
|
|
779
|
+
for (const name of shadowed) {
|
|
780
|
+
append(`function __StxRead_${name}() { return ${name} }`);
|
|
781
|
+
append(`type __StxT_${name} = ${UNWRAP_HELPER}<ReturnType<typeof __StxRead_${name}>>`);
|
|
782
|
+
}
|
|
781
783
|
append(`;((${shadowed.map((name) => `${name}: __StxT_${name}`).join(", ")}) => {`);
|
|
782
784
|
indent = 1;
|
|
783
785
|
}
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { extractExports as scopeExports, scopePropertyDescriptor } from "./client-scope-bindings.js";
|
|
1
2
|
import { pascalToKebab } from "./component-resolution.js";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
@@ -1337,7 +1338,7 @@ async function buildComponentIsland(rawContent, componentFilePath, minify) {
|
|
|
1337
1338
|
}
|
|
1338
1339
|
const { stripStxRuntimeImports } = await importOnce("stx/signal-processing", () => import("./signal-processing.js"));
|
|
1339
1340
|
bundledContent = stripStxRuntimeImports(bundledContent);
|
|
1340
|
-
const content = transformStoreImports(bundledContent), componentLocalNames = extractVariableNames(content), factoryBody = `function(__scopeId) {
|
|
1341
|
+
const content = transformStoreImports(bundledContent), componentLocalNames = extractVariableNames(content), mutableLocals = new Set(scopeExports(content, !0).split(",").map((name) => name.trim())), factoryBody = `function(__scopeId) {
|
|
1341
1342
|
${buildRuntimeGlobalsDestructure("const", [...COMPONENT_SCOPE_LOCAL_GLOBALS, ...componentLocalNames], content)}
|
|
1342
1343
|
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
1343
1344
|
const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
|
|
@@ -1395,11 +1396,12 @@ ${content}
|
|
|
1395
1396
|
// Register all defined signals and functions in this scope
|
|
1396
1397
|
const __localVars = {};
|
|
1397
1398
|
try {
|
|
1398
|
-
${componentLocalNames.map((v) => `if (typeof ${v} !== 'undefined') __localVars['${v}'] = ${v};`).join(`
|
|
1399
|
+
${componentLocalNames.map((v) => mutableLocals.has(v) ? `Object.defineProperty(__localVars, '${v}', ${scopePropertyDescriptor(v)});` : `if (typeof ${v} !== 'undefined') __localVars['${v}'] = ${v};`).join(`
|
|
1399
1400
|
`)}
|
|
1400
1401
|
}
|
|
1401
1402
|
catch (e) {}
|
|
1402
|
-
Object.
|
|
1403
|
+
Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__localVars));
|
|
1404
|
+
if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__stxLiveBindings));
|
|
1403
1405
|
}
|
|
1404
1406
|
finally {
|
|
1405
1407
|
__registeringSetupHooks = false;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.632",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -128,12 +128,12 @@
|
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"@stacksjs/ts-css": "^0.3.11",
|
|
130
130
|
"@stacksjs/clapp": "^0.2.16",
|
|
131
|
-
"@stacksjs/desktop": "0.2.
|
|
132
|
-
"@stacksjs/sanitizer": "0.2.
|
|
131
|
+
"@stacksjs/desktop": "0.2.632",
|
|
132
|
+
"@stacksjs/sanitizer": "0.2.632",
|
|
133
133
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
134
|
-
"bun-plugin-stx": "0.2.
|
|
134
|
+
"bun-plugin-stx": "0.2.632",
|
|
135
135
|
"bunfig": "^0.15.21",
|
|
136
|
-
"stx-router": "0.2.
|
|
136
|
+
"stx-router": "0.2.632",
|
|
137
137
|
"ts-broadcasting": "^0.0.11",
|
|
138
138
|
"ts-images": "^0.2.22",
|
|
139
139
|
"ts-syntax-highlighter": "^0.2.1"
|
package/dist/chunk-0fcxfd5f.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{gc,de,mc,ai,Et,Tt,Xu,ci,$t,mn,hc,yc,bc,us,Rt,vc,At,wc}from"./chunk-g9sv00hm.js";import"./chunk-zedvwcta.js";import"./chunk-5rtatjwq.js";import"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{mn as MODULE_SPECIFIER_PREFIX,gc as bundleCacheDir,At as bundleClientScript,Tt as clearBundleFailures,de as clientBundleDependencies,Et as getBundleFailures,$t as hasUserImports,Rt as moduleSubstitutionKey,yc as normalizeRegistrySpecifiers,vc as queueClientBundleBuild,ai as recordBundleFailure,hc as registryIdForPath,ci as resolveBundlerFallback,bc as rewriteRegistryImports,Xu as setBundlerFallbackMode,mc as shouldLogBundlerDiagnostics,wc as tempBuildName,us as withModuleSubstitutes};
|
package/dist/chunk-0fgp13q4.js
DELETED
package/dist/chunk-2340emvg.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ga,ko,ma,ha,Co,ya,ba,va,wa,_o,xa,kl}from"./chunk-h431swg6.js";import{Do,Ta}from"./chunk-5wrmcbch.js";import{B,F,z,Jt,ee,le,Jn,Fe,St,Yt,Zt,Qt,H,en,tn,Yn}from"./chunk-ebkjpj5m.js";import{sc}from"./chunk-7mehf3h5.js";import"./chunk-jsw5yby0.js";export{F as DEFAULT_FORMATS,z as DEFAULT_QUALITY,B as DEFAULT_WIDTHS,Yn as ImageProcessingError,ha as clearImageCache,Co as createImageDirective,Ta as createImageHandler,ba as createImagePlugin,kl as defaultImageConfig,tn as formatSize,_o as generateImageManifest,St as generateSizes,Fe as generateSrcSet,Yt as getFallbackVariant,Jn as getImageMetadata,H as getMimeType,en as getTotalSize,Zt as groupVariantsByFormat,Do as handleImageRequest,ya as imageDirective,ee as isImageBackendAvailable,Qt as isImageFile,Jt as isSharpAvailable,wa as optimizeDirectory,va as optimizeImage,ko as parseImageComponent,le as processImage,ma as processImageComponents,ga as renderImageComponent,sc as rewriteImagesWithSiblings,xa as writeImageManifest};
|
package/dist/chunk-317xf7hx.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ud,mi,dd,hi,Pc,Ic,Lt,kn,pd,Oc,Nc,fd,f}from"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{Lt as buildCss,Oc as extractClassNames,Ic as fingerprintConfig,Nc as generateCss,pd as getCachedCSS,ud as getCssServeAsset,f as injectCss,mi as loadCssEngine,hi as loadCssEngineConfig,kn as rebuildCss,dd as resetCssCache,Pc as resolveUserCssConfig,fd as withLinkedModuleBundles};
|
package/dist/chunk-4kyrzkvg.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{u,Is,Ri,Ai,Xc,Jc,Yc,Zc,Qc,el,tt,j,nt,tl,fr,nl,Ni,Fs,rt,r,gr,Di,g,oe,vd}from"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{oe as clearComponentCache,Fs as componentClientSignalNames,Is as convertToCommonJS,g as createDetailedErrorMessage,Qc as extractDirectiveNames,Ri as extractScriptFromTemplate,u as extractVariables,r as fileExists,vd as getComponentCacheStats,Jc as getPositionInfo,j as getSharedTranspiler,Di as getSourceLineInfo,Zc as hasDirectives,Ai as hasVariables,nl as isHydrateTrigger,el as isJavaScriptScript,rt as renderComponentWithSlot,gr as resolveTemplatePath,tl as scopeOnRootElement,tt as shouldTranspileTypeScript,Ni as slotContentHasExpressions,nt as transpileTypeScript,fr as userComponentFileExists,Yc as validateDirective,Xc as validateTemplate};
|
package/dist/chunk-5q7gcr0f.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$l}from"./chunk-y17jdnrm.js";import"./chunk-8zqgb3q9.js";import"./chunk-19bhnbyn.js";import"./chunk-zedvwcta.js";import"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{$l as buildForProduction};
|
package/dist/chunk-5s91drvs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Pt,ds,ps,gs,Ju,ms}from"./chunk-zedvwcta.js";import"./chunk-z4te6223.js";import"./chunk-gc1dzxee.js";import"./chunk-sxpnpvt5.js";export{ps as buildServerApi,Ju as createServerApi,Pt as discoverServerApi,ds as generateApiTypes,ms as isServerApiSource,gs as productionApiDispatcher};
|
package/dist/chunk-6377p5ry.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{qe,$c,rd,sd,od,id,Rc,Ac,ad,cd,gi,ld,vn,wn,ar}from"./chunk-8jgrakqd.js";import"./chunk-n5xbv1a9.js";import"./chunk-10s16tad.js";import"./chunk-z4te6223.js";import"./chunk-aktzv0x2.js";import"./chunk-gc1dzxee.js";import"./chunk-khzyc41k.js";import"./chunk-x6pz1h3x.js";import"./chunk-1gtrs8va.js";import"./chunk-66e4ga0z.js";import"./chunk-dvbgbd06.js";import"./chunk-sxpnpvt5.js";import"./chunk-jp6yn9mj.js";export{id as __setSignalsGeneratorsForTest,qe as cacheEngineFingerprint,wn as cacheTemplate,vn as checkCache,ld as clearDevCaches,Ac as getCachedRouterScript,Rc as getCachedSignalsRuntime,ad as getServeClientAsset,gi as getServeModuleBundle,ar as hashFilePath,sd as invalidateFileCache,od as invalidateFileCacheByDir,rd as readFileCached,cd as registerServeModuleBundle,$c as templateCache};
|
package/dist/chunk-7h4mxhkh.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Gr,Kr,Xr,Ia,Oa,Na,Lo,Da,Ma}from"./chunk-q35z0cyg.js";export{Gr as ImageProcessorCache,Lo as applyTransformations,Ia as clearImageCache,Da as generateResponsiveVariants,Ma as generateSrcset,Kr as getCachedImageResult,Na as optimizeImage,Oa as processImage,Xr as setCachedImageResult};
|
package/dist/chunk-7zdefvrn.js
DELETED
package/dist/chunk-8898f767.js
DELETED