UNPKG

21.9 kBJavaScriptView Raw
1/**
2 * react-router v8.5.3
3 *
4 * Copyright (c) Remix Software Inc.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE.md file in the root directory of this source tree.
8 *
9 * @license MIT
10 */
11import { useIsRSCRouterContext } from "../../context.js";
12import { useDataRouterContext, useDataRouterData, useDataRouterState, useLocation } from "../../hooks.js";
13import invariant from "./invariant.js";
14import { getKeyedLinksForMatches, getKeyedPrefetchLinks, getModuleLinkHrefs, getNewMatchesForLinks, isPageLinkDescriptor } from "./links.js";
15import { escapeHtml } from "./markup.js";
16import { singleFetchUrl } from "./single-fetch.js";
17import { warnOnce } from "../../server-runtime/warnings.js";
18import { getPartialManifest, isFogOfWarEnabled } from "./fog-of-war.js";
19import * as React$1 from "react";
20//#region lib/dom/ssr/components.tsx
21const FrameworkContext = React$1.createContext(void 0);
22FrameworkContext.displayName = "FrameworkContext";
23function useFrameworkContext() {
24 let context = React$1.useContext(FrameworkContext);
25 invariant(context, "You must render this element inside a <HydratedRouter> element");
26 return context;
27}
28function usePrefetchBehavior(prefetch, theirElementProps) {
29 let frameworkContext = React$1.useContext(FrameworkContext);
30 let [maybePrefetch, setMaybePrefetch] = React$1.useState(false);
31 let [shouldPrefetch, setShouldPrefetch] = React$1.useState(false);
32 let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
33 let ref = React$1.useRef(null);
34 React$1.useEffect(() => {
35 if (prefetch === "render") setShouldPrefetch(true);
36 if (prefetch === "viewport") {
37 let callback = (entries) => {
38 entries.forEach((entry) => {
39 setShouldPrefetch(entry.isIntersecting);
40 });
41 };
42 let observer = new IntersectionObserver(callback, { threshold: .5 });
43 if (ref.current) observer.observe(ref.current);
44 return () => {
45 observer.disconnect();
46 };
47 }
48 }, [prefetch]);
49 React$1.useEffect(() => {
50 if (maybePrefetch) {
51 let id = setTimeout(() => {
52 setShouldPrefetch(true);
53 }, 100);
54 return () => {
55 clearTimeout(id);
56 };
57 }
58 }, [maybePrefetch]);
59 let setIntent = () => {
60 setMaybePrefetch(true);
61 };
62 let cancelIntent = () => {
63 setMaybePrefetch(false);
64 setShouldPrefetch(false);
65 };
66 if (!frameworkContext) return [
67 false,
68 ref,
69 {}
70 ];
71 if (prefetch !== "intent") return [
72 shouldPrefetch,
73 ref,
74 {}
75 ];
76 return [
77 shouldPrefetch,
78 ref,
79 {
80 onFocus: composeEventHandlers(onFocus, setIntent),
81 onBlur: composeEventHandlers(onBlur, cancelIntent),
82 onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
83 onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
84 onTouchStart: composeEventHandlers(onTouchStart, setIntent)
85 }
86 ];
87}
88function composeEventHandlers(theirHandler, ourHandler) {
89 return (event) => {
90 theirHandler && theirHandler(event);
91 if (!event.defaultPrevented) ourHandler(event);
92 };
93}
94function getActiveMatches(matches, errors, isSpaMode) {
95 if (isSpaMode && !isHydrated) return [matches[0]];
96 if (errors) {
97 let errorIdx = matches.findIndex((m) => errors[m.route.id] !== void 0);
98 return matches.slice(0, errorIdx + 1);
99 }
100 return matches;
101}
102const CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css";
103/**
104* Renders all the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
105* tags created by the route module's [`links`](../../start/framework/route-module#links)
106* export. You should render it inside the [`<head>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head)
107* of your document.
108*
109* @example
110* import { Links } from "react-router";
111*
112* export default function Root() {
113* return (
114* <html>
115* <head>
116* <Links />
117* </head>
118* <body></body>
119* </html>
120* );
121* }
122*
123* @public
124* @category Components
125* @mode framework
126* @param props Props
127* @param {LinksProps.nonce} props.nonce n/a
128* @param {LinksProps.crossOrigin} props.crossOrigin n/a
129* @returns A collection of React elements for [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
130* tags
131*/
132function Links({ nonce, crossOrigin }) {
133 let { isSpaMode, manifest, routeModules, criticalCss, nonce: contextNonce } = useFrameworkContext();
134 let { matches: routerMatches } = useDataRouterState("Links");
135 let { errors } = useDataRouterData("Links");
136 let matches = getActiveMatches(routerMatches, errors, isSpaMode);
137 let keyedLinks = React$1.useMemo(() => getKeyedLinksForMatches(matches, routeModules, manifest), [
138 matches,
139 routeModules,
140 manifest
141 ]);
142 if (nonce == null && contextNonce) nonce = contextNonce;
143 return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, typeof criticalCss === "string" ? /* @__PURE__ */ React$1.createElement("style", {
144 [CRITICAL_CSS_DATA_ATTRIBUTE]: "",
145 nonce,
146 suppressHydrationWarning: true,
147 dangerouslySetInnerHTML: { __html: criticalCss }
148 }) : null, typeof criticalCss === "object" ? /* @__PURE__ */ React$1.createElement("link", {
149 [CRITICAL_CSS_DATA_ATTRIBUTE]: "",
150 rel: "stylesheet",
151 href: criticalCss.href,
152 nonce,
153 suppressHydrationWarning: true,
154 crossOrigin
155 }) : null, keyedLinks.map(({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React$1.createElement(PrefetchPageLinks, {
156 key,
157 nonce,
158 ...link,
159 crossOrigin: link.crossOrigin ?? crossOrigin
160 }) : /* @__PURE__ */ React$1.createElement("link", {
161 key,
162 nonce,
163 suppressHydrationWarning: true,
164 ...link,
165 crossOrigin: link.crossOrigin ?? crossOrigin
166 })));
167}
168/**
169* Renders [`<link rel=prefetch|modulepreload>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/rel)
170* tags for modules and data of another page to enable an instant navigation to
171* that page. [`<Link prefetch>`](./Link#prefetch) uses this internally, but you
172* can render it to prefetch a page for any other reason.
173*
174* For example, you may render one of this as the user types into a search field
175* to prefetch search results before they click through to their selection.
176*
177* @example
178* import { PrefetchPageLinks } from "react-router";
179*
180* <PrefetchPageLinks page="/absolute/path" />
181*
182* @public
183* @category Components
184* @mode framework
185* @param props Props
186* @param {PageLinkDescriptor.page} props.page n/a
187* @param props.linkProps Additional props to spread onto the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
188* tags, such as [`crossOrigin`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/crossOrigin),
189* [`integrity`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/integrity),
190* [`rel`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/rel),
191* etc.
192* @returns A collection of React elements for [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
193* tags
194*/
195function PrefetchPageLinks({ page, ...linkProps }) {
196 let rsc = useIsRSCRouterContext();
197 let { nonce: contextNonce } = useFrameworkContext();
198 let { router } = useDataRouterContext("PrefetchPageLinks");
199 let matches = React$1.useMemo(() => router.match(page), [
200 router,
201 router.routes,
202 page
203 ]);
204 if (!matches) return null;
205 if (linkProps.nonce == null && contextNonce) linkProps = {
206 ...linkProps,
207 nonce: contextNonce
208 };
209 if (rsc) return /* @__PURE__ */ React$1.createElement(RSCPrefetchPageLinksImpl, {
210 page,
211 matches,
212 ...linkProps
213 });
214 return /* @__PURE__ */ React$1.createElement(PrefetchPageLinksImpl, {
215 page,
216 matches,
217 ...linkProps
218 });
219}
220function useKeyedPrefetchLinks(matches) {
221 let { manifest, routeModules } = useFrameworkContext();
222 let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React$1.useState([]);
223 React$1.useEffect(() => {
224 let interrupted = false;
225 getKeyedPrefetchLinks(matches, manifest, routeModules).then((links) => {
226 if (!interrupted) setKeyedPrefetchLinks(links);
227 });
228 return () => {
229 interrupted = true;
230 };
231 }, [
232 matches,
233 manifest,
234 routeModules
235 ]);
236 return keyedPrefetchLinks;
237}
238function RSCPrefetchPageLinksImpl({ page, matches: nextMatches, ...linkProps }) {
239 let location = useLocation();
240 let { unstable_apiServerOrigin } = useFrameworkContext();
241 let dataHrefs = React$1.useMemo(() => {
242 if (page === location.pathname + location.search + location.hash) return [];
243 let url = singleFetchUrl(page, "rsc", unstable_apiServerOrigin);
244 let hasSomeRoutesWithShouldRevalidate = false;
245 let targetRoutes = [];
246 for (let match of nextMatches) if (typeof match.route.shouldRevalidate === "function") hasSomeRoutesWithShouldRevalidate = true;
247 else targetRoutes.push(match.route.id);
248 if (hasSomeRoutesWithShouldRevalidate && targetRoutes.length > 0) url.searchParams.set("_routes", targetRoutes.join(","));
249 return [unstable_apiServerOrigin ? url.toString() : url.pathname + url.search];
250 }, [
251 page,
252 location,
253 nextMatches,
254 unstable_apiServerOrigin
255 ]);
256 return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React$1.createElement("link", {
257 key: href,
258 rel: "prefetch",
259 as: "fetch",
260 href,
261 ...linkProps
262 })));
263}
264function PrefetchPageLinksImpl({ page, matches: nextMatches, ...linkProps }) {
265 let location = useLocation();
266 let { manifest, routeModules, unstable_apiServerOrigin } = useFrameworkContext();
267 let { matches } = useDataRouterState("PrefetchPageLinks");
268 let { loaderData } = useDataRouterData("PrefetchPageLinks");
269 let newMatchesForData = React$1.useMemo(() => getNewMatchesForLinks(page, nextMatches, matches, manifest, location, "data"), [
270 page,
271 nextMatches,
272 matches,
273 manifest,
274 location
275 ]);
276 let newMatchesForAssets = React$1.useMemo(() => getNewMatchesForLinks(page, nextMatches, matches, manifest, location, "assets"), [
277 page,
278 nextMatches,
279 matches,
280 manifest,
281 location
282 ]);
283 let dataHrefs = React$1.useMemo(() => {
284 if (page === location.pathname + location.search + location.hash) return [];
285 let routesParams = /* @__PURE__ */ new Set();
286 let foundOptOutRoute = false;
287 nextMatches.forEach((m) => {
288 let manifestRoute = manifest.routes[m.route.id];
289 if (!manifestRoute || !manifestRoute.hasLoader) return;
290 if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && routeModules[m.route.id]?.shouldRevalidate) foundOptOutRoute = true;
291 else if (manifestRoute.hasClientLoader) foundOptOutRoute = true;
292 else routesParams.add(m.route.id);
293 });
294 if (routesParams.size === 0) return [];
295 let url = singleFetchUrl(page, "data", unstable_apiServerOrigin);
296 if (foundOptOutRoute && routesParams.size > 0) url.searchParams.set("_routes", nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(","));
297 return [unstable_apiServerOrigin ? url.toString() : url.pathname + url.search];
298 }, [
299 loaderData,
300 location,
301 manifest,
302 newMatchesForData,
303 nextMatches,
304 page,
305 routeModules,
306 unstable_apiServerOrigin
307 ]);
308 let moduleHrefs = React$1.useMemo(() => getModuleLinkHrefs(newMatchesForAssets, manifest), [newMatchesForAssets, manifest]);
309 let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
310 return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React$1.createElement("link", {
311 key: href,
312 rel: "prefetch",
313 as: "fetch",
314 href,
315 ...linkProps
316 })), moduleHrefs.map((href) => /* @__PURE__ */ React$1.createElement("link", {
317 key: href,
318 rel: "modulepreload",
319 href,
320 ...linkProps
321 })), keyedPrefetchLinks.map(({ key, link }) => /* @__PURE__ */ React$1.createElement("link", {
322 key,
323 nonce: linkProps.nonce,
324 ...link,
325 crossOrigin: link.crossOrigin ?? linkProps.crossOrigin
326 })));
327}
328/**
329* Renders all the [`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta)
330* tags created by the route module's [`meta`](../../start/framework/route-module#meta)
331* export. You should render it inside the [`<head>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head)
332* of your document.
333*
334* @example
335* import { Meta } from "react-router";
336*
337* export default function Root() {
338* return (
339* <html>
340* <head>
341* <Meta />
342* </head>
343* </html>
344* );
345* }
346*
347* @public
348* @category Components
349* @mode framework
350* @returns A collection of React elements for [`<meta>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta)
351* tags
352*/
353function Meta() {
354 let { isSpaMode, routeModules } = useFrameworkContext();
355 let { matches: routerMatches } = useDataRouterState("Meta");
356 let { errors, loaderData } = useDataRouterData("Meta");
357 let location = useLocation();
358 let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
359 let error = null;
360 if (errors) error = errors[_matches[_matches.length - 1].route.id];
361 let meta = [];
362 let leafMeta = null;
363 let matches = [];
364 for (let i = 0; i < _matches.length; i++) {
365 let _match = _matches[i];
366 let routeId = _match.route.id;
367 let data = loaderData[routeId];
368 let params = _match.params;
369 let routeModule = routeModules[routeId];
370 let routeMeta = [];
371 let match = {
372 id: routeId,
373 loaderData: data,
374 meta: [],
375 params: _match.params,
376 pathname: _match.pathname,
377 handle: _match.route.handle,
378 error
379 };
380 matches[i] = match;
381 if (routeModule?.meta) routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
382 loaderData: data,
383 params,
384 location,
385 matches,
386 error
387 }) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
388 else if (leafMeta) routeMeta = [...leafMeta];
389 routeMeta = routeMeta || [];
390 if (!Array.isArray(routeMeta)) throw new Error("The route at " + _match.route.path + " returns an invalid value. All route meta functions must return an array of meta objects.\n\nTo reference the meta function API, see https://reactrouter.com/start/framework/route-module#meta");
391 match.meta = routeMeta;
392 matches[i] = match;
393 meta = [...routeMeta];
394 leafMeta = meta;
395 }
396 return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, meta.flat().map((metaProps) => {
397 if (!metaProps) return null;
398 if ("tagName" in metaProps) {
399 let { tagName, ...rest } = metaProps;
400 if (!isValidMetaTag(tagName)) {
401 console.warn(`A meta object uses an invalid tagName: ${tagName}. Expected either 'link' or 'meta'`);
402 return null;
403 }
404 let Comp = tagName;
405 return /* @__PURE__ */ React$1.createElement(Comp, {
406 key: JSON.stringify(rest),
407 ...rest
408 });
409 }
410 if ("title" in metaProps) return /* @__PURE__ */ React$1.createElement("title", { key: "title" }, String(metaProps.title));
411 if ("charset" in metaProps) {
412 metaProps.charSet ??= metaProps.charset;
413 delete metaProps.charset;
414 }
415 if ("charSet" in metaProps && metaProps.charSet != null) return typeof metaProps.charSet === "string" ? /* @__PURE__ */ React$1.createElement("meta", {
416 key: "charSet",
417 charSet: metaProps.charSet
418 }) : null;
419 if ("script:ld+json" in metaProps) try {
420 let json = JSON.stringify(metaProps["script:ld+json"]);
421 return /* @__PURE__ */ React$1.createElement("script", {
422 key: `script:ld+json:${json}`,
423 type: "application/ld+json",
424 dangerouslySetInnerHTML: { __html: escapeHtml(json) }
425 });
426 } catch {
427 return null;
428 }
429 return /* @__PURE__ */ React$1.createElement("meta", {
430 key: JSON.stringify(metaProps),
431 ...metaProps
432 });
433 }));
434}
435function isValidMetaTag(tagName) {
436 return typeof tagName === "string" && /^(meta|link)$/.test(tagName);
437}
438/**
439* Tracks whether hydration is finished, so scripts can be skipped
440* during client-side updates.
441*/
442let isHydrated = false;
443function setIsHydrated() {
444 isHydrated = true;
445}
446/**
447* Renders the client runtime of your app. It should be rendered inside the
448* [`<body>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body)
449* of the document.
450*
451* If server rendering, you can omit `<Scripts/>` and the app will work as a
452* traditional web app without JavaScript, relying solely on HTML and browser
453* behaviors.
454*
455* @example
456* import { Scripts } from "react-router";
457*
458* export default function Root() {
459* return (
460* <html>
461* <head />
462* <body>
463* <Scripts />
464* </body>
465* </html>
466* );
467* }
468*
469* @public
470* @category Components
471* @mode framework
472* @param scriptProps Additional props to spread onto the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
473* tags, such as [`crossOrigin`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/crossOrigin),
474* [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce),
475* etc.
476* @returns A collection of React elements for [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
477* tags
478*/
479function Scripts(scriptProps) {
480 let { manifest, serverHandoffString, isSpaMode, renderMeta, routeDiscovery, ssr, nonce: contextNonce } = useFrameworkContext();
481 let { router, static: isStatic, staticContext } = useDataRouterContext("Scripts");
482 let { matches: routerMatches } = useDataRouterState("Scripts");
483 let isRSCRouterContext = useIsRSCRouterContext();
484 let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr);
485 if (scriptProps.nonce == null && contextNonce) scriptProps = {
486 ...scriptProps,
487 nonce: contextNonce
488 };
489 if (renderMeta) renderMeta.didRenderScripts = true;
490 let matches = getActiveMatches(routerMatches, null, isSpaMode);
491 React$1.useEffect(() => {
492 setIsHydrated();
493 }, []);
494 let initialScripts = React$1.useMemo(() => {
495 if (isRSCRouterContext) return null;
496 let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());` : " ";
497 let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
498${matches.map((match, routeIndex) => {
499 let routeVarName = `route${routeIndex}`;
500 let manifestEntry = manifest.routes[match.route.id];
501 invariant(manifestEntry, `Route ${match.route.id} not found in manifest`);
502 let { clientActionModule, clientLoaderModule, clientMiddlewareModule, hydrateFallbackModule, module } = manifestEntry;
503 let chunks = [
504 ...clientActionModule ? [{
505 module: clientActionModule,
506 varName: `${routeVarName}_clientAction`
507 }] : [],
508 ...clientLoaderModule ? [{
509 module: clientLoaderModule,
510 varName: `${routeVarName}_clientLoader`
511 }] : [],
512 ...clientMiddlewareModule ? [{
513 module: clientMiddlewareModule,
514 varName: `${routeVarName}_clientMiddleware`
515 }] : [],
516 ...hydrateFallbackModule ? [{
517 module: hydrateFallbackModule,
518 varName: `${routeVarName}_HydrateFallback`
519 }] : [],
520 {
521 module,
522 varName: `${routeVarName}_main`
523 }
524 ];
525 if (chunks.length === 1) return `import * as ${routeVarName} from ${JSON.stringify(module)};`;
526 return [chunks.map((chunk) => `import * as ${chunk.varName} from "${chunk.module}";`).join("\n"), `const ${routeVarName} = {${chunks.map((chunk) => `...${chunk.varName}`).join(",")}};`].join("\n");
527 }).join("\n")}
528 ${enableFogOfWar ? `window.__reactRouterManifest = ${JSON.stringify(getPartialManifest(manifest, router), null, 2)};` : ""}
529 window.__reactRouterRouteModules = {${matches.map((match, index) => `${JSON.stringify(match.route.id)}:route${index}`).join(",")}};
530
531import(${JSON.stringify(manifest.entry.module)});`;
532 return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement("script", {
533 ...scriptProps,
534 suppressHydrationWarning: true,
535 dangerouslySetInnerHTML: { __html: contextScript },
536 type: void 0
537 }), /* @__PURE__ */ React$1.createElement("script", {
538 ...scriptProps,
539 suppressHydrationWarning: true,
540 dangerouslySetInnerHTML: { __html: routeModulesScript },
541 type: "module",
542 async: true
543 }));
544 }, []);
545 let preloads = isHydrated || isRSCRouterContext ? [] : [...new Set(manifest.entry.imports.concat(getModuleLinkHrefs(matches, manifest, { includeHydrateFallback: true })))];
546 let sri = typeof manifest.sri === "object" ? manifest.sri : {};
547 warnOnce(!isRSCRouterContext, "The <Scripts /> element is a no-op when using RSC and can be safely removed.");
548 return isHydrated || isRSCRouterContext ? null : /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, typeof manifest.sri === "object" ? /* @__PURE__ */ React$1.createElement("script", {
549 ...scriptProps,
550 "rr-importmap": "",
551 type: "importmap",
552 suppressHydrationWarning: true,
553 dangerouslySetInnerHTML: { __html: JSON.stringify({ integrity: sri }) }
554 }) : null, !enableFogOfWar ? /* @__PURE__ */ React$1.createElement("link", {
555 rel: "modulepreload",
556 href: manifest.url,
557 crossOrigin: scriptProps.crossOrigin,
558 integrity: sri[manifest.url],
559 nonce: scriptProps.nonce,
560 suppressHydrationWarning: true
561 }) : null, /* @__PURE__ */ React$1.createElement("link", {
562 rel: "modulepreload",
563 href: manifest.entry.module,
564 crossOrigin: scriptProps.crossOrigin,
565 integrity: sri[manifest.entry.module],
566 nonce: scriptProps.nonce,
567 suppressHydrationWarning: true
568 }), preloads.map((path) => /* @__PURE__ */ React$1.createElement("link", {
569 key: path,
570 rel: "modulepreload",
571 href: path,
572 crossOrigin: scriptProps.crossOrigin,
573 integrity: sri[path],
574 nonce: scriptProps.nonce,
575 suppressHydrationWarning: true
576 })), initialScripts);
577}
578function mergeRefs(...refs) {
579 return (value) => {
580 refs.forEach((ref) => {
581 if (typeof ref === "function") ref(value);
582 else if (ref != null) ref.current = value;
583 });
584 };
585}
586//#endregion
587export { CRITICAL_CSS_DATA_ATTRIBUTE, FrameworkContext, Links, Meta, PrefetchPageLinks, Scripts, mergeRefs, setIsHydrated, useFrameworkContext, usePrefetchBehavior };