fuma-content 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-mdx-BZxE8t2a.js → build-mdx-CUp6FpfT.js} +2 -2
- package/dist/{build-mdx-BZxE8t2a.js.map → build-mdx-CUp6FpfT.js.map} +1 -1
- package/dist/build-mdx-D6zM3Sgl.js +4 -0
- package/dist/bun/index.d.ts +1 -1
- package/dist/bun/index.js +2 -2
- package/dist/{code-generator-CjC4EEXg.js → code-generator-Qhhq7kHh.js} +30 -24
- package/dist/code-generator-Qhhq7kHh.js.map +1 -0
- package/dist/collections/data/runtime.d.ts +6 -5
- package/dist/collections/data/runtime.d.ts.map +1 -1
- package/dist/collections/data.d.ts +5 -5
- package/dist/collections/data.d.ts.map +1 -1
- package/dist/collections/data.js +3 -3
- package/dist/collections/fs.d.ts +2 -2
- package/dist/collections/fs.js +1 -1
- package/dist/collections/index.d.ts +1 -1
- package/dist/collections/index.js +1 -1
- package/dist/collections/json/loader-webpack.d.ts +3 -3
- package/dist/collections/json/loader-webpack.js +5 -5
- package/dist/collections/mdx/loader-webpack.d.ts +3 -3
- package/dist/collections/mdx/loader-webpack.js +5 -5
- package/dist/collections/mdx/react.d.ts +10 -8
- package/dist/collections/mdx/react.d.ts.map +1 -1
- package/dist/collections/mdx/runtime-browser.d.ts +10 -8
- package/dist/collections/mdx/runtime-browser.js +1 -1
- package/dist/collections/mdx/runtime-dynamic.d.ts +9 -8
- package/dist/collections/mdx/runtime-dynamic.d.ts.map +1 -1
- package/dist/collections/mdx/runtime-dynamic.js +6 -6
- package/dist/collections/mdx/runtime.d.ts +9 -7
- package/dist/collections/mdx.d.ts +5 -5
- package/dist/collections/mdx.js +4 -4
- package/dist/collections/runtime/file-store.d.ts +3 -2
- package/dist/collections/runtime/file-store.js +1 -4
- package/dist/collections/runtime/file-store.js.map +1 -1
- package/dist/collections/runtime/store.d.ts +2 -2
- package/dist/collections/runtime/store.js +1 -1
- package/dist/collections/yaml/loader-webpack.d.ts +3 -3
- package/dist/collections/yaml/loader-webpack.js +5 -5
- package/dist/{collections-CA4UxFun.js → collections-CNWuMDAZ.js} +7 -9
- package/dist/collections-CNWuMDAZ.js.map +1 -0
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js.map +1 -1
- package/dist/{core-BBWmcGSK.d.ts → core-CT06v32N.d.ts} +23 -23
- package/dist/core-CT06v32N.d.ts.map +1 -0
- package/dist/{core--4f2Q_1e.js → core-Uv3jZqL-.js} +15 -20
- package/dist/core-Uv3jZqL-.js.map +1 -0
- package/dist/{data-CEF6c9lw.js → data-Cxsx5KPD.js} +34 -33
- package/dist/data-Cxsx5KPD.js.map +1 -0
- package/dist/{dynamic-CtP2lSKk.d.ts → dynamic-Ck1wYoaL.d.ts} +2 -2
- package/dist/{dynamic-CtP2lSKk.d.ts.map → dynamic-Ck1wYoaL.d.ts.map} +1 -1
- package/dist/dynamic.d.ts +2 -2
- package/dist/{file-store-DuAY_Td0.d.ts → file-store-Dm1SjuLg.d.ts} +2 -3
- package/dist/file-store-Dm1SjuLg.d.ts.map +1 -0
- package/dist/{fs-B5nG0vk1.js → fs-CXzVd2Dp.js} +17 -13
- package/dist/fs-CXzVd2Dp.js.map +1 -0
- package/dist/{fs-BhyPXf1u.d.ts → fs-CmwaaFyx.d.ts} +3 -2
- package/dist/fs-CmwaaFyx.d.ts.map +1 -0
- package/dist/{git-BsHTaepF.js → git-DnejL9r_.js} +2 -2
- package/dist/{git-BsHTaepF.js.map → git-DnejL9r_.js.map} +1 -1
- package/dist/{git-CG9Jou-A.d.ts → git-n-9ddn78.d.ts} +2 -2
- package/dist/{git-CG9Jou-A.d.ts.map → git-n-9ddn78.d.ts.map} +1 -1
- package/dist/{index-DAchVPIz.d.ts → index-BheUVWBm.d.ts} +3 -3
- package/dist/{index-DAchVPIz.d.ts.map → index-BheUVWBm.d.ts.map} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{loader-Cff0rlh7.js → loader-B4nQrRwA.js} +2 -2
- package/dist/{loader-Cff0rlh7.js.map → loader-B4nQrRwA.js.map} +1 -1
- package/dist/loader-B6ordrWK.js +9 -0
- package/dist/{loader-CtrU5IEv.js → loader-BK8PnqRg.js} +2 -2
- package/dist/{loader-CtrU5IEv.js.map → loader-BK8PnqRg.js.map} +1 -1
- package/dist/{loader-CCb07d3O.js → loader-CnksfM7I.js} +3 -3
- package/dist/{loader-CCb07d3O.js.map → loader-CnksfM7I.js.map} +1 -1
- package/dist/{loader-DZ-8sxfs.js → loader-Cnz-VHne.js} +2 -2
- package/dist/{loader-DZ-8sxfs.js.map → loader-Cnz-VHne.js.map} +1 -1
- package/dist/{loader-Be0nPRo7.js → loader-CuntMmR4.js} +2 -2
- package/dist/{loader-Be0nPRo7.js.map → loader-CuntMmR4.js.map} +1 -1
- package/dist/loader-Cx1Rg_VM.js +8 -0
- package/dist/loader-Dao_nv3e.js +8 -0
- package/dist/mdx-Cw1nBJ0D.js +306 -0
- package/dist/mdx-Cw1nBJ0D.js.map +1 -0
- package/dist/{mdx-B2Umeh_M.d.ts → mdx-PaqRNZMS.d.ts} +7 -16
- package/dist/mdx-PaqRNZMS.d.ts.map +1 -0
- 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/plugins/git.d.ts +2 -2
- package/dist/plugins/git.js +1 -1
- package/dist/plugins/json-schema.d.ts +1 -1
- package/dist/plugins/json-schema.js +2 -2
- package/dist/plugins/loader/index.d.ts +3 -3
- package/dist/plugins/loader/index.js +1 -1
- package/dist/plugins/loader/webpack.d.ts +3 -3
- package/dist/plugins/loader/webpack.js +1 -1
- package/dist/{runtime-6EXTvWJC.d.ts → runtime-BUUHSFlR.d.ts} +5 -5
- package/dist/{runtime-6EXTvWJC.d.ts.map → runtime-BUUHSFlR.d.ts.map} +1 -1
- package/dist/{runtime-browser-CWRjOL5k.d.ts → runtime-browser-B70WGxeQ.d.ts} +4 -4
- package/dist/{runtime-browser-CWRjOL5k.d.ts.map → runtime-browser-B70WGxeQ.d.ts.map} +1 -1
- package/dist/{store-IvpEBdxi.js → store-CRyvZFKN.js} +7 -10
- package/dist/{store-IvpEBdxi.js.map → store-CRyvZFKN.js.map} +1 -1
- package/dist/{store-cFBKt8gh.d.ts → store-D_PPrdRE.d.ts} +4 -4
- package/dist/{store-cFBKt8gh.d.ts.map → store-D_PPrdRE.d.ts.map} +1 -1
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +2 -2
- package/package.json +1 -1
- package/dist/build-mdx-LhpFasX-.js +0 -4
- package/dist/code-generator-CjC4EEXg.js.map +0 -1
- package/dist/collections-CA4UxFun.js.map +0 -1
- package/dist/core--4f2Q_1e.js.map +0 -1
- package/dist/core-BBWmcGSK.d.ts.map +0 -1
- package/dist/data-CEF6c9lw.js.map +0 -1
- package/dist/file-store-DuAY_Td0.d.ts.map +0 -1
- package/dist/fs-B5nG0vk1.js.map +0 -1
- package/dist/fs-BhyPXf1u.d.ts.map +0 -1
- package/dist/loader-B36I1Ac5.js +0 -9
- package/dist/loader-Bf075jNM.js +0 -8
- package/dist/loader-Weah2DhH.js +0 -8
- package/dist/mdx-B2Umeh_M.d.ts.map +0 -1
- package/dist/mdx-DqCW-MvL.js +0 -303
- package/dist/mdx-DqCW-MvL.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Collection } from "./collections-
|
|
1
|
+
import { t as Collection } from "./collections-CNWuMDAZ.js";
|
|
2
2
|
import { t as createCache } from "./async-cache-U87GzQTb.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import picomatch from "picomatch";
|
|
@@ -9,7 +9,7 @@ var FileSystemCollection = class extends Collection {
|
|
|
9
9
|
/**
|
|
10
10
|
* content directory (absolute)
|
|
11
11
|
*/
|
|
12
|
-
dir
|
|
12
|
+
dir;
|
|
13
13
|
filesCache = createCache();
|
|
14
14
|
/** the glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */
|
|
15
15
|
patterns;
|
|
@@ -17,19 +17,23 @@ var FileSystemCollection = class extends Collection {
|
|
|
17
17
|
constructor(config) {
|
|
18
18
|
super();
|
|
19
19
|
const { files, supportedFormats } = config;
|
|
20
|
+
this.dir = config.dir;
|
|
20
21
|
this.patterns = files ?? [supportedFormats ? `**/*.{${supportedFormats.join(",")}}` : `**/*`];
|
|
21
22
|
this.supportedFileFormats = supportedFormats;
|
|
22
|
-
this.onInit.hook((
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
this.onServer.hook(({ server }) => {
|
|
26
|
-
server.watcher?.add(this.dir);
|
|
27
|
-
server.watcher?.on("all", (event, file) => {
|
|
28
|
-
if (event === "change" || !this.hasFile(file)) return;
|
|
29
|
-
this.filesCache.invalidate("");
|
|
30
|
-
});
|
|
31
|
-
});
|
|
23
|
+
this.onInit.hook(this.#onInitHandler.bind(this));
|
|
24
|
+
this.onServer.hook(this.#onServerHandler.bind(this));
|
|
32
25
|
}
|
|
26
|
+
#onInitHandler = ({ core }) => {
|
|
27
|
+
this.dir = path.resolve(core.getOptions().cwd, this.dir);
|
|
28
|
+
};
|
|
29
|
+
#onServerHandler = ({ server }) => {
|
|
30
|
+
if (!server.watcher) return;
|
|
31
|
+
server.watcher.add(this.dir);
|
|
32
|
+
server.watcher.on("all", (event, file) => {
|
|
33
|
+
if (event === "change" || !this.hasFile(file)) return;
|
|
34
|
+
this.filesCache.invalidate("");
|
|
35
|
+
});
|
|
36
|
+
};
|
|
33
37
|
isFileSupported(filePath) {
|
|
34
38
|
if (!this.supportedFileFormats) return true;
|
|
35
39
|
return this.supportedFileFormats.some((format) => filePath.endsWith(`.${format}`));
|
|
@@ -61,4 +65,4 @@ function fileSystemCollection(config) {
|
|
|
61
65
|
|
|
62
66
|
//#endregion
|
|
63
67
|
export { fileSystemCollection as n, FileSystemCollection as t };
|
|
64
|
-
//# sourceMappingURL=fs-
|
|
68
|
+
//# sourceMappingURL=fs-CXzVd2Dp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-CXzVd2Dp.js","names":["#onInitHandler","#onServerHandler"],"sources":["../src/collections/fs.ts"],"sourcesContent":["import picomatch from \"picomatch\";\nimport path from \"node:path\";\nimport { Collection } from \".\";\nimport { createCache } from \"@/utils/async-cache\";\n\nexport class FileSystemCollection extends Collection {\n private matcher: picomatch.Matcher | undefined;\n /**\n * content directory (absolute)\n */\n dir: string;\n private readonly filesCache = createCache<string[]>();\n /** the glob patterns to match files in collection, this doesn't take `supportedFormats` into account. */\n private readonly patterns: string[];\n readonly supportedFileFormats: string[] | undefined;\n\n constructor(config: FileSystemCollectionConfig) {\n super();\n const { files, supportedFormats } = config;\n this.dir = config.dir;\n this.patterns = files ?? [supportedFormats ? `**/*.{${supportedFormats.join(\",\")}}` : `**/*`];\n this.supportedFileFormats = supportedFormats;\n this.onInit.hook(this.#onInitHandler.bind(this));\n this.onServer.hook(this.#onServerHandler.bind(this));\n }\n\n #onInitHandler: (typeof this.onInit)[\"$inferHandler\"] = ({ core }) => {\n this.dir = path.resolve(core.getOptions().cwd, this.dir);\n };\n\n #onServerHandler: (typeof this.onServer)[\"$inferHandler\"] = ({ server }) => {\n if (!server.watcher) return;\n server.watcher.add(this.dir);\n server.watcher.on(\"all\", (event, file) => {\n if (event === \"change\" || !this.hasFile(file)) return;\n this.filesCache.invalidate(\"\");\n });\n };\n\n isFileSupported(filePath: string) {\n if (!this.supportedFileFormats) return true;\n return this.supportedFileFormats.some((format) => filePath.endsWith(`.${format}`));\n }\n\n /**\n * get all included files, relative to `dir`.\n *\n * the result is cached.\n */\n async getFiles() {\n return this.filesCache.cached(\"\", async () => {\n const { glob } = await import(\"tinyglobby\");\n\n const out = await glob(this.patterns, { cwd: this.dir });\n return out.filter((v) => this.isFileSupported(v));\n });\n }\n\n hasFile(filePath: string) {\n if (!this.isFileSupported(filePath)) return false;\n\n const relativePath = path.relative(this.dir, filePath);\n if (relativePath.startsWith(`..${path.sep}`)) return false;\n\n return (this.matcher ??= picomatch(this.patterns))(relativePath);\n }\n\n invalidateCache() {\n this.filesCache.invalidate(\"\");\n }\n}\n\nexport interface FileSystemCollectionConfig {\n /**\n * Directory to scan\n */\n dir: string;\n\n /**\n * what files to include/exclude (glob patterns)\n *\n * Include all files if not specified\n */\n files?: string[];\n\n /**\n * Restrict to a list of file extensions to include, e.g. `['js', 'ts']`.\n */\n supportedFormats?: string[];\n}\n\nexport function fileSystemCollection(config: FileSystemCollectionConfig) {\n return new FileSystemCollection(config);\n}\n"],"mappings":";;;;;;AAKA,IAAa,uBAAb,cAA0C,WAAW;CACnD,AAAQ;;;;CAIR;CACA,AAAiB,aAAa,aAAuB;;CAErD,AAAiB;CACjB,AAAS;CAET,YAAY,QAAoC;AAC9C,SAAO;EACP,MAAM,EAAE,OAAO,qBAAqB;AACpC,OAAK,MAAM,OAAO;AAClB,OAAK,WAAW,SAAS,CAAC,mBAAmB,SAAS,iBAAiB,KAAK,IAAI,CAAC,KAAK,OAAO;AAC7F,OAAK,uBAAuB;AAC5B,OAAK,OAAO,KAAK,MAAKA,cAAe,KAAK,KAAK,CAAC;AAChD,OAAK,SAAS,KAAK,MAAKC,gBAAiB,KAAK,KAAK,CAAC;;CAGtD,kBAAyD,EAAE,WAAW;AACpE,OAAK,MAAM,KAAK,QAAQ,KAAK,YAAY,CAAC,KAAK,KAAK,IAAI;;CAG1D,oBAA6D,EAAE,aAAa;AAC1E,MAAI,CAAC,OAAO,QAAS;AACrB,SAAO,QAAQ,IAAI,KAAK,IAAI;AAC5B,SAAO,QAAQ,GAAG,QAAQ,OAAO,SAAS;AACxC,OAAI,UAAU,YAAY,CAAC,KAAK,QAAQ,KAAK,CAAE;AAC/C,QAAK,WAAW,WAAW,GAAG;IAC9B;;CAGJ,gBAAgB,UAAkB;AAChC,MAAI,CAAC,KAAK,qBAAsB,QAAO;AACvC,SAAO,KAAK,qBAAqB,MAAM,WAAW,SAAS,SAAS,IAAI,SAAS,CAAC;;;;;;;CAQpF,MAAM,WAAW;AACf,SAAO,KAAK,WAAW,OAAO,IAAI,YAAY;GAC5C,MAAM,EAAE,SAAS,MAAM,OAAO;AAG9B,WADY,MAAM,KAAK,KAAK,UAAU,EAAE,KAAK,KAAK,KAAK,CAAC,EAC7C,QAAQ,MAAM,KAAK,gBAAgB,EAAE,CAAC;IACjD;;CAGJ,QAAQ,UAAkB;AACxB,MAAI,CAAC,KAAK,gBAAgB,SAAS,CAAE,QAAO;EAE5C,MAAM,eAAe,KAAK,SAAS,KAAK,KAAK,SAAS;AACtD,MAAI,aAAa,WAAW,KAAK,KAAK,MAAM,CAAE,QAAO;AAErD,UAAQ,KAAK,YAAY,UAAU,KAAK,SAAS,EAAE,aAAa;;CAGlE,kBAAkB;AAChB,OAAK,WAAW,WAAW,GAAG;;;AAuBlC,SAAgB,qBAAqB,QAAoC;AACvE,QAAO,IAAI,qBAAqB,OAAO"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { m as Collection } from "./core-
|
|
1
|
+
import { m as Collection } from "./core-CT06v32N.js";
|
|
2
2
|
|
|
3
3
|
//#region src/collections/fs.d.ts
|
|
4
4
|
declare class FileSystemCollection extends Collection {
|
|
5
|
+
#private;
|
|
5
6
|
private matcher;
|
|
6
7
|
/**
|
|
7
8
|
* content directory (absolute)
|
|
@@ -41,4 +42,4 @@ interface FileSystemCollectionConfig {
|
|
|
41
42
|
declare function fileSystemCollection(config: FileSystemCollectionConfig): FileSystemCollection;
|
|
42
43
|
//#endregion
|
|
43
44
|
export { FileSystemCollectionConfig as n, fileSystemCollection as r, FileSystemCollection as t };
|
|
44
|
-
//# sourceMappingURL=fs-
|
|
45
|
+
//# sourceMappingURL=fs-CmwaaFyx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-CmwaaFyx.d.ts","names":[],"sources":["../src/collections/fs.ts"],"sourcesContent":[],"mappings":";;;cAKa,oBAAA,SAA6B,UAAA;;EAA7B,QAAA,OAAA;EAWS;;;EAX8B,GAAA,EAAA,MAAA;EAmEnC,iBAAA,UAAA;EAmBD;;;sBA3EM;;;;;;;cAiCN;;;;UAuBC,0BAAA;;;;;;;;;;;;;;;;iBAmBD,oBAAA,SAA6B,6BAA0B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as asyncHook, n as defineCollectionHook } from "./collections-
|
|
1
|
+
import { a as asyncHook, n as defineCollectionHook } from "./collections-CNWuMDAZ.js";
|
|
2
2
|
import { t as createCache } from "./async-cache-U87GzQTb.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { x } from "tinyexec";
|
|
@@ -57,4 +57,4 @@ function createGitClient(cwd) {
|
|
|
57
57
|
|
|
58
58
|
//#endregion
|
|
59
59
|
export { gitHook as n, git as t };
|
|
60
|
-
//# sourceMappingURL=git-
|
|
60
|
+
//# sourceMappingURL=git-DnejL9r_.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-
|
|
1
|
+
{"version":3,"file":"git-DnejL9r_.js","names":["client: GitClient"],"sources":["../src/plugins/git.ts"],"sourcesContent":["import path from \"node:path\";\nimport { type Output, x } from \"tinyexec\";\nimport type { Plugin } from \"@/core\";\nimport { createCache } from \"@/utils/async-cache\";\nimport { defineCollectionHook } from \"@/collections\";\nimport { asyncHook, AsyncHook } from \"@/utils/hook\";\n\nexport interface GitFileData {\n /**\n * Last modified date of file, obtained from version control.\n */\n lastModified: Date | null;\n /**\n * Creation date of file, obtained from version control.\n */\n creationDate: Date | null;\n}\n\nexport interface GitHook {\n /**\n * receive the client.\n */\n onClient: AsyncHook<{ client: GitClient }>;\n}\n\nexport const gitHook = defineCollectionHook<GitHook>(() => ({\n onClient: asyncHook(),\n}));\n\n/**\n * Add version control integration for Git.\n * 1. Injects `creationDate` & `lastModified` properties to page exports.\n *\n * @remarks If you are using Vercel, please set `VERCEL_DEEP_CLONE` environment variable to `true`. This ensures the client can access the full commit history of Git.\n */\nexport default function git(): Plugin {\n let client: GitClient;\n\n return {\n name: \"git\",\n config() {\n const { cwd } = this.core.getOptions();\n client = createGitClient(cwd);\n },\n async collection(collection) {\n await collection.getPluginHook(gitHook)?.onClient.run({ client });\n },\n };\n}\n\nexport interface GitClient {\n getFileData: (options: { filePath: string }) => Promise<GitFileData>;\n}\n\nfunction createGitClient(cwd: string): GitClient {\n const cache = createCache<GitFileData>();\n\n function mapDate(out: Output): Date | null {\n if (out.exitCode !== 0) return null;\n const date = new Date(out.stdout);\n return Number.isNaN(date.getTime()) ? null : date;\n }\n\n return {\n async getFileData({ filePath }) {\n return cache.cached(filePath, async () => {\n const relativePath = path.relative(cwd, filePath);\n const [mod, create] = await Promise.all([\n x(\"git\", [\"log\", \"-1\", \"--pretty=%ai\", relativePath], {\n nodeOptions: {\n cwd,\n },\n }),\n x(\"git\", [\"log\", \"--diff-filter=A\", \"--follow\", \"--format=%ai\", \"-1\", relativePath], {\n nodeOptions: {\n cwd,\n },\n }),\n ]);\n\n return {\n lastModified: mapDate(mod),\n creationDate: mapDate(create),\n };\n });\n },\n };\n}\n"],"mappings":";;;;;;AAyBA,MAAa,UAAU,4BAAqC,EAC1D,UAAU,WAAW,EACtB,EAAE;;;;;;;AAQH,SAAwB,MAAc;CACpC,IAAIA;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP,MAAM,EAAE,QAAQ,KAAK,KAAK,YAAY;AACtC,YAAS,gBAAgB,IAAI;;EAE/B,MAAM,WAAW,YAAY;AAC3B,SAAM,WAAW,cAAc,QAAQ,EAAE,SAAS,IAAI,EAAE,QAAQ,CAAC;;EAEpE;;AAOH,SAAS,gBAAgB,KAAwB;CAC/C,MAAM,QAAQ,aAA0B;CAExC,SAAS,QAAQ,KAA0B;AACzC,MAAI,IAAI,aAAa,EAAG,QAAO;EAC/B,MAAM,OAAO,IAAI,KAAK,IAAI,OAAO;AACjC,SAAO,OAAO,MAAM,KAAK,SAAS,CAAC,GAAG,OAAO;;AAG/C,QAAO,EACL,MAAM,YAAY,EAAE,YAAY;AAC9B,SAAO,MAAM,OAAO,UAAU,YAAY;GACxC,MAAM,eAAe,KAAK,SAAS,KAAK,SAAS;GACjD,MAAM,CAAC,KAAK,UAAU,MAAM,QAAQ,IAAI,CACtC,EAAE,OAAO;IAAC;IAAO;IAAM;IAAgB;IAAa,EAAE,EACpD,aAAa,EACX,KACD,EACF,CAAC,EACF,EAAE,OAAO;IAAC;IAAO;IAAmB;IAAY;IAAgB;IAAM;IAAa,EAAE,EACnF,aAAa,EACX,KACD,EACF,CAAC,CACH,CAAC;AAEF,UAAO;IACL,cAAc,QAAQ,IAAI;IAC1B,cAAc,QAAQ,OAAO;IAC9B;IACD;IAEL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as AsyncHook,
|
|
1
|
+
import { S as AsyncHook, h as CollectionHook, s as Plugin } from "./core-CT06v32N.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugins/git.d.ts
|
|
4
4
|
interface GitFileData {
|
|
@@ -34,4 +34,4 @@ interface GitClient {
|
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
36
|
export { gitHook as a, git as i, GitFileData as n, GitHook as r, GitClient as t };
|
|
37
|
-
//# sourceMappingURL=git-
|
|
37
|
+
//# sourceMappingURL=git-n-9ddn78.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-
|
|
1
|
+
{"version":3,"file":"git-n-9ddn78.d.ts","names":[],"sources":["../src/plugins/git.ts"],"sourcesContent":[],"mappings":";;;UAOiB,WAAA;EAAA;AAWjB;AAOA;EAUwB,YAAG,EAxBX,IAwBe,GAAA,IAAM;EAepB;;;gBAnCD;;UAGC,OAAA;;;;YAIL;YAAoB;;;cAGnB,SAAO,eAAA;;;;;;;iBAUI,GAAA,CAAA,GAAO;UAed,SAAA;;;QACiC,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { t as DynamicCore } from "./dynamic-
|
|
1
|
+
import { c as PluginContext, h as CollectionHook, s as Plugin } from "./core-CT06v32N.js";
|
|
2
|
+
import { t as DynamicCore } from "./dynamic-Ck1wYoaL.js";
|
|
3
3
|
import { NextConfig } from "next";
|
|
4
4
|
import { LoaderContext } from "webpack";
|
|
5
5
|
|
|
@@ -84,4 +84,4 @@ interface LoaderHook {
|
|
|
84
84
|
declare const loaderHook: CollectionHook<LoaderHook, undefined>;
|
|
85
85
|
//#endregion
|
|
86
86
|
export { LoaderInput as a, loaderPlugin as c, createWebpackLoader as d, LoaderHook as i, WebpackLoader as l, Loader as n, LoaderOutput as o, LoaderConfig as r, loaderHook as s, CompilerOptions as t, WebpackLoaderOptions as u };
|
|
87
|
-
//# sourceMappingURL=index-
|
|
87
|
+
//# sourceMappingURL=index-BheUVWBm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-BheUVWBm.d.ts","names":[],"sources":["../src/plugins/loader/webpack.ts","../src/plugins/loader/index.ts"],"sourcesContent":[],"mappings":";;;;;;UAQiB,oBAAA;;;EAAA,MAAA,EAAA,MAAA;EAOL,KAAA,EAAA,OAAA;AAqBZ;AAA0D,KArB9C,aAAA,GAqB8C,CAAA,IAAA,EArBvB,aAqBuB,CArBT,oBAqBS,CAAA,EAAA,MAAA,EAAA,MAAA,EAAA,GAAA,IAAA;;;;iBAA1C,mBAAA,uBAA0C,gBAAgB,SAAS;;;KC7B9E,eAAe,IAAI,QAAQ;UAEf,eAAA;;ADDjB;AAOA,KCFK,iBAAA,GDEoB,MAAA,GAAwB,KAAA,GAAA,MAAA;AAqBjC,UCrBC,MAAA,CDqBD;EAA0C;;;;;;;EC7BrD,IAAA,EAAA,CAAA,KAAS,EAgBE,WAhBF,EAAA,GAgBkB,SAhBlB,CAgB4B,YAhB5B,GAAA,IAAA,CAAA;EAAM,GAAA,CAAA,EAAA;IAAY;;;AAEhC;IAIK,IAAA,CAAA,EAAA,CAAA,MAAA,EAAiB,MAAA,EAAA,KAAA,EAiBa,WAjBb,EAAA,GAiB6B,SAjB7B,CAiBuC,GAAA,CAAI,YAjB3C,CAAA;EAEL,CAAA;;AAQyB,UAWzB,WAAA,CAXyB;EAAV,WAAA,EAAA,OAAA;EAOG,QAAA,EAMvB,eANuB;EAA0B,QAAI,EAAA,MAAA;EAAd,KAAA,EAS1C,MAT0C,CAAA,MAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA,CAAA;EAAS,SAAA,EAAA,GAAA,GAAA,MAAA,GAUhC,OAVgC,CAAA,MAAA,CAAA;AAI5D;AAEY,UAOK,YAAA,CAPL;EAGH,IAAA,EAAA,MAAA;EACmB,GAAA,CAAA,EAAA,OAAA;EAAO;AAGnC;AAUC;AAMD;;EAcuB,UAAA,CAAA,EAAA,IAAA,GAAA,MAAA;;UAlBb,iBAAA,SAA0B,aAkB6C,CAAA;EAAR,gBAAA,EAAA,GAAA,GAjB/C,oBAiB+C;;AACvB,UAfjC,YAAA,CAeiC;EAAe;EAAU,EAAA,CAAA,EAAA,MAAA;EAY3D;AAqFhB;AAIA;;;SA3GS;;;;uBAKc,4BAA4B,sBAAsB,QAAQ;yBACxD,yBAAyB,eAAe;;;;;iBAYjD,YAAA,CAAA,GAAgB;UAqFf,UAAA;WACN;;cAGE,YAAU,eAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Hook, D as GetCollectionConfig, S as AsyncHook, T as hook, a as
|
|
1
|
+
import { C as Hook, D as GetCollectionConfig, S as AsyncHook, T as hook, a as EmitOptions, b as asyncPipe, c as PluginContext, d as ResolvedCoreOptions, f as ServerContext, i as EmitEntry, l as PluginOption, n as CoreOptions, o as EmitOutput, r as EmitContext, s as Plugin, t as Core, u as ResolvedConfig, v as AsyncPipe, w as asyncHook, x as pipe, y as Pipe } from "./core-CT06v32N.js";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/validation.d.ts
|
|
@@ -14,5 +14,5 @@ declare function validate<Schema extends StandardSchemaV1, Context>(schema: Stan
|
|
|
14
14
|
*/
|
|
15
15
|
declare function getJSONSchema(schema: StandardSchemaV1): Record<string, unknown> | undefined;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { AsyncHook, AsyncPipe, Core, CoreOptions,
|
|
17
|
+
export { AsyncHook, AsyncPipe, Core, CoreOptions, EmitContext, EmitEntry, EmitOptions, EmitOutput, type GetCollectionConfig, Hook, Pipe, Plugin, PluginContext, PluginOption, ResolvedConfig, ResolvedCoreOptions, ServerContext, ValidationError, asyncHook, asyncPipe, getJSONSchema, hook, pipe, validate };
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as asyncHook, i as pipe, o as hook, r as asyncPipe } from "./collections-
|
|
2
|
-
import { t as Core } from "./core
|
|
1
|
+
import { a as asyncHook, i as pipe, o as hook, r as asyncPipe } from "./collections-CNWuMDAZ.js";
|
|
2
|
+
import { t as Core } from "./core-Uv3jZqL-.js";
|
|
3
3
|
import { n as getJSONSchema, r as validate, t as ValidationError } from "./validation-BvVvvLII.js";
|
|
4
4
|
|
|
5
5
|
export { Core, ValidationError, asyncHook, asyncPipe, getJSONSchema, hook, pipe, validate };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as defineCollectionHook } from "./collections-
|
|
1
|
+
import { n as defineCollectionHook } from "./collections-CNWuMDAZ.js";
|
|
2
2
|
import { t as createCache } from "./async-cache-U87GzQTb.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
@@ -74,4 +74,4 @@ const loaderHook = defineCollectionHook(() => ({ loaders: [] }));
|
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
76
|
export { loaderPlugin as n, loaderHook as t };
|
|
77
|
-
//# sourceMappingURL=loader-
|
|
77
|
+
//# sourceMappingURL=loader-B4nQrRwA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-
|
|
1
|
+
{"version":3,"file":"loader-B4nQrRwA.js","names":["out: ResolvedLoader[]","ctx: NextLoaderContext"],"sources":["../src/plugins/loader/index.ts"],"sourcesContent":["import { defineCollectionHook } from \"@/collections\";\nimport type { Plugin, PluginContext } from \"@/core\";\nimport { createCache } from \"@/utils/async-cache\";\nimport { NextConfig } from \"next\";\nimport { WebpackLoaderOptions } from \"./webpack.js\";\nimport path from \"node:path\";\n\ntype Awaitable<T> = T | Promise<T>;\n\nexport interface CompilerOptions {\n addDependency: (file: string) => void;\n}\n\ntype LoaderEnvironment = \"vite\" | \"bun\" | \"node\";\n\nexport interface Loader {\n /**\n * Transform input into JavaScript.\n *\n * Returns:\n * - `LoaderOutput`: JavaScript code & source map.\n * - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.\n */\n load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;\n\n bun?: {\n /**\n * 1. Bun doesn't allow `null` in loaders.\n * 2. Bun requires sync result to support dynamic require().\n */\n load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;\n };\n}\n\nexport interface LoaderInput {\n development: boolean;\n compiler: CompilerOptions;\n\n filePath: string;\n query: Record<string, string | string[] | undefined>;\n getSource: () => string | Promise<string>;\n}\n\nexport interface LoaderOutput {\n code: string;\n map?: unknown;\n\n /**\n * only supported on Vite 8 at the moment, specify the output module type.\n *\n * on unsupported environments, it will be ignored.\n */\n moduleType?: \"js\" | \"json\";\n}\n\ninterface NextLoaderContext extends PluginContext {\n getLoaderOptions: () => WebpackLoaderOptions;\n}\n\nexport interface LoaderConfig {\n /** unique ID for loader, used to deduplicate loaders */\n id?: string;\n\n /**\n * Filter file paths, the input can be either a file URL or file path.\n *\n * Must take resource query into consideration.\n */\n test?: RegExp;\n\n /**\n * @remarks it doesn't configure automatically for Next.js, you have to define the webpack/turbopack config in `configureNext()`.\n */\n createLoader: (this: PluginContext, environment: LoaderEnvironment) => Promise<Loader>;\n configureNext?: (this: NextLoaderContext, next: NextConfig) => NextConfig;\n}\n\ninterface ResolvedLoader {\n id: string;\n test: RegExp | undefined;\n loader: Loader;\n}\n\n/**\n * a light layer for implementing loaders.\n */\nexport function loaderPlugin(): Plugin {\n // env -> loaders\n const cachedLoaders = createCache<ResolvedLoader[]>();\n\n function initLoaders(ctx: PluginContext, env: LoaderEnvironment) {\n return cachedLoaders.cached(env, async () => {\n const usedIds = new Set<string>();\n const out: ResolvedLoader[] = [];\n\n for (const collection of ctx.core.getCollections()) {\n const hook = collection.getPluginHook(loaderHook);\n if (!hook) continue;\n\n let nextId = 0;\n for (const loader of hook.loaders) {\n if (loader.id && usedIds.has(loader.id)) continue;\n if (loader.id) usedIds.add(loader.id);\n\n out.push({\n id: loader.id ?? `${collection.name}:${nextId++}`,\n test: loader.test,\n loader: await loader.createLoader.call(ctx, env),\n });\n }\n }\n return out;\n });\n }\n\n return {\n name: \"fuma-content:loader\",\n next: {\n config(config) {\n const ctx: NextLoaderContext = {\n ...this,\n getLoaderOptions: () => {\n const { configPath, outDir } = this.core.getOptions();\n return {\n configPath,\n outDir,\n absoluteCompiledConfigPath: path.resolve(this.core.getCompiledConfigPath()),\n isDev: process.env.NODE_ENV === \"development\",\n };\n },\n };\n for (const collection of this.core.getCollections()) {\n const hook = collection.getPluginHook(loaderHook);\n if (!hook) continue;\n\n for (const loader of hook.loaders) {\n if (!loader.configureNext) continue;\n\n config = loader.configureNext.call(ctx, config);\n }\n }\n\n return config;\n },\n },\n bun: {\n async setup(build) {\n const { toBun } = await import(\"./bun\");\n\n for (const loader of await initLoaders(this, \"bun\")) {\n toBun(loader.test, loader.loader)(build);\n }\n },\n },\n node: {\n async createLoad() {\n const { toNode } = await import(\"./node\");\n return toNode(await initLoaders(this, \"node\"));\n },\n },\n vite: {\n async createPlugin() {\n const { toVite } = await import(\"./vite\");\n return (await initLoaders(this, \"vite\")).map((loader) => {\n return toVite(`fuma-content:${loader.id}`, loader.test, loader.loader);\n });\n },\n },\n };\n}\n\nexport interface LoaderHook {\n loaders: LoaderConfig[];\n}\n\nexport const loaderHook = defineCollectionHook<LoaderHook>(() => ({\n loaders: [],\n}));\n"],"mappings":";;;;;;;;AAsFA,SAAgB,eAAuB;CAErC,MAAM,gBAAgB,aAA+B;CAErD,SAAS,YAAY,KAAoB,KAAwB;AAC/D,SAAO,cAAc,OAAO,KAAK,YAAY;GAC3C,MAAM,0BAAU,IAAI,KAAa;GACjC,MAAMA,MAAwB,EAAE;AAEhC,QAAK,MAAM,cAAc,IAAI,KAAK,gBAAgB,EAAE;IAClD,MAAM,OAAO,WAAW,cAAc,WAAW;AACjD,QAAI,CAAC,KAAM;IAEX,IAAI,SAAS;AACb,SAAK,MAAM,UAAU,KAAK,SAAS;AACjC,SAAI,OAAO,MAAM,QAAQ,IAAI,OAAO,GAAG,CAAE;AACzC,SAAI,OAAO,GAAI,SAAQ,IAAI,OAAO,GAAG;AAErC,SAAI,KAAK;MACP,IAAI,OAAO,MAAM,GAAG,WAAW,KAAK,GAAG;MACvC,MAAM,OAAO;MACb,QAAQ,MAAM,OAAO,aAAa,KAAK,KAAK,IAAI;MACjD,CAAC;;;AAGN,UAAO;IACP;;AAGJ,QAAO;EACL,MAAM;EACN,MAAM,EACJ,OAAO,QAAQ;GACb,MAAMC,MAAyB;IAC7B,GAAG;IACH,wBAAwB;KACtB,MAAM,EAAE,YAAY,WAAW,KAAK,KAAK,YAAY;AACrD,YAAO;MACL;MACA;MACA,4BAA4B,KAAK,QAAQ,KAAK,KAAK,uBAAuB,CAAC;MAC3E,OAAO,QAAQ,IAAI,aAAa;MACjC;;IAEJ;AACD,QAAK,MAAM,cAAc,KAAK,KAAK,gBAAgB,EAAE;IACnD,MAAM,OAAO,WAAW,cAAc,WAAW;AACjD,QAAI,CAAC,KAAM;AAEX,SAAK,MAAM,UAAU,KAAK,SAAS;AACjC,SAAI,CAAC,OAAO,cAAe;AAE3B,cAAS,OAAO,cAAc,KAAK,KAAK,OAAO;;;AAInD,UAAO;KAEV;EACD,KAAK,EACH,MAAM,MAAM,OAAO;GACjB,MAAM,EAAE,UAAU,MAAM,OAAO;AAE/B,QAAK,MAAM,UAAU,MAAM,YAAY,MAAM,MAAM,CACjD,OAAM,OAAO,MAAM,OAAO,OAAO,CAAC,MAAM;KAG7C;EACD,MAAM,EACJ,MAAM,aAAa;GACjB,MAAM,EAAE,WAAW,MAAM,OAAO;AAChC,UAAO,OAAO,MAAM,YAAY,MAAM,OAAO,CAAC;KAEjD;EACD,MAAM,EACJ,MAAM,eAAe;GACnB,MAAM,EAAE,WAAW,MAAM,OAAO;AAChC,WAAQ,MAAM,YAAY,MAAM,OAAO,EAAE,KAAK,WAAW;AACvD,WAAO,OAAO,gBAAgB,OAAO,MAAM,OAAO,MAAM,OAAO,OAAO;KACtE;KAEL;EACF;;AAOH,MAAa,aAAa,4BAAwC,EAChE,SAAS,EAAE,EACZ,EAAE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./validation-BvVvvLII.js";
|
|
2
|
+
import "./loader-B4nQrRwA.js";
|
|
3
|
+
import "./fs-CXzVd2Dp.js";
|
|
4
|
+
import "./git-DnejL9r_.js";
|
|
5
|
+
import "./mdx-Cw1nBJ0D.js";
|
|
6
|
+
import "./fuma-matter-BuBO2w-p.js";
|
|
7
|
+
import { t as createMdxLoader } from "./loader-CnksfM7I.js";
|
|
8
|
+
|
|
9
|
+
export { createMdxLoader };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createDataLoader } from "./loader-
|
|
1
|
+
import { t as createDataLoader } from "./loader-CuntMmR4.js";
|
|
2
2
|
|
|
3
3
|
//#region src/collections/json/loader.ts
|
|
4
4
|
function createJsonLoader(core, resolveJson = "js") {
|
|
@@ -13,4 +13,4 @@ function createJsonLoader(core, resolveJson = "js") {
|
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
15
15
|
export { createJsonLoader as t };
|
|
16
|
-
//# sourceMappingURL=loader-
|
|
16
|
+
//# sourceMappingURL=loader-BK8PnqRg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-
|
|
1
|
+
{"version":3,"file":"loader-BK8PnqRg.js","names":[],"sources":["../src/collections/json/loader.ts"],"sourcesContent":["import type { Loader } from \"@/plugins/loader\";\nimport type { DynamicCore } from \"@/dynamic\";\nimport { createDataLoader } from \"../data/loader\";\n\nexport function createJsonLoader(core: DynamicCore, resolveJson: \"json\" | \"js\" = \"js\"): Loader {\n return createDataLoader(\n core,\n (filePath, source) => {\n try {\n return JSON.parse(source);\n } catch (e) {\n throw new Error(`invalid data in ${filePath}`, { cause: e });\n }\n },\n resolveJson,\n );\n}\n"],"mappings":";;;AAIA,SAAgB,iBAAiB,MAAmB,cAA6B,MAAc;AAC7F,QAAO,iBACL,OACC,UAAU,WAAW;AACpB,MAAI;AACF,UAAO,KAAK,MAAM,OAAO;WAClB,GAAG;AACV,SAAM,IAAI,MAAM,mBAAmB,YAAY,EAAE,OAAO,GAAG,CAAC;;IAGhE,YACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as MDXCollection } from "./mdx-
|
|
1
|
+
import { t as MDXCollection } from "./mdx-Cw1nBJ0D.js";
|
|
2
2
|
import { t as fumaMatter } from "./fuma-matter-BuBO2w-p.js";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
@@ -50,7 +50,7 @@ function createMdxLoader({ getCore }) {
|
|
|
50
50
|
map: null
|
|
51
51
|
};
|
|
52
52
|
const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
|
|
53
|
-
const { buildMDX } = await import("./build-mdx-
|
|
53
|
+
const { buildMDX } = await import("./build-mdx-D6zM3Sgl.js");
|
|
54
54
|
const compiled = await buildMDX(core, collection, {
|
|
55
55
|
isDevelopment,
|
|
56
56
|
source: "\n".repeat(lineOffset) + matter.content,
|
|
@@ -78,4 +78,4 @@ function countLines(s) {
|
|
|
78
78
|
|
|
79
79
|
//#endregion
|
|
80
80
|
export { createMdxLoader as t };
|
|
81
|
-
//# sourceMappingURL=loader-
|
|
81
|
+
//# sourceMappingURL=loader-CnksfM7I.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-
|
|
1
|
+
{"version":3,"file":"loader-CnksfM7I.js","names":["after: (() => Promise<void>) | undefined"],"sources":["../src/collections/mdx/loader.ts"],"sourcesContent":["import { fumaMatter } from \"@/collections/mdx/fuma-matter\";\nimport type { SourceMap } from \"rollup\";\nimport { z } from \"zod\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport type { Loader } from \"@/plugins/loader\";\nimport type { DynamicCore } from \"@/dynamic\";\nimport { MDXCollection } from \"../mdx\";\n\nconst querySchema = z\n .object({\n only: z.literal([\"frontmatter\", \"all\"]).default(\"all\"),\n collection: z.string().optional(),\n workspace: z.string().optional(),\n })\n .loose();\n\nconst cacheEntry = z.object({\n code: z.string(),\n map: z.any().optional(),\n hash: z.string().optional(),\n});\n\ntype CacheEntry = z.infer<typeof cacheEntry>;\n\nexport function createMdxLoader({ getCore }: DynamicCore): Loader {\n return {\n async load({ getSource, development: isDevelopment, query, compiler, filePath }) {\n let core = await getCore();\n const value = await getSource();\n const matter = fumaMatter(value);\n const { collection: collectionName, workspace, only } = querySchema.parse(query);\n if (workspace) {\n core = core.getWorkspaces().get(workspace) ?? core;\n }\n\n let after: (() => Promise<void>) | undefined;\n\n const { experimentalBuildCache = false } = core.getConfig();\n if (!isDevelopment && experimentalBuildCache) {\n const cacheDir = experimentalBuildCache;\n const cacheKey = `${collectionName ?? \"global\"}_${generateCacheHash(filePath)}`;\n\n const cached = await fs\n .readFile(path.join(cacheDir, cacheKey))\n .then((content) => cacheEntry.parse(JSON.parse(content.toString())))\n .catch(() => null);\n\n if (cached && cached.hash === generateCacheHash(value)) return cached;\n after = async () => {\n await fs.mkdir(cacheDir, { recursive: true });\n await fs.writeFile(\n path.join(cacheDir, cacheKey),\n JSON.stringify({\n ...out,\n hash: generateCacheHash(value),\n } satisfies CacheEntry),\n );\n };\n }\n\n let collection = collectionName ? core.getCollection(collectionName) : undefined;\n if (!(collection instanceof MDXCollection)) collection = undefined;\n\n if (collection?.frontmatter) {\n matter.data = await collection.frontmatter.run(matter.data as Record<string, unknown>, {\n collection,\n filePath,\n source: value,\n });\n }\n\n if (only === \"frontmatter\") {\n return {\n code: `export const frontmatter = ${JSON.stringify(matter.data)}`,\n map: null,\n };\n }\n\n // ensure the line number is correct in dev mode\n const lineOffset = isDevelopment ? countLines(matter.matter) : 0;\n\n const { buildMDX } = await import(\"@/collections/mdx/build-mdx\");\n const compiled = await buildMDX(core, collection, {\n isDevelopment,\n source: \"\\n\".repeat(lineOffset) + matter.content,\n filePath,\n frontmatter: matter.data as Record<string, unknown>,\n _compiler: compiler,\n environment: \"bundler\",\n });\n\n const out = {\n code: String(compiled.value),\n map: compiled.map as SourceMap,\n };\n\n await after?.();\n return out;\n },\n };\n}\n\nfunction generateCacheHash(input: string): string {\n return createHash(\"md5\").update(input).digest(\"hex\");\n}\n\nfunction countLines(s: string) {\n let num = 0;\n\n for (const c of s) {\n if (c === \"\\n\") num++;\n }\n\n return num;\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,cAAc,EACjB,OAAO;CACN,MAAM,EAAE,QAAQ,CAAC,eAAe,MAAM,CAAC,CAAC,QAAQ,MAAM;CACtD,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,WAAW,EAAE,QAAQ,CAAC,UAAU;CACjC,CAAC,CACD,OAAO;AAEV,MAAM,aAAa,EAAE,OAAO;CAC1B,MAAM,EAAE,QAAQ;CAChB,KAAK,EAAE,KAAK,CAAC,UAAU;CACvB,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC5B,CAAC;AAIF,SAAgB,gBAAgB,EAAE,WAAgC;AAChE,QAAO,EACL,MAAM,KAAK,EAAE,WAAW,aAAa,eAAe,OAAO,UAAU,YAAY;EAC/E,IAAI,OAAO,MAAM,SAAS;EAC1B,MAAM,QAAQ,MAAM,WAAW;EAC/B,MAAM,SAAS,WAAW,MAAM;EAChC,MAAM,EAAE,YAAY,gBAAgB,WAAW,SAAS,YAAY,MAAM,MAAM;AAChF,MAAI,UACF,QAAO,KAAK,eAAe,CAAC,IAAI,UAAU,IAAI;EAGhD,IAAIA;EAEJ,MAAM,EAAE,yBAAyB,UAAU,KAAK,WAAW;AAC3D,MAAI,CAAC,iBAAiB,wBAAwB;GAC5C,MAAM,WAAW;GACjB,MAAM,WAAW,GAAG,kBAAkB,SAAS,GAAG,kBAAkB,SAAS;GAE7E,MAAM,SAAS,MAAM,GAClB,SAAS,KAAK,KAAK,UAAU,SAAS,CAAC,CACvC,MAAM,YAAY,WAAW,MAAM,KAAK,MAAM,QAAQ,UAAU,CAAC,CAAC,CAAC,CACnE,YAAY,KAAK;AAEpB,OAAI,UAAU,OAAO,SAAS,kBAAkB,MAAM,CAAE,QAAO;AAC/D,WAAQ,YAAY;AAClB,UAAM,GAAG,MAAM,UAAU,EAAE,WAAW,MAAM,CAAC;AAC7C,UAAM,GAAG,UACP,KAAK,KAAK,UAAU,SAAS,EAC7B,KAAK,UAAU;KACb,GAAG;KACH,MAAM,kBAAkB,MAAM;KAC/B,CAAsB,CACxB;;;EAIL,IAAI,aAAa,iBAAiB,KAAK,cAAc,eAAe,GAAG;AACvE,MAAI,EAAE,sBAAsB,eAAgB,cAAa;AAEzD,MAAI,YAAY,YACd,QAAO,OAAO,MAAM,WAAW,YAAY,IAAI,OAAO,MAAiC;GACrF;GACA;GACA,QAAQ;GACT,CAAC;AAGJ,MAAI,SAAS,cACX,QAAO;GACL,MAAM,8BAA8B,KAAK,UAAU,OAAO,KAAK;GAC/D,KAAK;GACN;EAIH,MAAM,aAAa,gBAAgB,WAAW,OAAO,OAAO,GAAG;EAE/D,MAAM,EAAE,aAAa,MAAM,OAAO;EAClC,MAAM,WAAW,MAAM,SAAS,MAAM,YAAY;GAChD;GACA,QAAQ,KAAK,OAAO,WAAW,GAAG,OAAO;GACzC;GACA,aAAa,OAAO;GACpB,WAAW;GACX,aAAa;GACd,CAAC;EAEF,MAAM,MAAM;GACV,MAAM,OAAO,SAAS,MAAM;GAC5B,KAAK,SAAS;GACf;AAED,QAAM,SAAS;AACf,SAAO;IAEV;;AAGH,SAAS,kBAAkB,OAAuB;AAChD,QAAO,WAAW,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;AAGtD,SAAS,WAAW,GAAW;CAC7B,IAAI,MAAM;AAEV,MAAK,MAAM,KAAK,EACd,KAAI,MAAM,KAAM;AAGlB,QAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createDataLoader } from "./loader-
|
|
1
|
+
import { t as createDataLoader } from "./loader-CuntMmR4.js";
|
|
2
2
|
import { load } from "js-yaml";
|
|
3
3
|
|
|
4
4
|
//#region src/collections/yaml/loader.ts
|
|
@@ -14,4 +14,4 @@ function createYamlLoader(core) {
|
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
export { createYamlLoader as t };
|
|
17
|
-
//# sourceMappingURL=loader-
|
|
17
|
+
//# sourceMappingURL=loader-Cnz-VHne.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-
|
|
1
|
+
{"version":3,"file":"loader-Cnz-VHne.js","names":[],"sources":["../src/collections/yaml/loader.ts"],"sourcesContent":["import type { Loader } from \"@/plugins/loader\";\nimport { load } from \"js-yaml\";\nimport type { DynamicCore } from \"@/dynamic\";\nimport { createDataLoader } from \"../data/loader\";\n\nexport function createYamlLoader(core: DynamicCore): Loader {\n return createDataLoader(core, (filePath, source) => {\n try {\n return load(source) as Record<string, unknown>;\n } catch (e) {\n throw new Error(`invalid data in ${filePath}`, { cause: e });\n }\n });\n}\n"],"mappings":";;;;AAKA,SAAgB,iBAAiB,MAA2B;AAC1D,QAAO,iBAAiB,OAAO,UAAU,WAAW;AAClD,MAAI;AACF,UAAO,KAAK,OAAO;WACZ,GAAG;AACV,SAAM,IAAI,MAAM,mBAAmB,YAAY,EAAE,OAAO,GAAG,CAAC;;GAE9D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as validate } from "./validation-BvVvvLII.js";
|
|
2
|
-
import { t as DataCollection } from "./data-
|
|
2
|
+
import { t as DataCollection } from "./data-Cxsx5KPD.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/collections/data/loader.ts
|
|
@@ -56,4 +56,4 @@ function createDataLoader({ getCore }, parse, moduleType = "js") {
|
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
58
|
export { createDataLoader as t };
|
|
59
|
-
//# sourceMappingURL=loader-
|
|
59
|
+
//# sourceMappingURL=loader-CuntMmR4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-
|
|
1
|
+
{"version":3,"file":"loader-CuntMmR4.js","names":["data: unknown","context: DataTransformationContext"],"sources":["../src/collections/data/loader.ts"],"sourcesContent":["import type { Loader, LoaderInput } from \"@/plugins/loader\";\nimport { z } from \"zod\";\nimport { validate } from \"@/utils/validation\";\nimport { DataCollection, type DataTransformationContext } from \"@/collections/data\";\nimport type { DynamicCore } from \"@/dynamic\";\n\nconst querySchema = z\n .object({\n collection: z.string().optional(),\n workspace: z.string().optional(),\n })\n .loose();\n\n/**\n * load data files, fallback to bundler's built-in plugins when ?collection is unspecified.\n */\nexport function createDataLoader(\n { getCore }: DynamicCore,\n parse: (filePath: string, source: string) => Record<string, unknown>,\n moduleType: \"json\" | \"js\" = \"js\",\n): Loader {\n function getCollectionProcessor({ filePath, query }: LoaderInput) {\n const parsed = querySchema.safeParse(query);\n if (!parsed.success || !parsed.data.collection) return null;\n const { collection: collectionName, workspace } = parsed.data;\n\n return async (source: string): Promise<unknown> => {\n let core = await getCore();\n if (workspace) {\n core = core.getWorkspaces().get(workspace) ?? core;\n }\n\n let collection = core.getCollection(collectionName);\n let data: unknown = parse(filePath, source);\n if (!collection || !(collection instanceof DataCollection)) return data;\n\n const context: DataTransformationContext = {\n path: filePath,\n source,\n };\n\n if (collection.schema) {\n data = await validate(collection.schema, data, context, `invalid data in ${filePath}`);\n }\n\n return collection.onLoad.run(data, context);\n };\n }\n\n return {\n async load(input) {\n const processor = getCollectionProcessor(input);\n if (processor === null) return null;\n const data = await processor(await input.getSource());\n\n if (moduleType === \"json\") {\n return {\n code: JSON.stringify(data),\n moduleType,\n };\n } else {\n return {\n code: `export default ${JSON.stringify(data)}`,\n };\n }\n },\n bun: {\n load(source, input) {\n const processor = getCollectionProcessor(input);\n if (processor === null)\n return {\n loader: \"object\",\n exports: parse(input.filePath, source),\n };\n\n return processor(source).then((data) => ({\n loader: \"object\",\n exports: { default: data },\n }));\n },\n },\n };\n}\n"],"mappings":";;;;;AAMA,MAAM,cAAc,EACjB,OAAO;CACN,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,WAAW,EAAE,QAAQ,CAAC,UAAU;CACjC,CAAC,CACD,OAAO;;;;AAKV,SAAgB,iBACd,EAAE,WACF,OACA,aAA4B,MACpB;CACR,SAAS,uBAAuB,EAAE,UAAU,SAAsB;EAChE,MAAM,SAAS,YAAY,UAAU,MAAM;AAC3C,MAAI,CAAC,OAAO,WAAW,CAAC,OAAO,KAAK,WAAY,QAAO;EACvD,MAAM,EAAE,YAAY,gBAAgB,cAAc,OAAO;AAEzD,SAAO,OAAO,WAAqC;GACjD,IAAI,OAAO,MAAM,SAAS;AAC1B,OAAI,UACF,QAAO,KAAK,eAAe,CAAC,IAAI,UAAU,IAAI;GAGhD,IAAI,aAAa,KAAK,cAAc,eAAe;GACnD,IAAIA,OAAgB,MAAM,UAAU,OAAO;AAC3C,OAAI,CAAC,cAAc,EAAE,sBAAsB,gBAAiB,QAAO;GAEnE,MAAMC,UAAqC;IACzC,MAAM;IACN;IACD;AAED,OAAI,WAAW,OACb,QAAO,MAAM,SAAS,WAAW,QAAQ,MAAM,SAAS,mBAAmB,WAAW;AAGxF,UAAO,WAAW,OAAO,IAAI,MAAM,QAAQ;;;AAI/C,QAAO;EACL,MAAM,KAAK,OAAO;GAChB,MAAM,YAAY,uBAAuB,MAAM;AAC/C,OAAI,cAAc,KAAM,QAAO;GAC/B,MAAM,OAAO,MAAM,UAAU,MAAM,MAAM,WAAW,CAAC;AAErD,OAAI,eAAe,OACjB,QAAO;IACL,MAAM,KAAK,UAAU,KAAK;IAC1B;IACD;OAED,QAAO,EACL,MAAM,kBAAkB,KAAK,UAAU,KAAK,IAC7C;;EAGL,KAAK,EACH,KAAK,QAAQ,OAAO;GAClB,MAAM,YAAY,uBAAuB,MAAM;AAC/C,OAAI,cAAc,KAChB,QAAO;IACL,QAAQ;IACR,SAAS,MAAM,MAAM,UAAU,OAAO;IACvC;AAEH,UAAO,UAAU,OAAO,CAAC,MAAM,UAAU;IACvC,QAAQ;IACR,SAAS,EAAE,SAAS,MAAM;IAC3B,EAAE;KAEN;EACF"}
|