fumadocs-core 16.2.0 → 16.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/breadcrumb.js +3 -3
- package/dist/{chunk-IZPLHEX4.js → chunk-XKUN7AUK.js} +45 -27
- package/dist/{fetch-2XFMBLBA.js → fetch-IBTWQCJR.js} +2 -2
- package/dist/{loader-DgL6G4CA.d.ts → loader-Dz9yZIJQ.d.ts} +4 -0
- package/dist/mdx-plugins/index.js +3 -3
- package/dist/page-tree/index.d.ts +2 -1
- package/dist/page-tree/index.js +5 -3
- package/dist/search/client.d.ts +1 -1
- package/dist/search/client.js +1 -1
- package/dist/search/server.d.ts +1 -1
- package/dist/search/server.js +1 -1
- package/dist/source/client/index.d.ts +16 -0
- package/dist/source/client/index.js +41 -0
- package/dist/source/index.d.ts +1 -1
- package/dist/source/index.js +53 -36
- package/dist/source/plugins/lucide-icons.d.ts +1 -1
- package/package.json +17 -17
- package/dist/hide-if-empty.d.ts +0 -18
- package/dist/hide-if-empty.js +0 -83
package/dist/breadcrumb.js
CHANGED
|
@@ -45,36 +45,21 @@ function getPageTreePeers(treeOrTrees, url) {
|
|
|
45
45
|
(item) => item.type === "page" && item.url !== url
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (rootTree) {
|
|
52
|
-
const parent = findParentFromTree(rootTree, url);
|
|
53
|
-
if (parent) {
|
|
54
|
-
return parent.children.filter(
|
|
55
|
-
(item) => item.type === "page" && item.url !== url
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
48
|
+
for (const lang in treeOrTrees) {
|
|
49
|
+
const result = getPageTreePeers(treeOrTrees[lang], url);
|
|
50
|
+
if (result) return result;
|
|
59
51
|
}
|
|
60
52
|
return [];
|
|
61
53
|
}
|
|
62
|
-
function findParentFromTree(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const parent = findParentFromTree(child, url);
|
|
69
|
-
if (parent) return parent;
|
|
70
|
-
}
|
|
71
|
-
if (child.type === "page" && child.url === url) {
|
|
72
|
-
return node;
|
|
54
|
+
function findParentFromTree(from, url) {
|
|
55
|
+
let result;
|
|
56
|
+
visit(from, (node, parent) => {
|
|
57
|
+
if ("type" in node && node.type === "page" && node.url === url) {
|
|
58
|
+
result = parent;
|
|
59
|
+
return "break";
|
|
73
60
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return findParentFromTree(node.fallback, url);
|
|
77
|
-
}
|
|
61
|
+
});
|
|
62
|
+
return result;
|
|
78
63
|
}
|
|
79
64
|
function findPath(nodes, matcher, options = {}) {
|
|
80
65
|
const { includeSeparator = true } = options;
|
|
@@ -103,11 +88,44 @@ function findPath(nodes, matcher, options = {}) {
|
|
|
103
88
|
}
|
|
104
89
|
return run(nodes) ?? null;
|
|
105
90
|
}
|
|
91
|
+
var VisitBreak = Symbol("VisitBreak");
|
|
92
|
+
function visit(root, visitor) {
|
|
93
|
+
function onNode(node, parent) {
|
|
94
|
+
const result = visitor(node, parent);
|
|
95
|
+
switch (result) {
|
|
96
|
+
case "skip":
|
|
97
|
+
return node;
|
|
98
|
+
case "break":
|
|
99
|
+
throw VisitBreak;
|
|
100
|
+
default:
|
|
101
|
+
if (result) node = result;
|
|
102
|
+
}
|
|
103
|
+
if ("index" in node && node.index) {
|
|
104
|
+
node.index = onNode(node.index, node);
|
|
105
|
+
}
|
|
106
|
+
if ("fallback" in node && node.fallback) {
|
|
107
|
+
node.fallback = onNode(node.fallback, node);
|
|
108
|
+
}
|
|
109
|
+
if ("children" in node) {
|
|
110
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
111
|
+
node.children[i] = onNode(node.children[i], node);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return node;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
return onNode(root);
|
|
118
|
+
} catch (e) {
|
|
119
|
+
if (e === VisitBreak) return root;
|
|
120
|
+
throw e;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
106
123
|
|
|
107
124
|
export {
|
|
108
125
|
flattenTree,
|
|
109
126
|
findNeighbour,
|
|
110
127
|
getPageTreeRoots,
|
|
111
128
|
getPageTreePeers,
|
|
112
|
-
findPath
|
|
129
|
+
findPath,
|
|
130
|
+
visit
|
|
113
131
|
};
|
|
@@ -8,10 +8,10 @@ async function fetchDocs(query, { api = "/api/search", locale, tag }) {
|
|
|
8
8
|
if (locale) url.searchParams.set("locale", locale);
|
|
9
9
|
if (tag)
|
|
10
10
|
url.searchParams.set("tag", Array.isArray(tag) ? tag.join(",") : tag);
|
|
11
|
-
const key =
|
|
11
|
+
const key = url.toString();
|
|
12
12
|
const cached = cache.get(key);
|
|
13
13
|
if (cached) return cached;
|
|
14
|
-
const res = await fetch(
|
|
14
|
+
const res = await fetch(url);
|
|
15
15
|
if (!res.ok) throw new Error(await res.text());
|
|
16
16
|
const result = await res.json();
|
|
17
17
|
cache.set(key, result);
|
|
@@ -280,6 +280,10 @@ interface LoaderOutput<Config extends LoaderConfig> {
|
|
|
280
280
|
* @param lang - customise parameter name for lang
|
|
281
281
|
*/
|
|
282
282
|
generateParams: <TSlug extends string = 'slug', TLang extends string = 'lang'>(slug?: TSlug, lang?: TLang) => (Record<TSlug, string[]> & Record<TLang, string>)[];
|
|
283
|
+
/**
|
|
284
|
+
* serialize page tree for non-RSC environments
|
|
285
|
+
*/
|
|
286
|
+
serializePageTree: (tree: Root) => Promise<object>;
|
|
283
287
|
}
|
|
284
288
|
declare function createGetUrl(baseUrl: string, i18n?: I18nConfig): ResolvedLoaderConfig['url'];
|
|
285
289
|
declare function loader<Config extends SourceConfig, I18n extends I18nConfig | undefined = undefined>(source: Source<Config>, options: LoaderOptions<{
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
default as default2
|
|
3
|
-
} from "../chunk-ONG4RVCR.js";
|
|
4
1
|
import {
|
|
5
2
|
remarkImage
|
|
6
3
|
} from "../chunk-YDNO7UZ6.js";
|
|
@@ -42,6 +39,9 @@ import {
|
|
|
42
39
|
import {
|
|
43
40
|
remarkDirectiveAdmonition
|
|
44
41
|
} from "../chunk-APKPSBSB.js";
|
|
42
|
+
import {
|
|
43
|
+
default as default2
|
|
44
|
+
} from "../chunk-ONG4RVCR.js";
|
|
45
45
|
import "../chunk-XN2LKXFZ.js";
|
|
46
46
|
import {
|
|
47
47
|
remarkHeading
|
|
@@ -28,5 +28,6 @@ declare function getPageTreePeers(treeOrTrees: Root | Record<string, Root>, url:
|
|
|
28
28
|
declare function findPath(nodes: Node[], matcher: (node: Node) => boolean, options?: {
|
|
29
29
|
includeSeparator?: boolean;
|
|
30
30
|
}): Node[] | null;
|
|
31
|
+
declare function visit<Root extends Node | Root>(root: Root, visitor: <T extends Node | Root>(node: T, parent?: Root | Folder) => 'skip' | 'break' | T | void): Root;
|
|
31
32
|
|
|
32
|
-
export { Folder, Item, Node, Root, findNeighbour, findPath, flattenTree, getPageTreePeers, getPageTreeRoots };
|
|
33
|
+
export { Folder, Item, Node, Root, findNeighbour, findPath, flattenTree, getPageTreePeers, getPageTreeRoots, visit };
|
package/dist/page-tree/index.js
CHANGED
|
@@ -3,13 +3,15 @@ import {
|
|
|
3
3
|
findPath,
|
|
4
4
|
flattenTree,
|
|
5
5
|
getPageTreePeers,
|
|
6
|
-
getPageTreeRoots
|
|
7
|
-
|
|
6
|
+
getPageTreeRoots,
|
|
7
|
+
visit
|
|
8
|
+
} from "../chunk-XKUN7AUK.js";
|
|
8
9
|
import "../chunk-U67V476Y.js";
|
|
9
10
|
export {
|
|
10
11
|
findNeighbour,
|
|
11
12
|
findPath,
|
|
12
13
|
flattenTree,
|
|
13
14
|
getPageTreePeers,
|
|
14
|
-
getPageTreeRoots
|
|
15
|
+
getPageTreeRoots,
|
|
16
|
+
visit
|
|
15
17
|
};
|
package/dist/search/client.d.ts
CHANGED
package/dist/search/client.js
CHANGED
|
@@ -58,7 +58,7 @@ function useDocsSearch(clientOptions) {
|
|
|
58
58
|
async function run() {
|
|
59
59
|
if (debouncedValue.length === 0 && !allowEmpty) return "empty";
|
|
60
60
|
if (client.type === "fetch") {
|
|
61
|
-
const { fetchDocs } = await import("../fetch-
|
|
61
|
+
const { fetchDocs } = await import("../fetch-IBTWQCJR.js");
|
|
62
62
|
return fetchDocs(debouncedValue, client);
|
|
63
63
|
}
|
|
64
64
|
if (client.type === "algolia") {
|
package/dist/search/server.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { StructuredData } from '../mdx-plugins/remark-structure.js';
|
|
|
3
3
|
import { SortedResult } from './index.js';
|
|
4
4
|
export { HighlightedText, ReactSortedResult, createContentHighlighter } from './index.js';
|
|
5
5
|
import { I18nConfig } from '../i18n/index.js';
|
|
6
|
-
import { g as LoaderOutput, c as LoaderConfig, I as InferPageType } from '../loader-
|
|
6
|
+
import { g as LoaderOutput, c as LoaderConfig, I as InferPageType } from '../loader-Dz9yZIJQ.js';
|
|
7
7
|
import 'mdast';
|
|
8
8
|
import 'unified';
|
|
9
9
|
import 'mdast-util-mdx-jsx';
|
package/dist/search/server.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { R as Root } from '../../definitions-DbCug1P3.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
declare function deserializePageTree(root: Root): Root;
|
|
5
|
+
/**
|
|
6
|
+
* Deserialize data passed from server-side loader.
|
|
7
|
+
*
|
|
8
|
+
* It only receives the serialized data from server-side, hence not sharing plugins and some properties.
|
|
9
|
+
*/
|
|
10
|
+
declare function useFumadocsLoader<V extends {
|
|
11
|
+
pageTree?: object;
|
|
12
|
+
}>(serialized: V): {
|
|
13
|
+
pageTree: V["pageTree"] extends object ? Root : undefined;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { deserializePageTree, useFumadocsLoader };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
visit
|
|
3
|
+
} from "../../chunk-XKUN7AUK.js";
|
|
4
|
+
import "../../chunk-U67V476Y.js";
|
|
5
|
+
|
|
6
|
+
// src/source/client/index.tsx
|
|
7
|
+
import { useMemo } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function deserializePageTree(root) {
|
|
10
|
+
function deserializeHTML(html) {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"span",
|
|
13
|
+
{
|
|
14
|
+
dangerouslySetInnerHTML: {
|
|
15
|
+
__html: html
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
visit(root, (item) => {
|
|
21
|
+
if ("icon" in item && typeof item.icon === "string") {
|
|
22
|
+
item.icon = deserializeHTML(item.icon);
|
|
23
|
+
}
|
|
24
|
+
if (typeof item.name === "string") {
|
|
25
|
+
item.name = deserializeHTML(item.name);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return root;
|
|
29
|
+
}
|
|
30
|
+
function useFumadocsLoader(serialized) {
|
|
31
|
+
const { pageTree } = serialized;
|
|
32
|
+
return useMemo(() => {
|
|
33
|
+
return {
|
|
34
|
+
pageTree: pageTree ? deserializePageTree(pageTree) : void 0
|
|
35
|
+
};
|
|
36
|
+
}, [pageTree]);
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
deserializePageTree,
|
|
40
|
+
useFumadocsLoader
|
|
41
|
+
};
|
package/dist/source/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as ContentStorage, q as ContentStorageFile, F as FileSystem, i as InferMetaType, I as InferPageType, c as LoaderConfig, d as LoaderOptions, g as LoaderOutput, L as LoaderPlugin, s as LoaderPluginOption, f as Meta, M as MetaData, e as Page, P as PageData, o as PageTreeBuilder, j as PageTreeBuilderContext, n as PageTreeOptions, k as PageTreeTransformer, R as ResolvedLoaderConfig, S as Source, a as SourceConfig, V as VirtualFile, _ as _ConfigUnion_, r as buildContentStorage, t as buildPlugins, h as createGetUrl, p as createPageTreeBuilder, l as loader, b as map, m as multiple } from '../loader-
|
|
1
|
+
export { C as ContentStorage, q as ContentStorageFile, F as FileSystem, i as InferMetaType, I as InferPageType, c as LoaderConfig, d as LoaderOptions, g as LoaderOutput, L as LoaderPlugin, s as LoaderPluginOption, f as Meta, M as MetaData, e as Page, P as PageData, o as PageTreeBuilder, j as PageTreeBuilderContext, n as PageTreeOptions, k as PageTreeTransformer, R as ResolvedLoaderConfig, S as Source, a as SourceConfig, V as VirtualFile, _ as _ConfigUnion_, r as buildContentStorage, t as buildPlugins, h as createGetUrl, p as createPageTreeBuilder, l as loader, b as map, m as multiple } from '../loader-Dz9yZIJQ.js';
|
|
2
2
|
import '../definitions-DbCug1P3.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '../i18n/index.js';
|
package/dist/source/index.js
CHANGED
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
normalizeUrl
|
|
15
15
|
} from "../chunk-PFNP6PEB.js";
|
|
16
|
+
import {
|
|
17
|
+
visit
|
|
18
|
+
} from "../chunk-XKUN7AUK.js";
|
|
16
19
|
import "../chunk-U67V476Y.js";
|
|
17
20
|
|
|
18
21
|
// src/source/source.ts
|
|
@@ -330,7 +333,8 @@ function createPageTreeBuilderUtils(ctx) {
|
|
|
330
333
|
const dirNode = this.folder(path, false);
|
|
331
334
|
if (dirNode) folders.push(dirNode);
|
|
332
335
|
}
|
|
333
|
-
|
|
336
|
+
items.push(...folders);
|
|
337
|
+
return items;
|
|
334
338
|
},
|
|
335
339
|
resolveFolderItem(folderPath, item) {
|
|
336
340
|
if (item === rest || item === restReversed) return item;
|
|
@@ -618,48 +622,28 @@ function createGetUrl(baseUrl, i18n) {
|
|
|
618
622
|
};
|
|
619
623
|
}
|
|
620
624
|
function loader(...args) {
|
|
621
|
-
const
|
|
622
|
-
return createOutput(resolved);
|
|
623
|
-
}
|
|
624
|
-
function resolveConfig(source, { slugs, icon, plugins = [], baseUrl, url, ...base }) {
|
|
625
|
-
let config = {
|
|
626
|
-
...base,
|
|
627
|
-
url: url ? (...args) => normalizeUrl(url(...args)) : createGetUrl(baseUrl, base.i18n),
|
|
628
|
-
source,
|
|
629
|
-
plugins: buildPlugins([
|
|
630
|
-
slugsPlugin(slugs),
|
|
631
|
-
icon && iconPlugin(icon),
|
|
632
|
-
...typeof plugins === "function" ? plugins({
|
|
633
|
-
typedPlugin: (plugin) => plugin
|
|
634
|
-
}) : plugins
|
|
635
|
-
])
|
|
636
|
-
};
|
|
637
|
-
for (const plugin of config.plugins ?? []) {
|
|
638
|
-
const result = plugin.config?.(config);
|
|
639
|
-
if (result) config = result;
|
|
640
|
-
}
|
|
641
|
-
return config;
|
|
642
|
-
}
|
|
643
|
-
function createOutput(loaderConfig) {
|
|
625
|
+
const loaderConfig = args.length === 2 ? resolveConfig(args[0], args[1]) : resolveConfig(args[0].source, args[0]);
|
|
644
626
|
const { i18n } = loaderConfig;
|
|
645
627
|
const defaultLanguage = i18n?.defaultLanguage ?? "";
|
|
646
628
|
const storages = buildContentStorage(loaderConfig, defaultLanguage);
|
|
647
629
|
const walker = indexPages(storages, loaderConfig);
|
|
648
630
|
const builder = createPageTreeBuilder(loaderConfig);
|
|
649
|
-
let
|
|
631
|
+
let pageTrees;
|
|
632
|
+
function getPageTrees() {
|
|
633
|
+
return pageTrees ??= builder.buildI18n(storages);
|
|
634
|
+
}
|
|
650
635
|
return {
|
|
651
636
|
_i18n: i18n,
|
|
652
637
|
get pageTree() {
|
|
653
|
-
|
|
654
|
-
return i18n ?
|
|
638
|
+
const trees = getPageTrees();
|
|
639
|
+
return i18n ? trees : trees[defaultLanguage];
|
|
655
640
|
},
|
|
656
641
|
set pageTree(v) {
|
|
657
642
|
if (i18n) {
|
|
658
|
-
|
|
643
|
+
pageTrees = v;
|
|
659
644
|
} else {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
};
|
|
645
|
+
pageTrees ??= {};
|
|
646
|
+
pageTrees[defaultLanguage] = v;
|
|
663
647
|
}
|
|
664
648
|
},
|
|
665
649
|
getPageByHref(href, { dir = "", language = defaultLanguage } = {}) {
|
|
@@ -715,11 +699,9 @@ function createOutput(loaderConfig) {
|
|
|
715
699
|
if (!ref) return;
|
|
716
700
|
return walker.pathToPage.get(`${language}.${ref}`);
|
|
717
701
|
},
|
|
718
|
-
getPageTree(locale) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
return this.pageTree;
|
|
702
|
+
getPageTree(locale = defaultLanguage) {
|
|
703
|
+
const trees = getPageTrees();
|
|
704
|
+
return trees[locale] ?? trees[defaultLanguage];
|
|
723
705
|
},
|
|
724
706
|
// @ts-expect-error -- ignore this
|
|
725
707
|
generateParams(slug, lang) {
|
|
@@ -734,9 +716,44 @@ function createOutput(loaderConfig) {
|
|
|
734
716
|
return this.getPages().map((page) => ({
|
|
735
717
|
[slug ?? "slug"]: page.slugs
|
|
736
718
|
}));
|
|
719
|
+
},
|
|
720
|
+
async serializePageTree(tree) {
|
|
721
|
+
const { renderToString } = await import("react-dom/server.edge");
|
|
722
|
+
return visit(tree, (node) => {
|
|
723
|
+
node = { ...node };
|
|
724
|
+
if ("icon" in node && node.icon) {
|
|
725
|
+
node.icon = renderToString(node.icon);
|
|
726
|
+
}
|
|
727
|
+
if (node.name) {
|
|
728
|
+
node.name = renderToString(node.name);
|
|
729
|
+
}
|
|
730
|
+
if ("children" in node) {
|
|
731
|
+
node.children = [...node.children];
|
|
732
|
+
}
|
|
733
|
+
return node;
|
|
734
|
+
});
|
|
737
735
|
}
|
|
738
736
|
};
|
|
739
737
|
}
|
|
738
|
+
function resolveConfig(source, { slugs, icon, plugins = [], baseUrl, url, ...base }) {
|
|
739
|
+
let config = {
|
|
740
|
+
...base,
|
|
741
|
+
url: url ? (...args) => normalizeUrl(url(...args)) : createGetUrl(baseUrl, base.i18n),
|
|
742
|
+
source,
|
|
743
|
+
plugins: buildPlugins([
|
|
744
|
+
slugsPlugin(slugs),
|
|
745
|
+
icon && iconPlugin(icon),
|
|
746
|
+
...typeof plugins === "function" ? plugins({
|
|
747
|
+
typedPlugin: (plugin) => plugin
|
|
748
|
+
}) : plugins
|
|
749
|
+
])
|
|
750
|
+
};
|
|
751
|
+
for (const plugin of config.plugins ?? []) {
|
|
752
|
+
const result = plugin.config?.(config);
|
|
753
|
+
if (result) config = result;
|
|
754
|
+
}
|
|
755
|
+
return config;
|
|
756
|
+
}
|
|
740
757
|
export {
|
|
741
758
|
FileSystem,
|
|
742
759
|
path_exports as PathUtils,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.2",
|
|
4
4
|
"description": "The React.js library for building a documentation website",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fumadocs",
|
|
@@ -28,10 +28,6 @@
|
|
|
28
28
|
"import": "./dist/content/*.js",
|
|
29
29
|
"types": "./dist/content/*.d.ts"
|
|
30
30
|
},
|
|
31
|
-
"./hide-if-empty": {
|
|
32
|
-
"import": "./dist/hide-if-empty.js",
|
|
33
|
-
"types": "./dist/hide-if-empty.d.ts"
|
|
34
|
-
},
|
|
35
31
|
"./negotiation": {
|
|
36
32
|
"import": "./dist/negotiation/index.js",
|
|
37
33
|
"types": "./dist/negotiation/index.d.ts"
|
|
@@ -52,6 +48,10 @@
|
|
|
52
48
|
"import": "./dist/source/index.js",
|
|
53
49
|
"types": "./dist/source/index.d.ts"
|
|
54
50
|
},
|
|
51
|
+
"./source/client": {
|
|
52
|
+
"import": "./dist/source/client/index.js",
|
|
53
|
+
"types": "./dist/source/client/index.d.ts"
|
|
54
|
+
},
|
|
55
55
|
"./source/*": {
|
|
56
56
|
"import": "./dist/source/plugins/*.js",
|
|
57
57
|
"types": "./dist/source/plugins/*.d.ts"
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"@formatjs/intl-localematcher": "^0.6.2",
|
|
109
109
|
"@orama/orama": "^3.1.16",
|
|
110
|
-
"@shikijs/rehype": "^3.
|
|
111
|
-
"@shikijs/transformers": "^3.
|
|
110
|
+
"@shikijs/rehype": "^3.18.0",
|
|
111
|
+
"@shikijs/transformers": "^3.18.0",
|
|
112
112
|
"estree-util-value-to-estree": "^3.5.0",
|
|
113
113
|
"github-slugger": "^2.0.0",
|
|
114
114
|
"hast-util-to-estree": "^3.1.3",
|
|
@@ -121,26 +121,26 @@
|
|
|
121
121
|
"remark-gfm": "^4.0.1",
|
|
122
122
|
"remark-rehype": "^11.1.2",
|
|
123
123
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
124
|
-
"shiki": "^3.
|
|
124
|
+
"shiki": "^3.18.0",
|
|
125
125
|
"unist-util-visit": "^5.0.0"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
128
|
"@mdx-js/mdx": "^3.1.1",
|
|
129
|
-
"@mixedbread/sdk": "^0.
|
|
129
|
+
"@mixedbread/sdk": "^0.45.0",
|
|
130
130
|
"@orama/core": "^1.2.13",
|
|
131
|
-
"@tanstack/react-router": "
|
|
131
|
+
"@tanstack/react-router": "1.136.18",
|
|
132
132
|
"@types/estree-jsx": "^1.0.5",
|
|
133
133
|
"@types/hast": "^3.0.4",
|
|
134
134
|
"@types/mdast": "^4.0.4",
|
|
135
135
|
"@types/negotiator": "^0.6.4",
|
|
136
136
|
"@types/node": "24.10.1",
|
|
137
|
-
"@types/react": "^19.2.
|
|
137
|
+
"@types/react": "^19.2.7",
|
|
138
138
|
"@types/react-dom": "^19.2.3",
|
|
139
|
-
"algoliasearch": "5.
|
|
140
|
-
"lucide-react": "^0.
|
|
139
|
+
"algoliasearch": "5.45.0",
|
|
140
|
+
"lucide-react": "^0.555.0",
|
|
141
141
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
142
142
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
143
|
-
"next": "16.0.
|
|
143
|
+
"next": "16.0.6",
|
|
144
144
|
"react-router": "^7.9.6",
|
|
145
145
|
"remark-directive": "^4.0.0",
|
|
146
146
|
"remark-mdx": "^3.1.1",
|
|
@@ -148,9 +148,9 @@
|
|
|
148
148
|
"typescript": "^5.9.3",
|
|
149
149
|
"unified": "^11.0.5",
|
|
150
150
|
"vfile": "^6.0.3",
|
|
151
|
-
"waku": "^0.27.
|
|
152
|
-
"
|
|
153
|
-
"
|
|
151
|
+
"waku": "^0.27.2",
|
|
152
|
+
"tsconfig": "0.0.0",
|
|
153
|
+
"eslint-config-custom": "0.0.0"
|
|
154
154
|
},
|
|
155
155
|
"peerDependencies": {
|
|
156
156
|
"@mixedbread/sdk": "^0.19.0",
|
package/dist/hide-if-empty.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode, HTMLAttributes, FC } from 'react';
|
|
3
|
-
|
|
4
|
-
declare function HideIfEmptyProvider({ nonce, children, }: {
|
|
5
|
-
nonce?: string;
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
}): react_jsx_runtime.JSX.Element;
|
|
8
|
-
/**
|
|
9
|
-
* The built-in CSS `:empty` selector cannot detect if the children is hidden, classes such as `md:hidden` causes it to fail.
|
|
10
|
-
* This component is an enhancement to `empty:hidden` to fix the issue described above.
|
|
11
|
-
*
|
|
12
|
-
* This can be expensive, please avoid this whenever possible.
|
|
13
|
-
*/
|
|
14
|
-
declare function HideIfEmpty<Props extends HTMLAttributes<HTMLElement>>({ as: Comp, ...props }: Props & {
|
|
15
|
-
as: FC<Props>;
|
|
16
|
-
}): react_jsx_runtime.JSX.Element;
|
|
17
|
-
|
|
18
|
-
export { HideIfEmpty, HideIfEmptyProvider };
|
package/dist/hide-if-empty.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "./chunk-U67V476Y.js";
|
|
3
|
-
|
|
4
|
-
// src/hide-if-empty.tsx
|
|
5
|
-
import {
|
|
6
|
-
createContext,
|
|
7
|
-
useContext,
|
|
8
|
-
useEffect,
|
|
9
|
-
useId,
|
|
10
|
-
useMemo,
|
|
11
|
-
useState
|
|
12
|
-
} from "react";
|
|
13
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
var Context = createContext({
|
|
15
|
-
nonce: void 0
|
|
16
|
-
});
|
|
17
|
-
function HideIfEmptyProvider({
|
|
18
|
-
nonce,
|
|
19
|
-
children
|
|
20
|
-
}) {
|
|
21
|
-
return /* @__PURE__ */ jsx(Context.Provider, { value: useMemo(() => ({ nonce }), [nonce]), children });
|
|
22
|
-
}
|
|
23
|
-
function getElement(id) {
|
|
24
|
-
return document.querySelector(`[data-fd-if-empty="${id}"]`);
|
|
25
|
-
}
|
|
26
|
-
function isEmpty(node) {
|
|
27
|
-
for (let i = 0; i < node.childNodes.length; i++) {
|
|
28
|
-
const child = node.childNodes.item(i);
|
|
29
|
-
if (child.nodeType === Node.TEXT_NODE || child.nodeType === Node.ELEMENT_NODE && window.getComputedStyle(child).display !== "none") {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
function HideIfEmpty({
|
|
36
|
-
as: Comp,
|
|
37
|
-
...props
|
|
38
|
-
}) {
|
|
39
|
-
const id = useId();
|
|
40
|
-
const { nonce } = useContext(Context);
|
|
41
|
-
const [empty, setEmpty] = useState(() => {
|
|
42
|
-
const element = typeof window !== "undefined" ? getElement(id) : null;
|
|
43
|
-
if (element) return isEmpty(element);
|
|
44
|
-
});
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
const handleResize = () => {
|
|
47
|
-
const element = getElement(id);
|
|
48
|
-
if (element) setEmpty(isEmpty(element));
|
|
49
|
-
};
|
|
50
|
-
window.addEventListener("resize", handleResize);
|
|
51
|
-
return () => window.removeEventListener("resize", handleResize);
|
|
52
|
-
}, [id]);
|
|
53
|
-
const init = (id2) => {
|
|
54
|
-
const element = getElement(id2);
|
|
55
|
-
if (element) {
|
|
56
|
-
element.hidden = isEmpty(element);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
-
/* @__PURE__ */ jsx(
|
|
61
|
-
Comp,
|
|
62
|
-
{
|
|
63
|
-
...props,
|
|
64
|
-
"data-fd-if-empty": id,
|
|
65
|
-
hidden: empty ?? false
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ jsx(
|
|
69
|
-
"script",
|
|
70
|
-
{
|
|
71
|
-
suppressHydrationWarning: true,
|
|
72
|
-
nonce,
|
|
73
|
-
dangerouslySetInnerHTML: {
|
|
74
|
-
__html: `{${getElement};${isEmpty};(${init})("${id}")}`
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
)
|
|
78
|
-
] });
|
|
79
|
-
}
|
|
80
|
-
export {
|
|
81
|
-
HideIfEmpty,
|
|
82
|
-
HideIfEmptyProvider
|
|
83
|
-
};
|