@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,14 @@
|
|
|
1
|
+
import { L as LoaderPlugin } from '../../loader-BvlPPJX0.js';
|
|
2
|
+
import { icons } from 'lucide-react';
|
|
3
|
+
import '../../definitions-pJ7PybYY.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '../../i18n/index.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert icon names into Lucide Icons, requires `lucide-react` to be installed.
|
|
9
|
+
*/
|
|
10
|
+
declare function lucideIconsPlugin(options?: {
|
|
11
|
+
defaultIcon?: keyof typeof icons;
|
|
12
|
+
}): LoaderPlugin;
|
|
13
|
+
|
|
14
|
+
export { lucideIconsPlugin };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
iconPlugin
|
|
3
|
+
} from "../../chunk-FAEPKD7U.js";
|
|
4
|
+
import "../../chunk-U67V476Y.js";
|
|
5
|
+
|
|
6
|
+
// src/source/plugins/lucide-icons.ts
|
|
7
|
+
import { icons } from "lucide-react";
|
|
8
|
+
import { createElement } from "react";
|
|
9
|
+
function lucideIconsPlugin(options = {}) {
|
|
10
|
+
const { defaultIcon } = options;
|
|
11
|
+
return iconPlugin((icon = defaultIcon) => {
|
|
12
|
+
if (icon === void 0) return;
|
|
13
|
+
const Icon = icons[icon];
|
|
14
|
+
if (!icon) {
|
|
15
|
+
console.warn(`[lucide-icons-plugin] Unknown icon detected: ${icon}.`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
return createElement(Icon);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
lucideIconsPlugin
|
|
23
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Zod 4 schema
|
|
5
|
+
*/
|
|
6
|
+
declare const metaSchema: z.ZodObject<{
|
|
7
|
+
title: z.ZodOptional<z.ZodString>;
|
|
8
|
+
pages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
|
+
description: z.ZodOptional<z.ZodString>;
|
|
10
|
+
root: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
defaultOpen: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
collapsible: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
/**
|
|
16
|
+
* Zod 4 schema
|
|
17
|
+
*/
|
|
18
|
+
declare const pageSchema: z.ZodObject<{
|
|
19
|
+
title: z.ZodString;
|
|
20
|
+
description: z.ZodOptional<z.ZodString>;
|
|
21
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
22
|
+
full: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
_openapi: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
|
|
26
|
+
export { metaSchema, pageSchema };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "../chunk-U67V476Y.js";
|
|
2
|
+
|
|
3
|
+
// src/source/schema.ts
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
var metaSchema = z.object({
|
|
6
|
+
title: z.string().optional(),
|
|
7
|
+
pages: z.array(z.string()).optional(),
|
|
8
|
+
description: z.string().optional(),
|
|
9
|
+
root: z.boolean().optional(),
|
|
10
|
+
defaultOpen: z.boolean().optional(),
|
|
11
|
+
collapsible: z.boolean().optional(),
|
|
12
|
+
icon: z.string().optional()
|
|
13
|
+
});
|
|
14
|
+
var pageSchema = z.object({
|
|
15
|
+
title: z.string(),
|
|
16
|
+
description: z.string().optional(),
|
|
17
|
+
icon: z.string().optional(),
|
|
18
|
+
full: z.boolean().optional(),
|
|
19
|
+
// Fumadocs OpenAPI generated
|
|
20
|
+
_openapi: z.looseObject({}).optional()
|
|
21
|
+
});
|
|
22
|
+
export {
|
|
23
|
+
metaSchema,
|
|
24
|
+
pageSchema
|
|
25
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
searchAdvanced,
|
|
3
|
+
searchSimple
|
|
4
|
+
} from "./chunk-XOFXGHS4.js";
|
|
5
|
+
import "./chunk-ZMWYLUDP.js";
|
|
6
|
+
import "./chunk-OTD7MV33.js";
|
|
7
|
+
import "./chunk-U67V476Y.js";
|
|
8
|
+
|
|
9
|
+
// src/search/client/static.ts
|
|
10
|
+
import { create, load } from "@orama/orama";
|
|
11
|
+
var cache = /* @__PURE__ */ new Map();
|
|
12
|
+
async function loadDB({
|
|
13
|
+
from = "/api/search",
|
|
14
|
+
initOrama = (locale) => create({ schema: { _: "string" }, language: locale })
|
|
15
|
+
}) {
|
|
16
|
+
const cacheKey = from;
|
|
17
|
+
const cached = cache.get(cacheKey);
|
|
18
|
+
if (cached) return cached;
|
|
19
|
+
async function init() {
|
|
20
|
+
const res = await fetch(from);
|
|
21
|
+
if (!res.ok)
|
|
22
|
+
throw new Error(
|
|
23
|
+
`failed to fetch exported search indexes from ${from}, make sure the search database is exported and available for client.`
|
|
24
|
+
);
|
|
25
|
+
const data = await res.json();
|
|
26
|
+
const dbs = /* @__PURE__ */ new Map();
|
|
27
|
+
if (data.type === "i18n") {
|
|
28
|
+
await Promise.all(
|
|
29
|
+
Object.entries(data.data).map(async ([k, v]) => {
|
|
30
|
+
const db2 = await initOrama(k);
|
|
31
|
+
load(db2, v);
|
|
32
|
+
dbs.set(k, {
|
|
33
|
+
type: v.type,
|
|
34
|
+
db: db2
|
|
35
|
+
});
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
return dbs;
|
|
39
|
+
}
|
|
40
|
+
const db = await initOrama();
|
|
41
|
+
load(db, data);
|
|
42
|
+
dbs.set("", {
|
|
43
|
+
type: data.type,
|
|
44
|
+
db
|
|
45
|
+
});
|
|
46
|
+
return dbs;
|
|
47
|
+
}
|
|
48
|
+
const result = init();
|
|
49
|
+
cache.set(cacheKey, result);
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
async function search(query, options) {
|
|
53
|
+
const { tag, locale } = options;
|
|
54
|
+
const db = (await loadDB(options)).get(locale ?? "");
|
|
55
|
+
if (!db) return [];
|
|
56
|
+
if (db.type === "simple")
|
|
57
|
+
return searchSimple(db, query);
|
|
58
|
+
return searchAdvanced(db.db, query, tag);
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
search
|
|
62
|
+
};
|
package/dist/toc.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode, RefObject, ComponentProps } from 'react';
|
|
3
|
+
|
|
4
|
+
interface TOCItemType {
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
url: string;
|
|
7
|
+
depth: number;
|
|
8
|
+
}
|
|
9
|
+
type TableOfContents = TOCItemType[];
|
|
10
|
+
/**
|
|
11
|
+
* The estimated active heading ID
|
|
12
|
+
*/
|
|
13
|
+
declare function useActiveAnchor(): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The id of visible anchors
|
|
16
|
+
*/
|
|
17
|
+
declare function useActiveAnchors(): string[];
|
|
18
|
+
interface AnchorProviderProps {
|
|
19
|
+
toc: TableOfContents;
|
|
20
|
+
/**
|
|
21
|
+
* Only accept one active item at most
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue false
|
|
24
|
+
*/
|
|
25
|
+
single?: boolean;
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
interface ScrollProviderProps {
|
|
29
|
+
/**
|
|
30
|
+
* Scroll into the view of container when active
|
|
31
|
+
*/
|
|
32
|
+
containerRef: RefObject<HTMLElement | null>;
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
declare function ScrollProvider({ containerRef, children, }: ScrollProviderProps): react_jsx_runtime.JSX.Element;
|
|
36
|
+
declare function AnchorProvider({ toc, single, children, }: AnchorProviderProps): react_jsx_runtime.JSX.Element;
|
|
37
|
+
interface TOCItemProps extends Omit<ComponentProps<'a'>, 'href'> {
|
|
38
|
+
href: string;
|
|
39
|
+
onActiveChange?: (v: boolean) => void;
|
|
40
|
+
}
|
|
41
|
+
declare function TOCItem({ ref, onActiveChange, ...props }: TOCItemProps): react_jsx_runtime.JSX.Element;
|
|
42
|
+
|
|
43
|
+
export { AnchorProvider, type AnchorProviderProps, ScrollProvider, type ScrollProviderProps, TOCItem, type TOCItemProps, type TOCItemType, type TableOfContents, useActiveAnchor, useActiveAnchors };
|
package/dist/toc.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "./chunk-U67V476Y.js";
|
|
3
|
+
|
|
4
|
+
// src/toc.tsx
|
|
5
|
+
import {
|
|
6
|
+
createContext,
|
|
7
|
+
useContext,
|
|
8
|
+
useEffect,
|
|
9
|
+
useEffectEvent,
|
|
10
|
+
useLayoutEffect,
|
|
11
|
+
useMemo,
|
|
12
|
+
useRef,
|
|
13
|
+
useState
|
|
14
|
+
} from "react";
|
|
15
|
+
import scrollIntoView from "scroll-into-view-if-needed";
|
|
16
|
+
|
|
17
|
+
// src/utils/merge-refs.ts
|
|
18
|
+
function mergeRefs(...refs) {
|
|
19
|
+
return (value) => {
|
|
20
|
+
refs.forEach((ref) => {
|
|
21
|
+
if (typeof ref === "function") {
|
|
22
|
+
ref(value);
|
|
23
|
+
} else if (ref != null) {
|
|
24
|
+
ref.current = value;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/toc.tsx
|
|
31
|
+
import { jsx } from "react/jsx-runtime";
|
|
32
|
+
var ActiveAnchorContext = createContext([]);
|
|
33
|
+
var ScrollContext = createContext({
|
|
34
|
+
current: null
|
|
35
|
+
});
|
|
36
|
+
function useActiveAnchor() {
|
|
37
|
+
return useContext(ActiveAnchorContext)[0];
|
|
38
|
+
}
|
|
39
|
+
function useActiveAnchors() {
|
|
40
|
+
return useContext(ActiveAnchorContext);
|
|
41
|
+
}
|
|
42
|
+
function ScrollProvider({
|
|
43
|
+
containerRef,
|
|
44
|
+
children
|
|
45
|
+
}) {
|
|
46
|
+
return /* @__PURE__ */ jsx(ScrollContext.Provider, { value: containerRef, children });
|
|
47
|
+
}
|
|
48
|
+
function AnchorProvider({
|
|
49
|
+
toc,
|
|
50
|
+
single = false,
|
|
51
|
+
children
|
|
52
|
+
}) {
|
|
53
|
+
const headings = useMemo(() => {
|
|
54
|
+
return toc.map((item) => item.url.split("#")[1]);
|
|
55
|
+
}, [toc]);
|
|
56
|
+
return /* @__PURE__ */ jsx(ActiveAnchorContext.Provider, { value: useAnchorObserver(headings, single), children });
|
|
57
|
+
}
|
|
58
|
+
function TOCItem({
|
|
59
|
+
ref,
|
|
60
|
+
onActiveChange = () => null,
|
|
61
|
+
...props
|
|
62
|
+
}) {
|
|
63
|
+
const containerRef = useContext(ScrollContext);
|
|
64
|
+
const anchorRef = useRef(null);
|
|
65
|
+
const activeOrder = useActiveAnchors().indexOf(props.href.slice(1));
|
|
66
|
+
const isActive = activeOrder !== -1;
|
|
67
|
+
const shouldScroll = activeOrder === 0;
|
|
68
|
+
const onActiveChangeEvent = useEffectEvent(onActiveChange);
|
|
69
|
+
useLayoutEffect(() => {
|
|
70
|
+
const anchor = anchorRef.current;
|
|
71
|
+
const container = containerRef.current;
|
|
72
|
+
if (container && anchor && shouldScroll)
|
|
73
|
+
scrollIntoView(anchor, {
|
|
74
|
+
behavior: "smooth",
|
|
75
|
+
block: "center",
|
|
76
|
+
inline: "center",
|
|
77
|
+
scrollMode: "always",
|
|
78
|
+
boundary: container
|
|
79
|
+
});
|
|
80
|
+
}, [containerRef, shouldScroll]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
return () => onActiveChangeEvent(isActive);
|
|
83
|
+
}, [isActive]);
|
|
84
|
+
return /* @__PURE__ */ jsx("a", { ref: mergeRefs(anchorRef, ref), "data-active": isActive, ...props, children: props.children });
|
|
85
|
+
}
|
|
86
|
+
function useAnchorObserver(watch, single) {
|
|
87
|
+
const observerRef = useRef(null);
|
|
88
|
+
const [activeAnchor, setActiveAnchor] = useState(() => []);
|
|
89
|
+
const stateRef = useRef(null);
|
|
90
|
+
const onChange = useEffectEvent((entries) => {
|
|
91
|
+
stateRef.current ??= {
|
|
92
|
+
visible: /* @__PURE__ */ new Set()
|
|
93
|
+
};
|
|
94
|
+
const state = stateRef.current;
|
|
95
|
+
for (const entry of entries) {
|
|
96
|
+
if (entry.isIntersecting) {
|
|
97
|
+
state.visible.add(entry.target.id);
|
|
98
|
+
} else {
|
|
99
|
+
state.visible.delete(entry.target.id);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (state.visible.size === 0) {
|
|
103
|
+
const viewTop = entries.length > 0 ? entries[0]?.rootBounds?.top ?? 0 : 0;
|
|
104
|
+
let fallback;
|
|
105
|
+
let min = -1;
|
|
106
|
+
for (const id of watch) {
|
|
107
|
+
const element = document.getElementById(id);
|
|
108
|
+
if (!element) continue;
|
|
109
|
+
const d = Math.abs(viewTop - element.getBoundingClientRect().top);
|
|
110
|
+
if (min === -1 || d < min) {
|
|
111
|
+
fallback = element;
|
|
112
|
+
min = d;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
setActiveAnchor(fallback ? [fallback.id] : []);
|
|
116
|
+
} else {
|
|
117
|
+
const items = watch.filter((item) => state.visible.has(item));
|
|
118
|
+
setActiveAnchor(single ? items.slice(0, 1) : items);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (observerRef.current) return;
|
|
123
|
+
observerRef.current = new IntersectionObserver(onChange, {
|
|
124
|
+
rootMargin: "0px",
|
|
125
|
+
threshold: 0.98
|
|
126
|
+
});
|
|
127
|
+
return () => {
|
|
128
|
+
observerRef.current?.disconnect();
|
|
129
|
+
observerRef.current = null;
|
|
130
|
+
};
|
|
131
|
+
}, []);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const observer = observerRef.current;
|
|
134
|
+
if (!observer) return;
|
|
135
|
+
const elements = watch.flatMap(
|
|
136
|
+
(heading) => document.getElementById(heading) ?? []
|
|
137
|
+
);
|
|
138
|
+
for (const element of elements) observer.observe(element);
|
|
139
|
+
return () => {
|
|
140
|
+
for (const element of elements) observer.unobserve(element);
|
|
141
|
+
};
|
|
142
|
+
}, [watch]);
|
|
143
|
+
return activeAnchor;
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
AnchorProvider,
|
|
147
|
+
ScrollProvider,
|
|
148
|
+
TOCItem,
|
|
149
|
+
useActiveAnchor,
|
|
150
|
+
useActiveAnchors
|
|
151
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type UseEffectEvent = <F extends (...params: never[]) => unknown>(callback: F) => F;
|
|
2
|
+
/**
|
|
3
|
+
* Polyfill for React.js 19.2 `useEffectEvent`.
|
|
4
|
+
*
|
|
5
|
+
* @internal Don't use this, could be deleted anytime.
|
|
6
|
+
*/
|
|
7
|
+
declare const useEffectEvent: UseEffectEvent;
|
|
8
|
+
|
|
9
|
+
export { useEffectEvent };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-U67V476Y.js";
|
|
3
|
+
|
|
4
|
+
// src/utils/use-effect-event.ts
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
var useEffectEvent = "useEffectEvent" in React ? { ...React }.useEffectEvent : (callback) => {
|
|
7
|
+
const ref = React.useRef(callback);
|
|
8
|
+
ref.current = callback;
|
|
9
|
+
return React.useCallback(
|
|
10
|
+
((...params) => ref.current(...params)),
|
|
11
|
+
[]
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
useEffectEvent
|
|
16
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "../chunk-U67V476Y.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/use-media-query.ts
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
function useMediaQuery(query, disabled = false) {
|
|
6
|
+
const [isMatch, setMatch] = useState(null);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (disabled) return;
|
|
9
|
+
const mediaQueryList = window.matchMedia(query);
|
|
10
|
+
const handleChange = () => {
|
|
11
|
+
setMatch(mediaQueryList.matches);
|
|
12
|
+
};
|
|
13
|
+
handleChange();
|
|
14
|
+
mediaQueryList.addEventListener("change", handleChange);
|
|
15
|
+
return () => {
|
|
16
|
+
mediaQueryList.removeEventListener("change", handleChange);
|
|
17
|
+
};
|
|
18
|
+
}, [disabled, query]);
|
|
19
|
+
return isMatch;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
useMediaQuery
|
|
23
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param value - state to watch
|
|
3
|
+
* @param onChange - when the state changed
|
|
4
|
+
* @param isUpdated - a function that determines if the state is updated
|
|
5
|
+
*/
|
|
6
|
+
declare function useOnChange<T>(value: T, onChange: (current: T, previous: T) => void, isUpdated?: (prev: T, current: T) => boolean): void;
|
|
7
|
+
|
|
8
|
+
export { useOnChange };
|
package/package.json
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hanzo/docs-core",
|
|
3
|
+
"version": "16.2.5",
|
|
4
|
+
"description": "The React.js library for building a documentation website",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Hanzo",
|
|
7
|
+
"Docs"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://hanzo.ai/docs",
|
|
10
|
+
"repository": "github:hanzoai/docs",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "Fuma Nama",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./breadcrumb": {
|
|
16
|
+
"import": "./dist/breadcrumb.js",
|
|
17
|
+
"types": "./dist/breadcrumb.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./toc": {
|
|
20
|
+
"import": "./dist/toc.js",
|
|
21
|
+
"types": "./dist/toc.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./content": {
|
|
24
|
+
"import": "./dist/content/index.js",
|
|
25
|
+
"types": "./dist/content/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./content/*": {
|
|
28
|
+
"import": "./dist/content/*.js",
|
|
29
|
+
"types": "./dist/content/*.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./negotiation": {
|
|
32
|
+
"import": "./dist/negotiation/index.js",
|
|
33
|
+
"types": "./dist/negotiation/index.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./page-tree": {
|
|
36
|
+
"import": "./dist/page-tree/index.js",
|
|
37
|
+
"types": "./dist/page-tree/index.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./search": {
|
|
40
|
+
"import": "./dist/search/index.js",
|
|
41
|
+
"types": "./dist/search/index.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./search/*": {
|
|
44
|
+
"import": "./dist/search/*.js",
|
|
45
|
+
"types": "./dist/search/*.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"./source": {
|
|
48
|
+
"import": "./dist/source/index.js",
|
|
49
|
+
"types": "./dist/source/index.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./source/client": {
|
|
52
|
+
"import": "./dist/source/client/index.js",
|
|
53
|
+
"types": "./dist/source/client/index.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./source/schema": {
|
|
56
|
+
"import": "./dist/source/schema.js",
|
|
57
|
+
"types": "./dist/source/schema.d.ts"
|
|
58
|
+
},
|
|
59
|
+
"./source/*": {
|
|
60
|
+
"import": "./dist/source/plugins/*.js",
|
|
61
|
+
"types": "./dist/source/plugins/*.d.ts"
|
|
62
|
+
},
|
|
63
|
+
"./utils/*": {
|
|
64
|
+
"import": "./dist/utils/*.js",
|
|
65
|
+
"types": "./dist/utils/*.d.ts"
|
|
66
|
+
},
|
|
67
|
+
"./link": {
|
|
68
|
+
"import": "./dist/link.js",
|
|
69
|
+
"types": "./dist/link.d.ts"
|
|
70
|
+
},
|
|
71
|
+
"./dynamic-link": {
|
|
72
|
+
"import": "./dist/dynamic-link.js",
|
|
73
|
+
"types": "./dist/dynamic-link.d.ts"
|
|
74
|
+
},
|
|
75
|
+
"./mdx-plugins": {
|
|
76
|
+
"import": "./dist/mdx-plugins/index.js",
|
|
77
|
+
"types": "./dist/mdx-plugins/index.d.ts"
|
|
78
|
+
},
|
|
79
|
+
"./mdx-plugins/*": {
|
|
80
|
+
"import": "./dist/mdx-plugins/*.js",
|
|
81
|
+
"types": "./dist/mdx-plugins/*.d.ts"
|
|
82
|
+
},
|
|
83
|
+
"./i18n": {
|
|
84
|
+
"import": "./dist/i18n/index.js",
|
|
85
|
+
"types": "./dist/i18n/index.d.ts"
|
|
86
|
+
},
|
|
87
|
+
"./i18n/middleware": {
|
|
88
|
+
"import": "./dist/i18n/middleware.js",
|
|
89
|
+
"types": "./dist/i18n/middleware.d.ts"
|
|
90
|
+
},
|
|
91
|
+
"./highlight": {
|
|
92
|
+
"import": "./dist/highlight/index.js",
|
|
93
|
+
"types": "./dist/highlight/index.d.ts"
|
|
94
|
+
},
|
|
95
|
+
"./highlight/client": {
|
|
96
|
+
"import": "./dist/highlight/client.js",
|
|
97
|
+
"types": "./dist/highlight/client.d.ts"
|
|
98
|
+
},
|
|
99
|
+
"./framework": {
|
|
100
|
+
"import": "./dist/framework/index.js",
|
|
101
|
+
"types": "./dist/framework/index.d.ts"
|
|
102
|
+
},
|
|
103
|
+
"./framework/*": {
|
|
104
|
+
"import": "./dist/framework/*.js",
|
|
105
|
+
"types": "./dist/framework/*.d.ts"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"files": [
|
|
109
|
+
"dist/*"
|
|
110
|
+
],
|
|
111
|
+
"dependencies": {
|
|
112
|
+
"@formatjs/intl-localematcher": "^0.6.2",
|
|
113
|
+
"@orama/orama": "^3.1.16",
|
|
114
|
+
"@shikijs/rehype": "^3.20.0",
|
|
115
|
+
"@shikijs/transformers": "^3.20.0",
|
|
116
|
+
"estree-util-value-to-estree": "^3.5.0",
|
|
117
|
+
"github-slugger": "^2.0.0",
|
|
118
|
+
"hast-util-to-estree": "^3.1.3",
|
|
119
|
+
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
120
|
+
"image-size": "^2.0.2",
|
|
121
|
+
"negotiator": "^1.0.0",
|
|
122
|
+
"npm-to-yarn": "^3.0.1",
|
|
123
|
+
"path-to-regexp": "^8.3.0",
|
|
124
|
+
"remark": "^15.0.1",
|
|
125
|
+
"remark-gfm": "^4.0.1",
|
|
126
|
+
"remark-rehype": "^11.1.2",
|
|
127
|
+
"scroll-into-view-if-needed": "^3.1.0",
|
|
128
|
+
"shiki": "^3.20.0",
|
|
129
|
+
"unist-util-visit": "^5.0.0"
|
|
130
|
+
},
|
|
131
|
+
"devDependencies": {
|
|
132
|
+
"@mdx-js/mdx": "^3.1.1",
|
|
133
|
+
"@mixedbread/sdk": "^0.46.0",
|
|
134
|
+
"@orama/core": "^1.2.14",
|
|
135
|
+
"@tanstack/react-router": "1.136.18",
|
|
136
|
+
"@types/estree-jsx": "^1.0.5",
|
|
137
|
+
"@types/hast": "^3.0.4",
|
|
138
|
+
"@types/mdast": "^4.0.4",
|
|
139
|
+
"@types/negotiator": "^0.6.4",
|
|
140
|
+
"@types/node": "24.10.2",
|
|
141
|
+
"@types/react": "^19.2.7",
|
|
142
|
+
"@types/react-dom": "^19.2.3",
|
|
143
|
+
"algoliasearch": "5.46.0",
|
|
144
|
+
"lucide-react": "^0.561.0",
|
|
145
|
+
"mdast-util-mdx-jsx": "^3.2.0",
|
|
146
|
+
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
147
|
+
"next": "16.0.10",
|
|
148
|
+
"react-router": "^7.10.1",
|
|
149
|
+
"remark-directive": "^4.0.0",
|
|
150
|
+
"remark-mdx": "^3.1.1",
|
|
151
|
+
"remove-markdown": "^0.6.2",
|
|
152
|
+
"typescript": "^5.9.3",
|
|
153
|
+
"unified": "^11.0.5",
|
|
154
|
+
"vfile": "^6.0.3",
|
|
155
|
+
"waku": "^0.27.4",
|
|
156
|
+
"zod": "^4.1.13",
|
|
157
|
+
"eslint-config-custom": "0.0.0",
|
|
158
|
+
"tsconfig": "0.0.0"
|
|
159
|
+
},
|
|
160
|
+
"peerDependencies": {
|
|
161
|
+
"@mixedbread/sdk": "^0.19.0",
|
|
162
|
+
"@orama/core": "1.x.x",
|
|
163
|
+
"@tanstack/react-router": "1.x.x",
|
|
164
|
+
"@types/react": "*",
|
|
165
|
+
"algoliasearch": "5.x.x",
|
|
166
|
+
"lucide-react": "*",
|
|
167
|
+
"next": "16.x.x",
|
|
168
|
+
"react": "^19.2.0",
|
|
169
|
+
"react-dom": "^19.2.0",
|
|
170
|
+
"react-router": "7.x.x",
|
|
171
|
+
"waku": "^0.26.0 || ^0.27.0",
|
|
172
|
+
"zod": "*"
|
|
173
|
+
},
|
|
174
|
+
"peerDependenciesMeta": {
|
|
175
|
+
"@mixedbread/sdk": {
|
|
176
|
+
"optional": true
|
|
177
|
+
},
|
|
178
|
+
"@types/react": {
|
|
179
|
+
"optional": true
|
|
180
|
+
},
|
|
181
|
+
"@orama/core": {
|
|
182
|
+
"optional": true
|
|
183
|
+
},
|
|
184
|
+
"algoliasearch": {
|
|
185
|
+
"optional": true
|
|
186
|
+
},
|
|
187
|
+
"next": {
|
|
188
|
+
"optional": true
|
|
189
|
+
},
|
|
190
|
+
"react": {
|
|
191
|
+
"optional": true
|
|
192
|
+
},
|
|
193
|
+
"react-dom": {
|
|
194
|
+
"optional": true
|
|
195
|
+
},
|
|
196
|
+
"react-router": {
|
|
197
|
+
"optional": true
|
|
198
|
+
},
|
|
199
|
+
"waku": {
|
|
200
|
+
"optional": true
|
|
201
|
+
},
|
|
202
|
+
"@tanstack/react-router": {
|
|
203
|
+
"optional": true
|
|
204
|
+
},
|
|
205
|
+
"lucide-react": {
|
|
206
|
+
"optional": true
|
|
207
|
+
},
|
|
208
|
+
"zod": {
|
|
209
|
+
"optional": true
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"publishConfig": {
|
|
213
|
+
"access": "public"
|
|
214
|
+
},
|
|
215
|
+
"scripts": {
|
|
216
|
+
"build": "tsup",
|
|
217
|
+
"clean": "rimraf dist",
|
|
218
|
+
"dev": "tsup --watch",
|
|
219
|
+
"lint": "eslint .",
|
|
220
|
+
"types:check": "tsc --noEmit"
|
|
221
|
+
}
|
|
222
|
+
}
|