@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.
Files changed (82) hide show
  1. package/.claude/settings.local.json +7 -1
  2. package/CLAUDE.md +65 -56
  3. package/LICENSE +80 -24
  4. package/README.md +163 -163
  5. package/THIRD_PARTY_NOTICES.md +61 -0
  6. package/dist/cli/index.js +24 -8
  7. package/dist/index.js +3013 -480
  8. package/dist/index.js.map +56 -26
  9. package/dist/{build → src/build}/compileSvelte.d.ts +2 -1
  10. package/dist/src/build/compileVue.d.ts +33 -0
  11. package/dist/src/build/generateReactIndexes.d.ts +1 -0
  12. package/dist/src/build/htmlScriptHMRPlugin.d.ts +13 -0
  13. package/dist/src/build/wrapHTMLScript.d.ts +24 -0
  14. package/dist/src/core/build.d.ts +2 -0
  15. package/dist/src/core/devBuild.d.ts +6 -0
  16. package/dist/{core → src/core}/index.d.ts +2 -1
  17. package/dist/src/core/lookup.d.ts +3 -0
  18. package/dist/{core → src/core}/pageHandlers.d.ts +4 -4
  19. package/dist/src/dev/assetStore.d.ts +12 -0
  20. package/dist/src/dev/buildHMRClient.d.ts +1 -0
  21. package/dist/src/dev/clientManager.d.ts +26 -0
  22. package/dist/src/dev/configResolver.d.ts +13 -0
  23. package/dist/src/dev/dependencyGraph.d.ts +13 -0
  24. package/dist/src/dev/fileHashTracker.d.ts +2 -0
  25. package/dist/src/dev/fileWatcher.d.ts +3 -0
  26. package/dist/src/dev/moduleMapper.d.ts +21 -0
  27. package/dist/src/dev/moduleVersionTracker.d.ts +7 -0
  28. package/dist/src/dev/pathUtils.d.ts +5 -0
  29. package/dist/src/dev/reactComponentClassifier.d.ts +2 -0
  30. package/dist/src/dev/rebuildTrigger.d.ts +10 -0
  31. package/dist/src/dev/simpleHTMLHMR.d.ts +4 -0
  32. package/dist/src/dev/simpleHTMXHMR.d.ts +4 -0
  33. package/dist/src/dev/simpleSvelteHMR.d.ts +1 -0
  34. package/dist/src/dev/simpleVueHMR.d.ts +1 -0
  35. package/dist/src/dev/webSocket.d.ts +9 -0
  36. package/dist/{index.d.ts → src/index.d.ts} +1 -0
  37. package/dist/src/plugins/hmr.d.ts +62 -0
  38. package/dist/{plugins → src/plugins}/index.d.ts +2 -1
  39. package/dist/{plugins → src/plugins}/networking.d.ts +3 -0
  40. package/dist/{svelte → src/svelte}/renderToReadableStream.d.ts +3 -1
  41. package/dist/src/utils/getRegisterClientScript.d.ts +10 -0
  42. package/dist/{utils → src/utils}/index.d.ts +2 -0
  43. package/dist/src/utils/logger.d.ts +45 -0
  44. package/dist/src/utils/networking.d.ts +2 -0
  45. package/dist/src/utils/normalizePath.d.ts +9 -0
  46. package/dist/src/utils/registerClientScript.d.ts +51 -0
  47. package/dist/{types.d.ts → types/build.d.ts} +7 -0
  48. package/dist/types/client.d.ts +104 -0
  49. package/dist/types/index.d.ts +4 -0
  50. package/dist/types/messages.d.ts +138 -0
  51. package/dist/types/websocket.d.ts +6 -0
  52. package/eslint.config.mjs +238 -234
  53. package/package.json +17 -12
  54. package/tsconfig.build.json +20 -20
  55. package/types/build.ts +46 -0
  56. package/types/client.ts +109 -0
  57. package/types/index.ts +4 -0
  58. package/types/messages.ts +205 -0
  59. package/types/websocket.ts +12 -0
  60. package/types/window-globals.ts +53 -0
  61. package/dist/build/compileVue.d.ts +0 -5
  62. package/dist/build/generateReactIndexes.d.ts +0 -1
  63. package/dist/core/build.d.ts +0 -2
  64. package/dist/core/lookup.d.ts +0 -1
  65. package/dist/utils/networking.d.ts +0 -1
  66. /package/dist/{build → src/build}/generateManifest.d.ts +0 -0
  67. /package/dist/{build → src/build}/outputLogs.d.ts +0 -0
  68. /package/dist/{build → src/build}/scanEntryPoints.d.ts +0 -0
  69. /package/dist/{build → src/build}/updateAssetPaths.d.ts +0 -0
  70. /package/dist/{cli → src/cli}/index.d.ts +0 -0
  71. /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
  72. /package/dist/{plugins → src/plugins}/pageRouter.d.ts +0 -0
  73. /package/dist/{svelte → src/svelte}/renderToPipeableStream.d.ts +0 -0
  74. /package/dist/{svelte → src/svelte}/renderToString.d.ts +0 -0
  75. /package/dist/{utils → src/utils}/cleanup.d.ts +0 -0
  76. /package/dist/{utils → src/utils}/commonAncestor.d.ts +0 -0
  77. /package/dist/{utils → src/utils}/escapeScriptContent.d.ts +0 -0
  78. /package/dist/{utils → src/utils}/generateHeadElement.d.ts +0 -0
  79. /package/dist/{utils → src/utils}/getDurationString.d.ts +0 -0
  80. /package/dist/{utils → src/utils}/getEnv.d.ts +0 -0
  81. /package/dist/{utils → src/utils}/stringModifiers.d.ts +0 -0
  82. /package/dist/{utils → src/utils}/validateSafePath.d.ts +0 -0
@@ -1,5 +1,11 @@
1
1
  {
2
2
  "permissions": {
3
- "allow": ["WebSearch"]
3
+ "allow": [
4
+ "WebSearch",
5
+ "WebFetch(domain:bun.com)",
6
+ "WebFetch(domain:github.com)",
7
+ "Bash(bun run typecheck:*)",
8
+ "WebFetch(domain:gist.github.com)"
9
+ ]
4
10
  }
5
11
  }
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
- ## 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
+ 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
- # 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
+ # 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
- [![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)
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
+ [![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)
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.