wdwh 1.12.20 → 1.12.21

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/components.d.ts CHANGED
@@ -1,14 +1,9 @@
1
- export declare function Button({
2
- label,
3
- children,
4
- className,
5
- ...props
6
- }: ButtonProps): import("react").JSX.Element;
1
+ export declare function Button({ label, children, className, ...props }: ButtonProps): import("react").JSX.Element;
7
2
  type ButtonProps = {
8
- label?: string;
9
- children?: React.ReactNode;
10
- className?: string;
11
- onClick?: React.MouseEventHandler<HTMLButtonElement>;
12
- style?: React.CSSProperties;
3
+ label?: string;
4
+ children?: React.ReactNode;
5
+ className?: string;
6
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
7
+ style?: React.CSSProperties;
13
8
  } & React.HTMLAttributes<HTMLButtonElement>;
14
9
  export {};
package/components.js CHANGED
@@ -1,2 +1,3 @@
1
- // @bun
2
- import{clsx as r}from".";import{jsxDEV as s}from"react/jsx-dev-runtime";function l({label:t,children:e,className:o,...n}){return s("button",{className:r(o,"cursor-pointer"),...n,children:t||e},void 0,!1,void 0,this)}export{l as Button};
1
+ import{clsx as r}from".";function c({label:t,children:e,className:n,...o}){return<button className={r(n,"cursor-pointer")}{...o}>
2
+ {t||e}
3
+ </button>}export{c as Button};
package/hooks.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{useState as n,useSyncExternalStore as s}from"react";function c(){let r=n(!1)[1];return()=>r((e)=>!e)}function i(r){return n(r)[0]}function f(){let[r,e]=n(!1);return[r,{onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1)}]}function g(r,e){let t=n(o(r,e));return a(r,t[0]),t}function o(r,e){let t=new URLSearchParams(location.search);return t.has(r)?decodeURI(t.get(r)):e}function a(r,e){let t=new URLSearchParams(location.search);t.set(r,e),history.pushState(null,"",`?${t.toString()}`)}function S(r){return s(r.subscribe,r.get)}export{S as useSignal,g as useSearchParam,c as useRefresh,f as useHover,i as useConst};
2
+ import{useState as n}from"react";function u(){let r=n(!1)[1];return()=>r((t)=>!t)}function i(r){return n(r)[0]}function c(){let[r,t]=n(!1);return[r,{onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1)}]}function f(r,t){let e=n(s(r,t));return o(r,e[0]),e}function s(r,t){let e=new URLSearchParams(location.search);return e.has(r)?decodeURI(e.get(r)):t}function o(r,t){let e=new URLSearchParams(location.search);e.set(r,t),history.pushState(null,"",`?${e.toString()}`)}function g(r){return r.use()}export{g as useSignal,f as useSearchParam,u as useRefresh,c as useHover,i as useConst};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdwh",
3
- "version": "1.12.20",
3
+ "version": "1.12.21",
4
4
  "author": "kubashh",
5
5
  "description": "The Bun Frontend Framework.",
6
6
  "license": "MIT",
@@ -38,10 +38,11 @@
38
38
  "devDependencies": {
39
39
  "@types/bun": "^1.3.13",
40
40
  "@types/react": "^19.2.14",
41
- "tailwindcss": "^4.2.4",
42
- "typescript": "^6.0.3",
41
+ "esbuild": "^0.28.0",
43
42
  "react": "^19.2.5",
44
- "react-dom": "^19.2.5"
43
+ "react-dom": "^19.2.5",
44
+ "tailwindcss": "^4.2.4",
45
+ "typescript": "^6.0.3"
45
46
  },
46
47
  "prettier": {
47
48
  "printWidth": 108
package/wdwh.js CHANGED
@@ -20,16 +20,15 @@ console.log(\`> Server running at \${url}\`);
20
20
  `;var Q=`
21
21
  [serve.static]
22
22
  plugins = ["bun-plugin-tailwind"]
23
- env = "BUN_PUBLIC_*"`;var F="../../../src/app/App.tsx",S="../../../src/app/global.css",D="./node_modules/.cache/wdwh",L={[`${D}/frontend.tsx`]:q.replace("CSS_PATH",S).replace("APP_PATH",F),[`${D}/server.ts`]:v},C={outdir:"dist",hashFiles:!0,cleanPrev:!1,tailwind:!0,external:[]};import V from"path";async function W(A){let _=[];for(let R of A)_.push(P(R));await Promise.all(_)}async function P(A){I("Create entry:",A.urlPath);for(let j in L)await Bun.write(j,L[j]);I("Creating index.html...");let _=p(A),{title:R,iconPath:U,htmlLang:N,...G}=await b(A),H=V.join("../".repeat(A.urlPath.split("/").length+2),"src/app",A.urlPath,U),K=["<!DOCTYPE html>",`<html lang="${N||"en"}">`,"<head>",'<meta charset="UTF-8" />','<meta name="viewport" content="width=device-width, initial-scale=1.0" />',`<title>${R}</title>`,`<link rel="icon" href="${H}" />`,...Object.entries(G).map(([j,B])=>`<meta name="${j}" content="${B}" />`),`<script src="${A.frontendPath}"></script>`,"</head>",_,"</html>"];await Bun.write(A.htmlOutPath,K.join(`
23
+ env = "BUN_PUBLIC_*"`;var F="../../../src/app/App.tsx",S="../../../src/app/global.css",D="./node_modules/.cache/wdwh",L={[`${D}/frontend.tsx`]:q.replace("CSS_PATH",S).replace("APP_PATH",F),[`${D}/server.ts`]:v},C={outdir:"dist",hashFiles:!0,cleanPrev:!0,tailwind:!0,external:[]};import V from"path";async function W(A){let _=[];for(let R of A)_.push(P(R));await Promise.all(_)}async function P(A){I("Create entry:",A.urlPath);for(let j in L)await Bun.write(j,L[j]);I("Creating index.html...");let _=p(A),{title:R,iconPath:U,htmlLang:N,...G}=await b(A),H=V.join("../".repeat(A.urlPath.split("/").length+2),"src/app",A.urlPath,U),K=["<!DOCTYPE html>",`<html lang="${N||"en"}">`,"<head>",'<meta charset="UTF-8" />','<meta name="viewport" content="width=device-width, initial-scale=1.0" />',`<title>${R}</title>`,`<link rel="icon" href="${H}" />`,...Object.entries(G).map(([j,B])=>`<meta name="${j}" content="${B}" />`),`<script src="${A.frontendPath}"></script>`,"</head>",_,"</html>"];await Bun.write(A.htmlOutPath,K.join(`
24
24
  `))}function p(A){let _=m(A.tsxText,"body").replaceAll("className","class"),R=_.indexOf(">")+1,U=_.lastIndexOf("<");return _.replace(_.slice(R,U),"")}function m(A,_){for(let R,U=A.indexOf("export default");;U++){if(!R&&A.startsWith(`<${_}`,U))R=U;if(R&&A.startsWith(`</${_}>`,U))return A.slice(R,U+_.length+3).replaceAll(`
25
25
  `," ").replaceAll(/\s{2,}/g," ").trim()}}async function Y(){let A=new Bun.Glob("**/index.tsx"),_=[];for(let R of A.scanSync("src/app")){let U=V.join("src/app",R),N=R.replace(/index\.tsx$/,"").replace(/\\/g,"/"),G=V.join(N,"./frontend.tsx"),H=V.join(D,N,"index.html");_.push({tsxPath:U,tsxText:await Bun.file(U).text(),urlPath:N,frontendPath:G,htmlOutPath:H})}return _}async function b(A){let _=A.tsxText.replaceAll(/'|`/g,'"').replaceAll(/([{,]\s*)([a-zA-Z0-9_]+)\s*:/g,'$1"$2":').replace(/,\s*([}\]])/g,"$1"),R=_.indexOf("{",_.indexOf("export const metadata")),U=_.indexOf("}",R)+1;_=_.slice(R,U);let N=JSON.parse(_);if(typeof N.title!=="string")M('Matadata must contain "title"');if(typeof N.iconPath!=="string")M('Matadata must contain "iconPath"');if(typeof N.description!=="string")M('Matadata must contain "description"');return N}function M(A){console.error("[error]",A),process.exit(1)}function I(...A){process.argv.includes("--wdwh-dev")&&console.log("[log]",...A)}async function O(){let A=await Y();await W(A);let _=Bun.file("./bunfig.toml");if(await _.exists()){let R=await _.text();if(!R.includes("bun-plugin-tailwind"))R+=`${R===""?"":`
26
- `}${Q}`,await _.write(R),await J()}else{await _.write(Q);async function R(){let U=Bun.file("bunfig.toml");try{if(await U.exists())await U.delete()}catch{}}process.on("SIGINT",R),setTimeout(R,250),await J()}Bun.spawnSync({cmd:["bun","node_modules/.cache/wdwh/server.ts"],stdio:["ignore","inherit","inherit"]})}async function J(){try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}import x from"fs";import X from"path";import u from"bun-plugin-tailwind";async function k(){let A=await Y(),_=performance.now(),R=await Bun.file("package.json").json(),U=Object.assign(C,R.wdwh);await W(A);let G={entrypoints:A.map((K)=>X.join(D,K.urlPath,"index.html")),outdir:U.outdir,plugins:U.tailwind?[u]:void 0,minify:!0,target:"browser",external:U.external,naming:!U.hashFiles?{chunk:"[name].[ext]",asset:"[name].[ext]"}:void 0,define:{"process.env.NODE_ENV":'"production"'}};if(U.cleanPrev)x.rmSync(U.outdir,{recursive:!0,force:!0});await Bun.build(G);for(let K of A){let j=Bun.file(X.join(U.outdir,K.urlPath,"index.html")),B=o(await j.text());await j.write(B)}let H=performance.now();if(process.argv.includes("--dir"))console.log(`See "${U.outdir}"`);if(process.argv.includes("--time"))console.log(`Build in ${H-_}ms`)}function o(A){return A.replaceAll(`
26
+ `}${Q}`,await _.write(R),await J()}else{await _.write(Q);async function R(){let U=Bun.file("bunfig.toml");try{if(await U.exists())await U.delete()}catch{}}process.on("SIGINT",R),setTimeout(R,250),await J()}Bun.spawnSync({cmd:["bun","node_modules/.cache/wdwh/server.ts"],stdio:["ignore","inherit","inherit"]})}async function J(){try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}import x from"fs";import X from"path";import u from"bun-plugin-tailwind";async function k(){let A=await Y(),_=performance.now(),R=await Bun.file("package.json").json(),U=Object.assign(C,R.wdwh);await W(A);let G={entrypoints:A.map((K)=>X.join(D,K.urlPath,"index.html")),outdir:U.outdir,plugins:U.tailwind?[u]:void 0,minify:!0,target:"browser",external:U.external,naming:!U.hashFiles?{chunk:"[name].[ext]",asset:"[name].[ext]"}:void 0,define:{"process.env.NODE_ENV":'"production"'}};if(U.cleanPrev)x.rmSync(U.outdir,{recursive:!0,force:!0});await Bun.build(G);for(let K of A){let j=Bun.file(X.join(U.outdir,K.urlPath,"index.html")),B=o(await j.text());await j.write(B)}let H=performance.now();if(process.argv.includes("--info"))console.log(`See "${U.outdir}"`),console.log(`Build in ${H-_}ms`)}function o(A){return A.replaceAll(`
27
27
  `," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}var Z="./tmp.zip",f="https://raw.githubusercontent.com/kubashh/wdwh/main/template/template.zip";switch(process.argv[2]){case"dev":await O();break;case"build":await k();break;case"init":{let A=await fetch(f);if(!A.ok)console.log(`feach error: ${A.status}`),process.exit(1);let _=await A.bytes();await Bun.write(Z,_);let R=process.platform==="win32"?["powershell","-Command","Expand-Archiv","-Path",Z,"-DestinationPath",".","-Force"]:["unzip","-o",Z,"-d","."];Bun.spawnSync(R);let U=new Bun.Glob("**/*");for(let N of U.scanSync("template/template"))if(!d(N))$(g.join("template/template",N),N),console.log(`+ ${N}`);$("./template/template",".",{recursive:!0}),w(Z),w("./template",{recursive:!0}),console.log("Installing dependencies..."),await Bun.$`bun update`,console.log(`
28
28
  Run "bun dev" and start development!`);break}default:console.log(`Usage:
29
- wdwh dev
30
- wdwh build
31
- --dir # Print out dir
32
- --time # Print build time
29
+ wdwh dev # Start development
30
+ wdwh build # Build project to path specified in package.json, default "dist"
31
+ --info # Print build info
33
32
 
34
33
  bunx wdwh@latest init # Init new project in current directory
35
34