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.
Files changed (2) hide show
  1. package/dist/main.js +7 -10
  2. 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 B from"child_process";var l="./node_modules/.cache/wdwh",p=`
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_*"`,u={["./node_modules/.cache/wdwh/frontend.tsx"]:`import { createRoot } from "react-dom/client"
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{readFileSync as x}from"fs";function f(){let e=String(x("./src/app/index.tsx")),t=g(e,"export const config"),n=g(e,"export const metadata");if(n.iconPath&&n.iconPath[0]===".")n.iconPath=`../../../src/app${n.iconPath.slice(1)}`;return{config:t,metadata:n}}function g(e,t){let n=e.indexOf("{",e.indexOf(t)),r=e.indexOf("}",n)+1;return A(e.slice(n,r))}function A(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}=f();for(let s in u)await Bun.write(s,u[s]);let{headContent:t,body:n}=await S(),{title:r,iconPath:i,...o}=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(o).map((s)=>`<meta name="${s}" content="${o[s]}" />`),`<link rel="icon" href="${i}" />`,`<title>${r}</title>`,'<script src="./frontend.tsx"></script>',"</head>",n,"</html>"];await Bun.write(`${l}/index.html`,c.join(`
19
- `))}async function S(){let e=String(x("./src/app/index.tsx")),t=h(e,"head").slice(6,-7),n=h(e,"body").replaceAll("className","class"),r=n.indexOf(">")+1,i=n.lastIndexOf("<");return n=n.replace(n.slice(r,i),""),{headContent:t,body:n}}function h(e,t){for(let n,r=e.indexOf("export default");;r++){if(!n&&e.startsWith(`<${t}`,r))n=r;if(n&&e.startsWith(`</${t}>`,r))return e.slice(n,r+t.length+3).replaceAll(`
20
- `," ").replaceAll(/\s{2,}/g," ").trim()}}async function w(){await d();let e="bun node_modules/.cache/wdwh/server.ts",t=Bun.file("./bunfig.toml");if(await t.exists()){let i=await t.text();if(!i.includes("bun-plugin-tailwind"))i+=`${i===""?"":`
21
- `}${p}`,t.write(i),e="wdwh dev"}else{t.write(p);async function i(){let o=Bun.file("bunfig.toml");try{if(await o.exists())await o.delete()}catch{}}process.on("SIGINT",i),setTimeout(i,250),e="wdwh dev"}let[n,...r]=e.split(" ");B.spawnSync(n,r,{stdio:"inherit"})}import O from"bun-plugin-tailwind";import{existsSync as P,rmSync as F}from"fs";import{relative as C}from"path";async function y(){let{config:e}=f();await d();let t={entrypoints:[`${l}/index.html`],outdir:e.outdir,plugins:[O],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&&P(e.outdir))F(e.outdir,{recursive:!0});let n=await Bun.build(t),r=Bun.file(`${e.outdir}/index.html`),i=b(await r.text());if(e.bundleCss){let c=n.outputs.find((s)=>s.path.endsWith(".css"));if(c?.path){let s=Bun.file(c.path),m=i.indexOf('<link rel="stylesheet"'),a=m;for(;a<i.length;a++)if(["/>",'">'].includes(i.slice(a,a+2))){a+=2;break}let v=i.slice(m,a),$=`<style>${b(await s.text())}</style>`;i=i.replace(v,$),s.delete(),n.outputs.splice(n.outputs.indexOf(c),1)}}r.write(i);let o=n.outputs.reduce((c,s)=>c+` ${C(process.cwd(),s.path)}
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.6",
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
- "publish": "bun scripts/publish.ts"
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
- "typescript": "latest"
39
+ "@kubashh/nutil": "latest"
40
40
  },
41
41
  "prettier": {
42
42
  "semi": false,