@emkodev/emroute 1.6.0-beta.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="doc/logo-full.png" alt="emroute" width="197" height="40">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/emko-io/emroute/main/doc/logo-full.png" alt="emroute" width="197" height="40">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
@@ -28,18 +28,22 @@ bun add @emkodev/emroute
|
|
|
28
28
|
> emroute ships TypeScript source. Your toolchain must handle `.ts` imports
|
|
29
29
|
> (Bun, tsx, esbuild, etc.).
|
|
30
30
|
|
|
31
|
+
For markdown rendering, add [@emkodev/emkoma](doc/08c-setup-emkoma.md) (built
|
|
32
|
+
for emroute) or bring your own — [marked](doc/08a-setup-marked.md) and
|
|
33
|
+
[markdown-it](doc/08b-setup-markdown-it.md) both work.
|
|
34
|
+
|
|
31
35
|
## How It Works
|
|
32
36
|
|
|
33
37
|
<p align="center">
|
|
34
|
-
<img src="doc/diagram-full.png" alt="emroute architecture" width="480" height="480">
|
|
38
|
+
<img src="https://raw.githubusercontent.com/emko-io/emroute/main/doc/diagram-full.png" alt="emroute architecture" width="480" height="480">
|
|
35
39
|
</p>
|
|
36
40
|
|
|
37
41
|
One component, three rendering paths:
|
|
38
42
|
|
|
39
43
|
<p align="center">
|
|
40
|
-
<img src="doc/diagram-flow-spa.png" alt="SPA flow" width="320" height="320">
|
|
41
|
-
<img src="doc/diagram-flow-ssr-html.png" alt="SSR HTML flow" width="320" height="320">
|
|
42
|
-
<img src="doc/diagram-flow-ssr-md.png" alt="SSR Markdown flow" width="320" height="320">
|
|
44
|
+
<img src="https://raw.githubusercontent.com/emko-io/emroute/main/doc/diagram-flow-spa.png" alt="SPA flow" width="320" height="320">
|
|
45
|
+
<img src="https://raw.githubusercontent.com/emko-io/emroute/main/doc/diagram-flow-ssr-html.png" alt="SSR HTML flow" width="320" height="320">
|
|
46
|
+
<img src="https://raw.githubusercontent.com/emko-io/emroute/main/doc/diagram-flow-ssr-md.png" alt="SSR Markdown flow" width="320" height="320">
|
|
43
47
|
</p>
|
|
44
48
|
|
|
45
49
|
The SPA and SSR HTML flows both call `renderHTML()` — same output, different
|
|
@@ -144,9 +148,10 @@ See [Setup](doc/01-setup.md) and [First Route](doc/02-first-route.md).
|
|
|
144
148
|
- [SPA modes](doc/10-spa-mode.md) — none, leaf, root, only
|
|
145
149
|
- [Error handling](doc/11-error-handling.md) — widget errors, boundaries, status pages
|
|
146
150
|
- [Shadow DOM](doc/12-shadow-dom.md) — unified architecture, SSR hydration
|
|
151
|
+
- [Hono integration](doc/13-hono.md) — using emroute with Hono
|
|
147
152
|
|
|
148
153
|
### For contributors and architects
|
|
149
154
|
|
|
150
155
|
- [Architectural decisions](doc/architecture/) — ADR-0001 through ADR-0017
|
|
151
156
|
|
|
152
|
-
<img src="doc/logo-full.png" alt="emroute" width="197" height="40">
|
|
157
|
+
<img src="https://raw.githubusercontent.com/emko-io/emroute/main/doc/logo-full.png" alt="emroute" width="197" height="40">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emkodev/emroute",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "File-based router with triple rendering (SPA, SSR HTML, SSR Markdown). Zero dependencies.",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"author": "emko.dev",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "https://github.com/
|
|
21
|
+
"url": "https://github.com/emko-io/emroute.git"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"src/",
|
|
@@ -53,6 +53,8 @@ export const EMROUTE_EXTERNALS = [
|
|
|
53
53
|
export interface RuntimeConfig {
|
|
54
54
|
routesDir?: string;
|
|
55
55
|
widgetsDir?: string;
|
|
56
|
+
/** SPA mode. When 'none', bundling is skipped entirely. */
|
|
57
|
+
spa?: 'none' | 'leaf' | 'root' | 'only';
|
|
56
58
|
/** Consumer's SPA entry point (e.g. '/main.ts'). Skips app bundle when absent. */
|
|
57
59
|
entryPoint?: string;
|
|
58
60
|
bundlePaths?: {
|
|
@@ -145,6 +145,7 @@ export class BunFsRuntime extends Runtime {
|
|
|
145
145
|
// ── Bundling ─────────────────────────────────────────────────────────
|
|
146
146
|
|
|
147
147
|
override async bundle(): Promise<void> {
|
|
148
|
+
if (this.config.spa === 'none') return;
|
|
148
149
|
const paths = this.config.bundlePaths;
|
|
149
150
|
if (!paths) return;
|
|
150
151
|
|
|
@@ -101,6 +101,7 @@ export class BunSqliteRuntime extends Runtime {
|
|
|
101
101
|
// ── Bundling ─────────────────────────────────────────────────────────
|
|
102
102
|
|
|
103
103
|
override async bundle(): Promise<void> {
|
|
104
|
+
if (this.config.spa === 'none') return;
|
|
104
105
|
const paths = this.config.bundlePaths;
|
|
105
106
|
if (!paths) return;
|
|
106
107
|
|
package/server/emroute.server.ts
CHANGED
|
@@ -215,6 +215,9 @@ export async function createEmrouteServer(
|
|
|
215
215
|
spa = 'root',
|
|
216
216
|
} = config;
|
|
217
217
|
|
|
218
|
+
// Let the runtime know the SPA mode so bundle() can skip when 'none'.
|
|
219
|
+
runtime.config.spa = spa;
|
|
220
|
+
|
|
218
221
|
const { html: htmlBase, md: mdBase } = config.basePath ?? DEFAULT_BASE_PATH;
|
|
219
222
|
|
|
220
223
|
// ── Routes manifest (read from runtime) ─────────────────────────────
|
|
@@ -364,16 +367,10 @@ export async function createEmrouteServer(
|
|
|
364
367
|
if (lastSegment.includes('.')) {
|
|
365
368
|
const fileResponse = await runtime.handle(pathname);
|
|
366
369
|
if (fileResponse.status === 200) return fileResponse;
|
|
370
|
+
return null;
|
|
367
371
|
}
|
|
368
372
|
|
|
369
|
-
// Bare paths —
|
|
370
|
-
// client-side nav). In none/leaf mode, redirect to /html/* for SSR.
|
|
371
|
-
if (spa === 'root' || spa === 'only') {
|
|
372
|
-
return new Response(shell, {
|
|
373
|
-
status: 200,
|
|
374
|
-
headers: { 'Content-Type': 'text/html; charset=utf-8' },
|
|
375
|
-
});
|
|
376
|
-
}
|
|
373
|
+
// Bare paths — redirect to /html/* in all modes.
|
|
377
374
|
const bare = pathname === '/' ? '' : pathname.slice(1).replace(/\/$/, '');
|
|
378
375
|
return Response.redirect(new URL(`${htmlBase}/${bare}`, url.origin), 302);
|
|
379
376
|
}
|