@ecopages/kitajs 0.2.0-alpha.12 → 0.2.0-alpha.14
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 +4 -8
- package/README.md +11 -1
- package/package.json +2 -2
- package/src/kitajs-renderer.d.ts +4 -0
- package/src/kitajs-renderer.js +25 -52
- package/src/kitajs.plugin.d.ts +1 -2
- package/src/kitajs.plugin.js +1 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,16 +8,12 @@ All notable changes to `@ecopages/kitajs` are documented here.
|
|
|
8
8
|
|
|
9
9
|
### Bug Fixes
|
|
10
10
|
|
|
11
|
-
- Fixed direct `ctx.render()`
|
|
11
|
+
- Fixed Kita full-route and direct `ctx.render()` rendering to stay on the renderer-owned page/layout/document path while resolving mixed boundaries inside the owning renderer.
|
|
12
12
|
|
|
13
|
-
###
|
|
13
|
+
### Documentation
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
### Refactoring
|
|
18
|
-
|
|
19
|
-
- Tightened Kita component typing and cleaned up ambient module declarations.
|
|
15
|
+
- Updated the README to document `.kita.tsx` route ownership and Kita's role as an outer shell in mixed-renderer apps.
|
|
20
16
|
|
|
21
17
|
### Tests
|
|
22
18
|
|
|
23
|
-
- Updated integration coverage for
|
|
19
|
+
- Updated integration coverage for explicit boundary composition and Node and esbuild compatibility.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ecopages/kitajs
|
|
2
2
|
|
|
3
|
-
Integration plugin for [KitaJS](https://kitajs.org/html/) HTML
|
|
3
|
+
Integration plugin for [KitaJS](https://kitajs.org/html/) HTML in Ecopages. Use it when Kita should own `.kita.tsx` routes, page shells, and document shells in HTML-first apps.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -23,3 +23,13 @@ const config = await new ConfigBuilder()
|
|
|
23
23
|
|
|
24
24
|
export default config;
|
|
25
25
|
```
|
|
26
|
+
|
|
27
|
+
## What This Integration Owns
|
|
28
|
+
|
|
29
|
+
- `.kita.tsx` route files.
|
|
30
|
+
- Page, layout, and document shells rendered by `@kitajs/html`.
|
|
31
|
+
- HTML-first outer shells that host nested component boundaries from other integrations.
|
|
32
|
+
|
|
33
|
+
## Mixed Rendering
|
|
34
|
+
|
|
35
|
+
Kita works well as the outer renderer in mixed apps. When a Kita-owned page encounters a nested boundary from another integration, Ecopages resolves that boundary with its owning renderer and inserts the resulting HTML back into the Kita shell.
|
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.14",
|
|
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.14",
|
|
21
21
|
"@kitajs/html": "^4.1.0",
|
|
22
22
|
"@kitajs/ts-html-plugin": "^4.0.1"
|
|
23
23
|
}
|
package/src/kitajs-renderer.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export declare class KitaRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
|
16
16
|
* Includes component-scoped dependency assets when declared.
|
|
17
17
|
*/
|
|
18
18
|
renderComponent(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
19
|
+
protected createComponentBoundaryRuntime(options: {
|
|
20
|
+
boundaryInput: ComponentRenderInput;
|
|
21
|
+
rendererCache: Map<string, IntegrationRenderer<any>>;
|
|
22
|
+
}): import("@ecopages/core").ComponentBoundaryRuntime;
|
|
19
23
|
render({ params, query, props, locals, pageLocals, metadata, Page, Layout, HtmlTemplate, }: IntegrationRendererRenderOptions): Promise<RouteRendererBody>;
|
|
20
24
|
renderToResponse<P = Record<string, unknown>>(view: EcoComponent<P>, props: P, ctx: RenderToResponseContext): Promise<Response>;
|
|
21
25
|
}
|
package/src/kitajs-renderer.js
CHANGED
|
@@ -8,20 +8,16 @@ class KitaRenderer extends IntegrationRenderer {
|
|
|
8
8
|
* Includes component-scoped dependency assets when declared.
|
|
9
9
|
*/
|
|
10
10
|
async renderComponent(input) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
rootTag: this.getRootTagName(html),
|
|
22
|
-
integrationName: this.name,
|
|
23
|
-
assets
|
|
24
|
-
};
|
|
11
|
+
return this.renderStringComponentBoundaryWithQueuedForeignBoundaries(
|
|
12
|
+
input,
|
|
13
|
+
input.component
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
createComponentBoundaryRuntime(options) {
|
|
17
|
+
return this.createQueuedBoundaryRuntime({
|
|
18
|
+
boundaryInput: options.boundaryInput,
|
|
19
|
+
rendererCache: options.rendererCache
|
|
20
|
+
});
|
|
25
21
|
}
|
|
26
22
|
async render({
|
|
27
23
|
params,
|
|
@@ -35,54 +31,31 @@ class KitaRenderer extends IntegrationRenderer {
|
|
|
35
31
|
HtmlTemplate
|
|
36
32
|
}) {
|
|
37
33
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
return await this.renderPageWithDocumentShell({
|
|
35
|
+
page: {
|
|
36
|
+
component: Page,
|
|
37
|
+
props: { params, query, ...props, locals: pageLocals }
|
|
38
|
+
},
|
|
39
|
+
layout: Layout ? {
|
|
40
|
+
component: Layout,
|
|
41
|
+
props: locals ? { locals } : {}
|
|
42
|
+
} : void 0,
|
|
43
|
+
htmlTemplate: HtmlTemplate,
|
|
42
44
|
metadata,
|
|
43
|
-
pageProps: props ?? {}
|
|
44
|
-
children
|
|
45
|
+
pageProps: props ?? {}
|
|
45
46
|
});
|
|
46
|
-
return this.DOC_TYPE + body;
|
|
47
47
|
} catch (error) {
|
|
48
48
|
throw this.createRenderError("Error rendering page", error);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
async renderToResponse(view, props, ctx) {
|
|
52
52
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const metadata = ctx.partial || !HtmlTemplate ? void 0 : view.metadata ? await view.metadata({
|
|
56
|
-
params: {},
|
|
57
|
-
query: {},
|
|
53
|
+
return await this.renderViewWithDocumentShell({
|
|
54
|
+
view,
|
|
58
55
|
props,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!ctx.partial) {
|
|
62
|
-
await this.prepareViewDependencies(view, Layout);
|
|
63
|
-
}
|
|
64
|
-
const viewFn = view;
|
|
65
|
-
const renderExecution = await this.captureHtmlRender(async () => {
|
|
66
|
-
const pageContent = await viewFn(props);
|
|
67
|
-
const pageHtml = String(pageContent);
|
|
68
|
-
if (ctx.partial) {
|
|
69
|
-
return pageHtml;
|
|
70
|
-
}
|
|
71
|
-
const children = Layout ? await Layout({ children: pageHtml }) : pageHtml;
|
|
72
|
-
return this.DOC_TYPE + await HtmlTemplate({
|
|
73
|
-
metadata: metadata ?? this.appConfig.defaultMetadata,
|
|
74
|
-
pageProps: props ?? {},
|
|
75
|
-
children: children ?? ""
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
const componentsToResolve = ctx.partial ? [view] : [HtmlTemplate, Layout, view].filter(Boolean);
|
|
79
|
-
const body = await this.finalizeCapturedHtmlRender({
|
|
80
|
-
html: renderExecution.html,
|
|
81
|
-
componentsToResolve,
|
|
82
|
-
graphContext: renderExecution.graphContext,
|
|
83
|
-
partial: ctx.partial
|
|
56
|
+
ctx,
|
|
57
|
+
layout: view.config?.layout
|
|
84
58
|
});
|
|
85
|
-
return this.createHtmlResponse(body, ctx);
|
|
86
59
|
} catch (error) {
|
|
87
60
|
throw this.createRenderError("Error rendering view", error);
|
|
88
61
|
}
|
package/src/kitajs.plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationPlugin, type
|
|
1
|
+
import { IntegrationPlugin, type IntegrationPluginConfig } from '@ecopages/core/plugins/integration-plugin';
|
|
2
2
|
import { KitaRenderer } from './kitajs-renderer.js';
|
|
3
3
|
/**
|
|
4
4
|
* The name of the Kita.js plugin
|
|
@@ -11,7 +11,6 @@ export declare const PLUGIN_NAME = "kitajs";
|
|
|
11
11
|
export declare class KitaHtmlPlugin extends IntegrationPlugin {
|
|
12
12
|
renderer: typeof KitaRenderer;
|
|
13
13
|
constructor(options?: Omit<IntegrationPluginConfig, 'name'>);
|
|
14
|
-
shouldDeferComponentBoundary(input: ComponentBoundaryPolicyInput): boolean;
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
16
|
* Factory function to create a Kita.js plugin instance.
|
package/src/kitajs.plugin.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IntegrationPlugin
|
|
3
|
-
} from "@ecopages/core/plugins/integration-plugin";
|
|
1
|
+
import { IntegrationPlugin } from "@ecopages/core/plugins/integration-plugin";
|
|
4
2
|
import { KitaRenderer } from "./kitajs-renderer.js";
|
|
5
3
|
const PLUGIN_NAME = "kitajs";
|
|
6
4
|
class KitaHtmlPlugin extends IntegrationPlugin {
|
|
@@ -13,9 +11,6 @@ class KitaHtmlPlugin extends IntegrationPlugin {
|
|
|
13
11
|
...options
|
|
14
12
|
});
|
|
15
13
|
}
|
|
16
|
-
shouldDeferComponentBoundary(input) {
|
|
17
|
-
return input.targetIntegration === this.name && input.currentIntegration !== this.name;
|
|
18
|
-
}
|
|
19
14
|
}
|
|
20
15
|
function kitajsPlugin(options) {
|
|
21
16
|
return new KitaHtmlPlugin(options);
|