@vezham/docs-core 1.0.1
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/advanced-Ct13khZr.js +79 -0
- package/dist/algolia-C0E5qQhM.d.ts +66 -0
- package/dist/breadcrumb.d.ts +46 -0
- package/dist/breadcrumb.js +59 -0
- package/dist/build-doc-4OvfjVN2.js +85 -0
- package/dist/client-kQ39Ub0-.d.ts +247 -0
- package/dist/codeblock-utils-CyP8qsYv.d.ts +29 -0
- package/dist/content/github.d.ts +41 -0
- package/dist/content/github.js +28 -0
- package/dist/content/md/frontmatter.d.ts +15 -0
- package/dist/content/md/frontmatter.js +24 -0
- package/dist/content/md.d.ts +24 -0
- package/dist/content/md.js +43 -0
- package/dist/content/mdx/preset-bundler.d.ts +29 -0
- package/dist/content/mdx/preset-bundler.js +39 -0
- package/dist/content/mdx/preset-runtime.d.ts +26 -0
- package/dist/content/mdx/preset-runtime.js +36 -0
- package/dist/content/toc.d.ts +19 -0
- package/dist/content/toc.js +14 -0
- package/dist/definitions-CFOhwE1k.d.ts +72 -0
- package/dist/dynamic-CTsodhTH.js +905 -0
- package/dist/dynamic-link.d.ts +12 -0
- package/dist/dynamic-link.js +31 -0
- package/dist/endpoint-MyoBU5IC.js +28 -0
- package/dist/framework/astro.d.ts +21 -0
- package/dist/framework/astro.js +52 -0
- package/dist/framework/index.d.ts +40 -0
- package/dist/framework/index.js +66 -0
- package/dist/framework/next.d.ts +10 -0
- package/dist/framework/next.js +19 -0
- package/dist/framework/react-router.d.ts +10 -0
- package/dist/framework/react-router.js +43 -0
- package/dist/framework/tanstack.d.ts +13 -0
- package/dist/framework/tanstack.js +54 -0
- package/dist/framework/waku.d.ts +10 -0
- package/dist/framework/waku.js +46 -0
- package/dist/highlight/client.d.ts +11 -0
- package/dist/highlight/client.js +15 -0
- package/dist/highlight/index.d.ts +31 -0
- package/dist/highlight/index.js +30 -0
- package/dist/highlight/shiki/full.d.ts +7 -0
- package/dist/highlight/shiki/full.js +23 -0
- package/dist/highlight/shiki/index.d.ts +2 -0
- package/dist/highlight/shiki/index.js +27 -0
- package/dist/highlight/shiki/react.d.ts +23 -0
- package/dist/highlight/shiki/react.js +50 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +63 -0
- package/dist/i18n/middleware.d.ts +34 -0
- package/dist/i18n/middleware.js +3855 -0
- package/dist/icon-BILaoXeg.js +17 -0
- package/dist/index-B-0R0VbS.d.ts +18 -0
- package/dist/index-BM36H-xw.d.ts +36 -0
- package/dist/index-BMEUQz-F.d.ts +21 -0
- package/dist/index-DAYtLGbx.d.ts +16 -0
- package/dist/index-DIwKCYOz.d.ts +513 -0
- package/dist/index-DydiXvgS.d.ts +90 -0
- package/dist/index-E8Qh_yQs.d.ts +49 -0
- package/dist/is-equal-LdLqRs0o.js +8 -0
- package/dist/link.d.ts +17 -0
- package/dist/link.js +23 -0
- package/dist/mdx-plugins/codeblock-utils.d.ts +2 -0
- package/dist/mdx-plugins/codeblock-utils.js +68 -0
- package/dist/mdx-plugins/index.d.ts +20 -0
- package/dist/mdx-plugins/index.js +18 -0
- package/dist/mdx-plugins/rehype-code.core.d.ts +3 -0
- package/dist/mdx-plugins/rehype-code.core.js +3 -0
- package/dist/mdx-plugins/rehype-code.d.ts +4 -0
- package/dist/mdx-plugins/rehype-code.js +24 -0
- package/dist/mdx-plugins/rehype-toc.d.ts +2 -0
- package/dist/mdx-plugins/rehype-toc.js +139 -0
- package/dist/mdx-plugins/remark-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-admonition.js +71 -0
- package/dist/mdx-plugins/remark-block-id.d.ts +37 -0
- package/dist/mdx-plugins/remark-block-id.js +41 -0
- package/dist/mdx-plugins/remark-code-tab.d.ts +2 -0
- package/dist/mdx-plugins/remark-code-tab.js +190 -0
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-directive-admonition.js +57 -0
- package/dist/mdx-plugins/remark-feedback-block.d.ts +2 -0
- package/dist/mdx-plugins/remark-feedback-block.js +54 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +2 -0
- package/dist/mdx-plugins/remark-gfm.js +2 -0
- package/dist/mdx-plugins/remark-heading.d.ts +2 -0
- package/dist/mdx-plugins/remark-heading.js +46 -0
- package/dist/mdx-plugins/remark-image.d.ts +2 -0
- package/dist/mdx-plugins/remark-image.js +167 -0
- package/dist/mdx-plugins/remark-llms.d.ts +2 -0
- package/dist/mdx-plugins/remark-llms.js +338 -0
- package/dist/mdx-plugins/remark-llms.runtime.d.ts +10 -0
- package/dist/mdx-plugins/remark-llms.runtime.js +24 -0
- package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-files.js +182 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.js +28 -0
- package/dist/mdx-plugins/remark-npm.d.ts +2 -0
- package/dist/mdx-plugins/remark-npm.js +76 -0
- package/dist/mdx-plugins/remark-steps.d.ts +2 -0
- package/dist/mdx-plugins/remark-steps.js +93 -0
- package/dist/mdx-plugins/remark-structure.d.ts +2 -0
- package/dist/mdx-plugins/remark-structure.js +118 -0
- package/dist/mdx-plugins/stringifier.d.ts +2 -0
- package/dist/mdx-plugins/stringifier.js +91 -0
- package/dist/mdx-plugins/transformer-icon.d.ts +2 -0
- package/dist/mdx-plugins/transformer-icon.js +145 -0
- package/dist/negotiation/index.d.ts +17 -0
- package/dist/negotiation/index.js +378 -0
- package/dist/page-tree/index.d.ts +3 -0
- package/dist/page-tree/index.js +2 -0
- package/dist/path-1H5VzYiT.js +75 -0
- package/dist/rehype-code-D-RFJb9W.d.ts +14 -0
- package/dist/rehype-code.core-BUwNuchP.js +548 -0
- package/dist/rehype-code.core-BjH1uHWj.d.ts +115 -0
- package/dist/rehype-toc-K51AGb5U.d.ts +43 -0
- package/dist/remark-admonition-BwTcmI_S.d.ts +20 -0
- package/dist/remark-code-tab-DE_4bdnu.d.ts +34 -0
- package/dist/remark-directive-admonition-BLiJ5l43.d.ts +27 -0
- package/dist/remark-feedback-block-BxtINXN-.d.ts +45 -0
- package/dist/remark-gfm-DpVfAX1x.d.ts +2 -0
- package/dist/remark-heading-DEIzTkU5.d.ts +33 -0
- package/dist/remark-image-BI2S9LOb.d.ts +57 -0
- package/dist/remark-llms-bD3WvU2V.d.ts +73 -0
- package/dist/remark-mdx-files-Buvxc-sa.d.ts +54 -0
- package/dist/remark-mdx-mermaid-C1bCHHc6.d.ts +15 -0
- package/dist/remark-npm-BbpvkJaT.d.ts +31 -0
- package/dist/remark-steps-DqVEo0iq.d.ts +23 -0
- package/dist/remark-structure-CnHwvNZr.d.ts +87 -0
- package/dist/remove-markdown-DfKNMl9w.js +40 -0
- package/dist/remove-undefined-CzMSKybq.js +24 -0
- package/dist/rolldown-runtime-DC62tzP2.js +33 -0
- package/dist/search/algolia.d.ts +2 -0
- package/dist/search/algolia.js +75 -0
- package/dist/search/client/algolia.d.ts +2 -0
- package/dist/search/client/algolia.js +53 -0
- package/dist/search/client/fetch.d.ts +2 -0
- package/dist/search/client/fetch.js +28 -0
- package/dist/search/client/flexsearch-static.d.ts +2 -0
- package/dist/search/client/flexsearch-static.js +42 -0
- package/dist/search/client/mixedbread.d.ts +2 -0
- package/dist/search/client/mixedbread.js +65 -0
- package/dist/search/client/orama-cloud-legacy.d.ts +2 -0
- package/dist/search/client/orama-cloud-legacy.js +84 -0
- package/dist/search/client/orama-cloud.d.ts +2 -0
- package/dist/search/client/orama-cloud.js +86 -0
- package/dist/search/client/orama-static.d.ts +2 -0
- package/dist/search/client/orama-static.js +75 -0
- package/dist/search/client.d.ts +2 -0
- package/dist/search/client.js +97 -0
- package/dist/search/flexsearch.d.ts +56 -0
- package/dist/search/flexsearch.js +128 -0
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.js +74 -0
- package/dist/search/mixedbread.d.ts +49 -0
- package/dist/search/mixedbread.js +77 -0
- package/dist/search/orama-cloud-legacy.d.ts +75 -0
- package/dist/search/orama-cloud-legacy.js +48 -0
- package/dist/search/orama-cloud.d.ts +75 -0
- package/dist/search/orama-cloud.js +50 -0
- package/dist/search/server.d.ts +2 -0
- package/dist/search/server.js +237 -0
- package/dist/server-CCqACwlF.d.ts +165 -0
- package/dist/server.browser.d.ts +13 -0
- package/dist/server.browser.js +22 -0
- package/dist/server.d.ts +42 -0
- package/dist/server.js +398 -0
- package/dist/source/client/index.d.ts +2 -0
- package/dist/source/client/index.js +37 -0
- package/dist/source/dynamic.d.ts +2 -0
- package/dist/source/dynamic.js +2 -0
- package/dist/source/index.d.ts +2 -0
- package/dist/source/index.js +5 -0
- package/dist/source/llms.d.ts +2 -0
- package/dist/source/llms.js +74 -0
- package/dist/source/plugins/lucide-icons.d.ts +11 -0
- package/dist/source/plugins/lucide-icons.js +21 -0
- package/dist/source/plugins/slugs.d.ts +2 -0
- package/dist/source/plugins/slugs.js +75 -0
- package/dist/source/plugins/status-badges.d.ts +50 -0
- package/dist/source/plugins/status-badges.js +52 -0
- package/dist/source/schema.d.ts +30 -0
- package/dist/source/schema.js +28 -0
- package/dist/stringifier-B_QUcUyo.d.ts +63 -0
- package/dist/toc-CtW5lwA1.d.ts +64 -0
- package/dist/toc.d.ts +2 -0
- package/dist/toc.js +245 -0
- package/dist/transformer-icon-DlrneIS3.d.ts +17 -0
- package/dist/types-D89QoQR-.d.ts +4 -0
- package/dist/url-BVHvi3_K.js +29 -0
- package/dist/util-BDsqOxh3.d.ts +6 -0
- package/dist/util-DjBr9b3w.js +8 -0
- package/dist/utils/use-media-query.d.ts +4 -0
- package/dist/utils/use-media-query.js +20 -0
- package/dist/utils/use-on-change.d.ts +9 -0
- package/dist/utils/use-on-change.js +17 -0
- package/dist/utils-Bvy3V-fv.js +59 -0
- package/dist/utils-Cgs-6U-z.js +39 -0
- package/dist/utils-DEVq3cEC.js +151 -0
- package/dist/utils-Yx0IL9eW.js +48 -0
- package/package.json +251 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LinkProps } from "./link.js";
|
|
2
|
+
//#region src/dynamic-link.d.ts
|
|
3
|
+
type DynamicLinkProps = LinkProps;
|
|
4
|
+
/**
|
|
5
|
+
* Extends the default `Link` component
|
|
6
|
+
*
|
|
7
|
+
* It supports dynamic hrefs, which means you can use `/[lang]/my-page` with `dynamicHrefs` enabled
|
|
8
|
+
*/
|
|
9
|
+
declare function DynamicLink({ href, ref, ...props }: DynamicLinkProps): import("react").JSX.Element;
|
|
10
|
+
declare function updateHref(href: string, params: Record<string, string | string[]>): string;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { DynamicLink, DynamicLink as default, DynamicLinkProps, updateHref };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useParams } from "./framework/index.js";
|
|
3
|
+
import { Link } from "./link.js";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/dynamic-link.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Extends the default `Link` component
|
|
9
|
+
*
|
|
10
|
+
* It supports dynamic hrefs, which means you can use `/[lang]/my-page` with `dynamicHrefs` enabled
|
|
11
|
+
*/
|
|
12
|
+
function DynamicLink({ href, ref, ...props }) {
|
|
13
|
+
const params = useParams();
|
|
14
|
+
const url = useMemo(() => href ? updateHref(href, params) : href, [params, href]);
|
|
15
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
16
|
+
ref,
|
|
17
|
+
href: url,
|
|
18
|
+
...props
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function updateHref(href, params) {
|
|
22
|
+
return href.replace(/\[(.*)]\/?/, (match, key) => {
|
|
23
|
+
const hasEndingSlash = match[match.length - 1] === "/";
|
|
24
|
+
const value = key in params ? params[key] : void 0;
|
|
25
|
+
if (!value) return "";
|
|
26
|
+
const replacement = typeof value === "string" ? value : value.join("/");
|
|
27
|
+
return hasEndingSlash ? `${replacement}/` : replacement;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { DynamicLink, DynamicLink as default, updateHref };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/search/server/endpoint.ts
|
|
2
|
+
function createEndpoint(server, options = {}) {
|
|
3
|
+
const { search } = server;
|
|
4
|
+
const { readOptions = defaultReadOptions } = options;
|
|
5
|
+
return {
|
|
6
|
+
...server,
|
|
7
|
+
async staticGET() {
|
|
8
|
+
return Response.json(await server.export());
|
|
9
|
+
},
|
|
10
|
+
async GET(request) {
|
|
11
|
+
const url = new URL(request.url);
|
|
12
|
+
const query = url.searchParams.get("query");
|
|
13
|
+
if (!query) return Response.json([]);
|
|
14
|
+
return Response.json(await search(query, readOptions(url, request)));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function defaultReadOptions(url) {
|
|
19
|
+
const params = url.searchParams;
|
|
20
|
+
const limit = params.has("limit") ? Number(params.get("limit")) : void 0;
|
|
21
|
+
return {
|
|
22
|
+
tag: params.get("tag")?.split(","),
|
|
23
|
+
locale: params.get("locale"),
|
|
24
|
+
limit: Number.isInteger(limit) ? limit : void 0
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { defaultReadOptions as n, createEndpoint as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Framework } from "./index.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/framework/astro.d.ts
|
|
4
|
+
type AstroParams = Record<string, string | string[] | undefined>;
|
|
5
|
+
interface AstroProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
pathname: string;
|
|
8
|
+
params?: AstroParams;
|
|
9
|
+
navigate?: (url: string) => void | Promise<void>;
|
|
10
|
+
Link?: Framework['Link'];
|
|
11
|
+
Image?: Framework['Image'];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Fumadocs adapter for Astro with React islands.
|
|
15
|
+
*
|
|
16
|
+
* Pass `pathname` and `params` from `Astro.url.pathname` and `Astro.params`.
|
|
17
|
+
* You can pass `navigate` from `astro:transitions/client` to preserve client navigation.
|
|
18
|
+
*/
|
|
19
|
+
declare function AstroProvider({ children, pathname, params, navigate, Link, Image }: AstroProviderProps): import("react").JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { AstroProvider, AstroProviderProps };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { FrameworkProvider } from "./index.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/framework/astro.tsx
|
|
6
|
+
function normalizeParams(params = {}) {
|
|
7
|
+
const out = {};
|
|
8
|
+
for (const [key, value] of Object.entries(params)) if (value !== void 0) out[key] = value;
|
|
9
|
+
return out;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fumadocs adapter for Astro with React islands.
|
|
13
|
+
*
|
|
14
|
+
* Pass `pathname` and `params` from `Astro.url.pathname` and `Astro.params`.
|
|
15
|
+
* You can pass `navigate` from `astro:transitions/client` to preserve client navigation.
|
|
16
|
+
*/
|
|
17
|
+
function AstroProvider({ children, pathname, params, navigate, Link, Image }) {
|
|
18
|
+
const resolvedParams = useMemo(() => normalizeParams(params), [params]);
|
|
19
|
+
const framework = useMemo(() => ({
|
|
20
|
+
usePathname() {
|
|
21
|
+
return pathname;
|
|
22
|
+
},
|
|
23
|
+
useParams() {
|
|
24
|
+
return resolvedParams;
|
|
25
|
+
},
|
|
26
|
+
useRouter() {
|
|
27
|
+
return {
|
|
28
|
+
push(url) {
|
|
29
|
+
if (navigate) return navigate(url);
|
|
30
|
+
window.location.assign(url);
|
|
31
|
+
},
|
|
32
|
+
refresh() {
|
|
33
|
+
window.location.reload();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
Link,
|
|
38
|
+
Image
|
|
39
|
+
}), [
|
|
40
|
+
Image,
|
|
41
|
+
Link,
|
|
42
|
+
navigate,
|
|
43
|
+
pathname,
|
|
44
|
+
resolvedParams
|
|
45
|
+
]);
|
|
46
|
+
return /* @__PURE__ */ jsx(FrameworkProvider, {
|
|
47
|
+
...framework,
|
|
48
|
+
children
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { AstroProvider };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ComponentProps, FC, ReactNode } from "react";
|
|
2
|
+
import { StaticImport } from "next/dist/shared/lib/get-img-props.js";
|
|
3
|
+
//#region src/framework/index.d.ts
|
|
4
|
+
interface ImageProps extends Omit<ComponentProps<'img'>, 'src'> {
|
|
5
|
+
sizes?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Next.js Image component has other allowed type for `src`
|
|
8
|
+
*/
|
|
9
|
+
src?: string | StaticImport;
|
|
10
|
+
/**
|
|
11
|
+
* priority of image (from Next.js)
|
|
12
|
+
*/
|
|
13
|
+
priority?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface LinkProps extends ComponentProps<'a'> {
|
|
16
|
+
prefetch?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface Router {
|
|
19
|
+
push: (url: string) => void | Promise<void>;
|
|
20
|
+
refresh: () => void | Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
interface Framework {
|
|
23
|
+
usePathname: () => string;
|
|
24
|
+
useParams: () => Record<string, string | string[]>;
|
|
25
|
+
useRouter: () => Router;
|
|
26
|
+
Link?: FC<ComponentProps<'a'> & {
|
|
27
|
+
prefetch?: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
Image?: FC<ImageProps>;
|
|
30
|
+
}
|
|
31
|
+
declare function FrameworkProvider({ Link, useRouter, useParams, usePathname, Image, children }: Framework & {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
|
+
declare function usePathname(): string;
|
|
35
|
+
declare function useRouter(): Router;
|
|
36
|
+
declare function useParams(): Record<string, string | string[]>;
|
|
37
|
+
declare function Image(props: ImageProps): import("react").JSX.Element;
|
|
38
|
+
declare function Link(props: LinkProps): import("react").JSX.Element;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { Framework, FrameworkProvider, Image, ImageProps, Link, Router, useParams, usePathname, useRouter };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, use, useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/framework/index.tsx
|
|
5
|
+
const notImplemented = () => {
|
|
6
|
+
throw new Error("You need to wrap your application inside `FrameworkProvider`.");
|
|
7
|
+
};
|
|
8
|
+
const FrameworkContext = createContext({
|
|
9
|
+
useParams: notImplemented,
|
|
10
|
+
useRouter: notImplemented,
|
|
11
|
+
usePathname: notImplemented
|
|
12
|
+
});
|
|
13
|
+
function FrameworkProvider({ Link, useRouter, useParams, usePathname, Image, children }) {
|
|
14
|
+
const framework = useMemo(() => ({
|
|
15
|
+
usePathname,
|
|
16
|
+
useRouter,
|
|
17
|
+
Link,
|
|
18
|
+
Image,
|
|
19
|
+
useParams
|
|
20
|
+
}), [
|
|
21
|
+
Link,
|
|
22
|
+
usePathname,
|
|
23
|
+
useRouter,
|
|
24
|
+
useParams,
|
|
25
|
+
Image
|
|
26
|
+
]);
|
|
27
|
+
return /* @__PURE__ */ jsx(FrameworkContext, {
|
|
28
|
+
value: framework,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function usePathname() {
|
|
33
|
+
return use(FrameworkContext).usePathname();
|
|
34
|
+
}
|
|
35
|
+
function useRouter() {
|
|
36
|
+
return use(FrameworkContext).useRouter();
|
|
37
|
+
}
|
|
38
|
+
function useParams() {
|
|
39
|
+
return use(FrameworkContext).useParams();
|
|
40
|
+
}
|
|
41
|
+
function Image(props) {
|
|
42
|
+
const { Image } = use(FrameworkContext);
|
|
43
|
+
if (!Image) {
|
|
44
|
+
const { src, alt, priority, ...rest } = props;
|
|
45
|
+
return /* @__PURE__ */ jsx("img", {
|
|
46
|
+
alt,
|
|
47
|
+
src,
|
|
48
|
+
fetchPriority: priority ? "high" : "auto",
|
|
49
|
+
...rest
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return /* @__PURE__ */ jsx(Image, { ...props });
|
|
53
|
+
}
|
|
54
|
+
function Link(props) {
|
|
55
|
+
const { Link } = use(FrameworkContext);
|
|
56
|
+
if (!Link) {
|
|
57
|
+
const { href, prefetch: _, ...rest } = props;
|
|
58
|
+
return /* @__PURE__ */ jsx("a", {
|
|
59
|
+
href,
|
|
60
|
+
...rest
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return /* @__PURE__ */ jsx(Link, { ...props });
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { FrameworkProvider, Image, Link, useParams, usePathname, useRouter };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Framework } from "./index.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/framework/next.d.ts
|
|
4
|
+
declare function NextProvider({ children, Link: CustomLink, Image: CustomImage }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
Link?: Framework['Link'];
|
|
7
|
+
Image?: Framework['Image'];
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { NextProvider };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { FrameworkProvider } from "./index.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useParams, usePathname, useRouter } from "next/navigation.js";
|
|
5
|
+
import Link from "next/link.js";
|
|
6
|
+
import Image from "next/image.js";
|
|
7
|
+
//#region src/framework/next.tsx
|
|
8
|
+
function NextProvider({ children, Link: CustomLink, Image: CustomImage }) {
|
|
9
|
+
return /* @__PURE__ */ jsx(FrameworkProvider, {
|
|
10
|
+
usePathname,
|
|
11
|
+
useRouter,
|
|
12
|
+
useParams,
|
|
13
|
+
Link: CustomLink ?? Link,
|
|
14
|
+
Image: CustomImage ?? Image,
|
|
15
|
+
children
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { NextProvider };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Framework } from "./index.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/framework/react-router.d.ts
|
|
4
|
+
declare function ReactRouterProvider({ children, Link: CustomLink, Image: CustomImage }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
Link?: Framework['Link'];
|
|
7
|
+
Image?: Framework['Image'];
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ReactRouterProvider };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { FrameworkProvider } from "./index.js";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Link, useLocation, useNavigate, useParams, useRevalidator } from "react-router";
|
|
5
|
+
//#region src/framework/react-router.tsx
|
|
6
|
+
const framework = {
|
|
7
|
+
usePathname() {
|
|
8
|
+
return useLocation().pathname;
|
|
9
|
+
},
|
|
10
|
+
useParams() {
|
|
11
|
+
return useParams();
|
|
12
|
+
},
|
|
13
|
+
useRouter() {
|
|
14
|
+
const navigate = useNavigate();
|
|
15
|
+
const revalidator = useRevalidator();
|
|
16
|
+
return useMemo(() => ({
|
|
17
|
+
push(url) {
|
|
18
|
+
navigate(url);
|
|
19
|
+
},
|
|
20
|
+
refresh() {
|
|
21
|
+
revalidator.revalidate();
|
|
22
|
+
}
|
|
23
|
+
}), [navigate, revalidator]);
|
|
24
|
+
},
|
|
25
|
+
Link({ href, prefetch, ...props }) {
|
|
26
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
27
|
+
to: href,
|
|
28
|
+
prefetch: prefetch ? "intent" : "none",
|
|
29
|
+
...props,
|
|
30
|
+
children: props.children
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function ReactRouterProvider({ children, Link: CustomLink, Image: CustomImage }) {
|
|
35
|
+
return /* @__PURE__ */ jsx(FrameworkProvider, {
|
|
36
|
+
...framework,
|
|
37
|
+
Link: CustomLink ?? framework.Link,
|
|
38
|
+
Image: CustomImage ?? framework.Image,
|
|
39
|
+
children
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ReactRouterProvider };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Framework } from "./index.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/framework/tanstack.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Fumadocs adapter for Tanstack Router/Start
|
|
6
|
+
*/
|
|
7
|
+
declare function TanstackProvider({ children, Link: CustomLink, Image: CustomImage }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
Link?: Framework['Link'];
|
|
10
|
+
Image?: Framework['Image'];
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { TanstackProvider };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FrameworkProvider } from "./index.js";
|
|
2
|
+
import { useMemo, useRef } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Link, useParams, useRouter, useRouterState } from "@tanstack/react-router";
|
|
5
|
+
//#region src/framework/tanstack.tsx
|
|
6
|
+
const framework = {
|
|
7
|
+
Link({ href, prefetch = true, ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
9
|
+
to: href,
|
|
10
|
+
preload: prefetch ? "intent" : false,
|
|
11
|
+
...props,
|
|
12
|
+
children: props.children
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
usePathname() {
|
|
16
|
+
const { isLoading, pathname } = useRouterState({ select: (state) => ({
|
|
17
|
+
isLoading: state.isLoading,
|
|
18
|
+
pathname: state.location.pathname
|
|
19
|
+
}) });
|
|
20
|
+
const activePathname = useRef(pathname);
|
|
21
|
+
return useMemo(() => {
|
|
22
|
+
if (isLoading) return activePathname.current;
|
|
23
|
+
activePathname.current = pathname;
|
|
24
|
+
return pathname;
|
|
25
|
+
}, [isLoading, pathname]);
|
|
26
|
+
},
|
|
27
|
+
useRouter() {
|
|
28
|
+
const router = useRouter();
|
|
29
|
+
return useMemo(() => ({
|
|
30
|
+
push(url) {
|
|
31
|
+
router.navigate({ href: url });
|
|
32
|
+
},
|
|
33
|
+
refresh() {
|
|
34
|
+
router.invalidate();
|
|
35
|
+
}
|
|
36
|
+
}), [router]);
|
|
37
|
+
},
|
|
38
|
+
useParams() {
|
|
39
|
+
return useParams({ strict: false });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Fumadocs adapter for Tanstack Router/Start
|
|
44
|
+
*/
|
|
45
|
+
function TanstackProvider({ children, Link: CustomLink, Image: CustomImage }) {
|
|
46
|
+
return /* @__PURE__ */ jsx(FrameworkProvider, {
|
|
47
|
+
...framework,
|
|
48
|
+
Link: CustomLink ?? framework.Link,
|
|
49
|
+
Image: CustomImage ?? framework.Image,
|
|
50
|
+
children
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { TanstackProvider };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Framework } from "./index.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/framework/waku.d.ts
|
|
4
|
+
declare function WakuProvider({ children, Link: CustomLink, Image: CustomImage }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
Link?: Framework['Link'];
|
|
7
|
+
Image?: Framework['Image'];
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { WakuProvider };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { FrameworkProvider } from "./index.js";
|
|
3
|
+
import { useMemo, useRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Link, useRouter } from "waku/router/client";
|
|
6
|
+
//#region src/framework/waku.tsx
|
|
7
|
+
const framework = {
|
|
8
|
+
usePathname() {
|
|
9
|
+
return useRouter().path;
|
|
10
|
+
},
|
|
11
|
+
useParams() {
|
|
12
|
+
console.warn("[Fumadocs] useParams() is not supported on Waku");
|
|
13
|
+
return useMemo(() => ({}), []);
|
|
14
|
+
},
|
|
15
|
+
useRouter() {
|
|
16
|
+
const router = useRouter();
|
|
17
|
+
const routerRef = useRef(router);
|
|
18
|
+
routerRef.current = router;
|
|
19
|
+
return useMemo(() => ({
|
|
20
|
+
push(url) {
|
|
21
|
+
return routerRef.current.push(url);
|
|
22
|
+
},
|
|
23
|
+
refresh() {
|
|
24
|
+
return routerRef.current.reload();
|
|
25
|
+
}
|
|
26
|
+
}), []);
|
|
27
|
+
},
|
|
28
|
+
Link({ href, prefetch = true, ...props }) {
|
|
29
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
30
|
+
to: href,
|
|
31
|
+
unstable_prefetchOnEnter: prefetch ? { mode: "once" } : void 0,
|
|
32
|
+
...props,
|
|
33
|
+
children: props.children
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function WakuProvider({ children, Link: CustomLink, Image: CustomImage }) {
|
|
38
|
+
return /* @__PURE__ */ jsx(FrameworkProvider, {
|
|
39
|
+
...framework,
|
|
40
|
+
Link: CustomLink ?? framework.Link,
|
|
41
|
+
Image: CustomImage ?? framework.Image,
|
|
42
|
+
children
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { WakuProvider };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HighlightOptions } from "./index.js";
|
|
2
|
+
import { DependencyList, ReactNode } from "react";
|
|
3
|
+
//#region src/highlight/client.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* get highlighted results, should be used with React Suspense API.
|
|
6
|
+
*
|
|
7
|
+
* note: results are cached with (lang, code) as keys, if this is not the desired behaviour, pass a `deps` instead.
|
|
8
|
+
*/
|
|
9
|
+
declare function useShiki(code: string, options: HighlightOptions, deps?: DependencyList): ReactNode;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { useShiki };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as applyDefaultThemes } from "../utils-Cgs-6U-z.js";
|
|
3
|
+
import { useShiki as useShiki$1 } from "./shiki/react.js";
|
|
4
|
+
import { defaultShikiFactory } from "./shiki/full.js";
|
|
5
|
+
//#region src/highlight/client.ts
|
|
6
|
+
/**
|
|
7
|
+
* get highlighted results, should be used with React Suspense API.
|
|
8
|
+
*
|
|
9
|
+
* note: results are cached with (lang, code) as keys, if this is not the desired behaviour, pass a `deps` instead.
|
|
10
|
+
*/
|
|
11
|
+
function useShiki(code, options, deps) {
|
|
12
|
+
return useShiki$1(() => defaultShikiFactory.getOrInit(), code, applyDefaultThemes(options), deps);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useShiki };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { Components } from "hast-util-to-jsx-runtime";
|
|
3
|
+
import { Root } from "hast";
|
|
4
|
+
import { BundledLanguage, BundledTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, LanguageRegistration, ThemeRegistrationAny } from "shiki";
|
|
5
|
+
//#region src/highlight/index.d.ts
|
|
6
|
+
type HighlightOptions = HighlightHastOptions & {
|
|
7
|
+
components?: Partial<Components>;
|
|
8
|
+
};
|
|
9
|
+
type HighlightHastOptions = CodeToHastOptionsCommon<BundledLanguage> & CodeOptionsMeta & {
|
|
10
|
+
fallbackLanguage?: BundledLanguage | (string & {});
|
|
11
|
+
/**
|
|
12
|
+
* The Regex Engine for Shiki
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue 'js'
|
|
15
|
+
*/
|
|
16
|
+
engine?: 'js' | 'oniguruma';
|
|
17
|
+
} & (CodeOptionsThemes<BundledTheme> | Record<never, never>);
|
|
18
|
+
declare function highlightHast(code: string, options: HighlightHastOptions): Promise<Root>;
|
|
19
|
+
/**
|
|
20
|
+
* Get Shiki highlighter instance of Fumadocs (mostly for internal use, you should use Shiki directly over this).
|
|
21
|
+
*
|
|
22
|
+
* @param engineType - Shiki Regex engine to use.
|
|
23
|
+
* @param options - Shiki options.
|
|
24
|
+
*/
|
|
25
|
+
declare function getHighlighter(engineType: 'js' | 'oniguruma', options?: {
|
|
26
|
+
langs?: (BundledLanguage | LanguageRegistration)[];
|
|
27
|
+
themes?: (BundledTheme | ThemeRegistrationAny)[];
|
|
28
|
+
}): Promise<import("shiki").HighlighterCore>;
|
|
29
|
+
declare function highlight(code: string, options: HighlightOptions): Promise<ReactNode>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { HighlightHastOptions, HighlightOptions, getHighlighter, highlight, highlightHast };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { a as loadMissingTheme, i as loadMissingLanguage, t as applyDefaultThemes } from "../utils-Cgs-6U-z.js";
|
|
2
|
+
import { highlightHast as highlightHast$1 } from "./shiki/index.js";
|
|
3
|
+
import { defaultShikiFactory, wasmShikiFactory } from "./shiki/full.js";
|
|
4
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
5
|
+
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
6
|
+
//#region src/highlight/index.ts
|
|
7
|
+
async function highlightHast(code, options) {
|
|
8
|
+
const instance = await ((options.engine ?? "js") === "js" ? defaultShikiFactory : wasmShikiFactory).getOrInit();
|
|
9
|
+
return highlightHast$1(instance, code, applyDefaultThemes(options));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get Shiki highlighter instance of Fumadocs (mostly for internal use, you should use Shiki directly over this).
|
|
13
|
+
*
|
|
14
|
+
* @param engineType - Shiki Regex engine to use.
|
|
15
|
+
* @param options - Shiki options.
|
|
16
|
+
*/
|
|
17
|
+
async function getHighlighter(engineType, options = {}) {
|
|
18
|
+
const instance = await (engineType === "js" ? defaultShikiFactory : wasmShikiFactory).getOrInit();
|
|
19
|
+
await Promise.all([options.langs && loadMissingLanguage(instance, options.langs), options.themes && loadMissingTheme(instance, options.themes)]);
|
|
20
|
+
return instance;
|
|
21
|
+
}
|
|
22
|
+
async function highlight(code, options) {
|
|
23
|
+
return toJsxRuntime(await highlightHast(code, options), {
|
|
24
|
+
...JsxRuntime,
|
|
25
|
+
development: false,
|
|
26
|
+
components: options.components
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getHighlighter, highlight, highlightHast };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { n as ShikiFactory } from "../../index-BMEUQz-F.js";
|
|
2
|
+
//#region src/highlight/shiki/full.d.ts
|
|
3
|
+
declare const defaultShikiFactory: ShikiFactory;
|
|
4
|
+
/** factory using the WASM powered Regex engine */
|
|
5
|
+
declare const wasmShikiFactory: ShikiFactory;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { defaultShikiFactory, wasmShikiFactory };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createShikiFactory } from "./index.js";
|
|
2
|
+
//#region src/highlight/shiki/full.ts
|
|
3
|
+
const defaultShikiFactory = createShikiFactory({ async init(options) {
|
|
4
|
+
const { createHighlighter, createJavaScriptRegexEngine } = await import("shiki");
|
|
5
|
+
return createHighlighter({
|
|
6
|
+
langs: [],
|
|
7
|
+
themes: [],
|
|
8
|
+
langAlias: options?.langAlias,
|
|
9
|
+
engine: createJavaScriptRegexEngine()
|
|
10
|
+
});
|
|
11
|
+
} });
|
|
12
|
+
/** factory using the WASM powered Regex engine */
|
|
13
|
+
const wasmShikiFactory = createShikiFactory({ async init(options) {
|
|
14
|
+
const { createHighlighter, createOnigurumaEngine } = await import("shiki");
|
|
15
|
+
return createHighlighter({
|
|
16
|
+
langs: [],
|
|
17
|
+
themes: [],
|
|
18
|
+
langAlias: options?.langAlias,
|
|
19
|
+
engine: createOnigurumaEngine(import("shiki/wasm"))
|
|
20
|
+
});
|
|
21
|
+
} });
|
|
22
|
+
//#endregion
|
|
23
|
+
export { defaultShikiFactory, wasmShikiFactory };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { a as loadMissingTheme, r as getRequiredThemes } from "../../utils-Cgs-6U-z.js";
|
|
2
|
+
//#region src/highlight/shiki/index.ts
|
|
3
|
+
function createShikiFactory(config) {
|
|
4
|
+
let instance;
|
|
5
|
+
return {
|
|
6
|
+
init(options) {
|
|
7
|
+
const created = config.init(options);
|
|
8
|
+
if (created instanceof Promise) created.catch(() => {
|
|
9
|
+
if (instance === created) instance = void 0;
|
|
10
|
+
});
|
|
11
|
+
return instance = created;
|
|
12
|
+
},
|
|
13
|
+
getOrInit() {
|
|
14
|
+
return instance ?? this.init();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async function highlightHast(highlighter, code, options) {
|
|
19
|
+
const { fallbackLanguage = "text", ...resolved } = options;
|
|
20
|
+
const { isSpecialLang } = await import("shiki/core");
|
|
21
|
+
const loaded = highlighter.getLoadedLanguages();
|
|
22
|
+
if (!isSpecialLang(resolved.lang) && !(resolved.lang in highlighter.getBundledLanguages()) && !loaded.includes(resolved.lang)) resolved.lang = fallbackLanguage;
|
|
23
|
+
await Promise.all([loadMissingTheme(highlighter, getRequiredThemes(resolved)), !isSpecialLang(resolved.lang) && !loaded.includes(resolved.lang) && highlighter.loadLanguage(resolved.lang)]);
|
|
24
|
+
return highlighter.codeToHast(code, resolved);
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { createShikiFactory, highlightHast };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t as Awaitable } from "../../types-D89QoQR-.js";
|
|
2
|
+
import { t as HighlightHastOptions } from "../../index-BMEUQz-F.js";
|
|
3
|
+
import { DependencyList, ReactNode } from "react";
|
|
4
|
+
import { Components } from "hast-util-to-jsx-runtime";
|
|
5
|
+
import { HighlighterCore } from "shiki";
|
|
6
|
+
//#region src/highlight/shiki/react.d.ts
|
|
7
|
+
type UseShikiOptions = HighlightHastOptions & {
|
|
8
|
+
components?: Partial<Components>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* get highlighted results (uncached), use `useEffect` instead of React 19 APIs.
|
|
12
|
+
*/
|
|
13
|
+
declare function useShikiDynamic(highlighter: HighlighterCore | (() => Awaitable<HighlighterCore>), code: string, options: UseShikiOptions & {
|
|
14
|
+
defaultValue?: ReactNode;
|
|
15
|
+
}, deps: DependencyList): ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* get highlighted results, should be used with React Suspense API.
|
|
18
|
+
*
|
|
19
|
+
* note: results are cached with (lang, code) as keys, if this is not the desired behaviour, pass a `deps` instead.
|
|
20
|
+
*/
|
|
21
|
+
declare function useShiki(highlighter: HighlighterCore | (() => Awaitable<HighlighterCore>), code: string, options: UseShikiOptions, deps?: DependencyList): ReactNode;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { UseShikiOptions, useShiki, useShikiDynamic };
|