wdwh 1.9.1 → 1.10.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 CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Works only with Bun runtime
4
4
 
5
- ## [Init new project](https://npmjs.com/package/create-wdwh-app)
5
+ ## Init project
6
6
 
7
7
  ```sh
8
- bun create wdwh-app@latest .
8
+ bunx wdwh@latest init .
9
9
  ```
10
10
 
11
11
  ## Adding to project
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",u=`
3
+ var l="./node_modules/.cache/wdwh",d=`
4
4
  [serve.static]
5
5
  plugins = ["bun-plugin-tailwind"]
6
- env = "BUN_PUBLIC_*"`,p={["./node_modules/.cache/wdwh/frontend.tsx"]:`import { createRoot } from "react-dom/client"
6
+ env = "BUN_PUBLIC_*"`,u={["./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,9 +15,11 @@ const server = Bun.serve({
15
15
  })
16
16
 
17
17
  console.log(\`> Server running at \${server.url}\`)
18
- `};async function f(){let e=await Bun.file("./src/app/index.tsx").text(),t=m(e,"export const config"),n=m(e,"export const metadata");if(n.iconPath&&n.iconPath[0]===".")n.iconPath=`../../../src/app${n.iconPath.slice(1)}`;return{config:t,metadata:n}}function m(e,t){let n=e.indexOf("{",e.indexOf(t)),i=e.indexOf("}",n)+1;return v(e.slice(n,i))}function v(e){let t=e.trim();return t=t.replace(/\/\/.*$/gm,""),t=t.replace(/\/\*[\s\S]*?\*\//g,""),t=t.replace(/,\s*([}\]])/g,"$1"),t=t.replace(/([{,]\s*)([A-Za-z0-9_$]+)\s*:/g,'$1"$2":'),t=t.replace(/'|`/g,'"'),JSON.parse(t)}async function d(){let{metadata:e}=await f();for(let s in p)await Bun.write(s,p[s]);let{headContent:t,body:n}=await B(),{title:i,iconPath:r,...a}=e,c=["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="UTF-8" />','<meta name="viewport" content="width=device-width, initial-scale=1.0" />',t,Object.keys(a).map((s)=>`<meta name="${s}" content="${a[s]}" />`),`<link rel="icon" href="${r}" />`,`<title>${i}</title>`,'<script src="./frontend.tsx"></script>',"</head>",n,"</html>"];await Bun.write(`${l}/index.html`,c.join(`
18
+ `};async function f(){let e=await Bun.file("./src/app/index.tsx").text(),t=m(e,"export const config"),n=m(e,"export const metadata");if(n.iconPath&&n.iconPath[0]===".")n.iconPath=`../../../src/app${n.iconPath.slice(1)}`;return{config:t,metadata:n}}function m(e,t){let n=e.indexOf("{",e.indexOf(t)),i=e.indexOf("}",n)+1;return v(e.slice(n,i))}function v(e){let t=e.trim();return t=t.replace(/\/\/.*$/gm,""),t=t.replace(/\/\*[\s\S]*?\*\//g,""),t=t.replace(/,\s*([}\]])/g,"$1"),t=t.replace(/([{,]\s*)([A-Za-z0-9_$]+)\s*:/g,'$1"$2":'),t=t.replace(/'|`/g,'"'),JSON.parse(t)}async function p(){let{metadata:e}=await f();for(let a in u)await Bun.write(a,u[a]);let{headContent:t,body:n}=await B(),{title:i,iconPath:r,...s}=e,c=["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="UTF-8" />','<meta name="viewport" content="width=device-width, initial-scale=1.0" />',t,Object.keys(s).map((a)=>`<meta name="${a}" content="${s[a]}" />`),`<link rel="icon" href="${r}" />`,`<title>${i}</title>`,'<script src="./frontend.tsx"></script>',"</head>",n,"</html>"];await Bun.write(`${l}/index.html`,c.join(`
19
19
  `))}async function B(){let e=await Bun.file("./src/app/index.tsx").text(),t=g(e,"head").slice(6,-7),n=g(e,"body").replaceAll("className","class"),i=n.indexOf(">")+1,r=n.lastIndexOf("<");return n=n.replace(n.slice(i,r),""),{headContent:t,body:n}}function g(e,t){for(let n,i=e.indexOf("export default");;i++){if(!n&&e.startsWith(`<${t}`,i))n=i;if(n&&e.startsWith(`</${t}>`,i))return e.slice(n,i+t.length+3).replaceAll(`
20
- `," ").replaceAll(/\s{2,}/g," ").trim()}}async function h(){d();let e=Bun.file("./bunfig.toml");if(await e.exists()){let t=await e.text();if(!t.includes("bun-plugin-tailwind")){t+=`${t===""?"":`
21
- `}${u}`,await e.write(t);try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}}else{await e.write(u);async function t(){let n=Bun.file("bunfig.toml");try{if(await n.exists())await n.delete()}catch{}}process.on("SIGINT",t),setTimeout(t,250);try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}await Bun.$`bun node_modules/.cache/wdwh/server.ts`}import A from"bun-plugin-tailwind";import x from"fs";async function b(){let{config:e}=await f();d();let t={entrypoints:[`${l}/index.html`],outdir:e.outdir,plugins:[A],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&&x.existsSync(e.outdir))x.rmSync(e.outdir,{recursive:!0});let n=await Bun.build(t),i=Bun.file(`${e.outdir}/index.html`),r=w(await i.text());if(e.bundleCss){let a=n.outputs.find((c)=>c.path.endsWith(".css"));if(a?.path){let c=Bun.file(a.path),s=r.indexOf('<link rel="stylesheet"'),o=s;for(;o<r.length;o++)if(["/>",'">'].includes(r.slice(o,o+2))){o+=2;break}let y=r.slice(s,o),$=`<style>${w(await c.text())}</style>`;r=r.replace(y,$),await c.delete(),n.outputs.splice(n.outputs.indexOf(a),1)}}await i.write(r),console.log(`See "${e.outdir}"`)}function w(e){return e.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":await h();break;case"build":await b();break;default:console.log(`wrong command: "${process.argv.at(2)}"
23
- try "dev" | "build"`),process.exit()}
20
+ `," ").replaceAll(/\s{2,}/g," ").trim()}}async function h(){await p();let e=Bun.file("./bunfig.toml");if(await e.exists()){let t=await e.text();if(!t.includes("bun-plugin-tailwind")){t+=`${t===""?"":`
21
+ `}${d}`,await e.write(t);try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}}else{await e.write(d);async function t(){let n=Bun.file("bunfig.toml");try{if(await n.exists())await n.delete()}catch{}}process.on("SIGINT",t),setTimeout(t,250);try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}await Bun.$`bun node_modules/.cache/wdwh/server.ts`}import A from"bun-plugin-tailwind";import w from"fs";async function b(){let{config:e}=await f();await p();let t={entrypoints:[`${l}/index.html`],outdir:e.outdir,plugins:[A],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&&w.existsSync(e.outdir))w.rmSync(e.outdir,{recursive:!0});let n=await Bun.build(t),i=Bun.file(`${e.outdir}/index.html`),r=x(await i.text());if(e.bundleCss){let s=n.outputs.find((c)=>c.path.endsWith(".css"));if(s?.path){let c=Bun.file(s.path),a=r.indexOf('<link rel="stylesheet"'),o=a;for(;o<r.length;o++)if(["/>",'">'].includes(r.slice(o,o+2))){o+=2;break}let y=r.slice(a,o),$=`<style>${x(await c.text())}</style>`;r=r.replace(y,$),await c.delete(),n.outputs.splice(n.outputs.indexOf(s),1)}}await i.write(r),console.log(`See "${e.outdir}"`)}function x(e){return e.replaceAll(`
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 h();break;case"build":await b();break;case"init":if(!process.argv[3])console.log(`USAGE:
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)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdwh",
3
- "version": "1.9.1",
3
+ "version": "1.10.1",
4
4
  "author": "kubashh",
5
5
  "description": "The Bun framework. Easyer web dev without html for static sites",
6
6
  "license": "MIT",