@ecopages/kitajs 0.2.1 → 0.3.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
@@ -5,31 +5,37 @@ Integration plugin for [KitaJS](https://kitajs.org/html/) HTML in Ecopages. Use
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- bunx jsr add @ecopages/kitajs
8
+ bun add @ecopages/kitajs @kitajs/html @kitajs/ts-html-plugin
9
9
  ```
10
10
 
11
+ `@kitajs/html` and `@kitajs/ts-html-plugin` are required peer dependencies for this package.
12
+
11
13
  ## Usage
12
14
 
13
15
  Import and register the `kitajsPlugin` in your `eco.config.ts`.
14
16
 
15
17
  ```ts
16
- import { ConfigBuilder } from '@ecopages/core/config-builder';
18
+ import { defineConfig } from '@ecopages/core/config';
17
19
  import { kitajsPlugin } from '@ecopages/kitajs';
18
20
 
19
- const config = await new ConfigBuilder()
20
- .setBaseUrl(import.meta.env.ECOPAGES_BASE_URL)
21
- .setIntegrations([kitajsPlugin()])
22
- .build();
23
-
24
- export default config;
21
+ export default defineConfig({ integrations: [kitajsPlugin()] });
25
22
  ```
26
23
 
27
24
  ## What This Integration Owns
28
25
 
29
26
  - `.kita.tsx` route files.
30
27
  - Page, layout, and document shells rendered by `@kitajs/html`.
31
- - HTML-first outer shells that host nested component boundaries from other integrations.
28
+ - HTML-first outer shells that host nested foreign subtrees from other integrations.
29
+
30
+ The default renderer uses core's `createIntegrationRenderer()` factory. Core owns the common route and document-shell pipeline; add hooks for Kita-specific behavior, and subclass only when the hook API cannot express a needed capability.
32
31
 
33
32
  ## Mixed Rendering
34
33
 
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.
34
+ Kita works well as the outer renderer in mixed apps. When a Kita-owned page encounters a nested foreign child from another integration, Ecopages resolves that foreign subtree with its owning renderer and inserts the resulting HTML back into the Kita shell.
35
+
36
+ Important:
37
+
38
+ - Components that may render foreign children must declare those children in `config.dependencies.components`.
39
+ - Ecopages validates mixed-renderer ownership from declared dependencies during render preparation instead of inferring every foreign child from rendered HTML.
40
+ - Route-level dependency resolvers can supply Components at request time; Kita includes those resolved roots through the shared string renderer when deciding whether a Foreign Subtree needs handoff.
41
+ - Kita remains an HTML-first outer shell. Same-integration Kita children do not go through a separate universal child serialization contract.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/kitajs",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Kitajs plugin for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -11,14 +11,31 @@
11
11
  "main": "./src/kitajs.plugin.js",
12
12
  "types": "./src/kitajs.plugin.d.ts",
13
13
  "type": "module",
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "default": "./src/kitajs.plugin.js",
20
+ "types": "./src/kitajs.plugin.d.ts"
21
+ },
22
+ "./eco-embed": {
23
+ "default": "./src/eco-embed.js",
24
+ "types": "./src/eco-embed.d.ts"
25
+ },
26
+ "./eco-embed.ts": {
27
+ "default": "./src/eco-embed.js",
28
+ "types": "./src/eco-embed.d.ts"
29
+ }
30
+ },
14
31
  "repository": {
15
32
  "type": "git",
16
- "url": "https://github.com/ecopages/ecopages.git",
33
+ "url": "git+https://github.com/ecopages/ecopages.git",
17
34
  "directory": "packages/integrations/kitajs"
18
35
  },
19
36
  "peerDependencies": {
20
- "@ecopages/core": "0.2.1",
37
+ "@ecopages/core": "0.3.1",
21
38
  "@kitajs/html": "^4.1.0",
22
39
  "@kitajs/ts-html-plugin": "^4.0.1"
23
40
  }
24
- }
41
+ }
@@ -0,0 +1,10 @@
1
+ import type { EcoComponent, EcoEmbedProps as CoreEcoEmbedProps, EcoPagesElement } from '@ecopages/core';
2
+ /**
3
+ * Props for the Kita-owned `EcoEmbed` adapter.
4
+ */
5
+ export type EcoEmbedProps<TComponent extends EcoComponent> = CoreEcoEmbedProps<TComponent>;
6
+ /**
7
+ * Renders a foreign or same-integration eco component from a Kita JSX file
8
+ * without forcing inline mixed-JSX authoring.
9
+ */
10
+ export declare function EcoEmbed<TComponent extends EcoComponent>({ component, props, children, }: EcoEmbedProps<TComponent>): EcoPagesElement;
@@ -0,0 +1,9 @@
1
+ /** @jsxImportSource @kitajs/html */
2
+ import { eco } from '@ecopages/core';
3
+ /**
4
+ * Renders a foreign or same-integration eco component from a Kita JSX file
5
+ * without forcing inline mixed-JSX authoring.
6
+ */
7
+ export function EcoEmbed({ component, props, children, }) {
8
+ return eco.embed(component, props, children);
9
+ }
@@ -2,24 +2,9 @@
2
2
  * This module contains the Kita.js renderer
3
3
  * @module
4
4
  */
5
- import type { ComponentRenderInput, ComponentRenderResult, EcoComponent, EcoPagesElement, IntegrationRendererRenderOptions, RouteRendererBody } from '@ecopages/core';
6
- import { IntegrationRenderer, type RenderToResponseContext } from '@ecopages/core/route-renderer/integration-renderer';
7
5
  /**
8
- * A renderer for the Kita.js integration.
9
- * It renders a page using the HtmlTemplate and Page components.
6
+ * A renderer for the Kita.js integration, backed by core's shared route pipeline.
10
7
  */
11
- export declare class KitaRenderer extends IntegrationRenderer<EcoPagesElement> {
8
+ export declare const KitaRenderer: new (options: import("@ecopages/core/integration").IntegrationRendererOptions) => import("@ecopages/core/integration").IntegrationRenderer<import("@ecopages/core").EcoPagesElement> & {
12
9
  name: string;
13
- /**
14
- * Renders a Kita component boundary for component-level orchestration.
15
- *
16
- * Includes component-scoped dependency assets when declared.
17
- */
18
- renderComponent(input: ComponentRenderInput): Promise<ComponentRenderResult>;
19
- protected createComponentBoundaryRuntime(options: {
20
- boundaryInput: ComponentRenderInput;
21
- rendererCache: Map<string, IntegrationRenderer<any>>;
22
- }): import("@ecopages/core").ComponentBoundaryRuntime;
23
- render({ params, query, props, locals, pageLocals, metadata, Page, Layout, HtmlTemplate, }: IntegrationRendererRenderOptions): Promise<RouteRendererBody>;
24
- renderToResponse<P = Record<string, unknown>>(view: EcoComponent<P>, props: P, ctx: RenderToResponseContext): Promise<Response>;
25
- }
10
+ };
@@ -1,66 +1,10 @@
1
- import { IntegrationRenderer } from "@ecopages/core/route-renderer/integration-renderer";
2
- import { PLUGIN_NAME } from "./kitajs.plugin.js";
3
- class KitaRenderer extends IntegrationRenderer {
4
- name = PLUGIN_NAME;
5
- /**
6
- * Renders a Kita component boundary for component-level orchestration.
7
- *
8
- * Includes component-scoped dependency assets when declared.
9
- */
10
- async renderComponent(input) {
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
- });
21
- }
22
- async render({
23
- params,
24
- query,
25
- props,
26
- locals,
27
- pageLocals,
28
- metadata,
29
- Page,
30
- Layout,
31
- HtmlTemplate
32
- }) {
33
- try {
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,
44
- metadata,
45
- pageProps: props ?? {}
46
- });
47
- } catch (error) {
48
- throw this.createRenderError("Error rendering page", error);
49
- }
50
- }
51
- async renderToResponse(view, props, ctx) {
52
- try {
53
- return await this.renderViewWithDocumentShell({
54
- view,
55
- props,
56
- ctx,
57
- layout: view.config?.layout
58
- });
59
- } catch (error) {
60
- throw this.createRenderError("Error rendering view", error);
61
- }
62
- }
63
- }
64
- export {
65
- KitaRenderer
66
- };
1
+ /**
2
+ * This module contains the Kita.js renderer
3
+ * @module
4
+ */
5
+ import { createIntegrationRenderer } from '@ecopages/core/integration';
6
+ import { KITAJS_PLUGIN_NAME } from './kitajs.constants.js';
7
+ /**
8
+ * A renderer for the Kita.js integration, backed by core's shared route pipeline.
9
+ */
10
+ export const KitaRenderer = createIntegrationRenderer(KITAJS_PLUGIN_NAME);
@@ -0,0 +1 @@
1
+ export declare const KITAJS_PLUGIN_NAME = "kitajs";
@@ -0,0 +1 @@
1
+ export const KITAJS_PLUGIN_NAME = 'kitajs';
@@ -1,20 +1,8 @@
1
- import { IntegrationPlugin, type IntegrationPluginConfig } from '@ecopages/core/plugins/integration-plugin';
2
- import { KitaRenderer } from './kitajs-renderer.js';
1
+ import { type DefinedIntegration } from '@ecopages/core/integration';
3
2
  /**
4
3
  * The name of the Kita.js plugin
5
4
  */
6
5
  export declare const PLUGIN_NAME = "kitajs";
7
- /**
8
- * The Kita.js plugin class
9
- * This plugin provides support for Kita.js components in Ecopages
10
- */
11
- export declare class KitaHtmlPlugin extends IntegrationPlugin {
12
- renderer: typeof KitaRenderer;
13
- constructor(options?: Omit<IntegrationPluginConfig, 'name'>);
14
- }
15
- /**
16
- * Factory function to create a Kita.js plugin instance.
17
- * @param options Configuration options for the Kita.js plugin
18
- * @returns A new KitaHtmlPlugin instance
19
- */
20
- export declare function kitajsPlugin(options?: Omit<IntegrationPluginConfig, 'name'>): KitaHtmlPlugin;
6
+ export declare const kitajsPlugin: DefinedIntegration;
7
+ /** @deprecated Use {@link kitajsPlugin.Plugin} or {@link kitajsPlugin} instead. */
8
+ export declare const KitaHtmlPlugin: new (options?: Omit<import("@ecopages/core/integration").IntegrationPluginConfig, "name">) => import("@ecopages/core/integration").IntegrationPlugin<import("@ecopages/core").EcoPagesElement>;
@@ -1,22 +1,15 @@
1
- import { IntegrationPlugin } from "@ecopages/core/plugins/integration-plugin";
2
- import { KitaRenderer } from "./kitajs-renderer.js";
3
- const PLUGIN_NAME = "kitajs";
4
- class KitaHtmlPlugin extends IntegrationPlugin {
5
- renderer = KitaRenderer;
6
- constructor(options) {
7
- super({
8
- name: PLUGIN_NAME,
9
- extensions: [".kita.tsx"],
10
- jsxImportSource: "@kitajs/html",
11
- ...options
12
- });
13
- }
14
- }
15
- function kitajsPlugin(options) {
16
- return new KitaHtmlPlugin(options);
17
- }
18
- export {
19
- KitaHtmlPlugin,
20
- PLUGIN_NAME,
21
- kitajsPlugin
22
- };
1
+ import { defineIntegration } from '@ecopages/core/integration';
2
+ import { KitaRenderer } from './kitajs-renderer.js';
3
+ import { KITAJS_PLUGIN_NAME } from './kitajs.constants.js';
4
+ /**
5
+ * The name of the Kita.js plugin
6
+ */
7
+ export const PLUGIN_NAME = KITAJS_PLUGIN_NAME;
8
+ export const kitajsPlugin = defineIntegration({
9
+ name: PLUGIN_NAME,
10
+ extensions: ['.kita.tsx'],
11
+ jsxImportSource: '@kitajs/html',
12
+ renderer: KitaRenderer,
13
+ });
14
+ /** @deprecated Use {@link kitajsPlugin.Plugin} or {@link kitajsPlugin} instead. */
15
+ export const KitaHtmlPlugin = kitajsPlugin.Plugin;
package/CHANGELOG.md DELETED
@@ -1,19 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to `@ecopages/kitajs` are documented here.
4
-
5
- > **Note:** Changelog tracking begins at version `0.2.0`. Changes prior to this release are not recorded here but are available in the git history.
6
-
7
- ## [0.2.1] — 2026-04-16
8
-
9
- ### Bug Fixes
10
-
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
-
13
- ### Documentation
14
-
15
- - Updated the README to document `.kita.tsx` route ownership and Kita's role as an outer shell in mixed-renderer apps.
16
-
17
- ### Tests
18
-
19
- - Updated integration coverage for explicit boundary composition and Node and esbuild compatibility.