@stacksjs/stx 0.2.139 → 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 +162 -145
- 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/js-ts.js +4 -1
- package/dist/pwa.js +30 -13
- package/dist/signals.js +25 -8
- package/dist/ssg.js +30 -13
- package/package.json +6 -6
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Returns false for:
|
|
5
5
|
* - `import type { ... }` (type-only — stripped by TS transpiler)
|
|
6
6
|
* - `import { ... } from 'stx'` (auto-imported from window.stx)
|
|
7
|
-
* - `import
|
|
7
|
+
* - `import '@stacksjs/browser'` (the framework-injected module bootstrap)
|
|
8
8
|
* - `import { ... } from '@stores'` (handled by transformStoreImports)
|
|
9
9
|
* - `import { ... } from '@composables'` (handled by transformStoreImports)
|
|
10
10
|
*/
|
|
@@ -24,6 +24,8 @@ export function hasUserImports(code) {
|
|
|
24
24
|
const source = match[1];
|
|
25
25
|
if (/\.css(?:\?.*)?$/.test(source))
|
|
26
26
|
continue;
|
|
27
|
+
if (source === "@stacksjs/browser")
|
|
28
|
+
continue;
|
|
27
29
|
if (!EXTERNAL_PATTERNS.some((p) => p.test(source))) {
|
|
28
30
|
console.log("[stx:bundler] detected side-effect import:", source);
|
|
29
31
|
return !0;
|
package/dist/craft.js
CHANGED
|
@@ -639,7 +639,7 @@ ${H}
|
|
|
639
639
|
`),X)Q=Q.replace(/\n/g,`<br />
|
|
640
640
|
`);for(let U=0;U<J.length;U++)Q=Q.replace(`\x00CODEBLOCK${U}\x00`,J[U]);return Q=Q.replace(/<p>\s*<\/p>/g,""),Q.trim()}function r0($){let Z=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;$=$.replace(Z,(X,Q)=>{return`const { ${Q.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,(X,Q)=>{return`const { ${Q.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__composables
|
|
642
|
-
`}),$}import ZK from"process";function p0($="STX_PUBLIC_"){let Z={},Y={};for(let[X,Q]of Object.entries(ZK.env)){if(!X.startsWith($)||Q===void 0)continue;Z[`import.meta.env.${X}`]=JSON.stringify(Q),Y[X]=Q}return Z["import.meta.env"]=JSON.stringify(Y),Z}var C1=()=>{};import p5 from"path";function Z8($){$8=$?.trim()||null}function c5(){return process.env[YK]?.trim()||$8||G5}function i5($=process.cwd(),...Z){let Y=c5();return p5.isAbsolute(Y)?p5.join(Y,...Z):p5.join($,Y,...Z)}function n5($){if(!$||p5.isAbsolute($))return $;let Z=$.replace(/\\/g,"/");if(Z!==G5&&!Z.startsWith(`${G5}/`))return $;let Y=Z.slice(G5.length+1);return Y?p5.join(c5(),Y):c5()}var G5=".stx",YK="STX_DIR",$8=null;var S$=()=>{};var s5={};t(s5,{queueClientBundleBuild:()=>Q8,hasUserImports:()=>JK,bundleClientScript:()=>GK});import j0 from"path";import P0 from"fs";function JK($){let Z=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Y;while((Y=Z.exec($))!==null){let Q=Y[1];if(!Y8.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected user import:",Q),!0}let X=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Y=X.exec($))!==null){let Q=Y[1];if(/\.css(?:\?.*)?$/.test(Q))continue;if(!Y8.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected side-effect import:",Q),!0}return!1}function QK($,Z,Y,X){let Q=(J,G)=>{let K=J===Y?Z:j0.dirname(J),q=j0.resolve(K,G),W=[q,`${q}.ts`,`${q}.tsx`,`${q}.js`,`${q}.mjs`,`${q}.jsx`,j0.join(q,"index.ts"),j0.join(q,"index.tsx"),j0.join(q,"index.js"),j0.join(q,"index.mjs")];for(let U of W)try{if(P0.existsSync(U)&&P0.statSync(U,{throwIfNoEntry:!1})?.isFile())return U}catch{}return q};return{name:"stx-client-bundle",setup(J){J.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(G)=>({path:G.path,external:!0})),J.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),J.onResolve({filter:/^\//},(G)=>{if(P0.existsSync(G.path))return{path:G.path};return{path:G.path,external:!0}}),J.onResolve({filter:/^\.\.?\//},(G)=>{let K=Q(G.importer,G.path);return X.add(K),{path:K}}),J.onResolve({filter:/^[@~]\//},(G)=>{let K=j0.resolve($,G.path.slice(2)),q=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,j0.join(K,"index.ts"),j0.join(K,"index.tsx"),j0.join(K,"index.js"),j0.join(K,"index.mjs")];for(let W of q)if(P0.existsSync(W)&&P0.statSync(W,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",W),X.add(W),{path:W};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}}),J.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(G)=>{let K=j0.extname(G.path).toLowerCase(),q=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";if(G.path!==Y)X.add(G.path);return{contents:P0.readFileSync(G.path,"utf8"),loader:q}})}}}function Q8($){let Z=globalThis,X=(Z[X8]??Promise.resolve()).then($,$);return Z[X8]=X.then(()=>{return},()=>{return}),X}async function GK($,Z,Y={}){let X=Y.projectRoot||process.cwd(),Q=Y.minify??!1,J=Y.cacheDir||i5(X,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${XK}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),q=j0.join(J,`${K}.js`),W=j0.join(J,`${K}.deps.json`),U=Bun.file(q);if(await U.exists()){let B=Bun.file(W),j=!0;if(await B.exists())try{let H=JSON.parse(await B.text());if(H.metadataVersion!==J8||!Array.isArray(H.files))j=!1;for(let L of Array.isArray(H.files)?H.files:[])try{if(P0.statSync(L.path).mtimeMs!==L.mtimeMs){j=!1;break}}catch{j=!1;break}}catch{j=!1}if(j)return console.log("[stx:bundler] cache hit:",K),await U.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let z=E7.get(K);if(z)return await z;let _=Q8(()=>KK($,Z,{projectRoot:X,minify:Q,cacheDir:J,hash:K,cachePath:q,depsPath:W}));E7.set(K,_);try{return await _}finally{E7.delete(K)}}async function KK($,Z,Y){let{projectRoot:X,minify:Q,cacheDir:J,hash:G,cachePath:K,depsPath:q}=Y,W=i5(X,"bundle-tmp"),U=j0.join(W,`${G}.ts`),z=j0.join(W,"out",G);P0.mkdirSync(W,{recursive:!0}),P0.mkdirSync(z,{recursive:!0});let _=j0.dirname(Z),B=[],j=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,H=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,L;while((L=j.exec($))!==null){if(L[1])continue;if(L[2])L[2].split(",").forEach((V)=>{let w=V.split(":")[0].trim();if(w)B.push(w)});else if(L[3])B.push(L[3])}while((L=H.exec($))!==null){if(L[1])continue;B.push(L[2])}let F=B.length>0?`
|
|
642
|
+
`}),$}import ZK from"process";function p0($="STX_PUBLIC_"){let Z={},Y={};for(let[X,Q]of Object.entries(ZK.env)){if(!X.startsWith($)||Q===void 0)continue;Z[`import.meta.env.${X}`]=JSON.stringify(Q),Y[X]=Q}return Z["import.meta.env"]=JSON.stringify(Y),Z}var C1=()=>{};import p5 from"path";function Z8($){$8=$?.trim()||null}function c5(){return process.env[YK]?.trim()||$8||G5}function i5($=process.cwd(),...Z){let Y=c5();return p5.isAbsolute(Y)?p5.join(Y,...Z):p5.join($,Y,...Z)}function n5($){if(!$||p5.isAbsolute($))return $;let Z=$.replace(/\\/g,"/");if(Z!==G5&&!Z.startsWith(`${G5}/`))return $;let Y=Z.slice(G5.length+1);return Y?p5.join(c5(),Y):c5()}var G5=".stx",YK="STX_DIR",$8=null;var S$=()=>{};var s5={};t(s5,{queueClientBundleBuild:()=>Q8,hasUserImports:()=>JK,bundleClientScript:()=>GK});import j0 from"path";import P0 from"fs";function JK($){let Z=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Y;while((Y=Z.exec($))!==null){let Q=Y[1];if(!Y8.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected user import:",Q),!0}let X=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Y=X.exec($))!==null){let Q=Y[1];if(/\.css(?:\?.*)?$/.test(Q))continue;if(Q==="@stacksjs/browser")continue;if(!Y8.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected side-effect import:",Q),!0}return!1}function QK($,Z,Y,X){let Q=(J,G)=>{let K=J===Y?Z:j0.dirname(J),q=j0.resolve(K,G),W=[q,`${q}.ts`,`${q}.tsx`,`${q}.js`,`${q}.mjs`,`${q}.jsx`,j0.join(q,"index.ts"),j0.join(q,"index.tsx"),j0.join(q,"index.js"),j0.join(q,"index.mjs")];for(let U of W)try{if(P0.existsSync(U)&&P0.statSync(U,{throwIfNoEntry:!1})?.isFile())return U}catch{}return q};return{name:"stx-client-bundle",setup(J){J.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(G)=>({path:G.path,external:!0})),J.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),J.onResolve({filter:/^\//},(G)=>{if(P0.existsSync(G.path))return{path:G.path};return{path:G.path,external:!0}}),J.onResolve({filter:/^\.\.?\//},(G)=>{let K=Q(G.importer,G.path);return X.add(K),{path:K}}),J.onResolve({filter:/^[@~]\//},(G)=>{let K=j0.resolve($,G.path.slice(2)),q=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,j0.join(K,"index.ts"),j0.join(K,"index.tsx"),j0.join(K,"index.js"),j0.join(K,"index.mjs")];for(let W of q)if(P0.existsSync(W)&&P0.statSync(W,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",W),X.add(W),{path:W};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}}),J.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(G)=>{let K=j0.extname(G.path).toLowerCase(),q=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";if(G.path!==Y)X.add(G.path);return{contents:P0.readFileSync(G.path,"utf8"),loader:q}})}}}function Q8($){let Z=globalThis,X=(Z[X8]??Promise.resolve()).then($,$);return Z[X8]=X.then(()=>{return},()=>{return}),X}async function GK($,Z,Y={}){let X=Y.projectRoot||process.cwd(),Q=Y.minify??!1,J=Y.cacheDir||i5(X,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${XK}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),q=j0.join(J,`${K}.js`),W=j0.join(J,`${K}.deps.json`),U=Bun.file(q);if(await U.exists()){let B=Bun.file(W),j=!0;if(await B.exists())try{let H=JSON.parse(await B.text());if(H.metadataVersion!==J8||!Array.isArray(H.files))j=!1;for(let L of Array.isArray(H.files)?H.files:[])try{if(P0.statSync(L.path).mtimeMs!==L.mtimeMs){j=!1;break}}catch{j=!1;break}}catch{j=!1}if(j)return console.log("[stx:bundler] cache hit:",K),await U.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let z=E7.get(K);if(z)return await z;let _=Q8(()=>KK($,Z,{projectRoot:X,minify:Q,cacheDir:J,hash:K,cachePath:q,depsPath:W}));E7.set(K,_);try{return await _}finally{E7.delete(K)}}async function KK($,Z,Y){let{projectRoot:X,minify:Q,cacheDir:J,hash:G,cachePath:K,depsPath:q}=Y,W=i5(X,"bundle-tmp"),U=j0.join(W,`${G}.ts`),z=j0.join(W,"out",G);P0.mkdirSync(W,{recursive:!0}),P0.mkdirSync(z,{recursive:!0});let _=j0.dirname(Z),B=[],j=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,H=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,L;while((L=j.exec($))!==null){if(L[1])continue;if(L[2])L[2].split(",").forEach((V)=>{let w=V.split(":")[0].trim();if(w)B.push(w)});else if(L[3])B.push(L[3])}while((L=H.exec($))!==null){if(L[1])continue;B.push(L[2])}let F=B.length>0?`
|
|
643
643
|
export { ${B.join(", ")} }`:"";await Bun.write(U,$+F),console.log("[stx:bundler] bundling:",G,"from:",j0.basename(Z));let O=new Set;try{let V=await Bun.build({entrypoints:[U],outdir:z,target:"browser",format:"esm",minify:Q,plugins:[QK(X,_,U,O)],define:{"process.env.NODE_ENV":Q?'"production"':'"development"',...p0()},root:X});if(!V.success){let E=V.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ");return console.warn("[stx:bundler] build failed:",E),$}let w="";for(let E of V.outputs){w=await E.text();break}let A=[];for(let E of w.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let y of E[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 b=y.trim();if(/^[A-Za-z_$][\w$]*$/.test(b))A.push([b,b])}let M=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 R=`__stxBundle_${G}`,N=A.map(([E,y])=>`${JSON.stringify(E)}: ${y}`).join(", "),T=A.map(([E])=>`var ${E} = undefined;`).join(`
|
|
644
644
|
`),I=A.map(([E])=>`${E} = ${R}[${JSON.stringify(E)}];`).join(`
|
|
645
645
|
`);if(w=`${M.join(`
|
|
@@ -1999,10 +1999,10 @@ ${s2($).split(",").map((J)=>J.trim()).filter(Boolean).map((J)=>` try { __scopeR
|
|
|
1999
1999
|
`}}if(S){let f=cU(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 o3(A,I,O,X,Q,J);let{processLoops:b}=await Promise.resolve().then(() => (n3(),i2)),v=b(A,I,O);v=c1(v,I,O);let h=U5(w);if(v=A1(v,I,O,{forceSignals:h}),T)v+=`
|
|
2000
2000
|
`+T;if(y)v+=`
|
|
2001
2001
|
`+y;return v}catch(w){let A=w instanceof Error?w.message:String(w);return W0("Include",`Error processing include ${j}: ${A}`,Y,L,F)}}let _=/@include\s*\(/g,B;while((B=_.exec(K))!==null){let j=B.index,H=j+B[0].length-1,L=1,F=H+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let O=K.substring(j,F),V=K.substring(H+1,F-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){_.lastIndex=F;continue}let A=w[1],M,R=V.substring(w[0].length),N=s3(R,0);if(N!==-1)M=R.substring(N+1).trim();let T={};if(M)try{T=w0(M,Z)}catch(D){let E=D instanceof Error?D.message:String(D);K=K.replace(O,W0("Include",`Error parsing include variables for ${A}: ${E}`,Y,$,j)),_.lastIndex=0;continue}let I=await z(A,T,$,j);K=K.substring(0,j)+I+K.substring(F),_.lastIndex=0}return K}function r3($,Z){let Y=$;function X(Q,J,G,K){let q=Q,W=!0;while(W){W=!1;let U=new RegExp(`@${J}\\(['"]([^'"]+)['"]\\)`),z=q.match(U);if(!z||z.index===void 0)break;let _=z.index,B=z[1],j=_+z[0].length,H=new RegExp(`@${J}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=j,V=-1;while(F>0&&O<q.length){let A=q.slice(O),M=A.match(H),R=A.match(L),N=M?O+M.index:1/0,T=R?O+R.index:1/0;if(N<T)F++,O=N+(M[0].length||1);else if(T<1/0){if(F--,F===0){V=T;break}O=T+G.length+1}else break}if(V===-1)break;let w=q.slice(j,V);if(!Z[B])Z[B]=[];if(K)Z[B].unshift(w);else Z[B].push(w);q=q.substring(0,_)+q.substring(V+`@${G}`.length),W=!0}return q}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function a3($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
|
|
2002
|
-
`)})}var n2=0,Mw,iU;var a2=k(()=>{G4();$4();X1();Z$();j5();H0();V0();Mw=new d1(500),iU=new Set});import*as t3 from"path";async function t2($,Z,Y=""){if(t3.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 $Y($,Z,Y,"@js","@endjs")}async function e2($,Z,Y=""){if(t3.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((J)=>({...J,displayName:`User ${J.id}: ${J.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return $Y($,Z,Y,"@ts","@endts")}async function $Y($,Z,Y,X,Q){let J=$,G=B5(`${X}([\\s\\S]*?)${Q}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:W,content:U,index:z}of K)try{let _=Object.keys(
|
|
2003
|
-
${
|
|
2004
|
-
${
|
|
2005
|
-
`,
|
|
2002
|
+
`)})}var n2=0,Mw,iU;var a2=k(()=>{G4();$4();X1();Z$();j5();H0();V0();Mw=new d1(500),iU=new Set});import*as t3 from"path";async function t2($,Z,Y=""){if(t3.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 $Y($,Z,Y,"@js","@endjs")}async function e2($,Z,Y=""){if(t3.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((J)=>({...J,displayName:`User ${J.id}: ${J.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return $Y($,Z,Y,"@ts","@endts")}async function $Y($,Z,Y,X,Q){let J=$,G=B5(`${X}([\\s\\S]*?)${Q}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:W,content:U,index:z}of K)try{let _={...Z,global:Z},B=Object.keys(_),j=Object.values(_),H=U.trim();if(X==="@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 F=(H.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((M)=>M.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),O=F.length>0?`return { ${F.join(", ")} };`:"return {};",V=`
|
|
2003
|
+
${H}
|
|
2004
|
+
${O}
|
|
2005
|
+
`,A=Function(...B,V)(...j);if(A&&typeof A==="object")Object.assign(Z,A);J=J.replace(W,"")}catch(_){console.error(`Error executing ${X} code block in ${Y}:`,_);let B=_ instanceof Error?_.message:String(_),j=W0(`${X} Directive`,`Error executing code: ${B}`,Y,$,z,W);console.error(j),J=J.replace(W,"")}return J}var ZY=k(()=>{j5();V0()});function sU($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function YY($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,Q,J)=>{return sU(X,J||"_method")})}async function XY($,Z,Y,X,Q){if(!X.middleware||X.middleware.length===0)return $;let J=$,G=X.middleware.filter((K)=>K.timing===Q);if(G.length===0)return J;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(X.debug)console.warn("Invalid middleware:",K);continue}try{let q=await K.handler(J,Z,Y,X);if(typeof q==="string")J=q;else if(X.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(q){if(X.debug)console.error(`Error in middleware ${K.name}:`,q);if(X.debug){let W=W0("Middleware",`Error in middleware '${K.name}': ${q instanceof Error?q.message:String(q)}`,Y,$);J=J.replace(/<body[^>]*>/,`$&
|
|
2006
2006
|
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${a0(W)}</div>
|
|
2007
2007
|
`)}}}return J}async function JY($,Z,Y,X){return XY($,Z,Y,X,"before")}async function QY($,Z,Y,X){return XY($,Z,Y,X,"after")}var GY=k(()=>{X1();V0()});import{defineRoute as xw,defineRoutes as fw,resetRoutes as gw,route as hw,setAppUrl as uw}from"stx-router";import{route as oU}from"stx-router";function KY($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,X,Q,J)=>{try{let G=Q?w0(Q,{}):{};return oU(X,G,J==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var qY=k(()=>{H0()});function WY($,Z,Y,X){let Q=$;Q=Q.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,q,W)=>{if(!W&&q.includes(":")){let U=q.split(":"),z=q,_=U.length>1?U[1]:"";if(_&&Z[_])W=Z[_];else if(z.startsWith("og:")&&Z.openGraph&&Z.openGraph[U[1]])W=Z.openGraph[U[1]];else W="";return W?`<meta property="${p(z)}" content="${p(W)}">`:""}return W?`<meta name="${p(q)}" content="${p(W)}">`:""});let J=/@metaTag\s*\(/g,G;while((G=J.exec(Q))!==null){let K=G.index,q=K+G[0].length-1,W=1,U=q+1;while(U<Q.length&&W>0){if(Q[U]==="(")W++;else if(Q[U]===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=Q.substring(q+1,U).trim(),_=U+1,B=(()=>{try{let j=w0(z,Z);if(!j)return"";let H="<meta";if(j.name)H+=` name="${p(String(j.name))}"`;if(j.property)H+=` property="${p(String(j.property))}"`;if(j.httpEquiv)H+=` http-equiv="${p(String(j.httpEquiv))}"`;if(j.content)H+=` content="${p(String(j.content))}"`;return H+=">",H}catch(j){let H=j instanceof Error?j.message:String(j);return e("MetaTag",H,o.EVALUATION_ERROR)}})();Q=Q.substring(0,K)+B+Q.substring(_),J.lastIndex=0}return Q}function UY($,Z,Y){let X=$,Q=/@structuredData\s*\(/g,J;while((J=Q.exec(X))!==null){let G=J.index,K=G+J[0].length-1,q=1,W=K+1;while(W<X.length&&q>0){if(X[W]==="(")q++;else if(X[W]===")"){if(q--,q===0)break}W++}if(q!==0)break;let U=X.substring(K+1,W).trim(),z=W+1,_=(()=>{try{let B=w0(U,Z);if(!B)return"";if(!B["@context"])B["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(B).replace(/<\//g,"<\\/")}</script>`}catch(B){let j=B instanceof Error?B.message:String(B);return e("StructuredData",j,o.EVALUATION_ERROR)}})();X=X.substring(0,G)+_+X.substring(z),Q.lastIndex=0}return X}function zY($,Z,Y,X){let Q=$,J=/@seo\s*\(\s*\{/g,G;while((G=J.exec(Q))!==null){let K=Q.indexOf("{",G.index+4),q=1,W=K+1,U=null,z=!1;while(W<Q.length&&q>0){let F=Q[W];if(z){z=!1,W++;continue}if(F==="\\"&&U){z=!0,W++;continue}if(U){if(F===U)U=null;W++;continue}if(F==='"'||F==="'"||F==="`"){U=F,W++;continue}if(F==="{")q++;else if(F==="}")q--;W++}if(q!==0)break;let _=Q.substring(W).match(/^\s*\)/);if(!_)break;let B=W+_[0].length,j=Q.substring(K,W),H=Q.substring(G.index,B),L=((F)=>{try{let O=w0(F,Z);if(!O)return"";let V="";if(O.title)V+=`<title>${p(O.title)}</title>
|
|
2008
2008
|
`,V+=`<meta name="title" content="${p(O.title)}">
|
|
@@ -2087,9 +2087,13 @@ console.log('[stx] entering IIFE');
|
|
|
2087
2087
|
|
|
2088
2088
|
// Inject x-cloak CSS to prevent FOUC (Flash of Unstyled Content)
|
|
2089
2089
|
// Elements with x-cloak are hidden until the runtime removes the attribute after mount
|
|
2090
|
-
var cloakStyle = document.
|
|
2091
|
-
cloakStyle
|
|
2092
|
-
|
|
2090
|
+
var cloakStyle = document.getElementById ? document.getElementById('stx-cloak-style') : null;
|
|
2091
|
+
if (!cloakStyle) {
|
|
2092
|
+
cloakStyle = document.createElement('style');
|
|
2093
|
+
cloakStyle.id = 'stx-cloak-style';
|
|
2094
|
+
cloakStyle.textContent = '[x-cloak] { display: none !important; }';
|
|
2095
|
+
document.head.appendChild(cloakStyle);
|
|
2096
|
+
}
|
|
2093
2097
|
|
|
2094
2098
|
// ==========================================================================
|
|
2095
2099
|
// Reactive Core
|
|
@@ -8027,8 +8031,13 @@ else {
|
|
|
8027
8031
|
// Auto-initialization
|
|
8028
8032
|
// ==========================================================================
|
|
8029
8033
|
|
|
8030
|
-
|
|
8031
|
-
|
|
8034
|
+
// A dev runtime may be evaluated again by HMR, an embed, or a test harness.
|
|
8035
|
+
// Replace the previous listener so only the latest runtime closure can own
|
|
8036
|
+
// componentScope and reactive subscriptions.
|
|
8037
|
+
if (window.__stxDomReadyHandler) {
|
|
8038
|
+
document.removeEventListener('DOMContentLoaded', window.__stxDomReadyHandler);
|
|
8039
|
+
}
|
|
8040
|
+
const stxDomReadyHandler = () => {
|
|
8032
8041
|
console.log('[stx] DOMContentLoaded fired \u2014 processing scopes');
|
|
8033
8042
|
// Track which scoped elements have been processed
|
|
8034
8043
|
const processedScopes = new Set();
|
|
@@ -8249,7 +8258,10 @@ catch (e) {
|
|
|
8249
8258
|
}
|
|
8250
8259
|
}
|
|
8251
8260
|
});
|
|
8252
|
-
}
|
|
8261
|
+
};
|
|
8262
|
+
window.__stxDomReadyHandler = stxDomReadyHandler;
|
|
8263
|
+
console.log('[stx] registering DOMContentLoaded handler');
|
|
8264
|
+
document.addEventListener('DOMContentLoaded', stxDomReadyHandler);
|
|
8253
8265
|
|
|
8254
8266
|
// ==========================================================================
|
|
8255
8267
|
// Scope Disposal
|
|
@@ -8414,10 +8426,15 @@ catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
|
8414
8426
|
// Re-initialize components after SPA content swap.
|
|
8415
8427
|
// Debounce to handle rapid re-fires (HMR triggers navigate which triggers stx:load again).
|
|
8416
8428
|
var _stxLoadTimer = null;
|
|
8417
|
-
window.
|
|
8429
|
+
if (window.__stxLoadHandler) {
|
|
8430
|
+
window.removeEventListener('stx:load', window.__stxLoadHandler);
|
|
8431
|
+
}
|
|
8432
|
+
function stxLoadHandler() {
|
|
8418
8433
|
if (_stxLoadTimer) { clearTimeout(_stxLoadTimer); }
|
|
8419
8434
|
_stxLoadTimer = setTimeout(_handleStxLoad, 5);
|
|
8420
|
-
}
|
|
8435
|
+
}
|
|
8436
|
+
window.__stxLoadHandler = stxLoadHandler;
|
|
8437
|
+
window.addEventListener('stx:load', stxLoadHandler);
|
|
8421
8438
|
function _handleStxLoad() {
|
|
8422
8439
|
_stxLoadTimer = null;
|
|
8423
8440
|
console.log('[stx:load] START. mountQueue:', mountQueue.length, '_latestSetup:', !!window.stx._latestSetup);
|
package/dist/js-ts.js
CHANGED
|
@@ -36,7 +36,10 @@ async function processCodeBlocks(template, context, filePath, startTag, endTag)
|
|
|
36
36
|
});
|
|
37
37
|
for (const { fullMatch, content, index } of matches)
|
|
38
38
|
try {
|
|
39
|
-
const
|
|
39
|
+
const executionContext = {
|
|
40
|
+
...context,
|
|
41
|
+
global: context
|
|
42
|
+
}, keys = Object.keys(executionContext), values = Object.values(executionContext);
|
|
40
43
|
let strippedContent = content.trim();
|
|
41
44
|
if (startTag === "@ts")
|
|
42
45
|
strippedContent = strippedContent.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, "");
|
package/dist/pwa.js
CHANGED
|
@@ -1830,7 +1830,7 @@ ${H}
|
|
|
1830
1830
|
`),X)Q=Q.replace(/\n/g,`<br />
|
|
1831
1831
|
`);for(let U=0;U<J.length;U++)Q=Q.replace(`\x00CODEBLOCK${U}\x00`,J[U]);return Q=Q.replace(/<p>\s*<\/p>/g,""),Q.trim()}function n0($){let Z=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;$=$.replace(Z,(X,Q)=>{return`const { ${Q.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
|
|
1832
1832
|
`});let Y=/import\s*\{([^}]+)\}\s*from\s*['"]@composables['"]\s*;?\n?/g;return $=$.replace(Y,(X,Q)=>{return`const { ${Q.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__composables
|
|
1833
|
-
`}),$}import zG from"process";function u0($="STX_PUBLIC_"){let Z={},Y={};for(let[X,Q]of Object.entries(zG.env)){if(!X.startsWith($)||Q===void 0)continue;Z[`import.meta.env.${X}`]=JSON.stringify(Q),Y[X]=Q}return Z["import.meta.env"]=JSON.stringify(Y),Z}var T1=()=>{};var x5={};s(x5,{queueClientBundleBuild:()=>i9,hasUserImports:()=>BG,bundleClientScript:()=>HG});import j0 from"path";import y0 from"fs";function BG($){let Z=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Y;while((Y=Z.exec($))!==null){let Q=Y[1];if(!l9.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected user import:",Q),!0}let X=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Y=X.exec($))!==null){let Q=Y[1];if(/\.css(?:\?.*)?$/.test(Q))continue;if(!l9.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected side-effect import:",Q),!0}return!1}function _G($,Z,Y,X){let Q=(J,G)=>{let K=J===Y?Z:j0.dirname(J),q=j0.resolve(K,G),W=[q,`${q}.ts`,`${q}.tsx`,`${q}.js`,`${q}.mjs`,`${q}.jsx`,j0.join(q,"index.ts"),j0.join(q,"index.tsx"),j0.join(q,"index.js"),j0.join(q,"index.mjs")];for(let U of W)try{if(y0.existsSync(U)&&y0.statSync(U,{throwIfNoEntry:!1})?.isFile())return U}catch{}return q};return{name:"stx-client-bundle",setup(J){J.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(G)=>({path:G.path,external:!0})),J.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),J.onResolve({filter:/^\//},(G)=>{if(y0.existsSync(G.path))return{path:G.path};return{path:G.path,external:!0}}),J.onResolve({filter:/^\.\.?\//},(G)=>{let K=Q(G.importer,G.path);return X.add(K),{path:K}}),J.onResolve({filter:/^[@~]\//},(G)=>{let K=j0.resolve($,G.path.slice(2)),q=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,j0.join(K,"index.ts"),j0.join(K,"index.tsx"),j0.join(K,"index.js"),j0.join(K,"index.mjs")];for(let W of q)if(y0.existsSync(W)&&y0.statSync(W,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",W),X.add(W),{path:W};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}}),J.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(G)=>{let K=j0.extname(G.path).toLowerCase(),q=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";if(G.path!==Y)X.add(G.path);return{contents:y0.readFileSync(G.path,"utf8"),loader:q}})}}}function i9($){let Z=globalThis,X=(Z[p9]??Promise.resolve()).then($,$);return Z[p9]=X.then(()=>{return},()=>{return}),X}async function HG($,Z,Y={}){let X=Y.projectRoot||process.cwd(),Q=Y.minify??!1,J=Y.cacheDir||P5(X,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${jG}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),q=j0.join(J,`${K}.js`),W=j0.join(J,`${K}.deps.json`),U=Bun.file(q);if(await U.exists()){let _=Bun.file(W),B=!0;if(await _.exists())try{let H=JSON.parse(await _.text());if(H.metadataVersion!==c9||!Array.isArray(H.files))B=!1;for(let L of Array.isArray(H.files)?H.files:[])try{if(y0.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 U.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let z=M7.get(K);if(z)return await z;let j=i9(()=>OG($,Z,{projectRoot:X,minify:Q,cacheDir:J,hash:K,cachePath:q,depsPath:W}));M7.set(K,j);try{return await j}finally{M7.delete(K)}}async function OG($,Z,Y){let{projectRoot:X,minify:Q,cacheDir:J,hash:G,cachePath:K,depsPath:q}=Y,W=P5(X,"bundle-tmp"),U=j0.join(W,`${G}.ts`),z=j0.join(W,"out",G);y0.mkdirSync(W,{recursive:!0}),y0.mkdirSync(z,{recursive:!0});let j=j0.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((V)=>{let w=V.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 F=_.length>0?`
|
|
1833
|
+
`}),$}import zG from"process";function u0($="STX_PUBLIC_"){let Z={},Y={};for(let[X,Q]of Object.entries(zG.env)){if(!X.startsWith($)||Q===void 0)continue;Z[`import.meta.env.${X}`]=JSON.stringify(Q),Y[X]=Q}return Z["import.meta.env"]=JSON.stringify(Y),Z}var T1=()=>{};var x5={};s(x5,{queueClientBundleBuild:()=>i9,hasUserImports:()=>BG,bundleClientScript:()=>HG});import j0 from"path";import y0 from"fs";function BG($){let Z=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Y;while((Y=Z.exec($))!==null){let Q=Y[1];if(!l9.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected user import:",Q),!0}let X=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Y=X.exec($))!==null){let Q=Y[1];if(/\.css(?:\?.*)?$/.test(Q))continue;if(Q==="@stacksjs/browser")continue;if(!l9.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected side-effect import:",Q),!0}return!1}function _G($,Z,Y,X){let Q=(J,G)=>{let K=J===Y?Z:j0.dirname(J),q=j0.resolve(K,G),W=[q,`${q}.ts`,`${q}.tsx`,`${q}.js`,`${q}.mjs`,`${q}.jsx`,j0.join(q,"index.ts"),j0.join(q,"index.tsx"),j0.join(q,"index.js"),j0.join(q,"index.mjs")];for(let U of W)try{if(y0.existsSync(U)&&y0.statSync(U,{throwIfNoEntry:!1})?.isFile())return U}catch{}return q};return{name:"stx-client-bundle",setup(J){J.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(G)=>({path:G.path,external:!0})),J.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),J.onResolve({filter:/^\//},(G)=>{if(y0.existsSync(G.path))return{path:G.path};return{path:G.path,external:!0}}),J.onResolve({filter:/^\.\.?\//},(G)=>{let K=Q(G.importer,G.path);return X.add(K),{path:K}}),J.onResolve({filter:/^[@~]\//},(G)=>{let K=j0.resolve($,G.path.slice(2)),q=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,j0.join(K,"index.ts"),j0.join(K,"index.tsx"),j0.join(K,"index.js"),j0.join(K,"index.mjs")];for(let W of q)if(y0.existsSync(W)&&y0.statSync(W,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",W),X.add(W),{path:W};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}}),J.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(G)=>{let K=j0.extname(G.path).toLowerCase(),q=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";if(G.path!==Y)X.add(G.path);return{contents:y0.readFileSync(G.path,"utf8"),loader:q}})}}}function i9($){let Z=globalThis,X=(Z[p9]??Promise.resolve()).then($,$);return Z[p9]=X.then(()=>{return},()=>{return}),X}async function HG($,Z,Y={}){let X=Y.projectRoot||process.cwd(),Q=Y.minify??!1,J=Y.cacheDir||P5(X,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${jG}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),q=j0.join(J,`${K}.js`),W=j0.join(J,`${K}.deps.json`),U=Bun.file(q);if(await U.exists()){let _=Bun.file(W),B=!0;if(await _.exists())try{let H=JSON.parse(await _.text());if(H.metadataVersion!==c9||!Array.isArray(H.files))B=!1;for(let L of Array.isArray(H.files)?H.files:[])try{if(y0.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 U.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let z=M7.get(K);if(z)return await z;let j=i9(()=>OG($,Z,{projectRoot:X,minify:Q,cacheDir:J,hash:K,cachePath:q,depsPath:W}));M7.set(K,j);try{return await j}finally{M7.delete(K)}}async function OG($,Z,Y){let{projectRoot:X,minify:Q,cacheDir:J,hash:G,cachePath:K,depsPath:q}=Y,W=P5(X,"bundle-tmp"),U=j0.join(W,`${G}.ts`),z=j0.join(W,"out",G);y0.mkdirSync(W,{recursive:!0}),y0.mkdirSync(z,{recursive:!0});let j=j0.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((V)=>{let w=V.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 F=_.length>0?`
|
|
1834
1834
|
export { ${_.join(", ")} }`:"";await Bun.write(U,$+F),console.log("[stx:bundler] bundling:",G,"from:",j0.basename(Z));let O=new Set;try{let V=await Bun.build({entrypoints:[U],outdir:z,target:"browser",format:"esm",minify:Q,plugins:[_G(X,j,U,O)],define:{"process.env.NODE_ENV":Q?'"production"':'"development"',...u0()},root:X});if(!V.success){let D=V.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 V.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 b=y.trim();if(/^[A-Za-z_$][\w$]*$/.test(b))A.push([b,b])}let N=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 R=`__stxBundle_${G}`,M=A.map(([D,y])=>`${JSON.stringify(D)}: ${y}`).join(", "),T=A.map(([D])=>`var ${D} = undefined;`).join(`
|
|
1835
1835
|
`),I=A.map(([D])=>`${D} = ${R}[${JSON.stringify(D)}];`).join(`
|
|
1836
1836
|
`);if(w=`${N.join(`
|
|
@@ -1996,9 +1996,13 @@ console.log('[stx] entering IIFE');
|
|
|
1996
1996
|
|
|
1997
1997
|
// Inject x-cloak CSS to prevent FOUC (Flash of Unstyled Content)
|
|
1998
1998
|
// Elements with x-cloak are hidden until the runtime removes the attribute after mount
|
|
1999
|
-
var cloakStyle = document.
|
|
2000
|
-
cloakStyle
|
|
2001
|
-
|
|
1999
|
+
var cloakStyle = document.getElementById ? document.getElementById('stx-cloak-style') : null;
|
|
2000
|
+
if (!cloakStyle) {
|
|
2001
|
+
cloakStyle = document.createElement('style');
|
|
2002
|
+
cloakStyle.id = 'stx-cloak-style';
|
|
2003
|
+
cloakStyle.textContent = '[x-cloak] { display: none !important; }';
|
|
2004
|
+
document.head.appendChild(cloakStyle);
|
|
2005
|
+
}
|
|
2002
2006
|
|
|
2003
2007
|
// ==========================================================================
|
|
2004
2008
|
// Reactive Core
|
|
@@ -7936,8 +7940,13 @@ else {
|
|
|
7936
7940
|
// Auto-initialization
|
|
7937
7941
|
// ==========================================================================
|
|
7938
7942
|
|
|
7939
|
-
|
|
7940
|
-
|
|
7943
|
+
// A dev runtime may be evaluated again by HMR, an embed, or a test harness.
|
|
7944
|
+
// Replace the previous listener so only the latest runtime closure can own
|
|
7945
|
+
// componentScope and reactive subscriptions.
|
|
7946
|
+
if (window.__stxDomReadyHandler) {
|
|
7947
|
+
document.removeEventListener('DOMContentLoaded', window.__stxDomReadyHandler);
|
|
7948
|
+
}
|
|
7949
|
+
const stxDomReadyHandler = () => {
|
|
7941
7950
|
console.log('[stx] DOMContentLoaded fired \u2014 processing scopes');
|
|
7942
7951
|
// Track which scoped elements have been processed
|
|
7943
7952
|
const processedScopes = new Set();
|
|
@@ -8158,7 +8167,10 @@ catch (e) {
|
|
|
8158
8167
|
}
|
|
8159
8168
|
}
|
|
8160
8169
|
});
|
|
8161
|
-
}
|
|
8170
|
+
};
|
|
8171
|
+
window.__stxDomReadyHandler = stxDomReadyHandler;
|
|
8172
|
+
console.log('[stx] registering DOMContentLoaded handler');
|
|
8173
|
+
document.addEventListener('DOMContentLoaded', stxDomReadyHandler);
|
|
8162
8174
|
|
|
8163
8175
|
// ==========================================================================
|
|
8164
8176
|
// Scope Disposal
|
|
@@ -8323,10 +8335,15 @@ catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
|
8323
8335
|
// Re-initialize components after SPA content swap.
|
|
8324
8336
|
// Debounce to handle rapid re-fires (HMR triggers navigate which triggers stx:load again).
|
|
8325
8337
|
var _stxLoadTimer = null;
|
|
8326
|
-
window.
|
|
8338
|
+
if (window.__stxLoadHandler) {
|
|
8339
|
+
window.removeEventListener('stx:load', window.__stxLoadHandler);
|
|
8340
|
+
}
|
|
8341
|
+
function stxLoadHandler() {
|
|
8327
8342
|
if (_stxLoadTimer) { clearTimeout(_stxLoadTimer); }
|
|
8328
8343
|
_stxLoadTimer = setTimeout(_handleStxLoad, 5);
|
|
8329
|
-
}
|
|
8344
|
+
}
|
|
8345
|
+
window.__stxLoadHandler = stxLoadHandler;
|
|
8346
|
+
window.addEventListener('stx:load', stxLoadHandler);
|
|
8330
8347
|
function _handleStxLoad() {
|
|
8331
8348
|
_stxLoadTimer = null;
|
|
8332
8349
|
console.log('[stx:load] START. mountQueue:', mountQueue.length, '_latestSetup:', !!window.stx._latestSetup);
|
|
@@ -10620,10 +10637,10 @@ ${NX($).split(",").map((J)=>J.trim()).filter(Boolean).map((J)=>` try { __scopeR
|
|
|
10620
10637
|
`}}if(S){let f=Ij(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 i6(A,I,O,X,Q,J);let{processLoops:b}=await Promise.resolve().then(() => (p6(),AX)),v=b(A,I,O);v=m1(v,I,O);let h=Z5(w);if(v=B1(v,I,O,{forceSignals:h}),T)v+=`
|
|
10621
10638
|
`+T;if(y)v+=`
|
|
10622
10639
|
`+y;return v}catch(w){let A=w instanceof Error?w.message:String(w);return q0("Include",`Error processing include ${B}: ${A}`,Y,L,F)}}let j=/@include\s*\(/g,_;while((_=j.exec(K))!==null){let B=_.index,H=B+_[0].length-1,L=1,F=H+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let O=K.substring(B,F),V=K.substring(H+1,F-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){j.lastIndex=F;continue}let A=w[1],N,R=V.substring(w[0].length),M=c6(R,0);if(M!==-1)N=R.substring(M+1).trim();let T={};if(N)try{T=F0(N,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 z(A,T,$,B);K=K.substring(0,B)+I+K.substring(F),j.lastIndex=0}return K}function n6($,Z){let Y=$;function X(Q,J,G,K){let q=Q,W=!0;while(W){W=!1;let U=new RegExp(`@${J}\\(['"]([^'"]+)['"]\\)`),z=q.match(U);if(!z||z.index===void 0)break;let j=z.index,_=z[1],B=j+z[0].length,H=new RegExp(`@${J}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=B,V=-1;while(F>0&&O<q.length){let A=q.slice(O),N=A.match(H),R=A.match(L),M=N?O+N.index:1/0,T=R?O+R.index:1/0;if(M<T)F++,O=M+(N[0].length||1);else if(T<1/0){if(F--,F===0){V=T;break}O=T+G.length+1}else break}if(V===-1)break;let w=q.slice(B,V);if(!Z[_])Z[_]=[];if(K)Z[_].unshift(w);else Z[_].push(w);q=q.substring(0,j)+q.substring(V+`@${G}`.length),W=!0}return q}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function o6($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
|
|
10623
|
-
`)})}var RX=0,CA,Dj;var IX=k(()=>{C7();p4();t0();i5();Q5();B0();L0();CA=new b1(500),Dj=new Set});import*as s6 from"path";async function DX($,Z,Y=""){if(s6.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 kX($,Z,Y,"@js","@endjs")}async function EX($,Z,Y=""){if(s6.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((J)=>({...J,displayName:`User ${J.id}: ${J.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return kX($,Z,Y,"@ts","@endts")}async function kX($,Z,Y,X,Q){let J=$,G=J5(`${X}([\\s\\S]*?)${Q}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:W,content:U,index:z}of K)try{let j=Object.keys(
|
|
10624
|
-
${
|
|
10625
|
-
${
|
|
10626
|
-
`,
|
|
10640
|
+
`)})}var RX=0,CA,Dj;var IX=k(()=>{C7();p4();t0();i5();Q5();B0();L0();CA=new b1(500),Dj=new Set});import*as s6 from"path";async function DX($,Z,Y=""){if(s6.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 kX($,Z,Y,"@js","@endjs")}async function EX($,Z,Y=""){if(s6.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((J)=>({...J,displayName:`User ${J.id}: ${J.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return kX($,Z,Y,"@ts","@endts")}async function kX($,Z,Y,X,Q){let J=$,G=J5(`${X}([\\s\\S]*?)${Q}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:W,content:U,index:z}of K)try{let j={...Z,global:Z},_=Object.keys(j),B=Object.values(j),H=U.trim();if(X==="@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 F=(H.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((N)=>N.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),O=F.length>0?`return { ${F.join(", ")} };`:"return {};",V=`
|
|
10641
|
+
${H}
|
|
10642
|
+
${O}
|
|
10643
|
+
`,A=Function(..._,V)(...B);if(A&&typeof A==="object")Object.assign(Z,A);J=J.replace(W,"")}catch(j){console.error(`Error executing ${X} code block in ${Y}:`,j);let _=j instanceof Error?j.message:String(j),B=q0(`${X} Directive`,`Error executing code: ${_}`,Y,$,z,W);console.error(B),J=J.replace(W,"")}return J}var bX=k(()=>{Q5();L0()});function kj($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function SX($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,Q,J)=>{return kj(X,J||"_method")})}async function yX($,Z,Y,X,Q){if(!X.middleware||X.middleware.length===0)return $;let J=$,G=X.middleware.filter((K)=>K.timing===Q);if(G.length===0)return J;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(X.debug)console.warn("Invalid middleware:",K);continue}try{let q=await K.handler(J,Z,Y,X);if(typeof q==="string")J=q;else if(X.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(q){if(X.debug)console.error(`Error in middleware ${K.name}:`,q);if(X.debug){let W=q0("Middleware",`Error in middleware '${K.name}': ${q instanceof Error?q.message:String(q)}`,Y,$);J=J.replace(/<body[^>]*>/,`$&
|
|
10627
10644
|
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${o0(W)}</div>
|
|
10628
10645
|
`)}}}return J}async function PX($,Z,Y,X){return yX($,Z,Y,X,"before")}async function CX($,Z,Y,X){return yX($,Z,Y,X,"after")}var vX=k(()=>{t0();L0()});import{defineRoute as nA,defineRoutes as oA,resetRoutes as sA,route as rA,setAppUrl as aA}from"stx-router";import{route as bj}from"stx-router";function xX($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,X,Q,J)=>{try{let G=Q?F0(Q,{}):{};return bj(X,G,J==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var fX=k(()=>{B0()});async function gX($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(_$.exact[$])for(let X of _$.exact[$])await Promise.resolve(X(Z,$));if(_$.exact[Y])for(let X of _$.exact[Y])await Promise.resolve(X(Z,$));for(let{pattern:X,callback:Q}of _$.patterns)if(X.test($)||X.test(Y))await Promise.resolve(Q(Z,$))}var _$;var hX=k(()=>{_$={patterns:[],exact:{}}});function dX($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>dX(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function mX($,Z){if(!/:[\w-]+=/.test($))return $;let Y=$,X=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,Q=[],J;while((J=X.exec($))!==null)Q.push([J.index,J.index+J[0].length]);function G(W){return Q.some(([U,z])=>W>=U&&W<z)}let K=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*'))*)\s*\/?>/g,q=[];while((J=K.exec(Y))!==null){if(G(J.index))continue;let W=J[0],U=J[2];if(!U||!U.includes(":"))continue;let z=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,j,_=U,B=!1;while((j=z.exec(U))!==null){let H=j[1],L=j[2];if(L.includes("()")&&!L.includes(".get(")||L.includes("$store")||L.includes("$ref"))continue;try{let F=Object.keys(Z),O=Object.values(Z),V=L.match(/^([a-zA-Z_$][\w$]*)/);if(V&&!F.includes(V[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(V[1]))continue;let A=Function(...F,`return (${L})`)(...O);if(H==="class"){let N=dX(A);if(N){let R=_.match(/\sclass="([^"]*)"/);if(R)_=_.replace(R[0],` class="${R[1]} ${N}"`);else _=_.replace(j[0],` class="${N}"`)}else _=_.replace(j[0],"");B=!0;continue}if(Sj.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 N=String(A).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");_=_.replace(j[0],` ${H}="${N}"`)}B=!0}catch{continue}}if(B){let H=W.endsWith("/>")?" /":"",F=`<${J[1]}${_}${H}>`;q.push({start:J.index,end:J.index+W.length,replacement:F})}}for(let W=q.length-1;W>=0;W--){let{start:U,end:z,replacement:j}=q[W];Y=Y.slice(0,U)+j+Y.slice(z)}return Y}var Sj;var uX=k(()=>{Sj=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function p1($,Z){let Y=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;Y.lastIndex=Z;let X=Y.exec($);if(!X)return null;let Q=/\/\s*>$/.test(X[0])||yj.has(X[1].toLowerCase()),J=Q?X[2].replace(/\/\s*$/,""):X[2];return{full:X[0],tag:X[1],attrs:J,selfClosing:Q,start:X.index,end:X.index+X[0].length}}function Cj($,Z,Y){let X=1,Q=Y,J=new RegExp(`<${Z}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),G=new RegExp(`</${Z}\\s*>`,"gi");while(X>0&&Q<$.length){J.lastIndex=Q,G.lastIndex=Q;let K=J.exec($),q=G.exec($);if(!q)return-1;if(K&&K.index<q.index)X++,Q=K.index+K[0].length;else{if(X--,X===0)return q.index+q[0].length;Q=q.index+q[0].length}}return-1}function e0($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=Cj($,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 lX($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function A5($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=$.match(new RegExp(`${Y}="([^"]*)"`,"s"))||$.match(new RegExp(`${Y}='([^']*)'`,"s"));return X?X[1]:null}function w1($,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 A1($,Z,Y){let X=Z.selfClosing?" /":"",Q=`<${Z.tag}${Y}${X}>`;return $.slice(0,Z.start)+Q+$.slice(Z.end)}function vj($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function xj($){let Z=$,Y=0;while(Y<Z.length){let X=p1(Z,Y);if(!X)break;let Q=A5(X.attrs,"v-for");if(Q===null){Y=X.end;continue}let J=Q.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!J){Y=X.end;continue}let G=J[1].trim(),K=J[2].trim(),q;if(G.includes(",")){let L=G.split(",").map((V)=>V.trim()),F=L[0],O=L[1];q=`${K} as ${O} => ${F}`}else q=`${K} as ${G}`;let W=w1(X.attrs,"v-for"),U=w1(W,":key").replace(/\s*v-bind:key="[^"]*"/g,""),z=e0(Z,X),j=Z.slice(z.outerStart,z.outerEnd),_=A1(j,{...X,start:0,end:X.end-X.start},U),B=`@foreach(${q})
|
|
10629
10646
|
`,H=`${B}${_}
|
package/dist/signals.js
CHANGED
|
@@ -63,9 +63,13 @@ console.log('[stx] entering IIFE');
|
|
|
63
63
|
|
|
64
64
|
// Inject x-cloak CSS to prevent FOUC (Flash of Unstyled Content)
|
|
65
65
|
// Elements with x-cloak are hidden until the runtime removes the attribute after mount
|
|
66
|
-
var cloakStyle = document.
|
|
67
|
-
cloakStyle
|
|
68
|
-
|
|
66
|
+
var cloakStyle = document.getElementById ? document.getElementById('stx-cloak-style') : null;
|
|
67
|
+
if (!cloakStyle) {
|
|
68
|
+
cloakStyle = document.createElement('style');
|
|
69
|
+
cloakStyle.id = 'stx-cloak-style';
|
|
70
|
+
cloakStyle.textContent = '[x-cloak] { display: none !important; }';
|
|
71
|
+
document.head.appendChild(cloakStyle);
|
|
72
|
+
}
|
|
69
73
|
|
|
70
74
|
// ==========================================================================
|
|
71
75
|
// Reactive Core
|
|
@@ -6003,8 +6007,13 @@ else {
|
|
|
6003
6007
|
// Auto-initialization
|
|
6004
6008
|
// ==========================================================================
|
|
6005
6009
|
|
|
6006
|
-
|
|
6007
|
-
|
|
6010
|
+
// A dev runtime may be evaluated again by HMR, an embed, or a test harness.
|
|
6011
|
+
// Replace the previous listener so only the latest runtime closure can own
|
|
6012
|
+
// componentScope and reactive subscriptions.
|
|
6013
|
+
if (window.__stxDomReadyHandler) {
|
|
6014
|
+
document.removeEventListener('DOMContentLoaded', window.__stxDomReadyHandler);
|
|
6015
|
+
}
|
|
6016
|
+
const stxDomReadyHandler = () => {
|
|
6008
6017
|
console.log('[stx] DOMContentLoaded fired \u2014 processing scopes');
|
|
6009
6018
|
// Track which scoped elements have been processed
|
|
6010
6019
|
const processedScopes = new Set();
|
|
@@ -6225,7 +6234,10 @@ catch (e) {
|
|
|
6225
6234
|
}
|
|
6226
6235
|
}
|
|
6227
6236
|
});
|
|
6228
|
-
}
|
|
6237
|
+
};
|
|
6238
|
+
window.__stxDomReadyHandler = stxDomReadyHandler;
|
|
6239
|
+
console.log('[stx] registering DOMContentLoaded handler');
|
|
6240
|
+
document.addEventListener('DOMContentLoaded', stxDomReadyHandler);
|
|
6229
6241
|
|
|
6230
6242
|
// ==========================================================================
|
|
6231
6243
|
// Scope Disposal
|
|
@@ -6390,10 +6402,15 @@ catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
|
6390
6402
|
// Re-initialize components after SPA content swap.
|
|
6391
6403
|
// Debounce to handle rapid re-fires (HMR triggers navigate which triggers stx:load again).
|
|
6392
6404
|
var _stxLoadTimer = null;
|
|
6393
|
-
window.
|
|
6405
|
+
if (window.__stxLoadHandler) {
|
|
6406
|
+
window.removeEventListener('stx:load', window.__stxLoadHandler);
|
|
6407
|
+
}
|
|
6408
|
+
function stxLoadHandler() {
|
|
6394
6409
|
if (_stxLoadTimer) { clearTimeout(_stxLoadTimer); }
|
|
6395
6410
|
_stxLoadTimer = setTimeout(_handleStxLoad, 5);
|
|
6396
|
-
}
|
|
6411
|
+
}
|
|
6412
|
+
window.__stxLoadHandler = stxLoadHandler;
|
|
6413
|
+
window.addEventListener('stx:load', stxLoadHandler);
|
|
6397
6414
|
function _handleStxLoad() {
|
|
6398
6415
|
_stxLoadTimer = null;
|
|
6399
6416
|
console.log('[stx:load] START. mountQueue:', mountQueue.length, '_latestSetup:', !!window.stx._latestSetup);
|
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"
|