eddev 2.0.0-beta.104 → 2.0.0-beta.106
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.
|
@@ -18,4 +18,10 @@ type RenderErrorPageArgs = {
|
|
|
18
18
|
realError?: Error;
|
|
19
19
|
};
|
|
20
20
|
export declare function renderErrorPage(args: RenderErrorPageArgs): Promise<Response>;
|
|
21
|
+
type Asset = {
|
|
22
|
+
tag: string;
|
|
23
|
+
attrs: Record<string, string | boolean>;
|
|
24
|
+
children?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function renderAsset({ tag, attrs, children }: Asset): string;
|
|
21
27
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { renderAsset } from "@vinxi/react";
|
|
3
2
|
import { renderToPipeableStream, renderToString } from "react-dom/server";
|
|
4
3
|
import { Writable } from "stream";
|
|
5
4
|
import { MetaTags } from "../entry/MetaTags.js";
|
|
@@ -7,7 +6,6 @@ import { SSRRoot } from "../entry/ssr-root.js";
|
|
|
7
6
|
import { RouteLoader } from "../lib/routing/loader.js";
|
|
8
7
|
import { AssetCaptureContext } from "../utils/asset-capture.js";
|
|
9
8
|
import { ServerContext } from "./server-context.js";
|
|
10
|
-
import { Fragment } from "react/jsx-runtime";
|
|
11
9
|
export async function getSsrStream(args) {
|
|
12
10
|
const clientManifest = ServerContext.main.runtime.getManifest("client");
|
|
13
11
|
const preloadAssets = new Set([clientManifest.handler]);
|
|
@@ -71,11 +69,17 @@ export async function getSsrStream(args) {
|
|
|
71
69
|
if (!key) {
|
|
72
70
|
throw new Error("Asset must have a key: " + JSON.stringify(asset));
|
|
73
71
|
}
|
|
74
|
-
if (
|
|
72
|
+
if (includedAssets.has(key))
|
|
75
73
|
continue;
|
|
76
|
-
|
|
74
|
+
includedAssets.add(key);
|
|
77
75
|
// Render the asset
|
|
78
|
-
|
|
76
|
+
try {
|
|
77
|
+
const tag = renderAsset(asset);
|
|
78
|
+
controller.enqueue(new TextEncoder().encode(tag + "\n"));
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
controller.enqueue(new TextEncoder().encode(`\n<!-- ${JSON.stringify(err)} -->\n`));
|
|
82
|
+
}
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
// console.log("ASSETS", await clientManifest)
|
|
@@ -164,3 +168,34 @@ export async function renderErrorPage(args) {
|
|
|
164
168
|
newOrigin: args.newOrigin,
|
|
165
169
|
});
|
|
166
170
|
}
|
|
171
|
+
export function renderAsset({ tag, attrs, children }) {
|
|
172
|
+
const formatAttributes = (attributes) => {
|
|
173
|
+
return Object.entries(attributes)
|
|
174
|
+
.map(([attr, value]) => {
|
|
175
|
+
if (value === true) {
|
|
176
|
+
return attr;
|
|
177
|
+
}
|
|
178
|
+
else if (value !== false && value != null) {
|
|
179
|
+
return `${attr}="${String(value).replace(/"/g, """)}"`;
|
|
180
|
+
}
|
|
181
|
+
return "";
|
|
182
|
+
})
|
|
183
|
+
.filter(Boolean)
|
|
184
|
+
.join(" ");
|
|
185
|
+
};
|
|
186
|
+
switch (tag) {
|
|
187
|
+
case "script":
|
|
188
|
+
if (attrs.src) {
|
|
189
|
+
return `<script ${formatAttributes(attrs)}></script>`;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return `<script ${formatAttributes(attrs)}>${children ?? ""}</script>`;
|
|
193
|
+
}
|
|
194
|
+
case "link":
|
|
195
|
+
return `<link ${formatAttributes(attrs)} />`;
|
|
196
|
+
case "style":
|
|
197
|
+
return `<style ${formatAttributes(attrs)}>${children ?? ""}</style>`;
|
|
198
|
+
default:
|
|
199
|
+
return "";
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.0.0-beta.
|
|
1
|
+
export declare const VERSION = "2.0.0-beta.106";
|
package/dist/node/cli/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "2.0.0-beta.
|
|
1
|
+
export const VERSION = "2.0.0-beta.106";
|