@stacksjs/stx 0.2.138 → 0.2.140
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/cli.js +627 -610
- package/dist/client-script-bundler.d.ts +1 -1
- package/dist/client-script-bundler.js +2 -0
- package/dist/craft.js +30 -13
- package/dist/dev-server/serve-app.js +17 -5
- package/dist/head.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/js-ts.js +4 -1
- package/dist/page-response.d.ts +7 -0
- package/dist/page-response.js +12 -0
- package/dist/pwa.js +30 -13
- package/dist/signals.js +25 -8
- package/dist/ssg.js +30 -13
- package/package.json +6 -6
package/dist/ssg.js
CHANGED
|
@@ -639,7 +639,7 @@ ${H}
|
|
|
639
639
|
`),J)X=X.replace(/\n/g,`<br />
|
|
640
640
|
`);for(let q=0;q<Q.length;q++)X=X.replace(`\x00CODEBLOCK${q}\x00`,Q[q]);return X=X.replace(/<p>\s*<\/p>/g,""),X.trim()}function s0($){let Z=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;$=$.replace(Z,(J,X)=>{return`const { ${X.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
|
|
641
641
|
`});let Y=/import\s*\{([^}]+)\}\s*from\s*['"]@composables['"]\s*;?\n?/g;return $=$.replace(Y,(J,X)=>{return`const { ${X.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__composables
|
|
642
|
-
`}),$}import IQ from"process";function l0($="STX_PUBLIC_"){let Z={},Y={};for(let[J,X]of Object.entries(IQ.env)){if(!J.startsWith($)||X===void 0)continue;Z[`import.meta.env.${J}`]=JSON.stringify(X),Y[J]=X}return Z["import.meta.env"]=JSON.stringify(Y),Z}var S1=()=>{};var x5={};a(x5,{queueClientBundleBuild:()=>A9,hasUserImports:()=>EQ,bundleClientScript:()=>bQ});import L0 from"path";import v0 from"fs";function EQ($){let Z=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(!F9.some((G)=>G.test(X)))return console.log("[stx:bundler] detected user import:",X),!0}let J=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Y=J.exec($))!==null){let X=Y[1];if(/\.css(?:\?.*)?$/.test(X))continue;if(!F9.some((G)=>G.test(X)))return console.log("[stx:bundler] detected side-effect import:",X),!0}return!1}function kQ($,Z,Y,J){let X=(Q,G)=>{let K=Q===Y?Z:L0.dirname(Q),W=L0.resolve(K,G),z=[W,`${W}.ts`,`${W}.tsx`,`${W}.js`,`${W}.mjs`,`${W}.jsx`,L0.join(W,"index.ts"),L0.join(W,"index.tsx"),L0.join(W,"index.js"),L0.join(W,"index.mjs")];for(let q of z)try{if(v0.existsSync(q)&&v0.statSync(q,{throwIfNoEntry:!1})?.isFile())return q}catch{}return W};return{name:"stx-client-bundle",setup(Q){Q.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^\//},(G)=>{if(v0.existsSync(G.path))return{path:G.path};return{path:G.path,external:!0}}),Q.onResolve({filter:/^\.\.?\//},(G)=>{let K=X(G.importer,G.path);return J.add(K),{path:K}}),Q.onResolve({filter:/^[@~]\//},(G)=>{let K=L0.resolve($,G.path.slice(2)),W=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,L0.join(K,"index.ts"),L0.join(K,"index.tsx"),L0.join(K,"index.js"),L0.join(K,"index.mjs")];for(let z of W)if(v0.existsSync(z)&&v0.statSync(z,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",z),J.add(z),{path:z};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}}),Q.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(G)=>{let K=L0.extname(G.path).toLowerCase(),W=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";if(G.path!==Y)J.add(G.path);return{contents:v0.readFileSync(G.path,"utf8"),loader:W}})}}}function A9($){let Z=globalThis,J=(Z[V9]??Promise.resolve()).then($,$);return Z[V9]=J.then(()=>{return},()=>{return}),J}async function bQ($,Z,Y={}){let J=Y.projectRoot||process.cwd(),X=Y.minify??!1,Q=Y.cacheDir||O1(J,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${DQ}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),W=L0.join(Q,`${K}.js`),z=L0.join(Q,`${K}.deps.json`),q=Bun.file(W);if(await q.exists()){let _=Bun.file(z),B=!0;if(await _.exists())try{let H=JSON.parse(await _.text());if(H.metadataVersion!==w9||!Array.isArray(H.files))B=!1;for(let L of Array.isArray(H.files)?H.files:[])try{if(v0.statSync(L.path).mtimeMs!==L.mtimeMs){B=!1;break}}catch{B=!1;break}}catch{B=!1}if(B)return console.log("[stx:bundler] cache hit:",K),await q.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let U=_7.get(K);if(U)return await U;let j=A9(()=>SQ($,Z,{projectRoot:J,minify:X,cacheDir:Q,hash:K,cachePath:W,depsPath:z}));_7.set(K,j);try{return await j}finally{_7.delete(K)}}async function SQ($,Z,Y){let{projectRoot:J,minify:X,cacheDir:Q,hash:G,cachePath:K,depsPath:W}=Y,z=O1(J,"bundle-tmp"),q=L0.join(z,`${G}.ts`),U=L0.join(z,"out",G);v0.mkdirSync(z,{recursive:!0}),v0.mkdirSync(U,{recursive:!0});let j=L0.dirname(Z),_=[],B=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,H=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,L;while((L=B.exec($))!==null){if(L[1])continue;if(L[2])L[2].split(",").forEach((F)=>{let w=F.split(":")[0].trim();if(w)_.push(w)});else if(L[3])_.push(L[3])}while((L=H.exec($))!==null){if(L[1])continue;_.push(L[2])}let V=_.length>0?`
|
|
642
|
+
`}),$}import IQ from"process";function l0($="STX_PUBLIC_"){let Z={},Y={};for(let[J,X]of Object.entries(IQ.env)){if(!J.startsWith($)||X===void 0)continue;Z[`import.meta.env.${J}`]=JSON.stringify(X),Y[J]=X}return Z["import.meta.env"]=JSON.stringify(Y),Z}var S1=()=>{};var x5={};a(x5,{queueClientBundleBuild:()=>A9,hasUserImports:()=>EQ,bundleClientScript:()=>bQ});import L0 from"path";import v0 from"fs";function EQ($){let Z=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(!F9.some((G)=>G.test(X)))return console.log("[stx:bundler] detected user import:",X),!0}let J=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Y=J.exec($))!==null){let X=Y[1];if(/\.css(?:\?.*)?$/.test(X))continue;if(X==="@stacksjs/browser")continue;if(!F9.some((G)=>G.test(X)))return console.log("[stx:bundler] detected side-effect import:",X),!0}return!1}function kQ($,Z,Y,J){let X=(Q,G)=>{let K=Q===Y?Z:L0.dirname(Q),W=L0.resolve(K,G),z=[W,`${W}.ts`,`${W}.tsx`,`${W}.js`,`${W}.mjs`,`${W}.jsx`,L0.join(W,"index.ts"),L0.join(W,"index.tsx"),L0.join(W,"index.js"),L0.join(W,"index.mjs")];for(let q of z)try{if(v0.existsSync(q)&&v0.statSync(q,{throwIfNoEntry:!1})?.isFile())return q}catch{}return W};return{name:"stx-client-bundle",setup(Q){Q.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^\//},(G)=>{if(v0.existsSync(G.path))return{path:G.path};return{path:G.path,external:!0}}),Q.onResolve({filter:/^\.\.?\//},(G)=>{let K=X(G.importer,G.path);return J.add(K),{path:K}}),Q.onResolve({filter:/^[@~]\//},(G)=>{let K=L0.resolve($,G.path.slice(2)),W=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,L0.join(K,"index.ts"),L0.join(K,"index.tsx"),L0.join(K,"index.js"),L0.join(K,"index.mjs")];for(let z of W)if(v0.existsSync(z)&&v0.statSync(z,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",z),J.add(z),{path:z};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}}),Q.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(G)=>{let K=L0.extname(G.path).toLowerCase(),W=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";if(G.path!==Y)J.add(G.path);return{contents:v0.readFileSync(G.path,"utf8"),loader:W}})}}}function A9($){let Z=globalThis,J=(Z[V9]??Promise.resolve()).then($,$);return Z[V9]=J.then(()=>{return},()=>{return}),J}async function bQ($,Z,Y={}){let J=Y.projectRoot||process.cwd(),X=Y.minify??!1,Q=Y.cacheDir||O1(J,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${DQ}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),W=L0.join(Q,`${K}.js`),z=L0.join(Q,`${K}.deps.json`),q=Bun.file(W);if(await q.exists()){let _=Bun.file(z),B=!0;if(await _.exists())try{let H=JSON.parse(await _.text());if(H.metadataVersion!==w9||!Array.isArray(H.files))B=!1;for(let L of Array.isArray(H.files)?H.files:[])try{if(v0.statSync(L.path).mtimeMs!==L.mtimeMs){B=!1;break}}catch{B=!1;break}}catch{B=!1}if(B)return console.log("[stx:bundler] cache hit:",K),await q.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let U=_7.get(K);if(U)return await U;let j=A9(()=>SQ($,Z,{projectRoot:J,minify:X,cacheDir:Q,hash:K,cachePath:W,depsPath:z}));_7.set(K,j);try{return await j}finally{_7.delete(K)}}async function SQ($,Z,Y){let{projectRoot:J,minify:X,cacheDir:Q,hash:G,cachePath:K,depsPath:W}=Y,z=O1(J,"bundle-tmp"),q=L0.join(z,`${G}.ts`),U=L0.join(z,"out",G);v0.mkdirSync(z,{recursive:!0}),v0.mkdirSync(U,{recursive:!0});let j=L0.dirname(Z),_=[],B=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,H=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,L;while((L=B.exec($))!==null){if(L[1])continue;if(L[2])L[2].split(",").forEach((F)=>{let w=F.split(":")[0].trim();if(w)_.push(w)});else if(L[3])_.push(L[3])}while((L=H.exec($))!==null){if(L[1])continue;_.push(L[2])}let V=_.length>0?`
|
|
643
643
|
export { ${_.join(", ")} }`:"";await Bun.write(q,$+V),console.log("[stx:bundler] bundling:",G,"from:",L0.basename(Z));let O=new Set;try{let F=await Bun.build({entrypoints:[q],outdir:U,target:"browser",format:"esm",minify:X,plugins:[kQ(J,j,q,O)],define:{"process.env.NODE_ENV":X?'"production"':'"development"',...l0()},root:J});if(!F.success){let D=F.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ");return console.warn("[stx:bundler] build failed:",D),$}let w="";for(let D of F.outputs){w=await D.text();break}let A=[];for(let D of w.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let y of D[1].split(",")){let S=y.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(S){A.push([S[2],S[1]]);continue}let k=y.trim();if(/^[A-Za-z_$][\w$]*$/.test(k))A.push([k,k])}let R=w.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];w=w.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let N=`__stxBundle_${G}`,M=A.map(([D,y])=>`${JSON.stringify(D)}: ${y}`).join(", "),T=A.map(([D])=>`var ${D} = undefined;`).join(`
|
|
644
644
|
`),I=A.map(([D])=>`${D} = ${N}[${JSON.stringify(D)}];`).join(`
|
|
645
645
|
`);if(w=`${R.join(`
|
|
@@ -805,9 +805,13 @@ console.log('[stx] entering IIFE');
|
|
|
805
805
|
|
|
806
806
|
// Inject x-cloak CSS to prevent FOUC (Flash of Unstyled Content)
|
|
807
807
|
// Elements with x-cloak are hidden until the runtime removes the attribute after mount
|
|
808
|
-
var cloakStyle = document.
|
|
809
|
-
cloakStyle
|
|
810
|
-
|
|
808
|
+
var cloakStyle = document.getElementById ? document.getElementById('stx-cloak-style') : null;
|
|
809
|
+
if (!cloakStyle) {
|
|
810
|
+
cloakStyle = document.createElement('style');
|
|
811
|
+
cloakStyle.id = 'stx-cloak-style';
|
|
812
|
+
cloakStyle.textContent = '[x-cloak] { display: none !important; }';
|
|
813
|
+
document.head.appendChild(cloakStyle);
|
|
814
|
+
}
|
|
811
815
|
|
|
812
816
|
// ==========================================================================
|
|
813
817
|
// Reactive Core
|
|
@@ -6745,8 +6749,13 @@ else {
|
|
|
6745
6749
|
// Auto-initialization
|
|
6746
6750
|
// ==========================================================================
|
|
6747
6751
|
|
|
6748
|
-
|
|
6749
|
-
|
|
6752
|
+
// A dev runtime may be evaluated again by HMR, an embed, or a test harness.
|
|
6753
|
+
// Replace the previous listener so only the latest runtime closure can own
|
|
6754
|
+
// componentScope and reactive subscriptions.
|
|
6755
|
+
if (window.__stxDomReadyHandler) {
|
|
6756
|
+
document.removeEventListener('DOMContentLoaded', window.__stxDomReadyHandler);
|
|
6757
|
+
}
|
|
6758
|
+
const stxDomReadyHandler = () => {
|
|
6750
6759
|
console.log('[stx] DOMContentLoaded fired \u2014 processing scopes');
|
|
6751
6760
|
// Track which scoped elements have been processed
|
|
6752
6761
|
const processedScopes = new Set();
|
|
@@ -6967,7 +6976,10 @@ catch (e) {
|
|
|
6967
6976
|
}
|
|
6968
6977
|
}
|
|
6969
6978
|
});
|
|
6970
|
-
}
|
|
6979
|
+
};
|
|
6980
|
+
window.__stxDomReadyHandler = stxDomReadyHandler;
|
|
6981
|
+
console.log('[stx] registering DOMContentLoaded handler');
|
|
6982
|
+
document.addEventListener('DOMContentLoaded', stxDomReadyHandler);
|
|
6971
6983
|
|
|
6972
6984
|
// ==========================================================================
|
|
6973
6985
|
// Scope Disposal
|
|
@@ -7132,10 +7144,15 @@ catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
|
7132
7144
|
// Re-initialize components after SPA content swap.
|
|
7133
7145
|
// Debounce to handle rapid re-fires (HMR triggers navigate which triggers stx:load again).
|
|
7134
7146
|
var _stxLoadTimer = null;
|
|
7135
|
-
window.
|
|
7147
|
+
if (window.__stxLoadHandler) {
|
|
7148
|
+
window.removeEventListener('stx:load', window.__stxLoadHandler);
|
|
7149
|
+
}
|
|
7150
|
+
function stxLoadHandler() {
|
|
7136
7151
|
if (_stxLoadTimer) { clearTimeout(_stxLoadTimer); }
|
|
7137
7152
|
_stxLoadTimer = setTimeout(_handleStxLoad, 5);
|
|
7138
|
-
}
|
|
7153
|
+
}
|
|
7154
|
+
window.__stxLoadHandler = stxLoadHandler;
|
|
7155
|
+
window.addEventListener('stx:load', stxLoadHandler);
|
|
7139
7156
|
function _handleStxLoad() {
|
|
7140
7157
|
_stxLoadTimer = null;
|
|
7141
7158
|
console.log('[stx:load] START. mountQueue:', mountQueue.length, '_latestSetup:', !!window.stx._latestSetup);
|
|
@@ -9429,10 +9446,10 @@ ${$J($).split(",").map((Q)=>Q.trim()).filter(Boolean).map((Q)=>` try { __scopeR
|
|
|
9429
9446
|
`}}if(S){let f=mU(A,S);if(A=f.html,f.mergedIntoExisting)y=y.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await x6(A,I,O,J,X,Q);let{processLoops:k}=await Promise.resolve().then(() => (C6(),tY)),v=k(A,I,O);v=n1(v,I,O);let g=Q5(w);if(v=w1(v,I,O,{forceSignals:g}),T)v+=`
|
|
9430
9447
|
`+T;if(y)v+=`
|
|
9431
9448
|
`+y;return v}catch(w){let A=w instanceof Error?w.message:String(w);return q0("Include",`Error processing include ${B}: ${A}`,Y,L,V)}}let j=/@include\s*\(/g,_;while((_=j.exec(K))!==null){let B=_.index,H=B+_[0].length-1,L=1,V=H+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")")L--;V++}if(L!==0)break;let O=K.substring(B,V),F=K.substring(H+1,V-1),w=F.match(/^\s*['"]([^'"]+)['"]/);if(!w){j.lastIndex=V;continue}let A=w[1],R,N=F.substring(w[0].length),M=v6(N,0);if(M!==-1)R=N.substring(M+1).trim();let T={};if(R)try{T=M0(R,Z)}catch(E){let D=E instanceof Error?E.message:String(E);K=K.replace(O,q0("Include",`Error parsing include variables for ${A}: ${D}`,Y,$,B)),j.lastIndex=0;continue}let I=await U(A,T,$,B);K=K.substring(0,B)+I+K.substring(V),j.lastIndex=0}return K}function f6($,Z){let Y=$;function J(X,Q,G,K){let W=X,z=!0;while(z){z=!1;let q=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),U=W.match(q);if(!U||U.index===void 0)break;let j=U.index,_=U[1],B=j+U[0].length,H=new RegExp(`@${Q}\\(`),L=new RegExp(`@${G}(?![a-z])`),V=1,O=B,F=-1;while(V>0&&O<W.length){let A=W.slice(O),R=A.match(H),N=A.match(L),M=R?O+R.index:1/0,T=N?O+N.index:1/0;if(M<T)V++,O=M+(R[0].length||1);else if(T<1/0){if(V--,V===0){F=T;break}O=T+G.length+1}else break}if(F===-1)break;let w=W.slice(B,F);if(!Z[_])Z[_]=[];if(K)Z[_].unshift(w);else Z[_].push(w);W=W.substring(0,j)+W.substring(F+`@${G}`.length),z=!0}return W}return Y=J(Y,"push","endpush",!1),Y=J(Y,"prepend","endprepend",!0),Y}function g6($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,J)=>{if(!Z[J]||Z[J].length===0)return"";return Z[J].join(`
|
|
9432
|
-
`)})}var eY=0,KA,pU;var JJ=b(()=>{N7();d4();J1();i5();z5();w0();N0();KA=new x1(500),pU=new Set});import*as h6 from"path";async function XJ($,Z,Y=""){if(h6.basename(Y)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return GJ($,Z,Y,"@js","@endjs")}async function QJ($,Z,Y=""){if(h6.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return GJ($,Z,Y,"@ts","@endts")}async function GJ($,Z,Y,J,X){let Q=$,G=W5(`${J}([\\s\\S]*?)${X}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:z,content:q,index:U}of K)try{let j=Object.keys(
|
|
9433
|
-
${
|
|
9434
|
-
${
|
|
9435
|
-
`,
|
|
9449
|
+
`)})}var eY=0,KA,pU;var JJ=b(()=>{N7();d4();J1();i5();z5();w0();N0();KA=new x1(500),pU=new Set});import*as h6 from"path";async function XJ($,Z,Y=""){if(h6.basename(Y)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return GJ($,Z,Y,"@js","@endjs")}async function QJ($,Z,Y=""){if(h6.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return GJ($,Z,Y,"@ts","@endts")}async function GJ($,Z,Y,J,X){let Q=$,G=W5(`${J}([\\s\\S]*?)${X}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:z,content:q,index:U}of K)try{let j={...Z,global:Z},_=Object.keys(j),B=Object.values(j),H=q.trim();if(J==="@ts")H=H.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let V=(H.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((R)=>R.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),O=V.length>0?`return { ${V.join(", ")} };`:"return {};",F=`
|
|
9450
|
+
${H}
|
|
9451
|
+
${O}
|
|
9452
|
+
`,A=Function(..._,F)(...B);if(A&&typeof A==="object")Object.assign(Z,A);Q=Q.replace(z,"")}catch(j){console.error(`Error executing ${J} code block in ${Y}:`,j);let _=j instanceof Error?j.message:String(j),B=q0(`${J} Directive`,`Error executing code: ${_}`,Y,$,U,z);console.error(B),Q=Q.replace(z,"")}return Q}var KJ=b(()=>{z5();N0()});function cU($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function WJ($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,J,X,Q)=>{return cU(J,Q||"_method")})}async function zJ($,Z,Y,J,X){if(!J.middleware||J.middleware.length===0)return $;let Q=$,G=J.middleware.filter((K)=>K.timing===X);if(G.length===0)return Q;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(J.debug)console.warn("Invalid middleware:",K);continue}try{let W=await K.handler(Q,Z,Y,J);if(typeof W==="string")Q=W;else if(J.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(W){if(J.debug)console.error(`Error in middleware ${K.name}:`,W);if(J.debug){let z=q0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
|
|
9436
9453
|
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${r0(z)}</div>
|
|
9437
9454
|
`)}}}return Q}async function qJ($,Z,Y,J){return zJ($,Z,Y,J,"before")}async function UJ($,Z,Y,J){return zJ($,Z,Y,J,"after")}var jJ=b(()=>{J1();N0()});import{defineRoute as wA,defineRoutes as AA,resetRoutes as RA,route as NA,setAppUrl as MA}from"stx-router";import{route as iU}from"stx-router";function _J($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,J,X,Q)=>{try{let G=X?M0(X,{}):{};return iU(J,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var BJ=b(()=>{w0()});async function HJ($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(O$.exact[$])for(let J of O$.exact[$])await Promise.resolve(J(Z,$));if(O$.exact[Y])for(let J of O$.exact[Y])await Promise.resolve(J(Z,$));for(let{pattern:J,callback:X}of O$.patterns)if(J.test($)||J.test(Y))await Promise.resolve(X(Z,$))}var O$;var OJ=b(()=>{O$={patterns:[],exact:{}}});function LJ($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>LJ(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function FJ($,Z){if(!/:[\w-]+=/.test($))return $;let Y=$,J=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,X=[],Q;while((Q=J.exec($))!==null)X.push([Q.index,Q.index+Q[0].length]);function G(z){return X.some(([q,U])=>z>=q&&z<U)}let K=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*'))*)\s*\/?>/g,W=[];while((Q=K.exec(Y))!==null){if(G(Q.index))continue;let z=Q[0],q=Q[2];if(!q||!q.includes(":"))continue;let U=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,j,_=q,B=!1;while((j=U.exec(q))!==null){let H=j[1],L=j[2];if(L.includes("()")&&!L.includes(".get(")||L.includes("$store")||L.includes("$ref"))continue;try{let V=Object.keys(Z),O=Object.values(Z),F=L.match(/^([a-zA-Z_$][\w$]*)/);if(F&&!V.includes(F[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(F[1]))continue;let A=Function(...V,`return (${L})`)(...O);if(H==="class"){let R=LJ(A);if(R){let N=_.match(/\sclass="([^"]*)"/);if(N)_=_.replace(N[0],` class="${N[1]} ${R}"`);else _=_.replace(j[0],` class="${R}"`)}else _=_.replace(j[0],"");B=!0;continue}if(nU.has(H)){if(A)_=_.replace(j[0],` ${H}`);else _=_.replace(j[0],"");B=!0;continue}if(A===null||A===void 0||A===!1)_=_.replace(j[0],"");else{let R=String(A).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");_=_.replace(j[0],` ${H}="${R}"`)}B=!0}catch{continue}}if(B){let H=z.endsWith("/>")?" /":"",V=`<${Q[1]}${_}${H}>`;W.push({start:Q.index,end:Q.index+z.length,replacement:V})}}for(let z=W.length-1;z>=0;z--){let{start:q,end:U,replacement:j}=W[z];Y=Y.slice(0,q)+j+Y.slice(U)}return Y}var nU;var VJ=b(()=>{nU=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function r1($,Z){let Y=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;Y.lastIndex=Z;let J=Y.exec($);if(!J)return null;let X=/\/\s*>$/.test(J[0])||oU.has(J[1].toLowerCase()),Q=X?J[2].replace(/\/\s*$/,""):J[2];return{full:J[0],tag:J[1],attrs:Q,selfClosing:X,start:J.index,end:J.index+J[0].length}}function rU($,Z,Y){let J=1,X=Y,Q=new RegExp(`<${Z}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),G=new RegExp(`</${Z}\\s*>`,"gi");while(J>0&&X<$.length){Q.lastIndex=X,G.lastIndex=X;let K=Q.exec($),W=G.exec($);if(!W)return-1;if(K&&K.index<W.index)J++,X=K.index+K[0].length;else{if(J--,J===0)return W.index+W[0].length;X=W.index+W[0].length}}return-1}function Q1($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=rU($,Z.tag,Z.end);if(Y===-1)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};return{outerStart:Z.start,outerEnd:Y,innerHTML:$.slice(Z.end,Y-`</${Z.tag}>`.length)}}function wJ($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function N5($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),J=$.match(new RegExp(`${Y}="([^"]*)"`,"s"))||$.match(new RegExp(`${Y}='([^']*)'`,"s"));return J?J[1]:null}function D1($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return $.replace(new RegExp(`\\s*${Y}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${Y}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${Y}(?=\\s|$|>|/)`,"g"),"")}function E1($,Z,Y){let J=Z.selfClosing?" /":"",X=`<${Z.tag}${Y}${J}>`;return $.slice(0,Z.start)+X+$.slice(Z.end)}function aU($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function tU($){let Z=$,Y=0;while(Y<Z.length){let J=r1(Z,Y);if(!J)break;let X=N5(J.attrs,"v-for");if(X===null){Y=J.end;continue}let Q=X.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!Q){Y=J.end;continue}let G=Q[1].trim(),K=Q[2].trim(),W;if(G.includes(",")){let L=G.split(",").map((F)=>F.trim()),V=L[0],O=L[1];W=`${K} as ${O} => ${V}`}else W=`${K} as ${G}`;let z=D1(J.attrs,"v-for"),q=D1(z,":key").replace(/\s*v-bind:key="[^"]*"/g,""),U=Q1(Z,J),j=Z.slice(U.outerStart,U.outerEnd),_=E1(j,{...J,start:0,end:J.end-J.start},q),B=`@foreach(${W})
|
|
9438
9455
|
`,H=`${B}${_}
|
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.140",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -115,14 +115,14 @@
|
|
|
115
115
|
"typecheck": "bun tsc -p tsconfig.src.json --noEmit"
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
|
-
"@cwcss/crosswind": "^0.2.
|
|
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.140",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.140",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.140",
|
|
124
124
|
"bunfig": "^0.15.15",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.140",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.1.9",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|