wdwh 1.12.0 → 1.12.4
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/README.md +1 -1
- package/hooks.js +1 -1
- package/package.json +12 -12
- package/wdwh.js +20 -12
package/README.md
CHANGED
package/hooks.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{useState as
|
|
2
|
+
import{useState as j}from"react";function x(){let b=j(!1)[1];return()=>b((h)=>!h)}function z(b){return j(b)[0]}function A(){let[b,h]=j(!1);return[b,{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1)}]}export{x as useRefresh,A as useHover,z as useConst};
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wdwh",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.4",
|
|
4
4
|
"author": "kubashh",
|
|
5
5
|
"description": "The Bun framework. Easyer web dev without html for static sites",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"repository": "
|
|
7
|
+
"repository": "kubashh/wdwh",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"react",
|
|
10
|
-
"
|
|
10
|
+
"framework",
|
|
11
11
|
"wdwh",
|
|
12
12
|
"web",
|
|
13
|
-
"
|
|
14
|
-
"css",
|
|
13
|
+
"bun",
|
|
15
14
|
"typescript",
|
|
16
|
-
"
|
|
15
|
+
"frontend"
|
|
17
16
|
],
|
|
18
17
|
"files": [
|
|
19
18
|
"LICENSE",
|
|
@@ -26,6 +25,7 @@
|
|
|
26
25
|
"signal.d.ts"
|
|
27
26
|
],
|
|
28
27
|
"scripts": {
|
|
28
|
+
"dev": "bun dev/dev.ts",
|
|
29
29
|
"build": "bun dev/scripts.ts",
|
|
30
30
|
"pub": "bun dev/scripts.ts pub",
|
|
31
31
|
"zip": "zip -r template/template.zip template/template"
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"wdwh": "./wdwh.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"bun-plugin-tailwind": "
|
|
38
|
-
"react": "^19.2.4",
|
|
39
|
-
"react-dom": "^19.2.4",
|
|
40
|
-
"tailwindcss": "^4.2.0",
|
|
41
|
-
"@types/react": "^19.2.14"
|
|
37
|
+
"bun-plugin-tailwind": "latest"
|
|
42
38
|
},
|
|
43
39
|
"devDependencies": {
|
|
44
40
|
"@types/bun": "^1.3.9",
|
|
45
|
-
"
|
|
41
|
+
"@types/react": "^19.2.14",
|
|
42
|
+
"tailwindcss": "^4.2.1",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"react": "^19.2.4",
|
|
45
|
+
"react-dom": "^19.2.4"
|
|
46
46
|
},
|
|
47
47
|
"prettier": {
|
|
48
48
|
"semi": false,
|
package/wdwh.js
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{cpSync as
|
|
3
|
+
import{cpSync as T,readdirSync as X,rmSync as I}from"fs";var m=`
|
|
4
4
|
[serve.static]
|
|
5
5
|
plugins = ["bun-plugin-tailwind"]
|
|
6
|
-
env = "BUN_PUBLIC_*"
|
|
6
|
+
env = "BUN_PUBLIC_*"`;var P=`import { createRoot } from "react-dom/client"
|
|
7
7
|
import "../../../src/app/index.css"
|
|
8
|
-
import App from "
|
|
8
|
+
import App from "APP_PATH"
|
|
9
9
|
|
|
10
|
-
createRoot(document.getElementsByTagName("body")[0]).render(<App />)
|
|
10
|
+
createRoot(document.getElementsByTagName("body")[0]).render(<App />)
|
|
11
|
+
`;var A=`import index from "./index.html"
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
+
const { url } = Bun.serve({
|
|
13
14
|
routes: { "/*": index },
|
|
14
15
|
development: { hmr: true },
|
|
15
16
|
})
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
`};async function
|
|
19
|
-
`))}async function
|
|
20
|
-
`," ").replaceAll(/\s{2,}/g," ").trim()}}async function
|
|
21
|
-
`}${
|
|
22
|
-
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}var
|
|
23
|
-
|
|
18
|
+
process.send?.(\`> Server running at \${url}\`)
|
|
19
|
+
`;var B="../../../src/app/App.tsx",s="./node_modules/.cache/wdwh",h={[`${s}/frontend.tsx`]:P.replace("APP_PATH",B),[`${s}/server.ts`]:A};async function w(){let r=await Bun.file("./src/app/index.tsx").text(),e=v(r,"export const config"),t=v(r,"export const metadata");if(t.iconPath&&t.iconPath[0]===".")t.iconPath=`../../../src/app${t.iconPath.slice(1)}`;return{config:e,metadata:t}}function v(r,e){let t=r.indexOf("{",r.indexOf(e)),o=r.indexOf("}",t)+1;return C(r.slice(t,o))}function C(r){let e=r.trim();return e=e.replace(/\/\/.*$/gm,""),e=e.replace(/\/\*[\s\S]*?\*\//g,""),e=e.replace(/,\s*([}\]])/g,"$1"),e=e.replace(/([{,]\s*)([A-Za-z0-9_$]+)\s*:/g,'$1"$2":'),e=e.replace(/'|`/g,'"'),JSON.parse(e)}async function i(){let{metadata:r}=await w();for(let n in h)await Bun.write(n,h[n]);let{headContent:e,body:t}=await D(),{title:o,iconPath:p,...a}=r,$=["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="UTF-8" />','<meta name="viewport" content="width=device-width, initial-scale=1.0" />',e,Object.keys(a).map((n)=>`<meta name="${n}" content="${a[n]}" />`),`<link rel="icon" href="${p}" />`,`<title>${o}</title>`,'<script src="./frontend.tsx"></script>',"</head>",t,"</html>"];await Bun.write(`${s}/index.html`,$.join(`
|
|
20
|
+
`))}async function D(){let r=await Bun.file("./src/app/index.tsx").text(),e=_(r,"head").slice(6,-7),t=_(r,"body").replaceAll("className","class"),o=t.indexOf(">")+1,p=t.lastIndexOf("<");return t=t.replace(t.slice(o,p),""),{headContent:e,body:t}}function _(r,e){for(let t,o=r.indexOf("export default");;o++){if(!t&&r.startsWith(`<${e}`,o))t=o;if(t&&r.startsWith(`</${e}>`,o))return r.slice(t,o+e.length+3).replaceAll(`
|
|
21
|
+
`," ").replaceAll(/\s{2,}/g," ").trim()}}async function j(){await i();let r=Bun.file("./bunfig.toml");if(await r.exists()){let t=await r.text();if(!t.includes("bun-plugin-tailwind")){t+=`${t===""?"":`
|
|
22
|
+
`}${m}`,await r.write(t);try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}}else{await r.write(m);async function t(){let o=Bun.file("bunfig.toml");try{if(await o.exists())await o.delete()}catch{}}process.on("SIGINT",t),setTimeout(t,250);try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}await Bun.spawn({cmd:["bun","node_modules/.cache/wdwh/server.ts"],stdout:"ignore",stderr:"inherit",ipc:(t)=>{console.log(t)}}).exited}import S from"bun-plugin-tailwind";import l from"fs";async function N(){let r=performance.now(),{config:e}=await w();await i();let t={entrypoints:[`${s}/index.html`],outdir:e.outdir,plugins:[S],minify:!0,target:"browser",sourcemap:"none",define:{"process.env.NODE_ENV":'"production"'},external:e.external,naming:!e.hashFiles?{chunk:"[name].[ext]",asset:"[name].[ext]"}:void 0};if(e.cleanPrev&&l.existsSync(e.outdir))l.rmSync(e.outdir,{recursive:!0});let o=await Bun.build(t),p=Bun.file(`${e.outdir}/index.html`),a=y(await p.text());if(e.bundleCss){let n=o.outputs.find((d)=>d.path.endsWith(".css"));if(n?.path){let d=Bun.file(n.path),O=a.indexOf('<link rel="stylesheet"'),c=O;for(;c<a.length;c++)if(["/>",'">'].includes(a.slice(c,c+2))){c+=2;break}let J=a.slice(O,c),R=`<style>${y(await d.text())}</style>`;a=a.replace(J,R),await d.delete(),o.outputs.splice(o.outputs.indexOf(n),1)}}await p.write(a);let $=performance.now();if(process.argv.includes("--dir"))console.log(`See "${e.outdir}"`);if(process.argv.includes("--time"))console.log(`Build in ${$-r}ms`)}function y(r){return r.replaceAll(`
|
|
23
|
+
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}var x="./tmp.zip",Y="https://raw.githubusercontent.com/kubashh/wdwh/main/template/template.zip";switch(process.argv[2]){case"dev":await j();break;case"build":await N();break;case"init":{if(X(".").length===0){let t=await(await fetch(Y)).bytes();await Bun.write(x,t);let o=process.platform==="win32"?["powershell","-Command","Expand-Archiv","-Path",x,"-DestinationPath",".","-Force"]:["unzip","-o",x,"-d","."];Bun.spawnSync(o),T("./template/template",".",{recursive:!0}),I(x),I("./template",{recursive:!0}),console.log('Run "bun i && bun dev" and start development!')}else console.log("Cannot initialize wdwh project: folder is not empty. Use an empty directory."),process.exit(1);break}default:console.log(`Usage:
|
|
24
|
+
wdwh dev
|
|
25
|
+
wdwh build
|
|
26
|
+
--dir # Print out dir
|
|
27
|
+
--time # Print build time
|
|
28
|
+
|
|
29
|
+
bunx wdwh@latest init # Init new project in current directory
|
|
30
|
+
|
|
31
|
+
wrong command: "${process.argv.at(2)}"`),process.exit(1)}
|