@absolutejs/absolute 0.13.10 → 0.14.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.md +56 -56
- package/LICENSE +24 -24
- package/README.md +163 -163
- package/dist/cli/index.js +2 -5
- package/dist/core/build.d.ts +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +26 -26
- package/dist/plugins/networking.d.ts +3 -0
- package/dist/types.d.ts +1 -0
- package/eslint.config.mjs +234 -234
- package/package.json +1 -1
- package/tsconfig.build.json +20 -20
- package/.claude/settings.local.json +0 -5
package/CLAUDE.md
CHANGED
|
@@ -1,56 +1,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
|
-
```
|
|
15
|
-
|
|
16
|
-
## Architecture
|
|
17
|
-
|
|
18
|
-
### Build Pipeline (`src/core/build.ts`)
|
|
19
|
-
|
|
20
|
-
The central orchestrator. A single `build()` call scans, compiles, and bundles all frameworks:
|
|
21
|
-
|
|
22
|
-
1. **Path validation** → `validateSafePath()` prevents directory traversal
|
|
23
|
-
2. **React index generation** → creates hydration entry points in `indexes/`
|
|
24
|
-
3. **Asset copy** + optional **Tailwind compilation**
|
|
25
|
-
4. **Entry point scanning** → `scanEntryPoints()` globs each framework directory
|
|
26
|
-
5. **Framework compilation** → Svelte (`compileSvelte`), Vue (`compileVue`) each produce SSR + client variants
|
|
27
|
-
6. **Bun bundling** (3 passes): server (target=bun), client (target=browser, minified), CSS
|
|
28
|
-
7. **Manifest generation** → maps filenames (PascalCased via `toPascal`) to hashed asset paths
|
|
29
|
-
8. **HTML asset path updating** → regex-based injection of hashed paths
|
|
30
|
-
9. **Cleanup** → removes `compiled/` intermediates unless `preserveIntermediateFiles` is set
|
|
31
|
-
|
|
32
|
-
### Key Modules
|
|
33
|
-
|
|
34
|
-
- **`src/core/pageHandlers.ts`** — `handleReactPageRequest`, `handleSveltePageRequest`, `handleVuePageRequest`, `handleHTMLPageRequest`, `handleHTMXPageRequest`. Each renders SSR HTML with hydration scripts.
|
|
35
|
-
- **`src/core/lookup.ts`** — `asset(manifest, name)` resolves build manifest entries.
|
|
36
|
-
- **`src/build/`** — Individual compilation steps: `compileSvelte.ts`, `compileVue.ts`, `generateManifest.ts`, `generateReactIndexes.ts`, `scanEntryPoints.ts`, `updateAssetPaths.ts`.
|
|
37
|
-
- **`src/plugins/networking.ts`** — Elysia plugin for server startup with HOST/PORT config and LAN binding (`--host` flag).
|
|
38
|
-
- **`src/utils/`** — Path validation, string transforms (`toPascal`/`toKebab`), head element generation, environment variable loading (`getEnv`).
|
|
39
|
-
- **`src/types.ts`** — `BuildConfig`, `BuildOptions`, `PropsOf<T>`, `Prettify<T>`.
|
|
40
|
-
|
|
41
|
-
### Framework SSR Pattern
|
|
42
|
-
|
|
43
|
-
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.
|
|
44
|
-
|
|
45
|
-
### Configuration Type
|
|
46
|
-
|
|
47
|
-
`BuildConfig` accepts optional directory paths for each framework (`reactDirectory`, `svelteDirectory`, `vueDirectory`, `htmlDirectory`, `htmxDirectory`), plus `buildDirectory`, `assetsDirectory`, `tailwind` config, and `options`.
|
|
48
|
-
|
|
49
|
-
## Code Conventions
|
|
50
|
-
|
|
51
|
-
- **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)
|
|
52
|
-
- **Prettier**: 4-space tabs, 80 char width, single quotes, trailing commas off, semicolons on
|
|
53
|
-
- **TypeScript**: strict mode, ESNext target, bundler module resolution, decorator support enabled
|
|
54
|
-
- **Barrel exports**: `index.ts` files re-export alphabetically from each module directory
|
|
55
|
-
- **No default imports** from `react` or `bun` (enforced by linter)
|
|
56
|
-
- Elysia plugin pattern for server extensibility
|
|
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
|
+
## Architecture
|
|
17
|
+
|
|
18
|
+
### Build Pipeline (`src/core/build.ts`)
|
|
19
|
+
|
|
20
|
+
The central orchestrator. A single `build()` call scans, compiles, and bundles all frameworks:
|
|
21
|
+
|
|
22
|
+
1. **Path validation** → `validateSafePath()` prevents directory traversal
|
|
23
|
+
2. **React index generation** → creates hydration entry points in `indexes/`
|
|
24
|
+
3. **Asset copy** + optional **Tailwind compilation**
|
|
25
|
+
4. **Entry point scanning** → `scanEntryPoints()` globs each framework directory
|
|
26
|
+
5. **Framework compilation** → Svelte (`compileSvelte`), Vue (`compileVue`) each produce SSR + client variants
|
|
27
|
+
6. **Bun bundling** (3 passes): server (target=bun), client (target=browser, minified), CSS
|
|
28
|
+
7. **Manifest generation** → maps filenames (PascalCased via `toPascal`) to hashed asset paths
|
|
29
|
+
8. **HTML asset path updating** → regex-based injection of hashed paths
|
|
30
|
+
9. **Cleanup** → removes `compiled/` intermediates unless `preserveIntermediateFiles` is set
|
|
31
|
+
|
|
32
|
+
### Key Modules
|
|
33
|
+
|
|
34
|
+
- **`src/core/pageHandlers.ts`** — `handleReactPageRequest`, `handleSveltePageRequest`, `handleVuePageRequest`, `handleHTMLPageRequest`, `handleHTMXPageRequest`. Each renders SSR HTML with hydration scripts.
|
|
35
|
+
- **`src/core/lookup.ts`** — `asset(manifest, name)` resolves build manifest entries.
|
|
36
|
+
- **`src/build/`** — Individual compilation steps: `compileSvelte.ts`, `compileVue.ts`, `generateManifest.ts`, `generateReactIndexes.ts`, `scanEntryPoints.ts`, `updateAssetPaths.ts`.
|
|
37
|
+
- **`src/plugins/networking.ts`** — Elysia plugin for server startup with HOST/PORT config and LAN binding (`--host` flag).
|
|
38
|
+
- **`src/utils/`** — Path validation, string transforms (`toPascal`/`toKebab`), head element generation, environment variable loading (`getEnv`).
|
|
39
|
+
- **`src/types.ts`** — `BuildConfig`, `BuildOptions`, `PropsOf<T>`, `Prettify<T>`.
|
|
40
|
+
|
|
41
|
+
### Framework SSR Pattern
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
### Configuration Type
|
|
46
|
+
|
|
47
|
+
`BuildConfig` accepts optional directory paths for each framework (`reactDirectory`, `svelteDirectory`, `vueDirectory`, `htmlDirectory`, `htmxDirectory`), plus `buildDirectory`, `assetsDirectory`, `tailwind` config, and `options`.
|
|
48
|
+
|
|
49
|
+
## Code Conventions
|
|
50
|
+
|
|
51
|
+
- **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)
|
|
52
|
+
- **Prettier**: 4-space tabs, 80 char width, single quotes, trailing commas off, semicolons on
|
|
53
|
+
- **TypeScript**: strict mode, ESNext target, bundler module resolution, decorator support enabled
|
|
54
|
+
- **Barrel exports**: `index.ts` files re-export alphabetically from each module directory
|
|
55
|
+
- **No default imports** from `react` or `bun` (enforced by linter)
|
|
56
|
+
- Elysia plugin pattern for server extensibility
|
package/LICENSE
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
```
|
|
2
|
-
# Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0)
|
|
3
|
-
|
|
4
|
-
By using this project, you agree to the following terms under the Creative Commons Attribution-NonCommercial 4.0 International License.
|
|
5
|
-
|
|
6
|
-
## License Summary
|
|
7
|
-
This license allows you to:
|
|
8
|
-
- **Share**: Copy and redistribute the material in any medium or format.
|
|
9
|
-
- **Adapt**: Remix, transform, and build upon the material.
|
|
10
|
-
|
|
11
|
-
**Under the following conditions**:
|
|
12
|
-
- **Attribution**: You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
|
|
13
|
-
- **Non-Commercial**: You may not use the material for commercial purposes.
|
|
14
|
-
|
|
15
|
-
## Full License Text
|
|
16
|
-
The full license text can be found at: https://creativecommons.org/licenses/by-nc/4.0/legalcode
|
|
17
|
-
|
|
18
|
-
## Contact Information for Commercial Use
|
|
19
|
-
For commercial use, licensing inquiries, or additional permissions, please contact:
|
|
20
|
-
Alex Kahn
|
|
21
|
-
alexkahndev@gmail.com
|
|
22
|
-
alexkahndev.github.io
|
|
23
|
-
```
|
|
24
|
-
|
|
1
|
+
```
|
|
2
|
+
# Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0)
|
|
3
|
+
|
|
4
|
+
By using this project, you agree to the following terms under the Creative Commons Attribution-NonCommercial 4.0 International License.
|
|
5
|
+
|
|
6
|
+
## License Summary
|
|
7
|
+
This license allows you to:
|
|
8
|
+
- **Share**: Copy and redistribute the material in any medium or format.
|
|
9
|
+
- **Adapt**: Remix, transform, and build upon the material.
|
|
10
|
+
|
|
11
|
+
**Under the following conditions**:
|
|
12
|
+
- **Attribution**: You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
|
|
13
|
+
- **Non-Commercial**: You may not use the material for commercial purposes.
|
|
14
|
+
|
|
15
|
+
## Full License Text
|
|
16
|
+
The full license text can be found at: https://creativecommons.org/licenses/by-nc/4.0/legalcode
|
|
17
|
+
|
|
18
|
+
## Contact Information for Commercial Use
|
|
19
|
+
For commercial use, licensing inquiries, or additional permissions, please contact:
|
|
20
|
+
Alex Kahn
|
|
21
|
+
alexkahndev@gmail.com
|
|
22
|
+
alexkahndev.github.io
|
|
23
|
+
```
|
|
24
|
+
|
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 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
|
-
- **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 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
|
+
- **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.
|
package/dist/cli/index.js
CHANGED
|
@@ -34,12 +34,9 @@ var startDatabase = async (scripts) => {
|
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
var stopDatabase = async (scripts) => {
|
|
37
|
-
|
|
37
|
+
console.log(`
|
|
38
|
+
Stopping database container...`);
|
|
38
39
|
await $`${{ raw: scripts.downCommand }}`.quiet().nothrow();
|
|
39
|
-
const duration = ((performance.now() - start) / 1000).toFixed(2);
|
|
40
|
-
const msg = `Stopping database container... \x1B[90m${duration}s\x1B[0m`;
|
|
41
|
-
process.stdout.write(`\r\x1B[2K${msg}
|
|
42
|
-
`);
|
|
43
40
|
};
|
|
44
41
|
var dev = async (serverEntry) => {
|
|
45
42
|
const usesDocker = existsSync(resolve(COMPOSE_PATH));
|
package/dist/core/build.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { BuildConfig } from '../types';
|
|
2
|
-
export declare const build: ({ buildDirectory, assetsDirectory, reactDirectory, htmlDirectory, htmxDirectory, angularDirectory, svelteDirectory, vueDirectory, tailwind, options }: BuildConfig) => Promise<Record<string, string>>;
|
|
2
|
+
export declare const build: ({ buildDirectory, assetsDirectory, publicDirectory, reactDirectory, htmlDirectory, htmxDirectory, angularDirectory, svelteDirectory, vueDirectory, tailwind, options }: BuildConfig) => Promise<Record<string, string>>;
|
package/dist/index.js
CHANGED
|
@@ -507,7 +507,8 @@ var vueFeatureFlags = {
|
|
|
507
507
|
};
|
|
508
508
|
var build = async ({
|
|
509
509
|
buildDirectory = "build",
|
|
510
|
-
assetsDirectory
|
|
510
|
+
assetsDirectory,
|
|
511
|
+
publicDirectory,
|
|
511
512
|
reactDirectory,
|
|
512
513
|
htmlDirectory,
|
|
513
514
|
htmxDirectory,
|
|
@@ -554,8 +555,11 @@ var build = async ({
|
|
|
554
555
|
serverRoot = sveltePagesPath;
|
|
555
556
|
else if (vuePagesPath)
|
|
556
557
|
serverRoot = vuePagesPath;
|
|
558
|
+
const publicPath = publicDirectory && validateSafePath(publicDirectory, projectRoot);
|
|
557
559
|
await rm3(buildPath, { force: true, recursive: true });
|
|
558
560
|
mkdirSync(buildPath);
|
|
561
|
+
if (publicPath)
|
|
562
|
+
cpSync(publicPath, buildPath, { force: true, recursive: true });
|
|
559
563
|
if (reactIndexesPath && reactPagesPath)
|
|
560
564
|
await generateReactIndexFiles(reactPagesPath, reactIndexesPath);
|
|
561
565
|
if (assetsPath)
|
|
@@ -644,7 +648,7 @@ var build = async ({
|
|
|
644
648
|
const { logs, outputs } = await bunBuild({
|
|
645
649
|
entrypoints: cssEntryPoints,
|
|
646
650
|
naming: `[name].[hash].[ext]`,
|
|
647
|
-
outdir: join5(buildPath, basename4(assetsPath), "css"),
|
|
651
|
+
outdir: join5(buildPath, assetsPath ? basename4(assetsPath) : "assets", "css"),
|
|
648
652
|
target: "browser"
|
|
649
653
|
}).catch((err) => {
|
|
650
654
|
console.error("CSS build failed:", err);
|
|
@@ -913,5 +917,5 @@ export {
|
|
|
913
917
|
BUN_BUILD_WARNING_SUPPRESSION
|
|
914
918
|
};
|
|
915
919
|
|
|
916
|
-
//# debugId=
|
|
920
|
+
//# debugId=C07A521038D2FB1664756E2164756E21
|
|
917
921
|
//# sourceMappingURL=index.js.map
|