@absolutejs/absolute 0.13.11 → 0.15.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/.claude/settings.local.json +7 -1
- package/CLAUDE.md +65 -56
- package/LICENSE +80 -24
- package/README.md +163 -163
- package/THIRD_PARTY_NOTICES.md +61 -0
- package/dist/cli/index.js +24 -8
- package/dist/index.js +3013 -480
- package/dist/index.js.map +56 -26
- package/dist/{build → src/build}/compileSvelte.d.ts +2 -1
- package/dist/src/build/compileVue.d.ts +33 -0
- package/dist/src/build/generateReactIndexes.d.ts +1 -0
- package/dist/src/build/htmlScriptHMRPlugin.d.ts +13 -0
- package/dist/src/build/wrapHTMLScript.d.ts +24 -0
- package/dist/src/core/build.d.ts +2 -0
- package/dist/src/core/devBuild.d.ts +6 -0
- package/dist/{core → src/core}/index.d.ts +2 -1
- package/dist/src/core/lookup.d.ts +3 -0
- package/dist/{core → src/core}/pageHandlers.d.ts +4 -4
- package/dist/src/dev/assetStore.d.ts +12 -0
- package/dist/src/dev/buildHMRClient.d.ts +1 -0
- package/dist/src/dev/clientManager.d.ts +26 -0
- package/dist/src/dev/configResolver.d.ts +13 -0
- package/dist/src/dev/dependencyGraph.d.ts +13 -0
- package/dist/src/dev/fileHashTracker.d.ts +2 -0
- package/dist/src/dev/fileWatcher.d.ts +3 -0
- package/dist/src/dev/moduleMapper.d.ts +21 -0
- package/dist/src/dev/moduleVersionTracker.d.ts +7 -0
- package/dist/src/dev/pathUtils.d.ts +5 -0
- package/dist/src/dev/reactComponentClassifier.d.ts +2 -0
- package/dist/src/dev/rebuildTrigger.d.ts +10 -0
- package/dist/src/dev/simpleHTMLHMR.d.ts +4 -0
- package/dist/src/dev/simpleHTMXHMR.d.ts +4 -0
- package/dist/src/dev/simpleSvelteHMR.d.ts +1 -0
- package/dist/src/dev/simpleVueHMR.d.ts +1 -0
- package/dist/src/dev/webSocket.d.ts +9 -0
- package/dist/{index.d.ts → src/index.d.ts} +1 -0
- package/dist/src/plugins/hmr.d.ts +62 -0
- package/dist/{plugins → src/plugins}/index.d.ts +2 -1
- package/dist/{plugins → src/plugins}/networking.d.ts +3 -0
- package/dist/{svelte → src/svelte}/renderToReadableStream.d.ts +3 -1
- package/dist/src/utils/getRegisterClientScript.d.ts +10 -0
- package/dist/{utils → src/utils}/index.d.ts +2 -0
- package/dist/src/utils/logger.d.ts +45 -0
- package/dist/src/utils/networking.d.ts +2 -0
- package/dist/src/utils/normalizePath.d.ts +9 -0
- package/dist/src/utils/registerClientScript.d.ts +51 -0
- package/dist/{types.d.ts → types/build.d.ts} +7 -0
- package/dist/types/client.d.ts +104 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/messages.d.ts +138 -0
- package/dist/types/websocket.d.ts +6 -0
- package/eslint.config.mjs +238 -234
- package/package.json +17 -12
- package/tsconfig.build.json +20 -20
- package/types/build.ts +46 -0
- package/types/client.ts +109 -0
- package/types/index.ts +4 -0
- package/types/messages.ts +205 -0
- package/types/websocket.ts +12 -0
- package/types/window-globals.ts +53 -0
- package/dist/build/compileVue.d.ts +0 -5
- package/dist/build/generateReactIndexes.d.ts +0 -1
- package/dist/core/build.d.ts +0 -2
- package/dist/core/lookup.d.ts +0 -1
- package/dist/utils/networking.d.ts +0 -1
- /package/dist/{build → src/build}/generateManifest.d.ts +0 -0
- /package/dist/{build → src/build}/outputLogs.d.ts +0 -0
- /package/dist/{build → src/build}/scanEntryPoints.d.ts +0 -0
- /package/dist/{build → src/build}/updateAssetPaths.d.ts +0 -0
- /package/dist/{cli → src/cli}/index.d.ts +0 -0
- /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/dist/{plugins → src/plugins}/pageRouter.d.ts +0 -0
- /package/dist/{svelte → src/svelte}/renderToPipeableStream.d.ts +0 -0
- /package/dist/{svelte → src/svelte}/renderToString.d.ts +0 -0
- /package/dist/{utils → src/utils}/cleanup.d.ts +0 -0
- /package/dist/{utils → src/utils}/commonAncestor.d.ts +0 -0
- /package/dist/{utils → src/utils}/escapeScriptContent.d.ts +0 -0
- /package/dist/{utils → src/utils}/generateHeadElement.d.ts +0 -0
- /package/dist/{utils → src/utils}/getDurationString.d.ts +0 -0
- /package/dist/{utils → src/utils}/getEnv.d.ts +0 -0
- /package/dist/{utils → src/utils}/stringModifiers.d.ts +0 -0
- /package/dist/{utils → src/utils}/validateSafePath.d.ts +0 -0
package/CLAUDE.md
CHANGED
|
@@ -1,56 +1,65 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
|
|
7
|
-
AbsoluteJS is a full-stack, type-safe meta-framework for building web applications with TypeScript. It provides universal server-side rendering (SSR) for multiple frontend frameworks (React, Svelte, Vue, HTML, HTMX) powered by Bun and Elysia.
|
|
8
|
-
|
|
9
|
-
## Commands
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
bun run typecheck # TypeScript type checking (no emit)
|
|
13
|
-
bun run format # Prettier formatting
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- **`src/
|
|
39
|
-
- **`src/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
AbsoluteJS is a full-stack, type-safe meta-framework for building web applications with TypeScript. It provides universal server-side rendering (SSR) for multiple frontend frameworks (React, Svelte, Vue, HTML, HTMX) powered by Bun and Elysia.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun run typecheck # TypeScript type checking (no emit)
|
|
13
|
+
bun run format # Prettier formatting
|
|
14
|
+
bun run lint # ESLint (do not run)
|
|
15
|
+
bun test # Run tests (do not run)
|
|
16
|
+
bun run dev # Dev server (runs example/server.ts with --hot) (ask before using always)
|
|
17
|
+
bun run build # Build the package to dist/ (do not run)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Architecture
|
|
21
|
+
|
|
22
|
+
### Build Pipeline (`src/core/build.ts`)
|
|
23
|
+
|
|
24
|
+
The central orchestrator. A single `build()` call scans, compiles, and bundles all frameworks:
|
|
25
|
+
|
|
26
|
+
1. **Path validation** → `validateSafePath()` prevents directory traversal
|
|
27
|
+
2. **React index generation** → creates hydration entry points in `indexes/`
|
|
28
|
+
3. **Asset copy** + optional **Tailwind compilation**
|
|
29
|
+
4. **Entry point scanning** → `scanEntryPoints()` globs each framework directory
|
|
30
|
+
5. **Framework compilation** → Svelte (`compileSvelte`), Vue (`compileVue`) each produce SSR + client variants
|
|
31
|
+
6. **Bun bundling** (3 passes): server (target=bun), client (target=browser, minified), CSS
|
|
32
|
+
7. **Manifest generation** → maps filenames (PascalCased via `toPascal`) to hashed asset paths
|
|
33
|
+
8. **HTML asset path updating** → regex-based injection of hashed paths
|
|
34
|
+
9. **Cleanup** → removes `compiled/` intermediates unless `preserveIntermediateFiles` is set
|
|
35
|
+
|
|
36
|
+
### Key Modules
|
|
37
|
+
|
|
38
|
+
- **`src/core/pageHandlers.ts`** — `handleReactPageRequest`, `handleSveltePageRequest`, `handleVuePageRequest`, `handleHTMLPageRequest`, `handleHTMXPageRequest`. Each renders SSR HTML with hydration scripts.
|
|
39
|
+
- **`src/core/lookup.ts`** — `asset(manifest, name)` resolves build manifest entries.
|
|
40
|
+
- **`src/build/`** — Individual compilation steps: `compileSvelte.ts`, `compileVue.ts`, `generateManifest.ts`, `generateReactIndexes.ts`, `scanEntryPoints.ts`, `updateAssetPaths.ts`.
|
|
41
|
+
- **`src/plugins/networking.ts`** — Elysia plugin for server startup with HOST/PORT config and LAN binding (`--host` flag).
|
|
42
|
+
- **`src/plugins/hmr.ts`** — HMR plugin with WebSocket-based hot reload for dev mode.
|
|
43
|
+
- **`src/dev/`** — Dev tooling: file watcher, HMR client builder, dependency graph, framework-specific HMR handlers (React, Svelte, Vue, HTML, HTMX).
|
|
44
|
+
- **`src/cli/index.ts`** — CLI entry point (`absolutejs dev [entry]`). Spawns server with `--hot`, manages database containers if docker-compose exists.
|
|
45
|
+
- **`src/utils/`** — Path validation, string transforms (`toPascal`/`toKebab`), head element generation, environment variable loading (`getEnv`).
|
|
46
|
+
- **`types/`** — Type definitions: `BuildConfig`, `BuildOptions`, `PropsOf<T>`, `Prettify<T>`.
|
|
47
|
+
|
|
48
|
+
### Framework SSR Pattern
|
|
49
|
+
|
|
50
|
+
All frameworks follow the same pattern: server renders HTML → props serialized to `window.__INITIAL_PROPS__` → client hydrates with framework-specific entry point. Hydration indexes are auto-generated during build.
|
|
51
|
+
|
|
52
|
+
### Configuration Type
|
|
53
|
+
|
|
54
|
+
`BuildConfig` accepts optional directory paths for each framework (`reactDirectory`, `svelteDirectory`, `vueDirectory`, `htmlDirectory`, `htmxDirectory`), plus `buildDirectory`, `assetsDirectory`, `tailwind` config, and `options`.
|
|
55
|
+
|
|
56
|
+
## Code Conventions
|
|
57
|
+
|
|
58
|
+
- **ESLint plugin `eslint-plugin-absolute`** enforces strict rules: max nesting depth of 1, min variable name length of 3 (exceptions: `_`, `id`, `db`, `OK`), explicit return types, sorted exports/keys, no default exports (except config files)
|
|
59
|
+
- **Prettier**: tabs, 4-space width, 80 char print width, single quotes, no trailing commas, semicolons
|
|
60
|
+
- **TypeScript**: strict mode, ESNext target, bundler module resolution, decorator support enabled
|
|
61
|
+
- **Barrel exports**: `index.ts` files re-export alphabetically from each module directory
|
|
62
|
+
- **No default imports** from `react` or `bun` (enforced by linter)
|
|
63
|
+
- **Function expressions only**: `func-style` rule enforces arrow functions over declarations
|
|
64
|
+
- **Blank line before return** statements (enforced by `@stylistic/ts/padding-line-between-statements`)
|
|
65
|
+
- Elysia plugin pattern for server extensibility
|
package/LICENSE
CHANGED
|
@@ -1,24 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
# Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
**Licensor:** Alex Kahn
|
|
4
|
+
|
|
5
|
+
**Licensed Work:** AbsoluteJS (https://github.com/absolutejs/absolutejs)
|
|
6
|
+
|
|
7
|
+
**Change Date:** February 16, 2036
|
|
8
|
+
|
|
9
|
+
**Change License:** Apache License, Version 2.0
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Terms
|
|
14
|
+
|
|
15
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
16
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
17
|
+
Licensor may make an Additional Use Grant, permitting limited production use.
|
|
18
|
+
|
|
19
|
+
### Additional Use Grant
|
|
20
|
+
|
|
21
|
+
You may use the Licensed Work in production, provided your use does not include
|
|
22
|
+
any of the following:
|
|
23
|
+
|
|
24
|
+
1. **Offering a Competing Service.** You may not offer the Licensed Work, or
|
|
25
|
+
any derivative of it, to third parties as a hosted or managed service that
|
|
26
|
+
competes with the Licensed Work itself (for example, a "framework-as-a-service"
|
|
27
|
+
platform, deployment service, or cloud offering where AbsoluteJS or a
|
|
28
|
+
substantial portion of its functionality is a primary component of the value
|
|
29
|
+
provided to users).
|
|
30
|
+
|
|
31
|
+
2. **Resale or Redistribution as a Standalone Product.** You may not sell,
|
|
32
|
+
license, or distribute the Licensed Work, or any derivative or fork of it,
|
|
33
|
+
as a standalone commercial product or framework.
|
|
34
|
+
|
|
35
|
+
3. **Removal of Attribution.** Any derivative work, fork, or redistribution of
|
|
36
|
+
the Licensed Work must prominently credit AbsoluteJS and include a link to
|
|
37
|
+
the original project repository (https://github.com/absolutejs/absolutejs).
|
|
38
|
+
|
|
39
|
+
For clarity, the following uses are expressly permitted:
|
|
40
|
+
|
|
41
|
+
- Using AbsoluteJS to build and deploy your own applications, websites, or
|
|
42
|
+
SaaS products (whether commercial or non-commercial).
|
|
43
|
+
- Using AbsoluteJS as a dependency in commercial software that you build and sell,
|
|
44
|
+
as long as the software is not itself a competing framework or hosting service.
|
|
45
|
+
- Providing consulting, development, or professional services to clients using
|
|
46
|
+
AbsoluteJS.
|
|
47
|
+
- Forking and modifying the Licensed Work for your own internal use, provided
|
|
48
|
+
attribution is maintained.
|
|
49
|
+
|
|
50
|
+
### Change Date and Change License
|
|
51
|
+
|
|
52
|
+
On the Change Date specified above, or on such other date as the Licensor may
|
|
53
|
+
specify by written notice, the Licensed Work will be made available under the
|
|
54
|
+
Change License (Apache License, Version 2.0). Until the Change Date, the terms
|
|
55
|
+
of this Business Source License 1.1 apply.
|
|
56
|
+
|
|
57
|
+
### Notices
|
|
58
|
+
|
|
59
|
+
You must not remove or obscure any licensing, copyright, or other notices
|
|
60
|
+
included in the Licensed Work.
|
|
61
|
+
|
|
62
|
+
### No Warranty
|
|
63
|
+
|
|
64
|
+
THE LICENSED WORK IS PROVIDED "AS IS". THE LICENSOR HEREBY DISCLAIMS ALL
|
|
65
|
+
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
|
|
66
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO
|
|
67
|
+
EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY,
|
|
68
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR
|
|
69
|
+
IN CONNECTION WITH THE LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE
|
|
70
|
+
LICENSED WORK.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Contact
|
|
75
|
+
|
|
76
|
+
For commercial licensing inquiries or additional permissions, contact:
|
|
77
|
+
|
|
78
|
+
- **Alex Kahn**
|
|
79
|
+
- alexkahndev@gmail.com
|
|
80
|
+
- alexkahndev.github.io
|
package/README.md
CHANGED
|
@@ -1,163 +1,163 @@
|
|
|
1
|
-
# AbsoluteJS
|
|
2
|
-
|
|
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
|
-
|
|
5
|
-
[](https://bun.sh)
|
|
6
|
-
[](https://elysiajs.com)
|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Why Absolute JS?
|
|
12
|
-
|
|
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`.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Requirements
|
|
22
|
-
|
|
23
|
-
| Tool | Version | Purpose |
|
|
24
|
-
| ---------- | ------- | ------------------------------------------- |
|
|
25
|
-
| **Bun** | ≥ 1.2 | Runtime, bundler, and TypeScript transpiler |
|
|
26
|
-
| **Elysia** | latest | Web server & middleware platform |
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Installation
|
|
31
|
-
|
|
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`.
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Plugin System
|
|
112
|
-
|
|
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
|
|
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
|
-
- **Angular** handlers
|
|
144
|
-
- Prisma support
|
|
145
|
-
- Biome support
|
|
146
|
-
- Hot‑reload development server
|
|
147
|
-
- First‑class Docker images & hosting recipes
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## Contributing
|
|
152
|
-
|
|
153
|
-
Pull requests and issues are welcome! Whether it’s a new plugin, framework handler, or docs improvement:
|
|
154
|
-
|
|
155
|
-
1. Fork & branch.
|
|
156
|
-
2. `bun install && bun test`.
|
|
157
|
-
3. Submit a PR with a clear description.
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## License
|
|
162
|
-
|
|
163
|
-
Creative Commons **CC BY‑NC 4.0** – see [`LICENSE`](./LICENSE) for details.
|
|
1
|
+
# AbsoluteJS
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
[](https://bun.sh)
|
|
6
|
+
[](https://elysiajs.com)
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why Absolute JS?
|
|
12
|
+
|
|
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`.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
| Tool | Version | Purpose |
|
|
24
|
+
| ---------- | ------- | ------------------------------------------- |
|
|
25
|
+
| **Bun** | ≥ 1.2 | Runtime, bundler, and TypeScript transpiler |
|
|
26
|
+
| **Elysia** | latest | Web server & middleware platform |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
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`.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Plugin System
|
|
112
|
+
|
|
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 from environment variables |
|
|
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
|
+
- **Angular** handlers
|
|
144
|
+
- Prisma support
|
|
145
|
+
- Biome support
|
|
146
|
+
- Hot‑reload development server
|
|
147
|
+
- First‑class Docker images & hosting recipes
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Contributing
|
|
152
|
+
|
|
153
|
+
Pull requests and issues are welcome! Whether it’s a new plugin, framework handler, or docs improvement:
|
|
154
|
+
|
|
155
|
+
1. Fork & branch.
|
|
156
|
+
2. `bun install && bun test`.
|
|
157
|
+
3. Submit a PR with a clear description.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
Creative Commons **CC BY‑NC 4.0** – see [`LICENSE`](./LICENSE) for details.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
This product includes the following third-party software:
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Bun
|
|
8
|
+
|
|
9
|
+
- **Source:** https://github.com/oven-sh/bun
|
|
10
|
+
- **License:** MIT
|
|
11
|
+
|
|
12
|
+
MIT License
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2024 Bun
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
in the Software without restriction, including without limitation the rights
|
|
19
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Elysia
|
|
37
|
+
|
|
38
|
+
- **Source:** https://github.com/elysiajs/elysia
|
|
39
|
+
- **License:** MIT
|
|
40
|
+
|
|
41
|
+
MIT License
|
|
42
|
+
|
|
43
|
+
Copyright (c) 2022 SaltyAom
|
|
44
|
+
|
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
46
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
47
|
+
in the Software without restriction, including without limitation the rights
|
|
48
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
49
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
50
|
+
furnished to do so, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
The above copyright notice and this permission notice shall be included in all
|
|
53
|
+
copies or substantial portions of the Software.
|
|
54
|
+
|
|
55
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
56
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
57
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
58
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
59
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
60
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
61
|
+
SOFTWARE.
|