fuma-content 1.1.3 → 1.1.5
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/{async-cache-CBEZB25o.d.ts → async-cache-Ca5oMQss.d.ts} +4 -2
- package/dist/async-cache-Ca5oMQss.d.ts.map +1 -0
- package/dist/{async-cache-DRmFaVGm.js → async-cache-Cce8lc9D.js} +4 -2
- package/dist/async-cache-Cce8lc9D.js.map +1 -0
- package/dist/{build-mdx-oug7zk0w.js → build-mdx-C210zpJN.js} +30 -53
- package/dist/build-mdx-C210zpJN.js.map +1 -0
- package/dist/{build-mdx-DkAvzRNg.d.ts → build-mdx-DhXGp7I9.d.ts} +35 -7
- package/dist/build-mdx-DhXGp7I9.d.ts.map +1 -0
- package/dist/bun/index.d.ts +1 -1
- package/dist/bun/index.js +1 -1
- package/dist/{bun-cxKGeSx6.js → bun-DsjsbVrx.js} +4 -3
- package/dist/bun-DsjsbVrx.js.map +1 -0
- package/dist/{code-generator-C_Gu9y3h.js → code-generator-CHcOrCeM.js} +2 -4
- package/dist/code-generator-CHcOrCeM.js.map +1 -0
- package/dist/collections/data/runtime.d.ts +2 -2
- package/dist/collections/data.d.ts +2 -2
- package/dist/collections/data.js +3 -3
- package/dist/collections/fs.d.ts +1 -1
- package/dist/collections/fs.js +1 -1
- package/dist/collections/index.d.ts +1 -1
- package/dist/collections/json/loader-webpack.d.ts +2 -2
- package/dist/collections/json/loader-webpack.js +2 -2
- package/dist/collections/mdx/loader-webpack.d.ts +2 -2
- package/dist/collections/mdx/loader-webpack.js +2 -2
- package/dist/collections/mdx/react.d.ts +3 -3
- package/dist/collections/mdx/react.d.ts.map +1 -1
- package/dist/collections/mdx/react.js +2 -1
- package/dist/collections/mdx/react.js.map +1 -1
- package/dist/collections/mdx/runtime-browser.d.ts +3 -4
- package/dist/collections/mdx/runtime-browser.d.ts.map +1 -1
- package/dist/collections/mdx/runtime-browser.js +1 -1
- package/dist/collections/mdx/runtime-dynamic.d.ts +2 -3
- package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -1
- package/dist/collections/mdx/runtime-dynamic.js +13 -6
- package/dist/collections/mdx/runtime-dynamic.js.map +1 -1
- package/dist/collections/mdx/runtime.d.ts +2 -3
- package/dist/collections/mdx/runtime.d.ts.map +1 -1
- package/dist/collections/mdx.d.ts +5 -13
- package/dist/collections/mdx.d.ts.map +1 -1
- package/dist/collections/mdx.js +35 -30
- package/dist/collections/mdx.js.map +1 -1
- package/dist/collections/obsidian.d.ts +11 -0
- package/dist/collections/obsidian.d.ts.map +1 -0
- package/dist/collections/obsidian.js +501 -0
- package/dist/collections/obsidian.js.map +1 -0
- package/dist/collections/runtime/file-store.d.ts +1 -1
- package/dist/collections/runtime/store.d.ts +1 -1
- package/dist/collections/yaml/loader-webpack.d.ts +2 -2
- package/dist/collections/yaml/loader-webpack.js +2 -2
- package/dist/config/index.d.ts +1 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/{core-DmbQk8Z2.js → core-BuUsOElL.js} +2 -2
- package/dist/{core-DmbQk8Z2.js.map → core-BuUsOElL.js.map} +1 -1
- package/dist/{core-CG2zTL4c.d.ts → core-FjA_Xoho.d.ts} +1 -2
- package/dist/core-FjA_Xoho.d.ts.map +1 -0
- package/dist/dynamic.d.ts +2 -2
- package/dist/dynamic.js +1 -1
- package/dist/{fuma-matter-Pwr2S9Ab.js → fuma-matter-CCYGfgju.js} +1 -1
- package/dist/{fuma-matter-Pwr2S9Ab.js.map → fuma-matter-CCYGfgju.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/is-promise-like-pBUIbRFy.js +8 -0
- package/dist/is-promise-like-pBUIbRFy.js.map +1 -0
- package/dist/{load-from-file-BeLFB77e.js → load-from-file-B9ho46XM.js} +1 -1
- package/dist/{load-from-file-BeLFB77e.js.map → load-from-file-B9ho46XM.js.map} +1 -1
- package/dist/{load-from-file-CpA8UQXX.d.ts → load-from-file-CIYdu-B5.d.ts} +1 -1
- package/dist/load-from-file-CIYdu-B5.d.ts.map +1 -0
- package/dist/{loader-DOjRBsog.js → loader-B3hZ0R4a.js} +12 -6
- package/dist/loader-B3hZ0R4a.js.map +1 -0
- package/dist/{loader-gwXIGo5Q.js → loader-BFfzKD3u.js} +1 -1
- package/dist/{loader-gwXIGo5Q.js.map → loader-BFfzKD3u.js.map} +1 -1
- package/dist/{loader-DTODFdmk.js → loader-C5w-u-h2.js} +2 -2
- package/dist/{loader-DTODFdmk.js.map → loader-C5w-u-h2.js.map} +1 -1
- package/dist/{loader-DKTW82eK.js → loader-D2BD3e0R.js} +2 -2
- package/dist/{loader-DKTW82eK.js.map → loader-D2BD3e0R.js.map} +1 -1
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +2 -2
- package/dist/node/index.d.ts +1 -1
- package/dist/node/loader.d.ts +1 -1
- package/dist/node/loader.js +2 -2
- package/dist/{node-l03HaPSS.js → node-Cu5Pqxxo.js} +2 -2
- package/dist/node-Cu5Pqxxo.js.map +1 -0
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/git.js +1 -1
- package/dist/plugins/json-schema.d.ts +1 -1
- package/dist/plugins/loader/index.d.ts +4 -7
- package/dist/plugins/loader/index.d.ts.map +1 -1
- package/dist/plugins/loader/index.js +6 -5
- package/dist/plugins/loader/index.js.map +1 -1
- package/dist/plugins/loader/webpack.d.ts +2 -2
- package/dist/plugins/loader/webpack.js +4 -2
- package/dist/plugins/loader/webpack.js.map +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +3 -14
- package/dist/vite/index.js.map +1 -1
- package/dist/{vite-mAc2TZyp.js → vite-CoJIMNWk.js} +3 -3
- package/dist/vite-CoJIMNWk.js.map +1 -0
- package/package.json +15 -8
- package/dist/async-cache-CBEZB25o.d.ts.map +0 -1
- package/dist/async-cache-DRmFaVGm.js.map +0 -1
- package/dist/build-mdx-DkAvzRNg.d.ts.map +0 -1
- package/dist/build-mdx-oug7zk0w.js.map +0 -1
- package/dist/bun-cxKGeSx6.js.map +0 -1
- package/dist/code-generator-C_Gu9y3h.js.map +0 -1
- package/dist/core-CG2zTL4c.d.ts.map +0 -1
- package/dist/load-from-file-CpA8UQXX.d.ts.map +0 -1
- package/dist/loader-DOjRBsog.js.map +0 -1
- package/dist/node-l03HaPSS.js.map +0 -1
- package/dist/vite-mAc2TZyp.js.map +0 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { S as Awaitable } from "./core-FjA_Xoho.js";
|
|
2
|
+
|
|
1
3
|
//#region src/utils/async-cache.d.ts
|
|
2
4
|
interface AsyncCache<V> {
|
|
3
|
-
cached: (key: string, fn: () =>
|
|
5
|
+
cached: (key: string, fn: () => Awaitable<V>) => V | PromiseLike<V>;
|
|
4
6
|
$value: <T>() => AsyncCache<T>;
|
|
5
7
|
invalidate: (key: string) => void;
|
|
6
8
|
}
|
|
7
9
|
//#endregion
|
|
8
10
|
export { AsyncCache as t };
|
|
9
|
-
//# sourceMappingURL=async-cache-
|
|
11
|
+
//# sourceMappingURL=async-cache-Ca5oMQss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-cache-Ca5oMQss.d.ts","names":[],"sources":["../src/utils/async-cache.ts"],"mappings":";;;UAGiB,UAAA;EACf,MAAA,GAAS,GAAA,UAAa,EAAA,QAAU,SAAA,CAAU,CAAA,MAAO,CAAA,GAAI,WAAA,CAAY,CAAA;EACjE,MAAA,WAAiB,UAAA,CAAW,CAAA;EAC5B,UAAA,GAAa,GAAA;AAAA"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { t as isPromiseLike } from "./is-promise-like-pBUIbRFy.js";
|
|
2
|
+
|
|
1
3
|
//#region src/utils/async-cache.ts
|
|
2
4
|
/**
|
|
3
5
|
* cache for async resources, finished promises will be resolved into original value, otherwise wrapped with a promise.
|
|
@@ -8,7 +10,7 @@ function createCache(store = /* @__PURE__ */ new Map()) {
|
|
|
8
10
|
let cached = store.get(key);
|
|
9
11
|
if (cached) return cached;
|
|
10
12
|
cached = fn();
|
|
11
|
-
if (cached
|
|
13
|
+
if (isPromiseLike(cached)) cached = cached.then((out) => {
|
|
12
14
|
if (store.has(key)) store.set(key, out);
|
|
13
15
|
return out;
|
|
14
16
|
});
|
|
@@ -26,4 +28,4 @@ function createCache(store = /* @__PURE__ */ new Map()) {
|
|
|
26
28
|
|
|
27
29
|
//#endregion
|
|
28
30
|
export { createCache as t };
|
|
29
|
-
//# sourceMappingURL=async-cache-
|
|
31
|
+
//# sourceMappingURL=async-cache-Cce8lc9D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-cache-Cce8lc9D.js","names":[],"sources":["../src/utils/async-cache.ts"],"sourcesContent":["import { Awaitable } from \"@/types\";\nimport { isPromiseLike } from \"./is-promise-like\";\n\nexport interface AsyncCache<V> {\n cached: (key: string, fn: () => Awaitable<V>) => V | PromiseLike<V>;\n $value: <T>() => AsyncCache<T>;\n invalidate: (key: string) => void;\n}\n\n/**\n * cache for async resources, finished promises will be resolved into original value, otherwise wrapped with a promise.\n */\nexport function createCache<V>(store = new Map<string, V | PromiseLike<V>>()): AsyncCache<V> {\n return {\n cached(key, fn) {\n let cached = store.get(key);\n if (cached) return cached;\n\n cached = fn();\n if (isPromiseLike(cached)) {\n cached = cached.then((out) => {\n // replace with resolved if still exists\n if (store.has(key)) {\n store.set(key, out);\n }\n\n return out;\n });\n }\n store.set(key, cached);\n return cached;\n },\n invalidate(key) {\n store.delete(key);\n },\n $value<T>() {\n return this as unknown as AsyncCache<T>;\n },\n };\n}\n"],"mappings":";;;;;;AAYA,SAAgB,YAAe,wBAAQ,IAAI,KAAiC,EAAiB;AAC3F,QAAO;EACL,OAAO,KAAK,IAAI;GACd,IAAI,SAAS,MAAM,IAAI,IAAI;AAC3B,OAAI,OAAQ,QAAO;AAEnB,YAAS,IAAI;AACb,OAAI,cAAc,OAAO,CACvB,UAAS,OAAO,MAAM,QAAQ;AAE5B,QAAI,MAAM,IAAI,IAAI,CAChB,OAAM,IAAI,KAAK,IAAI;AAGrB,WAAO;KACP;AAEJ,SAAM,IAAI,KAAK,OAAO;AACtB,UAAO;;EAET,WAAW,KAAK;AACd,SAAM,OAAO,IAAI;;EAEnB,SAAY;AACV,UAAO;;EAEV"}
|
|
@@ -1,53 +1,17 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-CjeV3_4I.js";
|
|
2
|
-
import { t as createCache } from "./async-cache-
|
|
3
|
-
import { t as fumaMatter } from "./fuma-matter-
|
|
2
|
+
import { t as createCache } from "./async-cache-Cce8lc9D.js";
|
|
3
|
+
import { t as fumaMatter } from "./fuma-matter-CCYGfgju.js";
|
|
4
4
|
import * as fs$1 from "node:fs/promises";
|
|
5
5
|
import * as path$1 from "node:path";
|
|
6
|
+
import { visit } from "unist-util-visit";
|
|
6
7
|
import { createProcessor } from "@mdx-js/mdx";
|
|
7
8
|
import { VFile } from "vfile";
|
|
8
|
-
import { unified } from "unified";
|
|
9
|
-
import { visit } from "unist-util-visit";
|
|
10
9
|
import { toMarkdown } from "mdast-util-to-markdown";
|
|
11
10
|
import { valueToEstree } from "estree-util-value-to-estree";
|
|
12
11
|
import { removePosition } from "unist-util-remove-position";
|
|
13
12
|
import { mdxToMarkdown } from "mdast-util-mdx";
|
|
14
13
|
|
|
15
|
-
//#region src/
|
|
16
|
-
function remarkMarkAndUnravel() {
|
|
17
|
-
return (tree) => {
|
|
18
|
-
visit(tree, (node, index, parent) => {
|
|
19
|
-
let offset = -1;
|
|
20
|
-
let all = true;
|
|
21
|
-
let oneOrMore = false;
|
|
22
|
-
if (parent && typeof index === "number" && node.type === "paragraph") {
|
|
23
|
-
const children = node.children;
|
|
24
|
-
while (++offset < children.length) {
|
|
25
|
-
const child = children[offset];
|
|
26
|
-
if (child.type === "mdxJsxTextElement" || child.type === "mdxTextExpression") oneOrMore = true;
|
|
27
|
-
else if (child.type === "text" && child.value.trim().length === 0) {} else {
|
|
28
|
-
all = false;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (all && oneOrMore) {
|
|
33
|
-
offset = -1;
|
|
34
|
-
const newChildren = [];
|
|
35
|
-
while (++offset < children.length) {
|
|
36
|
-
const child = children[offset];
|
|
37
|
-
if (child.type === "mdxJsxTextElement") child.type = "mdxJsxFlowElement";
|
|
38
|
-
if (child.type === "mdxTextExpression") child.type = "mdxFlowExpression";
|
|
39
|
-
if (child.type === "text" && /^[\t\r\n ]+$/.test(String(child.value))) {} else newChildren.push(child);
|
|
40
|
-
}
|
|
41
|
-
parent.children.splice(index, 1, ...newChildren);
|
|
42
|
-
return index;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/collections/mdx/mdast-utils.ts
|
|
14
|
+
//#region src/utils/mdast/flatten.ts
|
|
51
15
|
function flattenNode(node) {
|
|
52
16
|
if ("children" in node) return node.children.map((child) => flattenNode(child)).join("");
|
|
53
17
|
if ("value" in node) return node.value;
|
|
@@ -177,9 +141,7 @@ function extractCodeRegion(content, regionName) {
|
|
|
177
141
|
}
|
|
178
142
|
throw new Error(`Region "${regionName}" not found`);
|
|
179
143
|
}
|
|
180
|
-
function remarkInclude({
|
|
181
|
-
const TagName = "include";
|
|
182
|
-
const preprocessor = unified().use(remarkMarkAndUnravel).use(preprocess);
|
|
144
|
+
function remarkInclude({ tagName = "include" } = {}) {
|
|
183
145
|
const embedContent = async (targetPath, heading, params, parent) => {
|
|
184
146
|
const { _getProcessor = () => this, _compiler } = parent.data;
|
|
185
147
|
let content;
|
|
@@ -197,17 +159,24 @@ function remarkInclude({ preprocess = [] } = {}) {
|
|
|
197
159
|
value: heading ? extractCodeRegion(content, heading) : content,
|
|
198
160
|
data: {}
|
|
199
161
|
};
|
|
200
|
-
const
|
|
162
|
+
const processor = await _getProcessor(ext === ".mdx" ? "mdx" : "md");
|
|
201
163
|
const parsed = fumaMatter(content);
|
|
202
164
|
const targetFile = new VFile({
|
|
203
165
|
path: targetPath,
|
|
204
166
|
value: parsed.content,
|
|
205
167
|
data: {
|
|
206
168
|
...parent.data,
|
|
207
|
-
frontmatter: parsed.data
|
|
169
|
+
frontmatter: parsed.data,
|
|
170
|
+
_in_include: true
|
|
208
171
|
}
|
|
209
172
|
});
|
|
210
|
-
let mdast
|
|
173
|
+
let mdast;
|
|
174
|
+
try {
|
|
175
|
+
mdast = await processor.run(processor.parse(targetFile), targetFile);
|
|
176
|
+
} catch (e) {
|
|
177
|
+
if (e instanceof Terminated) mdast = e.value;
|
|
178
|
+
else throw e;
|
|
179
|
+
}
|
|
211
180
|
if (heading) {
|
|
212
181
|
const extracted = extractSection(mdast, heading);
|
|
213
182
|
if (!extracted) throw new Error(`Cannot find section ${heading} in ${targetPath}, make sure you have encapsulated the section in a <section id="${heading}"> tag, or a :::section directive with remark-directive configured.`);
|
|
@@ -220,7 +189,7 @@ function remarkInclude({ preprocess = [] } = {}) {
|
|
|
220
189
|
const queue = [];
|
|
221
190
|
visit(tree, ElementLikeTypes, (_node, _, parent) => {
|
|
222
191
|
const node = _node;
|
|
223
|
-
if (node.name !==
|
|
192
|
+
if (node.name !== tagName) return;
|
|
224
193
|
const specifier = flattenNode(node);
|
|
225
194
|
if (specifier.length === 0) return "skip";
|
|
226
195
|
const attributes = parseElementAttributes(node);
|
|
@@ -234,9 +203,15 @@ function remarkInclude({ preprocess = [] } = {}) {
|
|
|
234
203
|
await Promise.all(queue);
|
|
235
204
|
}
|
|
236
205
|
return async (tree, file) => {
|
|
206
|
+
if (file.data._in_include) throw new Terminated(tree);
|
|
237
207
|
await update(tree, file);
|
|
238
208
|
};
|
|
239
209
|
}
|
|
210
|
+
var Terminated = class {
|
|
211
|
+
constructor(value) {
|
|
212
|
+
this.value = value;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
240
215
|
|
|
241
216
|
//#endregion
|
|
242
217
|
//#region src/collections/mdx/remark-postprocess.ts
|
|
@@ -340,7 +315,7 @@ function getMdastExport(name, value) {
|
|
|
340
315
|
//#endregion
|
|
341
316
|
//#region src/collections/mdx/build-mdx.ts
|
|
342
317
|
var build_mdx_exports = /* @__PURE__ */ __exportAll({ buildMDX: () => buildMDX });
|
|
343
|
-
async function buildMDX(core, collection,
|
|
318
|
+
async function buildMDX({ core, collection, filePath, frontmatter, source, compiler, environment, isDevelopment }) {
|
|
344
319
|
const processorCache = createCache(core.cache).$value();
|
|
345
320
|
function getProcessor(format) {
|
|
346
321
|
const key = `build-mdx:${collection?.name ?? "global"}:${format}`;
|
|
@@ -350,13 +325,15 @@ async function buildMDX(core, collection, { filePath, frontmatter, source, _comp
|
|
|
350
325
|
_format: format,
|
|
351
326
|
...collection?.postprocess
|
|
352
327
|
};
|
|
353
|
-
const remarkIncludeOptions = { preprocess: collection?.preprocess?.remarkPlugins };
|
|
354
328
|
return createProcessor({
|
|
355
329
|
outputFormat: "program",
|
|
356
330
|
development: isDevelopment,
|
|
357
331
|
...mdxOptions,
|
|
358
|
-
remarkPlugins:
|
|
359
|
-
|
|
332
|
+
remarkPlugins: typeof mdxOptions?.remarkPlugins === "function" ? mdxOptions.remarkPlugins({
|
|
333
|
+
remarkInclude,
|
|
334
|
+
remarkPostprocess: [remarkPostprocess, postprocessOptions]
|
|
335
|
+
}) : [
|
|
336
|
+
remarkInclude,
|
|
360
337
|
...mdxOptions?.remarkPlugins ?? [],
|
|
361
338
|
[remarkPostprocess, postprocessOptions]
|
|
362
339
|
],
|
|
@@ -370,7 +347,7 @@ async function buildMDX(core, collection, { filePath, frontmatter, source, _comp
|
|
|
370
347
|
cwd: core.getOptions().cwd,
|
|
371
348
|
data: {
|
|
372
349
|
frontmatter,
|
|
373
|
-
_compiler,
|
|
350
|
+
_compiler: compiler,
|
|
374
351
|
_getProcessor: getProcessor
|
|
375
352
|
}
|
|
376
353
|
});
|
|
@@ -384,4 +361,4 @@ async function buildMDX(core, collection, { filePath, frontmatter, source, _comp
|
|
|
384
361
|
|
|
385
362
|
//#endregion
|
|
386
363
|
export { build_mdx_exports as n, buildMDX as t };
|
|
387
|
-
//# sourceMappingURL=build-mdx-
|
|
364
|
+
//# sourceMappingURL=build-mdx-C210zpJN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-mdx-C210zpJN.js","names":["fs","path"],"sources":["../src/utils/mdast/flatten.ts","../src/collections/mdx/remark-include.ts","../src/collections/mdx/remark-postprocess.ts","../src/collections/mdx/build-mdx.ts"],"sourcesContent":["import type { RootContent } from \"mdast\";\n\nexport function flattenNode(node: RootContent): string {\n if (\"children\" in node) return node.children.map((child) => flattenNode(child)).join(\"\");\n\n if (\"value\" in node) return node.value;\n\n return \"\";\n}\n","import type { Processor, Transformer } from \"unified\";\nimport { visit } from \"unist-util-visit\";\nimport type { Code, Node, Root, RootContent } from \"mdast\";\nimport * as path from \"node:path\";\nimport * as fs from \"node:fs/promises\";\nimport { fumaMatter } from \"@/collections/mdx/fuma-matter\";\nimport type { MdxJsxFlowElement, MdxJsxTextElement } from \"mdast-util-mdx-jsx\";\nimport { VFile } from \"vfile\";\nimport type { Directives } from \"mdast-util-directive\";\nimport { flattenNode } from \"@/utils/mdast/flatten\";\n\nexport interface Params {\n lang?: string;\n meta?: string;\n}\n\nconst ElementLikeTypes: ElementLikeContent[\"type\"][] = [\n \"mdxJsxFlowElement\",\n \"mdxJsxTextElement\",\n \"containerDirective\",\n \"textDirective\",\n \"leafDirective\",\n];\ntype ElementLikeContent = MdxJsxFlowElement | MdxJsxTextElement | Directives;\n\nfunction isElementLike(node: Node): node is ElementLikeContent {\n return ElementLikeTypes.includes(node.type as ElementLikeContent[\"type\"]);\n}\n\nfunction parseElementAttributes(\n element: ElementLikeContent,\n): Record<string, string | null | undefined> {\n if (Array.isArray(element.attributes)) {\n const attributes: Record<string, string | null> = {};\n\n for (const attr of element.attributes) {\n if (\n attr.type === \"mdxJsxAttribute\" &&\n (typeof attr.value === \"string\" || attr.value === null)\n ) {\n attributes[attr.name] = attr.value;\n }\n }\n\n return attributes;\n }\n\n return element.attributes ?? {};\n}\n\nfunction parseSpecifier(specifier: string): {\n file: string;\n section?: string;\n} {\n const idx = specifier.lastIndexOf(\"#\");\n if (idx === -1) return { file: specifier };\n\n return {\n file: specifier.slice(0, idx),\n section: specifier.slice(idx + 1),\n };\n}\n\nfunction extractSection(root: Root, section: string): Root | undefined {\n let nodes: RootContent[] | undefined;\n let capturingHeadingContent = false;\n\n visit(root, (node) => {\n if (node.type === \"heading\") {\n if (capturingHeadingContent) {\n return false;\n }\n\n if (node.data?.hProperties?.id === section) {\n capturingHeadingContent = true;\n nodes = [node];\n return \"skip\";\n }\n\n return;\n }\n\n if (capturingHeadingContent) {\n nodes?.push(node as RootContent);\n return \"skip\";\n }\n\n if (isElementLike(node) && node.name === \"section\") {\n const attributes = parseElementAttributes(node);\n\n if (attributes.id === section) {\n nodes = node.children;\n return false;\n }\n }\n });\n\n if (nodes)\n return {\n type: \"root\",\n children: nodes,\n };\n}\n\n// region marker regexes\nconst REGION_MARKERS = [\n {\n start: /^\\s*\\/\\/\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*\\/\\/\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*<!--\\s*#?region\\b\\s*(.*?)\\s*-->/,\n end: /^\\s*<!--\\s*#?endregion\\b\\s*(.*?)\\s*-->/,\n },\n {\n start: /^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\//,\n end: /^\\s*\\/\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\//,\n },\n {\n start: /^\\s*#[rR]egion\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#[eE]nd ?[rR]egion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#\\s*#?region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#\\s*#?endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*(?:--|::|@?REM)\\s*#region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*(?:--|::|@?REM)\\s*#endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*#pragma\\s+region\\b\\s*(.*?)\\s*$/,\n end: /^\\s*#pragma\\s+endregion\\b\\s*(.*?)\\s*$/,\n },\n {\n start: /^\\s*\\(\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\)/,\n end: /^\\s*\\(\\*\\s*#endregion\\b\\s*(.*?)\\s*\\*\\)/,\n },\n];\n\nfunction dedent(lines: string[]): string {\n const minIndent = lines.reduce((min, line) => {\n const match = line.match(/^(\\s*)\\S/);\n return match ? Math.min(min, match[1].length) : min;\n }, Infinity);\n\n return minIndent === Infinity\n ? lines.join(\"\\n\")\n : lines.map((l) => l.slice(minIndent)).join(\"\\n\");\n}\n\nfunction extractCodeRegion(content: string, regionName: string): string {\n const lines = content.split(\"\\n\");\n\n for (let i = 0; i < lines.length; i++) {\n for (const re of REGION_MARKERS) {\n let match = re.start.exec(lines[i]);\n if (match?.[1] !== regionName) continue;\n\n let depth = 1;\n const extractedLines: string[] = [];\n for (let j = i + 1; j < lines.length; j++) {\n match = re.start.exec(lines[j]);\n if (match) {\n depth++;\n continue;\n }\n\n match = re.end.exec(lines[j]);\n if (match) {\n if (match[1] === regionName) depth = 0;\n else if (match[1] === \"\") depth--;\n else continue;\n\n if (depth > 0) continue;\n return dedent(extractedLines);\n } else {\n extractedLines.push(lines[j]);\n }\n }\n }\n }\n throw new Error(`Region \"${regionName}\" not found`);\n}\n\nexport interface RemarkIncludeOptions {\n tagName?: string;\n}\n\ndeclare module \"vfile\" {\n interface DataMap {\n /** [Fuma Content: remark-include] whether the content is getting parsed from a `<include />` */\n _in_include?: boolean;\n }\n}\n\nexport function remarkInclude(\n this: Processor,\n { tagName = \"include\" }: RemarkIncludeOptions = {},\n): Transformer<Root, Root> {\n const embedContent = async (\n targetPath: string,\n heading: string | undefined,\n params: Params,\n parent: VFile,\n ) => {\n const { _getProcessor = () => this, _compiler } = parent.data;\n let content: string;\n try {\n content = (await fs.readFile(targetPath)).toString();\n } catch (e) {\n throw new Error(\n `failed to read file ${targetPath}\\n${e instanceof Error ? e.message : String(e)}`,\n { cause: e },\n );\n }\n\n const ext = path.extname(targetPath);\n _compiler?.addDependency(targetPath);\n if (params.lang || (ext !== \".md\" && ext !== \".mdx\")) {\n const lang = params.lang ?? ext.slice(1);\n\n return {\n type: \"code\",\n lang,\n meta: params.meta,\n value: heading ? extractCodeRegion(content, heading) : content,\n data: {},\n } satisfies Code;\n }\n\n const processor = (await _getProcessor(ext === \".mdx\" ? \"mdx\" : \"md\")) as unknown as Processor<\n Root,\n Root,\n Root\n >;\n const parsed = fumaMatter(content);\n const targetFile = new VFile({\n path: targetPath,\n value: parsed.content,\n data: {\n ...parent.data,\n frontmatter: parsed.data as Record<string, unknown>,\n _in_include: true,\n },\n });\n\n let mdast: Root;\n try {\n mdast = await processor.run(processor.parse(targetFile), targetFile);\n } catch (e) {\n if (e instanceof Terminated) mdast = e.value;\n else throw e;\n }\n\n if (heading) {\n const extracted = extractSection(mdast, heading);\n if (!extracted)\n throw new Error(\n `Cannot find section ${heading} in ${targetPath}, make sure you have encapsulated the section in a <section id=\"${heading}\"> tag, or a :::section directive with remark-directive configured.`,\n );\n\n mdast = extracted;\n }\n\n await update(mdast, targetFile);\n return mdast;\n };\n\n async function update(tree: Root, file: VFile) {\n const queue: Promise<void>[] = [];\n\n visit(tree, ElementLikeTypes, (_node, _, parent) => {\n const node = _node as ElementLikeContent;\n if (node.name !== tagName) return;\n\n const specifier = flattenNode(node);\n if (specifier.length === 0) return \"skip\";\n\n const attributes = parseElementAttributes(node);\n const { file: relativePath, section } = parseSpecifier(specifier);\n const targetPath = path.resolve(\n \"cwd\" in attributes ? file.cwd : (file.dirname ?? \"\"),\n relativePath,\n );\n\n queue.push(\n embedContent(targetPath, section, attributes, file).then((replace) => {\n Object.assign(parent && parent.type === \"paragraph\" ? parent : node, replace);\n }),\n );\n\n return \"skip\";\n });\n\n await Promise.all(queue);\n }\n return async (tree, file) => {\n if (file.data._in_include) throw new Terminated(tree);\n\n await update(tree, file);\n };\n}\n\nclass Terminated {\n constructor(readonly value: Root) {}\n}\n","import type { Processor, Transformer } from \"unified\";\nimport type { Heading, Root, RootContent } from \"mdast\";\nimport { visit } from \"unist-util-visit\";\nimport { toMarkdown } from \"mdast-util-to-markdown\";\nimport { valueToEstree } from \"estree-util-value-to-estree\";\nimport { removePosition } from \"unist-util-remove-position\";\nimport { flattenNode } from \"@/utils/mdast/flatten\";\nimport { mdxToMarkdown } from \"mdast-util-mdx\";\n\nexport interface LinkReference {\n href: string;\n}\n\nexport interface PostprocessOptions {\n _format: \"md\" | \"mdx\";\n\n /**\n * Properties to export from `vfile.data`\n */\n valueToExport?: string[];\n\n /**\n * stringify MDAST and export via `_markdown`.\n */\n processedMarkdown?:\n | boolean\n | {\n as?: string;\n /**\n * include heading IDs into the processed markdown.\n */\n headingIds?: boolean;\n };\n\n /**\n * extract link references, export via `_linkReferences`.\n */\n linkReferences?:\n | boolean\n | {\n as?: string;\n };\n\n /**\n * store MDAST and export via `_mdast`.\n */\n mdast?:\n | boolean\n | {\n as?: string;\n removePosition?: boolean;\n };\n}\n\n/**\n * - collect references\n * - write frontmatter (auto-title & description)\n */\nexport function remarkPostprocess(\n this: Processor,\n {\n _format,\n processedMarkdown = false,\n mdast = false,\n linkReferences = false,\n valueToExport = [],\n }: PostprocessOptions,\n): Transformer<Root, Root> {\n return (tree, file) => {\n const frontmatter = (file.data.frontmatter ??= {});\n if (!frontmatter.title) {\n visit(tree, \"heading\", (node) => {\n if (node.depth === 1) {\n frontmatter.title = flattenNode(node);\n return false;\n }\n });\n }\n\n file.data[\"mdx-export\"] ??= [];\n file.data[\"mdx-export\"].push({\n name: \"frontmatter\",\n value: frontmatter,\n });\n\n if (linkReferences) {\n const { as = \"_linkReferences\" } = linkReferences === true ? {} : linkReferences;\n const urls: LinkReference[] = [];\n\n visit(tree, \"link\", (node) => {\n urls.push({\n href: node.url,\n });\n return \"skip\";\n });\n\n file.data[\"mdx-export\"].push({\n name: as,\n value: urls,\n });\n }\n\n if (processedMarkdown) {\n const { as = \"_markdown\", headingIds = true } =\n processedMarkdown === true ? {} : processedMarkdown;\n const extensions = this.data(\"toMarkdownExtensions\") ?? [];\n\n const markdown = toMarkdown(tree, {\n ...this.data(\"settings\"),\n extensions: _format === \"md\" ? [...extensions, mdxToMarkdown()] : extensions,\n handlers: {\n heading(node: Heading) {\n const id = node.data?.hProperties?.id;\n const content = flattenNode(node);\n return headingIds && id ? `${content} [#${id}]` : content;\n },\n },\n });\n\n file.data[\"mdx-export\"].push({\n name: as,\n value: markdown,\n });\n }\n\n if (mdast) {\n const { as = \"_mdast\", removePosition: shouldRemovePosition = false } =\n mdast === true ? {} : mdast;\n const stringified = JSON.stringify(\n shouldRemovePosition ? removePosition(structuredClone(tree)) : tree,\n );\n\n file.data[\"mdx-export\"].push({\n name: as,\n value: stringified,\n });\n }\n\n for (const { name, value } of file.data[\"mdx-export\"]) {\n tree.children.unshift(getMdastExport(name, value));\n }\n\n // reset the data to reduce memory usage\n file.data[\"mdx-export\"] = [];\n\n for (const name of valueToExport) {\n if (!(name in file.data)) continue;\n\n tree.children.unshift(getMdastExport(name, file.data[name]));\n }\n };\n}\n\n/**\n * MDX.js first converts javascript (with esm support) into mdast nodes with remark-mdx, then handle the other remark plugins\n *\n * Therefore, if we want to inject an export, we must convert the object into AST, then add the mdast node\n */\nfunction getMdastExport(name: string, value: unknown): RootContent {\n return {\n type: \"mdxjsEsm\",\n value: \"\",\n data: {\n estree: {\n type: \"Program\",\n sourceType: \"module\",\n body: [\n {\n type: \"ExportNamedDeclaration\",\n specifiers: [],\n attributes: [],\n source: null,\n declaration: {\n type: \"VariableDeclaration\",\n kind: \"let\",\n declarations: [\n {\n type: \"VariableDeclarator\",\n id: {\n type: \"Identifier\",\n name,\n },\n init: valueToEstree(value),\n },\n ],\n },\n },\n ],\n },\n },\n };\n}\n","import { createProcessor, type ProcessorOptions } from \"@mdx-js/mdx\";\nimport { VFile } from \"vfile\";\nimport { remarkInclude } from \"@/collections/mdx/remark-include\";\nimport { type PostprocessOptions, remarkPostprocess } from \"@/collections/mdx/remark-postprocess\";\nimport type { Core } from \"@/core\";\nimport { createCache } from \"@/utils/async-cache\";\nimport type { MDXContent } from \"mdx/types\";\nimport { MDXCollection } from \"../mdx\";\nimport type { Pluggable, PluggableList } from \"unified\";\nimport type { Awaitable } from \"@/types\";\n\ntype MDXProcessor = ReturnType<typeof createProcessor>;\n\ninterface MDXCompilerContext {\n addDependency: (file: string) => void;\n collection: MDXCollection | undefined;\n core: Core;\n}\n\ninterface BuildMDXOptions {\n core: Core;\n collection: MDXCollection | undefined;\n /**\n * Specify a file path for source\n */\n filePath: string;\n source: string;\n frontmatter?: Record<string, unknown>;\n\n environment: \"bundler\" | \"runtime\";\n isDevelopment: boolean;\n compiler: MDXCompilerContext;\n}\n\nexport interface FumaContentProcessorOptions extends Omit<ProcessorOptions, \"remarkPlugins\"> {\n remarkPlugins?:\n | PluggableList\n | ((plugins: {\n remarkInclude: typeof remarkInclude;\n remarkPostprocess: Pluggable;\n }) => PluggableList)\n | null\n | undefined;\n}\n\nexport interface FumaContentDataMap {\n /**\n * [Fuma Content] raw frontmatter, you can modify it\n */\n frontmatter?: Record<string, unknown>;\n\n /**\n * [Fuma Content] additional ESM exports to write\n */\n \"mdx-export\"?: { name: string; value: unknown }[];\n\n /**\n * [Fuma Content] The internal compiler info\n */\n _compiler?: MDXCompilerContext;\n\n /**\n * [Fuma Content] get internal processor, do not use this on user land.\n */\n _getProcessor?: (format: \"md\" | \"mdx\") => Awaitable<MDXProcessor>;\n}\n\ndeclare module \"vfile\" {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- extend data map\n interface DataMap extends FumaContentDataMap {}\n}\n\nexport interface CompiledMDX<Frontmatter = Record<string, unknown>> extends Record<\n string,\n unknown\n> {\n frontmatter: Frontmatter;\n default: MDXContent;\n}\n\nexport async function buildMDX({\n core,\n collection,\n filePath,\n frontmatter,\n source,\n compiler,\n environment,\n isDevelopment,\n}: BuildMDXOptions): Promise<VFile> {\n const processorCache = createCache(core.cache).$value<MDXProcessor>();\n\n function getProcessor(format: \"md\" | \"mdx\") {\n const key = `build-mdx:${collection?.name ?? \"global\"}:${format}`;\n\n return processorCache.cached(key, async () => {\n const mdxOptions = await collection?.getMDXOptions?.(environment);\n const postprocessOptions: PostprocessOptions = {\n _format: format,\n ...collection?.postprocess,\n };\n\n return createProcessor({\n outputFormat: \"program\",\n development: isDevelopment,\n ...mdxOptions,\n remarkPlugins:\n typeof mdxOptions?.remarkPlugins === \"function\"\n ? mdxOptions.remarkPlugins({\n remarkInclude,\n remarkPostprocess: [remarkPostprocess, postprocessOptions],\n })\n : [\n remarkInclude,\n ...(mdxOptions?.remarkPlugins ?? []),\n [remarkPostprocess, postprocessOptions],\n ],\n format,\n });\n });\n }\n\n let vfile = new VFile({\n value: source,\n path: filePath,\n cwd: core.getOptions().cwd,\n data: {\n frontmatter,\n _compiler: compiler,\n _getProcessor: getProcessor,\n },\n });\n\n if (collection && collection) {\n vfile = await collection.vfile.run(vfile, {\n collection,\n filePath,\n source,\n });\n }\n\n return (await getProcessor(filePath.endsWith(\".mdx\") ? \"mdx\" : \"md\")).process(vfile);\n}\n"],"mappings":";;;;;;;;;;;;;;AAEA,SAAgB,YAAY,MAA2B;AACrD,KAAI,cAAc,KAAM,QAAO,KAAK,SAAS,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC,KAAK,GAAG;AAExF,KAAI,WAAW,KAAM,QAAO,KAAK;AAEjC,QAAO;;;;;ACST,MAAM,mBAAiD;CACrD;CACA;CACA;CACA;CACA;CACD;AAGD,SAAS,cAAc,MAAwC;AAC7D,QAAO,iBAAiB,SAA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;;;;;;AC9GH,eAAsB,SAAS,EAC7B,MACA,YACA,UACA,aACA,QACA,UACA,aACA,iBACkC;CAClC,MAAM,iBAAiB,YAAY,KAAK,MAAM,CAAC,QAAsB;CAErE,SAAS,aAAa,QAAsB;EAC1C,MAAM,MAAM,aAAa,YAAY,QAAQ,SAAS,GAAG;AAEzD,SAAO,eAAe,OAAO,KAAK,YAAY;GAC5C,MAAM,aAAa,MAAM,YAAY,gBAAgB,YAAY;GACjE,MAAM,qBAAyC;IAC7C,SAAS;IACT,GAAG,YAAY;IAChB;AAED,UAAO,gBAAgB;IACrB,cAAc;IACd,aAAa;IACb,GAAG;IACH,eACE,OAAO,YAAY,kBAAkB,aACjC,WAAW,cAAc;KACvB;KACA,mBAAmB,CAAC,mBAAmB,mBAAmB;KAC3D,CAAC,GACF;KACE;KACA,GAAI,YAAY,iBAAiB,EAAE;KACnC,CAAC,mBAAmB,mBAAmB;KACxC;IACP;IACD,CAAC;IACF;;CAGJ,IAAI,QAAQ,IAAI,MAAM;EACpB,OAAO;EACP,MAAM;EACN,KAAK,KAAK,YAAY,CAAC;EACvB,MAAM;GACJ;GACA,WAAW;GACX,eAAe;GAChB;EACF,CAAC;AAEF,KAAI,cAAc,WAChB,SAAQ,MAAM,WAAW,MAAM,IAAI,OAAO;EACxC;EACA;EACA;EACD,CAAC;AAGJ,SAAQ,MAAM,aAAa,SAAS,SAAS,OAAO,GAAG,QAAQ,KAAK,EAAE,QAAQ,MAAM"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { S as Awaitable, t as Core } from "./core-FjA_Xoho.js";
|
|
2
|
+
import { MDXCollection } from "./collections/mdx.js";
|
|
3
|
+
import { ProcessorOptions, createProcessor } from "@mdx-js/mdx";
|
|
3
4
|
import { VFile } from "vfile";
|
|
5
|
+
import { Pluggable, PluggableList, Processor, Transformer } from "unified";
|
|
6
|
+
import { Root } from "mdast";
|
|
4
7
|
import { MDXContent } from "mdx/types";
|
|
5
8
|
|
|
6
9
|
//#region src/collections/mdx/remark-postprocess.d.ts
|
|
@@ -38,8 +41,33 @@ interface PostprocessOptions {
|
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
//#endregion
|
|
44
|
+
//#region src/collections/mdx/remark-include.d.ts
|
|
45
|
+
interface RemarkIncludeOptions {
|
|
46
|
+
tagName?: string;
|
|
47
|
+
}
|
|
48
|
+
declare module "vfile" {
|
|
49
|
+
interface DataMap {
|
|
50
|
+
/** [Fuma Content: remark-include] whether the content is getting parsed from a `<include />` */
|
|
51
|
+
_in_include?: boolean;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
declare function remarkInclude(this: Processor, {
|
|
55
|
+
tagName
|
|
56
|
+
}?: RemarkIncludeOptions): Transformer<Root, Root>;
|
|
57
|
+
//#endregion
|
|
41
58
|
//#region src/collections/mdx/build-mdx.d.ts
|
|
42
59
|
type MDXProcessor = ReturnType<typeof createProcessor>;
|
|
60
|
+
interface MDXCompilerContext {
|
|
61
|
+
addDependency: (file: string) => void;
|
|
62
|
+
collection: MDXCollection | undefined;
|
|
63
|
+
core: Core;
|
|
64
|
+
}
|
|
65
|
+
interface FumaContentProcessorOptions extends Omit<ProcessorOptions, "remarkPlugins"> {
|
|
66
|
+
remarkPlugins?: PluggableList | ((plugins: {
|
|
67
|
+
remarkInclude: typeof remarkInclude;
|
|
68
|
+
remarkPostprocess: Pluggable;
|
|
69
|
+
}) => PluggableList) | null | undefined;
|
|
70
|
+
}
|
|
43
71
|
interface FumaContentDataMap {
|
|
44
72
|
/**
|
|
45
73
|
* [Fuma Content] raw frontmatter, you can modify it
|
|
@@ -53,13 +81,13 @@ interface FumaContentDataMap {
|
|
|
53
81
|
value: unknown;
|
|
54
82
|
}[];
|
|
55
83
|
/**
|
|
56
|
-
* [Fuma Content] The compiler
|
|
84
|
+
* [Fuma Content] The internal compiler info
|
|
57
85
|
*/
|
|
58
|
-
_compiler?:
|
|
86
|
+
_compiler?: MDXCompilerContext;
|
|
59
87
|
/**
|
|
60
88
|
* [Fuma Content] get internal processor, do not use this on user land.
|
|
61
89
|
*/
|
|
62
|
-
_getProcessor?: (format: "md" | "mdx") =>
|
|
90
|
+
_getProcessor?: (format: "md" | "mdx") => Awaitable<MDXProcessor>;
|
|
63
91
|
}
|
|
64
92
|
declare module "vfile" {
|
|
65
93
|
interface DataMap extends FumaContentDataMap {}
|
|
@@ -69,5 +97,5 @@ interface CompiledMDX<Frontmatter = Record<string, unknown>> extends Record<stri
|
|
|
69
97
|
default: MDXContent;
|
|
70
98
|
}
|
|
71
99
|
//#endregion
|
|
72
|
-
export {
|
|
73
|
-
//# sourceMappingURL=build-mdx-
|
|
100
|
+
export { PostprocessOptions as i, FumaContentProcessorOptions as n, LinkReference as r, CompiledMDX as t };
|
|
101
|
+
//# sourceMappingURL=build-mdx-DhXGp7I9.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-mdx-DhXGp7I9.d.ts","names":[],"sources":["../src/collections/mdx/remark-postprocess.ts","../src/collections/mdx/remark-include.ts","../src/collections/mdx/build-mdx.ts"],"mappings":";;;;;;;;;UASiB,aAAA;EACf,IAAA;AAAA;AAAA,UAGe,kBAAA;EACf,OAAA;;;AALF;EAUE,aAAA;;;;EAKA,iBAAA;IAGM,EAAA;IAd2B;;;IAkB3B,UAAA;EAAA;EAJA;;;EAUN,cAAA;IAGM,EAAA;EAAA;EAUA;;;EAJN,KAAA;IAGM,EAAA;IACA,cAAA;EAAA;AAAA;;;UCuIS,oBAAA;EACf,OAAA;AAAA;AAAA;EAAA,UAIU,OAAA;IDrLkB;ICuL1B,WAAA;EAAA;AAAA;AAAA,iBAIY,aAAA,CACd,IAAA,EAAM,SAAA;EACJ;AAAA,IAAuB,oBAAA,GACxB,WAAA,CAAY,IAAA,EAAM,IAAA;;;KC5LhB,YAAA,GAAe,UAAA,QAAkB,eAAA;AAAA,UAE5B,kBAAA;EACR,aAAA,GAAgB,IAAA;EAChB,UAAA,EAAY,aAAA;EACZ,IAAA,EAAM,IAAA;AAAA;AAAA,UAkBS,2BAAA,SAAoC,IAAA,CAAK,gBAAA;EACxD,aAAA,GACI,aAAA,KACE,OAAA;IACA,aAAA,SAAsB,aAAA;IACtB,iBAAA,EAAmB,SAAA;EAAA,MACf,aAAA;AAAA;AAAA,UAKK,kBAAA;ED4IoB;;;ECxInC,WAAA,GAAc,MAAA;ED0If;;;ECrIC,YAAA;IAAiB,IAAA;IAAc,KAAA;EAAA;ED8IJ;;;ECzI3B,SAAA,GAAY,kBAAA;ED2Ia;;;ECtIzB,aAAA,IAAiB,MAAA,mBAAyB,SAAA,CAAU,YAAA;AAAA;AAAA;EAAA,UAK1C,OAAA,SAAgB,kBAAA;AAAA;AAAA,UAGX,WAAA,eAA0B,MAAA,2BAAiC,MAAA;EAI1E,WAAA,EAAa,WAAA;EACb,OAAA,EAAS,UAAA;AAAA"}
|
package/dist/bun/index.d.ts
CHANGED
package/dist/bun/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as isPromiseLike } from "./is-promise-like-pBUIbRFy.js";
|
|
1
2
|
import { readFileSync } from "node:fs";
|
|
2
3
|
import { parse } from "node:querystring";
|
|
3
4
|
|
|
@@ -20,11 +21,11 @@ function toBun(test = /.+/, loader) {
|
|
|
20
21
|
query: parse(query),
|
|
21
22
|
filePath,
|
|
22
23
|
development: false,
|
|
23
|
-
|
|
24
|
+
addDependency() {}
|
|
24
25
|
};
|
|
25
26
|
if (loader.bun?.load) return loader.bun.load(readFileSync(filePath).toString(), input);
|
|
26
27
|
const result = loader.load(input);
|
|
27
|
-
if (result
|
|
28
|
+
if (isPromiseLike(result)) return result.then(toResult);
|
|
28
29
|
return toResult(result);
|
|
29
30
|
});
|
|
30
31
|
};
|
|
@@ -32,4 +33,4 @@ function toBun(test = /.+/, loader) {
|
|
|
32
33
|
|
|
33
34
|
//#endregion
|
|
34
35
|
export { toBun };
|
|
35
|
-
//# sourceMappingURL=bun-
|
|
36
|
+
//# sourceMappingURL=bun-DsjsbVrx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun-DsjsbVrx.js","names":[],"sources":["../src/plugins/loader/bun.ts"],"sourcesContent":["import { parse } from \"node:querystring\";\nimport { readFileSync } from \"node:fs\";\nimport type { LoaderInput, Loader, LoaderOutput } from \"@/plugins/loader\";\nimport { isPromiseLike } from \"@/utils/is-promise-like\";\n\nexport function toBun(test: RegExp = /.+/, loader: Loader) {\n function toResult(output: LoaderOutput | null): Bun.OnLoadResult {\n // it errors, treat this as an exception\n if (!output) return;\n\n return {\n contents: output.code,\n loader: output.moduleType ?? \"js\",\n };\n }\n\n return (build: Bun.PluginBuilder): void => {\n // avoid using async here, because it will cause dynamic require() to fail\n build.onLoad({ filter: test }, (args) => {\n const [filePath, query = \"\"] = args.path.split(\"?\", 2);\n const input: LoaderInput = {\n async getSource() {\n return Bun.file(filePath).text();\n },\n query: parse(query),\n filePath,\n development: false,\n addDependency() {},\n };\n\n if (loader.bun?.load) {\n return loader.bun.load(readFileSync(filePath).toString(), input);\n }\n\n const result = loader.load(input);\n if (isPromiseLike(result)) {\n return result.then(toResult);\n }\n return toResult(result);\n });\n };\n}\n"],"mappings":";;;;;AAKA,SAAgB,MAAM,OAAe,MAAM,QAAgB;CACzD,SAAS,SAAS,QAA+C;AAE/D,MAAI,CAAC,OAAQ;AAEb,SAAO;GACL,UAAU,OAAO;GACjB,QAAQ,OAAO,cAAc;GAC9B;;AAGH,SAAQ,UAAmC;AAEzC,QAAM,OAAO,EAAE,QAAQ,MAAM,GAAG,SAAS;GACvC,MAAM,CAAC,UAAU,QAAQ,MAAM,KAAK,KAAK,MAAM,KAAK,EAAE;GACtD,MAAM,QAAqB;IACzB,MAAM,YAAY;AAChB,YAAO,IAAI,KAAK,SAAS,CAAC,MAAM;;IAElC,OAAO,MAAM,MAAM;IACnB;IACA,aAAa;IACb,gBAAgB;IACjB;AAED,OAAI,OAAO,KAAK,KACd,QAAO,OAAO,IAAI,KAAK,aAAa,SAAS,CAAC,UAAU,EAAE,MAAM;GAGlE,MAAM,SAAS,OAAO,KAAK,MAAM;AACjC,OAAI,cAAc,OAAO,CACvB,QAAO,OAAO,KAAK,SAAS;AAE9B,UAAO,SAAS,OAAO;IACvB"}
|
|
@@ -10,9 +10,8 @@ var CodeGenerator = class {
|
|
|
10
10
|
importInfos = /* @__PURE__ */ new Map();
|
|
11
11
|
eagerImportId = 0;
|
|
12
12
|
options;
|
|
13
|
-
constructor({
|
|
13
|
+
constructor({ jsExtension = false, outDir = "" }) {
|
|
14
14
|
this.options = {
|
|
15
|
-
target,
|
|
16
15
|
jsExtension,
|
|
17
16
|
outDir
|
|
18
17
|
};
|
|
@@ -82,7 +81,6 @@ var CodeGenerator = class {
|
|
|
82
81
|
}
|
|
83
82
|
toString() {
|
|
84
83
|
const final = ["// @ts-nocheck"];
|
|
85
|
-
if (this.options.target === "vite") final.push("/// <reference types=\"vite/client\" />");
|
|
86
84
|
for (const [specifier, { namespaces, isUsed, named }] of this.importInfos) {
|
|
87
85
|
if (namespaces) for (const namespace of namespaces) final.push(isUsed?.has(namespace) ? `import * as ${namespace} from "${specifier}";` : `import type * as ${namespace} from "${specifier}";`);
|
|
88
86
|
if (named && named.size > 0) {
|
|
@@ -105,4 +103,4 @@ function slash(path) {
|
|
|
105
103
|
|
|
106
104
|
//#endregion
|
|
107
105
|
export { slash as n, CodeGenerator as t };
|
|
108
|
-
//# sourceMappingURL=code-generator-
|
|
106
|
+
//# sourceMappingURL=code-generator-CHcOrCeM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-generator-CHcOrCeM.js","names":[],"sources":["../src/utils/code-generator.ts"],"sourcesContent":["import type { EmitConfig } from \"@/config\";\nimport path from \"node:path\";\nimport { URLSearchParams } from \"node:url\";\n\nexport interface CodeGeneratorOptions extends EmitConfig {\n outDir: string;\n}\n\ninterface ImportInfo {\n /**\n * import name -> member name\n */\n named?: Map<string, string>;\n namespaces?: Set<string>;\n /**\n * a set of import names, the import is type-only if its name is missing in this set.\n */\n isUsed?: Set<string>;\n}\n\n/**\n * Code generator (one instance per file)\n */\nexport class CodeGenerator {\n private readonly lines: string[] = [];\n // specifier -> imported members/info\n private readonly importInfos = new Map<string, ImportInfo>();\n private eagerImportId = 0;\n\n readonly options: CodeGeneratorOptions;\n constructor({ jsExtension = false, outDir = \"\" }: Partial<CodeGeneratorOptions>) {\n this.options = {\n jsExtension,\n outDir,\n };\n }\n\n addNamespaceImport(namespace: string, specifier: string, typeOnly = false) {\n const info = this.importInfos.get(specifier) ?? {};\n this.importInfos.set(specifier, info);\n if (!typeOnly) {\n info.isUsed ??= new Set();\n info.isUsed.add(namespace);\n }\n\n info.namespaces ??= new Set();\n info.namespaces.add(namespace);\n }\n\n addNamedImport(names: string[], specifier: string, typeOnly = false) {\n const info = this.importInfos.get(specifier) ?? {};\n this.importInfos.set(specifier, info);\n info.named ??= new Map();\n\n for (const name of names) {\n const [memberName, importName = memberName] = name.split(/\\s+as\\s+/, 2);\n info.named.set(importName, memberName);\n if (!typeOnly) {\n info.isUsed ??= new Set();\n info.isUsed.add(importName);\n }\n }\n }\n\n push(...insert: string[]) {\n this.lines.push(...insert);\n }\n\n async pushAsync(insert: Promise<string | undefined>[]) {\n for (const line of await Promise.all(insert)) {\n if (line === undefined) continue;\n\n this.lines.push(line);\n }\n }\n\n /** generate a random import name that is unique in file. */\n generateImportName(): string {\n return `__${this.eagerImportId++}`;\n }\n\n formatDynamicImport(specifier: string, mod?: string): string {\n let s = `import(\"${specifier}\")`;\n if (mod) s += `.then(mod => mod.${mod})`;\n return s;\n }\n\n formatQuery(query: Record<string, string | undefined>) {\n const params = new URLSearchParams();\n for (const k in query) {\n const value = query[k];\n if (typeof value === \"string\") params.set(k, value);\n }\n return params.toString();\n }\n\n formatImportPath(file: string) {\n const ext = path.extname(file);\n let filename: string;\n\n switch (ext) {\n case \".ts\":\n case \".tsx\":\n filename = file.substring(0, file.length - ext.length);\n if (this.options.jsExtension) filename += \".js\";\n break;\n default:\n filename = file;\n }\n\n const importPath = slash(path.relative(this.options.outDir, filename));\n return importPath.startsWith(\"../\") ? importPath : `./${importPath}`;\n }\n\n toString() {\n const final: string[] = [\"// @ts-nocheck\"];\n\n for (const [specifier, { namespaces, isUsed, named }] of this.importInfos) {\n if (namespaces)\n for (const namespace of namespaces) {\n final.push(\n isUsed?.has(namespace)\n ? `import * as ${namespace} from \"${specifier}\";`\n : `import type * as ${namespace} from \"${specifier}\";`,\n );\n }\n\n if (named && named.size > 0) {\n const namedImports: string[] = [];\n\n for (const [importName, memberName] of named) {\n const item = importName === memberName ? importName : `${memberName} as ${importName}`;\n\n namedImports.push(isUsed?.has(importName) ? item : `type ${item}`);\n }\n\n final.push(`import { ${namedImports.join(\", \")} } from \"${specifier}\";`);\n }\n }\n\n final.push(...this.lines);\n return final.join(\"\\n\");\n }\n}\n\nexport function slash(path: string): string {\n const isExtendedLengthPath = path.startsWith(\"\\\\\\\\?\\\\\");\n\n if (isExtendedLengthPath) {\n return path;\n }\n\n return path.replaceAll(\"\\\\\", \"/\");\n}\n\nexport function ident(code: string, tab: number = 1) {\n return code\n .split(\"\\n\")\n .map((v) => \" \".repeat(tab) + v)\n .join(\"\\n\");\n}\n"],"mappings":";;;;;;;AAuBA,IAAa,gBAAb,MAA2B;CACzB,AAAiB,QAAkB,EAAE;CAErC,AAAiB,8BAAc,IAAI,KAAyB;CAC5D,AAAQ,gBAAgB;CAExB,AAAS;CACT,YAAY,EAAE,cAAc,OAAO,SAAS,MAAqC;AAC/E,OAAK,UAAU;GACb;GACA;GACD;;CAGH,mBAAmB,WAAmB,WAAmB,WAAW,OAAO;EACzE,MAAM,OAAO,KAAK,YAAY,IAAI,UAAU,IAAI,EAAE;AAClD,OAAK,YAAY,IAAI,WAAW,KAAK;AACrC,MAAI,CAAC,UAAU;AACb,QAAK,2BAAW,IAAI,KAAK;AACzB,QA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QACE,YAAW;;EAGf,MAAM,aAAa,MAAM,KAAK,SAAS,KAAK,QAAQ,QAAQ,SAAS,CAAC;AACtE,SAAO,WAAW,WAAW,MAAM,GAAG,aAAa,KAAK;;CAG1D,WAAW;EACT,MAAM,QAAkB,CAAC,iBAAiB;AAE1C,OAAK,MAAM,CAAC,WAAW,EAAE,YAAY,QAAQ,YAAY,KAAK,aAAa;AACzE,OAAI,WACF,MAAK,MAAM,aAAa,WACtB,OAAM,KACJ,QAAQ,IAAI,UAAU,GAClB,eAAe,UAAU,SAAS,UAAU,MAC5C,oBAAoB,UAAU,SAAS,UAAU,IACtD;AAGL,OAAI,SAAS,MAAM,OAAO,GAAG;IAC3B,MAAM,eAAyB,EAAE;AAEjC,SAAK,MAAM,CAAC,YAAY,eAAe,OAAO;KAC5C,MAAM,OAAO,eAAe,aAAa,aAAa,GAAG,WAAW,MAAM;AAE1E,kBAAa,KAAK,QAAQ,IAAI,WAAW,GAAG,OAAO,QAAQ,OAAO;;AAGpE,UAAM,KAAK,YAAY,aAAa,KAAK,KAAK,CAAC,WAAW,UAAU,IAAI;;;AAI5E,QAAM,KAAK,GAAG,KAAK,MAAM;AACzB,SAAO,MAAM,KAAK,KAAK;;;AAI3B,SAAgB,MAAM,MAAsB;AAG1C,KAF6B,KAAK,WAAW,UAAU,CAGrD,QAAO;AAGT,QAAO,KAAK,WAAW,MAAM,IAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as GetCollectionConfig } from "../../core-
|
|
2
|
-
import "../../load-from-file-
|
|
1
|
+
import { C as GetCollectionConfig } from "../../core-FjA_Xoho.js";
|
|
2
|
+
import "../../load-from-file-CIYdu-B5.js";
|
|
3
3
|
import { DataCollection } from "../data.js";
|
|
4
4
|
import { FileCollectionStore } from "../runtime/file-store.js";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as AsyncPipe } from "../core-
|
|
2
|
-
import "../load-from-file-
|
|
1
|
+
import { m as AsyncPipe } from "../core-FjA_Xoho.js";
|
|
2
|
+
import "../load-from-file-CIYdu-B5.js";
|
|
3
3
|
import { LoaderConfig } from "../plugins/loader/index.js";
|
|
4
4
|
import { FileSystemCollection, FileSystemCollectionConfig } from "./fs.js";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
package/dist/collections/data.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as asyncPipe } from "../pipe-CvCqOpXX.js";
|
|
2
|
-
import { n as slash } from "../code-generator-
|
|
2
|
+
import { n as slash } from "../code-generator-CHcOrCeM.js";
|
|
3
3
|
import { loaderHook } from "../plugins/loader/index.js";
|
|
4
4
|
import { FileSystemCollection } from "./fs.js";
|
|
5
5
|
import path from "node:path";
|
|
@@ -102,7 +102,7 @@ function yamlLoader() {
|
|
|
102
102
|
};
|
|
103
103
|
},
|
|
104
104
|
async createLoader() {
|
|
105
|
-
const { createYamlLoader } = await import("../loader-
|
|
105
|
+
const { createYamlLoader } = await import("../loader-D2BD3e0R.js").then((n) => n.n);
|
|
106
106
|
const core = this.core;
|
|
107
107
|
return createYamlLoader({ getCore: () => core });
|
|
108
108
|
}
|
|
@@ -147,7 +147,7 @@ function jsonLoader() {
|
|
|
147
147
|
};
|
|
148
148
|
},
|
|
149
149
|
async createLoader(environment) {
|
|
150
|
-
const { createJsonLoader } = await import("../loader-
|
|
150
|
+
const { createJsonLoader } = await import("../loader-C5w-u-h2.js").then((n) => n.n);
|
|
151
151
|
const core = this.core;
|
|
152
152
|
return createJsonLoader({ getCore: () => core }, environment === "vite" ? "json" : "js");
|
|
153
153
|
}
|
package/dist/collections/fs.d.ts
CHANGED
package/dist/collections/fs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as ServerContext, i as EmitEntry, l as PluginOption, m as AsyncPipe, r as EmitContext, t as Core, u as ResolvedConfig, v as AsyncHook, y as Hook } from "../core-
|
|
1
|
+
import { f as ServerContext, i as EmitEntry, l as PluginOption, m as AsyncPipe, r as EmitContext, t as Core, u as ResolvedConfig, v as AsyncHook, y as Hook } from "../core-FjA_Xoho.js";
|
|
2
2
|
|
|
3
3
|
//#region src/collections/index.d.ts
|
|
4
4
|
interface CollectionHookContext {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../../core-
|
|
2
|
-
import "../../load-from-file-
|
|
1
|
+
import "../../core-FjA_Xoho.js";
|
|
2
|
+
import "../../load-from-file-CIYdu-B5.js";
|
|
3
3
|
import { WebpackLoader } from "../../plugins/loader/webpack.js";
|
|
4
4
|
|
|
5
5
|
//#region src/collections/json/loader-webpack.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../../validation-C3kXuveD.js";
|
|
2
2
|
import { createWebpackLoader } from "../../plugins/loader/webpack.js";
|
|
3
|
-
import "../../loader-
|
|
4
|
-
import { t as createJsonLoader } from "../../loader-
|
|
3
|
+
import "../../loader-BFfzKD3u.js";
|
|
4
|
+
import { t as createJsonLoader } from "../../loader-C5w-u-h2.js";
|
|
5
5
|
|
|
6
6
|
//#region src/collections/json/loader-webpack.ts
|
|
7
7
|
var loader_webpack_default = createWebpackLoader((core) => createJsonLoader(core, "json"));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../../core-
|
|
2
|
-
import "../../load-from-file-
|
|
1
|
+
import "../../core-FjA_Xoho.js";
|
|
2
|
+
import "../../load-from-file-CIYdu-B5.js";
|
|
3
3
|
import { WebpackLoader } from "../../plugins/loader/webpack.js";
|
|
4
4
|
|
|
5
5
|
//#region src/collections/mdx/loader-webpack.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../../validation-C3kXuveD.js";
|
|
2
|
+
import "../../fuma-matter-CCYGfgju.js";
|
|
2
3
|
import { createWebpackLoader } from "../../plugins/loader/webpack.js";
|
|
3
|
-
import "../../
|
|
4
|
-
import { t as createMdxLoader } from "../../loader-DOjRBsog.js";
|
|
4
|
+
import { t as createMdxLoader } from "../../loader-B3hZ0R4a.js";
|
|
5
5
|
|
|
6
6
|
//#region src/collections/mdx/loader-webpack.ts
|
|
7
7
|
var loader_webpack_default = createWebpackLoader(createMdxLoader);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../../core-
|
|
2
|
-
import "../../
|
|
3
|
-
import
|
|
1
|
+
import "../../core-FjA_Xoho.js";
|
|
2
|
+
import { t as CompiledMDX } from "../../build-mdx-DhXGp7I9.js";
|
|
3
|
+
import "../../async-cache-Ca5oMQss.js";
|
|
4
4
|
import { MDXStoreBrowserData } from "./runtime-browser.js";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","names":[],"sources":["../../../src/collections/mdx/react.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"react.d.ts","names":[],"sources":["../../../src/collections/mdx/react.ts"],"mappings":";;;;;;;;;;;AAkBA;iBAAgB,WAAA,uBAAA,CACd,KAAA,EAAO,mBAAA,CAAoB,WAAA,EAAa,QAAA,eACxC,QAAA,GAAW,IAAA,EAAM,WAAA,CAAY,WAAA,IAAe,QAAA,KAAa,SAAA,GACxD,SAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as isPromiseLike } from "../../is-promise-like-pBUIbRFy.js";
|
|
1
2
|
import { createElement, lazy } from "react";
|
|
2
3
|
|
|
3
4
|
//#region src/collections/mdx/react.ts
|
|
@@ -20,7 +21,7 @@ function useRenderer(entry, renderFn) {
|
|
|
20
21
|
forceOnDemand: false,
|
|
21
22
|
renderJSX() {
|
|
22
23
|
const v = entry.preload();
|
|
23
|
-
if (!(
|
|
24
|
+
if (!isPromiseLike(v) && !this.forceOnDemand) return renderFn(v);
|
|
24
25
|
this.forceOnDemand = true;
|
|
25
26
|
return createElement(OnDemand);
|
|
26
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","names":[],"sources":["../../../src/collections/mdx/react.ts"],"sourcesContent":["import { ReactNode, lazy, createElement } from \"react\";\nimport { CompiledMDX } from \"./build-mdx\";\nimport { MDXStoreBrowserData } from \"./runtime-browser\";\n\nconst renderMap = new Map<\n string,\n {\n renderJSX: () => ReactNode;\n forceOnDemand: boolean;\n }\n>();\n\n/**\n * Renders content (loaded lazily).\n *\n * It is recommended to use with `<Suspense />`.\n */\nexport function useRenderer<Frontmatter, Attached>(\n entry: MDXStoreBrowserData<Frontmatter, Attached> | undefined,\n renderFn: (data: CompiledMDX<Frontmatter> & Attached) => ReactNode,\n): ReactNode {\n if (!entry) return null;\n const renderKey = `${entry._store.storeId}:${entry.id}`;\n let renderInfo = renderMap.get(renderKey);\n\n if (!renderInfo) {\n const OnDemand = lazy(async () => {\n const loaded = await entry.preload();\n return { default: () => renderFn(loaded) };\n });\n\n renderInfo = {\n forceOnDemand: false,\n renderJSX() {\n const v = entry.preload();\n if (!(
|
|
1
|
+
{"version":3,"file":"react.js","names":[],"sources":["../../../src/collections/mdx/react.ts"],"sourcesContent":["import { ReactNode, lazy, createElement } from \"react\";\nimport { CompiledMDX } from \"./build-mdx\";\nimport { MDXStoreBrowserData } from \"./runtime-browser\";\nimport { isPromiseLike } from \"@/utils/is-promise-like\";\n\nconst renderMap = new Map<\n string,\n {\n renderJSX: () => ReactNode;\n forceOnDemand: boolean;\n }\n>();\n\n/**\n * Renders content (loaded lazily).\n *\n * It is recommended to use with `<Suspense />`.\n */\nexport function useRenderer<Frontmatter, Attached>(\n entry: MDXStoreBrowserData<Frontmatter, Attached> | undefined,\n renderFn: (data: CompiledMDX<Frontmatter> & Attached) => ReactNode,\n): ReactNode {\n if (!entry) return null;\n const renderKey = `${entry._store.storeId}:${entry.id}`;\n let renderInfo = renderMap.get(renderKey);\n\n if (!renderInfo) {\n const OnDemand = lazy(async () => {\n const loaded = await entry.preload();\n return { default: () => renderFn(loaded) };\n });\n\n renderInfo = {\n forceOnDemand: false,\n renderJSX() {\n const v = entry.preload();\n if (!isPromiseLike(v) && !this.forceOnDemand) {\n return renderFn(v);\n }\n\n // ensure it won't unmount React lazy during re-renders\n this.forceOnDemand = true;\n return createElement(OnDemand);\n },\n };\n renderMap.set(renderKey, renderInfo);\n }\n\n return renderInfo.renderJSX();\n}\n"],"mappings":";;;;AAKA,MAAM,4BAAY,IAAI,KAMnB;;;;;;AAOH,SAAgB,YACd,OACA,UACW;AACX,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,YAAY,GAAG,MAAM,OAAO,QAAQ,GAAG,MAAM;CACnD,IAAI,aAAa,UAAU,IAAI,UAAU;AAEzC,KAAI,CAAC,YAAY;EACf,MAAM,WAAW,KAAK,YAAY;GAChC,MAAM,SAAS,MAAM,MAAM,SAAS;AACpC,UAAO,EAAE,eAAe,SAAS,OAAO,EAAE;IAC1C;AAEF,eAAa;GACX,eAAe;GACf,YAAY;IACV,MAAM,IAAI,MAAM,SAAS;AACzB,QAAI,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,cAC7B,QAAO,SAAS,EAAE;AAIpB,SAAK,gBAAgB;AACrB,WAAO,cAAc,SAAS;;GAEjC;AACD,YAAU,IAAI,WAAW,WAAW;;AAGtC,QAAO,WAAW,WAAW"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { C as GetCollectionConfig, S as Awaitable } from "../../core-
|
|
2
|
-
import "../../load-from-file-CpA8UQXX.js";
|
|
1
|
+
import { C as GetCollectionConfig, S as Awaitable } from "../../core-FjA_Xoho.js";
|
|
3
2
|
import { MapCollectionStore } from "../runtime/store.js";
|
|
4
|
-
import { t as CompiledMDX } from "../../build-mdx-
|
|
3
|
+
import { t as CompiledMDX } from "../../build-mdx-DhXGp7I9.js";
|
|
5
4
|
import { MDXCollection } from "../mdx.js";
|
|
6
|
-
import { t as AsyncCache } from "../../async-cache-
|
|
5
|
+
import { t as AsyncCache } from "../../async-cache-Ca5oMQss.js";
|
|
7
6
|
import { WithGit } from "./runtime.js";
|
|
8
7
|
|
|
9
8
|
//#region src/collections/mdx/runtime-browser.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-browser.d.ts","names":[],"sources":["../../../src/collections/mdx/runtime-browser.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-browser.d.ts","names":[],"sources":["../../../src/collections/mdx/runtime-browser.ts"],"mappings":";;;;;;;;UAQiB,mBAAA;EACf,EAAA;EACA,OAAA,QAAe,SAAA,CAAU,WAAA,CAAY,WAAA,IAAe,QAAA;EACpD,MAAA,EAAQ,YAAA;AAAA;AAAA,UAGA,YAAA;EACR,OAAA;AAAA;AAAA,UAGQ,SAAA;EACR,SAAA,EAAW,UAAA,CAAW,WAAA;AAAA;AAAA,KAGnB,cAAA,gCACH,mBAAA,CAAoB,MAAA,EAAQ,IAAA,UAAc,aAAA,GACtC,mBAAA,CAAoB,MAAA,EAAQ,IAAA;AAAA,cAGrB,cAAA,EAAc,GAAA,SAAA,SAAA;AAAA,iBAEX,eAAA,uCAAA,CACd,IAAA,EAAM,IAAA,EACN,MAAA,EAAQ,MAAA,eAAqB,OAAA,aAC5B,kBAAA,SAA2B,mBAAA,CAAoB,cAAA,CAAe,MAAA,EAAQ,IAAA,GAAO,QAAA"}
|