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