wdwh 1.12.14 → 1.12.15-dev.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/index.d.ts +1 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/wdwh.js +7 -7
package/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type Signal<T> = {
|
|
|
13
13
|
use(): T;
|
|
14
14
|
};
|
|
15
15
|
export declare function createSignal<T>(initial: T): Signal<T>;
|
|
16
|
+
export declare function useInlineSignal<T>(init: T): Signal<T>;
|
|
16
17
|
export type ClassValue = ClassArray | string | number | null | boolean | undefined;
|
|
17
18
|
export type ClassArray = ClassValue[];
|
|
18
19
|
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 l}from"react";import{useState as c,useSyncExternalStore as S}from"react";function a(r){return c(r)[0]}function f(r){let e=r,t=new Set;function s(){return e}function o(n){return t.add(n),()=>t.delete(n)}return{get:s,set(n){let i=typeof n==="function"?n(e):n;if(Object.is(e,i))return;e=i,t.forEach((u)=>u())},subscribe:o,use(){return l(o,s)}}}function d(r){return a(f(r))}function p(...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+=p(e)}return e}export{d as useInlineSignal,f as createSignal,p as clsx};
|
package/package.json
CHANGED
package/wdwh.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{cpSync as
|
|
3
|
+
import{cpSync as X,existsSync as g,rmSync as $}from"fs";import x from"path";var M=`import { createRoot } from "react-dom/client";
|
|
4
4
|
import "CSS_PATH";
|
|
5
5
|
import App from "APP_PATH";
|
|
6
6
|
|
|
@@ -16,14 +16,14 @@ const { url } = Bun.serve({
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
console.log(\`> Server running at \${url}\`);
|
|
19
|
-
`;var
|
|
19
|
+
`;var L=`
|
|
20
20
|
[serve.static]
|
|
21
21
|
plugins = ["bun-plugin-tailwind"]
|
|
22
|
-
env = "BUN_PUBLIC_*"`;var
|
|
23
|
-
`))}
|
|
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 E="../../../src/app/App.tsx",F="../../../src/app/global.css",D="./node_modules/.cache/wdwh",Z={[`${D}/frontend.tsx`]:M.replace("CSS_PATH",F).replace("APP_PATH",E),[`${D}/server.ts`]:q},v={outdir:"dist",hashFiles:!0,cleanPrev:!1,tailwind:!0,external:[]};import Q from"path";async function V(A){let _=[];for(let R of A)_.push(S(R));await Promise.all(_)}async function S(A){for(let j in Z)await Bun.write(j,Z[j]);let _=P(A),{title:R,iconPath:U,...N}=await p(A),G=Q.join("../".repeat(A.urlPath.split("/").length+2),"src/app",A.urlPath,U),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="${G}" />`,...Object.entries(N).map(([j,K])=>`<meta name="${j}" content="${K}" />`),`<script src="${A.frontendPath}"></script>`,"</head>",_,"</html>"];await Bun.write(A.htmlOutPath,H.join(`
|
|
23
|
+
`))}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(`
|
|
24
|
+
`," ").replaceAll(/\s{2,}/g," ").trim()}}async function W(){let A=new Bun.Glob("**/index.tsx"),_=[];for(let R of A.scanSync("src/app")){let U=Q.join("src/app",R),N=R.replace(/index\.tsx$/,"").replace(/\\/g,"/"),G=Q.join(N,"./frontend.tsx"),H=Q.join(D,N,"index.html");_.push({tsxPath:U,tsxText:await Bun.file(U).text(),urlPath:N,frontendPath:G,htmlOutPath:H})}return _}async function p(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")B('Matadata must contain "title"');if(typeof N.iconPath!=="string")B('Matadata must contain "iconPath"');if(typeof N.description!=="string")B('Matadata must contain "description"');return N}function B(A){console.error("[error]",A),process.exit(1)}async function I(){let A=await W();await V(A);let _=Bun.file("./bunfig.toml");if(await _.exists()){let R=await _.text();if(!R.includes("bun-plugin-tailwind"))R+=`${R===""?"":`
|
|
25
|
+
`}${L}`,await _.write(R),await C()}else{await _.write(L);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 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 o from"bun-plugin-tailwind";async function O(){let A=await W(),_=performance.now(),R=await Bun.file("package.json").json(),U=Object.assign(v,R.wdwh);await V(A);let G={entrypoints:A.map((j)=>J.join(D,j.urlPath,"index.html")),outdir:U.outdir,plugins:U.tailwind?[o]: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)b.rmSync(U.outdir,{recursive:!0,force:!0});await Bun.build(G);for(let j of A){let K=Bun.file(J.join(U.outdir,j.urlPath,"index.html")),k=u(await K.text());await K.write(k)}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 u(A){return A.replaceAll(`
|
|
26
|
+
`," ").replaceAll(/\s{2,}/g," ").replaceAll(/ > | >|> /g,">").replaceAll(/ < | <|< /g,"<").replaceAll(/ ; | ;|; /g,";").replaceAll(/ { | {|{ /g,"{").replaceAll(/ } | }|} /g,"}").replaceAll(/ " | "|" /g,'"').replaceAll(/ , | ,|, /g,",")}var Y="./tmp.zip",d="https://raw.githubusercontent.com/kubashh/wdwh/main/template/template.zip";switch(process.argv[2]){case"dev":await I();break;case"build":await O();break;case"init":{let A=await fetch(d);if(!A.ok)console.log(`feach error: ${A.status}`),process.exit(1);let _=await A.bytes();await Bun.write(Y,_);let R=process.platform==="win32"?["powershell","-Command","Expand-Archiv","-Path",Y,"-DestinationPath",".","-Force"]:["unzip","-o",Y,"-d","."];Bun.spawnSync(R);let U=new Bun.Glob("**/*");for(let N of U.scanSync("template/template"))if(!g(N))X(x.join("template/template",N),N),console.log(`+ ${N}`);X("./template/template",".",{recursive:!0}),$(Y),$("./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
|