@ecopages/kitajs 0.2.0-alpha.5 → 0.2.0-alpha.7

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 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 renderer with full orchestration mode — removed legacy rendering path (`fc07bdb0`).
15
+ - Aligned KitaJS with the unified orchestration pipeline.
12
16
 
13
17
  ### Refactoring
14
18
 
15
- - **Type safety improvements** — Enhanced type safety for component signatures; test component creation helpers are now more accurately typed (`574657eb`).
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 tests to align with the new orchestration model.
23
+ - Updated integration coverage for the orchestration pipeline and Node and esbuild compatibility.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Ecopages KitaJs Integration Plugin
1
+ # @ecopages/kitajs
2
2
 
3
- The `@ecopages/kitajs` package provides seamless integration with [Kita](https://kitajs.org/html/), enabling effortless rendering of JSX templates. This integration represents a minimalistic layer within the broader Ecopages integration plugin system, designed to enhance the platform's flexibility and ease of use.
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
- ## Install
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
- Incorporating this integration into your project is straightforward. Simply import and include the `kitajsPlugin` in your Ecopages configuration as shown below:
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.5",
3
+ "version": "0.2.0-alpha.7",
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.5",
20
+ "@ecopages/core": "0.2.0-alpha.7",
21
21
  "@kitajs/html": "^4.1.0",
22
22
  "@kitajs/ts-html-plugin": "^4.0.1"
23
23
  }
@@ -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 viewFn = view;
54
- const pageContent = await viewFn(props);
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
- await this.prepareViewDependencies(view, Layout);
67
- const html = this.DOC_TYPE + await HtmlTemplate({
68
- metadata,
69
- pageProps: props,
70
- children: children ?? ""
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
- const transformedResponse = await this.htmlTransformer.transform(
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
  }
@@ -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 viewFn = view as KitaViewFn<P>;
92
- const pageContent = await viewFn(props);
93
-
94
- if (ctx.partial) {
95
- return this.createHtmlResponse(pageContent, ctx);
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 children = Layout ? await Layout({ children: pageContent }) : pageContent;
99
-
100
- const HtmlTemplate = await this.getHtmlTemplate();
101
- const metadata = view.metadata
102
- ? await view.metadata({
103
- params: {},
104
- query: {},
105
- props: props as Record<string, unknown>,
106
- appConfig: this.appConfig,
107
- })
108
- : this.appConfig.defaultMetadata;
109
- await this.prepareViewDependencies(view, Layout as EcoComponent | undefined);
110
-
111
- const html =
112
- this.DOC_TYPE +
113
- (await HtmlTemplate({
114
- metadata,
115
- pageProps: props as Record<string, unknown>,
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 transformedResponse = await this.htmlTransformer.transform(
120
- new Response(html, {
121
- headers: { 'Content-Type': 'text/html' },
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(transformedResponse.body ?? '', ctx);
136
+ return this.createHtmlResponse(body, ctx);
126
137
  } catch (error) {
127
138
  throw this.createRenderError('Error rendering view', error);
128
139
  }