@absolutejs/absolute 0.2.5 → 0.3.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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- var _t=60,O=1000,h=60000,mt=60,It=24,Nt=86400000,w=2,b=3000;import{rm as j,mkdir as A,writeFile as Z}from"fs/promises";import{join as e,basename as tt}from"path";import{cwd as ot,exit as rt}from"process";var{$:y,build:st,Glob:B}=globalThis.Bun;import{readFile as Q,writeFile as V}from"fs/promises";var{Glob:X}=globalThis.Bun;var v=async(o,s)=>{let r=new X("*.html"),t=[];for await(let i of r.scan({cwd:s,absolute:!0}))t.push(i);for(let i of t){let a=await Q(i,"utf8");for(let[m,p]of Object.entries(o)){let I=m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=new RegExp(`(<script[^>]+src=["'])(/?(?:.*\\/)?${I})(?:\\.[^."'/]+)?(\\.js)(["'][^>]*>)`,"g");a=a.replace(l,(c,E,N,x,S)=>{return`${E}${p}${S}`})}await V(i,a,"utf8")}};var $t=async({buildDir:o="build",assetsDir:s,reactIndexDir:r,javascriptDir:t,typeScriptDir:i,reactPagesDir:a,htmlDir:m,htmxDir:p})=>{let I=performance.now(),l=ot(),c=e(l,o),E=s&&e(l,s),N=r&&e(l,r),x=t&&e(l,t),S=i&&e(l,i),C=a&&e(l,a),f=m&&e(l,m),T=p&&e(l,p);await j(c,{force:!0,recursive:!0}),await A(c),C&&N&&await nt(C,N);let W=N&&await L(N,"*.tsx"),q=x&&await L(x,"*.js"),z=S&&await L(S,"*.ts"),P=[...W??[],...q??[],...z??[]];if(P.length===0)return console.warn("No entry points found, skipping build"),null;let{logs:G,outputs:J}=await st({entrypoints:P,format:"esm",naming:"[dir]/[name].[hash].[ext]",outdir:c,target:"bun"}).catch((n)=>{console.error("Build failed:",n),rt(1)});if(G.forEach((n)=>{if(n.level==="error")console.error(n);else if(n.level==="warning")console.warn(n);else if(n.level==="info"||n.level==="debug")console.info(n)}),E&&await y`cp -R ${E} ${c}`,f)await A(e(c,"html")),await y`cp -R ${f} ${e(c)}`;if(T)await A(e(c,"htmx")),await y`cp -R ${T} ${e(c)}`;let R=J.reduce((n,U)=>{let _=U.path;if(_.startsWith(c))_=_.slice(c.length);_=_.replace(/^\/+/,"");let d=_.split("/").pop();if(!d)return n;let $=`.${U.hash}.`;if(!d.includes($))throw new Error(`Expected hash delimiter ${$} in ${d}`);let[K]=d.split($);return n[K]="/"+_,n},{});f&&await v(R,f);let u=performance.now()-I,g;if(u<O)g=`${u.toFixed(w)}ms`;else if(u<h)g=`${(u/O).toFixed(w)}s`;else g=`${(u/h).toFixed(w)}m`;return console.log(`Build completed in ${g}`),R},nt=async(o,s)=>{await j(s,{force:!0,recursive:!0}),await A(s);let r=new B("*.*"),t=[];for await(let a of r.scan({cwd:o}))t.push(a);let i=t.map(async(a)=>{let m=tt(a),[p]=m.split("."),I=["import { hydrateRoot } from 'react-dom/client';",`import { ${p} } from '../pages/${p}';
3
- `,`hydrateRoot(document, <${p} />);`].join(`
4
- `);return Z(e(s,`${p}Index.tsx`),I)});await Promise.all(i)},L=async(o,s)=>{let r=[],t=new B(s);for await(let i of t.scan({absolute:!0,cwd:o}))r.push(i);return r};import{createElement as et}from"react";import{renderToReadableStream as it}from"react-dom/server.browser";var Mt=async(o,s)=>{let r=et(o),t=await it(r,{bootstrapModules:[s]});return new Response(t,{headers:{"Content-Type":"text/html"}})},Ct=(o)=>Bun.file(o);import{argv as at}from"process";var{env:k}=globalThis.Bun;import ct from"os";var H=()=>{let o=ct.networkInterfaces(),r=Object.values(o).flat().filter((t)=>t!==void 0).find((t)=>t.family==="IPv4"&&!t.internal);if(r)return r.address;return console.warn("No IP address found, falling back to localhost"),"localhost"};var M=k.HOST??"localhost",D=k.PORT??b,F,lt=at,Y=lt.includes("--host");if(Y)F=H(),M="0.0.0.0";var Ft=(o)=>o.listen({hostname:M,port:D},()=>{if(Y)console.log(`Server started on http://localhost:${D}`),console.log(`Server started on network: http://${F}:${D}`);else console.log(`Server started on http://${M}:${D}`)});export{v as updateScriptTags,Ft as networkingPlugin,Mt as handleReactPageRequest,Ct as handleHTMLPageRequest,H as getLocalIPAddress,$t as build,w as TIME_PRECISION,_t as SECONDS_IN_A_MINUTE,mt as MINUTES_IN_AN_HOUR,O as MILLISECONDS_IN_A_SECOND,h as MILLISECONDS_IN_A_MINUTE,Nt as MILLISECONDS_IN_A_DAY,It as HOURS_IN_A_DAY,b as DEFAULT_PORT};
2
+ var pt=60,C=1000,O=60000,It=60,mt=24,Et=86400000,x=2,h=3000;import{rm as P,mkdir as A,writeFile as tt}from"fs/promises";import{join as n,basename as ot}from"path";import{cwd as rt,exit as nt}from"process";var{$:D,build:st,Glob:v}=globalThis.Bun;import{readFile as Z,writeFile as k}from"fs/promises";var{Glob:F}=globalThis.Bun;var H=async(o,s)=>{let r=new F("*.html"),t=[];for await(let c of r.scan({cwd:s,absolute:!0}))t.push(c);for(let c of t){let a=await Z(c,"utf8");for(let[I,_]of Object.entries(o)){let N=I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=new RegExp(`(<script[^>]+src=["'])(/?(?:.*\\/)?${N})(?:\\.[^."'/]+)?(\\.js)(["'][^>]*>)`,"g");a=a.replace(d,(u,i,g,m,S)=>{return`${i}${_}${S}`})}await k(c,a,"utf8")}};var Mt=async({buildDir:o="build",assetsDir:s,reactIndexDir:r,javascriptDir:t,typeScriptDir:c,reactPagesDir:a,htmlDir:I,htmxDir:_,tailwind:N})=>{let d=performance.now(),u=rt(),i=n(u,o),g=s&&n(u,s),m=r&&n(u,r),S=t&&n(u,t),b=c&&n(u,c),U=a&&n(u,a),l=I&&n(u,I),R=_&&n(u,_);await P(i,{force:!0,recursive:!0}),await A(i),U&&m&&await it(U,m);let G=m&&await y(m,"*.tsx"),J=S&&await y(S,"*.js"),K=b&&await y(b,"*.ts"),T=[...G??[],...J??[],...K??[]];if(T.length===0)return console.warn("No entry points found, skipping build"),null;let{logs:Q,outputs:V}=await st({entrypoints:T,format:"esm",naming:"[dir]/[name].[hash].[ext]",outdir:i,target:"bun"}).catch((e)=>{console.error("Build failed:",e),nt(1)});if(Q.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)}),g&&await D`cp -R ${g} ${i}`,l)await A(n(i,"html")),await D`cp -R ${l} ${n(i)}`;if(R)await A(n(i,"htmx")),await D`cp -R ${R} ${n(i)}`;if(N)await D`tailwindcss -i ${N.input} -o ${n(i,N.output)}`;let j=V.reduce((e,B)=>{let p=B.path;if(p.startsWith(i))p=p.slice(i.length);p=p.replace(/^\/+/,"");let w=p.split("/").pop();if(!w)return e;let M=`.${B.hash}.`;if(!w.includes(M))throw new Error(`Expected hash delimiter ${M} in ${w}`);let[X]=w.split(M);return e[X]="/"+p,e},{});l&&await H(j,l);let E=performance.now()-d,f;if(E<C)f=`${E.toFixed(x)}ms`;else if(E<O)f=`${(E/C).toFixed(x)}s`;else f=`${(E/O).toFixed(x)}m`;return console.log(`Build completed in ${f}`),j},it=async(o,s)=>{await P(s,{force:!0,recursive:!0}),await A(s);let r=new v("*.*"),t=[];for await(let a of r.scan({cwd:o}))t.push(a);let c=t.map(async(a)=>{let I=ot(a),[_]=I.split("."),N=["import { hydrateRoot } from 'react-dom/client';",`import { ${_} } from '../pages/${_}';
3
+ `,`hydrateRoot(document, <${_} />);`].join(`
4
+ `);return tt(n(s,`${_}Index.tsx`),N)});await Promise.all(c)},y=async(o,s)=>{let r=[],t=new v(s);for await(let c of t.scan({absolute:!0,cwd:o}))r.push(c);return r};import{createElement as et}from"react";import{renderToReadableStream as ct}from"react-dom/server.browser";var bt=async(o,s)=>{let r=et(o),t=await ct(r,{bootstrapModules:[s]});return new Response(t,{headers:{"Content-Type":"text/html"}})},Ut=(o)=>Bun.file(o);import{argv as _t}from"process";var{env:W}=globalThis.Bun;import at from"os";var Y=()=>{let o=at.networkInterfaces(),r=Object.values(o).flat().filter((t)=>t!==void 0).find((t)=>t.family==="IPv4"&&!t.internal);if(r)return r.address;return console.warn("No IP address found, falling back to localhost"),"localhost"};var L=W.HOST??"localhost",$=W.PORT??h,q,ut=_t,z=ut.includes("--host");if(z)q=Y(),L="0.0.0.0";var qt=(o)=>o.listen({hostname:L,port:$},()=>{if(z)console.log(`Server started on http://localhost:${$}`),console.log(`Server started on network: http://${q}:${$}`);else console.log(`Server started on http://${L}:${$}`)});export{H as updateScriptTags,qt as networkingPlugin,bt as handleReactPageRequest,Ut as handleHTMLPageRequest,Y as getLocalIPAddress,Mt as build,x as TIME_PRECISION,pt as SECONDS_IN_A_MINUTE,It as MINUTES_IN_AN_HOUR,C as MILLISECONDS_IN_A_SECOND,O as MILLISECONDS_IN_A_MINUTE,Et as MILLISECONDS_IN_A_DAY,mt as HOURS_IN_A_DAY,h as DEFAULT_PORT};
@@ -7,6 +7,10 @@ type BuildConfig = {
7
7
  reactPagesDir?: string;
8
8
  htmlDir?: string;
9
9
  htmxDir?: string;
10
+ tailwind?: {
11
+ input: string;
12
+ output: string;
13
+ };
10
14
  };
11
- export declare const build: ({ buildDir, assetsDir, reactIndexDir, javascriptDir, typeScriptDir, reactPagesDir, htmlDir, htmxDir }: BuildConfig) => Promise<Record<string, string> | null>;
15
+ export declare const build: ({ buildDir, assetsDir, reactIndexDir, javascriptDir, typeScriptDir, reactPagesDir, htmlDir, htmxDir, tailwind }: BuildConfig) => Promise<Record<string, string> | null>;
12
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/absolute",
3
- "version": "0.2.5",
3
+ "version": "0.3.1",
4
4
  "description": "A fullstack meta-framework for building web applications with TypeScript",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,9 +18,9 @@
18
18
  "release": "bun run format && bun run build && bun publish"
19
19
  },
20
20
  "peerDependencies": {
21
- "elysia": "1.2.25",
22
- "react": "19.1.0",
23
- "react-dom": "19.1.0"
21
+ "elysia": ">= 1.2.0",
22
+ "react": ">= 19.1.0",
23
+ "react-dom": ">= 19.1.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@elysiajs/static": "1.0.2",
@@ -31,6 +31,9 @@
31
31
  "typescript": "5.7.2",
32
32
  "react": "19.1.0",
33
33
  "svelte": "4.2.15",
34
- "vue": "3.4.26"
34
+ "vue": "3.4.26",
35
+ "postcss": "8.4.49",
36
+ "autoprefixer": "10.4.20",
37
+ "tailwindcss": "3.4.17"
35
38
  }
36
39
  }
package/src/core/build.ts CHANGED
@@ -18,6 +18,10 @@ type BuildConfig = {
18
18
  reactPagesDir?: string;
19
19
  htmlDir?: string;
20
20
  htmxDir?: string;
21
+ tailwind?: {
22
+ input: string;
23
+ output: string;
24
+ };
21
25
  };
22
26
 
23
27
  export const build = async ({
@@ -28,7 +32,8 @@ export const build = async ({
28
32
  typeScriptDir,
29
33
  reactPagesDir,
30
34
  htmlDir,
31
- htmxDir
35
+ htmxDir,
36
+ tailwind
32
37
  }: BuildConfig) => {
33
38
  const start = performance.now();
34
39
 
@@ -108,6 +113,10 @@ export const build = async ({
108
113
  await $`cp -R ${htmxDirAbsolute} ${join(buildDirAbsolute)}`;
109
114
  }
110
115
 
116
+ if (tailwind) {
117
+ await $`tailwindcss -i ${tailwind.input} -o ${join(buildDirAbsolute, tailwind.output)}`;
118
+ }
119
+
111
120
  const manifest = outputs.reduce<Record<string, string>>((acc, artifact) => {
112
121
  let relativePath = artifact.path;
113
122
 
@@ -23,6 +23,7 @@ export const networkingPlugin = (app: Elysia) =>
23
23
  port: port
24
24
  },
25
25
  () => {
26
+ //TODO: I dont think this works properly
26
27
  if (hostFlag) {
27
28
  console.log(`Server started on http://localhost:${port}`);
28
29
  console.log(
@@ -1,10 +1,7 @@
1
1
  import type { Config } from "tailwindcss";
2
- import flowbite from "flowbite/plugin";
3
- import tailwindForms from "@tailwindcss/forms";
4
2
 
5
3
  const config: Config = {
6
- content: ["./src/frontend/**/*.{js,ts,jsx,tsx,mdx}"],
7
- plugins: [flowbite, tailwindForms]
4
+ content: ["./src/frontend/**/*.{js,ts,jsx,tsx,mdx}"]
8
5
  };
9
6
 
10
7
  export default config;