goatly 0.1.0 → 0.1.2
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/README.md +874 -1
- package/bin/goatly.js +99 -0
- package/dist/cli/index.js +234 -0
- package/dist/compat/gatsby-node-entry.js +16 -0
- package/dist/compat/gatsby-package.json +6 -0
- package/dist/compat/md5-file.js +47 -0
- package/dist/compat-apis.json +72 -0
- package/dist/compat-apis.json.js +62 -0
- package/dist/graphql.js +3 -0
- package/dist/node/actions/index.js +619 -0
- package/dist/node/actions/job-store.js +180 -0
- package/dist/node/actions/jobs.js +174 -0
- package/dist/node/api-runner.js +258 -0
- package/dist/node/bootstrap.js +569 -0
- package/dist/node/build/assets.js +110 -0
- package/dist/node/build/incremental.js +208 -0
- package/dist/node/build/index.js +763 -0
- package/dist/node/build/memory-governor.js +450 -0
- package/dist/node/build/output-dirs.js +70 -0
- package/dist/node/build/page-data.js +40 -0
- package/dist/node/build/page-files.js +186 -0
- package/dist/node/build/partitioned-state.js +258 -0
- package/dist/node/build/query-worker.js +626 -0
- package/dist/node/build/query-workers.js +863 -0
- package/dist/node/build/render-thread.js +103 -0
- package/dist/node/build/render-worker.js +162 -0
- package/dist/node/build/state.js +24 -0
- package/dist/node/build/timing-breakdown.js +216 -0
- package/dist/node/build/work-clock.js +75 -0
- package/dist/node/build/worker-pool.js +242 -0
- package/dist/node/cache-layout.js +99 -0
- package/dist/node/cache.js +1430 -0
- package/dist/node/compat/chokidar-shim.js +148 -0
- package/dist/node/compat/core-utils-lmdb.js +145 -0
- package/dist/node/compat/create-node-id-shim.js +1 -0
- package/dist/node/compat/module-hooks.js +245 -0
- package/dist/node/compat/redux-shim.js +1 -0
- package/dist/node/config/index.js +162 -0
- package/dist/node/config/not-found-pages.js +95 -0
- package/dist/node/datastore/codec.js +144 -0
- package/dist/node/datastore/index.js +127 -0
- package/dist/node/datastore/logfile/cache.js +89 -0
- package/dist/node/datastore/logfile/index.js +1329 -0
- package/dist/node/datastore/logfile/record.js +71 -0
- package/dist/node/datastore/types.js +1 -0
- package/dist/node/develop/express-compat.js +207 -0
- package/dist/node/develop/graphiql.js +22 -0
- package/dist/node/develop/hydration-report.js +41 -0
- package/dist/node/develop/index.js +618 -0
- package/dist/node/develop/local-url.js +10 -0
- package/dist/node/develop/ssr-runner.js +66 -0
- package/dist/node/gql.js +5 -0
- package/dist/node/index.js +15 -0
- package/dist/node/info.js +270 -0
- package/dist/node/internal-plugins/data-bridge.js +196 -0
- package/dist/node/internal-plugins/page-creator.js +318 -0
- package/dist/node/loader/import-module.js +160 -0
- package/dist/node/node-helpers.js +66 -0
- package/dist/node/not-found-pages.js +220 -0
- package/dist/node/plugins/api-list.js +12 -0
- package/dist/node/plugins/load-plugins.js +427 -0
- package/dist/node/plugins/resolve-plugin.js +79 -0
- package/dist/node/plugins/static-exports.js +64 -0
- package/dist/node/query/compile.js +326 -0
- package/dist/node/query/dependencies.js +45 -0
- package/dist/node/query/execute.js +417 -0
- package/dist/node/query/extract.js +372 -0
- package/dist/node/query/gql-tada-introspection.js +124 -0
- package/dist/node/query/graphql-env.js +231 -0
- package/dist/node/query/graphql-runner.js +79 -0
- package/dist/node/redux/actions.js +1 -0
- package/dist/node/redux/index.js +133 -0
- package/dist/node/redux/node-changes.js +128 -0
- package/dist/node/redux/reducers.js +193 -0
- package/dist/node/redux/state.js +71 -0
- package/dist/node/renderer.js +124 -0
- package/dist/node/reporter-transports.js +259 -0
- package/dist/node/reporter.js +497 -0
- package/dist/node/schema/date.js +539 -0
- package/dist/node/schema/extensions.js +315 -0
- package/dist/node/schema/index.js +542 -0
- package/dist/node/schema/infer.js +388 -0
- package/dist/node/schema/inline-objects.js +128 -0
- package/dist/node/schema/naming.js +20 -0
- package/dist/node/schema/node-model.js +207 -0
- package/dist/node/schema/query-engine.js +1808 -0
- package/dist/node/schema/resolver-kinds.js +7 -0
- package/dist/node/schema/resolvers.js +273 -0
- package/dist/node/schema/type-builders.js +45 -0
- package/dist/node/schema/types.js +241 -0
- package/dist/node/serve.js +90 -0
- package/dist/node/site-page-nodes.js +277 -0
- package/dist/node/types.js +1 -0
- package/dist/node/utils/content-digest.js +107 -0
- package/dist/node/utils/cpus.js +104 -0
- package/dist/node/utils/create-node-id.js +51 -0
- package/dist/node/utils/env.js +25 -0
- package/dist/node/utils/fs-retry.js +74 -0
- package/dist/node/utils/memory-signals.js +441 -0
- package/dist/node/utils/memory.js +657 -0
- package/dist/node/utils/murmurhash.js +32 -0
- package/dist/node/utils/parser.js +33 -0
- package/dist/node/utils/partition-hash.js +19 -0
- package/dist/node/utils/paths.js +122 -0
- package/dist/node/utils/resolver.js +48 -0
- package/dist/node/utils/runtime.js +5 -0
- package/dist/node/utils/serializable.js +41 -0
- package/dist/node/utils/strings.js +41 -0
- package/dist/node/vite/config.js +289 -0
- package/dist/node/vite/paths.js +12 -0
- package/dist/node/vite/plugin-deps.js +232 -0
- package/dist/node/vite/plugin.js +283 -0
- package/dist/node/vite/react-compiler.js +362 -0
- package/dist/node/vite/source-files.js +83 -0
- package/dist/node/vite/static-image.js +136 -0
- package/dist/node/vite/styled-components.js +73 -0
- package/dist/node/vite/transforms.js +330 -0
- package/dist/node/wasm-data/host.js +406 -0
- package/dist/node/wasm-data/lower.js +406 -0
- package/dist/node/wasm-data/runner.js +79 -0
- package/dist/node/wasm-data/worker.js +95 -0
- package/dist/reporter.js +5 -0
- package/dist/runtime/api-runner.js +81 -0
- package/dist/runtime/app.js +256 -0
- package/dist/runtime/client-entry.js +4 -0
- package/dist/runtime/client.js +383 -0
- package/dist/runtime/default-html.js +31 -0
- package/dist/runtime/head-markup.js +100 -0
- package/dist/runtime/head-sync.js +101 -0
- package/dist/runtime/head-tags.js +45 -0
- package/dist/runtime/hydration-report.js +111 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/link.js +293 -0
- package/dist/runtime/loader.js +449 -0
- package/dist/runtime/not-found.js +61 -0
- package/dist/runtime/page-renderer.js +35 -0
- package/dist/runtime/preamble.js +47 -0
- package/dist/runtime/react-compat.js +14 -0
- package/dist/runtime/renderer-shared.js +10 -0
- package/dist/runtime/renderers/react-client.js +14 -0
- package/dist/runtime/renderers/react-server.js +99 -0
- package/dist/runtime/renderers/react.js +17 -0
- package/dist/runtime/renderers/types.js +1 -0
- package/dist/runtime/root-error-handlers.js +29 -0
- package/dist/runtime/router/history.js +132 -0
- package/dist/runtime/router/index.js +240 -0
- package/dist/runtime/router/utils.js +118 -0
- package/dist/runtime/script.js +110 -0
- package/dist/runtime/scroll.js +40 -0
- package/dist/runtime/slice.js +11 -0
- package/dist/runtime/ssr.js +240 -0
- package/dist/runtime/static-query.js +47 -0
- package/dist/utils.js +4 -0
- package/package.json +105 -3
- package/types/graphql-tada.d.ts +223 -0
- package/types/graphql.d.ts +2 -0
- package/types/index.d.ts +2287 -0
- package/types/node.d.ts +389 -0
- package/types/reporter.d.ts +187 -0
- package/types/router.d.ts +102 -0
- package/types/vendor/gql-tada.d.ts +2529 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { HEAD_ATTRIBUTE, VALID_HEAD_TAGS } from "./react-compat.js";
|
|
2
|
+
// src/runtime/head-markup.ts
|
|
3
|
+
const VOID = /* @__PURE__ */ new Set([
|
|
4
|
+
"link",
|
|
5
|
+
"meta",
|
|
6
|
+
"base"
|
|
7
|
+
]);
|
|
8
|
+
const RAW_TEXT = /* @__PURE__ */ new Set(["script", "style"]);
|
|
9
|
+
/**
|
|
10
|
+
* The text of a `<script>`/`<style>` as it is written into the document: `<\/script` / `</style`
|
|
11
|
+
* escaped, so the element is not closed early. The browser head sync compares server elements
|
|
12
|
+
* with this form of the client text. A renderer whose server writes another form exports its own
|
|
13
|
+
* (`RendererShared.escapeRawText`). Idempotent: already escaped text stays the same.
|
|
14
|
+
*/
|
|
15
|
+
function escapeRawText(text, tag) {
|
|
16
|
+
return text.replace(new RegExp(`</(?=${tag})`, "gi"), "<\\/");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Portal head mode: turns the static markup of a `Head` export (`RendererServer.renderHead`) into
|
|
20
|
+
* the markup that goes into `<head>` – the equivalent of Gatsby 5's
|
|
21
|
+
* `getValidHeadNodesAndAttributesSSR`:
|
|
22
|
+
* - keeps only valid head elements, at any depth (DOM wrappers – e.g. rendered by
|
|
23
|
+
* `wrapRootElement`, which also wraps the Head – are dropped, their head elements kept)
|
|
24
|
+
* - marks each kept element with `data-gatsby-head="true"` (the browser head sync removes and
|
|
25
|
+
* diffs exactly these, and compares them with `isEqualNode`, so the value must be "true")
|
|
26
|
+
* - writes `<script>`/`<style>` text in the form `escape` gives (the renderer's, by default
|
|
27
|
+
* `escapeRawText`; renderers hand it over as source text, not HTML-escaped, so JSON-LD stays valid)
|
|
28
|
+
* - keeps the last element of duplicate ids (Gatsby 5)
|
|
29
|
+
* Attribute values and text in the input never contain a raw `<` or `>` (renderer output).
|
|
30
|
+
*/
|
|
31
|
+
function headMarkup(html, escape = escapeRawText) {
|
|
32
|
+
return parseHeadMarkup(html, escape).map((e) => e.markup).join("");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `headMarkup` in two parts, for Gatsby 5's order of the document head: `<meta>` elements come
|
|
36
|
+
* first (with the other metas), everything else after the stylesheets and onRenderBody components.
|
|
37
|
+
*/
|
|
38
|
+
function headMarkupParts(html, escape = escapeRawText) {
|
|
39
|
+
let meta = "";
|
|
40
|
+
let rest = "";
|
|
41
|
+
for (const e of parseHeadMarkup(html, escape)) if (e.tag === "meta") meta += e.markup;
|
|
42
|
+
else rest += e.markup;
|
|
43
|
+
return {
|
|
44
|
+
meta,
|
|
45
|
+
rest
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function parseHeadMarkup(html, escape) {
|
|
49
|
+
const out = [];
|
|
50
|
+
const ids = /* @__PURE__ */ new Map();
|
|
51
|
+
let pos = 0;
|
|
52
|
+
while (pos < html.length) {
|
|
53
|
+
const lt = html.indexOf("<", pos);
|
|
54
|
+
if (lt === -1) break;
|
|
55
|
+
if (html.startsWith("<!--", lt)) {
|
|
56
|
+
const end = html.indexOf("-->", lt + 4);
|
|
57
|
+
pos = end === -1 ? html.length : end + 3;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const m = /^<(\/?)([a-zA-Z][a-zA-Z0-9-]*)/.exec(html.slice(lt, lt + 64));
|
|
61
|
+
const openEnd = m ? html.indexOf(">", lt) : -1;
|
|
62
|
+
if (!m || openEnd === -1) {
|
|
63
|
+
pos = lt + 1;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const tag = m[2].toLowerCase();
|
|
67
|
+
if (m[1] || !VALID_HEAD_TAGS.has(tag)) {
|
|
68
|
+
pos = openEnd + 1;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const raw = html.slice(lt, openEnd + 1);
|
|
72
|
+
const selfClosing = raw.endsWith("/>");
|
|
73
|
+
let markup = `${raw.slice(0, selfClosing ? -2 : -1)} ${HEAD_ATTRIBUTE}="true"${selfClosing ? "/>" : ">"}`;
|
|
74
|
+
let end = openEnd + 1;
|
|
75
|
+
if (!VOID.has(tag) && !selfClosing) {
|
|
76
|
+
const close = `</${tag}>`;
|
|
77
|
+
const closeAt = html.indexOf(close, end);
|
|
78
|
+
let inner = closeAt === -1 ? html.slice(end) : html.slice(end, closeAt);
|
|
79
|
+
if (RAW_TEXT.has(tag)) inner = escape(inner, tag);
|
|
80
|
+
markup += inner + close;
|
|
81
|
+
end = closeAt === -1 ? html.length : closeAt + close.length;
|
|
82
|
+
}
|
|
83
|
+
const id = /\sid="([^"]*)"/.exec(raw)?.[1];
|
|
84
|
+
const seen = id === void 0 ? void 0 : ids.get(id);
|
|
85
|
+
if (seen !== void 0) out[seen] = {
|
|
86
|
+
tag,
|
|
87
|
+
markup
|
|
88
|
+
};
|
|
89
|
+
else {
|
|
90
|
+
if (id !== void 0) ids.set(id, out.length);
|
|
91
|
+
out.push({
|
|
92
|
+
tag,
|
|
93
|
+
markup
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
pos = end;
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
export { escapeRawText, headMarkup, headMarkupParts };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { escapeRawText } from "./head-markup.js";
|
|
2
|
+
import { escapeRawText as escapeRawText$1 } from "./renderer-shared.js";
|
|
3
|
+
import { HEAD_ATTRIBUTE, VALID_HEAD_TAGS } from "./react-compat.js";
|
|
4
|
+
import { useLayoutEffect, useState, useSyncExternalStore } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { createPortal } from "react-dom";
|
|
7
|
+
// src/runtime/head-sync.tsx
|
|
8
|
+
/** the form of script/style text the renderer's server writes (see head-markup.ts) */
|
|
9
|
+
const escapeText = escapeRawText$1 ?? escapeRawText;
|
|
10
|
+
const warned = /* @__PURE__ */ new Set();
|
|
11
|
+
function warnInvalid(name) {
|
|
12
|
+
if (process.env.NODE_ENV === "production" || warned.has(name)) return;
|
|
13
|
+
warned.add(name);
|
|
14
|
+
console.warn(`<${name}> is not a valid head element and is ignored in the Head export. Valid elements: ${[...VALID_HEAD_TAGS].join(", ")}`);
|
|
15
|
+
}
|
|
16
|
+
/** `isEqualNode`, except: browsers hide `nonce` once connected (Gatsby 5); `<noscript>` is compared without its children (markup text on the server, elements or nothing on the client). */
|
|
17
|
+
function isEqualHeadNode(existing, next) {
|
|
18
|
+
if (next.nodeName === "NOSCRIPT") return existing.cloneNode(false).isEqualNode(next.cloneNode(false));
|
|
19
|
+
let candidate = next;
|
|
20
|
+
if (next.nodeName === "SCRIPT" || next.nodeName === "STYLE") {
|
|
21
|
+
const text = escapeText(next.textContent ?? "", next.nodeName === "SCRIPT" ? "script" : "style");
|
|
22
|
+
if (text !== next.textContent) {
|
|
23
|
+
candidate = next.cloneNode(false);
|
|
24
|
+
candidate.textContent = text;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const nonce = candidate.getAttribute("nonce");
|
|
28
|
+
if (nonce && !existing.getAttribute("nonce")) {
|
|
29
|
+
const clone = candidate.cloneNode(true);
|
|
30
|
+
clone.setAttribute("nonce", "");
|
|
31
|
+
return existing.nonce === nonce && existing.isEqualNode(clone);
|
|
32
|
+
}
|
|
33
|
+
return existing.isEqualNode(candidate);
|
|
34
|
+
}
|
|
35
|
+
function collectHeadNodes(root, out, ids) {
|
|
36
|
+
for (const node of Array.from(root.children)) {
|
|
37
|
+
const name = node.nodeName.toLowerCase();
|
|
38
|
+
if (!VALID_HEAD_TAGS.has(name)) {
|
|
39
|
+
warnInvalid(name);
|
|
40
|
+
collectHeadNodes(node, out, ids);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
let clone;
|
|
44
|
+
if (name === "script") {
|
|
45
|
+
clone = document.createElement("script");
|
|
46
|
+
for (const attr of Array.from(node.attributes)) clone.setAttribute(attr.name, attr.value);
|
|
47
|
+
clone.textContent = node.textContent;
|
|
48
|
+
} else clone = node.cloneNode(true);
|
|
49
|
+
clone.normalize();
|
|
50
|
+
clone.setAttribute(HEAD_ATTRIBUTE, "true");
|
|
51
|
+
const id = node.getAttribute("id");
|
|
52
|
+
const seen = id ? ids.get(id) : void 0;
|
|
53
|
+
if (seen !== void 0) out[seen] = clone;
|
|
54
|
+
else {
|
|
55
|
+
if (id) ids.set(id, out.length);
|
|
56
|
+
out.push(clone);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** Makes the `[data-gatsby-head]` elements of `document.head` equal to what the Head export rendered. */
|
|
62
|
+
function syncHeadElements(container) {
|
|
63
|
+
const next = collectHeadNodes(container, [], /* @__PURE__ */ new Map());
|
|
64
|
+
for (const existing of Array.from(document.head.querySelectorAll(`[${HEAD_ATTRIBUTE}]`))) {
|
|
65
|
+
const index = next.findIndex((node) => isEqualHeadNode(existing, node));
|
|
66
|
+
if (index === -1) existing.remove();
|
|
67
|
+
else next.splice(index, 1);
|
|
68
|
+
}
|
|
69
|
+
document.head.append(...next);
|
|
70
|
+
}
|
|
71
|
+
function HeadSync({ container }) {
|
|
72
|
+
useLayoutEffect(() => syncHeadElements(container));
|
|
73
|
+
useLayoutEffect(() => {
|
|
74
|
+
const observer = new MutationObserver(() => syncHeadElements(container));
|
|
75
|
+
observer.observe(container, {
|
|
76
|
+
subtree: true,
|
|
77
|
+
childList: true,
|
|
78
|
+
attributes: true,
|
|
79
|
+
characterData: true
|
|
80
|
+
});
|
|
81
|
+
return () => observer.disconnect();
|
|
82
|
+
}, [container]);
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const subscribeNothing = () => () => {};
|
|
86
|
+
const isClient = () => true;
|
|
87
|
+
const isServer = () => false;
|
|
88
|
+
/**
|
|
89
|
+
* Portal head mode (react-dom 18): renders the Head export into a detached element – inside the app tree, so it has every
|
|
90
|
+
* context (wrapRootElement providers, location, static queries) – and syncs the result into
|
|
91
|
+
* `document.head`. Renders nothing on the server and while hydrating: the server puts the Head
|
|
92
|
+
* markup into `<head>` itself, so the app markup has nothing at this position. Stays mounted when a
|
|
93
|
+
* page has no Head, so an empty container removes the previous page's elements.
|
|
94
|
+
*/
|
|
95
|
+
function HeadPortal({ children }) {
|
|
96
|
+
const [container] = useState(() => typeof document === "undefined" ? null : document.createElement("div"));
|
|
97
|
+
const hydrated = useSyncExternalStore(subscribeNothing, isClient, isServer);
|
|
98
|
+
if (!container || !hydrated) return null;
|
|
99
|
+
return createPortal(/* @__PURE__ */ jsxs(Fragment$1, { children: [children, /* @__PURE__ */ jsx(HeadSync, { container })] }), container);
|
|
100
|
+
}
|
|
101
|
+
export { HeadPortal, syncHeadElements };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createContext, useContext, useEffect, useLayoutEffect } from "react";
|
|
2
|
+
// src/runtime/head-tags.tsx
|
|
3
|
+
/** SSR only: collects the attributes of the page's `<html>`/`<body>` (null in the browser) */
|
|
4
|
+
const HtmlAttributeCollectorContext = createContext(null);
|
|
5
|
+
HtmlAttributeCollectorContext.displayName = "HtmlAttributeCollectorContext";
|
|
6
|
+
const createHtmlAttributeCollector = () => ({
|
|
7
|
+
html: {},
|
|
8
|
+
body: {}
|
|
9
|
+
});
|
|
10
|
+
const useIsoLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
11
|
+
function toDomAttribute(name) {
|
|
12
|
+
if (name === "className") return "class";
|
|
13
|
+
if (name === "htmlFor") return "for";
|
|
14
|
+
return name;
|
|
15
|
+
}
|
|
16
|
+
function useDocumentAttributes(target, props) {
|
|
17
|
+
const collector = useContext(HtmlAttributeCollectorContext);
|
|
18
|
+
if (collector) Object.assign(collector[target], props);
|
|
19
|
+
const serialized = JSON.stringify(props);
|
|
20
|
+
useIsoLayoutEffect(() => {
|
|
21
|
+
const el = target === "html" ? document.documentElement : document.body;
|
|
22
|
+
const applied = [];
|
|
23
|
+
for (const [key, value] of Object.entries(props)) {
|
|
24
|
+
if (key === "children" || value === void 0 || value === null || value === false) continue;
|
|
25
|
+
const attr = toDomAttribute(key);
|
|
26
|
+
const next = key === "style" && typeof value === "object" ? Object.entries(value).map(([k, v]) => `${k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}:${v}`).join(";") : value === true ? "" : String(value);
|
|
27
|
+
const current = el.getAttribute(attr);
|
|
28
|
+
applied.push([attr, current === next ? null : current]);
|
|
29
|
+
el.setAttribute(attr, next);
|
|
30
|
+
}
|
|
31
|
+
return () => {
|
|
32
|
+
for (const [attr, previous] of applied) if (previous === null) el.removeAttribute(attr);
|
|
33
|
+
else el.setAttribute(attr, previous);
|
|
34
|
+
};
|
|
35
|
+
}, [serialized]);
|
|
36
|
+
}
|
|
37
|
+
function HtmlAttributes(props) {
|
|
38
|
+
useDocumentAttributes("html", props);
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
function BodyAttributes(props) {
|
|
42
|
+
useDocumentAttributes("body", props);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
export { BodyAttributes, HtmlAttributeCollectorContext, HtmlAttributes, createHtmlAttributeCollector };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/runtime/hydration-report.ts
|
|
2
|
+
/**
|
|
3
|
+
* Develop only: collects hydration mismatches in the browser and sends them to the dev server,
|
|
4
|
+
* which prints them in the terminal (React only logs them to the browser console).
|
|
5
|
+
*
|
|
6
|
+
* Covers both what React recovers from (`onRecoverableError`: the server HTML is thrown away and
|
|
7
|
+
* re-rendered on the client) and what React 18 merely warns about (attribute mismatches such as
|
|
8
|
+
* `className`: the DOM keeps the server value until the element re-renders).
|
|
9
|
+
*/
|
|
10
|
+
const HYDRATION_EVENT = "goatly:hydration-mismatch";
|
|
11
|
+
const MAX_ISSUES = 10;
|
|
12
|
+
const MAX_STACK_FRAMES = 6;
|
|
13
|
+
const HYDRATION_WARNING_RE = /did not match\. Server:|Text content did not match|Expected server HTML to contain|Did not expect server HTML to contain|Extra attributes from the server|A tree hydrated but some attributes|Hydration failed|An error occurred during hydration/;
|
|
14
|
+
/** Is this `console.error` call one of React's (18 or 19) hydration mismatch warnings? */
|
|
15
|
+
function isHydrationWarning(args) {
|
|
16
|
+
return typeof args[0] === "string" && HYDRATION_WARNING_RE.test(args[0]);
|
|
17
|
+
}
|
|
18
|
+
/** Formats a React 18 `console.error("Warning: ...%s", ...args)` call; the trailing stack is split off. */
|
|
19
|
+
function formatReactWarning(args) {
|
|
20
|
+
const [format, ...rest] = args;
|
|
21
|
+
let i = 0;
|
|
22
|
+
let stack;
|
|
23
|
+
const message = format.replace(/%s/g, () => {
|
|
24
|
+
const arg = rest[i++];
|
|
25
|
+
const s = String(arg ?? "");
|
|
26
|
+
if (/^\s*\n\s+at /.test(s)) {
|
|
27
|
+
stack = s;
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
return s;
|
|
31
|
+
});
|
|
32
|
+
const extra = rest.slice(i).map(String).join(" ");
|
|
33
|
+
const text = `${message}${extra ? ` ${extra}` : ""}`.replace(/^Warning: /, "").trim();
|
|
34
|
+
return {
|
|
35
|
+
kind: /replaced with client content|Hydration failed/.test(text) ? "error" : "warning",
|
|
36
|
+
message: text,
|
|
37
|
+
componentStack: stack
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Keeps the innermost frames and makes dev-server URLs readable (`/@fs/abs/file.tsx?t=1:3:4` → `/abs/file.tsx:3:4`). */
|
|
41
|
+
function shortenComponentStack(stack, origin = "") {
|
|
42
|
+
if (!stack) return void 0;
|
|
43
|
+
const frames = stack.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("at ")).slice(0, MAX_STACK_FRAMES).map((l) => l.replace(origin, "").replace(/\(\/@fs\//, "(/").replace(/\?[^:)]*(?=:\d+:\d+\)|\))/, ""));
|
|
44
|
+
return frames.length ? frames.join("\n") : void 0;
|
|
45
|
+
}
|
|
46
|
+
/** How long after start mismatches are collected (Suspense boundaries can hydrate late). */
|
|
47
|
+
const COLLECT_MS = 15e3;
|
|
48
|
+
/** Mismatches arriving within this window are sent together. */
|
|
49
|
+
const BATCH_MS = 500;
|
|
50
|
+
/**
|
|
51
|
+
* Starts collecting. Returns the `onRecoverableError` handler for `hydrateRoot`. Issues are sent
|
|
52
|
+
* in batches as hydration progresses; `console.error` is restored after `COLLECT_MS`.
|
|
53
|
+
*/
|
|
54
|
+
function installHydrationReporter(hot) {
|
|
55
|
+
let pending = [];
|
|
56
|
+
const seen = /* @__PURE__ */ new Set();
|
|
57
|
+
let sent = 0;
|
|
58
|
+
let dropped = 0;
|
|
59
|
+
let batchTimer;
|
|
60
|
+
let active = true;
|
|
61
|
+
const path = window.location.pathname;
|
|
62
|
+
const origin = window.location.origin;
|
|
63
|
+
const flush = () => {
|
|
64
|
+
clearTimeout(batchTimer);
|
|
65
|
+
if (pending.length === 0 && dropped === 0) return;
|
|
66
|
+
const report = {
|
|
67
|
+
path,
|
|
68
|
+
issues: pending,
|
|
69
|
+
dropped
|
|
70
|
+
};
|
|
71
|
+
pending = [];
|
|
72
|
+
dropped = 0;
|
|
73
|
+
hot.send(HYDRATION_EVENT, report);
|
|
74
|
+
};
|
|
75
|
+
const add = (issue) => {
|
|
76
|
+
if (!active || seen.has(issue.message)) return;
|
|
77
|
+
seen.add(issue.message);
|
|
78
|
+
if (sent >= MAX_ISSUES) dropped++;
|
|
79
|
+
else {
|
|
80
|
+
sent++;
|
|
81
|
+
pending.push({
|
|
82
|
+
...issue,
|
|
83
|
+
componentStack: shortenComponentStack(issue.componentStack, origin)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
clearTimeout(batchTimer);
|
|
87
|
+
batchTimer = setTimeout(flush, BATCH_MS);
|
|
88
|
+
};
|
|
89
|
+
const original = console.error;
|
|
90
|
+
const patched = function(...args) {
|
|
91
|
+
try {
|
|
92
|
+
if (isHydrationWarning(args)) add(formatReactWarning(args));
|
|
93
|
+
} catch {}
|
|
94
|
+
return original.apply(this, args);
|
|
95
|
+
};
|
|
96
|
+
console.error = patched;
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
active = false;
|
|
99
|
+
if (console.error === patched) console.error = original;
|
|
100
|
+
flush();
|
|
101
|
+
}, COLLECT_MS);
|
|
102
|
+
return function onRecoverableError(error, info) {
|
|
103
|
+
const cause = error?.cause instanceof Error ? ` (${error.cause.message})` : "";
|
|
104
|
+
add({
|
|
105
|
+
kind: info?.kind ?? "error",
|
|
106
|
+
message: `${error?.message ?? String(error)}${cause}`,
|
|
107
|
+
componentStack: info?.componentStack
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export { HYDRATION_EVENT, formatReactWarning, installHydrationReporter, isHydrationWarning, shortenComponentStack };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Link, LinkProvider, navigate, parsePath, useLink, useLinkConfig, withAssetPrefix, withPrefix } from "./link.js";
|
|
2
|
+
import { StaticQuery, StaticQueryContext, graphql, useStaticQuery } from "./static-query.js";
|
|
3
|
+
import { Slice } from "./slice.js";
|
|
4
|
+
import { Script, ScriptStrategy, collectedScriptsByPage, scriptCache, scriptCallbackCache } from "./script.js";
|
|
5
|
+
import { useScrollRestoration } from "./scroll.js";
|
|
6
|
+
import { PageRenderer } from "./page-renderer.js";
|
|
7
|
+
import { BodyAttributes, HtmlAttributes } from "./head-tags.js";
|
|
8
|
+
// src/runtime/index.ts
|
|
9
|
+
function prefetchPathname(path) {
|
|
10
|
+
if (typeof window !== "undefined") window.___loader?.prefetch(path);
|
|
11
|
+
}
|
|
12
|
+
export { BodyAttributes, HtmlAttributes, Link, LinkProvider, PageRenderer, Script, ScriptStrategy, Slice, StaticQuery, StaticQueryContext, collectedScriptsByPage, graphql, navigate, parsePath, prefetchPathname, scriptCache, scriptCallbackCache, useLink, useLinkConfig, useScrollRestoration, useStaticQuery, withAssetPrefix, withPrefix };
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { resolve } from "./router/utils.js";
|
|
2
|
+
import { LocationContext } from "./router/index.js";
|
|
3
|
+
import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/runtime/link.tsx
|
|
6
|
+
const SCHEME = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
|
|
7
|
+
function parsePath(path) {
|
|
8
|
+
let pathname = path || "/";
|
|
9
|
+
let search = "";
|
|
10
|
+
let hash = "";
|
|
11
|
+
const hashIndex = pathname.indexOf("#");
|
|
12
|
+
if (hashIndex !== -1) {
|
|
13
|
+
hash = pathname.slice(hashIndex);
|
|
14
|
+
pathname = pathname.slice(0, hashIndex);
|
|
15
|
+
}
|
|
16
|
+
const searchIndex = pathname.indexOf("?");
|
|
17
|
+
if (searchIndex !== -1) {
|
|
18
|
+
search = pathname.slice(searchIndex);
|
|
19
|
+
pathname = pathname.slice(0, searchIndex);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
pathname,
|
|
23
|
+
search: search === "?" ? "" : search,
|
|
24
|
+
hash: hash === "#" ? "" : hash
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const isLocalLink = (path) => typeof path === "string" ? !SCHEME.test(path) : void 0;
|
|
28
|
+
const getGlobalBasePrefix = () => typeof __BASE_PATH__ !== "undefined" ? __BASE_PATH__ : void 0;
|
|
29
|
+
const getGlobalPathPrefix = () => typeof __PATH_PREFIX__ !== "undefined" ? __PATH_PREFIX__ : void 0;
|
|
30
|
+
const getGlobalTrailingSlash = () => typeof __TRAILING_SLASH__ !== "undefined" ? __TRAILING_SLASH__ : void 0;
|
|
31
|
+
/** gatsby-config `prefetch` (default: "viewport", like Gatsby) */
|
|
32
|
+
const getGlobalPrefetch = () => typeof __PREFETCH__ !== "undefined" ? __PREFETCH__ : "viewport";
|
|
33
|
+
/** how long the pointer has to stay on a link before the page is loaded */
|
|
34
|
+
const HOVER_DELAY_MS = 50;
|
|
35
|
+
let observer;
|
|
36
|
+
const observed = /* @__PURE__ */ new Map();
|
|
37
|
+
function observeVisibility(el, onChange) {
|
|
38
|
+
observer ??= new IntersectionObserver((entries) => {
|
|
39
|
+
for (const entry of entries) observed.get(entry.target)?.(entry.isIntersecting || entry.intersectionRatio > 0);
|
|
40
|
+
});
|
|
41
|
+
observed.set(el, onChange);
|
|
42
|
+
observer.observe(el);
|
|
43
|
+
return () => {
|
|
44
|
+
if (observed.get(el) !== onChange) return;
|
|
45
|
+
observed.delete(el);
|
|
46
|
+
observer?.unobserve(el);
|
|
47
|
+
if (observed.size === 0) {
|
|
48
|
+
observer?.disconnect();
|
|
49
|
+
observer = void 0;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function withPrefix(path, prefix = getGlobalBasePrefix()) {
|
|
54
|
+
if (!isLocalLink(path)) return path;
|
|
55
|
+
if (path.startsWith("./") || path.startsWith("../")) return path;
|
|
56
|
+
const base = prefix ?? getGlobalPathPrefix() ?? "/";
|
|
57
|
+
return `${base?.endsWith("/") ? base.slice(0, -1) : base}${path.startsWith("/") ? path : `/${path}`}`;
|
|
58
|
+
}
|
|
59
|
+
function withAssetPrefix(path) {
|
|
60
|
+
return withPrefix(path, getGlobalPathPrefix());
|
|
61
|
+
}
|
|
62
|
+
function applyTrailingSlashOption(input, option = "always") {
|
|
63
|
+
if (input === "/") return input;
|
|
64
|
+
const hasTrailingSlash = input.endsWith("/");
|
|
65
|
+
if (option === "always") return hasTrailingSlash ? input : `${input}/`;
|
|
66
|
+
if (option === "never") return hasTrailingSlash ? input.slice(0, -1) : input;
|
|
67
|
+
return input;
|
|
68
|
+
}
|
|
69
|
+
function applyTrailingSlashOptionOnPathnameOnly(path, option) {
|
|
70
|
+
const { pathname, search, hash } = parsePath(path);
|
|
71
|
+
return `${applyTrailingSlashOption(pathname, option)}${search}${hash}`;
|
|
72
|
+
}
|
|
73
|
+
const isAbsolutePath = (path) => path?.startsWith("/");
|
|
74
|
+
function rewriteLinkPath(path, relativeTo) {
|
|
75
|
+
if (typeof path === "number") return path;
|
|
76
|
+
if (!isLocalLink(path)) return path;
|
|
77
|
+
const option = getGlobalTrailingSlash();
|
|
78
|
+
if (isAbsolutePath(path)) {
|
|
79
|
+
const prefixed = withPrefix(path);
|
|
80
|
+
return option === "always" || option === "never" ? applyTrailingSlashOptionOnPathnameOnly(prefixed, option) : prefixed;
|
|
81
|
+
}
|
|
82
|
+
const absolute = resolve(path, relativeTo);
|
|
83
|
+
return option === "always" || option === "never" ? applyTrailingSlashOptionOnPathnameOnly(absolute, option) : absolute;
|
|
84
|
+
}
|
|
85
|
+
const LinkConfigContext = createContext({});
|
|
86
|
+
LinkConfigContext.displayName = "LinkConfig";
|
|
87
|
+
/** The `LinkProvider` component being rendered: a `<Link>` inside it renders the built-in link */
|
|
88
|
+
const RenderingOverrideContext = createContext(void 0);
|
|
89
|
+
/**
|
|
90
|
+
* Configures the `<Link>`s (and `useLink`s) below it: defaults for their props, or a `component`
|
|
91
|
+
* that replaces them. Nested providers override the values they set. Put it in `wrapRootElement`
|
|
92
|
+
* to configure every link of the site.
|
|
93
|
+
*/
|
|
94
|
+
function LinkProvider({ children, component, prefetch, activeClassName, activeStyle, partiallyActive }) {
|
|
95
|
+
const parent = useContext(LinkConfigContext);
|
|
96
|
+
const value = useMemo(() => {
|
|
97
|
+
const merged = { ...parent };
|
|
98
|
+
const own = {
|
|
99
|
+
component,
|
|
100
|
+
prefetch,
|
|
101
|
+
activeClassName,
|
|
102
|
+
activeStyle,
|
|
103
|
+
partiallyActive
|
|
104
|
+
};
|
|
105
|
+
for (const [key, v] of Object.entries(own)) if (v !== void 0) merged[key] = v;
|
|
106
|
+
return merged;
|
|
107
|
+
}, [
|
|
108
|
+
parent,
|
|
109
|
+
component,
|
|
110
|
+
prefetch,
|
|
111
|
+
activeClassName,
|
|
112
|
+
activeStyle,
|
|
113
|
+
partiallyActive
|
|
114
|
+
]);
|
|
115
|
+
return /* @__PURE__ */ jsx(LinkConfigContext.Provider, {
|
|
116
|
+
value,
|
|
117
|
+
children
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/** The configuration of the closest `LinkProvider`s (`{}` without one) */
|
|
121
|
+
function useLinkConfig() {
|
|
122
|
+
return useContext(LinkConfigContext);
|
|
123
|
+
}
|
|
124
|
+
function assignRef(ref, value) {
|
|
125
|
+
if (typeof ref === "function") ref(value);
|
|
126
|
+
else if (ref) ref.current = value;
|
|
127
|
+
}
|
|
128
|
+
const isPlainLeftClick = (e) => e.button === 0 && !e.defaultPrevented && !e.metaKey && !e.altKey && !e.ctrlKey && !e.shiftKey;
|
|
129
|
+
/**
|
|
130
|
+
* The behavior of Gatsby's `<Link>` without its markup: path prefixing, `trailingSlash`, relative
|
|
131
|
+
* paths, active state, prefetching and client-side navigation. Spread `linkProps` on any element or
|
|
132
|
+
* component that renders an `<a>`. Its `ref` is needed for `"viewport"` prefetching only.
|
|
133
|
+
*/
|
|
134
|
+
function useLink(options, ref) {
|
|
135
|
+
const config = useContext(LinkConfigContext);
|
|
136
|
+
const { location } = useContext(LocationContext);
|
|
137
|
+
const { to, state, replace, target, onClick, onMouseEnter, onMouseLeave, onFocus, onPointerDown } = options;
|
|
138
|
+
const partiallyActive = options.partiallyActive ?? config.partiallyActive;
|
|
139
|
+
const prefetchOption = options.prefetch ?? config.prefetch ?? getGlobalPrefetch();
|
|
140
|
+
const prefetch = prefetchOption === true ? "viewport" : prefetchOption;
|
|
141
|
+
const href = rewriteLinkPath(to, location.pathname);
|
|
142
|
+
const isExternal = !isLocalLink(href);
|
|
143
|
+
const encodedHref = encodeURI(href);
|
|
144
|
+
const isCurrent = !isExternal && location.pathname === encodedHref;
|
|
145
|
+
const isPartiallyCurrent = !isExternal && location.pathname.startsWith(encodedHref);
|
|
146
|
+
const isActive = partiallyActive ? isPartiallyCurrent : isCurrent;
|
|
147
|
+
const elRef = useRef(null);
|
|
148
|
+
const refProp = useCallback((el) => {
|
|
149
|
+
elRef.current = el;
|
|
150
|
+
assignRef(ref, el);
|
|
151
|
+
}, [ref]);
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
const el = elRef.current;
|
|
154
|
+
if (prefetch !== "viewport" || isExternal || !el || typeof window === "undefined" || !("IntersectionObserver" in window)) return;
|
|
155
|
+
let queued;
|
|
156
|
+
const unobserve = observeVisibility(el, (visible) => {
|
|
157
|
+
if (visible) {
|
|
158
|
+
if (queued) return;
|
|
159
|
+
const current = window.location.pathname + window.location.search;
|
|
160
|
+
const { pathname, search } = parsePath(href);
|
|
161
|
+
if (current !== pathname + search) queued = window.___loader?.enqueue(pathname + search);
|
|
162
|
+
} else {
|
|
163
|
+
queued?.abort();
|
|
164
|
+
queued = void 0;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return () => {
|
|
168
|
+
queued?.abort();
|
|
169
|
+
unobserve();
|
|
170
|
+
};
|
|
171
|
+
}, [
|
|
172
|
+
href,
|
|
173
|
+
isExternal,
|
|
174
|
+
prefetch
|
|
175
|
+
]);
|
|
176
|
+
const hoverTimer = useRef(void 0);
|
|
177
|
+
useEffect(() => () => clearTimeout(hoverTimer.current), []);
|
|
178
|
+
/** hover, focus or touch: the user is likely to follow the link, so the page is loaded */
|
|
179
|
+
const loadOnIntent = () => {
|
|
180
|
+
clearTimeout(hoverTimer.current);
|
|
181
|
+
if (prefetch === false || isExternal) return;
|
|
182
|
+
const { pathname, search } = parsePath(href);
|
|
183
|
+
window.___loader?.hovering(pathname + search);
|
|
184
|
+
};
|
|
185
|
+
const linkProps = {
|
|
186
|
+
href,
|
|
187
|
+
ref: refProp,
|
|
188
|
+
onMouseEnter(e) {
|
|
189
|
+
onMouseEnter?.(e);
|
|
190
|
+
if (prefetch === false || isExternal) return;
|
|
191
|
+
clearTimeout(hoverTimer.current);
|
|
192
|
+
hoverTimer.current = setTimeout(loadOnIntent, 50);
|
|
193
|
+
},
|
|
194
|
+
onMouseLeave(e) {
|
|
195
|
+
onMouseLeave?.(e);
|
|
196
|
+
clearTimeout(hoverTimer.current);
|
|
197
|
+
},
|
|
198
|
+
onFocus(e) {
|
|
199
|
+
onFocus?.(e);
|
|
200
|
+
loadOnIntent();
|
|
201
|
+
},
|
|
202
|
+
onPointerDown(e) {
|
|
203
|
+
onPointerDown?.(e);
|
|
204
|
+
loadOnIntent();
|
|
205
|
+
},
|
|
206
|
+
onClick(e) {
|
|
207
|
+
onClick?.(e);
|
|
208
|
+
if (isExternal || target || !isPlainLeftClick(e)) return;
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
let shouldReplace = replace;
|
|
211
|
+
if (typeof replace !== "boolean" && isCurrent) shouldReplace = true;
|
|
212
|
+
window.___navigate?.(href, {
|
|
213
|
+
state,
|
|
214
|
+
replace: shouldReplace
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
if (isCurrent) linkProps["aria-current"] = "page";
|
|
219
|
+
return {
|
|
220
|
+
href,
|
|
221
|
+
isCurrent,
|
|
222
|
+
isPartiallyCurrent,
|
|
223
|
+
isActive,
|
|
224
|
+
isExternal,
|
|
225
|
+
location,
|
|
226
|
+
linkProps
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function BuiltinLink(props) {
|
|
230
|
+
const config = useContext(LinkConfigContext);
|
|
231
|
+
const { to, getProps, onClick, onMouseEnter, onMouseLeave, onFocus, onPointerDown, activeClassName = config.activeClassName, activeStyle = config.activeStyle, innerRef, forwardedRef, partiallyActive, state, replace, prefetch, as: Component = "a", ...rest } = props;
|
|
232
|
+
const ref = useCallback((el) => {
|
|
233
|
+
assignRef(innerRef, el);
|
|
234
|
+
assignRef(forwardedRef, el);
|
|
235
|
+
}, [innerRef, forwardedRef]);
|
|
236
|
+
const link = useLink({
|
|
237
|
+
to,
|
|
238
|
+
state,
|
|
239
|
+
replace,
|
|
240
|
+
partiallyActive,
|
|
241
|
+
prefetch,
|
|
242
|
+
target: rest.target,
|
|
243
|
+
onClick,
|
|
244
|
+
onMouseEnter,
|
|
245
|
+
onMouseLeave,
|
|
246
|
+
onFocus,
|
|
247
|
+
onPointerDown
|
|
248
|
+
}, ref);
|
|
249
|
+
if (process.env.NODE_ENV !== "production" && link.isExternal) console.warn(`External link ${to} was detected in a Link component. Use the Link component only for internal links. See: https://gatsby.dev/internal-links`);
|
|
250
|
+
if (link.isExternal) return /* @__PURE__ */ jsx(Component, {
|
|
251
|
+
...rest,
|
|
252
|
+
...link.linkProps
|
|
253
|
+
});
|
|
254
|
+
const { href, isCurrent, isPartiallyCurrent, isActive, location } = link;
|
|
255
|
+
const extra = getProps ? getProps({
|
|
256
|
+
isCurrent,
|
|
257
|
+
isPartiallyCurrent,
|
|
258
|
+
href,
|
|
259
|
+
location
|
|
260
|
+
}) : isActive ? {
|
|
261
|
+
className: [rest.className, activeClassName].filter(Boolean).join(" ") || void 0,
|
|
262
|
+
style: rest.style || activeStyle ? {
|
|
263
|
+
...rest.style,
|
|
264
|
+
...activeStyle
|
|
265
|
+
} : void 0
|
|
266
|
+
} : null;
|
|
267
|
+
const { "aria-current": ariaCurrent, ...handlers } = link.linkProps;
|
|
268
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
269
|
+
"aria-current": ariaCurrent,
|
|
270
|
+
...rest,
|
|
271
|
+
...extra,
|
|
272
|
+
...handlers
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const Link = forwardRef(function Link(props, ref) {
|
|
276
|
+
const { component: Override } = useContext(LinkConfigContext);
|
|
277
|
+
const rendering = useContext(RenderingOverrideContext);
|
|
278
|
+
if (Override && Override !== rendering) return /* @__PURE__ */ jsx(RenderingOverrideContext.Provider, {
|
|
279
|
+
value: Override,
|
|
280
|
+
children: /* @__PURE__ */ jsx(Override, {
|
|
281
|
+
...props,
|
|
282
|
+
ref
|
|
283
|
+
})
|
|
284
|
+
});
|
|
285
|
+
return /* @__PURE__ */ jsx(BuiltinLink, {
|
|
286
|
+
...props,
|
|
287
|
+
forwardedRef: ref
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
function navigate(to, options) {
|
|
291
|
+
window.___navigate?.(rewriteLinkPath(to, window.location.pathname), options);
|
|
292
|
+
}
|
|
293
|
+
export { HOVER_DELAY_MS, Link, LinkProvider, navigate, parsePath, rewriteLinkPath, useLink, useLinkConfig, withAssetPrefix, withPrefix };
|