wdwh 1.10.1 → 1.11.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/README.md +2 -2
- package/dist/wdwh.js +8 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Works only with Bun runtime
|
|
|
5
5
|
## Init project
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
bunx wdwh@latest init
|
|
8
|
+
bunx wdwh@latest init
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Adding to project
|
|
@@ -27,7 +27,7 @@ bun i -d wdwh
|
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
### 3. [Add files](https://github.com/kubashh/
|
|
30
|
+
### 3. [Add files](https://github.com/kubashh/wdwh/tree/main/template/template)
|
|
31
31
|
|
|
32
32
|
- `src/app/index.tsx` (contains only `html` `head` `body` tags and `metadata`)
|
|
33
33
|
- `src/app/App.tsx` (app entry point)
|
package/dist/wdwh.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var l="./node_modules/.cache/wdwh",
|
|
3
|
+
import{cpSync as F,readdirSync as C,rmSync as P}from"fs";var l="./node_modules/.cache/wdwh",u=`
|
|
4
4
|
[serve.static]
|
|
5
5
|
plugins = ["bun-plugin-tailwind"]
|
|
6
|
-
env = "BUN_PUBLIC_*"`,
|
|
6
|
+
env = "BUN_PUBLIC_*"`,f={["./node_modules/.cache/wdwh/frontend.tsx"]:`import { createRoot } from "react-dom/client"
|
|
7
7
|
import "../../../src/app/index.css"
|
|
8
8
|
import App from "../../../src/app/App.tsx"
|
|
9
9
|
|
|
@@ -15,11 +15,9 @@ const server = Bun.serve({
|
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
console.log(\`> Server running at \${server.url}\`)
|
|
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,",")}switch(process.argv[2]){case"dev":await
|
|
23
|
-
|
|
24
|
-
bunx wdwh@latest init my-app # create app in 'my-app' directory, "." for current directory`),process.exit(1);Bun.spawnSync(["bun","create","wdwh-app@latest",process.argv[3]]);break;default:console.log(`wrong command: "${process.argv.at(2)}"
|
|
25
|
-
try "dev" | "build"`),process.exit(1)}
|
|
18
|
+
`};async function m(){let t=await Bun.file("./src/app/index.tsx").text(),e=g(t,"export const config"),n=g(t,"export const metadata");if(n.iconPath&&n.iconPath[0]===".")n.iconPath=`../../../src/app${n.iconPath.slice(1)}`;return{config:e,metadata:n}}function g(t,e){let n=t.indexOf("{",t.indexOf(e)),i=t.indexOf("}",n)+1;return A(t.slice(n,i))}function A(t){let e=t.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 d(){let{metadata:t}=await m();for(let r in f)await Bun.write(r,f[r]);let{headContent:e,body:n}=await v(),{title:i,iconPath:s,...a}=t,c=["<!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((r)=>`<meta name="${r}" content="${a[r]}" />`),`<link rel="icon" href="${s}" />`,`<title>${i}</title>`,'<script src="./frontend.tsx"></script>',"</head>",n,"</html>"];await Bun.write(`${l}/index.html`,c.join(`
|
|
19
|
+
`))}async function v(){let t=await Bun.file("./src/app/index.tsx").text(),e=h(t,"head").slice(6,-7),n=h(t,"body").replaceAll("className","class"),i=n.indexOf(">")+1,s=n.lastIndexOf("<");return n=n.replace(n.slice(i,s),""),{headContent:e,body:n}}function h(t,e){for(let n,i=t.indexOf("export default");;i++){if(!n&&t.startsWith(`<${e}`,i))n=i;if(n&&t.startsWith(`</${e}>`,i))return t.slice(n,i+e.length+3).replaceAll(`
|
|
20
|
+
`," ").replaceAll(/\s{2,}/g," ").trim()}}async function x(){await d();let t=Bun.file("./bunfig.toml");if(await t.exists()){let e=await t.text();if(!e.includes("bun-plugin-tailwind")){e+=`${e===""?"":`
|
|
21
|
+
`}${u}`,await t.write(e);try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}}else{await t.write(u);async function e(){let n=Bun.file("bunfig.toml");try{if(await n.exists())await n.delete()}catch{}}process.on("SIGINT",e),setTimeout(e,250);try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}await Bun.$`bun node_modules/.cache/wdwh/server.ts`}import O from"bun-plugin-tailwind";import w from"fs";async function b(){let{config:t}=await m();await d();let e={entrypoints:[`${l}/index.html`],outdir:t.outdir,plugins:[O],minify:!0,target:"browser",sourcemap:"none",define:{"process.env.NODE_ENV":'"production"'},external:t.external,naming:!t.hashFiles?{chunk:"[name].[ext]",asset:"[name].[ext]"}:void 0};if(t.cleanPrev&&w.existsSync(t.outdir))w.rmSync(t.outdir,{recursive:!0});let n=await Bun.build(e),i=Bun.file(`${t.outdir}/index.html`),s=$(await i.text());if(t.bundleCss){let a=n.outputs.find((c)=>c.path.endsWith(".css"));if(a?.path){let c=Bun.file(a.path),r=s.indexOf('<link rel="stylesheet"'),o=r;for(;o<s.length;o++)if(["/>",'">'].includes(s.slice(o,o+2))){o+=2;break}let y=s.slice(r,o),B=`<style>${$(await c.text())}</style>`;s=s.replace(y,B),await c.delete(),n.outputs.splice(n.outputs.indexOf(a),1)}}await i.write(s),console.log(`See "${t.outdir}"`)}function $(t){return t.replaceAll(`
|
|
22
|
+
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}var p="./tmp.zip",S="https://raw.githubusercontent.com/kubashh/wdwh/main/template/template.zip";switch(process.argv[2]){case"dev":await x();break;case"build":await b();break;case"init":{if(C(".").length===0){let n=await(await fetch(S)).bytes();await Bun.write(p,n);let i=process.platform==="win32"?["powershell","-Command","Expand-Archiv","-Path",p,"-DestinationPath",".","-Force"]:["unzip","-o",p,"-d","."];Bun.spawnSync(i),F("./template/template",".",{recursive:!0}),await Bun.file(p).delete(),P("./template",{recursive:!0})}else console.log("Cannot initialize wdwh project: folder is not empty. Use an empty directory."),process.exit(1);break}default:console.log(`wrong command: "${process.argv.at(2)}"
|
|
23
|
+
try "dev" | "build" | "init"`),process.exit(1)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wdwh",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"author": "kubashh",
|
|
5
5
|
"description": "The Bun framework. Easyer web dev without html for static sites",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"react",
|
|
10
10
|
"bun",
|
|
11
11
|
"wdwh",
|
|
12
|
-
"kubashh",
|
|
13
12
|
"web",
|
|
14
13
|
"html",
|
|
15
14
|
"css",
|
|
16
|
-
"typescript"
|
|
15
|
+
"typescript",
|
|
16
|
+
"framework"
|
|
17
17
|
],
|
|
18
18
|
"files": [
|
|
19
19
|
"LICENSE",
|