fumadocs-core 16.14.5 → 16.15.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/dist/{advanced-B0__lVW5.js → advanced-Ct13khZr.js} +3 -1
- package/dist/{loader-9mGcCnIF.js → dynamic-Dgf8t2t2.js} +104 -11
- package/dist/highlight/client.js +1 -1
- package/dist/highlight/index.js +1 -1
- package/dist/highlight/shiki/index.js +9 -4
- package/dist/{index-BNgjXvXj2.d.ts → index-DQWu2opy2.d.ts} +52 -16
- package/dist/mdx-plugins/index.js +1 -1
- package/dist/mdx-plugins/rehype-code.core.js +1 -1
- package/dist/mdx-plugins/rehype-code.js +1 -1
- package/dist/{rehype-code.core-CWlREGfK.js → rehype-code.core-BUwNuchP.js} +1 -1
- package/dist/search/client/algolia.js +3 -7
- package/dist/search/client/orama-static.js +1 -1
- package/dist/search/flexsearch.d.ts +2 -2
- package/dist/search/mixedbread.d.ts +1 -1
- package/dist/search/server.d.ts +1 -1
- package/dist/search/server.js +10 -6
- package/dist/{server-BYa_JUH1.d.ts → server-DRvCKdc_.d.ts} +1 -1
- package/dist/source/dynamic.d.ts +1 -1
- package/dist/source/dynamic.js +1 -65
- package/dist/source/index.d.ts +2 -2
- package/dist/source/index.js +2 -2
- package/dist/source/llms.d.ts +1 -1
- package/dist/source/plugins/lucide-icons.d.ts +1 -1
- package/dist/source/plugins/slugs.d.ts +1 -1
- package/dist/source/plugins/status-badges.d.ts +1 -1
- package/dist/{utils-D2T58c9w.js → utils-Cgs-6U-z.js} +6 -14
- package/package.json +1 -1
|
@@ -47,8 +47,10 @@ async function searchAdvanced(db, query, tag = [], { mode = "fulltext", ...overr
|
|
|
47
47
|
if (query.length > 0) params.term = query;
|
|
48
48
|
const highlighter = createContentHighlighter(query);
|
|
49
49
|
const result = await search(db, params);
|
|
50
|
+
const limit = typeof params.limit === "number" ? params.limit : Infinity;
|
|
50
51
|
const list = [];
|
|
51
52
|
for (const item of result.groups ?? []) {
|
|
53
|
+
if (list.length >= limit) break;
|
|
52
54
|
const pageId = item.values[0];
|
|
53
55
|
const page = getByID(db, pageId);
|
|
54
56
|
if (!page) continue;
|
|
@@ -60,6 +62,7 @@ async function searchAdvanced(db, query, tag = [], { mode = "fulltext", ...overr
|
|
|
60
62
|
url: page.url
|
|
61
63
|
});
|
|
62
64
|
for (const hit of item.result) {
|
|
65
|
+
if (list.length >= limit) break;
|
|
63
66
|
if (hit.document.type === "page") continue;
|
|
64
67
|
list.push({
|
|
65
68
|
id: hit.document.id.toString(),
|
|
@@ -70,7 +73,6 @@ async function searchAdvanced(db, query, tag = [], { mode = "fulltext", ...overr
|
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
|
-
if (typeof params.limit === "number" && list.length > params.limit) return list.slice(0, params.limit);
|
|
74
76
|
return list;
|
|
75
77
|
}
|
|
76
78
|
//#endregion
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { r as normalizeUrl } from "./url-BVHvi3_K.js";
|
|
2
2
|
import { c as visit } from "./utils-Dn9VIXRN.js";
|
|
3
|
+
import { t as isEqualShallow } from "./is-equal-LdLqRs0o.js";
|
|
3
4
|
import { a as normalize, i as joinPath, n as dirname, r as extname, t as basename } from "./path-1H5VzYiT.js";
|
|
4
5
|
import { slugsPlugin } from "./source/plugins/slugs.js";
|
|
5
6
|
import { t as iconPlugin } from "./icon-BILaoXeg.js";
|
|
7
|
+
import { cache } from "react";
|
|
6
8
|
//#region src/source/storage/file-system.ts
|
|
7
9
|
/**
|
|
8
10
|
* In memory file system.
|
|
@@ -12,7 +14,7 @@ var FileSystem = class {
|
|
|
12
14
|
this.files = /* @__PURE__ */ new Map();
|
|
13
15
|
this.folders = /* @__PURE__ */ new Map();
|
|
14
16
|
if (inherit) {
|
|
15
|
-
for (const [k, v] of inherit.folders) this.folders.set(k, v);
|
|
17
|
+
for (const [k, v] of inherit.folders) this.folders.set(k, [...v]);
|
|
16
18
|
for (const [k, v] of inherit.files) this.files.set(k, v);
|
|
17
19
|
} else this.folders.set("", []);
|
|
18
20
|
}
|
|
@@ -83,11 +85,8 @@ function multiple(sources) {
|
|
|
83
85
|
})) };
|
|
84
86
|
return out;
|
|
85
87
|
}
|
|
86
|
-
function source(config) {
|
|
87
|
-
return { files: [...config.pages, ...config.metas] };
|
|
88
|
-
}
|
|
89
88
|
/**
|
|
90
|
-
* update a source object in-place.
|
|
89
|
+
* update a **static** source object in-place.
|
|
91
90
|
*/
|
|
92
91
|
function update(source) {
|
|
93
92
|
return {
|
|
@@ -160,10 +159,11 @@ function createContentStorageBuilder(loaderConfig) {
|
|
|
160
159
|
function scan(type, source) {
|
|
161
160
|
for (const inputFile of source.files) {
|
|
162
161
|
let file;
|
|
162
|
+
const path = normalize(source.baseDir ? `${source.baseDir}/${inputFile.path}` : inputFile.path);
|
|
163
163
|
if (inputFile.type === "page") file = {
|
|
164
164
|
format: "page",
|
|
165
165
|
type,
|
|
166
|
-
path
|
|
166
|
+
path,
|
|
167
167
|
slugs: inputFile.slugs,
|
|
168
168
|
data: inputFile.data,
|
|
169
169
|
absolutePath: inputFile.absolutePath
|
|
@@ -171,11 +171,11 @@ function createContentStorageBuilder(loaderConfig) {
|
|
|
171
171
|
else file = {
|
|
172
172
|
format: "meta",
|
|
173
173
|
type,
|
|
174
|
-
path
|
|
174
|
+
path,
|
|
175
175
|
absolutePath: inputFile.absolutePath,
|
|
176
176
|
data: inputFile.data
|
|
177
177
|
};
|
|
178
|
-
const [storageKey, locale = i18n ? i18n.defaultLanguage : EmptyLang] = parser(
|
|
178
|
+
const [storageKey, locale = i18n ? i18n.defaultLanguage : EmptyLang] = parser(path);
|
|
179
179
|
const entry = [storageKey, file];
|
|
180
180
|
if (Array.isArray(locale)) for (const item of locale) pushMapList(fileMap, item, entry);
|
|
181
181
|
else pushMapList(fileMap, locale, entry);
|
|
@@ -601,6 +601,7 @@ function createPageIndexer({ url }) {
|
|
|
601
601
|
const pages = /* @__PURE__ */ new Map();
|
|
602
602
|
const pathToMeta = /* @__PURE__ */ new Map();
|
|
603
603
|
const pathToPage = /* @__PURE__ */ new Map();
|
|
604
|
+
const urlToPage = /* @__PURE__ */ new Map();
|
|
604
605
|
return {
|
|
605
606
|
scan(storage, lang) {
|
|
606
607
|
for (const filePath of storage.getFiles()) {
|
|
@@ -627,11 +628,15 @@ function createPageIndexer({ url }) {
|
|
|
627
628
|
};
|
|
628
629
|
pathToPage.set(path, page);
|
|
629
630
|
pages.set(prefix + page.slugs.join("/"), page);
|
|
631
|
+
urlToPage.set(prefix + page.url, page);
|
|
630
632
|
}
|
|
631
633
|
},
|
|
632
634
|
getPage(path, lang = "") {
|
|
633
635
|
return pathToPage.get(`${lang}.${path}`);
|
|
634
636
|
},
|
|
637
|
+
getPageByUrl(url, lang = "") {
|
|
638
|
+
return urlToPage.get(`${lang}.${url}`);
|
|
639
|
+
},
|
|
635
640
|
getMeta(path, lang = "") {
|
|
636
641
|
return pathToMeta.get(`${lang}.${path}`);
|
|
637
642
|
},
|
|
@@ -687,7 +692,7 @@ function loader(...args) {
|
|
|
687
692
|
return pageTrees = out;
|
|
688
693
|
}
|
|
689
694
|
}
|
|
690
|
-
|
|
695
|
+
const out = {
|
|
691
696
|
_i18n: i18n,
|
|
692
697
|
get pageTree() {
|
|
693
698
|
return getPageTrees();
|
|
@@ -705,7 +710,7 @@ function loader(...args) {
|
|
|
705
710
|
} catch {}
|
|
706
711
|
const path = joinPath(dir, decoded);
|
|
707
712
|
target = indexer.getPage(path, language);
|
|
708
|
-
} else target =
|
|
713
|
+
} else target = indexer.getPageByUrl(value, language);
|
|
709
714
|
if (target) return {
|
|
710
715
|
page: target,
|
|
711
716
|
hash
|
|
@@ -775,6 +780,12 @@ function loader(...args) {
|
|
|
775
780
|
};
|
|
776
781
|
}
|
|
777
782
|
};
|
|
783
|
+
if (isStaticSource(loaderConfig.input)) loaderConfig.input.configureStatic?.({ loader: out });
|
|
784
|
+
else for (const [k, v] of Object.entries(loaderConfig.input)) v.configureStatic?.({
|
|
785
|
+
loader: out,
|
|
786
|
+
source: k
|
|
787
|
+
});
|
|
788
|
+
return out;
|
|
778
789
|
}
|
|
779
790
|
function resolveConfig(input, { slugs, baseSlugs, icon, plugins = [], baseUrl, url, ...base }) {
|
|
780
791
|
let config = {
|
|
@@ -809,4 +820,86 @@ function buildPlugins(plugins, sort = true) {
|
|
|
809
820
|
return flatten;
|
|
810
821
|
}
|
|
811
822
|
//#endregion
|
|
812
|
-
|
|
823
|
+
//#region src/source/dynamic.ts
|
|
824
|
+
/** content loader API for static & dynamic content sources, with in-memory cache. */
|
|
825
|
+
function dynamicLoader(input, options) {
|
|
826
|
+
let cachedLoader;
|
|
827
|
+
const memoryCache = /* @__PURE__ */ new Map();
|
|
828
|
+
async function resolveSources() {
|
|
829
|
+
if (isStaticSource(input) || isDynamicSource(input)) return resolveSource(input);
|
|
830
|
+
const entries = await Promise.all(Object.entries(input).map(async ([k, v]) => [k, await resolveSource(v)]));
|
|
831
|
+
return Object.fromEntries(entries);
|
|
832
|
+
}
|
|
833
|
+
function resolveSource(v) {
|
|
834
|
+
if (isStaticSource(v)) return v;
|
|
835
|
+
const mapFiles = (files) => ({
|
|
836
|
+
baseDir: v.baseDir,
|
|
837
|
+
files,
|
|
838
|
+
configureStatic: v.configureStatic
|
|
839
|
+
});
|
|
840
|
+
if (!v.cache || v.cache === "memory") {
|
|
841
|
+
const cached = memoryCache.get(v);
|
|
842
|
+
if (cached && (cached.expires === void 0 || Date.now() < cached.expires)) return cached.value;
|
|
843
|
+
const value = Promise.resolve(v.files()).then(mapFiles).catch((e) => {
|
|
844
|
+
if (memoryCache.get(v)?.value === value) memoryCache.delete(v);
|
|
845
|
+
throw e;
|
|
846
|
+
});
|
|
847
|
+
memoryCache.set(v, {
|
|
848
|
+
value,
|
|
849
|
+
expires: v.staleTime !== void 0 ? Date.now() + v.staleTime : void 0
|
|
850
|
+
});
|
|
851
|
+
return value;
|
|
852
|
+
}
|
|
853
|
+
return Promise.resolve(v.files()).then(mapFiles);
|
|
854
|
+
}
|
|
855
|
+
const dynamicLoader = {
|
|
856
|
+
get: cache(async () => {
|
|
857
|
+
const resolved = await resolveSources();
|
|
858
|
+
if (cachedLoader && isEqual(cachedLoader.input, resolved)) return cachedLoader.value;
|
|
859
|
+
cachedLoader = {
|
|
860
|
+
input: resolved,
|
|
861
|
+
value: loader(resolved, options)
|
|
862
|
+
};
|
|
863
|
+
return cachedLoader.value;
|
|
864
|
+
}),
|
|
865
|
+
$inferPage: void 0,
|
|
866
|
+
$inferMeta: void 0,
|
|
867
|
+
async revalidate(name) {
|
|
868
|
+
dynamicLoader.invalidate(name);
|
|
869
|
+
if (name === void 0) await resolveSources();
|
|
870
|
+
else if (!isStaticSource(input) && !isDynamicSource(input)) await resolveSource(input[name]);
|
|
871
|
+
},
|
|
872
|
+
invalidate(name) {
|
|
873
|
+
if (isStaticSource(input)) return;
|
|
874
|
+
if (name === void 0) {
|
|
875
|
+
memoryCache.clear();
|
|
876
|
+
if (isDynamicSource(input)) input.invalidate?.();
|
|
877
|
+
else for (const v of Object.values(input)) if (isDynamicSource(v)) v.invalidate?.();
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
if (isDynamicSource(input)) return;
|
|
881
|
+
const s = input[name];
|
|
882
|
+
if (!isDynamicSource(s)) return;
|
|
883
|
+
memoryCache.delete(s);
|
|
884
|
+
s.invalidate?.();
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
if (isDynamicSource(input) || isStaticSource(input)) {
|
|
888
|
+
input.configureDynamic?.({ loader: dynamicLoader });
|
|
889
|
+
if (isDynamicSource(input)) input.configure?.(dynamicLoader, {});
|
|
890
|
+
} else for (const [k, v] of Object.entries(input)) {
|
|
891
|
+
v.configureDynamic?.({
|
|
892
|
+
loader: dynamicLoader,
|
|
893
|
+
source: k
|
|
894
|
+
});
|
|
895
|
+
if (isDynamicSource(v)) v.configure?.(dynamicLoader, { source: k });
|
|
896
|
+
}
|
|
897
|
+
return dynamicLoader;
|
|
898
|
+
}
|
|
899
|
+
function isEqual(a, b) {
|
|
900
|
+
if (isStaticSource(a) && isStaticSource(b)) return isEqualShallow(a.files, b.files);
|
|
901
|
+
if (!isStaticSource(a) && !isStaticSource(b)) return Object.keys(b).every((k) => isEqualShallow(a[k].files, b[k].files));
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
//#endregion
|
|
905
|
+
export { update as a, multiple as i, createGetUrl as n, FileSystem as o, loader as r, dynamicLoader as t };
|
package/dist/highlight/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { t as applyDefaultThemes } from "../utils-
|
|
2
|
+
import { t as applyDefaultThemes } from "../utils-Cgs-6U-z.js";
|
|
3
3
|
import { useShiki as useShiki$1 } from "./shiki/react.js";
|
|
4
4
|
import { defaultShikiFactory } from "./shiki/full.js";
|
|
5
5
|
//#region src/highlight/client.ts
|
package/dist/highlight/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as loadMissingTheme, i as loadMissingLanguage, t as applyDefaultThemes } from "../utils-
|
|
1
|
+
import { a as loadMissingTheme, i as loadMissingLanguage, t as applyDefaultThemes } from "../utils-Cgs-6U-z.js";
|
|
2
2
|
import { highlightHast as highlightHast$1 } from "./shiki/index.js";
|
|
3
3
|
import { defaultShikiFactory, wasmShikiFactory } from "./shiki/full.js";
|
|
4
4
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { a as loadMissingTheme, r as getRequiredThemes } from "../../utils-
|
|
1
|
+
import { a as loadMissingTheme, r as getRequiredThemes } from "../../utils-Cgs-6U-z.js";
|
|
2
2
|
//#region src/highlight/shiki/index.ts
|
|
3
3
|
function createShikiFactory(config) {
|
|
4
4
|
let instance;
|
|
5
5
|
return {
|
|
6
6
|
init(options) {
|
|
7
|
-
|
|
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;
|
|
8
12
|
},
|
|
9
13
|
getOrInit() {
|
|
10
14
|
return instance ?? this.init();
|
|
@@ -14,8 +18,9 @@ function createShikiFactory(config) {
|
|
|
14
18
|
async function highlightHast(highlighter, code, options) {
|
|
15
19
|
const { fallbackLanguage = "text", ...resolved } = options;
|
|
16
20
|
const { isSpecialLang } = await import("shiki/core");
|
|
17
|
-
|
|
18
|
-
|
|
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)]);
|
|
19
24
|
return highlighter.codeToHast(code, resolved);
|
|
20
25
|
}
|
|
21
26
|
//#endregion
|
|
@@ -265,11 +265,13 @@ interface LoaderOutput<Config extends LoaderConfig = LoaderConfig> {
|
|
|
265
265
|
serializePageTree: (tree: Root) => Promise<SerializedPageTree>;
|
|
266
266
|
}
|
|
267
267
|
declare function createGetUrl(baseUrl: string, i18n?: I18nConfig): ResolvedLoaderConfig['url'];
|
|
268
|
+
/** content loader API for static content sources */
|
|
268
269
|
declare function loader<I extends ResolvedInput, I18n extends I18nConfig | undefined = undefined>(source: I, options: LoaderOptions<NoInfer<GenerateStorage<I>>, I18n>): LoaderOutput<{
|
|
269
270
|
meta: GenerateMeta<I>;
|
|
270
271
|
page: GeneratePage<I>;
|
|
271
272
|
i18n: I18n;
|
|
272
273
|
}>;
|
|
274
|
+
/** content loader API for static content sources */
|
|
273
275
|
declare function loader<I extends ResolvedInput, I18n extends I18nConfig | undefined = undefined>(options: LoaderOptions<NoInfer<GenerateStorage<I>>, I18n> & {
|
|
274
276
|
source: I;
|
|
275
277
|
}): LoaderOutput<{
|
|
@@ -305,20 +307,20 @@ type InferPageType<Utils extends LoaderOutput<any>> = Utils['$inferPage'];
|
|
|
305
307
|
type InferMetaType<Utils extends LoaderOutput<any>> = Utils['$inferMeta'];
|
|
306
308
|
//#endregion
|
|
307
309
|
//#region src/source/dynamic.d.ts
|
|
308
|
-
type Input = SourceUnion | Record<string, SourceUnion>;
|
|
309
310
|
interface DynamicLoaderConfig extends LoaderConfig {
|
|
310
311
|
source: string | undefined;
|
|
311
312
|
}
|
|
312
313
|
interface DynamicLoader<Config extends DynamicLoaderConfig = DynamicLoaderConfig> {
|
|
313
314
|
get: () => Promise<LoaderOutput<Config>>;
|
|
314
|
-
/**
|
|
315
|
+
/** invalidate & re-compute dynamic sources immediately */
|
|
315
316
|
revalidate: (source?: Config['source']) => Promise<void>;
|
|
316
317
|
/** remove computed cache of dynamic sources */
|
|
317
318
|
invalidate: (source?: Config['source']) => void;
|
|
318
319
|
get $inferPage(): Config['page'];
|
|
319
320
|
get $inferMeta(): Config['meta'];
|
|
320
321
|
}
|
|
321
|
-
|
|
322
|
+
/** content loader API for static & dynamic content sources, with in-memory cache. */
|
|
323
|
+
declare function dynamicLoader<I extends SourceUnion | Record<string, SourceUnion>, I18n extends I18nConfig | undefined = undefined>(input: I, options: LoaderOptions<NoInfer<GenerateStorage<I>>, I18n>): DynamicLoader<{
|
|
322
324
|
i18n: I18n;
|
|
323
325
|
meta: NoInfer<GenerateMeta<I>>;
|
|
324
326
|
page: NoInfer<GeneratePage<I>>;
|
|
@@ -331,13 +333,54 @@ type SourceUnion<Config extends SourceConfig = SourceConfig> = StaticSource<Conf
|
|
|
331
333
|
* @deprecated use `StaticSource<Config>` instead
|
|
332
334
|
*/
|
|
333
335
|
type Source<Config extends SourceConfig = SourceConfig> = StaticSource<Config>;
|
|
334
|
-
interface
|
|
336
|
+
interface GenericSourceOptions {
|
|
337
|
+
/** the base directory for generated virtual files */
|
|
338
|
+
baseDir?: string;
|
|
339
|
+
/**
|
|
340
|
+
* when the source is attached to a new static loader, before loader output is accessible.
|
|
341
|
+
*
|
|
342
|
+
* can be called multiple times when attached to a dynamic loader.
|
|
343
|
+
**/
|
|
344
|
+
configureStatic?: (opts: {
|
|
345
|
+
loader: LoaderOutput;
|
|
346
|
+
source?: string;
|
|
347
|
+
}) => void;
|
|
348
|
+
/**
|
|
349
|
+
* when the source is attached to a dynamic loader.
|
|
350
|
+
*
|
|
351
|
+
* called at most once for each source object.
|
|
352
|
+
**/
|
|
353
|
+
configureDynamic?: (opts: {
|
|
354
|
+
loader: DynamicLoader;
|
|
355
|
+
source?: string;
|
|
356
|
+
}) => void;
|
|
357
|
+
}
|
|
358
|
+
interface StaticSource<Config extends SourceConfig = SourceConfig> extends GenericSourceOptions {
|
|
335
359
|
files: VirtualFile<Config>[];
|
|
336
360
|
}
|
|
337
|
-
|
|
361
|
+
/** one dynamic source object can only be used by one dynamic loader */
|
|
362
|
+
type DynamicSource<Config extends SourceConfig = SourceConfig> = GenericSourceOptions & {
|
|
363
|
+
/**
|
|
364
|
+
* - `memory`: the dynamic loader's in-memory cache handles caching.
|
|
365
|
+
* - `custom`: the source handles caching itself. When the newer result of `files()` is (shallowly) different from the previous result, the source is considered revalidated, and all associated properties will be re-computed.
|
|
366
|
+
*
|
|
367
|
+
* @default 'memory'
|
|
368
|
+
**/
|
|
369
|
+
cache?: 'memory' | 'custom';
|
|
338
370
|
files: () => Awaitable<VirtualFile<Config>[]>;
|
|
339
|
-
|
|
340
|
-
|
|
371
|
+
/** @deprecated use `configureDynamic` instead */
|
|
372
|
+
configure?: (loader: DynamicLoader, opts: {
|
|
373
|
+
source?: string;
|
|
374
|
+
}) => void;
|
|
375
|
+
/** when the source is invalidated */
|
|
376
|
+
invalidate?: () => void;
|
|
377
|
+
} & ({
|
|
378
|
+
cache?: 'memory';
|
|
379
|
+
/** enable time-based revalidation, the previous result will be stale after the specified duration (ms) */
|
|
380
|
+
staleTime?: number;
|
|
381
|
+
} | {
|
|
382
|
+
cache: 'custom';
|
|
383
|
+
});
|
|
341
384
|
type SourceConfig = {
|
|
342
385
|
pageData: PageData;
|
|
343
386
|
metaData: MetaData;
|
|
@@ -394,13 +437,6 @@ declare function multiple<T extends Record<string, StaticSource>>(sources: T): T
|
|
|
394
437
|
type: k;
|
|
395
438
|
};
|
|
396
439
|
}> : never; } : never;
|
|
397
|
-
declare function source<Page extends PageData, Meta extends MetaData>(config: {
|
|
398
|
-
pages: VirtualPage<Page>[];
|
|
399
|
-
metas: VirtualMeta<Meta>[];
|
|
400
|
-
}): StaticSource<{
|
|
401
|
-
pageData: Page;
|
|
402
|
-
metaData: Meta;
|
|
403
|
-
}>;
|
|
404
440
|
interface SourceUpdater<Config extends SourceConfig> {
|
|
405
441
|
files: <Page extends PageData, Meta extends MetaData>(fn: (files: VirtualFile<Config>[]) => (VirtualPage<Page> | VirtualMeta<Meta>)[]) => SourceUpdater<{
|
|
406
442
|
pageData: Page;
|
|
@@ -417,7 +453,7 @@ interface SourceUpdater<Config extends SourceConfig> {
|
|
|
417
453
|
build: () => StaticSource<Config>;
|
|
418
454
|
}
|
|
419
455
|
/**
|
|
420
|
-
* update a source object in-place.
|
|
456
|
+
* update a **static** source object in-place.
|
|
421
457
|
*/
|
|
422
458
|
declare function update<Config extends SourceConfig>(source: StaticSource<Config>): SourceUpdater<Config>;
|
|
423
459
|
declare namespace path_d_exports {
|
|
@@ -474,4 +510,4 @@ declare function llms<C extends LoaderConfig = LoaderConfig>(loader: LoaderOutpu
|
|
|
474
510
|
indexNode(node: Node, lang?: string): string;
|
|
475
511
|
};
|
|
476
512
|
//#endregion
|
|
477
|
-
export {
|
|
513
|
+
export { SlugsPluginOptions as A, ContentStoragePageFile as B, Meta as C, loader as D, createGetUrl as E, PageTreeBuilderContext as F, PageTreeOptions as I, PageTreeTransformer as L, slugsFromData as M, slugsPlugin as N, types_d_exports as O, PageTreeBuilder as P, ContentStorage as R, LoaderPluginOption as S, ResolvedLoaderConfig as T, FileSystem as V, InferPageType as _, MetaData as a, LoaderOutput as b, SourceUnion as c, multiple as d, update as f, InferMetaType as g, dynamicLoader as h, DynamicSource as i, getSlugs as j, SlugFn as k, StaticSource as l, DynamicLoaderConfig as m, llms as n, PageData as o, DynamicLoader as p, path_d_exports as r, Source as s, LLMsConfig as t, VirtualFile as u, LoaderConfig as v, Page as w, LoaderPlugin as x, LoaderOptions as y, ContentStorageMetaFile as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { remarkHeading } from "./remark-heading.js";
|
|
2
2
|
import { generateCodeBlockTabs, parseCodeBlockAttributes } from "./codeblock-utils.js";
|
|
3
3
|
import { remarkGfm } from "./remark-gfm.js";
|
|
4
|
-
import { r as transformerTab } from "../rehype-code.core-
|
|
4
|
+
import { r as transformerTab } from "../rehype-code.core-BUwNuchP.js";
|
|
5
5
|
import { transformerIcon } from "./transformer-icon.js";
|
|
6
6
|
import { rehypeCode, rehypeCodeDefaultOptions } from "./rehype-code.js";
|
|
7
7
|
import { remarkImage } from "./remark-image.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as rehypeCodeDefaultOptions, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-
|
|
1
|
+
import { n as rehypeCodeDefaultOptions, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-BUwNuchP.js";
|
|
2
2
|
import { transformerIcon } from "./transformer-icon.js";
|
|
3
3
|
export { createRehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultShikiFactory, wasmShikiFactory } from "../highlight/shiki/full.js";
|
|
2
|
-
import { n as rehypeCodeDefaultOptions$1, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-
|
|
2
|
+
import { n as rehypeCodeDefaultOptions$1, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-BUwNuchP.js";
|
|
3
3
|
import { transformerIcon } from "./transformer-icon.js";
|
|
4
4
|
//#region src/mdx-plugins/rehype-code.ts
|
|
5
5
|
const rehypeCodeDefaultOptions = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as flattenNodeHast } from "./utils-Yx0IL9eW.js";
|
|
2
|
-
import { n as defaultThemes, r as getRequiredThemes } from "./utils-
|
|
2
|
+
import { n as defaultThemes, r as getRequiredThemes } from "./utils-Cgs-6U-z.js";
|
|
3
3
|
import { parseCodeBlockAttributes } from "./mdx-plugins/codeblock-utils.js";
|
|
4
4
|
import { transformerIcon } from "./mdx-plugins/transformer-icon.js";
|
|
5
5
|
import { visit } from "unist-util-visit";
|
|
@@ -43,13 +43,9 @@ function algoliaClient(options) {
|
|
|
43
43
|
filters: tag ? `tag:${tag}` : void 0
|
|
44
44
|
}] });
|
|
45
45
|
const highlighter = createContentHighlighter(query);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
content: highlighter.highlightMarkdown(hit.content)
|
|
50
|
-
};
|
|
51
|
-
return [];
|
|
52
|
-
});
|
|
46
|
+
const results = groupResults(result.results[0].hits);
|
|
47
|
+
for (const item of results) item.content = highlighter.highlightMarkdown(item.content);
|
|
48
|
+
return results;
|
|
53
49
|
}
|
|
54
50
|
};
|
|
55
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as join, t as BASE_PATH } from "../../url-BVHvi3_K.js";
|
|
2
|
-
import { n as searchSimple, t as searchAdvanced } from "../../advanced-
|
|
2
|
+
import { n as searchSimple, t as searchAdvanced } from "../../advanced-Ct13khZr.js";
|
|
3
3
|
import { create, load } from "zbsearch";
|
|
4
4
|
//#region src/search/client/orama-static.ts
|
|
5
5
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as Awaitable } from "../types-D89QoQR-.js";
|
|
2
2
|
import { n as I18nConfig } from "../index-DydiXvgS.js";
|
|
3
3
|
import "../index-BM36H-xw.js";
|
|
4
|
-
import { m as SharedIndex, n as SearchAPI, t as QueryOptions } from "../server-
|
|
5
|
-
import {
|
|
4
|
+
import { m as SharedIndex, n as SearchAPI, t as QueryOptions } from "../server-DRvCKdc_.js";
|
|
5
|
+
import { b as LoaderOutput, v as LoaderConfig } from "../index-DQWu2opy2.js";
|
|
6
6
|
import { DocumentData, DocumentOptions } from "flexsearch";
|
|
7
7
|
//#region src/search/server/build-doc.d.ts
|
|
8
8
|
interface SharedDocument {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as SortedResult } from "../index-BM36H-xw.js";
|
|
2
|
-
import { n as SearchAPI } from "../server-
|
|
2
|
+
import { n as SearchAPI } from "../server-DRvCKdc_.js";
|
|
3
3
|
import Mixedbread from "@mixedbread/sdk";
|
|
4
4
|
import { StoreSearchResponse } from "@mixedbread/sdk/resources/stores";
|
|
5
5
|
//#region src/search/mixedbread.d.ts
|
package/dist/search/server.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AdvancedOptions, c as SimpleOptions, d as createSearchAPI, f as initAdvancedSearch, i as AdvancedIndex, l as createFromSource, n as SearchAPI, o as ExportedData, p as initSimpleSearch, r as SearchServer, s as Index, t as QueryOptions, u as createI18nSearchAPI } from "../server-
|
|
1
|
+
import { a as AdvancedOptions, c as SimpleOptions, d as createSearchAPI, f as initAdvancedSearch, i as AdvancedIndex, l as createFromSource, n as SearchAPI, o as ExportedData, p as initSimpleSearch, r as SearchServer, s as Index, t as QueryOptions, u as createI18nSearchAPI } from "../server-DRvCKdc_.js";
|
|
2
2
|
export { AdvancedIndex, AdvancedOptions, ExportedData, Index, QueryOptions, SearchAPI, SearchServer, SimpleOptions, createFromSource, createI18nSearchAPI, createSearchAPI, initAdvancedSearch, initSimpleSearch };
|
package/dist/search/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as defaultReadOptions, t as createEndpoint } from "../endpoint-MyoBU5IC.js";
|
|
2
2
|
import { n as buildBreadcrumbs, r as buildIndexDefault, t as buildDocuments } from "../build-doc-SC7P37WG.js";
|
|
3
|
-
import { n as searchSimple, t as searchAdvanced } from "../advanced-
|
|
4
|
-
import { create,
|
|
3
|
+
import { n as searchSimple, t as searchAdvanced } from "../advanced-Ct13khZr.js";
|
|
4
|
+
import { create, insertMultipleAsync, save } from "zbsearch";
|
|
5
5
|
//#region src/search/zbsearch/create-db.ts
|
|
6
6
|
const simpleSchema = {
|
|
7
7
|
url: "string",
|
|
@@ -36,7 +36,7 @@ async function createDB({ indexes, tokenizer, language = DefaultLanguage, search
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
const mapTo = buildDocuments(items);
|
|
39
|
-
await
|
|
39
|
+
await insertMultipleAsync(db, mapTo);
|
|
40
40
|
return db;
|
|
41
41
|
}
|
|
42
42
|
async function createDBSimple({ indexes, tokenizer, language = DefaultLanguage, search: _, localeFilter: __, ...rest }) {
|
|
@@ -51,7 +51,7 @@ async function createDBSimple({ indexes, tokenizer, language = DefaultLanguage,
|
|
|
51
51
|
tokenizer: resolvedTokenizer
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
await
|
|
54
|
+
await insertMultipleAsync(db, items.map((page) => ({
|
|
55
55
|
title: page.title,
|
|
56
56
|
description: page.description,
|
|
57
57
|
breadcrumbs: page.breadcrumbs,
|
|
@@ -207,8 +207,12 @@ function createFromSource(loader, options = {}) {
|
|
|
207
207
|
const l = typeof loader === "function" ? await loader() : loader;
|
|
208
208
|
let server = cache.get(l);
|
|
209
209
|
if (!server) {
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
const promise = initServer(l);
|
|
211
|
+
promise.catch(() => {
|
|
212
|
+
if (cache.get(l) === promise) cache.delete(l);
|
|
213
|
+
});
|
|
214
|
+
cache.set(l, promise);
|
|
215
|
+
server = promise;
|
|
212
216
|
}
|
|
213
217
|
return await server;
|
|
214
218
|
}
|
|
@@ -2,7 +2,7 @@ import { t as Awaitable } from "./types-D89QoQR-.js";
|
|
|
2
2
|
import { i as StructuredData } from "./remark-structure-CnHwvNZr.js";
|
|
3
3
|
import { n as I18nConfig } from "./index-DydiXvgS.js";
|
|
4
4
|
import { r as SortedResult } from "./index-BM36H-xw.js";
|
|
5
|
-
import {
|
|
5
|
+
import { b as LoaderOutput, v as LoaderConfig } from "./index-DQWu2opy2.js";
|
|
6
6
|
import { Language, RawData, SearchParams, TypedDocument, ZBSearch, create } from "zbsearch";
|
|
7
7
|
//#region src/search/zbsearch/create-db.d.ts
|
|
8
8
|
type SimpleDocument = TypedDocument<ZBSearch<typeof simpleSchema>>;
|
package/dist/source/dynamic.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as dynamicLoader, m as DynamicLoaderConfig, p as DynamicLoader } from "../index-DQWu2opy2.js";
|
|
2
2
|
export { DynamicLoader, DynamicLoaderConfig, dynamicLoader };
|
package/dist/source/dynamic.js
CHANGED
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { cache } from "react";
|
|
3
|
-
//#region src/source/dynamic.ts
|
|
4
|
-
function dynamicLoader(input, options) {
|
|
5
|
-
let loaderCacheKey;
|
|
6
|
-
let loaderCache;
|
|
7
|
-
const sourceCache = /* @__PURE__ */ new Map();
|
|
8
|
-
function configureSources() {
|
|
9
|
-
if (isStaticSource(input)) return;
|
|
10
|
-
if (isDynamicSource(input)) {
|
|
11
|
-
input.configure?.(dynamicLoader);
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
for (const v of Object.values(input)) if (isDynamicSource(v)) v.configure?.(dynamicLoader);
|
|
15
|
-
}
|
|
16
|
-
async function resolveSources(skipCache = false) {
|
|
17
|
-
if (isStaticSource(input) || isDynamicSource(input)) return resolveSource(input, skipCache);
|
|
18
|
-
const entries = await Promise.all(Object.entries(input).map(async ([k, v]) => [k, await resolveSource(v, skipCache)]));
|
|
19
|
-
return Object.fromEntries(entries);
|
|
20
|
-
}
|
|
21
|
-
function resolveSource(v, skipCache = false) {
|
|
22
|
-
if (isStaticSource(v)) return v;
|
|
23
|
-
let resolved = skipCache ? void 0 : sourceCache.get(v);
|
|
24
|
-
if (resolved) return resolved;
|
|
25
|
-
const files = v.files();
|
|
26
|
-
if ("then" in files) resolved = files.then((res) => ({ files: res }));
|
|
27
|
-
else resolved = { files };
|
|
28
|
-
sourceCache.set(v, resolved);
|
|
29
|
-
return resolved;
|
|
30
|
-
}
|
|
31
|
-
const dynamicLoader = {
|
|
32
|
-
get: cache(async () => {
|
|
33
|
-
const resolved = await resolveSources();
|
|
34
|
-
if (loaderCacheKey && isEqual(loaderCacheKey, resolved)) return loaderCache;
|
|
35
|
-
loaderCacheKey = resolved;
|
|
36
|
-
loaderCache = loader(resolved, options);
|
|
37
|
-
return loaderCache;
|
|
38
|
-
}),
|
|
39
|
-
$inferPage: void 0,
|
|
40
|
-
$inferMeta: void 0,
|
|
41
|
-
async revalidate(name) {
|
|
42
|
-
if (name === void 0) await resolveSources(true);
|
|
43
|
-
else if (!isStaticSource(input) && !isDynamicSource(input)) await resolveSource(input[name], true);
|
|
44
|
-
},
|
|
45
|
-
invalidate(name) {
|
|
46
|
-
if (name === void 0) sourceCache.clear();
|
|
47
|
-
else if (!isStaticSource(input) && !isDynamicSource(input)) {
|
|
48
|
-
const s = input[name];
|
|
49
|
-
if (isDynamicSource(s)) sourceCache.delete(s);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
configureSources();
|
|
54
|
-
return dynamicLoader;
|
|
55
|
-
}
|
|
56
|
-
function isEqual(a, b) {
|
|
57
|
-
if (isStaticSource(a) && isStaticSource(b)) return a === b;
|
|
58
|
-
if (!isStaticSource(a) && !isStaticSource(b)) {
|
|
59
|
-
const aKeys = Object.keys(a);
|
|
60
|
-
const bKeys = Object.keys(b);
|
|
61
|
-
return aKeys.length === bKeys.length && aKeys.every((k) => a[k] === b[k]);
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
1
|
+
import { t as dynamicLoader } from "../dynamic-Dgf8t2t2.js";
|
|
66
2
|
export { dynamicLoader };
|
package/dist/source/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
export { type ContentStorage, type ContentStorageMetaFile, type ContentStoragePageFile, type DynamicSource, FileSystem, InferMetaType, InferPageType, LLMsConfig, LoaderConfig, LoaderOptions, LoaderOutput, LoaderPlugin, LoaderPluginOption, Meta, type MetaData, Page, type PageData, type PageTreeBuilder, type PageTreeBuilderContext, type PageTreeOptions, type PageTreeTransformer, path_d_exports as PathUtils, ResolvedLoaderConfig, type Source, type SourceUnion, type StaticSource, type VirtualFile, type types_d_exports as _Internal, createGetUrl, getSlugs, llms, loader, multiple,
|
|
1
|
+
import { B as ContentStoragePageFile, C as Meta, D as loader, E as createGetUrl, F as PageTreeBuilderContext, I as PageTreeOptions, L as PageTreeTransformer, O as types_d_exports, P as PageTreeBuilder, R as ContentStorage, S as LoaderPluginOption, T as ResolvedLoaderConfig, V as FileSystem, _ as InferPageType, a as MetaData, b as LoaderOutput, c as SourceUnion, d as multiple, f as update, g as InferMetaType, h as dynamicLoader, i as DynamicSource, j as getSlugs, l as StaticSource, m as DynamicLoaderConfig, n as llms, o as PageData, p as DynamicLoader, r as path_d_exports, s as Source, t as LLMsConfig, u as VirtualFile, v as LoaderConfig, w as Page, x as LoaderPlugin, y as LoaderOptions, z as ContentStorageMetaFile } from "../index-DQWu2opy2.js";
|
|
2
|
+
export { type ContentStorage, type ContentStorageMetaFile, type ContentStoragePageFile, type DynamicLoader, type DynamicLoaderConfig, type DynamicSource, FileSystem, InferMetaType, InferPageType, LLMsConfig, LoaderConfig, LoaderOptions, LoaderOutput, LoaderPlugin, LoaderPluginOption, Meta, type MetaData, Page, type PageData, type PageTreeBuilder, type PageTreeBuilderContext, type PageTreeOptions, type PageTreeTransformer, path_d_exports as PathUtils, ResolvedLoaderConfig, type Source, type SourceUnion, type StaticSource, type VirtualFile, type types_d_exports as _Internal, createGetUrl, dynamicLoader, getSlugs, llms, loader, multiple, update };
|
package/dist/source/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as path_exports } from "../path-1H5VzYiT.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as update, i as multiple, n as createGetUrl, o as FileSystem, r as loader, t as dynamicLoader } from "../dynamic-Dgf8t2t2.js";
|
|
3
3
|
import { getSlugs } from "./plugins/slugs.js";
|
|
4
4
|
import { llms } from "./llms.js";
|
|
5
|
-
export { FileSystem, path_exports as PathUtils, createGetUrl, getSlugs, llms, loader, multiple,
|
|
5
|
+
export { FileSystem, path_exports as PathUtils, createGetUrl, dynamicLoader, getSlugs, llms, loader, multiple, update };
|
package/dist/source/llms.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as llms, t as LLMsConfig } from "../index-
|
|
1
|
+
import { n as llms, t as LLMsConfig } from "../index-DQWu2opy2.js";
|
|
2
2
|
export { LLMsConfig, llms };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as SlugsPluginOptions, M as slugsFromData, N as slugsPlugin, j as getSlugs, k as SlugFn } from "../../index-DQWu2opy2.js";
|
|
2
2
|
export { SlugFn, SlugsPluginOptions, getSlugs, slugsFromData, slugsPlugin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as Separator$1, n as Item$1, t as Folder$1 } from "../../definitions-D8-KI7Uy.js";
|
|
2
|
-
import {
|
|
2
|
+
import { x as LoaderPlugin } from "../../index-DQWu2opy2.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
//#region src/source/plugins/status-badges.d.ts
|
|
5
5
|
interface Item extends Item$1 {
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
//#region src/highlight/utils.ts
|
|
2
2
|
async function loadMissingTheme(highlighter, themes) {
|
|
3
3
|
const bundled = highlighter.getBundledThemes();
|
|
4
|
+
const loaded = highlighter.getLoadedThemes();
|
|
4
5
|
const missingThemes = themes.filter((theme) => {
|
|
5
|
-
if (typeof theme === "string"
|
|
6
|
-
|
|
7
|
-
highlighter.getTheme(theme);
|
|
8
|
-
return false;
|
|
9
|
-
} catch {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
6
|
+
if (typeof theme === "string") return theme in bundled && !loaded.includes(theme);
|
|
7
|
+
return theme.name === void 0 || !loaded.includes(theme.name);
|
|
12
8
|
});
|
|
13
9
|
if (missingThemes.length > 0) await highlighter.loadTheme(...missingThemes);
|
|
14
10
|
}
|
|
15
11
|
async function loadMissingLanguage(highlighter, langs) {
|
|
16
12
|
const bundled = highlighter.getBundledLanguages();
|
|
13
|
+
const loaded = highlighter.getLoadedLanguages();
|
|
17
14
|
const missingLangs = langs.filter((lang) => {
|
|
18
|
-
if (typeof lang === "string"
|
|
19
|
-
|
|
20
|
-
highlighter.getLanguage(lang);
|
|
21
|
-
return false;
|
|
22
|
-
} catch {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
15
|
+
if (typeof lang === "string") return lang in bundled && !loaded.includes(lang);
|
|
16
|
+
return !loaded.includes(lang.name);
|
|
25
17
|
});
|
|
26
18
|
if (missingLangs.length > 0) await highlighter.loadLanguage(...missingLangs);
|
|
27
19
|
}
|