wdwh 1.12.17-dev.0 → 1.12.20

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.
@@ -0,0 +1,14 @@
1
+ export declare function Button({
2
+ label,
3
+ children,
4
+ className,
5
+ ...props
6
+ }: ButtonProps): import("react").JSX.Element;
7
+ type ButtonProps = {
8
+ label?: string;
9
+ children?: React.ReactNode;
10
+ className?: string;
11
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
12
+ style?: React.CSSProperties;
13
+ } & React.HTMLAttributes<HTMLButtonElement>;
14
+ export {};
package/components.js ADDED
@@ -0,0 +1,2 @@
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};
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{useSyncExternalStore as f}from"react";import{useState as l,useSyncExternalStore as T}from"react";function u(r){return l(r)[0]}function p(r,e){let t=r,s=new Set(e?[e]:void 0);function i(){return t}function o(n){return s.add(n),()=>s.delete(n)}return{get:i,set(n){let a=typeof n==="function"?n(t):n;if(Object.is(t,a))return;t=a,s.forEach((c)=>c())},subscribe:o,use(){return f(o,i,i)}}}function y(r,e){return u(p(r,e))}function g(...r){let e="";for(let t of r){if(!t)continue;if(typeof t==="string")e&&(e+=" "),e+=t;else if(Array.isArray(t))e&&(e+=" "),e+=g(e)}return e}export{y as useCreateSignal,p as createSignal,g as clsx};
2
+ import{useSyncExternalStore as l}from"react";import{useConst as p}from"./hooks";function c(n,e){let t=n,i=new Set(e?[e]:void 0);function s(){return t}function o(r){return i.add(r),()=>i.delete(r)}return{get:s,set(r){let u=typeof r==="function"?r(t):r;if(Object.is(t,u))return;t=u,i.forEach((a)=>a())},subscribe:o,use(){return l(o,s,s)}}}function T(n,e){return p(c(n,e))}function f(...n){let e="";for(let t of n){if(!t)continue;if(typeof t==="string")e&&(e+=" "),e+=t;else if(Array.isArray(t))e&&(e+=" "),e+=f(e)}return e}export{T as useCreateSignal,c as createSignal,f as clsx};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdwh",
3
- "version": "1.12.17-dev.0",
3
+ "version": "1.12.20",
4
4
  "author": "kubashh",
5
5
  "description": "The Bun Frontend Framework.",
6
6
  "license": "MIT",
@@ -15,17 +15,17 @@
15
15
  "frontend"
16
16
  ],
17
17
  "files": [
18
- "LICENSE",
19
- "README.md",
20
18
  "index.js",
21
19
  "index.d.ts",
22
20
  "hooks.js",
23
21
  "hooks.d.ts",
22
+ "components.js",
23
+ "components.d.ts",
24
24
  "wdwh.js"
25
25
  ],
26
26
  "scripts": {
27
- "dev": "clear && bun dev/dev.ts",
28
- "build": "bun dev/scripts.ts",
27
+ "dev": "clear && bun dev/dev.ts --wdwh-dev",
28
+ "build": "bun dev/scripts.ts --wdwh-dev",
29
29
  "pub": "bun dev/scripts.ts --publish",
30
30
  "zip": "rm -f template/template.zip && zip -r template/template.zip template/template"
31
31
  },
package/wdwh.js CHANGED
@@ -20,9 +20,9 @@ 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:!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(`
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
- `," ").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){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===""?"":`
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
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(`
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: