wdwh 1.12.19 → 1.12.21-dev.0
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 +9 -0
- package/components.js +3 -0
- package/hooks.js +1 -1
- package/index.js +1 -1
- package/package.json +7 -6
- package/wdwh.js +5 -6
package/components.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function Button({ label, children, className, ...props }: ButtonProps): import("react").JSX.Element;
|
|
2
|
+
type ButtonProps = {
|
|
3
|
+
label?: string;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
} & React.HTMLAttributes<HTMLButtonElement>;
|
|
9
|
+
export {};
|
package/components.js
ADDED
package/hooks.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{useState as n
|
|
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/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{useSyncExternalStore as
|
|
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.
|
|
3
|
+
"version": "1.12.21-dev.0",
|
|
4
4
|
"author": "kubashh",
|
|
5
5
|
"description": "The Bun Frontend Framework.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,12 +15,12 @@
|
|
|
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": {
|
|
@@ -38,10 +38,11 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/bun": "^1.3.13",
|
|
40
40
|
"@types/react": "^19.2.14",
|
|
41
|
-
"
|
|
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:!
|
|
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("--
|
|
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
|
-
--
|
|
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
|
|