@vezham/docs-core 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/advanced-Ct13khZr.js +79 -0
- package/dist/algolia-C0E5qQhM.d.ts +66 -0
- package/dist/breadcrumb.d.ts +46 -0
- package/dist/breadcrumb.js +59 -0
- package/dist/build-doc-4OvfjVN2.js +85 -0
- package/dist/client-kQ39Ub0-.d.ts +247 -0
- package/dist/codeblock-utils-CyP8qsYv.d.ts +29 -0
- package/dist/content/github.d.ts +41 -0
- package/dist/content/github.js +28 -0
- package/dist/content/md/frontmatter.d.ts +15 -0
- package/dist/content/md/frontmatter.js +24 -0
- package/dist/content/md.d.ts +24 -0
- package/dist/content/md.js +43 -0
- package/dist/content/mdx/preset-bundler.d.ts +29 -0
- package/dist/content/mdx/preset-bundler.js +39 -0
- package/dist/content/mdx/preset-runtime.d.ts +26 -0
- package/dist/content/mdx/preset-runtime.js +36 -0
- package/dist/content/toc.d.ts +19 -0
- package/dist/content/toc.js +14 -0
- package/dist/definitions-CFOhwE1k.d.ts +72 -0
- package/dist/dynamic-CTsodhTH.js +905 -0
- package/dist/dynamic-link.d.ts +12 -0
- package/dist/dynamic-link.js +31 -0
- package/dist/endpoint-MyoBU5IC.js +28 -0
- package/dist/framework/astro.d.ts +21 -0
- package/dist/framework/astro.js +52 -0
- package/dist/framework/index.d.ts +40 -0
- package/dist/framework/index.js +66 -0
- package/dist/framework/next.d.ts +10 -0
- package/dist/framework/next.js +19 -0
- package/dist/framework/react-router.d.ts +10 -0
- package/dist/framework/react-router.js +43 -0
- package/dist/framework/tanstack.d.ts +13 -0
- package/dist/framework/tanstack.js +54 -0
- package/dist/framework/waku.d.ts +10 -0
- package/dist/framework/waku.js +46 -0
- package/dist/highlight/client.d.ts +11 -0
- package/dist/highlight/client.js +15 -0
- package/dist/highlight/index.d.ts +31 -0
- package/dist/highlight/index.js +30 -0
- package/dist/highlight/shiki/full.d.ts +7 -0
- package/dist/highlight/shiki/full.js +23 -0
- package/dist/highlight/shiki/index.d.ts +2 -0
- package/dist/highlight/shiki/index.js +27 -0
- package/dist/highlight/shiki/react.d.ts +23 -0
- package/dist/highlight/shiki/react.js +50 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +63 -0
- package/dist/i18n/middleware.d.ts +34 -0
- package/dist/i18n/middleware.js +3855 -0
- package/dist/icon-BILaoXeg.js +17 -0
- package/dist/index-B-0R0VbS.d.ts +18 -0
- package/dist/index-BM36H-xw.d.ts +36 -0
- package/dist/index-BMEUQz-F.d.ts +21 -0
- package/dist/index-DAYtLGbx.d.ts +16 -0
- package/dist/index-DIwKCYOz.d.ts +513 -0
- package/dist/index-DydiXvgS.d.ts +90 -0
- package/dist/index-E8Qh_yQs.d.ts +49 -0
- package/dist/is-equal-LdLqRs0o.js +8 -0
- package/dist/link.d.ts +17 -0
- package/dist/link.js +23 -0
- package/dist/mdx-plugins/codeblock-utils.d.ts +2 -0
- package/dist/mdx-plugins/codeblock-utils.js +68 -0
- package/dist/mdx-plugins/index.d.ts +20 -0
- package/dist/mdx-plugins/index.js +18 -0
- package/dist/mdx-plugins/rehype-code.core.d.ts +3 -0
- package/dist/mdx-plugins/rehype-code.core.js +3 -0
- package/dist/mdx-plugins/rehype-code.d.ts +4 -0
- package/dist/mdx-plugins/rehype-code.js +24 -0
- package/dist/mdx-plugins/rehype-toc.d.ts +2 -0
- package/dist/mdx-plugins/rehype-toc.js +139 -0
- package/dist/mdx-plugins/remark-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-admonition.js +71 -0
- package/dist/mdx-plugins/remark-block-id.d.ts +37 -0
- package/dist/mdx-plugins/remark-block-id.js +41 -0
- package/dist/mdx-plugins/remark-code-tab.d.ts +2 -0
- package/dist/mdx-plugins/remark-code-tab.js +190 -0
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -0
- package/dist/mdx-plugins/remark-directive-admonition.js +57 -0
- package/dist/mdx-plugins/remark-feedback-block.d.ts +2 -0
- package/dist/mdx-plugins/remark-feedback-block.js +54 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +2 -0
- package/dist/mdx-plugins/remark-gfm.js +2 -0
- package/dist/mdx-plugins/remark-heading.d.ts +2 -0
- package/dist/mdx-plugins/remark-heading.js +46 -0
- package/dist/mdx-plugins/remark-image.d.ts +2 -0
- package/dist/mdx-plugins/remark-image.js +167 -0
- package/dist/mdx-plugins/remark-llms.d.ts +2 -0
- package/dist/mdx-plugins/remark-llms.js +338 -0
- package/dist/mdx-plugins/remark-llms.runtime.d.ts +10 -0
- package/dist/mdx-plugins/remark-llms.runtime.js +24 -0
- package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-files.js +182 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.js +28 -0
- package/dist/mdx-plugins/remark-npm.d.ts +2 -0
- package/dist/mdx-plugins/remark-npm.js +76 -0
- package/dist/mdx-plugins/remark-steps.d.ts +2 -0
- package/dist/mdx-plugins/remark-steps.js +93 -0
- package/dist/mdx-plugins/remark-structure.d.ts +2 -0
- package/dist/mdx-plugins/remark-structure.js +118 -0
- package/dist/mdx-plugins/stringifier.d.ts +2 -0
- package/dist/mdx-plugins/stringifier.js +91 -0
- package/dist/mdx-plugins/transformer-icon.d.ts +2 -0
- package/dist/mdx-plugins/transformer-icon.js +145 -0
- package/dist/negotiation/index.d.ts +17 -0
- package/dist/negotiation/index.js +378 -0
- package/dist/page-tree/index.d.ts +3 -0
- package/dist/page-tree/index.js +2 -0
- package/dist/path-1H5VzYiT.js +75 -0
- package/dist/rehype-code-D-RFJb9W.d.ts +14 -0
- package/dist/rehype-code.core-BUwNuchP.js +548 -0
- package/dist/rehype-code.core-BjH1uHWj.d.ts +115 -0
- package/dist/rehype-toc-K51AGb5U.d.ts +43 -0
- package/dist/remark-admonition-BwTcmI_S.d.ts +20 -0
- package/dist/remark-code-tab-DE_4bdnu.d.ts +34 -0
- package/dist/remark-directive-admonition-BLiJ5l43.d.ts +27 -0
- package/dist/remark-feedback-block-BxtINXN-.d.ts +45 -0
- package/dist/remark-gfm-DpVfAX1x.d.ts +2 -0
- package/dist/remark-heading-DEIzTkU5.d.ts +33 -0
- package/dist/remark-image-BI2S9LOb.d.ts +57 -0
- package/dist/remark-llms-bD3WvU2V.d.ts +73 -0
- package/dist/remark-mdx-files-Buvxc-sa.d.ts +54 -0
- package/dist/remark-mdx-mermaid-C1bCHHc6.d.ts +15 -0
- package/dist/remark-npm-BbpvkJaT.d.ts +31 -0
- package/dist/remark-steps-DqVEo0iq.d.ts +23 -0
- package/dist/remark-structure-CnHwvNZr.d.ts +87 -0
- package/dist/remove-markdown-DfKNMl9w.js +40 -0
- package/dist/remove-undefined-CzMSKybq.js +24 -0
- package/dist/rolldown-runtime-DC62tzP2.js +33 -0
- package/dist/search/algolia.d.ts +2 -0
- package/dist/search/algolia.js +75 -0
- package/dist/search/client/algolia.d.ts +2 -0
- package/dist/search/client/algolia.js +53 -0
- package/dist/search/client/fetch.d.ts +2 -0
- package/dist/search/client/fetch.js +28 -0
- package/dist/search/client/flexsearch-static.d.ts +2 -0
- package/dist/search/client/flexsearch-static.js +42 -0
- package/dist/search/client/mixedbread.d.ts +2 -0
- package/dist/search/client/mixedbread.js +65 -0
- package/dist/search/client/orama-cloud-legacy.d.ts +2 -0
- package/dist/search/client/orama-cloud-legacy.js +84 -0
- package/dist/search/client/orama-cloud.d.ts +2 -0
- package/dist/search/client/orama-cloud.js +86 -0
- package/dist/search/client/orama-static.d.ts +2 -0
- package/dist/search/client/orama-static.js +75 -0
- package/dist/search/client.d.ts +2 -0
- package/dist/search/client.js +97 -0
- package/dist/search/flexsearch.d.ts +56 -0
- package/dist/search/flexsearch.js +128 -0
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.js +74 -0
- package/dist/search/mixedbread.d.ts +49 -0
- package/dist/search/mixedbread.js +77 -0
- package/dist/search/orama-cloud-legacy.d.ts +75 -0
- package/dist/search/orama-cloud-legacy.js +48 -0
- package/dist/search/orama-cloud.d.ts +75 -0
- package/dist/search/orama-cloud.js +50 -0
- package/dist/search/server.d.ts +2 -0
- package/dist/search/server.js +237 -0
- package/dist/server-CCqACwlF.d.ts +165 -0
- package/dist/server.browser.d.ts +13 -0
- package/dist/server.browser.js +22 -0
- package/dist/server.d.ts +42 -0
- package/dist/server.js +398 -0
- package/dist/source/client/index.d.ts +2 -0
- package/dist/source/client/index.js +37 -0
- package/dist/source/dynamic.d.ts +2 -0
- package/dist/source/dynamic.js +2 -0
- package/dist/source/index.d.ts +2 -0
- package/dist/source/index.js +5 -0
- package/dist/source/llms.d.ts +2 -0
- package/dist/source/llms.js +74 -0
- package/dist/source/plugins/lucide-icons.d.ts +11 -0
- package/dist/source/plugins/lucide-icons.js +21 -0
- package/dist/source/plugins/slugs.d.ts +2 -0
- package/dist/source/plugins/slugs.js +75 -0
- package/dist/source/plugins/status-badges.d.ts +50 -0
- package/dist/source/plugins/status-badges.js +52 -0
- package/dist/source/schema.d.ts +30 -0
- package/dist/source/schema.js +28 -0
- package/dist/stringifier-B_QUcUyo.d.ts +63 -0
- package/dist/toc-CtW5lwA1.d.ts +64 -0
- package/dist/toc.d.ts +2 -0
- package/dist/toc.js +245 -0
- package/dist/transformer-icon-DlrneIS3.d.ts +17 -0
- package/dist/types-D89QoQR-.d.ts +4 -0
- package/dist/url-BVHvi3_K.js +29 -0
- package/dist/util-BDsqOxh3.d.ts +6 -0
- package/dist/util-DjBr9b3w.js +8 -0
- package/dist/utils/use-media-query.d.ts +4 -0
- package/dist/utils/use-media-query.js +20 -0
- package/dist/utils/use-on-change.d.ts +9 -0
- package/dist/utils/use-on-change.js +17 -0
- package/dist/utils-Bvy3V-fv.js +59 -0
- package/dist/utils-Cgs-6U-z.js +39 -0
- package/dist/utils-DEVq3cEC.js +151 -0
- package/dist/utils-Yx0IL9eW.js +48 -0
- package/package.json +251 -0
|
@@ -0,0 +1,378 @@
|
|
|
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 };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as Separator, i as Root, n as Item, r as Node, t as Folder } from "../definitions-CFOhwE1k.js";
|
|
2
|
+
import { a as findSiblings, c as getPageTreeRoots, i as findProjection, l as visit, n as findParent, o as flattenTree, r as findPath, s as getPageTreePeers, t as findNeighbour } from "../index-E8Qh_yQs.js";
|
|
3
|
+
export { Folder, Item, Node, Root, Separator, findNeighbour, findParent, findPath, findProjection, findSiblings, flattenTree, getPageTreePeers, getPageTreeRoots, visit };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as findSiblings, c as getPageTreeRoots, i as findProjection, l as visit, n as findParent, o as flattenTree, r as findPath, s as getPageTreePeers, t as findNeighbour } from "../utils-DEVq3cEC.js";
|
|
2
|
+
export { findNeighbour, findParent, findPath, findProjection, findSiblings, flattenTree, getPageTreePeers, getPageTreeRoots, visit };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { n as __exportAll } from "./rolldown-runtime-DC62tzP2.js";
|
|
2
|
+
//#region src/source/path.ts
|
|
3
|
+
var path_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
basename: () => basename,
|
|
5
|
+
dirname: () => dirname,
|
|
6
|
+
extname: () => extname,
|
|
7
|
+
joinPath: () => joinPath,
|
|
8
|
+
normalize: () => normalize,
|
|
9
|
+
slash: () => slash,
|
|
10
|
+
splitPath: () => splitPath
|
|
11
|
+
});
|
|
12
|
+
function basename(path, ext) {
|
|
13
|
+
const idx = path.lastIndexOf("/");
|
|
14
|
+
return path.substring(idx === -1 ? 0 : idx + 1, ext ? path.length - ext.length : path.length);
|
|
15
|
+
}
|
|
16
|
+
function extname(path) {
|
|
17
|
+
for (let i = path.length - 1; i >= 0; i--) {
|
|
18
|
+
const c = path[i];
|
|
19
|
+
if (c === ".") return path.substring(i);
|
|
20
|
+
if (c === "/") return "";
|
|
21
|
+
}
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
function dirname(path) {
|
|
25
|
+
const idx = path.lastIndexOf("/");
|
|
26
|
+
if (idx === -1) return "";
|
|
27
|
+
return path.substring(0, idx);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Split path into segments, trailing/leading slashes are removed
|
|
31
|
+
*/
|
|
32
|
+
function splitPath(path) {
|
|
33
|
+
return path.split("/").filter((p) => p.length > 0);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Resolve paths, slashes within the path will be ignored
|
|
37
|
+
* @param paths - Paths to join
|
|
38
|
+
* @example
|
|
39
|
+
* ```
|
|
40
|
+
* ['a','b'] // 'a/b'
|
|
41
|
+
* ['/a'] // 'a'
|
|
42
|
+
* ['a', '/b'] // 'a/b'
|
|
43
|
+
* ['a', '../b/c'] // 'b/c'
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
function joinPath(...paths) {
|
|
47
|
+
const out = [];
|
|
48
|
+
for (const path of paths) for (const seg of path.split("/")) switch (seg) {
|
|
49
|
+
case "..":
|
|
50
|
+
out.pop();
|
|
51
|
+
break;
|
|
52
|
+
case "":
|
|
53
|
+
case ".": break;
|
|
54
|
+
default: out.push(seg);
|
|
55
|
+
}
|
|
56
|
+
return out.join("/");
|
|
57
|
+
}
|
|
58
|
+
function slash(path) {
|
|
59
|
+
if (path.startsWith("\\\\?\\")) return path;
|
|
60
|
+
return path.replaceAll("\\", "/");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Convert (relative) file path to virtual file path.
|
|
64
|
+
*
|
|
65
|
+
* @param path - Relative path
|
|
66
|
+
* @returns Normalized path, with no trailing/leading slashes
|
|
67
|
+
* @throws Throws error if path starts with `./` or `../`
|
|
68
|
+
*/
|
|
69
|
+
function normalize(path) {
|
|
70
|
+
const segments = path.split(/\/|\\/).filter((v) => v.length > 0);
|
|
71
|
+
if (segments[0] === "." || segments[0] === "..") throw new Error("It must not start with './' or '../'");
|
|
72
|
+
return segments.join("/");
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { normalize as a, joinPath as i, dirname as n, path_exports as o, extname as r, basename as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { t as RehypeCodeOptionsCommon } from "./rehype-code.core-BjH1uHWj.js";
|
|
2
|
+
//#region src/mdx-plugins/rehype-code.d.ts
|
|
3
|
+
type RehypeCodeOptions = RehypeCodeOptionsCommon & {
|
|
4
|
+
/**
|
|
5
|
+
* The regex engine to use.
|
|
6
|
+
*
|
|
7
|
+
* @defaultValue 'js'
|
|
8
|
+
*/
|
|
9
|
+
engine?: 'js' | 'oniguruma';
|
|
10
|
+
};
|
|
11
|
+
declare const rehypeCodeDefaultOptions: RehypeCodeOptions;
|
|
12
|
+
declare const rehypeCode: (this: import("unified").Processor, _options?: Partial<RehypeCodeOptions> | undefined) => import("unified").Transformer<import("hast").Root, import("hast").Root>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { rehypeCode as n, rehypeCodeDefaultOptions as r, RehypeCodeOptions as t };
|