fumadocs-core 16.15.1 → 16.15.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/{build-doc-SC7P37WG.js → build-doc-CX-PNB-q.js} +1 -1
- package/dist/content/mdx/preset-bundler.d.ts +1 -1
- package/dist/content/mdx/preset-runtime.d.ts +1 -1
- package/dist/i18n/middleware.js +65 -2
- package/dist/{index-DQWu2opy2.d.ts → index-19nHQs6M.d.ts} +1 -1
- package/dist/{index-C-fnVAhi.d.ts → index-BhgPrb5p.d.ts} +1 -1
- package/dist/mdx-plugins/index.d.ts +2 -2
- package/dist/mdx-plugins/remark-llms.d.ts +1 -1
- package/dist/mdx-plugins/remark-llms.js +287 -4
- package/dist/negotiation/index.d.ts +1 -3
- package/dist/negotiation/index.js +378 -2
- package/dist/{remark-llms-BF5SHW_O.d.ts → remark-llms-DxglVo94.d.ts} +16 -2
- package/dist/search/flexsearch.d.ts +2 -2
- package/dist/search/flexsearch.js +1 -1
- package/dist/search/mixedbread.d.ts +1 -1
- 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 +1 -1
- package/dist/{server-DRvCKdc_.d.ts → server-C8FDQbVc.d.ts} +1 -1
- 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/dynamic.d.ts +1 -1
- package/dist/source/index.d.ts +1 -1
- package/dist/source/llms.d.ts +1 -1
- package/dist/source/plugins/lucide-icons.d.ts +1 -1
- package/dist/source/plugins/slugs.d.ts +1 -1
- package/dist/source/plugins/status-badges.d.ts +1 -1
- package/package.json +13 -11
- package/dist/negotiation-DAsKgSvF.js +0 -1056
|
@@ -51,7 +51,7 @@ function buildDocuments(indexes) {
|
|
|
51
51
|
locale: page.locale
|
|
52
52
|
});
|
|
53
53
|
const nextId = () => `${page.id}-${id++}`;
|
|
54
|
-
if (page.description) docs.push({
|
|
54
|
+
if (page.description && !data.contents.some((item) => item.content === page.description)) docs.push({
|
|
55
55
|
id: nextId(),
|
|
56
56
|
page_id: page.id,
|
|
57
57
|
tags,
|
|
@@ -4,7 +4,7 @@ import { r as StructureOptions } from "../../remark-structure-CnHwvNZr.js";
|
|
|
4
4
|
import { t as RemarkHeadingOptions } from "../../remark-heading-DEIzTkU5.js";
|
|
5
5
|
import { t as RemarkCodeTabOptions } from "../../remark-code-tab-DE_4bdnu.js";
|
|
6
6
|
import { t as RemarkNpmOptions } from "../../remark-npm-BbpvkJaT.js";
|
|
7
|
-
import "../../index-
|
|
7
|
+
import "../../index-BhgPrb5p.js";
|
|
8
8
|
import { t as ResolvePlugins } from "../../util-BDsqOxh3.js";
|
|
9
9
|
import { Pluggable } from "unified";
|
|
10
10
|
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
@@ -4,7 +4,7 @@ import { r as StructureOptions } from "../../remark-structure-CnHwvNZr.js";
|
|
|
4
4
|
import { t as RemarkHeadingOptions } from "../../remark-heading-DEIzTkU5.js";
|
|
5
5
|
import { t as RemarkCodeTabOptions } from "../../remark-code-tab-DE_4bdnu.js";
|
|
6
6
|
import { t as RemarkNpmOptions } from "../../remark-npm-BbpvkJaT.js";
|
|
7
|
-
import "../../index-
|
|
7
|
+
import "../../index-BhgPrb5p.js";
|
|
8
8
|
import { t as ResolvePlugins } from "../../util-BDsqOxh3.js";
|
|
9
9
|
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
10
10
|
//#region src/content/mdx/preset-runtime.d.ts
|
package/dist/i18n/middleware.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { t as getNegotiator } from "../negotiation-DAsKgSvF.js";
|
|
2
1
|
import { NextResponse } from "next/server.js";
|
|
3
2
|
//#region ../../node_modules/.pnpm/@formatjs+fast-memoize@3.1.7/node_modules/@formatjs/fast-memoize/index.js
|
|
4
3
|
function memoize(fn, options) {
|
|
@@ -3738,6 +3737,70 @@ function match(requestedLocales, availableLocales, defaultLocale, opts) {
|
|
|
3738
3737
|
return ResolveLocale(availableLocales, CanonicalizeLocaleList(requestedLocales), { localeMatcher: opts?.algorithm || "best fit" }, [], {}, () => defaultLocale).locale;
|
|
3739
3738
|
}
|
|
3740
3739
|
//#endregion
|
|
3740
|
+
//#region src/utils/accept-language.ts
|
|
3741
|
+
function parseAcceptLanguage(header) {
|
|
3742
|
+
const specs = [];
|
|
3743
|
+
for (const section of header.split(",")) {
|
|
3744
|
+
const [rawTag, ...params] = section.split(";");
|
|
3745
|
+
const full = rawTag.trim().toLowerCase();
|
|
3746
|
+
if (full.length === 0) continue;
|
|
3747
|
+
let quality = 1;
|
|
3748
|
+
for (const param of params) {
|
|
3749
|
+
const separator = param.indexOf("=");
|
|
3750
|
+
if (separator === -1 || param.slice(0, separator).trim().toLowerCase() !== "q") continue;
|
|
3751
|
+
const parsed = Number.parseFloat(param.slice(separator + 1));
|
|
3752
|
+
if (!Number.isNaN(parsed)) quality = parsed;
|
|
3753
|
+
}
|
|
3754
|
+
const dash = full.indexOf("-");
|
|
3755
|
+
specs.push({
|
|
3756
|
+
prefix: dash === -1 ? full : full.slice(0, dash),
|
|
3757
|
+
full,
|
|
3758
|
+
quality,
|
|
3759
|
+
order: specs.length
|
|
3760
|
+
});
|
|
3761
|
+
}
|
|
3762
|
+
return specs;
|
|
3763
|
+
}
|
|
3764
|
+
function matchLanguage(language, specs) {
|
|
3765
|
+
const full = language.trim().toLowerCase();
|
|
3766
|
+
const dash = full.indexOf("-");
|
|
3767
|
+
const prefix = dash === -1 ? full : full.slice(0, dash);
|
|
3768
|
+
const best = {
|
|
3769
|
+
language,
|
|
3770
|
+
quality: 0,
|
|
3771
|
+
specificity: 0,
|
|
3772
|
+
order: -1
|
|
3773
|
+
};
|
|
3774
|
+
for (const spec of specs) {
|
|
3775
|
+
let specificity;
|
|
3776
|
+
if (spec.full === full) specificity = 4;
|
|
3777
|
+
else if (spec.prefix === full) specificity = 2;
|
|
3778
|
+
else if (spec.full === prefix) specificity = 1;
|
|
3779
|
+
else if (spec.full === "*") specificity = 0;
|
|
3780
|
+
else continue;
|
|
3781
|
+
if ((specificity - best.specificity || spec.quality - best.quality || spec.order - best.order) > 0) {
|
|
3782
|
+
best.quality = spec.quality;
|
|
3783
|
+
best.specificity = specificity;
|
|
3784
|
+
best.order = spec.order;
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
if (best.quality > 0) return best;
|
|
3788
|
+
}
|
|
3789
|
+
/**
|
|
3790
|
+
* Filter `available` down to the languages the `Accept-Language` header accepts, ordered by
|
|
3791
|
+
* client preference. A missing (`null`) header accepts everything.
|
|
3792
|
+
*/
|
|
3793
|
+
function negotiateLanguages(header, available) {
|
|
3794
|
+
const specs = parseAcceptLanguage(header ?? "*");
|
|
3795
|
+
const matches = [];
|
|
3796
|
+
for (const language of available) {
|
|
3797
|
+
const match = matchLanguage(language, specs);
|
|
3798
|
+
if (match) matches.push(match);
|
|
3799
|
+
}
|
|
3800
|
+
matches.sort((a, b) => b.quality - a.quality || b.specificity - a.specificity || a.order - b.order);
|
|
3801
|
+
return matches.map((match) => match.language);
|
|
3802
|
+
}
|
|
3803
|
+
//#endregion
|
|
3741
3804
|
//#region src/i18n/middleware.ts
|
|
3742
3805
|
const DefaultFormatter = {
|
|
3743
3806
|
get(url) {
|
|
@@ -3773,7 +3836,7 @@ function createI18nMiddleware({ languages, defaultLanguage, format = DefaultForm
|
|
|
3773
3836
|
if (pathLocale && !languages.includes(pathLocale)) pathLocale = void 0;
|
|
3774
3837
|
if (!pathLocale) {
|
|
3775
3838
|
if (hideLocale === "default-locale") return NextResponse.rewrite(formatter.add(url, defaultLanguage));
|
|
3776
|
-
const preferred = match(
|
|
3839
|
+
const preferred = match(negotiateLanguages(request.headers.get("accept-language"), languages), languages, defaultLanguage);
|
|
3777
3840
|
if (hideLocale === "always") {
|
|
3778
3841
|
const locale = request.cookies.get(cookieName)?.value ?? preferred;
|
|
3779
3842
|
return NextResponse.rewrite(formatter.add(url, locale));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as Separator, i as Root, n as Item, r as Node, t as Folder } from "./definitions-D8-KI7Uy.js";
|
|
2
2
|
import { t as Awaitable } from "./types-D89QoQR-.js";
|
|
3
3
|
import { i as StructuredData } from "./remark-structure-CnHwvNZr.js";
|
|
4
|
-
import "./index-
|
|
4
|
+
import "./index-BhgPrb5p.js";
|
|
5
5
|
import { n as I18nConfig } from "./index-DydiXvgS.js";
|
|
6
6
|
import "./index-DZN5OrTa.js";
|
|
7
7
|
import { n as SerializedPageTree } from "./index-CdZGMKDG.js";
|
|
@@ -15,6 +15,6 @@ import { i as parseCodeBlockAttributes, n as CodeBlockTabsOptions, r as generate
|
|
|
15
15
|
import { a as remarkMdxFiles, r as RemarkMdxFilesOptions } from "../remark-mdx-files-Buvxc-sa.js";
|
|
16
16
|
import { n as remarkMdxMermaid, t as RemarkMdxMermaidOptions } from "../remark-mdx-mermaid-C1bCHHc6.js";
|
|
17
17
|
import { n as RemarkFeedbackBlockOptions, r as remarkFeedbackBlock, t as FeedbackBlockProps } from "../remark-feedback-block-BxtINXN-.js";
|
|
18
|
-
import { t as LLMsOptions } from "../remark-llms-
|
|
19
|
-
import "../index-
|
|
18
|
+
import { t as LLMsOptions } from "../remark-llms-DxglVo94.js";
|
|
19
|
+
import "../index-BhgPrb5p.js";
|
|
20
20
|
export { CodeBlockAttributes, type CodeBlockIcon, CodeBlockTabsOptions, FeedbackBlockProps, type LLMsOptions, RehypeCodeOptions, RehypeTOCItemType, RehypeTocOptions, RemarkAdmonitionOptions, RemarkCodeTabOptions, RemarkDirectiveAdmonitionOptions, RemarkFeedbackBlockOptions, type RemarkGfmOptions, RemarkHeadingOptions, RemarkImageOptions, type RemarkMdxFilesOptions, RemarkMdxMermaidOptions, RemarkNpmOptions, RemarkStepsOptions, Stringifier, StringifyOptions, StructureOptions, StructuredData, defaultStringifier, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkCodeTab, remarkDirectiveAdmonition, remarkFeedbackBlock, remarkGfm, remarkHeading, remarkImage, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkSteps, remarkStructure, remarkStructureDefaultOptions, structure, transformerIcon, transformerTab };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as placeholder, r as remarkLLMs, t as LLMsOptions } from "../remark-llms-
|
|
1
|
+
import { n as placeholder, r as remarkLLMs, t as LLMsOptions } from "../remark-llms-DxglVo94.js";
|
|
2
2
|
export { LLMsOptions, placeholder, remarkLLMs };
|
|
@@ -5,7 +5,8 @@ import { defaultHandlers } from "mdast-util-to-markdown";
|
|
|
5
5
|
/**
|
|
6
6
|
* generate `llms.txt` for markdown.
|
|
7
7
|
*/
|
|
8
|
-
function remarkLLMs({ as = "_markdown", headingIds = true, _data = false, mdxAsPlaceholder, ...rest } = {}) {
|
|
8
|
+
function remarkLLMs({ as = "_markdown", headingIds = true, _data = false, mdxAsPlaceholder, output = "string", ...rest } = {}) {
|
|
9
|
+
const jsx = output === "function";
|
|
9
10
|
const stringifier = defaultStringifier({
|
|
10
11
|
...rest,
|
|
11
12
|
filterElement(node) {
|
|
@@ -14,12 +15,14 @@ function remarkLLMs({ as = "_markdown", headingIds = true, _data = false, mdxAsP
|
|
|
14
15
|
default: return true;
|
|
15
16
|
}
|
|
16
17
|
},
|
|
17
|
-
stringify(node, parent, state, info,
|
|
18
|
-
if (mdxAsPlaceholder) switch (node.type) {
|
|
18
|
+
stringify(node, parent, state, info, collect) {
|
|
19
|
+
if (mdxAsPlaceholder && !collect) switch (node.type) {
|
|
19
20
|
case "mdxJsxFlowElement":
|
|
20
21
|
case "mdxJsxTextElement": if (node.name && mdxAsPlaceholder.includes(node.name)) return placeholder(node, parent, state, info);
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
const custom = rest.stringify?.(node, parent, state, info, void 0);
|
|
24
|
+
if (custom) return custom;
|
|
25
|
+
if (collect) return collectJsx(node, state, info, collect);
|
|
23
26
|
},
|
|
24
27
|
handlers: {
|
|
25
28
|
heading(node, _p, state, info) {
|
|
@@ -31,6 +34,12 @@ function remarkLLMs({ as = "_markdown", headingIds = true, _data = false, mdxAsP
|
|
|
31
34
|
}
|
|
32
35
|
});
|
|
33
36
|
return (node, file) => {
|
|
37
|
+
if (jsx) {
|
|
38
|
+
const collect = [];
|
|
39
|
+
const text = stringifier.call(this, node, collect);
|
|
40
|
+
node.children.unshift(jsxToEstree(as, toJsxChunks(text, collect)));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
34
43
|
const value = stringifier.call(this, node, void 0);
|
|
35
44
|
node.children.unshift(toMdxExport(as, value));
|
|
36
45
|
if (_data) file.data.markdown = value;
|
|
@@ -51,5 +60,279 @@ function placeholder(node, _parent, state, info) {
|
|
|
51
60
|
attributes
|
|
52
61
|
})}\0`;
|
|
53
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* `stringify` branch for the `function` output: collect the element and return a marker,
|
|
65
|
+
* resolved later by `toJsxChunks()`. Only components (capitalized names) are kept.
|
|
66
|
+
*/
|
|
67
|
+
function collectJsx(node, state, info, collect) {
|
|
68
|
+
switch (node.type) {
|
|
69
|
+
case "mdxJsxFlowElement":
|
|
70
|
+
case "mdxJsxTextElement": {
|
|
71
|
+
if (!node.name || !/^[A-Z][\w$]*$/.test(node.name)) return;
|
|
72
|
+
const entry = {
|
|
73
|
+
node,
|
|
74
|
+
children: ""
|
|
75
|
+
};
|
|
76
|
+
const marker = `\0${collect.push(entry) - 1}\0`;
|
|
77
|
+
entry.children = node.type === "mdxJsxTextElement" ? state.containerPhrasing(node, info) : state.containerFlow(node, info);
|
|
78
|
+
return marker;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const Marker = /\0(\d+)\0/g;
|
|
83
|
+
/**
|
|
84
|
+
* Split stringified Markdown on the markers emitted by `collectJsx()` into
|
|
85
|
+
* alternating text chunks and kept JSX elements, recursively for their children.
|
|
86
|
+
*/
|
|
87
|
+
function toJsxChunks(text, collect) {
|
|
88
|
+
const out = [];
|
|
89
|
+
let idx = 0;
|
|
90
|
+
for (const match of text.matchAll(Marker)) {
|
|
91
|
+
if (match.index > idx) out.push(text.slice(idx, match.index));
|
|
92
|
+
const { node, children } = collect[Number(match[1])];
|
|
93
|
+
out.push({
|
|
94
|
+
node,
|
|
95
|
+
children: toJsxChunks(children, collect)
|
|
96
|
+
});
|
|
97
|
+
idx = match.index + match[0].length;
|
|
98
|
+
}
|
|
99
|
+
if (idx < text.length) out.push(text.slice(idx));
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Generate the component export as an ESM node with estree, for the MDX.js compiler.
|
|
104
|
+
*/
|
|
105
|
+
function jsxToEstree(as, chunks) {
|
|
106
|
+
const hasJsx = chunks.some((chunk) => typeof chunk !== "string");
|
|
107
|
+
let value;
|
|
108
|
+
if (chunks.length === 0) value = literal("");
|
|
109
|
+
else if (typeof chunks[0] === "string" && chunks.length === 1) value = literal(chunks[0]);
|
|
110
|
+
else if (chunks.length === 1) value = elementToEstree(chunks[0]);
|
|
111
|
+
else value = {
|
|
112
|
+
type: "JSXFragment",
|
|
113
|
+
openingFragment: { type: "JSXOpeningFragment" },
|
|
114
|
+
closingFragment: { type: "JSXClosingFragment" },
|
|
115
|
+
children: childrenToEstree(chunks)
|
|
116
|
+
};
|
|
117
|
+
const body = [{
|
|
118
|
+
type: "IfStatement",
|
|
119
|
+
test: {
|
|
120
|
+
type: "UnaryExpression",
|
|
121
|
+
operator: "!",
|
|
122
|
+
prefix: true,
|
|
123
|
+
argument: {
|
|
124
|
+
type: "CallExpression",
|
|
125
|
+
callee: {
|
|
126
|
+
type: "Identifier",
|
|
127
|
+
name: "_asMarkdown"
|
|
128
|
+
},
|
|
129
|
+
arguments: [],
|
|
130
|
+
optional: false
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
consequent: {
|
|
134
|
+
type: "ReturnStatement",
|
|
135
|
+
argument: literal(null)
|
|
136
|
+
},
|
|
137
|
+
alternate: null
|
|
138
|
+
}];
|
|
139
|
+
if (hasJsx) body.push({
|
|
140
|
+
type: "VariableDeclaration",
|
|
141
|
+
kind: "const",
|
|
142
|
+
declarations: [{
|
|
143
|
+
type: "VariableDeclarator",
|
|
144
|
+
id: {
|
|
145
|
+
type: "Identifier",
|
|
146
|
+
name: "_c"
|
|
147
|
+
},
|
|
148
|
+
init: {
|
|
149
|
+
type: "CallExpression",
|
|
150
|
+
callee: {
|
|
151
|
+
type: "Identifier",
|
|
152
|
+
name: "_jsxComponents"
|
|
153
|
+
},
|
|
154
|
+
arguments: [{
|
|
155
|
+
type: "MemberExpression",
|
|
156
|
+
object: {
|
|
157
|
+
type: "Identifier",
|
|
158
|
+
name: "props"
|
|
159
|
+
},
|
|
160
|
+
property: {
|
|
161
|
+
type: "Identifier",
|
|
162
|
+
name: "components"
|
|
163
|
+
},
|
|
164
|
+
computed: false,
|
|
165
|
+
optional: false
|
|
166
|
+
}],
|
|
167
|
+
optional: false
|
|
168
|
+
}
|
|
169
|
+
}]
|
|
170
|
+
});
|
|
171
|
+
body.push({
|
|
172
|
+
type: "ReturnStatement",
|
|
173
|
+
argument: value
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
type: "mdxjsEsm",
|
|
177
|
+
value: "",
|
|
178
|
+
data: { estree: {
|
|
179
|
+
type: "Program",
|
|
180
|
+
sourceType: "module",
|
|
181
|
+
body: [{
|
|
182
|
+
type: "ImportDeclaration",
|
|
183
|
+
attributes: [],
|
|
184
|
+
specifiers: [{
|
|
185
|
+
type: "ImportSpecifier",
|
|
186
|
+
imported: {
|
|
187
|
+
type: "Identifier",
|
|
188
|
+
name: "asMarkdown"
|
|
189
|
+
},
|
|
190
|
+
local: {
|
|
191
|
+
type: "Identifier",
|
|
192
|
+
name: "_asMarkdown"
|
|
193
|
+
}
|
|
194
|
+
}, ...hasJsx ? [{
|
|
195
|
+
type: "ImportSpecifier",
|
|
196
|
+
imported: {
|
|
197
|
+
type: "Identifier",
|
|
198
|
+
name: "jsxComponents"
|
|
199
|
+
},
|
|
200
|
+
local: {
|
|
201
|
+
type: "Identifier",
|
|
202
|
+
name: "_jsxComponents"
|
|
203
|
+
}
|
|
204
|
+
}] : []],
|
|
205
|
+
source: literal("fumadocs-core/server")
|
|
206
|
+
}, {
|
|
207
|
+
type: "ExportNamedDeclaration",
|
|
208
|
+
attributes: [],
|
|
209
|
+
specifiers: [],
|
|
210
|
+
declaration: {
|
|
211
|
+
type: "FunctionDeclaration",
|
|
212
|
+
id: {
|
|
213
|
+
type: "Identifier",
|
|
214
|
+
name: as
|
|
215
|
+
},
|
|
216
|
+
params: [{
|
|
217
|
+
type: "Identifier",
|
|
218
|
+
name: "props"
|
|
219
|
+
}],
|
|
220
|
+
body: {
|
|
221
|
+
type: "BlockStatement",
|
|
222
|
+
body
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}]
|
|
226
|
+
} }
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function literal(value) {
|
|
230
|
+
return {
|
|
231
|
+
type: "Literal",
|
|
232
|
+
value
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function childrenToEstree(chunks) {
|
|
236
|
+
const out = [];
|
|
237
|
+
for (const chunk of chunks) out.push(typeof chunk === "string" ? {
|
|
238
|
+
type: "JSXExpressionContainer",
|
|
239
|
+
expression: literal(chunk)
|
|
240
|
+
} : elementToEstree(chunk));
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
function elementToEstree({ node, children }) {
|
|
244
|
+
const attributes = [];
|
|
245
|
+
for (const attr of node.attributes) {
|
|
246
|
+
if (attr.type === "mdxJsxExpressionAttribute") {
|
|
247
|
+
const expression = programExpression(attr.data?.estree);
|
|
248
|
+
if (expression?.type === "ObjectExpression" && expression.properties.length === 1 && expression.properties[0].type === "SpreadElement") attributes.push({
|
|
249
|
+
type: "JSXSpreadAttribute",
|
|
250
|
+
argument: expression.properties[0].argument
|
|
251
|
+
});
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
let value = null;
|
|
255
|
+
if (typeof attr.value === "string") value = {
|
|
256
|
+
type: "Literal",
|
|
257
|
+
value: attr.value
|
|
258
|
+
};
|
|
259
|
+
else if (attr.value) {
|
|
260
|
+
const expression = programExpression(attr.value.data?.estree);
|
|
261
|
+
if (!expression) continue;
|
|
262
|
+
value = {
|
|
263
|
+
type: "JSXExpressionContainer",
|
|
264
|
+
expression
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
attributes.push({
|
|
268
|
+
type: "JSXAttribute",
|
|
269
|
+
name: attr.name.includes(":") ? {
|
|
270
|
+
type: "JSXNamespacedName",
|
|
271
|
+
namespace: {
|
|
272
|
+
type: "JSXIdentifier",
|
|
273
|
+
name: attr.name.slice(0, attr.name.indexOf(":"))
|
|
274
|
+
},
|
|
275
|
+
name: {
|
|
276
|
+
type: "JSXIdentifier",
|
|
277
|
+
name: attr.name.slice(attr.name.indexOf(":") + 1)
|
|
278
|
+
}
|
|
279
|
+
} : {
|
|
280
|
+
type: "JSXIdentifier",
|
|
281
|
+
name: attr.name
|
|
282
|
+
},
|
|
283
|
+
value
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const name = {
|
|
287
|
+
type: "JSXMemberExpression",
|
|
288
|
+
object: {
|
|
289
|
+
type: "JSXIdentifier",
|
|
290
|
+
name: "_c"
|
|
291
|
+
},
|
|
292
|
+
property: {
|
|
293
|
+
type: "JSXIdentifier",
|
|
294
|
+
name: node.name
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
const element = {
|
|
298
|
+
type: "JSXElement",
|
|
299
|
+
openingElement: {
|
|
300
|
+
type: "JSXOpeningElement",
|
|
301
|
+
name,
|
|
302
|
+
attributes,
|
|
303
|
+
selfClosing: children.length === 0
|
|
304
|
+
},
|
|
305
|
+
closingElement: children.length === 0 ? null : {
|
|
306
|
+
type: "JSXClosingElement",
|
|
307
|
+
name
|
|
308
|
+
},
|
|
309
|
+
children: childrenToEstree(children)
|
|
310
|
+
};
|
|
311
|
+
if (node.type === "mdxJsxFlowElement") return element;
|
|
312
|
+
return {
|
|
313
|
+
type: "JSXElement",
|
|
314
|
+
openingElement: {
|
|
315
|
+
type: "JSXOpeningElement",
|
|
316
|
+
name: {
|
|
317
|
+
type: "JSXIdentifier",
|
|
318
|
+
name: "span"
|
|
319
|
+
},
|
|
320
|
+
attributes: [],
|
|
321
|
+
selfClosing: false
|
|
322
|
+
},
|
|
323
|
+
closingElement: {
|
|
324
|
+
type: "JSXClosingElement",
|
|
325
|
+
name: {
|
|
326
|
+
type: "JSXIdentifier",
|
|
327
|
+
name: "span"
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
children: [element]
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function programExpression(program) {
|
|
334
|
+
const statement = program?.body[0];
|
|
335
|
+
if (statement?.type === "ExpressionStatement") return statement.expression;
|
|
336
|
+
}
|
|
54
337
|
//#endregion
|
|
55
338
|
export { placeholder, remarkLLMs };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import Negotiator from "negotiator";
|
|
2
1
|
//#region src/negotiation/index.d.ts
|
|
3
|
-
declare function getNegotiator(request: Request): Negotiator;
|
|
4
2
|
/**
|
|
5
3
|
* Rewrite incoming path matching the `source` pattern into the `destination` pattern.
|
|
6
4
|
*
|
|
@@ -16,4 +14,4 @@ declare function isMarkdownPreferred(request: Request, options?: {
|
|
|
16
14
|
markdownMediaTypes?: string[];
|
|
17
15
|
}): boolean;
|
|
18
16
|
//#endregion
|
|
19
|
-
export {
|
|
17
|
+
export { isMarkdownPreferred, rewritePath };
|