@stacksjs/stx 0.2.211 → 0.2.212
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-v5x6c698.js → chunk-0rpqx6xa.js} +1 -1
- package/dist/{chunk-1jeyh1e2.js → chunk-1hx2z3m0.js} +1 -1
- package/dist/{chunk-x2t441ge.js → chunk-1wfvhxjz.js} +1 -1
- package/dist/{chunk-kjw1ha92.js → chunk-2vdxfjxw.js} +1 -1
- package/dist/{chunk-kmgs48jy.js → chunk-3z8tp7v4.js} +1 -1
- package/dist/{chunk-r5hnhtp1.js → chunk-5ckn8vbq.js} +1 -1
- package/dist/{chunk-d9b00zcd.js → chunk-62gc6qg9.js} +1 -1
- package/dist/{chunk-ba6v2wh0.js → chunk-655pb2nj.js} +1 -1
- package/dist/{chunk-hdg7t3zs.js → chunk-66630av9.js} +1 -1
- package/dist/{chunk-2kjp90p2.js → chunk-7jq78m57.js} +1 -1
- package/dist/{chunk-qph3esct.js → chunk-9whrwhx4.js} +1 -1
- package/dist/{chunk-c18nh1et.js → chunk-amv1v5qf.js} +1 -1
- package/dist/{chunk-f7fhjvbe.js → chunk-c11nnxkg.js} +1 -1
- package/dist/{chunk-kregsntr.js → chunk-cf6npetr.js} +1 -1
- package/dist/{chunk-v1v3fxq1.js → chunk-d8hzg54c.js} +2 -2
- package/dist/{chunk-47mx5vng.js → chunk-drzrf2t7.js} +1 -1
- package/dist/{chunk-2bkqbmkn.js → chunk-e4h9zd1m.js} +1 -1
- package/dist/{chunk-81w2xqas.js → chunk-ejrtygcb.js} +1 -1
- package/dist/{chunk-d12xfcjd.js → chunk-em4wy7zv.js} +1 -1
- package/dist/{chunk-mghyceb1.js → chunk-eva1mgf5.js} +1 -1
- package/dist/{chunk-vkpmnn26.js → chunk-fc3g2z0p.js} +1 -1
- package/dist/{chunk-6xd5p5v3.js → chunk-hnrtw0rd.js} +8 -8
- package/dist/{chunk-y8mg8dem.js → chunk-hq60td8b.js} +1 -1
- package/dist/{chunk-td1cz8ms.js → chunk-hz1jcwdb.js} +1 -1
- package/dist/{chunk-8bmsw6gq.js → chunk-mm0f84gm.js} +185 -185
- package/dist/{chunk-1qkk4mrm.js → chunk-nrksd914.js} +1 -1
- package/dist/{chunk-evjs9zqm.js → chunk-nvfawtpq.js} +1 -1
- package/dist/{chunk-2md83wew.js → chunk-r7qzjt0h.js} +1 -1
- package/dist/{chunk-5gb8d966.js → chunk-s9pa2var.js} +1 -1
- package/dist/{chunk-mpt8ed9w.js → chunk-sgxjx75w.js} +1 -1
- package/dist/{chunk-591jpt6f.js → chunk-sk8ybwpe.js} +1 -1
- package/dist/{chunk-vtqej9yr.js → chunk-t82z0cbv.js} +1 -1
- package/dist/{chunk-85144680.js → chunk-xerx4bn9.js} +2 -2
- package/dist/{chunk-ztz7tdb0.js → chunk-xgxjp647.js} +1 -1
- package/dist/{chunk-vhvfja74.js → chunk-y8m9n9v6.js} +1 -1
- package/dist/{chunk-qfsgw9by.js → chunk-yb6f8ey1.js} +1 -1
- package/dist/{chunk-5ya35fex.js → chunk-yhn2saa7.js} +1 -1
- package/dist/{chunk-xcf62bdq.js → chunk-yvgjys59.js} +1 -1
- package/dist/{chunk-3bgyqx5b.js → chunk-yxefre1s.js} +1 -1
- package/dist/{chunk-gyxe9fzm.js → chunk-znsffkmk.js} +1 -1
- package/dist/{chunk-dt787jv4.js → chunk-zsfpwqrt.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/component-renderer.d.ts +2 -22
- package/dist/component-renderer.js +3 -4
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/loops.js +8 -2
- package/dist/pwa.js +1 -1
- package/dist/safe-evaluator.d.ts +22 -0
- package/dist/safe-evaluator.js +3 -0
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* @module component-renderer
|
|
18
18
|
*/
|
|
19
19
|
import type { StxOptions } from './types';
|
|
20
|
+
import { freeIdentifiers } from './safe-evaluator';
|
|
20
21
|
/**
|
|
21
22
|
* Process ES `import { A, B } from '<spec>'` statements inside `<script>` tags
|
|
22
23
|
* for component tag registration. Registers each named import as a tag pointing
|
|
@@ -30,29 +31,8 @@ import type { StxOptions } from './types';
|
|
|
30
31
|
* resolves to a single `.stx` file.
|
|
31
32
|
* - Named imports referencing non-`.stx` exports are left untouched in the script.
|
|
32
33
|
*/
|
|
34
|
+
export { freeIdentifiers };
|
|
33
35
|
export declare function processESImports(template: string, context: Record<string, any>, filePath: string, options: StxOptions, dependencies: Set<string>): Promise<string>;
|
|
34
|
-
/**
|
|
35
|
-
* The variables an expression actually reads from its surrounding scope.
|
|
36
|
-
*
|
|
37
|
-
* Deliberately not every identifier in the string. A property name is not a
|
|
38
|
-
* variable, and treating it as one is how `:label="section.label"` came to be
|
|
39
|
-
* misclassified: the section had no `label`, the expression evaluated to
|
|
40
|
-
* `undefined`, and the check for "does this reference something the server
|
|
41
|
-
* does not have?" found `label` — a key, not a binding — reported it as
|
|
42
|
-
* unresolved, and shipped the expression to the client as a reactive prop.
|
|
43
|
-
*
|
|
44
|
-
* On the client it could never resolve either: `section` is a server-side
|
|
45
|
-
* `@foreach` variable that does not exist in the browser. So every page with a
|
|
46
|
-
* component in a loop and one absent optional prop logged stx's own hydration
|
|
47
|
-
* invariant, once per prop, forever.
|
|
48
|
-
*
|
|
49
|
-
* Three things are stripped before identifiers are read: string contents, so a
|
|
50
|
-
* word inside a quote is not a variable; member access after `.` or `?.`, so a
|
|
51
|
-
* property is not a variable; and object-literal keys, for the same reason.
|
|
52
|
-
* What is left is the free variables, which is the question actually being
|
|
53
|
-
* asked.
|
|
54
|
-
*/
|
|
55
|
-
export declare function freeIdentifiers(expression: string): string[];
|
|
56
36
|
/**
|
|
57
37
|
* Unified component processing entry point.
|
|
58
38
|
*
|
|
@@ -4,7 +4,7 @@ import { registerBuiltins } from "./builtins/index.js";
|
|
|
4
4
|
import { decodeAttributeEntities, decodeStxProp, findComponentTags, parseMultilineAttributes, pascalToKebab, restoreStashedScripts, stashScriptElements } from "./component-processing.js";
|
|
5
5
|
import { maskAtElementPosition, matchHtmlComment } from "./html-masking.js";
|
|
6
6
|
import { renderComponentWithSlot, userComponentFileExists } from "./utils.js";
|
|
7
|
-
import { createSafeFunction, isExpressionSafe, safeEvaluateObject } from "./safe-evaluator.js";
|
|
7
|
+
import { createSafeFunction, isExpressionSafe, safeEvaluateObject, freeIdentifiers } from "./safe-evaluator.js";
|
|
8
8
|
import { BOOLEAN_ATTRIBUTE_SENTINEL } from "./prop-sentinels.js";
|
|
9
9
|
import { COMPONENT_PASSTHROUGH_X_ATTRS } from "./runtime-globals.js";
|
|
10
10
|
import { stripCommentsAndLiterals } from "./strip-literals.js";
|
|
@@ -439,6 +439,8 @@ function resolvePackageDir(spec, fromDir) {
|
|
|
439
439
|
dir = parent;
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
+
|
|
443
|
+
export { freeIdentifiers };
|
|
442
444
|
export async function processESImports(template, context, filePath, options, dependencies) {
|
|
443
445
|
if (!template.includes("import"))
|
|
444
446
|
return template;
|
|
@@ -670,9 +672,6 @@ async function processCustomElementTags(template, context, filePath, options, de
|
|
|
670
672
|
return result;
|
|
671
673
|
}
|
|
672
674
|
}
|
|
673
|
-
export function freeIdentifiers(expression) {
|
|
674
|
-
return expression.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g, " ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g, " ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g, "$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g) || [];
|
|
675
|
-
}
|
|
676
675
|
function emitClientReactiveAttrs(html, clientReactive) {
|
|
677
676
|
const componentControlBindings = new Set(["if", "for"]), rootStructuralBindings = new Set(["show"]), rootBindings = Object.entries(clientReactive).filter(([key]) => !componentControlBindings.has(key)), parentBindings = rootBindings.filter(([key]) => !rootStructuralBindings.has(key)).map(([key]) => pascalToKebab(key)).join(" ");
|
|
678
677
|
let output = html;
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Tj as Nj,Uj as wj,Vj as Aj}from"./chunk-hncp9gz6.js";import{$j as _j,Xj as Uj,Yj as Xj,Zj as Yj,_j as Zj,ak as $j,bk as qj,ck as Fj,dk as Oj,ek as Vj,fk as Ij,gk as Qj,hk as Wj,ik as Kj}from"./chunk-
|
|
2
|
+
import{Tj as Nj,Uj as wj,Vj as Aj}from"./chunk-hncp9gz6.js";import{$j as _j,Xj as Uj,Yj as Xj,Zj as Yj,_j as Zj,ak as $j,bk as qj,ck as Fj,dk as Oj,ek as Vj,fk as Ij,gk as Qj,hk as Wj,ik as Kj}from"./chunk-1hx2z3m0.js";import"./chunk-d8hzg54c.js";import"./chunk-mm0f84gm.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-yb6f8ey1.js";import"./chunk-m2mhtpwy.js";import"./chunk-6xg3j487.js";import"./chunk-q4se9rtw.js";import"./chunk-1nm2xrvq.js";import"./chunk-z47tw39z.js";import"./chunk-3wd9kfyz.js";import"./chunk-trtm887x.js";var I=new Map,Q=new Map;function L(j,B){let G=B?.id||g(j),J=h(j),U=I.get(G);if(U&&U.hash===J)return U;let X=S(j),Z=y(j),Y=T(j),_=v(X),{staticParts:q,dynamicParts:$}=C(X),F=u(j),O={id:G,hash:J,tree:X,scripts:Z,styles:Y,staticParts:q,dynamicParts:$,dependencies:F,metadata:_};return I.set(G,O),O}async function r(j,B={},G={}){let J=performance.now();if(G.cache){let Y=`${j.id}:${JSON.stringify(B)}`,_=Q.get(Y);if(_&&Date.now()-_.timestamp<(G.cacheTTL||60000))return{html:_.html,styles:j.styles.join(`
|
|
3
3
|
`),scripts:j.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:_.html.length,componentCount:j.metadata.componentCount}}}let U;if(G.streaming)U=await H(j.tree,B);else U=W(j.tree,B);let X;if(G.hydrate){let Y=k(U,j,B);U=Y.html,X=Y.data}if(G.minify)U=x(U);if(G.cache){let Y=`${j.id}:${JSON.stringify(B)}`;Q.set(Y,{html:U,timestamp:Date.now()})}let Z=performance.now()-J;return{html:U,styles:j.styles.join(`
|
|
5
5
|
`),scripts:j.scripts.join(`
|
package/dist/craft.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Tj as Nj,Uj as wj,Vj as Aj}from"./chunk-hncp9gz6.js";import{$j as _j,Xj as Uj,Yj as Xj,Zj as Yj,_j as Zj,ak as $j,bk as qj,ck as Fj,dk as Oj,ek as Vj,fk as Ij,gk as Qj,hk as Wj,ik as Kj}from"./chunk-
|
|
2
|
+
import{Tj as Nj,Uj as wj,Vj as Aj}from"./chunk-hncp9gz6.js";import{$j as _j,Xj as Uj,Yj as Xj,Zj as Yj,_j as Zj,ak as $j,bk as qj,ck as Fj,dk as Oj,ek as Vj,fk as Ij,gk as Qj,hk as Wj,ik as Kj}from"./chunk-1hx2z3m0.js";import"./chunk-d8hzg54c.js";import"./chunk-mm0f84gm.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import"./chunk-yb6f8ey1.js";import"./chunk-m2mhtpwy.js";import"./chunk-6xg3j487.js";import"./chunk-q4se9rtw.js";import"./chunk-1nm2xrvq.js";import"./chunk-z47tw39z.js";import"./chunk-3wd9kfyz.js";import"./chunk-trtm887x.js";var I=new Map,Q=new Map;function L(j,B){let G=B?.id||g(j),J=h(j),U=I.get(G);if(U&&U.hash===J)return U;let X=S(j),Z=y(j),Y=T(j),_=v(X),{staticParts:q,dynamicParts:$}=C(X),F=u(j),O={id:G,hash:J,tree:X,scripts:Z,styles:Y,staticParts:q,dynamicParts:$,dependencies:F,metadata:_};return I.set(G,O),O}async function r(j,B={},G={}){let J=performance.now();if(G.cache){let Y=`${j.id}:${JSON.stringify(B)}`,_=Q.get(Y);if(_&&Date.now()-_.timestamp<(G.cacheTTL||60000))return{html:_.html,styles:j.styles.join(`
|
|
3
3
|
`),scripts:j.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:_.html.length,componentCount:j.metadata.componentCount}}}let U;if(G.streaming)U=await H(j.tree,B);else U=W(j.tree,B);let X;if(G.hydrate){let Y=k(U,j,B);U=Y.html,X=Y.data}if(G.minify)U=x(U);if(G.cache){let Y=`${j.id}:${JSON.stringify(B)}`;Q.set(Y,{html:U,timestamp:Date.now()})}let Z=performance.now()-J;return{html:U,styles:j.styles.join(`
|
|
5
5
|
`),scripts:j.scripts.join(`
|
package/dist/loops.js
CHANGED
|
@@ -2,7 +2,7 @@ import { processConditionals } from "./conditionals.js";
|
|
|
2
2
|
import { ErrorCodes, inlineError } from "./error-handling.js";
|
|
3
3
|
import { processExpressions } from "./expressions.js";
|
|
4
4
|
import { findDirectiveBlocks, findMatchingDelimiter } from "./parser/index.js";
|
|
5
|
-
import { createSafeFunction, isExpressionSafe, isForExpressionSafe, sanitizeExpression, safeEvaluate, safeEvaluateObject } from "./safe-evaluator.js";
|
|
5
|
+
import { createSafeFunction, freeIdentifiers, isExpressionSafe, isForExpressionSafe, sanitizeExpression, safeEvaluate, safeEvaluateObject } from "./safe-evaluator.js";
|
|
6
6
|
const DEFAULT_MAX_WHILE_ITERATIONS = 1000, DEFAULT_USE_ALT_LOOP_VARIABLE = !1;
|
|
7
7
|
function preEvaluateIncludeData(content, ctx) {
|
|
8
8
|
const pattern = /@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g;
|
|
@@ -129,7 +129,13 @@ function processPropBindings(content, context) {
|
|
|
129
129
|
try {
|
|
130
130
|
const contextKeys = Object.keys(context), contextValues = Object.values(context);
|
|
131
131
|
sanitizeExpression(expression);
|
|
132
|
-
const value = createSafeFunction(expression, contextKeys)(...contextValues), serialized = JSON.stringify(value)
|
|
132
|
+
const value = createSafeFunction(expression, contextKeys)(...contextValues), serialized = JSON.stringify(value);
|
|
133
|
+
if (serialized === void 0) {
|
|
134
|
+
if (!freeIdentifiers(expression).some((name) => !(name in context)))
|
|
135
|
+
return "";
|
|
136
|
+
return match;
|
|
137
|
+
}
|
|
138
|
+
const encoded = Buffer.from(serialized, "utf8").toString("base64");
|
|
133
139
|
return `__stx_${propName}="${encoded}"`;
|
|
134
140
|
} catch (error) {
|
|
135
141
|
return match;
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Bk as wq,Ck as dq,Dk as Cq,Ek as mq,Fk as gq}from"./chunk-yf3bmmkk.js";import{Gk as S,Hk as Tq,Ik as _q,Jk as z,Kk as D,Lk as P,Mk as kq,Nk as vq,Ok as w,Pk as Iq,Qk as d,Rk as Hq,Sk as Oq,Tk as Mq}from"./chunk-53ajah3v.js";import{$t as Aq,au as bq,bu as Sq,cu as zq,du as Dq,eu as Pq}from"./chunk-3wd9kfyz.js";import{iu as N}from"./chunk-trtm887x.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-eva1mgf5.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/safe-evaluator.d.ts
CHANGED
|
@@ -120,6 +120,28 @@ export declare function safeEvaluateObject(expression: string, context: Record<s
|
|
|
120
120
|
* const result = fn(1, 2) // returns 3
|
|
121
121
|
* ```
|
|
122
122
|
*/
|
|
123
|
+
/**
|
|
124
|
+
* The variables an expression actually reads from its surrounding scope.
|
|
125
|
+
*
|
|
126
|
+
* Deliberately not every identifier in the string. A property name is not a
|
|
127
|
+
* variable, and treating it as one is how `:label="section.label"` came to be
|
|
128
|
+
* misclassified: the section had no `label`, the expression evaluated to
|
|
129
|
+
* `undefined`, and the check for "does this reference something the server
|
|
130
|
+
* does not have?" found `label` — a key, not a binding — reported it as
|
|
131
|
+
* unresolved, and shipped the expression to the client as a reactive prop.
|
|
132
|
+
*
|
|
133
|
+
* On the client it could never resolve either: `section` is a server-side
|
|
134
|
+
* `@foreach` variable that does not exist in the browser. So every page with a
|
|
135
|
+
* component in a loop and one absent optional prop logged stx's own hydration
|
|
136
|
+
* invariant, once per prop, forever.
|
|
137
|
+
*
|
|
138
|
+
* Three things are stripped before identifiers are read: string contents, so a
|
|
139
|
+
* word inside a quote is not a variable; member access after `.` or `?.`, so a
|
|
140
|
+
* property is not a variable; and object-literal keys, for the same reason.
|
|
141
|
+
* What is left is the free variables, which is the question actually being
|
|
142
|
+
* asked.
|
|
143
|
+
*/
|
|
144
|
+
export declare function freeIdentifiers(expression: string): string[];
|
|
123
145
|
export declare function createSafeFunction(expression: string, contextKeys: string[]): (...args: unknown[]) => unknown;
|
|
124
146
|
export declare function safeEvaluateCode(code: string, context: Record<string, unknown>): unknown;
|
|
125
147
|
/**
|
package/dist/safe-evaluator.js
CHANGED
|
@@ -299,6 +299,9 @@ const RESERVED_PARAM_NAMES = new Set([
|
|
|
299
299
|
"eval",
|
|
300
300
|
"await"
|
|
301
301
|
]);
|
|
302
|
+
export function freeIdentifiers(expression) {
|
|
303
|
+
return expression.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g, " ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g, " ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g, "$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g) || [];
|
|
304
|
+
}
|
|
302
305
|
export function createSafeFunction(expression, contextKeys) {
|
|
303
306
|
const sanitizedExpr = sanitizeExpression(expression), validIdent = /^[A-Za-z_$][\w$]*$/, validIndices = [], filteredKeys = [];
|
|
304
307
|
for (let i = 0;i < contextKeys.length; i++) {
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{sk as Bq,tk as Hq,xk as Tq}from"./chunk-1nnpwrqj.js";import{Ak as Eq,yk as Uq,zk as Iq}from"./chunk-yckd6ks5.js";import{Wk as Nq,Xk as _q}from"./chunk-
|
|
2
|
+
import{sk as Bq,tk as Hq,xk as Tq}from"./chunk-1nnpwrqj.js";import{Ak as Eq,yk as Uq,zk as Iq}from"./chunk-yckd6ks5.js";import{Wk as Nq,Xk as _q}from"./chunk-0rpqx6xa.js";import"./chunk-zgvga8rc.js";import{Cm as Aq,Lr as l,Wp as c,Zp as Oq,lp as Xq,mq as x}from"./chunk-mm0f84gm.js";import"./chunk-j0tfxbns.js";import"./chunk-khrtzbxd.js";import"./chunk-8anh6d36.js";import"./chunk-3fwn9edg.js";import{Hs as zq}from"./chunk-yb6f8ey1.js";import{Ms as f}from"./chunk-m2mhtpwy.js";import"./chunk-6xg3j487.js";import"./chunk-q4se9rtw.js";import"./chunk-1nm2xrvq.js";import{Pt as Wq,Qt as Yq,Rt as Vq,St as jq,Tt as Gq,Ut as Lq}from"./chunk-z47tw39z.js";import"./chunk-3wd9kfyz.js";import{iu as g}from"./chunk-trtm887x.js";import O from"fs";import j from"path";import{createHash as kq}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,A)=>{let N=A.trim();if(!N)return J;if(/\bdata-stx-src=/.test(z))return J;if(Z.minify)N=Sq(N);let X=xq(N);if(!$.has(X))$.set(X,N);let H=Z.integrity?` data-stx-integrity="sha384-${kq("sha384").update(N).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${W}" data-stx-src="/_stx/islands/${X}.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 A=Array.from(K).filter((N)=>!q.includes(`rel="prefetch" href="${N}"`)).map((N)=>`<link rel="prefetch" href="${N}" as="script">`).join("");if(!A)return q;return q.slice(0,z)+A+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 O.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 $=O.statSync(q),Q=`${this.salt}|${q}:${$.mtimeMs}`;for(let J of Z)if(O.existsSync(J)){let W=O.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 O.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 O.promises.unlink(Z)}async invalidatePattern(q){let Z=j.join(this.cacheDir,"isr");if(!O.existsSync(Z))return;let $=await O.promises.readdir(Z);for(let Q of $){let K=Q.replace(/_/g,"/").replace(".json","");if(q.test(K))await O.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,A=0,N={},X={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&O.existsSync(J.outputDir))await O.promises.rm(J.outputDir,{recursive:!0});await O.promises.mkdir(J.outputDir,{recursive:!0});let _=J.cacheSalt;if(!_){let{resolveUserCrosswindConfig:Y,fingerprintConfig:L}=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,A=0,N={},X={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&O.existsSync(J.outputDir))await O.promises.rm(J.outputDir,{recursive:!0});await O.promises.mkdir(J.outputDir,{recursive:!0});let _=J.cacheSalt;if(!_){let{resolveUserCrosswindConfig:Y,fingerprintConfig:L}=await import("./chunk-zsfpwqrt.js");try{_=L(await Y(process.cwd()))}catch{}}let G=new Dq(J.cacheDir,_);if(J.cache)await G.load();try{let{generateCrosswindCSS:Y}=await import("./chunk-zsfpwqrt.js");await Y('<div class="bg-black"></div>')}catch{}Wq();let m=$?.routeMiddleware?.dir||"middleware";await Vq(process.cwd(),m);let d=Yq();if(d.length>0)console.log(`Loaded ${d.length} middleware: ${d.join(", ")}`);let Mq=$?.routeMiddleware?.global||[];Tq($?.layoutsDir,f(process.cwd()));let n=c(".",{pagesDir:J.pagesDir});console.log(`Found ${n.length} routes`);let y=[];for(let Y of n){let L=await mq(Y);for(let B of L)y.push({route:Y,url:B.url,params:B.params,props:B.props,revalidate:B.revalidate??J.revalidate})}W.totalPages=y.length,console.log(`Generating ${W.totalPages} pages...`);let b=[],i=[];for(let Y=0;Y<y.length;Y+=J.concurrency)i.push(y.slice(Y,Y+J.concurrency));for(let Y of i)await Promise.all(Y.map(async(L)=>{let{route:B,url:V,params:k,props:wq,revalidate:a}=L;try{await J.hooks.onPageStart?.(V);let F=await Bun.file(B.filePath).text(),R=tq(F),bq=R?.middleware?Array.isArray(R.middleware)?R.middleware:[R.middleware]:[],r=[...Mq,...bq];if(r.length>0){let D=jq(V,k,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,v=eq(String(U),V),w=qJ(V,J);await O.promises.mkdir(j.dirname(w),{recursive:!0}),await Bun.write(w,v),W.successCount++,W.pages.push({route:V,outputPath:w,size:Buffer.byteLength(v),cached:!1}),b.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:k})){console.warn(`Validation failed for ${V}, skipping...`);return}}catch{}let I=null,e=!1;if(J.cache){if(I=G.get(V,B.filePath),I)e=!0,W.cachedCount++}if(!I){let D=await Rq(B,k,wq,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:
|
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.212",
|
|
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.212",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.212",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.212",
|
|
124
124
|
"bunfig": "^0.15.17",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.212",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.2.11",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|