wdwh 1.7.6 → 1.7.8
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/dist/main.js +7 -10
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import
|
|
3
|
+
import v from"child_process";var d="./node_modules/.cache/wdwh",f=`
|
|
4
4
|
[serve.static]
|
|
5
5
|
plugins = ["bun-plugin-tailwind"]
|
|
6
|
-
env = "BUN_PUBLIC_*"`,
|
|
6
|
+
env = "BUN_PUBLIC_*"`,m={["./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,12 +15,9 @@ const server = Bun.serve({
|
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
console.log(\`> Server running at \${server.url}\`)
|
|
18
|
-
`};import
|
|
19
|
-
`))}
|
|
20
|
-
`," ").replaceAll(/\s{2,}/g," ").trim()}}
|
|
21
|
-
`}${
|
|
22
|
-
`,"");console.log(`
|
|
23
|
-
Output:
|
|
24
|
-
${o}`)}function b(e){return e.replaceAll(`
|
|
25
|
-
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}switch(process.argv.at(2)){case"dev":await w();break;case"build":await y();break;default:console.log(`wrong command: "${process.argv.at(2)}"
|
|
18
|
+
`};import c from"fs";function s(t){return new h(t)}class h{path;constructor(t){this.path=t}text(){return String(c.readFileSync(this.path))}json(){if(!this.exists())return{};return JSON.parse(this.text())}write(t){let e=this.path.split("/");for(let n=1;n<e.length;n++){let i=e.slice(0,n).join("/");if(!c.existsSync(i))c.mkdirSync(i)}c.writeFileSync(this.path,t)}exists(){return c.existsSync(this.path)}delete(){c.unlinkSync(this.path)}}function S(){let t=s("./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 O(t.slice(n,i))}function O(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)}function u(){let{metadata:t}=S();for(let l in m)s(l).write(m[l]);let{headContent:e,body:n}=T(),{title:i,iconPath:r,...o}=t,a=["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="UTF-8" />','<meta name="viewport" content="width=device-width, initial-scale=1.0" />',e,Object.keys(o).map((l)=>`<meta name="${l}" content="${o[l]}" />`),`<link rel="icon" href="${r}" />`,`<title>${i}</title>`,'<script src="./frontend.tsx"></script>',"</head>",n,"</html>"];s(`${d}/index.html`).write(a.join(`
|
|
19
|
+
`))}function T(){let t=s("./src/app/index.tsx").text(),e=x(t,"head").slice(6,-7),n=x(t,"body").replaceAll("className","class"),i=n.indexOf(">")+1,r=n.lastIndexOf("<");return n=n.replace(n.slice(i,r),""),{headContent:e,body:n}}function x(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()}}function I(){u();let t="bun node_modules/.cache/wdwh/server.ts",e=s("./bunfig.toml");if(e.exists()){let r=e.text();if(!r.includes("bun-plugin-tailwind"))r+=`${r===""?"":`
|
|
21
|
+
`}${f}`,e.write(r),t="wdwh dev"}else{let r=function(){let o=s("bunfig.toml");try{if(o.exists())o.delete()}catch{}};e.write(f),process.on("SIGINT",r),setTimeout(r,250),t="wdwh dev"}let[n,...i]=t.split(" ");v.spawnSync(n,i,{stdio:"inherit"})}import P from"bun-plugin-tailwind";async function G(){let{config:t}=S();u();let e={entrypoints:[`${d}/index.html`],outdir:t.outdir,plugins:[P],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&&c.existsSync(t.outdir))c.rmSync(t.outdir,{recursive:!0});let n=await Bun.build(e),i=s(`${t.outdir}/index.html`),r=y(i.text());if(t.bundleCss){let o=n.outputs.find((a)=>a.path.endsWith(".css"));if(o?.path){let a=s(o.path),l=r.indexOf('<link rel="stylesheet"'),p=l;for(;p<r.length;p++)if(["/>",'">'].includes(r.slice(p,p+2))){p+=2;break}let b=r.slice(l,p),w=`<style>${y(a.text())}</style>`;r=r.replace(b,w),a.delete(),n.outputs.splice(n.outputs.indexOf(o),1)}}i.write(r),console.log(`See "${t.outdir}"`)}function y(t){return t.replaceAll(`
|
|
22
|
+
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}switch(process.argv.at(2)){case"dev":I();break;case"build":await G();break;default:console.log(`wrong command: "${process.argv.at(2)}"
|
|
26
23
|
try "dev" | "build"`),process.exit()}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wdwh",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
4
4
|
"author": "kubashh",
|
|
5
5
|
"description": "The Bun framework. Easyer web dev without html",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "bun build ./src/main.ts --outdir=dist --target=bun --minify --external=bun-plugin-tailwind",
|
|
26
|
-
"
|
|
26
|
+
"pub": "bun scripts/publish.ts"
|
|
27
27
|
},
|
|
28
28
|
"bin": {
|
|
29
29
|
"wdwh": "./dist/main.js"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/bun": "latest",
|
|
39
|
-
"
|
|
39
|
+
"@kubashh/nutil": "latest"
|
|
40
40
|
},
|
|
41
41
|
"prettier": {
|
|
42
42
|
"semi": false,
|