@ecopages/lit 0.2.0-alpha.23 → 0.2.0-alpha.26
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/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.26",
|
|
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.26",
|
|
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
|
@@ -10,6 +10,7 @@ import { IntegrationRenderer, type RenderToResponseContext } from '@ecopages/cor
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class LitRenderer extends IntegrationRenderer<EcoPagesElement> {
|
|
12
12
|
name: string;
|
|
13
|
+
private isFunctionComponent;
|
|
13
14
|
private resolveQueuedBoundaryChildren;
|
|
14
15
|
private resolveQueuedBoundaryHtml;
|
|
15
16
|
protected shouldRenderPageComponent(): boolean;
|
package/src/lit-renderer.js
CHANGED
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
} from "./utils/lit-html-rendering.js";
|
|
11
11
|
class LitRenderer extends IntegrationRenderer {
|
|
12
12
|
name = LIT_PLUGIN_NAME;
|
|
13
|
+
isFunctionComponent(component) {
|
|
14
|
+
return typeof component === "function";
|
|
15
|
+
}
|
|
13
16
|
async resolveQueuedBoundaryChildren(children, queuedResolutionsByToken, resolveToken) {
|
|
14
17
|
if (children === void 0) {
|
|
15
18
|
return void 0;
|
|
@@ -61,6 +64,9 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
61
64
|
*/
|
|
62
65
|
async renderComponent(input) {
|
|
63
66
|
await this.preloadSsrLazyScripts([input.component]);
|
|
67
|
+
if (!this.isFunctionComponent(input.component)) {
|
|
68
|
+
throw new TypeError("Lit renderer expected a callable component.");
|
|
69
|
+
}
|
|
64
70
|
const component = input.component;
|
|
65
71
|
let renderedChildren;
|
|
66
72
|
if (input.children !== void 0) {
|
|
@@ -187,11 +193,12 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
187
193
|
const Layout = viewConfig?.layout;
|
|
188
194
|
const HtmlTemplate = await this.getHtmlTemplate();
|
|
189
195
|
const metadata = await this.resolveViewMetadata(view, props);
|
|
196
|
+
const normalizedProps = props ?? {};
|
|
190
197
|
await this.preloadSsrLazyScripts([view, Layout]);
|
|
191
198
|
await this.prepareViewDependencies(view, Layout);
|
|
192
199
|
const pageRender = await this.renderComponentBoundary({
|
|
193
200
|
component: view,
|
|
194
|
-
props:
|
|
201
|
+
props: normalizedProps
|
|
195
202
|
});
|
|
196
203
|
const layoutRender = Layout ? await this.renderComponentBoundary({
|
|
197
204
|
component: Layout,
|
|
@@ -202,7 +209,7 @@ class LitRenderer extends IntegrationRenderer {
|
|
|
202
209
|
component: HtmlTemplate,
|
|
203
210
|
props: {
|
|
204
211
|
metadata,
|
|
205
|
-
pageProps:
|
|
212
|
+
pageProps: normalizedProps
|
|
206
213
|
},
|
|
207
214
|
children: layoutRender?.html ?? pageRender.html
|
|
208
215
|
});
|
|
@@ -23,6 +23,7 @@ export declare class LitSsrLazyPreloader {
|
|
|
23
23
|
private readonly ssrPreloadFailedScripts;
|
|
24
24
|
private readonly ssrPreloadEntrypointCache;
|
|
25
25
|
constructor({ resolveDependencyPath, processDependencies, preferSourceImports }: LitSsrLazyPreloaderOptions);
|
|
26
|
+
private getErrorCode;
|
|
26
27
|
/**
|
|
27
28
|
* Detects preload failures that are expected for browser-only modules.
|
|
28
29
|
*/
|
|
@@ -13,12 +13,19 @@ class LitSsrLazyPreloader {
|
|
|
13
13
|
this.processDependencies = processDependencies;
|
|
14
14
|
this.preferSourceImports = preferSourceImports ?? typeof Bun !== "undefined";
|
|
15
15
|
}
|
|
16
|
+
getErrorCode(error) {
|
|
17
|
+
if (typeof error !== "object" || error === null) {
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
const code = Reflect.get(error, "code");
|
|
21
|
+
return code === void 0 ? "" : String(code);
|
|
22
|
+
}
|
|
16
23
|
/**
|
|
17
24
|
* Detects preload failures that are expected for browser-only modules.
|
|
18
25
|
*/
|
|
19
26
|
isExpectedSsrPreloadError(error) {
|
|
20
27
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
21
|
-
const errorCode =
|
|
28
|
+
const errorCode = this.getErrorCode(error);
|
|
22
29
|
if (errorCode === "ERR_UNKNOWN_FILE_EXTENSION") {
|
|
23
30
|
return true;
|
|
24
31
|
}
|