@stacksjs/stx 0.2.574 → 0.2.576
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/README.md +3 -0
- package/dist/chunk-08a98yqt.js +2 -0
- package/dist/chunk-181m21rg.js +2 -0
- package/dist/{chunk-nxw03sy9.js → chunk-1edvsndv.js} +2 -2
- package/dist/chunk-1nbn56jw.js +2 -0
- package/dist/{chunk-a3w3jc0t.js → chunk-1w9ngqpv.js} +3 -3
- package/dist/{chunk-ta50ym5j.js → chunk-1wkpxa58.js} +2 -2
- package/dist/{chunk-6z57saf5.js → chunk-2ry2pfpe.js} +1 -1
- package/dist/{chunk-ss4h5ch3.js → chunk-32gycb72.js} +1 -1
- package/dist/{chunk-g8dx2jew.js → chunk-34fajf1n.js} +100 -99
- package/dist/chunk-3bj1w990.js +2 -0
- package/dist/{chunk-kcq2ed1d.js → chunk-3gqrv02t.js} +2 -2
- package/dist/chunk-4a12azrb.js +2 -0
- package/dist/{chunk-e7pjsrfc.js → chunk-4z21afpp.js} +2 -2
- package/dist/{chunk-r5ce7mkg.js → chunk-5dm4k229.js} +2 -2
- package/dist/chunk-6fpynp8q.js +2 -0
- package/dist/{chunk-ytf3qkaw.js → chunk-6q3yszw9.js} +1 -1
- package/dist/{chunk-crj0yqc6.js → chunk-6rfm6b1c.js} +1 -1
- package/dist/chunk-6ryab0yy.js +2 -0
- package/dist/{chunk-3pr388w5.js → chunk-6sasxbv9.js} +1 -1
- package/dist/chunk-6w9km7qb.js +2 -0
- package/dist/{chunk-4k6cb5fg.js → chunk-6wz6f8d5.js} +3 -3
- package/dist/{chunk-cp5903cg.js → chunk-7j9m4d7x.js} +1 -1
- package/dist/{chunk-7gxn7mvd.js → chunk-7y73q42g.js} +2 -2
- package/dist/chunk-98r9jk2b.js +2 -0
- package/dist/chunk-9dgygz8d.js +2 -0
- package/dist/chunk-a51f04an.js +2 -0
- package/dist/chunk-aa52jhak.js +2 -0
- package/dist/chunk-agk478t4.js +3 -0
- package/dist/chunk-ambynnzb.js +2 -0
- package/dist/chunk-asbq9cgs.js +2 -0
- package/dist/{chunk-1n9bxdnh.js → chunk-bbdg3sqq.js} +2 -2
- package/dist/{chunk-69k5t6pj.js → chunk-bctjmaxg.js} +53 -53
- package/dist/{chunk-9yht5n7g.js → chunk-bks1fe5e.js} +1 -1
- package/dist/chunk-bmtsb5mr.js +2 -0
- package/dist/chunk-c8rd3573.js +2 -0
- package/dist/chunk-d4b8cgvt.js +2 -0
- package/dist/chunk-d7skqhrc.js +2 -0
- package/dist/{chunk-hqda3vcw.js → chunk-d8ek63nc.js} +1 -1
- package/dist/chunk-f2y8bwdd.js +2 -0
- package/dist/{chunk-0px2ab3m.js → chunk-fkbthywg.js} +5 -5
- package/dist/chunk-g9vtny6q.js +2 -0
- package/dist/{chunk-f0mbj8w9.js → chunk-gjp2jxrp.js} +1 -1
- package/dist/{chunk-gh0q6jrm.js → chunk-gpb22a8n.js} +2 -2
- package/dist/{chunk-anjm087t.js → chunk-h1n43e5n.js} +2 -2
- package/dist/{chunk-gdxhe7ae.js → chunk-h72befy4.js} +2 -2
- package/dist/chunk-haeb904b.js +3 -0
- package/dist/chunk-hcsrj8z6.js +3 -0
- package/dist/chunk-hj1bntaa.js +2 -0
- package/dist/chunk-hwy3aw5v.js +2 -0
- package/dist/chunk-hyafyqy6.js +2 -0
- package/dist/{chunk-e27njk86.js → chunk-j4zyq2ap.js} +8 -8
- package/dist/chunk-j75hqvgt.js +2 -0
- package/dist/chunk-j83ax407.js +2 -0
- package/dist/{chunk-e40qpeg5.js → chunk-je0cttam.js} +1 -1
- package/dist/{chunk-jwe7yq8m.js → chunk-jgrtvs81.js} +2 -2
- package/dist/chunk-k3hfwve1.js +2 -0
- package/dist/{chunk-3kc7af8c.js → chunk-kskyfss0.js} +2 -2
- package/dist/{chunk-sej3ng5k.js → chunk-mp99h8wh.js} +3 -3
- package/dist/{chunk-svvavwp2.js → chunk-n0kw3q6p.js} +1 -1
- package/dist/{chunk-0gt7e1ns.js → chunk-n829xbbq.js} +1 -1
- package/dist/chunk-nd3qttxh.js +2 -0
- package/dist/{chunk-myhh1zsm.js → chunk-ndc1bmj7.js} +1 -1
- package/dist/chunk-nn462qm9.js +2 -0
- package/dist/chunk-nr07vxm2.js +2 -0
- package/dist/{chunk-yhqhv8mp.js → chunk-nskvepjv.js} +414 -162
- package/dist/{chunk-8hp6722y.js → chunk-pqkb1m5x.js} +3 -3
- package/dist/chunk-q7a5pwaz.js +2 -0
- package/dist/{chunk-yf90vn5t.js → chunk-qfb34r6k.js} +3 -3
- package/dist/chunk-r51vyhms.js +2 -0
- package/dist/{chunk-k5rrp1bt.js → chunk-s68bqf62.js} +1 -1
- package/dist/{chunk-32pxa1r0.js → chunk-sf7z2ar9.js} +3 -3
- package/dist/{chunk-825m59jr.js → chunk-sn3htx1z.js} +1 -1
- package/dist/chunk-svavrmxb.js +2 -0
- package/dist/chunk-sw7mvg9p.js +2 -0
- package/dist/{chunk-06hx32h4.js → chunk-szfkkbve.js} +1 -1
- package/dist/{chunk-c0ewddb3.js → chunk-tasjpnbf.js} +2 -2
- package/dist/{chunk-3dr757vb.js → chunk-tybk9hw9.js} +7 -7
- package/dist/chunk-tz40t18m.js +2 -0
- package/dist/chunk-v1k0bdsg.js +2 -0
- package/dist/chunk-vd10tty0.js +2 -0
- package/dist/{chunk-501h1mer.js → chunk-vmetcczm.js} +4 -4
- package/dist/{chunk-vnh550b5.js → chunk-vnsby98n.js} +1 -1
- package/dist/{chunk-zfw39q56.js → chunk-vqkzhd19.js} +1 -1
- package/dist/{chunk-bb5a8adb.js → chunk-vw1rmevt.js} +3 -3
- package/dist/{chunk-71zwgxws.js → chunk-w1yft5gg.js} +1 -1
- package/dist/chunk-w6sa921x.js +2 -0
- package/dist/{chunk-1x2x3xgc.js → chunk-wvk932dp.js} +1 -1
- package/dist/{chunk-nc0ba89b.js → chunk-x5xwe5nr.js} +6 -6
- package/dist/{chunk-76437eb4.js → chunk-xh0808cd.js} +1 -1
- package/dist/{chunk-b10n7cpe.js → chunk-xk2v20xe.js} +2 -2
- package/dist/{chunk-0ppzstqj.js → chunk-xsxh7h8z.js} +2 -2
- package/dist/{chunk-n8hnrgen.js → chunk-y120qq1a.js} +4 -4
- package/dist/{chunk-byhsfnkc.js → chunk-zak5xare.js} +1 -1
- package/dist/chunk-zcw74jmk.js +2 -0
- package/dist/chunk-zxvndwaz.js +2 -0
- package/dist/cli.js +58 -58
- package/dist/client/signals-context-runtime.js +200 -0
- package/dist/client/signals-effect-runtime.js +12 -1
- package/dist/client/signals-globals-runtime.js +3 -1
- package/dist/client/signals-kept-runtime.d.ts +1 -1
- package/dist/client/signals-kept-runtime.js +8 -3
- package/dist/client/signals-public-api-runtime.js +2 -0
- package/dist/client/signals-reactive-runtime.js +0 -1
- package/dist/client/signals-state-runtime.js +53 -20
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-cached-query.js +2 -1
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/includes.js +10 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/native/runtime/craft-bridge.js +31 -9
- package/dist/native/runtime/craft.d.ts +3 -2
- package/dist/native/testing.d.ts +115 -0
- package/dist/native/testing.js +421 -0
- package/dist/offline/query-cache.d.ts +2 -0
- package/dist/offline/query-cache.js +43 -33
- package/dist/pwa.js +3 -3
- package/dist/reactivity.d.ts +36 -1
- package/dist/reactivity.js +33 -9
- package/dist/runtime-globals.js +2 -0
- package/dist/shared-request.d.ts +46 -0
- package/dist/shared-request.js +56 -0
- package/dist/signals-api.d.ts +32 -6
- package/dist/signals-api.js +42 -18
- package/dist/signals.js +2 -1
- package/dist/ssg.js +3 -3
- package/dist/stx-module.d.ts +2 -0
- package/package.json +9 -5
- package/stx-module.d.ts +2 -0
- package/stx.d.ts +54 -4
- package/dist/chunk-1m5pagp3.js +0 -2
- package/dist/chunk-27ja2rpd.js +0 -2
- package/dist/chunk-2b0p7am3.js +0 -2
- package/dist/chunk-3k6q1481.js +0 -2
- package/dist/chunk-42h0kvng.js +0 -2
- package/dist/chunk-4eff1v2p.js +0 -2
- package/dist/chunk-5n2v9g2c.js +0 -2
- package/dist/chunk-68ygpbta.js +0 -2
- package/dist/chunk-6gjfres0.js +0 -2
- package/dist/chunk-7debnvz9.js +0 -2
- package/dist/chunk-a77gbp9x.js +0 -2
- package/dist/chunk-bgbz0wzq.js +0 -2
- package/dist/chunk-bgr7fqhs.js +0 -2
- package/dist/chunk-bjfrwcfh.js +0 -2
- package/dist/chunk-c6jyp7ss.js +0 -3
- package/dist/chunk-cdt5pg28.js +0 -2
- package/dist/chunk-cfh798k7.js +0 -2
- package/dist/chunk-dax3zkmm.js +0 -2
- package/dist/chunk-dn676tdp.js +0 -2
- package/dist/chunk-dtbj816p.js +0 -2
- package/dist/chunk-e23cg45k.js +0 -2
- package/dist/chunk-ecwpsjpd.js +0 -2
- package/dist/chunk-h8vk3q9n.js +0 -2
- package/dist/chunk-hq8vxds5.js +0 -3
- package/dist/chunk-j8pamkbh.js +0 -2
- package/dist/chunk-mfm7ezh6.js +0 -2
- package/dist/chunk-mp16jxcg.js +0 -2
- package/dist/chunk-n1c9j5qv.js +0 -2
- package/dist/chunk-n61v7e3s.js +0 -2
- package/dist/chunk-nf63pk4s.js +0 -2
- package/dist/chunk-p5cry5s7.js +0 -2
- package/dist/chunk-r8qhex33.js +0 -2
- package/dist/chunk-rqvn1s52.js +0 -2
- package/dist/chunk-sjsant53.js +0 -2
- package/dist/chunk-snzh9z3g.js +0 -3
- package/dist/chunk-ty8g61y9.js +0 -2
- package/dist/chunk-v1k6w4z5.js +0 -2
- package/dist/chunk-vm7zv0gc.js +0 -2
- package/dist/chunk-vnxc48en.js +0 -2
- package/dist/chunk-y7vbwhh7.js +0 -2
- package/dist/chunk-yvyypd92.js +0 -2
- package/dist/chunk-zpm02e15.js +0 -2
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Un,je,Go,ec}from"./chunk-
|
|
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{Un,je,Go,ec}from"./chunk-n0kw3q6p.js";import{Hn,Jr,Ya,Za,Qa}from"./chunk-sn3htx1z.js";import{Vo,Wo,qo,Xa,Ja}from"./chunk-gpb22a8n.js";import{ae,yt,Yr}from"./chunk-1c8sdf9a.js";import{nl,rl,sl,ol,vr,_u}from"./chunk-5dm4k229.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-6ryab0yy.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=ae(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Un(n,t);if(a){let s=je(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 se(n,t){return Jr(n,t)}function oe(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Wo as auditBuildOutput,Vo as auditConfig,re as buildPwaAssets,qo as calculateAuditResult,Ja as formatAuditResult,Yr as formatSize,j as generateManifest,_ as generateManifestJson,Za as generateManifestLink,F as generateOfflinePage,ae as generatePrecacheManifest,yt as generatePrecacheManifestJs,M as generatePwaIcons,Hn as generatePwaTags,Un as generateServiceWorker,ec as generateServiceWorkerAuto,Ya as generateSwRegistrationScript,Qa as generateThemeColorMeta,N as getExpectedIconPaths,je as getServiceWorkerFileName,Jr as injectPwaTags,oe as isPwaEnabled,I as isSharpAvailable,Go as isWorkboxEnabled,q as mergeManifestConfig,se as processPwaHtml,vr as pwaDirectives,nl as pwaInstallDirective,sl as pwaOfflineDirective,ol as pwaPushDirective,rl as pwaUpdateDirective,
|
|
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=ae(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Un(n,t);if(a){let s=je(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 se(n,t){return Jr(n,t)}function oe(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Wo as auditBuildOutput,Vo as auditConfig,re as buildPwaAssets,qo as calculateAuditResult,Ja as formatAuditResult,Yr as formatSize,j as generateManifest,_ as generateManifestJson,Za as generateManifestLink,F as generateOfflinePage,ae as generatePrecacheManifest,yt as generatePrecacheManifestJs,M as generatePwaIcons,Hn as generatePwaTags,Un as generateServiceWorker,ec as generateServiceWorkerAuto,Ya as generateSwRegistrationScript,Qa as generateThemeColorMeta,N as getExpectedIconPaths,je as getServiceWorkerFileName,Jr as injectPwaTags,oe as isPwaEnabled,I as isSharpAvailable,Go as isWorkboxEnabled,q as mergeManifestConfig,se as processPwaHtml,vr as pwaDirectives,nl as pwaInstallDirective,sl as pwaOfflineDirective,ol as pwaPushDirective,rl as pwaUpdateDirective,_u as registerPwaDirectives,Xa as runPwaAudit,D as validateManifest};
|
package/dist/reactivity.d.ts
CHANGED
|
@@ -49,7 +49,36 @@ export declare function reactive<T extends object>(target: T): T;
|
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
51
|
export declare function computed<T>(getter: () => T): Ref<T>;
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Watch a reactive source and run a callback when its value changes.
|
|
54
|
+
*
|
|
55
|
+
* The source is a ref, a signal or derived (`state()`/`derived()`), a getter
|
|
56
|
+
* (`() => user().id`), or an array of those. The callback gets the new value
|
|
57
|
+
* and the previous one, and runs only when the value changed (`Object.is`, or
|
|
58
|
+
* structurally with `deep`) - not when the watch is created, unless
|
|
59
|
+
* `immediate`. It runs at `flush` timing: `'post'` (the default, after the
|
|
60
|
+
* next render), `'pre'` (a microtask) or `'sync'`. Returns a stop function.
|
|
61
|
+
*
|
|
62
|
+
* The client runtime's `watch` (`window.stx.watch`, a bare `watch` in a
|
|
63
|
+
* `<script client>`) has the same contract.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const count = ref(0)
|
|
68
|
+
*
|
|
69
|
+
* watch(count, (newVal, oldVal) => {
|
|
70
|
+
* console.log(`Changed from ${oldVal} to ${newVal}`)
|
|
71
|
+
* })
|
|
72
|
+
*
|
|
73
|
+
* // A getter, called back only when the id changes
|
|
74
|
+
* watch(() => user().id, id => load(id), { immediate: true })
|
|
75
|
+
*
|
|
76
|
+
* // Several sources
|
|
77
|
+
* watch([from, to], ([a, b], [oldA, oldB]) => reload(a, b))
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function watch<const S extends readonly WatchSource<unknown>[]>(source: S, callback: WatchCallback<WatchSourceValues<S>>, options?: WatchOptions): () => void;
|
|
81
|
+
export declare function watch<T>(source: WatchSource<T>, callback: WatchCallback<T>, options?: WatchOptions): () => void;
|
|
53
82
|
/**
|
|
54
83
|
* Watch multiple sources.
|
|
55
84
|
*
|
|
@@ -158,6 +187,7 @@ export declare interface WatchOptions {
|
|
|
158
187
|
immediate?: boolean
|
|
159
188
|
deep?: boolean
|
|
160
189
|
flush?: 'pre' | 'post' | 'sync'
|
|
190
|
+
once?: boolean
|
|
161
191
|
}
|
|
162
192
|
/** Component instance for tracking lifecycle */
|
|
163
193
|
export declare interface ComponentInstance {
|
|
@@ -196,6 +226,11 @@ export type Component<Props = any> = DefineComponent<Props>;
|
|
|
196
226
|
export type WatchCallback<T> = (newValue: T, oldValue: T | undefined) => void;
|
|
197
227
|
/** Lifecycle hook callback */
|
|
198
228
|
export type LifecycleHook = () => void | Promise<void>;
|
|
229
|
+
/** What `watch` can follow: a ref, a signal or derived, a getter, or an array of those. */
|
|
230
|
+
export type WatchSource<T> = Ref<T> | (() => T);
|
|
231
|
+
declare type WatchSourceValues<S extends readonly unknown[]> = {
|
|
232
|
+
[K in keyof S]: S[K] extends Ref<infer V> ? V : S[K] extends () => infer V ? V : S[K]
|
|
233
|
+
}
|
|
199
234
|
// =============================================================================
|
|
200
235
|
// Exports
|
|
201
236
|
// =============================================================================
|
package/dist/reactivity.js
CHANGED
|
@@ -207,14 +207,31 @@ function afterRender(fn) {
|
|
|
207
207
|
setTimeout(fn, 0);
|
|
208
208
|
}
|
|
209
209
|
export function watch(source, callback, options = {}) {
|
|
210
|
-
const { immediate = !1, deep = !1, flush = "post" } = options;
|
|
211
|
-
let oldValue, cleanup, stopped = !1;
|
|
212
|
-
const
|
|
210
|
+
const { immediate = !1, deep = !1, flush = "post" } = options, multi = Array.isArray(source);
|
|
211
|
+
let oldValue, cleanup, stopped = !1, forceNext = immediate;
|
|
212
|
+
const read = (item) => {
|
|
213
|
+
if (typeof item === "function")
|
|
214
|
+
return item();
|
|
215
|
+
if (item && typeof item === "object" && "value" in item)
|
|
216
|
+
return item.value;
|
|
217
|
+
return item;
|
|
218
|
+
}, changed = (next, prev) => {
|
|
219
|
+
if (deep)
|
|
220
|
+
return !structuralEqual(next, prev);
|
|
221
|
+
if (multi) {
|
|
222
|
+
const a = next, b = prev;
|
|
223
|
+
if (!b || a.length !== b.length)
|
|
224
|
+
return !0;
|
|
225
|
+
return a.some((value, i) => !Object.is(value, b[i]));
|
|
226
|
+
}
|
|
227
|
+
return !Object.is(next, prev);
|
|
228
|
+
}, job = () => {
|
|
213
229
|
if (stopped)
|
|
214
230
|
return;
|
|
215
|
-
const newValue = getValueTracking();
|
|
216
|
-
|
|
217
|
-
|
|
231
|
+
const newValue = getValueTracking(), force = forceNext;
|
|
232
|
+
forceNext = !1;
|
|
233
|
+
if (force || changed(newValue, oldValue)) {
|
|
234
|
+
const previous = force && immediate ? void 0 : oldValue;
|
|
218
235
|
if (deep && newValue !== null && typeof newValue === "object")
|
|
219
236
|
try {
|
|
220
237
|
oldValue = structuredClone(newValue);
|
|
@@ -223,6 +240,9 @@ export function watch(source, callback, options = {}) {
|
|
|
223
240
|
}
|
|
224
241
|
else
|
|
225
242
|
oldValue = newValue;
|
|
243
|
+
callback(newValue, previous);
|
|
244
|
+
if (options.once)
|
|
245
|
+
cleanup?.();
|
|
226
246
|
}
|
|
227
247
|
}, scheduler = (fn) => {
|
|
228
248
|
if (flush === "sync")
|
|
@@ -242,17 +262,17 @@ export function watch(source, callback, options = {}) {
|
|
|
242
262
|
job();
|
|
243
263
|
});
|
|
244
264
|
}, getValueTracking = () => {
|
|
245
|
-
if (typeof source === "function") {
|
|
265
|
+
if (typeof source === "function" || multi) {
|
|
246
266
|
const prevEffect = setActiveSubscriber(onChange);
|
|
247
267
|
try {
|
|
248
|
-
return source();
|
|
268
|
+
return multi ? source.map(read) : source();
|
|
249
269
|
} finally {
|
|
250
270
|
restoreActiveSubscriber(prevEffect);
|
|
251
271
|
}
|
|
252
272
|
}
|
|
253
273
|
return source.value;
|
|
254
274
|
};
|
|
255
|
-
if (typeof source !== "function") {
|
|
275
|
+
if (typeof source !== "function" && !multi) {
|
|
256
276
|
const unsubscribe = source.subscribe(() => {
|
|
257
277
|
scheduler(job);
|
|
258
278
|
});
|
|
@@ -265,6 +285,10 @@ export function watch(source, callback, options = {}) {
|
|
|
265
285
|
stopped = !0;
|
|
266
286
|
};
|
|
267
287
|
oldValue = getValueTracking();
|
|
288
|
+
if (deep && oldValue !== null && typeof oldValue === "object")
|
|
289
|
+
try {
|
|
290
|
+
oldValue = structuredClone(oldValue);
|
|
291
|
+
} catch {}
|
|
268
292
|
if (immediate)
|
|
269
293
|
scheduler(job);
|
|
270
294
|
if (currentInstance)
|
package/dist/runtime-globals.js
CHANGED
|
@@ -22,6 +22,7 @@ export const STX_RUNTIME_GLOBALS = [
|
|
|
22
22
|
"isDerived",
|
|
23
23
|
"isSignal",
|
|
24
24
|
"keptState",
|
|
25
|
+
"memo",
|
|
25
26
|
"navigate",
|
|
26
27
|
"nextTick",
|
|
27
28
|
"onBeforeMount",
|
|
@@ -39,6 +40,7 @@ export const STX_RUNTIME_GLOBALS = [
|
|
|
39
40
|
"registerStoresClient",
|
|
40
41
|
"setKeptScope",
|
|
41
42
|
"setRouteParams",
|
|
43
|
+
"sharedRequest",
|
|
42
44
|
"state",
|
|
43
45
|
"untrack",
|
|
44
46
|
"useAsync",
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** One request for every caller that wants the same answer. Closure-free. */
|
|
2
|
+
export declare function sharedRequest<K = string, T = unknown>(options?: SharedRequestOptions<K>): SharedRequest<K, T>;
|
|
3
|
+
/**
|
|
4
|
+
* sharedRequest - one request for every caller that wants the same answer.
|
|
5
|
+
*
|
|
6
|
+
* Every store that loads data ended up writing the same three pieces by hand:
|
|
7
|
+
* a `let inflight: Promise | null` so two screens mounting at once send one
|
|
8
|
+
* request, a "wait for the one in flight, then ask again" for a load that must
|
|
9
|
+
* see a change just made, and a `const mine = ++request` counter so an answer
|
|
10
|
+
* that lost the race does not overwrite a newer one. Each copy got one of the
|
|
11
|
+
* three slightly wrong: a pull to refresh that joined the ordinary load already
|
|
12
|
+
* out (and showed what the server had before the change), or a load for a new
|
|
13
|
+
* URL answered with the old URL's data.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const list = sharedRequest<string, Row[]>()
|
|
18
|
+
*
|
|
19
|
+
* // Two callers, one request: the second joins the first.
|
|
20
|
+
* const rows = await list.run(url, () => api.get(url))
|
|
21
|
+
*
|
|
22
|
+
* // After a write: never joins a request that may have been read before it;
|
|
23
|
+
* // waits that one out, then asks once more.
|
|
24
|
+
* await list.fresh(url, () => api.get(url))
|
|
25
|
+
*
|
|
26
|
+
* // Only the newest answer lands.
|
|
27
|
+
* const isLatest = list.latest()
|
|
28
|
+
* const answer = await list.run(url, () => api.get(url))
|
|
29
|
+
* if (isLatest()) rows.set(answer)
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Closure-free: the browser runtime embeds `sharedRequest` by source
|
|
33
|
+
* (signals.ts), and `createQueryCache` is handed it, so it may use nothing
|
|
34
|
+
* from this module's scope.
|
|
35
|
+
*
|
|
36
|
+
* @module shared-request
|
|
37
|
+
*/
|
|
38
|
+
export declare interface SharedRequestOptions<K> {
|
|
39
|
+
covers?: (running: K, wanted: K) => boolean
|
|
40
|
+
}
|
|
41
|
+
export declare interface SharedRequest<K, T> {
|
|
42
|
+
run: (key: K, start: () => Promise<T>) => Promise<T>
|
|
43
|
+
fresh: (key: K, start: () => Promise<T>) => Promise<T>
|
|
44
|
+
latest: () => () => boolean
|
|
45
|
+
readonly busy: boolean
|
|
46
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export function sharedRequest(options) {
|
|
2
|
+
const covers = options && options.covers || ((running, wanted) => Object.is(running, wanted)), flights = [], waiting = [];
|
|
3
|
+
let ticket = 0;
|
|
4
|
+
const launch = (key, start) => {
|
|
5
|
+
let promise;
|
|
6
|
+
try {
|
|
7
|
+
promise = Promise.resolve(start());
|
|
8
|
+
} catch (error) {
|
|
9
|
+
promise = Promise.reject(error);
|
|
10
|
+
}
|
|
11
|
+
const flight = { key, promise };
|
|
12
|
+
flights.push(flight);
|
|
13
|
+
const land = () => {
|
|
14
|
+
const at = flights.indexOf(flight);
|
|
15
|
+
if (at !== -1)
|
|
16
|
+
flights.splice(at, 1);
|
|
17
|
+
};
|
|
18
|
+
promise.then(land, land);
|
|
19
|
+
return promise;
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
run(key, start) {
|
|
23
|
+
for (const flight of flights)
|
|
24
|
+
if (covers(flight.key, key))
|
|
25
|
+
return flight.promise;
|
|
26
|
+
for (const queued of waiting)
|
|
27
|
+
if (covers(queued.key, key))
|
|
28
|
+
return queued.promise;
|
|
29
|
+
return launch(key, start);
|
|
30
|
+
},
|
|
31
|
+
fresh(key, start) {
|
|
32
|
+
for (const queued of waiting)
|
|
33
|
+
if (covers(queued.key, key))
|
|
34
|
+
return queued.promise;
|
|
35
|
+
const before = flights.filter((flight) => covers(flight.key, key)).map((flight) => flight.promise);
|
|
36
|
+
if (!before.length)
|
|
37
|
+
return launch(key, start);
|
|
38
|
+
const queued = { key, promise: null }, settled = () => {};
|
|
39
|
+
queued.promise = Promise.all(before.map((promise) => promise.then(settled, settled))).then(() => {
|
|
40
|
+
const at = waiting.indexOf(queued);
|
|
41
|
+
if (at !== -1)
|
|
42
|
+
waiting.splice(at, 1);
|
|
43
|
+
return launch(key, start);
|
|
44
|
+
});
|
|
45
|
+
waiting.push(queued);
|
|
46
|
+
return queued.promise;
|
|
47
|
+
},
|
|
48
|
+
latest() {
|
|
49
|
+
const mine = ++ticket;
|
|
50
|
+
return () => mine === ticket;
|
|
51
|
+
},
|
|
52
|
+
get busy() {
|
|
53
|
+
return flights.length > 0 || waiting.length > 0;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
package/dist/signals-api.d.ts
CHANGED
|
@@ -88,7 +88,21 @@ export declare function state<T>(initialValue: T): Signal<T>;
|
|
|
88
88
|
* })
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
91
|
-
export declare function derived<T>(compute: () => T): DerivedSignal<T>;
|
|
91
|
+
export declare function derived<T>(compute: () => T, options?: DerivedOptions<T>): DerivedSignal<T>;
|
|
92
|
+
/**
|
|
93
|
+
* A derived value that reaches its readers only when it changes: `Object.is`,
|
|
94
|
+
* or the `equals` given. Short for `derived(compute, { equals })`.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const user = state({ id: 1, name: 'Ada' })
|
|
99
|
+
* const userId = memo(() => user().id)
|
|
100
|
+
*
|
|
101
|
+
* effect(() => load(userId())) // runs once
|
|
102
|
+
* user.set({ id: 1, name: 'Ada L.' }) // same id: the effect does not run again
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function memo<T>(compute: () => T, equals?: (previous: T, next: T) => boolean): DerivedSignal<T>;
|
|
92
106
|
/**
|
|
93
107
|
* Creates a side effect that runs when its dependencies change.
|
|
94
108
|
*
|
|
@@ -251,16 +265,22 @@ export declare function isSignal(value: unknown): value is Signal<unknown>;
|
|
|
251
265
|
*/
|
|
252
266
|
export declare function isDerived(value: unknown): value is DerivedSignal<unknown>;
|
|
253
267
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
268
|
+
* Reads a signal's value without tracking it: an effect that calls
|
|
269
|
+
* `untrack(count)` does not run again when `count` changes. Anything that is
|
|
270
|
+
* not a signal is returned as it is. For several reads, use {@link peek}.
|
|
256
271
|
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
272
|
+
* It used to read the signal tracked, so an effect calling it still re-ran on
|
|
273
|
+
* every change; it now matches its name in both implementations.
|
|
274
|
+
*
|
|
275
|
+
* @param value - A signal, derived signal or plain value
|
|
276
|
+
* @returns The value, read without subscribing
|
|
259
277
|
*
|
|
260
278
|
* @example
|
|
261
279
|
* ```typescript
|
|
262
280
|
* const count = state(5)
|
|
263
|
-
*
|
|
281
|
+
* effect(() => {
|
|
282
|
+
* console.log(untrack(count)) // logs once; count.set(6) does not run this again
|
|
283
|
+
* })
|
|
264
284
|
* untrack(10) // 10
|
|
265
285
|
* ```
|
|
266
286
|
*/
|
|
@@ -358,6 +378,12 @@ export declare interface DerivedSignal<T> {
|
|
|
358
378
|
readonly value: T
|
|
359
379
|
readonly _isDerived: true
|
|
360
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* Options for {@link derived}.
|
|
383
|
+
*/
|
|
384
|
+
export declare interface DerivedOptions<T> {
|
|
385
|
+
equals?: (previous: T, next: T) => boolean
|
|
386
|
+
}
|
|
361
387
|
/**
|
|
362
388
|
* Options for creating effects.
|
|
363
389
|
*/
|
package/dist/signals-api.js
CHANGED
|
@@ -46,33 +46,54 @@ export function state(initialValue) {
|
|
|
46
46
|
});
|
|
47
47
|
return signal;
|
|
48
48
|
}
|
|
49
|
-
export function derived(compute) {
|
|
50
|
-
let cachedValue, isDirty = !0;
|
|
51
|
-
const effects = new Set,
|
|
52
|
-
|
|
49
|
+
export function derived(compute, options = {}) {
|
|
50
|
+
let cachedValue, isDirty = !0, hasValue = !1;
|
|
51
|
+
const effects = new Set, equals = typeof options.equals === "function" ? options.equals : null, recompute = () => {
|
|
52
|
+
const prevEffect = setActiveSubscriber(markDirty);
|
|
53
|
+
try {
|
|
54
|
+
cachedValue = compute();
|
|
55
|
+
hasValue = !0;
|
|
56
|
+
} finally {
|
|
57
|
+
restoreActiveSubscriber(prevEffect);
|
|
58
|
+
}
|
|
59
|
+
isDirty = !1;
|
|
60
|
+
}, changedNow = () => {
|
|
61
|
+
const before = cachedValue, had = hasValue;
|
|
62
|
+
try {
|
|
63
|
+
recompute();
|
|
64
|
+
} catch {
|
|
53
65
|
isDirty = !0;
|
|
54
|
-
|
|
66
|
+
return !0;
|
|
67
|
+
}
|
|
68
|
+
return !had || !equals(before, cachedValue);
|
|
69
|
+
}, markDirty = () => {
|
|
70
|
+
if (isDirty)
|
|
71
|
+
return;
|
|
72
|
+
if (equals && effects.size) {
|
|
73
|
+
if (changedNow())
|
|
74
|
+
notifySubscribers(effects);
|
|
75
|
+
return;
|
|
55
76
|
}
|
|
77
|
+
isDirty = !0;
|
|
78
|
+
notifySubscribers(effects);
|
|
56
79
|
};
|
|
57
80
|
markAsForwarder(markDirty, (into) => {
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
81
|
+
if (isDirty)
|
|
82
|
+
return;
|
|
83
|
+
if (equals && effects.size) {
|
|
84
|
+
if (changedNow())
|
|
85
|
+
collectSubscribers(effects, into);
|
|
86
|
+
return;
|
|
61
87
|
}
|
|
88
|
+
isDirty = !0;
|
|
89
|
+
collectSubscribers(effects, into);
|
|
62
90
|
});
|
|
63
91
|
const signal = () => {
|
|
64
92
|
const subscriber = getActiveSubscriber();
|
|
65
93
|
if (subscriber)
|
|
66
94
|
effects.add(subscriber);
|
|
67
|
-
if (isDirty)
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
cachedValue = compute();
|
|
71
|
-
} finally {
|
|
72
|
-
restoreActiveSubscriber(prevEffect);
|
|
73
|
-
}
|
|
74
|
-
isDirty = !1;
|
|
75
|
-
}
|
|
95
|
+
if (isDirty)
|
|
96
|
+
recompute();
|
|
76
97
|
return cachedValue;
|
|
77
98
|
};
|
|
78
99
|
Object.defineProperty(signal, "_isDerived", { value: !0, writable: !1 });
|
|
@@ -82,6 +103,9 @@ export function derived(compute) {
|
|
|
82
103
|
});
|
|
83
104
|
return signal;
|
|
84
105
|
}
|
|
106
|
+
export function memo(compute, equals = Object.is) {
|
|
107
|
+
return derived(compute, { equals });
|
|
108
|
+
}
|
|
85
109
|
export function effect(fn, options = {}) {
|
|
86
110
|
let cleanup, isDisposed = !1;
|
|
87
111
|
const runEffect = () => {
|
|
@@ -155,7 +179,7 @@ export function isDerived(value) {
|
|
|
155
179
|
}
|
|
156
180
|
export function untrack(value) {
|
|
157
181
|
if (isSignal(value) || isDerived(value))
|
|
158
|
-
return value();
|
|
182
|
+
return withoutTracking(() => value());
|
|
159
183
|
return value;
|
|
160
184
|
}
|
|
161
185
|
export function peek(fn) {
|
package/dist/signals.js
CHANGED
|
@@ -4,6 +4,7 @@ import { createModelSignal } from "./component-model.js";
|
|
|
4
4
|
import { readHydratedData, clearServerData } from "./composables/use-fetch.js";
|
|
5
5
|
import { createKeptStore, indexedDbBackend } from "./offline/kept-store.js";
|
|
6
6
|
import { createQueryCache, queryTargetMatches } from "./offline/query-cache.js";
|
|
7
|
+
import { sharedRequest } from "./shared-request.js";
|
|
7
8
|
import { SIGNALS_APPEARANCE_RUNTIME } from "./client/signals-appearance-runtime.js";
|
|
8
9
|
import { signalsAuthoringRuntime } from "./client/signals-authoring-runtime.js";
|
|
9
10
|
import { SIGNALS_BINDING_UTILS_RUNTIME } from "./client/signals-binding-utils-runtime.js";
|
|
@@ -171,7 +172,7 @@ ${SIGNALS_REACTIVE_RUNTIME}
|
|
|
171
172
|
|
|
172
173
|
${SIGNALS_STORAGE_RUNTIME}
|
|
173
174
|
|
|
174
|
-
${signalsKeptRuntime(createKeptStore.toString(), indexedDbBackend.toString(), createQueryCache.toString(), queryTargetMatches.toString())}
|
|
175
|
+
${signalsKeptRuntime(createKeptStore.toString(), indexedDbBackend.toString(), createQueryCache.toString(), queryTargetMatches.toString(), sharedRequest.toString())}
|
|
175
176
|
${SIGNALS_COOKIE_RUNTIME}
|
|
176
177
|
${signalsAuthoringRuntime(createModelSignal.toString())}
|
|
177
178
|
${SIGNALS_HEAD_RUNTIME}
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-kskyfss0.js";import"./chunk-qfb34r6k.js";import"./chunk-7hr63cp5.js";import{rt,st,ot,it,at,ct}from"./chunk-h72befy4.js";import"./chunk-haeb904b.js";import"./chunk-4xvbc0mb.js";import{f,He,L,J,n,o}from"./chunk-34fajf1n.js";import"./chunk-tybk9hw9.js";import{cr}from"./chunk-x5xwe5nr.js";import"./chunk-vde4mtfr.js";import"./chunk-1wkpxa58.js";import"./chunk-1edvsndv.js";import"./chunk-550q827h.js";import"./chunk-mp99h8wh.js";import{ce,bt,wt}from"./chunk-y120qq1a.js";import{zo,Ho,Uo}from"./chunk-pxk0tpw2.js";import{ht,nn,rn}from"./chunk-xsxh7h8z.js";import"./chunk-7j9m4d7x.js";import{a}from"./chunk-hcsrj8z6.js";import x from"fs";import g from"path";import{createHash as Dt}from"crypto";function Rt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ut(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(kt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Rt(h);let S=Ct(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Dt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var Et=new Set(["visible","idle"]);function dt(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(Et.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var It=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Bt(t){for(let i of It){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function gt(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function jt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=gt(e.default??e);if(l)return l}catch{}}return null}async function pt(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=gt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await jt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=Bt(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ft(){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 mt{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 yt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function Ft(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${c[1]}
|
|
@@ -41,7 +41,7 @@ ${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();wt();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ft());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-
|
|
44
|
+
</rss>`}async function zt(t={}){let i=Date.now();wt();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ft());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-sw7mvg9p.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-zxvndwaz.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 mt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-sw7mvg9p.js");await u('<div class="bg-black"></div>')}catch{}rt();let xt=s?.routeMiddleware?.dir||"middleware";await ot(process.cwd(),xt);let H=st();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let vt=s?.routeMiddleware?.global||[];Uo(s?.layoutsDir,a(process.cwd()));let K=L(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${K.length} routes`);let G=[];for(let u of K){let m=await Ot(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 A=[],X=[];for(let u=0;u<G.length;u+=e.concurrency)X.push(G.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:M,props:Pt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),$t=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],tt=[...vt,...$t];if(tt.length>0){let C=it(d,M,F||{}),O=at(C,null,void 0,{isServer:!0}),E=await ct(tt,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,_),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(_),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${et[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,nt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)nt=!0,l.cachedCount++}if(!k){let C=await St(v,M,Pt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
|
@@ -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&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=cr({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=zo(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=Ho(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 V(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Z=
|
|
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&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=cr({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=zo(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=Ho(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 V(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Z=rn();if(Z)await V(Z,g.join(e.outputDir,nn)),console.log(`Copied assets from ${ht}`)}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
|
package/dist/stx-module.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ declare module 'stx' {
|
|
|
71
71
|
export const setResponseHeader: (name: string, value: string) => void // <script server> only
|
|
72
72
|
export const setResponseStatus: (status: number) => void // <script server> only
|
|
73
73
|
export const setRouteParams: typeof globalThis.setRouteParams
|
|
74
|
+
export const sharedRequest: typeof globalThis.sharedRequest
|
|
74
75
|
export const state: typeof globalThis.state
|
|
75
76
|
export const untrack: typeof globalThis.untrack
|
|
76
77
|
export const useAsync: typeof globalThis.useAsync
|
|
@@ -113,6 +114,7 @@ declare module 'stx' {
|
|
|
113
114
|
export const useServerRuntimeConfig: () => Readonly<{ public: Record<string, any>, private: Record<string, any> }> // <script server> only
|
|
114
115
|
export const useSessionStorage: typeof globalThis.useSessionStorage
|
|
115
116
|
export const keptState: typeof globalThis.keptState
|
|
117
|
+
export const memo: typeof globalThis.memo
|
|
116
118
|
export const forgetKeptState: typeof globalThis.forgetKeptState
|
|
117
119
|
export const setKeptScope: typeof globalThis.setKeptScope
|
|
118
120
|
export const flushKeptState: typeof globalThis.flushKeptState
|
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.576",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,6 +60,10 @@
|
|
|
60
60
|
"types": "./dist/native/index.d.ts",
|
|
61
61
|
"import": "./dist/native/index.js"
|
|
62
62
|
},
|
|
63
|
+
"./native/testing": {
|
|
64
|
+
"types": "./dist/native/testing.d.ts",
|
|
65
|
+
"import": "./dist/native/testing.js"
|
|
66
|
+
},
|
|
63
67
|
"./bundle-analyzer": {
|
|
64
68
|
"types": "./dist/bundle-analyzer/index.d.ts",
|
|
65
69
|
"import": "./dist/bundle-analyzer.js"
|
|
@@ -124,12 +128,12 @@
|
|
|
124
128
|
"dependencies": {
|
|
125
129
|
"@stacksjs/ts-css": "^0.3.11",
|
|
126
130
|
"@stacksjs/clapp": "^0.2.16",
|
|
127
|
-
"@stacksjs/desktop": "0.2.
|
|
128
|
-
"@stacksjs/sanitizer": "0.2.
|
|
131
|
+
"@stacksjs/desktop": "0.2.576",
|
|
132
|
+
"@stacksjs/sanitizer": "0.2.576",
|
|
129
133
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
130
|
-
"bun-plugin-stx": "0.2.
|
|
134
|
+
"bun-plugin-stx": "0.2.576",
|
|
131
135
|
"bunfig": "^0.15.21",
|
|
132
|
-
"stx-router": "0.2.
|
|
136
|
+
"stx-router": "0.2.576",
|
|
133
137
|
"ts-broadcasting": "^0.0.11",
|
|
134
138
|
"ts-images": "^0.2.22",
|
|
135
139
|
"ts-syntax-highlighter": "^0.2.1"
|
package/stx-module.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ declare module 'stx' {
|
|
|
71
71
|
export const setResponseHeader: (name: string, value: string) => void // <script server> only
|
|
72
72
|
export const setResponseStatus: (status: number) => void // <script server> only
|
|
73
73
|
export const setRouteParams: typeof globalThis.setRouteParams
|
|
74
|
+
export const sharedRequest: typeof globalThis.sharedRequest
|
|
74
75
|
export const state: typeof globalThis.state
|
|
75
76
|
export const untrack: typeof globalThis.untrack
|
|
76
77
|
export const useAsync: typeof globalThis.useAsync
|
|
@@ -113,6 +114,7 @@ declare module 'stx' {
|
|
|
113
114
|
export const useServerRuntimeConfig: () => Readonly<{ public: Record<string, any>, private: Record<string, any> }> // <script server> only
|
|
114
115
|
export const useSessionStorage: typeof globalThis.useSessionStorage
|
|
115
116
|
export const keptState: typeof globalThis.keptState
|
|
117
|
+
export const memo: typeof globalThis.memo
|
|
116
118
|
export const forgetKeptState: typeof globalThis.forgetKeptState
|
|
117
119
|
export const setKeptScope: typeof globalThis.setKeptScope
|
|
118
120
|
export const flushKeptState: typeof globalThis.flushKeptState
|