@ecopages/lit 0.2.0-alpha.5 → 0.2.0-alpha.7
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 +8 -5
- package/README.md +8 -6
- package/package.json +2 -2
- package/src/lit-renderer.d.ts +2 -0
- package/src/lit-renderer.js +17 -6
- package/src/lit-renderer.ts +19 -6
- package/src/lit.plugin.js +0 -1
- package/src/lit.plugin.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,14 +8,17 @@ All notable changes to `@ecopages/lit` are documented here.
|
|
|
8
8
|
|
|
9
9
|
### Features
|
|
10
10
|
|
|
11
|
-
- Aligned Lit
|
|
12
|
-
|
|
11
|
+
- Aligned Lit with the unified orchestration pipeline and the shared lazy dependency and global injector flow.
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- Prevented the shared Lit hydrate-support bootstrap from re-running on every browser-router navigation.
|
|
16
|
+
- Routed Lit renderer output through Lit's static SSR template pipeline so registered custom elements render declarative shadow DOM during SSR instead of staying as bare host tags.
|
|
13
17
|
|
|
14
18
|
### Refactoring
|
|
15
19
|
|
|
16
|
-
-
|
|
17
|
-
- Updated test suite for esbuild adapter and Node.js runtime compatibility (`31a44458`).
|
|
20
|
+
- Cleaned up ambient module declarations.
|
|
18
21
|
|
|
19
22
|
### Tests
|
|
20
23
|
|
|
21
|
-
- Updated integration
|
|
24
|
+
- Updated integration coverage for the orchestration pipeline and Node and esbuild compatibility.
|
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ecopages/lit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Integration plugin for [Lit](https://lit.dev/) web components in Ecopages.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This integration is optimized for use alongside `@ecopages/kitajs` (or another HTML JSX engine), allowing you to author your pages in Kitajs JSX templates while embedding interactive Lit components where needed.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
10
|
bunx jsr add @ecopages/lit
|
|
@@ -10,10 +12,10 @@ bunx jsr add @ecopages/lit
|
|
|
10
12
|
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
It is recommended to use `@ecopages/lit` in conjunction with `@ecopages/kitajs`. Configure your project to include both integrations in your `eco.config.ts`:
|
|
14
16
|
|
|
15
17
|
```ts
|
|
16
|
-
import { ConfigBuilder } from '@ecopages/core';
|
|
18
|
+
import { ConfigBuilder } from '@ecopages/core/config-builder';
|
|
17
19
|
import { kitajsPlugin } from '@ecopages/kitajs';
|
|
18
20
|
import { litPlugin } from '@ecopages/lit';
|
|
19
21
|
|
|
@@ -25,4 +27,4 @@ const config = await new ConfigBuilder()
|
|
|
25
27
|
export default config;
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
This setup enables server-rendered KitaJS pages that embed and hydrate Lit custom elements on the client.
|
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.7",
|
|
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.7",
|
|
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
|
@@ -9,6 +9,8 @@ import { IntegrationRenderer, type RenderToResponseContext } from '@ecopages/cor
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class LitRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
11
11
|
name: string;
|
|
12
|
+
private createRenderableMarkup;
|
|
13
|
+
private renderMarkupToString;
|
|
12
14
|
/**
|
|
13
15
|
* Renders a Lit component boundary for component-level orchestration.
|
|
14
16
|
*
|
package/src/lit-renderer.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { IntegrationRenderer } from "@ecopages/core/route-renderer/integration-renderer";
|
|
2
2
|
import { render } from "@lit-labs/ssr";
|
|
3
3
|
import { RenderResultReadable } from "@lit-labs/ssr/lib/render-result-readable.js";
|
|
4
|
-
import {
|
|
4
|
+
import { html as staticHtml, unsafeStatic } from "lit/static-html.js";
|
|
5
5
|
import { LitSsrLazyPreloader } from "./lit-ssr-lazy-preloader.js";
|
|
6
6
|
import { PLUGIN_NAME } from "./lit.plugin.js";
|
|
7
7
|
class LitRenderer extends IntegrationRenderer {
|
|
8
8
|
name = PLUGIN_NAME;
|
|
9
|
+
createRenderableMarkup(markup) {
|
|
10
|
+
return staticHtml`${unsafeStatic(markup)}`;
|
|
11
|
+
}
|
|
12
|
+
async renderMarkupToString(markup) {
|
|
13
|
+
let renderedHtml = "";
|
|
14
|
+
for (const chunk of render(this.createRenderableMarkup(markup))) {
|
|
15
|
+
renderedHtml += chunk;
|
|
16
|
+
}
|
|
17
|
+
return renderedHtml;
|
|
18
|
+
}
|
|
9
19
|
/**
|
|
10
20
|
* Renders a Lit component boundary for component-level orchestration.
|
|
11
21
|
*
|
|
@@ -15,14 +25,15 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
15
25
|
const component = input.component;
|
|
16
26
|
const props = input.children === void 0 ? input.props : { ...input.props, children: input.children };
|
|
17
27
|
const content = await component(props);
|
|
18
|
-
const
|
|
28
|
+
const markup = String(content);
|
|
29
|
+
const html = await this.renderMarkupToString(markup);
|
|
19
30
|
const hasDependencies = Boolean(input.component.config?.dependencies);
|
|
20
31
|
const canResolveAssets = typeof this.assetProcessingService?.processDependencies === "function";
|
|
21
32
|
const assets = hasDependencies && canResolveAssets ? await this.processComponentDependencies([input.component]) : void 0;
|
|
22
33
|
return {
|
|
23
34
|
html,
|
|
24
35
|
canAttachAttributes: true,
|
|
25
|
-
rootTag: this.getRootTagName(
|
|
36
|
+
rootTag: this.getRootTagName(markup),
|
|
26
37
|
integrationName: this.name,
|
|
27
38
|
assets
|
|
28
39
|
};
|
|
@@ -94,7 +105,7 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
94
105
|
function* streamBody() {
|
|
95
106
|
yield DOC_TYPE;
|
|
96
107
|
yield templateStart;
|
|
97
|
-
yield* render(
|
|
108
|
+
yield* render(staticHtml`${unsafeStatic(children)}`);
|
|
98
109
|
yield templateEnd;
|
|
99
110
|
}
|
|
100
111
|
return new RenderResultReadable(streamBody());
|
|
@@ -111,7 +122,7 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
111
122
|
const pageContent = await viewFn(props);
|
|
112
123
|
if (ctx.partial) {
|
|
113
124
|
function* streamBody2() {
|
|
114
|
-
yield* render(
|
|
125
|
+
yield* render(staticHtml`${unsafeStatic(pageContent)}`);
|
|
115
126
|
}
|
|
116
127
|
const readable = new RenderResultReadable(streamBody2());
|
|
117
128
|
return this.createHtmlResponse(readable, ctx);
|
|
@@ -135,7 +146,7 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
135
146
|
function* streamBody() {
|
|
136
147
|
yield DOC_TYPE;
|
|
137
148
|
yield templateStart;
|
|
138
|
-
yield* render(
|
|
149
|
+
yield* render(staticHtml`${unsafeStatic(children)}`);
|
|
139
150
|
yield templateEnd;
|
|
140
151
|
}
|
|
141
152
|
const stream = new RenderResultReadable(streamBody());
|
package/src/lit-renderer.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
import { IntegrationRenderer, type RenderToResponseContext } from '@ecopages/core/route-renderer/integration-renderer';
|
|
16
16
|
import { render } from '@lit-labs/ssr';
|
|
17
17
|
import { RenderResultReadable } from '@lit-labs/ssr/lib/render-result-readable.js';
|
|
18
|
-
import {
|
|
18
|
+
import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
|
|
19
19
|
import { LitSsrLazyPreloader } from './lit-ssr-lazy-preloader.ts';
|
|
20
20
|
import { PLUGIN_NAME } from './lit.plugin.ts';
|
|
21
21
|
|
|
@@ -25,6 +25,18 @@ import { PLUGIN_NAME } from './lit.plugin.ts';
|
|
|
25
25
|
export class LitRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
26
26
|
override name = PLUGIN_NAME;
|
|
27
27
|
|
|
28
|
+
private createRenderableMarkup(markup: string) {
|
|
29
|
+
return staticHtml`${unsafeStatic(markup)}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private async renderMarkupToString(markup: string): Promise<string> {
|
|
33
|
+
let renderedHtml = '';
|
|
34
|
+
for (const chunk of render(this.createRenderableMarkup(markup))) {
|
|
35
|
+
renderedHtml += chunk;
|
|
36
|
+
}
|
|
37
|
+
return renderedHtml;
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
/**
|
|
29
41
|
* Renders a Lit component boundary for component-level orchestration.
|
|
30
42
|
*
|
|
@@ -36,7 +48,8 @@ export class LitRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
|
36
48
|
) => Promise<EcoPagesElement> | EcoPagesElement;
|
|
37
49
|
const props = input.children === undefined ? input.props : { ...input.props, children: input.children };
|
|
38
50
|
const content = await component(props);
|
|
39
|
-
const
|
|
51
|
+
const markup = String(content);
|
|
52
|
+
const html = await this.renderMarkupToString(markup);
|
|
40
53
|
const hasDependencies = Boolean(input.component.config?.dependencies);
|
|
41
54
|
const canResolveAssets = typeof this.assetProcessingService?.processDependencies === 'function';
|
|
42
55
|
const assets =
|
|
@@ -47,7 +60,7 @@ export class LitRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
|
47
60
|
return {
|
|
48
61
|
html,
|
|
49
62
|
canAttachAttributes: true,
|
|
50
|
-
rootTag: this.getRootTagName(
|
|
63
|
+
rootTag: this.getRootTagName(markup),
|
|
51
64
|
integrationName: this.name,
|
|
52
65
|
assets,
|
|
53
66
|
};
|
|
@@ -132,7 +145,7 @@ export class LitRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
|
132
145
|
function* streamBody() {
|
|
133
146
|
yield DOC_TYPE;
|
|
134
147
|
yield templateStart;
|
|
135
|
-
yield* render(
|
|
148
|
+
yield* render(staticHtml`${unsafeStatic(children)}`);
|
|
136
149
|
yield templateEnd;
|
|
137
150
|
}
|
|
138
151
|
|
|
@@ -160,7 +173,7 @@ export class LitRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
|
160
173
|
|
|
161
174
|
if (ctx.partial) {
|
|
162
175
|
function* streamBody() {
|
|
163
|
-
yield* render(
|
|
176
|
+
yield* render(staticHtml`${unsafeStatic(pageContent)}`);
|
|
164
177
|
}
|
|
165
178
|
const readable = new RenderResultReadable(streamBody());
|
|
166
179
|
return this.createHtmlResponse(readable as unknown as BodyInit, ctx);
|
|
@@ -192,7 +205,7 @@ export class LitRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
|
192
205
|
function* streamBody() {
|
|
193
206
|
yield DOC_TYPE;
|
|
194
207
|
yield templateStart;
|
|
195
|
-
yield* render(
|
|
208
|
+
yield* render(staticHtml`${unsafeStatic(children)}`);
|
|
196
209
|
yield templateEnd;
|
|
197
210
|
}
|
|
198
211
|
const stream = new RenderResultReadable(streamBody());
|
package/src/lit.plugin.js
CHANGED