@stacksjs/stx 0.2.127 → 0.2.129
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 +135 -133
- package/dist/client-script-bundler.js +2 -1
- package/dist/craft.js +83 -81
- package/dist/native-build.d.ts +1 -0
- package/dist/native-build.js +64 -17
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +1 -1
- package/package.json +5 -5
package/dist/native-build.d.ts
CHANGED
package/dist/native-build.js
CHANGED
|
@@ -91,29 +91,57 @@ async function buildMacOS(html, appName, appVersion, outputDir, format, config,
|
|
|
91
91
|
sidebarConfigPath = join(resourcesDir, "sidebar-config.json");
|
|
92
92
|
await Bun.write(sidebarConfigPath, JSON.stringify(config.sidebar.config));
|
|
93
93
|
}
|
|
94
|
-
const sidebarFlags = config.sidebar?.enabled ? `--native-sidebar --sidebar-width ${config.sidebar?.width || 240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"` : "",
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
const sidebarFlags = config.sidebar?.enabled ? `--native-sidebar --sidebar-width ${config.sidebar?.width || 240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"` : "", menubarOnly = config.menubarOnly ?? config.systemTray;
|
|
95
|
+
if ((config.bundleStyle || (await supportsBundleManifest(craftPath) ? "executable" : "launcher")) === "executable") {
|
|
96
|
+
const executablePath = join(macOSDir, appName);
|
|
97
|
+
copyFileSync(craftPath, executablePath);
|
|
98
|
+
chmodSync(executablePath, 493);
|
|
99
|
+
const manifest = {
|
|
100
|
+
html: "index.html",
|
|
101
|
+
title: config.window?.title || appName,
|
|
102
|
+
width: config.window?.width || 1200,
|
|
103
|
+
height: config.window?.height || 800,
|
|
104
|
+
devTools: Boolean(config.devTools)
|
|
105
|
+
};
|
|
106
|
+
if (menubarOnly)
|
|
107
|
+
manifest.menubarOnly = !0;
|
|
108
|
+
else if (config.systemTray)
|
|
109
|
+
manifest.systemTray = !0;
|
|
110
|
+
if (config.window?.frameless)
|
|
111
|
+
manifest.frameless = !0;
|
|
112
|
+
if (config.window?.transparent)
|
|
113
|
+
manifest.transparent = !0;
|
|
114
|
+
if (config.window?.alwaysOnTop)
|
|
115
|
+
manifest.alwaysOnTop = !0;
|
|
116
|
+
if (config.window?.resizable === !1)
|
|
117
|
+
manifest.resizable = !1;
|
|
118
|
+
await Bun.write(join(resourcesDir, "craft.json"), `${JSON.stringify(manifest, null, 2)}
|
|
119
|
+
`);
|
|
120
|
+
} else {
|
|
121
|
+
const craftBinaryDest = join(macOSDir, "craft");
|
|
122
|
+
copyFileSync(craftPath, craftBinaryDest);
|
|
123
|
+
chmodSync(craftBinaryDest, 493);
|
|
124
|
+
const sidebarFlags = config.sidebar?.enabled ? `--native-sidebar --sidebar-width ${config.sidebar?.width || 240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"` : "", launcherScript = `#!/bin/bash
|
|
98
125
|
set -euo pipefail
|
|
99
126
|
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
100
127
|
RESOURCES="$DIR/../Resources"
|
|
101
128
|
exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
|
|
102
129
|
${[
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
130
|
+
`--title "${config.window?.title || appName}"`,
|
|
131
|
+
`--width ${config.window?.width || 1200}`,
|
|
132
|
+
`--height ${config.window?.height || 800}`,
|
|
133
|
+
menubarOnly ? "--menubar-only" : config.systemTray ? "--system-tray" : "",
|
|
134
|
+
config.devTools ? "" : "--no-devtools",
|
|
135
|
+
config.window?.frameless ? "--frameless" : "",
|
|
136
|
+
config.window?.transparent ? "--transparent" : "",
|
|
137
|
+
config.window?.alwaysOnTop ? "--always-on-top" : "",
|
|
138
|
+
config.window?.resizable === !1 ? "--no-resize" : "",
|
|
139
|
+
sidebarFlags
|
|
140
|
+
].filter(Boolean).join(" \\\n ")}
|
|
114
141
|
`, launcherPath = join(macOSDir, appName);
|
|
115
|
-
|
|
116
|
-
|
|
142
|
+
await Bun.write(launcherPath, launcherScript);
|
|
143
|
+
chmodSync(launcherPath, 493);
|
|
144
|
+
}
|
|
117
145
|
const hasIcon = Boolean(config.icon && await Bun.file(config.icon).exists());
|
|
118
146
|
if (hasIcon)
|
|
119
147
|
copyFileSync(config.icon, join(resourcesDir, "AppIcon.icns"));
|
|
@@ -144,6 +172,25 @@ exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
|
|
|
144
172
|
}
|
|
145
173
|
return { success: !0, target: "macos", format: "app", outputPath: appBundlePath };
|
|
146
174
|
}
|
|
175
|
+
async function supportsBundleManifest(craftPath) {
|
|
176
|
+
try {
|
|
177
|
+
const proc = Bun.spawn([craftPath, "--version"], { stdout: "pipe", stderr: "pipe" }), [stdout, stderr] = await Promise.all([
|
|
178
|
+
new Response(proc.stdout).text(),
|
|
179
|
+
new Response(proc.stderr).text()
|
|
180
|
+
]);
|
|
181
|
+
await proc.exited;
|
|
182
|
+
const version = `${stdout}
|
|
183
|
+
${stderr}`.match(/(\d+)\.(\d+)\.(\d+)/);
|
|
184
|
+
if (!version)
|
|
185
|
+
return !1;
|
|
186
|
+
const [major, minor, patch] = version.slice(1).map(Number);
|
|
187
|
+
if (major > 0 || minor > 0)
|
|
188
|
+
return !0;
|
|
189
|
+
return patch >= 57;
|
|
190
|
+
} catch {
|
|
191
|
+
return !1;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
147
194
|
function escapeXml(value) {
|
|
148
195
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
149
196
|
}
|
package/dist/pwa.js
CHANGED
|
@@ -1830,7 +1830,7 @@ ${H}
|
|
|
1830
1830
|
`),X)Q=Q.replace(/\n/g,`<br />
|
|
1831
1831
|
`);for(let z=0;z<J.length;z++)Q=Q.replace(`\x00CODEBLOCK${z}\x00`,J[z]);return Q=Q.replace(/<p>\s*<\/p>/g,""),Q.trim()}function c0($){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 oQ from"process";function d0($="STX_PUBLIC_"){let Z={},Y={};for(let[X,Q]of Object.entries(oQ.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 M1=()=>{};var b5={};r(b5,{queueClientBundleBuild:()=>x9,hasUserImports:()=>rQ,bundleClientScript:()=>tQ});import j0 from"path";import b0 from"fs";function rQ($){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(!P9.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(!P9.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected side-effect import:",Q),!0}return!1}function aQ($,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 z of W)try{if(b0.existsSync(z)&&b0.statSync(z,{throwIfNoEntry:!1})?.isFile())return z}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(b0.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(b0.existsSync(W)&&b0.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";
|
|
1833
|
+
`}),$}import oQ from"process";function d0($="STX_PUBLIC_"){let Z={},Y={};for(let[X,Q]of Object.entries(oQ.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 M1=()=>{};var b5={};r(b5,{queueClientBundleBuild:()=>x9,hasUserImports:()=>rQ,bundleClientScript:()=>tQ});import j0 from"path";import b0 from"fs";function rQ($){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(!P9.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(!P9.some((G)=>G.test(Q)))return console.log("[stx:bundler] detected side-effect import:",Q),!0}return!1}function aQ($,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 z of W)try{if(b0.existsSync(z)&&b0.statSync(z,{throwIfNoEntry:!1})?.isFile())return z}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(b0.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(b0.existsSync(W)&&b0.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:b0.readFileSync(G.path,"utf8"),loader:q}})}}}function x9($){let Z=globalThis,X=(Z[C9]??Promise.resolve()).then($,$);return Z[C9]=X.then(()=>{return},()=>{return}),X}async function tQ($,Z,Y={}){let X=Y.projectRoot||process.cwd(),Q=Y.minify??!1,J=Y.cacheDir||D5(X,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${sQ}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),q=j0.join(J,`${K}.js`),W=j0.join(J,`${K}.deps.json`),z=Bun.file(q);if(await z.exists()){let _=Bun.file(W),j=!0;if(await _.exists())try{let H=JSON.parse(await _.text());if(H.metadataVersion!==v9||!Array.isArray(H.files))j=!1;for(let L of Array.isArray(H.files)?H.files:[])try{if(b0.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 z.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let U=O7.get(K);if(U)return await U;let B=x9(()=>eQ($,Z,{projectRoot:X,minify:Q,cacheDir:J,hash:K,cachePath:q,depsPath:W}));O7.set(K,B);try{return await B}finally{O7.delete(K)}}async function eQ($,Z,Y){let{projectRoot:X,minify:Q,cacheDir:J,hash:G,cachePath:K,depsPath:q}=Y,W=D5(X,"bundle-tmp"),z=j0.join(W,`${G}.ts`),U=j0.join(W,"out",G);b0.mkdirSync(W,{recursive:!0}),b0.mkdirSync(U,{recursive:!0});let B=j0.dirname(Z),_=[],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 R=V.split(":")[0].trim();if(R)_.push(R)});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(z,$+F),console.log("[stx:bundler] bundling:",G,"from:",j0.basename(Z));let O=new Set;try{let V=await Bun.build({entrypoints:[z],outdir:U,target:"browser",format:"esm",minify:Q,plugins:[aQ(X,B,z,O)],define:{"process.env.NODE_ENV":Q?'"production"':'"development"',...d0()},root:X});if(!V.success){let D=V.logs.filter((P)=>P.level==="error").map((P)=>P.message).join(", ");return console.warn("[stx:bundler] build failed:",D),$}let R="";for(let D of V.outputs){R=await D.text();break}let w=[];for(let D of R.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let P of D[1].split(",")){let S=P.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(S){w.push([S[2],S[1]]);continue}let b=P.trim();if(/^[A-Za-z_$][\w$]*$/.test(b))w.push([b,b])}let A=R.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];R=R.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}`,T=w.map(([D,P])=>`${JSON.stringify(D)}: ${P}`).join(", "),M=w.map(([D])=>`var ${D} = undefined;`).join(`
|
|
1835
1835
|
`),I=w.map(([D])=>`${D} = ${N}[${JSON.stringify(D)}];`).join(`
|
|
1836
1836
|
`);if(R=`${A.join(`
|
package/dist/ssg.js
CHANGED
|
@@ -639,7 +639,7 @@ ${H}
|
|
|
639
639
|
`),J)X=X.replace(/\n/g,`<br />
|
|
640
640
|
`);for(let W=0;W<Q.length;W++)X=X.replace(`\x00CODEBLOCK${W}\x00`,Q[W]);return X=X.replace(/<p>\s*<\/p>/g,""),X.trim()}function o0($){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 qQ from"process";function p0($="STX_PUBLIC_"){let Z={},Y={};for(let[J,X]of Object.entries(qQ.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 b1=()=>{};var b5={};e(b5,{queueClientBundleBuild:()=>U9,hasUserImports:()=>UQ,bundleClientScript:()=>BQ});import F0 from"path";import C0 from"fs";function UQ($){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(!z9.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(!z9.some((G)=>G.test(X)))return console.log("[stx:bundler] detected side-effect import:",X),!0}return!1}function jQ($,Z,Y,J){let X=(Q,G)=>{let K=Q===Y?Z:F0.dirname(Q),z=F0.resolve(K,G),q=[z,`${z}.ts`,`${z}.tsx`,`${z}.js`,`${z}.mjs`,`${z}.jsx`,F0.join(z,"index.ts"),F0.join(z,"index.tsx"),F0.join(z,"index.js"),F0.join(z,"index.mjs")];for(let W of q)try{if(C0.existsSync(W)&&C0.statSync(W,{throwIfNoEntry:!1})?.isFile())return W}catch{}return z};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(C0.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=F0.resolve($,G.path.slice(2)),z=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,F0.join(K,"index.ts"),F0.join(K,"index.tsx"),F0.join(K,"index.js"),F0.join(K,"index.mjs")];for(let q of z)if(C0.existsSync(q)&&C0.statSync(q,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",q),J.add(q),{path:q};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=F0.extname(G.path).toLowerCase(),z=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";
|
|
642
|
+
`}),$}import qQ from"process";function p0($="STX_PUBLIC_"){let Z={},Y={};for(let[J,X]of Object.entries(qQ.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 b1=()=>{};var b5={};e(b5,{queueClientBundleBuild:()=>U9,hasUserImports:()=>UQ,bundleClientScript:()=>BQ});import F0 from"path";import C0 from"fs";function UQ($){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(!z9.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(!z9.some((G)=>G.test(X)))return console.log("[stx:bundler] detected side-effect import:",X),!0}return!1}function jQ($,Z,Y,J){let X=(Q,G)=>{let K=Q===Y?Z:F0.dirname(Q),z=F0.resolve(K,G),q=[z,`${z}.ts`,`${z}.tsx`,`${z}.js`,`${z}.mjs`,`${z}.jsx`,F0.join(z,"index.ts"),F0.join(z,"index.tsx"),F0.join(z,"index.js"),F0.join(z,"index.mjs")];for(let W of q)try{if(C0.existsSync(W)&&C0.statSync(W,{throwIfNoEntry:!1})?.isFile())return W}catch{}return z};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(C0.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=F0.resolve($,G.path.slice(2)),z=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,F0.join(K,"index.ts"),F0.join(K,"index.tsx"),F0.join(K,"index.js"),F0.join(K,"index.mjs")];for(let q of z)if(C0.existsSync(q)&&C0.statSync(q,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",q),J.add(q),{path:q};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=F0.extname(G.path).toLowerCase(),z=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:C0.readFileSync(G.path,"utf8"),loader:z}})}}}function U9($){let Z=globalThis,J=(Z[q9]??Promise.resolve()).then($,$);return Z[q9]=J.then(()=>{return},()=>{return}),J}async function BQ($,Z,Y={}){let J=Y.projectRoot||process.cwd(),X=Y.minify??!1,Q=Y.cacheDir||B1(J,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${WQ}\x00${$}\x00${Z}`);let K=G.digest("hex").slice(0,12),z=F0.join(Q,`${K}.js`),q=F0.join(Q,`${K}.deps.json`),W=Bun.file(z);if(await W.exists()){let B=Bun.file(q),_=!0;if(await B.exists())try{let H=JSON.parse(await B.text());if(H.metadataVersion!==W9||!Array.isArray(H.files))_=!1;for(let L of Array.isArray(H.files)?H.files:[])try{if(C0.statSync(L.path).mtimeMs!==L.mtimeMs){_=!1;break}}catch{_=!1;break}}catch{_=!1}if(_)return console.log("[stx:bundler] cache hit:",K),await W.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let U=Q7.get(K);if(U)return await U;let j=U9(()=>_Q($,Z,{projectRoot:J,minify:X,cacheDir:Q,hash:K,cachePath:z,depsPath:q}));Q7.set(K,j);try{return await j}finally{Q7.delete(K)}}async function _Q($,Z,Y){let{projectRoot:J,minify:X,cacheDir:Q,hash:G,cachePath:K,depsPath:z}=Y,q=B1(J,"bundle-tmp"),W=F0.join(q,`${G}.ts`),U=F0.join(q,"out",G);C0.mkdirSync(q,{recursive:!0}),C0.mkdirSync(U,{recursive:!0});let j=F0.dirname(Z),B=[],_=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,H=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,L;while((L=_.exec($))!==null){if(L[1])continue;if(L[2])L[2].split(",").forEach((F)=>{let w=F.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 V=B.length>0?`
|
|
643
643
|
export { ${B.join(", ")} }`:"";await Bun.write(W,$+V),console.log("[stx:bundler] bundling:",G,"from:",F0.basename(Z));let O=new Set;try{let F=await Bun.build({entrypoints:[W],outdir:U,target:"browser",format:"esm",minify:X,plugins:[jQ(J,j,W,O)],define:{"process.env.NODE_ENV":X?'"production"':'"development"',...p0()},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(`
|
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.129",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,12 +117,12 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@cwcss/crosswind": "^0.2.12",
|
|
119
119
|
"@stacksjs/clapp": "^0.2.0",
|
|
120
|
-
"@stacksjs/desktop": "0.2.
|
|
121
|
-
"@stacksjs/sanitizer": "0.2.
|
|
120
|
+
"@stacksjs/desktop": "0.2.129",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.129",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.129",
|
|
124
124
|
"bunfig": "^0.15.15",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.129",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.1.9",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|