@ecopages/core 0.2.0-beta.38 → 0.2.0-beta.39
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 +1 -0
- package/package.json +27 -3
- package/src/adapters/bun/server-adapter.js +1 -0
- package/src/adapters/node/server-adapter.js +1 -0
- package/src/adapters/shared/http/explicit-static-render-preparation.js +1 -1
- package/src/adapters/shared/http/explicit-static-route-matcher.js +1 -1
- package/src/adapters/shared/http/fs-server-response-matcher.js +15 -7
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.d.ts +11 -0
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.js +29 -0
- package/src/adapters/shared/runtime/dev-static-route-prewarm.d.ts +16 -0
- package/src/adapters/shared/runtime/dev-static-route-prewarm.js +66 -0
- package/src/adapters/shared/runtime/render-context.js +1 -1
- package/src/adapters/shared/runtime/server-adapter.d.ts +7 -1
- package/src/adapters/shared/runtime/server-adapter.js +64 -5
- package/src/build/README.md +1 -1
- package/src/build/browser/browser-runtime-plugin.js +2 -5
- package/src/build/cache/production-build-cache.d.ts +3 -2
- package/src/build/cache/production-build-cache.js +2 -2
- package/src/build/contracts/content-virtual-modules.d.ts +12 -0
- package/src/build/contracts/content-virtual-modules.js +29 -0
- package/src/build/rolldown/rolldown-adapter-helpers.js +1 -1
- package/src/build/runtime/build-request-policy.d.ts +3 -4
- package/src/build/runtime/build-request-policy.js +4 -4
- package/src/cache/index.d.ts +2 -1
- package/src/cache/index.js +2 -1
- package/src/cache/module-parse-cache.d.ts +5 -0
- package/src/cache/module-parse-cache.js +27 -3
- package/src/cache/module-transform-profiler.d.ts +8 -0
- package/src/cache/module-transform-profiler.js +8 -0
- package/src/client/view-transitions.d.ts +17 -1
- package/src/client/view-transitions.js +45 -1
- package/src/client/view-transitions.test.browser.d.ts +1 -0
- package/src/client/view-transitions.test.browser.js +56 -0
- package/src/config/config-builder.d.ts +16 -9
- package/src/config/config-builder.js +24 -14
- package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +1 -0
- package/src/dev/transform-server/dev-transform-vendor-registry.js +15 -2
- package/src/diagnostics/request-pipeline-metrics.d.ts +38 -0
- package/src/diagnostics/request-pipeline-metrics.js +121 -0
- package/src/eco/component-identity.d.ts +13 -0
- package/src/eco/component-identity.js +18 -0
- package/src/eco/eco-declared-component.d.ts +3 -2
- package/src/eco/eco-declared-component.js +6 -4
- package/src/eco/eco.browser.js +2 -2
- package/src/eco/eco.js +7 -6
- package/src/eco/eco.types.d.ts +6 -5
- package/src/errors/http-error.d.ts +8 -0
- package/src/errors/http-error.js +16 -0
- package/src/errors/undeclared-component-dependency-error.d.ts +1 -1
- package/src/errors/undeclared-component-dependency-error.js +2 -2
- package/src/index.browser.d.ts +1 -0
- package/src/index.browser.js +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/plugins/README.md +2 -1
- package/src/plugins/eco-component-meta-plugin.d.ts +6 -102
- package/src/plugins/eco-component-meta-plugin.js +110 -391
- package/src/plugins/processor.d.ts +10 -0
- package/src/plugins/processor.js +9 -0
- package/src/route-renderer/README.md +10 -8
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -1
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +1 -1
- package/src/route-renderer/orchestration/integration-renderer.d.ts +0 -8
- package/src/route-renderer/orchestration/integration-renderer.js +6 -19
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +5 -4
- package/src/route-renderer/orchestration/ownership-graph/component-graph.js +6 -4
- package/src/route-renderer/orchestration/ownership-graph/ownership-validation.service.d.ts +0 -1
- package/src/route-renderer/orchestration/ownership-graph/ownership-validation.service.js +10 -19
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +12 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +9 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +7 -0
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +65 -33
- package/src/route-renderer/page-loading/component-dependency-collection.js +3 -2
- package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +0 -5
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +4 -10
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +2 -2
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +12 -11
- package/src/route-renderer/page-loading/lazy-trigger-planning.js +2 -1
- package/src/route-renderer/page-loading/page-module-loader.d.ts +1 -1
- package/src/route-renderer/page-loading/page-module-loader.js +8 -3
- package/src/router/README.md +8 -0
- package/src/services/README.md +5 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +1 -0
- package/src/services/assets/asset-processing-service/asset-processing.service.js +22 -5
- package/src/services/cache/cache.types.d.ts +4 -2
- package/src/services/cache/html-page-cache-dependency-index.d.ts +34 -0
- package/src/services/cache/html-page-cache-dependency-index.js +88 -0
- package/src/services/cache/index.d.ts +2 -0
- package/src/services/cache/index.js +2 -0
- package/src/services/cache/page-cache-service.d.ts +31 -1
- package/src/services/cache/page-cache-service.js +79 -3
- package/src/services/cache/page-request-cache-coordinator.service.js +4 -0
- package/src/services/module-loading/README.md +9 -6
- package/src/services/module-loading/app-server-module-transpiler.service.js +0 -3
- package/src/services/module-loading/collection-server-module-build.service.d.ts +19 -0
- package/src/services/module-loading/collection-server-module-build.service.js +83 -0
- package/src/services/module-loading/page-module-import.service.d.ts +5 -11
- package/src/services/module-loading/page-module-import.service.js +56 -73
- package/src/services/module-loading/route-module-build-cache.store.js +6 -6
- package/src/services/module-loading/route-module-build-manifest.d.ts +8 -5
- package/src/services/module-loading/route-module-build-manifest.js +20 -32
- package/src/services/module-loading/server-module-transpiler.service.d.ts +0 -2
- package/src/services/module-loading/server-module-transpiler.service.js +0 -3
- package/src/static-site-generator/static-site-generator.js +2 -2
- package/src/types/internal-types.d.ts +4 -0
- package/src/types/public-types.d.ts +18 -18
- package/src/watchers/project-watcher.js +14 -0
package/src/eco/eco.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { finalizeComponentRender, getComponentRenderContext, interceptForeignChild, } from '../route-renderer/orchestration/foreign-child/component-render-context.js';
|
|
6
6
|
import { isThenable } from '../route-renderer/orchestration/foreign-child/foreign-child-output.utils.js';
|
|
7
7
|
import { applyPageLayoutConfig, mergeLayoutDependencies, normalizePageLayouts } from './page-layout-normalization.js';
|
|
8
|
+
import { getComponentIdentity } from './component-identity.js';
|
|
8
9
|
/**
|
|
9
10
|
* Creates a component factory with lazy-trigger support and foreign-child-runtime
|
|
10
11
|
* interception.
|
|
@@ -20,7 +21,7 @@ import { applyPageLayoutConfig, mergeLayoutDependencies, normalizePageLayouts }
|
|
|
20
21
|
* @returns Configured eco component.
|
|
21
22
|
*/
|
|
22
23
|
function createComponentFactory(options) {
|
|
23
|
-
const integrationName = options.integration ?? options.
|
|
24
|
+
const integrationName = options.integration ?? options.identity?.integration;
|
|
24
25
|
const comp = ((props) => {
|
|
25
26
|
const componentProps = (props ?? {});
|
|
26
27
|
const renderInline = (nextProps = props) => finalizeComponentRender(comp, options.render(nextProps));
|
|
@@ -48,12 +49,12 @@ function createComponentFactory(options) {
|
|
|
48
49
|
activeRenderContext.foreignChildRuntime &&
|
|
49
50
|
integrationName &&
|
|
50
51
|
integrationName !== activeRenderContext.currentIntegration) {
|
|
51
|
-
throw new Error(`[ecopages] Missing foreign-child interception from ${activeRenderContext.currentIntegration} to ${integrationName} for ${options.
|
|
52
|
+
throw new Error(`[ecopages] Missing foreign-child interception from ${activeRenderContext.currentIntegration} to ${integrationName} for ${options.identity?.file ?? 'unknown component'}.`);
|
|
52
53
|
}
|
|
53
54
|
return renderInline();
|
|
54
55
|
});
|
|
55
56
|
comp.config = {
|
|
56
|
-
|
|
57
|
+
identity: options.identity,
|
|
57
58
|
integration: options.integration,
|
|
58
59
|
dependencies: options.dependencies,
|
|
59
60
|
};
|
|
@@ -78,8 +79,8 @@ function isMissingForeignChildInterceptionError(error) {
|
|
|
78
79
|
function embed(component, props, children) {
|
|
79
80
|
const activeRenderContext = getComponentRenderContext();
|
|
80
81
|
const ecoComponent = component;
|
|
81
|
-
const targetIntegration = ecoComponent.config?.integration ?? ecoComponent
|
|
82
|
-
const componentFile = ecoComponent
|
|
82
|
+
const targetIntegration = ecoComponent.config?.integration ?? getComponentIdentity(ecoComponent)?.integration;
|
|
83
|
+
const componentFile = getComponentIdentity(ecoComponent)?.file ?? 'unknown component';
|
|
83
84
|
const nextProps = (children === undefined ? props : { ...props, children });
|
|
84
85
|
try {
|
|
85
86
|
return component(nextProps);
|
|
@@ -117,7 +118,7 @@ function page(options) {
|
|
|
117
118
|
? mergeLayoutDependencies(undefined, layoutEntries)
|
|
118
119
|
: mergeLayoutDependencies(dependenciesInput, layoutEntries);
|
|
119
120
|
const componentOptions = {
|
|
120
|
-
|
|
121
|
+
identity: options.identity,
|
|
121
122
|
integration: options.integration,
|
|
122
123
|
dependencies: staticDependencies,
|
|
123
124
|
render,
|
package/src/eco/eco.types.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Type definitions for the eco namespace API
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
|
-
import type { DependencyLazyTrigger, EcoComponent, EcoComponentDependencies, EcoHtmlComponent,
|
|
5
|
+
import type { DependencyLazyTrigger, EcoComponent, EcoComponentDependencies, EcoHtmlComponent, EcoLayoutComponent, EcoPageLayouts, EcoPagesElement, FileRouteMiddleware, GetMetadata, GetStaticPaths, GetStaticProps, HtmlTemplateProps, LayoutProps, RequestLocals, RequestPageContext, PageParams, PageQuery } from '../types/public-types.js';
|
|
6
6
|
import type { CacheStrategy } from '../services/cache/cache.types.js';
|
|
7
|
+
import type { ComponentIdentity } from './component-identity.js';
|
|
7
8
|
/**
|
|
8
9
|
* Extracts the props type from one eco component.
|
|
9
10
|
*/
|
|
@@ -87,8 +88,8 @@ export type LazyTrigger = DependencyLazyTrigger;
|
|
|
87
88
|
* @template E - The element/return type (defaults to EcoPagesElement for Kita, use ReactNode for React)
|
|
88
89
|
*/
|
|
89
90
|
export interface ComponentOptions<P, E = EcoPagesElement> {
|
|
90
|
-
/** @internal
|
|
91
|
-
|
|
91
|
+
/** @internal Bound by the component identity attribution transform. */
|
|
92
|
+
identity?: ComponentIdentity;
|
|
92
93
|
integration?: string;
|
|
93
94
|
dependencies?: EcoComponentDependencies;
|
|
94
95
|
render: (props: P) => E | Promise<E>;
|
|
@@ -110,8 +111,8 @@ export type LayoutOptions<E = EcoPagesElement> = ComponentOptions<LayoutProps<E>
|
|
|
110
111
|
* Base options shared by all page variants
|
|
111
112
|
*/
|
|
112
113
|
export interface PageOptionsBase<T, E = EcoPagesElement> {
|
|
113
|
-
/** @internal
|
|
114
|
-
|
|
114
|
+
/** @internal Bound by the component identity attribution transform. */
|
|
115
|
+
identity?: ComponentIdentity;
|
|
115
116
|
integration?: string;
|
|
116
117
|
/**
|
|
117
118
|
* Declares browser dependencies for the page, or resolves them per render after
|
|
@@ -14,6 +14,14 @@ export declare class HttpError extends Error {
|
|
|
14
14
|
readonly status: number;
|
|
15
15
|
readonly details?: HttpErrorDetails;
|
|
16
16
|
constructor(status: number, message: string, details?: HttpErrorDetails);
|
|
17
|
+
/**
|
|
18
|
+
* Detects HttpError across bundle boundaries where `instanceof` can fail.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Page modules may load a different class identity than core runtime code.
|
|
22
|
+
* Prefer this over `instanceof` when catching errors from app page bundles.
|
|
23
|
+
*/
|
|
24
|
+
static isHttpError(error: unknown): error is HttpError;
|
|
17
25
|
/**
|
|
18
26
|
* Serialize error to JSON for API responses.
|
|
19
27
|
*/
|
package/src/errors/http-error.js
CHANGED
|
@@ -11,6 +11,22 @@ export class HttpError extends Error {
|
|
|
11
11
|
this.status = status;
|
|
12
12
|
this.details = details;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Detects HttpError across bundle boundaries where `instanceof` can fail.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Page modules may load a different class identity than core runtime code.
|
|
19
|
+
* Prefer this over `instanceof` when catching errors from app page bundles.
|
|
20
|
+
*/
|
|
21
|
+
static isHttpError(error) {
|
|
22
|
+
if (error instanceof HttpError) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return (typeof error === 'object' &&
|
|
26
|
+
error !== null &&
|
|
27
|
+
error.name === 'HttpError' &&
|
|
28
|
+
typeof error.status === 'number');
|
|
29
|
+
}
|
|
14
30
|
/**
|
|
15
31
|
* Serialize error to JSON for API responses.
|
|
16
32
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare function getUndeclaredComponentDependencyMessage(parentComponentFile?: string): string;
|
|
2
2
|
/**
|
|
3
3
|
* Thrown when `dependencies.components` contains a plain function or component
|
|
4
|
-
* without plugin-
|
|
4
|
+
* without plugin-bound component identity attribution.
|
|
5
5
|
*/
|
|
6
6
|
export declare class UndeclaredComponentDependencyError extends Error {
|
|
7
7
|
name: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export function getUndeclaredComponentDependencyMessage(parentComponentFile) {
|
|
2
2
|
const parentHint = parentComponentFile ? ` (declared by ${parentComponentFile})` : '';
|
|
3
|
-
return `[ecopages] dependencies.components entries must be eco.component(), eco.layout(), or eco.html() components with
|
|
3
|
+
return `[ecopages] dependencies.components entries must be eco.component(), eco.layout(), or eco.html() components with component identity${parentHint}. Plain functions and untyped components are not valid dependency entries.`;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* Thrown when `dependencies.components` contains a plain function or component
|
|
7
|
-
* without plugin-
|
|
7
|
+
* without plugin-bound component identity attribution.
|
|
8
8
|
*/
|
|
9
9
|
export class UndeclaredComponentDependencyError extends Error {
|
|
10
10
|
name = 'UndeclaredComponentDependencyError';
|
package/src/index.browser.d.ts
CHANGED
package/src/index.browser.js
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export { eco } from './eco/eco.js';
|
|
|
4
4
|
export { defineApiHandler, defineGroupHandler, defineGet, definePost, definePut, defineDelete, definePatch, defineOptions, defineHead, json, html, redirect, type GroupHandler, } from './adapters/shared/http/define-api-handler.js';
|
|
5
5
|
export { createEcoBuildPluginFromSourceTransform, createVitePluginsFromAppSourceTransforms, getAppSourceTransforms, createVitePluginFromSourceTransform, normalizeTransformId, type EcoSourceTransform, type EcoSourceTransformResult, type EcoViteCompatiblePlugin, } from './plugins/source-transform.js';
|
|
6
6
|
export { createEcoComponentMetaTransform } from './plugins/eco-component-meta-plugin.js';
|
|
7
|
+
export { bindComponentIdentity, getComponentIdentity, type ComponentIdentity } from './eco/component-identity.js';
|
|
7
8
|
export { SchemaError, validateStandardSchema } from './services/validation/validate-standard-schema.js';
|
|
8
9
|
export { buildIslandHostAttributes, ECO_ISLAND_HOST_ATTRIBUTE, ECO_ISLAND_INTEGRATION_ATTRIBUTE, finalizeIslandComponentRender, isIslandHostElement, mergeIslandHostAttributes, } from './islands/island-host.js';
|
package/src/index.js
CHANGED
|
@@ -2,5 +2,6 @@ export { eco } from './eco/eco.js';
|
|
|
2
2
|
export { defineApiHandler, defineGroupHandler, defineGet, definePost, definePut, defineDelete, definePatch, defineOptions, defineHead, json, html, redirect, } from './adapters/shared/http/define-api-handler.js';
|
|
3
3
|
export { createEcoBuildPluginFromSourceTransform, createVitePluginsFromAppSourceTransforms, getAppSourceTransforms, createVitePluginFromSourceTransform, normalizeTransformId, } from './plugins/source-transform.js';
|
|
4
4
|
export { createEcoComponentMetaTransform } from './plugins/eco-component-meta-plugin.js';
|
|
5
|
+
export { bindComponentIdentity, getComponentIdentity } from './eco/component-identity.js';
|
|
5
6
|
export { SchemaError, validateStandardSchema } from './services/validation/validate-standard-schema.js';
|
|
6
7
|
export { buildIslandHostAttributes, ECO_ISLAND_HOST_ATTRIBUTE, ECO_ISLAND_INTEGRATION_ATTRIBUTE, finalizeIslandComponentRender, isIslandHostElement, mergeIslandHostAttributes, } from './islands/island-host.js';
|
package/src/plugins/README.md
CHANGED
|
@@ -19,13 +19,14 @@ These contracts are responsible for:
|
|
|
19
19
|
- `processor.ts`: asset-transformation contract for processors
|
|
20
20
|
- `runtime-capability.ts`: runtime compatibility declaration types
|
|
21
21
|
- `source-transform.ts`: bundler-neutral source-transform primitive with Ecopages adapters plus app-level Vite plugin composition helpers
|
|
22
|
-
- `eco-component-meta-plugin.ts`:
|
|
22
|
+
- `eco-component-meta-plugin.ts`: component-identity attribution transform that uses a lexical `eco.` gate, then an Oxc `CallExpression` rewrite
|
|
23
23
|
|
|
24
24
|
## Ownership Rules
|
|
25
25
|
|
|
26
26
|
- Integrations own rendering semantics, hydration behavior, and integration-specific HMR strategy.
|
|
27
27
|
- Processors own asset semantics, cache ownership, and processor-specific watch behavior.
|
|
28
28
|
- Core owns lifecycle ordering, startup orchestration, and manifest assembly.
|
|
29
|
+
- The transform wraps native `eco.page()`, `eco.component()`, `eco.layout()`, and `eco.html()` factory options with `bindComponentIdentity()`. Factories retain the resulting `options.identity` on `config`, and runtime consumers read it through `getComponentIdentity()`. Browser, HMR, and server builds use the same source transform, so ownership and dependency diagnostics retain stable file attribution without a loader duplicate.
|
|
29
30
|
|
|
30
31
|
## Lifecycle Summary
|
|
31
32
|
|
|
@@ -1,108 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bun plugin that auto-injects `__eco` metadata into EcoComponent config objects.
|
|
3
|
-
*
|
|
4
|
-
* This plugin uses AST parsing (via oxc-parser) to reliably inject the `__eco` property
|
|
5
|
-
* into EcoComponent config objects at import time. The injected metadata contains:
|
|
6
|
-
* - `dir`: The directory path of the component file (used for dependency resolution)
|
|
7
|
-
* - `integration`: The integration type (e.g., 'react', 'kitajs', 'ghtml', 'lit')
|
|
8
|
-
*
|
|
9
|
-
* The plugin intercepts file loading for all configured integration extensions and
|
|
10
|
-
* transforms component configs before they are executed.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // Before transformation:
|
|
15
|
-
* export default eco.page({
|
|
16
|
-
* render: () => '<div>Hello</div>',
|
|
17
|
-
* });
|
|
18
|
-
*
|
|
19
|
-
* // After transformation:
|
|
20
|
-
* export default eco.page({
|
|
21
|
-
* __eco: { id: "<hash>", file: "/path/to/pages/index.tsx", integration: "react" },
|
|
22
|
-
* render: () => '<div>Hello</div>',
|
|
23
|
-
* });
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @module eco-component-meta-plugin
|
|
27
|
-
*/
|
|
28
|
-
import type { EcoBuildPlugin } from '../build/contracts/build-types.js';
|
|
29
1
|
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
* Options for creating the eco-component-meta-plugin.
|
|
33
|
-
*/
|
|
2
|
+
import type { EcoSourceTransform, EcoViteCompatiblePlugin } from './source-transform.js';
|
|
3
|
+
import type { EcoBuildPlugin } from '../build/contracts/build-types.js';
|
|
34
4
|
export interface EcoComponentDirPluginOptions {
|
|
35
|
-
/** The EcoPages application configuration containing integration settings */
|
|
36
5
|
config: EcoPagesAppConfig;
|
|
37
6
|
}
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
* Vite-compatible adapters.
|
|
41
|
-
*/
|
|
7
|
+
/** Attributes real `eco.*()` factory calls with canonical component identity. */
|
|
8
|
+
export declare function attributeComponentIdentity(contents: string, filePath: string, integration: string): string;
|
|
42
9
|
export declare function createEcoComponentMetaTransform(options: EcoComponentDirPluginOptions): EcoSourceTransform;
|
|
43
|
-
/**
|
|
44
|
-
* Creates a build plugin that auto-injects `__eco` metadata into EcoComponent config objects.
|
|
45
|
-
*
|
|
46
|
-
* This plugin intercepts file loading for all integration-compatible files and:
|
|
47
|
-
* 1. Strips any query string from the file path (for dev mode cache-busting)
|
|
48
|
-
* 2. Reads the file contents
|
|
49
|
-
* 3. Parses the AST using oxc-parser to find injection points
|
|
50
|
-
* 4. Injects `__eco: { id: "...", file: "...", integration: "..." }` into config objects
|
|
51
|
-
* 5. Returns the transformed content with the appropriate loader
|
|
52
|
-
*
|
|
53
|
-
* Supported patterns:
|
|
54
|
-
* - `eco.page({ ... })` - Page component declarations
|
|
55
|
-
* - `eco.component({ ... })` - Reusable component declarations
|
|
56
|
-
* - `eco.html({ ... })` - HTML shell declarations
|
|
57
|
-
* - `eco.layout({ ... })` - Layout declarations
|
|
58
|
-
* - `Component.config = { ... }` - Config assignment pattern
|
|
59
|
-
* - `config: { ... }` - Config property in object literals
|
|
60
|
-
* - `export const config = { ... }` - Exported config declarations
|
|
61
|
-
*
|
|
62
|
-
* @param options - Plugin options containing the EcoPages config
|
|
63
|
-
* @returns A build plugin instance ready for registration
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* import { createEcoComponentMetaPlugin } from '@ecopages/core';
|
|
68
|
-
*
|
|
69
|
-
* const plugin = createEcoComponentMetaPlugin({ config: appConfig });
|
|
70
|
-
* appConfig.loaders.set(plugin.name, plugin);
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
export declare function createEcoComponentMetaPlugin(options: EcoComponentDirPluginOptions): EcoBuildPlugin;
|
|
74
|
-
/**
|
|
75
|
-
* Creates a Vite-compatible metadata injection plugin from the shared
|
|
76
|
-
* Ecopages source-transform primitive.
|
|
77
|
-
*/
|
|
78
10
|
export declare function createEcoComponentMetaVitePlugin(options: EcoComponentDirPluginOptions): EcoViteCompatiblePlugin;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
* Uses oxc-parser for robust AST-based code analysis, which handles edge cases
|
|
83
|
-
* that regex-based approaches would miss (e.g., complex generics, nested objects,
|
|
84
|
-
* comments, string literals containing similar patterns).
|
|
85
|
-
*
|
|
86
|
-
* The injection is performed by:
|
|
87
|
-
* 1. Parsing the source code into an AST
|
|
88
|
-
* 2. Walking the AST to find all config object patterns
|
|
89
|
-
* 3. Collecting insertion points (sorted in reverse order to preserve positions)
|
|
90
|
-
* 4. Inserting the `__eco` property at each point
|
|
91
|
-
*
|
|
92
|
-
* @param contents - The source code content to transform
|
|
93
|
-
* @param filePath - Absolute path to the file (used to derive the directory)
|
|
94
|
-
* @param integration - The integration identifier for this file type
|
|
95
|
-
* @returns Transformed source code with `__eco` injected, or original if no patterns found
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```typescript
|
|
99
|
-
* const result = injectEcoMeta(
|
|
100
|
-
* 'export default eco.page({ render: () => "<div>Hi</div>" });',
|
|
101
|
-
* '/app/src/pages/index.tsx',
|
|
102
|
-
* 'react'
|
|
103
|
-
* );
|
|
104
|
-
* // Result: 'export default eco.page({ __eco: { id: "<hash>", file: "/app/src/pages/index.tsx", integration: "react" }, render: () => "<div>Hi</div>" });'
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
export declare function injectEcoMeta(contents: string, filePath: string, integration: string): string;
|
|
108
|
-
export default createEcoComponentMetaPlugin;
|
|
11
|
+
export declare function createEcoComponentMetaPlugin(options: EcoComponentDirPluginOptions): EcoBuildPlugin;
|
|
12
|
+
export default createEcoComponentMetaTransform;
|