@hanzo/docs-core 16.2.5
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/algolia-IZEDLPHE.js +58 -0
- package/dist/breadcrumb.d.ts +46 -0
- package/dist/breadcrumb.js +81 -0
- package/dist/chunk-5PMI7QDD.js +220 -0
- package/dist/chunk-ADBHPKXG.js +78 -0
- package/dist/chunk-APKPSBSB.js +74 -0
- package/dist/chunk-CH7YHH7V.js +222 -0
- package/dist/chunk-EFVXL2PP.js +144 -0
- package/dist/chunk-EMWGTXSW.js +19 -0
- package/dist/chunk-FAEPKD7U.js +20 -0
- package/dist/chunk-FUUVPEA5.js +29 -0
- package/dist/chunk-GINBKBVQ.js +12 -0
- package/dist/chunk-GLRQBLGN.js +59 -0
- package/dist/chunk-JUF4WZ6G.js +117 -0
- package/dist/chunk-K4WNLOVQ.js +75 -0
- package/dist/chunk-L4JKQWCM.js +131 -0
- package/dist/chunk-MA6O2UUE.js +50 -0
- package/dist/chunk-ONG4RVCR.js +8 -0
- package/dist/chunk-OTD7MV33.js +53 -0
- package/dist/chunk-PFNP6PEB.js +11 -0
- package/dist/chunk-QJRXMG4S.js +275 -0
- package/dist/chunk-SH7BNTG7.js +38 -0
- package/dist/chunk-TWIDBWFG.js +84 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-VLSDGCJE.js +47 -0
- package/dist/chunk-W6WTLKRA.js +73 -0
- package/dist/chunk-X2HFD5QJ.js +275 -0
- package/dist/chunk-XJ6ZQNEX.js +91 -0
- package/dist/chunk-XN2LKXFZ.js +101 -0
- package/dist/chunk-XOFXGHS4.js +93 -0
- package/dist/chunk-XZSI7AHE.js +67 -0
- package/dist/chunk-YVVDKJ2H.js +34 -0
- package/dist/chunk-ZMWYLUDP.js +21 -0
- package/dist/content/github.d.ts +40 -0
- package/dist/content/github.js +44 -0
- package/dist/content/index.d.ts +16 -0
- package/dist/content/index.js +30 -0
- package/dist/content/mdx/preset-bundler.d.ts +31 -0
- package/dist/content/mdx/preset-bundler.js +72 -0
- package/dist/content/mdx/preset-runtime.d.ts +31 -0
- package/dist/content/mdx/preset-runtime.js +71 -0
- package/dist/content/toc.d.ts +21 -0
- package/dist/content/toc.js +22 -0
- package/dist/definitions-pJ7PybYY.d.ts +60 -0
- package/dist/dynamic-link.d.ts +12 -0
- package/dist/dynamic-link.js +32 -0
- package/dist/fetch-IBTWQCJR.js +22 -0
- package/dist/framework/index.d.ts +41 -0
- package/dist/framework/index.js +18 -0
- package/dist/framework/next.d.ts +12 -0
- package/dist/framework/next.js +31 -0
- package/dist/framework/react-router.d.ts +12 -0
- package/dist/framework/react-router.js +59 -0
- package/dist/framework/tanstack.d.ts +15 -0
- package/dist/framework/tanstack.js +72 -0
- package/dist/framework/waku.d.ts +12 -0
- package/dist/framework/waku.js +63 -0
- package/dist/highlight/client.d.ts +15 -0
- package/dist/highlight/client.js +18 -0
- package/dist/highlight/index.d.ts +30 -0
- package/dist/highlight/index.js +13 -0
- package/dist/i18n/index.d.ts +39 -0
- package/dist/i18n/index.js +9 -0
- package/dist/i18n/middleware.d.ts +34 -0
- package/dist/i18n/middleware.js +76 -0
- package/dist/link.d.ts +18 -0
- package/dist/link.js +9 -0
- package/dist/loader-BvlPPJX0.d.ts +321 -0
- package/dist/mdx-plugins/codeblock-utils.d.ts +29 -0
- package/dist/mdx-plugins/codeblock-utils.js +9 -0
- package/dist/mdx-plugins/index.d.ts +20 -0
- package/dist/mdx-plugins/index.js +73 -0
- package/dist/mdx-plugins/rehype-code.d.ts +55 -0
- package/dist/mdx-plugins/rehype-code.js +15 -0
- package/dist/mdx-plugins/rehype-toc.d.ts +14 -0
- package/dist/mdx-plugins/rehype-toc.js +7 -0
- package/dist/mdx-plugins/remark-admonition.d.ts +20 -0
- package/dist/mdx-plugins/remark-admonition.js +8 -0
- package/dist/mdx-plugins/remark-code-tab.d.ts +30 -0
- package/dist/mdx-plugins/remark-code-tab.js +8 -0
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +27 -0
- package/dist/mdx-plugins/remark-directive-admonition.js +7 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +1 -0
- package/dist/mdx-plugins/remark-gfm.js +7 -0
- package/dist/mdx-plugins/remark-heading.d.ts +31 -0
- package/dist/mdx-plugins/remark-heading.js +8 -0
- package/dist/mdx-plugins/remark-image.d.ts +57 -0
- package/dist/mdx-plugins/remark-image.js +7 -0
- package/dist/mdx-plugins/remark-mdx-files.d.ts +40 -0
- package/dist/mdx-plugins/remark-mdx-files.js +7 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +15 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.js +7 -0
- package/dist/mdx-plugins/remark-npm.d.ts +31 -0
- package/dist/mdx-plugins/remark-npm.js +8 -0
- package/dist/mdx-plugins/remark-steps.d.ts +23 -0
- package/dist/mdx-plugins/remark-steps.js +7 -0
- package/dist/mdx-plugins/remark-structure.d.ts +71 -0
- package/dist/mdx-plugins/remark-structure.js +12 -0
- package/dist/mixedbread-RAHDVXGJ.js +118 -0
- package/dist/negotiation/index.d.ts +19 -0
- package/dist/negotiation/index.js +11 -0
- package/dist/orama-cloud-UZAPMPFV.js +93 -0
- package/dist/page-tree/index.d.ts +33 -0
- package/dist/page-tree/index.js +17 -0
- package/dist/search/algolia.d.ts +69 -0
- package/dist/search/algolia.js +71 -0
- package/dist/search/client.d.ts +140 -0
- package/dist/search/client.js +99 -0
- package/dist/search/index.d.ts +26 -0
- package/dist/search/index.js +7 -0
- package/dist/search/orama-cloud.d.ts +79 -0
- package/dist/search/orama-cloud.js +60 -0
- package/dist/search/server.d.ts +136 -0
- package/dist/search/server.js +400 -0
- package/dist/source/client/index.d.ts +16 -0
- package/dist/source/client/index.js +41 -0
- package/dist/source/index.d.ts +42 -0
- package/dist/source/index.js +776 -0
- package/dist/source/plugins/lucide-icons.d.ts +14 -0
- package/dist/source/plugins/lucide-icons.js +23 -0
- package/dist/source/schema.d.ts +26 -0
- package/dist/source/schema.js +25 -0
- package/dist/static-A2YJ5TXV.js +62 -0
- package/dist/toc.d.ts +43 -0
- package/dist/toc.js +151 -0
- package/dist/util-bZU2QeJ2.d.ts +6 -0
- package/dist/utils/use-effect-event.d.ts +9 -0
- package/dist/utils/use-effect-event.js +16 -0
- package/dist/utils/use-media-query.d.ts +3 -0
- package/dist/utils/use-media-query.js +23 -0
- package/dist/utils/use-on-change.d.ts +8 -0
- package/dist/utils/use-on-change.js +7 -0
- package/package.json +222 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Link
|
|
4
|
+
} from "./chunk-SH7BNTG7.js";
|
|
5
|
+
import {
|
|
6
|
+
useParams
|
|
7
|
+
} from "./chunk-K4WNLOVQ.js";
|
|
8
|
+
import "./chunk-U67V476Y.js";
|
|
9
|
+
|
|
10
|
+
// src/dynamic-link.tsx
|
|
11
|
+
import { forwardRef, useMemo } from "react";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
var DynamicLink = forwardRef(
|
|
14
|
+
({ href, ...props }, ref) => {
|
|
15
|
+
const params = useParams();
|
|
16
|
+
const url = useMemo(() => {
|
|
17
|
+
return href?.replace(/\[.*]/, (key) => {
|
|
18
|
+
const mappedKey = key.slice(1, -1);
|
|
19
|
+
const value = mappedKey in params ? params[mappedKey] : void 0;
|
|
20
|
+
if (!value) return "";
|
|
21
|
+
return typeof value === "string" ? value : value.join("/");
|
|
22
|
+
});
|
|
23
|
+
}, [params, href]);
|
|
24
|
+
return /* @__PURE__ */ jsx(Link, { ref, href: url, ...props });
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
DynamicLink.displayName = "DynamicLink";
|
|
28
|
+
var dynamic_link_default = DynamicLink;
|
|
29
|
+
export {
|
|
30
|
+
DynamicLink,
|
|
31
|
+
dynamic_link_default as default
|
|
32
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "./chunk-U67V476Y.js";
|
|
2
|
+
|
|
3
|
+
// src/search/client/fetch.ts
|
|
4
|
+
var cache = /* @__PURE__ */ new Map();
|
|
5
|
+
async function fetchDocs(query, { api = "/api/search", locale, tag }) {
|
|
6
|
+
const url = new URL(api, window.location.origin);
|
|
7
|
+
url.searchParams.set("query", query);
|
|
8
|
+
if (locale) url.searchParams.set("locale", locale);
|
|
9
|
+
if (tag)
|
|
10
|
+
url.searchParams.set("tag", Array.isArray(tag) ? tag.join(",") : tag);
|
|
11
|
+
const key = url.toString();
|
|
12
|
+
const cached = cache.get(key);
|
|
13
|
+
if (cached) return cached;
|
|
14
|
+
const res = await fetch(url);
|
|
15
|
+
if (!res.ok) throw new Error(await res.text());
|
|
16
|
+
const result = await res.json();
|
|
17
|
+
cache.set(key, result);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
fetchDocs
|
|
22
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentProps, FC, ReactNode } from 'react';
|
|
3
|
+
import { StaticImport } from 'next/dist/shared/lib/get-img-props';
|
|
4
|
+
|
|
5
|
+
interface ImageProps extends Omit<ComponentProps<'img'>, 'src'> {
|
|
6
|
+
sizes?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Next.js Image component has other allowed type for `src`
|
|
9
|
+
*/
|
|
10
|
+
src?: string | StaticImport;
|
|
11
|
+
/**
|
|
12
|
+
* priority of image (from Next.js)
|
|
13
|
+
*/
|
|
14
|
+
priority?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface LinkProps extends ComponentProps<'a'> {
|
|
17
|
+
prefetch?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface Router {
|
|
20
|
+
push: (url: string) => void;
|
|
21
|
+
refresh: () => void;
|
|
22
|
+
}
|
|
23
|
+
interface Framework {
|
|
24
|
+
usePathname: () => string;
|
|
25
|
+
useParams: () => Record<string, string | string[]>;
|
|
26
|
+
useRouter: () => Router;
|
|
27
|
+
Link?: FC<ComponentProps<'a'> & {
|
|
28
|
+
prefetch?: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
Image?: FC<ImageProps>;
|
|
31
|
+
}
|
|
32
|
+
declare function FrameworkProvider({ Link, useRouter, useParams, usePathname, Image, children, }: Framework & {
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
}): react_jsx_runtime.JSX.Element;
|
|
35
|
+
declare function usePathname(): string;
|
|
36
|
+
declare function useRouter(): Router;
|
|
37
|
+
declare function useParams(): Record<string, string | string[]>;
|
|
38
|
+
declare function Image(props: ImageProps): react_jsx_runtime.JSX.Element;
|
|
39
|
+
declare function Link(props: LinkProps): react_jsx_runtime.JSX.Element;
|
|
40
|
+
|
|
41
|
+
export { type Framework, FrameworkProvider, Image, type ImageProps, Link, type Router, useParams, usePathname, useRouter };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
FrameworkProvider,
|
|
4
|
+
Image,
|
|
5
|
+
Link,
|
|
6
|
+
useParams,
|
|
7
|
+
usePathname,
|
|
8
|
+
useRouter
|
|
9
|
+
} from "../chunk-K4WNLOVQ.js";
|
|
10
|
+
import "../chunk-U67V476Y.js";
|
|
11
|
+
export {
|
|
12
|
+
FrameworkProvider,
|
|
13
|
+
Image,
|
|
14
|
+
Link,
|
|
15
|
+
useParams,
|
|
16
|
+
usePathname,
|
|
17
|
+
useRouter
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Framework } from './index.js';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import 'next/dist/shared/lib/get-img-props';
|
|
5
|
+
|
|
6
|
+
declare function NextProvider({ children, Link: CustomLink, Image: CustomImage, }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
Link?: Framework['Link'];
|
|
9
|
+
Image?: Framework['Image'];
|
|
10
|
+
}): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { NextProvider };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
FrameworkProvider
|
|
4
|
+
} from "../chunk-K4WNLOVQ.js";
|
|
5
|
+
import "../chunk-U67V476Y.js";
|
|
6
|
+
|
|
7
|
+
// src/framework/next.tsx
|
|
8
|
+
import { useParams, usePathname, useRouter } from "next/navigation";
|
|
9
|
+
import Link from "next/link";
|
|
10
|
+
import Image from "next/image";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
function NextProvider({
|
|
13
|
+
children,
|
|
14
|
+
Link: CustomLink,
|
|
15
|
+
Image: CustomImage
|
|
16
|
+
}) {
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
FrameworkProvider,
|
|
19
|
+
{
|
|
20
|
+
usePathname,
|
|
21
|
+
useRouter,
|
|
22
|
+
useParams,
|
|
23
|
+
Link: CustomLink ?? Link,
|
|
24
|
+
Image: CustomImage ?? Image,
|
|
25
|
+
children
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
NextProvider
|
|
31
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { Framework } from './index.js';
|
|
4
|
+
import 'next/dist/shared/lib/get-img-props';
|
|
5
|
+
|
|
6
|
+
declare function ReactRouterProvider({ children, Link: CustomLink, Image: CustomImage, }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
Link?: Framework['Link'];
|
|
9
|
+
Image?: Framework['Image'];
|
|
10
|
+
}): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { ReactRouterProvider };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FrameworkProvider
|
|
3
|
+
} from "../chunk-K4WNLOVQ.js";
|
|
4
|
+
import "../chunk-U67V476Y.js";
|
|
5
|
+
|
|
6
|
+
// src/framework/react-router.tsx
|
|
7
|
+
import { useMemo } from "react";
|
|
8
|
+
import {
|
|
9
|
+
Link,
|
|
10
|
+
useLocation,
|
|
11
|
+
useNavigate,
|
|
12
|
+
useParams,
|
|
13
|
+
useRevalidator
|
|
14
|
+
} from "react-router";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
var framework = {
|
|
17
|
+
usePathname() {
|
|
18
|
+
return useLocation().pathname;
|
|
19
|
+
},
|
|
20
|
+
useParams() {
|
|
21
|
+
return useParams();
|
|
22
|
+
},
|
|
23
|
+
useRouter() {
|
|
24
|
+
const navigate = useNavigate();
|
|
25
|
+
const revalidator = useRevalidator();
|
|
26
|
+
return useMemo(
|
|
27
|
+
() => ({
|
|
28
|
+
push(url) {
|
|
29
|
+
navigate(url);
|
|
30
|
+
},
|
|
31
|
+
refresh() {
|
|
32
|
+
void revalidator.revalidate();
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
[navigate, revalidator]
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
Link({ href, prefetch, ...props }) {
|
|
39
|
+
return /* @__PURE__ */ jsx(Link, { to: href, prefetch: prefetch ? "intent" : "none", ...props, children: props.children });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
function ReactRouterProvider({
|
|
43
|
+
children,
|
|
44
|
+
Link: CustomLink,
|
|
45
|
+
Image: CustomImage
|
|
46
|
+
}) {
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
FrameworkProvider,
|
|
49
|
+
{
|
|
50
|
+
...framework,
|
|
51
|
+
Link: CustomLink ?? framework.Link,
|
|
52
|
+
Image: CustomImage ?? framework.Image,
|
|
53
|
+
children
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
ReactRouterProvider
|
|
59
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { Framework } from './index.js';
|
|
4
|
+
import 'next/dist/shared/lib/get-img-props';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fumadocs adapter for Tanstack Router/Start
|
|
8
|
+
*/
|
|
9
|
+
declare function TanstackProvider({ children, Link: CustomLink, Image: CustomImage, }: {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
Link?: Framework['Link'];
|
|
12
|
+
Image?: Framework['Image'];
|
|
13
|
+
}): react_jsx_runtime.JSX.Element;
|
|
14
|
+
|
|
15
|
+
export { TanstackProvider };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FrameworkProvider
|
|
3
|
+
} from "../chunk-K4WNLOVQ.js";
|
|
4
|
+
import "../chunk-U67V476Y.js";
|
|
5
|
+
|
|
6
|
+
// src/framework/tanstack.tsx
|
|
7
|
+
import { useRef, useMemo } from "react";
|
|
8
|
+
import {
|
|
9
|
+
useParams,
|
|
10
|
+
Link,
|
|
11
|
+
useRouter,
|
|
12
|
+
useRouterState
|
|
13
|
+
} from "@tanstack/react-router";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
var framework = {
|
|
16
|
+
Link({ href, prefetch = true, ...props }) {
|
|
17
|
+
return /* @__PURE__ */ jsx(Link, { to: href, preload: prefetch ? "intent" : false, ...props, children: props.children });
|
|
18
|
+
},
|
|
19
|
+
usePathname() {
|
|
20
|
+
const { isLoading, pathname } = useRouterState({
|
|
21
|
+
select: (state) => ({
|
|
22
|
+
isLoading: state.isLoading,
|
|
23
|
+
pathname: state.location.pathname
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
const activePathname = useRef(pathname);
|
|
27
|
+
return useMemo(() => {
|
|
28
|
+
if (isLoading) {
|
|
29
|
+
return activePathname.current;
|
|
30
|
+
}
|
|
31
|
+
activePathname.current = pathname;
|
|
32
|
+
return pathname;
|
|
33
|
+
}, [isLoading, pathname]);
|
|
34
|
+
},
|
|
35
|
+
useRouter() {
|
|
36
|
+
const router = useRouter();
|
|
37
|
+
return useMemo(
|
|
38
|
+
() => ({
|
|
39
|
+
push(url) {
|
|
40
|
+
void router.navigate({
|
|
41
|
+
href: url
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
refresh() {
|
|
45
|
+
void router.invalidate();
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
[router]
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
useParams() {
|
|
52
|
+
return useParams({ strict: false });
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function TanstackProvider({
|
|
56
|
+
children,
|
|
57
|
+
Link: CustomLink,
|
|
58
|
+
Image: CustomImage
|
|
59
|
+
}) {
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
FrameworkProvider,
|
|
62
|
+
{
|
|
63
|
+
...framework,
|
|
64
|
+
Link: CustomLink ?? framework.Link,
|
|
65
|
+
Image: CustomImage ?? framework.Image,
|
|
66
|
+
children
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
TanstackProvider
|
|
72
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { Framework } from './index.js';
|
|
4
|
+
import 'next/dist/shared/lib/get-img-props';
|
|
5
|
+
|
|
6
|
+
declare function WakuProvider({ children, Link: CustomLink, Image: CustomImage, }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
Link?: Framework['Link'];
|
|
9
|
+
Image?: Framework['Image'];
|
|
10
|
+
}): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { WakuProvider };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
FrameworkProvider
|
|
4
|
+
} from "../chunk-K4WNLOVQ.js";
|
|
5
|
+
import "../chunk-U67V476Y.js";
|
|
6
|
+
|
|
7
|
+
// src/framework/waku.tsx
|
|
8
|
+
import { useMemo } from "react";
|
|
9
|
+
import { Link as WakuLink, useRouter } from "waku";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
var framework = {
|
|
12
|
+
usePathname() {
|
|
13
|
+
const { path } = useRouter();
|
|
14
|
+
return path;
|
|
15
|
+
},
|
|
16
|
+
useParams() {
|
|
17
|
+
const { query } = useRouter();
|
|
18
|
+
return useMemo(() => {
|
|
19
|
+
const params = new URLSearchParams(query);
|
|
20
|
+
return Object.fromEntries(
|
|
21
|
+
Array.from(params.entries()).map(([key, value]) => [
|
|
22
|
+
key,
|
|
23
|
+
Array.isArray(value) ? value[0] : value
|
|
24
|
+
])
|
|
25
|
+
);
|
|
26
|
+
}, [query]);
|
|
27
|
+
},
|
|
28
|
+
useRouter() {
|
|
29
|
+
const router = useRouter();
|
|
30
|
+
return useMemo(
|
|
31
|
+
() => ({
|
|
32
|
+
push(url) {
|
|
33
|
+
void router.push(url);
|
|
34
|
+
},
|
|
35
|
+
refresh() {
|
|
36
|
+
void router.push(router.path);
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
[router]
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
Link({ href, prefetch = true, ...props }) {
|
|
43
|
+
return /* @__PURE__ */ jsx(WakuLink, { to: href, unstable_prefetchOnEnter: prefetch, ...props, children: props.children });
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
function WakuProvider({
|
|
47
|
+
children,
|
|
48
|
+
Link: CustomLink,
|
|
49
|
+
Image: CustomImage
|
|
50
|
+
}) {
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
FrameworkProvider,
|
|
53
|
+
{
|
|
54
|
+
...framework,
|
|
55
|
+
Link: CustomLink ?? framework.Link,
|
|
56
|
+
Image: CustomImage ?? framework.Image,
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
WakuProvider
|
|
63
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DependencyList, ReactNode } from 'react';
|
|
2
|
+
import { HighlightOptions } from './index.js';
|
|
3
|
+
import 'shiki';
|
|
4
|
+
import 'shiki/themes';
|
|
5
|
+
import 'hast-util-to-jsx-runtime';
|
|
6
|
+
import 'hast';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* get highlighted results, should be used with React Suspense API.
|
|
10
|
+
*
|
|
11
|
+
* note: results are cached with (lang, code) as keys, if this is not the desired behaviour, pass a `deps` instead.
|
|
12
|
+
*/
|
|
13
|
+
declare function useShiki(code: string, options: HighlightOptions, deps?: DependencyList): ReactNode;
|
|
14
|
+
|
|
15
|
+
export { useShiki };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
highlight
|
|
4
|
+
} from "../chunk-XN2LKXFZ.js";
|
|
5
|
+
import "../chunk-U67V476Y.js";
|
|
6
|
+
|
|
7
|
+
// src/highlight/client.tsx
|
|
8
|
+
import { use, useMemo } from "react";
|
|
9
|
+
var promises = {};
|
|
10
|
+
function useShiki(code, options, deps) {
|
|
11
|
+
const key = useMemo(() => {
|
|
12
|
+
return deps ? JSON.stringify(deps) : `${options.lang}:${code}`;
|
|
13
|
+
}, [code, deps, options.lang]);
|
|
14
|
+
return use(promises[key] ??= highlight(code, options));
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
useShiki
|
|
18
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CodeToHastOptionsCommon, BundledLanguage, CodeOptionsMeta, CodeOptionsThemes, BundledHighlighterOptions, Highlighter } from 'shiki';
|
|
2
|
+
import { BundledTheme } from 'shiki/themes';
|
|
3
|
+
import { Components, Options } from 'hast-util-to-jsx-runtime';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { Root } from 'hast';
|
|
6
|
+
|
|
7
|
+
type HighlightOptionsCommon = CodeToHastOptionsCommon<BundledLanguage> & CodeOptionsMeta & {
|
|
8
|
+
/**
|
|
9
|
+
* The Regex Engine for Shiki
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue 'js'
|
|
12
|
+
*/
|
|
13
|
+
engine?: 'js' | 'oniguruma';
|
|
14
|
+
components?: Partial<Components>;
|
|
15
|
+
fallbackLanguage?: BundledLanguage;
|
|
16
|
+
};
|
|
17
|
+
type HighlightOptionsThemes = CodeOptionsThemes<BundledTheme>;
|
|
18
|
+
type HighlightOptions = HighlightOptionsCommon & (HighlightOptionsThemes | Record<never, never>);
|
|
19
|
+
declare function highlightHast(code: string, options: HighlightOptions): Promise<Root>;
|
|
20
|
+
declare function hastToJsx(hast: Root, options?: Partial<Options>): JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* Get Shiki highlighter instance of Fumadocs (mostly for internal use, you should use Shiki directly over this).
|
|
23
|
+
*
|
|
24
|
+
* @param engineType - Shiki Regex engine to use.
|
|
25
|
+
* @param options - Shiki options.
|
|
26
|
+
*/
|
|
27
|
+
declare function getHighlighter(engineType: 'js' | 'oniguruma', options: Omit<BundledHighlighterOptions<BundledLanguage, BundledTheme>, 'engine'>): Promise<Highlighter>;
|
|
28
|
+
declare function highlight(code: string, options: HighlightOptions): Promise<ReactNode>;
|
|
29
|
+
|
|
30
|
+
export { type HighlightOptions, type HighlightOptionsCommon, type HighlightOptionsThemes, getHighlighter, hastToJsx, highlight, highlightHast };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
interface I18nConfig<Languages extends string = string> {
|
|
2
|
+
/**
|
|
3
|
+
* Supported locale codes.
|
|
4
|
+
*
|
|
5
|
+
* A page tree will be built for each language.
|
|
6
|
+
*/
|
|
7
|
+
languages: Languages[];
|
|
8
|
+
/**
|
|
9
|
+
* Default locale if not specified
|
|
10
|
+
*/
|
|
11
|
+
defaultLanguage: Languages;
|
|
12
|
+
/**
|
|
13
|
+
* Don't show the locale prefix on URL.
|
|
14
|
+
*
|
|
15
|
+
* - `always`: Always hide the prefix
|
|
16
|
+
* - `default-locale`: Only hide the default locale
|
|
17
|
+
* - `never`: Never hide the prefix
|
|
18
|
+
*
|
|
19
|
+
* This API uses `NextResponse.rewrite`.
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue 'never'
|
|
22
|
+
*/
|
|
23
|
+
hideLocale?: 'always' | 'default-locale' | 'never';
|
|
24
|
+
/**
|
|
25
|
+
* Used by `loader()`, specify the way to parse i18n file structure.
|
|
26
|
+
*
|
|
27
|
+
* @defaultValue 'dot'
|
|
28
|
+
*/
|
|
29
|
+
parser?: 'dot' | 'dir' | 'none';
|
|
30
|
+
/**
|
|
31
|
+
* the fallback language when the page has no translations available for a given locale.
|
|
32
|
+
*
|
|
33
|
+
* Default to ``defaultLanguage`, no fallback when set to `null`.
|
|
34
|
+
*/
|
|
35
|
+
fallbackLanguage?: Languages | null;
|
|
36
|
+
}
|
|
37
|
+
declare function defineI18n<Languages extends string>(config: I18nConfig<Languages>): I18nConfig<Languages>;
|
|
38
|
+
|
|
39
|
+
export { type I18nConfig, defineI18n };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { NextProxy } from 'next/server';
|
|
2
|
+
import { I18nConfig } from './index.js';
|
|
3
|
+
import { NextURL } from 'next/dist/server/web/next-url';
|
|
4
|
+
|
|
5
|
+
interface MiddlewareOptions extends I18nConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Either:
|
|
8
|
+
* - A formatter object
|
|
9
|
+
* - A function that adds the locale prefix to pathname
|
|
10
|
+
*/
|
|
11
|
+
format?: URLFormatter | ((locale: string, pathname: string) => string);
|
|
12
|
+
/**
|
|
13
|
+
* the cookie to store locale code when `hideLocale` is set to `always`.
|
|
14
|
+
*/
|
|
15
|
+
cookieName?: string;
|
|
16
|
+
}
|
|
17
|
+
interface URLFormatter {
|
|
18
|
+
/**
|
|
19
|
+
* get locale code from request URL
|
|
20
|
+
*/
|
|
21
|
+
get: (url: NextURL) => string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* add locale code to request URL (which is missing the locale).
|
|
24
|
+
*/
|
|
25
|
+
add: (url: NextURL, locale: string) => URL;
|
|
26
|
+
/**
|
|
27
|
+
* remove locale code from request URL
|
|
28
|
+
*/
|
|
29
|
+
remove: (url: NextURL) => URL;
|
|
30
|
+
}
|
|
31
|
+
declare const DefaultFormatter: URLFormatter;
|
|
32
|
+
declare function createI18nMiddleware({ languages, defaultLanguage, format, cookieName, hideLocale, }: MiddlewareOptions): NextProxy;
|
|
33
|
+
|
|
34
|
+
export { DefaultFormatter, type URLFormatter, createI18nMiddleware };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getNegotiator
|
|
3
|
+
} from "../chunk-YVVDKJ2H.js";
|
|
4
|
+
import "../chunk-U67V476Y.js";
|
|
5
|
+
|
|
6
|
+
// src/i18n/middleware.ts
|
|
7
|
+
import { match as matchLocale } from "@formatjs/intl-localematcher";
|
|
8
|
+
import { NextResponse } from "next/server";
|
|
9
|
+
var DefaultFormatter = {
|
|
10
|
+
get(url) {
|
|
11
|
+
const segs = url.pathname.split("/");
|
|
12
|
+
if (segs.length > 1 && segs[1]) return segs[1];
|
|
13
|
+
},
|
|
14
|
+
add(url, locale) {
|
|
15
|
+
const next = new URL(url);
|
|
16
|
+
next.pathname = `${url.basePath}/${locale}/${url.pathname}`.replaceAll(
|
|
17
|
+
/\/+/g,
|
|
18
|
+
"/"
|
|
19
|
+
);
|
|
20
|
+
return next;
|
|
21
|
+
},
|
|
22
|
+
remove(url) {
|
|
23
|
+
const next = new URL(url);
|
|
24
|
+
const pathname = url.pathname.split("/").slice(2).join("/");
|
|
25
|
+
next.pathname = `${url.basePath}/${pathname}`.replaceAll(/\/+/g, "/");
|
|
26
|
+
return next;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function createI18nMiddleware({
|
|
30
|
+
languages,
|
|
31
|
+
defaultLanguage,
|
|
32
|
+
format = DefaultFormatter,
|
|
33
|
+
cookieName = "FD_LOCALE",
|
|
34
|
+
hideLocale = "never"
|
|
35
|
+
}) {
|
|
36
|
+
let formatter;
|
|
37
|
+
if (typeof format === "function") {
|
|
38
|
+
formatter = {
|
|
39
|
+
...DefaultFormatter,
|
|
40
|
+
add(url, locale) {
|
|
41
|
+
const next = new URL(url);
|
|
42
|
+
next.pathname = format(locale, url.pathname);
|
|
43
|
+
return next;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
formatter = format;
|
|
48
|
+
}
|
|
49
|
+
return (request) => {
|
|
50
|
+
const url = request.nextUrl;
|
|
51
|
+
let pathLocale = formatter.get(url);
|
|
52
|
+
if (pathLocale && !languages.includes(pathLocale)) pathLocale = void 0;
|
|
53
|
+
if (!pathLocale) {
|
|
54
|
+
if (hideLocale === "default-locale") {
|
|
55
|
+
return NextResponse.rewrite(formatter.add(url, defaultLanguage));
|
|
56
|
+
}
|
|
57
|
+
const finalLanguages = getNegotiator(request).languages(languages);
|
|
58
|
+
const preferred = matchLocale(finalLanguages, languages, defaultLanguage);
|
|
59
|
+
if (hideLocale === "always") {
|
|
60
|
+
const locale = request.cookies.get(cookieName)?.value ?? preferred;
|
|
61
|
+
return NextResponse.rewrite(formatter.add(url, locale));
|
|
62
|
+
}
|
|
63
|
+
return NextResponse.redirect(formatter.add(url, preferred));
|
|
64
|
+
}
|
|
65
|
+
if (hideLocale === "always" || hideLocale === "default-locale" && pathLocale === defaultLanguage) {
|
|
66
|
+
const res = NextResponse.redirect(formatter.remove(url));
|
|
67
|
+
res.cookies.set(cookieName, pathLocale);
|
|
68
|
+
return res;
|
|
69
|
+
}
|
|
70
|
+
return NextResponse.next();
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
DefaultFormatter,
|
|
75
|
+
createI18nMiddleware
|
|
76
|
+
};
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { AnchorHTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
5
|
+
/**
|
|
6
|
+
* If the href is an external URL
|
|
7
|
+
*
|
|
8
|
+
* automatically determined by default
|
|
9
|
+
*/
|
|
10
|
+
external?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Prefetch links, supported on Next.js
|
|
13
|
+
*/
|
|
14
|
+
prefetch?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare const Link: react.ForwardRefExoticComponent<LinkProps & react.RefAttributes<HTMLAnchorElement>>;
|
|
17
|
+
|
|
18
|
+
export { type LinkProps, Link as default };
|