wdwh 1.12.13 → 1.12.14-dev.0
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/index.d.ts +7 -0
- package/index.js +1 -1
- package/package.json +2 -2
- package/wdwh.js +8 -8
package/index.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
type Listener = () => void;
|
|
2
|
+
export type Metadata = {
|
|
3
|
+
title: string;
|
|
4
|
+
iconPath: string;
|
|
5
|
+
description: string;
|
|
6
|
+
author?: string;
|
|
7
|
+
[key: string]: string | undefined;
|
|
8
|
+
};
|
|
2
9
|
export type Signal<T> = {
|
|
3
10
|
get(): T;
|
|
4
11
|
set(newValueOrFn: T | ((prev: T) => T)): void;
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{useSyncExternalStore as
|
|
2
|
+
import{useSyncExternalStore as u}from"react";function p(n){let e=n,t=new Set;function s(){return e}function i(r){return t.add(r),()=>t.delete(r)}return{get:s,set(r){let o=typeof r==="function"?r(e):r;if(Object.is(e,o))return;e=o,t.forEach((a)=>a())},subscribe:i,use(){return u(i,s)}}}function l(...n){let e="";for(let t of n){if(!t)continue;if(typeof t==="string")e&&(e+=" "),e+=t;else if(Array.isArray(t))e&&(e+=" "),e+=l(e)}return e}export{p as createSignal,l as clsx};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wdwh",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.14-dev.0",
|
|
4
4
|
"author": "kubashh",
|
|
5
5
|
"description": "The Bun Frontend Framework.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/bun": "^1.3.11",
|
|
40
40
|
"@types/react": "^19.2.14",
|
|
41
41
|
"tailwindcss": "^4.2.2",
|
|
42
|
-
"typescript": "^
|
|
42
|
+
"typescript": "^6.0.2",
|
|
43
43
|
"react": "^19.2.4",
|
|
44
44
|
"react-dom": "^19.2.4"
|
|
45
45
|
},
|
package/wdwh.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{cpSync as
|
|
3
|
+
import{cpSync as $,existsSync as g,rmSync as k}from"fs";import o from"path";var O=`import { createRoot } from "react-dom/client";
|
|
4
4
|
import "CSS_PATH";
|
|
5
5
|
import App from "APP_PATH";
|
|
6
6
|
|
|
7
7
|
createRoot(document.getElementsByTagName("body")[0]).render(<App />);
|
|
8
|
-
`;var
|
|
8
|
+
`;var q=`import index from "./index.html";
|
|
9
9
|
|
|
10
10
|
const { url } = Bun.serve({
|
|
11
11
|
routes: {
|
|
@@ -16,14 +16,14 @@ const { url } = Bun.serve({
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
console.log(\`> Server running at \${url}\`);
|
|
19
|
-
`;var
|
|
19
|
+
`;var K=`
|
|
20
20
|
[serve.static]
|
|
21
21
|
plugins = ["bun-plugin-tailwind"]
|
|
22
|
-
env = "BUN_PUBLIC_*"`;var
|
|
23
|
-
`))}}async function
|
|
24
|
-
`," ").replaceAll(/\s{2,}/g," ").trim()}}function
|
|
25
|
-
`}${
|
|
26
|
-
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}var
|
|
22
|
+
env = "BUN_PUBLIC_*"`;var F="../../../src/app/App.tsx",S="../../../src/app/global.css",D="./node_modules/.cache/wdwh",B={[`${D}/frontend.tsx`]:O.replace("CSS_PATH",S).replace("APP_PATH",F),[`${D}/server.ts`]:q},v={outdir:"dist",hashFiles:!0,cleanPrev:!1,tailwind:!0,external:[]};import L from"path";async function Q(U){for(let A of U){for(let j in B)await Bun.write(j,B[j]);let _=await m(A),{title:R,iconPath:N,...Y}=await p(A),Z=L.join("../".repeat(A.urlPath.split("/").length+2),"src/app",A.urlPath,N),G=L.join(D,A.urlPath,"index.html"),H=["<!DOCTYPE html>",'<html lang="en">',"<head>",'<meta charset="UTF-8" />','<meta name="viewport" content="width=device-width, initial-scale=1.0" />',`<title>${R}</title>`,`<link rel="icon" href="${Z}" />`,...Object.entries(Y).map(([j,w])=>`<meta name="${j}" content="${w}" />`),`<script src="${L.join(A.urlPath,"./frontend.tsx")}"></script>`,"</head>",_,"</html>"];await Bun.write(G,H.join(`
|
|
23
|
+
`))}}async function m(U){let A=await Bun.file(U.tsxPath).text(),_=P(A,"body").replaceAll("className","class"),R=_.indexOf(">")+1,N=_.lastIndexOf("<");return _=_.replace(_.slice(R,N),""),_}function P(U,A){for(let _,R=U.indexOf("export default");;R++){if(!_&&U.startsWith(`<${A}`,R))_=R;if(_&&U.startsWith(`</${A}>`,R))return U.slice(_,R+A.length+3).replaceAll(`
|
|
24
|
+
`," ").replaceAll(/\s{2,}/g," ").trim()}}function V(){let U=new Bun.Glob("**/index.tsx"),A=[];for(let _ of U.scanSync("src/app")){let R=L.join("src/app",_),N=_.replace(/index\.tsx$/,"").replace(/\\/g,"/");A.push({tsxPath:R,urlPath:N})}return A}async function p(U){let A=await Bun.file(U.tsxPath).text();A=A.replaceAll(/'|`/g,'"').replaceAll(/([{,]\s*)([a-zA-Z0-9_]+)\s*:/g,'$1"$2":').replace(/,\s*([}\]])/g,"$1");let _=A.indexOf("{",A.indexOf("export const metadata")),R=A.indexOf("}",_)+1;A=A.slice(_,R);let N=JSON.parse(A);if(!N.title)M('Matadata must contain "title"');if(!N.iconPath)M('Matadata must contain "iconPath"');if(!N.description)M('Matadata must contain "description"');return N}function M(U){console.error("Error:",U),process.exit(1)}async function I(){let U=V();await Q(U);let A=Bun.file("./bunfig.toml");if(await A.exists()){let _=await A.text();if(!_.includes("bun-plugin-tailwind"))_+=`${_===""?"":`
|
|
25
|
+
`}${K}`,await A.write(_),await C()}else{await A.write(K);async function _(){let R=Bun.file("bunfig.toml");try{if(await R.exists())await R.delete()}catch{}}process.on("SIGINT",_),setTimeout(_,250),await C()}Bun.spawnSync({cmd:["bun","node_modules/.cache/wdwh/server.ts"],stdio:["ignore","inherit","inherit"]})}async function C(){try{await Bun.$`bunx wdwh dev`}catch{}process.exit()}import b from"fs";import J from"path";import u from"bun-plugin-tailwind";async function X(){let U=V(),A=performance.now(),_=await Bun.file("package.json").json(),R=Object.assign(v,_.wdwh);await Q(U);let Y={entrypoints:U.map((G)=>J.join(D,G.urlPath,"index.html")),outdir:R.outdir,plugins:R.tailwind?[u]:void 0,minify:!0,target:"browser",external:R.external,naming:!R.hashFiles?{chunk:"[name].[ext]",asset:"[name].[ext]"}:void 0,define:{"process.env.NODE_ENV":'"production"'}};if(R.cleanPrev)b.rmSync(R.outdir,{recursive:!0,force:!0});await Bun.build(Y);for(let G of U){let H=Bun.file(J.join(R.outdir,G.urlPath,"index.html")),j=y(await H.text());await H.write(j)}let Z=performance.now();if(process.argv.includes("--dir"))console.log(`See "${R.outdir}"`);if(process.argv.includes("--time"))console.log(`Build in ${Z-A}ms`)}function y(U){return U.replaceAll(`
|
|
26
|
+
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}var W="./tmp.zip",x="https://raw.githubusercontent.com/kubashh/wdwh/main/template/template.zip";switch(process.argv[2]){case"dev":await I();break;case"build":await X();break;case"init":{let U=await fetch(x);if(!U.ok)console.log(`feach error: ${U.status}`),process.exit(1);let A=await U.bytes();await Bun.write(W,A);let _=process.platform==="win32"?["powershell","-Command","Expand-Archiv","-Path",W,"-DestinationPath",".","-Force"]:["unzip","-o",W,"-d","."];Bun.spawnSync(_);let R=new Bun.Glob("**/*");for(let N of R.scanSync("template/template"))if(!g(N))$(o.join("template/template",N),N),console.log(`+ ${N}`);$("./template/template",".",{recursive:!0}),k(W),k("./template",{recursive:!0}),console.log("Installing dependencies..."),await Bun.$`bun update`,console.log(`
|
|
27
27
|
Run "bun dev" and start development!`);break}default:console.log(`Usage:
|
|
28
28
|
wdwh dev
|
|
29
29
|
wdwh build
|