fumadocs-core 16.15.1 → 16.15.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/i18n/middleware.js +65 -2
- package/dist/negotiation/index.d.ts +1 -3
- package/dist/negotiation/index.js +378 -2
- 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/{server-DRvCKdc_.d.ts → server-BoDPRfLi.d.ts} +1 -1
- package/dist/source/dynamic.d.ts +1 -1
- package/dist/source/index.d.ts +1 -1
- 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/package.json +8 -11
- package/dist/negotiation-DAsKgSvF.js +0 -1056
- /package/dist/{index-DQWu2opy2.d.ts → index-DQWu2opy.d.ts} +0 -0
package/dist/i18n/middleware.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { t as getNegotiator } from "../negotiation-DAsKgSvF.js";
|
|
2
1
|
import { NextResponse } from "next/server.js";
|
|
3
2
|
//#region ../../node_modules/.pnpm/@formatjs+fast-memoize@3.1.7/node_modules/@formatjs/fast-memoize/index.js
|
|
4
3
|
function memoize(fn, options) {
|
|
@@ -3738,6 +3737,70 @@ function match(requestedLocales, availableLocales, defaultLocale, opts) {
|
|
|
3738
3737
|
return ResolveLocale(availableLocales, CanonicalizeLocaleList(requestedLocales), { localeMatcher: opts?.algorithm || "best fit" }, [], {}, () => defaultLocale).locale;
|
|
3739
3738
|
}
|
|
3740
3739
|
//#endregion
|
|
3740
|
+
//#region src/utils/accept-language.ts
|
|
3741
|
+
function parseAcceptLanguage(header) {
|
|
3742
|
+
const specs = [];
|
|
3743
|
+
for (const section of header.split(",")) {
|
|
3744
|
+
const [rawTag, ...params] = section.split(";");
|
|
3745
|
+
const full = rawTag.trim().toLowerCase();
|
|
3746
|
+
if (full.length === 0) continue;
|
|
3747
|
+
let quality = 1;
|
|
3748
|
+
for (const param of params) {
|
|
3749
|
+
const separator = param.indexOf("=");
|
|
3750
|
+
if (separator === -1 || param.slice(0, separator).trim().toLowerCase() !== "q") continue;
|
|
3751
|
+
const parsed = Number.parseFloat(param.slice(separator + 1));
|
|
3752
|
+
if (!Number.isNaN(parsed)) quality = parsed;
|
|
3753
|
+
}
|
|
3754
|
+
const dash = full.indexOf("-");
|
|
3755
|
+
specs.push({
|
|
3756
|
+
prefix: dash === -1 ? full : full.slice(0, dash),
|
|
3757
|
+
full,
|
|
3758
|
+
quality,
|
|
3759
|
+
order: specs.length
|
|
3760
|
+
});
|
|
3761
|
+
}
|
|
3762
|
+
return specs;
|
|
3763
|
+
}
|
|
3764
|
+
function matchLanguage(language, specs) {
|
|
3765
|
+
const full = language.trim().toLowerCase();
|
|
3766
|
+
const dash = full.indexOf("-");
|
|
3767
|
+
const prefix = dash === -1 ? full : full.slice(0, dash);
|
|
3768
|
+
const best = {
|
|
3769
|
+
language,
|
|
3770
|
+
quality: 0,
|
|
3771
|
+
specificity: 0,
|
|
3772
|
+
order: -1
|
|
3773
|
+
};
|
|
3774
|
+
for (const spec of specs) {
|
|
3775
|
+
let specificity;
|
|
3776
|
+
if (spec.full === full) specificity = 4;
|
|
3777
|
+
else if (spec.prefix === full) specificity = 2;
|
|
3778
|
+
else if (spec.full === prefix) specificity = 1;
|
|
3779
|
+
else if (spec.full === "*") specificity = 0;
|
|
3780
|
+
else continue;
|
|
3781
|
+
if ((specificity - best.specificity || spec.quality - best.quality || spec.order - best.order) > 0) {
|
|
3782
|
+
best.quality = spec.quality;
|
|
3783
|
+
best.specificity = specificity;
|
|
3784
|
+
best.order = spec.order;
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
if (best.quality > 0) return best;
|
|
3788
|
+
}
|
|
3789
|
+
/**
|
|
3790
|
+
* Filter `available` down to the languages the `Accept-Language` header accepts, ordered by
|
|
3791
|
+
* client preference. A missing (`null`) header accepts everything.
|
|
3792
|
+
*/
|
|
3793
|
+
function negotiateLanguages(header, available) {
|
|
3794
|
+
const specs = parseAcceptLanguage(header ?? "*");
|
|
3795
|
+
const matches = [];
|
|
3796
|
+
for (const language of available) {
|
|
3797
|
+
const match = matchLanguage(language, specs);
|
|
3798
|
+
if (match) matches.push(match);
|
|
3799
|
+
}
|
|
3800
|
+
matches.sort((a, b) => b.quality - a.quality || b.specificity - a.specificity || a.order - b.order);
|
|
3801
|
+
return matches.map((match) => match.language);
|
|
3802
|
+
}
|
|
3803
|
+
//#endregion
|
|
3741
3804
|
//#region src/i18n/middleware.ts
|
|
3742
3805
|
const DefaultFormatter = {
|
|
3743
3806
|
get(url) {
|
|
@@ -3773,7 +3836,7 @@ function createI18nMiddleware({ languages, defaultLanguage, format = DefaultForm
|
|
|
3773
3836
|
if (pathLocale && !languages.includes(pathLocale)) pathLocale = void 0;
|
|
3774
3837
|
if (!pathLocale) {
|
|
3775
3838
|
if (hideLocale === "default-locale") return NextResponse.rewrite(formatter.add(url, defaultLanguage));
|
|
3776
|
-
const preferred = match(
|
|
3839
|
+
const preferred = match(negotiateLanguages(request.headers.get("accept-language"), languages), languages, defaultLanguage);
|
|
3777
3840
|
if (hideLocale === "always") {
|
|
3778
3841
|
const locale = request.cookies.get(cookieName)?.value ?? preferred;
|
|
3779
3842
|
return NextResponse.rewrite(formatter.add(url, locale));
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import Negotiator from "negotiator";
|
|
2
1
|
//#region src/negotiation/index.d.ts
|
|
3
|
-
declare function getNegotiator(request: Request): Negotiator;
|
|
4
2
|
/**
|
|
5
3
|
* Rewrite incoming path matching the `source` pattern into the `destination` pattern.
|
|
6
4
|
*
|
|
@@ -16,4 +14,4 @@ declare function isMarkdownPreferred(request: Request, options?: {
|
|
|
16
14
|
markdownMediaTypes?: string[];
|
|
17
15
|
}): boolean;
|
|
18
16
|
//#endregion
|
|
19
|
-
export {
|
|
17
|
+
export { isMarkdownPreferred, rewritePath };
|
|
@@ -1,2 +1,378 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { t as __commonJSMin } from "../rolldown-runtime-DC62tzP2.js";
|
|
2
|
+
//#endregion
|
|
3
|
+
//#region src/negotiation/index.ts
|
|
4
|
+
var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PathError = exports.TokenData = void 0;
|
|
7
|
+
exports.compile = compile;
|
|
8
|
+
exports.match = match;
|
|
9
|
+
const DEFAULT_DELIMITER = "/";
|
|
10
|
+
const NOOP_VALUE = (value) => value;
|
|
11
|
+
const ID_START = /^[$_\p{ID_Start}]$/u;
|
|
12
|
+
const ID_CONTINUE = /^[$\u200c\u200d\p{ID_Continue}]$/u;
|
|
13
|
+
/**
|
|
14
|
+
* Escape a regular expression string.
|
|
15
|
+
*/
|
|
16
|
+
function escape(str) {
|
|
17
|
+
return str.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tokenized path instance.
|
|
21
|
+
*/
|
|
22
|
+
var TokenData = class {
|
|
23
|
+
constructor(tokens, originalPath) {
|
|
24
|
+
this.tokens = tokens;
|
|
25
|
+
this.originalPath = originalPath;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.TokenData = TokenData;
|
|
29
|
+
/**
|
|
30
|
+
* ParseError is thrown when there is an error processing the path.
|
|
31
|
+
*/
|
|
32
|
+
var PathError = class extends TypeError {
|
|
33
|
+
constructor(message, originalPath) {
|
|
34
|
+
let text = message;
|
|
35
|
+
if (originalPath) text += `: ${originalPath}`;
|
|
36
|
+
text += `; visit https://git.new/pathToRegexpError for info`;
|
|
37
|
+
super(text);
|
|
38
|
+
this.originalPath = originalPath;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.PathError = PathError;
|
|
42
|
+
/**
|
|
43
|
+
* Parse a string for the raw tokens.
|
|
44
|
+
*/
|
|
45
|
+
function parse(str, options = {}) {
|
|
46
|
+
const { encodePath = NOOP_VALUE } = options;
|
|
47
|
+
const chars = [...str];
|
|
48
|
+
let index = 0;
|
|
49
|
+
function consumeUntil(end) {
|
|
50
|
+
const output = [];
|
|
51
|
+
let path = "";
|
|
52
|
+
function writePath() {
|
|
53
|
+
if (!path) return;
|
|
54
|
+
output.push({
|
|
55
|
+
type: "text",
|
|
56
|
+
value: encodePath(path)
|
|
57
|
+
});
|
|
58
|
+
path = "";
|
|
59
|
+
}
|
|
60
|
+
while (index < chars.length) {
|
|
61
|
+
const value = chars[index++];
|
|
62
|
+
if (value === end) {
|
|
63
|
+
writePath();
|
|
64
|
+
return output;
|
|
65
|
+
}
|
|
66
|
+
if (value === "\\") {
|
|
67
|
+
if (index === chars.length) throw new PathError(`Unexpected end after \\ at index ${index}`, str);
|
|
68
|
+
path += chars[index++];
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (value === ":" || value === "*") {
|
|
72
|
+
const type = value === ":" ? "param" : "wildcard";
|
|
73
|
+
let name = "";
|
|
74
|
+
if (ID_START.test(chars[index])) do
|
|
75
|
+
name += chars[index++];
|
|
76
|
+
while (ID_CONTINUE.test(chars[index]));
|
|
77
|
+
else if (chars[index] === "\"") {
|
|
78
|
+
let quoteStart = index;
|
|
79
|
+
while (index < chars.length) {
|
|
80
|
+
if (chars[++index] === "\"") {
|
|
81
|
+
index++;
|
|
82
|
+
quoteStart = 0;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (chars[index] === "\\") index++;
|
|
86
|
+
name += chars[index];
|
|
87
|
+
}
|
|
88
|
+
if (quoteStart) throw new PathError(`Unterminated quote at index ${quoteStart}`, str);
|
|
89
|
+
}
|
|
90
|
+
if (!name) throw new PathError(`Missing parameter name at index ${index}`, str);
|
|
91
|
+
writePath();
|
|
92
|
+
output.push({
|
|
93
|
+
type,
|
|
94
|
+
name
|
|
95
|
+
});
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (value === "{") {
|
|
99
|
+
writePath();
|
|
100
|
+
output.push({
|
|
101
|
+
type: "group",
|
|
102
|
+
tokens: consumeUntil("}")
|
|
103
|
+
});
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (value === "}" || value === "(" || value === ")" || value === "[" || value === "]" || value === "+" || value === "?" || value === "!") throw new PathError(`Unexpected ${value} at index ${index - 1}`, str);
|
|
107
|
+
path += value;
|
|
108
|
+
}
|
|
109
|
+
if (end) throw new PathError(`Unexpected end at index ${index}, expected ${end}`, str);
|
|
110
|
+
writePath();
|
|
111
|
+
return output;
|
|
112
|
+
}
|
|
113
|
+
return new TokenData(consumeUntil(""), str);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Compile a string to a template function for the path.
|
|
117
|
+
*/
|
|
118
|
+
function compile(path, options = {}) {
|
|
119
|
+
const { encode = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
|
|
120
|
+
const fn = tokensToFunction((typeof path === "object" ? path : parse(path, options)).tokens, delimiter, encode);
|
|
121
|
+
return function path(params = {}) {
|
|
122
|
+
const missing = [];
|
|
123
|
+
const path = fn(params, missing);
|
|
124
|
+
if (missing.length) throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
|
|
125
|
+
return path;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function tokensToFunction(tokens, delimiter, encode) {
|
|
129
|
+
const encoders = tokens.map((token) => tokenToFunction(token, delimiter, encode));
|
|
130
|
+
return (data, missing) => {
|
|
131
|
+
let result = "";
|
|
132
|
+
for (const encoder of encoders) result += encoder(data, missing);
|
|
133
|
+
return result;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Convert a single token into a path building function.
|
|
138
|
+
*/
|
|
139
|
+
function tokenToFunction(token, delimiter, encode) {
|
|
140
|
+
if (token.type === "text") return () => token.value;
|
|
141
|
+
if (token.type === "group") {
|
|
142
|
+
const fn = tokensToFunction(token.tokens, delimiter, encode);
|
|
143
|
+
return (data, missing) => {
|
|
144
|
+
const len = missing.length;
|
|
145
|
+
const value = fn(data, missing);
|
|
146
|
+
if (missing.length === len) return value;
|
|
147
|
+
missing.length = len;
|
|
148
|
+
return "";
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const encodeValue = encode || NOOP_VALUE;
|
|
152
|
+
if (token.type === "wildcard" && encode !== false) return (data, missing) => {
|
|
153
|
+
const value = data[token.name];
|
|
154
|
+
if (value == null) {
|
|
155
|
+
missing.push(token.name);
|
|
156
|
+
return "";
|
|
157
|
+
}
|
|
158
|
+
if (!Array.isArray(value) || value.length === 0) throw new TypeError(`Expected "${token.name}" to be a non-empty array`);
|
|
159
|
+
let result = "";
|
|
160
|
+
for (let i = 0; i < value.length; i++) {
|
|
161
|
+
if (typeof value[i] !== "string") throw new TypeError(`Expected "${token.name}/${i}" to be a string`);
|
|
162
|
+
if (i > 0) result += delimiter;
|
|
163
|
+
result += encodeValue(value[i]);
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
166
|
+
};
|
|
167
|
+
return (data, missing) => {
|
|
168
|
+
const value = data[token.name];
|
|
169
|
+
if (value == null) {
|
|
170
|
+
missing.push(token.name);
|
|
171
|
+
return "";
|
|
172
|
+
}
|
|
173
|
+
if (typeof value !== "string") throw new TypeError(`Expected "${token.name}" to be a string`);
|
|
174
|
+
return encodeValue(value);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Transform a path into a match function.
|
|
179
|
+
*/
|
|
180
|
+
function match(path, options = {}) {
|
|
181
|
+
const { decode = decodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
|
|
182
|
+
const { regexp, keys } = pathToRegexp(path, options);
|
|
183
|
+
const decoders = keys.map((key) => {
|
|
184
|
+
if (decode === false) return NOOP_VALUE;
|
|
185
|
+
if (key.type === "param") return decode;
|
|
186
|
+
return (value) => value.split(delimiter).map(decode);
|
|
187
|
+
});
|
|
188
|
+
return function match(input) {
|
|
189
|
+
const m = regexp.exec(input);
|
|
190
|
+
if (!m) return false;
|
|
191
|
+
const path = m[0];
|
|
192
|
+
const params = Object.create(null);
|
|
193
|
+
for (let i = 1; i < m.length; i++) {
|
|
194
|
+
if (m[i] === void 0) continue;
|
|
195
|
+
const key = keys[i - 1];
|
|
196
|
+
const decoder = decoders[i - 1];
|
|
197
|
+
params[key.name] = decoder(m[i]);
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
path,
|
|
201
|
+
params
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Transform a path into a regular expression and capture keys.
|
|
207
|
+
*/
|
|
208
|
+
function pathToRegexp(path, options = {}) {
|
|
209
|
+
const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
|
|
210
|
+
const keys = [];
|
|
211
|
+
let source = "";
|
|
212
|
+
let combinations = 0;
|
|
213
|
+
function process(path) {
|
|
214
|
+
if (Array.isArray(path)) {
|
|
215
|
+
for (const p of path) process(p);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const data = typeof path === "object" ? path : parse(path, options);
|
|
219
|
+
flatten(data.tokens, 0, [], (tokens) => {
|
|
220
|
+
if (combinations >= 256) throw new PathError("Too many path combinations", data.originalPath);
|
|
221
|
+
if (combinations > 0) source += "|";
|
|
222
|
+
source += toRegExpSource(tokens, delimiter, keys, data.originalPath);
|
|
223
|
+
combinations++;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
process(path);
|
|
227
|
+
let pattern = `^(?:${source})`;
|
|
228
|
+
if (trailing) pattern += "(?:" + escape(delimiter) + "$)?";
|
|
229
|
+
pattern += end ? "$" : "(?=" + escape(delimiter) + "|$)";
|
|
230
|
+
return {
|
|
231
|
+
regexp: new RegExp(pattern, sensitive ? "" : "i"),
|
|
232
|
+
keys
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Generate a flat list of sequence tokens from the given tokens.
|
|
237
|
+
*/
|
|
238
|
+
function flatten(tokens, index, result, callback) {
|
|
239
|
+
while (index < tokens.length) {
|
|
240
|
+
const token = tokens[index++];
|
|
241
|
+
if (token.type === "group") {
|
|
242
|
+
const len = result.length;
|
|
243
|
+
flatten(token.tokens, 0, result, (seq) => flatten(tokens, index, seq, callback));
|
|
244
|
+
result.length = len;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
result.push(token);
|
|
248
|
+
}
|
|
249
|
+
callback(result);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Transform a flat sequence of tokens into a regular expression.
|
|
253
|
+
*/
|
|
254
|
+
function toRegExpSource(tokens, delimiter, keys, originalPath) {
|
|
255
|
+
let result = "";
|
|
256
|
+
let backtrack = "";
|
|
257
|
+
let wildcardBacktrack = "";
|
|
258
|
+
let prevCaptureType = 0;
|
|
259
|
+
let hasSegmentCapture = 0;
|
|
260
|
+
let index = 0;
|
|
261
|
+
function hasInSegment(index, type) {
|
|
262
|
+
while (index < tokens.length) {
|
|
263
|
+
const token = tokens[index++];
|
|
264
|
+
if (token.type === type) return true;
|
|
265
|
+
if (token.type === "text") {
|
|
266
|
+
if (token.value.includes(delimiter)) break;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
function peekText(index) {
|
|
272
|
+
let result = "";
|
|
273
|
+
while (index < tokens.length) {
|
|
274
|
+
const token = tokens[index++];
|
|
275
|
+
if (token.type !== "text") break;
|
|
276
|
+
result += token.value;
|
|
277
|
+
}
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
while (index < tokens.length) {
|
|
281
|
+
const token = tokens[index++];
|
|
282
|
+
if (token.type === "text") {
|
|
283
|
+
result += escape(token.value);
|
|
284
|
+
backtrack += token.value;
|
|
285
|
+
if (prevCaptureType === 2) wildcardBacktrack += token.value;
|
|
286
|
+
if (token.value.includes(delimiter)) hasSegmentCapture = 0;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (token.type === "param" || token.type === "wildcard") {
|
|
290
|
+
if (prevCaptureType && !backtrack) throw new PathError(`Missing text before "${token.name}" ${token.type}`, originalPath);
|
|
291
|
+
if (token.type === "param") {
|
|
292
|
+
result += hasSegmentCapture & 2 ? `(${negate(delimiter, backtrack)}+)` : hasInSegment(index, "wildcard") ? `(${negate(delimiter, peekText(index))}+)` : hasSegmentCapture & 1 ? `(${negate(delimiter, backtrack)}+|${escape(backtrack)})` : `(${negate(delimiter, "")}+)`;
|
|
293
|
+
hasSegmentCapture |= prevCaptureType = 1;
|
|
294
|
+
} else {
|
|
295
|
+
result += hasSegmentCapture & 2 ? `(${negate(backtrack, "")}+)` : wildcardBacktrack ? `(${negate(wildcardBacktrack, "")}+|${negate(delimiter, "")}+)` : `([^]+)`;
|
|
296
|
+
wildcardBacktrack = "";
|
|
297
|
+
hasSegmentCapture |= prevCaptureType = 2;
|
|
298
|
+
}
|
|
299
|
+
keys.push(token);
|
|
300
|
+
backtrack = "";
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
throw new TypeError(`Unknown token type: ${token.type}`);
|
|
304
|
+
}
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Block backtracking on previous text/delimiter.
|
|
309
|
+
*/
|
|
310
|
+
function negate(a, b) {
|
|
311
|
+
if (b.length > a.length) return negate(b, a);
|
|
312
|
+
if (a === b) b = "";
|
|
313
|
+
if (b.length > 1) return `(?:(?!${escape(a)}|${escape(b)})[^])`;
|
|
314
|
+
if (a.length > 1) return `(?:(?!${escape(a)})[^${escape(b)}])`;
|
|
315
|
+
return `[^${escape(a + b)}]`;
|
|
316
|
+
}
|
|
317
|
+
})))();
|
|
318
|
+
/**
|
|
319
|
+
* Rewrite incoming path matching the `source` pattern into the `destination` pattern.
|
|
320
|
+
*
|
|
321
|
+
* See [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) for accepted pattern formats.
|
|
322
|
+
*
|
|
323
|
+
* @param source - the original pattern of incoming paths
|
|
324
|
+
* @param destination - the target pattern to convert into
|
|
325
|
+
*/
|
|
326
|
+
function rewritePath(source, destination) {
|
|
327
|
+
const matcher = (0, import_dist.match)(source, { decode: false });
|
|
328
|
+
const compiler = (0, import_dist.compile)(destination, { encode: false });
|
|
329
|
+
return { rewrite(pathname) {
|
|
330
|
+
const result = matcher(pathname);
|
|
331
|
+
if (!result) return false;
|
|
332
|
+
return compiler(result.params);
|
|
333
|
+
} };
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Parse an `Accept` header into its media types and quality values.
|
|
337
|
+
*
|
|
338
|
+
* Media types the client didn't rank explicitly default to `q=1`.
|
|
339
|
+
*/
|
|
340
|
+
function parseAccept(header) {
|
|
341
|
+
const entries = [];
|
|
342
|
+
for (const section of header.split(",")) {
|
|
343
|
+
const [rawMediaType, ...params] = section.split(";");
|
|
344
|
+
const mediaType = rawMediaType.trim().toLowerCase();
|
|
345
|
+
if (mediaType.length === 0) continue;
|
|
346
|
+
let quality = 1;
|
|
347
|
+
for (const param of params) {
|
|
348
|
+
const separator = param.indexOf("=");
|
|
349
|
+
if (separator === -1 || param.slice(0, separator).trim().toLowerCase() !== "q") continue;
|
|
350
|
+
const parsed = Number.parseFloat(param.slice(separator + 1));
|
|
351
|
+
if (!Number.isNaN(parsed)) quality = parsed;
|
|
352
|
+
}
|
|
353
|
+
entries.push({
|
|
354
|
+
mediaType,
|
|
355
|
+
quality
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
return entries;
|
|
359
|
+
}
|
|
360
|
+
function isMarkdownPreferred(request, options) {
|
|
361
|
+
const { markdownMediaTypes = [
|
|
362
|
+
"text/plain",
|
|
363
|
+
"text/markdown",
|
|
364
|
+
"text/x-markdown"
|
|
365
|
+
] } = options ?? {};
|
|
366
|
+
const accept = request.headers.get("accept");
|
|
367
|
+
if (!accept) return false;
|
|
368
|
+
let markdown = 0;
|
|
369
|
+
let html = 0;
|
|
370
|
+
for (const { mediaType, quality } of parseAccept(accept)) {
|
|
371
|
+
if (quality <= 0) continue;
|
|
372
|
+
if (markdownMediaTypes.includes(mediaType)) markdown = Math.max(markdown, quality);
|
|
373
|
+
else if (mediaType === "text/html" || mediaType === "text/*" || mediaType === "*/*") html = Math.max(html, quality);
|
|
374
|
+
}
|
|
375
|
+
return markdown > 0 && markdown >= html;
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
378
|
+
export { isMarkdownPreferred, rewritePath };
|
|
@@ -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 { b as LoaderOutput, v as LoaderConfig } from "../index-
|
|
4
|
+
import { m as SharedIndex, n as SearchAPI, t as QueryOptions } from "../server-BoDPRfLi.js";
|
|
5
|
+
import { b as LoaderOutput, v as LoaderConfig } from "../index-DQWu2opy.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-BoDPRfLi.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-BoDPRfLi.js";
|
|
2
2
|
export { AdvancedIndex, AdvancedOptions, ExportedData, Index, QueryOptions, SearchAPI, SearchServer, SimpleOptions, createFromSource, createI18nSearchAPI, createSearchAPI, initAdvancedSearch, initSimpleSearch };
|
|
@@ -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 { b as LoaderOutput, v as LoaderConfig } from "./index-
|
|
5
|
+
import { b as LoaderOutput, v as LoaderConfig } from "./index-DQWu2opy.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 { h as dynamicLoader, m as DynamicLoaderConfig, p as DynamicLoader } from "../index-
|
|
1
|
+
import { h as dynamicLoader, m as DynamicLoaderConfig, p as DynamicLoader } from "../index-DQWu2opy.js";
|
|
2
2
|
export { DynamicLoader, DynamicLoaderConfig, dynamicLoader };
|
package/dist/source/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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-DQWu2opy.js";
|
|
2
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/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-DQWu2opy.js";
|
|
2
2
|
export { LLMsConfig, llms };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as SlugsPluginOptions, M as slugsFromData, N as slugsPlugin, j as getSlugs, k as SlugFn } from "../../index-
|
|
1
|
+
import { A as SlugsPluginOptions, M as slugsFromData, N as slugsPlugin, j as getSlugs, k as SlugFn } from "../../index-DQWu2opy.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 { x as LoaderPlugin } from "../../index-
|
|
2
|
+
import { x as LoaderPlugin } from "../../index-DQWu2opy.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
//#region src/source/plugins/status-badges.d.ts
|
|
5
5
|
interface Item extends Item$1 {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "16.15.
|
|
3
|
+
"version": "16.15.2",
|
|
4
4
|
"description": "The React.js library for building a documentation website",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -130,19 +130,17 @@
|
|
|
130
130
|
"@orama/core": "^1.2.19",
|
|
131
131
|
"@oramacloud/client": "^2.1.4",
|
|
132
132
|
"@shikijs/transformers": "^4.4.3",
|
|
133
|
-
"@tanstack/react-router": "1.170.
|
|
133
|
+
"@tanstack/react-router": "1.170.32",
|
|
134
134
|
"@types/estree-jsx": "^1.0.5",
|
|
135
135
|
"@types/hast": "^3.0.5",
|
|
136
136
|
"@types/mdast": "^4.0.4",
|
|
137
|
-
"@types/
|
|
138
|
-
"@types/node": "26.2.0",
|
|
137
|
+
"@types/node": "26.3.0",
|
|
139
138
|
"@types/react": "^19.2.18",
|
|
140
|
-
"@types/react-dom": "^19.2.
|
|
141
|
-
"algoliasearch": "5.
|
|
139
|
+
"@types/react-dom": "^19.2.5",
|
|
140
|
+
"algoliasearch": "5.57.0",
|
|
142
141
|
"flexsearch": "^0.8.212",
|
|
143
|
-
"lucide-react": "^1.
|
|
144
|
-
"
|
|
145
|
-
"next": "16.3.0",
|
|
142
|
+
"lucide-react": "^1.34.0",
|
|
143
|
+
"next": "16.3.2",
|
|
146
144
|
"path-to-regexp": "^8.4.2",
|
|
147
145
|
"react-router": "^8.3.0",
|
|
148
146
|
"remark-directive": "^4.0.0",
|
|
@@ -150,7 +148,7 @@
|
|
|
150
148
|
"remove-markdown": "^0.6.4",
|
|
151
149
|
"tsdown": "0.22.14",
|
|
152
150
|
"typescript": "^6.0.3",
|
|
153
|
-
"waku": "1.0.0-
|
|
151
|
+
"waku": "1.0.0-rc.0",
|
|
154
152
|
"zod": "4.4.3",
|
|
155
153
|
"tsconfig": "0.0.0"
|
|
156
154
|
},
|
|
@@ -234,7 +232,6 @@
|
|
|
234
232
|
"@formatjs/fast-memoize": "3.1.7",
|
|
235
233
|
"@formatjs/intl-localematcher": "0.8.13",
|
|
236
234
|
"@shikijs/transformers": "4.4.3",
|
|
237
|
-
"negotiator": "1.0.0",
|
|
238
235
|
"path-to-regexp": "8.4.2",
|
|
239
236
|
"remove-markdown": "0.6.4"
|
|
240
237
|
},
|