eddev 2.0.0-beta.91 → 2.0.0-beta.93
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.
|
@@ -7,9 +7,9 @@ export type RouteMetaTag = {
|
|
|
7
7
|
inner?: string;
|
|
8
8
|
};
|
|
9
9
|
export type TrackerTags = {
|
|
10
|
-
head?:
|
|
11
|
-
body?:
|
|
12
|
-
footer?:
|
|
10
|
+
head?: string;
|
|
11
|
+
body?: string;
|
|
12
|
+
footer?: string;
|
|
13
13
|
};
|
|
14
14
|
export interface RouteData {
|
|
15
15
|
view: string;
|
|
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { renderAsset } from "@vinxi/react";
|
|
3
3
|
import { Suspense } from "react";
|
|
4
4
|
import { renderToPipeableStream, renderToString } from "react-dom/server";
|
|
5
|
-
import { SSRRoot } from "../entry/ssr-root.js";
|
|
6
|
-
import { RouteLoader } from "../lib/routing/loader.js";
|
|
7
|
-
import { ServerContext } from "./server-context.js";
|
|
8
5
|
import { Writable } from "stream";
|
|
9
6
|
import { MetaTags } from "../entry/MetaTags.js";
|
|
7
|
+
import { SSRRoot } from "../entry/ssr-root.js";
|
|
8
|
+
import { RouteLoader } from "../lib/routing/loader.js";
|
|
10
9
|
import { AssetCaptureContext } from "../utils/asset-capture.js";
|
|
10
|
+
import { ServerContext } from "./server-context.js";
|
|
11
11
|
export async function getSsrStream(args) {
|
|
12
12
|
const clientManifest = ServerContext.main.runtime.getManifest("client");
|
|
13
13
|
const assets = await clientManifest.inputs[clientManifest.handler].assets();
|
|
@@ -37,10 +37,17 @@ export async function getSsrStream(args) {
|
|
|
37
37
|
console.error(err);
|
|
38
38
|
},
|
|
39
39
|
bootstrapModules: [clientManifest.inputs[clientManifest.handler].output.path],
|
|
40
|
-
bootstrapScriptContent:
|
|
40
|
+
bootstrapScriptContent: `\nwindow.manifest = ${JSON.stringify(await clientManifest.json())};\nwindow._PAGE_DATA = ${JSON.stringify({
|
|
41
|
+
...args.initialData,
|
|
42
|
+
trackers: undefined,
|
|
43
|
+
})};\n`,
|
|
41
44
|
});
|
|
42
45
|
});
|
|
43
|
-
const [initial, middle, end] = renderToString(_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx(MetaTags, { tags: args.initialData.meta?.head ?? [] }),
|
|
46
|
+
const [initial, middle, end] = renderToString(_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx(MetaTags, { tags: args.initialData.meta?.head ?? [] }), "%%trackers_head%%", assets.map((m) => renderAsset(m)), "%%$%%"] }), _jsxs("body", { children: ["%%trackers_body%%", _jsx("div", { id: "_root", children: "%%$%%" }), "%%trackers_footer%%"] })] }))
|
|
47
|
+
.replace(/%%trackers_(head|body|footer)%%/g, (_, name) => {
|
|
48
|
+
return args.initialData.trackers?.[name] || "";
|
|
49
|
+
})
|
|
50
|
+
.split("%%$%%");
|
|
44
51
|
return new ReadableStream({
|
|
45
52
|
async start(controller) {
|
|
46
53
|
controller.enqueue(new TextEncoder().encode(initial));
|
|
@@ -61,14 +68,13 @@ export async function getSsrStream(args) {
|
|
|
61
68
|
});
|
|
62
69
|
stream.pipe(writableStream);
|
|
63
70
|
});
|
|
64
|
-
console.log(clientManifest.json());
|
|
65
71
|
for (const asset of dynamicAssets) {
|
|
66
72
|
// const assets = await clientManifest.inputs["/" + asset].assets()
|
|
67
73
|
// console.log(assets)
|
|
68
74
|
// console.log("A", assets.output, (await assets.assets())?.[0])
|
|
69
75
|
// const assets = await clientManifest.inputs[assets.output.path!]?.assets()
|
|
70
76
|
// console.log("F?", inputs)
|
|
71
|
-
controller.enqueue(new TextEncoder().encode(`\n<!-- for ${asset} -->`))
|
|
77
|
+
// controller.enqueue(new TextEncoder().encode(`\n<!-- for ${asset} -->`))
|
|
72
78
|
// controller.enqueue(new TextEncoder().encode(`\n<script>${JSON.stringify(assets)}</script>`))
|
|
73
79
|
// controller.enqueue(
|
|
74
80
|
// new TextEncoder().encode(renderToString(<>{assets.map((a) => renderAsset(asset as any))}</>)),
|
|
@@ -116,6 +122,14 @@ export async function renderPage(args) {
|
|
|
116
122
|
title: "Internal Server Error",
|
|
117
123
|
});
|
|
118
124
|
}
|
|
125
|
+
if (data.redirect) {
|
|
126
|
+
return new Response(null, {
|
|
127
|
+
status: data.status || 302,
|
|
128
|
+
headers: {
|
|
129
|
+
Location: data.redirect,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
119
133
|
headers.set("Content-Type", "text/html; charset=utf-8");
|
|
120
134
|
const stream = await getSsrStream({
|
|
121
135
|
...args,
|
|
@@ -3,7 +3,7 @@ import { fetchWP } from "../../node/utils/fetch-wp.js";
|
|
|
3
3
|
import { filterHeader } from "./utils/headers.js";
|
|
4
4
|
import { createUrlReplacer } from "./utils/replace-host.js";
|
|
5
5
|
import { pageCache, queryCache, swr } from "./utils/swr-cache.js";
|
|
6
|
-
const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control", /woocommerce
|
|
6
|
+
const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control", /woocommerce/, "location"];
|
|
7
7
|
const PROXY_REQUEST_HEADERS = [
|
|
8
8
|
"content-type",
|
|
9
9
|
"accept",
|
|
@@ -115,8 +115,8 @@ export class ServerContext {
|
|
|
115
115
|
ctx.metadata.ttl = preferredCacheDuration * 1000;
|
|
116
116
|
}
|
|
117
117
|
let resultStatus = result.status;
|
|
118
|
-
let resultHeaders = result.headers;
|
|
119
|
-
let resultData =
|
|
118
|
+
let resultHeaders = new Headers(result.headers);
|
|
119
|
+
let resultData = {};
|
|
120
120
|
// Special case for redirects
|
|
121
121
|
if (result.headers.get("location")) {
|
|
122
122
|
let location = result.headers.get("location");
|
|
@@ -125,12 +125,13 @@ export class ServerContext {
|
|
|
125
125
|
location = this.replaceUrls(location);
|
|
126
126
|
}
|
|
127
127
|
resultHeaders.delete("location");
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
data:
|
|
128
|
+
return {
|
|
129
|
+
status: 200,
|
|
130
|
+
headers: resultHeaders,
|
|
131
|
+
data: JSON.stringify({ redirect: location, status: status }),
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
+
resultData = await result.json();
|
|
134
135
|
if (resultData && typeof resultData === "object") {
|
|
135
136
|
resultData.__generated = new Date().toISOString();
|
|
136
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.0.0-beta.
|
|
1
|
+
export declare const VERSION = "2.0.0-beta.92";
|
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.92";
|