@absolutejs/absolute 0.8.14 → 0.9.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.
Files changed (33) hide show
  1. package/README.md +146 -19
  2. package/dist/build/compileVue.d.ts +5 -0
  3. package/dist/{src/build → build}/generateManifest.d.ts +1 -1
  4. package/dist/core/build.d.ts +4 -0
  5. package/dist/{src/core → core}/index.d.ts +1 -0
  6. package/dist/core/lookup.d.ts +2 -0
  7. package/dist/core/pageHandlers.d.ts +14 -0
  8. package/dist/{src/index.d.ts → index.d.ts} +1 -1
  9. package/dist/index.js +384 -183
  10. package/dist/index.js.map +11 -9
  11. package/dist/types.d.ts +24 -0
  12. package/eslint.config.mjs +33 -3
  13. package/package.json +7 -7
  14. package/tsconfig.lint.json +20 -0
  15. package/dist/src/core/build.d.ts +0 -2
  16. package/dist/src/core/pageHandlers.d.ts +0 -10
  17. package/dist/src/types.d.ts +0 -20
  18. /package/dist/{src/svelte → build}/compileSvelte.d.ts +0 -0
  19. /package/dist/{src/build → build}/generateReactIndexes.d.ts +0 -0
  20. /package/dist/{src/build → build}/scanEntryPoints.d.ts +0 -0
  21. /package/dist/{src/build → build}/updateScriptTags.d.ts +0 -0
  22. /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
  23. /package/dist/{src/plugins → plugins}/index.d.ts +0 -0
  24. /package/dist/{src/plugins → plugins}/networkingPlugin.d.ts +0 -0
  25. /package/dist/{src/plugins → plugins}/pageRouterPlugin.d.ts +0 -0
  26. /package/dist/{src/svelte → svelte}/renderToPipeableStream.d.ts +0 -0
  27. /package/dist/{src/svelte → svelte}/renderToReadableStream.d.ts +0 -0
  28. /package/dist/{src/svelte → svelte}/renderToString.d.ts +0 -0
  29. /package/dist/{src/utils → utils}/escapeScriptContent.d.ts +0 -0
  30. /package/dist/{src/utils → utils}/getDurationString.d.ts +0 -0
  31. /package/dist/{src/utils → utils}/index.d.ts +0 -0
  32. /package/dist/{src/utils → utils}/networking.d.ts +0 -0
  33. /package/dist/{src/utils → utils}/validateSafePath.d.ts +0 -0
package/README.md CHANGED
@@ -1,34 +1,161 @@
1
- # AbsoluteJS
1
+ # Absolute JS
2
2
 
3
- ## Introduction
3
+ Full‑stack, **type‑safe** batteries‑included platform that lets you **server‑side render _any_ modern front‑end**—React, Svelte, plain HTML, HTMX (Vue & Angular coming)—with a single Bun‑powered build step.
4
4
 
5
- AbsoluteJS is a revolutionary JavaScript framework designed to unify all past, present, and future JavaScript frameworks into one powerful environment. It's powered by Bun and Elysia, providing a seamless and efficient development experience.
5
+ [![bun-required](https://img.shields.io/badge/runtime-bun%401.x-yellowgreen?logo=bun)](https://bun.sh)
6
+ [![elysia-required](https://img.shields.io/badge/server-elysia%40latest-blue?logo=elysia)](https://elysiajs.com)
7
+ ![license](https://img.shields.io/badge/license-CC%20BY--NC%204.0-lightgrey)
6
8
 
7
- ## Features
9
+ ---
8
10
 
9
- - **Unified Environment**: AbsoluteJS brings together all JavaScript frameworks, allowing developers to use any framework within one environment.
10
- - **Powered by Bun and Elysia**: Leveraging the power of Bun and Elysia, AbsoluteJS provides a robust and efficient development experience.
11
- - **Future-Proof**: AbsoluteJS is designed to accommodate future JavaScript frameworks, making it a sustainable choice for JavaScript development.
11
+ ## Why Absolute JS?
12
12
 
13
- ## Getting Started
13
+ - **Universal SSR.** Bring your favourite UI layer; Absolute JS handles bundling, hydration, and HTML streaming.
14
+ - **One build, one manifest.** Call `build()` once—get a manifest mapping every page’s client and server assets, ready to wire into routes.
15
+ - **End‑to‑end type safety.** A unified source of truth for your types—from the database, through the server, and all the way to the client—so you can be certain of the data shape at every step.
16
+ - **Zero‑config philosophy.** Point the build at your folders; sane defaults light up everything else.
17
+ - **Plugin power.** Extend with standard Elysia plugins—ship auth, logging, i18n, and more. First‑party: `absolute-auth`, `networkingPlugin`.
14
18
 
15
- 1. **Installation**: Provide instructions on how to install AbsoluteJS.
16
- 2. **Basic Usage**: Give a simple example of how to use AbsoluteJS.
19
+ ---
17
20
 
18
- ## Documentation
21
+ ## Requirements
19
22
 
20
- Link to your detailed documentation here.
23
+ | Tool | Version | Purpose |
24
+ | ---------- | ------- | ------------------------------------------- |
25
+ | **Bun** | ≥ 1.2 | Runtime, bundler, and TypeScript transpiler |
26
+ | **Elysia** | latest | Web server & middleware platform |
21
27
 
22
- ## Contributing
28
+ ---
23
29
 
24
- Provide guidelines on how contributors can help improve AbsoluteJS.
30
+ ## Installation
25
31
 
26
- ## License
32
+ ```bash
33
+ bun add @absolutejs/absolute
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Quick Start
39
+
40
+ ```ts
41
+ // example/server.ts
42
+ import { staticPlugin } from '@elysiajs/static';
43
+ import { Elysia } from 'elysia';
44
+ import { file } from 'bun';
45
+ import { build } from 'absolutejs/core/build';
46
+ import {
47
+ handleHTMLPageRequest,
48
+ handleReactPageRequest,
49
+ handleSveltePageRequest
50
+ } from 'absolutejs/core/pageHandlers';
51
+
52
+ import { ReactExample } from './react/pages/ReactExample';
53
+ import SvelteExample from './svelte/pages/SvelteExample.svelte';
54
+ import { networkingPlugin } from 'absolutejs';
55
+
56
+ const manifest = await build({
57
+ assetsDirectory: 'example/assets',
58
+ buildDirectory: 'example/build',
59
+ htmlDirectory: 'example/html',
60
+ htmxDirectory: 'example/htmx',
61
+ reactDirectory: 'example/react',
62
+ svelteDirectory: 'example/svelte',
63
+ options: { preserveIntermediateFiles: true }
64
+ });
65
+
66
+ if (!manifest) throw new Error('Manifest generation failed');
67
+
68
+ let counter = 0;
69
+
70
+ export const server = new Elysia()
71
+ .use(staticPlugin({ assets: './example/build', prefix: '' }))
72
+
73
+ // HTML
74
+ .get('/', () =>
75
+ handleHTMLPageRequest('./example/build/html/pages/HtmlExample.html')
76
+ )
77
+
78
+ // React
79
+ .get('/react', () =>
80
+ handleReactPageRequest(ReactExample, manifest['ReactExampleIndex'], {
81
+ test: 123
82
+ })
83
+ )
84
+
85
+ // Svelte
86
+ .get('/svelte', () =>
87
+ handleSveltePageRequest(SvelteExample, manifest, { test: 456 })
88
+ )
89
+
90
+ // HTMX demo
91
+ .get('/htmx', () => file('./example/build/htmx/HtmxHome.html'))
92
+ .get('/htmx/increment', () => new Response(String(++counter)))
93
+
94
+ .use(networkingPlugin)
95
+ .on('error', (error) => {
96
+ const { request } = error;
97
+ console.error(
98
+ `Server error on ${request.method} ${request.url}: ${error.message}`
99
+ );
100
+ });
101
+ ```
102
+
103
+ ### How it works
104
+
105
+ 1. **`build()`** scans your project, bundles each framework, and returns a **manifest** that has the server, and client assets required to serve each route.
106
+ 2. Route handlers (`handleReactPageRequest`, `handleSveltePageRequest`, …) stream HTML and inject scripts/assets based on that manifest.
107
+ 3. The static plugin serves all compiled files from `/build`.
27
108
 
28
- Include information about your license here.
109
+ ---
29
110
 
30
- ## Contact
111
+ ## Plugin System
31
112
 
32
- Provide contact information or links to your social media profiles here.
113
+ Absolute JS piggybacks on the [Elysia plugin API](https://elysiajs.com/plugins). Any Elysia plugin works out of the box; Absolute adds helpers for:
114
+
115
+ | Plugin | Description |
116
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
117
+ | **`absolute-auth`** | Full OAuth2 flow configured with 66 providers and allows full customizability with event handlers |
118
+ | **`networkingPlugin`** | Starts your Elysia server with HOST/PORT defaults and adds a --host flag to toggle listening on localhost or your LAN interface |
119
+
120
+ ---
121
+
122
+ ## Configuration Philosophy
123
+
124
+ Everything funnels through a single `build()` call:
125
+
126
+ ```ts
127
+ await build({
128
+ reactDirectory: 'src/react',
129
+ svelteDirectory: 'src/svelte',
130
+ htmlDirectory: 'src/html',
131
+ htmxDirectory: 'src/htmx',
132
+ assetsDirectory: 'public/assets',
133
+ options: { preserveIntermediateFiles: false }
134
+ });
135
+ ```
136
+
137
+ No separate config files or environment variables—just explicit arguments with sensible defaults.
138
+
139
+ ---
140
+
141
+ ## Roadmap
142
+
143
+ - **Vue** and **Angular** handlers
144
+ - Hot‑reload development server
145
+ - First‑class Docker images & hosting recipes
146
+
147
+ ---
148
+
149
+ ## Contributing
150
+
151
+ Pull requests and issues are welcome! Whether it’s a new plugin, framework handler, or docs improvement:
152
+
153
+ 1. Fork & branch.
154
+ 2. `bun install && bun test`.
155
+ 3. Submit a PR with a clear description.
156
+
157
+ ---
158
+
159
+ ## License
33
160
 
34
- We hope you enjoy using AbsoluteJS as much as we enjoyed building it!
161
+ Creative Commons **CC BY‑NC 4.0** see [`LICENSE`](./LICENSE) for details.
@@ -0,0 +1,5 @@
1
+ export declare const compileVue: (entryPoints: string[], outputDirectory: string) => Promise<{
2
+ vueClientPaths: string[];
3
+ vueCssPaths: Record<string, string[]>;
4
+ vueServerPaths: string[];
5
+ }>;
@@ -1,2 +1,2 @@
1
1
  import { BuildArtifact } from 'bun';
2
- export declare const generateManifest: (outputs: BuildArtifact[], buildDirectoryAbsolute: string, svelteDirName?: string) => Record<string, string>;
2
+ export declare const generateManifest: (outputs: BuildArtifact[], buildDirectoryAbsolute: string) => Record<string, string>;
@@ -0,0 +1,4 @@
1
+ import { BuildConfig } from '../types';
2
+ export declare const build: ({ buildDirectory, assetsDirectory, reactDirectory, htmlDirectory, htmxDirectory, svelteDirectory, vueDirectory, tailwind, options }: BuildConfig) => Promise<{
3
+ [x: string]: string | string[];
4
+ } | null>;
@@ -1,2 +1,3 @@
1
1
  export * from './build';
2
2
  export * from './pageHandlers';
3
+ export * from './lookup';
@@ -0,0 +1,2 @@
1
+ export declare const asset: (manifest: Record<string, string | string[]>, name: string) => string;
2
+ export declare const assets: (manifest: Record<string, string | string[]>, name: string) => string[];
@@ -0,0 +1,14 @@
1
+ import { ComponentType as ReactComponent } from 'react';
2
+ import { Component as SvelteComponent } from 'svelte';
3
+ import { Component as VueComponent } from 'vue';
4
+ import { PropsArgs } from '../types';
5
+ export declare const handleReactPageRequest: <Props extends Record<string, unknown> = Record<never, never>>(pageComponent: ReactComponent<Props>, index: string, ...props: keyof Props extends never ? [] : [props: Props]) => Promise<Response>;
6
+ type HandleSveltePageRequest = {
7
+ (PageComponent: SvelteComponent<Record<string, never>>, pagePath: string, indexPath: string): Promise<Response>;
8
+ <P extends Record<string, unknown>>(PageComponent: SvelteComponent<P>, pagePath: string, indexPath: string, props: P): Promise<Response>;
9
+ };
10
+ export declare const handleSveltePageRequest: HandleSveltePageRequest;
11
+ export declare const handleVuePageRequest: <Props extends Record<string, unknown> = Record<never, never>>(_PageComponent: VueComponent<Props>, pagePath: string, indexPath: string, ...props: keyof Props extends never ? [] : [props: Props]) => Promise<Response>;
12
+ export declare const handleHTMLPageRequest: (html: string) => Bun.BunFile;
13
+ export declare const handlePageRequest: <Component>(PageComponent: Component, ...props: PropsArgs<Component>) => void;
14
+ export {};
@@ -1,4 +1,4 @@
1
1
  export * from './constants';
2
- export * from './core/index';
2
+ export * from './core';
3
3
  export * from './plugins/index';
4
4
  export * from './utils/index';