@absolutejs/absolute 0.3.1 → 0.4.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/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`,`hydrateRoot(document, <${
|
|
4
|
-
`);return tt(n(
|
|
2
|
+
var _t=60,y=1000,h=60000,mt=60,It=24,Nt=86400000,d=2,v=3000;import{rm as j,mkdir as A,writeFile as tt}from"fs/promises";import{join as n,basename as ot}from"path";import{cwd as rt,exit as st}from"process";var{$:w,build:nt,Glob:B}=globalThis.Bun;import{readFile as V,writeFile as X}from"fs/promises";var{Glob:Z}=globalThis.Bun;var H=async(o,r)=>{let s=new Z("*.html"),t=[];for await(let a of s.scan({cwd:r,absolute:!0}))t.push(a);for(let a of t){let c=await V(a,"utf8");for(let[m,p]of Object.entries(o)){let u=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$=new RegExp(`(<script[^>]+src=["'])(/?(?:.*\\/)?${u})(?:\\.[^."'/]+)?(\\.js)(["'][^>]*>)`,"g");c=c.replace($,(l,i,x,I,f)=>{return`${i}${p}${f}`})}await X(a,c,"utf8")}};var Ot=async({buildDir:o="build",assetsDir:r,reactIndexDir:s,javascriptDir:t,typeScriptDir:a,reactPagesDir:c,htmlDir:m,htmxDir:p,tailwind:u})=>{let $=performance.now(),l=rt(),i=n(l,o),x=r&&n(l,r),I=s&&n(l,s),f=t&&n(l,t),C=a&&n(l,a),T=c&&n(l,c),E=m&&n(l,m),P=p&&n(l,p);await j(i,{force:!0,recursive:!0}),await A(i),T&&I&&await it(T,I);let q=I&&await L(I,"*.tsx"),z=f&&await L(f,"*.js"),G=C&&await L(C,"*.ts"),R=[...q??[],...z??[],...G??[]];if(R.length===0)return console.warn("No entry points found, skipping build"),null;let{logs:J,outputs:K}=await nt({entrypoints:R,format:"esm",naming:"[dir]/[name].[hash].[ext]",outdir:i,target:"bun"}).catch((e)=>{console.error("Build failed:",e),st(1)});if(J.forEach((e)=>{if(e.level==="error")console.error(e);else if(e.level==="warning")console.warn(e);else if(e.level==="info"||e.level==="debug")console.info(e)}),x&&await w`cp -R ${x} ${i}`,E)await A(n(i,"html")),await w`cp -R ${E} ${n(i)}`;if(P)await A(n(i,"htmx")),await w`cp -R ${P} ${n(i)}`;if(u)await w`tailwindcss -i ${u.input} -o ${n(i,u.output)}`;let U=K.reduce((e,b)=>{let _=b.path;if(_.startsWith(i))_=_.slice(i.length);_=_.replace(/^\/+/,"");let g=_.split("/").pop();if(!g)return e;let O=`.${b.hash}.`;if(!g.includes(O))throw new Error(`Expected hash delimiter ${O} in ${g}`);let[Q]=g.split(O);return e[Q]="/"+_,e},{});E&&await H(U,E);let N=performance.now()-$,S;if(N<y)S=`${N.toFixed(d)}ms`;else if(N<h)S=`${(N/y).toFixed(d)}s`;else S=`${(N/h).toFixed(d)}m`;return console.log(`Build completed in ${S}`),U},it=async(o,r)=>{await j(r,{force:!0,recursive:!0}),await A(r);let s=new B("*.*"),t=[];for await(let c of s.scan({cwd:o}))t.push(c);let a=t.map(async(c)=>{let m=ot(c),[p]=m.split("."),u=["import { hydrateRoot } from 'react-dom/client';",`import { ${p} } from '../pages/${p}';
|
|
3
|
+
`,`hydrateRoot(document, <${p} />);`].join(`
|
|
4
|
+
`);return tt(n(r,`${p}Index.tsx`),u)});await Promise.all(a)},L=async(o,r)=>{let s=[],t=new B(r);for await(let a of t.scan({absolute:!0,cwd:o}))s.push(a);return s};import{createElement as et}from"react";import{renderToReadableStream as at}from"react-dom/server.browser";var Ct=async(o,r)=>{let s=et(o),t=await at(s,{bootstrapModules:[r]});return new Response(t,{headers:{"Content-Type":"text/html"}})},Tt=(o)=>Bun.file(o);import{argv as pt}from"process";var{env:F}=globalThis.Bun;import ct from"os";var k=()=>{let o=ct.networkInterfaces(),s=Object.values(o).flat().filter((t)=>t!==void 0).find((t)=>t.family==="IPv4"&&!t.internal);if(s)return s.address;return console.warn("No IP address found, falling back to localhost"),"localhost"};var D=F.HOST??"0.0.0.0",M=F.PORT??v,Y,lt=pt,W=lt.includes("--host");if(W)Y=k(),D="0.0.0.0";var Yt=(o)=>o.listen({hostname:D,port:M},()=>{if(console.log(`Server started on http://${D==="0.0.0.0"?"localhost":D}:${M}`),W)console.log(`Server started on network: http://${Y}:${M}`)});export{H as updateScriptTags,Yt as networkingPlugin,Ct as handleReactPageRequest,Tt as handleHTMLPageRequest,k as getLocalIPAddress,Ot as build,d as TIME_PRECISION,_t as SECONDS_IN_A_MINUTE,mt as MINUTES_IN_AN_HOUR,y as MILLISECONDS_IN_A_SECOND,h as MILLISECONDS_IN_A_MINUTE,Nt as MILLISECONDS_IN_A_DAY,It as HOURS_IN_A_DAY,v as DEFAULT_PORT};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Elysia } from "elysia";
|
|
2
|
-
export declare const networkingPlugin: (app: Elysia) => Elysia<"",
|
|
2
|
+
export declare const networkingPlugin: (app: Elysia) => Elysia<"", {
|
|
3
3
|
decorator: {};
|
|
4
4
|
store: {};
|
|
5
5
|
derive: {};
|
|
6
6
|
resolve: {};
|
|
7
7
|
}, {
|
|
8
|
-
|
|
8
|
+
typebox: import("@sinclair/typebox").TModule<{}>;
|
|
9
9
|
error: {};
|
|
10
10
|
}, {
|
|
11
11
|
schema: {};
|
|
12
12
|
macro: {};
|
|
13
|
+
macroFn: {};
|
|
14
|
+
parser: {};
|
|
13
15
|
}, {}, {
|
|
14
16
|
derive: {};
|
|
15
17
|
resolve: {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/absolute",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A fullstack meta-framework for building web applications with TypeScript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "https://github.com/absolutejs/absolutejs.git"
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/src/index.d.ts",
|
|
@@ -28,12 +28,14 @@
|
|
|
28
28
|
"@types/react": "19.1.0",
|
|
29
29
|
"@types/react-dom": "19.1.2",
|
|
30
30
|
"@types/vue": "2.0.0",
|
|
31
|
-
"
|
|
31
|
+
"autoprefixer": "10.4.20",
|
|
32
|
+
"elysia": "1.2.25",
|
|
33
|
+
"postcss": "8.4.49",
|
|
34
|
+
"prettier": "3.5.3",
|
|
32
35
|
"react": "19.1.0",
|
|
33
36
|
"svelte": "4.2.15",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"tailwindcss": "3.4.17"
|
|
37
|
+
"tailwindcss": "3.4.17",
|
|
38
|
+
"typescript": "5.7.2",
|
|
39
|
+
"vue": "3.4.26"
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -4,7 +4,7 @@ import { Elysia } from "elysia";
|
|
|
4
4
|
import { getLocalIPAddress } from "../utils/networking";
|
|
5
5
|
import { DEFAULT_PORT } from "../constants";
|
|
6
6
|
|
|
7
|
-
let host = env.HOST ?? "
|
|
7
|
+
let host = env.HOST ?? "0.0.0.0";
|
|
8
8
|
const port = env.PORT ?? DEFAULT_PORT;
|
|
9
9
|
let localIP: string | undefined;
|
|
10
10
|
|
|
@@ -23,14 +23,12 @@ export const networkingPlugin = (app: Elysia) =>
|
|
|
23
23
|
port: port
|
|
24
24
|
},
|
|
25
25
|
() => {
|
|
26
|
-
|
|
26
|
+
const displayHost = host === "0.0.0.0" ? "localhost" : host;
|
|
27
|
+
console.log(`Server started on http://${displayHost}:${port}`);
|
|
27
28
|
if (hostFlag) {
|
|
28
|
-
console.log(`Server started on http://localhost:${port}`);
|
|
29
29
|
console.log(
|
|
30
30
|
`Server started on network: http://${localIP}:${port}`
|
|
31
31
|
);
|
|
32
|
-
} else {
|
|
33
|
-
console.log(`Server started on http://${host}:${port}`);
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
);
|