@ecopages/core 0.2.0-alpha.12 → 0.2.0-alpha.14
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 +7 -28
- package/README.md +5 -4
- package/package.json +2 -2
- package/src/adapters/bun/hmr-manager.js +2 -2
- package/src/adapters/node/node-hmr-manager.js +2 -2
- package/src/adapters/node/server-adapter.d.ts +2 -2
- package/src/adapters/node/server-adapter.js +5 -5
- package/src/build/build-adapter.d.ts +7 -6
- package/src/build/build-adapter.js +6 -7
- package/src/eco/eco.js +15 -6
- package/src/eco/eco.utils.d.ts +1 -1
- package/src/eco/eco.utils.js +5 -1
- package/src/hmr/hmr-strategy.d.ts +2 -2
- package/src/integrations/ghtml/ghtml-renderer.d.ts +6 -1
- package/src/integrations/ghtml/ghtml-renderer.js +29 -28
- package/src/plugins/integration-plugin.d.ts +1 -24
- package/src/plugins/integration-plugin.js +0 -14
- package/src/route-renderer/GRAPH.md +54 -84
- package/src/route-renderer/README.md +11 -22
- package/src/route-renderer/orchestration/component-render-context.d.ts +33 -84
- package/src/route-renderer/orchestration/component-render-context.js +30 -108
- package/src/route-renderer/orchestration/integration-renderer.d.ts +219 -96
- package/src/route-renderer/orchestration/integration-renderer.js +416 -236
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +93 -0
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
- package/src/route-renderer/orchestration/render-execution.service.d.ts +8 -71
- package/src/route-renderer/orchestration/render-execution.service.js +28 -115
- package/src/route-renderer/orchestration/render-output.utils.d.ts +6 -0
- package/src/route-renderer/orchestration/render-output.utils.js +25 -0
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +0 -9
- package/src/route-renderer/orchestration/render-preparation.service.js +3 -34
- package/src/route-renderer/page-loading/dependency-resolver.js +6 -1
- package/src/route-renderer/page-loading/page-module-loader.d.ts +1 -2
- package/src/route-renderer/page-loading/page-module-loader.js +0 -2
- package/src/router/client/navigation-coordinator.js +2 -2
- package/src/router/server/fs-router-scanner.js +6 -1
- package/src/services/runtime-state/dev-graph.service.d.ts +5 -5
- package/src/services/runtime-state/dev-graph.service.js +10 -10
- package/src/types/public-types.d.ts +2 -5
- package/src/eco/component-render-context.d.ts +0 -2
- package/src/eco/component-render-context.js +0 -12
- package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -33
- package/src/route-renderer/component-graph/component-graph-executor.js +0 -30
- package/src/route-renderer/component-graph/component-graph.d.ts +0 -53
- package/src/route-renderer/component-graph/component-graph.js +0 -94
- package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
- package/src/route-renderer/component-graph/component-marker.js +0 -44
- package/src/route-renderer/component-graph/component-reference.d.ts +0 -10
- package/src/route-renderer/component-graph/component-reference.js +0 -34
- package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -79
- package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -117
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const GLOBAL_COMPONENT_REFERENCE_STATE_KEY = "__ECOPAGES_COMPONENT_REFERENCE_STATE__";
|
|
2
|
-
function getSharedReferenceScope() {
|
|
3
|
-
const globalProcess = globalThis.process;
|
|
4
|
-
if (globalProcess && typeof globalProcess === "object") {
|
|
5
|
-
return globalProcess;
|
|
6
|
-
}
|
|
7
|
-
return globalThis;
|
|
8
|
-
}
|
|
9
|
-
function getComponentReferenceState() {
|
|
10
|
-
const sharedScope = getSharedReferenceScope();
|
|
11
|
-
sharedScope[GLOBAL_COMPONENT_REFERENCE_STATE_KEY] ??= {
|
|
12
|
-
runtimeComponentRefs: /* @__PURE__ */ new WeakMap(),
|
|
13
|
-
nextRuntimeComponentRef: 0
|
|
14
|
-
};
|
|
15
|
-
return sharedScope[GLOBAL_COMPONENT_REFERENCE_STATE_KEY];
|
|
16
|
-
}
|
|
17
|
-
function getComponentReference(component) {
|
|
18
|
-
const state = getComponentReferenceState();
|
|
19
|
-
const metadataRef = component.config?.__eco?.id ?? component.config?.__eco?.file;
|
|
20
|
-
if (metadataRef) {
|
|
21
|
-
return metadataRef;
|
|
22
|
-
}
|
|
23
|
-
const existingRef = state.runtimeComponentRefs.get(component);
|
|
24
|
-
if (existingRef) {
|
|
25
|
-
return existingRef;
|
|
26
|
-
}
|
|
27
|
-
state.nextRuntimeComponentRef += 1;
|
|
28
|
-
const runtimeRef = `eco-runtime-component-${state.nextRuntimeComponentRef}`;
|
|
29
|
-
state.runtimeComponentRefs.set(component, runtimeRef);
|
|
30
|
-
return runtimeRef;
|
|
31
|
-
}
|
|
32
|
-
export {
|
|
33
|
-
getComponentReference
|
|
34
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import type { ComponentRenderInput, ComponentRenderResult, EcoComponent } from '../../types/public-types.js';
|
|
2
|
-
import type { ProcessedAsset } from '../../services/assets/asset-processing-service/index.js';
|
|
3
|
-
import type { MarkerNodeId } from './component-marker.js';
|
|
4
|
-
/**
|
|
5
|
-
* Serializable graph-context payload used during post-render marker resolution.
|
|
6
|
-
*
|
|
7
|
-
* `propsByRef` stores serialized props captured during the first render pass,
|
|
8
|
-
* while `slotChildrenByRef` preserves parent-child marker relationships for
|
|
9
|
-
* slot-like composition.
|
|
10
|
-
*/
|
|
11
|
-
export type MarkerGraphContext = {
|
|
12
|
-
propsByRef?: Record<string, Record<string, unknown>>;
|
|
13
|
-
slotChildrenByRef?: Record<string, MarkerNodeId[]>;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Minimal renderer contract needed for deferred component resolution.
|
|
17
|
-
*
|
|
18
|
-
* The marker graph resolver intentionally depends only on component-level render
|
|
19
|
-
* capabilities, not on the full integration renderer abstraction.
|
|
20
|
-
*/
|
|
21
|
-
export interface MarkerGraphComponentRenderer {
|
|
22
|
-
renderComponentForMarkerGraph(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
23
|
-
}
|
|
24
|
-
export interface MarkerGraphResolverOptions {
|
|
25
|
-
html: string;
|
|
26
|
-
componentsToResolve: EcoComponent[];
|
|
27
|
-
graphContext: MarkerGraphContext;
|
|
28
|
-
resolveRenderer: (integrationName: string) => MarkerGraphComponentRenderer;
|
|
29
|
-
applyAttributesToFirstElement: (html: string, attributes: Record<string, string>) => string;
|
|
30
|
-
instanceIdScope?: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Resolves deferred `eco-marker` tokens after the first render pass.
|
|
34
|
-
*
|
|
35
|
-
* This service owns the second-stage orchestration for cross-integration
|
|
36
|
-
* component rendering. It builds a component reference registry, constructs a
|
|
37
|
-
* deterministic marker DAG, resolves leaf nodes before parents, and collects any
|
|
38
|
-
* component-level assets emitted during that process.
|
|
39
|
-
*
|
|
40
|
-
* Responsibility split:
|
|
41
|
-
* - core resolves marker structure, refs, child ordering, and renderer dispatch
|
|
42
|
-
* - the target integration renderer resolves the actual component render through
|
|
43
|
-
* `renderComponent()` once the marker has been decoded into component input
|
|
44
|
-
*/
|
|
45
|
-
export declare class MarkerGraphResolver {
|
|
46
|
-
private restoreSerializedChildren;
|
|
47
|
-
/**
|
|
48
|
-
* Resolves every marker in the supplied HTML and returns the final HTML plus
|
|
49
|
-
* any assets produced by nested component renders.
|
|
50
|
-
*
|
|
51
|
-
* The resolver is intentionally fail-fast: missing component refs or props refs
|
|
52
|
-
* indicate a broken render graph and should surface immediately instead of
|
|
53
|
-
* producing partial output.
|
|
54
|
-
*
|
|
55
|
-
* The resolver does not render integration-specific HTML itself. Instead, it
|
|
56
|
-
* reconstructs `ComponentRenderInput` from the marker payload and then delegates
|
|
57
|
-
* the actual rendering to the target integration renderer.
|
|
58
|
-
*
|
|
59
|
-
* @param options Marker graph resolution inputs for one render pass.
|
|
60
|
-
* @returns Resolved HTML and collected component assets.
|
|
61
|
-
*/
|
|
62
|
-
resolve(options: MarkerGraphResolverOptions): Promise<{
|
|
63
|
-
html: string;
|
|
64
|
-
assets: ProcessedAsset[];
|
|
65
|
-
}>;
|
|
66
|
-
/**
|
|
67
|
-
* Builds a reference registry from the root component set and all nested
|
|
68
|
-
* declared component dependencies.
|
|
69
|
-
*
|
|
70
|
-
* Component refs are keyed by build metadata when available, falling back to a
|
|
71
|
-
* stable runtime reference for source-imported components. Traversal is depth-
|
|
72
|
-
* first and deduplicated by component identity to remain stable in shared
|
|
73
|
-
* dependency graphs.
|
|
74
|
-
*
|
|
75
|
-
* @param components Root components participating in resolution.
|
|
76
|
-
* @returns Lookup table from component ref to component definition.
|
|
77
|
-
*/
|
|
78
|
-
private buildComponentRefRegistry;
|
|
79
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { getComponentReference } from "./component-reference.js";
|
|
2
|
-
import { extractComponentGraph } from "./component-graph.js";
|
|
3
|
-
import { resolveComponentGraph } from "./component-graph-executor.js";
|
|
4
|
-
class MarkerGraphResolver {
|
|
5
|
-
restoreSerializedChildren(serializedChildren, childNodeIds, resolvedNodeHtml) {
|
|
6
|
-
let restoredChildren = serializedChildren;
|
|
7
|
-
for (const childNodeId of childNodeIds) {
|
|
8
|
-
const resolvedChildHtml = resolvedNodeHtml.get(childNodeId);
|
|
9
|
-
if (!resolvedChildHtml) {
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
const markerRegex = new RegExp(
|
|
13
|
-
`<eco-marker\\b(?=[^>]*data-eco-node-id="${childNodeId}")[^>]*><\\/eco-marker>`,
|
|
14
|
-
"g"
|
|
15
|
-
);
|
|
16
|
-
restoredChildren = restoredChildren.replace(markerRegex, resolvedChildHtml);
|
|
17
|
-
}
|
|
18
|
-
return restoredChildren;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Resolves every marker in the supplied HTML and returns the final HTML plus
|
|
22
|
-
* any assets produced by nested component renders.
|
|
23
|
-
*
|
|
24
|
-
* The resolver is intentionally fail-fast: missing component refs or props refs
|
|
25
|
-
* indicate a broken render graph and should surface immediately instead of
|
|
26
|
-
* producing partial output.
|
|
27
|
-
*
|
|
28
|
-
* The resolver does not render integration-specific HTML itself. Instead, it
|
|
29
|
-
* reconstructs `ComponentRenderInput` from the marker payload and then delegates
|
|
30
|
-
* the actual rendering to the target integration renderer.
|
|
31
|
-
*
|
|
32
|
-
* @param options Marker graph resolution inputs for one render pass.
|
|
33
|
-
* @returns Resolved HTML and collected component assets.
|
|
34
|
-
*/
|
|
35
|
-
async resolve(options) {
|
|
36
|
-
const registry = this.buildComponentRefRegistry(options.componentsToResolve);
|
|
37
|
-
const graph = extractComponentGraph(
|
|
38
|
-
options.html,
|
|
39
|
-
options.graphContext.slotChildrenByRef ?? {},
|
|
40
|
-
options.graphContext.propsByRef ?? {}
|
|
41
|
-
);
|
|
42
|
-
const resolvedNodeHtml = /* @__PURE__ */ new Map();
|
|
43
|
-
const assets = [];
|
|
44
|
-
const resolvedHtml = await resolveComponentGraph(options.html, graph, async (marker) => {
|
|
45
|
-
const component = registry.get(marker.componentRef);
|
|
46
|
-
if (!component) {
|
|
47
|
-
throw new Error(`[ecopages] Missing component reference for marker: ${marker.componentRef}`);
|
|
48
|
-
}
|
|
49
|
-
const props = options.graphContext.propsByRef?.[marker.propsRef];
|
|
50
|
-
if (!props) {
|
|
51
|
-
throw new Error(`[ecopages] Missing props reference for marker: ${marker.propsRef}`);
|
|
52
|
-
}
|
|
53
|
-
const normalizedProps = { ...props };
|
|
54
|
-
let children;
|
|
55
|
-
if (marker.slotRef) {
|
|
56
|
-
const childNodeIds = options.graphContext.slotChildrenByRef?.[marker.slotRef] ?? [];
|
|
57
|
-
if (childNodeIds.length > 0) {
|
|
58
|
-
const serializedChildren = normalizedProps.children;
|
|
59
|
-
children = typeof serializedChildren === "string" ? this.restoreSerializedChildren(serializedChildren, childNodeIds, resolvedNodeHtml) : childNodeIds.map((childNodeId) => resolvedNodeHtml.get(childNodeId) ?? "").join("");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const renderer = options.resolveRenderer(marker.integration);
|
|
63
|
-
const componentInstanceId = options.instanceIdScope ? `${options.instanceIdScope}_${marker.nodeId}` : marker.nodeId;
|
|
64
|
-
const componentRender = await renderer.renderComponentForMarkerGraph({
|
|
65
|
-
component,
|
|
66
|
-
props: normalizedProps,
|
|
67
|
-
children,
|
|
68
|
-
integrationContext: {
|
|
69
|
-
componentInstanceId
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
if (componentRender.assets?.length) {
|
|
73
|
-
assets.push(...componentRender.assets);
|
|
74
|
-
}
|
|
75
|
-
const htmlWithAttributes = componentRender.canAttachAttributes && componentRender.rootAttributes ? options.applyAttributesToFirstElement(componentRender.html, componentRender.rootAttributes) : componentRender.html;
|
|
76
|
-
resolvedNodeHtml.set(marker.nodeId, htmlWithAttributes);
|
|
77
|
-
return { html: htmlWithAttributes };
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
html: resolvedHtml,
|
|
81
|
-
assets
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Builds a reference registry from the root component set and all nested
|
|
86
|
-
* declared component dependencies.
|
|
87
|
-
*
|
|
88
|
-
* Component refs are keyed by build metadata when available, falling back to a
|
|
89
|
-
* stable runtime reference for source-imported components. Traversal is depth-
|
|
90
|
-
* first and deduplicated by component identity to remain stable in shared
|
|
91
|
-
* dependency graphs.
|
|
92
|
-
*
|
|
93
|
-
* @param components Root components participating in resolution.
|
|
94
|
-
* @returns Lookup table from component ref to component definition.
|
|
95
|
-
*/
|
|
96
|
-
buildComponentRefRegistry(components) {
|
|
97
|
-
const registry = /* @__PURE__ */ new Map();
|
|
98
|
-
const stack = [...components];
|
|
99
|
-
const seen = /* @__PURE__ */ new Set();
|
|
100
|
-
while (stack.length > 0) {
|
|
101
|
-
const current = stack.pop();
|
|
102
|
-
if (!current || seen.has(current)) {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
seen.add(current);
|
|
106
|
-
registry.set(getComponentReference(current), current);
|
|
107
|
-
const nested = current.config?.dependencies?.components ?? [];
|
|
108
|
-
for (const component of nested) {
|
|
109
|
-
stack.push(component);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return registry;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
export {
|
|
116
|
-
MarkerGraphResolver
|
|
117
|
-
};
|