wdwh 1.12.4 → 1.12.9
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 +21 -6
- package/hooks.d.ts +1 -0
- package/hooks.js +1 -1
- package/package.json +5 -8
- package/signal.d.ts +6 -6
- package/signal.js +1 -1
- package/wdwh.js +16 -15
- package/config.d.ts +0 -17
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
# WDWH (
|
|
1
|
+
# WDWH (Easier web dev without html)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Bun frontend framework.
|
|
4
|
+
Designed to simplify static-site web development using TypeScript and Bun runtime.
|
|
5
|
+
The framework automatically converts `src/app/**/index.tsx` pages into HTML
|
|
6
|
+
during build, supports multi‑page projects, and bundles client-side code with
|
|
7
|
+
tailwind CSS.
|
|
8
|
+
For development you need the Bun runtime.
|
|
9
|
+
[Install bun](https://bun.com/docs/installation)
|
|
4
10
|
|
|
5
11
|
## Init project
|
|
6
12
|
|
|
@@ -29,9 +35,18 @@ bun i wdwh@latest
|
|
|
29
35
|
|
|
30
36
|
### 3. [Add files](https://github.com/kubashh/wdwh/tree/main/template/template)
|
|
31
37
|
|
|
32
|
-
- `src/app/index.tsx`
|
|
33
|
-
|
|
38
|
+
- `src/app/index.tsx` and additional `src/app/` subfolders – **all**
|
|
39
|
+
`index.tsx` files are treated as separate pages and will produce
|
|
40
|
+
`/dist/index.html`, `/dist/foo/index.html`, etc.
|
|
41
|
+
- `src/app/App.tsx`
|
|
34
42
|
- `src/app/react.svg` (favicon, can be any other image, bun path must be specify in `src/app/index.tsx`)
|
|
35
|
-
- `src/app/
|
|
43
|
+
- `src/app/global.css` (must contain `@import "tailwindcss";`)
|
|
36
44
|
- `package.json` (with scripts `dev` `build`)
|
|
37
|
-
- `tsconfig.json` (for `typescript`)
|
|
45
|
+
- `tsconfig.json` (for `typescript`). The framework ships with strict
|
|
46
|
+
settings and checks every page file during build.
|
|
47
|
+
|
|
48
|
+
### Optional helper utilities
|
|
49
|
+
|
|
50
|
+
- You can use built‑in helpers such as `useUrl()` (client side hook that
|
|
51
|
+
returns the current path) and other future `comptime` helpers for compiling
|
|
52
|
+
data at build time. Extend them by editing `src/lib/*` or adding plugins.
|
package/hooks.d.ts
CHANGED
package/hooks.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{useState as
|
|
2
|
+
import{useState as n}from"react";function c(){let r=n(!1)[1];return()=>r((t)=>!t)}function u(r){return n(r)[0]}function i(){let[r,t]=n(!1);return[r,{onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1)}]}function f(r,t){let e=n(s(r,t));return a(r,e[0]),e}function s(r,t){let e=new URLSearchParams(location.search);return e.has(r)?decodeURI(e.get(r)):t}function a(r,t){let e=new URLSearchParams(location.search);e.set(r,t),history.pushState(null,"",`?${e.toString()}`)}export{f as useSearchParam,c as useRefresh,i as useHover,u as useConst};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wdwh",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.9",
|
|
4
4
|
"author": "kubashh",
|
|
5
|
-
"description": "The Bun
|
|
5
|
+
"description": "The Bun Frontend Framework.",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"repository": "kubashh/wdwh",
|
|
7
|
+
"repository": "https://github.com/kubashh/wdwh",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"react",
|
|
10
10
|
"framework",
|
|
@@ -17,15 +17,13 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"LICENSE",
|
|
19
19
|
"README.md",
|
|
20
|
-
"dist",
|
|
21
|
-
"config.d.ts",
|
|
22
20
|
"hooks.js",
|
|
23
21
|
"hooks.d.ts",
|
|
24
22
|
"signal.js",
|
|
25
23
|
"signal.d.ts"
|
|
26
24
|
],
|
|
27
25
|
"scripts": {
|
|
28
|
-
"dev": "bun dev/dev.ts",
|
|
26
|
+
"dev": "clear && bun dev/dev.ts",
|
|
29
27
|
"build": "bun dev/scripts.ts",
|
|
30
28
|
"pub": "bun dev/scripts.ts pub",
|
|
31
29
|
"zip": "zip -r template/template.zip template/template"
|
|
@@ -37,7 +35,7 @@
|
|
|
37
35
|
"bun-plugin-tailwind": "latest"
|
|
38
36
|
},
|
|
39
37
|
"devDependencies": {
|
|
40
|
-
"@types/bun": "^1.3.
|
|
38
|
+
"@types/bun": "^1.3.10",
|
|
41
39
|
"@types/react": "^19.2.14",
|
|
42
40
|
"tailwindcss": "^4.2.1",
|
|
43
41
|
"typescript": "^5.9.3",
|
|
@@ -45,7 +43,6 @@
|
|
|
45
43
|
"react-dom": "^19.2.4"
|
|
46
44
|
},
|
|
47
45
|
"prettier": {
|
|
48
|
-
"semi": false,
|
|
49
46
|
"printWidth": 108
|
|
50
47
|
}
|
|
51
48
|
}
|
package/signal.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
type
|
|
1
|
+
type Listener = () => void;
|
|
2
2
|
export type Signal<T> = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
get(): T;
|
|
4
|
+
set(value: T): void;
|
|
5
|
+
subscribe(listener: Listener): () => void;
|
|
6
6
|
};
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function useSignal<T>(
|
|
7
|
+
export declare function createSignal<T>(initial: T): Signal<T>;
|
|
8
|
+
export declare function useSignal<T>(signal: Signal<T>): T;
|
|
9
9
|
export {};
|
package/signal.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{useSyncExternalStore as s}from"react";function u(t){let r=t,n=new Set;return{get(){return r},set(e){if(Object.is(r,e))return;r=e,n.forEach((i)=>i())},subscribe(e){return n.add(e),()=>n.delete(e)}}}function c(t){return s(t.subscribe,t.get)}export{c as useSignal,u as createSignal};
|
package/wdwh.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{cpSync as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
env = "BUN_PUBLIC_*"`;var P=`import { createRoot } from "react-dom/client"
|
|
7
|
-
import "../../../src/app/index.css"
|
|
8
|
-
import App from "APP_PATH"
|
|
3
|
+
import{cpSync as F,existsSync as o,rmSync as P}from"fs";import d from"path";var X=`import { createRoot } from "react-dom/client";
|
|
4
|
+
import "../../../src/app/global.css";
|
|
5
|
+
import App from "APP_PATH";
|
|
9
6
|
|
|
10
|
-
createRoot(document.getElementsByTagName("body")[0]).render(<App />)
|
|
11
|
-
`;var
|
|
7
|
+
createRoot(document.getElementsByTagName("body")[0]).render(<App />);
|
|
8
|
+
`;var O=`import index from "./index.html";
|
|
12
9
|
|
|
13
10
|
const { url } = Bun.serve({
|
|
14
11
|
routes: { "/*": index },
|
|
15
12
|
development: { hmr: true },
|
|
16
|
-
})
|
|
13
|
+
});
|
|
17
14
|
|
|
18
|
-
process.send?.(\`> Server running at \${url}\`)
|
|
19
|
-
`;var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
process.send?.(\`> Server running at \${url}\`);
|
|
16
|
+
`;var L=`
|
|
17
|
+
[serve.static]
|
|
18
|
+
plugins = ["bun-plugin-tailwind"]
|
|
19
|
+
env = "BUN_PUBLIC_*"`;var b="../../../src/app/App.tsx",B="./node_modules/.cache/wdwh",k={[`${B}/frontend.tsx`]:X.replace("APP_PATH",b),[`${B}/server.ts`]:O};import D from"path";async function M(R){for(let U of R){for(let N in k)await Bun.write(N,k[N]);let{headContent:A,body:_}=await x(U),v=D.join(B,U.urlPath,"index.html"),G=["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="UTF-8" />','<meta name="viewport" content="width=device-width, initial-scale=1.0" />',A,'<script src="./frontend.tsx"></script>',"</head>",_,"</html>"];await Bun.write(v,G.join(`
|
|
20
|
+
`))}}async function x(R){let U=await Bun.file(R.tsxPath).text(),A=$(U,"head").slice(6,-7),_=A.match(/<link\s+rel=["']icon["']\s+href=["']([^"']+)["']\s*\/?>/)?.at(1);if(_){let W=D.join("../".repeat(R.urlPath.split("/").length+2),"src/app",R.urlPath,_);A=A.replace(/<link\s+rel=["']icon["']\s+href=["'][^"']+["']\s*\/?>/,`<link rel="icon" href="${W}" />`)}let v=$(U,"body").replaceAll("className","class"),G=v.indexOf(">")+1,N=v.lastIndexOf("<");return v=v.replace(v.slice(G,N),""),{headContent:A,body:v}}function $(R,U){for(let A,_=R.indexOf("export default");;_++){if(!A&&R.startsWith(`<${U}`,_))A=_;if(A&&R.startsWith(`</${U}>`,_))return R.slice(A,_+U.length+3).replaceAll(`
|
|
21
|
+
`," ").replaceAll(/\s{2,}/g," ").trim()}}function Q(){let R=new Bun.Glob("**/index.tsx"),U=[];for(let A of R.scanSync("src/app")){let _=D.join("src/app",A),v=A.replace(/index\.tsx$/,"").replace(/\\/g,"/");U.push({tsxPath:_,urlPath:v})}return U}async function w(){let R=Q();await M(R);let U=Bun.file("./bunfig.toml");if(await U.exists()){let _=await U.text();if(!_.includes("bun-plugin-tailwind"))_+=`${_===""?"":`
|
|
22
|
+
`}${L}`,await U.write(_),H()}else{await U.write(L);async function _(){let v=Bun.file("bunfig.toml");try{if(await v.exists())await v.delete()}catch{}}process.on("SIGINT",_),setTimeout(_,250),H()}await Bun.spawn({cmd:["bun","node_modules/.cache/wdwh/server.ts"],stdio:["ignore","ignore","inherit"],ipc:(_)=>{console.log(_)}}).exited}function H(){Bun.spawnSync({cmd:["bunx","wdwh","dev"],stdio:["ignore","ignore","ignore"]}),process.exit()}import u from"fs";import z from"path";import g from"bun-plugin-tailwind";async function T(){let R=Q(),U=performance.now(),_=(await Bun.file("package.json").json()).wdwh||{};if(!_.outdir)_.outdir="dist";await M(R);let G={entrypoints:R.map((Y)=>z.join(B,Y.urlPath,"index.html")),outdir:_.outdir,plugins:[g],minify:!0,target:"browser",sourcemap:"none",external:_.external,naming:_.hashFiles===!1?{chunk:"[name].[ext]",asset:"[name].[ext]"}:void 0,define:{"process.env.NODE_ENV":'"production"'}};if(_.cleanPrev)u.rmSync(_.outdir,{recursive:!0,force:!0});let N=await Bun.build(G);for(let Y of R){let J=Bun.file(z.join(_.outdir,Y.urlPath,"index.html")),j=C(await J.text());if(R.length===1){let Z=N.outputs.find((K)=>K.path.endsWith(".css"));if(Z?.path){let K=Bun.file(Z.path),I=j.indexOf('<link rel="stylesheet"'),q=I;for(;q<j.length;q++)if(["/>",'">'].includes(j.slice(q,q+2))){q+=2;break}let E=j.slice(I,q),S=`<style>${C(await K.text())}</style>`;j=j.replace(E,S),await K.delete(),N.outputs.splice(N.outputs.indexOf(Z),1)}}await J.write(j)}let W=performance.now();if(process.argv.includes("--dir"))console.log(`See "${_.outdir}"`);if(process.argv.includes("--time"))console.log(`Build in ${W-U}ms`)}function C(R){return R.replaceAll(`
|
|
23
|
+
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}var V="./tmp.zip",f="https://raw.githubusercontent.com/kubashh/wdwh/main/template/template.zip";switch(process.argv[2]){case"dev":await w();break;case"build":await T();break;case"init":{let R=await fetch(f);if(!R.ok)console.log(`feach error: ${R.status}`),process.exit(1);let U=await R.bytes();await Bun.write(V,U);let A=process.platform==="win32"?["powershell","-Command","Expand-Archiv","-Path",V,"-DestinationPath",".","-Force"]:["unzip","-o",V,"-d","."];Bun.spawnSync(A);let _=new Bun.Glob("**/*");for(let v of _.scanSync("template/template"))if(!o(v))F(d.join("template/template",v),v),console.log(`+ ${v}`);F("./template/template",".",{recursive:!0}),P(V),P("./template",{recursive:!0}),console.log("Installing dependencies..."),await Bun.$`bun update`,console.log(`
|
|
24
|
+
Run "bun dev" and start development!`);break}default:console.log(`Usage:
|
|
24
25
|
wdwh dev
|
|
25
26
|
wdwh build
|
|
26
27
|
--dir # Print out dir
|
package/config.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
type WdwhConfig = {
|
|
2
|
-
outdir: string
|
|
3
|
-
bundleCss?: boolean
|
|
4
|
-
hashFiles?: boolean
|
|
5
|
-
cleanPrev?: boolean
|
|
6
|
-
external?: string[]
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
type Metadata = {
|
|
10
|
-
iconPath: string
|
|
11
|
-
title: string
|
|
12
|
-
description?: string
|
|
13
|
-
author?: string
|
|
14
|
-
keywords?: string
|
|
15
|
-
themeColor?: string
|
|
16
|
-
[name: string]: string | undefined
|
|
17
|
-
}
|