@ecopages/kitajs 0.2.1-beta.0 → 0.3.0

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
@@ -15,15 +15,10 @@ bun add @ecopages/kitajs @kitajs/html @kitajs/ts-html-plugin
15
15
  Import and register the `kitajsPlugin` in your `eco.config.ts`.
16
16
 
17
17
  ```ts
18
- import { ConfigBuilder } from '@ecopages/core/config-builder';
18
+ import { defineConfig } from '@ecopages/core/config';
19
19
  import { kitajsPlugin } from '@ecopages/kitajs';
20
20
 
21
- const config = await new ConfigBuilder()
22
- .setBaseUrl(import.meta.env.ECOPAGES_BASE_URL)
23
- .setIntegrations([kitajsPlugin()])
24
- .build();
25
-
26
- export default config;
21
+ export default defineConfig({ integrations: [kitajsPlugin()] });
27
22
  ```
28
23
 
29
24
  ## What This Integration Owns
@@ -32,6 +27,8 @@ export default config;
32
27
  - Page, layout, and document shells rendered by `@kitajs/html`.
33
28
  - HTML-first outer shells that host nested foreign subtrees from other integrations.
34
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.
31
+
35
32
  ## Mixed Rendering
36
33
 
37
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.
@@ -40,4 +37,5 @@ Important:
40
37
 
41
38
  - Components that may render foreign children must declare those children in `config.dependencies.components`.
42
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.
43
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-beta.0",
3
+ "version": "0.3.0",
4
4
  "description": "Kitajs plugin for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -11,6 +11,9 @@
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
+ },
14
17
  "exports": {
15
18
  ".": {
16
19
  "default": "./src/kitajs.plugin.js",
@@ -27,12 +30,12 @@
27
30
  },
28
31
  "repository": {
29
32
  "type": "git",
30
- "url": "https://github.com/ecopages/ecopages.git",
33
+ "url": "git+https://github.com/ecopages/ecopages.git",
31
34
  "directory": "packages/integrations/kitajs"
32
35
  },
33
36
  "peerDependencies": {
34
- "@ecopages/core": "0.2.1-beta.0",
37
+ "@ecopages/core": "0.3.0",
35
38
  "@kitajs/html": "^4.1.0",
36
39
  "@kitajs/ts-html-plugin": "^4.0.1"
37
40
  }
38
- }
41
+ }
package/src/eco-embed.js CHANGED
@@ -1,11 +1,9 @@
1
- import { eco } from "@ecopages/core";
2
- function EcoEmbed({
3
- component,
4
- props,
5
- children
6
- }) {
7
- return eco.embed(component, props, children);
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);
8
9
  }
9
- export {
10
- EcoEmbed
11
- };
@@ -2,21 +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
- private isFunctionComponent;
14
- /**
15
- * Renders a Kita-owned foreign subtree for component-level orchestration.
16
- *
17
- * Includes component-scoped dependency assets when declared.
18
- */
19
- renderComponent(input: ComponentRenderInput): Promise<ComponentRenderResult>;
20
- render({ params, query, props, locals, pageLocals, metadata, Page, Layout, HtmlTemplate, }: IntegrationRendererRenderOptions): Promise<RouteRendererBody>;
21
- renderToResponse<P = Record<string, unknown>>(view: EcoComponent<P>, props: P, ctx: RenderToResponseContext): Promise<Response>;
22
- }
10
+ };
@@ -1,63 +1,10 @@
1
- import { IntegrationRenderer } from "@ecopages/core/route-renderer/integration-renderer";
2
- import { KITAJS_PLUGIN_NAME } from "./kitajs.constants.js";
3
- class KitaRenderer extends IntegrationRenderer {
4
- name = KITAJS_PLUGIN_NAME;
5
- isFunctionComponent(component) {
6
- return typeof component === "function";
7
- }
8
- /**
9
- * Renders a Kita-owned foreign subtree for component-level orchestration.
10
- *
11
- * Includes component-scoped dependency assets when declared.
12
- */
13
- async renderComponent(input) {
14
- if (!this.isFunctionComponent(input.component)) {
15
- throw new TypeError("Kita renderer expected a callable component.");
16
- }
17
- return this.renderStringComponentWithQueuedForeignSubtrees(input, input.component);
18
- }
19
- async render({
20
- params,
21
- query,
22
- props,
23
- locals,
24
- pageLocals,
25
- metadata,
26
- Page,
27
- Layout,
28
- HtmlTemplate
29
- }) {
30
- try {
31
- return await this.renderPageWithDocumentShell({
32
- page: {
33
- component: Page,
34
- props: { params, query, ...props, locals: pageLocals }
35
- },
36
- layout: Layout ? {
37
- component: Layout,
38
- props: locals ? { locals } : {}
39
- } : void 0,
40
- htmlTemplate: HtmlTemplate,
41
- metadata,
42
- pageProps: props ?? {}
43
- });
44
- } catch (error) {
45
- throw this.createRenderError("Error rendering page", error);
46
- }
47
- }
48
- async renderToResponse(view, props, ctx) {
49
- try {
50
- return await this.renderViewWithDocumentShell({
51
- view,
52
- props,
53
- ctx,
54
- layout: view.config?.layout
55
- });
56
- } catch (error) {
57
- throw this.createRenderError("Error rendering view", error);
58
- }
59
- }
60
- }
61
- export {
62
- KitaRenderer
63
- };
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);
@@ -1,4 +1 @@
1
- const KITAJS_PLUGIN_NAME = "kitajs";
2
- export {
3
- KITAJS_PLUGIN_NAME
4
- };
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,23 +1,15 @@
1
- import { IntegrationPlugin } from "@ecopages/core/plugins/integration-plugin";
2
- import { KitaRenderer } from "./kitajs-renderer.js";
3
- import { KITAJS_PLUGIN_NAME } from "./kitajs.constants.js";
4
- const PLUGIN_NAME = KITAJS_PLUGIN_NAME;
5
- class KitaHtmlPlugin extends IntegrationPlugin {
6
- renderer = KitaRenderer;
7
- constructor(options) {
8
- super({
9
- name: PLUGIN_NAME,
10
- extensions: [".kita.tsx"],
11
- jsxImportSource: "@kitajs/html",
12
- ...options
13
- });
14
- }
15
- }
16
- function kitajsPlugin(options) {
17
- return new KitaHtmlPlugin(options);
18
- }
19
- export {
20
- KitaHtmlPlugin,
21
- PLUGIN_NAME,
22
- kitajsPlugin
23
- };
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;