eddev 2.0.0-beta.33 → 2.0.0-beta.34
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/dist/app/entry/MetaTags.d.ts +1 -0
- package/dist/app/entry/MetaTags.js +13 -13
- package/dist/app/lib/routing/types.d.ts +8 -0
- package/dist/app/server/render-ssr-page.d.ts +4 -2
- package/dist/app/server/render-ssr-page.js +1 -5
- package/dist/app/server/server-context.d.ts +10 -3
- package/dist/app/server/server-context.js +1 -3
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/vinxi-codegen.js +3 -2
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
2
|
export function MetaTags(props) {
|
|
4
|
-
return (_jsx(
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
if (tag.
|
|
8
|
-
|
|
9
|
-
props.children = tag.inner;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
props.dangerouslySetInnerHTML = { __html: tag.inner };
|
|
13
|
-
}
|
|
3
|
+
return (_jsx(_Fragment, { children: props.tags?.map((tag, i) => {
|
|
4
|
+
const Tag = tag.tagName;
|
|
5
|
+
const tagProps = Array.isArray(tag.attributes) ? {} : { ...tag.attributes };
|
|
6
|
+
if (tag.tagName === "title") {
|
|
7
|
+
tagProps.children = tag.inner ?? "";
|
|
14
8
|
}
|
|
15
|
-
|
|
9
|
+
else if (tag.tagName === "script" || !!tag.inner) {
|
|
10
|
+
tagProps.dangerouslySetInnerHTML = { __html: tag.inner ?? "" };
|
|
11
|
+
}
|
|
12
|
+
if (tagProps.async === "") {
|
|
13
|
+
tagProps.async = true;
|
|
14
|
+
}
|
|
15
|
+
return _jsx(Tag, { "data-test": props.debugKey + "_" + i, ...tagProps }, i);
|
|
16
16
|
}) }));
|
|
17
17
|
}
|
|
@@ -6,6 +6,11 @@ export type RouteMetaTag = {
|
|
|
6
6
|
attributes: Record<string, string>;
|
|
7
7
|
inner?: string;
|
|
8
8
|
};
|
|
9
|
+
export type TrackerTags = {
|
|
10
|
+
head?: RouteMetaTag[];
|
|
11
|
+
body?: RouteMetaTag[];
|
|
12
|
+
footer?: RouteMetaTag[];
|
|
13
|
+
};
|
|
9
14
|
export interface RouteData {
|
|
10
15
|
view: string;
|
|
11
16
|
editLink?: string;
|
|
@@ -19,6 +24,9 @@ export interface RouteData {
|
|
|
19
24
|
footer: RouteMetaTag[];
|
|
20
25
|
};
|
|
21
26
|
}
|
|
27
|
+
export interface RouteDataWithTrackers extends RouteData {
|
|
28
|
+
trackers?: TrackerTags;
|
|
29
|
+
}
|
|
22
30
|
export type RouteReturnState<T = {}> = {
|
|
23
31
|
scrollTop: number;
|
|
24
32
|
scrollLeft: number;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type { RouteData } from "../lib/routing/types.js";
|
|
1
|
+
import type { RouteData, TrackerTags } from "../lib/routing/types.js";
|
|
2
2
|
import { ServerContext } from "./server-context.js";
|
|
3
|
-
export declare function renderPageToSSRStream(pathname: string, initialData: RouteData
|
|
3
|
+
export declare function renderPageToSSRStream(pathname: string, initialData: RouteData & {
|
|
4
|
+
trackers?: TrackerTags;
|
|
5
|
+
}, serverContext: ServerContext): Promise<unknown>;
|
|
@@ -6,15 +6,11 @@ import { SSRRoot } from "../entry/ssr-root.js";
|
|
|
6
6
|
import { RouteLoader } from "../lib/routing/loader.js";
|
|
7
7
|
export async function renderPageToSSRStream(pathname, initialData, serverContext) {
|
|
8
8
|
const clientManifest = serverContext.runtime.getManifest("client");
|
|
9
|
-
// console.log("Rendering to SSR Stream, get assets")
|
|
10
9
|
const assets = await clientManifest.inputs[clientManifest.handler].assets();
|
|
11
|
-
// console.log("Got assets", assets)
|
|
12
10
|
const jsx = (_jsx(SSRRoot, { assets: _jsx(Suspense, { children: assets.map((m) => renderAsset(m)) }), metaTags: initialData?.meta?.head || [], pathname: pathname, initialData: initialData, loader: new RouteLoader() }));
|
|
13
11
|
const stream = await new Promise(async (resolve, reject) => {
|
|
14
|
-
// console.log("Rendering to pipable")
|
|
15
12
|
const stream = renderToPipeableStream(jsx, {
|
|
16
13
|
onShellReady() {
|
|
17
|
-
// console.log("Shell ready")
|
|
18
14
|
resolve(stream);
|
|
19
15
|
},
|
|
20
16
|
onShellError(err) {
|
|
@@ -26,7 +22,7 @@ export async function renderPageToSSRStream(pathname, initialData, serverContext
|
|
|
26
22
|
console.error(err);
|
|
27
23
|
},
|
|
28
24
|
bootstrapModules: [clientManifest.inputs[clientManifest.handler].output.path],
|
|
29
|
-
bootstrapScriptContent: `window.
|
|
25
|
+
bootstrapScriptContent: `window._PAGE_DATA = ${JSON.stringify(initialData)};`,
|
|
30
26
|
});
|
|
31
27
|
});
|
|
32
28
|
return stream;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RequestHeaders } from "vinxi/http";
|
|
2
2
|
import { UrlReplacerConf } from "./utils/replace-host.js";
|
|
3
3
|
import { Manifest } from "vinxi/dist/types/types/manifest";
|
|
4
|
+
import { TrackerTags } from "../lib/routing/types.js";
|
|
4
5
|
export type ServerContextArgs = {
|
|
5
6
|
dev: boolean;
|
|
6
7
|
origin: string;
|
|
@@ -9,6 +10,13 @@ export type ServerContextArgs = {
|
|
|
9
10
|
export type ServerContextRuntime = {
|
|
10
11
|
getManifest: (name: string) => Manifest;
|
|
11
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Data returned from WordPress origin /_appdata route
|
|
15
|
+
*/
|
|
16
|
+
type ServerAppData = {
|
|
17
|
+
appData: any;
|
|
18
|
+
trackers: TrackerTags;
|
|
19
|
+
};
|
|
12
20
|
export declare class ServerContext {
|
|
13
21
|
dev: boolean;
|
|
14
22
|
origin: string;
|
|
@@ -26,9 +34,7 @@ export declare class ServerContext {
|
|
|
26
34
|
headers?: RequestHeaders;
|
|
27
35
|
withAppData?: boolean;
|
|
28
36
|
}): Promise<Response>;
|
|
29
|
-
fetchAppData(
|
|
30
|
-
headers?: RequestHeaders;
|
|
31
|
-
}): Promise<any>;
|
|
37
|
+
fetchAppData(): Promise<ServerAppData>;
|
|
32
38
|
extractRequestHeaders(req?: RequestHeaders): Partial<Record<import("vinxi/http").HTTPHeaderName, string | undefined>>;
|
|
33
39
|
fetchNamedQuery(req: {
|
|
34
40
|
name: string;
|
|
@@ -41,3 +47,4 @@ export declare class ServerContext {
|
|
|
41
47
|
headers: RequestHeaders;
|
|
42
48
|
}): Promise<Response>;
|
|
43
49
|
}
|
|
50
|
+
export {};
|
|
@@ -83,13 +83,12 @@ export class ServerContext {
|
|
|
83
83
|
headers: {
|
|
84
84
|
"Content-Type": "application/json",
|
|
85
85
|
Accept: "application/json",
|
|
86
|
-
...this.extractRequestHeaders(req.headers),
|
|
87
86
|
},
|
|
88
87
|
});
|
|
89
88
|
// console.log("Finished fetching route data")
|
|
90
89
|
return result;
|
|
91
90
|
}
|
|
92
|
-
async fetchAppData(
|
|
91
|
+
async fetchAppData() {
|
|
93
92
|
// console.log("Fetching app data")
|
|
94
93
|
const response = await this.fetchOrigin("/_appdata", {
|
|
95
94
|
cache: "no-cache",
|
|
@@ -97,7 +96,6 @@ export class ServerContext {
|
|
|
97
96
|
headers: {
|
|
98
97
|
"Content-Type": "application/json",
|
|
99
98
|
Accept: "application/json",
|
|
100
|
-
...(req?.headers ? this.extractRequestHeaders(req.headers) : {}),
|
|
101
99
|
},
|
|
102
100
|
});
|
|
103
101
|
// console.log("Decoding app data")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.0.0-beta.
|
|
1
|
+
export declare const VERSION = "2.0.0-beta.34";
|
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.34";
|
|
@@ -261,11 +261,11 @@ export function createVinxiCodegen(opts) {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
try {
|
|
264
|
-
const [appData, response] = await Promise.all([
|
|
264
|
+
const [{appData, trackers}, response] = await Promise.all([
|
|
265
265
|
serverContext.fetchAppData(),
|
|
266
266
|
serverContext.fetchRouteData({
|
|
267
267
|
pathname: url.pathname,
|
|
268
|
-
withAppData:
|
|
268
|
+
withAppData: false,
|
|
269
269
|
headers: {},
|
|
270
270
|
query: {},
|
|
271
271
|
}),
|
|
@@ -275,6 +275,7 @@ export function createVinxiCodegen(opts) {
|
|
|
275
275
|
try {
|
|
276
276
|
data = await response.json()
|
|
277
277
|
data.appData = appData
|
|
278
|
+
data.trackers = trackers
|
|
278
279
|
} catch (err) {
|
|
279
280
|
data = {
|
|
280
281
|
view: "_error",
|