fuma-content 1.1.2 → 1.1.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/async-cache-CBEZB25o.d.ts +9 -0
- package/dist/async-cache-CBEZB25o.d.ts.map +1 -0
- package/dist/{async-cache-U87GzQTb.js → async-cache-DRmFaVGm.js} +1 -1
- package/dist/{async-cache-U87GzQTb.js.map → async-cache-DRmFaVGm.js.map} +1 -1
- package/dist/build-mdx-DkAvzRNg.d.ts +73 -0
- package/dist/build-mdx-DkAvzRNg.d.ts.map +1 -0
- package/dist/{build-mdx-CUp6FpfT.js → build-mdx-oug7zk0w.js} +23 -36
- package/dist/build-mdx-oug7zk0w.js.map +1 -0
- package/dist/bun/index.d.ts +1 -1
- package/dist/bun/index.d.ts.map +1 -1
- package/dist/bun/index.js +2 -2
- package/dist/{bun-CBROq3I0.js → bun-cxKGeSx6.js} +1 -1
- package/dist/bun-cxKGeSx6.js.map +1 -0
- package/dist/{code-generator-Qhhq7kHh.js → code-generator-C_Gu9y3h.js} +4 -4
- package/dist/code-generator-C_Gu9y3h.js.map +1 -0
- package/dist/collections/data/runtime.d.ts +3 -6
- package/dist/collections/data/runtime.d.ts.map +1 -1
- package/dist/collections/data/runtime.js.map +1 -1
- package/dist/collections/data.d.ts +4 -4
- package/dist/collections/data.d.ts.map +1 -1
- package/dist/collections/data.js +158 -4
- package/dist/collections/data.js.map +1 -0
- package/dist/collections/fs.d.ts +45 -3
- package/dist/collections/fs.d.ts.map +1 -0
- package/dist/collections/fs.js +65 -2
- package/dist/collections/fs.js.map +1 -0
- package/dist/collections/index.d.ts +37 -2
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/index.js +37 -2
- package/dist/collections/index.js.map +1 -0
- package/dist/collections/json/loader-webpack.d.ts +3 -3
- package/dist/collections/json/loader-webpack.d.ts.map +1 -1
- package/dist/collections/json/loader-webpack.js +3 -7
- package/dist/collections/json/loader-webpack.js.map +1 -1
- package/dist/collections/mdx/loader-webpack.d.ts +3 -3
- package/dist/collections/mdx/loader-webpack.d.ts.map +1 -1
- package/dist/collections/mdx/loader-webpack.js +3 -8
- package/dist/collections/mdx/loader-webpack.js.map +1 -1
- package/dist/collections/mdx/react.d.ts +4 -10
- package/dist/collections/mdx/react.d.ts.map +1 -1
- package/dist/collections/mdx/runtime-browser.d.ts +26 -11
- package/dist/collections/mdx/runtime-browser.d.ts.map +1 -0
- package/dist/collections/mdx/runtime-browser.js +2 -2
- package/dist/collections/mdx/runtime-browser.js.map +1 -1
- package/dist/collections/mdx/runtime-dynamic.d.ts +7 -10
- package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -1
- package/dist/collections/mdx/runtime-dynamic.js +9 -12
- package/dist/collections/mdx/runtime-dynamic.js.map +1 -1
- package/dist/collections/mdx/runtime.d.ts +27 -10
- package/dist/collections/mdx/runtime.d.ts.map +1 -0
- package/dist/collections/mdx/runtime.js.map +1 -1
- package/dist/collections/mdx.d.ts +67 -6
- package/dist/collections/mdx.d.ts.map +1 -0
- package/dist/collections/mdx.js +318 -6
- package/dist/collections/mdx.js.map +1 -0
- package/dist/collections/runtime/file-store.d.ts +21 -4
- package/dist/collections/runtime/file-store.d.ts.map +1 -0
- package/dist/collections/runtime/file-store.js +1 -1
- package/dist/collections/runtime/store.d.ts +31 -3
- package/dist/collections/runtime/store.d.ts.map +1 -0
- package/dist/collections/runtime/store.js +33 -2
- package/dist/collections/runtime/store.js.map +1 -0
- package/dist/collections/yaml/loader-webpack.d.ts +3 -3
- package/dist/collections/yaml/loader-webpack.d.ts.map +1 -1
- package/dist/collections/yaml/loader-webpack.js +3 -7
- package/dist/collections/yaml/loader-webpack.js.map +1 -1
- package/dist/config/index.d.ts +36 -2
- package/dist/config/index.d.ts.map +1 -0
- package/dist/{core-CT06v32N.d.ts → core-CG2zTL4c.d.ts} +4 -66
- package/dist/core-CG2zTL4c.d.ts.map +1 -0
- package/dist/{core-Uv3jZqL-.js → core-DmbQk8Z2.js} +9 -9
- package/dist/core-DmbQk8Z2.js.map +1 -0
- package/dist/dynamic.d.ts +25 -3
- package/dist/dynamic.d.ts.map +1 -0
- package/dist/dynamic.js +28 -2
- package/dist/dynamic.js.map +1 -0
- package/dist/{fuma-matter-BuBO2w-p.js → fuma-matter-Pwr2S9Ab.js} +1 -1
- package/dist/fuma-matter-Pwr2S9Ab.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/{load-from-file-z7EGuf2n.js → load-from-file-BeLFB77e.js} +4 -2
- package/dist/{load-from-file-z7EGuf2n.js.map → load-from-file-BeLFB77e.js.map} +1 -1
- package/dist/load-from-file-CpA8UQXX.d.ts +10 -0
- package/dist/load-from-file-CpA8UQXX.d.ts.map +1 -0
- package/dist/loader-DKTW82eK.js +19 -0
- package/dist/{loader-Cnz-VHne.js.map → loader-DKTW82eK.js.map} +1 -1
- package/dist/{loader-CnksfM7I.js → loader-DOjRBsog.js} +7 -5
- package/dist/loader-DOjRBsog.js.map +1 -0
- package/dist/loader-DTODFdmk.js +18 -0
- package/dist/{loader-BK8PnqRg.js.map → loader-DTODFdmk.js.map} +1 -1
- package/dist/{loader-CuntMmR4.js → loader-gwXIGo5Q.js} +3 -3
- package/dist/loader-gwXIGo5Q.js.map +1 -0
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.d.ts.map +1 -1
- package/dist/next/index.js +3 -3
- package/dist/next/index.js.map +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/loader.d.ts +1 -1
- package/dist/node/loader.d.ts.map +1 -1
- package/dist/node/loader.js +8 -8
- package/dist/node/loader.js.map +1 -1
- package/dist/{node-2VZOh3P9.js → node-l03HaPSS.js} +1 -1
- package/dist/{node-2VZOh3P9.js.map → node-l03HaPSS.js.map} +1 -1
- package/dist/{collections-CNWuMDAZ.js → pipe-CvCqOpXX.js} +2 -36
- package/dist/pipe-CvCqOpXX.js.map +1 -0
- package/dist/plugins/git.d.ts +38 -3
- package/dist/plugins/git.d.ts.map +1 -0
- package/dist/plugins/git.js +60 -2
- package/dist/plugins/git.js.map +1 -0
- package/dist/plugins/json-schema.d.ts +2 -1
- package/dist/plugins/json-schema.d.ts.map +1 -1
- package/dist/plugins/json-schema.js +2 -2
- package/dist/plugins/json-schema.js.map +1 -1
- package/dist/plugins/loader/index.d.ts +75 -4
- package/dist/plugins/loader/index.d.ts.map +1 -0
- package/dist/plugins/loader/index.js +76 -2
- package/dist/plugins/loader/index.js.map +1 -0
- package/dist/plugins/loader/webpack.d.ts +21 -4
- package/dist/plugins/loader/webpack.d.ts.map +1 -0
- package/dist/plugins/loader/webpack.js +4 -4
- package/dist/plugins/loader/webpack.js.map +1 -1
- package/dist/rolldown-runtime-CjeV3_4I.js +18 -0
- package/dist/{validation-BvVvvLII.js → validation-C3kXuveD.js} +1 -1
- package/dist/{validation-BvVvvLII.js.map → validation-C3kXuveD.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 -3
- package/dist/{vite-C1qXY47G.js → vite-mAc2TZyp.js} +3 -3
- package/dist/vite-mAc2TZyp.js.map +1 -0
- package/package.json +19 -10
- package/dist/build-mdx-CUp6FpfT.js.map +0 -1
- package/dist/build-mdx-D6zM3Sgl.js +0 -4
- package/dist/bun-CBROq3I0.js.map +0 -1
- package/dist/code-generator-Qhhq7kHh.js.map +0 -1
- package/dist/collections-CNWuMDAZ.js.map +0 -1
- package/dist/core-CT06v32N.d.ts.map +0 -1
- package/dist/core-Uv3jZqL-.js.map +0 -1
- package/dist/data-Cxsx5KPD.js +0 -159
- package/dist/data-Cxsx5KPD.js.map +0 -1
- package/dist/dynamic-Ck1wYoaL.d.ts +0 -33
- package/dist/dynamic-Ck1wYoaL.d.ts.map +0 -1
- package/dist/dynamic-CtOB4Rkp.js +0 -29
- package/dist/dynamic-CtOB4Rkp.js.map +0 -1
- package/dist/file-store-Dm1SjuLg.d.ts +0 -20
- package/dist/file-store-Dm1SjuLg.d.ts.map +0 -1
- package/dist/fs-CXzVd2Dp.js +0 -68
- package/dist/fs-CXzVd2Dp.js.map +0 -1
- package/dist/fs-CmwaaFyx.d.ts +0 -45
- package/dist/fs-CmwaaFyx.d.ts.map +0 -1
- package/dist/fuma-matter-BuBO2w-p.js.map +0 -1
- package/dist/git-DnejL9r_.js +0 -60
- package/dist/git-DnejL9r_.js.map +0 -1
- package/dist/git-n-9ddn78.d.ts +0 -37
- package/dist/git-n-9ddn78.d.ts.map +0 -1
- package/dist/index-BheUVWBm.d.ts +0 -87
- package/dist/index-BheUVWBm.d.ts.map +0 -1
- package/dist/load-from-file-D-Xm95Fz.js +0 -3
- package/dist/loader-B4nQrRwA.js +0 -77
- package/dist/loader-B4nQrRwA.js.map +0 -1
- package/dist/loader-B6ordrWK.js +0 -9
- package/dist/loader-BK8PnqRg.js +0 -16
- package/dist/loader-CnksfM7I.js.map +0 -1
- package/dist/loader-Cnz-VHne.js +0 -17
- package/dist/loader-CuntMmR4.js.map +0 -1
- package/dist/loader-Cx1Rg_VM.js +0 -8
- package/dist/loader-Dao_nv3e.js +0 -8
- package/dist/mdx-Cw1nBJ0D.js +0 -306
- package/dist/mdx-Cw1nBJ0D.js.map +0 -1
- package/dist/mdx-PaqRNZMS.d.ts +0 -135
- package/dist/mdx-PaqRNZMS.d.ts.map +0 -1
- package/dist/runtime-BUUHSFlR.d.ts +0 -31
- package/dist/runtime-BUUHSFlR.d.ts.map +0 -1
- package/dist/runtime-browser-B70WGxeQ.d.ts +0 -29
- package/dist/runtime-browser-B70WGxeQ.d.ts.map +0 -1
- package/dist/store-CRyvZFKN.js +0 -34
- package/dist/store-CRyvZFKN.js.map +0 -1
- package/dist/store-D_PPrdRE.d.ts +0 -31
- package/dist/store-D_PPrdRE.d.ts.map +0 -1
- package/dist/vite-C1qXY47G.js.map +0 -1
|
@@ -1,6 +1,67 @@
|
|
|
1
|
-
import "../core-
|
|
2
|
-
import "
|
|
3
|
-
import "../
|
|
4
|
-
import "
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { S as Awaitable, h as Pipe, m as AsyncPipe, p as CodeGenerator } from "../core-CG2zTL4c.js";
|
|
2
|
+
import { Collection } from "./index.js";
|
|
3
|
+
import "../load-from-file-CpA8UQXX.js";
|
|
4
|
+
import { FileSystemCollection, FileSystemCollectionConfig } from "./fs.js";
|
|
5
|
+
import { n as LinkReference, r as PostprocessOptions, t as CompiledMDX } from "../build-mdx-DkAvzRNg.js";
|
|
6
|
+
import { ProcessorOptions } from "@mdx-js/mdx";
|
|
7
|
+
import { VFile } from "vfile";
|
|
8
|
+
import { PluggableList } from "unified";
|
|
9
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
10
|
+
|
|
11
|
+
//#region src/collections/mdx.d.ts
|
|
12
|
+
interface CompilationContext {
|
|
13
|
+
collection: Collection;
|
|
14
|
+
filePath: string;
|
|
15
|
+
source: string;
|
|
16
|
+
}
|
|
17
|
+
interface MDXCollectionConfig<FrontmatterSchema extends StandardSchemaV1 | undefined> extends Omit<FileSystemCollectionConfig, "supportedFormats"> {
|
|
18
|
+
postprocess?: Partial<PostprocessOptions>;
|
|
19
|
+
preprocess?: PreprocessOptions;
|
|
20
|
+
frontmatter?: FrontmatterSchema;
|
|
21
|
+
options?: (environment: "bundler" | "runtime") => Awaitable<ProcessorOptions>;
|
|
22
|
+
lazy?: boolean;
|
|
23
|
+
dynamic?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface PreprocessOptions {
|
|
26
|
+
remarkPlugins?: PluggableList;
|
|
27
|
+
}
|
|
28
|
+
interface InitializerCode {
|
|
29
|
+
fn: string;
|
|
30
|
+
typeParams: [config: string, name: string, attached: string];
|
|
31
|
+
params: string[];
|
|
32
|
+
}
|
|
33
|
+
declare class MDXCollection<FrontmatterSchema extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined> extends FileSystemCollection {
|
|
34
|
+
#private;
|
|
35
|
+
readonly dynamic: boolean;
|
|
36
|
+
readonly lazy: boolean;
|
|
37
|
+
readonly preprocess?: PreprocessOptions;
|
|
38
|
+
readonly postprocess?: Partial<PostprocessOptions>;
|
|
39
|
+
readonly getMDXOptions?: (environment: "bundler" | "runtime") => Awaitable<ProcessorOptions>;
|
|
40
|
+
/**
|
|
41
|
+
* Frontmatter schema
|
|
42
|
+
*/
|
|
43
|
+
frontmatterSchema?: FrontmatterSchema;
|
|
44
|
+
/**
|
|
45
|
+
* Transform & validate frontmatter
|
|
46
|
+
*/
|
|
47
|
+
frontmatter: AsyncPipe<Record<string, unknown> | undefined, CompilationContext>;
|
|
48
|
+
/**
|
|
49
|
+
* Transform `vfile` on compilation stage
|
|
50
|
+
*/
|
|
51
|
+
vfile: AsyncPipe<VFile, CompilationContext>;
|
|
52
|
+
/**
|
|
53
|
+
* Transform the generated initializer code (TypeScript) for collection store
|
|
54
|
+
*/
|
|
55
|
+
storeInitializer: Pipe<InitializerCode, {
|
|
56
|
+
codegen: CodeGenerator;
|
|
57
|
+
environment: "browser" | "server" | "dynamic";
|
|
58
|
+
}>;
|
|
59
|
+
$inferFrontmatter: FrontmatterSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<FrontmatterSchema> : Record<string, unknown>;
|
|
60
|
+
constructor(config: MDXCollectionConfig<FrontmatterSchema>);
|
|
61
|
+
private generateDocCollectionFrontmatterGlob;
|
|
62
|
+
private generateDocCollectionGlob;
|
|
63
|
+
}
|
|
64
|
+
declare function mdxCollection<FrontmatterSchema extends StandardSchemaV1 | undefined = undefined>(config: MDXCollectionConfig<FrontmatterSchema>): MDXCollection<FrontmatterSchema>;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { type CompiledMDX, type LinkReference, MDXCollection, MDXCollectionConfig, mdxCollection };
|
|
67
|
+
//# sourceMappingURL=mdx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx.d.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,iBAAA"}
|
package/dist/collections/mdx.js
CHANGED
|
@@ -1,7 +1,319 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import {
|
|
1
|
+
import { n as pipe, t as asyncPipe } from "../pipe-CvCqOpXX.js";
|
|
2
|
+
import { n as slash } from "../code-generator-C_Gu9y3h.js";
|
|
3
|
+
import { r as validate } from "../validation-C3kXuveD.js";
|
|
4
|
+
import { loaderHook } from "../plugins/loader/index.js";
|
|
5
|
+
import { FileSystemCollection } from "./fs.js";
|
|
6
|
+
import { gitHook } from "../plugins/git.js";
|
|
7
|
+
import path from "node:path";
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
//#region src/collections/mdx.ts
|
|
10
|
+
const RuntimePaths = {
|
|
11
|
+
browser: "fuma-content/collections/mdx/runtime-browser",
|
|
12
|
+
dynamic: "fuma-content/collections/mdx/runtime-dynamic",
|
|
13
|
+
server: "fuma-content/collections/mdx/runtime"
|
|
14
|
+
};
|
|
15
|
+
function formatInitializer(code) {
|
|
16
|
+
return `${code.fn}<${code.typeParams.join()}>(${code.params.join()})`;
|
|
17
|
+
}
|
|
18
|
+
var MDXCollection = class extends FileSystemCollection {
|
|
19
|
+
dynamic;
|
|
20
|
+
lazy;
|
|
21
|
+
preprocess;
|
|
22
|
+
postprocess;
|
|
23
|
+
getMDXOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Frontmatter schema
|
|
26
|
+
*/
|
|
27
|
+
frontmatterSchema;
|
|
28
|
+
/**
|
|
29
|
+
* Transform & validate frontmatter
|
|
30
|
+
*/
|
|
31
|
+
frontmatter = asyncPipe();
|
|
32
|
+
/**
|
|
33
|
+
* Transform `vfile` on compilation stage
|
|
34
|
+
*/
|
|
35
|
+
vfile = asyncPipe();
|
|
36
|
+
/**
|
|
37
|
+
* Transform the generated initializer code (TypeScript) for collection store
|
|
38
|
+
*/
|
|
39
|
+
storeInitializer = pipe();
|
|
40
|
+
$inferFrontmatter = void 0;
|
|
41
|
+
constructor(config) {
|
|
42
|
+
super({
|
|
43
|
+
dir: config.dir,
|
|
44
|
+
files: config.files,
|
|
45
|
+
supportedFormats: ["md", "mdx"]
|
|
46
|
+
});
|
|
47
|
+
this.postprocess = config.postprocess;
|
|
48
|
+
this.preprocess = config.preprocess;
|
|
49
|
+
this.getMDXOptions = config.options;
|
|
50
|
+
this.dynamic = config.dynamic ?? false;
|
|
51
|
+
this.lazy = config.lazy ?? false;
|
|
52
|
+
this.frontmatterSchema = config.frontmatter;
|
|
53
|
+
this.frontmatter.pipe(this.#onFrontmatter.bind(this));
|
|
54
|
+
this.onServer.hook(this.#onServerHandler.bind(this));
|
|
55
|
+
this.onEmit.pipe(this.#onEmitHandler.bind(this));
|
|
56
|
+
this.pluginHook(loaderHook).loaders.push(mdxLoader());
|
|
57
|
+
this.pluginHook(gitHook).onClient.hook(this.#onGitHandler.bind(this));
|
|
58
|
+
if (this.postprocess) {
|
|
59
|
+
const { processedMarkdown, linkReferences, mdast } = this.postprocess;
|
|
60
|
+
if (processedMarkdown) {
|
|
61
|
+
const { as = "_markdown" } = processedMarkdown === true ? {} : processedMarkdown;
|
|
62
|
+
this.storeInitializer.pipe((code) => {
|
|
63
|
+
code.typeParams[2] += ` & { /** Processed Markdown */ ${as}: string; }`;
|
|
64
|
+
return code;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (mdast) {
|
|
68
|
+
const { as = "_mdast" } = mdast === true ? {} : mdast;
|
|
69
|
+
this.storeInitializer.pipe((code) => {
|
|
70
|
+
code.typeParams[2] += ` & { /** MDAST (as JSON string) */ ${as}: string; }`;
|
|
71
|
+
return code;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (linkReferences) {
|
|
75
|
+
const { as = "_linkReferences" } = linkReferences === true ? {} : linkReferences;
|
|
76
|
+
this.storeInitializer.pipe((code, { codegen }) => {
|
|
77
|
+
codegen.addNamedImport(["LinkReference"], "fuma-content/collections/mdx", true);
|
|
78
|
+
code.typeParams[2] += ` & { /** extracted link references (e.g. hrefs, paths), useful for analyzing relationships between pages. */ ${as}: LinkReference[] }`;
|
|
79
|
+
return code;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
#onFrontmatter = (data, { filePath }) => {
|
|
85
|
+
if (!this.frontmatterSchema) return data;
|
|
86
|
+
return validate(this.frontmatterSchema, data, void 0, `invalid frontmatter in ${filePath}`);
|
|
87
|
+
};
|
|
88
|
+
#onServerHandler = ({ server, core }) => {
|
|
89
|
+
if (!server.watcher) return;
|
|
90
|
+
server.watcher.on("all", async (event, file) => {
|
|
91
|
+
if (event === "change" && !this.dynamic) return;
|
|
92
|
+
if (!this.hasFile(file)) return;
|
|
93
|
+
await core.emit({
|
|
94
|
+
filterCollection: (item) => item === this,
|
|
95
|
+
filterWorkspace: () => false,
|
|
96
|
+
write: true
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
#onEmitHandler = async (entries, { core, createCodeGenerator }) => {
|
|
101
|
+
entries.push(await createCodeGenerator(`${this.name}.ts`, async ({ codegen }) => {
|
|
102
|
+
const runtimePath = RuntimePaths.server;
|
|
103
|
+
const base = slash(core._toRuntimePath(this.dir));
|
|
104
|
+
let code;
|
|
105
|
+
codegen.addNamespaceImport("Config", codegen.formatImportPath(core.getOptions().configPath), true);
|
|
106
|
+
if (this.lazy) {
|
|
107
|
+
codegen.addNamedImport(["mdxStoreLazy"], runtimePath);
|
|
108
|
+
const headGlob = await this.generateDocCollectionFrontmatterGlob(core, codegen, true);
|
|
109
|
+
const bodyGlob = await this.generateDocCollectionGlob(core, codegen);
|
|
110
|
+
code = {
|
|
111
|
+
fn: "mdxStoreLazy",
|
|
112
|
+
typeParams: [
|
|
113
|
+
"typeof Config",
|
|
114
|
+
`"${this.name}"`,
|
|
115
|
+
"unknown"
|
|
116
|
+
],
|
|
117
|
+
params: [
|
|
118
|
+
`"${this.name}"`,
|
|
119
|
+
`"${base}"`,
|
|
120
|
+
`{ head: ${headGlob}, body: ${bodyGlob} }`
|
|
121
|
+
]
|
|
122
|
+
};
|
|
123
|
+
} else {
|
|
124
|
+
codegen.addNamedImport(["mdxStore"], runtimePath);
|
|
125
|
+
code = {
|
|
126
|
+
fn: "mdxStore",
|
|
127
|
+
typeParams: [
|
|
128
|
+
"typeof Config",
|
|
129
|
+
`"${this.name}"`,
|
|
130
|
+
"unknown"
|
|
131
|
+
],
|
|
132
|
+
params: [
|
|
133
|
+
`"${this.name}"`,
|
|
134
|
+
`"${base}"`,
|
|
135
|
+
await this.generateDocCollectionGlob(core, codegen, true)
|
|
136
|
+
]
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
code = this.storeInitializer.run(code, {
|
|
140
|
+
codegen,
|
|
141
|
+
environment: "server"
|
|
142
|
+
});
|
|
143
|
+
codegen.push(`export const ${this.name} = ${formatInitializer(code)};`);
|
|
144
|
+
}), await createCodeGenerator(`${this.name}.browser.ts`, async ({ codegen }) => {
|
|
145
|
+
const runtimePath = RuntimePaths.browser;
|
|
146
|
+
codegen.addNamedImport(["mdxStoreBrowser"], runtimePath);
|
|
147
|
+
codegen.addNamespaceImport("Config", codegen.formatImportPath(core.getOptions().configPath), true);
|
|
148
|
+
let code = {
|
|
149
|
+
fn: `mdxStoreBrowser`,
|
|
150
|
+
typeParams: [
|
|
151
|
+
"typeof Config",
|
|
152
|
+
`"${this.name}"`,
|
|
153
|
+
"unknown"
|
|
154
|
+
],
|
|
155
|
+
params: [`"${this.name}"`, await this.generateDocCollectionGlob(core, codegen)]
|
|
156
|
+
};
|
|
157
|
+
code = this.storeInitializer.run(code, {
|
|
158
|
+
codegen,
|
|
159
|
+
environment: "browser"
|
|
160
|
+
});
|
|
161
|
+
codegen.push(`export const ${this.name} = ${formatInitializer(code)};`);
|
|
162
|
+
}));
|
|
163
|
+
if (this.dynamic) entries.push(await createCodeGenerator(`${this.name}.dynamic.ts`, async ({ codegen }) => {
|
|
164
|
+
const coreOptions = core.getOptions();
|
|
165
|
+
const runtimePath = RuntimePaths.dynamic;
|
|
166
|
+
const base = slash(core._toRuntimePath(this.dir));
|
|
167
|
+
codegen.addNamespaceImport("Config", codegen.formatImportPath(coreOptions.configPath));
|
|
168
|
+
codegen.addNamedImport(["mdxStoreDynamic"], runtimePath);
|
|
169
|
+
const serializableCoreOptions = {
|
|
170
|
+
configPath: core._toRuntimePath(coreOptions.configPath),
|
|
171
|
+
outDir: core._toRuntimePath(coreOptions.outDir),
|
|
172
|
+
cwd: core._toRuntimePath(coreOptions.cwd)
|
|
173
|
+
};
|
|
174
|
+
const jsxImportSource = (await this.getMDXOptions?.("runtime"))?.jsxImportSource ?? "react";
|
|
175
|
+
if (!jsxImportSource) throw new Error(`[Fuma Content] "jsxImportSource" is required for dynamic MDX collection "${this.name}".`);
|
|
176
|
+
codegen.addNamespaceImport("_jsx_runtime", `${jsxImportSource}/jsx-runtime`);
|
|
177
|
+
let code = {
|
|
178
|
+
fn: "mdxStoreDynamic",
|
|
179
|
+
typeParams: [
|
|
180
|
+
"typeof Config",
|
|
181
|
+
`"${this.name}"`,
|
|
182
|
+
"unknown"
|
|
183
|
+
],
|
|
184
|
+
params: [
|
|
185
|
+
"Config",
|
|
186
|
+
JSON.stringify(serializableCoreOptions),
|
|
187
|
+
`"${this.name}"`,
|
|
188
|
+
`"${base}"`,
|
|
189
|
+
await this.generateDocCollectionFrontmatterGlob(core, codegen, true),
|
|
190
|
+
"_jsx_runtime"
|
|
191
|
+
]
|
|
192
|
+
};
|
|
193
|
+
code = this.storeInitializer.run(code, {
|
|
194
|
+
codegen,
|
|
195
|
+
environment: "dynamic"
|
|
196
|
+
});
|
|
197
|
+
codegen.push(`export const ${this.name} = ${formatInitializer(code)};`);
|
|
198
|
+
}));
|
|
199
|
+
return entries;
|
|
200
|
+
};
|
|
201
|
+
#onGitHandler = async ({ client }) => {
|
|
202
|
+
this.storeInitializer.pipe((code, { codegen, environment }) => {
|
|
203
|
+
codegen.addNamedImport(["WithGit"], RuntimePaths[environment], true);
|
|
204
|
+
code.typeParams[2] += " & WithGit";
|
|
205
|
+
return code;
|
|
206
|
+
});
|
|
207
|
+
this.vfile.pipe(async (file) => {
|
|
208
|
+
const vcData = await client.getFileData({ filePath: file.path });
|
|
209
|
+
file.data["mdx-export"] ??= [];
|
|
210
|
+
file.data["mdx-export"].push({
|
|
211
|
+
name: "lastModified",
|
|
212
|
+
value: vcData.lastModified
|
|
213
|
+
}, {
|
|
214
|
+
name: "creationDate",
|
|
215
|
+
value: vcData.creationDate
|
|
216
|
+
});
|
|
217
|
+
return file;
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
async generateDocCollectionFrontmatterGlob(core, codegen, eager = false) {
|
|
221
|
+
let s = `{`;
|
|
222
|
+
const files = await this.getFiles();
|
|
223
|
+
const query = codegen.formatQuery({
|
|
224
|
+
collection: this.name,
|
|
225
|
+
only: "frontmatter",
|
|
226
|
+
workspace: core.getWorkspace()?.name
|
|
227
|
+
});
|
|
228
|
+
for (const file of files) {
|
|
229
|
+
const fullPath = path.join(this.dir, file);
|
|
230
|
+
const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;
|
|
231
|
+
if (eager) {
|
|
232
|
+
const name = codegen.generateImportName();
|
|
233
|
+
codegen.addNamedImport([`frontmatter as ${name}`], specifier);
|
|
234
|
+
s += `"${slash(file)}": ${name},`;
|
|
235
|
+
} else s += `"${slash(file)}": () => ${codegen.formatDynamicImport(specifier, "frontmatter")},`;
|
|
236
|
+
}
|
|
237
|
+
s += "}";
|
|
238
|
+
return s;
|
|
239
|
+
}
|
|
240
|
+
async generateDocCollectionGlob(core, codegen, eager = false) {
|
|
241
|
+
let s = `{`;
|
|
242
|
+
const files = await this.getFiles();
|
|
243
|
+
const query = codegen.formatQuery({
|
|
244
|
+
collection: this.name,
|
|
245
|
+
workspace: core.getWorkspace()?.name
|
|
246
|
+
});
|
|
247
|
+
for (const file of files) {
|
|
248
|
+
const fullPath = path.join(this.dir, file);
|
|
249
|
+
const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;
|
|
250
|
+
if (eager) {
|
|
251
|
+
const name = codegen.generateImportName();
|
|
252
|
+
codegen.addNamespaceImport(name, specifier);
|
|
253
|
+
s += `"${slash(file)}": ${name},`;
|
|
254
|
+
} else s += `"${slash(file)}": () => ${codegen.formatDynamicImport(specifier)},`;
|
|
255
|
+
}
|
|
256
|
+
s += "}";
|
|
257
|
+
return s;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
function mdxCollection(config) {
|
|
261
|
+
return new MDXCollection(config);
|
|
262
|
+
}
|
|
263
|
+
function mdxLoader() {
|
|
264
|
+
const test = /\.mdx?(\?.+?)?$/;
|
|
265
|
+
return {
|
|
266
|
+
id: "mdx",
|
|
267
|
+
test,
|
|
268
|
+
configureNext(nextConfig) {
|
|
269
|
+
const loaderPath = "fuma-content/collections/mdx/loader-webpack";
|
|
270
|
+
const loaderOptions = this.getLoaderOptions();
|
|
271
|
+
return {
|
|
272
|
+
...nextConfig,
|
|
273
|
+
turbopack: {
|
|
274
|
+
...nextConfig.turbopack,
|
|
275
|
+
rules: {
|
|
276
|
+
...nextConfig.turbopack?.rules,
|
|
277
|
+
"*.{md,mdx}": {
|
|
278
|
+
loaders: [{
|
|
279
|
+
loader: loaderPath,
|
|
280
|
+
options: loaderOptions
|
|
281
|
+
}],
|
|
282
|
+
as: "*.js"
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
pageExtensions: [
|
|
287
|
+
...nextConfig.pageExtensions ?? [
|
|
288
|
+
"js",
|
|
289
|
+
"jsx",
|
|
290
|
+
"tsx",
|
|
291
|
+
"ts"
|
|
292
|
+
],
|
|
293
|
+
"mdx",
|
|
294
|
+
"md"
|
|
295
|
+
],
|
|
296
|
+
webpack(config, options) {
|
|
297
|
+
config.module ||= {};
|
|
298
|
+
config.module.rules ||= [];
|
|
299
|
+
config.module.rules.push({
|
|
300
|
+
test,
|
|
301
|
+
use: [options.defaultLoaders.babel, {
|
|
302
|
+
loader: loaderPath,
|
|
303
|
+
options: loaderOptions
|
|
304
|
+
}]
|
|
305
|
+
});
|
|
306
|
+
return nextConfig.webpack?.(config, options) ?? config;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
},
|
|
310
|
+
async createLoader() {
|
|
311
|
+
const { createMdxLoader } = await import("../loader-DOjRBsog.js").then((n) => n.n);
|
|
312
|
+
return createMdxLoader({ getCore: () => this.core });
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
//#endregion
|
|
318
|
+
export { MDXCollection, mdxCollection };
|
|
319
|
+
//# sourceMappingURL=mdx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx.js","names":["#onFrontmatter","#onServerHandler","#onEmitHandler","#onGitHandler"],"sources":["../../src/collections/mdx.ts"],"sourcesContent":["import type { Collection } from \"@/collections\";\nimport type { PostprocessOptions } from \"@/collections/mdx/remark-postprocess\";\nimport type { Core, CoreOptions } from \"@/core\";\nimport type { ProcessorOptions } from \"@mdx-js/mdx\";\nimport type { VFile } from \"vfile\";\nimport type { TurbopackLoaderOptions } from \"next/dist/server/config-shared\";\nimport type { Configuration } from \"webpack\";\nimport { LoaderConfig, loaderHook } from \"@/plugins/loader\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { CodeGenerator, slash } from \"@/utils/code-generator\";\nimport { validate } from \"@/utils/validation\";\nimport type { Awaitable } from \"@/types\";\nimport { asyncPipe, pipe } from \"@/utils/pipe\";\nimport { FileSystemCollection, FileSystemCollectionConfig } from \"./fs\";\nimport { GitHook, gitHook } from \"@/plugins/git\";\nimport path from \"node:path\";\nimport type { PluggableList } from \"unified\";\n\ninterface CompilationContext {\n collection: Collection;\n filePath: string;\n source: string;\n}\n\nexport interface MDXCollectionConfig<\n FrontmatterSchema extends StandardSchemaV1 | undefined,\n> extends Omit<FileSystemCollectionConfig, \"supportedFormats\"> {\n postprocess?: Partial<PostprocessOptions>;\n preprocess?: PreprocessOptions;\n frontmatter?: FrontmatterSchema;\n options?: (environment: \"bundler\" | \"runtime\") => Awaitable<ProcessorOptions>;\n lazy?: boolean;\n dynamic?: boolean;\n}\n\ninterface PreprocessOptions {\n remarkPlugins?: PluggableList;\n}\n\nconst RuntimePaths = {\n browser: \"fuma-content/collections/mdx/runtime-browser\",\n dynamic: \"fuma-content/collections/mdx/runtime-dynamic\",\n server: \"fuma-content/collections/mdx/runtime\",\n};\n\ninterface InitializerCode {\n fn: string;\n typeParams: [config: string, name: string, attached: string];\n params: string[];\n}\n\nfunction formatInitializer(code: InitializerCode) {\n return `${code.fn}<${code.typeParams.join()}>(${code.params.join()})`;\n}\n\nexport class MDXCollection<\n FrontmatterSchema extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined,\n> extends FileSystemCollection {\n readonly dynamic: boolean;\n readonly lazy: boolean;\n readonly preprocess?: PreprocessOptions;\n readonly postprocess?: Partial<PostprocessOptions>;\n readonly getMDXOptions?: (environment: \"bundler\" | \"runtime\") => Awaitable<ProcessorOptions>;\n /**\n * Frontmatter schema\n */\n frontmatterSchema?: FrontmatterSchema;\n /**\n * Transform & validate frontmatter\n */\n frontmatter = asyncPipe<Record<string, unknown> | undefined, CompilationContext>();\n /**\n * Transform `vfile` on compilation stage\n */\n vfile = asyncPipe<VFile, CompilationContext>();\n /**\n * Transform the generated initializer code (TypeScript) for collection store\n */\n storeInitializer = pipe<\n InitializerCode,\n {\n codegen: CodeGenerator;\n environment: \"browser\" | \"server\" | \"dynamic\";\n }\n >();\n\n $inferFrontmatter: FrontmatterSchema extends StandardSchemaV1\n ? StandardSchemaV1.InferOutput<FrontmatterSchema>\n : Record<string, unknown> = undefined as never;\n\n constructor(config: MDXCollectionConfig<FrontmatterSchema>) {\n super({\n dir: config.dir,\n files: config.files,\n supportedFormats: [\"md\", \"mdx\"],\n });\n this.postprocess = config.postprocess;\n this.preprocess = config.preprocess;\n this.getMDXOptions = config.options;\n this.dynamic = config.dynamic ?? false;\n this.lazy = config.lazy ?? false;\n this.frontmatterSchema = config.frontmatter;\n this.frontmatter.pipe(this.#onFrontmatter.bind(this));\n this.onServer.hook(this.#onServerHandler.bind(this));\n this.onEmit.pipe(this.#onEmitHandler.bind(this));\n this.pluginHook(loaderHook).loaders.push(mdxLoader());\n this.pluginHook(gitHook).onClient.hook(this.#onGitHandler.bind(this));\n\n if (this.postprocess) {\n const { processedMarkdown, linkReferences, mdast } = this.postprocess;\n\n if (processedMarkdown) {\n const { as = \"_markdown\" } = processedMarkdown === true ? {} : processedMarkdown;\n\n this.storeInitializer.pipe((code) => {\n code.typeParams[2] += ` & { /** Processed Markdown */ ${as}: string; }`;\n return code;\n });\n }\n\n if (mdast) {\n const { as = \"_mdast\" } = mdast === true ? {} : mdast;\n\n this.storeInitializer.pipe((code) => {\n code.typeParams[2] += ` & { /** MDAST (as JSON string) */ ${as}: string; }`;\n return code;\n });\n }\n\n if (linkReferences) {\n const { as = \"_linkReferences\" } = linkReferences === true ? {} : linkReferences;\n\n this.storeInitializer.pipe((code, { codegen }) => {\n codegen.addNamedImport([\"LinkReference\"], \"fuma-content/collections/mdx\", true);\n code.typeParams[2] += ` & { /** extracted link references (e.g. hrefs, paths), useful for analyzing relationships between pages. */ ${as}: LinkReference[] }`;\n return code;\n });\n }\n }\n }\n\n #onFrontmatter: (typeof this.frontmatter)[\"$inferHandler\"] = (data, { filePath }) => {\n if (!this.frontmatterSchema) return data;\n\n return validate(\n this.frontmatterSchema,\n data,\n undefined,\n `invalid frontmatter in ${filePath}`,\n ) as Promise<Record<string, unknown>>;\n };\n\n #onServerHandler: (typeof this.onServer)[\"$inferHandler\"] = ({ server, core }) => {\n if (!server.watcher) return;\n\n server.watcher.on(\"all\", async (event, file) => {\n if (event === \"change\" && !this.dynamic) return;\n if (!this.hasFile(file)) return;\n\n await core.emit({\n filterCollection: (item) => item === this,\n filterWorkspace: () => false,\n write: true,\n });\n });\n };\n\n #onEmitHandler: (typeof this.onEmit)[\"$inferHandler\"] = async (\n entries,\n { core, createCodeGenerator },\n ) => {\n entries.push(\n await createCodeGenerator(`${this.name}.ts`, async ({ codegen }) => {\n const runtimePath = RuntimePaths.server;\n const base = slash(core._toRuntimePath(this.dir));\n let code: InitializerCode;\n codegen.addNamespaceImport(\n \"Config\",\n codegen.formatImportPath(core.getOptions().configPath),\n true,\n );\n\n if (this.lazy) {\n codegen.addNamedImport([\"mdxStoreLazy\"], runtimePath);\n const headGlob = await this.generateDocCollectionFrontmatterGlob(core, codegen, true);\n const bodyGlob = await this.generateDocCollectionGlob(core, codegen);\n\n code = {\n fn: \"mdxStoreLazy\",\n typeParams: [\"typeof Config\", `\"${this.name}\"`, \"unknown\"],\n params: [`\"${this.name}\"`, `\"${base}\"`, `{ head: ${headGlob}, body: ${bodyGlob} }`],\n };\n } else {\n codegen.addNamedImport([\"mdxStore\"], runtimePath);\n code = {\n fn: \"mdxStore\",\n typeParams: [\"typeof Config\", `\"${this.name}\"`, \"unknown\"],\n params: [\n `\"${this.name}\"`,\n `\"${base}\"`,\n await this.generateDocCollectionGlob(core, codegen, true),\n ],\n };\n }\n\n code = this.storeInitializer.run(code, {\n codegen,\n environment: \"server\",\n });\n codegen.push(`export const ${this.name} = ${formatInitializer(code)};`);\n }),\n await createCodeGenerator(`${this.name}.browser.ts`, async ({ codegen }) => {\n const runtimePath = RuntimePaths.browser;\n codegen.addNamedImport([\"mdxStoreBrowser\"], runtimePath);\n codegen.addNamespaceImport(\n \"Config\",\n codegen.formatImportPath(core.getOptions().configPath),\n true,\n );\n\n let code: InitializerCode = {\n fn: `mdxStoreBrowser`,\n typeParams: [\"typeof Config\", `\"${this.name}\"`, \"unknown\"],\n params: [`\"${this.name}\"`, await this.generateDocCollectionGlob(core, codegen)],\n };\n code = this.storeInitializer.run(code, {\n codegen,\n environment: \"browser\",\n });\n codegen.push(`export const ${this.name} = ${formatInitializer(code)};`);\n }),\n );\n if (this.dynamic)\n entries.push(\n await createCodeGenerator(`${this.name}.dynamic.ts`, async ({ codegen }) => {\n const coreOptions = core.getOptions();\n const runtimePath = RuntimePaths.dynamic;\n const base = slash(core._toRuntimePath(this.dir));\n codegen.addNamespaceImport(\"Config\", codegen.formatImportPath(coreOptions.configPath));\n codegen.addNamedImport([\"mdxStoreDynamic\"], runtimePath);\n\n const serializableCoreOptions: CoreOptions = {\n configPath: core._toRuntimePath(coreOptions.configPath),\n outDir: core._toRuntimePath(coreOptions.outDir),\n cwd: core._toRuntimePath(coreOptions.cwd),\n };\n\n const jsxImportSource =\n (await this.getMDXOptions?.(\"runtime\"))?.jsxImportSource ?? \"react\";\n if (!jsxImportSource)\n throw new Error(\n `[Fuma Content] \"jsxImportSource\" is required for dynamic MDX collection \"${this.name}\".`,\n );\n codegen.addNamespaceImport(\"_jsx_runtime\", `${jsxImportSource}/jsx-runtime`);\n\n let code: InitializerCode = {\n fn: \"mdxStoreDynamic\",\n typeParams: [\"typeof Config\", `\"${this.name}\"`, \"unknown\"],\n params: [\n \"Config\",\n JSON.stringify(serializableCoreOptions),\n `\"${this.name}\"`,\n `\"${base}\"`,\n await this.generateDocCollectionFrontmatterGlob(core, codegen, true),\n \"_jsx_runtime\",\n ],\n };\n\n code = this.storeInitializer.run(code, {\n codegen,\n environment: \"dynamic\",\n });\n codegen.push(`export const ${this.name} = ${formatInitializer(code)};`);\n }),\n );\n return entries;\n };\n\n #onGitHandler: GitHook[\"onClient\"][\"$inferHandler\"] = async ({ client }) => {\n this.storeInitializer.pipe((code, { codegen, environment }) => {\n codegen.addNamedImport([\"WithGit\"], RuntimePaths[environment], true);\n code.typeParams[2] += \" & WithGit\";\n return code;\n });\n\n this.vfile.pipe(async (file) => {\n const vcData = await client.getFileData({ filePath: file.path });\n file.data[\"mdx-export\"] ??= [];\n file.data[\"mdx-export\"].push(\n {\n name: \"lastModified\",\n value: vcData.lastModified,\n },\n {\n name: \"creationDate\",\n value: vcData.creationDate,\n },\n );\n return file;\n });\n };\n\n private async generateDocCollectionFrontmatterGlob(\n core: Core,\n codegen: CodeGenerator,\n eager = false,\n ) {\n let s = `{`;\n const files = await this.getFiles();\n const query = codegen.formatQuery({\n collection: this.name,\n only: \"frontmatter\",\n workspace: core.getWorkspace()?.name,\n });\n for (const file of files) {\n const fullPath = path.join(this.dir, file);\n const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;\n if (eager) {\n const name = codegen.generateImportName();\n codegen.addNamedImport([`frontmatter as ${name}`], specifier);\n s += `\"${slash(file)}\": ${name},`;\n } else {\n s += `\"${slash(file)}\": () => ${codegen.formatDynamicImport(specifier, \"frontmatter\")},`;\n }\n }\n s += \"}\";\n return s;\n }\n\n private async generateDocCollectionGlob(core: Core, codegen: CodeGenerator, eager = false) {\n let s = `{`;\n const files = await this.getFiles();\n const query = codegen.formatQuery({\n collection: this.name,\n workspace: core.getWorkspace()?.name,\n });\n for (const file of files) {\n const fullPath = path.join(this.dir, file);\n const specifier = `${codegen.formatImportPath(fullPath)}?${query}`;\n if (eager) {\n const name = codegen.generateImportName();\n codegen.addNamespaceImport(name, specifier);\n s += `\"${slash(file)}\": ${name},`;\n } else {\n s += `\"${slash(file)}\": () => ${codegen.formatDynamicImport(specifier)},`;\n }\n }\n s += \"}\";\n return s;\n }\n}\n\nexport function mdxCollection<FrontmatterSchema extends StandardSchemaV1 | undefined = undefined>(\n config: MDXCollectionConfig<FrontmatterSchema>,\n) {\n return new MDXCollection(config);\n}\n\nfunction mdxLoader(): LoaderConfig {\n const test = /\\.mdx?(\\?.+?)?$/;\n\n return {\n id: \"mdx\",\n test,\n configureNext(nextConfig) {\n const loaderPath = \"fuma-content/collections/mdx/loader-webpack\";\n const loaderOptions = this.getLoaderOptions();\n\n return {\n ...nextConfig,\n turbopack: {\n ...nextConfig.turbopack,\n rules: {\n ...nextConfig.turbopack?.rules,\n \"*.{md,mdx}\": {\n loaders: [\n {\n loader: loaderPath,\n options: loaderOptions as unknown as TurbopackLoaderOptions,\n },\n ],\n as: \"*.js\",\n },\n },\n },\n pageExtensions: [...(nextConfig.pageExtensions ?? [\"js\", \"jsx\", \"tsx\", \"ts\"]), \"mdx\", \"md\"],\n webpack(config: Configuration, options) {\n config.module ||= {};\n config.module.rules ||= [];\n config.module.rules.push({\n test,\n use: [\n options.defaultLoaders.babel,\n {\n loader: loaderPath,\n options: loaderOptions,\n },\n ],\n });\n\n return nextConfig.webpack?.(config, options) ?? config;\n },\n };\n },\n async createLoader() {\n const { createMdxLoader } = await import(\"./mdx/loader\");\n return createMdxLoader({\n getCore: () => this.core,\n });\n },\n };\n}\n\nexport type { LinkReference } from \"@/collections/mdx/remark-postprocess\";\nexport type { CompiledMDX } from \"@/collections/mdx/build-mdx\";\n"],"mappings":";;;;;;;;;AAuCA,MAAM,eAAe;CACnB,SAAS;CACT,SAAS;CACT,QAAQ;CACT;AAQD,SAAS,kBAAkB,MAAuB;AAChD,QAAO,GAAG,KAAK,GAAG,GAAG,KAAK,WAAW,MAAM,CAAC,IAAI,KAAK,OAAO,MAAM,CAAC;;AAGrE,IAAa,gBAAb,cAEU,qBAAqB;CAC7B,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;;;;CAIT;;;;CAIA,cAAc,WAAoE;;;;CAIlF,QAAQ,WAAsC;;;;CAI9C,mBAAmB,MAMhB;CAEH,oBAE8B;CAE9B,YAAY,QAAgD;AAC1D,QAAM;GACJ,KAAK,OAAO;GACZ,OAAO,OAAO;GACd,kBAAkB,CAAC,MAAM,MAAM;GAChC,CAAC;AACF,OAAK,cAAc,OAAO;AAC1B,OAAK,aAAa,OAAO;AACzB,OAAK,gBAAgB,OAAO;AAC5B,OAAK,UAAU,OAAO,WAAW;AACjC,OAAK,OAAO,OAAO,QAAQ;AAC3B,OAAK,oBAAoB,OAAO;AAChC,OAAK,YAAY,KAAK,MAAKA,cAAe,KAAK,KAAK,CAAC;AACrD,OAAK,SAAS,KAAK,M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;GACnB,MAAM,EAAE,oBAAoB,MAAM,OAAO;AACzC,UAAO,gBAAgB,EACrB,eAAe,KAAK,MACrB,CAAC;;EAEL"}
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import "../../core-
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import "../../core-CG2zTL4c.js";
|
|
2
|
+
import { MapCollectionStore } from "./store.js";
|
|
3
|
+
|
|
4
|
+
//#region src/collections/runtime/file-store.d.ts
|
|
5
|
+
interface FileInfo {
|
|
6
|
+
/**
|
|
7
|
+
* path relative to content directory
|
|
8
|
+
*/
|
|
9
|
+
path: string;
|
|
10
|
+
/**
|
|
11
|
+
* the full file path in file system
|
|
12
|
+
*/
|
|
13
|
+
fullPath: string;
|
|
14
|
+
}
|
|
15
|
+
declare class FileCollectionStore<V> extends MapCollectionStore<string, FileInfo & V> {
|
|
16
|
+
constructor(base: string, glob: Record<string, V>);
|
|
17
|
+
castData<T>(_cast: (input: FileInfo & V) => FileInfo & T): FileCollectionStore<T>;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { FileCollectionStore, FileInfo };
|
|
21
|
+
//# sourceMappingURL=file-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-store.d.ts","names":[],"sources":["../../../src/collections/runtime/file-store.ts"],"mappings":";;;;UAGiB,QAAA;;;AAAjB;EAIE,IAAA;;;;EAKA,QAAA;AAAA;AAAA,cAWW,mBAAA,YAA+B,kBAAA,SAA2B,QAAA,GAAW,CAAA;cACpE,IAAA,UAAc,IAAA,EAAM,MAAA,SAAe,CAAA;EAa/C,QAAA,GAAA,CAAY,KAAA,GAAQ,KAAA,EAAO,QAAA,GAAW,CAAA,KAAM,QAAA,GAAW,CAAA,GAAI,mBAAA,CAAoB,CAAA;AAAA"}
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
import "../../core-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { S as Awaitable } from "../../core-CG2zTL4c.js";
|
|
2
|
+
|
|
3
|
+
//#region src/collections/runtime/store.d.ts
|
|
4
|
+
interface CollectionStore<Id, Data> {
|
|
5
|
+
/**
|
|
6
|
+
* type-only operation to cast data type, doesn't do any runtime transformation.
|
|
7
|
+
*/
|
|
8
|
+
castData: <T>(_cast: (input: Data) => T) => CollectionStore<Id, T>;
|
|
9
|
+
get: (id: Id) => Awaitable<Data | undefined>;
|
|
10
|
+
list: () => Awaitable<Data[]>;
|
|
11
|
+
/**
|
|
12
|
+
* For typescript to infer data types, don't access the value of this property.
|
|
13
|
+
*/
|
|
14
|
+
$inferData: Data;
|
|
15
|
+
}
|
|
16
|
+
declare class MapCollectionStore<Id, Data> implements CollectionStore<Id, Data> {
|
|
17
|
+
private readonly dataMap;
|
|
18
|
+
private readonly dataList;
|
|
19
|
+
constructor(input: Map<Id, Data>);
|
|
20
|
+
get(id: Id): Data | undefined;
|
|
21
|
+
list(): Data[];
|
|
22
|
+
castData<T>(_cast: (input: Data) => T): MapCollectionStore<Id, T>;
|
|
23
|
+
/**
|
|
24
|
+
* transform entry and create a new store
|
|
25
|
+
*/
|
|
26
|
+
transform<$Id, T>(fn: (id: Id, data: Data) => [$Id, T]): MapCollectionStore<$Id, T>;
|
|
27
|
+
get $inferData(): Data;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { CollectionStore, MapCollectionStore };
|
|
31
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","names":[],"sources":["../../../src/collections/runtime/store.ts"],"mappings":";;;UAEiB,eAAA;;AAAjB;;EAIE,QAAA,MAAc,KAAA,GAAQ,KAAA,EAAO,IAAA,KAAS,CAAA,KAAM,eAAA,CAAgB,EAAA,EAAI,CAAA;EAEhE,GAAA,GAAM,EAAA,EAAI,EAAA,KAAO,SAAA,CAAU,IAAA;EAC3B,IAAA,QAAY,SAAA,CAAU,IAAA;EAHsC;;;EAQ5D,UAAA,EAAY,IAAA;AAAA;AAAA,cAGD,kBAAA,sBAAwC,eAAA,CAAgB,EAAA,EAAI,IAAA;EAAA,iBACtD,OAAA;EAAA,iBACA,QAAA;cAEL,KAAA,EAAO,GAAA,CAAI,EAAA,EAAI,IAAA;EAK3B,GAAA,CAAI,EAAA,EAAI,EAAA,GAAK,IAAA;EAIb,IAAA,CAAA,GAAQ,IAAA;EAIR,QAAA,GAAA,CAAY,KAAA,GAAQ,KAAA,EAAO,IAAA,KAAS,CAAA,GAAI,kBAAA,CAAmB,EAAA,EAAI,CAAA;EAhC5B;;;EAuCnC,SAAA,QAAA,CAAkB,EAAA,GAAK,EAAA,EAAI,EAAA,EAAI,IAAA,EAAM,IAAA,MAAU,GAAA,EAAK,CAAA,IAAK,kBAAA,CAAmB,GAAA,EAAK,CAAA;EAAA,IAW7E,UAAA,CAAA,GAAc,IAAA;AAAA"}
|
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/collections/runtime/store.ts
|
|
2
|
+
var MapCollectionStore = class MapCollectionStore {
|
|
3
|
+
dataMap;
|
|
4
|
+
dataList;
|
|
5
|
+
constructor(input) {
|
|
6
|
+
this.dataMap = input;
|
|
7
|
+
this.dataList = Array.from(input.values());
|
|
8
|
+
}
|
|
9
|
+
get(id) {
|
|
10
|
+
return this.dataMap.get(id);
|
|
11
|
+
}
|
|
12
|
+
list() {
|
|
13
|
+
return this.dataList;
|
|
14
|
+
}
|
|
15
|
+
castData(_cast) {
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* transform entry and create a new store
|
|
20
|
+
*/
|
|
21
|
+
transform(fn) {
|
|
22
|
+
const updated = /* @__PURE__ */ new Map();
|
|
23
|
+
for (const [k, v] of this.dataMap) {
|
|
24
|
+
const out = fn(k, v);
|
|
25
|
+
updated.set(out[0], out[1]);
|
|
26
|
+
}
|
|
27
|
+
return new MapCollectionStore(updated);
|
|
28
|
+
}
|
|
29
|
+
get $inferData() {}
|
|
30
|
+
};
|
|
2
31
|
|
|
3
|
-
|
|
32
|
+
//#endregion
|
|
33
|
+
export { MapCollectionStore };
|
|
34
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","names":[],"sources":["../../../src/collections/runtime/store.ts"],"sourcesContent":["import type { Awaitable } from \"@/types\";\n\nexport interface CollectionStore<Id, Data> {\n /**\n * type-only operation to cast data type, doesn't do any runtime transformation.\n */\n castData: <T>(_cast: (input: Data) => T) => CollectionStore<Id, T>;\n\n get: (id: Id) => Awaitable<Data | undefined>;\n list: () => Awaitable<Data[]>;\n\n /**\n * For typescript to infer data types, don't access the value of this property.\n */\n $inferData: Data;\n}\n\nexport class MapCollectionStore<Id, Data> implements CollectionStore<Id, Data> {\n private readonly dataMap: Map<Id, Data>;\n private readonly dataList: Data[];\n\n constructor(input: Map<Id, Data>) {\n this.dataMap = input;\n this.dataList = Array.from(input.values());\n }\n\n get(id: Id): Data | undefined {\n return this.dataMap.get(id);\n }\n\n list(): Data[] {\n return this.dataList;\n }\n\n castData<T>(_cast: (input: Data) => T): MapCollectionStore<Id, T> {\n return this as unknown as MapCollectionStore<Id, T>;\n }\n\n /**\n * transform entry and create a new store\n */\n transform<$Id, T>(fn: (id: Id, data: Data) => [$Id, T]): MapCollectionStore<$Id, T> {\n const updated = new Map<$Id, T>();\n\n for (const [k, v] of this.dataMap) {\n const out = fn(k, v);\n updated.set(out[0], out[1]);\n }\n\n return new MapCollectionStore(updated);\n }\n\n get $inferData(): Data {\n return undefined as Data;\n }\n}\n"],"mappings":";AAiBA,IAAa,qBAAb,MAAa,mBAAkE;CAC7E,AAAiB;CACjB,AAAiB;CAEjB,YAAY,OAAsB;AAChC,OAAK,UAAU;AACf,OAAK,WAAW,MAAM,KAAK,MAAM,QAAQ,CAAC;;CAG5C,IAAI,IAA0B;AAC5B,SAAO,KAAK,QAAQ,IAAI,GAAG;;CAG7B,OAAe;AACb,SAAO,KAAK;;CAGd,SAAY,OAAsD;AAChE,SAAO;;;;;CAMT,UAAkB,IAAkE;EAClF,MAAM,0BAAU,IAAI,KAAa;AAEjC,OAAK,MAAM,CAAC,GAAG,MAAM,KAAK,SAAS;GACjC,MAAM,MAAM,GAAG,GAAG,EAAE;AACpB,WAAQ,IAAI,IAAI,IAAI,IAAI,GAAG;;AAG7B,SAAO,IAAI,mBAAmB,QAAQ;;CAGxC,IAAI,aAAmB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../../core-
|
|
2
|
-
import "../../
|
|
3
|
-
import {
|
|
1
|
+
import "../../core-CG2zTL4c.js";
|
|
2
|
+
import "../../load-from-file-CpA8UQXX.js";
|
|
3
|
+
import { WebpackLoader } from "../../plugins/loader/webpack.js";
|
|
4
4
|
|
|
5
5
|
//#region src/collections/yaml/loader-webpack.d.ts
|
|
6
6
|
declare const _default: WebpackLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-webpack.d.ts","names":[],"sources":["../../../src/collections/yaml/loader-webpack.ts"],"
|
|
1
|
+
{"version":3,"file":"loader-webpack.d.ts","names":[],"sources":["../../../src/collections/yaml/loader-webpack.ts"],"mappings":""}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import "../../validation-BvVvvLII.js";
|
|
3
|
-
import "../../loader-B4nQrRwA.js";
|
|
4
|
-
import "../../fs-CXzVd2Dp.js";
|
|
5
|
-
import "../../data-Cxsx5KPD.js";
|
|
1
|
+
import "../../validation-C3kXuveD.js";
|
|
6
2
|
import { createWebpackLoader } from "../../plugins/loader/webpack.js";
|
|
7
|
-
import "../../loader-
|
|
8
|
-
import { t as createYamlLoader } from "../../loader-
|
|
3
|
+
import "../../loader-gwXIGo5Q.js";
|
|
4
|
+
import { t as createYamlLoader } from "../../loader-DKTW82eK.js";
|
|
9
5
|
|
|
10
6
|
//#region src/collections/yaml/loader-webpack.ts
|
|
11
7
|
var loader_webpack_default = createWebpackLoader((core) => createYamlLoader(core));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-webpack.js","names":[],"sources":["../../../src/collections/yaml/loader-webpack.ts"],"sourcesContent":["import { createWebpackLoader } from \"@/plugins/loader/webpack\";\nimport { createYamlLoader } from \"./loader\";\n\nexport default createWebpackLoader((core) => createYamlLoader(core));\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader-webpack.js","names":[],"sources":["../../../src/collections/yaml/loader-webpack.ts"],"sourcesContent":["import { createWebpackLoader } from \"@/plugins/loader/webpack\";\nimport { createYamlLoader } from \"./loader\";\n\nexport default createWebpackLoader((core) => createYamlLoader(core));\n"],"mappings":";;;;;;AAGA,6BAAe,qBAAqB,SAAS,iBAAiB,KAAK,CAAC"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,2 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { l as PluginOption } from "../core-CG2zTL4c.js";
|
|
2
|
+
import { Collection } from "../collections/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/config/index.d.ts
|
|
5
|
+
interface GlobalConfig<Collections extends Record<string, Collection> = Record<string, Collection>> {
|
|
6
|
+
plugins?: PluginOption[];
|
|
7
|
+
collections?: Collections;
|
|
8
|
+
workspaces?: Record<string, WorkspaceConfig>;
|
|
9
|
+
/**
|
|
10
|
+
* specify a directory to access & store cache (disabled during development mode).
|
|
11
|
+
*
|
|
12
|
+
* The cache will never be updated, delete the cache folder to clean.
|
|
13
|
+
*/
|
|
14
|
+
experimentalBuildCache?: string;
|
|
15
|
+
/**
|
|
16
|
+
* configure code generation
|
|
17
|
+
*/
|
|
18
|
+
emit?: EmitConfig;
|
|
19
|
+
}
|
|
20
|
+
interface EmitConfig {
|
|
21
|
+
target?: "default" | "vite";
|
|
22
|
+
/**
|
|
23
|
+
* add .js extenstion to imports
|
|
24
|
+
*/
|
|
25
|
+
jsExtension?: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface WorkspaceConfig {
|
|
28
|
+
dir: string;
|
|
29
|
+
config: GlobalConfig | {
|
|
30
|
+
default: GlobalConfig;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
declare function defineConfig<Collections extends Record<string, Collection> = Record<string, Collection>>(config?: GlobalConfig<Collections>): GlobalConfig<Collections>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { EmitConfig, GlobalConfig, WorkspaceConfig, defineConfig };
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/config/index.ts"],"mappings":";;;;UAGiB,YAAA,qBACK,MAAA,SAAe,UAAA,IAAc,MAAA,SAAe,UAAA;EAEhE,OAAA,GAAU,YAAA;EACV,WAAA,GAAc,WAAA;EACd,UAAA,GAAa,MAAA,SAAe,eAAA;EALD;;;;;EAY3B,sBAAA;EARc;;;EAad,IAAA,GAAO,UAAA;AAAA;AAAA,UAGQ,UAAA;EACf,MAAA;EApBoB;;;EAwBpB,WAAA;AAAA;AAAA,UAGe,eAAA;EACf,GAAA;EACA,MAAA,EAAQ,YAAA;IAAiB,OAAA,EAAS,YAAA;EAAA;AAAA;AAAA,iBAGpB,YAAA,qBACM,MAAA,SAAe,UAAA,IAAc,MAAA,SAAe,UAAA,EAAA,CAChE,MAAA,GAAQ,YAAA,CAAa,WAAA,IAAoB,YAAA,CAAa,WAAA"}
|