wdwh 1.12.22 → 1.12.23-dev.1

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,6 +1,6 @@
1
1
  export declare function Button({ label, children, className, ...props }: ButtonProps): import("react").JSX.Element;
2
2
  export declare function TextInput({ onChange, allow, ...props }: TextInputProps): import("react").JSX.Element;
3
- export declare function FileInput({ children, onFile, className, ...props }: FileInputProps): import("react").JSX.Element;
3
+ export declare function FileInput({ children, onFile, className, boxClassName, style, boxStyle, ...props }: FileInputProps): import("react").JSX.Element;
4
4
  type ButtonProps = {
5
5
  label?: string;
6
6
  children?: React.ReactNode;
@@ -14,5 +14,7 @@ type TextInputProps = {
14
14
  } & Omit<React.InputHTMLAttributes<HTMLInputElement>, `type` | `onChange`>;
15
15
  type FileInputProps = {
16
16
  onFile: (file: File) => void;
17
+ boxClassName?: string;
18
+ boxStyle?: React.CSSProperties;
17
19
  } & Omit<React.InputHTMLAttributes<HTMLInputElement>, `type`>;
18
20
  export {};
package/components.js CHANGED
@@ -1,8 +1,8 @@
1
- import{clsx as l}from".";import{useConst as s}from"./hooks";function a({label:n,children:e,className:i,...t}){return<button className={l(i,"cursor-pointer")}{...t}>
1
+ import{clsx as p}from".";import{useConst as a}from"./hooks";function d({label:n,children:e,className:i,...t}){return<button className={p(i,"cursor-pointer")}{...t}>
2
2
  {n||e}
3
- </button>}function c({onChange:n,allow:e,...i}){return<input type="text"onChange={n?({target:t})=>{if(e&&!e.test(t.value)){t.value=t.value.split("").filter(o=>e.test(o)).join("");return}n(t.value)}:void 0}{...i}/>}function d({children:n,onFile:e,className:i,...t}){const o=s(t?.id||Math.random().toFixed(7));return<div>
4
- <label htmlFor={o}className={i}>
3
+ </button>}function f({onChange:n,allow:e,...i}){return<input type="text"onChange={n?({target:t})=>{if(e&&!e.test(t.value)){t.value=t.value.split("").filter(o=>e.test(o)).join("");return}n(t.value)}:void 0}{...i}/>}function x({children:n,onFile:e,className:i,boxClassName:t,style:o,boxStyle:r,...l}){const u=a(l?.id||Math.random().toFixed(7));return<div className={t}style={r}>
4
+ <label htmlFor={u}className={i}style={o}>
5
5
  {n}
6
6
  </label>
7
- <input type="file"className="hidden"id={o}onChange={({target:u})=>{u.files&&u.files[0]&&e(u.files[0])}}{...t}/>
8
- </div>}export{a as Button,d as FileInput,c as TextInput};
7
+ <input type="file"className="hidden"id={u}onChange={({target:s})=>{s.files&&s.files[0]&&e(s.files[0])}}{...l}/>
8
+ </div>}export{d as Button,x as FileInput,f as TextInput};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdwh",
3
- "version": "1.12.22",
3
+ "version": "1.12.23-dev.1",
4
4
  "author": "kubashh",
5
5
  "description": "The Bun Frontend Framework.",
6
6
  "license": "MIT",
@@ -32,12 +32,10 @@
32
32
  "bin": {
33
33
  "wdwh": "./wdwh.js"
34
34
  },
35
- "dependencies": {
36
- "bun-plugin-tailwind": "latest"
37
- },
38
35
  "devDependencies": {
39
36
  "@types/bun": "^1.3.13",
40
37
  "@types/react": "^19.2.14",
38
+ "bun-plugin-tailwind": "latest",
41
39
  "esbuild": "^0.28.0",
42
40
  "react": "^19.2.6",
43
41
  "react-dom": "^19.2.6",
package/wdwh.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{cpSync as $,existsSync as d,rmSync as w}from"fs";import g from"path";var q=`// @ts-nocheck
3
+ var z=import.meta.require;import{cpSync as $,existsSync as d,rmSync as w}from"fs";import g from"path";var q=`// @ts-nocheck
4
4
  import { createRoot } from "react-dom/client";
5
5
  import "CSS_PATH";
6
6
  import App from "APP_PATH";
@@ -20,10 +20,10 @@ 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:!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
- `))}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
- `," ").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("--info"))console.log(`See "${U.outdir}"`),console.log(`Build in ${H-_}ms`)}function o(A){return A.replaceAll(`
23
+ env = "BUN_PUBLIC_*"`;var S="../../../src/app/App.tsx",P="../../../src/app/global.css",D="./node_modules/.cache/wdwh",L={[`${D}/frontend.tsx`]:q.replace("CSS_PATH",P).replace("APP_PATH",S),[`${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 _=m(A),{title:R,iconPath:U,htmlLang:N,...G}=await u(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
+ `))}function m(A){let _=b(A.tsxText,"body").replaceAll("className","class"),R=_.indexOf(">")+1,U=_.lastIndexOf("<");return _.replace(_.slice(R,U),"")}function b(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
+ `," ").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 u(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";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?[(await import("bun-plugin-tailwind")).default]: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
29
  wdwh dev # Start development