wdwh 1.12.9 → 1.12.10
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/package.json +1 -1
- package/signal.d.ts +1 -0
- package/signal.js +1 -1
- package/wdwh.js +2 -2
package/package.json
CHANGED
package/signal.d.ts
CHANGED
package/signal.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{useSyncExternalStore as
|
|
2
|
+
import{useSyncExternalStore as o}from"react";function u(t){let r=t,i=new Set;return{get(){return r},set(e){let n=typeof e==="function"?e(r):e;if(Object.is(r,n))return;r=n,i.forEach((s)=>s())},forceRefresh(){i.forEach((e)=>e())},subscribe(e){return i.add(e),()=>i.delete(e)}}}function T(t){return o(t.subscribe,t.get)}export{T as useSignal,u as createSignal};
|
package/wdwh.js
CHANGED
|
@@ -18,8 +18,8 @@ process.send?.(\`> Server running at \${url}\`);
|
|
|
18
18
|
plugins = ["bun-plugin-tailwind"]
|
|
19
19
|
env = "BUN_PUBLIC_*"`;var b="../../../src/app/App.tsx",B="./node_modules/.cache/wdwh",k={[`${B}/frontend.tsx`]:X.replace("APP_PATH",b),[`${B}/server.ts`]:O};import D from"path";async function M(R){for(let U of R){for(let N in k)await Bun.write(N,k[N]);let{headContent:A,body:_}=await x(U),v=D.join(B,U.urlPath,"index.html"),G=["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="UTF-8" />','<meta name="viewport" content="width=device-width, initial-scale=1.0" />',A,'<script src="./frontend.tsx"></script>',"</head>",_,"</html>"];await Bun.write(v,G.join(`
|
|
20
20
|
`))}}async function x(R){let U=await Bun.file(R.tsxPath).text(),A=$(U,"head").slice(6,-7),_=A.match(/<link\s+rel=["']icon["']\s+href=["']([^"']+)["']\s*\/?>/)?.at(1);if(_){let W=D.join("../".repeat(R.urlPath.split("/").length+2),"src/app",R.urlPath,_);A=A.replace(/<link\s+rel=["']icon["']\s+href=["'][^"']+["']\s*\/?>/,`<link rel="icon" href="${W}" />`)}let v=$(U,"body").replaceAll("className","class"),G=v.indexOf(">")+1,N=v.lastIndexOf("<");return v=v.replace(v.slice(G,N),""),{headContent:A,body:v}}function $(R,U){for(let A,_=R.indexOf("export default");;_++){if(!A&&R.startsWith(`<${U}`,_))A=_;if(A&&R.startsWith(`</${U}>`,_))return R.slice(A,_+U.length+3).replaceAll(`
|
|
21
|
-
`," ").replaceAll(/\s{2,}/g," ").trim()}}function Q(){let R=new Bun.Glob("**/index.tsx"),U=[];for(let A of R.scanSync("src/app")){let _=D.join("src/app",A),v=A.replace(/index\.tsx$/,"").replace(/\\/g,"/");U.push({tsxPath:_,urlPath:v})}return U}async function w(){let R=Q();await M(R);let U=Bun.file("./bunfig.toml");if(await U.exists()){let _=await U.text();if(!_.includes("bun-plugin-tailwind"))_+=`${_===""?"":`
|
|
22
|
-
`}${L}`,await U.write(_),H()}else{await U.write(L);async function _(){let v=Bun.file("bunfig.toml");try{if(await v.exists())await v.delete()}catch{}}process.on("SIGINT",_),setTimeout(_,250),H()}await Bun.spawn({cmd:["bun","node_modules/.cache/wdwh/server.ts"],stdio:["ignore","ignore","
|
|
21
|
+
`," ").replaceAll(/\s{2,}/g," ").trim()}}function Q(){let R=new Bun.Glob("**/index.tsx"),U=[];for(let A of R.scanSync("src/app")){let _=D.join("src/app",A),v=A.replace(/index\.tsx$/,"").replace(/\\/g,"/");U.push({tsxPath:_,urlPath:v})}return U}async function w(){let R=Q();await M(R);let U=Bun.file("./bunfig.toml");if(await U.exists()){console.log("Creating bunfig...");let _=await U.text();if(!_.includes("bun-plugin-tailwind"))_+=`${_===""?"":`
|
|
22
|
+
`}${L}`,await U.write(_),await H()}else{console.log("Deleting bunfig..."),await U.write(L);async function _(){let v=Bun.file("bunfig.toml");try{if(await v.exists())await v.delete()}catch{}}process.on("SIGINT",_),setTimeout(_,250),await H()}console.log("Exists of bunfig...");function A(){console.log("Exit")}process.on("SIGINT",A);try{await Bun.spawn({cmd:["bun","node_modules/.cache/wdwh/server.ts"],stdio:["ignore","ignore","pipe"],ipc:(v)=>{console.log(v)}}).exited}catch(_){console.error(_)}}async function H(){try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}import u from"fs";import z from"path";import g from"bun-plugin-tailwind";async function T(){let R=Q(),U=performance.now(),_=(await Bun.file("package.json").json()).wdwh||{};if(!_.outdir)_.outdir="dist";await M(R);let G={entrypoints:R.map((Y)=>z.join(B,Y.urlPath,"index.html")),outdir:_.outdir,plugins:[g],minify:!0,target:"browser",sourcemap:"none",external:_.external,naming:_.hashFiles===!1?{chunk:"[name].[ext]",asset:"[name].[ext]"}:void 0,define:{"process.env.NODE_ENV":'"production"'}};if(_.cleanPrev)u.rmSync(_.outdir,{recursive:!0,force:!0});let N=await Bun.build(G);for(let Y of R){let J=Bun.file(z.join(_.outdir,Y.urlPath,"index.html")),j=C(await J.text());if(R.length===1){let Z=N.outputs.find((K)=>K.path.endsWith(".css"));if(Z?.path){let K=Bun.file(Z.path),I=j.indexOf('<link rel="stylesheet"'),q=I;for(;q<j.length;q++)if(["/>",'">'].includes(j.slice(q,q+2))){q+=2;break}let S=j.slice(I,q),E=`<style>${C(await K.text())}</style>`;j=j.replace(S,E),await K.delete(),N.outputs.splice(N.outputs.indexOf(Z),1)}}await J.write(j)}let W=performance.now();if(process.argv.includes("--dir"))console.log(`See "${_.outdir}"`);if(process.argv.includes("--time"))console.log(`Build in ${W-U}ms`)}function C(R){return R.replaceAll(`
|
|
23
23
|
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}var V="./tmp.zip",f="https://raw.githubusercontent.com/kubashh/wdwh/main/template/template.zip";switch(process.argv[2]){case"dev":await w();break;case"build":await T();break;case"init":{let R=await fetch(f);if(!R.ok)console.log(`feach error: ${R.status}`),process.exit(1);let U=await R.bytes();await Bun.write(V,U);let A=process.platform==="win32"?["powershell","-Command","Expand-Archiv","-Path",V,"-DestinationPath",".","-Force"]:["unzip","-o",V,"-d","."];Bun.spawnSync(A);let _=new Bun.Glob("**/*");for(let v of _.scanSync("template/template"))if(!o(v))F(d.join("template/template",v),v),console.log(`+ ${v}`);F("./template/template",".",{recursive:!0}),P(V),P("./template",{recursive:!0}),console.log("Installing dependencies..."),await Bun.$`bun update`,console.log(`
|
|
24
24
|
Run "bun dev" and start development!`);break}default:console.log(`Usage:
|
|
25
25
|
wdwh dev
|