@ecopages/mdx 0.2.0-alpha.26 → 0.2.0-alpha.28

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
@@ -12,8 +12,8 @@ All notable changes to `@ecopages/mdx` are documented here.
12
12
 
13
13
  ### Bug Fixes
14
14
 
15
- - Fixed loader registration, Node `source-map` interop, and renderer-owned mixed-boundary rendering for standalone MDX routes.
16
- - Fixed standalone MDX boundary payload compatibility coverage and removed the plugin/renderer integration-name import cycle.
15
+ - Fixed loader registration, Node `source-map` interop, and renderer-owned mixed foreign-subtree rendering for standalone MDX routes.
16
+ - Fixed standalone MDX foreign-subtree payload compatibility coverage and removed the plugin/renderer integration-name import cycle.
17
17
 
18
18
  ### Documentation
19
19
 
@@ -21,7 +21,7 @@ All notable changes to `@ecopages/mdx` are documented here.
21
21
 
22
22
  ### Tests
23
23
 
24
- - Added renderer-level coverage for the boundary payload compatibility contract.
24
+ - Added renderer-level coverage for the foreign-subtree payload compatibility contract.
25
25
 
26
26
  ### Refactoring
27
27
 
package/README.md CHANGED
@@ -5,9 +5,11 @@ Integration plugin for standalone MDX support in Ecopages for non-React JSX runt
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- bun add @ecopages/mdx
8
+ bun add @ecopages/mdx @kitajs/html @mdx-js/mdx
9
9
  ```
10
10
 
11
+ `@kitajs/html` and `@mdx-js/mdx` are required peer dependencies for this package.
12
+
11
13
  ## Usage
12
14
 
13
15
  Import and apply the `mdxPlugin` in your `eco.config.ts`:
@@ -67,12 +69,12 @@ mdxPlugin({
67
69
 
68
70
  ## Mixed Rendering
69
71
 
70
- Standalone MDX can own the page shell or nested MDX component boundaries in a mixed-renderer app. When another integration reaches an MDX-owned boundary, Ecopages hands that boundary back to the MDX renderer so the MDX runtime can finish serialization before the outer renderer resumes.
72
+ Standalone MDX can own the page shell or nested MDX foreign subtrees in a mixed-renderer app. When another integration reaches an MDX-owned foreign child, Ecopages hands that foreign subtree back to the MDX renderer so the MDX runtime can finish serialization before the outer renderer resumes.
71
73
 
72
74
  Important:
73
75
 
74
76
  - Components that may render foreign children must declare those children in `config.dependencies.components`.
75
- - Ecopages validates mixed-renderer ownership from declared dependencies during render preparation rather than inferring every boundary from rendered HTML alone.
77
+ - Ecopages validates mixed-renderer ownership from declared dependencies during render preparation rather than inferring every foreign subtree from rendered HTML alone.
76
78
  - Standalone MDX keeps its own page normalization and non-React JSX runtime behavior.
77
79
 
78
80
  ## Using MDX with React
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/mdx",
3
- "version": "0.2.0-alpha.26",
3
+ "version": "0.2.0-alpha.28",
4
4
  "description": "MDX plugin for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -37,7 +37,7 @@
37
37
  "directory": "packages/integrations/mdx"
38
38
  },
39
39
  "peerDependencies": {
40
- "@ecopages/core": "0.2.0-alpha.26",
40
+ "@ecopages/core": "0.2.0-alpha.28",
41
41
  "@kitajs/html": "^4.1.0",
42
42
  "@mdx-js/mdx": "^3.1.0"
43
43
  },
@@ -1,3 +1,3 @@
1
- import type { EcoBuildPlugin } from '@ecopages/core/build/build-types';
1
+ import type { EcoBuildPlugin } from '@ecopages/core/plugins/integration-plugin';
2
2
  import { type CompileOptions } from '@mdx-js/mdx';
3
3
  export declare function createMdxLoaderPlugin(compilerOptions?: CompileOptions): EcoBuildPlugin;
@@ -21,13 +21,11 @@ export declare class MDXRenderer extends IntegrationRenderer<EcoPagesElement> {
21
21
  readonly compilerOptions: CompileOptions;
22
22
  private isFunctionComponent;
23
23
  constructor({ mdxConfig, ...options }: MDXRendererOptions);
24
- buildRouteRenderAssets(pagePath: string): Promise<ProcessedAsset[]>;
24
+ buildPageBrowserGraph(pagePath: string): Promise<{
25
+ assets: ProcessedAsset[];
26
+ }>;
25
27
  protected normalizeImportedPageFile<TPageModule extends EcoPageFile>(_file: string, pageModule: TPageModule): TPageModule;
26
28
  renderComponent(input: ComponentRenderInput): Promise<ComponentRenderResult>;
27
- protected createComponentBoundaryRuntime(options: {
28
- boundaryInput: ComponentRenderInput;
29
- rendererCache: Map<string, IntegrationRenderer<any>>;
30
- }): import("@ecopages/core").ComponentBoundaryRuntime;
31
29
  render({ params, query, props, locals, pageLocals, metadata, Page, HtmlTemplate, Layout, pageProps, }: MDXIntegrationRendererOptions): Promise<RouteRendererBody>;
32
30
  renderToResponse<P = Record<string, unknown>>(view: EcoComponent<P>, props: P, ctx: RenderToResponseContext): Promise<Response>;
33
31
  }
@@ -1,5 +1,5 @@
1
+ import { assertIntegrationInvariant } from "@ecopages/core/plugins/integration-plugin";
1
2
  import { IntegrationRenderer } from "@ecopages/core/route-renderer/integration-renderer";
2
- import { invariant } from "@ecopages/core/utils/invariant";
3
3
  import { MDX_PLUGIN_NAME } from "./mdx.constants.js";
4
4
  import { rapidhash } from "@ecopages/core/hash";
5
5
  class MDXRenderer extends IntegrationRenderer {
@@ -12,7 +12,7 @@ class MDXRenderer extends IntegrationRenderer {
12
12
  super(options);
13
13
  this.compilerOptions = mdxConfig?.compilerOptions ?? {};
14
14
  }
15
- async buildRouteRenderAssets(pagePath) {
15
+ async buildPageBrowserGraph(pagePath) {
16
16
  const { default: pageComponent } = await this.importPageFile(pagePath);
17
17
  const config = pageComponent.config;
18
18
  const components = [];
@@ -32,7 +32,9 @@ class MDXRenderer extends IntegrationRenderer {
32
32
  }
33
33
  });
34
34
  }
35
- return await this.resolveDependencies(components);
35
+ return {
36
+ assets: await this.resolveDependencies(components)
37
+ };
36
38
  }
37
39
  normalizeImportedPageFile(_file, pageModule) {
38
40
  try {
@@ -50,20 +52,14 @@ class MDXRenderer extends IntegrationRenderer {
50
52
  getMetadata
51
53
  };
52
54
  } catch (error) {
53
- invariant(false, `Error importing MDX file: ${error}`);
55
+ assertIntegrationInvariant(false, `Error importing MDX file: ${error}`);
54
56
  }
55
57
  }
56
58
  async renderComponent(input) {
57
59
  if (!this.isFunctionComponent(input.component)) {
58
60
  throw new TypeError("MDX renderer expected a callable component.");
59
61
  }
60
- return this.renderStringComponentBoundaryWithQueuedForeignBoundaries(input, input.component);
61
- }
62
- createComponentBoundaryRuntime(options) {
63
- return this.createQueuedBoundaryRuntime({
64
- boundaryInput: options.boundaryInput,
65
- rendererCache: options.rendererCache
66
- });
62
+ return this.renderStringComponentWithQueuedForeignSubtrees(input, input.component);
67
63
  }
68
64
  async render({
69
65
  params,
@@ -1,6 +1,5 @@
1
- import type { EcoBuildPlugin } from '@ecopages/core/build/build-types';
2
1
  import type { EcoPagesElement } from '@ecopages/core';
3
- import { IntegrationPlugin } from '@ecopages/core/plugins/integration-plugin';
2
+ import { IntegrationPlugin, type EcoBuildPlugin } from '@ecopages/core/plugins/integration-plugin';
4
3
  import { MDXRenderer } from './mdx-renderer.js';
5
4
  import type { MDXPluginConfig } from './mdx.types.js';
6
5
  export type { MDXPluginConfig, MDXRendererConfig, MDXRendererOptions } from './mdx.types.js';
package/src/mdx.plugin.js CHANGED
@@ -1,5 +1,7 @@
1
- import { IntegrationPlugin } from "@ecopages/core/plugins/integration-plugin";
2
- import { deepMerge } from "@ecopages/core/utils/deep-merge";
1
+ import {
2
+ IntegrationPlugin,
3
+ mergeIntegrationOptions
4
+ } from "@ecopages/core/plugins/integration-plugin";
3
5
  import { Logger } from "@ecopages/logger";
4
6
  import { createMdxLoaderPlugin } from "./mdx-loader-plugin.js";
5
7
  import { MDX_PLUGIN_NAME } from "./mdx.constants.js";
@@ -36,7 +38,7 @@ class MDXPlugin extends IntegrationPlugin {
36
38
  ...options
37
39
  });
38
40
  const { mdExtensions, mdxExtensions } = splitMarkdownExtensions(this.extensions);
39
- const finalCompilerOptions = deepMerge(
41
+ const finalCompilerOptions = mergeIntegrationOptions(
40
42
  {
41
43
  ...defaultOptions,
42
44
  mdxExtensions,
@@ -1,5 +1,4 @@
1
- import type { EcoComponent, EcoComponentConfig, GetMetadata } from '@ecopages/core';
2
- import type { EcoPagesAppConfig } from '@ecopages/core/internal-types';
1
+ import type { EcoComponent, EcoComponentConfig, EcoPagesAppConfig, GetMetadata } from '@ecopages/core';
3
2
  import type { IntegrationPluginConfig } from '@ecopages/core/plugins/integration-plugin';
4
3
  import type { AssetProcessingService, ProcessedAsset } from '@ecopages/core/services/asset-processing-service';
5
4
  import type { CompileOptions } from '@mdx-js/mdx';