@ecopages/lit 0.2.0-alpha.25 → 0.2.0-alpha.27
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 +6 -6
- package/README.md +4 -2
- package/package.json +2 -2
- package/src/lit-renderer.d.ts +4 -8
- package/src/lit-renderer.js +21 -23
package/CHANGELOG.md
CHANGED
|
@@ -8,18 +8,18 @@ All notable changes to `@ecopages/lit` are documented here.
|
|
|
8
8
|
|
|
9
9
|
### Bug Fixes
|
|
10
10
|
|
|
11
|
-
- Fixed Lit document-shell composition, declarative shadow DOM SSR, nested child serialization, lazy preload handling, explicit render paths, and mixed-renderer
|
|
12
|
-
- Fixed Lit
|
|
11
|
+
- Fixed Lit document-shell composition, declarative shadow DOM SSR, nested child serialization, lazy preload handling, explicit render paths, and mixed-renderer foreign-subtree resolution.
|
|
12
|
+
- Fixed Lit foreign-subtree payload compatibility coverage and removed the plugin/renderer integration-name import cycle.
|
|
13
13
|
|
|
14
14
|
### Documentation
|
|
15
15
|
|
|
16
|
-
- Updated the README to document `.lit.tsx` route ownership, standalone setup, and mixed-renderer Lit
|
|
16
|
+
- Updated the README to document `.lit.tsx` route ownership, standalone setup, and mixed-renderer Lit foreign-subtree handling.
|
|
17
17
|
|
|
18
18
|
### Tests
|
|
19
19
|
|
|
20
|
-
- Updated integration coverage for explicit
|
|
21
|
-
- Added renderer-level coverage for the
|
|
20
|
+
- Updated integration coverage for explicit foreign-subtree composition and Node and esbuild compatibility.
|
|
21
|
+
- Added renderer-level coverage for the foreign-subtree payload compatibility contract.
|
|
22
22
|
|
|
23
23
|
### Refactoring
|
|
24
24
|
|
|
25
|
-
- Moved Lit HTML serialization and child-slot reinjection mechanics into a dedicated utility so the renderer stays focused on preload and
|
|
25
|
+
- Moved Lit HTML serialization and child-slot reinjection mechanics into a dedicated utility so the renderer stays focused on preload and foreign-subtree orchestration.
|
package/README.md
CHANGED
|
@@ -5,9 +5,11 @@ Integration plugin for [Lit](https://lit.dev/) in Ecopages. Use it when Lit shou
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
bun add @ecopages/lit
|
|
8
|
+
bun add @ecopages/lit lit @lit-labs/ssr @lit-labs/ssr-client
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
`lit`, `@lit-labs/ssr`, and `@lit-labs/ssr-client` are required peer dependencies for this package.
|
|
12
|
+
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
15
|
Register `litPlugin()` in your `eco.config.ts`.
|
|
@@ -49,7 +51,7 @@ This setup lets Kita own the page shell while Lit owns the nested Lit component
|
|
|
49
51
|
|
|
50
52
|
## Mixed Rendering
|
|
51
53
|
|
|
52
|
-
When a non-Lit render pass
|
|
54
|
+
When a non-Lit render pass reaches a Lit-owned foreign child, Ecopages hands that foreign subtree to the Lit renderer. That keeps Lit SSR in charge of custom elements, declarative shadow DOM, and Lit-managed child content.
|
|
53
55
|
|
|
54
56
|
Important:
|
|
55
57
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/lit",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.27",
|
|
4
4
|
"description": "Ecopages lit integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"directory": "packages/integrations/lit"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@ecopages/core": "0.2.0-alpha.
|
|
34
|
+
"@ecopages/core": "0.2.0-alpha.27",
|
|
35
35
|
"@lit-labs/ssr": "^3.3.0",
|
|
36
36
|
"@lit-labs/ssr-client": "^1.1.7",
|
|
37
37
|
"lit": "^3.2.1"
|
package/src/lit-renderer.d.ts
CHANGED
|
@@ -11,24 +11,20 @@ import { IntegrationRenderer, type RenderToResponseContext } from '@ecopages/cor
|
|
|
11
11
|
export declare class LitRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
12
12
|
name: string;
|
|
13
13
|
private isFunctionComponent;
|
|
14
|
-
private
|
|
15
|
-
private
|
|
14
|
+
private resolveQueuedForeignSubtreeChildren;
|
|
15
|
+
private resolveQueuedForeignSubtreeHtml;
|
|
16
16
|
protected shouldRenderPageComponent(): boolean;
|
|
17
17
|
private isLitManagedComponent;
|
|
18
18
|
/**
|
|
19
|
-
* Renders a Lit component
|
|
19
|
+
* Renders a Lit component for component-level orchestration.
|
|
20
20
|
*
|
|
21
21
|
* SSR-eligible lazy scripts are preloaded first so custom elements registered
|
|
22
22
|
* by the component can render their server markup even when the Lit renderer is
|
|
23
|
-
* entered through cross-integration
|
|
23
|
+
* entered through cross-integration foreign-child handoff.
|
|
24
24
|
*
|
|
25
25
|
* Includes component-scoped dependency assets when declared.
|
|
26
26
|
*/
|
|
27
27
|
renderComponent(input: ComponentRenderInput): Promise<ComponentRenderResult>;
|
|
28
|
-
protected createComponentBoundaryRuntime(options: {
|
|
29
|
-
boundaryInput: ComponentRenderInput;
|
|
30
|
-
rendererCache: Map<string, IntegrationRenderer<any>>;
|
|
31
|
-
}): import("@ecopages/core").ComponentBoundaryRuntime;
|
|
32
28
|
private readonly ssrLazyPreloader;
|
|
33
29
|
/**
|
|
34
30
|
* Detects preload failures that are expected for browser-only modules.
|
package/src/lit-renderer.js
CHANGED
|
@@ -13,25 +13,29 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
13
13
|
isFunctionComponent(component) {
|
|
14
14
|
return typeof component === "function";
|
|
15
15
|
}
|
|
16
|
-
async
|
|
16
|
+
async resolveQueuedForeignSubtreeChildren(children, queuedResolutionsByToken, resolveToken) {
|
|
17
17
|
if (children === void 0) {
|
|
18
18
|
return void 0;
|
|
19
19
|
}
|
|
20
20
|
let renderedChildren = typeof children === "string" ? children : await renderLitValueToString(children);
|
|
21
|
-
renderedChildren = await this.
|
|
21
|
+
renderedChildren = await this.foreignSubtreeExecutionService.resolveQueuedTokens(
|
|
22
22
|
renderedChildren,
|
|
23
23
|
queuedResolutionsByToken,
|
|
24
24
|
resolveToken
|
|
25
25
|
);
|
|
26
26
|
return renderedChildren;
|
|
27
27
|
}
|
|
28
|
-
async
|
|
29
|
-
const
|
|
28
|
+
async resolveQueuedForeignSubtreeHtml(html, runtimeContext) {
|
|
29
|
+
const queuedForeignSubtreeResolution = await this.foreignSubtreeExecutionService.resolveQueuedHtml({
|
|
30
|
+
currentIntegrationName: this.name,
|
|
30
31
|
html,
|
|
31
32
|
runtimeContext,
|
|
32
33
|
queueLabel: "Lit",
|
|
34
|
+
getOwningRenderer: (integrationName, rendererCache) => this.getIntegrationRendererForName(integrationName, rendererCache),
|
|
35
|
+
applyAttributesToFirstElement: (resolvedHtml, attributes) => this.htmlTransformer.applyAttributesToFirstElement(resolvedHtml, attributes),
|
|
36
|
+
dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
|
|
33
37
|
renderQueuedChildren: async (children, _runtimeContext, queuedResolutionsByToken, resolveToken) => {
|
|
34
|
-
const renderedChildren = await this.
|
|
38
|
+
const renderedChildren = await this.resolveQueuedForeignSubtreeChildren(
|
|
35
39
|
children,
|
|
36
40
|
queuedResolutionsByToken,
|
|
37
41
|
resolveToken
|
|
@@ -43,8 +47,8 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
43
47
|
}
|
|
44
48
|
});
|
|
45
49
|
return {
|
|
46
|
-
html:
|
|
47
|
-
assets:
|
|
50
|
+
html: queuedForeignSubtreeResolution.html,
|
|
51
|
+
assets: queuedForeignSubtreeResolution.assets.length > 0 ? queuedForeignSubtreeResolution.assets : void 0
|
|
48
52
|
};
|
|
49
53
|
}
|
|
50
54
|
shouldRenderPageComponent() {
|
|
@@ -54,11 +58,11 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
54
58
|
return component?.config?.integration === this.name || component?.config?.__eco?.integration === this.name;
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
|
-
* Renders a Lit component
|
|
61
|
+
* Renders a Lit component for component-level orchestration.
|
|
58
62
|
*
|
|
59
63
|
* SSR-eligible lazy scripts are preloaded first so custom elements registered
|
|
60
64
|
* by the component can render their server markup even when the Lit renderer is
|
|
61
|
-
* entered through cross-integration
|
|
65
|
+
* entered through cross-integration foreign-child handoff.
|
|
62
66
|
*
|
|
63
67
|
* Includes component-scoped dependency assets when declared.
|
|
64
68
|
*/
|
|
@@ -82,30 +86,24 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
82
86
|
const content = await component(props);
|
|
83
87
|
const renderedHtml = await renderLitValueToString(content);
|
|
84
88
|
const html = renderedChildren === void 0 ? renderedHtml : injectLitRenderedChildren(renderedHtml, renderedChildren);
|
|
85
|
-
const
|
|
89
|
+
const queuedForeignSubtreeResolution = await this.resolveQueuedForeignSubtreeHtml(
|
|
86
90
|
html,
|
|
87
|
-
this.
|
|
91
|
+
this.getQueuedForeignSubtreeResolutionContext(input)
|
|
88
92
|
);
|
|
89
93
|
const hasDependencies = Boolean(input.component.config?.dependencies);
|
|
90
94
|
const canResolveAssets = typeof this.assetProcessingService?.processDependencies === "function";
|
|
91
95
|
const assets = hasDependencies && canResolveAssets ? await this.processComponentDependencies([input.component]) : void 0;
|
|
92
96
|
return {
|
|
93
|
-
html:
|
|
97
|
+
html: queuedForeignSubtreeResolution.html,
|
|
94
98
|
canAttachAttributes: true,
|
|
95
|
-
rootTag: this.getRootTagName(
|
|
99
|
+
rootTag: this.getRootTagName(queuedForeignSubtreeResolution.html),
|
|
96
100
|
integrationName: this.name,
|
|
97
101
|
assets: this.htmlTransformer.dedupeProcessedAssets([
|
|
98
102
|
...assets ?? [],
|
|
99
|
-
...
|
|
103
|
+
...queuedForeignSubtreeResolution.assets ?? []
|
|
100
104
|
])
|
|
101
105
|
};
|
|
102
106
|
}
|
|
103
|
-
createComponentBoundaryRuntime(options) {
|
|
104
|
-
return this.createQueuedBoundaryRuntime({
|
|
105
|
-
boundaryInput: options.boundaryInput,
|
|
106
|
-
rendererCache: options.rendererCache
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
107
|
ssrLazyPreloader = new LitSsrLazyPreloader({
|
|
110
108
|
resolveDependencyPath: this.resolveDependencyPath.bind(this),
|
|
111
109
|
processDependencies: this.assetProcessingService?.processDependencies?.bind(this.assetProcessingService)
|
|
@@ -196,16 +194,16 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
196
194
|
const normalizedProps = props ?? {};
|
|
197
195
|
await this.preloadSsrLazyScripts([view, Layout]);
|
|
198
196
|
await this.prepareViewDependencies(view, Layout);
|
|
199
|
-
const pageRender = await this.
|
|
197
|
+
const pageRender = await this.renderComponentWithForeignChildren({
|
|
200
198
|
component: view,
|
|
201
199
|
props: normalizedProps
|
|
202
200
|
});
|
|
203
|
-
const layoutRender = Layout ? await this.
|
|
201
|
+
const layoutRender = Layout ? await this.renderComponentWithForeignChildren({
|
|
204
202
|
component: Layout,
|
|
205
203
|
props: {},
|
|
206
204
|
children: pageRender.html
|
|
207
205
|
}) : void 0;
|
|
208
|
-
const documentRender = await this.
|
|
206
|
+
const documentRender = await this.renderComponentWithForeignChildren({
|
|
209
207
|
component: HtmlTemplate,
|
|
210
208
|
props: {
|
|
211
209
|
metadata,
|