@stacksjs/stx 0.2.228 → 0.2.230
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-bd7v7g46.js → chunk-0939bnyw.js} +2 -2
- package/dist/{chunk-knr1wfcd.js → chunk-1tmhht43.js} +1 -1
- package/dist/{chunk-62pema3f.js → chunk-40rqwfqt.js} +1 -1
- package/dist/{chunk-r3k599q0.js → chunk-4bbyk43z.js} +1 -1
- package/dist/{chunk-cp834r9n.js → chunk-4j8vpk72.js} +8 -8
- package/dist/{chunk-7xwjaqh9.js → chunk-5fy1k8m0.js} +1 -1
- package/dist/{chunk-qtj8qrz6.js → chunk-764km47e.js} +1 -1
- package/dist/{chunk-h92r2rv6.js → chunk-7918r5qc.js} +1 -1
- package/dist/{chunk-f5z2jbtk.js → chunk-8309r1ea.js} +1 -1
- package/dist/{chunk-6wrkkdve.js → chunk-8m0p3v0e.js} +1 -1
- package/dist/{chunk-9nnq8xrq.js → chunk-9ny96ccv.js} +1 -1
- package/dist/{chunk-4p0bja56.js → chunk-a0a7vmgm.js} +1 -1
- package/dist/{chunk-xfbc0xp4.js → chunk-akh7aqh0.js} +1 -1
- package/dist/{chunk-ydwg6e34.js → chunk-apk45qqk.js} +1 -1
- package/dist/{chunk-we3731c4.js → chunk-c4a2kfj0.js} +1 -1
- package/dist/{chunk-65yw97a2.js → chunk-cddj2p27.js} +1 -1
- package/dist/{chunk-25b3r6ff.js → chunk-cges9wnq.js} +1 -1
- package/dist/{chunk-512qkvya.js → chunk-dedefnzd.js} +1 -1
- package/dist/{chunk-0r9xr2km.js → chunk-dk06jv4n.js} +1 -1
- package/dist/{chunk-07pmn67t.js → chunk-en8ajb6b.js} +1 -1
- package/dist/{chunk-emgn7z93.js → chunk-erwwmzym.js} +1 -1
- package/dist/{chunk-eakgdbd0.js → chunk-g3qcyeb1.js} +1 -1
- package/dist/{chunk-061f3pf7.js → chunk-h1jzzy6t.js} +95 -95
- package/dist/{chunk-ksfkskte.js → chunk-hkn78n7a.js} +1 -1
- package/dist/{chunk-cjk8zvjm.js → chunk-jrcm4vzs.js} +1 -1
- package/dist/{chunk-h0xfat7c.js → chunk-n2fhxh9a.js} +1 -1
- package/dist/{chunk-2v51cp46.js → chunk-n4ecxe8x.js} +2 -2
- package/dist/{chunk-8z29ty0t.js → chunk-nwxd1jee.js} +1 -1
- package/dist/{chunk-vg62v5bz.js → chunk-p13ggd30.js} +1 -1
- package/dist/{chunk-jw0y7tx4.js → chunk-p58b19t0.js} +1 -1
- package/dist/{chunk-e1eze8zn.js → chunk-paz6f4m5.js} +1 -1
- package/dist/{chunk-ykss7ta8.js → chunk-rfky5t3a.js} +1 -1
- package/dist/{chunk-wmj84fj0.js → chunk-rfpg019d.js} +1 -1
- package/dist/{chunk-7jbfha4x.js → chunk-s3x1p8ff.js} +1 -1
- package/dist/{chunk-tfkwgjvm.js → chunk-t7zk4x6s.js} +1 -1
- package/dist/{chunk-2wvg84c0.js → chunk-v7fsv3wn.js} +1 -1
- package/dist/{chunk-x3gv35ke.js → chunk-vy3brhf3.js} +1 -1
- package/dist/{chunk-b02x07dh.js → chunk-wbegam4r.js} +1 -1
- package/dist/{chunk-yq2j2tzb.js → chunk-x7rf15d3.js} +1 -1
- package/dist/{chunk-ft56brtb.js → chunk-y8g3d192.js} +1 -1
- package/dist/{chunk-h3a96ak4.js → chunk-zbsnkmne.js} +1 -1
- package/dist/{chunk-1cs82015.js → chunk-zd7bn188.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/types/config-types.d.ts +17 -0
- package/dist/utils.js +13 -10
- package/package.json +5 -5
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Fk as wq,Gk as dq,Hk as Cq,Ik as mq,Jk as gq}from"./chunk-wvc7t11n.js";import{Kk as S,Lk as Tq,Mk as _q,Nk as z,Ok as D,Pk as P,Qk as kq,Rk as vq,Sk as w,Tk as Iq,Uk as d,Vk as Hq,Wk as Oq,Xk as Mq}from"./chunk-nf4tx374.js";import{Au as Pq,vu as Aq,wu as bq,xu as Sq,yu as zq,zu as Dq}from"./chunk-ge69r310.js";import{Eu as N}from"./chunk-q891e1vj.js";import p from"fs";import E from"path";import C from"fs";import L from"path";var k=[72,96,128,144,152,192,384,512],v=[120,152,167,180],I=[16,32];async function H(G,B){let q={success:!0,generatedFiles:[],errors:[],warnings:[]},K=G.pwa?.icons;if(!K?.src)return q.errors.push("No source icon specified in pwa.icons.src"),q.success=!1,q;let Y=L.isAbsolute(K.src)?K.src:L.resolve(process.cwd(),K.src);if(!await Bun.file(Y).exists())return q.errors.push(`Source icon not found: ${Y}`),q.success=!1,q;let Q=L.resolve(B,K.outputDir||"pwa-icons");try{C.mkdirSync(Q,{recursive:!0})}catch{return q.errors.push(`Failed to create output directory: ${Q}`),q.success=!1,q}let X=K.sizes||k,j=K.generateWebP??!0,J=K.generateAppleIcons??!0;try{let y;try{y=await import("sharp")}catch{return q.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),q.success=!1,q}let R=await y.default(Y).metadata();if(R.width&&R.width<512)q.warnings.push(`Source icon is ${R.width}x${R.height}. Recommend using at least 512x512 for best quality.`);for(let $ of X){let x=L.join(Q,`icon-${$}x${$}.png`);if(await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x),j){let F=L.join(Q,`icon-${$}x${$}.webp`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(F),q.generatedFiles.push(F)}}if(J){for(let x of v){let F=L.join(Q,`apple-touch-icon-${x}x${x}.png`);await y.default(Y).resize(x,x,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(F),q.generatedFiles.push(F)}let $=L.join(Q,"apple-touch-icon.png");await y.default(Y).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile($),q.generatedFiles.push($)}for(let $ of I){let x=L.join(Q,`favicon-${$}x${$}.png`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x)}let U=512,T=L.join(Q,`icon-maskable-${U}x${U}.png`),Z=Math.floor(U*0.1),_=U-Z*2;await y.default(Y).resize(_,_,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:Z,bottom:Z,left:Z,right:Z,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(T),q.generatedFiles.push(T)}catch(y){let V=y instanceof Error?y.message:String(y);q.errors.push(`Icon generation failed: ${V}`),q.success=!1}return q}function n(G){let B=G.sizes||k,q=G.outputDir?`/${G.outputDir}`:"/pwa-icons",K=G.generateWebP??!0,Y=G.generateAppleIcons??!0,Q=[];for(let X of B)if(Q.push(`${q}/icon-${X}x${X}.png`),K)Q.push(`${q}/icon-${X}x${X}.webp`);if(Y){Q.push(`${q}/apple-touch-icon.png`);for(let X of v)Q.push(`${q}/apple-touch-icon-${X}x${X}.png`)}for(let X of I)Q.push(`${q}/favicon-${X}x${X}.png`);return Q.push(`${q}/icon-maskable-512x512.png`),Q}async function O(){try{return await import("sharp"),!0}catch{return!1}}function m(G,B,q,K){let Y=[],Q=K.join(" ");for(let X of G)if(Y.push({src:`${B}/icon-${X}x${X}.png`,sizes:`${X}x${X}`,type:"image/png",purpose:Q}),q)Y.push({src:`${B}/icon-${X}x${X}.webp`,sizes:`${X}x${X}`,type:"image/webp",purpose:Q});return Y}function g(G){return G.map((B)=>({name:B.name,short_name:B.shortName,description:B.description,url:B.url,icons:B.icons?.map((q)=>({src:q.src,sizes:q.sizes,type:q.type}))}))}function h(G){let B=G.pwa?.shareTarget;if(!B?.enabled)return;let q={action:B.action||"/share",method:B.method||"POST",enctype:B.enctype||"multipart/form-data",params:{title:B.params?.title||"title",text:B.params?.text||"text",url:B.params?.url||"url"}};if(B.acceptFiles&&B.acceptFiles.length>0)q.params.files=B.acceptFiles.map((K)=>({name:K.name,accept:K.accept}));return q}function c(G){let B=G.pwa?.fileHandlers;if(!B?.enabled||!B.accept)return;let q=[{action:B.action||"/",accept:B.accept,launch_type:B.launchType||"single-client"}];if(B.icons)q[0].icons=B.icons.map((K)=>({src:K.src,sizes:K.sizes,type:K.type}));return q}function l(G){let B=G.pwa?.protocolHandlers;if(!B||B.length===0)return;return B.map((q)=>({protocol:q.protocol,url:q.url}))}function u(G){let B=G.pwa;if(!B?.enabled||!B.manifest)return null;let{manifest:q,icons:K}=B,Y=K?.sizes||[72,96,128,144,152,192,384,512],Q=K?.outputDir?`/${K.outputDir}`:"/pwa-icons",X=K?.generateWebP??!0,j=K?.purpose||["any","maskable"],J={name:q.name,short_name:q.shortName||q.name,description:q.description,start_url:q.startUrl||"/",display:q.display||"standalone",display_override:q.displayOverride,orientation:q.orientation,theme_color:q.themeColor,background_color:q.backgroundColor,scope:q.scope||"/",lang:q.lang,dir:q.dir,id:q.id,categories:q.categories,icons:m(Y,Q,X,j)};if(q.shortcuts&&q.shortcuts.length>0)J.shortcuts=g(q.shortcuts);if(q.screenshots&&q.screenshots.length>0)J.screenshots=q.screenshots.map((U)=>({src:U.src,sizes:U.sizes,type:U.type,label:U.label,form_factor:U.platform}));let y=h(G);if(y)J.share_target=y;let V=c(G);if(V)J.file_handlers=V;let R=l(G);if(R)J.protocol_handlers=R;if(q.launchHandler)J.launch_handler={client_mode:q.launchHandler};if(q.handleLinks)J.handle_links=q.handleLinks;if(q.edgeSidePanel?.enabled)J.edge_side_panel={preferred_width:q.edgeSidePanel.preferredWidth};return J}function M(G){let B=u(G);if(!B)return"";let q=JSON.parse(JSON.stringify(B));return JSON.stringify(q,null,2)}function i(G,B){return{...B,...G,shortcuts:G.shortcuts||B.shortcuts,screenshots:G.screenshots||B.screenshots,categories:G.categories||B.categories}}function s(G){let B=[],q=G.pwa;if(!q?.enabled)return B;let K=q.manifest;if(!K)return B.push("PWA manifest configuration is missing"),B;if(!K.name)B.push("Manifest name is required");let Y=["fullscreen","standalone","minimal-ui","browser"];if(K.display&&!Y.includes(K.display))B.push(`Invalid display mode: ${K.display}. Must be one of: ${Y.join(", ")}`);let Q=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(K.orientation&&!Q.includes(K.orientation))B.push(`Invalid orientation: ${K.orientation}`);let X=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(K.themeColor&&!X.test(K.themeColor))B.push(`Invalid theme color: ${K.themeColor}. Must be a valid hex color.`);if(K.backgroundColor&&!X.test(K.backgroundColor))B.push(`Invalid background color: ${K.backgroundColor}. Must be a valid hex color.`);if(q.shareTarget?.enabled){if(!q.shareTarget.action)B.push("Share target action URL is required")}if(q.fileHandlers?.enabled){if(!q.fileHandlers.accept||Object.keys(q.fileHandlers.accept).length===0)B.push("File handlers must specify accepted MIME types")}if(q.protocolHandlers)for(let j of q.protocolHandlers){if(!j.protocol)B.push("Protocol handler missing protocol");if(!j.url||!j.url.includes("%s"))B.push(`Protocol handler URL must contain %s placeholder: ${j.protocol}`)}return B}import A from"path";async function b(G){let B=G.pwa?.offline;if(!B?.enabled)return"";if(B.page){let q=A.isAbsolute(B.page)?B.page:A.resolve(process.cwd(),B.page);if(await Bun.file(q).exists())try{let{processDirectives:K}=await import("./chunk-
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),q.success=!1,q}let R=await y.default(Y).metadata();if(R.width&&R.width<512)q.warnings.push(`Source icon is ${R.width}x${R.height}. Recommend using at least 512x512 for best quality.`);for(let $ of X){let x=L.join(Q,`icon-${$}x${$}.png`);if(await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x),j){let F=L.join(Q,`icon-${$}x${$}.webp`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(F),q.generatedFiles.push(F)}}if(J){for(let x of v){let F=L.join(Q,`apple-touch-icon-${x}x${x}.png`);await y.default(Y).resize(x,x,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(F),q.generatedFiles.push(F)}let $=L.join(Q,"apple-touch-icon.png");await y.default(Y).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile($),q.generatedFiles.push($)}for(let $ of I){let x=L.join(Q,`favicon-${$}x${$}.png`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x)}let U=512,T=L.join(Q,`icon-maskable-${U}x${U}.png`),Z=Math.floor(U*0.1),_=U-Z*2;await y.default(Y).resize(_,_,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:Z,bottom:Z,left:Z,right:Z,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(T),q.generatedFiles.push(T)}catch(y){let V=y instanceof Error?y.message:String(y);q.errors.push(`Icon generation failed: ${V}`),q.success=!1}return q}function n(G){let B=G.sizes||k,q=G.outputDir?`/${G.outputDir}`:"/pwa-icons",K=G.generateWebP??!0,Y=G.generateAppleIcons??!0,Q=[];for(let X of B)if(Q.push(`${q}/icon-${X}x${X}.png`),K)Q.push(`${q}/icon-${X}x${X}.webp`);if(Y){Q.push(`${q}/apple-touch-icon.png`);for(let X of v)Q.push(`${q}/apple-touch-icon-${X}x${X}.png`)}for(let X of I)Q.push(`${q}/favicon-${X}x${X}.png`);return Q.push(`${q}/icon-maskable-512x512.png`),Q}async function O(){try{return await import("sharp"),!0}catch{return!1}}function m(G,B,q,K){let Y=[],Q=K.join(" ");for(let X of G)if(Y.push({src:`${B}/icon-${X}x${X}.png`,sizes:`${X}x${X}`,type:"image/png",purpose:Q}),q)Y.push({src:`${B}/icon-${X}x${X}.webp`,sizes:`${X}x${X}`,type:"image/webp",purpose:Q});return Y}function g(G){return G.map((B)=>({name:B.name,short_name:B.shortName,description:B.description,url:B.url,icons:B.icons?.map((q)=>({src:q.src,sizes:q.sizes,type:q.type}))}))}function h(G){let B=G.pwa?.shareTarget;if(!B?.enabled)return;let q={action:B.action||"/share",method:B.method||"POST",enctype:B.enctype||"multipart/form-data",params:{title:B.params?.title||"title",text:B.params?.text||"text",url:B.params?.url||"url"}};if(B.acceptFiles&&B.acceptFiles.length>0)q.params.files=B.acceptFiles.map((K)=>({name:K.name,accept:K.accept}));return q}function c(G){let B=G.pwa?.fileHandlers;if(!B?.enabled||!B.accept)return;let q=[{action:B.action||"/",accept:B.accept,launch_type:B.launchType||"single-client"}];if(B.icons)q[0].icons=B.icons.map((K)=>({src:K.src,sizes:K.sizes,type:K.type}));return q}function l(G){let B=G.pwa?.protocolHandlers;if(!B||B.length===0)return;return B.map((q)=>({protocol:q.protocol,url:q.url}))}function u(G){let B=G.pwa;if(!B?.enabled||!B.manifest)return null;let{manifest:q,icons:K}=B,Y=K?.sizes||[72,96,128,144,152,192,384,512],Q=K?.outputDir?`/${K.outputDir}`:"/pwa-icons",X=K?.generateWebP??!0,j=K?.purpose||["any","maskable"],J={name:q.name,short_name:q.shortName||q.name,description:q.description,start_url:q.startUrl||"/",display:q.display||"standalone",display_override:q.displayOverride,orientation:q.orientation,theme_color:q.themeColor,background_color:q.backgroundColor,scope:q.scope||"/",lang:q.lang,dir:q.dir,id:q.id,categories:q.categories,icons:m(Y,Q,X,j)};if(q.shortcuts&&q.shortcuts.length>0)J.shortcuts=g(q.shortcuts);if(q.screenshots&&q.screenshots.length>0)J.screenshots=q.screenshots.map((U)=>({src:U.src,sizes:U.sizes,type:U.type,label:U.label,form_factor:U.platform}));let y=h(G);if(y)J.share_target=y;let V=c(G);if(V)J.file_handlers=V;let R=l(G);if(R)J.protocol_handlers=R;if(q.launchHandler)J.launch_handler={client_mode:q.launchHandler};if(q.handleLinks)J.handle_links=q.handleLinks;if(q.edgeSidePanel?.enabled)J.edge_side_panel={preferred_width:q.edgeSidePanel.preferredWidth};return J}function M(G){let B=u(G);if(!B)return"";let q=JSON.parse(JSON.stringify(B));return JSON.stringify(q,null,2)}function i(G,B){return{...B,...G,shortcuts:G.shortcuts||B.shortcuts,screenshots:G.screenshots||B.screenshots,categories:G.categories||B.categories}}function s(G){let B=[],q=G.pwa;if(!q?.enabled)return B;let K=q.manifest;if(!K)return B.push("PWA manifest configuration is missing"),B;if(!K.name)B.push("Manifest name is required");let Y=["fullscreen","standalone","minimal-ui","browser"];if(K.display&&!Y.includes(K.display))B.push(`Invalid display mode: ${K.display}. Must be one of: ${Y.join(", ")}`);let Q=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(K.orientation&&!Q.includes(K.orientation))B.push(`Invalid orientation: ${K.orientation}`);let X=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(K.themeColor&&!X.test(K.themeColor))B.push(`Invalid theme color: ${K.themeColor}. Must be a valid hex color.`);if(K.backgroundColor&&!X.test(K.backgroundColor))B.push(`Invalid background color: ${K.backgroundColor}. Must be a valid hex color.`);if(q.shareTarget?.enabled){if(!q.shareTarget.action)B.push("Share target action URL is required")}if(q.fileHandlers?.enabled){if(!q.fileHandlers.accept||Object.keys(q.fileHandlers.accept).length===0)B.push("File handlers must specify accepted MIME types")}if(q.protocolHandlers)for(let j of q.protocolHandlers){if(!j.protocol)B.push("Protocol handler missing protocol");if(!j.url||!j.url.includes("%s"))B.push(`Protocol handler URL must contain %s placeholder: ${j.protocol}`)}return B}import A from"path";async function b(G){let B=G.pwa?.offline;if(!B?.enabled)return"";if(B.page){let q=A.isAbsolute(B.page)?B.page:A.resolve(process.cwd(),B.page);if(await Bun.file(q).exists())try{let{processDirectives:K}=await import("./chunk-rfpg019d.js"),Y=await Bun.file(q).text();return await K(Y,{},q,G,new Set)}catch(K){console.warn(`[PWA] Failed to process custom offline page: ${K}`)}else console.warn(`[PWA] Custom offline page not found: ${q}`)}return f(G)}function f(G){let B=G.pwa?.offline,q=G.pwa?.manifest,K=B?.fallbackTitle||"You are offline",Y=B?.fallbackMessage||"Please check your internet connection and try again.",Q=q?.themeColor||"#4f46e5",X=q?.shortName||q?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bk as Tq,wk as Bq,xk as Hq}from"./chunk-n58aem37.js";import{Ck as Uq,Dk as Iq,Ek as Eq}from"./chunk-c0n802j1.js";import{$k as _q,_k as Nq}from"./chunk-
|
|
2
|
+
import{Bk as Tq,wk as Bq,xk as Hq}from"./chunk-n58aem37.js";import{Ck as Uq,Dk as Iq,Ek as Eq}from"./chunk-c0n802j1.js";import{$k as _q,_k as Nq}from"./chunk-8309r1ea.js";import"./chunk-ncvd7673.js";import{Ap as Xq,Bq as y,Gm as Aq,_r as l,jq as c,mq as Oq}from"./chunk-h1jzzy6t.js";import"./chunk-by2p4by1.js";import"./chunk-a2ppgamd.js";import"./chunk-dmzc008f.js";import"./chunk-nstqd54d.js";import{Ws as zq}from"./chunk-vy3brhf3.js";import"./chunk-kqjxwz6c.js";import{gt as f}from"./chunk-t0jzk81v.js";import"./chunk-njc6sven.js";import"./chunk-70v7vvry.js";import"./chunk-myh6j9ab.js";import{ju as Wq,ku as Yq,lu as Vq,mu as jq,nu as Gq,ou as Lq}from"./chunk-bqdbf8k2.js";import"./chunk-ge69r310.js";import{Eu as k}from"./chunk-q891e1vj.js";import B from"fs";import j from"path";import{createHash as wq}from"crypto";function Sq(q){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(q).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return q}}var vq=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function xq(q){return Bun.hash(q).toString(16)}function Jq(q,Z={}){if(!q.includes('type="stx/island"'))return{html:q,chunks:[]};let $=new Map,Q=q.replace(vq,(J,W,z,X)=>{let N=X.trim();if(!N)return J;if(/\bdata-stx-src=/.test(z))return J;if(Z.minify)N=Sq(N);let O=xq(N);if(!$.has(O))$.set(O,N);let H=Z.integrity?` data-stx-integrity="sha384-${wq("sha384").update(N).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${W}" data-stx-src="/_stx/islands/${O}.js"${H}${z}></script>`}),K=Array.from($,([J,W])=>({hash:J,code:W}));return{html:Q,chunks:K}}var yq=new Set(["visible","idle"]);function Qq(q){if(!q.includes("data-stx-src="))return q;let Z=new Map,$=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,Q;while((Q=$.exec(q))!==null)Z.set(Q[1],Q[2]);let K=new Set,J=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,W;while((W=J.exec(q))!==null)if(yq.has(Z.get(W[1])||""))K.add(W[2]);let z=q.lastIndexOf("</head>");if(K.size===0||z===-1)return q;let X=Array.from(K).filter((N)=>!q.includes(`rel="prefetch" href="${N}"`)).map((N)=>`<link rel="prefetch" href="${N}" as="script">`).join("");if(!X)return q;return q.slice(0,z)+X+q.slice(z)}var Pq=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function u(q){let Z=q.trim();if(!Z)return null;let $=/^https?:\/\//i.test(Z)?Z:`https://${Z}`;try{return new URL($).origin+new URL($).pathname.replace(/\/$/,"")}catch{return null}}function Cq(q){for(let Z of Pq){let $=q[Z];if(!$)continue;let Q=u($);if(Q)return{url:Q,source:"env",via:Z}}return null}function Zq(q){if(!q||typeof q!=="object")return null;let Z=q,$=Z.site?.url??Z.url??Z.app?.url;return typeof $==="string"?u($):null}async function gq(q){let{existsSync:Z}=await import("fs"),$=await import("path");for(let Q of["site.config.ts","site.config.js",".config/site.config.ts"]){let K=$.resolve(q,Q);if(!Z(K))continue;try{let J=await import(K),W=Zq(J.default??J);if(W)return W}catch{}}return null}async function $q(q={}){let Z=q.cwd??process.cwd(),$=q.env??process.env;if(q.explicit){let W=u(q.explicit);if(W)return{url:W,source:"option"}}let Q=Zq(q.stxConfig);if(Q)return{url:Q,source:"stx.config",via:"site.url"};let K=await gq(Z);if(K)return{url:K,source:"site.config",via:"url"};let J=Cq($);if(J)return J;return{url:"http://localhost",source:"fallback"}}function Kq(){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 Dq{cacheDir;cache=new Map;loaded=!1;salt;constructor(q,Z=""){this.cacheDir=q,this.salt=Z}async load(){if(this.loaded)return;let q=j.join(this.cacheDir,"build-cache.json");if(await Bun.file(q).exists())try{let Z=JSON.parse(await Bun.file(q).text());for(let[$,Q]of Object.entries(Z))this.cache.set($,Q)}catch{}this.loaded=!0}async save(){await B.promises.mkdir(this.cacheDir,{recursive:!0});let q=j.join(this.cacheDir,"build-cache.json"),Z={};for(let[$,Q]of this.cache)Z[$]=Q;await Bun.write(q,JSON.stringify(Z))}getHash(q,Z){let $=B.statSync(q),Q=`${this.salt}|${q}:${$.mtimeMs}`;for(let J of Z)if(B.existsSync(J)){let W=B.statSync(J);Q+=`:${J}:${W.mtimeMs}`}let K=0;for(let J=0;J<Q.length;J++){let W=Q.charCodeAt(J);K=(K<<5)-K+W,K=K&K}return Math.abs(K).toString(36)}get(q,Z){let $=this.cache.get(q);if(!$)return null;let Q=this.getHash(Z,$.dependencies??[]);if($.hash!==Q)return this.cache.delete(q),null;return $.html}set(q,Z,$,Q){let K=this.getHash(Z,$);this.cache.set(q,{hash:K,html:Q,generatedAt:Date.now(),dependencies:$})}}class Fq{cacheDir;constructor(q){this.cacheDir=q}getFilePath(q){let Z=q.replace(/[^a-zA-Z0-9]/g,"_")+".json";return j.join(this.cacheDir,"isr",Z)}async get(q){let Z=this.getFilePath(q);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set(q,Z){let $=this.getFilePath(q);await B.promises.mkdir(j.dirname($),{recursive:!0}),await Bun.write($,JSON.stringify(Z))}async invalidate(q){let Z=this.getFilePath(q);if(await Bun.file(Z).exists())await B.promises.unlink(Z)}async invalidatePattern(q){let Z=j.join(this.cacheDir,"isr");if(!B.existsSync(Z))return;let $=await B.promises.readdir(Z);for(let Q of $){let K=Q.replace(/_/g,"/").replace(".json","");if(q.test(K))await B.promises.unlink(j.join(Z,Q))}}async needsRevalidation(q){let Z=await this.get(q);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function fq(q){try{let $=(await Bun.file(q).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!$)return null;let Q=$[1];if(!Q.includes("getStaticPaths"))return null;let K=Q.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!K)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${K[1]}
|
|
@@ -41,7 +41,7 @@ ${q.map((Q)=>{let K=new URL(Q.loc,Z).href,J=` <url>
|
|
|
41
41
|
${$.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function sq(q={}){let Z=Date.now();_q();let $=await l(process.cwd()),Q=$.build||{},K=await $q({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Kq());let J={pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||f(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},z=new Set,X=0,N={},O={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&B.existsSync(J.outputDir))await B.promises.rm(J.outputDir,{recursive:!0});await B.promises.mkdir(J.outputDir,{recursive:!0});let _=J.cacheSalt;if(!_){let{resolveUserCrosswindConfig:Y,fingerprintConfig:G}=await import("./chunk-
|
|
44
|
+
</rss>`}async function sq(q={}){let Z=Date.now();_q();let $=await l(process.cwd()),Q=$.build||{},K=await $q({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Kq());let J={pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||f(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},z=new Set,X=0,N={},O={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&B.existsSync(J.outputDir))await B.promises.rm(J.outputDir,{recursive:!0});await B.promises.mkdir(J.outputDir,{recursive:!0});let _=J.cacheSalt;if(!_){let{resolveUserCrosswindConfig:Y,fingerprintConfig:G}=await import("./chunk-v7fsv3wn.js");try{_=G(await Y(process.cwd()))}catch{}}let L=new Dq(J.cacheDir,_);if(J.cache)await L.load();try{let{generateCrosswindCSS:Y}=await import("./chunk-v7fsv3wn.js");await Y('<div class="bg-black"></div>')}catch{}Wq();let m=$?.routeMiddleware?.dir||"middleware";await Vq(process.cwd(),m);let p=Yq();if(p.length>0)console.log(`Loaded ${p.length} middleware: ${p.join(", ")}`);let Mq=$?.routeMiddleware?.global||[];Tq($?.layoutsDir,f(process.cwd()));let n=c(".",{pagesDir:J.pagesDir});console.log(`Found ${n.length} routes`);let P=[];for(let Y of n){let G=await mq(Y);for(let A of G)P.push({route:Y,url:A.url,params:A.params,props:A.props,revalidate:A.revalidate??J.revalidate})}W.totalPages=P.length;try{let{warmImagePlaceholders:Y}=await import("./chunk-z87q7ee7.js"),{stateDir:G}=await import("./chunk-hrdps19s.js"),A=await Y(J.publicDir,{cachePath:G(process.cwd(),"image-placeholders.json")});if(A>0)console.log(`Derived ${A} image placeholder(s)`)}catch{}console.log(`Generating ${W.totalPages} pages...`);let w=[],i=[];for(let Y=0;Y<P.length;Y+=J.concurrency)i.push(P.slice(Y,Y+J.concurrency));for(let Y of i)await Promise.all(Y.map(async(G)=>{let{route:A,url:V,params:S,props:bq,revalidate:a}=G;try{await J.hooks.onPageStart?.(V);let F=await Bun.file(A.filePath).text(),R=tq(F),kq=R?.middleware?Array.isArray(R.middleware)?R.middleware:[R.middleware]:[],r=[...Mq,...kq];if(r.length>0){let D=jq(V,S,R||{}),M=Gq(D,null,void 0,{isServer:!0}),E=await Lq(r,M);if(E.redirect){let U=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,x=eq(String(U),V),b=qJ(V,J);await B.promises.mkdir(j.dirname(b),{recursive:!0}),await Bun.write(b,x),W.successCount++,W.pages.push({route:V,outputPath:b,size:Buffer.byteLength(x),cached:!1}),w.push({loc:V,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${V} \u2192 redirect to ${U}`);return}if(E.abort){let U=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${V} \u2014 middleware aborted: ${U}`);return}}let t=F.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(t)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${t[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:S})){console.warn(`Validation failed for ${V}, skipping...`);return}}catch{}let I=null,e=!1;if(J.cache){if(I=L.get(V,A.filePath),I)e=!0,W.cachedCount++}if(!I){let D=await Rq(A,S,bq,J,$);if(I=D.html,J.failOnIncludeError&&D.includeFailures.length>0)throw Error(`${D.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
|
@@ -635,6 +635,23 @@ export interface StxConfig {
|
|
|
635
635
|
* which is far harder to diagnose than a 404.
|
|
636
636
|
*/
|
|
637
637
|
fallbackLayoutsDir?: string;
|
|
638
|
+
/**
|
|
639
|
+
* Where to look for a component `componentsDir` does not have.
|
|
640
|
+
*
|
|
641
|
+
* The component-side counterpart of `fallbackLayoutsDir`, and it exists for
|
|
642
|
+
* the same reason. A framework ships default components and lets an app
|
|
643
|
+
* override them by name: the app's directory is `componentsDir` and wins,
|
|
644
|
+
* anything it does not define falls back here.
|
|
645
|
+
*
|
|
646
|
+
* Without it, a host had one bad choice to make. Point `componentsDir` at
|
|
647
|
+
* the framework defaults and an app could never override a component - its
|
|
648
|
+
* own file was never even looked for. Point it at the app and every
|
|
649
|
+
* framework component stops resolving. Stacks' production server took the
|
|
650
|
+
* first option, so an app that had written its own `NativeAppShell.stx`
|
|
651
|
+
* still rendered the framework's, and the only symptom was that file's
|
|
652
|
+
* relative includes failing with ENOENT paths the author had never written.
|
|
653
|
+
*/
|
|
654
|
+
fallbackComponentsDir?: string;
|
|
638
655
|
/**
|
|
639
656
|
* Path to the stores directory, resolved against `root`.
|
|
640
657
|
*
|
package/dist/utils.js
CHANGED
|
@@ -379,16 +379,17 @@ export async function userComponentFileExists(componentPath, componentsDir, pare
|
|
|
379
379
|
push(options._rootComponentsDir);
|
|
380
380
|
push(path.join(path.dirname(parentFilePath), "components"));
|
|
381
381
|
push(options.componentsDir);
|
|
382
|
-
const pluginDirs = options._pluginComponentDirs;
|
|
383
|
-
if (Array.isArray(pluginDirs))
|
|
384
|
-
for (const dir of pluginDirs)
|
|
385
|
-
push(typeof dir === "string" ? dir : null);
|
|
386
382
|
if (configuredRoot) {
|
|
387
383
|
push(path.resolve(configuredRoot, "resources/views/components"));
|
|
388
384
|
push(path.resolve(configuredRoot, "resources/components"));
|
|
389
385
|
push(path.resolve(configuredRoot, "src/components"));
|
|
390
386
|
push(path.resolve(configuredRoot, "components"));
|
|
391
387
|
}
|
|
388
|
+
const pluginDirs = options._pluginComponentDirs;
|
|
389
|
+
if (Array.isArray(pluginDirs))
|
|
390
|
+
for (const dir of pluginDirs)
|
|
391
|
+
push(typeof dir === "string" ? dir : null);
|
|
392
|
+
push(options.fallbackComponentsDir);
|
|
392
393
|
if (baseName.startsWith("./") || baseName.startsWith("../"))
|
|
393
394
|
return fileExists(path.resolve(path.dirname(parentFilePath), `${baseName}.stx`));
|
|
394
395
|
for (const dir of searchDirs) {
|
|
@@ -466,12 +467,6 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
466
467
|
searchDirs.push(parentRelative);
|
|
467
468
|
if (options.componentsDir && options.componentsDir !== componentsDir && !searchDirs.includes(options.componentsDir))
|
|
468
469
|
searchDirs.push(options.componentsDir);
|
|
469
|
-
const pluginDirs = options._pluginComponentDirs;
|
|
470
|
-
if (Array.isArray(pluginDirs)) {
|
|
471
|
-
for (const dir of pluginDirs)
|
|
472
|
-
if (typeof dir === "string" && !searchDirs.includes(dir))
|
|
473
|
-
searchDirs.push(dir);
|
|
474
|
-
}
|
|
475
470
|
const configuredRoot = typeof options.root === "string" ? path.resolve(options.root) : void 0, resolveBase = configuredRoot ?? path.dirname(parentFilePath), fallbackDirs = [];
|
|
476
471
|
if (configuredRoot) {
|
|
477
472
|
fallbackDirs.push(path.resolve(configuredRoot, "resources/views/components"));
|
|
@@ -483,6 +478,14 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
483
478
|
for (const fallback of fallbackDirs)
|
|
484
479
|
if (!searchDirs.includes(fallback))
|
|
485
480
|
searchDirs.push(fallback);
|
|
481
|
+
const pluginDirs = options._pluginComponentDirs;
|
|
482
|
+
if (Array.isArray(pluginDirs)) {
|
|
483
|
+
for (const dir of pluginDirs)
|
|
484
|
+
if (typeof dir === "string" && !searchDirs.includes(dir))
|
|
485
|
+
searchDirs.push(dir);
|
|
486
|
+
}
|
|
487
|
+
if (options.fallbackComponentsDir && !searchDirs.includes(options.fallbackComponentsDir))
|
|
488
|
+
searchDirs.push(options.fallbackComponentsDir);
|
|
486
489
|
const normalizedSearchDirs = [...new Set(searchDirs.map((dir) => {
|
|
487
490
|
if (!dir)
|
|
488
491
|
return dir;
|
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.230",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,12 +117,12 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@cwcss/crosswind": "^0.2.14",
|
|
119
119
|
"@stacksjs/clapp": "^0.2.0",
|
|
120
|
-
"@stacksjs/desktop": "0.2.
|
|
121
|
-
"@stacksjs/sanitizer": "0.2.
|
|
120
|
+
"@stacksjs/desktop": "0.2.230",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.230",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.230",
|
|
124
124
|
"bunfig": "^0.15.17",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.230",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.2.11",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|