fumadocs-core 16.18.2 → 16.18.3
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/{algolia-B36wJl6E.d.ts → algolia-DsNJZd4P.d.ts} +2 -2
- package/dist/{build-index-CqctTvug.js → build-index-8ryBfL45.js} +1 -1
- package/dist/{client-LE_6Q0xR.d.ts → client-Bv_2P4D3.d.ts} +3 -3
- package/dist/content/mdx/preset-bundler.d.ts +2 -2
- package/dist/content/mdx/preset-runtime.d.ts +2 -2
- package/dist/{dynamic-BKMu5hc8.js → dynamic-CENrXFis.js} +182 -23
- package/dist/dynamic-link.js +1 -1
- package/dist/framework/plugin.d.ts +2 -2
- package/dist/highlight/client.js +1 -1
- package/dist/highlight/index.js +1 -1
- package/dist/highlight/shiki/full.d.ts +1 -1
- package/dist/highlight/shiki/index.d.ts +1 -1
- package/dist/highlight/shiki/react.d.ts +2 -2
- package/dist/i18n/middleware.js +2088 -3439
- package/dist/{index-DWVer6sb.d.ts → index-BOhS1UKT.d.ts} +110 -13
- package/dist/{index-B0Bzrmfa.d.ts → index-e-8QoCiA.d.ts} +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mdx-plugins/index.d.ts +4 -4
- package/dist/mdx-plugins/index.js +6 -5
- package/dist/mdx-plugins/rehype-code.core.d.ts +1 -1
- package/dist/mdx-plugins/rehype-code.core.js +1 -1
- package/dist/mdx-plugins/rehype-code.d.ts +2 -2
- package/dist/mdx-plugins/rehype-code.js +1 -1
- package/dist/mdx-plugins/remark-code-tab.js +1 -1
- package/dist/mdx-plugins/remark-include.js +2 -2
- package/dist/mdx-plugins/remark-llms.js +1 -1
- package/dist/mdx-plugins/remark-npm.js +1 -1
- package/dist/mdx-plugins/remark-show.d.ts +2 -0
- package/dist/mdx-plugins/remark-show.js +162 -0
- package/dist/mdx-plugins/remark-steps.js +1 -1
- package/dist/mdx-plugins/remark-structure.js +1 -1
- package/dist/mdx-plugins/stringifier.js +6 -0
- package/dist/{meilisearch-CsyDr1xA.d.ts → meilisearch-DzjbVbAn.d.ts} +2 -2
- package/dist/{mixedbread-CyM4na_-.d.ts → mixedbread-CMi5F-zO.d.ts} +2 -2
- package/dist/negotiation/index.js +279 -290
- package/dist/{path-CH9Umap3.js → path-B8old5-F.js} +1 -1
- package/dist/{rehype-code-CPNaiqAY.d.ts → rehype-code-Czh_8L5z.d.ts} +1 -1
- package/dist/{rehype-code.core-D1aZ5yla.d.ts → rehype-code.core-BeCtKe7K.d.ts} +1 -1
- package/dist/{rehype-code.core-Dq2jmvan.js → rehype-code.core-Jt2VtK1A.js} +3 -3
- package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
- package/dist/search/algolia.d.ts +1 -1
- package/dist/search/algolia.js +1 -1
- package/dist/search/client/algolia.d.ts +1 -1
- package/dist/search/client/docs-search.d.ts +1 -1
- package/dist/search/client/fetch.d.ts +1 -1
- package/dist/search/client/fetch.js +1 -1
- package/dist/search/client/flexsearch-static.d.ts +1 -1
- package/dist/search/client/flexsearch-static.js +1 -1
- package/dist/search/client/meilisearch.d.ts +1 -1
- package/dist/search/client/mixedbread.d.ts +2 -2
- package/dist/search/client/orama-cloud-legacy.d.ts +1 -1
- package/dist/search/client/orama-cloud-legacy.js +1 -1
- package/dist/search/client/orama-cloud.d.ts +1 -1
- package/dist/search/client/orama-cloud.js +1 -1
- package/dist/search/client/orama-static.d.ts +1 -1
- package/dist/search/client/orama-static.js +2 -2
- package/dist/search/client.d.ts +1 -1
- package/dist/search/flexsearch.d.ts +2 -2
- package/dist/search/flexsearch.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/search/meilisearch.d.ts +1 -1
- package/dist/search/meilisearch.js +1 -1
- package/dist/search/mixedbread.d.ts +2 -2
- package/dist/search/orama-cloud-legacy.d.ts +1 -1
- package/dist/search/orama-cloud.d.ts +2 -3
- package/dist/search/orama-cloud.js +1 -1
- package/dist/search/server.d.ts +1 -1
- package/dist/search/server.js +2 -2
- package/dist/{server-BUYLz3H4.d.ts → server-MsDv36PV.d.ts} +3 -3
- package/dist/source/dynamic.d.ts +1 -1
- package/dist/source/dynamic.js +1 -1
- package/dist/source/index.d.ts +2 -2
- package/dist/source/index.js +3 -3
- 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/slugs.js +1 -1
- package/dist/source/plugins/status-badges.d.ts +1 -1
- package/dist/source/schema.d.ts +2 -0
- package/dist/source/schema.js +3 -0
- package/dist/utils/hast-to-jsx.js +22 -31
- package/package.json +21 -20
- package/dist/index-BFnMPJLk.d.ts +0 -17
- package/dist/rolldown-runtime-C-UrYobY.js +0 -13
|
@@ -1,319 +1,308 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
// ../../node_modules/.pnpm/path-to-regexp@9.0.0/node_modules/path-to-regexp/dist/index.js
|
|
2
|
+
const DEFAULT_DELIMITER = "/";
|
|
3
|
+
const NOOP_VALUE = (value) => value;
|
|
4
|
+
const ID_START = /^[$_\p{ID_Start}]$/u;
|
|
5
|
+
const ID_CONTINUE = /^[$\u200c\u200d\p{ID_Continue}]$/u;
|
|
6
|
+
/**
|
|
7
|
+
* Escape a regular expression string.
|
|
8
|
+
*/
|
|
9
|
+
function escape(str) {
|
|
10
|
+
return str.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ParseError is thrown when there is an error processing the path.
|
|
14
|
+
*/
|
|
15
|
+
var PathError = class extends TypeError {
|
|
16
|
+
originalPath;
|
|
17
|
+
constructor(message, originalPath) {
|
|
18
|
+
super(message + (originalPath ? `: ${originalPath}` : "") + "; visit https://git.new/pathToRegexpError for info");
|
|
19
|
+
this.originalPath = originalPath;
|
|
17
20
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
super(text);
|
|
37
|
-
this.originalPath = originalPath;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Parse a string for the raw tokens.
|
|
24
|
+
*/
|
|
25
|
+
function parse(str, options = {}) {
|
|
26
|
+
const { encodePath = NOOP_VALUE } = options;
|
|
27
|
+
const chars = [...str];
|
|
28
|
+
let index = 0;
|
|
29
|
+
function consumeUntil(end) {
|
|
30
|
+
const output = [];
|
|
31
|
+
let path = "";
|
|
32
|
+
function writePath() {
|
|
33
|
+
if (!path) return;
|
|
34
|
+
output.push({
|
|
35
|
+
type: "text",
|
|
36
|
+
value: encodePath(path)
|
|
37
|
+
});
|
|
38
|
+
path = "";
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function parse(str, options = {}) {
|
|
45
|
-
const { encodePath = NOOP_VALUE } = options;
|
|
46
|
-
const chars = [...str];
|
|
47
|
-
let index = 0;
|
|
48
|
-
function consumeUntil(end) {
|
|
49
|
-
const output = [];
|
|
50
|
-
let path = "";
|
|
51
|
-
function writePath() {
|
|
52
|
-
if (!path) return;
|
|
53
|
-
output.push({
|
|
54
|
-
type: "text",
|
|
55
|
-
value: encodePath(path)
|
|
56
|
-
});
|
|
57
|
-
path = "";
|
|
40
|
+
while (index < chars.length) {
|
|
41
|
+
const char = chars[index++];
|
|
42
|
+
if (char === end) {
|
|
43
|
+
writePath();
|
|
44
|
+
return output;
|
|
58
45
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let quoteStart = index;
|
|
78
|
-
while (index < chars.length) {
|
|
79
|
-
if (chars[++index] === "\"") {
|
|
80
|
-
index++;
|
|
81
|
-
quoteStart = 0;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
if (chars[index] === "\\") index++;
|
|
85
|
-
name += chars[index];
|
|
46
|
+
if (char === "\\") {
|
|
47
|
+
if (index === chars.length) throw new PathError(`Unexpected end after \\ at index ${index}`, str);
|
|
48
|
+
path += chars[index++];
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (char === ":" || char === "*") {
|
|
52
|
+
const type = char === ":" ? "param" : "wildcard";
|
|
53
|
+
let name = "";
|
|
54
|
+
if (ID_START.test(chars[index])) do
|
|
55
|
+
name += chars[index++];
|
|
56
|
+
while (ID_CONTINUE.test(chars[index]));
|
|
57
|
+
else if (chars[index] === "\"") {
|
|
58
|
+
let quoteStart = index;
|
|
59
|
+
while (index < chars.length) {
|
|
60
|
+
if (chars[++index] === "\"") {
|
|
61
|
+
index++;
|
|
62
|
+
quoteStart = 0;
|
|
63
|
+
break;
|
|
86
64
|
}
|
|
87
|
-
if (
|
|
65
|
+
if (chars[index] === "\\") index++;
|
|
66
|
+
name += chars[index];
|
|
88
67
|
}
|
|
89
|
-
if (
|
|
90
|
-
writePath();
|
|
91
|
-
output.push({
|
|
92
|
-
type,
|
|
93
|
-
name
|
|
94
|
-
});
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
if (value === "{") {
|
|
98
|
-
writePath();
|
|
99
|
-
output.push({
|
|
100
|
-
type: "group",
|
|
101
|
-
tokens: consumeUntil("}")
|
|
102
|
-
});
|
|
103
|
-
continue;
|
|
68
|
+
if (quoteStart) throw new PathError(`Unterminated quote at index ${quoteStart}`, str);
|
|
104
69
|
}
|
|
105
|
-
if (
|
|
106
|
-
|
|
70
|
+
if (!name) throw new PathError(`Missing parameter name at index ${index}`, str);
|
|
71
|
+
writePath();
|
|
72
|
+
output.push({
|
|
73
|
+
type,
|
|
74
|
+
name
|
|
75
|
+
});
|
|
76
|
+
continue;
|
|
107
77
|
}
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
78
|
+
if (char === "{") {
|
|
79
|
+
writePath();
|
|
80
|
+
output.push({
|
|
81
|
+
type: "group",
|
|
82
|
+
tokens: consumeUntil("}")
|
|
83
|
+
});
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if ("}()[]+?!".includes(char)) throw new PathError(`Unexpected ${char} at index ${index - 1}`, str);
|
|
87
|
+
path += char;
|
|
111
88
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* Compile a string to a template function for the path.
|
|
116
|
-
*/
|
|
117
|
-
function compile(path, options = {}) {
|
|
118
|
-
const { encode = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
|
|
119
|
-
const fn = tokensToFunction((typeof path === "object" ? path : parse(path, options)).tokens, delimiter, encode);
|
|
120
|
-
return function path(params = {}) {
|
|
121
|
-
const missing = [];
|
|
122
|
-
const path = fn(params, missing);
|
|
123
|
-
if (missing.length) throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
|
|
124
|
-
return path;
|
|
125
|
-
};
|
|
89
|
+
if (end) throw new PathError(`Unexpected end at index ${index}, expected ${end}`, str);
|
|
90
|
+
writePath();
|
|
91
|
+
return output;
|
|
126
92
|
}
|
|
127
|
-
|
|
128
|
-
|
|
93
|
+
return {
|
|
94
|
+
tokens: consumeUntil(""),
|
|
95
|
+
originalPath: str
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Compile a string to a template function for the path.
|
|
100
|
+
*/
|
|
101
|
+
function compile(path, options = {}) {
|
|
102
|
+
const { encode = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
|
|
103
|
+
const fn = tokensToFunction((typeof path === "object" ? path : parse(path, options)).tokens, delimiter, encode);
|
|
104
|
+
return function path(params = {}) {
|
|
105
|
+
const missing = [];
|
|
106
|
+
const path = fn(params, missing);
|
|
107
|
+
if (missing.length) throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
|
|
108
|
+
return path;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function tokensToFunction(tokens, delimiter, encode) {
|
|
112
|
+
const encoders = tokens.map((token) => tokenToFunction(token, delimiter, encode));
|
|
113
|
+
return (data, missing) => {
|
|
114
|
+
let result = "";
|
|
115
|
+
for (const encoder of encoders) result += encoder(data, missing);
|
|
116
|
+
return result;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Convert a single token into a path building function.
|
|
121
|
+
*/
|
|
122
|
+
function tokenToFunction(token, delimiter, encode) {
|
|
123
|
+
if (token.type === "text") return () => token.value;
|
|
124
|
+
if (token.type === "group") {
|
|
125
|
+
const fn = tokensToFunction(token.tokens, delimiter, encode);
|
|
129
126
|
return (data, missing) => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return
|
|
127
|
+
const len = missing.length;
|
|
128
|
+
const value = fn(data, missing);
|
|
129
|
+
if (missing.length === len) return value;
|
|
130
|
+
missing.length = len;
|
|
131
|
+
return "";
|
|
133
132
|
};
|
|
134
133
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const fn = tokensToFunction(token.tokens, delimiter, encode);
|
|
142
|
-
return (data, missing) => {
|
|
143
|
-
const len = missing.length;
|
|
144
|
-
const value = fn(data, missing);
|
|
145
|
-
if (missing.length === len) return value;
|
|
146
|
-
missing.length = len;
|
|
147
|
-
return "";
|
|
148
|
-
};
|
|
134
|
+
const encodeValue = encode || NOOP_VALUE;
|
|
135
|
+
if (token.type === "wildcard" && encode !== false) return (data, missing) => {
|
|
136
|
+
const value = data[token.name];
|
|
137
|
+
if (value == null) {
|
|
138
|
+
missing.push(token.name);
|
|
139
|
+
return "";
|
|
149
140
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (value
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
141
|
+
if (!Array.isArray(value) || value.length === 0) throw new TypeError(`Expected "${token.name}" to be a non-empty array`);
|
|
142
|
+
let result = "";
|
|
143
|
+
for (let i = 0; i < value.length; i++) {
|
|
144
|
+
if (typeof value[i] !== "string") throw new TypeError(`Expected "${token.name}/${i}" to be a string`);
|
|
145
|
+
if (i > 0) result += delimiter;
|
|
146
|
+
result += encodeValue(value[i]);
|
|
147
|
+
}
|
|
148
|
+
if (!result) throw new TypeError(`Expected "${token.name}" to be a non-empty array`);
|
|
149
|
+
return result;
|
|
150
|
+
};
|
|
151
|
+
return (data, missing) => {
|
|
152
|
+
const value = data[token.name];
|
|
153
|
+
if (value == null) {
|
|
154
|
+
missing.push(token.name);
|
|
155
|
+
return "";
|
|
156
|
+
}
|
|
157
|
+
if (typeof value !== "string" || value.length === 0) throw new TypeError(`Expected "${token.name}" to be a non-empty string`);
|
|
158
|
+
return encodeValue(value);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Transform a path into a match function.
|
|
163
|
+
*/
|
|
164
|
+
function match(path, options = {}) {
|
|
165
|
+
const { decode = decodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
|
|
166
|
+
const { regexp, keys } = pathToRegexp(path, options);
|
|
167
|
+
const decoders = keys.map((key) => {
|
|
168
|
+
if (decode === false) return NOOP_VALUE;
|
|
169
|
+
if (key.type === "param") return decode;
|
|
170
|
+
return (value) => value.split(delimiter).map(decode);
|
|
171
|
+
});
|
|
172
|
+
return function match(input) {
|
|
173
|
+
const m = regexp.exec(input);
|
|
174
|
+
if (!m) return false;
|
|
175
|
+
const path = m[0];
|
|
176
|
+
const params = Object.create(null);
|
|
177
|
+
for (let i = 1; i < m.length; i++) {
|
|
178
|
+
if (m[i] === void 0) continue;
|
|
179
|
+
const key = keys[i - 1];
|
|
180
|
+
const decoder = decoders[i - 1];
|
|
181
|
+
params[key.name] = decoder(m[i]);
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
path,
|
|
185
|
+
params
|
|
174
186
|
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Transform a path into a regular expression and capture keys.
|
|
191
|
+
*/
|
|
192
|
+
function pathToRegexp(path, options = {}) {
|
|
193
|
+
const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
|
|
194
|
+
const keys = [];
|
|
195
|
+
let source = "";
|
|
196
|
+
let combinations = 0;
|
|
197
|
+
function process(path) {
|
|
198
|
+
if (Array.isArray(path)) {
|
|
199
|
+
for (const p of path) process(p);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const data = typeof path === "object" ? path : parse(path, options);
|
|
203
|
+
flatten(data.tokens, 0, [], (tokens) => {
|
|
204
|
+
if (combinations >= 256) throw new PathError("Too many path combinations", data.originalPath);
|
|
205
|
+
if (combinations > 0) source += "|";
|
|
206
|
+
source += toRegExpSource(tokens, delimiter, keys, data.originalPath, trailing);
|
|
207
|
+
combinations++;
|
|
186
208
|
});
|
|
187
|
-
return function match(input) {
|
|
188
|
-
const m = regexp.exec(input);
|
|
189
|
-
if (!m) return false;
|
|
190
|
-
const path = m[0];
|
|
191
|
-
const params = Object.create(null);
|
|
192
|
-
for (let i = 1; i < m.length; i++) {
|
|
193
|
-
if (m[i] === void 0) continue;
|
|
194
|
-
const key = keys[i - 1];
|
|
195
|
-
const decoder = decoders[i - 1];
|
|
196
|
-
params[key.name] = decoder(m[i]);
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
path,
|
|
200
|
-
params
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
209
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
});
|
|
210
|
+
process(path);
|
|
211
|
+
let pattern = `^(?:${source})`;
|
|
212
|
+
pattern += end ? "$" : "(?=" + escape(delimiter) + "|$)";
|
|
213
|
+
return {
|
|
214
|
+
regexp: new RegExp(pattern, sensitive ? "" : "i"),
|
|
215
|
+
keys
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Generate a flat list of sequence tokens from the given tokens.
|
|
220
|
+
*/
|
|
221
|
+
function flatten(tokens, index, result, callback) {
|
|
222
|
+
while (index < tokens.length) {
|
|
223
|
+
const token = tokens[index++];
|
|
224
|
+
if (token.type === "group") {
|
|
225
|
+
const len = result.length;
|
|
226
|
+
flatten(token.tokens, 0, result, (seq) => flatten(tokens, index, seq, callback));
|
|
227
|
+
result.length = len;
|
|
228
|
+
continue;
|
|
224
229
|
}
|
|
225
|
-
|
|
226
|
-
let pattern = `^(?:${source})`;
|
|
227
|
-
if (trailing) pattern += "(?:" + escape(delimiter) + "$)?";
|
|
228
|
-
pattern += end ? "$" : "(?=" + escape(delimiter) + "|$)";
|
|
229
|
-
return {
|
|
230
|
-
regexp: new RegExp(pattern, sensitive ? "" : "i"),
|
|
231
|
-
keys
|
|
232
|
-
};
|
|
230
|
+
result.push(token);
|
|
233
231
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
232
|
+
callback(result);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Transform a flat sequence of tokens into a regular expression.
|
|
236
|
+
*/
|
|
237
|
+
function toRegExpSource(tokens, delimiter, keys, originalPath, trailing) {
|
|
238
|
+
let result = "";
|
|
239
|
+
let prefix = "";
|
|
240
|
+
let hasWildcardAhead = false;
|
|
241
|
+
let hasSegmentWildcard = false;
|
|
242
|
+
let wildcardBacktrack = "";
|
|
243
|
+
let index = 0;
|
|
244
|
+
function seekWildcard(index) {
|
|
245
|
+
while (index < tokens.length) if (tokens[index++].type === "wildcard") return true;
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
function textRemaining(index) {
|
|
249
|
+
let result = "";
|
|
238
250
|
while (index < tokens.length) {
|
|
239
251
|
const token = tokens[index++];
|
|
240
|
-
if (token.type
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
result.length = len;
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
result.push(token);
|
|
252
|
+
if (token.type !== "text") return result;
|
|
253
|
+
if (token.value.includes(delimiter)) break;
|
|
254
|
+
result += token.value;
|
|
247
255
|
}
|
|
248
|
-
callback(result);
|
|
249
256
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
let index = 0;
|
|
260
|
-
function hasInSegment(index, type) {
|
|
261
|
-
while (index < tokens.length) {
|
|
262
|
-
const token = tokens[index++];
|
|
263
|
-
if (token.type === type) return true;
|
|
264
|
-
if (token.type === "text") {
|
|
265
|
-
if (token.value.includes(delimiter)) break;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
function peekText(index) {
|
|
271
|
-
let result = "";
|
|
272
|
-
while (index < tokens.length) {
|
|
273
|
-
const token = tokens[index++];
|
|
274
|
-
if (token.type !== "text") break;
|
|
275
|
-
result += token.value;
|
|
276
|
-
}
|
|
277
|
-
return result;
|
|
257
|
+
while (index < tokens.length) {
|
|
258
|
+
const token = tokens[index++];
|
|
259
|
+
if (token.type === "text") {
|
|
260
|
+
const value = escape(token.value);
|
|
261
|
+
result += value;
|
|
262
|
+
wildcardBacktrack += value;
|
|
263
|
+
prefix += token.value;
|
|
264
|
+
if (token.value.includes(delimiter)) hasSegmentWildcard = false;
|
|
265
|
+
continue;
|
|
278
266
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
if (token.type === "param" || token.type === "wildcard") {
|
|
289
|
-
if (prevCaptureType && !backtrack) throw new PathError(`Missing text before "${token.name}" ${token.type}`, originalPath);
|
|
290
|
-
if (token.type === "param") {
|
|
291
|
-
result += hasSegmentCapture & 2 ? `(${negate(delimiter, backtrack)}+)` : hasInSegment(index, "wildcard") ? `(${negate(delimiter, peekText(index))}+)` : hasSegmentCapture & 1 ? `(${negate(delimiter, backtrack)}+|${escape(backtrack)})` : `(${negate(delimiter, "")}+)`;
|
|
292
|
-
hasSegmentCapture |= prevCaptureType = 1;
|
|
267
|
+
if (token.type === "param" || token.type === "wildcard") {
|
|
268
|
+
if (result && !prefix) throw new PathError(`Missing text before "${token.name}" ${token.type}`, originalPath);
|
|
269
|
+
keys.push(token);
|
|
270
|
+
if (token.type === "param") {
|
|
271
|
+
if (hasSegmentWildcard) {
|
|
272
|
+
const value = negate(delimiter, prefix);
|
|
273
|
+
result += `(${value}+?|${value}*${escape(prefix)})`;
|
|
293
274
|
} else {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
275
|
+
const text = textRemaining(index);
|
|
276
|
+
if (text) result += `(?=(${negate(delimiter, "")}+?)${escape(text)})(?:\\${keys.length})`;
|
|
277
|
+
else result += `(${negate(delimiter, "")}+)`;
|
|
297
278
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
279
|
+
} else {
|
|
280
|
+
if (hasWildcardAhead) result += `)${wildcardBacktrack}`;
|
|
281
|
+
hasWildcardAhead = seekWildcard(index);
|
|
282
|
+
result += hasWildcardAhead ? "(?=([^]+?)" : "([^]+)";
|
|
283
|
+
hasSegmentWildcard = true;
|
|
284
|
+
wildcardBacktrack = "";
|
|
301
285
|
}
|
|
302
|
-
|
|
286
|
+
wildcardBacktrack += `(?:\\${keys.length})`;
|
|
287
|
+
prefix = "";
|
|
288
|
+
continue;
|
|
303
289
|
}
|
|
304
|
-
|
|
290
|
+
throw new TypeError(`Unknown token type: ${token.type}`);
|
|
305
291
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
|
|
292
|
+
if (trailing && !prefix.endsWith(delimiter)) result += "(?:" + escape(delimiter) + "$)?";
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Block backtracking on previous text/delimiter.
|
|
297
|
+
*/
|
|
298
|
+
function negate(a, b) {
|
|
299
|
+
if (b.length > a.length) return negate(b, a);
|
|
300
|
+
if (a === b) b = "";
|
|
301
|
+
if (b.length > 1) return `(?:(?!${escape(a)}|${escape(b)})[^])`;
|
|
302
|
+
if (a.length > 1) return `(?:(?!${escape(a)})[^${escape(b)}])`;
|
|
303
|
+
return `[^${escape(a + b)}]`;
|
|
304
|
+
}
|
|
305
|
+
// src/negotiation/index.ts
|
|
317
306
|
/**
|
|
318
307
|
* Rewrite incoming path matching the `source` pattern into the `destination` pattern.
|
|
319
308
|
*
|
|
@@ -323,8 +312,8 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
323
312
|
* @param destination - the target pattern to convert into
|
|
324
313
|
*/
|
|
325
314
|
function rewritePath(source, destination) {
|
|
326
|
-
const matcher =
|
|
327
|
-
const compiler =
|
|
315
|
+
const matcher = match(source, { decode: false });
|
|
316
|
+
const compiler = compile(destination, { encode: false });
|
|
328
317
|
return { rewrite(pathname) {
|
|
329
318
|
const result = matcher(pathname);
|
|
330
319
|
if (!result) return false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as IconOptions } from "./transformer-icon-Bi4LROAz.js";
|
|
2
2
|
import { t as Awaitable } from "./types-Dvkw0Kd0.js";
|
|
3
3
|
import { i as Highlighter, t as HighlightCodeOptions } from "./index-BhAz6nyI.js";
|
|
4
|
-
import { n as ShikiFactory } from "./index-
|
|
4
|
+
import { n as ShikiFactory } from "./index-e-8QoCiA.js";
|
|
5
5
|
import { Element, Root } from "hast";
|
|
6
6
|
import { Processor, Transformer } from "unified";
|
|
7
7
|
import { BuiltinLanguage, BuiltinTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, HighlighterCore, LanguageInput, ShikiTransformer, TransformerOptions } from "shiki";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as flattenNodeHast, s as walk } from "./utils-DV8PBZiI.js";
|
|
2
|
-
import { a as defaultThemes, n as createShikiHighlighter } from "./shiki-DL5DIaX-.js";
|
|
3
|
-
import { parseCodeBlockAttributes } from "./mdx-plugins/codeblock-utils.js";
|
|
4
2
|
import { transformerIcon } from "./mdx-plugins/transformer-icon.js";
|
|
5
|
-
|
|
3
|
+
import { parseCodeBlockAttributes } from "./mdx-plugins/codeblock-utils.js";
|
|
4
|
+
import { a as defaultThemes, n as createShikiHighlighter } from "./shiki-DL5DIaX-.js";
|
|
5
|
+
// ../../node_modules/.pnpm/@shikijs+transformers@4.6.0/node_modules/@shikijs/transformers/dist/index.mjs
|
|
6
6
|
const RE_SPLIT_COMMENT = /(\s+\/\/)/;
|
|
7
7
|
const RE_V1_END_COMMENT_PREFIX = /(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/;
|
|
8
8
|
const RE_V3_END_COMMENT_PREFIX = /(?:\/\/|#|;{1,2}|%{1,2}|--)(\s*)$/;
|