eddev 2.0.0-beta.44 → 2.0.0-beta.45

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.
@@ -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, useRef } from "react";
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 { useRouteMeta } from "../lib/routing/hooks/useRouteMeta.js";
8
+ import { useSnapshot } from "valtio";
9
+ import { clientMetaTags } from "../lib/routing/context.js";
9
10
  export function SSRClientRoot(props) {
10
- const router = useRef(null);
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("link", { rel: "icon", href: "/favicon.ico" }), _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 data = useRouteMeta();
15
- return _jsx(MetaTags, { tags: data.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,9 +1,9 @@
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 { getQueryClient } from "../utils/query-client.js";
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;
@@ -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 { Context } from "react";
2
- import { RouterAPI, RouterAPIState } from "./types.js";
3
- export declare const RouterContext: Context<RouterAPI>;
4
- export declare const RouterStateContext: Context<RouterAPIState>;
5
- export declare const RouteItemContext: Context<import("./types.js").TypedRouteState<"_unknown", {}>>;
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.44";
1
+ export declare const VERSION = "2.0.0-beta.45";
@@ -1 +1 @@
1
- export const VERSION = "2.0.0-beta.44";
1
+ export const VERSION = "2.0.0-beta.45";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "2.0.0-beta.44",
3
+ "version": "2.0.0-beta.45",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",