eddev 2.0.0-beta.44 → 2.0.0-beta.46
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/ssr-root-client.js +20 -9
- package/dist/app/entry/ssr-root.d.ts +1 -1
- package/dist/app/entry/ssr-root.js +3 -3
- package/dist/app/lib/routing/components/BackButton.js +1 -1
- package/dist/app/lib/routing/components/BrowserRouter.js +3 -2
- package/dist/app/lib/routing/context.d.ts +8 -5
- package/dist/app/lib/routing/context.js +7 -0
- package/dist/app/lib/routing/utils.js +1 -1
- package/dist/app/server/render-ssr-page.js +1 -1
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/vinxi-app.js +8 -0
- package/dist/node/project/config.d.ts +31 -37
- package/dist/node/project/config.js +12 -10
- package/package.json +1 -1
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
-
import { Suspense,
|
|
4
|
-
import { getQueryClient } from "../utils/query-client.js";
|
|
5
|
-
import { BrowserRouter } from "../lib/routing/components/BrowserRouter.js";
|
|
3
|
+
import { Suspense, useEffect, useState } from "react";
|
|
6
4
|
import { DevUILoader } from "../lib/devtools/loader.js";
|
|
5
|
+
import { BrowserRouter } from "../lib/routing/components/BrowserRouter.js";
|
|
6
|
+
import { getQueryClient } from "../utils/query-client.js";
|
|
7
7
|
import { MetaTags } from "./MetaTags.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useSnapshot } from "valtio";
|
|
9
|
+
import { clientMetaTags } from "../lib/routing/context.js";
|
|
9
10
|
export function SSRClientRoot(props) {
|
|
10
|
-
|
|
11
|
-
return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("link", { rel: "icon", href: "/favicon.ico" }), _jsx(DynamicMetaTags, { tags: props.metaTags, router: router }), props.assets] }), _jsx("body", { children: _jsxs(QueryClientProvider, { client: getQueryClient(), children: [_jsx(Suspense, { children: _jsx(BrowserRouter, { routerRef: router }) }), _jsx(DevUILoader, {})] }) })] }));
|
|
11
|
+
return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx(DynamicMetaTags, { tags: props.metaTags }), _jsx(Trackers, { position: "head" }), props.assets] }), _jsxs("body", { children: [_jsx(Trackers, { position: "body" }), _jsxs(QueryClientProvider, { client: getQueryClient(), children: [_jsx(Suspense, { children: _jsx(BrowserRouter, {}) }), _jsx(DevUILoader, {})] }), _jsx(Trackers, { position: "footer" })] })] }));
|
|
12
12
|
}
|
|
13
13
|
function DynamicMetaTags(props) {
|
|
14
|
-
const
|
|
15
|
-
return _jsx(MetaTags, { tags:
|
|
14
|
+
const dynamicTags = useSnapshot(clientMetaTags).tags;
|
|
15
|
+
return _jsx(MetaTags, { tags: dynamicTags ?? props.tags ?? [] });
|
|
16
|
+
}
|
|
17
|
+
function Trackers(props) {
|
|
18
|
+
const [render, setRender] = useState(false);
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const trackers = window._TRACKERS;
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setRender(true);
|
|
23
|
+
}, []);
|
|
24
|
+
if (!render || !trackers || typeof trackers !== "object")
|
|
25
|
+
return null;
|
|
26
|
+
return (_jsx(_Fragment, { children: _jsx(MetaTags, { tags: trackers[props.position] ?? [] }) }));
|
|
16
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import type { RouteData, RouteMetaTag } from "../lib/routing/types.js";
|
|
3
2
|
import type { RouteLoader } from "../lib/routing/loader.js";
|
|
3
|
+
import type { RouteData, RouteMetaTag } from "../lib/routing/types.js";
|
|
4
4
|
export declare function SSRRoot(props: {
|
|
5
5
|
pathname: string;
|
|
6
6
|
initialData: RouteData;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Suspense } from "react";
|
|
3
2
|
import { QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
-
import {
|
|
3
|
+
import { Suspense } from "react";
|
|
5
4
|
import { SSRRouter } from "../lib/routing/components/SSRRouter.js";
|
|
6
5
|
import { getRouteMeta, normalizeRoute } from "../lib/routing/utils.js";
|
|
6
|
+
import { getQueryClient } from "../utils/query-client.js";
|
|
7
7
|
import { MetaTags } from "./MetaTags.js";
|
|
8
8
|
export function SSRRoot(props) {
|
|
9
9
|
const loader = props.loader;
|
|
10
10
|
loader.setAppData(props.initialData.appData.data);
|
|
11
11
|
loader.populateRouteData(props.pathname, props.initialData);
|
|
12
|
-
return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx(
|
|
12
|
+
return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx(MetaTags, { tags: props.metaTags }), props.assets] }), _jsx("body", { children: _jsx(QueryClientProvider, { client: getQueryClient(), children: _jsx(Suspense, { children: _jsx(SSRRouter, { loader: loader, route: normalizeRoute({
|
|
13
13
|
id: "initial",
|
|
14
14
|
component: loader.getRouteComponent(props.initialData.view),
|
|
15
15
|
key: "",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
+
import { useRoute } from "../hooks/useRoute";
|
|
2
3
|
import { useRouter } from "../hooks/useRouter";
|
|
3
4
|
import { useRouterState } from "../hooks/useRouterState";
|
|
4
5
|
import { getLinkHandlerMode } from "../utils";
|
|
5
|
-
import { useRoute } from "../hooks/useRoute";
|
|
6
6
|
/**
|
|
7
7
|
* Display a back button that will navigate to the previous page in the router's history.
|
|
8
8
|
*
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState, useTransition } from "react";
|
|
3
3
|
import { isEqual, isRelative, parseURL, resolveURL } from "ufo";
|
|
4
|
-
import { RouterContext, RouterStateContext } from "../context.js";
|
|
4
|
+
import { clientMetaTags, RouterContext, RouterStateContext } from "../context.js";
|
|
5
|
+
import { $routeMetaStore } from "../hooks/useRouteMeta.js";
|
|
5
6
|
import { RouteLoader } from "../loader.js";
|
|
6
7
|
import { getLinkHandlerMode, getRouteMeta, isSamePathname, normalizeRoute, parseQuery, stringifyRouteLink, } from "../utils.js";
|
|
7
8
|
import { AppRenderer } from "./RouteRenderer.js";
|
|
8
|
-
import { $routeMetaStore } from "../hooks/useRouteMeta.js";
|
|
9
9
|
// Create a global RouteLoader instance
|
|
10
10
|
const loader = new RouteLoader();
|
|
11
11
|
// Create a unique ID for each history entry
|
|
@@ -86,6 +86,7 @@ export function BrowserRouter(props) {
|
|
|
86
86
|
...state,
|
|
87
87
|
...update,
|
|
88
88
|
};
|
|
89
|
+
clientMetaTags.setMetaTags(state.activeRoute.meta.tags ?? []);
|
|
89
90
|
setRouterState(state);
|
|
90
91
|
};
|
|
91
92
|
const internals = {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
1
|
+
import { RouteMetaTag, RouterAPI, RouterAPIState } from "./types.js";
|
|
2
|
+
export declare const RouterContext: import("react").Context<RouterAPI>;
|
|
3
|
+
export declare const RouterStateContext: import("react").Context<RouterAPIState>;
|
|
4
|
+
export declare const RouteItemContext: import("react").Context<import("./types.js").TypedRouteState<"_unknown", {}>>;
|
|
5
|
+
export declare const clientMetaTags: {
|
|
6
|
+
tags: null | RouteMetaTag[];
|
|
7
|
+
setMetaTags(tags: RouteMetaTag[]): void;
|
|
8
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
2
|
import { RouteLoader } from "./loader.js";
|
|
3
|
+
import { proxy } from "valtio";
|
|
3
4
|
const NOOP_ROUTE = {
|
|
4
5
|
component: () => null,
|
|
5
6
|
id: "initial",
|
|
@@ -37,3 +38,9 @@ export const RouterStateContext = createContext({
|
|
|
37
38
|
blockers: [],
|
|
38
39
|
});
|
|
39
40
|
export const RouteItemContext = createContext(NOOP_ROUTE);
|
|
41
|
+
export const clientMetaTags = proxy({
|
|
42
|
+
tags: null,
|
|
43
|
+
setMetaTags(tags) {
|
|
44
|
+
clientMetaTags.tags = tags;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { parse as qsParse, stringify as qsStringify } from "qs";
|
|
1
2
|
import { parseURL, resolveURL, stringifyParsedURL, withoutTrailingSlash } from "ufo";
|
|
2
|
-
import { stringify as qsStringify, parse as qsParse } from "qs";
|
|
3
3
|
export function isSameOrigin(url) {
|
|
4
4
|
if (typeof document === "undefined") {
|
|
5
5
|
return url.startsWith("/");
|
|
@@ -24,7 +24,7 @@ export async function renderPageToSSRStream(pathname, initialData, serverContext
|
|
|
24
24
|
console.error(err);
|
|
25
25
|
},
|
|
26
26
|
bootstrapModules: [clientManifest.inputs[clientManifest.handler].output.path],
|
|
27
|
-
bootstrapScriptContent: `window.manifest = ${JSON.stringify(await clientManifest.json())};\nwindow._PAGE_DATA = ${JSON.stringify(initialData)}
|
|
27
|
+
bootstrapScriptContent: `window.manifest = ${JSON.stringify(await clientManifest.json())};\nwindow._PAGE_DATA = ${JSON.stringify(initialData)};\nwindow._TRACKERS = ${JSON.stringify(initialData.trackers)}`,
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
return stream;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.0.0-beta.
|
|
1
|
+
export declare const VERSION = "2.0.0-beta.46";
|
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.46";
|
|
@@ -25,6 +25,14 @@ export function createVinxiApp(args) {
|
|
|
25
25
|
varies: [],
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
+
"/favicon**": {
|
|
29
|
+
proxy: joinURL(args.origin, "**"),
|
|
30
|
+
static: true,
|
|
31
|
+
cache: {
|
|
32
|
+
maxAge: 3600,
|
|
33
|
+
varies: [],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
28
36
|
"/wp-content/plugins/**": {
|
|
29
37
|
proxy: joinURL(args.origin, "wp-content/plugins/**"),
|
|
30
38
|
headers: {
|
|
@@ -5,31 +5,25 @@ export declare const EDConfigSchema: z.ZodObject<{
|
|
|
5
5
|
version: z.ZodEffects<z.ZodEnum<["1", "2"]>, "2", "1" | "2">;
|
|
6
6
|
legacyMetadata: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
7
7
|
legacyStitches: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
trackingID: z.ZodOptional<z.ZodString>;
|
|
12
|
-
version: z.ZodEnum<["3", "4"]>;
|
|
13
|
-
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
version: "3" | "4";
|
|
15
|
-
trackingID?: string | undefined;
|
|
16
|
-
}, {
|
|
17
|
-
version: "3" | "4";
|
|
18
|
-
trackingID?: string | undefined;
|
|
19
|
-
}>>;
|
|
8
|
+
trackers: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"provider", [z.ZodObject<{
|
|
9
|
+
provider: z.ZodLiteral<"ga4">;
|
|
10
|
+
id: z.ZodString;
|
|
20
11
|
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
version: "3" | "4";
|
|
24
|
-
trackingID?: string | undefined;
|
|
25
|
-
} | undefined;
|
|
12
|
+
provider: "ga4";
|
|
13
|
+
id: string;
|
|
26
14
|
}, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
15
|
+
provider: "ga4";
|
|
16
|
+
id: string;
|
|
17
|
+
}>, z.ZodObject<{
|
|
18
|
+
provider: z.ZodLiteral<"gtm">;
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
provider: "gtm";
|
|
22
|
+
id: string;
|
|
23
|
+
}, {
|
|
24
|
+
provider: "gtm";
|
|
25
|
+
id: string;
|
|
26
|
+
}>]>, "many">>;
|
|
33
27
|
serverless: z.ZodObject<{
|
|
34
28
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
35
29
|
uploads: z.ZodEnum<["proxy", "remote"]>;
|
|
@@ -85,13 +79,13 @@ export declare const EDConfigSchema: z.ZodObject<{
|
|
|
85
79
|
};
|
|
86
80
|
devUI: "enabled" | "disabled";
|
|
87
81
|
$schema?: string | undefined;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
} | undefined;
|
|
82
|
+
trackers?: ({
|
|
83
|
+
provider: "ga4";
|
|
84
|
+
id: string;
|
|
85
|
+
} | {
|
|
86
|
+
provider: "gtm";
|
|
87
|
+
id: string;
|
|
88
|
+
})[] | undefined;
|
|
95
89
|
cache?: Record<string, {
|
|
96
90
|
props: number;
|
|
97
91
|
queries: number;
|
|
@@ -111,13 +105,13 @@ export declare const EDConfigSchema: z.ZodObject<{
|
|
|
111
105
|
$schema?: string | undefined;
|
|
112
106
|
legacyMetadata?: boolean | undefined;
|
|
113
107
|
legacyStitches?: boolean | undefined;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
} | undefined;
|
|
108
|
+
trackers?: ({
|
|
109
|
+
provider: "ga4";
|
|
110
|
+
id: string;
|
|
111
|
+
} | {
|
|
112
|
+
provider: "gtm";
|
|
113
|
+
id: string;
|
|
114
|
+
})[] | undefined;
|
|
121
115
|
cache?: Record<string, {
|
|
122
116
|
props: number;
|
|
123
117
|
queries: number;
|
|
@@ -15,16 +15,18 @@ export const EDConfigSchema = z.object({
|
|
|
15
15
|
.default(false)
|
|
16
16
|
.describe("Whether to use legacy comments or exported JSON for block and view metadata"),
|
|
17
17
|
legacyStitches: z.boolean().optional().default(true).describe("Whether this site is using Stitches"),
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
18
|
+
trackers: z
|
|
19
|
+
.array(z.discriminatedUnion("provider", [
|
|
20
|
+
z.object({
|
|
21
|
+
provider: z.literal("ga4"),
|
|
22
|
+
id: z.string().describe("The Google Analytics 4 tracking ID"),
|
|
23
|
+
}),
|
|
24
|
+
z.object({
|
|
25
|
+
provider: z.literal("gtm"),
|
|
26
|
+
id: z.string().describe("The Google Tag Manager project ID (eg. GTM-XXXXXXX)"),
|
|
27
|
+
}),
|
|
28
|
+
]))
|
|
29
|
+
.describe("An array of standard tracking codes to embed")
|
|
28
30
|
.optional(),
|
|
29
31
|
serverless: z.object({
|
|
30
32
|
enabled: z.boolean().default(true).describe("Whether to deploy the site as a serverless app"),
|