@emkodev/emroute 1.7.3 → 1.8.0-beta.2
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 +1 -1
- package/core/component/abstract.component.ts +74 -0
- package/{src → core}/component/page.component.ts +3 -61
- package/core/component/widget.component.ts +54 -0
- package/core/pipeline/pipeline.ts +224 -0
- package/{src/renderer/ssr → core/renderer}/html.renderer.ts +26 -47
- package/{src/renderer/ssr → core/renderer}/md.renderer.ts +22 -41
- package/{src/renderer/ssr → core/renderer}/ssr.renderer.ts +44 -58
- package/{src/route → core/router}/route.resolver.ts +1 -10
- package/core/router/route.trie.ts +175 -0
- package/core/runtime/abstract.runtime.ts +47 -0
- package/core/server/emroute.server.ts +324 -0
- package/core/type/component.type.ts +39 -0
- package/core/type/element.type.ts +10 -0
- package/core/type/logger.type.ts +20 -0
- package/core/type/markdown.type.ts +8 -0
- package/core/type/route-tree.type.ts +28 -0
- package/core/type/route.type.ts +75 -0
- package/core/type/widget.type.ts +27 -0
- package/core/util/html.util.ts +50 -0
- package/{src → core}/util/md.util.ts +3 -5
- package/{src/route → core/util}/route-tree.util.ts +0 -2
- package/{src → core}/util/widget-resolve.util.ts +15 -46
- package/{src → core}/widget/widget.parser.ts +2 -23
- package/core/widget/widget.registry.ts +36 -0
- package/dist/core/component/abstract.component.d.ts +48 -0
- package/dist/core/component/abstract.component.js +42 -0
- package/dist/core/component/abstract.component.js.map +1 -0
- package/dist/core/component/page.component.d.ts +23 -0
- package/dist/core/component/page.component.js +49 -0
- package/dist/core/component/page.component.js.map +1 -0
- package/dist/core/component/widget.component.d.ts +17 -0
- package/dist/core/component/widget.component.js +37 -0
- package/dist/core/component/widget.component.js.map +1 -0
- package/dist/core/pipeline/pipeline.d.ts +61 -0
- package/dist/core/pipeline/pipeline.js +189 -0
- package/dist/core/pipeline/pipeline.js.map +1 -0
- package/dist/{src/renderer/ssr → core/renderer}/html.renderer.d.ts +8 -24
- package/dist/{src/renderer/ssr → core/renderer}/html.renderer.js +20 -35
- package/dist/core/renderer/html.renderer.js.map +1 -0
- package/dist/{src/renderer/ssr → core/renderer}/md.renderer.d.ts +6 -21
- package/dist/{src/renderer/ssr → core/renderer}/md.renderer.js +16 -32
- package/dist/core/renderer/md.renderer.js.map +1 -0
- package/dist/{src/renderer/ssr → core/renderer}/ssr.renderer.d.ts +11 -27
- package/dist/{src/renderer/ssr → core/renderer}/ssr.renderer.js +33 -37
- package/dist/core/renderer/ssr.renderer.js.map +1 -0
- package/dist/{src/route → core/router}/route.resolver.d.ts +1 -8
- package/dist/{src/route → core/router}/route.resolver.js +0 -1
- package/dist/core/router/route.resolver.js.map +1 -0
- package/dist/core/router/route.trie.d.ts +32 -0
- package/dist/core/router/route.trie.js +152 -0
- package/dist/core/router/route.trie.js.map +1 -0
- package/dist/core/runtime/abstract.runtime.d.ts +32 -0
- package/dist/core/runtime/abstract.runtime.js +26 -0
- package/dist/core/runtime/abstract.runtime.js.map +1 -0
- package/dist/core/server/emroute.server.d.ts +48 -0
- package/dist/core/server/emroute.server.js +239 -0
- package/dist/core/server/emroute.server.js.map +1 -0
- package/dist/core/server/server.type.d.ts +45 -0
- package/dist/core/server/server.type.js +11 -0
- package/dist/core/server/server.type.js.map +1 -0
- package/dist/core/type/component.type.d.ts +37 -0
- package/dist/core/type/component.type.js +7 -0
- package/dist/core/type/component.type.js.map +1 -0
- package/dist/core/type/element.type.d.ts +9 -0
- package/dist/core/type/element.type.js +5 -0
- package/dist/core/type/element.type.js.map +1 -0
- package/dist/core/type/logger.type.d.ts +14 -0
- package/dist/core/type/logger.type.js +8 -0
- package/dist/core/type/logger.type.js.map +1 -0
- package/dist/core/type/markdown.type.d.ts +7 -0
- package/dist/core/type/markdown.type.js +5 -0
- package/dist/core/type/markdown.type.js.map +1 -0
- package/dist/{src → core}/type/route-tree.type.d.ts +0 -12
- package/dist/{src → core}/type/route-tree.type.js +0 -1
- package/dist/core/type/route-tree.type.js.map +1 -0
- package/dist/core/type/route.type.d.ts +62 -0
- package/dist/core/type/route.type.js +7 -0
- package/dist/core/type/route.type.js.map +1 -0
- package/dist/core/type/widget.type.d.ts +27 -0
- package/dist/core/type/widget.type.js +5 -0
- package/dist/core/type/widget.type.js.map +1 -0
- package/dist/core/util/html.util.d.ts +14 -0
- package/dist/core/util/html.util.js +43 -0
- package/dist/core/util/html.util.js.map +1 -0
- package/dist/{src → core}/util/md.util.d.ts +0 -1
- package/dist/{src → core}/util/md.util.js +0 -2
- package/dist/core/util/md.util.js.map +1 -0
- package/dist/{src/route → core/util}/route-tree.util.js +0 -2
- package/dist/core/util/route-tree.util.js.map +1 -0
- package/dist/core/util/widget-resolve.util.d.ts +28 -0
- package/dist/{src → core}/util/widget-resolve.util.js +12 -42
- package/dist/core/util/widget-resolve.util.js.map +1 -0
- package/dist/{src → core}/widget/widget.parser.d.ts +0 -13
- package/dist/{src → core}/widget/widget.parser.js +1 -22
- package/dist/core/widget/widget.parser.js.map +1 -0
- package/dist/core/widget/widget.registry.d.ts +14 -0
- package/dist/core/widget/widget.registry.js +26 -0
- package/dist/core/widget/widget.registry.js.map +1 -0
- package/dist/emroute.js +1092 -1220
- package/dist/emroute.js.map +36 -5
- package/dist/runtime/abstract.runtime.d.ts +41 -7
- package/dist/runtime/abstract.runtime.js +404 -9
- package/dist/runtime/abstract.runtime.js.map +1 -1
- package/dist/runtime/bun/fs/bun-fs.runtime.d.ts +1 -0
- package/dist/runtime/bun/fs/bun-fs.runtime.js +15 -1
- package/dist/runtime/bun/fs/bun-fs.runtime.js.map +1 -1
- package/dist/runtime/bun/sqlite/bun-sqlite.runtime.d.ts +2 -0
- package/dist/runtime/bun/sqlite/bun-sqlite.runtime.js +8 -0
- package/dist/runtime/bun/sqlite/bun-sqlite.runtime.js.map +1 -1
- package/dist/runtime/fetch.runtime.d.ts +3 -3
- package/dist/runtime/fetch.runtime.js +3 -3
- package/dist/runtime/sitemap.generator.d.ts +1 -1
- package/dist/runtime/sitemap.generator.js +1 -1
- package/dist/runtime/sitemap.generator.js.map +1 -1
- package/dist/runtime/universal/fs/universal-fs.runtime.d.ts +1 -0
- package/dist/runtime/universal/fs/universal-fs.runtime.js +15 -1
- package/dist/runtime/universal/fs/universal-fs.runtime.js.map +1 -1
- package/dist/server/build.util.d.ts +9 -10
- package/dist/server/build.util.js +11 -31
- package/dist/server/build.util.js.map +1 -1
- package/dist/server/codegen.util.d.ts +1 -1
- package/dist/server/emroute.server.d.ts +8 -35
- package/dist/server/emroute.server.js +7 -351
- package/dist/server/emroute.server.js.map +1 -1
- package/dist/server/esbuild-manifest.plugin.js +1 -1
- package/dist/server/esbuild-manifest.plugin.js.map +1 -1
- package/dist/server/server-api.type.d.ts +3 -71
- package/dist/server/server-api.type.js +1 -8
- package/dist/server/server-api.type.js.map +1 -1
- package/dist/src/element/component.element.d.ts +6 -14
- package/dist/src/element/component.element.js +13 -40
- package/dist/src/element/component.element.js.map +1 -1
- package/dist/src/element/markdown.element.d.ts +2 -2
- package/dist/src/element/markdown.element.js +3 -2
- package/dist/src/element/markdown.element.js.map +1 -1
- package/dist/src/index.d.ts +15 -14
- package/dist/src/index.js +8 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/renderer/spa/emroute.app.d.ts +50 -0
- package/dist/src/renderer/spa/emroute.app.js +246 -0
- package/dist/src/renderer/spa/emroute.app.js.map +1 -0
- package/dist/src/renderer/spa/mod.d.ts +17 -16
- package/dist/src/renderer/spa/mod.js +9 -9
- package/dist/src/renderer/spa/mod.js.map +1 -1
- package/dist/src/renderer/spa/thin-client.d.ts +3 -3
- package/dist/src/renderer/spa/thin-client.js +7 -7
- package/dist/src/renderer/spa/thin-client.js.map +1 -1
- package/dist/src/route/route.core.d.ts +3 -3
- package/dist/src/util/html.util.d.ts +5 -22
- package/dist/src/util/html.util.js +8 -56
- package/dist/src/util/html.util.js.map +1 -1
- package/dist/src/widget/breadcrumb.widget.d.ts +2 -2
- package/dist/src/widget/breadcrumb.widget.js +2 -2
- package/dist/src/widget/breadcrumb.widget.js.map +1 -1
- package/dist/src/widget/page-title.widget.d.ts +1 -1
- package/dist/src/widget/page-title.widget.js +1 -1
- package/dist/src/widget/page-title.widget.js.map +1 -1
- package/package.json +8 -8
- package/runtime/abstract.runtime.ts +433 -17
- package/runtime/bun/fs/bun-fs.runtime.ts +15 -1
- package/runtime/bun/sqlite/bun-sqlite.runtime.ts +9 -0
- package/runtime/fetch.runtime.ts +3 -3
- package/runtime/sitemap.generator.ts +2 -2
- package/runtime/universal/fs/universal-fs.runtime.ts +15 -1
- package/server/build.util.ts +17 -43
- package/server/codegen.util.ts +1 -1
- package/server/emroute.server.ts +12 -426
- package/src/element/component.element.ts +14 -54
- package/src/element/markdown.element.ts +4 -3
- package/src/index.ts +22 -19
- package/src/renderer/spa/{thin-client.ts → emroute.app.ts} +19 -20
- package/src/renderer/spa/mod.ts +22 -22
- package/src/util/html.util.ts +16 -61
- package/src/widget/breadcrumb.widget.ts +3 -3
- package/src/widget/page-title.widget.ts +1 -1
- package/dist/src/component/abstract.component.d.ts +0 -199
- package/dist/src/component/abstract.component.js +0 -84
- package/dist/src/component/abstract.component.js.map +0 -1
- package/dist/src/component/page.component.d.ts +0 -74
- package/dist/src/component/page.component.js +0 -107
- package/dist/src/component/page.component.js.map +0 -1
- package/dist/src/component/widget.component.d.ts +0 -47
- package/dist/src/component/widget.component.js +0 -69
- package/dist/src/component/widget.component.js.map +0 -1
- package/dist/src/renderer/ssr/html.renderer.js.map +0 -1
- package/dist/src/renderer/ssr/md.renderer.js.map +0 -1
- package/dist/src/renderer/ssr/ssr.renderer.js.map +0 -1
- package/dist/src/route/route-tree.util.js.map +0 -1
- package/dist/src/route/route.matcher.d.ts +0 -86
- package/dist/src/route/route.matcher.js +0 -214
- package/dist/src/route/route.matcher.js.map +0 -1
- package/dist/src/route/route.resolver.js.map +0 -1
- package/dist/src/route/route.trie.d.ts +0 -38
- package/dist/src/route/route.trie.js +0 -206
- package/dist/src/route/route.trie.js.map +0 -1
- package/dist/src/type/element.type.d.ts +0 -19
- package/dist/src/type/element.type.js +0 -9
- package/dist/src/type/element.type.js.map +0 -1
- package/dist/src/type/logger.type.d.ts +0 -17
- package/dist/src/type/logger.type.js +0 -9
- package/dist/src/type/logger.type.js.map +0 -1
- package/dist/src/type/markdown.type.d.ts +0 -20
- package/dist/src/type/markdown.type.js +0 -2
- package/dist/src/type/markdown.type.js.map +0 -1
- package/dist/src/type/route-tree.type.js.map +0 -1
- package/dist/src/type/route.type.d.ts +0 -94
- package/dist/src/type/route.type.js +0 -8
- package/dist/src/type/route.type.js.map +0 -1
- package/dist/src/type/widget.type.d.ts +0 -55
- package/dist/src/type/widget.type.js +0 -10
- package/dist/src/type/widget.type.js.map +0 -1
- package/dist/src/util/logger.util.d.ts +0 -26
- package/dist/src/util/logger.util.js +0 -80
- package/dist/src/util/logger.util.js.map +0 -1
- package/dist/src/util/md.util.js.map +0 -1
- package/dist/src/util/widget-resolve.util.d.ts +0 -52
- package/dist/src/util/widget-resolve.util.js.map +0 -1
- package/dist/src/widget/widget.parser.js.map +0 -1
- package/dist/src/widget/widget.registry.d.ts +0 -23
- package/dist/src/widget/widget.registry.js +0 -42
- package/dist/src/widget/widget.registry.js.map +0 -1
- package/runtime/bun/esbuild-runtime-loader.plugin.ts +0 -112
- package/server/esbuild-manifest.plugin.ts +0 -209
- package/server/server-api.type.ts +0 -101
- package/src/component/abstract.component.ts +0 -231
- package/src/component/widget.component.ts +0 -85
- package/src/route/route.core.ts +0 -371
- package/src/route/route.trie.ts +0 -265
- package/src/type/element.type.ts +0 -22
- package/src/type/logger.type.ts +0 -24
- package/src/type/markdown.type.ts +0 -21
- package/src/type/route-tree.type.ts +0 -51
- package/src/type/route.type.ts +0 -124
- package/src/type/widget.type.ts +0 -65
- package/src/util/logger.util.ts +0 -83
- package/src/widget/widget.registry.ts +0 -51
- /package/dist/{src/route → core/util}/route-tree.util.d.ts +0 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline
|
|
3
|
+
*
|
|
4
|
+
* Orchestration layer between Router, Runtime, and Component.
|
|
5
|
+
*
|
|
6
|
+
* Owns:
|
|
7
|
+
* - Route matching (reads manifest from Runtime, walks RouteNode tree)
|
|
8
|
+
* - Module loading (delegates to Runtime)
|
|
9
|
+
* - Companion file reading (delegates to Runtime)
|
|
10
|
+
* - ComponentContext building
|
|
11
|
+
* - Route hierarchy construction
|
|
12
|
+
*
|
|
13
|
+
* Does NOT own:
|
|
14
|
+
* - Rendering (that's Renderer)
|
|
15
|
+
* - HTTP routing / base paths (that's Server)
|
|
16
|
+
* - Storage I/O (that's Runtime)
|
|
17
|
+
* - Navigation events (that's the browser adapter)
|
|
18
|
+
*/
|
|
19
|
+
import { RouteTrie } from "../router/route.trie.js";
|
|
20
|
+
import { ROUTES_MANIFEST_PATH } from "../runtime/abstract.runtime.js";
|
|
21
|
+
import { defaultLogger } from "../type/logger.type.js";
|
|
22
|
+
/** Default root route — renders a slot for child routes. */
|
|
23
|
+
export const DEFAULT_ROOT_ROUTE = {
|
|
24
|
+
pattern: '/',
|
|
25
|
+
type: 'page',
|
|
26
|
+
modulePath: '__default_root__',
|
|
27
|
+
};
|
|
28
|
+
/** Synthesize a RouteConfig from matched route data. */
|
|
29
|
+
function toRouteConfig(node, pattern) {
|
|
30
|
+
return {
|
|
31
|
+
pattern,
|
|
32
|
+
type: node.redirect ? 'redirect' : 'page',
|
|
33
|
+
modulePath: node.redirect ?? node.files?.ts ?? node.files?.js ?? node.files?.html ?? node.files?.md ?? '',
|
|
34
|
+
...(node.files ? { files: node.files } : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export class Pipeline {
|
|
38
|
+
runtime;
|
|
39
|
+
contextProvider;
|
|
40
|
+
logger;
|
|
41
|
+
moduleLoaders;
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this.runtime = options.runtime;
|
|
44
|
+
this.contextProvider = options.contextProvider;
|
|
45
|
+
this.logger = options.logger ?? defaultLogger;
|
|
46
|
+
this.moduleLoaders = options.moduleLoaders ?? {};
|
|
47
|
+
}
|
|
48
|
+
// ── Route resolver (from Runtime) ───────────────────────────────────
|
|
49
|
+
async getResolver() {
|
|
50
|
+
const response = await this.runtime.query(ROUTES_MANIFEST_PATH);
|
|
51
|
+
const tree = response.status === 404 ? {} : await response.json();
|
|
52
|
+
return new RouteTrie(tree);
|
|
53
|
+
}
|
|
54
|
+
// ── Matching ────────────────────────────────────────────────────────
|
|
55
|
+
async match(url) {
|
|
56
|
+
const resolver = await this.getResolver();
|
|
57
|
+
const resolved = resolver.match(url.pathname);
|
|
58
|
+
if (resolved) {
|
|
59
|
+
return { route: toRouteConfig(resolved.node, resolved.pattern), params: resolved.params };
|
|
60
|
+
}
|
|
61
|
+
if (url.pathname === '/' || url.pathname === '') {
|
|
62
|
+
return { route: DEFAULT_ROOT_ROUTE, params: {} };
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
async findRoute(pattern) {
|
|
67
|
+
const resolver = await this.getResolver();
|
|
68
|
+
const node = resolver.findRoute(pattern);
|
|
69
|
+
if (!node)
|
|
70
|
+
return undefined;
|
|
71
|
+
return toRouteConfig(node, pattern);
|
|
72
|
+
}
|
|
73
|
+
async findErrorBoundary(pathname) {
|
|
74
|
+
const resolver = await this.getResolver();
|
|
75
|
+
const modulePath = resolver.findErrorBoundary(pathname);
|
|
76
|
+
if (!modulePath)
|
|
77
|
+
return undefined;
|
|
78
|
+
return { pattern: pathname, modulePath };
|
|
79
|
+
}
|
|
80
|
+
async getStatusPage(status) {
|
|
81
|
+
const resolver = await this.getResolver();
|
|
82
|
+
const node = resolver.findRoute(`/${status}`);
|
|
83
|
+
if (!node)
|
|
84
|
+
return undefined;
|
|
85
|
+
return toRouteConfig(node, `/${status}`);
|
|
86
|
+
}
|
|
87
|
+
async getErrorHandler() {
|
|
88
|
+
const resolver = await this.getResolver();
|
|
89
|
+
const modulePath = resolver.findErrorBoundary('/');
|
|
90
|
+
if (!modulePath)
|
|
91
|
+
return undefined;
|
|
92
|
+
return { pattern: '/', type: 'error', modulePath };
|
|
93
|
+
}
|
|
94
|
+
// ── Route hierarchy ────────────────────────────────────────────────
|
|
95
|
+
buildRouteHierarchy(pattern) {
|
|
96
|
+
if (pattern === '/')
|
|
97
|
+
return ['/'];
|
|
98
|
+
const segments = pattern.split('/').filter(Boolean);
|
|
99
|
+
const hierarchy = ['/'];
|
|
100
|
+
let current = '';
|
|
101
|
+
for (const segment of segments) {
|
|
102
|
+
current += '/' + segment;
|
|
103
|
+
hierarchy.push(current);
|
|
104
|
+
}
|
|
105
|
+
return hierarchy;
|
|
106
|
+
}
|
|
107
|
+
// ── Module loading ─────────────────────────────────────────────────
|
|
108
|
+
async loadModule(modulePath) {
|
|
109
|
+
const loader = this.moduleLoaders[modulePath];
|
|
110
|
+
if (loader) {
|
|
111
|
+
return await loader();
|
|
112
|
+
}
|
|
113
|
+
const abs = modulePath.startsWith('/') ? modulePath : '/' + modulePath;
|
|
114
|
+
return await this.runtime.loadModule(abs);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get inlined `__files` from a loaded module (merged module pattern).
|
|
118
|
+
*/
|
|
119
|
+
getModuleFiles(mod) {
|
|
120
|
+
if (!mod || typeof mod !== 'object')
|
|
121
|
+
return undefined;
|
|
122
|
+
const files = mod.__files;
|
|
123
|
+
if (!files || typeof files !== 'object')
|
|
124
|
+
return undefined;
|
|
125
|
+
return files;
|
|
126
|
+
}
|
|
127
|
+
// ── File loading ───────────────────────────────────────────────────
|
|
128
|
+
async loadFiles(files) {
|
|
129
|
+
const load = async (path) => {
|
|
130
|
+
const abs = path.startsWith('/') ? path : '/' + path;
|
|
131
|
+
try {
|
|
132
|
+
return await this.runtime.query(abs, { as: 'text' });
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
console.warn(`[Pipeline] Failed to load file ${path}:`, e instanceof Error ? e.message : e);
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const [html, md, css] = await Promise.all([
|
|
140
|
+
files.html ? load(files.html) : undefined,
|
|
141
|
+
files.md ? load(files.md) : undefined,
|
|
142
|
+
files.css ? load(files.css) : undefined,
|
|
143
|
+
]);
|
|
144
|
+
const result = {};
|
|
145
|
+
if (html !== undefined)
|
|
146
|
+
result.html = html;
|
|
147
|
+
if (md !== undefined)
|
|
148
|
+
result.md = md;
|
|
149
|
+
if (css !== undefined)
|
|
150
|
+
result.css = css;
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
// ── Context building ───────────────────────────────────────────────
|
|
154
|
+
toRouteInfo(matched, url) {
|
|
155
|
+
return { url, params: matched.params };
|
|
156
|
+
}
|
|
157
|
+
async buildContext(routeInfo, route, signal, isLeaf, loadedModule) {
|
|
158
|
+
const rf = route.files;
|
|
159
|
+
// Try inlined __files from merged module first
|
|
160
|
+
const inlined = loadedModule ? this.getModuleFiles(loadedModule) : undefined;
|
|
161
|
+
let files;
|
|
162
|
+
if (inlined) {
|
|
163
|
+
files = inlined;
|
|
164
|
+
}
|
|
165
|
+
else if (rf) {
|
|
166
|
+
const filePaths = {};
|
|
167
|
+
if (rf.html)
|
|
168
|
+
filePaths.html = rf.html;
|
|
169
|
+
if (rf.md)
|
|
170
|
+
filePaths.md = rf.md;
|
|
171
|
+
if (rf.css)
|
|
172
|
+
filePaths.css = rf.css;
|
|
173
|
+
files = await this.loadFiles(filePaths);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
files = {};
|
|
177
|
+
}
|
|
178
|
+
const base = {
|
|
179
|
+
...routeInfo,
|
|
180
|
+
pathname: routeInfo.url.pathname,
|
|
181
|
+
searchParams: routeInfo.url.searchParams,
|
|
182
|
+
files,
|
|
183
|
+
...(signal ? { signal } : {}),
|
|
184
|
+
...(isLeaf !== undefined ? { isLeaf } : {}),
|
|
185
|
+
};
|
|
186
|
+
return this.contextProvider ? this.contextProvider(base) : base;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../core/pipeline/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAKpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAe,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEpE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC7C,OAAO,EAAE,GAAG;IACZ,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,kBAAkB;CAC/B,CAAC;AAEF,wDAAwD;AACxD,SAAS,aAAa,CAAC,IAAe,EAAE,OAAe;IACrD,OAAO;QACL,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM;QACzC,UAAU,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE;QACzG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7C,CAAC;AACJ,CAAC;AAWD,MAAM,OAAO,QAAQ;IACF,OAAO,CAAU;IACzB,eAAe,CAA8B;IAC7C,MAAM,CAAS;IACP,aAAa,CAAyC;IAEvE,YAAY,OAAwB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,O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CAAC,IAAI,CAAC;IAClE,CAAC;CACF"}
|
|
@@ -5,29 +5,22 @@
|
|
|
5
5
|
* Generates complete HTML strings without DOM manipulation.
|
|
6
6
|
* Expands <mark-down> tags server-side when a markdown renderer is provided.
|
|
7
7
|
*/
|
|
8
|
-
import type { RouteConfig, RouteInfo } from '
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
8
|
+
import type { RouteConfig, RouteInfo } from '../type/route.type.ts';
|
|
9
|
+
import type { MarkdownRenderer } from '../type/markdown.type.ts';
|
|
10
|
+
import type { PageComponent } from '../component/page.component.ts';
|
|
11
|
+
import type { Pipeline } from '../pipeline/pipeline.ts';
|
|
12
12
|
import { SsrRenderer, type SsrRendererOptions } from './ssr.renderer.ts';
|
|
13
|
-
/** Options for SSR HTML
|
|
14
|
-
export interface
|
|
15
|
-
/** Markdown renderer for server-side <mark-down> expansion */
|
|
13
|
+
/** Options for SSR HTML Renderer. */
|
|
14
|
+
export interface SsrHtmlRendererOptions extends SsrRendererOptions {
|
|
16
15
|
markdownRenderer?: MarkdownRenderer;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
* SSR HTML Router for server-side rendering.
|
|
20
|
-
*/
|
|
21
|
-
export declare class SsrHtmlRouter extends SsrRenderer {
|
|
17
|
+
export declare class SsrHtmlRenderer extends SsrRenderer {
|
|
22
18
|
protected readonly label = "SSR HTML";
|
|
23
19
|
private markdownRenderer;
|
|
24
20
|
private markdownReady;
|
|
25
|
-
constructor(
|
|
21
|
+
constructor(pipeline: Pipeline, options?: SsrHtmlRendererOptions);
|
|
26
22
|
protected injectSlot(parent: string, child: string, parentPattern: string): string;
|
|
27
23
|
protected stripSlots(result: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* Render a single route's content.
|
|
30
|
-
*/
|
|
31
24
|
protected renderRouteContent(routeInfo: RouteInfo, route: RouteConfig, isLeaf?: boolean, signal?: AbortSignal): Promise<{
|
|
32
25
|
content: string;
|
|
33
26
|
title?: string;
|
|
@@ -36,15 +29,6 @@ export declare class SsrHtmlRouter extends SsrRenderer {
|
|
|
36
29
|
protected renderRedirect(to: string): string;
|
|
37
30
|
protected renderStatusPage(status: number, url: URL): string;
|
|
38
31
|
protected renderErrorPage(error: unknown, url: URL): string;
|
|
39
|
-
/** Add pattern attribute to bare <router-slot> tags. */
|
|
40
32
|
private attributeSlots;
|
|
41
|
-
/**
|
|
42
|
-
* Expand <mark-down> tags by rendering markdown to HTML server-side.
|
|
43
|
-
* Leaves content unchanged if no markdown renderer is configured.
|
|
44
|
-
*/
|
|
45
33
|
private expandMarkdown;
|
|
46
34
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Create SSR HTML router.
|
|
49
|
-
*/
|
|
50
|
-
export declare function createSsrHtmlRouter(resolver: RouteResolver, options?: SsrHtmlRouterOptions): SsrHtmlRouter;
|
|
@@ -5,19 +5,16 @@
|
|
|
5
5
|
* Generates complete HTML strings without DOM manipulation.
|
|
6
6
|
* Expands <mark-down> tags server-side when a markdown renderer is provided.
|
|
7
7
|
*/
|
|
8
|
-
import { DEFAULT_ROOT_ROUTE } from "
|
|
9
|
-
import { escapeHtml, STATUS_MESSAGES, unescapeHtml } from "
|
|
10
|
-
import { resolveWidgetTags } from "
|
|
8
|
+
import { DEFAULT_ROOT_ROUTE } from "../pipeline/pipeline.js";
|
|
9
|
+
import { escapeHtml, STATUS_MESSAGES, unescapeHtml } from "../util/html.util.js";
|
|
10
|
+
import { resolveWidgetTags } from "../util/widget-resolve.util.js";
|
|
11
11
|
import { SsrRenderer } from "./ssr.renderer.js";
|
|
12
|
-
|
|
13
|
-
* SSR HTML Router for server-side rendering.
|
|
14
|
-
*/
|
|
15
|
-
export class SsrHtmlRouter extends SsrRenderer {
|
|
12
|
+
export class SsrHtmlRenderer extends SsrRenderer {
|
|
16
13
|
label = 'SSR HTML';
|
|
17
14
|
markdownRenderer;
|
|
18
15
|
markdownReady = null;
|
|
19
|
-
constructor(
|
|
20
|
-
super(
|
|
16
|
+
constructor(pipeline, options = {}) {
|
|
17
|
+
super(pipeline, options);
|
|
21
18
|
this.markdownRenderer = options.markdownRenderer ?? null;
|
|
22
19
|
if (this.markdownRenderer?.init) {
|
|
23
20
|
this.markdownReady = this.markdownRenderer.init();
|
|
@@ -30,28 +27,29 @@ export class SsrHtmlRouter extends SsrRenderer {
|
|
|
30
27
|
stripSlots(result) {
|
|
31
28
|
return result.replace(/<router-slot[^>]*><\/router-slot>/g, '');
|
|
32
29
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Render a single route's content.
|
|
35
|
-
*/
|
|
36
30
|
async renderRouteContent(routeInfo, route, isLeaf, signal) {
|
|
37
31
|
if (route.modulePath === DEFAULT_ROOT_ROUTE.modulePath) {
|
|
38
32
|
return { content: `<router-slot pattern="${route.pattern}"></router-slot>` };
|
|
39
33
|
}
|
|
40
34
|
const { content: rawContent, title } = await this.loadRouteContent(routeInfo, route, isLeaf, signal);
|
|
41
35
|
let content = rawContent;
|
|
42
|
-
// Expand <mark-down> tags server-side
|
|
43
36
|
content = await this.expandMarkdown(content);
|
|
44
|
-
// Attribute bare <router-slot> tags with this route's pattern
|
|
45
|
-
// resolution so widget-internal slots inside <template> are not affected)
|
|
37
|
+
// Attribute bare <router-slot> tags with this route's pattern
|
|
46
38
|
content = this.attributeSlots(content, route.pattern);
|
|
47
|
-
// Resolve <widget-*> tags
|
|
39
|
+
// Resolve <widget-*> tags
|
|
48
40
|
if (this.widgets) {
|
|
49
|
-
content = await resolveWidgetTags(content, this.widgets, routeInfo, (name
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
content = await resolveWidgetTags(content, this.widgets, routeInfo, async (name) => {
|
|
42
|
+
const modulePath = this.widgets.getModulePath(name);
|
|
43
|
+
if (modulePath) {
|
|
44
|
+
const mod = await this.pipeline.loadModule(modulePath);
|
|
45
|
+
const inlined = this.pipeline.getModuleFiles(mod);
|
|
46
|
+
if (inlined)
|
|
47
|
+
return inlined;
|
|
48
|
+
}
|
|
49
|
+
return {};
|
|
50
|
+
}, this.pipeline.contextProvider, this.logger);
|
|
53
51
|
}
|
|
54
|
-
return { content, ...(title
|
|
52
|
+
return { content, ...(title !== undefined ? { title } : {}) };
|
|
55
53
|
}
|
|
56
54
|
renderContent(component, args) {
|
|
57
55
|
return component.renderHTML(args);
|
|
@@ -73,14 +71,9 @@ export class SsrHtmlRouter extends SsrRenderer {
|
|
|
73
71
|
<p>${escapeHtml(message)}</p>
|
|
74
72
|
`;
|
|
75
73
|
}
|
|
76
|
-
/** Add pattern attribute to bare <router-slot> tags. */
|
|
77
74
|
attributeSlots(content, routePattern) {
|
|
78
75
|
return content.replace(/<router-slot(?![^>]*\bpattern=)([^>]*)><\/router-slot>/g, `<router-slot pattern="${routePattern}"$1></router-slot>`);
|
|
79
76
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Expand <mark-down> tags by rendering markdown to HTML server-side.
|
|
82
|
-
* Leaves content unchanged if no markdown renderer is configured.
|
|
83
|
-
*/
|
|
84
77
|
async expandMarkdown(content) {
|
|
85
78
|
if (!this.markdownRenderer)
|
|
86
79
|
return content;
|
|
@@ -90,19 +83,11 @@ export class SsrHtmlRouter extends SsrRenderer {
|
|
|
90
83
|
await this.markdownReady;
|
|
91
84
|
}
|
|
92
85
|
const renderer = this.markdownRenderer;
|
|
93
|
-
// Match <mark-down>escaped content</mark-down>
|
|
94
86
|
const pattern = /<mark-down>([\s\S]*?)<\/mark-down>/g;
|
|
95
87
|
return content.replace(pattern, (_match, escaped) => {
|
|
96
88
|
const markdown = unescapeHtml(escaped);
|
|
97
|
-
|
|
98
|
-
return rendered;
|
|
89
|
+
return renderer.render(markdown);
|
|
99
90
|
});
|
|
100
91
|
}
|
|
101
92
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Create SSR HTML router.
|
|
104
|
-
*/
|
|
105
|
-
export function createSsrHtmlRouter(resolver, options) {
|
|
106
|
-
return new SsrHtmlRouter(resolver, options);
|
|
107
|
-
}
|
|
108
93
|
//# sourceMappingURL=html.renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.renderer.js","sourceRoot":"","sources":["../../../core/renderer/html.renderer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AAOzE,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAClB,KAAK,GAAG,UAAU,CAAC;IACvC,gBAAgB,CAA0B;IAC1C,aAAa,GAAyB,IAAI,CAAC;IAEnD,YAAY,QAAkB,EAAE,UAAkC,EAAE;QAClE,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,IAAI,CAAC;QAEzD,IAAI,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QACpD,CAAC;IACH,CAAC;IAEkB,UAAU,CAAC,MAAc,EAAE,KAAa,EAAE,aAAqB;QAChF,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QACrE,OAAO,MAAM,CAAC,OAAO,CACnB,IAAI,MAAM,CAAC,mCAAmC,OAAO,uBAAuB,CAAC,EAC7E,KAAK,CACN,CAAC;IACJ,CAAC;IAEkB,UAAU,CAAC,MAAc;QAC1C,OAAO,MAAM,CAAC,OAAO,CAAC,oCAAoC,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAEkB,KAAK,CAAC,kBAAkB,CACzC,SAA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qCAAqC,CAAC;QAEtD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAe,EAAE,EAAE;YAC1D,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;YACvC,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -4,23 +4,16 @@
|
|
|
4
4
|
* Server-side Markdown rendering.
|
|
5
5
|
* Generates Markdown strings for LLM consumption, text clients, curl.
|
|
6
6
|
*/
|
|
7
|
-
import type { RouteConfig, RouteInfo } from '
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
7
|
+
import type { RouteConfig, RouteInfo } from '../type/route.type.ts';
|
|
8
|
+
import type { PageComponent } from '../component/page.component.ts';
|
|
9
|
+
import type { Pipeline } from '../pipeline/pipeline.ts';
|
|
10
10
|
import { SsrRenderer, type SsrRendererOptions } from './ssr.renderer.ts';
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
/**
|
|
14
|
-
* SSR Markdown Router for server-side markdown rendering.
|
|
15
|
-
*/
|
|
16
|
-
export declare class SsrMdRouter extends SsrRenderer {
|
|
11
|
+
export type SsrMdRendererOptions = SsrRendererOptions;
|
|
12
|
+
export declare class SsrMdRenderer extends SsrRenderer {
|
|
17
13
|
protected readonly label = "SSR MD";
|
|
18
|
-
constructor(
|
|
14
|
+
constructor(pipeline: Pipeline, options?: SsrMdRendererOptions);
|
|
19
15
|
protected injectSlot(parent: string, child: string, parentPattern: string): string;
|
|
20
16
|
protected stripSlots(result: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Render a single route's content to Markdown.
|
|
23
|
-
*/
|
|
24
17
|
protected renderRouteContent(routeInfo: RouteInfo, route: RouteConfig, isLeaf?: boolean, signal?: AbortSignal): Promise<{
|
|
25
18
|
content: string;
|
|
26
19
|
title?: string;
|
|
@@ -29,13 +22,5 @@ export declare class SsrMdRouter extends SsrRenderer {
|
|
|
29
22
|
protected renderRedirect(to: string): string;
|
|
30
23
|
protected renderStatusPage(status: number, url: URL): string;
|
|
31
24
|
protected renderErrorPage(_error: unknown, url: URL): string;
|
|
32
|
-
/**
|
|
33
|
-
* Resolve fenced widget blocks in markdown content.
|
|
34
|
-
* Replaces ```widget:name blocks with rendered markdown output.
|
|
35
|
-
*/
|
|
36
25
|
private resolveWidgets;
|
|
37
26
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Create SSR Markdown router.
|
|
40
|
-
*/
|
|
41
|
-
export declare function createSsrMdRouter(resolver: RouteResolver, options?: SsrMdRouterOptions): SsrMdRouter;
|
|
@@ -4,22 +4,19 @@
|
|
|
4
4
|
* Server-side Markdown rendering.
|
|
5
5
|
* Generates Markdown strings for LLM consumption, text clients, curl.
|
|
6
6
|
*/
|
|
7
|
-
import { DEFAULT_ROOT_ROUTE } from "
|
|
8
|
-
import { STATUS_MESSAGES } from "
|
|
9
|
-
import { resolveRecursively } from "
|
|
10
|
-
import { parseWidgetBlocks, replaceWidgetBlocks } from "
|
|
7
|
+
import { DEFAULT_ROOT_ROUTE } from "../pipeline/pipeline.js";
|
|
8
|
+
import { STATUS_MESSAGES } from "../util/html.util.js";
|
|
9
|
+
import { resolveRecursively } from "../util/widget-resolve.util.js";
|
|
10
|
+
import { parseWidgetBlocks, replaceWidgetBlocks } from "../widget/widget.parser.js";
|
|
11
11
|
import { SsrRenderer } from "./ssr.renderer.js";
|
|
12
12
|
const BARE_SLOT_BLOCK = '```router-slot\n```';
|
|
13
13
|
function routerSlotBlock(pattern) {
|
|
14
14
|
return `\`\`\`router-slot\n{"pattern":"${pattern}"}\n\`\`\``;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
* SSR Markdown Router for server-side markdown rendering.
|
|
18
|
-
*/
|
|
19
|
-
export class SsrMdRouter extends SsrRenderer {
|
|
16
|
+
export class SsrMdRenderer extends SsrRenderer {
|
|
20
17
|
label = 'SSR MD';
|
|
21
|
-
constructor(
|
|
22
|
-
super(
|
|
18
|
+
constructor(pipeline, options = {}) {
|
|
19
|
+
super(pipeline, options);
|
|
23
20
|
}
|
|
24
21
|
injectSlot(parent, child, parentPattern) {
|
|
25
22
|
return parent.replace(routerSlotBlock(parentPattern), child);
|
|
@@ -29,9 +26,6 @@ export class SsrMdRouter extends SsrRenderer {
|
|
|
29
26
|
.replace(/```router-slot\n(?:\{[^}]*\}\n)?```/g, '')
|
|
30
27
|
.trim();
|
|
31
28
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Render a single route's content to Markdown.
|
|
34
|
-
*/
|
|
35
29
|
async renderRouteContent(routeInfo, route, isLeaf, signal) {
|
|
36
30
|
if (route.modulePath === DEFAULT_ROOT_ROUTE.modulePath) {
|
|
37
31
|
return { content: routerSlotBlock(route.pattern) };
|
|
@@ -39,13 +33,12 @@ export class SsrMdRouter extends SsrRenderer {
|
|
|
39
33
|
const { content: rawContent, title } = await this.loadRouteContent(routeInfo, route, isLeaf, signal);
|
|
40
34
|
let content = rawContent;
|
|
41
35
|
// Attribute bare router-slot blocks with this route's pattern
|
|
42
|
-
// (before widget resolution so widget-internal blocks are not affected)
|
|
43
36
|
content = content.replaceAll(BARE_SLOT_BLOCK, routerSlotBlock(route.pattern));
|
|
44
|
-
// Resolve fenced widget blocks
|
|
37
|
+
// Resolve fenced widget blocks
|
|
45
38
|
if (this.widgets) {
|
|
46
39
|
content = await this.resolveWidgets(content, routeInfo);
|
|
47
40
|
}
|
|
48
|
-
return { content, ...(title
|
|
41
|
+
return { content, ...(title !== undefined ? { title } : {}) };
|
|
49
42
|
}
|
|
50
43
|
renderContent(component, args) {
|
|
51
44
|
return component.renderMarkdown(args);
|
|
@@ -59,10 +52,6 @@ export class SsrMdRouter extends SsrRenderer {
|
|
|
59
52
|
renderErrorPage(_error, url) {
|
|
60
53
|
return `# Internal Server Error\n\nPath: \`${url.pathname}\``;
|
|
61
54
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Resolve fenced widget blocks in markdown content.
|
|
64
|
-
* Replaces ```widget:name blocks with rendered markdown output.
|
|
65
|
-
*/
|
|
66
55
|
resolveWidgets(content, routeInfo) {
|
|
67
56
|
return resolveRecursively(content, parseWidgetBlocks, async (block) => {
|
|
68
57
|
if (block.parseError || !block.params) {
|
|
@@ -74,9 +63,10 @@ export class SsrMdRouter extends SsrRenderer {
|
|
|
74
63
|
}
|
|
75
64
|
try {
|
|
76
65
|
let files;
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
|
|
66
|
+
const modulePath = this.widgets.getModulePath(block.widgetName);
|
|
67
|
+
if (modulePath) {
|
|
68
|
+
const mod = await this.pipeline.loadModule(modulePath);
|
|
69
|
+
files = this.pipeline.getModuleFiles(mod);
|
|
80
70
|
}
|
|
81
71
|
const baseContext = {
|
|
82
72
|
...routeInfo,
|
|
@@ -84,8 +74,8 @@ export class SsrMdRouter extends SsrRenderer {
|
|
|
84
74
|
searchParams: routeInfo.url.searchParams,
|
|
85
75
|
...(files ? { files } : {}),
|
|
86
76
|
};
|
|
87
|
-
const context = this.
|
|
88
|
-
? this.
|
|
77
|
+
const context = this.pipeline.contextProvider
|
|
78
|
+
? this.pipeline.contextProvider(baseContext)
|
|
89
79
|
: baseContext;
|
|
90
80
|
const data = await widget.getData({ params: block.params, context });
|
|
91
81
|
return widget.renderMarkdown({ data, params: block.params, context });
|
|
@@ -93,13 +83,7 @@ export class SsrMdRouter extends SsrRenderer {
|
|
|
93
83
|
catch (e) {
|
|
94
84
|
return widget.renderMarkdownError(e);
|
|
95
85
|
}
|
|
96
|
-
}, replaceWidgetBlocks);
|
|
86
|
+
}, replaceWidgetBlocks, 0, this.logger);
|
|
97
87
|
}
|
|
98
88
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Create SSR Markdown router.
|
|
101
|
-
*/
|
|
102
|
-
export function createSsrMdRouter(resolver, options) {
|
|
103
|
-
return new SsrMdRouter(resolver, options);
|
|
104
|
-
}
|
|
105
89
|
//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EAAE,OAAO,EAAE,CAAC,CAAC;YACxE,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,EACD,mBAAmB,EACnB,CAAC,EACD,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -4,36 +4,25 @@
|
|
|
4
4
|
* Abstract base class for server-side renderers.
|
|
5
5
|
* Provides the shared render() pipeline; subclasses supply format-specific rendering.
|
|
6
6
|
*/
|
|
7
|
-
import type { MatchedRoute, RouteConfig, RouteInfo } from '
|
|
8
|
-
import type { ComponentContext } from '
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import type
|
|
12
|
-
import type { WidgetRegistry } from '
|
|
13
|
-
/**
|
|
14
|
-
export interface SsrRendererOptions
|
|
15
|
-
/** Widget registry for server-side widget rendering */
|
|
7
|
+
import type { MatchedRoute, RouteConfig, RouteInfo } from '../type/route.type.ts';
|
|
8
|
+
import type { ComponentContext } from '../type/component.type.ts';
|
|
9
|
+
import type { Logger } from '../type/logger.type.ts';
|
|
10
|
+
import { type PageComponent } from '../component/page.component.ts';
|
|
11
|
+
import { type Pipeline } from '../pipeline/pipeline.ts';
|
|
12
|
+
import type { WidgetRegistry } from '../widget/widget.registry.ts';
|
|
13
|
+
/** Options for SSR renderers. */
|
|
14
|
+
export interface SsrRendererOptions {
|
|
16
15
|
widgets?: WidgetRegistry;
|
|
17
|
-
/** Widget companion file paths, keyed by widget name */
|
|
18
|
-
widgetFiles?: Record<string, {
|
|
19
|
-
html?: string;
|
|
20
|
-
md?: string;
|
|
21
|
-
css?: string;
|
|
22
|
-
}>;
|
|
23
16
|
}
|
|
24
17
|
/**
|
|
25
18
|
* Abstract SSR renderer with shared routing pipeline.
|
|
26
19
|
*/
|
|
27
20
|
export declare abstract class SsrRenderer {
|
|
28
|
-
protected
|
|
21
|
+
protected readonly pipeline: Pipeline;
|
|
29
22
|
protected widgets: WidgetRegistry | null;
|
|
30
|
-
protected widgetFiles: Record<string, {
|
|
31
|
-
html?: string;
|
|
32
|
-
md?: string;
|
|
33
|
-
css?: string;
|
|
34
|
-
}>;
|
|
35
23
|
protected abstract readonly label: string;
|
|
36
|
-
|
|
24
|
+
protected readonly logger: Logger;
|
|
25
|
+
constructor(pipeline: Pipeline, options?: SsrRendererOptions);
|
|
37
26
|
/**
|
|
38
27
|
* Render a URL to a content string.
|
|
39
28
|
*/
|
|
@@ -59,18 +48,13 @@ export declare abstract class SsrRenderer {
|
|
|
59
48
|
content: string;
|
|
60
49
|
title?: string;
|
|
61
50
|
}>;
|
|
62
|
-
/** Render a component to the output format (HTML or Markdown). */
|
|
63
51
|
protected abstract renderContent(component: PageComponent, args: PageComponent['RenderArgs']): string;
|
|
64
|
-
/** Render a component for error boundary/handler with minimal context. */
|
|
65
52
|
protected renderComponent(component: PageComponent, data: unknown, context: ComponentContext): string;
|
|
66
53
|
private static readonly EMPTY_URL;
|
|
67
|
-
/** Try to load and render an error boundary or handler module. Returns null on failure. */
|
|
68
54
|
private tryRenderErrorModule;
|
|
69
55
|
protected abstract renderRedirect(to: string): string;
|
|
70
56
|
protected abstract renderStatusPage(status: number, url: URL): string;
|
|
71
57
|
protected abstract renderErrorPage(error: unknown, url: URL): string;
|
|
72
|
-
/** Inject child content into the slot owned by parentPattern. */
|
|
73
58
|
protected abstract injectSlot(parent: string, child: string, parentPattern: string): string;
|
|
74
|
-
/** Strip all unconsumed slot placeholders from the final result. */
|
|
75
59
|
protected abstract stripSlots(result: string): string;
|
|
76
60
|
}
|