@ecopages/kitajs 0.2.0-alpha.5 → 0.2.0-alpha.8
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/CHANGELOG.md +7 -5
- package/README.md +5 -5
- package/package.json +2 -2
- package/src/kitajs-renderer.js +25 -19
- package/src/kitajs-renderer.ts +43 -32
package/CHANGELOG.md
CHANGED
|
@@ -6,16 +6,18 @@ All notable changes to `@ecopages/kitajs` are documented here.
|
|
|
6
6
|
|
|
7
7
|
## [UNRELEASED] — TBD
|
|
8
8
|
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- Fixed explicit `ctx.render()` flows so deferred cross-integration layout components resolve through the marker pipeline instead of crashing during direct server rendering.
|
|
12
|
+
|
|
9
13
|
### Features
|
|
10
14
|
|
|
11
|
-
- Aligned KitaJS
|
|
15
|
+
- Aligned KitaJS with the unified orchestration pipeline.
|
|
12
16
|
|
|
13
17
|
### Refactoring
|
|
14
18
|
|
|
15
|
-
-
|
|
16
|
-
- Ambient module declarations cleaned up (`5f46ecc5`).
|
|
17
|
-
- Updated test suite for esbuild adapter and Node.js runtime compatibility (`31a44458`).
|
|
19
|
+
- Tightened Kita component typing and cleaned up ambient module declarations.
|
|
18
20
|
|
|
19
21
|
### Tests
|
|
20
22
|
|
|
21
|
-
- Updated integration
|
|
23
|
+
- Updated integration coverage for the orchestration pipeline and Node and esbuild compatibility.
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ecopages/kitajs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Integration plugin for [KitaJS](https://kitajs.org/html/) HTML within the Ecopages framework. It enables the rendering of standard JSX templates for multi-page applications.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
bunx jsr add @ecopages/kitajs
|
|
@@ -10,10 +10,10 @@ bunx jsr add @ecopages/kitajs
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Import and register the `kitajsPlugin` in your `eco.config.ts`.
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import { ConfigBuilder } from '@ecopages/core';
|
|
16
|
+
import { ConfigBuilder } from '@ecopages/core/config-builder';
|
|
17
17
|
import { kitajsPlugin } from '@ecopages/kitajs';
|
|
18
18
|
|
|
19
19
|
const config = await new ConfigBuilder()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/kitajs",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.8",
|
|
4
4
|
"description": "Kitajs plugin for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"directory": "packages/integrations/kitajs"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@ecopages/core": "0.2.0-alpha.
|
|
20
|
+
"@ecopages/core": "0.2.0-alpha.8",
|
|
21
21
|
"@kitajs/html": "^4.1.0",
|
|
22
22
|
"@kitajs/ts-html-plugin": "^4.0.1"
|
|
23
23
|
}
|
package/src/kitajs-renderer.js
CHANGED
|
@@ -50,31 +50,37 @@ class KitaRenderer extends IntegrationRenderer {
|
|
|
50
50
|
async renderToResponse(view, props, ctx) {
|
|
51
51
|
try {
|
|
52
52
|
const Layout = view.config?.layout;
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
if (ctx.partial) {
|
|
56
|
-
return this.createHtmlResponse(pageContent, ctx);
|
|
57
|
-
}
|
|
58
|
-
const children = Layout ? await Layout({ children: pageContent }) : pageContent;
|
|
59
|
-
const HtmlTemplate = await this.getHtmlTemplate();
|
|
60
|
-
const metadata = view.metadata ? await view.metadata({
|
|
53
|
+
const HtmlTemplate = ctx.partial ? void 0 : await this.getHtmlTemplate();
|
|
54
|
+
const metadata = ctx.partial || !HtmlTemplate ? void 0 : view.metadata ? await view.metadata({
|
|
61
55
|
params: {},
|
|
62
56
|
query: {},
|
|
63
57
|
props,
|
|
64
58
|
appConfig: this.appConfig
|
|
65
59
|
}) : this.appConfig.defaultMetadata;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
if (!ctx.partial) {
|
|
61
|
+
await this.prepareViewDependencies(view, Layout);
|
|
62
|
+
}
|
|
63
|
+
const viewFn = view;
|
|
64
|
+
const renderExecution = await this.captureHtmlRender(async () => {
|
|
65
|
+
const pageContent = await viewFn(props);
|
|
66
|
+
if (ctx.partial) {
|
|
67
|
+
return pageContent;
|
|
68
|
+
}
|
|
69
|
+
const children = Layout ? await Layout({ children: pageContent }) : pageContent;
|
|
70
|
+
return this.DOC_TYPE + await HtmlTemplate({
|
|
71
|
+
metadata: metadata ?? this.appConfig.defaultMetadata,
|
|
72
|
+
pageProps: props ?? {},
|
|
73
|
+
children: children ?? ""
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
const componentsToResolve = ctx.partial ? [view] : [HtmlTemplate, Layout, view].filter(Boolean);
|
|
77
|
+
const body = await this.finalizeCapturedHtmlRender({
|
|
78
|
+
html: renderExecution.html,
|
|
79
|
+
componentsToResolve,
|
|
80
|
+
graphContext: renderExecution.graphContext,
|
|
81
|
+
partial: ctx.partial
|
|
71
82
|
});
|
|
72
|
-
|
|
73
|
-
new Response(html, {
|
|
74
|
-
headers: { "Content-Type": "text/html" }
|
|
75
|
-
})
|
|
76
|
-
);
|
|
77
|
-
return this.createHtmlResponse(transformedResponse.body ?? "", ctx);
|
|
83
|
+
return this.createHtmlResponse(body, ctx);
|
|
78
84
|
} catch (error) {
|
|
79
85
|
throw this.createRenderError("Error rendering view", error);
|
|
80
86
|
}
|
package/src/kitajs-renderer.ts
CHANGED
|
@@ -87,42 +87,53 @@ export class KitaRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
|
87
87
|
): Promise<Response> {
|
|
88
88
|
try {
|
|
89
89
|
const Layout = view.config?.layout as KitaLayoutFn | undefined;
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
const HtmlTemplate = ctx.partial ? undefined : await this.getHtmlTemplate();
|
|
91
|
+
const metadata =
|
|
92
|
+
ctx.partial || !HtmlTemplate
|
|
93
|
+
? undefined
|
|
94
|
+
: view.metadata
|
|
95
|
+
? await view.metadata({
|
|
96
|
+
params: {},
|
|
97
|
+
query: {},
|
|
98
|
+
props: props as Record<string, unknown>,
|
|
99
|
+
appConfig: this.appConfig,
|
|
100
|
+
})
|
|
101
|
+
: this.appConfig.defaultMetadata;
|
|
102
|
+
|
|
103
|
+
if (!ctx.partial) {
|
|
104
|
+
await this.prepareViewDependencies(view, Layout as EcoComponent | undefined);
|
|
96
105
|
}
|
|
97
106
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
children: children ?? '',
|
|
117
|
-
}));
|
|
107
|
+
const viewFn = view as KitaViewFn<P>;
|
|
108
|
+
const renderExecution = await this.captureHtmlRender(async () => {
|
|
109
|
+
const pageContent = await viewFn(props);
|
|
110
|
+
|
|
111
|
+
if (ctx.partial) {
|
|
112
|
+
return pageContent;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const children = Layout ? await Layout({ children: pageContent }) : pageContent;
|
|
116
|
+
return (
|
|
117
|
+
this.DOC_TYPE +
|
|
118
|
+
(await HtmlTemplate!({
|
|
119
|
+
metadata: metadata ?? this.appConfig.defaultMetadata,
|
|
120
|
+
pageProps: (props as Record<string, unknown>) ?? {},
|
|
121
|
+
children: children ?? '',
|
|
122
|
+
}))
|
|
123
|
+
);
|
|
124
|
+
});
|
|
118
125
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
const componentsToResolve = ctx.partial
|
|
127
|
+
? [view]
|
|
128
|
+
: ([HtmlTemplate, Layout, view].filter(Boolean) as EcoComponent[]);
|
|
129
|
+
const body = await this.finalizeCapturedHtmlRender({
|
|
130
|
+
html: renderExecution.html,
|
|
131
|
+
componentsToResolve,
|
|
132
|
+
graphContext: renderExecution.graphContext,
|
|
133
|
+
partial: ctx.partial,
|
|
134
|
+
});
|
|
124
135
|
|
|
125
|
-
return this.createHtmlResponse(
|
|
136
|
+
return this.createHtmlResponse(body, ctx);
|
|
126
137
|
} catch (error) {
|
|
127
138
|
throw this.createRenderError('Error rendering view', error);
|
|
128
139
|
}
|