fumadocs-core 16.7.12 → 16.7.13
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-B6xijHpk.js → advanced-Bv_qi9IC.js} +1 -1
- package/dist/{algolia-CV1p_BGs.d.ts → algolia-DphIPKrc.d.ts} +1 -1
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/{build-doc-CRrL6r30.js → build-doc-DKBeOVIN.js} +1 -1
- package/dist/{client-DwXJpdzf.d.ts → client-D3PZ2z2N.d.ts} +3 -3
- package/dist/content/mdx/preset-bundler.d.ts +7 -7
- package/dist/content/mdx/preset-bundler.js +1 -1
- package/dist/content/mdx/preset-runtime.d.ts +7 -7
- package/dist/content/mdx/preset-runtime.js +1 -1
- package/dist/content/toc.d.ts +1 -1
- package/dist/dist-BvsXWCqT.js +808 -0
- package/dist/fromFile-rjAsJGw3.js +845 -0
- 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/index.d.ts +1 -1
- package/dist/i18n/middleware.d.ts +1 -1
- package/dist/i18n/middleware.js +3763 -2
- package/dist/{index-DkqXqEn8.d.ts → index-9M3g3SDy.d.ts} +3 -3
- package/dist/{index-D-UKvVrz.d.ts → index-Bm0msojm.d.ts} +1 -1
- package/dist/{index-D2XxhP9t.d.ts → index-C4kyQCbj.d.ts} +1 -1
- package/dist/{index-Ca0YkTYK2.d.ts → index-CDOu1Gxx2.d.ts} +1 -1
- package/dist/mdx-plugins/codeblock-utils.d.ts +1 -1
- package/dist/mdx-plugins/index.d.ts +17 -17
- package/dist/mdx-plugins/index.js +2 -2
- 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/rehype-toc.d.ts +1 -1
- package/dist/mdx-plugins/remark-admonition.d.ts +1 -1
- package/dist/mdx-plugins/remark-code-tab.d.ts +1 -1
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +1 -1
- package/dist/mdx-plugins/remark-feedback-block.d.ts +1 -1
- package/dist/mdx-plugins/remark-gfm.d.ts +1 -1
- package/dist/mdx-plugins/remark-heading.d.ts +1 -1
- package/dist/mdx-plugins/remark-image.d.ts +1 -1
- package/dist/mdx-plugins/remark-image.js +2 -2
- package/dist/mdx-plugins/remark-llms.d.ts +1 -1
- package/dist/mdx-plugins/remark-llms.runtime.d.ts +1 -1
- package/dist/mdx-plugins/remark-mdx-files.d.ts +1 -1
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +1 -1
- package/dist/mdx-plugins/remark-npm.d.ts +1 -1
- package/dist/mdx-plugins/remark-npm.js +1 -64
- package/dist/mdx-plugins/remark-steps.d.ts +1 -1
- package/dist/mdx-plugins/remark-structure.d.ts +1 -1
- package/dist/mdx-plugins/stringifier.d.ts +1 -1
- package/dist/negotiation/index.js +1 -37
- package/dist/negotiation-CMIpYwJJ.js +1021 -0
- package/dist/page-tree/index.d.ts +2 -2
- package/dist/{rehype-code-CMrTh9Lu.d.ts → rehype-code-BceXtwzN.d.ts} +1 -1
- package/dist/{rehype-code.core-AAMsXdqJ.d.ts → rehype-code.core-DfJelVqH.d.ts} +2 -2
- package/dist/{remark-heading-95OQNNoH.d.ts → remark-heading-C3ZesmHL.d.ts} +1 -1
- package/dist/{remark-llms-Bjyq1jdk.d.ts → remark-llms-4bK9f_wN.d.ts} +1 -1
- package/dist/remark-npm-DIGXA7E3.js +593 -0
- package/dist/{remark-structure-c-gm2PCy.d.ts → remark-structure-DLKk-p9t.d.ts} +1 -1
- package/dist/search/algolia.d.ts +1 -1
- package/dist/search/client/algolia.d.ts +1 -1
- package/dist/search/client/fetch.d.ts +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/mixedbread.d.ts +1 -1
- package/dist/search/client/mixedbread.js +1 -1
- 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 +1 -1
- package/dist/search/client.d.ts +1 -1
- package/dist/search/flexsearch.d.ts +4 -4
- package/dist/search/flexsearch.js +3 -3
- package/dist/search/index.d.ts +1 -1
- package/dist/search/mixedbread.d.ts +2 -2
- package/dist/search/mixedbread.js +2 -2
- package/dist/search/orama-cloud-legacy.d.ts +1 -1
- package/dist/search/orama-cloud.d.ts +1 -1
- package/dist/search/server.d.ts +1 -1
- package/dist/search/server.js +3 -3
- package/dist/{server-B89IM_4v.d.ts → server-D74cMtck.d.ts} +5 -5
- package/dist/source/client/index.d.ts +1 -1
- package/dist/source/index.d.ts +1 -1
- package/dist/source/index.js +2 -2
- package/dist/source/plugins/lucide-icons.d.ts +1 -1
- package/dist/source/plugins/lucide-icons.js +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 +2 -2
- package/dist/toc.d.ts +1 -1
- package/dist/toc.js +12 -26
- package/package.json +87 -103
- /package/dist/{codeblock-utils-DuhKfwET.d.ts → codeblock-utils-BMoNeXUb.d.ts} +0 -0
- /package/dist/{definitions-j1YD3oZE.d.ts → definitions-DH0vdUJV.d.ts} +0 -0
- /package/dist/{endpoint-Bs6bqGYq.js → endpoint-BWgZs3LL.js} +0 -0
- /package/dist/{icon-CfEtMzdP.js → icon-DXrdIp2K.js} +0 -0
- /package/dist/{index-DAzunKMp.d.ts → index-B_5tvyCk.d.ts} +0 -0
- /package/dist/{index-CQ5TBOzH.d.ts → index-WhA-NTMB.d.ts} +0 -0
- /package/dist/{path-CL7hf0GY.js → path-ClKaiDuq.js} +0 -0
- /package/dist/{rehype-code.core-23F1yz08.js → rehype-code.core-B9asBGBz.js} +0 -0
- /package/dist/{rehype-toc-iWxg6ELI.d.ts → rehype-toc-Dk5ozAin.d.ts} +0 -0
- /package/dist/{remark-admonition-0gZM40ZU.d.ts → remark-admonition-D6mMI676.d.ts} +0 -0
- /package/dist/{remark-code-tab-Dk79zZwn.d.ts → remark-code-tab-Cl4XxpJ9.d.ts} +0 -0
- /package/dist/{remark-directive-admonition-CxFIkQ_i.d.ts → remark-directive-admonition-BJwUZuIt.d.ts} +0 -0
- /package/dist/{remark-feedback-block-CehhnqT0.d.ts → remark-feedback-block-PeBl_Fvl.d.ts} +0 -0
- /package/dist/{remark-gfm-DIHBRjLx.d.ts → remark-gfm-IilhXQUz.d.ts} +0 -0
- /package/dist/{remark-image-DQlJevNY.d.ts → remark-image-Co-rKW87.d.ts} +0 -0
- /package/dist/{remark-mdx-files-C50nFvnY.d.ts → remark-mdx-files-Ba1Yf3sk.d.ts} +0 -0
- /package/dist/{remark-mdx-mermaid-BkA2vurg.d.ts → remark-mdx-mermaid-DPDDbIZJ.d.ts} +0 -0
- /package/dist/{remark-npm-7SDuqMc6.d.ts → remark-npm-B7OPb7Ze.d.ts} +0 -0
- /package/dist/{remark-steps-DsnXM6Xj.d.ts → remark-steps-PxfBg8ws.d.ts} +0 -0
- /package/dist/{remove-markdown-Cte6pwYx.js → remove-markdown-CQ--9YPQ.js} +0 -0
- /package/dist/{remove-undefined-PK1FA5gc.js → remove-undefined-DLE4y6II.js} +0 -0
- /package/dist/{stringifier-l_KdmdPb.d.ts → stringifier-D6T4zhkn.d.ts} +0 -0
- /package/dist/{toc-CgnJPi4Q.d.ts → toc-DXlLlbv_.d.ts} +0 -0
- /package/dist/{types-Dr0HqbXP.d.ts → types-D8S_yMgI.d.ts} +0 -0
- /package/dist/{util-D2LMvKsn.d.ts → util-CZD_oO6N.d.ts} +0 -0
- /package/dist/{util-BnfE-P1F.js → util-D3lJGMcv.js} +0 -0
- /package/dist/{utils-D_KDPEof.js → utils-CEyx3kFf.js} +0 -0
|
@@ -0,0 +1,1021 @@
|
|
|
1
|
+
import { r as __toESM, t as __commonJSMin } from "./chunk-BoAXSpZd.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/negotiator@1.0.0/node_modules/negotiator/lib/charset.js
|
|
3
|
+
/**
|
|
4
|
+
* negotiator
|
|
5
|
+
* Copyright(c) 2012 Isaac Z. Schlueter
|
|
6
|
+
* Copyright(c) 2014 Federico Romero
|
|
7
|
+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
8
|
+
* MIT Licensed
|
|
9
|
+
*/
|
|
10
|
+
var require_charset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11
|
+
/**
|
|
12
|
+
* Module exports.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
module.exports = preferredCharsets;
|
|
16
|
+
module.exports.preferredCharsets = preferredCharsets;
|
|
17
|
+
/**
|
|
18
|
+
* Module variables.
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
var simpleCharsetRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
|
|
22
|
+
/**
|
|
23
|
+
* Parse the Accept-Charset header.
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
function parseAcceptCharset(accept) {
|
|
27
|
+
var accepts = accept.split(",");
|
|
28
|
+
for (var i = 0, j = 0; i < accepts.length; i++) {
|
|
29
|
+
var charset = parseCharset(accepts[i].trim(), i);
|
|
30
|
+
if (charset) accepts[j++] = charset;
|
|
31
|
+
}
|
|
32
|
+
accepts.length = j;
|
|
33
|
+
return accepts;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Parse a charset from the Accept-Charset header.
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
function parseCharset(str, i) {
|
|
40
|
+
var match = simpleCharsetRegExp.exec(str);
|
|
41
|
+
if (!match) return null;
|
|
42
|
+
var charset = match[1];
|
|
43
|
+
var q = 1;
|
|
44
|
+
if (match[2]) {
|
|
45
|
+
var params = match[2].split(";");
|
|
46
|
+
for (var j = 0; j < params.length; j++) {
|
|
47
|
+
var p = params[j].trim().split("=");
|
|
48
|
+
if (p[0] === "q") {
|
|
49
|
+
q = parseFloat(p[1]);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
charset,
|
|
56
|
+
q,
|
|
57
|
+
i
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the priority of a charset.
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
function getCharsetPriority(charset, accepted, index) {
|
|
65
|
+
var priority = {
|
|
66
|
+
o: -1,
|
|
67
|
+
q: 0,
|
|
68
|
+
s: 0
|
|
69
|
+
};
|
|
70
|
+
for (var i = 0; i < accepted.length; i++) {
|
|
71
|
+
var spec = specify(charset, accepted[i], index);
|
|
72
|
+
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) priority = spec;
|
|
73
|
+
}
|
|
74
|
+
return priority;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get the specificity of the charset.
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
function specify(charset, spec, index) {
|
|
81
|
+
var s = 0;
|
|
82
|
+
if (spec.charset.toLowerCase() === charset.toLowerCase()) s |= 1;
|
|
83
|
+
else if (spec.charset !== "*") return null;
|
|
84
|
+
return {
|
|
85
|
+
i: index,
|
|
86
|
+
o: spec.i,
|
|
87
|
+
q: spec.q,
|
|
88
|
+
s
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get the preferred charsets from an Accept-Charset header.
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
function preferredCharsets(accept, provided) {
|
|
96
|
+
var accepts = parseAcceptCharset(accept === void 0 ? "*" : accept || "");
|
|
97
|
+
if (!provided) return accepts.filter(isQuality).sort(compareSpecs).map(getFullCharset);
|
|
98
|
+
var priorities = provided.map(function getPriority(type, index) {
|
|
99
|
+
return getCharsetPriority(type, accepts, index);
|
|
100
|
+
});
|
|
101
|
+
return priorities.filter(isQuality).sort(compareSpecs).map(function getCharset(priority) {
|
|
102
|
+
return provided[priorities.indexOf(priority)];
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compare two specs.
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
function compareSpecs(a, b) {
|
|
110
|
+
return b.q - a.q || b.s - a.s || a.o - b.o || a.i - b.i || 0;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get full charset string.
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
function getFullCharset(spec) {
|
|
117
|
+
return spec.charset;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if a spec has any quality.
|
|
121
|
+
* @private
|
|
122
|
+
*/
|
|
123
|
+
function isQuality(spec) {
|
|
124
|
+
return spec.q > 0;
|
|
125
|
+
}
|
|
126
|
+
}));
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region ../../node_modules/.pnpm/negotiator@1.0.0/node_modules/negotiator/lib/encoding.js
|
|
129
|
+
/**
|
|
130
|
+
* negotiator
|
|
131
|
+
* Copyright(c) 2012 Isaac Z. Schlueter
|
|
132
|
+
* Copyright(c) 2014 Federico Romero
|
|
133
|
+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
134
|
+
* MIT Licensed
|
|
135
|
+
*/
|
|
136
|
+
var require_encoding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
137
|
+
/**
|
|
138
|
+
* Module exports.
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
module.exports = preferredEncodings;
|
|
142
|
+
module.exports.preferredEncodings = preferredEncodings;
|
|
143
|
+
/**
|
|
144
|
+
* Module variables.
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
var simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
|
|
148
|
+
/**
|
|
149
|
+
* Parse the Accept-Encoding header.
|
|
150
|
+
* @private
|
|
151
|
+
*/
|
|
152
|
+
function parseAcceptEncoding(accept) {
|
|
153
|
+
var accepts = accept.split(",");
|
|
154
|
+
var hasIdentity = false;
|
|
155
|
+
var minQuality = 1;
|
|
156
|
+
for (var i = 0, j = 0; i < accepts.length; i++) {
|
|
157
|
+
var encoding = parseEncoding(accepts[i].trim(), i);
|
|
158
|
+
if (encoding) {
|
|
159
|
+
accepts[j++] = encoding;
|
|
160
|
+
hasIdentity = hasIdentity || specify("identity", encoding);
|
|
161
|
+
minQuality = Math.min(minQuality, encoding.q || 1);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (!hasIdentity) accepts[j++] = {
|
|
165
|
+
encoding: "identity",
|
|
166
|
+
q: minQuality,
|
|
167
|
+
i
|
|
168
|
+
};
|
|
169
|
+
accepts.length = j;
|
|
170
|
+
return accepts;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Parse an encoding from the Accept-Encoding header.
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
176
|
+
function parseEncoding(str, i) {
|
|
177
|
+
var match = simpleEncodingRegExp.exec(str);
|
|
178
|
+
if (!match) return null;
|
|
179
|
+
var encoding = match[1];
|
|
180
|
+
var q = 1;
|
|
181
|
+
if (match[2]) {
|
|
182
|
+
var params = match[2].split(";");
|
|
183
|
+
for (var j = 0; j < params.length; j++) {
|
|
184
|
+
var p = params[j].trim().split("=");
|
|
185
|
+
if (p[0] === "q") {
|
|
186
|
+
q = parseFloat(p[1]);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
encoding,
|
|
193
|
+
q,
|
|
194
|
+
i
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get the priority of an encoding.
|
|
199
|
+
* @private
|
|
200
|
+
*/
|
|
201
|
+
function getEncodingPriority(encoding, accepted, index) {
|
|
202
|
+
var priority = {
|
|
203
|
+
encoding,
|
|
204
|
+
o: -1,
|
|
205
|
+
q: 0,
|
|
206
|
+
s: 0
|
|
207
|
+
};
|
|
208
|
+
for (var i = 0; i < accepted.length; i++) {
|
|
209
|
+
var spec = specify(encoding, accepted[i], index);
|
|
210
|
+
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) priority = spec;
|
|
211
|
+
}
|
|
212
|
+
return priority;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get the specificity of the encoding.
|
|
216
|
+
* @private
|
|
217
|
+
*/
|
|
218
|
+
function specify(encoding, spec, index) {
|
|
219
|
+
var s = 0;
|
|
220
|
+
if (spec.encoding.toLowerCase() === encoding.toLowerCase()) s |= 1;
|
|
221
|
+
else if (spec.encoding !== "*") return null;
|
|
222
|
+
return {
|
|
223
|
+
encoding,
|
|
224
|
+
i: index,
|
|
225
|
+
o: spec.i,
|
|
226
|
+
q: spec.q,
|
|
227
|
+
s
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get the preferred encodings from an Accept-Encoding header.
|
|
232
|
+
* @public
|
|
233
|
+
*/
|
|
234
|
+
function preferredEncodings(accept, provided, preferred) {
|
|
235
|
+
var accepts = parseAcceptEncoding(accept || "");
|
|
236
|
+
var comparator = preferred ? function comparator(a, b) {
|
|
237
|
+
if (a.q !== b.q) return b.q - a.q;
|
|
238
|
+
var aPreferred = preferred.indexOf(a.encoding);
|
|
239
|
+
var bPreferred = preferred.indexOf(b.encoding);
|
|
240
|
+
if (aPreferred === -1 && bPreferred === -1) return b.s - a.s || a.o - b.o || a.i - b.i;
|
|
241
|
+
if (aPreferred !== -1 && bPreferred !== -1) return aPreferred - bPreferred;
|
|
242
|
+
return aPreferred === -1 ? 1 : -1;
|
|
243
|
+
} : compareSpecs;
|
|
244
|
+
if (!provided) return accepts.filter(isQuality).sort(comparator).map(getFullEncoding);
|
|
245
|
+
var priorities = provided.map(function getPriority(type, index) {
|
|
246
|
+
return getEncodingPriority(type, accepts, index);
|
|
247
|
+
});
|
|
248
|
+
return priorities.filter(isQuality).sort(comparator).map(function getEncoding(priority) {
|
|
249
|
+
return provided[priorities.indexOf(priority)];
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Compare two specs.
|
|
254
|
+
* @private
|
|
255
|
+
*/
|
|
256
|
+
function compareSpecs(a, b) {
|
|
257
|
+
return b.q - a.q || b.s - a.s || a.o - b.o || a.i - b.i;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Get full encoding string.
|
|
261
|
+
* @private
|
|
262
|
+
*/
|
|
263
|
+
function getFullEncoding(spec) {
|
|
264
|
+
return spec.encoding;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Check if a spec has any quality.
|
|
268
|
+
* @private
|
|
269
|
+
*/
|
|
270
|
+
function isQuality(spec) {
|
|
271
|
+
return spec.q > 0;
|
|
272
|
+
}
|
|
273
|
+
}));
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region ../../node_modules/.pnpm/negotiator@1.0.0/node_modules/negotiator/lib/language.js
|
|
276
|
+
/**
|
|
277
|
+
* negotiator
|
|
278
|
+
* Copyright(c) 2012 Isaac Z. Schlueter
|
|
279
|
+
* Copyright(c) 2014 Federico Romero
|
|
280
|
+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
281
|
+
* MIT Licensed
|
|
282
|
+
*/
|
|
283
|
+
var require_language = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
284
|
+
/**
|
|
285
|
+
* Module exports.
|
|
286
|
+
* @public
|
|
287
|
+
*/
|
|
288
|
+
module.exports = preferredLanguages;
|
|
289
|
+
module.exports.preferredLanguages = preferredLanguages;
|
|
290
|
+
/**
|
|
291
|
+
* Module variables.
|
|
292
|
+
* @private
|
|
293
|
+
*/
|
|
294
|
+
var simpleLanguageRegExp = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
|
|
295
|
+
/**
|
|
296
|
+
* Parse the Accept-Language header.
|
|
297
|
+
* @private
|
|
298
|
+
*/
|
|
299
|
+
function parseAcceptLanguage(accept) {
|
|
300
|
+
var accepts = accept.split(",");
|
|
301
|
+
for (var i = 0, j = 0; i < accepts.length; i++) {
|
|
302
|
+
var language = parseLanguage(accepts[i].trim(), i);
|
|
303
|
+
if (language) accepts[j++] = language;
|
|
304
|
+
}
|
|
305
|
+
accepts.length = j;
|
|
306
|
+
return accepts;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Parse a language from the Accept-Language header.
|
|
310
|
+
* @private
|
|
311
|
+
*/
|
|
312
|
+
function parseLanguage(str, i) {
|
|
313
|
+
var match = simpleLanguageRegExp.exec(str);
|
|
314
|
+
if (!match) return null;
|
|
315
|
+
var prefix = match[1];
|
|
316
|
+
var suffix = match[2];
|
|
317
|
+
var full = prefix;
|
|
318
|
+
if (suffix) full += "-" + suffix;
|
|
319
|
+
var q = 1;
|
|
320
|
+
if (match[3]) {
|
|
321
|
+
var params = match[3].split(";");
|
|
322
|
+
for (var j = 0; j < params.length; j++) {
|
|
323
|
+
var p = params[j].split("=");
|
|
324
|
+
if (p[0] === "q") q = parseFloat(p[1]);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
prefix,
|
|
329
|
+
suffix,
|
|
330
|
+
q,
|
|
331
|
+
i,
|
|
332
|
+
full
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Get the priority of a language.
|
|
337
|
+
* @private
|
|
338
|
+
*/
|
|
339
|
+
function getLanguagePriority(language, accepted, index) {
|
|
340
|
+
var priority = {
|
|
341
|
+
o: -1,
|
|
342
|
+
q: 0,
|
|
343
|
+
s: 0
|
|
344
|
+
};
|
|
345
|
+
for (var i = 0; i < accepted.length; i++) {
|
|
346
|
+
var spec = specify(language, accepted[i], index);
|
|
347
|
+
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) priority = spec;
|
|
348
|
+
}
|
|
349
|
+
return priority;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Get the specificity of the language.
|
|
353
|
+
* @private
|
|
354
|
+
*/
|
|
355
|
+
function specify(language, spec, index) {
|
|
356
|
+
var p = parseLanguage(language);
|
|
357
|
+
if (!p) return null;
|
|
358
|
+
var s = 0;
|
|
359
|
+
if (spec.full.toLowerCase() === p.full.toLowerCase()) s |= 4;
|
|
360
|
+
else if (spec.prefix.toLowerCase() === p.full.toLowerCase()) s |= 2;
|
|
361
|
+
else if (spec.full.toLowerCase() === p.prefix.toLowerCase()) s |= 1;
|
|
362
|
+
else if (spec.full !== "*") return null;
|
|
363
|
+
return {
|
|
364
|
+
i: index,
|
|
365
|
+
o: spec.i,
|
|
366
|
+
q: spec.q,
|
|
367
|
+
s
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Get the preferred languages from an Accept-Language header.
|
|
372
|
+
* @public
|
|
373
|
+
*/
|
|
374
|
+
function preferredLanguages(accept, provided) {
|
|
375
|
+
var accepts = parseAcceptLanguage(accept === void 0 ? "*" : accept || "");
|
|
376
|
+
if (!provided) return accepts.filter(isQuality).sort(compareSpecs).map(getFullLanguage);
|
|
377
|
+
var priorities = provided.map(function getPriority(type, index) {
|
|
378
|
+
return getLanguagePriority(type, accepts, index);
|
|
379
|
+
});
|
|
380
|
+
return priorities.filter(isQuality).sort(compareSpecs).map(function getLanguage(priority) {
|
|
381
|
+
return provided[priorities.indexOf(priority)];
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Compare two specs.
|
|
386
|
+
* @private
|
|
387
|
+
*/
|
|
388
|
+
function compareSpecs(a, b) {
|
|
389
|
+
return b.q - a.q || b.s - a.s || a.o - b.o || a.i - b.i || 0;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Get full language string.
|
|
393
|
+
* @private
|
|
394
|
+
*/
|
|
395
|
+
function getFullLanguage(spec) {
|
|
396
|
+
return spec.full;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Check if a spec has any quality.
|
|
400
|
+
* @private
|
|
401
|
+
*/
|
|
402
|
+
function isQuality(spec) {
|
|
403
|
+
return spec.q > 0;
|
|
404
|
+
}
|
|
405
|
+
}));
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region ../../node_modules/.pnpm/negotiator@1.0.0/node_modules/negotiator/lib/mediaType.js
|
|
408
|
+
/**
|
|
409
|
+
* negotiator
|
|
410
|
+
* Copyright(c) 2012 Isaac Z. Schlueter
|
|
411
|
+
* Copyright(c) 2014 Federico Romero
|
|
412
|
+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
|
413
|
+
* MIT Licensed
|
|
414
|
+
*/
|
|
415
|
+
var require_mediaType = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
416
|
+
/**
|
|
417
|
+
* Module exports.
|
|
418
|
+
* @public
|
|
419
|
+
*/
|
|
420
|
+
module.exports = preferredMediaTypes;
|
|
421
|
+
module.exports.preferredMediaTypes = preferredMediaTypes;
|
|
422
|
+
/**
|
|
423
|
+
* Module variables.
|
|
424
|
+
* @private
|
|
425
|
+
*/
|
|
426
|
+
var simpleMediaTypeRegExp = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;
|
|
427
|
+
/**
|
|
428
|
+
* Parse the Accept header.
|
|
429
|
+
* @private
|
|
430
|
+
*/
|
|
431
|
+
function parseAccept(accept) {
|
|
432
|
+
var accepts = splitMediaTypes(accept);
|
|
433
|
+
for (var i = 0, j = 0; i < accepts.length; i++) {
|
|
434
|
+
var mediaType = parseMediaType(accepts[i].trim(), i);
|
|
435
|
+
if (mediaType) accepts[j++] = mediaType;
|
|
436
|
+
}
|
|
437
|
+
accepts.length = j;
|
|
438
|
+
return accepts;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Parse a media type from the Accept header.
|
|
442
|
+
* @private
|
|
443
|
+
*/
|
|
444
|
+
function parseMediaType(str, i) {
|
|
445
|
+
var match = simpleMediaTypeRegExp.exec(str);
|
|
446
|
+
if (!match) return null;
|
|
447
|
+
var params = Object.create(null);
|
|
448
|
+
var q = 1;
|
|
449
|
+
var subtype = match[2];
|
|
450
|
+
var type = match[1];
|
|
451
|
+
if (match[3]) {
|
|
452
|
+
var kvps = splitParameters(match[3]).map(splitKeyValuePair);
|
|
453
|
+
for (var j = 0; j < kvps.length; j++) {
|
|
454
|
+
var pair = kvps[j];
|
|
455
|
+
var key = pair[0].toLowerCase();
|
|
456
|
+
var val = pair[1];
|
|
457
|
+
var value = val && val[0] === "\"" && val[val.length - 1] === "\"" ? val.slice(1, -1) : val;
|
|
458
|
+
if (key === "q") {
|
|
459
|
+
q = parseFloat(value);
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
params[key] = value;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
type,
|
|
467
|
+
subtype,
|
|
468
|
+
params,
|
|
469
|
+
q,
|
|
470
|
+
i
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Get the priority of a media type.
|
|
475
|
+
* @private
|
|
476
|
+
*/
|
|
477
|
+
function getMediaTypePriority(type, accepted, index) {
|
|
478
|
+
var priority = {
|
|
479
|
+
o: -1,
|
|
480
|
+
q: 0,
|
|
481
|
+
s: 0
|
|
482
|
+
};
|
|
483
|
+
for (var i = 0; i < accepted.length; i++) {
|
|
484
|
+
var spec = specify(type, accepted[i], index);
|
|
485
|
+
if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) priority = spec;
|
|
486
|
+
}
|
|
487
|
+
return priority;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Get the specificity of the media type.
|
|
491
|
+
* @private
|
|
492
|
+
*/
|
|
493
|
+
function specify(type, spec, index) {
|
|
494
|
+
var p = parseMediaType(type);
|
|
495
|
+
var s = 0;
|
|
496
|
+
if (!p) return null;
|
|
497
|
+
if (spec.type.toLowerCase() == p.type.toLowerCase()) s |= 4;
|
|
498
|
+
else if (spec.type != "*") return null;
|
|
499
|
+
if (spec.subtype.toLowerCase() == p.subtype.toLowerCase()) s |= 2;
|
|
500
|
+
else if (spec.subtype != "*") return null;
|
|
501
|
+
var keys = Object.keys(spec.params);
|
|
502
|
+
if (keys.length > 0) if (keys.every(function(k) {
|
|
503
|
+
return spec.params[k] == "*" || (spec.params[k] || "").toLowerCase() == (p.params[k] || "").toLowerCase();
|
|
504
|
+
})) s |= 1;
|
|
505
|
+
else return null;
|
|
506
|
+
return {
|
|
507
|
+
i: index,
|
|
508
|
+
o: spec.i,
|
|
509
|
+
q: spec.q,
|
|
510
|
+
s
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Get the preferred media types from an Accept header.
|
|
515
|
+
* @public
|
|
516
|
+
*/
|
|
517
|
+
function preferredMediaTypes(accept, provided) {
|
|
518
|
+
var accepts = parseAccept(accept === void 0 ? "*/*" : accept || "");
|
|
519
|
+
if (!provided) return accepts.filter(isQuality).sort(compareSpecs).map(getFullType);
|
|
520
|
+
var priorities = provided.map(function getPriority(type, index) {
|
|
521
|
+
return getMediaTypePriority(type, accepts, index);
|
|
522
|
+
});
|
|
523
|
+
return priorities.filter(isQuality).sort(compareSpecs).map(function getType(priority) {
|
|
524
|
+
return provided[priorities.indexOf(priority)];
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Compare two specs.
|
|
529
|
+
* @private
|
|
530
|
+
*/
|
|
531
|
+
function compareSpecs(a, b) {
|
|
532
|
+
return b.q - a.q || b.s - a.s || a.o - b.o || a.i - b.i || 0;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Get full type string.
|
|
536
|
+
* @private
|
|
537
|
+
*/
|
|
538
|
+
function getFullType(spec) {
|
|
539
|
+
return spec.type + "/" + spec.subtype;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Check if a spec has any quality.
|
|
543
|
+
* @private
|
|
544
|
+
*/
|
|
545
|
+
function isQuality(spec) {
|
|
546
|
+
return spec.q > 0;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Count the number of quotes in a string.
|
|
550
|
+
* @private
|
|
551
|
+
*/
|
|
552
|
+
function quoteCount(string) {
|
|
553
|
+
var count = 0;
|
|
554
|
+
var index = 0;
|
|
555
|
+
while ((index = string.indexOf("\"", index)) !== -1) {
|
|
556
|
+
count++;
|
|
557
|
+
index++;
|
|
558
|
+
}
|
|
559
|
+
return count;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Split a key value pair.
|
|
563
|
+
* @private
|
|
564
|
+
*/
|
|
565
|
+
function splitKeyValuePair(str) {
|
|
566
|
+
var index = str.indexOf("=");
|
|
567
|
+
var key;
|
|
568
|
+
var val;
|
|
569
|
+
if (index === -1) key = str;
|
|
570
|
+
else {
|
|
571
|
+
key = str.slice(0, index);
|
|
572
|
+
val = str.slice(index + 1);
|
|
573
|
+
}
|
|
574
|
+
return [key, val];
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Split an Accept header into media types.
|
|
578
|
+
* @private
|
|
579
|
+
*/
|
|
580
|
+
function splitMediaTypes(accept) {
|
|
581
|
+
var accepts = accept.split(",");
|
|
582
|
+
for (var i = 1, j = 0; i < accepts.length; i++) if (quoteCount(accepts[j]) % 2 == 0) accepts[++j] = accepts[i];
|
|
583
|
+
else accepts[j] += "," + accepts[i];
|
|
584
|
+
accepts.length = j + 1;
|
|
585
|
+
return accepts;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Split a string of parameters.
|
|
589
|
+
* @private
|
|
590
|
+
*/
|
|
591
|
+
function splitParameters(str) {
|
|
592
|
+
var parameters = str.split(";");
|
|
593
|
+
for (var i = 1, j = 0; i < parameters.length; i++) if (quoteCount(parameters[j]) % 2 == 0) parameters[++j] = parameters[i];
|
|
594
|
+
else parameters[j] += ";" + parameters[i];
|
|
595
|
+
parameters.length = j + 1;
|
|
596
|
+
for (var i = 0; i < parameters.length; i++) parameters[i] = parameters[i].trim();
|
|
597
|
+
return parameters;
|
|
598
|
+
}
|
|
599
|
+
}));
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region ../../node_modules/.pnpm/negotiator@1.0.0/node_modules/negotiator/index.js
|
|
602
|
+
/*!
|
|
603
|
+
* negotiator
|
|
604
|
+
* Copyright(c) 2012 Federico Romero
|
|
605
|
+
* Copyright(c) 2012-2014 Isaac Z. Schlueter
|
|
606
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
607
|
+
* MIT Licensed
|
|
608
|
+
*/
|
|
609
|
+
var require_negotiator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
610
|
+
var preferredCharsets = require_charset();
|
|
611
|
+
var preferredEncodings = require_encoding();
|
|
612
|
+
var preferredLanguages = require_language();
|
|
613
|
+
var preferredMediaTypes = require_mediaType();
|
|
614
|
+
/**
|
|
615
|
+
* Module exports.
|
|
616
|
+
* @public
|
|
617
|
+
*/
|
|
618
|
+
module.exports = Negotiator;
|
|
619
|
+
module.exports.Negotiator = Negotiator;
|
|
620
|
+
/**
|
|
621
|
+
* Create a Negotiator instance from a request.
|
|
622
|
+
* @param {object} request
|
|
623
|
+
* @public
|
|
624
|
+
*/
|
|
625
|
+
function Negotiator(request) {
|
|
626
|
+
if (!(this instanceof Negotiator)) return new Negotiator(request);
|
|
627
|
+
this.request = request;
|
|
628
|
+
}
|
|
629
|
+
Negotiator.prototype.charset = function charset(available) {
|
|
630
|
+
var set = this.charsets(available);
|
|
631
|
+
return set && set[0];
|
|
632
|
+
};
|
|
633
|
+
Negotiator.prototype.charsets = function charsets(available) {
|
|
634
|
+
return preferredCharsets(this.request.headers["accept-charset"], available);
|
|
635
|
+
};
|
|
636
|
+
Negotiator.prototype.encoding = function encoding(available, opts) {
|
|
637
|
+
var set = this.encodings(available, opts);
|
|
638
|
+
return set && set[0];
|
|
639
|
+
};
|
|
640
|
+
Negotiator.prototype.encodings = function encodings(available, options) {
|
|
641
|
+
var opts = options || {};
|
|
642
|
+
return preferredEncodings(this.request.headers["accept-encoding"], available, opts.preferred);
|
|
643
|
+
};
|
|
644
|
+
Negotiator.prototype.language = function language(available) {
|
|
645
|
+
var set = this.languages(available);
|
|
646
|
+
return set && set[0];
|
|
647
|
+
};
|
|
648
|
+
Negotiator.prototype.languages = function languages(available) {
|
|
649
|
+
return preferredLanguages(this.request.headers["accept-language"], available);
|
|
650
|
+
};
|
|
651
|
+
Negotiator.prototype.mediaType = function mediaType(available) {
|
|
652
|
+
var set = this.mediaTypes(available);
|
|
653
|
+
return set && set[0];
|
|
654
|
+
};
|
|
655
|
+
Negotiator.prototype.mediaTypes = function mediaTypes(available) {
|
|
656
|
+
return preferredMediaTypes(this.request.headers.accept, available);
|
|
657
|
+
};
|
|
658
|
+
Negotiator.prototype.preferredCharset = Negotiator.prototype.charset;
|
|
659
|
+
Negotiator.prototype.preferredCharsets = Negotiator.prototype.charsets;
|
|
660
|
+
Negotiator.prototype.preferredEncoding = Negotiator.prototype.encoding;
|
|
661
|
+
Negotiator.prototype.preferredEncodings = Negotiator.prototype.encodings;
|
|
662
|
+
Negotiator.prototype.preferredLanguage = Negotiator.prototype.language;
|
|
663
|
+
Negotiator.prototype.preferredLanguages = Negotiator.prototype.languages;
|
|
664
|
+
Negotiator.prototype.preferredMediaType = Negotiator.prototype.mediaType;
|
|
665
|
+
Negotiator.prototype.preferredMediaTypes = Negotiator.prototype.mediaTypes;
|
|
666
|
+
}));
|
|
667
|
+
//#endregion
|
|
668
|
+
//#region ../../node_modules/.pnpm/path-to-regexp@8.4.2/node_modules/path-to-regexp/dist/index.js
|
|
669
|
+
var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
670
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
671
|
+
exports.PathError = exports.TokenData = void 0;
|
|
672
|
+
exports.compile = compile;
|
|
673
|
+
exports.match = match;
|
|
674
|
+
const DEFAULT_DELIMITER = "/";
|
|
675
|
+
const NOOP_VALUE = (value) => value;
|
|
676
|
+
const ID_START = /^[$_\p{ID_Start}]$/u;
|
|
677
|
+
const ID_CONTINUE = /^[$\u200c\u200d\p{ID_Continue}]$/u;
|
|
678
|
+
/**
|
|
679
|
+
* Escape a regular expression string.
|
|
680
|
+
*/
|
|
681
|
+
function escape(str) {
|
|
682
|
+
return str.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Tokenized path instance.
|
|
686
|
+
*/
|
|
687
|
+
var TokenData = class {
|
|
688
|
+
constructor(tokens, originalPath) {
|
|
689
|
+
this.tokens = tokens;
|
|
690
|
+
this.originalPath = originalPath;
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
exports.TokenData = TokenData;
|
|
694
|
+
/**
|
|
695
|
+
* ParseError is thrown when there is an error processing the path.
|
|
696
|
+
*/
|
|
697
|
+
var PathError = class extends TypeError {
|
|
698
|
+
constructor(message, originalPath) {
|
|
699
|
+
let text = message;
|
|
700
|
+
if (originalPath) text += `: ${originalPath}`;
|
|
701
|
+
text += `; visit https://git.new/pathToRegexpError for info`;
|
|
702
|
+
super(text);
|
|
703
|
+
this.originalPath = originalPath;
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
exports.PathError = PathError;
|
|
707
|
+
/**
|
|
708
|
+
* Parse a string for the raw tokens.
|
|
709
|
+
*/
|
|
710
|
+
function parse(str, options = {}) {
|
|
711
|
+
const { encodePath = NOOP_VALUE } = options;
|
|
712
|
+
const chars = [...str];
|
|
713
|
+
let index = 0;
|
|
714
|
+
function consumeUntil(end) {
|
|
715
|
+
const output = [];
|
|
716
|
+
let path = "";
|
|
717
|
+
function writePath() {
|
|
718
|
+
if (!path) return;
|
|
719
|
+
output.push({
|
|
720
|
+
type: "text",
|
|
721
|
+
value: encodePath(path)
|
|
722
|
+
});
|
|
723
|
+
path = "";
|
|
724
|
+
}
|
|
725
|
+
while (index < chars.length) {
|
|
726
|
+
const value = chars[index++];
|
|
727
|
+
if (value === end) {
|
|
728
|
+
writePath();
|
|
729
|
+
return output;
|
|
730
|
+
}
|
|
731
|
+
if (value === "\\") {
|
|
732
|
+
if (index === chars.length) throw new PathError(`Unexpected end after \\ at index ${index}`, str);
|
|
733
|
+
path += chars[index++];
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
if (value === ":" || value === "*") {
|
|
737
|
+
const type = value === ":" ? "param" : "wildcard";
|
|
738
|
+
let name = "";
|
|
739
|
+
if (ID_START.test(chars[index])) do
|
|
740
|
+
name += chars[index++];
|
|
741
|
+
while (ID_CONTINUE.test(chars[index]));
|
|
742
|
+
else if (chars[index] === "\"") {
|
|
743
|
+
let quoteStart = index;
|
|
744
|
+
while (index < chars.length) {
|
|
745
|
+
if (chars[++index] === "\"") {
|
|
746
|
+
index++;
|
|
747
|
+
quoteStart = 0;
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
if (chars[index] === "\\") index++;
|
|
751
|
+
name += chars[index];
|
|
752
|
+
}
|
|
753
|
+
if (quoteStart) throw new PathError(`Unterminated quote at index ${quoteStart}`, str);
|
|
754
|
+
}
|
|
755
|
+
if (!name) throw new PathError(`Missing parameter name at index ${index}`, str);
|
|
756
|
+
writePath();
|
|
757
|
+
output.push({
|
|
758
|
+
type,
|
|
759
|
+
name
|
|
760
|
+
});
|
|
761
|
+
continue;
|
|
762
|
+
}
|
|
763
|
+
if (value === "{") {
|
|
764
|
+
writePath();
|
|
765
|
+
output.push({
|
|
766
|
+
type: "group",
|
|
767
|
+
tokens: consumeUntil("}")
|
|
768
|
+
});
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
if (value === "}" || value === "(" || value === ")" || value === "[" || value === "]" || value === "+" || value === "?" || value === "!") throw new PathError(`Unexpected ${value} at index ${index - 1}`, str);
|
|
772
|
+
path += value;
|
|
773
|
+
}
|
|
774
|
+
if (end) throw new PathError(`Unexpected end at index ${index}, expected ${end}`, str);
|
|
775
|
+
writePath();
|
|
776
|
+
return output;
|
|
777
|
+
}
|
|
778
|
+
return new TokenData(consumeUntil(""), str);
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Compile a string to a template function for the path.
|
|
782
|
+
*/
|
|
783
|
+
function compile(path, options = {}) {
|
|
784
|
+
const { encode = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
|
|
785
|
+
const fn = tokensToFunction((typeof path === "object" ? path : parse(path, options)).tokens, delimiter, encode);
|
|
786
|
+
return function path(params = {}) {
|
|
787
|
+
const missing = [];
|
|
788
|
+
const path = fn(params, missing);
|
|
789
|
+
if (missing.length) throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
|
|
790
|
+
return path;
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function tokensToFunction(tokens, delimiter, encode) {
|
|
794
|
+
const encoders = tokens.map((token) => tokenToFunction(token, delimiter, encode));
|
|
795
|
+
return (data, missing) => {
|
|
796
|
+
let result = "";
|
|
797
|
+
for (const encoder of encoders) result += encoder(data, missing);
|
|
798
|
+
return result;
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Convert a single token into a path building function.
|
|
803
|
+
*/
|
|
804
|
+
function tokenToFunction(token, delimiter, encode) {
|
|
805
|
+
if (token.type === "text") return () => token.value;
|
|
806
|
+
if (token.type === "group") {
|
|
807
|
+
const fn = tokensToFunction(token.tokens, delimiter, encode);
|
|
808
|
+
return (data, missing) => {
|
|
809
|
+
const len = missing.length;
|
|
810
|
+
const value = fn(data, missing);
|
|
811
|
+
if (missing.length === len) return value;
|
|
812
|
+
missing.length = len;
|
|
813
|
+
return "";
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
const encodeValue = encode || NOOP_VALUE;
|
|
817
|
+
if (token.type === "wildcard" && encode !== false) return (data, missing) => {
|
|
818
|
+
const value = data[token.name];
|
|
819
|
+
if (value == null) {
|
|
820
|
+
missing.push(token.name);
|
|
821
|
+
return "";
|
|
822
|
+
}
|
|
823
|
+
if (!Array.isArray(value) || value.length === 0) throw new TypeError(`Expected "${token.name}" to be a non-empty array`);
|
|
824
|
+
let result = "";
|
|
825
|
+
for (let i = 0; i < value.length; i++) {
|
|
826
|
+
if (typeof value[i] !== "string") throw new TypeError(`Expected "${token.name}/${i}" to be a string`);
|
|
827
|
+
if (i > 0) result += delimiter;
|
|
828
|
+
result += encodeValue(value[i]);
|
|
829
|
+
}
|
|
830
|
+
return result;
|
|
831
|
+
};
|
|
832
|
+
return (data, missing) => {
|
|
833
|
+
const value = data[token.name];
|
|
834
|
+
if (value == null) {
|
|
835
|
+
missing.push(token.name);
|
|
836
|
+
return "";
|
|
837
|
+
}
|
|
838
|
+
if (typeof value !== "string") throw new TypeError(`Expected "${token.name}" to be a string`);
|
|
839
|
+
return encodeValue(value);
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Transform a path into a match function.
|
|
844
|
+
*/
|
|
845
|
+
function match(path, options = {}) {
|
|
846
|
+
const { decode = decodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
|
|
847
|
+
const { regexp, keys } = pathToRegexp(path, options);
|
|
848
|
+
const decoders = keys.map((key) => {
|
|
849
|
+
if (decode === false) return NOOP_VALUE;
|
|
850
|
+
if (key.type === "param") return decode;
|
|
851
|
+
return (value) => value.split(delimiter).map(decode);
|
|
852
|
+
});
|
|
853
|
+
return function match(input) {
|
|
854
|
+
const m = regexp.exec(input);
|
|
855
|
+
if (!m) return false;
|
|
856
|
+
const path = m[0];
|
|
857
|
+
const params = Object.create(null);
|
|
858
|
+
for (let i = 1; i < m.length; i++) {
|
|
859
|
+
if (m[i] === void 0) continue;
|
|
860
|
+
const key = keys[i - 1];
|
|
861
|
+
const decoder = decoders[i - 1];
|
|
862
|
+
params[key.name] = decoder(m[i]);
|
|
863
|
+
}
|
|
864
|
+
return {
|
|
865
|
+
path,
|
|
866
|
+
params
|
|
867
|
+
};
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Transform a path into a regular expression and capture keys.
|
|
872
|
+
*/
|
|
873
|
+
function pathToRegexp(path, options = {}) {
|
|
874
|
+
const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
|
|
875
|
+
const keys = [];
|
|
876
|
+
let source = "";
|
|
877
|
+
let combinations = 0;
|
|
878
|
+
function process(path) {
|
|
879
|
+
if (Array.isArray(path)) {
|
|
880
|
+
for (const p of path) process(p);
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
const data = typeof path === "object" ? path : parse(path, options);
|
|
884
|
+
flatten(data.tokens, 0, [], (tokens) => {
|
|
885
|
+
if (combinations >= 256) throw new PathError("Too many path combinations", data.originalPath);
|
|
886
|
+
if (combinations > 0) source += "|";
|
|
887
|
+
source += toRegExpSource(tokens, delimiter, keys, data.originalPath);
|
|
888
|
+
combinations++;
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
process(path);
|
|
892
|
+
let pattern = `^(?:${source})`;
|
|
893
|
+
if (trailing) pattern += "(?:" + escape(delimiter) + "$)?";
|
|
894
|
+
pattern += end ? "$" : "(?=" + escape(delimiter) + "|$)";
|
|
895
|
+
return {
|
|
896
|
+
regexp: new RegExp(pattern, sensitive ? "" : "i"),
|
|
897
|
+
keys
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Generate a flat list of sequence tokens from the given tokens.
|
|
902
|
+
*/
|
|
903
|
+
function flatten(tokens, index, result, callback) {
|
|
904
|
+
while (index < tokens.length) {
|
|
905
|
+
const token = tokens[index++];
|
|
906
|
+
if (token.type === "group") {
|
|
907
|
+
const len = result.length;
|
|
908
|
+
flatten(token.tokens, 0, result, (seq) => flatten(tokens, index, seq, callback));
|
|
909
|
+
result.length = len;
|
|
910
|
+
continue;
|
|
911
|
+
}
|
|
912
|
+
result.push(token);
|
|
913
|
+
}
|
|
914
|
+
callback(result);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Transform a flat sequence of tokens into a regular expression.
|
|
918
|
+
*/
|
|
919
|
+
function toRegExpSource(tokens, delimiter, keys, originalPath) {
|
|
920
|
+
let result = "";
|
|
921
|
+
let backtrack = "";
|
|
922
|
+
let wildcardBacktrack = "";
|
|
923
|
+
let prevCaptureType = 0;
|
|
924
|
+
let hasSegmentCapture = 0;
|
|
925
|
+
let index = 0;
|
|
926
|
+
function hasInSegment(index, type) {
|
|
927
|
+
while (index < tokens.length) {
|
|
928
|
+
const token = tokens[index++];
|
|
929
|
+
if (token.type === type) return true;
|
|
930
|
+
if (token.type === "text") {
|
|
931
|
+
if (token.value.includes(delimiter)) break;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
function peekText(index) {
|
|
937
|
+
let result = "";
|
|
938
|
+
while (index < tokens.length) {
|
|
939
|
+
const token = tokens[index++];
|
|
940
|
+
if (token.type !== "text") break;
|
|
941
|
+
result += token.value;
|
|
942
|
+
}
|
|
943
|
+
return result;
|
|
944
|
+
}
|
|
945
|
+
while (index < tokens.length) {
|
|
946
|
+
const token = tokens[index++];
|
|
947
|
+
if (token.type === "text") {
|
|
948
|
+
result += escape(token.value);
|
|
949
|
+
backtrack += token.value;
|
|
950
|
+
if (prevCaptureType === 2) wildcardBacktrack += token.value;
|
|
951
|
+
if (token.value.includes(delimiter)) hasSegmentCapture = 0;
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
if (token.type === "param" || token.type === "wildcard") {
|
|
955
|
+
if (prevCaptureType && !backtrack) throw new PathError(`Missing text before "${token.name}" ${token.type}`, originalPath);
|
|
956
|
+
if (token.type === "param") {
|
|
957
|
+
result += hasSegmentCapture & 2 ? `(${negate(delimiter, backtrack)}+)` : hasInSegment(index, "wildcard") ? `(${negate(delimiter, peekText(index))}+)` : hasSegmentCapture & 1 ? `(${negate(delimiter, backtrack)}+|${escape(backtrack)})` : `(${negate(delimiter, "")}+)`;
|
|
958
|
+
hasSegmentCapture |= prevCaptureType = 1;
|
|
959
|
+
} else {
|
|
960
|
+
result += hasSegmentCapture & 2 ? `(${negate(backtrack, "")}+)` : wildcardBacktrack ? `(${negate(wildcardBacktrack, "")}+|${negate(delimiter, "")}+)` : `([^]+)`;
|
|
961
|
+
wildcardBacktrack = "";
|
|
962
|
+
hasSegmentCapture |= prevCaptureType = 2;
|
|
963
|
+
}
|
|
964
|
+
keys.push(token);
|
|
965
|
+
backtrack = "";
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
throw new TypeError(`Unknown token type: ${token.type}`);
|
|
969
|
+
}
|
|
970
|
+
return result;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Block backtracking on previous text/delimiter.
|
|
974
|
+
*/
|
|
975
|
+
function negate(a, b) {
|
|
976
|
+
if (b.length > a.length) return negate(b, a);
|
|
977
|
+
if (a === b) b = "";
|
|
978
|
+
if (b.length > 1) return `(?:(?!${escape(a)}|${escape(b)})[^])`;
|
|
979
|
+
if (a.length > 1) return `(?:(?!${escape(a)})[^${escape(b)}])`;
|
|
980
|
+
return `[^${escape(a + b)}]`;
|
|
981
|
+
}
|
|
982
|
+
}));
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region src/negotiation/index.ts
|
|
985
|
+
var import_negotiator = /* @__PURE__ */ __toESM(require_negotiator(), 1);
|
|
986
|
+
var import_dist = require_dist();
|
|
987
|
+
function getNegotiator(request) {
|
|
988
|
+
const headers = {};
|
|
989
|
+
request.headers.forEach((value, key) => {
|
|
990
|
+
headers[key] = value;
|
|
991
|
+
});
|
|
992
|
+
return new import_negotiator.default({ headers });
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Rewrite incoming path matching the `source` pattern into the `destination` pattern.
|
|
996
|
+
*
|
|
997
|
+
* See [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) for accepted pattern formats.
|
|
998
|
+
*
|
|
999
|
+
* @param source - the original pattern of incoming paths
|
|
1000
|
+
* @param destination - the target pattern to convert into
|
|
1001
|
+
*/
|
|
1002
|
+
function rewritePath(source, destination) {
|
|
1003
|
+
const matcher = (0, import_dist.match)(source, { decode: false });
|
|
1004
|
+
const compiler = (0, import_dist.compile)(destination, { encode: false });
|
|
1005
|
+
return { rewrite(pathname) {
|
|
1006
|
+
const result = matcher(pathname);
|
|
1007
|
+
if (!result) return false;
|
|
1008
|
+
return compiler(result.params);
|
|
1009
|
+
} };
|
|
1010
|
+
}
|
|
1011
|
+
function isMarkdownPreferred(request, options) {
|
|
1012
|
+
const { markdownMediaTypes = [
|
|
1013
|
+
"text/plain",
|
|
1014
|
+
"text/markdown",
|
|
1015
|
+
"text/x-markdown"
|
|
1016
|
+
] } = options ?? {};
|
|
1017
|
+
const mediaTypes = getNegotiator(request).mediaTypes();
|
|
1018
|
+
return markdownMediaTypes.some((type) => mediaTypes.includes(type));
|
|
1019
|
+
}
|
|
1020
|
+
//#endregion
|
|
1021
|
+
export { isMarkdownPreferred as n, rewritePath as r, getNegotiator as t };
|